Hi Everyone,

Could you please overview and accept following patches (1 is non
functional which I've sent to Klaus yesterday).  patch should remove any
symbol from the number before sending the query to initiate the call...

I don't have chain ready to build it for phone, but built fine on
desktop so should be fine? ;)  Also I am not sure if location of
phone # filtering is the best , and it would be great if similar would
be adopted for matching numbers in the phone calls log book.

Thanks in advance

On Mon, 21 Jun 2010, Yaroslav Halchenko wrote:

> Hi guys,

> It has been a while since I've been observing this but finally decided
> to email after the last upgrade today.

> I have my contacts synced from gmail using PISI (Thank you Michael), I
> am using SHR, and I have somewhat a variety of formats for numbers
> specifications, e.g.

> 2345678900
> (234) 567-8900
> +1 (234) 567-8900

> etc

> the problem is, that it seems that  if there is any non-digit in the
> phone #, it fails to actually initiate the call. e.g. here is example --
> I've called contact with only numbers in phone #, then added a space
> after 1 - and it failed to call:
-- 
                                  .-.
=------------------------------   /v\  ----------------------------=
Keep in touch                    // \\     (yoh@|www.)onerussian.com
Yaroslav Halchenko              /(   )\               ICQ#: 60653192
                   Linux User    ^^-^^    [175555]


From 2aeea757dc8ac787cee4f50f9c753bb7815b1d37 Mon Sep 17 00:00:00 2001
From: Yaroslav Halchenko <deb...@onerussian.com>
Date: Mon, 21 Jun 2010 16:02:23 -0400
Subject: [PATCH 1/2] ENH: non-functional -- tabs, "Initi[t]ating" spelling

---
 src/phoneui-utils-calls.c    |    6 +++---
 src/phoneui-utils-contacts.c |    2 +-
 src/phoneui-utils-sound.c    |   42 +++++++++++++++++++++---------------------
 3 files changed, 25 insertions(+), 25 deletions(-)

diff --git a/src/phoneui-utils-calls.c b/src/phoneui-utils-calls.c
index 12833fd..12e8a5a 100644
--- a/src/phoneui-utils-calls.c
+++ b/src/phoneui-utils-calls.c
@@ -35,7 +35,7 @@ _call_initiate_callback(GObject *source, GAsyncResult *res, gpointer data)
 	int callid;
 	struct _call_pack *pack = data;
 
-        callid = free_smartphone_gsm_call_initiate_finish
+	callid = free_smartphone_gsm_call_initiate_finish
 					(pack->call, res, &error);
 	if (pack->callback) {
 		pack->callback(error, callid, pack->data);
@@ -54,7 +54,7 @@ phoneui_utils_call_initiate(const char *number,
 {
 	struct _call_pack *pack;
 
-	g_message("Inititating a call to %s\n", number);
+	g_message("Initiating a call to %s\n", number);
 	pack = malloc(sizeof(*pack));
 	pack->callback = callback;
 	pack->data = userdata;
@@ -251,7 +251,7 @@ phoneui_utils_ussd_initiate(const char *request,
 {
 	struct _network_pack *pack;
 
-	g_message("Inititating a USSD request %s\n", request);
+	g_message("Initiating a USSD request %s\n", request);
 	pack = malloc(sizeof(*pack));
 	pack->callback = callback;
 	pack->data = data;
diff --git a/src/phoneui-utils-contacts.c b/src/phoneui-utils-contacts.c
index e4563e8..fe6a5f5 100644
--- a/src/phoneui-utils-contacts.c
+++ b/src/phoneui-utils-contacts.c
@@ -346,7 +346,7 @@ _contact_lookup_callback(GObject *source, GAsyncResult *res, gpointer data)
 	g_debug("_contact_lookup_callback");
 	path = free_smartphone_pim_contacts_get_single_entry_single_field_finish
 					(pack->contacts, res, &error);
-        g_debug("got path %s", path);
+	g_debug("got path %s", path);
 	if (error || !path || !*path) {
 		pack->callback(error, NULL, pack->data);
 		if (error) {
diff --git a/src/phoneui-utils-sound.c b/src/phoneui-utils-sound.c
index 3c34794..4b08c60 100644
--- a/src/phoneui-utils-sound.c
+++ b/src/phoneui-utils-sound.c
@@ -556,13 +556,13 @@ phoneui_utils_sound_init(GKeyFile *keyfile)
 	int err, f;
 	char *device_name;
 	static GSourceFuncs funcs = {
-                _sourcefunc_prepare,
-                _sourcefunc_check,
-                _sourcefunc_dispatch,
-                0,
+		_sourcefunc_prepare,
+		_sourcefunc_check,
+		_sourcefunc_dispatch,
+		0,
 		0,
 		0
-        };
+	};
 
 
 	sound_state = SOUND_STATE_IDLE;
@@ -714,13 +714,13 @@ _phoneui_utils_sound_volume_changed_cb(snd_hctl_elem_t *elem, unsigned int mask)
 	int volume;
 
 
-        if (mask == SND_CTL_EVENT_MASK_REMOVE)
-                return 0;
-        if (mask & SND_CTL_EVENT_MASK_VALUE) {
-                snd_ctl_elem_value_alloca(&control);
-                snd_hctl_elem_read(elem, control);
-                type = _phoneui_utils_sound_volume_element_to_type(elem);
-                if (type != CONTROL_END) {
+	if (mask == SND_CTL_EVENT_MASK_REMOVE)
+		return 0;
+	if (mask & SND_CTL_EVENT_MASK_VALUE) {
+		snd_ctl_elem_value_alloca(&control);
+		snd_hctl_elem_read(elem, control);
+		type = _phoneui_utils_sound_volume_element_to_type(elem);
+		if (type != CONTROL_END) {
 			volume = phoneui_utils_sound_volume_get(type);
 			g_debug("Got alsa volume change for control '%s', new value: %d%%",
 				controls[STATE_INDEX][type].name, volume);
@@ -728,7 +728,7 @@ _phoneui_utils_sound_volume_changed_cb(snd_hctl_elem_t *elem, unsigned int mask)
 				_phoneui_utils_sound_volume_changed_callback(type, volume, _phoneui_utils_sound_volume_changed_userdata);
 			}
 		}
-        }
+	}
 	return 0;
 }
 
@@ -740,13 +740,13 @@ _phoneui_utils_sound_volume_mute_changed_cb(snd_hctl_elem_t *elem, unsigned int
 	int mute;
 
 
-        if (mask == SND_CTL_EVENT_MASK_REMOVE)
-                return 0;
-        if (mask & SND_CTL_EVENT_MASK_VALUE) {
-                snd_ctl_elem_value_alloca(&control);
-                snd_hctl_elem_read(elem, control);
-                type = _phoneui_utils_sound_volume_mute_element_to_type(elem);
-                if (type != CONTROL_END) {
+	if (mask == SND_CTL_EVENT_MASK_REMOVE)
+		return 0;
+	if (mask & SND_CTL_EVENT_MASK_VALUE) {
+		snd_ctl_elem_value_alloca(&control);
+		snd_hctl_elem_read(elem, control);
+		type = _phoneui_utils_sound_volume_mute_element_to_type(elem);
+		if (type != CONTROL_END) {
 			mute = phoneui_utils_sound_volume_mute_get(type);
 			g_debug("Got alsa mute change for control type '%d', new value: %d",
 				type, mute);
@@ -754,7 +754,7 @@ _phoneui_utils_sound_volume_mute_changed_cb(snd_hctl_elem_t *elem, unsigned int
 				_phoneui_utils_sound_volume_mute_changed_callback(type, mute, _phoneui_utils_sound_volume_mute_changed_userdata);
 			}
 		}
-        }
+	}
 	return 0;
 }
 int
-- 
1.7.1

From a4b7931815c7e1ee61280e21c408ef839db1f5eb Mon Sep 17 00:00:00 2001
From: Yaroslav Halchenko <deb...@onerussian.com>
Date: Tue, 22 Jun 2010 14:52:19 -0400
Subject: [PATCH 2/2] ENH: adding filtering of phone # off illegal symbols before sending to gsm

---
 src/helpers.c             |   16 ++++++++++++++++
 src/helpers.h             |    2 ++
 src/phoneui-utils-calls.c |    5 ++++-
 3 files changed, 22 insertions(+), 1 deletions(-)

diff --git a/src/helpers.c b/src/helpers.c
index 92d87e3..1dc4a1c 100644
--- a/src/helpers.c
+++ b/src/helpers.c
@@ -1,5 +1,6 @@
 
 #include <stdlib.h>
+#include <string.h>
 #include <glib.h>
 #include <glib-object.h>
 
@@ -49,3 +50,18 @@ _helpers_free_gvalue(gpointer val)
 	g_value_unset(value);
 	g_free(value);
 }
+
+void
+_helpers_strfilter(const char* s, const char *valid_chars, char** res)
+// remove occurrences of illegal symbols, return a new string
+{
+	if (!s) return;
+	*res = malloc(strlen(s)+1);
+	int k=0;						// index in res
+	while (s && *s) {
+		if (index(valid_chars, *s))
+			(*res)[k++] = *s;
+		s++;
+	}
+	(*res)[k] = 0;
+}
diff --git a/src/helpers.h b/src/helpers.h
index 945a506..115e2df 100644
--- a/src/helpers.h
+++ b/src/helpers.h
@@ -9,4 +9,6 @@ GValue *_helpers_new_gvalue_int(int value);
 GValue *_helpers_new_gvalue_boolean(gboolean value);
 void _helpers_free_gvalue(gpointer value);
 
+void _helpers_strfilter(const char* s, const char *valid_chars, char** res);
+
 #endif
diff --git a/src/phoneui-utils-calls.c b/src/phoneui-utils-calls.c
index 12e8a5a..1cf38b8 100644
--- a/src/phoneui-utils-calls.c
+++ b/src/phoneui-utils-calls.c
@@ -53,7 +53,9 @@ phoneui_utils_call_initiate(const char *number,
 			    gpointer userdata)
 {
 	struct _call_pack *pack;
+	char * number_ = NULL;		// Filtered phone #
 
+	_helpers_strfilter(number, "0123456789pP#*+wW", &number_);
 	g_message("Initiating a call to %s\n", number);
 	pack = malloc(sizeof(*pack));
 	pack->callback = callback;
@@ -61,8 +63,9 @@ phoneui_utils_call_initiate(const char *number,
 	pack->call = free_smartphone_gsm_get_call_proxy(_dbus(),
 					FSO_FRAMEWORK_GSM_ServiceDBusName,
 					FSO_FRAMEWORK_GSM_DeviceServicePath);
-	free_smartphone_gsm_call_initiate(pack->call, number, "voice",
+	free_smartphone_gsm_call_initiate(pack->call, number_, "voice",
 					  _call_initiate_callback, pack);
+	free(number_);
 	return 0;
 }
 
-- 
1.7.1

Attachment: signature.asc
Description: Digital signature

_______________________________________________
Openmoko community mailing list
community@lists.openmoko.org
http://lists.openmoko.org/mailman/listinfo/community

Reply via email to