Re: [PATCH 5/5] bluetooth: add DBG() messages

2011-02-17 Thread Marcel Holtmann
Hi Gustavo,

>  plugins/bluetooth.c |4 
>  1 files changed, 4 insertions(+), 0 deletions(-)

patch has been applied.

Regards

Marcel


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


Re: [PATCH 4/5] bluetooth: fix crash by removing record

2011-02-17 Thread Marcel Holtmann
Hi Gustavo,

> When bluetoothd is not running we should not call RemoveRecord()
> ---
>  plugins/bluetooth.c |   12 
>  1 files changed, 12 insertions(+), 0 deletions(-)

patch has been applied.

Regards

Marcel


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


Re: [PATCH 3/5] bluetooth: change how we report DBus errors

2011-02-17 Thread Marcel Holtmann
Hi Gustavo,

>  plugins/bluetooth.c |   33 -
>  1 files changed, 20 insertions(+), 13 deletions(-)

patch has been applied.

Regards

Marcel


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


Re: [PATCH 2/5] bluetooth: add a bluetoothd connect watch

2011-02-17 Thread Marcel Holtmann
Hi Gustavo,

> This fix a issue with sending DBus messages when bluetoothd is not up yet.
> ---
>  plugins/bluetooth.c |   24 ++--
>  1 files changed, 14 insertions(+), 10 deletions(-)

patch has been applied.

Regards

Marcel


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


Re: [PATCH 1/5] bluetooth: move find_adapter_cb to better place.

2011-02-17 Thread Marcel Holtmann
Hi Gustavo,

>  plugins/bluetooth.c |   52 +-
>  1 files changed, 26 insertions(+), 26 deletions(-)

patch has been applied.

Regards

Marcel


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


[PATCH] atmodem: CEREG support for LTE network status reporting in AT modem

2011-02-17 Thread Tomasz Gregorek
From: Tomasz Gregorek 

This is a proposal for CEREG support based on the AT modem.
Support in driver should work, though I have an issue with
the core.

The core has one gprs status currently. In case of having
second status for LTE, there is need of having two satuses,
one for each, 3G and LTE, or to combine those two into one.

I took second approach as it leaves current oFono API, though
it is not perfect.
---
 drivers/atmodem/gprs.c  |  151 +++
 drivers/isimodem/gprs.c |6 +-
 include/gprs.h  |   11 +++-
 src/gprs.c  |   43 -
 4 files changed, 189 insertions(+), 22 deletions(-)

diff --git a/drivers/atmodem/gprs.c b/drivers/atmodem/gprs.c
index 6e01994..f6585de 100644
--- a/drivers/atmodem/gprs.c
+++ b/drivers/atmodem/gprs.c
@@ -43,12 +43,15 @@
 #include "vendor.h"
 
 static const char *cgreg_prefix[] = { "+CGREG:", NULL };
+static const char *cereg_prefix[] = { "+CEREG:", NULL };
 static const char *cgdcont_prefix[] = { "+CGDCONT:", NULL };
 static const char *none_prefix[] = { NULL };
 
 struct gprs_data {
GAtChat *chat;
unsigned int vendor;
+   ofono_bool_t have_cgreg;
+   ofono_bool_t have_cereg;
 };
 
 static void at_cgatt_cb(gboolean ok, GAtResult *result, gpointer user_data)
@@ -80,6 +83,31 @@ static void at_gprs_set_attached(struct ofono_gprs *gprs, 
int attached,
CALLBACK_WITH_FAILURE(cb, data);
 }
 
+static void at_cereg_cb(gboolean ok, GAtResult *result, gpointer user_data)
+{
+   struct cb_data *cbd = user_data;
+   ofono_gprs_status_cb_t cb = cbd->cb;
+   struct ofono_error error;
+   int status;
+   struct gprs_data *gd = cbd->user;
+
+   decode_at_error(&error, g_at_result_final_response(result));
+
+   if (!ok) {
+   cb(&error, -1, GPRS_PS_STATUS_SOURCE_LTE, cbd->data);
+   return;
+   }
+
+   if (at_util_parse_reg(result, "+CEREG:", NULL, &status,
+   NULL, NULL, NULL, gd->vendor) == FALSE) {
+   CALLBACK_WITH_FAILURE(cb, -1,
+   GPRS_PS_STATUS_SOURCE_LTE, cbd->data);
+   return;
+   }
+
+   cb(&error, status, GPRS_PS_STATUS_SOURCE_LTE, cbd->data);
+}
+
 static void at_cgreg_cb(gboolean ok, GAtResult *result, gpointer user_data)
 {
struct cb_data *cbd = user_data;
@@ -91,17 +119,28 @@ static void at_cgreg_cb(gboolean ok, GAtResult *result, 
gpointer user_data)
decode_at_error(&error, g_at_result_final_response(result));
 
if (!ok) {
-   cb(&error, -1, cbd->data);
+   cb(&error, -1, GPRS_PS_STATUS_SOURCE_LTE, cbd->data);
return;
}
 
if (at_util_parse_reg(result, "+CGREG:", NULL, &status,
NULL, NULL, NULL, gd->vendor) == FALSE) {
-   CALLBACK_WITH_FAILURE(cb, -1, cbd->data);
+   CALLBACK_WITH_FAILURE(cb, -1,
+   GPRS_PS_STATUS_SOURCE_3G, cbd->data);
+   g_free(cbd);
return;
}
 
-   cb(&error, status, cbd->data);
+   cb(&error, status, GPRS_PS_STATUS_SOURCE_3G, cbd->data);
+
+   if (gd->have_cereg) {
+   if (g_at_chat_send(gd->chat, "AT+CEREG?", cereg_prefix,
+   at_cereg_cb, cbd, g_free) == FALSE) {
+   CALLBACK_WITH_FAILURE(cb, -1,
+   GPRS_PS_STATUS_SOURCE_LTE, cbd->data);
+   g_free(cbd);
+   }
+   }
 }
 
 static void at_gprs_registration_status(struct ofono_gprs *gprs,
@@ -132,9 +171,17 @@ static void at_gprs_registration_status(struct ofono_gprs 
*gprs,
break;
}
 
-   if (g_at_chat_send(gd->chat, "AT+CGREG?", cgreg_prefix,
-   at_cgreg_cb, cbd, g_free) > 0)
+   if (gd->have_cgreg) {
+   if (g_at_chat_send(gd->chat, "AT+CGREG?", cgreg_prefix,
+   at_cgreg_cb, cbd, NULL) > 0)
return;
+   }
+   else {
+   if (g_at_chat_send(gd->chat, "AT+CEREG?", cereg_prefix,
+   at_cereg_cb, cbd, g_free) > 0)
+   return;
+   }
+
 
g_free(cbd);
 
@@ -151,7 +198,20 @@ static void cgreg_notify(GAtResult *result, gpointer 
user_data)
NULL, NULL, NULL, gd->vendor) == FALSE)
return;
 
-   ofono_gprs_status_notify(gprs, status);
+   ofono_gprs_status_notify(gprs, status, GPRS_PS_STATUS_SOURCE_3G);
+}
+
+static void cereg_notify(GAtResult *result, gpointer user_data)
+{
+   struct ofono_gprs *gprs = user_data;
+   int status;
+   struct gprs_data *gd = ofono_gprs_get_data(gprs);
+
+   if (at_util_parse_reg_unsolicited(result, "+CEREG:", &status,
+   NULL, NULL, NULL, gd->vendor) == FALSE)
+   return;
+
+   ofono_gprs_status_notify(gp

[PATCH 5/5] bluetooth: add DBG() messages

2011-02-17 Thread Gustavo F. Padovan
---
 plugins/bluetooth.c |4 
 1 files changed, 4 insertions(+), 0 deletions(-)

diff --git a/plugins/bluetooth.c b/plugins/bluetooth.c
index 5f2d80d..7c2d5b0 100644
--- a/plugins/bluetooth.c
+++ b/plugins/bluetooth.c
@@ -280,6 +280,8 @@ static void device_properties_cb(DBusPendingCall *call, 
gpointer user_data)
goto done;
}
 
+   DBG("");
+
bluetooth_parse_properties(reply, "UUIDs", has_uuid, &have_uuid,
"Adapter", parse_string, &adapter,
"Address", parse_string, &device_addr,
@@ -410,6 +412,8 @@ static void adapter_properties_cb(DBusPendingCall *call, 
gpointer user_data)
goto done;
}
 
+   DBG("");
+
bluetooth_parse_properties(reply,
"Devices", parse_devices, &device_list,
"Address", parse_string, &addr,
-- 
1.7.4

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


[PATCH 4/5] bluetooth: fix crash by removing record

2011-02-17 Thread Gustavo F. Padovan
When bluetoothd is not running we should not call RemoveRecord()
---
 plugins/bluetooth.c |   12 
 1 files changed, 12 insertions(+), 0 deletions(-)

diff --git a/plugins/bluetooth.c b/plugins/bluetooth.c
index 161ae4b..5f2d80d 100644
--- a/plugins/bluetooth.c
+++ b/plugins/bluetooth.c
@@ -445,6 +445,9 @@ static void remove_record(struct server *server)
 {
DBusMessage *msg;
 
+   if (server->handle == 0)
+   return;
+
msg = dbus_message_new_method_call(BLUEZ_SERVICE, adapter_any_path,
BLUEZ_SERVICE_INTERFACE,
"RemoveRecord");
@@ -596,6 +599,13 @@ static void new_connection(GIOChannel *io, gpointer 
user_data)
client_event, cbd);
 }
 
+static void remove_service_handle(gpointer data, gpointer user_data)
+{
+   struct server *server = data;
+
+   server->handle = 0;
+}
+
 static void add_record_cb(DBusPendingCall *call, gpointer user_data)
 {
struct server *server = user_data;
@@ -767,6 +777,8 @@ static void bluetooth_disconnect(DBusConnection 
*connection, void *user_data)
return;
 
g_hash_table_foreach(uuid_hash, bluetooth_remove_all_modem, NULL);
+
+   g_slist_foreach(server_list, (GFunc) remove_service_handle, NULL);
 }
 
 static guint bluetooth_watch;
-- 
1.7.4

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


[PATCH 3/5] bluetooth: change how we report DBus errors

2011-02-17 Thread Gustavo F. Padovan
---
 plugins/bluetooth.c |   33 -
 1 files changed, 20 insertions(+), 13 deletions(-)

diff --git a/plugins/bluetooth.c b/plugins/bluetooth.c
index 8ca9f5f..161ae4b 100644
--- a/plugins/bluetooth.c
+++ b/plugins/bluetooth.c
@@ -267,19 +267,16 @@ static void device_properties_cb(DBusPendingCall *call, 
gpointer user_data)
const char *device_addr = NULL;
const char *alias = NULL;
struct bluetooth_profile *profile;
+   struct DBusError derr;
 
reply = dbus_pending_call_steal_reply(call);
 
-   if (dbus_message_is_error(reply, DBUS_ERROR_SERVICE_UNKNOWN)) {
-   DBG("Bluetooth daemon is apparently not available.");
-   goto done;
-   }
-
-   if (dbus_message_get_type(reply) == DBUS_MESSAGE_TYPE_ERROR) {
-   if (!dbus_message_is_error(reply, DBUS_ERROR_UNKNOWN_METHOD))
-   ofono_info("Error from GetProperties reply: %s",
-   dbus_message_get_error_name(reply));
+   dbus_error_init(&derr);
 
+   if (dbus_set_error_from_message(&derr, reply)) {
+   ofono_error("Device.GetProperties replied an error: %s, %s",
+   derr.name, derr.message);
+   dbus_error_free(&derr);
goto done;
}
 
@@ -397,14 +394,19 @@ static void adapter_properties_cb(DBusPendingCall *call, 
gpointer user_data)
 {
const char *path = user_data;
DBusMessage *reply;
+   DBusError derr;
GSList *device_list = NULL;
GSList *l;
const char *addr;
 
reply = dbus_pending_call_steal_reply(call);
 
-   if (dbus_message_is_error(reply, DBUS_ERROR_SERVICE_UNKNOWN)) {
-   DBG("Bluetooth daemon is apparently not available.");
+   dbus_error_init(&derr);
+
+   if (dbus_set_error_from_message(&derr, reply)) {
+   ofono_error("Adapter.GetProperties replied an error: %s, %s",
+   derr.name, derr.message);
+   dbus_error_free(&derr);
goto done;
}
 
@@ -717,11 +719,16 @@ static void parse_adapters(DBusMessageIter *array, 
gpointer user_data)
 static void manager_properties_cb(DBusPendingCall *call, gpointer user_data)
 {
DBusMessage *reply;
+   DBusError derr;
 
reply = dbus_pending_call_steal_reply(call);
 
-   if (dbus_message_is_error(reply, DBUS_ERROR_SERVICE_UNKNOWN)) {
-   DBG("Bluetooth daemon is apparently not available.");
+   dbus_error_init(&derr);
+
+   if (dbus_set_error_from_message(&derr, reply)) {
+   ofono_error("Manager.GetProperties() replied an error: %s, %s",
+   derr.name, derr.message);
+   dbus_error_free(&derr);
goto done;
}
 
-- 
1.7.4

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


[PATCH 1/5] bluetooth: move find_adapter_cb to better place.

2011-02-17 Thread Gustavo F. Padovan
---
 plugins/bluetooth.c |   52 +-
 1 files changed, 26 insertions(+), 26 deletions(-)

diff --git a/plugins/bluetooth.c b/plugins/bluetooth.c
index 175ebaa..32be96e 100644
--- a/plugins/bluetooth.c
+++ b/plugins/bluetooth.c
@@ -633,6 +633,32 @@ static void add_record(gpointer data, gpointer user_data)
DBUS_TYPE_INVALID);
 }
 
+static void find_adapter_cb(DBusPendingCall *call, gpointer user_data)
+{
+   DBusMessage *reply = dbus_pending_call_steal_reply(call);
+   DBusError derr;
+   const char *path;
+
+   dbus_error_init(&derr);
+
+   if (dbus_set_error_from_message(&derr, reply)) {
+   ofono_error("Replied with an error: %s, %s",
+   derr.name, derr.message);
+   dbus_error_free(&derr);
+   goto done;
+   }
+
+   dbus_message_get_args(reply, NULL, DBUS_TYPE_OBJECT_PATH, &path,
+   DBUS_TYPE_INVALID);
+
+   adapter_any_path = g_strdup(path);
+
+   g_slist_foreach(server_list, (GFunc) add_record, NULL);
+
+done:
+   dbus_message_unref(reply);
+}
+
 static gboolean adapter_added(DBusConnection *connection, DBusMessage *message,
void *user_data)
 {
@@ -724,32 +750,6 @@ static void bluetooth_disconnect(DBusConnection 
*connection, void *user_data)
g_hash_table_foreach(uuid_hash, bluetooth_remove_all_modem, NULL);
 }
 
-static void find_adapter_cb(DBusPendingCall *call, gpointer user_data)
-{
-   DBusMessage *reply = dbus_pending_call_steal_reply(call);
-   DBusError derr;
-   const char *path;
-
-   dbus_error_init(&derr);
-
-   if (dbus_set_error_from_message(&derr, reply)) {
-   ofono_error("Replied with an error: %s, %s",
-   derr.name, derr.message);
-   dbus_error_free(&derr);
-   goto done;
-   }
-
-   dbus_message_get_args(reply, NULL, DBUS_TYPE_OBJECT_PATH, &path,
-   DBUS_TYPE_INVALID);
-
-   adapter_any_path = g_strdup(path);
-
-   g_slist_foreach(server_list, (GFunc) add_record, NULL);
-
-done:
-   dbus_message_unref(reply);
-}
-
 static guint bluetooth_watch;
 static guint adapter_added_watch;
 static guint adapter_removed_watch;
-- 
1.7.4

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


[PATCH 2/5] bluetooth: add a bluetoothd connect watch

2011-02-17 Thread Gustavo F. Padovan
This fix a issue with sending DBus messages when bluetoothd is not up yet.
---
 plugins/bluetooth.c |   24 ++--
 1 files changed, 14 insertions(+), 10 deletions(-)

diff --git a/plugins/bluetooth.c b/plugins/bluetooth.c
index 32be96e..8ca9f5f 100644
--- a/plugins/bluetooth.c
+++ b/plugins/bluetooth.c
@@ -742,6 +742,18 @@ static void bluetooth_remove_all_modem(gpointer key, 
gpointer value,
profile->remove_all();
 }
 
+static void bluetooth_connect(DBusConnection *connection, void *user_data)
+{
+   bluetooth_send_with_reply("/", BLUEZ_MANAGER_INTERFACE, "GetProperties",
+   manager_properties_cb, NULL, NULL, -1,
+   DBUS_TYPE_INVALID);
+
+   bluetooth_send_with_reply("/", BLUEZ_MANAGER_INTERFACE, "FindAdapter",
+   find_adapter_cb, NULL, NULL, -1,
+   DBUS_TYPE_STRING, &adapter_any_name,
+   DBUS_TYPE_INVALID);
+}
+
 static void bluetooth_disconnect(DBusConnection *connection, void *user_data)
 {
if (uuid_hash == NULL)
@@ -763,7 +775,8 @@ static void bluetooth_ref(void)
connection = ofono_dbus_get_connection();
 
bluetooth_watch = g_dbus_add_service_watch(connection, BLUEZ_SERVICE,
-   NULL, bluetooth_disconnect, NULL, NULL);
+   bluetooth_connect,
+   bluetooth_disconnect, NULL, NULL);
 
adapter_added_watch = g_dbus_add_signal_watch(connection, NULL, NULL,
BLUEZ_MANAGER_INTERFACE,
@@ -791,15 +804,6 @@ static void bluetooth_ref(void)
adapter_address_hash = g_hash_table_new_full(g_str_hash, g_str_equal,
g_free, g_free);
 
-   bluetooth_send_with_reply("/", BLUEZ_MANAGER_INTERFACE, "GetProperties",
-   manager_properties_cb, NULL, NULL, -1,
-   DBUS_TYPE_INVALID);
-
-   bluetooth_send_with_reply("/", BLUEZ_MANAGER_INTERFACE, "FindAdapter",
-   find_adapter_cb, NULL, NULL, -1,
-   DBUS_TYPE_STRING, &adapter_any_name,
-   DBUS_TYPE_INVALID);
-
 increment:
g_atomic_int_inc(&bluetooth_refcount);
 
-- 
1.7.4

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


Re: [PATCH 9/9] stk: Partially handle Refresh command.

2011-02-17 Thread Denis Kenzior
Hi Andrew,

On 02/15/2011 01:58 AM, Andrzej Zaborowski wrote:
> Only the four "NAA initialisation" modes are handled at the moment.
> ---
>  src/stk.c |   65 
> +
>  1 files changed, 65 insertions(+), 0 deletions(-)
> 

Patch has been applied, thanks.

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


Re: [PATCH 6/9] cbs: Watch for changes to relevant SIM files.

2011-02-17 Thread Denis Kenzior
Hi Andrew,

On 02/15/2011 01:58 AM, Andrzej Zaborowski wrote:
> ---
>  src/cbs.c |   32 +++-
>  1 files changed, 31 insertions(+), 1 deletions(-)
> 

Patch has been applied.  One more comment below:

> @@ -886,7 +888,33 @@ static void sim_cbmid_read_cb(int ok, int length, int 
> record,
>   g_free(str);
>  
>  done:
> - cbs_got_file_contents(cbs);
> + if (cbs->efcbmid_update) {
> + topic_str = cbs_topics_to_str(cbs, cbs->topics);
> + cbs->driver->set_topics(cbs, topic_str,
> + cbs_set_powered_cb, cbs);
> + g_free(topic_str);

I think you meant to do this only if CBS atom was powered.  I fixed this
under that assumption.  Can you double check my logic?

> +
> + cbs->efcbmid_update = FALSE;
> + } else
> + cbs_got_file_contents(cbs);
> +}
> +

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


Re: [PATCH 5/9] network: Watch for changes to relevant SIM files.

2011-02-17 Thread Denis Kenzior
Hi Andrew,

On 02/15/2011 01:58 AM, Andrzej Zaborowski wrote:
> ---
>  src/network.c |   66 
> +
>  1 files changed, 66 insertions(+), 0 deletions(-)
> 

Patch has been applied, thanks.

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


Re: [PATCH 4/9] voicecall: Watch for changes to relevant SIM files.

2011-02-17 Thread Denis Kenzior
Hi Andrew,

On 02/15/2011 01:58 AM, Andrzej Zaborowski wrote:
> ---
>  src/voicecall.c |   24 +---
>  1 files changed, 17 insertions(+), 7 deletions(-)
> 

Patch has been applied, thanks.

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


Re: [PATCH 3/9] sim: Watch for changes to relevant SIM files.

2011-02-17 Thread Denis Kenzior
Hi Andrew,

On 02/15/2011 01:58 AM, Andrzej Zaborowski wrote:
> The watch callbacks are notified when a watched file is changed
> during a Refresh.  Currently in most of the callbacks we free all
> the information read from the file, and schedule a re-read.  I
> wonder if we need some sort of check if a re-read is already in
> progress.  We may also need to send PropertyChanged indicating
> that the value is invalid until the file read finishes at which
> point we send another PropertyChanged.  Otherwise the value of
> the property is for a short while inconsistent with what
> GetProperties would return (but I note that D-bus is already racy
> so maybe it doesn't matter).
> ---
>  src/sim.c |  153 
> +
>  1 files changed, 143 insertions(+), 10 deletions(-)
> 
> diff --git a/src/sim.c b/src/sim.c
> index 7c2e151..63c1ce9 100644
> --- a/src/sim.c
> +++ b/src/sim.c
> @@ -59,6 +59,7 @@ struct ofono_sim {
>   char **language_prefs;
>   unsigned char *efli;
>   unsigned char efli_length;
> + gboolean language_prefs_update;
>  
>   enum ofono_sim_password_type pin_type;
>   gboolean locked_pins[OFONO_SIM_PASSWORD_SIM_PUK]; /* Number of PINs */
> @@ -929,6 +930,11 @@ static void sim_iidf_read_cb(int ok, int length, int 
> record,
>   sim_iidf_read_clut_cb, sim);
>  }
>  
> +static void sim_image_data_changed(int id, void *userdata)
> +{
> + /* TODO: notify D-bus clients */
> +}
> +
>  static void sim_get_image(struct ofono_sim *sim, unsigned char id,
>   gpointer user_data)
>  {
> @@ -959,6 +965,8 @@ static void sim_get_image(struct ofono_sim *sim, unsigned 
> char id,
>   /* read the image data */
>   ofono_sim_read_bytes(sim->context, iidf_id, iidf_offset, iidf_len,
>   sim_iidf_read_cb, sim);
> + ofono_sim_add_file_watch(sim->context, iidf_id,
> + sim_image_data_changed, sim, NULL);
>  }
>  
>  static DBusMessage *sim_get_icon(DBusConnection *conn,
> @@ -1198,10 +1206,12 @@ out:
>  check:
>   /* All records retrieved */
>   if (sim->service_numbers) {
> - char **service_numbers;
> -
>   sim->service_numbers = g_slist_reverse(sim->service_numbers);
>   sim->sdn_ready = TRUE;
> + }
> +
> + if (sim->sdn_ready) {
> + char **service_numbers;
>  
>   service_numbers = get_service_numbers(sim->service_numbers);
>  
> @@ -1214,6 +1224,21 @@ check:
>   }
>  }
>  
> +static void sim_service_numbers_changed(int id, void *userdata)
> +{
> + struct ofono_sim *sim = userdata;
> +
> + if (sim->service_numbers) {
> + g_slist_foreach(sim->service_numbers,
> + (GFunc)service_number_free, NULL);
> + g_slist_free(sim->service_numbers);
> + sim->service_numbers = NULL;
> + }
> +
> + ofono_sim_read(sim->context, SIM_EFSDN_FILEID,
> + OFONO_SIM_FILE_STRUCTURE_FIXED, sim_sdn_read_cb, sim);
> +}
> +
>  static void sim_own_numbers_update(struct ofono_sim *sim)
>  {
>   ofono_sim_read(sim->context, SIM_EFMSISDN_FILEID,
> @@ -1221,6 +1246,13 @@ static void sim_own_numbers_update(struct ofono_sim 
> *sim)
>   sim);
>  }
>  
> +static void sim_own_numbers_changed(int id, void *userdata)
> +{
> + struct ofono_sim *sim = userdata;
> +
> + sim_own_numbers_update(sim);
> +}
> +
>  static void sim_efimg_read_cb(int ok, int length, int record,
>   const unsigned char *data,
>   int record_length, void *userdata)
> @@ -1262,19 +1294,69 @@ static void sim_efimg_read_cb(int ok, int length, int 
> record,
>   memcpy(efimg, &data[1], 9);
>  }
>  
> +static void sim_efimg_changed(int id, void *userdata)
> +{
> + struct ofono_sim *sim = userdata;
> + int i, iidf_id;
> +
> + if (sim->efimg != NULL) {
> + for (i = sim->efimg_length / 9 - 1; i >= 0; i--) {
> + iidf_id = (sim->efimg[i * 9 + 3] << 8) |
> + sim->efimg[i * 9 + 4];
> +
> + ofono_sim_remove_file_watch(sim->context, iidf_id);
> + }
> +
> + g_free(sim->efimg);
> + sim->efimg = NULL;
> + sim->efimg_length = 0;
> + }
> +
> + ofono_sim_read(sim->context, SIM_EFIMG_FILEID,
> + OFONO_SIM_FILE_STRUCTURE_FIXED, sim_efimg_read_cb, sim);
> +
> + /* TODO: notify D-bus clients */
> +}
> +
>  static void sim_ready(enum ofono_sim_state new_state, void *user)
>  {
>   struct ofono_sim *sim = user;
> + int i, iidf_id;
> +
> + if (new_state != OFONO_SIM_STATE_READY) {
> + if (sim->context == NULL)
> + return;
> +
> + ofono_sim_remove_file_watch(sim->context, SIM_EFMSISDN_FILEID);
> + ofo

Re: [PATCH 2/9] sim: Implement basic Refresh.

2011-02-17 Thread Denis Kenzior
Hi Andrew,

On 02/15/2011 01:58 AM, Andrzej Zaborowski wrote:
> ---
>  src/ofono.h |4 ++
>  src/sim.c   |  163 ++
>  2 files changed, 155 insertions(+), 12 deletions(-)
> 

Patch has been applied, but some comments below:

> + if (reinit_naa) {
> + /* Force the sim state out of READY */
> +
> + sim_free_main_state(sim);
> +
> + sim->state = OFONO_SIM_STATE_INSERTED;
> + for (l = sim->state_watches->items; l; l = l->next) {
> + struct ofono_watchlist_item *item = l->data;
> + notify = item->notify;
> +
> + notify(sim->state, item->notify_data);
> + }

I changed this to directly call the modem object and force it into
pre-sim state.  I think this is a bit more clear than your proposed
approach.

Another question here is whether we want to maintain two separate simfs
contexts.  One for the main state and one for the early state.  This
might make things a bit easier to implement for patch 3 in this series.

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


Re: [PATCH 1/9] modem.c: Go to PRE_SIM modem state on OFONO_SIM_STATE_INSERTED.

2011-02-17 Thread Denis Kenzior
Hi Andrew,

On 02/15/2011 01:58 AM, Andrzej Zaborowski wrote:
> The assumption so far was that SIM state would only go from
> NOT_PRESENT -> INSERTED -> READY -> NOT_PRESENT because there's
> no method to unauthenticate from SIM without removing.  We need to
> be able to switch to INSERTED when SIM is being reset,
> reinitialised, etc. because going to NOT_PRESENT and then
> immediately INSERTED would be logically wrong.
> ---
>  src/modem.c |   12 
>  1 files changed, 8 insertions(+), 4 deletions(-)

I applied this patch, but partly refactored it in a later commit.  Can
you check that I didn't screw something up?

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


Re: [PATCH 8/9] call-forwarding: Watch for changes to relevant SIM files.

2011-02-17 Thread Denis Kenzior
Hi Andrew,

On 02/15/2011 01:58 AM, Andrzej Zaborowski wrote:
> ---
>  src/call-forwarding.c |   39 +--
>  1 files changed, 37 insertions(+), 2 deletions(-)
> 
> diff --git a/src/call-forwarding.c b/src/call-forwarding.c
> index d13f990..d610521 100644
> --- a/src/call-forwarding.c
> +++ b/src/call-forwarding.c
> @@ -74,6 +74,7 @@ static void get_query_next_cf_cond(struct 
> ofono_call_forwarding *cf);
>  static void set_query_next_cf_cond(struct ofono_call_forwarding *cf);
>  static void ss_set_query_next_cf_cond(struct ofono_call_forwarding *cf);
>  static void cf_unregister_ss_controls(struct ofono_call_forwarding *cf);
> +static void sim_read_cf_indicator(struct ofono_call_forwarding *cf);
>  
>  struct cf_ss_request {
>   int ss_type;
> @@ -1358,18 +1359,52 @@ static void sim_cphs_cff_read_cb(int ok, int 
> total_length, int record,
>   DBUS_TYPE_BOOLEAN, &cfu_voice);
>  }
>  
> +static void sim_cfis_changed(int id, void *userdata)
> +{
> + struct ofono_call_forwarding *cf = userdata;
> +
> + if (((cf->flags & CALL_FORWARDING_FLAG_CPHS_CFF) ||
> + cf->cfis_record_id > 0) && is_cfu_enabled(cf, NULL)) {
> + DBusConnection *conn = ofono_dbus_get_connection();
> + const char *path = __ofono_atom_get_path(cf->atom);
> + ofono_bool_t status = FALSE;
> +
> + ofono_dbus_signal_property_changed(conn, path,
> + OFONO_CALL_FORWARDING_INTERFACE,
> + "ForwardingFlagOnSim",
> + DBUS_TYPE_BOOLEAN, &status);
> + }
> +
> + cf->cfis_record_id = 0;
> + cf->flags &= ~CALL_FORWARDING_FLAG_CPHS_CFF;
> +
> + /*
> +  * TODO: remove forwarding rules in
> +  * cf->cf_conditions[CALL_FORWARDING_TYPE_UNCONDITIONAL] that
> +  * originate from EFcfis before adding the new rules?
> +  */
> +
> + sim_read_cf_indicator(cf);

Wouldn't this result in us adding a 2nd, or 3rd, or 4th, etc file watch
here?

> +}
> +
>  static void sim_read_cf_indicator(struct ofono_call_forwarding *cf)
>  {
>   if (__ofono_sim_service_available(cf->sim,
>   SIM_UST_SERVICE_CFIS,
> - SIM_SST_SERVICE_CFIS) == TRUE)
> + SIM_SST_SERVICE_CFIS) == TRUE) {
>   ofono_sim_read(cf->sim_context, SIM_EFCFIS_FILEID,
>   OFONO_SIM_FILE_STRUCTURE_FIXED,
>   sim_cfis_read_cb, cf);
> - else
> + ofono_sim_add_file_watch(cf->sim_context, SIM_EFCFIS_FILEID,
> + sim_cfis_changed, cf, NULL);
> + } else {
>   ofono_sim_read(cf->sim_context, SIM_EF_CPHS_CFF_FILEID,
>   OFONO_SIM_FILE_STRUCTURE_TRANSPARENT,
>   sim_cphs_cff_read_cb, cf);
> + ofono_sim_add_file_watch(cf->sim_context,
> + SIM_EF_CPHS_CFF_FILEID,
> + sim_cfis_changed, cf, NULL);
> + }
>  }
>  
>  int ofono_call_forwarding_driver_register(const struct 
> ofono_call_forwarding_driver *d)

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


Re: [PATCH 7/9] message-waiting: Watch for changes to relevant SIM files.

2011-02-17 Thread Denis Kenzior
Hi Andrew,

On 02/15/2011 01:58 AM, Andrzej Zaborowski wrote:
> ---
>  src/message-waiting.c |   88 
> -
>  1 files changed, 87 insertions(+), 1 deletions(-)
> 
> diff --git a/src/message-waiting.c b/src/message-waiting.c
> index 72cf582..f5406ca 100644
> --- a/src/message-waiting.c
> +++ b/src/message-waiting.c
> @@ -576,6 +576,33 @@ static void mw_mbdn_read_cb(int ok, int total_length, 
> int record,
>   mw->efmbdn_length = record_length;
>  }
>  
> +static void mw_mbdn_changed(int id, void *userdata)
> +{
> + struct ofono_message_waiting *mw = userdata;
> + int err;
> +
> + mw->efmbdn_length = 0;
> + mw->mbdn_not_provided = FALSE;
> +
> + err = ofono_sim_read(mw->sim_context, SIM_EFMBDN_FILEID,
> + OFONO_SIM_FILE_STRUCTURE_FIXED,
> + mw_mbdn_read_cb, mw);
> + if (err != 0)
> + ofono_error("Unable to read EF-MBDN from SIM");
> +}
> +
> +static void mw_cphs_mbdn_changed(int id, void *userdata)
> +{
> + struct ofono_message_waiting *mw = userdata;
> +
> + mw->ef_cphs_mbdn_length = 0;
> + mw->cphs_mbdn_not_provided = FALSE;
> +
> + ofono_sim_read(mw->sim_context, SIM_EF_CPHS_MBDN_FILEID,
> + OFONO_SIM_FILE_STRUCTURE_FIXED,
> + mw_cphs_mbdn_read_cb, mw);
> +}
> +
>  static void mw_mbi_read_cb(int ok, int total_length, int record,
>   const unsigned char *data,
>   int record_length, void *userdata)
> @@ -604,6 +631,8 @@ static void mw_mbi_read_cb(int ok, int total_length, int 
> record,
>   err = ofono_sim_read(mw->sim_context, SIM_EFMBDN_FILEID,
>   OFONO_SIM_FILE_STRUCTURE_FIXED,
>   mw_mbdn_read_cb, mw);
> + ofono_sim_add_file_watch(mw->sim_context, SIM_EFMBDN_FILEID,
> + mw_mbdn_changed, mw, NULL);
>  
>   if (err != 0)
>   ofono_error("Unable to read EF-MBDN from SIM");
> @@ -615,10 +644,14 @@ out:
>*/
>   st = ofono_sim_get_cphs_service_table(mw->sim);
>  
> - if (st && bit_field(st[0], 4, 2) == 3)
> + if (st && bit_field(st[0], 4, 2) == 3) {
>   ofono_sim_read(mw->sim_context, SIM_EF_CPHS_MBDN_FILEID,
>   OFONO_SIM_FILE_STRUCTURE_FIXED,
>   mw_cphs_mbdn_read_cb, mw);
> + ofono_sim_add_file_watch(mw->sim_context,
> + SIM_EF_CPHS_MBDN_FILEID,
> + mw_cphs_mbdn_changed, mw, NULL);
> + }
>  }
>  
>  static void mw_mwis_write_cb(int ok, void *userdata)
> @@ -935,6 +968,46 @@ static void message_waiting_unregister(struct ofono_atom 
> *atom)
>   ofono_modem_remove_interface(modem, OFONO_MESSAGE_WAITING_INTERFACE);
>  }
>  
> +static void mw_mwis_changed(int id, void *userdata)
> +{
> + struct ofono_message_waiting *mw = userdata;
> +
> + mw->efmwis_length = 0;
> +
> + ofono_sim_read(mw->sim_context, SIM_EFMWIS_FILEID,
> + OFONO_SIM_FILE_STRUCTURE_FIXED,
> + mw_mwis_read_cb, mw);
> +}
> +
> +static void mw_cphs_mwis_changed(int id, void *userdata)
> +{
> + struct ofono_message_waiting *mw = userdata;
> +
> + mw->ef_cphs_mwis_length = 0;
> +
> + ofono_sim_read(mw->sim_context, SIM_EF_CPHS_MWIS_FILEID,
> + OFONO_SIM_FILE_STRUCTURE_TRANSPARENT,
> + mw_cphs_mwis_read_cb, mw);
> +}
> +
> +static void mw_mbi_changed(int id, void *userdata)
> +{
> + struct ofono_message_waiting *mw = userdata;
> +
> + mw->efmbdn_length = 0;
> + mw->mbdn_not_provided = FALSE;
> +
> + mw->ef_cphs_mbdn_length = 0;
> + mw->cphs_mbdn_not_provided = FALSE;
> +
> + ofono_sim_remove_file_watch(mw->sim_context, SIM_EFMBDN_FILEID);
> + ofono_sim_remove_file_watch(mw->sim_context, SIM_EF_CPHS_MBDN_FILEID);

This won't actually work, the id returned by add_file_watch and taken by
remove_file_watch is just an unsigned int.  Not the id of the watched
file.  In theory we can try to make it work this way, but it doesn't
right now.

> +
> + ofono_sim_read(mw->sim_context, SIM_EFMBI_FILEID,
> + OFONO_SIM_FILE_STRUCTURE_FIXED,
> + mw_mbi_read_cb, mw);
> +}
> +
>  void ofono_message_waiting_register(struct ofono_message_waiting *mw)
>  {
>   DBusConnection *conn;
> @@ -980,6 +1053,19 @@ void ofono_message_waiting_register(struct 
> ofono_message_waiting *mw)
>   ofono_sim_read(mw->sim_context, SIM_EF_CPHS_MWIS_FILEID,
>   OFONO_SIM_FILE_STRUCTURE_TRANSPARENT,
>   mw_cphs_mwis_read_cb, mw);
> +
> + /*
> +  * The operator could send us SMS mwi updates, but let's be
> +  * extra careful and track the file contents too.

Re: [PATCH] test-server:Add test of PPP disconnect reason to avoid crash

2011-02-17 Thread Denis Kenzior
Hi Guillaume,

On 02/17/2011 11:27 AM, Guillaume Zajac wrote:
> ---
>  gatchat/test-server.c |6 ++
>  1 files changed, 6 insertions(+), 0 deletions(-)
> 

Patch has been applied, thanks.

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


[PATCH] test-server:Add test of PPP disconnect reason to avoid crash

2011-02-17 Thread Guillaume Zajac
---
 gatchat/test-server.c |6 ++
 1 files changed, 6 insertions(+), 0 deletions(-)

diff --git a/gatchat/test-server.c b/gatchat/test-server.c
index e574d64..28bad1d 100644
--- a/gatchat/test-server.c
+++ b/gatchat/test-server.c
@@ -137,6 +137,12 @@ static void ppp_disconnect(GAtPPPDisconnectReason reason, 
gpointer user)
g_at_ppp_unref(ppp);
ppp = NULL;
 
+   if (reason == G_AT_PPP_REASON_LINK_DEAD) {
+   g_at_server_unref(server);
+   server = NULL;
+   return;
+   }
+
g_at_server_resume(server);
g_at_server_set_debug(server, server_debug, "Server");
 
-- 
1.7.1

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


Re: [PATCH] emulator: force creation of atom at modem offline state

2011-02-17 Thread Denis Kenzior
Hi Frédéric,

On 02/17/2011 11:23 AM, Frédéric Danis wrote:
> this allows to fix problem when atom created in online state
> are destroyed when modem goes to offline state
> ---
>  src/emulator.c |3 ++-
>  src/modem.c|   14 ++
>  src/ofono.h|5 +
>  3 files changed, 21 insertions(+), 1 deletions(-)
> 

Patch has been applied, thanks.

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


[PATCH] emulator: force creation of atom at modem offline state

2011-02-17 Thread Frédéric Danis
this allows to fix problem when atom created in online state
are destroyed when modem goes to offline state
---
 src/emulator.c |3 ++-
 src/modem.c|   14 ++
 src/ofono.h|5 +
 3 files changed, 21 insertions(+), 1 deletions(-)

diff --git a/src/emulator.c b/src/emulator.c
index 5744903..101b33d 100644
--- a/src/emulator.c
+++ b/src/emulator.c
@@ -115,7 +115,8 @@ struct ofono_emulator *ofono_emulator_create(struct 
ofono_modem *modem,
 
em->type = type;
 
-   em->atom = __ofono_modem_add_atom(modem, atom_t, emulator_remove, em);
+   em->atom = __ofono_modem_add_atom_offline(modem, atom_t,
+   emulator_remove, em);
 
return em;
 }
diff --git a/src/modem.c b/src/modem.c
index 8567cac..bf8b0c0 100644
--- a/src/modem.c
+++ b/src/modem.c
@@ -189,6 +189,20 @@ struct ofono_atom *__ofono_modem_add_atom(struct 
ofono_modem *modem,
return atom;
 }
 
+struct ofono_atom *__ofono_modem_add_atom_offline(struct ofono_modem *modem,
+   enum ofono_atom_type type,
+   void (*destruct)(struct ofono_atom *),
+   void *data)
+{
+   struct ofono_atom *atom;
+
+   atom = __ofono_modem_add_atom(modem, type, destruct, data);
+
+   atom->modem_state = MODEM_STATE_OFFLINE;
+
+   return atom;
+}
+
 void *__ofono_atom_get_data(struct ofono_atom *atom)
 {
return atom->data;
diff --git a/src/ofono.h b/src/ofono.h
index f52356e..9d13684 100644
--- a/src/ofono.h
+++ b/src/ofono.h
@@ -148,6 +148,11 @@ struct ofono_atom *__ofono_modem_add_atom(struct 
ofono_modem *modem,
void (*destruct)(struct ofono_atom *),
void *data);
 
+struct ofono_atom *__ofono_modem_add_atom_offline(struct ofono_modem *modem,
+   enum ofono_atom_type type,
+   void (*destruct)(struct ofono_atom *),
+   void *data);
+
 struct ofono_atom *__ofono_modem_find_atom(struct ofono_modem *modem,
enum ofono_atom_type type);
 
-- 
1.7.1

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


Re: [PATCH] test-server:Add test of PPP disconnect reason

2011-02-17 Thread Guillaume Zajac

Hi Denis,

On 17/02/2011 17:50, Denis Kenzior wrote:

Hi Guillaume,

On 02/17/2011 10:37 AM, Guillaume Zajac wrote:

Hi Denis,

On 17/02/2011 17:14, Denis Kenzior wrote:

Hi Guillaume,

On 02/17/2011 07:48 AM, Guillaume Zajac wrote:

---
   gatchat/test-server.c |6 ++
   1 files changed, 6 insertions(+), 0 deletions(-)

diff --git a/gatchat/test-server.c b/gatchat/test-server.c
index e574d64..c0a5a4d 100644
--- a/gatchat/test-server.c
+++ b/gatchat/test-server.c
@@ -137,6 +137,12 @@ static void
ppp_disconnect(GAtPPPDisconnectReason reason, gpointer user)
   g_at_ppp_unref(ppp);
   ppp = NULL;

+if (reason == G_AT_PPP_REASON_NET_FAIL) {

Don't you mean G_AT_PPP_REASON_LINK_DEAD?


In case of test-server, I didn't reproduce the crash with/without the
fix, I applied it to test server first as we don't have dial_cb for
emulator yet:

I did ./gsmdial -i localhost -p 12346

At the end of the exchange:
ppp_lcp_down_notify() is called
disconnect reason is G_AT_PPP_REASON_PEER_CLOSED
then the GAtServer is well resumed.


That is because gsmdial performs graceful shutdown, try killing the app
with -9.


Right, I just tested it and the fix with:

if (reason == G_AT_PPP_REASON_LINK_DEAD) {
g_at_server_unref(server);
server = NULL;
return;
}

is avoiding the crash in case the telnet is killed after we do a ATD*99.
I will submit a new patch for fixing this crash.


In case of emulator (based on Gustavo/ZhenZhua dial_cb),
ppp_lcp_down_notify() is called but just after this one,
ppp_ipcp_up_notify() fails and sets disconnect reason to
G_AT_PPP_REASON_NET_FAIL.

Then we probably have a bug.


Yes, I will try to investigate a bit more on this issue and the action 
to do.



Then we get a crash after ppp_disconnect because we call the hdlc write
handler e.g. can_write_data() into gathldc.c although we have unref the
PPP server.

So I called ofono_emulator_remove() that will call the unref GAtServer
etc... when we get G_AT_PPP_REASON_NET_FAIL into ppp_disconnect

I don't get G_AT_PPP_REASON_LINK_DEAD disconnect reason when emulator
crashes.

So should we call ofono_emulator_remove()/GAtServer_unref() in both
disconnect reason cases?
Or is there a specific action to do when G_AT_PPP_REASON_NET_FAIL?


Not necessarily, NET_FAIL basically means the IPCP negotiation failed.
It is not fatal.


Ok.


Regards,
-Denis


Kind regards,
Guillaume
___
ofono mailing list
ofono@ofono.org
http://lists.ofono.org/listinfo/ofono


Re: [PATCH] bluetooth: remove unneeded g_io_channel_shutdown

2011-02-17 Thread Denis Kenzior
Hi Frédéric,

On 02/17/2011 10:52 AM, Frédéric Danis wrote:
> ---
>  plugins/hfp_ag.c |9 +++--
>  1 files changed, 3 insertions(+), 6 deletions(-)
> 

Patch has been applied, thanks.

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


[PATCH] bluetooth: remove unneeded g_io_channel_shutdown

2011-02-17 Thread Frédéric Danis
---
 plugins/hfp_ag.c |9 +++--
 1 files changed, 3 insertions(+), 6 deletions(-)

diff --git a/plugins/hfp_ag.c b/plugins/hfp_ag.c
index 6acb4dd..6edd73d 100644
--- a/plugins/hfp_ag.c
+++ b/plugins/hfp_ag.c
@@ -95,19 +95,19 @@ static void hfp_ag_connect_cb(GIOChannel *io, GError *err, 
gpointer user_data)
 
if (err) {
DBG("%s", err->message);
-   goto failed;
+   return;
}
 
/* Pick the first voicecall capable modem */
modem = modems->data;
if (modem == NULL)
-   goto failed;
+   return;
 
DBG("Picked modem %p for emulator", modem);
 
em = ofono_emulator_create(modem, OFONO_EMULATOR_TYPE_HFP);
if (em == NULL)
-   goto failed;
+   return;
 
fd = g_io_channel_unix_get_fd(io);
ofono_emulator_register(em, fd);
@@ -115,9 +115,6 @@ static void hfp_ag_connect_cb(GIOChannel *io, GError *err, 
gpointer user_data)
g_io_channel_set_close_on_unref(io, FALSE);
 
return;
-
-failed:
-   g_io_channel_shutdown(io, TRUE, NULL);
 }
 
 static void voicecall_watch(struct ofono_atom *atom,
-- 
1.7.1

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


Re: [PATCH] test-server:Add test of PPP disconnect reason

2011-02-17 Thread Denis Kenzior
Hi Guillaume,

On 02/17/2011 10:37 AM, Guillaume Zajac wrote:
> Hi Denis,
> 
> On 17/02/2011 17:14, Denis Kenzior wrote:
>> Hi Guillaume,
>>
>> On 02/17/2011 07:48 AM, Guillaume Zajac wrote:
>>> ---
>>>   gatchat/test-server.c |6 ++
>>>   1 files changed, 6 insertions(+), 0 deletions(-)
>>>
>>> diff --git a/gatchat/test-server.c b/gatchat/test-server.c
>>> index e574d64..c0a5a4d 100644
>>> --- a/gatchat/test-server.c
>>> +++ b/gatchat/test-server.c
>>> @@ -137,6 +137,12 @@ static void
>>> ppp_disconnect(GAtPPPDisconnectReason reason, gpointer user)
>>>   g_at_ppp_unref(ppp);
>>>   ppp = NULL;
>>>
>>> +if (reason == G_AT_PPP_REASON_NET_FAIL) {
>> Don't you mean G_AT_PPP_REASON_LINK_DEAD?
>>
> 
> In case of test-server, I didn't reproduce the crash with/without the
> fix, I applied it to test server first as we don't have dial_cb for
> emulator yet:
> 
> I did ./gsmdial -i localhost -p 12346
> 
> At the end of the exchange:
> ppp_lcp_down_notify() is called
> disconnect reason is G_AT_PPP_REASON_PEER_CLOSED
> then the GAtServer is well resumed.
> 

That is because gsmdial performs graceful shutdown, try killing the app
with -9.

> In case of emulator (based on Gustavo/ZhenZhua dial_cb),
> ppp_lcp_down_notify() is called but just after this one,
> ppp_ipcp_up_notify() fails and sets disconnect reason to
> G_AT_PPP_REASON_NET_FAIL.

Then we probably have a bug.

> Then we get a crash after ppp_disconnect because we call the hdlc write
> handler e.g. can_write_data() into gathldc.c although we have unref the
> PPP server.
> 
> So I called ofono_emulator_remove() that will call the unref GAtServer
> etc... when we get G_AT_PPP_REASON_NET_FAIL into ppp_disconnect
> 
> I don't get G_AT_PPP_REASON_LINK_DEAD disconnect reason when emulator
> crashes.
> 
> So should we call ofono_emulator_remove()/GAtServer_unref() in both
> disconnect reason cases?
> Or is there a specific action to do when G_AT_PPP_REASON_NET_FAIL?
> 

Not necessarily, NET_FAIL basically means the IPCP negotiation failed.
It is not fatal.

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


Re: [PATCH] test-server:Add test of PPP disconnect reason

2011-02-17 Thread Guillaume Zajac

Hi Denis,

On 17/02/2011 17:14, Denis Kenzior wrote:

Hi Guillaume,

On 02/17/2011 07:48 AM, Guillaume Zajac wrote:

---
  gatchat/test-server.c |6 ++
  1 files changed, 6 insertions(+), 0 deletions(-)

diff --git a/gatchat/test-server.c b/gatchat/test-server.c
index e574d64..c0a5a4d 100644
--- a/gatchat/test-server.c
+++ b/gatchat/test-server.c
@@ -137,6 +137,12 @@ static void ppp_disconnect(GAtPPPDisconnectReason reason, 
gpointer user)
g_at_ppp_unref(ppp);
ppp = NULL;

+   if (reason == G_AT_PPP_REASON_NET_FAIL) {

Don't you mean G_AT_PPP_REASON_LINK_DEAD?



In case of test-server, I didn't reproduce the crash with/without the 
fix, I applied it to test server first as we don't have dial_cb for 
emulator yet:


I did ./gsmdial -i localhost -p 12346

At the end of the exchange:
ppp_lcp_down_notify() is called
disconnect reason is G_AT_PPP_REASON_PEER_CLOSED
then the GAtServer is well resumed.

In case of emulator (based on Gustavo/ZhenZhua dial_cb), 
ppp_lcp_down_notify() is called but just after this one, 
ppp_ipcp_up_notify() fails and sets disconnect reason to 
G_AT_PPP_REASON_NET_FAIL.
Then we get a crash after ppp_disconnect because we call the hdlc write 
handler e.g. can_write_data() into gathldc.c although we have unref the 
PPP server.


So I called ofono_emulator_remove() that will call the unref GAtServer 
etc... when we get G_AT_PPP_REASON_NET_FAIL into ppp_disconnect


I don't get G_AT_PPP_REASON_LINK_DEAD disconnect reason when emulator 
crashes.


So should we call ofono_emulator_remove()/GAtServer_unref() in both 
disconnect reason cases?

Or is there a specific action to do when G_AT_PPP_REASON_NET_FAIL?


+   g_at_server_unref(server);
+   server = NULL;
+   return;
+   }
+
g_at_server_resume(server);
g_at_server_set_debug(server, server_debug, "Server");


Regards,
-Denis



Kind regards,
Guillaume
___
ofono mailing list
ofono@ofono.org
http://lists.ofono.org/listinfo/ofono


Re: [PATCH] test-server:Add test of PPP disconnect reason

2011-02-17 Thread Denis Kenzior
Hi Guillaume,

On 02/17/2011 07:48 AM, Guillaume Zajac wrote:
> ---
>  gatchat/test-server.c |6 ++
>  1 files changed, 6 insertions(+), 0 deletions(-)
> 
> diff --git a/gatchat/test-server.c b/gatchat/test-server.c
> index e574d64..c0a5a4d 100644
> --- a/gatchat/test-server.c
> +++ b/gatchat/test-server.c
> @@ -137,6 +137,12 @@ static void ppp_disconnect(GAtPPPDisconnectReason 
> reason, gpointer user)
>   g_at_ppp_unref(ppp);
>   ppp = NULL;
>  
> + if (reason == G_AT_PPP_REASON_NET_FAIL) {

Don't you mean G_AT_PPP_REASON_LINK_DEAD?

> + g_at_server_unref(server);
> + server = NULL;
> + return;
> + }
> +
>   g_at_server_resume(server);
>   g_at_server_set_debug(server, server_debug, "Server");
>  

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


Re: [PATCH 0/2] Fix reference handling in hfp_ag

2011-02-17 Thread Denis Kenzior
Hi Frédéric,

On 02/17/2011 09:55 AM, Frédéric Dalleau wrote:
> Hi, these patch fixes reference handling in hfp_ag.
> 
> First patch makes sure that GATServer properly disconnects client
> when modem is put offline. 
> 
> Second patch fixes a Glib warning about a socket closed twice.
> dun_gw may need something similar.
> 
> Frédéric Dalleau (2):
>   emulator: unref GIOChannel after creation
>   hfp_ag: Do not close client fd on unref
> 
>  plugins/hfp_ag.c |9 +
>  src/emulator.c   |2 ++
>  2 files changed, 3 insertions(+), 8 deletions(-)
> 

Both patches have been applied, thanks.

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


[PATCH 2/2] hfp_ag: Do not close client fd on unref

2011-02-17 Thread Frédéric Dalleau
---
 plugins/hfp_ag.c |   10 +-
 1 files changed, 1 insertions(+), 9 deletions(-)

diff --git a/plugins/hfp_ag.c b/plugins/hfp_ag.c
index cbf3ccd..cb4a0be 100644
--- a/plugins/hfp_ag.c
+++ b/plugins/hfp_ag.c
@@ -40,7 +40,6 @@
 static struct server *server;
 static guint modemwatch_id;
 static GList *modems;
-static guint channel_watch;
 
 static const gchar *hfp_ag_record =
 "\n"
@@ -86,12 +85,6 @@ static const gchar *hfp_ag_record =
 "  \n"
 "\n";
 
-static gboolean hfp_ag_disconnect_cb(GIOChannel *io, GIOCondition cond,
-   gpointer user_data)
-{
-   return FALSE;
-}
-
 static void hfp_ag_connect_cb(GIOChannel *io, GError *err, gpointer user_data)
 {
struct ofono_modem *modem;
@@ -118,8 +111,7 @@ static void hfp_ag_connect_cb(GIOChannel *io, GError *err, 
gpointer user_data)
fd = g_io_channel_unix_get_fd(io);
ofono_emulator_register(em, fd);
 
-   channel_watch = g_io_add_watch(io, G_IO_NVAL | G_IO_HUP | G_IO_ERR,
-   hfp_ag_disconnect_cb, NULL);
+   g_io_channel_set_close_on_unref(io, FALSE);
 
return;
 
-- 
1.7.1

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


[PATCH 0/2] Fix reference handling in hfp_ag

2011-02-17 Thread Frédéric Dalleau
Hi, these patch fixes reference handling in hfp_ag.

First patch makes sure that GATServer properly disconnects client
when modem is put offline. 

Second patch fixes a Glib warning about a socket closed twice.
dun_gw may need something similar.

Frédéric Dalleau (2):
  emulator: unref GIOChannel after creation
  hfp_ag: Do not close client fd on unref

 plugins/hfp_ag.c |9 +
 src/emulator.c   |2 ++
 2 files changed, 3 insertions(+), 8 deletions(-)

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


[PATCH 1/2] emulator: unref GIOChannel after creation

2011-02-17 Thread Frédéric Dalleau
---
 src/emulator.c |2 ++
 1 files changed, 2 insertions(+), 0 deletions(-)

diff --git a/src/emulator.c b/src/emulator.c
index 567692d..5744903 100644
--- a/src/emulator.c
+++ b/src/emulator.c
@@ -75,6 +75,8 @@ void ofono_emulator_register(struct ofono_emulator *em, int 
fd)
if (em->server == NULL)
return;
 
+   g_io_channel_unref(io);
+
g_at_server_set_debug(em->server, emulator_debug, "Server");
g_at_server_set_disconnect_function(em->server,
emulator_disconnect, em);
-- 
1.7.1

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


Re: [PATCH 2/2] emulator: add dialing support

2011-02-17 Thread Gustavo F. Padovan
Hi Guillaume,

* Guillaume Zajac  [2011-02-17 14:27:31 +0100]:

> Hi Gustavo,
> 
> On 16/02/2011 22:41, Gustavo F. Padovan wrote:
> > It handles client ATD*99# request and then initiate the PPP negotiation.
> > IP forward through the new ppp interface is not done yet.
> >
> > Initially based on patches from Zhenhua Zhang
> > ---
> >   src/emulator.c |  113 
> > 
> >   1 files changed, 113 insertions(+), 0 deletions(-)
> >
> > diff --git a/src/emulator.c b/src/emulator.c
> > index 567692d..c60863b 100644
> > --- a/src/emulator.c
> > +++ b/src/emulator.c
> > @@ -29,11 +29,18 @@
> >
> >   #include "ofono.h"
> >   #include "gatserver.h"
> > +#include "gatppp.h"
> > +
> > +#define DUN_SERVER_ADDRESS "192.168.1.1"
> > +#define DUN_PEER_ADDRESS   "192.168.1.2"
> > +#define DUN_DNS_SERVER_1   "10.10.10.10"
> > +#define DUN_DNS_SERVER_2   "10.10.10.11"
> >
> >   struct ofono_emulator {
> > struct ofono_atom *atom;
> > enum ofono_emulator_type type;
> > GAtServer *server;
> > +   GAtPPP *ppp;
> >   };
> >
> >   static void emulator_debug(const char *str, void *data)
> > @@ -50,6 +57,110 @@ static void emulator_disconnect(gpointer user_data)
> > ofono_emulator_remove(em);
> >   }
> >
> > +static void ppp_connect(const char *iface, const char *local,
> > +   const char *remote,
> > +   const char *dns1, const char *dns2,
> > +   gpointer user_data)
> > +{
> > +   DBG("Network Device: %s\n", iface);
> > +   DBG("IP Address: %s\n", local);
> > +   DBG("Remote IP Address: %s\n", remote);
> > +   DBG("Primary DNS Server: %s\n", dns1);
> > +   DBG("Secondary DNS Server: %s\n", dns2);
> > +}
> > +
> > +static void ppp_disconnect(GAtPPPDisconnectReason reason, gpointer 
> > user_data)
> > +{
> > +   struct ofono_emulator *em = user_data;
> > +
> > +   DBG("");
> > +
> > +   g_at_ppp_unref(em->ppp);
> > +   em->ppp = NULL;
> > +
> > +   if (em->server == NULL)
> > +   return;
> > +
> > +   g_at_server_resume(em->server);
> > +}
> > +
> > +static gboolean setup_ppp(gpointer user_data)
> > +{
> > +   struct ofono_emulator *em = user_data;
> > +   GAtIO *io;
> > +
> > +   DBG("");
> > +
> > +   io = g_at_server_get_io(em->server);
> > +
> > +   g_at_server_suspend(em->server);
> > +
> > +   em->ppp = g_at_ppp_server_new_from_io(io, DUN_SERVER_ADDRESS);
> > +   if (em->ppp == NULL) {
> > +   g_at_server_resume(em->server);
> > +   return FALSE;
> > +   }
> > +
> > +   g_at_ppp_set_server_info(em->ppp, DUN_PEER_ADDRESS,
> > +   DUN_DNS_SERVER_1, DUN_DNS_SERVER_2);
> > +
> > +   g_at_ppp_set_credentials(em->ppp, "", "");
> > +   g_at_ppp_set_debug(em->ppp, emulator_debug, "PPP");
> > +
> > +   g_at_ppp_set_connect_function(em->ppp, ppp_connect, em);
> > +   g_at_ppp_set_disconnect_function(em->ppp, ppp_disconnect, em);
> > +
> > +   return FALSE;
> > +}
> > +
> > +static gboolean dial_call(struct ofono_emulator *e, const char *dial_str)
> > +{
> > +   char c = *dial_str;
> > +
> > +   DBG("dial call %s", dial_str);
> > +
> > +   if (c == '*' || c == '#' || c == 'T' || c == 't') {
> > +
> > +   g_at_server_send_intermediate(e->server, "CONNECT");
> > +   g_idle_add(setup_ppp, e);
> > +   }
> > +
> > +   return TRUE;
> > +}
> > +
> > +static void dial_cb(GAtServer *server, GAtServerRequestType type,
> > +GAtResult *result, gpointer user_data)
> > +{
> > +   struct ofono_emulator *em = user_data;
> > +   GAtResultIter iter;
> > +   const char *dial_str;
> > +
> > +   DBG("");
> > +
> > +   if (type != G_AT_SERVER_REQUEST_TYPE_SET)
> > +   goto error;
> > +
> > +   g_at_result_iter_init(&iter, result);
> > +
> > +   if (!g_at_result_iter_next(&iter, ""))
> > +   goto error;
> > +
> > +   dial_str = g_at_result_iter_raw_line(&iter);
> > +   if (!dial_str)
> > +   goto error;
> > +
> > +   if (em->ppp)
> > +   goto error;
> > +
> > +   if (!dial_call(em, dial_str))
> > +   goto error;
> > +
> > +   return;
> > +
> > +error:
> > +   g_at_server_send_final(em->server, G_AT_SERVER_RESULT_ERROR);
> > +}
> > +
> >   static void emulator_unregister(struct ofono_atom *atom)
> >   {
> > struct ofono_emulator *em = __ofono_atom_get_data(atom);
> > @@ -80,6 +191,8 @@ void ofono_emulator_register(struct ofono_emulator *em, 
> > int fd)
> > emulator_disconnect, em);
> >
> > __ofono_atom_register(em->atom, emulator_unregister);
> > +
> > +   g_at_server_register(em->server, "D", dial_cb, em, NULL);
> 
> There is an issue here, you are registering this dial_cb independantly 
> from the emulator type e.g. f

[PATCH] test-server:Add test of PPP disconnect reason

2011-02-17 Thread Guillaume Zajac
---
 gatchat/test-server.c |6 ++
 1 files changed, 6 insertions(+), 0 deletions(-)

diff --git a/gatchat/test-server.c b/gatchat/test-server.c
index e574d64..c0a5a4d 100644
--- a/gatchat/test-server.c
+++ b/gatchat/test-server.c
@@ -137,6 +137,12 @@ static void ppp_disconnect(GAtPPPDisconnectReason reason, 
gpointer user)
g_at_ppp_unref(ppp);
ppp = NULL;
 
+   if (reason == G_AT_PPP_REASON_NET_FAIL) {
+   g_at_server_unref(server);
+   server = NULL;
+   return;
+   }
+
g_at_server_resume(server);
g_at_server_set_debug(server, server_debug, "Server");
 
-- 
1.7.1

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


Re: [PATCH 2/2] emulator: add dialing support

2011-02-17 Thread Guillaume Zajac

Hi Gustavo,

On 16/02/2011 22:41, Gustavo F. Padovan wrote:

It handles client ATD*99# request and then initiate the PPP negotiation.
IP forward through the new ppp interface is not done yet.

Initially based on patches from Zhenhua Zhang
---
  src/emulator.c |  113 
  1 files changed, 113 insertions(+), 0 deletions(-)

diff --git a/src/emulator.c b/src/emulator.c
index 567692d..c60863b 100644
--- a/src/emulator.c
+++ b/src/emulator.c
@@ -29,11 +29,18 @@

  #include "ofono.h"
  #include "gatserver.h"
+#include "gatppp.h"
+
+#define DUN_SERVER_ADDRESS "192.168.1.1"
+#define DUN_PEER_ADDRESS   "192.168.1.2"
+#define DUN_DNS_SERVER_1   "10.10.10.10"
+#define DUN_DNS_SERVER_2   "10.10.10.11"

  struct ofono_emulator {
struct ofono_atom *atom;
enum ofono_emulator_type type;
GAtServer *server;
+   GAtPPP *ppp;
  };

  static void emulator_debug(const char *str, void *data)
@@ -50,6 +57,110 @@ static void emulator_disconnect(gpointer user_data)
ofono_emulator_remove(em);
  }

+static void ppp_connect(const char *iface, const char *local,
+   const char *remote,
+   const char *dns1, const char *dns2,
+   gpointer user_data)
+{
+   DBG("Network Device: %s\n", iface);
+   DBG("IP Address: %s\n", local);
+   DBG("Remote IP Address: %s\n", remote);
+   DBG("Primary DNS Server: %s\n", dns1);
+   DBG("Secondary DNS Server: %s\n", dns2);
+}
+
+static void ppp_disconnect(GAtPPPDisconnectReason reason, gpointer user_data)
+{
+   struct ofono_emulator *em = user_data;
+
+   DBG("");
+
+   g_at_ppp_unref(em->ppp);
+   em->ppp = NULL;
+
+   if (em->server == NULL)
+   return;
+
+   g_at_server_resume(em->server);
+}
+
+static gboolean setup_ppp(gpointer user_data)
+{
+   struct ofono_emulator *em = user_data;
+   GAtIO *io;
+
+   DBG("");
+
+   io = g_at_server_get_io(em->server);
+
+   g_at_server_suspend(em->server);
+
+   em->ppp = g_at_ppp_server_new_from_io(io, DUN_SERVER_ADDRESS);
+   if (em->ppp == NULL) {
+   g_at_server_resume(em->server);
+   return FALSE;
+   }
+
+   g_at_ppp_set_server_info(em->ppp, DUN_PEER_ADDRESS,
+   DUN_DNS_SERVER_1, DUN_DNS_SERVER_2);
+
+   g_at_ppp_set_credentials(em->ppp, "", "");
+   g_at_ppp_set_debug(em->ppp, emulator_debug, "PPP");
+
+   g_at_ppp_set_connect_function(em->ppp, ppp_connect, em);
+   g_at_ppp_set_disconnect_function(em->ppp, ppp_disconnect, em);
+
+   return FALSE;
+}
+
+static gboolean dial_call(struct ofono_emulator *e, const char *dial_str)
+{
+   char c = *dial_str;
+
+   DBG("dial call %s", dial_str);
+
+   if (c == '*' || c == '#' || c == 'T' || c == 't') {
+
+   g_at_server_send_intermediate(e->server, "CONNECT");
+   g_idle_add(setup_ppp, e);
+   }
+
+   return TRUE;
+}
+
+static void dial_cb(GAtServer *server, GAtServerRequestType type,
+GAtResult *result, gpointer user_data)
+{
+   struct ofono_emulator *em = user_data;
+   GAtResultIter iter;
+   const char *dial_str;
+
+   DBG("");
+
+   if (type != G_AT_SERVER_REQUEST_TYPE_SET)
+   goto error;
+
+   g_at_result_iter_init(&iter, result);
+
+   if (!g_at_result_iter_next(&iter, ""))
+   goto error;
+
+   dial_str = g_at_result_iter_raw_line(&iter);
+   if (!dial_str)
+   goto error;
+
+   if (em->ppp)
+   goto error;
+
+   if (!dial_call(em, dial_str))
+   goto error;
+
+   return;
+
+error:
+   g_at_server_send_final(em->server, G_AT_SERVER_RESULT_ERROR);
+}
+
  static void emulator_unregister(struct ofono_atom *atom)
  {
struct ofono_emulator *em = __ofono_atom_get_data(atom);
@@ -80,6 +191,8 @@ void ofono_emulator_register(struct ofono_emulator *em, int 
fd)
emulator_disconnect, em);

__ofono_atom_register(em->atom, emulator_unregister);
+
+   g_at_server_register(em->server, "D", dial_cb, em, NULL);


There is an issue here, you are registering this dial_cb independantly 
from the emulator type e.g. for hfp_ag it won't match.
Maybe you should test the emulator type or make the CB registered by the 
GPRS atom.


We can also keep only one callback and manage the different emulator 
type into it.



  }

  static void emulator_remove(struct ofono_atom *atom)


Kind regards,
Guillaume

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


Re: [PATCH 17/18] isimodem: CBS for wgmodem2.5

2011-02-17 Thread Andreas WESTIN

Hi Denis,

On 2011-02-16 17:10, Denis Kenzior wrote:

Hi Andreas,


Have you thought of adapting cbs_extract_topic_ranges function for all
of this somehow?



Yes we are looking at it now.

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


The answer Api in Voicecall can't work

2011-02-17 Thread cy xie
Hi guys,
  I faced a problem, I use ofono on N900, and try to answer the call .
When the state change to Incoming, I use Answe() API, but the api can't call
succeed.
The hangupall() api is no problem, Can anybody help me? thanks.
___
ofono mailing list
ofono@ofono.org
http://lists.ofono.org/listinfo/ofono


Re: [PATCH 16/18] isimodem: sms updated with wgmodem2.5

2011-02-17 Thread Aki Niemi
Hi Andreas,

2011/2/16 Andreas WESTIN :
>> This UICC stuff seems to be leftovers form patch 8/18.
>
> Well they are related to SMS, debug prints. But yes they are also UICC. Do
> you want them in patch 8 ?

That would be my preference. That is, a patch to bring in the PN_UICC
codepoints and debugs, then separate patches for implementations using
those new codepoints.

> PN_SIM client is created in the UICC client verify callback if it fails, do
> we not get a response to that callback even if UICC fails ?

Ah, right.

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


Re: [PATCH 05/18] plugins: add plugin for u8500

2011-02-17 Thread Aki Niemi
Hi Andreas,

2011/2/16 Andreas WESTIN :
>>> +       if (!g_isi_modem_set_version(isimodem, modemversion))
>>> +               return -EINVAL;
>>
>> I'm not going to add this API in GIsiModem. If we went this route, and
>> used vendor quirks inside the isimodem driver, then it would make a
>> whole lot more sense to do it in the driver create(), not here.
>>
>> But we're not going that route. Each driver detects the version of the
>> ISI service it is talking to when it is probed.
>>
>
> Yes this should not be there, but maybe I misunderstood you regarding the
> version handling. I was under the impression that we checked the version we
> get from doing PN_MTC or PN_MODEM_MCE ?

The modem driver is a bit of a special case again. There is no generic
isimodem modem driver, but each modem plugin implements their own
version. Here, just use PN_MODEM_MCE, since that is what the U8500
uses.

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