aboutsummaryrefslogtreecommitdiff
path: root/src/application-service-watcher.c
diff options
context:
space:
mode:
authorTed Gould <ted@gould.cx>2009-11-30 13:28:20 -0600
committerTed Gould <ted@gould.cx>2009-11-30 13:28:20 -0600
commit44be8d22131ab3f6e2b4173da2af1dc5194919a8 (patch)
treeb246e31d89f79defb4d3f2e8ba26a7c716e6f816 /src/application-service-watcher.c
parentf23c54ff5fee5587c31ecb8bf176b58fa3d4be1d (diff)
parentf0881be3b8f779e0411958e6637f8f29e5697cbb (diff)
downloadayatana-indicator-application-44be8d22131ab3f6e2b4173da2af1dc5194919a8.tar.gz
ayatana-indicator-application-44be8d22131ab3f6e2b4173da2af1dc5194919a8.tar.bz2
ayatana-indicator-application-44be8d22131ab3f6e2b4173da2af1dc5194919a8.zip
Getting the right named files.
Diffstat (limited to 'src/application-service-watcher.c')
-rw-r--r--src/application-service-watcher.c183
1 files changed, 183 insertions, 0 deletions
diff --git a/src/application-service-watcher.c b/src/application-service-watcher.c
new file mode 100644
index 0000000..b077e6a
--- /dev/null
+++ b/src/application-service-watcher.c
@@ -0,0 +1,183 @@
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include <dbus/dbus-glib.h>
+#include <dbus/dbus-glib-lowlevel.h>
+#include "application-service-watcher.h"
+#include "dbus-shared.h"
+
+static gboolean _notification_watcher_server_register_service (ApplicationServiceWatcher * appwatcher, const gchar * service, DBusGMethodInvocation * method);
+static gboolean _notification_watcher_server_registered_services (ApplicationServiceWatcher * appwatcher, GArray ** apps);
+static gboolean _notification_watcher_server_protocol_version (ApplicationServiceWatcher * appwatcher, char ** version);
+static gboolean _notification_watcher_server_register_notification_host (ApplicationServiceWatcher * appwatcher, const gchar * host);
+static gboolean _notification_watcher_server_is_notification_host_registered (ApplicationServiceWatcher * appwatcher, gboolean * haveHost);
+
+#include "notification-watcher-server.h"
+
+/* Private Stuff */
+typedef struct _ApplicationServiceWatcherPrivate ApplicationServiceWatcherPrivate;
+struct _ApplicationServiceWatcherPrivate {
+ ApplicationServiceAppstore * appstore;
+};
+
+#define APPLICATION_SERVICE_WATCHER_GET_PRIVATE(o) \
+(G_TYPE_INSTANCE_GET_PRIVATE ((o), APPLICATION_SERVICE_WATCHER_TYPE, ApplicationServiceWatcherPrivate))
+
+/* Signals Stuff */
+enum {
+ SERVICE_REGISTERED,
+ SERVICE_UNREGISTERED,
+ NOTIFICATION_HOST_REGISTERED,
+ NOTIFICATION_HOST_UNREGISTERED,
+ LAST_SIGNAL
+};
+
+static guint signals[LAST_SIGNAL] = { 0 };
+
+/* GObject stuff */
+static void application_service_watcher_class_init (ApplicationServiceWatcherClass *klass);
+static void application_service_watcher_init (ApplicationServiceWatcher *self);
+static void application_service_watcher_dispose (GObject *object);
+static void application_service_watcher_finalize (GObject *object);
+
+G_DEFINE_TYPE (ApplicationServiceWatcher, application_service_watcher, G_TYPE_OBJECT);
+
+static void
+application_service_watcher_class_init (ApplicationServiceWatcherClass *klass)
+{
+ GObjectClass *object_class = G_OBJECT_CLASS (klass);
+
+ g_type_class_add_private (klass, sizeof (ApplicationServiceWatcherPrivate));
+
+ object_class->dispose = application_service_watcher_dispose;
+ object_class->finalize = application_service_watcher_finalize;
+
+ signals[SERVICE_REGISTERED] = g_signal_new ("service-registered",
+ G_TYPE_FROM_CLASS(klass),
+ G_SIGNAL_RUN_LAST,
+ G_STRUCT_OFFSET (ApplicationServiceWatcherClass, service_registered),
+ NULL, NULL,
+ g_cclosure_marshal_VOID__STRING,
+ G_TYPE_NONE, 1, G_TYPE_STRING, G_TYPE_NONE);
+ signals[SERVICE_UNREGISTERED] = g_signal_new ("service-unregistered",
+ G_TYPE_FROM_CLASS(klass),
+ G_SIGNAL_RUN_LAST,
+ G_STRUCT_OFFSET (ApplicationServiceWatcherClass, service_unregistered),
+ NULL, NULL,
+ g_cclosure_marshal_VOID__STRING,
+ G_TYPE_NONE, 1, G_TYPE_STRING, G_TYPE_NONE);
+ signals[NOTIFICATION_HOST_REGISTERED] = g_signal_new ("notification-host-registered",
+ G_TYPE_FROM_CLASS(klass),
+ G_SIGNAL_RUN_LAST,
+ G_STRUCT_OFFSET (ApplicationServiceWatcherClass, notification_host_registered),
+ NULL, NULL,
+ g_cclosure_marshal_VOID__VOID,
+ G_TYPE_NONE, 0, G_TYPE_NONE);
+ signals[NOTIFICATION_HOST_UNREGISTERED] = g_signal_new ("notification-host-unregistered",
+ G_TYPE_FROM_CLASS(klass),
+ G_SIGNAL_RUN_LAST,
+ G_STRUCT_OFFSET (ApplicationServiceWatcherClass, notification_host_unregistered),
+ NULL, NULL,
+ g_cclosure_marshal_VOID__VOID,
+ G_TYPE_NONE, 0, G_TYPE_NONE);
+
+ dbus_g_object_type_install_info(APPLICATION_SERVICE_WATCHER_TYPE,
+ &dbus_glib__notification_watcher_server_object_info);
+
+ return;
+}
+
+static void
+application_service_watcher_init (ApplicationServiceWatcher *self)
+{
+ ApplicationServiceWatcherPrivate * priv = APPLICATION_SERVICE_WATCHER_GET_PRIVATE(self);
+
+ priv->appstore = NULL;
+
+ GError * error = NULL;
+ DBusGConnection * session_bus = dbus_g_bus_get(DBUS_BUS_SESSION, &error);
+ if (error != NULL) {
+ g_error("Unable to get session bus: %s", error->message);
+ g_error_free(error);
+ return;
+ }
+
+ dbus_g_connection_register_g_object(session_bus,
+ NOTIFICATION_WATCHER_DBUS_OBJ,
+ G_OBJECT(self));
+
+ return;
+}
+
+static void
+application_service_watcher_dispose (GObject *object)
+{
+ ApplicationServiceWatcherPrivate * priv = APPLICATION_SERVICE_WATCHER_GET_PRIVATE(object);
+
+ if (priv->appstore != NULL) {
+ g_object_unref(G_OBJECT(priv->appstore));
+ priv->appstore = NULL;
+ }
+
+ G_OBJECT_CLASS (application_service_watcher_parent_class)->dispose (object);
+ return;
+}
+
+static void
+application_service_watcher_finalize (GObject *object)
+{
+
+ G_OBJECT_CLASS (application_service_watcher_parent_class)->finalize (object);
+ return;
+}
+
+ApplicationServiceWatcher *
+application_service_watcher_new (ApplicationServiceAppstore * appstore)
+{
+ GObject * obj = g_object_new(APPLICATION_SERVICE_WATCHER_TYPE, NULL);
+ ApplicationServiceWatcherPrivate * priv = APPLICATION_SERVICE_WATCHER_GET_PRIVATE(obj);
+ priv->appstore = appstore;
+ g_object_ref(G_OBJECT(priv->appstore));
+ return APPLICATION_SERVICE_WATCHER(obj);
+}
+
+static gboolean
+_notification_watcher_server_register_service (ApplicationServiceWatcher * appwatcher, const gchar * service, DBusGMethodInvocation * method)
+{
+ ApplicationServiceWatcherPrivate * priv = APPLICATION_SERVICE_WATCHER_GET_PRIVATE(appwatcher);
+
+ application_service_appstore_application_add(priv->appstore, dbus_g_method_get_sender(method), service);
+
+ dbus_g_method_return(method, G_TYPE_NONE);
+ return TRUE;
+}
+
+static gboolean
+_notification_watcher_server_registered_services (ApplicationServiceWatcher * appwatcher, GArray ** apps)
+{
+
+ return FALSE;
+}
+
+static gboolean
+_notification_watcher_server_protocol_version (ApplicationServiceWatcher * appwatcher, char ** version)
+{
+ *version = g_strdup("Ayatana Version 1");
+ return TRUE;
+}
+
+static gboolean
+_notification_watcher_server_register_notification_host (ApplicationServiceWatcher * appwatcher, const gchar * host)
+{
+
+ return FALSE;
+}
+
+static gboolean
+_notification_watcher_server_is_notification_host_registered (ApplicationServiceWatcher * appwatcher, gboolean * haveHost)
+{
+ *haveHost = TRUE;
+ return TRUE;
+}
+