summaryrefslogtreecommitdiff
path: root/examples
diff options
context:
space:
mode:
authorJiří Klimeš <jklimes@redhat.com>2012-02-14 09:03:21 +0100
committerJiří Klimeš <jklimes@redhat.com>2012-02-14 09:03:21 +0100
commit0b57cc68fd4a146c9fe255f14c667ab306266c0c (patch)
treebfeedc839a52ee574b078153e64301dd74b7574a /examples
parent227f36d3d5667c8d5f26c275d804b9c688db2c6e (diff)
downloadNetworkManager-0b57cc68fd4a146c9fe255f14c667ab306266c0c.tar.gz
examples: fix dependency on GDBus (it's available only in GLib >= 2.26)
Diffstat (limited to 'examples')
-rw-r--r--examples/C/glib/monitor-nm-running-GDBus.c6
-rw-r--r--examples/C/glib/monitor-nm-state-GDBus.c6
2 files changed, 12 insertions, 0 deletions
diff --git a/examples/C/glib/monitor-nm-running-GDBus.c b/examples/C/glib/monitor-nm-running-GDBus.c
index 5cc7232449..42f9b75824 100644
--- a/examples/C/glib/monitor-nm-running-GDBus.c
+++ b/examples/C/glib/monitor-nm-running-GDBus.c
@@ -31,6 +31,7 @@
#include <gio/gio.h>
+#if GLIB_CHECK_VERSION(2,26,0)
static void
on_name_appeared (GDBusConnection *connection,
const gchar *name,
@@ -48,11 +49,13 @@ on_name_vanished (GDBusConnection *connection,
{
g_print ("Name '%s' does not exist on the system bus => NM is not running\n", name);
}
+#endif
int
main (int argc, char *argv[])
{
+#if GLIB_CHECK_VERSION(2,26,0)
guint watcher_id;
GMainLoop *loop;
GBusNameWatcherFlags flags;
@@ -80,6 +83,9 @@ main (int argc, char *argv[])
/* Stop watching the name */
g_bus_unwatch_name (watcher_id);
+#else
+ g_print ("Sorry, you need at least GLib 2.26 for GDBus.\n");
+#endif
return 0;
}
diff --git a/examples/C/glib/monitor-nm-state-GDBus.c b/examples/C/glib/monitor-nm-state-GDBus.c
index a3c5d8e131..22ff65b77a 100644
--- a/examples/C/glib/monitor-nm-state-GDBus.c
+++ b/examples/C/glib/monitor-nm-state-GDBus.c
@@ -34,6 +34,7 @@
#include <string.h>
#include <NetworkManager.h>
+#if GLIB_CHECK_VERSION(2,26,0)
static const char *
nm_state_to_string (NMState state)
{
@@ -81,11 +82,13 @@ on_signal (GDBusProxy *proxy,
g_print ("NetworkManager state is: (%d) %s\n", new_state, nm_state_to_string ((NMState) new_state));
}
}
+#endif
int
main (int argc, char *argv[])
{
+#if GLIB_CHECK_VERSION(2,26,0)
GMainLoop *loop;
GError *error = NULL;
GDBusProxyFlags flags;
@@ -126,6 +129,9 @@ main (int argc, char *argv[])
g_main_loop_run (loop);
g_object_unref (proxy);
+#else
+ g_print ("Sorry, you need at least GLib 2.26 for GDBus.\n");
+#endif
return 0;
}