Re: [PATCH 4/4] TODO: Marking the Barred Dialing task as done

2010-12-06 Thread Sankar
Hi Jeevaka,

I have a few comments on the support of FDN and BDN in Ofono. Can you please
clarify.

Thanks,
Sankar.

On Mon, Oct 25, 2010 at 5:04 PM, Jeevaka Badrappan 
jeevaka.badrap...@elektrobit.com wrote:

 ---
  TODO |7 ---
  doc/features.txt |5 +
  2 files changed, 5 insertions(+), 7 deletions(-)

 diff --git a/TODO b/TODO
 index d9a6580..ad96241 100644
 --- a/TODO
 +++ b/TODO
 @@ -110,13 +110,6 @@ SMS
  SIM / SIM File system
  =

 -- Barred Dialing numbers support.  BDN will not be supported by oFono.
 -  If BDN service enabled SIM is used, oFono will go into emergency mode.
 -
 -  Priority: Low
 -  Complexity: C2
 -  Owner: Jeevaka Badrappan jeevaka.badrap...@elektrobit.com
 -
  - Read / Write EFcfis.  Call forwarding settings can be bootstrapped on
 the
   SIM for faster notification of the user that call forwarding is active.
   These settings are stored in EFcfis.  oFono should read these settings
 and
 diff --git a/doc/features.txt b/doc/features.txt
 index 3524e79..12be037 100644
 --- a/doc/features.txt
 +++ b/doc/features.txt
 @@ -135,3 +135,8 @@ SIM
   check if FDN support is allocated and enabled in the SIM.  If enabled,
   oFono halts the SIM initialization procedure and the modem remains in the
   PRESIM state.  In this state oFono will only allow emergency calls.


Is there a way for the clients to enable or disable the Fixed Dialling? I
assume they should be able to do this by using the dbus calls,
LockPin/UnlockPin.  Is there a way to store the FDN numbers in the sim
card? How does ofono validate the request to be passed to the network when
FDN is enabled? Looks like as per the current implementation of FDN, only
emergency calls are allowed. But as per the 3GPP standards, calls shall be
allowed to any number (irrespective of emergency no) that is part of the FDN
list.

If the modem remains in PRESIM State, how does the mobile receive the
Incoming Calls or SMS? As per my understanding FDN applies in the uplink and
not in the downlink.
Please clarify if my understanding is wrong.

 +
 +- Barred Dialing support.  oFono reads the necessary bits from the SIM to
 +  check if BDN support is allocated and enabled in the SIM.  If enabled,
 +  oFono halts the SIM initialization procedure and the modem remains in
 the
 +  PRESIM state.  In this state oFono will only allow emergency calls.

I have similar doubts for BDN also.

 --


Best Regards,
Sankar.

 1.7.0.4

 ___
 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 4/4] TODO: Marking the Barred Dialing task as done

2010-12-06 Thread Jeevaka.Badrappan
Hi Sankar,
 
 Then as per your email, the support provided in Ofono seems to be
limited. If there is no enable or disable is allowed,
 I am not sure, how we can we have a card in which FDN enabled, which
will force the ofono to enter presim state. Unless there is no
 option to disable at, forever with that sim card, the phone will be in
presim state,leading to only placing of emergency calls.

Support for disabling FDN was discussed earlier. Denis/Pessi could you
confirm what was the decision made on FDN disable support?

 Thanks for confirming. Then in this case, are we not forcing the
mobile to go in a state, where if FDN is already enabled in the sim
card( may be from a different phone), 
 user allowed with no option rather than making an emergency call. 

Yes, we are forcing the mobile into presim state where only emergency
calls are allowed. We have already discussed this many times in irc and
its been agreed that only emergency calls are allowed when FDN or BDN
enabled SIM used.

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


[PATCH] Mark ofono/*.h symbolink links as built sources

2010-12-06 Thread Rémi Denis-Courmont
This forces automake/make to build them first if needed (as before).
But it avoids marking every single header as a dependency of every
single object. Thus we do not need a bogus full rebuild of the tree
everytime a header is added.
---
 Makefile.am |6 +++---
 1 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/Makefile.am b/Makefile.am
index a4c47e8..cdb3166 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -326,7 +326,9 @@ src_ofonod_LDADD = $(builtin_libadd) @GLIB_LIBS@ 
@DBUS_LIBS@ @CAPNG_LIBS@ -ldl
 src_ofonod_LDFLAGS = -Wl,--export-dynamic \
-Wl,--version-script=$(srcdir)/src/ofono.ver
 
-CLEANFILES = src/builtin.h $(local_headers) $(rules_DATA)
+BUILT_SOURCES = $(local_headers)
+
+CLEANFILES = src/builtin.h $(BUILT_SOURCES) $(rules_DATA)
 
 plugindir = $(libdir)/ofono/plugins
 
@@ -512,8 +514,6 @@ src/builtin.h: src/genbuiltin $(builtin_sources)
 plugins/%.rules:
$(AM_V_GEN)cp $(srcdir)/$(subst 97-,,$@) $@
 
-$(src_ofonod_OBJECTS) $(unit_objects): $(local_headers)
-
 include/ofono/version.h: include/version.h
$(AM_V_at)$(MKDIR_P) include/ofono
$(AM_V_GEN)$(LN_S) $(abs_top_builddir)/$ $@
-- 
1.7.1

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


Re: [PATCH 1/3] plugins: Implementation of Network Time plugin

2010-12-06 Thread Rémi Denis-Courmont
On Saturday 04 December 2010 02:02:56 ext Marcel Holtmann, you wrote:
 Hi Aki,
 
  The only thing I would change here are the names. It's customary to
  avoid repeating the interface name in the signal or method, but of
  course the problem here is then what to call these. Maybe just Get()
  and Changed()? ;-)
  
  Oh, and you probably should have included a short description of what
  this plugin is for (I forgot to mention this before).
  
  The thinking behind this plugin is that timed in MeeGo wants to get
  the information, and a D-Bus API is a fine way to accomplish this.
 
 where is this timed running? I prefer the plugin just send a D-Bus
 message to the timed directly instead of a Get/Changed API kind of
 thing.

AFAIK, Get/Changed is the simplest functional way to avoid races, where say 
oFono would receive the time before timed can process it. The getter also 
enables implementing trivial a tool à la ntpdate.

-- 
Rémi Denis-Courmont
Nokia Devices RD, Maemo Software, Helsinki
___
ofono mailing list
ofono@ofono.org
http://lists.ofono.org/listinfo/ofono


Re: [PATCH 1/3] plugins: Implementation of Network Time plugin

2010-12-06 Thread Rémi Denis-Courmont
Nitpicking...

On Friday 03 December 2010 11:47:26 ext Antti Paila, you wrote:
 diff --git a/plugins/nettime.c b/plugins/nettime.c
 new file mode 100644
 index 000..0f99bb1
 --- /dev/null
 +++ b/plugins/nettime.c
 @@ -0,0 +1,293 @@
 +/*
 + *
 + *  oFono - Open Source Telephony
 + *
 + *  Copyright (C) 2008-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 string.h
 +#include glib.h
 +
 +#define OFONO_API_SUBJECT_TO_CHANGE
 +#include ofono/plugin.h
 +#include ofono/log.h
 +#include ofono/nettime.h
 +#include ofono/types.h
 +#include gdbus.h
 +#include ofono.h
 +
 +#include common.h
 +
 +#define MAX_TIME_STR_LEN 128
 +#define TIME_FORMAT %FT%TZ
 +
 +
 +struct nettime_data {
 + struct ofono_network_time nw_time;
 + time_t received;
 +};
 +
 +static void nettime_register(struct ofono_nettime_context *);
 +
 +static gboolean encode_time_format(struct ofono_network_time *time,
 +  struct tm *tm)
 +{
 + if (time-year  0)
 + return FALSE;
 +
 + tm-tm_year = time-year - 1900;
 + tm-tm_mon = time-mon - 1;
 + tm-tm_mday = time-mday;
 + tm-tm_hour = time-hour;
 + tm-tm_min = time-min;
 + tm-tm_sec = time-sec;
 + tm-tm_gmtoff = time-utcoff;
 + tm-tm_isdst = time-dst;
 +
 + return TRUE;
 +}
 +
 +static time_t get_monotonic_time()
 +{
 + struct timespec ts;
 + clock_gettime(CLOCK_MONOTONIC, ts);
 + return ts.tv_sec;
 +}
 +
 +static struct tm *refresh_nw_time(struct tm *nw_time,
 + time_t received)
 +{
 + time_t now, new_nw_time;
 +
 + now = get_monotonic_time();
 + new_nw_time = timegm(nw_time) + now - received;
 + return gmtime(new_nw_time);
 +}

Brrr, the result is somewhere in static data. This can cause quite confusing 
behaviour if/when the code is changed. I would much rather use gmtime_r().

That being said, wouldn't it be far simpler to return a second timestamp 
instead of a broken-down time structure over D-Bus? Eventually, timed/whatever 
will want a timestamp anyway to set the system clock or whatever else it wants 
to do with the NITZ.

 +static int fill_time_changed_signal(DBusMessage *signal,
 + struct nettime_data *ntd)
 +{
 + DBusMessageIter iter, iter_array;
 + int time_available;
 + char buf[MAX_TIME_STR_LEN];
 + struct tm time_tm, *new_time_tm;
 + const char *str = buf;
 +
 + dbus_message_iter_init_append(signal, iter);
 + dbus_message_iter_open_container(iter,
 + DBUS_TYPE_ARRAY,
 + {sv},
 + iter_array);
 +
 + time_available = encode_time_format(ntd-nw_time, time_tm);
 + if (time_available != 0) {
 + new_time_tm = refresh_nw_time(time_tm, ntd-received);
 + strftime(buf, MAX_TIME_STR_LEN, TIME_FORMAT, new_time_tm);
 +
 + ofono_dbus_dict_append(iter_array,
 + DateAndTime,
 + DBUS_TYPE_STRING,
 + str);
 + }
 +
 + ofono_dbus_dict_append(iter_array,
 + Timezone,
 + DBUS_TYPE_INT32,
 + ntd-nw_time.utcoff);
 + ofono_dbus_dict_append(iter_array,
 + DST,
 + DBUS_TYPE_UINT32,
 + ntd-nw_time.dst);
 + dbus_message_iter_close_container(iter, iter_array);
 + return 0;
 +}

Are the time zone offset and the DST always available, but the current time 
not? This seems odd.

Passing the time over D-Bus may cause extra drift/imprecision than we already 
have. I wonder if it would make sense to provide not just the current time but 
both:
- the current time for trivial programs, and
- the system boot time (i.e. nw_time - received) for smarter programs;
  this value cannot drift.

 +static DBusMessage *create_time_changed_signal(
 + struct ofono_nettime_context *context)
 +{
 + DBusMessage *signal;
 + struct nettime_data *ntd = context-data;
 + const char *path = ofono_modem_get_path(context-modem);
 +
 + 

Fix issues in ofono_sim_get_phase and its usage

2010-12-06 Thread Jeevaka Badrappan
Hi,

 Following patch adds the missing OFONO_SIM_PHASE_UNKNOWN check in some
of the functions which uses ofono_sim_get_phase. Also fixed the issue
in ofono_get_sim_phase when the passed sim paramter is NULL. 
 
Jeevaka Badrappan (2):
  sim: fix minor issue in ofono_sim_get_phase
  simfs: Add unknown sim phase check

 src/sim.c   |2 +-
 src/simfs.c |9 -
 2 files changed, 9 insertions(+), 2 deletions(-)

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


[PATCH 1/2] sim: fix minor issue in ofono_sim_get_phase

2010-12-06 Thread Jeevaka Badrappan
---
 src/sim.c |2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/src/sim.c b/src/sim.c
index c523982..6217a25 100644
--- a/src/sim.c
+++ b/src/sim.c
@@ -1914,7 +1914,7 @@ const char *ofono_sim_get_imsi(struct ofono_sim *sim)
 enum ofono_sim_phase ofono_sim_get_phase(struct ofono_sim *sim)
 {
if (sim == NULL)
-   return 0;
+   return OFONO_SIM_PHASE_UNKNOWN;
 
return sim-phase;
 }
-- 
1.7.0.4

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


[PATCH 2/2] simfs: Add unknown sim phase check

2010-12-06 Thread Jeevaka Badrappan
---
 src/simfs.c |9 -
 1 files changed, 8 insertions(+), 1 deletions(-)

diff --git a/src/simfs.c b/src/simfs.c
index 8e52f7b..617af14 100644
--- a/src/simfs.c
+++ b/src/simfs.c
@@ -554,7 +554,8 @@ static gboolean sim_fs_op_check_cached(struct sim_fs *fs)
enum ofono_sim_file_structure structure;
int record_length;
 
-   if (imsi == NULL || op-info_only == TRUE)
+   if (imsi == NULL || phase == OFONO_SIM_PHASE_UNKNOWN ||
+   op-info_only == TRUE)
return FALSE;
 
path = g_strdup_printf(SIM_CACHE_PATH, imsi, phase, op-id);
@@ -836,6 +837,9 @@ char *sim_fs_get_cached_image(struct sim_fs *fs, int id)
return NULL;
 
phase = ofono_sim_get_phase(fs-sim);
+   if (phase == OFONO_SIM_PHASE_UNKNOWN)
+   return NULL;
+
path = g_strdup_printf(SIM_IMAGE_CACHE_PATH, imsi, phase, id);
 
TFR(stat(path, st_buf));
@@ -907,6 +911,9 @@ void sim_fs_check_version(struct sim_fs *fs)
int len;
char *path;
 
+   if (imsi == NULL || phase == OFONO_SIM_PHASE_UNKNOWN)
+   return;
+
if (read_file(version, 1, SIM_CACHE_VERSION, imsi, phase) == 1)
if (version == SIM_FS_VERSION)
return;
-- 
1.7.0.4

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


[PATCH 01/14] test: fix bug in test-ss-control-cs

2010-12-06 Thread Gustavo F. Padovan
---
 test/test-ss-control-cs |2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/test/test-ss-control-cs b/test/test-ss-control-cs
index bf59789..e04a4a0 100755
--- a/test/test-ss-control-cs
+++ b/test/test-ss-control-cs
@@ -29,7 +29,7 @@ if __name__ == __main__:
 
 cs.connect_to_signal(PropertyChanged, property_changed)
 
-   ss = dbus.Interface(bus.get_object('org.ofono', modems[0]),
+   ss = dbus.Interface(bus.get_object('org.ofono', modems[0][0]),

'org.ofono.SupplementaryServices')
 
print_properties(cs)
-- 
1.7.3.2

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


[PATCH 05/14] include: add CNAP fields and defines

2010-12-06 Thread Gustavo F. Padovan
---
 include/types.h |3 +++
 src/common.h|7 +++
 2 files changed, 10 insertions(+), 0 deletions(-)

diff --git a/include/types.h b/include/types.h
index ba2481f..de15437 100644
--- a/include/types.h
+++ b/include/types.h
@@ -77,6 +77,7 @@ struct ofono_error {
 };
 
 #define OFONO_MAX_PHONE_NUMBER_LENGTH 20
+#define OFONO_MAX_CALLER_NAME_LENGTH 80
 
 struct ofono_phone_number {
char number[OFONO_MAX_PHONE_NUMBER_LENGTH + 1];
@@ -90,7 +91,9 @@ struct ofono_call {
int status;
ofono_bool_t mpty;
struct ofono_phone_number phone_number;
+   char name[OFONO_MAX_CALLER_NAME_LENGTH + 1];
int clip_validity;
+   int cnap_validity;
 };
 
 struct ofono_network_time {
diff --git a/src/common.h b/src/common.h
index 8b5798a..c8e7070 100644
--- a/src/common.h
+++ b/src/common.h
@@ -48,6 +48,13 @@ enum clip_validity {
CLIP_VALIDITY_NOT_AVAILABLE = 2
 };
 
+/* 27.007 Section 7.30 */
+enum cnap_validity {
+   CNAP_VALIDITY_VALID = 0,
+   CNAP_VALIDITY_WITHHELD = 1,
+   CNAP_VALIDITY_NOT_AVAILABLE = 2
+};
+
 /* 27.007 Section 7.18 */
 enum call_status {
CALL_STATUS_ACTIVE = 0,
-- 
1.7.3.2

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


[PATCH 04/14] TODO: Add onwer to CNAP task

2010-12-06 Thread Gustavo F. Padovan
---
 TODO |1 +
 1 files changed, 1 insertions(+), 0 deletions(-)

diff --git a/TODO b/TODO
index 6cf7202..290932e 100644
--- a/TODO
+++ b/TODO
@@ -249,6 +249,7 @@ Supplementary Services
 
   Priority: Low
   Complexity: C2
+  Owner: Gustavo F Padovan pado...@profusion.mobi
 
 - User to User Signaling (UUS) support
 
-- 
1.7.3.2

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


[PATCH 06/14] voicecall: add support for CNAP

2010-12-06 Thread Gustavo F. Padovan
Enable oFono to get a info about the Calling Name.
---
 src/voicecall.c |   53 +
 1 files changed, 53 insertions(+), 0 deletions(-)

diff --git a/src/voicecall.c b/src/voicecall.c
index dbf3e9a..84d45f9 100644
--- a/src/voicecall.c
+++ b/src/voicecall.c
@@ -178,6 +178,17 @@ static const char *phone_and_clip_to_string(const struct 
ofono_phone_number *n,
return phone_number_to_string(n);
 }
 
+static const char *cnap_to_string(const char *name, int cnap_validity)
+{
+   if (cnap_validity == CNAP_VALIDITY_WITHHELD  !strlen(name))
+   return withheld;
+
+   if (cnap_validity == CNAP_VALIDITY_NOT_AVAILABLE)
+   return ;
+
+   return name;
+}
+
 static const char *time_to_str(const time_t *t)
 {
static char buf[128];
@@ -323,16 +334,24 @@ static void append_voicecall_properties(struct voicecall 
*v,
const char *status;
const char *callerid;
const char *timestr;
+   char buf[OFONO_MAX_CALLER_NAME_LENGTH + 1];
+   char *name;
ofono_bool_t mpty;
 
status = call_status_to_string(call-status);
callerid = phone_number_to_string(call-phone_number);
 
+   strncpy(buf, call-name, OFONO_MAX_CALLER_NAME_LENGTH);
+   buf[OFONO_MAX_CALLER_NAME_LENGTH] = '\0';
+   name = buf;
+
ofono_dbus_dict_append(dict, State, DBUS_TYPE_STRING, status);
 
ofono_dbus_dict_append(dict, LineIdentification,
DBUS_TYPE_STRING, callerid);
 
+   ofono_dbus_dict_append(dict, Name, DBUS_TYPE_STRING, name);
+
if (call-status == CALL_STATUS_ACTIVE ||
call-status == CALL_STATUS_HELD ||
(call-status == CALL_STATUS_DISCONNECTED 
@@ -723,6 +742,38 @@ static void voicecall_set_call_lineid(struct voicecall *v,
DBUS_TYPE_STRING, lineid_str);
 }
 
+static void voicecall_set_call_name(struct voicecall *v,
+   const char *name,
+   int cnap_validity)
+{
+   struct ofono_call *call = v-call;
+   DBusConnection *conn = ofono_dbus_get_connection();
+   const char *path;
+   const char *name_str;
+
+   if (!strcmp(call-name, name) 
+   call-cnap_validity == cnap_validity)
+   return;
+
+   /* For plugins that don't keep state, ignore */
+   if (call-cnap_validity == CNAP_VALIDITY_VALID 
+   cnap_validity == CNAP_VALIDITY_NOT_AVAILABLE)
+   return;
+
+   strncpy(call-name, name, OFONO_MAX_CALLER_NAME_LENGTH);
+   call-name[OFONO_MAX_CALLER_NAME_LENGTH] = '\0';
+   call-cnap_validity = cnap_validity;
+
+   path = voicecall_build_path(v-vc, call);
+
+   name_str = cnap_to_string(name, cnap_validity);
+
+   ofono_dbus_signal_property_changed(conn, path,
+   OFONO_VOICECALL_INTERFACE,
+   Name,
+   DBUS_TYPE_STRING, name_str);
+}
+
 static gboolean voicecall_dbus_register(struct voicecall *v)
 {
DBusConnection *conn = ofono_dbus_get_connection();
@@ -1838,6 +1889,8 @@ void ofono_voicecall_notify(struct ofono_voicecall *vc,
voicecall_set_call_status(l-data, call-status);
voicecall_set_call_lineid(l-data, call-phone_number,
call-clip_validity);
+   voicecall_set_call_name(l-data, call-name,
+   call-cnap_validity);
 
return;
}
-- 
1.7.3.2

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


[PATCH 07/14] doc: add Name property

2010-12-06 Thread Gustavo F. Padovan
---
 doc/voicecall-api.txt |5 +
 1 files changed, 5 insertions(+), 0 deletions(-)

diff --git a/doc/voicecall-api.txt b/doc/voicecall-api.txt
index f0ba316..a0242ab 100644
--- a/doc/voicecall-api.txt
+++ b/doc/voicecall-api.txt
@@ -87,6 +87,11 @@ Properties   string LineIdentification [readonly]
override category option was not provisioned for
the current subscriber.
 
+   string Name [readonly]
+
+   Contains the Name Identification information returned
+   by the network, if present.
+
boolean Multiparty [readonly]
 
Contains the indication if the voice call is part
-- 
1.7.3.2

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


[PATCH 08/14] atmodem: Add CNAP parsing to voicecall

2010-12-06 Thread Gustavo F. Padovan
---
 drivers/atmodem/voicecall.c |   47 +++
 1 files changed, 47 insertions(+), 0 deletions(-)

diff --git a/drivers/atmodem/voicecall.c b/drivers/atmodem/voicecall.c
index a2ee49d..41fd901 100644
--- a/drivers/atmodem/voicecall.c
+++ b/drivers/atmodem/voicecall.c
@@ -746,6 +746,51 @@ static void clip_notify(GAtResult *result, gpointer 
user_data)
}
 }
 
+static void cnap_notify(GAtResult *result, gpointer user_data)
+{
+   struct ofono_voicecall *vc = user_data;
+   struct voicecall_data *vd = ofono_voicecall_get_data(vc);
+   GAtResultIter iter;
+   const char *name;
+   int validity;
+   GSList *l;
+   struct ofono_call *call;
+
+   l = g_slist_find_custom(vd-calls, GINT_TO_POINTER(4),
+   at_util_call_compare_by_status);
+   if (l == NULL) {
+   ofono_error(CNAP for unknown call);
+   return;
+   }
+
+   g_at_result_iter_init(iter, result);
+
+   if (!g_at_result_iter_next(iter, +CNAP:))
+   return;
+
+   if (!g_at_result_iter_next_string(iter, name))
+   return;
+
+   if (strlen(name)  0)
+   validity = CNAP_VALIDITY_VALID;
+   else
+   validity = CNAP_VALIDITY_NOT_AVAILABLE;
+
+   /* If we have CNI validity field, override our guessed value */
+   g_at_result_iter_next_number(iter, validity);
+
+   DBG(%s %d, name, validity);
+
+   call = l-data;
+
+   strncpy(call-name, name,
+   OFONO_MAX_CALLER_NAME_LENGTH);
+   call-name[OFONO_MAX_CALLER_NAME_LENGTH] = '\0';
+   call-cnap_validity = validity;
+
+   ofono_voicecall_notify(vc, call);
+}
+
 static void ccwa_notify(GAtResult *result, gpointer user_data)
 {
struct ofono_voicecall *vc = user_data;
@@ -864,6 +909,7 @@ static void at_voicecall_initialized(gboolean ok, GAtResult 
*result,
g_at_chat_register(vd-chat, RING, ring_notify, FALSE, vc, NULL);
g_at_chat_register(vd-chat, +CRING:, cring_notify, FALSE, vc, NULL);
g_at_chat_register(vd-chat, +CLIP:, clip_notify, FALSE, vc, NULL);
+   g_at_chat_register(vd-chat, +CNAP:, cnap_notify, FALSE, vc, NULL);
g_at_chat_register(vd-chat, +CCWA:, ccwa_notify, FALSE, vc, NULL);
 
/* Modems with 'better' call progress indicators should
@@ -899,6 +945,7 @@ static int at_voicecall_probe(struct ofono_voicecall *vc, 
unsigned int vendor,
 
g_at_chat_send(vd-chat, AT+CRC=1, NULL, NULL, NULL, NULL);
g_at_chat_send(vd-chat, AT+CLIP=1, NULL, NULL, NULL, NULL);
+   g_at_chat_send(vd-chat, AT+CNAP=1, NULL, NULL, NULL, NULL);
g_at_chat_send(vd-chat, AT+COLP=1, NULL, NULL, NULL, NULL);
g_at_chat_send(vd-chat, AT+VTD?, NULL,
vtd_query_cb, vc, NULL);
-- 
1.7.3.2

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


[PATCH 10/14] include: add cnap_query callback

2010-12-06 Thread Gustavo F. Padovan
---
 include/call-settings.h |2 ++
 1 files changed, 2 insertions(+), 0 deletions(-)

diff --git a/include/call-settings.h b/include/call-settings.h
index 77e0440..c1ff668 100644
--- a/include/call-settings.h
+++ b/include/call-settings.h
@@ -46,6 +46,8 @@ struct ofono_call_settings_driver {
void (*remove)(struct ofono_call_settings *cs);
void (*clip_query)(struct ofono_call_settings *cs,
ofono_call_settings_status_cb_t cb, void *data);
+   void (*cnap_query)(struct ofono_call_settings *cs,
+   ofono_call_settings_status_cb_t cb, void *data);
void (*colp_query)(struct ofono_call_settings *cs,
ofono_call_settings_status_cb_t cb, void *data);
void (*clir_query)(struct ofono_call_settings *cs,
-- 
1.7.3.2

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


[PATCH 11/14] call-settings: add CNAP support

2010-12-06 Thread Gustavo F. Padovan
---
 src/call-settings.c |  102 ++
 1 files changed, 93 insertions(+), 9 deletions(-)

diff --git a/src/call-settings.c b/src/call-settings.c
index 2bf54d3..b6c3924 100644
--- a/src/call-settings.c
+++ b/src/call-settings.c
@@ -55,6 +55,13 @@ enum clip_status {
CLIP_STATUS_UNKNOWN
 };
 
+/* 27.007 Section 7.30 */
+enum cnap_status {
+   CNAP_STATUS_NOT_PROVISIONED = 0,
+   CNAP_STATUS_PROVISIONED,
+   CNAP_STATUS_UNKNOWN
+};
+
 /* 27.007 Section 7.8 */
 enum colp_status {
COLP_STATUS_NOT_PROVISIONED = 0,
@@ -71,6 +78,7 @@ enum colr_status {
 
 enum call_setting_type {
CALL_SETTING_TYPE_CLIP = 0,
+   CALL_SETTING_TYPE_CNAP,
CALL_SETTING_TYPE_COLP,
CALL_SETTING_TYPE_COLR,
CALL_SETTING_TYPE_CLIR,
@@ -81,6 +89,7 @@ struct ofono_call_settings {
int clir;
int colr;
int clip;
+   int cnap;
int colp;
int clir_setting;
int cw;
@@ -108,6 +117,18 @@ static const char *clip_status_to_string(int status)
return unknown;
 }
 
+static const char *cnap_status_to_string(int status)
+{
+   switch (status) {
+   case CNAP_STATUS_NOT_PROVISIONED:
+   return disabled;
+   case CNAP_STATUS_PROVISIONED:
+   return enabled;
+   }
+
+   return unknown;
+}
+
 static const char *colp_status_to_string(int status)
 {
switch (status) {
@@ -228,6 +249,28 @@ static void set_clip(struct ofono_call_settings *cs, int 
clip)
DBUS_TYPE_STRING, str);
 }
 
+static void set_cnap(struct ofono_call_settings *cs, int cnap)
+{
+   DBusConnection *conn;
+   const char *path;
+   const char *str;
+
+   if (cs-cnap == cnap)
+   return;
+
+   cs-cnap = cnap;
+
+   conn = ofono_dbus_get_connection();
+   path = __ofono_atom_get_path(cs-atom);
+
+   str = cnap_status_to_string(cnap);
+
+   ofono_dbus_signal_property_changed(conn, path,
+   OFONO_CALL_SETTINGS_INTERFACE,
+   CallingNamePresentation,
+   DBUS_TYPE_STRING, str);
+}
+
 static void set_colp(struct ofono_call_settings *cs, int colp)
 {
DBusConnection *conn;
@@ -520,7 +563,7 @@ static void generate_ss_query_reply(struct 
ofono_call_settings *cs,
__ofono_dbus_pending_reply(cs-pending, reply);
 }
 
-static void clip_colp_colr_ss_query_cb(const struct ofono_error *error,
+static void clip_cnap_colp_colr_ss_query_cb(const struct ofono_error *error,
int status, void *data)
 {
struct ofono_call_settings *cs = data;
@@ -542,6 +585,13 @@ static void clip_colp_colr_ss_query_cb(const struct 
ofono_error *error,
context = CallingLinePresentation;
break;
 
+   case CALL_SETTING_TYPE_CNAP:
+   set_cnap(cs, status);
+   value = cnap_status_to_string(status);
+   context = CallingNamePresentation;
+   break;
+
+
case CALL_SETTING_TYPE_COLP:
set_colp(cs, status);
value = colp_status_to_string(status);
@@ -557,14 +607,14 @@ static void clip_colp_colr_ss_query_cb(const struct 
ofono_error *error,
default:
__ofono_dbus_pending_reply(cs-pending,
__ofono_error_failed(cs-pending));
-   ofono_error(Unknown type during COLR/COLP/CLIP ss);
+   ofono_error(Unknown type during COLR/COLP/CLIP/CNAP ss);
return;
};
 
generate_ss_query_reply(cs, context, value);
 }
 
-static gboolean clip_colp_colr_ss(int type,
+static gboolean clip_cnap_colp_colr_ss(int type,
const char *sc, const char *sia,
const char *sib, const char *sic,
const char *dn, DBusMessage *msg, void *data)
@@ -587,6 +637,9 @@ static gboolean clip_colp_colr_ss(int type,
if (!strcmp(sc, 30)) {
cs-ss_setting = CALL_SETTING_TYPE_CLIP;
query_op = cs-driver-clip_query;
+   } else if (!strcmp(sc, 300)) {
+   cs-ss_setting = CALL_SETTING_TYPE_CNAP;
+   query_op = cs-driver-cnap_query;
} else if (!strcmp(sc, 76)) {
cs-ss_setting = CALL_SETTING_TYPE_COLP;
query_op = cs-driver-colp_query;
@@ -612,11 +665,11 @@ static gboolean clip_colp_colr_ss(int type,
return TRUE;
}
 
-   DBG(Received CLIP/COLR/COLP query ss control);
+   DBG(Received CLIP/CNAP/COLR/COLP query ss control);
 
cs-pending = dbus_message_ref(msg);
 
-   query_op(cs, clip_colp_colr_ss_query_cb, cs);
+   query_op(cs, clip_cnap_colp_colr_ss_query_cb, cs);
 
return TRUE;
 }
@@ -762,15 +815,19 @@ static gboolean 

[PATCH 09/14] call-settings: fix coding style

2010-12-06 Thread Gustavo F. Padovan
---
 src/call-settings.c |   20 ++--
 1 files changed, 10 insertions(+), 10 deletions(-)

diff --git a/src/call-settings.c b/src/call-settings.c
index 49a7fb0..2bf54d3 100644
--- a/src/call-settings.c
+++ b/src/call-settings.c
@@ -103,9 +103,9 @@ static const char *clip_status_to_string(int status)
return disabled;
case CLIP_STATUS_PROVISIONED:
return enabled;
-   default:
-   return unknown;
}
+
+   return unknown;
 }
 
 static const char *colp_status_to_string(int status)
@@ -115,9 +115,9 @@ static const char *colp_status_to_string(int status)
return disabled;
case COLP_STATUS_PROVISIONED:
return enabled;
-   default:
-   return unknown;
}
+
+   return unknown;
 }
 
 static const char *colr_status_to_string(int status)
@@ -127,9 +127,9 @@ static const char *colr_status_to_string(int status)
return disabled;
case COLR_STATUS_PROVISIONED:
return enabled;
-   default:
-   return unknown;
}
+
+   return unknown;
 }
 
 static const char *hide_callerid_to_string(int status)
@@ -141,9 +141,9 @@ static const char *hide_callerid_to_string(int status)
return enabled;
case OFONO_CLIR_OPTION_SUPPRESSION:
return disabled;
-   default:
-   return default;
}
+
+   return default;
 }
 
 static const char *clir_status_to_string(int status)
@@ -157,9 +157,9 @@ static const char *clir_status_to_string(int status)
return on;
case CLIR_STATUS_TEMPORARY_ALLOWED:
return off;
-   default:
-   return unknown;
}
+
+   return unknown;
 }
 
 static void set_clir_network(struct ofono_call_settings *cs, int clir)
-- 
1.7.3.2

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


[PATCH 12/14] doc: add CallingNamePresentation property to CallSettings

2010-12-06 Thread Gustavo F. Padovan
---
 doc/call-settings-api.txt |   12 
 1 files changed, 12 insertions(+), 0 deletions(-)

diff --git a/doc/call-settings-api.txt b/doc/call-settings-api.txt
index e98ce0c..a454621 100644
--- a/doc/call-settings-api.txt
+++ b/doc/call-settings-api.txt
@@ -30,6 +30,18 @@ Properties   string CallingLinePresentation [readonly]
enabled,
unknown
 
+   string CallingNamePresentation [readonly]
+
+   Contains the value of the calling name identification
+   presentation property.  The value indicates
+   the state of the CNAP supplementary service in the
+   network.  If enabled, the network will provide
+   the name of the calling party for incoming calls.
+   Possible values are:
+   disabled,
+   enabled,
+   unknown
+
string CalledLinePresentation [readonly]
 
Contains the value of the connected line identification
-- 
1.7.3.2

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


[PATCH 13/14] atmodem: add CNAP to call-settings

2010-12-06 Thread Gustavo F. Padovan
---
 drivers/atmodem/call-settings.c |   53 +++
 1 files changed, 53 insertions(+), 0 deletions(-)

diff --git a/drivers/atmodem/call-settings.c b/drivers/atmodem/call-settings.c
index 7e1b422..b3e8ea6 100644
--- a/drivers/atmodem/call-settings.c
+++ b/drivers/atmodem/call-settings.c
@@ -45,6 +45,7 @@ static const char *colp_prefix[] = { +COLP:, NULL };
 static const char *clip_prefix[] = { +CLIP:, NULL };
 static const char *ccwa_prefix[] = { +CCWA:, NULL };
 static const char *colr_prefix[] = { +COLR:, NULL };
+static const char *cnap_prefix[] = { +CNAP:, NULL };
 
 static void ccwa_query_cb(gboolean ok, GAtResult *result, gpointer user_data)
 {
@@ -188,6 +189,57 @@ error:
CALLBACK_WITH_FAILURE(cb, -1, data);
 }
 
+static void cnap_query_cb(gboolean ok, GAtResult *result, gpointer user_data)
+{
+   struct cb_data *cbd = user_data;
+   ofono_call_settings_status_cb_t cb = cbd-cb;
+   struct ofono_error error;
+   GAtResultIter iter;
+   int status;
+
+   decode_at_error(error, g_at_result_final_response(result));
+
+   if (!ok) {
+   cb(error, -1, cbd-data);
+   return;
+   }
+
+   g_at_result_iter_init(iter, result);
+
+   if (g_at_result_iter_next(iter, +CNAP:) == FALSE)
+   goto error;
+
+   if (g_at_result_iter_next_number(iter, status) == FALSE)
+   goto error;
+
+   DBG(network: %d, status);
+
+   cb(error, status, cbd-data);
+   return;
+
+error:
+   CALLBACK_WITH_FAILURE(cb, -1, cbd-data);
+}
+
+static void at_cnap_query(struct ofono_call_settings *cs,
+   ofono_call_settings_status_cb_t cb, void *data)
+{
+   GAtChat *chat = ofono_call_settings_get_data(cs);
+   struct cb_data *cbd = cb_data_new(cb, data);
+
+   if (cbd == NULL)
+   goto error;
+
+   if (g_at_chat_send(chat, AT+CNAP?, cnap_prefix,
+   cnap_query_cb, cbd, g_free)  0)
+   return;
+
+error:
+   g_free(cbd);
+
+   CALLBACK_WITH_FAILURE(cb, -1, data);
+}
+
 static void colp_query_cb(gboolean ok, GAtResult *result, gpointer user_data)
 {
struct cb_data *cbd = user_data;
@@ -404,6 +456,7 @@ static struct ofono_call_settings_driver driver = {
.probe = at_call_settings_probe,
.remove = at_call_settings_remove,
.clip_query = at_clip_query,
+   .cnap_query = at_cnap_query,
.colp_query = at_colp_query,
.clir_query = at_clir_query,
.clir_set = at_clir_set,
-- 
1.7.3.2

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


[PATCH 14/14] test: add CNAP to test-ss-control-cs

2010-12-06 Thread Gustavo F. Padovan
---
 test/test-ss-control-cs |3 +++
 1 files changed, 3 insertions(+), 0 deletions(-)

diff --git a/test/test-ss-control-cs b/test/test-ss-control-cs
index e04a4a0..35db591 100755
--- a/test/test-ss-control-cs
+++ b/test/test-ss-control-cs
@@ -55,6 +55,9 @@ if __name__ == __main__:
print Query CLIP
print ss.Initiate(*#30#)
 
+   print Query CNAP
+   print ss.Initiate(*#300#)
+
print Query COLP
print ss.Initiate(*#76#)
 
-- 
1.7.3.2

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


Re: [PATCH 1/3] plugins: Implementation of Network Time plugin

2010-12-06 Thread Rémi Denis-Courmont
On Tuesday 07 December 2010 01:29:34 ext Marcel Holtmann, you wrote:
   where is this timed running? I prefer the plugin just send a D-Bus
   message to the timed directly instead of a Get/Changed API kind of
   thing.
  
  AFAIK, Get/Changed is the simplest functional way to avoid races, where
  say oFono would receive the time before timed can process it. The getter
  also enables implementing trivial a tool à la ntpdate.
 
 then please answer my questions from my other email. If we receive the
 time before timed (or any other time daemon) is running, who does ensure
 the current timestamp of this received time and what it correlates to.

The answer is in the patch. It makes me wonder if you even read it? When we 
receive NITZ from the modem, we take a timestamp from the monotonic clock.

From there, we have plenty of options, mostly boiling down to:

(1) Give an estimate of the current wall time:
   nitz + (now(CLOCK_MONOTONIC) - timestamp)
This induces avoidable imprecision, but it is easiest to understand.

(2) Give both the NITZ time and the monotonic timestamp, and let the time 
daemon do all the maths. IIRC, that's what timed would like, although I find it 
needlessly complicated.

(3) Give an estimate of the time of day of the monotonic clock origin, which 
is to say the time of day of the system boot:
  nitz - timestamp.
The time daemon can then add the current monotonic time. This is a bit more 
precise than (1), and a bit simpler than (2), which is why I was suggesting 
that.

 If no time daemon is running it is safer to just set this time as system
 time right away and then let the time daemon adjust it later.

Either oFono maintains the time (may be a configuration option), or it does 
not. I would really hate to have oFono set the system time depending on the 
effect of the phase of moon on the ordering of the boot sequence.

 But just
 handing out a random time from a random time before is not helping. And
 oFono is not suppose to track time and it corelation to it.

Antti's patch returns an extrapolation of the _current_ wall time by adding 
the time since the NITZ was received to the NITZ. This is not at all random. 
Obviously, we need a working monotonic clock - but I think a mobile device 
without a working timer is about as useful as a brick.

-- 
Rémi Denis-Courmont
Nokia Devices RD, Maemo Software, Helsinki
___
ofono mailing list
ofono@ofono.org
http://lists.ofono.org/listinfo/ofono


Re: [PATCH 1/3] plugins: Implementation of Network Time plugin

2010-12-06 Thread Aki Niemi
Hi Rémi,

2010/12/6 Rémi Denis-Courmont remi.denis-courm...@nokia.com:
 +static struct tm *refresh_nw_time(struct tm *nw_time,
 +                             time_t received)
 +{
 +     time_t now, new_nw_time;
 +
 +     now = get_monotonic_time();
 +     new_nw_time = timegm(nw_time) + now - received;
 +     return gmtime(new_nw_time);
 +}

 Brrr, the result is somewhere in static data. This can cause quite confusing
 behaviour if/when the code is changed. I would much rather use gmtime_r().

I suppose that's a good point.

 That being said, wouldn't it be far simpler to return a second timestamp
 instead of a broken-down time structure over D-Bus? Eventually, timed/whatever
 will want a timestamp anyway to set the system clock or whatever else it wants
 to do with the NITZ.

 +static int fill_time_changed_signal(DBusMessage *signal,
 +             struct nettime_data *ntd)
 +{
 +     DBusMessageIter iter, iter_array;
 +     int time_available;
 +     char buf[MAX_TIME_STR_LEN];
 +     struct tm time_tm, *new_time_tm;
 +     const char *str = buf;
 +
 +     dbus_message_iter_init_append(signal, iter);
 +     dbus_message_iter_open_container(iter,
 +                                     DBUS_TYPE_ARRAY,
 +                                     {sv},
 +                                     iter_array);
 +
 +     time_available = encode_time_format(ntd-nw_time, time_tm);
 +     if (time_available != 0) {
 +             new_time_tm = refresh_nw_time(time_tm, ntd-received);
 +             strftime(buf, MAX_TIME_STR_LEN, TIME_FORMAT, new_time_tm);
 +
 +             ofono_dbus_dict_append(iter_array,
 +                                     DateAndTime,
 +                                     DBUS_TYPE_STRING,
 +                                     str);
 +     }
 +
 +     ofono_dbus_dict_append(iter_array,
 +                             Timezone,
 +                             DBUS_TYPE_INT32,
 +                             ntd-nw_time.utcoff);
 +     ofono_dbus_dict_append(iter_array,
 +                             DST,
 +                             DBUS_TYPE_UINT32,
 +                             ntd-nw_time.dst);
 +     dbus_message_iter_close_container(iter, iter_array);
 +     return 0;
 +}

 Are the time zone offset and the DST always available, but the current time
 not? This seems odd.

Tell me about it, but this is how the spec works. Operators have the
flexibility to send just the timezone, the timezone and DST, or the
works.

 Passing the time over D-Bus may cause extra drift/imprecision than we already
 have. I wonder if it would make sense to provide not just the current time but
 both:
 - the current time for trivial programs, and
 - the system boot time (i.e. nw_time - received) for smarter programs;
  this value cannot drift.

I remember we had similar argument in the past with the timed folks,
which actually resulted in a much more convoluted API... I'm still not
convinced time drift is a problem, since NITZ itself is accurate to
the second.

However, thinking about this, I actually don't see any value in
providing a human readable time over D-Bus. No application should
directly ask oFono for time, this is why timed is there to begin with.

So sending a plain time_t over D-Bus is actually sufficient. This
leaves us with having to send timestamps over D-Bus, which is ugly.
Can you explain how you see clock drift a problem here exactly?

 +static DBusMessage *create_time_changed_signal(
 +                     struct ofono_nettime_context *context)
 +{
 +     DBusMessage *signal;
 +     struct nettime_data *ntd = context-data;
 +     const char *path = ofono_modem_get_path(context-modem);
 +
 +     if (path == NULL) {
 +             ofono_error(Fetching path for modem failed);
 +             return NULL;
 +     }
 +
 +     signal = dbus_message_new_signal(path, OFONO_NETWORK_TIME_INTERFACE,
 +                                     NetworkTimeChanged);
 +     fill_time_changed_signal(signal, ntd);
 +
 +     return signal;
 +}
 +
 +static void init_time(struct ofono_nettime_context *context)
 +{
 +     struct nettime_data *nettime_data;
 +     context-data = g_try_new0(struct nettime_data, 1);

 Hmm, if you don't check the result, I suspect you should g_new0() instead.

Good point.

 +     nettime_data = context-data;
 +     nettime_data-nw_time.year = -1;
 +}
 +
 +static int nettime_probe(struct ofono_nettime_context *context)
 +{
 +     ofono_debug(Network Time Probe for modem: %p, context-modem);
 +
 +     init_time(context);
 +
 +     nettime_register(context);
 +     return 0;
 +}
 +
 +static void nettime_remove(struct ofono_nettime_context *context)
 +{
 +     DBusConnection *conn;
 +     const char *path;
 +
 +     ofono_debug(Network Time Remove for modem: %p, context-modem);
 +
 +     g_free(context-data);
 +
 +     conn = ofono_dbus_get_connection();
 +     path = ofono_modem_get_path(context-modem);
 +
 +     if (!g_dbus_unregister_interface(conn,
 +                                     path,
 +