2007-09-09 Dan Williams <dcbw@redhat.com>
* introspection/nm-device.xml - The 'Activate' method now takes 3 arguments, a service name for the settings service (user or system), the object path of the connection to activate, and the specific object to activate, if any * src/nm-device-interface.c - (nm_device_interface_error_quark, nm_device_interface_error_get_type): Add error bits - (impl_device_activate): adapt to new Activate arguments; validate the service name and get the Connection object from the NMManager before starting to activate the device with the specified connection * src/nm-device-802-3-ethernet.c - (real_get_best_connection): find the best connection, or create a default one if no existing connections can be used * src/NetworkManagerPolicy.c - (nm_policy_auto_get_best_device): Get the device's best connection and only pick the device if it has one - (nm_policy_device_change_check): disable wireless bits for now until wireless get_best_connection() can be implemented (replacing "best_ap"); don't create a default connection here as the device subclass will do that if needed * src/nm-manager.h src/nm-manager.c - (nm_manager_get): make NMManager a singleton and expose the getter internally - Rework internal NMManager connection handling to use the same routines for both the system and user settings services. Most calls take a new NMConnectionType argument specifying either system or user connections - (nm_manager_get_connection_by_object_path): new function; get a connection keyed on its object path * src/NetworkManager.c - (main): use nm_manager_get() git-svn-id: http://svn-archive.gnome.org/svn/NetworkManager/trunk@2776 4912f4e0-d625-0410-9fb7-b9a5a253dbdc
This commit is contained in:
@@ -1,16 +1,46 @@
|
||||
|
||||
#include "nm-device-interface.h"
|
||||
#include "nm-ip4-config.h"
|
||||
#include "nm-manager.h"
|
||||
|
||||
static gboolean impl_device_activate (NMDeviceInterface *device,
|
||||
GHashTable *connection_hash,
|
||||
const char *specific_object,
|
||||
GError **err);
|
||||
const char *service_name,
|
||||
const char *connection_path,
|
||||
const char *specific_object,
|
||||
GError **err);
|
||||
|
||||
static gboolean impl_device_deactivate (NMDeviceInterface *device, GError **err);
|
||||
|
||||
#include "nm-device-interface-glue.h"
|
||||
|
||||
GQuark
|
||||
nm_device_interface_error_quark (void)
|
||||
{
|
||||
static GQuark quark = 0;
|
||||
if (!quark)
|
||||
quark = g_quark_from_static_string ("nm_device_interface_error");
|
||||
return quark;
|
||||
}
|
||||
|
||||
/* This should really be standard. */
|
||||
#define ENUM_ENTRY(NAME, DESC) { NAME, "" #NAME "", DESC }
|
||||
|
||||
GType
|
||||
nm_device_interface_error_get_type (void)
|
||||
{
|
||||
static GType etype = 0;
|
||||
|
||||
if (etype == 0) {
|
||||
static const GEnumValue values[] = {
|
||||
ENUM_ENTRY (NM_DEVICE_INTERFACE_ERROR_UNKNOWN_CONNECTION, "UnknownConnection"),
|
||||
{ 0, 0, 0 }
|
||||
};
|
||||
etype = g_enum_register_static ("NMDeviceInterfaceError", values);
|
||||
}
|
||||
return etype;
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
nm_device_interface_init (gpointer g_iface)
|
||||
{
|
||||
@@ -164,18 +194,41 @@ nm_device_interface_activate (NMDeviceInterface *device,
|
||||
|
||||
static gboolean
|
||||
impl_device_activate (NMDeviceInterface *device,
|
||||
GHashTable *connection_hash,
|
||||
const char *specific_object,
|
||||
GError **err)
|
||||
const char *service_name,
|
||||
const char *connection_path,
|
||||
const char *specific_object,
|
||||
GError **err)
|
||||
{
|
||||
NMManager *manager;
|
||||
NMConnection *connection;
|
||||
gboolean success = FALSE;
|
||||
|
||||
manager = nm_manager_get ();
|
||||
if (!strcmp (service_name, NM_DBUS_SERVICE_USER_SETTINGS)) {
|
||||
connection = nm_manager_get_connection_by_object_path (manager,
|
||||
NM_CONNECTION_TYPE_USER,
|
||||
connection_path);
|
||||
} else if (!strcmp (service_name, NM_DBUS_SERVICE_USER_SETTINGS)) {
|
||||
connection = nm_manager_get_connection_by_object_path (manager,
|
||||
NM_CONNECTION_TYPE_SYSTEM,
|
||||
connection_path);
|
||||
}
|
||||
|
||||
if (connection == NULL) {
|
||||
g_set_error (err,
|
||||
NM_DEVICE_INTERFACE_ERROR,
|
||||
NM_DEVICE_INTERFACE_ERROR_UNKNOWN_CONNECTION,
|
||||
"%s",
|
||||
"Connection object or service unknown");
|
||||
goto out;
|
||||
}
|
||||
|
||||
connection = nm_connection_new_from_hash (connection_hash);
|
||||
nm_connection_dump (connection);
|
||||
|
||||
nm_device_interface_activate (device, connection, specific_object, TRUE);
|
||||
success = TRUE;
|
||||
|
||||
return TRUE;
|
||||
out:
|
||||
return success;
|
||||
}
|
||||
|
||||
void
|
||||
|
Reference in New Issue
Block a user