diff options
Diffstat (limited to 'examples/C')
| -rw-r--r-- | examples/C/glib/add-connection-gdbus.c | 5 | ||||
| -rw-r--r-- | examples/C/glib/add-connection-libnm.c | 6 | ||||
| -rw-r--r-- | examples/C/glib/get-active-connections-gdbus.c | 6 | ||||
| -rw-r--r-- | examples/C/glib/get-ap-info-libnm.c | 11 | ||||
| -rw-r--r-- | examples/C/glib/list-connections-gdbus.c | 5 | ||||
| -rw-r--r-- | examples/C/glib/list-connections-libnm.c | 5 | ||||
| -rw-r--r-- | examples/C/glib/meson.build | 19 | ||||
| -rw-r--r-- | examples/C/glib/monitor-nm-running-gdbus.c | 6 | ||||
| -rw-r--r-- | examples/C/glib/monitor-nm-state-gdbus.c | 6 | ||||
| -rw-r--r-- | examples/C/qt/meson.build | 47 |
10 files changed, 69 insertions, 47 deletions
diff --git a/examples/C/glib/add-connection-gdbus.c b/examples/C/glib/add-connection-gdbus.c index 7c8edf68..1045db38 100644 --- a/examples/C/glib/add-connection-gdbus.c +++ b/examples/C/glib/add-connection-gdbus.c @@ -124,11 +124,6 @@ main (int argc, char *argv[]) GDBusProxy *proxy; GError *error = NULL; -#if !GLIB_CHECK_VERSION (2, 35, 0) - /* Initialize GType system */ - g_type_init (); -#endif - /* Create a D-Bus proxy; NM_DBUS_* defined in nm-dbus-interface.h */ proxy = g_dbus_proxy_new_for_bus_sync (G_BUS_TYPE_SYSTEM, G_DBUS_PROXY_FLAGS_NONE, diff --git a/examples/C/glib/add-connection-libnm.c b/examples/C/glib/add-connection-libnm.c index 86915ea2..e6075352 100644 --- a/examples/C/glib/add-connection-libnm.c +++ b/examples/C/glib/add-connection-libnm.c @@ -97,7 +97,6 @@ add_connection (NMClient *client, GMainLoop *loop, const char *con_name) g_object_unref (connection); } - int main (int argc, char *argv[]) { @@ -105,11 +104,6 @@ main (int argc, char *argv[]) GMainLoop *loop; GError *error = NULL; -#if !GLIB_CHECK_VERSION (2, 35, 0) - /* Initialize GType system */ - g_type_init (); -#endif - loop = g_main_loop_new (NULL, FALSE); /* Connect to NetworkManager */ diff --git a/examples/C/glib/get-active-connections-gdbus.c b/examples/C/glib/get-active-connections-gdbus.c index 217fd7ac..1f3858c9 100644 --- a/examples/C/glib/get-active-connections-gdbus.c +++ b/examples/C/glib/get-active-connections-gdbus.c @@ -245,17 +245,11 @@ out: g_variant_unref (ret); } - int main (int argc, char *argv[]) { GDBusProxy *props_proxy; -#if !GLIB_CHECK_VERSION (2, 35, 0) - /* Initialize GType system */ - g_type_init (); -#endif - /* Create a D-Bus proxy to get the object properties from the NM Manager * object. NM_DBUS_* defines are from nm-dbus-interface.h. */ diff --git a/examples/C/glib/get-ap-info-libnm.c b/examples/C/glib/get-ap-info-libnm.c index a548d12d..c11d4146 100644 --- a/examples/C/glib/get-ap-info-libnm.c +++ b/examples/C/glib/get-ap-info-libnm.c @@ -79,7 +79,7 @@ show_access_point_info (NMAccessPoint *ap) { guint32 flags, wpa_flags, rsn_flags, freq, bitrate; guint8 strength; - GBytes *ssid; + GBytes *ssid; const char *hwaddr; NM80211Mode mode; char *freq_str, *ssid_str, *bitrate_str, *strength_str, *wpa_flags_str, *rsn_flags_str; @@ -158,7 +158,7 @@ show_wifi_device_info (NMDevice *device) const char *iface; const char *driver; guint32 speed; - GBytes *active_ssid; + GBytes *active_ssid; char *active_ssid_str = NULL; int i; @@ -180,7 +180,7 @@ show_wifi_device_info (NMDevice *device) speed /= 1000; printf ("Device: %s ---- Driver: %s ---- Speed: %d Mbit/s ---- Active AP: %s\n", - iface, driver, speed, active_ssid_str ? active_ssid_str : "none"); + iface, driver, speed, active_ssid_str ?: "none"); printf ("=================================================================================\n"); g_free (active_ssid_str); @@ -202,11 +202,6 @@ main (int argc, char *argv[]) int i; GError *error = NULL; -#if !GLIB_CHECK_VERSION (2, 35, 0) - /* Initialize GType system */ - g_type_init (); -#endif - /* Get NMClient object */ client = nm_client_new (NULL, &error); if (!client) { diff --git a/examples/C/glib/list-connections-gdbus.c b/examples/C/glib/list-connections-gdbus.c index 088df1d8..b8e77dc9 100644 --- a/examples/C/glib/list-connections-gdbus.c +++ b/examples/C/glib/list-connections-gdbus.c @@ -65,11 +65,6 @@ main (int argc, char *argv[]) { GDBusProxy *proxy; -#if !GLIB_CHECK_VERSION (2, 35, 0) - /* Initialize GType system */ - g_type_init (); -#endif - /* Create a D-Bus proxy; NM_DBUS_* defined in nm-dbus-interface.h */ proxy = g_dbus_proxy_new_for_bus_sync (G_BUS_TYPE_SYSTEM, G_DBUS_PROXY_FLAGS_NONE, diff --git a/examples/C/glib/list-connections-libnm.c b/examples/C/glib/list-connections-libnm.c index 5dc38201..1b3ed8d1 100644 --- a/examples/C/glib/list-connections-libnm.c +++ b/examples/C/glib/list-connections-libnm.c @@ -69,11 +69,6 @@ main (int argc, char *argv[]) const GPtrArray *connections; int i; -#if !GLIB_CHECK_VERSION (2, 35, 0) - /* Initialize GType system */ - g_type_init (); -#endif - if (!(client = nm_client_new (NULL, &error))) { g_message ("Error: Could not connect to NetworkManager: %s.", error->message); g_error_free (error); diff --git a/examples/C/glib/meson.build b/examples/C/glib/meson.build new file mode 100644 index 00000000..edc4dbb1 --- /dev/null +++ b/examples/C/glib/meson.build @@ -0,0 +1,19 @@ +examples = [ + ['add-connection-gdbus', [libnm_enum[1]], [libnm_inc], [uuid_dep]], + ['add-connection-libnm', [], [], [libnm_dep]], + ['get-active-connections-gdbus', [libnm_enum[1]], [libnm_inc], []], + ['get-ap-info-libnm', [], [], [libnm_dep]], + ['list-connections-gdbus', [], [], []], + ['list-connections-libnm', [], [], [libnm_dep]], + ['monitor-nm-running-gdbus', [], [], []], + ['monitor-nm-state-gdbus', [], [], []] +] + +foreach example: examples + executable( + example[0], + [example[0] + '.c'] + example[1], + include_directories: example[2], + dependencies: [nm_core_dep] + example[3], + ) +endforeach diff --git a/examples/C/glib/monitor-nm-running-gdbus.c b/examples/C/glib/monitor-nm-running-gdbus.c index c19569b5..16e1cfad 100644 --- a/examples/C/glib/monitor-nm-running-gdbus.c +++ b/examples/C/glib/monitor-nm-running-gdbus.c @@ -48,7 +48,6 @@ on_name_vanished (GDBusConnection *connection, g_print ("Name '%s' does not exist on the system bus => NM is not running\n", name); } - int main (int argc, char *argv[]) { @@ -56,11 +55,6 @@ main (int argc, char *argv[]) GMainLoop *loop; GBusNameWatcherFlags flags; -#if !GLIB_CHECK_VERSION (2, 35, 0) - /* Initialize GType system */ - g_type_init (); -#endif - g_print ("Monitor 'org.freedesktop.NetworkManager' D-Bus name\n"); g_print ("===================================================\n"); diff --git a/examples/C/glib/monitor-nm-state-gdbus.c b/examples/C/glib/monitor-nm-state-gdbus.c index 913644d2..fdb4d95d 100644 --- a/examples/C/glib/monitor-nm-state-gdbus.c +++ b/examples/C/glib/monitor-nm-state-gdbus.c @@ -81,7 +81,6 @@ on_signal (GDBusProxy *proxy, } } - int main (int argc, char *argv[]) { @@ -90,11 +89,6 @@ main (int argc, char *argv[]) GDBusProxyFlags flags; GDBusProxy *proxy; -#if !GLIB_CHECK_VERSION (2, 35, 0) - /* Initialize GType system */ - g_type_init (); -#endif - /* Monitor 'StateChanged' signal on 'org.freedesktop.NetworkManager' interface */ g_print ("Monitor NetworkManager's state\n"); g_print ("==============================\n"); diff --git a/examples/C/qt/meson.build b/examples/C/qt/meson.build new file mode 100644 index 00000000..d92205b1 --- /dev/null +++ b/examples/C/qt/meson.build @@ -0,0 +1,47 @@ +examples = [ + ['add-connection-wired', []], + ['list-connections', []], + ['change-ipv4-addresses', []] +] + +incs = [ + top_inc, + libnm_core_inc +] + +qt_core_dep = dependency('QtCore', version: '>= 4') + +deps = [ + dbus_dep, + dbus_glib_dep, + qt_core_dep, + dependency('QtDBus'), + dependency('QtNetwork') +] + +moc = find_program('moc-qt4', required: false) +if not moc.found() + moc = qt_core_dep.get_pkgconfig_variable('moc_location') +endif + +example = 'monitor-nm-running' +output = example + '.moc' + +example_moc = custom_target( + output, + input: example + '.cpp', + output: output, + command: [moc, '-i', '@INPUT@', '-o', '@OUTPUT@'] +) + +examples += [[example, [example_moc]]] + +foreach example: examples + executable( + example[0], + example[0] + '.cpp', + include_directories: incs, + dependencies: deps, + link_depends: example[1] + ) +endforeach |