[RFC PATCH 2/2] unit: national to international conversion

2010-09-15 Thread Petteri Tikander
---
 unit/test-sms.c |   17 +
 1 files changed, 17 insertions(+), 0 deletions(-)

diff --git a/unit/test-sms.c b/unit/test-sms.c
index 0ff9cd5..96b9b50 100644
--- a/unit/test-sms.c
+++ b/unit/test-sms.c
@@ -1316,6 +1316,23 @@ static void test_sr_assembly()
 
g_assert(id == 42);
g_assert(delivered == TRUE);
+   g_assert(g_hash_table_size(sra-assembly_table) == 0);
+
+   /*
+* Send sms-message in the national address-format,
+* but receive in the international address-format.
+*/
+   sms_address_from_string(addr, 9911630);
+   status_report_assembly_add_fragment(sra, 42, addr, 4, time(NULL), 2);
+   status_report_assembly_add_fragment(sra, 42, addr, 5, time(NULL), 2);
+
+   g_assert(!status_report_assembly_report(sra, sr1, id, delivered));
+   g_assert(status_report_assembly_report(sra, sr2, id, delivered));
+
+   g_assert(id == 42);
+   g_assert(delivered == TRUE);
+   g_assert(g_hash_table_size(sra-assembly_table) == 0);
+
status_report_assembly_free(sra);
 }
 
-- 
1.6.3.3


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


[RFC PATCH 1/2] smsutil: national to international conversion in status report

2010-09-15 Thread Petteri Tikander
---
 src/smsutil.c |   70 
 1 files changed, 55 insertions(+), 15 deletions(-)

diff --git a/src/smsutil.c b/src/smsutil.c
index 26c7951..2d47289 100644
--- a/src/smsutil.c
+++ b/src/smsutil.c
@@ -2826,14 +2826,18 @@ gboolean status_report_assembly_report(struct 
status_report_assembly *assembly,
unsigned int offset = status_report-status_report.mr / 32;
unsigned int bit = 1  (status_report-status_report.mr % 32);
struct id_table_node *node = NULL;
-   const char *straddr;
+   const char *straddr, *sent_addr;
+   struct sms_address addr;
GHashTable *id_table;
gpointer key, value;
gboolean delivered;
-   GHashTableIter iter;
+   GHashTableIter iter_addr, iter;
gboolean pending;
int i;
unsigned int msg_id;
+   unsigned int n_digits;
+   unsigned int len_sent_addr;
+   unsigned int len_rec_addr;
 
/* We ignore temporary or tempfinal status reports */
if (sr_st_to_delivered(status_report-status_report.st,
@@ -2841,20 +2845,54 @@ gboolean status_report_assembly_report(struct 
status_report_assembly *assembly,
return FALSE;
 
straddr = sms_address_to_string(status_report-status_report.raddr);
-   id_table = g_hash_table_lookup(assembly-assembly_table, straddr);
 
-   /* key (receiver address) does not exist in assembly */
-   if (id_table == NULL)
-   return FALSE;
+   g_hash_table_iter_init(iter_addr, assembly-assembly_table);
 
-   g_hash_table_iter_init(iter, id_table);
-   while (g_hash_table_iter_next(iter, key, value)) {
-   node = value;
+   /*
+* Go through all addresses. Each address can relate to
+* 1-n msg_ids.
+*/
+   while (g_hash_table_iter_next(iter_addr, (gpointer) sent_addr,
+   (gpointer) id_table)) {
+   /*
+* Some networks can change address to international format,
+* although address is sent in the national format.
+* So notify this special case by checking only
+* last six digits. If address contains less than six digits,
+* compare only existing digits.
+*/
+   if ((straddr[0] == '+')  (sent_addr[0] != '+')) {
+   len_sent_addr = strlen(sent_addr);
+   len_rec_addr = strlen(straddr);
+   n_digits = (len_sent_addr  6) ? 6 : len_sent_addr;
 
-   if (node-mrs[offset]  bit)
-   break;
+   if (strcmp(straddr[len_rec_addr - n_digits],
+   sent_addr[len_sent_addr - n_digits]))
+   continue;
+   }
+   /*
+* In other cases the whole number received in the status report
+* should match with the number originally sent.
+*/
+   else if (strcmp(straddr, sent_addr))
+   continue;
+
+   g_hash_table_iter_init(iter, id_table);
+   while (g_hash_table_iter_next(iter, key, value)) {
+   node = value;
+
+   if (node-mrs[offset]  bit)
+   break;
 
-   node = NULL;
+   node = NULL;
+   }
+
+   /*
+* Received address with MR matched with one of the stored
+* addresses and MR, so no need to continue searching.
+*/
+   if (node)
+   break;
}
 
/* Unable to find a message reference belonging to this address */
@@ -2881,6 +2919,8 @@ gboolean status_report_assembly_report(struct 
status_report_assembly *assembly,
 
msg_id = *(unsigned int *) key;
 
+   sms_address_from_string(addr, sent_addr);
+
if (pending == TRUE  node-deliverable == TRUE) {
/*
 * More status reports expected, and already received
@@ -2888,7 +2928,7 @@ gboolean status_report_assembly_report(struct 
status_report_assembly *assembly,
 */
sr_assembly_add_fragment_backup(
assembly-imsi, node,
-   status_report-status_report.raddr,
+   addr,
msg_id);
 
return FALSE;
@@ -2901,14 +2941,14 @@ gboolean status_report_assembly_report(struct 
status_report_assembly *assembly,
*out_id = msg_id;
 
sr_assembly_remove_fragment_backup(assembly-imsi,
-   status_report-status_report.raddr,
+   addr,
msg_id);
 

RE: [PATCH 0/1] stk: Handle send ss proactive command

2010-09-15 Thread Jeevaka.Badrappan

Hi Yang,

 Below is the description:
 This patch is to handle send ss proactive command from SIM. 
 Currently when sending a supplementary service control string via
D-Bus, a series of functions would be called. For example, if we want to
send a call barring activatioin string via D-Bus, these 
 functions would be called:
ussd_initiate()-recognized_control_string()-cb_ss_control()-cb_ss_set
_lock_callback()-cb_ss_query_next_lock()-cb_ss_query_next_lock_callbac
k(). To handle send ss command  from SIM needs to follow the same way
as D-Bus, so my target is to try the best to reuse these functions.
However, currently these functions take the assumption that the calling
is from D-Bus. My 
 solution is to introduce a data structure named ofono_ss_req to
replace original DBusMessage * parameter. 
 Other main changes are to unify the return code of these functions and
handle them centrally.

 Comments are welcome!

Following the same control flow as normal case, requires rewriting some
of the existing functions to deal with both the cases like what you have
done now. Isn't it better to keep it separate? So that we won't end up
in introducing SAT specific handling in the normal use case also.

Proposed solution:

SS(eg: call forwarding, call barring) registers to the USSD by calling
__ofono_ussd_ssc_register with the service code, call back
function(normal_callback) and few other parameters. SS can also register
to the STK by calling __ofono_ussd_ssc_register with the service code,
call back function(stk_callback). normal_callback and stk_callback can
handle normal and stk use case respectively. More generic handling can
be moved to a separate function which normal_callback and stk_callback
functions can make use of. Also parsing/matching of the service strings
can be moved to utility. STK, USSD or anyother atoms can make use of the
parsing/matching(of service string) utility function.

Let me know your views on this.

Thanks and Regards,
jeevaka
___
ofono mailing list
ofono@ofono.org
http://lists.ofono.org/listinfo/ofono


[n900 PATCH 3/5] isimodem: remove the modem driver parts

2010-09-15 Thread Pekka . Pessi
From: Pekka Pessi ppe...@hamsa.research.nokia.com

The isimodem driver is now part of isigen (just like atmodem and atgen).
---
 drivers/isimodem/isimodem.c |  401 ---
 1 files changed, 0 insertions(+), 401 deletions(-)

diff --git a/drivers/isimodem/isimodem.c b/drivers/isimodem/isimodem.c
index e7cac50..10d681e 100644
--- a/drivers/isimodem/isimodem.c
+++ b/drivers/isimodem/isimodem.c
@@ -29,408 +29,11 @@
 #include string.h
 #include glib.h
 
-#include gisi/netlink.h
-#include gisi/client.h
-
 #define OFONO_API_SUBJECT_TO_CHANGE
 #include ofono/plugin.h
 #include ofono/log.h
-#include ofono/modem.h
-#include ofono/devinfo.h
-#include ofono/phonebook.h
-#include ofono/netreg.h
-#include ofono/voicecall.h
-#include ofono/sms.h
-#include ofono/cbs.h
-#include ofono/sim.h
-#include ofono/ussd.h
-#include ofono/ssn.h
-#include ofono/call-forwarding.h
-#include ofono/call-settings.h
-#include ofono/call-barring.h
-#include ofono/call-meter.h
-#include ofono/radio-settings.h
-#include ofono/gprs.h
-#include ofono/gprs-context.h
 
 #include isimodem.h
-#include isiutil.h
-#include mtc.h
-#include debug.h
-
-struct isi_data {
-   struct ofono_modem *modem;
-   char const *ifname;
-   GIsiModem *idx;
-   GIsiClient *client;
-   GPhonetNetlink *link;
-   GPhonetLinkState linkstate;
-   unsigned interval;
-   int reported;
-   ofono_bool_t online;
-   struct isi_cb_data *online_cbd;
-};
-
-static void report_powered(struct isi_data *isi, ofono_bool_t powered)
-{
-   if (powered != isi-reported)
-   ofono_modem_set_powered(isi-modem, isi-reported = powered);
-}
-
-static void report_online(struct isi_data *isi, ofono_bool_t online)
-{
-   struct isi_cb_data *cbd = isi-online_cbd;
-   ofono_modem_online_cb_t cb = cbd-cb;
-
-   isi-online_cbd = NULL;
-
-   if (isi-online == online)
-   CALLBACK_WITH_SUCCESS(cb, cbd-data);
-   else
-   CALLBACK_WITH_FAILURE(cb, cbd-data);
-
-   g_free(cbd);
-}
-
-static void set_power_by_mtc_state(struct isi_data *isi, int mtc_state)
-{
-   if (isi-online_cbd)
-   report_online(isi, mtc_state == MTC_NORMAL);
-
-   switch (mtc_state) {
-   case MTC_STATE_NONE:
-   case MTC_POWER_OFF:
-   case MTC_CHARGING:
-   case MTC_SELFTEST_FAIL:
-   report_powered(isi, 0);
-   break;
-
-   case MTC_RF_INACTIVE:
-   case MTC_NORMAL:
-   default:
-   report_powered(isi, 1);
-   }
-}
-
-static void mtc_state_ind_cb(GIsiClient *client,
-   const void *restrict data, size_t len,
-   uint16_t object, void *opaque)
-{
-   const unsigned char *msg = data;
-   struct isi_data *isi = opaque;
-
-   if (!msg) {
-   DBG(ISI client error: %d, g_isi_client_error(client));
-   return;
-   }
-
-   if (len  3 || msg[0] != MTC_STATE_INFO_IND)
-   return;
-
-   if (msg[2] == MTC_START) {
-   DBG(target modem state: %s (0x%02X),
-   mtc_modem_state_name(msg[1]), msg[1]);
-   } else if (msg[2] == MTC_READY) {
-   DBG(current modem state: %s (0x%02X),
-   mtc_modem_state_name(msg[1]), msg[1]);
-   set_power_by_mtc_state(isi, msg[1]);
-   }
-}
-
-static gboolean mtc_poll_query_cb(GIsiClient *client,
-   const void *restrict data, size_t len,
-   uint16_t object, void *opaque)
-{
-   const unsigned char *msg = data;
-   struct isi_data *isi = opaque;
-
-   if (!msg) {
-   const unsigned char req[] = {
-   MTC_STATE_QUERY_REQ, 0x00, 0x00
-   };
-
-   if (isi-linkstate != PN_LINK_UP)
-   return TRUE;
-
-   isi-interval *= 2;
-   if (isi-interval = 20)
-   isi-interval = 20;
-
-   g_isi_request_make(client, req, sizeof(req),
-   isi-interval,
-   mtc_poll_query_cb, opaque);
-
-   return TRUE;
-   }
-
-   if (len  3 || msg[0] != MTC_STATE_QUERY_RESP)
-   return FALSE;
-
-   g_isi_subscribe(client, MTC_STATE_INFO_IND, mtc_state_ind_cb, opaque);
-
-   DBG(current modem state: %s (0x%02X),
-   mtc_modem_state_name(msg[1]), msg[1]);
-   DBG(target modem state: %s (0x%02X),
-   mtc_modem_state_name(msg[2]), msg[2]);
-
-   if (msg[1] == msg[2])
-   set_power_by_mtc_state(isi, msg[1]);
-
-   return TRUE;
-}
-
-static gboolean mtc_query_cb(GIsiClient *client,
-   const void *restrict data, size_t len,
-   uint16_t object, void *opaque)
-{
-   const unsigned char *msg = data;
-   

[n900 PATCH 1/5] Include isimodem sources always in dist

2010-09-15 Thread Pekka . Pessi
From: Pekka Pessi ppe...@hamsa.research.nokia.com

---
 Makefile.am |   14 ++
 1 files changed, 10 insertions(+), 4 deletions(-)

diff --git a/Makefile.am b/Makefile.am
index 802e94b..79ef4e4 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -94,9 +94,7 @@ if DATAFILES
 conf_DATA += plugins/modem.conf
 endif
 
-if ISIMODEM
-builtin_modules += isimodem
-builtin_sources += $(gisi_sources) \
+isimodem_sources = $(gisi_sources) \
drivers/isimodem/isimodem.h \
drivers/isimodem/isimodem.c \
drivers/isimodem/mtc.h \
@@ -130,8 +128,14 @@ builtin_sources += $(gisi_sources) \
drivers/isimodem/gprs-context.c \
drivers/isimodem/gpds.h
 
+usbpn_sources = plugins/usbpnmodem.c
+
+if ISIMODEM
+builtin_modules += isimodem
+builtin_sources += $(isimodem_sources)
+
 builtin_modules += usbpnmodem
-builtin_sources += plugins/usbpnmodem.c
+builtin_sources += $(usbpn_sources)
 endif
 
 if ATMODEM
@@ -377,6 +381,8 @@ endif
 conf_files = src/ofono.conf plugins/modem.conf
 
 EXTRA_DIST = src/genbuiltin plugins/example_history.c $(doc_files) \
+   $(isimodem_sources) \
+   $(usbpn_sources) \
$(test_scripts) $(conf_files) $(udev_files)
 
 dist_man_MANS = doc/ofonod.8
-- 
1.7.0.4

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


[n900 PATCH 5/5] n900maemo: modem driver plugin for N900 with Maemo

2010-09-15 Thread Pekka . Pessi
From: Pekka Pessi ppe...@hamsa.research.nokia.com

This modem plugin is used on N900 running Maemo userspace already
controlling the phonet link and the N900 modem (csd and sscd).

The plugin uses the isigen driver for the N900 internal modem.

The n900maemo is compiled (while the normal n900 modem driver is
disabled) if ofono is configured with with --enable-n900modem option.
---
 Makefile.am |9 +
 configure.ac|5 +++
 plugins/n900maemo.c |   99 +++
 3 files changed, 113 insertions(+), 0 deletions(-)
 create mode 100644 plugins/n900maemo.c

diff --git a/Makefile.am b/Makefile.am
index d643ca8..23f0edb 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -132,6 +132,8 @@ isigen_sources = plugins/isigen.c
 
 n900_sources = plugins/n900.c plugins/n900gpio.h plugins/n900gpio.c
 
+n900maemo_sources = plugins/n900maemo.c
+
 if ISIMODEM
 builtin_modules += isimodem
 builtin_sources += $(isimodem_sources)
@@ -139,8 +141,14 @@ builtin_sources += $(isimodem_sources)
 builtin_modules += isigen
 builtin_sources += $(isigen_sources)
 
+if !N900MAEMO
 builtin_modules += n900
 builtin_sources += $(n900_sources)
+else
+builtin_modules += n900maemo
+builtin_sources += $(n900maemo_sources)
+endif
+
 endif
 
 if ATMODEM
@@ -389,6 +397,7 @@ EXTRA_DIST = src/genbuiltin plugins/example_history.c 
$(doc_files) \
$(isimodem_sources) \
$(isigen_sources) \
$(n900_sources) \
+   $(n900maemo_sources) \
$(test_scripts) $(conf_files) $(udev_files)
 
 dist_man_MANS = doc/ofonod.8
diff --git a/configure.ac b/configure.ac
index bd1dacb..c79a88b 100644
--- a/configure.ac
+++ b/configure.ac
@@ -140,6 +140,11 @@ AC_ARG_ENABLE(isimodem, 
AC_HELP_STRING([--disable-isimodem],
[enable_isimodem=${enableval}])
 AM_CONDITIONAL(ISIMODEM, test ${enable_isimodem} != no)
 
+AC_ARG_ENABLE(n900maemo, AC_HELP_STRING([--enable-n900maemo],
+   [Enable support for N900 running Maemo]),
+   [enable_n900maemo=${enableval}])
+AM_CONDITIONAL(N900MAEMO, test ${enable_n900maemo} = yes)
+
 AC_ARG_ENABLE(atmodem, AC_HELP_STRING([--disable-atmodem],
[disable ETSI AT modem support]),
[enable_atmodem=${enableval}])
diff --git a/plugins/n900maemo.c b/plugins/n900maemo.c
new file mode 100644
index 000..4728edb
--- /dev/null
+++ b/plugins/n900maemo.c
@@ -0,0 +1,99 @@
+/*
+ * This file is part of oFono - Open Source Telephony
+ *
+ * Copyright (C) 2010 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 stdio.h
+#include errno.h
+#include stdlib.h
+#include string.h
+#include glib.h
+
+#include gisi/client.h
+#include gisi/netlink.h
+
+#define OFONO_API_SUBJECT_TO_CHANGE
+#include ofono/plugin.h
+#include ofono/log.h
+#include ofono/modem.h
+
+#include drivers/isimodem/isimodem.h
+#include drivers/isimodem/debug.h
+
+static GPhonetNetlink *link;
+
+/*
+ * Add or remove phonet0 interface is added/removed
+ */
+static void phonet0_status_cb(GIsiModem *idx,
+   GPhonetLinkState st,
+   char const ifname[],
+   void *data)
+{
+   struct ofono_modem *modem;
+   int error;
+
+   if (strcmp(phonet0, ifname))
+   return;
+
+   DBG(Phonet link %s (%u) is %s,
+   ifname, g_isi_modem_index(idx),
+   st == PN_LINK_REMOVED ? removed :
+   st == PN_LINK_DOWN ? down : up);
+
+   if (st == PN_LINK_REMOVED)
+   return;
+
+   if (g_pn_netlink_by_modem(idx)) {
+   DBG(Modem for interface %s already exists, ifname);
+   return;
+   }
+
+   modem = ofono_modem_create(n900, isigen);
+   if (!modem)
+   return;
+
+   ofono_modem_set_string(modem, Interface, ifname);
+
+   if (ofono_modem_register(modem) == 0)
+   DBG(Done regging modem %s, ofono_modem_get_path(modem));
+   else
+   ofono_modem_remove(modem);
+}
+
+static int 

[n900 PATCH 2/5] isigen: generic modem driver plugin for isimodems

2010-09-15 Thread Pekka . Pessi
From: Pekka Pessi ppe...@hamsa.research.nokia.com

The new isigen modem driver replaces the uspnmodem plugin and the
generic isimodem driver.
---
 Makefile.am  |8 +-
 plugins/isigen.c |  518 ++
 plugins/usbpnmodem.c |  104 --
 3 files changed, 522 insertions(+), 108 deletions(-)
 create mode 100644 plugins/isigen.c
 delete mode 100644 plugins/usbpnmodem.c

diff --git a/Makefile.am b/Makefile.am
index 79ef4e4..aca5d1b 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -128,14 +128,14 @@ isimodem_sources = $(gisi_sources) \
drivers/isimodem/gprs-context.c \
drivers/isimodem/gpds.h
 
-usbpn_sources = plugins/usbpnmodem.c
+isigen_sources = plugins/isigen.c
 
 if ISIMODEM
 builtin_modules += isimodem
 builtin_sources += $(isimodem_sources)
 
-builtin_modules += usbpnmodem
-builtin_sources += $(usbpn_sources)
+builtin_modules += isigen
+builtin_sources += $(isigen_sources)
 endif
 
 if ATMODEM
@@ -382,7 +382,7 @@ conf_files = src/ofono.conf plugins/modem.conf
 
 EXTRA_DIST = src/genbuiltin plugins/example_history.c $(doc_files) \
$(isimodem_sources) \
-   $(usbpn_sources) \
+   $(isigen_sources) \
$(test_scripts) $(conf_files) $(udev_files)
 
 dist_man_MANS = doc/ofonod.8
diff --git a/plugins/isigen.c b/plugins/isigen.c
new file mode 100644
index 000..1439a49
--- /dev/null
+++ b/plugins/isigen.c
@@ -0,0 +1,518 @@
+/*
+ * This file is part of oFono - Open Source Telephony
+ *
+ * Copyright (C) 2009 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 stdio.h
+#include errno.h
+#include stdlib.h
+#include string.h
+#include glib.h
+
+#include gisi/netlink.h
+#include gisi/client.h
+
+#define OFONO_API_SUBJECT_TO_CHANGE
+#include ofono/plugin.h
+#include ofono/log.h
+#include ofono/modem.h
+#include ofono/devinfo.h
+#include ofono/phonebook.h
+#include ofono/netreg.h
+#include ofono/voicecall.h
+#include ofono/sms.h
+#include ofono/cbs.h
+#include ofono/sim.h
+#include ofono/ussd.h
+#include ofono/ssn.h
+#include ofono/call-forwarding.h
+#include ofono/call-settings.h
+#include ofono/call-barring.h
+#include ofono/call-meter.h
+#include ofono/radio-settings.h
+#include ofono/gprs.h
+#include ofono/gprs-context.h
+
+#include drivers/isimodem/isimodem.h
+#include drivers/isimodem/isiutil.h
+#include drivers/isimodem/mtc.h
+#include drivers/isimodem/debug.h
+
+struct isi_data {
+   struct ofono_modem *modem;
+   char const *ifname;
+   GIsiModem *idx;
+   GIsiClient *client;
+   GPhonetNetlink *link;
+   GPhonetLinkState linkstate;
+   unsigned interval;
+   int reported;
+   ofono_bool_t online;
+   struct isi_cb_data *online_cbd;
+};
+
+static void report_powered(struct isi_data *isi, ofono_bool_t powered)
+{
+   if (powered != isi-reported)
+   ofono_modem_set_powered(isi-modem, isi-reported = powered);
+}
+
+static void report_online(struct isi_data *isi, ofono_bool_t online)
+{
+   struct isi_cb_data *cbd = isi-online_cbd;
+   ofono_modem_online_cb_t cb = cbd-cb;
+
+   isi-online_cbd = NULL;
+
+   if (isi-online == online)
+   CALLBACK_WITH_SUCCESS(cb, cbd-data);
+   else
+   CALLBACK_WITH_FAILURE(cb, cbd-data);
+
+   g_free(cbd);
+}
+
+static void set_power_by_mtc_state(struct isi_data *isi, int mtc_state)
+{
+   if (isi-online_cbd)
+   report_online(isi, mtc_state == MTC_NORMAL);
+
+   switch (mtc_state) {
+   case MTC_STATE_NONE:
+   case MTC_POWER_OFF:
+   case MTC_CHARGING:
+   case MTC_SELFTEST_FAIL:
+   report_powered(isi, 0);
+   break;
+
+   case MTC_RF_INACTIVE:
+   case MTC_NORMAL:
+   default:
+   report_powered(isi, 1);
+   }
+}
+
+static void mtc_state_ind_cb(GIsiClient *client,
+   const void *restrict data, size_t len,
+   uint16_t object, void *opaque)
+{
+   const unsigned char *msg = data;
+   struct isi_data *isi = opaque;
+
+   if (!msg) {
+   DBG(ISI 

RE: [PATCH 0/1] stk: Handle send ss proactive command

2010-09-15 Thread Gu, Yang
Hi jeevaka,



-Original Message-
From: ofono-boun...@ofono.org [mailto:ofono-boun...@ofono.org] On Behalf Of
jeevaka.badrap...@elektrobit.com
Sent: Wednesday, September 15, 2010 8:12 PM
To: ofono@ofono.org
Subject: RE: [PATCH 0/1] stk: Handle send ss proactive command


Hi Yang,

 Below is the description:
 This patch is to handle send ss proactive command from SIM.
 Currently when sending a supplementary service control string via
D-Bus, a series of functions would be called. For example, if we want to
send a call barring activatioin string via D-Bus, these
 functions would be called:
ussd_initiate()-recognized_control_string()-cb_ss_control()-cb_ss_set
_lock_callback()-cb_ss_query_next_lock()-cb_ss_query_next_lock_callbac
k(). To handle send ss command  from SIM needs to follow the same way
as D-Bus, so my target is to try the best to reuse these functions.
However, currently these functions take the assumption that the calling
is from D-Bus. My
 solution is to introduce a data structure named ofono_ss_req to
replace original DBusMessage * parameter.
 Other main changes are to unify the return code of these functions and
handle them centrally.

 Comments are welcome!

Following the same control flow as normal case, requires rewriting some
of the existing functions to deal with both the cases like what you have
done now. Isn't it better to keep it separate? So that we won't end up
in introducing SAT specific handling in the normal use case also.

Proposed solution:

SS(eg: call forwarding, call barring) registers to the USSD by calling
__ofono_ussd_ssc_register with the service code, call back
function(normal_callback) and few other parameters. SS can also register
to the STK by calling __ofono_ussd_ssc_register with the service code,
call back function(stk_callback). normal_callback and stk_callback can
handle normal and stk use case respectively. More generic handling can
be moved to a separate function which normal_callback and stk_callback
functions can make use of. Also parsing/matching of the service strings
can be moved to utility. STK, USSD or anyother atoms can make use of the
parsing/matching(of service string) utility function.

Let me know your views on this.

Thank you for the comments!

But if we handle stk logic in separate functions, we would have to duplicate:
In ussd.c, 
recognized_control_string()
recognized_passwd_change_string()
ussd-ss_control_list
in ss.c:
ss_ss_control() and other registered functions  // We may extract most of 
logic as a utility function, but we have to set the pending or the indication 
for stk request
Various call back functions

I don't want to duplicate all these functions for stk, especially the two 
functions in ussd.c. Thinking about the case we may support at server (oFono 
has the ability to parse incoming at command, talk with modem in its specific 
language, at command or proprietary protocol, and send back the response) 
someday, you may need to duplicate all these functions again for it. 
In my opinion, the request from D-Bus isn't so normal. Each atom provides a 
set of functions (services) that can be requested by others, either the request 
from D-Bus, or request from other atoms, such as stk and at server. Current 
functions take the assumption that all the requests are all from D-Bus. What I 
want to do is just to break this assumption, and my current solution is easy to 
be extended to support the at server case. 
What do you think about?

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


Re: [PATCH 1/4] Internal and Driver API changes for Send USSD

2010-09-15 Thread Denis Kenzior
Hi Jeevaka,

On 09/14/2010 04:23 PM, Jeevaka Badrappan wrote:
 ---
  drivers/atmodem/ussd.c  |  115 
 ---
  drivers/isimodem/ussd.c |   42 +++--
  include/ussd.h  |8 ++-
  src/ussd.c  |   39 +---
  4 files changed, 115 insertions(+), 89 deletions(-)
 

This patch has been applied, but refactored heavily afterward.

 + struct ussd_data *data = ofono_ussd_get_data(ussd);
   GAtResultIter iter;
   int status;
   int dcs;
 - const char *content;
 - char *converted = NULL;
 - gboolean udhi;
 + const char *content = NULL;
   enum sms_charset charset;
 - gboolean compressed;
 - gboolean iso639;
 + unsigned char msg[160];
 + const unsigned char *msg_ptr = NULL;
 + unsigned char *converted = NULL;
 + long written;
 + long msg_len = 0;

Please avoid initializing variables unless absolutely necessary.  This
actually hid some serious issues in the code which I had to fix.  In the
future I will not be so nice and simply reject such patches.

 + switch (charset) {
 + case SMS_CHARSET_7BIT:
 + if (data-charset == AT_UTIL_CHARSET_GSM)
 + msg_ptr = pack_7bit_own_buf((const guint8 *) content,
 + strlen(content), 0, TRUE, msg_len, 0, 
 msg);
 + else if (data-charset == AT_UTIL_CHARSET_UTF8)
 + ussd_encode(content, msg_len, msg);
 + else if (data-charset == AT_UTIL_CHARSET_UCS2) {
 + msg_ptr = decode_hex_own_buf(content, -1, msg_len, 0, 
 msg);

Please watch out for buffer overflows and make sure to run valgrind and
test all your code.  msg in this case was too small to contain the
decoded UCS2 information (up to 182 * 2 characters)

 + snprintf(buf, sizeof(buf), AT+CUSD=1,\%.*s\,%d,
 + (int) written, unpacked_buf, dcs);
 + } else {
 + converted = encode_hex_own_buf(pdu, len, 0, coded_buf);

Same thing here, you were overflowing the coded_buf

 + if (!converted)
 + goto error;
 +
 + snprintf(buf, sizeof(buf), AT+CUSD=1,\%.*s\,%d,
 + strlen(converted), converted, dcs);

and overflowing buf as well

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


Re: [PATCH 2/4] Add __ofono_ussd_initiate internal api for Sending USSD

2010-09-15 Thread Denis Kenzior
Hi Jeevaka,

On 09/14/2010 04:31 PM, Jeevaka Badrappan wrote:
 ---
  src/ofono.h |8 +
  src/ussd.c  |  101 
 ---
  2 files changed, 104 insertions(+), 5 deletions(-)

This patch has been applied, but simplified a bit afterward.

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


Re: [PATCH 3/4] stk: Handling of Send USSD proactive command

2010-09-15 Thread Denis Kenzior
Hi Jeevaka,

On 09/14/2010 04:49 PM, Jeevaka Badrappan wrote:
 ---
  src/stk.c |  173 
 -
  1 files changed, 172 insertions(+), 1 deletions(-)


This patch has been applied, but refactored afterward.

 + rsp.result.type = STK_RESULT_TYPE_USSD_RETURN_ERROR;
 + rsp.result.additional = (unsigned char *) error;
 + rsp.result.additional_len = 1;

This part made no sense to me, why are we sending our internal error
enum to the SIM?

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


Re: [n900 PATCH 2/5] isigen: generic modem driver plugin for isimodems

2010-09-15 Thread Rémi Denis-Courmont

   Hello

Please. Don't put netlink *settings* in oFono. This kills the whole idea of
having a common socket stack that can be shared by several processes. If
you want to run against the Maemo kernel, then you have phonet-utils and
sscd taking care of that anyway. As for the Meego kernel, it should get a
up-to-date and patched Phonet stack as needed.

-- 
Rémi Denis-Courmont
http://www.remlab.net
http://fi.linkedin.com/in/remidenis

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


Re: [PATCH] phonesim: simulate language notification in sim app

2010-09-15 Thread Denis Kenzior
Hi Jeevaka,

On 09/14/2010 05:27 PM, Jeevaka Badrappan wrote:
 ---
  src/qsimcommand.cpp|   11 
  src/simapplication.cpp |   68 
 
  src/simapplication.h   |2 +
  3 files changed, 81 insertions(+), 0 deletions(-)
 
 diff --git a/src/qsimcommand.cpp b/src/qsimcommand.cpp
 index 9a9a169..9746592 100644
 --- a/src/qsimcommand.cpp
 +++ b/src/qsimcommand.cpp
 @@ -3280,6 +3280,17 @@ QByteArray QSimCommand::toPdu( 
 QSimCommand::ToPduOptions options ) const
  }
  break;
  
 +case LanguageNotification:
 +{
 +if ( qualifier  0x01 ) {
 +data += (char)0xAD;
 +data += (char)0x02;
 +data += (char)0x73;
 +data += (char)0x65;
 +}
 +}
 +break;
 +

I'd really prefer that this wasn't completely hard-coded.  Can we make
an enum of some sort, or even use a QString (null means no language
object included)

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


[PATCH] set phonesim character set to GSM

2010-09-15 Thread Jeevaka Badrappan
---
 plugins/phonesim.c |2 ++
 1 files changed, 2 insertions(+), 0 deletions(-)

diff --git a/plugins/phonesim.c b/plugins/phonesim.c
index d3caa20..7aa59ff 100644
--- a/plugins/phonesim.c
+++ b/plugins/phonesim.c
@@ -253,6 +253,8 @@ static int phonesim_enable(struct ofono_modem *modem)
data-chat = NULL;
}
 
+   g_at_chat_send(data-chat, AT+CSCS=\GSM\, none_prefix, NULL, NULL, 
NULL);
+
return 0;
 }
 
-- 
1.7.0.4

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


Re: [n900 PATCH 2/5] isigen: generic modem driver plugin for isimodems

2010-09-15 Thread Pekka Pessi
Hi Rémi,

2010/9/15 Rémi Denis-Courmont r...@remlab.net:
 Please. Don't put netlink *settings* in oFono. This kills the whole idea of
 having a common socket stack that can be shared by several processes. If
 you want to run against the Maemo kernel, then you have phonet-utils and
 sscd taking care of that anyway. As for the Meego kernel, it should get a
 up-to-date and patched Phonet stack as needed.

I'm all for including settings as udev rules and driving the plugins
from udev. That is the goal if and when we have up-to-date kernel, but
we are not there yet.

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


Re: [n900 PATCH 2/5] isigen: generic modem driver plugin for isimodems

2010-09-15 Thread Rémi Denis-Courmont

On Thu, 16 Sep 2010 00:27:00 +0300, Pekka Pessi ppe...@gmail.com wrote:
 2010/9/15 Rémi Denis-Courmont r...@remlab.net:
 Please. Don't put netlink *settings* in oFono. This kills the whole idea
 of having a common socket stack that can be shared by several processes.
 If you want to run against the Maemo kernel, then you have phonet-utils
 and sscd taking care of that anyway. As for the Meego kernel, it should
 get a up-to-date and patched Phonet stack as needed.
 
 I'm all for including settings as udev rules and driving the plugins
 from udev.

Right.

 That is the goal if and when we have up-to-date kernel, but
 we are not there yet.

I don't see the point of adding temporary cruft to the main oFono
repository then.

-- 
Rémi Denis-Courmont
http://www.remlab.net
http://fi.linkedin.com/in/remidenis

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