aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTed Gould <ted@gould.cx>2012-02-23 00:08:04 -0600
committerTed Gould <ted@gould.cx>2012-02-23 00:08:04 -0600
commit96982968aa4a61a15c90eeb93bd0406aaedeb723 (patch)
tree895c60c1c00e2a2ae3188372df884dff5ee22890
parent8d32c607ddbef24050bcfb9155f8a662953a0999 (diff)
parent3e6ea0a46c929ac0a4072915058508316510fabd (diff)
downloadayatana-indicator-messages-96982968aa4a61a15c90eeb93bd0406aaedeb723.tar.gz
ayatana-indicator-messages-96982968aa4a61a15c90eeb93bd0406aaedeb723.tar.bz2
ayatana-indicator-messages-96982968aa4a61a15c90eeb93bd0406aaedeb723.zip
Import upstream version 0.5.92
-rw-r--r--AUTHORS1
-rw-r--r--ChangeLog36
-rwxr-xr-xconfigure2
-rw-r--r--configure.ac2
-rw-r--r--src/messages-service-dbus.c205
-rw-r--r--src/status-items.c102
6 files changed, 297 insertions, 51 deletions
diff --git a/AUTHORS b/AUTHORS
index cdbf492..f7c41e6 100644
--- a/AUTHORS
+++ b/AUTHORS
@@ -2,6 +2,7 @@
Allan LeSage
Andrea Cimitan
+ Charles Kerr
Chow Loong Jin
Chris Coulson
cody
diff --git a/ChangeLog b/ChangeLog
index 75097dd..32f71ae 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,41 @@
# Generated by Makefile. Do not edit.
+2012-02-22 Ted Gould <ted@gould.cx>
+
+ 0.5.92
+
+2012-02-22 Ted Gould <ted@gould.cx>
+
+ Remove unneeded goto's and clean up the code
+
+2012-02-21 Charles Kerr <charles.kerr@canonical.com>
+
+ silence LP Bug #937438 - Coverity got confused by goto's and gave Coverity PW.BRANCH_PAST_INITIALIZATION - CID 10663
+
+2012-02-21 Charles Kerr <charles.kerr@canonical.com>
+
+ trivial: fix a comment typo
+
+2012-02-21 Charles Kerr <charles.kerr@canonical.com>
+
+ trivial: fix error message grammar
+
+2012-02-21 Charles Kerr <charles.kerr@canonical.com>
+
+ trivial: fix comment typo
+
+2012-02-21 Charles Kerr <charles.kerr@canonical.com>
+
+ trivial: remove unnecessary cast
+
+2012-02-16 Michael Terry <michael.terry@canonical.com>
+
+ tell accountsservices about whether the user has messages or not
+
+2012-02-15 Michael Terry <michael.terry@canonical.com>
+
+ tell accounts service about message status
+
2012-02-14 Ted Gould <ted@gould.cx>
0.5.91
diff --git a/configure b/configure
index f97c650..9c10068 100755
--- a/configure
+++ b/configure
@@ -2776,7 +2776,7 @@ fi
# Define the identity of the package.
PACKAGE=indicator-messages
- VERSION=0.5.91
+ VERSION=0.5.92
cat >>confdefs.h <<_ACEOF
diff --git a/configure.ac b/configure.ac
index 7fb043a..179d679 100644
--- a/configure.ac
+++ b/configure.ac
@@ -4,7 +4,7 @@ AC_INIT(src/indicator-messages.c)
AC_PREREQ(2.53)
AM_CONFIG_HEADER(config.h)
-AM_INIT_AUTOMAKE(indicator-messages, 0.5.91)
+AM_INIT_AUTOMAKE(indicator-messages, 0.5.92)
AM_MAINTAINER_MODE
diff --git a/src/messages-service-dbus.c b/src/messages-service-dbus.c
index 1585ac0..2b72f2e 100644
--- a/src/messages-service-dbus.c
+++ b/src/messages-service-dbus.c
@@ -42,6 +42,8 @@ typedef struct _MessageServiceDbusPrivate MessageServiceDbusPrivate;
struct _MessageServiceDbusPrivate
{
GDBusConnection * connection;
+ GCancellable * accounts_cancel;
+ GDBusProxy * accounts_user;
gboolean dot;
gboolean hidden;
};
@@ -155,9 +157,199 @@ connection_cb (GObject * object, GAsyncResult * res, gpointer user_data)
}
static void
+accounts_notify_cb (GObject *source_object, GAsyncResult *res,
+ gpointer user_data)
+{
+ GError * error = NULL;
+ GVariant * answer = g_dbus_proxy_call_finish(G_DBUS_PROXY(source_object), res, &error);
+
+ if (g_error_matches(error, G_IO_ERROR, G_IO_ERROR_CANCELLED)) {
+ g_error_free(error);
+ return; /* Must exit before accessing freed memory */
+ }
+
+ MessageServiceDbusPrivate * priv = MESSAGE_SERVICE_DBUS_GET_PRIVATE(user_data);
+
+ if (priv->accounts_cancel != NULL) {
+ g_object_unref(priv->accounts_cancel);
+ priv->accounts_cancel = NULL;
+ }
+
+ if (error != NULL) {
+ g_warning("Unable to get notify accounts service of message status: %s", error->message);
+ g_error_free(error);
+ return;
+ }
+
+ g_variant_unref (answer);
+}
+
+static void
+accounts_notify (MessageServiceDbus *self)
+{
+ MessageServiceDbusPrivate * priv = MESSAGE_SERVICE_DBUS_GET_PRIVATE(self);
+
+ if (priv->accounts_user == NULL)
+ return; /* We're not able to talk to accounts service */
+
+ if (priv->accounts_cancel != NULL) {
+ /* Cancel old notify before starting new one */
+ g_cancellable_cancel(priv->accounts_cancel);
+ g_object_unref(priv->accounts_cancel);
+ priv->accounts_cancel = NULL;
+ }
+
+ priv->accounts_cancel = g_cancellable_new();
+ g_dbus_proxy_call(priv->accounts_user,
+ "SetXHasMessages",
+ g_variant_new ("(b)", priv->dot),
+ G_DBUS_CALL_FLAGS_NONE,
+ -1, /* timeout */
+ priv->accounts_cancel,
+ accounts_notify_cb,
+ self);
+}
+
+static void
+get_accounts_user_proxy_cb (GObject *source_object, GAsyncResult *res,
+ gpointer user_data)
+{
+ GError * error = NULL;
+ GDBusProxy * proxy = g_dbus_proxy_new_for_bus_finish(res, &error);
+
+ if (g_error_matches(error, G_IO_ERROR, G_IO_ERROR_CANCELLED)) {
+ g_error_free(error);
+ return; /* Must exit before accessing freed memory */
+ }
+
+ MessageServiceDbusPrivate * priv = MESSAGE_SERVICE_DBUS_GET_PRIVATE(user_data);
+
+ if (priv->accounts_cancel != NULL) {
+ g_object_unref(priv->accounts_cancel);
+ priv->accounts_cancel = NULL;
+ }
+
+ if (error != NULL) {
+ g_warning("Unable to get proxy of accountsservice: %s", error->message);
+ g_error_free(error);
+ return;
+ }
+
+ priv->accounts_user = proxy;
+ accounts_notify (MESSAGE_SERVICE_DBUS (user_data));
+}
+
+static void
+get_accounts_user_find_user_cb (GObject *source_object, GAsyncResult *res,
+ gpointer user_data)
+{
+ GError * error = NULL;
+ GVariant * answer = g_dbus_proxy_call_finish(G_DBUS_PROXY(source_object), res, &error);
+
+ /* We're done with main accounts proxy now */
+ g_object_unref (source_object);
+
+ if (g_error_matches(error, G_IO_ERROR, G_IO_ERROR_CANCELLED)) {
+ g_error_free(error);
+ return; /* Must exit before accessing freed memory */
+ }
+
+ MessageServiceDbusPrivate * priv = MESSAGE_SERVICE_DBUS_GET_PRIVATE(user_data);
+
+ if (priv->accounts_cancel != NULL) {
+ g_object_unref(priv->accounts_cancel);
+ priv->accounts_cancel = NULL;
+ }
+
+ if (error != NULL) {
+ g_warning("Unable to get object name of user from accountsservice: %s", error->message);
+ g_error_free(error);
+ return;
+ }
+
+ if (!g_variant_is_of_type (answer, G_VARIANT_TYPE ("(o)"))) {
+ g_warning("Unexpected type from FindUserByName: %s", g_variant_get_type_string (answer));
+ g_variant_unref(answer);
+ return;
+ }
+
+ const gchar *path;
+ g_variant_get(answer, "(&o)", &path);
+
+ priv->accounts_cancel = g_cancellable_new();
+ g_dbus_proxy_new_for_bus(G_BUS_TYPE_SYSTEM,
+ G_DBUS_PROXY_FLAGS_NONE,
+ NULL,
+ "org.freedesktop.Accounts",
+ path,
+ "org.freedesktop.Accounts.User",
+ priv->accounts_cancel,
+ get_accounts_user_proxy_cb,
+ user_data);
+
+ g_variant_unref (answer);
+}
+
+static void
+get_accounts_proxy_cb (GObject *source_object, GAsyncResult *res,
+ gpointer user_data)
+{
+ GError * error = NULL;
+ GDBusProxy * proxy = g_dbus_proxy_new_for_bus_finish(res, &error);
+
+ if (g_error_matches(error, G_IO_ERROR, G_IO_ERROR_CANCELLED)) {
+ g_error_free(error);
+ return; /* Must exit before accessing freed memory */
+ }
+
+ MessageServiceDbusPrivate * priv = MESSAGE_SERVICE_DBUS_GET_PRIVATE(user_data);
+
+ if (priv->accounts_cancel != NULL) {
+ g_object_unref(priv->accounts_cancel);
+ priv->accounts_cancel = NULL;
+ }
+
+ if (error != NULL) {
+ g_warning("Unable to get proxy of accountsservice: %s", error->message);
+ g_error_free(error);
+ return;
+ }
+
+ priv->accounts_cancel = g_cancellable_new();
+ g_dbus_proxy_call(proxy,
+ "FindUserByName",
+ g_variant_new ("(s)", g_get_user_name ()),
+ G_DBUS_CALL_FLAGS_NONE,
+ -1, /* timeout */
+ priv->accounts_cancel,
+ get_accounts_user_find_user_cb,
+ user_data);
+}
+
+static void
+get_accounts_proxy (MessageServiceDbus *self)
+{
+ MessageServiceDbusPrivate * priv = MESSAGE_SERVICE_DBUS_GET_PRIVATE(self);
+
+ g_return_if_fail(priv->accounts_cancel == NULL);
+
+ priv->accounts_cancel = g_cancellable_new();
+ g_dbus_proxy_new_for_bus(G_BUS_TYPE_SYSTEM,
+ G_DBUS_PROXY_FLAGS_NONE,
+ NULL,
+ "org.freedesktop.Accounts",
+ "/org/freedesktop/Accounts",
+ "org.freedesktop.Accounts",
+ priv->accounts_cancel,
+ get_accounts_proxy_cb,
+ self);
+}
+
+static void
message_service_dbus_init (MessageServiceDbus *self)
{
g_bus_get(G_BUS_TYPE_SESSION, NULL, connection_cb, self);
+ get_accounts_proxy (self);
MessageServiceDbusPrivate * priv = MESSAGE_SERVICE_DBUS_GET_PRIVATE(self);
@@ -177,6 +369,17 @@ message_service_dbus_dispose (GObject *object)
priv->connection = NULL;
}
+ if (priv->accounts_cancel != NULL) {
+ g_cancellable_cancel(priv->accounts_cancel);
+ g_object_unref(priv->accounts_cancel);
+ priv->accounts_cancel = NULL;
+ }
+
+ if (priv->accounts_user != NULL) {
+ g_object_unref(priv->accounts_user);
+ priv->accounts_user = NULL;
+ }
+
G_OBJECT_CLASS (message_service_dbus_parent_class)->dispose (object);
return;
}
@@ -240,6 +443,8 @@ message_service_dbus_set_attention (MessageServiceDbus * self, gboolean attentio
g_variant_new("(b)", priv->dot),
NULL);
}
+
+ accounts_notify (self);
}
return;
}
diff --git a/src/status-items.c b/src/status-items.c
index 25a7aa2..70a2ad9 100644
--- a/src/status-items.c
+++ b/src/status-items.c
@@ -253,62 +253,66 @@ module_destroy_in_idle (gpointer data)
static gboolean
load_status_provider (gpointer dir)
{
- gchar * provider = (gchar *)dir;
-
- if (!g_file_test(provider, G_FILE_TEST_EXISTS)) {
- goto exit_final;
- }
-
- g_debug("Loading status provider: %s", provider);
-
- GModule * module;
-
- module = g_module_open(provider, G_MODULE_BIND_LAZY | G_MODULE_BIND_LOCAL);
- if (module == NULL) {
- g_warning("Unable to module for: %s", provider);
- goto exit_module_fail;
+ gchar * provider = dir;
+
+ /* load the module */
+ GModule * module = NULL;
+ if (g_file_test(provider, G_FILE_TEST_EXISTS)) {
+ g_debug("Loading status provider: %s", provider);
+ module = g_module_open(provider, G_MODULE_BIND_LAZY | G_MODULE_BIND_LOCAL);
+ if (module == NULL) {
+ g_warning("Unable to open module: %s", provider);
+ }
}
- /* Got it */
- GType (*type_func) (void);
- if (!g_module_symbol(module, STATUS_PROVIDER_EXPORT_S, (gpointer *)&type_func)) {
- g_warning("Unable to find type symbol in: %s", provider);
- goto exit_module_fail;
+ /* find the status provider's GType */
+ GType provider_type = 0;
+ if (module != NULL) {
+ GType (*type_func) (void);
+ if (!g_module_symbol(module, STATUS_PROVIDER_EXPORT_S, (gpointer *)&type_func)) {
+ g_warning("Unable to find type symbol in: %s", provider);
+ } else {
+ provider_type = type_func();
+ if (provider_type == 0) {
+ g_warning("Unable to create type from: %s", provider);
+ }
+ }
}
- GType provider_type = type_func();
- if (provider_type == 0) {
- g_warning("Unable to create type from: %s", provider);
- goto exit_module_fail;
+ /* instantiate the status provider */
+ StatusProvider * sprovider = NULL;
+ if (provider_type != 0) {
+ sprovider = STATUS_PROVIDER(g_object_new(provider_type, NULL));
+ if (sprovider == NULL) {
+ g_warning("Unable to build provider from: %s", provider);
+ }
}
- StatusProvider * sprovider = STATUS_PROVIDER(g_object_new(provider_type, NULL));
- if (sprovider == NULL) {
- g_warning("Unable to build provider from: %s", provider);
- goto exit_module_fail;
+ /* use the provider */
+ if (sprovider != NULL) {
+ /* On update let's talk to all of them and create the aggregate
+ value to export */
+ g_signal_connect(G_OBJECT(sprovider),
+ STATUS_PROVIDER_SIGNAL_STATUS_CHANGED,
+ G_CALLBACK(update_status), NULL);
+
+ /* Attach the module object to the status provider so
+ that when the status provider is free'd the module
+ is closed automatically. */
+ g_object_set_data_full(G_OBJECT(sprovider),
+ "status-provider-module",
+ module, module_destroy_in_idle);
+ module = NULL; /* don't close module in this func */
+
+ status_providers = g_list_prepend(status_providers, sprovider);
+
+ /* Force an update to ensure a consistent state */
+ update_status();
}
- /* On update let's talk to all of them and create the aggregate
- value to export */
- g_signal_connect(G_OBJECT(sprovider), STATUS_PROVIDER_SIGNAL_STATUS_CHANGED, G_CALLBACK(update_status), NULL);
-
- /* Attach the module object to the status provider so
- that when the status provider is free'd the module
- is close automatically. */
- g_object_set_data_full(G_OBJECT(sprovider), "status-provider-module", module, module_destroy_in_idle);
-
- status_providers = g_list_prepend(status_providers, sprovider);
-
- /* Force and update every time just so we know we're
- in a consistent state*/
- update_status();
-
- goto exit_final;
-
-exit_module_fail:
- g_module_close(module);
-
-exit_final:
+ /* cleanup */
+ if (module != NULL)
+ g_module_close(module);
g_free(provider);
- return FALSE;
+ return FALSE; /* only call this idle func once */
}