Added support for pausing Panucci 1.3
authorThomas Perl <thp@thpinfo.com>
Thu, 19 Nov 2009 22:43:48 +0000 (23:43 +0100)
committerThomas Perl <thp@thpinfo.com>
Thu, 19 Nov 2009 22:43:48 +0000 (23:43 +0100)
debian/changelog
debian/control
makefile
src/headphoned.c

index ba4ec3e..fd68590 100644 (file)
@@ -1,3 +1,9 @@
+headphoned (1.3) diablo; urgency=low
+
+  * Add support for pausing Panucci
+
+ -- Thomas Perl <thp@thpinfo.com>  Thu, 19 Nov 2009 23:42:38 +0100
+
 headphoned (1.2) diablo; urgency=low
 
   * Fix a typo in the package description.
index b693d0c..2e242b2 100644 (file)
@@ -2,7 +2,7 @@ Source: headphoned
 Section: user/multimedia
 Priority: extra
 Maintainer: Thomas Perl <thp@thpinfo.com>
-Build-Depends: debhelper (>= 5), libosso-dev, libgconf2-dev, libglib2.0-dev
+Build-Depends: debhelper (>= 5), libosso-dev, libgconf2-dev, libglib2.0-dev, libdbus-1-dev
 Standards-Version: 3.7.2
 
 Package: headphoned
@@ -14,6 +14,8 @@ Description: Pauses the media player when headphones are unplugged
  connection state of headphones on the N800/N810. Whenever the
  headphones are unplugged, headphoned will send a "pause" signal
  to the mediaplayer to avoid "public transport situations".
+ .
+ Supported applications: Media Player and Panucci
 XB-Maemo-Icon-26: iVBORw0KGgoAAAANSUhEUgAAABoAAAAaCAMAAACelLz8AAAAAXNSR0IArs4c
  6QAAAMlQTFRFAAD4ra2t8/PzT09PSkpKtra28/Lyw8PD+fn5cnJy8vHx8O/v
  7+7uyMjIoaGhZmZm4+Pj0NDQzc3NhYWFYmJipaWlXV1dr6+vk5OTuLi46unp
index b649bd5..2905814 100644 (file)
--- a/makefile
+++ b/makefile
@@ -1,7 +1,7 @@
 OBJS = src/headphoned.o
 PROG = headphoned
-CFLAGS += `pkg-config --cflags glib-2.0 gconf-2.0 libosso` -Os -Wall
-LDFLAGS += `pkg-config --libs glib-2.0 gconf-2.0 libosso`
+CFLAGS += `pkg-config --cflags glib-2.0 gconf-2.0 libosso dbus-1` -Os -Wall
+LDFLAGS += `pkg-config --libs glib-2.0 gconf-2.0 libosso dbus-1`
 
 DESTDIR ?= 
 PREFIX ?= /usr
index 0279237..2daaf69 100644 (file)
@@ -17,6 +17,7 @@
 #include <glib.h>
 #include <gconf/gconf-client.h>
 #include <libosso.h>
+#include <dbus/dbus.h>
 
 #define STATE_FILE "/sys/devices/platform/gpio-switch/headphone/state"
 #define STATE_CONNECTED_STR "connected"
 #define MEDIA_SERVER_PATH "/com/nokia/osso_media_server"
 #define MEDIA_SERVER_INTF "com.nokia.osso_media_server.music"
 
+#define PANUCCI_SRVC "org.panucci.panucciInterface"
+#define PANUCCI_PATH "/panucciInterface"
+#define PANUCCI_INTF "org.panucci.panucciInterface"
+
 // Volume control is currently broken, as something is messing
 // with the controls from outside this process in GConf..
 //#define ENABLE_VOLUME_CONTROL
@@ -38,6 +43,7 @@ enum { STATE_UNKNOWN, STATE_CONNECTED, STATE_DISCONNECTED, STATE_COUNT };
 
 typedef struct {
        GConfClient* client;
+       DBusConnection* session_bus;
        osso_context_t* osso;
        guint state;
        gint volume[STATE_COUNT];
@@ -69,6 +75,8 @@ headphoned_new()
        gconf_client_notify_add(this->client, GCONF_VOLUME_CONTROL,
                        on_volume_changed, this, NULL, NULL);
 #endif
+
+       this->session_bus = dbus_bus_get(DBUS_BUS_SESSION, NULL);
        this->initial = TRUE;
 
        return this;
@@ -93,6 +101,7 @@ on_file_changed(GIOChannel* source, GIOCondition condition, gpointer data)
                headphoned->state = STATE_DISCONNECTED;
 #ifdef ENABLE_PAUSE_ON_DISCONNECT
                if (headphoned->initial == FALSE) {
+                       /* Nokia Media Player */
                        osso_rpc_run(headphoned->osso,
                                        MEDIA_SERVER_SRVC,
                                        MEDIA_SERVER_PATH,
@@ -100,6 +109,19 @@ on_file_changed(GIOChannel* source, GIOCondition condition, gpointer data)
                                        "pause",
                                        NULL,
                                        DBUS_TYPE_INVALID);
+
+                       /* Panucci */
+                       if (dbus_bus_name_has_owner(headphoned->session_bus,
+                                                       PANUCCI_SRVC,
+                                                       NULL)) {
+                               osso_rpc_run(headphoned->osso,
+                                               PANUCCI_SRVC,
+                                               PANUCCI_PATH,
+                                               PANUCCI_INTF,
+                                               "pause",
+                                               NULL,
+                                               DBUS_TYPE_INVALID);
+                       }
                }
 #endif
        }