Commit 960224f294cfca30d738cded38cee3cbe267b2f3
1 parent
f3bfb8d6
Exists in
master
and in
1 other branch
Updating properties and getter/setter c++ methods.
Showing
4 changed files
with
68 additions
and
4 deletions
Show diff stats
ipc/session.cc
... | ... | @@ -235,6 +235,10 @@ |
235 | 235 | |
236 | 236 | } |
237 | 237 | |
238 | + void IPC::Session::getProperty(const char *name, bool &value) const { | |
239 | + throw std::system_error(ENOENT, std::system_category()); | |
240 | + } | |
241 | + | |
238 | 242 | /// @brief Get lib3270 version. |
239 | 243 | std::string IPC::Session::getVersion() const { |
240 | 244 | ... | ... |
local/session.cc
... | ... | @@ -38,9 +38,10 @@ |
38 | 38 | |
39 | 39 | #include "../private.h" |
40 | 40 | #include <lib3270/actions.h> |
41 | + #include <lib3270/properties.h> | |
42 | + #include <cstring> | |
41 | 43 | |
42 | 44 | extern "C" { |
43 | - #include <lib3270/actions.h> | |
44 | 45 | #include <lib3270/session.h> |
45 | 46 | } |
46 | 47 | |
... | ... | @@ -149,11 +150,68 @@ |
149 | 150 | } |
150 | 151 | |
151 | 152 | void Local::Session::getProperty(const char *name, int &value) const { |
152 | - throw std::system_error(ENOTSUP, std::system_category()); | |
153 | + | |
154 | + const LIB3270_INT_PROPERTY * intprop = lib3270_get_int_properties_list(); | |
155 | + for(size_t ix = 0; intprop[ix].name; ix++) { | |
156 | + | |
157 | + if(!strcasecmp(name,intprop[ix].name)) { | |
158 | + | |
159 | + std::lock_guard<std::mutex> lock(const_cast<Local::Session *>(this)->sync); | |
160 | + | |
161 | + value = intprop[ix].get(hSession); | |
162 | + | |
163 | + if(value < 0 && errno != 0) { | |
164 | + throw std::system_error(errno, std::system_category()); | |
165 | + } | |
166 | + | |
167 | + | |
168 | + } | |
169 | + | |
170 | + } | |
171 | + | |
172 | + throw std::system_error(ENOENT, std::system_category()); | |
173 | + | |
153 | 174 | } |
154 | 175 | |
155 | 176 | void Local::Session::getProperty(const char *name, std::string &value) const { |
156 | - throw std::system_error(ENOTSUP, std::system_category()); | |
177 | + | |
178 | + const LIB3270_STRING_PROPERTY * strprop = lib3270_get_string_properties_list(); | |
179 | + | |
180 | + for(size_t ix = 0; strprop[ix].name; ix++) { | |
181 | + | |
182 | + if(!strcasecmp(name,strprop[ix].name)) { | |
183 | + | |
184 | + std::lock_guard<std::mutex> lock(const_cast<Local::Session *>(this)->sync); | |
185 | + | |
186 | + // Found it! | |
187 | + const char * str = strprop[ix].get(hSession); | |
188 | + | |
189 | + if(str) { | |
190 | + value.assign(str); | |
191 | + return; | |
192 | + } | |
193 | + | |
194 | + throw std::system_error(errno, std::system_category()); | |
195 | + | |
196 | + } | |
197 | + | |
198 | + } | |
199 | + | |
200 | + throw std::system_error(ENOENT, std::system_category()); | |
201 | + } | |
202 | + | |
203 | + void Local::Session::getProperty(const char *name, bool &value) const { | |
204 | + | |
205 | + LIB3270_TOGGLE toggle = lib3270_get_toggle_id(name); | |
206 | + if(toggle != (LIB3270_TOGGLE) -1) { | |
207 | + | |
208 | + // Is a Tn3270 toggle, get it! | |
209 | + std::lock_guard<std::mutex> lock(const_cast<Local::Session *>(this)->sync); | |
210 | + value = lib3270_get_toggle(hSession,toggle); | |
211 | + | |
212 | + } | |
213 | + | |
214 | + throw std::system_error(ENOENT, std::system_category()); | |
157 | 215 | } |
158 | 216 | |
159 | 217 | ProgramMessage Local::Session::getProgramMessage() const { | ... | ... |
private.h
... | ... | @@ -179,6 +179,7 @@ |
179 | 179 | // Get properties. |
180 | 180 | void getProperty(const char *name, int &value) const override; |
181 | 181 | void getProperty(const char *name, std::string &value) const override; |
182 | + void getProperty(const char *name, bool &value) const override; | |
182 | 183 | |
183 | 184 | std::string getVersion() const override; |
184 | 185 | std::string getRevision() const override; |
... | ... | @@ -312,6 +313,7 @@ |
312 | 313 | // Get properties. |
313 | 314 | void getProperty(const char *name, int &value) const override; |
314 | 315 | void getProperty(const char *name, std::string &value) const override; |
316 | + void getProperty(const char *name, bool &value) const override; | |
315 | 317 | |
316 | 318 | std::string getVersion() const override; |
317 | 319 | std::string getRevision() const override; | ... | ... |