NetworkManager r3875 - branches/mbca/src



Author: kaijanma
Date: Thu Jul 31 13:09:38 2008
New Revision: 3875
URL: http://svn.gnome.org/viewvc/NetworkManager?rev=3875&view=rev

Log:
probe V.250 modems

Added:
   branches/mbca/src/probe-modem.h
Modified:
   branches/mbca/src/Makefile.am
   branches/mbca/src/nm-hal-manager.c
   branches/mbca/src/probe-modem.c

Modified: branches/mbca/src/Makefile.am
==============================================================================
--- branches/mbca/src/Makefile.am	(original)
+++ branches/mbca/src/Makefile.am	Thu Jul 31 13:09:38 2008
@@ -70,7 +70,9 @@
 		nm-netlink.c			\
 		nm-netlink.h \
 		nm-dhcp4-config.c \
-		nm-dhcp4-config.h
+		nm-dhcp4-config.h \
+		probe-modem.c \
+		probe-modem.h 
 
 nm-access-point-glue.h: $(top_srcdir)/introspection/nm-access-point.xml
 	dbus-binding-tool --prefix=nm_access_point --mode=glib-server --output=$@ $<

Modified: branches/mbca/src/nm-hal-manager.c
==============================================================================
--- branches/mbca/src/nm-hal-manager.c	(original)
+++ branches/mbca/src/nm-hal-manager.c	Thu Jul 31 13:09:38 2008
@@ -15,6 +15,7 @@
 #include "nm-device-ethernet.h"
 #include "nm-gsm-device.h"
 #include "nm-cdma-device.h"
+#include "probe-modem.h"
 
 /* Killswitch poll frequency in seconds */
 #define RFKILL_POLL_FREQUENCY 6
@@ -231,6 +232,7 @@
 	char **capabilities, **iter;
 	gboolean type_gsm = FALSE;
 	gboolean type_cdma = FALSE;
+	gboolean type_v250 = FALSE;
 
 	serial_device = libhal_device_get_property_string (priv->hal_ctx, udi, "serial.device", NULL);
 
@@ -244,6 +246,7 @@
 	if (!serial_device || !driver_name)
 		goto out;
 
+retry:
 	capabilities = libhal_device_get_property_strlist (priv->hal_ctx, udi, "modem.command_sets", NULL);
 	/* 'capabilites' may be NULL */
 	for (iter = capabilities; iter && *iter; iter++) {
@@ -255,6 +258,10 @@
 			type_cdma = TRUE;
 			break;
 		}
+		if (!strcmp (*iter, "V.250")) {
+			type_v250 = TRUE;
+			/* no break here! */
+		}
 	}
 	g_strfreev (capabilities);
 
@@ -274,6 +281,14 @@
 		g_strfreev (capabilities);
 	}
 
+	/* V.250 probe */
+	if (!type_gsm && !type_cdma && type_v250) {
+		if (probe_modem (serial_device, udi, priv->hal_ctx) == 1) {
+			/* probe changed something */
+			goto retry;
+		}
+	}
+
 	if (type_gsm)
 		device = (GObject *) nm_gsm_device_new (udi, serial_device + strlen ("/dev/"), NULL, driver_name, managed);
 	else if (type_cdma)

Modified: branches/mbca/src/probe-modem.c
==============================================================================
--- branches/mbca/src/probe-modem.c	(original)
+++ branches/mbca/src/probe-modem.c	Thu Jul 31 13:09:38 2008
@@ -19,10 +19,6 @@
  *
  */
 
-#ifdef HAVE_CONFIG_H
-# include <config.h>
-#endif
-
 #include <termios.h>
 #include <unistd.h>
 #include <fcntl.h>
@@ -32,8 +28,9 @@
 #include <string.h>
 #include <stdlib.h>
 
-#include "libhal/libhal.h"
-#include "../../logger.h"
+#include "nm-utils.h"
+#include "probe-modem.h"
+
 
 #define MODEM_CAP_GSM         0x0001 /* GSM commands */
 #define MODEM_CAP_IS707_A     0x0002 /* CDMA circuit switched data commands */
@@ -115,31 +112,15 @@
 	return ret;
 }
 
-int main(int argc, char *argv[])
+int probe_modem (const char* device, const char *udi, LibHalContext *ctx)
 {
 	struct termios orig, attrs;
-	DBusError error;
-	LibHalContext *ctx;
-	char *udi;
-	char *device;
 	int fd, caps;
 
-	setup_logger();
-
-	if ((udi = getenv("UDI")) == NULL) {
-		HAL_ERROR(("UDI is not set"));
-		return -1;
-	}
-	
-	if ((device = getenv("HAL_PROP_SERIAL_DEVICE")) == NULL) {
-		HAL_ERROR(("HAL_PROP_SERIAL_DEVICE is not set"));
-		return -1;
-	}
-
 	fd = open(device, O_RDWR|O_NDELAY);
 
 	if (-1 == fd) {
-		HAL_ERROR(("open(%s): %s", device, strerror(errno)));
+		nm_error("open(%s): %s", device, strerror(errno));
 		return -1;
 	}
 
@@ -160,26 +141,21 @@
 	tcsetattr(fd, TCSANOW, &orig);
 
 	if (caps < 0) {
-		HAL_ERROR(("Couldn't get caps"));
+		nm_debug("Couldn't get caps");
 		return -1;
 	}
 	
-	dbus_error_init (&error);
-
-	if ((ctx = libhal_ctx_init_direct(&error)) == NULL) {
-		HAL_ERROR(("ctx init failed"));
-		return -1;
-	}
-
 	if (caps & MODEM_CAP_GSM) {
-		HAL_DEBUG(("Found GSM modem"));
+		nm_debug("Found GSM modem");
 		libhal_device_property_strlist_append(ctx, udi, "modem.command_sets", "GSM-07.07", NULL);
 		libhal_device_property_strlist_append(ctx, udi, "modem.command_sets", "GSM-07.05", NULL);
+		return 1;
 	}
 	
 	if (caps & MODEM_CAP_IS707_A) {
-		HAL_DEBUG(("Found CDMA modem"));
+		nm_debug("Found CDMA modem");
 		libhal_device_property_strlist_append(ctx, udi, "modem.command_sets", "IS-707-A", NULL);
+		return 1;
 	}
 	
 	return 0;

Added: branches/mbca/src/probe-modem.h
==============================================================================
--- (empty file)
+++ branches/mbca/src/probe-modem.h	Thu Jul 31 13:09:38 2008
@@ -0,0 +1,29 @@
+/* Copyright (c) 2008 Antti KaijanmÃki, <antti kaijanmaki net>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ *
+ */
+
+#ifndef PROBE_MODEM_H
+#define PROBE_MODEM_H
+
+
+#include <glib.h>
+#include <libhal.h>
+
+/* returns '1' if properties were changed */
+int probe_modem (const char* device, const char* udi, LibHalContext *ctx);
+
+#endif /* PROBE_MODEM_H */



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