From 2e5fa45ddfbb5cffa1e78221f1cea706e2f298af Mon Sep 17 00:00:00 2001 From: Michael Biebl Date: Wed, 31 Jul 2019 10:51:42 +0200 Subject: New upstream version 1.19.90 --- examples/C/glib/add-connection-gdbus.c | 1 - examples/C/glib/add-connection-libnm.c | 1 - examples/C/glib/get-active-connections-gdbus.c | 1 - examples/C/glib/get-ap-info-libnm.c | 1 - examples/C/glib/list-connections-gdbus.c | 1 - examples/C/glib/list-connections-libnm.c | 1 - examples/C/glib/monitor-nm-running-gdbus.c | 1 - examples/C/glib/monitor-nm-state-gdbus.c | 1 - examples/C/qt/add-connection-wired.cpp | 151 ++++++++++---------- examples/C/qt/change-ipv4-addresses.cpp | 1 - examples/C/qt/list-connections.cpp | 1 - examples/C/qt/monitor-nm-running.cpp | 2 - examples/lua/lgi/add-connection.lua | 2 - examples/lua/lgi/change-vpn-username.lua | 2 - examples/lua/lgi/deactivate-all.lua | 2 - examples/lua/lgi/get-basic-nm-info.lua | 2 - examples/lua/lgi/get-ips.lua | 2 - examples/lua/lgi/list-connections.lua | 2 - examples/lua/lgi/list-devices.lua | 2 - examples/lua/lgi/show-wifi-networks.lua | 2 - examples/python/dbus/disconnect-device.py | 1 - .../python/dbus/get-active-connection-uuids.py | 1 - examples/python/dbus/is-wwan-default.py | 1 - examples/python/dbus/list-devices.py | 1 - examples/python/dbus/update-ip4-method.py | 1 - examples/python/gi/add_connection.py | 2 - examples/python/gi/deactivate-all.py | 2 - examples/python/gi/device-state-ip4config.py | 2 - examples/python/gi/firewall-zone.py | 2 - examples/python/gi/get-active-connections.py | 2 - examples/python/gi/get_ips.py | 2 - examples/python/gi/list-connections.py | 2 - examples/python/gi/nm-add-connection2.py | 156 +++++++++++++++++++++ .../python/gi/nm-connection-update-stable-id.py | 2 - examples/python/gi/nm-update2.py | 155 ++++++++++++++++++++ examples/python/gi/setting-user-data.py | 2 - examples/python/gi/show-wifi-networks.py | 2 - examples/python/gi/update-ip4-method.py | 2 - examples/ruby/add-connection.rb | 2 - examples/ruby/get-basic-nm-info.rb | 2 - examples/ruby/list-devices.rb | 2 - examples/shell/active-wifi.sh | 2 - examples/shell/disconnect-device.sh | 2 - examples/shell/get-hostname.sh | 2 - examples/shell/list-devices.sh | 2 - examples/shell/nm-logging.sh | 2 - 46 files changed, 386 insertions(+), 147 deletions(-) create mode 100755 examples/python/gi/nm-add-connection2.py create mode 100755 examples/python/gi/nm-update2.py (limited to 'examples') diff --git a/examples/C/glib/add-connection-gdbus.c b/examples/C/glib/add-connection-gdbus.c index 1045db38..7f779f81 100644 --- a/examples/C/glib/add-connection-gdbus.c +++ b/examples/C/glib/add-connection-gdbus.c @@ -1,4 +1,3 @@ -/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; 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 diff --git a/examples/C/glib/add-connection-libnm.c b/examples/C/glib/add-connection-libnm.c index e6075352..e8188f6b 100644 --- a/examples/C/glib/add-connection-libnm.c +++ b/examples/C/glib/add-connection-libnm.c @@ -1,4 +1,3 @@ -/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; 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 diff --git a/examples/C/glib/get-active-connections-gdbus.c b/examples/C/glib/get-active-connections-gdbus.c index 1f3858c9..3045ab73 100644 --- a/examples/C/glib/get-active-connections-gdbus.c +++ b/examples/C/glib/get-active-connections-gdbus.c @@ -1,4 +1,3 @@ -/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; 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 diff --git a/examples/C/glib/get-ap-info-libnm.c b/examples/C/glib/get-ap-info-libnm.c index c11d4146..2f31d7db 100644 --- a/examples/C/glib/get-ap-info-libnm.c +++ b/examples/C/glib/get-ap-info-libnm.c @@ -1,4 +1,3 @@ -/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; 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 diff --git a/examples/C/glib/list-connections-gdbus.c b/examples/C/glib/list-connections-gdbus.c index b8e77dc9..86a4cc19 100644 --- a/examples/C/glib/list-connections-gdbus.c +++ b/examples/C/glib/list-connections-gdbus.c @@ -1,4 +1,3 @@ -/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; 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 diff --git a/examples/C/glib/list-connections-libnm.c b/examples/C/glib/list-connections-libnm.c index 1b3ed8d1..1c7fafe7 100644 --- a/examples/C/glib/list-connections-libnm.c +++ b/examples/C/glib/list-connections-libnm.c @@ -1,4 +1,3 @@ -/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; 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 diff --git a/examples/C/glib/monitor-nm-running-gdbus.c b/examples/C/glib/monitor-nm-running-gdbus.c index ad05a9e4..e2ea38db 100644 --- a/examples/C/glib/monitor-nm-running-gdbus.c +++ b/examples/C/glib/monitor-nm-running-gdbus.c @@ -1,4 +1,3 @@ -/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; 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 diff --git a/examples/C/glib/monitor-nm-state-gdbus.c b/examples/C/glib/monitor-nm-state-gdbus.c index 4593f1a6..bca4d572 100644 --- a/examples/C/glib/monitor-nm-state-gdbus.c +++ b/examples/C/glib/monitor-nm-state-gdbus.c @@ -1,4 +1,3 @@ -/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; 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 diff --git a/examples/C/qt/add-connection-wired.cpp b/examples/C/qt/add-connection-wired.cpp index c06ed71f..fade1e4f 100644 --- a/examples/C/qt/add-connection-wired.cpp +++ b/examples/C/qt/add-connection-wired.cpp @@ -1,76 +1,75 @@ -/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; 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. - * - * (C) Copyright 2011 Eckhart Wörner - */ - -/* - * The example shows how to call AddConnection() D-Bus method to add - * a connection to settings service using Qt and D-Bus. - */ - -#include -#include -#include -#include -#include -#include -#include - -#include - -typedef QMap > Connection; -Q_DECLARE_METATYPE(Connection) - - -void addConnection(QDBusInterface& interface, const QString& connectionName) { - qDBusRegisterMetaType(); - - // Create a new connection object - Connection connection; - - // Build up the 'connection' Setting - connection["connection"]["uuid"] = QUuid::createUuid().toString().remove('{').remove('}'); - connection["connection"]["id"] = connectionName; - connection["connection"]["type"] = "802-3-ethernet"; - - // Build up the '802-3-ethernet' Setting - connection["802-3-ethernet"]; - - // Build up the 'ipv4' Setting - connection["ipv4"]["method"] = "auto"; - - // Call AddConnection - QDBusReply result = interface.call("AddConnection", QVariant::fromValue(connection)); - if (!result.isValid()) { - qDebug() << QString("Error adding connection: %1 %2").arg(result.error().name()).arg(result.error().message()); - } else { - qDebug() << QString("Added: %1").arg(result.value().path()); - } -} - -int main() { - // Create a D-Bus proxy; NM_DBUS_* defined in NetworkManager.h - QDBusInterface interface( - NM_DBUS_SERVICE, - NM_DBUS_PATH_SETTINGS, - NM_DBUS_INTERFACE_SETTINGS, - QDBusConnection::systemBus()); - - addConnection(interface, "__Test connection__"); - - return 0; -} +/* + * 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. + * + * (C) Copyright 2011 Eckhart Wörner + */ + +/* + * The example shows how to call AddConnection() D-Bus method to add + * a connection to settings service using Qt and D-Bus. + */ + +#include +#include +#include +#include +#include +#include +#include + +#include + +typedef QMap > Connection; +Q_DECLARE_METATYPE(Connection) + + +void addConnection(QDBusInterface& interface, const QString& connectionName) { + qDBusRegisterMetaType(); + + // Create a new connection object + Connection connection; + + // Build up the 'connection' Setting + connection["connection"]["uuid"] = QUuid::createUuid().toString().remove('{').remove('}'); + connection["connection"]["id"] = connectionName; + connection["connection"]["type"] = "802-3-ethernet"; + + // Build up the '802-3-ethernet' Setting + connection["802-3-ethernet"]; + + // Build up the 'ipv4' Setting + connection["ipv4"]["method"] = "auto"; + + // Call AddConnection + QDBusReply result = interface.call("AddConnection", QVariant::fromValue(connection)); + if (!result.isValid()) { + qDebug() << QString("Error adding connection: %1 %2").arg(result.error().name()).arg(result.error().message()); + } else { + qDebug() << QString("Added: %1").arg(result.value().path()); + } +} + +int main() { + // Create a D-Bus proxy; NM_DBUS_* defined in NetworkManager.h + QDBusInterface interface( + NM_DBUS_SERVICE, + NM_DBUS_PATH_SETTINGS, + NM_DBUS_INTERFACE_SETTINGS, + QDBusConnection::systemBus()); + + addConnection(interface, "__Test connection__"); + + return 0; +} diff --git a/examples/C/qt/change-ipv4-addresses.cpp b/examples/C/qt/change-ipv4-addresses.cpp index d403900a..ce9b1ab4 100644 --- a/examples/C/qt/change-ipv4-addresses.cpp +++ b/examples/C/qt/change-ipv4-addresses.cpp @@ -1,4 +1,3 @@ -/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; 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 diff --git a/examples/C/qt/list-connections.cpp b/examples/C/qt/list-connections.cpp index 48dd685e..0ade61a8 100644 --- a/examples/C/qt/list-connections.cpp +++ b/examples/C/qt/list-connections.cpp @@ -1,4 +1,3 @@ -/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; 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 diff --git a/examples/C/qt/monitor-nm-running.cpp b/examples/C/qt/monitor-nm-running.cpp index cf597b54..2d318031 100644 --- a/examples/C/qt/monitor-nm-running.cpp +++ b/examples/C/qt/monitor-nm-running.cpp @@ -1,5 +1,3 @@ -/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */ -/* vim: set ft=c ts=4 sts=4 sw=4 expandtab smartindent: */ /* * 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 diff --git a/examples/lua/lgi/add-connection.lua b/examples/lua/lgi/add-connection.lua index 69bc8cb2..efccfddf 100755 --- a/examples/lua/lgi/add-connection.lua +++ b/examples/lua/lgi/add-connection.lua @@ -1,6 +1,4 @@ #!/usr/bin/env lua --- -*- Mode: Lua; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- --- vim: ft=lua ts=2 sts=2 sw=2 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 diff --git a/examples/lua/lgi/change-vpn-username.lua b/examples/lua/lgi/change-vpn-username.lua index 2e93f9dd..1e6c94bb 100755 --- a/examples/lua/lgi/change-vpn-username.lua +++ b/examples/lua/lgi/change-vpn-username.lua @@ -1,6 +1,4 @@ #!/usr/bin/env lua --- -*- Mode: Lua; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- --- vim: ft=lua ts=2 sts=2 sw=2 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 diff --git a/examples/lua/lgi/deactivate-all.lua b/examples/lua/lgi/deactivate-all.lua index 2e8d8935..b4db8add 100755 --- a/examples/lua/lgi/deactivate-all.lua +++ b/examples/lua/lgi/deactivate-all.lua @@ -1,6 +1,4 @@ #!/usr/bin/env lua --- -*- Mode: Lua; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- --- vim: ft=lua ts=2 sts=2 sw=2 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 diff --git a/examples/lua/lgi/get-basic-nm-info.lua b/examples/lua/lgi/get-basic-nm-info.lua index fe3c3ea3..6ff0be54 100755 --- a/examples/lua/lgi/get-basic-nm-info.lua +++ b/examples/lua/lgi/get-basic-nm-info.lua @@ -1,6 +1,4 @@ #!/usr/bin/env lua --- -*- Mode: Lua; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- --- vim: ft=lua ts=2 sts=2 sw=2 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 diff --git a/examples/lua/lgi/get-ips.lua b/examples/lua/lgi/get-ips.lua index 9a70de43..0f67c807 100755 --- a/examples/lua/lgi/get-ips.lua +++ b/examples/lua/lgi/get-ips.lua @@ -1,6 +1,4 @@ #!/usr/bin/env lua --- -*- Mode: Lua; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- --- vim: ft=lua ts=2 sts=2 sw=2 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 diff --git a/examples/lua/lgi/list-connections.lua b/examples/lua/lgi/list-connections.lua index f2eda442..6c1d0cb0 100755 --- a/examples/lua/lgi/list-connections.lua +++ b/examples/lua/lgi/list-connections.lua @@ -1,6 +1,4 @@ #!/usr/bin/env lua --- -*- Mode: Lua; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- --- vim: ft=lua ts=2 sts=2 sw=2 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 diff --git a/examples/lua/lgi/list-devices.lua b/examples/lua/lgi/list-devices.lua index 712d353e..57ed54e6 100755 --- a/examples/lua/lgi/list-devices.lua +++ b/examples/lua/lgi/list-devices.lua @@ -1,6 +1,4 @@ #!/usr/bin/env lua --- -*- Mode: Lua; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- --- vim: ft=lua ts=2 sts=2 sw=2 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 diff --git a/examples/lua/lgi/show-wifi-networks.lua b/examples/lua/lgi/show-wifi-networks.lua index 954fee70..7bffada2 100755 --- a/examples/lua/lgi/show-wifi-networks.lua +++ b/examples/lua/lgi/show-wifi-networks.lua @@ -1,6 +1,4 @@ #!/usr/bin/env lua --- -*- Mode: Lua; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- --- vim: ft=lua ts=2 sts=2 sw=2 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 diff --git a/examples/python/dbus/disconnect-device.py b/examples/python/dbus/disconnect-device.py index 85afa97b..e884df62 100755 --- a/examples/python/dbus/disconnect-device.py +++ b/examples/python/dbus/disconnect-device.py @@ -1,5 +1,4 @@ #!/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 diff --git a/examples/python/dbus/get-active-connection-uuids.py b/examples/python/dbus/get-active-connection-uuids.py index deb38dae..6e4310d0 100755 --- a/examples/python/dbus/get-active-connection-uuids.py +++ b/examples/python/dbus/get-active-connection-uuids.py @@ -1,5 +1,4 @@ #!/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 diff --git a/examples/python/dbus/is-wwan-default.py b/examples/python/dbus/is-wwan-default.py index 10ae31fc..c16aadca 100755 --- a/examples/python/dbus/is-wwan-default.py +++ b/examples/python/dbus/is-wwan-default.py @@ -1,5 +1,4 @@ #!/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 diff --git a/examples/python/dbus/list-devices.py b/examples/python/dbus/list-devices.py index 1afb5a45..fd58695b 100755 --- a/examples/python/dbus/list-devices.py +++ b/examples/python/dbus/list-devices.py @@ -1,5 +1,4 @@ #!/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 diff --git a/examples/python/dbus/update-ip4-method.py b/examples/python/dbus/update-ip4-method.py index 505e808b..5a1cd4c5 100755 --- a/examples/python/dbus/update-ip4-method.py +++ b/examples/python/dbus/update-ip4-method.py @@ -1,5 +1,4 @@ #!/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 diff --git a/examples/python/gi/add_connection.py b/examples/python/gi/add_connection.py index 25a59235..3b0abef1 100755 --- a/examples/python/gi/add_connection.py +++ b/examples/python/gi/add_connection.py @@ -1,6 +1,4 @@ #!/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 diff --git a/examples/python/gi/deactivate-all.py b/examples/python/gi/deactivate-all.py index 13d14bc9..7a9b2ce1 100755 --- a/examples/python/gi/deactivate-all.py +++ b/examples/python/gi/deactivate-all.py @@ -1,6 +1,4 @@ #!/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 diff --git a/examples/python/gi/device-state-ip4config.py b/examples/python/gi/device-state-ip4config.py index b92a7b09..70ab8871 100755 --- a/examples/python/gi/device-state-ip4config.py +++ b/examples/python/gi/device-state-ip4config.py @@ -1,7 +1,5 @@ #!/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 diff --git a/examples/python/gi/firewall-zone.py b/examples/python/gi/firewall-zone.py index 979f2acf..6be18dd9 100755 --- a/examples/python/gi/firewall-zone.py +++ b/examples/python/gi/firewall-zone.py @@ -1,6 +1,4 @@ #!/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 diff --git a/examples/python/gi/get-active-connections.py b/examples/python/gi/get-active-connections.py index cee579f9..d7d35663 100755 --- a/examples/python/gi/get-active-connections.py +++ b/examples/python/gi/get-active-connections.py @@ -1,6 +1,4 @@ #!/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 diff --git a/examples/python/gi/get_ips.py b/examples/python/gi/get_ips.py index 66d154f2..48bbac6d 100755 --- a/examples/python/gi/get_ips.py +++ b/examples/python/gi/get_ips.py @@ -1,7 +1,5 @@ #!/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 diff --git a/examples/python/gi/list-connections.py b/examples/python/gi/list-connections.py index 2139e8c1..4cd15feb 100755 --- a/examples/python/gi/list-connections.py +++ b/examples/python/gi/list-connections.py @@ -1,6 +1,4 @@ #!/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 diff --git a/examples/python/gi/nm-add-connection2.py b/examples/python/gi/nm-add-connection2.py new file mode 100755 index 00000000..b78016db --- /dev/null +++ b/examples/python/gi/nm-add-connection2.py @@ -0,0 +1,156 @@ +#!/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 2019 Red Hat, Inc. +# + +import sys +import re + +import gi +gi.require_version('NM', '1.0') +from gi.repository import GLib, NM + +def find_connections(nm_client, arg_type, arg_id): + for c in nm_client.get_connections(): + if arg_type in [None, 'id'] and c.get_id() == arg_id: + yield c + if arg_type in [None, 'uuid'] and c.get_uuid() == arg_id: + yield c + +def find_connection_first(nm_client, arg_type, arg_id): + for f in find_connections(nm_client, arg_type, arg_id): + return f + +def con_to_str(con): + s_con = con.get_setting_connection() + return '"%s" (%s)' % (s_con.get_id(), s_con.get_uuid()) + +def usage(): + print('Usage: %s --clone [[id] ]' % (sys.argv[0])) + print(' %s --clone [[uuid] ]' % (sys.argv[0])) + return 1 + +def die(msg, print_usage=False): + print(msg) + if print_usage: + usage() + sys.exit(1) + +def main(): + + main_loop = GLib.MainLoop() + + nm_client = NM.Client.new(None) + + arg_mode = None + arg_block_autoconnect = NM.SettingsAddConnection2Flags.NONE + arg_id = None + arg_uuid = None + + cons = [] + + argv = list(sys.argv[1:]) + while argv: + if argv[0] == '--clone': + match_type = None + if len(argv) < 2: + die('missing argument for --clone option') + if argv[0] in ['id', 'uuid']: + match_type = argv[0] + if len(argv) < 3: + die('missing argument for "--clone %s" option' % (match_type)) + argv = argv[1:] + if cons: + die('cannot specify --clone argument more than once') + cons.extend(find_connections(nm_client, match_type, argv[1])) + if len(cons) == 0: + die('could not find connection for "--clone %s%s"' % ((match_type or ''), argv[1])) + if len(cons) != 1: + die('could not find unique connection for "--clone %s%s"' % ((match_type or ''), argv[1])) + argv = argv[2:] + continue + if argv[0] in ['--block-autoconnect']: + arg_block_autoconnect = NM.SettingsAddConnection2Flags.BLOCK_AUTOCONNECT + argv = argv[1:] + continue + if argv[0] in ['--to-disk', '--in-memory']: + if argv[0] == '--to-disk': + v = NM.SettingsAddConnection2Flags.TO_DISK + elif argv[0] == '--in-memory': + v = NM.SettingsAddConnection2Flags.IN_MEMORY + else: + assert(False) + if arg_mode is not None: + die('duplicate storage modes ("%s")' % (argv[0])) + arg_mode = v + argv = argv[1:] + continue + if argv[0] in ['--id']: + if len(argv) < 2: + die('missing argument for --id option') + arg_id = argv[1] + argv = argv[2:] + continue + if argv[0] in ['--uuid']: + if len(argv) < 2: + die('missing argument for --uuid option') + arg_uuid = argv[1] + argv = argv[2:] + continue + die('unknown argument "%s"' % (argv[0])) + + if len(cons) != 1: + die('missing --clone argument', True) + + con = cons[0] + + con2 = NM.SimpleConnection.new_clone(con) + + s_con = con2.get_setting_connection() + if arg_id: + s_con.set_property(NM.SETTING_CONNECTION_ID, arg_id) + s_con.set_property(NM.SETTING_CONNECTION_UUID, arg_uuid or NM.utils_uuid_generate()) + + result = {} + def _add_connection2_cb(cl, async_result, user_data): + try: + c, r = nm_client.add_connection2_finish(async_result) + except Exception as e: + result['error'] = e + else: + result['result'] = r + result['connection'] = c + main_loop.quit() + + nm_client.add_connection2(con2.to_dbus(NM.ConnectionSerializationFlags.ALL), + (arg_mode if arg_mode is not None else NM.SettingsAddConnection2Flags.TO_DISK) + | arg_block_autoconnect, + None, + False, + None, + _add_connection2_cb, + None) + + main_loop.run() + + if 'error' in result: + die('update connection %s failed [%s]: %s' % (con_to_str(con2), ' '.join(sys.argv), result['error'])) + + print('update connection %s succeeded [%s]: %s, %s' % (con_to_str(con2), ' '.join(sys.argv), result['connection'].get_path(), result['result'])) + +if __name__ == '__main__': + main() diff --git a/examples/python/gi/nm-connection-update-stable-id.py b/examples/python/gi/nm-connection-update-stable-id.py index ad852f77..bd4f12b6 100755 --- a/examples/python/gi/nm-connection-update-stable-id.py +++ b/examples/python/gi/nm-connection-update-stable-id.py @@ -1,6 +1,4 @@ #!/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 diff --git a/examples/python/gi/nm-update2.py b/examples/python/gi/nm-update2.py new file mode 100755 index 00000000..36449fd8 --- /dev/null +++ b/examples/python/gi/nm-update2.py @@ -0,0 +1,155 @@ +#!/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 2019 Red Hat, Inc. +# + +import sys +import re + +import gi +gi.require_version('NM', '1.0') +from gi.repository import GLib, NM + +def find_connections(nm_client, arg_type, arg_id): + for c in nm_client.get_connections(): + if arg_type in [None, 'id'] and c.get_id() == arg_id: + yield c + if arg_type in [None, 'uuid'] and c.get_uuid() == arg_id: + yield c + +def find_connection_first(nm_client, arg_type, arg_id): + for f in find_connections(nm_client, arg_type, arg_id): + return f + +def con_to_str(con): + s_con = con.get_setting_connection() + return '"%s" (%s)' % (s_con.get_id(), s_con.get_uuid()) + +def usage(): + print('Usage: %s [[id] ]' % (sys.argv[0])) + print(' %s [[uuid] ]' % (sys.argv[0])) + return 1 + +def die(msg, print_usage=False): + print(msg) + if print_usage: + usage() + sys.exit(1) + +def main(): + + main_loop = GLib.MainLoop() + + nm_client = NM.Client.new(None) + + arg_mode = None + arg_block_autoconnect = NM.SettingsUpdate2Flags.NONE + arg_volatile = NM.SettingsUpdate2Flags.NONE + arg_no_reapply = NM.SettingsUpdate2Flags.NONE + + cons = [] + + argv = list(sys.argv[1:]) + while argv: + if argv[0] in ['id', 'uuid']: + if cons: + die('cannot specify multiple connections') + if len(argv) < 2: + die('missing argument for "%s" specifier' % (argv[0])) + cons.extend(find_connections(nm_client, argv[0], argv[1])) + if len(cons) == 0: + die('could not find connection for "%s %s"' % (argv[0], argv[1])) + if len(cons) != 1: + die('could not find unique connection for "%s %s"' % (argv[0], argv[1])) + argv = argv[2:] + continue + if argv[0] in ['--block-autoconnect']: + arg_block_autoconnect = NM.SettingsUpdate2Flags.BLOCK_AUTOCONNECT + argv = argv[1:] + continue + if argv[0] in ['--volatile']: + arg_volatile = NM.SettingsUpdate2Flags.VOLATILE + argv = argv[1:] + continue + if argv[0] in ['--no-reapply']: + arg_no_reapply = NM.SettingsUpdate2Flags.NO_REAPPLY + argv = argv[1:] + continue + if argv[0] in ['--to-disk', '--in-memory', '--in-memory-detached', '--in-memory-only']: + if argv[0] == '--to-disk': + v = NM.SettingsUpdate2Flags.TO_DISK + elif argv[0] == '--in-memory': + v = NM.SettingsUpdate2Flags.IN_MEMORY + elif argv[0] == '--in-memory-detached': + v = NM.SettingsUpdate2Flags.IN_MEMORY_DETACHED + elif argv[0] == '--in-memory-only': + v = NM.SettingsUpdate2Flags.IN_MEMORY_ONLY + elif argv[0] == '--keep': + v = NM.SettingsUpdate2Flags.NONE + else: + assert(False) + if arg_mode is not None: + die('duplicate storage modes ("%s")' % (argv[0])) + arg_mode = v + argv = argv[1:] + continue + if cons: + die('unknown argument "%s"' % (argv[0])) + cons.extend(find_connections(nm_client, None, argv[0])) + if len(cons) == 0: + die('could not find connection for "%s"' % (argv[0])) + if len(cons) != 1: + die('could not find unique connection for "%s"' % (argv[0])) + argv = argv[1:] + continue + + if len(cons) != 1: + die('missing connection argument', True) + + con = cons[0] + + con2 = NM.SimpleConnection.new_clone(con) + + result = {} + def _update2_cb(con, async_result, user_data): + try: + r = con.update2_finish(async_result) + except Exception as e: + result['error'] = e + else: + result['result'] = r + main_loop.quit() + + con.update2(con2.to_dbus(NM.ConnectionSerializationFlags.ALL), + (arg_mode if arg_mode is not None else NM.SettingsUpdate2Flags.NONE) + | arg_block_autoconnect + | arg_volatile + | arg_no_reapply, + None, + None, + _update2_cb, + None) + + main_loop.run() + + if 'error' in result: + die('update connection %s failed [%s]: %s' % (con_to_str(con2), ' '.join(sys.argv), result['error'])) + + print('update connection %s succeeded [%s]: %s' % (con_to_str(con2), ' '.join(sys.argv), result['result'])) + +if __name__ == '__main__': + main() diff --git a/examples/python/gi/setting-user-data.py b/examples/python/gi/setting-user-data.py index 79fb98cd..d5e00105 100755 --- a/examples/python/gi/setting-user-data.py +++ b/examples/python/gi/setting-user-data.py @@ -1,6 +1,4 @@ #!/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 diff --git a/examples/python/gi/show-wifi-networks.py b/examples/python/gi/show-wifi-networks.py index 4c7a126f..6eb6ac91 100755 --- a/examples/python/gi/show-wifi-networks.py +++ b/examples/python/gi/show-wifi-networks.py @@ -1,7 +1,5 @@ #!/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 diff --git a/examples/python/gi/update-ip4-method.py b/examples/python/gi/update-ip4-method.py index 3b2df72e..e4c603fb 100755 --- a/examples/python/gi/update-ip4-method.py +++ b/examples/python/gi/update-ip4-method.py @@ -1,6 +1,4 @@ #!/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 diff --git a/examples/ruby/add-connection.rb b/examples/ruby/add-connection.rb index 645ad348..bd9b4ed7 100755 --- a/examples/ruby/add-connection.rb +++ b/examples/ruby/add-connection.rb @@ -1,6 +1,4 @@ #!/usr/bin/env ruby -# vim: ft=ruby ts=2 sts=2 sw=2 et ai -# -*- Mode: ruby; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- # # 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 diff --git a/examples/ruby/get-basic-nm-info.rb b/examples/ruby/get-basic-nm-info.rb index 1cf67947..d5525429 100755 --- a/examples/ruby/get-basic-nm-info.rb +++ b/examples/ruby/get-basic-nm-info.rb @@ -1,6 +1,4 @@ #!/usr/bin/env ruby -# vim: ft=ruby ts=2 sts=2 sw=2 et ai -# -*- Mode: ruby; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- # # 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 diff --git a/examples/ruby/list-devices.rb b/examples/ruby/list-devices.rb index bf374258..690d3e5f 100755 --- a/examples/ruby/list-devices.rb +++ b/examples/ruby/list-devices.rb @@ -1,6 +1,4 @@ #!/usr/bin/env ruby -# vim: ft=ruby ts=2 sts=2 sw=2 et ai -# -*- Mode: ruby; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- # # 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 diff --git a/examples/shell/active-wifi.sh b/examples/shell/active-wifi.sh index 2ff54190..0f550fed 100755 --- a/examples/shell/active-wifi.sh +++ b/examples/shell/active-wifi.sh @@ -1,6 +1,4 @@ #!/bin/sh -# vim: ft=sh ts=2 sts=2 sw=2 et ai -# -*- Mode: sh; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- # # 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 diff --git a/examples/shell/disconnect-device.sh b/examples/shell/disconnect-device.sh index e8af42fc..edfb9d17 100755 --- a/examples/shell/disconnect-device.sh +++ b/examples/shell/disconnect-device.sh @@ -1,6 +1,4 @@ #!/bin/sh -# vim: ft=sh ts=2 sts=2 sw=2 et ai -# -*- Mode: sh; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- # # 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 diff --git a/examples/shell/get-hostname.sh b/examples/shell/get-hostname.sh index a521132c..5009120b 100755 --- a/examples/shell/get-hostname.sh +++ b/examples/shell/get-hostname.sh @@ -1,6 +1,4 @@ #!/bin/sh -# vim: ft=sh ts=2 sts=2 sw=2 et ai -# -*- Mode: sh; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- # # 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 diff --git a/examples/shell/list-devices.sh b/examples/shell/list-devices.sh index c5c41140..ee694215 100755 --- a/examples/shell/list-devices.sh +++ b/examples/shell/list-devices.sh @@ -1,6 +1,4 @@ #!/bin/sh -# vim: ft=sh ts=2 sts=2 sw=2 et ai -# -*- Mode: sh; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- # # 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 diff --git a/examples/shell/nm-logging.sh b/examples/shell/nm-logging.sh index 98821650..ab4c4917 100755 --- a/examples/shell/nm-logging.sh +++ b/examples/shell/nm-logging.sh @@ -1,6 +1,4 @@ #!/bin/sh -# vim: ft=sh ts=2 sts=2 sw=2 et ai -# -*- Mode: sh; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- # # 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 -- cgit 1.3.0-6-gf8a5