aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.bzrignore24
-rw-r--r--Makefile.am2
-rw-r--r--configure.ac9
-rw-r--r--examples/Makefile.am72
-rw-r--r--examples/im-client.c (renamed from tests/im-client.c)0
-rw-r--r--examples/indicate-alot.c (renamed from tests/indicate-alot.c)0
-rw-r--r--examples/indicate-and-crash.c (renamed from tests/indicate-and-crash.c)0
-rw-r--r--examples/listen-and-print.c (renamed from tests/listen-and-print.c)0
-rw-r--r--examples/show-hide-server.c (renamed from tests/show-hide-server.c)0
-rwxr-xr-xexamples/test.js (renamed from tests/test.js)0
-rw-r--r--libindicate/Makefile.am44
-rw-r--r--libindicate/interests.h5
-rw-r--r--libindicate/listener.c145
-rw-r--r--libindicate/listener.h5
-rw-r--r--libindicate/server.c13
-rw-r--r--libindicator/Makefile.am14
-rw-r--r--libindicator/indicator.h34
-rw-r--r--libindicator/indicator.pc.in16
-rw-r--r--src/Makefile.am2
-rw-r--r--src/applet-main.c51
-rw-r--r--tests/Makefile.am153
-rw-r--r--tests/test-interests-client.c63
-rw-r--r--tests/test-interests-server.c45
-rw-r--r--tests/test-interests-server1.c41
-rw-r--r--tests/test-interests-server2.c41
-rw-r--r--tests/test-interests-server3.c41
-rw-r--r--tests/test-interests-server4.c41
-rw-r--r--tests/test-interests-server5.c41
-rw-r--r--tests/test-simple-client.c30
-rw-r--r--tests/test-simple-server.c39
-rw-r--r--tests/test-thousand-indicators-client.c34
-rw-r--r--tests/test-thousand-indicators-server.c43
-rwxr-xr-xtests/test_interests5
-rwxr-xr-xtests/test_interests_multi5
-rwxr-xr-xtests/test_simple5
-rwxr-xr-xtests/test_thousand_indicators5
36 files changed, 1000 insertions, 68 deletions
diff --git a/.bzrignore b/.bzrignore
index 3548564..6e10243 100644
--- a/.bzrignore
+++ b/.bzrignore
@@ -55,3 +55,27 @@ tests/indicate-alot
tests/indicate-and-crash
tests/listen-and-print
tests/show-hide-server
+libindicate/indicate-enum-types.c
+libindicate/indicate-enum-types.h
+libindicate/libindicate_la-indicate-enum-types.lo
+libindicate/s-enum-types-c
+libindicate/s-enum-types-h
+indicator.pc
+examples/.deps
+examples/.libs
+examples/im-client
+examples/indicate-alot
+examples/indicate-and-crash
+examples/listen-and-print
+examples/show-hide-server
+test-simple-client
+test-simple-server
+test-interests-client
+test-interests-server
+test-interests-server1
+test-interests-server2
+test-interests-server3
+test-interests-server4
+test-interests-server5
+test-thousand-indicators-server
+test-thousand-indicators-client
diff --git a/Makefile.am b/Makefile.am
index d4f7ca2..ac6fe90 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -2,6 +2,8 @@
SUBDIRS = \
src \
libindicate \
+ libindicator \
+ examples \
tests \
data \
po \
diff --git a/configure.ac b/configure.ac
index 6e5d253..939accd 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.6)
+AM_INIT_AUTOMAKE(indicator-applet, 0.2.0dev)
AM_MAINTAINER_MODE
@@ -50,11 +50,13 @@ AM_GCONF_SOURCE_2
GLIB_REQUIRED_VERSION=2.18
GIO_REQUIRED_VERSION=2.18
GDK_PIXBUF_REQUIRED_VERSION=2.12
+XML_REQUIRED_VERSION=2.6
PKG_CHECK_MODULES(LIBINDICATE, glib-2.0 >= $GLIB_REQUIRED_VERSION
gio-2.0 >= $GIO_REQUIRED_VERSION
gdk-pixbuf-2.0 >= $GDK_PIXBUF_REQUIRED_VERSION
- dbus-glib-1 >= $DBUS_REQUIRED_VERSION)
+ dbus-glib-1 >= $DBUS_REQUIRED_VERSION
+ libxml-2.0 >= $XML_REQUIRED_VERSION)
AC_SUBST(LIBINDICATE_CFLAGS)
AC_SUBST(LIBINDICATE_LIBS)
@@ -159,6 +161,9 @@ Makefile
src/Makefile
libindicate/Makefile
libindicate/indicate.pc
+libindicator/Makefile
+libindicator/indicator.pc
+examples/Makefile
tests/Makefile
data/Makefile
po/Makefile.in
diff --git a/examples/Makefile.am b/examples/Makefile.am
new file mode 100644
index 0000000..862046e
--- /dev/null
+++ b/examples/Makefile.am
@@ -0,0 +1,72 @@
+
+libexec_PROGRAMS = \
+ indicate-and-crash \
+ indicate-alot \
+ listen-and-print \
+ im-client \
+ show-hide-server
+
+indicate_and_crash_SOURCES = \
+ indicate-and-crash.c
+
+indicate_and_crash_CFLAGS = \
+ -I $(srcdir)/.. \
+ $(LIBINDICATE_CFLAGS)
+
+indicate_and_crash_LDADD = \
+ ../libindicate/libindicate.la \
+ $(LIBINDICATE_LIBS)
+
+indicate_alot_SOURCES = \
+ indicate-alot.c
+
+indicate_alot_CFLAGS = \
+ -I $(srcdir)/.. \
+ $(LIBINDICATE_CFLAGS)
+
+indicate_alot_LDADD = \
+ ../libindicate/libindicate.la \
+ $(LIBINDICATE_LIBS)
+
+listen_and_print_SOURCES = \
+ listen-and-print.c
+
+listen_and_print_CFLAGS = \
+ -I $(srcdir)/.. \
+ $(LIBINDICATE_CFLAGS)
+
+listen_and_print_LDADD = \
+ ../libindicate/libindicate.la \
+ $(LIBINDICATE_LIBS)
+
+im_client_SOURCES = \
+ im-client.c
+
+im_client_CFLAGS = \
+ -I $(srcdir)/.. \
+ $(LIBINDICATE_CFLAGS)
+
+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 = \
+ $(indicate_and_crash_SOURCES) \
+ $(indicate_alot_SOURCES) \
+ $(listen_and_print_SOURCES) \
+ $(im_client_SOURCES)
+
+EXTRA_DIST = $(examples_DATA)
diff --git a/tests/im-client.c b/examples/im-client.c
index bf2fbb2..bf2fbb2 100644
--- a/tests/im-client.c
+++ b/examples/im-client.c
diff --git a/tests/indicate-alot.c b/examples/indicate-alot.c
index 479040b..479040b 100644
--- a/tests/indicate-alot.c
+++ b/examples/indicate-alot.c
diff --git a/tests/indicate-and-crash.c b/examples/indicate-and-crash.c
index c002a54..c002a54 100644
--- a/tests/indicate-and-crash.c
+++ b/examples/indicate-and-crash.c
diff --git a/tests/listen-and-print.c b/examples/listen-and-print.c
index dcad92b..dcad92b 100644
--- a/tests/listen-and-print.c
+++ b/examples/listen-and-print.c
diff --git a/tests/show-hide-server.c b/examples/show-hide-server.c
index 23c1ea1..23c1ea1 100644
--- a/tests/show-hide-server.c
+++ b/examples/show-hide-server.c
diff --git a/tests/test.js b/examples/test.js
index 45b0d05..45b0d05 100755
--- a/tests/test.js
+++ b/examples/test.js
diff --git a/libindicate/Makefile.am b/libindicate/Makefile.am
index c1900a6..3ad6247 100644
--- a/libindicate/Makefile.am
+++ b/libindicate/Makefile.am
@@ -1,3 +1,6 @@
+MARSHAL_PREFIX = indicate_marshal
+MARSHAL_FILE = indicate-marshal
+ENUM_FILE = indicate-enum-types
INCLUDES= \
-DG_LOG_DOMAIN=\"libindicate\"
@@ -14,7 +17,9 @@ BUILT_SOURCES = \
dbus-listener-server.h \
dbus-listener-client.h \
listener-marshal.c \
- listener-marshal.h
+ listener-marshal.h \
+ $(ENUM_FILE).h \
+ $(ENUM_FILE).c
lib_LTLIBRARIES = \
libindicate.la
@@ -26,7 +31,8 @@ indicate_headers = \
indicator-message.h \
listener.h \
server.h \
- interests.h
+ interests.h \
+ $(ENUM_FILE).h
libindicateinclude_HEADERS = \
$(indicate_headers)
@@ -37,6 +43,7 @@ libindicate_la_SOURCES = \
dbus-indicate-client.h \
dbus-listener-server.h \
dbus-listener-client.h \
+ indicate-enum-types.c \
server.c \
listener.c \
listener-marshal.c \
@@ -97,6 +104,39 @@ listener-marshal.c: $(srcdir)/listener-marshal.list
pkgconfig_DATA = indicate.pc
pkgconfigdir = $(libdir)/pkgconfig
+$(ENUM_FILE).h: s-enum-types-h
+ @true
+s-enum-types-h: $(indicate_headers) Makefile
+ ( cd $(srcdir) && glib-mkenums \
+ --fhead "#ifndef _INDICATE_ENUM_TYPES_H_\n#define _INDICATE_ENUM_TYPES_H_\n\n#include <glib-object.h>\n\nG_BEGIN_DECLS\n" \
+ --fprod "/* enumerations from \"@filename@\" */\n" \
+ --vhead "GType @enum_name@_get_type(void);\n#define INDICATE_TYPE_@ENUMSHORT@ (@enum_name@_get_type())\n" \
+ --ftail "G_END_DECLS\n\n#endif /* _INDICATE_ENUM_TYPES_H_ */" \
+ interests.h ) > tmp-$(ENUM_FILE).h \
+ && (cmp -s tmp-$(ENUM_FILE).h $(ENUM_FILE).h || cp tmp-$(ENUM_FILE).h $(ENUM_FILE).h ) \
+ && rm -f tmp-$(ENUM_FILE).h \
+ && echo timestamp > $(@F)
+
+$(ENUM_FILE).c: s-enum-types-c
+ @true
+s-enum-types-c: $(indicate_headers) Makefile
+ ( cd $(srcdir) && glib-mkenums \
+ --fhead "#include \"interests.h\"\n#include <glib-object.h>" \
+ --fprod "\n/* enumerations from \"@filename@\" */" \
+ --vhead "GType\n@enum_name@_get_type (void)\n{\n static GType etype = 0;\n if (etype == 0) {\n static const G@Type@Value values[] = {" \
+ --vprod " { @VALUENAME@, \"@VALUENAME@\", \"@valuenick@\" }," \
+ --vtail " { 0, NULL, NULL }\n };\n etype = g_@type@_register_static (\"@EnumName@\", values);\n }\n return etype;\n}\n" \
+ interests.h ) > tmp-$(ENUM_FILE).c \
+ && (cmp -s tmp-$(ENUM_FILE).c $(ENUM_FILE).c || cp tmp-$(ENUM_FILE).c $(ENUM_FILE).c ) \
+ && rm -f tmp-$(ENUM_FILE).c \
+ && echo timestamp > $(@F)
+
+CLEANFILES = \
+ $(ENUM_FILE).c \
+ $(ENUM_FILE).h \
+ s-enum-types-c \
+ s-enum-types-h
+
if USE_GIR
gobjectintrospection_gir_DATA = \
diff --git a/libindicate/interests.h b/libindicate/interests.h
index 70c52d9..1c6215a 100644
--- a/libindicate/interests.h
+++ b/libindicate/interests.h
@@ -34,8 +34,7 @@ License version 3 and version 2.1 along with this program. If not, see
G_BEGIN_DECLS
-typedef enum _IndicateInterests IndicateInterests;
-enum _IndicateInterests {
+typedef enum {
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 */
@@ -43,7 +42,7 @@ enum _IndicateInterests {
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 */
-};
+} IndicateInterests;
G_END_DECLS
diff --git a/libindicate/listener.c b/libindicate/listener.c
index 3cc84b6..bd3639d 100644
--- a/libindicate/listener.c
+++ b/libindicate/listener.c
@@ -27,6 +27,9 @@ License version 3 and version 2.1 along with this program. If not, see
<http://www.gnu.org/licenses/>
*/
+#include <libxml/parser.h>
+#include <libxml/tree.h>
+
#include "listener.h"
#include "listener-marshal.h"
#include <dbus/dbus-glib-bindings.h>
@@ -89,6 +92,7 @@ typedef struct {
gchar * type;
IndicateListener * listener;
GHashTable * indicators;
+ guint introspect_level;
IndicateListenerServer server;
} proxy_t;
@@ -129,6 +133,7 @@ static void proxy_indicator_modified (DBusGProxy * proxy, guint id, const gchar
static void proxy_get_indicator_list (DBusGProxy * proxy, GArray * indicators, GError * error, gpointer data);
static void proxy_get_indicator_type (DBusGProxy * proxy, gchar * type, GError * error, gpointer data);
static void proxy_indicators_free (gpointer data);
+static void introspect_this (DBusGProxy * proxy, char * OUT_data, GError * error, gpointer data);
/* DBus interface */
gboolean _indicate_listener_get_indicator_servers (IndicateListener * listener, GList * servers);
@@ -154,35 +159,35 @@ indicate_listener_class_init (IndicateListenerClass * class)
G_STRUCT_OFFSET (IndicateListenerClass, indicator_added),
NULL, NULL,
_indicate_listener_marshal_VOID__POINTER_POINTER_STRING,
- G_TYPE_NONE, 3, G_TYPE_POINTER, G_TYPE_POINTER, G_TYPE_STRING);
+ G_TYPE_NONE, 3, INDICATE_TYPE_LISTENER_SERVER, INDICATE_TYPE_LISTENER_INDICATOR, 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,
- G_TYPE_NONE, 3, G_TYPE_POINTER, G_TYPE_POINTER, G_TYPE_STRING);
+ G_TYPE_NONE, 3, INDICATE_TYPE_LISTENER_SERVER, INDICATE_TYPE_LISTENER_INDICATOR, 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,
- G_TYPE_NONE, 4, G_TYPE_POINTER, G_TYPE_POINTER, G_TYPE_STRING, G_TYPE_STRING);
+ G_TYPE_NONE, 4, INDICATE_TYPE_LISTENER_SERVER, INDICATE_TYPE_LISTENER_INDICATOR, 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,
- G_TYPE_NONE, 2, G_TYPE_POINTER, G_TYPE_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_listener_marshal_VOID__POINTER_STRING,
- G_TYPE_NONE, 2, G_TYPE_POINTER, G_TYPE_STRING);
+ G_TYPE_NONE, 2, INDICATE_TYPE_LISTENER_SERVER, G_TYPE_STRING);
dbus_g_object_register_marshaller(_indicate_listener_marshal_VOID__UINT_STRING,
G_TYPE_NONE,
@@ -499,13 +504,9 @@ todo_idle (gpointer data)
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
- * that message, but before we set up the handler for the ServerShow
- * 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, &proxyt->server, get_type_cb, proxyt);
+ /* Look through the introspection data to see if this
+ is already a server */
+ introspect_this (NULL, NULL, NULL, proxyt);
return TRUE;
}
@@ -1002,6 +1003,10 @@ interest_cb (DBusGProxy *proxy, GError *error, gpointer userdata)
void
indicate_listener_server_show_interest (IndicateListener * listener, IndicateListenerServer * server, IndicateInterests interest)
{
+ if (!(interest > INDICATE_INTEREST_NONE && interest < INDICATE_INTEREST_LAST)) {
+ return;
+ }
+
if (!server->interests[interest]) {
org_freedesktop_indicator_show_interest_async (server->proxy, interest_to_string(interest), interest_cb, server);
server->interests[interest] = TRUE;
@@ -1025,3 +1030,119 @@ indicate_listener_server_check_interest (IndicateListener * listener, IndicateLi
return server->interests[interest];
}
+GType
+indicate_listener_server_get_gtype (void)
+{
+ static GType our_type = 0;
+
+ if (our_type == 0)
+ our_type = g_pointer_type_register_static ("IndicateListenerServer");
+
+ return our_type;
+}
+
+GType
+indicate_listener_indicator_get_gtype (void)
+{
+ static GType our_type = 0;
+
+ if (our_type == 0)
+ our_type = g_pointer_type_register_static ("IndicateListenerIndicator");
+
+ return our_type;
+}
+
+static const gchar * _introspector_path[] = {"", "org", "freedesktop", "indicate", NULL};
+static const gchar * _introspector_fullpath[] = {"/", "/org", "/org/freedesktop", "/org/freedesktop/indicate", NULL};
+static const gchar * _introspector_interface = "org.freedesktop.indicator";
+
+static void
+introspect_this (DBusGProxy * proxy, char * OUT_data, GError * error, gpointer data)
+{
+ /* g_debug("Introspect this:\n%s", OUT_data); */
+ proxy_t * server = (proxy_t *)data;
+ if (proxy != NULL) {
+ g_object_unref(proxy);
+ }
+ if (error != NULL) {
+ /* We probably couldn't introspect that far up. That's
+ life, it happens. Or there's a timeout, that happens
+ too, I guess some apps are too busy for us. */
+ /* g_debug("Introspection error on %s object %s: %s", server->name, _introspector_fullpath[server->introspect_level], error->message); */
+ return;
+ }
+
+ if (OUT_data != NULL) {
+ xmlDocPtr xmldoc;
+ /* Parse the XML */
+ xmldoc = xmlReadMemory(OUT_data, g_utf8_strlen(OUT_data, 16*1024), "introspection.xml", NULL, 0);
+
+ /* Check for root being "node" */
+ xmlNodePtr root = xmlDocGetRootElement(xmldoc);
+ if (g_strcmp0(root->name, "node") != 0) {
+ xmlFreeDoc(xmldoc);
+ g_warning("Introspection data from %s is not valid: %s", server->name, OUT_data);
+ return;
+ }
+
+ server->introspect_level += 1;
+ const gchar * nodename = NULL;
+ const gchar * nameval = NULL;
+ if (_introspector_path[server->introspect_level] == NULL) {
+ /* We're looking for our interface */
+ nodename = "interface";
+ nameval = _introspector_interface;
+ } else {
+ /* We're looking for our next node */
+ nodename = "node";
+ nameval = _introspector_path[server->introspect_level];
+ }
+
+ gboolean found = FALSE;
+ xmlNodePtr children;
+ for (children = root->children; children != NULL; children = children->next) {
+ gchar * xmlnameval = NULL;
+ if (g_strcmp0(children->name, nodename) == 0) {
+ xmlAttrPtr attrib;
+ for (attrib = children->properties; attrib != NULL; attrib = attrib->next) {
+ if (g_strcmp0(attrib->name, "name") == 0) {
+ if (attrib->children != NULL) {
+ xmlnameval = attrib->children->content;
+ }
+ break;
+ }
+ }
+
+ if (!g_strcmp0(nameval, xmlnameval)) {
+ found = TRUE;
+ break;
+ }
+ }
+ }
+
+ xmlFreeDoc(xmldoc);
+
+ if (!found) {
+ /* Ah, nothing we're interested in */
+ return;
+ }
+
+ if (_introspector_path[server->introspect_level] == NULL) {
+ /* If we've found the interface at the end of the tree, whoo! hoo! */
+ /* Now we know it's safe to get the type on it */
+ indicate_listener_server_get_type(server->listener, &server->server, get_type_cb, server);
+ return;
+ }
+ } else {
+ server->introspect_level = 0;
+ }
+
+ DBusGProxy * newproxy = dbus_g_proxy_new_for_name(server->connection,
+ server->name,
+ _introspector_fullpath[server->introspect_level],
+ DBUS_INTERFACE_INTROSPECTABLE);
+
+ org_freedesktop_DBus_Introspectable_introspect_async(newproxy, introspect_this, server);
+
+ return;
+}
diff --git a/libindicate/listener.h b/libindicate/listener.h
index 0fdaa9b..5bfd298 100644
--- a/libindicate/listener.h
+++ b/libindicate/listener.h
@@ -59,7 +59,12 @@ G_BEGIN_DECLS
#define INDICATE_LISTENER_INDICATOR_ID(indicator) (indicate_listener_indicator_get_id(indicator))
typedef struct _IndicateListenerServer IndicateListenerServer;
+#define INDICATE_TYPE_LISTENER_SERVER (indicate_listener_server_get_gtype ())
+GType indicate_listener_server_get_gtype (void) G_GNUC_CONST;
+
typedef struct _IndicateListenerIndicator IndicateListenerIndicator;
+#define INDICATE_TYPE_LISTENER_INDICATOR (indicate_listener_indicator_get_gtype ())
+GType indicate_listener_indicator_get_gtype (void) G_GNUC_CONST;
typedef struct _IndicateListener IndicateListener;
struct _IndicateListener {
diff --git a/libindicate/server.c b/libindicate/server.c
index e3d071c..d42fe61 100644
--- a/libindicate/server.c
+++ b/libindicate/server.c
@@ -1207,6 +1207,19 @@ _indicate_server_remove_interest (IndicateServer * server, gchar * interest, DBu
return 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 */
void
indicate_server_emit_indicator_added (IndicateServer *server, guint id, const gchar *type)
diff --git a/libindicator/Makefile.am b/libindicator/Makefile.am
new file mode 100644
index 0000000..be68721
--- /dev/null
+++ b/libindicator/Makefile.am
@@ -0,0 +1,14 @@
+EXTRA_DIST = \
+ indicator.pc.in
+
+libindicatorincludedir=$(includedir)/libindicator-0.1/libindicator
+
+indicator_headers = \
+ indicator.h
+
+libindicatorinclude_HEADERS = \
+ $(indicator_headers)
+
+pkgconfig_DATA = indicator.pc
+pkgconfigdir = $(libdir)/pkgconfig
+
diff --git a/libindicator/indicator.h b/libindicator/indicator.h
new file mode 100644
index 0000000..8947f5b
--- /dev/null
+++ b/libindicator/indicator.h
@@ -0,0 +1,34 @@
+
+#ifndef __LIBINDICATOR_INDICATOR_H_SEEN__
+#define __LIBINDICATOR_INDICATOR_H_SEEN__ 1
+
+#include <gtk/gtk.h>
+
+#define INDICATOR_GET_LABEL_S "get_label"
+typedef GtkLabel * (*get_label_t)(void);
+GtkLabel * get_label (void);
+
+#define INDICATOR_GET_ICON_S "get_icon"
+typedef GtkImage * (*get_icon_t) (void);
+GtkImage * get_icon (void);
+
+#define INDICATOR_GET_MENU_S "get_menu"
+typedef GtkMenu * (*get_menu_t) (void);
+GtkMenu * get_menu (void);
+
+#define INDICATOR_GET_VERSION_S "get_version"
+typedef gchar * (*get_version_t) (void);
+gchar * get_version (void);
+
+#define INDICATOR_VERSION "0.2.0"
+#define INDICATOR_SET_VERSION gchar * get_version(void) { return INDICATOR_VERSION; }
+#define INDICATOR_VERSION_CHECK(x) (!g_strcmp0(x, INDICATOR_VERSION))
+
+#define INDICATOR_GET_NAME_S "get_name"
+typedef gchar * (*get_name_t) (void);
+gchar * get_name (void);
+#define INDICATOR_SET_NAME(x) gchar * get_name(void) {return (x); }
+
+
+#endif /* __LIBINDICATOR_INDICATOR_H_SEEN__ */
+
diff --git a/libindicator/indicator.pc.in b/libindicator/indicator.pc.in
new file mode 100644
index 0000000..ba88032
--- /dev/null
+++ b/libindicator/indicator.pc.in
@@ -0,0 +1,16 @@
+prefix=@prefix@
+exec_prefix=@exec_prefix@
+libdir=@libdir@
+bindir=@bindir@
+includedir=@includedir@
+
+indicatordir=${libdir}/indicators/2/
+
+Cflags: -I${includedir}/libindicator-0.1
+Requires: gtk+-2.0
+Libs:
+
+Name: libindicator
+Description: libindicator.
+Version: @VERSION@
+
diff --git a/src/Makefile.am b/src/Makefile.am
index 818bdd9..02b70c1 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -5,7 +5,7 @@ libexec_PROGRAMS = \
indicator_applet_CFLAGS = \
-DG_LOG_DOMAIN=\""Indicator-Applet"\" \
-DDATADIR=\""$(datadir)"\" \
- -DINDICATOR_DIR=\""$(libdir)/indicators/1"\" \
+ -DINDICATOR_DIR=\""$(libdir)/indicators/2"\" \
$(APPLET_CFLAGS)
indicator_applet_SOURCES = \
diff --git a/src/applet-main.c b/src/applet-main.c
index 535a6ae..fca71a7 100644
--- a/src/applet-main.c
+++ b/src/applet-main.c
@@ -24,7 +24,8 @@ with this program. If not, see <http://www.gnu.org/licenses/>.
#include <panel-applet.h>
#include <libgnomeui/gnome-ui-init.h>
-#define SYMBOL_NAME "get_menu_item"
+#include "libindicator/indicator.h"
+
#define ICONS_DIR (DATADIR G_DIR_SEPARATOR_S "indicator-applet" G_DIR_SEPARATOR_S "icons")
static gboolean applet_fill_cb (PanelApplet * applet, const gchar * iid, gpointer data);
@@ -79,14 +80,52 @@ load_module (const gchar * name, GtkWidget * menu)
g_free(fullpath);
g_return_val_if_fail(module != NULL, FALSE);
- GtkWidget * (*make_item)(void);
- g_return_val_if_fail(g_module_symbol(module, SYMBOL_NAME, (gpointer *)(&make_item)), FALSE);
- g_return_val_if_fail(make_item != NULL, FALSE);
+ get_version_t lget_version = NULL;
+ g_return_val_if_fail(g_module_symbol(module, INDICATOR_GET_VERSION_S, (gpointer *)(&lget_version)), FALSE);
+ if (!INDICATOR_VERSION_CHECK(lget_version())) {
+ g_warning("Indicator using API version '%s' we're expecting '%s'", lget_version(), INDICATOR_VERSION);
+ return FALSE;
+ }
+
+ get_label_t lget_label = NULL;
+ g_return_val_if_fail(g_module_symbol(module, INDICATOR_GET_LABEL_S, (gpointer *)(&lget_label)), FALSE);
+ g_return_val_if_fail(lget_label != NULL, FALSE);
+ GtkLabel * label = lget_label();
+
+ get_icon_t lget_icon = NULL;
+ g_return_val_if_fail(g_module_symbol(module, INDICATOR_GET_ICON_S, (gpointer *)(&lget_icon)), FALSE);
+ g_return_val_if_fail(lget_icon != NULL, FALSE);
+ GtkImage * icon = lget_icon();
+
+ get_menu_t lget_menu = NULL;
+ g_return_val_if_fail(g_module_symbol(module, INDICATOR_GET_MENU_S, (gpointer *)(&lget_menu)), FALSE);
+ g_return_val_if_fail(lget_menu != NULL, FALSE);
+ GtkMenu * lmenu = lget_menu();
+
+ if (label == NULL && icon == NULL) {
+ /* This is the case where there is nothing to display,
+ kinda odd that we'd have a module with nothing. */
+ g_warning("No label or icon. Odd.");
+ return FALSE;
+ }
+
+ GtkWidget * menuitem = gtk_menu_item_new();
+ GtkWidget * hbox = gtk_hbox_new(FALSE, 3);
+ if (icon != NULL) {
+ gtk_box_pack_start(GTK_BOX(hbox), GTK_WIDGET(icon), FALSE, FALSE, 0);
+ }
+ if (label != NULL) {
+ gtk_box_pack_start(GTK_BOX(hbox), GTK_WIDGET(label), FALSE, FALSE, 0);
+ }
+ gtk_container_add(GTK_CONTAINER(menuitem), hbox);
+ gtk_widget_show(hbox);
- GtkWidget * menuitem = make_item();
- g_return_val_if_fail(GTK_MENU_ITEM(menuitem), FALSE);
+ if (lmenu != NULL) {
+ gtk_menu_item_set_submenu(GTK_MENU_ITEM(menuitem), GTK_WIDGET(lmenu));
+ }
gtk_menu_shell_append(GTK_MENU_SHELL(menu), menuitem);
+ gtk_widget_show(menuitem);
return TRUE;
}
diff --git a/tests/Makefile.am b/tests/Makefile.am
index 862046e..03bd980 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -1,72 +1,141 @@
+TESTS = \
+ test_simple \
+ test_interests \
+ test_interests_multi \
+ test_thousand_indicators
+
libexec_PROGRAMS = \
- indicate-and-crash \
- indicate-alot \
- listen-and-print \
- im-client \
- show-hide-server
+ test-interests-client \
+ test-interests-server \
+ test-interests-server1 \
+ test-interests-server2 \
+ test-interests-server3 \
+ test-interests-server4 \
+ test-interests-server5 \
+ test-thousand-indicators-client \
+ test-thousand-indicators-server \
+ test-simple-client \
+ test-simple-server
+
+EXTRA_DIST = \
+ $(TESTS)
+
+test_simple: test-simple-client test-simple-server
+
+test_simple_client_SOURCES = \
+ test-simple-client.c
+
+test_simple_client_CFLAGS = \
+ $(LIBINDICATE_CFLAGS) -I$(srcdir)/..
+
+test_simple_client_LDADD = \
+ ../libindicate/libindicate.la \
+ $(LIBINDICATE_LIBS)
-indicate_and_crash_SOURCES = \
- indicate-and-crash.c
+test_simple_server_SOURCES = \
+ test-simple-server.c
-indicate_and_crash_CFLAGS = \
- -I $(srcdir)/.. \
- $(LIBINDICATE_CFLAGS)
+test_simple_server_CFLAGS = \
+ $(LIBINDICATE_CFLAGS) -I$(srcdir)/..
-indicate_and_crash_LDADD = \
+test_simple_server_LDADD = \
../libindicate/libindicate.la \
$(LIBINDICATE_LIBS)
-indicate_alot_SOURCES = \
- indicate-alot.c
+test_interests: test-interests-client test-interests-server
+
+test_interests_client_SOURCES = \
+ test-interests-client.c
+
+test_interests_client_CFLAGS = \
+ $(LIBINDICATE_CFLAGS) -I$(srcdir)/..
+
+test_interests_client_LDADD = \
+ ../libindicate/libindicate.la \
+ $(LIBINDICATE_LIBS)
+
+test_interests_server_SOURCES = \
+ test-interests-server.c
+
+test_interests_server_CFLAGS = \
+ $(LIBINDICATE_CFLAGS) -I$(srcdir)/..
+
+test_interests_server_LDADD = \
+ ../libindicate/libindicate.la \
+ $(LIBINDICATE_LIBS)
+
+test_interests_multi: test-interests-client test-interests-server1 test-interests-server2 test-interests-server3 test-interests-server4 test-interests-server5
+
+test_interests_server1_SOURCES = \
+ test-interests-server1.c
-indicate_alot_CFLAGS = \
- -I $(srcdir)/.. \
- $(LIBINDICATE_CFLAGS)
+test_interests_server1_CFLAGS = \
+ $(LIBINDICATE_CFLAGS) -I$(srcdir)/..
-indicate_alot_LDADD = \
+test_interests_server1_LDADD = \
../libindicate/libindicate.la \
$(LIBINDICATE_LIBS)
-listen_and_print_SOURCES = \
- listen-and-print.c
+test_interests_server2_SOURCES = \
+ test-interests-server2.c
-listen_and_print_CFLAGS = \
- -I $(srcdir)/.. \
- $(LIBINDICATE_CFLAGS)
+test_interests_server2_CFLAGS = \
+ $(LIBINDICATE_CFLAGS) -I$(srcdir)/..
-listen_and_print_LDADD = \
+test_interests_server2_LDADD = \
../libindicate/libindicate.la \
$(LIBINDICATE_LIBS)
-im_client_SOURCES = \
- im-client.c
+test_interests_server3_SOURCES = \
+ test-interests-server3.c
-im_client_CFLAGS = \
- -I $(srcdir)/.. \
- $(LIBINDICATE_CFLAGS)
+test_interests_server3_CFLAGS = \
+ $(LIBINDICATE_CFLAGS) -I$(srcdir)/..
-im_client_LDADD = \
+test_interests_server3_LDADD = \
../libindicate/libindicate.la \
$(LIBINDICATE_LIBS)
-show_hide_server_SOURCES = \
- show-hide-server.c
+test_interests_server4_SOURCES = \
+ test-interests-server4.c
-show_hide_server_CFLAGS = \
- -I $(srcdir)/.. \
- $(LIBINDICATE_CFLAGS)
+test_interests_server4_CFLAGS = \
+ $(LIBINDICATE_CFLAGS) -I$(srcdir)/..
-show_hide_server_LDADD = \
+test_interests_server4_LDADD = \
../libindicate/libindicate.la \
$(LIBINDICATE_LIBS)
-examplesdir = $(docdir)/examples/
+test_interests_server5_SOURCES = \
+ test-interests-server5.c
-examples_DATA = \
- $(indicate_and_crash_SOURCES) \
- $(indicate_alot_SOURCES) \
- $(listen_and_print_SOURCES) \
- $(im_client_SOURCES)
+test_interests_server5_CFLAGS = \
+ $(LIBINDICATE_CFLAGS) -I$(srcdir)/..
+
+test_interests_server5_LDADD = \
+ ../libindicate/libindicate.la \
+ $(LIBINDICATE_LIBS)
+
+test_thousand_indicators: test-thousand-indicators-client test-thousand-indicators-server
+
+test_thousand_indicators_client_SOURCES = \
+ test-thousand-indicators-client.c
+
+test_thousand_indicators_client_CFLAGS = \
+ $(LIBINDICATE_CFLAGS) -I$(srcdir)/..
+
+test_thousand_indicators_client_LDADD = \
+ ../libindicate/libindicate.la \
+ $(LIBINDICATE_LIBS)
+
+test_thousand_indicators_server_SOURCES = \
+ test-thousand-indicators-server.c
+
+test_thousand_indicators_server_CFLAGS = \
+ $(LIBINDICATE_CFLAGS) -I$(srcdir)/..
+
+test_thousand_indicators_server_LDADD = \
+ ../libindicate/libindicate.la \
+ $(LIBINDICATE_LIBS)
-EXTRA_DIST = $(examples_DATA)
diff --git a/tests/test-interests-client.c b/tests/test-interests-client.c
new file mode 100644
index 0000000..bde3b26
--- /dev/null
+++ b/tests/test-interests-client.c
@@ -0,0 +1,63 @@
+
+#include <glib.h>
+#include "libindicate/indicator.h"
+#include "libindicate/server.h"
+#include "libindicate/interests.h"
+
+static gboolean passed = TRUE;
+static GMainLoop * mainloop = NULL;
+static gboolean interests[INDICATE_INTEREST_LAST] = {0};
+
+static gboolean
+check_interests (void)
+{
+ guint i;
+ for (i = INDICATE_INTEREST_NONE + 1; i < INDICATE_INTEREST_LAST; i++) {
+ if (!interests[i]) {
+ return FALSE;
+ }
+ }
+
+ return TRUE;
+}
+
+static void
+interest_added (IndicateServer * server, IndicateInterests interest)
+{
+ g_debug("Oh, someone is interested in my for: %d", interest);
+ interests[interest] = TRUE;
+
+ if (check_interests()) {
+ g_main_loop_quit(mainloop);
+ }
+
+ return;
+}
+
+static gboolean
+done_timeout_cb (gpointer data)
+{
+ g_debug("All interests not set");
+ passed = FALSE;
+ g_main_loop_quit(mainloop);
+ return FALSE;
+}
+
+int
+main (int argc, char * argv)
+{
+ g_type_init();
+
+ IndicateIndicator * indicator = indicate_indicator_new();
+ indicate_indicator_show(indicator);
+
+ IndicateServer * server = indicate_server_ref_default();
+ g_signal_connect(G_OBJECT(server), INDICATE_SERVER_SIGNAL_INTEREST_ADDED, G_CALLBACK(interest_added), NULL);
+
+ g_timeout_add_seconds(2, done_timeout_cb, indicator);
+
+ mainloop = g_main_loop_new(NULL, FALSE);
+ g_main_loop_run(mainloop);
+
+ return !passed;
+}
diff --git a/tests/test-interests-server.c b/tests/test-interests-server.c
new file mode 100644
index 0000000..e1433d8
--- /dev/null
+++ b/tests/test-interests-server.c
@@ -0,0 +1,45 @@
+
+#include <glib.h>
+#include "libindicate/listener.h"
+
+static gboolean passed = TRUE;
+static GMainLoop * mainloop = NULL;
+
+static void
+server_added (IndicateListener * listener, IndicateListenerServer * server, gchar * type, gpointer data)
+{
+ g_debug("Indicator Server Added: %s %s", INDICATE_LISTENER_SERVER_DBUS_NAME(server), type);
+
+ gint i;
+ for (i = INDICATE_INTEREST_NONE - 2; i < INDICATE_INTEREST_LAST + 2; i++) {
+ g_debug("Indicating Interests: %d", i);
+ indicate_listener_server_show_interest(listener, server, i);
+ }
+
+ return;
+}
+
+static gboolean
+failed_cb (gpointer data)
+{
+ g_debug("Done indicatating interest");
+ g_main_loop_quit(mainloop);
+ return FALSE;
+}
+
+int
+main (int argc, char * argv)
+{
+ g_type_init();
+
+ IndicateListener * listener = indicate_listener_ref_default();
+
+ g_signal_connect(listener, INDICATE_LISTENER_SIGNAL_SERVER_ADDED, G_CALLBACK(server_added), NULL);
+
+ g_timeout_add_seconds(2, failed_cb, NULL);
+
+ mainloop = g_main_loop_new(NULL, FALSE);
+ g_main_loop_run(mainloop);
+
+ return !passed;
+}
diff --git a/tests/test-interests-server1.c b/tests/test-interests-server1.c
new file mode 100644
index 0000000..e0d77f3
--- /dev/null
+++ b/tests/test-interests-server1.c
@@ -0,0 +1,41 @@
+
+#include <glib.h>
+#include "libindicate/listener.h"
+
+static gboolean passed = TRUE;
+static GMainLoop * mainloop = NULL;
+
+static void
+server_added (IndicateListener * listener, IndicateListenerServer * server, gchar * type, gpointer data)
+{
+ g_debug("Indicator Server Added: %s %s", INDICATE_LISTENER_SERVER_DBUS_NAME(server), type);
+ #define INTEREST 1
+ g_debug("Setting Interest: %d", INTEREST);
+ indicate_listener_server_show_interest(listener, server, INTEREST);
+ return;
+}
+
+static gboolean
+failed_cb (gpointer data)
+{
+ g_debug("Done indicatating interest");
+ g_main_loop_quit(mainloop);
+ return FALSE;
+}
+
+int
+main (int argc, char * argv)
+{
+ g_type_init();
+
+ IndicateListener * listener = indicate_listener_ref_default();
+
+ g_signal_connect(listener, INDICATE_LISTENER_SIGNAL_SERVER_ADDED, G_CALLBACK(server_added), NULL);
+
+ g_timeout_add_seconds(2, failed_cb, NULL);
+
+ mainloop = g_main_loop_new(NULL, FALSE);
+ g_main_loop_run(mainloop);
+
+ return !passed;
+}
diff --git a/tests/test-interests-server2.c b/tests/test-interests-server2.c
new file mode 100644
index 0000000..0416c21
--- /dev/null
+++ b/tests/test-interests-server2.c
@@ -0,0 +1,41 @@
+
+#include <glib.h>
+#include "libindicate/listener.h"
+
+static gboolean passed = TRUE;
+static GMainLoop * mainloop = NULL;
+
+static void
+server_added (IndicateListener * listener, IndicateListenerServer * server, gchar * type, gpointer data)
+{
+ g_debug("Indicator Server Added: %s %s", INDICATE_LISTENER_SERVER_DBUS_NAME(server), type);
+ #define INTEREST 2
+ g_debug("Setting Interest: %d", INTEREST);
+ indicate_listener_server_show_interest(listener, server, INTEREST);
+ return;
+}
+
+static gboolean
+failed_cb (gpointer data)
+{
+ g_debug("Done indicatating interest");
+ g_main_loop_quit(mainloop);
+ return FALSE;
+}
+
+int
+main (int argc, char * argv)
+{
+ g_type_init();
+
+ IndicateListener * listener = indicate_listener_ref_default();
+
+ g_signal_connect(listener, INDICATE_LISTENER_SIGNAL_SERVER_ADDED, G_CALLBACK(server_added), NULL);
+
+ g_timeout_add_seconds(2, failed_cb, NULL);
+
+ mainloop = g_main_loop_new(NULL, FALSE);
+ g_main_loop_run(mainloop);
+
+ return !passed;
+}
diff --git a/tests/test-interests-server3.c b/tests/test-interests-server3.c
new file mode 100644
index 0000000..7d889b1
--- /dev/null
+++ b/tests/test-interests-server3.c
@@ -0,0 +1,41 @@
+
+#include <glib.h>
+#include "libindicate/listener.h"
+
+static gboolean passed = TRUE;
+static GMainLoop * mainloop = NULL;
+
+static void
+server_added (IndicateListener * listener, IndicateListenerServer * server, gchar * type, gpointer data)
+{
+ g_debug("Indicator Server Added: %s %s", INDICATE_LISTENER_SERVER_DBUS_NAME(server), type);
+ #define INTEREST 3
+ g_debug("Setting Interest: %d", INTEREST);
+ indicate_listener_server_show_interest(listener, server, INTEREST);
+ return;
+}
+
+static gboolean
+failed_cb (gpointer data)
+{
+ g_debug("Done indicatating interest");
+ g_main_loop_quit(mainloop);
+ return FALSE;
+}
+
+int
+main (int argc, char * argv)
+{
+ g_type_init();
+
+ IndicateListener * listener = indicate_listener_ref_default();
+
+ g_signal_connect(listener, INDICATE_LISTENER_SIGNAL_SERVER_ADDED, G_CALLBACK(server_added), NULL);
+
+ g_timeout_add_seconds(2, failed_cb, NULL);
+
+ mainloop = g_main_loop_new(NULL, FALSE);
+ g_main_loop_run(mainloop);
+
+ return !passed;
+}
diff --git a/tests/test-interests-server4.c b/tests/test-interests-server4.c
new file mode 100644
index 0000000..50e6db1
--- /dev/null
+++ b/tests/test-interests-server4.c
@@ -0,0 +1,41 @@
+
+#include <glib.h>
+#include "libindicate/listener.h"
+
+static gboolean passed = TRUE;
+static GMainLoop * mainloop = NULL;
+
+static void
+server_added (IndicateListener * listener, IndicateListenerServer * server, gchar * type, gpointer data)
+{
+ g_debug("Indicator Server Added: %s %s", INDICATE_LISTENER_SERVER_DBUS_NAME(server), type);
+ #define INTEREST 4
+ g_debug("Setting Interest: %d", INTEREST);
+ indicate_listener_server_show_interest(listener, server, INTEREST);
+ return;
+}
+
+static gboolean
+failed_cb (gpointer data)
+{
+ g_debug("Done indicatating interest");
+ g_main_loop_quit(mainloop);
+ return FALSE;
+}
+
+int
+main (int argc, char * argv)
+{
+ g_type_init();
+
+ IndicateListener * listener = indicate_listener_ref_default();
+
+ g_signal_connect(listener, INDICATE_LISTENER_SIGNAL_SERVER_ADDED, G_CALLBACK(server_added), NULL);
+
+ g_timeout_add_seconds(2, failed_cb, NULL);
+
+ mainloop = g_main_loop_new(NULL, FALSE);
+ g_main_loop_run(mainloop);
+
+ return !passed;
+}
diff --git a/tests/test-interests-server5.c b/tests/test-interests-server5.c
new file mode 100644
index 0000000..d415716
--- /dev/null
+++ b/tests/test-interests-server5.c
@@ -0,0 +1,41 @@
+
+#include <glib.h>
+#include "libindicate/listener.h"
+
+static gboolean passed = TRUE;
+static GMainLoop * mainloop = NULL;
+
+static void
+server_added (IndicateListener * listener, IndicateListenerServer * server, gchar * type, gpointer data)
+{
+ g_debug("Indicator Server Added: %s %s", INDICATE_LISTENER_SERVER_DBUS_NAME(server), type);
+ #define INTEREST 5
+ g_debug("Setting Interest: %d", INTEREST);
+ indicate_listener_server_show_interest(listener, server, INTEREST);
+ return;
+}
+
+static gboolean
+failed_cb (gpointer data)
+{
+ g_debug("Done indicatating interest");
+ g_main_loop_quit(mainloop);
+ return FALSE;
+}
+
+int
+main (int argc, char * argv)
+{
+ g_type_init();
+
+ IndicateListener * listener = indicate_listener_ref_default();
+
+ g_signal_connect(listener, INDICATE_LISTENER_SIGNAL_SERVER_ADDED, G_CALLBACK(server_added), NULL);
+
+ g_timeout_add_seconds(2, failed_cb, NULL);
+
+ mainloop = g_main_loop_new(NULL, FALSE);
+ g_main_loop_run(mainloop);
+
+ return !passed;
+}
diff --git a/tests/test-simple-client.c b/tests/test-simple-client.c
new file mode 100644
index 0000000..f8db55a
--- /dev/null
+++ b/tests/test-simple-client.c
@@ -0,0 +1,30 @@
+
+#include <glib.h>
+#include "libindicate/indicator.h"
+
+static gboolean passed = TRUE;
+static GMainLoop * mainloop = NULL;
+
+static gboolean
+done_timeout_cb (gpointer data)
+{
+ g_debug("All done.");
+ g_main_loop_quit(mainloop);
+ return FALSE;
+}
+
+int
+main (int argc, char * argv)
+{
+ g_type_init();
+
+ IndicateIndicator * indicator = indicate_indicator_new();
+ indicate_indicator_show(indicator);
+
+ g_timeout_add_seconds(2, done_timeout_cb, indicator);
+
+ mainloop = g_main_loop_new(NULL, FALSE);
+ g_main_loop_run(mainloop);
+
+ return !passed;
+}
diff --git a/tests/test-simple-server.c b/tests/test-simple-server.c
new file mode 100644
index 0000000..0a04e85
--- /dev/null
+++ b/tests/test-simple-server.c
@@ -0,0 +1,39 @@
+
+#include <glib.h>
+#include "libindicate/listener.h"
+
+static gboolean passed = TRUE;
+static GMainLoop * mainloop = NULL;
+
+static void
+server_added (IndicateListener * listener, IndicateListenerServer * server, gchar * type, gpointer data)
+{
+ g_debug("Indicator Server Added: %s %s", INDICATE_LISTENER_SERVER_DBUS_NAME(server), type);
+ g_main_loop_quit(mainloop);
+}
+
+static gboolean
+failed_cb (gpointer data)
+{
+ g_debug("Failed to get a server in 5 seconds.");
+ passed = FALSE;
+ g_main_loop_quit(mainloop);
+ return FALSE;
+}
+
+int
+main (int argc, char * argv)
+{
+ g_type_init();
+
+ IndicateListener * listener = indicate_listener_ref_default();
+
+ g_signal_connect(listener, INDICATE_LISTENER_SIGNAL_SERVER_ADDED, G_CALLBACK(server_added), NULL);
+
+ g_timeout_add_seconds(5, failed_cb, NULL);
+
+ mainloop = g_main_loop_new(NULL, FALSE);
+ g_main_loop_run(mainloop);
+
+ return !passed;
+}
diff --git a/tests/test-thousand-indicators-client.c b/tests/test-thousand-indicators-client.c
new file mode 100644
index 0000000..0ac7305
--- /dev/null
+++ b/tests/test-thousand-indicators-client.c
@@ -0,0 +1,34 @@
+
+#include <glib.h>
+#include "libindicate/indicator.h"
+
+static gboolean passed = TRUE;
+static GMainLoop * mainloop = NULL;
+
+static gboolean
+done_timeout_cb (gpointer data)
+{
+ g_debug("All done.");
+ g_main_loop_quit(mainloop);
+ return FALSE;
+}
+
+int
+main (int argc, char * argv)
+{
+ g_type_init();
+
+ int i;
+ for (i = 0; i < 1000; i++) {
+ /* Memory leak :) */
+ IndicateIndicator * indicator = indicate_indicator_new();
+ indicate_indicator_show(indicator);
+ }
+
+ g_timeout_add_seconds(2, done_timeout_cb, NULL);
+
+ mainloop = g_main_loop_new(NULL, FALSE);
+ g_main_loop_run(mainloop);
+
+ return !passed;
+}
diff --git a/tests/test-thousand-indicators-server.c b/tests/test-thousand-indicators-server.c
new file mode 100644
index 0000000..285e56b
--- /dev/null
+++ b/tests/test-thousand-indicators-server.c
@@ -0,0 +1,43 @@
+
+#include <glib.h>
+#include "libindicate/listener.h"
+
+static gboolean passed = TRUE;
+static GMainLoop * mainloop = NULL;
+static guint indicator_count = 0;
+
+static void
+indicator_added (IndicateListener * listener, IndicateListenerServer * server, IndicateListenerIndicator * indicator, gchar * type, gpointer data)
+{
+ g_debug("Indicator Added: %s %d %s", INDICATE_LISTENER_SERVER_DBUS_NAME(server), INDICATE_LISTENER_INDICATOR_ID(indicator), type);
+ indicator_count++;
+ if (indicator_count == 1000) {
+ g_main_loop_quit(mainloop);
+ }
+}
+
+static gboolean
+failed_cb (gpointer data)
+{
+ g_debug("Failed to get a server in 5 seconds.");
+ passed = FALSE;
+ g_main_loop_quit(mainloop);
+ return FALSE;
+}
+
+int
+main (int argc, char * argv)
+{
+ g_type_init();
+
+ IndicateListener * listener = indicate_listener_ref_default();
+
+ g_signal_connect(listener, INDICATE_LISTENER_SIGNAL_INDICATOR_ADDED, G_CALLBACK(indicator_added), NULL);
+
+ g_timeout_add_seconds(5, failed_cb, NULL);
+
+ mainloop = g_main_loop_new(NULL, FALSE);
+ g_main_loop_run(mainloop);
+
+ return !passed;
+}
diff --git a/tests/test_interests b/tests/test_interests
new file mode 100755
index 0000000..750a789
--- /dev/null
+++ b/tests/test_interests
@@ -0,0 +1,5 @@
+#!/bin/sh
+
+DBUS_RUNNER="dbus-test-runner --dbus-config /usr/share/dbus-test-runner/session.conf"
+
+${DBUS_RUNNER} --task ./test-interests-client --task-name Client --task ./test-interests-server --task-name Server
diff --git a/tests/test_interests_multi b/tests/test_interests_multi
new file mode 100755
index 0000000..4dbdee8
--- /dev/null
+++ b/tests/test_interests_multi
@@ -0,0 +1,5 @@
+#!/bin/sh
+
+DBUS_RUNNER="dbus-test-runner --dbus-config /usr/share/dbus-test-runner/session.conf"
+
+${DBUS_RUNNER} --task ./test-interests-client --task-name Client --task ./test-interests-server1 --task-name Server1 --task ./test-interests-server2 --task-name Server2 --task ./test-interests-server3 --task-name Server3 --task ./test-interests-server4 --task-name Server4 --task ./test-interests-server5 --task-name Server5
diff --git a/tests/test_simple b/tests/test_simple
new file mode 100755
index 0000000..1b0dc4c
--- /dev/null
+++ b/tests/test_simple
@@ -0,0 +1,5 @@
+#!/bin/sh
+
+DBUS_RUNNER="dbus-test-runner --dbus-config /usr/share/dbus-test-runner/session.conf"
+
+${DBUS_RUNNER} --task ./test-simple-client --task-name Client --task ./test-simple-server --task-name Server
diff --git a/tests/test_thousand_indicators b/tests/test_thousand_indicators
new file mode 100755
index 0000000..fb1079d
--- /dev/null
+++ b/tests/test_thousand_indicators
@@ -0,0 +1,5 @@
+#!/bin/sh
+
+DBUS_RUNNER="dbus-test-runner --dbus-config /usr/share/dbus-test-runner/session.conf"
+
+${DBUS_RUNNER} --task ./test-thousand-indicators-client --task-name Client --task ./test-thousand-indicators-server --task-name Server