#include <glib.h> #include <glib-object.h> #include <dbus/dbus.h> #include <dbus/dbus-glib.h> #include <hildon/hildon-notification.h> #include "marshal.h" /* The file generated from marshal.list via tool glib-genmarshal */ /* pidgin dbus station name */ #define DBUS_SERVICE_PURPLE "im.pidgin.purple.PurpleService" #define DBUS_PATH_PURPLE "/im/pidgin/purple/PurpleObject" #define DBUS_INTERFACE_PURPLE "im.pidgin.purple.PurpleInterface" /* global dbus instance */ DBusGConnection *bus; DBusGProxy *purple_proxy; /* Main event loop */ GMainLoop *loop = NULL; /* Signal callback handling routing */ void received_im_msg_cb (DBusGProxy *purple_proxy, int account_id, const char *sender, const char *message, int conv_id, unsigned int flags, gpointer user_data) { HildonNotification *n = NULL; n = hildon_notification_new( sender, message, "pidgin", "network" ); /* maybe someone can find an dbus call for bringing the current conversation window to foreground when being clicked - using the "com.nokia.SOMETHING" interface */ /* an example for using the pidgin interface - not tried yet ^^ */ /* hildon_notification_add_dbus_action( n, "default", "pidgin", DBUS_SERVICE_PURPLE, DBUS_PATH_PURPLE, DBUS_INTERFACE_PURPLE, "$METHOD", // see http://developer.pidgin.im/wiki/DbusHowto#CallingPidginmethods for methods?! G_TYPE_NONE, NULL, -1 ); */ notify_notification_show( NOTIFY_NOTIFICATION( n ), NULL ); g_timeout_add_seconds( 2, close_notification, n ); } /* * The main process, loop waiting for any signals */ int main (int argc, char **argv) { GError *error = NULL; g_type_init (); /* Get the bus */ bus = dbus_g_bus_get (DBUS_BUS_SESSION, &error); if (bus == NULL) { g_printerr("Failed to open connection to bus: %s", error->message); g_error_free(error); return -1; } /* Create a proxy object for the bus driver */ purple_proxy = dbus_g_proxy_new_for_name (bus, DBUS_SERVICE_PURPLE, DBUS_PATH_PURPLE, DBUS_INTERFACE_PURPLE); if (!purple_proxy) { g_printerr("Couldn't connect to the Purple Service: %s", error->message); g_error_free(error); return -1; } /* Create the main loop instance */ loop = g_main_loop_new (NULL, FALSE); /* Register dbus signal marshaller */ dbus_g_object_register_marshaller(marshal_VOID__INT_STRING_STRING_INT_UINT, G_TYPE_NONE, G_TYPE_INT, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_INT, G_TYPE_UINT, G_TYPE_INVALID); /* Add the signal to the proxy */ dbus_g_proxy_add_signal(purple_proxy, "ReceivedImMsg", G_TYPE_INT, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_INT, G_TYPE_UINT, G_TYPE_INVALID); /* Connect the signal handler to the proxy */ dbus_g_proxy_connect_signal(purple_proxy, "ReceivedImMsg", G_CALLBACK(received_im_msg_cb), bus, NULL); /* Main loop */ g_main_loop_run (loop); return 0; }
#!/bin/sh DAEMON=/usr/bin/pidginnotifyd DSMETOOL=/usr/sbin/dsmetool DSMETOOL_PARAMETERS="-t" $DSMETOOL $DSMETOOL_PARAMETERS $DAEMON