summary refs log tree commit diff
path: root/src/modem-manager/nm-modem-cdma.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/modem-manager/nm-modem-cdma.c')
-rw-r--r--src/modem-manager/nm-modem-cdma.c55
1 files changed, 19 insertions, 36 deletions
diff --git a/src/modem-manager/nm-modem-cdma.c b/src/modem-manager/nm-modem-cdma.c
index 5db6a84f..fa19a342 100644
--- a/src/modem-manager/nm-modem-cdma.c
+++ b/src/modem-manager/nm-modem-cdma.c
@@ -27,11 +27,13 @@
 #include "nm-dbus-glib-types.h"
 #include "nm-modem-cdma.h"
 #include "nm-modem-types.h"
+#include "nm-enum-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-ppp.h"
 #include "NetworkManagerUtils.h"
 #include "nm-logging.h"
 
@@ -46,14 +48,7 @@ typedef struct {
 } NMModemCdmaPrivate;
 
 
-typedef enum {
-	NM_CDMA_ERROR_CONNECTION_NOT_CDMA = 0,
-	NM_CDMA_ERROR_CONNECTION_INVALID,
-	NM_CDMA_ERROR_CONNECTION_INCOMPATIBLE,
-} NMCdmaError;
-
 #define NM_CDMA_ERROR (nm_cdma_error_quark ())
-#define NM_TYPE_CDMA_ERROR (nm_cdma_error_get_type ())
 
 static GQuark
 nm_cdma_error_quark (void)
@@ -64,29 +59,6 @@ nm_cdma_error_quark (void)
 	return quark;
 }
 
-/* This should really be standard. */
-#define ENUM_ENTRY(NAME, DESC) { NAME, "" #NAME "", DESC }
-
-static GType
-nm_cdma_error_get_type (void)
-{
-	static GType etype = 0;
-
-	if (etype == 0) {
-		static const GEnumValue values[] = {
-			/* Connection was not a CDMA connection. */
-			ENUM_ENTRY (NM_CDMA_ERROR_CONNECTION_NOT_CDMA, "ConnectionNotCdma"),
-			/* Connection was not a valid CDMA connection. */
-			ENUM_ENTRY (NM_CDMA_ERROR_CONNECTION_INVALID, "ConnectionInvalid"),
-			/* Connection does not apply to this device. */
-			ENUM_ENTRY (NM_CDMA_ERROR_CONNECTION_INCOMPATIBLE, "ConnectionIncompatible"),
-			{ 0, 0, 0 }
-		};
-		etype = g_enum_register_static ("NMCdmaError", values);
-	}
-	return etype;
-}
-
 
 NMModem *
 nm_modem_cdma_new (const char *path,
@@ -169,7 +141,7 @@ create_connect_properties (NMConnection *connection)
 	GHashTable *properties;
 	const char *str;
 
-	setting = NM_SETTING_CDMA (nm_connection_get_setting (connection, NM_TYPE_SETTING_CDMA));
+	setting = nm_connection_get_setting_cdma (connection);
 	properties = value_hash_create ();
 
 	str = nm_setting_cdma_get_number (setting);
@@ -230,7 +202,7 @@ real_get_best_auto_connection (NMModem *modem,
 		NMConnection *connection = NM_CONNECTION (iter->data);
 		NMSettingConnection *s_con;
 
-		s_con = (NMSettingConnection *) nm_connection_get_setting (connection, NM_TYPE_SETTING_CONNECTION);
+		s_con = nm_connection_get_setting_connection (connection);
 		g_assert (s_con);
 
 		if (!nm_setting_connection_get_autoconnect (s_con))
@@ -252,7 +224,7 @@ real_check_connection_compatible (NMModem *modem,
 	NMSettingConnection *s_con;
 	NMSettingCdma *s_cdma;
 
-	s_con = NM_SETTING_CONNECTION (nm_connection_get_setting (connection, NM_TYPE_SETTING_CONNECTION));
+	s_con = nm_connection_get_setting_connection (connection);
 	g_assert (s_con);
 
 	if (strcmp (nm_setting_connection_get_connection_type (s_con), NM_SETTING_CDMA_SETTING_NAME)) {
@@ -262,7 +234,7 @@ real_check_connection_compatible (NMModem *modem,
 		return FALSE;
 	}
 
-	s_cdma = NM_SETTING_CDMA (nm_connection_get_setting (connection, NM_TYPE_SETTING_CDMA));
+	s_cdma = nm_connection_get_setting_cdma (connection);
 	if (!s_cdma) {
 		g_set_error (error,
 		             NM_CDMA_ERROR, NM_CDMA_ERROR_CONNECTION_INVALID,
@@ -280,8 +252,9 @@ real_complete_connection (NMModem *modem,
                           GError **error)
 {
 	NMSettingCdma *s_cdma;
+	NMSettingPPP *s_ppp;
 
-	s_cdma = (NMSettingCdma *) nm_connection_get_setting (connection, NM_TYPE_SETTING_CDMA);
+	s_cdma = nm_connection_get_setting_cdma (connection);
 	if (!s_cdma) {
 		s_cdma = (NMSettingCdma *) nm_setting_cdma_new ();
 		nm_connection_add_setting (connection, NM_SETTING (s_cdma));
@@ -290,6 +263,16 @@ 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);
 
+	s_ppp = nm_connection_get_setting_ppp (connection);
+	if (!s_ppp) {
+		s_ppp = (NMSettingPPP *) nm_setting_ppp_new ();
+		g_object_set (G_OBJECT (s_ppp),
+		              NM_SETTING_PPP_LCP_ECHO_FAILURE, 5,
+		              NM_SETTING_PPP_LCP_ECHO_INTERVAL, 30,
+		              NULL);
+		nm_connection_add_setting (connection, NM_SETTING (s_ppp));
+	}
+
 	nm_utils_complete_generic (connection,
 	                           NM_SETTING_CDMA_SETTING_NAME,
 	                           existing_connections,
@@ -308,7 +291,7 @@ real_get_user_pass (NMModem *modem,
 {
 	NMSettingCdma *s_cdma;
 
-	s_cdma = (NMSettingCdma *) nm_connection_get_setting (connection, NM_TYPE_SETTING_CDMA);
+	s_cdma = nm_connection_get_setting_cdma (connection);
 	if (!s_cdma)
 		return FALSE;