Back to index

libindicate  12.10.0
test-max-indicators-server.c
Go to the documentation of this file.
00001 
00002 #include <glib.h>
00003 #include "libindicate/listener.h"
00004 #include "test-max-indicators-list.h"
00005 
00006 static gboolean passed = TRUE;
00007 static GMainLoop * mainloop = NULL;
00008 
00009 static guint count = 0;
00010 
00011 static IndicateListener * l = NULL;
00012 static IndicateListenerServer * s = NULL;
00013 
00014 gboolean
00015 set_max (gpointer userdata)
00016 {
00017        g_debug("Setting max indicators to: %d", max_indicator_list[count]);
00018        indicate_listener_set_server_max_indicators(l, s, max_indicator_list[count]);
00019        count++;
00020 
00021        if (count >= MAX_INDICATOR_COUNT) {
00022               return FALSE;
00023        } else {
00024               return TRUE;
00025        }
00026 }
00027 
00028 static void
00029 server_added (IndicateListener * listener, IndicateListenerServer * server, gchar * type, gpointer data)
00030 {
00031        g_debug("Indicator Server Added:   %s %s", INDICATE_LISTENER_SERVER_DBUS_NAME(server), type);
00032 
00033        if (l != NULL || s != NULL) {
00034               g_warning("Adding a second server?  %s", INDICATE_LISTENER_SERVER_DBUS_NAME(server));
00035               return;
00036        }
00037 
00038        l = listener;
00039        s = server;
00040 
00041        g_timeout_add(100, set_max, NULL);
00042 
00043        return;
00044 }
00045 
00046 static gboolean
00047 failed_cb (gpointer data)
00048 {
00049        g_debug("Done indicatating max indicators");
00050        g_main_loop_quit(mainloop);
00051        return FALSE;
00052 }
00053 
00054 int
00055 main (int argc, char * argv)
00056 {
00057        g_type_init();
00058 
00059        IndicateListener * listener = indicate_listener_ref_default();
00060 
00061        g_signal_connect(listener, INDICATE_LISTENER_SIGNAL_SERVER_ADDED, G_CALLBACK(server_added), NULL);
00062 
00063        g_timeout_add((MAX_INDICATOR_COUNT + 4) * 100, failed_cb, NULL);
00064 
00065        mainloop = g_main_loop_new(NULL, FALSE);
00066        g_main_loop_run(mainloop);
00067 
00068        return !passed;
00069 }