X-Git-Url: http://git.maemo.org/git/?a=blobdiff_plain;f=src%2Fhildon2%2Fmodest-maemo-utils.c;h=2ca89a502cef465d0a9643e785062e8c80ca5e06;hb=591c8ef59dd9cb1ec95e77ac3fc9de1f9d94ccc0;hp=dfd26589c5e777fbe80078335d7f95a43996d989;hpb=890cdf6655a56ebb2a860c01bedbe15a59e7d9dd;p=modest diff --git a/src/hildon2/modest-maemo-utils.c b/src/hildon2/modest-maemo-utils.c index dfd2658..2ca89a5 100644 --- a/src/hildon2/modest-maemo-utils.c +++ b/src/hildon2/modest-maemo-utils.c @@ -64,45 +64,27 @@ osso_context_t * modest_maemo_utils_get_osso_context (void) { if (!__osso_context) - g_warning ("%s: __osso_context == NULL", __FUNCTION__); + __osso_context = osso_initialize(PACKAGE,PACKAGE_VERSION, + FALSE, NULL); return __osso_context; } -void -modest_maemo_utils_set_osso_context (osso_context_t *osso_context) -{ - g_return_if_fail (osso_context); - __osso_context = osso_context; -} - static void -get_properties_cb (DBusPendingCall *call, - void *user_data) +get_properties_cb (DBusMessage *message) { DBusMessageIter iter; DBusMessageIter dict_iter; DBusMessageIter dict_entry_iter; DBusError err; gchar *bt_name = NULL; - DBusMessage *message; int key_type, array_type, msg_type; - if ( !dbus_pending_call_get_completed ( call ) ) - g_warning ("%s: Call not completed!", __FUNCTION__); - - message = dbus_pending_call_steal_reply ( call ); - - if (message == NULL) - g_warning ("%s: Message is NULL", __FUNCTION__); - - dbus_error_init(&err); if (dbus_set_error_from_message (&err, message)) { g_warning ("%s: %s", __FUNCTION__, err.message); } - /* Get msg type */ dbus_message_iter_init (message, &iter); msg_type = dbus_message_iter_get_arg_type (&iter); @@ -153,37 +135,32 @@ get_properties_cb (DBusPendingCall *call, } static void -get_default_adapter_cb (DBusPendingCall *call, - void *user_data) +get_default_adapter_cb (DBusConnection *conn, + DBusMessage *message) { - DBusMessage *message; DBusMessageIter iter; gchar* path = NULL; + DBusError error; + DBusMessage *msg, *adapterMsg; - message = dbus_pending_call_steal_reply(call); + dbus_message_iter_init (message, &iter); + dbus_message_iter_get_basic (&iter, &path); - // Todo extract msg info from here - dbus_message_iter_init ( message, &iter ); + if (!path) + return; - dbus_message_iter_get_basic (&iter, &path); - if (path != NULL) { - DBusConnection *conn; - 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) ) { - 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); - } - } else { - g_warning ("Failed to get the default bluetooth adapter"); + 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 @@ -192,7 +169,7 @@ modest_maemo_utils_get_device_name (void) static DBusConnection *conn = NULL; DBusMessage *request; DBusError error; - DBusPendingCall *call = NULL; + DBusMessage *msg; dbus_error_init (&error); if (!conn) { @@ -206,16 +183,17 @@ modest_maemo_utils_get_device_name (void) } /* Get the default adapter */ - request = dbus_message_new_method_call("org.bluez", "/" , - "org.bluez.Manager", - "DefaultAdapter"); + request = dbus_message_new_method_call ("org.bluez", "/" , + "org.bluez.Manager", + "DefaultAdapter"); - if (dbus_connection_send_with_reply(conn, request, &call, -1)) { + msg = dbus_connection_send_with_reply_and_block (conn, request, -1, &error); + if (msg) { 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); + get_default_adapter_cb (conn, msg); + dbus_message_unref (msg); } + dbus_message_unref (request); } void @@ -524,14 +502,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 ++;