Back to index

libindicator  12.10.0
service-version-multiwatch-service.c
Go to the documentation of this file.
00001 /*
00002 Test for libindicator
00003 
00004 Copyright 2009 Canonical Ltd.
00005 
00006 Authors:
00007     Ted Gould <ted@canonical.com>
00008 
00009 This library is free software; you can redistribute it and/or
00010 modify it under the terms of the GNU General Public License
00011 version 3.0 as published by the Free Software Foundation.
00012 
00013 This library is distributed in the hope that it will be useful,
00014 but WITHOUT ANY WARRANTY; without even the implied warranty of
00015 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00016 GNU General Public License version 3.0 for more details.
00017 
00018 You should have received a copy of the GNU General Public
00019 License along with this library. If not, see
00020 <http://www.gnu.org/licenses/>.
00021 */
00022 
00023 
00024 #include <glib.h>
00025 #include "libindicator/indicator-service.h"
00026 #include "service-version-values.h"
00027 
00028 static GMainLoop * mainloop = NULL;
00029 static gboolean passed = FALSE;
00030 
00031 gboolean
00032 timeout (gpointer data)
00033 {
00034        passed = FALSE;
00035        g_debug("Timeout with no shutdown.");
00036        g_main_loop_quit(mainloop);
00037        return FALSE;
00038 }
00039 
00040 void
00041 shutdown (void)
00042 {
00043        g_debug("Shutdown");
00044        passed = TRUE;
00045        g_main_loop_quit(mainloop);
00046        return;
00047 }
00048 
00049 int
00050 main (int argc, char ** argv)
00051 {
00052        g_type_init();
00053        g_debug("Service starting");
00054 
00055        IndicatorService * is = indicator_service_new_version("org.ayatana.version.good", SERVICE_VERSION_GOOD);
00056        g_signal_connect(G_OBJECT(is), INDICATOR_SERVICE_SIGNAL_SHUTDOWN, shutdown, NULL);
00057 
00058        g_timeout_add_seconds(2, timeout, NULL);
00059 
00060        mainloop = g_main_loop_new(NULL, FALSE);
00061        g_main_loop_run(mainloop);
00062 
00063        g_debug("Quiting");
00064        if (passed) {
00065               g_debug("Passed");
00066               return 0;
00067        }
00068        g_debug("Failed");
00069        return 1;
00070 }