[PATCH] [ModemManager] Report errors from the GSM Register operation

2011-08-08 Thread Eric Shienbrood
Register was appearing to succeed even when it failed.
From 124157f2f9142739a1fe325c9063f272b664f2ab Mon Sep 17 00:00:00 2001
From: Eric Shienbrood 
Date: Mon, 8 Aug 2011 18:01:27 -0400
Subject: [PATCH] gsm: pass GSM Register errors up to caller

---
 src/mm-generic-gsm.c |2 ++
 1 files changed, 2 insertions(+), 0 deletions(-)

diff --git a/src/mm-generic-gsm.c b/src/mm-generic-gsm.c
index c41ecf9..7266575 100644
--- a/src/mm-generic-gsm.c
+++ b/src/mm-generic-gsm.c
@@ -3044,6 +3044,8 @@ register_done (MMAtSerialPort *port,
 
 if (priv->pending_reg_info) {
 g_warn_if_fail (info == priv->pending_reg_info);
+if (error)
+info->error = g_error_copy(error);
 
 /* Don't use cached registration state here since it could be up to
  * 30 seconds old.  Get fresh registration state.
-- 
1.7.3.1

___
networkmanager-list mailing list
networkmanager-list@gnome.org
http://mail.gnome.org/mailman/listinfo/networkmanager-list


[MM] [PATCH] sms_get_done(): Check for the correct return value from sscanf()

2011-08-08 Thread Nathan Williams
The "%n" format in sscanf() is tricky; it's best avoided if we don't
actually need it.

(dropped through the cracks of my upstreaming process a little while ago, sorry)

- Nathan
From fc3f0e40f1c7196f38789f585dca98f22fb13601 Mon Sep 17 00:00:00 2001
From: Nathan Williams 
Date: Fri, 24 Jun 2011 21:12:00 -0400
Subject: [PATCH] sms_get_done(): Check for the correct return value from sscanf().

Remove an unused variable so it's more obvious what the correct value is.
Fixes live (vs. list) SMS reception on ToT.

BUG=none
TEST=Send SMS to device, see that it shows up in Chrome.

Change-Id: I9c76fb15ef229fe83672e2eee8ae37d7e6ab7b9e
Reviewed-on: http://gerrit.chromium.org/gerrit/3216
Reviewed-by: Nathan J. Williams 
Tested-by: Nathan J. Williams 
---
 src/mm-generic-gsm.c |8 
 1 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/src/mm-generic-gsm.c b/src/mm-generic-gsm.c
index 8e18222..3f7c9ab 100644
--- a/src/mm-generic-gsm.c
+++ b/src/mm-generic-gsm.c
@@ -4472,7 +4472,7 @@ sms_get_done (MMAtSerialPort *port,
 {
 MMCallbackInfo *info = (MMCallbackInfo *) user_data;
 GHashTable *properties;
-int rv, status, tpdu_len, offset;
+int rv, status, tpdu_len;
 char pdu[SMS_MAX_PDU_LEN + 1];
 
 /* If the modem has already been removed, return without
@@ -4486,9 +4486,9 @@ sms_get_done (MMAtSerialPort *port,
 }
 
 /* 344 == SMS_MAX_PDU_LEN */
-rv = sscanf (response->str, "+CMGR: %d,,%d %344s %n",
- &status, &tpdu_len, pdu, &offset);
-if (rv != 4) {
+rv = sscanf (response->str, "+CMGR: %d,,%d %344s",
+ &status, &tpdu_len, pdu);
+if (rv != 3) {
 info->error = g_error_new (MM_MODEM_ERROR,
MM_MODEM_ERROR_GENERAL,
"Failed to parse CMGR response (parsed %d items)",
-- 
1.7.3.1

___
networkmanager-list mailing list
networkmanager-list@gnome.org
http://mail.gnome.org/mailman/listinfo/networkmanager-list


[PATCH] network-manager-vpnc: properties: replace pcf_file_* by glib functions

2011-08-08 Thread Murilo Opsfelder
Replace pcf_file_* functions by the corresponding functions in glib.

Signed-off-by: Murilo Opsfelder Araujo 
---
 properties/Makefile.am |2 -
 properties/nm-vpnc.c   |  201 --
 properties/pcf-file.c  |  287 
 properties/pcf-file.h  |   56 --
 4 files changed, 95 insertions(+), 451 deletions(-)
 delete mode 100644 properties/pcf-file.c
 delete mode 100644 properties/pcf-file.h

diff --git a/properties/Makefile.am b/properties/Makefile.am
index c7d17ad..3d83a55 100644
--- a/properties/Makefile.am
+++ b/properties/Makefile.am
@@ -6,8 +6,6 @@ plugindir = $(libdir)/NetworkManager
 plugin_LTLIBRARIES = libnm-vpnc-properties.la

 libnm_vpnc_properties_la_SOURCES = \
-   pcf-file.c \
-   pcf-file.h \
nm-vpnc.c \
nm-vpnc.h

diff --git a/properties/nm-vpnc.c b/properties/nm-vpnc.c
index 34f4fc0..81025d8 100644
--- a/properties/nm-vpnc.c
+++ b/properties/nm-vpnc.c
@@ -48,7 +48,6 @@
 #include 

 #include "src/nm-vpnc-service.h"
-#include "pcf-file.h"
 #include "nm-vpnc.h"

 #define VPNC_PLUGIN_NAME_("Cisco Compatible VPN (vpnc)")
@@ -1161,15 +1160,17 @@ import (NMVpnPluginUiInterface *iface, const char 
*path, GError **error)
NMConnection *connection;
NMSettingConnection *s_con;
NMSettingVPN *s_vpn;
-   GHashTable *pcf;
-   const char *buf;
+   NMSettingSecretFlags flags = NM_SETTING_SECRET_FLAG_NONE;
+   GKeyFile *keyfile;
+   GKeyFileFlags keyfile_flags;
+   char *buf;
gboolean bool_value;
NMSettingIP4Config *s_ip4;
gint val;
-   gboolean found;

-   pcf = pcf_file_load (path);
-   if (!pcf) {
+   keyfile = g_key_file_new ();
+   keyfile_flags = G_KEY_FILE_KEEP_COMMENTS | G_KEY_FILE_KEEP_TRANSLATIONS;
+   if (!g_key_file_load_from_file (keyfile, path, keyfile_flags, error)) {
g_set_error (error, 0, 0, "does not look like a %s VPN 
connection (parse failed)",
 VPNC_PLUGIN_NAME);
return NULL;
@@ -1187,7 +1188,8 @@ import (NMVpnPluginUiInterface *iface, const char *path, 
GError **error)
nm_connection_add_setting (connection, NM_SETTING (s_ip4));

/* Gateway */
-   if (pcf_file_lookup_string (pcf, "main", "Host", &buf))
+   buf = g_key_file_get_string (keyfile, "main", "Host", error);
+   if (buf)
nm_setting_vpn_add_data_item (s_vpn, NM_VPNC_KEY_GATEWAY, buf);
else {
g_set_error (error, 0, 0, "does not look like a %s VPN 
connection (no Host)",
@@ -1197,7 +1199,8 @@ import (NMVpnPluginUiInterface *iface, const char *path, 
GError **error)
}

/* Group name */
-   if (pcf_file_lookup_string (pcf, "main", "GroupName", &buf))
+   buf = g_key_file_get_string (keyfile, "main", "GroupName", error);
+   if (buf)
nm_setting_vpn_add_data_item (s_vpn, NM_VPNC_KEY_ID, buf);
else {
g_set_error (error, 0, 0, "does not look like a %s VPN 
connection (no GroupName)",
@@ -1209,13 +1212,16 @@ import (NMVpnPluginUiInterface *iface, const char 
*path, GError **error)
/* Optional settings */

/* Connection name */
-   if (pcf_file_lookup_string (pcf, "main", "Description", &buf))
+   buf = g_key_file_get_string (keyfile, "main", "Description", NULL);
+   if (buf)
g_object_set (s_con, NM_SETTING_CONNECTION_ID, buf, NULL);

-   if (pcf_file_lookup_string (pcf, "main", "UserName", &buf))
+   buf = g_key_file_get_string (keyfile, "main", "Username", NULL);
+   if (buf)
nm_setting_vpn_add_data_item (s_vpn, NM_VPNC_KEY_XAUTH_USER, 
buf);

-   if (pcf_file_lookup_string (pcf, "main", "UserPassword", &buf)) {
+   buf = g_key_file_get_string (keyfile, "main", "UserPassword", NULL);
+   if (buf) {
nm_setting_vpn_add_secret (s_vpn, NM_VPNC_KEY_XAUTH_PASSWORD, 
buf);
nm_setting_set_secret_flags (NM_SETTING (s_vpn),
 NM_VPNC_KEY_XAUTH_PASSWORD,
@@ -1223,23 +1229,21 @@ import (NMVpnPluginUiInterface *iface, const char 
*path, GError **error)
 NULL);
}

-   if (pcf_file_lookup_bool (pcf, "main", "SaveUserPassword", 
&bool_value)) {
-   NMSettingSecretFlags flags = NM_SETTING_SECRET_FLAG_AGENT_OWNED;
-
-   if (bool_value) {
-   nm_setting_vpn_add_data_item (s_vpn,
- 
NM_VPNC_KEY_XAUTH_PASSWORD_TYPE,
- NM_VPNC_PW_TYPE_SAVE);
-   } else
-   flags |= NM_SETTING_SECRET_FLAG_NOT_SAVED;
-
-   nm_setting_set_secret_flags (NM_SETTING (s_vpn),
-NM_VPNC_KEY_XAUTH_PASSWORD,
-