diff options
48 files changed, 5448 insertions, 45 deletions
diff --git a/configure.ac b/configure.ac index 2a33ebd9cb..bc635338db 100644 --- a/configure.ac +++ b/configure.ac @@ -600,6 +600,7 @@ Makefile include/Makefile include/nm-version.h src/Makefile +src/compat/Makefile src/tests/Makefile marshallers/Makefile src/logging/Makefile diff --git a/kde-plasma-networkmanagement-nm-compat.patch b/kde-plasma-networkmanagement-nm-compat.patch new file mode 100644 index 0000000000..720ffcf1e6 --- /dev/null +++ b/kde-plasma-networkmanagement-nm-compat.patch @@ -0,0 +1,220 @@ +diff -up networkmanagement-0.9/backends/NetworkManager/nmdbussettingsservice.cpp.blah networkmanagement-0.9/backends/NetworkManager/nmdbussettingsservice.cpp +--- networkmanagement-0.9/backends/NetworkManager/nmdbussettingsservice.cpp.blah 2011-03-22 20:06:02.769311181 -0500 ++++ networkmanagement-0.9/backends/NetworkManager/nmdbussettingsservice.cpp 2011-03-22 20:08:03.199805593 -0500 +@@ -57,6 +57,9 @@ public: + QHash<QUuid, QDBusObjectPath> uuidToPath; + }; + ++#define NM_DBUS_SERVICE_USER_SETTINGS "org.freedesktop.NetworkManagerUserSettings" ++#define NM_DBUS_SERVICE_SYSTEM_SETTINGS "org.freedesktop.NetworkManagerSystemSettings" ++ + const QString NMDBusSettingsService::SERVICE_USER_SETTINGS = QLatin1String(NM_DBUS_SERVICE_USER_SETTINGS); + const QString NMDBusSettingsService::SERVICE_SYSTEM_SETTINGS = QLatin1String(NM_DBUS_SERVICE_SYSTEM_SETTINGS); + +diff -up networkmanagement-0.9/settings/config/manageconnectionwidget.cpp.blah networkmanagement-0.9/settings/config/manageconnectionwidget.cpp +--- networkmanagement-0.9/settings/config/manageconnectionwidget.cpp.blah 2011-03-22 20:07:03.879547198 -0500 ++++ networkmanagement-0.9/settings/config/manageconnectionwidget.cpp 2011-03-22 20:07:58.302866812 -0500 +@@ -55,6 +55,9 @@ along with this program. If not, see <h + #define ConnectionTypeRole 1066 + #define ConnectionLastUsedRole 1848 + ++#define NM_DBUS_SERVICE_USER_SETTINGS "org.freedesktop.NetworkManagerUserSettings" ++#define NM_DBUS_SERVICE_SYSTEM_SETTINGS "org.freedesktop.NetworkManagerSystemSettings" ++ + K_PLUGIN_FACTORY( ManageConnectionWidgetFactory, registerPlugin<ManageConnectionWidget>();) + K_EXPORT_PLUGIN( ManageConnectionWidgetFactory( "kcm_networkmanagement", "libknetworkmanager" ) ) + +diff -up networkmanagement-0.9/backends/NetworkManager/settings/gsmdbus.cpp.foo networkmanagement-0.9/backends/NetworkManager/settings/gsmdbus.cpp +--- networkmanagement-0.9/backends/NetworkManager/settings/gsmdbus.cpp.foo 2011-03-22 20:00:12.443690853 -0500 ++++ networkmanagement-0.9/backends/NetworkManager/settings/gsmdbus.cpp 2011-03-22 20:01:10.360966787 -0500 +@@ -35,7 +35,7 @@ void GsmDbus::fromMap(const QVariantMap + if (map.contains(QLatin1String(NM_SETTING_GSM_NETWORK_TYPE))) { + setting->setNetworktype(map.value(QLatin1String(NM_SETTING_GSM_NETWORK_TYPE)).value<int>()); + } else { +- setting->setNetworktype(NM_GSM_NETWORK_ANY); ++ setting->setNetworktype(NM_SETTING_GSM_NETWORK_TYPE_ANY); + } + if (map.contains("band")) { + setting->setBand(map.value("band").value<int>()); +@@ -62,7 +62,7 @@ QVariantMap GsmDbus::toMap() + map.insert("apn", setting->apn()); + if (!setting->networkid().isEmpty()) + map.insert(QLatin1String(NM_SETTING_GSM_NETWORK_ID), setting->networkid()); +- if (setting->networktype() != NM_GSM_NETWORK_ANY) { ++ if (setting->networktype() != NM_SETTING_GSM_NETWORK_TYPE_ANY) { + map.insert(QLatin1String(NM_SETTING_GSM_NETWORK_TYPE), setting->networktype()); + } + +diff -up networkmanagement-0.9/backends/NetworkManager/busconnection.h.nm-compat networkmanagement-0.9/backends/NetworkManager/busconnection.h +--- networkmanagement-0.9/backends/NetworkManager/busconnection.h.nm-compat 2011-02-21 14:25:52.000000000 -0600 ++++ networkmanagement-0.9/backends/NetworkManager/busconnection.h 2011-03-22 21:45:47.432492595 -0500 +@@ -51,9 +51,9 @@ namespace Knm + class BusConnection : public QObject + { + Q_OBJECT +- Q_CLASSINFO("D-Bus Interface", "org.freedesktop.NetworkManagerSettings.Connection") ++ Q_CLASSINFO("D-Bus Interface", "org.freedesktop.NetworkManager.Settings.Connection") + // Can QtDbus handle multiple interfaces being provided by one object like this? +- Q_CLASSINFO("D-Bus Interface", "org.freedesktop.NetworkManagerSettings.Connection.Secrets") ++ Q_CLASSINFO("D-Bus Interface", "org.freedesktop.NetworkManager.Settings.Connection.Secrets") + + public: + /** +diff -up networkmanagement-0.9/backends/NetworkManager/exportedconnection.h.nm-compat networkmanagement-0.9/backends/NetworkManager/exportedconnection.h +--- networkmanagement-0.9/backends/NetworkManager/exportedconnection.h.nm-compat 2011-03-22 21:49:45.233519674 -0500 ++++ networkmanagement-0.9/backends/NetworkManager/exportedconnection.h 2011-03-22 21:49:53.455416886 -0500 +@@ -30,9 +30,9 @@ class QVariant; + class ConnectionAdaptor: public QDBusAbstractAdaptor + { + Q_OBJECT +- Q_CLASSINFO("D-Bus Interface", "org.freedesktop.NetworkManagerSettings.Connection") ++ Q_CLASSINFO("D-Bus Interface", "org.freedesktop.NetworkManager.Settings.Connection") + Q_CLASSINFO("D-Bus Introspection", "" +-" <interface name=\"org.freedesktop.NetworkManagerSettings.Connection\">\n" ++" <interface name=\"org.freedesktop.NetworkManager.Settings.Connection\">\n" + " <method name=\"Update\">\n" + " <annotation value=\"impl_exported_connection_update\" name=\"org.freedesktop.DBus.GLib.CSymbol\"/>\n" + " <annotation value=\"\" name=\"org.freedesktop.DBus.GLib.Async\"/>\n" +diff -up networkmanagement-0.9/backends/NetworkManager/exportedconnectionsecrets.h.nm-compat networkmanagement-0.9/backends/NetworkManager/exportedconnectionsecrets.h +--- networkmanagement-0.9/backends/NetworkManager/exportedconnectionsecrets.h.nm-compat 2011-03-22 21:50:31.390942626 -0500 ++++ networkmanagement-0.9/backends/NetworkManager/exportedconnectionsecrets.h 2011-03-22 21:50:38.994847564 -0500 +@@ -30,9 +30,9 @@ class QVariant; + class SecretsAdaptor: public QDBusAbstractAdaptor + { + Q_OBJECT +- Q_CLASSINFO("D-Bus Interface", "org.freedesktop.NetworkManagerSettings.Connection.Secrets") ++ Q_CLASSINFO("D-Bus Interface", "org.freedesktop.NetworkManager.Settings.Connection.Secrets") + Q_CLASSINFO("D-Bus Introspection", "" +-" <interface name=\"org.freedesktop.NetworkManagerSettings.Connection.Secrets\">\n" ++" <interface name=\"org.freedesktop.NetworkManager.Settings.Connection.Secrets\">\n" + " <method name=\"GetSecrets\">\n" + " <annotation value=\"impl_exported_connection_get_secrets\" name=\"org.freedesktop.DBus.GLib.CSymbol\"/>\n" + " <annotation value=\"\" name=\"org.freedesktop.DBus.GLib.Async\"/>\n" +diff -up networkmanagement-0.9/backends/NetworkManager/introspection/nm-active-connection.xml.nm-compat networkmanagement-0.9/backends/NetworkManager/introspection/nm-active-connection.xml +--- networkmanagement-0.9/backends/NetworkManager/introspection/nm-active-connection.xml.nm-compat 2011-02-21 14:25:52.000000000 -0600 ++++ networkmanagement-0.9/backends/NetworkManager/introspection/nm-active-connection.xml 2011-03-22 21:45:47.433492583 -0500 +@@ -1,7 +1,7 @@ + <?xml version="1.0" encoding="UTF-8" ?> + + <node name="/" xmlns:tp="http://telepathy.freedesktop.org/wiki/DbusSpec#extensions-v0"> +- <interface name="org.freedesktop.NetworkManager.Connection.Active"> ++ <interface name="org.freedesktop.NetworkManagerCompat.Connection.Active"> + <property name="ServiceName" type="s" access="read"> + <tp:docstring>The D-Bus service name providing this connection.</tp:docstring> + </property> +diff -up networkmanagement-0.9/backends/NetworkManager/introspection/nm-connection-secrets.xml.nm-compat networkmanagement-0.9/backends/NetworkManager/introspection/nm-connection-secrets.xml +--- networkmanagement-0.9/backends/NetworkManager/introspection/nm-connection-secrets.xml.nm-compat 2011-02-21 14:25:52.000000000 -0600 ++++ networkmanagement-0.9/backends/NetworkManager/introspection/nm-connection-secrets.xml 2011-03-22 21:45:47.432492595 -0500 +@@ -2,7 +2,7 @@ + + <node name="/" xmlns:tp="http://telepathy.freedesktop.org/wiki/DbusSpec#extensions-v0"> + +- <interface name="org.freedesktop.NetworkManagerSettings.Connection.Secrets"> ++ <interface name="org.freedesktop.NetworkManager.Settings.Connection.Secrets"> + <tp:docstring> + Secrets have a separate interface so that they can be locked down. + </tp:docstring> +diff -up networkmanagement-0.9/backends/NetworkManager/introspection/nm-exported-connection.xml.nm-compat networkmanagement-0.9/backends/NetworkManager/introspection/nm-exported-connection.xml +--- networkmanagement-0.9/backends/NetworkManager/introspection/nm-exported-connection.xml.nm-compat 2011-02-21 14:25:52.000000000 -0600 ++++ networkmanagement-0.9/backends/NetworkManager/introspection/nm-exported-connection.xml 2011-03-22 21:45:47.433492583 -0500 +@@ -2,7 +2,7 @@ + + <node name="/" xmlns:tp="http://telepathy.freedesktop.org/wiki/DbusSpec#extensions-v0"> + +- <interface name="org.freedesktop.NetworkManagerSettings.Connection"> ++ <interface name="org.freedesktop.NetworkManager.Settings.Connection"> + <tp:docstring> + Represents a single network connection configuration. + </tp:docstring> +diff -up networkmanagement-0.9/backends/NetworkManager/introspection/nm-settings.xml.nm-compat networkmanagement-0.9/backends/NetworkManager/introspection/nm-settings.xml +--- networkmanagement-0.9/backends/NetworkManager/introspection/nm-settings.xml.nm-compat 2011-02-21 14:25:52.000000000 -0600 ++++ networkmanagement-0.9/backends/NetworkManager/introspection/nm-settings.xml 2011-03-22 21:45:47.433492583 -0500 +@@ -1,7 +1,7 @@ + <?xml version="1.0" encoding="UTF-8" ?> + + <node name="/" xmlns:tp="http://telepathy.freedesktop.org/wiki/DbusSpec#extensions-v0"> +- <interface name="org.freedesktop.NetworkManagerSettings"> ++ <interface name="org.freedesktop.NetworkManager.Settings"> + <tp:docstring> + The NetworkManagerSettings interface is provided by the service which provides connections to NetworkManager. + </tp:docstring> +diff -up networkmanagement-0.9/backends/NetworkManager/introspection/nm-vpn-connection.xml.nm-compat networkmanagement-0.9/backends/NetworkManager/introspection/nm-vpn-connection.xml +--- networkmanagement-0.9/backends/NetworkManager/introspection/nm-vpn-connection.xml.nm-compat 2011-02-21 14:25:52.000000000 -0600 ++++ networkmanagement-0.9/backends/NetworkManager/introspection/nm-vpn-connection.xml 2011-03-22 21:45:47.434492571 -0500 +@@ -1,7 +1,7 @@ + <?xml version="1.0" encoding="UTF-8" ?> + + <node name="/" xmlns:tp="http://telepathy.freedesktop.org/wiki/DbusSpec#extensions-v0"> +- <interface name="org.freedesktop.NetworkManager.VPN.Connection"> ++ <interface name="org.freedesktop.NetworkManagerCompat.VPN.Connection"> + <tp:docstring> + Represents an active connection to a Virtual Private Network. + </tp:docstring> +diff -up networkmanagement-0.9/backends/NetworkManager/nmdbussettingsservice.h.nm-compat networkmanagement-0.9/backends/NetworkManager/nmdbussettingsservice.h +--- networkmanagement-0.9/backends/NetworkManager/nmdbussettingsservice.h.nm-compat 2011-03-22 21:47:20.410330209 -0500 ++++ networkmanagement-0.9/backends/NetworkManager/nmdbussettingsservice.h 2011-03-22 21:47:25.547265991 -0500 +@@ -43,7 +43,7 @@ class NMDBusSettingsServicePrivate; + class KNM_EXPORT NMDBusSettingsService : public QObject, public ActivatableObserver, public ConnectionHandler + { + Q_OBJECT +-Q_CLASSINFO("D-Bus Interface", "org.freedesktop.NetworkManagerSettings") ++Q_CLASSINFO("D-Bus Interface", "org.freedesktop.NetworkManager.Settings") + + public: + enum ServiceStatus { Available, AlreadyRunning, AccessDenied, UnknownError }; +diff -up networkmanagement-0.9/backends/NetworkManager/nm-exported-connectioninterface.h.nm-compat networkmanagement-0.9/backends/NetworkManager/nm-exported-connectioninterface.h +--- networkmanagement-0.9/backends/NetworkManager/nm-exported-connectioninterface.h.nm-compat 2011-03-22 21:51:16.724375881 -0500 ++++ networkmanagement-0.9/backends/NetworkManager/nm-exported-connectioninterface.h 2011-03-22 21:51:22.869299057 -0500 +@@ -29,7 +29,7 @@ class OrgFreedesktopNetworkManagerSettin + Q_OBJECT + public: + static inline const char *staticInterfaceName() +- { return "org.freedesktop.NetworkManagerSettings.Connection"; } ++ { return "org.freedesktop.NetworkManager.Settings.Connection"; } + + public: + OrgFreedesktopNetworkManagerSettingsConnectionInterface(const QString &service, const QString &path, const QDBusConnection &connection, QObject *parent = 0); +diff -up networkmanagement-0.9/backends/NetworkManager/nm-settingsinterface.h.nm-compat networkmanagement-0.9/backends/NetworkManager/nm-settingsinterface.h +--- networkmanagement-0.9/backends/NetworkManager/nm-settingsinterface.h.nm-compat 2011-03-22 21:46:35.953885990 -0500 ++++ networkmanagement-0.9/backends/NetworkManager/nm-settingsinterface.h 2011-03-22 21:46:48.942723611 -0500 +@@ -29,7 +29,7 @@ class OrgFreedesktopNetworkManagerSettin + Q_OBJECT + public: + static inline const char *staticInterfaceName() +- { return "org.freedesktop.NetworkManagerSettings"; } ++ { return "org.freedesktop.NetworkManager.Settings"; } + + public: + OrgFreedesktopNetworkManagerSettingsInterface(const QString &service, const QString &path, const QDBusConnection &connection, QObject *parent = 0); +diff -up networkmanagement-0.9/NetworkManager-kde4.conf.nm-compat networkmanagement-0.9/NetworkManager-kde4.conf +--- networkmanagement-0.9/NetworkManager-kde4.conf.nm-compat 2011-02-21 14:25:52.000000000 -0600 ++++ networkmanagement-0.9/NetworkManager-kde4.conf 2011-03-22 21:45:47.434492571 -0500 +@@ -14,23 +14,23 @@ + <allow own="org.freedesktop.NetworkManagerUserSettings"/> + + <allow send_destination="org.freedesktop.NetworkManagerUserSettings" +- send_interface="org.freedesktop.NetworkManagerSettings"/> ++ send_interface="org.freedesktop.NetworkManager.Settings"/> + + <allow send_destination="org.freedesktop.NetworkManagerUserSettings" +- send_interface="org.freedesktop.NetworkManagerSettings.Connection"/> ++ send_interface="org.freedesktop.NetworkManager.Settings.Connection"/> + + <!-- Only root can get secrets --> + <allow send_destination="org.freedesktop.NetworkManagerUserSettings" +- send_interface="org.freedesktop.NetworkManagerSettings.Connection.Secrets"/> ++ send_interface="org.freedesktop.NetworkManager.Settings.Connection.Secrets"/> + </policy> + <policy at_console="true"> + <allow own="org.freedesktop.NetworkManagerUserSettings"/> + + <allow send_destination="org.freedesktop.NetworkManagerUserSettings" +- send_interface="org.freedesktop.NetworkManagerSettings"/> ++ send_interface="org.freedesktop.NetworkManager.Settings"/> + + <allow send_destination="org.freedesktop.NetworkManagerUserSettings" +- send_interface="org.freedesktop.NetworkManagerSettings.Connection"/> ++ send_interface="org.freedesktop.NetworkManager.Settings.Connection"/> + </policy> + <policy context="default"> + <allow send_destination="org.freedesktop.NetworkManagerUserSettings" diff --git a/kdebase-workspace-nm-compat.patch b/kdebase-workspace-nm-compat.patch new file mode 100644 index 0000000000..ff3170b656 --- /dev/null +++ b/kdebase-workspace-nm-compat.patch @@ -0,0 +1,271 @@ +diff -up kdebase-workspace-4.6.1/solid/networkmanager-0.7/manager.cpp.foo kdebase-workspace-4.6.1/solid/networkmanager-0.7/manager.cpp +--- kdebase-workspace-4.6.1/solid/networkmanager-0.7/manager.cpp.foo 2011-03-22 20:02:37.298879915 -0500 ++++ kdebase-workspace-4.6.1/solid/networkmanager-0.7/manager.cpp 2011-03-22 20:03:40.423090754 -0500 +@@ -118,16 +118,16 @@ QObject *NMNetworkManager::createNetwork + uint deviceType = devIface.deviceType(); + NMNetworkInterface * createdInterface = 0; + switch ( deviceType ) { +- case DEVICE_TYPE_802_3_ETHERNET: ++ case NM_DEVICE_TYPE_ETHERNET: + createdInterface = new NMWiredNetworkInterface(uni, this, 0); // these are deleted by the frontend manager + break; +- case DEVICE_TYPE_802_11_WIRELESS: ++ case NM_DEVICE_TYPE_WIFI: + createdInterface = new NMWirelessNetworkInterface(uni, this, 0); + break; +- case DEVICE_TYPE_GSM: ++ case 3: + createdInterface = new NMGsmNetworkInterface(uni, this, 0); + break; +- case DEVICE_TYPE_CDMA: ++ case 4: + createdInterface = new NMCdmaNetworkInterface(uni, this, 0); + break; + /* +diff -up kdebase-workspace-4.6.1/solid/networkmanager-0.7/dbus/introspection/nm-active-connection.xml.compat kdebase-workspace-4.6.1/solid/networkmanager-0.7/dbus/introspection/nm-active-connection.xml +--- kdebase-workspace-4.6.1/solid/networkmanager-0.7/dbus/introspection/nm-active-connection.xml.compat 2011-03-22 22:37:57.592360205 -0500 ++++ kdebase-workspace-4.6.1/solid/networkmanager-0.7/dbus/introspection/nm-active-connection.xml 2011-03-22 22:38:02.782295329 -0500 +@@ -1,7 +1,7 @@ + <?xml version="1.0" encoding="UTF-8" ?> + + <node name="/" xmlns:tp="http://telepathy.freedesktop.org/wiki/DbusSpec#extensions-v0"> +- <interface name="org.freedesktop.NetworkManager.Connection.Active"> ++ <interface name="org.freedesktop.NetworkManagerCompat.Connection.Active"> + <property name="ServiceName" type="s" access="read"> + <tp:docstring>The D-Bus service name providing this connection.</tp:docstring> + </property> +diff -up kdebase-workspace-4.6.1/solid/networkmanager-0.7/dbus/introspection/nm-device.xml.compat kdebase-workspace-4.6.1/solid/networkmanager-0.7/dbus/introspection/nm-device.xml +--- kdebase-workspace-4.6.1/solid/networkmanager-0.7/dbus/introspection/nm-device.xml.compat 2011-03-22 22:44:02.289800865 -0500 ++++ kdebase-workspace-4.6.1/solid/networkmanager-0.7/dbus/introspection/nm-device.xml 2011-03-22 22:44:08.398724494 -0500 +@@ -1,7 +1,7 @@ + <?xml version="1.0" encoding="UTF-8" ?> + + <node name="/" xmlns:tp="http://telepathy.freedesktop.org/wiki/DbusSpec#extensions-v0"> +- <interface name="org.freedesktop.NetworkManager.Device"> ++ <interface name="org.freedesktop.NetworkManagerCompat.Device"> + <property name="Udi" type="s" access="read"> + <tp:docstring> + Unique Device Identifier. +diff -up kdebase-workspace-4.6.1/solid/networkmanager-0.7/dbus/introspection/nm-exported-connection.xml.compat kdebase-workspace-4.6.1/solid/networkmanager-0.7/dbus/introspection/nm-exported-connection.xml +--- kdebase-workspace-4.6.1/solid/networkmanager-0.7/dbus/introspection/nm-exported-connection.xml.compat 2011-03-22 21:21:03.447044965 -0500 ++++ kdebase-workspace-4.6.1/solid/networkmanager-0.7/dbus/introspection/nm-exported-connection.xml 2011-03-22 21:21:13.615917837 -0500 +@@ -2,7 +2,7 @@ + + <node name="/" xmlns:tp="http://telepathy.freedesktop.org/wiki/DbusSpec#extensions-v0"> + +- <interface name="org.freedesktop.NetworkManagerSettings.Connection"> ++ <interface name="org.freedesktop.NetworkManager.Settings.Connection"> + <tp:docstring> + Represents a single network connection configuration. + </tp:docstring> +@@ -59,7 +59,7 @@ + + </interface> + +- <interface name="org.freedesktop.NetworkManagerSettings.Connection.Secrets"> ++ <interface name="org.freedesktop.NetworkManager.Settings.Connection.Secrets"> + <tp:docstring> + Secrets have a separate interface so that they can be locked down. + </tp:docstring> +diff -up kdebase-workspace-4.6.1/solid/networkmanager-0.7/dbus/introspection/nm-manager-client.xml.compat kdebase-workspace-4.6.1/solid/networkmanager-0.7/dbus/introspection/nm-manager-client.xml +--- kdebase-workspace-4.6.1/solid/networkmanager-0.7/dbus/introspection/nm-manager-client.xml.compat 2011-03-22 22:39:58.308851042 -0500 ++++ kdebase-workspace-4.6.1/solid/networkmanager-0.7/dbus/introspection/nm-manager-client.xml 2011-03-22 22:40:03.794782464 -0500 +@@ -13,7 +13,7 @@ object. dbus-glib generates the same bo + --> + + <node name="/"> +- <interface name="org.freedesktop.NetworkManager"> ++ <interface name="org.freedesktop.NetworkManagerCompat"> + <method name="GetDevices"> + <annotation name="org.freedesktop.DBus.GLib.CSymbol" value="impl_manager_get_devices"/> + <arg name="devices" type="ao" direction="out"/> +diff -up kdebase-workspace-4.6.1/solid/networkmanager-0.7/dbus/introspection/nm-manager.xml.compat kdebase-workspace-4.6.1/solid/networkmanager-0.7/dbus/introspection/nm-manager.xml +--- kdebase-workspace-4.6.1/solid/networkmanager-0.7/dbus/introspection/nm-manager.xml.compat 2011-03-22 22:40:35.208389741 -0500 ++++ kdebase-workspace-4.6.1/solid/networkmanager-0.7/dbus/introspection/nm-manager.xml 2011-03-22 22:40:41.365312768 -0500 +@@ -8,7 +8,7 @@ + --> + + <node name="/" xmlns:tp="http://telepathy.freedesktop.org/wiki/DbusSpec#extensions-v0"> +- <interface name="org.freedesktop.NetworkManager"> ++ <interface name="org.freedesktop.NetworkManagerCompat"> + <method name="GetDevices"> + <tp:docstring> + Get the list of network devices. +diff -up kdebase-workspace-4.6.1/solid/networkmanager-0.7/dbus/introspection/nm-settings-connection.xml.compat kdebase-workspace-4.6.1/solid/networkmanager-0.7/dbus/introspection/nm-settings-connection.xml +--- kdebase-workspace-4.6.1/solid/networkmanager-0.7/dbus/introspection/nm-settings-connection.xml.compat 2011-03-22 21:27:09.861464155 -0500 ++++ kdebase-workspace-4.6.1/solid/networkmanager-0.7/dbus/introspection/nm-settings-connection.xml 2011-03-22 21:28:04.230784445 -0500 +@@ -1,7 +1,7 @@ + <?xml version="1.0" encoding="UTF-8"?> + <!DOCTYPE node PUBLIC "-//freedesktop//DTD D-BUS Object Introspection 1.0//EN" "http://www.freedesktop.org/standards/dbus/1.0/introspect.dtd"> + <node name="/"> +- <interface name="org.freedesktop.NetworkManagerSettings.Connection"> ++ <interface name="org.freedesktop.NetworkManager.Settings.Connection"> + <method name="GetID"> + <annotation name="org.freedesktop.DBus.GLib.CSymbol" value="impl_connection_settings_get_id"/> + <arg name="id" type="s" direction="out"/> +@@ -17,7 +17,7 @@ + </signal> + <signal name="Removed"/> + </interface> +- <interface name="org.freedesktop.NetworkManagerSettings.Connection.Secrets"> ++ <interface name="org.freedesktop.NetworkManager.Settings.Connection.Secrets"> + <method name="GetSecrets"> + <annotation name="org.freedesktop.DBus.GLib.CSymbol" value="impl_connection_settings_get_secrets"/> + <annotation name="org.freedesktop.DBus.GLib.Async" value=""/> +diff -up kdebase-workspace-4.6.1/solid/networkmanager-0.7/dbus/introspection/nm-settings-system.xml.compat kdebase-workspace-4.6.1/solid/networkmanager-0.7/dbus/introspection/nm-settings-system.xml +diff -up kdebase-workspace-4.6.1/solid/networkmanager-0.7/dbus/introspection/nm-settings.xml.compat kdebase-workspace-4.6.1/solid/networkmanager-0.7/dbus/introspection/nm-settings.xml +--- kdebase-workspace-4.6.1/solid/networkmanager-0.7/dbus/introspection/nm-settings.xml.compat 2011-03-22 21:27:55.513893420 -0500 ++++ kdebase-workspace-4.6.1/solid/networkmanager-0.7/dbus/introspection/nm-settings.xml 2011-03-22 21:28:01.964812774 -0500 +@@ -1,7 +1,7 @@ + <?xml version="1.0" encoding="UTF-8" ?> + + <node name="/" xmlns:tp="http://telepathy.freedesktop.org/wiki/DbusSpec#extensions-v0"> +- <interface name="org.freedesktop.NetworkManagerSettings"> ++ <interface name="org.freedesktop.NetworkManager.Settings"> + <tp:docstring> + The NetworkManagerSettings interface is provided by the service which provides connections to NetworkManager. + </tp:docstring> +diff -up kdebase-workspace-4.6.1/solid/networkmanager-0.7/dbus/introspection/nm-vpn-connection.xml.compat kdebase-workspace-4.6.1/solid/networkmanager-0.7/dbus/introspection/nm-vpn-connection.xml +--- kdebase-workspace-4.6.1/solid/networkmanager-0.7/dbus/introspection/nm-vpn-connection.xml.compat 2011-03-22 22:38:16.725121014 -0500 ++++ kdebase-workspace-4.6.1/solid/networkmanager-0.7/dbus/introspection/nm-vpn-connection.xml 2011-03-22 22:38:27.426987227 -0500 +@@ -1,7 +1,7 @@ + <?xml version="1.0" encoding="UTF-8" ?> + + <node name="/" xmlns:tp="http://telepathy.freedesktop.org/wiki/DbusSpec#extensions-v0"> +- <interface name="org.freedesktop.NetworkManager.Connection.Active"> ++ <interface name="org.freedesktop.NetworkManagerCompat.Connection.Active"> + <property name="ServiceName" type="s" access="read"> + <tp:docstring>The D-Bus service name providing this connection.</tp:docstring> + </property> +@@ -22,7 +22,7 @@ + </property> + </interface> + +- <interface name="org.freedesktop.NetworkManager.VPN.Connection"> ++ <interface name="org.freedesktop.NetworkManagerCompat.VPN.Connection"> + <tp:docstring> + Represents an active connection to a Virtual Private Network. + </tp:docstring> +diff -up kdebase-workspace-4.6.1/solid/networkmanager-0.7/dbus/nm-deviceinterface.h.compat kdebase-workspace-4.6.1/solid/networkmanager-0.7/dbus/nm-deviceinterface.h +--- kdebase-workspace-4.6.1/solid/networkmanager-0.7/dbus/nm-deviceinterface.h.compat 2011-03-22 22:45:42.681545791 -0500 ++++ kdebase-workspace-4.6.1/solid/networkmanager-0.7/dbus/nm-deviceinterface.h 2011-03-22 22:45:57.396361835 -0500 +@@ -28,7 +28,7 @@ class OrgFreedesktopNetworkManagerDevice + Q_OBJECT + public: + static inline const char *staticInterfaceName() +- { return "org.freedesktop.NetworkManager.Device"; } ++ { return "org.freedesktop.NetworkManagerCompat.Device"; } + + public: + OrgFreedesktopNetworkManagerDeviceInterface(const QString &service, const QString &path, const QDBusConnection &connection, QObject *parent = 0); +diff -up kdebase-workspace-4.6.1/solid/networkmanager-0.7/dbus/nm-exported-connectioninterface.h.compat kdebase-workspace-4.6.1/solid/networkmanager-0.7/dbus/nm-exported-connectioninterface.h +--- kdebase-workspace-4.6.1/solid/networkmanager-0.7/dbus/nm-exported-connectioninterface.h.compat 2011-03-22 22:35:56.539873577 -0500 ++++ kdebase-workspace-4.6.1/solid/networkmanager-0.7/dbus/nm-exported-connectioninterface.h 2011-03-22 22:47:32.353174713 -0500 +@@ -31,7 +31,7 @@ class OrgFreedesktopNetworkManagerSettin + Q_OBJECT + public: + static inline const char *staticInterfaceName() +- { return "org.freedesktop.NetworkManagerSettings.Connection"; } ++ { return "org.freedesktop.NetworkManager.Settings.Connection"; } + + public: + OrgFreedesktopNetworkManagerSettingsConnectionInterface(const QString &service, const QString &path, const QDBusConnection &connection, QObject *parent = 0); +@@ -64,7 +64,7 @@ class OrgFreedesktopNetworkManagerSettin + Q_OBJECT + public: + static inline const char *staticInterfaceName() +- { return "org.freedesktop.NetworkManagerSettings.Connection.Secrets"; } ++ { return "org.freedesktop.NetworkManager.Settings.Connection.Secrets"; } + + public: + OrgFreedesktopNetworkManagerSettingsConnectionSecretsInterface(const QString &service, const QString &path, const QDBusConnection &connection, QObject *parent = 0); +diff -up kdebase-workspace-4.6.1/solid/networkmanager-0.7/dbus/nm-manager-clientinterface.h.compat kdebase-workspace-4.6.1/solid/networkmanager-0.7/dbus/nm-manager-clientinterface.h +--- kdebase-workspace-4.6.1/solid/networkmanager-0.7/dbus/nm-manager-clientinterface.h.compat 2011-03-22 22:42:14.897143461 -0500 ++++ kdebase-workspace-4.6.1/solid/networkmanager-0.7/dbus/nm-manager-clientinterface.h 2011-03-22 22:42:22.576047460 -0500 +@@ -28,7 +28,7 @@ class OrgFreedesktopNetworkManagerInterf + Q_OBJECT + public: + static inline const char *staticInterfaceName() +- { return "org.freedesktop.NetworkManager"; } ++ { return "org.freedesktop.NetworkManagerCompat"; } + + public: + OrgFreedesktopNetworkManagerInterface(const QString &service, const QString &path, const QDBusConnection &connection, QObject *parent = 0); +diff -up kdebase-workspace-4.6.1/solid/networkmanager-0.7/dbus/nm-vpn-connectioninterface.h.compat kdebase-workspace-4.6.1/solid/networkmanager-0.7/dbus/nm-vpn-connectioninterface.h +--- kdebase-workspace-4.6.1/solid/networkmanager-0.7/dbus/nm-vpn-connectioninterface.h.compat 2011-03-22 22:39:22.821294703 -0500 ++++ kdebase-workspace-4.6.1/solid/networkmanager-0.7/dbus/nm-vpn-connectioninterface.h 2011-03-22 22:39:28.974217781 -0500 +@@ -28,7 +28,7 @@ class OrgFreedesktopNetworkManagerVPNCon + Q_OBJECT + public: + static inline const char *staticInterfaceName() +- { return "org.freedesktop.NetworkManager.VPN.Connection"; } ++ { return "org.freedesktop.NetworkManagerCompat.VPN.Connection"; } + + public: + OrgFreedesktopNetworkManagerVPNConnectionInterface(const QString &service, const QString &path, const QDBusConnection &connection, QObject *parent = 0); +diff -up kdebase-workspace-4.6.1/solid/networkmanager-0.7/manager.cpp.compat kdebase-workspace-4.6.1/solid/networkmanager-0.7/manager.cpp +--- kdebase-workspace-4.6.1/solid/networkmanager-0.7/manager.cpp.compat 2011-03-22 22:48:32.189426653 -0500 ++++ kdebase-workspace-4.6.1/solid/networkmanager-0.7/manager.cpp 2011-03-22 22:48:52.074178063 -0500 +@@ -31,12 +31,12 @@ along with this program. If not, see <h + #include "networkcdmainterface.h" + + const QString NMNetworkManager::DBUS_SERVICE(QString::fromLatin1("org.freedesktop.NetworkManager")); +-const QString NMNetworkManager::DBUS_DAEMON_PATH(QString::fromLatin1("/org/freedesktop/NetworkManager")); ++const QString NMNetworkManager::DBUS_DAEMON_PATH(QString::fromLatin1("/org/freedesktop/NetworkManagerCompat")); + const QString NMNetworkManager::DBUS_USER_SETTINGS_PATH(QString::fromLatin1("org.freedesktop.NetworkManagerUserSettings")); + const QString NMNetworkManager::DBUS_SYSTEM_SETTINGS_PATH(QString::fromLatin1("org.freedesktop.NetworkManagerSystemSettings")); + + +-NMNetworkManagerPrivate::NMNetworkManagerPrivate() : iface(NMNetworkManager::DBUS_SERVICE, "/org/freedesktop/NetworkManager", QDBusConnection::systemBus()) ++NMNetworkManagerPrivate::NMNetworkManagerPrivate() : iface(NMNetworkManager::DBUS_SERVICE, "/org/freedesktop/NetworkManagerCompat", QDBusConnection::systemBus()) + { + kDebug(1441) << NMNetworkManager::DBUS_SERVICE; + } +diff -up kdebase-workspace-4.6.1/solid/networkmanager-0.7/dbus/introspection/nm-device-ethernet.xml.compat kdebase-workspace-4.6.1/solid/networkmanager-0.7/dbus/introspection/nm-device-ethernet.xml +--- kdebase-workspace-4.6.1/solid/networkmanager-0.7/dbus/introspection/nm-device-ethernet.xml.compat 2011-03-23 10:58:34.591823501 -0500 ++++ kdebase-workspace-4.6.1/solid/networkmanager-0.7/dbus/introspection/nm-device-ethernet.xml 2011-03-23 10:58:39.481762370 -0500 +@@ -1,7 +1,7 @@ + <?xml version="1.0" encoding="UTF-8" ?> + + <node name="/" xmlns:tp="http://telepathy.freedesktop.org/wiki/DbusSpec#extensions-v0"> +- <interface name="org.freedesktop.NetworkManager.Device.Wired"> ++ <interface name="org.freedesktop.NetworkManagerCompat.Device.Wired"> + + <property name="HwAddress" type="s" access="read"> + <tp:docstring> +diff -up kdebase-workspace-4.6.1/solid/networkmanager-0.7/dbus/nm-device-ethernetinterface.h.compat kdebase-workspace-4.6.1/solid/networkmanager-0.7/dbus/nm-device-ethernetinterface.h +--- kdebase-workspace-4.6.1/solid/networkmanager-0.7/dbus/nm-device-ethernetinterface.h.compat 2011-03-23 10:58:48.815645681 -0500 ++++ kdebase-workspace-4.6.1/solid/networkmanager-0.7/dbus/nm-device-ethernetinterface.h 2011-03-23 10:58:53.599585872 -0500 +@@ -28,7 +28,7 @@ class OrgFreedesktopNetworkManagerDevice + Q_OBJECT + public: + static inline const char *staticInterfaceName() +- { return "org.freedesktop.NetworkManager.Device.Wired"; } ++ { return "org.freedesktop.NetworkManagerCompat.Device.Wired"; } + + public: + OrgFreedesktopNetworkManagerDeviceWiredInterface(const QString &service, const QString &path, const QDBusConnection &connection, QObject *parent = 0); +diff -up kdebase-workspace-4.6.1/solid/networkmanager-0.7/dbus/introspection/nm-device-wifi.xml.bar kdebase-workspace-4.6.1/solid/networkmanager-0.7/dbus/introspection/nm-device-wifi.xml +--- kdebase-workspace-4.6.1/solid/networkmanager-0.7/dbus/introspection/nm-device-wifi.xml.bar 2011-03-23 11:00:13.977581010 -0500 ++++ kdebase-workspace-4.6.1/solid/networkmanager-0.7/dbus/introspection/nm-device-wifi.xml 2011-03-23 11:00:19.949506349 -0500 +@@ -1,7 +1,7 @@ + <?xml version="1.0" encoding="UTF-8" ?> + + <node name="/" xmlns:tp="http://telepathy.freedesktop.org/wiki/DbusSpec#extensions-v0"> +- <interface name="org.freedesktop.NetworkManager.Device.Wireless"> ++ <interface name="org.freedesktop.NetworkManagerCompat.Device.Wireless"> + <method name="GetAccessPoints"> + <annotation name="org.freedesktop.DBus.GLib.CSymbol" value="impl_device_get_access_points"/> + <arg name="access_points" type="ao" direction="out"> +diff -up kdebase-workspace-4.6.1/solid/networkmanager-0.7/dbus/nm-device-wifiinterface.h.bar kdebase-workspace-4.6.1/solid/networkmanager-0.7/dbus/nm-device-wifiinterface.h +--- kdebase-workspace-4.6.1/solid/networkmanager-0.7/dbus/nm-device-wifiinterface.h.bar 2011-03-23 11:00:32.229352829 -0500 ++++ kdebase-workspace-4.6.1/solid/networkmanager-0.7/dbus/nm-device-wifiinterface.h 2011-03-23 11:00:38.372276033 -0500 +@@ -28,7 +28,7 @@ class OrgFreedesktopNetworkManagerDevice + Q_OBJECT + public: + static inline const char *staticInterfaceName() +- { return "org.freedesktop.NetworkManager.Device.Wireless"; } ++ { return "org.freedesktop.NetworkManagerCompat.Device.Wireless"; } + + public: + OrgFreedesktopNetworkManagerDeviceWirelessInterface(const QString &service, const QString &path, const QDBusConnection &connection, QObject *parent = 0); diff --git a/src/Makefile.am b/src/Makefile.am index 94e1a8c0c1..9bdfbaad6d 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -8,6 +8,7 @@ SUBDIRS= \ ppp-manager \ backends \ dnsmasq-manager \ + compat \ modem-manager \ bluez-manager \ settings @@ -264,6 +265,7 @@ NetworkManager_LDADD = \ ./modem-manager/libmodem-manager.la \ ./bluez-manager/libbluez-manager.la \ ./settings/libsettings.la \ + ./compat/libcompat.la \ $(WIMAX_LIBS) \ ./backends/libnmbackend.la \ $(top_builddir)/libnm-util/libnm-util.la \ diff --git a/src/compat/Makefile.am b/src/compat/Makefile.am new file mode 100644 index 0000000000..77833f2dba --- /dev/null +++ b/src/compat/Makefile.am @@ -0,0 +1,104 @@ +INCLUDES = -I${top_srcdir} \ + -I${top_srcdir}/include \ + -I${top_builddir}/marshallers \ + -I${top_srcdir}/src/logging \ + -I${top_srcdir}/src/settings/ \ + -I${top_srcdir}/src/ \ + -I${top_srcdir}/src/modem-manager/ \ + -I${top_srcdir}/src/vpn-manager/ \ + -I${top_srcdir}/libnm-util + +EXTRA_DIST = \ + nm-compat-device-cdma.xml \ + nm-compat-device-gsm.xml \ + nm-compat-device-serial.xml \ + nm-compat-device.xml \ + nm-compat-device-ethernet.xml \ + nm-compat-device-wifi.xml \ + nm-compat-manager.xml \ + nm-compat-settings.xml \ + nm-compat-exported-connection.xml \ + nm-compat-active-connection.xml \ + nm-compat-vpn-connection.xml + +nm-compat-device-cdma-glue.h: nm-compat-device-cdma.xml + $(AM_V_GEN) dbus-binding-tool --prefix=nm_compat_device_cdma --mode=glib-server --output=$@ $< + +nm-compat-device-gsm-glue.h: nm-compat-device-gsm.xml + $(AM_V_GEN) dbus-binding-tool --prefix=nm_compat_device_gsm --mode=glib-server --output=$@ $< + +nm-compat-device-serial-glue.h: nm-compat-device-serial.xml + $(AM_V_GEN) dbus-binding-tool --prefix=nm_compat_device_serial --mode=glib-server --output=$@ $< + +nm-compat-device-glue.h: nm-compat-device.xml + $(AM_V_GEN) dbus-binding-tool --prefix=nm_compat_device --mode=glib-server --output=$@ $< + +nm-compat-device-ethernet-glue.h: nm-compat-device-ethernet.xml + $(AM_V_GEN) dbus-binding-tool --prefix=nm_compat_device_ethernet --mode=glib-server --output=$@ $< + +nm-compat-device-wifi-glue.h: nm-compat-device-wifi.xml + $(AM_V_GEN) dbus-binding-tool --prefix=nm_compat_device_wifi --mode=glib-server --output=$@ $< + +nm-compat-manager-glue.h: nm-compat-manager.xml + $(AM_V_GEN) dbus-binding-tool --prefix=nm_compat_manager --mode=glib-server --output=$@ $< + +nm-compat-settings-glue.h: nm-compat-settings.xml + $(AM_V_GEN) dbus-binding-tool --prefix=nm_compat_settings --mode=glib-server --output=$@ $< + +nm-compat-exported-connection-glue.h: nm-compat-exported-connection.xml + $(AM_V_GEN) dbus-binding-tool --prefix=nm_compat_exported_connection --mode=glib-server --output=$@ $< + +nm-compat-active-connection-glue.h: nm-compat-active-connection.xml + $(AM_V_GEN) dbus-binding-tool --prefix=nm_compat_active_connection --mode=glib-server --output=$@ $< + +nm-compat-vpn-connection-glue.h: nm-compat-vpn-connection.xml + $(AM_V_GEN) dbus-binding-tool --prefix=nm_compat_vpn_connection --mode=glib-server --output=$@ $< + +BUILT_SOURCES = \ + nm-compat-device-cdma-glue.h \ + nm-compat-device-gsm-glue.h \ + nm-compat-device-serial-glue.h \ + nm-compat-device-glue.h \ + nm-compat-device-ethernet-glue.h \ + nm-compat-device-wifi-glue.h \ + nm-compat-manager-glue.h \ + nm-compat-settings-glue.h \ + nm-compat-exported-connection-glue.h \ + nm-compat-active-connection-glue.h \ + nm-compat-vpn-connection-glue.h + +noinst_LTLIBRARIES = libcompat.la + +libcompat_la_SOURCES = \ + nm-compat-manager.c \ + nm-compat-manager.h \ + nm-compat-device.c \ + nm-compat-device.h \ + nm-compat-device-ethernet.c \ + nm-compat-device-ethernet.h \ + nm-compat-device-wifi.c \ + nm-compat-device-wifi.h \ + nm-compat-device-gsm.c \ + nm-compat-device-gsm.h \ + nm-compat-device-cdma.c \ + nm-compat-device-cdma.h \ + nm-compat-active-connection.c \ + nm-compat-active-connection.h \ + nm-compat-act-request.c \ + nm-compat-act-request.h \ + nm-compat-vpn-connection.c \ + nm-compat-vpn-connection.h + +libcompat_la_CPPFLAGS = \ + $(DBUS_CFLAGS) \ + $(GLIB_CFLAGS) \ + -DG_DISABLE_DEPRECATED + +libcompat_la_LIBADD = \ + $(top_builddir)/marshallers/libmarshallers.la \ + $(top_builddir)/src/logging/libnm-logging.la \ + $(DBUS_LIBS) \ + $(GLIB_LIBS) + +CLEANFILES = $(BUILT_SOURCES) + diff --git a/src/compat/nm-compat-act-request.c b/src/compat/nm-compat-act-request.c new file mode 100644 index 0000000000..5ebcd259c3 --- /dev/null +++ b/src/compat/nm-compat-act-request.c @@ -0,0 +1,84 @@ +/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */ +/* NetworkManager -- Network link manager + * + * 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 Red Hat, Inc. + */ + +#include "config.h" + +#include <glib.h> + +#include "NetworkManager.h" +#include "nm-properties-changed-signal.h" +#include "nm-compat-act-request.h" + +G_DEFINE_TYPE (NMCompatActRequest, nm_compat_act_request, NM_TYPE_COMPAT_ACTIVE_CONNECTION) + +enum { + PROPERTIES_CHANGED, + LAST_SIGNAL +}; +static guint signals[LAST_SIGNAL] = { 0 }; + +/********************************************************************/ + +NMCompatActRequest * +nm_compat_act_request_new (NMActRequest *parent, DBusGConnection *bus) +{ + NMCompatActRequest *self; + + self = (NMCompatActRequest *) g_object_new (NM_TYPE_COMPAT_ACT_REQUEST, + "parent", parent, + NULL); + if (self) + nm_compat_active_connection_export (NM_COMPAT_ACTIVE_CONNECTION (self), bus); + + return self; +} + +static void +nm_compat_act_request_init (NMCompatActRequest *self) +{ +} + +static NMConnection * +get_connection (NMCompatActiveConnection *compat, GObject *parent) +{ + /* Parent should be an NMActRequest */ + return nm_act_request_get_connection (NM_ACT_REQUEST (parent)); +} + +static NMDevice * +get_device (NMCompatActiveConnection *compat, GObject *parent) +{ + /* Parent should be an NMActRequest */ + return NM_DEVICE (nm_act_request_get_device (NM_ACT_REQUEST (parent))); +} + +static void +nm_compat_act_request_class_init (NMCompatActRequestClass *compat_class) +{ + NMCompatActiveConnectionClass *ac_class = NM_COMPAT_ACTIVE_CONNECTION_CLASS (compat_class); + + ac_class->get_connection = get_connection; + ac_class->get_device = get_device; + + signals[PROPERTIES_CHANGED] = + nm_properties_changed_signal_new (G_OBJECT_CLASS (compat_class), + G_STRUCT_OFFSET (NMCompatActRequestClass, properties_changed)); +} + diff --git a/src/compat/nm-compat-act-request.h b/src/compat/nm-compat-act-request.h new file mode 100644 index 0000000000..47039a4f8b --- /dev/null +++ b/src/compat/nm-compat-act-request.h @@ -0,0 +1,53 @@ +/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */ +/* NetworkManager -- Network link manager + * + * 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 Red Hat, Inc. + */ + +#ifndef NM_COMPAT_ACT_REQUEST_H +#define NM_COMPAT_ACT_REQUEST_H + +#include <glib.h> +#include <glib-object.h> +#include <dbus/dbus-glib-lowlevel.h> +#include "nm-activation-request.h" +#include "nm-compat-active-connection.h" + +#define NM_TYPE_COMPAT_ACT_REQUEST (nm_compat_act_request_get_type ()) +#define NM_COMPAT_ACT_REQUEST(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), NM_TYPE_COMPAT_ACT_REQUEST, NMCompatActRequest)) +#define NM_COMPAT_ACT_REQUEST_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), NM_TYPE_COMPAT_ACT_REQUEST, NMCompatActRequestClass)) +#define NM_IS_COMPAT_ACT_REQUEST(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), NM_TYPE_COMPAT_ACT_REQUEST)) +#define NM_IS_COMPAT_ACT_REQUEST_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((obj), NM_TYPE_COMPAT_ACT_REQUEST)) +#define NM_COMPAT_ACT_REQUEST_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), NM_TYPE_COMPAT_ACT_REQUEST, NMCompatActRequestClass)) + +typedef struct { + NMCompatActiveConnection parent; +} NMCompatActRequest; + +typedef struct { + NMCompatActiveConnectionClass parent; + + void (*properties_changed) (NMCompatActRequest *self, GHashTable *properties); +} NMCompatActRequestClass; + +GType nm_compat_act_request_get_type (void); + +NMCompatActRequest *nm_compat_act_request_new (NMActRequest *parent, DBusGConnection *bus); + +const char *nm_compat_act_request_get_path (NMCompatActRequest *self); + +#endif /* NM_COMPAT_ACT_REQUEST_H */ diff --git a/src/compat/nm-compat-active-connection.c b/src/compat/nm-compat-active-connection.c new file mode 100644 index 0000000000..8b6e75fa1d --- /dev/null +++ b/src/compat/nm-compat-active-connection.c @@ -0,0 +1,255 @@ +/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */ +/* NetworkManager -- Network link manager + * + * 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 Red Hat, Inc. + */ + +#include "config.h" + +#include <glib.h> +#include <string.h> +#include <dbus/dbus-glib-lowlevel.h> + +#include "NetworkManager.h" +#include "nm-dbus-glib-types.h" +#include "nm-marshal.h" +#include "nm-compat-active-connection.h" +#include "nm-compat-device.h" +#include "nm-properties-changed-signal.h" + +G_DEFINE_ABSTRACT_TYPE (NMCompatActiveConnection, nm_compat_active_connection, G_TYPE_OBJECT) + +#define NM_COMPAT_ACTIVE_CONNECTION_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), \ + NM_TYPE_COMPAT_ACTIVE_CONNECTION, \ + NMCompatActiveConnectionPrivate)) + +typedef struct { + GObject *parent; + char *path; +} NMCompatActiveConnectionPrivate; + + +enum { + PROP_0 = 0x1000, + PROP_SERVICE_NAME, + PROP_CONNECTION, + PROP_UUID, + PROP_SPECIFIC_OBJECT, + PROP_DEVICES, + PROP_STATE, + PROP_DEFAULT, + PROP_DEFAULT6, + PROP_VPN, + PROP_PARENT, + + LAST_PROP +}; + +#include "nm-compat-active-connection-glue.h" + +#define NM_OLD_ACTIVE_CONNECTION_SERVICE_NAME "service-name" + +/*************************************************************************/ + +#define NM_OLD_AC_STATE_UNKNOWN 0 +#define NM_OLD_AC_STATE_ACTIVATING 1 +#define NM_OLD_AC_STATE_ACTIVATED 2 + +static guint32 +new_state_to_old (NMActiveConnectionState state) +{ + switch (state) { + case NM_ACTIVE_CONNECTION_STATE_ACTIVATING: + return NM_OLD_AC_STATE_ACTIVATING; + case NM_ACTIVE_CONNECTION_STATE_ACTIVATED: + return NM_OLD_AC_STATE_ACTIVATED; + default: + return NM_OLD_AC_STATE_UNKNOWN; + } + g_assert_not_reached (); +} + +static void +prop_reemit_cb (GObject *object, GParamSpec *pspec, NMCompatActiveConnection *self) +{ + g_object_notify (G_OBJECT (self), pspec->name); +} + +/*************************************************************************/ + +const char * +nm_compat_active_connection_get_path (NMCompatActiveConnection *self) +{ + return NM_COMPAT_ACTIVE_CONNECTION_GET_PRIVATE (self)->path; +} + +GObject * +nm_compat_active_connection_get_parent (NMCompatActiveConnection *self) +{ + return NM_COMPAT_ACTIVE_CONNECTION_GET_PRIVATE (self)->parent; +} + +void +nm_compat_active_connection_export (NMCompatActiveConnection *self, DBusGConnection *bus) +{ + NMCompatActiveConnectionPrivate *priv = NM_COMPAT_ACTIVE_CONNECTION_GET_PRIVATE (self); + static guint32 idx = 0; + + priv->path = g_strdup_printf ("/org/freedesktop/NetworkManagerCompat/ActiveConnection/%d", idx++); + dbus_g_connection_register_g_object (bus, priv->path, G_OBJECT (self)); +} + +static GObject* +constructor (GType type, + guint n_construct_params, + GObjectConstructParam *construct_params) +{ + GObject *object; + NMCompatActiveConnection *self; + NMCompatActiveConnectionPrivate *priv; + + object = G_OBJECT_CLASS (nm_compat_active_connection_parent_class)->constructor (type, n_construct_params, construct_params); + if (object) { + self = NM_COMPAT_ACTIVE_CONNECTION (object); + priv = NM_COMPAT_ACTIVE_CONNECTION_GET_PRIVATE (self); + g_signal_connect (priv->parent, "notify::" NM_OLD_ACTIVE_CONNECTION_SERVICE_NAME, G_CALLBACK (prop_reemit_cb), self); + g_signal_connect (priv->parent, "notify::" NM_ACTIVE_CONNECTION_CONNECTION, G_CALLBACK (prop_reemit_cb), self); + g_signal_connect (priv->parent, "notify::" NM_ACTIVE_CONNECTION_SPECIFIC_OBJECT, G_CALLBACK (prop_reemit_cb), self); + g_signal_connect (priv->parent, "notify::" NM_ACTIVE_CONNECTION_DEVICES, G_CALLBACK (prop_reemit_cb), self); + g_signal_connect (priv->parent, "notify::" NM_ACTIVE_CONNECTION_STATE, G_CALLBACK (prop_reemit_cb), self); + g_signal_connect (priv->parent, "notify::" NM_ACTIVE_CONNECTION_DEFAULT, G_CALLBACK (prop_reemit_cb), self); + g_signal_connect (priv->parent, "notify::" NM_ACTIVE_CONNECTION_DEFAULT6, G_CALLBACK (prop_reemit_cb), self); + g_signal_connect (priv->parent, "notify::" NM_ACTIVE_CONNECTION_VPN, G_CALLBACK (prop_reemit_cb), self); + } + return object; +} + +static void +nm_compat_active_connection_init (NMCompatActiveConnection *self) +{ +} + +static void +set_property (GObject *object, guint prop_id, + const GValue *value, GParamSpec *pspec) +{ + NMCompatActiveConnection *self = NM_COMPAT_ACTIVE_CONNECTION (object); + NMCompatActiveConnectionPrivate *priv = NM_COMPAT_ACTIVE_CONNECTION_GET_PRIVATE (self); + + switch (prop_id) { + case PROP_PARENT: + priv->parent = g_value_get_object (value); + break; + default: + G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); + break; + } +} + +static void +get_property (GObject *object, guint prop_id, + GValue *value, GParamSpec *pspec) +{ + NMCompatActiveConnection *self = NM_COMPAT_ACTIVE_CONNECTION (object); + NMCompatActiveConnectionPrivate *priv = NM_COMPAT_ACTIVE_CONNECTION_GET_PRIVATE (self); + NMCompatDevice *compat; + NMConnection *connection; + NMDevice *device; + GPtrArray *devices; + guint32 u; + + switch (prop_id) { + case PROP_PARENT: + g_value_set_object (value, priv->parent); + break; + case PROP_SERVICE_NAME: + g_assert (NM_COMPAT_ACTIVE_CONNECTION_GET_CLASS (self)->get_connection); + connection = NM_COMPAT_ACTIVE_CONNECTION_GET_CLASS (self)->get_connection (self, priv->parent); + + if (g_object_get_data (G_OBJECT (connection), "user")) + g_value_set_string (value, "org.freedesktop.NetworkManagerUserSettings"); + else + g_value_set_string (value, "org.freedesktop.NetworkManagerSystemSettings"); + break; + case PROP_DEVICES: + devices = g_ptr_array_sized_new (1); + + g_assert (NM_COMPAT_ACTIVE_CONNECTION_GET_CLASS (self)->get_device); + device = NM_COMPAT_ACTIVE_CONNECTION_GET_CLASS (self)->get_device (self, priv->parent); + if (device) { + compat = nm_device_get_compat (device); + if (compat) + g_ptr_array_add (devices, g_strdup (nm_compat_device_get_path (compat))); + } + + g_value_take_boxed (value, devices); + break; + case PROP_STATE: + g_object_get (priv->parent, NM_ACTIVE_CONNECTION_STATE, &u, NULL); + g_value_set_uint (value, new_state_to_old (u)); + break; + default: + g_object_get_property (G_OBJECT (priv->parent), pspec->name, value); + break; + } +} + +static void +finalize (GObject *object) +{ + g_free (NM_COMPAT_ACTIVE_CONNECTION_GET_PRIVATE (object)->path); + G_OBJECT_CLASS (nm_compat_active_connection_parent_class)->finalize (object); +} + +static void +nm_compat_active_connection_class_init (NMCompatActiveConnectionClass *compat_class) +{ + GObjectClass *object_class = G_OBJECT_CLASS (compat_class); + + g_type_class_add_private (compat_class, sizeof (NMCompatActiveConnectionPrivate)); + + object_class->constructor = constructor; + object_class->finalize = finalize; + object_class->set_property = set_property; + object_class->get_property = get_property; + + g_object_class_install_property + (object_class, PROP_PARENT, + g_param_spec_object ("parent", "parent", "parent", + G_TYPE_OBJECT, + G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY | NM_PROPERTY_PARAM_NO_EXPORT)); + + g_object_class_install_property (object_class, PROP_SERVICE_NAME, + g_param_spec_string (NM_OLD_ACTIVE_CONNECTION_SERVICE_NAME, + "Service name", + "Service name", + NULL, + G_PARAM_READABLE)); + + nm_active_connection_install_properties (object_class, + PROP_CONNECTION, + PROP_UUID, + PROP_SPECIFIC_OBJECT, + PROP_DEVICES, + PROP_STATE, + PROP_DEFAULT, + PROP_DEFAULT6, + PROP_VPN); + + dbus_g_object_type_install_info (G_TYPE_FROM_CLASS (compat_class), &dbus_glib_nm_compat_active_connection_object_info); +} + diff --git a/src/compat/nm-compat-active-connection.h b/src/compat/nm-compat-active-connection.h new file mode 100644 index 0000000000..ee42bc2e5f --- /dev/null +++ b/src/compat/nm-compat-active-connection.h @@ -0,0 +1,56 @@ +/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */ +/* NetworkManager -- Network link manager + * + * 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 Red Hat, Inc. + */ + +#ifndef NM_COMPAT_ACTIVE_CONNECTION_H +#define NM_COMPAT_ACTIVE_CONNECTION_H + +#include <glib.h> +#include <glib-object.h> +#include <dbus/dbus-glib-lowlevel.h> +#include "nm-activation-request.h" +#include "nm-device.h" + +#define NM_TYPE_COMPAT_ACTIVE_CONNECTION (nm_compat_active_connection_get_type ()) +#define NM_COMPAT_ACTIVE_CONNECTION(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), NM_TYPE_COMPAT_ACTIVE_CONNECTION, NMCompatActiveConnection)) +#define NM_COMPAT_ACTIVE_CONNECTION_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), NM_TYPE_COMPAT_ACTIVE_CONNECTION, NMCompatActiveConnectionClass)) +#define NM_IS_COMPAT_ACTIVE_CONNECTION(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), NM_TYPE_COMPAT_ACTIVE_CONNECTION)) +#define NM_IS_COMPAT_ACTIVE_CONNECTION_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((obj), NM_TYPE_COMPAT_ACTIVE_CONNECTION)) +#define NM_COMPAT_ACTIVE_CONNECTION_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), NM_TYPE_COMPAT_ACTIVE_CONNECTION, NMCompatActiveConnectionClass)) + +typedef struct { + GObject parent; +} NMCompatActiveConnection; + +typedef struct { + GObjectClass parent; + + NMConnection * (*get_connection) (NMCompatActiveConnection *self, GObject *parent); + NMDevice * (*get_device) (NMCompatActiveConnection *self, GObject *parent); +} NMCompatActiveConnectionClass; + +GType nm_compat_active_connection_get_type (void); + +void nm_compat_active_connection_export (NMCompatActiveConnection *self, DBusGConnection *bus); + +const char *nm_compat_active_connection_get_path (NMCompatActiveConnection *self); + +GObject *nm_compat_active_connection_get_parent (NMCompatActiveConnection *self); + +#endif /* NM_COMPAT_ACTIVE_CONNECTION_H */ diff --git a/src/compat/nm-compat-active-connection.xml b/src/compat/nm-compat-active-connection.xml new file mode 100644 index 0000000000..edb92c0cb5 --- /dev/null +++ b/src/compat/nm-compat-active-connection.xml @@ -0,0 +1,57 @@ +<?xml version="1.0" encoding="UTF-8" ?> + +<node name="/" xmlns:tp="http://telepathy.freedesktop.org/wiki/DbusSpec#extensions-v0"> + <interface name="org.freedesktop.NetworkManagerCompat.Connection.Active"> + <property name="ServiceName" type="s" access="read"> + <tp:docstring>The D-Bus service name providing this connection.</tp:docstring> + </property> + <property name="Connection" type="o" access="read"> + <tp:docstring>The path of the connection.</tp:docstring> + </property> + <property name="SpecificObject" type="o" access="read"> + <tp:docstring>A specific object associated with the active connection.</tp:docstring> + </property> + <property name="Devices" type="ao" access="read"> + <tp:docstring>Array of object paths representing devices which are part of this active connection.</tp:docstring> + </property> + <property name="State" type="u" access="read" tp:type="NM_ACTIVE_CONNECTION_STATE"> + <tp:docstring>The state of this active connection.</tp:docstring> + </property> + <property name="Default" type="b" access="read"> + <tp:docstring>Whether this active connection is the default IPv4 connection, i.e. whether it currently owns the default IPv4 route.</tp:docstring> + </property> + <property name="Default6" type="b" access="read"> + <tp:docstring>Whether this active connection is the default IPv6 connection, i.e. whether it currently owns the default IPv6 route.</tp:docstring> + </property> + <property name="Vpn" type="b" access="read"> + <tp:docstring>Whether this active connection is also a VPN connection.</tp:docstring> + </property> + + <signal name="PropertiesChanged"> + <arg name="properties" type="a{sv}" tp:type="String_Variant_Map"> + <tp:docstring> + A dictionary mapping property names to variant boxed values + </tp:docstring> + </arg> + </signal> + + <tp:enum name="NM_ACTIVE_CONNECTION_STATE" type="u"> + <tp:enumvalue suffix="UNKNOWN" value="0"> + <tp:docstring> + The active connection is in an unknown state. + </tp:docstring> + </tp:enumvalue> + <tp:enumvalue suffix="ACTIVATING" value="1"> + <tp:docstring> + The connection is activating. + </tp:docstring> + </tp:enumvalue> + <tp:enumvalue suffix="ACTIVATED" value="2"> + <tp:docstring> + The connection is activated. + </tp:docstring> + </tp:enumvalue> + </tp:enum> + </interface> +</node> + diff --git a/src/compat/nm-compat-device-cdma.c b/src/compat/nm-compat-device-cdma.c new file mode 100644 index 0000000000..37e72603ae --- /dev/null +++ b/src/compat/nm-compat-device-cdma.c @@ -0,0 +1,67 @@ +/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */ +/* NetworkManager -- Network link manager + * + * 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 Red Hat, Inc. + */ + +#include "config.h" + +#include <glib.h> +#include <stdio.h> +#include <string.h> + +#include "NetworkManager.h" +#include "nm-compat-device-cdma.h" +#include "nm-properties-changed-signal.h" + +G_DEFINE_TYPE (NMCompatDeviceCdma, nm_compat_device_cdma, NM_TYPE_COMPAT_DEVICE) + +enum { + PROPERTIES_CHANGED, + LAST_SIGNAL +}; +static guint signals[LAST_SIGNAL] = { 0 }; + +#include "nm-compat-device-cdma-glue.h" + +/*************************************************************************/ + +NMCompatDeviceCdma * +nm_compat_device_cdma_new (NMDeviceModem *parent) +{ + return (NMCompatDeviceCdma *) g_object_new (NM_TYPE_COMPAT_DEVICE_CDMA, + NM_COMPAT_DEVICE_PARENT, parent, + NULL); +} + +static void +nm_compat_device_cdma_init (NMCompatDeviceCdma *self) +{ +} + +static void +nm_compat_device_cdma_class_init (NMCompatDeviceCdmaClass *compat_class) +{ + GObjectClass *object_class = G_OBJECT_CLASS (compat_class); + + signals[PROPERTIES_CHANGED] = + nm_properties_changed_signal_new (object_class, + G_STRUCT_OFFSET (NMCompatDeviceCdmaClass, properties_changed)); + + dbus_g_object_type_install_info (G_TYPE_FROM_CLASS (compat_class), &dbus_glib_nm_compat_device_cdma_object_info); +} + diff --git a/src/compat/nm-compat-device-cdma.h b/src/compat/nm-compat-device-cdma.h new file mode 100644 index 0000000000..e295206ac7 --- /dev/null +++ b/src/compat/nm-compat-device-cdma.h @@ -0,0 +1,50 @@ +/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */ +/* NetworkDevice -- Network link manager + * + * 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 Red Hat, Inc. + */ + +#ifndef NM_COMPAT_DEVICE_CDMA_H +#define NM_COMPAT_DEVICE_CDMA_H + +#include <glib.h> +#include <glib-object.h> +#include "nm-device-modem.h" +#include "nm-compat-device.h" + +#define NM_TYPE_COMPAT_DEVICE_CDMA (nm_compat_device_cdma_get_type ()) +#define NM_COMPAT_DEVICE_CDMA(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), NM_TYPE_COMPAT_DEVICE_CDMA, NMCompatDeviceCdma)) +#define NM_COMPAT_DEVICE_CDMA_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), NM_TYPE_COMPAT_DEVICE_CDMA, NMCompatDeviceCdmaClass)) +#define NM_IS_COMPAT_DEVICE_CDMA(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), NM_TYPE_COMPAT_DEVICE_CDMA)) +#define NM_IS_COMPAT_DEVICE_CDMA_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((obj), NM_TYPE_COMPAT_DEVICE_CDMA)) +#define NM_COMPAT_DEVICE_CDMA_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), NM_TYPE_COMPAT_DEVICE_CDMA, NMCompatDeviceCdmaClass)) + +typedef struct { + NMCompatDevice parent; +} NMCompatDeviceCdma; + +typedef struct { + NMCompatDeviceClass parent; + + void (*properties_changed) (NMCompatDeviceCdma *self, GHashTable *properties); +} NMCompatDeviceCdmaClass; + +GType nm_compat_device_cdma_get_type (void); + +NMCompatDeviceCdma *nm_compat_device_cdma_new (NMDeviceModem *parent); + +#endif /* NM_COMPAT_DEVICE_CDMA_H */ diff --git a/src/compat/nm-compat-device-cdma.xml b/src/compat/nm-compat-device-cdma.xml new file mode 100644 index 0000000000..7cfc25d3ff --- /dev/null +++ b/src/compat/nm-compat-device-cdma.xml @@ -0,0 +1,15 @@ +<?xml version="1.0" encoding="UTF-8" ?> + +<node name="/" xmlns:tp="http://telepathy.freedesktop.org/wiki/DbusSpec#extensions-v0"> + <interface name="org.freedesktop.NetworkManagerCompat.Device.Cdma"> + + <signal name="PropertiesChanged"> + <arg name="properties" type="a{sv}" tp:type="String_Variant_Map"> + <tp:docstring> + A dictionary mapping property names to variant boxed values + </tp:docstring> + </arg> + </signal> + + </interface> +</node> diff --git a/src/compat/nm-compat-device-ethernet.c b/src/compat/nm-compat-device-ethernet.c new file mode 100644 index 0000000000..443d983d6a --- /dev/null +++ b/src/compat/nm-compat-device-ethernet.c @@ -0,0 +1,180 @@ +/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */ +/* NetworkManager -- Network link manager + * + * 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 Red Hat, Inc. + */ + +#include "config.h" + +#include <glib.h> +#include <stdio.h> +#include <string.h> +#include <dbus/dbus-glib-lowlevel.h> + +#include "NetworkManager.h" +#include "nm-compat-device-ethernet.h" +#include "nm-dbus-glib-types.h" +#include "nm-marshal.h" +#include "nm-properties-changed-signal.h" + +G_DEFINE_TYPE (NMCompatDeviceEthernet, nm_compat_device_ethernet, NM_TYPE_COMPAT_DEVICE) + +#define NM_COMPAT_DEVICE_ETHERNET_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), \ + NM_TYPE_COMPAT_DEVICE_ETHERNET, \ + NMCompatDeviceEthernetPrivate)) + +typedef struct { + gboolean disposed; +} NMCompatDeviceEthernetPrivate; + +enum { + PROP_0, + PROP_HW_ADDRESS, + PROP_PERM_HW_ADDRESS, + PROP_SPEED, + PROP_CARRIER, + LAST_PROP +}; + +enum { + PROPERTIES_CHANGED, + LAST_SIGNAL +}; +static guint signals[LAST_SIGNAL] = { 0 }; + +#include "nm-compat-device-ethernet-glue.h" + +/*************************************************************************/ + +static void +prop_reemit_cb (GObject *object, GParamSpec *pspec, NMCompatDevice *self) +{ + g_object_notify (G_OBJECT (self), pspec->name); +} + +NMCompatDeviceEthernet * +nm_compat_device_ethernet_new (NMDeviceEthernet *parent) +{ + NMCompatDeviceEthernet *self; + + self = (NMCompatDeviceEthernet *) g_object_new (NM_TYPE_COMPAT_DEVICE_ETHERNET, + NM_COMPAT_DEVICE_PARENT, parent, + NULL); + if (self) { + g_signal_connect (parent, "notify::" NM_DEVICE_ETHERNET_HW_ADDRESS, G_CALLBACK (prop_reemit_cb), self); + g_signal_connect (parent, "notify::" NM_DEVICE_ETHERNET_PERMANENT_HW_ADDRESS, G_CALLBACK (prop_reemit_cb), self); + g_signal_connect (parent, "notify::" NM_DEVICE_ETHERNET_SPEED, G_CALLBACK (prop_reemit_cb), self); + g_signal_connect (parent, "notify::" NM_DEVICE_ETHERNET_CARRIER, G_CALLBACK (prop_reemit_cb), self); + } + + return self; +} + +static void +nm_compat_device_ethernet_init (NMCompatDeviceEthernet *self) +{ +} + +static void +get_property (GObject *object, guint prop_id, + GValue *value, GParamSpec *pspec) +{ + NMCompatDeviceEthernet *self = NM_COMPAT_DEVICE_ETHERNET (object); +// NMCompatDeviceEthernetPrivate *priv = NM_COMPAT_DEVICE_ETHERNET_GET_PRIVATE (self); + NMDevice *parent; +// char *str; +// guint32 u; +// gboolean b; + + parent = nm_compat_device_get_parent (NM_COMPAT_DEVICE (self)); + if (parent) + g_object_get_property (G_OBJECT (parent), pspec->name, value); + +#if 0 + switch (prop_id) { + case PROP_HW_ADDRESS: + g_object_get (priv->parent, NM_DEVICE_ETHERNET_HW_ADDRESS, &str, NULL); + g_value_take_string (value, str); + break; + case PROP_PERM_HW_ADDRESS: + g_object_get (priv->parent, NM_DEVICE_ETHERNET_PERMANENT_HW_ADDRESS, &str, NULL); + g_value_take_string (value, str); + break; + case PROP_SPEED: + g_object_get (priv->parent, NM_DEVICE_ETHERNET_SPEED, &u, NULL); + g_value_set_uint (value, u); + break; + case PROP_CARRIER: + g_object_get (priv->parent, NM_DEVICE_ETHERNET_CARRIER, &b, NULL); + g_value_set_boolean (value, b); + break; + default: + G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); + break; + } +#endif +} + +static void +nm_compat_device_ethernet_class_init (NMCompatDeviceEthernetClass *compat_class) +{ + GObjectClass *object_class = G_OBJECT_CLASS (compat_class); + + g_type_class_add_private (compat_class, sizeof (NMCompatDeviceEthernetPrivate)); + + object_class->get_property = get_property; + + /* properties */ + g_object_class_install_property + (object_class, PROP_HW_ADDRESS, + g_param_spec_string (NM_DEVICE_ETHERNET_HW_ADDRESS, + "Active MAC Address", + "Currently set hardware MAC address", + NULL, + G_PARAM_READABLE)); + + g_object_class_install_property + (object_class, PROP_PERM_HW_ADDRESS, + g_param_spec_string (NM_DEVICE_ETHERNET_PERMANENT_HW_ADDRESS, + "Permanent MAC Address", + "Permanent hardware MAC address", + NULL, + G_PARAM_READABLE)); + + g_object_class_install_property + (object_class, PROP_SPEED, + g_param_spec_uint (NM_DEVICE_ETHERNET_SPEED, + "Speed", + "Speed", + 0, G_MAXUINT32, 0, + G_PARAM_READABLE)); + + g_object_class_install_property + (object_class, PROP_CARRIER, + g_param_spec_boolean (NM_DEVICE_ETHERNET_CARRIER, + "Carrier", + "Carrier", + FALSE, + G_PARAM_READABLE)); + + signals[PROPERTIES_CHANGED] = + nm_properties_changed_signal_new (object_class, + G_STRUCT_OFFSET (NMCompatDeviceEthernetClass, properties_changed)); + + dbus_g_object_type_install_info (G_TYPE_FROM_CLASS (compat_class), &dbus_glib_nm_compat_device_ethernet_object_info); +} + diff --git a/src/compat/nm-compat-device-ethernet.h b/src/compat/nm-compat-device-ethernet.h new file mode 100644 index 0000000000..42f63749bc --- /dev/null +++ b/src/compat/nm-compat-device-ethernet.h @@ -0,0 +1,50 @@ +/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */ +/* NetworkDevice -- Network link manager + * + * 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 Red Hat, Inc. + */ + +#ifndef NM_COMPAT_DEVICE_ETHERNET_H +#define NM_COMPAT_DEVICE_ETHERNET_H + +#include <glib.h> +#include <glib-object.h> +#include "nm-device-ethernet.h" +#include "nm-compat-device.h" + +#define NM_TYPE_COMPAT_DEVICE_ETHERNET (nm_compat_device_ethernet_get_type ()) +#define NM_COMPAT_DEVICE_ETHERNET(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), NM_TYPE_COMPAT_DEVICE_ETHERNET, NMCompatDeviceEthernet)) +#define NM_COMPAT_DEVICE_ETHERNET_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), NM_TYPE_COMPAT_DEVICE_ETHERNET, NMCompatDeviceEthernetClass)) +#define NM_IS_COMPAT_DEVICE_ETHERNET(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), NM_TYPE_COMPAT_DEVICE_ETHERNET)) +#define NM_IS_COMPAT_DEVICE_ETHERNET_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((obj), NM_TYPE_COMPAT_DEVICE_ETHERNET)) +#define NM_COMPAT_DEVICE_ETHERNET_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), NM_TYPE_COMPAT_DEVICE_ETHERNET, NMCompatDeviceEthernetClass)) + +typedef struct { + NMCompatDevice parent; +} NMCompatDeviceEthernet; + +typedef struct { + NMCompatDeviceClass parent; + + void (*properties_changed) (NMCompatDeviceEthernet *self, GHashTable *properties); +} NMCompatDeviceEthernetClass; + +GType nm_compat_device_ethernet_get_type (void); + +NMCompatDeviceEthernet *nm_compat_device_ethernet_new (NMDeviceEthernet *parent); + +#endif /* NM_COMPAT_DEVICE_ETHERNET_H */ diff --git a/src/compat/nm-compat-device-ethernet.xml b/src/compat/nm-compat-device-ethernet.xml new file mode 100644 index 0000000000..2f237e6a6a --- /dev/null +++ b/src/compat/nm-compat-device-ethernet.xml @@ -0,0 +1,39 @@ +<?xml version="1.0" encoding="UTF-8" ?> + +<node name="/" xmlns:tp="http://telepathy.freedesktop.org/wiki/DbusSpec#extensions-v0"> + <interface name="org.freedesktop.NetworkManagerCompat.Device.Wired"> + + <property name="HwAddress" type="s" access="read"> + <tp:docstring> + Active hardware address of the device. + </tp:docstring> + </property> + + <property name="PermHwAddress" type="s" access="read"> + <tp:docstring> + Permanent hardware address of the device. + </tp:docstring> + </property> + + <property name="Speed" type="u" access="read"> + <tp:docstring> + Design speed of the device, in megabits/second (Mb/s). + </tp:docstring> + </property> + + <property name="Carrier" type="b" access="read"> + <tp:docstring> + Indicates whether the physical carrier is found (e.g. whether a cable is plugged in or not). + </tp:docstring> + </property> + + <signal name="PropertiesChanged"> + <arg name="properties" type="a{sv}" tp:type="String_Variant_Map"> + <tp:docstring> + A dictionary mapping property names to variant boxed values + </tp:docstring> + </arg> + </signal> + + </interface> +</node> diff --git a/src/compat/nm-compat-device-gsm.c b/src/compat/nm-compat-device-gsm.c new file mode 100644 index 0000000000..d94841b4bb --- /dev/null +++ b/src/compat/nm-compat-device-gsm.c @@ -0,0 +1,67 @@ +/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */ +/* NetworkManager -- Network link manager + * + * 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 Red Hat, Inc. + */ + +#include "config.h" + +#include <glib.h> +#include <stdio.h> +#include <string.h> + +#include "NetworkManager.h" +#include "nm-compat-device-gsm.h" +#include "nm-properties-changed-signal.h" + +G_DEFINE_TYPE (NMCompatDeviceGsm, nm_compat_device_gsm, NM_TYPE_COMPAT_DEVICE) + +enum { + PROPERTIES_CHANGED, + LAST_SIGNAL +}; +static guint signals[LAST_SIGNAL] = { 0 }; + +#include "nm-compat-device-gsm-glue.h" + +/*************************************************************************/ + +NMCompatDeviceGsm * +nm_compat_device_gsm_new (NMDeviceModem *parent) +{ + return (NMCompatDeviceGsm *) g_object_new (NM_TYPE_COMPAT_DEVICE_GSM, + NM_COMPAT_DEVICE_PARENT, parent, + NULL); +} + +static void +nm_compat_device_gsm_init (NMCompatDeviceGsm *self) +{ +} + +static void +nm_compat_device_gsm_class_init (NMCompatDeviceGsmClass *compat_class) +{ + GObjectClass *object_class = G_OBJECT_CLASS (compat_class); + + signals[PROPERTIES_CHANGED] = + nm_properties_changed_signal_new (object_class, + G_STRUCT_OFFSET (NMCompatDeviceGsmClass, properties_changed)); + + dbus_g_object_type_install_info (G_TYPE_FROM_CLASS (compat_class), &dbus_glib_nm_compat_device_gsm_object_info); +} + diff --git a/src/compat/nm-compat-device-gsm.h b/src/compat/nm-compat-device-gsm.h new file mode 100644 index 0000000000..1f3813abcf --- /dev/null +++ b/src/compat/nm-compat-device-gsm.h @@ -0,0 +1,50 @@ +/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */ +/* NetworkDevice -- Network link manager + * + * 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 Red Hat, Inc. + */ + +#ifndef NM_COMPAT_DEVICE_GSM_H +#define NM_COMPAT_DEVICE_GSM_H + +#include <glib.h> +#include <glib-object.h> +#include "nm-device-modem.h" +#include "nm-compat-device.h" + +#define NM_TYPE_COMPAT_DEVICE_GSM (nm_compat_device_gsm_get_type ()) +#define NM_COMPAT_DEVICE_GSM(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), NM_TYPE_COMPAT_DEVICE_GSM, NMCompatDeviceGsm)) +#define NM_COMPAT_DEVICE_GSM_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), NM_TYPE_COMPAT_DEVICE_GSM, NMCompatDeviceGsmClass)) +#define NM_IS_COMPAT_DEVICE_GSM(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), NM_TYPE_COMPAT_DEVICE_GSM)) +#define NM_IS_COMPAT_DEVICE_GSM_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((obj), NM_TYPE_COMPAT_DEVICE_GSM)) +#define NM_COMPAT_DEVICE_GSM_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), NM_TYPE_COMPAT_DEVICE_GSM, NMCompatDeviceGsmClass)) + +typedef struct { + NMCompatDevice parent; +} NMCompatDeviceGsm; + +typedef struct { + NMCompatDeviceClass parent; + + void (*properties_changed) (NMCompatDeviceGsm *self, GHashTable *properties); +} NMCompatDeviceGsmClass; + +GType nm_compat_device_gsm_get_type (void); + +NMCompatDeviceGsm *nm_compat_device_gsm_new (NMDeviceModem *parent); + +#endif /* NM_COMPAT_DEVICE_GSM_H */ diff --git a/src/compat/nm-compat-device-gsm.xml b/src/compat/nm-compat-device-gsm.xml new file mode 100644 index 0000000000..b1971377ca --- /dev/null +++ b/src/compat/nm-compat-device-gsm.xml @@ -0,0 +1,15 @@ +<?xml version="1.0" encoding="UTF-8" ?> + +<node name="/" xmlns:tp="http://telepathy.freedesktop.org/wiki/DbusSpec#extensions-v0"> + <interface name="org.freedesktop.NetworkManagerCompat.Device.Gsm"> + + <signal name="PropertiesChanged"> + <arg name="properties" type="a{sv}" tp:type="String_Variant_Map"> + <tp:docstring> + A dictionary mapping property names to variant boxed values + </tp:docstring> + </arg> + </signal> + + </interface> +</node> diff --git a/src/compat/nm-compat-device-serial.xml b/src/compat/nm-compat-device-serial.xml new file mode 100644 index 0000000000..13b0853737 --- /dev/null +++ b/src/compat/nm-compat-device-serial.xml @@ -0,0 +1,20 @@ +<?xml version="1.0" encoding="UTF-8" ?> + +<node name="/" xmlns:tp="http://telepathy.freedesktop.org/wiki/DbusSpec#extensions-v0"> + <interface name="org.freedesktop.NetworkManager.Device.Serial"> + + <signal name="PppStats"> + <arg name="in_bytes" type="u"> + <tp:docstring> + Bytes received + </tp:docstring> + </arg> + <arg name="out_bytes" type="u"> + <tp:docstring> + Bytes sent + </tp:docstring> + </arg> + </signal> + + </interface> +</node> diff --git a/src/compat/nm-compat-device-wifi.c b/src/compat/nm-compat-device-wifi.c new file mode 100644 index 0000000000..8888d1062a --- /dev/null +++ b/src/compat/nm-compat-device-wifi.c @@ -0,0 +1,257 @@ +/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */ +/* NetworkManager -- Network link manager + * + * 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 Red Hat, Inc. + */ + +#include "config.h" + +#include <glib.h> +#include <stdio.h> +#include <string.h> +#include <dbus/dbus-glib-lowlevel.h> + +#include "NetworkManager.h" +#include "nm-compat-device-wifi.h" +#include "nm-dbus-glib-types.h" +#include "nm-marshal.h" +#include "nm-properties-changed-signal.h" + +G_DEFINE_TYPE (NMCompatDeviceWifi, nm_compat_device_wifi, NM_TYPE_COMPAT_DEVICE) + +#define NM_COMPAT_DEVICE_WIFI_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), \ + NM_TYPE_COMPAT_DEVICE_WIFI, \ + NMCompatDeviceWifiPrivate)) + +typedef struct { + gboolean disposed; +} NMCompatDeviceWifiPrivate; + +enum { + PROP_0, + PROP_HW_ADDRESS, + PROP_PERM_HW_ADDRESS, + PROP_MODE, + PROP_BITRATE, + PROP_ACTIVE_ACCESS_POINT, + PROP_CAPABILITIES, + LAST_PROP +}; + +enum { + ACCESS_POINT_ADDED, + ACCESS_POINT_REMOVED, + PROPERTIES_CHANGED, + LAST_SIGNAL +}; +static guint signals[LAST_SIGNAL] = { 0 }; + +static gboolean impl_compat_device_get_access_points (NMCompatDeviceWifi *device, + GPtrArray **aps, + GError **err); + +#include "nm-compat-device-wifi-glue.h" + +/*************************************************************************/ + +static gboolean +impl_compat_device_get_access_points (NMCompatDeviceWifi *self, + GPtrArray **aps, + GError **err) +{ + NMDevice *parent = nm_compat_device_get_parent (NM_COMPAT_DEVICE (self)); + + *aps = nm_device_wifi_get_access_points (NM_DEVICE_WIFI (parent)); + return TRUE; +} + +/*************************************************************************/ + +static void +prop_reemit_cb (GObject *object, GParamSpec *pspec, NMCompatDevice *self) +{ + g_object_notify (G_OBJECT (self), pspec->name); +} + +static void +ap_added_cb (GObject *object, NMAccessPoint *ap, NMCompatDeviceWifi *self) +{ + g_signal_emit (self, signals[ACCESS_POINT_ADDED], 0, ap); +} + +static void +ap_removed_cb (GObject *object, NMAccessPoint *ap, NMCompatDeviceWifi *self) +{ + g_signal_emit (self, signals[ACCESS_POINT_REMOVED], 0, ap); +} + +NMCompatDeviceWifi * +nm_compat_device_wifi_new (NMDeviceWifi *parent) +{ + NMCompatDeviceWifi *self; + + self = (NMCompatDeviceWifi *) g_object_new (NM_TYPE_COMPAT_DEVICE_WIFI, + NM_COMPAT_DEVICE_PARENT, parent, + NULL); + if (self) { + g_signal_connect (parent, "notify::" NM_DEVICE_WIFI_HW_ADDRESS, G_CALLBACK (prop_reemit_cb), self); + g_signal_connect (parent, "notify::" NM_DEVICE_WIFI_PERMANENT_HW_ADDRESS, G_CALLBACK (prop_reemit_cb), self); + g_signal_connect (parent, "notify::" NM_DEVICE_WIFI_MODE, G_CALLBACK (prop_reemit_cb), self); + g_signal_connect (parent, "notify::" NM_DEVICE_WIFI_BITRATE, G_CALLBACK (prop_reemit_cb), self); + g_signal_connect (parent, "notify::" NM_DEVICE_WIFI_ACTIVE_ACCESS_POINT, G_CALLBACK (prop_reemit_cb), self); + g_signal_connect (parent, "notify::" NM_DEVICE_WIFI_CAPABILITIES, G_CALLBACK (prop_reemit_cb), self); + + g_signal_connect (parent, "access-point-added", G_CALLBACK (ap_added_cb), self); + g_signal_connect (parent, "access-point-removed", G_CALLBACK (ap_removed_cb), self); + } + + return self; +} + +static void +nm_compat_device_wifi_init (NMCompatDeviceWifi *self) +{ +} + +static void +get_property (GObject *object, guint prop_id, + GValue *value, GParamSpec *pspec) +{ + NMCompatDeviceWifi *self = NM_COMPAT_DEVICE_WIFI (object); +// NMCompatDeviceWifiPrivate *priv = NM_COMPAT_DEVICE_WIFI_GET_PRIVATE (self); +// char *str; +// guint32 u; + NMDevice *parent; + + parent = nm_compat_device_get_parent (NM_COMPAT_DEVICE (self)); + if (parent) + g_object_get_property (G_OBJECT (parent), pspec->name, value); + +#if 0 + if (priv->parent == NULL) + return; + + switch (prop_id) { + case PROP_HW_ADDRESS: + g_object_get (priv->parent, NM_DEVICE_WIFI_HW_ADDRESS, &str, NULL); + g_value_take_string (value, str); + break; + case PROP_PERM_HW_ADDRESS: + g_object_get (priv->parent, NM_DEVICE_WIFI_PERMANENT_HW_ADDRESS, &str, NULL); + g_value_take_string (value, str); + break; + case PROP_MODE: + g_object_get (priv->parent, NM_DEVICE_WIFI_MODE, &u, NULL); + g_value_set_uint (value, u); + break; + case PROP_BITRATE: + g_object_get (priv->parent, NM_DEVICE_WIFI_BITRATE, &u, NULL); + g_value_set_uint (value, u); + break; + case PROP_CAPABILITIES: + g_object_get (priv->parent, NM_DEVICE_WIFI_CAPABILITIES, &u, NULL); + g_value_set_uint (value, u); + break; + case PROP_ACTIVE_ACCESS_POINT: + g_object_get (priv->parent, NM_DEVICE_WIFI_ACTIVE_ACCESS_POINT, &str, NULL); + g_value_take_boxed (value, str); + break; + default: + G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); + break; + } +#endif +} + +static void +nm_compat_device_wifi_class_init (NMCompatDeviceWifiClass *compat_class) +{ + GObjectClass *object_class = G_OBJECT_CLASS (compat_class); + + g_type_class_add_private (compat_class, sizeof (NMCompatDeviceWifiPrivate)); + + object_class->get_property = get_property; + + /* properties */ + g_object_class_install_property (object_class, PROP_HW_ADDRESS, + g_param_spec_string (NM_DEVICE_WIFI_HW_ADDRESS, + "Active MAC Address", + "Currently set hardware MAC address", + NULL, + G_PARAM_READABLE)); + + g_object_class_install_property (object_class, PROP_PERM_HW_ADDRESS, + g_param_spec_string (NM_DEVICE_WIFI_PERMANENT_HW_ADDRESS, + "Permanent MAC Address", + "Permanent hardware MAC address", + NULL, + G_PARAM_READABLE)); + + g_object_class_install_property (object_class, PROP_MODE, + g_param_spec_uint (NM_DEVICE_WIFI_MODE, + "Mode", + "Mode", + NM_802_11_MODE_UNKNOWN, + NM_802_11_MODE_INFRA, + NM_802_11_MODE_INFRA, + G_PARAM_READABLE)); + + g_object_class_install_property (object_class, PROP_BITRATE, + g_param_spec_uint (NM_DEVICE_WIFI_BITRATE, + "Bitrate", + "Bitrate", + 0, G_MAXUINT32, 0, + G_PARAM_READABLE)); + + g_object_class_install_property (object_class, PROP_ACTIVE_ACCESS_POINT, + g_param_spec_boxed (NM_DEVICE_WIFI_ACTIVE_ACCESS_POINT, + "Active access point", + "Currently active access point", + DBUS_TYPE_G_OBJECT_PATH, + G_PARAM_READABLE)); + + g_object_class_install_property (object_class, PROP_CAPABILITIES, + g_param_spec_uint (NM_DEVICE_WIFI_CAPABILITIES, + "Wireless Capabilities", + "Wireless Capabilities", + 0, G_MAXUINT32, NM_WIFI_DEVICE_CAP_NONE, + G_PARAM_READABLE)); + + /* Signals */ + signals[ACCESS_POINT_ADDED] = + g_signal_new ("access-point-added", + G_OBJECT_CLASS_TYPE (object_class), + G_SIGNAL_RUN_FIRST, + 0, NULL, NULL, + g_cclosure_marshal_VOID__OBJECT, + G_TYPE_NONE, 1, G_TYPE_OBJECT); + + signals[ACCESS_POINT_REMOVED] = + g_signal_new ("access-point-removed", + G_OBJECT_CLASS_TYPE (object_class), + G_SIGNAL_RUN_FIRST, + 0, NULL, NULL, + g_cclosure_marshal_VOID__OBJECT, + G_TYPE_NONE, 1, G_TYPE_OBJECT); + + signals[PROPERTIES_CHANGED] = + nm_properties_changed_signal_new (object_class, + G_STRUCT_OFFSET (NMCompatDeviceWifiClass, properties_changed)); + + dbus_g_object_type_install_info (G_TYPE_FROM_CLASS (compat_class), &dbus_glib_nm_compat_device_wifi_object_info); +} + diff --git a/src/compat/nm-compat-device-wifi.h b/src/compat/nm-compat-device-wifi.h new file mode 100644 index 0000000000..e09dcb53d2 --- /dev/null +++ b/src/compat/nm-compat-device-wifi.h @@ -0,0 +1,52 @@ +/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */ +/* NetworkDevice -- Network link manager + * + * 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 Red Hat, Inc. + */ + +#ifndef NM_COMPAT_DEVICE_WIFI_H +#define NM_COMPAT_DEVICE_WIFI_H + +#include <glib.h> +#include <glib-object.h> +#include "nm-device-wifi.h" +#include "nm-compat-device.h" + +#define NM_TYPE_COMPAT_DEVICE_WIFI (nm_compat_device_wifi_get_type ()) +#define NM_COMPAT_DEVICE_WIFI(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), NM_TYPE_COMPAT_DEVICE_WIFI, NMCompatDeviceWifi)) +#define NM_COMPAT_DEVICE_WIFI_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), NM_TYPE_COMPAT_DEVICE_WIFI, NMCompatDeviceWifiClass)) +#define NM_IS_COMPAT_DEVICE_WIFI(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), NM_TYPE_COMPAT_DEVICE_WIFI)) +#define NM_IS_COMPAT_DEVICE_WIFI_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((obj), NM_TYPE_COMPAT_DEVICE_WIFI)) +#define NM_COMPAT_DEVICE_WIFI_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), NM_TYPE_COMPAT_DEVICE_WIFI, NMCompatDeviceWifiClass)) + +typedef struct { + NMCompatDevice parent; +} NMCompatDeviceWifi; + +typedef struct { + NMCompatDeviceClass parent; + + void (*access_point_added) (NMCompatDeviceWifi *device, NMAccessPoint *ap); + void (*access_point_removed) (NMCompatDeviceWifi *device, NMAccessPoint *ap); + void (*properties_changed) (NMCompatDeviceWifi *self, GHashTable *properties); +} NMCompatDeviceWifiClass; + +GType nm_compat_device_wifi_get_type (void); + +NMCompatDeviceWifi *nm_compat_device_wifi_new (NMDeviceWifi *parent); + +#endif /* NM_COMPAT_DEVICE_WIFI_H */ diff --git a/src/compat/nm-compat-device-wifi.xml b/src/compat/nm-compat-device-wifi.xml new file mode 100644 index 0000000000..b495c3564a --- /dev/null +++ b/src/compat/nm-compat-device-wifi.xml @@ -0,0 +1,111 @@ +<?xml version="1.0" encoding="UTF-8" ?> + +<node name="/" xmlns:tp="http://telepathy.freedesktop.org/wiki/DbusSpec#extensions-v0"> + <interface name="org.freedesktop.NetworkManagerCompat.Device.Wireless"> + <method name="GetAccessPoints"> + <annotation name="org.freedesktop.DBus.GLib.CSymbol" value="impl_compat_device_get_access_points"/> + <arg name="access_points" type="ao" direction="out"> + <tp:docstring> + List of access point object paths + </tp:docstring> + </arg> + <tp:docstring> + Get the list of access points visible to this device. + </tp:docstring> + </method> + + <property name="HwAddress" type="s" access="read"> + <tp:docstring> + The active hardware address of the device. + </tp:docstring> + </property> + + <property name="PermHwAddress" type="s" access="read"> + <tp:docstring> + The permanent hardware address of the device. + </tp:docstring> + </property> + + <property name="Mode" type="u" access="read" tp:type="NM_802_11_MODE"> + <tp:docstring> + The operating mode of the wireless device. + </tp:docstring> + </property> + + <property name="Bitrate" type="u" access="read"> + <tp:docstring> + The bit rate currently used by the wireless device, in kilobits/second (Kb/s). + </tp:docstring> + </property> + <property name="ActiveAccessPoint" type="o" access="read"> + <tp:docstring> + Object path of the access point currently used by the wireless device. + </tp:docstring> + </property> + <property name="WirelessCapabilities" type="u" access="read" tp:type="NM_802_11_DEVICE_CAP"> + <tp:docstring> + The capabilities of the wireless device. + </tp:docstring> + </property> + + <signal name="PropertiesChanged"> + <arg name="properties" type="a{sv}" tp:type="String_Variant_Map"> + <tp:docstring> + A dictionary containing the FIXME: check changed parameters. + </tp:docstring> + </arg> + <tp:docstring> + Emitted when the wireless device's properties changed. + </tp:docstring> + </signal> + + <signal name="AccessPointAdded"> + <arg name="access_point" type="o"> + <tp:docstring> + The object path of the newly found access point. + </tp:docstring> + </arg> + <tp:docstring> + Emitted when a new access point is found by the device. + </tp:docstring> + </signal> + + <signal name="AccessPointRemoved"> + <arg name="access_point" type="o"> + <tp:docstring> + The object path of the access point that has disappeared. + </tp:docstring> + </arg> + <tp:docstring> + Emitted when an access point disappears from view of the device. + </tp:docstring> + </signal> + + <tp:flags name="NM_802_11_DEVICE_CAP" type="u"> + <tp:docstring> + Flags describing the capabilities of a wireless device. + </tp:docstring> + <tp:flag suffix="NONE" value="0x0"> + <tp:docstring>Null capability - syntactic sugar for no capabilities supported. Do not AND this with other capabilities!</tp:docstring> + </tp:flag> + <tp:flag suffix="CIPHER_WEP40" value="0x1"> + <tp:docstring>The device supports the 40-bit WEP cipher.</tp:docstring> + </tp:flag> + <tp:flag suffix="CIPHER_WEP104" value="0x2"> + <tp:docstring>The device supports the 104-bit WEP cipher.</tp:docstring> + </tp:flag> + <tp:flag suffix="CIPHER_TKIP" value="0x4"> + <tp:docstring>The device supports the TKIP cipher.</tp:docstring> + </tp:flag> + <tp:flag suffix="CIPHER_CCMP" value="0x8"> + <tp:docstring>The device supports the CCMP cipher.</tp:docstring> + </tp:flag> + <tp:flag suffix="WPA" value="0x10"> + <tp:docstring>The device supports the WPA encryption/authentication protocol.</tp:docstring> + </tp:flag> + <tp:flag suffix="RSN" value="0x20"> + <tp:docstring>The device supports the RSN encryption/authentication protocol.</tp:docstring> + </tp:flag> + </tp:flags> + </interface> +</node> diff --git a/src/compat/nm-compat-device.c b/src/compat/nm-compat-device.c new file mode 100644 index 0000000000..16feeb7502 --- /dev/null +++ b/src/compat/nm-compat-device.c @@ -0,0 +1,418 @@ +/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */ +/* NetworkManager -- Network link manager + * + * 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 Red Hat, Inc. + */ + +#include "config.h" + +#include <glib.h> +#include <stdio.h> +#include <string.h> +#include <dbus/dbus-glib-lowlevel.h> + +#include "NetworkManager.h" +#include "nm-compat-device.h" +#include "nm-dbus-glib-types.h" +#include "nm-marshal.h" +#include "nm-device-interface.h" +#include "nm-device-modem.h" +#include "nm-properties-changed-signal.h" + +G_DEFINE_TYPE (NMCompatDevice, nm_compat_device, G_TYPE_OBJECT); + +#define NM_COMPAT_DEVICE_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), NM_TYPE_COMPAT_DEVICE, NMCompatDevicePrivate)) + +typedef struct { + gboolean disposed; + + NMDevice *parent; + char *path; +} NMCompatDevicePrivate; + +enum { + PROP_0 = 0x1000, + PROP_UDI, + PROP_IFACE, + PROP_IP_IFACE, + PROP_DRIVER, + PROP_CAPABILITIES, + PROP_IP4_ADDRESS, + PROP_IP4_CONFIG, + PROP_DHCP4_CONFIG, + PROP_IP6_CONFIG, + PROP_DHCP6_CONFIG, + PROP_STATE, + PROP_MANAGED, + PROP_DEVICE_TYPE, + PROP_PARENT, + LAST_PROP +}; + +enum { + STATE_CHANGED, + LAST_SIGNAL +}; +static guint signals[LAST_SIGNAL] = { 0 }; + +static void impl_compat_device_disconnect (NMCompatDevice *self, + DBusGMethodInvocation *context); + +#include "nm-compat-device-glue.h" + +/*************************************************************************/ + +static void +impl_compat_device_disconnect (NMCompatDevice *self, + DBusGMethodInvocation *context) +{ + NMCompatDevicePrivate *priv = NM_COMPAT_DEVICE_GET_PRIVATE (self); + + g_signal_emit_by_name (priv->parent, NM_DEVICE_INTERFACE_DISCONNECT_REQUEST, context); +} + +#define NM_OLD_DEVICE_STATE_UNKNOWN 0 +#define NM_OLD_DEVICE_STATE_UNMANAGED 1 +#define NM_OLD_DEVICE_STATE_UNAVAILABLE 2 +#define NM_OLD_DEVICE_STATE_DISCONNECTED 3 +#define NM_OLD_DEVICE_STATE_PREPARE 4 +#define NM_OLD_DEVICE_STATE_CONFIG 5 +#define NM_OLD_DEVICE_STATE_NEED_AUTH 6 +#define NM_OLD_DEVICE_STATE_IP_CONFIG 7 +#define NM_OLD_DEVICE_STATE_ACTIVATED 8 +#define NM_OLD_DEVICE_STATE_FAILED 9 + +static guint32 +new_state_to_old (NMDeviceState state) +{ + switch (state) { + case NM_DEVICE_STATE_UNMANAGED: + return NM_OLD_DEVICE_STATE_UNMANAGED; + case NM_DEVICE_STATE_UNAVAILABLE: + return NM_OLD_DEVICE_STATE_UNAVAILABLE; + case NM_DEVICE_STATE_DEACTIVATING: + case NM_DEVICE_STATE_DISCONNECTED: + return NM_OLD_DEVICE_STATE_DISCONNECTED; + case NM_DEVICE_STATE_PREPARE: + return NM_OLD_DEVICE_STATE_PREPARE; + case NM_DEVICE_STATE_CONFIG: + return NM_OLD_DEVICE_STATE_CONFIG; + case NM_DEVICE_STATE_NEED_AUTH: + return NM_OLD_DEVICE_STATE_NEED_AUTH; + case NM_DEVICE_STATE_IP_CONFIG: + case NM_DEVICE_STATE_IP_CHECK: + case NM_DEVICE_STATE_SECONDARIES: + return NM_OLD_DEVICE_STATE_IP_CONFIG; + case NM_DEVICE_STATE_ACTIVATED: + return NM_OLD_DEVICE_STATE_ACTIVATED; + case NM_DEVICE_STATE_FAILED: + return NM_OLD_DEVICE_STATE_FAILED; + default: + return NM_STATE_UNKNOWN; + } + g_assert_not_reached (); +} + +static void +state_changed_cb (NMDevice *parent, + NMDeviceState new_state, + NMDeviceState old_state, + NMDeviceStateReason reason, + NMCompatDevice *self) +{ + g_signal_emit (self, signals[STATE_CHANGED], 0, + new_state_to_old (new_state), + new_state_to_old (old_state), + reason); +} + +static void +prop_reemit_cb (GObject *object, GParamSpec *pspec, NMCompatDevice *self) +{ + g_object_notify (G_OBJECT (self), pspec->name); +} + +/*************************************************************************/ + +const char * +nm_compat_device_get_path (NMCompatDevice *compat) +{ + return NM_COMPAT_DEVICE_GET_PRIVATE (compat)->path; +} + +NMDevice * +nm_compat_device_get_parent (NMCompatDevice *compat) +{ + return NM_COMPAT_DEVICE_GET_PRIVATE (compat)->parent; +} + +void +nm_compat_device_export (NMCompatDevice *self, DBusGConnection *bus) +{ + NMCompatDevicePrivate *priv = NM_COMPAT_DEVICE_GET_PRIVATE (self); + static guint32 idx = 0; + + priv->path = g_strdup_printf ("/org/freedesktop/NetworkManagerCompat/Devices/%d", idx++); + dbus_g_connection_register_g_object (bus, priv->path, G_OBJECT (self)); +} + +NMCompatDevice * +nm_compat_device_new (NMDevice *parent) +{ + return (NMCompatDevice *) g_object_new (NM_TYPE_COMPAT_DEVICE, + NM_COMPAT_DEVICE_PARENT, parent, + NULL); +} + +static GObject* +constructor (GType type, + guint n_construct_params, + GObjectConstructParam *construct_params) +{ + GObject *object; + NMCompatDevice *self; + NMCompatDevicePrivate *priv; + + object = G_OBJECT_CLASS (nm_compat_device_parent_class)->constructor (type, n_construct_params, construct_params); + if (!object) + return NULL; + + self = NM_COMPAT_DEVICE (object); + priv = NM_COMPAT_DEVICE_GET_PRIVATE (self); + + g_signal_connect (priv->parent, "notify::" NM_DEVICE_INTERFACE_UDI, G_CALLBACK (prop_reemit_cb), self); + g_signal_connect (priv->parent, "notify::" NM_DEVICE_INTERFACE_IFACE, G_CALLBACK (prop_reemit_cb), self); + g_signal_connect (priv->parent, "notify::" NM_DEVICE_INTERFACE_IP_IFACE, G_CALLBACK (prop_reemit_cb), self); + g_signal_connect (priv->parent, "notify::" NM_DEVICE_INTERFACE_DRIVER, G_CALLBACK (prop_reemit_cb), self); + g_signal_connect (priv->parent, "notify::" NM_DEVICE_INTERFACE_CAPABILITIES, G_CALLBACK (prop_reemit_cb), self); + g_signal_connect (priv->parent, "notify::" NM_DEVICE_INTERFACE_IP4_ADDRESS, G_CALLBACK (prop_reemit_cb), self); + g_signal_connect (priv->parent, "notify::" NM_DEVICE_INTERFACE_IP4_CONFIG, G_CALLBACK (prop_reemit_cb), self); + g_signal_connect (priv->parent, "notify::" NM_DEVICE_INTERFACE_DHCP4_CONFIG, G_CALLBACK (prop_reemit_cb), self); + g_signal_connect (priv->parent, "notify::" NM_DEVICE_INTERFACE_IP6_CONFIG, G_CALLBACK (prop_reemit_cb), self); + g_signal_connect (priv->parent, "notify::" NM_DEVICE_INTERFACE_DHCP6_CONFIG, G_CALLBACK (prop_reemit_cb), self); + g_signal_connect (priv->parent, "notify::" NM_DEVICE_INTERFACE_STATE, G_CALLBACK (prop_reemit_cb), self); + g_signal_connect (priv->parent, "notify::" NM_DEVICE_INTERFACE_DEVICE_TYPE, G_CALLBACK (prop_reemit_cb), self); + g_signal_connect (priv->parent, "notify::" NM_DEVICE_INTERFACE_MANAGED, G_CALLBACK (prop_reemit_cb), self); + g_signal_connect (priv->parent, "state-changed", G_CALLBACK (state_changed_cb), self); + + return G_OBJECT (self); +} + +static void +nm_compat_device_init (NMCompatDevice *self) +{ +} + +static void +set_property (GObject *object, guint prop_id, + const GValue *value, GParamSpec *pspec) +{ + NMCompatDevice *self = NM_COMPAT_DEVICE (object); + NMCompatDevicePrivate *priv = NM_COMPAT_DEVICE_GET_PRIVATE (self); + + switch (prop_id) { + case PROP_PARENT: + priv->parent = g_value_get_object (value); + break; + default: + G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); + break; + } +} + +#define NM_OLD_DEVICE_TYPE_GSM 3 +#define NM_OLD_DEVICE_TYPE_CDMA 4 + +static void +get_property (GObject *object, guint prop_id, + GValue *value, GParamSpec *pspec) +{ + NMCompatDevice *self = NM_COMPAT_DEVICE (object); + NMCompatDevicePrivate *priv = NM_COMPAT_DEVICE_GET_PRIVATE (self); + guint32 u; + + switch (prop_id) { + case PROP_PARENT: + g_value_set_object (value, priv->parent); + break; + case PROP_STATE: + g_object_get (priv->parent, NM_DEVICE_INTERFACE_STATE, &u, NULL); + g_value_set_uint (value, new_state_to_old (u)); + break; + case PROP_DEVICE_TYPE: + g_object_get (priv->parent, NM_DEVICE_INTERFACE_DEVICE_TYPE, &u, NULL); + + /* Handle GSM/CDMA */ + if (u == NM_DEVICE_TYPE_MODEM) { + NMDeviceModemCapabilities caps = NM_DEVICE_MODEM_CAPABILITY_NONE; + + g_object_get (G_OBJECT (priv->parent), NM_DEVICE_MODEM_CURRENT_CAPABILITIES, &caps, NULL); + if (caps & NM_DEVICE_MODEM_CAPABILITY_CDMA_EVDO) + u = NM_OLD_DEVICE_TYPE_CDMA; + else if (caps & NM_DEVICE_MODEM_CAPABILITY_GSM_UMTS) + u = NM_OLD_DEVICE_TYPE_GSM; + } + g_value_set_uint (value, u); + break; + default: + g_object_get_property (G_OBJECT (priv->parent), pspec->name, value); + break; + } +} + +static void +finalize (GObject *object) +{ + g_free (NM_COMPAT_DEVICE_GET_PRIVATE (object)->path); + G_OBJECT_CLASS (nm_compat_device_parent_class)->finalize (object); +} + +static void +nm_compat_device_class_init (NMCompatDeviceClass *compat_class) +{ + GObjectClass *object_class = G_OBJECT_CLASS (compat_class); + + g_type_class_add_private (compat_class, sizeof (NMCompatDevicePrivate)); + + object_class->constructor = constructor; + object_class->finalize = finalize; + object_class->set_property = set_property; + object_class->get_property = get_property; + + /* properties */ + g_object_class_install_property + (object_class, PROP_UDI, + g_param_spec_string (NM_DEVICE_INTERFACE_UDI, + "UDI", + "Unique Device Identifier", + NULL, + G_PARAM_READABLE)); + + g_object_class_install_property + (object_class, PROP_IFACE, + g_param_spec_string (NM_DEVICE_INTERFACE_IFACE, + "Interface", + "Interface", + NULL, + G_PARAM_READABLE)); + + g_object_class_install_property + (object_class, PROP_IP_IFACE, + g_param_spec_string (NM_DEVICE_INTERFACE_IP_IFACE, + "IP Interface", + "IP Interface", + NULL, + G_PARAM_READABLE)); + + g_object_class_install_property + (object_class, PROP_DRIVER, + g_param_spec_string (NM_DEVICE_INTERFACE_DRIVER, + "Driver", + "Driver", + NULL, + G_PARAM_READABLE)); + + g_object_class_install_property + (object_class, PROP_CAPABILITIES, + g_param_spec_uint (NM_DEVICE_INTERFACE_CAPABILITIES, + "Capabilities", + "Capabilities", + 0, G_MAXUINT32, NM_DEVICE_CAP_NONE, + G_PARAM_READABLE)); + + g_object_class_install_property + (object_class, PROP_IP4_ADDRESS, + g_param_spec_uint (NM_DEVICE_INTERFACE_IP4_ADDRESS, + "IP4 address", + "IP4 address", + 0, G_MAXUINT32, 0, /* FIXME */ + G_PARAM_READABLE)); + + g_object_class_install_property + (object_class, PROP_IP4_CONFIG, + g_param_spec_boxed (NM_DEVICE_INTERFACE_IP4_CONFIG, + "IP4 Config", + "IP4 Config", + DBUS_TYPE_G_OBJECT_PATH, + G_PARAM_READABLE)); + + g_object_class_install_property + (object_class, PROP_DHCP4_CONFIG, + g_param_spec_boxed (NM_DEVICE_INTERFACE_DHCP4_CONFIG, + "DHCP4 Config", + "DHCP4 Config", + DBUS_TYPE_G_OBJECT_PATH, + G_PARAM_READABLE)); + + g_object_class_install_property + (object_class, PROP_IP6_CONFIG, + g_param_spec_boxed (NM_DEVICE_INTERFACE_IP6_CONFIG, + "IP6 Config", + "IP6 Config", + DBUS_TYPE_G_OBJECT_PATH, + G_PARAM_READABLE)); + + g_object_class_install_property + (object_class, PROP_DHCP6_CONFIG, + g_param_spec_boxed (NM_DEVICE_INTERFACE_DHCP6_CONFIG, + "DHCP6 Config", + "DHCP6 Config", + DBUS_TYPE_G_OBJECT_PATH, + G_PARAM_READABLE)); + + g_object_class_install_property + (object_class, PROP_STATE, + g_param_spec_uint (NM_DEVICE_INTERFACE_STATE, + "State", + "State", + 0, G_MAXUINT32, NM_DEVICE_STATE_UNKNOWN, + G_PARAM_READABLE)); + + g_object_class_install_property + (object_class, PROP_DEVICE_TYPE, + g_param_spec_uint (NM_DEVICE_INTERFACE_DEVICE_TYPE, + "DeviceType", + "DeviceType", + 0, G_MAXUINT32, NM_DEVICE_TYPE_UNKNOWN, + G_PARAM_READABLE)); + + g_object_class_install_property + (object_class, PROP_MANAGED, + g_param_spec_boolean (NM_DEVICE_INTERFACE_MANAGED, + "Managed", + "Managed", + FALSE, + G_PARAM_READABLE)); + + g_object_class_install_property + (object_class, PROP_PARENT, + g_param_spec_object ("parent", "parent", "parent", + NM_TYPE_DEVICE, + G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY | NM_PROPERTY_PARAM_NO_EXPORT)); + + /* Signals */ + signals[STATE_CHANGED] = + g_signal_new ("state-changed", + G_OBJECT_CLASS_TYPE (object_class), + G_SIGNAL_RUN_FIRST, + 0, NULL, NULL, + _nm_marshal_VOID__UINT_UINT_UINT, + G_TYPE_NONE, 3, G_TYPE_UINT, G_TYPE_UINT, G_TYPE_UINT); + + dbus_g_object_type_install_info (G_TYPE_FROM_CLASS (compat_class), &dbus_glib_nm_compat_device_object_info); +} + diff --git a/src/compat/nm-compat-device.h b/src/compat/nm-compat-device.h new file mode 100644 index 0000000000..f017b3363b --- /dev/null +++ b/src/compat/nm-compat-device.h @@ -0,0 +1,56 @@ +/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */ +/* NetworkDevice -- Network link manager + * + * 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 Red Hat, Inc. + */ + +#ifndef NM_COMPAT_DEVICE_H +#define NM_COMPAT_DEVICE_H + +#include <glib.h> +#include <glib-object.h> +#include <dbus/dbus-glib-lowlevel.h> +#include "nm-device.h" + +#define NM_TYPE_COMPAT_DEVICE (nm_compat_device_get_type ()) +#define NM_COMPAT_DEVICE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), NM_TYPE_COMPAT_DEVICE, NMCompatDevice)) +#define NM_COMPAT_DEVICE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), NM_TYPE_COMPAT_DEVICE, NMCompatDeviceClass)) +#define NM_IS_COMPAT_DEVICE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), NM_TYPE_COMPAT_DEVICE)) +#define NM_IS_COMPAT_DEVICE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((obj), NM_TYPE_COMPAT_DEVICE)) +#define NM_COMPAT_DEVICE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), NM_TYPE_COMPAT_DEVICE, NMCompatDeviceClass)) + +#define NM_COMPAT_DEVICE_PARENT "parent" + +typedef struct { + GObject parent; +} NMCompatDevice; + +typedef struct { + GObjectClass parent; +} NMCompatDeviceClass; + +GType nm_compat_device_get_type (void); + +NMCompatDevice *nm_compat_device_new (NMDevice *parent); + +void nm_compat_device_export (NMCompatDevice *compat, DBusGConnection *bus); + +const char *nm_compat_device_get_path (NMCompatDevice *compat); + +NMDevice *nm_compat_device_get_parent (NMCompatDevice *compat); + +#endif /* NM_COMPAT_DEVICE_H */ diff --git a/src/compat/nm-compat-device.xml b/src/compat/nm-compat-device.xml new file mode 100644 index 0000000000..b088a3bb9b --- /dev/null +++ b/src/compat/nm-compat-device.xml @@ -0,0 +1,417 @@ +<?xml version="1.0" encoding="UTF-8" ?> + +<node name="/" xmlns:tp="http://telepathy.freedesktop.org/wiki/DbusSpec#extensions-v0"> + <interface name="org.freedesktop.NetworkManagerCompat.Device"> + <property name="Udi" type="s" access="read"> + <tp:docstring> + Unique Device Identifier. + </tp:docstring> + </property> + <property name="Interface" type="s" access="read"> + <tp:docstring> + The name of the device's control (and often data) interface. + </tp:docstring> + </property> + <property name="IpInterface" type="s" access="read"> + <tp:docstring> + The name of the device's data interface when available. This property + may not refer to the actual data interface until the device has + successfully established a data connection, indicated by the device's + State becoming ACTIVATED. + </tp:docstring> + </property> + <property name="Driver" type="s" access="read"> + <tp:docstring> + The driver handling the device. + </tp:docstring> + </property> + <property name="Capabilities" type="u" access="read" tp:type="NM_DEVICE_CAP"> + <tp:docstring> + Flags describing the capabilities of the device. + </tp:docstring> + </property> + <property name="Ip4Address" type="i" access="read"> + <tp:docstring> + The IPv4 address bound to the device. FIXME: what about devices with >1 IP address? + </tp:docstring> + </property> + <property name="State" type="u" access="read" tp:type="NM_DEVICE_STATE"> + <tp:docstring> + The current state of the device. + </tp:docstring> + </property> + <property name="Ip4Config" type="o" access="read"> + <tp:docstring> + Object path of the Ip4Config object describing the configuration of the device. Only valid when the device is in the NM_DEVICE_STATE_ACTIVATED state. + </tp:docstring> + </property> + <property name="Dhcp4Config" type="o" access="read"> + <tp:docstring> + Object path of the Dhcp4Config object describing the DHCP options returned by the DHCP server. Only valid when the device is in the NM_DEVICE_STATE_ACTIVATED state. + </tp:docstring> + </property> + <property name="Ip6Config" type="o" access="read"> + <tp:docstring> + Object path of the Ip6Config object describing the configuration of the device. Only valid when the device is in the NM_DEVICE_STATE_ACTIVATED state. + </tp:docstring> + </property> + <property name="Managed" type="b" access="read"> + <tp:docstring> + Whether or not this device is managed by NetworkManager. + </tp:docstring> + </property> + <property name="DeviceType" type="u" access="read" tp:type="NM_DEVICE_TYPE"> + <tp:docstring> + The general type of the network device; ie Ethernet, WiFi, etc. + </tp:docstring> + </property> + + <method name="Disconnect"> + <annotation name="org.freedesktop.DBus.GLib.CSymbol" value="impl_compat_device_disconnect"/> + <annotation name="org.freedesktop.DBus.GLib.Async" value=""/> + <tp:docstring> + Disconnects a device and prevents the device from automatically activating further connections without user intervention. + </tp:docstring> + </method> + + <signal name="StateChanged"> + <arg name="new_state" type="u" tp:type="NM_DEVICE_STATE"> + <tp:docstring> + The new state of the device. + </tp:docstring> + </arg> + <arg name="old_state" type="u" tp:type="NM_DEVICE_STATE"> + <tp:docstring> + The previous state of the device. + </tp:docstring> + </arg> + <arg name="reason" type="u" tp:type="NM_DEVICE_STATE_REASON"> + <tp:docstring> + A reason for the state transition. + </tp:docstring> + </arg> + </signal> + + <tp:enum name="NM_DEVICE_STATE" type="u"> + <tp:enumvalue suffix="UNKNOWN" value="0"> + <tp:docstring> + The device is in an unknown state. + </tp:docstring> + </tp:enumvalue> + <tp:enumvalue suffix="UNMANAGED" value="1"> + <tp:docstring> + The device is not managed by NetworkManager. + </tp:docstring> + </tp:enumvalue> + <tp:enumvalue suffix="UNAVAILABLE" value="2"> + <tp:docstring> + The device cannot be used (carrier off, rfkill, etc). + </tp:docstring> + </tp:enumvalue> + <tp:enumvalue suffix="DISCONNECTED" value="3"> + <tp:docstring> + The device is not connected. + </tp:docstring> + </tp:enumvalue> + <tp:enumvalue suffix="PREPARE" value="4"> + <tp:docstring> + The device is preparing to connect. + </tp:docstring> + </tp:enumvalue> + <tp:enumvalue suffix="CONFIG" value="5"> + <tp:docstring> + The device is being configured. + </tp:docstring> + </tp:enumvalue> + <tp:enumvalue suffix="NEED_AUTH" value="6"> + <tp:docstring> + The device is awaiting secrets necessary to continue connection. + </tp:docstring> + </tp:enumvalue> + <tp:enumvalue suffix="IP_CONFIG" value="7"> + <tp:docstring> + The IP settings of the device are being requested and configured. + </tp:docstring> + </tp:enumvalue> + <tp:enumvalue suffix="ACTIVATED" value="8"> + <tp:docstring> + The device is active. + </tp:docstring> + </tp:enumvalue> + <tp:enumvalue suffix="FAILED" value="9"> + <tp:docstring> + The device is in a failure state following an attempt to activate it. + </tp:docstring> + </tp:enumvalue> + </tp:enum> + + <tp:enum name="NM_DEVICE_TYPE" type="u"> + <tp:enumvalue suffix="UNKNOWN" value="0"> + <tp:docstring> + The device type is unknown. + </tp:docstring> + </tp:enumvalue> + <tp:enumvalue suffix="ETHERNET" value="1"> + <tp:docstring> + The device is wired Ethernet device. + </tp:docstring> + </tp:enumvalue> + <tp:enumvalue suffix="WIFI" value="2"> + <tp:docstring> + The device is an 802.11 WiFi device. + </tp:docstring> + </tp:enumvalue> + <tp:enumvalue suffix="GSM" value="3"> + <tp:docstring> + The device is a GSM-based cellular WAN device. + </tp:docstring> + </tp:enumvalue> + <tp:enumvalue suffix="CDMA" value="4"> + <tp:docstring> + The device is a CDMA/IS-95-based cellular WAN device. + </tp:docstring> + </tp:enumvalue> + </tp:enum> + + <tp:flags name="NM_DEVICE_CAP" value-prefix="NM_DEVICE_CAP" type="u"> + <tp:flag suffix="NONE" value="0x0"> + <tp:docstring>Null capability.</tp:docstring> + </tp:flag> + <tp:flag suffix="NM_SUPPORTED" value="0x1"> + <tp:docstring>The device is supported by NetworkManager.</tp:docstring> + </tp:flag> + <tp:flag suffix="CARRIER_DETECT" value="0x2"> + <tp:docstring>The device supports carrier detection.</tp:docstring> + </tp:flag> + </tp:flags> + + <tp:enum name="NM_DEVICE_STATE_REASON" type="u"> + <tp:enumvalue suffix="UNKNOWN" value="0"> + <tp:docstring> + The reason for the device state change is unknown. + </tp:docstring> + </tp:enumvalue> + <tp:enumvalue suffix="NONE" value="1"> + <tp:docstring> + The state change is normal. + </tp:docstring> + </tp:enumvalue> + <tp:enumvalue suffix="NOW_MANAGED" value="2"> + <tp:docstring> + The device is now managed. + </tp:docstring> + </tp:enumvalue> + <tp:enumvalue suffix="NOW_UNMANAGED" value="3"> + <tp:docstring> + The device is no longer managed. + </tp:docstring> + </tp:enumvalue> + <tp:enumvalue suffix="CONFIG_FAILED" value="4"> + <tp:docstring> + The device could not be readied for configuration. + </tp:docstring> + </tp:enumvalue> + <tp:enumvalue suffix="CONFIG_UNAVAILABLE" value="5"> + <tp:docstring> + IP configuration could not be reserved (no available address, timeout, etc). + </tp:docstring> + </tp:enumvalue> + <tp:enumvalue suffix="CONFIG_EXPIRED" value="6"> + <tp:docstring> + The IP configuration is no longer valid. + </tp:docstring> + </tp:enumvalue> + <tp:enumvalue suffix="NO_SECRETS" value="7"> + <tp:docstring> + Secrets were required, but not provided. + </tp:docstring> + </tp:enumvalue> + <tp:enumvalue suffix="SUPPLICANT_DISCONNECT" value="8"> + <tp:docstring> + The 802.1X supplicant disconnected from the access point or authentication server. + </tp:docstring> + </tp:enumvalue> + <tp:enumvalue suffix="SUPPLICANT_CONFIG_FAILED" value="9"> + <tp:docstring> + Configuration of the 802.1X supplicant failed. + </tp:docstring> + </tp:enumvalue> + <tp:enumvalue suffix="SUPPLICANT_FAILED" value="10"> + <tp:docstring> + The 802.1X supplicant quit or failed unexpectedly. + </tp:docstring> + </tp:enumvalue> + <tp:enumvalue suffix="SUPPLICANT_TIMEOUT" value="11"> + <tp:docstring> + The 802.1X supplicant took too long to authenticate. + </tp:docstring> + </tp:enumvalue> + <tp:enumvalue suffix="PPP_START_FAILED" value="12"> + <tp:docstring> + The PPP service failed to start within the allowed time. + </tp:docstring> + </tp:enumvalue> + <tp:enumvalue suffix="PPP_DISCONNECT" value="13"> + <tp:docstring> + The PPP service disconnected unexpectedly. + </tp:docstring> + </tp:enumvalue> + <tp:enumvalue suffix="PPP_FAILED" value="14"> + <tp:docstring> + The PPP service quit or failed unexpectedly. + </tp:docstring> + </tp:enumvalue> + <tp:enumvalue suffix="DHCP_START_FAILED" value="15"> + <tp:docstring> + The DHCP service failed to start within the allowed time. + </tp:docstring> + </tp:enumvalue> + <tp:enumvalue suffix="DHCP_ERROR" value="16"> + <tp:docstring> + The DHCP service reported an unexpected error. + </tp:docstring> + </tp:enumvalue> + <tp:enumvalue suffix="DHCP_FAILED" value="17"> + <tp:docstring> + The DHCP service quit or failed unexpectedly. + </tp:docstring> + </tp:enumvalue> + <tp:enumvalue suffix="SHARED_START_FAILED" value="18"> + <tp:docstring> + The shared connection service failed to start. + </tp:docstring> + </tp:enumvalue> + <tp:enumvalue suffix="SHARED_FAILED" value="19"> + <tp:docstring> + The shared connection service quit or failed unexpectedly. + </tp:docstring> + </tp:enumvalue> + <tp:enumvalue suffix="AUTOIP_START_FAILED" value="20"> + <tp:docstring> + The AutoIP service failed to start. + </tp:docstring> + </tp:enumvalue> + <tp:enumvalue suffix="AUTOIP_ERROR" value="21"> + <tp:docstring> + The AutoIP service reported an unexpected error. + </tp:docstring> + </tp:enumvalue> + <tp:enumvalue suffix="AUTOIP_FAILED" value="22"> + <tp:docstring> + The AutoIP service quit or failed unexpectedly. + </tp:docstring> + </tp:enumvalue> + <tp:enumvalue suffix="MODEM_BUSY" value="23"> + <tp:docstring> + Dialing failed because the line was busy. + </tp:docstring> + </tp:enumvalue> + <tp:enumvalue suffix="MODEM_NO_DIAL_TONE" value="24"> + <tp:docstring> + Dialing failed because there was no dial tone. + </tp:docstring> + </tp:enumvalue> + <tp:enumvalue suffix="MODEM_NO_CARRIER" value="25"> + <tp:docstring> + Dialing failed because there was carrier. + </tp:docstring> + </tp:enumvalue> + <tp:enumvalue suffix="MODEM_DIAL_TIMEOUT" value="26"> + <tp:docstring> + Dialing timed out. + </tp:docstring> + </tp:enumvalue> + <tp:enumvalue suffix="MODEM_DIAL_FAILED" value="27"> + <tp:docstring> + Dialing failed. + </tp:docstring> + </tp:enumvalue> + <tp:enumvalue suffix="MODEM_INIT_FAILED" value="28"> + <tp:docstring> + Modem initialization failed. + </tp:docstring> + </tp:enumvalue> + <tp:enumvalue suffix="GSM_APN_FAILED" value="29"> + <tp:docstring> + Failed to select the specified GSM APN. + </tp:docstring> + </tp:enumvalue> + <tp:enumvalue suffix="GSM_REGISTRATION_NOT_SEARCHING" value="30"> + <tp:docstring> + Not searching for networks. + </tp:docstring> + </tp:enumvalue> + <tp:enumvalue suffix="GSM_REGISTRATION_DENIED" value="31"> + <tp:docstring> + Network registration was denied. + </tp:docstring> + </tp:enumvalue> + <tp:enumvalue suffix="GSM_REGISTRATION_TIMEOUT" value="32"> + <tp:docstring> + Network registration timed out. + </tp:docstring> + </tp:enumvalue> + <tp:enumvalue suffix="GSM_REGISTRATION_FAILED" value="33"> + <tp:docstring> + Failed to register with the requested GSM network. + </tp:docstring> + </tp:enumvalue> + <tp:enumvalue suffix="GSM_PIN_CHECK_FAILED" value="34"> + <tp:docstring> + PIN check failed. + </tp:docstring> + </tp:enumvalue> + <tp:enumvalue suffix="FIRMWARE_MISSING" value="35"> + <tp:docstring> + Necessary firmware for the device may be missing. + </tp:docstring> + </tp:enumvalue> + <tp:enumvalue suffix="REMOVED" value="36"> + <tp:docstring> + The device was removed. + </tp:docstring> + </tp:enumvalue> + <tp:enumvalue suffix="SLEEPING" value="37"> + <tp:docstring> + NetworkManager went to sleep. + </tp:docstring> + </tp:enumvalue> + <tp:enumvalue suffix="CONNECTION_REMOVED" value="38"> + <tp:docstring> + The device's active connection was removed or disappeared. + </tp:docstring> + </tp:enumvalue> + <tp:enumvalue suffix="USER_REQUESTED" value="39"> + <tp:docstring> + A user or client requested the disconnection. + </tp:docstring> + </tp:enumvalue> + <tp:enumvalue suffix="CARRIER" value="40"> + <tp:docstring> + The device's carrier/link changed. + </tp:docstring> + </tp:enumvalue> + <tp:enumvalue suffix="CONNECTION_ASSUMED" value="41"> + <tp:docstring> + The device's existing connection was assumed. + </tp:docstring> + </tp:enumvalue> + <tp:enumvalue suffix="SUPPLICANT_AVAILABLE" value="42"> + <tp:docstring> + The 802.1x supplicant is now available. + </tp:docstring> + </tp:enumvalue> + <tp:enumvalue suffix="MODEM_NOT_FOUND" value="43"> + <tp:docstring> + The modem could not be found. + </tp:docstring> + </tp:enumvalue> + <tp:enumvalue suffix="BT_FAILED" value="44"> + <tp:docstring> + The Bluetooth connection timed out or failed. + </tp:docstring> + </tp:enumvalue> + </tp:enum> + + </interface> +</node> diff --git a/src/compat/nm-compat-exported-connection.xml b/src/compat/nm-compat-exported-connection.xml new file mode 100644 index 0000000000..46907c05e9 --- /dev/null +++ b/src/compat/nm-compat-exported-connection.xml @@ -0,0 +1,99 @@ +<?xml version="1.0" encoding="UTF-8" ?> + +<node name="/" xmlns:tp="http://telepathy.freedesktop.org/wiki/DbusSpec#extensions-v0"> + + <interface name="org.freedesktop.NetworkManagerSettings.Connection"> + <tp:docstring> + Represents a single network connection configuration. + </tp:docstring> + + <method name="Update"> + <tp:docstring> + Update the connection with new settings and properties, replacing all previous settings and properties. + </tp:docstring> + <annotation name="org.freedesktop.DBus.GLib.CSymbol" value="impl_exported_connection_update"/> + <annotation name="org.freedesktop.DBus.GLib.Async" value=""/> + <arg name="properties" type="a{sa{sv}}" direction="in"> + <tp:docstring> + New connection properties. + </tp:docstring> + </arg> + </method> + + <method name="Delete"> + <tp:docstring> + Delete the connection. + </tp:docstring> + <annotation name="org.freedesktop.DBus.GLib.CSymbol" value="impl_exported_connection_delete"/> + <annotation name="org.freedesktop.DBus.GLib.Async" value=""/> + </method> + + <method name="GetSettings"> + <tp:docstring> + Get the settings maps describing this object. + </tp:docstring> + <annotation name="org.freedesktop.DBus.GLib.CSymbol" value="impl_exported_connection_get_settings"/> + <arg name="settings" type="a{sa{sv}}" direction="out" tp:type="String_String_Variant_Map_Map"> + <tp:docstring> + The nested settings maps describing this object. + </tp:docstring> + </arg> + </method> + + <signal name="Updated"> + <tp:docstring> + Emitted when some settings changed. + </tp:docstring> + <arg name="settings" type="a{sa{sv}}" tp:type="String_String_Variant_Map_Map"> + <tp:docstring> + Contains complete connection setting parameters, including changes. + </tp:docstring> + </arg> + </signal> + + <signal name="Removed"> + <tp:docstring> + Emitted when this connection has been deleted/removed. After receipt of this signal, the object no longer exists. + </tp:docstring> + </signal> + + </interface> + + <interface name="org.freedesktop.NetworkManagerSettings.Connection.Secrets"> + <tp:docstring> + Secrets have a separate interface so that they can be locked down. + </tp:docstring> + + <method name="GetSecrets"> + <tp:docstring> + Get the secrets encapsulated in this object. + </tp:docstring> + <annotation name="org.freedesktop.DBus.GLib.CSymbol" value="impl_exported_connection_get_secrets"/> + <annotation name="org.freedesktop.DBus.GLib.Async" value=""/> + <arg name="setting_name" type="s" direction="in"> + <tp:docstring> + Name of the setting to return. + </tp:docstring> + </arg> + <arg name="hints" type="as" direction="in"> + <tp:docstring> + Array of strings of key names in the Setting for which NM thinks + a secrets may be required. + </tp:docstring> + </arg> + <arg name="request_new" type="b" direction="in"> + <tp:docstring> + Indicates whether new secrets should be requested or if the request can be fulfilled from storage. + </tp:docstring> + </arg> + + <arg name="secrets" type="a{sa{sv}}" direction="out" tp:type="String_String_Variant_Map_Map"> + <tp:docstring> + Nested settings maps containing secrets. Each setting MUST contain at least the 'name' field, containing the name of the setting, and one or more secrets. + </tp:docstring> + </arg> + </method> + + </interface> + +</node> diff --git a/src/compat/nm-compat-manager.c b/src/compat/nm-compat-manager.c new file mode 100644 index 0000000000..b0ff71a3e3 --- /dev/null +++ b/src/compat/nm-compat-manager.c @@ -0,0 +1,434 @@ +/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */ +/* NetworkManager -- Network link manager + * + * 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 Red Hat, Inc. + */ + +#include "config.h" + +#include <glib.h> +#include <stdio.h> +#include <string.h> +#include <dbus/dbus-glib-lowlevel.h> + +#include "NetworkManager.h" +#include "nm-compat-manager.h" +#include "nm-dbus-glib-types.h" +#include "nm-marshal.h" +#include "nm-properties-changed-signal.h" +#include "nm-compat-device.h" +#include "nm-compat-active-connection.h" + +G_DEFINE_TYPE (NMCompatManager, nm_compat_manager, G_TYPE_OBJECT) + +#define NM_COMPAT_MANAGER_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), NM_TYPE_COMPAT_MANAGER, NMCompatManagerPrivate)) + +typedef struct { + gboolean disposed; + + NMManager *manager; +} NMCompatManagerPrivate; + + +enum { + PROP_0, + PROP_VERSION, + PROP_STATE, + PROP_NETWORKING_ENABLED, + PROP_WIRELESS_ENABLED, + PROP_WIRELESS_HARDWARE_ENABLED, + PROP_WWAN_ENABLED, + PROP_WWAN_HARDWARE_ENABLED, + PROP_ACTIVE_CONNECTIONS, + + LAST_PROP +}; + +enum { + DEVICE_ADDED, + DEVICE_REMOVED, + STATE_CHANGED, + PROPERTIES_CHANGED, + + LAST_SIGNAL +}; +static guint signals[LAST_SIGNAL] = { 0 }; + +static gboolean impl_compat_manager_get_devices (NMCompatManager *self, + GPtrArray **devices, + GError **err); + +static void impl_compat_manager_activate_connection (NMCompatManager *self, + const char *service_name, + const char *connection_path, + const char *device_path, + const char *specific_object_path, + DBusGMethodInvocation *context); + +static void impl_compat_manager_deactivate_connection (NMCompatManager *self, + const char *active_path, + DBusGMethodInvocation *context); + +static void impl_compat_manager_sleep (NMCompatManager *self, + gboolean do_sleep, + DBusGMethodInvocation *context); + +static void impl_compat_manager_enable (NMCompatManager *self, + gboolean enable, + DBusGMethodInvocation *context); + +static gboolean impl_compat_manager_get_state (NMCompatManager *self, + guint32 *state, + GError **err); + +#include "nm-compat-manager-glue.h" + +/*************************************************************************/ + +static gboolean +impl_compat_manager_get_devices (NMCompatManager *self, + GPtrArray **devices, + GError **err) +{ + NMCompatManagerPrivate *priv = NM_COMPAT_MANAGER_GET_PRIVATE (self); + GSList *list, *iter; + + list = nm_manager_get_devices (priv->manager); + *devices = g_ptr_array_sized_new (g_slist_length (list)); + for (iter = list; iter; iter = iter->next) { + NMCompatDevice *compat = nm_device_get_compat (NM_DEVICE (iter->data)); + + if (compat) + g_ptr_array_add (*devices, g_strdup (nm_compat_device_get_path (compat))); + } + return TRUE; +} + +static void +impl_compat_manager_enable (NMCompatManager *self, + gboolean enable, + DBusGMethodInvocation *context) +{ + nm_manager_compat_enable (NM_COMPAT_MANAGER_GET_PRIVATE (self)->manager, enable, context); +} + +static void +impl_compat_manager_sleep (NMCompatManager *self, + gboolean do_sleep, + DBusGMethodInvocation *context) +{ + nm_manager_compat_sleep (NM_COMPAT_MANAGER_GET_PRIVATE (self)->manager, do_sleep, context); +} + +#define NM_DBUS_SERVICE_USER_SETTINGS "org.freedesktop.NetworkManagerUserSettings" + +static void +impl_compat_manager_activate_connection (NMCompatManager *self, + const char *service_name, + const char *connection_path, + const char *device_path, + const char *specific_object_path, + DBusGMethodInvocation *context) +{ + nm_manager_compat_activate_connection (NM_COMPAT_MANAGER_GET_PRIVATE (self)->manager, + (g_strcmp0 (service_name, NM_DBUS_SERVICE_USER_SETTINGS) == 0) ? TRUE : FALSE, + connection_path, + device_path, + specific_object_path, + context); +} + +static void +impl_compat_manager_deactivate_connection (NMCompatManager *self, + const char *active_path, + DBusGMethodInvocation *context) +{ + nm_manager_compat_deactivate_connection (NM_COMPAT_MANAGER_GET_PRIVATE (self)->manager, + active_path, + context); +} + +#define NM_OLD_STATE_UNKNOWN 0 +#define NM_OLD_STATE_ASLEEP 1 +#define NM_OLD_STATE_CONNECTING 2 +#define NM_OLD_STATE_CONNECTED 3 +#define NM_OLD_STATE_DISCONNECTED 4 + +static guint32 +new_state_to_old (NMState state) +{ + switch (state) { + case NM_STATE_ASLEEP: + return NM_OLD_STATE_ASLEEP; + case NM_STATE_DISCONNECTED: + case NM_STATE_DISCONNECTING: + return NM_OLD_STATE_DISCONNECTED; + case NM_STATE_CONNECTING: + return NM_OLD_STATE_CONNECTING; + case NM_STATE_CONNECTED_LOCAL: + case NM_STATE_CONNECTED_SITE: + case NM_STATE_CONNECTED_GLOBAL: + return NM_OLD_STATE_CONNECTED; + default: + return NM_OLD_STATE_UNKNOWN; + } + g_assert_not_reached (); +} + +static gboolean +impl_compat_manager_get_state (NMCompatManager *self, + guint32 *state, + GError **err) +{ + NMCompatManagerPrivate *priv = NM_COMPAT_MANAGER_GET_PRIVATE (self); + + *state = new_state_to_old (nm_manager_get_state (priv->manager)); + return TRUE; +} + +static void +prop_reemit_cb (GObject *object, GParamSpec *pspec, NMCompatManager *self) +{ + g_object_notify (G_OBJECT (self), pspec->name); +} + +static void +state_changed_cb (NMManager *parent, NMState state, NMCompatManager *self) +{ + g_signal_emit (self, signals[STATE_CHANGED], 0, new_state_to_old (state)); +} + +static void +device_added_cb (NMManager *parent, NMDevice *device, NMCompatManager *self) +{ + NMCompatDevice *compat = nm_device_get_compat (device); + + if (compat) + g_signal_emit (self, signals[DEVICE_ADDED], 0, compat); +} + +static void +device_removed_cb (NMManager *parent, NMDevice *device, NMCompatManager *self) +{ + NMCompatDevice *compat = nm_device_get_compat (device); + + if (compat) + g_signal_emit (self, signals[DEVICE_REMOVED], 0, compat); +} + +/*************************************************************************/ + +NMCompatManager * +nm_compat_manager_new (NMManager *parent, DBusGConnection *bus) +{ + NMCompatManager *self; + + self = (NMCompatManager *) g_object_new (NM_TYPE_COMPAT_MANAGER, NULL); + if (self) { + NM_COMPAT_MANAGER_GET_PRIVATE (self)->manager = parent; + g_signal_connect (parent, "notify::" NM_MANAGER_STATE, G_CALLBACK (prop_reemit_cb), self); + g_signal_connect (parent, "notify::" NM_MANAGER_NETWORKING_ENABLED, G_CALLBACK (prop_reemit_cb), self); + g_signal_connect (parent, "notify::" NM_MANAGER_WIRELESS_ENABLED, G_CALLBACK (prop_reemit_cb), self); + g_signal_connect (parent, "notify::" NM_MANAGER_WIRELESS_HARDWARE_ENABLED, G_CALLBACK (prop_reemit_cb), self); + g_signal_connect (parent, "notify::" NM_MANAGER_WWAN_ENABLED, G_CALLBACK (prop_reemit_cb), self); + g_signal_connect (parent, "notify::" NM_MANAGER_WWAN_HARDWARE_ENABLED, G_CALLBACK (prop_reemit_cb), self); + g_signal_connect (parent, "notify::" NM_MANAGER_ACTIVE_CONNECTIONS, G_CALLBACK (prop_reemit_cb), self); + + g_signal_connect (parent, "state-changed", G_CALLBACK (state_changed_cb), self); + g_signal_connect (parent, "device-added", G_CALLBACK (device_added_cb), self); + g_signal_connect (parent, "device-removed", G_CALLBACK (device_removed_cb), self); + + dbus_g_connection_register_g_object (bus, + "/org/freedesktop/NetworkManagerCompat", + G_OBJECT (self)); + } + + return self; +} + +static void +nm_compat_manager_init (NMCompatManager *self) +{ +} + +static void +set_property (GObject *object, guint prop_id, + const GValue *value, GParamSpec *pspec) +{ + NMCompatManager *self = NM_COMPAT_MANAGER (object); + NMCompatManagerPrivate *priv = NM_COMPAT_MANAGER_GET_PRIVATE (self); + + switch (prop_id) { + case PROP_WIRELESS_ENABLED: + g_object_set (G_OBJECT (priv->manager), + NM_MANAGER_WIRELESS_ENABLED, + g_value_get_boolean (value), + NULL); + break; + case PROP_WWAN_ENABLED: + g_object_set (G_OBJECT (priv->manager), + NM_MANAGER_WWAN_ENABLED, + g_value_get_boolean (value), + NULL); + break; + default: + break; + } +} + +static void +get_property (GObject *object, guint prop_id, + GValue *value, GParamSpec *pspec) +{ + NMCompatManager *self = NM_COMPAT_MANAGER (object); + NMCompatManagerPrivate *priv = NM_COMPAT_MANAGER_GET_PRIVATE (self); + NMState state = NM_STATE_UNKNOWN; + GSList *iter, *list; + GPtrArray *active; + + if (!priv->manager) + return; + + switch (prop_id) { + case PROP_STATE: + g_object_get (priv->manager, NM_MANAGER_STATE, &state, NULL); + g_value_set_uint (value, new_state_to_old (state)); + break; + case PROP_ACTIVE_CONNECTIONS: + list = nm_manager_compat_get_active_connections (priv->manager); + active = g_ptr_array_sized_new (g_slist_length (list)); + for (iter = list; iter; iter = g_slist_next (iter)) { + NMCompatActiveConnection *compat = NM_COMPAT_ACTIVE_CONNECTION (iter->data); + + g_ptr_array_add (active, g_strdup (nm_compat_active_connection_get_path (compat))); + } + g_value_take_boxed (value, active); + g_slist_free (list); + break; + default: + g_object_get_property (G_OBJECT (priv->manager), pspec->name, value); + break; + } +} + +static void +nm_compat_manager_class_init (NMCompatManagerClass *manager_class) +{ + GObjectClass *object_class = G_OBJECT_CLASS (manager_class); + + g_type_class_add_private (manager_class, sizeof (NMCompatManagerPrivate)); + + object_class->set_property = set_property; + object_class->get_property = get_property; + + /* properties */ + g_object_class_install_property + (object_class, PROP_VERSION, + g_param_spec_string (NM_MANAGER_VERSION, + "Version", + "NetworkManager version", + NULL, + G_PARAM_READABLE)); + + g_object_class_install_property + (object_class, PROP_STATE, + g_param_spec_uint (NM_MANAGER_STATE, + "State", + "Current state", + 0, G_MAXUINT, 0, + G_PARAM_READABLE)); + + g_object_class_install_property + (object_class, PROP_NETWORKING_ENABLED, + g_param_spec_boolean (NM_MANAGER_NETWORKING_ENABLED, + "NetworkingEnabled", + "Is networking enabled", + TRUE, + G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY)); + + g_object_class_install_property + (object_class, PROP_WIRELESS_ENABLED, + g_param_spec_boolean (NM_MANAGER_WIRELESS_ENABLED, + "WirelessEnabled", + "Is wireless enabled", + TRUE, + G_PARAM_READWRITE)); + + g_object_class_install_property + (object_class, PROP_WIRELESS_HARDWARE_ENABLED, + g_param_spec_boolean (NM_MANAGER_WIRELESS_HARDWARE_ENABLED, + "WirelessHardwareEnabled", + "RF kill state", + TRUE, + G_PARAM_READABLE)); + + g_object_class_install_property + (object_class, PROP_WWAN_ENABLED, + g_param_spec_boolean (NM_MANAGER_WWAN_ENABLED, + "WwanEnabled", + "Is mobile broadband enabled", + TRUE, + G_PARAM_READWRITE)); + + g_object_class_install_property + (object_class, PROP_WWAN_HARDWARE_ENABLED, + g_param_spec_boolean (NM_MANAGER_WWAN_HARDWARE_ENABLED, + "WwanHardwareEnabled", + "Whether WWAN is disabled by a hardware switch or not", + TRUE, + G_PARAM_READABLE)); + + g_object_class_install_property + (object_class, PROP_ACTIVE_CONNECTIONS, + g_param_spec_boxed (NM_MANAGER_ACTIVE_CONNECTIONS, + "Active connections", + "Active connections", + DBUS_TYPE_G_ARRAY_OF_OBJECT_PATH, + G_PARAM_READABLE)); + + /* signals */ + signals[DEVICE_ADDED] = + g_signal_new ("device-added", + G_OBJECT_CLASS_TYPE (object_class), + G_SIGNAL_RUN_FIRST, + 0, NULL, NULL, + g_cclosure_marshal_VOID__OBJECT, + G_TYPE_NONE, 1, G_TYPE_OBJECT); + + signals[DEVICE_REMOVED] = + g_signal_new ("device-removed", + G_OBJECT_CLASS_TYPE (object_class), + G_SIGNAL_RUN_FIRST, + 0, NULL, NULL, + g_cclosure_marshal_VOID__OBJECT, + G_TYPE_NONE, 1, G_TYPE_OBJECT); + + signals[STATE_CHANGED] = + g_signal_new ("state-changed", + G_OBJECT_CLASS_TYPE (object_class), + G_SIGNAL_RUN_FIRST, + 0, NULL, NULL, + g_cclosure_marshal_VOID__UINT, + G_TYPE_NONE, 1, G_TYPE_UINT); + + signals[PROPERTIES_CHANGED] = + nm_properties_changed_signal_new (object_class, + G_STRUCT_OFFSET (NMCompatManagerClass, properties_changed)); + + dbus_g_object_type_install_info (G_TYPE_FROM_CLASS (manager_class), &dbus_glib_nm_compat_manager_object_info); +} + diff --git a/src/compat/nm-compat-manager.h b/src/compat/nm-compat-manager.h new file mode 100644 index 0000000000..7fe8556b54 --- /dev/null +++ b/src/compat/nm-compat-manager.h @@ -0,0 +1,49 @@ +/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */ +/* NetworkManager -- Network link manager + * + * 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 Red Hat, Inc. + */ + +#ifndef NM_COMPAT_MANAGER_H +#define NM_COMPAT_MANAGER_H + +#include <glib.h> +#include <glib-object.h> +#include "nm-manager.h" + +#define NM_TYPE_COMPAT_MANAGER (nm_compat_manager_get_type ()) +#define NM_COMPAT_MANAGER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), NM_TYPE_COMPAT_MANAGER, NMCompatManager)) +#define NM_COMPAT_MANAGER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), NM_TYPE_COMPAT_MANAGER, NMCompatManagerClass)) +#define NM_IS_COMPAT_MANAGER(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), NM_TYPE_COMPAT_MANAGER)) +#define NM_IS_COMPAT_MANAGER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((obj), NM_TYPE_COMPAT_MANAGER)) +#define NM_COMPAT_MANAGER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), NM_TYPE_COMPAT_MANAGER, NMCompatManagerClass)) + +typedef struct { + GObject parent; +} NMCompatManager; + +typedef struct { + GObjectClass parent; + + void (*properties_changed) (NMCompatManager *self, GHashTable *properties); +} NMCompatManagerClass; + +GType nm_compat_manager_get_type (void); + +NMCompatManager *nm_compat_manager_new (NMManager *parent, DBusGConnection *bus); + +#endif /* NM_COMPAT_MANAGER_H */ diff --git a/src/compat/nm-compat-manager.xml b/src/compat/nm-compat-manager.xml new file mode 100644 index 0000000000..523bcc38de --- /dev/null +++ b/src/compat/nm-compat-manager.xml @@ -0,0 +1,250 @@ +<?xml version="1.0" encoding="UTF-8" ?> + +<node name="/" xmlns:tp="http://telepathy.freedesktop.org/wiki/DbusSpec#extensions-v0"> + <interface name="org.freedesktop.NetworkManagerCompat"> + <method name="GetDevices"> + <tp:docstring> + Get the list of network devices. + </tp:docstring> + <annotation name="org.freedesktop.DBus.GLib.CSymbol" value="impl_compat_manager_get_devices"/> + <arg name="devices" type="ao" direction="out"> + <tp:docstring> + List of object paths of network devices known to the system. + </tp:docstring> + </arg> + </method> + + <method name="ActivateConnection"> + <annotation name="org.freedesktop.DBus.GLib.CSymbol" value="impl_compat_manager_activate_connection"/> + <annotation name="org.freedesktop.DBus.GLib.Async" value=""/> + <tp:docstring> + Activate a connection using the supplied device. + </tp:docstring> + <arg name="service_name" type="s" direction="in"> + <tp:docstring> + The D-Bus service name of the settings service that provides this connection. + </tp:docstring> + </arg> + <arg name="connection" type="o" direction="in"> + <tp:docstring> + The connection to activate the devices with. + </tp:docstring> + </arg> + <arg name="device" type="o" direction="in"> + <tp:docstring> + The object path of device to be activated for physical connections. + This parameter is ignored for VPN connections, because the + specific_object (if provided) specifies the device to use. + </tp:docstring> + </arg> + <arg name="specific_object" type="o" direction="in"> + <tp:docstring> + The path of a connection-type-specific object this activation should use. + This parameter is currently ignored for wired and mobile broadband connections, + and the value of "/" should be used (ie, no specific object). For WiFi + connections, pass the object path of a specific AP from the card's scan + list, or "/" to pick and AP automatically. For VPN connections, pass + the object path of an ActiveConnection object that should serve as the + "base" connection (to which the VPN connections lifetime will be tied), + or pass "/" and NM will automatically use the current default device. + </tp:docstring> + </arg> + <arg name="active_connection" type="o" direction="out"> + <tp:docstring> + The path of the active connection object representing this active connection. + </tp:docstring> + </arg> + <tp:possible-errors> + <tp:error name="org.freedesktop.NetworkManager.Error.UnknownConnection"/> + <tp:error name="org.freedesktop.NetworkManager.Error.UnknownDevice"/> + <tp:error name="org.freedesktop.NetworkManager.Error.InvalidService"/> + <tp:error name="org.freedesktop.NetworkManager.Error.ConnectionActivating"> + <tp:docstring>Another connection is already activating or the same connection is already active. FIXME: check if the error name is correct. FIXME: split into 2 errors?</tp:docstring> + </tp:error> + <tp:error name="org.freedesktop.NetworkManager.Error.ConnectionInvalid"> + <tp:docstring>The connection is invalid for this device.</tp:docstring> + </tp:error> + </tp:possible-errors> + </method> + + <method name="DeactivateConnection"> + <tp:docstring> + Deactivate an active connection. + </tp:docstring> + <annotation name="org.freedesktop.DBus.GLib.CSymbol" value="impl_compat_manager_deactivate_connection"/> + <annotation name="org.freedesktop.DBus.GLib.Async" value=""/> + <arg name="active_connection" type="o" direction="in"> + <tp:docstring> + The currently active connection to deactivate. + </tp:docstring> + </arg> + </method> + + <method name="Sleep"> + <annotation name="org.freedesktop.DBus.GLib.CSymbol" value="impl_compat_manager_sleep"/> + <annotation name="org.freedesktop.DBus.GLib.Async" value=""/> + <tp:docstring> + Control the NetworkManager daemon's sleep state. When asleep, all + interfaces that it manages are deactivated. When awake, devices are + available to be activated. This command should not be called directly + by users or clients; it is intended for system suspend/resume tracking. + </tp:docstring> + <arg name="sleep" type="b" direction="in"> + <tp:docstring> + Indicates whether the NetworkManager daemon should sleep or wake. + </tp:docstring> + </arg> + </method> + + <method name="Enable"> + <annotation name="org.freedesktop.DBus.GLib.CSymbol" value="impl_compat_manager_enable"/> + <annotation name="org.freedesktop.DBus.GLib.Async" value=""/> + <tp:docstring> + Control whether overall networking is enabled or disabled. When + disabled, all interfaces that NM manages are deactivated. When enabled, + all managed interfaces are re-enabled and available to be activated. + This command should be used by clients that provide to users the ability + to enable/disable all networking. + </tp:docstring> + <arg name="enable" type="b" direction="in"> + <tp:docstring> + If FALSE, indicates that all networking should be disabled. If TRUE, + indicates that NetworkManager should begin managing network devices. + </tp:docstring> + </arg> + </method> + + <property name="NetworkingEnabled" type="b" access="read"> + <tp:docstring> + Indicates if overall networking is currently enabled or not. See the + Enable() method. + </tp:docstring> + </property> + + <property name="WirelessEnabled" type="b" access="readwrite"> + <tp:docstring> + Indicates if wireless is currently enabled or not. + </tp:docstring> + </property> + + <property name="WirelessHardwareEnabled" type="b" access="read"> + <tp:docstring> + Indicates if the wireless hardware is currently enabled, i.e. the state of the RF kill switch. + </tp:docstring> + </property> + + <property name="WwanEnabled" type="b" access="readwrite"> + <tp:docstring> + Indicates if mobile broadband devices are currently enabled or not. + </tp:docstring> + </property> + + <property name="WwanHardwareEnabled" type="b" access="read"> + <tp:docstring> + Indicates if the mobile broadband hardware is currently enabled, i.e. the state of the RF kill switch. + </tp:docstring> + </property> + + <property name="ActiveConnections" type="ao" access="read"> + <tp:docstring> + List of active connection object paths. + </tp:docstring> + </property> + + <property name="Version" type="s" access="read"> + <tp:docstring> + NetworkManager version. + </tp:docstring> + </property> + + <property name="State" type="u" access="read" tp:type="NM_STATE"> + <tp:docstring> + The overall state of the NetworkManager daemon. + </tp:docstring> + </property> + + <signal name="StateChanged"> + <tp:docstring> + NetworkManager's state changed. + </tp:docstring> + <arg name="state" type="u" tp:type="NM_STATE"> + <tp:docstring> + The new state of NetworkManager. + </tp:docstring> + </arg> + </signal> + + <signal name="PropertiesChanged"> + <tp:docstring> + NetworkManager's properties changed. + </tp:docstring> + <arg name="properties" type="a{sv}" tp:type="String_Variant_Map"> + <tp:docstring> + The changed properties. + </tp:docstring> + </arg> + </signal> + + <signal name="DeviceAdded"> + <tp:docstring> + A device was added to the system + </tp:docstring> + <arg name="device_path" type="o"> + <tp:docstring> + The object path of the newly added device. + </tp:docstring> + </arg> + </signal> + + <signal name="DeviceRemoved"> + <tp:docstring> + A device was removed from the system, and is no longer available. + </tp:docstring> + <arg name="device_path" type="o"> + <tp:docstring> + The object path of the device that was just removed. + </tp:docstring> + </arg> + </signal> + + <tp:enum name="NM_STATE" type="u"> + <tp:docstring> + Describes the overall state of the daemon. + </tp:docstring> + <tp:enumvalue suffix="UNKNOWN" value="0"> + <tp:docstring> + The NetworkManager daemon is in an unknown state. + </tp:docstring> + </tp:enumvalue> + <tp:enumvalue suffix="ASLEEP" value="1"> + <tp:docstring> + The NetworkManager daemon is asleep and all interfaces managed by it are inactive. + </tp:docstring> + </tp:enumvalue> + <tp:enumvalue suffix="CONNECTING" value="2"> + <tp:docstring> + The NetworkManager daemon is connecting a device. FIXME: What does this mean when one device is active and another is connecting? + </tp:docstring> + </tp:enumvalue> + <tp:enumvalue suffix="CONNECTED" value="3"> + <tp:docstring> + The NetworkManager daemon is connected. + </tp:docstring> + </tp:enumvalue> + <tp:enumvalue suffix="DISCONNECTED" value="4"> + <tp:docstring> + The NetworkManager daemon is disconnected. + </tp:docstring> + </tp:enumvalue> + </tp:enum> + + <method name="state"> + <tp:docstring> + The overall state of the NetworkManager daemon. + </tp:docstring> + <annotation name="org.freedesktop.DBus.GLib.CSymbol" value="impl_compat_manager_get_state"/> + <arg name="state" type="u" direction="out" tp:type="NM_STATE"/> + </method> + + </interface> +</node> diff --git a/src/compat/nm-compat-settings.xml b/src/compat/nm-compat-settings.xml new file mode 100644 index 0000000000..b252c00d59 --- /dev/null +++ b/src/compat/nm-compat-settings.xml @@ -0,0 +1,47 @@ +<?xml version="1.0" encoding="UTF-8" ?> + +<node name="/" xmlns:tp="http://telepathy.freedesktop.org/wiki/DbusSpec#extensions-v0"> + <interface name="org.freedesktop.NetworkManagerSettings"> + <tp:docstring> + The NetworkManagerSettings interface is provided by the service which provides connections to NetworkManager. + </tp:docstring> + + <method name="ListConnections"> + <tp:docstring> + List the connections stored by this Settings object. + </tp:docstring> + <annotation name="org.freedesktop.DBus.GLib.CSymbol" value="impl_settings_list_connections"/> + <arg name="connections" type="ao" direction="out"> + <tp:docstring> + List of connections. + </tp:docstring> + </arg> + </method> + + <method name="AddConnection"> + <tp:docstring> + Add new connection. + </tp:docstring> + <annotation name="org.freedesktop.DBus.GLib.CSymbol" value="impl_settings_add_connection"/> + <annotation name="org.freedesktop.DBus.GLib.Async" value=""/> + <arg name="connection" type="a{sa{sv}}" direction="in"> + <tp:docstring> + Connection settings and properties. + </tp:docstring> + </arg> + </method> + + <signal name="NewConnection"> + <tp:docstring> + Emitted when a new connection has been added. + </tp:docstring> + <arg name="connection" type="o"> + <tp:docstring> + Object path of the new connection. + </tp:docstring> + </arg> + </signal> + + </interface> +</node> + diff --git a/src/compat/nm-compat-vpn-connection.c b/src/compat/nm-compat-vpn-connection.c new file mode 100644 index 0000000000..365bc11700 --- /dev/null +++ b/src/compat/nm-compat-vpn-connection.c @@ -0,0 +1,200 @@ +/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */ +/* NetworkManager -- Network link manager + * + * 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 Red Hat, Inc. + */ + +#include "config.h" + +#include <glib.h> + +#include "NetworkManager.h" +#include "nm-dbus-glib-types.h" +#include "nm-marshal.h" +#include "nm-properties-changed-signal.h" +#include "nm-compat-vpn-connection.h" + +G_DEFINE_TYPE (NMCompatVpnConnection, nm_compat_vpn_connection, NM_TYPE_COMPAT_ACTIVE_CONNECTION) + +#define NM_COMPAT_VPN_CONNECTION_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), \ + NM_TYPE_COMPAT_VPN_CONNECTION, \ + NMCompatVpnConnectionPrivate)) + +enum { + PROP_0 = 0x9000, + PROP_VPN_STATE, + PROP_BANNER, + PROP_SPECIFIC_OBJECT, + LAST_PROP +}; + +enum { + PROPERTIES_CHANGED, + VPN_STATE_CHANGED, + LAST_SIGNAL +}; +static guint signals[LAST_SIGNAL] = { 0 }; + +#include "nm-compat-vpn-connection-glue.h" + +typedef struct { + char *specific_object; +} NMCompatVpnConnectionPrivate; + +/*************************************************************************/ + +static void +prop_reemit_cb (GObject *object, GParamSpec *pspec, GObject *self) +{ + g_object_notify (self, pspec->name); +} + +static void +vpn_state_changed_cb (NMVPNConnection *vpn, + NMVPNConnectionState state, + NMVPNConnectionStateReason reason, + GObject *self) +{ + g_signal_emit (self, signals[VPN_STATE_CHANGED], 0, state, reason); +} + +/*************************************************************************/ + +NMCompatVpnConnection * +nm_compat_vpn_connection_new (NMVPNConnection *parent, DBusGConnection *bus) +{ + NMCompatVpnConnection *self; + NMCompatVpnConnectionPrivate *priv; + NMDevice *device; + NMActRequest *req; + NMCompatActiveConnection *compat_req; + + self = (NMCompatVpnConnection *) g_object_new (NM_TYPE_COMPAT_VPN_CONNECTION, + "parent", parent, + NULL); + if (self) { + priv = NM_COMPAT_VPN_CONNECTION_GET_PRIVATE (self); + + g_signal_connect (parent, "notify::" NM_VPN_CONNECTION_VPN_STATE, G_CALLBACK (prop_reemit_cb), self); + g_signal_connect (parent, "notify::" NM_VPN_CONNECTION_BANNER, G_CALLBACK (prop_reemit_cb), self); + g_signal_connect (parent, "vpn-state-changed", G_CALLBACK (vpn_state_changed_cb), self); + + device = nm_vpn_connection_get_parent_device (NM_VPN_CONNECTION (parent)); + g_assert (device); + req = nm_device_get_act_request (device); + g_assert (req); + compat_req = nm_act_request_get_compat (req); + g_assert (compat_req); + priv->specific_object = g_strdup (nm_compat_active_connection_get_path (compat_req)); + g_assert (priv->specific_object); + + nm_compat_active_connection_export (NM_COMPAT_ACTIVE_CONNECTION (self), bus); + } + + return self; +} + +static void +nm_compat_vpn_connection_init (NMCompatVpnConnection *self) +{ +} + +static void +get_property (GObject *object, guint prop_id, + GValue *value, GParamSpec *pspec) +{ + GObject *parent = nm_compat_active_connection_get_parent (NM_COMPAT_ACTIVE_CONNECTION (object)); + + switch (prop_id) { + case PROP_SPECIFIC_OBJECT: + g_value_set_boxed (value, NM_COMPAT_VPN_CONNECTION_GET_PRIVATE (object)->specific_object); + break; + default: + if (parent) + g_object_get_property (parent, pspec->name, value); + break; + } +} + +static NMConnection * +get_connection (NMCompatActiveConnection *compat, GObject *parent) +{ + /* Parent should be an NMVPNConnection */ + return nm_vpn_connection_get_connection (NM_VPN_CONNECTION (parent)); +} + +static NMDevice * +get_device (NMCompatActiveConnection *compat, GObject *parent) +{ + /* Parent should be an NMVPNConnection */ + return nm_vpn_connection_get_parent_device (NM_VPN_CONNECTION (parent)); +} + +static void +nm_compat_vpn_connection_class_init (NMCompatVpnConnectionClass *compat_class) +{ + GObjectClass *object_class = G_OBJECT_CLASS (compat_class); + NMCompatActiveConnectionClass *ac_class = NM_COMPAT_ACTIVE_CONNECTION_CLASS (compat_class); + + g_type_class_add_private (compat_class, sizeof (NMCompatVpnConnectionPrivate)); + + ac_class->get_connection = get_connection; + ac_class->get_device = get_device; + object_class->get_property = get_property; + + /* properties */ + g_object_class_install_property (object_class, PROP_VPN_STATE, + g_param_spec_uint (NM_VPN_CONNECTION_VPN_STATE, + "VpnState", + "Current VPN state", + NM_VPN_CONNECTION_STATE_UNKNOWN, + NM_VPN_CONNECTION_STATE_DISCONNECTED, + NM_VPN_CONNECTION_STATE_UNKNOWN, + G_PARAM_READABLE)); + + g_object_class_install_property (object_class, PROP_BANNER, + g_param_spec_string (NM_VPN_CONNECTION_BANNER, + "Banner", + "Login Banner", + NULL, + G_PARAM_READABLE)); + + /* Need to override the specific object because for VPN connections + * it will point to the non-compat path of the base NMActRequest and we + * need to redirect it to the NMCompatActiveConnection. + */ + g_object_class_override_property (object_class, + PROP_SPECIFIC_OBJECT, + NM_ACTIVE_CONNECTION_SPECIFIC_OBJECT); + + /* signals */ + signals[VPN_STATE_CHANGED] = + g_signal_new ("vpn-state-changed", + G_OBJECT_CLASS_TYPE (object_class), + G_SIGNAL_RUN_FIRST, + 0, NULL, NULL, + _nm_marshal_VOID__UINT_UINT, + G_TYPE_NONE, 2, G_TYPE_UINT, G_TYPE_UINT); + + signals[PROPERTIES_CHANGED] = + nm_properties_changed_signal_new (object_class, + G_STRUCT_OFFSET (NMCompatVpnConnectionClass, properties_changed)); + + dbus_g_object_type_install_info (G_TYPE_FROM_CLASS (object_class), + &dbus_glib_nm_compat_vpn_connection_object_info); +} + diff --git a/src/compat/nm-compat-vpn-connection.h b/src/compat/nm-compat-vpn-connection.h new file mode 100644 index 0000000000..fc3cfdf226 --- /dev/null +++ b/src/compat/nm-compat-vpn-connection.h @@ -0,0 +1,55 @@ +/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */ +/* NetworkManager -- Network link manager + * + * 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 Red Hat, Inc. + */ + +#ifndef NM_COMPAT_VPN_CONNECTION_H +#define NM_COMPAT_VPN_CONNECTION_H + +#include <glib.h> +#include <glib-object.h> +#include <dbus/dbus-glib-lowlevel.h> +#include "nm-vpn-connection.h" +#include "nm-compat-active-connection.h" + +#define NM_TYPE_COMPAT_VPN_CONNECTION (nm_compat_vpn_connection_get_type ()) +#define NM_COMPAT_VPN_CONNECTION(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), NM_TYPE_COMPAT_VPN_CONNECTION, NMCompatVpnConnection)) +#define NM_COMPAT_VPN_CONNECTION_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), NM_TYPE_COMPAT_VPN_CONNECTION, NMCompatVpnConnectionClass)) +#define NM_IS_COMPAT_VPN_CONNECTION(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), NM_TYPE_COMPAT_VPN_CONNECTION)) +#define NM_IS_COMPAT_VPN_CONNECTION_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((obj), NM_TYPE_COMPAT_VPN_CONNECTION)) +#define NM_COMPAT_VPN_CONNECTION_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), NM_TYPE_COMPAT_VPN_CONNECTION, NMCompatVpnConnectionClass)) + +typedef struct { + NMCompatActiveConnection parent; +} NMCompatVpnConnection; + +typedef struct { + NMCompatActiveConnectionClass parent; + + void (*vpn_state_changed) (NMCompatVpnConnection *self, + NMVPNConnectionState state, + NMVPNConnectionStateReason reason); + + void (*properties_changed) (NMCompatVpnConnection *self, GHashTable *properties); +} NMCompatVpnConnectionClass; + +GType nm_compat_vpn_connection_get_type (void); + +NMCompatVpnConnection *nm_compat_vpn_connection_new (NMVPNConnection *parent, DBusGConnection *bus); + +#endif /* NM_COMPAT_VPN_CONNECTION_H */ diff --git a/src/compat/nm-compat-vpn-connection.xml b/src/compat/nm-compat-vpn-connection.xml new file mode 100644 index 0000000000..97e4a1b9f0 --- /dev/null +++ b/src/compat/nm-compat-vpn-connection.xml @@ -0,0 +1,146 @@ +<?xml version="1.0" encoding="UTF-8" ?> + +<node name="/" xmlns:tp="http://telepathy.freedesktop.org/wiki/DbusSpec#extensions-v0"> + <interface name="org.freedesktop.NetworkManagerCompat.VPN.Connection"> + <tp:docstring> + Represents an active connection to a Virtual Private Network. + </tp:docstring> + + <signal name="PropertiesChanged"> + <arg name="properties" type="a{sv}" tp:type="String_Variant_Map"> + <tp:docstring> + A dictionary mapping property names to variant boxed values + </tp:docstring> + </arg> + </signal> + + <property name="VpnState" type="u" access="read" tp:type="NM_VPN_CONNECTION_STATE"> + <tp:docstring>The VPN-specific state of the connection.</tp:docstring> + </property> + <property name="Banner" type="s" access="read"> + <tp:docstring>The banner string of the VPN connection.</tp:docstring> + </property> + + <signal name="VpnStateChanged"> + <tp:docstring> + Emitted when the state of the VPN connection has changed. + </tp:docstring> + <arg name="state" type="u" tp:type="NM_VPN_CONNECTION_STATE"> + <tp:docstring> + The new state of the VPN connection. + </tp:docstring> + </arg> + <arg name="reason" type="u" tp:type="NM_VPN_CONNECTION_STATE_REASON"> + <tp:docstring> + Reason code describing the change to the new state. + </tp:docstring> + </arg> + </signal> + + <tp:enum name="NM_VPN_CONNECTION_STATE" type="u"> + <tp:enumvalue suffix="UNKNOWN" value="0"> + <tp:docstring> + The state of the VPN connection is unknown. + </tp:docstring> + </tp:enumvalue> + <tp:enumvalue suffix="PREPARE" value="1"> + <tp:docstring> + The VPN connection is preparing to connect. + </tp:docstring> + </tp:enumvalue> + <tp:enumvalue suffix="NEED_AUTH" value="2"> + <tp:docstring> + The VPN connection needs authorization credentials. + </tp:docstring> + </tp:enumvalue> + <tp:enumvalue suffix="CONNECT" value="3"> + <tp:docstring> + The VPN connection is being established. FIXME: Should be CONNECTING or CONNECTED. + </tp:docstring> + </tp:enumvalue> + <tp:enumvalue suffix="IP_CONFIG_GET" value="4"> + <tp:docstring> + The VPN connection is getting an IP address. FIXME: Should be an -ING + </tp:docstring> + </tp:enumvalue> + <tp:enumvalue suffix="ACTIVATED" value="5"> + <tp:docstring> + The VPN connection is active. + </tp:docstring> + </tp:enumvalue> + <tp:enumvalue suffix="FAILED" value="6"> + <tp:docstring> + The VPN connection failed. + </tp:docstring> + </tp:enumvalue> + <tp:enumvalue suffix="DISCONNECTED" value="7"> + <tp:docstring> + The VPN connection is disconnected. + </tp:docstring> + </tp:enumvalue> + </tp:enum> + <tp:enum name="NM_VPN_CONNECTION_STATE_REASON" type="u"> + <tp:enumvalue suffix="UNKNOWN" value="0"> + <tp:docstring> + The reason for the VPN connection state change is unknown. + </tp:docstring> + </tp:enumvalue> + <tp:enumvalue suffix="NONE" value="1"> + <tp:docstring> + No reason was given for the VPN connection state change. + </tp:docstring> + </tp:enumvalue> + <tp:enumvalue suffix="USER_DISCONNECTED" value="2"> + <tp:docstring> + The VPN connection changed state because the user disconnected it. + </tp:docstring> + </tp:enumvalue> + <tp:enumvalue suffix="DEVICE_DISCONNECTED" value="3"> + <tp:docstring> + The VPN connection changed state because the device it was using was disconnected. + </tp:docstring> + </tp:enumvalue> + <tp:enumvalue suffix="SERVICE_STOPPED" value="4"> + <tp:docstring> + The service providing the VPN connection was stopped. + </tp:docstring> + </tp:enumvalue> + <tp:enumvalue suffix="IP_CONFIG_INVALID" value="5"> + <tp:docstring> + The IP config of the VPN connection was invalid. + </tp:docstring> + </tp:enumvalue> + <tp:enumvalue suffix="CONNECT_TIMEOUT" value="6"> + <tp:docstring> + The connection attempt to the VPN service timed out. + </tp:docstring> + </tp:enumvalue> + <tp:enumvalue suffix="SERVICE_START_TIMEOUT" value="7"> + <tp:docstring> + A timeout occurred while starting the service providing the VPN connection. + </tp:docstring> + </tp:enumvalue> + <tp:enumvalue suffix="SERVICE_START_FAILED" value="8"> + <tp:docstring> + Starting the service starting the service providing the VPN connection failed. + </tp:docstring> + </tp:enumvalue> + <tp:enumvalue suffix="NO_SECRETS" value="9"> + <tp:docstring> + Necessary secrets for the VPN connection were not provided. + </tp:docstring> + </tp:enumvalue> + <tp:enumvalue suffix="LOGIN_FAILED" value="10"> + <tp:docstring> + Authentication to the VPN server failed. + </tp:docstring> + </tp:enumvalue> + <tp:enumvalue suffix="CONNECTION_REMOVED" value="11"> + <tp:docstring> + The connection was deleted from settings. + </tp:docstring> + </tp:enumvalue> + </tp:enum> + </interface> +</node> + diff --git a/src/nm-activation-request.c b/src/nm-activation-request.c index d3eb920d26..c3b93fe803 100644 --- a/src/nm-activation-request.c +++ b/src/nm-activation-request.c @@ -39,6 +39,7 @@ #include "nm-dbus-glib-types.h" #include "nm-active-connection-glue.h" #include "nm-settings-connection.h" +#include "compat/nm-compat-act-request.h" G_DEFINE_TYPE (NMActRequest, nm_act_request, G_TYPE_OBJECT) @@ -79,6 +80,8 @@ typedef struct { char *ac_path; gboolean assumed; + + NMCompatActRequest *compat; } NMActRequestPrivate; enum { @@ -102,9 +105,128 @@ typedef struct { guint32 call_id; NMActRequestSecretsFunc callback; gpointer callback_data; + + char *setting_name; + DBusGProxy *user_proxy; } GetSecretsInfo; static void +free_get_secrets_info (GetSecretsInfo *info) +{ + g_free (info->setting_name); + if (info->user_proxy) + g_object_unref (info->user_proxy); + memset (info, 0, sizeof (*info)); + g_free (info); +} + +static void +user_get_secrets_cb (DBusGProxy *proxy, + DBusGProxyCall *call, + gpointer user_data) +{ + GetSecretsInfo *info = user_data; + NMActRequestPrivate *priv; + GHashTable *settings = NULL; + GError *error = NULL; + + nm_log_dbg (LOGD_SETTINGS, "(%p) user secrets request reply", info); + + g_return_if_fail (info != NULL); + g_return_if_fail (info->setting_name); + + priv = NM_ACT_REQUEST_GET_PRIVATE (info->self); + + if (dbus_g_proxy_end_call (proxy, call, &error, + DBUS_TYPE_G_MAP_OF_MAP_OF_VARIANT, &settings, + G_TYPE_INVALID)) { + nm_log_dbg (LOGD_SETTINGS, "got user connection secrets size %d", g_hash_table_size (settings)); + nm_connection_update_secrets (priv->connection, info->setting_name, settings, &error); + +#if 0 + if (g_hash_table_lookup (settings, info->setting_name)) { + GHashTableIter iter; + const char *setting_name = NULL; + GHashTable *setting = NULL; + g_hash_table_iter_init (&iter, settings); + while (g_hash_table_iter_next (&iter, (gpointer) &setting_name, (gpointer) &setting)) { + GHashTableIter setting_iter; + const char *key = NULL; + GValue *val = NULL; + + g_hash_table_iter_init (&setting_iter, setting); + while (g_hash_table_iter_next (&setting_iter, (gpointer) &key, (gpointer) &val)) + g_message (" %s => %s", key, g_strdup_value_contents (val)); + } + } else { + GHashTableIter iter; + const char *key = NULL; + GValue *val = NULL; + + g_hash_table_iter_init (&iter, settings); + while (g_hash_table_iter_next (&iter, (gpointer) &key, (gpointer) &val)) + g_message (" %s => %s", key, g_strdup_value_contents (val)); + } +#endif + g_hash_table_destroy (settings); + } else { + nm_log_warn (LOGD_SETTINGS, "failed to get user connection secrets: %s", error->message); + } + + priv->secrets_calls = g_slist_remove (priv->secrets_calls, info); + info->callback (info->self, info->call_id, priv->connection, error, info->callback_data); + g_clear_error (&error); + + free_get_secrets_info (info); +} + +static guint32 +user_get_secrets (NMActRequest *self, + const char *setting_name, + guint32 flags, + const char *hint, + GetSecretsInfo *info) +{ + NMActRequestPrivate *priv = NM_ACT_REQUEST_GET_PRIVATE (self); + NMDBusManager *dbus_mgr; + DBusGConnection *bus; + GPtrArray *hints; + static guint32 counter = 3000000000u; /* start high to avoid collision with system connections */ + + /* User connection */ + dbus_mgr = nm_dbus_manager_get (); + bus = nm_dbus_manager_get_connection (dbus_mgr); + info->user_proxy = dbus_g_proxy_new_for_name (bus, + "org.freedesktop.NetworkManagerUserSettings", + nm_connection_get_path (priv->connection), + NM_DBUS_IFACE_SETTINGS_CONNECTION_SECRETS); + g_object_unref (dbus_mgr); + + if (!info->user_proxy) { + nm_log_warn (LOGD_SETTINGS, "could not create user connection secrets proxy"); + return 0; + } + + hints = g_ptr_array_sized_new (1); + if (hint) + g_ptr_array_add (hints, (gpointer) hint); + + dbus_g_proxy_begin_call_with_timeout (info->user_proxy, "GetSecrets", + user_get_secrets_cb, + info, + NULL, + 120000, + G_TYPE_STRING, setting_name, + DBUS_TYPE_G_ARRAY_OF_STRING, hints, + G_TYPE_BOOLEAN, (flags & NM_SETTINGS_GET_SECRETS_FLAG_REQUEST_NEW), + G_TYPE_INVALID); + nm_log_dbg (LOGD_SETTINGS, "(%p) new user secrets request", info); + + g_ptr_array_free (hints, TRUE); + return counter++; +} + +static void get_secrets_cb (NMSettingsConnection *connection, guint32 call_id, const char *agent_username, @@ -119,7 +241,7 @@ get_secrets_cb (NMSettingsConnection *connection, priv->secrets_calls = g_slist_remove (priv->secrets_calls, info); info->callback (info->self, call_id, NM_CONNECTION (connection), error, info->callback_data); - g_free (info); + free_get_secrets_info (info); } guint32 @@ -143,21 +265,26 @@ nm_act_request_get_secrets (NMActRequest *self, info->self = self; info->callback = callback; info->callback_data = callback_data; + info->setting_name = g_strdup (setting_name); + + if (NM_IS_SETTINGS_CONNECTION (priv->connection)) { + call_id = nm_settings_connection_get_secrets (NM_SETTINGS_CONNECTION (priv->connection), + priv->user_requested, + priv->user_uid, + setting_name, + flags, + hint, + get_secrets_cb, + info, + NULL); + } else + call_id = user_get_secrets (self, setting_name, flags, hint, info); - call_id = nm_settings_connection_get_secrets (NM_SETTINGS_CONNECTION (priv->connection), - priv->user_requested, - priv->user_uid, - setting_name, - flags, - hint, - get_secrets_cb, - info, - NULL); if (call_id > 0) { info->call_id = call_id; priv->secrets_calls = g_slist_append (priv->secrets_calls, info); } else - g_free (info); + free_get_secrets_info (info); return call_id; } @@ -182,8 +309,10 @@ nm_act_request_cancel_secrets (NMActRequest *self, guint32 call_id) priv->secrets_calls = g_slist_remove_link (priv->secrets_calls, iter); g_slist_free (iter); - nm_settings_connection_cancel_secrets (NM_SETTINGS_CONNECTION (priv->connection), call_id); - g_free (info); + if (NM_IS_SETTINGS_CONNECTION (priv->connection)) + nm_settings_connection_cancel_secrets (NM_SETTINGS_CONNECTION (priv->connection), call_id); + /* For user connections destroying the proxy cancels the request */ + free_get_secrets_info (info); break; } } @@ -467,6 +596,12 @@ device_state_changed (NMDevice *device, } } +gpointer +nm_act_request_get_compat (NMActRequest *req) +{ + return NM_ACT_REQUEST_GET_PRIVATE (req)->compat; +} + /********************************************************************/ NMActRequest * @@ -518,6 +653,8 @@ nm_act_request_init (NMActRequest *req) dbus_g_connection_register_g_object (nm_dbus_manager_get_connection (dbus_mgr), priv->ac_path, G_OBJECT (req)); + + priv->compat = nm_compat_act_request_new (req, nm_dbus_manager_get_connection (dbus_mgr)); g_object_unref (dbus_mgr); } @@ -588,12 +725,14 @@ dispose (GObject *object) for (iter = priv->secrets_calls; iter; iter = g_slist_next (iter)) { GetSecretsInfo *info = iter->data; - nm_settings_connection_cancel_secrets (NM_SETTINGS_CONNECTION (priv->connection), info->call_id); - g_free (info); + if (NM_IS_SETTINGS_CONNECTION (priv->connection)) + nm_settings_connection_cancel_secrets (NM_SETTINGS_CONNECTION (priv->connection), info->call_id); + free_get_secrets_info (info); } g_slist_free (priv->secrets_calls); g_object_unref (priv->connection); + g_object_unref (priv->compat); G_OBJECT_CLASS (nm_act_request_parent_class)->dispose (object); } diff --git a/src/nm-activation-request.h b/src/nm-activation-request.h index dac9d89af6..b20acd8fab 100644 --- a/src/nm-activation-request.h +++ b/src/nm-activation-request.h @@ -84,6 +84,8 @@ GObject * nm_act_request_get_device (NMActRequest *req); gboolean nm_act_request_get_assumed (NMActRequest *req); +gpointer nm_act_request_get_compat (NMActRequest *req); + /* Secrets handling */ typedef void (*NMActRequestSecretsFunc) (NMActRequest *req, diff --git a/src/nm-device-ethernet.c b/src/nm-device-ethernet.c index f470e090c1..6a88e8d856 100644 --- a/src/nm-device-ethernet.c +++ b/src/nm-device-ethernet.c @@ -58,6 +58,7 @@ #include "nm-logging.h" #include "nm-properties-changed-signal.h" #include "nm-dhcp-manager.h" +#include "compat/nm-compat-device-ethernet.h" #include "nm-device-ethernet-glue.h" @@ -470,6 +471,8 @@ constructor (GType type, priv->carrier = TRUE; } + nm_device_set_compat (self, nm_compat_device_ethernet_new (NM_DEVICE_ETHERNET (self))); + return object; } diff --git a/src/nm-device-modem.c b/src/nm-device-modem.c index 076bfa49ba..51694a69df 100644 --- a/src/nm-device-modem.c +++ b/src/nm-device-modem.c @@ -30,6 +30,8 @@ #include "nm-rfkill.h" #include "nm-marshal.h" #include "nm-logging.h" +#include "compat/nm-compat-device-gsm.h" +#include "compat/nm-compat-device-cdma.h" static void device_interface_init (NMDeviceInterface *iface_class); @@ -360,6 +362,28 @@ nm_device_modem_new (NMModem *modem, const char *driver) NULL); } +static GObject* +constructor (GType type, + guint n_construct_params, + GObjectConstructParam *construct_params) +{ + GObject *object; + + object = G_OBJECT_CLASS (nm_device_modem_parent_class)->constructor (type, + n_construct_params, + construct_params); + if (object) { + NMDeviceModemPrivate *priv = NM_DEVICE_MODEM_GET_PRIVATE (object); + + if (priv->current_caps & NM_DEVICE_MODEM_CAPABILITY_GSM_UMTS) + nm_device_set_compat (NM_DEVICE (object), nm_compat_device_gsm_new (NM_DEVICE_MODEM (object))); + else if (priv->current_caps & NM_DEVICE_MODEM_CAPABILITY_CDMA_EVDO) + nm_device_set_compat (NM_DEVICE (object), nm_compat_device_cdma_new (NM_DEVICE_MODEM (object))); + } + + return object; +} + static void device_interface_init (NMDeviceInterface *iface_class) { @@ -455,6 +479,7 @@ nm_device_modem_class_init (NMDeviceModemClass *mclass) g_type_class_add_private (object_class, sizeof (NMDeviceModemPrivate)); /* Virtual methods */ + object_class->constructor = constructor; object_class->finalize = finalize; object_class->get_property = get_property; object_class->set_property = set_property; diff --git a/src/nm-device-wifi.c b/src/nm-device-wifi.c index 491b856ce2..cfb30cc196 100644 --- a/src/nm-device-wifi.c +++ b/src/nm-device-wifi.c @@ -55,6 +55,7 @@ #include "nm-setting-ip4-config.h" #include "nm-setting-ip6-config.h" #include "nm-system.h" +#include "compat/nm-compat-device-wifi.h" #include "nm-settings-connection.h" static gboolean impl_device_get_access_points (NMDeviceWifi *device, @@ -706,6 +707,8 @@ constructor (GType type, } priv->ipw_rfkill_state = nm_device_wifi_get_ipw_rfkill_state (self); + nm_device_set_compat (NM_DEVICE (self), nm_compat_device_wifi_new (NM_DEVICE_WIFI (self))); + return object; error: @@ -979,8 +982,10 @@ update_seen_bssids_cache (NMDeviceWifi *self, NMAccessPoint *ap) req = nm_device_get_act_request (NM_DEVICE (self)); if (req) { connection = nm_act_request_get_connection (req); - nm_settings_connection_add_seen_bssid (NM_SETTINGS_CONNECTION (connection), - nm_ap_get_address (ap)); + /* connection can be plain NMConnection for compat interface (user connections) */ + if (NM_IS_SETTINGS_CONNECTION (connection)) + nm_settings_connection_add_seen_bssid (NM_SETTINGS_CONNECTION (connection), + nm_ap_get_address (ap)); } } } @@ -1661,22 +1666,29 @@ nm_device_wifi_ap_list_print (NMDeviceWifi *self) nm_log_dbg (LOGD_WIFI_SCAN, "Current AP list: done"); } -static gboolean -impl_device_get_access_points (NMDeviceWifi *self, - GPtrArray **aps, - GError **err) +GPtrArray * +nm_device_wifi_get_access_points (NMDeviceWifi *self) { NMDeviceWifiPrivate *priv = NM_DEVICE_WIFI_GET_PRIVATE (self); GSList *elt; + GPtrArray *aps; - *aps = g_ptr_array_new (); - + aps = g_ptr_array_new (); for (elt = priv->ap_list; elt; elt = g_slist_next (elt)) { NMAccessPoint * ap = NM_AP (elt->data); if (nm_ap_get_ssid (ap)) - g_ptr_array_add (*aps, g_strdup (nm_ap_get_dbus_path (ap))); + g_ptr_array_add (aps, g_strdup (nm_ap_get_dbus_path (ap))); } + return aps; +} + +static gboolean +impl_device_get_access_points (NMDeviceWifi *self, + GPtrArray **aps, + GError **err) +{ + *aps = nm_device_wifi_get_access_points (self); return TRUE; } diff --git a/src/nm-device-wifi.h b/src/nm-device-wifi.h index 31ac5ad5b5..efb6a25e84 100644 --- a/src/nm-device-wifi.h +++ b/src/nm-device-wifi.h @@ -100,6 +100,8 @@ NMAccessPoint * nm_device_wifi_get_activation_ap (NMDeviceWifi *self); RfKillState nm_device_wifi_get_ipw_rfkill_state (NMDeviceWifi *self); +GPtrArray *nm_device_wifi_get_access_points (NMDeviceWifi *self); + G_END_DECLS #endif /* NM_DEVICE_WIFI_H */ diff --git a/src/nm-device.c b/src/nm-device.c index 1301197acf..b822bf64e8 100644 --- a/src/nm-device.c +++ b/src/nm-device.c @@ -55,6 +55,7 @@ #include "nm-ip6-manager.h" #include "nm-marshal.h" #include "nm-rfkill.h" +#include "compat/nm-compat-device.h" #define NM_ACT_REQUEST_IP4_CONFIG "nm-act-request-ip4-config" #define NM_ACT_REQUEST_IP6_CONFIG "nm-act-request-ip6-config" @@ -148,6 +149,8 @@ typedef struct { /* inhibit autoconnect feature */ gboolean autoconnect_inhibit; + + NMCompatDevice *compat; } NMDevicePrivate; static gboolean check_connection_compatible (NMDeviceInterface *device, @@ -3353,6 +3356,9 @@ dispose (GObject *object) clear_act_request (self); + if (priv->compat) + g_object_unref (priv->compat); + out: G_OBJECT_CLASS (nm_device_parent_class)->dispose (object); } @@ -4047,3 +4053,18 @@ nm_device_clear_autoconnect_inhibit (NMDevice *device) priv->autoconnect_inhibit = FALSE; } +gpointer +nm_device_get_compat (NMDevice *device) +{ + return NM_DEVICE_GET_PRIVATE (device)->compat; +} + +void +nm_device_set_compat (NMDevice *device, gpointer compat) +{ + g_return_if_fail (NM_IS_COMPAT_DEVICE (compat)); + g_return_if_fail (NM_DEVICE_GET_PRIVATE (device)->compat == NULL); + + NM_DEVICE_GET_PRIVATE (device)->compat = NM_COMPAT_DEVICE (compat); +} + diff --git a/src/nm-device.h b/src/nm-device.h index 1d080eda50..7482b49b2a 100644 --- a/src/nm-device.h +++ b/src/nm-device.h @@ -192,6 +192,9 @@ void nm_device_clear_autoconnect_inhibit (NMDevice *device); gboolean nm_device_dhcp4_renew (NMDevice *device, gboolean release); +gpointer nm_device_get_compat (NMDevice *device); +void nm_device_set_compat (NMDevice *device, gpointer compat); + G_END_DECLS #endif /* NM_DEVICE_H */ diff --git a/src/nm-manager.c b/src/nm-manager.c index a15e4b7916..d2bccbe788 100644 --- a/src/nm-manager.c +++ b/src/nm-manager.c @@ -63,6 +63,9 @@ #include "nm-settings-connection.h" #include "nm-manager-auth.h" #include "NetworkManagerUtils.h" +#include "compat/nm-compat-manager.h" +#include "compat/nm-compat-device.h" +#include "compat/nm-compat-active-connection.h" #include "nm-utils.h" #define NM_AUTOIP_DBUS_SERVICE "org.freedesktop.nm_avahi_autoipd" @@ -174,7 +177,10 @@ struct PendingActivation { PendingActivationFunc callback; NMAuthChain *chain; + guint timeout_id; + char *connection_path; + gboolean user_connection; NMConnection *connection; char *specific_object_path; char *device_path; @@ -208,6 +214,11 @@ typedef struct { NMSettings *settings; char *hostname; + GHashTable *user_connections; + DBusGProxy *user_proxy; + NMAuthCallResult user_net_perm; + NMCompatManager *compat; + RadioState radio_states[RFKILL_TYPE_MAX]; gboolean sleeping; gboolean net_enabled; @@ -248,6 +259,11 @@ enum { CHECK_PERMISSIONS, USER_PERMISSIONS_CHANGED, + CONNECTIONS_ADDED, + CONNECTION_ADDED, + CONNECTION_UPDATED, + CONNECTION_REMOVED, + LAST_SIGNAL }; @@ -496,11 +512,15 @@ manager_device_state_changed (NMDevice *device, if (new_state == NM_DEVICE_STATE_ACTIVATED) { NMActRequest *req; + NMConnection *connection; req = nm_device_get_act_request (device); - if (req) - nm_settings_connection_update_timestamp (NM_SETTINGS_CONNECTION (nm_act_request_get_connection (req)), - (guint64) time (NULL)); + if (req) { + connection = nm_act_request_get_connection (req); + if (NM_IS_SETTINGS_CONNECTION (connection)) + nm_settings_connection_update_timestamp (NM_SETTINGS_CONNECTION (connection), + (guint64) time (NULL)); + } } } @@ -617,6 +637,7 @@ nm_manager_get_state (NMManager *manager) { g_return_val_if_fail (NM_IS_MANAGER (manager), NM_STATE_UNKNOWN); + nm_manager_update_state (manager); return NM_MANAGER_GET_PRIVATE (manager)->state; } @@ -665,6 +686,7 @@ pending_activation_new (NMManager *manager, DBusGMethodInvocation *context, const char *device_path, const char *connection_path, + gboolean user_connection, GHashTable *settings, const char *specific_object_path, PendingActivationFunc callback, @@ -730,6 +752,7 @@ pending_activation_new (NMManager *manager, pending->device_path = g_strdup (device_path); pending->connection_path = g_strdup (connection_path); + pending->user_connection = user_connection; pending->connection = connection; /* "/" is special-cased to NULL to get through D-Bus */ @@ -836,6 +859,9 @@ pending_activation_destroy (PendingActivation *pending, if (pending->chain) nm_auth_chain_unref (pending->chain); + if (pending->timeout_id) + g_source_remove (pending->timeout_id); + memset (pending, 0, sizeof (PendingActivation)); g_slice_free (PendingActivation, pending); } @@ -870,6 +896,39 @@ get_active_connections (NMManager *manager, NMConnection *filter) return active; } +GSList * +nm_manager_compat_get_active_connections (NMManager *self) +{ + NMManagerPrivate *priv = NM_MANAGER_GET_PRIVATE (self); + GSList *iter, *list = NULL, *vpns; + NMCompatActiveConnection *compat; + + /* Add active device connections */ + for (iter = priv->devices; iter; iter = g_slist_next (iter)) { + NMActRequest *req; + + req = nm_device_get_act_request (NM_DEVICE (iter->data)); + if (req) { + compat = nm_act_request_get_compat (req); + g_assert (compat); + list = g_slist_prepend (list, compat); + } + } + + /* And VPN connections */ + vpns = nm_vpn_manager_get_active_connections (priv->vpn_manager); + for (iter = vpns; iter; iter = g_slist_next (iter)) { + NMVPNConnection *vpn = NM_VPN_CONNECTION (iter->data); + + compat = nm_vpn_connection_get_compat (vpn); + g_assert (compat); + list = g_slist_prepend (list, compat); + } + g_slist_free (vpns); + + return g_slist_reverse (list); +} + /*******************************************************************/ /* Settings stuff via NMSettings */ /*******************************************************************/ @@ -927,6 +986,502 @@ system_hostname_changed_cb (NMSettings *settings, } /*******************************************************************/ +/* Compat user connection stuff */ +/*******************************************************************/ + +static void +emit_removed (gpointer key, gpointer value, gpointer user_data) +{ + NMManager *manager = NM_MANAGER (user_data); + NMConnection *connection = NM_CONNECTION (value); + + g_signal_emit (manager, signals[CONNECTION_REMOVED], 0, connection); +} + +static void +user_proxy_cleanup (NMManager *self, gboolean resync_bt) +{ + NMManagerPrivate *priv = NM_MANAGER_GET_PRIVATE (self); + + if (priv->user_connections) { + g_hash_table_foreach (priv->user_connections, emit_removed, self); + g_hash_table_remove_all (priv->user_connections); + } + + priv->user_net_perm = NM_AUTH_CALL_RESULT_UNKNOWN; + + if (priv->user_proxy) { + g_object_unref (priv->user_proxy); + priv->user_proxy = NULL; + } + + if (resync_bt) { + /* Resync BT devices since they are generated from connections */ + bluez_manager_resync_devices (self); + } +} + +typedef struct GetSettingsInfo { + NMManager *manager; + NMConnection *connection; + DBusGProxy *proxy; + guint32 *calls; +} GetSettingsInfo; + +static void +free_get_settings_info (gpointer data) +{ + GetSettingsInfo *info = (GetSettingsInfo *) data; + + /* If this was the last pending call for a batch of GetSettings calls, + * send out the connections-added signal. + */ + if (info->calls) { + (*info->calls)--; + if (*info->calls == 0) { + g_slice_free (guint32, (gpointer) info->calls); + g_signal_emit (info->manager, signals[CONNECTIONS_ADDED], 0); + + /* Update the Bluetooth connections for all the new connections */ + bluez_manager_resync_devices (info->manager); + } + } + + if (info->manager) { + g_object_unref (info->manager); + info->manager = NULL; + } + if (info->connection) { + g_object_unref (info->connection); + info->connection = NULL; + } + if (info->proxy) { + g_object_unref (info->proxy); + info->proxy = NULL; + } + + g_slice_free (GetSettingsInfo, data); +} + +static void +user_connection_get_settings_cb (DBusGProxy *proxy, + DBusGProxyCall *call_id, + gpointer user_data) +{ + GetSettingsInfo *info = (GetSettingsInfo *) user_data; + GError *err = NULL; + GHashTable *settings = NULL; + NMConnection *connection; + NMManager *manager; + + g_return_if_fail (info != NULL); + + if (!dbus_g_proxy_end_call (proxy, call_id, &err, + DBUS_TYPE_G_MAP_OF_MAP_OF_VARIANT, &settings, + G_TYPE_INVALID)) { + nm_log_info (LOGD_SETTINGS, "couldn't retrieve user connection settings: %s.", + err && err->message ? err->message : "(unknown)"); + g_error_free (err); + goto out; + } + + manager = info->manager; + connection = info->connection; + if (connection == NULL) { + const char *path = dbus_g_proxy_get_path (proxy); + NMManagerPrivate *priv; + GError *error = NULL; + NMConnection *existing = NULL; + + connection = nm_connection_new_from_hash (settings, &error); + if (connection == NULL) { + nm_log_warn (LOGD_SETTINGS, "invalid user connection: '%s' / '%s' invalid: %d", + g_type_name (nm_connection_lookup_setting_type_by_quark (error->domain)), + error->message, error->code); + g_error_free (error); + goto out; + } + + nm_connection_set_path (connection, path); + g_object_set_data (G_OBJECT (connection), "user", GUINT_TO_POINTER (1)); + + /* Add the new connection to the internal hashes only if the same + * connection isn't already there. + */ + priv = NM_MANAGER_GET_PRIVATE (manager); + + existing = g_hash_table_lookup (priv->user_connections, path); + if (!existing || !nm_connection_compare (existing, connection, NM_SETTING_COMPARE_FLAG_EXACT)) { + g_hash_table_insert (priv->user_connections, + g_strdup (path), + connection); + existing = NULL; + + /* Attach the D-Bus proxy representing the remote NMConnection + * to the local NMConnection object to ensure it stays alive to + * continue delivering signals. It'll be destroyed once the + * NMConnection is destroyed. + */ + g_object_set_data_full (G_OBJECT (connection), + "proxy", + g_object_ref (info->proxy), + g_object_unref); + } else + g_object_unref (connection); + + /* If the connection-added signal is supposed to be batched, don't + * emit the single connection-added here. Also, don't emit the signal + * if the connection wasn't actually added to the system or user hashes. + */ + if (!info->calls && !existing) { + g_signal_emit (manager, signals[CONNECTION_ADDED], 0, connection); + /* Update the Bluetooth connections for that single new connection */ + bluez_manager_resync_devices (manager); + } + } + +out: + if (settings) + g_hash_table_destroy (settings); +} + +static void +remove_connection (NMManager *manager, + NMConnection *connection, + GHashTable *hash) +{ + /* Destroys the connection, then associated DBusGProxy due to the + * weak reference notify function placed on the connection when it + * was created. + */ + g_object_ref (connection); + g_hash_table_remove (hash, nm_connection_get_path (connection)); + g_signal_emit (manager, signals[CONNECTION_REMOVED], 0, connection); + g_object_unref (connection); + + bluez_manager_resync_devices (manager); +} + +static void +user_connection_removed_cb (DBusGProxy *proxy, gpointer user_data) +{ + NMManager *manager = NM_MANAGER (user_data); + NMManagerPrivate *priv = NM_MANAGER_GET_PRIVATE (manager); + NMConnection *connection = NULL; + const char *path; + + path = dbus_g_proxy_get_path (proxy); + if (path) { + connection = g_hash_table_lookup (priv->user_connections, path); + if (connection) + remove_connection (manager, connection, priv->user_connections); + } +} + +static void +user_connection_updated_cb (DBusGProxy *proxy, + GHashTable *settings, + gpointer user_data) +{ + NMManager *manager = NM_MANAGER (user_data); + NMManagerPrivate *priv = NM_MANAGER_GET_PRIVATE (manager); + NMConnection *new_connection; + NMConnection *old_connection = NULL; + gboolean valid = FALSE; + GError *error = NULL; + const char *path; + + path = dbus_g_proxy_get_path (proxy); + if (path) + old_connection = g_hash_table_lookup (priv->user_connections, path); + + g_return_if_fail (old_connection != NULL); + + new_connection = nm_connection_new_from_hash (settings, &error); + if (!new_connection) { + /* New connection invalid, remove existing connection */ + nm_log_warn (LOGD_SETTINGS, "invalid user connection: '%s' / '%s' invalid: %d", + g_type_name (nm_connection_lookup_setting_type_by_quark (error->domain)), + error->message, error->code); + g_error_free (error); + remove_connection (manager, old_connection, priv->user_connections); + return; + } + g_object_unref (new_connection); + + valid = nm_connection_replace_settings (old_connection, settings, NULL); + if (valid) { + g_signal_emit (manager, signals[CONNECTION_UPDATED], 0, old_connection); + bluez_manager_resync_devices (manager); + } else { + remove_connection (manager, old_connection, priv->user_connections); + } +} + +#define NM_DBUS_SERVICE_USER_SETTINGS "org.freedesktop.NetworkManagerUserSettings" + +static void +user_internal_new_connection_cb (NMManager *manager, + const char *path, + guint32 *counter) +{ + GetSettingsInfo *info; + DBusGProxy *con_proxy; + DBusGConnection *g_connection; + NMManagerPrivate *priv = NM_MANAGER_GET_PRIVATE (manager); + + g_connection = nm_dbus_manager_get_connection (priv->dbus_mgr); + con_proxy = dbus_g_proxy_new_for_name (g_connection, + NM_DBUS_SERVICE_USER_SETTINGS, + path, + NM_DBUS_IFACE_SETTINGS_CONNECTION); + if (!con_proxy) { + nm_log_err (LOGD_SETTINGS, "could not init user connection proxy"); + return; + } + + dbus_g_proxy_add_signal (con_proxy, "Updated", + DBUS_TYPE_G_MAP_OF_MAP_OF_VARIANT, + G_TYPE_INVALID); + dbus_g_proxy_connect_signal (con_proxy, "Updated", + G_CALLBACK (user_connection_updated_cb), + manager, + NULL); + + dbus_g_proxy_add_signal (con_proxy, "Removed", G_TYPE_INVALID, G_TYPE_INVALID); + dbus_g_proxy_connect_signal (con_proxy, "Removed", + G_CALLBACK (user_connection_removed_cb), + manager, + NULL); + + info = g_slice_new0 (GetSettingsInfo); + info->manager = g_object_ref (manager); + info->proxy = con_proxy; + if (counter) { + info->calls = counter; + (*info->calls)++; + } + dbus_g_proxy_begin_call (con_proxy, "GetSettings", + user_connection_get_settings_cb, + info, + free_get_settings_info, + G_TYPE_INVALID); +} + +static void +user_list_connections_cb (DBusGProxy *proxy, + DBusGProxyCall *call_id, + gpointer user_data) +{ + NMManager *manager = NM_MANAGER (user_data); + GError *err = NULL; + GPtrArray *ops; + guint32 *counter = NULL; + int i; + + if (!dbus_g_proxy_end_call (proxy, call_id, &err, + DBUS_TYPE_G_ARRAY_OF_OBJECT_PATH, &ops, + G_TYPE_INVALID)) { + nm_log_warn (LOGD_SETTINGS, "couldn't retrieve user connections: %s", + err && err->message ? err->message : "(unknown)"); + g_clear_error (&err); + return; + } + + /* Keep track of all calls made here; don't want to emit connection-added for + * each one, but emit connections-added when they are all done. + */ + counter = g_slice_new0 (guint32); + for (i = 0; i < ops->len; i++) { + char *op = g_ptr_array_index (ops, i); + + user_internal_new_connection_cb (manager, op, counter); + g_free (op); + } + g_ptr_array_free (ops, TRUE); +} + +static void +user_proxy_destroyed_cb (DBusGProxy *proxy, NMManager *self) +{ + nm_log_dbg (LOGD_SETTINGS, "Removing user connections..."); + + /* At this point the user proxy is already being disposed */ + NM_MANAGER_GET_PRIVATE (self)->user_proxy = NULL; + + /* User Settings service disappeared; throw away user connections */ + user_proxy_cleanup (self, TRUE); +} + +static void +user_new_connection_cb (DBusGProxy *proxy, const char *path, gpointer user_data) +{ + user_internal_new_connection_cb (NM_MANAGER (user_data), path, NULL); +} + +static gboolean +user_settings_authorized (NMManager *self, NMAuthChain *chain) +{ + NMManagerPrivate *priv = NM_MANAGER_GET_PRIVATE (self); +// NMAuthCallResult old_net_perm = priv->user_net_perm; + + /* If the user could potentially get authorization to use networking and/or + * to use user connections, the user settings service is authorized. + */ + priv->user_net_perm = GPOINTER_TO_UINT (nm_auth_chain_get_data (chain, NM_AUTH_PERMISSION_NETWORK_CONTROL)); + + nm_log_dbg (LOGD_SETTINGS, "User connections permissions: net %d", priv->user_net_perm); + +// if (old_net_perm != priv->user_net_perm) +// g_signal_emit (self, signals[USER_PERMISSIONS_CHANGED], 0); + + /* If the user can't control the network they certainly aren't allowed + * to provide user connections. + */ + if ( priv->user_net_perm == NM_AUTH_CALL_RESULT_UNKNOWN + || priv->user_net_perm == NM_AUTH_CALL_RESULT_NO) + return FALSE; + + return TRUE; +} + +static void +user_proxy_auth_done (NMAuthChain *chain, + GError *error, + DBusGMethodInvocation *context, + gpointer user_data) +{ + NMManager *self = NM_MANAGER (user_data); + NMManagerPrivate *priv = NM_MANAGER_GET_PRIVATE (self); + gboolean authorized = FALSE; + + priv->auth_chains = g_slist_remove (priv->auth_chains, chain); + + if (error) { + nm_log_warn (LOGD_SETTINGS, "User connections unavailable: (%d) %s", + error->code, error->message ? error->message : "(unknown)"); + } else + authorized = user_settings_authorized (self, chain); + + if (authorized) { + /* If authorized, finish setting up the user settings service proxy */ + nm_log_dbg (LOGD_SETTINGS, "Requesting user connections..."); + + authorized = TRUE; + + dbus_g_proxy_add_signal (priv->user_proxy, + "NewConnection", + DBUS_TYPE_G_OBJECT_PATH, + G_TYPE_INVALID); + dbus_g_proxy_connect_signal (priv->user_proxy, "NewConnection", + G_CALLBACK (user_new_connection_cb), + self, + NULL); + + /* Clean up when the user settings proxy goes away */ + g_signal_connect (priv->user_proxy, "destroy", + G_CALLBACK (user_proxy_destroyed_cb), + self); + + /* Request user connections */ + dbus_g_proxy_begin_call (priv->user_proxy, "ListConnections", + user_list_connections_cb, + self, + NULL, + G_TYPE_INVALID); + } else { + /* Otherwise, we ignore the user settings service completely */ + user_proxy_cleanup (self, TRUE); + } + + nm_auth_chain_unref (chain); +} + +static void +user_proxy_init (NMManager *self) +{ + NMManagerPrivate *priv = NM_MANAGER_GET_PRIVATE (self); + DBusGConnection *bus; + NMAuthChain *chain; + GError *error = NULL; + + g_return_if_fail (self != NULL); + g_return_if_fail (priv->user_proxy == NULL); + + /* Don't try to initialize the user settings proxy if the user + * settings service doesn't actually exist. + */ + if (!nm_dbus_manager_name_has_owner (priv->dbus_mgr, NM_DBUS_SERVICE_USER_SETTINGS)) + return; + + bus = nm_dbus_manager_get_connection (priv->dbus_mgr); + priv->user_proxy = dbus_g_proxy_new_for_name_owner (bus, + NM_DBUS_SERVICE_USER_SETTINGS, + NM_DBUS_PATH_SETTINGS, + NM_DBUS_IFACE_SETTINGS, + &error); + if (!priv->user_proxy) { + nm_log_err (LOGD_SETTINGS, "could not init user settings proxy: (%d) %s", + error ? error->code : -1, + error && error->message ? error->message : "(unknown)"); + g_clear_error (&error); + return; + } + + /* Kick off some PolicyKit authorization requests to figure out what + * permissions this user settings service has. + */ + chain = nm_auth_chain_new (NULL, + priv->user_proxy, + user_proxy_auth_done, + self); + priv->auth_chains = g_slist_prepend (priv->auth_chains, chain); + +// nm_auth_chain_add_call (chain, NM_AUTH_PERMISSION_USE_USER_CONNECTIONS, FALSE); + nm_auth_chain_add_call (chain, NM_AUTH_PERMISSION_NETWORK_CONTROL, FALSE); +} + +static void +nm_manager_name_owner_changed (NMDBusManager *mgr, + const char *name, + const char *old, + const char *new, + gpointer user_data) +{ + NMManager *manager = NM_MANAGER (user_data); + gboolean old_owner_good = (old && (strlen (old) > 0)); + gboolean new_owner_good = (new && (strlen (new) > 0)); + + if (strcmp (name, NM_DBUS_SERVICE_USER_SETTINGS) == 0) { + if (!old_owner_good && new_owner_good) + user_proxy_init (manager); + else + user_proxy_cleanup (manager, TRUE); + } +} + +gboolean +nm_manager_compat_auto_user_connections_allowed (NMManager *self) +{ + NMManagerPrivate *priv = NM_MANAGER_GET_PRIVATE (self); + + return (priv->user_net_perm == NM_AUTH_CALL_RESULT_YES); +} + +GSList * +nm_manager_compat_get_user_connections (NMManager *self) +{ + GHashTableIter iter; + GSList *list = NULL; + gpointer connection = NULL; + + g_hash_table_iter_init (&iter, NM_MANAGER_GET_PRIVATE (self)->user_connections); + while (g_hash_table_iter_next (&iter, NULL, (gpointer) &connection)) + list = g_slist_append (list, connection); + return list; +} + +/*******************************************************************/ /* General NMManager stuff */ /*******************************************************************/ @@ -1423,6 +1978,8 @@ add_device (NMManager *self, NMDevice *device) G_OBJECT (device)); nm_log_info (LOGD_CORE, "(%s): exported as %s", iface, path); g_free (path); + if (nm_device_get_compat (device)) + nm_compat_device_export (nm_device_get_compat (device), nm_dbus_manager_get_connection (priv->dbus_mgr)); /* Check if we should assume the device's active connection by matching its * config with an existing system connection. @@ -1800,6 +2357,7 @@ nm_manager_get_act_request_by_path (NMManager *manager, for (iter = priv->devices; iter; iter = g_slist_next (iter)) { NMActRequest *req; const char *ac_path; + NMCompatActiveConnection *compat_req; req = nm_device_get_act_request (NM_DEVICE (iter->data)); if (!req) @@ -1810,6 +2368,16 @@ nm_manager_get_act_request_by_path (NMManager *manager, *device = NM_DEVICE (iter->data); return req; } + + /* It might be the object path of the compat ActiveConnection */ + compat_req = nm_act_request_get_compat (req); + if (compat_req) { + ac_path = nm_compat_active_connection_get_path (compat_req); + if (g_strcmp0 (path, ac_path) == 0) { + *device = NM_DEVICE (iter->data); + return req; + } + } } return NULL; @@ -1990,14 +2558,18 @@ static void pending_activate (NMManager *self, PendingActivation *pending) { NMManagerPrivate *priv = NM_MANAGER_GET_PRIVATE (self); - NMSettingsConnection *connection; + NMConnection *connection = NULL; const char *path = NULL; GError *error = NULL; char *sender; /* Ok, we're authorized */ - connection = nm_settings_get_connection_by_path (priv->settings, pending->connection_path); + if (pending->user_connection) + connection = g_hash_table_lookup (priv->user_connections, pending->connection_path); + else + connection = (NMConnection *) nm_settings_get_connection_by_path (priv->settings, pending->connection_path); + if (!connection) { error = g_error_new_literal (NM_MANAGER_ERROR, NM_MANAGER_ERROR_UNKNOWN_CONNECTION, @@ -2008,7 +2580,7 @@ pending_activate (NMManager *self, PendingActivation *pending) sender = dbus_g_method_get_sender (pending->context); g_assert (sender); path = nm_manager_activate_connection (self, - NM_CONNECTION (connection), + connection, pending->specific_object_path, pending->device_path, sender, @@ -2053,6 +2625,7 @@ impl_manager_activate_connection (NMManager *self, context, device_path, connection_path, + FALSE, NULL, specific_object_path, activation_auth_done, @@ -2066,6 +2639,90 @@ impl_manager_activate_connection (NMManager *self, } } +static gboolean +compat_recheck_activation (gpointer user_data) +{ + PendingActivation *pending = user_data; + + g_assert (pending->user_connection); + pending_activate (pending->manager, pending); + return FALSE; +} + +static void +compat_activation_auth_done (PendingActivation *pending, GError *error) +{ + NMManagerPrivate *priv = NM_MANAGER_GET_PRIVATE (pending->manager); + + if (error) { + pending_activation_destroy (pending, error, NULL); + return; + } + + /* If we don't know about the connection yet, wait for it */ + if (pending->user_connection) { + if (!g_hash_table_lookup (priv->user_connections, pending->connection_path)) + pending->timeout_id = g_timeout_add_seconds (4, compat_recheck_activation, pending); + } + + /* Otherwise activate it immediately */ + if (pending->timeout_id == 0) + pending_activate (pending->manager, pending); +} + +void +nm_manager_compat_activate_connection (NMManager *self, + gboolean user_connection, + const char *connection_path, + const char *device_path, + const char *specific_object_path, + DBusGMethodInvocation *context) +{ + NMManagerPrivate *priv = NM_MANAGER_GET_PRIVATE (self); + PendingActivation *pending; + GError *error = NULL; + GSList *iter; + const char *real_dev_path = NULL; + + /* Find the compat device path */ + for (iter = priv->devices; iter; iter = g_slist_next (iter)) { + NMDevice *device = iter->data; + NMCompatDevice *compat = nm_device_get_compat (device); + + if (compat && (g_strcmp0 (device_path, nm_compat_device_get_path (compat)) == 0)) { + real_dev_path = nm_device_get_path (device); + break; + } + } + + if (!real_dev_path) { + error = g_error_new_literal (NM_MANAGER_ERROR, NM_MANAGER_ERROR_UNKNOWN_DEVICE, "Device not found"); + dbus_g_method_return_error (context, error); + g_error_free (error); + return; + } + + /* Need to check the caller's permissions and stuff before we can + * activate the connection. + */ + pending = pending_activation_new (self, + context, + real_dev_path, + connection_path, + user_connection, + NULL, + specific_object_path, + compat_activation_auth_done, + &error); + if (pending) + pending_activation_check_authorized (pending, priv->dbus_mgr); + else { + g_assert (error); + dbus_g_method_return_error (context, error); + g_error_free (error); + } +} + static void activation_add_done (NMSettings *self, NMSettingsConnection *connection, @@ -2121,6 +2778,7 @@ impl_manager_add_and_activate_connection (NMManager *self, context, device_path, NULL, + FALSE, settings, specific_object_path, add_and_activate_auth_done, @@ -2230,13 +2888,21 @@ impl_manager_deactivate_connection (NMManager *self, for (iter = priv->devices; iter; iter = g_slist_next (iter)) { NMActRequest *req; const char *req_path = NULL; + const char *compat_path = NULL; + NMCompatActiveConnection *compat; req = nm_device_get_act_request (NM_DEVICE (iter->data)); - if (req) + if (req) { req_path = nm_act_request_get_active_connection_path (req); + compat = nm_act_request_get_compat (req); + if (compat) + compat_path = nm_compat_active_connection_get_path (compat); + } - if (req_path && !strcmp (active_path, req_path)) { + if ( g_strcmp0 (active_path, req_path) == 0 + || g_strcmp0 (active_path, compat_path) == 0) { connection = nm_act_request_get_connection (req); + active_path = req_path; /* ensure we have real (not compat) path */ break; } } @@ -2258,7 +2924,7 @@ impl_manager_deactivate_connection (NMManager *self, * deactivate the connection. */ if (!nm_auth_get_caller_uid (context, - priv->dbus_mgr, + priv->dbus_mgr, &sender_uid, &error_desc)) { error = g_error_new_literal (NM_MANAGER_ERROR, @@ -2293,6 +2959,14 @@ impl_manager_deactivate_connection (NMManager *self, nm_auth_chain_add_call (chain, NM_AUTH_PERMISSION_NETWORK_CONTROL, TRUE); } +void +nm_manager_compat_deactivate_connection (NMManager *self, + const char *active_path, + DBusGMethodInvocation *context) +{ + impl_manager_deactivate_connection (self, active_path, context); +} + static void do_sleep_wake (NMManager *self) { @@ -2483,6 +3157,14 @@ impl_manager_sleep (NMManager *self, #endif } +void +nm_manager_compat_sleep (NMManager *self, + gboolean do_sleep, + DBusGMethodInvocation *context) +{ + impl_manager_sleep (self, do_sleep, context); +} + static void upower_sleeping_cb (DBusGProxy *proxy, gpointer user_data) { @@ -2617,6 +3299,14 @@ impl_manager_enable (NMManager *self, nm_auth_chain_add_call (chain, NM_AUTH_PERMISSION_ENABLE_DISABLE_NETWORK, TRUE); } +void +nm_manager_compat_enable (NMManager *self, + gboolean enable, + DBusGMethodInvocation *context) +{ + impl_manager_enable (self, enable, context); +} + /* Permissions */ static void @@ -2768,6 +3458,12 @@ nm_manager_start (NMManager *self) system_unmanaged_devices_changed_cb (priv->settings, NULL, self); system_hostname_changed_cb (priv->settings, NULL, self); + /* Get user connections if the user settings service is around, otherwise + * they will be queried when the user settings service shows up on the + * bus in nm_manager_name_owner_changed(). + */ + user_proxy_init (self); + nm_udev_manager_query_devices (priv->udev_mgr); bluez_manager_resync_devices (self); } @@ -2919,7 +3615,9 @@ prop_filter (DBusConnection *connection, if (dbus_message_iter_get_arg_type (&iter) != DBUS_TYPE_STRING) return DBUS_HANDLER_RESULT_NOT_YET_HANDLED; dbus_message_iter_get_basic (&iter, &propiface); - if (!propiface || strcmp (propiface, NM_DBUS_INTERFACE)) + if (!propiface) + return DBUS_HANDLER_RESULT_NOT_YET_HANDLED; + if (g_strcmp0 (propiface, NM_DBUS_INTERFACE) && g_strcmp0 (propiface, "org.freedesktop.NetworkManagerCompat")) return DBUS_HANDLER_RESULT_NOT_YET_HANDLED; dbus_message_iter_next (&iter); @@ -3052,6 +3750,11 @@ nm_manager_get (NMSettings *settings, dbus_g_connection_register_g_object (bus, NM_DBUS_PATH, G_OBJECT (singleton)); + g_signal_connect (priv->dbus_mgr, + "name-owner-changed", + G_CALLBACK (nm_manager_name_owner_changed), + singleton); + priv->udev_mgr = nm_udev_manager_new (); g_signal_connect (priv->udev_mgr, "device-added", @@ -3078,6 +3781,9 @@ nm_manager_get (NMSettings *settings, G_CALLBACK (bluez_manager_bdaddr_removed_cb), singleton); + /* Compat manager */ + priv->compat = nm_compat_manager_new (singleton, bus); + return singleton; } @@ -3110,6 +3816,10 @@ dispose (GObject *object) g_free (priv->hostname); g_free (priv->config_file); + user_proxy_cleanup (manager, FALSE); + g_hash_table_destroy (priv->user_connections); + priv->user_connections = NULL; + g_object_unref (priv->settings); if (priv->vpn_manager_id) { @@ -3364,11 +4074,15 @@ periodic_update_active_connection_timestamps (gpointer user_data) const char *active_path = g_ptr_array_index (active, i); NMActRequest *req; NMDevice *device = NULL; + NMConnection *connection; req = nm_manager_get_act_request_by_path (manager, active_path, &device); - if (device && nm_device_get_state (device) == NM_DEVICE_STATE_ACTIVATED) - nm_settings_connection_update_timestamp (NM_SETTINGS_CONNECTION (nm_act_request_get_connection (req)), - (guint64) time (NULL)); + if (device && nm_device_get_state (device) == NM_DEVICE_STATE_ACTIVATED) { + connection = nm_act_request_get_connection (req); + if (NM_IS_SETTINGS_CONNECTION (connection)) + nm_settings_connection_update_timestamp (NM_SETTINGS_CONNECTION (connection), + (guint64) time (NULL)); + } } return TRUE; @@ -3424,6 +4138,10 @@ nm_manager_init (NMManager *manager) priv->dbus_mgr = nm_dbus_manager_get (); + priv->user_connections = g_hash_table_new_full (g_str_hash, + g_str_equal, + g_free, + g_object_unref); priv->modem_manager = nm_modem_manager_get (); priv->modem_added_id = g_signal_connect (priv->modem_manager, "modem-added", G_CALLBACK (modem_added), manager); @@ -3654,6 +4372,8 @@ nm_manager_class_init (NMManagerClass *manager_class) g_cclosure_marshal_VOID__VOID, G_TYPE_NONE, 0); + /* Compat junk */ + signals[USER_PERMISSIONS_CHANGED] = g_signal_new ("user-permissions-changed", G_OBJECT_CLASS_TYPE (object_class), @@ -3662,6 +4382,38 @@ nm_manager_class_init (NMManagerClass *manager_class) g_cclosure_marshal_VOID__VOID, G_TYPE_NONE, 0); + signals[CONNECTIONS_ADDED] = + g_signal_new ("connections-added", + G_OBJECT_CLASS_TYPE (object_class), + G_SIGNAL_RUN_FIRST, + 0, NULL, NULL, + g_cclosure_marshal_VOID__VOID, + G_TYPE_NONE, 0); + + signals[CONNECTION_ADDED] = + g_signal_new ("connection-added", + G_OBJECT_CLASS_TYPE (object_class), + G_SIGNAL_RUN_FIRST, + 0, NULL, NULL, + g_cclosure_marshal_VOID__OBJECT, + G_TYPE_NONE, 1, G_TYPE_OBJECT); + + signals[CONNECTION_UPDATED] = + g_signal_new ("connection-updated", + G_OBJECT_CLASS_TYPE (object_class), + G_SIGNAL_RUN_FIRST, + 0, NULL, NULL, + g_cclosure_marshal_VOID__OBJECT, + G_TYPE_NONE, 1, G_TYPE_OBJECT); + + signals[CONNECTION_REMOVED] = + g_signal_new ("connection-removed", + G_OBJECT_CLASS_TYPE (object_class), + G_SIGNAL_RUN_FIRST, + 0, NULL, NULL, + g_cclosure_marshal_VOID__OBJECT, + G_TYPE_NONE, 1, G_TYPE_OBJECT); + dbus_g_object_type_install_info (G_TYPE_FROM_CLASS (manager_class), &dbus_glib_nm_manager_object_info); diff --git a/src/nm-manager.h b/src/nm-manager.h index 22bfca9e8b..92f8cc1dff 100644 --- a/src/nm-manager.h +++ b/src/nm-manager.h @@ -102,4 +102,31 @@ NMState nm_manager_get_state (NMManager *manager); GPtrArray * nm_manager_get_active_connections_by_connection (NMManager *manager, NMConnection *connection); +/* Compat manager accessors */ + +GSList *nm_manager_compat_get_active_connections (NMManager *self); + +void nm_manager_compat_enable (NMManager *self, + gboolean enable, + DBusGMethodInvocation *context); + +void nm_manager_compat_sleep (NMManager *self, + gboolean do_sleep, + DBusGMethodInvocation *context); + +void nm_manager_compat_deactivate_connection (NMManager *self, + const char *active_path, + DBusGMethodInvocation *context); + +GSList *nm_manager_compat_get_user_connections (NMManager *self); + +gboolean nm_manager_compat_auto_user_connections_allowed (NMManager *self); + +void nm_manager_compat_activate_connection (NMManager *self, + gboolean user_settings, + const char *connection_path, + const char *device_path, + const char *specific_object_path, + DBusGMethodInvocation *context); + #endif /* NM_MANAGER_H */ diff --git a/src/nm-policy.c b/src/nm-policy.c index e3c899f5e3..16bb0bfd92 100644 --- a/src/nm-policy.c +++ b/src/nm-policy.c @@ -722,9 +722,12 @@ auto_activate_device (gpointer user_data) if (nm_device_get_act_request (data->device)) goto out; - iter = connections = nm_settings_get_connections (policy->settings); + connections = nm_settings_get_connections (policy->settings); + if (nm_manager_compat_auto_user_connections_allowed (policy->manager)) + connections = g_slist_concat (connections, nm_manager_compat_get_user_connections (policy->manager)); /* Remove connections that shouldn't be auto-activated */ + iter = connections; while (iter) { NMConnection *candidate = NM_CONNECTION (iter->data); @@ -735,7 +738,7 @@ auto_activate_device (gpointer user_data) * to any logged-in users. */ if ( get_connection_auto_retries (candidate) == 0 - || nm_settings_connection_is_visible (NM_SETTINGS_CONNECTION (candidate)) == FALSE) + || (NM_IS_SETTINGS_CONNECTION (candidate) && nm_settings_connection_is_visible (NM_SETTINGS_CONNECTION (candidate)) == FALSE)) connections = g_slist_remove (connections, candidate); } @@ -1234,6 +1237,12 @@ nm_policy_new (NMManager *manager, _connect_manager_signal (policy, "device-added", device_added); _connect_manager_signal (policy, "device-removed", device_removed); + /* Compat bits */ + _connect_manager_signal (policy, "connections-added", connections_loaded); + _connect_manager_signal (policy, "connection-added", connection_added); + _connect_manager_signal (policy, "connection-updated", connection_updated); + _connect_manager_signal (policy, "connection-removed", connection_removed); + _connect_settings_signal (policy, NM_SETTINGS_SIGNAL_CONNECTIONS_LOADED, connections_loaded); _connect_settings_signal (policy, NM_SETTINGS_SIGNAL_CONNECTION_ADDED, connection_added); _connect_settings_signal (policy, NM_SETTINGS_SIGNAL_CONNECTION_UPDATED, connection_updated); diff --git a/src/vpn-manager/nm-vpn-connection.c b/src/vpn-manager/nm-vpn-connection.c index 067b2dce3e..6243d16ae4 100644 --- a/src/vpn-manager/nm-vpn-connection.c +++ b/src/vpn-manager/nm-vpn-connection.c @@ -48,6 +48,7 @@ #include "nm-netlink-monitor.h" #include "nm-glib-compat.h" #include "settings/nm-settings-connection.h" +#include "compat/nm-compat-vpn-connection.h" #include "nm-vpn-connection-glue.h" @@ -71,6 +72,7 @@ typedef struct { gboolean user_requested; gulong user_uid; + DBusGProxy *user_proxy; guint32 secrets_id; SecretsReq secrets_idx; char *username; @@ -89,6 +91,8 @@ typedef struct { char *banner; struct rtnl_route *gw_route; + + NMCompatVpnConnection *compat; } NMVPNConnectionPrivate; #define NM_VPN_CONNECTION_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), NM_TYPE_VPN_CONNECTION, NMVPNConnectionPrivate)) @@ -224,6 +228,7 @@ nm_vpn_connection_new (NMConnection *connection, { NMVPNConnection *self; NMVPNConnectionPrivate *priv; + NMDBusManager *dbus_mgr; g_return_val_if_fail (NM_IS_CONNECTION (connection), NULL); g_return_val_if_fail (NM_IS_DEVICE (parent_device), NULL); @@ -249,6 +254,10 @@ nm_vpn_connection_new (NMConnection *connection, nm_vpn_connection_base_export (NM_VPN_CONNECTION_BASE (self), connection); + dbus_mgr = nm_dbus_manager_get (); + priv->compat = nm_compat_vpn_connection_new (self, nm_dbus_manager_get_connection (dbus_mgr)); + g_object_unref (dbus_mgr); + return self; } @@ -803,9 +812,126 @@ nm_vpn_connection_disconnect (NMVPNConnection *connection, reason); } +gpointer +nm_vpn_connection_get_compat (NMVPNConnection *connection) +{ + return NM_VPN_CONNECTION_GET_PRIVATE (connection)->compat; +} + /******************************************************************************/ static void +user_get_secrets_cb (DBusGProxy *proxy, + DBusGProxyCall *call, + gpointer user_data) +{ + NMVPNConnection *self = NM_VPN_CONNECTION (user_data); + NMVPNConnectionPrivate *priv = NM_VPN_CONNECTION_GET_PRIVATE (self); + GHashTable *settings = NULL; + GError *error = NULL; + + nm_log_dbg (LOGD_VPN, "(%s/%s) VPN user secrets reply", + nm_connection_get_uuid (priv->connection), + nm_connection_get_id (priv->connection)); + + if (dbus_g_proxy_end_call (proxy, call, &error, + DBUS_TYPE_G_MAP_OF_MAP_OF_VARIANT, &settings, + G_TYPE_INVALID)) { + nm_log_dbg (LOGD_VPN, "(%s/%s) got user VPN secrets size %d", + nm_connection_get_uuid (priv->connection), + nm_connection_get_id (priv->connection), + g_hash_table_size (settings)); + + nm_connection_update_secrets (priv->connection, NM_SETTING_VPN_SETTING_NAME, settings, &error); + +#if 0 + if (g_hash_table_lookup (settings, info->setting_name)) { + GHashTableIter iter; + const char *setting_name = NULL; + GHashTable *setting = NULL; + g_hash_table_iter_init (&iter, settings); + while (g_hash_table_iter_next (&iter, (gpointer) &setting_name, (gpointer) &setting)) { + GHashTableIter setting_iter; + const char *key = NULL; + GValue *val = NULL; + + g_hash_table_iter_init (&setting_iter, setting); + while (g_hash_table_iter_next (&setting_iter, (gpointer) &key, (gpointer) &val)) + g_message (" %s => %s", key, g_strdup_value_contents (val)); + } + } else { + GHashTableIter iter; + const char *key = NULL; + GValue *val = NULL; + + g_hash_table_iter_init (&iter, settings); + while (g_hash_table_iter_next (&iter, (gpointer) &key, (gpointer) &val)) + g_message (" %s => %s", key, g_strdup_value_contents (val)); + } +#endif + g_hash_table_destroy (settings); + } else { + nm_log_warn (LOGD_VPN, "(%s/%s) failed to get VPN user secrets: %s", + nm_connection_get_uuid (priv->connection), + nm_connection_get_id (priv->connection), + error ? error->message : "(none)"); + } + + priv->secrets_id = 0; + g_object_unref (priv->user_proxy); + + if (error) + nm_vpn_connection_fail (self, NM_VPN_CONNECTION_STATE_REASON_NO_SECRETS); + else + really_activate (self, NULL); + + g_clear_error (&error); +} + +static void +get_user_secrets (NMVPNConnection *self) +{ + NMVPNConnectionPrivate *priv = NM_VPN_CONNECTION_GET_PRIVATE (self); + NMDBusManager *dbus_mgr; + DBusGConnection *bus; + GPtrArray *hints; + static guint32 counter = 3000000000u; + + /* User connection */ + dbus_mgr = nm_dbus_manager_get (); + bus = nm_dbus_manager_get_connection (dbus_mgr); + priv->user_proxy = dbus_g_proxy_new_for_name (bus, + "org.freedesktop.NetworkManagerUserSettings", + nm_connection_get_path (priv->connection), + NM_DBUS_IFACE_SETTINGS_CONNECTION_SECRETS); + g_object_unref (dbus_mgr); + + if (!priv->user_proxy) { + nm_log_warn (LOGD_SETTINGS, "could not create user VPN secrets proxy"); + return; + } + + nm_log_dbg (LOGD_VPN, "(%s/%s) requesting VPN user secrets", + nm_connection_get_uuid (priv->connection), + nm_connection_get_id (priv->connection)); + + hints = g_ptr_array_sized_new (0); + dbus_g_proxy_begin_call_with_timeout (priv->user_proxy, "GetSecrets", + user_get_secrets_cb, + self, + NULL, + 120000, + G_TYPE_STRING, NM_SETTING_VPN_SETTING_NAME, + DBUS_TYPE_G_ARRAY_OF_STRING, hints, + G_TYPE_BOOLEAN, FALSE, + G_TYPE_INVALID); + nm_log_dbg (LOGD_SETTINGS, "new user VPN secrets request"); + g_ptr_array_free (hints, TRUE); + + priv->secrets_id = counter++; +} + +static void plugin_need_secrets_cb (DBusGProxy *proxy, char *setting_name, GError *error, @@ -999,9 +1125,16 @@ connection_state_changed (NMVPNConnection *self, /* Clear any in-progress secrets request */ if (priv->secrets_id) { - nm_settings_connection_cancel_secrets (NM_SETTINGS_CONNECTION (priv->connection), priv->secrets_id); + if (NM_IS_SETTINGS_CONNECTION (priv->connection)) + nm_settings_connection_cancel_secrets (NM_SETTINGS_CONNECTION (priv->connection), priv->secrets_id); priv->secrets_id = 0; } + + if (priv->user_proxy) { + g_object_unref (priv->user_proxy); + priv->user_proxy = NULL; + } + priv->secrets_idx = SECRETS_REQ_SYSTEM; switch (state) { @@ -1011,7 +1144,12 @@ connection_state_changed (NMVPNConnection *self, * secrets from system and from user agents and ask the plugin again, * and last we ask the user for new secrets if required. */ - get_secrets (self, SECRETS_REQ_SYSTEM); + if (NM_IS_SETTINGS_CONNECTION (priv->connection)) + get_secrets (self, SECRETS_REQ_SYSTEM); + else { + /* Don't bother with existing secrets if it's user settings */ + get_user_secrets (self); + } break; case NM_VPN_CONNECTION_STATE_ACTIVATED: /* Secrets no longer needed now that we're connected */ @@ -1075,12 +1213,18 @@ dispose (GObject *object) if (priv->proxy) g_object_unref (priv->proxy); - if (priv->secrets_id) { + if (priv->secrets_id && NM_IS_SETTINGS_CONNECTION (priv->connection)) { nm_settings_connection_cancel_secrets (NM_SETTINGS_CONNECTION (priv->connection), priv->secrets_id); } + if (priv->user_proxy) { + /* User secrets call gets cleaned up when proxy is unrefed */ + g_object_unref (priv->user_proxy); + } + g_object_unref (priv->connection); + g_object_unref (priv->compat); g_free (priv->username); G_OBJECT_CLASS (nm_vpn_connection_parent_class)->dispose (object); diff --git a/src/vpn-manager/nm-vpn-connection.h b/src/vpn-manager/nm-vpn-connection.h index ee8eb5b6ea..ea905b7f2a 100644 --- a/src/vpn-manager/nm-vpn-connection.h +++ b/src/vpn-manager/nm-vpn-connection.h @@ -75,4 +75,6 @@ const char * nm_vpn_connection_get_ip_iface (NMVPNConnection *connect NMDevice * nm_vpn_connection_get_parent_device (NMVPNConnection *connection); guint32 nm_vpn_connection_get_ip4_internal_gateway (NMVPNConnection *connection); +gpointer nm_vpn_connection_get_compat (NMVPNConnection *connection); + #endif /* NM_VPN_CONNECTION_H */ diff --git a/src/vpn-manager/nm-vpn-manager.c b/src/vpn-manager/nm-vpn-manager.c index 6772bb18d6..9deaeb348b 100644 --- a/src/vpn-manager/nm-vpn-manager.c +++ b/src/vpn-manager/nm-vpn-manager.c @@ -30,6 +30,7 @@ #include "NetworkManagerVPN.h" #include "nm-marshal.h" #include "nm-logging.h" +#include "compat/nm-compat-active-connection.h" G_DEFINE_TYPE (NMVPNManager, nm_vpn_manager, G_TYPE_OBJECT) @@ -240,10 +241,17 @@ nm_vpn_manager_deactivate_connection (NMVPNManager *self, active = nm_vpn_service_get_active_connections (NM_VPN_SERVICE (data)); for (aiter = active; aiter; aiter = g_slist_next (aiter)) { NMVPNConnection *vpn = NM_VPN_CONNECTION (aiter->data); - const char *vpn_path; + const char *vpn_path, *compat_path = NULL; + NMCompatActiveConnection *compat; vpn_path = nm_vpn_connection_get_active_connection_path (vpn); - if (!strcmp (path, vpn_path)) { + /* We might have been passed a compat path too */ + compat = nm_vpn_connection_get_compat (vpn); + if (compat) + compat_path = nm_compat_active_connection_get_path (compat); + + if ( g_strcmp0 (path, vpn_path) == 0 + || g_strcmp0 (path, compat_path) == 0) { nm_vpn_connection_disconnect (vpn, reason); success = TRUE; break; @@ -324,9 +332,16 @@ nm_vpn_manager_get_connection_for_active (NMVPNManager *manager, for (elt = active; elt; elt = g_slist_next (elt)) { NMVPNConnection *vpn = NM_VPN_CONNECTION (elt->data); const char *ac_path; + const char *compat_path = NULL; + NMCompatActiveConnection *compat; ac_path = nm_vpn_connection_get_active_connection_path (vpn); - if (ac_path && !strcmp (ac_path, active_path)) + compat = nm_vpn_connection_get_compat (vpn); + if (compat) + compat_path = nm_compat_active_connection_get_path (compat); + + if ( g_strcmp0 (ac_path, active_path) == 0 + || g_strcmp0 (compat_path, active_path) == 0) return nm_vpn_connection_get_connection (vpn); } } |