Commit d43f266d8893895d929febd5161384f4c4bbde0e
1 parent
71e3beb1
Exists in
master
and in
3 other branches
Adding callback for URL change.
Showing
3 changed files
with
17 additions
and
8 deletions
Show diff stats
src/core/host.c
... | ... | @@ -219,20 +219,22 @@ void lib3270_st_changed(H3270 *h, LIB3270_STATE tx, int mode) |
219 | 219 | trace("%s ends",__FUNCTION__); |
220 | 220 | } |
221 | 221 | |
222 | -static void update_host(H3270 *h) | |
222 | +static void update_url(H3270 *hSession) | |
223 | 223 | { |
224 | - Replace(h->host.full, | |
224 | + Replace(hSession->host.full, | |
225 | 225 | lib3270_strdup_printf( |
226 | 226 | "%s%s:%s", |
227 | 227 | #ifdef HAVE_LIBSSL |
228 | - (h->ssl.enabled ? "tn3270s://" : "tn3270://"), | |
228 | + (hSession->ssl.enabled ? "tn3270s://" : "tn3270://"), | |
229 | 229 | #else |
230 | 230 | "tn3270://", |
231 | 231 | #endif // HAVE_LIBSSL |
232 | - h->host.current, | |
233 | - h->host.srvc | |
232 | + hSession->host.current, | |
233 | + hSession->host.srvc | |
234 | 234 | )); |
235 | 235 | |
236 | + hSession->cbk.update_url(hSession, hSession->host.full); | |
237 | + | |
236 | 238 | } |
237 | 239 | |
238 | 240 | LIB3270_EXPORT int lib3270_set_luname(H3270 *hSession, const char *luname) |
... | ... | @@ -381,7 +383,7 @@ LIB3270_EXPORT int lib3270_set_url(H3270 *h, const char *n) |
381 | 383 | } |
382 | 384 | |
383 | 385 | // Notifica atualização |
384 | - update_host(h); | |
386 | + update_url(h); | |
385 | 387 | |
386 | 388 | return 0; |
387 | 389 | } |
... | ... | @@ -398,7 +400,7 @@ LIB3270_EXPORT void lib3270_set_hostname(H3270 *h, const char *hostname) |
398 | 400 | { |
399 | 401 | CHECK_SESSION_HANDLE(h); |
400 | 402 | Replace(h->host.current,strdup(hostname)); |
401 | - update_host(h); | |
403 | + update_url(h); | |
402 | 404 | } |
403 | 405 | |
404 | 406 | LIB3270_EXPORT const char * lib3270_get_srvcname(const H3270 *h) |
... | ... | @@ -412,7 +414,7 @@ LIB3270_EXPORT void lib3270_set_srvcname(H3270 *h, const char *srvc) |
412 | 414 | { |
413 | 415 | CHECK_SESSION_HANDLE(h); |
414 | 416 | Replace(h->host.srvc,strdup(srvc)); |
415 | - update_host(h); | |
417 | + update_url(h); | |
416 | 418 | } |
417 | 419 | |
418 | 420 | LIB3270_EXPORT const char * lib3270_get_host(const H3270 *h) | ... | ... |
src/core/session.c
... | ... | @@ -273,6 +273,11 @@ static void default_update_luname(H3270 GNUC_UNUSED(*session), const char GNUC_U |
273 | 273 | { |
274 | 274 | } |
275 | 275 | |
276 | +static void default_update_url(H3270 GNUC_UNUSED(*session), const char GNUC_UNUSED(*url)) | |
277 | +{ | |
278 | +} | |
279 | + | |
280 | + | |
276 | 281 | void lib3270_reset_callbacks(H3270 *hSession) |
277 | 282 | { |
278 | 283 | // Default calls |
... | ... | @@ -306,6 +311,7 @@ void lib3270_reset_callbacks(H3270 *hSession) |
306 | 311 | hSession->cbk.load = load; |
307 | 312 | hSession->cbk.set_peer_certificate = set_peer_certificate; |
308 | 313 | hSession->cbk.update_luname = default_update_luname; |
314 | + hSession->cbk.update_url = default_update_url; | |
309 | 315 | } |
310 | 316 | |
311 | 317 | static void lib3270_session_init(H3270 *hSession, const char *model, const char *charset) | ... | ... |
src/include/lib3270/session.h
... | ... | @@ -66,6 +66,7 @@ |
66 | 66 | void (*update_model)(H3270 *session, const char *name, int model, int rows, int cols); |
67 | 67 | void (*update_selection)(H3270 *session, int start, int end); |
68 | 68 | void (*update_ssl)(H3270 *session, LIB3270_SSL_STATE state); |
69 | + void (*update_url)(H3270 *session, const char *url); | |
69 | 70 | |
70 | 71 | void (*set_timer)(H3270 *session, unsigned char on); |
71 | 72 | void (*erase)(H3270 *session); | ... | ... |