aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.bzrignore44
-rw-r--r--configure.ac6
-rw-r--r--debian/changelog15
-rw-r--r--debian/control4
-rw-r--r--debian/libindicate1.install (renamed from debian/libindicate0.install)0
-rw-r--r--docs/reference/tmpl/libindicate-unused.sgml195
-rw-r--r--libindicate/Makefile.am20
-rw-r--r--libindicate/indicate-interface.xml8
-rw-r--r--libindicate/indicator.c2
-rw-r--r--libindicate/interests-priv.h46
-rw-r--r--libindicate/interests.h51
-rw-r--r--libindicate/listener.c214
-rw-r--r--libindicate/listener.h25
-rw-r--r--libindicate/server.c445
-rw-r--r--libindicate/server.h28
-rw-r--r--src/applet-main.c20
-rw-r--r--tests/Makefile.am14
-rw-r--r--tests/im-client.c14
-rw-r--r--tests/listen-and-print.c5
-rw-r--r--tests/show-hide-server.c44
20 files changed, 1080 insertions, 120 deletions
diff --git a/.bzrignore b/.bzrignore
index f9243de..3548564 100644
--- a/.bzrignore
+++ b/.bzrignore
@@ -11,3 +11,47 @@ dbus-indicate-client.h
dbus-indicate-server.h
listener-marshal.c
listener-marshal.h
+gtk-doc.make
+docs/reference/.libs
+docs/reference/html
+docs/reference/html-build.stamp
+docs/reference/html.stamp
+docs/reference/libindicate-decl-list.txt
+docs/reference/libindicate-decl.txt
+docs/reference/libindicate-overrides.txt
+docs/reference/libindicate-undeclared.txt
+docs/reference/libindicate-undocumented.txt
+docs/reference/libindicate-unused.txt
+docs/reference/libindicate.args
+docs/reference/libindicate.hierarchy
+docs/reference/libindicate.interfaces
+docs/reference/libindicate.prerequisites
+docs/reference/libindicate.signals
+docs/reference/scan-build.stamp
+docs/reference/sgml-build.stamp
+docs/reference/sgml.stamp
+docs/reference/tmpl-build.stamp
+docs/reference/tmpl.stamp
+docs/reference/version.xml
+docs/reference/xml
+docs/reference/tmpl/indicator.sgml
+libindicate/.deps
+libindicate/.libs
+libindicate/Indicate-0.1.gir
+libindicate/Indicate-0.1.typelib
+libindicate/dbus-listener-client.h
+libindicate/dbus-listener-server.h
+libindicate/indicate.pc
+libindicate/libindicate.la
+libindicate/libindicate_la-indicator-message.lo
+libindicate/libindicate_la-indicator.lo
+libindicate/libindicate_la-listener-marshal.lo
+libindicate/libindicate_la-listener.lo
+libindicate/libindicate_la-server.lo
+tests/.deps
+tests/.libs
+tests/im-client
+tests/indicate-alot
+tests/indicate-and-crash
+tests/listen-and-print
+tests/show-hide-server
diff --git a/configure.ac b/configure.ac
index 90d75c7..b86656d 100644
--- a/configure.ac
+++ b/configure.ac
@@ -4,7 +4,7 @@ AC_INIT(src/applet-main.c)
AC_PREREQ(2.53)
AM_CONFIG_HEADER(config.h)
-AM_INIT_AUTOMAKE(indicator-applet, 0.1.4)
+AM_INIT_AUTOMAKE(indicator-applet, 0.1.5)
AM_MAINTAINER_MODE
@@ -22,8 +22,8 @@ AC_CONFIG_MACRO_DIR([m4])
# Libindicate versioning
###########################
-LIBINDICATE_CURRENT=0
-LIBINDICATE_REVISION=1
+LIBINDICATE_CURRENT=1
+LIBINDICATE_REVISION=0
LIBINDICATE_AGE=0
AC_SUBST(LIBINDICATE_CURRENT)
diff --git a/debian/changelog b/debian/changelog
index 656a529..38f10e1 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -1,3 +1,18 @@
+indicator-applet (0.1.5-0ubuntu1) jaunty; urgency=low
+
+ * debian/control: Switching libindicate0 to libindicate1 to express
+ the fact that the binary compatibility is broken.
+ * debian/libindicate0.install changed to debian/libindicate1.install
+ * New upstream version:
+ * Adds new API for detecting interests of various listeners. Implemented
+ on both client and server side. (LP: #353112)
+ * Makes it so that all objects down to the menu now use the gtkstyle
+ naming from FUSA to ensure that they all pick up the theme hacks that
+ are set for FUSA. (LP: #334490)
+ * Explicitly sets the about window's window icon. (LP: #356437)
+
+ -- Ted Gould <ted@ubuntu.com> Fri, 03 Apr 2009 15:09:33 -0500
+
indicator-applet (0.1.4-0ubuntu1) jaunty; urgency=low
* New upstream version
diff --git a/debian/control b/debian/control
index 7fb1784..d269a2d 100644
--- a/debian/control
+++ b/debian/control
@@ -28,7 +28,7 @@ Description: GNOME panel indicator applet
Currently this includes support for messaging applications in the
indicator-messages package.
-Package: libindicate0
+Package: libindicate1
Section: libs
Conflicts: libindicate
Replaces: libindicate
@@ -46,7 +46,7 @@ Section: libdevel
Architecture: any
Depends: ${shlibs:Depends},
${misc:Depends},
- libindicate0 (= ${binary:Version}),
+ libindicate1 (= ${binary:Version}),
libdbus-glib-1-dev (>= 0.76),
libgtk2.0-dev (>= 2.12.0)
Description: GNOME panel indicator applet - shared library
diff --git a/debian/libindicate0.install b/debian/libindicate1.install
index 0618a58..0618a58 100644
--- a/debian/libindicate0.install
+++ b/debian/libindicate1.install
diff --git a/docs/reference/tmpl/libindicate-unused.sgml b/docs/reference/tmpl/libindicate-unused.sgml
index e69de29..d4e3767 100644
--- a/docs/reference/tmpl/libindicate-unused.sgml
+++ b/docs/reference/tmpl/libindicate-unused.sgml
@@ -0,0 +1,195 @@
+<!-- ##### FUNCTION dbus_glib_marshal_indicate_server_BOOLEAN__POINTER_POINTER ##### -->
+<para>
+
+</para>
+
+@closure:
+@return_value:
+@n_param_values:
+@param_values:
+@invocation_hint:
+@marshal_data:
+
+<!-- ##### FUNCTION dbus_glib_marshal_indicate_server_BOOLEAN__STRING_POINTER_POINTER ##### -->
+<para>
+
+</para>
+
+@closure:
+@return_value:
+@n_param_values:
+@param_values:
+@invocation_hint:
+@marshal_data:
+
+<!-- ##### FUNCTION dbus_glib_marshal_indicate_server_BOOLEAN__UINT_BOXED_POINTER_POINTER ##### -->
+<para>
+
+</para>
+
+@closure:
+@return_value:
+@n_param_values:
+@param_values:
+@invocation_hint:
+@marshal_data:
+
+<!-- ##### FUNCTION dbus_glib_marshal_indicate_server_BOOLEAN__UINT_POINTER ##### -->
+<para>
+
+</para>
+
+@closure:
+@return_value:
+@n_param_values:
+@param_values:
+@invocation_hint:
+@marshal_data:
+
+<!-- ##### FUNCTION dbus_glib_marshal_indicate_server_BOOLEAN__UINT_POINTER_POINTER ##### -->
+<para>
+
+</para>
+
+@closure:
+@return_value:
+@n_param_values:
+@param_values:
+@invocation_hint:
+@marshal_data:
+
+<!-- ##### FUNCTION dbus_glib_marshal_indicate_server_BOOLEAN__UINT_STRING_POINTER_POINTER ##### -->
+<para>
+
+</para>
+
+@closure:
+@return_value:
+@n_param_values:
+@param_values:
+@invocation_hint:
+@marshal_data:
+
+<!-- ##### FUNCTION indicate_listener_marshal_VOID__POINTER_POINTER_STRING ##### -->
+<para>
+
+</para>
+
+@closure:
+@return_value:
+@n_param_values:
+@param_values:
+@invocation_hint:
+@marshal_data:
+
+<!-- ##### FUNCTION indicate_listener_marshal_VOID__POINTER_POINTER_STRING_STRING ##### -->
+<para>
+
+</para>
+
+@closure:
+@return_value:
+@n_param_values:
+@param_values:
+@invocation_hint:
+@marshal_data:
+
+<!-- ##### FUNCTION indicate_listener_marshal_VOID__UINT_STRING ##### -->
+<para>
+
+</para>
+
+@closure:
+@return_value:
+@n_param_values:
+@param_values:
+@invocation_hint:
+@marshal_data:
+
+<!-- ##### FUNCTION indicate_server_get_indicator_count ##### -->
+<para>
+
+</para>
+
+@server:
+@count:
+@error:
+@Returns:
+
+<!-- ##### FUNCTION indicate_server_get_indicator_count_by_type ##### -->
+<para>
+
+</para>
+
+@server:
+@type:
+@count:
+@error:
+@Returns:
+
+<!-- ##### FUNCTION indicate_server_get_indicator_list ##### -->
+<para>
+
+</para>
+
+@server:
+@indicators:
+@error:
+@Returns:
+
+<!-- ##### FUNCTION indicate_server_get_indicator_list_by_type ##### -->
+<para>
+
+</para>
+
+@server:
+@type:
+@indicators:
+@error:
+@Returns:
+
+<!-- ##### FUNCTION indicate_server_get_indicator_properties ##### -->
+<para>
+
+</para>
+
+@server:
+@id:
+@properties:
+@error:
+@Returns:
+
+<!-- ##### FUNCTION indicate_server_get_indicator_property ##### -->
+<para>
+
+</para>
+
+@server:
+@id:
+@property:
+@value:
+@error:
+@Returns:
+
+<!-- ##### FUNCTION indicate_server_get_indicator_property_group ##### -->
+<para>
+
+</para>
+
+@server:
+@id:
+@properties:
+@value:
+@error:
+@Returns:
+
+<!-- ##### FUNCTION indicate_server_show_indicator_to_user ##### -->
+<para>
+
+</para>
+
+@server:
+@id:
+@error:
+@Returns:
+
diff --git a/libindicate/Makefile.am b/libindicate/Makefile.am
index 5a6f466..c1900a6 100644
--- a/libindicate/Makefile.am
+++ b/libindicate/Makefile.am
@@ -25,7 +25,8 @@ indicate_headers = \
indicator.h \
indicator-message.h \
listener.h \
- server.h
+ server.h \
+ interests.h
libindicateinclude_HEADERS = \
$(indicate_headers)
@@ -41,12 +42,13 @@ libindicate_la_SOURCES = \
listener-marshal.c \
listener-marshal.h \
indicator.c \
- indicator-message.c
+ indicator-message.c \
+ interests-priv.h
libindicate_la_LDFLAGS = \
-version-info $(LIBINDICATE_CURRENT):$(LIBINDICATE_REVISION):$(LIBINDICATE_AGE) \
-no-undefined \
- -export-symbols-regex "^[^_].*"
+ -export-symbols-regex "^[^_d].*"
libindicate_la_CFLAGS = \
$(LIBINDICATE_CFLAGS)
@@ -56,40 +58,40 @@ libindicate_la_LIBADD = \
dbus-indicate-server.h: indicate-interface.xml
dbus-binding-tool \
- --prefix=indicate_server \
+ --prefix=_indicate_server \
--mode=glib-server \
--output=dbus-indicate-server.h \
$(srcdir)/indicate-interface.xml
dbus-indicate-client.h: indicate-interface.xml
dbus-binding-tool \
- --prefix=indicate_client \
+ --prefix=_indicate_client \
--mode=glib-client \
--output=dbus-indicate-client.h \
$(srcdir)/indicate-interface.xml
dbus-listener-server.h: indicate-listener.xml
dbus-binding-tool \
- --prefix=indicate_listener \
+ --prefix=_indicate_listener \
--mode=glib-server \
--output=dbus-listener-server.h \
$(srcdir)/indicate-listener.xml
dbus-listener-client.h: indicate-listener.xml
dbus-binding-tool \
- --prefix=indicate_listener \
+ --prefix=_indicate_listener \
--mode=glib-client \
--output=dbus-listener-client.h \
$(srcdir)/indicate-listener.xml
listener-marshal.h: $(srcdir)/listener-marshal.list
glib-genmarshal --header \
- --prefix=indicate_listener_marshal $(srcdir)/listener-marshal.list \
+ --prefix=_indicate_listener_marshal $(srcdir)/listener-marshal.list \
> listener-marshal.h
listener-marshal.c: $(srcdir)/listener-marshal.list
glib-genmarshal --body \
- --prefix=indicate_listener_marshal $(srcdir)/listener-marshal.list \
+ --prefix=_indicate_listener_marshal $(srcdir)/listener-marshal.list \
> listener-marshal.c
pkgconfig_DATA = indicate.pc
diff --git a/libindicate/indicate-interface.xml b/libindicate/indicate-interface.xml
index 102df12..900b336 100644
--- a/libindicate/indicate-interface.xml
+++ b/libindicate/indicate-interface.xml
@@ -66,6 +66,14 @@ License version 3 and version 2.1 along with this program. If not, see
<method name="ShowIndicatorToUser">
<arg type="u" name="id" direction="in" />
</method>
+ <method name="ShowInterest">
+ <annotation name="org.freedesktop.DBus.GLib.Async" value="true" />
+ <arg type="s" name="interest" direction="in" />
+ </method>
+ <method name="RemoveInterest">
+ <annotation name="org.freedesktop.DBus.GLib.Async" value="true" />
+ <arg type="s" name="interest" direction="in" />
+ </method>
<!-- Signals -->
diff --git a/libindicate/indicator.c b/libindicate/indicator.c
index e4bae76..9427d03 100644
--- a/libindicate/indicator.c
+++ b/libindicate/indicator.c
@@ -249,7 +249,7 @@ indicate_indicator_set_property_icon (IndicateIndicator * indicator, const gchar
gchar * png_data;
gsize png_data_len;
- if (!gdk_pixbuf_save_to_buffer(data, &png_data, &png_data_len, "png", &error, NULL)) {
+ if (!gdk_pixbuf_save_to_buffer((GdkPixbuf *)data, &png_data, &png_data_len, "png", &error, NULL)) {
if (error == NULL) {
g_warning("Unable to create pixbuf data stream: %d", png_data_len);
} else {
diff --git a/libindicate/interests-priv.h b/libindicate/interests-priv.h
new file mode 100644
index 0000000..eb4e791
--- /dev/null
+++ b/libindicate/interests-priv.h
@@ -0,0 +1,46 @@
+/*
+A library to allow applictions to provide simple indications of
+information to be displayed to users of the application through the
+interface shell.
+
+Copyright 2009 Canonical Ltd.
+
+Authors:
+ Ted Gould <ted@canonical.com>
+
+This program is free software: you can redistribute it and/or modify it
+under the terms of either or both of the following licenses:
+
+1) the GNU Lesser General Public License version 3, as published by the
+Free Software Foundation; and/or
+2) the GNU Lesser General Public License version 2.1, as published by
+the Free Software Foundation.
+
+This program is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranties of
+MERCHANTABILITY, SATISFACTORY QUALITY or FITNESS FOR A PARTICULAR
+PURPOSE. See the applicable version of the GNU Lesser General Public
+License for more details.
+
+You should have received a copy of both the GNU Lesser General Public
+License version 3 and version 2.1 along with this program. If not, see
+<http://www.gnu.org/licenses/>
+*/
+
+#ifndef INDICATE_INTERESTS_PRIV_H_INCLUDED__
+#define INDICATE_INTERESTS_PRIV_H_INCLUDED__ 1
+
+#include <glib.h>
+
+G_BEGIN_DECLS
+
+#define INDICATE_INTEREST_STRING_SERVER_DISPLAY "server-display"
+#define INDICATE_INTEREST_STRING_SERVER_SIGNAL "server-signal"
+#define INDICATE_INTEREST_STRING_INDICATOR_DISPLAY "indicator-display"
+#define INDICATE_INTEREST_STRING_INDICATOR_SIGNAL "indicator-signal"
+#define INDICATE_INTEREST_STRING_INDICATOR_COUNT "indicator-count"
+
+G_END_DECLS
+
+#endif /* INDICATE_INTERESTS_PRIV_H_INCLUDED__ */
+
diff --git a/libindicate/interests.h b/libindicate/interests.h
new file mode 100644
index 0000000..70c52d9
--- /dev/null
+++ b/libindicate/interests.h
@@ -0,0 +1,51 @@
+/*
+A library to allow applictions to provide simple indications of
+information to be displayed to users of the application through the
+interface shell.
+
+Copyright 2009 Canonical Ltd.
+
+Authors:
+ Ted Gould <ted@canonical.com>
+
+This program is free software: you can redistribute it and/or modify it
+under the terms of either or both of the following licenses:
+
+1) the GNU Lesser General Public License version 3, as published by the
+Free Software Foundation; and/or
+2) the GNU Lesser General Public License version 2.1, as published by
+the Free Software Foundation.
+
+This program is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranties of
+MERCHANTABILITY, SATISFACTORY QUALITY or FITNESS FOR A PARTICULAR
+PURPOSE. See the applicable version of the GNU Lesser General Public
+License for more details.
+
+You should have received a copy of both the GNU Lesser General Public
+License version 3 and version 2.1 along with this program. If not, see
+<http://www.gnu.org/licenses/>
+*/
+
+#ifndef INDICATE_INTERESTS_H_INCLUDED__
+#define INDICATE_INTERESTS_H_INCLUDED__ 1
+
+#include <glib.h>
+
+G_BEGIN_DECLS
+
+typedef enum _IndicateInterests IndicateInterests;
+enum _IndicateInterests {
+ INDICATE_INTEREST_NONE, /**< We're of no interest */
+ INDICATE_INTEREST_SERVER_DISPLAY, /**< Displays the server's existance to the user */
+ INDICATE_INTEREST_SERVER_SIGNAL, /**< Will send signals to the server to be displayed */
+ INDICATE_INTEREST_INDICATOR_DISPLAY, /**< Displays indicators to the user */
+ INDICATE_INTEREST_INDICATOR_SIGNAL, /**< Will return signals based on individual indicators being responded to */
+ INDICATE_INTEREST_INDICATOR_COUNT, /**< Only displays a count of the indicators */
+ INDICATE_INTEREST_LAST /**< Makes merges and counting easier */
+};
+
+G_END_DECLS
+
+#endif /* INDICATE_INTERESTS_H_INCLUDED__ */
+
diff --git a/libindicate/listener.c b/libindicate/listener.c
index b786552..381a5f9 100644
--- a/libindicate/listener.c
+++ b/libindicate/listener.c
@@ -32,7 +32,7 @@ License version 3 and version 2.1 along with this program. If not, see
#include <dbus/dbus-glib-bindings.h>
#include "dbus-indicate-client.h"
#include "dbus-listener-client.h"
-#include "dbus-listener-server.h"
+#include "interests-priv.h"
/* Errors */
enum {
@@ -51,6 +51,17 @@ enum {
static guint signals[LAST_SIGNAL] = { 0 };
+struct _IndicateListenerServer {
+ gchar * name;
+ DBusGProxy * proxy;
+ DBusGConnection * connection;
+ gboolean interests[INDICATE_INTEREST_LAST];
+};
+
+struct _IndicateListenerIndicator {
+ guint id;
+};
+
typedef struct _IndicateListenerPrivate IndicateListenerPrivate;
struct _IndicateListenerPrivate
{
@@ -60,8 +71,8 @@ struct _IndicateListenerPrivate
DBusGProxy * dbus_proxy_session;
DBusGProxy * dbus_proxy_system;
- GHashTable * proxies_working;
- GHashTable * proxies_possible;
+ GList * proxies_working;
+ GList * proxies_possible;
GArray * proxy_todo;
guint todo_idle;
@@ -78,8 +89,23 @@ typedef struct {
gchar * type;
IndicateListener * listener;
GHashTable * indicators;
+
+ IndicateListenerServer server;
} proxy_t;
+static gint
+proxy_t_equal (gconstpointer pa, gconstpointer pb)
+{
+ proxy_t * a = (proxy_t *)pa; proxy_t * b = (proxy_t *)pb;
+
+ if (a->connection == b->connection) {
+ return g_strcmp0(a->name, b->name);
+ } else {
+ /* we're only using this for equal, not sorting */
+ return 1;
+ }
+}
+
typedef struct {
DBusGConnection * bus;
gchar * name;
@@ -95,7 +121,7 @@ static void proxy_struct_destroy (gpointer data);
static void build_todo_list_cb (DBusGProxy * proxy, char ** names, GError * error, void * data);
static void todo_list_add (const gchar * name, DBusGProxy * proxy, IndicateListener * listener, gboolean startup);
static gboolean todo_idle (gpointer data);
-void get_type_cb (IndicateListener * listener, IndicateListenerServer * server, gchar * type, gpointer data);
+static void get_type_cb (IndicateListener * listener, IndicateListenerServer * server, gchar * type, gpointer data);
static void proxy_server_added (DBusGProxy * proxy, const gchar * type, proxy_t * proxyt);
static void proxy_indicator_added (DBusGProxy * proxy, guint id, const gchar * type, proxy_t * proxyt);
static void proxy_indicator_removed (DBusGProxy * proxy, guint id, const gchar * type, proxy_t * proxyt);
@@ -104,6 +130,12 @@ static void proxy_get_indicator_list (DBusGProxy * proxy, GArray * indicators, G
static void proxy_get_indicator_type (DBusGProxy * proxy, gchar * type, GError * error, gpointer data);
static void proxy_indicators_free (gpointer data);
+/* DBus interface */
+gboolean _indicate_listener_get_indicator_servers (IndicateListener * listener, GList * servers);
+
+/* Need the above prototypes */
+#include "dbus-listener-server.h"
+
/* Code */
static void
indicate_listener_class_init (IndicateListenerClass * class)
@@ -121,38 +153,38 @@ indicate_listener_class_init (IndicateListenerClass * class)
G_SIGNAL_RUN_LAST,
G_STRUCT_OFFSET (IndicateListenerClass, indicator_added),
NULL, NULL,
- indicate_listener_marshal_VOID__POINTER_POINTER_STRING,
+ _indicate_listener_marshal_VOID__POINTER_POINTER_STRING,
G_TYPE_NONE, 3, G_TYPE_POINTER, G_TYPE_POINTER, G_TYPE_STRING);
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_listener_marshal_VOID__POINTER_POINTER_STRING,
+ _indicate_listener_marshal_VOID__POINTER_POINTER_STRING,
G_TYPE_NONE, 3, G_TYPE_POINTER, G_TYPE_POINTER, G_TYPE_STRING);
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_listener_marshal_VOID__POINTER_POINTER_STRING_STRING,
+ _indicate_listener_marshal_VOID__POINTER_POINTER_STRING_STRING,
G_TYPE_NONE, 4, G_TYPE_POINTER, G_TYPE_POINTER, G_TYPE_STRING, 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_listener_marshal_VOID__POINTER_STRING,
+ _indicate_listener_marshal_VOID__POINTER_STRING,
G_TYPE_NONE, 2, G_TYPE_POINTER, 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_listener_marshal_VOID__POINTER_STRING,
+ _indicate_listener_marshal_VOID__POINTER_STRING,
G_TYPE_NONE, 2, G_TYPE_POINTER, G_TYPE_STRING);
- dbus_g_object_register_marshaller(indicate_listener_marshal_VOID__UINT_STRING,
+ dbus_g_object_register_marshaller(_indicate_listener_marshal_VOID__UINT_STRING,
G_TYPE_NONE,
G_TYPE_UINT,
G_TYPE_STRING,
@@ -219,8 +251,8 @@ indicate_listener_init (IndicateListener * listener)
G_CALLBACK(dbus_owner_change), listener, NULL);
/* Initialize Data structures */
- priv->proxies_working = g_hash_table_new(g_str_hash, g_str_equal);
- priv->proxies_possible = g_hash_table_new(g_str_hash, g_str_equal);
+ priv->proxies_working = NULL;
+ priv->proxies_possible = 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));
@@ -292,16 +324,20 @@ dbus_owner_change (DBusGProxy * proxy, const gchar * name, const gchar * prev, c
todo_list_add(name, proxy, listener, FALSE);
}
if (new != NULL && new[0] == '\0') {
- proxy_t * proxyt;
- proxyt = g_hash_table_lookup(priv->proxies_working, name);
- if (proxyt != NULL) {
- g_hash_table_remove(priv->proxies_working, name);
- proxy_struct_destroy(proxyt);
+ proxy_t searchitem;
+ searchitem.connection = bus;
+ searchitem.name = (gchar *)name; /* Droping const, not that it isn't, but to remove the warning */
+
+ GList * proxyt_item;
+ proxyt_item = g_list_find_custom(priv->proxies_working, &searchitem, proxy_t_equal);
+ if (proxyt_item != NULL) {
+ proxy_struct_destroy((proxy_t *)proxyt_item->data);
+ priv->proxies_working = g_list_remove(priv->proxies_working, proxyt_item->data);
}
- proxyt = g_hash_table_lookup(priv->proxies_possible, name);
- if (proxyt != NULL) {
- g_hash_table_remove(priv->proxies_possible, name);
- proxy_struct_destroy(proxyt);
+ proxyt_item = g_list_find_custom(priv->proxies_possible, &searchitem, proxy_t_equal);
+ if (proxyt_item != NULL) {
+ proxy_struct_destroy((proxy_t *)proxyt_item->data);
+ priv->proxies_possible = g_list_remove(priv->proxies_possible, proxyt_item->data);
}
}
@@ -319,7 +355,7 @@ proxy_struct_destroy_indicators (gpointer key, gpointer value, gpointer data)
GList * indicator;
for (indicator = keys; indicator != NULL; indicator = indicator->next) {
guint id = (guint)indicator->data;
- g_signal_emit(proxy_data->listener, signals[INDICATOR_REMOVED], 0, proxy_data->name, id, type, TRUE);
+ g_signal_emit(proxy_data->listener, signals[INDICATOR_REMOVED], 0, &proxy_data->server, GUINT_TO_POINTER(id), type, TRUE);
}
g_list_free(keys);
@@ -339,15 +375,15 @@ proxy_struct_destroy (gpointer data)
proxy_data);
g_hash_table_remove_all(proxy_data->indicators);
- g_signal_emit(proxy_data->listener, signals[SERVER_REMOVED], 0, proxy_data->name, proxy_data->type, TRUE);
+ g_signal_emit(proxy_data->listener, signals[SERVER_REMOVED], 0, &proxy_data->server, proxy_data->type, TRUE);
proxy_data->indicators = NULL;
}
- if (proxy_data->property_proxy) {
+ if (DBUS_IS_G_PROXY(proxy_data->property_proxy)) {
g_object_unref(G_OBJECT(proxy_data->property_proxy));
}
- if (proxy_data->proxy) {
+ if (DBUS_IS_G_PROXY(proxy_data->proxy)) {
g_object_unref(G_OBJECT(proxy_data->proxy));
}
@@ -433,7 +469,7 @@ todo_idle (gpointer data)
proxy_todo_t * todo = &g_array_index(priv->proxy_todo, proxy_todo_t, priv->proxy_todo->len - 1);
- proxy_t * proxyt = g_new(proxy_t, 1);
+ proxy_t * proxyt = g_new0(proxy_t, 1);
proxyt->name = todo->name;
proxyt->type = NULL;
proxyt->proxy = dbus_g_proxy_new_for_name(todo->bus,
@@ -444,6 +480,9 @@ todo_idle (gpointer data)
proxyt->listener = listener;
proxyt->indicators = NULL;
proxyt->connection = todo->bus;
+ proxyt->server.name = todo->name;
+ proxyt->server.proxy = proxyt->proxy;
+ proxyt->server.connection = proxyt->connection;
priv->proxy_todo = g_array_remove_index(priv->proxy_todo, priv->proxy_todo->len - 1);
@@ -457,7 +496,7 @@ todo_idle (gpointer data)
dbus_g_proxy_connect_signal(proxyt->proxy, "ServerShow",
G_CALLBACK(proxy_server_added), proxyt, NULL);
- g_hash_table_insert(priv->proxies_possible, proxyt->name, proxyt);
+ priv->proxies_possible = g_list_prepend(priv->proxies_possible, proxyt);
/* I think that we need to have this as there is a race
* condition here. If someone comes on the bus and we get
@@ -465,12 +504,12 @@ todo_idle (gpointer data)
* signal it gets sent, we wouldn't get it. So then we would
* miss an indicator server coming on the bus. I'd like to not
* generate a warning in every app with DBus though. */
- indicate_listener_server_get_type(listener, (IndicateListenerServer *)proxyt->name, get_type_cb, proxyt);
+ indicate_listener_server_get_type(listener, &proxyt->server, get_type_cb, proxyt);
return TRUE;
}
-void
+static void
get_type_cb (IndicateListener * listener, IndicateListenerServer * server, gchar * type, gpointer data)
{
if (type == NULL) {
@@ -538,8 +577,13 @@ proxy_server_added (DBusGProxy * proxy, const gchar * type, proxy_t * proxyt)
g_free, proxy_indicators_free);
/* Elevate to working */
IndicateListenerPrivate * priv = INDICATE_LISTENER_GET_PRIVATE(proxyt->listener);
- g_hash_table_remove(priv->proxies_possible, proxyt->name);
- g_hash_table_insert(priv->proxies_working, proxyt->name, proxyt);
+
+ GList * proxyt_item;
+ proxyt_item = g_list_find_custom(priv->proxies_possible, proxyt, proxy_t_equal);
+ if (proxyt_item != NULL) {
+ priv->proxies_possible = g_list_remove(priv->proxies_possible, proxyt_item->data);
+ }
+ priv->proxies_working = g_list_prepend(priv->proxies_working, proxyt);
dbus_g_proxy_add_signal(proxyt->proxy, "IndicatorAdded",
G_TYPE_UINT, G_TYPE_STRING, G_TYPE_INVALID);
@@ -561,7 +605,7 @@ proxy_server_added (DBusGProxy * proxy, const gchar * type, proxy_t * proxyt)
proxyt->type = g_strdup(type);
}
- g_signal_emit(proxyt->listener, signals[SERVER_ADDED], 0, proxyt->name, proxyt->type, TRUE);
+ g_signal_emit(proxyt->listener, signals[SERVER_ADDED], 0, &proxyt->server, proxyt->type, TRUE);
}
return;
@@ -583,7 +627,7 @@ proxy_indicator_added (DBusGProxy * proxy, guint id, const gchar * type, proxy_t
if (!g_hash_table_lookup(indicators, (gpointer)id)) {
g_hash_table_insert(indicators, (gpointer)id, (gpointer)TRUE);
- g_signal_emit(proxyt->listener, signals[INDICATOR_ADDED], 0, proxyt->name, id, type, TRUE);
+ g_signal_emit(proxyt->listener, signals[INDICATOR_ADDED], 0, &proxyt->server, GUINT_TO_POINTER(id), type, TRUE);
}
return;
@@ -609,7 +653,7 @@ proxy_indicator_removed (DBusGProxy * proxy, guint id, const gchar * type, proxy
}
g_hash_table_remove(indicators, (gpointer)id);
- g_signal_emit(proxyt->listener, signals[INDICATOR_REMOVED], 0, proxyt->name, id, type, TRUE);
+ g_signal_emit(proxyt->listener, signals[INDICATOR_REMOVED], 0, &proxyt->server, GUINT_TO_POINTER(id), type, TRUE);
return;
}
@@ -642,7 +686,7 @@ proxy_indicator_modified (DBusGProxy * proxy, guint id, const gchar * property,
return;
}
- g_signal_emit(proxyt->listener, signals[INDICATOR_MODIFIED], 0, proxyt->name, id, type, property, TRUE);
+ g_signal_emit(proxyt->listener, signals[INDICATOR_MODIFIED], 0, &proxyt->server, GUINT_TO_POINTER(id), type, property, TRUE);
return;
}
@@ -754,14 +798,6 @@ get_property_helper (IndicateListener * listener, IndicateListenerServer * serve
{
/* g_debug("get_property_helper: %s %d", property, prop_type); */
/* TODO: Do we need to somehow refcount the server/indicator while we're waiting on this? */
- IndicateListenerPrivate * priv = INDICATE_LISTENER_GET_PRIVATE(listener);
-
- proxy_t * proxyt = g_hash_table_lookup(priv->proxies_working, server);
- if (proxyt == NULL) {
- g_error("Trying to get property '%s' on server '%s' that currently isn't set to working.", property, (gchar *)server);
- return;
- }
-
get_property_t * get_property_data = g_new(get_property_t, 1);
get_property_data->cb = callback;
get_property_data->data = data;
@@ -771,7 +807,7 @@ get_property_helper (IndicateListener * listener, IndicateListenerServer * serve
get_property_data->property = g_strdup(property);
get_property_data->type = prop_type;
- org_freedesktop_indicator_get_indicator_property_async (proxyt->proxy , INDICATE_LISTENER_INDICATOR_ID(indicator), property, get_property_cb, get_property_data);
+ org_freedesktop_indicator_get_indicator_property_async (server->proxy , INDICATE_LISTENER_INDICATOR_ID(indicator), property, get_property_cb, get_property_data);
return;
}
@@ -794,7 +830,7 @@ indicate_listener_get_property_icon (IndicateListener * listener, IndicateListen
}
gboolean
-indicate_listener_get_indicator_servers (IndicateListener * listener, GList * servers)
+_indicate_listener_get_indicator_servers (IndicateListener * listener, GList * servers)
{
@@ -812,11 +848,7 @@ listener_display_cb (DBusGProxy *proxy, GError *error, gpointer userdata)
void
indicate_listener_display (IndicateListener * listener, IndicateListenerServer * server, IndicateListenerIndicator * indicator)
{
- IndicateListenerPrivate * priv = INDICATE_LISTENER_GET_PRIVATE(listener);
-
- proxy_t * proxyt = g_hash_table_lookup(priv->proxies_working, server);
-
- org_freedesktop_indicator_show_indicator_to_user_async (proxyt->proxy, INDICATE_LISTENER_INDICATOR_ID(indicator), listener_display_cb, NULL);
+ org_freedesktop_indicator_show_indicator_to_user_async (server->proxy, INDICATE_LISTENER_INDICATOR_ID(indicator), listener_display_cb, NULL);
return;
}
@@ -871,16 +903,22 @@ get_server_property (IndicateListener * listener, IndicateListenerServer * serve
/* g_debug("Setting up callback for property %s on %s", property_name, INDICATE_LISTENER_SERVER_DBUS_NAME(server)); */
IndicateListenerPrivate * priv = INDICATE_LISTENER_GET_PRIVATE(listener);
- proxy_t * proxyt = g_hash_table_lookup(priv->proxies_possible, server);
- if (proxyt == NULL) {
- proxyt = g_hash_table_lookup(priv->proxies_working, server);
+ proxy_t searchitem;
+ searchitem.name = server->name;
+ searchitem.connection = server->connection;
+
+ GList * proxyitem = g_list_find_custom(priv->proxies_possible, &searchitem, proxy_t_equal);
+ if (proxyitem == NULL) {
+ proxyitem = g_list_find_custom(priv->proxies_working, &searchitem, proxy_t_equal);
}
- if (proxyt == NULL) {
+ if (proxyitem == NULL) {
g_warning("Can not find a proxy for the server at all.");
return;
}
+ proxy_t * proxyt = (proxy_t *)proxyitem->data;
+
if (proxyt->property_proxy == NULL) {
proxyt->property_proxy = dbus_g_proxy_new_for_name(proxyt->connection,
proxyt->name,
@@ -918,3 +956,71 @@ indicate_listener_server_get_desktop (IndicateListener * listener, IndicateListe
return get_server_property(listener, server, callback, "desktop", data);
}
+const gchar *
+indicate_listener_server_get_dbusname (IndicateListenerServer * server)
+{
+ if (server == NULL) return NULL;
+ return server->name;
+}
+
+guint
+indicate_listener_indicator_get_id (IndicateListenerIndicator * indicator)
+{
+ return GPOINTER_TO_UINT(indicator);
+}
+
+static const gchar *
+interest_to_string (IndicateInterests interest)
+{
+ switch (interest) {
+ case INDICATE_INTEREST_SERVER_DISPLAY:
+ return INDICATE_INTEREST_STRING_SERVER_DISPLAY;
+ case INDICATE_INTEREST_SERVER_SIGNAL:
+ return INDICATE_INTEREST_STRING_SERVER_SIGNAL;
+ case INDICATE_INTEREST_INDICATOR_DISPLAY:
+ return INDICATE_INTEREST_STRING_INDICATOR_DISPLAY;
+ case INDICATE_INTEREST_INDICATOR_SIGNAL:
+ return INDICATE_INTEREST_STRING_INDICATOR_SIGNAL;
+ case INDICATE_INTEREST_INDICATOR_COUNT:
+ return INDICATE_INTEREST_STRING_INDICATOR_COUNT;
+ default:
+ return "";
+ }
+}
+
+static void
+interest_cb (DBusGProxy *proxy, GError *error, gpointer userdata)
+{
+ if (error != NULL) {
+ g_warning("Unable to configure interest.");
+ }
+
+ return;
+}
+
+void
+indicate_listener_server_show_interest (IndicateListener * listener, IndicateListenerServer * server, IndicateInterests interest)
+{
+ if (!server->interests[interest]) {
+ org_freedesktop_indicator_show_interest_async (server->proxy, interest_to_string(interest), interest_cb, server);
+ server->interests[interest] = TRUE;
+ }
+ return;
+}
+
+void
+indicate_listener_server_remove_interest (IndicateListener * listener, IndicateListenerServer * server, IndicateInterests interest)
+{
+ if (server->interests[interest]) {
+ org_freedesktop_indicator_remove_interest_async (server->proxy, interest_to_string(interest), interest_cb, server);
+ server->interests[interest] = FALSE;
+ }
+ return;
+}
+
+gboolean
+indicate_listener_server_check_interest (IndicateListener * listener, IndicateListenerServer * server, IndicateInterests interest)
+{
+ return server->interests[interest];
+}
+
diff --git a/libindicate/listener.h b/libindicate/listener.h
index f931b04..0fdaa9b 100644
--- a/libindicate/listener.h
+++ b/libindicate/listener.h
@@ -37,6 +37,7 @@ License version 3 and version 2.1 along with this program. If not, see
#include "indicator.h"
#include "server.h"
+#include "interests.h"
G_BEGIN_DECLS
@@ -54,11 +55,11 @@ G_BEGIN_DECLS
#define INDICATE_LISTENER_SIGNAL_SERVER_ADDED "server-added"
#define INDICATE_LISTENER_SIGNAL_SERVER_REMOVED "server-removed"
-#define INDICATE_LISTENER_SERVER_DBUS_NAME(server) ((gchar *)server)
-#define INDICATE_LISTENER_INDICATOR_ID(indicator) (GPOINTER_TO_UINT(indicator))
+#define INDICATE_LISTENER_SERVER_DBUS_NAME(server) (indicate_listener_server_get_dbusname(server))
+#define INDICATE_LISTENER_INDICATOR_ID(indicator) (indicate_listener_indicator_get_id(indicator))
-typedef gchar IndicateListenerServer;
-typedef guint IndicateListenerIndicator;
+typedef struct _IndicateListenerServer IndicateListenerServer;
+typedef struct _IndicateListenerIndicator IndicateListenerIndicator;
typedef struct _IndicateListener IndicateListener;
struct _IndicateListener {
@@ -109,7 +110,6 @@ void indicate_listener_get_property_icon (IndicateListener * l
void indicate_listener_display (IndicateListener * listener,
IndicateListenerServer * server,
IndicateListenerIndicator * indicator);
-gboolean indicate_listener_get_indicator_servers (IndicateListener * listener, GList * servers);
void indicate_listener_server_get_type (IndicateListener * listener,
IndicateListenerServer * server,
indicate_listener_get_server_property_cb callback,
@@ -118,10 +118,17 @@ void indicate_listener_server_get_desktop (IndicateListener * l
IndicateListenerServer * server,
indicate_listener_get_server_property_cb callback,
gpointer data);
-
-
-
-
+const gchar * indicate_listener_server_get_dbusname (IndicateListenerServer * server);
+guint indicate_listener_indicator_get_id (IndicateListenerIndicator * indicator);
+void indicate_listener_server_show_interest (IndicateListener * listener,
+ IndicateListenerServer * server,
+ IndicateInterests interest);
+void indicate_listener_server_remove_interest (IndicateListener * listener,
+ IndicateListenerServer * server,
+ IndicateInterests interest);
+gboolean indicate_listener_server_check_interest (IndicateListener * listener,
+ IndicateListenerServer * server,
+ IndicateInterests interest);
G_END_DECLS
diff --git a/libindicate/server.c b/libindicate/server.c
index 39753d2..9e33516 100644
--- a/libindicate/server.c
+++ b/libindicate/server.c
@@ -28,7 +28,9 @@ License version 3 and version 2.1 along with this program. If not, see
*/
#include "server.h"
-#include "dbus-indicate-server.h"
+#include "interests-priv.h"
+#include <dbus/dbus-glib.h>
+#include <dbus/dbus-glib-lowlevel.h>
/* Errors */
enum {
@@ -42,6 +44,10 @@ enum {
NO_GET_INDICATOR_PROPERTIES,
NO_SHOW_INDICATOR_TO_USER,
INVALID_INDICATOR_ID,
+ NO_SHOW_INTEREST,
+ NO_REMOVE_INTEREST,
+ SHOW_INTEREST_FAILED,
+ REMOVE_INTEREST_FAILED,
LAST_ERROR
};
@@ -53,6 +59,8 @@ enum {
SERVER_SHOW,
SERVER_HIDE,
SERVER_DISPLAY,
+ INTEREST_ADDED,
+ INTEREST_REMOVED,
LAST_SIGNAL
};
@@ -70,21 +78,33 @@ typedef struct _IndicateServerPrivate IndicateServerPrivate;
struct _IndicateServerPrivate
{
DBusGConnection *connection;
+ DBusGProxy * dbus_proxy;
+
gchar * path;
GSList * indicators;
gboolean visible;
guint current_id;
+ gboolean registered;
gchar * desktop;
gchar * type;
// TODO: Should have a more robust way to track this, but this'll work for now
guint num_hidden;
+
+ gboolean interests[INDICATE_INTEREST_LAST];
+ GList * interestedfolks;
};
#define INDICATE_SERVER_GET_PRIVATE(o) \
(G_TYPE_INSTANCE_GET_PRIVATE ((o), INDICATE_TYPE_SERVER, IndicateServerPrivate))
+typedef struct _IndicateServerInterestedFolk IndicateServerInterestedFolk;
+struct _IndicateServerInterestedFolk {
+ gchar * sender;
+ gboolean interests[INDICATE_INTEREST_LAST];
+};
+
/* Define Type */
G_DEFINE_TYPE (IndicateServer, indicate_server, G_TYPE_OBJECT);
@@ -94,14 +114,40 @@ static void indicate_server_finalize (GObject * obj);
static gboolean get_indicator_count (IndicateServer * server, guint * count, GError **error);
static gboolean get_indicator_count_by_type (IndicateServer * server, gchar * type, guint * count, GError **error);
static gboolean get_indicator_list (IndicateServer * server, GArray ** indicators, GError ** error);
-static gboolean get_indicator_list_by_type (IndicateServer * server, gchar * type, guint ** indicators, GError ** error);
+static gboolean get_indicator_list_by_type (IndicateServer * server, gchar * type, GArray ** indicators, GError ** error);
static gboolean get_indicator_property (IndicateServer * server, guint id, gchar * property, gchar ** value, GError **error);
static gboolean get_indicator_property_group (IndicateServer * server, guint id, GPtrArray * properties, gchar *** value, GError **error);
static gboolean get_indicator_properties (IndicateServer * server, guint id, gchar *** properties, GError **error);
static gboolean show_indicator_to_user (IndicateServer * server, guint id, GError ** error);
+static void dbus_owner_change (DBusGProxy * proxy, const gchar * name, const gchar * prev, const gchar * new, IndicateServer * server);
static guint get_next_id (IndicateServer * server);
static void set_property (GObject * obj, guint id, const GValue * value, GParamSpec * pspec);
static void get_property (GObject * obj, guint id, GValue * value, GParamSpec * pspec);
+static gboolean show_interest (IndicateServer * server, gchar * sender, IndicateInterests interest);
+static gboolean remove_interest (IndicateServer * server, gchar * sender, IndicateInterests interest);
+static gboolean check_interest (IndicateServer * server, IndicateInterests intrest);
+static gint indicate_server_interested_folks_equal (gconstpointer a, gconstpointer b);
+static void indicate_server_interested_folks_init (IndicateServerInterestedFolk * folk, gchar * sender);
+static void indicate_server_interested_folks_set (IndicateServerInterestedFolk * folk, IndicateInterests interest, gboolean value);
+static void indicate_server_interested_folks_copy (IndicateServerInterestedFolk * folk, gboolean * interests);
+static void indicate_server_interested_folks_destroy(IndicateServerInterestedFolk * folk);
+
+/* DBus API */
+gboolean _indicate_server_get_indicator_count (IndicateServer * server, guint * count, GError **error);
+gboolean _indicate_server_get_indicator_count_by_type (IndicateServer * server, gchar * type, guint * count, GError **error);
+gboolean _indicate_server_get_indicator_list (IndicateServer * server, GArray ** indicators, GError ** error);
+gboolean _indicate_server_get_indicator_list_by_type (IndicateServer * server, gchar * type, GArray ** indicators, GError ** error);
+gboolean _indicate_server_get_indicator_property (IndicateServer * server, guint id, gchar * property, gchar ** value, GError **error);
+gboolean _indicate_server_get_indicator_property_group (IndicateServer * server, guint id, GPtrArray * properties, gchar *** value, GError **error);
+gboolean _indicate_server_get_indicator_properties (IndicateServer * server, guint id, gchar *** properties, GError **error);
+gboolean _indicate_server_show_indicator_to_user (IndicateServer * server, guint id, GError ** error);
+gboolean _indicate_server_show_interest (IndicateServer * server, gchar * interest, DBusGMethodInvocation * method);
+gboolean _indicate_server_remove_interest (IndicateServer * server, gchar * interest, DBusGMethodInvocation * method);
+
+/* Has to be after the dbus prototypes */
+#include "dbus-indicate-server.h"
+
+
/* Code */
static void
@@ -159,6 +205,20 @@ indicate_server_class_init (IndicateServerClass * class)
NULL, NULL,
g_cclosure_marshal_VOID__VOID,
G_TYPE_NONE, 0);
+ signals[INTEREST_ADDED] = g_signal_new(INDICATE_SERVER_SIGNAL_INTEREST_ADDED,
+ G_TYPE_FROM_CLASS (class),
+ G_SIGNAL_RUN_LAST,
+ G_STRUCT_OFFSET (IndicateServerClass, interest_added),
+ NULL, NULL,
+ g_cclosure_marshal_VOID__UINT,
+ G_TYPE_NONE, 1, G_TYPE_UINT);
+ signals[INTEREST_REMOVED] = g_signal_new(INDICATE_SERVER_SIGNAL_INTEREST_REMOVED,
+ G_TYPE_FROM_CLASS (class),
+ G_SIGNAL_RUN_LAST,
+ G_STRUCT_OFFSET (IndicateServerClass, interest_removed),
+ NULL, NULL,
+ g_cclosure_marshal_VOID__UINT,
+ G_TYPE_NONE, 1, G_TYPE_UINT);
g_object_class_install_property (gobj, PROP_DESKTOP,
g_param_spec_string("desktop", "Desktop File",
@@ -172,7 +232,7 @@ indicate_server_class_init (IndicateServerClass * class)
G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
dbus_g_object_type_install_info(INDICATE_TYPE_SERVER,
- &dbus_glib_indicate_server_object_info);
+ &dbus_glib__indicate_server_object_info);
class->get_indicator_count = get_indicator_count;
class->get_indicator_count_by_type = get_indicator_count_by_type;
@@ -183,6 +243,9 @@ indicate_server_class_init (IndicateServerClass * class)
class->get_indicator_properties = get_indicator_properties;
class->show_indicator_to_user = show_indicator_to_user;
class->get_next_id = get_next_id;
+ class->show_interest = show_interest;
+ class->remove_interest = remove_interest;
+ class->check_interest = check_interest;
return;
}
@@ -198,10 +261,18 @@ indicate_server_init (IndicateServer * server)
priv->indicators = NULL;
priv->num_hidden = 0;
priv->visible = FALSE;
+ priv->registered = FALSE;
priv->current_id = 0;
priv->type = NULL;
priv->desktop = NULL;
+ guint i;
+ for (i = INDICATE_INTEREST_NONE; i < INDICATE_INTEREST_LAST; i++) {
+ priv->interests[i] = FALSE;
+ }
+ priv->interestedfolks = NULL;
+
+
return;
}
@@ -302,12 +373,27 @@ indicate_server_show (IndicateServer * server)
priv->connection = dbus_g_bus_get(DBUS_BUS_SESSION, NULL);
- dbus_g_connection_register_g_object(priv->connection,
- priv->path,
- G_OBJECT(server));
+ if (!priv->registered) {
+ dbus_g_connection_register_g_object(priv->connection,
+ priv->path,
+ G_OBJECT(server));
+ priv->registered = TRUE;
+ }
+
priv->visible = TRUE;
g_signal_emit(server, signals[SERVER_SHOW], 0, priv->type ? priv->type : "", TRUE);
+
+ priv->dbus_proxy = dbus_g_proxy_new_for_name_owner (priv->connection,
+ DBUS_SERVICE_DBUS,
+ DBUS_PATH_DBUS,
+ DBUS_INTERFACE_DBUS,
+ NULL);
+ dbus_g_proxy_add_signal(priv->dbus_proxy, "NameOwnerChanged",
+ G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING,
+ G_TYPE_INVALID);
+ dbus_g_proxy_connect_signal(priv->dbus_proxy, "NameOwnerChanged",
+ G_CALLBACK(dbus_owner_change), server, NULL);
return;
}
@@ -323,14 +409,86 @@ indicate_server_hide (IndicateServer * server)
priv->visible = FALSE;
+ /* Delete interested parties */
+ g_list_foreach(priv->interestedfolks, (GFunc)indicate_server_interested_folks_destroy, NULL);
+ g_list_free(priv->interestedfolks);
+ priv->interestedfolks = NULL;
+
+ /* Signal the lack of interest */
+ guint i;
+ for (i = INDICATE_INTEREST_NONE; i < INDICATE_INTEREST_LAST; i++) {
+ if (priv->interests[i]) {
+ g_signal_emit(G_OBJECT(server), signals[INTEREST_REMOVED], 0, i, TRUE);
+ }
+ priv->interests[i] = FALSE;
+ }
+
g_signal_emit(server, signals[SERVER_HIDE], 0, priv->type ? priv->type : "", TRUE);
- dbus_g_connection_unref (priv->connection);
- priv->connection = NULL;
+ if (priv->dbus_proxy != NULL) {
+ g_object_unref(G_OBJECT(priv->dbus_proxy));
+ priv->dbus_proxy = NULL;
+ }
+
+ if (priv->connection != NULL) {
+ dbus_g_connection_unref (priv->connection);
+ priv->connection = NULL;
+ }
return;
}
+static void
+dbus_owner_change (DBusGProxy * proxy, const gchar * name, const gchar * prev, const gchar * new, IndicateServer * server)
+{
+ /* g_debug("DBus Owner change (%s, %s, %s)", name, prev, new); */
+ if (prev == NULL || prev[0] == '\0') {
+ /* We only care about people leaving the bus */
+ return;
+ }
+
+ /* g_debug("\tBeing removed, interesting"); */
+ IndicateServerPrivate * priv = INDICATE_SERVER_GET_PRIVATE(server);
+
+ IndicateServerInterestedFolk searchitem;
+ searchitem.sender = (gchar *)name;
+ GList * entry = g_list_find_custom(priv->interestedfolks, &searchitem, indicate_server_interested_folks_equal);
+
+ if (entry == NULL) {
+ /* g_debug("\tWe don't have it, not interesting"); */
+ return;
+ }
+
+ IndicateServerInterestedFolk * folk = (IndicateServerInterestedFolk *)entry->data;
+ priv->interestedfolks = g_list_remove(priv->interestedfolks, entry->data);
+
+ guint i;
+ for (i = INDICATE_INTEREST_NONE; i < INDICATE_INTEREST_LAST; i++) {
+ priv->interests[i] = FALSE;
+ }
+
+ GList * listi = NULL;
+ for (listi = priv->interestedfolks ; listi != NULL ; listi = listi->next) {
+ IndicateServerInterestedFolk * folkpointer = (IndicateServerInterestedFolk *)listi->data;
+ /* g_debug("\tRebuild list from folk: %s", folkpointer->sender); */
+ indicate_server_interested_folks_copy(folkpointer, priv->interests);
+ }
+
+ for (i = INDICATE_INTEREST_NONE; i < INDICATE_INTEREST_LAST; i++) {
+ /* g_debug("\tComparing interests. Interest: %d Folk: %d Everyone: %d", i, folk->interests[i], priv->interests[i]); */
+ if (folk->interests[i] && !priv->interests[i]) {
+ /* We can only remove interest here. Think about it for a
+ moment and I think you'll be cool with it. */
+ /* g_debug("\tOh, and it was interested in %d. Not anymore.", i); */
+ g_signal_emit(G_OBJECT(server), signals[INTEREST_REMOVED], 0, i, TRUE);
+ }
+ }
+
+ g_free(folk);
+
+ return;
+}
+
static guint
get_next_id (IndicateServer * server)
{
@@ -339,6 +497,89 @@ get_next_id (IndicateServer * server)
return priv->current_id;
}
+static gboolean
+show_interest (IndicateServer * server, gchar * sender, IndicateInterests interest)
+{
+ if (!(interest > INDICATE_INTEREST_NONE && interest < INDICATE_INTEREST_LAST)) {
+ return FALSE;
+ }
+
+ /* g_debug("Someone is showing interest. %s in %d", sender, interest); */
+ IndicateServerInterestedFolk localfolk;
+ localfolk.sender = sender;
+
+ IndicateServerPrivate * priv = INDICATE_SERVER_GET_PRIVATE(server);
+
+ GList * entry = g_list_find_custom(priv->interestedfolks, &localfolk, indicate_server_interested_folks_equal);
+ IndicateServerInterestedFolk * folkpointer = NULL;
+ if (entry == NULL) {
+ folkpointer = g_new(IndicateServerInterestedFolk, 1);
+ indicate_server_interested_folks_init(folkpointer, sender);
+ priv->interestedfolks = g_list_append(priv->interestedfolks, folkpointer);
+ } else {
+ folkpointer = (IndicateServerInterestedFolk *)entry->data;
+ }
+
+ indicate_server_interested_folks_set(folkpointer, interest, TRUE);
+ if (!priv->interests[interest]) {
+ g_signal_emit(G_OBJECT(server), signals[INTEREST_ADDED], 0, interest, TRUE);
+ priv->interests[interest] = TRUE;
+ }
+
+ return TRUE;
+}
+
+static gboolean
+remove_interest (IndicateServer * server, gchar * sender, IndicateInterests interest)
+{
+ if (!(interest > INDICATE_INTEREST_NONE && interest < INDICATE_INTEREST_LAST)) {
+ return FALSE;
+ }
+
+ IndicateServerInterestedFolk localfolk;
+ localfolk.sender = sender;
+
+ IndicateServerPrivate * priv = INDICATE_SERVER_GET_PRIVATE(server);
+
+ GList * entry = g_list_find_custom(priv->interestedfolks, &localfolk, indicate_server_interested_folks_equal);
+ IndicateServerInterestedFolk * folkpointer = NULL;
+ if (entry == NULL) {
+ folkpointer = g_new(IndicateServerInterestedFolk, 1);
+ indicate_server_interested_folks_init(folkpointer, sender);
+ priv->interestedfolks = g_list_append(priv->interestedfolks, folkpointer);
+ } else {
+ folkpointer = (IndicateServerInterestedFolk *)entry->data;
+ }
+
+ indicate_server_interested_folks_set(folkpointer, interest, FALSE);
+
+ if (priv->interests[interest]) {
+ guint i;
+ for (i = INDICATE_INTEREST_NONE; i < INDICATE_INTEREST_LAST; i++) {
+ priv->interests[i] = FALSE;
+ }
+
+ GList * listi = NULL;
+ for (listi = priv->interestedfolks ; listi != NULL ; listi = listi->next) {
+ folkpointer = (IndicateServerInterestedFolk *)listi->data;
+ indicate_server_interested_folks_copy(folkpointer, priv->interests);
+ }
+
+ if (!priv->interests[interest]) {
+ g_signal_emit(G_OBJECT(server), signals[INTEREST_REMOVED], 0, interest, TRUE);
+ }
+ }
+
+ return TRUE;
+}
+
+static gboolean
+check_interest (IndicateServer * server, IndicateInterests interest)
+{
+ IndicateServerPrivate * priv = INDICATE_SERVER_GET_PRIVATE(server);
+ return priv->interests[interest];
+}
+
static void
indicator_show_cb (IndicateIndicator * indicator, IndicateServer * server)
{
@@ -369,8 +610,10 @@ indicate_server_add_indicator (IndicateServer * server, IndicateIndicator * indi
{
IndicateServerPrivate * priv = INDICATE_SERVER_GET_PRIVATE(server);
- g_object_ref(indicator);
- priv->indicators = g_slist_prepend(priv->indicators, indicator);
+ if (g_slist_find (priv->indicators, indicator) != NULL)
+ return;
+
+ priv->indicators = g_slist_prepend(priv->indicators, indicator);
if (!indicate_indicator_is_visible(indicator)) {
priv->num_hidden++;
@@ -390,6 +633,9 @@ indicate_server_remove_indicator (IndicateServer * server, IndicateIndicator * i
{
IndicateServerPrivate * priv = INDICATE_SERVER_GET_PRIVATE(server);
+ if (g_slist_find (priv->indicators, indicator) == NULL)
+ return;
+
priv->indicators = g_slist_remove(priv->indicators, indicator);
if (indicate_indicator_is_visible(indicator)) {
g_signal_emit(server, signals[INDICATOR_REMOVED], 0, indicate_indicator_get_id(indicator), indicate_indicator_get_indicator_type(indicator), TRUE);
@@ -401,7 +647,6 @@ indicate_server_remove_indicator (IndicateServer * server, IndicateIndicator * i
g_signal_handlers_disconnect_by_func(indicator, indicator_hide_cb, server);
g_signal_handlers_disconnect_by_func(indicator, indicator_modified_cb, server);
- g_object_unref(indicator);
return;
}
@@ -553,7 +798,7 @@ get_indicator_list (IndicateServer * server, GArray ** indicators, GError ** err
}
static gboolean
-get_indicator_list_by_type (IndicateServer * server, gchar * type, guint ** indicators, GError ** error)
+get_indicator_list_by_type (IndicateServer * server, gchar * type, GArray ** indicators, GError ** error)
{
g_return_val_if_fail(INDICATE_IS_SERVER(server), TRUE);
@@ -686,11 +931,11 @@ show_indicator_to_user (IndicateServer * server, guint id, GError ** error)
/* Virtual Functions */
gboolean
-indicate_server_get_indicator_count (IndicateServer * server, guint * count, GError **error)
+_indicate_server_get_indicator_count (IndicateServer * server, guint * count, GError **error)
{
IndicateServerClass * class = INDICATE_SERVER_GET_CLASS(server);
- if (class != NULL) {
+ if (class != NULL && class->get_indicator_count != NULL) {
return class->get_indicator_count (server, count, error);
}
@@ -707,11 +952,11 @@ indicate_server_get_indicator_count (IndicateServer * server, guint * count, GEr
}
gboolean
-indicate_server_get_indicator_count_by_type (IndicateServer * server, gchar * type, guint * count, GError **error)
+_indicate_server_get_indicator_count_by_type (IndicateServer * server, gchar * type, guint * count, GError **error)
{
IndicateServerClass * class = INDICATE_SERVER_GET_CLASS(server);
- if (class != NULL) {
+ if (class != NULL && class->get_indicator_count_by_type != NULL) {
return class->get_indicator_count_by_type (server, type, count, error);
}
@@ -728,11 +973,11 @@ indicate_server_get_indicator_count_by_type (IndicateServer * server, gchar * ty
}
gboolean
-indicate_server_get_indicator_list (IndicateServer * server, GArray ** indicators, GError ** error)
+_indicate_server_get_indicator_list (IndicateServer * server, GArray ** indicators, GError ** error)
{
IndicateServerClass * class = INDICATE_SERVER_GET_CLASS(server);
- if (class != NULL) {
+ if (class != NULL && class->get_indicator_list != NULL) {
return class->get_indicator_list (server, indicators, error);
}
@@ -749,11 +994,11 @@ indicate_server_get_indicator_list (IndicateServer * server, GArray ** indicator
}
gboolean
-indicate_server_get_indicator_list_by_type (IndicateServer * server, gchar * type, guint ** indicators, GError ** error)
+_indicate_server_get_indicator_list_by_type (IndicateServer * server, gchar * type, GArray ** indicators, GError ** error)
{
IndicateServerClass * class = INDICATE_SERVER_GET_CLASS(server);
- if (class != NULL) {
+ if (class != NULL && class->get_indicator_list_by_type != NULL) {
return class->get_indicator_list_by_type (server, type, indicators, error);
}
@@ -770,11 +1015,11 @@ indicate_server_get_indicator_list_by_type (IndicateServer * server, gchar * typ
}
gboolean
-indicate_server_get_indicator_property (IndicateServer * server, guint id, gchar * property, gchar ** value, GError **error)
+_indicate_server_get_indicator_property (IndicateServer * server, guint id, gchar * property, gchar ** value, GError **error)
{
IndicateServerClass * class = INDICATE_SERVER_GET_CLASS(server);
- if (class != NULL) {
+ if (class != NULL && class->get_indicator_property != NULL) {
return class->get_indicator_property (server, id, property, value, error);
}
@@ -791,11 +1036,11 @@ indicate_server_get_indicator_property (IndicateServer * server, guint id, gchar
}
gboolean
-indicate_server_get_indicator_property_group (IndicateServer * server, guint id, GPtrArray * properties, gchar *** value, GError **error)
+_indicate_server_get_indicator_property_group (IndicateServer * server, guint id, GPtrArray * properties, gchar *** value, GError **error)
{
IndicateServerClass * class = INDICATE_SERVER_GET_CLASS(server);
- if (class != NULL) {
+ if (class != NULL && class->get_indicator_property_group != NULL) {
return class->get_indicator_property_group (server, id, properties, value, error);
}
@@ -812,11 +1057,11 @@ indicate_server_get_indicator_property_group (IndicateServer * server, guint id,
}
gboolean
-indicate_server_get_indicator_properties (IndicateServer * server, guint id, gchar *** properties, GError **error)
+_indicate_server_get_indicator_properties (IndicateServer * server, guint id, gchar *** properties, GError **error)
{
IndicateServerClass * class = INDICATE_SERVER_GET_CLASS(server);
- if (class != NULL) {
+ if (class != NULL && class->get_indicator_properties != NULL) {
return class->get_indicator_properties (server, id, properties, error);
}
@@ -833,11 +1078,11 @@ indicate_server_get_indicator_properties (IndicateServer * server, guint id, gch
}
gboolean
-indicate_server_show_indicator_to_user (IndicateServer * server, guint id, GError ** error)
+_indicate_server_show_indicator_to_user (IndicateServer * server, guint id, GError ** error)
{
IndicateServerClass * class = INDICATE_SERVER_GET_CLASS(server);
- if (class != NULL) {
+ if (class != NULL && class->show_indicator_to_user != NULL) {
return class->show_indicator_to_user (server, id, error);
}
@@ -858,13 +1103,105 @@ indicate_server_get_next_id (IndicateServer * server)
{
IndicateServerClass * class = INDICATE_SERVER_GET_CLASS(server);
- if (class != NULL) {
+ if (class != NULL && class->get_next_id != NULL) {
return class->get_next_id (server);
}
return 0;
}
+static IndicateInterests
+interest_string_to_enum (gchar * interest_string)
+{
+ if (!g_strcmp0(interest_string, INDICATE_INTEREST_STRING_SERVER_DISPLAY)) {
+ return INDICATE_INTEREST_SERVER_DISPLAY;
+ }
+
+ if (!g_strcmp0(interest_string, INDICATE_INTEREST_STRING_SERVER_SIGNAL)) {
+ return INDICATE_INTEREST_SERVER_SIGNAL;
+ }
+
+ if (!g_strcmp0(interest_string, INDICATE_INTEREST_STRING_INDICATOR_DISPLAY)) {
+ return INDICATE_INTEREST_INDICATOR_DISPLAY;
+ }
+
+ if (!g_strcmp0(interest_string, INDICATE_INTEREST_STRING_INDICATOR_SIGNAL)) {
+ return INDICATE_INTEREST_INDICATOR_SIGNAL;
+ }
+
+ if (!g_strcmp0(interest_string, INDICATE_INTEREST_STRING_INDICATOR_COUNT)) {
+ return INDICATE_INTEREST_INDICATOR_COUNT;
+ }
+
+ return INDICATE_INTEREST_NONE;
+}
+
+gboolean
+_indicate_server_show_interest (IndicateServer * server, gchar * interest, DBusGMethodInvocation * method)
+{
+ IndicateServerClass * class = INDICATE_SERVER_GET_CLASS(server);
+
+ if (class != NULL && class->show_interest != NULL) {
+ if (class->show_interest (server, dbus_g_method_get_sender(method), interest_string_to_enum(interest))){
+ dbus_g_method_return(method);
+ return TRUE;
+ } else {
+ GError * error;
+ g_set_error(&error,
+ indicate_server_error_quark(),
+ SHOW_INTEREST_FAILED,
+ "Unable to show interest: %s",
+ interest);
+ dbus_g_method_return_error(method, error);
+ g_error_free(error);
+ return FALSE;
+ }
+ }
+
+ GError * error;
+ g_set_error(&error,
+ indicate_server_error_quark(),
+ NO_SHOW_INTEREST,
+ "show_interest function doesn't exist for this server class: %s",
+ G_OBJECT_TYPE_NAME(server));
+ dbus_g_method_return_error(method, error);
+ g_error_free(error);
+ return FALSE;
+}
+
+gboolean
+_indicate_server_remove_interest (IndicateServer * server, gchar * interest, DBusGMethodInvocation * method)
+{
+ IndicateServerClass * class = INDICATE_SERVER_GET_CLASS(server);
+
+ if (class != NULL && class->remove_interest != NULL) {
+ if (class->remove_interest (server, dbus_g_method_get_sender(method), interest_string_to_enum(interest))){
+ dbus_g_method_return(method);
+ return TRUE;
+ } else {
+ GError * error;
+ g_set_error(&error,
+ indicate_server_error_quark(),
+ REMOVE_INTEREST_FAILED,
+ "Unable to remove interest: %s",
+ interest);
+ dbus_g_method_return_error(method, error);
+ g_error_free(error);
+ return FALSE;
+ }
+ }
+
+ GError * error;
+ g_set_error(&error,
+ indicate_server_error_quark(),
+ NO_REMOVE_INTEREST,
+ "remove_interest function doesn't exist for this server class: %s",
+ G_OBJECT_TYPE_NAME(server));
+ dbus_g_method_return_error(method, error);
+ g_error_free(error);
+ return FALSE;
+}
+
/* Signal emission functions for sub-classes of the server */
void
indicate_server_emit_indicator_added (IndicateServer *server, guint id, const gchar *type)
@@ -900,3 +1237,53 @@ indicate_server_emit_server_display (IndicateServer *server)
g_signal_emit(server, signals[SERVER_DISPLAY], 0, TRUE);
}
+
+/* *** Folks stuff *** */
+
+static gint
+indicate_server_interested_folks_equal (gconstpointer a, gconstpointer b)
+{
+ return g_strcmp0(((IndicateServerInterestedFolk *)a)->sender,((IndicateServerInterestedFolk *)b)->sender);
+}
+
+static void
+indicate_server_interested_folks_init (IndicateServerInterestedFolk * folk, gchar * sender)
+{
+ folk->sender = g_strdup(sender);
+
+ guint i;
+ for (i = INDICATE_INTEREST_NONE; i < INDICATE_INTEREST_LAST; i++) {
+ folk->interests[i] = FALSE;
+ }
+
+ return;
+}
+
+static void
+indicate_server_interested_folks_set (IndicateServerInterestedFolk * folk, IndicateInterests interest, gboolean value)
+{
+ folk->interests[interest] = value;
+ return;
+}
+
+static void
+indicate_server_interested_folks_copy (IndicateServerInterestedFolk * folk, gboolean * interests)
+{
+ guint i;
+ for (i = INDICATE_INTEREST_NONE; i < INDICATE_INTEREST_LAST; i++) {
+ if (folk->interests[i]) {
+ interests[i] = TRUE;
+ }
+ }
+
+ return;
+}
+
+static void
+indicate_server_interested_folks_destroy(IndicateServerInterestedFolk * folk)
+{
+ g_free(folk->sender);
+ g_free(folk);
+ return;
+}
+/* *** End Folks *** */
diff --git a/libindicate/server.h b/libindicate/server.h
index 8aa0cf1..cfb4334 100644
--- a/libindicate/server.h
+++ b/libindicate/server.h
@@ -34,6 +34,7 @@ License version 3 and version 2.1 along with this program. If not, see
#include <glib-object.h>
#include "indicator.h"
+#include "interests.h"
G_BEGIN_DECLS
@@ -53,7 +54,8 @@ G_BEGIN_DECLS
#define INDICATE_SERVER_SIGNAL_SERVER_SHOW "server-show"
#define INDICATE_SERVER_SIGNAL_SERVER_HIDE "server-hide"
#define INDICATE_SERVER_SIGNAL_SERVER_DISPLAY "server-display"
-
+#define INDICATE_SERVER_SIGNAL_INTEREST_ADDED "interest-added"
+#define INDICATE_SERVER_SIGNAL_INTEREST_REMOVED "interest-removed"
typedef struct _IndicateServer IndicateServer;
struct _IndicateServer {
@@ -71,17 +73,28 @@ struct _IndicateServerClass {
void (* server_show) (IndicateServer * server, gchar * type);
void (* server_hide) (IndicateServer * server, gchar * type);
void (* server_display) (IndicateServer * server);
+ void (* interest_added) (IndicateServer * server, IndicateInterests interest);
+ void (* interest_removed) (IndicateServer * server, IndicateInterests interest);
/* Virtual Functions */
gboolean (*get_indicator_count) (IndicateServer * server, guint * count, GError **error);
gboolean (*get_indicator_count_by_type) (IndicateServer * server, gchar * type, guint * count, GError **error);
gboolean (*get_indicator_list) (IndicateServer * server, GArray ** indicators, GError ** error);
- gboolean (*get_indicator_list_by_type) (IndicateServer * server, gchar * type, guint ** indicators, GError ** error);
+ gboolean (*get_indicator_list_by_type) (IndicateServer * server, gchar * type, GArray ** indicators, GError ** error);
gboolean (*get_indicator_property) (IndicateServer * server, guint id, gchar * property, gchar ** value, GError **error);
gboolean (*get_indicator_property_group) (IndicateServer * server, guint id, GPtrArray * properties, gchar *** value, GError **error);
gboolean (*get_indicator_properties) (IndicateServer * server, guint id, gchar *** properties, GError **error);
gboolean (*show_indicator_to_user) (IndicateServer * server, guint id, GError ** error);
guint (*get_next_id) (IndicateServer * server);
+ gboolean (*show_interest) (IndicateServer * server, gchar * sender, IndicateInterests interest);
+ gboolean (*remove_interest) (IndicateServer * server, gchar * sender, IndicateInterests interest);
+ gboolean (*check_interest) (IndicateServer * server, IndicateInterests interest);
+
+ /* Reserver for future use */
+ void (*indicate_server_reserved1)(void);
+ void (*indicate_server_reserved2)(void);
+ void (*indicate_server_reserved3)(void);
+ void (*indicate_server_reserved4)(void);
};
GType indicate_server_get_type (void) G_GNUC_CONST;
@@ -111,16 +124,9 @@ void indicate_server_remove_indicator (IndicateServer * server, IndicateIndicato
IndicateServer * indicate_server_ref_default (void);
void indicate_server_set_default (IndicateServer * server);
+/* Check to see if there is someone, out there, who likes this */
+gboolean indicate_server_check_interest (IndicateServer * server, IndicateInterests interest);
-/* DBus API */
-gboolean indicate_server_get_indicator_count (IndicateServer * server, guint * count, GError **error);
-gboolean indicate_server_get_indicator_count_by_type (IndicateServer * server, gchar * type, guint * count, GError **error);
-gboolean indicate_server_get_indicator_list (IndicateServer * server, GArray ** indicators, GError ** error);
-gboolean indicate_server_get_indicator_list_by_type (IndicateServer * server, gchar * type, guint ** indicators, GError ** error);
-gboolean indicate_server_get_indicator_property (IndicateServer * server, guint id, gchar * property, gchar ** value, GError **error);
-gboolean indicate_server_get_indicator_property_group (IndicateServer * server, guint id, GPtrArray * properties, gchar *** value, GError **error);
-gboolean indicate_server_get_indicator_properties (IndicateServer * server, guint id, gchar *** properties, GError **error);
-gboolean indicate_server_show_indicator_to_user (IndicateServer * server, guint id, GError ** error);
/* Signal emission functions for sub-classes of the server */
void indicate_server_emit_indicator_added (IndicateServer *server, guint id, const gchar *type);
diff --git a/src/applet-main.c b/src/applet-main.c
index f6d5199..df93b27 100644
--- a/src/applet-main.c
+++ b/src/applet-main.c
@@ -150,6 +150,7 @@ about_cb (BonoboUIComponent *ui_container,
"wrap-license", TRUE,
"translator-credits", _("translator-credits"),
"logo-icon-name", "indicator-applet",
+ "icon-name", "indicator-applet",
"website", "http://launchpad.net/indicator-applet",
"website-label", _("Indicator Applet Website"),
NULL
@@ -220,13 +221,30 @@ applet_fill_cb (PanelApplet * applet, const gchar * iid, gpointer data)
" GtkWidget::focus-line-width = 0\n"
" GtkWidget::focus-padding = 0\n"
"}\n"
- "widget \"*.fast-user-switch-applet\" style \"indicator-applet-style\"");
+ "style \"indicator-applet-menubar-style\"\n"
+ "{\n"
+ " GtkMenuBar::shadow-type = none\n"
+ " GtkMenuBar::internal-padding = 0\n"
+ " GtkWidget::focus-line-width = 0\n"
+ " GtkWidget::focus-padding = 0\n"
+ " GtkMenuItem::horizontal-padding = 0\n"
+ "}\n"
+ "style \"indicator-applet-menuitem-style\"\n"
+ "{\n"
+ " GtkWidget::focus-line-width = 0\n"
+ " GtkWidget::focus-padding = 0\n"
+ " GtkMenuItem::horizontal-padding = 0\n"
+ "}\n"
+ "widget \"*.fast-user-switch-applet\" style \"indicator-applet-style\""
+ "widget \"*.fast-user-switch-menuitem\" style \"indicator-applet-menuitem-style\""
+ "widget \"*.fast-user-switch-menubar\" style \"indicator-applet-menubar-style\"");
//gtk_widget_set_name(GTK_WIDGET (applet), "indicator-applet-menubar");
gtk_widget_set_name(GTK_WIDGET (applet), "fast-user-switch-applet");
/* Build menubar */
menubar = gtk_menu_bar_new();
GTK_WIDGET_SET_FLAGS (menubar, GTK_WIDGET_FLAGS(menubar) | GTK_CAN_FOCUS);
+ gtk_widget_set_name(GTK_WIDGET (menubar), "fast-user-switch-menubar");
g_signal_connect(menubar, "button-press-event", G_CALLBACK(menubar_press), NULL);
g_signal_connect_after(menubar, "expose-event", G_CALLBACK(menubar_on_expose), menubar);
gtk_container_set_border_width(GTK_CONTAINER(menubar), 0);
diff --git a/tests/Makefile.am b/tests/Makefile.am
index 4a8f962..862046e 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -3,7 +3,8 @@ libexec_PROGRAMS = \
indicate-and-crash \
indicate-alot \
listen-and-print \
- im-client
+ im-client \
+ show-hide-server
indicate_and_crash_SOURCES = \
indicate-and-crash.c
@@ -49,6 +50,17 @@ im_client_LDADD = \
../libindicate/libindicate.la \
$(LIBINDICATE_LIBS)
+show_hide_server_SOURCES = \
+ show-hide-server.c
+
+show_hide_server_CFLAGS = \
+ -I $(srcdir)/.. \
+ $(LIBINDICATE_CFLAGS)
+
+show_hide_server_LDADD = \
+ ../libindicate/libindicate.la \
+ $(LIBINDICATE_LIBS)
+
examplesdir = $(docdir)/examples/
examples_DATA = \
diff --git a/tests/im-client.c b/tests/im-client.c
index 1b5a86b..bf2fbb2 100644
--- a/tests/im-client.c
+++ b/tests/im-client.c
@@ -65,6 +65,18 @@ server_display (IndicateServer * server, gpointer data)
g_debug("Ah, my server has been displayed");
}
+static void
+interest_added (IndicateServer * server, IndicateInterests interest)
+{
+ g_debug("Oh, someone is interested in my for: %d", interest);
+}
+
+void
+interest_removed (IndicateServer * server, IndicateInterests interest)
+{
+ g_debug("Someone is no longer interested in my for: %d", interest);
+}
+
int
main (int argc, char ** argv)
{
@@ -74,6 +86,8 @@ main (int argc, char ** argv)
indicate_server_set_type(server, "message.im");
indicate_server_set_desktop_file(server, "/usr/share/applications/empathy.desktop");
g_signal_connect(G_OBJECT(server), INDICATE_SERVER_SIGNAL_SERVER_DISPLAY, G_CALLBACK(server_display), NULL);
+ g_signal_connect(G_OBJECT(server), INDICATE_SERVER_SIGNAL_INTEREST_ADDED, G_CALLBACK(interest_added), NULL);
+ g_signal_connect(G_OBJECT(server), INDICATE_SERVER_SIGNAL_INTEREST_REMOVED, G_CALLBACK(interest_removed), NULL);
IndicateIndicatorMessage * indicator;
diff --git a/tests/listen-and-print.c b/tests/listen-and-print.c
index 2535160..dcad92b 100644
--- a/tests/listen-and-print.c
+++ b/tests/listen-and-print.c
@@ -111,6 +111,11 @@ server_added (IndicateListener * listener, IndicateListenerServer * server, gcha
g_debug("Indicator Server Added: %s %s", INDICATE_LISTENER_SERVER_DBUS_NAME(server), type);
indicate_listener_server_get_type(listener, server, type_cb, NULL);
indicate_listener_server_get_desktop(listener, server, desktop_cb, NULL);
+
+ indicate_listener_server_show_interest(listener, server, INDICATE_INTEREST_SERVER_DISPLAY);
+ indicate_listener_server_show_interest(listener, server, INDICATE_INTEREST_INDICATOR_DISPLAY);
+
+ return;
}
static void
diff --git a/tests/show-hide-server.c b/tests/show-hide-server.c
new file mode 100644
index 0000000..23c1ea1
--- /dev/null
+++ b/tests/show-hide-server.c
@@ -0,0 +1,44 @@
+/* From LP: #351537 */
+
+#include <glib.h>
+#include "libindicate/server.h"
+#include "libindicate/indicator-message.h"
+
+gboolean hidden = TRUE;
+
+static gboolean
+timeout_cb (gpointer data)
+{
+ IndicateServer * server = INDICATE_SERVER(data);
+
+ if (hidden) {
+ printf("showing... ");
+ indicate_server_show(server);
+ printf("ok\n");
+ hidden = FALSE;
+ } else {
+ printf("hiding... ");
+ indicate_server_hide(server);
+ printf("ok\n");
+ hidden = TRUE;
+ }
+
+ return TRUE;
+}
+
+
+int
+main (int argc, char ** argv)
+{
+ g_type_init();
+
+ IndicateServer * server = indicate_server_ref_default();
+ indicate_server_set_type(server, "message.im");
+ indicate_server_set_desktop_file(server, "/usr/share/applications/empathy.desktop");
+ g_timeout_add_seconds(1, timeout_cb, server);
+
+ g_main_loop_run(g_main_loop_new(NULL, FALSE));
+
+ return 0;
+}
+