Back to index

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

Go to the source code of this file.

Classes

struct  _DatetimeInterfacePrivate
 DatetimeInterfacePrivate: : The handle for this object being registered on dbus. More...

Defines

#define DATETIME_INTERFACE_GET_PRIVATE(o)   (DATETIME_INTERFACE(o)->priv)

Functions

static void datetime_interface_class_init (DatetimeInterfaceClass *klass)
static void datetime_interface_init (DatetimeInterface *self)
static void datetime_interface_dispose (GObject *object)
static void datetime_interface_finalize (GObject *object)
static void bus_get_cb (GObject *object, GAsyncResult *res, gpointer user_data)
 G_DEFINE_TYPE (DatetimeInterface, datetime_interface, G_TYPE_OBJECT)
void datetime_interface_update (DatetimeInterface *self)

Variables

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

Class Documentation

struct _DatetimeInterfacePrivate

DatetimeInterfacePrivate: : The handle for this object being registered on dbus.

Structure to define the memory for the private area of the datetime interface instance.

Definition at line 40 of file datetime-interface.c.

Class Members
GDBusConnection * bus
GCancellable * bus_cancel
guint dbus_registration

Define Documentation

#define DATETIME_INTERFACE_GET_PRIVATE (   o)    (DATETIME_INTERFACE(o)->priv)

Definition at line 46 of file datetime-interface.c.


Function Documentation

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

Definition at line 111 of file datetime-interface.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;
       }

       DatetimeInterfacePrivate * priv = DATETIME_INTERFACE_GET_PRIVATE(user_data);

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

       g_clear_object (&priv->bus_cancel);

       /* Now register our object on our new connection */
       priv->dbus_registration = g_dbus_connection_register_object(priv->bus,
                                                                   SERVICE_OBJ,
                                                                   interface_info,
                                                                   NULL,
                                                                   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 datetime_interface_class_init ( DatetimeInterfaceClass *  klass) [static]

Definition at line 61 of file datetime-interface.c.

{
       GObjectClass *object_class = G_OBJECT_CLASS (klass);

       g_type_class_add_private (klass, sizeof (DatetimeInterfacePrivate));

       object_class->dispose = datetime_interface_dispose;
       object_class->finalize = datetime_interface_finalize;

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

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

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

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

       return;
}

Here is the call graph for this function:

static void datetime_interface_dispose ( GObject *  object) [static]

Definition at line 148 of file datetime-interface.c.

{
       DatetimeInterfacePrivate * priv = DATETIME_INTERFACE_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;
       }

       g_clear_object (&priv->bus);

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

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

Here is the caller graph for this function:

static void datetime_interface_finalize ( GObject *  object) [static]

Definition at line 170 of file datetime-interface.c.

{

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

Here is the caller graph for this function:

static void datetime_interface_init ( DatetimeInterface *  self) [static]

Definition at line 93 of file datetime-interface.c.

{
       self->priv = G_TYPE_INSTANCE_GET_PRIVATE (self, DATETIME_INTERFACE_TYPE, DatetimeInterfacePrivate);

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

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

       return;
}

Here is the call graph for this function:

void datetime_interface_update ( DatetimeInterface *  self)

Definition at line 178 of file datetime-interface.c.

{
       g_return_if_fail(IS_DATETIME_INTERFACE(self));

       DatetimeInterfacePrivate * priv = DATETIME_INTERFACE_GET_PRIVATE(self);
       GError * error = NULL;

       g_dbus_connection_emit_signal (priv->bus,
                                      NULL,
                                      SERVICE_OBJ,
                                      SERVICE_IFACE,
                                      "UpdateTime",
                                      NULL,
                                      &error);

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

       return;
}

Here is the caller graph for this function:

G_DEFINE_TYPE ( DatetimeInterface  ,
datetime_interface  ,
G_TYPE_OBJECT   
)

Variable Documentation

GDBusInterfaceInfo* interface_info = NULL [static]

Definition at line 50 of file datetime-interface.c.

GDBusNodeInfo* node_info = NULL [static]

Definition at line 49 of file datetime-interface.c.