[gprs-provision PATCHv4 0/8] plugin API for provisioning of GPRS context settings

2011-01-18 Thread Jukka Saunamaki
Hello

Here is a new patchset about implementing automatic provisioning of GPRS 
context settings. (Internet Access Provider database TODO item).

Compared to last one, this makes gprs-provision a pseudo atom similar to 
nettime. And possible races caused by a removed gprs-atom, while it is running 
asyncronous provisioning, should hopefully be fixed now.

Provisioning data for gprs contexts is returned by gprs-provisioning 
plugins/drivers. Different kind of provisioning modules may be created for 
different platforms or use cases.
It is up to the module what settings database it uses, and how many, and what 
type of contexts (with settings) it returns.
Several plugins may be loaded in oFono, and they will be called in priority 
order until first plugin returns non-empty result.

Provisioning modules are called in case there are no previously configured 
contexts found during gprs atom registration.
 
These patches add new gprs-provision.[hc] API for provisioning plugins to 
register into, and __ofono_gprs_provision_get_settings for gprs.c to call when 
needed.
gprs.c is modified to use provisioning if reading existing context settings 
fails.

A dummy example provisioning plugin is included. In case it is called when 
using phonesim with default.xml configuration, the plugin returns dummy 
settings for two contexts, one type Internet and one type MMS. 

Patches also add new functions ofono_sim_get_mcc/mnc to SIM atom API (typically 
needed by provisioning plugins).

--Jukka Saunamäki

Jukka Saunamaki (8):
  gprs-provision: add driver API header
  gprs-provision: add new atom type
  gprs-provision: add driver API sources
  gprs-provision: probe gprs_provision drivers
  gprs: add gprs context provisioning
  sim: getters for mcc and mnc definition
  sim: getters for mcc and mnc implementation
  gprs-provision: add example context provisioning driver

 Makefile.am  |7 +-
 examples/provision.c |  206 
 include/gprs-provision.h |   80 
 include/sim.h|2 +
 src/gprs-provision.c |  236 ++
 src/gprs.c   |  147 ++---
 src/modem.c  |1 +
 src/ofono.h  |9 ++
 src/sim.c|   50 ++
 9 files changed, 703 insertions(+), 35 deletions(-)
 create mode 100644 examples/provision.c
 create mode 100644 include/gprs-provision.h
 create mode 100644 src/gprs-provision.c


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


[PATCH 4/8] gprs-provision: probe gprs_provision drivers

2011-01-18 Thread Jukka Saunamaki
---
 src/modem.c |1 +
 1 files changed, 1 insertions(+), 0 deletions(-)

diff --git a/src/modem.c b/src/modem.c
index f587766..a835775 100644
--- a/src/modem.c
+++ b/src/modem.c
@@ -424,6 +424,7 @@ static void modem_change_state(struct ofono_modem *modem,
driver-post_sim(modem);
__ofono_history_probe_drivers(modem);
__ofono_nettime_probe_drivers(modem);
+   __ofono_gprs_provision_probe_drivers(modem);
} else
notify_online_watches(modem);
 
-- 
1.7.1

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


[PATCH 2/8] gprs-provision: add new atom type

2011-01-18 Thread Jukka Saunamaki
---
 src/ofono.h |9 +
 1 files changed, 9 insertions(+), 0 deletions(-)

diff --git a/src/ofono.h b/src/ofono.h
index 77567c2..873b688 100644
--- a/src/ofono.h
+++ b/src/ofono.h
@@ -127,6 +127,7 @@ enum ofono_atom_type {
OFONO_ATOM_TYPE_NETTIME = 21,
OFONO_ATOM_TYPE_CTM = 22,
OFONO_ATOM_TYPE_CDMA_VOICECALL_MANAGER = 23,
+   OFONO_ATOM_TYPE_GPRS_PROVISION = 24,
 };
 
 enum ofono_atom_watch_condition {
@@ -417,4 +418,12 @@ void __ofono_nettime_probe_drivers(struct ofono_modem 
*modem);
 void __ofono_nettime_info_received(struct ofono_modem *modem,
struct ofono_network_time *info);
 
+#include ofono/gprs-provision.h
+
+void __ofono_gprs_provision_probe_drivers(struct ofono_modem *modem);
+
+void __ofono_gprs_provision_get_settings(struct ofono_modem *modem,
+   ofono_gprs_provision_cb_t cb,
+   void *user_data);
+
 #include ofono/cdma-voicecall.h
-- 
1.7.1

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


[PATCH 5/8] gprs: add gprs context provisioning

2011-01-18 Thread Jukka Saunamaki
---
 src/gprs.c |  147 ++--
 1 files changed, 133 insertions(+), 14 deletions(-)

diff --git a/src/gprs.c b/src/gprs.c
index 0e86bdf..b0d58f6 100644
--- a/src/gprs.c
+++ b/src/gprs.c
@@ -43,6 +43,7 @@
 #include common.h
 #include storage.h
 #include idmap.h
+#include gprs-provision.h
 
 #define GPRS_FLAG_ATTACHING 0x1
 #define GPRS_FLAG_RECHECK 0x2
@@ -82,6 +83,7 @@ struct ofono_gprs {
const struct ofono_gprs_driver *driver;
void *driver_data;
struct ofono_atom *atom;
+   struct provision_request *provision;
 };
 
 struct ofono_gprs_context {
@@ -122,6 +124,10 @@ struct pri_context {
struct ofono_gprs *gprs;
 };
 
+struct provision_request {
+   struct ofono_gprs *gprs;
+};
+
 static void gprs_netreg_update(struct ofono_gprs *gprs);
 static void gprs_deactivate_next(struct ofono_gprs *gprs);
 
@@ -2203,6 +2209,9 @@ static void gprs_remove(struct ofono_atom *atom)
if (gprs-driver  gprs-driver-remove)
gprs-driver-remove(gprs);
 
+   if (gprs-provision != NULL)
+   gprs-provision-gprs = NULL;
+
g_free(gprs);
 }
 
@@ -2456,13 +2465,15 @@ remove:
storage_sync(imsi, SETTINGS_STORE, gprs-settings);
 }
 
-void ofono_gprs_register(struct ofono_gprs *gprs)
+static void ofono_gprs_finish_register(struct ofono_gprs *gprs)
 {
DBusConnection *conn = ofono_dbus_get_connection();
struct ofono_modem *modem = __ofono_atom_get_modem(gprs-atom);
const char *path = __ofono_atom_get_path(gprs-atom);
struct ofono_atom *netreg_atom;
-   struct ofono_atom *sim_atom;
+
+   if (gprs-contexts == NULL) /* Automatic provisioning failed */
+   add_context(gprs, NULL, OFONO_GPRS_CONTEXT_TYPE_INTERNET);
 
if (!g_dbus_register_interface(conn, path,
OFONO_CONNECTION_MANAGER_INTERFACE,
@@ -2477,18 +2488,6 @@ void ofono_gprs_register(struct ofono_gprs *gprs)
ofono_modem_add_interface(modem,
OFONO_CONNECTION_MANAGER_INTERFACE);
 
-   sim_atom = __ofono_modem_find_atom(modem, OFONO_ATOM_TYPE_SIM);
-
-   if (sim_atom) {
-   struct ofono_sim *sim = __ofono_atom_get_data(sim_atom);
-   const char *imsi = ofono_sim_get_imsi(sim);
-
-   gprs_load_settings(gprs, imsi);
-   }
-
-   if (gprs-contexts == NULL)
-   add_context(gprs, NULL, OFONO_GPRS_CONTEXT_TYPE_INTERNET);
-
gprs-netreg_watch = __ofono_modem_add_atom_watch(modem,
OFONO_ATOM_TYPE_NETREG,
netreg_watch, gprs, NULL);
@@ -2502,6 +2501,126 @@ void ofono_gprs_register(struct ofono_gprs *gprs)
__ofono_atom_register(gprs-atom, gprs_unregister);
 }
 
+static void provision_context(gpointer data, gpointer user_data)
+{
+   struct ofono_gprs_provision_data *ap = data;
+   struct ofono_gprs *gprs = user_data;
+
+   unsigned int id;
+   struct pri_context *context = NULL;
+
+   /* Sanity check */
+   if (ap == NULL || ap-name == NULL)
+   return;
+
+   if (gprs-last_context_id)
+   id = idmap_alloc_next(gprs-pid_map, gprs-last_context_id);
+   else
+   id = idmap_alloc(gprs-pid_map);
+
+   if (id  idmap_get_max(gprs-pid_map))
+   return;
+
+   context = pri_context_create(gprs, ap-name, ap-type);
+   DBG(%s context%d '%s' %s, gprs_context_default_name(ap-type),
+   id, ap-name, context ? created : creation failed);
+
+   if (context == NULL)
+   return;
+
+   context-id = id;
+
+   if (ap-username != NULL)
+   strncpy(context-context.username, ap-username,
+   OFONO_GPRS_MAX_USERNAME_LENGTH);
+
+   if (ap-password != NULL)
+   strncpy(context-context.password, ap-password,
+   OFONO_GPRS_MAX_PASSWORD_LENGTH);
+
+   if (ap-apn != NULL)
+   strncpy(context-context.apn, ap-apn,
+   OFONO_GPRS_MAX_APN_LENGTH);
+
+   context-context.proto = ap-proto;
+
+   if (ap-type == OFONO_GPRS_CONTEXT_TYPE_MMS 
+   ap-message_proxy != NULL)
+   strncpy(context-message_proxy, ap-message_proxy,
+   MAX_MESSAGE_PROXY_LENGTH);
+
+   if (ap-type == OFONO_GPRS_CONTEXT_TYPE_MMS 
+   ap-message_center != NULL)
+   strncpy(context-message_center, ap-message_center,
+   MAX_MESSAGE_CENTER_LENGTH);
+
+   if (context_dbus_register(context) == TRUE) {
+   gprs-last_context_id = id;
+   gprs-contexts = g_slist_append(gprs-contexts, context);
+   write_context_settings(gprs, context);
+
+   if (context-type == OFONO_GPRS_CONTEXT_TYPE_MMS) {
+   

[PATCH 3/8] gprs-provision: add driver API sources

2011-01-18 Thread Jukka Saunamaki
---
 Makefile.am  |2 +-
 src/gprs-provision.c |  236 ++
 2 files changed, 237 insertions(+), 1 deletions(-)
 create mode 100644 src/gprs-provision.c

diff --git a/Makefile.am b/Makefile.am
index 22ec95d..e792851 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -354,7 +354,7 @@ src_ofonod_SOURCES = $(gdbus_sources) $(builtin_sources) 
src/ofono.ver \
src/nettime.c src/stkagent.c src/stkagent.h \
src/simfs.c src/simfs.h src/audio-settings.c \
src/smsagent.c src/smsagent.h src/ctm.c \
-   src/cdma-voicecall.c
+   src/cdma-voicecall.c src/gprs-provision.c
 
 src_ofonod_LDADD = $(builtin_libadd) @GLIB_LIBS@ @DBUS_LIBS@ @CAPNG_LIBS@ -ldl
 
diff --git a/src/gprs-provision.c b/src/gprs-provision.c
new file mode 100644
index 000..1690bc7
--- /dev/null
+++ b/src/gprs-provision.c
@@ -0,0 +1,236 @@
+/*
+ *
+ *  oFono - Open Source Telephony
+ *
+ *  Copyright (C) 2011  Nokia Corporation and/or its subsidiary(-ies).
+ *
+ *  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
+
+#include stdlib.h
+#include glib.h
+
+#include ofono.h
+#include gprs-provision.h
+
+static GSList *g_drivers = NULL;
+static GSList *provision_requests = NULL;
+
+struct gprs_provision_request {
+   GSList *drivers; /* Provisioning drivers to be called */
+   struct ofono_modem *modem;
+   ofono_gprs_provision_cb_t cb;
+   void *user_data;
+};
+
+static void settings_cb(GSList *settings, void *user_data);
+
+static struct ofono_gprs_provision_context *gprs_provision_context_create(
+   struct ofono_modem *modem,
+   struct ofono_gprs_provision_driver *driver)
+{
+   struct ofono_gprs_provision_context *context;
+
+   if (driver-probe == NULL)
+   return NULL;
+
+   context = g_try_new0(struct ofono_gprs_provision_context, 1);
+
+   if (context == NULL)
+   return NULL;
+
+   context-driver = driver;
+   context-modem = modem;
+
+   if (driver-probe(context)  0) {
+   g_free(context);
+   return NULL;
+   }
+
+   return context;
+}
+
+static void clean_active_requests(gpointer data, gpointer user_data)
+{
+   struct gprs_provision_request *req = data;
+   struct ofono_gprs_provision_context *context = user_data;
+
+   req-drivers = g_slist_remove(req-drivers, context);
+}
+
+static void context_remove(struct ofono_atom *atom)
+{
+   struct ofono_gprs_provision_context *context =
+   __ofono_atom_get_data(atom);
+
+   g_slist_foreach(provision_requests, clean_active_requests, context);
+
+   if (context-driver-remove)
+   context-driver-remove(context);
+
+   g_free(context);
+}
+
+void __ofono_gprs_provision_probe_drivers(struct ofono_modem *modem)
+{
+   struct ofono_gprs_provision_driver *driver;
+   struct ofono_gprs_provision_context *context;
+   GSList *l;
+
+   for (l = g_drivers; l; l = l-next) {
+   driver = l-data;
+
+   context = gprs_provision_context_create(modem, driver);
+   if (context == NULL)
+   continue;
+
+   __ofono_modem_add_atom(modem, OFONO_ATOM_TYPE_GPRS_PROVISION,
+   context_remove, context);
+   }
+}
+
+void ofono_gprs_provision_data_free(struct ofono_gprs_provision_data *data)
+{
+   if (data == NULL)
+   return;
+
+   free(data-name);
+   free(data-apn);
+   free(data-username);
+   free(data-password);
+   free(data-message_proxy);
+   free(data-message_center);
+   g_free(data);
+}
+
+/*
+ * Calls next driver that has callable get_settings()
+ * Returns TRUE if a driver was called.
+ */
+static gboolean call_driver_get_settings(struct gprs_provision_request *req,
+   ofono_gprs_provision_cb_t cb)
+{
+   struct ofono_gprs_provision_context *context;
+
+   if (req-drivers == NULL)
+   return FALSE;
+
+   do {
+   context = req-drivers-data;
+   req-drivers = g_slist_delete_link(req-drivers, req-drivers);
+
+   if 

[PATCH 1/8] gprs-provision: add driver API header

2011-01-18 Thread Jukka Saunamaki
---
 Makefile.am  |2 +-
 include/gprs-provision.h |   80 ++
 2 files changed, 81 insertions(+), 1 deletions(-)
 create mode 100644 include/gprs-provision.h

diff --git a/Makefile.am b/Makefile.am
index da59be7..22ec95d 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -15,7 +15,7 @@ include_HEADERS = include/log.h include/plugin.h 
include/history.h \
include/radio-settings.h include/stk.h \
include/audio-settings.h include/nettime.h \
include/ctm.h include/cdma-voicecall.h \
-   include/cdma-sms.h
+   include/cdma-sms.h include/gprs-provision.h
 
 nodist_include_HEADERS = include/version.h
 
diff --git a/include/gprs-provision.h b/include/gprs-provision.h
new file mode 100644
index 000..70152b4
--- /dev/null
+++ b/include/gprs-provision.h
@@ -0,0 +1,80 @@
+/*
+ *
+ *  oFono - Open Telephony stack for Linux
+ *
+ *  Copyright (C) 2011  Nokia Corporation and/or its subsidiary(-ies).
+ *
+ *  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
+ *
+ */
+
+#ifndef __OFONO_GPRS_PROVISION_H
+#define __OFONO_GPRS_PROVISION_H
+
+#ifdef __cplusplus
+extern C {
+#endif
+
+#include gprs-context.h
+
+struct ofono_gprs_provision_context {
+   struct ofono_gprs_provision_driver *driver;
+   struct ofono_modem *modem;
+   void *data;
+};
+
+struct ofono_gprs_provision_data {
+   enum ofono_gprs_context_type type;
+   enum ofono_gprs_proto proto;
+   char *name;
+   char *apn;
+   char *username;
+   char *password;
+   char *message_proxy;
+   char *message_center;
+};
+
+/*
+ * Callback from provisioning plugin.
+ * settings: list of struct ofono_gprs_provision_data
+ *
+ * It is responsibility of callback function to free settings-list
+ * settings-list elements must be freed with ofono_gprs_provision_data_free()
+ */
+typedef void (*ofono_gprs_provision_cb_t)(GSList *settings, void *userdata);
+
+struct ofono_gprs_provision_driver {
+   const char *name;
+   int priority;
+   int (*probe)(struct ofono_gprs_provision_context *context);
+   void (*remove)(struct ofono_gprs_provision_context *context);
+   void (*get_settings) (struct ofono_gprs_provision_context *context,
+   ofono_gprs_provision_cb_t cb,
+   void *user_data);
+};
+
+/* For provisioning drivers/plugins */
+int ofono_gprs_provision_driver_register(
+   const struct ofono_gprs_provision_driver *driver);
+void ofono_gprs_provision_driver_unregister(
+   const struct ofono_gprs_provision_driver *driver);
+
+/* For gprs */
+void ofono_gprs_provision_data_free(struct ofono_gprs_provision_data *data);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* __OFONO_GPRS_PROVISION_H */
-- 
1.7.1

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


[PATCH 6/8] sim: getters for mcc and mnc definition

2011-01-18 Thread Jukka Saunamaki
---
 include/sim.h |2 ++
 1 files changed, 2 insertions(+), 0 deletions(-)

diff --git a/include/sim.h b/include/sim.h
index 830322a..81df60e 100644
--- a/include/sim.h
+++ b/include/sim.h
@@ -178,6 +178,8 @@ void ofono_sim_set_data(struct ofono_sim *sim, void *data);
 void *ofono_sim_get_data(struct ofono_sim *sim);
 
 const char *ofono_sim_get_imsi(struct ofono_sim *sim);
+const char *ofono_sim_get_mcc(struct ofono_sim *sim);
+const char *ofono_sim_get_mnc(struct ofono_sim *sim);
 enum ofono_sim_phase ofono_sim_get_phase(struct ofono_sim *sim);
 
 enum ofono_sim_cphs_phase ofono_sim_get_cphs_phase(struct ofono_sim *sim);
-- 
1.7.1

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


[PATCH 7/8] sim: getters for mcc and mnc implementation

2011-01-18 Thread Jukka Saunamaki
---
 src/sim.c |   50 +++---
 1 files changed, 31 insertions(+), 19 deletions(-)

diff --git a/src/sim.c b/src/sim.c
index d627647..86c3f13 100644
--- a/src/sim.c
+++ b/src/sim.c
@@ -78,6 +78,8 @@ struct ofono_sim {
gboolean barred_dialing;
 
char *imsi;
+   char mcc[OFONO_MAX_MCC_LENGTH + 1];
+   char mnc[OFONO_MAX_MNC_LENGTH + 1];
 
GSList *own_numbers;
GSList *new_numbers;
@@ -348,21 +350,13 @@ static DBusMessage *sim_get_properties(DBusConnection 
*conn,
bdn = sim-barred_dialing;
ofono_dbus_dict_append(dict, BarredDialing, DBUS_TYPE_BOOLEAN, bdn);
 
-   if (sim-mnc_length  sim-imsi) {
-   char mcc[OFONO_MAX_MCC_LENGTH + 1];
-   char mnc[OFONO_MAX_MNC_LENGTH + 1];
+   if (sim-mcc[0] != '\0'  sim-mnc[0] != '\0') {
const char *str;
-
-   strncpy(mcc, sim-imsi, OFONO_MAX_MCC_LENGTH);
-   mcc[OFONO_MAX_MCC_LENGTH] = '\0';
-   strncpy(mnc, sim-imsi + OFONO_MAX_MCC_LENGTH, sim-mnc_length);
-   mnc[sim-mnc_length] = '\0';
-
-   str = mcc;
+   str = sim-mcc;
ofono_dbus_dict_append(dict, MobileCountryCode,
DBUS_TYPE_STRING, str);
 
-   str = mnc;
+   str = sim-mnc;
ofono_dbus_dict_append(dict, MobileNetworkCode,
DBUS_TYPE_STRING, str);
}
@@ -1299,22 +1293,21 @@ static void sim_imsi_cb(const struct ofono_error 
*error, const char *imsi,
DBUS_TYPE_STRING, sim-imsi);
 
if (sim-mnc_length) {
-   char mcc[OFONO_MAX_MCC_LENGTH + 1];
-   char mnc[OFONO_MAX_MNC_LENGTH + 1];
const char *str;
 
-   strncpy(mcc, sim-imsi, OFONO_MAX_MCC_LENGTH);
-   mcc[OFONO_MAX_MCC_LENGTH] = '\0';
-   strncpy(mnc, sim-imsi + OFONO_MAX_MCC_LENGTH, sim-mnc_length);
-   mnc[sim-mnc_length] = '\0';
+   strncpy(sim-mcc, sim-imsi, OFONO_MAX_MCC_LENGTH);
+   sim-mcc[OFONO_MAX_MCC_LENGTH] = '\0';
+   strncpy(sim-mnc, sim-imsi + OFONO_MAX_MCC_LENGTH,
+   sim-mnc_length);
+   sim-mnc[sim-mnc_length] = '\0';
 
-   str = mcc;
+   str = sim-mcc;
ofono_dbus_signal_property_changed(conn, path,
OFONO_SIM_MANAGER_INTERFACE,
MobileCountryCode,
DBUS_TYPE_STRING, str);
 
-   str = mnc;
+   str = sim-mnc;
ofono_dbus_signal_property_changed(conn, path,
OFONO_SIM_MANAGER_INTERFACE,
MobileNetworkCode,
@@ -1997,6 +1990,22 @@ const char *ofono_sim_get_imsi(struct ofono_sim *sim)
return sim-imsi;
 }
 
+const char *ofono_sim_get_mcc(struct ofono_sim *sim)
+{
+   if (sim == NULL)
+   return NULL;
+
+   return sim-mcc;
+}
+
+const char *ofono_sim_get_mnc(struct ofono_sim *sim)
+{
+   if (sim == NULL)
+   return NULL;
+
+   return sim-mnc;
+}
+
 enum ofono_sim_phase ofono_sim_get_phase(struct ofono_sim *sim)
 {
if (sim == NULL)
@@ -2060,6 +2069,9 @@ static void sim_free_state(struct ofono_sim *sim)
sim-imsi = NULL;
}
 
+   sim-mcc[0] = '\0';
+   sim-mnc[0] = '\0';
+
if (sim-own_numbers) {
g_slist_foreach(sim-own_numbers, (GFunc)g_free, NULL);
g_slist_free(sim-own_numbers);
-- 
1.7.1

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


[PATCH 8/8] gprs-provision: add example context provisioning driver

2011-01-18 Thread Jukka Saunamaki
---
 Makefile.am  |3 +
 examples/provision.c |  206 ++
 2 files changed, 209 insertions(+), 0 deletions(-)
 create mode 100644 examples/provision.c

diff --git a/Makefile.am b/Makefile.am
index e792851..a74f75e 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -328,6 +328,9 @@ builtin_sources += examples/history.c
 
 builtin_modules += example_nettime
 builtin_sources += examples/nettime.c
+
+builtin_modules += example_provision
+builtin_sources += examples/provision.c
 endif
 
 builtin_modules += smart_messaging
diff --git a/examples/provision.c b/examples/provision.c
new file mode 100644
index 000..d39fc3c
--- /dev/null
+++ b/examples/provision.c
@@ -0,0 +1,206 @@
+/*
+ *
+ *  oFono - Open Source Telephony
+ *
+ *  Copyright (C) 2011  Nokia Corporation and/or its subsidiary(-ies).
+ *
+ *  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
+
+#include string.h
+#include glib.h
+
+#define OFONO_API_SUBJECT_TO_CHANGE
+
+#include ofono/modem.h
+#include ofono/plugin.h
+#include ofono/log.h
+#include ofono/gprs-provision.h
+#include ofono/types.h
+
+#include ofono.h
+#include common.h
+#include sim.h
+#include simutil.h
+#include util.h
+
+struct provisioning_request {
+   struct ofono_modem *modem;
+   ofono_gprs_provision_cb_t cb;
+   void *user_data;
+};
+
+static int example_provision_probe(struct ofono_gprs_provision_context 
*context)
+{
+   ofono_debug(Example GPRS context provisioning Probe for modem: %p,
+   context-modem);
+   return 0;
+}
+
+static void example_provision_remove(
+   struct ofono_gprs_provision_context *context)
+{
+   ofono_debug(Example GPRS context provisioning Remove for modem: %p,
+   context-modem);
+}
+
+static void sim_spn_read_cb(int ok, int length, int record,
+   const unsigned char *data,
+   int record_length, void *user_data)
+{
+   struct provisioning_request *req = user_data;
+   char *spn = NULL;
+
+   struct ofono_atom *sim_atom;
+   struct ofono_sim *sim;
+   const char *mcc;
+   const char *mnc;
+
+   GSList *settings = NULL;
+   struct ofono_gprs_provision_data *entry;
+
+   sim_atom = __ofono_modem_find_atom(req-modem, OFONO_ATOM_TYPE_SIM);
+
+   if (sim_atom == NULL) {
+   ofono_debug(No SIM atom);
+   goto finish;
+   }
+
+   sim = __ofono_atom_get_data(sim_atom);
+   mcc = ofono_sim_get_mcc(sim);
+   if (mcc == NULL) {
+   ofono_debug(No MCC available);
+   goto finish;
+   }
+
+   mnc = ofono_sim_get_mnc(sim);
+   if (mnc == NULL) {
+   ofono_debug(No MNC available);
+   goto finish;
+   }
+
+   if (ok)
+   spn = sim_string_to_utf8(data + 1, length - 1);
+
+   ofono_debug(Finding settings for MCC %s, MNC %s, SPN '%s',
+   mcc, mnc, spn);
+
+   /* Example settings for phonesim */
+   if (strcmp(mcc, 246) != 0 || strcmp(mnc, 81) != 0 ||
+   spn == NULL || strcmp(spn, oFono) != 0)
+   goto finish;
+
+   ofono_debug(Creating example settings for phonesim);
+
+   /* MMS context settings */
+   entry = g_try_new0(struct ofono_gprs_provision_data, 1);
+   if (entry == NULL)
+   goto finish;
+
+   entry-proto = OFONO_GPRS_PROTO_IP;
+   entry-type = OFONO_GPRS_CONTEXT_TYPE_MMS;
+   entry-name = strdup(Phonesim MMS);
+   entry-apn = strdup(mmsapn);
+   entry-username = strdup(mmsuser);
+   entry-password = strdup(mmspass);
+   entry-message_proxy = strdup(10.11.12.13:8080);
+   entry-message_center = strdup(http://mms.example.com:8000;);
+   settings = g_slist_prepend(settings, entry);
+
+   /* Internet context settings */
+   entry = g_try_new0(struct ofono_gprs_provision_data, 1);
+   if (entry == NULL)
+   goto finish;
+
+   entry-proto = OFONO_GPRS_PROTO_IP;
+   entry-type = OFONO_GPRS_CONTEXT_TYPE_INTERNET;
+   entry-name = strdup(Phonesim Internet);
+   entry-apn = strdup(internetapn);
+   settings = g_slist_prepend(settings, entry);
+
+finish:
+   g_free(spn);
+
+   if 

Re: [RFC PATCH 0/3] Long phone numbers

2011-01-18 Thread Rafael Ignacio Zurita
On Mon, Jan 17, 2011 at 11:18:51PM +0200, Pekka Pessi wrote:
 Hi Rafael,
 
 2011/1/17 Rafael Ignacio Zurita rafael.zur...@profusion.mobi:
  This is a proposal for the long phone number task (80 digits max length).
  It changes OFONO_MAX_PHONE_NUMBER_LENGTH and splits
  common:valid_phone_number_format(), to make sure long numbers are handled
  appropriately for functions that need manage shorter numbers, like
  numbers written to the SIM, or sms SCA.
 
 Perhaps a validator and type for long phone numbers is better than for
 short numbers? I guess long numbers are mostly used when reporting an
 outgoing call back to oFono.

No completely sure if it is better. Maybe it is the same?. With a new
type for long number we will have modifications on other parts of the code
which use OFONO_MAX_PHONE_NUMBER_LENGTH. The first idea could be simpler
because we just have one type and would check for the format and length on the
proper places.
 
 BTW, with call forwarding you could have numbers up to 16 digits or if
 longForwardedToNumber is supported (by modem and both home and visited
 networks) even 28 digits. See TS 29.002 for merry details.

Thanks for that. I am checking, and going to add an extra validator
surely.

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


Re: Ofono CF states not always correct

2011-01-18 Thread Jarko Poutiainen
Hi Denis,

On Fri, 2011-01-14 at 17:59 +0200, Denis Kenzior wrote:
 Hi Jarko,
 
 Both are active and the modem should be reporting both.  At least that
 is how I understood the specifications.
 
Well that is a bit debatable. As 27.007 states:
command:
+CCFC=reason,mode[,number[,type[,class[,subaddr[,satype[,time]]

reason: integer type
0 unconditional
1 mobile busy
2 no reply
3 not reachable
4 all call forwarding (refer 3GPP TS 22.030 [19])
5 all conditional call forwarding (refer 3GPP TS 22.030 [19])

mode: integer type
0 disable
1 enable
2 query status
3 registration
4 erasure

response whenmode=2 and command successfull:
+CCFC:status,class1[,number,type[,subaddr,satype[,time]]][CRLF+CCFC:
 status,class2[,number,type[,subaddr,satype[,time]]][...]]

status: integer type
0 not active
1 active

So actually they aren't both active at same time as the logs show but
personally I don't really care as long as the results are consistent
regardless which API you use which is not the case at the moment as
querying through org.ofono.CallForwarding can give you different result
than using org.ofono.SupplementaryServices.

 A bit, but having the AT command logs would help greatly.

Well hopefully these will help. I have numbered each step and copied
corresponding logs after it. list-modems doesn't cause AT queries to
modem(except on a very first time which I have already done) so I have
copied what it prints regarding CF. It's a bit long though so sorry
about that.

#1: ./list-modems
[ org.ofono.CallForwarding ]
ForwardingFlagOnSim = 0
VoiceNoReplyTimeout = 20
VoiceNotReachable = 
VoiceBusy = 
VoiceNoReply = 
VoiceUnconditional = 

#2: ./test-ussd '**61*+358401234567*11#'
ofonod[30925]: Default:  AT+CCFC=2,3,358401234567,145,1,,,20\r
ofonod[30925]: Default:  \r\nOK\r\n
ofonod[30925]: Default:  AT+CCFC=2,2\r
ofonod[30925]: Default:  \r\n+CCFC: 1,1,0401234567,129,,,20\r\n\r
\nOK\r\n

#3: ./list-modems
[ org.ofono.CallForwarding ]
ForwardingFlagOnSim = 0
VoiceNoReplyTimeout = 20
VoiceNotReachable = 
VoiceBusy = 
VoiceNoReply = 0401234567
VoiceUnconditional = 

#4: ./test-ussd '**21*+358401234567*11#'
ofonod[30925]: Default:  AT+CCFC=0,3,358401234567,145,1\r
ofonod[30925]: Default:  \r\nOK\r\n
ofonod[30925]: Default:  AT+CCFC=0,2\r
ofonod[30925]: Default:  \r\n+CCFC: 1,1,0401234567,129\r\n\r\nOK\r\n

#5: ./list-modems
[ org.ofono.CallForwarding ]
ForwardingFlagOnSim = 1
VoiceNoReplyTimeout = 20
VoiceNotReachable = 
VoiceBusy = 
VoiceNoReply = 0401234567
VoiceUnconditional = 0401234567

#6: ./test-ussd '*#002#'
ofonod[30925]: Default:  AT+CCFC=0,2\r
ofonod[30925]: Default:  \r\n+CCFC: 1,1,0401234567,129\r\n\r\nOK\r\n
ofonod[30925]: Default:  AT+CCFC=1,2\r
ofonod[30925]: Default:  \r\n+CCFC: 0,1\r\n+CCFC: 0,4\r\n+CCFC: 0,16\r
\n
ofonod[30925]: Default:  +CCFC: 0,32\r\n+CCFC: 0,64\r\n
ofonod[30925]: Default:  +CCFC: 0,128\r\n\r\nOK\r\n
ofonod[30925]: Default:  AT+CCFC=2,2\r
ofonod[30925]: Default:  \r\n+CCFC: 0,1\r\n+CCFC: 0,4\r\n
ofonod[30925]: Default:  +CCFC: 0,16\r\n+CCFC: 0,32\r\n
ofonod[30925]: Default:  +CCFC: 0,64\r\n+CCFC: 0,128\r\n
ofonod[30925]: Default:  \r\nOK\r\n
ofonod[30925]: Default:  AT+CCFC=3,2\r
ofonod[30925]: Default:  \r\n+CCFC: 0,1\r\n+CCFC: 0,4\r\n
ofonod[30925]: Default:  +CCFC: 0,16\r\n+CCFC: 0,32\r\n+CCFC: 0,64\r\n
ofonod[30925]: Default:  +CCFC: 0,128\r\n\r\nOK\r\n

#7: ./list-modems
[ org.ofono.CallForwarding ]
ForwardingFlagOnSim = 1
VoiceNoReplyTimeout = 20
VoiceNotReachable = 
VoiceBusy = 
VoiceNoReply = 
VoiceUnconditional = 0401234567

#8: ./test-ussd '##21#'
ofonod[30925]: Default:  AT+CCFC=0,4\r
ofonod[30925]: Default:  \r\nOK\r\n
ofonod[30925]: Default:  AT+CCFC=0,2\r
ofonod[30925]: Default:  \r\n+CCFC: 0,1\r\n
ofonod[30925]: Default:  +CCFC: 0,4\r\n+CCFC: 0,16\r\n+CCFC: 0,32\r\n
ofonod[30925]: Default:  +CCFC: 0,64\r\n+CCFC: 0,128\r\n
ofonod[30925]: Default:  \r\nOK\r\n

#9: ./list-modems
[ org.ofono.CallForwarding ]
ForwardingFlagOnSim = 0
VoiceNoReplyTimeout = 20
VoiceNotReachable = 
VoiceBusy = 
VoiceNoReply = 
VoiceUnconditional = 

#10: ./test-ussd '*#002#'
ofonod[30925]: Default:  AT+CCFC=0,2\r
ofonod[30925]: Default:  \r\n+CCFC: 0,1\r\n+CCFC: 0,4\r\n+CCFC: 0,16\r
\n
ofonod[30925]: Default:  +CCFC: 0,32\r\n+CCFC: 0,64\r\n
ofonod[30925]: Default:  +CCFC: 0,128\r\n\r\nOK\r\n
ofonod[30925]: Default:  AT+CCFC=1,2\r
ofonod[30925]: Default:  \r\n+CCFC: 0,1\r\n+CCFC: 0,4\r\n
ofonod[30925]: Default:  +CCFC: 0,16\r\n+CCFC: 0,32\r\n+CCFC: 0,64\r\n
ofonod[30925]: Default:  +CCFC: 0,128\r\n\r\nOK\r\n
ofonod[30925]: Default:  AT+CCFC=2,2\r
ofonod[30925]: Default:  \r\n+CCFC: 1,1,0401234567,129,,,20\r\n\r
\nOK\r\n
ofonod[30925]: Default:  AT+CCFC=3,2\r
ofonod[30925]: Default:  \r\n+CCFC: 0,1\r\n
ofonod[30925]: Default:  +CCFC: 

[PATCH 1/2] simutil: M9, M11, Minor style fixes and indentation

2011-01-18 Thread Jessica Nilsson
---
 src/simutil.h |   68 
 1 files changed, 34 insertions(+), 34 deletions(-)

diff --git a/src/simutil.h b/src/simutil.h
index ad84907..cda9d55 100644
--- a/src/simutil.h
+++ b/src/simutil.h
@@ -19,36 +19,39 @@
  *
  */
 
+#define SIM_EFSPN_DC_HOME_PLMN_BIT 0x1
+#define SIM_EFSPN_DC_ROAMING_SPN_BIT 0x2
+
 enum sim_fileid {
-   SIM_EFPL_FILEID = 0x2f05,
-   SIM_EF_ICCID_FILEID = 0x2fe2,
-   SIM_EFIMG_FILEID = 0x4F20,
-   SIM_EFLI_FILEID = 0x6f05,
-   SIM_EF_CPHS_MWIS_FILEID = 0x6f11,
-   SIM_EF_CPHS_CFF_FILEID = 0x6f13,
-   SIM_EF_CPHS_INFORMATION_FILEID = 0x6f16,
-   SIM_EF_CPHS_MBDN_FILEID = 0x6f17,
-   SIM_EFUST_FILEID = 0x6f38,
-   SIM_EFSST_FILEID = 0x6f38, /* same as EFust */
-   SIM_EFMSISDN_FILEID = 0x6f40,
-   SIM_EFSPN_FILEID = 0x6f46,
-   SIM_EFSDN_FILEID = 0x6f49,
-   SIM_EFBDN_FILEID = 0x6f4d,
-   SIM_EFADN_FILEID = 0x6f3a,
-   SIM_EFEST_FILEID = 0x6f56,
-   SIM_EFAD_FILEID = 0x6fad,
-   SIM_EFPHASE_FILEID = 0x6fae,
-   SIM_EFPNN_FILEID = 0x6fc5,
-   SIM_EFOPL_FILEID = 0x6fc6,
-   SIM_EFMBDN_FILEID = 0x6fc7,
-   SIM_EFMBI_FILEID = 0x6fc9,
-   SIM_EFMWIS_FILEID = 0x6fca,
-   SIM_EFCFIS_FILEID = 0x6fcb,
-   SIM_EFSPDI_FILEID = 0x6fcd,
-   SIM_EFECC_FILEID = 0x6fb7,
-   SIM_EFCBMIR_FILEID = 0x6f50,
-   SIM_EFCBMI_FILEID = 0x6f45,
-   SIM_EFCBMID_FILEID = 0x6f48,
+   SIM_EFPL_FILEID =   0x2f05,
+   SIM_EF_ICCID_FILEID =   0x2fe2,
+   SIM_EFIMG_FILEID =  0x4f20,
+   SIM_EFLI_FILEID =   0x6f05,
+   SIM_EF_CPHS_MWIS_FILEID =   0x6f11,
+   SIM_EF_CPHS_CFF_FILEID =0x6f13,
+   SIM_EF_CPHS_INFORMATION_FILEID =0x6f16,
+   SIM_EF_CPHS_MBDN_FILEID =   0x6f17,
+   SIM_EFUST_FILEID =  0x6f38,
+   SIM_EFSST_FILEID =  0x6f38, /* same as EFust */
+   SIM_EFMSISDN_FILEID =   0x6f40,
+   SIM_EFSPN_FILEID =  0x6f46,
+   SIM_EFSDN_FILEID =  0x6f49,
+   SIM_EFBDN_FILEID =  0x6f4d,
+   SIM_EFADN_FILEID =  0x6f3a,
+   SIM_EFEST_FILEID =  0x6f56,
+   SIM_EFAD_FILEID =   0x6fad,
+   SIM_EFPHASE_FILEID =0x6fae,
+   SIM_EFPNN_FILEID =  0x6fc5,
+   SIM_EFOPL_FILEID =  0x6fc6,
+   SIM_EFMBDN_FILEID = 0x6fc7,
+   SIM_EFMBI_FILEID =  0x6fc9,
+   SIM_EFMWIS_FILEID = 0x6fca,
+   SIM_EFCFIS_FILEID = 0x6fcb,
+   SIM_EFSPDI_FILEID = 0x6fcd,
+   SIM_EFECC_FILEID =  0x6fb7,
+   SIM_EFCBMIR_FILEID =0x6f50,
+   SIM_EFCBMI_FILEID = 0x6f45,
+   SIM_EFCBMID_FILEID =0x6f48,
 };
 
 /* 51.011 Section 9.3 */
@@ -223,9 +226,6 @@ enum sim_sst_service {
SIM_SST_SERVICE_PROVIDER_DISPLAY_INFO = 55
 };
 
-#define SIM_EFSPN_DC_HOME_PLMN_BIT 0x1
-#define SIM_EFSPN_DC_ROAMING_SPN_BIT 0x2
-
 enum ber_tlv_data_type {
BER_TLV_DATA_TYPE_UNIVERSAL =   0,
BER_TLV_DATA_TYPE_APPLICATION = 1,
@@ -347,8 +347,8 @@ void ber_tlv_iter_init(struct ber_tlv_iter *iter, const 
unsigned char *pdu,
 unsigned int ber_tlv_iter_get_tag(struct ber_tlv_iter *iter);
 
 enum ber_tlv_data_type ber_tlv_iter_get_class(struct ber_tlv_iter *iter);
-enum ber_tlv_data_encoding_type
-   ber_tlv_iter_get_encoding(struct ber_tlv_iter *iter);
+enum ber_tlv_data_encoding_type ber_tlv_iter_get_encoding(
+   struct ber_tlv_iter *iter);
 
 /*
  * This will return the short tag along with class and encoding information.
-- 
1.7.3.2

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


[PATCH 2/2] simutil: sim_fileid sorted in numerical order

2011-01-18 Thread Jessica Nilsson
---
 src/simutil.h |   10 +-
 1 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/src/simutil.h b/src/simutil.h
index cda9d55..fb87c3a 100644
--- a/src/simutil.h
+++ b/src/simutil.h
@@ -33,14 +33,18 @@ enum sim_fileid {
SIM_EF_CPHS_MBDN_FILEID =   0x6f17,
SIM_EFUST_FILEID =  0x6f38,
SIM_EFSST_FILEID =  0x6f38, /* same as EFust */
+   SIM_EFADN_FILEID =  0x6f3a,
SIM_EFMSISDN_FILEID =   0x6f40,
+   SIM_EFCBMI_FILEID = 0x6f45,
SIM_EFSPN_FILEID =  0x6f46,
+   SIM_EFCBMID_FILEID =0x6f48,
SIM_EFSDN_FILEID =  0x6f49,
SIM_EFBDN_FILEID =  0x6f4d,
-   SIM_EFADN_FILEID =  0x6f3a,
+   SIM_EFCBMIR_FILEID =0x6f50,
SIM_EFEST_FILEID =  0x6f56,
SIM_EFAD_FILEID =   0x6fad,
SIM_EFPHASE_FILEID =0x6fae,
+   SIM_EFECC_FILEID =  0x6fb7,
SIM_EFPNN_FILEID =  0x6fc5,
SIM_EFOPL_FILEID =  0x6fc6,
SIM_EFMBDN_FILEID = 0x6fc7,
@@ -48,10 +52,6 @@ enum sim_fileid {
SIM_EFMWIS_FILEID = 0x6fca,
SIM_EFCFIS_FILEID = 0x6fcb,
SIM_EFSPDI_FILEID = 0x6fcd,
-   SIM_EFECC_FILEID =  0x6fb7,
-   SIM_EFCBMIR_FILEID =0x6f50,
-   SIM_EFCBMI_FILEID = 0x6f45,
-   SIM_EFCBMID_FILEID =0x6f48,
 };
 
 /* 51.011 Section 9.3 */
-- 
1.7.3.2

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


[PATCH v2 1/1] atmodem: add ifx support for pin retries query

2011-01-18 Thread Jeevaka Badrappan
Adds ifx support for the remaining pin retries query
---
 drivers/atmodem/sim.c |   84 +++--
 1 files changed, 67 insertions(+), 17 deletions(-)

diff --git a/drivers/atmodem/sim.c b/drivers/atmodem/sim.c
index c5f4a44..2219e88 100644
--- a/drivers/atmodem/sim.c
+++ b/drivers/atmodem/sim.c
@@ -56,6 +56,7 @@ static const char *crsm_prefix[] = { +CRSM:, NULL };
 static const char *cpin_prefix[] = { +CPIN:, NULL };
 static const char *clck_prefix[] = { +CLCK:, NULL };
 static const char *huawei_cpin_prefix[] = { ^CPIN:, NULL };
+static const char *xpincnt_prefix[] = { +XPINCNT:, NULL };
 static const char *none_prefix[] = { NULL };
 
 static void at_crsm_info_cb(gboolean ok, GAtResult *result, gpointer user_data)
@@ -522,40 +523,89 @@ error:
CALLBACK_WITH_FAILURE(cb, NULL, cbd-data);
 }
 
+static void xpincnt_cb(gboolean ok, GAtResult *result, gpointer user_data)
+{
+   struct cb_data *cbd = user_data;
+   ofono_sim_pin_retries_cb_t cb = cbd-cb;
+   const char *final = g_at_result_final_response(result);
+   GAtResultIter iter;
+   struct ofono_error error;
+   int retries[OFONO_SIM_PASSWORD_INVALID];
+   size_t i;
+   static enum ofono_sim_password_type password_types[] = {
+   OFONO_SIM_PASSWORD_SIM_PIN,
+   OFONO_SIM_PASSWORD_SIM_PIN2,
+   OFONO_SIM_PASSWORD_SIM_PUK,
+   OFONO_SIM_PASSWORD_SIM_PUK2,
+   };
+
+   decode_at_error(error, final);
+
+   if (!ok) {
+   cb(error, NULL, cbd-data);
+   return;
+   }
+
+   g_at_result_iter_init(iter, result);
+
+   if (!g_at_result_iter_next(iter, +XPINCNT:))
+   goto error;
+
+   for (i = 0; i  OFONO_SIM_PASSWORD_INVALID; i++)
+   retries[i] = -1;
+
+   for (i = 0; i  ARRAY_SIZE(password_types); i++) {
+   int val;
+
+   if (!g_at_result_iter_next_number(iter, val))
+   goto error;
+
+   retries[password_types[i]]= val;
+
+   DBG(retry counter id=%d, val=%d, password_types[i],
+   retries[password_types[i]]);
+   }
+
+   cb(error, retries, cbd-data);
+
+   return;
+
+error:
+   CALLBACK_WITH_FAILURE(cb, NULL, cbd-data);
+}
+
 static void at_pin_retries_query(struct ofono_sim *sim,
ofono_sim_pin_retries_cb_t cb, void *data)
 {
struct sim_data *sd = ofono_sim_get_data(sim);
-   struct cb_data *cbd;
-   int retries[OFONO_SIM_PASSWORD_INVALID];
-   int i;
+   struct cb_data *cbd = cb_data_new(cb, data);
 
DBG();
 
-   switch (sd-vendor) {
-   case OFONO_VENDOR_HUAWEI:
-   cbd = cb_data_new(cb, data);
+   if (cbd == NULL)
+   goto error;
 
-   if (cbd == NULL) {
-   CALLBACK_WITH_FAILURE(cb, NULL, data);
+   switch (sd-vendor) {
+   case OFONO_VENDOR_IFX:
+   if (g_at_chat_send(sd-chat, AT+XPINCNT, xpincnt_prefix,
+   xpincnt_cb, cbd, g_free)  0)
return;
-   }
 
+   break;
+   case OFONO_VENDOR_HUAWEI:
if (g_at_chat_send(sd-chat, AT^CPIN?, huawei_cpin_prefix,
huawei_cpin_cb, cbd, g_free)  0)
return;
 
-   g_free(cbd);
-
-   CALLBACK_WITH_FAILURE(cb, NULL, data);
break;
-
default:
-   for(i = 0; i  OFONO_SIM_PASSWORD_INVALID; i++)
-   retries[i] = -1;
-
-   CALLBACK_WITH_SUCCESS(cb, retries, data);
+   break;
}
+
+error:
+   g_free(cbd);
+
+   CALLBACK_WITH_FAILURE(cb, NULL, data);
 }
 
 static void at_cpin_cb(gboolean ok, GAtResult *result, gpointer user_data)
-- 
1.7.0.4

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


[PATCH v2 0/1] ifx support for querying remaining pin entries

2011-01-18 Thread Jeevaka Badrappan
Hi,

 Following patch adds ifx support for querying remaining pin entries

Regards,
Jeevaka

Jeevaka Badrappan (1):
  atmodem: add ifx support for pin retries query

 drivers/atmodem/sim.c |   84 +++--
 1 files changed, 67 insertions(+), 17 deletions(-)

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


Re: [PATCH 1/2] atmodem: move USSD quirk to probe and use it also for STE modems

2011-01-18 Thread Lasse Kunnasluoto
Hi Denis,

On Mon, 2011-01-17 at 17:58 +0200, Denis Kenzior wrote:
 Hi Lasse,
 
 On 01/17/2011 02:42 AM, Lasse Kunnasluoto wrote:
  Hi Marcel,
  
 Supporting IRA character set is not really an option since IRA and GSM
 7bit have disjoint sets of characters.  The best you can really do is:
 
 - If your modem supports UTF8, then set that for all multiplexer
 channels in the modem driver.
Yes, it supports UTF8. I'll send a new patch for this. Thanks.

 - Otherwise set the character set to GSM and do your best to put ussd
 and phonebook on separate multiplexer channels.  That is of course
 assuming that the CSCS setting is handled per channel.
 
  
  The best is if the STE modem would provide access to the USSD in PDU
  mode and we can then decode it properly. Using text mode for USSD is not
  the best idea actually. Same as text mode for SMS is utterly broken ;)
  Don't know if this is possible.
 
 USSD PDU mode is the ideal solution.  If this is not available, then you
 will have to jump through all kinds of hoops to get this done properly.
 
 Regards,
 -Denis

-Lasse

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


[PATCH 1/5] simutil: Add EFcsp file and service group IDs

2011-01-18 Thread Aki Niemi
---
 src/simutil.h |   16 
 1 files changed, 16 insertions(+), 0 deletions(-)

diff --git a/src/simutil.h b/src/simutil.h
index 7e386fa..61440a5 100644
--- a/src/simutil.h
+++ b/src/simutil.h
@@ -26,6 +26,7 @@ enum sim_fileid {
SIM_EFLI_FILEID =   0x6F05,
SIM_EF_CPHS_MWIS_FILEID =   0x6F11,
SIM_EF_CPHS_CFF_FILEID =0x6F13,
+   SIM_EF_CPHS_CSP_FILEID =0x6F15,
SIM_EF_CPHS_INFORMATION_FILEID =0x6F16,
SIM_EF_CPHS_MBDN_FILEID =   0x6F17,
SIM_EFUST_FILEID =  0x6F38,
@@ -223,6 +224,21 @@ enum sim_sst_service {
SIM_SST_SERVICE_PROVIDER_DISPLAY_INFO = 55
 };
 
+/* CPHS 4.2, Section B4.7 CSP Service Group Codes */
+enum sim_csp_entry {
+   SIM_CSP_ENTRY_CALL_OFFERING =   0x01,
+   SIM_CSP_ENTRY_CALL_RESTRICTION =0x02,
+   SIM_CSP_ENTRY_OTHER_SUPP_SERVICES = 0x03,
+   SIM_CSP_ENTRY_CALL_COMPLETION = 0x04,
+   SIM_CSP_ENTRY_TELESERVICES =0x05,
+   SIM_CSP_ENTRY_CPHS_TELESERVICES =   0x06,
+   SIM_CSP_ENTRY_CPHS_FEATURES =   0x07,
+   SIM_CSP_ENTRY_NUMBER_IDENTIFICATION =   0x08,
+   SIM_CSP_ENTRY_PHASE_2GPLUS_SERVICES =   0x09,
+   SIM_CSP_ENTRY_VALUE_ADDED_SERVICES =0xC0,
+   SIM_CSP_ENTRY_INFORMATION_NUMBERS = 0xD5,
+};
+
 #define SIM_EFSPN_DC_HOME_PLMN_BIT 0x1
 #define SIM_EFSPN_DC_ROAMING_SPN_BIT 0x2
 
-- 
1.7.1

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


[PATCH 0/5] Implement CPHS CSP support

2011-01-18 Thread Aki Niemi
Hi All,

This patch set implements support for the PLMN mode bit found in the
CPHS EFcsp file. Based on the PLMN mode setting, the netreg atom
enables or disables manual network registration.

There is a new Mode property value of 'forced-auto' for indicating the
case when manual selection is disabled. Any attempt to manually
Register() will also fail with an error.

In addition, we add a short description of the CPHS spec in
doc/standards.txt. Unfortunately that spec is not publically
available, although people may have luck finding an unofficial version
online with the help of a search engine. ;)

Aki Niemi (5):
  simutil: Add EFcsp file and service group IDs
  netreg: Add CPHS CSP PLMN mode implementation
  doc: Add documentation for 'forced-mode'
  doc: Add short mention of CPHS under standards
  TODO: Remove completed CPHS CSP task

 TODO|   13 
 doc/network-api.txt |   24 --
 doc/standards.txt   |9 +
 src/network.c   |   85 ++-
 src/simutil.h   |   16 +
 5 files changed, 123 insertions(+), 24 deletions(-)


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


[PATCH 2/5] netreg: Add CPHS CSP PLMN mode implementation

2011-01-18 Thread Aki Niemi
---
 src/network.c |   85 -
 1 files changed, 84 insertions(+), 1 deletions(-)

diff --git a/src/network.c b/src/network.c
index ae0f334..927f7ce 100644
--- a/src/network.c
+++ b/src/network.c
@@ -66,6 +66,7 @@ struct ofono_netreg {
int cellid;
int technology;
int mode;
+   gboolean forced_auto;
char *base_station;
struct network_operator_data *current_operator;
GSList *operator_list;
@@ -174,6 +175,36 @@ static void set_registration_mode(struct ofono_netreg 
*netreg, int mode)
Mode, DBUS_TYPE_STRING, strmode);
 }
 
+static void set_registration_forced_auto(struct ofono_netreg *netreg, gboolean 
value)
+{
+   DBusConnection *conn;
+   const char *strmode;
+   const char *path;
+
+   if (netreg-forced_auto == value)
+   return;
+
+   netreg-forced_auto = value;
+
+   if (netreg-settings) {
+   g_key_file_set_boolean(netreg-settings, SETTINGS_GROUP,
+   ForcedAuto, netreg-forced_auto);
+   storage_sync(netreg-imsi, SETTINGS_STORE, netreg-settings);
+   }
+
+   if (value)
+   strmode = forced-auto;
+   else
+   strmode = registration_mode_to_string(netreg-mode);
+
+   conn = ofono_dbus_get_connection();
+   path = __ofono_atom_get_path(netreg-atom);
+
+   ofono_dbus_signal_property_changed(conn, path,
+   OFONO_NETWORK_REGISTRATION_INTERFACE,
+   Mode, DBUS_TYPE_STRING, strmode);
+}
+
 static void registration_status_callback(const struct ofono_error *error,
int status, int lac, int ci, int tech,
void *data)
@@ -588,6 +619,9 @@ static DBusMessage 
*network_operator_register(DBusConnection *conn,
struct network_operator_data *opd = data;
struct ofono_netreg *netreg = opd-netreg;
 
+   if (netreg-forced_auto)
+   return __ofono_error_access_denied(msg);
+
if (netreg-pending)
return __ofono_error_busy(msg);
 
@@ -757,7 +791,12 @@ static DBusMessage *network_get_properties(DBusConnection 
*conn,
 
const char *status = registration_status_to_string(netreg-status);
const char *operator;
-   const char *mode = registration_mode_to_string(netreg-mode);
+   const char *mode;
+
+   if (netreg-forced_auto)
+   mode = forced-auto;
+   else
+   mode = registration_mode_to_string(netreg-mode);
 
reply = dbus_message_new_method_return(msg);
if (reply == NULL)
@@ -1598,6 +1637,43 @@ static void sim_spn_read_cb(int ok, int length, int 
record,
}
 }
 
+static void sim_csp_read_cb(int ok, int length, int record,
+   const unsigned char *data,
+   int record_length, void *user_data)
+{
+   struct ofono_netreg *netreg = user_data;
+   int i;
+
+   if (!ok)
+   return;
+
+   if (length  18 || record_length  18 || length  record_length)
+   return;
+
+   /*
+* Acording to CPHS 4.2, EFcsp is an array of two-byte service
+* entries, each consisting of a one byte service group
+* identifier followed by 8 bits; each bit is indicating
+* availability of a specific service or feature.
+*
+* The PLMN mode bit, if present, indicates whether manual
+* operator selection should be disabled or enabled. When
+* unset, the device is forced to automatic mode; when set,
+* manual selection is to be enabled. The latter is also the
+* default.
+*/
+   for (i = 0; i  record_length / 2; i++) {
+   gboolean forced_auto;
+
+   if (data[i * 2] != SIM_CSP_ENTRY_VALUE_ADDED_SERVICES)
+   continue;
+
+   forced_auto = (data[i * 2 + 1]  0x80) == 0;
+
+   set_registration_forced_auto(netreg, forced_auto);
+   }
+}
+
 int ofono_netreg_get_location(struct ofono_netreg *netreg)
 {
if (netreg == NULL)
@@ -1803,6 +1879,10 @@ static void netreg_load_settings(struct ofono_netreg 
*netreg)
 
g_key_file_set_integer(netreg-settings, SETTINGS_GROUP,
Mode, netreg-mode);
+
+   netreg-forced_auto = g_key_file_get_boolean(netreg-settings,
+   SETTINGS_GROUP,
+   ForcedAuto, NULL);
 }
 
 void ofono_netreg_register(struct ofono_netreg *netreg)
@@ -1845,6 +1925,9 @@ void ofono_netreg_register(struct ofono_netreg *netreg)
ofono_sim_read(netreg-sim, SIM_EFSPN_FILEID,
OFONO_SIM_FILE_STRUCTURE_TRANSPARENT,

[PATCH 4/5] doc: Add short mention of CPHS under standards

2011-01-18 Thread Aki Niemi
---
 doc/standards.txt |9 +
 1 files changed, 9 insertions(+), 0 deletions(-)

diff --git a/doc/standards.txt b/doc/standards.txt
index 2b85cb0..35f2a3a 100644
--- a/doc/standards.txt
+++ b/doc/standards.txt
@@ -166,3 +166,12 @@ Describes the general background and assumption of 
wireless features.
Capability: Network Perspective
 - S.R0006-808: Wireless Features Description: Circuit Switched Call Precedence 
Over
CDMA Packet Data Session
+
+Common PCN Handset Specification (CPHS)
+===
+
+This specification includes certain pre-standard extensions to GSM
+standards. oFono implements some of the features found in the Phase 2
+specification, version 4.2.
+
+The specification itself is not publicly available.
-- 
1.7.1

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


[PATCH 5/5] TODO: Remove completed CPHS CSP task

2011-01-18 Thread Aki Niemi
---
 TODO |   13 -
 1 files changed, 0 insertions(+), 13 deletions(-)

diff --git a/TODO b/TODO
index 1acae81..345952e 100644
--- a/TODO
+++ b/TODO
@@ -97,19 +97,6 @@ SIM / SIM File system
   Complexity: C1
   Owner: Marit Henriksen marit.henrik...@stericsson.com
 
-- Add support for CPHS Customer Service Profile (CSP).  This task adds support
-  for reading the EFcsp file and in particular, interpreting the PLMN mode bit
-  within the 'Value Added Services' service group.
-
-  Based on the PLMN mode value, manual network selection needs to either be
-  enabled or disabled in the netreg atom.  Also to accommodate this, there
-  probably needs to be a new 'forced' mode to indicate that manual network
-  selection is disabled.
-
-  Priority: Medium
-  Complexity: C1
-  Owner: Aki Niemi aki.ni...@nokia.com
-
 Modem Emulator
 ==
 
-- 
1.7.1

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


[PATCH] ste: Use UTF-8 as a default character set

2011-01-18 Thread Lasse Kunnasluoto
---
 plugins/ste.c |2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/plugins/ste.c b/plugins/ste.c
index 7bb7232..cc01f7b 100644
--- a/plugins/ste.c
+++ b/plugins/ste.c
@@ -247,7 +247,7 @@ static int ste_enable(struct ofono_modem *modem)
return -EIO;
 
data-chat = g_at_chat_new_blocking(channel, syntax);
-   g_at_chat_send(data-chat, ATF E0 V1 X4 C1 +CMEE=1,
+   g_at_chat_send(data-chat, ATF E0 V1 X4 C1 +CMEE=1;+CSCS=\UTF-8\,
NULL, NULL, NULL, NULL);
 
g_io_channel_unref(channel);
-- 
1.7.0.4

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


[PATCH 1/1] TODO: claim IPv6 task

2011-01-18 Thread Mika Liljeberg
---
 TODO |3 ++-
 1 files changed, 2 insertions(+), 1 deletions(-)

diff --git a/TODO b/TODO
index dec43fd..7fe2d8e 100644
--- a/TODO
+++ b/TODO
@@ -212,7 +212,8 @@ GPRS
 - Add support for IPv6 GPRS contexts.
 
   Priority: Medium
-  Complexity: C1
+  Complexity: C2
+  Owner: Mika Liljeberg mika.liljeb...@nokia.com
 
 
 Location Services
-- 
1.7.1

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


IPv6 support

2011-01-18 Thread Mika Liljeberg
Hi all,

I plan to start working on IPv6 support.

Br,

MikaL

[PATCH 1/1] TODO: claim IPv6 task
___
ofono mailing list
ofono@ofono.org
http://lists.ofono.org/listinfo/ofono


Re: [PATCH] [PATCH v2] doc: Add Bluetooth Dial-up Networking Profile specs

2011-01-18 Thread Marcel Holtmann
Hi Olivier,

  doc/bluetooth-cmd-set.txt |   45 
 +
  doc/standards.txt |4 
  2 files changed, 49 insertions(+), 0 deletions(-)
  create mode 100644 doc/bluetooth-cmd-set.txt

please create two separate patches for this.

Also I would rename it to doc/dialup-command-set.txt. While the
Bluetooth specification is the driving factor is can also be dialup over
USB.

Regards

Marcel


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


Re: [PATCH 1/2] simutil: M9, M11, Minor style fixes and indentation

2011-01-18 Thread Marcel Holtmann
Hi Jessica,

snip
 
  enum ber_tlv_data_type ber_tlv_iter_get_class(struct ber_tlv_iter *iter);
 -enum ber_tlv_data_encoding_type
 - ber_tlv_iter_get_encoding(struct ber_tlv_iter *iter);
 +enum ber_tlv_data_encoding_type ber_tlv_iter_get_encoding(
 + struct ber_tlv_iter *iter);

leave this one out. It is such a rare corner case with return parameter
being an enum and a long function name. There is really no unique right
way to make this look good. Whatever you try the break will be ugly.

Regards

Marcel


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


Re: [PATCH v2 1/1] atmodem: add ifx support for pin retries query

2011-01-18 Thread Marcel Holtmann
Hi Jeevaka,

 Adds ifx support for the remaining pin retries query

since the commit message is essentially the same as the subject line,
you can leave it out. Or better expend the commit message with further
details or example of the command.

 ---
  drivers/atmodem/sim.c |   84 
 +++--
  1 files changed, 67 insertions(+), 17 deletions(-)
 
 diff --git a/drivers/atmodem/sim.c b/drivers/atmodem/sim.c
 index c5f4a44..2219e88 100644
 --- a/drivers/atmodem/sim.c
 +++ b/drivers/atmodem/sim.c
 @@ -56,6 +56,7 @@ static const char *crsm_prefix[] = { +CRSM:, NULL };
  static const char *cpin_prefix[] = { +CPIN:, NULL };
  static const char *clck_prefix[] = { +CLCK:, NULL };
  static const char *huawei_cpin_prefix[] = { ^CPIN:, NULL };
 +static const char *xpincnt_prefix[] = { +XPINCNT:, NULL };
  static const char *none_prefix[] = { NULL };
  
  static void at_crsm_info_cb(gboolean ok, GAtResult *result, gpointer 
 user_data)
 @@ -522,40 +523,89 @@ error:
   CALLBACK_WITH_FAILURE(cb, NULL, cbd-data);
  }
  
 +static void xpincnt_cb(gboolean ok, GAtResult *result, gpointer user_data)
 +{
 + struct cb_data *cbd = user_data;
 + ofono_sim_pin_retries_cb_t cb = cbd-cb;
 + const char *final = g_at_result_final_response(result);
 + GAtResultIter iter;
 + struct ofono_error error;
 + int retries[OFONO_SIM_PASSWORD_INVALID];
 + size_t i;
 + static enum ofono_sim_password_type password_types[] = {
 + OFONO_SIM_PASSWORD_SIM_PIN,
 + OFONO_SIM_PASSWORD_SIM_PIN2,
 + OFONO_SIM_PASSWORD_SIM_PUK,
 + OFONO_SIM_PASSWORD_SIM_PUK2,
 + };
 +
 + decode_at_error(error, final);
 +
 + if (!ok) {
 + cb(error, NULL, cbd-data);
 + return;
 + }
 +
 + g_at_result_iter_init(iter, result);
 +
 + if (!g_at_result_iter_next(iter, +XPINCNT:))
 + goto error;
 +
 + for (i = 0; i  OFONO_SIM_PASSWORD_INVALID; i++)
 + retries[i] = -1;
 +
 + for (i = 0; i  ARRAY_SIZE(password_types); i++) {
 + int val;
 +
 + if (!g_at_result_iter_next_number(iter, val))
 + goto error;
 +
 + retries[password_types[i]]= val;

coding style issue. Must be [i]] = val, but I also realized that the
Huawei code has the same issue. That needs to be fixed as well.

Btw. the code is 100% identical besides the password_types type array.
Maybe it is a good idea to write a helper function for this.

 + DBG(retry counter id=%d, val=%d, password_types[i],
 + retries[password_types[i]]);
 + }
 +
 + cb(error, retries, cbd-data);
 +
 + return;
 +
 +error:
 + CALLBACK_WITH_FAILURE(cb, NULL, cbd-data);
 +}
 +
  static void at_pin_retries_query(struct ofono_sim *sim,
   ofono_sim_pin_retries_cb_t cb, void *data)
  {
   struct sim_data *sd = ofono_sim_get_data(sim);
 - struct cb_data *cbd;
 - int retries[OFONO_SIM_PASSWORD_INVALID];
 - int i;
 + struct cb_data *cbd = cb_data_new(cb, data);
  
   DBG();
  
 - switch (sd-vendor) {
 - case OFONO_VENDOR_HUAWEI:
 - cbd = cb_data_new(cb, data);
 + if (cbd == NULL)
 + goto error;
  
 - if (cbd == NULL) {
 - CALLBACK_WITH_FAILURE(cb, NULL, data);
 + switch (sd-vendor) {
 + case OFONO_VENDOR_IFX:
 + if (g_at_chat_send(sd-chat, AT+XPINCNT, xpincnt_prefix,
 + xpincnt_cb, cbd, g_free)  0)
   return;
 - }
  
 + break;
 + case OFONO_VENDOR_HUAWEI:
   if (g_at_chat_send(sd-chat, AT^CPIN?, huawei_cpin_prefix,
   huawei_cpin_cb, cbd, g_free)  0)
   return;
  
 - g_free(cbd);
 -
 - CALLBACK_WITH_FAILURE(cb, NULL, data);
   break;
 -
   default:
 - for(i = 0; i  OFONO_SIM_PASSWORD_INVALID; i++)
 - retries[i] = -1;
 -
 - CALLBACK_WITH_SUCCESS(cb, retries, data);
 + break;
   }
 +
 +error:
 + g_free(cbd);
 +
 + CALLBACK_WITH_FAILURE(cb, NULL, data);
  }
  
  static void at_cpin_cb(gboolean ok, GAtResult *result, gpointer user_data)

The rest looks fine to me.

Regards

Marcel


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


Re: [PATCH 4/5] doc: Add short mention of CPHS under standards

2011-01-18 Thread Marcel Holtmann
Hi Aki,

  doc/standards.txt |9 +
  1 files changed, 9 insertions(+), 0 deletions(-)

patch has been applied. Thanks.

Regards

Marcel


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


Re: [PATCH 3/5] doc: Add documentation for 'forced-mode'

2011-01-18 Thread Marcel Holtmann
Hi Aki,

snip

 + auto Network registration is performed
 +automatically.
 + forced-auto  Network registration is performed
 +automatically while manual
 +selection is disabled.

we need to discuss this a little bit. I am not sure using a mode of
forced auto is the best choice here.

Maybe an extra property like ManualAllowed would be better. Thoughts?

Regards

Marcel


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


Re: [PATCH 2/5] netreg: Add CPHS CSP PLMN mode implementation

2011-01-18 Thread Marcel Holtmann
Hi Aki,

snip

 + if (netreg-settings) {
 + g_key_file_set_boolean(netreg-settings, SETTINGS_GROUP,
 + ForcedAuto, netreg-forced_auto);
 + storage_sync(netreg-imsi, SETTINGS_STORE, netreg-settings);
 + }

why are we bothering to store this value? Would it not be better to
re-read when bringing up the modem?

Regards

Marcel


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


Re: [PATCH] ste: Use UTF-8 as a default character set

2011-01-18 Thread Marcel Holtmann
Hi Lasse,

  plugins/ste.c |2 +-
  1 files changed, 1 insertions(+), 1 deletions(-)
 
 diff --git a/plugins/ste.c b/plugins/ste.c
 index 7bb7232..cc01f7b 100644
 --- a/plugins/ste.c
 +++ b/plugins/ste.c
 @@ -247,7 +247,7 @@ static int ste_enable(struct ofono_modem *modem)
   return -EIO;
  
   data-chat = g_at_chat_new_blocking(channel, syntax);
 - g_at_chat_send(data-chat, ATF E0 V1 X4 C1 +CMEE=1,
 + g_at_chat_send(data-chat, ATF E0 V1 X4 C1 +CMEE=1;+CSCS=\UTF-8\,
   NULL, NULL, NULL, NULL);

is it guaranteed that every single STE modem supports UTF-8 character
set?

I would rather see a new command checking for supported character sets
and then picking the default. And intermixing with ATE is not really
clean from my perspective.

Regards

Marcel


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


Re: [PATCH 1/1] TODO: claim IPv6 task

2011-01-18 Thread Marcel Holtmann
Hi Mika,

  TODO |3 ++-
  1 files changed, 2 insertions(+), 1 deletions(-)

patch has been applied. Thanks.

Regards

Marcel


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


Re: [PATCH 7/8] sim: getters for mcc and mnc implementation

2011-01-18 Thread Marcel Holtmann
Hi Jukka,

  src/sim.c |   50 +++---
  1 files changed, 31 insertions(+), 19 deletions(-)
 
 diff --git a/src/sim.c b/src/sim.c
 index d627647..86c3f13 100644
 --- a/src/sim.c
 +++ b/src/sim.c
 @@ -78,6 +78,8 @@ struct ofono_sim {
   gboolean barred_dialing;
  
   char *imsi;
 + char mcc[OFONO_MAX_MCC_LENGTH + 1];
 + char mnc[OFONO_MAX_MNC_LENGTH + 1];

so I would split this a little bit.

1) refactor src/sim.c to store mcc and mnc.
2) add header definitions
3) add getters implementation.

And send these separately. No need to make them part of the provision
patch set. I know that you need them for that, but they are not really
required and could be reviewed and applied quicker.

Regards

Marcel


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


[PATCH] atmodem: coding style fix

2011-01-18 Thread Jeevaka Badrappan
---
 drivers/atmodem/sim.c |2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/drivers/atmodem/sim.c b/drivers/atmodem/sim.c
index c5f4a44..8d89d53 100644
--- a/drivers/atmodem/sim.c
+++ b/drivers/atmodem/sim.c
@@ -508,7 +508,7 @@ static void huawei_cpin_cb(gboolean ok, GAtResult *result, 
gpointer user_data)
if (!g_at_result_iter_next_number(iter, val))
goto error;
 
-   retries[password_types[i]]= val;
+   retries[password_types[i]] = val;
 
DBG(retry counter id=%d, val=%d, password_types[i],
retries[password_types[i]]);
-- 
1.7.0.4

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


Re: [PATCH 1/8] gprs-provision: add driver API header

2011-01-18 Thread Marcel Holtmann
Hi Jukka,

snip

 +/*
 + * Callback from provisioning plugin.
 + * settings: list of struct ofono_gprs_provision_data
 + *
 + * It is responsibility of callback function to free settings-list
 + * settings-list elements must be freed with ofono_gprs_provision_data_free()
 + */
 +typedef void (*ofono_gprs_provision_cb_t)(GSList *settings, void *userdata);

so our general rule is no GLib types in oFono public APIs.

 +struct ofono_gprs_provision_driver {
 + const char *name;
 + int priority;
 + int (*probe)(struct ofono_gprs_provision_context *context);
 + void (*remove)(struct ofono_gprs_provision_context *context);
 + void (*get_settings) (struct ofono_gprs_provision_context *context,

No space between (get_settings) and (struct please.

 + ofono_gprs_provision_cb_t cb,
 + void *user_data);
 +};
 +
 +/* For provisioning drivers/plugins */
 +int ofono_gprs_provision_driver_register(
 + const struct ofono_gprs_provision_driver *driver);
 +void ofono_gprs_provision_driver_unregister(
 + const struct ofono_gprs_provision_driver *driver);
 +
 +/* For gprs */
 +void ofono_gprs_provision_data_free(struct ofono_gprs_provision_data *data);

This sounds more like an __ofono_* internal API kind of thing.

Regards

Marcel


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


Re: [PATCH 3/8] gprs-provision: add driver API sources

2011-01-18 Thread Marcel Holtmann
Hi Jukka,

I am just making some minor style comments right now.

snip

 +struct gprs_provision_request {
 + GSList *drivers; /* Provisioning drivers to be called */
 + struct ofono_modem *modem;
 + ofono_gprs_provision_cb_t cb;
 + void *user_data;
 +};
 +
 +static void settings_cb(GSList *settings, void *user_data);
 +
 +static struct ofono_gprs_provision_context *gprs_provision_context_create(
 + struct ofono_modem *modem,
 + struct ofono_gprs_provision_driver *driver)
 +{
 + struct ofono_gprs_provision_context *context;
 +
 + if (driver-probe == NULL)
 + return NULL;
 +
 + context = g_try_new0(struct ofono_gprs_provision_context, 1);
 +

No empty line here please. Checking for a memory allocation result
should be done right away.

We might have some leftover cases from the earlier days. So bonus points
if you find them and fix them ;)

 + if (context == NULL)
 + return NULL;
 +
 + context-driver = driver;
 + context-modem = modem;
 +
 + if (driver-probe(context)  0) {
 + g_free(context);
 + return NULL;
 + }
 +
 + return context;
 +}
 +
 +static void clean_active_requests(gpointer data, gpointer user_data)
 +{
 + struct gprs_provision_request *req = data;
 + struct ofono_gprs_provision_context *context = user_data;
 +
 + req-drivers = g_slist_remove(req-drivers, context);
 +}
 +
 +static void context_remove(struct ofono_atom *atom)
 +{
 + struct ofono_gprs_provision_context *context =
 + __ofono_atom_get_data(atom);
 +
 + g_slist_foreach(provision_requests, clean_active_requests, context);
 +
 + if (context-driver-remove)
 + context-driver-remove(context);
 +
 + g_free(context);
 +}
 +
 +void __ofono_gprs_provision_probe_drivers(struct ofono_modem *modem)
 +{
 + struct ofono_gprs_provision_driver *driver;
 + struct ofono_gprs_provision_context *context;
 + GSList *l;
 +
 + for (l = g_drivers; l; l = l-next) {
 + driver = l-data;
 +
 + context = gprs_provision_context_create(modem, driver);
 + if (context == NULL)
 + continue;
 +
 + __ofono_modem_add_atom(modem, OFONO_ATOM_TYPE_GPRS_PROVISION,
 + context_remove, context);
 + }
 +}
 +
 +void ofono_gprs_provision_data_free(struct ofono_gprs_provision_data *data)
 +{
 + if (data == NULL)
 + return;
 +
 + free(data-name);
 + free(data-apn);
 + free(data-username);
 + free(data-password);
 + free(data-message_proxy);
 + free(data-message_center);

Use g_free for all of them please.

 + g_free(data);
 +}

As mentioned in the other reply. This sounds more like an internal API
detail to me.

 + * Calls next driver that has callable get_settings()
 + * Returns TRUE if a driver was called.
 + */
 +static gboolean call_driver_get_settings(struct gprs_provision_request *req,
 + ofono_gprs_provision_cb_t cb)
 +{
 + struct ofono_gprs_provision_context *context;
 +
 + if (req-drivers == NULL)
 + return FALSE;

What is this check for? Wouldn't a 

while (req-drivers != NULL) {

}

return FALSE;

just work fine as well.

 +
 + do {
 + context = req-drivers-data;
 + req-drivers = g_slist_delete_link(req-drivers, req-drivers);
 +
 + if (context-driver-get_settings != NULL) {
 + DBG(Calling provisioning plugin '%s',
 + context-driver-name);
 +
 + provision_requests = g_slist_append(provision_requests,
 + req);
 + context-driver-get_settings(context, cb, req);
 + return TRUE;
 + }
 +
 + } while (req-drivers != NULL);
 +
 + return FALSE;
 +}
 +
 +static void settings_cb(GSList *settings, void *user_data)
 +{
 + struct gprs_provision_request *req = user_data;
 +
 + provision_requests = g_slist_remove(provision_requests, req);
 + if (settings == NULL) {
 + DBG(Provisioning plugin returned no settings);

This sounds more like an ofono_warn message. Especially if you can also
print out the settings driver name.

 + /* No success from this driver, try next */
 + if (call_driver_get_settings(req, settings_cb) == TRUE)
 + return;
 + } else
 + DBG(Provisioning plugin returned settings for %d contexts,
 + g_slist_length(settings));
 +
 + req-cb(settings, req-user_data);
 + g_slist_free(req-drivers);
 + g_free(req);
 +}
 +
 +static void prepend_provision_driver(struct ofono_atom *atom, void *data)
 +{
 + struct ofono_gprs_provision_context *context =
 + __ofono_atom_get_data(atom);
 + 

Re: [PATCH] atmodem: coding style fix

2011-01-18 Thread Marcel Holtmann
Hi Jeevaka,

  drivers/atmodem/sim.c |2 +-
  1 files changed, 1 insertions(+), 1 deletions(-)

patch has been applied. Thanks.

Regards

Marcel


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


Re: [PATCH 3/5 v3] nettime: DBUS and compilation configuration

2011-01-18 Thread Marcel Holtmann
Hi Aki,

  So these are redundant, unless the whole thing is rewritten as:
 
allow send_destination=org.ofono 
  send_interface=org.ofono.SimToolkitAgent/
allow send_destination=org.ofono 
  send_interface=org.ofono.PushNotificationAgent/
allow send_destination=org.ofono 
  send_interface=org.ofono.SmartMessagingAgent/
 
 
  The agents are registered by the application, not ofono.  So the
  destination is in fact not org.ofono but a system bus connection owned
  by the application.  Hence the need to punch holes here.
 
 This means we also need punch a hole for org.ofono.NetworkTime. The
 only difference there to the above agent interfaces is that it's a
 singleton and comes with no registration API on oFono side. Instead,
 there is a custom plugin per agent implementation, like the one for
 timed.

please don't implement org.ofono interface in timed. Just implement a
timed specific (com.nokia.time) interface and punch the whole for that
in the timed D-Bus policy.

The plugin is timed specific since it monitors com.nokia.time and thus
should also target a timed specific API. Not a generic oFono API
description.

Regards

Marcel


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


[PATCHv3 1/2] doc:Add Bluetooth Dial-up Networking Profile specs

2011-01-18 Thread Olivier Guiter
---
 doc/standards.txt |4 
 1 files changed, 4 insertions(+), 0 deletions(-)

diff --git a/doc/standards.txt b/doc/standards.txt
index 35f2a3a..b7b68f3 100644
--- a/doc/standards.txt
+++ b/doc/standards.txt
@@ -175,3 +175,7 @@ standards. oFono implements some of the features found in 
the Phase 2
 specification, version 4.2.
 
 The specification itself is not publicly available.
+
+Bluetooth Specifications
+
+- Dial-up Networking Profile - Bluetooth specification version 1.1 - 22 
February 2001
-- 
1.7.1

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


[PATCHv3 2/2] doc: Add AT command set for Dialup Networking

2011-01-18 Thread Olivier Guiter
---
 doc/dialup-command-set.txt |   45 
 1 files changed, 45 insertions(+), 0 deletions(-)
 create mode 100644 doc/dialup-command-set.txt

diff --git a/doc/dialup-command-set.txt b/doc/dialup-command-set.txt
new file mode 100644
index 000..a7a1df3
--- /dev/null
+++ b/doc/dialup-command-set.txt
@@ -0,0 +1,45 @@
+This document specifies the AT command set used in the bluetooth ofono plugins.
+
+Bluetooth Dial-up Networking Profile Features Description
+=
+(Ref. document: Dial-up Networking Profile - Bluetooth specification version 
1.1 - 22 February 2001)
+
+- AT COMMAND SET USED:
+Commands:
+   C  Circuit 109 (DCD) Control
+   D  Circuit 108 (DTR) Response
+   F  Set to Factory Defined Configuration
+   +GCAP   Request Complete Capabilities List
+   +GMIRequest Manufacturer Identification
+   +GMMRead Model Identification
+   +GMRRead Revision Identification
+   A   Answer Incoming Call
+   D   Dial
+   E   Command Echo
+   H   Hang Up
+   L   Monitor Speaker Loudness
+   M   Monitor Speaker Control
+   O   Return to Online Data Mode
+   P   Select Pulse Dialling
+   Q   Result Code Suppression
+   S0  Automatic Answer Control
+   S10 Automatic Disconnect Delay Control
+   S3  Command Line Termination Character
+   S4  Response Formatting Character
+   S5  Command Line Editing Character (BACKSPACE)
+   S6  Blind Dial Delay Control
+   S7  Connection Completion Timeout
+   S8  Comma Dial Modifier Delay Control
+   T   Select Tone Dialling
+   V   DCE Response Format
+   X   Call Progress Monitoring Control
+   Z   Reset to Default Configuration
+Result codes:
+   OK  Acknowledge execution of a command
+   CONNECT Connection has been established
+   RINGThe DCE has detected an incoming call signal from 
network
+   NO CARRIER  The connection has been terminated, or attempt to 
establish
+   a connection failed
+   ERROR   Error
+   NO DIALTONE No dial-tone detected
+   BUSYBusy signal detected
-- 
1.7.1

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


[PATCH] atmodem: fix signal strength issue with ifx

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

diff --git a/drivers/atmodem/network-registration.c 
b/drivers/atmodem/network-registration.c
index 0c77ba8..e11c974 100644
--- a/drivers/atmodem/network-registration.c
+++ b/drivers/atmodem/network-registration.c
@@ -662,13 +662,13 @@ static void ifx_xciev_notify(GAtResult *result, gpointer 
user_data)
return;
 
if (ind == 0)
-   strength = 0;
+   strength = -1;
else if (ind == 7)
strength = 100;
else
strength = (ind * 15);
 
-   ofono_netreg_strength_notify(netreg, ind);
+   ofono_netreg_strength_notify(netreg, strength);
 }
 
 static void ciev_notify(GAtResult *result, gpointer user_data)
-- 
1.7.0.4

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


Re: [PATCHv3 1/2] doc:Add Bluetooth Dial-up Networking Profile specs

2011-01-18 Thread Marcel Holtmann
Hi Olivier,

  doc/standards.txt |4 
  1 files changed, 4 insertions(+), 0 deletions(-)

patch has been applied. However please ensure doc:space in the
subject. It was easy to fix so did it for you.

Regards

Marcel


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


Re: [PATCHv3 2/2] doc: Add AT command set for Dialup Networking

2011-01-18 Thread Marcel Holtmann
Hi Olivier,

  doc/dialup-command-set.txt |   45 
 
  1 files changed, 45 insertions(+), 0 deletions(-)
  create mode 100644 doc/dialup-command-set.txt

patch has been applied. Thanks.

Regards

Marcel


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


Re: [PATCH] atmodem: fix signal strength issue with ifx

2011-01-18 Thread Marcel Holtmann
Hi Jeevaka,

  drivers/atmodem/network-registration.c |4 ++--
  1 files changed, 2 insertions(+), 2 deletions(-)
 
 diff --git a/drivers/atmodem/network-registration.c 
 b/drivers/atmodem/network-registration.c
 index 0c77ba8..e11c974 100644
 --- a/drivers/atmodem/network-registration.c
 +++ b/drivers/atmodem/network-registration.c
 @@ -662,13 +662,13 @@ static void ifx_xciev_notify(GAtResult *result, 
 gpointer user_data)
   return;
  
   if (ind == 0)
 - strength = 0;
 + strength = -1;
   else if (ind == 7)
   strength = 100;
   else
   strength = (ind * 15);
  
 - ofono_netreg_strength_notify(netreg, ind);
 + ofono_netreg_strength_notify(netreg, strength);

good catch. I really screwed this one up. Patch has been applied.

Regards

Marcel


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


Re: [PATCH] ste: Use UTF-8 as a default character set

2011-01-18 Thread Lasse Kunnasluoto
Hi Marcel,

On Tue, 2011-01-18 at 16:32 +0200, Marcel Holtmann wrote:
 Hi Lasse,
 
   plugins/ste.c |2 +-
   1 files changed, 1 insertions(+), 1 deletions(-)
  
  diff --git a/plugins/ste.c b/plugins/ste.c
  index 7bb7232..cc01f7b 100644
  --- a/plugins/ste.c
  +++ b/plugins/ste.c
  @@ -247,7 +247,7 @@ static int ste_enable(struct ofono_modem *modem)
  return -EIO;
   
  data-chat = g_at_chat_new_blocking(channel, syntax);
  -   g_at_chat_send(data-chat, ATF E0 V1 X4 C1 +CMEE=1,
  +   g_at_chat_send(data-chat, ATF E0 V1 X4 C1 +CMEE=1;+CSCS=\UTF-8\,
  NULL, NULL, NULL, NULL);
 
 is it guaranteed that every single STE modem supports UTF-8 character
 set?
 
Based on information I have, yes, every single ste modem support UTF-8.

 I would rather see a new command checking for supported character sets
 and then picking the default. And intermixing with ATE is not really
 clean from my perspective.
You want this to be changed accordingly? I tried to to follow minimalism
in this simple change and not to introduce new functions. If command
fails for some reason, modem uses its default value, which is IRA. It
could be on a separate line, but still I would not add a call back for
it, nothing to do if the command fails. I prefer the patch I sent, but
you can decide 

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


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


Re: [PATCH v3] gatserver: ATS6 command handler added

2011-01-18 Thread Marcel Holtmann
Hi Olivier,

 Use integer to be compliant with existing function prototypes.

patch has been applied, but I did remove this comment from the commit
message. If you see it within git log it made no sense and was only
relevant for the review.

 ---

So such a comment for review belongs between --- and the diffstat.

  gatchat/gatserver.c |   10 ++
  1 files changed, 10 insertions(+), 0 deletions(-)

Regards

Marcel


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


Re: [PATCH] ste: Use UTF-8 as a default character set

2011-01-18 Thread Marcel Holtmann
Hi Laase,

  is it guaranteed that every single STE modem supports UTF-8 character
  set?
  
 Based on information I have, yes, every single ste modem support UTF-8.
 
  I would rather see a new command checking for supported character sets
  and then picking the default. And intermixing with ATE is not really
  clean from my perspective.
 You want this to be changed accordingly? I tried to to follow minimalism
 in this simple change and not to introduce new functions. If command
 fails for some reason, modem uses its default value, which is IRA. It
 could be on a separate line, but still I would not add a call back for
 it, nothing to do if the command fails. I prefer the patch I sent, but
 you can decide 

so at least use AT+CSCS=\UTF-8\ as a separate command after the init
command and put a comment above that all STE modems support UTF-8.

And to answer your question, I have seen other modems misbehaving when
it comes to charsets and even lying to use. That is why I asked ;)

Regards

Marcel


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


[PATCH] bluetooth: Add bluetooth server support (based on Zhenhua code)

2011-01-18 Thread Frédéric Danis
It watches Bluetooth adapter property changes and adds SDP record to
listen client connection request (refactored to support both DUN and
HFP GW servers).
Add bluetooth_ref()/bluetooth_unref() to support reference count in
bluetooth utils.
---
 Makefile.am |2 +-
 plugins/bluetooth.c |  396 --
 plugins/bluetooth.h |   11 ++
 3 files changed, 392 insertions(+), 17 deletions(-)

diff --git a/Makefile.am b/Makefile.am
index da59be7..fb3f750 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -312,7 +312,7 @@ builtin_sources += plugins/nokiacdma.c
 
 if BLUETOOTH
 builtin_modules += bluetooth
-builtin_sources += plugins/bluetooth.c plugins/bluetooth.h
+builtin_sources += $(btio_sources) plugins/bluetooth.c plugins/bluetooth.h
 
 builtin_modules += hfp
 builtin_sources += plugins/hfp.c plugins/bluetooth.h
diff --git a/plugins/bluetooth.c b/plugins/bluetooth.c
index 602c6da..fd6f541 100644
--- a/plugins/bluetooth.c
+++ b/plugins/bluetooth.c
@@ -35,11 +35,34 @@
 
 #include ofono/dbus.h
 
+#include btio.h
 #include bluetooth.h
 
 static DBusConnection *connection;
 static GHashTable *uuid_hash = NULL;
 static GHashTable *adapter_address_hash = NULL;
+static GSList *server_list = NULL;
+static gint ref_count;
+
+#define TIMEOUT (60*1000) /* Timeout for user response (miliseconds) */
+
+struct client {
+   GIOChannel  *io;
+   guint   watch;
+};
+
+struct server {
+   gchar   *name;
+   guint8  channel;
+   gchar   *sdp_record;
+   GIOChannel  *io;
+   gchar   *adapter;
+   guint   handle;
+   ConnectFunc connect_cb;
+   gpointeruser_data;
+
+   struct client   client;
+};
 
 void bluetooth_create_path(const char *dev_addr, const char *adapter_addr,
char *buf, int size)
@@ -370,6 +393,246 @@ static gboolean property_changed(DBusConnection 
*connection, DBusMessage *msg,
return TRUE;
 }
 
+static void disconnect(struct server *server)
+{
+   struct client *client = server-client;
+
+   if (!client-io)
+   return;
+
+   g_io_channel_unref(client-io);
+   client-io = NULL;
+
+   if (client-watch  0) {
+   g_source_remove(client-watch);
+   client-watch = 0;
+   }
+
+   return;
+}
+
+static void server_stop(gpointer data, gpointer user_data)
+{
+   struct server *server = data;
+
+   disconnect(server);
+
+   if (server-handle) {
+   DBusMessage *msg;
+
+   msg = dbus_message_new_method_call(BLUEZ_SERVICE,
+   server-adapter,
+   BLUEZ_SERVICE_INTERFACE,
+   RemoveRecord);
+   dbus_message_append_args(msg, DBUS_TYPE_UINT32, server-handle,
+   DBUS_TYPE_INVALID);
+   g_dbus_send_message(connection, msg);
+
+   server-handle = 0;
+   }
+
+   if (server-io) {
+   g_io_channel_shutdown(server-io, TRUE, NULL);
+   g_io_channel_unref(server-io);
+   server-io = NULL;
+   }
+
+   g_free(server-adapter);
+   server-adapter = NULL;
+}
+
+static gboolean client_event(GIOChannel *chan, GIOCondition cond, gpointer 
data)
+{
+   struct server *server = data;
+
+   disconnect(server);
+
+   return FALSE;
+}
+
+static void cancel_authorization(struct server *server)
+{
+   DBusMessage *msg;
+
+   if (!server-adapter)
+   return;
+
+   msg = dbus_message_new_method_call(BLUEZ_SERVICE, server-adapter,
+   BLUEZ_SERVICE_INTERFACE,
+   CancelAuthorization);
+
+   g_dbus_send_message(connection, msg);
+}
+
+static void auth_cb(DBusPendingCall *call, gpointer user_data)
+{
+   struct server *server = user_data;
+   struct client *client = server-client;
+   GIOChannel *io = client-io;
+   DBusMessage *reply = dbus_pending_call_steal_reply(call);
+   DBusError derr;
+   GError *err = NULL;
+
+   dbus_error_init(derr);
+
+   if (dbus_set_error_from_message(derr, reply)) {
+   ofono_error(RequestAuthorization error: %s, %s,
+   derr.name, derr.message);
+
+   if (dbus_error_has_name(derr, DBUS_ERROR_NO_REPLY))
+   cancel_authorization(server);
+
+   dbus_error_free(derr);
+   goto failed;
+   }
+
+   ofono_info(RequestAuthorization succeeded);
+
+   if (!bt_io_accept(io, server-connect_cb, server-user_data,
+   NULL, err)) {
+   ofono_error(%s, err-message);
+   g_error_free(err);
+   goto failed;
+   }
+
+   

[PATCH v2] ste: Use UTF-8 as a default character set

2011-01-18 Thread Lasse Kunnasluoto
---
 plugins/ste.c |4 
 1 files changed, 4 insertions(+), 0 deletions(-)

diff --git a/plugins/ste.c b/plugins/ste.c
index 7bb7232..44cfc14 100644
--- a/plugins/ste.c
+++ b/plugins/ste.c
@@ -250,6 +250,10 @@ static int ste_enable(struct ofono_modem *modem)
g_at_chat_send(data-chat, ATF E0 V1 X4 C1 +CMEE=1,
NULL, NULL, NULL, NULL);
 
+   /* All STE modems support UTF-8 */
+   g_at_chat_send(data-chat, AT+CSCS=\UTF-8\, NULL, NULL, NULL,
+   NULL);
+
g_io_channel_unref(channel);
g_at_syntax_unref(syntax);
 
-- 
1.7.0.4

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


Re: [PATCH 1/2] simutil: M9, M11, Minor style fixes and indentation

2011-01-18 Thread Denis Kenzior
Hi Jessica,

On 01/18/2011 06:32 AM, Jessica Nilsson wrote:
 ---
  src/simutil.h |   68 
  1 files changed, 34 insertions(+), 34 deletions(-)
 

This patch has been applied, but I had to merge it with some code
cleanups that were made in the meantime.

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


Re: [PATCH 2/2] simutil: sim_fileid sorted in numerical order

2011-01-18 Thread Denis Kenzior
Hi Jessica,

On 01/18/2011 06:32 AM, Jessica Nilsson wrote:
 ---
  src/simutil.h |   10 +-
  1 files changed, 5 insertions(+), 5 deletions(-)
 

This patch no longer applied, so I pushed my own version of the fix.

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


Re: [PATCH] bluetooth: Add bluetooth server support (based on Zhenhua code)

2011-01-18 Thread Marcel Holtmann
Hi Fred,

 Add bluetooth_ref()/bluetooth_unref() to support reference count in
 bluetooth utils.

didn't you had this as separate patch already? I think we should keep
that as a separate patch.

 ---
  Makefile.am |2 +-
  plugins/bluetooth.c |  396 --
  plugins/bluetooth.h |   11 ++
  3 files changed, 392 insertions(+), 17 deletions(-)
 
 diff --git a/Makefile.am b/Makefile.am
 index da59be7..fb3f750 100644
 --- a/Makefile.am
 +++ b/Makefile.am
 @@ -312,7 +312,7 @@ builtin_sources += plugins/nokiacdma.c
  
  if BLUETOOTH
  builtin_modules += bluetooth
 -builtin_sources += plugins/bluetooth.c plugins/bluetooth.h
 +builtin_sources += $(btio_sources) plugins/bluetooth.c plugins/bluetooth.h
  
  builtin_modules += hfp
  builtin_sources += plugins/hfp.c plugins/bluetooth.h

Please do it like this:

builtin_sources += $(btio_sources)
builtin_cflags += @BLUEZ_CFLAGS@
builtin_libadd += @BLUEZ_LIBS@

 +struct client {
 + GIOChannel  *io;
 + guint   watch;
 +};

Why do you need both. Normally only the watch is enough?

 +struct server {
 + gchar   *name;

Don't bother with gchar. Just use char.

 + guint8  channel;
 + gchar   *sdp_record;
 + GIOChannel  *io;
 + gchar   *adapter;
 + guint   handle;
 + ConnectFunc connect_cb;
 + gpointeruser_data;
 +
 + struct client   client;

Is it not simpler to just fold client_watch directly into it?

 +};
  
  void bluetooth_create_path(const char *dev_addr, const char *adapter_addr,
   char *buf, int size)
 @@ -370,6 +393,246 @@ static gboolean property_changed(DBusConnection 
 *connection, DBusMessage *msg,
   return TRUE;
  }
  
 +static void disconnect(struct server *server)
 +{
 + struct client *client = server-client;
 +
 + if (!client-io)
 + return;
 +
 + g_io_channel_unref(client-io);
 + client-io = NULL;
 +
 + if (client-watch  0) {
 + g_source_remove(client-watch);
 + client-watch = 0;
 + }
 +
 + return;

Don't bother with return for functions returning void.

 +}
 +
 +static void server_stop(gpointer data, gpointer user_data)
 +{
 + struct server *server = data;
 +
 + disconnect(server);
 +
 + if (server-handle) {

We do prefer service-handle  0 for these cases.

 + DBusMessage *msg;
 +
 + msg = dbus_message_new_method_call(BLUEZ_SERVICE,
 + server-adapter,
 + BLUEZ_SERVICE_INTERFACE,
 + RemoveRecord);
 + dbus_message_append_args(msg, DBUS_TYPE_UINT32, server-handle,
 + DBUS_TYPE_INVALID);
 + g_dbus_send_message(connection, msg);
 +
 + server-handle = 0;
 + }
 +
 + if (server-io) {

And here please do server-io != NULL.

 + g_io_channel_shutdown(server-io, TRUE, NULL);
 + g_io_channel_unref(server-io);
 + server-io = NULL;
 + }
 +
 + g_free(server-adapter);
 + server-adapter = NULL;
 +}
 +
 +static gboolean client_event(GIOChannel *chan, GIOCondition cond, gpointer 
 data)
 +{
 + struct server *server = data;
 +
 + disconnect(server);
 +
 + return FALSE;
 +}
 +
 +static void cancel_authorization(struct server *server)
 +{
 + DBusMessage *msg;
 +
 + if (!server-adapter)
 + return;
 +
 + msg = dbus_message_new_method_call(BLUEZ_SERVICE, server-adapter,
 + BLUEZ_SERVICE_INTERFACE,
 + CancelAuthorization);

Check that msg allocation succeeded before calling send.

 +
 + g_dbus_send_message(connection, msg);
 +}
 +
 +static void auth_cb(DBusPendingCall *call, gpointer user_data)
 +{
 + struct server *server = user_data;
 + struct client *client = server-client;
 + GIOChannel *io = client-io;
 + DBusMessage *reply = dbus_pending_call_steal_reply(call);
 + DBusError derr;
 + GError *err = NULL;
 +
 + dbus_error_init(derr);
 +
 + if (dbus_set_error_from_message(derr, reply)) {
 + ofono_error(RequestAuthorization error: %s, %s,
 + derr.name, derr.message);
 +
 + if (dbus_error_has_name(derr, DBUS_ERROR_NO_REPLY))
 + cancel_authorization(server);
 +
 + dbus_error_free(derr);
 + goto failed;
 + }
 +
 + ofono_info(RequestAuthorization succeeded);
 +
 + if (!bt_io_accept(io, server-connect_cb, server-user_data,
 + NULL, err)) {
 + ofono_error(%s, err-message);
 + g_error_free(err);
 + goto failed;
 + }
 +
 + g_source_remove(client-watch);
 +
 + client-watch = 

Re: [PATCH v2] ste: Use UTF-8 as a default character set

2011-01-18 Thread Marcel Holtmann
Hi Lasse,

  plugins/ste.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: Ofono CF states not always correct

2011-01-18 Thread Denis Kenzior
Hi Jarko,

 So actually they aren't both active at same time as the logs show but
 personally I don't really care as long as the results are consistent
 regardless which API you use which is not the case at the moment as
 querying through org.ofono.CallForwarding can give you different result
 than using org.ofono.SupplementaryServices.

Ok, so I'm convinced we're not handling this properly.  Based on your
testing and my own independent testing setting the Unconditional CF rule
does indeed 'hide' all other rules so they appear inactive.

So do you care to come up with a patch fixing this?  Briefly thinking
about this I believe we can implement option 2 from your earlier email.
 I'd rather play some tricks and not clear the cache unless really
necessary.

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


[PATCH] bluetooth: Add reference count for bluetooth utils

2011-01-18 Thread Frédéric Danis
Add bluetooth_ref()/bluetooth_unref() to support reference count in
bluetooth utils.
---
 plugins/bluetooth.c |   62 +-
 1 files changed, 46 insertions(+), 16 deletions(-)

diff --git a/plugins/bluetooth.c b/plugins/bluetooth.c
index 602c6da..a82cc64 100644
--- a/plugins/bluetooth.c
+++ b/plugins/bluetooth.c
@@ -40,6 +40,7 @@
 static DBusConnection *connection;
 static GHashTable *uuid_hash = NULL;
 static GHashTable *adapter_address_hash = NULL;
+static gint ref_count;
 
 void bluetooth_create_path(const char *dev_addr, const char *adapter_addr,
char *buf, int size)
@@ -504,12 +505,14 @@ static guint adapter_added_watch;
 static guint adapter_removed_watch;
 static guint property_watch;
 
-int bluetooth_register_uuid(const char *uuid, struct bluetooth_profile 
*profile)
+static int bluetooth_ref(void)
 {
int err;
 
-   if (uuid_hash)
-   goto done;
+   g_atomic_int_inc(ref_count);
+
+   if (ref_count  1)
+   return 0;
 
connection = ofono_dbus_get_connection();
 
@@ -543,13 +546,6 @@ int bluetooth_register_uuid(const char *uuid, struct 
bluetooth_profile *profile)
adapter_address_hash = g_hash_table_new_full(g_str_hash, g_str_equal,
g_free, g_free);
 
-done:
-   g_hash_table_insert(uuid_hash, g_strdup(uuid), profile);
-
-   bluetooth_send_with_reply(/, BLUEZ_MANAGER_INTERFACE, GetProperties,
-   manager_properties_cb, NULL, NULL, -1,
-   DBUS_TYPE_INVALID);
-
return 0;
 
 remove:
@@ -557,14 +553,17 @@ remove:
g_dbus_remove_watch(connection, adapter_added_watch);
g_dbus_remove_watch(connection, adapter_removed_watch);
g_dbus_remove_watch(connection, property_watch);
+
return err;
 }
 
-void bluetooth_unregister_uuid(const char *uuid)
+static void bluetooth_unref(void)
 {
-   g_hash_table_remove(uuid_hash, uuid);
+   gboolean is_zero;
 
-   if (g_hash_table_size(uuid_hash))
+   is_zero = g_atomic_int_dec_and_test(ref_count);
+
+   if (is_zero == FALSE)
return;
 
g_dbus_remove_watch(connection, bluetooth_watch);
@@ -572,9 +571,40 @@ void bluetooth_unregister_uuid(const char *uuid)
g_dbus_remove_watch(connection, adapter_removed_watch);
g_dbus_remove_watch(connection, property_watch);
 
-   g_hash_table_destroy(uuid_hash);
-   g_hash_table_destroy(adapter_address_hash);
-   uuid_hash = NULL;
+   if (uuid_hash) {
+   g_hash_table_destroy(uuid_hash);
+   uuid_hash = NULL;
+   }
+
+   if (adapter_address_hash) {
+   g_hash_table_destroy(adapter_address_hash);
+   adapter_address_hash = NULL;
+   }
+}
+
+int bluetooth_register_uuid(const char *uuid, struct bluetooth_profile 
*profile)
+{
+   int err;
+
+   err = bluetooth_ref();
+
+   if (err != 0)
+   return err;
+
+   g_hash_table_insert(uuid_hash, g_strdup(uuid), profile);
+
+   bluetooth_send_with_reply(/, BLUEZ_MANAGER_INTERFACE, GetProperties,
+   manager_properties_cb, NULL, NULL, -1,
+   DBUS_TYPE_INVALID);
+
+   return 0;
+}
+
+void bluetooth_unregister_uuid(const char *uuid)
+{
+   g_hash_table_remove(uuid_hash, uuid);
+
+   bluetooth_unref();
 }
 
 OFONO_PLUGIN_DEFINE(bluetooth, Bluetooth Utils Plugins, VERSION,
-- 
1.7.1

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


Re: [PATCH] bluetooth: Add reference count for bluetooth utils

2011-01-18 Thread Gustavo F. Padovan
Hi Frédéric,

* Frédéric Danis frederic.da...@linux.intel.com [2011-01-18 17:29:59 +0100]:

 Add bluetooth_ref()/bluetooth_unref() to support reference count in
 bluetooth utils.
 ---
  plugins/bluetooth.c |   62 +-
  1 files changed, 46 insertions(+), 16 deletions(-)
 
 diff --git a/plugins/bluetooth.c b/plugins/bluetooth.c
 index 602c6da..a82cc64 100644
 --- a/plugins/bluetooth.c
 +++ b/plugins/bluetooth.c
 @@ -40,6 +40,7 @@
  static DBusConnection *connection;
  static GHashTable *uuid_hash = NULL;
  static GHashTable *adapter_address_hash = NULL;
 +static gint ref_count;
  
  void bluetooth_create_path(const char *dev_addr, const char *adapter_addr,
   char *buf, int size)
 @@ -504,12 +505,14 @@ static guint adapter_added_watch;
  static guint adapter_removed_watch;
  static guint property_watch;
  
 -int bluetooth_register_uuid(const char *uuid, struct bluetooth_profile 
 *profile)
 +static int bluetooth_ref(void)
  {
   int err;
  
 - if (uuid_hash)
 - goto done;
 + g_atomic_int_inc(ref_count);
 +
 + if (ref_count  1)
 + return 0;

As I said in the other e-mail, only increment in the end of the function.

  
   connection = ofono_dbus_get_connection();
  
 @@ -543,13 +546,6 @@ int bluetooth_register_uuid(const char *uuid, struct 
 bluetooth_profile *profile)
   adapter_address_hash = g_hash_table_new_full(g_str_hash, g_str_equal,
   g_free, g_free);
  
 -done:
 - g_hash_table_insert(uuid_hash, g_strdup(uuid), profile);
 -
 - bluetooth_send_with_reply(/, BLUEZ_MANAGER_INTERFACE, GetProperties,
 - manager_properties_cb, NULL, NULL, -1,
 - DBUS_TYPE_INVALID);
 -
   return 0;
  
  remove:
 @@ -557,14 +553,17 @@ remove:
   g_dbus_remove_watch(connection, adapter_added_watch);
   g_dbus_remove_watch(connection, adapter_removed_watch);
   g_dbus_remove_watch(connection, property_watch);
 +
   return err;
  }
  
 -void bluetooth_unregister_uuid(const char *uuid)
 +static void bluetooth_unref(void)
  {
 - g_hash_table_remove(uuid_hash, uuid);
 + gboolean is_zero;
  
 - if (g_hash_table_size(uuid_hash))
 + is_zero = g_atomic_int_dec_and_test(ref_count);
 +
 + if (is_zero == FALSE)
   return;
  
   g_dbus_remove_watch(connection, bluetooth_watch);
 @@ -572,9 +571,40 @@ void bluetooth_unregister_uuid(const char *uuid)
   g_dbus_remove_watch(connection, adapter_removed_watch);
   g_dbus_remove_watch(connection, property_watch);
  
 - g_hash_table_destroy(uuid_hash);
 - g_hash_table_destroy(adapter_address_hash);
 - uuid_hash = NULL;
 + if (uuid_hash) {
 + g_hash_table_destroy(uuid_hash);
 + uuid_hash = NULL;
 + }
 +
 + if (adapter_address_hash) {
 + g_hash_table_destroy(adapter_address_hash);
 + adapter_address_hash = NULL;
 + }
 +}
 +
 +int bluetooth_register_uuid(const char *uuid, struct bluetooth_profile 
 *profile)
 +{
 + int err;
 +
 + err = bluetooth_ref();

Same here.

 +
 + if (err != 0)
 + return err;
 +
 + g_hash_table_insert(uuid_hash, g_strdup(uuid), profile);
 +
 + bluetooth_send_with_reply(/, BLUEZ_MANAGER_INTERFACE, GetProperties,
 + manager_properties_cb, NULL, NULL, -1,
 + DBUS_TYPE_INVALID);
 +
 + return 0;
 +}
 +
 +void bluetooth_unregister_uuid(const char *uuid)
 +{
 + g_hash_table_remove(uuid_hash, uuid);
 +
 + bluetooth_unref();
  }
  
  OFONO_PLUGIN_DEFINE(bluetooth, Bluetooth Utils Plugins, VERSION,
 -- 
 1.7.1
 
 ___
 ofono mailing list
 ofono@ofono.org
 http://lists.ofono.org/listinfo/ofono

-- 
Gustavo F. Padovan
http://profusion.mobi
___
ofono mailing list
ofono@ofono.org
http://lists.ofono.org/listinfo/ofono


[PATCH v2] bluetooth: Add reference count for bluetooth utils

2011-01-18 Thread Frédéric Danis
Add bluetooth_ref()/bluetooth_unref() to support reference count in
bluetooth utils.
---
 plugins/bluetooth.c |   60 ++
 1 files changed, 45 insertions(+), 15 deletions(-)

diff --git a/plugins/bluetooth.c b/plugins/bluetooth.c
index 602c6da..d641d18 100644
--- a/plugins/bluetooth.c
+++ b/plugins/bluetooth.c
@@ -40,6 +40,7 @@
 static DBusConnection *connection;
 static GHashTable *uuid_hash = NULL;
 static GHashTable *adapter_address_hash = NULL;
+static gint ref_count;
 
 void bluetooth_create_path(const char *dev_addr, const char *adapter_addr,
char *buf, int size)
@@ -504,12 +505,12 @@ static guint adapter_added_watch;
 static guint adapter_removed_watch;
 static guint property_watch;
 
-int bluetooth_register_uuid(const char *uuid, struct bluetooth_profile 
*profile)
+static int bluetooth_ref(void)
 {
int err;
 
-   if (uuid_hash)
-   goto done;
+   if (ref_count  0)
+   return 0;
 
connection = ofono_dbus_get_connection();
 
@@ -543,12 +544,7 @@ int bluetooth_register_uuid(const char *uuid, struct 
bluetooth_profile *profile)
adapter_address_hash = g_hash_table_new_full(g_str_hash, g_str_equal,
g_free, g_free);
 
-done:
-   g_hash_table_insert(uuid_hash, g_strdup(uuid), profile);
-
-   bluetooth_send_with_reply(/, BLUEZ_MANAGER_INTERFACE, GetProperties,
-   manager_properties_cb, NULL, NULL, -1,
-   DBUS_TYPE_INVALID);
+   g_atomic_int_inc(ref_count);
 
return 0;
 
@@ -557,14 +553,17 @@ remove:
g_dbus_remove_watch(connection, adapter_added_watch);
g_dbus_remove_watch(connection, adapter_removed_watch);
g_dbus_remove_watch(connection, property_watch);
+
return err;
 }
 
-void bluetooth_unregister_uuid(const char *uuid)
+static void bluetooth_unref(void)
 {
-   g_hash_table_remove(uuid_hash, uuid);
+   gboolean is_zero;
+
+   is_zero = g_atomic_int_dec_and_test(ref_count);
 
-   if (g_hash_table_size(uuid_hash))
+   if (is_zero == FALSE)
return;
 
g_dbus_remove_watch(connection, bluetooth_watch);
@@ -572,9 +571,40 @@ void bluetooth_unregister_uuid(const char *uuid)
g_dbus_remove_watch(connection, adapter_removed_watch);
g_dbus_remove_watch(connection, property_watch);
 
-   g_hash_table_destroy(uuid_hash);
-   g_hash_table_destroy(adapter_address_hash);
-   uuid_hash = NULL;
+   if (uuid_hash) {
+   g_hash_table_destroy(uuid_hash);
+   uuid_hash = NULL;
+   }
+
+   if (adapter_address_hash) {
+   g_hash_table_destroy(adapter_address_hash);
+   adapter_address_hash = NULL;
+   }
+}
+
+int bluetooth_register_uuid(const char *uuid, struct bluetooth_profile 
*profile)
+{
+   int err;
+
+   err = bluetooth_ref();
+
+   if (err != 0)
+   return err;
+
+   g_hash_table_insert(uuid_hash, g_strdup(uuid), profile);
+
+   bluetooth_send_with_reply(/, BLUEZ_MANAGER_INTERFACE, GetProperties,
+   manager_properties_cb, NULL, NULL, -1,
+   DBUS_TYPE_INVALID);
+
+   return 0;
+}
+
+void bluetooth_unregister_uuid(const char *uuid)
+{
+   g_hash_table_remove(uuid_hash, uuid);
+
+   bluetooth_unref();
 }
 
 OFONO_PLUGIN_DEFINE(bluetooth, Bluetooth Utils Plugins, VERSION,
-- 
1.7.1

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


Re: [PATCH v2] bluetooth: Add reference count for bluetooth utils

2011-01-18 Thread Gustavo F. Padovan
Hi Frédéric,

* Frédéric Danis frederic.da...@linux.intel.com [2011-01-18 18:05:03 +0100]:

 Add bluetooth_ref()/bluetooth_unref() to support reference count in
 bluetooth utils.
 ---
  plugins/bluetooth.c |   60 ++
  1 files changed, 45 insertions(+), 15 deletions(-)
 
 diff --git a/plugins/bluetooth.c b/plugins/bluetooth.c
 index 602c6da..d641d18 100644
 --- a/plugins/bluetooth.c
 +++ b/plugins/bluetooth.c
 @@ -40,6 +40,7 @@
  static DBusConnection *connection;
  static GHashTable *uuid_hash = NULL;
  static GHashTable *adapter_address_hash = NULL;
 +static gint ref_count;
  
  void bluetooth_create_path(const char *dev_addr, const char *adapter_addr,
   char *buf, int size)
 @@ -504,12 +505,12 @@ static guint adapter_added_watch;
  static guint adapter_removed_watch;
  static guint property_watch;
  
 -int bluetooth_register_uuid(const char *uuid, struct bluetooth_profile 
 *profile)
 +static int bluetooth_ref(void)
  {
   int err;
  
 - if (uuid_hash)
 - goto done;
 + if (ref_count  0)
 + return 0;
  
   connection = ofono_dbus_get_connection();
  
 @@ -543,12 +544,7 @@ int bluetooth_register_uuid(const char *uuid, struct 
 bluetooth_profile *profile)
   adapter_address_hash = g_hash_table_new_full(g_str_hash, g_str_equal,
   g_free, g_free);
  
 -done:
 - g_hash_table_insert(uuid_hash, g_strdup(uuid), profile);
 -
 - bluetooth_send_with_reply(/, BLUEZ_MANAGER_INTERFACE, GetProperties,
 - manager_properties_cb, NULL, NULL, -1,
 - DBUS_TYPE_INVALID);
 + g_atomic_int_inc(ref_count);
  
   return 0;
  
 @@ -557,14 +553,17 @@ remove:
   g_dbus_remove_watch(connection, adapter_added_watch);
   g_dbus_remove_watch(connection, adapter_removed_watch);
   g_dbus_remove_watch(connection, property_watch);
 +

Extra line here.

-- 
Gustavo F. Padovan
http://profusion.mobi
___
ofono mailing list
ofono@ofono.org
http://lists.ofono.org/listinfo/ofono


[PATCH] gatchat: Fix issue after removing deprecated functions

2011-01-18 Thread Olivier Guiter
---
 gatchat/gatio.c |1 +
 1 files changed, 1 insertions(+), 0 deletions(-)

diff --git a/gatchat/gatio.c b/gatchat/gatio.c
index 9cfc998..53896df 100644
--- a/gatchat/gatio.c
+++ b/gatchat/gatio.c
@@ -145,6 +145,7 @@ gsize g_at_io_write(GAtIO *io, const gchar *data, gsize 
count)
return 0;
}
 
+   g_io_channel_flush(io-channel, NULL);
g_at_util_debug_chat(FALSE, data, bytes_written,
io-debugf, io-debug_data);
 
-- 
1.7.1

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


Re: [PATCH 2/5] netreg: Add CPHS CSP PLMN mode implementation

2011-01-18 Thread Aki Niemi
Hi Marcel,

2011/1/18 Marcel Holtmann mar...@holtmann.org:
 +     if (netreg-settings) {
 +             g_key_file_set_boolean(netreg-settings, SETTINGS_GROUP,
 +                                     ForcedAuto, netreg-forced_auto);
 +             storage_sync(netreg-imsi, SETTINGS_STORE, netreg-settings);
 +     }

 why are we bothering to store this value? Would it not be better to
 re-read when bringing up the modem?

We read the value always, yes, but storing the last known value rids
us of a superfluous PropertyChanged signal in the case when last value
of forced_auto was true, and after reading is still true. This is
because forced_auto is by default set to false.

I went back and forth with this myself as well, so perhaps it's not
worth the trouble.

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


Re: [PATCH 2/5] netreg: Add CPHS CSP PLMN mode implementation

2011-01-18 Thread Denis Kenzior
Hi Aki,

On 01/18/2011 12:44 PM, Aki Niemi wrote:
 Hi Marcel,
 
 2011/1/18 Marcel Holtmann mar...@holtmann.org:
 + if (netreg-settings) {
 + g_key_file_set_boolean(netreg-settings, SETTINGS_GROUP,
 + ForcedAuto, netreg-forced_auto);
 + storage_sync(netreg-imsi, SETTINGS_STORE, netreg-settings);
 + }

 why are we bothering to store this value? Would it not be better to
 re-read when bringing up the modem?
 
 We read the value always, yes, but storing the last known value rids
 us of a superfluous PropertyChanged signal in the case when last value
 of forced_auto was true, and after reading is still true. This is
 because forced_auto is by default set to false.

Do you mean across atom instantiations here?  If so there are plenty of
other attributes that get emitted in a similar fashion, so my vote is to
just emit the signal.  Or are you worried about something else?

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


Re: [PATCH 2/5] netreg: Add CPHS CSP PLMN mode implementation

2011-01-18 Thread Aki Niemi
Hi Denis,

2011/1/18 Denis Kenzior denk...@gmail.com:
 We read the value always, yes, but storing the last known value rids
 us of a superfluous PropertyChanged signal in the case when last value
 of forced_auto was true, and after reading is still true. This is
 because forced_auto is by default set to false.

 Do you mean across atom instantiations here?  If so there are plenty of
 other attributes that get emitted in a similar fashion, so my vote is to
 just emit the signal.  Or are you worried about something else?

Nope, that was basically it. I'll remove the code.

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


Re: [PATCH 3/5] doc: Add documentation for 'forced-mode'

2011-01-18 Thread Aki Niemi
Hi Marcel,

2011/1/18 Marcel Holtmann mar...@holtmann.org:
 +                             auto         Network registration is 
 performed
 +                                            automatically.
 +                             forced-auto  Network registration is 
 performed
 +                                            automatically while manual
 +                                            selection is disabled.

 we need to discuss this a little bit. I am not sure using a mode of
 forced auto is the best choice here.

 Maybe an extra property like ManualAllowed would be better. Thoughts?

The reason I ended up extending the Mode property was that once
forced_auto is true, no other Mode than auto is anyway possible. So in
a sense it is another type of Mode, which isn't to say a separate
property wouldn't work equally well.

I'm really open to either option. The way the code is written makes it
very easy to just expose this as a separate property.

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


Re: [PATCH 1/5] Add SIM authentication atom's driver definitions.

2011-01-18 Thread Denis Kenzior
Hi Andrew,

 +typedef void (*ofono_sim_list_apps_cb_t)(const struct ofono_error *error,
 + struct ofono_sim_app_record *list,
 + int count, void *data);

So I've been thinking about this one.  Was there a reason why you want
to pass the parsed list out of the driver instead of just returning the
hex_decoded CUAD response and length?

If we do that then:

 +struct ofono_sim_app_record {
 + unsigned char aid[16];
 + int aid_len;
 + char *label;
 +};

Can be easily hidden inside simutil.h and not exposed to the outside world.

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


Re: [PATCH 2/5] simutil: SIM applications directory decoding utils.

2011-01-18 Thread Denis Kenzior
Hi Andrew,

On 01/17/2011 11:38 AM, Andrzej Zaborowski wrote:
 ---
  src/simutil.c |   57 
 +
  src/simutil.h |2 ++
  2 files changed, 59 insertions(+), 0 deletions(-)
 
 diff --git a/src/simutil.c b/src/simutil.c
 index 8abf3d5..b3e2f52 100644
 --- a/src/simutil.c
 +++ b/src/simutil.c
 @@ -1465,3 +1465,60 @@ gboolean sim_sst_is_active(unsigned char *efsst, 
 unsigned char len,
  
   return (efsst[index / 4]  (((index % 4) * 2) + 1))  1;
  }
 +
 +GSList *sim_parse_app_template_entries(const unsigned char *buffer, int len)
 +{
 + GSList *ret = NULL;
 + const unsigned char *dataobj;
 + int dataobj_len;
 +
 + /* Find all the application entries */
 + while ((dataobj = ber_tlv_find_by_tag(buffer, 0x61, len,
 + dataobj_len)) != NULL) {
 + struct ofono_sim_app_record app;
 + const unsigned char *aid, *label;
 + int label_len;
 +
 + /* Find the aid (mandatory) */
 + aid = ber_tlv_find_by_tag(dataobj, 0x4f, dataobj_len,
 + app.aid_len);
 + if (!aid || app.aid_len  0x01 || app.aid_len  0x10)
 + goto error;
 +
 + memcpy(app.aid, aid, app.aid_len);
 +
 + /* Find the label (optional) */
 + label = ber_tlv_find_by_tag(dataobj, 0x50, dataobj_len,
 + label_len);
 + if (label) {
 + /*
 +  * Label field uses the extra complicated
 +  * encoding in 102.221 Annex A
 +  */
 + app.label = sim_string_to_utf8(label, label_len);
 +
 + if (app.label == NULL)
 + goto error;
 + } else
 + app.label = NULL;
 +
 + ret = g_slist_prepend(ret, g_memdup(app, sizeof(app)));
 +
 + len -= (dataobj - buffer) + dataobj_len;
 + buffer = dataobj + dataobj_len;
 + }
 +
 + return ret;
 +
 +error:
 + while (ret) {
 + GSList *t = ret;
 +
 + g_free(((struct ofono_sim_app_record *) ret-data)-label);

Is there a memory leak here?  I don't believe you are freeing the
ofono_sim_app_record structure itself.  This might be the opportunity to
get rid of that nasty cast as well ;)

 +
 + ret = ret-next;
 + g_slist_free_1(t);
 + }
 +
 + return NULL;
 +}

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


Re: [PATCH 5/5] atmodem: sim-auth atom driver.

2011-01-18 Thread Denis Kenzior
Hi Andrew,

 +static void at_discover_apps_cb(gboolean ok, GAtResult *result,
 + gpointer user_data)
 +{
 + struct cb_data *cbd = user_data;
 + GAtResultIter iter;
 + ofono_sim_list_apps_cb_t cb = cbd-cb;
 + struct ofono_error error;
 + GSList *list = NULL, *i;
 + struct ofono_sim_app_record *buffer;
 + int j, n;
 +
 + decode_at_error(error, g_at_result_final_response(result));
 +
 + if (!ok) {
 + cb(error, NULL, 0, cbd-data);
 + return;
 + }
 +
 + g_at_result_iter_init(iter, result);
 +
 + while (g_at_result_iter_next(iter, +CUAD:)) {
 + const guint8 *obj_str;
 + gint len;
 +
 + if (!g_at_result_iter_next_hexstring(iter, obj_str, len))
 + goto error;
 +
 + i = sim_parse_app_template_entries(obj_str, len);
 + if (i == NULL)
 + goto error;
 +
 + list = g_slist_concat(i, list);
 + }
 +

Since we potentially multiple results, what do you think of using an
approach similar to how phonebook works.  E.g. a simple:

typedef void (*ofono_sim_auth_cb_t)(const struct ofono_error *error,
void *data);

and ofono_sim_auth_app_record(struct ofono_sim_auth *sa, unsigned char
*record, int len);

This would work nicely even for drivers using CRSM I think...

 + n = g_slist_length(list);
 + buffer = g_new(struct ofono_sim_app_record, n);
 +
 + for (i = list, j = n - 1; i != NULL; i = i-next, i--)
 + memcpy(buffer[j], i-data, sizeof(*buffer));
 +
 + cb(error, buffer, n, cbd-data);
 +
 + g_free(buffer);
 + goto done;
 +
 +error:
 + CALLBACK_WITH_FAILURE(cb, NULL, 0, cbd-data);
 +
 +done:
 + while (list) {
 + i = list;
 + list = list-next;
 +
 + g_free(((struct ofono_sim_app_record *) i-data)-label);
 + g_free(i-data);
 + g_slist_free_1(i);
 + }
 +}

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


Re: [PATCH 3/5] doc: Add documentation for 'forced-mode'

2011-01-18 Thread Marcel Holtmann
Hi Aki,

  + auto Network registration is 
  performed
  +automatically.
  + forced-auto  Network registration is 
  performed
  +automatically while manual
  +selection is disabled.
 
  we need to discuss this a little bit. I am not sure using a mode of
  forced auto is the best choice here.
 
  Maybe an extra property like ManualAllowed would be better. Thoughts?
 
 The reason I ended up extending the Mode property was that once
 forced_auto is true, no other Mode than auto is anyway possible. So in
 a sense it is another type of Mode, which isn't to say a separate
 property wouldn't work equally well.
 
 I'm really open to either option. The way the code is written makes it
 very easy to just expose this as a separate property.

the extra forced-auto mode feels kinda forced into this property. So
that is my main concern here.

However on the other hand the Mode property is actually read-only. If it
would be a user changeable property then it would be pretty clear that
we do not wanna intermix this here.

With this in mind, it might be just fine here from a UI interaction flow
point of view.

Denis, what is your take on this?

And while thinking about this, now I have another question. If this flag
is set on the SIM card, are you allowed to deregister from the network?

Regards

Marcel


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


Re: [gisi-notify-fix PATCH 1/4] gisi: remove before notify

2011-01-18 Thread Aki Niemi
Hi Pekka,

2011/1/12  pekka.pe...@nokia.com:
 @@ -192,24 +223,18 @@ static void service_dispatch(GIsiServiceMux *mux, 
 GIsiMessage *msg,
                        pending_dispatch(pend, msg);

                } else if (pend-type == GISI_MESSAGE_TYPE_RESP 
 -                               !is_indication  pend-utid == utid) {
 +                                !is_indication  pend-utid == utid) {

The rest looked good, so I amended this extra space that had jumped in
here, and pushed. Thanks.

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


Re: [gisi-notify-fix PATCH 4/4] isimodem: fix crash in gprs

2011-01-18 Thread Aki Niemi
Hi Pekka,

2011/1/12  pekka.pe...@nokia.com:
 From: Pekka Pessi pekka.pe...@nokia.com

 There was a crash if gprs was removed while creating context.
 ---
  drivers/isimodem/gprs.c |    3 +++
  1 files changed, 3 insertions(+), 0 deletions(-)

Patch was pushed, thanks.

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


Re: [gisi-notify-fix PATCH 2/4] gisi: simplify handling of pending

2011-01-18 Thread Aki Niemi
Hi Pekka,

2011/1/12  pekka.pe...@nokia.com:
 diff --git a/gisi/modem.h b/gisi/modem.h
 index fff1338..91fe3d0 100644
 --- a/gisi/modem.h
 +++ b/gisi/modem.h
 @@ -109,7 +109,9 @@ int g_isi_response_vsend(GIsiModem *modem, const 
 GIsiMessage *req,

  GIsiPending *g_isi_pending_from_msg(const GIsiMessage *msg);

 -void g_isi_pending_remove(GIsiPending *operation);
 +void g_isi_pending_own(GIsiPending *op, gpointer owner);
 +void g_isi_remove_all_my_pending(GIsiModem *modem, uint8_t resource,
 +                                       gpointer owner);

Overall, I like the idea.

But how about naming these a bit better? Something like
g_isi_pending_set_owner() and g_isi_pending_remove_by_owner()?

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


Re: [PATCH 3/5] doc: Add documentation for 'forced-mode'

2011-01-18 Thread Aki Niemi
Hi Marcel,

2011/1/18 Marcel Holtmann mar...@holtmann.org:
 And while thinking about this, now I have another question. If this flag
 is set on the SIM card, are you allowed to deregister from the network?

I suppose so. However, you know how I feel about Deregister() to begin
with. I think with the Online property, it simply serves no purpose.
Or is there an actual use case for intentionally leaving RF active
while in limited service only?

For sure, you're allowed to take the device offline.

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


Re: [PATCH 3/5] doc: Add documentation for 'forced-mode'

2011-01-18 Thread Marcel Holtmann
Hi Aki,

  And while thinking about this, now I have another question. If this flag
  is set on the SIM card, are you allowed to deregister from the network?
 
 I suppose so. However, you know how I feel about Deregister() to begin
 with. I think with the Online property, it simply serves no purpose.
 Or is there an actual use case for intentionally leaving RF active
 while in limited service only?

this is actually a good question. Do we still need the Deregister()
since we have Online property now.

I personally don't remember that we discussed this after we pushed the
Online support and fixed up the majority of the modem drivers.

Regards

Marcel


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


Re: [gisi-notify-fix PATCH 2/4] gisi: simplify handling of pending

2011-01-18 Thread Pekka Pessi
Hi,

2011/1/18 Aki Niemi a...@protocolpolice.com:
 -void g_isi_pending_remove(GIsiPending *operation);
 +void g_isi_pending_own(GIsiPending *op, gpointer owner);
 +void g_isi_remove_all_my_pending(GIsiModem *modem, uint8_t resource,
 +                                       gpointer owner);

 Overall, I like the idea.

 But how about naming these a bit better? Something like
 g_isi_pending_set_owner() and g_isi_pending_remove_by_owner()?

Sounds better. I'll do that, and I think I also leave the
g_isi_pending_remove() as an added bonus. Just in case.

-- 
Pekka.Pessi mail at nokia.com
___
ofono mailing list
ofono@ofono.org
http://lists.ofono.org/listinfo/ofono


Re: [PATCH 3/5] doc: Add documentation for 'forced-mode'

2011-01-18 Thread Denis Kenzior
Hi Marcel,

 The reason I ended up extending the Mode property was that once
 forced_auto is true, no other Mode than auto is anyway possible. So in
 a sense it is another type of Mode, which isn't to say a separate
 property wouldn't work equally well.

 I'm really open to either option. The way the code is written makes it
 very easy to just expose this as a separate property.
 
 the extra forced-auto mode feels kinda forced into this property. So
 that is my main concern here.
 
 However on the other hand the Mode property is actually read-only. If it
 would be a user changeable property then it would be pretty clear that
 we do not wanna intermix this here.
 
 With this in mind, it might be just fine here from a UI interaction flow
 point of view.
 
 Denis, what is your take on this?
 

I'm fine with forced-auto, but we might want to add a new error type to
ofono.h (maybe something like ManualRegistrationNotAllowed) and return
that error when trying to use Scan or NetworkOperator.Register.

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


Re: [PATCH 3/5] doc: Add documentation for 'forced-mode'

2011-01-18 Thread Denis Kenzior
Hi Aki,

On 01/18/2011 02:35 PM, Aki Niemi wrote:
 Hi Marcel,
 
 2011/1/18 Marcel Holtmann mar...@holtmann.org:
 And while thinking about this, now I have another question. If this flag
 is set on the SIM card, are you allowed to deregister from the network?
 
 I suppose so. However, you know how I feel about Deregister() to begin
 with. I think with the Online property, it simply serves no purpose.
 Or is there an actual use case for intentionally leaving RF active
 while in limited service only?
 

I'm fine removing this one as well.

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


Re: [PATCH 1/9] include: add cdip field in ofono_call

2011-01-18 Thread Denis Kenzior
Hi Lucas,

On 01/12/2011 05:27 AM, Lucas De Marchi wrote:
 ---
  include/types.h |1 +
  1 files changed, 1 insertions(+), 0 deletions(-)
 

I applied all 9 patches in this series but made some minor modifications
afterwards.  Can you review and make sure things are still working as
intended?

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


Re: Ofono CF states not always correct

2011-01-18 Thread Pekka Pessi
HI Denis,

2011/1/18 Denis Kenzior denk...@gmail.com:
 Ok, so I'm convinced we're not handling this properly.  Based on your
 testing and my own independent testing setting the Unconditional CF rule
 does indeed 'hide' all other rules so they appear inactive.

 So do you care to come up with a patch fixing this?  Briefly thinking
 about this I believe we can implement option 2 from your earlier email.

I've yet to see a network which sends forwardingFeatureList for
conditional CFs if unconditional CF is active, they just tell that the
unconditional CFs are, uh, quiescent.

Try your self, do you get anything sensible from *#67# if you have CFU
active? (Like after step #4 above?)

  I'd rather play some tricks and not clear the cache unless really
 necessary.

I just don't see any option but clearing the cache. Of course, we can
optimize by the fact that CFU makes  conditional CFs
inactive/quiescent.

-- 
Pekka.Pessi mail at nokia.com
___
ofono mailing list
ofono@ofono.org
http://lists.ofono.org/listinfo/ofono


Re: Ofono CF states not always correct

2011-01-18 Thread Denis Kenzior
Hi Pekka,

On 01/18/2011 03:08 PM, Pekka Pessi wrote:
 HI Denis,
 
 2011/1/18 Denis Kenzior denk...@gmail.com:
 Ok, so I'm convinced we're not handling this properly.  Based on your
 testing and my own independent testing setting the Unconditional CF rule
 does indeed 'hide' all other rules so they appear inactive.

 So do you care to come up with a patch fixing this?  Briefly thinking
 about this I believe we can implement option 2 from your earlier email.
 
 I've yet to see a network which sends forwardingFeatureList for
 conditional CFs if unconditional CF is active, they just tell that the
 unconditional CFs are, uh, quiescent.
 
 Try your self, do you get anything sensible from *#67# if you have CFU
 active? (Like after step #4 above?)
 

That was indeed the behavior on T-mobile during my personal testing.  So
I'm already convinced ;)

  I'd rather play some tricks and not clear the cache unless really
 necessary.
 
 I just don't see any option but clearing the cache. Of course, we can
 optimize by the fact that CFU makes  conditional CFs
 inactive/quiescent.
 

I think we can track the cached flag for conditional CFs independently
from CFU.  The question is really whether the networks allow us to
modify conditional CFs when CFU is active.  In my testing the answer is No.

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


[gisi-notify-fix PATCHv2 1/2] gisi: simplify pending management

2011-01-18 Thread Pekka . Pessi
From: Pekka Pessi pekka.pe...@nokia.com

Client or server mark their pending objects with
the function g_isi_pending_set_owner().

When client or server get destroyed or reset the pending objects are
removed with the function g_isi_remove_pending_by_owner(). As a client
or server always uses only a particular resource, all the pending
objects are conveniently stored into a single list.
---
 gisi/client.c |  199 ++---
 gisi/modem.c  |   63 ++
 gisi/modem.h  |5 +-
 gisi/server.c |   73 ++---
 4 files changed, 107 insertions(+), 233 deletions(-)

diff --git a/gisi/client.c b/gisi/client.c
index 85e1fa7..ff2b1f4 100644
--- a/gisi/client.c
+++ b/gisi/client.c
@@ -32,58 +32,12 @@
 
 #include client.h
 
-struct pending_data {
-   GIsiClient *client;
-   GIsiNotifyFunc notify;
-   void *data;
-   GDestroyNotify destroy;
-};
-
 struct _GIsiClient {
GIsiModem *modem;
unsigned timeout;
uint8_t resource;
-   GSList *pending;
 };
 
-static void pending_destroy(gpointer data)
-{
-   struct pending_data *pd = data;
-
-   if (pd == NULL)
-   return;
-
-   if (pd-destroy != NULL)
-   pd-destroy(pd-data);
-
-   g_free(pd);
-}
-
-static void pending_resp_notify(const GIsiMessage *msg, void *data)
-{
-   struct pending_data *pd = data;
-
-   if (pd == NULL)
-   return;
-
-   pd-client-pending = g_slist_remove(pd-client-pending,
-   g_isi_pending_from_msg(msg));
-
-   if (pd-notify != NULL)
-   pd-notify(msg, pd-data);
-}
-
-static void pending_notify(const GIsiMessage *msg, void *data)
-{
-   struct pending_data *pd = data;
-
-   if (pd == NULL)
-   return;
-
-   if (pd-notify != NULL)
-   pd-notify(msg, pd-data);
-}
-
 uint8_t g_isi_client_resource(GIsiClient *client)
 {
return client != NULL ? client-resource : 0;
@@ -112,31 +66,13 @@ GIsiClient *g_isi_client_create(GIsiModem *modem, uint8_t 
resource)
client-timeout = G_ISI_CLIENT_DEFAULT_TIMEOUT;
client-resource = resource;
client-modem = modem;
-   client-pending = NULL;
 
return client;
 }
 
-static void foreach_destroy(gpointer value, gpointer user)
-{
-   GIsiPending *op = value;
-   GIsiClient *client = user;
-
-   if (op == NULL || client == NULL)
-   return;
-
-   client-pending = g_slist_remove(client-pending, op);
-   g_isi_pending_remove(op);
-}
-
 void g_isi_client_reset(GIsiClient *client)
 {
-   if (client == NULL || client-pending == NULL)
-   return;
-
-   g_slist_foreach(client-pending, foreach_destroy, client);
-   g_slist_free(client-pending);
-   client-pending = NULL;
+   g_isi_remove_pending_by_owner(client-modem, client-resource, client);
 };
 
 void g_isi_client_destroy(GIsiClient *client)
@@ -156,43 +92,19 @@ void g_isi_client_set_timeout(GIsiClient *client, unsigned 
timeout)
client-timeout = timeout;
 }
 
-static struct pending_data *pending_data_create(GIsiClient *client,
-   GIsiNotifyFunc notify,
-   void *data,
-   GDestroyNotify destroy)
-{
-   struct pending_data *pd;
-
-   if (client == NULL) {
-   errno = EINVAL;
-   return NULL;
-   }
-
-   pd = g_try_new0(struct pending_data, 1);
-   if (pd == NULL) {
-   errno = ENOMEM;
-   return NULL;
-   }
-
-   pd-client = client;
-   pd-notify = notify;
-   pd-data = data;
-   pd-destroy = destroy;
-
-   return pd;
-}
-
 gboolean g_isi_client_send(GIsiClient *client,
const void *__restrict msg, size_t len,
GIsiNotifyFunc notify, void *data,
GDestroyNotify destroy)
 {
-   if (client == NULL)
-   return FALSE;
+   GIsiPending *op;
+
+   op = g_isi_request_send(client-modem, client-resource, msg, len,
+   client-timeout, notify, data, destroy);
 
-   return g_isi_client_send_with_timeout(client, msg, len,
-   client-timeout,
-   notify, data, destroy);
+   g_isi_pending_set_owner(op, client);
+
+   return op != NULL;
 }
 
 gboolean g_isi_client_send_with_timeout(GIsiClient *client,
@@ -201,23 +113,14 @@ gboolean g_isi_client_send_with_timeout(GIsiClient 
*client,
GIsiNotifyFunc notify, void *data,
GDestroyNotify destroy)
 {
-   struct pending_data *pd;
GIsiPending *op;
 
-   pd = pending_data_create(client, notify, data, destroy);
-   if (pd == NULL)
-   return 

[gisi-notify-fix PATCHv2 2/2] gisi: remove g_isi_pending_from_msg()

2011-01-18 Thread Pekka . Pessi
From: Pekka Pessi pekka.pe...@nokia.com

---
 gisi/modem.c |9 -
 gisi/modem.h |2 --
 2 files changed, 0 insertions(+), 11 deletions(-)

diff --git a/gisi/modem.c b/gisi/modem.c
index f80d671..8750367 100644
--- a/gisi/modem.c
+++ b/gisi/modem.c
@@ -156,8 +156,6 @@ static void pending_dispatch(GIsiPending *pend, GIsiMessage 
*msg)
g_isi_msg_resource(msg), g_isi_msg_id(msg),
g_isi_msg_utid(msg));
 
-   msg-private = pend;
-
pend-notify(msg, pend-data);
 }
 
@@ -177,8 +175,6 @@ static void pending_remove_and_dispatch(GIsiPending *op, 
GIsiMessage *msg)
g_isi_msg_resource(msg), g_isi_msg_id(msg),
g_isi_msg_utid(msg));
 
-   msg-private = op;
-
op-notify(msg, op-data);
 
 destroy:
@@ -770,11 +766,6 @@ uint8_t g_isi_request_utid(GIsiPending *resp)
return resp != NULL ? resp-utid : 0;
 }
 
-GIsiPending *g_isi_pending_from_msg(const GIsiMessage *msg)
-{
-   return msg != NULL ? msg-private : NULL;
-}
-
 void g_isi_pending_remove(GIsiPending *op)
 {
if (op == NULL)
diff --git a/gisi/modem.h b/gisi/modem.h
index 0de720d..f0a1617 100644
--- a/gisi/modem.h
+++ b/gisi/modem.h
@@ -107,8 +107,6 @@ int g_isi_response_vsend(GIsiModem *modem, const 
GIsiMessage *req,
const struct iovec *__restrict iov,
size_t iovlen);
 
-GIsiPending *g_isi_pending_from_msg(const GIsiMessage *msg);
-
 void g_isi_pending_remove(GIsiPending *op);
 void g_isi_pending_set_owner(GIsiPending *op, gpointer owner);
 void g_isi_remove_pending_by_owner(GIsiModem *modem, uint8_t resource,
-- 
1.7.1

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


Re: Ofono CF states not always correct

2011-01-18 Thread Pekka Pessi
Hi Denis,

2011/1/18 Denis Kenzior denk...@gmail.com:
 I think we can track the cached flag for conditional CFs independently
 from CFU.  The question is really whether the networks allow us to
 modify conditional CFs when CFU is active.  In my testing the answer is No.

You can erase (##67#) or deactivate (#67#) them.

-- 
Pekka.Pessi mail at nokia.com
___
ofono mailing list
ofono@ofono.org
http://lists.ofono.org/listinfo/ofono


Re: [gisi-notify-fix PATCHv2 1/2] gisi: simplify pending management

2011-01-18 Thread Aki Niemi
Hi Pekka,

2011/1/18  pekka.pe...@nokia.com:
 From: Pekka Pessi pekka.pe...@nokia.com

 Client or server mark their pending objects with
 the function g_isi_pending_set_owner().

 When client or server get destroyed or reset the pending objects are
 removed with the function g_isi_remove_pending_by_owner(). As a client
 or server always uses only a particular resource, all the pending
 objects are conveniently stored into a single list.
 ---
  gisi/client.c |  199 
 ++---
  gisi/modem.c  |   63 ++
  gisi/modem.h  |    5 +-
  gisi/server.c |   73 ++---
  4 files changed, 107 insertions(+), 233 deletions(-)

Pushed, thanks!

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


Re: [gisi-notify-fix PATCHv2 2/2] gisi: remove g_isi_pending_from_msg()

2011-01-18 Thread Aki Niemi
Hi Pekka,

2011/1/18  pekka.pe...@nokia.com:
 From: Pekka Pessi pekka.pe...@nokia.com

 ---
  gisi/modem.c |    9 -
  gisi/modem.h |    2 --
  2 files changed, 0 insertions(+), 11 deletions(-)

Pushed, thanks!

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


Re: Ofono CF states not always correct

2011-01-18 Thread Denis Kenzior
Hi Pekka,

On 01/18/2011 03:32 PM, Pekka Pessi wrote:
 Hi Denis,
 
 2011/1/18 Denis Kenzior denk...@gmail.com:
 I think we can track the cached flag for conditional CFs independently
 from CFU.  The question is really whether the networks allow us to
 modify conditional CFs when CFU is active.  In my testing the answer is No.
 
 You can erase (##67#) or deactivate (#67#) them.
 

So CFB active.

Activate CFU
Query CFB - Inactive

Deregister CFB - OK
Query CFB - Inactive

Register CFB - Error

Deactivate CFU
Query CFB - Inactive

Correct?

Jeez, who thought this stuff up.

So my thinking is that we should:
- Not update conditional cfs when cfu is active (whether via
GetProperties or mmi)
- only clear the conditional cache flag if a conditional operation is
attempted and succeeds while cfu is active
- Report conditional cfs as empty when CFU is active (and emit signals
appropriately when cfu is activated / deactivated)
- Don't bother running conditional cf queries via GetProperties if cfu
is active

Do you see any issues with this?  I'm really trying to minimize the
number of queries we have to do in the most common case (which is
activating / deactivating cfu via settings)

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


Re: Ofono CF states not always correct

2011-01-18 Thread Pekka Pessi
Hi Denis,

2011/1/18 Denis Kenzior denk...@gmail.com:
 2011/1/18 Denis Kenzior denk...@gmail.com:
 I think we can track the cached flag for conditional CFs independently
 from CFU.  The question is really whether the networks allow us to
 modify conditional CFs when CFU is active.  In my testing the answer is No.

 You can erase (##67#) or deactivate (#67#) them.

 So CFB active.

 Activate CFU
 Query CFB - Inactive

 Deregister CFB - OK
 Query CFB - Inactive

 Register CFB - Error

 Deactivate CFU
 Query CFB - Inactive

 Correct?

That is how I think it works.

 Jeez, who thought this stuff up.

 So my thinking is that we should:
 - Not update conditional cfs when cfu is active (whether via
 GetProperties or mmi)
 - only clear the conditional cache flag if a conditional operation is
 attempted and succeeds while cfu is active
 - Report conditional cfs as empty when CFU is active (and emit signals
 appropriately when cfu is activated / deactivated)
 - Don't bother running conditional cf queries via GetProperties if cfu
 is active

 Do you see any issues with this?

Nope, it sounds reasonable.

-- 
Pekka.Pessi mail at nokia.com
___
ofono mailing list
ofono@ofono.org
http://lists.ofono.org/listinfo/ofono


[PATCH v4, 5/7] cdmamodem: Add CDMA SMS driver support

2011-01-18 Thread Lei Yu
---
 Makefile.am   |3 +-
 drivers/atmodem/atutil.c  |   21 +++
 drivers/atmodem/atutil.h  |3 +
 drivers/atmodem/sms.c |   21 ---
 drivers/cdmamodem/cdmamodem.c |2 +
 drivers/cdmamodem/cdmamodem.h |2 +
 drivers/cdmamodem/sms.c   |  125 +
 7 files changed, 155 insertions(+), 22 deletions(-)
 create mode 100644 drivers/cdmamodem/sms.c

diff --git a/Makefile.am b/Makefile.am
index dff5553..7548942 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -253,7 +253,8 @@ builtin_modules += cdmamodem
 builtin_sources += drivers/cdmamodem/cdmamodem.h \
drivers/cdmamodem/cdmamodem.c \
drivers/cdmamodem/voicecall.c \
-   drivers/cdmamodem/devinfo.c
+   drivers/cdmamodem/devinfo.c \
+   drivers/cdmamodem/sms.c
 endif
 
 builtin_modules += g1
diff --git a/drivers/atmodem/atutil.c b/drivers/atmodem/atutil.c
index da17253..d567fbe 100644
--- a/drivers/atmodem/atutil.c
+++ b/drivers/atmodem/atutil.c
@@ -480,3 +480,24 @@ gboolean at_util_parse_attr(GAtResult *result, const char 
*prefix,
 
return TRUE;
 }
+
+gboolean at_parse_pdu_common(GAtResult *result, const char *prefix,
+   const char **pdu, int *pdulen)
+{
+   GAtResultIter iter;
+
+   g_at_result_iter_init(iter, result);
+
+   if (!g_at_result_iter_next(iter, prefix))
+   return FALSE;
+
+   if (!strcmp(prefix, +CMT:)  !g_at_result_iter_skip_next(iter))
+   return FALSE;
+
+   if (!g_at_result_iter_next_number(iter, pdulen))
+   return FALSE;
+
+   *pdu = g_at_result_pdu(result);
+
+   return TRUE;
+}
diff --git a/drivers/atmodem/atutil.h b/drivers/atmodem/atutil.h
index 3d13b84..3f70ac0 100644
--- a/drivers/atmodem/atutil.h
+++ b/drivers/atmodem/atutil.h
@@ -74,6 +74,9 @@ gboolean at_util_parse_cscs_query(GAtResult *result,
 gboolean at_util_parse_attr(GAtResult *result, const char *prefix,
const char **out_attr);
 
+gboolean at_parse_pdu_common(GAtResult *result, const char *prefix,
+   const char **pdu, int *pdulen);
+
 struct cb_data {
void *cb;
void *data;
diff --git a/drivers/atmodem/sms.c b/drivers/atmodem/sms.c
index c570886..725ed3c 100644
--- a/drivers/atmodem/sms.c
+++ b/drivers/atmodem/sms.c
@@ -339,27 +339,6 @@ static void at_cnma_cb(gboolean ok, GAtResult *result, 
gpointer user_data)
Further SMS reception is not guaranteed);
 }
 
-static gboolean at_parse_pdu_common(GAtResult *result, const char *prefix,
-   const char **pdu, int *pdulen)
-{
-   GAtResultIter iter;
-
-   g_at_result_iter_init(iter, result);
-
-   if (!g_at_result_iter_next(iter, prefix))
-   return FALSE;
-
-   if (!strcmp(prefix, +CMT:)  !g_at_result_iter_skip_next(iter))
-   return FALSE;
-
-   if (!g_at_result_iter_next_number(iter, pdulen))
-   return FALSE;
-
-   *pdu = g_at_result_pdu(result);
-
-   return TRUE;
-}
-
 static inline void at_ack_delivery(struct ofono_sms *sms)
 {
struct sms_data *data = ofono_sms_get_data(sms);
diff --git a/drivers/cdmamodem/cdmamodem.c b/drivers/cdmamodem/cdmamodem.c
index 9eddd88..f133fb0 100644
--- a/drivers/cdmamodem/cdmamodem.c
+++ b/drivers/cdmamodem/cdmamodem.c
@@ -36,6 +36,7 @@ static int cdmamodem_init(void)
 {
cdma_voicecall_init();
cdma_devinfo_init();
+   cdma_sms_init();
 
return 0;
 }
@@ -44,6 +45,7 @@ static void cdmamodem_exit(void)
 {
cdma_voicecall_exit();
cdma_devinfo_exit();
+   cdma_sms_exit();
 }
 
 OFONO_PLUGIN_DEFINE(cdmamodem, CDMA AT modem driver, VERSION,
diff --git a/drivers/cdmamodem/cdmamodem.h b/drivers/cdmamodem/cdmamodem.h
index 4365bec..4ce0b3d 100644
--- a/drivers/cdmamodem/cdmamodem.h
+++ b/drivers/cdmamodem/cdmamodem.h
@@ -25,3 +25,5 @@ extern void cdma_voicecall_init(void);
 extern void cdma_voicecall_exit(void);
 extern void cdma_devinfo_init(void);
 extern void cdma_devinfo_exit(void);
+extern void cdma_sms_init(void);
+extern void cdma_sms_exit(void);
diff --git a/drivers/cdmamodem/sms.c b/drivers/cdmamodem/sms.c
new file mode 100644
index 000..df61b7d
--- /dev/null
+++ b/drivers/cdmamodem/sms.c
@@ -0,0 +1,125 @@
+/*
+ *
+ *  oFono - Open Source Telephony
+ *
+ *  Copyright (C) 2010-2011  Nokia 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 

[PATCH v4, 4/7] cdma-sms: Add CDMA SMS Support

2011-01-18 Thread Lei Yu
---
 Makefile.am|2 +-
 src/cdma-sms.c |  330 
 src/ofono.h|3 +
 3 files changed, 334 insertions(+), 1 deletions(-)
 create mode 100644 src/cdma-sms.c

diff --git a/Makefile.am b/Makefile.am
index bd8c058..dff5553 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -355,7 +355,7 @@ src_ofonod_SOURCES = $(gdbus_sources) $(builtin_sources) 
src/ofono.ver \
src/simfs.c src/simfs.h src/audio-settings.c \
src/smsagent.c src/smsagent.h src/ctm.c \
src/cdma-voicecall.c src/cdma-smsutil.h \
-   src/cdma-smsutil.c
+   src/cdma-smsutil.c src/cdma-sms.c
 
 src_ofonod_LDADD = $(builtin_libadd) @GLIB_LIBS@ @DBUS_LIBS@ @CAPNG_LIBS@ -ldl
 
diff --git a/src/cdma-sms.c b/src/cdma-sms.c
new file mode 100644
index 000..ea88028
--- /dev/null
+++ b/src/cdma-sms.c
@@ -0,0 +1,330 @@
+/*
+ *
+ *  oFono - Open Source Telephony
+ *
+ *  Copyright (C) 2010-2011  Nokia 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
+
+#include string.h
+#include stdio.h
+#include errno.h
+
+#include glib.h
+#include gdbus.h
+#include sys/time.h
+
+#include ofono.h
+
+#include cdma-smsutil.h
+
+static GSList *g_drivers;
+
+struct ofono_cdma_sms {
+   const struct ofono_cdma_sms_driver *driver;
+   void *driver_data;
+   struct ofono_atom *atom;
+};
+
+static GDBusMethodTable cdma_sms_manager_methods[] = {
+   /* TODO */
+   { }
+};
+
+static GDBusSignalTable cdma_sms_manager_signals[] = {
+   { IncomingMessage,sa{sv}},
+   /* TODO */
+   { }
+};
+
+static void cdma_dispatch_text_message(struct ofono_cdma_sms *cdma_sms,
+   const char *message,
+   const char *oaddr)
+{
+   const char *path = __ofono_atom_get_path(cdma_sms-atom);
+   DBusConnection *conn = ofono_dbus_get_connection();
+   DBusMessage *signal;
+   DBusMessageIter iter;
+   DBusMessageIter dict;
+   const char *signal_name;
+
+   /* TODO: Support ImmediateMessage */
+   signal_name = IncomingMessage;
+
+   signal = dbus_message_new_signal(path,
+   OFONO_CDMA_MESSAGE_MANAGER_INTERFACE,
+   signal_name);
+   if (signal == NULL)
+   return;
+
+   dbus_message_iter_init_append(signal, iter);
+
+   dbus_message_iter_append_basic(iter, DBUS_TYPE_STRING, message);
+
+   dbus_message_iter_open_container(iter, DBUS_TYPE_ARRAY,
+   OFONO_PROPERTIES_ARRAY_SIGNATURE,
+   dict);
+
+   ofono_dbus_dict_append(dict, Sender, DBUS_TYPE_STRING, oaddr);
+
+   /* TODO: Other properties not supported yet */
+
+   dbus_message_iter_close_container(iter, dict);
+
+   g_dbus_send_message(conn, signal);
+
+   /*TODO: Add the message to history*/
+}
+
+static void ofono_cdma_sms_process_wmt_deliver(struct ofono_cdma_sms *cdma_sms,
+   const struct cdma_sms *incoming)
+{
+   char *message;
+   const char *oaddr;
+   const struct cdma_sms_ud *ud;
+
+   ud = incoming-p2p_msg.bd.wmt_deliver.ud;
+
+   /*
+* If incoming message does not contain USER DATA, still
+* send indication to upper layer but with empty string.
+*/
+   if (check_bitmap(incoming-p2p_msg.bd.subparam_bitmap,
+   CDMA_SMS_SUBPARAM_ID_USER_DATA) == FALSE)
+   message = g_new0(char, 1);
+   else
+   message = cdma_sms_decode_text(ud);
+
+   if (message == NULL)
+   return;
+
+   oaddr = cdma_sms_address_to_string(incoming-p2p_msg.oaddr);
+   if (oaddr == NULL) {
+   g_free(message);
+   return;
+   }
+
+   cdma_dispatch_text_message(cdma_sms, message, oaddr);
+
+   g_free(message);
+}
+
+static void ofono_cdma_sms_process_wmt(struct ofono_cdma_sms *cdma_sms,
+   struct cdma_sms *incoming)
+{
+   /* TODO: Add duplicate detection support */
+
+   switch 

[PATCH v4, 6/7] test: Add CDMA SMS Support

2011-01-18 Thread Lei Yu
---
 Makefile.am |6 ++-
 unit/test-cdmasms.c |  116 +++
 2 files changed, 121 insertions(+), 1 deletions(-)
 create mode 100644 unit/test-cdmasms.c

diff --git a/Makefile.am b/Makefile.am
index 7548942..11fc274 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -489,7 +489,7 @@ dist_man_MANS = doc/ofonod.8
 noinst_PROGRAMS = unit/test-common unit/test-util unit/test-idmap \
unit/test-sms unit/test-simutil \
unit/test-mux unit/test-caif \
-   unit/test-stkutil
+   unit/test-stkutil unit/test-cdmasms
 
 unit_objects =
 
@@ -509,6 +509,10 @@ unit_test_sms_SOURCES = unit/test-sms.c src/util.c 
src/smsutil.c src/storage.c
 unit_test_sms_LDADD = @GLIB_LIBS@
 unit_objects += $(unit_test_sms_OBJECTS)
 
+unit_test_cdmasms_SOURCES = unit/test-cdmasms.c src/cdma-smsutil.c
+unit_test_cdmasms_LDADD = @GLIB_LIBS@
+unit_objects += $(unit_test_cdmasms_OBJECTS)
+
 unit_test_simutil_SOURCES = unit/test-simutil.c src/util.c \
src/simutil.c src/smsutil.c src/storage.c
 unit_test_simutil_LDADD = @GLIB_LIBS@
diff --git a/unit/test-cdmasms.c b/unit/test-cdmasms.c
new file mode 100644
index 000..5140bc7
--- /dev/null
+++ b/unit/test-cdmasms.c
@@ -0,0 +1,116 @@
+/*
+ * oFono - Open Source Telephony
+ *
+ * Copyright (C) 2010-2011 Nokia 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 as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * 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
+
+#include string.h
+
+#include glib.h
+
+#include cdma-smsutil.h
+
+static inline void check_text(const char *decoded, const char *expected)
+{
+   if (expected == NULL) {
+   g_assert(decoded == NULL);
+   return;
+   }
+
+   g_assert(decoded != NULL);
+   g_assert(g_str_equal(decoded, expected));
+}
+
+struct wmt_deliver_test {
+   const guint8 *tpdu;
+   guint8 tpdu_len;
+   const char *text;
+   const char *oaddr;
+};
+
+guint8 wmt_deliver_1[] = {0x00, 0x00, 0x02, 0x10, 0x02, 0x02, 0x05, 0x01,
+   0xC4, 0x8D, 0x15, 0x9C, 0x08, 0x0D, 0x00,
+   0x03, 0x1B, 0xEE, 0xF0, 0x01, 0x06, 0x10,
+   0x2C, 0x8C, 0xBB, 0x36, 0x6F};
+
+guint8 wmt_deliver_2[] = {0x00, 0x00, 0x02, 0x10, 0x02, 0x02, 0x07, 0x02,
+   0xA1, 0x62, 0x51, 0x55, 0xA6, 0x40, 0x08,
+   0x18, 0x00, 0x03, 0x10, 0x00, 0x40, 0x01,
+   0x06, 0x10, 0x25, 0x4C, 0xBC, 0xFA, 0x00,
+   0x03, 0x06, 0x03, 0x08, 0x20, 0x13, 0x43,
+   0x12, 0x0D, 0x01, 0x01};
+
+static struct wmt_deliver_test wmt_deliver_data_1 = {
+   .tpdu = wmt_deliver_1,
+   .tpdu_len = sizeof(wmt_deliver_1),
+   .text = Hello,
+   .oaddr = 1234567
+};
+
+static struct wmt_deliver_test wmt_deliver_data_2 = {
+   .tpdu = wmt_deliver_2,
+   .tpdu_len = sizeof(wmt_deliver_2),
+   .text = Test,
+   .oaddr = 8589455699
+};
+
+static void test_wmt_deliver(gconstpointer data)
+{
+   const struct wmt_deliver_test *test = data;
+   gboolean ret;
+   struct cdma_sms s;
+   const char *addr;
+   char *message;
+
+   memset(s, 0, sizeof(struct cdma_sms));
+
+   ret = cdma_sms_decode(test-tpdu, test-tpdu_len, s);
+
+   g_assert(ret == TRUE);
+
+   g_assert(s.type == CDMA_SMS_TP_MSG_TYPE_P2P);
+
+   g_assert(s.p2p_msg.teleservice_id == CDMA_SMS_TELESERVICE_ID_WMT);
+
+   addr = cdma_sms_address_to_string(s.p2p_msg.oaddr);
+   check_text(addr, test-oaddr);
+
+   message = cdma_sms_decode_text(s.p2p_msg.bd.wmt_deliver.ud);
+   check_text(message, test-text);
+
+   g_free(message);
+
+   return;
+}
+
+int main(int argc, char **argv)
+{
+   g_test_init(argc, argv, NULL);
+
+   g_test_add_data_func(/test-cdmasms/WMT DELIVER 1,
+   wmt_deliver_data_1, test_wmt_deliver);
+
+   g_test_add_data_func(/test-cdmasms/WMT DELIVER 2,
+   wmt_deliver_data_2, test_wmt_deliver);
+
+   return g_test_run();
+}
-- 
1.7.0.4


Re: [PATCH] doc: use right description for CallSettings

2011-01-18 Thread Denis Kenzior
Hi Lucas,

On 01/18/2011 06:14 PM, Lucas De Marchi wrote:
 ---
  doc/features.txt |2 +-
  1 files changed, 1 insertions(+), 1 deletions(-)
 

Patch has been applied, thanks.

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


Re: [sim-auth RFCv2 1/4] TODO: add SIM authentication

2011-01-18 Thread Denis Kenzior
Hi Pekka,

 +- Support SIM authentication: SIM, AKA, and GBA suites.
 +
 +  Priority: Medium
 +  Complexity: C3

Please don't invent new complexity levels.  We explicitly use an
exponential system, so it is either a C2 or a C4, there's no inbetween ;)

 +  Owner: Pekka Pessi pekka.pe...@nokia.com
 +
  Modem Emulator
  ==
  

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


Re: [sim-auth RFCv2 3/4] Add GBA documents to doc/standards.txt

2011-01-18 Thread Denis Kenzior
Hi Pekka,

On 01/12/2011 05:08 PM, pekka.pe...@nokia.com wrote:
 From: Pekka Pessi pekka.pe...@nokia.com
 
 ---
  doc/standards.txt |   13 +
  1 files changed, 13 insertions(+), 0 deletions(-)
 

This patch has been applied, thanks.

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


Re: [PATCH 1/3] stk: Handle Launch Browser proactive command

2011-01-18 Thread Denis Kenzior
Hi Jeevaka,

On 01/14/2011 03:38 AM, Jeevaka Badrappan wrote:
 ---
  src/stk.c  |   90 
 
  src/stkagent.c |   68 ++
  src/stkagent.h |7 
  3 files changed, 165 insertions(+), 0 deletions(-)
 
 diff --git a/src/stk.c b/src/stk.c
 index f151fc1..e6df58b 100644
 --- a/src/stk.c
 +++ b/src/stk.c
 @@ -2358,6 +2358,91 @@ static gboolean handle_command_play_tone(const struct 
 stk_command *cmd,
   return FALSE;
  }
  
 +static void confirm_launch_browser_cb(enum stk_agent_result result,
 + gboolean confirm,
 + void *user_data)
 +{
 + struct ofono_stk *stk = user_data;
 + unsigned char no_cause[] = { 0x00 };
 + struct ofono_error failure = { .type = OFONO_ERROR_TYPE_FAILURE };
 + struct stk_response rsp;
 +
 + stk-respond_on_exit = FALSE;
 +
 + switch (result) {
 + case STK_AGENT_RESULT_TIMEOUT:
 + confirm = FALSE;
 + /* Fall through */
 +
 + case STK_AGENT_RESULT_OK:
 + if (confirm)
 + break;
 +
 + send_simple_response(stk, STK_RESULT_TYPE_USER_REJECT);

So funnily enough TS 102.223 Table 6.1 says that USER_REJECT is not a
valid response to Launch Browser, even though it certainly describes a
user confirmation phase.

 + return;
 + default:
 + memset(rsp, 0, sizeof(rsp));
 + ADD_ERROR_RESULT(rsp.result, STK_RESULT_TYPE_TERMINAL_BUSY,
 + no_cause);
 +
 + if (stk_respond(stk, rsp, stk_command_cb))
 + stk_command_cb(failure, stk);
 +
 + return;
 + }
 +
 + send_simple_response(stk, STK_RESULT_TYPE_SUCCESS);
 +}
 +
 +static gboolean handle_command_launch_browser(const struct stk_command *cmd,
 + struct stk_response *rsp,
 + struct ofono_stk *stk)
 +{
 + const struct stk_command_launch_browser *lb = cmd-launch_browser;
 + static unsigned char no_cause[] = { 0x00 };
 + int qualifier = cmd-qualifier;
 + char *alpha_id;
 + int err;
 +
 + if (qualifier  3 || qualifier == 1) {
 + rsp-result.type = STK_RESULT_TYPE_COMMAND_NOT_UNDERSTOOD;
 + return TRUE;
 + }

So my view is that this should be done inside stkutil.c

 +
 + if ( lb-browser_id  4) {
 + rsp-result.type = STK_RESULT_TYPE_DATA_NOT_UNDERSTOOD;
 + return TRUE;
 + }

Same for this one, the id should be validated inside browser_id parser

 +
 + alpha_id = dbus_apply_text_attributes(lb-alpha_id ? lb-alpha_id : ,
 + lb-text_attr);
 + if (alpha_id == NULL) {
 + rsp-result.type = STK_RESULT_TYPE_DATA_NOT_UNDERSTOOD;
 + return TRUE;
 + }
 +
 + err = stk_agent_confirm_launch_browser(stk-current_agent, alpha_id,
 + lb-icon_id.id, lb-url,
 + confirm_launch_browser_cb,
 + stk, NULL, stk-timeout * 1000);
 + g_free(alpha_id);
 +
 + if (err  0) {
 + /*
 +  * We most likely got an out of memory error, tell SIM
 +  * to retry
 +  */
 + ADD_ERROR_RESULT(rsp-result, STK_RESULT_TYPE_TERMINAL_BUSY,
 + no_cause);
 + return TRUE;
 + }
 +
 + stk-respond_on_exit = TRUE;
 + stk-cancel_cmd = stk_request_cancel;
 +
 + return FALSE;
 +}
 +
  static void stk_proactive_command_cancel(struct ofono_stk *stk)
  {
   if (stk-immediate_response)
 @@ -2545,6 +2630,11 @@ void ofono_stk_proactive_command_notify(struct 
 ofono_stk *stk,
   rsp, stk);
   break;
  
 + case STK_COMMAND_TYPE_LAUNCH_BROWSER:
 + respond = handle_command_launch_browser(stk-pending_cmd,
 + rsp, stk);
 + break;
 +
   default:
   rsp.result.type = STK_RESULT_TYPE_COMMAND_NOT_UNDERSTOOD;
   break;
 diff --git a/src/stkagent.c b/src/stkagent.c
 index 2cdc6e1..2395182 100644
 --- a/src/stkagent.c
 +++ b/src/stkagent.c
 @@ -1013,3 +1013,71 @@ int stk_agent_display_action_info(struct stk_agent 
 *agent, const char *text,
  
   return 0;
  }
 +
 +static void confirm_launch_browser_cb(DBusPendingCall *call, void *data)
 +{
 + struct stk_agent *agent = data;
 + stk_agent_confirmation_cb cb = agent-user_cb;
 + DBusMessage *reply = dbus_pending_call_steal_reply(call);
 + enum stk_agent_result result;
 + gboolean remove_agent;
 + dbus_bool_t confirm;
 +
 + if (check_error(agent, reply, 0, result) == -EINVAL) {
 +   

Re: [PATCH 2/3] test: Add support for launch browser command

2011-01-18 Thread Denis Kenzior
Hi Jeevaka,

On 01/14/2011 03:38 AM, Jeevaka Badrappan wrote:
 ---
  test/test-stk-menu |   13 +
  1 files changed, 13 insertions(+), 0 deletions(-)
 

Since we already figured out the API I went ahead and applied this patch.

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


Re: [PATCH 3/3] doc: Describe ConfirmLaunchBrowser method

2011-01-18 Thread Denis Kenzior
Hi Jeevaka,

On 01/14/2011 03:38 AM, Jeevaka Badrappan wrote:
 ---
  doc/stk-api.txt |8 
  1 files changed, 8 insertions(+), 0 deletions(-)
 

Patch has been applied, thanks.

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


Re: [offline-atoms PATCH 1/2] Make gprs atom offline-safe.

2011-01-18 Thread Denis Kenzior
Hi Pekka,

On 01/14/2011 08:40 AM, pekka.pe...@nokia.com wrote:
 From: Pekka Pessi pekka.pe...@nokia.com
 
 Allow use of GPRS atom both in online and offline (post_sim) states.
 
 The GPRS now considers the removal of the netreg atom as implicit detach
 and registration change to NOT_REGISTERED.
 ---
  src/gprs.c |   20 ++--
  1 files changed, 18 insertions(+), 2 deletions(-)
 
 diff --git a/src/gprs.c b/src/gprs.c
 index 0e86bdf..35cc475 100644
 --- a/src/gprs.c
 +++ b/src/gprs.c
 @@ -1370,10 +1370,27 @@ static void gprs_attach_callback(const struct 
 ofono_error *error, void *data)
   }
  }
  
 +static void gprs_netreg_removed(struct ofono_gprs *gprs)
 +{
 + gprs-netreg = NULL;
 +
 + gprs-flags = ~(GPRS_FLAG_RECHECK | GPRS_FLAG_ATTACHING);
 + gprs-status_watch = 0;
 + gprs-netreg_status = NETWORK_REGISTRATION_STATUS_NOT_REGISTERED;
 + gprs-driver_attached = FALSE;
 +
 + gprs_attached_update(gprs);
 +}
 +
  static void gprs_netreg_update(struct ofono_gprs *gprs)
  {
   ofono_bool_t attach;
  
 + if (gprs-netreg == NULL) {
 + gprs_netreg_removed(gprs);
 + return;
 + }
 +

I'm having trouble visualizing why this chunk is necessary.  We reset
netreg to NULL only when shutting down the atom or when netreg atom goes
away.  So this condition should never be triggered.

   attach = gprs-netreg_status == NETWORK_REGISTRATION_STATUS_REGISTERED;
  
   attach = attach || (gprs-roaming_allowed 
 @@ -2250,8 +2267,7 @@ static void netreg_watch(struct ofono_atom *atom,
   struct ofono_gprs *gprs = data;
  
   if (cond == OFONO_ATOM_WATCH_CONDITION_UNREGISTERED) {
 - gprs-status_watch = 0;
 - gprs-netreg = NULL;
 + gprs_netreg_removed(gprs);
   return;
   }
  

Otherwise the rest seems fine to me.

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


Re: [offline-atoms PATCH 2/2] Make sms atom offline-safe

2011-01-18 Thread Denis Kenzior
Hi Pekka,

On 01/14/2011 08:40 AM, pekka.pe...@nokia.com wrote:
 From: Pekka Pessi pekka.pe...@nokia.com
 
 Allow use of SMS atom both in online and offline (post_sim) states.
 
 SMS atom now watches network registration atom and state.  Thmessages
 are queued but not sent if not registered to a network.  Errors
 occurring when a short message is being sent while transition from
 online to offline or when network coverage is dropped are now handled
 gracefully.
 ---
  src/sms.c |   97 
 +
  1 files changed, 91 insertions(+), 6 deletions(-)
 

Patch looked fine to me, so I went ahead and applied it.  Can we get
this one tested ASAP on various modem drivers?

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


Re: [RFC PATCH 0/3] Long phone numbers

2011-01-18 Thread Denis Kenzior
Hi Rafael,

On 01/18/2011 03:39 AM, Rafael Ignacio Zurita wrote:
 On Mon, Jan 17, 2011 at 11:18:51PM +0200, Pekka Pessi wrote:
 Hi Rafael,

 2011/1/17 Rafael Ignacio Zurita rafael.zur...@profusion.mobi:
 This is a proposal for the long phone number task (80 digits max length).
 It changes OFONO_MAX_PHONE_NUMBER_LENGTH and splits
 common:valid_phone_number_format(), to make sure long numbers are handled
 appropriately for functions that need manage shorter numbers, like
 numbers written to the SIM, or sms SCA.

 Perhaps a validator and type for long phone numbers is better than for
 short numbers? I guess long numbers are mostly used when reporting an
 outgoing call back to oFono.
 
 No completely sure if it is better. Maybe it is the same?. With a new
 type for long number we will have modifications on other parts of the code
 which use OFONO_MAX_PHONE_NUMBER_LENGTH. The first idea could be simpler
 because we just have one type and would check for the format and length on the
 proper places.

So I actually agree with Pekka on this one, validating the long phone
number might actually be a bit easier.  Basically the long phone number
only happens when we place an outgoing call.

For the rest we can keep the limit to 20.

However, do note that this function is being (ab)used for:
- Checking valid destination for an SMS (20 chars max)
- Checking valid phone number to be written to SIM (currently no
extension records, so 20 chars max)
- Checking valid phone number to be sent to ATD (80 chars max)
- Checking valid phone number to be uses for deflection (? chars max)

Perhaps we should use an enumeration of the type of number we want,
similar to how is_valid_pin is implemented.

  
 BTW, with call forwarding you could have numbers up to 16 digits or if
 longForwardedToNumber is supported (by modem and both home and visited
 networks) even 28 digits. See TS 29.002 for merry details.
 
 Thanks for that. I am checking, and going to add an extra validator
 surely.
 

This might be a good idea, but keep in mind that if we set a long number
into CFU, we might not be able to support writing it out to the SIM's
EFcfis record.  So 20 characters might be all you have anyway.

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


Re: [PATCH 2/6] Define packet switched bearers

2011-01-18 Thread Marcel Holtmann
Hi Remi,

  src/common.c |   24 
  src/common.h |   13 +
  2 files changed, 37 insertions(+), 0 deletions(-)
 
 diff --git a/src/common.c b/src/common.c
 index d4e567b..c58ed5c 100644
 --- a/src/common.c
 +++ b/src/common.c
 @@ -714,6 +714,30 @@ const char *registration_tech_to_string(int tech)
   }
  }
  
 +const char *packet_bearer_to_string(int bearer)
 +{
 + switch (bearer) {
 + case PACKET_BEARER_NONE:
 + return none;
 + case PACKET_BEARER_GPRS:
 + return gprs;
 + case PACKET_BEARER_EGPRS:
 + return egprs;
 + case PACKET_BEARER_UMTS:
 + return umts;
 + case PACKET_BEARER_HSUPA:
 + return hsupa;
 + case PACKET_BEARER_HSDPA:
 + return hsdpa;
 + case PACKET_BEARER_HSUPA_HSDPA:
 + return hspa;
 + case PACKET_BEARER_EPS:
 + return eps;
 + default:
 + return ;
 + }
 +}

these don't match the documentation. Use edge and lte for them.

And please don't use a default switch label. Just return  at the end
of the function.

Regards

Marcel


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


Re: [PATCH 1/8] gprs-provision: add driver API header

2011-01-18 Thread Jukka Saunamaki
Hi Marcel,

  +/*
  + * Callback from provisioning plugin.
  + * settings: list of struct ofono_gprs_provision_data
  + *
  + * It is responsibility of callback function to free settings-list
  + * settings-list elements must be freed with 
  ofono_gprs_provision_data_free()
  + */
  +typedef void (*ofono_gprs_provision_cb_t)(GSList *settings, void 
  *userdata);
 
 so our general rule is no GLib types in oFono public APIs.

OK. Do you have any preferences for the best type here? Linked list of
'struct ofono_gprs_provision_data's, array of structs + count, array of
pointers (+count)?

--Jukka


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


[PATCH 0/3] sim: add getters for mcc and mnc

2011-01-18 Thread Jukka Saunamaki
These patches add getter functions for home PLMN MCC and MCC values to SIM atom.

Jukka Saunamaki (3):
  sim: store mcc and mnc separate from imsi
  sim: getters for mcc and mnc definition
  sim: getters for mcc and mnc implementation

 include/sim.h |2 ++
 src/sim.c |   50 +++---
 2 files changed, 33 insertions(+), 19 deletions(-)

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


  1   2   >