Manager signals need to be captured for service and technology
completion. This has the unintended consequence that enabling any
other monitoring will also print out the Manager interface
messages. Fix this by providing a pointer to the relevant monitor
struct boolean in order to decide whether to forward the message
to the monitor command filter function or to stop its forwarding
in the command completion filter function.
---
 client/commands.c |   28 ++++++++++++++++++++++++----
 1 file changed, 24 insertions(+), 4 deletions(-)

diff --git a/client/commands.c b/client/commands.c
index c8c7684..ecf7745 100644
--- a/client/commands.c
+++ b/client/commands.c
@@ -2164,35 +2164,48 @@ static DBusHandlerResult monitor_completions_changed(
                DBusConnection *connection,
                DBusMessage *message, void *user_data)
 {
+       bool *enabled = user_data;
        DBusMessageIter iter;
+       DBusHandlerResult handled;
+
+       if (*enabled)
+               handled = DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
+       else
+               handled = DBUS_HANDLER_RESULT_HANDLED;
 
        if (dbus_message_is_signal(message, "net.connman.Manager",
                                        "ServicesChanged")) {
                dbus_message_iter_init(message, &iter);
                update_services(&iter);
-               return DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
+               return handled;
        }
 
        if (dbus_message_is_signal(message, "net.connman.Manager",
                                        "TechnologyAdded")) {
                dbus_message_iter_init(message, &iter);
                add_technology(&iter);
-               return DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
+               return handled;
        }
 
        if (dbus_message_is_signal(message, "net.connman.Manager",
                                        "TechnologyRemoved")) {
                dbus_message_iter_init(message, &iter);
                remove_technology(&iter);
-               return DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
+               return handled;
        }
 
+       if (!g_strcmp0(dbus_message_get_interface(message),
+                                       "net.connman.Manager"))
+               return handled;
+
        return DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
 }
 
 void __connmanctl_monitor_completions(DBusConnection *dbus_conn)
 {
+       bool *enabled = NULL;
        DBusError err;
+       int i;
 
        if (!dbus_conn) {
                g_hash_table_destroy(service_hash);
@@ -2224,8 +2237,15 @@ void __connmanctl_monitor_completions(DBusConnection 
*dbus_conn)
                                "net.connman.Manager", "GetTechnologies",
                                populate_technology_hash, NULL, NULL, NULL);
 
+       for (i = 0; monitor[i].interface; i++) {
+               if (!strcmp(monitor[i].interface, "Manager")) {
+                       enabled = &monitor[i].enabled;
+                       break;
+               }
+       }
+
        dbus_connection_add_filter(connection,
-                               monitor_completions_changed, NULL, NULL);
+                               monitor_completions_changed, enabled, NULL);
 
        dbus_error_init(&err);
        dbus_bus_add_match(connection,
-- 
1.7.10.4

_______________________________________________
connman mailing list
[email protected]
https://lists.connman.net/mailman/listinfo/connman

Reply via email to