diff options
author | nags <nags@nags-desktop.(none)> | 2009-08-13 21:30:53 -0700 |
---|---|---|
committer | nags <nags@nags-desktop.(none)> | 2009-08-13 21:30:53 -0700 |
commit | cc030db89688e9ca72edec15955928146e02e24b (patch) | |
tree | 77ea9540258d84e2513411bbbb8e87dcc0d9b680 | |
parent | 925d7142d8a58e63264663900f159d7ebadb25ae (diff) |
2009-08-13 Nagappan Alagappan <nagappan@gmail.com>
* ldtp.c (report_window_event): Fixes bug 591753 – On window
callback exit ldtp crashes.
* device.c (get_keyboard_keycodes): Fixes ldtp crash when xmodmap
doesn't exist in path. This was a regression from the previous fix
of bug 590755 - Keycodes mismatch using generatekeyevent from
python-ldtp.
-rw-r--r-- | src/ChangeLog | 10 | ||||
-rw-r--r-- | src/device.c | 35 | ||||
-rw-r--r-- | src/ldtp.c | 68 |
3 files changed, 67 insertions, 46 deletions
diff --git a/src/ChangeLog b/src/ChangeLog index c723aa1..94ee5b1 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,13 @@ +2009-08-13 Nagappan Alagappan <nagappan@gmail.com> + + * ldtp.c (report_window_event): Fixes bug 591753 – On window + callback exit ldtp crashes. + + * device.c (get_keyboard_keycodes): Fixes ldtp crash when xmodmap + doesn't exist in path. This was a regression from the previous fix + of bug 590755 - Keycodes mismatch using generatekeyevent from + python-ldtp. + 2009-08-12 José Luis Segura Lucas <josel.segura@gmx.es> * device.c (get_keyboard_keycodes): Fixes bug 590755, Keycodes diff --git a/src/device.c b/src/device.c index 9aa5485..a7735ef 100644 --- a/src/device.c +++ b/src/device.c @@ -452,7 +452,7 @@ get_keyboard_keycodes() { int keycode; gchar **lines; gchar *line; - int i; + int i, status; int index = 0; struct NonPrint_Key_Synth old_NonPrint_Key_Synth_Vals[] = {{"escape", 9}, {"esc", 9}, {"backspace", 22}, @@ -476,35 +476,40 @@ get_keyboard_keycodes() { src = (char *) malloc(sizeof(char) * 100); readed = 0; - fd = popen("xmodmap -pke", "r"); + fd = popen("xmodmap -pke 2>/dev/null", "r"); while ( ! feof(fd)) { readed += fread(src + readed, 1, 100, fd); src = (char *) realloc(src, sizeof(char)*(readed+100)); } - pclose(fd); + status = pclose(fd); - lines = g_strsplit(src, "\n", 0); + if (status != -1) { + lines = g_strsplit(src, "\n", 0); - for (index=0; lines != NULL && strcmp(*lines, ""); lines++) { - gchar **split; - line = *lines; + for (index=0; lines != NULL && strcmp(*lines, ""); lines++) { + gchar **split; + line = *lines; - split = g_strsplit(line, "=", 2); - keycode = atoi(split[0] + 7); + split = g_strsplit(line, "=", 2); + keycode = atoi(split[0] + 7); - if (strlen(split[1]) > 0) { - gchar **space_split = g_strsplit(split[1], " ", 3); - NonPrint_Key_Synth_Vals[index].sym = space_split[1]; - NonPrint_Key_Synth_Vals[index].KeyVal = keycode; - index++; + if (strlen(split[1]) > 0) { + gchar **space_split = g_strsplit(split[1], " ", 3); + NonPrint_Key_Synth_Vals[index].sym = space_split[1]; + NonPrint_Key_Synth_Vals[index].KeyVal = keycode; + index++; + } } + } else if (src) { + g_free (src); + src = NULL; } int old_len = sizeof(old_NonPrint_Key_Synth_Vals) / sizeof(struct NonPrint_Key_Synth); - for(i=0 ; index < 300 && i < old_len; index++, i++) + for(i = 0 ; index < 300 && i < old_len; index++, i++) NonPrint_Key_Synth_Vals[index] = old_NonPrint_Key_Synth_Vals[i]; NonPrint_Key_Synth_Vals[index].sym = NULL; @@ -76,16 +76,11 @@ static GOptionEntry entries [] = #endif static LDTPClientContext* -is_window_reg_for_events (char *context, char *window_name) +is_window_reg_for_events (char *context) { LDTPClientContext *cctxt = NULL; if (event_notifier) { cctxt = g_hash_table_find (event_notifier, search_title_based, context); - if (cctxt && context && cctxt->req && cctxt->req->context) { - g_print ("Registered window title: %s - %s\n", context, cctxt->req->context); - return cctxt; - } - cctxt = g_hash_table_find (event_notifier, search_title_based, window_name); if (cctxt && context && cctxt->req && cctxt->req->context) g_print ("Registered window title: %s - %s\n", context, cctxt->req->context); } @@ -128,6 +123,7 @@ report_window_event (const AccessibleEvent *event, void *user_data) g_print ("Event type: %s\n", event->type); if (g_ascii_strcasecmp ("window:create", event->type) == 0) { uint32_t resp_size = 0; + gboolean flag = FALSE; LDTPErrorCode status; char *resp_pckt = NULL; char *window_name = NULL; @@ -174,38 +170,48 @@ report_window_event (const AccessibleEvent *event, void *user_data) SPI_freeString (title); return; } - if ((cctxt = is_window_reg_for_events (window_name, title))) { - /* - Notify to client - */ - if (!cctxt || !cctxt->resp) { - g_print ("CCTXT is lost\n"); - g_free (window_name); - SPI_freeString (title); - return; - } - cctxt->resp->data = g_strdup (window_name); - cctxt->resp->data_len = g_utf8_strlen (window_name, -1); - cctxt->resp->resp_status = LDTP_ERROR_SUCCESS; - - generate_notification_packet (cctxt, &status, &resp_pckt, &resp_size); - if (status != LDTP_ERROR_SUCCESS) { - SPI_freeString (title); - g_free (window_name); - g_print ("Error generating notification\n"); - return; - } - if (resp_pckt) - g_print ("Notification: %s - Len - %d", resp_pckt, resp_size); - send_response (cctxt->sock_fd, resp_pckt, resp_size, &status); + cctxt = is_window_reg_for_events (window_name); + if (!cctxt) { + cctxt = is_window_reg_for_events (title); + flag = TRUE; + } + if (!cctxt || !cctxt->resp) { + g_print ("CCTXT is lost\n"); + g_free (window_name); + SPI_freeString (title); + return; + } + /* + Notify to client + */ + if (cctxt->resp->data) { g_free (cctxt->resp->data); cctxt->resp->data = NULL; + } + if (flag) { + cctxt->resp->data = g_strdup (title); + cctxt->resp->data_len = g_utf8_strlen (title, -1); + } else { + cctxt->resp->data = g_strdup (window_name); + cctxt->resp->data_len = g_utf8_strlen (window_name, -1); + } + cctxt->resp->resp_status = LDTP_ERROR_SUCCESS; + + generate_notification_packet (cctxt, &status, &resp_pckt, &resp_size); + if (status != LDTP_ERROR_SUCCESS) { SPI_freeString (title); g_free (window_name); + g_print ("Error generating notification\n"); return; } - g_free (window_name); + if (resp_pckt) + g_print ("Notification: %s - Len - %d", resp_pckt, resp_size); + send_response (cctxt->sock_fd, resp_pckt, resp_size, &status); + g_free (cctxt->resp->data); + cctxt->resp->data = NULL; SPI_freeString (title); + g_free (window_name); + return; } else if (g_ascii_strcasecmp ("window:close", event->type) == 0 || g_ascii_strcasecmp ("window:deactivate", event->type) == 0 || g_ascii_strcasecmp ("window:destroy", event->type) == 0) { |