aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorCharles Kerr <charles.kerr@canonical.com>2012-06-18 12:17:25 -0500
committerCharles Kerr <charles.kerr@canonical.com>2012-06-18 12:17:25 -0500
commit448f0a6342797e9510ff2a83ff8e7b40604e5642 (patch)
tree5cfec97c9e6bacecf658cc69702b6bb81c89b0dc /src
parent63b800e6036bc9d5096d8f7b7db42a814b8a2bed (diff)
downloadayatana-indicator-session-448f0a6342797e9510ff2a83ff8e7b40604e5642.tar.gz
ayatana-indicator-session-448f0a6342797e9510ff2a83ff8e7b40604e5642.tar.bz2
ayatana-indicator-session-448f0a6342797e9510ff2a83ff8e7b40604e5642.zip
handle fringe case where GetRealUserName is called before the username's been set -- send an empty string rather than NULL s.t. the client doens't get an '[Invalid UTF-8]' string
Diffstat (limited to 'src')
-rw-r--r--src/session-dbus.c29
1 files changed, 13 insertions, 16 deletions
diff --git a/src/session-dbus.c b/src/session-dbus.c
index 124733a..4b9d45f 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);
@@ -206,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;
@@ -219,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 *
@@ -242,7 +239,7 @@ session_dbus_set_users_real_name (SessionDbus * session, const gchar * name)
g_free(priv->name);
priv->name = NULL;
}
-
+
priv->name = g_strdup(name);
if (priv->bus != NULL) {
@@ -267,7 +264,7 @@ 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");
@@ -283,6 +280,6 @@ void session_dbus_restart_required (SessionDbus* session)
g_warning("Unable to send reboot-required signal: %s", error->message);
g_error_free(error);
}
- }
-
+ }
+
}