Back to index

libindicate  12.10.0
test-interests-server2.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        #define INTEREST 2
00013        g_debug("Setting Interest: %d", INTEREST);
00014        indicate_listener_server_show_interest(listener, server, INTEREST);
00015        return;
00016 }
00017 
00018 static gboolean
00019 failed_cb (gpointer data)
00020 {
00021        g_debug("Done indicatating interest");
00022        g_main_loop_quit(mainloop);
00023        return FALSE;
00024 }
00025 
00026 int
00027 main (int argc, char * argv)
00028 {
00029        g_type_init();
00030 
00031        IndicateListener * listener = indicate_listener_ref_default();
00032 
00033        g_signal_connect(listener, INDICATE_LISTENER_SIGNAL_SERVER_ADDED, G_CALLBACK(server_added), NULL);
00034 
00035        g_timeout_add_seconds(2, failed_cb, NULL);
00036 
00037        mainloop = g_main_loop_new(NULL, FALSE);
00038        g_main_loop_run(mainloop);
00039 
00040        return !passed;
00041 }