Open Source Telephony
 help / color / mirror / Atom feed
* [PATCH 0/7] Add enum called_number_type
@ 2011-01-23 10:16 George Matveev
  2011-01-23 10:16 ` [PATCH 1/7] src: Introduced " George Matveev
                   ` (5 more replies)
  0 siblings, 6 replies; 8+ messages in thread
From: George Matveev @ 2011-01-23 10:16 UTC (permalink / raw)
  To: ofono

[-- Attachment #1: Type: text/plain, Size: 1365 bytes --]

This patch series adds enumeration called_number_type
based on 3GPP TS 24.008, section 10.5.4.7.
Elements of this enum is to be used whenever phone type
is required, replacing numbers 129, 145 used previously
ad hock throughout the code. 

George Matveev (7):
  src: Introduced enum called_number_type
  atmodem: Phone type defined using enum called_number_type
  huaweimodem: Phone type defined using enum called_number_type
  hfpmodem: Phone type defined using enum called_number_type
  ifxmodem: Phone type defined using enum called_number_type
  calypsomodem: Phone type defined using enum called_number_type
  stemodem: Phone type defined using enum called_number_type

 drivers/atmodem/atutil.c          |    3 ++-
 drivers/atmodem/call-forwarding.c |    3 ++-
 drivers/atmodem/ssn.c             |    3 ++-
 drivers/atmodem/voicecall.c       |    2 +-
 drivers/calypsomodem/voicecall.c  |    3 ++-
 drivers/hfpmodem/voicecall.c      |    2 +-
 drivers/huaweimodem/voicecall.c   |    3 ++-
 drivers/ifxmodem/voicecall.c      |    3 ++-
 drivers/stemodem/voicecall.c      |    2 +-
 src/call-forwarding.c             |    2 +-
 src/common.c                      |    8 ++++----
 src/common.h                      |   10 ++++++++++
 src/phonebook.c                   |    3 +--
 13 files changed, 31 insertions(+), 16 deletions(-)


^ permalink raw reply	[flat|nested] 8+ messages in thread

* [PATCH 1/7] src: Introduced enum called_number_type
  2011-01-23 10:16 [PATCH 0/7] Add enum called_number_type George Matveev
@ 2011-01-23 10:16 ` George Matveev
  2011-01-24 22:19   ` Denis Kenzior
  2011-01-23 10:16 ` [PATCH 2/7] atmodem: Phone type defined using " George Matveev
                   ` (4 subsequent siblings)
  5 siblings, 1 reply; 8+ messages in thread
From: George Matveev @ 2011-01-23 10:16 UTC (permalink / raw)
  To: ofono

[-- Attachment #1: Type: text/plain, Size: 2949 bytes --]

Based on 24.008 section 10.5.4.7 enum called_number_type
is to be used when phone number type is required.
---
 src/call-forwarding.c |    2 +-
 src/common.c          |    8 ++++----
 src/common.h          |   10 ++++++++++
 src/phonebook.c       |    3 +--
 4 files changed, 16 insertions(+), 7 deletions(-)

diff --git a/src/call-forwarding.c b/src/call-forwarding.c
index 512f223..b9e6633 100644
--- a/src/call-forwarding.c
+++ b/src/call-forwarding.c
@@ -791,7 +791,7 @@ static DBusMessage *cf_set_property(DBusConnection *conn, DBusMessage *msg,
 		int timeout;
 
 		ph.number[0] = '\0';
-		ph.type = 129;
+		ph.type = CALLED_NUMBER_TYPE_UNKNOWN;
 
 		if (dbus_message_iter_get_arg_type(&var) != DBUS_TYPE_STRING)
 			return __ofono_error_invalid_args(msg);
diff --git a/src/common.c b/src/common.c
index 4d93488..44bc925 100644
--- a/src/common.c
+++ b/src/common.c
@@ -405,8 +405,8 @@ const char *phone_number_to_string(const struct ofono_phone_number *ph)
 {
 	static char buffer[64];
 
-	if (ph->type == 145 && (strlen(ph->number) > 0) &&
-			ph->number[0] != '+') {
+	if (ph->type == CALLED_NUMBER_TYPE_INTERNATIONAL &&
+		(strlen(ph->number) > 0) && ph->number[0] != '+') {
 		buffer[0] = '+';
 		strncpy(buffer + 1, ph->number, 62);
 		buffer[63] = '\0';
@@ -422,10 +422,10 @@ void string_to_phone_number(const char *str, struct ofono_phone_number *ph)
 {
 	if (str[0] == '+') {
 		strcpy(ph->number, str+1);
-		ph->type = 145;	/* International */
+		ph->type = CALLED_NUMBER_TYPE_INTERNATIONAL;
 	} else {
 		strcpy(ph->number, str);
-		ph->type = 129;	/* Local */
+		ph->type = CALLED_NUMBER_TYPE_UNKNOWN;
 	}
 }
 
diff --git a/src/common.h b/src/common.h
index 5edff49..a019231 100644
--- a/src/common.h
+++ b/src/common.h
@@ -135,6 +135,16 @@ enum context_status {
 	CONTEXT_STATUS_ACTIVATED = 1,
 };
 
+/* 24.008 Section 10.5.4.7 Called party BCD number */
+enum called_number_type {
+	CALLED_NUMBER_TYPE_UNKNOWN = 0,
+	CALLED_NUMBER_TYPE_INTERNATIONAL = 1,
+	CALLED_NUMBER_TYPE_NATIONAL = 2,
+	CALLED_NUMBER_TYPE_NETWORK_SPECIFIC = 3,
+	CALLED_NUMBER_TYPE_DEDICATED_ACCESS = 4,
+	CALLED_NUMBER_TYPE_RESERVED = 7
+};
+
 const char *telephony_error_to_str(const struct ofono_error *error);
 
 gboolean valid_phone_number_format(const char *number);
diff --git a/src/phonebook.c b/src/phonebook.c
index e388ac1..cf33e00 100644
--- a/src/phonebook.c
+++ b/src/phonebook.c
@@ -38,7 +38,6 @@
 #include "common.h"
 
 #define LEN_MAX 128
-#define TYPE_INTERNATIONAL 145
 
 #define PHONEBOOK_FLAG_CACHED 0x1
 
@@ -176,7 +175,7 @@ static void vcard_printf_number(GString *vcards, const char *number, int type,
 		break;
 	}
 
-	if ((type == TYPE_INTERNATIONAL) && (number[0] != '+'))
+	if ((type == CALLED_NUMBER_TYPE_INTERNATIONAL) && (number[0] != '+'))
 		intl = "+";
 
 	snprintf(buf, sizeof(buf), "TEL;TYPE=\%s%s:\%s\%s", pref,
-- 
1.5.6.5


^ permalink raw reply related	[flat|nested] 8+ messages in thread

* [PATCH 2/7] atmodem: Phone type defined using enum called_number_type
  2011-01-23 10:16 [PATCH 0/7] Add enum called_number_type George Matveev
  2011-01-23 10:16 ` [PATCH 1/7] src: Introduced " George Matveev
@ 2011-01-23 10:16 ` George Matveev
  2011-01-23 10:16 ` [PATCH 3/7] huaweimodem: " George Matveev
                   ` (3 subsequent siblings)
  5 siblings, 0 replies; 8+ messages in thread
From: George Matveev @ 2011-01-23 10:16 UTC (permalink / raw)
  To: ofono

[-- Attachment #1: Type: text/plain, Size: 2662 bytes --]

---
 drivers/atmodem/atutil.c          |    3 ++-
 drivers/atmodem/call-forwarding.c |    3 ++-
 drivers/atmodem/ssn.c             |    3 ++-
 drivers/atmodem/voicecall.c       |    2 +-
 4 files changed, 7 insertions(+), 4 deletions(-)

diff --git a/drivers/atmodem/atutil.c b/drivers/atmodem/atutil.c
index a55b3f5..8c24e72 100644
--- a/drivers/atmodem/atutil.c
+++ b/drivers/atmodem/atutil.c
@@ -34,6 +34,7 @@
 
 #include "atutil.h"
 #include "vendor.h"
+#include "common.h"
 
 void decode_at_error(struct ofono_error *error, const char *final)
 {
@@ -112,7 +113,7 @@ GSList *at_util_parse_clcc(GAtResult *result)
 
 	while (g_at_result_iter_next(&iter, "+CLCC:")) {
 		const char *str = "";
-		int number_type = 129;
+		int number_type = CALLED_NUMBER_TYPE_UNKNOWN;
 
 		if (!g_at_result_iter_next_number(&iter, &id))
 			continue;
diff --git a/drivers/atmodem/call-forwarding.c b/drivers/atmodem/call-forwarding.c
index f11a68e..bd091ad 100644
--- a/drivers/atmodem/call-forwarding.c
+++ b/drivers/atmodem/call-forwarding.c
@@ -38,6 +38,7 @@
 #include "gatresult.h"
 
 #include "atmodem.h"
+#include "common.h"
 
 static const char *none_prefix[] = { NULL };
 static const char *ccfc_prefix[] = { "+CCFC:", NULL };
@@ -89,7 +90,7 @@ static void ccfc_query_cb(gboolean ok, GAtResult *result, gpointer user_data)
 		g_at_result_iter_next_number(&iter, &(list[num].cls));
 
 		list[num].phone_number.number[0] = '\0';
-		list[num].phone_number.type = 129;
+		list[num].phone_number.type = CALLED_NUMBER_TYPE_UNKNOWN;
 		list[num].time = 20;
 
 		if (!g_at_result_iter_next_string(&iter, &str))
diff --git a/drivers/atmodem/ssn.c b/drivers/atmodem/ssn.c
index b7a9df4..8ede79b 100644
--- a/drivers/atmodem/ssn.c
+++ b/drivers/atmodem/ssn.c
@@ -36,6 +36,7 @@
 #include "gatresult.h"
 
 #include "atmodem.h"
+#include "common.h"
 
 static const char *none_prefix[] = { NULL };
 
@@ -69,7 +70,7 @@ static void cssu_notify(GAtResult *result, gpointer user_data)
 	struct ofono_phone_number ph;
 
 	ph.number[0] = '\0';
-	ph.type = 129;
+	ph.type = CALLED_NUMBER_TYPE_UNKNOWN;
 
 	g_at_result_iter_init(&iter, result);
 
diff --git a/drivers/atmodem/voicecall.c b/drivers/atmodem/voicecall.c
index 9e56999..75a53ab 100644
--- a/drivers/atmodem/voicecall.c
+++ b/drivers/atmodem/voicecall.c
@@ -379,7 +379,7 @@ static void at_dial(struct ofono_voicecall *vc,
 
 	cbd->user = vc;
 
-	if (ph->type == 145)
+	if (ph->type == CALLED_NUMBER_TYPE_INTERNATIONAL)
 		snprintf(buf, sizeof(buf), "ATD+%s", ph->number);
 	else
 		snprintf(buf, sizeof(buf), "ATD%s", ph->number);
-- 
1.5.6.5


^ permalink raw reply related	[flat|nested] 8+ messages in thread

* [PATCH 3/7] huaweimodem: Phone type defined using enum called_number_type
  2011-01-23 10:16 [PATCH 0/7] Add enum called_number_type George Matveev
  2011-01-23 10:16 ` [PATCH 1/7] src: Introduced " George Matveev
  2011-01-23 10:16 ` [PATCH 2/7] atmodem: Phone type defined using " George Matveev
@ 2011-01-23 10:16 ` George Matveev
  2011-01-23 10:16 ` [PATCH 4/7] hfpmodem: " George Matveev
                   ` (2 subsequent siblings)
  5 siblings, 0 replies; 8+ messages in thread
From: George Matveev @ 2011-01-23 10:16 UTC (permalink / raw)
  To: ofono

[-- Attachment #1: Type: text/plain, Size: 723 bytes --]

---
 drivers/huaweimodem/voicecall.c |    3 ++-
 1 files changed, 2 insertions(+), 1 deletions(-)

diff --git a/drivers/huaweimodem/voicecall.c b/drivers/huaweimodem/voicecall.c
index 0c0aaa1..598a26e 100644
--- a/drivers/huaweimodem/voicecall.c
+++ b/drivers/huaweimodem/voicecall.c
@@ -37,6 +37,7 @@
 
 #include "gatchat.h"
 #include "gatresult.h"
+#include "common.h"
 
 #include "huaweimodem.h"
 
@@ -120,7 +121,7 @@ static void huawei_dial(struct ofono_voicecall *vc,
 {
 	char buf[256];
 
-	if (ph->type == 145)
+	if (ph->type == CALLED_NUMBER_TYPE_INTERNATIONAL)
 		snprintf(buf, sizeof(buf), "ATD+%s", ph->number);
 	else
 		snprintf(buf, sizeof(buf), "ATD%s", ph->number);
-- 
1.5.6.5


^ permalink raw reply related	[flat|nested] 8+ messages in thread

* [PATCH 4/7] hfpmodem: Phone type defined using enum called_number_type
  2011-01-23 10:16 [PATCH 0/7] Add enum called_number_type George Matveev
                   ` (2 preceding siblings ...)
  2011-01-23 10:16 ` [PATCH 3/7] huaweimodem: " George Matveev
@ 2011-01-23 10:16 ` George Matveev
  2011-01-23 10:16 ` [PATCH 5/7] ifxmodem: " George Matveev
  2011-01-23 10:16 ` [PATCH 6/7] calypsomodem: " George Matveev
  5 siblings, 0 replies; 8+ messages in thread
From: George Matveev @ 2011-01-23 10:16 UTC (permalink / raw)
  To: ofono

[-- Attachment #1: Type: text/plain, Size: 592 bytes --]

---
 drivers/hfpmodem/voicecall.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/drivers/hfpmodem/voicecall.c b/drivers/hfpmodem/voicecall.c
index d4d370e..9481545 100644
--- a/drivers/hfpmodem/voicecall.c
+++ b/drivers/hfpmodem/voicecall.c
@@ -366,7 +366,7 @@ static void hfp_dial(struct ofono_voicecall *vc,
 		goto error;
 
 	cbd->user = vc;
-	if (ph->type == 145)
+	if (ph->type == CALLED_NUMBER_TYPE_INTERNATIONAL)
 		snprintf(buf, sizeof(buf), "ATD+%s", ph->number);
 	else
 		snprintf(buf, sizeof(buf), "ATD%s", ph->number);
-- 
1.5.6.5


^ permalink raw reply related	[flat|nested] 8+ messages in thread

* [PATCH 5/7] ifxmodem: Phone type defined using enum called_number_type
  2011-01-23 10:16 [PATCH 0/7] Add enum called_number_type George Matveev
                   ` (3 preceding siblings ...)
  2011-01-23 10:16 ` [PATCH 4/7] hfpmodem: " George Matveev
@ 2011-01-23 10:16 ` George Matveev
  2011-01-23 10:16 ` [PATCH 6/7] calypsomodem: " George Matveev
  5 siblings, 0 replies; 8+ messages in thread
From: George Matveev @ 2011-01-23 10:16 UTC (permalink / raw)
  To: ofono

[-- Attachment #1: Type: text/plain, Size: 702 bytes --]

---
 drivers/ifxmodem/voicecall.c |    3 ++-
 1 files changed, 2 insertions(+), 1 deletions(-)

diff --git a/drivers/ifxmodem/voicecall.c b/drivers/ifxmodem/voicecall.c
index f673624..b8ccbb2 100644
--- a/drivers/ifxmodem/voicecall.c
+++ b/drivers/ifxmodem/voicecall.c
@@ -37,6 +37,7 @@
 
 #include "gatchat.h"
 #include "gatresult.h"
+#include "common.h"
 
 #include "ifxmodem.h"
 
@@ -310,7 +311,7 @@ static void ifx_dial(struct ofono_voicecall *vc,
 
 	cbd->user = vc;
 
-	if (ph->type == 145)
+	if (ph->type == CALLED_NUMBER_TYPE_INTERNATIONAL)
 		snprintf(buf, sizeof(buf), "ATD+%s", ph->number);
 	else
 		snprintf(buf, sizeof(buf), "ATD%s", ph->number);
-- 
1.5.6.5


^ permalink raw reply related	[flat|nested] 8+ messages in thread

* [PATCH 6/7] calypsomodem: Phone type defined using enum called_number_type
  2011-01-23 10:16 [PATCH 0/7] Add enum called_number_type George Matveev
                   ` (4 preceding siblings ...)
  2011-01-23 10:16 ` [PATCH 5/7] ifxmodem: " George Matveev
@ 2011-01-23 10:16 ` George Matveev
  5 siblings, 0 replies; 8+ messages in thread
From: George Matveev @ 2011-01-23 10:16 UTC (permalink / raw)
  To: ofono

[-- Attachment #1: Type: text/plain, Size: 728 bytes --]

---
 drivers/calypsomodem/voicecall.c |    3 ++-
 1 files changed, 2 insertions(+), 1 deletions(-)

diff --git a/drivers/calypsomodem/voicecall.c b/drivers/calypsomodem/voicecall.c
index 837ff69..398f5a2 100644
--- a/drivers/calypsomodem/voicecall.c
+++ b/drivers/calypsomodem/voicecall.c
@@ -37,6 +37,7 @@
 
 #include "gatchat.h"
 #include "gatresult.h"
+#include "common.h"
 
 #include "calypsomodem.h"
 
@@ -85,7 +86,7 @@ static void calypso_dial(struct ofono_voicecall *vc,
 {
 	char buf[256];
 
-	if (ph->type == 145)
+	if (ph->type == CALLED_NUMBER_TYPE_INTERNATIONAL)
 		snprintf(buf, sizeof(buf), "ATD+%s", ph->number);
 	else
 		snprintf(buf, sizeof(buf), "ATD%s", ph->number);
-- 
1.5.6.5


^ permalink raw reply related	[flat|nested] 8+ messages in thread

* Re: [PATCH 1/7] src: Introduced enum called_number_type
  2011-01-23 10:16 ` [PATCH 1/7] src: Introduced " George Matveev
@ 2011-01-24 22:19   ` Denis Kenzior
  0 siblings, 0 replies; 8+ messages in thread
From: Denis Kenzior @ 2011-01-24 22:19 UTC (permalink / raw)
  To: ofono

[-- Attachment #1: Type: text/plain, Size: 1281 bytes --]

Hi George,

> +/* 24.008 Section 10.5.4.7 Called party BCD number */
> +enum called_number_type {
> +	CALLED_NUMBER_TYPE_UNKNOWN = 0,
> +	CALLED_NUMBER_TYPE_INTERNATIONAL = 1,
> +	CALLED_NUMBER_TYPE_NATIONAL = 2,
> +	CALLED_NUMBER_TYPE_NETWORK_SPECIFIC = 3,
> +	CALLED_NUMBER_TYPE_DEDICATED_ACCESS = 4,
> +	CALLED_NUMBER_TYPE_RESERVED = 7
> +};
> +

This isn't going to work.  Your patches basically break all voice call
drivers that we have.  I refer you to stemodem ecav_notify function or
the calypsomodem cpi parser.  The number type is not handled properly there.

27.007 uses three main ton/npi combinations:

unknown / unknown (128)
unknown / isdn (129)
international / isdn (145)

If you want to be pedantic, then define an enum something like this:

enum number_type {
	NUMBER_TYPE_UNKNOWN,
	NUMBER_TYPE_UNKNOWN_ISDN,
	NUMBER_TYPE_INTERNATIONAL_ISDN,
};

And just handle these three appropriately.

Alternatively decompose the value into the appropriate bit-fields and
compare the bit-field values.  E.g. bits 1..4 -> npi.  Bits 5..7 -> ton
and define enums for them appropriately.  This will still be a messier
solution than assigning the values 128/129 (in fact 27.007 recommends
assigning these values anyway).

Regards,
-Denis

^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2011-01-24 22:19 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-01-23 10:16 [PATCH 0/7] Add enum called_number_type George Matveev
2011-01-23 10:16 ` [PATCH 1/7] src: Introduced " George Matveev
2011-01-24 22:19   ` Denis Kenzior
2011-01-23 10:16 ` [PATCH 2/7] atmodem: Phone type defined using " George Matveev
2011-01-23 10:16 ` [PATCH 3/7] huaweimodem: " George Matveev
2011-01-23 10:16 ` [PATCH 4/7] hfpmodem: " George Matveev
2011-01-23 10:16 ` [PATCH 5/7] ifxmodem: " George Matveev
2011-01-23 10:16 ` [PATCH 6/7] calypsomodem: " George Matveev

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox