configure.ac | 10 + src/applet-device-gsm.c | 267 ++++++++++++++++++++++++- src/applet-device-wired.c | 79 +++++++ src/applet.c | 67 ++++++- src/applet.h | 30 +++ src/connection-editor/nm-connection-list.c | 303 +++++++++++++++++++++++---- src/connection-editor/nm-connection-list.h | 14 ++ src/wireless-security/eap-method-peap.c | 24 ++- src/wireless-security/eap-method-ttls.c | 2 +- 9 files changed, 744 insertions(+), 52 deletions(-) diff --git a/configure.ac b/configure.ac index 293de81..1527352 100644 --- a/configure.ac +++ b/configure.ac @@ -219,6 +219,16 @@ else AC_MSG_RESULT(no) fi +AC_ARG_WITH(mbca, AC_HELP_STRING([--with-mbca], [use Mobile Broadband Configuration Assistant])) + +if ! test -z "$with_mbca" ; then + CFLAGS="$CFLAGS -DWITH_MBCA" + PKG_CHECK_MODULES(MBCA, libmbca) + NMA_CFLAGS="$NMA_CFLAGS $MBCA_CFLAGS" + #NMA_LIBS="$NMA_LIBS $MBCA_LIBS" +fi + + AC_OUTPUT([ Makefile src/Makefile diff --git a/src/applet-device-gsm.c b/src/applet-device-gsm.c index a01d57c..5b2680b 100644 --- a/src/applet-device-gsm.c +++ b/src/applet-device-gsm.c @@ -40,6 +40,13 @@ #include "applet-device-gsm.h" #include "utils.h" +#ifdef WITH_MBCA +#include +#include +#include +#include +#endif + typedef struct { NMApplet *applet; NMDevice *device; @@ -52,6 +59,157 @@ gsm_menu_item_info_destroy (gpointer data) g_slice_free (GSMMenuItemInfo, data); } +#ifdef WITH_MBCA +static void +assistant_state_changed_cb (MBCAAssistant* assistant, + MBCAAssistantState state, + gpointer data) +{ + NMApplet *applet = data; + GSList* iter; + + NMAGConfConnection *exported; + + NMConnection *connection; + NMSettingGsm *s_gsm; + NMSettingSerial *s_serial; + NMSettingPPP *s_ppp; + NMSettingConnection *s_con; + + NMSettingIP4Config* ipv4conf; + gboolean ignore_auto_dns = FALSE; + GArray *dns_servers = FALSE; + const char *method; + + MBCAConfiguration* conf; + + if (!applet_open_mbca (applet)) + g_return_if_reached (); /* this cb should not be called without + * libmbca */ + + switch (state) + { + case MBCA_STATE_READY: + case MBCA_STATE_RUNNING: + { + break; + } + case MBCA_STATE_DONE: + { + char *uuid; + conf = applet->mbca_assistant_get_configuration_func (assistant); + connection = nm_connection_new (); + + s_con = NM_SETTING_CONNECTION (nm_setting_connection_new ()); + nm_connection_add_setting (connection, NM_SETTING (s_con)); + + ipv4conf = NM_SETTING_IP4_CONFIG (nm_setting_ip4_config_new ()); + nm_connection_add_setting (connection, NM_SETTING (ipv4conf)); + + uuid = nm_utils_uuid_generate (); + + g_object_set (s_con, + NM_SETTING_CONNECTION_ID, conf->name, + NM_SETTING_CONNECTION_TYPE, NM_SETTING_GSM_SETTING_NAME, + NM_SETTING_CONNECTION_UUID, uuid, + NM_SETTING_CONNECTION_AUTOCONNECT, FALSE, + NULL); + + g_free(uuid); + + /* Serial setting */ + s_serial = (NMSettingSerial *) nm_setting_serial_new (); + g_object_set (s_con, + NM_SETTING_SERIAL_BAUD, 115200, + NM_SETTING_SERIAL_BITS, 8, + NM_SETTING_SERIAL_PARITY, 'n', + NM_SETTING_SERIAL_STOPBITS, 1, + NULL); + + nm_connection_add_setting (connection, NM_SETTING (s_serial)); + + method = NM_SETTING_IP4_CONFIG_METHOD_AUTO; + + s_gsm = NM_SETTING_GSM (nm_setting_gsm_new ()); + + g_object_set (s_gsm, NM_SETTING_GSM_NUMBER, "*99#", /* De-facto standard for GSM */ + NM_SETTING_GSM_APN, conf->provider->gsm.apn, + NM_SETTING_GSM_USERNAME, conf->provider->username, + NM_SETTING_GSM_PASSWORD, conf->provider->password, + NULL); + + if (conf->provider->dns1) { + struct in_addr tmp_addr; + ignore_auto_dns = TRUE; + dns_servers = g_array_new (FALSE, FALSE, sizeof (guint)); + + inet_aton (conf->provider->dns1, &tmp_addr); + g_array_append_val (dns_servers, tmp_addr.s_addr); + + if (conf->provider->dns2) { + inet_aton (conf->provider->dns2, &tmp_addr); + g_array_append_val (dns_servers, tmp_addr.s_addr); + } + } + + /* TODO: gateway */ + + g_object_set (ipv4conf, + NM_SETTING_IP4_CONFIG_METHOD, method, + NM_SETTING_IP4_CONFIG_DNS, dns_servers, + NM_SETTING_IP4_CONFIG_IGNORE_AUTO_DNS, ignore_auto_dns, + NULL); + + nm_connection_add_setting (connection, NM_SETTING (s_gsm)); + + s_ppp = (NMSettingPPP *) nm_setting_ppp_new (); + nm_connection_add_setting (connection, NM_SETTING (s_ppp)); + + + applet->mbca_free_configuration_func (conf); + if (dns_servers) + g_array_free (dns_servers, TRUE); + + exported = nma_gconf_settings_add_connection (applet->gconf_settings, connection); + if (!exported) { + g_object_unref (connection); + g_return_if_reached (); + } + g_object_unref (connection); + + applet_do_notify (applet, NOTIFY_URGENCY_LOW, + _("New Configuration Created"), + _("You can activate the connection by clicking this icon.\n" + "\n" + "Use connection editor to add new and to change settings if necessary"), + "nm-device-wwan", NULL, NULL, NULL, NULL); + + /* FALLTHROUGH */ + } + case MBCA_STATE_ABORTED: + { + for (iter = applet->mbca_assistants; iter; iter = iter->next){ + if ((MBCAAssistant*)(iter->data) == assistant) { + UdiAssistant* ua = iter->data; + g_object_unref (G_OBJECT (ua->assistant)); + g_free (ua->udi); + applet->mbca_assistants = g_slist_remove_all (applet->mbca_assistants, + ua); + + g_free (ua); + + } + } + break; + } + default: + { + g_return_if_reached (); + } + } +} +#endif + #define DEFAULT_GSM_NAME _("Auto Mobile Broadband (GSM) connection") static NMConnection * @@ -66,6 +224,49 @@ gsm_new_auto_connection (NMDevice *device, NMSettingConnection *s_con; char *uuid; +#ifdef WITH_MBCA + UdiAssistant* ua; + const gchar* udi; + GSList* iter; + + if (applet_open_mbca (applet)) + { + udi = nm_device_get_udi (device); + + for (iter = applet->mbca_assistants; iter; iter = iter->next) { + UdiAssistant* tmp = iter->data; + if (!strcmp (tmp->udi, udi)) + { + applet->mbca_assistant_present_func (tmp->assistant); + break; + } + } + if (!iter) + { + /* not found */ + ua = g_malloc (sizeof (UdiAssistant)); + ua->udi = g_strdup (udi); + ua->assistant = applet->mbca_assistant_new_func (); + g_signal_connect (G_OBJECT (ua->assistant), "state-changed", + G_CALLBACK (assistant_state_changed_cb), applet); + applet->mbca_assistants = g_slist_prepend (applet->mbca_assistants, ua); + applet->mbca_assistant_run_for_device_func (ua->assistant, + MBCA_DEVICE_PSEUDO, + NULL, NULL); + } + + nm_warning ("There's a new GSM modem being configured and no " + "configuration is yet available. You can safely ignore the " + "next warninig, if any, about missing default configuration." + ); + return NULL; + } + else + { + /* continue to default code */ + } +#endif + connection = nm_connection_new (); s_gsm = NM_SETTING_GSM (nm_setting_gsm_new ()); @@ -155,9 +356,15 @@ add_default_connection_item (NMDevice *device, NMApplet *applet) { GSMMenuItemInfo *info; - GtkWidget *item; + GtkWidget *item = NULL; + +#ifdef WITH_MBCA + if (applet_open_mbca (applet)) + item = gtk_check_menu_item_new_with_label (_("Configure...")); +#endif + if (!item) + item = gtk_check_menu_item_new_with_label (DEFAULT_GSM_NAME); - item = gtk_check_menu_item_new_with_label (DEFAULT_GSM_NAME); gtk_check_menu_item_set_draw_as_radio (GTK_CHECK_MENU_ITEM (item), TRUE); info = g_slice_new0 (GSMMenuItemInfo); @@ -308,6 +515,58 @@ gsm_device_state_changed (NMDevice *device, } } +#ifdef WITH_MBCA +typedef struct { + NMDevice* device; + NMApplet* applet; +} NotifyConfigureNewDeviceCbData; + +static void +notify_configure_new_device_cb (NotifyNotification* notification, gchar* foo, gpointer data) +{ + NotifyConfigureNewDeviceCbData* d = data; + gsm_new_auto_connection (d->device, d->applet, NULL); + g_free (d); +} + +static void +gsm_device_added (NMDevice *device, NMApplet *applet) +{ + GSList *connections, *all; + + if (!applet_open_mbca (applet)) + return; + + all = applet_get_all_connections (applet); + connections = utils_filter_connections_for_device (device, all); + g_slist_free (all); + + if (g_slist_length (connections) == 0) + { + gchar* summary; + NotifyConfigureNewDeviceCbData* d = g_malloc (sizeof (NotifyConfigureNewDeviceCbData)); + d->device = device; + d->applet = applet; + + summary = g_strdup_printf ("%s:\n - %s", + utils_get_device_description (device), + _("Click here to configure the device...") + ); + + applet_do_notify (applet, NOTIFY_URGENCY_LOW, + _("New Mobile Broadband Device Detected"), + summary, + "nm-device-wwan", + "configure", + "Configure", + notify_configure_new_device_cb, + d); + g_free (summary); + } + +} +#endif + static GdkPixbuf * gsm_get_icon (NMDevice *device, NMDeviceState state, @@ -654,6 +913,10 @@ applet_device_gsm_get_class (NMApplet *applet) dclass->get_icon = gsm_get_icon; dclass->get_secrets = gsm_get_secrets; +#ifdef WITH_MBCA + dclass->device_added = gsm_device_added; +#endif + return dclass; } diff --git a/src/applet-device-wired.c b/src/applet-device-wired.c index 09ca5e2..945ff44 100644 --- a/src/applet-device-wired.c +++ b/src/applet-device-wired.c @@ -240,6 +240,70 @@ out: g_slist_free (connections); } +static gboolean +connections_present(NMDevice *device, NMApplet *applet) +{ + GSList *connections, *all; + + all = applet_get_all_connections (applet); + connections = utils_filter_connections_for_device (device, all); + g_slist_free (all); + + if(g_slist_length(connections)) + { + g_slist_free(connections); + return TRUE; + } + + return FALSE; +} + +typedef struct create_auto_connection_data +{ + NMDevice *device; + NMApplet *applet; +}create_auto_connection_data; + +#define CREATE_AUTO_CONNECT_TIMEOUT (1500) + +static gboolean +create_auto_connection(gpointer data) +{ + create_auto_connection_data *info = (create_auto_connection_data *)data; + NMConnection *connection; + NMAGConfConnection *exported; + NMDevice *device; + NMApplet *applet; + + g_return_val_if_fail(info != NULL, FALSE); + + device = info->device; + applet = info->applet; + + g_free(info); + + if(connections_present(device, applet)) + { + return FALSE; + } + + connection = wired_new_auto_connection (device, applet, NULL); + + if (!connection) { + nm_warning ("Couldn't create default connection."); + return FALSE; + } + g_message("Default auto connection created"); + exported = nma_gconf_settings_add_connection (applet->gconf_settings, connection); + if (!exported) + { + nm_warning ("Invalid default connection."); + } + g_object_unref (connection); + + return FALSE; +} + static void wired_device_state_changed (NMDevice *device, NMDeviceState new_state, @@ -247,6 +311,21 @@ wired_device_state_changed (NMDevice *device, NMDeviceStateReason reason, NMApplet *applet) { + + if(new_state == NM_DEVICE_STATE_DISCONNECTED) + { + if(!connections_present(device, applet)) + { + create_auto_connection_data *info; + + info = g_malloc(sizeof(create_auto_connection_data)); + g_return_if_fail(info != NULL); + info->device = device; + info->applet = applet; + g_timeout_add (CREATE_AUTO_CONNECT_TIMEOUT, create_auto_connection, info); + } + } + if (new_state == NM_DEVICE_STATE_ACTIVATED) { NMConnection *connection; NMSettingConnection *s_con = NULL; diff --git a/src/applet.c b/src/applet.c index 82472c1..9d77915 100644 --- a/src/applet.c +++ b/src/applet.c @@ -995,6 +995,51 @@ applet_find_active_connection_for_device (NMDevice *device, return connection; } +#ifdef WITH_MBCA +gboolean +applet_open_mbca (NMApplet *applet) +{ + if (applet->mbca_module) + return TRUE; + + applet->mbca_module = g_module_open ("libmbca.so.0", G_MODULE_BIND_LAZY | G_MODULE_BIND_LOCAL); + if (!applet->mbca_module) + return FALSE; + + if (!g_module_symbol (applet->mbca_module, + "mbca_assistant_abort", + ((gpointer)(&applet->mbca_assistant_abort_func)))); + g_warn_if_reached (); + + if (!g_module_symbol (applet->mbca_module, + "mbca_assistant_present", + (gpointer)(&applet->mbca_assistant_present_func)) ); + g_warn_if_reached (); + + if (!g_module_symbol (applet->mbca_module, + "mbca_assistant_new", + (gpointer)(&applet->mbca_assistant_new_func))); + g_warn_if_reached (); + + if (!g_module_symbol (applet->mbca_module, + "mbca_assistant_run_for_device", + (gpointer)(&applet->mbca_assistant_run_for_device_func))); + g_warn_if_reached (); + + if (!g_module_symbol (applet->mbca_module, + "mbca_assistant_get_configuration", + (gpointer)(&applet->mbca_assistant_get_configuration_func))); + g_warn_if_reached (); + + if (!g_module_symbol (applet->mbca_module, + "mbca_free_configuration", + (gpointer)(&applet->mbca_free_configuration_func))); + g_warn_if_reached (); + + return TRUE; +} +#endif + GtkWidget * nma_menu_device_check_unusable (NMDevice *device, const char *unavailable_msg) @@ -1776,7 +1821,7 @@ foo_client_setup (NMApplet *applet) static GdkPixbuf * applet_common_get_device_icon (NMDeviceState state, NMApplet *applet) { - GdkPixbuf *pixbuf = NULL; + GdkPixbuf *pixbuf = applet->no_connection_icon; int stage = -1; switch (state) { @@ -2574,6 +2619,21 @@ static void finalize (GObject *object) { NMApplet *applet = NM_APPLET (object); +#ifdef WITH_MBCA + GSList* iter = NULL; + + for (iter = applet->mbca_assistants; iter; iter = iter->next) { + UdiAssistant* ua = iter->data; + if (!applet_open_mbca (applet)) + g_return_if_reached (); /* no assistants without libmbca */ + applet->mbca_assistant_abort_func (ua->assistant); + /* let the cb handle freeing of resources */ + } + + if (applet->mbca_module) + g_module_close (applet->mbca_module); +#endif + nm_gconf_set_pre_keyring_callback (NULL, NULL); if (applet->update_timestamps_id) @@ -2631,6 +2691,11 @@ static void nma_init (NMApplet *applet) applet->icon_theme = NULL; applet->notification = NULL; applet->size = -1; + +#ifdef WITH_MBCA + applet->mbca_assistants = NULL; + applet->mbca_module = NULL; +#endif } enum { diff --git a/src/applet.h b/src/applet.h index f333447..0280680 100644 --- a/src/applet.h +++ b/src/applet.h @@ -47,6 +47,10 @@ #include #include +#ifdef WITH_MBCA +#include +#endif + #include "applet-dbus-manager.h" #include "nma-gconf-settings.h" @@ -57,6 +61,14 @@ #define NM_IS_APPLET_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass), NM_TYPE_APPLET)) #define NM_APPLET_GET_CLASS(object)(G_TYPE_INSTANCE_GET_CLASS((object), NM_TYPE_APPLET, NMAppletClass)) +#ifdef WITH_MBCA +typedef struct +{ + char* udi; + MBCAAssistant* assistant; +} UdiAssistant; +#endif + typedef struct { GObjectClass parent_class; @@ -144,6 +156,20 @@ typedef struct GladeXML * info_dialog_xml; NotifyNotification* notification; gboolean notify_with_actions; + +#ifdef WITH_MBCA + GSList *mbca_assistants; /* list of UdiAssistant */ + GModule *mbca_module; + void (*mbca_assistant_abort_func) (MBCAAssistant*); + void (*mbca_assistant_present_func) (MBCAAssistant*); + MBCAAssistant* (*mbca_assistant_new_func) (); + gint (*mbca_assistant_run_for_device_func) (MBCAAssistant*, + MBCADeviceType, + const gchar*, + const gchar*); + MBCAConfiguration* (*mbca_assistant_get_configuration_func) (MBCAAssistant*); + void (*mbca_free_configuration_func) (MBCAConfiguration*); +#endif } NMApplet; @@ -228,4 +254,8 @@ NMConnection * applet_find_active_connection_for_device (NMDevice *device, NMApplet *applet, NMActiveConnection **out_active); +#ifdef WITH_MBCA +gboolean applet_open_mbca (NMApplet *applet); +#endif + #endif diff --git a/src/connection-editor/nm-connection-list.c b/src/connection-editor/nm-connection-list.c index 70557fb..2732642 100644 --- a/src/connection-editor/nm-connection-list.c +++ b/src/connection-editor/nm-connection-list.c @@ -51,6 +51,13 @@ #include #include +#ifdef WITH_MBCA +#include +#include +#include +#include +#endif + #include "nm-connection-editor.h" #include "nm-connection-list.h" #include "gconf-helpers.h" @@ -108,6 +115,42 @@ error_dialog (GtkWindow *parent, const char *heading, const char *format, ...) gtk_widget_destroy (dialog); } +#ifdef WITH_MBCA +static gboolean +open_mbca (NMConnectionList *list) +{ + if (list->mbca_module) + return TRUE; + + list->mbca_module = g_module_open ("libmbca.so.0", G_MODULE_BIND_LAZY | + G_MODULE_BIND_LOCAL); + if (!list->mbca_module) + return FALSE; + + if (!g_module_symbol (list->mbca_module, + "mbca_assistant_new", + (gpointer)(&list->mbca_assistant_new_func))); + g_warn_if_reached (); + + if (!g_module_symbol (list->mbca_module, + "mbca_assistant_run_for_device", + (gpointer)(&list->mbca_assistant_run_for_device_func))); + g_warn_if_reached (); + + if (!g_module_symbol (list->mbca_module, + "mbca_assistant_get_configuration", + (gpointer)(&list->mbca_assistant_get_configuration_func))); + g_warn_if_reached (); + + if (!g_module_symbol (list->mbca_module, + "mbca_free_configuration", + (gpointer)(&list->mbca_free_configuration_func))); + g_warn_if_reached (); + + return TRUE; +} +#endif + static NMExportedConnection * get_active_connection (GtkTreeView *treeview) { @@ -819,6 +862,141 @@ add_default_serial_setting (NMConnection *connection) nm_connection_add_setting (connection, NM_SETTING (s_serial)); } +#ifdef WITH_MBCA +static void +mbca_assistant_state_changed_cb (MBCAAssistant* assistant, + MBCAAssistantState state, + gpointer user_data) +{ + NMConnection *connection = NULL; + NMSettingConnection *s_con; + NMSetting *type_setting = NULL; + MBCAConfiguration* conf; + + NMConnectionList *list = user_data; + + NMSettingIP4Config* ipv4conf; + gboolean ignore_auto_dns = FALSE; + GArray *dns_servers = FALSE; + const char *method; + char *uuid; + + switch (state) { + case MBCA_STATE_READY: + case MBCA_STATE_RUNNING: + return; + case MBCA_STATE_DONE: + + /* this function should never get called without a prior usage of + * libmbca in create_new_connection_for_type + */ + g_return_if_fail (open_mbca (list)); + + connection = nm_connection_new (); + nm_connection_set_scope (connection, NM_CONNECTION_SCOPE_USER); + + s_con = NM_SETTING_CONNECTION (nm_setting_connection_new ()); + nm_connection_add_setting (connection, NM_SETTING (s_con)); + + ipv4conf = NM_SETTING_IP4_CONFIG (nm_setting_ip4_config_new ()); + nm_connection_add_setting (connection, NM_SETTING (ipv4conf)); + + conf = list->mbca_assistant_get_configuration_func (assistant); + + uuid = nm_utils_uuid_generate (); + + g_object_set (s_con, + NM_SETTING_CONNECTION_ID, conf->name, + NM_SETTING_CONNECTION_UUID, uuid, + NM_SETTING_CONNECTION_AUTOCONNECT, FALSE, + NULL); + + g_free(uuid); + + add_default_serial_setting (connection); + + method = NM_SETTING_IP4_CONFIG_METHOD_AUTO; + + if (conf->provider->type == MBCA_NETWORK_GSM) { + NMSettingGsm *s_gsm; + + g_object_set (s_con, + NM_SETTING_CONNECTION_TYPE, NM_SETTING_GSM_SETTING_NAME, + NULL); + + type_setting = nm_setting_gsm_new (); + s_gsm = NM_SETTING_GSM (type_setting); + + g_object_set (s_gsm, NM_SETTING_GSM_NUMBER, "*99#", /* De-facto standard for GSM */ + NM_SETTING_GSM_APN, conf->provider->gsm.apn, + NM_SETTING_GSM_USERNAME, conf->provider->username, + NM_SETTING_GSM_PASSWORD, conf->provider->password, + NULL); + + if (conf->provider->dns1) { + struct in_addr tmp_addr; + ignore_auto_dns = TRUE; + dns_servers = g_array_new (FALSE, FALSE, sizeof (guint)); + + inet_aton (conf->provider->dns1, &tmp_addr); + g_array_append_val (dns_servers, tmp_addr.s_addr); + + if (conf->provider->dns2) { + inet_aton (conf->provider->dns2, &tmp_addr); + g_array_append_val (dns_servers, tmp_addr.s_addr); + } + } + + /* TODO: gateway */ + + } else if (conf->provider->type == MBCA_NETWORK_CDMA) { + NMSettingCdma *s_cdma; + + g_object_set (s_con, + NM_SETTING_CONNECTION_TYPE, NM_SETTING_CDMA_SETTING_NAME, + NULL); + + type_setting = nm_setting_cdma_new (); + s_cdma = NM_SETTING_CDMA (type_setting); + + g_object_set (s_cdma, NM_SETTING_CDMA_NUMBER, "#777", /* De-facto standard for CDMA */ + NM_SETTING_CDMA_USERNAME, conf->provider->username, + NM_SETTING_CDMA_PASSWORD, conf->provider->password, + NULL); + + } + nm_connection_add_setting (connection, nm_setting_ppp_new ()); + + g_object_set (ipv4conf, + NM_SETTING_IP4_CONFIG_METHOD, method, + NM_SETTING_IP4_CONFIG_DNS, dns_servers, + NM_SETTING_IP4_CONFIG_IGNORE_AUTO_DNS, ignore_auto_dns, + NULL); + + if (type_setting) { + nm_connection_add_setting (connection, type_setting); + } else { + g_object_unref (connection); + connection = NULL; + } + + add_connection (list, NULL, connection, NULL, NULL); + g_hash_table_remove (list->editors, connection); + + list->mbca_free_configuration_func (conf); + if (dns_servers) + g_array_free (dns_servers, TRUE); + /* FALLTHROUGH */ + + case MBCA_STATE_ABORTED: + g_object_unref (assistant); + break; + default: + g_warn_if_reached (); + } +} +#endif + static NMConnection * create_new_connection_for_type (NMConnectionList *list, const char *connection_type) { @@ -828,6 +1006,10 @@ create_new_connection_for_type (NMConnectionList *list, const char *connection_t NMSetting *type_setting = NULL; char *id, *uuid; GType mb_type; +#ifdef WITH_MBCA + MBCAAssistant *assistant = NULL; +#endif + gboolean use_mbca = FALSE; ctype = nm_connection_lookup_setting_type (connection_type); @@ -864,51 +1046,74 @@ create_new_connection_for_type (NMConnectionList *list, const char *connection_t s_wireless = NM_SETTING_WIRELESS (type_setting); g_object_set (s_wireless, NM_SETTING_WIRELESS_MODE, "infrastructure", NULL); } else if ((ctype == NM_TYPE_SETTING_GSM) || (ctype == NM_TYPE_SETTING_CDMA)) { - /* Since GSM is a placeholder for both GSM and CDMA; ask the user which - * one they really want. - */ - mb_type = mobile_wizard_ask_connection_type (); - if (mb_type == NM_TYPE_SETTING_GSM) { - NMSettingGsm *s_gsm; - - id = get_next_available_name (list, _("GSM connection %d")); - g_object_set (s_con, - NM_SETTING_CONNECTION_ID, id, - NM_SETTING_CONNECTION_TYPE, NM_SETTING_GSM_SETTING_NAME, - NM_SETTING_CONNECTION_AUTOCONNECT, FALSE, - NULL); - g_free (id); - - add_default_serial_setting (connection); - - type_setting = nm_setting_gsm_new (); - s_gsm = NM_SETTING_GSM (type_setting); - /* De-facto standard for GSM */ - g_object_set (s_gsm, NM_SETTING_GSM_NUMBER, "*99#", NULL); - - nm_connection_add_setting (connection, nm_setting_ppp_new ()); - } else if (mb_type == NM_TYPE_SETTING_CDMA) { - NMSettingCdma *s_cdma; - - id = get_next_available_name (list, _("CDMA connection %d")); - g_object_set (s_con, - NM_SETTING_CONNECTION_ID, id, - NM_SETTING_CONNECTION_TYPE, NM_SETTING_CDMA_SETTING_NAME, - NM_SETTING_CONNECTION_AUTOCONNECT, FALSE, - NULL); - g_free (id); - - add_default_serial_setting (connection); - - type_setting = nm_setting_cdma_new (); - s_cdma = NM_SETTING_CDMA (type_setting); - - /* De-facto standard for CDMA */ - g_object_set (s_cdma, NM_SETTING_CDMA_NUMBER, "#777", NULL); - - nm_connection_add_setting (connection, nm_setting_ppp_new ()); - } else { - /* user canceled; do nothing */ +#ifdef WITH_MBCA + use_mbca = open_mbca (list); +#endif + if (use_mbca) + { +#ifdef WITH_MBCA + + assistant = list->mbca_assistant_new_func (); + g_signal_connect (G_OBJECT (assistant), "state-changed", + G_CALLBACK (mbca_assistant_state_changed_cb), list); + list->mbca_assistant_run_for_device_func (assistant, + MBCA_DEVICE_PSEUDO, + NULL, NULL); + + mb_type = NM_TYPE_SETTING_GSM; /* get rid of compiler warning about + * unused variable */ +#endif + } + else + { + /* MBCA support not compiled in or libmbca is missing */ + + /* Since GSM is a placeholder for both GSM and CDMA; ask the user which + * one they really want. + */ + mb_type = mobile_wizard_ask_connection_type (); + if (mb_type == NM_TYPE_SETTING_GSM) { + NMSettingGsm *s_gsm; + + id = get_next_available_name (list, _("GSM connection %d")); + g_object_set (s_con, + NM_SETTING_CONNECTION_ID, id, + NM_SETTING_CONNECTION_TYPE, NM_SETTING_GSM_SETTING_NAME, + NM_SETTING_CONNECTION_AUTOCONNECT, FALSE, + NULL); + g_free (id); + + add_default_serial_setting (connection); + + type_setting = nm_setting_gsm_new (); + s_gsm = NM_SETTING_GSM (type_setting); + /* De-facto standard for GSM */ + g_object_set (s_gsm, NM_SETTING_GSM_NUMBER, "*99#", NULL); + + nm_connection_add_setting (connection, nm_setting_ppp_new ()); + } else if (mb_type == NM_TYPE_SETTING_CDMA) { + NMSettingCdma *s_cdma; + + id = get_next_available_name (list, _("CDMA connection %d")); + g_object_set (s_con, + NM_SETTING_CONNECTION_ID, id, + NM_SETTING_CONNECTION_TYPE, NM_SETTING_CDMA_SETTING_NAME, + NM_SETTING_CONNECTION_AUTOCONNECT, FALSE, + NULL); + g_free (id); + + add_default_serial_setting (connection); + + type_setting = nm_setting_cdma_new (); + s_cdma = NM_SETTING_CDMA (type_setting); + + /* De-facto standard for CDMA */ + g_object_set (s_cdma, NM_SETTING_CDMA_NUMBER, "#777", NULL); + + nm_connection_add_setting (connection, nm_setting_ppp_new ()); + } else { + /* user canceled; do nothing */ + } } } else if (ctype == NM_TYPE_SETTING_VPN) { char *service = NULL; @@ -1420,6 +1625,9 @@ nm_connection_list_init (NMConnectionList *list) list->system_action = polkit_action_new (); polkit_action_set_action_id (list->system_action, "org.freedesktop.network-manager-settings.system.modify"); +#ifdef WITH_MBCA + list->mbca_module = NULL; +#endif } static void @@ -1461,6 +1669,11 @@ dispose (GObject *object) if (list->system_settings) g_object_unref (list->system_settings); +#if WITH_MBCA + if (list->mbca_module) + g_module_close (list->mbca_module); +#endif + G_OBJECT_CLASS (nm_connection_list_parent_class)->dispose (object); } diff --git a/src/connection-editor/nm-connection-list.h b/src/connection-editor/nm-connection-list.h index 800873a..74351fe 100644 --- a/src/connection-editor/nm-connection-list.h +++ b/src/connection-editor/nm-connection-list.h @@ -36,6 +36,10 @@ #endif #include "nma-gconf-settings.h" +#ifdef WITH_MBCA +#include +#endif + #define NM_TYPE_CONNECTION_LIST (nm_connection_list_get_type ()) #define NM_IS_CONNECTION_LIST(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), NM_TYPE_CONNECTION_LIST)) #define NM_CONNECTION_LIST(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), NM_TYPE_CONNECTION_LIST, NMConnectionList)) @@ -62,6 +66,16 @@ typedef struct { GdkPixbuf *vpn_icon; GdkPixbuf *unknown_icon; GtkIconTheme *icon_theme; +#ifdef WITH_MBCA + GModule *mbca_module; + MBCAAssistant* (*mbca_assistant_new_func) (); + gint (*mbca_assistant_run_for_device_func) (MBCAAssistant*, + MBCADeviceType, + const gchar*, + const gchar*); + MBCAConfiguration* (*mbca_assistant_get_configuration_func) (MBCAAssistant*); + void (*mbca_free_configuration_func) (MBCAConfiguration*); +#endif } NMConnectionList; typedef struct { diff --git a/src/wireless-security/eap-method-peap.c b/src/wireless-security/eap-method-peap.c index 8d82fee..f3e34b8 100644 --- a/src/wireless-security/eap-method-peap.c +++ b/src/wireless-security/eap-method-peap.c @@ -209,7 +209,8 @@ inner_auth_combo_changed_cb (GtkWidget *combo, gpointer user_data) static GtkWidget * inner_auth_combo_init (EAPMethodPEAP *method, const char *glade_file, - NMConnection *connection) + NMConnection *connection, + NMSetting8021x *s_8021x) { GladeXML *xml = EAP_METHOD (method)->xml; GtkWidget *combo; @@ -217,9 +218,18 @@ inner_auth_combo_init (EAPMethodPEAP *method, GtkTreeIter iter; EAPMethodSimple *em_mschap_v2; EAPMethodSimple *em_md5; + guint32 active = 0; + const char *phase2_auth = NULL; auth_model = gtk_list_store_new (2, G_TYPE_STRING, eap_method_get_g_type ()); + if (s_8021x) { + if (nm_setting_802_1x_get_phase2_auth (s_8021x)) + phase2_auth = nm_setting_802_1x_get_phase2_auth (s_8021x); + else if (nm_setting_802_1x_get_phase2_autheap (s_8021x)) + phase2_auth = nm_setting_802_1x_get_phase2_autheap (s_8021x); + } + em_mschap_v2 = eap_method_simple_new (glade_file, method->sec_parent, connection, @@ -231,6 +241,10 @@ inner_auth_combo_init (EAPMethodPEAP *method, -1); eap_method_unref (EAP_METHOD (em_mschap_v2)); + /* Check for defaulting to MSCHAPv2 */ + if (phase2_auth && !strcasecmp (phase2_auth, "mschapv2")) + active = 0; + em_md5 = eap_method_simple_new (glade_file, method->sec_parent, connection, @@ -242,12 +256,16 @@ inner_auth_combo_init (EAPMethodPEAP *method, -1); eap_method_unref (EAP_METHOD (em_md5)); + /* Check for defaulting to MD5 */ + if (phase2_auth && !strcasecmp (phase2_auth, "md5")) + active = 1; + combo = glade_xml_get_widget (xml, "eap_peap_inner_auth_combo"); g_assert (combo); gtk_combo_box_set_model (GTK_COMBO_BOX (combo), GTK_TREE_MODEL (auth_model)); g_object_unref (G_OBJECT (auth_model)); - gtk_combo_box_set_active (GTK_COMBO_BOX (combo), 0); + gtk_combo_box_set_active (GTK_COMBO_BOX (combo), active); g_signal_connect (G_OBJECT (combo), "changed", (GCallback) inner_auth_combo_changed_cb, @@ -320,7 +338,7 @@ eap_method_peap_new (const char *glade_file, gtk_file_chooser_set_filename (GTK_FILE_CHOOSER (widget), filename); } - widget = inner_auth_combo_init (method, glade_file, connection); + widget = inner_auth_combo_init (method, glade_file, connection, s_8021x); inner_auth_combo_changed_cb (widget, (gpointer) method); widget = glade_xml_get_widget (xml, "eap_peap_version_combo"); diff --git a/src/wireless-security/eap-method-ttls.c b/src/wireless-security/eap-method-ttls.c index b455fc8..4fe51f0 100644 --- a/src/wireless-security/eap-method-ttls.c +++ b/src/wireless-security/eap-method-ttls.c @@ -272,7 +272,7 @@ inner_auth_combo_init (EAPMethodTTLS *method, /* Check for defaulting to CHAP */ if (phase2_auth && !strcasecmp (phase2_auth, "chap")) - active = 4; + active = 3; combo = glade_xml_get_widget (xml, "eap_ttls_inner_auth_combo"); g_assert (combo);