aboutsummaryrefslogtreecommitdiff
path: root/src/application-service-watcher.c
diff options
context:
space:
mode:
authorKen VanDine <ken.vandine@canonical.com>2010-01-08 22:17:33 -0500
committerKen VanDine <ken.vandine@canonical.com>2010-01-08 22:17:33 -0500
commit64df46b47e18de9c4cbf0ef87b9bae2853324637 (patch)
tree58d878cb2b30e583f0a0b87609e31478ba5a52d2 /src/application-service-watcher.c
parent60e78aa5b49972bb34b5049d2d54e1be4b7ad992 (diff)
parentc1010b61c9097212c9631b6cbc4e85fd62539364 (diff)
downloadayatana-indicator-application-64df46b47e18de9c4cbf0ef87b9bae2853324637.tar.gz
ayatana-indicator-application-64df46b47e18de9c4cbf0ef87b9bae2853324637.tar.bz2
ayatana-indicator-application-64df46b47e18de9c4cbf0ef87b9bae2853324637.zip
* Upstream Release 0.0.7
* Making the Notification Watcher register for it's own DBus name to keep the service one unique. * Adding support for icons changing through the service and in the indicator. * Fixing the generated headers for DBus Properties calls * Fixing libappindicator set_icon to set the right icon. * Adding in icon path support. * Switching DBus interface to org.freedesktop * Adding check/radio support to menu parsing * Adding ChangeLog to dist * Adding check item support to menu parsing
Diffstat (limited to 'src/application-service-watcher.c')
-rw-r--r--src/application-service-watcher.c56
1 files changed, 51 insertions, 5 deletions
diff --git a/src/application-service-watcher.c b/src/application-service-watcher.c
index 984b9d4..eff249d 100644
--- a/src/application-service-watcher.c
+++ b/src/application-service-watcher.c
@@ -26,14 +26,16 @@ with this program. If not, see <http://www.gnu.org/licenses/>.
#include <dbus/dbus-glib.h>
#include <dbus/dbus-glib-lowlevel.h>
+#include <dbus/dbus-glib-bindings.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_register_status_notifier_item (ApplicationServiceWatcher * appwatcher, const gchar * service, DBusGMethodInvocation * method);
+static gboolean _notification_watcher_server_registered_status_notifier_items (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);
+static void get_name_cb (DBusGProxy * proxy, guint status, GError * error, gpointer data);
#include "notification-watcher-server.h"
@@ -41,6 +43,7 @@ static gboolean _notification_watcher_server_is_notification_host_registered (Ap
typedef struct _ApplicationServiceWatcherPrivate ApplicationServiceWatcherPrivate;
struct _ApplicationServiceWatcherPrivate {
ApplicationServiceAppstore * appstore;
+ DBusGProxy * dbus_proxy;
};
#define APPLICATION_SERVICE_WATCHER_GET_PRIVATE(o) \
@@ -129,6 +132,23 @@ application_service_watcher_init (ApplicationServiceWatcher *self)
NOTIFICATION_WATCHER_DBUS_OBJ,
G_OBJECT(self));
+ priv->dbus_proxy = dbus_g_proxy_new_for_name_owner(session_bus,
+ DBUS_SERVICE_DBUS,
+ DBUS_PATH_DBUS,
+ DBUS_INTERFACE_DBUS,
+ &error);
+ if (error != NULL) {
+ g_error("Ah, can't get proxy to dbus: %s", error->message);
+ g_error_free(error);
+ return;
+ }
+
+ org_freedesktop_DBus_request_name_async(priv->dbus_proxy,
+ NOTIFICATION_WATCHER_DBUS_ADDR,
+ DBUS_NAME_FLAG_DO_NOT_QUEUE,
+ get_name_cb,
+ self);
+
return;
}
@@ -165,18 +185,26 @@ application_service_watcher_new (ApplicationServiceAppstore * appstore)
}
static gboolean
-_notification_watcher_server_register_service (ApplicationServiceWatcher * appwatcher, const gchar * service, DBusGMethodInvocation * method)
+_notification_watcher_server_register_status_notifier_item (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);
+ if (service[0] == '/') {
+ application_service_appstore_application_add(priv->appstore,
+ dbus_g_method_get_sender(method),
+ service);
+ } else {
+ application_service_appstore_application_add(priv->appstore,
+ service,
+ NOTIFICATION_ITEM_DEFAULT_OBJ);
+ }
dbus_g_method_return(method, G_TYPE_NONE);
return TRUE;
}
static gboolean
-_notification_watcher_server_registered_services (ApplicationServiceWatcher * appwatcher, GArray ** apps)
+_notification_watcher_server_registered_status_notifier_items (ApplicationServiceWatcher * appwatcher, GArray ** apps)
{
return FALSE;
@@ -203,3 +231,21 @@ _notification_watcher_server_is_notification_host_registered (ApplicationService
return TRUE;
}
+/* Function to handle the return of the get name. There isn't a whole
+ lot that can be done, but we're atleast going to tell people. */
+static void
+get_name_cb (DBusGProxy * proxy, guint status, GError * error, gpointer data)
+{
+ if (error != NULL) {
+ g_warning("Unable to get watcher name '%s' because: %s", NOTIFICATION_WATCHER_DBUS_ADDR, error->message);
+ return;
+ }
+
+ if (status != DBUS_REQUEST_NAME_REPLY_PRIMARY_OWNER &&
+ status != DBUS_REQUEST_NAME_REPLY_ALREADY_OWNER) {
+ g_warning("Unable to get watcher name '%s'", NOTIFICATION_WATCHER_DBUS_ADDR);
+ return;
+ }
+
+ return;
+}