Re: [PATCH 09/18] isimodem: clip colp clir colr wgmodem2.5

2011-02-18 Thread Aki Niemi
Hi Andreas,

2011/2/15 Andreas Westin andreas.wes...@stericsson.com:
 From: Jessica Nilsson jessica.j.nils...@stericsson.com

 ---
  drivers/isimodem/call-settings.c |  697 
 +-
  drivers/isimodem/call.h          |    9 +
  drivers/isimodem/debug.c         |    4 +
  drivers/isimodem/ss.h            |   22 ++
  4 files changed, 714 insertions(+), 18 deletions(-)

 diff --git a/drivers/isimodem/call-settings.c 
 b/drivers/isimodem/call-settings.c
 index 89270e9..7a6bedf 100644
 --- a/drivers/isimodem/call-settings.c
 +++ b/drivers/isimodem/call-settings.c
 @@ -3,6 +3,7 @@
  *  oFono - Open Source Telephony
  *
  *  Copyright (C) 2009-2010 Nokia Corporation and/or its subsidiary(-ies).
 + *  Copyright (C) ST-Ericsson SA 2011.
  *
  *  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
 @@ -43,10 +44,15 @@
  #include ss.h
  #include debug.h

 +#define CLIP_ETC
 +

I don't see this used anywhere in the code.

  struct settings_data {
        GIsiClient *client;
  };

 +#define content_size  40
 +static char content[content_size] = {0};
 +

(snip)

 +static int set_clir_status(const char *value)
 +{
 +       DBG(Setting CLIR status to %s, value);
 +       strncpy(content, value, content_size);
 +       content[content_size-1] = 0;
 +       return EXIT_SUCCESS;
 +}
 +
 +static int get_clir_status(void)
 +{
 +       DBG(Getting CLIR status %s, content);
 +
 +       if (!strcmp(content, OFONO_CLIR_OPTION_INVOCATION))
 +               return OFONO_CLIR_OPTION_INVOCATION;
 +
 +       if (!strcmp(content, OFONO_CLIR_OPTION_SUPPRESSION))
 +               return OFONO_CLIR_OPTION_SUPPRESSION;
 +
 +       return OFONO_CLIR_OPTION_DEFAULT;
 +}

I don't understand this part. Why is 'content' a static buffer, and
why is strncpy() used? All I see are const strings copied there.

Also, if the getter anyway returns an int, why not store an int there
in the first place? Could it also be part of the call-settings driver
data?

 +static void clir_set_cb(const GIsiMessage *msg, void *data)
 +{
 +       GIsiSubBlockIter iter, iter_info;
 +       struct isi_cb_data *cbd = data;
 +       ofono_call_settings_set_cb_t cb = cbd-cb;
 +       gint override = OFONO_CLIR_OPTION_DEFAULT;
 +       gint network = CLIR_STATUS_UNKNOWN;
 +       uint8_t service;
 +
 +       if (!check_response_status(msg, SS_SERVICE_COMPLETED_RESP))
 +               goto error;
 +
 +       if (!g_isi_msg_data_get_byte(msg, 0, service) ||
 +                       service != SS_INTERROGATION)
 +               goto error;
 +
 +       for (g_isi_sb_iter_init(iter, msg, 6);
                        g_isi_sb_iter_is_valid(iter);
                        g_isi_sb_iter_next(iter)) {
 +               DBG(Sub-block %s,
 +                               
 ss_subblock_name(g_isi_sb_iter_get_id(iter)));

 -               if (g_isi_sb_iter_get_id(iter) != SS_GSM_BSC_INFO)
 -                       continue;
 +               switch (g_isi_sb_iter_get_id(iter)) {
 +               case SS_STATUS_RESULT: {
 +                       guint8 ss_status;
 +
 +                       if (!g_isi_sb_iter_get_byte(iter, ss_status, 2))
 +                               goto error;
 +
 +                       DBG(SS_STATUS_RESULT=%d, ss_status);
 +
 +                       if (!(ss_status  SS_GSM_PROVISIONED))
 +                               network = CLIR_STATUS_NOT_PROVISIONED;
 +               }
 +               break;
 +               case SS_GSM_ADDITIONAL_INFO:
 +                       break;
 +               case SS_GSM_GENERIC_SERVICE_INFO: {
 +                       guint8 ss_status = 0;
 +                       guint8 clir_option = 0;
 +                       void *info = NULL;
 +                       GIsiMessage info_msg;
 +
 +                       if (!g_isi_sb_iter_get_byte(iter, ss_status, 2))
 +                               goto error;
 +
 +                       if (!(ss_status  SS_GSM_PROVISIONED))
 +                               network = CLIR_STATUS_NOT_PROVISIONED;
 +
 +                       if (!g_isi_sb_iter_get_data(iter, info, 4))
 +                               goto error;
 +
 +                       info_msg.addr = NULL;
 +                       info_msg.error = 0;
 +                       /*
 +                        * GIsiMessage function adds 2 to data pointer and
 +                        * removes 2 from len
 +                        */
 +                       info_msg.data = info - 2;
 +                       info_msg.len = msg-len - 6 + 2;
 +
 +                       for (g_isi_sb_iter_init(iter_info, info_msg, 0);
 +                                       g_isi_sb_iter_is_valid(iter_info);
 +                                       g_isi_sb_iter_next(iter_info)) {
 +                               DBG(Sub-block %s,
 +                                       ss_subblock_name(
 +                                       

[PATCH 09/18] isimodem: clip colp clir colr wgmodem2.5

2011-02-15 Thread Andreas Westin
From: Jessica Nilsson jessica.j.nils...@stericsson.com

---
 drivers/isimodem/call-settings.c |  697 +-
 drivers/isimodem/call.h  |9 +
 drivers/isimodem/debug.c |4 +
 drivers/isimodem/ss.h|   22 ++
 4 files changed, 714 insertions(+), 18 deletions(-)

diff --git a/drivers/isimodem/call-settings.c b/drivers/isimodem/call-settings.c
index 89270e9..7a6bedf 100644
--- a/drivers/isimodem/call-settings.c
+++ b/drivers/isimodem/call-settings.c
@@ -3,6 +3,7 @@
  *  oFono - Open Source Telephony
  *
  *  Copyright (C) 2009-2010 Nokia Corporation and/or its subsidiary(-ies).
+ *  Copyright (C) ST-Ericsson SA 2011.
  *
  *  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
@@ -43,10 +44,15 @@
 #include ss.h
 #include debug.h
 
+#define CLIP_ETC
+
 struct settings_data {
GIsiClient *client;
 };
 
+#define content_size  40
+static char content[content_size] = {0};
+
 static void update_status_mask(unsigned int *mask, int bsc)
 {
switch (bsc) {
@@ -88,7 +94,6 @@ static void update_status_mask(unsigned int *mask, int bsc)
break;
}
 }
-
 static gboolean check_response_status(const GIsiMessage *msg, uint8_t msgid)
 {
if (g_isi_msg_error(msg)  0) {
@@ -104,6 +109,59 @@ static gboolean check_response_status(const GIsiMessage 
*msg, uint8_t msgid)
return TRUE;
 }
 
+static void clip_query_cb(const GIsiMessage *msg, void *data)
+{
+   GIsiSubBlockIter iter;
+   struct isi_cb_data *cbd = data;
+
+   ofono_call_settings_status_cb_t cb = cbd-cb;
+   uint8_t service;
+   guint32 mask = 0;
+
+   if (!check_response_status(msg, SS_SERVICE_COMPLETED_RESP))
+   goto error;
+
+   if (!g_isi_msg_data_get_byte(msg, 0, service) ||
+   service != SS_INTERROGATION)
+   goto error;
+
+   for (g_isi_sb_iter_init(iter, msg, 6);
+g_isi_sb_iter_is_valid(iter);
+g_isi_sb_iter_next(iter)) {
+   DBG(Sub-block %s,
+   ss_subblock_name(g_isi_sb_iter_get_id(iter)));
+
+   switch (g_isi_sb_iter_get_id(iter)) {
+   case SS_STATUS_RESULT: {
+   guint8 ss_status;
+
+   if (!g_isi_sb_iter_get_byte(iter, ss_status, 2))
+   goto error;
+
+   DBG(SS_STATUS_RESULT=%d, ss_status);
+
+   if (ss_status  SS_GSM_PROVISIONED)
+   mask = 1;
+   }
+   break;
+   case SS_GSM_ADDITIONAL_INFO:
+   break;
+   default:
+   DBG(Skipping sub-block: %s (%zd bytes),
+   ss_subblock_name(g_isi_sb_iter_get_id(iter)),
+   g_isi_sb_iter_get_len(iter));
+   break;
+   }
+   }
+
+   DBG(status_mask %d\n, mask);
+   CALLBACK_WITH_SUCCESS(cb, mask, cbd-data);
+   return;
+error:
+   CALLBACK_WITH_FAILURE(cb, 0, cbd-data);
+}
+
+
 static gboolean decode_gsm_bsc_info(GIsiSubBlockIter *iter, uint32_t *mask)
 {
uint8_t num;
@@ -136,23 +194,611 @@ static void query_resp_cb(const GIsiMessage *msg, void 
*data)
goto error;
 
for (g_isi_sb_iter_init(iter, msg, 6);
+g_isi_sb_iter_is_valid(iter);
+g_isi_sb_iter_next(iter)) {
+
+   if (g_isi_sb_iter_get_id(iter) == SS_GSM_BSC_INFO) {
+   if (!decode_gsm_bsc_info(iter, mask))
+   goto error;
+
+   CALLBACK_WITH_SUCCESS(cb, mask, cbd-data);
+   return;
+   } else if (g_isi_sb_iter_get_id(iter) == SS_STATUS_RESULT) {
+   guint8 ss_status;
+
+   if (!g_isi_sb_iter_get_byte(iter, ss_status, 2))
+   goto error;
+
+   if (ss_status  SS_GSM_PROVISIONED)
+   mask = 1;
+   CALLBACK_WITH_SUCCESS(cb, mask, cbd-data);
+   return;
+   }
+   }
+
+error:
+   CALLBACK_WITH_FAILURE(cb, 0, cbd-data);
+}
+
+static void isi_clip_query(struct ofono_call_settings *cs,
+   ofono_call_settings_status_cb_t cb, void *data)
+{
+   struct settings_data *sd = ofono_call_settings_get_data(cs);
+   struct isi_cb_data *cbd = isi_cb_data_new(cs, cb, data);
+   unsigned char msg[] = {
+   SS_SERVICE_REQ,
+   SS_INTERROGATION,
+   SS_ALL_TELE_AND_BEARER,
+   SS_GSM_CLIP  8,   /* Supplementary services */
+   SS_GSM_CLIP  0xFF, /* code */
+   SS_SEND_ADDITIONAL_INFO,
+   0