[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);
 

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

2010-11-09 Thread Marcel Holtmann
Hi Andras,

 Signed-off-by: Andras Domokos andras.domo...@nokia.com

please redo the patches without the Signed-off-by line. It is mentioned
in doc/coding-style.txt that we do not use this.

Regards

Marcel


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


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

2010-11-09 Thread Denis Kenzior
Hi Andras,

On 11/09/2010 02:59 AM, Andras Domokos wrote:
 
 Signed-off-by: Andras Domokos andras.domo...@nokia.com

As Marcel already mentioned, we do not use Signed-off-by.

Otherwise this patch looks good to me.

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


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

2010-11-09 Thread Denis Kenzior
Hi Andras,

On 11/09/2010 03:00 AM, Andras Domokos wrote:
 
 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);

Empty line here, please see coding-style.txt, Section M1

   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);

Empty line here

 + ofono_modem_inc_emergency_mode(modem);

And one here

 + 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);
 +

I'm not convinced that you have the reference tracking completely
correct.  You increment the ref when a call is dialed, as well as when
it is notified + created.  However, you only decrement it when it is
disconnected...

   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))
 + 

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

2010-11-09 Thread Denis Kenzior
Hi Andras,

On 11/09/2010 02:59 AM, Andras Domokos wrote:
 
 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;

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...

 + 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'.

 +}
 +
 +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.

 +}
 +
  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,

Re: [PATCH] Add test/reset-pin

2010-11-09 Thread Denis Kenzior
Hi Pekka,

On 11/08/2010 02:28 PM, pekka.pe...@nokia.com wrote:
 From: Pekka Pessi pekka.pe...@nokia.com
 
 ---
  test/reset-pin |   23 +++
  1 files changed, 23 insertions(+), 0 deletions(-)
  create mode 100755 test/reset-pin
 

Patch has been applied, thanks.

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


Re: [PATCHv2 1/2] stemodem: Add RTNL functionality managing CAIF Network Interfaces.

2010-11-09 Thread Sjur Brændeland
Hi Marcel.

 I do need another look at the RTNL magic and casting. That always drives
 my crazy when I look at that. In the meantime, please address these
 details first.

I have some RTNL unit tests ready if your're interested.
Also I hope I have closed most open issues from your review
in the v4 version of this patch, please inform me if you think
otherwise.

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


Re: [PATCH] Added implementation for ReportVoiceCall, ReportTextMessage, Release methods and related code.Please take a look and give me feedback on the code quality , thinks that need to be ch

2010-11-09 Thread Denis Kenzior
On 11/03/2010 06:20 PM, Rajyalakshmi Bommaraju wrote:
 ---
  Makefile.am |6 +
  plugins/history.c   |  438 +
  plugins/history_agent.c |  453 
 +++
  plugins/history_agent.h |  103 +++

You might want to separate this patch into a series of patches.  Start
with the API definition in the oFono API documentation format.  Then the
history_agent implementation.  Then the actual history plugin
implementation.

  4 files changed, 1000 insertions(+), 0 deletions(-)
  create mode 100755 plugins/history.c
  create mode 100644 plugins/history_agent.c
  create mode 100644 plugins/history_agent.h
 
 diff --git a/Makefile.am b/Makefile.am
 index cd17fa2..530c2de 100644
 --- a/Makefile.am
 +++ b/Makefile.am
 @@ -286,6 +286,12 @@ builtin_sources += plugins/ste.c
  
  builtin_modules += caif
  builtin_sources += plugins/caif.c
 +
 +
 +builtin_modules += history
 +builtin_sources += plugins/history_agent.h
 +builtin_sources += plugins/history_agent.c
 +builtin_sources += plugins/history.c
  endif
  
  if MAINTAINER_MODE
 diff --git a/plugins/history.c b/plugins/history.c
 new file mode 100755
 index 000..f5d4ba0
 --- /dev/null
 +++ b/plugins/history.c
 @@ -0,0 +1,438 @@
 +/*
 + *
 + * 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 the GNU General Public License version 2 as
 + * published by the Free Software Foundation.
 + *
 + *  This program is distributed in the hope that it will be useful,
 + *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 + *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 + *  GNU General Public License for more details.
 + *
 + *  You should have received a copy of the GNU General Public License
 + *  along with this program; if not, write to the Free Software
 + *  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  
 USA
 + *
 + */
 +
 +#ifdef HAVE_CONFIG_H
 +#include config.h
 +#endif
 +
 +#define OFONO_API_SUBJECT_TO_CHANGE
 +#include errno.h
 +
 +#include gdbus/gdbus.h
 +#include ofono/history.h
 +#include plugins/history_agent.h
 +#include src/common.h
 +
 +#define HISTORY_FILE_PATH /var/cache/ofonohistory/
 +#define HISTORY_FILE HISTORY_FILE_PATHofonohistorydata
 +#define OFONO_MANAGER_PATH /

Please note that this is already defined in include/dbus.h

 +#define OFONO_HISTORY_INTERFACE com.meego.TelephonyHistory

Please don't hijack OFONO_ prefix for private enums / defines.

 +
 +struct ofono_history {
 + struct history_agent *current_agent;
 + int timeout;
 +} *history;
 +
 +

Please avoid double empty lines

 +static int history_plugin_probe(struct ofono_history_context *context)
 +{
 + DBG(History Probe for modem: %p, context-modem);
 + return 0;
 +}
 +
 +static void history_plugin_remove(struct ofono_history_context *context)
 +{
 + DBG(History Remove for modem: %p, context-modem);
 +}
 +
 +/**
 + * history_call_ended:
 + * ofono calls this method with the call information
 + */
 +

Remove this empty line here

 +static void history_plugin_call_ended(struct ofono_history_context *context,
 + const struct ofono_call *call,
 + time_t start,
 + time_t end)
 +{
 + struct ofono_modem *modem;
 + const char *path;
 + struct history *v = g_try_new0(struct history, 1);

There should be an empty line after a variable declaration block.

 + if (!v)
 + return;
 +
 + v-data.voice.type = VOICE;
 +
 + strcpy(v-data.voice.lineid, Unknown);
 +
 + if (call-type != 0)
 + return;
 +
 + DBG(Voice Call, %s, call-direction ? Incoming : Outgoing);
 + v-data.voice.type = call-direction;
 +
 + if (call-clip_validity == 0)
 + strcpy(v-data.voice.lineid,
 + phone_number_to_string(call-phone_number));
 +
 + v-data.voice.start_time = start;
 + v-data.voice.end_time = end;
 +
 + DBG(Call Ended on modem: %p, context-modem);
 + modem = context-modem;
 + path = ofono_modem_get_path(modem);
 +
 + v-data.voice.modem_path = g_try_malloc0(strlen(path) + 1);
 + if (v-data.voice.modem_path)
 + strcpy(v-data.voice.modem_path, path);
 +
 + if (!history) {
 + g_free(v);
 + return;
 + }
 +
 + history_agent_report_voicecall(v, history-current_agent,
 + history-timeout);
 +}
 +
 +/**
 + * history_call_missed:
 + * ofono calls this method with the call information
 + */
 +

Remove the empty line here

 +static void history_plugin_call_missed(struct ofono_history_context *context,
 + const struct ofono_call *call,
 + 

[PATCH] Force requirement for filename option in cmd line

2010-11-09 Thread Gustavo F. Padovan
---
 src/main.cpp |7 ++-
 1 files changed, 6 insertions(+), 1 deletions(-)

diff --git a/src/main.cpp b/src/main.cpp
index d601ac2..d4327b1 100644
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -35,7 +35,7 @@ static void usage()
 int main(int argc, char **argv)
 {
 QApplication app(argc, argv);
-QString filename;
+QString filename = NULL;
 int port = 12345;
 int index;
 bool with_gui = false;
@@ -71,6 +71,11 @@ int main(int argc, char **argv)
 
 }
 
+if (filename == NULL) {
+qWarning()  ERROR: filename must be the last argument;
+usage();
+}
+
 PhoneSimServer *pss = new PhoneSimServer(filename, port, 0);
 
 if (with_gui)
-- 
1.7.3.1

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


[PATCH] Add SIM reset button

2010-11-09 Thread Gustavo F. Padovan
AT+CRST now send a reset resquest command
---
 src/control.cpp|6 ++
 src/control.h  |1 +
 src/controlbase.ui |   16 
 3 files changed, 23 insertions(+), 0 deletions(-)

diff --git a/src/control.cpp b/src/control.cpp
index 2e22f69..1fa1978 100644
--- a/src/control.cpp
+++ b/src/control.cpp
@@ -84,6 +84,7 @@ ControlWidget::ControlWidget(const QString ruleFile, Control 
*parent)
 connect(ui-cbSimInserted, SIGNAL(clicked()), this, 
SLOT(simInsertRemove()));
 connect(ui-pbStart, SIGNAL(clicked()), this, SLOT(simAppStart()));
 connect(ui-pbAbort, SIGNAL(clicked()), this, SLOT(simAppAbort()));
+connect(ui-pbReset, SIGNAL(clicked()), this, SLOT(simAppReset()));
 
 QStringList headers;
 headers  Sender  Priority  Notification Status;
@@ -459,6 +460,11 @@ void ControlWidget::simAppAbort()
 p-simAppAbort();
 }
 
+void ControlWidget::simAppReset()
+{
+emit unsolicitedCommand(AT+CRST);
+}
+
 Script::Script(QObject *obj, Ui_ControlBase *ui) : QDBusAbstractAdaptor(obj)
 {
 /* Export tabs to be accessed by script */
diff --git a/src/control.h b/src/control.h
index 3c85e22..6c4d8a8 100644
--- a/src/control.h
+++ b/src/control.h
@@ -94,6 +94,7 @@ private slots:
 void simInsertRemove();
 void simAppStart();
 void simAppAbort();
+void simAppReset();
 
 signals:
 void unsolicitedCommand(const QString );
diff --git a/src/controlbase.ui b/src/controlbase.ui
index eca1898..ab06b51 100644
--- a/src/controlbase.ui
+++ b/src/controlbase.ui
@@ -1406,6 +1406,22 @@ p, li { white-space: pre-wrap; }
 /property
/widget
   /item
+  item
+   widget class=QPushButton name=pbReset
+property name=enabled
+ booltrue/bool
+/property
+property name=maximumSize
+ size
+  width185/width
+  height25/height
+ /size
+/property
+property name=text
+ stringReset/string
+/property
+   /widget
+  /item
  /layout
 /widget
/item
-- 
1.7.3.1

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


Re: [PATCH] Add test/reset-pin

2010-11-09 Thread Marcel Holtmann
Hi Pekka,

  ---
   test/reset-pin |   23 +++
   1 files changed, 23 insertions(+), 0 deletions(-)
   create mode 100755 test/reset-pin
  
 
 Patch has been applied, thanks.

I saw that Denis fixed the Makefile.am for you. Please keep in mind to
ensure that test scripts get included when building the release
tarballs.

Regards

Marcel


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


Re: [PATCH] Force requirement for filename option in cmd line

2010-11-09 Thread Denis Kenzior
Hi Gustavo,

On 11/09/2010 12:45 PM, Gustavo F. Padovan wrote:
 ---
  src/main.cpp |7 ++-
  1 files changed, 6 insertions(+), 1 deletions(-)
 

This patch has been applied, thanks.

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


RE: Can I modify CallingLineRestriction(the Property of CallSetting) value to disabled or enabled

2010-11-09 Thread Ding, HaitaoX
Hi, yang

Thanks a lot for your feedback. 

According to your tip , I tried to set HideCallerId to default, disabled 
and  enabled, and I can verify by run list-modem script that HideCallerId 
had been modified . but I still could find phone number on both called party 
and calling party , regardless the value of  HideCallerId is what. 

How can I let phone number be withheld on incoming at called party , when I 
make a voice call. 

Could you give me some help .


Best Regards
Haitao


-Original Message-
From: ofono-boun...@ofono.org [mailto:ofono-boun...@ofono.org] On Behalf Of Gu, 
Yang
Sent: Thursday, October 28, 2010 7:32 PM
To: ofono@ofono.org
Subject: RE: Can I modify CallingLineRestriction(the Property of CallSetting) 
value to disabled or enabled

Hi Haitao,

 From: ofono-boun...@ofono.org [mailto:ofono-boun...@ofono.org] On Behalf Of 
 Ding, HaitaoX
 Sent: Thursday, October 28, 2010 3:29 PM
 To: ofono@ofono.org
 Subject: Can I modify CallingLineRestriction(the Property of CallSetting) 
 value to disabled or enabled

 Hi, 
 
 Can I modify  CallingLineRestriction(the Property of CallSetting)  value to 
 disalbed or enabled. 
 
 I refer to the newest doc for CallSettings and found the 
 CallingLineRestriction is a read-only property, is it means ofono does not 
 support enable or disable CLIP. 
 Thanks a lot☺

 
You may set the property HideCallerId to default, disabled or enabled.
 
 
Regards,
-Yang 
___
ofono mailing list
ofono@ofono.org
http://lists.ofono.org/listinfo/ofono
___
ofono mailing list
ofono@ofono.org
http://lists.ofono.org/listinfo/ofono