core: don't require serial and PPP settings for mobile broadband

If they are there, use them.  If not, make them up on the fly.
This commit is contained in:
Dan Williams 2011-02-25 11:24:20 -06:00
parent bf34e7099d
commit 125540471b
8 changed files with 9 additions and 143 deletions

View file

@ -23,7 +23,6 @@
#include <string.h>
#include "nm-setting-cdma.h"
#include "nm-setting-serial.h"
#include "nm-utils.h"
#include "nm-setting-private.h"
@ -70,7 +69,7 @@ nm_setting_cdma_error_get_type (void)
ENUM_ENTRY (NM_SETTING_CDMA_ERROR_INVALID_PROPERTY, "InvalidProperty"),
/* The specified property was missing and is required. */
ENUM_ENTRY (NM_SETTING_CDMA_ERROR_MISSING_PROPERTY, "MissingProperty"),
/* The required serial setting is missing */
/* The required serial setting is missing (DEPRECATED) */
ENUM_ENTRY (NM_SETTING_CDMA_ERROR_MISSING_SERIAL_SETTING, "MissingSerialSetting"),
{ 0, 0, 0 }
};
@ -170,30 +169,11 @@ nm_setting_cdma_get_password_flags (NMSettingCdma *setting)
return NM_SETTING_CDMA_GET_PRIVATE (setting)->password_flags;
}
static gint
find_setting_by_name (gconstpointer a, gconstpointer b)
{
NMSetting *setting = NM_SETTING (a);
const char *str = (const char *) b;
return strcmp (nm_setting_get_name (setting), str);
}
static gboolean
verify (NMSetting *setting, GSList *all_settings, GError **error)
{
NMSettingCdmaPrivate *priv = NM_SETTING_CDMA_GET_PRIVATE (setting);
/* Serial connections require a PPP setting */
if (all_settings &&
!g_slist_find_custom (all_settings, NM_SETTING_SERIAL_SETTING_NAME, find_setting_by_name)) {
g_set_error (error,
NM_SETTING_CDMA_ERROR,
NM_SETTING_CDMA_ERROR_MISSING_SERIAL_SETTING,
NULL);
return FALSE;
}
if (!priv->number) {
g_set_error (error,
NM_SETTING_CDMA_ERROR,

View file

@ -26,7 +26,6 @@
#include <string.h>
#include <ctype.h>
#include "nm-setting-gsm.h"
#include "nm-setting-serial.h"
#include "nm-utils.h"
#include "nm-setting-private.h"
@ -56,7 +55,7 @@ nm_setting_gsm_error_get_type (void)
ENUM_ENTRY (NM_SETTING_GSM_ERROR_INVALID_PROPERTY, "InvalidProperty"),
/* The specified property was missing and is required. */
ENUM_ENTRY (NM_SETTING_GSM_ERROR_MISSING_PROPERTY, "MissingProperty"),
/* The required serial setting is missing */
/* The required serial setting is missing (DEPRECATED) */
ENUM_ENTRY (NM_SETTING_GSM_ERROR_MISSING_SERIAL_SETTING, "MissingSerialSetting"),
{ 0, 0, 0 }
};
@ -110,15 +109,6 @@ nm_setting_gsm_new (void)
return (NMSetting *) g_object_new (NM_TYPE_SETTING_GSM, NULL);
}
static gint
find_setting_by_name (gconstpointer a, gconstpointer b)
{
NMSetting *setting = NM_SETTING (a);
const char *str = (const char *) b;
return strcmp (nm_setting_get_name (setting), str);
}
const char *
nm_setting_gsm_get_number (NMSettingGsm *setting)
{
@ -224,16 +214,6 @@ verify (NMSetting *setting, GSList *all_settings, GError **error)
{
NMSettingGsmPrivate *priv = NM_SETTING_GSM_GET_PRIVATE (setting);
/* Serial connections require a PPP setting */
if (all_settings &&
!g_slist_find_custom (all_settings, NM_SETTING_SERIAL_SETTING_NAME, find_setting_by_name)) {
g_set_error (error,
NM_SETTING_GSM_ERROR,
NM_SETTING_GSM_ERROR_MISSING_SERIAL_SETTING,
NULL);
return FALSE;
}
if (!priv->number) {
g_set_error (error,
NM_SETTING_GSM_ERROR,

View file

@ -19,14 +19,13 @@
* Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
* Boston, MA 02110-1301 USA.
*
* (C) Copyright 2007 - 2008 Red Hat, Inc.
* (C) Copyright 2007 - 2011 Red Hat, Inc.
* (C) Copyright 2007 - 2008 Novell, Inc.
*/
#include <string.h>
#include "nm-setting-serial.h"
#include "nm-setting-ppp.h"
GQuark
nm_setting_serial_error_quark (void)
@ -54,7 +53,7 @@ nm_setting_serial_error_get_type (void)
ENUM_ENTRY (NM_SETTING_SERIAL_ERROR_INVALID_PROPERTY, "InvalidProperty"),
/* The specified property was missing and is required. */
ENUM_ENTRY (NM_SETTING_SERIAL_ERROR_MISSING_PROPERTY, "MissingProperty"),
/* The required PPP setting is missing */
/* The required PPP setting is missing (DEPRECATED) */
ENUM_ENTRY (NM_SETTING_SERIAL_ERROR_MISSING_PPP_SETTING, "MissingPPPSetting"),
{ 0, 0, 0 }
};
@ -134,28 +133,9 @@ nm_setting_serial_get_send_delay (NMSettingSerial *setting)
return NM_SETTING_SERIAL_GET_PRIVATE (setting)->send_delay;
}
static gint
find_setting_by_name (gconstpointer a, gconstpointer b)
{
NMSetting *setting = NM_SETTING (a);
const char *str = (const char *) b;
return strcmp (nm_setting_get_name (setting), str);
}
static gboolean
verify (NMSetting *setting, GSList *all_settings, GError **error)
{
/* Serial connections require a PPP setting */
if (all_settings &&
!g_slist_find_custom (all_settings, NM_SETTING_PPP_SETTING_NAME, find_setting_by_name)) {
g_set_error_literal (error,
NM_SETTING_SERIAL_ERROR,
NM_SETTING_SERIAL_ERROR_MISSING_PPP_SETTING,
"Missing required PPP setting");
return FALSE;
}
return TRUE;
}

View file

@ -30,8 +30,6 @@
#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"
@ -280,13 +278,8 @@ real_complete_connection (NMModem *modem,
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));
@ -295,16 +288,6 @@ real_complete_connection (NMModem *modem,
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_utils_complete_generic (connection,
NM_SETTING_CDMA_SETTING_NAME,
existing_connections,

View file

@ -28,8 +28,6 @@
#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"
@ -479,13 +477,8 @@ real_complete_connection (NMModem *modem,
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,
@ -498,16 +491,6 @@ real_complete_connection (NMModem *modem,
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_utils_complete_generic (connection,
NM_SETTING_GSM_SETTING_NAME,
existing_connections,

View file

@ -309,7 +309,7 @@ real_complete_connection (NMDevice *device,
}
/* PAN can't use any DUN-related settings */
if (s_gsm || s_cdma || s_serial) {
if (s_gsm || s_cdma || s_serial || s_ppp) {
g_set_error_literal (error,
NM_SETTING_BLUETOOTH_ERROR,
NM_SETTING_BLUETOOTH_ERROR_INVALID_PROPERTY,
@ -355,16 +355,6 @@ real_complete_connection (NMDevice *device,
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,

View file

@ -2017,7 +2017,9 @@ nm_device_activate_stage4_ip4_config_get (gpointer user_data)
g_object_set_data (G_OBJECT (nm_device_get_act_request (self)),
NM_ACT_REQUEST_IP4_CONFIG, ip4_config);
nm_log_info (LOGD_DEVICE | LOGD_IP4, "Scheduling stage 5");
nm_device_activate_schedule_stage5_ip_config_commit (self, AF_INET);
nm_log_info (LOGD_DEVICE | LOGD_IP4, "Done scheduling stage 5");
out:
nm_log_info (LOGD_DEVICE | LOGD_IP4,

View file

@ -33,10 +33,6 @@
#include <nm-setting-wired.h>
#include <nm-setting-wireless.h>
#include <nm-setting-bluetooth.h>
#include <nm-setting-serial.h>
#include <nm-setting-gsm.h>
#include <nm-setting-cdma.h>
#include <nm-setting-ppp.h>
#include <arpa/inet.h>
#include <netinet/ether.h>
#include <string.h>
@ -1061,13 +1057,12 @@ nm_keyfile_plugin_connection_from_file (const char *filename, GError **error)
gboolean bad_owner, bad_permissions;
NMConnection *connection = NULL;
NMSettingConnection *s_con;
NMSettingBluetooth *s_bt;
NMSetting *setting;
gchar **groups;
gsize length;
int i;
gboolean vpn_secrets = FALSE;
const char *ctype, *tmp;
const char *ctype;
GError *verify_error = NULL;
if (stat (filename, &statbuf) != 0 || !S_ISREG (statbuf.st_mode)) {
@ -1114,38 +1109,11 @@ nm_keyfile_plugin_connection_from_file (const char *filename, GError **error)
ctype = nm_setting_connection_get_connection_type (s_con);
setting = nm_connection_get_setting_by_name (connection, ctype);
if (ctype) {
gboolean add_serial = FALSE;
NMSetting *new_setting = NULL;
if (!setting && !strcmp (ctype, NM_SETTING_WIRED_SETTING_NAME))
new_setting = nm_setting_wired_new ();
else if (!strcmp (ctype, NM_SETTING_BLUETOOTH_SETTING_NAME)) {
s_bt = (NMSettingBluetooth *) nm_connection_get_setting (connection, NM_TYPE_SETTING_BLUETOOTH);
if (s_bt) {
tmp = nm_setting_bluetooth_get_connection_type (s_bt);
if (tmp && !strcmp (tmp, NM_SETTING_BLUETOOTH_TYPE_DUN))
add_serial = TRUE;
}
} else if (!strcmp (ctype, NM_SETTING_GSM_SETTING_NAME))
add_serial = TRUE;
else if (!strcmp (ctype, NM_SETTING_CDMA_SETTING_NAME))
add_serial = TRUE;
/* Bluetooth DUN, GSM, and CDMA connections require a serial setting */
if (add_serial && !nm_connection_get_setting (connection, NM_TYPE_SETTING_SERIAL))
new_setting = nm_setting_serial_new ();
if (new_setting)
nm_connection_add_setting (connection, new_setting);
nm_connection_add_setting (connection, nm_setting_wired_new ());
}
}
/* Serial connections require a PPP setting too */
if (nm_connection_get_setting (connection, NM_TYPE_SETTING_SERIAL)) {
if (!nm_connection_get_setting (connection, NM_TYPE_SETTING_PPP))
nm_connection_add_setting (connection, nm_setting_ppp_new ());
}
/* Handle vpn secrets after the 'vpn' setting was read */
if (vpn_secrets) {
NMSettingVPN *s_vpn;