* Fixes NB#112208, use the bluetooth device name
authorSergio Villar Senin <svillar@igalia.com>
Thu, 23 Apr 2009 16:02:45 +0000 (16:02 +0000)
committerSergio Villar Senin <svillar@igalia.com>
Thu, 23 Apr 2009 16:02:45 +0000 (16:02 +0000)
Removed unused code

pmo-trunk-r9101

src/hildon2/modest-maemo-utils.c

index 5b02b20..e0fa856 100644 (file)
 #include "modest-ui-constants.h"
 #include <hildon/hildon-picker-dialog.h>
 
 #include "modest-ui-constants.h"
 #include <hildon/hildon-picker-dialog.h>
 
-/*
- * For getting and tracking the Bluetooth name
- */
-#define BTNAME_SERVICE                  "org.bluez"
-#define BTNAME_REQUEST_IF               "org.bluez.Adapter"
-#define BTNAME_SIGNAL_IF                "org.bluez.Adapter"
-#define BTNAME_SIGNAL_PATH              "/org/bluez/hci0"
-
-#define BTNAME_REQ_GET_PROPERTIES       "GetProperties"
-#define BTNAME_REQ_DEFAULT_ADAPTER      "DefaultAdapter"
-#define BTNAME_SIG_CHANGED              "NameChanged"
-
-#define BTNAME_MATCH_RULE "type='signal',interface='" BTNAME_SIGNAL_IF \
-                          "',member='" BTNAME_SIG_CHANGED "'"
-
 /* Label child of a captioned */
 #define CAPTIONED_LABEL_CHILD "captioned-label"
 
 /* Label child of a captioned */
 #define CAPTIONED_LABEL_CHILD "captioned-label"
 
@@ -91,58 +76,6 @@ modest_maemo_utils_set_osso_context (osso_context_t *osso_context)
        __osso_context = osso_context;
 }
 
        __osso_context = osso_context;
 }
 
-/* static void */
-/* update_device_name_from_msg (DBusMessage *message) */
-/* { */
-/*     DBusError error; */
-/*     DBusMessageIter iter; */
-
-/*     dbus_error_init (&error); */
-
-/*     if (dbus_set_error_from_message (&error, message)) { */
-/*             g_printerr ("modest: failed to get bluetooth name: %s\n", error.message); */
-/*             dbus_error_free (&error); */
-/*     } else { */
-/*             const gchar *device_name; */
-/*             if (!dbus_message_iter_init (message, &iter)) { */
-/*                     g_printerr ("modest: message did not have argument\n"); */
-/*                     return; */
-/*             } */
-/*             dbus_message_iter_get_basic (&iter, &device_name); */
-/*             modest_conf_set_string (modest_runtime_get_conf(), */
-/*                                     MODEST_CONF_DEVICE_NAME, device_name, */
-/*                                     NULL); */
-/*     } */
-/* } */
-
-
-/* static void */
-/* on_device_name_received (DBusPendingCall *call, void *user_data) */
-/* { */
-/*     DBusMessage *message; */
-
-/*     g_return_if_fail (dbus_pending_call_get_completed (call)); */
-
-/*     message = dbus_pending_call_steal_reply (call); */
-/*     if (!message) { */
-/*             g_printerr ("modest: no reply on device name query\n"); */
-/*             return; */
-/*     } */
-
-/*     update_device_name_from_msg (message); */
-/*     dbus_message_unref (message); */
-/* } */
-
-
-/* static DBusHandlerResult */
-/* handle_dbus_signal (DBusConnection *conn, DBusMessage *msg, gpointer data) */
-/* { */
-/*     if (dbus_message_is_signal(msg, BTNAME_SIGNAL_IF, BTNAME_SIG_CHANGED)) */
-/*             update_device_name_from_msg (msg); */
-
-/*     return DBUS_HANDLER_RESULT_NOT_YET_HANDLED; */
-/* } */
-
 static void
 get_properties_cb (DBusPendingCall *call,
                   void *user_data)
 static void
 get_properties_cb (DBusPendingCall *call,
                   void *user_data)
@@ -195,8 +128,9 @@ get_properties_cb (DBusPendingCall *call,
                        if (dict_entry_content_type == DBUS_TYPE_STRING) {
                                dbus_message_iter_get_basic ( &dict_entry_content_iter, &value );
 
                        if (dict_entry_content_type == DBUS_TYPE_STRING) {
                                dbus_message_iter_get_basic ( &dict_entry_content_iter, &value );
 
-                               if ( strcmp ( key, "Name" ) == 0 ) {
+                               if (strcmp (key, "Name") == 0 ) {
                                        g_debug ("-------------Name %s", value);
                                        g_debug ("-------------Name %s", value);
+                                       bt_name = value;
                                        break;
                                }
                        }
                                        break;
                                }
                        }
@@ -211,6 +145,7 @@ get_properties_cb (DBusPendingCall *call,
 
        /* Save device name */
        if (bt_name) {
 
        /* Save device name */
        if (bt_name) {
+               g_debug ("Setting the device name %s", bt_name);
                modest_conf_set_string (modest_runtime_get_conf(),
                                        MODEST_CONF_DEVICE_NAME, bt_name,
                                        NULL);
                modest_conf_set_string (modest_runtime_get_conf(),
                                        MODEST_CONF_DEVICE_NAME, bt_name,
                                        NULL);
@@ -233,14 +168,15 @@ get_default_adapter_cb (DBusPendingCall *call,
        dbus_message_iter_get_basic (&iter, &path);
        if (path != NULL) {
                DBusConnection *conn;
        dbus_message_iter_get_basic (&iter, &path);
        if (path != NULL) {
                DBusConnection *conn;
-               DBusMessage *adapterMsg = dbus_message_new_method_call(BTNAME_SERVICE, path,
-                                                                      BTNAME_REQUEST_IF,
-                                                                      BTNAME_REQ_GET_PROPERTIES);
+               DBusMessage *adapterMsg = dbus_message_new_method_call("org.bluez", path,
+                                                                      "org.bluez.Adapter",
+                                                                      "GetProperties");
                DBusPendingCall *call = NULL;
 
                conn = dbus_bus_get (DBUS_BUS_SYSTEM, NULL);
 
                if (conn && dbus_connection_send_with_reply(conn, adapterMsg, &call, -1) ) {
                DBusPendingCall *call = NULL;
 
                conn = dbus_bus_get (DBUS_BUS_SYSTEM, NULL);
 
                if (conn && dbus_connection_send_with_reply(conn, adapterMsg, &call, -1) ) {
+                       g_debug ("Getting the properties");
                        dbus_pending_call_set_notify(call, get_properties_cb, NULL, NULL);
                        dbus_pending_call_block(call);
                        dbus_pending_call_unref(call);
                        dbus_pending_call_set_notify(call, get_properties_cb, NULL, NULL);
                        dbus_pending_call_block(call);
                        dbus_pending_call_unref(call);
@@ -270,40 +206,16 @@ modest_maemo_utils_get_device_name (void)
        }
 
        /* Get the default adapter */
        }
 
        /* Get the default adapter */
-       request = dbus_message_new_method_call(BTNAME_SERVICE, "/" ,
-                                              BTNAME_REQUEST_IF,
-                                              BTNAME_REQ_DEFAULT_ADAPTER);
+       request = dbus_message_new_method_call("org.bluez", "/" ,
+                                              "org.bluez.Manager",
+                                              "DefaultAdapter");
 
        if (dbus_connection_send_with_reply(conn, request, &call, -1)) {
 
        if (dbus_connection_send_with_reply(conn, request, &call, -1)) {
+               g_debug ("Getting the default adapter");
                dbus_pending_call_set_notify(call, get_default_adapter_cb, NULL, NULL);
                dbus_pending_call_block(call);
                dbus_pending_call_unref(call);
        }
                dbus_pending_call_set_notify(call, get_default_adapter_cb, NULL, NULL);
                dbus_pending_call_block(call);
                dbus_pending_call_unref(call);
        }
-
-/*     request = dbus_message_new_method_call (BTNAME_SERVICE, BTNAME_REQUEST_PATH, */
-/*                                             BTNAME_REQUEST_IF, BTNAME_REQ_GET); */
-/*     if (!request) { */
-/*             /\* should we free the connection? *\/ */
-/*             g_printerr ("modest: dbus_message_new_method_call failed\n"); */
-/*             return; */
-/*     } */
-/*     dbus_message_set_auto_start (request, TRUE); */
-/*     if (dbus_connection_send_with_reply (conn, request, &call, -1)) { */
-/*             dbus_pending_call_set_notify (call, on_device_name_received, */
-/*                                           NULL, NULL); */
-/*             dbus_pending_call_unref (call); */
-/*     } */
-/*     dbus_message_unref (request); */
-
-/*     dbus_connection_setup_with_g_main (conn, NULL); */
-/*     dbus_bus_add_match (conn, BTNAME_MATCH_RULE, &error); */
-/*     if (dbus_error_is_set(&error)) { */
-/*             g_printerr ("modest: dbus_bus_add_match failed: %s\n", error.message); */
-/*             dbus_error_free (&error); */
-/*     } */
-
-/*     if (!dbus_connection_add_filter(conn, handle_dbus_signal, NULL, NULL)) */
-/*             g_printerr ("modest: dbus_connection_add_filter failed\n"); */
 }
 
 void
 }
 
 void