[PATCH v4 0/2] Add support for modem handled setup call proactive command

2011-07-25 Thread Jeevaka Badrappan
Hi,

This patch set fixes the review comments.

If the modem is able to setup the call, then the alpha id will be freed when the
initiated call ends.

If the modem is not able to setup the call due to some reason, then the memory
allocated for alpha id and dial request are freed when the command end/session
end is received.

Also, noticed there is a break missing in the 
ofono_stk_proactive_command_handled_notify
for STK_COMMAND_TYPE_SEND_SS case. Fix for that will be provided as a separate 
patch.

Note: This version of the patch is not tested.

Thanks and Regards,
Jeevaka

Jeevaka Badrappan (2):
  voicecall: api for set/clear alpha and icon id
  stk: Handle set up call in handled_notify

 src/ofono.h |6 ++
 src/stk.c   |  166 ++-
 src/voicecall.c |   65 +
 3 files changed, 211 insertions(+), 26 deletions(-)

-- 
1.7.4.1

___
ofono mailing list
ofono@ofono.org
http://lists.ofono.org/listinfo/ofono


[PATCH v4 2/2] stk: Handle set up call in handled_notify

2011-07-25 Thread Jeevaka Badrappan
---
 src/stk.c |  166 +++--
 1 files changed, 140 insertions(+), 26 deletions(-)

diff --git a/src/stk.c b/src/stk.c
index e8ffb42..e85e595 100644
--- a/src/stk.c
+++ b/src/stk.c
@@ -1790,6 +1790,45 @@ static void confirm_call_cb(enum stk_agent_result 
result, gboolean confirm,
stk_command_cb(error, stk);
 }
 
+static void confirm_handled_call_cb(enum stk_agent_result result,
+   gboolean confirm, void *user_data)
+{
+   struct ofono_stk *stk = user_data;
+   const struct stk_command_setup_call *sc =
+   stk-pending_cmd-setup_call;
+   struct ofono_voicecall *vc = NULL;
+   struct ofono_atom *vc_atom;
+
+   if (stk-driver-user_confirmation == NULL)
+   goto out;
+
+   if (result != STK_AGENT_RESULT_OK) {
+   stk-driver-user_confirmation(stk, FALSE);
+   goto out;
+   }
+
+   stk-driver-user_confirmation(stk, confirm);
+
+   vc_atom = __ofono_modem_find_atom(__ofono_atom_get_modem(stk-atom),
+   OFONO_ATOM_TYPE_VOICECALL);
+   if (vc_atom)
+   vc = __ofono_atom_get_data(vc_atom);
+
+   if (vc == NULL)
+   goto out;
+
+   __ofono_voicecall_set_alpha_and_icon_id(vc, sc-addr.number,
+   sc-addr.ton_npi,
+   sc-alpha_id_call_setup,
+   sc-icon_id_call_setup.id);
+
+   return;
+
+out:
+   stk_command_free(stk-pending_cmd);
+   stk-pending_cmd = NULL;
+}
+
 static gboolean handle_command_set_up_call(const struct stk_command *cmd,
struct stk_response *rsp,
struct ofono_stk *stk)
@@ -2606,6 +2645,77 @@ static gboolean handle_command_launch_browser(const 
struct stk_command *cmd,
return FALSE;
 }
 
+static void proactive_command_handled_end(struct ofono_stk *stk)
+{
+   if (stk-pending_cmd == NULL)
+   return;
+
+   switch(stk-pending_cmd-type) {
+   case STK_COMMAND_TYPE_SETUP_CALL:
+   {
+   struct ofono_voicecall *vc = NULL;
+   struct ofono_atom *vc_atom;
+
+   vc_atom = __ofono_modem_find_atom(
+   __ofono_atom_get_modem(stk-atom),
+   OFONO_ATOM_TYPE_VOICECALL);
+   if (vc_atom)
+   vc = __ofono_atom_get_data(vc_atom);
+
+   if (vc != NULL)
+   __ofono_voicecall_clear_alpha_and_icon_id(vc);
+
+   break;
+   }
+   case STK_COMMAND_TYPE_SEND_SMS:
+   case STK_COMMAND_TYPE_SEND_USSD:
+   case STK_COMMAND_TYPE_SEND_SS:
+   case STK_COMMAND_TYPE_SEND_DTMF:
+   stk_alpha_id_unset(stk);
+   break;
+
+   default:
+   break;
+   }
+
+   stk_command_free(stk-pending_cmd);
+   stk-pending_cmd = NULL;
+   stk-cancel_cmd = NULL;
+}
+
+static gboolean handle_setup_call_confirmation_req(struct stk_command *cmd,
+   struct ofono_stk *stk)
+{
+   const struct stk_command_setup_call *sc = cmd-setup_call;
+   int err;
+   char *alpha_id = dbus_apply_text_attributes(
+   sc-alpha_id_usr_cfm ?
+   sc-alpha_id_usr_cfm : ,
+   sc-text_attr_usr_cfm);
+   if (alpha_id == NULL)
+   goto out;
+
+   err = stk_agent_confirm_call(stk-current_agent, alpha_id,
+   sc-icon_id_usr_cfm,
+   confirm_handled_call_cb,
+   stk, NULL,
+   stk-timeout * 1000);
+   g_free(alpha_id);
+
+   if (err  0)
+   goto out;
+
+   stk-cancel_cmd = proactive_command_handled_end;
+
+   return TRUE;
+
+out:
+   if (stk-driver-user_confirmation)
+   stk-driver-user_confirmation(stk, FALSE);
+
+   return FALSE;
+}
+
 static void stk_proactive_command_cancel(struct ofono_stk *stk)
 {
if (stk-immediate_response)
@@ -2816,8 +2926,8 @@ void ofono_stk_proactive_command_handled_notify(struct 
ofono_stk *stk,
int length,
const unsigned char *pdu)
 {
-   struct stk_command *cmd;
struct stk_response dummyrsp;
+   gboolean ok = TRUE;
 
/*
 * Modems send us the proactive command details and terminal responses
@@ -2826,69 +2936,73 @@ void ofono_stk_proactive_command_handled_notify(struct 
ofono_stk *stk,
 * responses here
 */
if (length 

[PATCH v4 1/2] voicecall: api for set/clear alpha and icon id

2011-07-25 Thread Jeevaka Badrappan
---
 src/ofono.h |6 +
 src/voicecall.c |   65 +++
 2 files changed, 71 insertions(+), 0 deletions(-)

diff --git a/src/ofono.h b/src/ofono.h
index 6524806..808a8f1 100644
--- a/src/ofono.h
+++ b/src/ofono.h
@@ -266,6 +266,12 @@ int __ofono_voicecall_dial(struct ofono_voicecall *vc,
ofono_voicecall_dial_cb_t cb, void *user_data);
 void __ofono_voicecall_dial_cancel(struct ofono_voicecall *vc);
 
+void __ofono_voicecall_set_alpha_and_icon_id(struct ofono_voicecall *vc,
+   const char *addr, int addr_type,
+   const char *message,
+   unsigned char icon_id);
+void __ofono_voicecall_clear_alpha_and_icon_id(struct ofono_voicecall *vc);
+
 int __ofono_voicecall_tone_send(struct ofono_voicecall *vc,
const char *tone_str,
ofono_voicecall_tone_cb_t cb, void *user_data);
diff --git a/src/voicecall.c b/src/voicecall.c
index f4c2358..14b5d22 100644
--- a/src/voicecall.c
+++ b/src/voicecall.c
@@ -42,6 +42,7 @@
 #define MAX_VOICE_CALLS 16
 
 #define VOICECALL_FLAG_SIM_ECC_READY 0x1
+#define VOICECALL_FLAG_STK_MODEM_CALLSETUP 0x2
 
 #define SETTINGS_STORE voicecall
 #define SETTINGS_GROUP Settings
@@ -2223,6 +2224,39 @@ void ofono_voicecall_notify(struct ofono_voicecall *vc,
goto error;
}
 
+   if (vc-flags  VOICECALL_FLAG_STK_MODEM_CALLSETUP) {
+   struct dial_request *req = vc-dial_req;
+   const char *number = phone_number_to_string(req-ph);
+
+   if (!strcmp(number, 112)) {
+   struct ofono_modem *modem =
+   __ofono_atom_get_modem(vc-atom);
+
+   __ofono_modem_inc_emergency_mode(modem);
+   }
+
+   if (v-call-clip_validity == CLIP_VALIDITY_NOT_AVAILABLE) {
+   v-call-phone_number.type = req-ph.type;
+   strncpy(v-call-phone_number.number, req-ph.number,
+   20);
+   v-call-clip_validity = CLIP_VALIDITY_VALID;
+   }
+
+   v-message = req-message;
+   v-icon_id = req-icon_id;
+
+   req-message = NULL;
+   req-call = v;
+
+   /*
+* TS 102 223 Section 6.4.13: The terminal shall not store
+* in the UICC the call set-up details (called party number
+* and associated parameters)
+*/
+   v-untracked = TRUE;
+   vc-flags = ~VOICECALL_FLAG_STK_MODEM_CALLSETUP;
+   }
+
v-detect_time = time(NULL);
 
if (!voicecall_dbus_register(v)) {
@@ -3682,6 +3716,37 @@ void __ofono_voicecall_tone_cancel(struct 
ofono_voicecall *vc, int id)
}
 }
 
+void __ofono_voicecall_set_alpha_and_icon_id(struct ofono_voicecall *vc,
+   const char *addr, int addr_type,
+   const char *message,
+   unsigned char icon_id)
+{
+   struct dial_request *req;
+
+   req = g_new0(struct dial_request, 1);
+
+   req-message = g_strdup(message);
+   req-icon_id = icon_id;
+
+   req-ph.type = addr_type;
+   strncpy(req-ph.number, addr, 20);
+
+   vc-dial_req = req;
+
+   vc-flags |= VOICECALL_FLAG_STK_MODEM_CALLSETUP;
+}
+
+void __ofono_voicecall_clear_alpha_and_icon_id(struct ofono_voicecall *vc)
+{
+   g_free(vc-dial_req-message);
+   vc-dial_req-message = NULL;
+
+   g_free(vc-dial_req);
+   vc-dial_req = NULL;
+
+   vc-flags = ~VOICECALL_FLAG_STK_MODEM_CALLSETUP;
+}
+
 static void ssn_mt_forwarded_notify(struct ofono_voicecall *vc,
unsigned int id, int code,
const struct ofono_phone_number *ph)
-- 
1.7.4.1

___
ofono mailing list
ofono@ofono.org
http://lists.ofono.org/listinfo/ofono


RE: [PATCH] ifxmodem: emergency number list support

2011-07-20 Thread jeevaka . badrappan
Hi,

 Hi Jeevaka,

 I'm Nicolas Paccou, I'm in charge of validating the changes applied in new
 oFono release.
 Unfortunately, I have not the hardware to be able to regress your patch:
 Add support for handling IFX emergency number list

 I wanted to know if you have tested your patch on IFX modem ?
 If yes, can you tell me if the result is ok ?
 If not, do you able to test it and tell me the result please ?

Yep, this has been tested with the IFX modem FW which supports XLEMA.

Regards,
Jeevaka
___
ofono mailing list
ofono@ofono.org
http://lists.ofono.org/listinfo/ofono


[PATCH 0/2] Add support for modem handled setup call proactive command

2011-07-19 Thread Jeevaka Badrappan
Hi,

This patch set fixes the review comments.

If the modem is able to setup the call, then the alpha id will be freed when the
initiated call ends.

If the modem is not able to setup the call due to some reason, then the memory
allocated for alpha id and dial request are freed when the command end/session
end is received.

Thanks and Regards,
Jeevaka

Jeevaka Badrappan (2):
  voicecall: api for set/clear alpha and icon id
  stk: Handle set up call in handled_notify

 src/ofono.h |6 +++
 src/stk.c   |  113 +-
 src/voicecall.c |   62 ++
 3 files changed, 178 insertions(+), 3 deletions(-)

-- 
1.7.4.1

___
ofono mailing list
ofono@ofono.org
http://lists.ofono.org/listinfo/ofono


[PATCH 1/2] voicecall: api for set/clear alpha and icon id

2011-07-19 Thread Jeevaka Badrappan
---
 src/ofono.h |6 +
 src/voicecall.c |   62 +++
 2 files changed, 68 insertions(+), 0 deletions(-)

diff --git a/src/ofono.h b/src/ofono.h
index 6524806..808a8f1 100644
--- a/src/ofono.h
+++ b/src/ofono.h
@@ -266,6 +266,12 @@ int __ofono_voicecall_dial(struct ofono_voicecall *vc,
ofono_voicecall_dial_cb_t cb, void *user_data);
 void __ofono_voicecall_dial_cancel(struct ofono_voicecall *vc);
 
+void __ofono_voicecall_set_alpha_and_icon_id(struct ofono_voicecall *vc,
+   const char *addr, int addr_type,
+   const char *message,
+   unsigned char icon_id);
+void __ofono_voicecall_clear_alpha_and_icon_id(struct ofono_voicecall *vc);
+
 int __ofono_voicecall_tone_send(struct ofono_voicecall *vc,
const char *tone_str,
ofono_voicecall_tone_cb_t cb, void *user_data);
diff --git a/src/voicecall.c b/src/voicecall.c
index 3646951..03a0c96 100644
--- a/src/voicecall.c
+++ b/src/voicecall.c
@@ -42,6 +42,7 @@
 #define MAX_VOICE_CALLS 16
 
 #define VOICECALL_FLAG_SIM_ECC_READY 0x1
+#define VOICECALL_FLAG_STK_MODEM_CALLSETUP 0x2
 
 #define SETTINGS_STORE voicecall
 #define SETTINGS_GROUP Settings
@@ -2158,6 +2159,8 @@ void ofono_voicecall_disconnected(struct ofono_voicecall 
*vc, int id,
voicecall_dbus_unregister(vc, call);
 
vc-call_list = g_slist_remove(vc-call_list, call);
+
+   vc-flags = ~VOICECALL_FLAG_STK_MODEM_CALLSETUP;
 }
 
 void ofono_voicecall_notify(struct ofono_voicecall *vc,
@@ -2204,6 +2207,31 @@ void ofono_voicecall_notify(struct ofono_voicecall *vc,
goto error;
}
 
+   if (vc-flags  VOICECALL_FLAG_STK_MODEM_CALLSETUP) {
+   struct dial_request *req = vc-dial_req;
+   const char *number = phone_number_to_string(req-ph);
+
+   if (!strcmp(number, 112)) {
+   struct ofono_modem *modem =
+   __ofono_atom_get_modem(vc-atom);
+
+   __ofono_modem_inc_emergency_mode(modem);
+   }
+
+   v-message = req-message;
+   v-icon_id = req-icon_id;
+
+   req-message = NULL;
+   req-call = v;
+
+   /*
+* TS 102 223 Section 6.4.13: The terminal shall not store
+* in the UICC the call set-up details (called party number
+* and associated parameters)
+*/
+   v-untracked = TRUE;
+   }
+
v-detect_time = time(NULL);
 
if (!voicecall_dbus_register(v)) {
@@ -3659,6 +3687,40 @@ void __ofono_voicecall_tone_cancel(struct 
ofono_voicecall *vc, int id)
}
 }
 
+void __ofono_voicecall_set_alpha_and_icon_id(struct ofono_voicecall *vc,
+   const char *addr, int addr_type,
+   const char *message,
+   unsigned char icon_id)
+{
+   struct dial_request *req;
+
+   req = g_new0(struct dial_request, 1);
+
+   req-message = g_strdup(message);
+   req-icon_id = icon_id;
+
+   req-ph.type = addr_type;
+   strncpy(req-ph.number, addr, 20);
+
+   vc-dial_req = req;
+
+   vc-flags |= VOICECALL_FLAG_STK_MODEM_CALLSETUP;
+}
+
+void __ofono_voicecall_clear_alpha_and_icon_id(struct ofono_voicecall *vc)
+{
+   if (vc-dial_req == NULL)
+   return;
+
+   g_free(vc-dial_req-message);
+   vc-dial_req-message = NULL;
+
+   g_free(vc-dial_req);
+   vc-dial_req = NULL;
+
+   vc-flags = ~VOICECALL_FLAG_STK_MODEM_CALLSETUP;
+}
+
 static void ssn_mt_forwarded_notify(struct ofono_voicecall *vc,
unsigned int id, int code,
const struct ofono_phone_number *ph)
-- 
1.7.4.1

___
ofono mailing list
ofono@ofono.org
http://lists.ofono.org/listinfo/ofono


[PATCH 2/2] stk: Handle set up call in handled_notify

2011-07-19 Thread Jeevaka Badrappan
---
 src/stk.c |  113 +++--
 1 files changed, 110 insertions(+), 3 deletions(-)

diff --git a/src/stk.c b/src/stk.c
index e8ffb42..a204e45 100644
--- a/src/stk.c
+++ b/src/stk.c
@@ -1790,6 +1790,45 @@ static void confirm_call_cb(enum stk_agent_result 
result, gboolean confirm,
stk_command_cb(error, stk);
 }
 
+static void confirm_handled_call_cb(enum stk_agent_result result,
+   gboolean confirm, void *user_data)
+{
+   struct ofono_stk *stk = user_data;
+   const struct stk_command_setup_call *sc =
+   stk-pending_cmd-setup_call;
+   struct ofono_voicecall *vc = NULL;
+   struct ofono_atom *vc_atom;
+
+   if (stk-driver-user_confirmation == NULL)
+   goto out;
+
+   if (result != STK_AGENT_RESULT_OK) {
+   stk-driver-user_confirmation(stk, FALSE);
+   goto out;
+   }
+
+   stk-driver-user_confirmation(stk, confirm);
+
+   vc_atom = __ofono_modem_find_atom(__ofono_atom_get_modem(stk-atom),
+   OFONO_ATOM_TYPE_VOICECALL);
+   if (vc_atom)
+   vc = __ofono_atom_get_data(vc_atom);
+
+   if (vc == NULL)
+   goto out;
+
+   __ofono_voicecall_set_alpha_and_icon_id(vc, sc-addr.number,
+   sc-addr.ton_npi,
+   sc-alpha_id_call_setup,
+   sc-icon_id_call_setup.id);
+
+   return;
+
+out:
+   stk_command_free(stk-pending_cmd);
+   stk-pending_cmd = NULL;
+}
+
 static gboolean handle_command_set_up_call(const struct stk_command *cmd,
struct stk_response *rsp,
struct ofono_stk *stk)
@@ -2606,6 +2645,74 @@ static gboolean handle_command_launch_browser(const 
struct stk_command *cmd,
return FALSE;
 }
 
+static void proactive_command_handled_end(struct ofono_stk *stk)
+{
+   if (stk-pending_cmd == NULL)
+   return;
+
+   switch(stk-pending_cmd-type) {
+   case STK_COMMAND_TYPE_SETUP_CALL:
+   {
+   struct ofono_voicecall *vc = NULL;
+   struct ofono_atom *vc_atom;
+
+   vc_atom = __ofono_modem_find_atom(
+   __ofono_atom_get_modem(stk-atom),
+   OFONO_ATOM_TYPE_VOICECALL);
+   if (vc_atom)
+   vc = __ofono_atom_get_data(vc_atom);
+
+   if (vc != NULL)
+   __ofono_voicecall_clear_alpha_and_icon_id(vc);
+
+   break;
+   }
+   case STK_COMMAND_TYPE_SEND_SMS:
+   case STK_COMMAND_TYPE_SEND_USSD:
+   case STK_COMMAND_TYPE_SEND_SS:
+   case STK_COMMAND_TYPE_SEND_DTMF:
+   stk_alpha_id_unset(stk);
+   break;
+
+   default:
+   break;
+   }
+}
+
+static void handle_setup_call_confirmation_req(struct stk_command *cmd,
+   struct ofono_stk *stk)
+{
+   const struct stk_command_setup_call *sc = cmd-setup_call;
+   int err;
+   char *alpha_id = dbus_apply_text_attributes(
+   sc-alpha_id_usr_cfm ?
+   sc-alpha_id_usr_cfm : ,
+   sc-text_attr_usr_cfm);
+   if (alpha_id == NULL)
+   goto out;
+
+   err = stk_agent_confirm_call(stk-current_agent, alpha_id,
+   sc-icon_id_usr_cfm,
+   confirm_handled_call_cb,
+   stk, NULL,
+   stk-timeout * 1000);
+   g_free(alpha_id);
+
+   if (err  0)
+   goto out;
+
+   stk-pending_cmd = cmd;
+   stk-cancel_cmd = proactive_command_handled_end;
+
+   return;
+
+out:
+   if (stk-driver-user_confirmation)
+   stk-driver-user_confirmation(stk, FALSE);
+
+   stk_command_free(cmd);
+}
+
 static void stk_proactive_command_cancel(struct ofono_stk *stk)
 {
if (stk-immediate_response)
@@ -2826,7 +2933,7 @@ void ofono_stk_proactive_command_handled_notify(struct 
ofono_stk *stk,
 * responses here
 */
if (length  0  pdu[0] == 0x81) {
-   stk_alpha_id_unset(stk);
+   proactive_command_handled_end(stk);
return;
}
 
@@ -2863,8 +2970,8 @@ void ofono_stk_proactive_command_handled_notify(struct 
ofono_stk *stk,
break;
 
case STK_COMMAND_TYPE_SETUP_CALL:
-   /* TODO */
-   break;
+   handle_setup_call_confirmation_req(cmd, stk);
+   return;
 
case STK_COMMAND_TYPE_SEND_USSD:
   

[PATCH 2/4] voicecall: api for set/clear alpha and icon id

2011-07-15 Thread Jeevaka Badrappan
---
 src/ofono.h |6 
 src/voicecall.c |   76 +++
 2 files changed, 82 insertions(+), 0 deletions(-)

diff --git a/src/ofono.h b/src/ofono.h
index 6524806..808a8f1 100644
--- a/src/ofono.h
+++ b/src/ofono.h
@@ -266,6 +266,12 @@ int __ofono_voicecall_dial(struct ofono_voicecall *vc,
ofono_voicecall_dial_cb_t cb, void *user_data);
 void __ofono_voicecall_dial_cancel(struct ofono_voicecall *vc);
 
+void __ofono_voicecall_set_alpha_and_icon_id(struct ofono_voicecall *vc,
+   const char *addr, int addr_type,
+   const char *message,
+   unsigned char icon_id);
+void __ofono_voicecall_clear_alpha_and_icon_id(struct ofono_voicecall *vc);
+
 int __ofono_voicecall_tone_send(struct ofono_voicecall *vc,
const char *tone_str,
ofono_voicecall_tone_cb_t cb, void *user_data);
diff --git a/src/voicecall.c b/src/voicecall.c
index 3646951..33041a1 100644
--- a/src/voicecall.c
+++ b/src/voicecall.c
@@ -2204,6 +2204,25 @@ void ofono_voicecall_notify(struct ofono_voicecall *vc,
goto error;
}
 
+   if (vc-dial_req) {
+   v-message = vc-dial_req-message;
+   v-icon_id = vc-dial_req-icon_id;
+
+   vc-dial_req-message = NULL;
+   vc-dial_req-call = v;
+
+   newcall-phone_number.type = vc-dial_req-ph.type;
+   strncpy(newcall-phone_number.number, vc-dial_req-ph.number,
+   20);
+
+   /*
+* TS 102 223 Section 6.4.13: The terminal shall not store
+* in the UICC the call set-up details (called party number
+* and associated parameters)
+*/
+   v-untracked = TRUE;
+   }
+
v-detect_time = time(NULL);
 
if (!voicecall_dbus_register(v)) {
@@ -3659,6 +3678,63 @@ void __ofono_voicecall_tone_cancel(struct 
ofono_voicecall *vc, int id)
}
 }
 
+void __ofono_voicecall_set_alpha_and_icon_id(struct ofono_voicecall *vc,
+   const char *addr, int addr_type,
+   const char *message,
+   unsigned char icon_id)
+{
+   struct dial_request *req;
+   const char *number;
+
+   req = g_new0(struct dial_request, 1);
+
+   req-message = g_strdup(message);
+   req-icon_id = icon_id;
+
+   req-ph.type = addr_type;
+   strncpy(req-ph.number, addr, 20);
+
+   number = phone_number_to_string(req-ph);
+
+   if (!strcmp(number, 112)) {
+   struct ofono_modem *modem = __ofono_atom_get_modem(vc-atom);
+
+   __ofono_modem_inc_emergency_mode(modem);
+   }
+
+   vc-dial_req = req;
+}
+
+void __ofono_voicecall_clear_alpha_and_icon_id(struct ofono_voicecall *vc)
+{
+   const char *number;
+
+   if (vc-dial_req == NULL)
+   return;
+
+   number = phone_number_to_string(vc-dial_req-ph);
+
+   /*
+* Incase the modem fails to setup the call and if there is no call
+* created, then the emergency mode has to be cleared.
+*/
+   if (!strcmp(number, 112)) {
+   if (voicecalls_num_active(vc) == 0 
+   voicecalls_num_connecting(vc) == 0) {
+   struct ofono_modem *modem =
+   __ofono_atom_get_modem(vc-atom);
+
+   __ofono_modem_dec_emergency_mode(modem);
+   }
+   }
+
+   g_free(vc-dial_req-message);
+   vc-dial_req-message = NULL;
+
+   g_free(vc-dial_req);
+   vc-dial_req = NULL;
+}
+
 static void ssn_mt_forwarded_notify(struct ofono_voicecall *vc,
unsigned int id, int code,
const struct ofono_phone_number *ph)
-- 
1.7.4.1

___
ofono mailing list
ofono@ofono.org
http://lists.ofono.org/listinfo/ofono


[PATCH 0/4] Add support for modem handled setup call proactive command

2011-07-15 Thread Jeevaka Badrappan
Hi,

 This patch set fixes the review comments and also fixes some of the corner 
cases.

 If the modem is able to setup the call, then the alpha id will be freed when 
the
initiated call ends.

 If the modem is not able to setup the call due to some reason, then the memory
allocated for alpha id and dial request are freed when the command end/session
end is received.

Thanks and Regards,
Jeevaka

Jeevaka Badrappan (4):
  include: Add driver api for user confirmation
  voicecall: api for set/clear alpha and icon id
  stk: Handle set up call in handled_notify
  ifxmodem: add support for user_confirmation in stk

 drivers/ifxmodem/stk.c |   11 
 include/stk.h  |1 +
 src/ofono.h|6 ++
 src/stk.c  |  122 ++-
 src/voicecall.c|   76 ++
 5 files changed, 213 insertions(+), 3 deletions(-)

-- 
1.7.4.1

___
ofono mailing list
ofono@ofono.org
http://lists.ofono.org/listinfo/ofono


[PATCH 1/4] include: Add driver api for user confirmation

2011-07-15 Thread Jeevaka Badrappan
---
 include/stk.h |1 +
 1 files changed, 1 insertions(+), 0 deletions(-)

diff --git a/include/stk.h b/include/stk.h
index c276c84..60636b5 100644
--- a/include/stk.h
+++ b/include/stk.h
@@ -47,6 +47,7 @@ struct ofono_stk_driver {
void (*terminal_response)(struct ofono_stk *stk,
int length, const unsigned char *resp,
ofono_stk_generic_cb_t cb, void *data);
+   void (*user_confirmation)(struct ofono_stk *stk, ofono_bool_t confirm);
 };
 
 int ofono_stk_driver_register(const struct ofono_stk_driver *d);
-- 
1.7.4.1

___
ofono mailing list
ofono@ofono.org
http://lists.ofono.org/listinfo/ofono


[PATCH 4/4] ifxmodem: add support for user_confirmation in stk

2011-07-15 Thread Jeevaka Badrappan
---
 drivers/ifxmodem/stk.c |   11 +++
 1 files changed, 11 insertions(+), 0 deletions(-)

diff --git a/drivers/ifxmodem/stk.c b/drivers/ifxmodem/stk.c
index f08cf47..d2082c4 100644
--- a/drivers/ifxmodem/stk.c
+++ b/drivers/ifxmodem/stk.c
@@ -173,6 +173,16 @@ error:
CALLBACK_WITH_FAILURE(cb, data);
 }
 
+static void ifx_stk_user_confirmation(struct ofono_stk *stk, gboolean confirm)
+{
+   struct stk_data *sd = ofono_stk_get_data(stk);
+   char buf[20];
+
+   snprintf(buf, sizeof(buf), AT+SATD=%i, confirm ? 1 : 0);
+
+   g_at_chat_send(sd-chat, buf, none_prefix, NULL, NULL, NULL);
+}
+
 static void sati_notify(GAtResult *result, gpointer user_data)
 {
struct ofono_stk *stk = user_data;
@@ -303,6 +313,7 @@ static struct ofono_stk_driver driver = {
.remove = ifx_stk_remove,
.envelope   = ifx_stk_envelope,
.terminal_response  = ifx_stk_terminal_response,
+   .user_confirmation  = ifx_stk_user_confirmation,
 };
 
 void ifx_stk_init(void)
-- 
1.7.4.1

___
ofono mailing list
ofono@ofono.org
http://lists.ofono.org/listinfo/ofono


[PATCH 3/4] stk: Handle set up call in handled_notify

2011-07-15 Thread Jeevaka Badrappan
---
 src/stk.c |  122 +++-
 1 files changed, 119 insertions(+), 3 deletions(-)

diff --git a/src/stk.c b/src/stk.c
index 4df23b5..6cc3be3 100644
--- a/src/stk.c
+++ b/src/stk.c
@@ -77,6 +77,8 @@ struct ofono_stk {
struct timeval get_inkey_start_ts;
int dtmf_id;
 
+   gboolean modem_handled_cmd;
+
__ofono_sms_sim_download_cb_t sms_pp_cb;
void *sms_pp_userdata;
 };
@@ -529,7 +531,12 @@ static void stk_alpha_id_set(struct ofono_stk *stk,
 
 static void stk_alpha_id_unset(struct ofono_stk *stk)
 {
-   stk_agent_request_cancel(stk-current_agent);
+   /*
+* If there is no default agent, then current agent also will be NULL.
+* So, call request cancel only when there is a valid current agent.
+*/
+   if (stk-current_agent)
+   stk_agent_request_cancel(stk-current_agent);
 }
 
 static int duration_to_msecs(const struct stk_duration *duration)
@@ -1785,6 +1792,47 @@ static void confirm_call_cb(enum stk_agent_result 
result, gboolean confirm,
stk_command_cb(error, stk);
 }
 
+static void confirm_handled_call_cb(enum stk_agent_result result,
+   gboolean confirm, void *user_data)
+{
+   struct ofono_stk *stk = user_data;
+   const struct stk_command_setup_call *sc =
+   stk-pending_cmd-setup_call;
+   struct ofono_voicecall *vc = NULL;
+   struct ofono_atom *vc_atom;
+
+   if (stk-driver-user_confirmation == NULL)
+   goto out;
+
+   if (result != STK_AGENT_RESULT_OK) {
+   stk-driver-user_confirmation(stk, FALSE);
+   goto out;
+   }
+
+   stk-driver-user_confirmation(stk, confirm);
+
+   vc_atom = __ofono_modem_find_atom(__ofono_atom_get_modem(stk-atom),
+   OFONO_ATOM_TYPE_VOICECALL);
+   if (vc_atom)
+   vc = __ofono_atom_get_data(vc_atom);
+
+   if (vc == NULL)
+   goto out;
+
+   __ofono_voicecall_set_alpha_and_icon_id(vc, sc-addr.number,
+   sc-addr.ton_npi,
+   sc-alpha_id_call_setup,
+   sc-icon_id_call_setup.id);
+
+   stk-modem_handled_cmd = TRUE;
+
+   return;
+
+out:
+   stk_command_free(stk-pending_cmd);
+   stk-pending_cmd = NULL;
+}
+
 static gboolean handle_command_set_up_call(const struct stk_command *cmd,
struct stk_response *rsp,
struct ofono_stk *stk)
@@ -2601,8 +2649,75 @@ static gboolean handle_command_launch_browser(const 
struct stk_command *cmd,
return FALSE;
 }
 
+static void handle_setup_call_confirmation_req(struct stk_command *cmd,
+   struct ofono_stk *stk)
+{
+   const struct stk_command_setup_call *sc = cmd-setup_call;
+   int err;
+   char *alpha_id = dbus_apply_text_attributes(
+   sc-alpha_id_usr_cfm ?
+   sc-alpha_id_usr_cfm : ,
+   sc-text_attr_usr_cfm);
+   if (alpha_id == NULL)
+   goto out;
+
+   err = stk_agent_confirm_call(stk-current_agent, alpha_id,
+   sc-icon_id_usr_cfm,
+   confirm_handled_call_cb,
+   stk, NULL,
+   stk-timeout * 1000);
+   g_free(alpha_id);
+
+   if (err  0)
+   goto out;
+
+   stk-pending_cmd = cmd;
+   stk-cancel_cmd = stk_request_cancel;
+
+   return;
+
+out:
+   if (stk-driver-user_confirmation)
+   stk-driver-user_confirmation(stk, FALSE);
+
+   stk_command_free(cmd);
+}
+
+static void proactive_command_handled_end(struct ofono_stk *stk)
+{
+   stk-modem_handled_cmd = FALSE;
+
+   if (stk-pending_cmd == NULL)
+   return;
+
+   switch(stk-pending_cmd-type) {
+   case STK_COMMAND_TYPE_SETUP_CALL:
+   {
+   struct ofono_voicecall *vc = NULL;
+   struct ofono_atom *vc_atom;
+
+   vc_atom = __ofono_modem_find_atom(
+   __ofono_atom_get_modem(stk-atom),
+   OFONO_ATOM_TYPE_VOICECALL);
+   if (vc_atom)
+   vc = __ofono_atom_get_data(vc_atom);
+
+   if (vc != NULL)
+   __ofono_voicecall_clear_alpha_and_icon_id(vc);
+
+   break;
+   }
+
+   default:
+   break;
+   }
+}
+
 static void stk_proactive_command_cancel(struct ofono_stk *stk)
 {
+   if (stk-modem_handled_cmd == TRUE)
+   

Re: [PATCH 3/4] stk: Handle set up call in handled_notify

2011-07-15 Thread jeevaka . badrappan
Hi,

 @@ -529,7 +531,12 @@ static void stk_alpha_id_set(struct ofono_stk *stk,

  static void stk_alpha_id_unset(struct ofono_stk *stk)
  {
 - stk_agent_request_cancel(stk-current_agent);
 + /*
 +  * If there is no default agent, then current agent also will be NULL.
 +  * So, call request cancel only when there is a valid current agent.
 +  */
 + if (stk-current_agent)
 + stk_agent_request_cancel(stk-current_agent);
  }


If needed, I can send this code change alone in a separate fix patch.

Regards,
Jeevaka
___
ofono mailing list
ofono@ofono.org
http://lists.ofono.org/listinfo/ofono


[PATCH] stk: Fix crash seen in stk_alpha_id_unset

2011-07-15 Thread Jeevaka Badrappan
If there is no default agent, then current agent also will
be NULL. So, call stk_agent_request_cancel only when there is a valid
current agent.
---
 src/stk.c |7 ++-
 1 files changed, 6 insertions(+), 1 deletions(-)

diff --git a/src/stk.c b/src/stk.c
index 4df23b5..e8ffb42 100644
--- a/src/stk.c
+++ b/src/stk.c
@@ -529,7 +529,12 @@ static void stk_alpha_id_set(struct ofono_stk *stk,
 
 static void stk_alpha_id_unset(struct ofono_stk *stk)
 {
-   stk_agent_request_cancel(stk-current_agent);
+   /*
+* If there is no default agent, then current agent also will be NULL.
+* So, call request cancel only when there is a valid current agent.
+*/
+   if (stk-current_agent)
+   stk_agent_request_cancel(stk-current_agent);
 }
 
 static int duration_to_msecs(const struct stk_duration *duration)
-- 
1.7.4.1

___
ofono mailing list
ofono@ofono.org
http://lists.ofono.org/listinfo/ofono


Re: [PATCH 2/4] voicecall: api for set/clear alpha and icon id

2011-07-15 Thread jeevaka . badrappan
Hi Denis,

  }

 +if (vc-dial_req) {
 +v-message = vc-dial_req-message;
 +v-icon_id = vc-dial_req-icon_id;
 +
 +vc-dial_req-message = NULL;
 +vc-dial_req-call = v;
 +
 +newcall-phone_number.type = vc-dial_req-ph.type;
 +strncpy(newcall-phone_number.number, vc-dial_req-ph.number,
 +20);

 Do you really want to do this?  I suspect we should override the phone
 number information only if the CLIP validity is not valid.

Agreed.


 +
 +/*
 + * TS 102 223 Section 6.4.13: The terminal shall not store
 + * in the UICC the call set-up details (called party number
 + * and associated parameters)
 + */
 +v-untracked = TRUE;
 +}
 +

 This looks fine, but there's a very subtle thing going on which breaks
 one particular case.  Some background, voicecall driver is free to
 notify the call before returning from the atd callback, or vice versa.

 So e.g.

 #1
 driver-dial(.., cb, data);
 ofono_voicecall_notify()
 cb(data);

 or

 #2
 driver-dial(..., cb, data);
 cb(data);
 ofono_voicecall_notify()

 In the case that oFono generates the Set Up Call Request and assuming
 driver behavior #1, you end up performing some steps twice.  Perhaps we
 should set a flag in vc-flags to indicate that the call setup is being
 initiated by the modem, and only trigger this path if this flag is set.


I haven't seen the case where the call status is notified before dial
callback. But agreed, we will end up in steps twice in this case. Proposed
change is fine with me. Will be incorporated in the next version.

 +void __ofono_voicecall_clear_alpha_and_icon_id(struct ofono_voicecall
 *vc)
 +{
 +const char *number;
 +
 +if (vc-dial_req == NULL)
 +return;
 +
 +number = phone_number_to_string(vc-dial_req-ph);
 +
 +/*
 + * Incase the modem fails to setup the call and if there is no call
 + * created, then the emergency mode has to be cleared.
 + */
 +if (!strcmp(number, 112)) {
 +if (voicecalls_num_active(vc) == 0 
 +voicecalls_num_connecting(vc) == 0) {
 +struct ofono_modem *modem =
 +__ofono_atom_get_modem(vc-atom);
 +
 +__ofono_modem_dec_emergency_mode(modem);
 +}
 +}

 I'm guessing what you're trying to take care of here is the case that
 the set up call might have been canceled before the call was notified,
 right?

 Wouldn't it be better to do:

 if (vc-dial_req-call == NULL)
   ...

 ?

 However, in the end I think it is simpler to only initiate the emergency
 mode when we have the call, and let it be deactivated by the disconnect
 notification.  Then this function becomes way simpler.

 +
 +g_free(vc-dial_req-message);
 +vc-dial_req-message = NULL;
 +
 +g_free(vc-dial_req);
 +vc-dial_req = NULL;
 +}
 +

 However, I'm actually questioning the need for this function since the
 cancellation can only be accomplished by hanging up the call before it
 is active, in which case the modem will take care of sending the
 appropriate terminal response.

Here, I'm trying to cover the following case:

1. oFono core is informed of the modem handled setup call and requests
user confirmation
2. User confirms the call
3. User confirmation sent to modem.
4. Due to some reason, modem is not able to setup the call. So, basically
oFono core is not notified of any call status notifications
5. Modem sends the terminal response to SAT and notifies oFono core of the
command/session completion

Regards,
Jeevaka
___
ofono mailing list
ofono@ofono.org
http://lists.ofono.org/listinfo/ofono


Re: [PATCH 3/4] stk: Handle set up call in handled_notify

2011-07-15 Thread jeevaka . badrappan
Hi Denis,

 +static void proactive_command_handled_end(struct ofono_stk *stk)
 +{
 +stk-modem_handled_cmd = FALSE;
 +
 +if (stk-pending_cmd == NULL)
 +return;
 +
 +switch(stk-pending_cmd-type) {
 +case STK_COMMAND_TYPE_SETUP_CALL:
 +{
 +struct ofono_voicecall *vc = NULL;
 +struct ofono_atom *vc_atom;
 +
 +vc_atom = __ofono_modem_find_atom(
 +__ofono_atom_get_modem(stk-atom),
 +OFONO_ATOM_TYPE_VOICECALL);
 +if (vc_atom)
 +vc = __ofono_atom_get_data(vc_atom);
 +
 +if (vc != NULL)
 +__ofono_voicecall_clear_alpha_and_icon_id(vc);
 +
 +break;
 +}
 +
 +default:
 +break;
 +}
 +}
 +

 So I'm still not sure this part is actually needed.  Once the user has
 acknowledged the call, there is no way for us to cancel it until the
 call is notified to the voicecall driver.  So unless the modem is drunk,
 I don't really see the need to cover this case.

 Once the call is notified to voicecall driver, then the need for
 clearing alpha/icon id disappears.  The voicecall driver will do this
 automatically based on the ofono_voicecall_disconnected notification.

 What do you guys think?

As pointed in other mail thred, trying to cover the following case:

1. oFono core is informed of the modem handled setup call and requests
user confirmation
2. User confirms the call
3. User confirmation sent to modem.
4. Due to some reason, modem is not able to setup the call. So, basically
oFono core is not notified of any call status notifications
5. Modem sends the terminal response to SAT and notifies oFono core of the
command/session completion

Basically, if the modem due to some reason fails to initiate/setup the
call and call status notifications not sent to the voice call driver side.
This case, we will be left with dial_req, message and icon id set but not
freed.

Regards,
Jeevaka
___
ofono mailing list
ofono@ofono.org
http://lists.ofono.org/listinfo/ofono


Re: [PATCH 2/4] voicecall: api for set/clear alpha and icon id

2011-07-15 Thread jeevaka . badrappan
Hi Denis,

 +
 +number = phone_number_to_string(req-ph);
 +
 +if (!strcmp(number, 112)) {
 +struct ofono_modem *modem = __ofono_atom_get_modem(vc-atom);
 +
 +__ofono_modem_inc_emergency_mode(modem);
 +}

 I think we should do this step in the block of code in
 ofono_voicecall_notify dealing with modem callsetup.  See below for more:

Emergency mode for all other dial(user initiated, ofono handled setup
call) has been activated before we issue dial request to modem. Also I
believe its better to activate it here rather than in
ofono_voicecall_notify.

Regards,
Jeevaka
___
ofono mailing list
ofono@ofono.org
http://lists.ofono.org/listinfo/ofono


[PATCH 0/4] Add support for modem handled setup call proactive command

2011-07-06 Thread Jeevaka Badrappan
Hi,

 Following set of patches adds support for modem handled setup call proactive 
command.

Regards,
Jeevaka

Jeevaka Badrappan (4):
  include: Add driver api for user confirmation
  voicecall: api for set/clear alpha and icon id
  stk: Handle set up call in handled_notify
  ifxmodem: add support for user_confirmation in stk

 drivers/ifxmodem/stk.c |   11 +
 include/stk.h  |1 +
 src/ofono.h|5 ++
 src/stk.c  |  108 +++-
 src/voicecall.c|   21 +
 5 files changed, 144 insertions(+), 2 deletions(-)

-- 
1.7.4.1

___
ofono mailing list
ofono@ofono.org
http://lists.ofono.org/listinfo/ofono


[PATCH 2/4] voicecall: api for set/clear alpha and icon id

2011-07-06 Thread Jeevaka Badrappan
---
 src/ofono.h |5 +
 src/voicecall.c |   21 +
 2 files changed, 26 insertions(+), 0 deletions(-)

diff --git a/src/ofono.h b/src/ofono.h
index 6524806..118d762 100644
--- a/src/ofono.h
+++ b/src/ofono.h
@@ -266,6 +266,11 @@ int __ofono_voicecall_dial(struct ofono_voicecall *vc,
ofono_voicecall_dial_cb_t cb, void *user_data);
 void __ofono_voicecall_dial_cancel(struct ofono_voicecall *vc);
 
+void __ofono_voicecall_set_alpha_and_icon_id(struct ofono_voicecall *vc,
+   const char *message,
+   unsigned char icon_id);
+void __ofono_voicecall_clear_alpha_and_icon_id(struct ofono_voicecall *vc);
+
 int __ofono_voicecall_tone_send(struct ofono_voicecall *vc,
const char *tone_str,
ofono_voicecall_tone_cb_t cb, void *user_data);
diff --git a/src/voicecall.c b/src/voicecall.c
index 9620838..b193d61 100644
--- a/src/voicecall.c
+++ b/src/voicecall.c
@@ -74,6 +74,8 @@ struct ofono_voicecall {
struct dial_request *dial_req;
GQueue *toneq;
guint tone_source;
+   char *message;
+   uint8_t icon_id;
unsigned int hfp_watch;
GKeyFile *settings;
char *imsi;
@@ -656,6 +658,11 @@ static struct voicecall *voicecall_create(struct 
ofono_voicecall *vc,
v-call = call;
v-vc = vc;
 
+   if (vc-message != NULL) {
+   v-message = g_strdup(vc-message);
+   v-icon_id = vc-icon_id;
+   }
+
return v;
 }
 
@@ -3538,6 +3545,20 @@ void __ofono_voicecall_tone_cancel(struct 
ofono_voicecall *vc, int id)
}
 }
 
+void __ofono_voicecall_set_alpha_and_icon_id(struct ofono_voicecall *vc,
+   const char *message,
+   unsigned char icon_id)
+{
+   vc-message = g_strdup(message);
+   vc-icon_id = icon_id;
+}
+
+void __ofono_voicecall_clear_alpha_and_icon_id(struct ofono_voicecall *vc)
+{
+   g_free(vc-message);
+   vc-icon_id = 0;
+}
+
 static void ssn_mt_forwarded_notify(struct ofono_voicecall *vc,
unsigned int id, int code,
const struct ofono_phone_number *ph)
-- 
1.7.4.1

___
ofono mailing list
ofono@ofono.org
http://lists.ofono.org/listinfo/ofono


[PATCH 3/4] stk: Handle set up call in handled_notify

2011-07-06 Thread Jeevaka Badrappan
---
 src/stk.c |  108 +++-
 1 files changed, 106 insertions(+), 2 deletions(-)

diff --git a/src/stk.c b/src/stk.c
index 9575f0e..26faa11 100644
--- a/src/stk.c
+++ b/src/stk.c
@@ -77,6 +77,8 @@ struct ofono_stk {
struct timeval get_inkey_start_ts;
int dtmf_id;
 
+   gboolean modem_handled_cmd;
+
__ofono_sms_sim_download_cb_t sms_pp_cb;
void *sms_pp_userdata;
 };
@@ -1785,6 +1787,44 @@ static void confirm_call_cb(enum stk_agent_result 
result, gboolean confirm,
stk_command_cb(error, stk);
 }
 
+static void confirm_handled_call_cb(enum stk_agent_result result,
+   gboolean confirm, void *user_data)
+{
+   struct ofono_stk *stk = user_data;
+   const struct stk_command_setup_call *sc =
+   stk-pending_cmd-setup_call;
+   struct ofono_voicecall *vc = NULL;
+   struct ofono_atom *vc_atom;
+
+   if (stk-driver-user_confirmation == NULL)
+   goto out;
+
+   if (result != STK_AGENT_RESULT_OK) {
+   stk-driver-user_confirmation(stk, FALSE);
+   goto out;
+   }
+
+   stk-driver-user_confirmation(stk, confirm);
+
+   vc_atom = __ofono_modem_find_atom(__ofono_atom_get_modem(stk-atom),
+   OFONO_ATOM_TYPE_VOICECALL);
+   if (vc_atom)
+   vc = __ofono_atom_get_data(vc_atom);
+
+   if (vc == NULL)
+   goto out;
+
+   __ofono_voicecall_set_alpha_and_icon_id(vc, sc-alpha_id_call_setup,
+   sc-icon_id_call_setup.id);
+
+   stk-modem_handled_cmd = TRUE;
+
+   return;
+out:
+   stk_command_free(stk-pending_cmd);
+   stk-pending_cmd = NULL;
+}
+
 static gboolean handle_command_set_up_call(const struct stk_command *cmd,
struct stk_response *rsp,
struct ofono_stk *stk)
@@ -2601,6 +2641,40 @@ static gboolean handle_command_launch_browser(const 
struct stk_command *cmd,
return FALSE;
 }
 
+static void handle_setup_call_confirmation_req(struct stk_command *cmd,
+   struct ofono_stk *stk)
+{
+   const struct stk_command_setup_call *sc = cmd-setup_call;
+   int err;
+   char *alpha_id = dbus_apply_text_attributes(
+   sc-alpha_id_usr_cfm ?
+   sc-alpha_id_usr_cfm : ,
+   sc-text_attr_usr_cfm);
+   if (alpha_id == NULL)
+   goto out;
+
+   err = stk_agent_confirm_call(stk-current_agent, alpha_id,
+   sc-icon_id_usr_cfm,
+   confirm_handled_call_cb,
+   stk, NULL,
+   stk-timeout * 1000);
+   g_free(alpha_id);
+
+   if (err  0)
+   goto out;
+
+   stk-pending_cmd = cmd;
+   stk-cancel_cmd = stk_request_cancel;
+
+   return;
+
+out:
+   if (stk-driver-user_confirmation)
+   stk-driver-user_confirmation(stk, FALSE);
+
+   stk_command_free(cmd);
+}
+
 static void stk_proactive_command_cancel(struct ofono_stk *stk)
 {
if (stk-immediate_response)
@@ -2615,8 +2689,38 @@ static void stk_proactive_command_cancel(struct 
ofono_stk *stk)
}
 }
 
+static void proactive_session_end_handled_cmd(struct ofono_stk *stk)
+{
+   stk-modem_handled_cmd = FALSE;
+
+   switch(stk-pending_cmd-type) {
+   case STK_COMMAND_TYPE_SETUP_CALL:
+   {
+   struct ofono_voicecall *vc = NULL;
+   struct ofono_atom *vc_atom;
+
+   vc_atom = __ofono_modem_find_atom(
+   __ofono_atom_get_modem(stk-atom),
+   OFONO_ATOM_TYPE_VOICECALL);
+   if (vc_atom)
+   vc = __ofono_atom_get_data(vc_atom);
+
+   if (vc != NULL)
+   __ofono_voicecall_clear_alpha_and_icon_id(vc);
+
+   break;
+   }
+
+   default:
+   break;
+   }
+}
+
 void ofono_stk_proactive_session_end_notify(struct ofono_stk *stk)
 {
+   if (stk-modem_handled_cmd == TRUE)
+   proactive_session_end_handled_cmd(stk);
+
/* Wait until we receive the next command */
if (stk-immediate_response)
return;
@@ -2858,8 +2962,8 @@ void ofono_stk_proactive_command_handled_notify(struct 
ofono_stk *stk,
break;
 
case STK_COMMAND_TYPE_SETUP_CALL:
-   /* TODO */
-   break;
+   handle_setup_call_confirmation_req(cmd, stk);
+   return;
 
case STK_COMMAND_TYPE_SEND_USSD:
stk_alpha_id_set(stk, 

[PATCH 4/4] ifxmodem: add support for user_confirmation in stk

2011-07-06 Thread Jeevaka Badrappan
---
 drivers/ifxmodem/stk.c |   11 +++
 1 files changed, 11 insertions(+), 0 deletions(-)

diff --git a/drivers/ifxmodem/stk.c b/drivers/ifxmodem/stk.c
index f08cf47..d2082c4 100644
--- a/drivers/ifxmodem/stk.c
+++ b/drivers/ifxmodem/stk.c
@@ -173,6 +173,16 @@ error:
CALLBACK_WITH_FAILURE(cb, data);
 }
 
+static void ifx_stk_user_confirmation(struct ofono_stk *stk, gboolean confirm)
+{
+   struct stk_data *sd = ofono_stk_get_data(stk);
+   char buf[20];
+
+   snprintf(buf, sizeof(buf), AT+SATD=%i, confirm ? 1 : 0);
+
+   g_at_chat_send(sd-chat, buf, none_prefix, NULL, NULL, NULL);
+}
+
 static void sati_notify(GAtResult *result, gpointer user_data)
 {
struct ofono_stk *stk = user_data;
@@ -303,6 +313,7 @@ static struct ofono_stk_driver driver = {
.remove = ifx_stk_remove,
.envelope   = ifx_stk_envelope,
.terminal_response  = ifx_stk_terminal_response,
+   .user_confirmation  = ifx_stk_user_confirmation,
 };
 
 void ifx_stk_init(void)
-- 
1.7.4.1

___
ofono mailing list
ofono@ofono.org
http://lists.ofono.org/listinfo/ofono


Re: [PATCH] ifxmodem: emergency number list support

2011-06-09 Thread jeevaka . badrappan
Hi Denis,

 +
 +if (!g_at_result_iter_next_number(iter, total_cnt))
 +return;
 +
 +if (!g_at_result_iter_next_string(iter, number))
 +return;
 +
 +/* Skip the category, valid in simpresent and mcc fields */

 What is this comment referring to?

Following fields like category, valid in sim present state and mcc are
skipped as we are not going to use it. Just for information purpose.
I'll remove the comment.


 +
 +if (vd-en_list == NULL)
 +vd-en_list = g_new0(char *, total_cnt + 1);
 +
 +vd-en_list[count] = g_strdup(number);
 +
 +if (index != total_cnt)
 +return;
 +
 +ofono_voicecall_en_list_notify(vc, vd-en_list);
 +
 +g_strfreev(vd-en_list);
 +vd-en_list = NULL;
 +}
 +
 +static void xlema_read(gboolean ok, GAtResult *result, gpointer
 user_data)
 +{
 +struct ofono_voicecall *vc = user_data;
 +struct voicecall_data *vd = ofono_voicecall_get_data(vc);
 +GAtResultIter iter;
 +int num = 0;
 +int index, total_cnt;
 +const char *number;
 +
 +if (!ok) {
 +DBG(Emergency number list read failed);
 +return;
 +}
 +
 +g_at_result_iter_init(iter, result);
 +
 +while (g_at_result_iter_next(iter, +XLEMA:))
 +num += 1;
 +
 +vd-en_list = g_new0(char *, num + 1);
 +
 +num = 0;
 +g_at_result_iter_init(iter, result);
 +
 +while (g_at_result_iter_next(iter, +XLEMA:)) {
 +if (!g_at_result_iter_next_number(iter, index))
 +continue;
 +
 +if (!g_at_result_iter_next_number(iter, total_cnt))
 +continue;
 +
 +if (!g_at_result_iter_next_string(iter, number))
 +continue;
 +
 +/* Skip the category, valid in simpresent and mcc fields */
 +g_at_result_iter_skip_next(iter);
 +g_at_result_iter_skip_next(iter);
 +g_at_result_iter_skip_next(iter);

 What are you trying to achieve here?  Since you're not checking the
 result, it doesn't look like this code serves any purpose.

Agreed no pointing in having this as we are not going to make use of the
fields. Will be removed.

Regards,
Jeevaka
___
ofono mailing list
ofono@ofono.org
http://lists.ofono.org/listinfo/ofono


[PATCH v2] ifxmodem: emergency number list support

2011-06-09 Thread Jeevaka Badrappan
---
 drivers/ifxmodem/voicecall.c |   88 ++
 1 files changed, 88 insertions(+), 0 deletions(-)

diff --git a/drivers/ifxmodem/voicecall.c b/drivers/ifxmodem/voicecall.c
index 87a48e6..bd2c6c3 100644
--- a/drivers/ifxmodem/voicecall.c
+++ b/drivers/ifxmodem/voicecall.c
@@ -42,11 +42,13 @@
 #include ifxmodem.h
 
 static const char *none_prefix[] = { NULL };
+static const char *xlema_prefix[] = { +XLEMA:, NULL };
 
 struct voicecall_data {
GSList *calls;
unsigned int local_release;
GAtChat *chat;
+   char **en_list;
 };
 
 struct release_id_req {
@@ -786,6 +788,86 @@ static void xcolp_notify(GAtResult *result, gpointer 
user_data)
ofono_voicecall_notify(vc, call);
 }
 
+static void xlema_notify(GAtResult *result, gpointer user_data)
+{
+   struct ofono_voicecall *vc = user_data;
+   struct voicecall_data *vd = ofono_voicecall_get_data(vc);
+   GAtResultIter iter;
+   int index, total_cnt;
+   const char *number;
+   int count = (vd-en_list == NULL) ? 0 : g_strv_length(vd-en_list);
+
+   g_at_result_iter_init(iter, result);
+
+   if (!g_at_result_iter_next(iter, +XLEMA:))
+   return;
+
+   if (!g_at_result_iter_next_number(iter, index))
+   return;
+
+   if (!g_at_result_iter_next_number(iter, total_cnt))
+   return;
+
+   if (!g_at_result_iter_next_string(iter, number))
+   return;
+
+   if (vd-en_list == NULL)
+   vd-en_list = g_new0(char *, total_cnt + 1);
+
+   vd-en_list[count] = g_strdup(number);
+
+   if (index != total_cnt)
+   return;
+
+   ofono_voicecall_en_list_notify(vc, vd-en_list);
+
+   g_strfreev(vd-en_list);
+   vd-en_list = NULL;
+}
+
+static void xlema_read(gboolean ok, GAtResult *result, gpointer user_data)
+{
+   struct ofono_voicecall *vc = user_data;
+   struct voicecall_data *vd = ofono_voicecall_get_data(vc);
+   GAtResultIter iter;
+   int num = 0;
+   int index, total_cnt;
+   const char *number;
+
+   if (!ok) {
+   DBG(Emergency number list read failed);
+   return;
+   }
+
+   g_at_result_iter_init(iter, result);
+
+   while (g_at_result_iter_next(iter, +XLEMA:))
+   num += 1;
+
+   vd-en_list = g_new0(char *, num + 1);
+
+   num = 0;
+   g_at_result_iter_init(iter, result);
+
+   while (g_at_result_iter_next(iter, +XLEMA:)) {
+   if (!g_at_result_iter_next_number(iter, index))
+   continue;
+
+   if (!g_at_result_iter_next_number(iter, total_cnt))
+   continue;
+
+   if (!g_at_result_iter_next_string(iter, number))
+   continue;
+
+   vd-en_list[num++] = g_strdup(number);
+   }
+
+   ofono_voicecall_en_list_notify(vc, vd-en_list);
+
+   g_strfreev(vd-en_list);
+   vd-en_list = NULL;
+}
+
 static void ifx_voicecall_initialized(gboolean ok, GAtResult *result,
gpointer user_data)
 {
@@ -802,6 +884,10 @@ static void ifx_voicecall_initialized(gboolean ok, 
GAtResult *result,
g_at_chat_register(vd-chat, +XCALLSTAT:, xcallstat_notify,
FALSE, vc, NULL);
g_at_chat_register(vd-chat, +XCOLP:, xcolp_notify, FALSE, vc, NULL);
+   g_at_chat_register(vd-chat, +XLEMA:, xlema_notify, FALSE, vc, NULL);
+   /* Enable emergency number list notification */
+   g_at_chat_send(vd-chat, AT+XLEMA=1, xlema_prefix, xlema_read, vc,
+   NULL);
 
ofono_voicecall_register(vc);
 }
@@ -840,6 +926,8 @@ static void ifx_voicecall_remove(struct ofono_voicecall *vc)
g_slist_foreach(vd-calls, (GFunc) g_free, NULL);
g_slist_free(vd-calls);
 
+   g_strfreev(vd-en_list);
+
ofono_voicecall_set_data(vc, NULL);
 
g_at_chat_unref(vd-chat);
-- 
1.7.4.1

___
ofono mailing list
ofono@ofono.org
http://lists.ofono.org/listinfo/ofono


[PATCH] ifxmodem: emergency number list support

2011-06-08 Thread Jeevaka Badrappan
---
 drivers/ifxmodem/voicecall.c |   95 ++
 1 files changed, 95 insertions(+), 0 deletions(-)

diff --git a/drivers/ifxmodem/voicecall.c b/drivers/ifxmodem/voicecall.c
index 87a48e6..0aa83e4 100644
--- a/drivers/ifxmodem/voicecall.c
+++ b/drivers/ifxmodem/voicecall.c
@@ -42,11 +42,13 @@
 #include ifxmodem.h
 
 static const char *none_prefix[] = { NULL };
+static const char *xlema_prefix[] = { +XLEMA:, NULL };
 
 struct voicecall_data {
GSList *calls;
unsigned int local_release;
GAtChat *chat;
+   char **en_list;
 };
 
 struct release_id_req {
@@ -786,6 +788,93 @@ static void xcolp_notify(GAtResult *result, gpointer 
user_data)
ofono_voicecall_notify(vc, call);
 }
 
+static void xlema_notify(GAtResult *result, gpointer user_data)
+{
+   struct ofono_voicecall *vc = user_data;
+   struct voicecall_data *vd = ofono_voicecall_get_data(vc);
+   GAtResultIter iter;
+   int index, total_cnt;
+   const char *number;
+   int count = (vd-en_list == NULL) ? 0 : g_strv_length(vd-en_list);
+
+   g_at_result_iter_init(iter, result);
+
+   if (!g_at_result_iter_next(iter, +XLEMA:))
+   return;
+
+   if (!g_at_result_iter_next_number(iter, index))
+   return;
+
+   if (!g_at_result_iter_next_number(iter, total_cnt))
+   return;
+
+   if (!g_at_result_iter_next_string(iter, number))
+   return;
+
+   /* Skip the category, valid in simpresent and mcc fields */
+
+   if (vd-en_list == NULL)
+   vd-en_list = g_new0(char *, total_cnt + 1);
+
+   vd-en_list[count] = g_strdup(number);
+
+   if (index != total_cnt)
+   return;
+
+   ofono_voicecall_en_list_notify(vc, vd-en_list);
+
+   g_strfreev(vd-en_list);
+   vd-en_list = NULL;
+}
+
+static void xlema_read(gboolean ok, GAtResult *result, gpointer user_data)
+{
+   struct ofono_voicecall *vc = user_data;
+   struct voicecall_data *vd = ofono_voicecall_get_data(vc);
+   GAtResultIter iter;
+   int num = 0;
+   int index, total_cnt;
+   const char *number;
+
+   if (!ok) {
+   DBG(Emergency number list read failed);
+   return;
+   }
+
+   g_at_result_iter_init(iter, result);
+
+   while (g_at_result_iter_next(iter, +XLEMA:))
+   num += 1;
+
+   vd-en_list = g_new0(char *, num + 1);
+
+   num = 0;
+   g_at_result_iter_init(iter, result);
+
+   while (g_at_result_iter_next(iter, +XLEMA:)) {
+   if (!g_at_result_iter_next_number(iter, index))
+   continue;
+
+   if (!g_at_result_iter_next_number(iter, total_cnt))
+   continue;
+
+   if (!g_at_result_iter_next_string(iter, number))
+   continue;
+
+   /* Skip the category, valid in simpresent and mcc fields */
+   g_at_result_iter_skip_next(iter);
+   g_at_result_iter_skip_next(iter);
+   g_at_result_iter_skip_next(iter);
+
+   vd-en_list[num++] = g_strdup(number);
+   }
+
+   ofono_voicecall_en_list_notify(vc, vd-en_list);
+
+   g_strfreev(vd-en_list);
+   vd-en_list = NULL;
+}
+
 static void ifx_voicecall_initialized(gboolean ok, GAtResult *result,
gpointer user_data)
 {
@@ -802,6 +891,10 @@ static void ifx_voicecall_initialized(gboolean ok, 
GAtResult *result,
g_at_chat_register(vd-chat, +XCALLSTAT:, xcallstat_notify,
FALSE, vc, NULL);
g_at_chat_register(vd-chat, +XCOLP:, xcolp_notify, FALSE, vc, NULL);
+   g_at_chat_register(vd-chat, +XLEMA:, xlema_notify, FALSE, vc, NULL);
+   /* Enable emergency number list notification */
+   g_at_chat_send(vd-chat, AT+XLEMA=1, xlema_prefix, xlema_read, vc,
+   NULL);
 
ofono_voicecall_register(vc);
 }
@@ -840,6 +933,8 @@ static void ifx_voicecall_remove(struct ofono_voicecall *vc)
g_slist_foreach(vd-calls, (GFunc) g_free, NULL);
g_slist_free(vd-calls);
 
+   g_strfreev(vd-en_list);
+
ofono_voicecall_set_data(vc, NULL);
 
g_at_chat_unref(vd-chat);
-- 
1.7.4.1

___
ofono mailing list
ofono@ofono.org
http://lists.ofono.org/listinfo/ofono


[PATCH v4 1/4] include: Add ofono_voicecall_en_list_notify api

2011-04-06 Thread Jeevaka Badrappan
---
 include/voicecall.h |3 +++
 1 files changed, 3 insertions(+), 0 deletions(-)

diff --git a/include/voicecall.h b/include/voicecall.h
index 6ae06a9..a373c64 100644
--- a/include/voicecall.h
+++ b/include/voicecall.h
@@ -135,6 +135,9 @@ struct ofono_voicecall_driver {
ofono_voicecall_cb_t cb, void *data);
 };
 
+void ofono_voicecall_en_list_notify(struct ofono_voicecall *vc,
+   char **nw_en_list);
+
 void ofono_voicecall_notify(struct ofono_voicecall *vc,
const struct ofono_call *call);
 void ofono_voicecall_disconnected(struct ofono_voicecall *vc, int id,
-- 
1.7.0.4

___
ofono mailing list
ofono@ofono.org
http://lists.ofono.org/listinfo/ofono


[PATCH v4 2/4] voicecall: refactor emergency number list handling

2011-04-06 Thread Jeevaka Badrappan
---
 src/voicecall.c |  143 ---
 1 files changed, 72 insertions(+), 71 deletions(-)

diff --git a/src/voicecall.c b/src/voicecall.c
index 469b939..b0f15fd 100644
--- a/src/voicecall.c
+++ b/src/voicecall.c
@@ -46,8 +46,9 @@ struct ofono_voicecall {
GSList *call_list;
GSList *release_list;
GSList *multiparty_list;
-   GSList *en_list;  /* emergency number list */
-   GSList *new_en_list; /* Emergency numbers being read from SIM */
+   GHashTable *en_list; /* emergency number list */
+   GSList *sim_en_list; /* Emergency numbers being read from SIM */
+   ofono_bool_t sim_en_list_ready;
DBusMessage *pending;
struct ofono_sim *sim;
struct ofono_sim_context *sim_context;
@@ -130,11 +131,12 @@ static gint call_compare(gconstpointer a, gconstpointer b)
return 0;
 }
 
-static void add_to_en_list(GSList **l, const char **list)
+static void add_to_en_list(struct ofono_voicecall *vc, char **list)
 {
int i = 0;
+
while (list[i])
-   *l = g_slist_prepend(*l, g_strdup(list[i++]));
+   g_hash_table_insert(vc-en_list, g_strdup(list[i++]), NULL);
 }
 
 static const char *disconnect_reason_to_string(enum ofono_disconnect_reason r)
@@ -331,17 +333,10 @@ static void tone_request_finish(struct ofono_voicecall 
*vc,
g_free(entry);
 }
 
-static gint number_compare(gconstpointer a, gconstpointer b)
-{
-   const char *s1 = a, *s2 = b;
-   return strcmp(s1, s2);
-}
-
 static gboolean is_emergency_number(struct ofono_voicecall *vc,
const char *number)
 {
-   return g_slist_find_custom(vc-en_list, number,
-   number_compare) ? TRUE : FALSE;
+   return g_hash_table_lookup_extended(vc-en_list, number, NULL, NULL);
 }
 
 static void append_voicecall_properties(struct voicecall *v,
@@ -1120,9 +1115,10 @@ static DBusMessage 
*manager_get_properties(DBusConnection *conn,
DBusMessage *reply;
DBusMessageIter iter;
DBusMessageIter dict;
-   int i;
-   GSList *l;
+   int i = 0;
char **list;
+   GHashTableIter ht_iter;
+   gpointer key, value;
 
reply = dbus_message_new_method_return(msg);
if (reply == NULL)
@@ -1135,14 +1131,16 @@ static DBusMessage 
*manager_get_properties(DBusConnection *conn,
dict);
 
/* property EmergencyNumbers */
-   list = g_new0(char *, g_slist_length(vc-en_list) + 1);
+   list = g_new0(char *, g_hash_table_size(vc-en_list) + 1);
+
+   g_hash_table_iter_init(ht_iter, vc-en_list);
 
-   for (i = 0, l = vc-en_list; l; l = l-next, i++)
-   list[i] = g_strdup(l-data);
+   while (g_hash_table_iter_next(ht_iter, key, value))
+   list[i++] = key;
 
ofono_dbus_dict_append_array(dict, EmergencyNumbers,
DBUS_TYPE_STRING, list);
-   g_strfreev(list);
+   g_free(list);
 
dbus_message_iter_close_container(iter, dict);
 
@@ -2068,46 +2066,43 @@ static void emit_en_list_changed(struct ofono_voicecall 
*vc)
DBusConnection *conn = ofono_dbus_get_connection();
const char *path = __ofono_atom_get_path(vc-atom);
char **list;
-   GSList *l;
-   int i;
+   int i = 0;
+   GHashTableIter iter;
+   gpointer key, value;
 
-   list = g_new0(char *, g_slist_length(vc-en_list) + 1);
-   for (i = 0, l = vc-en_list; l; l = l-next, i++)
-   list[i] = g_strdup(l-data);
+   list = g_new0(char *, g_hash_table_size(vc-en_list) + 1);
+
+   g_hash_table_iter_init(iter, vc-en_list);
+
+   while (g_hash_table_iter_next(iter, key, value))
+   list[i++] = key;
 
ofono_dbus_signal_array_property_changed(conn, path,
OFONO_VOICECALL_MANAGER_INTERFACE,
EmergencyNumbers, DBUS_TYPE_STRING, list);
 
-   g_strfreev(list);
+   g_free(list);
 }
 
 static void set_new_ecc(struct ofono_voicecall *vc)
 {
-   int i = 0;
-
-   g_slist_foreach(vc-en_list, (GFunc) g_free, NULL);
-   g_slist_free(vc-en_list);
-   vc-en_list = NULL;
-
-   vc-en_list = vc-new_en_list;
-   vc-new_en_list = NULL;
+   GSList *l;
 
-   while (default_en_list[i]) {
-   GSList *l;
+   g_hash_table_destroy(vc-en_list);
 
-   for (l = vc-en_list; l; l = l-next)
-   if (!strcmp(l-data, default_en_list[i]))
-   break;
+   vc-en_list = g_hash_table_new_full(g_str_hash, g_str_equal,
+   g_free, NULL);
 
-   if (l == NULL)
-   vc-en_list = g_slist_prepend(vc-en_list,
-   g_strdup(default_en_list[i]));
-
- 

[PATCH v4 0/4] Support of Network / Modem updated emergency numbers

2011-04-06 Thread Jeevaka Badrappan
Hi,

 Following set of patch adds the support for emergency number list update
from the network/modem in the oFono core.

Regards,
Jeevaka

Jeevaka Badrappan (4):
  include: Add ofono_voicecall_en_list_notify api
  voicecall: refactor emergency number list handling
  voicecall: network emergency number list support
  TODO: Mark Network/Modem EN update task as done

 TODO|   11 
 doc/features.txt|   18 +++---
 include/voicecall.h |3 +
 src/voicecall.c |  160 --
 4 files changed, 103 insertions(+), 89 deletions(-)

___
ofono mailing list
ofono@ofono.org
http://lists.ofono.org/listinfo/ofono


[PATCH v4 3/4] voicecall: network emergency number list support

2011-04-06 Thread Jeevaka Badrappan
---
 src/voicecall.c |   19 +++
 1 files changed, 19 insertions(+), 0 deletions(-)

diff --git a/src/voicecall.c b/src/voicecall.c
index b0f15fd..19ef479 100644
--- a/src/voicecall.c
+++ b/src/voicecall.c
@@ -49,6 +49,7 @@ struct ofono_voicecall {
GHashTable *en_list; /* emergency number list */
GSList *sim_en_list; /* Emergency numbers being read from SIM */
ofono_bool_t sim_en_list_ready;
+   char **nw_en_list; /* Emergency numbers from modem/network */
DBusMessage *pending;
struct ofono_sim *sim;
struct ofono_sim_context *sim_context;
@@ -2093,6 +2094,10 @@ static void set_new_ecc(struct ofono_voicecall *vc)
vc-en_list = g_hash_table_new_full(g_str_hash, g_str_equal,
g_free, NULL);
 
+   /* Emergency numbers from modem/network */
+   if (vc-nw_en_list)
+   add_to_en_list(vc, vc-nw_en_list);
+
/* Emergency numbers read from SIM */
if (vc-sim_en_list_ready == TRUE  vc-sim_en_list) {
for (l = vc-sim_en_list; l; l = l-next)
@@ -2175,6 +2180,15 @@ check:
set_new_ecc(vc);
 }
 
+void ofono_voicecall_en_list_notify(struct ofono_voicecall *vc,
+   char **nw_en_list)
+{
+   g_strfreev(vc-nw_en_list);
+
+   vc-nw_en_list = g_strdupv(nw_en_list);
+   set_new_ecc(vc);
+}
+
 int ofono_voicecall_driver_register(const struct ofono_voicecall_driver *d)
 {
DBG(driver: %p, name: %s, d, d-name);
@@ -2220,6 +2234,11 @@ static void voicecall_unregister(struct ofono_atom *atom)
vc-sim_en_list = NULL;
}
 
+   if (vc-nw_en_list) {
+   g_strfreev(vc-nw_en_list);
+   vc-nw_en_list = NULL;
+   }
+
g_hash_table_destroy(vc-en_list);
vc-en_list = NULL;
 
-- 
1.7.0.4

___
ofono mailing list
ofono@ofono.org
http://lists.ofono.org/listinfo/ofono


[PATCH v4 4/4] TODO: Mark Network/Modem EN update task as done

2011-04-06 Thread Jeevaka Badrappan
---
 TODO |   11 ---
 doc/features.txt |   18 ++
 2 files changed, 10 insertions(+), 19 deletions(-)

diff --git a/TODO b/TODO
index 85c5ad1..3491436 100644
--- a/TODO
+++ b/TODO
@@ -289,17 +289,6 @@ Sim Toolkit
   Complexity: C2
   Owner: Philippe Nunes philippe.nu...@linux.intel.com
 
-Emergency Calls
-===
-
-- Network / Modem updating of the emergency number list. Support the list of
-  emergency numbers dynamically updated by the network or by the modem (e.g.
-  additional numbers burned into modem ROM).
-
-  Priority: High
-  Complexity: C2
-
-
 Miscellaneous
 =
 
diff --git a/doc/features.txt b/doc/features.txt
index eb945c3..68d0676 100644
--- a/doc/features.txt
+++ b/doc/features.txt
@@ -583,14 +583,16 @@ Text Telephony
 Emergency Calls
 ===
 
-- EFecc support.  During SIM initialization phase oFono reads EFecc in order
-  to bootstrap the emergency calling codes provides by the SIM.  If the SIM is
-  not present or EFecc has not been read yet, the default set of emergency
-  calling codes is used.
-
-- Emergency number reporting.  The current known list of emergency calling
-  codes is reported by oFono in the EmergencyNumbers property on the
-  VoicecallManager interface.  When a voicecall is made to a number present
+- Emergency number reporting.  During SIM initialization phase oFono reads
+  EFecc in order to bootstrap the emergency calling codes provided by the SIM.
+  Emergency number list is exposed via the EmergencyNumbers property on the
+  VoicecallManager interface.  If SIM is present, list is the union of default
+  emergency numbers(112, 911), numbers in EFecc and Network / Modem reported
+  emergency numbers.  If SIM is not present or EFecc has not been read yet,
+  list is the union of default emergency numbers(112, 911) and emergency
+  numbers without SIM(119, 118, 999, 110, 08 and 000).
+
+- Emergency call reporting.  When a voicecall is made to a number present
   on the EmergencyNumbers list it is automatically flagged as an emergency
   call.  This is done by setting the Emergency property on the Voicecall
   interface to TRUE.
-- 
1.7.0.4

___
ofono mailing list
ofono@ofono.org
http://lists.ofono.org/listinfo/ofono


[PATCH v3 2/4] voicecall: refactor emergency number list handling

2011-04-02 Thread Jeevaka Badrappan
---
 src/voicecall.c |  135 ---
 1 files changed, 68 insertions(+), 67 deletions(-)

diff --git a/src/voicecall.c b/src/voicecall.c
index 3e8fa46..60b8db5 100644
--- a/src/voicecall.c
+++ b/src/voicecall.c
@@ -46,8 +46,9 @@ struct ofono_voicecall {
GSList *call_list;
GSList *release_list;
GSList *multiparty_list;
-   GSList *en_list;  /* emergency number list */
-   GSList *new_en_list; /* Emergency numbers being read from SIM */
+   GHashTable *en_list; /* emergency number list */
+   GSList *sim_en_list; /* Emergency numbers being read from SIM */
+   char **new_en_list; /* Emergency numbers from modem/network/NO SIM */
DBusMessage *pending;
struct ofono_sim *sim;
struct ofono_sim_context *sim_context;
@@ -130,11 +131,12 @@ static gint call_compare(gconstpointer a, gconstpointer b)
return 0;
 }
 
-static void add_to_en_list(GSList **l, const char **list)
+static void add_to_en_list(struct ofono_voicecall *vc, char **list)
 {
int i = 0;
+
while (list[i])
-   *l = g_slist_prepend(*l, g_strdup(list[i++]));
+   g_hash_table_insert(vc-en_list, g_strdup(list[i++]), NULL);
 }
 
 static const char *disconnect_reason_to_string(enum ofono_disconnect_reason r)
@@ -331,12 +333,6 @@ static void tone_request_finish(struct ofono_voicecall *vc,
g_free(entry);
 }
 
-static gint number_compare(gconstpointer a, gconstpointer b)
-{
-   const char *s1 = a, *s2 = b;
-   return strcmp(s1, s2);
-}
-
 static gboolean voicecall_is_emergency(struct voicecall *v)
 {
struct ofono_call *call = v-call;
@@ -344,8 +340,8 @@ static gboolean voicecall_is_emergency(struct voicecall *v)
 
lineid_str = phone_number_to_string(call-phone_number);
 
-   return g_slist_find_custom(v-vc-en_list, lineid_str,
-   number_compare) ? TRUE : FALSE;
+   return g_hash_table_lookup_extended(v-vc-en_list, lineid_str,
+   NULL, NULL);
 }
 
 static void append_voicecall_properties(struct voicecall *v,
@@ -1124,9 +1120,10 @@ static DBusMessage 
*manager_get_properties(DBusConnection *conn,
DBusMessage *reply;
DBusMessageIter iter;
DBusMessageIter dict;
-   int i;
-   GSList *l;
+   int i = 0;
char **list;
+   GHashTableIter ht_iter;
+   gpointer key, value;
 
reply = dbus_message_new_method_return(msg);
if (reply == NULL)
@@ -1139,10 +1136,12 @@ static DBusMessage 
*manager_get_properties(DBusConnection *conn,
dict);
 
/* property EmergencyNumbers */
-   list = g_new0(char *, g_slist_length(vc-en_list) + 1);
+   list = g_new0(char *, g_hash_table_size(vc-en_list) + 1);
+
+   g_hash_table_iter_init(ht_iter, vc-en_list);
 
-   for (i = 0, l = vc-en_list; l; l = l-next, i++)
-   list[i] = g_strdup(l-data);
+   while (g_hash_table_iter_next(ht_iter, key, value))
+   list[i++] = g_strdup(key);
 
ofono_dbus_dict_append_array(dict, EmergencyNumbers,
DBUS_TYPE_STRING, list);
@@ -2054,12 +2053,16 @@ static void emit_en_list_changed(struct ofono_voicecall 
*vc)
DBusConnection *conn = ofono_dbus_get_connection();
const char *path = __ofono_atom_get_path(vc-atom);
char **list;
-   GSList *l;
-   int i;
+   int i = 0;
+   GHashTableIter iter;
+   gpointer key, value;
 
-   list = g_new0(char *, g_slist_length(vc-en_list) + 1);
-   for (i = 0, l = vc-en_list; l; l = l-next, i++)
-   list[i] = g_strdup(l-data);
+   list = g_new0(char *, g_hash_table_size(vc-en_list) + 1);
+
+   g_hash_table_iter_init(iter, vc-en_list);
+
+   while (g_hash_table_iter_next(iter, key, value))
+   list[i++] = g_strdup(key);
 
ofono_dbus_signal_array_property_changed(conn, path,
OFONO_VOICECALL_MANAGER_INTERFACE,
@@ -2070,30 +2073,25 @@ static void emit_en_list_changed(struct ofono_voicecall 
*vc)
 
 static void set_new_ecc(struct ofono_voicecall *vc)
 {
-   int i = 0;
+   GSList *l;
 
-   g_slist_foreach(vc-en_list, (GFunc) g_free, NULL);
-   g_slist_free(vc-en_list);
-   vc-en_list = NULL;
+   g_hash_table_destroy(vc-en_list);
 
-   vc-en_list = vc-new_en_list;
-   vc-new_en_list = NULL;
+   vc-en_list = g_hash_table_new_full(g_str_hash, g_str_equal,
+   g_free, NULL);
 
-   while (default_en_list[i]) {
-   GSList *l;
+   if (vc-new_en_list)
+   add_to_en_list(vc, vc-new_en_list);
 
-   for (l = vc-en_list; l; l = l-next)
-   if (!strcmp(l-data, default_en_list[i]))
-   break;
+   

[PATCH v3 1/4] include: Add ofono_voicecall_en_list_notify api

2011-04-01 Thread Jeevaka Badrappan
---
 include/voicecall.h |3 +++
 1 files changed, 3 insertions(+), 0 deletions(-)

diff --git a/include/voicecall.h b/include/voicecall.h
index 5e6da02..73eee26 100644
--- a/include/voicecall.h
+++ b/include/voicecall.h
@@ -140,6 +140,9 @@ struct ofono_voicecall_driver {
ofono_voicecall_cb_t cb, void *data);
 };
 
+void ofono_voicecall_en_list_notify(struct ofono_voicecall *vc,
+   char **nw_en_list);
+
 void ofono_voicecall_notify(struct ofono_voicecall *vc,
const struct ofono_call *call);
 void ofono_voicecall_disconnected(struct ofono_voicecall *vc, int id,
-- 
1.7.0.4

___
ofono mailing list
ofono@ofono.org
http://lists.ofono.org/listinfo/ofono


[PATCH v3 0/4] Support for emergency number list from network/modem

2011-04-01 Thread Jeevaka Badrappan
Hi,

 Following set of patch adds the emergency number list update from
the network/modem. Upon emergency number list update from modem, ofono
core will be updated which will result in dbus property change signal
as well. With this patch, even if the emergency number list maintained
in ofono matches with the received emergency number list from modem,
dbus property change will be signalled. If this should be avoided,
then it needs to be decided whether the check should be added in core
or for each modem.

Regards,
Jeevaka

Jeevaka Badrappan (4):
  include: Add ofono_voicecall_en_list_notify api
  voicecall: refactor emergency number list handling
  voicecall: network emergency number list support
  ifxmodem: emergency number list support

 drivers/ifxmodem/voicecall.c |   99 +
 include/voicecall.h  |3 +
 src/voicecall.c  |  142 ++
 3 files changed, 177 insertions(+), 67 deletions(-)

___
ofono mailing list
ofono@ofono.org
http://lists.ofono.org/listinfo/ofono


[PATCH v3 2/4] voicecall: refactor emergency number list handling

2011-04-01 Thread Jeevaka Badrappan
---
 src/voicecall.c |  135 ---
 1 files changed, 68 insertions(+), 67 deletions(-)

diff --git a/src/voicecall.c b/src/voicecall.c
index b1d5586..d7d8424 100644
--- a/src/voicecall.c
+++ b/src/voicecall.c
@@ -46,8 +46,9 @@ struct ofono_voicecall {
GSList *call_list;
GSList *release_list;
GSList *multiparty_list;
-   GSList *en_list;  /* emergency number list */
-   GSList *new_en_list; /* Emergency numbers being read from SIM */
+   GHashTable *en_list; /* emergency number list */
+   GSList *sim_en_list; /* Emergency numbers being read from SIM */
+   char **new_en_list; /* Emergency numbers from modem/network/NO SIM */
DBusMessage *pending;
struct ofono_sim *sim;
struct ofono_sim_context *sim_context;
@@ -130,11 +131,12 @@ static gint call_compare(gconstpointer a, gconstpointer b)
return 0;
 }
 
-static void add_to_en_list(GSList **l, const char **list)
+static void add_to_en_list(struct ofono_voicecall *vc, char **list)
 {
int i = 0;
+
while (list[i])
-   *l = g_slist_prepend(*l, g_strdup(list[i++]));
+   g_hash_table_insert(vc-en_list, g_strdup(list[i++]), NULL);
 }
 
 static const char *disconnect_reason_to_string(enum ofono_disconnect_reason r)
@@ -331,12 +333,6 @@ static void tone_request_finish(struct ofono_voicecall *vc,
g_free(entry);
 }
 
-static gint number_compare(gconstpointer a, gconstpointer b)
-{
-   const char *s1 = a, *s2 = b;
-   return strcmp(s1, s2);
-}
-
 static gboolean voicecall_is_emergency(struct voicecall *v)
 {
struct ofono_call *call = v-call;
@@ -344,8 +340,8 @@ static gboolean voicecall_is_emergency(struct voicecall *v)
 
lineid_str = phone_number_to_string(call-phone_number);
 
-   return g_slist_find_custom(v-vc-en_list, lineid_str,
-   number_compare) ? TRUE : FALSE;
+   return g_hash_table_lookup_extended(v-vc-en_list, lineid_str,
+   NULL, NULL);
 }
 
 static void append_voicecall_properties(struct voicecall *v,
@@ -1124,9 +1120,10 @@ static DBusMessage 
*manager_get_properties(DBusConnection *conn,
DBusMessage *reply;
DBusMessageIter iter;
DBusMessageIter dict;
-   int i;
-   GSList *l;
+   int i = 0;
char **list;
+   GHashTableIter ht_iter;
+   gpointer key, value;
 
reply = dbus_message_new_method_return(msg);
if (reply == NULL)
@@ -1139,10 +1136,12 @@ static DBusMessage 
*manager_get_properties(DBusConnection *conn,
dict);
 
/* property EmergencyNumbers */
-   list = g_new0(char *, g_slist_length(vc-en_list) + 1);
+   list = g_new0(char *, g_hash_table_size(vc-en_list) + 1);
+
+   g_hash_table_iter_init(ht_iter, vc-en_list);
 
-   for (i = 0, l = vc-en_list; l; l = l-next, i++)
-   list[i] = g_strdup(l-data);
+   while (g_hash_table_iter_next(ht_iter, key, value))
+   list[i++] = g_strdup(key);
 
ofono_dbus_dict_append_array(dict, EmergencyNumbers,
DBUS_TYPE_STRING, list);
@@ -2054,12 +2053,16 @@ static void emit_en_list_changed(struct ofono_voicecall 
*vc)
DBusConnection *conn = ofono_dbus_get_connection();
const char *path = __ofono_atom_get_path(vc-atom);
char **list;
-   GSList *l;
-   int i;
+   int i = 0;
+   GHashTableIter iter;
+   gpointer key, value;
 
-   list = g_new0(char *, g_slist_length(vc-en_list) + 1);
-   for (i = 0, l = vc-en_list; l; l = l-next, i++)
-   list[i] = g_strdup(l-data);
+   list = g_new0(char *, g_hash_table_size(vc-en_list) + 1);
+
+   g_hash_table_iter_init (iter, vc-en_list);
+
+   while (g_hash_table_iter_next(iter, key, value))
+   list[i++] = g_strdup(key);
 
ofono_dbus_signal_array_property_changed(conn, path,
OFONO_VOICECALL_MANAGER_INTERFACE,
@@ -2070,30 +2073,25 @@ static void emit_en_list_changed(struct ofono_voicecall 
*vc)
 
 static void set_new_ecc(struct ofono_voicecall *vc)
 {
-   int i = 0;
+   GSList *l;
 
-   g_slist_foreach(vc-en_list, (GFunc) g_free, NULL);
-   g_slist_free(vc-en_list);
-   vc-en_list = NULL;
+   g_hash_table_destroy(vc-en_list);
 
-   vc-en_list = vc-new_en_list;
-   vc-new_en_list = NULL;
+   vc-en_list = g_hash_table_new_full(g_str_hash, g_str_equal,
+   g_free, NULL);
 
-   while (default_en_list[i]) {
-   GSList *l;
+   if (vc-new_en_list)
+   add_to_en_list(vc, vc-new_en_list);
 
-   for (l = vc-en_list; l; l = l-next)
-   if (!strcmp(l-data, default_en_list[i]))
-   break;
+   

[PATCH v3 3/4] voicecall: network emergency number list support

2011-04-01 Thread Jeevaka Badrappan
---
 src/voicecall.c |7 +++
 1 files changed, 7 insertions(+), 0 deletions(-)

diff --git a/src/voicecall.c b/src/voicecall.c
index d7d8424..42ff6dc 100644
--- a/src/voicecall.c
+++ b/src/voicecall.c
@@ -2162,6 +2162,13 @@ check:
set_new_ecc(vc);
 }
 
+void ofono_voicecall_en_list_notify(struct ofono_voicecall *vc,
+   char **nw_en_list)
+{
+   vc-new_en_list = nw_en_list;
+   set_new_ecc(vc);
+}
+
 int ofono_voicecall_driver_register(const struct ofono_voicecall_driver *d)
 {
DBG(driver: %p, name: %s, d, d-name);
-- 
1.7.0.4

___
ofono mailing list
ofono@ofono.org
http://lists.ofono.org/listinfo/ofono


[PATCH v3 4/4] ifxmodem: emergency number list support

2011-04-01 Thread Jeevaka Badrappan
---
 drivers/ifxmodem/voicecall.c |   99 ++
 1 files changed, 99 insertions(+), 0 deletions(-)

diff --git a/drivers/ifxmodem/voicecall.c b/drivers/ifxmodem/voicecall.c
index 87a48e6..0841165 100644
--- a/drivers/ifxmodem/voicecall.c
+++ b/drivers/ifxmodem/voicecall.c
@@ -42,11 +42,13 @@
 #include ifxmodem.h
 
 static const char *none_prefix[] = { NULL };
+static const char *xlema_prefix[] = { +XLEMA:, NULL };
 
 struct voicecall_data {
GSList *calls;
unsigned int local_release;
GAtChat *chat;
+   char **en_list;
 };
 
 struct release_id_req {
@@ -786,6 +788,93 @@ static void xcolp_notify(GAtResult *result, gpointer 
user_data)
ofono_voicecall_notify(vc, call);
 }
 
+static void xlema_notify(GAtResult *result, gpointer user_data)
+{
+   struct ofono_voicecall *vc = user_data;
+   struct voicecall_data *vd = ofono_voicecall_get_data(vc);
+   GAtResultIter iter;
+   int index, total_cnt;
+   const char *number;
+   int count = g_strv_length(vd-en_list);
+
+   g_at_result_iter_init(iter, result);
+
+   if (!g_at_result_iter_next(iter, +XLEMA:))
+   return;
+
+   if (!g_at_result_iter_next_number(iter, index))
+   return;
+
+   if (!g_at_result_iter_next_number(iter, total_cnt))
+   return;
+
+   if (!g_at_result_iter_next_string(iter, number))
+   return;
+
+   /* Skip the category, valid in simpresent and mcc fields */
+
+   if (vd-en_list == NULL)
+   vd-en_list = g_new0(char *, total_cnt + 1);
+
+   vd-en_list[count] = g_strdup(number);
+
+   if (index != total_cnt)
+   return;
+
+   ofono_voicecall_en_list_notify(vc, vd-en_list);
+
+   g_strfreev(vd-en_list);
+   vd-en_list = NULL;
+}
+
+static void xlema_read(gboolean ok, GAtResult *result, gpointer user_data)
+{
+   struct ofono_voicecall *vc = user_data;
+   struct voicecall_data *vd = ofono_voicecall_get_data(vc);
+   GAtResultIter iter;
+   int num = 0;
+   int index, total_cnt;
+   const char *number;
+
+   if (!ok) {
+   DBG(Emergency number list read failed);
+   return;
+   }
+
+   g_at_result_iter_init(iter, result);
+
+   while (g_at_result_iter_next(iter, +XLEMA:))
+   num += 1;
+
+   vd-en_list = g_new0(char *, num + 1);
+
+   num = 0;
+   g_at_result_iter_init(iter, result);
+
+   while (g_at_result_iter_next(iter, +XLEMA:)) {
+   if (!g_at_result_iter_next_number(iter, index))
+   continue;
+
+   if (!g_at_result_iter_next_number(iter, total_cnt))
+   continue;
+
+   if (!g_at_result_iter_next_string(iter, number))
+   continue;
+
+   /* Skip the category, valid in simpresent and mcc fields */
+   g_at_result_iter_skip_next(iter);
+   g_at_result_iter_skip_next(iter);
+   g_at_result_iter_skip_next(iter);
+
+   vd-en_list[num++] = g_strdup(number);
+   }
+
+   ofono_voicecall_en_list_notify(vc, vd-en_list);
+
+   g_strfreev(vd-en_list);
+   vd-en_list = NULL;
+}
+
 static void ifx_voicecall_initialized(gboolean ok, GAtResult *result,
gpointer user_data)
 {
@@ -803,7 +892,15 @@ static void ifx_voicecall_initialized(gboolean ok, 
GAtResult *result,
FALSE, vc, NULL);
g_at_chat_register(vd-chat, +XCOLP:, xcolp_notify, FALSE, vc, NULL);
 
+   g_at_chat_register(vd-chat, +XLEMA:, xlema_notify, FALSE, vc, NULL);
+
+   /* Enable emergency number list notification */
+   g_at_chat_send(vd-chat, AT+XLEMA=1, none_prefix, NULL, NULL, NULL);
+
ofono_voicecall_register(vc);
+
+   g_at_chat_send(vd-chat, AT+XLEMA?, xlema_prefix, xlema_read, vc,
+   NULL);
 }
 
 static int ifx_voicecall_probe(struct ofono_voicecall *vc, unsigned int vendor,
@@ -840,6 +937,8 @@ static void ifx_voicecall_remove(struct ofono_voicecall *vc)
g_slist_foreach(vd-calls, (GFunc) g_free, NULL);
g_slist_free(vd-calls);
 
+   g_strfreev(vd-en_list);
+
ofono_voicecall_set_data(vc, NULL);
 
g_at_chat_unref(vd-chat);
-- 
1.7.0.4

___
ofono mailing list
ofono@ofono.org
http://lists.ofono.org/listinfo/ofono


[RFC PATCH 0/9] Emergency Mode

2011-03-31 Thread Jeevaka Badrappan
Hi,

 Following patch is a proposal for emergency mode. Test has been done
with the phonesim.

Listed down few important cases to give an overview of the state
changes that happen in each case.

Case 1: SIM Present, No PIN required, modem in offline state

- Modem set to online mode(UI triggered)
Post online atoms created
- Dial request received with emergency number
- Emergency mode activated
- Dial request sent to modem
- Emergency call is active
- Call ended
Emergency mode deactivated.
- Modem remains in online mode. Post online
  atoms are present.

Case 2: SIM Present and PIN required

- Modem set to online mode(UI triggered)
Post SIM and Post online atoms not created
- Dial request received with emergency number
- Emergency mode activated
- Dial request sent to modem
- Emergency call is active
- Call ended
Emergency mode deactivated.
- Modem remains in online mode. Post sim
  and post online atoms are not present/created.

Case 3: SIM Present and PIN required(Dial request cancelled by user)

- Modem set to online mode(UI triggered)
Post SIM and Post online atoms not created
- Dial request received with emergency number
- Emergency mode activated
- Dial request sent to modem
- Dial request cancelled by user
Emergency mode deactivated.
- Modem remains in online mode.
- User enters the right pin
- Modem remains in online mode. Post sim
  and post online atoms are created.

Case 4: SIM Not Present(PIN disabled SIM inserted)

- Modem set to online mode(UI triggered)
Post SIM and Post online atoms not created
- Dial request received with emergency number
- Emergency mode activated
- Emergency call is active
- SIM inserted and SIM ready received(NO PIN required).
- Post sim and post online atoms are created.
- Call ended
Emergency mode deactivated.
- Modem remains in online mode. Post sim and post
  online atoms are present.

Case 5: SIM Not Present(PIN enabled SIM inserted)

- Modem set to online mode(UI triggered)
Post SIM and Post online atoms not created
- Dial request received with emergency number
- Emergency mode activated
- Emergency call is active
- SIM Inserted(PIN required).
- Call ended
Emergency mode deactivated.
- Modem remains in online mode. Post sim
  and post online atoms are not created.

Regards,
Jeevaka

Jeevaka Badrappan (9):
  dbus: Add __ofono_error_emergency_active
  include: add ofono_modem_get_emergency_mode api
  modem: add ofono_modem_get_emergency_mode api
  modem: add Emergency property
  modem: add increment/decrement emergency mode api
  modem: modem state decoupled from rf state
  modem: restrict operations allowed in emergency
  voicecall: generalise emergency call check
  voicecall: add emergency mode handling

 include/modem.h |2 +
 src/dbus.c  |7 +++
 src/modem.c |  135 --
 src/ofono.h |4 ++
 src/voicecall.c |   34 ++
 5 files changed, 147 insertions(+), 35 deletions(-)

___
ofono mailing list
ofono@ofono.org
http://lists.ofono.org/listinfo/ofono


[RFC PATCH 2/9] include: add ofono_modem_get_emergency_mode api

2011-03-31 Thread Jeevaka Badrappan
---
 include/modem.h |2 ++
 1 files changed, 2 insertions(+), 0 deletions(-)

diff --git a/include/modem.h b/include/modem.h
index a92eb88..5a34370 100644
--- a/include/modem.h
+++ b/include/modem.h
@@ -53,6 +53,8 @@ ofono_bool_t ofono_modem_get_powered(struct ofono_modem 
*modem);
 
 ofono_bool_t ofono_modem_get_online(struct ofono_modem *modem);
 
+ofono_bool_t ofono_modem_get_emergency_mode(struct ofono_modem *modem);
+
 void ofono_modem_set_name(struct ofono_modem *modem, const char *name);
 
 int ofono_modem_set_string(struct ofono_modem *modem,
-- 
1.7.0.4

___
ofono mailing list
ofono@ofono.org
http://lists.ofono.org/listinfo/ofono


[RFC PATCH 3/9] modem: add ofono_modem_get_emergency_mode api

2011-03-31 Thread Jeevaka Badrappan
---
 src/modem.c |6 ++
 1 files changed, 6 insertions(+), 0 deletions(-)

diff --git a/src/modem.c b/src/modem.c
index 26468e8..2b49770 100644
--- a/src/modem.c
+++ b/src/modem.c
@@ -86,6 +86,7 @@ struct ofono_modem {
void*driver_data;
char*driver_type;
char*name;
+   guint   emergency;
 };
 
 struct ofono_devinfo {
@@ -2040,3 +2041,8 @@ void __ofono_modem_foreach(ofono_modem_foreach_func func, 
void *userdata)
func(modem, userdata);
}
 }
+
+ofono_bool_t ofono_modem_get_emergency_mode(struct ofono_modem *modem)
+{
+   return modem-emergency != 0;
+}
-- 
1.7.0.4

___
ofono mailing list
ofono@ofono.org
http://lists.ofono.org/listinfo/ofono


[RFC PATCH 6/9] modem: modem state decoupled from rf state

2011-03-31 Thread Jeevaka Badrappan
---
 src/modem.c |   80 --
 1 files changed, 55 insertions(+), 25 deletions(-)

diff --git a/src/modem.c b/src/modem.c
index 72937a3..126c0e6 100644
--- a/src/modem.c
+++ b/src/modem.c
@@ -416,26 +416,34 @@ static void notify_powered_watches(struct ofono_modem 
*modem)
}
 }
 
+static void set_online(struct ofono_modem *modem, ofono_bool_t new_online)
+{
+   DBusConnection *conn = ofono_dbus_get_connection();
+
+   if (new_online == modem-online)
+   return;
+
+   modem-online = new_online;
+
+   ofono_dbus_signal_property_changed(conn, modem-path,
+   OFONO_MODEM_INTERFACE,
+   Online, DBUS_TYPE_BOOLEAN,
+   modem-online);
+
+   notify_online_watches(modem);
+}
+
 static void modem_change_state(struct ofono_modem *modem,
enum modem_state new_state)
 {
struct ofono_modem_driver const *driver = modem-driver;
enum modem_state old_state = modem-modem_state;
-   ofono_bool_t new_online = new_state == MODEM_STATE_ONLINE;
 
DBG(old state: %d, new state: %d, old_state, new_state);
 
if (old_state == new_state)
return;
 
-   if (new_online != modem-online) {
-   DBusConnection *conn = ofono_dbus_get_connection();
-   modem-online = new_online;
-   ofono_dbus_signal_property_changed(conn, modem-path,
-   OFONO_MODEM_INTERFACE, Online,
-   DBUS_TYPE_BOOLEAN, modem-online);
-   }
-
modem-modem_state = new_state;
 
if (old_state  new_state)
@@ -457,8 +465,7 @@ static void modem_change_state(struct ofono_modem *modem,
driver-post_sim(modem);
__ofono_history_probe_drivers(modem);
__ofono_nettime_probe_drivers(modem);
-   } else
-   notify_online_watches(modem);
+   }
 
break;
 
@@ -466,7 +473,6 @@ static void modem_change_state(struct ofono_modem *modem,
if (driver-post_online)
driver-post_online(modem);
 
-   notify_online_watches(modem);
break;
}
 }
@@ -541,14 +547,22 @@ static void common_online_cb(const struct ofono_error 
*error, void *data)
 */
switch (modem-modem_state) {
case MODEM_STATE_OFFLINE:
+   set_online(modem, TRUE);
+
+   /* Will this increase emergency call setup time??? */
modem_change_state(modem, MODEM_STATE_ONLINE);
break;
case MODEM_STATE_POWER_OFF:
/* The powered operation is pending */
break;
case MODEM_STATE_PRE_SIM:
-   /* Go back offline if the sim was removed or reset */
-   modem-driver-set_online(modem, 0, NULL, NULL);
+   /*
+* Its valid to be in online even without a SIM/SIM being
+* PIN locked. e.g.: Emergency mode
+*/
+   DBG(Online in PRE SIM state);
+
+   set_online(modem, TRUE);
break;
case MODEM_STATE_ONLINE:
ofono_error(Online called when the modem is already online!);
@@ -564,8 +578,7 @@ static void online_cb(const struct ofono_error *error, void 
*data)
if (!modem-pending)
goto out;
 
-   if (error-type == OFONO_ERROR_TYPE_NO_ERROR 
-   modem-modem_state == MODEM_STATE_OFFLINE)
+   if (error-type == OFONO_ERROR_TYPE_NO_ERROR)
reply = dbus_message_new_method_return(modem-pending);
else
reply = __ofono_error_failed(modem-pending);
@@ -588,9 +601,19 @@ static void offline_cb(const struct ofono_error *error, 
void *data)
 
__ofono_dbus_pending_reply(modem-pending, reply);
 
-   if (error-type == OFONO_ERROR_TYPE_NO_ERROR 
-   modem-modem_state == MODEM_STATE_ONLINE)
-   modem_change_state(modem, MODEM_STATE_OFFLINE);
+   if (error-type == OFONO_ERROR_TYPE_NO_ERROR) {
+   switch (modem-modem_state) {
+   case MODEM_STATE_PRE_SIM:
+   set_online(modem, FALSE);
+   break;
+   case MODEM_STATE_ONLINE:
+   set_online(modem, FALSE);
+   modem_change_state(modem, MODEM_STATE_OFFLINE);
+   break;
+   default:
+   break;
+   }
+   }
 }
 
 static void sim_state_watch(enum ofono_sim_state new_state, void *user)
@@ -609,7 +632,7 @@ static void sim_state_watch(enum ofono_sim_state new_state, 
void *user)
 * If we don't have the 

[RFC PATCH 4/9] modem: add Emergency property

2011-03-31 Thread Jeevaka Badrappan
---
 src/modem.c |4 
 1 files changed, 4 insertions(+), 0 deletions(-)

diff --git a/src/modem.c b/src/modem.c
index 2b49770..0aef463 100644
--- a/src/modem.c
+++ b/src/modem.c
@@ -669,6 +669,7 @@ void __ofono_modem_append_properties(struct ofono_modem 
*modem,
int i;
GSList *l;
struct ofono_atom *devinfo_atom;
+   dbus_bool_t emergency = ofono_modem_get_emergency_mode(modem);
 
ofono_dbus_dict_append(dict, Online, DBUS_TYPE_BOOLEAN,
modem-online);
@@ -679,6 +680,9 @@ void __ofono_modem_append_properties(struct ofono_modem 
*modem,
ofono_dbus_dict_append(dict, Lockdown, DBUS_TYPE_BOOLEAN,
modem-lockdown);
 
+   ofono_dbus_dict_append(dict, Emergency, DBUS_TYPE_BOOLEAN,
+   emergency);
+
devinfo_atom = __ofono_modem_find_atom(modem, OFONO_ATOM_TYPE_DEVINFO);
 
/* We cheat a little here and don't check the registered status */
-- 
1.7.0.4

___
ofono mailing list
ofono@ofono.org
http://lists.ofono.org/listinfo/ofono


[RFC PATCH 5/9] modem: add increment/decrement emergency mode api

2011-03-31 Thread Jeevaka Badrappan
---
 src/modem.c |   36 
 src/ofono.h |3 +++
 2 files changed, 39 insertions(+), 0 deletions(-)

diff --git a/src/modem.c b/src/modem.c
index 0aef463..72937a3 100644
--- a/src/modem.c
+++ b/src/modem.c
@@ -2050,3 +2050,39 @@ ofono_bool_t ofono_modem_get_emergency_mode(struct 
ofono_modem *modem)
 {
return modem-emergency != 0;
 }
+
+void __ofono_modem_inc_emergency_mode(struct ofono_modem *modem)
+{
+   DBusConnection *conn = ofono_dbus_get_connection();
+   dbus_bool_t emergency = TRUE;
+
+   if (++modem-emergency  1)
+   return;
+
+   ofono_dbus_signal_property_changed(conn, modem-path,
+   OFONO_MODEM_INTERFACE,
+   Emergency, DBUS_TYPE_BOOLEAN,
+   emergency);
+}
+
+void __ofono_modem_dec_emergency_mode(struct ofono_modem *modem)
+{
+   DBusConnection *conn = ofono_dbus_get_connection();
+   dbus_bool_t emergency = FALSE;
+
+   if (modem-emergency == 0) {
+   ofono_error(emergency mode is already deactivated!!!);
+   return;
+   }
+
+   if (modem-emergency  1)
+   goto out;
+
+   ofono_dbus_signal_property_changed(conn, modem-path,
+   OFONO_MODEM_INTERFACE,
+   Emergency, DBUS_TYPE_BOOLEAN,
+   emergency);
+
+out:
+   modem-emergency--;
+}
diff --git a/src/ofono.h b/src/ofono.h
index 511be8a..a80af4f 100644
--- a/src/ofono.h
+++ b/src/ofono.h
@@ -212,6 +212,9 @@ void __ofono_modem_remove_powered_watch(struct ofono_modem 
*modem,
 
 void __ofono_modem_sim_reset(struct ofono_modem *modem);
 
+void __ofono_modem_inc_emergency_mode(struct ofono_modem *modem);
+void __ofono_modem_dec_emergency_mode(struct ofono_modem *modem);
+
 #include ofono/call-barring.h
 
 gboolean __ofono_call_barring_is_busy(struct ofono_call_barring *cb);
-- 
1.7.0.4

___
ofono mailing list
ofono@ofono.org
http://lists.ofono.org/listinfo/ofono


[RFC PATCH 7/9] modem: restrict operations allowed in emergency

2011-03-31 Thread Jeevaka Badrappan
---
 src/modem.c |9 +
 1 files changed, 9 insertions(+), 0 deletions(-)

diff --git a/src/modem.c b/src/modem.c
index 126c0e6..49b3314 100644
--- a/src/modem.c
+++ b/src/modem.c
@@ -662,6 +662,9 @@ static DBusMessage *set_property_online(struct ofono_modem 
*modem,
if (modem-online == online)
return dbus_message_new_method_return(msg);
 
+   if (ofono_modem_get_emergency_mode(modem) == TRUE)
+   return __ofono_error_emergency_active(msg);
+
if (driver-set_online == NULL)
return __ofono_error_not_implemented(msg);
 
@@ -906,6 +909,9 @@ static DBusMessage *set_property_lockdown(struct 
ofono_modem *modem,
goto done;
}
 
+   if (ofono_modem_get_emergency_mode(modem) == TRUE)
+   return __ofono_error_emergency_active(msg);
+
modem-lock_owner = g_strdup(caller);
 
modem-lock_watch = g_dbus_add_disconnect_watch(conn,
@@ -998,6 +1004,9 @@ static DBusMessage *modem_set_property(DBusConnection 
*conn,
if (modem-powered == powered)
return dbus_message_new_method_return(msg);
 
+   if (ofono_modem_get_emergency_mode(modem) == TRUE)
+   return __ofono_error_emergency_active(msg);
+
if (modem-lockdown)
return __ofono_error_access_denied(msg);
 
-- 
1.7.0.4

___
ofono mailing list
ofono@ofono.org
http://lists.ofono.org/listinfo/ofono


[RFC PATCH 9/9] voicecall: add emergency mode handling

2011-03-31 Thread Jeevaka Badrappan
---
 src/voicecall.c |   20 +++-
 1 files changed, 19 insertions(+), 1 deletions(-)

diff --git a/src/voicecall.c b/src/voicecall.c
index f25c770..04be551 100644
--- a/src/voicecall.c
+++ b/src/voicecall.c
@@ -1281,8 +1281,14 @@ static void manager_dial_callback(const struct 
ofono_error *error, void *data)
 
dbus_message_append_args(reply, DBUS_TYPE_OBJECT_PATH, path,
DBUS_TYPE_INVALID);
-   } else
+   } else {
+   struct ofono_modem *modem = __ofono_atom_get_modem(vc-atom);
+
+   if (is_emergency_number(vc, number) == TRUE)
+   __ofono_modem_dec_emergency_mode(modem);
+
reply = __ofono_error_failed(vc-pending);
+   }
 
__ofono_dbus_pending_reply(vc-pending, reply);
 
@@ -1294,6 +1300,7 @@ static DBusMessage *manager_dial(DBusConnection *conn,
DBusMessage *msg, void *data)
 {
struct ofono_voicecall *vc = data;
+   struct ofono_modem *modem = __ofono_atom_get_modem(vc-atom);
const char *number;
struct ofono_phone_number ph;
const char *clirstr;
@@ -1316,6 +1323,9 @@ static DBusMessage *manager_dial(DBusConnection *conn,
if (clir_string_to_clir(clirstr, clir) == FALSE)
return __ofono_error_invalid_format(msg);
 
+   if (ofono_modem_get_online(modem) == FALSE)
+   return __ofono_error_not_available(msg);
+
if (vc-driver-dial == NULL)
return __ofono_error_not_implemented(msg);
 
@@ -1329,6 +1339,9 @@ static DBusMessage *manager_dial(DBusConnection *conn,
if (voicecalls_have_active(vc)  voicecalls_have_held(vc))
return __ofono_error_failed(msg);
 
+   if (is_emergency_number(vc, number) == TRUE)
+   __ofono_modem_inc_emergency_mode(modem);
+
vc-pending = dbus_message_ref(msg);
 
string_to_phone_number(number, ph);
@@ -1891,6 +1904,7 @@ void ofono_voicecall_disconnected(struct ofono_voicecall 
*vc, int id,
struct voicecall *call;
time_t ts;
enum call_status prev_status;
+   const char *number;
 
DBG(Got disconnection event for id: %d, reason: %d, id, reason);
 
@@ -1931,6 +1945,10 @@ void ofono_voicecall_disconnected(struct ofono_voicecall 
*vc, int id,
if (reason != OFONO_DISCONNECT_REASON_UNKNOWN)
voicecall_emit_disconnect_reason(call, reason);
 
+   number = phone_number_to_string(call-call-phone_number);
+   if (is_emergency_number(vc, number) == TRUE)
+   __ofono_modem_dec_emergency_mode(modem);
+
voicecall_set_call_status(call, CALL_STATUS_DISCONNECTED);
 
if (!call-untracked) {
-- 
1.7.0.4

___
ofono mailing list
ofono@ofono.org
http://lists.ofono.org/listinfo/ofono


[RFC PATCH 8/9] voicecall: generalise emergency call check

2011-03-31 Thread Jeevaka Badrappan
---
 src/voicecall.c |   14 +-
 1 files changed, 5 insertions(+), 9 deletions(-)

diff --git a/src/voicecall.c b/src/voicecall.c
index 4932ffa..f25c770 100644
--- a/src/voicecall.c
+++ b/src/voicecall.c
@@ -337,14 +337,10 @@ static gint number_compare(gconstpointer a, gconstpointer 
b)
return strcmp(s1, s2);
 }
 
-static gboolean voicecall_is_emergency(struct voicecall *v)
+static gboolean is_emergency_number(struct ofono_voicecall *vc,
+   const char *number)
 {
-   struct ofono_call *call = v-call;
-   const char *lineid_str;
-
-   lineid_str = phone_number_to_string(call-phone_number);
-
-   return g_slist_find_custom(v-vc-en_list, lineid_str,
+   return g_slist_find_custom(vc-en_list, number,
number_compare) ? TRUE : FALSE;
 }
 
@@ -417,7 +413,7 @@ static void append_voicecall_properties(struct voicecall *v,
ofono_dbus_dict_append(dict, Icon,
DBUS_TYPE_BYTE, v-icon_id);
 
-   if (voicecall_is_emergency(v) == TRUE)
+   if (is_emergency_number(v-vc, callerid) == TRUE)
emergency_call = TRUE;
else
emergency_call = FALSE;
@@ -788,7 +784,7 @@ static void voicecall_set_call_lineid(struct voicecall *v,
LineIdentification,
DBUS_TYPE_STRING, lineid_str);
 
-   if (voicecall_is_emergency(v)) {
+   if (is_emergency_number(v-vc, lineid_str)) {
dbus_bool_t emergency_call = TRUE;
 
ofono_dbus_signal_property_changed(conn, path,
-- 
1.7.0.4

___
ofono mailing list
ofono@ofono.org
http://lists.ofono.org/listinfo/ofono


[PATCH] TODO: set owner of Emergency Calls task

2011-03-29 Thread Jeevaka Badrappan
---
 TODO |1 +
 1 files changed, 1 insertions(+), 0 deletions(-)

diff --git a/TODO b/TODO
index f8926a3..5189111 100644
--- a/TODO
+++ b/TODO
@@ -389,6 +389,7 @@ Emergency Calls
 
   Priority: High
   Complexity: C2
+  Owner: Jeevaka Badrappan jeevaka.badrap...@elektrobit.com
 
 - Country / Operator specific emergency numbers.  Figure out how to support
   countries / operators with specific mandated emergency numbers which are
-- 
1.7.0.4

___
ofono mailing list
ofono@ofono.org
http://lists.ofono.org/listinfo/ofono


[PATCH v2 1/4] include: Add ofono_voicecall_en_list_notify api

2011-03-28 Thread Jeevaka Badrappan
---
 include/voicecall.h |3 +++
 1 files changed, 3 insertions(+), 0 deletions(-)

diff --git a/include/voicecall.h b/include/voicecall.h
index 5e6da02..477b226 100644
--- a/include/voicecall.h
+++ b/include/voicecall.h
@@ -140,6 +140,9 @@ struct ofono_voicecall_driver {
ofono_voicecall_cb_t cb, void *data);
 };
 
+void ofono_voicecall_en_list_notify(struct ofono_voicecall *vc,
+   GSList *nw_en_list);
+
 void ofono_voicecall_notify(struct ofono_voicecall *vc,
const struct ofono_call *call);
 void ofono_voicecall_disconnected(struct ofono_voicecall *vc, int id,
-- 
1.7.0.4

___
ofono mailing list
ofono@ofono.org
http://lists.ofono.org/listinfo/ofono


[PATCH v2 0/4] Support for emergency number list from network/modem

2011-03-28 Thread Jeevaka Badrappan
Hi,

 Following set of patch adds the emergency number list update from
the network/modem. Upon emergency number list update from modem, ofono
core will be updated which will result in dbus property change signal
as well. With this patch, even if the emergency number list maintained
in ofono matches with the received emergency number list from modem,
dbus property change will be signalled. If this should be avoided,
then it needs to be decided whether the check should be added in core
or for each modem.

Regards,
Jeevaka

Jeevaka Badrappan (4):
  include: Add ofono_voicecall_en_list_notify api
  voicecall: refactor emergency number list handling
  voicecall: network emergency number list support
  ifxmodem: emergency number list support

 drivers/ifxmodem/voicecall.c |   98 ++
 include/voicecall.h  |3 +
 src/voicecall.c  |   45 ---
 3 files changed, 138 insertions(+), 8 deletions(-)

___
ofono mailing list
ofono@ofono.org
http://lists.ofono.org/listinfo/ofono


[PATCH v2 2/4] voicecall: refactor emergency number list handling

2011-03-28 Thread Jeevaka Badrappan
---
 src/voicecall.c |   32 
 1 files changed, 24 insertions(+), 8 deletions(-)

diff --git a/src/voicecall.c b/src/voicecall.c
index b1d5586..826e10c 100644
--- a/src/voicecall.c
+++ b/src/voicecall.c
@@ -47,7 +47,8 @@ struct ofono_voicecall {
GSList *release_list;
GSList *multiparty_list;
GSList *en_list;  /* emergency number list */
-   GSList *new_en_list; /* Emergency numbers being read from SIM */
+   GSList *sim_en_list; /* Emergency numbers being read from SIM */
+   GSList *new_en_list; /* Emergency numbers from modem/network/no SIM*/
DBusMessage *pending;
struct ofono_sim *sim;
struct ofono_sim_context *sim_context;
@@ -2071,6 +2072,7 @@ static void emit_en_list_changed(struct ofono_voicecall 
*vc)
 static void set_new_ecc(struct ofono_voicecall *vc)
 {
int i = 0;
+   GSList *l;
 
g_slist_foreach(vc-en_list, (GFunc) g_free, NULL);
g_slist_free(vc-en_list);
@@ -2079,6 +2081,12 @@ static void set_new_ecc(struct ofono_voicecall *vc)
vc-en_list = vc-new_en_list;
vc-new_en_list = NULL;
 
+   for (l = vc-sim_en_list; l; l = l-next) {
+   if (!g_slist_find_custom(vc-en_list, l-data, number_compare))
+   vc-en_list = g_slist_prepend(vc-en_list,
+   g_strdup(l-data));
+   }
+
while (default_en_list[i]) {
GSList *l;
 
@@ -2120,10 +2128,11 @@ static void ecc_g2_read_cb(int ok, int total_length, 
int record,
data += 3;
 
if (en[0] != '\0')
-   vc-new_en_list = g_slist_prepend(vc-new_en_list,
+   vc-sim_en_list = g_slist_prepend(vc-sim_en_list,
g_strdup(en));
}
 
+   vc-sim_en_list = g_slist_reverse(vc-sim_en_list);
set_new_ecc(vc);
 }
 
@@ -2149,16 +2158,17 @@ static void ecc_g3_read_cb(int ok, int total_length, 
int record,
extract_bcd_number(data, 3, en);
 
if (en[0] != '\0')
-   vc-new_en_list = g_slist_prepend(vc-new_en_list,
+   vc-sim_en_list = g_slist_prepend(vc-sim_en_list,
g_strdup(en));
 
if (record != total)
return;
 
 check:
-   if (!ok  vc-new_en_list == NULL)
+   if (!ok  vc-sim_en_list == NULL)
return;
 
+   vc-sim_en_list = g_slist_reverse(vc-sim_en_list);
set_new_ecc(vc);
 }
 
@@ -2231,6 +2241,12 @@ static void voicecall_remove(struct ofono_atom *atom)
vc-new_en_list = NULL;
}
 
+   if (vc-sim_en_list) {
+   g_slist_foreach(vc-sim_en_list, (GFunc) g_free, NULL);
+   g_slist_free(vc-sim_en_list);
+   vc-sim_en_list = NULL;
+   }
+
if (vc-sim_state_watch) {
ofono_sim_remove_state_watch(vc-sim, vc-sim_state_watch);
vc-sim_state_watch = 0;
@@ -2330,10 +2346,10 @@ static void sim_state_watch(enum ofono_sim_state 
new_state, void *user)
 * Free the currently being read EN list, just in case the
 * SIM is removed when we're still reading them
 */
-   if (vc-new_en_list) {
-   g_slist_foreach(vc-new_en_list, (GFunc) g_free, NULL);
-   g_slist_free(vc-new_en_list);
-   vc-new_en_list = NULL;
+   if (vc-sim_en_list) {
+   g_slist_foreach(vc-sim_en_list, (GFunc) g_free, NULL);
+   g_slist_free(vc-sim_en_list);
+   vc-sim_en_list = NULL;
}
 
add_to_en_list(vc-new_en_list, default_en_list_no_sim);
-- 
1.7.0.4

___
ofono mailing list
ofono@ofono.org
http://lists.ofono.org/listinfo/ofono


[PATCH v2 4/4] ifxmodem: emergency number list support

2011-03-28 Thread Jeevaka Badrappan
---
 drivers/ifxmodem/voicecall.c |   98 ++
 1 files changed, 98 insertions(+), 0 deletions(-)

diff --git a/drivers/ifxmodem/voicecall.c b/drivers/ifxmodem/voicecall.c
index 87a48e6..a92ac11 100644
--- a/drivers/ifxmodem/voicecall.c
+++ b/drivers/ifxmodem/voicecall.c
@@ -42,11 +42,13 @@
 #include ifxmodem.h
 
 static const char *none_prefix[] = { NULL };
+static const char *xlema_prefix[] = { +XLEMA:, NULL };
 
 struct voicecall_data {
GSList *calls;
unsigned int local_release;
GAtChat *chat;
+   GSList *en_list;
 };
 
 struct release_id_req {
@@ -786,6 +788,95 @@ static void xcolp_notify(GAtResult *result, gpointer 
user_data)
ofono_voicecall_notify(vc, call);
 }
 
+static gint number_compare(gconstpointer a, gconstpointer b)
+{
+   const char *s1 = a, *s2 = b;
+   return strcmp(s1, s2);
+}
+
+static void xlema_notify(GAtResult *result, gpointer user_data)
+{
+   struct ofono_voicecall *vc = user_data;
+   struct voicecall_data *vd = ofono_voicecall_get_data(vc);
+   GAtResultIter iter;
+   int index, total_cnt;
+   const char *number;
+
+   g_at_result_iter_init(iter, result);
+
+   if (!g_at_result_iter_next(iter, +XLEMA:))
+   return;
+
+   if (!g_at_result_iter_next_number(iter, index))
+   return;
+
+   if (!g_at_result_iter_next_number(iter, total_cnt))
+   return;
+
+   if (!g_at_result_iter_next_string(iter, number))
+   return;
+
+   // Skip the category, EN valid with simpresence and mcc fields
+
+   if (!g_slist_find_custom(vd-en_list, number, number_compare))
+   vd-en_list = g_slist_prepend(vd-en_list, g_strdup(number));
+
+   if (index != total_cnt)
+   return;
+
+   vd-en_list = g_slist_reverse(vd-en_list);
+
+   ofono_voicecall_en_list_notify(vc, vd-en_list);
+
+   g_slist_foreach(vd-en_list, (GFunc) g_free, NULL);
+   g_slist_free(vd-en_list);
+   vd-en_list = NULL;
+}
+
+static void xlema_read(gboolean ok, GAtResult *result, gpointer user_data)
+{
+   struct ofono_voicecall *vc = user_data;
+   struct voicecall_data *vd = ofono_voicecall_get_data(vc);
+   GAtResultIter iter;
+   int index, total_cnt;
+   const char *number;
+
+   if (!ok) {
+   DBG(Emergency number list read failed);
+   return;
+   }
+
+   g_at_result_iter_init(iter, result);
+
+   while (g_at_result_iter_next(iter, +XLEMA:)) {
+   if (!g_at_result_iter_next_number(iter, index))
+   continue;
+
+   if (!g_at_result_iter_next_number(iter, total_cnt))
+   continue;
+
+   if (!g_at_result_iter_next_string(iter, number))
+   continue;
+
+   // Skip the category, EN valid with simpresence and mcc fields
+   g_at_result_iter_skip_next(iter);
+   g_at_result_iter_skip_next(iter);
+   g_at_result_iter_skip_next(iter);
+
+   if (!g_slist_find_custom(vd-en_list, number, number_compare))
+   vd-en_list = g_slist_prepend(vd-en_list,
+   g_strdup(number));
+   }
+
+   vd-en_list = g_slist_reverse(vd-en_list);
+
+   ofono_voicecall_en_list_notify(vc, vd-en_list);
+
+   g_slist_foreach(vd-en_list, (GFunc) g_free, NULL);
+   g_slist_free(vd-en_list);
+   vd-en_list = NULL;
+}
+
 static void ifx_voicecall_initialized(gboolean ok, GAtResult *result,
gpointer user_data)
 {
@@ -803,7 +894,14 @@ static void ifx_voicecall_initialized(gboolean ok, 
GAtResult *result,
FALSE, vc, NULL);
g_at_chat_register(vd-chat, +XCOLP:, xcolp_notify, FALSE, vc, NULL);
 
+   g_at_chat_register(vd-chat, +XLEMA:, xlema_notify, FALSE, vc, NULL);
+   /* Enable emergency number list notification */
+   g_at_chat_send(vd-chat, AT+XLEMA=1, none_prefix, NULL, NULL, NULL);
+
ofono_voicecall_register(vc);
+
+   g_at_chat_send(vd-chat, AT+XLEMA?, xlema_prefix, xlema_read, vc,
+   NULL);
 }
 
 static int ifx_voicecall_probe(struct ofono_voicecall *vc, unsigned int vendor,
-- 
1.7.0.4

___
ofono mailing list
ofono@ofono.org
http://lists.ofono.org/listinfo/ofono


[PATCH v2 3/4] voicecall: network emergency number list support

2011-03-28 Thread Jeevaka Badrappan
---
 src/voicecall.c |   13 +
 1 files changed, 13 insertions(+), 0 deletions(-)

diff --git a/src/voicecall.c b/src/voicecall.c
index 826e10c..e3b1135 100644
--- a/src/voicecall.c
+++ b/src/voicecall.c
@@ -2172,6 +2172,19 @@ check:
set_new_ecc(vc);
 }
 
+void ofono_voicecall_en_list_notify(struct ofono_voicecall *vc,
+   GSList *new_en_list)
+{
+   GSList *l;
+
+   for (l = new_en_list; l; l = l-next)
+   vc-new_en_list = g_slist_prepend(vc-new_en_list,
+   g_strdup(l-data));
+
+   vc-new_en_list = g_slist_reverse(vc-new_en_list);
+   set_new_ecc(vc);
+}
+
 int ofono_voicecall_driver_register(const struct ofono_voicecall_driver *d)
 {
DBG(driver: %p, name: %s, d, d-name);
-- 
1.7.0.4

___
ofono mailing list
ofono@ofono.org
http://lists.ofono.org/listinfo/ofono


[PATCH 0/2] Add support for emergency number list from modem

2011-03-25 Thread Jeevaka Badrappan
Hi,

 Following set of patch adds the emergency number list update from
the modem. Upon emergency number list update from modem, ofono
core will be updated which will result in dbus property change signal
as well. With this patch, even if the emergency number list maintained
in ofono matches with the received emergency number list from modem,
dbus property change will be signalled. If this should be avoided,
then it needs to be decided whether the check should be added in core
or for each modem.

Regards,
Jeevaka

Jeevaka Badrappan (2):
  voicecall: add ofono_voicecall_en_list_notify api
  ifxmodem: add support for emergency number list

 drivers/ifxmodem/voicecall.c |   98 ++
 include/voicecall.h  |3 +
 src/voicecall.c  |   12 +
 3 files changed, 113 insertions(+), 0 deletions(-)

___
ofono mailing list
ofono@ofono.org
http://lists.ofono.org/listinfo/ofono


[PATCH 1/2] voicecall: add ofono_voicecall_en_list_notify api

2011-03-25 Thread Jeevaka Badrappan
---
 include/voicecall.h |3 +++
 src/voicecall.c |   12 
 2 files changed, 15 insertions(+), 0 deletions(-)

diff --git a/include/voicecall.h b/include/voicecall.h
index f00eb08..3710646 100644
--- a/include/voicecall.h
+++ b/include/voicecall.h
@@ -140,6 +140,9 @@ struct ofono_voicecall_driver {
ofono_voicecall_cb_t cb, void *data);
 };
 
+void ofono_voicecall_en_list_notify(struct ofono_voicecall *vc,
+   GSList *nw_en_list);
+
 void ofono_voicecall_notify(struct ofono_voicecall *vc,
const struct ofono_call *call);
 void ofono_voicecall_disconnected(struct ofono_voicecall *vc, int id,
diff --git a/src/voicecall.c b/src/voicecall.c
index d6e8539..74fe910 100644
--- a/src/voicecall.c
+++ b/src/voicecall.c
@@ -2150,6 +2150,18 @@ check:
set_new_ecc(vc);
 }
 
+void ofono_voicecall_en_list_notify(struct ofono_voicecall *vc,
+   GSList *new_en_list)
+{
+   GSList *l;
+
+   for (l = new_en_list; l; l = l-next)
+   vc-new_en_list = g_slist_prepend(vc-new_en_list,
+   g_strdup(l-data));
+
+   set_new_ecc(vc);
+}
+
 int ofono_voicecall_driver_register(const struct ofono_voicecall_driver *d)
 {
DBG(driver: %p, name: %s, d, d-name);
-- 
1.7.0.4

___
ofono mailing list
ofono@ofono.org
http://lists.ofono.org/listinfo/ofono


[PATCH 2/2] ifxmodem: add support for emergency number list

2011-03-25 Thread Jeevaka Badrappan
---
 drivers/ifxmodem/voicecall.c |   98 ++
 1 files changed, 98 insertions(+), 0 deletions(-)

diff --git a/drivers/ifxmodem/voicecall.c b/drivers/ifxmodem/voicecall.c
index 87a48e6..a92ac11 100644
--- a/drivers/ifxmodem/voicecall.c
+++ b/drivers/ifxmodem/voicecall.c
@@ -42,11 +42,13 @@
 #include ifxmodem.h
 
 static const char *none_prefix[] = { NULL };
+static const char *xlema_prefix[] = { +XLEMA:, NULL };
 
 struct voicecall_data {
GSList *calls;
unsigned int local_release;
GAtChat *chat;
+   GSList *en_list;
 };
 
 struct release_id_req {
@@ -786,6 +788,95 @@ static void xcolp_notify(GAtResult *result, gpointer 
user_data)
ofono_voicecall_notify(vc, call);
 }
 
+static gint number_compare(gconstpointer a, gconstpointer b)
+{
+   const char *s1 = a, *s2 = b;
+   return strcmp(s1, s2);
+}
+
+static void xlema_notify(GAtResult *result, gpointer user_data)
+{
+   struct ofono_voicecall *vc = user_data;
+   struct voicecall_data *vd = ofono_voicecall_get_data(vc);
+   GAtResultIter iter;
+   int index, total_cnt;
+   const char *number;
+
+   g_at_result_iter_init(iter, result);
+
+   if (!g_at_result_iter_next(iter, +XLEMA:))
+   return;
+
+   if (!g_at_result_iter_next_number(iter, index))
+   return;
+
+   if (!g_at_result_iter_next_number(iter, total_cnt))
+   return;
+
+   if (!g_at_result_iter_next_string(iter, number))
+   return;
+
+   // Skip the category, EN valid with simpresence and mcc fields
+
+   if (!g_slist_find_custom(vd-en_list, number, number_compare))
+   vd-en_list = g_slist_prepend(vd-en_list, g_strdup(number));
+
+   if (index != total_cnt)
+   return;
+
+   vd-en_list = g_slist_reverse(vd-en_list);
+
+   ofono_voicecall_en_list_notify(vc, vd-en_list);
+
+   g_slist_foreach(vd-en_list, (GFunc) g_free, NULL);
+   g_slist_free(vd-en_list);
+   vd-en_list = NULL;
+}
+
+static void xlema_read(gboolean ok, GAtResult *result, gpointer user_data)
+{
+   struct ofono_voicecall *vc = user_data;
+   struct voicecall_data *vd = ofono_voicecall_get_data(vc);
+   GAtResultIter iter;
+   int index, total_cnt;
+   const char *number;
+
+   if (!ok) {
+   DBG(Emergency number list read failed);
+   return;
+   }
+
+   g_at_result_iter_init(iter, result);
+
+   while (g_at_result_iter_next(iter, +XLEMA:)) {
+   if (!g_at_result_iter_next_number(iter, index))
+   continue;
+
+   if (!g_at_result_iter_next_number(iter, total_cnt))
+   continue;
+
+   if (!g_at_result_iter_next_string(iter, number))
+   continue;
+
+   // Skip the category, EN valid with simpresence and mcc fields
+   g_at_result_iter_skip_next(iter);
+   g_at_result_iter_skip_next(iter);
+   g_at_result_iter_skip_next(iter);
+
+   if (!g_slist_find_custom(vd-en_list, number, number_compare))
+   vd-en_list = g_slist_prepend(vd-en_list,
+   g_strdup(number));
+   }
+
+   vd-en_list = g_slist_reverse(vd-en_list);
+
+   ofono_voicecall_en_list_notify(vc, vd-en_list);
+
+   g_slist_foreach(vd-en_list, (GFunc) g_free, NULL);
+   g_slist_free(vd-en_list);
+   vd-en_list = NULL;
+}
+
 static void ifx_voicecall_initialized(gboolean ok, GAtResult *result,
gpointer user_data)
 {
@@ -803,7 +894,14 @@ static void ifx_voicecall_initialized(gboolean ok, 
GAtResult *result,
FALSE, vc, NULL);
g_at_chat_register(vd-chat, +XCOLP:, xcolp_notify, FALSE, vc, NULL);
 
+   g_at_chat_register(vd-chat, +XLEMA:, xlema_notify, FALSE, vc, NULL);
+   /* Enable emergency number list notification */
+   g_at_chat_send(vd-chat, AT+XLEMA=1, none_prefix, NULL, NULL, NULL);
+
ofono_voicecall_register(vc);
+
+   g_at_chat_send(vd-chat, AT+XLEMA?, xlema_prefix, xlema_read, vc,
+   NULL);
 }
 
 static int ifx_voicecall_probe(struct ofono_voicecall *vc, unsigned int vendor,
-- 
1.7.0.4

___
ofono mailing list
ofono@ofono.org
http://lists.ofono.org/listinfo/ofono


[PATCH 1/1] stk: Fix getenv failure case

2011-03-23 Thread Jeevaka Badrappan
---
 src/stk.c |6 +++---
 1 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/src/stk.c b/src/stk.c
index 68b6240..94ad396 100644
--- a/src/stk.c
+++ b/src/stk.c
@@ -2177,8 +2177,9 @@ static void get_lang(struct stk_response *rsp, struct 
ofono_stk *stk)
 
l = getenv(LANG);
if (l == NULL) {
-   rsp-result.type = STK_RESULT_TYPE_NOT_CAPABLE;
-   goto out;
+   l = en;
+   ofono_warn(LANG environment variable not set
+- defaulting to en);
}
 
memcpy(lang, l, 2);
@@ -2187,7 +2188,6 @@ static void get_lang(struct stk_response *rsp, struct 
ofono_stk *stk)
rsp-result.type = STK_RESULT_TYPE_SUCCESS;
rsp-provide_local_info.language = lang;
 
-out:
if (stk_respond(stk, rsp, stk_command_cb))
stk_command_cb(failure, stk);
 }
-- 
1.7.0.4

___
ofono mailing list
ofono@ofono.org
http://lists.ofono.org/listinfo/ofono


[PATCH 0/1] Handle getenv failure case

2011-03-23 Thread Jeevaka Badrappan
Hi,

If ofono is started before setting the LANG enviroment variable, then
call to getenv fails. This results in the failure of test case
Provide Local Information - Language setting(27.22.4.15 seq 1.5).

Plan is to default to en when the getenv fails. Warning message has
also been added. Distribution will be informed to start ofono after
the locale is set.

Regards,
Jeevaka

Jeevaka Badrappan (1):
  stk: Fix getenv failure case

 src/stk.c |6 +++---
 1 files changed, 3 insertions(+), 3 deletions(-)

___
ofono mailing list
ofono@ofono.org
http://lists.ofono.org/listinfo/ofono


[PATCH] unit: fix broken alpha id unit test cases

2011-03-19 Thread Jeevaka Badrappan
---
 unit/test-stkutil.c |7 ---
 1 files changed, 4 insertions(+), 3 deletions(-)

diff --git a/unit/test-stkutil.c b/unit/test-stkutil.c
index f1cad78..aa62aac 100644
--- a/unit/test-stkutil.c
+++ b/unit/test-stkutil.c
@@ -129,7 +129,10 @@ static inline void check_address(const struct stk_address 
*command,
 /* Defined in TS 102.223 Section 8.2 */
 static inline void check_alpha_id(const char *command, const char *test)
 {
-   check_common_text(command, test);
+   if (test != NULL  strlen(test)  0)
+   check_common_text(command, test);
+   else
+   g_assert(command == NULL);
 }
 
 /* Defined in TS 102.223 Section 8.3 */
@@ -5937,8 +5940,6 @@ static void test_setup_menu(gconstpointer data)
g_assert(command-src == STK_DEVICE_IDENTITY_TYPE_UICC);
g_assert(command-dst == STK_DEVICE_IDENTITY_TYPE_TERMINAL);
 
-   if (test-alpha_id)
-   g_assert(command-setup_menu.alpha_id);
check_alpha_id(command-setup_menu.alpha_id, test-alpha_id);
check_items(command-setup_menu.items, test-items);
check_items_next_action_indicator(command-setup_menu.next_act,
-- 
1.7.0.4

___
ofono mailing list
ofono@ofono.org
http://lists.ofono.org/listinfo/ofono


[PATCH 0/1] Fix issue in ifx nitz time reporting

2011-03-18 Thread Jeevaka Badrappan
Hi,

 CTZDST will be reported only if the network daylight saving time is
received from network as part of the MM information message. Due to this,
time was not reported to the core.
 Fix is to schedule the timer once the CTZV is received. This way, time
information will be reported always and also only once as expected.

Regards,
Jeevaka

Jeevaka Badrappan (1):
  atmodem: fix issue in time reporting with ifx

 drivers/atmodem/network-registration.c |   25 +++--
 1 files changed, 23 insertions(+), 2 deletions(-)

___
ofono mailing list
ofono@ofono.org
http://lists.ofono.org/listinfo/ofono


[PATCH 1/1] atmodem: fix issue in time reporting with ifx

2011-03-18 Thread Jeevaka Badrappan
---
 drivers/atmodem/network-registration.c |   25 +++--
 1 files changed, 23 insertions(+), 2 deletions(-)

diff --git a/drivers/atmodem/network-registration.c 
b/drivers/atmodem/network-registration.c
index 4913611..0dbc72d 100644
--- a/drivers/atmodem/network-registration.c
+++ b/drivers/atmodem/network-registration.c
@@ -58,6 +58,7 @@ struct netreg_data {
int signal_max; /* max strength reported via CIND */
int tech;
struct ofono_network_time time;
+   guint nitz_source;
unsigned int vendor;
 };
 
@@ -691,6 +692,18 @@ static void ctzv_notify(GAtResult *result, gpointer 
user_data)
ofono_netreg_time_notify(netreg, nd-time);
 }
 
+static gboolean notify_time(gpointer user_data)
+{
+   struct ofono_netreg *netreg = user_data;
+   struct netreg_data *nd = ofono_netreg_get_data(netreg);
+
+   nd-nitz_source = 0;
+
+   ofono_netreg_time_notify(netreg, nd-time);
+
+   return FALSE;
+}
+
 static void ifx_ctzv_notify(GAtResult *result, gpointer user_data)
 {
struct ofono_netreg *netreg = user_data;
@@ -722,6 +735,11 @@ static void ifx_ctzv_notify(GAtResult *result, gpointer 
user_data)
nd-time.mday = mday;
nd-time.mon = mon;
nd-time.year = 2000 + year;
+
+   if (nd-nitz_source)
+   g_source_remove(nd-nitz_source);
+
+   nd-nitz_source = g_timeout_add(0, notify_time, user_data);
 }
 
 static void ifx_ctzdst_notify(GAtResult *result, gpointer user_data)
@@ -742,8 +760,6 @@ static void ifx_ctzdst_notify(GAtResult *result, gpointer 
user_data)
DBG(dst %d, dst);
 
nd-time.dst = dst;
-
-   ofono_netreg_time_notify(netreg, nd-time);
 }
 
 static void cind_cb(gboolean ok, GAtResult *result, gpointer user_data)
@@ -1367,6 +1383,11 @@ static void at_netreg_remove(struct ofono_netreg *netreg)
 {
struct netreg_data *nd = ofono_netreg_get_data(netreg);
 
+   if (nd-nitz_source) {
+   g_source_remove(nd-nitz_source);
+   nd-nitz_source = 0;
+   }
+
ofono_netreg_set_data(netreg, NULL);
 
g_at_chat_unref(nd-chat);
-- 
1.7.0.4

___
ofono mailing list
ofono@ofono.org
http://lists.ofono.org/listinfo/ofono


[PATCH v2 0/1] Fix issue in ifx nitz time reporting

2011-03-18 Thread Jeevaka Badrappan
Hi,

 CTZDST will be reported only if the network daylight saving time is
received from network as part of the MM information message. Due to this,
time was not reported to the core.
 Fix is to schedule the timer once the CTZV is received. This way, time
information will be reported always and also only once as expected.

Regards,
Jeevaka

Jeevaka Badrappan (1):
  atmodem: fix issue in time reporting with ifx

 drivers/atmodem/network-registration.c |   26 ++
 1 files changed, 26 insertions(+), 0 deletions(-)

___
ofono mailing list
ofono@ofono.org
http://lists.ofono.org/listinfo/ofono


[PATCH 0/1] Limits the send sms retry to network timeout

2011-03-17 Thread Jeevaka Badrappan
Hi,

  If sending of SMS fails, then oFono core will try to resend it after
n * 5 seconds(n = retry count). Due to this, conformance test case
27.22.8 sequence 1.4 fails(refer 31.124 spec). Plan is to limit the
failue codes for which the retry will be done. This patch allows the
retry if the failure is only due to network timeout. For all the other
failure cases, retry is not done.

Regards,
Jeevaka

Jeevaka Badrappan (1):
  sms: limit the sms sending retry

 src/sms.c |5 +
 1 files changed, 5 insertions(+), 0 deletions(-)

___
ofono mailing list
ofono@ofono.org
http://lists.ofono.org/listinfo/ofono


[PATCH 1/1] sms: limit the sms sending retry

2011-03-17 Thread Jeevaka Badrappan
---
 src/sms.c |5 +
 1 files changed, 5 insertions(+), 0 deletions(-)

diff --git a/src/sms.c b/src/sms.c
index 01f54dd..c4f8b54 100644
--- a/src/sms.c
+++ b/src/sms.c
@@ -47,6 +47,7 @@
 #define SETTINGS_GROUP Settings
 
 #define TXQ_MAX_RETRIES 4
+#define NETWORK_TIMEOUT 332
 
 static gboolean tx_next(gpointer user_data);
 
@@ -630,6 +631,10 @@ static void tx_finished(const struct ofono_error *error, 
int mr, void *data)
if (sms-registered == FALSE)
return;
 
+   /* Retry done only for Network Timeout failure */
+   if (error-error != NETWORK_TIMEOUT)
+   goto next_q;
+
if (!(entry-flags  OFONO_SMS_SUBMIT_FLAG_RETRY))
goto next_q;
 
-- 
1.7.0.4

___
ofono mailing list
ofono@ofono.org
http://lists.ofono.org/listinfo/ofono


[PATCH 0/1] Limits the send sms retry to network timeout

2011-03-17 Thread Jeevaka Badrappan
Hi,

  If sending of SMS fails, then oFono core will try to resend it after
n * 5 seconds(n = retry count). Due to this, conformance test case
27.22.8 sequence 1.4 fails(refer 31.124 spec). Plan is to limit the
failue codes for which the retry will be done. This patch allows the
retry if the failure is only due to network timeout. For all the other
failure cases, retry is not done.

Regards,
Jeevaka

Jeevaka Badrappan (1):
  sms: limit the sms sending retry

 src/sms.c |6 ++
 1 files changed, 6 insertions(+), 0 deletions(-)

___
ofono mailing list
ofono@ofono.org
http://lists.ofono.org/listinfo/ofono


[PATCH 0/1] Fixes issue with Get Inkey variable timeout

2011-03-16 Thread Jeevaka Badrappan
Hi,

 As per the ETSI TS 102 384 specification 27.22.4.2.8 section, duration
data object needs to be sent as part of the Get Inkey terminal response
for No response from user result.

Regards,
Jeevaka

Jeevaka Badrappan (1):
  stk: fix issue with Get Inkey variable timeout

 src/stk.c |   28 ++--
 1 files changed, 26 insertions(+), 2 deletions(-)

___
ofono mailing list
ofono@ofono.org
http://lists.ofono.org/listinfo/ofono


[PATCH 1/1] stk: fix issue with Get Inkey variable timeout

2011-03-16 Thread Jeevaka Badrappan
---
 src/stk.c |   28 ++--
 1 files changed, 26 insertions(+), 2 deletions(-)

diff --git a/src/stk.c b/src/stk.c
index e933e4e..68b6240 100644
--- a/src/stk.c
+++ b/src/stk.c
@@ -1396,7 +1396,19 @@ static void request_confirmation_cb(enum 
stk_agent_result result,
break;
 
case STK_AGENT_RESULT_TIMEOUT:
-   send_simple_response(stk, STK_RESULT_TYPE_NO_RESPONSE);
+   memset(rsp, 0, sizeof(rsp));
+
+   rsp.result.type = STK_RESULT_TYPE_NO_RESPONSE;
+
+   if (cmd-duration.interval) {
+   rsp.get_inkey.duration.unit = cmd-duration.unit;
+   set_get_inkey_duration(rsp.get_inkey.duration,
+   stk-get_inkey_start_ts);
+   }
+
+   if (stk_respond(stk, rsp, stk_command_cb))
+   stk_command_cb(error, stk);
+
break;
 
case STK_AGENT_RESULT_TERMINATE:
@@ -1439,7 +1451,19 @@ static void request_key_cb(enum stk_agent_result result, 
char *string,
break;
 
case STK_AGENT_RESULT_TIMEOUT:
-   send_simple_response(stk, STK_RESULT_TYPE_NO_RESPONSE);
+   memset(rsp, 0, sizeof(rsp));
+
+   rsp.result.type = STK_RESULT_TYPE_NO_RESPONSE;
+
+   if (cmd-duration.interval) {
+   rsp.get_inkey.duration.unit = cmd-duration.unit;
+   set_get_inkey_duration(rsp.get_inkey.duration,
+   stk-get_inkey_start_ts);
+   }
+
+   if (stk_respond(stk, rsp, stk_command_cb))
+   stk_command_cb(error, stk);
+
break;
 
case STK_AGENT_RESULT_TERMINATE:
-- 
1.7.0.4

___
ofono mailing list
ofono@ofono.org
http://lists.ofono.org/listinfo/ofono


[PATCH 0/2] Fix issue with null data object

2011-03-07 Thread Jeevaka Badrappan
Hi,

As per the specification, if the alpha identifier is provided by the UICC
and is a null data object (i.e. length = '00' and no value part), this is an
indication that the terminal should not give any information to the user.

Regards,
Jeevaka

Jeevaka Badrappan (2):
  stk: fix issue with null data object
  stkutil: fix issue with null data object

 src/stk.c |2 +-
 src/stkutil.c |2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

___
ofono mailing list
ofono@ofono.org
http://lists.ofono.org/listinfo/ofono


[PATCH 1/2] stk: fix issue with null data object

2011-03-07 Thread Jeevaka Badrappan
As per the specification, if alphad identifier is
provided and is a null data object, no information
should be given to the user.
---
 src/stk.c |2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/src/stk.c b/src/stk.c
index e933e4e..3d736dd 100644
--- a/src/stk.c
+++ b/src/stk.c
@@ -484,7 +484,7 @@ static void stk_alpha_id_set(struct ofono_stk *stk,
 * and no alpha identifier cases equally. This may be changed once
 * better idea is found out.
 */
-   if (alpha != NULL)
+   if (alpha != NULL  alpha[0] != '\0')
stk_agent_display_action_info(stk-current_agent, alpha, icon);
 
g_free(alpha);
-- 
1.7.0.4

___
ofono mailing list
ofono@ofono.org
http://lists.ofono.org/listinfo/ofono


[PATCH 2/2] stkutil: fix issue with null data object

2011-03-07 Thread Jeevaka Badrappan
---
 src/stkutil.c |2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/src/stkutil.c b/src/stkutil.c
index abd1c99..66b2924 100644
--- a/src/stkutil.c
+++ b/src/stkutil.c
@@ -308,7 +308,7 @@ static gboolean parse_dataobj_alpha_id(struct 
comprehension_tlv_iter *iter,
char *utf8;
 
len = comprehension_tlv_iter_get_length(iter);
-   if (len == 0) {
+   if (len = 1) {
*alpha_id = g_try_malloc0(1);
return TRUE;
}
-- 
1.7.0.4

___
ofono mailing list
ofono@ofono.org
http://lists.ofono.org/listinfo/ofono


[PATCH 0/4] Update the cell broadcast properties

2011-02-25 Thread Jeevaka Badrappan
Hi,

 Following patch removes the EmergencyType property as the required
functionality can be achieved with the EmergencyAlert property itself.
Also EmergencyBroadcast property has been renamed to WarningSystemBroadcast
to make it general for ETWS, CMAS and EU-Alert CBS message.

Regards,
Jeevaka

Jeevaka Badrappan (4):
  cbs: remove EmergencyType property
  cbs: rename EmergencyBroadcast property
  doc: Update the cell broadcast properties
  test: update the cell broadcast property

 doc/cell-broadcast-api.txt |   17 ++---
 src/cbs.c  |   44 +++-
 test/monitor-ofono |2 +-
 3 files changed, 18 insertions(+), 45 deletions(-)

___
ofono mailing list
ofono@ofono.org
http://lists.ofono.org/listinfo/ofono


[PATCH 1/4] cbs: remove EmergencyType property

2011-02-25 Thread Jeevaka Badrappan
---
 src/cbs.c |   35 ++-
 1 files changed, 6 insertions(+), 29 deletions(-)

diff --git a/src/cbs.c b/src/cbs.c
index d99f250..36cca48 100644
--- a/src/cbs.c
+++ b/src/cbs.c
@@ -98,7 +98,6 @@ static void cbs_dispatch_base_station_id(struct ofono_cbs 
*cbs, const char *id)
 }
 
 static void cbs_dispatch_emergency(struct ofono_cbs *cbs, const char *message,
-   enum etws_topic_type topic,
gboolean alert, gboolean popup)
 {
DBusConnection *conn = ofono_dbus_get_connection();
@@ -107,29 +106,6 @@ static void cbs_dispatch_emergency(struct ofono_cbs *cbs, 
const char *message,
DBusMessageIter iter;
DBusMessageIter dict;
dbus_bool_t boolean;
-   const char *emergency_str;
-
-   if (topic == ETWS_TOPIC_TYPE_TEST) {
-   ofono_error(Explicitly ignoring ETWS Test messages);
-   return;
-   }
-
-   switch (topic) {
-   case ETWS_TOPIC_TYPE_EARTHQUAKE:
-   emergency_str = Earthquake;
-   break;
-   case ETWS_TOPIC_TYPE_TSUNAMI:
-   emergency_str = Tsunami;
-   break;
-   case ETWS_TOPIC_TYPE_EARTHQUAKE_TSUNAMI:
-   emergency_str = Earthquake+Tsunami;
-   break;
-   case ETWS_TOPIC_TYPE_EMERGENCY:
-   emergency_str = Other;
-   break;
-   default:
-   return;
-   };
 
signal = dbus_message_new_signal(path, OFONO_CELL_BROADCAST_INTERFACE,
EmergencyBroadcast);
@@ -144,9 +120,6 @@ static void cbs_dispatch_emergency(struct ofono_cbs *cbs, 
const char *message,
OFONO_PROPERTIES_ARRAY_SIGNATURE,
dict);
 
-   ofono_dbus_dict_append(dict, EmergencyType,
-   DBUS_TYPE_STRING, emergency_str);
-
boolean = alert;
ofono_dbus_dict_append(dict, EmergencyAlert,
DBUS_TYPE_BOOLEAN, boolean);
@@ -251,6 +224,11 @@ void ofono_cbs_notify(struct ofono_cbs *cbs, const 
unsigned char *pdu,
gboolean alert = FALSE;
gboolean popup = FALSE;
 
+   if (c.message_identifier == ETWS_TOPIC_TYPE_TEST) {
+   ofono_error(Explicitly ignoring ETWS Test messages);
+   goto out;
+   }
+
/* 3GPP 23.041 9.4.1.2.1: Alert is encoded in bit 9 */
if (c.message_code  (1  9))
alert = TRUE;
@@ -259,8 +237,7 @@ void ofono_cbs_notify(struct ofono_cbs *cbs, const unsigned 
char *pdu,
if (c.message_code  (1  8))
popup = TRUE;
 
-   cbs_dispatch_emergency(cbs, message,
-   c.message_identifier, alert, popup);
+   cbs_dispatch_emergency(cbs, message, alert, popup);
goto out;
}
 
-- 
1.7.0.4

___
ofono mailing list
ofono@ofono.org
http://lists.ofono.org/listinfo/ofono


[PATCH 2/4] cbs: rename EmergencyBroadcast property

2011-02-25 Thread Jeevaka Badrappan
---
 src/cbs.c |   11 ++-
 1 files changed, 6 insertions(+), 5 deletions(-)

diff --git a/src/cbs.c b/src/cbs.c
index 36cca48..8bbae21 100644
--- a/src/cbs.c
+++ b/src/cbs.c
@@ -97,8 +97,9 @@ static void cbs_dispatch_base_station_id(struct ofono_cbs 
*cbs, const char *id)
__ofono_netreg_set_base_station_name(cbs-netreg, id);
 }
 
-static void cbs_dispatch_emergency(struct ofono_cbs *cbs, const char *message,
-   gboolean alert, gboolean popup)
+static void cbs_dispatch_warningsystem(struct ofono_cbs *cbs,
+   const char *message, gboolean alert,
+   gboolean popup)
 {
DBusConnection *conn = ofono_dbus_get_connection();
const char *path = __ofono_atom_get_path(cbs-atom);
@@ -108,7 +109,7 @@ static void cbs_dispatch_emergency(struct ofono_cbs *cbs, 
const char *message,
dbus_bool_t boolean;
 
signal = dbus_message_new_signal(path, OFONO_CELL_BROADCAST_INTERFACE,
-   EmergencyBroadcast);
+   WarningSystemBroadcast);
if (signal == NULL)
return;
 
@@ -237,7 +238,7 @@ void ofono_cbs_notify(struct ofono_cbs *cbs, const unsigned 
char *pdu,
if (c.message_code  (1  8))
popup = TRUE;
 
-   cbs_dispatch_emergency(cbs, message, alert, popup);
+   cbs_dispatch_warningsystem(cbs, message, alert, popup);
goto out;
}
 
@@ -532,7 +533,7 @@ static GDBusMethodTable cbs_methods[] = {
 static GDBusSignalTable cbs_signals[] = {
{ PropertyChanged,sv},
{ IncomingBroadcast,  sq},
-   { EmergencyBroadcast, sa{sv}},
+   { WarningSystemBroadcast, sa{v} },
{ }
 };
 
-- 
1.7.0.4

___
ofono mailing list
ofono@ofono.org
http://lists.ofono.org/listinfo/ofono


[PATCH 3/4] doc: Update the cell broadcast properties

2011-02-25 Thread Jeevaka Badrappan
---
 doc/cell-broadcast-api.txt |   17 ++---
 1 files changed, 6 insertions(+), 11 deletions(-)

diff --git a/doc/cell-broadcast-api.txt b/doc/cell-broadcast-api.txt
index 52618eb..5f6b4d6 100644
--- a/doc/cell-broadcast-api.txt
+++ b/doc/cell-broadcast-api.txt
@@ -36,19 +36,14 @@ Signals PropertyChanged(string name, variant 
value)
Please note that base station name broadcasts are
handled by the NetworkRegistration interface.
 
-   EmergencyBroadcast(string text, dict properties)
+   WarningSystemBroadcast(string text, dict properties)
 
-   This signal is emitted whenever an ETWS cell broadcast
-   is received.  The string text contains contents of the
-   broadcast.  The dict is made up of the following
-   entries:
-   EmergencyType - string value, possible values
-   include: Earthquake,
-   Tsunami,
-   Earthquake+Tsunami,
-   Other
+   This signal is emitted whenever an ETWS or CMAS or
+   EU-Alert cell broadcast is received. The string text
+   contains contents of the broadcast. The dict is made
+   up of the following entries:
EmergencyAlert - boolean value hinting whether
-   an extra emergency indicator
+   an emergency indicator
should be activated (e.g.
vibrate mode, emergency alert
mode.)
-- 
1.7.0.4

___
ofono mailing list
ofono@ofono.org
http://lists.ofono.org/listinfo/ofono


[PATCH 4/4] test: update the cell broadcast property

2011-02-25 Thread Jeevaka Badrappan
---
 test/monitor-ofono |2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/test/monitor-ofono b/test/monitor-ofono
index 8570c34..b803aa2 100755
--- a/test/monitor-ofono
+++ b/test/monitor-ofono
@@ -161,7 +161,7 @@ if __name__ == '__main__':
path_keyword=path,
interface_keyword=interface)
 
-   for member in [IncomingBroadcast, EmergencyBroadcast,
+   for member in [IncomingBroadcast, WarningSystemBroadcast,
IncomingMessage, ImmediateMessage]:
bus.add_signal_receiver(message,
bus_name=org.ofono,
-- 
1.7.0.4

___
ofono mailing list
ofono@ofono.org
http://lists.ofono.org/listinfo/ofono


[RFC] doc: Add support for CMAS/EU-Alert

2011-02-21 Thread Jeevaka Badrappan
---
 doc/cell-broadcast-api.txt |   26 +-
 1 files changed, 17 insertions(+), 9 deletions(-)

diff --git a/doc/cell-broadcast-api.txt b/doc/cell-broadcast-api.txt
index 52618eb..71b2516 100644
--- a/doc/cell-broadcast-api.txt
+++ b/doc/cell-broadcast-api.txt
@@ -36,19 +36,27 @@ Signals PropertyChanged(string name, variant 
value)
Please note that base station name broadcasts are
handled by the NetworkRegistration interface.
 
-   EmergencyBroadcast(string text, dict properties)
+   WarningSystemBroadcast(string text, dict properties)
 
-   This signal is emitted whenever an ETWS cell broadcast
-   is received.  The string text contains contents of the
-   broadcast.  The dict is made up of the following
-   entries:
-   EmergencyType - string value, possible values
+   This signal is emitted whenever an ETWS or CMAS or
+   EU-Alert cell broadcast is received. The string text
+   contains contents of the broadcast. The dict is made
+   up of the following entries:
+   WarningType - string value, possible values
include: Earthquake,
Tsunami,
Earthquake+Tsunami,
-   Other
-   EmergencyAlert - boolean value hinting whether
-   an extra emergency indicator
+   OtherEmergency,
+   Presidential,
+   Extreme,
+   Severe,
+   Advisory,
+   ChildAbduction,
+   MonthlyTest,
+   Exercise
+
+   WarningAlert - boolean value hinting whether
+   an emergency indicator
should be activated (e.g.
vibrate mode, emergency alert
mode.)
-- 
1.7.0.4

___
ofono mailing list
ofono@ofono.org
http://lists.ofono.org/listinfo/ofono


[PATCH] network: Remove unused SetProperty

2011-02-11 Thread Jeevaka Badrappan
---
 doc/network-api.txt |   10 --
 1 files changed, 0 insertions(+), 10 deletions(-)

diff --git a/doc/network-api.txt b/doc/network-api.txt
index 4cb6366..db8da75 100644
--- a/doc/network-api.txt
+++ b/doc/network-api.txt
@@ -12,16 +12,6 @@ Methods  dict GetProperties()
 
Possible Errors: [service].Error.InvalidArguments
 
-   void SetProperty(string name, variant value)
-
-   Changes the value of the specified property. Only
-   properties that are listed as readwrite are
-   changeable. On success a PropertyChanged signal
-   will be emitted.
-
-   Possible Errors: [service].Error.InvalidArguments
-[service].Error.DoesNotExist
-
void Register()
 
Attempts to register to the default network. The
-- 
1.7.0.4

___
ofono mailing list
ofono@ofono.org
http://lists.ofono.org/listinfo/ofono


[PATCH 0/1] Update possible errors

2011-02-11 Thread Jeevaka Badrappan
Hi,

  Following patch updates the possible errors to the api documentation.
Possible error values are updated based on currently returned errors.

Regards,
Jeevaka

Jeevaka Badrappan (1):
  doc: Update possible errors

 doc/audio-settings-api.txt |2 -
 doc/call-barring-api.txt   |   31 ++
 doc/call-forwarding-api.txt|   16 +++
 doc/call-meter-api.txt |   14 ++
 doc/call-settings-api.txt  |8 ++
 doc/call-volume-api.txt|9 +++---
 doc/cdma-voicecall-manager-api.txt |   10 +++
 doc/cell-broadcast-api.txt |7 ++---
 doc/connman-api.txt|   25 ++
 doc/manager-api.txt|2 -
 doc/message-api.txt|2 -
 doc/message-waiting-api.txt|7 +++--
 doc/messagemanager-api.txt |   14 --
 doc/modem-api.txt  |   10 ---
 doc/network-api.txt|   16 +++
 doc/phonebook-api.txt  |2 +-
 doc/pushnotification-api.txt   |8 ++
 doc/radio-settings-api.txt |9 +++---
 doc/sim-api.txt|   37 +-
 doc/stk-api.txt|   17 +++-
 doc/supplementaryservices-api.txt  |   20 +++---
 doc/voicecall-api.txt  |   17 +++-
 doc/voicecallmanager-api.txt   |   49 ++-
 23 files changed, 273 insertions(+), 59 deletions(-)

___
ofono mailing list
ofono@ofono.org
http://lists.ofono.org/listinfo/ofono


[PATCH 1/1] doc: Update possible errors

2011-02-11 Thread Jeevaka Badrappan
---
 doc/audio-settings-api.txt |2 -
 doc/call-barring-api.txt   |   31 ++
 doc/call-forwarding-api.txt|   16 +++
 doc/call-meter-api.txt |   14 ++
 doc/call-settings-api.txt  |8 ++
 doc/call-volume-api.txt|9 +++---
 doc/cdma-voicecall-manager-api.txt |   10 +++
 doc/cell-broadcast-api.txt |7 ++---
 doc/connman-api.txt|   25 ++
 doc/manager-api.txt|2 -
 doc/message-api.txt|2 -
 doc/message-waiting-api.txt|7 +++--
 doc/messagemanager-api.txt |   14 --
 doc/modem-api.txt  |   10 ---
 doc/network-api.txt|   16 +++
 doc/phonebook-api.txt  |2 +-
 doc/pushnotification-api.txt   |8 ++
 doc/radio-settings-api.txt |9 +++---
 doc/sim-api.txt|   37 +-
 doc/stk-api.txt|   17 +++-
 doc/supplementaryservices-api.txt  |   20 +++---
 doc/voicecall-api.txt  |   17 +++-
 doc/voicecallmanager-api.txt   |   49 ++-
 23 files changed, 273 insertions(+), 59 deletions(-)

diff --git a/doc/audio-settings-api.txt b/doc/audio-settings-api.txt
index 0f60306..49d7909 100644
--- a/doc/audio-settings-api.txt
+++ b/doc/audio-settings-api.txt
@@ -10,8 +10,6 @@ Methods   dict GetProperties()
Returns all audio settings properties. See the
properties section for available properties.
 
-   Possible Errors: [service].Error.InvalidArguments
-
 SignalsPropertyChanged(string property, variant value)
 
This signal indicates a changed value of the given
diff --git a/doc/call-barring-api.txt b/doc/call-barring-api.txt
index 1534494..a80bf61 100644
--- a/doc/call-barring-api.txt
+++ b/doc/call-barring-api.txt
@@ -9,29 +9,60 @@ Methods   dict GetProperties()
 
Contains the properties for this object.
 
+   Possible Errors: [service].Error.InProgress
+[service].Error.NotImplemented
+
void ChangePassword(string old_password, string new_password)
 
Register new network password for the barring
services.
 
+   Possible Errors: [service].Error.InProgress
+[service].Error.InvalidFormat
+[service].Error.Failed
+
void DisableAll(string password)
 
Disables all call barrings.
 
+   Possible Errors: [service].Error.InProgress
+[service].Error.NotImplemented
+[service].Error.InvalidArguments
+[service].Error.InvalidFormat
+[service].Error.Failed
+
void DisableAllIncoming(string password)
 
Disables barrings for incoming calls.
 
+   Possible Errors: [service].Error.InProgress
+[service].Error.NotImplemented
+[service].Error.InvalidArguments
+[service].Error.InvalidFormat
+[service].Error.Failed
+
void DisableAllOutgoing(string password)
 
Disables barrings for outgoing calls.
 
+   Possible Errors: [service].Error.InProgress
+[service].Error.NotImplemented
+[service].Error.InvalidArguments
+[service].Error.InvalidFormat
+[service].Error.Failed
+
void SetProperty(string property, variant value, string pin2)
 
Sets the given property value to that specified in
call parameter.  For all properties, the password
(typically PIN2) must be provided.
 
+   Possible Errors: [service].Error.InProgress
+[service].Error.NotImplemented
+[service].Error.InvalidArguments
+[service].Error.InvalidFormat
+[service].Error.Failed
+
 SignalsPropertyChanged(string property, variant value)
 
Signal is emitted whenever a property has changed.
diff --git a/doc/call-forwarding-api.txt b/doc/call-forwarding-api.txt
index 

[PATCH 0/1] Fix issue in ifxmodem set rat mode

2011-02-11 Thread Jeevaka Badrappan
Hi,
 
  Find the syntax of the XRAT set command:

Defined values

AcT indicates the radio access technology and may be

0 GSM single mode
1 GSM / UMTS Dual mode
2 UTRAN (UMTS)

 PreferredAct  This parameter is used for network registration in case of 
AcT=1.

0 RAT GSM
2 RAT UMTS

Regards,
Jeevaka

Jeevaka Badrappan (1):
  ifxmodem: fix issue in set rat mode

 drivers/ifxmodem/radio-settings.c |5 -
 1 files changed, 4 insertions(+), 1 deletions(-)

___
ofono mailing list
ofono@ofono.org
http://lists.ofono.org/listinfo/ofono


[PATCH 1/1] ifxmodem: fix issue in set rat mode

2011-02-11 Thread Jeevaka Badrappan
---
 drivers/ifxmodem/radio-settings.c |5 -
 1 files changed, 4 insertions(+), 1 deletions(-)

diff --git a/drivers/ifxmodem/radio-settings.c 
b/drivers/ifxmodem/radio-settings.c
index fd590ae..bd292c5 100644
--- a/drivers/ifxmodem/radio-settings.c
+++ b/drivers/ifxmodem/radio-settings.c
@@ -145,7 +145,10 @@ static void ifx_set_rat_mode(struct ofono_radio_settings 
*rs,
goto error;
}
 
-   snprintf(buf, sizeof(buf), AT+XRAT=%u,%u, value, preferred);
+   if (value == 1)
+   snprintf(buf, sizeof(buf), AT+XRAT=%u,%u, value, preferred);
+   else
+   snprintf(buf, sizeof(buf), AT+XRAT=%u, value);
 
if (g_at_chat_send(rsd-chat, buf, none_prefix,
xrat_modify_cb, cbd, g_free)  0)
-- 
1.7.0.4

___
ofono mailing list
ofono@ofono.org
http://lists.ofono.org/listinfo/ofono


[PATCH] ifx: Remove modem selftest

2011-02-10 Thread Jeevaka Badrappan
Command used for self test is not working for all
versions of the modem firmware.
---
 plugins/ifx.c |   65 +---
 1 files changed, 2 insertions(+), 63 deletions(-)

diff --git a/plugins/ifx.c b/plugins/ifx.c
index a41fc36..527a8c4 100644
--- a/plugins/ifx.c
+++ b/plugins/ifx.c
@@ -524,7 +524,7 @@ static gboolean mux_timeout_cb(gpointer user_data)
struct ofono_modem *modem = user_data;
struct ifx_data *data = ofono_modem_get_data(modem);
 
-   ofono_error(Timeout with modem or multiplexer setup);
+   ofono_error(Timeout with multiplexer setup);
 
data-mux_init_timeout = 0;
 
@@ -539,56 +539,6 @@ static gboolean mux_timeout_cb(gpointer user_data)
return FALSE;
 }
 
-static void dev_ver_selftest_cb(gboolean ok, GAtResult *result,
-   gpointer user_data)
-{
-   struct ofono_modem *modem = user_data;
-   struct ifx_data *data = ofono_modem_get_data(modem);
-
-   if (ok)
-   return;
-
-   ofono_error(at@vers:device_version_id()-FAILED);
-
-   if (data-mux_init_timeout  0) {
-   g_source_remove(data-mux_init_timeout);
-   data-mux_init_timeout = 0;
-   }
-
-   g_at_chat_unref(data-dlcs[AUX_DLC]);
-   data-dlcs[AUX_DLC] = NULL;
-
-   g_io_channel_unref(data-device);
-   data-device = NULL;
-
-   ofono_modem_set_powered(modem, FALSE);
-}
-
-static void rtc_gti_selftest_cb(gboolean ok, GAtResult *result,
-   gpointer user_data)
-{
-   struct ofono_modem *modem = user_data;
-   struct ifx_data *data = ofono_modem_get_data(modem);
-
-   if (ok)
-   return;
-
-   ofono_error(at@rtc_drv:rtc_gti_test_verify_32khz()-FAILED);
-
-   if (data-mux_init_timeout  0) {
-   g_source_remove(data-mux_init_timeout);
-   data-mux_init_timeout = 0;
-   }
-
-   g_at_chat_unref(data-dlcs[AUX_DLC]);
-   data-dlcs[AUX_DLC] = NULL;
-
-   g_io_channel_unref(data-device);
-   data-device = NULL;
-
-   ofono_modem_set_powered(modem, FALSE);
-}
-
 static int ifx_enable(struct ofono_modem *modem)
 {
struct ifx_data *data = ofono_modem_get_data(modem);
@@ -642,24 +592,13 @@ static int ifx_enable(struct ofono_modem *modem)
g_at_chat_send(chat, ATE0 +CMEE=1, NULL,
NULL, NULL, NULL);
 
-   /* Execute modem self tests */
-   g_at_chat_send(chat, at@rtc_drv:rtc_gti_test_verify_32khz(), NULL,
-   rtc_gti_selftest_cb, modem, NULL);
-
-   g_at_chat_send(chat, at@vers:device_version_id(), NULL,
-   dev_ver_selftest_cb, modem, NULL);
-
/* Enable multiplexer */
data-frame_size = 1509;
 
g_at_chat_send(chat, AT+CMUX=0,0,,1509,10,3,30,,, NULL,
mux_setup_cb, modem, NULL);
 
-   /*
-* Total self test execution time is around 2 seconds. Use
-* 10 seconds timeout to cover self tests and multiplexer setup.
-*/
-   data-mux_init_timeout = g_timeout_add_seconds(10, mux_timeout_cb,
+   data-mux_init_timeout = g_timeout_add_seconds(5, mux_timeout_cb,
modem);
 
data-dlcs[AUX_DLC] = chat;
-- 
1.7.0.4

___
ofono mailing list
ofono@ofono.org
http://lists.ofono.org/listinfo/ofono


[PATCH] ifxmodem: add CNAP support

2011-02-10 Thread Jeevaka Badrappan
---
 drivers/ifxmodem/voicecall.c |   51 ++
 1 files changed, 51 insertions(+), 0 deletions(-)

diff --git a/drivers/ifxmodem/voicecall.c b/drivers/ifxmodem/voicecall.c
index 30e6991..87a48e6 100644
--- a/drivers/ifxmodem/voicecall.c
+++ b/drivers/ifxmodem/voicecall.c
@@ -630,6 +630,56 @@ static void clip_notify(GAtResult *result, gpointer 
user_data)
ofono_voicecall_notify(vc, call);
 }
 
+static void cnap_notify(GAtResult *result, gpointer user_data)
+{
+   struct ofono_voicecall *vc = user_data;
+   struct voicecall_data *vd = ofono_voicecall_get_data(vc);
+   GAtResultIter iter;
+   const char *name;
+   int validity;
+   GSList *l;
+   struct ofono_call *call;
+
+   /*
+* Currently, its not clear which URC will contain the
+* calling party name for the waiting call.
+*/
+   l = g_slist_find_custom(vd-calls,
+   GINT_TO_POINTER(CALL_STATUS_INCOMING),
+   at_util_call_compare_by_status);
+   if (l == NULL) {
+   ofono_error(CNAP for unknown call);
+   return;
+   }
+
+   g_at_result_iter_init(iter, result);
+
+   if (!g_at_result_iter_next(iter, +CNAP:))
+   return;
+
+   if (!g_at_result_iter_next_string(iter, name))
+   return;
+
+   if (strlen(name)  0)
+   validity = CNAP_VALIDITY_VALID;
+   else
+   validity = CNAP_VALIDITY_NOT_AVAILABLE;
+
+   /* If we have CNI validity field, override our guessed value */
+   g_at_result_iter_next_number(iter, validity);
+
+   DBG(%s %d, name, validity);
+
+   call = l-data;
+
+   strncpy(call-name, name, OFONO_MAX_CALLER_NAME_LENGTH);
+   call-name[OFONO_MAX_CALLER_NAME_LENGTH] = '\0';
+   call-cnap_validity = validity;
+
+   if (call-type == 0)
+   ofono_voicecall_notify(vc, call);
+}
+
 static void ccwa_notify(GAtResult *result, gpointer user_data)
 {
struct ofono_voicecall *vc = user_data;
@@ -746,6 +796,7 @@ static void ifx_voicecall_initialized(gboolean ok, 
GAtResult *result,
 
g_at_chat_register(vd-chat, +CRING:, cring_notify, FALSE, vc, NULL);
g_at_chat_register(vd-chat, +CLIP:, clip_notify, FALSE, vc, NULL);
+   g_at_chat_register(vd-chat, +CNAP:, cnap_notify, FALSE, vc, NULL);
g_at_chat_register(vd-chat, +CCWA:, ccwa_notify, FALSE, vc, NULL);
g_at_chat_register(vd-chat, +XEM:, xem_notify, FALSE, vc, NULL);
g_at_chat_register(vd-chat, +XCALLSTAT:, xcallstat_notify,
-- 
1.7.0.4

___
ofono mailing list
ofono@ofono.org
http://lists.ofono.org/listinfo/ofono


[PATCH] atmodem: close the list in clvl_range_query

2011-02-08 Thread Jeevaka Badrappan
---
 drivers/atmodem/call-volume.c |1 +
 1 files changed, 1 insertions(+), 0 deletions(-)

diff --git a/drivers/atmodem/call-volume.c b/drivers/atmodem/call-volume.c
index 6d87276..1e32a69 100644
--- a/drivers/atmodem/call-volume.c
+++ b/drivers/atmodem/call-volume.c
@@ -114,6 +114,7 @@ static void clvl_range_query(gboolean ok, GAtResult 
*result, gpointer user_data)
/* Try opening the list, but don't fail */
g_at_result_iter_open_list(iter);
g_at_result_iter_next_range(iter, cvd-clvl_min, cvd-clvl_max);
+   g_at_result_iter_close_list(iter);
 }
 
 static void cv_generic_set_cb(gboolean ok, GAtResult *result,
-- 
1.7.0.4

___
ofono mailing list
ofono@ofono.org
http://lists.ofono.org/listinfo/ofono


[PATCH v4 1/1] ifxmodem: move call creation to xcallstat_notify

2011-02-08 Thread Jeevaka Badrappan
---
 drivers/ifxmodem/voicecall.c |  172 --
 1 files changed, 98 insertions(+), 74 deletions(-)

diff --git a/drivers/ifxmodem/voicecall.c b/drivers/ifxmodem/voicecall.c
index 648f46b..30e6991 100644
--- a/drivers/ifxmodem/voicecall.c
+++ b/drivers/ifxmodem/voicecall.c
@@ -79,7 +79,8 @@ static int class_to_call_type(int cls)
 
 static struct ofono_call *create_call(struct ofono_voicecall *vc, int type,
int direction, int status,
-   const char *num, int num_type, int clip)
+   const char *num, int num_type,
+   int clip, int id)
 {
struct voicecall_data *d = ofono_voicecall_get_data(vc);
struct ofono_call *call;
@@ -91,7 +92,7 @@ static struct ofono_call *create_call(struct ofono_voicecall 
*vc, int type,
 
ofono_call_init(call);
 
-   call-id = ofono_voicecall_get_next_callid(vc);
+   call-id = id;
call-type = type;
call-direction = direction;
call-status = status;
@@ -117,7 +118,8 @@ static void xcallstat_notify(GAtResult *result, gpointer 
user_data)
int id;
int status;
GSList *l;
-   struct ofono_call *call;
+   struct ofono_call *new_call;
+   struct ofono_call *existing_call = NULL;
 
g_at_result_iter_init(iter, result);
 
@@ -133,53 +135,83 @@ static void xcallstat_notify(GAtResult *result, gpointer 
user_data)
l = g_slist_find_custom(vd-calls, GINT_TO_POINTER(id),
at_util_call_compare_by_id);
 
-   if (l == NULL) {
-   /*
-* We should only receive XCALLSTAT on waiting and incoming
-* In the case of waiting, we will get the rest of the info
-* from CCWA indication.
-* In the case of incoming, we will get the info from CLIP
-* indications.
-*/
-   if (status != CALL_STATUS_INCOMING 
-   status != CALL_STATUS_WAITING) {
-   ofono_info(Received an XCALLSTAT for an untracked
-call, this indicates a bug!);
-   return;
-   }
-
+   if (l == NULL  status != CALL_STATUS_DIALING 
+   status != CALL_STATUS_INCOMING 
+   status != CALL_STATUS_WAITING) {
+   ofono_error(Received XCALLSTAT for an untracked
+call, this indicates a bug!);
return;
}
 
-   call = l-data;
+   if (l)
+   existing_call = l-data;
 
-   /* Check if call has been disconnected */
-   if (status == CALL_STATUS_DISCONNECTED) {
-   enum ofono_disconnect_reason r;
+   switch (status) {
+   case CALL_STATUS_DISCONNECTED:
+   {
+   enum ofono_disconnect_reason reason;
 
-   if (vd-local_release  (1  call-id))
-   r = OFONO_DISCONNECT_REASON_LOCAL_HANGUP;
-   else
-   r = OFONO_DISCONNECT_REASON_REMOTE_HANGUP;
+   existing_call-status = status;
 
-   if (call-type == 0)
-   ofono_voicecall_disconnected(vc, call-id, r, NULL);
+   if (vd-local_release  (1  existing_call-id))
+   reason = OFONO_DISCONNECT_REASON_LOCAL_HANGUP;
+   else
+   reason = OFONO_DISCONNECT_REASON_REMOTE_HANGUP;
 
-   vd-local_release = ~(1  call-id);
-   vd-calls = g_slist_remove(vd-calls, call);
-   g_free(call);
+   ofono_voicecall_disconnected(vc, existing_call-id,
+   reason, NULL);
 
-   return;
+   vd-local_release = ~(1  existing_call-id);
+   vd-calls = g_slist_remove(vd-calls, l-data);
+   g_free(existing_call);
+   break;
}
+   case CALL_STATUS_DIALING:
+   case CALL_STATUS_WAITING:
+   case CALL_STATUS_INCOMING:
+   {
+   int direction;
+
+   /* Handle the following situation:
+* Active Call + Waiting Call. Active Call is Released.
+* The Waiting call becomes Incoming. In this case, no
+* need to create a new call. Call status change will be
+* triggered from clip_notify.
+*/
+   if (existing_call) {
+   existing_call-status = status;
+   return;
+   }
 
-   /* For connected status, simply reset back to active */
-   if (status == 7)
-   status = 0;
+   if (status == CALL_STATUS_DIALING)
+   direction = CALL_DIRECTION_MOBILE_ORIGINATED;
+   

[PATCH v4 0/1] Refactor call status handling

2011-02-08 Thread Jeevaka Badrappan
Hi,

Since XCALLSTAT reports the voice call status information and call id,
creation of the call is moved inside xcallstat_notify function.

Regards,
Jeevaka

Jeevaka Badrappan (1):
  ifxmodem: move call creation to xcallstat_notify

 drivers/ifxmodem/voicecall.c |  172 --
 1 files changed, 98 insertions(+), 74 deletions(-)

___
ofono mailing list
ofono@ofono.org
http://lists.ofono.org/listinfo/ofono


[PATCH 0/2] Add handling of XCOLP and refactor call status handling

2011-02-07 Thread Jeevaka Badrappan
Hi,

 Incase of ifxmodem, COLP is not an intermediate status for ATD. Vendor
specific AT command XCOLP is used for the connected line presentation.
Since XCALLSTAT reports the voice call status information, there is no need to
listen for CRING notification. Following patch refactors the handling of 
call status information and also removes the CRING handling.

Regards,
Jeevaka

Jeevaka Badrappan (2):
  ifxmodem: add handling of XCOLP notification
  ifxmodem: refactor handling of call status

 drivers/ifxmodem/voicecall.c |  240 +++---
 1 files changed, 109 insertions(+), 131 deletions(-)

___
ofono mailing list
ofono@ofono.org
http://lists.ofono.org/listinfo/ofono


[PATCH 1/2] ifxmodem: add handling of XCOLP notification

2011-02-07 Thread Jeevaka Badrappan
---
 drivers/ifxmodem/voicecall.c |   51 ++
 1 files changed, 51 insertions(+), 0 deletions(-)

diff --git a/drivers/ifxmodem/voicecall.c b/drivers/ifxmodem/voicecall.c
index f66815a..d31fa70 100644
--- a/drivers/ifxmodem/voicecall.c
+++ b/drivers/ifxmodem/voicecall.c
@@ -688,6 +688,55 @@ static void ccwa_notify(GAtResult *result, gpointer 
user_data)
ofono_voicecall_notify(vc, call);
 }
 
+static void xcolp_notify(GAtResult *result, gpointer user_data)
+{
+   struct ofono_voicecall *vc = user_data;
+   struct voicecall_data *vd = ofono_voicecall_get_data(vc);
+   GAtResultIter iter;
+   const char *num;
+   int type, call_id;
+   GSList *l;
+   struct ofono_call *call;
+
+   g_at_result_iter_init(iter, result);
+
+   if (!g_at_result_iter_next(iter, +XCOLP:))
+   return;
+
+   if (!g_at_result_iter_next_number(iter, call_id))
+   return;
+
+   if (!g_at_result_iter_next_string(iter, num))
+   return;
+
+   if (!g_at_result_iter_next_number(iter, type))
+   return;
+
+   if (strlen(num) == 0) {
+   ofono_error(XCOLP received with invalid number!!!);
+   return;
+   }
+
+   DBG(xcolp_notify: %d %s %d, call_id, num, type);
+
+   l = g_slist_find_custom(vd-calls,
+   GINT_TO_POINTER(call_id),
+   at_util_call_compare_by_id);
+   if (l == NULL) {
+   ofono_error(XCOLP for unknown call);
+   return;
+   }
+
+   call = l-data;
+
+   strncpy(call-phone_number.number, num, OFONO_MAX_PHONE_NUMBER_LENGTH);
+   call-phone_number.number[OFONO_MAX_PHONE_NUMBER_LENGTH] = '\0';
+   call-phone_number.type = type;
+   call-clip_validity = CLIP_VALIDITY_VALID;
+
+   ofono_voicecall_notify(vc, call);
+}
+
 static void ifx_voicecall_initialized(gboolean ok, GAtResult *result,
gpointer user_data)
 {
@@ -702,6 +751,7 @@ static void ifx_voicecall_initialized(gboolean ok, 
GAtResult *result,
g_at_chat_register(vd-chat, +XEM:, xem_notify, FALSE, vc, NULL);
g_at_chat_register(vd-chat, +XCALLSTAT:, xcallstat_notify,
FALSE, vc, NULL);
+   g_at_chat_register(vd-chat, +XCOLP:, xcolp_notify, FALSE, vc, NULL);
 
ofono_voicecall_register(vc);
 }
@@ -722,6 +772,7 @@ static int ifx_voicecall_probe(struct ofono_voicecall *vc, 
unsigned int vendor,
 
g_at_chat_send(chat, AT+XCALLSTAT=1, none_prefix, NULL, NULL, NULL);
g_at_chat_send(chat, AT+XEMC=1, none_prefix, NULL, NULL, NULL);
+   g_at_chat_send(vd-chat, AT+XCOLP=1, none_prefix, NULL, NULL, NULL);
 
g_at_chat_send(vd-chat, AT+CRC=1, none_prefix, NULL, NULL, NULL);
g_at_chat_send(vd-chat, AT+CLIP=1, none_prefix, NULL, NULL, NULL);
-- 
1.7.0.4

___
ofono mailing list
ofono@ofono.org
http://lists.ofono.org/listinfo/ofono


[PATCH v2 0/5] Make use of defined call_status enum

2011-02-05 Thread Jeevaka Badrappan
Hi,

 Following set of patches makes use of the defined call_status enum
instead of using the actual defined values.

Regards,
Jeevaka

Jeevaka Badrappan (5):
  atmodem: use defined call_status enum
  hfpmodem: Use defined call_status enum
  huaweimodem: Use defined call_status enum
  ifxmodem: Use defined call_status enum
  stemodem: Use defined call_status enum

 drivers/atmodem/voicecall.c |   51 --
 drivers/hfpmodem/voicecall.c|   12 +
 drivers/huaweimodem/voicecall.c |   20 +--
 drivers/ifxmodem/voicecall.c|   33 -
 drivers/stemodem/voicecall.c|   15 +++
 5 files changed, 81 insertions(+), 50 deletions(-)

___
ofono mailing list
ofono@ofono.org
http://lists.ofono.org/listinfo/ofono


[PATCH v2 1/5] atmodem: use defined call_status enum

2011-02-05 Thread Jeevaka Badrappan
---
 drivers/atmodem/voicecall.c |   51 +++
 1 files changed, 32 insertions(+), 19 deletions(-)

diff --git a/drivers/atmodem/voicecall.c b/drivers/atmodem/voicecall.c
index 583e037..56fd858 100644
--- a/drivers/atmodem/voicecall.c
+++ b/drivers/atmodem/voicecall.c
@@ -161,7 +161,8 @@ static void clcc_poll_cb(gboolean ok, GAtResult *result, 
gpointer user_data)
nc = n ? n-data : NULL;
oc = o ? o-data : NULL;
 
-   if (nc  nc-status = 2  nc-status = 5)
+   if (nc  nc-status = CALL_STATUS_DIALING 
+   nc-status = CALL_STATUS_WAITING)
poll_again = TRUE;
 
if (oc  (nc == NULL || (nc-id  oc-id))) {
@@ -216,7 +217,8 @@ static void clcc_poll_cb(gboolean ok, GAtResult *result, 
gpointer user_data)
 * arrives, or RING is used, then signal the call
 * here
 */
-   if (nc-status == 4  (vd-flags  FLAG_NEED_CLIP)) {
+   if (nc-status == CALL_STATUS_INCOMING 
+   (vd-flags  FLAG_NEED_CLIP)) {
if (nc-type == 0)
ofono_voicecall_notify(vc, nc);
 
@@ -323,10 +325,10 @@ static void atd_cb(gboolean ok, GAtResult *result, 
gpointer user_data)
for (l = vd-calls; l; l = l-next) {
call = l-data;
 
-   if (call-status != 0)
+   if (call-status != CALL_STATUS_ACTIVE)
continue;
 
-   call-status = 1;
+   call-status = CALL_STATUS_HELD;
ofono_voicecall_notify(vc, call);
}
 
@@ -345,7 +347,7 @@ static void atd_cb(gboolean ok, GAtResult *result, gpointer 
user_data)
}
 
/* Generate a voice call that was just dialed, we guess the ID */
-   call = create_call(vc, 0, 0, 2, num, type, validity);
+   call = create_call(vc, 0, 0, CALL_STATUS_DIALING, num, type, validity);
if (call == NULL) {
ofono_error(Unable to malloc, call tracking will fail!);
return;
@@ -467,14 +469,16 @@ static void at_hold_all_active(struct ofono_voicecall *vc,
 static void at_release_all_held(struct ofono_voicecall *vc,
ofono_voicecall_cb_t cb, void *data)
 {
-   unsigned int held_status = 0x1  1;
+   unsigned int held_status = 1  CALL_STATUS_HELD;
at_template(AT+CHLD=0, vc, generic_cb, held_status, cb, data);
 }
 
 static void at_set_udub(struct ofono_voicecall *vc,
ofono_voicecall_cb_t cb, void *data)
 {
-   unsigned int incoming_or_waiting = (0x1  4) | (0x1  5);
+   unsigned int incoming_or_waiting =
+   (1  CALL_STATUS_INCOMING) | (1  CALL_STATUS_WAITING);
+
at_template(AT+CHLD=0, vc, generic_cb, incoming_or_waiting,
cb, data);
 }
@@ -547,7 +551,8 @@ static void at_deflect(struct ofono_voicecall *vc,
ofono_voicecall_cb_t cb, void *data)
 {
char buf[128];
-   unsigned int incoming_or_waiting = (0x1  4) | (0x1  5);
+   unsigned int incoming_or_waiting =
+   (1  CALL_STATUS_INCOMING) | (1  CALL_STATUS_WAITING);
 
snprintf(buf, sizeof(buf), AT+CTFR=%s,%d, ph-number, ph-type);
at_template(buf, vc, generic_cb, incoming_or_waiting, cb, data);
@@ -631,17 +636,19 @@ static void ring_notify(GAtResult *result, gpointer 
user_data)
struct ofono_call *call;
 
/* See comment in CRING */
-   if (g_slist_find_custom(vd-calls, GINT_TO_POINTER(5),
+   if (g_slist_find_custom(vd-calls,
+   GINT_TO_POINTER(CALL_STATUS_WAITING),
at_util_call_compare_by_status))
return;
 
/* RING can repeat, ignore if we already have an incoming call */
-   if (g_slist_find_custom(vd-calls, GINT_TO_POINTER(4),
+   if (g_slist_find_custom(vd-calls,
+   GINT_TO_POINTER(CALL_STATUS_INCOMING),
at_util_call_compare_by_status))
return;
 
/* Generate an incoming call of unknown type */
-   call = create_call(vc, 9, 1, 4, NULL, 128, 2);
+   call = create_call(vc, 9, 1, CALL_STATUS_INCOMING, NULL, 128, 2);
if (call == NULL) {
ofono_error(Couldn't create call, call management is fubar!);
return;
@@ -667,12 +674,14 @@ static void cring_notify(GAtResult *result, gpointer 
user_data)
 * the stage change.  If this happens, simply ignore the RING/CRING
 * when a waiting call exists (cannot have waiting + incoming in GSM)
 */
-   if (g_slist_find_custom(vd-calls, GINT_TO_POINTER(5),
+   if (g_slist_find_custom(vd-calls,
+   GINT_TO_POINTER(CALL_STATUS_WAITING),

[PATCH v2 2/5] hfpmodem: Use defined call_status enum

2011-02-05 Thread Jeevaka Badrappan
---
 drivers/hfpmodem/voicecall.c |   12 +++-
 1 files changed, 7 insertions(+), 5 deletions(-)

diff --git a/drivers/hfpmodem/voicecall.c b/drivers/hfpmodem/voicecall.c
index a87ddbe..f247bea 100644
--- a/drivers/hfpmodem/voicecall.c
+++ b/drivers/hfpmodem/voicecall.c
@@ -33,7 +33,7 @@
 #include ofono/log.h
 #include ofono/modem.h
 #include ofono/voicecall.h
-#include common.h
+#include common.h
 #include gatchat.h
 #include gatresult.h
 
@@ -337,7 +337,7 @@ static void atd_cb(gboolean ok, GAtResult *result, gpointer 
user_data)
for (l = vd-calls; l; l = l-next) {
call = l-data;
 
-   if (call-status != 0)
+   if (call-status != CALL_STATUS_ACTIVE)
continue;
 
call-status = CALL_STATUS_HELD;
@@ -436,7 +436,7 @@ static void hfp_release_all_held(struct ofono_voicecall *vc,
ofono_voicecall_cb_t cb, void *data)
 {
struct voicecall_data *vd = ofono_voicecall_get_data(vc);
-   unsigned int held_status = 0x1  1;
+   unsigned int held_status = 1  CALL_STATUS_HELD;
 
if (vd-ag_mpty_features  AG_CHLD_0) {
hfp_template(AT+CHLD=0, vc, generic_cb, held_status,
@@ -451,7 +451,8 @@ static void hfp_set_udub(struct ofono_voicecall *vc,
ofono_voicecall_cb_t cb, void *data)
 {
struct voicecall_data *vd = ofono_voicecall_get_data(vc);
-   unsigned int incoming_or_waiting = (0x1  4) | (0x1  5);
+   unsigned int incoming_or_waiting =
+   (1  CALL_STATUS_INCOMING) | (1  CALL_STATUS_WAITING);
 
if (vd-ag_mpty_features  AG_CHLD_0) {
hfp_template(AT+CHLD=0, vc, generic_cb, incoming_or_waiting,
@@ -647,7 +648,8 @@ static void ccwa_notify(GAtResult *result, gpointer 
user_data)
 
DBG(ccwa_notify: %s %d %d, num, num_type, validity);
 
-   call = create_call(vc, 0, 1, 5, num, num_type, validity);
+   call = create_call(vc, 0, 1, CALL_STATUS_WAITING, num, num_type,
+   validity);
 
if (call == NULL) {
ofono_error(malloc call struct failed.  
-- 
1.7.0.4

___
ofono mailing list
ofono@ofono.org
http://lists.ofono.org/listinfo/ofono


[PATCH v2 3/5] huaweimodem: Use defined call_status enum

2011-02-05 Thread Jeevaka Badrappan
---
 drivers/huaweimodem/voicecall.c |   20 
 1 files changed, 12 insertions(+), 8 deletions(-)

diff --git a/drivers/huaweimodem/voicecall.c b/drivers/huaweimodem/voicecall.c
index 53377d9..1800763 100644
--- a/drivers/huaweimodem/voicecall.c
+++ b/drivers/huaweimodem/voicecall.c
@@ -38,6 +38,7 @@
 #include gatchat.h
 #include gatresult.h
 
+#include common.h
 #include huaweimodem.h
 
 static const char *none_prefix[] = { NULL };
@@ -170,8 +171,9 @@ static void cring_notify(GAtResult *result, gpointer 
user_data)
int id;
 
/* CRING can repeat, ignore if we already have an incoming call */
-   if (g_slist_find_custom(vd-calls, GINT_TO_POINTER(4),
-   at_util_call_compare_by_status))
+   if (g_slist_find_custom(vd-calls,
+   GINT_TO_POINTER(CALL_STATUS_INCOMING),
+   at_util_call_compare_by_status))
return;
 
g_at_result_iter_init(iter, result);
@@ -192,7 +194,7 @@ static void cring_notify(GAtResult *result, gpointer 
user_data)
id = ofono_voicecall_get_next_callid(vc);
 
/* Generate an incoming call */
-   create_call(vc, type, 1, 4, NULL, 128, 2, id);
+   create_call(vc, type, 1, CALL_STATUS_INCOMING, NULL, 128, 2, id);
 
/* Assume the CLIP always arrives, and we signal the call there */
DBG(%d, type);
@@ -208,8 +210,9 @@ static void clip_notify(GAtResult *result, gpointer 
user_data)
GSList *l;
struct ofono_call *call;
 
-   l = g_slist_find_custom(vd-calls, GINT_TO_POINTER(4),
-   at_util_call_compare_by_status);
+   l = g_slist_find_custom(vd-calls,
+   GINT_TO_POINTER(CALL_STATUS_INCOMING),
+   at_util_call_compare_by_status);
if (l == NULL) {
ofono_error(CLIP for unknown call);
return;
@@ -307,7 +310,8 @@ static void orig_notify(GAtResult *result, gpointer 
user_data)
 
ofono_info(Call origin: id %d type %d, call_id, call_type);
 
-   call = create_call(vc, call_type, 0, 2, NULL, 128, 2, call_id);
+   call = create_call(vc, call_type, 0, CALL_STATUS_DIALING, NULL, 128, 2,
+   call_id);
if (call == NULL) {
ofono_error(Unable to malloc, call tracking will fail!);
return;
@@ -345,7 +349,7 @@ static void conf_notify(GAtResult *result, gpointer 
user_data)
 
/* Set call to alerting */
call = l-data;
-   call-status = 3;
+   call-status = CALL_STATUS_ALERTING;
 
if (call-type == 0)
ofono_voicecall_notify(vc, call);
@@ -382,7 +386,7 @@ static void conn_notify(GAtResult *result, gpointer 
user_data)
 
/* Set call to active */
call = l-data;
-   call-status = 0;
+   call-status = CALL_STATUS_ACTIVE;
 
if (call-type == 0)
ofono_voicecall_notify(vc, call);
-- 
1.7.0.4

___
ofono mailing list
ofono@ofono.org
http://lists.ofono.org/listinfo/ofono


[PATCH v2 5/5] stemodem: Use defined call_status enum

2011-02-05 Thread Jeevaka Badrappan
---
 drivers/stemodem/voicecall.c |   15 +--
 1 files changed, 9 insertions(+), 6 deletions(-)

diff --git a/drivers/stemodem/voicecall.c b/drivers/stemodem/voicecall.c
index 4a3a83d..b8fcf5b 100644
--- a/drivers/stemodem/voicecall.c
+++ b/drivers/stemodem/voicecall.c
@@ -255,8 +255,10 @@ static void ste_hangup(struct ofono_voicecall *vc,
ofono_voicecall_cb_t cb, void *data)
 {
unsigned int active_dial_alert_or_incoming =
-   (0x1  CALL_STATUS_ACTIVE) | (0x1  
CALL_STATUS_DIALING) |
-   (0x1  CALL_STATUS_ALERTING) | (0x1  
CALL_STATUS_INCOMING);
+   (1  CALL_STATUS_ACTIVE) |
+   (1  CALL_STATUS_DIALING) |
+   (1  CALL_STATUS_ALERTING) |
+   (1  CALL_STATUS_INCOMING);
 
ste_template(AT+CHUP, vc, ste_generic_cb,
active_dial_alert_or_incoming, cb, data);
@@ -271,7 +273,7 @@ static void ste_hold_all_active(struct ofono_voicecall *vc,
 static void ste_release_all_held(struct ofono_voicecall *vc,
ofono_voicecall_cb_t cb, void *data)
 {
-   unsigned int held = 0x1  CALL_STATUS_HELD;
+   unsigned int held = 1  CALL_STATUS_HELD;
 
ste_template(AT+CHLD=0, vc, ste_generic_cb, held, cb, data);
 }
@@ -280,7 +282,7 @@ static void ste_set_udub(struct ofono_voicecall *vc,
ofono_voicecall_cb_t cb, void *data)
 {
unsigned int incoming_or_waiting =
-   (0x1  CALL_STATUS_INCOMING) | (0x1  
CALL_STATUS_WAITING);
+   (1  CALL_STATUS_INCOMING) | (1  
CALL_STATUS_WAITING);
 
ste_template(AT+CHLD=0, vc, ste_generic_cb, incoming_or_waiting,
cb, data);
@@ -289,7 +291,7 @@ static void ste_set_udub(struct ofono_voicecall *vc,
 static void ste_release_all_active(struct ofono_voicecall *vc,
ofono_voicecall_cb_t cb, void *data)
 {
-   unsigned int active = 0x1  CALL_STATUS_ACTIVE;
+   unsigned int active = 1  CALL_STATUS_ACTIVE;
 
ste_template(AT+CHLD=1, vc, ste_generic_cb, active, cb, data);
 }
@@ -356,7 +358,8 @@ static void ste_deflect(struct ofono_voicecall *vc,
ofono_voicecall_cb_t cb, void *data)
 {
char buf[128];
-   unsigned int incoming_or_waiting = (0x1  4) | (0x1  5);
+   unsigned int incoming_or_waiting =
+   (1  CALL_STATUS_INCOMING) | (1  CALL_STATUS_WAITING);
 
snprintf(buf, sizeof(buf), AT+CTFR=\%s\,%d, ph-number, ph-type);
ste_template(buf, vc, ste_generic_cb, incoming_or_waiting, cb, data);
-- 
1.7.0.4

___
ofono mailing list
ofono@ofono.org
http://lists.ofono.org/listinfo/ofono


[PATCH v2 4/5] ifxmodem: Use defined call_status enum

2011-02-05 Thread Jeevaka Badrappan
---
 drivers/ifxmodem/voicecall.c |   33 +
 1 files changed, 21 insertions(+), 12 deletions(-)

diff --git a/drivers/ifxmodem/voicecall.c b/drivers/ifxmodem/voicecall.c
index e7f72fc..5ff3bcc 100644
--- a/drivers/ifxmodem/voicecall.c
+++ b/drivers/ifxmodem/voicecall.c
@@ -38,6 +38,7 @@
 #include gatchat.h
 #include gatresult.h
 
+#include common.h
 #include ifxmodem.h
 
 static const char *none_prefix[] = { NULL };
@@ -143,7 +144,8 @@ static void xcallstat_notify(GAtResult *result, gpointer 
user_data)
 * In the case of incoming, we will get the info from CLIP
 * indications.
 */
-   if (status != 4  status != 5) {
+   if (status != CALL_STATUS_INCOMING 
+   status != CALL_STATUS_WAITING) {
ofono_info(Received an XCALLSTAT for an untracked
 call, this indicates a bug!);
return;
@@ -155,7 +157,7 @@ static void xcallstat_notify(GAtResult *result, gpointer 
user_data)
call = l-data;
 
/* Check if call has been disconnected */
-   if (status == 6) {
+   if (status == CALL_STATUS_DISCONNECTED) {
enum ofono_disconnect_reason r;
 
if (vd-local_release  (0x1  call-id))
@@ -282,7 +284,7 @@ static void atd_cb(gboolean ok, GAtResult *result, gpointer 
user_data)
}
 
/* Generate a voice call that was just dialed, we guess the ID */
-   call = create_call(vc, 0, 0, 2, num, type, validity);
+   call = create_call(vc, 0, 0, CALL_STATUS_DIALING, num, type, validity);
if (call == NULL) {
ofono_error(Unable to malloc, call tracking will fail!);
return;
@@ -390,14 +392,16 @@ static void ifx_hold_all_active(struct ofono_voicecall 
*vc,
 static void ifx_release_all_held(struct ofono_voicecall *vc,
ofono_voicecall_cb_t cb, void *data)
 {
-   unsigned int held_status = 0x1  1;
+   unsigned int held_status = 1  CALL_STATUS_HELD;
ifx_template(AT+CHLD=0, vc, generic_cb, held_status, cb, data);
 }
 
 static void ifx_set_udub(struct ofono_voicecall *vc,
ofono_voicecall_cb_t cb, void *data)
 {
-   unsigned int incoming_or_waiting = (0x1  4) | (0x1  5);
+   unsigned int incoming_or_waiting =
+   (1  CALL_STATUS_INCOMING) | (1  CALL_STATUS_WAITING);
+
ifx_template(AT+CHLD=0, vc, generic_cb, incoming_or_waiting,
cb, data);
 }
@@ -470,7 +474,8 @@ static void ifx_deflect(struct ofono_voicecall *vc,
ofono_voicecall_cb_t cb, void *data)
 {
char buf[128];
-   unsigned int incoming_or_waiting = (0x1  4) | (0x1  5);
+   unsigned int incoming_or_waiting =
+   (1  CALL_STATUS_INCOMING) | (1  CALL_STATUS_WAITING);
 
snprintf(buf, sizeof(buf), AT+CTFR=%s,%d, ph-number, ph-type);
ifx_template(buf, vc, generic_cb, incoming_or_waiting, cb, data);
@@ -541,12 +546,14 @@ static void cring_notify(GAtResult *result, gpointer 
user_data)
 * the stage change.  If this happens, simply ignore the RING/CRING
 * when a waiting call exists (cannot have waiting + incoming in GSM)
 */
-   if (g_slist_find_custom(vd-calls, GINT_TO_POINTER(5),
+   if (g_slist_find_custom(vd-calls,
+   GINT_TO_POINTER(CALL_STATUS_WAITING),
at_util_call_compare_by_status))
return;
 
/* CRING can repeat, ignore if we already have an incoming call */
-   if (g_slist_find_custom(vd-calls, GINT_TO_POINTER(4),
+   if (g_slist_find_custom(vd-calls,
+   GINT_TO_POINTER(CALL_STATUS_INCOMING),
at_util_call_compare_by_status))
return;
 
@@ -566,7 +573,7 @@ static void cring_notify(GAtResult *result, gpointer 
user_data)
type = 9;
 
/* Generate an incoming call */
-   create_call(vc, type, 1, 4, NULL, 128, 2);
+   create_call(vc, type, 1, CALL_STATUS_INCOMING, NULL, 128, 2);
 
/* Assume the CLIP always arrives, and we signal the call there */
DBG(cring_notify);
@@ -582,7 +589,8 @@ static void clip_notify(GAtResult *result, gpointer 
user_data)
GSList *l;
struct ofono_call *call;
 
-   l = g_slist_find_custom(vd-calls, GINT_TO_POINTER(4),
+   l = g_slist_find_custom(vd-calls,
+   GINT_TO_POINTER(CALL_STATUS_INCOMING),
at_util_call_compare_by_status);
if (l == NULL) {
ofono_error(CLIP for unknown call);
@@ -637,7 +645,8 @@ static void ccwa_notify(GAtResult *result, gpointer 
user_data)
struct ofono_call *call;
 
/* Some modems resend CCWA, ignore it the second time around */
-   if 

[PATCH 1/7] coding-style: Don't use hex with shift operator

2011-02-05 Thread Jeevaka Badrappan
---
 doc/coding-style.txt |   12 
 1 files changed, 12 insertions(+), 0 deletions(-)

diff --git a/doc/coding-style.txt b/doc/coding-style.txt
index 40bb36b..287e9e9 100644
--- a/doc/coding-style.txt
+++ b/doc/coding-style.txt
@@ -294,6 +294,18 @@ void foo() // Wrong
 {
 }
 
+M16: Don't use hex value with shift operators
+==
+The expression argument to the shift operators should not be in hex.
+
+Example:
+
+1)
+1  y
+
+2)
+0x1  y   // Wrong
+
 O1: Shorten the name
 
 Better to use abbreviation, rather than full name, to name a variable,
-- 
1.7.0.4

___
ofono mailing list
ofono@ofono.org
http://lists.ofono.org/listinfo/ofono


[PATCH 2/7] atmodem: M16 coding style fix

2011-02-05 Thread Jeevaka Badrappan
---
 drivers/atmodem/voicecall.c |8 
 1 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/atmodem/voicecall.c b/drivers/atmodem/voicecall.c
index 56fd858..ee055da 100644
--- a/drivers/atmodem/voicecall.c
+++ b/drivers/atmodem/voicecall.c
@@ -168,7 +168,7 @@ static void clcc_poll_cb(gboolean ok, GAtResult *result, 
gpointer user_data)
if (oc  (nc == NULL || (nc-id  oc-id))) {
enum ofono_disconnect_reason reason;
 
-   if (vd-local_release  (0x1  oc-id))
+   if (vd-local_release  (1  oc-id))
reason = OFONO_DISCONNECT_REASON_LOCAL_HANGUP;
else
reason = OFONO_DISCONNECT_REASON_REMOTE_HANGUP;
@@ -271,8 +271,8 @@ static void generic_cb(gboolean ok, GAtResult *result, 
gpointer user_data)
for (l = vd-calls; l; l = l-next) {
call = l-data;
 
-   if (req-affected_types  (0x1  call-status))
-   vd-local_release |= (0x1  call-id);
+   if (req-affected_types  (1  call-status))
+   vd-local_release |= (1  call-id);
}
}
 
@@ -293,7 +293,7 @@ static void release_id_cb(gboolean ok, GAtResult *result,
decode_at_error(error, g_at_result_final_response(result));
 
if (ok)
-   vd-local_release = 0x1  req-id;
+   vd-local_release = 1  req-id;
 
g_at_chat_send(vd-chat, AT+CLCC, clcc_prefix,
clcc_poll_cb, req-vc, NULL);
-- 
1.7.0.4

___
ofono mailing list
ofono@ofono.org
http://lists.ofono.org/listinfo/ofono


[PATCH 3/7] hfpmodem: M16 coding style fix

2011-02-05 Thread Jeevaka Badrappan
---
 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 f247bea..e5121f4 100644
--- a/drivers/hfpmodem/voicecall.c
+++ b/drivers/hfpmodem/voicecall.c
@@ -229,7 +229,7 @@ static void clcc_poll_cb(gboolean ok, GAtResult *result, 
gpointer user_data)
if (oc  (nc == NULL || (nc-id  oc-id))) {
enum ofono_disconnect_reason reason;
 
-   if (vd-local_release  (0x1  oc-id))
+   if (vd-local_release  (1  oc-id))
reason = OFONO_DISCONNECT_REASON_LOCAL_HANGUP;
else
reason = OFONO_DISCONNECT_REASON_REMOTE_HANGUP;
-- 
1.7.0.4

___
ofono mailing list
ofono@ofono.org
http://lists.ofono.org/listinfo/ofono


[PATCH 4/7] ifxmodem: M16 coding style fix

2011-02-05 Thread Jeevaka Badrappan
---
 drivers/ifxmodem/voicecall.c |   10 +-
 1 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/drivers/ifxmodem/voicecall.c b/drivers/ifxmodem/voicecall.c
index 5ff3bcc..f66815a 100644
--- a/drivers/ifxmodem/voicecall.c
+++ b/drivers/ifxmodem/voicecall.c
@@ -160,7 +160,7 @@ static void xcallstat_notify(GAtResult *result, gpointer 
user_data)
if (status == CALL_STATUS_DISCONNECTED) {
enum ofono_disconnect_reason r;
 
-   if (vd-local_release  (0x1  call-id))
+   if (vd-local_release  (1  call-id))
r = OFONO_DISCONNECT_REASON_LOCAL_HANGUP;
else
r = OFONO_DISCONNECT_REASON_REMOTE_HANGUP;
@@ -168,7 +168,7 @@ static void xcallstat_notify(GAtResult *result, gpointer 
user_data)
if (call-type == 0)
ofono_voicecall_disconnected(vc, call-id, r, NULL);
 
-   vd-local_release = ~(0x1  call-id);
+   vd-local_release = ~(1  call-id);
vd-calls = g_slist_remove(vd-calls, call);
g_free(call);
 
@@ -227,8 +227,8 @@ static void generic_cb(gboolean ok, GAtResult *result, 
gpointer user_data)
for (l = vd-calls; l; l = l-next) {
call = l-data;
 
-   if (req-affected_types  (0x1  call-status))
-   vd-local_release |= (0x1  call-id);
+   if (req-affected_types  (1  call-status))
+   vd-local_release |= (1  call-id);
}
}
 
@@ -245,7 +245,7 @@ static void release_id_cb(gboolean ok, GAtResult *result,
decode_at_error(error, g_at_result_final_response(result));
 
if (ok)
-   vd-local_release |= 0x1  req-id;
+   vd-local_release |= 1  req-id;
 
req-cb(error, req-data);
 }
-- 
1.7.0.4

___
ofono mailing list
ofono@ofono.org
http://lists.ofono.org/listinfo/ofono


[PATCH 5/7] stemodem: M16 coding style fix

2011-02-05 Thread Jeevaka Badrappan
---
 drivers/stemodem/voicecall.c |8 
 1 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/stemodem/voicecall.c b/drivers/stemodem/voicecall.c
index b8fcf5b..ca275cd 100644
--- a/drivers/stemodem/voicecall.c
+++ b/drivers/stemodem/voicecall.c
@@ -148,8 +148,8 @@ static void ste_generic_cb(gboolean ok, GAtResult *result, 
gpointer user_data)
for (l = vd-calls; l; l = l-next) {
call = l-data;
 
-   if (req-affected_types  (0x1  call-status))
-   vd-local_release |= (0x1  call-id);
+   if (req-affected_types  (1  call-status))
+   vd-local_release |= (1  call-id);
}
}
 
@@ -166,7 +166,7 @@ static void release_id_cb(gboolean ok, GAtResult *result,
decode_at_error(error, g_at_result_final_response(result));
 
if (ok)
-   vd-local_release = 0x1  req-id;
+   vd-local_release = 1  req-id;
 
req-cb(error, req-data);
 }
@@ -481,7 +481,7 @@ static void ecav_notify(GAtResult *result, gpointer 
user_data)
 
existing_call-status = status;
 
-   if (vd-local_release  (0x1  existing_call-id))
+   if (vd-local_release  (1  existing_call-id))
reason = OFONO_DISCONNECT_REASON_LOCAL_HANGUP;
else
reason = OFONO_DISCONNECT_REASON_REMOTE_HANGUP;
-- 
1.7.0.4

___
ofono mailing list
ofono@ofono.org
http://lists.ofono.org/listinfo/ofono


[PATCH 6/7] modem: M16 coding style fix

2011-02-05 Thread Jeevaka Badrappan
---
 src/modem.c |6 +++---
 1 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/src/modem.c b/src/modem.c
index 8e243d8..6cb8fab 100644
--- a/src/modem.c
+++ b/src/modem.c
@@ -121,7 +121,7 @@ unsigned int __ofono_modem_callid_next(struct ofono_modem 
*modem)
unsigned int i;
 
for (i = 1; i  sizeof(modem-call_ids) * 8; i++) {
-   if (modem-call_ids  (0x1  i))
+   if (modem-call_ids  (1  i))
continue;
 
return i;
@@ -132,12 +132,12 @@ unsigned int __ofono_modem_callid_next(struct ofono_modem 
*modem)
 
 void __ofono_modem_callid_hold(struct ofono_modem *modem, int id)
 {
-   modem-call_ids |= (0x1  id);
+   modem-call_ids |= (1  id);
 }
 
 void __ofono_modem_callid_release(struct ofono_modem *modem, int id)
 {
-   modem-call_ids = ~(0x1  id);
+   modem-call_ids = ~(1  id);
 }
 
 void ofono_modem_set_data(struct ofono_modem *modem, void *data)
-- 
1.7.0.4

___
ofono mailing list
ofono@ofono.org
http://lists.ofono.org/listinfo/ofono


[PATCH] ifxmodem: refactor call status notifications

2011-02-05 Thread Jeevaka Badrappan
---
 drivers/ifxmodem/voicecall.c |  197 +++---
 1 files changed, 90 insertions(+), 107 deletions(-)

diff --git a/drivers/ifxmodem/voicecall.c b/drivers/ifxmodem/voicecall.c
index f66815a..c6e3878 100644
--- a/drivers/ifxmodem/voicecall.c
+++ b/drivers/ifxmodem/voicecall.c
@@ -120,7 +120,8 @@ static void xcallstat_notify(GAtResult *result, gpointer 
user_data)
int id;
int status;
GSList *l;
-   struct ofono_call *call;
+   struct ofono_call *new_call;
+   struct ofono_call *existing_call = NULL;
 
g_at_result_iter_init(iter, result);
 
@@ -136,53 +137,70 @@ static void xcallstat_notify(GAtResult *result, gpointer 
user_data)
l = g_slist_find_custom(vd-calls, GINT_TO_POINTER(id),
at_util_call_compare_by_id);
 
-   if (l == NULL) {
-   /*
-* We should only receive XCALLSTAT on waiting and incoming
-* In the case of waiting, we will get the rest of the info
-* from CCWA indication.
-* In the case of incoming, we will get the info from CLIP
-* indications.
-*/
-   if (status != CALL_STATUS_INCOMING 
-   status != CALL_STATUS_WAITING) {
-   ofono_info(Received an XCALLSTAT for an untracked
-call, this indicates a bug!);
-   return;
-   }
-
+   if (l == NULL  status != CALL_STATUS_INCOMING 
+   status != CALL_STATUS_WAITING) {
+   ofono_error(Received an XCALLSTAT for an untracked
+call, this indicates a bug!);
return;
}
 
-   call = l-data;
+   if (l)
+   existing_call = l-data;
 
-   /* Check if call has been disconnected */
-   if (status == CALL_STATUS_DISCONNECTED) {
-   enum ofono_disconnect_reason r;
+   switch (status) {
+   case CALL_STATUS_DISCONNECTED:
+   {
+   enum ofono_disconnect_reason reason;
 
-   if (vd-local_release  (1  call-id))
-   r = OFONO_DISCONNECT_REASON_LOCAL_HANGUP;
-   else
-   r = OFONO_DISCONNECT_REASON_REMOTE_HANGUP;
+   existing_call-status = status;
 
-   if (call-type == 0)
-   ofono_voicecall_disconnected(vc, call-id, r, NULL);
+   if (vd-local_release  (1  existing_call-id))
+   reason = OFONO_DISCONNECT_REASON_LOCAL_HANGUP;
+   else
+   reason = OFONO_DISCONNECT_REASON_REMOTE_HANGUP;
 
-   vd-local_release = ~(1  call-id);
-   vd-calls = g_slist_remove(vd-calls, call);
-   g_free(call);
+   ofono_voicecall_disconnected(vc, existing_call-id,
+   reason, NULL);
 
-   return;
+   vd-local_release = ~(1  existing_call-id);
+   vd-calls = g_slist_remove(vd-calls, l-data);
+   g_free(existing_call);
+   break;
}
+   case CALL_STATUS_DIALING:
+   case CALL_STATUS_WAITING:
+   case CALL_STATUS_INCOMING:
+   {
+   int direction;
+
+   if (status == CALL_STATUS_DIALING)
+   direction = CALL_DIRECTION_MOBILE_ORIGINATED;
+   else
+   direction = CALL_DIRECTION_MOBILE_TERMINATED;
 
-   /* For connected status, simply reset back to active */
-   if (status == 7)
-   status = 0;
+   new_call = create_call(vc, 0, direction, status,
+   NULL, 128, CLIP_VALIDITY_NOT_AVAILABLE);
+   if (new_call == NULL) {
+   ofono_error(Unable to malloc. 
+   Call management is fubar);
+   return;
+   }
 
-   call-status = status;
+   new_call-id = id;
+   break;
+   }
+   case CALL_STATUS_ALERTING:
+   case CALL_STATUS_ACTIVE:
+   case CALL_STATUS_HELD:
+   default:
+   /* For connected status, simply reset back to active */
+   if (status == 7)
+   status = 0;
 
-   if (call-type == 0)
-   ofono_voicecall_notify(vc, call);
+   existing_call-status = status;
+   ofono_voicecall_notify(vc, existing_call);
+   break;
+   }
 }
 
 static void xem_notify(GAtResult *result, gpointer user_data)
@@ -253,51 +271,12 @@ static void release_id_cb(gboolean ok, GAtResult *result,
 static void atd_cb(gboolean ok, GAtResult *result, gpointer user_data)
 {
struct cb_data *cbd = user_data;
-   struct ofono_voicecall *vc = cbd-user;
ofono_voicecall_cb_t 

[PATCH 0/5] Make use of defined call_status enum

2011-02-04 Thread Jeevaka Badrappan
Hi,

 Following set of patches makes use of the defined call_status enum
instead of using the actual defined values.

Regards,
Jeevaka

Jeevaka Badrappan (5):
  atmodem: use defined call_status enum
  hfpmodem: Use defined call_status enum
  huaweimodem: Use defined call_status enum
  ifxmodem: Use defined call_status enum
  stemodem: Use defined call_status enum

 drivers/atmodem/voicecall.c |   51 --
 drivers/hfpmodem/voicecall.c|   12 +
 drivers/huaweimodem/voicecall.c |   20 +--
 drivers/ifxmodem/voicecall.c|   33 -
 drivers/stemodem/voicecall.c|3 +-
 5 files changed, 74 insertions(+), 45 deletions(-)

___
ofono mailing list
ofono@ofono.org
http://lists.ofono.org/listinfo/ofono


[PATCH 1/5] atmodem: use defined call_status enum

2011-02-04 Thread Jeevaka Badrappan
---
 drivers/atmodem/voicecall.c |   51 +++
 1 files changed, 32 insertions(+), 19 deletions(-)

diff --git a/drivers/atmodem/voicecall.c b/drivers/atmodem/voicecall.c
index 583e037..42b44fa 100644
--- a/drivers/atmodem/voicecall.c
+++ b/drivers/atmodem/voicecall.c
@@ -161,7 +161,8 @@ static void clcc_poll_cb(gboolean ok, GAtResult *result, 
gpointer user_data)
nc = n ? n-data : NULL;
oc = o ? o-data : NULL;
 
-   if (nc  nc-status = 2  nc-status = 5)
+   if (nc  nc-status = CALL_STATUS_DIALING 
+   nc-status = CALL_STATUS_WAITING)
poll_again = TRUE;
 
if (oc  (nc == NULL || (nc-id  oc-id))) {
@@ -216,7 +217,8 @@ static void clcc_poll_cb(gboolean ok, GAtResult *result, 
gpointer user_data)
 * arrives, or RING is used, then signal the call
 * here
 */
-   if (nc-status == 4  (vd-flags  FLAG_NEED_CLIP)) {
+   if (nc-status == CALL_STATUS_INCOMING 
+   (vd-flags  FLAG_NEED_CLIP)) {
if (nc-type == 0)
ofono_voicecall_notify(vc, nc);
 
@@ -323,10 +325,10 @@ static void atd_cb(gboolean ok, GAtResult *result, 
gpointer user_data)
for (l = vd-calls; l; l = l-next) {
call = l-data;
 
-   if (call-status != 0)
+   if (call-status != CALL_STATUS_ACTIVE)
continue;
 
-   call-status = 1;
+   call-status = CALL_STATUS_HELD;
ofono_voicecall_notify(vc, call);
}
 
@@ -345,7 +347,7 @@ static void atd_cb(gboolean ok, GAtResult *result, gpointer 
user_data)
}
 
/* Generate a voice call that was just dialed, we guess the ID */
-   call = create_call(vc, 0, 0, 2, num, type, validity);
+   call = create_call(vc, 0, 0, CALL_STATUS_DIALING, num, type, validity);
if (call == NULL) {
ofono_error(Unable to malloc, call tracking will fail!);
return;
@@ -467,14 +469,16 @@ static void at_hold_all_active(struct ofono_voicecall *vc,
 static void at_release_all_held(struct ofono_voicecall *vc,
ofono_voicecall_cb_t cb, void *data)
 {
-   unsigned int held_status = 0x1  1;
+   unsigned int held_status = 0x1  CALL_STATUS_HELD;
at_template(AT+CHLD=0, vc, generic_cb, held_status, cb, data);
 }
 
 static void at_set_udub(struct ofono_voicecall *vc,
ofono_voicecall_cb_t cb, void *data)
 {
-   unsigned int incoming_or_waiting = (0x1  4) | (0x1  5);
+   unsigned int incoming_or_waiting =
+   (0x1  CALL_STATUS_INCOMING) | (0x1  CALL_STATUS_WAITING);
+
at_template(AT+CHLD=0, vc, generic_cb, incoming_or_waiting,
cb, data);
 }
@@ -547,7 +551,8 @@ static void at_deflect(struct ofono_voicecall *vc,
ofono_voicecall_cb_t cb, void *data)
 {
char buf[128];
-   unsigned int incoming_or_waiting = (0x1  4) | (0x1  5);
+   unsigned int incoming_or_waiting =
+   (0x1  CALL_STATUS_INCOMING) | (0x1  CALL_STATUS_WAITING);
 
snprintf(buf, sizeof(buf), AT+CTFR=%s,%d, ph-number, ph-type);
at_template(buf, vc, generic_cb, incoming_or_waiting, cb, data);
@@ -631,17 +636,19 @@ static void ring_notify(GAtResult *result, gpointer 
user_data)
struct ofono_call *call;
 
/* See comment in CRING */
-   if (g_slist_find_custom(vd-calls, GINT_TO_POINTER(5),
+   if (g_slist_find_custom(vd-calls,
+   GINT_TO_POINTER(CALL_STATUS_WAITING),
at_util_call_compare_by_status))
return;
 
/* RING can repeat, ignore if we already have an incoming call */
-   if (g_slist_find_custom(vd-calls, GINT_TO_POINTER(4),
+   if (g_slist_find_custom(vd-calls,
+   GINT_TO_POINTER(CALL_STATUS_INCOMING),
at_util_call_compare_by_status))
return;
 
/* Generate an incoming call of unknown type */
-   call = create_call(vc, 9, 1, 4, NULL, 128, 2);
+   call = create_call(vc, 9, 1, CALL_STATUS_INCOMING, NULL, 128, 2);
if (call == NULL) {
ofono_error(Couldn't create call, call management is fubar!);
return;
@@ -667,12 +674,14 @@ static void cring_notify(GAtResult *result, gpointer 
user_data)
 * the stage change.  If this happens, simply ignore the RING/CRING
 * when a waiting call exists (cannot have waiting + incoming in GSM)
 */
-   if (g_slist_find_custom(vd-calls, GINT_TO_POINTER(5),
+   if (g_slist_find_custom(vd-calls,
+   

  1   2   3   4   >