aboutsummaryrefslogtreecommitdiff
path: root/libindicator/indicator-service.c
diff options
context:
space:
mode:
authorTed Gould <ted@gould.cx>2009-12-03 16:25:33 -0600
committerTed Gould <ted@gould.cx>2009-12-03 16:25:33 -0600
commita6d2a696cf0df7be8a2c731e441ffdf8ce4dc086 (patch)
tree296a77aaa8f2574ca9fff0dbd1c78623916363fc /libindicator/indicator-service.c
parent873b502fb3f519492a7ec0a1e2dea434d866f3d8 (diff)
downloadlibayatana-indicator-a6d2a696cf0df7be8a2c731e441ffdf8ce4dc086.tar.gz
libayatana-indicator-a6d2a696cf0df7be8a2c731e441ffdf8ce4dc086.tar.bz2
libayatana-indicator-a6d2a696cf0df7be8a2c731e441ffdf8ce4dc086.zip
Putting in comments for the functions.
Diffstat (limited to 'libindicator/indicator-service.c')
-rw-r--r--libindicator/indicator-service.c39
1 files changed, 38 insertions, 1 deletions
diff --git a/libindicator/indicator-service.c b/libindicator/indicator-service.c
index 89842bb..003566a 100644
--- a/libindicator/indicator-service.c
+++ b/libindicator/indicator-service.c
@@ -14,8 +14,16 @@ static gboolean _indicator_service_server_un_watch (IndicatorService * service,
#include "dbus-shared.h"
/* Private Stuff */
+/**
+ IndicatorSevicePrivate:
+ @name: The DBus well known name for the service.
+ @dbus_proxy: A proxy for talking to the dbus bus manager.
+ @timeout: The source ID for the timeout event.
+ @watcher: A list of processes on dbus that are watching us.
+ @this_service_version: The version to hand out that we're
+ implementing. May not be set, so we'll send zero (default).
+*/
typedef struct _IndicatorServicePrivate IndicatorServicePrivate;
-
struct _IndicatorServicePrivate {
gchar * name;
DBusGProxy * dbus_proxy;
@@ -113,6 +121,10 @@ indicator_service_class_init (IndicatorServiceClass *klass)
return;
}
+/* This function builds the variables, sets up the dbus
+ proxy and registers the object on dbus. Importantly,
+ it does not request a name as we don't know what name
+ we have yet. */
static void
indicator_service_init (IndicatorService *self)
{
@@ -162,6 +174,8 @@ indicator_service_init (IndicatorService *self)
return;
}
+/* Unrefcounting the proxies and making sure that our
+ timeout doesn't come to haunt us. */
static void
indicator_service_dispose (GObject *object)
{
@@ -181,6 +195,8 @@ indicator_service_dispose (GObject *object)
return;
}
+/* Freeing the name we're looking for and all of the
+ information on the watchers we're tracking. */
static void
indicator_service_finalize (GObject *object)
{
@@ -200,6 +216,8 @@ indicator_service_finalize (GObject *object)
return;
}
+/* Either copies a string for the name or it just grabs
+ the value of the version. */
static void
set_property (GObject * object, guint prop_id, const GValue * value, GParamSpec * pspec)
{
@@ -236,6 +254,8 @@ set_property (GObject * object, guint prop_id, const GValue * value, GParamSpec
return;
}
+/* Copies out the name into a value or the version number.
+ Probably this is the least useful code in this file. */
static void
get_property (GObject * object, guint prop_id, GValue * value, GParamSpec * pspec)
{
@@ -267,6 +287,9 @@ get_property (GObject * object, guint prop_id, GValue * value, GParamSpec * pspe
return;
}
+/* This is the function that gets executed if we timeout
+ because there are no watchers. We sent the shutdown
+ signal and hope someone does something sane with it. */
static gboolean
timeout_no_watchers (gpointer data)
{
@@ -274,6 +297,9 @@ timeout_no_watchers (gpointer data)
return FALSE;
}
+/* The callback from our request to get a well known name
+ on dbus. If we can't get it we send the shutdown signal.
+ Else we start the timer to see if anyone cares about us. */
static void
try_and_get_name_cb (DBusGProxy * proxy, guint status, GError * error, gpointer data)
{
@@ -294,6 +320,7 @@ try_and_get_name_cb (DBusGProxy * proxy, guint status, GError * error, gpointer
return;
}
+/* This function sets up the request for the name on dbus. */
static void
try_and_get_name (IndicatorService * service)
{
@@ -310,6 +337,10 @@ try_and_get_name (IndicatorService * service)
return;
}
+/* Here is the function that gets called by the dbus
+ interface "Watch" function. It is an async function so
+ that we can get the sender and store that information. We
+ put them in a list and reset the timeout. */
static gboolean
_indicator_service_server_watch (IndicatorService * service, DBusGMethodInvocation * method)
{
@@ -328,12 +359,18 @@ _indicator_service_server_watch (IndicatorService * service, DBusGMethodInvocati
return TRUE;
}
+/* Mung g_strcmp0 into GCompareFunc */
static gint
find_watcher (gconstpointer a, gconstpointer b)
{
return g_strcmp0((const gchar *)a, (const gchar *)b);
}
+/* A function connecting into the dbus interface for the
+ "UnWatch" function. It is also an async function to get
+ the sender. It then looks the sender up and removes them
+ from the list of watchers. If there are none left, it then
+ starts the timer for the shutdown signal. */
static gboolean
_indicator_service_server_un_watch (IndicatorService * service, DBusGMethodInvocation * method)
{