Back to index

indicator-session  12.10.0
Classes | Defines | Typedefs | Functions | Variables
session-dbus.c File Reference
#include <gio/gio.h>
#include "session-dbus.h"
#include "shared-names.h"
#include "gen-session-dbus.xml.h"

Go to the source code of this file.

Classes

struct  _SessionDbusPrivate

Defines

#define SESSION_DBUS_GET_PRIVATE(o)   (G_TYPE_INSTANCE_GET_PRIVATE ((o), SESSION_DBUS_TYPE, SessionDbusPrivate))

Typedefs

typedef struct _SessionDbusPrivate

Functions

static GVariant * get_users_real_name (SessionDbus *service)
static void bus_get_cb (GObject *object, GAsyncResult *res, gpointer user_data)
static void bus_method_call (GDBusConnection *connection, const gchar *sender, const gchar *path, const gchar *interface, const gchar *method, GVariant *params, GDBusMethodInvocation *invocation, gpointer user_data)
static void session_dbus_class_init (SessionDbusClass *klass)
static void session_dbus_init (SessionDbus *self)
static void session_dbus_dispose (GObject *object)
static void session_dbus_finalize (GObject *object)
 G_DEFINE_TYPE (SessionDbus, session_dbus, G_TYPE_OBJECT)
SessionDbus * session_dbus_new (void)
void session_dbus_set_name (SessionDbus *session, const gchar *name)
void session_dbus_set_users_real_name (SessionDbus *session, const gchar *name)
void session_dbus_restart_required (SessionDbus *session)

Variables

static GDBusNodeInfo * node_info = NULL
static GDBusInterfaceInfo * interface_info = NULL
static GDBusInterfaceVTable interface_table

Class Documentation

struct _SessionDbusPrivate

Definition at line 39 of file session-dbus.c.

Class Members
GDBusConnection * bus
GCancellable * bus_cancel
guint dbus_registration
gchar * name

Define Documentation

#define SESSION_DBUS_GET_PRIVATE (   o)    (G_TYPE_INSTANCE_GET_PRIVATE ((o), SESSION_DBUS_TYPE, SessionDbusPrivate))

Definition at line 55 of file session-dbus.c.


Typedef Documentation

typedef struct _SessionDbusPrivate

Definition at line 38 of file session-dbus.c.


Function Documentation

static void bus_get_cb ( GObject *  object,
GAsyncResult *  res,
gpointer  user_data 
) [static]

Definition at line 117 of file session-dbus.c.

{
       GError * error = NULL;
       GDBusConnection * connection = g_bus_get_finish(res, &error);

       if (error != NULL) {
              g_error("OMG! Unable to get a connection to DBus: %s", error->message);
              g_error_free(error);
              return;
       }

       SessionDbusPrivate * priv = SESSION_DBUS_GET_PRIVATE(user_data);

       g_warn_if_fail(priv->bus == NULL);
       priv->bus = connection;

       if (priv->bus_cancel != NULL) {
              g_object_unref(priv->bus_cancel);
              priv->bus_cancel = NULL;
       }

       /* Now register our object on our new connection */
       priv->dbus_registration = g_dbus_connection_register_object(priv->bus,
                                                                   INDICATOR_SESSION_SERVICE_DBUS_OBJECT,
                                                                   interface_info,
                                                                   &interface_table,
                                                                   user_data,
                                                                   NULL,
                                                                   &error);

       if (error != NULL) {
              g_error("Unable to register the object to DBus: %s", error->message);
              g_error_free(error);
              return;
       }

       return;       
}

Here is the caller graph for this function:

static void bus_method_call ( GDBusConnection *  connection,
const gchar *  sender,
const gchar *  path,
const gchar *  interface,
const gchar *  method,
GVariant *  params,
GDBusMethodInvocation *  invocation,
gpointer  user_data 
) [static]

Definition at line 159 of file session-dbus.c.

{
       SessionDbus * service = SESSION_DBUS (user_data);

       GVariant * retval = NULL;

       if (g_strcmp0(method, "GetUserRealName") == 0) {
              retval = get_users_real_name (service);
       }
  else {
    g_warning("Calling method '%s' on the indicator service and it's unknown", method);
       }
       g_dbus_method_invocation_return_value(invocation, retval);
       return;
}

Here is the call graph for this function:

G_DEFINE_TYPE ( SessionDbus  ,
session_dbus  ,
G_TYPE_OBJECT   
)
static GVariant * get_users_real_name ( SessionDbus *  service) [static]

Definition at line 216 of file session-dbus.c.

{
       SessionDbusPrivate * priv = SESSION_DBUS_GET_PRIVATE(service);
       return g_variant_new ("(s)", priv->name ? priv->name : "");
}

Here is the caller graph for this function:

static void session_dbus_class_init ( SessionDbusClass *  klass) [static]

Definition at line 66 of file session-dbus.c.

{
       GObjectClass *object_class = G_OBJECT_CLASS (klass);

       g_type_class_add_private (klass, sizeof (SessionDbusPrivate));

       object_class->dispose = session_dbus_dispose;
       object_class->finalize = session_dbus_finalize;

       /* Setting up the DBus interfaces */
       if (node_info == NULL) {
              GError * error = NULL;

              node_info = g_dbus_node_info_new_for_xml(_session_dbus, &error);
              if (error != NULL) {
                     g_error("Unable to parse Session Service Interface description: %s", error->message);
                     g_error_free(error);
              }
       }

       if (interface_info == NULL) {
              interface_info = g_dbus_node_info_lookup_interface(node_info, INDICATOR_SESSION_SERVICE_DBUS_IFACE);

              if (interface_info == NULL) {
                     g_error("Unable to find interface '" INDICATOR_SESSION_SERVICE_DBUS_IFACE "'");
              }
       }

       return;
}

Here is the call graph for this function:

static void session_dbus_dispose ( GObject *  object) [static]

Definition at line 179 of file session-dbus.c.

{
       SessionDbusPrivate * priv = SESSION_DBUS_GET_PRIVATE(object);

       if (priv->dbus_registration != 0) {
              g_dbus_connection_unregister_object(priv->bus, priv->dbus_registration);
              /* Don't care if it fails, there's nothing we can do */
              priv->dbus_registration = 0;
       }

       if (priv->bus != NULL) {
              g_object_unref(priv->bus);
              priv->bus = NULL;
       }

       if (priv->bus_cancel != NULL) {
              g_cancellable_cancel(priv->bus_cancel);
              g_object_unref(priv->bus_cancel);
              priv->bus_cancel = NULL;
       }

       G_OBJECT_CLASS (session_dbus_parent_class)->dispose (object);
       return;
}

Here is the caller graph for this function:

static void session_dbus_finalize ( GObject *  object) [static]

Definition at line 205 of file session-dbus.c.

{
       SessionDbusPrivate * priv = SESSION_DBUS_GET_PRIVATE(object);

       g_clear_pointer (&priv->name, g_free);

       G_OBJECT_CLASS (session_dbus_parent_class)->finalize (object);
       return;
}

Here is the caller graph for this function:

static void session_dbus_init ( SessionDbus *  self) [static]

Definition at line 98 of file session-dbus.c.

{
       SessionDbusPrivate * priv = SESSION_DBUS_GET_PRIVATE(self);

       priv->name = NULL;
       priv->bus = NULL;
       priv->bus_cancel = NULL;
       priv->dbus_registration = 0;

       priv->bus_cancel = g_cancellable_new();
       g_bus_get(G_BUS_TYPE_SESSION,
                 priv->bus_cancel,
                 bus_get_cb,
                 self);

       return;
}

Here is the call graph for this function:

SessionDbus* session_dbus_new ( void  )

Definition at line 223 of file session-dbus.c.

{
       return SESSION_DBUS(g_object_new(SESSION_DBUS_TYPE, NULL));
}

Here is the caller graph for this function:

void session_dbus_restart_required ( SessionDbus *  session)

Definition at line 260 of file session-dbus.c.

{
       SessionDbusPrivate * priv = SESSION_DBUS_GET_PRIVATE(session);
       GError * error = NULL;

       if (priv->bus != NULL) {
    g_debug("About to send RebootRequired signal");

              g_dbus_connection_emit_signal (priv->bus,
                                   NULL,
                                   INDICATOR_SESSION_SERVICE_DBUS_OBJECT,
                                   INDICATOR_SESSION_SERVICE_DBUS_IFACE,
                                   "RestartRequired",
                                   NULL,
                                   &error);

              if (error != NULL) {
                     g_warning("Unable to send reboot-required signal: %s", error->message);
                     g_error_free(error);
              }
       }

}
void session_dbus_set_name ( SessionDbus *  session,
const gchar *  name 
)

Definition at line 229 of file session-dbus.c.

{
}
void session_dbus_set_users_real_name ( SessionDbus *  session,
const gchar *  name 
)

Definition at line 234 of file session-dbus.c.

{
       SessionDbusPrivate * priv = SESSION_DBUS_GET_PRIVATE(session);
       GError * error = NULL;

       g_free (priv->name);
       priv->name = g_strdup(name);

       if (priv->bus != NULL) {
              g_dbus_connection_emit_signal (priv->bus,
                                   NULL,
                                   INDICATOR_SESSION_SERVICE_DBUS_OBJECT,
                                   INDICATOR_SESSION_SERVICE_DBUS_IFACE,
                                   "UserRealNameUpdated",
                                   g_variant_new ("(s)", priv->name, NULL),
                                   &error);

              if (error != NULL) {
                     g_warning("Unable to send UserRealNameUpdated signal: %s", error->message);
                     g_error_free(error);
                     return;
              }
       }
       return;
}

Here is the caller graph for this function:


Variable Documentation

GDBusInterfaceInfo* interface_info = NULL [static]

Definition at line 48 of file session-dbus.c.

GDBusInterfaceVTable interface_table [static]
Initial value:
 {
       method_call:    bus_method_call,
       get_property:   NULL, 
       set_property:   NULL  
}

Definition at line 49 of file session-dbus.c.

GDBusNodeInfo* node_info = NULL [static]

Definition at line 47 of file session-dbus.c.