mirror of
https://gitlab.freedesktop.org/NetworkManager/NetworkManager
synced 2024-10-15 12:34:55 +00:00
2008-03-20 Dan Williams <dcbw@redhat.com>
* introspection/nm-manager.xml introspection/nm-manager-client.xml - (ActivateConnection): return the object path of the active connection on success - (GetActiveConnections): remove - (DeactivateConnection): new function; deactivate a currently active connection - Add an ActiveConnections property which returns an array of active connection object paths * introspection/nm-device.xml - (Deactivate): remove * introspection/all.xml - Add ActiveConnection introspection * introspection/nm-active-connection.xml - Add the ActiveConnection object * include/NetworkManager.h - Add the Connection.Active D-Bus interface * src/nm-device-interface.c - (impl_device_deactivate): remove * src/nm-activation-request.c src/nm-activation-request.c src/Makefile.am - Implement the Connection.Active D-Bus interface * src/nm-manager.c - (get_property, nm_manager_class_init): add ACTIVE_CONNECTIONS property - (nm_manager_activate_device): return the active connection path - (connection_added_default_handler, impl_manager_activate_connection): return the active connection to the caller - (add_one_connection_element, impl_manager_get_active_connections): remove - (impl_manager_deactivate_connection): new function; deactivate an active connection * libnm-glib/nm-device.c libnm-glib/nm-device.h - Remove Deactivate() function git-svn-id: http://svn-archive.gnome.org/svn/NetworkManager/trunk@3484 4912f4e0-d625-0410-9fb7-b9a5a253dbdc
This commit is contained in:
parent
2a80111913
commit
393685203f
46
ChangeLog
46
ChangeLog
|
@ -1,3 +1,49 @@
|
|||
2008-03-20 Dan Williams <dcbw@redhat.com>
|
||||
|
||||
* introspection/nm-manager.xml
|
||||
introspection/nm-manager-client.xml
|
||||
- (ActivateConnection): return the object path of the active connection
|
||||
on success
|
||||
- (GetActiveConnections): remove
|
||||
- (DeactivateConnection): new function; deactivate a currently active
|
||||
connection
|
||||
- Add an ActiveConnections property which returns an array of
|
||||
active connection object paths
|
||||
|
||||
* introspection/nm-device.xml
|
||||
- (Deactivate): remove
|
||||
|
||||
* introspection/all.xml
|
||||
- Add ActiveConnection introspection
|
||||
|
||||
* introspection/nm-active-connection.xml
|
||||
- Add the ActiveConnection object
|
||||
|
||||
* include/NetworkManager.h
|
||||
- Add the Connection.Active D-Bus interface
|
||||
|
||||
* src/nm-device-interface.c
|
||||
- (impl_device_deactivate): remove
|
||||
|
||||
* src/nm-activation-request.c
|
||||
src/nm-activation-request.c
|
||||
src/Makefile.am
|
||||
- Implement the Connection.Active D-Bus interface
|
||||
|
||||
* src/nm-manager.c
|
||||
- (get_property, nm_manager_class_init): add ACTIVE_CONNECTIONS property
|
||||
- (nm_manager_activate_device): return the active connection path
|
||||
- (connection_added_default_handler, impl_manager_activate_connection):
|
||||
return the active connection to the caller
|
||||
- (add_one_connection_element, impl_manager_get_active_connections):
|
||||
remove
|
||||
- (impl_manager_deactivate_connection): new function; deactivate an
|
||||
active connection
|
||||
|
||||
* libnm-glib/nm-device.c
|
||||
libnm-glib/nm-device.h
|
||||
- Remove Deactivate() function
|
||||
|
||||
2008-03-19 Dan Williams <dcbw@redhat.com>
|
||||
|
||||
* introspection/nm-manager.xml
|
||||
|
|
|
@ -36,6 +36,7 @@
|
|||
#define NM_DBUS_INTERFACE_ACCESS_POINT "org.freedesktop.NetworkManager.AccessPoint"
|
||||
#define NM_DBUS_INTERFACE_GSM_DEVICE "org.freedesktop.NetworkManager.Device.Gsm"
|
||||
#define NM_DBUS_INTERFACE_CDMA_DEVICE "org.freedesktop.NetworkManager.Device.Cdma"
|
||||
#define NM_DBUS_INTERFACE_ACTIVE_CONNECTION "org.freedesktop.NetworkManager.Connection.Active"
|
||||
|
||||
#define NM_DBUS_SERVICE_USER_SETTINGS "org.freedesktop.NetworkManagerUserSettings"
|
||||
#define NM_DBUS_SERVICE_SYSTEM_SETTINGS "org.freedesktop.NetworkManagerSystemSettings"
|
||||
|
|
|
@ -11,5 +11,6 @@ EXTRA_DIST = \
|
|||
nm-vpn-manager.xml \
|
||||
nm-vpn-plugin.xml \
|
||||
nm-vpn-connection.xml \
|
||||
nm-ppp-manager.xml
|
||||
nm-ppp-manager.xml \
|
||||
nm-active-connection.xml
|
||||
|
||||
|
|
|
@ -33,6 +33,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.</
|
|||
<xi:include href="nm-ip4-config.xml"/>
|
||||
<xi:include href="nm-settings.xml"/>
|
||||
<xi:include href="nm-exported-connection.xml"/>
|
||||
<xi:include href="nm-active-connection.xml"/>
|
||||
<xi:include href="nm-vpn-manager.xml"/>
|
||||
<xi:include href="nm-vpn-connection.xml"/>
|
||||
<xi:include href="nm-vpn-plugin.xml"/>
|
||||
|
|
|
@ -2,13 +2,6 @@
|
|||
|
||||
<node name="/" xmlns:tp="http://telepathy.freedesktop.org/wiki/DbusSpec#extensions-v0">
|
||||
<interface name="org.freedesktop.NetworkManager.Device">
|
||||
<method name="Deactivate">
|
||||
<annotation name="org.freedesktop.DBus.GLib.CSymbol" value="impl_device_deactivate"/>
|
||||
<tp:docstring>
|
||||
Deactivate the device, removing its routing table entry and IP address
|
||||
</tp:docstring>
|
||||
</method>
|
||||
|
||||
<property name="Udi" type="s" access="read">
|
||||
<tp:docstring>
|
||||
HAL UDI for the device.
|
||||
|
|
|
@ -26,11 +26,12 @@ object. dbus-glib generates the same bound function names for D-Bus the methods
|
|||
<arg name="connection" type="o" direction="in"/>
|
||||
<arg name="device" type="o" direction="in"/>
|
||||
<arg name="specific_object" type="o" direction="in"/>
|
||||
<arg name="active_connection" type="o" direction="out"/>
|
||||
</method>
|
||||
|
||||
<method name="GetActiveConnections">
|
||||
<annotation name="org.freedesktop.DBus.GLib.CSymbol" value="impl_manager_get_active_connections"/>
|
||||
<arg name="connections" type="aa{sv}" direction="out"/>
|
||||
<method name="DeactivateConnection">
|
||||
<annotation name="org.freedesktop.DBus.GLib.CSymbol" value="impl_manager_deactivate_connection"/>
|
||||
<arg name="active_connection" type="o" direction="in"/>
|
||||
</method>
|
||||
|
||||
<method name="Sleep">
|
||||
|
@ -40,9 +41,10 @@ object. dbus-glib generates the same bound function names for D-Bus the methods
|
|||
|
||||
<property name="WirelessEnabled" type="b" access="readwrite"/>
|
||||
<property name="WirelessHardwareEnabled" type="b" access="read"/>
|
||||
<property name="ActiveConnections" type="ao" access="read"/>
|
||||
<property name="State" type="u" access="read"/>
|
||||
|
||||
<signal name="StateChange">
|
||||
<signal name="StateChanged">
|
||||
<arg name="state" type="u"/>
|
||||
</signal>
|
||||
|
||||
|
|
|
@ -47,6 +47,11 @@
|
|||
The path of a device-type-specific object this activation should use, for example a WiFi access point.
|
||||
</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"/>
|
||||
|
@ -57,15 +62,17 @@
|
|||
<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="GetActiveConnections">
|
||||
<annotation name="org.freedesktop.DBus.GLib.CSymbol" value="impl_manager_get_active_connections"/>
|
||||
<arg name="connections" type="aa{sv}" direction="out">
|
||||
<method name="DeactivateConnection">
|
||||
<tp:docstring>
|
||||
Deactivate an active connection.
|
||||
</tp:docstring>
|
||||
<annotation name="org.freedesktop.DBus.GLib.CSymbol" value="impl_manager_deactivate_connection"/>
|
||||
<arg name="active_connection" type="o" direction="in">
|
||||
<tp:docstring>
|
||||
List of active connections, each described by a property dictionary.
|
||||
The currently active connection to deactivate.
|
||||
</tp:docstring>
|
||||
</arg>
|
||||
</method>
|
||||
|
@ -94,6 +101,12 @@
|
|||
</tp:docstring>
|
||||
</property>
|
||||
|
||||
<property name="ActiveConnections" type="ao" access="read">
|
||||
<tp:docstring>
|
||||
List of active connection object paths.
|
||||
</tp:docstring>
|
||||
</property>
|
||||
|
||||
<property name="State" type="u" access="read" tp:type="NM_STATE">
|
||||
<tp:docstring>
|
||||
The overall state of the NetworkManager daemon.
|
||||
|
|
|
@ -150,19 +150,6 @@ nm_device_new (DBusGConnection *connection, const char *path)
|
|||
NULL);
|
||||
}
|
||||
|
||||
void
|
||||
nm_device_deactivate (NMDevice *device)
|
||||
{
|
||||
GError *err = NULL;
|
||||
|
||||
g_return_if_fail (NM_IS_DEVICE (device));
|
||||
|
||||
if (!org_freedesktop_NetworkManager_Device_deactivate (NM_DEVICE_GET_PRIVATE (device)->device_proxy, &err)) {
|
||||
g_warning ("Cannot deactivate device: %s", err->message);
|
||||
g_error_free (err);
|
||||
}
|
||||
}
|
||||
|
||||
char *
|
||||
nm_device_get_iface (NMDevice *device)
|
||||
{
|
||||
|
|
|
@ -34,8 +34,6 @@ GType nm_device_get_type (void);
|
|||
NMDevice *nm_device_new (DBusGConnection *connection,
|
||||
const char *path);
|
||||
|
||||
void nm_device_deactivate (NMDevice *device);
|
||||
|
||||
char *nm_device_get_iface (NMDevice *device);
|
||||
char *nm_device_get_udi (NMDevice *device);
|
||||
char *nm_device_get_driver (NMDevice *device);
|
||||
|
|
|
@ -86,6 +86,8 @@ nm-device-802-11-wireless-glue.h: $(top_srcdir)/introspection/nm-device-802-11-w
|
|||
nm-ip4-config-glue.h: $(top_srcdir)/introspection/nm-ip4-config.xml
|
||||
dbus-binding-tool --prefix=nm_ip4_config --mode=glib-server --output=nm-ip4-config-glue.h $(top_srcdir)/introspection/nm-ip4-config.xml
|
||||
|
||||
nm-active-connection-glue.h: $(top_srcdir)/introspection/nm-active-connection.xml
|
||||
dbus-binding-tool --prefix=nm_active_connection --mode=glib-server --output=nm-active-connection-glue.h $(top_srcdir)/introspection/nm-active-connection.xml
|
||||
|
||||
built_sources = \
|
||||
nm-access-point-glue.h \
|
||||
|
@ -94,6 +96,7 @@ built_sources = \
|
|||
nm-device-802-3-ethernet-glue.h \
|
||||
nm-device-802-11-wireless-glue.h \
|
||||
nm-ip4-config-glue.h \
|
||||
nm-active-connection-glue.h \
|
||||
$(NULL)
|
||||
|
||||
$(NetworkManager_OBJECTS): $(built_sources)
|
||||
|
|
|
@ -27,6 +27,10 @@
|
|||
#include "nm-utils.h"
|
||||
#include "nm-setting-wireless-security.h"
|
||||
#include "nm-setting-8021x.h"
|
||||
#include "nm-dbus-manager.h"
|
||||
#include "nm-device.h"
|
||||
#include "nm-properties-changed-signal.h"
|
||||
#include "nm-active-connection-glue.h"
|
||||
|
||||
#include "nm-manager.h" /* FIXME! */
|
||||
|
||||
|
@ -39,6 +43,7 @@ G_DEFINE_TYPE (NMActRequest, nm_act_request, G_TYPE_OBJECT)
|
|||
enum {
|
||||
CONNECTION_SECRETS_UPDATED,
|
||||
CONNECTION_SECRETS_FAILED,
|
||||
PROPERTIES_CHANGED,
|
||||
|
||||
LAST_SIGNAL
|
||||
};
|
||||
|
@ -49,9 +54,59 @@ static guint signals[LAST_SIGNAL] = { 0 };
|
|||
typedef struct {
|
||||
NMConnection *connection;
|
||||
char *specific_object;
|
||||
NMConnection *shared;
|
||||
NMDevice *device;
|
||||
gboolean user_requested;
|
||||
|
||||
char *ac_path;
|
||||
} NMActRequestPrivate;
|
||||
|
||||
enum {
|
||||
PROP_0,
|
||||
PROP_SERVICE_NAME,
|
||||
PROP_CONNECTION,
|
||||
PROP_SPECIFIC_OBJECT,
|
||||
PROP_SHARED_SERVICE_NAME,
|
||||
PROP_SHARED_CONNECTION,
|
||||
PROP_DEVICES,
|
||||
|
||||
LAST_PROP
|
||||
};
|
||||
|
||||
|
||||
NMActRequest *
|
||||
nm_act_request_new (NMConnection *connection,
|
||||
const char *specific_object,
|
||||
gboolean user_requested,
|
||||
gpointer *device)
|
||||
{
|
||||
GObject *object;
|
||||
NMActRequestPrivate *priv;
|
||||
DBusGConnection *g_connection;
|
||||
static guint32 counter = 0;
|
||||
|
||||
g_return_val_if_fail (NM_IS_CONNECTION (connection), NULL);
|
||||
g_return_val_if_fail (NM_DEVICE (device), NULL);
|
||||
|
||||
object = g_object_new (NM_TYPE_ACT_REQUEST, NULL);
|
||||
if (!object)
|
||||
return NULL;
|
||||
|
||||
priv = NM_ACT_REQUEST_GET_PRIVATE (object);
|
||||
|
||||
priv->connection = g_object_ref (connection);
|
||||
if (specific_object)
|
||||
priv->specific_object = g_strdup (specific_object);
|
||||
priv->device = NM_DEVICE (device);
|
||||
priv->user_requested = user_requested;
|
||||
|
||||
g_connection = nm_dbus_manager_get_connection (nm_dbus_manager_get ());
|
||||
priv->ac_path = g_strdup_printf (NM_DBUS_PATH "/ActiveConnection/%d", counter++);
|
||||
dbus_g_connection_register_g_object (g_connection, priv->ac_path, object);
|
||||
|
||||
return NM_ACT_REQUEST (object);
|
||||
}
|
||||
|
||||
static void
|
||||
nm_act_request_init (NMActRequest *req)
|
||||
{
|
||||
|
@ -79,6 +134,9 @@ dispose (GObject *object)
|
|||
CONNECTION_GET_SECRETS_CALL_TAG, NULL);
|
||||
g_object_unref (priv->connection);
|
||||
|
||||
if (priv->shared)
|
||||
g_object_unref (priv->shared);
|
||||
|
||||
out:
|
||||
G_OBJECT_CLASS (nm_act_request_parent_class)->dispose (object);
|
||||
}
|
||||
|
@ -89,10 +147,73 @@ finalize (GObject *object)
|
|||
NMActRequestPrivate *priv = NM_ACT_REQUEST_GET_PRIVATE (object);
|
||||
|
||||
g_free (priv->specific_object);
|
||||
g_free (priv->ac_path);
|
||||
|
||||
G_OBJECT_CLASS (nm_act_request_parent_class)->finalize (object);
|
||||
}
|
||||
|
||||
static void
|
||||
scope_to_value (NMConnection *connection, GValue *value)
|
||||
{
|
||||
if (!connection) {
|
||||
g_value_set_string (value, "");
|
||||
return;
|
||||
}
|
||||
|
||||
switch (nm_connection_get_scope (connection)) {
|
||||
case NM_CONNECTION_SCOPE_SYSTEM:
|
||||
g_value_set_string (value, NM_DBUS_SERVICE_SYSTEM_SETTINGS);
|
||||
break;
|
||||
case NM_CONNECTION_SCOPE_USER:
|
||||
g_value_set_string (value, NM_DBUS_SERVICE_USER_SETTINGS);
|
||||
break;
|
||||
default:
|
||||
g_warning ("%s: unknown connection scope!", __func__);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
get_property (GObject *object, guint prop_id,
|
||||
GValue *value, GParamSpec *pspec)
|
||||
{
|
||||
NMActRequestPrivate *priv = NM_ACT_REQUEST_GET_PRIVATE (object);
|
||||
GPtrArray *devices;
|
||||
|
||||
switch (prop_id) {
|
||||
case PROP_SERVICE_NAME:
|
||||
scope_to_value (priv->connection, value);
|
||||
break;
|
||||
case PROP_CONNECTION:
|
||||
g_value_set_boxed (value, nm_connection_get_path (priv->connection));
|
||||
break;
|
||||
case PROP_SPECIFIC_OBJECT:
|
||||
if (priv->specific_object)
|
||||
g_value_set_boxed (value, priv->specific_object);
|
||||
else
|
||||
g_value_set_boxed (value, "/");
|
||||
break;
|
||||
case PROP_SHARED_SERVICE_NAME:
|
||||
scope_to_value (priv->shared, value);
|
||||
break;
|
||||
case PROP_SHARED_CONNECTION:
|
||||
if (!priv->shared) {
|
||||
g_value_set_boxed (value, "/");
|
||||
break;
|
||||
}
|
||||
g_value_set_boxed (value, nm_connection_get_path (priv->shared));
|
||||
break;
|
||||
case PROP_DEVICES:
|
||||
devices = g_ptr_array_sized_new (1);
|
||||
g_ptr_array_add (devices, g_strdup (nm_device_get_udi (priv->device)));
|
||||
g_value_take_boxed (value, devices);
|
||||
break;
|
||||
default:
|
||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
nm_act_request_class_init (NMActRequestClass *req_class)
|
||||
{
|
||||
|
@ -100,9 +221,55 @@ nm_act_request_class_init (NMActRequestClass *req_class)
|
|||
|
||||
g_type_class_add_private (req_class, sizeof (NMActRequestPrivate));
|
||||
|
||||
/* virtual methods */
|
||||
object_class->get_property = get_property;
|
||||
object_class->dispose = dispose;
|
||||
object_class->finalize = finalize;
|
||||
|
||||
/* properties */
|
||||
g_object_class_install_property
|
||||
(object_class, PROP_SERVICE_NAME,
|
||||
g_param_spec_string (NM_ACTIVE_CONNECTION_SERVICE_NAME,
|
||||
"Service name",
|
||||
"Service name",
|
||||
NULL,
|
||||
G_PARAM_READABLE));
|
||||
g_object_class_install_property
|
||||
(object_class, PROP_CONNECTION,
|
||||
g_param_spec_boxed (NM_ACTIVE_CONNECTION_CONNECTION,
|
||||
"Connection",
|
||||
"Connection",
|
||||
DBUS_TYPE_G_OBJECT_PATH,
|
||||
G_PARAM_READABLE));
|
||||
g_object_class_install_property
|
||||
(object_class, PROP_SPECIFIC_OBJECT,
|
||||
g_param_spec_string (NM_ACTIVE_CONNECTION_SPECIFIC_OBJECT,
|
||||
"Specific object",
|
||||
"Specific object",
|
||||
NULL,
|
||||
G_PARAM_READABLE));
|
||||
g_object_class_install_property
|
||||
(object_class, PROP_SHARED_SERVICE_NAME,
|
||||
g_param_spec_string (NM_ACTIVE_CONNECTION_SHARED_SERVICE_NAME,
|
||||
"Shared service name",
|
||||
"Shared service name",
|
||||
NULL,
|
||||
G_PARAM_READABLE));
|
||||
g_object_class_install_property
|
||||
(object_class, PROP_SHARED_CONNECTION,
|
||||
g_param_spec_boxed (NM_ACTIVE_CONNECTION_SHARED_CONNECTION,
|
||||
"Shared connection",
|
||||
"Shared connection",
|
||||
DBUS_TYPE_G_OBJECT_PATH,
|
||||
G_PARAM_READABLE));
|
||||
g_object_class_install_property
|
||||
(object_class, PROP_DEVICES,
|
||||
g_param_spec_boxed (NM_ACTIVE_CONNECTION_DEVICES,
|
||||
"Devices",
|
||||
"Devices",
|
||||
dbus_g_type_get_collection ("GPtrArray", DBUS_TYPE_G_OBJECT_PATH),
|
||||
G_PARAM_READABLE));
|
||||
|
||||
/* Signals */
|
||||
signals[CONNECTION_SECRETS_UPDATED] =
|
||||
g_signal_new ("connection-secrets-updated",
|
||||
|
@ -123,30 +290,13 @@ nm_act_request_class_init (NMActRequestClass *req_class)
|
|||
nm_marshal_VOID__OBJECT_STRING,
|
||||
G_TYPE_NONE, 2,
|
||||
G_TYPE_OBJECT, G_TYPE_STRING);
|
||||
}
|
||||
|
||||
NMActRequest *
|
||||
nm_act_request_new (NMConnection *connection,
|
||||
const char *specific_object,
|
||||
gboolean user_requested)
|
||||
{
|
||||
GObject *obj;
|
||||
NMActRequestPrivate *priv;
|
||||
signals[PROPERTIES_CHANGED] =
|
||||
nm_properties_changed_signal_new (object_class,
|
||||
G_STRUCT_OFFSET (NMActRequestClass, properties_changed));
|
||||
|
||||
g_return_val_if_fail (NM_IS_CONNECTION (connection), NULL);
|
||||
|
||||
obj = g_object_new (NM_TYPE_ACT_REQUEST, NULL);
|
||||
if (!obj)
|
||||
return NULL;
|
||||
|
||||
priv = NM_ACT_REQUEST_GET_PRIVATE (obj);
|
||||
|
||||
priv->connection = g_object_ref (connection);
|
||||
priv->user_requested = user_requested;
|
||||
if (specific_object)
|
||||
priv->specific_object = g_strdup (specific_object);
|
||||
|
||||
return NM_ACT_REQUEST (obj);
|
||||
dbus_g_object_type_install_info (G_TYPE_FROM_CLASS (req_class),
|
||||
&dbus_glib_nm_active_connection_object_info);
|
||||
}
|
||||
|
||||
typedef struct GetSecretsInfo {
|
||||
|
@ -407,3 +557,12 @@ nm_act_request_get_user_requested (NMActRequest *req)
|
|||
|
||||
return NM_ACT_REQUEST_GET_PRIVATE (req)->user_requested;
|
||||
}
|
||||
|
||||
const char *
|
||||
nm_act_request_get_active_connection_path (NMActRequest *req)
|
||||
{
|
||||
g_return_val_if_fail (NM_IS_ACT_REQUEST (req), FALSE);
|
||||
|
||||
return NM_ACT_REQUEST_GET_PRIVATE (req)->ac_path;
|
||||
}
|
||||
|
||||
|
|
|
@ -33,6 +33,13 @@
|
|||
#define NM_IS_ACT_REQUEST_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((obj), NM_TYPE_ACT_REQUEST))
|
||||
#define NM_ACT_REQUEST_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), NM_TYPE_ACT_REQUEST, NMActRequestClass))
|
||||
|
||||
#define NM_ACTIVE_CONNECTION_SERVICE_NAME "service-name"
|
||||
#define NM_ACTIVE_CONNECTION_CONNECTION "connection"
|
||||
#define NM_ACTIVE_CONNECTION_SPECIFIC_OBJECT "specific-object"
|
||||
#define NM_ACTIVE_CONNECTION_SHARED_SERVICE_NAME "shared-service-name"
|
||||
#define NM_ACTIVE_CONNECTION_SHARED_CONNECTION "shared-connection"
|
||||
#define NM_ACTIVE_CONNECTION_DEVICES "devices"
|
||||
|
||||
typedef struct {
|
||||
GObject parent;
|
||||
} NMActRequest;
|
||||
|
@ -47,13 +54,16 @@ typedef struct {
|
|||
void (*connection_secrets_failed) (NMActRequest *req,
|
||||
NMConnection *connection,
|
||||
const char * setting);
|
||||
|
||||
void (*properties_changed) (NMActRequest *req, GHashTable *properties);
|
||||
} NMActRequestClass;
|
||||
|
||||
GType nm_act_request_get_type (void);
|
||||
|
||||
NMActRequest *nm_act_request_new (NMConnection *connection,
|
||||
const char *specific_object,
|
||||
gboolean user_requested);
|
||||
gboolean user_requested,
|
||||
gpointer *device); /* An NMDevice */
|
||||
|
||||
NMConnection *nm_act_request_get_connection (NMActRequest *req);
|
||||
gboolean nm_act_request_request_connection_secrets (NMActRequest *req,
|
||||
|
@ -66,4 +76,6 @@ void nm_act_request_set_specific_object (NMActRequest *req,
|
|||
|
||||
gboolean nm_act_request_get_user_requested (NMActRequest *req);
|
||||
|
||||
const char * nm_act_request_get_active_connection_path (NMActRequest *req);
|
||||
|
||||
#endif /* NM_ACTIVATION_REQUEST_H */
|
||||
|
|
|
@ -5,8 +5,6 @@
|
|||
#include "nm-ip4-config.h"
|
||||
#include "nm-utils.h"
|
||||
|
||||
static gboolean impl_device_deactivate (NMDeviceInterface *device, GError **err);
|
||||
|
||||
#include "nm-device-interface-glue.h"
|
||||
|
||||
GQuark
|
||||
|
@ -228,12 +226,3 @@ nm_device_interface_deactivate (NMDeviceInterface *device)
|
|||
NM_DEVICE_INTERFACE_GET_INTERFACE (device)->deactivate (device);
|
||||
}
|
||||
|
||||
static gboolean
|
||||
impl_device_deactivate (NMDeviceInterface *device, GError **err)
|
||||
{
|
||||
g_return_val_if_fail (NM_IS_DEVICE_INTERFACE (device), FALSE);
|
||||
|
||||
nm_device_interface_deactivate (device);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
|
234
src/nm-manager.c
234
src/nm-manager.c
|
@ -16,15 +16,15 @@
|
|||
|
||||
static gboolean impl_manager_get_devices (NMManager *manager, GPtrArray **devices, GError **err);
|
||||
static void impl_manager_activate_connection (NMManager *manager,
|
||||
char *service_name,
|
||||
char *connection_path,
|
||||
char *device_path,
|
||||
char *specific_object_path,
|
||||
const char *service_name,
|
||||
const char *connection_path,
|
||||
const char *device_path,
|
||||
const char *specific_object_path,
|
||||
DBusGMethodInvocation *context);
|
||||
|
||||
static gboolean impl_manager_get_active_connections (NMManager *manager,
|
||||
GPtrArray **connections,
|
||||
GError **err);
|
||||
static gboolean impl_manager_deactivate_connection (NMManager *manager,
|
||||
const char *connection_path,
|
||||
GError **error);
|
||||
|
||||
static gboolean impl_manager_sleep (NMManager *manager, gboolean sleep, GError **err);
|
||||
|
||||
|
@ -101,6 +101,7 @@ enum {
|
|||
PROP_STATE,
|
||||
PROP_WIRELESS_ENABLED,
|
||||
PROP_WIRELESS_HARDWARE_ENABLED,
|
||||
PROP_ACTIVE_CONNECTIONS,
|
||||
|
||||
LAST_PROP
|
||||
};
|
||||
|
@ -112,6 +113,7 @@ typedef enum
|
|||
NM_MANAGER_ERROR_INVALID_SERVICE,
|
||||
NM_MANAGER_ERROR_SYSTEM_CONNECTION,
|
||||
NM_MANAGER_ERROR_PERMISSION_DENIED,
|
||||
NM_MANAGER_ERROR_CONNECTION_NOT_ACTIVE,
|
||||
} NMManagerError;
|
||||
|
||||
#define NM_MANAGER_ERROR (nm_manager_error_quark ())
|
||||
|
@ -148,6 +150,8 @@ nm_manager_error_get_type (void)
|
|||
ENUM_ENTRY (NM_MANAGER_ERROR_SYSTEM_CONNECTION, "SystemConnection"),
|
||||
/* User does not have the permission to activate this connection. */
|
||||
ENUM_ENTRY (NM_MANAGER_ERROR_PERMISSION_DENIED, "PermissionDenied"),
|
||||
/* The connection was not active. */
|
||||
ENUM_ENTRY (NM_MANAGER_ERROR_CONNECTION_NOT_ACTIVE, "ConnectionNotActive"),
|
||||
{ 0, 0, 0 }
|
||||
};
|
||||
etype = g_enum_register_static ("NMManagerError", values);
|
||||
|
@ -303,6 +307,25 @@ get_property (GObject *object, guint prop_id,
|
|||
case PROP_WIRELESS_HARDWARE_ENABLED:
|
||||
g_value_set_boolean (value, priv->wireless_hw_enabled);
|
||||
break;
|
||||
case PROP_ACTIVE_CONNECTIONS: {
|
||||
GPtrArray *active;
|
||||
GSList *iter;
|
||||
|
||||
active = g_ptr_array_sized_new (2);
|
||||
for (iter = priv->devices; iter; iter = g_slist_next (iter)) {
|
||||
NMActRequest *req;
|
||||
const char *path;
|
||||
|
||||
req = nm_device_get_act_request (NM_DEVICE (iter->data));
|
||||
if (!req)
|
||||
continue;
|
||||
|
||||
path = nm_act_request_get_active_connection_path (req);
|
||||
g_ptr_array_add (active, g_strdup (path));
|
||||
}
|
||||
g_value_take_boxed (value, active);
|
||||
break;
|
||||
}
|
||||
default:
|
||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
||||
break;
|
||||
|
@ -348,6 +371,14 @@ nm_manager_class_init (NMManagerClass *manager_class)
|
|||
TRUE,
|
||||
G_PARAM_READWRITE));
|
||||
|
||||
g_object_class_install_property
|
||||
(object_class, PROP_ACTIVE_CONNECTIONS,
|
||||
g_param_spec_boxed (NM_MANAGER_ACTIVE_CONNECTIONS,
|
||||
"Active connections",
|
||||
"Active connections",
|
||||
dbus_g_type_get_collection ("GPtrArray", DBUS_TYPE_G_OBJECT_PATH),
|
||||
G_PARAM_READABLE));
|
||||
|
||||
/* signals */
|
||||
signals[DEVICE_ADDED] =
|
||||
g_signal_new ("device-added",
|
||||
|
@ -1255,7 +1286,7 @@ check_connection_allowed (NMManager *manager,
|
|||
return allowed;
|
||||
}
|
||||
|
||||
gboolean
|
||||
const char *
|
||||
nm_manager_activate_device (NMManager *manager,
|
||||
NMDevice *device,
|
||||
NMConnection *connection,
|
||||
|
@ -1267,24 +1298,24 @@ nm_manager_activate_device (NMManager *manager,
|
|||
NMDeviceInterface *dev_iface;
|
||||
gboolean success;
|
||||
|
||||
g_return_val_if_fail (NM_IS_MANAGER (manager), FALSE);
|
||||
g_return_val_if_fail (NM_IS_DEVICE (device), FALSE);
|
||||
g_return_val_if_fail (NM_IS_CONNECTION (connection), FALSE);
|
||||
g_return_val_if_fail (NM_IS_MANAGER (manager), NULL);
|
||||
g_return_val_if_fail (NM_IS_DEVICE (device), NULL);
|
||||
g_return_val_if_fail (NM_IS_CONNECTION (connection), NULL);
|
||||
|
||||
dev_iface = NM_DEVICE_INTERFACE (device);
|
||||
|
||||
/* Ensure the requested connection is allowed to be activated */
|
||||
if (!check_connection_allowed (manager, dev_iface, connection, specific_object, error))
|
||||
return FALSE;
|
||||
return NULL;
|
||||
|
||||
if (nm_device_get_act_request (device))
|
||||
nm_device_interface_deactivate (dev_iface);
|
||||
|
||||
req = nm_act_request_new (connection, specific_object, user_requested);
|
||||
req = nm_act_request_new (connection, specific_object, user_requested, (gpointer) device);
|
||||
success = nm_device_interface_activate (dev_iface, req, error);
|
||||
g_object_unref (req);
|
||||
|
||||
return success;
|
||||
return nm_act_request_get_active_connection_path (req);
|
||||
}
|
||||
|
||||
gboolean
|
||||
|
@ -1332,7 +1363,7 @@ connection_added_default_handler (NMManager *manager,
|
|||
{
|
||||
NMManagerPrivate *priv = NM_MANAGER_GET_PRIVATE (manager);
|
||||
PendingConnectionInfo *info = priv->pending_connection_info;
|
||||
gboolean success;
|
||||
const char *path;
|
||||
GError *error = NULL;
|
||||
|
||||
if (!info)
|
||||
|
@ -1347,14 +1378,14 @@ connection_added_default_handler (NMManager *manager,
|
|||
/* Will destroy below; can't be valid during the initial activation start */
|
||||
priv->pending_connection_info = NULL;
|
||||
|
||||
success = nm_manager_activate_device (manager,
|
||||
info->device,
|
||||
connection,
|
||||
info->specific_object_path,
|
||||
TRUE,
|
||||
&error);
|
||||
if (success)
|
||||
dbus_g_method_return (info->context, TRUE);
|
||||
path = nm_manager_activate_device (manager,
|
||||
info->device,
|
||||
connection,
|
||||
info->specific_object_path,
|
||||
TRUE,
|
||||
&error);
|
||||
if (path)
|
||||
dbus_g_method_return (info->context, path);
|
||||
else {
|
||||
dbus_g_method_return_error (info->context, error);
|
||||
nm_warning ("Failed to activate device %s: (%d) %s",
|
||||
|
@ -1369,10 +1400,10 @@ connection_added_default_handler (NMManager *manager,
|
|||
|
||||
static void
|
||||
impl_manager_activate_connection (NMManager *manager,
|
||||
char *service_name,
|
||||
char *connection_path,
|
||||
char *device_path,
|
||||
char *specific_object_path,
|
||||
const char *service_name,
|
||||
const char *connection_path,
|
||||
const char *device_path,
|
||||
const char *specific_object_path,
|
||||
DBusGMethodInvocation *context)
|
||||
{
|
||||
NMDevice *device;
|
||||
|
@ -1408,16 +1439,16 @@ impl_manager_activate_connection (NMManager *manager,
|
|||
|
||||
connection = nm_manager_get_connection_by_object_path (manager, scope, connection_path);
|
||||
if (connection) {
|
||||
gboolean success;
|
||||
const char *path;
|
||||
|
||||
success = nm_manager_activate_device (manager,
|
||||
device,
|
||||
connection,
|
||||
real_sop,
|
||||
TRUE,
|
||||
&error);
|
||||
if (success)
|
||||
dbus_g_method_return (context, TRUE);
|
||||
path = nm_manager_activate_device (manager,
|
||||
device,
|
||||
connection,
|
||||
real_sop,
|
||||
TRUE,
|
||||
&error);
|
||||
if (path)
|
||||
dbus_g_method_return (context, path);
|
||||
} else {
|
||||
PendingConnectionInfo *info;
|
||||
NMManagerPrivate *priv = NM_MANAGER_GET_PRIVATE (manager);
|
||||
|
@ -1456,130 +1487,33 @@ impl_manager_activate_connection (NMManager *manager,
|
|||
g_free (real_sop);
|
||||
}
|
||||
|
||||
static void
|
||||
destroy_gvalue (gpointer data)
|
||||
{
|
||||
GValue *value = (GValue *) data;
|
||||
|
||||
g_value_unset (value);
|
||||
g_slice_free (GValue, value);
|
||||
}
|
||||
|
||||
static GHashTable *
|
||||
add_one_connection_element (NMManager *manager,
|
||||
NMDevice *device)
|
||||
{
|
||||
GHashTable *properties;
|
||||
NMActRequest *req;
|
||||
const char *service_name = NULL;
|
||||
NMConnection *connection;
|
||||
const char *specific_object;
|
||||
GPtrArray *dev_array = NULL;
|
||||
GValue *value;
|
||||
|
||||
req = nm_device_get_act_request (device);
|
||||
g_assert (req);
|
||||
connection = nm_act_request_get_connection (req);
|
||||
g_assert (connection);
|
||||
|
||||
switch (nm_connection_get_scope (connection)) {
|
||||
case NM_CONNECTION_SCOPE_USER:
|
||||
service_name = NM_DBUS_SERVICE_USER_SETTINGS;
|
||||
break;
|
||||
case NM_CONNECTION_SCOPE_SYSTEM:
|
||||
service_name = NM_DBUS_SERVICE_SYSTEM_SETTINGS;
|
||||
break;
|
||||
default:
|
||||
g_assert_not_reached ();
|
||||
break;
|
||||
}
|
||||
|
||||
specific_object = nm_act_request_get_specific_object (req);
|
||||
|
||||
properties = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, destroy_gvalue);
|
||||
|
||||
/* Service name */
|
||||
value = g_slice_new0 (GValue);
|
||||
g_value_init (value, G_TYPE_STRING);
|
||||
g_value_set_string (value, service_name);
|
||||
g_hash_table_insert (properties, g_strdup (NM_AC_KEY_SERVICE_NAME), value);
|
||||
|
||||
/* Connection path */
|
||||
value = g_slice_new0 (GValue);
|
||||
g_value_init (value, DBUS_TYPE_G_OBJECT_PATH);
|
||||
g_value_set_boxed (value, nm_connection_get_path (connection));
|
||||
g_hash_table_insert (properties, g_strdup (NM_AC_KEY_CONNECTION), value);
|
||||
|
||||
/* Specific object */
|
||||
if (specific_object) {
|
||||
value = g_slice_new0 (GValue);
|
||||
g_value_init (value, DBUS_TYPE_G_OBJECT_PATH);
|
||||
g_value_set_boxed (value, specific_object);
|
||||
g_hash_table_insert (properties, g_strdup (NM_AC_KEY_SPECIFIC_OBJECT), value);
|
||||
}
|
||||
|
||||
if (FALSE /* SHARED */ ) {
|
||||
/* Shared connection service name */
|
||||
value = g_slice_new0 (GValue);
|
||||
g_value_init (value, G_TYPE_STRING);
|
||||
g_value_set_string (value, service_name);
|
||||
g_hash_table_insert (properties, g_strdup (NM_AC_KEY_SHARED_TO_SERVICE_NAME), value);
|
||||
|
||||
/* Shared connection connection path */
|
||||
value = g_slice_new0 (GValue);
|
||||
g_value_init (value, DBUS_TYPE_G_OBJECT_PATH);
|
||||
g_value_set_boxed (value, nm_connection_get_path (connection));
|
||||
g_hash_table_insert (properties, g_strdup (NM_AC_KEY_SHARED_TO_CONNECTION), value);
|
||||
}
|
||||
|
||||
/* Device list */
|
||||
dev_array = g_ptr_array_sized_new (1);
|
||||
if (!dev_array) {
|
||||
g_hash_table_destroy (properties);
|
||||
return NULL;
|
||||
}
|
||||
g_ptr_array_add (dev_array, g_object_ref (device));
|
||||
|
||||
value = g_slice_new0 (GValue);
|
||||
g_value_init (value, DBUS_TYPE_G_OBJECT_ARRAY);
|
||||
g_value_take_boxed (value, dev_array);
|
||||
g_hash_table_insert (properties, g_strdup (NM_AC_KEY_DEVICES), value);
|
||||
|
||||
return properties;
|
||||
}
|
||||
|
||||
static gboolean
|
||||
impl_manager_get_active_connections (NMManager *manager,
|
||||
GPtrArray **connections,
|
||||
GError **err)
|
||||
impl_manager_deactivate_connection (NMManager *manager,
|
||||
const char *connection_path,
|
||||
GError **error)
|
||||
{
|
||||
NMManagerPrivate *priv;
|
||||
NMManagerPrivate *priv = NM_MANAGER_GET_PRIVATE (manager);
|
||||
GSList *iter;
|
||||
|
||||
g_return_val_if_fail (NM_IS_MANAGER (manager), FALSE);
|
||||
|
||||
priv = NM_MANAGER_GET_PRIVATE (manager);
|
||||
|
||||
/* GPtrArray of GHashTables */
|
||||
*connections = g_ptr_array_sized_new (1);
|
||||
|
||||
// FIXME: this assumes one active device per connection
|
||||
for (iter = priv->devices; iter; iter = g_slist_next (iter)) {
|
||||
NMDevice *dev = NM_DEVICE (iter->data);
|
||||
GHashTable *item;
|
||||
NMDevice *device = NM_DEVICE (iter->data);
|
||||
NMActRequest *req;
|
||||
|
||||
if ( (nm_device_get_state (dev) != NM_DEVICE_STATE_ACTIVATED)
|
||||
&& !nm_device_is_activating (dev))
|
||||
req = nm_device_get_act_request (device);
|
||||
if (!req)
|
||||
continue;
|
||||
|
||||
item = add_one_connection_element (manager, dev);
|
||||
if (!item)
|
||||
continue;
|
||||
|
||||
g_ptr_array_add (*connections, item);
|
||||
if (!strcmp (connection_path, nm_act_request_get_active_connection_path (req))) {
|
||||
nm_device_interface_deactivate (NM_DEVICE_INTERFACE (device));
|
||||
return TRUE;
|
||||
}
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
g_set_error (error,
|
||||
NM_MANAGER_ERROR, NM_MANAGER_ERROR_CONNECTION_NOT_ACTIVE,
|
||||
"%s", "The connection was not active.");
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
gboolean
|
||||
|
|
|
@ -17,6 +17,7 @@
|
|||
#define NM_MANAGER_STATE "state"
|
||||
#define NM_MANAGER_WIRELESS_ENABLED "wireless-enabled"
|
||||
#define NM_MANAGER_WIRELESS_HARDWARE_ENABLED "wireless-hardware-enabled"
|
||||
#define NM_MANAGER_ACTIVE_CONNECTIONS "active-connections"
|
||||
|
||||
#define NM_MANAGER_CONNECTION_PROXY_TAG "dbus-proxy"
|
||||
#define NM_MANAGER_CONNECTION_SECRETS_PROXY_TAG "dbus-secrets-proxy"
|
||||
|
@ -63,7 +64,7 @@ NMDevice *nm_manager_get_device_by_udi (NMManager *manager, const char *udi);
|
|||
|
||||
NMDevice *nm_manager_get_active_device (NMManager *manager);
|
||||
|
||||
gboolean nm_manager_activate_device (NMManager *manager,
|
||||
const char *nm_manager_activate_device (NMManager *manager,
|
||||
NMDevice *device,
|
||||
NMConnection *connection,
|
||||
const char *specific_object,
|
||||
|
|
Loading…
Reference in a new issue