Back to index

libindicate  12.10.0
test-interests-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 
00008 static void
00009 server_added (IndicateListener * listener, IndicateListenerServer * server, gchar * type, gpointer data)
00010 {
00011        g_debug("Indicator Server Added:   %s %s", INDICATE_LISTENER_SERVER_DBUS_NAME(server), type);
00012 
00013        gint i;
00014        for (i = INDICATE_INTEREST_NONE - 2; i < INDICATE_INTEREST_LAST + 2; i++) {
00015               g_debug("Indicating Interests: %d", i);
00016               indicate_listener_server_show_interest(listener, server, i);
00017        }
00018 
00019        return;
00020 }
00021 
00022 static gboolean
00023 failed_cb (gpointer data)
00024 {
00025        g_debug("Done indicatating interest");
00026        g_main_loop_quit(mainloop);
00027        return FALSE;
00028 }
00029 
00030 int
00031 main (int argc, char * argv)
00032 {
00033        g_type_init();
00034 
00035        IndicateListener * listener = indicate_listener_ref_default();
00036 
00037        g_signal_connect(listener, INDICATE_LISTENER_SIGNAL_SERVER_ADDED, G_CALLBACK(server_added), NULL);
00038 
00039        g_timeout_add_seconds(2, failed_cb, NULL);
00040 
00041        mainloop = g_main_loop_new(NULL, FALSE);
00042        g_main_loop_run(mainloop);
00043 
00044        return !passed;
00045 }