client: Wait for a reply from Technology API
authorPatrik Flykt <patrik.flykt@linux.intel.com>
Tue, 19 Feb 2013 20:39:57 +0000 (22:39 +0200)
committerPatrik Flykt <patrik.flykt@linux.intel.com>
Thu, 21 Feb 2013 14:23:08 +0000 (16:23 +0200)
Also reduce logging.

client/technology.c

index b5ed90d..3720c4a 100644 (file)
@@ -155,12 +155,10 @@ int set_technology(DBusConnection *connection, DBusMessage *message, char *key,
        DBusMessage *message_send;
        DBusMessageIter iter;
        struct tech_data technology;
+       DBusError err;
 
        match_tech_name(message, tech, &technology);
        if (g_strcmp0(tech, technology.name) != 0) {
-               fprintf(stderr, "%s does not exist on the system\n", tech);
-               fprintf(stderr, "Use the 'tech' command to find available "
-                                       "technologies on your system.\n");
                return -ENXIO;
        }
 
@@ -174,9 +172,15 @@ int set_technology(DBusConnection *connection, DBusMessage *message, char *key,
        dbus_message_iter_init_append(message_send, &iter);
        dbus_property_append_basic(&iter, (const char *) key,
                                                DBUS_TYPE_BOOLEAN, &value);
-       dbus_connection_send(connection, message_send, NULL);
-       dbus_connection_flush(connection);
-       dbus_message_unref(message_send);
+
+       dbus_error_init(&err);
+       dbus_connection_send_with_reply_and_block(connection, message_send,
+                       -1, &err);
+       if (dbus_error_is_set(&err) == TRUE) {
+               printf("Error '%s' %s\n", technology.path, err.message);
+               dbus_error_free(&err);
+       }
+
        g_free(technology.name);
        g_free(technology.path);