diff options
author | Sebastien Bacher <seb128@ubuntu.com> | 2012-07-11 19:25:42 +0200 |
---|---|---|
committer | Sebastien Bacher <seb128@ubuntu.com> | 2012-07-11 19:25:42 +0200 |
commit | e1ec25c1ccc63162bcfefc0661fc61fac9f376d1 (patch) | |
tree | d4d8adfec594c44bf54ed58c9ddf91dedaaa20e4 /src/session-dbus.c | |
parent | 6127a94efad13c780625228a1541c387528d75f1 (diff) | |
parent | 5b3945bab742d40e33e8a9bb3077cdc2b3898b22 (diff) | |
download | ayatana-indicator-session-e1ec25c1ccc63162bcfefc0661fc61fac9f376d1.tar.gz ayatana-indicator-session-e1ec25c1ccc63162bcfefc0661fc61fac9f376d1.tar.bz2 ayatana-indicator-session-e1ec25c1ccc63162bcfefc0661fc61fac9f376d1.zip |
Import upstream version 12.10.0
Diffstat (limited to 'src/session-dbus.c')
-rw-r--r-- | src/session-dbus.c | 65 |
1 files changed, 14 insertions, 51 deletions
diff --git a/src/session-dbus.c b/src/session-dbus.c index 232e440..4ece444 100644 --- a/src/session-dbus.c +++ b/src/session-dbus.c @@ -7,16 +7,16 @@ Authors: Ted Gould <ted@canonical.com> Conor Curran <conor.curran@canonical.com> -This program is free software: you can redistribute it and/or modify it -under the terms of the GNU General Public License version 3, as published +This program is free software: you can redistribute it and/or modify it +under the terms of the GNU General Public License version 3, as published by the Free Software Foundation. -This program is distributed in the hope that it will be useful, but -WITHOUT ANY WARRANTY; without even the implied warranties of -MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR +This program is distributed in the hope that it will be useful, but +WITHOUT ANY WARRANTY; without even the implied warranties of +MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. -You should have received a copy of the GNU General Public License along +You should have received a copy of the GNU General Public License along with this program. If not, see <http://www.gnu.org/licenses/>. */ @@ -27,7 +27,7 @@ with this program. If not, see <http://www.gnu.org/licenses/>. #include <gio/gio.h> #include "session-dbus.h" -#include "dbus-shared-names.h" +#include "shared-names.h" static GVariant * get_users_real_name (SessionDbus * service); static void bus_get_cb (GObject * object, GAsyncResult * res, gpointer user_data); @@ -38,7 +38,6 @@ static void bus_method_call (GDBusConnection * connection, const gchar * sender, typedef struct _SessionDbusPrivate SessionDbusPrivate; struct _SessionDbusPrivate { gchar * name; - gboolean user_menu_is_visible; GDBusConnection * bus; GCancellable * bus_cancel; guint dbus_registration; @@ -104,7 +103,6 @@ session_dbus_init (SessionDbus *self) priv->bus = NULL; priv->bus_cancel = NULL; priv->dbus_registration = 0; - priv->user_menu_is_visible = FALSE; priv->bus_cancel = g_cancellable_new(); g_bus_get(G_BUS_TYPE_SESSION, @@ -164,16 +162,12 @@ bus_method_call (GDBusConnection * connection, const gchar * sender, GDBusMethodInvocation * invocation, gpointer user_data) { SessionDbus * service = SESSION_DBUS (user_data); - SessionDbusPrivate * priv = SESSION_DBUS_GET_PRIVATE (service); GVariant * retval = NULL; if (g_strcmp0(method, "GetUserRealName") == 0) { retval = get_users_real_name (service); } - else if (g_strcmp0 (method, "GetUserMenuVisibility") == 0){ - retval = g_variant_new ("(b)", priv->user_menu_is_visible); - } else { g_warning("Calling method '%s' on the indicator service and it's unknown", method); } @@ -212,10 +206,7 @@ session_dbus_finalize (GObject *object) { SessionDbusPrivate * priv = SESSION_DBUS_GET_PRIVATE(object); - if (priv->name != NULL) { - g_free(priv->name); - priv->name = NULL; - } + g_clear_pointer (&priv->name, g_free); G_OBJECT_CLASS (session_dbus_parent_class)->finalize (object); return; @@ -225,7 +216,7 @@ static GVariant * get_users_real_name (SessionDbus * service) { SessionDbusPrivate * priv = SESSION_DBUS_GET_PRIVATE(service); - return g_variant_new ("(s)", priv->name); + return g_variant_new ("(s)", priv->name ? priv->name : ""); } SessionDbus * @@ -244,11 +235,8 @@ session_dbus_set_users_real_name (SessionDbus * session, const gchar * name) { SessionDbusPrivate * priv = SESSION_DBUS_GET_PRIVATE(session); GError * error = NULL; - if (priv->name != NULL) { - g_free(priv->name); - priv->name = NULL; - } - + + g_free (priv->name); priv->name = g_strdup(name); if (priv->bus != NULL) { @@ -269,36 +257,11 @@ session_dbus_set_users_real_name (SessionDbus * session, const gchar * name) return; } -void -session_dbus_set_user_menu_visibility (SessionDbus* session, - gboolean visible) -{ - SessionDbusPrivate * priv = SESSION_DBUS_GET_PRIVATE(session); - GError * error = NULL; - - priv->user_menu_is_visible = visible; - - if (priv->bus != NULL) { - g_dbus_connection_emit_signal (priv->bus, - NULL, - INDICATOR_SESSION_SERVICE_DBUS_OBJECT, - INDICATOR_SESSION_SERVICE_DBUS_IFACE, - "UserMenuIsVisible", - g_variant_new ("(b)", priv->user_menu_is_visible), - &error); - - if (error != NULL) { - g_warning("Unable to send UserMenuIsVisible signal: %s", error->message); - g_error_free(error); - } - } -} - void session_dbus_restart_required (SessionDbus* session) { SessionDbusPrivate * priv = SESSION_DBUS_GET_PRIVATE(session); GError * error = NULL; - + if (priv->bus != NULL) { g_debug("About to send RebootRequired signal"); @@ -314,6 +277,6 @@ void session_dbus_restart_required (SessionDbus* session) g_warning("Unable to send reboot-required signal: %s", error->message); g_error_free(error); } - } - + } + } |