Re: [RFC PATCH 3/5] voicecall: implement SSN handling functions

2011-03-14 Thread Andras Domokos

Hi Denis,

On 03/11/2011 09:54 PM, ext Denis Kenzior wrote:

Hi Andras,


+static struct voicecall *voicecall_select(struct ofono_voicecall *vc,
+   unsigned int id, int code)
+{
+   struct voicecall *v = NULL;
+   GSList *l;
+
+   if (id != 0) {
+   l = g_slist_find_custom(vc-call_list, GUINT_TO_POINTER(id),
+   call_compare_by_id);
+
+   if (l == NULL)
+   return NULL;
+
+   v = l-data;
+   } else if (g_slist_length(vc-call_list) == 1) {
+   v = vc-call_list-data;
+
+   switch (code) {
+   case SS_MT_VOICECALL_RETRIEVED:
+   if (v-remote_held != TRUE)
+   return NULL;
+   break;
+   case SS_MT_VOICECALL_ON_HOLD:
+   if (v-remote_held == TRUE)
+   return NULL;
+   break;
+   case SS_MT_MULTIPARTY_VOICECALL:
+   if (v-remote_multiparty == TRUE)
+   return NULL;
+   break;
+   default:
+   return NULL;
+   }

I was mostly fine with this patch, but didn't see the real need in these
checks, so I re-factored the patch slightly afterward.  Let me know if I
broke something.



I am fine with your simplified version, I was a bit overly cautious
with those checks. Thanks!


+   }
+
+   return v;
+}
+

Regards,
-Denis


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


Re: [RFC PATCH 1/3] ssn: remove SSN atom completely

2011-03-04 Thread Andras Domokos

Hi Denis,

On 03/03/2011 09:51 PM, ext Denis Kenzior wrote:

Hi Andras,

On 03/03/2011 10:48 AM, Andras Domokos wrote:

---
  Makefile.am |6 +-
  drivers/atmodem/atmodem.c   |2 -
  drivers/atmodem/atmodem.h   |3 -
  drivers/atmodem/ssn.c   |  147 -
  drivers/isimodem/isimodem.c |2 -
  drivers/isimodem/isimodem.h |3 -
  drivers/isimodem/ssn.c  |   95 -
  include/ssn.h   |   61 ---
  plugins/calypso.c   |2 -
  plugins/g1.c|2 -
  plugins/huawei.c|2 -
  plugins/ifx.c   |2 -
  plugins/isiusb.c|2 -
  plugins/linktop.c   |2 -
  plugins/n900.c  |2 -
  plugins/phonesim.c  |2 -
  plugins/ste.c   |2 -
  plugins/tc65.c  |2 -
  plugins/u8500.c |2 -
  plugins/wavecom.c   |2 -
  src/ofono.h |   17 ---
  src/ssn.c   |  247 ---
  22 files changed, 2 insertions(+), 605 deletions(-)
  delete mode 100644 drivers/atmodem/ssn.c
  delete mode 100644 drivers/isimodem/ssn.c
  delete mode 100644 include/ssn.h
  delete mode 100644 src/ssn.c


Patch looks good but no longer applies due to changes that Aki pushed
recently.


I will correct the problem.


Regards,
-Denis


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


Re: [RFC PATCH 2/3] voicecall: add SSN handling functions

2011-03-04 Thread Andras Domokos

Hi Denis,

On 03/03/2011 10:03 PM, ext Denis Kenzior wrote:

Hi Andras,

On 03/03/2011 10:48 AM, Andras Domokos wrote:

---
  include/types.h |2 +
  include/voicecall.h |6 ++
  src/voicecall.c |  156 +++
  3 files changed, 164 insertions(+), 0 deletions(-)


Please make sure to split this patch into several in accordance to our
patch submission guidelines.  See HACKING document, specifically the
'Submitting Patches' section.


OK, I'll split up the patch according to the HACKING principles.


diff --git a/include/types.h b/include/types.h
index d25f409..b639c8a 100644
--- a/include/types.h
+++ b/include/types.h
@@ -96,6 +96,8 @@ struct ofono_call {
char name[OFONO_MAX_CALLER_NAME_LENGTH + 1];
int clip_validity;
int cnap_validity;
+   ofono_bool_t remote_held;
+   ofono_bool_t remote_multiparty;

I really don't like these being here.  Lets put them onto the struct
voicecall object in src/voicecall.c.  The logic for setting remote_held
and remote_multiparty is something that belongs in the core and should
not be exposed to the driver.


You are right, this informations have little to do with the drivers,
makes more sense to have them in the voicecall struct.


  };

  struct ofono_network_time {
diff --git a/include/voicecall.h b/include/voicecall.h
index f00eb08..5e6da02 100644
--- a/include/voicecall.h
+++ b/include/voicecall.h
@@ -160,6 +160,12 @@ void ofono_voicecall_set_data(struct ofono_voicecall *vc, 
void *data);
  void *ofono_voicecall_get_data(struct ofono_voicecall *vc);
  int ofono_voicecall_get_next_callid(struct ofono_voicecall *vc);

+void ofono_voicecall_ssn_mo_notify(struct ofono_voicecall *vc, unsigned int id,
+   int code, int index);
+void ofono_voicecall_ssn_mt_notify(struct ofono_voicecall *vc, unsigned int id,
+   int code, int index,
+   const struct ofono_phone_number *ph);
+

Looks good, but as I mentioned this should be a separate patch.



I'll create a separate patch for each top level directory.


  #ifdef __cplusplus
  }
  #endif
diff --git a/src/voicecall.c b/src/voicecall.c
index ec001c0..e5936f5 100644
--- a/src/voicecall.c
+++ b/src/voicecall.c
@@ -400,6 +400,12 @@ static void append_voicecall_properties(struct voicecall 
*v,

ofono_dbus_dict_append(dict, Multiparty, DBUS_TYPE_BOOLEAN,mpty);

+   ofono_dbus_dict_append(dict, RemoteHeld, DBUS_TYPE_BOOLEAN,
+   call-remote_held);
+
+   ofono_dbus_dict_append(dict, RemoteMultiparty, DBUS_TYPE_BOOLEAN,
+   call-remote_multiparty);
+
if (v-message)
ofono_dbus_dict_append(dict, Information,
DBUS_TYPE_STRING,v-message);
@@ -1869,6 +1875,8 @@ static GDBusMethodTable manager_methods[] = {
  };

  static GDBusSignalTable manager_signals[] = {
+   { Forwarded, s },
+   { BarringActive, s },
{ PropertyChanged,  sv },
{ CallAdded,oa{sv} },
{ CallRemoved,  o },
@@ -2684,3 +2692,151 @@ void __ofono_voicecall_tone_cancel(struct 
ofono_voicecall *vc, int id)
tone_request_run(vc);
}
  }
+
+static void ssn_mt_forwarded_notify(struct ofono_voicecall *vc,
+   unsigned int id, int code,
+   const struct ofono_phone_number *ph)
+{
+   DBusConnection *conn = ofono_dbus_get_connection();
+   const char *path = __ofono_atom_get_path(vc-atom);
+   char *info = incoming;
+
+   g_dbus_emit_signal(conn, path, OFONO_VOICECALL_MANAGER_INTERFACE,
+   Forwarded,
+   DBUS_TYPE_STRING,info,
+   DBUS_TYPE_INVALID);
+}
+
+static struct voicecall *voicecall_select(struct ofono_voicecall *vc,
+   unsigned int id, int code)
+{
+   struct voicecall *v = NULL;
+   GSList *l;
+
+   for (l = vc-call_list; l; l = l-next) {
+   struct voicecall *v1 = l-data;
+
+   if (id == 0  g_slist_length(vc-call_list) == 1) {
+   if (code == SS_MT_VOICECALL_RETRIEVED
+   v1-call-remote_held == TRUE) {
+   v = v1;
+   break;
+   } else if (code == SS_MT_VOICECALL_ON_HOLD
+   v1-call-remote_held == FALSE) {
+   v = v1;
+   break;
+   } else if (code == SS_MT_MULTIPARTY_VOICECALL
+   v1-call-remote_multiparty == FALSE) {
+   v = v1;
+   break

[PATCH 0/5] Voice call SS notifications (4th version)

2011-03-04 Thread Andras Domokos
Implementation proposal for handling some of the voice call
related Supplementary Services (SS) notifications.

Implementation details:
- removed SSN atom and all the dependencies
- (re)implemented voice call SS notification handling framework
- added voice call SS notification handling to AT modem driver
  (+CSSU and +CSSI notifications) 
- added voice call SS notification handling to ISI modem driver

Andras Domokos (5):
  ssn: remove SSN atom completely
  voicecall: add SSN function declarations
  voicecall: implement SSN handling functions
  atmodem: implement SSN handling
  isimodem: implement SSN handling

 Makefile.am  |6 +-
 drivers/atmodem/atmodem.c|2 -
 drivers/atmodem/atmodem.h|3 -
 drivers/atmodem/ssn.c|  147 
 drivers/atmodem/voicecall.c  |   61 +
 drivers/isimodem/isimodem.c  |2 -
 drivers/isimodem/isimodem.h  |3 -
 drivers/isimodem/ssn.c   |  503 --
 drivers/isimodem/voicecall.c |  359 ++
 include/ssn.h|   61 -
 include/voicecall.h  |6 +
 plugins/calypso.c|2 -
 plugins/g1.c |2 -
 plugins/huawei.c |2 -
 plugins/ifx.c|2 -
 plugins/isiusb.c |2 -
 plugins/linktop.c|2 -
 plugins/n900.c   |2 -
 plugins/phonesim.c   |2 -
 plugins/ste.c|2 -
 plugins/tc65.c   |2 -
 plugins/u8500.c  |2 -
 plugins/wavecom.c|2 -
 src/ofono.h  |   17 --
 src/ssn.c|  247 -
 src/voicecall.c  |  174 +++
 26 files changed, 602 insertions(+), 1013 deletions(-)
 delete mode 100644 drivers/atmodem/ssn.c
 delete mode 100644 drivers/isimodem/ssn.c
 delete mode 100644 include/ssn.h
 delete mode 100644 src/ssn.c

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


[RFC PATCH 2/5] voicecall: add SSN function declarations

2011-03-04 Thread Andras Domokos
---
 include/voicecall.h |6 ++
 1 files changed, 6 insertions(+), 0 deletions(-)

diff --git a/include/voicecall.h b/include/voicecall.h
index f00eb08..5e6da02 100644
--- a/include/voicecall.h
+++ b/include/voicecall.h
@@ -160,6 +160,12 @@ void ofono_voicecall_set_data(struct ofono_voicecall *vc, 
void *data);
 void *ofono_voicecall_get_data(struct ofono_voicecall *vc);
 int ofono_voicecall_get_next_callid(struct ofono_voicecall *vc);
 
+void ofono_voicecall_ssn_mo_notify(struct ofono_voicecall *vc, unsigned int id,
+   int code, int index);
+void ofono_voicecall_ssn_mt_notify(struct ofono_voicecall *vc, unsigned int id,
+   int code, int index,
+   const struct ofono_phone_number *ph);
+
 #ifdef __cplusplus
 }
 #endif
-- 
1.7.0.4

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


[RFC PATCH 4/5] atmodem: implement SSN handling

2011-03-04 Thread Andras Domokos
---
 drivers/atmodem/voicecall.c |   61 +++
 1 files changed, 61 insertions(+), 0 deletions(-)

diff --git a/drivers/atmodem/voicecall.c b/drivers/atmodem/voicecall.c
index ee055da..7d70c85 100644
--- a/drivers/atmodem/voicecall.c
+++ b/drivers/atmodem/voicecall.c
@@ -967,6 +967,63 @@ static void busy_notify(GAtResult *result, gpointer 
user_data)
clcc_poll_cb, vc, NULL);
 }
 
+static void cssi_notify(GAtResult *result, gpointer user_data)
+{
+   struct ofono_voicecall *vc = user_data;
+   GAtResultIter iter;
+   int code, index;
+
+   g_at_result_iter_init(iter, result);
+
+   if (!g_at_result_iter_next(iter, +CSSI:))
+   return;
+
+   if (!g_at_result_iter_next_number(iter, code))
+   return;
+
+   if (!g_at_result_iter_next_number(iter, index))
+   index = 0;
+
+   ofono_voicecall_ssn_mo_notify(vc, 0, code, index);
+}
+
+static void cssu_notify(GAtResult *result, gpointer user_data)
+{
+   struct ofono_voicecall *vc = user_data;
+   GAtResultIter iter;
+   int code;
+   int index = -1;
+   const char *num;
+   struct ofono_phone_number ph;
+
+   ph.number[0] = '\0';
+   ph.type = 129;
+
+   g_at_result_iter_init(iter, result);
+
+   if (!g_at_result_iter_next(iter, +CSSU:))
+   return;
+
+   if (!g_at_result_iter_next_number(iter, code))
+   return;
+
+   /* This field is optional, if we can't read it, try to skip it */
+   if (!g_at_result_iter_next_number(iter, index) 
+   !g_at_result_iter_skip_next(iter))
+   goto out;
+
+   if (!g_at_result_iter_next_string(iter, num))
+   goto out;
+
+   strncpy(ph.number, num, OFONO_MAX_PHONE_NUMBER_LENGTH);
+
+   if (!g_at_result_iter_next_number(iter, ph.type))
+   return;
+
+out:
+   ofono_voicecall_ssn_mt_notify(vc, 0, code, index, ph);
+}
+
 static void vtd_query_cb(gboolean ok, GAtResult *result, gpointer user_data)
 {
struct ofono_voicecall *vc = user_data;
@@ -1015,6 +1072,9 @@ static void at_voicecall_initialized(gboolean ok, 
GAtResult *result,
 
/* Populate the call list */
g_at_chat_send(vd-chat, AT+CLCC, clcc_prefix, clcc_cb, vc, NULL);
+
+   g_at_chat_register(vd-chat, +CSSI:, cssi_notify, FALSE, vc, NULL);
+   g_at_chat_register(vd-chat, +CSSU:, cssu_notify, FALSE, vc, NULL);
 }
 
 static int at_voicecall_probe(struct ofono_voicecall *vc, unsigned int vendor,
@@ -1038,6 +1098,7 @@ static int at_voicecall_probe(struct ofono_voicecall *vc, 
unsigned int vendor,
g_at_chat_send(vd-chat, AT+CDIP=1, NULL, NULL, NULL, NULL);
g_at_chat_send(vd-chat, AT+CNAP=1, NULL, NULL, NULL, NULL);
g_at_chat_send(vd-chat, AT+COLP=1, NULL, NULL, NULL, NULL);
+   g_at_chat_send(vd-chat, AT+CSSN=1,1, NULL, NULL, NULL, NULL);
g_at_chat_send(vd-chat, AT+VTD?, NULL,
vtd_query_cb, vc, NULL);
g_at_chat_send(vd-chat, AT+CCWA=1, NULL,
-- 
1.7.0.4

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


[RFC PATCH 5/5] isimodem: implement SSN handling

2011-03-04 Thread Andras Domokos
---
 drivers/isimodem/voicecall.c |  359 ++
 1 files changed, 359 insertions(+), 0 deletions(-)

diff --git a/drivers/isimodem/voicecall.c b/drivers/isimodem/voicecall.c
index 9507255..165f3b4 100644
--- a/drivers/isimodem/voicecall.c
+++ b/drivers/isimodem/voicecall.c
@@ -739,6 +739,362 @@ static void isi_call_terminated_ind_cb(const GIsiMessage 
*msg, void *data)
isi_call_notify(ovc, call);
 }
 
+static gboolean decode_notify(GIsiSubBlockIter *iter)
+{
+   uint8_t byte;
+
+   if (!g_isi_sb_iter_get_byte(iter, byte, 2))
+   return FALSE;
+
+   switch (byte) {
+   case CALL_NOTIFY_USER_SUSPENDED:
+   DBG(CALL_NOTIFY_USER_SUSPENDED);
+   break;
+
+   case CALL_NOTIFY_USER_RESUMED:
+   DBG(CALL_NOTIFY_USER_RESUMED);
+   break;
+
+   case CALL_NOTIFY_BEARER_CHANGE:
+   DBG(CALL_NOTIFY_BEARER_CHANGE);
+   break;
+
+   default:
+   DBG(Unknown notification: 0x%02X, byte);
+   }
+
+   return TRUE;
+}
+
+static gboolean decode_ss_code(GIsiSubBlockIter *iter, int *cssi, int *cssu)
+{
+   uint16_t word;
+
+   if (!g_isi_sb_iter_get_word(iter, word, 2))
+   return FALSE;
+
+   switch (word) {
+   case CALL_SSC_ALL_FWDS:
+   DBG(Call forwarding is active);
+   break;
+
+   case CALL_SSC_ALL_COND_FWD:
+   *cssi = SS_MO_CONDITIONAL_FORWARDING;
+   DBG(Some of conditional call forwardings active);
+   break;
+
+   case CALL_SSC_CFU:
+   *cssi = SS_MO_UNCONDITIONAL_FORWARDING;
+   DBG(Unconditional call forwarding is active);
+   break;
+
+   case CALL_SSC_OUTGOING_BARR_SERV:
+   *cssi = SS_MO_OUTGOING_BARRING;
+   DBG(Outgoing calls are barred);
+   break;
+
+   case CALL_SSC_INCOMING_BARR_SERV:
+   *cssi = SS_MO_INCOMING_BARRING;
+   DBG(Incoming calls are barred);
+   break;
+
+   case CALL_SSC_CALL_WAITING:
+   DBG(Incoming calls are barred);
+   break;
+
+   case CALL_SSC_CLIR:
+   DBG(CLIR connected unknown indication.);
+   break;
+
+   case CALL_SSC_MPTY:
+   *cssu = SS_MT_MULTIPARTY_VOICECALL;
+   DBG(Multiparty call entered.);
+   break;
+
+   case CALL_SSC_CALL_HOLD:
+   *cssu = SS_MT_VOICECALL_HOLD_RELEASED;
+   DBG(Call on hold has been released.);
+   break;
+
+   default:
+   DBG(Unknown/unhandled notification: 0x%02X, word);
+   break;
+   }
+
+   return TRUE;
+}
+
+static gboolean decode_ss_status(GIsiSubBlockIter *iter)
+{
+   uint8_t byte;
+
+   if (!g_isi_sb_iter_get_byte(iter, byte, 2))
+   return FALSE;
+
+   if (byte  CALL_SS_STATUS_ACTIVE)
+   DBG(CALL_SS_STATUS_ACTIVE);
+
+   if (byte  CALL_SS_STATUS_REGISTERED)
+   DBG(CALL_SS_STATUS_REGISTERED);
+
+   if (byte  CALL_SS_STATUS_PROVISIONED)
+   DBG(CALL_SS_STATUS_PROVISIONED);
+
+   if (byte  CALL_SS_STATUS_QUIESCENT)
+   DBG(CALL_SS_STATUS_QUIESCENT);
+
+   return TRUE;
+}
+
+static gboolean decode_ss_notify(GIsiSubBlockIter *iter, int *cssi, int *cssu)
+{
+   uint8_t byte;
+
+   if (!g_isi_sb_iter_get_byte(iter, byte, 2))
+   return FALSE;
+
+   if (byte  CALL_SSN_INCOMING_IS_FWD) {
+   *cssu = SS_MT_CALL_FORWARDED;
+   DBG(This is a forwarded call #1.);
+   }
+
+   if (byte  CALL_SSN_INCOMING_FWD)
+   DBG(This is a forwarded call #2.);
+
+   if (byte  CALL_SSN_OUTGOING_FWD) {
+   *cssi = SS_MO_CALL_FORWARDED;
+   DBG(Call has been forwarded.);
+   }
+
+   return TRUE;
+}
+
+static gboolean decode_ss_notify_indicator(GIsiSubBlockIter *iter, int *cssi)
+{
+   uint8_t byte;
+
+   if (!g_isi_sb_iter_get_byte(iter, byte, 2))
+   return FALSE;
+
+   if (byte  CALL_SSI_CALL_IS_WAITING) {
+   *cssi = SS_MO_CALL_WAITING;
+   DBG(Call is waiting.);
+   }
+
+   if (byte  CALL_SSI_MPTY)
+   DBG(Multiparty call);
+
+   if (byte  CALL_SSI_CLIR_SUPPR_REJ) {
+   *cssi = SS_MO_CLIR_SUPPRESSION_REJECTED;
+   DBG(CLIR suppression rejected);
+   }
+
+   return TRUE;
+}
+
+static gboolean decode_ss_hold_indicator(GIsiSubBlockIter *iter, int *cssu)
+{
+   uint8_t byte;
+
+   if (!g_isi_sb_iter_get_byte(iter, byte, 2))
+   return FALSE;
+
+   if (byte == CALL_HOLD_IND_RETRIEVED) {
+   *cssu = SS_MT_VOICECALL_RETRIEVED;
+   DBG(Call has been retrieved);
+   } else if (byte  CALL_HOLD_IND_ON_HOLD) {
+   *cssu = SS_MT_VOICECALL_ON_HOLD;
+   DBG(Call 

[PATCH 0/3] Voice call SS notifications (3rd version)

2011-03-03 Thread Andras Domokos
Implementation proposal for handling some of the voice call
related Supplementary Services (SS) notifications.

Implementation details:
- removed SSN atom
- (re)implemented voice call SS notification handling framework
- added voice call SS notification handling to AT modem driver
  (+CSSU and +CSSI notifications) 

Andras Domokos (3):
  ssn: remove SSN atom completely
  voicecall: add SSN handling functions
  atmodem: add SSN handling

 Makefile.am |6 +-
 drivers/atmodem/atmodem.c   |2 -
 drivers/atmodem/atmodem.h   |3 -
 drivers/atmodem/ssn.c   |  147 -
 drivers/atmodem/voicecall.c |   61 +++
 drivers/isimodem/isimodem.c |2 -
 drivers/isimodem/isimodem.h |3 -
 drivers/isimodem/ssn.c  |   95 -
 include/ssn.h   |   61 ---
 include/types.h |2 +
 include/voicecall.h |6 +
 plugins/calypso.c   |2 -
 plugins/g1.c|2 -
 plugins/huawei.c|2 -
 plugins/ifx.c   |2 -
 plugins/isiusb.c|2 -
 plugins/linktop.c   |2 -
 plugins/n900.c  |2 -
 plugins/phonesim.c  |2 -
 plugins/ste.c   |2 -
 plugins/tc65.c  |2 -
 plugins/u8500.c |2 -
 plugins/wavecom.c   |2 -
 src/ofono.h |   17 ---
 src/ssn.c   |  247 ---
 src/voicecall.c |  156 +++
 26 files changed, 227 insertions(+), 605 deletions(-)
 delete mode 100644 drivers/atmodem/ssn.c
 delete mode 100644 drivers/isimodem/ssn.c
 delete mode 100644 include/ssn.h
 delete mode 100644 src/ssn.c

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


[RFC PATCH 1/3] ssn: remove SSN atom completely

2011-03-03 Thread Andras Domokos
---
 Makefile.am |6 +-
 drivers/atmodem/atmodem.c   |2 -
 drivers/atmodem/atmodem.h   |3 -
 drivers/atmodem/ssn.c   |  147 -
 drivers/isimodem/isimodem.c |2 -
 drivers/isimodem/isimodem.h |3 -
 drivers/isimodem/ssn.c  |   95 -
 include/ssn.h   |   61 ---
 plugins/calypso.c   |2 -
 plugins/g1.c|2 -
 plugins/huawei.c|2 -
 plugins/ifx.c   |2 -
 plugins/isiusb.c|2 -
 plugins/linktop.c   |2 -
 plugins/n900.c  |2 -
 plugins/phonesim.c  |2 -
 plugins/ste.c   |2 -
 plugins/tc65.c  |2 -
 plugins/u8500.c |2 -
 plugins/wavecom.c   |2 -
 src/ofono.h |   17 ---
 src/ssn.c   |  247 ---
 22 files changed, 2 insertions(+), 605 deletions(-)
 delete mode 100644 drivers/atmodem/ssn.c
 delete mode 100644 drivers/isimodem/ssn.c
 delete mode 100644 include/ssn.h
 delete mode 100644 src/ssn.c

diff --git a/Makefile.am b/Makefile.am
index 3f20717..b607b0d 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -5,7 +5,7 @@ pkginclude_HEADERS = include/log.h include/plugin.h 
include/history.h \
include/dbus.h include/modem.h include/types.h \
include/call-barring.h include/call-forwarding.h \
include/call-meter.h include/call-settings.h \
-   include/phonebook.h include/ssn.h include/ussd.h \
+   include/phonebook.h include/ussd.h \
include/sms.h include/sim.h include/message-waiting.h \
include/netreg.h include/voicecall.h include/devinfo.h \
include/cbs.h include/call-volume.h \
@@ -126,7 +126,6 @@ builtin_sources += $(gisi_sources) \
drivers/isimodem/cbs.c \
drivers/isimodem/sim.c \
drivers/isimodem/sim.h \
-   drivers/isimodem/ssn.c \
drivers/isimodem/ussd.c \
drivers/isimodem/call-forwarding.c \
drivers/isimodem/call-settings.c \
@@ -172,7 +171,6 @@ builtin_sources += $(gatchat_sources) \
drivers/atmodem/voicecall.c \
drivers/atmodem/call-barring.c \
drivers/atmodem/phonebook.c \
-   drivers/atmodem/ssn.c \
drivers/atmodem/devinfo.c \
drivers/atmodem/call-volume.c \
drivers/atmodem/vendor.h \
@@ -372,7 +370,7 @@ src_ofonod_SOURCES = $(gdbus_sources) $(builtin_sources) 
src/ofono.ver \
src/network.c src/voicecall.c src/ussd.c src/sms.c \
src/call-settings.c src/call-forwarding.c \
src/call-meter.c src/smsutil.h src/smsutil.c \
-   src/ssn.c src/call-barring.c src/sim.c src/stk.c \
+   src/call-barring.c src/sim.c src/stk.c \
src/phonebook.c src/history.c src/message-waiting.c \
src/simutil.h src/simutil.c src/storage.h \
src/storage.c src/cbs.c src/watch.c src/call-volume.c \
diff --git a/drivers/atmodem/atmodem.c b/drivers/atmodem/atmodem.c
index e140281..ce6c10a 100644
--- a/drivers/atmodem/atmodem.c
+++ b/drivers/atmodem/atmodem.c
@@ -41,7 +41,6 @@ static int atmodem_init(void)
at_call_meter_init();
at_call_settings_init();
at_phonebook_init();
-   at_ssn_init();
at_ussd_init();
at_sms_init();
at_sim_init();
@@ -63,7 +62,6 @@ static void atmodem_exit(void)
at_sim_exit();
at_sms_exit();
at_ussd_exit();
-   at_ssn_exit();
at_phonebook_exit();
at_call_settings_exit();
at_call_meter_exit();
diff --git a/drivers/atmodem/atmodem.h b/drivers/atmodem/atmodem.h
index 1b7cf67..a6720d1 100644
--- a/drivers/atmodem/atmodem.h
+++ b/drivers/atmodem/atmodem.h
@@ -54,9 +54,6 @@ extern void at_sms_exit(void);
 extern void at_phonebook_init(void);
 extern void at_phonebook_exit(void);
 
-extern void at_ssn_init(void);
-extern void at_ssn_exit(void);
-
 extern void at_devinfo_init(void);
 extern void at_devinfo_exit(void);
 
diff --git a/drivers/atmodem/ssn.c b/drivers/atmodem/ssn.c
deleted file mode 100644
index b7a9df4..000
--- a/drivers/atmodem/ssn.c
+++ /dev/null
@@ -1,147 +0,0 @@
-/*
- *
- *  oFono - Open Source Telephony
- *
- *  Copyright (C) 2008-2010  Intel Corporation. All rights reserved.
- *
- *  This program is free software; you can redistribute it and/or modify
- *  it under the terms of 

[RFC PATCH 2/3] voicecall: add SSN handling functions

2011-03-03 Thread Andras Domokos
---
 include/types.h |2 +
 include/voicecall.h |6 ++
 src/voicecall.c |  156 +++
 3 files changed, 164 insertions(+), 0 deletions(-)

diff --git a/include/types.h b/include/types.h
index d25f409..b639c8a 100644
--- a/include/types.h
+++ b/include/types.h
@@ -96,6 +96,8 @@ struct ofono_call {
char name[OFONO_MAX_CALLER_NAME_LENGTH + 1];
int clip_validity;
int cnap_validity;
+   ofono_bool_t remote_held;
+   ofono_bool_t remote_multiparty;
 };
 
 struct ofono_network_time {
diff --git a/include/voicecall.h b/include/voicecall.h
index f00eb08..5e6da02 100644
--- a/include/voicecall.h
+++ b/include/voicecall.h
@@ -160,6 +160,12 @@ void ofono_voicecall_set_data(struct ofono_voicecall *vc, 
void *data);
 void *ofono_voicecall_get_data(struct ofono_voicecall *vc);
 int ofono_voicecall_get_next_callid(struct ofono_voicecall *vc);
 
+void ofono_voicecall_ssn_mo_notify(struct ofono_voicecall *vc, unsigned int id,
+   int code, int index);
+void ofono_voicecall_ssn_mt_notify(struct ofono_voicecall *vc, unsigned int id,
+   int code, int index,
+   const struct ofono_phone_number *ph);
+
 #ifdef __cplusplus
 }
 #endif
diff --git a/src/voicecall.c b/src/voicecall.c
index ec001c0..e5936f5 100644
--- a/src/voicecall.c
+++ b/src/voicecall.c
@@ -400,6 +400,12 @@ static void append_voicecall_properties(struct voicecall 
*v,
 
ofono_dbus_dict_append(dict, Multiparty, DBUS_TYPE_BOOLEAN, mpty);
 
+   ofono_dbus_dict_append(dict, RemoteHeld, DBUS_TYPE_BOOLEAN,
+   call-remote_held);
+
+   ofono_dbus_dict_append(dict, RemoteMultiparty, DBUS_TYPE_BOOLEAN,
+   call-remote_multiparty);
+
if (v-message)
ofono_dbus_dict_append(dict, Information,
DBUS_TYPE_STRING, v-message);
@@ -1869,6 +1875,8 @@ static GDBusMethodTable manager_methods[] = {
 };
 
 static GDBusSignalTable manager_signals[] = {
+   { Forwarded,   s },
+   { BarringActive,   s },
{ PropertyChanged,sv },
{ CallAdded,  oa{sv} },
{ CallRemoved,o },
@@ -2684,3 +2692,151 @@ void __ofono_voicecall_tone_cancel(struct 
ofono_voicecall *vc, int id)
tone_request_run(vc);
}
 }
+
+static void ssn_mt_forwarded_notify(struct ofono_voicecall *vc,
+   unsigned int id, int code,
+   const struct ofono_phone_number *ph)
+{
+   DBusConnection *conn = ofono_dbus_get_connection();
+   const char *path = __ofono_atom_get_path(vc-atom);
+   char *info = incoming;
+
+   g_dbus_emit_signal(conn, path, OFONO_VOICECALL_MANAGER_INTERFACE,
+   Forwarded,
+   DBUS_TYPE_STRING, info,
+   DBUS_TYPE_INVALID);
+}
+
+static struct voicecall *voicecall_select(struct ofono_voicecall *vc,
+   unsigned int id, int code)
+{
+   struct voicecall *v = NULL;
+   GSList *l;
+
+   for (l = vc-call_list; l; l = l-next) {
+   struct voicecall *v1 = l-data;
+
+   if (id == 0  g_slist_length(vc-call_list) == 1) {
+   if (code == SS_MT_VOICECALL_RETRIEVED 
+   v1-call-remote_held == TRUE) {
+   v = v1;
+   break;
+   } else if (code == SS_MT_VOICECALL_ON_HOLD 
+   v1-call-remote_held == FALSE) {
+   v = v1;
+   break;
+   } else if (code == SS_MT_MULTIPARTY_VOICECALL 
+   v1-call-remote_multiparty == FALSE) {
+   v = v1;
+   break;
+   }
+   } else if (v1-call-id == id) {
+   v = v1;
+   break;
+   }
+   }
+
+   return v;
+}
+
+static void ssn_mt_remote_held_notify(struct ofono_voicecall *vc,
+   unsigned int id, int code,
+   const struct ofono_phone_number *ph)
+{
+   struct voicecall *v = voicecall_select(vc, id, code);
+   DBusConnection *conn = ofono_dbus_get_connection();
+   const char *path;
+
+   if (v == NULL)
+   return;
+
+   if (code == SS_MT_VOICECALL_ON_HOLD)
+   v-call-remote_held = TRUE;
+   else
+   v-call-remote_held = FALSE;
+
+   path = voicecall_build_path(vc, v-call);
+
+   ofono_dbus_signal_property_changed(conn, path,
+   

[RFC PATCH 3/3] atmodem: add SSN handling

2011-03-03 Thread Andras Domokos
---
 drivers/atmodem/voicecall.c |   61 +++
 1 files changed, 61 insertions(+), 0 deletions(-)

diff --git a/drivers/atmodem/voicecall.c b/drivers/atmodem/voicecall.c
index ee055da..7d70c85 100644
--- a/drivers/atmodem/voicecall.c
+++ b/drivers/atmodem/voicecall.c
@@ -967,6 +967,63 @@ static void busy_notify(GAtResult *result, gpointer 
user_data)
clcc_poll_cb, vc, NULL);
 }
 
+static void cssi_notify(GAtResult *result, gpointer user_data)
+{
+   struct ofono_voicecall *vc = user_data;
+   GAtResultIter iter;
+   int code, index;
+
+   g_at_result_iter_init(iter, result);
+
+   if (!g_at_result_iter_next(iter, +CSSI:))
+   return;
+
+   if (!g_at_result_iter_next_number(iter, code))
+   return;
+
+   if (!g_at_result_iter_next_number(iter, index))
+   index = 0;
+
+   ofono_voicecall_ssn_mo_notify(vc, 0, code, index);
+}
+
+static void cssu_notify(GAtResult *result, gpointer user_data)
+{
+   struct ofono_voicecall *vc = user_data;
+   GAtResultIter iter;
+   int code;
+   int index = -1;
+   const char *num;
+   struct ofono_phone_number ph;
+
+   ph.number[0] = '\0';
+   ph.type = 129;
+
+   g_at_result_iter_init(iter, result);
+
+   if (!g_at_result_iter_next(iter, +CSSU:))
+   return;
+
+   if (!g_at_result_iter_next_number(iter, code))
+   return;
+
+   /* This field is optional, if we can't read it, try to skip it */
+   if (!g_at_result_iter_next_number(iter, index) 
+   !g_at_result_iter_skip_next(iter))
+   goto out;
+
+   if (!g_at_result_iter_next_string(iter, num))
+   goto out;
+
+   strncpy(ph.number, num, OFONO_MAX_PHONE_NUMBER_LENGTH);
+
+   if (!g_at_result_iter_next_number(iter, ph.type))
+   return;
+
+out:
+   ofono_voicecall_ssn_mt_notify(vc, 0, code, index, ph);
+}
+
 static void vtd_query_cb(gboolean ok, GAtResult *result, gpointer user_data)
 {
struct ofono_voicecall *vc = user_data;
@@ -1015,6 +1072,9 @@ static void at_voicecall_initialized(gboolean ok, 
GAtResult *result,
 
/* Populate the call list */
g_at_chat_send(vd-chat, AT+CLCC, clcc_prefix, clcc_cb, vc, NULL);
+
+   g_at_chat_register(vd-chat, +CSSI:, cssi_notify, FALSE, vc, NULL);
+   g_at_chat_register(vd-chat, +CSSU:, cssu_notify, FALSE, vc, NULL);
 }
 
 static int at_voicecall_probe(struct ofono_voicecall *vc, unsigned int vendor,
@@ -1038,6 +1098,7 @@ static int at_voicecall_probe(struct ofono_voicecall *vc, 
unsigned int vendor,
g_at_chat_send(vd-chat, AT+CDIP=1, NULL, NULL, NULL, NULL);
g_at_chat_send(vd-chat, AT+CNAP=1, NULL, NULL, NULL, NULL);
g_at_chat_send(vd-chat, AT+COLP=1, NULL, NULL, NULL, NULL);
+   g_at_chat_send(vd-chat, AT+CSSN=1,1, NULL, NULL, NULL, NULL);
g_at_chat_send(vd-chat, AT+VTD?, NULL,
vtd_query_cb, vc, NULL);
g_at_chat_send(vd-chat, AT+CCWA=1, NULL,
-- 
1.7.0.4

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


[PATCH 0/3] Voice call SS notifications (2nd version)

2011-02-28 Thread Andras Domokos
Implementation proposal for handling some of the voice call
related Supplementary Services (SS) notifications.

Implementation details:
- removed SSN atom
- expanded the SS notify functions with call number info, useful
  for modems capable of delivering it in the SS notifications
- expanded the SS callback functions with call number info and
  service code, useful in demultiplexing when a common callback
  function is defined for multiple service codes
- added +CSSU and +CSSI type SS notifications handling to the
  voicecall code

Andras Domokos (3):
  ssn: remove SSN atom
  ssn: add code and call id to notifications
  voicecall: add SSN notifications handling

 drivers/atmodem/ssn.c |6 +-
 include/ssn.h |   12 ++--
 include/types.h   |2 +
 plugins/calypso.c |1 -
 plugins/g1.c  |1 -
 plugins/huawei.c  |1 -
 plugins/ifx.c |1 -
 plugins/isiusb.c  |1 -
 plugins/linktop.c |1 -
 plugins/n900.c|1 -
 plugins/phonesim.c|1 -
 plugins/ste.c |1 -
 plugins/tc65.c|1 -
 plugins/u8500.c   |1 -
 plugins/wavecom.c |1 -
 src/ofono.h   |5 +-
 src/ssn.c |   66 +-
 src/voicecall.c   |  240 -
 18 files changed, 272 insertions(+), 71 deletions(-)

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


[RFC PATCH 1/3] ssn: remove SSN atom

2011-02-28 Thread Andras Domokos
---
 drivers/atmodem/ssn.c |6 +---
 include/ssn.h |9 +++
 plugins/calypso.c |1 -
 plugins/g1.c  |1 -
 plugins/huawei.c  |1 -
 plugins/ifx.c |1 -
 plugins/isiusb.c  |1 -
 plugins/linktop.c |1 -
 plugins/n900.c|1 -
 plugins/phonesim.c|1 -
 plugins/ste.c |1 -
 plugins/tc65.c|1 -
 plugins/u8500.c   |1 -
 plugins/wavecom.c |1 -
 src/ssn.c |   59 +++--
 15 files changed, 24 insertions(+), 62 deletions(-)

diff --git a/drivers/atmodem/ssn.c b/drivers/atmodem/ssn.c
index b7a9df4..c927bf1 100644
--- a/drivers/atmodem/ssn.c
+++ b/drivers/atmodem/ssn.c
@@ -56,7 +56,7 @@ static void cssi_notify(GAtResult *result, gpointer user_data)
if (!g_at_result_iter_next_number(iter, index))
index = 0;
 
-   ofono_ssn_cssi_notify(ssn, code1, index);
+   ofono_ssn_mo_notify(ssn, code1, index);
 }
 
 static void cssu_notify(GAtResult *result, gpointer user_data)
@@ -93,7 +93,7 @@ static void cssu_notify(GAtResult *result, gpointer user_data)
return;
 
 out:
-   ofono_ssn_cssu_notify(ssn, code2, index, ph);
+   ofono_ssn_mt_notify(ssn, code2, index, ph);
 }
 
 static void at_ssn_initialized(gboolean ok, GAtResult *result,
@@ -104,8 +104,6 @@ static void at_ssn_initialized(gboolean ok, GAtResult 
*result,
 
g_at_chat_register(chat, +CSSI:, cssi_notify, FALSE, ssn, NULL);
g_at_chat_register(chat, +CSSU:, cssu_notify, FALSE, ssn, NULL);
-
-   ofono_ssn_register(ssn);
 }
 
 static int at_ssn_probe(struct ofono_ssn *ssn, unsigned int vendor,
diff --git a/include/ssn.h b/include/ssn.h
index d640cad..c8f3e0b 100644
--- a/include/ssn.h
+++ b/include/ssn.h
@@ -37,19 +37,18 @@ struct ofono_ssn_driver {
 };
 
 /* SSN notifications (CSSI and CSSU).  */
-void ofono_ssn_cssi_notify(struct ofono_ssn *ssn, int code, int index);
-void ofono_ssn_cssu_notify(struct ofono_ssn *ssn, int code, int index,
+void ofono_ssn_mo_notify(struct ofono_ssn *ssn, int code, int index);
+void ofono_ssn_mt_notify(struct ofono_ssn *ssn, int code, int index,
const struct ofono_phone_number *number);
 
 int ofono_ssn_driver_register(const struct ofono_ssn_driver *d);
 void ofono_ssn_driver_unregister(const struct ofono_ssn_driver *d);
 
-struct ofono_ssn *ofono_ssn_create(struct ofono_modem *modem,
+struct ofono_ssn *ofono_ssn_new(struct ofono_modem *modem,
unsigned int vendor,
const char *driver, void *data);
 
-void ofono_ssn_register(struct ofono_ssn *ssn);
-void ofono_ssn_remove(struct ofono_ssn *ssn);
+void ofono_ssn_free(struct ofono_ssn *ssn);
 
 void ofono_ssn_set_data(struct ofono_ssn *ssn, void *data);
 void *ofono_ssn_get_data(struct ofono_ssn *ssn);
diff --git a/plugins/calypso.c b/plugins/calypso.c
index 0e29256..9c1b449 100644
--- a/plugins/calypso.c
+++ b/plugins/calypso.c
@@ -534,7 +534,6 @@ static void calypso_post_sim(struct ofono_modem *modem)
data-dlcs[NETREG_DLC]);
ofono_call_meter_create(modem, 0, atmodem, data-dlcs[AUX_DLC]);
ofono_call_barring_create(modem, 0, atmodem, data-dlcs[AUX_DLC]);
-   ofono_ssn_create(modem, 0, atmodem, data-dlcs[AUX_DLC]);
ofono_call_volume_create(modem, 0, atmodem, data-dlcs[AUX_DLC]);
 
mw = ofono_message_waiting_create(modem);
diff --git a/plugins/g1.c b/plugins/g1.c
index 22bacdc..bccde13 100644
--- a/plugins/g1.c
+++ b/plugins/g1.c
@@ -184,7 +184,6 @@ static void g1_post_sim(struct ofono_modem *modem)
ofono_netreg_create(modem, 0, atmodem, chat);
ofono_call_meter_create(modem, 0, atmodem, chat);
ofono_call_barring_create(modem, 0, atmodem, chat);
-   ofono_ssn_create(modem, 0, atmodem, chat);
ofono_sms_create(modem, OFONO_VENDOR_QUALCOMM_MSM, atmodem, chat);
ofono_phonebook_create(modem, 0, atmodem, chat);
 
diff --git a/plugins/huawei.c b/plugins/huawei.c
index 6f05677..5be5247 100644
--- a/plugins/huawei.c
+++ b/plugins/huawei.c
@@ -685,7 +685,6 @@ static void huawei_post_online(struct ofono_modem *modem)
ofono_call_forwarding_create(modem, 0, atmodem, data-pcui);
ofono_call_settings_create(modem, 0, atmodem, data-pcui);
ofono_call_barring_create(modem, 0, atmodem, data-pcui);
-   ofono_ssn_create(modem, 0, atmodem, data-pcui);
 
mw = ofono_message_waiting_create(modem);
if (mw)
diff --git a/plugins/ifx.c b/plugins/ifx.c
index 527a8c4..16a2326 100644
--- a/plugins/ifx.c
+++ b/plugins/ifx.c
@@ -717,7 +717,6 @@ static void ifx_post_online(struct ofono_modem *modem)
ofono_cbs_create(modem, 0, atmodem, data-dlcs[AUX_DLC]);
ofono_ussd_create(modem, 0, atmodem, data-dlcs[AUX_DLC]);
 
-   ofono_ssn_create(modem, 0, atmodem, 

[RFC PATCH 2/3] ssn: add code and call id to notifications

2011-02-28 Thread Andras Domokos
---
 drivers/atmodem/ssn.c |4 ++--
 include/ssn.h |7 ---
 src/ofono.h   |5 +++--
 src/ssn.c |   11 ++-
 4 files changed, 15 insertions(+), 12 deletions(-)

diff --git a/drivers/atmodem/ssn.c b/drivers/atmodem/ssn.c
index c927bf1..ba8f89a 100644
--- a/drivers/atmodem/ssn.c
+++ b/drivers/atmodem/ssn.c
@@ -56,7 +56,7 @@ static void cssi_notify(GAtResult *result, gpointer user_data)
if (!g_at_result_iter_next_number(iter, index))
index = 0;
 
-   ofono_ssn_mo_notify(ssn, code1, index);
+   ofono_ssn_mo_notify(ssn, 0, code1, index);
 }
 
 static void cssu_notify(GAtResult *result, gpointer user_data)
@@ -93,7 +93,7 @@ static void cssu_notify(GAtResult *result, gpointer user_data)
return;
 
 out:
-   ofono_ssn_mt_notify(ssn, code2, index, ph);
+   ofono_ssn_mt_notify(ssn, 0, code2, index, ph);
 }
 
 static void at_ssn_initialized(gboolean ok, GAtResult *result,
diff --git a/include/ssn.h b/include/ssn.h
index c8f3e0b..4f41bae 100644
--- a/include/ssn.h
+++ b/include/ssn.h
@@ -37,9 +37,10 @@ struct ofono_ssn_driver {
 };
 
 /* SSN notifications (CSSI and CSSU).  */
-void ofono_ssn_mo_notify(struct ofono_ssn *ssn, int code, int index);
-void ofono_ssn_mt_notify(struct ofono_ssn *ssn, int code, int index,
-   const struct ofono_phone_number *number);
+void ofono_ssn_mo_notify(struct ofono_ssn *ssn, unsigned int id,
+   int code1, int index);
+void ofono_ssn_mt_notify(struct ofono_ssn *ssn, unsigned int id, int code2,
+   int index, const struct ofono_phone_number *number);
 
 int ofono_ssn_driver_register(const struct ofono_ssn_driver *d);
 void ofono_ssn_driver_unregister(const struct ofono_ssn_driver *d);
diff --git a/src/ofono.h b/src/ofono.h
index 4e298f1..4af6f86 100644
--- a/src/ofono.h
+++ b/src/ofono.h
@@ -346,8 +346,9 @@ int __ofono_sms_sim_download(struct ofono_stk *stk, const 
struct sms *msg,
 
 #include ofono/ssn.h
 
-typedef void (*ofono_ssn_mo_notify_cb)(int index, void *user);
-typedef void (*ofono_ssn_mt_notify_cb)(int index,
+typedef void (*ofono_ssn_mo_notify_cb)(unsigned int id, int code1, int index,
+   void *user);
+typedef void (*ofono_ssn_mt_notify_cb)(unsigned int id, int code2, int index,
const struct ofono_phone_number *ph,
void *user);
 
diff --git a/src/ssn.c b/src/ssn.c
index ee48fba..383114c 100644
--- a/src/ssn.c
+++ b/src/ssn.c
@@ -111,7 +111,8 @@ gboolean __ofono_ssn_mt_watch_remove(struct ofono_ssn *ssn, 
unsigned int id)
return __ofono_watchlist_remove_item(ssn-mt_handler_list, id);
 }
 
-void ofono_ssn_mo_notify(struct ofono_ssn *ssn, int code1, int index)
+void ofono_ssn_mo_notify(struct ofono_ssn *ssn, unsigned int id,
+   int code1, int index)
 {
struct ssn_handler *h;
GSList *l;
@@ -122,12 +123,12 @@ void ofono_ssn_mo_notify(struct ofono_ssn *ssn, int 
code1, int index)
notify = h-item.notify;
 
if (h-code == code1)
-   notify(index, h-item.notify_data);
+   notify(id, code1, index, h-item.notify_data);
}
 }
 
-void ofono_ssn_mt_notify(struct ofono_ssn *ssn, int code2, int index,
-   const struct ofono_phone_number *ph)
+void ofono_ssn_mt_notify(struct ofono_ssn *ssn, unsigned int id, int code2,
+   int index, const struct ofono_phone_number *ph)
 {
struct ssn_handler *h;
GSList *l;
@@ -138,7 +139,7 @@ void ofono_ssn_mt_notify(struct ofono_ssn *ssn, int code2, 
int index,
notify = h-item.notify;
 
if (h-code == code2)
-   notify(index, ph, h-item.notify_data);
+   notify(id, code2, index, ph, h-item.notify_data);
}
 }
 
-- 
1.7.0.4

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


Re: [RFC PATCH 2/3] ssn: add code and call id to notifications

2011-02-24 Thread Andras Domokos

Hi Denis and Sankar,

The call SS notification handling patches hasn't been (fully) applied, I 
think we need to do something about it.


Regards,
Andras


On 02/22/2011 02:07 PM, ext Sankar wrote:

Hi Denis/Andras,

Is this patch applied and available in the GIT?

Regards,
Sankar.

On Thu, Feb 10, 2011 at 2:42 PM, Andras Domokos 
andras.domo...@nokia.com mailto:andras.domo...@nokia.com wrote:


Hi Denis,


On 02/10/2011 05:08 AM, ext Denis Kenzior wrote:

Hi Andras,

diff --git a/include/ssn.h b/include/ssn.h
index d640cad..ba3701b 100644
--- a/include/ssn.h
+++ b/include/ssn.h
@@ -37,9 +37,10 @@ struct ofono_ssn_driver {
 };

 /* SSN notifications (CSSI and CSSU).  */
-void ofono_ssn_cssi_notify(struct ofono_ssn *ssn, int
code, int index);
-void ofono_ssn_cssu_notify(struct ofono_ssn *ssn, int
code, int index,
-   const struct
ofono_phone_number *number);
+void ofono_ssn_cssi_notify(struct ofono_ssn *ssn,
unsigned int id,
+   int code1, int index);
+void ofono_ssn_cssu_notify(struct ofono_ssn *ssn,
unsigned int id, int code2,
+   int index, const struct
ofono_phone_number *number);

 int ofono_ssn_driver_register(const struct
ofono_ssn_driver *d);
 void ofono_ssn_driver_unregister(const struct
ofono_ssn_driver *d);

Right now I'm not seeing any users (or even potential ones) of
the SSN
atom besides voicecall.  What do you think of removing the SSN
atom and
moving these to the voicecall atom?

Yes, we talked about removing the SSN atom, but I thought I would
keep it for now, it can be removed any time later, anyways, doesn't
save much removing it.


The only one I'm not sure about iscode2  from 27.007:
6   forward check SS message received (can be received
whenever)

Any idea what this one is about?

Never encountered this message, and I am not sure what is it for.
A patch for handling this message can be submitted later, if a real
life case is found for it.

Regards,
-Denis

Regards,
Andras

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




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


Re: [RFC PATCH 2/3] ssn: add code and call id to notifications

2011-02-24 Thread Andras Domokos

Hi,

On 02/24/2011 05:43 PM, ext Denis Kenzior wrote:

Hi Andras,

Please no top posting on this mailing list.  You should know this by now.

I am terribly sorry, I know I should have not done that.

On 02/24/2011 05:43 AM, Andras Domokos wrote:

Hi Denis and Sankar,

The call SS notification handling patches hasn't been (fully) applied, I
think we need to do something about it.


I'd still like a version with the SSN atom removed.
OK, I am going to remove the SSN atom, not a big deal, but do you have 
any other issues at this point?

Regards,
-Denis


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


Re: [RFC PATCH 2/3] ssn: add code and call id to notifications

2011-02-24 Thread Andras Domokos

Hi Denis,

On 02/24/2011 06:14 PM, ext Denis Kenzior wrote:

Hi Andras,


The call SS notification handling patches hasn't been (fully) applied, I
think we need to do something about it.


I'd still like a version with the SSN atom removed.

OK, I am going to remove the SSN atom, not a big deal, but do you have
any other issues at this point?

Not right now.  Your API proposal is already upstream, I just didn't
like the ssn atom being kept around.


OK, I'll prepare the patches with the SSN atom removed.


Regards,
-Denis


Regards,
Andras

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


Re: [RFC PATCH 1/3] call-barring: removed +CSSI type SS notifications

2011-02-10 Thread Andras Domokos

Hi Denis,

On 02/10/2011 05:04 AM, ext Denis Kenzior wrote:

Hi Andras

On 02/09/2011 04:33 AM, Andras Domokos wrote:

---
  src/call-barring.c |   74 
  1 files changed, 0 insertions(+), 74 deletions(-)

diff --git a/src/call-barring.c b/src/call-barring.c
index 649826e..84ed277 100644
--- a/src/call-barring.c
+++ b/src/call-barring.c
@@ -58,9 +58,6 @@ struct ofono_call_barring {
int ss_req_lock;
struct ofono_ssn *ssn;

You forgot to remove this part in your patch.  I applied your patch and
fixed this in a follow on patch.

Indeed I did. Thanks a lot for the fix!

struct ofono_ussd *ussd;
-   unsigned int incoming_bar_watch;
-   unsigned int outgoing_bar_watch;
-   unsigned int ssn_watch;
unsigned int ussd_watch;
const struct ofono_call_barring_driver *driver;
void *driver_data;

Regards,
-Denis

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


[PATCH 0/3] Voice call SS notifications

2011-02-09 Thread Andras Domokos
Here are the implementation proposal for handling some of the voice call
related Supplementary Services notifications.

Implementation details:
- removed the +CSSI type SS notifications handling from the
  call-barring code
- expanded the SS notify functions with call number info, useful
  for modems capable of delivering it in the SS notifications
- expanded the SS callback functions with call number info and
  service code, useful in demultiplexing when a common callback
  function is defined for multiple service codes
- added +CSSU and +CSSI type SS notifications handling to the
  voicecall code

The API level detailed changes are explained in the doc files. 

Andras Domokos (3):
  call-barring: removed +CSSI type SS notifications
  ssn: add code and call id to notifications
  voicecall: handle voice call SS notifications

 drivers/atmodem/ssn.c |4 +-
 include/ssn.h |7 +-
 include/types.h   |2 +
 src/call-barring.c|   74 ---
 src/ofono.h   |6 +-
 src/ssn.c |   11 +-
 src/voicecall.c   |  242 -
 7 files changed, 257 insertions(+), 89 deletions(-)

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


[RFC PATCH 1/3] call-barring: removed +CSSI type SS notifications

2011-02-09 Thread Andras Domokos
---
 src/call-barring.c |   74 
 1 files changed, 0 insertions(+), 74 deletions(-)

diff --git a/src/call-barring.c b/src/call-barring.c
index 649826e..84ed277 100644
--- a/src/call-barring.c
+++ b/src/call-barring.c
@@ -58,9 +58,6 @@ struct ofono_call_barring {
int ss_req_lock;
struct ofono_ssn *ssn;
struct ofono_ussd *ussd;
-   unsigned int incoming_bar_watch;
-   unsigned int outgoing_bar_watch;
-   unsigned int ssn_watch;
unsigned int ussd_watch;
const struct ofono_call_barring_driver *driver;
void *driver_data;
@@ -987,41 +984,10 @@ static GDBusMethodTable cb_methods[] = {
 };
 
 static GDBusSignalTable cb_signals[] = {
-   { IncomingBarringInEffect, },
-   { OutgoingBarringInEffect, },
{ PropertyChanged,sv },
{ }
 };
 
-static void call_barring_incoming_enabled_notify(int idx, void *userdata)
-{
-   struct ofono_call_barring *cb = userdata;
-   DBusConnection *conn = ofono_dbus_get_connection();
-   const char *path = __ofono_atom_get_path(cb-atom);
-
-   g_dbus_emit_signal(conn, path, OFONO_CALL_BARRING_INTERFACE,
-   IncomingBarringInEffect, DBUS_TYPE_INVALID);
-}
-
-static void call_barring_outgoing_enabled_notify(int idx, void *userdata)
-{
-   struct ofono_call_barring *cb = userdata;
-   DBusConnection *conn = ofono_dbus_get_connection();
-   const char *path = __ofono_atom_get_path(cb-atom);
-   DBusMessage *signal;
-
-   signal = dbus_message_new_signal(path, OFONO_CALL_BARRING_INTERFACE,
-   OutgoingBarringInEffect);
-
-   if (signal == NULL) {
-   ofono_error(Unable to allocate new %s.OutgoingBarringInEffect
-signal, OFONO_CALL_BARRING_INTERFACE);
-   return;
-   }
-
-   g_dbus_send_message(conn, signal);
-}
-
 int ofono_call_barring_driver_register(const struct ofono_call_barring_driver 
*d)
 {
DBG(driver: %p, name: %s, d, d-name);
@@ -1054,14 +1020,6 @@ static void call_barring_unregister(struct ofono_atom 
*atom)
if (cb-ussd)
cb_unregister_ss_controls(cb);
 
-   if (cb-incoming_bar_watch)
-   __ofono_ssn_mo_watch_remove(cb-ssn, cb-incoming_bar_watch);
-   if (cb-outgoing_bar_watch)
-   __ofono_ssn_mt_watch_remove(cb-ssn, cb-outgoing_bar_watch);
-
-   if (cb-ssn_watch)
-   __ofono_modem_remove_atom_watch(modem, cb-ssn_watch);
-
if (cb-ussd_watch)
__ofono_modem_remove_atom_watch(modem, cb-ussd_watch);
 }
@@ -1116,29 +1074,6 @@ struct ofono_call_barring 
*ofono_call_barring_create(struct ofono_modem *modem,
return cb;
 }
 
-static void ssn_watch(struct ofono_atom *atom,
-   enum ofono_atom_watch_condition cond, void *data)
-{
-   struct ofono_call_barring *cb = data;
-
-   if (cond == OFONO_ATOM_WATCH_CONDITION_UNREGISTERED) {
-   cb-ssn = NULL;
-   cb-incoming_bar_watch = 0;
-   cb-outgoing_bar_watch = 0;
-   return;
-   }
-
-   cb-ssn = __ofono_atom_get_data(atom);
-
-   cb-incoming_bar_watch =
-   __ofono_ssn_mo_watch_add(cb-ssn, SS_MO_INCOMING_BARRING,
-   call_barring_incoming_enabled_notify, cb, NULL);
-
-   cb-outgoing_bar_watch =
-   __ofono_ssn_mo_watch_add(cb-ssn, SS_MO_OUTGOING_BARRING,
-   call_barring_outgoing_enabled_notify, cb, NULL);
-}
-
 static void ussd_watch(struct ofono_atom *atom,
enum ofono_atom_watch_condition cond, void *data)
 {
@@ -1158,7 +1093,6 @@ void ofono_call_barring_register(struct 
ofono_call_barring *cb)
DBusConnection *conn = ofono_dbus_get_connection();
const char *path = __ofono_atom_get_path(cb-atom);
struct ofono_modem *modem = __ofono_atom_get_modem(cb-atom);
-   struct ofono_atom *ssn_atom;
struct ofono_atom *ussd_atom;
 
if (!g_dbus_register_interface(conn, path,
@@ -1173,14 +1107,6 @@ void ofono_call_barring_register(struct 
ofono_call_barring *cb)
 
ofono_modem_add_interface(modem, OFONO_CALL_BARRING_INTERFACE);
 
-   cb-ssn_watch = __ofono_modem_add_atom_watch(modem, OFONO_ATOM_TYPE_SSN,
-   ssn_watch, cb, NULL);
-
-   ssn_atom = __ofono_modem_find_atom(modem, OFONO_ATOM_TYPE_SSN);
-
-   if (ssn_atom  __ofono_atom_get_registered(ssn_atom))
-   ssn_watch(ssn_atom, OFONO_ATOM_WATCH_CONDITION_REGISTERED, cb);
-
cb-ussd_watch = __ofono_modem_add_atom_watch(modem,
OFONO_ATOM_TYPE_USSD,
ussd_watch, cb, NULL);
-- 
1.7.0.4

___
ofono mailing list
ofono@ofono.org

[RFC PATCH 2/3] ssn: add code and call id to notifications

2011-02-09 Thread Andras Domokos
---
 drivers/atmodem/ssn.c |4 ++--
 include/ssn.h |7 ---
 src/ofono.h   |6 --
 src/ssn.c |   11 ++-
 4 files changed, 16 insertions(+), 12 deletions(-)

diff --git a/drivers/atmodem/ssn.c b/drivers/atmodem/ssn.c
index b7a9df4..b00871d 100644
--- a/drivers/atmodem/ssn.c
+++ b/drivers/atmodem/ssn.c
@@ -56,7 +56,7 @@ static void cssi_notify(GAtResult *result, gpointer user_data)
if (!g_at_result_iter_next_number(iter, index))
index = 0;
 
-   ofono_ssn_cssi_notify(ssn, code1, index);
+   ofono_ssn_cssi_notify(ssn, 0, code1, index);
 }
 
 static void cssu_notify(GAtResult *result, gpointer user_data)
@@ -93,7 +93,7 @@ static void cssu_notify(GAtResult *result, gpointer user_data)
return;
 
 out:
-   ofono_ssn_cssu_notify(ssn, code2, index, ph);
+   ofono_ssn_cssu_notify(ssn, 0, code2, index, ph);
 }
 
 static void at_ssn_initialized(gboolean ok, GAtResult *result,
diff --git a/include/ssn.h b/include/ssn.h
index d640cad..ba3701b 100644
--- a/include/ssn.h
+++ b/include/ssn.h
@@ -37,9 +37,10 @@ struct ofono_ssn_driver {
 };
 
 /* SSN notifications (CSSI and CSSU).  */
-void ofono_ssn_cssi_notify(struct ofono_ssn *ssn, int code, int index);
-void ofono_ssn_cssu_notify(struct ofono_ssn *ssn, int code, int index,
-   const struct ofono_phone_number *number);
+void ofono_ssn_cssi_notify(struct ofono_ssn *ssn, unsigned int id,
+   int code1, int index);
+void ofono_ssn_cssu_notify(struct ofono_ssn *ssn, unsigned int id, int code2,
+   int index, const struct ofono_phone_number *number);
 
 int ofono_ssn_driver_register(const struct ofono_ssn_driver *d);
 void ofono_ssn_driver_unregister(const struct ofono_ssn_driver *d);
diff --git a/src/ofono.h b/src/ofono.h
index 6ba0187..eafab21 100644
--- a/src/ofono.h
+++ b/src/ofono.h
@@ -314,8 +314,10 @@ int __ofono_sms_sim_download(struct ofono_stk *stk, const 
struct sms *msg,
 
 #include ofono/ssn.h
 
-typedef void (*ofono_ssn_mo_notify_cb)(int index, void *user);
-typedef void (*ofono_ssn_mt_notify_cb)(int index,
+typedef void (*ofono_ssn_mo_notify_cb)(unsigned int id, int code1, int index,
+   void *user);
+
+typedef void (*ofono_ssn_mt_notify_cb)(unsigned int id, int code2, int index,
const struct ofono_phone_number *ph,
void *user);
 
diff --git a/src/ssn.c b/src/ssn.c
index 64c94b7..065e4fd 100644
--- a/src/ssn.c
+++ b/src/ssn.c
@@ -112,7 +112,8 @@ gboolean __ofono_ssn_mt_watch_remove(struct ofono_ssn *ssn, 
unsigned int id)
return __ofono_watchlist_remove_item(ssn-mt_handler_list, id);
 }
 
-void ofono_ssn_cssi_notify(struct ofono_ssn *ssn, int code1, int index)
+void ofono_ssn_cssi_notify(struct ofono_ssn *ssn, unsigned int id,
+   int code1, int index)
 {
struct ssn_handler *h;
GSList *l;
@@ -123,12 +124,12 @@ void ofono_ssn_cssi_notify(struct ofono_ssn *ssn, int 
code1, int index)
notify = h-item.notify;
 
if (h-code == code1)
-   notify(index, h-item.notify_data);
+   notify(id, code1, index, h-item.notify_data);
}
 }
 
-void ofono_ssn_cssu_notify(struct ofono_ssn *ssn, int code2, int index,
-   const struct ofono_phone_number *ph)
+void ofono_ssn_cssu_notify(struct ofono_ssn *ssn, unsigned int id, int code2,
+   int index, const struct ofono_phone_number *ph)
 {
struct ssn_handler *h;
GSList *l;
@@ -139,7 +140,7 @@ void ofono_ssn_cssu_notify(struct ofono_ssn *ssn, int 
code2, int index,
notify = h-item.notify;
 
if (h-code == code2)
-   notify(index, ph, h-item.notify_data);
+   notify(id, code2, index, ph, h-item.notify_data);
}
 }
 
-- 
1.7.0.4

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


[RFC PATCH 3/3] voicecall: handle voice call SS notifications

2011-02-09 Thread Andras Domokos
---
 include/types.h |2 +
 src/voicecall.c |  242 ++-
 2 files changed, 241 insertions(+), 3 deletions(-)

diff --git a/include/types.h b/include/types.h
index d25f409..b639c8a 100644
--- a/include/types.h
+++ b/include/types.h
@@ -96,6 +96,8 @@ struct ofono_call {
char name[OFONO_MAX_CALLER_NAME_LENGTH + 1];
int clip_validity;
int cnap_validity;
+   ofono_bool_t remote_held;
+   ofono_bool_t remote_multiparty;
 };
 
 struct ofono_network_time {
diff --git a/src/voicecall.c b/src/voicecall.c
index 4606668..7178714 100644
--- a/src/voicecall.c
+++ b/src/voicecall.c
@@ -53,6 +53,15 @@ struct ofono_voicecall {
struct ofono_sim_context *sim_context;
unsigned int sim_watch;
unsigned int sim_state_watch;
+   struct ofono_ssn *ssn;
+   unsigned int ssn_watch;
+   unsigned int ssn_mt_fwd_watch;
+   unsigned int ssn_mt_hold_watch;
+   unsigned int ssn_mt_unhold_watch;
+   unsigned int ssn_mt_mpty_watch;
+   unsigned int ssn_mo_fwd_watch;
+   unsigned int ssn_mo_local_bar_watch;
+   unsigned int ssn_mo_remote_bar_watch;
const struct ofono_voicecall_driver *driver;
void *driver_data;
struct ofono_atom *atom;
@@ -400,6 +409,12 @@ static void append_voicecall_properties(struct voicecall 
*v,
 
ofono_dbus_dict_append(dict, Multiparty, DBUS_TYPE_BOOLEAN, mpty);
 
+   ofono_dbus_dict_append(dict, RemoteHeld, DBUS_TYPE_BOOLEAN,
+   v-call-remote_held);
+
+   ofono_dbus_dict_append(dict, RemoteMultiparty, DBUS_TYPE_BOOLEAN,
+   v-call-remote_multiparty);
+
if (v-message)
ofono_dbus_dict_append(dict, Information,
DBUS_TYPE_STRING, v-message);
@@ -1869,9 +1884,11 @@ static GDBusMethodTable manager_methods[] = {
 };
 
 static GDBusSignalTable manager_signals[] = {
-   { PropertyChanged,sv },
-   { CallAdded,  oa{sv} },
-   { CallRemoved,o },
+   { Forwarded,   s },
+   { BarringActive,   s },
+   { PropertyChanged, sv },
+   { CallAdded,   oa{sv} },
+   { CallRemoved, o },
{ }
 };
 
@@ -2182,6 +2199,11 @@ static void voicecall_unregister(struct ofono_atom *atom)
vc-sim_watch = 0;
}
 
+   if (vc-ssn_watch) {
+   __ofono_modem_remove_atom_watch(modem, vc-ssn_watch);
+   vc-ssn_watch = 0;
+   }
+
if (vc-dial_req)
dial_request_finish(vc);
 
@@ -2225,6 +2247,29 @@ static void voicecall_remove(struct ofono_atom *atom)
vc-sim = NULL;
}
 
+   if (vc-ssn_mt_fwd_watch)
+   __ofono_ssn_mt_watch_remove(vc-ssn, vc-ssn_mt_fwd_watch);
+
+   if (vc-ssn_mt_hold_watch)
+   __ofono_ssn_mt_watch_remove(vc-ssn, vc-ssn_mt_hold_watch);
+
+   if (vc-ssn_mt_unhold_watch)
+   __ofono_ssn_mt_watch_remove(vc-ssn, vc-ssn_mt_unhold_watch);
+
+   if (vc-ssn_mt_mpty_watch)
+   __ofono_ssn_mt_watch_remove(vc-ssn, vc-ssn_mt_mpty_watch);
+
+   if (vc-ssn_mo_fwd_watch)
+   __ofono_ssn_mt_watch_remove(vc-ssn, vc-ssn_mo_fwd_watch);
+
+   if (vc-ssn_mo_local_bar_watch)
+   __ofono_ssn_mt_watch_remove(vc-ssn,
+   vc-ssn_mo_local_bar_watch);
+
+   if (vc-ssn_mo_remote_bar_watch)
+   __ofono_ssn_mo_watch_remove(vc-ssn,
+   vc-ssn_mo_remote_bar_watch);
+
if (vc-tone_source) {
g_source_remove(vc-tone_source);
vc-tone_source = 0;
@@ -2341,12 +2386,194 @@ static void sim_watch(struct ofono_atom *atom,
sim_state_watch(ofono_sim_get_state(sim), vc);
 }
 
+static void ssn_mt_forwarded_notify(unsigned int id, int code1, int idx,
+   const struct ofono_phone_number *ph,
+   void *data)
+{
+   struct ofono_voicecall *vc = data;
+   DBusConnection *conn = ofono_dbus_get_connection();
+   const char *path = __ofono_atom_get_path(vc-atom);
+   char *info = incoming;
+
+   g_dbus_emit_signal(conn, path, OFONO_VOICECALL_MANAGER_INTERFACE,
+   Forwarded,
+   DBUS_TYPE_STRING, info,
+   DBUS_TYPE_INVALID);
+}
+
+static struct voicecall *voicecall_select(struct ofono_voicecall *vc,
+   unsigned int id, int code)
+{
+   struct voicecall *v = NULL;
+   GSList *l;
+
+   for (l = vc-call_list; l; l = l-next) {
+   struct voicecall *v1 = l-data;
+
+   if (id == 0  g_slist_length(vc-call_list) == 1) {
+   if (code == SS_MT_VOICECALL_RETRIEVED 
+   

Re: [RFC] voicecall API changes (proposal v3)

2011-02-08 Thread Andras Domokos

Hi Denis,

On 02/07/2011 09:39 PM, ext Denis Kenzior wrote:

Hi Andras,

On 02/07/2011 11:09 AM, Andras Domokos wrote:

---
  doc/call-barring-api.txt |   10 --
  doc/voicecall-api.txt|   11 +++
  doc/voicecallmanager-api.txt |   25 +
  3 files changed, 36 insertions(+), 10 deletions(-)


Your patch still didn't apply due to whitespace at EOF, but I was nice
and enough and fixed it for you.  Patch has been applied.  I went ahead
and marked the properties / signals as experimental until an
implementation arrives.

Thanks a lot!
I move on to preparing the implementation patches.

Regards,
-Denis

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


[RFC] voicecall API changes (proposal v3)

2011-02-07 Thread Andras Domokos
---
 doc/call-barring-api.txt |   10 --
 doc/voicecall-api.txt|   11 +++
 doc/voicecallmanager-api.txt |   26 ++
 3 files changed, 37 insertions(+), 10 deletions(-)

diff --git a/doc/call-barring-api.txt b/doc/call-barring-api.txt
index 41ae4b1..1534494 100644
--- a/doc/call-barring-api.txt
+++ b/doc/call-barring-api.txt
@@ -37,16 +37,6 @@ Signals  PropertyChanged(string property, 
variant value)
Signal is emitted whenever a property has changed.
The new value is passed as the signal argument.
 
-   IncomingBarringInEffect()
-
-   Signal is emitted when a call is made and an
-   incoming call barring supplementary service is in use.
-
-   OutgoingBarringInEffect()
-
-   Signal is emitted when a call is made and an
-   outgoing call barring supplementary service is in use.
-
 Properties string VoiceIncoming [readwrite]
 
Contains the value of the barrings for the incoming
diff --git a/doc/voicecall-api.txt b/doc/voicecall-api.txt
index 047b8cb..6a72386 100644
--- a/doc/voicecall-api.txt
+++ b/doc/voicecall-api.txt
@@ -145,3 +145,14 @@ Properties string LineIdentification [readonly]
 
Contains the indication if the voice call is an
emergency call or not.
+
+   boolean RemoteHeld
+
+   Contains the indication whether the voice call is put on
+   hold by the remote party or not.
+
+   boolean RemoteMultiparty
+
+   Contains the indication whether the voice call is joined
+   in a multiparty call by the remote party or not.
+
diff --git a/doc/voicecallmanager-api.txt b/doc/voicecallmanager-api.txt
index 5415345..1d49a42 100644
--- a/doc/voicecallmanager-api.txt
+++ b/doc/voicecallmanager-api.txt
@@ -144,6 +144,32 @@ SignalsCallAdded(object path, dict properties)
Signal is emitted whenever a property has changed.
The new value is passed as the signal argument.
 
+   BarringActive(string type)
+
+   Signal emitted when an outgoing voice call is made and
+   the call has been barred by the network due to the
+   remote party's Call Barring Supplementary Services
+   settings for incoming calls. In this case the type
+   parameter in the signal set to remote.
+   The signal is also emitted when an outgoing voice call
+   is made and the call has been barred by the network due
+   to the local Call Barring Supplementary Services
+   settings for outgoing calls. In this case the type
+   parameter in the signal is set to local.
+
+   CallForwarded(string type)
+
+   Signal emitted when an outgoing voice call is made and
+   the call has been redirected to another number due to
+   the remote party's Call Forwarding Supplementary
+   Services settings. In this case the type parameter in
+   the signal is set to outgoing.
+   The signal is also emitted when the incoming voice call
+   is a redirected call due to a call forwarding operation.
+   In this case the type parameter in the signal is set to
+   incoming.
+
+
 Properties array{string} EmergencyNumbers [readonly]
 
Contains the list of emergency numbers recognized
-- 
1.7.0.4

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


Re: [RFC] voicecall API changes (proposal v3)

2011-02-07 Thread Andras Domokos

Hi Denis,

On 02/07/2011 06:38 PM, ext Denis Kenzior wrote:

Hi Andras,


+   CallForwarded(string type)
+
+   Signal emitted when an outgoing voice call is made and
+   the call has been redirected to another number due to
+   the remote party's Call Forwarding Supplementary
+   Services settings. In this case the type parameter in
+   the signal is set to outgoing.

You do not want to distinguish between conditional / unconditional?
Just checking here, either one is fine with me.

In the end I made a simplification and I merged the conditional and
unconditional cases.

+   The signal is also emitted when the incoming voice call
+   is a redirected call due to a call forwarding operation.
+   In this case the type parameter in the signal is set to
+   incoming.
+
+
  Propertiesarray{string} EmergencyNumbers [readonly]

Contains the list of emergency numbers recognized

The proposal looks good to me.  I'd apply it, however git am complains:

Applying: voicecall API changes (proposal v3)
/home/denkenz/ofono-master/.git/rebase-apply/patch:32: new blank line at
EOF.
+
fatal: 1 line adds whitespace errors.

My mistake, there is an extra empty line there, I will redo the patch.

Regards,
-Denis

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


[RFC] voicecall API changes (proposal v3)

2011-02-07 Thread Andras Domokos
---
 doc/call-barring-api.txt |   10 --
 doc/voicecall-api.txt|   11 +++
 doc/voicecallmanager-api.txt |   25 +
 3 files changed, 36 insertions(+), 10 deletions(-)

diff --git a/doc/call-barring-api.txt b/doc/call-barring-api.txt
index 41ae4b1..1534494 100644
--- a/doc/call-barring-api.txt
+++ b/doc/call-barring-api.txt
@@ -37,16 +37,6 @@ Signals  PropertyChanged(string property, 
variant value)
Signal is emitted whenever a property has changed.
The new value is passed as the signal argument.
 
-   IncomingBarringInEffect()
-
-   Signal is emitted when a call is made and an
-   incoming call barring supplementary service is in use.
-
-   OutgoingBarringInEffect()
-
-   Signal is emitted when a call is made and an
-   outgoing call barring supplementary service is in use.
-
 Properties string VoiceIncoming [readwrite]
 
Contains the value of the barrings for the incoming
diff --git a/doc/voicecall-api.txt b/doc/voicecall-api.txt
index 047b8cb..6a72386 100644
--- a/doc/voicecall-api.txt
+++ b/doc/voicecall-api.txt
@@ -145,3 +145,14 @@ Properties string LineIdentification [readonly]
 
Contains the indication if the voice call is an
emergency call or not.
+
+   boolean RemoteHeld
+
+   Contains the indication whether the voice call is put on
+   hold by the remote party or not.
+
+   boolean RemoteMultiparty
+
+   Contains the indication whether the voice call is joined
+   in a multiparty call by the remote party or not.
+
diff --git a/doc/voicecallmanager-api.txt b/doc/voicecallmanager-api.txt
index 5415345..06e7b4e 100644
--- a/doc/voicecallmanager-api.txt
+++ b/doc/voicecallmanager-api.txt
@@ -144,6 +144,31 @@ SignalsCallAdded(object path, dict properties)
Signal is emitted whenever a property has changed.
The new value is passed as the signal argument.
 
+   BarringActive(string type)
+
+   Signal emitted when an outgoing voice call is made and
+   the call has been barred by the network due to the
+   remote party's Call Barring Supplementary Services
+   settings for incoming calls. In this case the type
+   parameter in the signal set to remote.
+   The signal is also emitted when an outgoing voice call
+   is made and the call has been barred by the network due
+   to the local Call Barring Supplementary Services
+   settings for outgoing calls. In this case the type
+   parameter in the signal is set to local.
+
+   CallForwarded(string type)
+
+   Signal emitted when an outgoing voice call is made and
+   the call has been redirected to another number due to
+   the remote party's Call Forwarding Supplementary
+   Services settings. In this case the type parameter in
+   the signal is set to outgoing.
+   The signal is also emitted when the incoming voice call
+   is a redirected call due to a call forwarding operation.
+   In this case the type parameter in the signal is set to
+   incoming.
+
 Properties array{string} EmergencyNumbers [readonly]
 
Contains the list of emergency numbers recognized
-- 
1.7.0.4

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


Re: [RFC] voicecall API changes (proposal 2)

2011-02-03 Thread Andras Domokos

Hi Denis,

On 02/02/2011 10:01 PM, ext Denis Kenzior wrote:

Hi Andras,


+
+   boolean ForwardedCall
+
+   Contains the indication whether the incoming voice call
+   is a redirected call due to a call forwarding operation
+   or not.

Please drop the Call suffix, you are already on the VoiceCall interface,
so putting 'Call' at the end is redundant.

OK, I am fine with shorter name.

+
+   boolean RemoteHoldActive
+
+   Contains the indication whether the voice call is put on
+   hold by the remote party or not.
+

RemoteHeld might be a better name here, but I'm fine either way.

I will go with RemoteHeld, it's shorter.

+   boolean RemoteMultiparty
+
+   Contains the indication whether the voice call is joined
+   in a multiparty call by the remote party or not.
+
diff --git a/doc/voicecallmanager-api.txt b/doc/voicecallmanager-api.txt
index 5415345..7517a7c 100644
--- a/doc/voicecallmanager-api.txt
+++ b/doc/voicecallmanager-api.txt
@@ -144,6 +144,34 @@ SignalsCallAdded(object path, dict properties)
Signal is emitted whenever a property has changed.
The new value is passed as the signal argument.

+   RemoteCallBarringActive()
+
+   Signal is emitted when an outgoing voice call is made
+   and the call has been barred by the network due to the
+   remote party's Call Barring Supplementary Services
+   settings for incoming calls.
+
+   LocalCallBarringActive()
+
+   Signal is emitted when an outgoing voice call is made
+   and the call has been barred by the network due to the
+   local party's Call Barring Supplementary Services
+   settings for outgoing calls.
+

I suggest to combine these two signals into one:
BarringActive(string type)

where type is:
remote or local.

OK, let's combine them into a single signal.

The explanations you have should be applied to the type.  Another point
is whether we want this signal on the call object itself.  Question is
how reliably we can figure out the call index.  At what point does CSSI
/ CSSU fire, before or after the call goes to active / disconnected state?

Usually, the user is informed about the call barred situation in a
very generic wording, like call barring active with no interest
in the call index information.
I prefer to keep it simple and make this signal call index free. I
suggest keeping it on the VoiceCallManager interface.
The CSSI indication comes right after when call reached the MO
dialing state and an operator announcement is played over
and over again telling the caller the reason why calls are not
possible.


+   OutgoingCallCondForwarded()
+
+   Signal is emitted when an outgoing voice call is made
+   and the call has been redirected to another number due
+   to the remote party's conditional Call Forwarding
+   Supplementary Service settings.
+
+   OutgoingCallUncondForwarded()
+
+   Signal is emitted when an outgoing voice call is made
+   and the call has been redirected to another number due
+   to the remote party's unconditional Call Forwarding
+   Supplementary Service settings.
+

Same with these two, lets call it CallForwarded(string type)

where type is:
conditional or unconditional

I'll combine them into one, that's fine.

And the same question applies here as well, do we want this on the call
object itself?  If so, then calling this signal Forwarded(string type)
would be better.  Perhaps adding another type for incoming calls that
are forwarded and removing the 'Forwarded' property would be a good idea
as well.  e.g. something like incoming type.

I am thinking along the same line. Let's replace the Forwarded
property with the Forwarded signal and add the incoming type
you were suggesting to this signal.
And we shall not care about the call index, since most probably
is not going to be used anywhere, in this respect this cases is
pretty similar to the call barring signaling case; signal will be
emitted on the VoiceCallManager interface.


Regards,
-Denis


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


[RFC] voicecall API changes (proposal 2)

2011-02-02 Thread Andras Domokos
---
 doc/call-barring-api.txt |   10 --
 doc/voicecall-api.txt|   17 +
 doc/voicecallmanager-api.txt |   28 
 3 files changed, 45 insertions(+), 10 deletions(-)

diff --git a/doc/call-barring-api.txt b/doc/call-barring-api.txt
index 41ae4b1..1534494 100644
--- a/doc/call-barring-api.txt
+++ b/doc/call-barring-api.txt
@@ -37,16 +37,6 @@ Signals  PropertyChanged(string property, 
variant value)
Signal is emitted whenever a property has changed.
The new value is passed as the signal argument.
 
-   IncomingBarringInEffect()
-
-   Signal is emitted when a call is made and an
-   incoming call barring supplementary service is in use.
-
-   OutgoingBarringInEffect()
-
-   Signal is emitted when a call is made and an
-   outgoing call barring supplementary service is in use.
-
 Properties string VoiceIncoming [readwrite]
 
Contains the value of the barrings for the incoming
diff --git a/doc/voicecall-api.txt b/doc/voicecall-api.txt
index 047b8cb..9e1d90f 100644
--- a/doc/voicecall-api.txt
+++ b/doc/voicecall-api.txt
@@ -145,3 +145,20 @@ Properties string LineIdentification [readonly]
 
Contains the indication if the voice call is an
emergency call or not.
+
+   boolean ForwardedCall
+
+   Contains the indication whether the incoming voice call
+   is a redirected call due to a call forwarding operation
+   or not.
+
+   boolean RemoteHoldActive
+
+   Contains the indication whether the voice call is put on
+   hold by the remote party or not.
+
+   boolean RemoteMultiparty
+
+   Contains the indication whether the voice call is joined
+   in a multiparty call by the remote party or not.
+
diff --git a/doc/voicecallmanager-api.txt b/doc/voicecallmanager-api.txt
index 5415345..7517a7c 100644
--- a/doc/voicecallmanager-api.txt
+++ b/doc/voicecallmanager-api.txt
@@ -144,6 +144,34 @@ SignalsCallAdded(object path, dict properties)
Signal is emitted whenever a property has changed.
The new value is passed as the signal argument.
 
+   RemoteCallBarringActive()
+
+   Signal is emitted when an outgoing voice call is made
+   and the call has been barred by the network due to the
+   remote party's Call Barring Supplementary Services
+   settings for incoming calls.
+
+   LocalCallBarringActive()
+
+   Signal is emitted when an outgoing voice call is made
+   and the call has been barred by the network due to the
+   local party's Call Barring Supplementary Services
+   settings for outgoing calls.
+
+   OutgoingCallCondForwarded()
+
+   Signal is emitted when an outgoing voice call is made
+   and the call has been redirected to another number due
+   to the remote party's conditional Call Forwarding
+   Supplementary Service settings.
+
+   OutgoingCallUncondForwarded()
+
+   Signal is emitted when an outgoing voice call is made
+   and the call has been redirected to another number due
+   to the remote party's unconditional Call Forwarding
+   Supplementary Service settings.
+
 Properties array{string} EmergencyNumbers [readonly]
 
Contains the list of emergency numbers recognized
-- 
1.7.0.4

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


Re: [RFC] voice call API changes (proposal)

2011-02-01 Thread Andras Domokos

Hi Denis,

On 01/31/2011 09:58 PM, ext Denis Kenzior wrote:

Hi Andras,

On 01/31/2011 05:56 AM, Andras Domokos wrote:

Here is a proposal for expanding the VoiceCallManager interface with
call related Supplementary Services signals, and the VoiceCall
interface with new properties.

---
  doc/call-barring-api.txt |   10 --
  doc/voicecall-api.txt|   15 +++
  doc/voicecallmanager-api.txt |   21 +
  3 files changed, 36 insertions(+), 10 deletions(-)

diff --git a/doc/call-barring-api.txt b/doc/call-barring-api.txt
index 41ae4b1..1534494 100644
--- a/doc/call-barring-api.txt
+++ b/doc/call-barring-api.txt
@@ -37,16 +37,6 @@ Signals  PropertyChanged(string property, 
variant value)
Signal is emitted whenever a property has changed.
The new value is passed as the signal argument.

-   IncomingBarringInEffect()
-
-   Signal is emitted when a call is made and an
-   incoming call barring supplementary service is in use.
-
-   OutgoingBarringInEffect()
-
-   Signal is emitted when a call is made and an
-   outgoing call barring supplementary service is in use.
-
  Propertiesstring VoiceIncoming [readwrite]

Contains the value of the barrings for the incoming
diff --git a/doc/voicecall-api.txt b/doc/voicecall-api.txt
index 047b8cb..e7276a3 100644
--- a/doc/voicecall-api.txt
+++ b/doc/voicecall-api.txt
@@ -145,3 +145,18 @@ Properties string LineIdentification [readonly]

Contains the indication if the voice call is an
emergency call or not.
+
+   boolean Forwarded
+
+   Contains the indication whether the voice call is a
+   forwarded call or not.
+

So just to clarify, this is usually set on a local Incoming / Waiting
call, correct?

This property would apply to both, outgoing and incoming calls.

When the incoming call is a forwarded call the call is accompanied
by a forwarded call SS notification.

When the call is an outgoing call and the call is forwarded due to the
remote party having a conditional or unconditional forwarding enabled,
the outgoing call is accompanied by a call has been forwarded
SS notification.

I think would be a good idea, if not mandatory, to have a voice call
property indicating the call direction.

+   boolean RemoteHold
+
+   Contains the indication whether the voice call has been
+   put on hold by the remote party or not.
+

This one is rather tricky, since AT modems do not report the index of
the call.  So the only way you can report this is if you have only a
single call active or your modem supports this properly (I know ISI does).

Indeed, this is a tricky case since the standard AT Supplementary
Services notification don't provide the call index within the notifications.
Although in many cases the call index can be inferred correctly, there
are cases when this is impossible and the call index needs to be
provided explicitly, like in the remote hold/multiparty  cases and
assuming 2 local calls. We do best effort guess for modems not
supporting call indexes.


+   boolean Waiting
+
+   Contains the indication whether the outgoing voice call
+   is waiting or not.

And this is for a local dialing / alerting call.  Correct?

This is an indication from the network in connection with an
outgoing call telling that the remote party is already engaged into
a call and your call is waiting to be answered or rejected (handled).


diff --git a/doc/voicecallmanager-api.txt b/doc/voicecallmanager-api.txt
index 2bf9ded..bbd80db 100644
--- a/doc/voicecallmanager-api.txt
+++ b/doc/voicecallmanager-api.txt
@@ -144,6 +144,27 @@ SignalsCallAdded(object path, dict properties)
Signal is emitted whenever a property has changed.
The new value is passed as the signal argument.

+   UnconditionalForwardingInEffect
+
+   Signal is emitted when a call is made and unconditional
+   call forwarding supplementary service is active.

This is for a local dialing / alerting call.  Correct?

The notification is sent in connection with an outgoing call when
the remote party has unconditional call forwarding enabled that
is enforced by the network.

+
+   ConditionalForwardingInEffect
+
+   Signal is emitted when a call is made and some of the
+   conditional call forwarding supplementary services are
+   active.
+

Same as above?

The notification is sent in connection with an outgoing call when
the remote party has such conditional call forwarding enabled
that is enforced by the network

[RFC] voice call API changes (proposal)

2011-01-31 Thread Andras Domokos
Here is a proposal for expanding the VoiceCallManager interface with 
call related Supplementary Services signals, and the VoiceCall
interface with new properties.

---
 doc/call-barring-api.txt |   10 --
 doc/voicecall-api.txt|   15 +++
 doc/voicecallmanager-api.txt |   21 +
 3 files changed, 36 insertions(+), 10 deletions(-)

diff --git a/doc/call-barring-api.txt b/doc/call-barring-api.txt
index 41ae4b1..1534494 100644
--- a/doc/call-barring-api.txt
+++ b/doc/call-barring-api.txt
@@ -37,16 +37,6 @@ Signals  PropertyChanged(string property, 
variant value)
Signal is emitted whenever a property has changed.
The new value is passed as the signal argument.
 
-   IncomingBarringInEffect()
-
-   Signal is emitted when a call is made and an
-   incoming call barring supplementary service is in use.
-
-   OutgoingBarringInEffect()
-
-   Signal is emitted when a call is made and an
-   outgoing call barring supplementary service is in use.
-
 Properties string VoiceIncoming [readwrite]
 
Contains the value of the barrings for the incoming
diff --git a/doc/voicecall-api.txt b/doc/voicecall-api.txt
index 047b8cb..e7276a3 100644
--- a/doc/voicecall-api.txt
+++ b/doc/voicecall-api.txt
@@ -145,3 +145,18 @@ Properties string LineIdentification [readonly]
 
Contains the indication if the voice call is an
emergency call or not.
+
+   boolean Forwarded
+
+   Contains the indication whether the voice call is a
+   forwarded call or not.
+
+   boolean RemoteHold
+
+   Contains the indication whether the voice call has been
+   put on hold by the remote party or not.
+
+   boolean Waiting
+
+   Contains the indication whether the outgoing voice call
+   is waiting or not.
diff --git a/doc/voicecallmanager-api.txt b/doc/voicecallmanager-api.txt
index 2bf9ded..bbd80db 100644
--- a/doc/voicecallmanager-api.txt
+++ b/doc/voicecallmanager-api.txt
@@ -144,6 +144,27 @@ SignalsCallAdded(object path, dict properties)
Signal is emitted whenever a property has changed.
The new value is passed as the signal argument.
 
+   UnconditionalForwardingInEffect
+
+   Signal is emitted when a call is made and unconditional
+   call forwarding supplementary service is active.
+
+   ConditionalForwardingInEffect
+
+   Signal is emitted when a call is made and some of the
+   conditional call forwarding supplementary services are
+   active.
+
+   IncomingBarringInEffect()
+
+   Signal is emitted when a call is made and an
+   incoming call barring supplementary service is in use.
+
+   OutgoingBarringInEffect()
+
+   Signal is emitted when a call is made and an
+   outgoing call barring supplementary service is in use.
+
 Properties array{string} EmergencyNumbers [readonly]
 
Contains the list of emergency numbers recognized
-- 
1.7.0.4

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


Re: [RFC] voicecallmanager-api: call related SS signals (proposal)

2011-01-28 Thread Andras Domokos

Hi Denis,

On 01/27/2011 06:01 PM, ext Denis Kenzior wrote:

Hi Andras,


This  becomes a problem when there are multiple calls since it is not
possible to determine to which call instance the indication is referring
to.
This raises the question where/how to show this type of properties?

Have you seen the thread from Pekka's previous attempt to define such
APIs?  Its been a while now but should be in the archives.


It seems, we might have a bit work to do here.

The first thing is to settle on  the APIs for handling the voice call SS
notifications, I am thinking about the DBus level API and the oFono
internal API.

Currently the SSI notifications are handled in the call barring code, a
better place for handling those notifications would be under the voice
call atom.

Some of the SSI/SSU notifications should be presented as DBus signals
on the VoiceCallManager interface, others converted to voice call
properties, visible on the VoiceCall interface. I compiled a list of
properties/signals based on the possible SSI/SSU notification. The list
is not complete, but can be expanded any time later, based on practical
needs.

Here is the mapping between the properties/signals and SS notification
codes I considered essential to start with:

VoiceCall properties:
Forwarded (bool):: +CSSI: 2, +CSSU: 0
RemoteHold (bool):: +CSSU: 2, +CSSU: 3
Multiparty (bool): +CSSU: 4

VoiceCallManager signals:
UnconditionalForwardingInEffect: +CSSI: 0
ConditionalForwardingInEffect: +CSSI: 1
OutgoingBarringInEffect: +CSSI: 5
IncomingBarringInEffect: +CSSI: 6

In the case of the VoiceCall properties, it is assumed that call instance
number (call id) is available either implicitly, or explicitly provided 
by the

modem driver. Some of the SSN functions needs to be changed to
add call id to the function parameters list, so that modems supporting
the call id feature can deliver this information.
For cases when it's impossible to unambiguously determine the call id
for the SS notifications, the notification will be either discarded, or a
VoiceCallManager DBus could be emitted in connection with the
notification (+CSSU: 2, +CSSU: 3, +CSSU: 4 cases).

I see no any need for the SSN atom, and my proposal is to remove it
completely.


Regards,
-Denis


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


[PATCH 0/4] Emergency Calls

2010-12-20 Thread Andras Domokos
Steps in handling emergency calls:
- subscribe to modem online notifications
- emergency call detected (phone number is an emergency number)
- increment emergency mode 
  - advertise Emergency property change on D-Bus (first call)
  - set modem online (minimal setup) if mode was offline
- adevertise Online property change on D-Bus
- if modem is not online postpone making the call, otherwise make
  the emergency call
- when modem online notification comes and there is postponed emergency call
  request, make the emergency call
- when an emergency call ends decrement emergency mode
  - set modem to pre emergency call state (last call)
- advertise Online property change on D-Bus (if any)
  - advertise Emergency property change on D-Bus (last call)

Andras Domokos (3):
  modem: add Emergency property
  modem: move dial request_cb function
  voicecall: add emergency call handling

 src/dbus.c  |7 ++
 src/modem.c |  207 ++-
 src/ofono.h |5 ++
 src/voicecall.c |  186 -
 4 files changed, 369 insertions(+), 36 deletions(-)

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


[RFC PATCH 1/3] modem: add Emergency property

2010-12-20 Thread Andras Domokos
---
 src/dbus.c  |7 ++
 src/modem.c |  207 ++-
 src/ofono.h |5 ++
 3 files changed, 216 insertions(+), 3 deletions(-)

diff --git a/src/dbus.c b/src/dbus.c
index c24615f..3be8d22 100644
--- a/src/dbus.c
+++ b/src/dbus.c
@@ -345,6 +345,13 @@ DBusMessage *__ofono_error_access_denied(DBusMessage *msg)
Operation not permitted);
 }
 
+DBusMessage *__ofono_error_emergency_active(DBusMessage *msg)
+{
+   return g_dbus_create_error(msg, OFONO_ERROR_INTERFACE
+   .EmergencyActive,
+   Emergency state active);
+}
+
 void __ofono_dbus_pending_reply(DBusMessage **msg, DBusMessage *reply)
 {
DBusConnection *conn = ofono_dbus_get_connection();
diff --git a/src/modem.c b/src/modem.c
index 2f9387c..1ad72bd 100644
--- a/src/modem.c
+++ b/src/modem.c
@@ -61,6 +61,8 @@ enum modem_state {
 struct ofono_modem {
char*path;
enum modem_statemodem_state;
+   enum modem_statemodem_state_pre_emergency;
+   ofono_bool_tmodem_state_pending;
GSList  *atoms;
struct ofono_watchlist  *atom_watches;
GSList  *interface_list;
@@ -73,6 +75,7 @@ struct ofono_modem {
guint   timeout;
ofono_bool_tonline;
struct ofono_watchlist  *online_watches;
+   unsigned intemergency;
GHashTable  *properties;
struct ofono_sim*sim;
unsigned intsim_watch;
@@ -401,6 +404,11 @@ static void modem_change_state(struct ofono_modem *modem,
 
modem-modem_state = new_state;
 
+   if (modem-emergency  0)
+   modem-modem_state_pre_emergency = new_state;
+
+   modem-modem_state_pending = FALSE;
+
if (old_state  new_state)
flush_atoms(modem, new_state);
 
@@ -440,11 +448,25 @@ static void sim_state_watch(enum ofono_sim_state 
new_state, void *user)
 
switch (new_state) {
case OFONO_SIM_STATE_NOT_PRESENT:
+   if (modem-emergency != 0) {
+   modem-modem_state_pre_emergency = MODEM_STATE_PRE_SIM;
+   break;
+   }
+
modem_change_state(modem, MODEM_STATE_PRE_SIM);
break;
case OFONO_SIM_STATE_INSERTED:
break;
case OFONO_SIM_STATE_READY:
+   if (modem-emergency != 0) {
+   modem-modem_state_pre_emergency = MODEM_STATE_OFFLINE;
+
+   if (modem-driver-set_online == NULL)
+   modem-modem_state_pre_emergency = 
MODEM_STATE_ONLINE;
+
+   break;
+   }
+
modem_change_state(modem, MODEM_STATE_OFFLINE);
 
/*
@@ -482,6 +504,73 @@ void __ofono_modem_remove_online_watch(struct ofono_modem 
*modem,
__ofono_watchlist_remove_item(modem-online_watches, id);
 }
 
+static void modem_change_online(struct ofono_modem *modem,
+   enum modem_state new_state)
+{
+   DBusConnection *conn = ofono_dbus_get_connection();
+   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);
+
+   modem-modem_state = new_state;
+   modem-modem_state_pending = FALSE;
+   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 emergency_online_cb(const struct ofono_error *error, void *data)
+{
+   struct ofono_modem *modem = data;
+
+   DBG(modem: %p, modem);
+
+   if (error-type == OFONO_ERROR_TYPE_NO_ERROR 
+   modem-modem_state != MODEM_STATE_ONLINE) {
+   modem_change_online(modem, MODEM_STATE_ONLINE);
+   } else {
+   modem-modem_state_pending = FALSE;
+   notify_online_watches(modem);
+   }
+}
+
+static void emergency_offline_cb(const struct ofono_error *error, void *data)
+{
+   struct ofono_modem *modem = data;
+   DBusConnection *conn = ofono_dbus_get_connection();
+   const char *path = ofono_modem_get_path(modem);
+   gboolean state = FALSE;
+
+   DBG(modem: %p, modem);
+
+   if (error-type == OFONO_ERROR_TYPE_NO_ERROR 
+   modem-modem_state == MODEM_STATE_ONLINE) {
+   modem_change_online(modem, modem-modem_state_pre_emergency);
+   } else {
+   modem-modem_state_pending = FALSE;
+   notify_online_watches(modem);
+   }
+
+   modem-emergency--;
+   if 

[RFC PATCH 3/3] voicecall: add emergency call handling

2010-12-20 Thread Andras Domokos
---
 src/voicecall.c |  122 ++-
 1 files changed, 121 insertions(+), 1 deletions(-)

diff --git a/src/voicecall.c b/src/voicecall.c
index 0120cd0..370f760 100644
--- a/src/voicecall.c
+++ b/src/voicecall.c
@@ -52,6 +52,7 @@ struct ofono_voicecall {
struct ofono_sim *sim;
unsigned int sim_watch;
unsigned int sim_state_watch;
+   unsigned int modem_online_watch;
const struct ofono_voicecall_driver *driver;
void *driver_data;
struct ofono_atom *atom;
@@ -134,6 +135,22 @@ static void add_to_en_list(GSList **l, const char **list)
*l = g_slist_prepend(*l, g_strdup(list[i++]));
 }
 
+static gint number_compare(gconstpointer a, gconstpointer b)
+{
+   const char *s1 = a, *s2 = b;
+   return strcmp(s1, s2);
+}
+
+static ofono_bool_t emergency_number(struct ofono_voicecall *vc,
+   const char *number)
+{
+   if (number == NULL)
+   return FALSE;
+
+   return g_slist_find_custom(vc-en_list,
+   number, number_compare) ? TRUE : FALSE;
+}
+
 static const char *disconnect_reason_to_string(enum ofono_disconnect_reason r)
 {
switch (r) {
@@ -1134,6 +1151,7 @@ handled:
 static void manager_dial_callback(const struct ofono_error *error, void *data)
 {
struct ofono_voicecall *vc = data;
+   struct ofono_modem *modem = __ofono_atom_get_modem(vc-atom);
DBusMessage *reply;
const char *number;
gboolean need_to_emit;
@@ -1152,8 +1170,12 @@ 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 {
+   if (emergency_number(vc, number))
+   ofono_modem_dec_emergency(modem);
+
reply = __ofono_error_failed(vc-pending);
+   }
 
__ofono_dbus_pending_reply(vc-pending, reply);
 
@@ -1165,6 +1187,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;
@@ -1204,6 +1227,16 @@ static DBusMessage *manager_dial(DBusConnection *conn,
 
string_to_phone_number(number, ph);
 
+   if (emergency_number(vc, number)) {
+   int online;
+
+   ofono_modem_inc_emergency(modem);
+
+   online = ofono_modem_get_online(modem);
+   if (online != TRUE)
+   return NULL;
+   }
+
vc-driver-dial(vc, ph, clir, OFONO_CUG_OPTION_DEFAULT,
manager_dial_callback, vc);
 
@@ -1757,6 +1790,7 @@ void ofono_voicecall_disconnected(struct ofono_voicecall 
*vc, int id,
const struct ofono_error *error)
 {
struct ofono_modem *modem = __ofono_atom_get_modem(vc-atom);
+   const char *number;
GSList *l;
struct voicecall *call;
time_t ts;
@@ -1776,6 +1810,7 @@ void ofono_voicecall_disconnected(struct ofono_voicecall 
*vc, int id,
}
 
call = l-data;
+   number = phone_number_to_string(call-call-phone_number);
 
ts = time(NULL);
prev_status = call-call-status;
@@ -1814,6 +1849,9 @@ void ofono_voicecall_disconnected(struct ofono_voicecall 
*vc, int id,
 
voicecalls_emit_call_removed(vc, call);
 
+   if (emergency_number(vc, number))
+   ofono_modem_dec_emergency(modem);
+
voicecall_dbus_unregister(vc, call);
 
vc-call_list = g_slist_remove(vc-call_list, call);
@@ -2074,6 +2112,7 @@ static void voicecall_unregister(struct ofono_atom *atom)
 static void voicecall_remove(struct ofono_atom *atom)
 {
struct ofono_voicecall *vc = __ofono_atom_get_data(atom);
+   struct ofono_modem *modem = __ofono_atom_get_modem(atom);
 
DBG(atom: %p, atom);
 
@@ -2115,6 +2154,12 @@ static void voicecall_remove(struct ofono_atom *atom)
g_queue_free(vc-toneq);
}
 
+   if (vc-modem_online_watch) {
+   __ofono_modem_remove_online_watch(modem,
+   vc-modem_online_watch);
+   vc-modem_online_watch = 0;
+   }
+
g_free(vc);
 }
 
@@ -2212,6 +2257,7 @@ static void sim_watch(struct ofono_atom *atom,
 static void dial_request_cb(const struct ofono_error *error, void *data)
 {
struct ofono_voicecall *vc = data;
+   struct ofono_modem *modem = __ofono_atom_get_modem(vc-atom);
gboolean need_to_emit;
struct voicecall *v;
 
@@ -2221,6 +2267,10 @@ static void dial_request_cb(const struct ofono_error 
*error, void *data)
 

Re: [PATCH 0/5] Call Counters (2nd)

2010-12-10 Thread Andras Domokos

Hi,

On 12/10/2010 12:53 AM, ext Marcel Holtmann wrote:

Hi Kai,

   

I share the concern for the IO/CPU cost, but I don't think it
matters much in which daemon this is done. Especially if some slack
is  allowed for the timers (which should be the case), ofonod will be
scheduled when the CPU is anyways woken up (e.g. modem/audio interrupts
wake up pulseaudio).
 

this is not really true. We can not wakeup ofonod every single second.
You might wanna start running powertop.
   

uhm, but I'm not claiming that. I was just stating that moving
the timers to e.g. pulseaudio in this case won't save much if
anything (the CPU will be woken up anyways, and the cost between
scheduling ofonod or a thread from PA, has really no difference
to overall consumption.. the CPU is woken up anyways and roughly
the same code to handle the timer is run).

So whether this code is in oFono or elsewhere, does not matter
much (to overall power consumption). The main question is of course
how often the counters are synced.
 

actually it does matter since you have no extra context switch and in
addition you not accidentally wake up PA and then ofonod. You have one
centralized wakeup of one thread.

Of course this should be smart and done along with the PA audio
processing and not async to that one.

If we consider that the only sensible thing is to track the actual
talking time, then PA becomes a nice choice for this.

This doesn't mean that you should be implementing it, but I am still
maintaining that this would be a pretty damn smart way of solving this
efficiently.

   

Obviously, there are many implementation options, we have to
decide only about whether we want to have this implemented
in oFono or not, or in first place, whether the feature is needed
at all or not. For the latter part I am collecting more info from
our people.

Personally I think the every-10sec interval is too short.
It's also highly system specific when wakeups start to get
too costly, so picking up one value seems difficult.
 

My take here is that a granularity of 1 minute is enough.

Doing this every 10 seconds and displaying it on a per second level
sounds insane to me.
   


That second level D-Bus query of the call counters should be forgotten,
probably is not going to happen and anyways, querying is something
that can be controlled/tuned outside ofono. In fact any method can be
abused in a similar way, is not oFono's responsibility to prevent such
misuse from happening.
There is a single value to tune, the sync interval, we can either settle
on a reasonable value, or we can make it a configurable parameter (the
default value would disable the periodic syncing), then everybody can
do whatever with its own product.


Regards

Marcel


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


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


Re: [PATCH 0/5] Call Counters (2nd)

2010-12-08 Thread Andras Domokos

Hi Marcel,

On 12/08/2010 06:12 PM, ext Marcel Holtmann wrote:

Hi Andras,

   

Lets take this one step and please explain to me what your requirements
and objectives are. I also wanna see a top to bottom from UI down to the
modem usage of this API.

   

We need a UI showing total MO and MT call times. They also need to be
able to be reset, if the user so wishes. The data needs to be
reasonably reliable.

 

Fair enough, but when I look at such a feature as a whole, then my
question is when does it need to be shown? What is your user interaction
requirement with this data?

Andras, please explain what reasonable reliable means.


   

The call counters are shown to the user when he or she opens up
an application/applet whatever UI component that is meant for
showing this information.
 

do we have a clear use case requirement from an UI point of view on how
this is expected to be working.
   

In our case, it is expected to have the counters information shown to the
user continuously updated with about 1 second granularity, as long as the
user keeps opened the UI showing the counters. This practically means
live call counters in the UI.


I checked with my iPhone and how it does it. Basically it just updates
after the call and only after you re-entered that menu.

So here again, do we have a requirement to make this realtime or not.
And I mean that from an user interaction point of view.

   

Coming to the reliability part, saving the call counters information
often enough, gives us sort of hard guarantee that whatever happens
with any subsystem, be that SW or HW, the call counters will stay enough
accurate. Syncing to the permanent storage, based on our product
requirements, should take place in fact every 5 sec, or could be
configurable.
 

Writing and syncing something to disk every 5 seconds costs us IO. Is
this really a sacrifice that is acceptable.

   

I agree, from pure technical point of view it's a costly operation.

There might be some liability issues if for some reason the counters would
loose time, the user my blame the phone manufacturer for the extra
expenses incurred by inaccurate counters.
 

To be honest the counters can not be considered accurate anyway. Only
the billing system has the final say.
   

I think any info we decide to show to the user has to be accurate enough,
otherwise becomes meaningless.

and consuming heavy IO with writing this information to disk. In
addition to that there is no clear UI usage for the getter API.

   

What do you mean? Do you mean your iPhone has no such UI?

 

I have actually tested this with an iPhone and it has such an UI
element, but it is not realtime. It gets updated after the call has been
completed.

So why can't we just update/reset this in Tracker via the history plugin
in a general way. I am failing to see the need for this inside oFono. It
seems to me that doing this within the scope of the Tracker integration
is a lot cleaner and better for CPU and IO usage.

   

We can discuss the place of the call counters plugin, but I think using the
ofono history framework is a reasonable choice, with the note that the it
needs to be expanded with a history function called in the beginning
of a call.
The call counters plugin could be an optionally compiled/included (dynamic)
plugin or downgraded to experimental status.
 

So I am actually thinking that doing that inside PulseAudio is a lot
more efficient solution.

The idea is that PA already runs in the user session and has to monitor
the uplink/downlink state (and additionally could monitor call states as
well if needed). So it knows when a call is active and it is active
anyway doing the audio processing. So it could just then go ahead and
write your call accounting into Tracker.

Would such an architecture work for you guys?
   

I don't know at the moment whether this solution is good and elegant
enough, we need to think about it.


The reason these are not properties is just because it makes no sense
to update the counters live. The UI can poll if it so wishes, but
the poll interval is not something we want to decide.


 

What are the granularity there. What is the expected user experience
with this API. I don't see any clear usage model here.

In addition to that, what is the problem with just updating the stats
after the call has ended?

   

Because if your battery runs out in the middle of a 4 hour conference
call, your timers are not updated and become worthless. Obviously,
this is a compromise between how reliable the counters are and how
many wakeups and IO we can bear.

 

I think this is not a good idea to have oFono handles this. Why can't
the system daemon just shutdown all calls when the battery reaches
critical limit.

You will never fully run down the battery anyway. One of the system
health components in the system will prevent it and then can cleanly
shutdown oFono and thus all calls. The 

Re: [PATCH 0/3] Long dial string support (2nd)

2010-11-24 Thread Andras Domokos

Hi Denis,

On 11/24/2010 12:04 AM, ext Denis Kenzior wrote:

Hi Andras,

   

Even if we don't support FDN at this point, there is still a remaining
related issue, who we are going to dial numbers like:

12345456p1234#

I think the the dial string could still be passed to the voicecall driver
that will take care of the modem specific details, most importantly
playing the DTMF tones and generating the tone events that would be
propagated back to voicecall manager and to D-Bus from there.
 

So we looked into what it would take to implement dial strings with AT
modems.  The consensus was that passing the entire string to the driver
was a bad idea as most modems simply do not support pause characters and
have strict limitations on the number length.

The best idea we have came up with so far is to parse the string passed
to dial and separate the actual number from the dial string.  The dial
string then gets assigned to a separate property on the voice call
object (see Dial String task in the TODO).

We would then extend the call state logic to queue the dial string the
same as a DTMF once the call is active.  If you study the DTMF logic,
you will note that Andrew has recently made it into a tone queue.

Today we burst up to 8 (arbitrarily picked number) DTMF tones per driver
request.  What we could do is send a single tone at a time.  In theory
this would allow us to emit the Tone Started / Tone Stopped signals
(please see the provide feedback of sent DTMF tones task) as well.

It sounds like the ISI modems already work this way and are nicely
covered by this approach...
   

Thanks for your clarification. I also had a thorough look at the
the DTMF tones handling implementation. Based on these infos
and assuming that we don't want to implement (full) FDN
support, these patches are not needed indeed.


Regards,
-Denis
   


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


Re: [PATCH 0/3] Long dial string support (2nd)

2010-11-24 Thread Andras Domokos

Hi Rajesh,

On 11/22/2010 10:58 PM, ext rajesh.naga...@elektrobit.com wrote:

Hi Andras,

   

Dial strings can now be as long as 120 digits (not counting
'+'). This feature is going to be needed by the FDN feature.

An FDN may consist of a phone number plus a DTMF string. In
order to have the call succeed when FDN is enabled, both
parts need to be provided when making a call, as a single dial string.

For AT modems the long dial string can be and has to be
passed as is to the modem, for ISI modems the dial string
needs to be split into phone number (dest.
address sub block) and DTMF tone (post dest. address sub
block) before feeding it to the modem.
 

Sending the DTMF tone in post dest. address sub block in case of
the ISI modem or sending as part of the dial string in case of
AT modems, will the modem take care of DTMF postfix handling by
itself or its only going to use that for FDN check ?

If its going to be earlier case, then not all modems support
this feature and also sending the postfix DTMF tone automatically
by the modem without notifying to the AP, then the user neither
wont be aware of ongoing DTMF tone sending as there will be no
local playback of the tone nor will have any control over the
DTMF tones sending.

So we should parse the dial string and extract the DTMF postfix
(after the FDN check, anyways we are not suppoting FDN in oFono).
Once the call gets connected, then the postfix DTMF tones can be
sent out and signaled to the application about the start and stop
events of each tone, so the application can generate the
corresponding DTMF tones using the tonegenerator for local
playback.

Also currently the w/W stop character handling is not there,
so I am not sure if its intentionally left out or missing ?
   


I think the situation has been clarified based on the
discussion with Denis. I stop pushing these patches.

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


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


Re: [RFC PATCH 2/4] modem: add EmergencyMode property

2010-11-24 Thread Andras Domokos

Hi Denis,

On 11/23/2010 10:46 AM, ext Denis Kenzior wrote:

Hi Andras,

On 11/15/2010 10:57 AM, Andras Domokos wrote:
   

From: Andras Domokosandras.domo...@nokia.com

---
  src/modem.c |  134 +++
  src/ofono.h |4 ++
  2 files changed, 138 insertions(+), 0 deletions(-)

diff --git a/src/modem.c b/src/modem.c
index f73cc1d..4307914 100644
--- a/src/modem.c
+++ b/src/modem.c
@@ -61,6 +61,7 @@ enum modem_state {
  struct ofono_modem {
   char*path;
   enum modem_statemodem_state;
+ enum modem_statemodem_state_pre_emergency;
   GSList  *atoms;
   struct ofono_watchlist  *atom_watches;
   GSList  *interface_list;
@@ -72,6 +73,7 @@ struct ofono_modem {
   ofono_bool_tpowered_pending;
   guint   timeout;
   ofono_bool_tonline;
+ unsigned intemergency_mode;
 

I really prefer this to be called 'emergency'

   

   struct ofono_watchlist  *online_watches;
   GHashTable  *properties;
   struct ofono_sim*sim;
@@ -514,6 +516,127 @@ static void offline_cb(const struct ofono_error *error, 
void *data)
   modem_change_state(modem, MODEM_STATE_OFFLINE);
  }

+ofono_bool_t ofono_modem_get_emergency_mode(struct ofono_modem *modem)
+{
+ if (modem == NULL)
+ return FALSE;
+
+ return modem-emergency_mode != 0;
+}
+
+static void modem_change_online(struct ofono_modem *modem,
+ enum modem_state new_state)
+{
+ DBusConnection *conn = ofono_dbus_get_connection();
+ 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 (new_online == modem-online)
+ return;
+
+ modem-modem_state = new_state;
+ 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 emergency_online_cb(const struct ofono_error *error, void *data)
+{
+ struct ofono_modem *modem = data;
+
+ DBG(modem: %p, modem);
+
+ if (error-type == OFONO_ERROR_TYPE_NO_ERROR
+ modem-modem_state != MODEM_STATE_ONLINE)
+ modem_change_online(modem, MODEM_STATE_ONLINE);
+}
+
+static void emergency_offline_cb(const struct ofono_error *error, void *data)
+{
+ struct ofono_modem *modem = data;
+ DBusConnection *conn = ofono_dbus_get_connection();
+ const char *path = ofono_modem_get_path(modem);
+ gboolean state = FALSE;
+
+ DBG(modem: %p, modem);
+
+ if (error-type == OFONO_ERROR_TYPE_NO_ERROR
+ modem-modem_state == MODEM_STATE_ONLINE)
+ modem_change_online(modem, modem-modem_state_pre_emergency);
+
+ modem-emergency_mode--;
+
+ ofono_dbus_signal_property_changed(conn, path,
+ OFONO_MODEM_INTERFACE,
+ EmergencyMode,
 

The property should really be called 'Emergency' to be in line with the
current API proposal (doc/modem-api.txt  TODO)

   

+ DBUS_TYPE_BOOLEAN,
+state);
+}
+
+void ofono_modem_inc_emergency_mode(struct ofono_modem *modem)
+{
+ DBusConnection *conn = ofono_dbus_get_connection();
+ const char *path = ofono_modem_get_path(modem);
+ gboolean state = TRUE;
+
+ DBG(modem: %p, modem);
+
+ modem-emergency_mode++;
+ if (modem-emergency_mode  1)
+ return;
+
+ ofono_dbus_signal_property_changed(conn, path,
+ OFONO_MODEM_INTERFACE,
+ EmergencyMode,
 

Again, 'Emergency' here

   

+ DBUS_TYPE_BOOLEAN,
+state);
+
+ modem-modem_state_pre_emergency = modem-modem_state;
+
+ if (modem-modem_state == MODEM_STATE_ONLINE)
+ return;
+
+ modem-driver-set_online(modem, TRUE, emergency_online_cb, modem);
+}
+
+void ofono_modem_dec_emergency_mode(struct ofono_modem *modem)
+{
+ DBusConnection *conn = ofono_dbus_get_connection();
+ const char *path = ofono_modem_get_path(modem);
+ gboolean state = FALSE;
+
+ DBG(modem: %p, modem);
+
+ if (modem-emergency_mode == 0)
+ return;
 

Can you be a bit more pedantic and send an ofono_error for this case?
We probably want to track whether some plugin abuses the reference counting.

   

+
+ if (modem-emergency_mode  1) {
+ modem-emergency_mode--;
+ return;
+ }
+
+ if (modem-modem_state == MODEM_STATE_ONLINE
+ modem-modem_state_pre_emergency

Re: [RFC PATCH 4/4] voicecall: add emergency call handling

2010-11-24 Thread Andras Domokos

Hi Denis,

On 11/23/2010 11:00 AM, ext Denis Kenzior wrote:

Hi Andras,

On 11/15/2010 10:58 AM, Andras Domokos wrote:
   

---
  src/voicecall.c |  111 ++-
  1 files changed, 110 insertions(+), 1 deletions(-)

diff --git a/src/voicecall.c b/src/voicecall.c
index 3af614b..066cdb9 100644
--- a/src/voicecall.c
+++ b/src/voicecall.c
@@ -52,6 +52,7 @@ struct ofono_voicecall {
   struct ofono_sim *sim;
   unsigned int sim_watch;
   unsigned int sim_state_watch;
+ unsigned int modem_online_watch;
   const struct ofono_voicecall_driver *driver;
   void *driver_data;
   struct ofono_atom *atom;
@@ -133,6 +134,22 @@ static void add_to_en_list(GSList **l, const char **list)
   *l = g_slist_prepend(*l, g_strdup(list[i++]));
  }

+static gint number_compare(gconstpointer a, gconstpointer b)
+{
+ const char *s1 = a, *s2 = b;
+ return strcmp(s1, s2);
+}
+
+static ofono_bool_t emergency_number(struct ofono_voicecall *vc,
+ const char *number)
+{
+ if (!number)
 

Just nit picking here, but in general we really prefer this to be
written like this:

if (number == NULL)

This is much easier to read when you don't know if number is a string or
an integer.  Yes I know we're not always consistent about doing this,
particularly in voicecall.c.

   

+ return FALSE;
+
+ return g_slist_find_custom(vc-en_list,
+ number, number_compare) ? TRUE : FALSE;
+}
+
  static const char *disconnect_reason_to_string(enum ofono_disconnect_reason r)
  {
   switch (r) {
@@ -1125,6 +1142,7 @@ static struct voicecall *dial_handle_result(struct 
ofono_voicecall *vc,
  static void manager_dial_callback(const struct ofono_error *error, void *data)
  {
   struct ofono_voicecall *vc = data;
+ struct ofono_modem *modem = __ofono_atom_get_modem(vc-atom);
   DBusMessage *reply;
   const char *number;
   gboolean need_to_emit;
@@ -1143,8 +1161,12 @@ 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 {
+ if (emergency_number(vc, number))
+ ofono_modem_dec_emergency_mode(modem);
+
   reply = __ofono_error_failed(vc-pending);
+ }

   __ofono_dbus_pending_reply(vc-pending, reply);

@@ -1156,6 +1178,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;
@@ -1195,6 +1218,15 @@ static DBusMessage *manager_dial(DBusConnection *conn,

   string_to_phone_number(number,ph);

+ if (emergency_number(vc, number)) {
+ ofono_bool_t online = ofono_modem_get_online(modem);
+
+ ofono_modem_inc_emergency_mode(modem);
+
+ if (!online)
 

Do me a favor and change this to:
if (online == FALSE)

   

+ return NULL;
+ }
+
   vc-driver-dial(vc,ph, clir, OFONO_CUG_OPTION_DEFAULT,
   manager_dial_callback, vc);

@@ -1748,6 +1780,7 @@ void ofono_voicecall_disconnected(struct ofono_voicecall 
*vc, int id,
   const struct ofono_error *error)
  {
   struct ofono_modem *modem = __ofono_atom_get_modem(vc-atom);
+ const char *number;
   GSList *l;
   struct voicecall *call;
   time_t ts;
@@ -1767,6 +1800,7 @@ void ofono_voicecall_disconnected(struct ofono_voicecall 
*vc, int id,
   }

   call = l-data;
+ number = phone_number_to_string(call-call-phone_number);

   ts = time(NULL);
   prev_status = call-call-status;
@@ -1805,6 +1839,9 @@ void ofono_voicecall_disconnected(struct ofono_voicecall 
*vc, int id,

   voicecalls_emit_call_removed(vc, call);

+ if (emergency_number(vc, number))
+ ofono_modem_dec_emergency_mode(modem);
+
   voicecall_dbus_unregister(vc, call);

   vc-call_list = g_slist_remove(vc-call_list, call);
@@ -2067,6 +2104,7 @@ static void voicecall_unregister(struct ofono_atom *atom)
  static void voicecall_remove(struct ofono_atom *atom)
  {
   struct ofono_voicecall *vc = __ofono_atom_get_data(atom);
+ struct ofono_modem *modem = __ofono_atom_get_modem(atom);

   DBG(atom: %p, atom);

@@ -2108,6 +2146,12 @@ static void voicecall_remove(struct ofono_atom *atom)
   g_queue_free(vc-toneq);
   }

+ if (vc-modem_online_watch) {
+ __ofono_modem_remove_online_watch(modem,
+ vc-modem_online_watch);
+ vc-modem_online_watch = 0;
+ }
+
   g_free(vc

[RFC PATCH 2/4] modem: add EmergencyMode property

2010-11-24 Thread Andras Domokos
---
 src/dbus.c  |7 +++
 src/modem.c |  137 +++
 src/ofono.h |5 ++
 3 files changed, 149 insertions(+), 0 deletions(-)

diff --git a/src/dbus.c b/src/dbus.c
index ad29241..0b4fc06 100644
--- a/src/dbus.c
+++ b/src/dbus.c
@@ -348,6 +348,13 @@ DBusMessage *__ofono_error_access_denied(DBusMessage *msg)
Operation not permitted);
 }
 
+DBusMessage *__ofono_error_emergency_active(DBusMessage *msg)
+{
+   return g_dbus_create_error(msg, OFONO_ERROR_INTERFACE
+   .EmergencyActive,
+   Emergency state active);
+}
+
 void __ofono_dbus_pending_reply(DBusMessage **msg, DBusMessage *reply)
 {
DBusConnection *conn = ofono_dbus_get_connection();
diff --git a/src/modem.c b/src/modem.c
index cfc767e..f005877 100644
--- a/src/modem.c
+++ b/src/modem.c
@@ -61,6 +61,7 @@ enum modem_state {
 struct ofono_modem {
char*path;
enum modem_statemodem_state;
+   enum modem_statemodem_state_pre_emergency;
GSList  *atoms;
struct ofono_watchlist  *atom_watches;
GSList  *interface_list;
@@ -73,6 +74,7 @@ struct ofono_modem {
guint   timeout;
ofono_bool_tonline;
struct ofono_watchlist  *online_watches;
+   unsigned intemergency;
GHashTable  *properties;
struct ofono_sim*sim;
unsigned intsim_watch;
@@ -517,6 +519,130 @@ static void offline_cb(const struct ofono_error *error, 
void *data)
modem_change_state(modem, MODEM_STATE_OFFLINE);
 }
 
+ofono_bool_t ofono_modem_get_emergency(struct ofono_modem *modem)
+{
+   if (modem == NULL)
+   return FALSE;
+
+   return modem-emergency != 0;
+}
+
+static void modem_change_online(struct ofono_modem *modem,
+   enum modem_state new_state)
+{
+   DBusConnection *conn = ofono_dbus_get_connection();
+   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 (new_online == modem-online)
+   return;
+
+   modem-modem_state = new_state;
+   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 emergency_online_cb(const struct ofono_error *error, void *data)
+{
+   struct ofono_modem *modem = data;
+
+   DBG(modem: %p, modem);
+
+   if (error-type == OFONO_ERROR_TYPE_NO_ERROR 
+   modem-modem_state != MODEM_STATE_ONLINE)
+   modem_change_online(modem, MODEM_STATE_ONLINE);
+}
+
+static void emergency_offline_cb(const struct ofono_error *error, void *data)
+{
+   struct ofono_modem *modem = data;
+   DBusConnection *conn = ofono_dbus_get_connection();
+   const char *path = ofono_modem_get_path(modem);
+   gboolean state = FALSE;
+
+   DBG(modem: %p, modem);
+
+   if (error-type == OFONO_ERROR_TYPE_NO_ERROR 
+   modem-modem_state == MODEM_STATE_ONLINE)
+   modem_change_online(modem, modem-modem_state_pre_emergency);
+
+   modem-emergency--;
+
+   ofono_dbus_signal_property_changed(conn, path,
+   OFONO_MODEM_INTERFACE,
+   Emergency,
+   DBUS_TYPE_BOOLEAN,
+   state);
+}
+
+void ofono_modem_inc_emergency(struct ofono_modem *modem)
+{
+   DBusConnection *conn = ofono_dbus_get_connection();
+   const char *path = ofono_modem_get_path(modem);
+   gboolean state = TRUE;
+
+   DBG(modem: %p, modem);
+
+   modem-emergency++;
+   if (modem-emergency  1)
+   return;
+
+   ofono_dbus_signal_property_changed(conn, path,
+   OFONO_MODEM_INTERFACE,
+   Emergency,
+   DBUS_TYPE_BOOLEAN,
+   state);
+
+   modem-modem_state_pre_emergency = modem-modem_state;
+
+   if (modem-modem_state == MODEM_STATE_ONLINE)
+   return;
+
+   modem-driver-set_online(modem, TRUE, emergency_online_cb, modem);
+}
+
+void ofono_modem_dec_emergency(struct ofono_modem *modem)
+{
+   DBusConnection *conn = ofono_dbus_get_connection();
+   const char *path = ofono_modem_get_path(modem);
+   gboolean state = FALSE;
+
+   DBG(modem: %p, modem);
+
+   if (modem-emergency 

Re: [PATCH 0/3] Long dial string support (2nd)

2010-11-23 Thread Andras Domokos

On 11/23/2010 07:41 PM, ext Denis Kenzior wrote:

On 11/22/2010 10:36 AM, Andras Domokos wrote:
   

Dial strings can now be as long as 120 digits (not counting '+'). This feature
is going to be needed by the FDN feature.

An FDN may consist of a phone number plus a DTMF string. In order to have the
call succeed when FDN is enabled, both parts need to be provided when making a
call, as a single dial string.
 

So as mentioned previously, oFono does not support FDN.  So why are we
doing this again?

   

Even if we don't support FDN at this point, there is still a remaining
related issue, who we are going to dial numbers like:

12345456p1234#

I think the the dial string could still be passed to the voicecall driver
that will take care of the modem specific details, most importantly
playing the DTMF tones and generating the tone events that would be
propagated back to voicecall manager and to D-Bus from there.

For AT modems the long dial string can be and has to be passed as is to the
 

Most AT modems have serious limitations on how many characters are
supported in the dial string.  Not to mention that the pause character
doesn't really always work.

I can understand supporting long dialing numbers, but supporting dial
strings is something else entirely...

Regards,
-Denis
   

Regards,
Andras

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


[PATCH 0/5] Call Counters (2nd)

2010-11-22 Thread Andras Domokos
Here a proposal for call counters implementation for keeping track
of the total incoming and outgoing call duration counters. Each
established call instance is contributing to either of the call
duration counters. The 2 counters are updated periodically when
there is an established call and the information is stored in
a file. The bookkeeping of the call duration counters are per IMSI
number.
The implementation makes use of the history framework which had to be
expanded with a function for marking the beginning of a voice call.
There is a D-Bus interface to call counters for reading and clearing
the counters.

Andras Domokos (5):
  history: expand history API include file
  history: expand history API
  voicecall: take into use the new history function
  plugins: add call counters
  doc: call counters API doc

 Makefile.am  |3 +
 doc/callcounters-api.txt |   18 ++
 include/history.h|3 +
 plugins/callcounters.c   |  388 ++
 src/history.c|   24 +++
 src/ofono.h  |4 +
 src/voicecall.c  |3 +
 7 files changed, 443 insertions(+), 0 deletions(-)
 create mode 100644 doc/callcounters-api.txt
 create mode 100644 plugins/callcounters.c

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


[RFC PATCH 2/5] history: expand history API

2010-11-22 Thread Andras Domokos
---
 src/history.c |   24 
 src/ofono.h   |4 
 2 files changed, 28 insertions(+), 0 deletions(-)

diff --git a/src/history.c b/src/history.c
index 0229cf5..31efadb 100644
--- a/src/history.c
+++ b/src/history.c
@@ -114,6 +114,30 @@ void __ofono_history_probe_drivers(struct ofono_modem 
*modem)
}
 }
 
+static void history_call_started(struct ofono_atom *atom, void *data)
+{
+   struct ofono_history_context *context = __ofono_atom_get_data(atom);
+   struct history_call_foreach_data *hfd = data;
+
+   if (context-driver-call_started == NULL)
+   return;
+
+   context-driver-call_started(context, hfd-call, hfd-start);
+}
+
+void __ofono_history_call_started(struct ofono_modem *modem,
+   const struct ofono_call *call,
+   time_t start)
+{
+   struct history_call_foreach_data hfd;
+
+   hfd.call = call;
+   hfd.start = start;
+
+   __ofono_modem_foreach_atom(modem, OFONO_ATOM_TYPE_HISTORY,
+   history_call_started, hfd);
+}
+
 static void history_call_ended(struct ofono_atom *atom, void *data)
 {
struct ofono_history_context *context = __ofono_atom_get_data(atom);
diff --git a/src/ofono.h b/src/ofono.h
index 4d76d20..61a0637 100644
--- a/src/ofono.h
+++ b/src/ofono.h
@@ -368,6 +368,10 @@ void __ofono_netreg_set_base_station_name(struct 
ofono_netreg *netreg,
 
 void __ofono_history_probe_drivers(struct ofono_modem *modem);
 
+void __ofono_history_call_started(struct ofono_modem *modem,
+   const struct ofono_call *call,
+   time_t start);
+
 void __ofono_history_call_ended(struct ofono_modem *modem,
const struct ofono_call *call,
time_t start, time_t end);
-- 
1.7.0.4

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


[RFC PATCH 3/5] voicecall: take into use the new history function

2010-11-22 Thread Andras Domokos
---
 src/voicecall.c |3 +++
 1 files changed, 3 insertions(+), 0 deletions(-)

diff --git a/src/voicecall.c b/src/voicecall.c
index bd64432..b40d284 100644
--- a/src/voicecall.c
+++ b/src/voicecall.c
@@ -630,6 +630,7 @@ static void voicecall_emit_multiparty(struct voicecall 
*call, gboolean mpty)
 
 static void voicecall_set_call_status(struct voicecall *call, int status)
 {
+   struct ofono_modem *modem = __ofono_atom_get_modem(call-vc-atom);
DBusConnection *conn = ofono_dbus_get_connection();
const char *path;
const char *status_str;
@@ -658,6 +659,8 @@ static void voicecall_set_call_status(struct voicecall 
*call, int status)
const char *timestr;
 
call-start_time = time(NULL);
+   __ofono_history_call_started(modem, call-call,
+   call-start_time);
timestr = time_to_str(call-start_time);
 
ofono_dbus_signal_property_changed(conn, path,
-- 
1.7.0.4

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


[RFC PATCH 1/3] common: add long dial string support

2010-11-22 Thread Andras Domokos
---
 include/types.h |2 +-
 src/common.c|   38 +-
 src/common.h|1 +
 3 files changed, 35 insertions(+), 6 deletions(-)

diff --git a/include/types.h b/include/types.h
index ba2481f..b3d2247 100644
--- a/include/types.h
+++ b/include/types.h
@@ -76,7 +76,7 @@ struct ofono_error {
int error;
 };
 
-#define OFONO_MAX_PHONE_NUMBER_LENGTH 20
+#define OFONO_MAX_PHONE_NUMBER_LENGTH 120
 
 struct ofono_phone_number {
char number[OFONO_MAX_PHONE_NUMBER_LENGTH + 1];
diff --git a/src/common.c b/src/common.c
index b5b9a6f..56a6aa8 100644
--- a/src/common.c
+++ b/src/common.c
@@ -262,6 +262,34 @@ gboolean valid_phone_number_format(const char *number)
return TRUE;
 }
 
+gboolean valid_dial_string(const char *number)
+{
+   int len = strlen(number);
+   int begin = 0;
+   int i;
+
+   if (!len)
+   return FALSE;
+
+   if (number[0] == '+')
+   begin = 1;
+
+   if ((len - begin)  OFONO_MAX_PHONE_NUMBER_LENGTH)
+   return FALSE;
+
+   for (i = begin; i  len; i++) {
+   if (number[i] = '0'  number[i] = '9')
+   continue;
+
+   if (number[i] == '*' || number[i] == '#' || number[i] == 'p')
+   continue;
+
+   return FALSE;
+   }
+
+   return TRUE;
+}
+
 const char *telephony_error_to_str(const struct ofono_error *error)
 {
struct error_entry *e;
@@ -379,18 +407,18 @@ int mmi_service_code_to_bearer_class(int code)
 
 const char *phone_number_to_string(const struct ofono_phone_number *ph)
 {
-   static char buffer[64];
+   static char buffer[(OFONO_MAX_PHONE_NUMBER_LENGTH + 1) + 1];
 
if (ph-type == 145  (strlen(ph-number)  0) 
ph-number[0] != '+') {
buffer[0] = '+';
-   strncpy(buffer + 1, ph-number, 62);
-   buffer[63] = '\0';
+   strncpy(buffer + 1, ph-number, sizeof(buffer) - 2);
} else {
-   strncpy(buffer, ph-number, 63);
-   buffer[63] = '\0';
+   strncpy(buffer, ph-number, sizeof(buffer) - 1);
}
 
+   buffer[sizeof(buffer) - 1] = '\0';
+
return buffer;
 }
 
diff --git a/src/common.h b/src/common.h
index 8b5798a..c7bfe26 100644
--- a/src/common.h
+++ b/src/common.h
@@ -125,6 +125,7 @@ enum pin_type {
 const char *telephony_error_to_str(const struct ofono_error *error);
 
 gboolean valid_phone_number_format(const char *number);
+gboolean valid_dial_string(const char *number);
 const char *phone_number_to_string(const struct ofono_phone_number *ph);
 void string_to_phone_number(const char *str, struct ofono_phone_number *ph);
 
-- 
1.7.0.4

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


[RFC PATCH 3/3] isimodem/voicecall: add long dial string support

2010-11-22 Thread Andras Domokos
---
 drivers/isimodem/voicecall.c |   83 +-
 1 files changed, 65 insertions(+), 18 deletions(-)

diff --git a/drivers/isimodem/voicecall.c b/drivers/isimodem/voicecall.c
index c3365f6..b0dad72 100644
--- a/drivers/isimodem/voicecall.c
+++ b/drivers/isimodem/voicecall.c
@@ -49,7 +49,7 @@ struct isi_call {
uint8_t id, call_id, status, mode, mode_info, cause_type, cause;
uint8_t addr_type, presentation;
uint8_t reason;
-   char address[20], addr_pad[4];
+   char address[OFONO_MAX_PHONE_NUMBER_LENGTH + 1], addr_pad[4];
 };
 
 struct isi_voicecall {
@@ -244,6 +244,28 @@ static void isi_call_destination_address_sb_proc(struct 
isi_voicecall *ivc,
isi_call_any_address_sb_proc(ivc, call, sb);
 }
 
+static void isi_call_destination_post_address_sb_proc(struct isi_voicecall 
*ivc,
+   struct isi_call *call,
+   GIsiSubBlockIter const *sb)
+{
+   uint8_t addr_info, addr_len;
+   char *address;
+
+   if (!call-address[0] ||
+   strlen(call-address) = OFONO_MAX_PHONE_NUMBER_LENGTH)
+   return;
+
+   if (!g_isi_sb_iter_get_byte(sb, addr_info, 2) ||
+   !g_isi_sb_iter_get_byte(sb, addr_len, 3) ||
+   !g_isi_sb_iter_get_alpha_tag(sb, address, 2 * addr_len, 4))
+   return;
+
+   strncat(call-address, address,
+   OFONO_MAX_PHONE_NUMBER_LENGTH - strlen(call-address));
+   g_free(address);
+
+}
+
 static void isi_call_mode_sb_proc(struct isi_voicecall *ivc,
struct isi_call *call,
GIsiSubBlockIter const *sb)
@@ -371,40 +393,61 @@ static struct isi_call_req_context *
 isi_call_create_req(struct ofono_voicecall *ovc,
uint8_t presentation,
uint8_t addr_type,
-   char const address[21],
+   char const address[OFONO_MAX_PHONE_NUMBER_LENGTH + 1],
ofono_voicecall_cb_t cb,
void *data)
 {
-   size_t addr_len = strlen(address);
-   size_t sub_len = (6 + 2 * addr_len + 3)  ~3;
-   size_t i, offset = 3 + 4 + 8 + 6;
-   uint8_t req[3 + 4 + 8 + 6 + 40] = {
+   uint8_t req[3 + 4 + 8 + 10 + 2 * OFONO_MAX_PHONE_NUMBER_LENGTH + 4] = {
CALL_CREATE_REQ,
0,  /* No id */
-   3,  /* Mode, Clir, Number */
+   4,  /* Mode, Clir, Number, Postfix */
/* MODE SB */
CALL_MODE, 4, CALL_MODE_SPEECH, CALL_MODE_INFO_NONE,
/* ORIGIN_INFO SB */
CALL_ORIGIN_INFO, 8, presentation, 0, 0, 0, 0, 0,
/* DESTINATION_ADDRESS SB */
CALL_DESTINATION_ADDRESS,
-   sub_len,
+   0,  /* sub_len */
addr_type  0x7F,
0, 0,
-   addr_len,
-   /* uint16_t addr[20] */
+   0,  /* addr_len */
+   /* uint16_t addr[OFONO_MAX_PHONE_NUMBER_LENGTH] */
};
-   size_t rlen = 3 + 4 + 8 + sub_len;
+   size_t i, j, offset;
 
-   if (addr_len  20) {
-   CALLBACK_WITH_FAILURE(cb, data);
-   return NULL;
+   offset = 3 + 4 + 8;
+   for (i = 0, j = 0; address[i]; i++, j++) {
+   if (i  OFONO_MAX_PHONE_NUMBER_LENGTH)
+   goto out;
+   if (address[i] != '*')
+   break;
+   req[offset + 6 + 2 * j + 1] = address[i];
}
 
-   for (i = 0; i  addr_len; i++)
-   req[offset + 2 * i + 1] = address[i];
+   for (; address[i]; i++, j++) {
+   if (i  OFONO_MAX_PHONE_NUMBER_LENGTH)
+   goto out;
+   if (address[i] == '*' || address[i] == 'p' || address[i] == '#')
+   break;
+   req[offset + 6 + 2 * j + 1] = address[i];
+   }
+   req[offset + 5] = j;
+   offset += (req[offset + 1] = (6 + 2 * j + 3)  ~3);
+
+   req[offset + 0] = CALL_DESTINATION_POST_ADDRESS;
+   for (j = 0; address[i]; i++, j++) {
+   if (i  OFONO_MAX_PHONE_NUMBER_LENGTH)
+   goto out;
+   req[offset + 4 + 2 * j + 1] = address[i];
+   }
+   req[offset + 3] = j;
+   offset += (req[offset + 1] = (4 + 2 * j + 3)  ~3);
 
-   return isi_call_req(ovc, req, rlen, isi_call_create_resp, cb, data);
+   return isi_call_req(ovc, req, offset, isi_call_create_resp, cb, data);
+
+out:
+   CALLBACK_WITH_FAILURE(cb, data);
+   return NULL;
 }
 
 static gboolean isi_call_create_resp(GIsiClient *client,
@@ -477,13 +520,17 @@ static void isi_call_status_ind_cb(GIsiClient *client,

[RFC PATCH 2/3] voicecall: add long dial string support

2010-11-22 Thread Andras Domokos
---
 src/voicecall.c |6 +++---
 1 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/src/voicecall.c b/src/voicecall.c
index bd64432..4022f36 100644
--- a/src/voicecall.c
+++ b/src/voicecall.c
@@ -408,7 +408,7 @@ static DBusMessage *voicecall_deflect(DBusConnection *conn,
DBUS_TYPE_INVALID) == FALSE)
return __ofono_error_invalid_args(msg);
 
-   if (!valid_phone_number_format(number))
+   if (!valid_dial_string(number))
return __ofono_error_invalid_format(msg);
 
vc-pending = dbus_message_ref(msg);
@@ -1172,7 +1172,7 @@ static DBusMessage *manager_dial(DBusConnection *conn,
DBUS_TYPE_INVALID) == FALSE)
return __ofono_error_invalid_args(msg);
 
-   if (!valid_phone_number_format(number))
+   if (!valid_dial_string(number))
return __ofono_error_invalid_format(msg);
 
if (clir_string_to_clir(clirstr, clir) == FALSE)
@@ -2360,7 +2360,7 @@ int __ofono_voicecall_dial(struct ofono_voicecall *vc,
 {
struct dial_request *req;
 
-   if (!valid_phone_number_format(addr))
+   if (!valid_dial_string(addr))
return -EINVAL;
 
if (!vc-driver-dial)
-- 
1.7.0.4

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


[RFC PATCH 2/2] isimodem/voicecall: add long dial string support

2010-11-16 Thread Andras Domokos
---
 drivers/isimodem/voicecall.c |   83 +-
 1 files changed, 65 insertions(+), 18 deletions(-)

diff --git a/drivers/isimodem/voicecall.c b/drivers/isimodem/voicecall.c
index c3365f6..b0dad72 100644
--- a/drivers/isimodem/voicecall.c
+++ b/drivers/isimodem/voicecall.c
@@ -49,7 +49,7 @@ struct isi_call {
uint8_t id, call_id, status, mode, mode_info, cause_type, cause;
uint8_t addr_type, presentation;
uint8_t reason;
-   char address[20], addr_pad[4];
+   char address[OFONO_MAX_PHONE_NUMBER_LENGTH + 1], addr_pad[4];
 };
 
 struct isi_voicecall {
@@ -244,6 +244,28 @@ static void isi_call_destination_address_sb_proc(struct 
isi_voicecall *ivc,
isi_call_any_address_sb_proc(ivc, call, sb);
 }
 
+static void isi_call_destination_post_address_sb_proc(struct isi_voicecall 
*ivc,
+   struct isi_call *call,
+   GIsiSubBlockIter const *sb)
+{
+   uint8_t addr_info, addr_len;
+   char *address;
+
+   if (!call-address[0] ||
+   strlen(call-address) = OFONO_MAX_PHONE_NUMBER_LENGTH)
+   return;
+
+   if (!g_isi_sb_iter_get_byte(sb, addr_info, 2) ||
+   !g_isi_sb_iter_get_byte(sb, addr_len, 3) ||
+   !g_isi_sb_iter_get_alpha_tag(sb, address, 2 * addr_len, 4))
+   return;
+
+   strncat(call-address, address,
+   OFONO_MAX_PHONE_NUMBER_LENGTH - strlen(call-address));
+   g_free(address);
+
+}
+
 static void isi_call_mode_sb_proc(struct isi_voicecall *ivc,
struct isi_call *call,
GIsiSubBlockIter const *sb)
@@ -371,40 +393,61 @@ static struct isi_call_req_context *
 isi_call_create_req(struct ofono_voicecall *ovc,
uint8_t presentation,
uint8_t addr_type,
-   char const address[21],
+   char const address[OFONO_MAX_PHONE_NUMBER_LENGTH + 1],
ofono_voicecall_cb_t cb,
void *data)
 {
-   size_t addr_len = strlen(address);
-   size_t sub_len = (6 + 2 * addr_len + 3)  ~3;
-   size_t i, offset = 3 + 4 + 8 + 6;
-   uint8_t req[3 + 4 + 8 + 6 + 40] = {
+   uint8_t req[3 + 4 + 8 + 10 + 2 * OFONO_MAX_PHONE_NUMBER_LENGTH + 4] = {
CALL_CREATE_REQ,
0,  /* No id */
-   3,  /* Mode, Clir, Number */
+   4,  /* Mode, Clir, Number, Postfix */
/* MODE SB */
CALL_MODE, 4, CALL_MODE_SPEECH, CALL_MODE_INFO_NONE,
/* ORIGIN_INFO SB */
CALL_ORIGIN_INFO, 8, presentation, 0, 0, 0, 0, 0,
/* DESTINATION_ADDRESS SB */
CALL_DESTINATION_ADDRESS,
-   sub_len,
+   0,  /* sub_len */
addr_type  0x7F,
0, 0,
-   addr_len,
-   /* uint16_t addr[20] */
+   0,  /* addr_len */
+   /* uint16_t addr[OFONO_MAX_PHONE_NUMBER_LENGTH] */
};
-   size_t rlen = 3 + 4 + 8 + sub_len;
+   size_t i, j, offset;
 
-   if (addr_len  20) {
-   CALLBACK_WITH_FAILURE(cb, data);
-   return NULL;
+   offset = 3 + 4 + 8;
+   for (i = 0, j = 0; address[i]; i++, j++) {
+   if (i  OFONO_MAX_PHONE_NUMBER_LENGTH)
+   goto out;
+   if (address[i] != '*')
+   break;
+   req[offset + 6 + 2 * j + 1] = address[i];
}
 
-   for (i = 0; i  addr_len; i++)
-   req[offset + 2 * i + 1] = address[i];
+   for (; address[i]; i++, j++) {
+   if (i  OFONO_MAX_PHONE_NUMBER_LENGTH)
+   goto out;
+   if (address[i] == '*' || address[i] == 'p' || address[i] == '#')
+   break;
+   req[offset + 6 + 2 * j + 1] = address[i];
+   }
+   req[offset + 5] = j;
+   offset += (req[offset + 1] = (6 + 2 * j + 3)  ~3);
+
+   req[offset + 0] = CALL_DESTINATION_POST_ADDRESS;
+   for (j = 0; address[i]; i++, j++) {
+   if (i  OFONO_MAX_PHONE_NUMBER_LENGTH)
+   goto out;
+   req[offset + 4 + 2 * j + 1] = address[i];
+   }
+   req[offset + 3] = j;
+   offset += (req[offset + 1] = (4 + 2 * j + 3)  ~3);
 
-   return isi_call_req(ovc, req, rlen, isi_call_create_resp, cb, data);
+   return isi_call_req(ovc, req, offset, isi_call_create_resp, cb, data);
+
+out:
+   CALLBACK_WITH_FAILURE(cb, data);
+   return NULL;
 }
 
 static gboolean isi_call_create_resp(GIsiClient *client,
@@ -477,13 +520,17 @@ static void isi_call_status_ind_cb(GIsiClient *client,

[RFC PATCH 1/2] common: add long dial string support

2010-11-16 Thread Andras Domokos
---
 include/types.h |2 +-
 src/common.c|   12 ++--
 2 files changed, 7 insertions(+), 7 deletions(-)

diff --git a/include/types.h b/include/types.h
index ba2481f..b3d2247 100644
--- a/include/types.h
+++ b/include/types.h
@@ -76,7 +76,7 @@ struct ofono_error {
int error;
 };
 
-#define OFONO_MAX_PHONE_NUMBER_LENGTH 20
+#define OFONO_MAX_PHONE_NUMBER_LENGTH 120
 
 struct ofono_phone_number {
char number[OFONO_MAX_PHONE_NUMBER_LENGTH + 1];
diff --git a/src/common.c b/src/common.c
index b5b9a6f..de5a508 100644
--- a/src/common.c
+++ b/src/common.c
@@ -253,7 +253,7 @@ gboolean valid_phone_number_format(const char *number)
if (number[i] = '0'  number[i] = '9')
continue;
 
-   if (number[i] == '*' || number[i] == '#')
+   if (number[i] == '*' || number[i] == '#' || number[i] == 'p')
continue;
 
return FALSE;
@@ -379,18 +379,18 @@ int mmi_service_code_to_bearer_class(int code)
 
 const char *phone_number_to_string(const struct ofono_phone_number *ph)
 {
-   static char buffer[64];
+   static char buffer[(OFONO_MAX_PHONE_NUMBER_LENGTH + 1) + 1];
 
if (ph-type == 145  (strlen(ph-number)  0) 
ph-number[0] != '+') {
buffer[0] = '+';
-   strncpy(buffer + 1, ph-number, 62);
-   buffer[63] = '\0';
+   strncpy(buffer + 1, ph-number, sizeof(buffer) - 2);
} else {
-   strncpy(buffer, ph-number, 63);
-   buffer[63] = '\0';
+   strncpy(buffer, ph-number, sizeof(buffer) - 1);
}
 
+   buffer[sizeof(buffer) - 1] = '\0';
+
return buffer;
 }
 
-- 
1.7.0.4

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


[PATCH 0/5] Call Counters

2010-11-15 Thread Andras Domokos
Here a proposal for call counters implementation for keeping track
of the total incoming and outgoing call duration counters. Each
established call instance is contributing to either of the call
duration counters. The 2 counters are updated periodically when
there is an established call and the information is stored in
a file. The bookkeeping of the call duration counters are per IMSI
number.
The implementation makes use of the history framework which had to be
expanded with a function for marking the beginning of a voice call.
There is a D-Bus interface to call counters for reading and clearing
the counters.

Andras Domokos (5):
  history: expand history API include file
  history: expand history API
  voicecall: take into use the new history function
  voicecall: add call counters
  Makefile: add call counters to the build

 Makefile.am|3 +
 include/history.h  |3 +
 src/callcounters.c |  388 
 src/history.c  |   24 
 src/ofono.h|4 +
 src/voicecall.c|3 +
 6 files changed, 425 insertions(+), 0 deletions(-)
 create mode 100644 src/callcounters.c

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


[RFC PATCH 2/5] history: expand history API

2010-11-15 Thread Andras Domokos
---
 src/history.c |   24 
 1 files changed, 24 insertions(+), 0 deletions(-)

diff --git a/src/history.c b/src/history.c
index 0229cf5..31efadb 100644
--- a/src/history.c
+++ b/src/history.c
@@ -114,6 +114,30 @@ void __ofono_history_probe_drivers(struct ofono_modem 
*modem)
}
 }
 
+static void history_call_started(struct ofono_atom *atom, void *data)
+{
+   struct ofono_history_context *context = __ofono_atom_get_data(atom);
+   struct history_call_foreach_data *hfd = data;
+
+   if (context-driver-call_started == NULL)
+   return;
+
+   context-driver-call_started(context, hfd-call, hfd-start);
+}
+
+void __ofono_history_call_started(struct ofono_modem *modem,
+   const struct ofono_call *call,
+   time_t start)
+{
+   struct history_call_foreach_data hfd;
+
+   hfd.call = call;
+   hfd.start = start;
+
+   __ofono_modem_foreach_atom(modem, OFONO_ATOM_TYPE_HISTORY,
+   history_call_started, hfd);
+}
+
 static void history_call_ended(struct ofono_atom *atom, void *data)
 {
struct ofono_history_context *context = __ofono_atom_get_data(atom);
-- 
1.7.0.4

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


[RFC PATCH 1/5] history: expand history API include file

2010-11-15 Thread Andras Domokos
---
 include/history.h |3 +++
 src/ofono.h   |4 
 2 files changed, 7 insertions(+), 0 deletions(-)

diff --git a/include/history.h b/include/history.h
index c1c4aa1..a2490f6 100644
--- a/include/history.h
+++ b/include/history.h
@@ -49,6 +49,9 @@ struct ofono_history_driver {
const char *name;
int (*probe)(struct ofono_history_context *context);
void (*remove)(struct ofono_history_context *context);
+   void (*call_started)(struct ofono_history_context *context,
+   const struct ofono_call *call,
+   time_t start);
void (*call_ended)(struct ofono_history_context *context,
const struct ofono_call *call,
time_t start, time_t end);
diff --git a/src/ofono.h b/src/ofono.h
index 4d76d20..61a0637 100644
--- a/src/ofono.h
+++ b/src/ofono.h
@@ -368,6 +368,10 @@ void __ofono_netreg_set_base_station_name(struct 
ofono_netreg *netreg,
 
 void __ofono_history_probe_drivers(struct ofono_modem *modem);
 
+void __ofono_history_call_started(struct ofono_modem *modem,
+   const struct ofono_call *call,
+   time_t start);
+
 void __ofono_history_call_ended(struct ofono_modem *modem,
const struct ofono_call *call,
time_t start, time_t end);
-- 
1.7.0.4

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


Re: [PATCH 0/4] Emergency Calls (3rd round)

2010-11-15 Thread Andras Domokos

Hi Frederic,

I found a small issue in these patches, resulting into improper handling 
of the emergency calls for the non-SIM cases, but now that has been 
fixed and I am going to create a new set of patches.


The answer to your question is yes, emergency calls will be also 
possible without a SIM card.


Andras

On 11/15/2010 12:45 PM, ext Predon, Frederic wrote:

Hi Andras,

   

Here is a new proposal for emergency calls handling.

Steps in handling emergency calls:
- subscribe to modem online notifications (add modem online watcher)
- an emergency call detected (phone number is emergency number)
- increment emergency mode
   - advertise EmergencyMode property change on D-Bus (first call)
   - set modem online if it's in offline mode (minimal setup)
 - adevertise Online property change on D-Bus
- if modem is not online postpone making the call, otherwise make
   the emergency call
- when modem online notification comes and there is postponed call
request
   make the emergency call
- when an emergency call ends decrement emergency mode
   - set modem offline if it was set online due to the emergency call
(last call)
 - advertise Online property change on D-Bus
   - advertise EmergencyMode property change on D-Bus (last call)
 

Do you handle the case of making an emergency call when there is no SIM card?

Fred
-
Intel Corporation SAS (French simplified joint stock company)
Registered headquarters: Les Montalets- 2, rue de Paris,
92196 Meudon Cedex, France
Registration Number:  302 456 199 R.C.S. NANTERRE
Capital: 4,572,000 Euros

This e-mail and any attachments may contain confidential material for
the sole use of the intended recipient(s). Any review or distribution
by others is strictly prohibited. If you are not the intended
recipient, please contact the sender and delete all copies.

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


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


[RFC PATCH 4/4] voicecall: add emergency call handling

2010-11-15 Thread Andras Domokos
---
 src/voicecall.c |  111 ++-
 1 files changed, 110 insertions(+), 1 deletions(-)

diff --git a/src/voicecall.c b/src/voicecall.c
index 3af614b..066cdb9 100644
--- a/src/voicecall.c
+++ b/src/voicecall.c
@@ -52,6 +52,7 @@ struct ofono_voicecall {
struct ofono_sim *sim;
unsigned int sim_watch;
unsigned int sim_state_watch;
+   unsigned int modem_online_watch;
const struct ofono_voicecall_driver *driver;
void *driver_data;
struct ofono_atom *atom;
@@ -133,6 +134,22 @@ static void add_to_en_list(GSList **l, const char **list)
*l = g_slist_prepend(*l, g_strdup(list[i++]));
 }
 
+static gint number_compare(gconstpointer a, gconstpointer b)
+{
+   const char *s1 = a, *s2 = b;
+   return strcmp(s1, s2);
+}
+
+static ofono_bool_t emergency_number(struct ofono_voicecall *vc,
+   const char *number)
+{
+   if (!number)
+   return FALSE;
+
+   return g_slist_find_custom(vc-en_list,
+   number, number_compare) ? TRUE : FALSE;
+}
+
 static const char *disconnect_reason_to_string(enum ofono_disconnect_reason r)
 {
switch (r) {
@@ -1125,6 +1142,7 @@ static struct voicecall *dial_handle_result(struct 
ofono_voicecall *vc,
 static void manager_dial_callback(const struct ofono_error *error, void *data)
 {
struct ofono_voicecall *vc = data;
+   struct ofono_modem *modem = __ofono_atom_get_modem(vc-atom);
DBusMessage *reply;
const char *number;
gboolean need_to_emit;
@@ -1143,8 +1161,12 @@ 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 {
+   if (emergency_number(vc, number))
+   ofono_modem_dec_emergency_mode(modem);
+
reply = __ofono_error_failed(vc-pending);
+   }
 
__ofono_dbus_pending_reply(vc-pending, reply);
 
@@ -1156,6 +1178,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;
@@ -1195,6 +1218,15 @@ static DBusMessage *manager_dial(DBusConnection *conn,
 
string_to_phone_number(number, ph);
 
+   if (emergency_number(vc, number)) {
+   ofono_bool_t online = ofono_modem_get_online(modem);
+
+   ofono_modem_inc_emergency_mode(modem);
+
+   if (!online)
+   return NULL;
+   }
+
vc-driver-dial(vc, ph, clir, OFONO_CUG_OPTION_DEFAULT,
manager_dial_callback, vc);
 
@@ -1748,6 +1780,7 @@ void ofono_voicecall_disconnected(struct ofono_voicecall 
*vc, int id,
const struct ofono_error *error)
 {
struct ofono_modem *modem = __ofono_atom_get_modem(vc-atom);
+   const char *number;
GSList *l;
struct voicecall *call;
time_t ts;
@@ -1767,6 +1800,7 @@ void ofono_voicecall_disconnected(struct ofono_voicecall 
*vc, int id,
}
 
call = l-data;
+   number = phone_number_to_string(call-call-phone_number);
 
ts = time(NULL);
prev_status = call-call-status;
@@ -1805,6 +1839,9 @@ void ofono_voicecall_disconnected(struct ofono_voicecall 
*vc, int id,
 
voicecalls_emit_call_removed(vc, call);
 
+   if (emergency_number(vc, number))
+   ofono_modem_dec_emergency_mode(modem);
+
voicecall_dbus_unregister(vc, call);
 
vc-call_list = g_slist_remove(vc-call_list, call);
@@ -2067,6 +2104,7 @@ static void voicecall_unregister(struct ofono_atom *atom)
 static void voicecall_remove(struct ofono_atom *atom)
 {
struct ofono_voicecall *vc = __ofono_atom_get_data(atom);
+   struct ofono_modem *modem = __ofono_atom_get_modem(atom);
 
DBG(atom: %p, atom);
 
@@ -2108,6 +2146,12 @@ static void voicecall_remove(struct ofono_atom *atom)
g_queue_free(vc-toneq);
}
 
+   if (vc-modem_online_watch) {
+   __ofono_modem_remove_online_watch(modem,
+   vc-modem_online_watch);
+   vc-modem_online_watch = 0;
+   }
+
g_free(vc);
 }
 
@@ -2205,6 +2249,7 @@ static void sim_watch(struct ofono_atom *atom,
 static void dial_request_cb(const struct ofono_error *error, void *data)
 {
struct ofono_voicecall *vc = data;
+   struct ofono_modem *modem = __ofono_atom_get_modem(vc-atom);
gboolean need_to_emit;
struct voicecall *v;
 
@@ -2214,6 +2259,9 @@ static void 

[RFC PATCH 1/4] modem: add modem online-offline watch

2010-11-15 Thread Andras Domokos
From: Andras Domokos andras.domo...@nokia.com

---
 src/modem.c |   46 ++
 src/ofono.h |8 
 2 files changed, 54 insertions(+), 0 deletions(-)

diff --git a/src/modem.c b/src/modem.c
index 3776461..f73cc1d 100644
--- a/src/modem.c
+++ b/src/modem.c
@@ -72,6 +72,7 @@ struct ofono_modem {
ofono_bool_tpowered_pending;
guint   timeout;
ofono_bool_tonline;
+   struct ofono_watchlist  *online_watches;
GHashTable  *properties;
struct ofono_sim*sim;
unsigned intsim_watch;
@@ -362,6 +363,22 @@ static void flush_atoms(struct ofono_modem *modem, enum 
modem_state new_state)
}
 }
 
+static void notify_online_watches(struct ofono_modem *modem)
+{
+   struct ofono_watchlist_item *item;
+   GSList *l;
+   ofono_modem_online_notify_func notify;
+
+   if (modem-online_watches == NULL)
+   return;
+
+   for (l = modem-online_watches-items; l; l = l-next) {
+   item = l-data;
+   notify = item-notify;
+   notify(modem-online, item-notify_data);
+   }
+}
+
 static void modem_change_state(struct ofono_modem *modem,
enum modem_state new_state)
 {
@@ -404,11 +421,13 @@ static void modem_change_state(struct ofono_modem *modem,
__ofono_history_probe_drivers(modem);
__ofono_nettime_probe_drivers(modem);
}
+   notify_online_watches(modem);
break;
 
case MODEM_STATE_ONLINE:
if (driver-post_online)
driver-post_online(modem);
+   notify_online_watches(modem);
break;
}
 }
@@ -437,6 +456,29 @@ static void sim_state_watch(enum ofono_sim_state 
new_state, void *user)
}
 }
 
+unsigned __ofono_modem_add_online_watch(struct ofono_modem *modem,
+   ofono_modem_online_notify_func notify,
+   void *data, ofono_destroy_func destroy)
+{
+   struct ofono_watchlist_item *item;
+
+   if (modem == NULL || notify == NULL)
+   return 0;
+
+   item = g_new0(struct ofono_watchlist_item, 1);
+
+   item-notify = notify;
+   item-destroy = destroy;
+   item-notify_data = data;
+
+   return __ofono_watchlist_add_item(modem-online_watches, item);
+}
+
+void __ofono_modem_remove_online_watch(struct ofono_modem *modem, unsigned id)
+{
+   __ofono_watchlist_remove_item(modem-online_watches, id);
+}
+
 static void online_cb(const struct ofono_error *error, void *data)
 {
struct ofono_modem *modem = data;
@@ -1472,6 +1514,7 @@ int ofono_modem_register(struct ofono_modem *modem)
modem-driver_type = NULL;
 
modem-atom_watches = __ofono_watchlist_new(g_free);
+   modem-online_watches = __ofono_watchlist_new(g_free);
 
emit_modem_added(modem);
call_modemwatches(modem, TRUE);
@@ -1503,6 +1546,9 @@ static void modem_unregister(struct ofono_modem *modem)
__ofono_watchlist_free(modem-atom_watches);
modem-atom_watches = NULL;
 
+   __ofono_watchlist_free(modem-online_watches);
+   modem-online_watches = NULL;
+
modem-sim_watch = 0;
modem-sim_ready_watch = 0;
 
diff --git a/src/ofono.h b/src/ofono.h
index ab6ecd2..01cd6c0 100644
--- a/src/ofono.h
+++ b/src/ofono.h
@@ -177,6 +177,14 @@ unsigned int __ofono_modemwatch_add(ofono_modemwatch_cb_t 
cb, void *user,
ofono_destroy_func destroy);
 gboolean __ofono_modemwatch_remove(unsigned int id);
 
+typedef void (*ofono_modem_online_notify_func)(ofono_bool_t online,
+   void *data);
+unsigned int __ofono_modem_add_online_watch(struct ofono_modem *modem,
+   ofono_modem_online_notify_func notify,
+   void *data, ofono_destroy_func destroy);
+void __ofono_modem_remove_online_watch(struct ofono_modem *modem,
+   unsigned int id);
+
 #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 2/4] modem: add EmergencyMode property

2010-11-13 Thread Andras Domokos
From: Andras Domokos andras.domo...@nokia.com

---
 src/modem.c |  132 +++
 src/ofono.h |4 ++
 2 files changed, 136 insertions(+), 0 deletions(-)

diff --git a/src/modem.c b/src/modem.c
index f73cc1d..5315e72 100644
--- a/src/modem.c
+++ b/src/modem.c
@@ -72,6 +72,8 @@ struct ofono_modem {
ofono_bool_tpowered_pending;
guint   timeout;
ofono_bool_tonline;
+   ofono_bool_temergency_online;
+   unsigned intemergency_mode;
struct ofono_watchlist  *online_watches;
GHashTable  *properties;
struct ofono_sim*sim;
@@ -514,6 +516,125 @@ static void offline_cb(const struct ofono_error *error, 
void *data)
modem_change_state(modem, MODEM_STATE_OFFLINE);
 }
 
+ofono_bool_t ofono_modem_get_emergency_mode(struct ofono_modem *modem)
+{
+   if (modem == NULL)
+   return FALSE;
+
+   return modem-emergency_mode != 0;
+}
+
+static void modem_change_online(struct ofono_modem *modem,
+   enum modem_state new_state)
+{
+   DBusConnection *conn = ofono_dbus_get_connection();
+   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 (new_online == modem-online)
+   return;
+
+   modem-modem_state = new_state;
+   modem-emergency_online = modem-online;
+   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 emergency_online_cb(const struct ofono_error *error, void *data)
+{
+   struct ofono_modem *modem = data;
+
+   DBG(modem: %p, modem);
+
+   if (error-type == OFONO_ERROR_TYPE_NO_ERROR 
+   modem-modem_state == MODEM_STATE_OFFLINE)
+   modem_change_online(modem, MODEM_STATE_ONLINE);
+}
+
+static void emergency_offline_cb(const struct ofono_error *error, void *data)
+{
+   struct ofono_modem *modem = data;
+   DBusConnection *conn = ofono_dbus_get_connection();
+   const char *path = ofono_modem_get_path(modem);
+   gboolean state = FALSE;
+
+   DBG(modem: %p, modem);
+
+   if (error-type == OFONO_ERROR_TYPE_NO_ERROR 
+   modem-modem_state == MODEM_STATE_ONLINE)
+   modem_change_online(modem, MODEM_STATE_OFFLINE);
+
+   modem-emergency_mode--;
+
+   ofono_dbus_signal_property_changed(conn, path,
+   OFONO_MODEM_INTERFACE,
+   EmergencyMode,
+   DBUS_TYPE_BOOLEAN,
+   state);
+}
+
+void ofono_modem_inc_emergency_mode(struct ofono_modem *modem)
+{
+   DBusConnection *conn = ofono_dbus_get_connection();
+   const char *path = ofono_modem_get_path(modem);
+   gboolean state = TRUE;
+
+   DBG(modem: %p, modem);
+
+   modem-emergency_mode++;
+   if (modem-emergency_mode  1)
+   return;
+
+   ofono_dbus_signal_property_changed(conn, path,
+   OFONO_MODEM_INTERFACE,
+   EmergencyMode,
+   DBUS_TYPE_BOOLEAN,
+   state);
+
+   if (modem-online)
+   return;
+
+   modem-driver-set_online(modem, TRUE, emergency_online_cb, modem);
+}
+
+void ofono_modem_dec_emergency_mode(struct ofono_modem *modem)
+{
+   DBusConnection *conn = ofono_dbus_get_connection();
+   const char *path = ofono_modem_get_path(modem);
+   gboolean state = FALSE;
+
+   DBG(modem: %p, modem);
+
+   if (modem-emergency_mode == 0)
+   return;
+
+   if (modem-emergency_mode  1) {
+   modem-emergency_mode--;
+   return;
+   }
+
+   if (!modem-emergency_online) {
+   modem-driver-set_online(modem, FALSE,
+   emergency_offline_cb, modem);
+   return;
+   }
+
+   modem-emergency_mode--;
+
+   ofono_dbus_signal_property_changed(conn, path,
+   OFONO_MODEM_INTERFACE,
+   EmergencyMode,
+   DBUS_TYPE_BOOLEAN,
+   state);
+}
+
 static DBusMessage *set_property_online(struct ofono_modem *modem,
DBusMessage *msg

[RFC PATCH 1/4] modem: add modem online-offline watch

2010-11-13 Thread Andras Domokos
From: Andras Domokos andras.domo...@nokia.com

---
 src/modem.c |   46 ++
 src/ofono.h |8 
 2 files changed, 54 insertions(+), 0 deletions(-)

diff --git a/src/modem.c b/src/modem.c
index 3776461..f73cc1d 100644
--- a/src/modem.c
+++ b/src/modem.c
@@ -72,6 +72,7 @@ struct ofono_modem {
ofono_bool_tpowered_pending;
guint   timeout;
ofono_bool_tonline;
+   struct ofono_watchlist  *online_watches;
GHashTable  *properties;
struct ofono_sim*sim;
unsigned intsim_watch;
@@ -362,6 +363,22 @@ static void flush_atoms(struct ofono_modem *modem, enum 
modem_state new_state)
}
 }
 
+static void notify_online_watches(struct ofono_modem *modem)
+{
+   struct ofono_watchlist_item *item;
+   GSList *l;
+   ofono_modem_online_notify_func notify;
+
+   if (modem-online_watches == NULL)
+   return;
+
+   for (l = modem-online_watches-items; l; l = l-next) {
+   item = l-data;
+   notify = item-notify;
+   notify(modem-online, item-notify_data);
+   }
+}
+
 static void modem_change_state(struct ofono_modem *modem,
enum modem_state new_state)
 {
@@ -404,11 +421,13 @@ static void modem_change_state(struct ofono_modem *modem,
__ofono_history_probe_drivers(modem);
__ofono_nettime_probe_drivers(modem);
}
+   notify_online_watches(modem);
break;
 
case MODEM_STATE_ONLINE:
if (driver-post_online)
driver-post_online(modem);
+   notify_online_watches(modem);
break;
}
 }
@@ -437,6 +456,29 @@ static void sim_state_watch(enum ofono_sim_state 
new_state, void *user)
}
 }
 
+unsigned __ofono_modem_add_online_watch(struct ofono_modem *modem,
+   ofono_modem_online_notify_func notify,
+   void *data, ofono_destroy_func destroy)
+{
+   struct ofono_watchlist_item *item;
+
+   if (modem == NULL || notify == NULL)
+   return 0;
+
+   item = g_new0(struct ofono_watchlist_item, 1);
+
+   item-notify = notify;
+   item-destroy = destroy;
+   item-notify_data = data;
+
+   return __ofono_watchlist_add_item(modem-online_watches, item);
+}
+
+void __ofono_modem_remove_online_watch(struct ofono_modem *modem, unsigned id)
+{
+   __ofono_watchlist_remove_item(modem-online_watches, id);
+}
+
 static void online_cb(const struct ofono_error *error, void *data)
 {
struct ofono_modem *modem = data;
@@ -1472,6 +1514,7 @@ int ofono_modem_register(struct ofono_modem *modem)
modem-driver_type = NULL;
 
modem-atom_watches = __ofono_watchlist_new(g_free);
+   modem-online_watches = __ofono_watchlist_new(g_free);
 
emit_modem_added(modem);
call_modemwatches(modem, TRUE);
@@ -1503,6 +1546,9 @@ static void modem_unregister(struct ofono_modem *modem)
__ofono_watchlist_free(modem-atom_watches);
modem-atom_watches = NULL;
 
+   __ofono_watchlist_free(modem-online_watches);
+   modem-online_watches = NULL;
+
modem-sim_watch = 0;
modem-sim_ready_watch = 0;
 
diff --git a/src/ofono.h b/src/ofono.h
index ab6ecd2..01cd6c0 100644
--- a/src/ofono.h
+++ b/src/ofono.h
@@ -177,6 +177,14 @@ unsigned int __ofono_modemwatch_add(ofono_modemwatch_cb_t 
cb, void *user,
ofono_destroy_func destroy);
 gboolean __ofono_modemwatch_remove(unsigned int id);
 
+typedef void (*ofono_modem_online_notify_func)(ofono_bool_t online,
+   void *data);
+unsigned int __ofono_modem_add_online_watch(struct ofono_modem *modem,
+   ofono_modem_online_notify_func notify,
+   void *data, ofono_destroy_func destroy);
+void __ofono_modem_remove_online_watch(struct ofono_modem *modem,
+   unsigned int id);
+
 #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


Re: [RFC PATCH 2/3] modem: add EmergencyMode property

2010-11-10 Thread Andras Domokos

Hi Denis,


On 11/09/2010 04:37 PM, ext Denis Kenzior wrote:

Hi Andras,

On 11/09/2010 02:59 AM, Andras Domokos wrote:
   

Signed-off-by: Andras Domokosandras.domo...@nokia.com
---
  src/modem.c |   53 +
  src/ofono.h |4 
  2 files changed, 57 insertions(+), 0 deletions(-)

diff --git a/src/modem.c b/src/modem.c
index f73cc1d..d7ad90e 100644
--- a/src/modem.c
+++ b/src/modem.c
@@ -72,6 +72,7 @@ struct ofono_modem {
ofono_bool_tpowered_pending;
guint   timeout;
ofono_bool_tonline;
+   unsigned intemergency_mode;
struct ofono_watchlist  *online_watches;
GHashTable  *properties;
struct ofono_sim*sim;
@@ -479,6 +480,50 @@ void __ofono_modem_remove_online_watch(struct ofono_modem 
*modem, unsigned id)
__ofono_watchlist_remove_item(modem-online_watches, id);
  }

+ofono_bool_t ofono_modem_get_emergency_mode(struct ofono_modem *modem)
+{
+   if (modem == NULL)
+   return FALSE;
+
+   return modem-emergency_mode != 0;
+}
+
+void ofono_modem_inc_emergency_mode(struct ofono_modem *modem)
+{
+   DBusConnection *conn = ofono_dbus_get_connection();
+   const char *path = ofono_modem_get_path(modem);
+   ofono_bool_t emergency_mode = modem-emergency_mode;
 

I suggest getting rid of this variable

   

+   gboolean state = TRUE;
+
+   modem-emergency_mode++;
+   if (emergency_mode)
+   return;
+
 

And checking if modem-emergency_mode  1 here...

   

You are right, makes the code shorter with less variables.

+   ofono_dbus_signal_property_changed(conn, path,
+   OFONO_MODEM_INTERFACE,
+   EmergencyMode,
+   DBUS_TYPE_BOOLEAN,
+   state);
+   modem_change_state(modem, MODEM_STATE_ONLINE);
 

So we have to be a bit careful here.  You can't simply call
modem_change_state here.  This results in calling the post_online
method, which populates the atoms that function when the radio is on.
Instead you need to call the set_online driver method directly.

Also, you probably do not want to populate the online atoms in an
emergency call situation.  Each atom driver / atom will perform
initialization procedures when they're newly added.  This can
potentially interfere with the voice call setup time, and not desirable.
  Not to mention that if we're actually in an emergency situation with
the SIM removed or PIN locked, we do not want to populate the atoms in
the first place.

So the modem 'ONLINE_STATE' has to be slightly de-coupled from whether
the radio is 'online'.

   

Good point, thanks. I am going to call directly the modem driver
set_online function with my own callback.

Now the question is whether modem-online should be toggled
according to the radio state changes? I think yes, and have the
change signaled on D-Bus (modem Online poperty).

There is another question then, when to notify the modem online
watchers, supposedly whenever modem-online changes, including
the changes triggered by the emergency call case.


+}
+
+void ofono_modem_dec_emergency_mode(struct ofono_modem *modem)
+{
+   DBusConnection *conn = ofono_dbus_get_connection();
+   const char *path = ofono_modem_get_path(modem);
+   gboolean state = FALSE;
+
+   modem-emergency_mode--;
+   if (modem-emergency_mode)
+   return;
+
+   ofono_dbus_signal_property_changed(conn, path,
+   OFONO_MODEM_INTERFACE,
+   EmergencyMode,
+   DBUS_TYPE_BOOLEAN,
+   state);
 

Here you should turn the radio off if it was off before starting the
emergency call.

   


The rationale behind leaving the radio on after emergency calls
was to have the theoretical possibility the emergency call center
to call you back (when SIM card is present...). If this is an unrealistic
scenario, I'll disable the radio after emergency calls in case it was off
before the call.

   

+}
+
  static void online_cb(const struct ofono_error *error, void *data)
  {
struct ofono_modem *modem = data;
@@ -535,6 +580,9 @@ static DBusMessage *set_property_online(struct ofono_modem 
*modem,
if (modem-modem_state  MODEM_STATE_OFFLINE)
return __ofono_error_not_available(msg);

+   if (modem-emergency_mode  online == FALSE)
+   return __ofono_error_failed(msg);
+
if (modem-online == online)
return dbus_message_new_method_return(msg);

@@ -562,6 +610,7 @@ void __ofono_modem_append_properties(struct ofono_modem 
*modem,
int i;
GSList *l;
struct ofono_atom

[PATCH 0/3] Emergency Calls (2nd round)

2010-11-09 Thread Andras Domokos
From: Andras Domokos andras.domo...@nokia.com

Here is a new proposal for emergency calls handling.

Steps in handling emergency calls:
- subscribe to modem online notifications (add modem online watcher)
- an emergency call detected (phone number is emergency number)
- increment emergency mode
  - switch modem online if not in online mode
  - advertise EmergencyMode property change on D-Bus (for first call)
- if modem is not online postpone making the call, otherwise make
  de emergency call
- when modem online notification comes and there is postponed call request
  make the emergency call
- when an emergency call ends decrement emergency mode
  - advertise EmergencyMode property change on D-Bus (for last call)

Note: modem remains online even if it was offline before starting the 
emergency call

Andras Domokos (3):
  modem: add modem online-offline watch
  modem: add EmergencyMode property
  voicecall: add emergency call handling

 src/modem.c |   99 +
 src/ofono.h |   12 ++
 src/voicecall.c |  101 ++-
 3 files changed, 211 insertions(+), 1 deletions(-)

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


[RFC PATCH 1/3] modem: add modem online-offline watch

2010-11-09 Thread Andras Domokos

Signed-off-by: Andras Domokos andras.domo...@nokia.com
---
 src/modem.c |   46 ++
 src/ofono.h |8 
 2 files changed, 54 insertions(+), 0 deletions(-)

diff --git a/src/modem.c b/src/modem.c
index 3776461..f73cc1d 100644
--- a/src/modem.c
+++ b/src/modem.c
@@ -72,6 +72,7 @@ struct ofono_modem {
ofono_bool_tpowered_pending;
guint   timeout;
ofono_bool_tonline;
+   struct ofono_watchlist  *online_watches;
GHashTable  *properties;
struct ofono_sim*sim;
unsigned intsim_watch;
@@ -362,6 +363,22 @@ static void flush_atoms(struct ofono_modem *modem, enum 
modem_state new_state)
}
 }
 
+static void notify_online_watches(struct ofono_modem *modem)
+{
+   struct ofono_watchlist_item *item;
+   GSList *l;
+   ofono_modem_online_notify_func notify;
+
+   if (modem-online_watches == NULL)
+   return;
+
+   for (l = modem-online_watches-items; l; l = l-next) {
+   item = l-data;
+   notify = item-notify;
+   notify(modem-online, item-notify_data);
+   }
+}
+
 static void modem_change_state(struct ofono_modem *modem,
enum modem_state new_state)
 {
@@ -404,11 +421,13 @@ static void modem_change_state(struct ofono_modem *modem,
__ofono_history_probe_drivers(modem);
__ofono_nettime_probe_drivers(modem);
}
+   notify_online_watches(modem);
break;
 
case MODEM_STATE_ONLINE:
if (driver-post_online)
driver-post_online(modem);
+   notify_online_watches(modem);
break;
}
 }
@@ -437,6 +456,29 @@ static void sim_state_watch(enum ofono_sim_state 
new_state, void *user)
}
 }
 
+unsigned __ofono_modem_add_online_watch(struct ofono_modem *modem,
+   ofono_modem_online_notify_func notify,
+   void *data, ofono_destroy_func destroy)
+{
+   struct ofono_watchlist_item *item;
+
+   if (modem == NULL || notify == NULL)
+   return 0;
+
+   item = g_new0(struct ofono_watchlist_item, 1);
+
+   item-notify = notify;
+   item-destroy = destroy;
+   item-notify_data = data;
+
+   return __ofono_watchlist_add_item(modem-online_watches, item);
+}
+
+void __ofono_modem_remove_online_watch(struct ofono_modem *modem, unsigned id)
+{
+   __ofono_watchlist_remove_item(modem-online_watches, id);
+}
+
 static void online_cb(const struct ofono_error *error, void *data)
 {
struct ofono_modem *modem = data;
@@ -1472,6 +1514,7 @@ int ofono_modem_register(struct ofono_modem *modem)
modem-driver_type = NULL;
 
modem-atom_watches = __ofono_watchlist_new(g_free);
+   modem-online_watches = __ofono_watchlist_new(g_free);
 
emit_modem_added(modem);
call_modemwatches(modem, TRUE);
@@ -1503,6 +1546,9 @@ static void modem_unregister(struct ofono_modem *modem)
__ofono_watchlist_free(modem-atom_watches);
modem-atom_watches = NULL;
 
+   __ofono_watchlist_free(modem-online_watches);
+   modem-online_watches = NULL;
+
modem-sim_watch = 0;
modem-sim_ready_watch = 0;
 
diff --git a/src/ofono.h b/src/ofono.h
index ab6ecd2..35335b6 100644
--- a/src/ofono.h
+++ b/src/ofono.h
@@ -177,6 +177,14 @@ unsigned int __ofono_modemwatch_add(ofono_modemwatch_cb_t 
cb, void *user,
ofono_destroy_func destroy);
 gboolean __ofono_modemwatch_remove(unsigned int id);
 
+typedef void (*ofono_modem_online_notify_func)(ofono_bool_t state,
+   void *data);
+unsigned int __ofono_modem_add_online_watch(struct ofono_modem *modem,
+   ofono_modem_online_notify_func notify,
+   void *data, ofono_destroy_func destroy);
+void __ofono_modem_remove_online_watch(struct ofono_modem *modem,
+   unsigned int id);
+
 #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 2/3] modem: add EmergencyMode property

2010-11-09 Thread Andras Domokos

Signed-off-by: Andras Domokos andras.domo...@nokia.com
---
 src/modem.c |   53 +
 src/ofono.h |4 
 2 files changed, 57 insertions(+), 0 deletions(-)

diff --git a/src/modem.c b/src/modem.c
index f73cc1d..d7ad90e 100644
--- a/src/modem.c
+++ b/src/modem.c
@@ -72,6 +72,7 @@ struct ofono_modem {
ofono_bool_tpowered_pending;
guint   timeout;
ofono_bool_tonline;
+   unsigned intemergency_mode;
struct ofono_watchlist  *online_watches;
GHashTable  *properties;
struct ofono_sim*sim;
@@ -479,6 +480,50 @@ void __ofono_modem_remove_online_watch(struct ofono_modem 
*modem, unsigned id)
__ofono_watchlist_remove_item(modem-online_watches, id);
 }
 
+ofono_bool_t ofono_modem_get_emergency_mode(struct ofono_modem *modem)
+{
+   if (modem == NULL)
+   return FALSE;
+
+   return modem-emergency_mode != 0;
+}
+
+void ofono_modem_inc_emergency_mode(struct ofono_modem *modem)
+{
+   DBusConnection *conn = ofono_dbus_get_connection();
+   const char *path = ofono_modem_get_path(modem);
+   ofono_bool_t emergency_mode = modem-emergency_mode;
+   gboolean state = TRUE;
+
+   modem-emergency_mode++;
+   if (emergency_mode)
+   return;
+
+   ofono_dbus_signal_property_changed(conn, path,
+   OFONO_MODEM_INTERFACE,
+   EmergencyMode,
+   DBUS_TYPE_BOOLEAN,
+   state);
+   modem_change_state(modem, MODEM_STATE_ONLINE);
+}
+
+void ofono_modem_dec_emergency_mode(struct ofono_modem *modem)
+{
+   DBusConnection *conn = ofono_dbus_get_connection();
+   const char *path = ofono_modem_get_path(modem);
+   gboolean state = FALSE;
+
+   modem-emergency_mode--;
+   if (modem-emergency_mode)
+   return;
+
+   ofono_dbus_signal_property_changed(conn, path,
+   OFONO_MODEM_INTERFACE,
+   EmergencyMode,
+   DBUS_TYPE_BOOLEAN,
+   state);
+}
+
 static void online_cb(const struct ofono_error *error, void *data)
 {
struct ofono_modem *modem = data;
@@ -535,6 +580,9 @@ static DBusMessage *set_property_online(struct ofono_modem 
*modem,
if (modem-modem_state  MODEM_STATE_OFFLINE)
return __ofono_error_not_available(msg);
 
+   if (modem-emergency_mode  online == FALSE)
+   return __ofono_error_failed(msg);
+
if (modem-online == online)
return dbus_message_new_method_return(msg);
 
@@ -562,6 +610,7 @@ void __ofono_modem_append_properties(struct ofono_modem 
*modem,
int i;
GSList *l;
struct ofono_atom *devinfo_atom;
+   ofono_bool_t state;
 
ofono_dbus_dict_append(dict, Online, DBUS_TYPE_BOOLEAN,
modem-online);
@@ -569,6 +618,10 @@ void __ofono_modem_append_properties(struct ofono_modem 
*modem,
ofono_dbus_dict_append(dict, Powered, DBUS_TYPE_BOOLEAN,
modem-powered);
 
+   state = ofono_modem_get_emergency_mode(modem);
+   ofono_dbus_dict_append(dict, EmergencyMode,
+   DBUS_TYPE_BOOLEAN, state);
+
devinfo_atom = __ofono_modem_find_atom(modem, OFONO_ATOM_TYPE_DEVINFO);
 
/* We cheat a little here and don't check the registered status */
diff --git a/src/ofono.h b/src/ofono.h
index 35335b6..b5c32b4 100644
--- a/src/ofono.h
+++ b/src/ofono.h
@@ -185,6 +185,10 @@ unsigned int __ofono_modem_add_online_watch(struct 
ofono_modem *modem,
 void __ofono_modem_remove_online_watch(struct ofono_modem *modem,
unsigned int id);
 
+ofono_bool_t ofono_modem_get_emergency_mode(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 3/3] voicecall: add emergency call handling

2010-11-09 Thread Andras Domokos

Signed-off-by: Andras Domokos andras.domo...@nokia.com
---
 src/voicecall.c |  101 ++-
 1 files changed, 100 insertions(+), 1 deletions(-)

diff --git a/src/voicecall.c b/src/voicecall.c
index bd64432..0268ce1 100644
--- a/src/voicecall.c
+++ b/src/voicecall.c
@@ -52,6 +52,7 @@ struct ofono_voicecall {
struct ofono_sim *sim;
unsigned int sim_watch;
unsigned int sim_state_watch;
+   unsigned int modem_online_watch;
const struct ofono_voicecall_driver *driver;
void *driver_data;
struct ofono_atom *atom;
@@ -133,6 +134,22 @@ static void add_to_en_list(GSList **l, const char **list)
*l = g_slist_prepend(*l, g_strdup(list[i++]));
 }
 
+static gint number_compare(gconstpointer a, gconstpointer b)
+{
+   const char *s1 = a, *s2 = b;
+   return strcmp(s1, s2);
+}
+
+static ofono_bool_t emergency_number(struct ofono_voicecall *vc,
+   const char *number)
+{
+   if (!number)
+   return FALSE;
+
+   return g_slist_find_custom(vc-en_list,
+   number, number_compare) ? TRUE : FALSE;
+}
+
 static const char *disconnect_reason_to_string(enum ofono_disconnect_reason r)
 {
switch (r) {
@@ -1125,6 +1142,7 @@ static struct voicecall *dial_handle_result(struct 
ofono_voicecall *vc,
 static void manager_dial_callback(const struct ofono_error *error, void *data)
 {
struct ofono_voicecall *vc = data;
+   struct ofono_modem *modem = __ofono_atom_get_modem(vc-atom);
DBusMessage *reply;
const char *number;
gboolean need_to_emit;
@@ -1143,8 +1161,11 @@ 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 {
+   if (emergency_number(vc, number))
+   ofono_modem_dec_emergency_mode(modem);
reply = __ofono_error_failed(vc-pending);
+   }
 
__ofono_dbus_pending_reply(vc-pending, reply);
 
@@ -1156,6 +1177,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;
@@ -1195,6 +1217,13 @@ static DBusMessage *manager_dial(DBusConnection *conn,
 
string_to_phone_number(number, ph);
 
+   if (emergency_number(vc, number)) {
+   ofono_bool_t online = ofono_modem_get_online(modem);
+   ofono_modem_inc_emergency_mode(modem);
+   if (!online)
+   return NULL;
+   }
+
vc-driver-dial(vc, ph, clir, OFONO_CUG_OPTION_DEFAULT,
manager_dial_callback, vc);
 
@@ -1748,6 +1777,7 @@ void ofono_voicecall_disconnected(struct ofono_voicecall 
*vc, int id,
const struct ofono_error *error)
 {
struct ofono_modem *modem = __ofono_atom_get_modem(vc-atom);
+   const char *number;
GSList *l;
struct voicecall *call;
time_t ts;
@@ -1767,6 +1797,7 @@ void ofono_voicecall_disconnected(struct ofono_voicecall 
*vc, int id,
}
 
call = l-data;
+   number = phone_number_to_string(call-call-phone_number);
 
ts = time(NULL);
prev_status = call-call-status;
@@ -1805,6 +1836,9 @@ void ofono_voicecall_disconnected(struct ofono_voicecall 
*vc, int id,
 
voicecalls_emit_call_removed(vc, call);
 
+   if (emergency_number(vc, number))
+   ofono_modem_dec_emergency_mode(modem);
+
voicecall_dbus_unregister(vc, call);
 
vc-call_list = g_slist_remove(vc-call_list, call);
@@ -1814,6 +1848,7 @@ void ofono_voicecall_notify(struct ofono_voicecall *vc,
const struct ofono_call *call)
 {
struct ofono_modem *modem = __ofono_atom_get_modem(vc-atom);
+   const char *number;
GSList *l;
struct voicecall *v = NULL;
struct ofono_call *newcall;
@@ -1860,6 +1895,10 @@ void ofono_voicecall_notify(struct ofono_voicecall *vc,
 
vc-call_list = g_slist_insert_sorted(vc-call_list, v, call_compare);
 
+   number = phone_number_to_string(v-call-phone_number);
+   if (emergency_number(vc, number))
+   ofono_modem_inc_emergency_mode(modem);
+
voicecalls_emit_call_added(vc, v);
 
return;
@@ -2067,6 +2106,7 @@ static void voicecall_unregister(struct ofono_atom *atom)
 static void voicecall_remove(struct ofono_atom *atom)
 {
struct ofono_voicecall *vc = __ofono_atom_get_data(atom);
+   struct ofono_modem *modem = __ofono_atom_get_modem(atom);
 
DBG

Re: [RFC PATCH 2/3] voicecall: emergency call handling added

2010-11-01 Thread Andras Domokos

Hi Denis,

On 10/29/2010 08:32 PM, ext Denis Kenzior wrote:

Hi Andras,

   

Just some general comments, but this patch seems to be backwards from
the earlier proposal.  Namely EmergencyMode is a property on the Modem
interface, not on the VoiceCallManager.  See doc/modem-api.txt,
Emergency property.

   

I thought it was more logical to have the EmergencyMode property
linked to voicecall since it is about a special call case, but I am fine
with moving that property up to modem level.

 

Oh I can see that as well, but I think earlier we agreed that it should
be on the Modem interface.  This has several advantages: offline /
online toggling has to happen in the modem and it is easier for the
power management framework to monitor it there.  So unless you feel
really strongly against that I suggest we stick with the earlier proposal.

   

I see the advantage of using the Modem interface and I am fine
with basing the implementation on it.

In general I think that the emergency_watch is unnecessary.  Having a
reference counted emergency tracking inside the modem object and a modem
online state watch should be sufficient.


   

The idea with the emergency watch is that any subsystem can get the
notification  when the emergency mode is entered and react on it.
 

Don't get me wrong, it might be useful in the future.  But for the
context of supporting emergency calls in the voicecall driver the
emergency watch is not really needed.  In general I prefer to review
code which has an immediate or foreseeable need.

In this case if we detect an emergency call dial and we're offline, we:

- Save the pending call
- establish an online watch
- ofono_modem_inc_emergency_mode()

Once we are online:
- Dial the call

Once the call ends
- ofono_modem_dec_emergency_mode()

Nowhere do we actually need to use an emergency watch itself.

   

To give you a more complex example, it might well be that the gprs
connection needs to be torn down when making an emergency call in
2G mode, there are such networks out there that prevents you from
making an emergency call if your device is attached to a PDP context.
In this given situation it comes to the question how to bring down the
gprs connection. It can be done such that the gprs atom will tear down
the connection after receiving the EmergencyMode notification, or
another option is to have gprs connection handling functions made
 

Have we established that this is actually still needed?  I thought you
guys said all the networks that have this problem have been fixed by now?

If this is still required, I suggest you group the emergency watch
functions with patches implementing the above functionality.

   

available by gprs and to deal with the gprs connection within voicecall
(or somewhere else). The online/offline mode change handling in fact is
bringing up the some issue, how the mode change handling should be
implemented when making the emergency call. My idea was let every
subsystem deal with the specifics of its own subsystem.
 

Let the modem figure out the specifics.  Basically as long as the count
for emergency is greater than 1, Offline mode should not be entered.
Once it reaches 0, the online mode should go back to the previous value.
   


Based on the comments and after some clarifications made in our
team, I consider the emergency watch unnecessary. We can forget
about the very corner case and go with the simpler approach.

OK, I am going to come up with a new set of patches.


Regards,
-Denis
   


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


Re: [RFC PATCH 2/3] voicecall: emergency call handling added

2010-10-29 Thread Andras Domokos

Hi Denis,

Thank you for your comments, here is my response.

On 10/28/2010 06:48 AM, ext Denis Kenzior wrote:

Hi Andras,

On 10/25/2010 03:03 AM, Andras Domokos wrote:
   

From: Andras Domokosandras.domo...@nokia.com


Signed-off-by: Andras Domokosandras.domo...@nokia.com
---
  include/voicecall.h |   12 +++
  src/voicecall.c |  221 ++
  2 files changed, 215 insertions(+), 18 deletions(-)

diff --git a/include/voicecall.h b/include/voicecall.h
index 2356fcf..d530148 100644
--- a/include/voicecall.h
+++ b/include/voicecall.h
@@ -38,6 +38,9 @@ typedef void (*ofono_call_list_cb_t)(const struct ofono_error 
*error,
   const struct ofono_call *call_list,
   void *data);

+typedef void (*ofono_voicecall_emergency_notify_cb_t)(ofono_bool_t state,
+ void *data);
+
  /* Voice call related functionality, including ATD, ATA, +CHLD, CTFR, CLCC
   * and VTS.
   *
@@ -116,6 +119,15 @@ void ofono_voicecall_set_data(struct ofono_voicecall *vc, 
void *data);
  void *ofono_voicecall_get_data(struct ofono_voicecall *vc);
  int ofono_voicecall_get_next_callid(struct ofono_voicecall *vc);

+unsigned int __ofono_voicecall_add_emergency_watch(struct ofono_voicecall *vc,
+ ofono_voicecall_emergency_notify_cb_t notify,
+ void *data, ofono_destroy_func destroy);
+void __ofono_voicecall_remove_emergency_watch(struct ofono_voicecall *vc,
+ unsigned int id);
+ofono_bool_t ofono_voicecall_get_emergency_state(struct ofono_voicecall *vc);
+void __ofono_voicecall_set_emergency_state(struct ofono_voicecall *vc,
+ int state);
+
 

Just some general comments, but this patch seems to be backwards from
the earlier proposal.  Namely EmergencyMode is a property on the Modem
interface, not on the VoiceCallManager.  See doc/modem-api.txt,
Emergency property.
   

I thought it was more logical to have the EmergencyMode property
linked to voicecall since it is about a special call case, but I am fine
with moving that property up to modem level.


In general I think that the emergency_watch is unnecessary.  Having a
reference counted emergency tracking inside the modem object and a modem
online state watch should be sufficient.

   

The idea with the emergency watch is that any subsystem can get the
notification  when the emergency mode is entered and react on it.
To give you a more complex example, it might well be that the gprs
connection needs to be torn down when making an emergency call in
2G mode, there are such networks out there that prevents you from
making an emergency call if your device is attached to a PDP context.
In this given situation it comes to the question how to bring down the
gprs connection. It can be done such that the gprs atom will tear down
the connection after receiving the EmergencyMode notification, or
another option is to have gprs connection handling functions made
available by gprs and to deal with the gprs connection within voicecall
(or somewhere else). The online/offline mode change handling in fact is
bringing up the some issue, how the mode change handling should be
implemented when making the emergency call. My idea was let every
subsystem deal with the specifics of its own subsystem.


  #ifdef __cplusplus
  }
  #endif
diff --git a/src/voicecall.c b/src/voicecall.c
index 7b5fe3b..a619b30 100644
--- a/src/voicecall.c
+++ b/src/voicecall.c
@@ -25,6 +25,7 @@

  #includestring.h
  #includestdio.h
+#includestdlib.h
  #includetime.h
  #includeerrno.h
  #includestdint.h
@@ -56,6 +57,9 @@ struct ofono_voicecall {
   void *driver_data;
   struct ofono_atom *atom;
   struct dial_request *dial_req;
+ struct ofono_watchlist *emergency_watches;
+ unsigned int emergency_state;
+ unsigned int modem_state_watch;
  };

  struct voicecall {
@@ -85,6 +89,8 @@ static const char *default_en_list_no_sim[] = { 119, 118, 999, 
110,

  static void generic_callback(const struct ofono_error *error, void *data);
  static void multirelease_callback(const struct ofono_error *err, void *data);
+static const char *voicecall_build_path(struct ofono_voicecall *vc,
+ const struct ofono_call *call);

 

It is generally against the coding style to forward-declare static
functions.  If this function is needed, please simply move it higher.
   

OK, I'll conform to the agreed coding policy.
   

  static gint call_compare_by_id(gconstpointer a, gconstpointer b)
  {
@@ -121,6 +127,145 @@ static void add_to_en_list(GSList **l, const char **list)
   *l = g_slist_prepend(*l, g_strdup(list[i++]));
  }

+static gint number_compare(gconstpointer a, gconstpointer b)
+{
+ const char *s1 = a, *s2 = b;
+ return strcmp(s1, s2);
+}
+
+static ofono_bool_t

Call counters proposal (TODO patch)

2010-10-25 Thread Andras Domokos

I am proposing adding Call counters to Voicecall. Here is the TODO patch:

diff --git a/TODO b/TODO
index d9a6580..89e180c 100644
--- a/TODO
+++ b/TODO
@@ -329,6 +329,15 @@ Voicecall
   Complexity: C2
   Owner: Pekka Pessi pekka.pe...@nokia.com

+- Call counters. Provide total outgoing and incoming call duration 
information.
+  Separate call counters will be maintained for each SIM card. Call 
counters

+  can be read and reset to 0, and must be backed up periodically to a
+  non-volatile storage place.
+
+  Priority: Medium
+  Complexity: C2
+  Owner: Andras Domokos andras.domo...@nokia.com
+

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


Emergency Calls

2010-10-22 Thread Andras Domokos
Hi,

This is a proposal for handling emergency calls in ofono:

Detect when an emergency call is requested/ended and notify the interested,
subscribed parties, so that steps can be taken to ensure that the emergency
call can be established and maintained.

The EmergencyMode boolean property added to the VoicecallManager D-Bus
interface will reflect the emergency call situation.

There is an emergency watchlist in ofono_voicecall, where the watchers of
the interested parties are stored. When there is a change with regards to 
emergency calls (call starts/ends), the watchers in the list are notified.
One interested watcher is the modem, it has to change the modem state from
offline to online for the duration of an emergency call.

The modem has a modem state watchlist, so that interested parties can 
learn about the modem state changes. For emergency calls, voicecall manager
needs to know when the modem reached the online state, if a modem state change
to online was necessary.

The important details are in the patches.

Cheers,
Andras

Andras Domokos (3):
  modem: modem state watch added
  voicecall: emergency call handling added
  modem: emergency state handling added

 include/voicecall.h |   12 +++
 src/modem.c |  101 +---
 src/ofono.h |   15 
 src/voicecall.c |  221 ++
 4 files changed, 319 insertions(+), 30 deletions(-)

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


[RFC PATCH 1/3] modem: modem state watch added

2010-10-22 Thread Andras Domokos

Signed-off-by: Andras Domokos andras.domo...@nokia.com
---
 src/modem.c |   64 +++---
 src/ofono.h |   15 +
 2 files changed, 67 insertions(+), 12 deletions(-)

diff --git a/src/modem.c b/src/modem.c
index 7a29edf..9aeb49c 100644
--- a/src/modem.c
+++ b/src/modem.c
@@ -51,16 +51,9 @@ enum property_type {
PROPERTY_TYPE_BOOLEAN,
 };
 
-enum modem_state {
-   MODEM_STATE_POWER_OFF,
-   MODEM_STATE_PRE_SIM,
-   MODEM_STATE_OFFLINE,
-   MODEM_STATE_ONLINE,
-};
-
 struct ofono_modem {
char*path;
-   enum modem_statemodem_state;
+   enum ofono_modem_state  modem_state;
GSList  *atoms;
struct ofono_watchlist  *atom_watches;
GSList  *interface_list;
@@ -72,6 +65,7 @@ struct ofono_modem {
ofono_bool_tpowered_pending;
guint   timeout;
ofono_bool_tonline;
+   struct ofono_watchlist  *state_watches;
GHashTable  *properties;
struct ofono_sim*sim;
unsigned intsim_watch;
@@ -94,7 +88,7 @@ struct ofono_devinfo {
 
 struct ofono_atom {
enum ofono_atom_type type;
-   enum modem_state modem_state;
+   enum ofono_modem_state modem_state;
void (*destruct)(struct ofono_atom *atom);
void (*unregister)(struct ofono_atom *atom);
void *data;
@@ -324,7 +318,8 @@ void __ofono_atom_free(struct ofono_atom *atom)
g_free(atom);
 }
 
-static void flush_atoms(struct ofono_modem *modem, enum modem_state new_state)
+static void flush_atoms(struct ofono_modem *modem,
+   enum ofono_modem_state new_state)
 {
GSList *cur;
GSList *prev;
@@ -360,11 +355,50 @@ static void flush_atoms(struct ofono_modem *modem, enum 
modem_state new_state)
}
 }
 
+static void notify_state_watches(struct ofono_modem *modem)
+{
+   struct ofono_watchlist_item *item;
+   GSList *l;
+   ofono_modem_state_notify_func notify;
+
+   if (modem-state_watches == NULL)
+   return;
+
+   for (l = modem-state_watches-items; l; l = l-next) {
+   item = l-data;
+   notify = item-notify;
+   notify(modem-modem_state, item-notify_data);
+   }
+}
+
+unsigned __ofono_modem_add_state_watch(struct ofono_modem *modem,
+   ofono_modem_state_notify_func notify,
+   void *data, ofono_destroy_func destroy)
+{
+   struct ofono_watchlist_item *item;
+
+   if (modem == NULL || notify == NULL)
+   return 0;
+
+   item = g_new0(struct ofono_watchlist_item, 1);
+
+   item-notify = notify;
+   item-destroy = destroy;
+   item-notify_data = data;
+
+   return __ofono_watchlist_add_item(modem-state_watches, item);
+}
+
+void __ofono_modem_remove_state_watch(struct ofono_modem *modem, unsigned id)
+{
+   __ofono_watchlist_remove_item(modem-state_watches, id);
+}
+
 static void modem_change_state(struct ofono_modem *modem,
-   enum modem_state new_state)
+   enum ofono_modem_state new_state)
 {
struct ofono_modem_driver const *driver = modem-driver;
-   enum modem_state old_state = modem-modem_state;
+   enum ofono_modem_state old_state = modem-modem_state;
ofono_bool_t new_online = new_state == MODEM_STATE_ONLINE;
 
if (old_state == new_state)
@@ -407,6 +441,8 @@ static void modem_change_state(struct ofono_modem *modem,
driver-post_online(modem);
break;
}
+
+   notify_state_watches(modem);
 }
 
 static void sim_state_watch(enum ofono_sim_state new_state, void *user)
@@ -1457,6 +1493,7 @@ int ofono_modem_register(struct ofono_modem *modem)
modem-driver_type = NULL;
 
modem-atom_watches = __ofono_watchlist_new(g_free);
+   modem-state_watches = __ofono_watchlist_new(g_free);
 
emit_modem_added(modem);
call_modemwatches(modem, TRUE);
@@ -1488,6 +1525,9 @@ static void modem_unregister(struct ofono_modem *modem)
__ofono_watchlist_free(modem-atom_watches);
modem-atom_watches = NULL;
 
+   __ofono_watchlist_free(modem-state_watches);
+   modem-state_watches = NULL;
+
modem-sim_watch = 0;
modem-sim_ready_watch = 0;
 
diff --git a/src/ofono.h b/src/ofono.h
index 6c7f649..b132727 100644
--- a/src/ofono.h
+++ b/src/ofono.h
@@ -177,6 +177,21 @@ unsigned int __ofono_modemwatch_add(ofono_modemwatch_cb_t 
cb, void *user,
ofono_destroy_func destroy);
 gboolean __ofono_modemwatch_remove(unsigned int id);
 
+enum ofono_modem_state {
+   MODEM_STATE_POWER_OFF,
+   MODEM_STATE_PRE_SIM,
+   MODEM_STATE_OFFLINE,
+   MODEM_STATE_ONLINE,
+};
+
+typedef void (*ofono_modem_state_notify_func)(enum ofono_modem_state state

[RFC PATCH 2/3] voicecall: emergency call handling added

2010-10-22 Thread Andras Domokos

Signed-off-by: Andras Domokos andras.domo...@nokia.com
---
 include/voicecall.h |   12 +++
 src/voicecall.c |  221 ++
 2 files changed, 215 insertions(+), 18 deletions(-)

diff --git a/include/voicecall.h b/include/voicecall.h
index 2356fcf..d530148 100644
--- a/include/voicecall.h
+++ b/include/voicecall.h
@@ -38,6 +38,9 @@ typedef void (*ofono_call_list_cb_t)(const struct ofono_error 
*error,
const struct ofono_call *call_list,
void *data);
 
+typedef void (*ofono_voicecall_emergency_notify_cb_t)(ofono_bool_t state,
+   void *data);
+
 /* Voice call related functionality, including ATD, ATA, +CHLD, CTFR, CLCC
  * and VTS.
  *
@@ -116,6 +119,15 @@ void ofono_voicecall_set_data(struct ofono_voicecall *vc, 
void *data);
 void *ofono_voicecall_get_data(struct ofono_voicecall *vc);
 int ofono_voicecall_get_next_callid(struct ofono_voicecall *vc);
 
+unsigned int __ofono_voicecall_add_emergency_watch(struct ofono_voicecall *vc,
+   ofono_voicecall_emergency_notify_cb_t notify,
+   void *data, ofono_destroy_func destroy);
+void __ofono_voicecall_remove_emergency_watch(struct ofono_voicecall *vc,
+   unsigned int id);
+ofono_bool_t ofono_voicecall_get_emergency_state(struct ofono_voicecall *vc);
+void __ofono_voicecall_set_emergency_state(struct ofono_voicecall *vc,
+   int state);
+
 #ifdef __cplusplus
 }
 #endif
diff --git a/src/voicecall.c b/src/voicecall.c
index 7b5fe3b..a619b30 100644
--- a/src/voicecall.c
+++ b/src/voicecall.c
@@ -25,6 +25,7 @@
 
 #include string.h
 #include stdio.h
+#include stdlib.h
 #include time.h
 #include errno.h
 #include stdint.h
@@ -56,6 +57,9 @@ struct ofono_voicecall {
void *driver_data;
struct ofono_atom *atom;
struct dial_request *dial_req;
+   struct ofono_watchlist *emergency_watches;
+   unsigned int emergency_state;
+   unsigned int modem_state_watch;
 };
 
 struct voicecall {
@@ -85,6 +89,8 @@ static const char *default_en_list_no_sim[] = { 119, 118, 
999, 110,
 
 static void generic_callback(const struct ofono_error *error, void *data);
 static void multirelease_callback(const struct ofono_error *err, void *data);
+static const char *voicecall_build_path(struct ofono_voicecall *vc,
+   const struct ofono_call *call);
 
 static gint call_compare_by_id(gconstpointer a, gconstpointer b)
 {
@@ -121,6 +127,145 @@ static void add_to_en_list(GSList **l, const char **list)
*l = g_slist_prepend(*l, g_strdup(list[i++]));
 }
 
+static gint number_compare(gconstpointer a, gconstpointer b)
+{
+   const char *s1 = a, *s2 = b;
+   return strcmp(s1, s2);
+}
+
+static ofono_bool_t emergency_number(struct ofono_voicecall *vc,
+   const char *number)
+{
+   if (!number)
+   return FALSE;
+
+   return g_slist_find_custom(vc-en_list,
+   number, number_compare) ? TRUE : FALSE;
+}
+
+static void notify_emergency_watches(struct ofono_voicecall *vc,
+   ofono_bool_t state)
+{
+   struct ofono_watchlist_item *item;
+   GSList *l;
+   ofono_voicecall_emergency_notify_cb_t notify;
+
+   if (vc-emergency_watches == NULL)
+   return;
+
+   for (l = vc-emergency_watches-items; l; l = l-next) {
+   item = l-data;
+   notify = item-notify;
+   notify(state, item-notify_data);
+   }
+}
+
+unsigned int __ofono_voicecall_add_emergency_watch(struct ofono_voicecall *vc,
+   ofono_voicecall_emergency_notify_cb_t notify,
+   void *data, ofono_destroy_func destroy)
+{
+   struct ofono_watchlist_item *item;
+
+   if (vc == NULL || notify == NULL)
+   return 0;
+
+   item = g_new0(struct ofono_watchlist_item, 1);
+
+   item-notify = notify;
+   item-destroy = destroy;
+   item-notify_data = data;
+
+   return __ofono_watchlist_add_item(vc-emergency_watches, item);
+}
+
+void __ofono_voicecall_remove_emergency_watch(struct ofono_voicecall *vc,
+   unsigned int id)
+{
+   __ofono_watchlist_remove_item(vc-emergency_watches, id);
+}
+
+ofono_bool_t ofono_voicecall_get_emergency_state(struct ofono_voicecall *vc)
+{
+   return vc-emergency_state ? 1 : 0;
+}
+
+void __ofono_voicecall_inc_emergency_state(struct ofono_voicecall *vc)
+{
+   DBusConnection *conn = ofono_dbus_get_connection();
+   const char *path = __ofono_atom_get_path(vc-atom);
+   gboolean state = TRUE;
+
+   if (!vc-emergency_state

[RFC PATCH 3/3] modem: emergency state handling added

2010-10-22 Thread Andras Domokos

Signed-off-by: Andras Domokos andras.domo...@nokia.com
---
 src/modem.c |   37 +
 1 files changed, 37 insertions(+), 0 deletions(-)

diff --git a/src/modem.c b/src/modem.c
index 9aeb49c..9e96cce 100644
--- a/src/modem.c
+++ b/src/modem.c
@@ -70,6 +70,8 @@ struct ofono_modem {
struct ofono_sim*sim;
unsigned intsim_watch;
unsigned intsim_ready_watch;
+   unsigned intvoicecall_watch;
+   unsigned intemergency_watch;
const struct ofono_modem_driver *driver;
void*driver_data;
char*driver_type;
@@ -544,6 +546,34 @@ ofono_bool_t ofono_modem_get_online(struct ofono_modem 
*modem)
return modem-online;
 }
 
+static void emergency_state_watch(ofono_bool_t state, void *data);
+static void voicecall_watch(struct ofono_atom *atom,
+   enum ofono_atom_watch_condition cond, void *data)
+{
+   struct ofono_modem *modem = data;
+   struct ofono_voicecall *vc;
+
+   if (cond == OFONO_ATOM_WATCH_CONDITION_UNREGISTERED) {
+   modem-emergency_watch = 0;
+   return;
+   }
+
+   vc = __ofono_atom_get_data(atom);
+   modem-emergency_watch = __ofono_voicecall_add_emergency_watch(vc,
+   emergency_state_watch,
+   modem, NULL);
+}
+
+static void emergency_state_watch(ofono_bool_t state, void *data)
+{
+   struct ofono_modem *modem = data;
+
+   DBG(Emergency mode is %s, state ? On : Off);
+
+   if (state)
+   modem_change_state(modem, MODEM_STATE_ONLINE);
+}
+
 void __ofono_modem_append_properties(struct ofono_modem *modem,
DBusMessageIter *dict)
 {
@@ -1502,6 +1532,10 @@ int ofono_modem_register(struct ofono_modem *modem)
OFONO_ATOM_TYPE_SIM,
sim_watch, modem, NULL);
 
+   modem-voicecall_watch = __ofono_modem_add_atom_watch(modem,
+   OFONO_ATOM_TYPE_VOICECALL,
+   voicecall_watch, modem, NULL);
+
return 0;
 }
 
@@ -1531,6 +1565,9 @@ static void modem_unregister(struct ofono_modem *modem)
modem-sim_watch = 0;
modem-sim_ready_watch = 0;
 
+   modem-voicecall_watch = 0;
+   modem-emergency_watch = 0;
+
g_slist_foreach(modem-interface_list, (GFunc) g_free, NULL);
g_slist_free(modem-interface_list);
modem-interface_list = NULL;
-- 
1.7.0.4

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