aboutsummaryrefslogtreecommitdiff
path: root/libindicate/server.c
diff options
context:
space:
mode:
Diffstat (limited to 'libindicate/server.c')
-rw-r--r--libindicate/server.c232
1 files changed, 227 insertions, 5 deletions
diff --git a/libindicate/server.c b/libindicate/server.c
index e3d071c..a3d3be8 100644
--- a/libindicate/server.c
+++ b/libindicate/server.c
@@ -29,6 +29,7 @@ License version 3 and version 2.1 along with this program. If not, see
#include "server.h"
#include "interests-priv.h"
+#include "server-marshal.h"
#include <dbus/dbus-glib.h>
#include <dbus/dbus-glib-lowlevel.h>
@@ -163,41 +164,101 @@ indicate_server_class_init (IndicateServerClass * class)
gobj->set_property = set_property;
gobj->get_property = get_property;
+ /**
+ IndicateServer::indicator-added:
+ @arg0: The #IndicateServer object
+ @arg1: The #IndicateIndicator ID number
+ @arg2: The type of the indicator
+
+ Emitted every time that a new indicator is made visible to
+ the world. This results in a signal on DBus.
+
+ Can be emitted by subclasses using indicate_server_emit_indicator_added()
+ */
signals[INDICATOR_ADDED] = g_signal_new(INDICATE_SERVER_SIGNAL_INDICATOR_ADDED,
G_TYPE_FROM_CLASS (class),
G_SIGNAL_RUN_LAST,
G_STRUCT_OFFSET (IndicateServerClass, indicator_added),
NULL, NULL,
- g_cclosure_marshal_VOID__UINT_POINTER,
+ _indicate_server_marshal_VOID__UINT_STRING,
G_TYPE_NONE, 2, G_TYPE_UINT, G_TYPE_STRING);
+ /**
+ IndicateServer::indicator-removed:
+ @arg0: The #IndicateServer object
+ @arg1: The #IndicateIndicator ID number
+ @arg2: The type of the indicator
+
+ Emitted every time that a new indicator is made invisible to
+ the world. This results in a signal on DBus.
+
+ Can be emitted by subclasses using indicate_server_emit_indicator_removed()
+ */
signals[INDICATOR_REMOVED] = g_signal_new(INDICATE_SERVER_SIGNAL_INDICATOR_REMOVED,
G_TYPE_FROM_CLASS (class),
G_SIGNAL_RUN_LAST,
G_STRUCT_OFFSET (IndicateServerClass, indicator_removed),
NULL, NULL,
- g_cclosure_marshal_VOID__UINT_POINTER,
+ _indicate_server_marshal_VOID__UINT_STRING,
G_TYPE_NONE, 2, G_TYPE_UINT, G_TYPE_STRING);
+ /**
+ IndicateServer::indicator-modified:
+ @arg0: The #IndicateServer object
+ @arg1: The #IndicateIndicator ID number
+ @arg2: The name of the property modified
+
+ Emitted every time that a property on an indicator changes
+ and it is visible to the world. This results in a signal on DBus.
+
+ Can be emitted by subclasses using indicate_server_emit_indicator_modified()
+ */
signals[INDICATOR_MODIFIED] = g_signal_new(INDICATE_SERVER_SIGNAL_INDICATOR_MODIFIED,
G_TYPE_FROM_CLASS (class),
G_SIGNAL_RUN_LAST,
G_STRUCT_OFFSET (IndicateServerClass, indicator_modified),
NULL, NULL,
- g_cclosure_marshal_VOID__UINT_POINTER,
+ _indicate_server_marshal_VOID__UINT_STRING,
G_TYPE_NONE, 2, G_TYPE_UINT, G_TYPE_STRING);
+ /**
+ IndicateServer::server-show:
+ @arg0: The #IndicateServer object
+ @arg1: The type of the server
+
+ Emitted when a server comes onto DBus by being shown. This
+ is typically when listeners start reacting to the application's
+ indicators. This results in a signal on DBus.
+ */
signals[SERVER_SHOW] = g_signal_new(INDICATE_SERVER_SIGNAL_SERVER_SHOW,
G_TYPE_FROM_CLASS (class),
G_SIGNAL_RUN_LAST,
G_STRUCT_OFFSET (IndicateServerClass, server_show),
NULL, NULL,
- g_cclosure_marshal_VOID__POINTER,
+ g_cclosure_marshal_VOID__STRING,
G_TYPE_NONE, 1, G_TYPE_STRING);
+ /**
+ IndicateServer::server-hide:
+ @arg0: The #IndicateServer object
+ @arg1: The type of the server
+
+ Emitted when a server removes itself from DBus. This results
+ in a signal on DBus.
+ */
signals[SERVER_HIDE] = g_signal_new(INDICATE_SERVER_SIGNAL_SERVER_HIDE,
G_TYPE_FROM_CLASS (class),
G_SIGNAL_RUN_LAST,
G_STRUCT_OFFSET (IndicateServerClass, server_hide),
NULL, NULL,
- g_cclosure_marshal_VOID__POINTER,
+ g_cclosure_marshal_VOID__STRING,
G_TYPE_NONE, 1, G_TYPE_STRING);
+ /**
+ IndicateServer::server-display:
+ @arg0: The #IndicateServer object
+
+ Emitted when a listener signals that the server itself should be
+ displayed. This signal is caused by a user clicking on the application
+ item in the Messaging Menu. This signal is emitted by DBus.
+
+ Can be emitted by subclasses using indicate_server_emit_server_display()
+ */
signals[SERVER_DISPLAY] = g_signal_new(INDICATE_SERVER_SIGNAL_SERVER_DISPLAY,
G_TYPE_FROM_CLASS (class),
G_SIGNAL_RUN_LAST,
@@ -205,6 +266,14 @@ indicate_server_class_init (IndicateServerClass * class)
NULL, NULL,
g_cclosure_marshal_VOID__VOID,
G_TYPE_NONE, 0);
+ /**
+ IndicateServer::interest-added:
+ @arg0: The #IndicateServer object
+ @arg1: The interest that was added from #IndicateInterests
+
+ Emitted when a listener signals that they are interested in
+ this server for a particular reason. This signal is emitted by DBus.
+ */
signals[INTEREST_ADDED] = g_signal_new(INDICATE_SERVER_SIGNAL_INTEREST_ADDED,
G_TYPE_FROM_CLASS (class),
G_SIGNAL_RUN_LAST,
@@ -212,6 +281,14 @@ indicate_server_class_init (IndicateServerClass * class)
NULL, NULL,
g_cclosure_marshal_VOID__UINT,
G_TYPE_NONE, 1, G_TYPE_UINT);
+ /**
+ IndicateServer::interest-removed:
+ @arg0: The #IndicateServer object
+ @arg1: The interest that was removed from #IndicateInterests
+
+ Emitted when a listener signals that they are no longer interested in
+ this server for a particular reason. This signal is emitted by DBus.
+ */
signals[INTEREST_REMOVED] = g_signal_new(INDICATE_SERVER_SIGNAL_INTEREST_REMOVED,
G_TYPE_FROM_CLASS (class),
G_SIGNAL_RUN_LAST,
@@ -366,7 +443,17 @@ indicate_server_error_quark (void)
return quark;
}
+/**
+ indicate_server_show:
+ @server: The #IndicateServer to be shown
+ This function exports the object onto DBus and shows it
+ to the world. This will be the start of it receiving external
+ signals from DBus. It is likely that, if there are listeners
+ running, there will several #IndicateServer::interest-added
+ signals coming shortly after this function. This function
+ emits the #IndicateServer::server-added signal across the bus.
+*/
void
indicate_server_show (IndicateServer * server)
{
@@ -403,6 +490,16 @@ indicate_server_show (IndicateServer * server)
return;
}
+/**
+ indicate_server_hide:
+ @server: The #IndicateServer to hide.
+
+ This function hides the server from DBus so that it does
+ not get signals anymore. This causes the signal #IndicateServer::server-hide
+ to be sent across the bus for all listeners. Also internally
+ it will signal #IndicateServer::interest-removed for all the
+ interests that were currently set for this server.
+*/
void
indicate_server_hide (IndicateServer * server)
{
@@ -610,6 +707,16 @@ indicator_modified_cb (IndicateIndicator * indicator, gchar * property, Indicate
g_signal_emit(server, signals[INDICATOR_MODIFIED], 0, indicate_indicator_get_id(indicator), property, TRUE);
}
+/**
+ indicate_server_add_indicator:
+ @server: The #IndicateServer to add the #IndicateIndictor to.
+ @indicator: The #IndicateIndicator to add.
+
+ This function adds an indicator @indicator to the list that are
+ watched by the server @server. This means that signals that are
+ emitted by the indicator will be picked up and passed via DBus onto
+ listeners of the application.
+*/
void
indicate_server_add_indicator (IndicateServer * server, IndicateIndicator * indicator)
{
@@ -633,6 +740,14 @@ indicate_server_add_indicator (IndicateServer * server, IndicateIndicator * indi
return;
}
+/**
+ indicate_server_remove_indicator:
+ @server: The #IndicateServer to remove the #IndicateIndictor from.
+ @indicator: The #IndicateIndicator to remove.
+
+ Removes an indicator @indicator from being watched by the server @server
+ so it's signals are no longer watched and set over DBus.
+*/
void
indicate_server_remove_indicator (IndicateServer * server, IndicateIndicator * indicator)
{
@@ -663,6 +778,15 @@ indicate_server_set_dbus_object (const gchar * obj)
return;
}
+/**
+ indicate_server_set_desktop_file:
+ @server: The #IndicateServer to set the type of
+ @path: The new desktop file representing the server
+
+ This is a convience function to set the #IndicateServer:desktop
+ property of the @server object. The property can also be set
+ via traditional means, but this one is easier to read.
+*/
void
indicate_server_set_desktop_file (IndicateServer * server, const gchar * path)
{
@@ -673,6 +797,15 @@ indicate_server_set_desktop_file (IndicateServer * server, const gchar * path)
return;
}
+/**
+ indicate_server_set_type:
+ @server: The #IndicateServer to set the type of
+ @type: The new type of the server
+
+ This is a convience function to set the #IndicateServer:type
+ property of the @server object. The property can also be set
+ via traditional means, but this one is easier to read.
+*/
void
indicate_server_set_type (IndicateServer * server, const gchar * type)
{
@@ -685,6 +818,17 @@ indicate_server_set_type (IndicateServer * server, const gchar * type)
static IndicateServer * default_indicate_server = NULL;
+/**
+ indicate_server_ref_default:
+
+ This function will return a reference to the default #IndicateServer
+ reference if there is one, or it will create one if one had not
+ previously been created. It is recommended that all applications
+ use this function to create a #IndicateServer as it ensure that there
+ is only one per application.
+
+ Return value: A reference to the default #IndicateServer instance.
+*/
IndicateServer *
indicate_server_ref_default (void)
{
@@ -699,6 +843,16 @@ indicate_server_ref_default (void)
return default_indicate_server;
}
+/**
+ indicate_server_set_default:
+ @server: The #IndicateServer that should be used
+
+ This function is used to set the default #IndicateServer that will
+ be used when creating #IndicateIndicators or for anyone else that
+ calls indicate_server_ref_default(). Typically this is just an
+ instance of #IndicateServer but applications that create a subclass
+ of #IndicateServer should set this as well.
+*/
void
indicate_server_set_default (IndicateServer * server)
{
@@ -1103,6 +1257,15 @@ _indicate_server_show_indicator_to_user (IndicateServer * server, guint id, GErr
return TRUE;
}
+/**
+ indicate_server_get_next_id:
+ @server: The #IndicateServer the ID will be on
+
+ Returns the next available unused ID that an indicator
+ can have.
+
+ Return value: A valid indicator ID.
+*/
guint
indicate_server_get_next_id (IndicateServer * server)
{
@@ -1207,7 +1370,41 @@ _indicate_server_remove_interest (IndicateServer * server, gchar * interest, DBu
return FALSE;
}
+/**
+ indicate_server_check_interest:
+ @server: The #IndicateServer being checked
+ @interest: Which interest type we're checking for
+
+ This function looks at all the interest that various listeners
+ have specified that they have for this server and returns whether
+ there is a listener that has the interest specified in @interest.
+
+ Return value: %TRUE if a listener as the interest otherwise %FALSE
+*/
+gboolean
+indicate_server_check_interest (IndicateServer * server, IndicateInterests interest)
+{
+ IndicateServerClass * class = INDICATE_SERVER_GET_CLASS(server);
+
+ if (class != NULL && class->check_interest != NULL) {
+ return class->check_interest (server, interest);
+ }
+
+ g_warning("check_interest function not implemented in this server class: %s", G_OBJECT_TYPE_NAME(server));
+ return FALSE;
+}
+
/* Signal emission functions for sub-classes of the server */
+
+/**
+ indicate_server_emit_indicator_added:
+ @server: The #IndicateServer being represented
+ @id: The ID of the indicator being added
+ @type: The type of the indicator
+
+ This function emits the #IndicateServer::indicator-added signal and is
+ used by subclasses.
+*/
void
indicate_server_emit_indicator_added (IndicateServer *server, guint id, const gchar *type)
{
@@ -1217,6 +1414,15 @@ indicate_server_emit_indicator_added (IndicateServer *server, guint id, const gc
g_signal_emit(server, signals[INDICATOR_ADDED], 0, id, type);
}
+/**
+ indicate_server_emit_indicator_removed:
+ @server: The #IndicateServer being represented
+ @id: The ID of the indicator being removed
+ @type: The type of the indicator
+
+ This function emits the #IndicateServer::indicator-removed signal and is
+ used by subclasses.
+*/
void
indicate_server_emit_indicator_removed (IndicateServer *server, guint id, const gchar *type)
{
@@ -1226,6 +1432,15 @@ indicate_server_emit_indicator_removed (IndicateServer *server, guint id, const
g_signal_emit(server, signals[INDICATOR_REMOVED], 0, id, type);
}
+/**
+ indicate_server_emit_indicator_modified:
+ @server: The #IndicateServer being represented
+ @id: The ID of the indicator with the modified property
+ @property: The name of the property being modified
+
+ This function emits the #IndicateServer::indicator-modified signal and is
+ used by subclasses.
+*/
void
indicate_server_emit_indicator_modified (IndicateServer *server, guint id, const gchar *property)
{
@@ -1235,6 +1450,13 @@ indicate_server_emit_indicator_modified (IndicateServer *server, guint id, const
g_signal_emit(server, signals[INDICATOR_MODIFIED], 0, id, property);
}
+/**
+ indicate_server_emit_server_display:
+ @server: The #IndicateServer being displayed
+
+ This function emits the #IndicateServer::server-display signal and is
+ used by subclasses.
+*/
void
indicate_server_emit_server_display (IndicateServer *server)
{