[PATCH] add libmbca support



Hi,

here's a patch to add libmbca support to network-manager-applet. Support
has to be enabled by --with-mbca configure flag, so the support (and
dependency) is not mandatory. I've tested the patch against the latest
trunk (r859).

If the support gets compiled in, libmbca does not have to be present on
the users system as the library is dynamically loaded at runtime.

There's one change that has unconditional effect. I've added IPv4 tab to
mobile broadband connection editor, because it's needed with certain
service providers.

comments appreciated!
Br,
Antti

Index: src/applet-device-gsm.c
===================================================================
--- src/applet-device-gsm.c	(revision 859)
+++ src/applet-device-gsm.c	(working copy)
@@ -36,6 +36,13 @@
 #include <nm-setting-ppp.h>
 #include <nm-gsm-device.h>
 
+#ifdef WITH_MBCA
+#include <netinet/in.h>
+#include <arpa/inet.h>
+#include <nm-setting-ip4-config.h>
+#include <nm-utils.h>
+#endif
+
 #include "applet.h"
 #include "applet-device-gsm.h"
 #include "utils.h"
@@ -52,6 +59,149 @@
 	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:
+		{
+			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));				
+			
+			s_con->id = g_strdup (conf->name);
+			s_con->type = g_strdup (NM_SETTING_GSM_SETTING_NAME);
+			s_con->autoconnect = FALSE;
+			
+			/* Serial setting */
+			s_serial = (NMSettingSerial *) nm_setting_serial_new ();
+			s_serial->baud = 115200;
+			s_serial->bits = 8;
+			s_serial->parity = 'n';
+			s_serial->stopbits = 1;
+			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 ());
+			s_gsm->number = g_strdup ("*99***1#");
+	
+			s_gsm->apn = g_strdup (conf->provider->gsm.apn);
+	
+			s_gsm->username = g_strdup (conf->provider->username);
+			s_gsm->password = g_strdup (conf->provider->password);
+			
+			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 GSM network connection")
 
 static NMConnection *
@@ -64,7 +214,50 @@
 	NMSettingSerial *s_serial;
 	NMSettingPPP *s_ppp;
 	NMSettingConnection *s_con;
-
+	
+#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 ());
@@ -91,6 +284,8 @@
 	return connection;
 }
 
+
+
 static void
 gsm_menu_item_activate (GtkMenuItem *item, gpointer user_data)
 {
@@ -145,9 +340,15 @@
                              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);
@@ -287,6 +488,58 @@
 	}
 }
 
+#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,
@@ -604,6 +857,10 @@
 	dclass->get_icon = gsm_get_icon;
 	dclass->get_secrets = gsm_get_secrets;
 
+#ifdef WITH_MBCA
+	dclass->device_added = gsm_device_added;
+#endif
+	
 	return dclass;
 }
 
Index: src/applet.c
===================================================================
--- src/applet.c	(revision 859)
+++ src/applet.c	(working copy)
@@ -892,6 +892,53 @@
 	return connection;
 }
 
+#ifdef WITH_MBCA
+gboolean
+applet_open_mbca (NMApplet *applet)
+{
+	if (applet->mbca_module)
+		return TRUE;
+	
+	applet->mbca_module = g_module_open ("libmbca", 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
+
+
 static guint32
 nma_menu_add_devices (GtkWidget *menu, NMApplet *applet)
 {
@@ -2244,6 +2291,21 @@
 {
 	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
+	
 	if (applet->update_timestamps_id)
 		g_source_remove (applet->update_timestamps_id);
 
@@ -2286,6 +2348,11 @@
 	applet->icon_theme = NULL;
 	applet->notification = NULL;
 	applet->size = -1;
+
+#ifdef WITH_MBCA
+	applet->mbca_assistants = NULL;
+	applet->mbca_module = NULL;
+#endif 
 }
 
 static void nma_class_init (NMAppletClass *klass)
Index: src/applet.h
===================================================================
--- src/applet.h	(revision 859)
+++ src/applet.h	(working copy)
@@ -48,6 +48,10 @@
 #include <nm-active-connection.h>
 #include <nm-dbus-settings.h>
 
+#ifdef WITH_MBCA
+#include <mbca_assistant.h>
+#endif
+
 #include "applet-dbus-manager.h"
 #include "nma-gconf-settings.h"
 
@@ -58,8 +62,16 @@
 #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;
 } NMAppletClass; 
 
@@ -141,6 +153,20 @@
 
 	GladeXML *		info_dialog_xml;
 	NotifyNotification*	notification;
+	
+#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;
 
 
@@ -192,5 +218,9 @@
 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
Index: src/connection-editor/nm-connection-list.c
===================================================================
--- src/connection-editor/nm-connection-list.c	(revision 859)
+++ src/connection-editor/nm-connection-list.c	(working copy)
@@ -56,6 +56,13 @@
 #include <nm-setting-serial.h>
 #include <nm-vpn-plugin-ui-interface.h>
 
+#ifdef WITH_MBCA
+#include <netinet/in.h>
+#include <arpa/inet.h>
+#include <nm-setting-ip4-config.h>
+#include <nm-utils.h>
+#endif
+
 #include "nm-connection-editor.h"
 #include "nm-connection-list.h"
 #include "gconf-helpers.h"
@@ -105,6 +112,42 @@
 	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", 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)
 {
@@ -730,6 +773,127 @@
 	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;
+		
+	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 ();
+		
+		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);
+			
+		s_con->id = g_strdup (conf->name);
+		s_con->autoconnect = FALSE;
+
+		add_default_serial_setting (connection);
+
+		method = NM_SETTING_IP4_CONFIG_METHOD_AUTO;
+
+		if (conf->provider->type == MBCA_NETWORK_GSM) {
+			NMSettingGsm *s_gsm;
+			
+			s_con->type = g_strdup (NM_SETTING_GSM_SETTING_NAME);
+	
+			type_setting = nm_setting_gsm_new ();
+			s_gsm = NM_SETTING_GSM (type_setting);
+			s_gsm->number = g_strdup ("*99***1#"); 
+			
+			s_gsm->apn = g_strdup (conf->provider->gsm.apn);
+		
+			s_gsm->username = g_strdup (conf->provider->username);
+			s_gsm->password = g_strdup (conf->provider->password);
+			
+
+			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;
+			
+			s_con->type = g_strdup (NM_SETTING_CDMA_SETTING_NAME);
+			
+			type_setting = nm_setting_cdma_new ();
+			s_cdma = NM_SETTING_CDMA (type_setting);
+			s_cdma->number = g_strdup ("#777"); /* De-facto standard for CDMA */
+
+			s_cdma->username = g_strdup (conf->provider->username);
+			s_cdma->password = g_strdup (conf->provider->password);
+		}
+		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, 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)
 {
@@ -738,7 +902,11 @@
 	NMSettingConnection *s_con;
 	NMSetting *type_setting = NULL;
 	GType mb_type;
-
+#ifdef WITH_MBCA
+	MBCAAssistant *assistant = NULL;
+#endif
+	gboolean use_mbca = FALSE;
+	
 	ctype = nm_connection_lookup_setting_type (connection_type);
 
 	connection = nm_connection_new ();
@@ -762,41 +930,66 @@
 		s_wireless = NM_SETTING_WIRELESS (type_setting);
 		s_wireless->mode = g_strdup ("infrastructure");
 	} 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;
+		
+#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;
 
-			s_con->id = get_next_available_name (list, _("GSM connection %d"));
-			s_con->type = g_strdup (NM_SETTING_GSM_SETTING_NAME);
-			s_con->autoconnect = FALSE;
+				s_con->id = get_next_available_name (list, _("GSM connection %d"));
+				s_con->type = g_strdup (NM_SETTING_GSM_SETTING_NAME);
+				s_con->autoconnect = FALSE;
 
-			add_default_serial_setting (connection);
+				add_default_serial_setting (connection);
 
-			type_setting = nm_setting_gsm_new ();
-			s_gsm = NM_SETTING_GSM (type_setting);
-			s_gsm->number = g_strdup ("*99#"); /* De-facto standard for GSM */
+				type_setting = nm_setting_gsm_new ();
+				s_gsm = NM_SETTING_GSM (type_setting);
+				s_gsm->number = g_strdup ("*99#"); /* De-facto standard for GSM */
 
-			nm_connection_add_setting (connection, nm_setting_ppp_new ());
-		} else if (mb_type == NM_TYPE_SETTING_CDMA) {
-			NMSettingCdma *s_cdma;
+				nm_connection_add_setting (connection, nm_setting_ppp_new ());
+			} else if (mb_type == NM_TYPE_SETTING_CDMA) {
+				NMSettingCdma *s_cdma;
 
-			s_con->id = get_next_available_name (list, _("CDMA connection %d"));
-			s_con->type = g_strdup (NM_SETTING_CDMA_SETTING_NAME);
-			s_con->autoconnect = FALSE;
+				s_con->id = get_next_available_name (list, _("CDMA connection %d"));
+				s_con->type = g_strdup (NM_SETTING_CDMA_SETTING_NAME);
+				s_con->autoconnect = FALSE;
 
-			add_default_serial_setting (connection);
+				add_default_serial_setting (connection);
 
-			type_setting = nm_setting_cdma_new ();
-			s_cdma = NM_SETTING_CDMA (type_setting);
-			s_cdma->number = g_strdup ("#777"); /* De-facto standard for CDMA */
+				type_setting = nm_setting_cdma_new ();
+				s_cdma = NM_SETTING_CDMA (type_setting);
+				s_cdma->number = g_strdup ("#777"); /* De-facto standard for CDMA */
 
-			nm_connection_add_setting (connection, nm_setting_ppp_new ());
-		} else {
-			/* user canceled; do nothing */
+				nm_connection_add_setting (connection, nm_setting_ppp_new ());
+			} else {
+				/* user canceled; do nothing */
+			}	
 		}
+		
 	} else if (ctype == NM_TYPE_SETTING_VPN) {
 		char *service = NULL;
 
@@ -1170,6 +1363,10 @@
 nm_connection_list_init (NMConnectionList *list)
 {
 	list->treeviews = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, NULL);
+
+#ifdef WITH_MBCA
+	list->mbca_module = NULL;
+#endif
 }
 
 static void
@@ -1209,6 +1406,11 @@
 	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);
 }
 
Index: src/connection-editor/nm-connection-list.h
===================================================================
--- src/connection-editor/nm-connection-list.h	(revision 859)
+++ src/connection-editor/nm-connection-list.h	(working copy)
@@ -32,6 +32,10 @@
 #include <nm-dbus-settings-system.h>
 #include "nma-gconf-settings.h"
 
+#ifdef WITH_MBCA
+#include <mbca_assistant.h>
+#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))
@@ -56,6 +60,16 @@
 	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 {
Index: src/connection-editor/nm-connection-editor.c
===================================================================
--- src/connection-editor/nm-connection-editor.c	(revision 859)
+++ src/connection-editor/nm-connection-editor.c	(working copy)
@@ -344,6 +344,7 @@
 			 !strcmp (s_con->type, NM_SETTING_CDMA_SETTING_NAME)) {
 		add_page (editor, CE_PAGE (ce_page_mobile_new (editor->connection)));
 		add_page (editor, CE_PAGE (ce_page_ppp_new (editor->connection)));
+		add_page (editor, CE_PAGE (ce_page_ip4_new (editor->connection)));
 	} else {
 		g_warning ("Unhandled setting type '%s'", s_con->type);
 	}
Index: configure.ac
===================================================================
--- configure.ac	(revision 859)
+++ configure.ac	(working copy)
@@ -213,6 +213,16 @@
 	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

Attachment: signature.asc
Description: Digitaalisesti allekirjoitettu viestin osa



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]