Commit 7154cff7a5604ea7a8e2096361ee55fa038652e0
1 parent
e77e567c
Exists in
master
and in
3 other branches
Implementing IPC calls.
Showing
4 changed files
with
137 additions
and
11 deletions
Show diff stats
src/include/lib3270++.h
@@ -243,10 +243,10 @@ | @@ -243,10 +243,10 @@ | ||
243 | } | 243 | } |
244 | 244 | ||
245 | /// @brief Set cursor address. | 245 | /// @brief Set cursor address. |
246 | - virtual void setCursorPosition(unsigned short addr) = 0; | 246 | + virtual TN3270::Session & setCursorPosition(unsigned short addr) = 0; |
247 | 247 | ||
248 | /// @brief Set cursor position. | 248 | /// @brief Set cursor position. |
249 | - virtual void setCursorPosition(unsigned short row, unsigned short col) = 0; | 249 | + virtual TN3270::Session & setCursorPosition(unsigned short row, unsigned short col) = 0; |
250 | 250 | ||
251 | virtual Session & push(int baddr, const std::string &text) = 0; | 251 | virtual Session & push(int baddr, const std::string &text) = 0; |
252 | virtual Session & push(int row, int col, const std::string &text) = 0; | 252 | virtual Session & push(int row, int col, const std::string &text) = 0; |
src/lib3270++/ipc/session.cc
@@ -127,59 +127,169 @@ | @@ -127,59 +127,169 @@ | ||
127 | 127 | ||
128 | /// @brief Set field at current position, jumps to next writable field. | 128 | /// @brief Set field at current position, jumps to next writable field. |
129 | TN3270::Session & IPC::Session::push(const char *text) { | 129 | TN3270::Session & IPC::Session::push(const char *text) { |
130 | - throw std::system_error(EINVAL, std::system_category()); | 130 | + |
131 | + int rc; | ||
132 | + | ||
133 | + Request(*this,"setString") | ||
134 | + .push(text) | ||
135 | + .call() | ||
136 | + .pop(rc); | ||
137 | + | ||
138 | + if(rc) { | ||
139 | + throw std::system_error((int) rc, std::system_category()); | ||
140 | + } | ||
141 | + | ||
142 | + return *this; | ||
143 | + | ||
131 | } | 144 | } |
132 | 145 | ||
133 | TN3270::Session & IPC::Session::push(int baddr, const std::string &text) { | 146 | TN3270::Session & IPC::Session::push(int baddr, const std::string &text) { |
134 | 147 | ||
148 | + int rc; | ||
149 | + | ||
150 | + Request(*this,"setStringAtAddress") | ||
151 | + .push((uint32_t) baddr) | ||
152 | + .push(text.c_str()) | ||
153 | + .call() | ||
154 | + .pop(rc); | ||
155 | + | ||
156 | + if(rc) { | ||
157 | + throw std::system_error((int) rc, std::system_category()); | ||
158 | + } | ||
135 | 159 | ||
136 | return *this; | 160 | return *this; |
161 | + | ||
137 | } | 162 | } |
138 | 163 | ||
139 | TN3270::Session & IPC::Session::push(int row, int col, const std::string &text) { | 164 | TN3270::Session & IPC::Session::push(int row, int col, const std::string &text) { |
140 | 165 | ||
166 | + int32_t rc; | ||
167 | + | ||
168 | + Request(*this,"setStringAt") | ||
169 | + .push((uint32_t) row) | ||
170 | + .push((uint32_t) col) | ||
171 | + .push(text.c_str()) | ||
172 | + .call() | ||
173 | + .pop(rc); | ||
174 | + | ||
175 | + if(rc) { | ||
176 | + throw std::system_error((int) rc, std::system_category()); | ||
177 | + } | ||
141 | 178 | ||
142 | return *this; | 179 | return *this; |
180 | + | ||
143 | } | 181 | } |
144 | 182 | ||
145 | TN3270::Session & IPC::Session::push(const PFKey key) { | 183 | TN3270::Session & IPC::Session::push(const PFKey key) { |
146 | 184 | ||
185 | + int32_t rc; | ||
186 | + | ||
187 | + Request(*this,"pfkey") | ||
188 | + .push((uint32_t) key) | ||
189 | + .call() | ||
190 | + .pop(rc); | ||
191 | + | ||
192 | + if(rc) { | ||
193 | + throw std::system_error((int) rc, std::system_category()); | ||
194 | + } | ||
147 | 195 | ||
148 | return *this; | 196 | return *this; |
197 | + | ||
149 | } | 198 | } |
150 | 199 | ||
151 | TN3270::Session & IPC::Session::push(const PAKey key) { | 200 | TN3270::Session & IPC::Session::push(const PAKey key) { |
152 | 201 | ||
202 | + int32_t rc; | ||
203 | + | ||
204 | + Request(*this,"pakey") | ||
205 | + .push((uint32_t) key) | ||
206 | + .call() | ||
207 | + .pop(rc); | ||
208 | + | ||
209 | + if(rc) { | ||
210 | + throw std::system_error((int) rc, std::system_category()); | ||
211 | + } | ||
153 | 212 | ||
154 | return *this; | 213 | return *this; |
214 | + | ||
155 | } | 215 | } |
156 | 216 | ||
157 | TN3270::Session & IPC::Session::push(const Action action) { | 217 | TN3270::Session & IPC::Session::push(const Action action) { |
158 | 218 | ||
219 | + const char * actions[] = { | ||
220 | + "enter", | ||
221 | + "erase", | ||
222 | + "eraseeof", | ||
223 | + "eraseeol", | ||
224 | + "eraseinput" | ||
225 | + }; | ||
226 | + | ||
227 | + int32_t rc; | ||
228 | + | ||
229 | + if( ((size_t) action) > (sizeof(actions)/sizeof(actions[0]))) { | ||
230 | + throw std::system_error(EINVAL, std::system_category()); | ||
231 | + } | ||
232 | + | ||
233 | + Request(*this,actions[(size_t) action]) | ||
234 | + .call() | ||
235 | + .pop(rc); | ||
236 | + | ||
237 | + if(rc) { | ||
238 | + throw std::system_error((int) rc, std::system_category()); | ||
239 | + } | ||
240 | + | ||
159 | return *this; | 241 | return *this; |
242 | + | ||
160 | } | 243 | } |
161 | 244 | ||
162 | TN3270::Session & IPC::Session::pop(int baddr, std::string &text) { | 245 | TN3270::Session & IPC::Session::pop(int baddr, std::string &text) { |
163 | 246 | ||
247 | + Request(*this,"getFieldAtAddress") | ||
248 | + .push((uint32_t) baddr) | ||
249 | + .call() | ||
250 | + .pop(text); | ||
164 | 251 | ||
165 | return *this; | 252 | return *this; |
166 | } | 253 | } |
167 | 254 | ||
168 | TN3270::Session & IPC::Session::pop(int row, int col, std::string &text) { | 255 | TN3270::Session & IPC::Session::pop(int row, int col, std::string &text) { |
169 | 256 | ||
257 | + Request(*this,"getFieldAt") | ||
258 | + .push((uint32_t) row) | ||
259 | + .push((uint32_t) col) | ||
260 | + .call() | ||
261 | + .pop(text); | ||
262 | + | ||
170 | return *this; | 263 | return *this; |
171 | } | 264 | } |
172 | 265 | ||
173 | TN3270::Session & IPC::Session::pop(std::string &text) { | 266 | TN3270::Session & IPC::Session::pop(std::string &text) { |
174 | 267 | ||
268 | + Request(*this,"getFieldAtCursor") | ||
269 | + .call() | ||
270 | + .pop(text); | ||
271 | + | ||
175 | return *this; | 272 | return *this; |
273 | + | ||
176 | } | 274 | } |
177 | 275 | ||
178 | /// @brief Set cursor address. | 276 | /// @brief Set cursor address. |
179 | /// | 277 | /// |
180 | /// @param addr Cursor address. | 278 | /// @param addr Cursor address. |
181 | - void IPC::Session::setCursorPosition(unsigned short addr) { | 279 | + TN3270::Session & IPC::Session::setCursorPosition(unsigned short addr) { |
280 | + | ||
281 | + int32_t rc; | ||
182 | 282 | ||
283 | + Request(*this,"setCursorAddress") | ||
284 | + .push((uint32_t) addr) | ||
285 | + .call() | ||
286 | + .pop(rc); | ||
287 | + | ||
288 | + if(rc) { | ||
289 | + throw std::system_error((int) rc, std::system_category()); | ||
290 | + } | ||
291 | + | ||
292 | + return *this; | ||
183 | 293 | ||
184 | } | 294 | } |
185 | 295 | ||
@@ -187,8 +297,21 @@ | @@ -187,8 +297,21 @@ | ||
187 | /// | 297 | /// |
188 | /// @param row New cursor row. | 298 | /// @param row New cursor row. |
189 | /// @param col New cursor column. | 299 | /// @param col New cursor column. |
190 | - void IPC::Session::setCursorPosition(unsigned short row, unsigned short col) { | 300 | + TN3270::Session & IPC::Session::setCursorPosition(unsigned short row, unsigned short col) { |
191 | 301 | ||
302 | + int32_t rc; | ||
303 | + | ||
304 | + Request(*this,"setCursorPosition") | ||
305 | + .push((uint32_t) row) | ||
306 | + .push((uint32_t) col) | ||
307 | + .call() | ||
308 | + .pop(rc); | ||
309 | + | ||
310 | + if(rc) { | ||
311 | + throw std::system_error((int) rc, std::system_category()); | ||
312 | + } | ||
313 | + | ||
314 | + return *this; | ||
192 | 315 | ||
193 | } | 316 | } |
194 | 317 |
src/lib3270++/local/session.cc
@@ -344,24 +344,27 @@ | @@ -344,24 +344,27 @@ | ||
344 | /// @brief Set cursor address. | 344 | /// @brief Set cursor address. |
345 | /// | 345 | /// |
346 | /// @param addr Cursor address. | 346 | /// @param addr Cursor address. |
347 | - void Local::Session::setCursorPosition(unsigned short addr) { | 347 | + TN3270::Session & Local::Session::setCursorPosition(unsigned short addr) { |
348 | 348 | ||
349 | if(lib3270_set_cursor_address(hSession,addr) < 0) { | 349 | if(lib3270_set_cursor_address(hSession,addr) < 0) { |
350 | throw std::system_error(errno, std::system_category()); | 350 | throw std::system_error(errno, std::system_category()); |
351 | } | 351 | } |
352 | 352 | ||
353 | + return *this; | ||
353 | } | 354 | } |
354 | 355 | ||
355 | /// @brief Set cursor position. | 356 | /// @brief Set cursor position. |
356 | /// | 357 | /// |
357 | /// @param row New cursor row. | 358 | /// @param row New cursor row. |
358 | /// @param col New cursor column. | 359 | /// @param col New cursor column. |
359 | - void Local::Session::setCursorPosition(unsigned short row, unsigned short col) { | 360 | + TN3270::Session & Local::Session::setCursorPosition(unsigned short row, unsigned short col) { |
360 | 361 | ||
361 | if(lib3270_set_cursor_position(hSession,row,col)) { | 362 | if(lib3270_set_cursor_position(hSession,row,col)) { |
362 | throw std::system_error(errno, std::system_category()); | 363 | throw std::system_error(errno, std::system_category()); |
363 | } | 364 | } |
364 | 365 | ||
366 | + return *this; | ||
367 | + | ||
365 | } | 368 | } |
366 | 369 | ||
367 | // Get properties. | 370 | // Get properties. |
src/lib3270++/private.h
@@ -192,8 +192,8 @@ | @@ -192,8 +192,8 @@ | ||
192 | 192 | ||
193 | ConnectionState getConnectionState() const override; | 193 | ConnectionState getConnectionState() const override; |
194 | 194 | ||
195 | - void setCursorPosition(unsigned short addr); | ||
196 | - void setCursorPosition(unsigned short row, unsigned short col); | 195 | + TN3270::Session & setCursorPosition(unsigned short addr) override; |
196 | + TN3270::Session & setCursorPosition(unsigned short row, unsigned short col) override; | ||
197 | 197 | ||
198 | /// @brief Set field at current posicion, jumps to next writable field. | 198 | /// @brief Set field at current posicion, jumps to next writable field. |
199 | TN3270::Session & push(const char *text) override; | 199 | TN3270::Session & push(const char *text) override; |
@@ -353,8 +353,8 @@ | @@ -353,8 +353,8 @@ | ||
353 | 353 | ||
354 | ConnectionState getConnectionState() const override; | 354 | ConnectionState getConnectionState() const override; |
355 | 355 | ||
356 | - void setCursorPosition(unsigned short addr); | ||
357 | - void setCursorPosition(unsigned short row, unsigned short col); | 356 | + TN3270::Session & setCursorPosition(unsigned short addr) override; |
357 | + TN3270::Session & setCursorPosition(unsigned short row, unsigned short col) override; | ||
358 | 358 | ||
359 | /// @brief Set field at current posicion, jumps to next writable field. | 359 | /// @brief Set field at current posicion, jumps to next writable field. |
360 | TN3270::Session & push(const char *text) override; | 360 | TN3270::Session & push(const char *text) override; |