diff options
Diffstat (limited to 'examples')
46 files changed, 3117 insertions, 168 deletions
diff --git a/examples/C/Makefile.in b/examples/C/Makefile.in index 724e1e098..95754494d 100644 --- a/examples/C/Makefile.in +++ b/examples/C/Makefile.in @@ -81,7 +81,8 @@ host_triplet = @host@ subdir = examples/C DIST_COMMON = $(srcdir)/Makefile.in $(srcdir)/Makefile.am ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 -am__aclocal_m4_deps = $(top_srcdir)/m4/compiler_warnings.m4 \ +am__aclocal_m4_deps = $(top_srcdir)/m4/ax_lib_readline.m4 \ + $(top_srcdir)/m4/compiler_warnings.m4 \ $(top_srcdir)/m4/gettext.m4 \ $(top_srcdir)/m4/gnome-code-coverage.m4 \ $(top_srcdir)/m4/gtk-doc.m4 $(top_srcdir)/m4/iconv.m4 \ @@ -205,12 +206,15 @@ CXXFLAGS = @CXXFLAGS@ CYGPATH_W = @CYGPATH_W@ DATADIRNAME = @DATADIRNAME@ DBUS_CFLAGS = @DBUS_CFLAGS@ +DBUS_GLIB_100_CFLAGS = @DBUS_GLIB_100_CFLAGS@ +DBUS_GLIB_100_LIBS = @DBUS_GLIB_100_LIBS@ DBUS_LIBS = @DBUS_LIBS@ DBUS_SYS_DIR = @DBUS_SYS_DIR@ DEFS = @DEFS@ DEPDIR = @DEPDIR@ DHCLIENT_PATH = @DHCLIENT_PATH@ DHCPCD_PATH = @DHCPCD_PATH@ +DISTRO_NETWORK_SERVICE = @DISTRO_NETWORK_SERVICE@ DLLTOOL = @DLLTOOL@ DNSMASQ_PATH = @DNSMASQ_PATH@ DSYMUTIL = @DSYMUTIL@ @@ -235,7 +239,6 @@ GNUTLS_CFLAGS = @GNUTLS_CFLAGS@ GNUTLS_LIBS = @GNUTLS_LIBS@ GREP = @GREP@ GTKDOC_CHECK = @GTKDOC_CHECK@ -GTKDOC_CHECK_PATH = @GTKDOC_CHECK_PATH@ GTKDOC_DEPS_CFLAGS = @GTKDOC_DEPS_CFLAGS@ GTKDOC_DEPS_LIBS = @GTKDOC_DEPS_LIBS@ GTKDOC_MKPDF = @GTKDOC_MKPDF@ @@ -280,12 +283,16 @@ LIBGCRYPT_LIBS = @LIBGCRYPT_LIBS@ LIBICONV = @LIBICONV@ LIBINTL = @LIBINTL@ LIBM = @LIBM@ +LIBNDP_CFLAGS = @LIBNDP_CFLAGS@ +LIBNDP_LIBS = @LIBNDP_LIBS@ LIBNL_CFLAGS = @LIBNL_CFLAGS@ LIBNL_LIBS = @LIBNL_LIBS@ LIBOBJS = @LIBOBJS@ LIBS = @LIBS@ LIBSOUP_CFLAGS = @LIBSOUP_CFLAGS@ LIBSOUP_LIBS = @LIBSOUP_LIBS@ +LIBTEAMDCTL_CFLAGS = @LIBTEAMDCTL_CFLAGS@ +LIBTEAMDCTL_LIBS = @LIBTEAMDCTL_LIBS@ LIBTOOL = @LIBTOOL@ LIPO = @LIPO@ LN_S = @LN_S@ @@ -302,6 +309,8 @@ MOC = @MOC@ MSGFMT = @MSGFMT@ MSGFMT_015 = @MSGFMT_015@ MSGMERGE = @MSGMERGE@ +NEWT_CFLAGS = @NEWT_CFLAGS@ +NEWT_LIBS = @NEWT_LIBS@ NM = @NM@ NMEDIT = @NMEDIT@ NM_MAJOR_VERSION = @NM_MAJOR_VERSION@ @@ -329,11 +338,16 @@ PKG_CONFIG_PATH = @PKG_CONFIG_PATH@ POLKIT_CFLAGS = @POLKIT_CFLAGS@ POLKIT_LIBS = @POLKIT_LIBS@ POSUB = @POSUB@ +PPPD_PATH = @PPPD_PATH@ PPPD_PLUGIN_DIR = @PPPD_PLUGIN_DIR@ +PPPOE_PATH = @PPPOE_PATH@ QT_CFLAGS = @QT_CFLAGS@ QT_LIBS = @QT_LIBS@ RANLIB = @RANLIB@ +READLINE_LIBS = @READLINE_LIBS@ SED = @SED@ +SELINUX_CFLAGS = @SELINUX_CFLAGS@ +SELINUX_LIBS = @SELINUX_LIBS@ SET_MAKE = @SET_MAKE@ SHELL = @SHELL@ STRIP = @STRIP@ @@ -348,6 +362,7 @@ UDEV_BASE_DIR = @UDEV_BASE_DIR@ USE_NLS = @USE_NLS@ UUID_CFLAGS = @UUID_CFLAGS@ UUID_LIBS = @UUID_LIBS@ +VALGRIND_RULES = @VALGRIND_RULES@ VAPIGEN = @VAPIGEN@ VAPIGEN_MAKEFILE = @VAPIGEN_MAKEFILE@ VAPIGEN_VAPIDIR = @VAPIGEN_VAPIDIR@ @@ -410,6 +425,7 @@ psdir = @psdir@ sbindir = @sbindir@ sharedstatedir = @sharedstatedir@ srcdir = @srcdir@ +subdirs = @subdirs@ sysconfdir = @sysconfdir@ systemdsystemunitdir = @systemdsystemunitdir@ target_alias = @target_alias@ @@ -420,6 +436,7 @@ with_dhclient = @with_dhclient@ with_dhcpcd = @with_dhcpcd@ with_netconfig = @with_netconfig@ with_resolvconf = @with_resolvconf@ +with_valgrind = @with_valgrind@ SUBDIRS = glib $(am__append_1) all: all-recursive diff --git a/examples/C/glib/Makefile.in b/examples/C/glib/Makefile.in index ff7d65a41..e58e66d01 100644 --- a/examples/C/glib/Makefile.in +++ b/examples/C/glib/Makefile.in @@ -91,7 +91,8 @@ subdir = examples/C/glib DIST_COMMON = $(srcdir)/Makefile.in $(srcdir)/Makefile.am \ $(top_srcdir)/build-aux/depcomp ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 -am__aclocal_m4_deps = $(top_srcdir)/m4/compiler_warnings.m4 \ +am__aclocal_m4_deps = $(top_srcdir)/m4/ax_lib_readline.m4 \ + $(top_srcdir)/m4/compiler_warnings.m4 \ $(top_srcdir)/m4/gettext.m4 \ $(top_srcdir)/m4/gnome-code-coverage.m4 \ $(top_srcdir)/m4/gtk-doc.m4 $(top_srcdir)/m4/iconv.m4 \ @@ -274,12 +275,15 @@ CXXFLAGS = @CXXFLAGS@ CYGPATH_W = @CYGPATH_W@ DATADIRNAME = @DATADIRNAME@ DBUS_CFLAGS = @DBUS_CFLAGS@ +DBUS_GLIB_100_CFLAGS = @DBUS_GLIB_100_CFLAGS@ +DBUS_GLIB_100_LIBS = @DBUS_GLIB_100_LIBS@ DBUS_LIBS = @DBUS_LIBS@ DBUS_SYS_DIR = @DBUS_SYS_DIR@ DEFS = @DEFS@ DEPDIR = @DEPDIR@ DHCLIENT_PATH = @DHCLIENT_PATH@ DHCPCD_PATH = @DHCPCD_PATH@ +DISTRO_NETWORK_SERVICE = @DISTRO_NETWORK_SERVICE@ DLLTOOL = @DLLTOOL@ DNSMASQ_PATH = @DNSMASQ_PATH@ DSYMUTIL = @DSYMUTIL@ @@ -304,7 +308,6 @@ GNUTLS_CFLAGS = @GNUTLS_CFLAGS@ GNUTLS_LIBS = @GNUTLS_LIBS@ GREP = @GREP@ GTKDOC_CHECK = @GTKDOC_CHECK@ -GTKDOC_CHECK_PATH = @GTKDOC_CHECK_PATH@ GTKDOC_DEPS_CFLAGS = @GTKDOC_DEPS_CFLAGS@ GTKDOC_DEPS_LIBS = @GTKDOC_DEPS_LIBS@ GTKDOC_MKPDF = @GTKDOC_MKPDF@ @@ -349,12 +352,16 @@ LIBGCRYPT_LIBS = @LIBGCRYPT_LIBS@ LIBICONV = @LIBICONV@ LIBINTL = @LIBINTL@ LIBM = @LIBM@ +LIBNDP_CFLAGS = @LIBNDP_CFLAGS@ +LIBNDP_LIBS = @LIBNDP_LIBS@ LIBNL_CFLAGS = @LIBNL_CFLAGS@ LIBNL_LIBS = @LIBNL_LIBS@ LIBOBJS = @LIBOBJS@ LIBS = @LIBS@ LIBSOUP_CFLAGS = @LIBSOUP_CFLAGS@ LIBSOUP_LIBS = @LIBSOUP_LIBS@ +LIBTEAMDCTL_CFLAGS = @LIBTEAMDCTL_CFLAGS@ +LIBTEAMDCTL_LIBS = @LIBTEAMDCTL_LIBS@ LIBTOOL = @LIBTOOL@ LIPO = @LIPO@ LN_S = @LN_S@ @@ -371,6 +378,8 @@ MOC = @MOC@ MSGFMT = @MSGFMT@ MSGFMT_015 = @MSGFMT_015@ MSGMERGE = @MSGMERGE@ +NEWT_CFLAGS = @NEWT_CFLAGS@ +NEWT_LIBS = @NEWT_LIBS@ NM = @NM@ NMEDIT = @NMEDIT@ NM_MAJOR_VERSION = @NM_MAJOR_VERSION@ @@ -398,11 +407,16 @@ PKG_CONFIG_PATH = @PKG_CONFIG_PATH@ POLKIT_CFLAGS = @POLKIT_CFLAGS@ POLKIT_LIBS = @POLKIT_LIBS@ POSUB = @POSUB@ +PPPD_PATH = @PPPD_PATH@ PPPD_PLUGIN_DIR = @PPPD_PLUGIN_DIR@ +PPPOE_PATH = @PPPOE_PATH@ QT_CFLAGS = @QT_CFLAGS@ QT_LIBS = @QT_LIBS@ RANLIB = @RANLIB@ +READLINE_LIBS = @READLINE_LIBS@ SED = @SED@ +SELINUX_CFLAGS = @SELINUX_CFLAGS@ +SELINUX_LIBS = @SELINUX_LIBS@ SET_MAKE = @SET_MAKE@ SHELL = @SHELL@ STRIP = @STRIP@ @@ -417,6 +431,7 @@ UDEV_BASE_DIR = @UDEV_BASE_DIR@ USE_NLS = @USE_NLS@ UUID_CFLAGS = @UUID_CFLAGS@ UUID_LIBS = @UUID_LIBS@ +VALGRIND_RULES = @VALGRIND_RULES@ VAPIGEN = @VAPIGEN@ VAPIGEN_MAKEFILE = @VAPIGEN_MAKEFILE@ VAPIGEN_VAPIDIR = @VAPIGEN_VAPIDIR@ @@ -479,6 +494,7 @@ psdir = @psdir@ sbindir = @sbindir@ sharedstatedir = @sharedstatedir@ srcdir = @srcdir@ +subdirs = @subdirs@ sysconfdir = @sysconfdir@ systemdsystemunitdir = @systemdsystemunitdir@ target_alias = @target_alias@ @@ -489,6 +505,7 @@ with_dhclient = @with_dhclient@ with_dhcpcd = @with_dhcpcd@ with_netconfig = @with_netconfig@ with_resolvconf = @with_resolvconf@ +with_valgrind = @with_valgrind@ AM_CPPFLAGS = \ -I${top_srcdir}/libnm-util \ -I${top_builddir}/libnm-util \ diff --git a/examples/C/glib/add-connection-dbus-glib.c b/examples/C/glib/add-connection-dbus-glib.c index c7c1a3f11..354dcb75a 100644 --- a/examples/C/glib/add-connection-dbus-glib.c +++ b/examples/C/glib/add-connection-dbus-glib.c @@ -102,8 +102,10 @@ int main (int argc, char *argv[]) DBusGConnection *bus; DBusGProxy *proxy; +#if !GLIB_CHECK_VERSION (2, 35, 0) /* Initialize GType system */ g_type_init (); +#endif /* Get system bus */ bus = dbus_g_bus_get (DBUS_BUS_SYSTEM, NULL); diff --git a/examples/C/glib/add-connection-libnm-glib.c b/examples/C/glib/add-connection-libnm-glib.c index 510e06ee7..28eadf8d3 100644 --- a/examples/C/glib/add-connection-libnm-glib.c +++ b/examples/C/glib/add-connection-libnm-glib.c @@ -110,8 +110,10 @@ int main (int argc, char *argv[]) NMRemoteSettings *settings; GMainLoop *loop; +#if !GLIB_CHECK_VERSION (2, 35, 0) /* Initialize GType system */ g_type_init (); +#endif loop = g_main_loop_new (NULL, FALSE); diff --git a/examples/C/glib/get-active-connections-dbus-glib.c b/examples/C/glib/get-active-connections-dbus-glib.c index f27c44fba..186feae26 100644 --- a/examples/C/glib/get-active-connections-dbus-glib.c +++ b/examples/C/glib/get-active-connections-dbus-glib.c @@ -14,7 +14,7 @@ * with this program; if not, write to the Free Software Foundation, Inc., * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. * - * (C) Copyright 2010 Red Hat, Inc. + * (C) Copyright 2010 -2014 Red Hat, Inc. */ /* @@ -26,6 +26,7 @@ * gcc -Wall `pkg-config --libs --cflags glib-2.0 dbus-glib-1 libnm-util` get-active-connections-dbus-glib.c -o get-active-connections-dbus-glib */ +#include <stdio.h> #include <glib.h> #include <dbus/dbus-glib.h> @@ -41,22 +42,18 @@ #define DBUS_TYPE_G_ARRAY_OF_OBJECT_PATH (dbus_g_type_get_collection ("GPtrArray", DBUS_TYPE_G_OBJECT_PATH)) static void -print_connection (DBusGConnection *bus, const char *service, const char *path) +print_connection (DBusGConnection *bus, const char *path) { DBusGProxy *proxy; GError *error = NULL; GHashTable *hash = NULL; NMConnection *connection = NULL; - /* This function asks the Settings Service that provides this network - * configuration for the details of that configuration. - */ + /* This function asks NetworkManager for the details of the connection */ - /* Create the D-Bus proxy for the Settings Service so we can ask it for the - * connection configuration details. - */ + /* Create the D-Bus proxy so we can ask it for the connection configuration details. */ proxy = dbus_g_proxy_new_for_name (bus, - service, + NM_DBUS_SERVICE, path, NM_DBUS_IFACE_SETTINGS_CONNECTION); g_assert (proxy); @@ -72,9 +69,8 @@ print_connection (DBusGConnection *bus, const char *service, const char *path) goto out; } - /* Using the raw configuration, create an NMConnection object for it. This - * step also verifies that the data we got from the settings service is - * valid. */ + /* Using the raw configuration, create an NMConnection object for it. This + * step also verifies that the data we got from NetworkManager are valid. */ connection = nm_connection_new_from_hash (hash, &error); if (!connection) { g_warning ("Received invalid connection data: %s", error->message); @@ -83,7 +79,7 @@ print_connection (DBusGConnection *bus, const char *service, const char *path) } /* And finally dump all the configuration to stdout */ - g_message ("%s => %s", service, path); + printf ("%s <=> %s\n", nm_connection_get_id (connection), path); nm_connection_dump (connection); out: @@ -98,10 +94,9 @@ static void get_active_connection_details (DBusGConnection *bus, const char *obj_path) { DBusGProxy *props_proxy; - GValue path_value = { 0 }; - GValue serv_value = { 0 }; + GValue path_value = G_VALUE_INIT; GError *error = NULL; - const char *path = NULL, *service = NULL; + const char *path = NULL; /* This function gets the backing Connection object that describes the * network configuration that the ActiveConnection object is actually using. @@ -141,37 +136,11 @@ get_active_connection_details (DBusGConnection *bus, const char *obj_path) goto out; } - /* Get the service name of the D-Bus service that provides the Connection */ - if (!dbus_g_proxy_call (props_proxy, "Get", &error, - G_TYPE_STRING, NM_DBUS_INTERFACE_ACTIVE_CONNECTION, - G_TYPE_STRING, "ServiceName", - G_TYPE_INVALID, - G_TYPE_VALUE, &serv_value, - G_TYPE_INVALID)) { - g_warning ("Failed to get active connection ServiceName property: %s", - error->message); - g_error_free (error); - goto out; - } - - if (!G_VALUE_HOLDS (&serv_value, G_TYPE_STRING)) { - g_warning ("Unexpected type returned getting Connection property: %s", - G_VALUE_TYPE_NAME (&serv_value)); - goto out; - } - - service = g_value_get_string (&serv_value); - if (!service) { - g_warning ("Missing connection service name!"); - goto out; - } - /* Print out the actual connection details */ - print_connection (bus, service, path); + print_connection (bus, path); out: g_value_unset (&path_value); - g_value_unset (&serv_value); g_object_unref (props_proxy); } @@ -179,8 +148,9 @@ static void get_active_connections (DBusGConnection *bus, DBusGProxy *proxy) { GError *error = NULL; - GValue value = { 0 }; + GValue value = G_VALUE_INIT; GPtrArray *paths = NULL; + const char *a_path; int i; /* Get the ActiveConnections property from the NM Manager object */ @@ -209,9 +179,12 @@ get_active_connections (DBusGConnection *bus, DBusGProxy *proxy) goto out; } - /* And print out the details of each active connection */ - for (i = 0; i < paths->len; i++) - get_active_connection_details (bus, g_ptr_array_index (paths, i)); + /* And print out the details for each active connection */ + for (i = 0; i < paths->len; i++) { + a_path = g_ptr_array_index (paths, i); + printf ("Active connection path: %s\n", a_path); + get_active_connection_details (bus, a_path); + } out: g_value_unset (&value); @@ -223,8 +196,10 @@ int main (int argc, char *argv[]) DBusGConnection *bus; DBusGProxy *props_proxy; +#if !GLIB_CHECK_VERSION (2, 35, 0) /* Initialize GType system */ g_type_init (); +#endif /* Get system bus */ bus = dbus_g_bus_get (DBUS_BUS_SYSTEM, NULL); diff --git a/examples/C/glib/get-ap-info-libnm-glib.c b/examples/C/glib/get-ap-info-libnm-glib.c index e72ce54fa..1ad58124b 100644 --- a/examples/C/glib/get-ap-info-libnm-glib.c +++ b/examples/C/glib/get-ap-info-libnm-glib.c @@ -96,7 +96,7 @@ show_access_point_info (NMAccessPoint *ap) wpa_flags = nm_access_point_get_wpa_flags (ap); rsn_flags = nm_access_point_get_rsn_flags (ap); ssid = nm_access_point_get_ssid (ap); - hwaddr = nm_access_point_get_hw_address (ap); + hwaddr = nm_access_point_get_bssid (ap); freq = nm_access_point_get_frequency (ap); mode = nm_access_point_get_mode (ap); bitrate = nm_access_point_get_max_bitrate (ap); @@ -105,7 +105,7 @@ show_access_point_info (NMAccessPoint *ap) /* Convert to strings */ ssid_str = nm_utils_ssid_to_utf8 (ssid); freq_str = g_strdup_printf ("%u MHz", freq); - bitrate_str = g_strdup_printf ("%u MB/s", bitrate/1000); + bitrate_str = g_strdup_printf ("%u Mbit/s", bitrate/1000); strength_str = g_strdup_printf ("%u", strength); wpa_flags_str = ap_wpa_rsn_flags_to_string (wpa_flags); rsn_flags_str = ap_wpa_rsn_flags_to_string (rsn_flags); @@ -178,7 +178,7 @@ show_wifi_device_info (NMDevice *device) speed = nm_device_wifi_get_bitrate (NM_DEVICE_WIFI (device)); speed /= 1000; - printf ("Device: %s ---- Driver: %s ---- Speed: %d MB/s ---- Active AP: %s\n", + printf ("Device: %s ---- Driver: %s ---- Speed: %d Mbit/s ---- Active AP: %s\n", iface, driver, speed, active_ssid_str ? active_ssid_str : "none"); printf ("=================================================================================\n"); g_free (active_ssid_str); @@ -200,8 +200,10 @@ int main (int argc, char *argv[]) const GPtrArray *devices; int i; +#if !GLIB_CHECK_VERSION (2, 35, 0) /* Initialize GType system */ g_type_init (); +#endif /* Get system bus */ bus = dbus_g_bus_get (DBUS_BUS_SYSTEM, NULL); diff --git a/examples/C/glib/list-connections-dbus-glib.c b/examples/C/glib/list-connections-dbus-glib.c index 2cb584b59..e17b8dc7d 100644 --- a/examples/C/glib/list-connections-dbus-glib.c +++ b/examples/C/glib/list-connections-dbus-glib.c @@ -40,13 +40,19 @@ list_connections (DBusGProxy *proxy) int i; GError *error = NULL; GPtrArray *con_array; + gboolean success; /* Call ListConnections D-Bus method */ - dbus_g_proxy_call (proxy, "ListConnections", &error, - /* No input arguments */ - G_TYPE_INVALID, - DBUS_TYPE_G_ARRAY_OF_OBJECT_PATH, &con_array, /* Return values */ - G_TYPE_INVALID); + success = dbus_g_proxy_call (proxy, "ListConnections", &error, + /* No input arguments */ + G_TYPE_INVALID, + DBUS_TYPE_G_ARRAY_OF_OBJECT_PATH, &con_array, /* Return values */ + G_TYPE_INVALID); + if (!success) { + printf ("ListConnections failed: %s", error->message); + g_error_free (error); + return; + } for (i = 0; con_array && i < con_array->len; i++) { char *connection_path = g_ptr_array_index (con_array, i); @@ -61,8 +67,10 @@ int main (int argc, char *argv[]) DBusGConnection *bus; DBusGProxy *proxy; +#if !GLIB_CHECK_VERSION (2, 35, 0) /* Initialize GType system */ g_type_init (); +#endif /* Get system bus */ bus = dbus_g_bus_get (DBUS_BUS_SYSTEM, NULL); diff --git a/examples/C/glib/list-connections-libnm-glib.c b/examples/C/glib/list-connections-libnm-glib.c index 01a9f254e..29f105c60 100644 --- a/examples/C/glib/list-connections-libnm-glib.c +++ b/examples/C/glib/list-connections-libnm-glib.c @@ -67,7 +67,7 @@ setup_signals (void) /* Print details of connection */ static void -show_connection (NMConnection *data, gpointer user_data) +show_connection (gpointer data, gpointer user_data) { NMConnection *connection = (NMConnection *) data; NMSettingConnection *s_con; @@ -107,7 +107,7 @@ get_connections_cb (NMRemoteSettings *settings, gpointer user_data) printf ("Connections:\n===================\n"); - g_slist_foreach (connections, (GFunc) show_connection, NULL); + g_slist_foreach (connections, show_connection, NULL); g_slist_free (connections); g_object_unref (settings); @@ -153,8 +153,10 @@ int main (int argc, char *argv[]) { DBusGConnection *bus; +#if !GLIB_CHECK_VERSION (2, 35, 0) /* Initialize GType system */ g_type_init (); +#endif /* Get system bus */ bus = dbus_g_bus_get (DBUS_BUS_SYSTEM, NULL); diff --git a/examples/C/glib/monitor-nm-running-GDBus.c b/examples/C/glib/monitor-nm-running-GDBus.c index 42f9b7582..9e38d4c70 100644 --- a/examples/C/glib/monitor-nm-running-GDBus.c +++ b/examples/C/glib/monitor-nm-running-GDBus.c @@ -31,7 +31,6 @@ #include <gio/gio.h> -#if GLIB_CHECK_VERSION(2,26,0) static void on_name_appeared (GDBusConnection *connection, const gchar *name, @@ -49,19 +48,19 @@ 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; +#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"); @@ -83,9 +82,6 @@ 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-running-dbus-glib.c b/examples/C/glib/monitor-nm-running-dbus-glib.c index 3290fb1ac..0b01a57f0 100644 --- a/examples/C/glib/monitor-nm-running-dbus-glib.c +++ b/examples/C/glib/monitor-nm-running-dbus-glib.c @@ -71,8 +71,10 @@ main (int argc, char *argv[]) GError *err = NULL; gboolean nm_running; +#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 22ff65b77..f40197253 100644 --- a/examples/C/glib/monitor-nm-state-GDBus.c +++ b/examples/C/glib/monitor-nm-state-GDBus.c @@ -34,7 +34,6 @@ #include <string.h> #include <NetworkManager.h> -#if GLIB_CHECK_VERSION(2,26,0) static const char * nm_state_to_string (NMState state) { @@ -82,20 +81,20 @@ 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; 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"); @@ -129,9 +128,6 @@ 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; } diff --git a/examples/C/qt/Makefile.in b/examples/C/qt/Makefile.in index 9ef5fea6f..6cce98839 100644 --- a/examples/C/qt/Makefile.in +++ b/examples/C/qt/Makefile.in @@ -85,7 +85,8 @@ subdir = examples/C/qt DIST_COMMON = $(srcdir)/Makefile.in $(srcdir)/Makefile.am \ $(top_srcdir)/build-aux/depcomp ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 -am__aclocal_m4_deps = $(top_srcdir)/m4/compiler_warnings.m4 \ +am__aclocal_m4_deps = $(top_srcdir)/m4/ax_lib_readline.m4 \ + $(top_srcdir)/m4/compiler_warnings.m4 \ $(top_srcdir)/m4/gettext.m4 \ $(top_srcdir)/m4/gnome-code-coverage.m4 \ $(top_srcdir)/m4/gtk-doc.m4 $(top_srcdir)/m4/iconv.m4 \ @@ -215,12 +216,15 @@ CXXFLAGS = @CXXFLAGS@ CYGPATH_W = @CYGPATH_W@ DATADIRNAME = @DATADIRNAME@ DBUS_CFLAGS = @DBUS_CFLAGS@ +DBUS_GLIB_100_CFLAGS = @DBUS_GLIB_100_CFLAGS@ +DBUS_GLIB_100_LIBS = @DBUS_GLIB_100_LIBS@ DBUS_LIBS = @DBUS_LIBS@ DBUS_SYS_DIR = @DBUS_SYS_DIR@ DEFS = @DEFS@ DEPDIR = @DEPDIR@ DHCLIENT_PATH = @DHCLIENT_PATH@ DHCPCD_PATH = @DHCPCD_PATH@ +DISTRO_NETWORK_SERVICE = @DISTRO_NETWORK_SERVICE@ DLLTOOL = @DLLTOOL@ DNSMASQ_PATH = @DNSMASQ_PATH@ DSYMUTIL = @DSYMUTIL@ @@ -245,7 +249,6 @@ GNUTLS_CFLAGS = @GNUTLS_CFLAGS@ GNUTLS_LIBS = @GNUTLS_LIBS@ GREP = @GREP@ GTKDOC_CHECK = @GTKDOC_CHECK@ -GTKDOC_CHECK_PATH = @GTKDOC_CHECK_PATH@ GTKDOC_DEPS_CFLAGS = @GTKDOC_DEPS_CFLAGS@ GTKDOC_DEPS_LIBS = @GTKDOC_DEPS_LIBS@ GTKDOC_MKPDF = @GTKDOC_MKPDF@ @@ -290,12 +293,16 @@ LIBGCRYPT_LIBS = @LIBGCRYPT_LIBS@ LIBICONV = @LIBICONV@ LIBINTL = @LIBINTL@ LIBM = @LIBM@ +LIBNDP_CFLAGS = @LIBNDP_CFLAGS@ +LIBNDP_LIBS = @LIBNDP_LIBS@ LIBNL_CFLAGS = @LIBNL_CFLAGS@ LIBNL_LIBS = @LIBNL_LIBS@ LIBOBJS = @LIBOBJS@ LIBS = @LIBS@ LIBSOUP_CFLAGS = @LIBSOUP_CFLAGS@ LIBSOUP_LIBS = @LIBSOUP_LIBS@ +LIBTEAMDCTL_CFLAGS = @LIBTEAMDCTL_CFLAGS@ +LIBTEAMDCTL_LIBS = @LIBTEAMDCTL_LIBS@ LIBTOOL = @LIBTOOL@ LIPO = @LIPO@ LN_S = @LN_S@ @@ -312,6 +319,8 @@ MOC = @MOC@ MSGFMT = @MSGFMT@ MSGFMT_015 = @MSGFMT_015@ MSGMERGE = @MSGMERGE@ +NEWT_CFLAGS = @NEWT_CFLAGS@ +NEWT_LIBS = @NEWT_LIBS@ NM = @NM@ NMEDIT = @NMEDIT@ NM_MAJOR_VERSION = @NM_MAJOR_VERSION@ @@ -339,11 +348,16 @@ PKG_CONFIG_PATH = @PKG_CONFIG_PATH@ POLKIT_CFLAGS = @POLKIT_CFLAGS@ POLKIT_LIBS = @POLKIT_LIBS@ POSUB = @POSUB@ +PPPD_PATH = @PPPD_PATH@ PPPD_PLUGIN_DIR = @PPPD_PLUGIN_DIR@ +PPPOE_PATH = @PPPOE_PATH@ QT_CFLAGS = @QT_CFLAGS@ QT_LIBS = @QT_LIBS@ RANLIB = @RANLIB@ +READLINE_LIBS = @READLINE_LIBS@ SED = @SED@ +SELINUX_CFLAGS = @SELINUX_CFLAGS@ +SELINUX_LIBS = @SELINUX_LIBS@ SET_MAKE = @SET_MAKE@ SHELL = @SHELL@ STRIP = @STRIP@ @@ -358,6 +372,7 @@ UDEV_BASE_DIR = @UDEV_BASE_DIR@ USE_NLS = @USE_NLS@ UUID_CFLAGS = @UUID_CFLAGS@ UUID_LIBS = @UUID_LIBS@ +VALGRIND_RULES = @VALGRIND_RULES@ VAPIGEN = @VAPIGEN@ VAPIGEN_MAKEFILE = @VAPIGEN_MAKEFILE@ VAPIGEN_VAPIDIR = @VAPIGEN_VAPIDIR@ @@ -420,6 +435,7 @@ psdir = @psdir@ sbindir = @sbindir@ sharedstatedir = @sharedstatedir@ srcdir = @srcdir@ +subdirs = @subdirs@ sysconfdir = @sysconfdir@ systemdsystemunitdir = @systemdsystemunitdir@ target_alias = @target_alias@ @@ -430,6 +446,7 @@ with_dhclient = @with_dhclient@ with_dhcpcd = @with_dhcpcd@ with_netconfig = @with_netconfig@ with_resolvconf = @with_resolvconf@ +with_valgrind = @with_valgrind@ AM_CPPFLAGS = \ -I${top_srcdir}/include \ -I${top_builddir}/include \ diff --git a/examples/C/qt/monitor-nm-running.cpp b/examples/C/qt/monitor-nm-running.cpp index 861f251e0..cf597b541 100644 --- a/examples/C/qt/monitor-nm-running.cpp +++ b/examples/C/qt/monitor-nm-running.cpp @@ -51,13 +51,13 @@ class NMWatcher: public QObject { void NMWatcher::serviceRegistered(const QString& name) { - std::cout << "Name '" << name.toStdString() << "' registered" + std::cout << "Name '" << name.toUtf8().constData() << "' registered" << " => NM is running" << std::endl; } void NMWatcher::serviceUnregistered(const QString& name) { - std::cout << "Name '" << name.toStdString() << "' unregistered" + std::cout << "Name '" << name.toUtf8().constData() << "' unregistered" << " => NM is not running" << std::endl; } diff --git a/examples/Makefile.in b/examples/Makefile.in index 22bf9efb4..8a27af4f3 100644 --- a/examples/Makefile.in +++ b/examples/Makefile.in @@ -80,7 +80,8 @@ host_triplet = @host@ subdir = examples DIST_COMMON = $(srcdir)/Makefile.in $(srcdir)/Makefile.am ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 -am__aclocal_m4_deps = $(top_srcdir)/m4/compiler_warnings.m4 \ +am__aclocal_m4_deps = $(top_srcdir)/m4/ax_lib_readline.m4 \ + $(top_srcdir)/m4/compiler_warnings.m4 \ $(top_srcdir)/m4/gettext.m4 \ $(top_srcdir)/m4/gnome-code-coverage.m4 \ $(top_srcdir)/m4/gtk-doc.m4 $(top_srcdir)/m4/iconv.m4 \ @@ -204,12 +205,15 @@ CXXFLAGS = @CXXFLAGS@ CYGPATH_W = @CYGPATH_W@ DATADIRNAME = @DATADIRNAME@ DBUS_CFLAGS = @DBUS_CFLAGS@ +DBUS_GLIB_100_CFLAGS = @DBUS_GLIB_100_CFLAGS@ +DBUS_GLIB_100_LIBS = @DBUS_GLIB_100_LIBS@ DBUS_LIBS = @DBUS_LIBS@ DBUS_SYS_DIR = @DBUS_SYS_DIR@ DEFS = @DEFS@ DEPDIR = @DEPDIR@ DHCLIENT_PATH = @DHCLIENT_PATH@ DHCPCD_PATH = @DHCPCD_PATH@ +DISTRO_NETWORK_SERVICE = @DISTRO_NETWORK_SERVICE@ DLLTOOL = @DLLTOOL@ DNSMASQ_PATH = @DNSMASQ_PATH@ DSYMUTIL = @DSYMUTIL@ @@ -234,7 +238,6 @@ GNUTLS_CFLAGS = @GNUTLS_CFLAGS@ GNUTLS_LIBS = @GNUTLS_LIBS@ GREP = @GREP@ GTKDOC_CHECK = @GTKDOC_CHECK@ -GTKDOC_CHECK_PATH = @GTKDOC_CHECK_PATH@ GTKDOC_DEPS_CFLAGS = @GTKDOC_DEPS_CFLAGS@ GTKDOC_DEPS_LIBS = @GTKDOC_DEPS_LIBS@ GTKDOC_MKPDF = @GTKDOC_MKPDF@ @@ -279,12 +282,16 @@ LIBGCRYPT_LIBS = @LIBGCRYPT_LIBS@ LIBICONV = @LIBICONV@ LIBINTL = @LIBINTL@ LIBM = @LIBM@ +LIBNDP_CFLAGS = @LIBNDP_CFLAGS@ +LIBNDP_LIBS = @LIBNDP_LIBS@ LIBNL_CFLAGS = @LIBNL_CFLAGS@ LIBNL_LIBS = @LIBNL_LIBS@ LIBOBJS = @LIBOBJS@ LIBS = @LIBS@ LIBSOUP_CFLAGS = @LIBSOUP_CFLAGS@ LIBSOUP_LIBS = @LIBSOUP_LIBS@ +LIBTEAMDCTL_CFLAGS = @LIBTEAMDCTL_CFLAGS@ +LIBTEAMDCTL_LIBS = @LIBTEAMDCTL_LIBS@ LIBTOOL = @LIBTOOL@ LIPO = @LIPO@ LN_S = @LN_S@ @@ -301,6 +308,8 @@ MOC = @MOC@ MSGFMT = @MSGFMT@ MSGFMT_015 = @MSGFMT_015@ MSGMERGE = @MSGMERGE@ +NEWT_CFLAGS = @NEWT_CFLAGS@ +NEWT_LIBS = @NEWT_LIBS@ NM = @NM@ NMEDIT = @NMEDIT@ NM_MAJOR_VERSION = @NM_MAJOR_VERSION@ @@ -328,11 +337,16 @@ PKG_CONFIG_PATH = @PKG_CONFIG_PATH@ POLKIT_CFLAGS = @POLKIT_CFLAGS@ POLKIT_LIBS = @POLKIT_LIBS@ POSUB = @POSUB@ +PPPD_PATH = @PPPD_PATH@ PPPD_PLUGIN_DIR = @PPPD_PLUGIN_DIR@ +PPPOE_PATH = @PPPOE_PATH@ QT_CFLAGS = @QT_CFLAGS@ QT_LIBS = @QT_LIBS@ RANLIB = @RANLIB@ +READLINE_LIBS = @READLINE_LIBS@ SED = @SED@ +SELINUX_CFLAGS = @SELINUX_CFLAGS@ +SELINUX_LIBS = @SELINUX_LIBS@ SET_MAKE = @SET_MAKE@ SHELL = @SHELL@ STRIP = @STRIP@ @@ -347,6 +361,7 @@ UDEV_BASE_DIR = @UDEV_BASE_DIR@ USE_NLS = @USE_NLS@ UUID_CFLAGS = @UUID_CFLAGS@ UUID_LIBS = @UUID_LIBS@ +VALGRIND_RULES = @VALGRIND_RULES@ VAPIGEN = @VAPIGEN@ VAPIGEN_MAKEFILE = @VAPIGEN_MAKEFILE@ VAPIGEN_VAPIDIR = @VAPIGEN_VAPIDIR@ @@ -409,6 +424,7 @@ psdir = @psdir@ sbindir = @sbindir@ sharedstatedir = @sharedstatedir@ srcdir = @srcdir@ +subdirs = @subdirs@ sysconfdir = @sysconfdir@ systemdsystemunitdir = @systemdsystemunitdir@ target_alias = @target_alias@ @@ -419,6 +435,7 @@ with_dhclient = @with_dhclient@ with_dhcpcd = @with_dhcpcd@ with_netconfig = @with_netconfig@ with_resolvconf = @with_resolvconf@ +with_valgrind = @with_valgrind@ SUBDIRS = \ shell \ python \ diff --git a/examples/dispatcher/70-wifi-wired-exclusive.sh b/examples/dispatcher/70-wifi-wired-exclusive.sh index 501f159ef..676695f44 100755 --- a/examples/dispatcher/70-wifi-wired-exclusive.sh +++ b/examples/dispatcher/70-wifi-wired-exclusive.sh @@ -1,26 +1,17 @@ #!/bin/bash -export LC_ALL=C - # This dispatcher script makes WiFi mutually exclusive with # wired networking. When a wired interface is connected, # WiFi will be set to airplane mode (rfkilled). When the wired # interface is disconnected, WiFi will be turned back on. +# +# Copyright 2012 Johannes Buchner <buchner.johannes@gmx.at> +# Copyright 2012 - 2014 Red Hat, Inc. +# -enable_disable_wifi () -{ - result=$(nmcli dev | grep "802-3-ethernet" | grep -w "connected") - if [ -n "$result" ]; then - nmcli nm wifi off - else - nmcli nm wifi on - fi -} - -if [ "$2" = "up" ]; then - enable_disable_wifi -fi - -if [ "$2" = "down" ]; then - enable_disable_wifi +export LC_ALL=C +if nmcli -t --fields type,state dev | grep -E "ethernet:connected" -q; then + nmcli radio wifi off +else + nmcli radio wifi on fi diff --git a/examples/dispatcher/Makefile.in b/examples/dispatcher/Makefile.in index 7325da6b8..d577fde10 100644 --- a/examples/dispatcher/Makefile.in +++ b/examples/dispatcher/Makefile.in @@ -80,7 +80,8 @@ host_triplet = @host@ subdir = examples/dispatcher DIST_COMMON = $(srcdir)/Makefile.in $(srcdir)/Makefile.am ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 -am__aclocal_m4_deps = $(top_srcdir)/m4/compiler_warnings.m4 \ +am__aclocal_m4_deps = $(top_srcdir)/m4/ax_lib_readline.m4 \ + $(top_srcdir)/m4/compiler_warnings.m4 \ $(top_srcdir)/m4/gettext.m4 \ $(top_srcdir)/m4/gnome-code-coverage.m4 \ $(top_srcdir)/m4/gtk-doc.m4 $(top_srcdir)/m4/iconv.m4 \ @@ -144,12 +145,15 @@ CXXFLAGS = @CXXFLAGS@ CYGPATH_W = @CYGPATH_W@ DATADIRNAME = @DATADIRNAME@ DBUS_CFLAGS = @DBUS_CFLAGS@ +DBUS_GLIB_100_CFLAGS = @DBUS_GLIB_100_CFLAGS@ +DBUS_GLIB_100_LIBS = @DBUS_GLIB_100_LIBS@ DBUS_LIBS = @DBUS_LIBS@ DBUS_SYS_DIR = @DBUS_SYS_DIR@ DEFS = @DEFS@ DEPDIR = @DEPDIR@ DHCLIENT_PATH = @DHCLIENT_PATH@ DHCPCD_PATH = @DHCPCD_PATH@ +DISTRO_NETWORK_SERVICE = @DISTRO_NETWORK_SERVICE@ DLLTOOL = @DLLTOOL@ DNSMASQ_PATH = @DNSMASQ_PATH@ DSYMUTIL = @DSYMUTIL@ @@ -174,7 +178,6 @@ GNUTLS_CFLAGS = @GNUTLS_CFLAGS@ GNUTLS_LIBS = @GNUTLS_LIBS@ GREP = @GREP@ GTKDOC_CHECK = @GTKDOC_CHECK@ -GTKDOC_CHECK_PATH = @GTKDOC_CHECK_PATH@ GTKDOC_DEPS_CFLAGS = @GTKDOC_DEPS_CFLAGS@ GTKDOC_DEPS_LIBS = @GTKDOC_DEPS_LIBS@ GTKDOC_MKPDF = @GTKDOC_MKPDF@ @@ -219,12 +222,16 @@ LIBGCRYPT_LIBS = @LIBGCRYPT_LIBS@ LIBICONV = @LIBICONV@ LIBINTL = @LIBINTL@ LIBM = @LIBM@ +LIBNDP_CFLAGS = @LIBNDP_CFLAGS@ +LIBNDP_LIBS = @LIBNDP_LIBS@ LIBNL_CFLAGS = @LIBNL_CFLAGS@ LIBNL_LIBS = @LIBNL_LIBS@ LIBOBJS = @LIBOBJS@ LIBS = @LIBS@ LIBSOUP_CFLAGS = @LIBSOUP_CFLAGS@ LIBSOUP_LIBS = @LIBSOUP_LIBS@ +LIBTEAMDCTL_CFLAGS = @LIBTEAMDCTL_CFLAGS@ +LIBTEAMDCTL_LIBS = @LIBTEAMDCTL_LIBS@ LIBTOOL = @LIBTOOL@ LIPO = @LIPO@ LN_S = @LN_S@ @@ -241,6 +248,8 @@ MOC = @MOC@ MSGFMT = @MSGFMT@ MSGFMT_015 = @MSGFMT_015@ MSGMERGE = @MSGMERGE@ +NEWT_CFLAGS = @NEWT_CFLAGS@ +NEWT_LIBS = @NEWT_LIBS@ NM = @NM@ NMEDIT = @NMEDIT@ NM_MAJOR_VERSION = @NM_MAJOR_VERSION@ @@ -268,11 +277,16 @@ PKG_CONFIG_PATH = @PKG_CONFIG_PATH@ POLKIT_CFLAGS = @POLKIT_CFLAGS@ POLKIT_LIBS = @POLKIT_LIBS@ POSUB = @POSUB@ +PPPD_PATH = @PPPD_PATH@ PPPD_PLUGIN_DIR = @PPPD_PLUGIN_DIR@ +PPPOE_PATH = @PPPOE_PATH@ QT_CFLAGS = @QT_CFLAGS@ QT_LIBS = @QT_LIBS@ RANLIB = @RANLIB@ +READLINE_LIBS = @READLINE_LIBS@ SED = @SED@ +SELINUX_CFLAGS = @SELINUX_CFLAGS@ +SELINUX_LIBS = @SELINUX_LIBS@ SET_MAKE = @SET_MAKE@ SHELL = @SHELL@ STRIP = @STRIP@ @@ -287,6 +301,7 @@ UDEV_BASE_DIR = @UDEV_BASE_DIR@ USE_NLS = @USE_NLS@ UUID_CFLAGS = @UUID_CFLAGS@ UUID_LIBS = @UUID_LIBS@ +VALGRIND_RULES = @VALGRIND_RULES@ VAPIGEN = @VAPIGEN@ VAPIGEN_MAKEFILE = @VAPIGEN_MAKEFILE@ VAPIGEN_VAPIDIR = @VAPIGEN_VAPIDIR@ @@ -349,6 +364,7 @@ psdir = @psdir@ sbindir = @sbindir@ sharedstatedir = @sharedstatedir@ srcdir = @srcdir@ +subdirs = @subdirs@ sysconfdir = @sysconfdir@ systemdsystemunitdir = @systemdsystemunitdir@ target_alias = @target_alias@ @@ -359,6 +375,7 @@ with_dhclient = @with_dhclient@ with_dhcpcd = @with_dhcpcd@ with_netconfig = @with_netconfig@ with_resolvconf = @with_resolvconf@ +with_valgrind = @with_valgrind@ EXTRA_DIST = \ 70-wifi-wired-exclusive.sh diff --git a/examples/python/Makefile.am b/examples/python/Makefile.am index 4c0f9c745..3b6a41f49 100644 --- a/examples/python/Makefile.am +++ b/examples/python/Makefile.am @@ -1,13 +1,2 @@ -EXTRA_DIST = \ - nm-state.py \ - add-connection.py \ - add-system-wifi-connection.py - vpn.py \ - update-secrets.py \ - list-connections.py \ - show-bssids.py \ - disconnect-device.py \ - get-active-connection-uuids.py \ - list-devices.py \ - goi-list-connections.py \ - goi-device-state-ip4config.py +SUBDIRS= dbus gi + diff --git a/examples/python/Makefile.in b/examples/python/Makefile.in index e2dea30af..338935955 100644 --- a/examples/python/Makefile.in +++ b/examples/python/Makefile.in @@ -80,7 +80,8 @@ host_triplet = @host@ subdir = examples/python DIST_COMMON = $(srcdir)/Makefile.in $(srcdir)/Makefile.am ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 -am__aclocal_m4_deps = $(top_srcdir)/m4/compiler_warnings.m4 \ +am__aclocal_m4_deps = $(top_srcdir)/m4/ax_lib_readline.m4 \ + $(top_srcdir)/m4/compiler_warnings.m4 \ $(top_srcdir)/m4/gettext.m4 \ $(top_srcdir)/m4/gnome-code-coverage.m4 \ $(top_srcdir)/m4/gtk-doc.m4 $(top_srcdir)/m4/iconv.m4 \ @@ -112,13 +113,73 @@ am__v_at_0 = @ am__v_at_1 = SOURCES = DIST_SOURCES = +RECURSIVE_TARGETS = all-recursive check-recursive cscopelist-recursive \ + ctags-recursive dvi-recursive html-recursive info-recursive \ + install-data-recursive install-dvi-recursive \ + install-exec-recursive install-html-recursive \ + install-info-recursive install-pdf-recursive \ + install-ps-recursive install-recursive installcheck-recursive \ + installdirs-recursive pdf-recursive ps-recursive \ + tags-recursive uninstall-recursive am__can_run_installinfo = \ case $$AM_UPDATE_INFO_DIR in \ n|no|NO) false;; \ *) (install-info --version) >/dev/null 2>&1;; \ esac +RECURSIVE_CLEAN_TARGETS = mostlyclean-recursive clean-recursive \ + distclean-recursive maintainer-clean-recursive +am__recursive_targets = \ + $(RECURSIVE_TARGETS) \ + $(RECURSIVE_CLEAN_TARGETS) \ + $(am__extra_recursive_targets) +AM_RECURSIVE_TARGETS = $(am__recursive_targets:-recursive=) TAGS CTAGS \ + distdir am__tagged_files = $(HEADERS) $(SOURCES) $(TAGS_FILES) $(LISP) +# Read a list of newline-separated strings from the standard input, +# and print each of them once, without duplicates. Input order is +# *not* preserved. +am__uniquify_input = $(AWK) '\ + BEGIN { nonempty = 0; } \ + { items[$$0] = 1; nonempty = 1; } \ + END { if (nonempty) { for (i in items) print i; }; } \ +' +# Make sure the list of sources is unique. This is necessary because, +# e.g., the same source file might be shared among _SOURCES variables +# for different programs/libraries. +am__define_uniq_tagged_files = \ + list='$(am__tagged_files)'; \ + unique=`for i in $$list; do \ + if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ + done | $(am__uniquify_input)` +ETAGS = etags +CTAGS = ctags +DIST_SUBDIRS = $(SUBDIRS) DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) +am__relativize = \ + dir0=`pwd`; \ + sed_first='s,^\([^/]*\)/.*$$,\1,'; \ + sed_rest='s,^[^/]*/*,,'; \ + sed_last='s,^.*/\([^/]*\)$$,\1,'; \ + sed_butlast='s,/*[^/]*$$,,'; \ + while test -n "$$dir1"; do \ + first=`echo "$$dir1" | sed -e "$$sed_first"`; \ + if test "$$first" != "."; then \ + if test "$$first" = ".."; then \ + dir2=`echo "$$dir0" | sed -e "$$sed_last"`/"$$dir2"; \ + dir0=`echo "$$dir0" | sed -e "$$sed_butlast"`; \ + else \ + first2=`echo "$$dir2" | sed -e "$$sed_first"`; \ + if test "$$first2" = "$$first"; then \ + dir2=`echo "$$dir2" | sed -e "$$sed_rest"`; \ + else \ + dir2="../$$dir2"; \ + fi; \ + dir0="$$dir0"/"$$first"; \ + fi; \ + fi; \ + dir1=`echo "$$dir1" | sed -e "$$sed_rest"`; \ + done; \ + reldir="$$dir2" ACLOCAL = @ACLOCAL@ ALL_LINGUAS = @ALL_LINGUAS@ AMTAR = @AMTAR@ @@ -144,12 +205,15 @@ CXXFLAGS = @CXXFLAGS@ CYGPATH_W = @CYGPATH_W@ DATADIRNAME = @DATADIRNAME@ DBUS_CFLAGS = @DBUS_CFLAGS@ +DBUS_GLIB_100_CFLAGS = @DBUS_GLIB_100_CFLAGS@ +DBUS_GLIB_100_LIBS = @DBUS_GLIB_100_LIBS@ DBUS_LIBS = @DBUS_LIBS@ DBUS_SYS_DIR = @DBUS_SYS_DIR@ DEFS = @DEFS@ DEPDIR = @DEPDIR@ DHCLIENT_PATH = @DHCLIENT_PATH@ DHCPCD_PATH = @DHCPCD_PATH@ +DISTRO_NETWORK_SERVICE = @DISTRO_NETWORK_SERVICE@ DLLTOOL = @DLLTOOL@ DNSMASQ_PATH = @DNSMASQ_PATH@ DSYMUTIL = @DSYMUTIL@ @@ -174,7 +238,6 @@ GNUTLS_CFLAGS = @GNUTLS_CFLAGS@ GNUTLS_LIBS = @GNUTLS_LIBS@ GREP = @GREP@ GTKDOC_CHECK = @GTKDOC_CHECK@ -GTKDOC_CHECK_PATH = @GTKDOC_CHECK_PATH@ GTKDOC_DEPS_CFLAGS = @GTKDOC_DEPS_CFLAGS@ GTKDOC_DEPS_LIBS = @GTKDOC_DEPS_LIBS@ GTKDOC_MKPDF = @GTKDOC_MKPDF@ @@ -219,12 +282,16 @@ LIBGCRYPT_LIBS = @LIBGCRYPT_LIBS@ LIBICONV = @LIBICONV@ LIBINTL = @LIBINTL@ LIBM = @LIBM@ +LIBNDP_CFLAGS = @LIBNDP_CFLAGS@ +LIBNDP_LIBS = @LIBNDP_LIBS@ LIBNL_CFLAGS = @LIBNL_CFLAGS@ LIBNL_LIBS = @LIBNL_LIBS@ LIBOBJS = @LIBOBJS@ LIBS = @LIBS@ LIBSOUP_CFLAGS = @LIBSOUP_CFLAGS@ LIBSOUP_LIBS = @LIBSOUP_LIBS@ +LIBTEAMDCTL_CFLAGS = @LIBTEAMDCTL_CFLAGS@ +LIBTEAMDCTL_LIBS = @LIBTEAMDCTL_LIBS@ LIBTOOL = @LIBTOOL@ LIPO = @LIPO@ LN_S = @LN_S@ @@ -241,6 +308,8 @@ MOC = @MOC@ MSGFMT = @MSGFMT@ MSGFMT_015 = @MSGFMT_015@ MSGMERGE = @MSGMERGE@ +NEWT_CFLAGS = @NEWT_CFLAGS@ +NEWT_LIBS = @NEWT_LIBS@ NM = @NM@ NMEDIT = @NMEDIT@ NM_MAJOR_VERSION = @NM_MAJOR_VERSION@ @@ -268,11 +337,16 @@ PKG_CONFIG_PATH = @PKG_CONFIG_PATH@ POLKIT_CFLAGS = @POLKIT_CFLAGS@ POLKIT_LIBS = @POLKIT_LIBS@ POSUB = @POSUB@ +PPPD_PATH = @PPPD_PATH@ PPPD_PLUGIN_DIR = @PPPD_PLUGIN_DIR@ +PPPOE_PATH = @PPPOE_PATH@ QT_CFLAGS = @QT_CFLAGS@ QT_LIBS = @QT_LIBS@ RANLIB = @RANLIB@ +READLINE_LIBS = @READLINE_LIBS@ SED = @SED@ +SELINUX_CFLAGS = @SELINUX_CFLAGS@ +SELINUX_LIBS = @SELINUX_LIBS@ SET_MAKE = @SET_MAKE@ SHELL = @SHELL@ STRIP = @STRIP@ @@ -287,6 +361,7 @@ UDEV_BASE_DIR = @UDEV_BASE_DIR@ USE_NLS = @USE_NLS@ UUID_CFLAGS = @UUID_CFLAGS@ UUID_LIBS = @UUID_LIBS@ +VALGRIND_RULES = @VALGRIND_RULES@ VAPIGEN = @VAPIGEN@ VAPIGEN_MAKEFILE = @VAPIGEN_MAKEFILE@ VAPIGEN_VAPIDIR = @VAPIGEN_VAPIDIR@ @@ -349,6 +424,7 @@ psdir = @psdir@ sbindir = @sbindir@ sharedstatedir = @sharedstatedir@ srcdir = @srcdir@ +subdirs = @subdirs@ sysconfdir = @sysconfdir@ systemdsystemunitdir = @systemdsystemunitdir@ target_alias = @target_alias@ @@ -359,12 +435,9 @@ with_dhclient = @with_dhclient@ with_dhcpcd = @with_dhcpcd@ with_netconfig = @with_netconfig@ with_resolvconf = @with_resolvconf@ -EXTRA_DIST = \ - nm-state.py \ - add-connection.py \ - add-system-wifi-connection.py - -all: all-am +with_valgrind = @with_valgrind@ +SUBDIRS = dbus gi +all: all-recursive .SUFFIXES: $(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.am $(am__configure_deps) @@ -403,12 +476,105 @@ mostlyclean-libtool: clean-libtool: -rm -rf .libs _libs -tags TAGS: - -ctags CTAGS: -cscope cscopelist: +# This directory's subdirectories are mostly independent; you can cd +# into them and run 'make' without going through this Makefile. +# To change the values of 'make' variables: instead of editing Makefiles, +# (1) if the variable is set in 'config.status', edit 'config.status' +# (which will cause the Makefiles to be regenerated when you run 'make'); +# (2) otherwise, pass the desired values on the 'make' command line. +$(am__recursive_targets): + @fail=; \ + if $(am__make_keepgoing); then \ + failcom='fail=yes'; \ + else \ + failcom='exit 1'; \ + fi; \ + dot_seen=no; \ + target=`echo $@ | sed s/-recursive//`; \ + case "$@" in \ + distclean-* | maintainer-clean-*) list='$(DIST_SUBDIRS)' ;; \ + *) list='$(SUBDIRS)' ;; \ + esac; \ + for subdir in $$list; do \ + echo "Making $$target in $$subdir"; \ + if test "$$subdir" = "."; then \ + dot_seen=yes; \ + local_target="$$target-am"; \ + else \ + local_target="$$target"; \ + fi; \ + ($(am__cd) $$subdir && $(MAKE) $(AM_MAKEFLAGS) $$local_target) \ + || eval $$failcom; \ + done; \ + if test "$$dot_seen" = "no"; then \ + $(MAKE) $(AM_MAKEFLAGS) "$$target-am" || exit 1; \ + fi; test -z "$$fail" + +ID: $(am__tagged_files) + $(am__define_uniq_tagged_files); mkid -fID $$unique +tags: tags-recursive +TAGS: tags + +tags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files) + set x; \ + here=`pwd`; \ + if ($(ETAGS) --etags-include --version) >/dev/null 2>&1; then \ + include_option=--etags-include; \ + empty_fix=.; \ + else \ + include_option=--include; \ + empty_fix=; \ + fi; \ + list='$(SUBDIRS)'; for subdir in $$list; do \ + if test "$$subdir" = .; then :; else \ + test ! -f $$subdir/TAGS || \ + set "$$@" "$$include_option=$$here/$$subdir/TAGS"; \ + fi; \ + done; \ + $(am__define_uniq_tagged_files); \ + shift; \ + if test -z "$(ETAGS_ARGS)$$*$$unique"; then :; else \ + test -n "$$unique" || unique=$$empty_fix; \ + if test $$# -gt 0; then \ + $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ + "$$@" $$unique; \ + else \ + $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ + $$unique; \ + fi; \ + fi +ctags: ctags-recursive + +CTAGS: ctags +ctags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files) + $(am__define_uniq_tagged_files); \ + test -z "$(CTAGS_ARGS)$$unique" \ + || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \ + $$unique + +GTAGS: + here=`$(am__cd) $(top_builddir) && pwd` \ + && $(am__cd) $(top_srcdir) \ + && gtags -i $(GTAGS_ARGS) "$$here" +cscopelist: cscopelist-recursive + +cscopelist-am: $(am__tagged_files) + list='$(am__tagged_files)'; \ + case "$(srcdir)" in \ + [\\/]* | ?:[\\/]*) sdir="$(srcdir)" ;; \ + *) sdir=$(subdir)/$(srcdir) ;; \ + esac; \ + for i in $$list; do \ + if test -f "$$i"; then \ + echo "$(subdir)/$$i"; \ + else \ + echo "$$sdir/$$i"; \ + fi; \ + done >> $(top_builddir)/cscope.files +distclean-tags: + -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags distdir: $(DISTFILES) @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ @@ -440,19 +606,45 @@ distdir: $(DISTFILES) || exit 1; \ fi; \ done + @list='$(DIST_SUBDIRS)'; for subdir in $$list; do \ + if test "$$subdir" = .; then :; else \ + $(am__make_dryrun) \ + || test -d "$(distdir)/$$subdir" \ + || $(MKDIR_P) "$(distdir)/$$subdir" \ + || exit 1; \ + dir1=$$subdir; dir2="$(distdir)/$$subdir"; \ + $(am__relativize); \ + new_distdir=$$reldir; \ + dir1=$$subdir; dir2="$(top_distdir)"; \ + $(am__relativize); \ + new_top_distdir=$$reldir; \ + echo " (cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) top_distdir="$$new_top_distdir" distdir="$$new_distdir" \\"; \ + echo " am__remove_distdir=: am__skip_length_check=: am__skip_mode_fix=: distdir)"; \ + ($(am__cd) $$subdir && \ + $(MAKE) $(AM_MAKEFLAGS) \ + top_distdir="$$new_top_distdir" \ + distdir="$$new_distdir" \ + am__remove_distdir=: \ + am__skip_length_check=: \ + am__skip_mode_fix=: \ + distdir) \ + || exit 1; \ + fi; \ + done check-am: all-am -check: check-am +check: check-recursive all-am: Makefile -installdirs: -install: install-am -install-exec: install-exec-am -install-data: install-data-am -uninstall: uninstall-am +installdirs: installdirs-recursive +installdirs-am: +install: install-recursive +install-exec: install-exec-recursive +install-data: install-data-recursive +uninstall: uninstall-recursive install-am: all-am @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am -installcheck: installcheck-am +installcheck: installcheck-recursive install-strip: if test -z '$(STRIP)'; then \ $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ @@ -474,95 +666,87 @@ distclean-generic: maintainer-clean-generic: @echo "This command is intended for maintainers to use" @echo "it deletes files that may require special tools to rebuild." -clean: clean-am +clean: clean-recursive clean-am: clean-generic clean-libtool mostlyclean-am -distclean: distclean-am +distclean: distclean-recursive -rm -f Makefile -distclean-am: clean-am distclean-generic +distclean-am: clean-am distclean-generic distclean-tags -dvi: dvi-am +dvi: dvi-recursive dvi-am: -html: html-am +html: html-recursive html-am: -info: info-am +info: info-recursive info-am: install-data-am: -install-dvi: install-dvi-am +install-dvi: install-dvi-recursive install-dvi-am: install-exec-am: -install-html: install-html-am +install-html: install-html-recursive install-html-am: -install-info: install-info-am +install-info: install-info-recursive install-info-am: install-man: -install-pdf: install-pdf-am +install-pdf: install-pdf-recursive install-pdf-am: -install-ps: install-ps-am +install-ps: install-ps-recursive install-ps-am: installcheck-am: -maintainer-clean: maintainer-clean-am +maintainer-clean: maintainer-clean-recursive -rm -f Makefile maintainer-clean-am: distclean-am maintainer-clean-generic -mostlyclean: mostlyclean-am +mostlyclean: mostlyclean-recursive mostlyclean-am: mostlyclean-generic mostlyclean-libtool -pdf: pdf-am +pdf: pdf-recursive pdf-am: -ps: ps-am +ps: ps-recursive ps-am: uninstall-am: -.MAKE: install-am install-strip +.MAKE: $(am__recursive_targets) install-am install-strip -.PHONY: all all-am check check-am clean clean-generic clean-libtool \ - cscopelist-am ctags-am distclean distclean-generic \ - distclean-libtool distdir dvi dvi-am html html-am info info-am \ +.PHONY: $(am__recursive_targets) CTAGS GTAGS TAGS all all-am check \ + check-am clean clean-generic clean-libtool cscopelist-am ctags \ + ctags-am distclean distclean-generic distclean-libtool \ + distclean-tags distdir dvi dvi-am html html-am info info-am \ install install-am install-data install-data-am install-dvi \ install-dvi-am install-exec install-exec-am install-html \ install-html-am install-info install-info-am install-man \ install-pdf install-pdf-am install-ps install-ps-am \ install-strip installcheck installcheck-am installdirs \ - maintainer-clean maintainer-clean-generic mostlyclean \ - mostlyclean-generic mostlyclean-libtool pdf pdf-am ps ps-am \ - tags-am uninstall uninstall-am - - vpn.py \ - update-secrets.py \ - list-connections.py \ - show-bssids.py \ - disconnect-device.py \ - get-active-connection-uuids.py \ - list-devices.py \ - goi-list-connections.py \ - goi-device-state-ip4config.py + installdirs-am maintainer-clean maintainer-clean-generic \ + mostlyclean mostlyclean-generic mostlyclean-libtool pdf pdf-am \ + ps ps-am tags tags-am uninstall uninstall-am + # Tell versions [3.59,3.63) of GNU make to not export all variables. # Otherwise a system limit (for SysV at least) may be exceeded. diff --git a/examples/python/dbus/Makefile.am b/examples/python/dbus/Makefile.am new file mode 100644 index 000000000..0e8848849 --- /dev/null +++ b/examples/python/dbus/Makefile.am @@ -0,0 +1,13 @@ +EXTRA_DIST = \ + nm-state.py \ + add-connection.py \ + add-system-wifi-connection.py \ + vpn.py \ + update-secrets.py \ + list-connections.py \ + show-bssids.py \ + disconnect-device.py \ + get-active-connection-uuids.py \ + list-devices.py \ + update-ip4-method.py \ + is-wwan-default.py diff --git a/examples/python/dbus/Makefile.in b/examples/python/dbus/Makefile.in new file mode 100644 index 000000000..7b543fa73 --- /dev/null +++ b/examples/python/dbus/Makefile.in @@ -0,0 +1,586 @@ +# Makefile.in generated by automake 1.13.4 from Makefile.am. +# @configure_input@ + +# Copyright (C) 1994-2013 Free Software Foundation, Inc. + +# This Makefile.in is free software; the Free Software Foundation +# gives unlimited permission to copy and/or distribute it, +# with or without modifications, as long as this notice is preserved. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY, to the extent permitted by law; without +# even the implied warranty of MERCHANTABILITY or FITNESS FOR A +# PARTICULAR PURPOSE. + +@SET_MAKE@ +VPATH = @srcdir@ +am__is_gnu_make = test -n '$(MAKEFILE_LIST)' && test -n '$(MAKELEVEL)' +am__make_running_with_option = \ + case $${target_option-} in \ + ?) ;; \ + *) echo "am__make_running_with_option: internal error: invalid" \ + "target option '$${target_option-}' specified" >&2; \ + exit 1;; \ + esac; \ + has_opt=no; \ + sane_makeflags=$$MAKEFLAGS; \ + if $(am__is_gnu_make); then \ + sane_makeflags=$$MFLAGS; \ + else \ + case $$MAKEFLAGS in \ + *\\[\ \ ]*) \ + bs=\\; \ + sane_makeflags=`printf '%s\n' "$$MAKEFLAGS" \ + | sed "s/$$bs$$bs[$$bs $$bs ]*//g"`;; \ + esac; \ + fi; \ + skip_next=no; \ + strip_trailopt () \ + { \ + flg=`printf '%s\n' "$$flg" | sed "s/$$1.*$$//"`; \ + }; \ + for flg in $$sane_makeflags; do \ + test $$skip_next = yes && { skip_next=no; continue; }; \ + case $$flg in \ + *=*|--*) continue;; \ + -*I) strip_trailopt 'I'; skip_next=yes;; \ + -*I?*) strip_trailopt 'I';; \ + -*O) strip_trailopt 'O'; skip_next=yes;; \ + -*O?*) strip_trailopt 'O';; \ + -*l) strip_trailopt 'l'; skip_next=yes;; \ + -*l?*) strip_trailopt 'l';; \ + -[dEDm]) skip_next=yes;; \ + -[JT]) skip_next=yes;; \ + esac; \ + case $$flg in \ + *$$target_option*) has_opt=yes; break;; \ + esac; \ + done; \ + test $$has_opt = yes +am__make_dryrun = (target_option=n; $(am__make_running_with_option)) +am__make_keepgoing = (target_option=k; $(am__make_running_with_option)) +pkgdatadir = $(datadir)/@PACKAGE@ +pkgincludedir = $(includedir)/@PACKAGE@ +pkglibdir = $(libdir)/@PACKAGE@ +pkglibexecdir = $(libexecdir)/@PACKAGE@ +am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd +install_sh_DATA = $(install_sh) -c -m 644 +install_sh_PROGRAM = $(install_sh) -c +install_sh_SCRIPT = $(install_sh) -c +INSTALL_HEADER = $(INSTALL_DATA) +transform = $(program_transform_name) +NORMAL_INSTALL = : +PRE_INSTALL = : +POST_INSTALL = : +NORMAL_UNINSTALL = : +PRE_UNINSTALL = : +POST_UNINSTALL = : +build_triplet = @build@ +host_triplet = @host@ +subdir = examples/python/dbus +DIST_COMMON = $(srcdir)/Makefile.in $(srcdir)/Makefile.am +ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 +am__aclocal_m4_deps = $(top_srcdir)/m4/ax_lib_readline.m4 \ + $(top_srcdir)/m4/compiler_warnings.m4 \ + $(top_srcdir)/m4/gettext.m4 \ + $(top_srcdir)/m4/gnome-code-coverage.m4 \ + $(top_srcdir)/m4/gtk-doc.m4 $(top_srcdir)/m4/iconv.m4 \ + $(top_srcdir)/m4/intlmacosx.m4 $(top_srcdir)/m4/intltool.m4 \ + $(top_srcdir)/m4/introspection.m4 $(top_srcdir)/m4/lib-ld.m4 \ + $(top_srcdir)/m4/lib-link.m4 $(top_srcdir)/m4/lib-prefix.m4 \ + $(top_srcdir)/m4/libtool.m4 $(top_srcdir)/m4/ltoptions.m4 \ + $(top_srcdir)/m4/ltsugar.m4 $(top_srcdir)/m4/ltversion.m4 \ + $(top_srcdir)/m4/lt~obsolete.m4 $(top_srcdir)/m4/nls.m4 \ + $(top_srcdir)/m4/po.m4 $(top_srcdir)/m4/progtest.m4 \ + $(top_srcdir)/m4/vapigen.m4 $(top_srcdir)/configure.ac +am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ + $(ACLOCAL_M4) +mkinstalldirs = $(install_sh) -d +CONFIG_HEADER = $(top_builddir)/config.h +CONFIG_CLEAN_FILES = +CONFIG_CLEAN_VPATH_FILES = +AM_V_P = $(am__v_P_@AM_V@) +am__v_P_ = $(am__v_P_@AM_DEFAULT_V@) +am__v_P_0 = false +am__v_P_1 = : +AM_V_GEN = $(am__v_GEN_@AM_V@) +am__v_GEN_ = $(am__v_GEN_@AM_DEFAULT_V@) +am__v_GEN_0 = @echo " GEN " $@; +am__v_GEN_1 = +AM_V_at = $(am__v_at_@AM_V@) +am__v_at_ = $(am__v_at_@AM_DEFAULT_V@) +am__v_at_0 = @ +am__v_at_1 = +SOURCES = +DIST_SOURCES = +am__can_run_installinfo = \ + case $$AM_UPDATE_INFO_DIR in \ + n|no|NO) false;; \ + *) (install-info --version) >/dev/null 2>&1;; \ + esac +am__tagged_files = $(HEADERS) $(SOURCES) $(TAGS_FILES) $(LISP) +DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) +ACLOCAL = @ACLOCAL@ +ALL_LINGUAS = @ALL_LINGUAS@ +AMTAR = @AMTAR@ +AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@ +AR = @AR@ +AUTOCONF = @AUTOCONF@ +AUTOHEADER = @AUTOHEADER@ +AUTOMAKE = @AUTOMAKE@ +AWK = @AWK@ +CC = @CC@ +CCDEPMODE = @CCDEPMODE@ +CFLAGS = @CFLAGS@ +CKDB_PATH = @CKDB_PATH@ +CODE_COVERAGE_CFLAGS = @CODE_COVERAGE_CFLAGS@ +CODE_COVERAGE_ENABLED = @CODE_COVERAGE_ENABLED@ +CODE_COVERAGE_LDFLAGS = @CODE_COVERAGE_LDFLAGS@ +CPP = @CPP@ +CPPFLAGS = @CPPFLAGS@ +CXX = @CXX@ +CXXCPP = @CXXCPP@ +CXXDEPMODE = @CXXDEPMODE@ +CXXFLAGS = @CXXFLAGS@ +CYGPATH_W = @CYGPATH_W@ +DATADIRNAME = @DATADIRNAME@ +DBUS_CFLAGS = @DBUS_CFLAGS@ +DBUS_GLIB_100_CFLAGS = @DBUS_GLIB_100_CFLAGS@ +DBUS_GLIB_100_LIBS = @DBUS_GLIB_100_LIBS@ +DBUS_LIBS = @DBUS_LIBS@ +DBUS_SYS_DIR = @DBUS_SYS_DIR@ +DEFS = @DEFS@ +DEPDIR = @DEPDIR@ +DHCLIENT_PATH = @DHCLIENT_PATH@ +DHCPCD_PATH = @DHCPCD_PATH@ +DISTRO_NETWORK_SERVICE = @DISTRO_NETWORK_SERVICE@ +DLLTOOL = @DLLTOOL@ +DNSMASQ_PATH = @DNSMASQ_PATH@ +DSYMUTIL = @DSYMUTIL@ +DUMPBIN = @DUMPBIN@ +ECHO_C = @ECHO_C@ +ECHO_N = @ECHO_N@ +ECHO_T = @ECHO_T@ +EGREP = @EGREP@ +EXEEXT = @EXEEXT@ +FGREP = @FGREP@ +GENHTML = @GENHTML@ +GETTEXT_MACRO_VERSION = @GETTEXT_MACRO_VERSION@ +GETTEXT_PACKAGE = @GETTEXT_PACKAGE@ +GLIB_CFLAGS = @GLIB_CFLAGS@ +GLIB_GENMARSHAL = @GLIB_GENMARSHAL@ +GLIB_LIBS = @GLIB_LIBS@ +GLIB_MAKEFILE = @GLIB_MAKEFILE@ +GLIB_MKENUMS = @GLIB_MKENUMS@ +GMSGFMT = @GMSGFMT@ +GMSGFMT_015 = @GMSGFMT_015@ +GNUTLS_CFLAGS = @GNUTLS_CFLAGS@ +GNUTLS_LIBS = @GNUTLS_LIBS@ +GREP = @GREP@ +GTKDOC_CHECK = @GTKDOC_CHECK@ +GTKDOC_DEPS_CFLAGS = @GTKDOC_DEPS_CFLAGS@ +GTKDOC_DEPS_LIBS = @GTKDOC_DEPS_LIBS@ +GTKDOC_MKPDF = @GTKDOC_MKPDF@ +GTKDOC_REBASE = @GTKDOC_REBASE@ +GUDEV_CFLAGS = @GUDEV_CFLAGS@ +GUDEV_LIBS = @GUDEV_LIBS@ +HTML_DIR = @HTML_DIR@ +INSTALL = @INSTALL@ +INSTALL_DATA = @INSTALL_DATA@ +INSTALL_PROGRAM = @INSTALL_PROGRAM@ +INSTALL_SCRIPT = @INSTALL_SCRIPT@ +INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ +INTLLIBS = @INTLLIBS@ +INTLTOOL_EXTRACT = @INTLTOOL_EXTRACT@ +INTLTOOL_MERGE = @INTLTOOL_MERGE@ +INTLTOOL_PERL = @INTLTOOL_PERL@ +INTLTOOL_UPDATE = @INTLTOOL_UPDATE@ +INTLTOOL_V_MERGE = @INTLTOOL_V_MERGE@ +INTLTOOL_V_MERGE_OPTIONS = @INTLTOOL_V_MERGE_OPTIONS@ +INTLTOOL__v_MERGE_ = @INTLTOOL__v_MERGE_@ +INTLTOOL__v_MERGE_0 = @INTLTOOL__v_MERGE_0@ +INTL_MACOSX_LIBS = @INTL_MACOSX_LIBS@ +INTROSPECTION_CFLAGS = @INTROSPECTION_CFLAGS@ +INTROSPECTION_COMPILER = @INTROSPECTION_COMPILER@ +INTROSPECTION_GENERATE = @INTROSPECTION_GENERATE@ +INTROSPECTION_GIRDIR = @INTROSPECTION_GIRDIR@ +INTROSPECTION_LIBS = @INTROSPECTION_LIBS@ +INTROSPECTION_MAKEFILE = @INTROSPECTION_MAKEFILE@ +INTROSPECTION_SCANNER = @INTROSPECTION_SCANNER@ +INTROSPECTION_TYPELIBDIR = @INTROSPECTION_TYPELIBDIR@ +IPTABLES_PATH = @IPTABLES_PATH@ +IWMX_SDK_CFLAGS = @IWMX_SDK_CFLAGS@ +IWMX_SDK_LIBS = @IWMX_SDK_LIBS@ +KERNEL_FIRMWARE_DIR = @KERNEL_FIRMWARE_DIR@ +LCOV = @LCOV@ +LD = @LD@ +LDFLAGS = @LDFLAGS@ +LIBDL = @LIBDL@ +LIBGCRYPT_CFLAGS = @LIBGCRYPT_CFLAGS@ +LIBGCRYPT_CONFIG = @LIBGCRYPT_CONFIG@ +LIBGCRYPT_LIBS = @LIBGCRYPT_LIBS@ +LIBICONV = @LIBICONV@ +LIBINTL = @LIBINTL@ +LIBM = @LIBM@ +LIBNDP_CFLAGS = @LIBNDP_CFLAGS@ +LIBNDP_LIBS = @LIBNDP_LIBS@ +LIBNL_CFLAGS = @LIBNL_CFLAGS@ +LIBNL_LIBS = @LIBNL_LIBS@ +LIBOBJS = @LIBOBJS@ +LIBS = @LIBS@ +LIBSOUP_CFLAGS = @LIBSOUP_CFLAGS@ +LIBSOUP_LIBS = @LIBSOUP_LIBS@ +LIBTEAMDCTL_CFLAGS = @LIBTEAMDCTL_CFLAGS@ +LIBTEAMDCTL_LIBS = @LIBTEAMDCTL_LIBS@ +LIBTOOL = @LIBTOOL@ +LIPO = @LIPO@ +LN_S = @LN_S@ +LTLIBICONV = @LTLIBICONV@ +LTLIBINTL = @LTLIBINTL@ +LTLIBOBJS = @LTLIBOBJS@ +MAINT = @MAINT@ +MAKEINFO = @MAKEINFO@ +MANIFEST_TOOL = @MANIFEST_TOOL@ +MKDIR_P = @MKDIR_P@ +MM_GLIB_CFLAGS = @MM_GLIB_CFLAGS@ +MM_GLIB_LIBS = @MM_GLIB_LIBS@ +MOC = @MOC@ +MSGFMT = @MSGFMT@ +MSGFMT_015 = @MSGFMT_015@ +MSGMERGE = @MSGMERGE@ +NEWT_CFLAGS = @NEWT_CFLAGS@ +NEWT_LIBS = @NEWT_LIBS@ +NM = @NM@ +NMEDIT = @NMEDIT@ +NM_MAJOR_VERSION = @NM_MAJOR_VERSION@ +NM_MICRO_VERSION = @NM_MICRO_VERSION@ +NM_MINOR_VERSION = @NM_MINOR_VERSION@ +NM_MODIFY_SYSTEM_POLICY = @NM_MODIFY_SYSTEM_POLICY@ +NM_VERSION = @NM_VERSION@ +NSS_CFLAGS = @NSS_CFLAGS@ +NSS_LIBS = @NSS_LIBS@ +OBJDUMP = @OBJDUMP@ +OBJEXT = @OBJEXT@ +OTOOL = @OTOOL@ +OTOOL64 = @OTOOL64@ +PACKAGE = @PACKAGE@ +PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@ +PACKAGE_NAME = @PACKAGE_NAME@ +PACKAGE_STRING = @PACKAGE_STRING@ +PACKAGE_TARNAME = @PACKAGE_TARNAME@ +PACKAGE_URL = @PACKAGE_URL@ +PACKAGE_VERSION = @PACKAGE_VERSION@ +PATH_SEPARATOR = @PATH_SEPARATOR@ +PKG_CONFIG = @PKG_CONFIG@ +PKG_CONFIG_LIBDIR = @PKG_CONFIG_LIBDIR@ +PKG_CONFIG_PATH = @PKG_CONFIG_PATH@ +POLKIT_CFLAGS = @POLKIT_CFLAGS@ +POLKIT_LIBS = @POLKIT_LIBS@ +POSUB = @POSUB@ +PPPD_PATH = @PPPD_PATH@ +PPPD_PLUGIN_DIR = @PPPD_PLUGIN_DIR@ +PPPOE_PATH = @PPPOE_PATH@ +QT_CFLAGS = @QT_CFLAGS@ +QT_LIBS = @QT_LIBS@ +RANLIB = @RANLIB@ +READLINE_LIBS = @READLINE_LIBS@ +SED = @SED@ +SELINUX_CFLAGS = @SELINUX_CFLAGS@ +SELINUX_LIBS = @SELINUX_LIBS@ +SET_MAKE = @SET_MAKE@ +SHELL = @SHELL@ +STRIP = @STRIP@ +SYSTEMD_200_CFLAGS = @SYSTEMD_200_CFLAGS@ +SYSTEMD_200_LIBS = @SYSTEMD_200_LIBS@ +SYSTEMD_INHIBIT_CFLAGS = @SYSTEMD_INHIBIT_CFLAGS@ +SYSTEMD_INHIBIT_LIBS = @SYSTEMD_INHIBIT_LIBS@ +SYSTEMD_LOGIN_CFLAGS = @SYSTEMD_LOGIN_CFLAGS@ +SYSTEMD_LOGIN_LIBS = @SYSTEMD_LOGIN_LIBS@ +SYSTEM_CA_PATH = @SYSTEM_CA_PATH@ +UDEV_BASE_DIR = @UDEV_BASE_DIR@ +USE_NLS = @USE_NLS@ +UUID_CFLAGS = @UUID_CFLAGS@ +UUID_LIBS = @UUID_LIBS@ +VALGRIND_RULES = @VALGRIND_RULES@ +VAPIGEN = @VAPIGEN@ +VAPIGEN_MAKEFILE = @VAPIGEN_MAKEFILE@ +VAPIGEN_VAPIDIR = @VAPIGEN_VAPIDIR@ +VERSION = @VERSION@ +XGETTEXT = @XGETTEXT@ +XGETTEXT_015 = @XGETTEXT_015@ +XGETTEXT_EXTRA_OPTIONS = @XGETTEXT_EXTRA_OPTIONS@ +abs_builddir = @abs_builddir@ +abs_srcdir = @abs_srcdir@ +abs_top_builddir = @abs_top_builddir@ +abs_top_srcdir = @abs_top_srcdir@ +ac_ct_AR = @ac_ct_AR@ +ac_ct_CC = @ac_ct_CC@ +ac_ct_CXX = @ac_ct_CXX@ +ac_ct_DUMPBIN = @ac_ct_DUMPBIN@ +am__include = @am__include@ +am__leading_dot = @am__leading_dot@ +am__quote = @am__quote@ +am__tar = @am__tar@ +am__untar = @am__untar@ +bindir = @bindir@ +build = @build@ +build_alias = @build_alias@ +build_cpu = @build_cpu@ +build_os = @build_os@ +build_vendor = @build_vendor@ +builddir = @builddir@ +datadir = @datadir@ +datarootdir = @datarootdir@ +docdir = @docdir@ +dvidir = @dvidir@ +exec_prefix = @exec_prefix@ +host = @host@ +host_alias = @host_alias@ +host_cpu = @host_cpu@ +host_os = @host_os@ +host_vendor = @host_vendor@ +htmldir = @htmldir@ +includedir = @includedir@ +infodir = @infodir@ +install_sh = @install_sh@ +intltool__v_merge_options_ = @intltool__v_merge_options_@ +intltool__v_merge_options_0 = @intltool__v_merge_options_0@ +libdir = @libdir@ +libexecdir = @libexecdir@ +localedir = @localedir@ +localstatedir = @localstatedir@ +mandir = @mandir@ +mkdir_p = @mkdir_p@ +nmbinary = @nmbinary@ +nmconfdir = @nmconfdir@ +nmdatadir = @nmdatadir@ +nmrundir = @nmrundir@ +nmstatedir = @nmstatedir@ +oldincludedir = @oldincludedir@ +pdfdir = @pdfdir@ +prefix = @prefix@ +program_transform_name = @program_transform_name@ +psdir = @psdir@ +sbindir = @sbindir@ +sharedstatedir = @sharedstatedir@ +srcdir = @srcdir@ +subdirs = @subdirs@ +sysconfdir = @sysconfdir@ +systemdsystemunitdir = @systemdsystemunitdir@ +target_alias = @target_alias@ +top_build_prefix = @top_build_prefix@ +top_builddir = @top_builddir@ +top_srcdir = @top_srcdir@ +with_dhclient = @with_dhclient@ +with_dhcpcd = @with_dhcpcd@ +with_netconfig = @with_netconfig@ +with_resolvconf = @with_resolvconf@ +with_valgrind = @with_valgrind@ +EXTRA_DIST = \ + nm-state.py \ + add-connection.py \ + add-system-wifi-connection.py \ + vpn.py \ + update-secrets.py \ + list-connections.py \ + show-bssids.py \ + disconnect-device.py \ + get-active-connection-uuids.py \ + list-devices.py \ + update-ip4-method.py \ + is-wwan-default.py + +all: all-am + +.SUFFIXES: +$(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.am $(am__configure_deps) + @for dep in $?; do \ + case '$(am__configure_deps)' in \ + *$$dep*) \ + ( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \ + && { if test -f $@; then exit 0; else break; fi; }; \ + exit 1;; \ + esac; \ + done; \ + echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu examples/python/dbus/Makefile'; \ + $(am__cd) $(top_srcdir) && \ + $(AUTOMAKE) --gnu examples/python/dbus/Makefile +.PRECIOUS: Makefile +Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status + @case '$?' in \ + *config.status*) \ + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \ + *) \ + echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \ + cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \ + esac; + +$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES) + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh + +$(top_srcdir)/configure: @MAINTAINER_MODE_TRUE@ $(am__configure_deps) + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh +$(ACLOCAL_M4): @MAINTAINER_MODE_TRUE@ $(am__aclocal_m4_deps) + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh +$(am__aclocal_m4_deps): + +mostlyclean-libtool: + -rm -f *.lo + +clean-libtool: + -rm -rf .libs _libs +tags TAGS: + +ctags CTAGS: + +cscope cscopelist: + + +distdir: $(DISTFILES) + @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ + topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ + list='$(DISTFILES)'; \ + dist_files=`for file in $$list; do echo $$file; done | \ + sed -e "s|^$$srcdirstrip/||;t" \ + -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \ + case $$dist_files in \ + */*) $(MKDIR_P) `echo "$$dist_files" | \ + sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \ + sort -u` ;; \ + esac; \ + for file in $$dist_files; do \ + if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \ + if test -d $$d/$$file; then \ + dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \ + if test -d "$(distdir)/$$file"; then \ + find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ + fi; \ + if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \ + cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \ + find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ + fi; \ + cp -fpR $$d/$$file "$(distdir)$$dir" || exit 1; \ + else \ + test -f "$(distdir)/$$file" \ + || cp -p $$d/$$file "$(distdir)/$$file" \ + || exit 1; \ + fi; \ + done +check-am: all-am +check: check-am +all-am: Makefile +installdirs: +install: install-am +install-exec: install-exec-am +install-data: install-data-am +uninstall: uninstall-am + +install-am: all-am + @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am + +installcheck: installcheck-am +install-strip: + if test -z '$(STRIP)'; then \ + $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ + install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ + install; \ + else \ + $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ + install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ + "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'" install; \ + fi +mostlyclean-generic: + +clean-generic: + +distclean-generic: + -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES) + -test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES) + +maintainer-clean-generic: + @echo "This command is intended for maintainers to use" + @echo "it deletes files that may require special tools to rebuild." +clean: clean-am + +clean-am: clean-generic clean-libtool mostlyclean-am + +distclean: distclean-am + -rm -f Makefile +distclean-am: clean-am distclean-generic + +dvi: dvi-am + +dvi-am: + +html: html-am + +html-am: + +info: info-am + +info-am: + +install-data-am: + +install-dvi: install-dvi-am + +install-dvi-am: + +install-exec-am: + +install-html: install-html-am + +install-html-am: + +install-info: install-info-am + +install-info-am: + +install-man: + +install-pdf: install-pdf-am + +install-pdf-am: + +install-ps: install-ps-am + +install-ps-am: + +installcheck-am: + +maintainer-clean: maintainer-clean-am + -rm -f Makefile +maintainer-clean-am: distclean-am maintainer-clean-generic + +mostlyclean: mostlyclean-am + +mostlyclean-am: mostlyclean-generic mostlyclean-libtool + +pdf: pdf-am + +pdf-am: + +ps: ps-am + +ps-am: + +uninstall-am: + +.MAKE: install-am install-strip + +.PHONY: all all-am check check-am clean clean-generic clean-libtool \ + cscopelist-am ctags-am distclean distclean-generic \ + distclean-libtool distdir dvi dvi-am html html-am info info-am \ + install install-am install-data install-data-am install-dvi \ + install-dvi-am install-exec install-exec-am install-html \ + install-html-am install-info install-info-am install-man \ + install-pdf install-pdf-am install-ps install-ps-am \ + install-strip installcheck installcheck-am installdirs \ + maintainer-clean maintainer-clean-generic mostlyclean \ + mostlyclean-generic mostlyclean-libtool pdf pdf-am ps ps-am \ + tags-am uninstall uninstall-am + + +# Tell versions [3.59,3.63) of GNU make to not export all variables. +# Otherwise a system limit (for SysV at least) may be exceeded. +.NOEXPORT: diff --git a/examples/python/add-connection.py b/examples/python/dbus/add-connection.py index 6df14c103..6df14c103 100755 --- a/examples/python/add-connection.py +++ b/examples/python/dbus/add-connection.py diff --git a/examples/python/add-system-wifi-connection.py b/examples/python/dbus/add-system-wifi-connection.py index ff3908217..ff3908217 100755 --- a/examples/python/add-system-wifi-connection.py +++ b/examples/python/dbus/add-system-wifi-connection.py diff --git a/examples/python/dbus/disconnect-device.py b/examples/python/dbus/disconnect-device.py new file mode 100755 index 000000000..85afa97ba --- /dev/null +++ b/examples/python/dbus/disconnect-device.py @@ -0,0 +1,62 @@ +#!/usr/bin/env python +# -*- Mode: python; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License along +# with this program; if not, write to the Free Software Foundation, Inc., +# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. +# +# Copyright (C) 2010 Red Hat, Inc. +# + +import dbus, sys + +# This example takes a device interface name as a parameter and tells +# NetworkManager to disconnect that device, closing down any network +# connection it may have + +if len(sys.argv) != 2: + raise Exception("Usage: %s <interface>" % sys.argv[0]) + +bus = dbus.SystemBus() + +# Get a proxy for the base NetworkManager object +proxy = bus.get_object("org.freedesktop.NetworkManager", "/org/freedesktop/NetworkManager") +manager = dbus.Interface(proxy, "org.freedesktop.NetworkManager") + +dpath = None + +# Find the device the user wants to disconnect +devices = manager.GetDevices() +for d in devices: + dev_proxy = bus.get_object("org.freedesktop.NetworkManager", d) + prop_iface = dbus.Interface(dev_proxy, "org.freedesktop.DBus.Properties") + iface = prop_iface.Get("org.freedesktop.NetworkManager.Device", "Interface") + if iface == sys.argv[1]: + dpath = d + break + +if not dpath or not len(dpath): + raise Exception("NetworkManager knows nothing about %s" % sys.argv[1]) + +dev_proxy = bus.get_object("org.freedesktop.NetworkManager", dpath) +dev_iface = dbus.Interface(dev_proxy, "org.freedesktop.NetworkManager.Device") +prop_iface = dbus.Interface(dev_proxy, "org.freedesktop.DBus.Properties") + +# Make sure the device is connected before we try to disconnect it +state = prop_iface.Get("org.freedesktop.NetworkManager.Device", "State") +if state <= 3: + raise Exception("Device %s isn't connected" % sys.argv[1]) + +# Tell NM to disconnect it +dev_iface.Disconnect() + diff --git a/examples/python/dbus/get-active-connection-uuids.py b/examples/python/dbus/get-active-connection-uuids.py new file mode 100755 index 000000000..6fe93d05d --- /dev/null +++ b/examples/python/dbus/get-active-connection-uuids.py @@ -0,0 +1,56 @@ +#!/usr/bin/env python +# -*- Mode: python; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License along +# with this program; if not, write to the Free Software Foundation, Inc., +# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. +# +# Copyright (C) 2010 Red Hat, Inc. +# + +import dbus, sys + +# This example takes a device interface name as a parameter and tells +# NetworkManager to disconnect that device, closing down any network +# connection it may have + +bus = dbus.SystemBus() + +# Get a proxy for the base NetworkManager object +m_proxy = bus.get_object("org.freedesktop.NetworkManager", "/org/freedesktop/NetworkManager") +manager = dbus.Interface(m_proxy, "org.freedesktop.NetworkManager") +mgr_props = dbus.Interface(m_proxy, "org.freedesktop.DBus.Properties") + +s_proxy = bus.get_object("org.freedesktop.NetworkManager", "/org/freedesktop/NetworkManager/Settings") +settings = dbus.Interface(s_proxy, "org.freedesktop.NetworkManager.Settings") + +# Find the device the user wants to disconnect +active = mgr_props.Get("org.freedesktop.NetworkManager", "ActiveConnections") +for a in active: + a_proxy = bus.get_object("org.freedesktop.NetworkManager", a) + + # Get the UUID directly; apps could use this to perform certain operations + # based on which network you're connected too + a_props = dbus.Interface(a_proxy, "org.freedesktop.DBus.Properties") + uuid = a_props.Get("org.freedesktop.NetworkManager.Connection.Active", "Uuid") + + # Grab the connection object path so we can get all the connection's settings + connection_path = a_props.Get("org.freedesktop.NetworkManager.Connection.Active", "Connection") + c_proxy = bus.get_object("org.freedesktop.NetworkManager", connection_path) + connection = dbus.Interface(c_proxy, "org.freedesktop.NetworkManager.Settings.Connection") + settings = connection.GetSettings() + print "%s (%s) - %s" % (settings['connection']['id'], uuid, settings['connection']['type']) + +if len(active) == 0: + print "No active connections" + diff --git a/examples/python/dbus/is-wwan-default.py b/examples/python/dbus/is-wwan-default.py new file mode 100755 index 000000000..6131cda16 --- /dev/null +++ b/examples/python/dbus/is-wwan-default.py @@ -0,0 +1,78 @@ +#!/usr/bin/env python +# -*- Mode: python; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License along +# with this program; if not, write to the Free Software Foundation, Inc., +# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. +# +# Copyright (C) 2011 - 2012 Red Hat, Inc. +# + +import dbus, sys + +# This example indicates whether the default network connection is known to be WWAN + +NM_DEVICE_TYPE_MODEM = 8 +NM_DEVICE_TYPE_BLUETOOTH = 5 +NM_SERVICE_NAME = "org.freedesktop.NetworkManager" +NM_MANAGER_IFACE = "org.freedesktop.NetworkManager" +DBUS_PROPS_IFACE = "org.freedesktop.DBus.Properties" + +bus = dbus.SystemBus() + +# Exit early if NetworkManager is not running +proxy = bus.get_object("org.freedesktop.DBus", "/org/freedesktop/DBus") +busdaemon = dbus.Interface(proxy, "org.freedesktop.DBus") +if not busdaemon.NameHasOwner(NM_SERVICE_NAME): + print "NetworkManager not running" + sys.exit(1) + +# Get a proxy for the NetworkManager object +proxy = bus.get_object(NM_SERVICE_NAME, "/org/freedesktop/NetworkManager") +manager = dbus.Interface(proxy, NM_MANAGER_IFACE) +props = dbus.Interface(proxy, DBUS_PROPS_IFACE) + +default_is_wwan = False + +# Look through all active network connections for the default one +active = props.Get(NM_MANAGER_IFACE, "ActiveConnections") +for a in active: + a_proxy = bus.get_object(NM_SERVICE_NAME, a) + a_props = dbus.Interface(a_proxy, DBUS_PROPS_IFACE) + all_props = a_props.GetAll("org.freedesktop.NetworkManager.Connection.Active") + + # Ignore this network connection if it's not default for IPv4 or IPv6 + if all_props["Default"] == False and all_props["Default6"] == False: + continue + + # Shortcut: check for Type property (only present in NM 0.9.9+) + try: + ctype = all_props["Type"] + if ctype in ["gsm", "cdma", "bluetooth"]: + default_is_wwan = True + break + except KeyError: + # Fall back to checking the type of the network connection's device + dev_path = all_props["Devices"][0] + dev_proxy = bus.get_object(NM_SERVICE_NAME, dev_path) + dev_props = dbus.Interface(dev_proxy, DBUS_PROPS_IFACE) + devtype = dev_props.Get("org.freedesktop.NetworkManager.Device", "DeviceType") + if devtype == NM_DEVICE_TYPE_MODEM or devtype == NM_DEVICE_TYPE_BLUETOOTH: + default_is_wwan = True + break + +if default_is_wwan: + print "WWAN is default" +else: + print "WWAN is not default" + diff --git a/examples/python/dbus/list-connections.py b/examples/python/dbus/list-connections.py new file mode 100755 index 000000000..120b744ac --- /dev/null +++ b/examples/python/dbus/list-connections.py @@ -0,0 +1,107 @@ +#!/usr/bin/env python +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License along +# with this program; if not, write to the Free Software Foundation, Inc., +# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. +# +# Copyright (C) 2010 - 2011 Red Hat, Inc. +# + +import dbus + +# This example asks settings service for all configured connections. +# It also asks for secrets, demonstrating the mechanism the secrets can +# be handled with. + +bus = dbus.SystemBus() + +def merge_secrets(proxy, config, setting_name): + try: + # returns a dict of dicts mapping name::setting, where setting is a dict + # mapping key::value. Each member of the 'setting' dict is a secret + secrets = proxy.GetSecrets(setting_name) + + # Copy the secrets into our connection config + for setting in secrets: + for key in secrets[setting]: + config[setting_name][key] = secrets[setting][key] + except Exception, e: + pass + +def dict_to_string(d, indent): + # Try to trivially translate a dictionary's elements into nice string + # formatting. + dstr = "" + for key in d: + val = d[key] + str_val = "" + add_string = True + if type(val) == type(dbus.Array([])): + for elt in val: + if type(elt) == type(dbus.Byte(1)): + str_val += "%s " % int(elt) + elif type(elt) == type(dbus.String("")): + str_val += "%s" % elt + elif type(val) == type(dbus.Dictionary({})): + dstr += dict_to_string(val, indent + " ") + add_string = False + else: + str_val = val + if add_string: + dstr += "%s%s: %s\n" % (indent, key, str_val) + return dstr + +def connection_to_string(config): + # dump a connection configuration to a the console + for setting_name in config: + print " Setting: %s" % setting_name + print dict_to_string(config[setting_name], " ") + print "" + + +def print_connections(): + # Ask the settings service for the list of connections it provides + service_name = "org.freedesktop.NetworkManager" + proxy = bus.get_object(service_name, "/org/freedesktop/NetworkManager/Settings") + settings = dbus.Interface(proxy, "org.freedesktop.NetworkManager.Settings") + connection_paths = settings.ListConnections() + + # List each connection's name, UUID, and type + for path in connection_paths: + con_proxy = bus.get_object(service_name, path) + settings_connection = dbus.Interface(con_proxy, "org.freedesktop.NetworkManager.Settings.Connection") + config = settings_connection.GetSettings() + + # Now get secrets too; we grab the secrets for each type of connection + # (since there isn't a "get all secrets" call because most of the time + # you only need 'wifi' secrets or '802.1x' secrets, not everything) and + # merge that into the configuration data + merge_secrets(settings_connection, config, '802-11-wireless') + merge_secrets(settings_connection, config, '802-11-wireless-security') + merge_secrets(settings_connection, config, '802-1x') + merge_secrets(settings_connection, config, 'gsm') + merge_secrets(settings_connection, config, 'cdma') + merge_secrets(settings_connection, config, 'ppp') + + # Get the details of the 'connection' setting + s_con = config['connection'] + print " name: %s" % s_con['id'] + print " uuid: %s" % s_con['uuid'] + print " type: %s" % s_con['type'] + print " ------------------------------------------" + connection_to_string(config) + + print "" + +print_connections() + diff --git a/examples/python/dbus/list-devices.py b/examples/python/dbus/list-devices.py new file mode 100755 index 000000000..b8e0058be --- /dev/null +++ b/examples/python/dbus/list-devices.py @@ -0,0 +1,83 @@ +#!/usr/bin/env python +# -*- Mode: python; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License along +# with this program; if not, write to the Free Software Foundation, Inc., +# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. +# +# Copyright (C) 2011 - 2012 Red Hat, Inc. +# + +import dbus, sys + +# This example lists basic information about network interfaces known to NM + +# For the types see include/NetworkManager.h +devtypes = { 1: "Ethernet", + 2: "Wi-Fi", + 5: "Bluetooth", + 6: "OLPC", + 7: "WiMAX", + 8: "Modem", + 9: "InfiniBand", + 10: "Bond", + 11: "VLAN", + 12: "ADSL", + 13: "Bridge", + 14: "Generic", + 15: "Team" + } + +states = { 0: "Unknown", + 10: "Unmanaged", + 20: "Unavailable", + 30: "Disconnected", + 40: "Prepare", + 50: "Config", + 60: "Need Auth", + 70: "IP Config", + 80: "IP Check", + 90: "Secondaries", + 100: "Activated", + 110: "Deactivating", + 120: "Failed" } + +bus = dbus.SystemBus() + +# Get a proxy for the base NetworkManager object +proxy = bus.get_object("org.freedesktop.NetworkManager", "/org/freedesktop/NetworkManager") +manager = dbus.Interface(proxy, "org.freedesktop.NetworkManager") + +# Get all devices known to NM and print their properties +devices = manager.GetDevices() +for d in devices: + dev_proxy = bus.get_object("org.freedesktop.NetworkManager", d) + prop_iface = dbus.Interface(dev_proxy, "org.freedesktop.DBus.Properties") + props = prop_iface.GetAll("org.freedesktop.NetworkManager.Device") + print "============================" + + print "Interface: %s" % props['Interface'] + try: + devtype = devtypes[props['DeviceType']] + except KeyError: + devtype = "Unknown" + print "Type: %s" % devtype + + print "Driver: %s" % props['Driver'] + + try: + state = states[props['State']] + except KeyError: + state = "Unknown" + print "State: %s" % state + diff --git a/examples/python/nm-state.py b/examples/python/dbus/nm-state.py index 94fa63099..94fa63099 100644..100755 --- a/examples/python/nm-state.py +++ b/examples/python/dbus/nm-state.py diff --git a/examples/python/dbus/show-bssids.py b/examples/python/dbus/show-bssids.py new file mode 100755 index 000000000..505e3d35c --- /dev/null +++ b/examples/python/dbus/show-bssids.py @@ -0,0 +1,78 @@ +#!/usr/bin/env python +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License along +# with this program; if not, write to the Free Software Foundation, Inc., +# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. +# +# Copyright (C) 2010 Red Hat, Inc. +# + + +# This example prints out all the AP BSSIDs that all WiFi devices on the +# machine can see. Useful for location-based services like Skyhook that +# can geolocate you based on the APs you can see. + +import dbus + +bus = dbus.SystemBus() + +# Get a proxy for the base NetworkManager object +proxy = bus.get_object("org.freedesktop.NetworkManager", "/org/freedesktop/NetworkManager") +manager = dbus.Interface(proxy, "org.freedesktop.NetworkManager") + +all_aps = [] + +print "Associated APs:" + +# Get all network devices +devices = manager.GetDevices() +for d in devices: + dev_proxy = bus.get_object("org.freedesktop.NetworkManager", d) + prop_iface = dbus.Interface(dev_proxy, "org.freedesktop.DBus.Properties") + + # Make sure the device is enabled before we try to use it + state = prop_iface.Get("org.freedesktop.NetworkManager.Device", "State") + if state <= 2: + continue + + # Get device's type; we only want wifi devices + iface = prop_iface.Get("org.freedesktop.NetworkManager.Device", "Interface") + dtype = prop_iface.Get("org.freedesktop.NetworkManager.Device", "DeviceType") + if dtype == 2: # WiFi + # Get a proxy for the wifi interface + wifi_iface = dbus.Interface(dev_proxy, "org.freedesktop.NetworkManager.Device.Wireless") + wifi_prop_iface = dbus.Interface(dev_proxy, "org.freedesktop.DBus.Properties") + + # Get the associated AP's object path + connected_path = wifi_prop_iface.Get("org.freedesktop.NetworkManager.Device.Wireless", "ActiveAccessPoint") + + # Get all APs the card can see + aps = wifi_iface.GetAccessPoints() + for path in aps: + ap_proxy = bus.get_object("org.freedesktop.NetworkManager", path) + ap_prop_iface = dbus.Interface(ap_proxy, "org.freedesktop.DBus.Properties") + bssid = ap_prop_iface.Get("org.freedesktop.NetworkManager.AccessPoint", "HwAddress") + + # Cache the BSSID + if not bssid in all_aps: + all_aps.append(bssid) + + # Print the current AP's BSSID + if path == connected_path: + print "%s (%s)" % (bssid, iface) + +# and print out all APs the wifi devices can see +print"\nFound APs:" +for bssid in all_aps: + print bssid + diff --git a/examples/python/dbus/update-ip4-method.py b/examples/python/dbus/update-ip4-method.py new file mode 100755 index 000000000..243738c5c --- /dev/null +++ b/examples/python/dbus/update-ip4-method.py @@ -0,0 +1,82 @@ +#!/usr/bin/env python +# -*- Mode: Python; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License along +# with this program; if not, write to the Free Software Foundation, Inc., +# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. +# +# Copyright (C) 2014 Red Hat, Inc. +# + +# +# This example updates a connection's IPv4 method with the Update() method. +# +# Configuration settings are described at +# https://developer.gnome.org/NetworkManager/0.9/ref-settings.html +# + +import socket, struct, dbus, sys + +def ip_to_int(ip_string): + return struct.unpack("=I", socket.inet_aton(ip_string))[0] + + +if len(sys.argv) < 3: + print "Usage: %s <uuid> <auto|static> [address prefix gateway]" % sys.argv[0] + sys.exit(1) + +method = sys.argv[2] +if method == "static" and len(sys.argv) < 5: + print "Usage: %s %s static address prefix [gateway]" % (sys.argv[0], sys.argv[1]) + sys.exit(1) + +# Convert method to NM method +if method == "static": + method = "manual" + +bus = dbus.SystemBus() +proxy = bus.get_object("org.freedesktop.NetworkManager", "/org/freedesktop/NetworkManager/Settings") +settings = dbus.Interface(proxy, "org.freedesktop.NetworkManager.Settings") + +for c_path in settings.ListConnections(): + c_proxy = bus.get_object("org.freedesktop.NetworkManager", c_path) + c_obj = dbus.Interface(c_proxy, "org.freedesktop.NetworkManager.Settings.Connection") + c_settings = c_obj.GetSettings() + + # Look for the requested connection UUID + if c_settings['connection']['uuid'] != sys.argv[1]: + continue + + # add IPv4 setting if it doesn't yet exist + if not c_settings.has_key('ipv4'): + c_settings['ipv4'] = {} + + # set the method and change properties + c_settings['ipv4']['method'] = method + if method == "auto": + # remove addresses + c_settings['ipv4']['addresses'] = dbus.Array([], signature=dbus.Signature('au')) + elif method == "manual": + # Add the static IP address, prefix, and (optional) gateway + gw = 0 + if len(sys.argv) == 6: + gw = ip_to_int(sys.argv[5]) + addr = dbus.Array([ip_to_int(sys.argv[3]), dbus.UInt32(int(sys.argv[4])), gw], signature=dbus.Signature('u')) + c_settings['ipv4']['addresses'] = dbus.Array([addr], signature=dbus.Signature('au')) + + # Save all the updated settings back to NetworkManager + c_obj.Update(c_settings) + break + +sys.exit(0) + diff --git a/examples/python/dbus/update-secrets.py b/examples/python/dbus/update-secrets.py new file mode 100755 index 000000000..13cac1b08 --- /dev/null +++ b/examples/python/dbus/update-secrets.py @@ -0,0 +1,116 @@ +#!/usr/bin/env python +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License along +# with this program; if not, write to the Free Software Foundation, Inc., +# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. +# +# Copyright (C) 2011 - 2012 Red Hat, Inc. +# + +# +# The example shows how to update secrets in a connection by means of D-Bus +# Update() method. The method replaces all previous settings with new ones +# including possible secrets. +# So, we get all settings using GetSettings() and then find out what secrets +# are associated with the connection using GetSecrets(), ask for new secret +# values, and add them to the settings that we pass to Update(). +# + +import dbus +import sys + +bus = dbus.SystemBus() + +def change_secrets_in_one_setting(proxy, config, setting_name): + # Add new secret values to the connection config + try: + # returns a dict of dicts mapping name::setting, where setting is a dict + # mapping key::value. Each member of the 'setting' dict is a secret + secrets = proxy.GetSecrets(setting_name) + print "Current secrets:", secrets + + # Ask user for new secrets and put them into our connection config + for setting in secrets: + for key in secrets[setting]: + new_secret = raw_input ("Enter new secret for '%s' in '%s': " % (key, setting)) + config[setting_name][key] = new_secret + except Exception, e: + #code = str(e).split(':')[0] + #print "Exception:", str(e) + pass + +def change_secrets(con_path, config): + # Get existing secrets; we grab the secrets for each type of connection + # (since there isn't a "get all secrets" call because most of the time + # you only need 'wifi' secrets or '802.1x' secrets, not everything) and + # set new values into the connection settings (config) + con_proxy = bus.get_object("org.freedesktop.NetworkManager", con_path) + connection_secrets = dbus.Interface(con_proxy, "org.freedesktop.NetworkManager.Settings.Connection") + change_secrets_in_one_setting(connection_secrets, config, '802-11-wireless') + change_secrets_in_one_setting(connection_secrets, config, '802-11-wireless-security') + change_secrets_in_one_setting(connection_secrets, config, '802-1x') + change_secrets_in_one_setting(connection_secrets, config, 'gsm') + change_secrets_in_one_setting(connection_secrets, config, 'cdma') + change_secrets_in_one_setting(connection_secrets, config, 'ppp') + +def find_connection(name): + # Ask the settings service for the list of connections it provides + global con_path + proxy = bus.get_object("org.freedesktop.NetworkManager", "/org/freedesktop/NetworkManager/Settings") + settings = dbus.Interface(proxy, "org.freedesktop.NetworkManager.Settings") + connection_paths = settings.ListConnections() + + # Get the settings and look for connection's name + for path in connection_paths: + con_proxy = bus.get_object("org.freedesktop.NetworkManager", path) + connection = dbus.Interface(con_proxy, "org.freedesktop.NetworkManager.Settings.Connection") + try: + config = connection.GetSettings() + except Exception, e: + pass + + # Find connection by the id + s_con = config['connection'] + if name == s_con['id']: + con_path = path + return config + # Find connection by the uuid + if name == s_con['uuid']: + con_path = path + return config + + return None + + +# Main part +con_path = None + +if len(sys.argv) != 2: + sys.exit("Usage: %s <connection name/uuid>" % sys.argv[0]) + +# Find the connection +con = find_connection(sys.argv[1]) + +print "Connection found: ", con_path + +if con: + # Obtain new secrets and put then into connection dict + change_secrets(con_path, con) + + # Change the connection with Update() + proxy = bus.get_object("org.freedesktop.NetworkManager", con_path) + settings = dbus.Interface(proxy, "org.freedesktop.NetworkManager.Settings.Connection") + settings.Update(con) +else: + sys.exit("No connection '%s' found" % sys.argv[1]) + diff --git a/examples/python/dbus/vpn.py b/examples/python/dbus/vpn.py new file mode 100755 index 000000000..59773a61f --- /dev/null +++ b/examples/python/dbus/vpn.py @@ -0,0 +1,152 @@ +#!/usr/bin/env python +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License along +# with this program; if not, write to the Free Software Foundation, Inc., +# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. +# +# Copyright (C) 2009 Novell, Inc. +# Copyright (C) 2009 Red Hat, Inc. +# + +# Run this script without any arguments to list the available connection uuids. + +# The uuid of the connection to activate +CONNECTION_UUID="ac6dc9b2-85ef-4311-83d8-add5d7db3f59" + +# UID to use. Note that NM only allows the owner of the connection to activate it. +#UID=1000 +UID=0 + +import sys +import os +import dbus +from dbus.mainloop.glib import DBusGMainLoop +import gobject + +DBusGMainLoop(set_as_default=True) + +def get_connections(): + bus = dbus.SystemBus() + proxy = bus.get_object('org.freedesktop.NetworkManager', '/org/freedesktop/NetworkManager/Settings') + iface = dbus.Interface(proxy, dbus_interface='org.freedesktop.NetworkManager.Settings') + return iface.ListConnections() + + +def get_connection_by_uuid(uuid): + bus = dbus.SystemBus() + for c in get_connections(): + proxy = bus.get_object('org.freedesktop.NetworkManager', c) + iface = dbus.Interface(proxy, dbus_interface='org.freedesktop.NetworkManager.Settings.Connection') + settings = iface.GetSettings() + if settings['connection']['uuid'] == uuid: + return c + + return None + + +def list_uuids(): + bus = dbus.SystemBus() + for c in get_connections(): + proxy = bus.get_object('org.freedesktop.NetworkManager', c) + iface = dbus.Interface(proxy, dbus_interface='org.freedesktop.NetworkManager.Settings.Connection') + settings = iface.GetSettings() + conn = settings['connection'] + print "%s - %s (%s)" % (conn['uuid'], conn['id'], conn['type']) + + +def get_active_connection_path(uuid): + bus = dbus.SystemBus() + proxy = bus.get_object('org.freedesktop.NetworkManager', '/org/freedesktop/NetworkManager') + iface = dbus.Interface(proxy, dbus_interface='org.freedesktop.DBus.Properties') + active_connections = iface.Get('org.freedesktop.NetworkManager', 'ActiveConnections') + all_connections = get_connections() + + for a in active_connections: + proxy = bus.get_object('org.freedesktop.NetworkManager', a) + iface = dbus.Interface(proxy, dbus_interface='org.freedesktop.DBus.Properties') + path = iface.Get('org.freedesktop.NetworkManager.Connection.Active', 'Connection') + + proxy = bus.get_object('org.freedesktop.NetworkManager', path) + iface = dbus.Interface(proxy, dbus_interface='org.freedesktop.NetworkManager.Settings.Connection') + settings = iface.GetSettings() + + if settings['connection']['uuid'] == uuid: + return a + + return None + + +def get_wifi_device_path(): + bus = dbus.SystemBus() + proxy = bus.get_object('org.freedesktop.NetworkManager', '/org/freedesktop/NetworkManager') + iface = dbus.Interface(proxy, dbus_interface='org.freedesktop.NetworkManager') + devices = iface.GetDevices() + for d in devices: + proxy = bus.get_object('org.freedesktop.NetworkManager', d) + iface = dbus.Interface(proxy, dbus_interface='org.freedesktop.DBus.Properties') + devtype = iface.Get('org.freedesktop.NetworkManager.Device', 'DeviceType') + if devtype == 2: + return d + return None + +def activate_connection(connection_path, device_path): + + def reply_handler(opath): + print "Success: device activating" + sys.exit(0) + + def error_handler(*args): + print "Error activating device: %s" % args + sys.exit(1) + + bus = dbus.SystemBus() + proxy = bus.get_object('org.freedesktop.NetworkManager', '/org/freedesktop/NetworkManager') + iface = dbus.Interface(proxy, dbus_interface='org.freedesktop.NetworkManager') + iface.ActivateConnection('org.freedesktop.NetworkManager', + connection_path, + device_path, + "/", + reply_handler=reply_handler, + error_handler=error_handler) + + +# Change the UID first if required +if UID != 0: + os.setuid(UID) + +# Are we configured? +if not len(CONNECTION_UUID): + print "missing connection UUID" + sys.exit(0) + +connection_path = get_connection_by_uuid(CONNECTION_UUID) +if not connection_path: + # Configured VPN connection is not known to NM, check CONNECTION_UUID. + print "couldn't find the connection" + sys.exit(1) + +device_path = get_wifi_device_path() +if not device_path: + print "no wifi device found" + sys.exit(1) + +# Is it already activated? +if get_active_connection_path(CONNECTION_UUID): + print "already connected" + sys.exit(0) + +print "Activating connection..." +activate_connection(connection_path, device_path) +loop = gobject.MainLoop() +loop.run() + diff --git a/examples/python/gi/Makefile.am b/examples/python/gi/Makefile.am new file mode 100644 index 000000000..dcf2dff09 --- /dev/null +++ b/examples/python/gi/Makefile.am @@ -0,0 +1,9 @@ +EXTRA_DIST = \ + list-connections.py \ + device-state-ip4config.py \ + firewall-zone.py \ + show-wifi-networks.py \ + get_ips.py \ + add_connection.py \ + get-active-connections.py \ + update-ip4-method.py diff --git a/examples/python/gi/Makefile.in b/examples/python/gi/Makefile.in new file mode 100644 index 000000000..8ea13b18d --- /dev/null +++ b/examples/python/gi/Makefile.in @@ -0,0 +1,582 @@ +# Makefile.in generated by automake 1.13.4 from Makefile.am. +# @configure_input@ + +# Copyright (C) 1994-2013 Free Software Foundation, Inc. + +# This Makefile.in is free software; the Free Software Foundation +# gives unlimited permission to copy and/or distribute it, +# with or without modifications, as long as this notice is preserved. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY, to the extent permitted by law; without +# even the implied warranty of MERCHANTABILITY or FITNESS FOR A +# PARTICULAR PURPOSE. + +@SET_MAKE@ +VPATH = @srcdir@ +am__is_gnu_make = test -n '$(MAKEFILE_LIST)' && test -n '$(MAKELEVEL)' +am__make_running_with_option = \ + case $${target_option-} in \ + ?) ;; \ + *) echo "am__make_running_with_option: internal error: invalid" \ + "target option '$${target_option-}' specified" >&2; \ + exit 1;; \ + esac; \ + has_opt=no; \ + sane_makeflags=$$MAKEFLAGS; \ + if $(am__is_gnu_make); then \ + sane_makeflags=$$MFLAGS; \ + else \ + case $$MAKEFLAGS in \ + *\\[\ \ ]*) \ + bs=\\; \ + sane_makeflags=`printf '%s\n' "$$MAKEFLAGS" \ + | sed "s/$$bs$$bs[$$bs $$bs ]*//g"`;; \ + esac; \ + fi; \ + skip_next=no; \ + strip_trailopt () \ + { \ + flg=`printf '%s\n' "$$flg" | sed "s/$$1.*$$//"`; \ + }; \ + for flg in $$sane_makeflags; do \ + test $$skip_next = yes && { skip_next=no; continue; }; \ + case $$flg in \ + *=*|--*) continue;; \ + -*I) strip_trailopt 'I'; skip_next=yes;; \ + -*I?*) strip_trailopt 'I';; \ + -*O) strip_trailopt 'O'; skip_next=yes;; \ + -*O?*) strip_trailopt 'O';; \ + -*l) strip_trailopt 'l'; skip_next=yes;; \ + -*l?*) strip_trailopt 'l';; \ + -[dEDm]) skip_next=yes;; \ + -[JT]) skip_next=yes;; \ + esac; \ + case $$flg in \ + *$$target_option*) has_opt=yes; break;; \ + esac; \ + done; \ + test $$has_opt = yes +am__make_dryrun = (target_option=n; $(am__make_running_with_option)) +am__make_keepgoing = (target_option=k; $(am__make_running_with_option)) +pkgdatadir = $(datadir)/@PACKAGE@ +pkgincludedir = $(includedir)/@PACKAGE@ +pkglibdir = $(libdir)/@PACKAGE@ +pkglibexecdir = $(libexecdir)/@PACKAGE@ +am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd +install_sh_DATA = $(install_sh) -c -m 644 +install_sh_PROGRAM = $(install_sh) -c +install_sh_SCRIPT = $(install_sh) -c +INSTALL_HEADER = $(INSTALL_DATA) +transform = $(program_transform_name) +NORMAL_INSTALL = : +PRE_INSTALL = : +POST_INSTALL = : +NORMAL_UNINSTALL = : +PRE_UNINSTALL = : +POST_UNINSTALL = : +build_triplet = @build@ +host_triplet = @host@ +subdir = examples/python/gi +DIST_COMMON = $(srcdir)/Makefile.in $(srcdir)/Makefile.am +ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 +am__aclocal_m4_deps = $(top_srcdir)/m4/ax_lib_readline.m4 \ + $(top_srcdir)/m4/compiler_warnings.m4 \ + $(top_srcdir)/m4/gettext.m4 \ + $(top_srcdir)/m4/gnome-code-coverage.m4 \ + $(top_srcdir)/m4/gtk-doc.m4 $(top_srcdir)/m4/iconv.m4 \ + $(top_srcdir)/m4/intlmacosx.m4 $(top_srcdir)/m4/intltool.m4 \ + $(top_srcdir)/m4/introspection.m4 $(top_srcdir)/m4/lib-ld.m4 \ + $(top_srcdir)/m4/lib-link.m4 $(top_srcdir)/m4/lib-prefix.m4 \ + $(top_srcdir)/m4/libtool.m4 $(top_srcdir)/m4/ltoptions.m4 \ + $(top_srcdir)/m4/ltsugar.m4 $(top_srcdir)/m4/ltversion.m4 \ + $(top_srcdir)/m4/lt~obsolete.m4 $(top_srcdir)/m4/nls.m4 \ + $(top_srcdir)/m4/po.m4 $(top_srcdir)/m4/progtest.m4 \ + $(top_srcdir)/m4/vapigen.m4 $(top_srcdir)/configure.ac +am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ + $(ACLOCAL_M4) +mkinstalldirs = $(install_sh) -d +CONFIG_HEADER = $(top_builddir)/config.h +CONFIG_CLEAN_FILES = +CONFIG_CLEAN_VPATH_FILES = +AM_V_P = $(am__v_P_@AM_V@) +am__v_P_ = $(am__v_P_@AM_DEFAULT_V@) +am__v_P_0 = false +am__v_P_1 = : +AM_V_GEN = $(am__v_GEN_@AM_V@) +am__v_GEN_ = $(am__v_GEN_@AM_DEFAULT_V@) +am__v_GEN_0 = @echo " GEN " $@; +am__v_GEN_1 = +AM_V_at = $(am__v_at_@AM_V@) +am__v_at_ = $(am__v_at_@AM_DEFAULT_V@) +am__v_at_0 = @ +am__v_at_1 = +SOURCES = +DIST_SOURCES = +am__can_run_installinfo = \ + case $$AM_UPDATE_INFO_DIR in \ + n|no|NO) false;; \ + *) (install-info --version) >/dev/null 2>&1;; \ + esac +am__tagged_files = $(HEADERS) $(SOURCES) $(TAGS_FILES) $(LISP) +DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) +ACLOCAL = @ACLOCAL@ +ALL_LINGUAS = @ALL_LINGUAS@ +AMTAR = @AMTAR@ +AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@ +AR = @AR@ +AUTOCONF = @AUTOCONF@ +AUTOHEADER = @AUTOHEADER@ +AUTOMAKE = @AUTOMAKE@ +AWK = @AWK@ +CC = @CC@ +CCDEPMODE = @CCDEPMODE@ +CFLAGS = @CFLAGS@ +CKDB_PATH = @CKDB_PATH@ +CODE_COVERAGE_CFLAGS = @CODE_COVERAGE_CFLAGS@ +CODE_COVERAGE_ENABLED = @CODE_COVERAGE_ENABLED@ +CODE_COVERAGE_LDFLAGS = @CODE_COVERAGE_LDFLAGS@ +CPP = @CPP@ +CPPFLAGS = @CPPFLAGS@ +CXX = @CXX@ +CXXCPP = @CXXCPP@ +CXXDEPMODE = @CXXDEPMODE@ +CXXFLAGS = @CXXFLAGS@ +CYGPATH_W = @CYGPATH_W@ +DATADIRNAME = @DATADIRNAME@ +DBUS_CFLAGS = @DBUS_CFLAGS@ +DBUS_GLIB_100_CFLAGS = @DBUS_GLIB_100_CFLAGS@ +DBUS_GLIB_100_LIBS = @DBUS_GLIB_100_LIBS@ +DBUS_LIBS = @DBUS_LIBS@ +DBUS_SYS_DIR = @DBUS_SYS_DIR@ +DEFS = @DEFS@ +DEPDIR = @DEPDIR@ +DHCLIENT_PATH = @DHCLIENT_PATH@ +DHCPCD_PATH = @DHCPCD_PATH@ +DISTRO_NETWORK_SERVICE = @DISTRO_NETWORK_SERVICE@ +DLLTOOL = @DLLTOOL@ +DNSMASQ_PATH = @DNSMASQ_PATH@ +DSYMUTIL = @DSYMUTIL@ +DUMPBIN = @DUMPBIN@ +ECHO_C = @ECHO_C@ +ECHO_N = @ECHO_N@ +ECHO_T = @ECHO_T@ +EGREP = @EGREP@ +EXEEXT = @EXEEXT@ +FGREP = @FGREP@ +GENHTML = @GENHTML@ +GETTEXT_MACRO_VERSION = @GETTEXT_MACRO_VERSION@ +GETTEXT_PACKAGE = @GETTEXT_PACKAGE@ +GLIB_CFLAGS = @GLIB_CFLAGS@ +GLIB_GENMARSHAL = @GLIB_GENMARSHAL@ +GLIB_LIBS = @GLIB_LIBS@ +GLIB_MAKEFILE = @GLIB_MAKEFILE@ +GLIB_MKENUMS = @GLIB_MKENUMS@ +GMSGFMT = @GMSGFMT@ +GMSGFMT_015 = @GMSGFMT_015@ +GNUTLS_CFLAGS = @GNUTLS_CFLAGS@ +GNUTLS_LIBS = @GNUTLS_LIBS@ +GREP = @GREP@ +GTKDOC_CHECK = @GTKDOC_CHECK@ +GTKDOC_DEPS_CFLAGS = @GTKDOC_DEPS_CFLAGS@ +GTKDOC_DEPS_LIBS = @GTKDOC_DEPS_LIBS@ +GTKDOC_MKPDF = @GTKDOC_MKPDF@ +GTKDOC_REBASE = @GTKDOC_REBASE@ +GUDEV_CFLAGS = @GUDEV_CFLAGS@ +GUDEV_LIBS = @GUDEV_LIBS@ +HTML_DIR = @HTML_DIR@ +INSTALL = @INSTALL@ +INSTALL_DATA = @INSTALL_DATA@ +INSTALL_PROGRAM = @INSTALL_PROGRAM@ +INSTALL_SCRIPT = @INSTALL_SCRIPT@ +INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ +INTLLIBS = @INTLLIBS@ +INTLTOOL_EXTRACT = @INTLTOOL_EXTRACT@ +INTLTOOL_MERGE = @INTLTOOL_MERGE@ +INTLTOOL_PERL = @INTLTOOL_PERL@ +INTLTOOL_UPDATE = @INTLTOOL_UPDATE@ +INTLTOOL_V_MERGE = @INTLTOOL_V_MERGE@ +INTLTOOL_V_MERGE_OPTIONS = @INTLTOOL_V_MERGE_OPTIONS@ +INTLTOOL__v_MERGE_ = @INTLTOOL__v_MERGE_@ +INTLTOOL__v_MERGE_0 = @INTLTOOL__v_MERGE_0@ +INTL_MACOSX_LIBS = @INTL_MACOSX_LIBS@ +INTROSPECTION_CFLAGS = @INTROSPECTION_CFLAGS@ +INTROSPECTION_COMPILER = @INTROSPECTION_COMPILER@ +INTROSPECTION_GENERATE = @INTROSPECTION_GENERATE@ +INTROSPECTION_GIRDIR = @INTROSPECTION_GIRDIR@ +INTROSPECTION_LIBS = @INTROSPECTION_LIBS@ +INTROSPECTION_MAKEFILE = @INTROSPECTION_MAKEFILE@ +INTROSPECTION_SCANNER = @INTROSPECTION_SCANNER@ +INTROSPECTION_TYPELIBDIR = @INTROSPECTION_TYPELIBDIR@ +IPTABLES_PATH = @IPTABLES_PATH@ +IWMX_SDK_CFLAGS = @IWMX_SDK_CFLAGS@ +IWMX_SDK_LIBS = @IWMX_SDK_LIBS@ +KERNEL_FIRMWARE_DIR = @KERNEL_FIRMWARE_DIR@ +LCOV = @LCOV@ +LD = @LD@ +LDFLAGS = @LDFLAGS@ +LIBDL = @LIBDL@ +LIBGCRYPT_CFLAGS = @LIBGCRYPT_CFLAGS@ +LIBGCRYPT_CONFIG = @LIBGCRYPT_CONFIG@ +LIBGCRYPT_LIBS = @LIBGCRYPT_LIBS@ +LIBICONV = @LIBICONV@ +LIBINTL = @LIBINTL@ +LIBM = @LIBM@ +LIBNDP_CFLAGS = @LIBNDP_CFLAGS@ +LIBNDP_LIBS = @LIBNDP_LIBS@ +LIBNL_CFLAGS = @LIBNL_CFLAGS@ +LIBNL_LIBS = @LIBNL_LIBS@ +LIBOBJS = @LIBOBJS@ +LIBS = @LIBS@ +LIBSOUP_CFLAGS = @LIBSOUP_CFLAGS@ +LIBSOUP_LIBS = @LIBSOUP_LIBS@ +LIBTEAMDCTL_CFLAGS = @LIBTEAMDCTL_CFLAGS@ +LIBTEAMDCTL_LIBS = @LIBTEAMDCTL_LIBS@ +LIBTOOL = @LIBTOOL@ +LIPO = @LIPO@ +LN_S = @LN_S@ +LTLIBICONV = @LTLIBICONV@ +LTLIBINTL = @LTLIBINTL@ +LTLIBOBJS = @LTLIBOBJS@ +MAINT = @MAINT@ +MAKEINFO = @MAKEINFO@ +MANIFEST_TOOL = @MANIFEST_TOOL@ +MKDIR_P = @MKDIR_P@ +MM_GLIB_CFLAGS = @MM_GLIB_CFLAGS@ +MM_GLIB_LIBS = @MM_GLIB_LIBS@ +MOC = @MOC@ +MSGFMT = @MSGFMT@ +MSGFMT_015 = @MSGFMT_015@ +MSGMERGE = @MSGMERGE@ +NEWT_CFLAGS = @NEWT_CFLAGS@ +NEWT_LIBS = @NEWT_LIBS@ +NM = @NM@ +NMEDIT = @NMEDIT@ +NM_MAJOR_VERSION = @NM_MAJOR_VERSION@ +NM_MICRO_VERSION = @NM_MICRO_VERSION@ +NM_MINOR_VERSION = @NM_MINOR_VERSION@ +NM_MODIFY_SYSTEM_POLICY = @NM_MODIFY_SYSTEM_POLICY@ +NM_VERSION = @NM_VERSION@ +NSS_CFLAGS = @NSS_CFLAGS@ +NSS_LIBS = @NSS_LIBS@ +OBJDUMP = @OBJDUMP@ +OBJEXT = @OBJEXT@ +OTOOL = @OTOOL@ +OTOOL64 = @OTOOL64@ +PACKAGE = @PACKAGE@ +PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@ +PACKAGE_NAME = @PACKAGE_NAME@ +PACKAGE_STRING = @PACKAGE_STRING@ +PACKAGE_TARNAME = @PACKAGE_TARNAME@ +PACKAGE_URL = @PACKAGE_URL@ +PACKAGE_VERSION = @PACKAGE_VERSION@ +PATH_SEPARATOR = @PATH_SEPARATOR@ +PKG_CONFIG = @PKG_CONFIG@ +PKG_CONFIG_LIBDIR = @PKG_CONFIG_LIBDIR@ +PKG_CONFIG_PATH = @PKG_CONFIG_PATH@ +POLKIT_CFLAGS = @POLKIT_CFLAGS@ +POLKIT_LIBS = @POLKIT_LIBS@ +POSUB = @POSUB@ +PPPD_PATH = @PPPD_PATH@ +PPPD_PLUGIN_DIR = @PPPD_PLUGIN_DIR@ +PPPOE_PATH = @PPPOE_PATH@ +QT_CFLAGS = @QT_CFLAGS@ +QT_LIBS = @QT_LIBS@ +RANLIB = @RANLIB@ +READLINE_LIBS = @READLINE_LIBS@ +SED = @SED@ +SELINUX_CFLAGS = @SELINUX_CFLAGS@ +SELINUX_LIBS = @SELINUX_LIBS@ +SET_MAKE = @SET_MAKE@ +SHELL = @SHELL@ +STRIP = @STRIP@ +SYSTEMD_200_CFLAGS = @SYSTEMD_200_CFLAGS@ +SYSTEMD_200_LIBS = @SYSTEMD_200_LIBS@ +SYSTEMD_INHIBIT_CFLAGS = @SYSTEMD_INHIBIT_CFLAGS@ +SYSTEMD_INHIBIT_LIBS = @SYSTEMD_INHIBIT_LIBS@ +SYSTEMD_LOGIN_CFLAGS = @SYSTEMD_LOGIN_CFLAGS@ +SYSTEMD_LOGIN_LIBS = @SYSTEMD_LOGIN_LIBS@ +SYSTEM_CA_PATH = @SYSTEM_CA_PATH@ +UDEV_BASE_DIR = @UDEV_BASE_DIR@ +USE_NLS = @USE_NLS@ +UUID_CFLAGS = @UUID_CFLAGS@ +UUID_LIBS = @UUID_LIBS@ +VALGRIND_RULES = @VALGRIND_RULES@ +VAPIGEN = @VAPIGEN@ +VAPIGEN_MAKEFILE = @VAPIGEN_MAKEFILE@ +VAPIGEN_VAPIDIR = @VAPIGEN_VAPIDIR@ +VERSION = @VERSION@ +XGETTEXT = @XGETTEXT@ +XGETTEXT_015 = @XGETTEXT_015@ +XGETTEXT_EXTRA_OPTIONS = @XGETTEXT_EXTRA_OPTIONS@ +abs_builddir = @abs_builddir@ +abs_srcdir = @abs_srcdir@ +abs_top_builddir = @abs_top_builddir@ +abs_top_srcdir = @abs_top_srcdir@ +ac_ct_AR = @ac_ct_AR@ +ac_ct_CC = @ac_ct_CC@ +ac_ct_CXX = @ac_ct_CXX@ +ac_ct_DUMPBIN = @ac_ct_DUMPBIN@ +am__include = @am__include@ +am__leading_dot = @am__leading_dot@ +am__quote = @am__quote@ +am__tar = @am__tar@ +am__untar = @am__untar@ +bindir = @bindir@ +build = @build@ +build_alias = @build_alias@ +build_cpu = @build_cpu@ +build_os = @build_os@ +build_vendor = @build_vendor@ +builddir = @builddir@ +datadir = @datadir@ +datarootdir = @datarootdir@ +docdir = @docdir@ +dvidir = @dvidir@ +exec_prefix = @exec_prefix@ +host = @host@ +host_alias = @host_alias@ +host_cpu = @host_cpu@ +host_os = @host_os@ +host_vendor = @host_vendor@ +htmldir = @htmldir@ +includedir = @includedir@ +infodir = @infodir@ +install_sh = @install_sh@ +intltool__v_merge_options_ = @intltool__v_merge_options_@ +intltool__v_merge_options_0 = @intltool__v_merge_options_0@ +libdir = @libdir@ +libexecdir = @libexecdir@ +localedir = @localedir@ +localstatedir = @localstatedir@ +mandir = @mandir@ +mkdir_p = @mkdir_p@ +nmbinary = @nmbinary@ +nmconfdir = @nmconfdir@ +nmdatadir = @nmdatadir@ +nmrundir = @nmrundir@ +nmstatedir = @nmstatedir@ +oldincludedir = @oldincludedir@ +pdfdir = @pdfdir@ +prefix = @prefix@ +program_transform_name = @program_transform_name@ +psdir = @psdir@ +sbindir = @sbindir@ +sharedstatedir = @sharedstatedir@ +srcdir = @srcdir@ +subdirs = @subdirs@ +sysconfdir = @sysconfdir@ +systemdsystemunitdir = @systemdsystemunitdir@ +target_alias = @target_alias@ +top_build_prefix = @top_build_prefix@ +top_builddir = @top_builddir@ +top_srcdir = @top_srcdir@ +with_dhclient = @with_dhclient@ +with_dhcpcd = @with_dhcpcd@ +with_netconfig = @with_netconfig@ +with_resolvconf = @with_resolvconf@ +with_valgrind = @with_valgrind@ +EXTRA_DIST = \ + list-connections.py \ + device-state-ip4config.py \ + firewall-zone.py \ + show-wifi-networks.py \ + get_ips.py \ + add_connection.py \ + get-active-connections.py \ + update-ip4-method.py + +all: all-am + +.SUFFIXES: +$(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.am $(am__configure_deps) + @for dep in $?; do \ + case '$(am__configure_deps)' in \ + *$$dep*) \ + ( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \ + && { if test -f $@; then exit 0; else break; fi; }; \ + exit 1;; \ + esac; \ + done; \ + echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu examples/python/gi/Makefile'; \ + $(am__cd) $(top_srcdir) && \ + $(AUTOMAKE) --gnu examples/python/gi/Makefile +.PRECIOUS: Makefile +Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status + @case '$?' in \ + *config.status*) \ + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \ + *) \ + echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \ + cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \ + esac; + +$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES) + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh + +$(top_srcdir)/configure: @MAINTAINER_MODE_TRUE@ $(am__configure_deps) + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh +$(ACLOCAL_M4): @MAINTAINER_MODE_TRUE@ $(am__aclocal_m4_deps) + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh +$(am__aclocal_m4_deps): + +mostlyclean-libtool: + -rm -f *.lo + +clean-libtool: + -rm -rf .libs _libs +tags TAGS: + +ctags CTAGS: + +cscope cscopelist: + + +distdir: $(DISTFILES) + @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ + topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ + list='$(DISTFILES)'; \ + dist_files=`for file in $$list; do echo $$file; done | \ + sed -e "s|^$$srcdirstrip/||;t" \ + -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \ + case $$dist_files in \ + */*) $(MKDIR_P) `echo "$$dist_files" | \ + sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \ + sort -u` ;; \ + esac; \ + for file in $$dist_files; do \ + if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \ + if test -d $$d/$$file; then \ + dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \ + if test -d "$(distdir)/$$file"; then \ + find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ + fi; \ + if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \ + cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \ + find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ + fi; \ + cp -fpR $$d/$$file "$(distdir)$$dir" || exit 1; \ + else \ + test -f "$(distdir)/$$file" \ + || cp -p $$d/$$file "$(distdir)/$$file" \ + || exit 1; \ + fi; \ + done +check-am: all-am +check: check-am +all-am: Makefile +installdirs: +install: install-am +install-exec: install-exec-am +install-data: install-data-am +uninstall: uninstall-am + +install-am: all-am + @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am + +installcheck: installcheck-am +install-strip: + if test -z '$(STRIP)'; then \ + $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ + install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ + install; \ + else \ + $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ + install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ + "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'" install; \ + fi +mostlyclean-generic: + +clean-generic: + +distclean-generic: + -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES) + -test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES) + +maintainer-clean-generic: + @echo "This command is intended for maintainers to use" + @echo "it deletes files that may require special tools to rebuild." +clean: clean-am + +clean-am: clean-generic clean-libtool mostlyclean-am + +distclean: distclean-am + -rm -f Makefile +distclean-am: clean-am distclean-generic + +dvi: dvi-am + +dvi-am: + +html: html-am + +html-am: + +info: info-am + +info-am: + +install-data-am: + +install-dvi: install-dvi-am + +install-dvi-am: + +install-exec-am: + +install-html: install-html-am + +install-html-am: + +install-info: install-info-am + +install-info-am: + +install-man: + +install-pdf: install-pdf-am + +install-pdf-am: + +install-ps: install-ps-am + +install-ps-am: + +installcheck-am: + +maintainer-clean: maintainer-clean-am + -rm -f Makefile +maintainer-clean-am: distclean-am maintainer-clean-generic + +mostlyclean: mostlyclean-am + +mostlyclean-am: mostlyclean-generic mostlyclean-libtool + +pdf: pdf-am + +pdf-am: + +ps: ps-am + +ps-am: + +uninstall-am: + +.MAKE: install-am install-strip + +.PHONY: all all-am check check-am clean clean-generic clean-libtool \ + cscopelist-am ctags-am distclean distclean-generic \ + distclean-libtool distdir dvi dvi-am html html-am info info-am \ + install install-am install-data install-data-am install-dvi \ + install-dvi-am install-exec install-exec-am install-html \ + install-html-am install-info install-info-am install-man \ + install-pdf install-pdf-am install-ps install-ps-am \ + install-strip installcheck installcheck-am installdirs \ + maintainer-clean maintainer-clean-generic mostlyclean \ + mostlyclean-generic mostlyclean-libtool pdf pdf-am ps ps-am \ + tags-am uninstall uninstall-am + + +# Tell versions [3.59,3.63) of GNU make to not export all variables. +# Otherwise a system limit (for SysV at least) may be exceeded. +.NOEXPORT: diff --git a/examples/python/gi/add_connection.py b/examples/python/gi/add_connection.py new file mode 100755 index 000000000..76c2e94e6 --- /dev/null +++ b/examples/python/gi/add_connection.py @@ -0,0 +1,101 @@ +#!/usr/bin/env python +# -*- Mode: Python; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License along +# with this program; if not, write to the Free Software Foundation, Inc., +# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. +# +# Copyright (C) 2014 Red Hat, Inc. +# + +# +# This example shows how to add a new NM connection profile. +# The code uses libnm-util (NetworkManager) and libnm-glib (NMClient) +# via GObject Introspection. +# +# Documentation links: +# https://developer.gnome.org/libnm-glib/0.9/ +# https://developer.gnome.org/libnm-util/0.9/ +# https://developer.gnome.org/NetworkManager/0.9/ref-settings.html +# + +from gi.repository import GLib, NetworkManager, NMClient +import sys, uuid + +main_loop = None + +def print_values(setting, key, value, flags, data): + print " %s.%s: %s" % (setting.get_name(), key, value) + +# create an Ethernet connection and return it +def create_profile(name): + profile = NetworkManager.Connection.new() + s_con = NetworkManager.SettingConnection.new() + s_con.set_property(NetworkManager.SETTING_CONNECTION_ID, name) + s_con.set_property(NetworkManager.SETTING_CONNECTION_UUID, str(uuid.uuid4())) + s_con.set_property(NetworkManager.SETTING_CONNECTION_TYPE, "802-3-ethernet") + + s_wired = NetworkManager.SettingWired.new() + + s_ip4 = NetworkManager.SettingIP4Config.new() + s_ip4.set_property(NetworkManager.SETTING_IP4_CONFIG_METHOD, "auto") + + s_ip6 = NetworkManager.SettingIP6Config.new() + s_ip6.set_property(NetworkManager.SETTING_IP6_CONFIG_METHOD, "auto") + + profile.add_setting(s_con) + profile.add_setting(s_ip4) + profile.add_setting(s_ip6) + profile.add_setting(s_wired) + + print("Created connection profile:") + profile.for_each_setting_value(print_values, None) + + return profile + +# callback function +def added_cb(settings, con, error, data): + if error is (None): + print("The connection profile has been succesfully added to NetworkManager.") + else: + print(error) + main_loop.quit() + +if __name__ == "__main__": + # parse arguments + persistent = False + if len(sys.argv) != 2 and len(sys.argv) != 3: + sys.exit('Usage: %s <connection name> [persistent]' % sys.argv[0]) + if len(sys.argv) == 3: + if sys.argv[2] in "persistent" and sys.argv[2][:1] == "p": + persistent = True + else: + sys.exit('Usage: %s <connection name> [persistent]' % sys.argv[0]) + profile_name = sys.argv[1] + + main_loop = GLib.MainLoop() + + # create RemoteSettings object + settings = NMClient.RemoteSettings.new(None); + + # create a connection profile for NM + con = create_profile(profile_name) + + # send the connection to NM + if persistent: + settings.add_connection(con, added_cb, None) + else: + settings.add_connection_unsaved(con, added_cb, None) + + main_loop.run() + diff --git a/examples/python/gi/device-state-ip4config.py b/examples/python/gi/device-state-ip4config.py new file mode 100755 index 000000000..be19b9966 --- /dev/null +++ b/examples/python/gi/device-state-ip4config.py @@ -0,0 +1,64 @@ +#!/usr/bin/env python +# +# vim: ft=python ts=4 sts=4 sw=4 et ai +# -*- Mode: Python; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License along +# with this program; if not, write to the Free Software Foundation, Inc., +# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. +# +# Copyright (C) 2012 Red Hat, Inc. +# + +import sys +from gi.repository import GLib, NetworkManager, NMClient + +# +# This example shows how to get NMIP4Config from NMDevice after it is activated. +# +# We listen to notify::ip4-config glib signal. This signal is trigered by D-Bus +# PropertiesChanged for IP4Config that comes after StateChanged for NMDevice. +# + +main_loop = None + +def do_notify(self, property): + print "notify: %s" % property + ip4cfg = self.get_ip4_config() + if ip4cfg is not None: + print "ip4-config: %s" % ip4cfg.get_path() + main_loop.quit() + +def state_changed(obj, arg1, arg2, arg3): + print "State changed: New: %d, Old: %d, Reason: %d" % (arg1, arg2, arg3) + # Device is connected + if arg1 == 100: + obj.connect('notify::ip4-config', do_notify) + + +if __name__ == "__main__": + if len(sys.argv) != 2: + sys.exit('Usage: %s <interface>' % sys.argv[0]) + dev_iface = sys.argv[1] + + c = NMClient.Client.new() + dev = c.get_device_by_iface(dev_iface) + if dev is None: + sys.exit('Device \'%s\' not found' % dev_iface) + print "Device: %s - %s" % (dev_iface, dev.get_device_type().value_name) + print "---------------------------------------" + + dev.connect('state-changed', state_changed) + main_loop = GLib.MainLoop() + main_loop.run() + diff --git a/examples/python/gi/firewall-zone.py b/examples/python/gi/firewall-zone.py new file mode 100755 index 000000000..5e5eea919 --- /dev/null +++ b/examples/python/gi/firewall-zone.py @@ -0,0 +1,87 @@ +#!/usr/bin/env python +# -*- Mode: Python; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- +# vim: ft=python ts=4 sts=4 sw=4 et ai +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License along +# with this program; if not, write to the Free Software Foundation, Inc., +# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. +# +# Copyright (C) 2013 Red Hat, Inc. +# + +import sys +from gi.repository import GLib, NetworkManager, NMClient + +# +# This example demonstrates how to get and change firewall zone in a +# connection. It uses GObject Introspection instead of direct D-Bus calls. +# 'zone' is a property of 'connection' setting in a connection. You can't +# get/set individual properties directly. Rather you ask for the whole +# connection, change a property and update the connection back into +# NetworkManager. +# If you used D-Bus calls, you would call GetSettings() and then Update(). +# +# Links: +# https://developer.gnome.org/libnm-glib/0.9/ +# https://wiki.gnome.org/GObjectIntrospection +# https://wiki.gnome.org/PyGObject +# + +main_loop = None + +def connection_saved(connection, error, data): + print ("Connection '%s' saved.") % (connection.get_id()) + main_loop.quit() + +def connections_read(settings, data): + con_name = sys.argv[1] + if len(sys.argv) == 3: + new_zone = sys.argv[2] + else: + new_zone = None + + found = False + connections = settings.list_connections() + for c in connections: + if c.get_id() == con_name or c.get_uuid() == con_name: + found = True + s_con = c.get_setting_connection() + if new_zone is None: + zone = s_con.get_zone() + if zone is not None: + print("'%s' zone is '%s'") % (c.get_id(), zone) + else: + print("'%s' zone is empty") % (c.get_id()) + main_loop.quit() + else: + s_con.set_property("zone", new_zone) + c.commit_changes(connection_saved, None) + print("'%s' zone set to '%s'") % (c.get_id(), new_zone) + break + if not found: + print ("Error: connection '%s' not found.") % (con_name) + main_loop.quit() + + +if __name__ == "__main__": + if len(sys.argv) != 2 and len(sys.argv) != 3: + sys.exit('Usage: %s <connection name or UUID> [new zone]' % sys.argv[0]) + + main_loop = GLib.MainLoop() + settings = NMClient.RemoteSettings.new(None); + + # Connections are read asynchronously, so we have to wait for the + # 'settings' object to tell us that all connections have been read. + settings.connect("connections-read", connections_read, None) + main_loop.run() + diff --git a/examples/python/gi/get-active-connections.py b/examples/python/gi/get-active-connections.py new file mode 100755 index 000000000..13f0b0310 --- /dev/null +++ b/examples/python/gi/get-active-connections.py @@ -0,0 +1,34 @@ +#!/usr/bin/env python +# vim: ft=python ts=4 sts=4 sw=4 et ai +# -*- Mode: python; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License along +# with this program; if not, write to the Free Software Foundation, Inc., +# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. +# +# Copyright (C) 2014 Red Hat, Inc. +# + +# This example lists currently active connections + +from gi.repository import GLib, NMClient + +if __name__ == "__main__": + client = NMClient.Client.new() + acons = client.get_active_connections() + for ac in acons: + print "%s (%s) - %s" % (ac.get_id(), ac.get_uuid(), ac.get_connection_type()) + if len(acons) == 0: + print "No active connections" + + diff --git a/examples/python/gi/get_ips.py b/examples/python/gi/get_ips.py new file mode 100755 index 000000000..6903b6de2 --- /dev/null +++ b/examples/python/gi/get_ips.py @@ -0,0 +1,163 @@ +#!/usr/bin/env python +# +# vim: ft=python ts=4 sts=4 sw=4 et ai +# -*- Mode: Python; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License along +# with this program; if not, write to the Free Software Foundation, Inc., +# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. +# +# Copyright (C) 2014 Red Hat, Inc. +# + +import sys, socket, struct +from gi.repository import GLib, NetworkManager, NMClient + +# +# This example shows how to get addresses, routes and DNS information +# from NMIP4Config and NMIP6Config (got out of NMDevice) +# + +def show_addresses(self, family): + if (family == socket.AF_INET): + ip_cfg = self.get_ip4_config() + else: + ip_cfg = self.get_ip6_config() + + if ip_cfg is None: + print("None") + return + + nm_addresses = ip_cfg.get_addresses() + if len(nm_addresses) == 0: + print("None") + return + + for nm_address in nm_addresses: + addr = nm_address.get_address() + prefix = nm_address.get_prefix() + gateway = nm_address.get_gateway() + + if (family == socket.AF_INET): + addr_struct = struct.pack("=I", addr) + gateway_struct = struct.pack("=I", gateway) + else: + addr_struct = addr + gateway_struct = gateway + print("%s/%d %s") % (socket.inet_ntop(family, addr_struct), + prefix, + socket.inet_ntop(family, gateway_struct)) + + +def show_routes(self, family): + if (family == socket.AF_INET): + ip_cfg = self.get_ip4_config() + else: + ip_cfg = self.get_ip6_config() + + if ip_cfg is None: + print("None") + return + + nm_routes = ip_cfg.get_routes() + if len(nm_routes) == 0: + print("None") + return + + for nm_route in nm_routes: + dest = nm_route.get_dest() + prefix = nm_route.get_prefix() + next_hop = nm_route.get_next_hop() + metric = nm_route.get_metric() + + if (family == socket.AF_INET): + dest_struct = struct.pack("=I", dest) + next_hop_struct = struct.pack("=I", next_hop) + else: + dest_struct = dest + next_hop_struct = next_hop + print("%s/%d %s %d") % (socket.inet_ntop(family, dest_struct), + prefix, + socket.inet_ntop(family, next_hop_struct), + metric) + + +def show_dns(self, family): + if (family == socket.AF_INET): + ip_cfg = self.get_ip4_config() + else: + ip_cfg = self.get_ip6_config() + + if ip_cfg is None: + print("None") + return + + if (family == socket.AF_INET): + print ("Domains: %s") % (ip_cfg.get_domains()) + print ("Searches: %s") % (ip_cfg.get_searches()) + print("Nameservers:") + nameservers = ip_cfg.get_nameservers() + for dns in nameservers: + print socket.inet_ntop(family, struct.pack("=I", dns)) + else: + print ("Domains: %s") % (ip_cfg.get_domains()) + print ("Searches: %s") % (ip_cfg.get_searches()) + print("Nameservers:") + num = ip_cfg.get_num_nameservers() + for i in range(0,num): + dns = ip_cfg.get_nameserver(i) + print socket.inet_ntop(family, dns) + + +if __name__ == "__main__": + if len(sys.argv) != 2: + sys.exit('Usage: %s <interface>' % sys.argv[0]) + dev_iface = sys.argv[1] + + c = NMClient.Client.new() + dev = c.get_device_by_iface(dev_iface) + if dev is None: + sys.exit('Device \'%s\' not found' % dev_iface) + print "Device: %s - %s" % (dev_iface, dev.get_device_type().value_name) + print "---------------------------------------" + + print("IPv4 addresses:") + print("---------------") + show_addresses(dev, socket.AF_INET) + print + + print("IPv4 routes:") + print("------------") + show_routes(dev, socket.AF_INET) + print + + print "IPv6 addresses:" + print("---------------") + show_addresses(dev, socket.AF_INET6) + print + + print "IPv6 routes:" + print("------------") + show_routes(dev, socket.AF_INET6) + print + + print "IPv4 DNS:" + print("------------") + show_dns(dev, socket.AF_INET) + print + + print "IPv6 DNS:" + print("------------") + show_dns(dev, socket.AF_INET6) + print + diff --git a/examples/python/gi/list-connections.py b/examples/python/gi/list-connections.py new file mode 100755 index 000000000..b6452d35a --- /dev/null +++ b/examples/python/gi/list-connections.py @@ -0,0 +1,50 @@ +#!/usr/bin/env python +# -*- Mode: Python; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License along +# with this program; if not, write to the Free Software Foundation, Inc., +# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. +# +# Copyright (C) 2012 Red Hat, Inc. +# + +from gi.repository import GLib, NetworkManager, NMClient + +# This example asks settings service for all configured connections. +# Unfortunately, at this time since libnm-glib still makes heavy use of +# GValue and GHashTable (rather than GVariant), libnm-glib isn't fully +# usable from GObject Introspection-ready languages. Most functions will +# work fine, but e. g. nm_connection_to_hash() causes assertion failures. + +main_loop = None + +def print_values(setting, key, value, flags, data): + print " %s.%s: %s" % (setting.get_name(), key, value) + +def connections_read(settings): + connections = settings.list_connections() + for c in connections: + print "--- %s : %s" % (c.get_id(), c.get_path()) + c.for_each_setting_value(print_values, None) + print "\n" + main_loop.quit() + +if __name__ == "__main__": + main_loop = GLib.MainLoop() + settings = NMClient.RemoteSettings.new(None); + + # connections are read asynchronously, so we need to wait for the + # settings object to tell us that it's read all connections + settings.connect("connections-read", connections_read) + main_loop.run() + diff --git a/examples/python/gi/show-wifi-networks.py b/examples/python/gi/show-wifi-networks.py new file mode 100755 index 000000000..9d9e34718 --- /dev/null +++ b/examples/python/gi/show-wifi-networks.py @@ -0,0 +1,73 @@ +#!/usr/bin/env python +# coding=utf-8 +# -*- Mode: Python; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- +# vim: ft=python ts=4 sts=4 sw=4 et ai +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License along +# with this program; if not, write to the Free Software Foundation, Inc., +# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. +# +# Copyright (C) 2013 Red Hat, Inc. +# + +from gi.repository import NetworkManager, NMClient + +# +# This example lists Wi-Fi access points NetworkManager scanned on Wi-Fi devices. +# It calls libnm-glib functions using GObject introspection. +# +# Note the second line of the file: coding=utf-8 +# It is necessary because we use unicode characters and python would produce +# an error without it: http://www.python.org/dev/peps/pep-0263/ +# + +signal_bars = { + 0 : "____", + 1 : "▂___", + 2 : "▂▄__", + 3 : "▂▄▆_", + 4 : "▂▄▆█" +} + +def clamp(value, minvalue, maxvalue): + return max(minvalue, min(value, maxvalue)) + +def print_device_info(device): + active_ap = dev.get_active_access_point() + ssid = None + if active_ap is not None: + ssid = active_ap.get_ssid() + info = "Device: %s | Driver: %s | Active AP: %s" % (dev.get_iface(), dev.get_driver(), ssid) + print info + print '=' * len(info) + +def print_ap_info(ap): + strength = ap.get_strength() + frequency = ap.get_frequency() + print "SSID: %s" % (ap.get_ssid()) + print "BSSID: %s" % (ap.get_bssid()) + print "Frequency: %s" % (frequency) + print "Channel: %s" % (NetworkManager.utils_wifi_freq_to_channel(frequency)) + print "Strength: %s %s%%" % (signal_bars[(clamp(strength-5, 0, 99)+24)/25], strength) + print + +if __name__ == "__main__": + nmc = NMClient.Client.new() + devs = nmc.get_devices() + + for dev in devs: + if dev.get_device_type() == NetworkManager.DeviceType.WIFI: + print_device_info(dev) + for ap in dev.get_access_points(): + print_ap_info(ap) + diff --git a/examples/python/gi/update-ip4-method.py b/examples/python/gi/update-ip4-method.py new file mode 100755 index 000000000..2fe12693b --- /dev/null +++ b/examples/python/gi/update-ip4-method.py @@ -0,0 +1,96 @@ +#!/usr/bin/env python +# -*- Mode: Python; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License along +# with this program; if not, write to the Free Software Foundation, Inc., +# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. +# +# Copyright (C) 2014 Red Hat, Inc. +# + +# +# This example updates a connection's IPv4 method with the Update() method +# using the libnm-glib GObject-based convenience APIs. +# +# Configuration settings are described at +# https://developer.gnome.org/NetworkManager/0.9/ref-settings.html +# + +from gi.repository import GLib, NetworkManager, NMClient +import sys, struct, socket + +def ip_to_int(ip_string): + return struct.unpack("=I", socket.inet_aton(ip_string))[0] + +# callback function +def commit_cb(connection, error, data): + if error is (None): + print("The connection profile has been updated.") + else: + print(error) + main_loop.quit() + +def connections_read_cb(settings, data): + uuid, method, args = data + + all_connections = settings.list_connections() + for c in all_connections: + if c.get_uuid() != uuid: + continue + + # add IPv4 setting if it doesn't yet exist + s_ip4 = c.get_setting_ip4_config() + if not s_ip4: + s_ip4 = NetworkManager.SettingIP4Config.new() + c.add_setting(s_ip4) + + # set the method and change properties + s_ip4.set_property(NetworkManager.SETTING_IP4_CONFIG_METHOD, method) + if method == "auto": + # remove addresses + s_ip4.clear_addresses() + elif method == "manual": + # Add the static IP address, prefix, and (optional) gateway + addr = NetworkManager.IP4Address.new() + addr.set_address(ip_to_int(sys.argv[3])) + addr.set_prefix(int(sys.argv[4])) + if len(sys.argv) == 6: + addr.set_gateway(ip_to_int(sys.argv[5])) + s_ip4.add_address(addr) + + c.commit_changes(commit_cb, None) + +if __name__ == "__main__": + # parse and validate arguments + if len(sys.argv) < 3: + print "Usage: %s <uuid> <auto|static> [address prefix gateway]" % sys.argv[0] + sys.exit(1) + + method = sys.argv[2] + if method == "static" and len(sys.argv) < 5: + print "Usage: %s %s static address prefix [gateway]" % (sys.argv[0], sys.argv[1]) + sys.exit(1) + + # Convert method to NM method + if method == "static": + method = "manual" + + main_loop = GLib.MainLoop() + + # create RemoteSettings object and attach to the "connections-read" signal + # to wait for connections to be loaded asynchronously + settings = NMClient.RemoteSettings.new(None) + settings.connect('connections-read', connections_read_cb, (sys.argv[1], method, sys.argv)) + + main_loop.run() + diff --git a/examples/ruby/Makefile.in b/examples/ruby/Makefile.in index 5213269d1..e9bff7858 100644 --- a/examples/ruby/Makefile.in +++ b/examples/ruby/Makefile.in @@ -80,7 +80,8 @@ host_triplet = @host@ subdir = examples/ruby DIST_COMMON = $(srcdir)/Makefile.in $(srcdir)/Makefile.am ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 -am__aclocal_m4_deps = $(top_srcdir)/m4/compiler_warnings.m4 \ +am__aclocal_m4_deps = $(top_srcdir)/m4/ax_lib_readline.m4 \ + $(top_srcdir)/m4/compiler_warnings.m4 \ $(top_srcdir)/m4/gettext.m4 \ $(top_srcdir)/m4/gnome-code-coverage.m4 \ $(top_srcdir)/m4/gtk-doc.m4 $(top_srcdir)/m4/iconv.m4 \ @@ -144,12 +145,15 @@ CXXFLAGS = @CXXFLAGS@ CYGPATH_W = @CYGPATH_W@ DATADIRNAME = @DATADIRNAME@ DBUS_CFLAGS = @DBUS_CFLAGS@ +DBUS_GLIB_100_CFLAGS = @DBUS_GLIB_100_CFLAGS@ +DBUS_GLIB_100_LIBS = @DBUS_GLIB_100_LIBS@ DBUS_LIBS = @DBUS_LIBS@ DBUS_SYS_DIR = @DBUS_SYS_DIR@ DEFS = @DEFS@ DEPDIR = @DEPDIR@ DHCLIENT_PATH = @DHCLIENT_PATH@ DHCPCD_PATH = @DHCPCD_PATH@ +DISTRO_NETWORK_SERVICE = @DISTRO_NETWORK_SERVICE@ DLLTOOL = @DLLTOOL@ DNSMASQ_PATH = @DNSMASQ_PATH@ DSYMUTIL = @DSYMUTIL@ @@ -174,7 +178,6 @@ GNUTLS_CFLAGS = @GNUTLS_CFLAGS@ GNUTLS_LIBS = @GNUTLS_LIBS@ GREP = @GREP@ GTKDOC_CHECK = @GTKDOC_CHECK@ -GTKDOC_CHECK_PATH = @GTKDOC_CHECK_PATH@ GTKDOC_DEPS_CFLAGS = @GTKDOC_DEPS_CFLAGS@ GTKDOC_DEPS_LIBS = @GTKDOC_DEPS_LIBS@ GTKDOC_MKPDF = @GTKDOC_MKPDF@ @@ -219,12 +222,16 @@ LIBGCRYPT_LIBS = @LIBGCRYPT_LIBS@ LIBICONV = @LIBICONV@ LIBINTL = @LIBINTL@ LIBM = @LIBM@ +LIBNDP_CFLAGS = @LIBNDP_CFLAGS@ +LIBNDP_LIBS = @LIBNDP_LIBS@ LIBNL_CFLAGS = @LIBNL_CFLAGS@ LIBNL_LIBS = @LIBNL_LIBS@ LIBOBJS = @LIBOBJS@ LIBS = @LIBS@ LIBSOUP_CFLAGS = @LIBSOUP_CFLAGS@ LIBSOUP_LIBS = @LIBSOUP_LIBS@ +LIBTEAMDCTL_CFLAGS = @LIBTEAMDCTL_CFLAGS@ +LIBTEAMDCTL_LIBS = @LIBTEAMDCTL_LIBS@ LIBTOOL = @LIBTOOL@ LIPO = @LIPO@ LN_S = @LN_S@ @@ -241,6 +248,8 @@ MOC = @MOC@ MSGFMT = @MSGFMT@ MSGFMT_015 = @MSGFMT_015@ MSGMERGE = @MSGMERGE@ +NEWT_CFLAGS = @NEWT_CFLAGS@ +NEWT_LIBS = @NEWT_LIBS@ NM = @NM@ NMEDIT = @NMEDIT@ NM_MAJOR_VERSION = @NM_MAJOR_VERSION@ @@ -268,11 +277,16 @@ PKG_CONFIG_PATH = @PKG_CONFIG_PATH@ POLKIT_CFLAGS = @POLKIT_CFLAGS@ POLKIT_LIBS = @POLKIT_LIBS@ POSUB = @POSUB@ +PPPD_PATH = @PPPD_PATH@ PPPD_PLUGIN_DIR = @PPPD_PLUGIN_DIR@ +PPPOE_PATH = @PPPOE_PATH@ QT_CFLAGS = @QT_CFLAGS@ QT_LIBS = @QT_LIBS@ RANLIB = @RANLIB@ +READLINE_LIBS = @READLINE_LIBS@ SED = @SED@ +SELINUX_CFLAGS = @SELINUX_CFLAGS@ +SELINUX_LIBS = @SELINUX_LIBS@ SET_MAKE = @SET_MAKE@ SHELL = @SHELL@ STRIP = @STRIP@ @@ -287,6 +301,7 @@ UDEV_BASE_DIR = @UDEV_BASE_DIR@ USE_NLS = @USE_NLS@ UUID_CFLAGS = @UUID_CFLAGS@ UUID_LIBS = @UUID_LIBS@ +VALGRIND_RULES = @VALGRIND_RULES@ VAPIGEN = @VAPIGEN@ VAPIGEN_MAKEFILE = @VAPIGEN_MAKEFILE@ VAPIGEN_VAPIDIR = @VAPIGEN_VAPIDIR@ @@ -349,6 +364,7 @@ psdir = @psdir@ sbindir = @sbindir@ sharedstatedir = @sharedstatedir@ srcdir = @srcdir@ +subdirs = @subdirs@ sysconfdir = @sysconfdir@ systemdsystemunitdir = @systemdsystemunitdir@ target_alias = @target_alias@ @@ -359,6 +375,7 @@ with_dhclient = @with_dhclient@ with_dhcpcd = @with_dhcpcd@ with_netconfig = @with_netconfig@ with_resolvconf = @with_resolvconf@ +with_valgrind = @with_valgrind@ EXTRA_DIST = \ add-connection.rb \ get-basic-nm-info.rb \ diff --git a/examples/ruby/list-devices.rb b/examples/ruby/list-devices.rb index a3bf90f5c..710ccedc0 100755 --- a/examples/ruby/list-devices.rb +++ b/examples/ruby/list-devices.rb @@ -25,6 +25,7 @@ require 'dbus' # This example lists basic information about network interfaces known to NM # +# For the types see include/NetworkManager.h devtypes = { 1 => "Ethernet", 2 => "Wi-Fi", 5 => "Bluetooth", @@ -34,7 +35,11 @@ devtypes = { 1 => "Ethernet", 9 => "InfiniBand", 10 => "Bond", 11 => "VLAN", - 12 => "ADSL" } + 12 => "ADSL", + 13 => "Bridge", + 14 => "Generic", + 15 => "Team" + } states = { 0 => "Unknown", 10 => "Unmanaged", diff --git a/examples/shell/Makefile.in b/examples/shell/Makefile.in index 55f4fb21c..d3a6bdfae 100644 --- a/examples/shell/Makefile.in +++ b/examples/shell/Makefile.in @@ -80,7 +80,8 @@ host_triplet = @host@ subdir = examples/shell DIST_COMMON = $(srcdir)/Makefile.in $(srcdir)/Makefile.am ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 -am__aclocal_m4_deps = $(top_srcdir)/m4/compiler_warnings.m4 \ +am__aclocal_m4_deps = $(top_srcdir)/m4/ax_lib_readline.m4 \ + $(top_srcdir)/m4/compiler_warnings.m4 \ $(top_srcdir)/m4/gettext.m4 \ $(top_srcdir)/m4/gnome-code-coverage.m4 \ $(top_srcdir)/m4/gtk-doc.m4 $(top_srcdir)/m4/iconv.m4 \ @@ -144,12 +145,15 @@ CXXFLAGS = @CXXFLAGS@ CYGPATH_W = @CYGPATH_W@ DATADIRNAME = @DATADIRNAME@ DBUS_CFLAGS = @DBUS_CFLAGS@ +DBUS_GLIB_100_CFLAGS = @DBUS_GLIB_100_CFLAGS@ +DBUS_GLIB_100_LIBS = @DBUS_GLIB_100_LIBS@ DBUS_LIBS = @DBUS_LIBS@ DBUS_SYS_DIR = @DBUS_SYS_DIR@ DEFS = @DEFS@ DEPDIR = @DEPDIR@ DHCLIENT_PATH = @DHCLIENT_PATH@ DHCPCD_PATH = @DHCPCD_PATH@ +DISTRO_NETWORK_SERVICE = @DISTRO_NETWORK_SERVICE@ DLLTOOL = @DLLTOOL@ DNSMASQ_PATH = @DNSMASQ_PATH@ DSYMUTIL = @DSYMUTIL@ @@ -174,7 +178,6 @@ GNUTLS_CFLAGS = @GNUTLS_CFLAGS@ GNUTLS_LIBS = @GNUTLS_LIBS@ GREP = @GREP@ GTKDOC_CHECK = @GTKDOC_CHECK@ -GTKDOC_CHECK_PATH = @GTKDOC_CHECK_PATH@ GTKDOC_DEPS_CFLAGS = @GTKDOC_DEPS_CFLAGS@ GTKDOC_DEPS_LIBS = @GTKDOC_DEPS_LIBS@ GTKDOC_MKPDF = @GTKDOC_MKPDF@ @@ -219,12 +222,16 @@ LIBGCRYPT_LIBS = @LIBGCRYPT_LIBS@ LIBICONV = @LIBICONV@ LIBINTL = @LIBINTL@ LIBM = @LIBM@ +LIBNDP_CFLAGS = @LIBNDP_CFLAGS@ +LIBNDP_LIBS = @LIBNDP_LIBS@ LIBNL_CFLAGS = @LIBNL_CFLAGS@ LIBNL_LIBS = @LIBNL_LIBS@ LIBOBJS = @LIBOBJS@ LIBS = @LIBS@ LIBSOUP_CFLAGS = @LIBSOUP_CFLAGS@ LIBSOUP_LIBS = @LIBSOUP_LIBS@ +LIBTEAMDCTL_CFLAGS = @LIBTEAMDCTL_CFLAGS@ +LIBTEAMDCTL_LIBS = @LIBTEAMDCTL_LIBS@ LIBTOOL = @LIBTOOL@ LIPO = @LIPO@ LN_S = @LN_S@ @@ -241,6 +248,8 @@ MOC = @MOC@ MSGFMT = @MSGFMT@ MSGFMT_015 = @MSGFMT_015@ MSGMERGE = @MSGMERGE@ +NEWT_CFLAGS = @NEWT_CFLAGS@ +NEWT_LIBS = @NEWT_LIBS@ NM = @NM@ NMEDIT = @NMEDIT@ NM_MAJOR_VERSION = @NM_MAJOR_VERSION@ @@ -268,11 +277,16 @@ PKG_CONFIG_PATH = @PKG_CONFIG_PATH@ POLKIT_CFLAGS = @POLKIT_CFLAGS@ POLKIT_LIBS = @POLKIT_LIBS@ POSUB = @POSUB@ +PPPD_PATH = @PPPD_PATH@ PPPD_PLUGIN_DIR = @PPPD_PLUGIN_DIR@ +PPPOE_PATH = @PPPOE_PATH@ QT_CFLAGS = @QT_CFLAGS@ QT_LIBS = @QT_LIBS@ RANLIB = @RANLIB@ +READLINE_LIBS = @READLINE_LIBS@ SED = @SED@ +SELINUX_CFLAGS = @SELINUX_CFLAGS@ +SELINUX_LIBS = @SELINUX_LIBS@ SET_MAKE = @SET_MAKE@ SHELL = @SHELL@ STRIP = @STRIP@ @@ -287,6 +301,7 @@ UDEV_BASE_DIR = @UDEV_BASE_DIR@ USE_NLS = @USE_NLS@ UUID_CFLAGS = @UUID_CFLAGS@ UUID_LIBS = @UUID_LIBS@ +VALGRIND_RULES = @VALGRIND_RULES@ VAPIGEN = @VAPIGEN@ VAPIGEN_MAKEFILE = @VAPIGEN_MAKEFILE@ VAPIGEN_VAPIDIR = @VAPIGEN_VAPIDIR@ @@ -349,6 +364,7 @@ psdir = @psdir@ sbindir = @sbindir@ sharedstatedir = @sharedstatedir@ srcdir = @srcdir@ +subdirs = @subdirs@ sysconfdir = @sysconfdir@ systemdsystemunitdir = @systemdsystemunitdir@ target_alias = @target_alias@ @@ -359,6 +375,7 @@ with_dhclient = @with_dhclient@ with_dhcpcd = @with_dhcpcd@ with_netconfig = @with_netconfig@ with_resolvconf = @with_resolvconf@ +with_valgrind = @with_valgrind@ EXTRA_DIST = \ nm-logging.sh \ get-hostname.sh \ diff --git a/examples/shell/list-devices.sh b/examples/shell/list-devices.sh index 4cf9c5991..dba82261c 100755 --- a/examples/shell/list-devices.sh +++ b/examples/shell/list-devices.sh @@ -31,6 +31,7 @@ DEVICE_IFACE="org.freedesktop.NetworkManager.Device" NM_GET_DEVICES="org.freedesktop.NetworkManager.GetDevices" DBUS_PROPERTIES_GET="org.freedesktop.DBus.Properties.Get" +# For the types see include/NetworkManager.h devtype_to_name() { case $1 in @@ -44,6 +45,9 @@ devtype_to_name() 10) echo "Bond" ;; 11) echo "VLAN" ;; 12) echo "ADSL" ;; + 13) echo "Bridge" ;; + 14) echo "Generic" ;; + 15) echo "Team" ;; *) echo "Unknown" ;; esac } |