Back to index

libindicate  12.10.0
Classes | Enumerations | Functions | Variables
listener.c File Reference
#include <stdlib.h>
#include <gio/gio.h>
#include "listener.h"
#include "interests-priv.h"
#include "dbus-shared.h"
#include "gen-indicate-interface.xml.h"
#include "gen-indicate-listener.xml.h"
#include "indicate-marshal.h"
#include "listener-private.h"

Go to the source code of this file.

Classes

struct  proxy_t
struct  proxy_todo_t

Enumerations

enum  { LAST_ERROR }
enum  {
  INDICATOR_ADDED, INDICATOR_REMOVED, INDICATOR_MODIFIED, SERVER_ADDED,
  SERVER_REMOVED, SERVER_COUNT_CHANGED, INDICATOR_SERVERS_REPORT, LAST_SIGNAL
}

Functions

static gint proxy_t_equal (gconstpointer pa, gconstpointer pb)
 G_DEFINE_TYPE (IndicateListener, indicate_listener, G_TYPE_OBJECT)
static void indicate_listener_finalize (GObject *obj)
static void indicate_listener_dispose (GObject *obj)
static void proxy_struct_destroy (gpointer data)
static void todo_list_add (const gchar *name, const gchar *path, IndicateListener *listener)
static gboolean todo_idle (gpointer data)
static void set_max_indicators_cb (GObject *object, GAsyncResult *res, gpointer user_data)
static void get_type_initial_cb (IndicateListener *listener, IndicateListenerServer *server, const gchar *type, gpointer data)
static void get_type_cb (IndicateListener *listener, IndicateListenerServer *server, const gchar *type, gpointer data)
static void proxy_indicator_added_legacy (guint id, gchar *type, proxy_t *proxyt)
static void proxy_indicator_added (guint id, proxy_t *proxyt)
static void proxy_indicator_removed_legacy (guint id, gchar *type, proxy_t *proxyt)
static void proxy_indicator_removed (guint id, proxy_t *proxyt)
static void proxy_indicator_modified (guint id, const gchar *property, proxy_t *proxyt)
static void proxy_server_count_changed (guint count, proxy_t *proxyt)
static void proxy_get_indicator_list (GObject *object, GAsyncResult *res, gpointer data)
static void proxy_destroyed (GObject *proxy, 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 bus_get_cb (GObject *object, GAsyncResult *res, gpointer user_data)
static void bus_filter_show_server (GDBusConnection *connection, const gchar *sender, const gchar *object, const gchar *interface, const gchar *signal, GVariant *params, gpointer user_data)
static void prox_ready_cb (GObject *object, GAsyncResult *res, gpointer user_data)
static void proxy_signal_cb (GDBusProxy *proxy, gchar *sender, gchar *signal, GVariant *params, gpointer user_data)
static void indicate_listener_class_init (IndicateListenerClass *class)
static void indicate_listener_init (IndicateListener *listener)
static void proxy_name_owner_changed (GDBusConnection *connection, const gchar *sender_name, const gchar *object_path, const gchar *interface_name, const gchar *signal_name, GVariant *parameters, gpointer user_data)
IndicateListener * indicate_listener_new (void)
 indicate_listener_new:
IndicateListener * indicate_listener_ref_default (void)
 indicate_listener_ref_default:
static void proxy_struct_destroy_indicators (gpointer key, gpointer value, gpointer data)

Variables

static guint signals [LAST_SIGNAL] = { 0 }
static GDBusNodeInfo * bus_indicate_node_info = NULL
static GDBusInterfaceInfo * bus_indicate_interface_info = NULL
static GDBusNodeInfo * bus_listener_node_info = NULL
static GDBusInterfaceInfo * bus_listener_interface_info = NULL
static const GDBusInterfaceVTable bus_interface_table
static IndicateListener * default_indicate_listener = NULL

Class Documentation

struct proxy_t

Definition at line 60 of file listener.c.

Class Members
GDBusConnection * connection
guint dbus_listener_sub
gboolean hidden
GHashTable * indicators
guint introspect_level
IndicateListener * listener
gchar * name
gchar * path
GDBusProxy * property_proxy
GDBusProxy * proxy
IndicateListenerServer server
gchar * type
struct proxy_todo_t

Definition at line 92 of file listener.c.

Class Members
GDBusConnection * bus
gchar * name
gchar * path

Enumeration Type Documentation

anonymous enum
Enumerator:
LAST_ERROR 

Definition at line 40 of file listener.c.

     {
       LAST_ERROR
};
anonymous enum
Enumerator:
INDICATOR_ADDED 
INDICATOR_REMOVED 
INDICATOR_MODIFIED 
SERVER_ADDED 
SERVER_REMOVED 
SERVER_COUNT_CHANGED 
INDICATOR_SERVERS_REPORT 
LAST_SIGNAL 

Definition at line 45 of file listener.c.


Function Documentation

static void bus_filter_show_server ( GDBusConnection *  connection,
const gchar *  sender,
const gchar *  object,
const gchar *  interface,
const gchar *  signal,
GVariant *  params,
gpointer  user_data 
) [static]

Definition at line 443 of file listener.c.

{
       if (g_strcmp0(signal, "ServerShow") != 0) {
              return;
       }

       todo_list_add(sender, object, INDICATE_LISTENER(user_data));

       return;
}

Here is the call graph for this function:

Here is the caller graph for this function:

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

Definition at line 326 of file listener.c.

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

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

       IndicateListenerPrivate * priv = INDICATE_LISTENER_GET_PRIVATE(user_data);
       priv->session_bus = connection;

       /* Export this object onto the bus */
       priv->object_registration = g_dbus_connection_register_object(priv->session_bus,
                                                                     INDICATE_LISTENER_OBJ_PATH,
                                                                     bus_listener_interface_info,
                                                                     &bus_interface_table,
                                                                     user_data,
                                                                     NULL,
                                                                     &error);

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

       /* Watch for servers starting up */
       priv->signal_subscription = g_dbus_connection_signal_subscribe(priv->session_bus,
                                                                      NULL, /* sender */
                                                                      INDICATE_DBUS_IFACE,
                                                                      "ServerShow",
                                                                      NULL, /* path */
                                                                      NULL, /* arg0 */
                                                                      G_DBUS_SIGNAL_FLAGS_NONE,
                                                                      bus_filter_show_server,
                                                                      user_data,
                                                                      NULL); /* destroy notify */

       /* Tell that we're here! */
       g_dbus_connection_emit_signal(priv->session_bus,
                                     NULL, /* dest */
                                     INDICATE_LISTENER_OBJ_PATH,
                                     INDICATE_LISTENER_DBUS_IFACE,
                                     "IndicatorServersReport",
                                     NULL, /* params */
                                     &error);

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

       return;
}

Here is the call graph for this function:

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 387 of file listener.c.

{

       /* TODO: We should do this, in the future though */
}
G_DEFINE_TYPE ( IndicateListener  ,
indicate_listener  ,
G_TYPE_OBJECT   
)
static void get_type_cb ( IndicateListener *  listener,
IndicateListenerServer *  server,
const gchar *  type,
gpointer  data 
) [static]

Definition at line 755 of file listener.c.

{
       if (type == NULL) {
              /* This is usually caused by an error getting the type,
               * which would mean that this isn't an indicator server */
              return;
       }

       proxy_t * proxyt = (proxy_t *)data;

       if (proxyt->type != NULL) {
              g_free(proxyt->type);
              proxyt->type = NULL;
       }
       proxyt->type = g_strdup(type);

       return;
}

Here is the caller graph for this function:

static void get_type_initial_cb ( IndicateListener *  listener,
IndicateListenerServer *  server,
const gchar *  type,
gpointer  data 
) [static]

Definition at line 738 of file listener.c.

{
       get_type_cb(listener, server, type, data);

       proxy_t * proxyt = (proxy_t *)data;

       if (!proxyt->hidden && proxyt->type != NULL) {
              g_signal_emit(proxyt->listener, signals[SERVER_ADDED], 0, &proxyt->server, proxyt->type, TRUE);
       }

       return;
}

Here is the call graph for this function:

Here is the caller graph for this function:

static void indicate_listener_class_init ( IndicateListenerClass *  class) [static]

Definition at line 137 of file listener.c.

{
       /* g_debug("Listener Class Initialized"); */
       GObjectClass * gobj;
       gobj = G_OBJECT_CLASS(class);

       g_type_class_add_private (class, sizeof (IndicateListenerPrivate));

       gobj->dispose = indicate_listener_dispose;
       gobj->finalize = indicate_listener_finalize;

       signals[INDICATOR_ADDED] = g_signal_new(INDICATE_LISTENER_SIGNAL_INDICATOR_ADDED,
                                               G_TYPE_FROM_CLASS (class),
                                               G_SIGNAL_RUN_LAST,
                                               G_STRUCT_OFFSET (IndicateListenerClass, indicator_added),
                                               NULL, NULL,
                                               _indicate_marshal_VOID__POINTER_POINTER,
                                               G_TYPE_NONE, 2, INDICATE_TYPE_LISTENER_SERVER, INDICATE_TYPE_LISTENER_INDICATOR);
       signals[INDICATOR_REMOVED] = g_signal_new(INDICATE_LISTENER_SIGNAL_INDICATOR_REMOVED,
                                               G_TYPE_FROM_CLASS (class),
                                               G_SIGNAL_RUN_LAST,
                                               G_STRUCT_OFFSET (IndicateListenerClass, indicator_removed),
                                               NULL, NULL,
                                               _indicate_marshal_VOID__POINTER_POINTER,
                                               G_TYPE_NONE, 2, INDICATE_TYPE_LISTENER_SERVER, INDICATE_TYPE_LISTENER_INDICATOR);
       signals[INDICATOR_MODIFIED] = g_signal_new(INDICATE_LISTENER_SIGNAL_INDICATOR_MODIFIED,
                                               G_TYPE_FROM_CLASS (class),
                                               G_SIGNAL_RUN_LAST,
                                               G_STRUCT_OFFSET (IndicateListenerClass, indicator_modified),
                                               NULL, NULL,
                                               _indicate_marshal_VOID__POINTER_POINTER_STRING,
                                               G_TYPE_NONE, 3, INDICATE_TYPE_LISTENER_SERVER, INDICATE_TYPE_LISTENER_INDICATOR, G_TYPE_STRING);
       signals[SERVER_ADDED] = g_signal_new(INDICATE_LISTENER_SIGNAL_SERVER_ADDED,
                                               G_TYPE_FROM_CLASS (class),
                                               G_SIGNAL_RUN_LAST,
                                               G_STRUCT_OFFSET (IndicateListenerClass, server_added),
                                               NULL, NULL,
                                               _indicate_marshal_VOID__POINTER_STRING,
                                               G_TYPE_NONE, 2, INDICATE_TYPE_LISTENER_SERVER, G_TYPE_STRING);
       signals[SERVER_REMOVED] = g_signal_new(INDICATE_LISTENER_SIGNAL_SERVER_REMOVED,
                                               G_TYPE_FROM_CLASS (class),
                                               G_SIGNAL_RUN_LAST,
                                               G_STRUCT_OFFSET (IndicateListenerClass, server_removed),
                                               NULL, NULL,
                                               _indicate_marshal_VOID__POINTER_STRING,
                                               G_TYPE_NONE, 2, INDICATE_TYPE_LISTENER_SERVER, G_TYPE_STRING);
       signals[SERVER_COUNT_CHANGED] = g_signal_new(INDICATE_LISTENER_SIGNAL_SERVER_COUNT_CHANGED,
                                               G_TYPE_FROM_CLASS (class),
                                               G_SIGNAL_RUN_LAST,
                                               G_STRUCT_OFFSET (IndicateListenerClass, server_count_changed),
                                               NULL, NULL,
                                               _indicate_marshal_VOID__POINTER_UINT,
                                               G_TYPE_NONE, 2, INDICATE_TYPE_LISTENER_SERVER, G_TYPE_UINT);
       signals[INDICATOR_SERVERS_REPORT] = g_signal_new("indicator-servers-report",
                                               G_TYPE_FROM_CLASS (class),
                                               G_SIGNAL_RUN_LAST,
                                               G_STRUCT_OFFSET (IndicateListenerClass, indicator_servers_report),
                                               NULL, NULL,
                                               g_cclosure_marshal_VOID__VOID,
                                               G_TYPE_NONE, 0, G_TYPE_NONE);

       /* DBus interfaces */
       if (bus_indicate_node_info == NULL) {
              GError * error = NULL;

              bus_indicate_node_info = g_dbus_node_info_new_for_xml(_indicate_interface, &error);
              if (error != NULL) {
                     g_error("Unable to parse Indicate Interface description: %s", error->message);
                     g_error_free(error);
              }
       }

       if (bus_indicate_interface_info == NULL) {
              bus_indicate_interface_info = g_dbus_node_info_lookup_interface(bus_indicate_node_info, INDICATE_DBUS_IFACE);

              if (bus_indicate_interface_info == NULL) {
                     g_error("Unable to find interface '" INDICATE_DBUS_IFACE "'");
              }
       }

       if (bus_listener_node_info == NULL) {
              GError * error = NULL;

              bus_listener_node_info = g_dbus_node_info_new_for_xml(_indicate_listener, &error);
              if (error != NULL) {
                     g_error("Unable to parse Listener Interface description: %s", error->message);
                     g_error_free(error);
              }
       }

       if (bus_listener_interface_info == NULL) {
              bus_listener_interface_info = g_dbus_node_info_lookup_interface(bus_listener_node_info, INDICATE_LISTENER_DBUS_IFACE);

              if (bus_listener_interface_info == NULL) {
                     g_error("Unable to find interface '" INDICATE_LISTENER_DBUS_IFACE "'");
              }
       }

       return;
}

Here is the call graph for this function:

static void indicate_listener_dispose ( GObject *  obj) [static]

Definition at line 264 of file listener.c.

{
       IndicateListener * listener = INDICATE_LISTENER(obj);
        IndicateListenerPrivate * priv = INDICATE_LISTENER_GET_PRIVATE(listener);

       if (priv->signal_subscription != 0) {
              g_dbus_connection_signal_unsubscribe(priv->session_bus, priv->signal_subscription);
              priv->signal_subscription = 0;
       }

       if (priv->object_registration != 0) {
              g_dbus_connection_signal_unsubscribe(priv->session_bus, priv->object_registration);
              priv->object_registration = 0;
       }

       G_OBJECT_CLASS (indicate_listener_parent_class)->dispose (obj);
       return;
}

Here is the caller graph for this function:

static void indicate_listener_finalize ( GObject *  obj) [static]

Definition at line 285 of file listener.c.

{
       IndicateListener * listener = INDICATE_LISTENER(obj);
       IndicateListenerPrivate * priv = INDICATE_LISTENER_GET_PRIVATE(listener);

       if (priv->todo_idle != 0) {
              g_idle_remove_by_data(obj);
       }

       /* Hack: proxy_struct_destroy() lacks a user_data parameter, but since the
        * caller is responsible for handling params on the stack, it works
        */
       g_list_foreach(priv->proxies, (GFunc)proxy_struct_destroy, NULL);
       g_list_free(priv->proxies);

       G_OBJECT_CLASS (indicate_listener_parent_class)->finalize (obj);
       return;
}

Here is the call graph for this function:

Here is the caller graph for this function:

static void indicate_listener_init ( IndicateListener *  listener) [static]

Definition at line 239 of file listener.c.

{
       /* g_debug("Listener Object Initialized"); */
       IndicateListenerPrivate * priv = INDICATE_LISTENER_GET_PRIVATE(listener);

       /* Get the buses */
       g_bus_get(G_BUS_TYPE_SESSION,
                 NULL, /* TODO: Cancelable */
                 bus_get_cb,
                 listener);

       /* Initialize Data structures */
       priv->proxies = NULL;

       /* TODO: Look at some common scenarios and find out how to make this sized */
       priv->proxy_todo = g_array_new(FALSE, TRUE, sizeof(proxy_todo_t));
       priv->todo_idle = 0;

       priv->max_indicators = -1;

       return;
}

Here is the call graph for this function:

IndicateListener* indicate_listener_new ( void  )

indicate_listener_new:

Creates a new Listener object. Does not set this to the default listener object.

Return value: A new listener object.

Definition at line 402 of file listener.c.

{
       IndicateListener * listener;
       listener = g_object_new(INDICATE_TYPE_LISTENER, NULL);
       return listener;
}
IndicateListener* indicate_listener_ref_default ( void  )

indicate_listener_ref_default:

Looks for the default listener, and if it doesn't exist it'll allocate a new one and mark it the default. This is what most programs should use rather than indicate_listener_new because it is rare that anyone would need more than a single listener. This function does increase the ref count on the object so anyone calling it should unref thier instance of the default listener.

Return value: (transfer full): The default instance of #IndicateListener for the program.

Definition at line 426 of file listener.c.

{
       if (default_indicate_listener != NULL) {
              g_object_ref(default_indicate_listener);
       } else {
              default_indicate_listener = g_object_new(INDICATE_TYPE_LISTENER, NULL);
              g_object_add_weak_pointer(G_OBJECT(default_indicate_listener),
                                        (gpointer *)&default_indicate_listener);
       }

       return default_indicate_listener;
}

Here is the caller graph for this function:

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

Definition at line 626 of file listener.c.

{
       proxy_t * proxyt = (proxy_t *)user_data;
       GError * error = NULL;
       GDBusProxy * proxy = g_dbus_proxy_new_finish(res, &error);

       if (error != NULL) {
              g_warning("Unable to create proxy for %s", proxyt->name);
              g_error_free(error);
              return;
       }

       proxyt->proxy = proxy;

       g_signal_connect(G_OBJECT(proxyt->proxy), "notify::g-name-owner", G_CALLBACK(proxy_destroyed), proxyt);
       g_signal_connect(G_OBJECT(proxyt->proxy), "g-signal", G_CALLBACK(proxy_signal_cb), proxyt);

       proxyt->dbus_listener_sub = g_dbus_connection_signal_subscribe(g_dbus_proxy_get_connection(proxy),
                                                                      "org.freedesktop.DBus", /* sender */
                                                                      "org.freedesktop.DBus",
                                                                      "NameOwnerChanged",
                                                                      "/org/freedesktop/DBus", /* path */
                                                                      g_dbus_proxy_get_name(proxy), /* arg0 */
                                                                      G_DBUS_SIGNAL_FLAGS_NONE,
                                                                      proxy_name_owner_changed,
                                                                      proxyt,
                                                                      NULL); /* destroy notify */

       /* Making sure the server has the proxy as well */
       proxyt->server.proxy = proxyt->proxy;

       IndicateListenerPrivate * priv = INDICATE_LISTENER_GET_PRIVATE(proxyt->listener);
       /* Adding into the list of proxies */
       priv->proxies = g_list_prepend(priv->proxies, proxyt);

       /* We're setting the max number of indicators from the default
          when we detect it.  This should give a reasonable amount of
          time for listeners to set the default if they want something
          different from infinite.  Otherwise it'd be easy to miss the
          first couple. */
       proxyt->server.max_indicators = priv->max_indicators;
       if (proxyt->server.max_indicators != -1) {
              g_dbus_proxy_call(proxyt->proxy,
                                "SetMaxIndicators",
                                g_variant_new("(i)", proxyt->server.max_indicators),
                                G_DBUS_CALL_FLAGS_NONE,
                                -1, /* timeout */
                                NULL,
                                set_max_indicators_cb,
                                proxyt->server.name);
       }

       indicate_listener_server_get_type(proxyt->listener, &proxyt->server, get_type_initial_cb, proxyt);


       g_dbus_proxy_call(proxyt->proxy,
                         "GetIndicatorList",
                         NULL, /* params */
                         G_DBUS_CALL_FLAGS_NONE,
                         -1, /* timeout */
                         NULL,
                         proxy_get_indicator_list,
                         proxyt);

       return;
}

Here is the call graph for this function:

Here is the caller graph for this function:

void proxy_destroyed ( GObject *  proxy,
gpointer  user_data 
) [static]

Definition at line 539 of file listener.c.

{
       proxy_t * proxyt = (proxy_t *)user_data;
       proxyt->proxy = NULL; /* Clear this so we don't get a double free on this guy */
       IndicateListener * listener = proxyt->listener;
       IndicateListenerPrivate * priv = INDICATE_LISTENER_GET_PRIVATE(listener);
       priv->proxies = g_list_remove_all(priv->proxies, proxyt);
       proxy_struct_destroy(proxyt);
       return;
}

Here is the call graph for this function:

Here is the caller graph for this function:

static void proxy_get_indicator_list ( GObject *  object,
GAsyncResult *  res,
gpointer  data 
) [static]

Definition at line 794 of file listener.c.

{
       GError * error = NULL;
       GVariant * retval = g_dbus_proxy_call_finish(G_DBUS_PROXY(object), res, &error);

       if (error != NULL) {
              g_warning("Unable to get indicator list");
              g_error_free(error);
              return;
       }

       proxy_t * proxyt = (proxy_t *)data;

       GVariant * list = g_variant_get_child_value(retval, 0);
       GVariantIter iter;
       g_variant_iter_init(&iter, list);
       gint id;

       while (g_variant_iter_next(&iter, "i", &id)) {
              proxy_indicator_added(id, proxyt);
       }

       if (retval != NULL) {
              g_variant_unref(retval);
       }

       return;
}

Here is the call graph for this function:

Here is the caller graph for this function:

static void proxy_indicator_added ( guint  id,
proxy_t proxyt 
) [static]

Definition at line 839 of file listener.c.

{
       g_debug("Proxy Indicator Added");
       g_return_if_fail(proxyt != NULL);

       if (!g_hash_table_lookup(proxyt->indicators, GUINT_TO_POINTER(id))) {
              g_hash_table_insert(proxyt->indicators, GUINT_TO_POINTER(id), GUINT_TO_POINTER(TRUE));
              g_signal_emit(proxyt->listener, signals[INDICATOR_ADDED], 0, &proxyt->server, GUINT_TO_POINTER(id), TRUE);
       }

       return;
}

Here is the caller graph for this function:

static void proxy_indicator_added_legacy ( guint  id,
gchar *  type,
proxy_t proxyt 
) [static]

Definition at line 828 of file listener.c.

{
       return proxy_indicator_added(id, proxyt);
}

Here is the call graph for this function:

Here is the caller graph for this function:

static void proxy_indicator_modified ( guint  id,
const gchar *  property,
proxy_t proxyt 
) [static]

Definition at line 890 of file listener.c.

{
       g_debug("Proxy Indicator Modified");
       g_return_if_fail(proxyt != NULL);

       if (proxyt->indicators == NULL) {
              g_warning("Oddly we had an indicator modified from an interface that we didn't think had indicators.");
              return;
       }

       if (!g_hash_table_lookup(proxyt->indicators, GUINT_TO_POINTER(id))) {
              g_warning("Can not modify indicator %d with property '%s' as there are no indicators with that id on %s.", id, property, proxyt->name);
              return;
       }

       g_signal_emit(proxyt->listener, signals[INDICATOR_MODIFIED], 0, &proxyt->server, GUINT_TO_POINTER(id), property, TRUE);

       return;
}

Here is the caller graph for this function:

static void proxy_indicator_removed ( guint  id,
proxy_t proxyt 
) [static]

Definition at line 865 of file listener.c.

{
       g_debug("Proxy Indicator Removed");
       g_return_if_fail(proxyt != NULL);

       if (proxyt->indicators == NULL) {
              g_warning("Oddly we had an indicator removed from an interface that we didn't think had indicators.");
              return;
       }

       if (!g_hash_table_lookup(proxyt->indicators, GUINT_TO_POINTER(id))) {
              g_warning("No indicator %d on '%s'.", id, proxyt->name);
              return;
       }

       g_hash_table_remove(proxyt->indicators, GUINT_TO_POINTER(id));
       g_signal_emit(proxyt->listener, signals[INDICATOR_REMOVED], 0, &proxyt->server, GUINT_TO_POINTER(id), TRUE);

       return;
}

Here is the caller graph for this function:

static void proxy_indicator_removed_legacy ( guint  id,
gchar *  type,
proxy_t proxyt 
) [static]

Definition at line 856 of file listener.c.

{
       return proxy_indicator_removed(id, proxyt);
}

Here is the call graph for this function:

Here is the caller graph for this function:

static void proxy_name_owner_changed ( GDBusConnection *  connection,
const gchar *  sender_name,
const gchar *  object_path,
const gchar *  interface_name,
const gchar *  signal_name,
GVariant *  parameters,
gpointer  user_data 
) [static]

Definition at line 307 of file listener.c.

{
       const gchar * new_name;
       g_variant_get(parameters, "(&s&s&s)", NULL, NULL, &new_name);

       if (new_name == NULL || new_name[0] == 0) {
              proxy_t * proxyt = (proxy_t *)user_data;

              g_object_unref(proxyt->proxy);
              proxyt->proxy = NULL;

              proxy_destroyed(NULL, user_data);
       }

       return;
}

Here is the call graph for this function:

Here is the caller graph for this function:

static void proxy_server_count_changed ( guint  count,
proxy_t proxyt 
) [static]

Definition at line 915 of file listener.c.

{
       g_debug("Proxy Server Count Changed");
       g_return_if_fail(proxyt != NULL);
       g_signal_emit(proxyt->listener, signals[SERVER_COUNT_CHANGED], 0, &proxyt->server, count, TRUE);
       return;
}

Here is the caller graph for this function:

static void proxy_signal_cb ( GDBusProxy *  proxy,
gchar *  sender,
gchar *  signal,
GVariant *  params,
gpointer  user_data 
) [static]

Definition at line 695 of file listener.c.

{
       proxy_t * proxyt = (proxy_t *)user_data;

       if (g_strcmp0(signal, "IndicatorAdded") == 0) {
              guint id; gchar * type;
              g_variant_get(params, "(us)", &id, &type);
              proxy_indicator_added_legacy(id, type, proxyt);
       } else if (g_strcmp0(signal, "IndicatorNew") == 0) {
              guint id;
              g_variant_get(params, "(u)", &id);
              proxy_indicator_added(id, proxyt);
       } else if (g_strcmp0(signal, "IndicatorRemoved") == 0) {
              guint id; gchar * type;
              g_variant_get(params, "(us)", &id, &type);
              proxy_indicator_removed_legacy(id, type, proxyt);
       } else if (g_strcmp0(signal, "IndicatorDelete") == 0) {
              guint id;
              g_variant_get(params, "(u)", &id);
              proxy_indicator_removed(id, proxyt);
       } else if (g_strcmp0(signal, "IndicatorModified") == 0) {
              guint id; gchar * property;
              g_variant_get(params, "(us)", &id, &property);
              proxy_indicator_modified(id, property, proxyt);
       } else if (g_strcmp0(signal, "ServerCountChanged") == 0) {
              guint count;
              g_variant_get(params, "(u)", &count);
              proxy_server_count_changed(count, proxyt);
       } else if (g_strcmp0(signal, "ServerShow") == 0) {
              /* Unused here */
       } else if (g_strcmp0(signal, "ServerHide") == 0) {
              /* Unused here */
       } else {
              g_warning("Unknown signal from server '%s'", signal);
       }

       return;
}

Here is the call graph for this function:

Here is the caller graph for this function:

static void proxy_struct_destroy ( gpointer  data) [static]

Definition at line 470 of file listener.c.

{
       proxy_t * proxy_data = data;

       if (proxy_data->indicators != NULL) {
              g_hash_table_foreach(proxy_data->indicators,
                                                  proxy_struct_destroy_indicators,
                                                  proxy_data);
              g_hash_table_destroy(proxy_data->indicators);

              g_signal_emit(proxy_data->listener, signals[SERVER_REMOVED], 0, &proxy_data->server, proxy_data->type, TRUE);
              proxy_data->indicators = NULL;
       }

       if (proxy_data->dbus_listener_sub != 0) {
              g_dbus_connection_signal_unsubscribe(proxy_data->connection, proxy_data->dbus_listener_sub);
              proxy_data->dbus_listener_sub = 0;
       }

       if (proxy_data->proxy != NULL) {
              g_object_unref(G_OBJECT(proxy_data->proxy));
       }

       if (proxy_data->name != NULL) {
              g_free(proxy_data->name);
       }

       if (proxy_data->path != NULL) {
              g_free(proxy_data->path);
       }

       if (proxy_data->type != NULL) {
              g_free(proxy_data->type);
       }
       g_free(proxy_data);

       return;
}

Here is the call graph for this function:

Here is the caller graph for this function:

static void proxy_struct_destroy_indicators ( gpointer  key,
gpointer  value,
gpointer  data 
) [static]

Definition at line 457 of file listener.c.

{
       proxy_t * proxy_data = (proxy_t *)data;

       if (value) {
              g_signal_emit(proxy_data->listener, signals[INDICATOR_REMOVED], 0, &proxy_data->server, GUINT_TO_POINTER(key), TRUE);
       }
       return;
}

Here is the caller graph for this function:

static gint proxy_t_equal ( gconstpointer  pa,
gconstpointer  pb 
) [static]

Definition at line 77 of file listener.c.

{
       proxy_t * a = (proxy_t *)pa; proxy_t * b = (proxy_t *)pb;

       if  (a->connection == b->connection) {
               if (g_strcmp0(a->name, b->name) == 0) {
                      return g_strcmp0(a->path, b->path);
              }
        }

       /* we're only using this for equal, not sorting */
       return 1;

}

Here is the caller graph for this function:

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

Definition at line 777 of file listener.c.

{
       GError * error = NULL;
       g_dbus_proxy_call_finish(G_DBUS_PROXY(object), res, &error);

       if (error != NULL) {
              g_warning("Unable to set the max indicators on '%s': %s", (gchar *)user_data, error->message);
              g_error_free(error);
       }

       return;
}

Here is the caller graph for this function:

gboolean todo_idle ( gpointer  data) [static]

Definition at line 551 of file listener.c.

{
       IndicateListener * listener = INDICATE_LISTENER(data);
       if (listener == NULL) {
              g_error("Listener got lost in todo_idle");
              return FALSE;
       }

       IndicateListenerPrivate * priv = INDICATE_LISTENER_GET_PRIVATE(listener);

       if (priv->proxy_todo->len == 0) {
              /* Basically if we have no todo, we need to stop running.  This
               * is done this way to make the function error handling simpler
               * and results in an extra run */
              priv->todo_idle = 0;
              return FALSE;
       }

       proxy_todo_t * todo = &g_array_index(priv->proxy_todo, proxy_todo_t, priv->proxy_todo->len - 1);
       /* Remove the todo list */
       priv->proxy_todo = g_array_remove_index(priv->proxy_todo, priv->proxy_todo->len - 1);

       /* Check to see if we already have this item, if so,
          we assume that it's signal handler will handle the
          ServerShow signal.  We're just going to exit this 
          function. */
       if (TRUE) {
              proxy_t searchitem;
              searchitem.name = todo->name;
              searchitem.connection = todo->bus;
              searchitem.path = todo->path;

              GList * proxyitem = g_list_find_custom(priv->proxies, &searchitem, proxy_t_equal);
              if (proxyitem != NULL) {
                     g_free(todo->name);
                     g_free(todo->path);
                     return TRUE;
              }
       }

       proxy_t * proxyt = g_new0(proxy_t, 1);
       proxyt->name = todo->name;
       proxyt->path = todo->path;
       proxyt->type = NULL;
       proxyt->property_proxy = NULL;
       proxyt->proxy = NULL;
       proxyt->listener = listener;
       proxyt->indicators = NULL;
       proxyt->hidden = FALSE;
       proxyt->connection = todo->bus;
       proxyt->server.name = todo->name;
       proxyt->server.proxy = NULL;
       proxyt->server.connection = proxyt->connection;
       proxyt->server.max_indicators = priv->max_indicators;

       /* Build the indicators hash */
       proxyt->indicators = g_hash_table_new(g_direct_hash, g_direct_equal);

       /* Build the proxy and ensure that it gets created.  If
          it gets created we're all happy. */
       g_dbus_proxy_new(priv->session_bus,
                        G_DBUS_PROXY_FLAGS_NONE,
                        bus_indicate_interface_info,
                        proxyt->name,
                        todo->path,
                        INDICATE_DBUS_IFACE,
                        NULL, /* cancel */
                        prox_ready_cb,
                        proxyt);

       return TRUE; /* do the next entry */
}

Here is the call graph for this function:

Here is the caller graph for this function:

static void todo_list_add ( const gchar *  name,
const gchar *  path,
IndicateListener *  listener 
) [static]

Definition at line 513 of file listener.c.

{
       if (name == NULL || name[0] != ':') {
              return;
       }

       IndicateListenerPrivate * priv = INDICATE_LISTENER_GET_PRIVATE(listener);

       proxy_todo_t todo;
       todo.name = g_strdup(name);
       todo.path = g_strdup(path);
       todo.bus  = priv->session_bus;

       g_array_append_val(priv->proxy_todo, todo);

       if (priv->todo_idle == 0) {
              priv->todo_idle = g_idle_add(todo_idle, listener);
       }

       return;
}

Here is the call graph for this function:

Here is the caller graph for this function:


Variable Documentation

GDBusInterfaceInfo* bus_indicate_interface_info = NULL [static]

Definition at line 125 of file listener.c.

GDBusNodeInfo* bus_indicate_node_info = NULL [static]

Definition at line 124 of file listener.c.

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

Definition at line 128 of file listener.c.

GDBusInterfaceInfo* bus_listener_interface_info = NULL [static]

Definition at line 127 of file listener.c.

GDBusNodeInfo* bus_listener_node_info = NULL [static]

Definition at line 126 of file listener.c.

IndicateListener* default_indicate_listener = NULL [static]

Definition at line 410 of file listener.c.

guint signals[LAST_SIGNAL] = { 0 } [static]

Definition at line 56 of file listener.c.