Commit 215306f5 authored by Dan Williams's avatar Dan Williams

core: add AddAndActivate D-Bus method

Given connection details, complete the connection as well as possible
using the given specific object and device, add it to system
settings, and activate it all in one method.
parent bf98469b
......@@ -94,6 +94,7 @@ libnm-util/tests/test-setting-8021x
libnm-glib/tests/test-remote-settings-client
src/tests/test-dhcp-options
src/tests/test-policy-hosts
src/tests/test-wifi-ap-utils
system-settings/plugins/keyfile/tests/test-keyfile
system-settings/plugins/ifcfg-rh/tests/test-ifcfg-rh
......
......@@ -66,6 +66,55 @@
</tp:possible-errors>
</method>
<method name="AddAndActivateConnection">
<annotation name="org.freedesktop.DBus.GLib.CSymbol" value="impl_manager_add_and_activate_connection"/>
<annotation name="org.freedesktop.DBus.GLib.Async" value=""/>
<tp:docstring>
Adds a new connection using the given details (if any) as a template
(automatically filling in missing settings with the capabilities of the
given device and specific object), then activate the new connection.
Cannot be used for VPN connections at this time.
</tp:docstring>
<arg name="connection" type="a{sa{sv}}" direction="in">
<tp:docstring>
Connection settings and properties; if incomplete missing settings will
be automatically completed using the given device and specific object.
</tp:docstring>
</arg>
<arg name="device" type="o" direction="in">
<tp:docstring>
The object path of device to be activated using the given connection.
</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, which will be used to complete the details of the newly added
connection.
</tp:docstring>
</arg>
<arg name="path" type="o" direction="out">
<tp:docstring>
Object path of the new connection that was just added.
</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.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.
......
......@@ -35,7 +35,10 @@ INCLUDES = -I${top_srcdir} \
# Test libraries
###########################################
noinst_LTLIBRARIES = libtest-dhcp.la libtest-policy-hosts.la
noinst_LTLIBRARIES = \
libtest-dhcp.la \
libtest-policy-hosts.la \
libtest-wifi-ap-utils.la
###########################################
# DHCP test library
......@@ -76,6 +79,22 @@ libtest_policy_hosts_la_LIBADD = \
$(GLIB_LIBS)
###########################################
# Wifi ap utils
###########################################
libtest_wifi_ap_utils_la_SOURCES = \
nm-wifi-ap-utils.c \
nm-wifi-ap-utils.h
libtest_wifi_ap_utils_la_CPPFLAGS = \
$(GLIB_CFLAGS)
libtest_wifi_ap_utils_la_LIBADD = \
${top_builddir}/libnm-util/libnm-util.la \
$(GLIB_LIBS)
###########################################
# NetworkManager
###########################################
......@@ -106,6 +125,8 @@ NetworkManager_SOURCES = \
nm-device-gsm.h \
nm-wifi-ap.c \
nm-wifi-ap.h \
nm-wifi-ap-utils.c \
nm-wifi-ap-utils.h \
nm-dbus-manager.h \
nm-dbus-manager.c \
nm-udev-manager.c \
......
......@@ -15,19 +15,23 @@
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Copyright (C) 2009 - 2010 Red Hat, Inc.
* Copyright (C) 2009 - 2011 Red Hat, Inc.
* Copyright (C) 2009 Novell, Inc.
*/
#include <string.h>
#include <glib/gi18n.h>
#include "nm-dbus-glib-types.h"
#include "nm-modem-cdma.h"
#include "nm-modem-types.h"
#include "nm-device.h"
#include "nm-device-private.h"
#include "nm-dbus-manager.h"
#include "nm-setting-connection.h"
#include "nm-setting-cdma.h"
#include "nm-setting-serial.h"
#include "nm-setting-ppp.h"
#include "NetworkManagerUtils.h"
#include "nm-logging.h"
......@@ -269,6 +273,47 @@ real_check_connection_compatible (NMModem *modem,
return TRUE;
}
static gboolean
real_complete_connection (NMModem *modem,
NMConnection *connection,
const GSList *existing_connections,
GError **error)
{
NMSettingCdma *s_cdma;
NMSettingSerial *s_serial;
NMSettingPPP *s_ppp;
s_cdma = (NMSettingCdma *) nm_connection_get_setting (connection, NM_TYPE_SETTING_CDMA);
s_serial = (NMSettingSerial *) nm_connection_get_setting (connection, NM_TYPE_SETTING_SERIAL);
s_ppp = (NMSettingPPP *) nm_connection_get_setting (connection, NM_TYPE_SETTING_PPP);
if (!s_cdma) {
s_cdma = (NMSettingCdma *) nm_setting_cdma_new ();
nm_connection_add_setting (connection, NM_SETTING (s_cdma));
}
if (!nm_setting_cdma_get_number (s_cdma))
g_object_set (G_OBJECT (s_cdma), NM_SETTING_CDMA_NUMBER, "#777", NULL);
/* Need serial and PPP settings at least */
if (!s_serial) {
s_serial = (NMSettingSerial *) nm_setting_serial_new ();
nm_connection_add_setting (connection, NM_SETTING (s_serial));
}
if (!s_ppp) {
s_ppp = (NMSettingPPP *) nm_setting_ppp_new ();
nm_connection_add_setting (connection, NM_SETTING (s_ppp));
}
nm_device_complete_generic (connection,
NM_SETTING_CDMA_SETTING_NAME,
existing_connections,
_("CDMA connection %d"),
NULL);
return TRUE;
}
static gboolean
real_get_user_pass (NMModem *modem,
NMConnection *connection,
......@@ -344,6 +389,7 @@ nm_modem_cdma_class_init (NMModemCdmaClass *klass)
modem_class->get_setting_name = real_get_setting_name;
modem_class->get_best_auto_connection = real_get_best_auto_connection;
modem_class->check_connection_compatible = real_check_connection_compatible;
modem_class->complete_connection = real_complete_connection;
modem_class->act_stage1_prepare = real_act_stage1_prepare;
modem_class->deactivate_quickly = real_deactivate_quickly;
......
......@@ -15,16 +15,21 @@
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Copyright (C) 2009 - 2010 Red Hat, Inc.
* Copyright (C) 2009 - 2011 Red Hat, Inc.
* Copyright (C) 2009 Novell, Inc.
*/
#include <string.h>
#include <glib/gi18n.h>
#include "nm-dbus-glib-types.h"
#include "nm-modem-gsm.h"
#include "nm-device.h"
#include "nm-device-private.h"
#include "nm-setting-connection.h"
#include "nm-setting-gsm.h"
#include "nm-setting-serial.h"
#include "nm-setting-ppp.h"
#include "nm-modem-types.h"
#include "nm-logging.h"
#include "NetworkManagerUtils.h"
......@@ -467,6 +472,51 @@ real_check_connection_compatible (NMModem *modem,
return TRUE;
}
static gboolean
real_complete_connection (NMModem *modem,
NMConnection *connection,
const GSList *existing_connections,
GError **error)
{
NMSettingGsm *s_gsm;
NMSettingSerial *s_serial;
NMSettingPPP *s_ppp;
s_gsm = (NMSettingGsm *) nm_connection_get_setting (connection, NM_TYPE_SETTING_GSM);
s_serial = (NMSettingSerial *) nm_connection_get_setting (connection, NM_TYPE_SETTING_SERIAL);
s_ppp = (NMSettingPPP *) nm_connection_get_setting (connection, NM_TYPE_SETTING_PPP);
if (!s_gsm || !nm_setting_gsm_get_apn (s_gsm)) {
/* Need an APN at least */
g_set_error_literal (error,
NM_SETTING_GSM_ERROR,
NM_SETTING_GSM_ERROR_MISSING_PROPERTY,
NM_SETTING_GSM_APN);
return FALSE;
}
if (!nm_setting_gsm_get_number (s_gsm))
g_object_set (G_OBJECT (s_gsm), NM_SETTING_GSM_NUMBER, "*99#", NULL);
/* Need serial and PPP settings at least */
if (!s_serial) {
s_serial = (NMSettingSerial *) nm_setting_serial_new ();
nm_connection_add_setting (connection, NM_SETTING (s_serial));
}
if (!s_ppp) {
s_ppp = (NMSettingPPP *) nm_setting_ppp_new ();
nm_connection_add_setting (connection, NM_SETTING (s_ppp));
}
nm_device_complete_generic (connection,
NM_SETTING_GSM_SETTING_NAME,
existing_connections,
_("GSM connection %d"),
NULL);
return TRUE;
}
static gboolean
real_get_user_pass (NMModem *modem,
NMConnection *connection,
......@@ -545,6 +595,7 @@ nm_modem_gsm_class_init (NMModemGsmClass *klass)
modem_class->get_setting_name = real_get_setting_name;
modem_class->get_best_auto_connection = real_get_best_auto_connection;
modem_class->check_connection_compatible = real_check_connection_compatible;
modem_class->complete_connection = real_complete_connection;
modem_class->act_stage1_prepare = real_act_stage1_prepare;
modem_class->deactivate_quickly = real_deactivate_quickly;
......
......@@ -619,6 +619,17 @@ nm_modem_check_connection_compatible (NMModem *self,
return FALSE;
}
gboolean
nm_modem_complete_connection (NMModem *self,
NMConnection *connection,
const GSList *existing_connections,
GError **error)
{
if (NM_MODEM_GET_CLASS (self)->complete_connection)
return NM_MODEM_GET_CLASS (self)->complete_connection (self, connection, existing_connections, error);
return FALSE;
}
static void
real_deactivate_quickly (NMModem *self, NMDevice *device)
{
......
......@@ -67,6 +67,11 @@ typedef struct {
NMConnection *connection,
GError **error);
gboolean (*complete_connection) (NMModem *modem,
NMConnection *connection,
const GSList *existing_connections,
GError **error);
NMConnection * (*get_best_auto_connection) (NMModem *modem,
GSList *connections,
char **specific_object);
......@@ -107,6 +112,11 @@ gboolean nm_modem_check_connection_compatible (NMModem *self,
NMConnection *connection,
GError **error);
gboolean nm_modem_complete_connection (NMModem *self,
NMConnection *connection,
const GSList *existing_connections,
GError **error);
NMActStageReturn nm_modem_act_stage1_prepare (NMModem *modem,
NMActRequest *req,
NMDeviceStateReason *reason);
......
......@@ -15,12 +15,15 @@
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Copyright (C) 2009 - 2010 Red Hat, Inc.
* Copyright (C) 2009 - 2011 Red Hat, Inc.
*/
#include <stdio.h>
#include <string.h>
#include <net/ethernet.h>
#include <netinet/ether.h>
#include <glib/gi18n.h>
#include "nm-glib-compat.h"
#include "nm-bluez-common.h"
......@@ -36,6 +39,8 @@
#include "nm-setting-bluetooth.h"
#include "nm-setting-cdma.h"
#include "nm-setting-gsm.h"
#include "nm-setting-serial.h"
#include "nm-setting-ppp.h"
#include "nm-device-bt-glue.h"
#include "NetworkManagerUtils.h"
......@@ -250,6 +255,156 @@ real_check_connection_compatible (NMDevice *device,
return addr_match;
}
static gboolean
real_complete_connection (NMDevice *device,
NMConnection *connection,
const char *specific_object,
const GSList *existing_connections,
GError **error)
{
NMDeviceBtPrivate *priv = NM_DEVICE_BT_GET_PRIVATE (device);
NMSettingBluetooth *s_bt;
const GByteArray *setting_bdaddr;
struct ether_addr *devaddr = ether_aton (priv->bdaddr);
const char *ctype;
gboolean is_dun = FALSE, is_pan = FALSE;
NMSettingGsm *s_gsm;
NMSettingCdma *s_cdma;
NMSettingSerial *s_serial;
NMSettingPPP *s_ppp;
const char *format = NULL, *preferred = NULL;
s_gsm = (NMSettingGsm *) nm_connection_get_setting (connection, NM_TYPE_SETTING_GSM);
s_cdma = (NMSettingCdma *) nm_connection_get_setting (connection, NM_TYPE_SETTING_CDMA);
s_serial = (NMSettingSerial *) nm_connection_get_setting (connection, NM_TYPE_SETTING_SERIAL);
s_ppp = (NMSettingPPP *) nm_connection_get_setting (connection, NM_TYPE_SETTING_PPP);
s_bt = (NMSettingBluetooth *) nm_connection_get_setting (connection, NM_TYPE_SETTING_BLUETOOTH);
if (!s_bt) {
s_bt = (NMSettingBluetooth *) nm_setting_bluetooth_new ();
nm_connection_add_setting (connection, NM_SETTING (s_bt));
}
ctype = nm_setting_bluetooth_get_connection_type (s_bt);
if (ctype) {
if (!strcmp (ctype, NM_SETTING_BLUETOOTH_TYPE_DUN))
is_dun = TRUE;
else if (!strcmp (ctype, NM_SETTING_BLUETOOTH_TYPE_PANU))
is_pan = TRUE;
} else {
if (s_gsm || s_cdma)
is_dun = TRUE;
else if (priv->capabilities & NM_BT_CAPABILITY_NAP)
is_pan = TRUE;
}
if (is_pan) {
/* Make sure the device supports PAN */
if (!(priv->capabilities & NM_BT_CAPABILITY_NAP)) {
g_set_error_literal (error,
NM_SETTING_BLUETOOTH_ERROR,
NM_SETTING_BLUETOOTH_ERROR_INVALID_PROPERTY,
"PAN required but Bluetooth device does not support NAP");
return FALSE;
}
/* PAN can't use any DUN-related settings */
if (s_gsm || s_cdma || s_serial) {
g_set_error_literal (error,
NM_SETTING_BLUETOOTH_ERROR,
NM_SETTING_BLUETOOTH_ERROR_INVALID_PROPERTY,
"PAN incompatible with GSM, CDMA, or serial settings");
return FALSE;
}
g_object_set (G_OBJECT (s_bt),
NM_SETTING_BLUETOOTH_TYPE, NM_SETTING_BLUETOOTH_TYPE_PANU,
NULL);
format = _("PAN connection %d");
} else if (is_dun) {
/* Make sure the device supports PAN */
if (!(priv->capabilities & NM_BT_CAPABILITY_DUN)) {
g_set_error_literal (error,
NM_SETTING_BLUETOOTH_ERROR,
NM_SETTING_BLUETOOTH_ERROR_INVALID_PROPERTY,
"DUN required but Bluetooth device does not support DUN");
return FALSE;
}
/* Need at least a GSM or a CDMA setting */
if (!s_gsm && !s_cdma) {
g_set_error_literal (error,
NM_SETTING_BLUETOOTH_ERROR,
NM_SETTING_BLUETOOTH_ERROR_INVALID_PROPERTY,
"Setting requires DUN but no GSM or CDMA setting is present");
return FALSE;
}
g_object_set (G_OBJECT (s_bt),
NM_SETTING_BLUETOOTH_TYPE, NM_SETTING_BLUETOOTH_TYPE_DUN,
NULL);
if (s_gsm) {
format = _("GSM connection %d");
if (!nm_setting_gsm_get_number (s_gsm))
g_object_set (G_OBJECT (s_gsm), NM_SETTING_GSM_NUMBER, "*99#", NULL);
} else if (s_cdma) {
format = _("CDMA connection %d");
if (!nm_setting_cdma_get_number (s_cdma))
g_object_set (G_OBJECT (s_cdma), NM_SETTING_GSM_NUMBER, "#777", NULL);
} else
format = _("DUN connection %d");
/* Need serial and PPP settings */
if (!s_serial) {
s_serial = (NMSettingSerial *) nm_setting_serial_new ();
nm_connection_add_setting (connection, NM_SETTING (s_serial));
}
if (!s_ppp) {
s_ppp = (NMSettingPPP *) nm_setting_ppp_new ();
nm_connection_add_setting (connection, NM_SETTING (s_ppp));
}
} else {
g_set_error_literal (error,
NM_SETTING_BLUETOOTH_ERROR,
NM_SETTING_BLUETOOTH_ERROR_INVALID_PROPERTY,
"Unknown/unhandled Bluetooth connection type");
return FALSE;
}
nm_device_complete_generic (connection,
NM_SETTING_BLUETOOTH_SETTING_NAME,
existing_connections,
format,
preferred);
setting_bdaddr = nm_setting_bluetooth_get_bdaddr (s_bt);
if (setting_bdaddr) {
/* Make sure the setting BT Address (if any) matches the device's */
if (memcmp (setting_bdaddr->data, devaddr->ether_addr_octet, ETH_ALEN)) {
g_set_error_literal (error,
NM_SETTING_BLUETOOTH_ERROR,
NM_SETTING_BLUETOOTH_ERROR_INVALID_PROPERTY,
NM_SETTING_BLUETOOTH_BDADDR);
return FALSE;
}
} else {
GByteArray *bdaddr;
const guint8 null_mac[ETH_ALEN] = { 0, 0, 0, 0, 0, 0 };
/* Lock the connection to this device by default */
if (memcmp (devaddr->ether_addr_octet, null_mac, ETH_ALEN)) {
bdaddr = g_byte_array_sized_new (ETH_ALEN);
g_byte_array_append (bdaddr, devaddr->ether_addr_octet, ETH_ALEN);
g_object_set (G_OBJECT (s_bt), NM_SETTING_BLUETOOTH_BDADDR, bdaddr, NULL);
g_byte_array_free (bdaddr, TRUE);
}
}
return TRUE;
}
static guint32
real_get_generic_capabilities (NMDevice *dev)
{
......@@ -1000,6 +1155,7 @@ nm_device_bt_class_init (NMDeviceBtClass *klass)
device_class->act_stage3_ip4_config_start = real_act_stage3_ip4_config_start;
device_class->act_stage4_get_ip4_config = real_act_stage4_get_ip4_config;
device_class->check_connection_compatible = real_check_connection_compatible;
device_class->complete_connection = real_complete_connection;
/* Properties */
g_object_class_install_property
......
......@@ -15,7 +15,7 @@
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Copyright (C) 2005 - 2010 Red Hat, Inc.
* Copyright (C) 2005 - 2011 Red Hat, Inc.
* Copyright (C) 2006 - 2008 Novell, Inc.
*/
......@@ -1624,6 +1624,67 @@ real_check_connection_compatible (NMDevice *device,
return TRUE;
}
static gboolean
real_complete_connection (NMDevice *device,
NMConnection *connection,
const char *specific_object,
const GSList *existing_connections,
GError **error)
{
NMDeviceEthernetPrivate *priv = NM_DEVICE_ETHERNET_GET_PRIVATE (device);
NMSettingWired *s_wired;
NMSettingPPPOE *s_pppoe;
const GByteArray *setting_mac;
s_pppoe = (NMSettingPPPOE *) nm_connection_get_setting (connection, NM_TYPE_SETTING_PPPOE);
/* We can't telepathically figure out the service name or username, so if
* those weren't given, we can't complete the connection.
*/
if (s_pppoe && !nm_setting_verify (NM_SETTING (s_pppoe), NULL, error))
return FALSE;
/* Default to an ethernet-only connection, but if a PPPoE setting was given
* then PPPoE should be our connection type.
*/
nm_device_complete_generic (connection,
s_pppoe ? NM_SETTING_PPPOE_SETTING_NAME : NM_SETTING_CONNECTION_SETTING_NAME,
existing_connections,
s_pppoe ? _("PPPoE connection %d") : _("Wired connection %d"),
NULL);
s_wired = (NMSettingWired *) nm_connection_get_setting (connection, NM_TYPE_SETTING_WIRED);
if (!s_wired) {
s_wired = (NMSettingWired *) nm_setting_wired_new ();
nm_connection_add_setting (connection, NM_SETTING (s_wired));
}
setting_mac = nm_setting_wired_get_mac_address (s_wired);
if (setting_mac) {
/* Make sure the setting MAC (if any) matches the device's permanent MAC */
if (memcmp (setting_mac->data, priv->perm_hw_addr, ETH_ALEN)) {
g_set_error_literal (error,
NM_SETTING_WIRED_ERROR,
NM_SETTING_WIRED_ERROR_INVALID_PROPERTY,
NM_SETTING_WIRED_MAC_ADDRESS);
return FALSE;
}
} else {
GByteArray *mac;
const guint8 null_mac[ETH_ALEN] = { 0, 0, 0, 0, 0, 0 };
/* Lock the connection to this device by default */
if (memcmp (priv->perm_hw_addr, null_mac, ETH_ALEN)) {
mac = g_byte_array_sized_new (ETH_ALEN);
g_byte_array_append (mac, priv->perm_hw_addr, ETH_ALEN);
g_object_set (G_OBJECT (s_wired), NM_SETTING_WIRED_MAC_ADDRESS, mac, NULL);
g_byte_array_free (mac, TRUE);
}
}
return TRUE;
}
static gboolean
spec_match_list (NMDevice *device, const GSList *specs)
{
......@@ -1933,6 +1994,7 @@ nm_device_ethernet_class_init (NMDeviceEthernetClass *klass)
parent_class->get_best_auto_connection = real_get_best_auto_connection;
parent_class->is_available = real_is_available;
parent_class->check_connection_compatible = real_check_connection_compatible;
parent_class->complete_connection = real_complete_connection;
parent_class->act_stage1_prepare = real_act_stage1_prepare;
parent_class->act_stage2_config = real_act_stage2_config;
......
......@@ -220,6 +220,18 @@ real_check_connection_compatible (NMDevice *device,
return nm_modem_check_connection_compatible (priv->modem, connection, error);
}
static gboolean
real_complete_connection (NMDevice *device,
NMConnection *connection,
const char *specific_object,
const GSList *existing_connections,
GError **error)
{
NMDeviceModemPrivate *priv = NM_DEVICE_MODEM_GET_PRIVATE (device);
return nm_modem_complete_connection (priv->modem, connection, existing_connections, error);
}
static gboolean
real_hw_is_up (NMDevice *device)
{
......@@ -401,6 +413,7 @@ nm_device_modem_class_init (NMDeviceModemClass *mclass)
device_class->get_generic_capabilities = real_get_generic_capabilities;
device_class->get_best_auto_connection = real_get_best_auto_connection;
device_class->check_connection_compatible = real_check_connection_compatible;
device_class->complete_connection = real_complete_connection;
device_class->hw_is_up = real_hw_is_up;
device_class->hw_bring_up = real_hw_bring_up;
device_class->deactivate_quickly = real_deactivate_quickly;
......
......@@ -15,7 +15,7 @@
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Copyright (C) 2010 Red Hat, Inc.
* Copyright (C) 2011 Red Hat, Inc.
*/
#ifndef NM_DEVICE_MODEM_H
......
......@@ -19,7 +19,7 @@
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*
* (C) Copyright 2005 - 2010 Red Hat, Inc.
* (C) Copyright 2005 - 2011 Red Hat, Inc.
* (C) Copyright 2008 Collabora Ltd.
* (C) Copyright 2009 One Laptop per Child
*/
......@@ -381,6 +381,50 @@ real_check_connection_compatible (NMDevice *device,
return TRUE;
}
#define DEFAULT_SSID "olpc-mesh"
static gboolean
real_complete_connection (NMDevice *device,
NMConnection *connection,
const char *specific_object,
const GSList *existing_connections,
GError **error)
{
NMSettingOlpcMesh *s_mesh;
GByteArray *tmp;
s_mesh = (NMSettingOlpcMesh *) nm_connection_get_setting (connection, NM_TYPE_SETTING_OLPC_MESH);
if (!s_mesh) {
s_mesh = (NMSettingOlpcMesh *) nm_setting_olpc_mesh_new ();
nm_connection_add_setting (connection, NM_SETTING (s_mesh));
}
if (!nm_setting_olpc_mesh_get_ssid (s_mesh)) {
tmp = g_byte_array_sized_new (strlen (DEFAULT_SSID));
g_byte_array_append (tmp, (const guint8 *) DEFAULT_SSID, strlen (DEFAULT_SSID));
g_object_set (G_OBJECT (s_mesh), NM_SETTING_OLPC_MESH_SSID, tmp, NULL);
g_byte_array_free (tmp, TRUE);
}
if (!nm_setting_olpc_mesh_get_dhcp_anycast_address (s_mesh)) {
const guint8 anycast[ETH_ALEN] = { 0xC0, 0x27, 0xC0, 0x27, 0xC0, 0x27 };
tmp = g_byte_array_sized_new (ETH_ALEN);
g_byte_array_append (tmp, anycast, sizeof (anycast));
g_object_set (G_OBJECT (s_mesh), NM_SETTING_OLPC_MESH_DHCP_ANYCAST_ADDRESS, tmp, NULL);
g_byte_array_free (tmp, TRUE);
}
nm_device_complete_generic (connection,
NM_SETTING_OLPC_MESH_SETTING_NAME,
existing_connections,
_("Mesh %d"),
NULL);
return TRUE;
}
/*
* nm_device_olpc_mesh_get_address
*
......@@ -722,6 +766,7 @@ nm_device_olpc_mesh_class_init (NMDeviceOlpcMeshClass *klass)
parent_class->take_down = real_take_down;
parent_class->update_hw_address = real_update_hw_address;
parent_class->check_connection_compatible = real_check_connection_compatible;
parent_class->complete_connection = real_complete_connection;
parent_class->act_stage1_prepare = real_act_stage1_prepare;
parent_class->act_stage2_config = real_act_stage2_config;
......
......@@ -16,7 +16,7 @@
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Copyright (C) 2007 - 2008 Novell, Inc.
* Copyright (C) 2007 - 2008 Red Hat, Inc.
* Copyright (C) 2007 - 2011 Red Hat, Inc.
*/
#ifndef NM_DEVICE_PRIVATE_H
......@@ -46,4 +46,10 @@ gboolean nm_device_get_firmware_missing (NMDevice *self);
void nm_device_set_firmware_missing (NMDevice *self, gboolean missing);
void nm_device_complete_generic (NMConnection *connection,
const char *ctype,
const GSList *existing,
const char *format,
const char *preferred);
#endif /* NM_DEVICE_PRIVATE_H */
......@@ -15,7 +15,7 @@
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Copyright (C) 2005 - 2010 Red Hat, Inc.
* Copyright (C) 2005 - 2011 Red Hat, Inc.
* Copyright (C) 2006 - 2008 Novell, Inc.
*/
......@@ -104,15 +104,6 @@ enum {
static guint signals[LAST_SIGNAL] = { 0 };
typedef enum {
NM_WIFI_ERROR_CONNECTION_NOT_WIRELESS = 0,
NM_WIFI_ERROR_CONNECTION_INVALID,
NM_WIFI_ERROR_CONNECTION_INCOMPATIBLE,
} NMWifiError;
#define NM_WIFI_ERROR (nm_wifi_error_quark ())
#define NM_TYPE_WIFI_ERROR (nm_wifi_error_get_type ())
#define SUP_SIG_ID_LEN 5
typedef struct Supplicant {
......@@ -208,6 +199,18 @@ static guint32 nm_device_wifi_get_bitrate (NMDeviceWifi *self);