** get_modal() method of window manager must only return the visible modal windows
[modest] / src / hildon2 / modest-maemo-utils.c
index 4a17ebd..573c78f 100644 (file)
@@ -64,7 +64,7 @@ osso_context_t *
 modest_maemo_utils_get_osso_context (void)
 {
        if (!__osso_context) 
-               g_warning ("%s: __osso_context == NULL", __FUNCTION__);
+               g_debug ("%s: __osso_context == NULL", __FUNCTION__);
 
        return __osso_context;
 }
@@ -141,39 +141,32 @@ get_properties_cb (DBusMessage *message)
 }
 
 static void
-get_default_adapter_cb (DBusMessage *message)
+get_default_adapter_cb (DBusConnection *conn,
+                       DBusMessage *message)
 {
        DBusMessageIter iter;
        gchar* path = NULL;
+       DBusError error;
+       DBusMessage *msg, *adapterMsg;
 
        dbus_message_iter_init (message, &iter);
-
        dbus_message_iter_get_basic (&iter, &path);
-       if (path != NULL) {
-               DBusError error;
-               DBusConnection *conn;
-               DBusMessage *adapterMsg = dbus_message_new_method_call ("org.bluez", path,
-                                                                       "org.bluez.Adapter",
-                                                                       "GetProperties");
-
-               conn = dbus_bus_get (DBUS_BUS_SYSTEM, NULL);
-
-               if (conn) {
-                       DBusMessage *msg;
-
-                       dbus_error_init (&error);
-                       msg = dbus_connection_send_with_reply_and_block (conn, adapterMsg, -1, &error);
-                       if (msg) {
-                               g_debug ("Getting the properties");
-                               get_properties_cb (msg);
-                               dbus_message_unref (msg);
-                       }
-                       dbus_connection_unref (conn);
-               }
-               dbus_message_unref (adapterMsg);
-       } else {
-               g_warning ("Failed to get the default bluetooth adapter");
+
+       if (!path)
+               return;
+
+       adapterMsg = dbus_message_new_method_call ("org.bluez", path,
+                                                  "org.bluez.Adapter",
+                                                  "GetProperties");
+
+       dbus_error_init (&error);
+       msg = dbus_connection_send_with_reply_and_block (conn, adapterMsg, -1, &error);
+       if (msg) {
+               g_debug ("Getting the properties");
+               get_properties_cb (msg);
+               dbus_message_unref (msg);
        }
+       dbus_message_unref (adapterMsg);
 }
 
 void
@@ -203,11 +196,10 @@ modest_maemo_utils_get_device_name (void)
        msg = dbus_connection_send_with_reply_and_block (conn, request, -1, &error);
        if (msg) {
                g_debug ("Getting the default adapter");
-               get_default_adapter_cb (msg);
+               get_default_adapter_cb (conn, msg);
                dbus_message_unref (msg);
        }
        dbus_message_unref (request);
-       dbus_connection_unref (conn);
 }
 
 void
@@ -516,14 +508,14 @@ modest_maemo_utils_select_attachments (GtkWindow *window, TnyList *att_list, gbo
                        if (TNY_IS_MSG (part)) {
                                TnyHeader *header = tny_msg_get_header (TNY_MSG (part));
                                filename = tny_header_dup_subject (header);
-                               if ((filename == NULL) || (filename[0] == '\0')) {
-                                       g_free (filename);
-                                       filename = g_strdup (_("mail_va_no_subject"));
-                               }
                                g_object_unref (header);
                        } else {
                                filename = g_strdup (tny_mime_part_get_filename (part));
                        }
+                       if ((filename == NULL) || (filename[0] == '\0')) {
+                               g_free (filename);
+                               filename = g_strdup (_("mail_va_no_subject"));
+                       }
                        gtk_list_store_append (GTK_LIST_STORE (model), &iter);
                        gtk_list_store_set (GTK_LIST_STORE (model), &iter, 0, filename, 1, part, -1);
                        attachments_added ++;