Back to index

libindicator  12.10.0
service-version-good-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 static IndicatorService * is = NULL;
00031 
00032 gboolean
00033 timeout (gpointer data)
00034 {
00035        passed = FALSE;
00036        g_debug("Timeout with no shutdown.");
00037 
00038        if (is != NULL) {
00039               g_object_unref(is);
00040               is = NULL;
00041        }
00042 
00043        g_main_loop_quit(mainloop);
00044        return FALSE;
00045 }
00046 
00047 void
00048 shutdown (void)
00049 {
00050        g_debug("Shutdown");
00051        passed = TRUE;
00052 
00053        if (is != NULL) {
00054               g_object_unref(is);
00055               is = NULL;
00056        }
00057 
00058        g_main_loop_quit(mainloop);
00059        return;
00060 }
00061 
00062 int
00063 main (int argc, char ** argv)
00064 {
00065        g_type_init();
00066 
00067        is = indicator_service_new_version("org.ayatana.version.good", SERVICE_VERSION_GOOD);
00068        g_signal_connect(G_OBJECT(is), INDICATOR_SERVICE_SIGNAL_SHUTDOWN, shutdown, NULL);
00069 
00070        g_timeout_add_seconds(1, timeout, NULL);
00071 
00072        mainloop = g_main_loop_new(NULL, FALSE);
00073        g_main_loop_run(mainloop);
00074 
00075        g_debug("Quiting");
00076        if (passed) {
00077               g_debug("Passed");
00078               return 0;
00079        }
00080        g_debug("Failed");
00081        return 1;
00082 }