cleanups, notification timeout fix
authorTuomo Tanskanen <ext-tuomo.1.tanskanen@nokia.com>
Tue, 2 Mar 2010 12:25:24 +0000 (14:25 +0200)
committerTuomo Tanskanen <ext-tuomo.1.tanskanen@nokia.com>
Tue, 2 Mar 2010 12:25:24 +0000 (14:25 +0200)
debian/changelog
nowplaying.c

index 86a8e2d..aa50847 100644 (file)
@@ -1,11 +1,13 @@
-nowplayingd (0.2-1~unreleased1) fremantle; urgency=low
+nowplayingd (0.2-1~unreleased3) fremantle; urgency=low
 
   * Added bugtracker (mailto me)
   * Fix postinst/99nowplayingd to use dsmetool -f, which does NOT reboot
     device if nowplayingd for some reason goes to segfault loop. Now
     it just silently stops trying to respawn it.
+  * Added cleanup functions for mafw and notify
+  * Added dependency to dsme, due dsmetool used in scripts
 
- -- Tuomo Tanskanen <tumi@tumi.fi>  Tue, 02 Mar 2010 09:28:51 +0200
+ -- Tuomo Tanskanen <tumi@tumi.fi>  Tue, 02 Mar 2010 14:23:40 +0200
 
 nowplayingd (0.1-2) fremantle; urgency=low
 
index 8dfbe8d..ff0f811 100644 (file)
@@ -28,13 +28,6 @@ static void sig_handler( int sig G_GNUC_UNUSED )
        }
 }
 
-static gboolean close_notification( gpointer n )
-{
-       notify_notification_close( NOTIFY_NOTIFICATION( n ), NULL );
-
-       return FALSE;
-}
-
 static void metadata_callback(
        const MafwRenderer *self G_GNUC_UNUSED,
        const gchar *object_id G_GNUC_UNUSED,
@@ -66,9 +59,9 @@ static void metadata_callback(
                "open_mp_now_playing",
                G_TYPE_NONE, NULL,
                -1 );
-               
+
+       notify_notification_set_timeout( NOTIFY_NOTIFICATION( n ), 4500 /* 4.5s */ );
        notify_notification_show( NOTIFY_NOTIFICATION( n ), NULL );
-       g_timeout_add_seconds( 5, close_notification, n );
 }
 
 static void state_changed_cb(
@@ -89,6 +82,20 @@ static void state_changed_cb(
   }
 }
 
+static void renderer_removed_cb(
+       const MafwRegistry *registry2 G_GNUC_UNUSED,
+       GObject *renderer,
+       gconstpointer user_data G_GNUC_UNUSED)
+{
+       if ( MAFW_IS_RENDERER( renderer ) ) {
+               const gchar *name = mafw_extension_get_name( MAFW_EXTENSION( renderer ) );
+
+               if ( !strcmp( name, WANTED_RENDERER ) ) {
+                       g_signal_handlers_disconnect_by_func( renderer, G_CALLBACK( state_changed_cb ), NULL );
+               }
+       }
+}
+
 static void renderer_added_cb(
        const MafwRegistry *registry2 G_GNUC_UNUSED,
        GObject *renderer,
@@ -103,6 +110,18 @@ static void renderer_added_cb(
        }
 }
 
+static void mafw_deinit( void )
+{
+    GList *renderers = NULL;
+
+       g_signal_handlers_disconnect_by_func( registry, G_CALLBACK( renderer_removed_cb ), NULL );
+       renderers = mafw_registry_get_renderers( registry );
+       while ( renderers ) {
+               renderer_removed_cb( registry, G_OBJECT( renderers->data ), NULL );
+               renderers = g_list_next( renderers );
+       }
+}
+
 static void mafw_init( void )
 {
     GList *renderers = NULL;
@@ -140,8 +159,12 @@ int main (void)
 
        g_main_loop_unref( loop );
 
+       mafw_deinit();
+
        mafw_shared_deinit();
 
+       notify_uninit();
+
        return EXIT_SUCCESS;
 }