summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJosé Roberto de Souza <zehortigoza@profusion.mobi>2013-01-07 15:20:16 +0000
committerLucas De Marchi <lucas.demarchi@profusion.mobi>2013-01-07 15:20:16 +0000
commit96904096361721ef62872c4f4446a86937a60e91 (patch)
treebd0481d5192c814d052322ede42e6437994cbc10 /src
parent984a147f9b93d24871a3085e59dff2e3893b7429 (diff)
edbus: Fix signal handler extra match check
When an extra argument didn't match, instead of going to the next signal handler we were skiping to next extra match argument because we were calling "continue" inside EINA_INLIST_FOREACH. Patch by: José Roberto de Souza <zehortigoza@profusion.mobi> SVN revision: 82351
Diffstat (limited to 'src')
-rw-r--r--src/lib/edbus/edbus_core.c53
1 files changed, 32 insertions, 21 deletions
diff --git a/src/lib/edbus/edbus_core.c b/src/lib/edbus/edbus_core.c
index f060ee8bcd..af3742c238 100644
--- a/src/lib/edbus/edbus_core.c
+++ b/src/lib/edbus/edbus_core.c
@@ -759,14 +759,40 @@ cb_dispatch_status(DBusConnection *dbus_conn EINA_UNUSED, DBusDispatchStatus new
759 } 759 }
760} 760}
761 761
762static inline Eina_Bool
763extra_arguments_check(DBusMessage *msg, EDBus_Signal_Handler *sh)
764{
765 DBusMessageIter iter;
766 Signal_Argument *arg;
767 unsigned int arg_index = 0;
768
769 dbus_message_iter_init(msg, &iter);
770 EINA_INLIST_FOREACH(sh->args, arg)
771 {
772 const char *arg_msg;
773 int type = 0;
774
775 while((arg->index > arg_index) && dbus_message_iter_next(&iter))
776 arg_index++;
777
778 if (arg_index != arg->index)
779 return EINA_FALSE;
780
781 type = dbus_message_iter_get_arg_type(&iter);
782 if (!(type == 's' || type == 'o'))
783 return EINA_FALSE;
784
785 dbus_message_iter_get_basic(&iter, &arg_msg);
786 if (strcmp(arg_msg, arg->value))
787 return EINA_FALSE;
788 }
789 return EINA_TRUE;
790}
791
762static void 792static void
763cb_signal_dispatcher(EDBus_Connection *conn, DBusMessage *msg) 793cb_signal_dispatcher(EDBus_Connection *conn, DBusMessage *msg)
764{ 794{
765 DBusMessageIter iter;
766 int counter;
767 char *arg_msg;
768 EDBus_Message *edbus_msg; 795 EDBus_Message *edbus_msg;
769 Signal_Argument *arg;
770 Eina_Inlist *next; 796 Eina_Inlist *next;
771 797
772 edbus_msg = edbus_message_new(EINA_FALSE); 798 edbus_msg = edbus_message_new(EINA_FALSE);
@@ -787,7 +813,6 @@ cb_signal_dispatcher(EDBus_Connection *conn, DBusMessage *msg)
787 while (next != NULL) 813 while (next != NULL)
788 { 814 {
789 EDBus_Signal_Handler *sh; 815 EDBus_Signal_Handler *sh;
790 int type = 0;
791 816
792 sh = EINA_INLIST_CONTAINER_GET(next, EDBus_Signal_Handler); 817 sh = EINA_INLIST_CONTAINER_GET(next, EDBus_Signal_Handler);
793 next = next->next; 818 next = next->next;
@@ -803,26 +828,12 @@ cb_signal_dispatcher(EDBus_Connection *conn, DBusMessage *msg)
803 continue; 828 continue;
804 } 829 }
805 else 830 else
806 if (!dbus_message_has_sender(msg, sh->sender)) continue; 831 if (!dbus_message_has_sender(msg, sh->sender)) continue;
807 } 832 }
808 if (sh->path && !dbus_message_has_path(msg, sh->path)) continue; 833 if (sh->path && !dbus_message_has_path(msg, sh->path)) continue;
809 if (sh->member && !dbus_message_has_member(msg, sh->member)) continue; 834 if (sh->member && !dbus_message_has_member(msg, sh->member)) continue;
835 if (!extra_arguments_check(msg, sh)) continue;
810 836
811 dbus_message_iter_init(msg, &iter);
812 counter = 0;
813 EINA_INLIST_FOREACH(sh->args, arg)
814 {
815 type = dbus_message_iter_get_arg_type(&iter);
816 if (counter != arg->index || !(type == 's' || type == 'o'))
817 continue;
818
819 dbus_message_iter_get_basic(&iter, &arg_msg);
820 if (strcmp(arg_msg, arg->value))
821 continue;
822
823 dbus_message_iter_next(&iter);
824 counter++;
825 }
826 edbus_signal_handler_ref(sh); 837 edbus_signal_handler_ref(sh);
827 sh->cb((void *)sh->cb_data, edbus_msg); 838 sh->cb((void *)sh->cb_data, edbus_msg);
828 /* update next signal handler because the list may have changed */ 839 /* update next signal handler because the list may have changed */