Hi George,
> Hi,
>
> this is proposal for a patch series which would replace
> "magic" numbers 145 and 129 with well defined enumeration.
>
> Currently we have the following (eliminating sms and CAIF
> related code):
>
> geo@fermat:/home/work/ofono/ofono$ grep -nr 145 drivers src|grep -v
> sms|grep -v CAIF
> drivers/huaweimodem/voicecall.c:123: if (ph->type == 145)
> drivers/stemodem/voicecall.c:195: if (ph->type == 145)
> drivers/atmodem/voicecall.c:374: if (ph->type == 145)
> drivers/calypsomodem/voicecall.c:88: if (ph->type == 145)
> drivers/hfpmodem/voicecall.c:369: if (ph->type == 145)
> drivers/ifxmodem/voicecall.c:313: if (ph->type == 145)
> src/phonebook.c:41:#define TYPE_INTERNATIONAL 145
> src/common.c:74: { 145, "Message class not supported" },
> src/common.c:408: if (ph->type == 145 &&
> (strlen(ph->number) > 0) &&
> src/common.c:425: ph->type = 145; /* International */
> geo@fermat:/home/work/ofono/ofono$
>
> Even though TYPE_INTERNATIONAL is defined it is used only once:
>
> geo@fermat:/home/work/ofono/ofono$ grep -nr _INTERNATIONAL
> .|grep -v SMS ./src/phonebook.c:41:#define TYPE_INTERNATIONAL 145
> ./src/phonebook.c:179: if ((type ==
> TYPE_INTERNATIONAL) && (number[0] !=
> '+'))
> geo@fermat:/home/work/ofono/ofono$
>
> And for "magic" number 129 we have:
>
> geo@fermat:/home/work/ofono/ofono$ grep -nr 129 drivers src|grep -v
> sms|grep -v CAIF
> drivers/atmodem/call-forwarding.c:92:
> list[num].phone_number.type = 129;
> drivers/atmodem/atutil.c:115: int number_type = 129;
> drivers/atmodem/ssn.c:72: ph.type = 129;
> drivers/calypsomodem/voicecall.c:298: type = 129;
> src/call-forwarding.c:794: ph.type = 129;
> src/common.c:70: { 129, "Short message type 0 not supported" },
> src/common.c:428: ph->type = 129; /* Local */
> geo@fermat:/home/work/ofono/ofono$
>
>
> So if we introduce enum phone_number_type in src/common.h
> similar to sms_number_type defined in smsutils.h:
>
> enum phone_number_type {
> PHONE_NUMBER_TYPE_LOCAL = 0,
> PHONE_NUMBER_TYPE_INTER = 1
> };
>
> and use it consistently with phone type then we may avoid
> magic numbers and need to guess what they mean.
145 and 129, doesnt only represent the type of number (TON), but also
includes the numbering plan indentification (NPI).
145 - 1 001 0001 (1- EXT, 001 - international number, 0001 -
ISDN/telephony numbering plan )
129 - 1 000 0001 (1- EXT, 000 - unknown, 0001 - ISDN/telephony numbering
plan )
In 129 TON is unknown type, not Local or National, so it should be
_UNKNOWN not _LOCAL
BR,
Rajesh
_______________________________________________
ofono mailing list
[email protected]
http://lists.ofono.org/listinfo/ofono