Back to index

libindicate  12.10.0
test-thousand-indicators-server.c
Go to the documentation of this file.
00001 
00002 #include <glib.h>
00003 #include "libindicate/listener.h"
00004 
00005 static gboolean passed = TRUE;
00006 static GMainLoop * mainloop = NULL;
00007 static guint indicator_count = 0;
00008 
00009 static void
00010 indicator_added (IndicateListener * listener, IndicateListenerServer * server, IndicateListenerIndicator * indicator, gchar * type, gpointer data)
00011 {
00012        g_debug("Indicator Added:          %s %d %s", INDICATE_LISTENER_SERVER_DBUS_NAME(server), INDICATE_LISTENER_INDICATOR_ID(indicator), type);
00013        indicator_count++;
00014        if (indicator_count == 1000) {
00015               g_main_loop_quit(mainloop);
00016        }
00017 }
00018 
00019 static gboolean
00020 failed_cb (gpointer data)
00021 {
00022        g_debug("Failed to get a server in 5 seconds.");
00023        passed = FALSE;
00024        g_main_loop_quit(mainloop);
00025        return FALSE;
00026 }
00027 
00028 int
00029 main (int argc, char * argv)
00030 {
00031        g_type_init();
00032 
00033        IndicateListener * listener = indicate_listener_ref_default();
00034 
00035        g_signal_connect(listener, INDICATE_LISTENER_SIGNAL_INDICATOR_ADDED, G_CALLBACK(indicator_added), NULL);
00036 
00037        g_timeout_add_seconds(5, failed_cb, NULL);
00038 
00039        mainloop = g_main_loop_new(NULL, FALSE);
00040        g_main_loop_run(mainloop);
00041 
00042        return !passed;
00043 }