[PATCH] plugin: Add ste modem initd integration

2010-11-17 Thread Sjur Brændeland
From: Sjur Brændeland sjur.brandel...@stericsson.com

This patch introduces auto discovery of ST-Ericsson modems.
ST-Ericsson modems are managed by a Modem Init Daemon that
is responsible for start/stop/restart flashing etc. The
STE plugin monitors the modem state exposed from the
Modem Init Damon Dbus API. When the modem is in state on
the STE modem is created and registered.
---
 Makefile.am  |5 ++
 configure.ac |6 ++
 plugins/stemid.c |  195 ++
 3 files changed, 206 insertions(+), 0 deletions(-)
 create mode 100644 plugins/stemid.c

diff --git a/Makefile.am b/Makefile.am
index f841b4c..aaf5de5 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -81,6 +81,11 @@ gatchat_sources = gatchat/gatchat.h gatchat/gatchat.c \
 
 udev_files = plugins/ofono.rules
 
+if STE_MODEM_INITD
+builtin_modules += stemid
+builtin_sources += plugins/stemid.c
+endif
+
 if UDEV
 builtin_modules += udev
 builtin_sources += plugins/udev.c
diff --git a/configure.ac b/configure.ac
index 6aeab7c..6fafadd 100644
--- a/configure.ac
+++ b/configure.ac
@@ -175,6 +175,12 @@ AC_ARG_ENABLE(datafiles, 
AC_HELP_STRING([--disable-datafiles],
 
 AM_CONDITIONAL(DATAFILES, test ${enable_datafiles} != no)
 
+AC_ARG_ENABLE(ste_modem_initd, AC_HELP_STRING([--disable-ste-modem-initd],
+   [disable auto discovery of STE modem using modem init 
daemon]),
+   [enable_ste_modem_initd=${enableval}])
+
+AM_CONDITIONAL(STE_MODEM_INITD, test ${enable_ste_modem_initd} != no)
+
 if (test ${prefix} = NONE); then
dnl no prefix and no localstatedir, so default to /var
if (test $localstatedir = '${prefix}/var'); then
diff --git a/plugins/stemid.c b/plugins/stemid.c
new file mode 100644
index 000..7041e5e
--- /dev/null
+++ b/plugins/stemid.c
@@ -0,0 +1,195 @@
+/*
+ *
+ *  oFono - Open Source Telephony
+ *
+ *  Copyright (C) 2010 ST-Ericsson AB.
+ *
+ *  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 errno.h
+#include stdio.h
+#include fcntl.h
+#include stdlib.h
+#include string.h
+#include unistd.h
+#include net/if.h
+
+#include gdbus.h
+#include glib.h
+#include gatchat.h
+
+#define OFONO_API_SUBJECT_TO_CHANGE
+#include ofono/plugin.h
+#include ofono/log.h
+#include ofono/modem.h
+#include ofono/dbus.h
+#include ofono/version.h
+
+/*
+ * ST-Ericsson's modem init daemon defines the signal StateChange
+ * and the method GetState. When state is on the STE modem is
+ * created and registered.
+ */
+#define STATUS_CHANGED StateChange
+#define MID_SERVICEcom.stericsson.modeminit
+#define MID_INTERFACE  MID_SERVICE .Modem
+#define GET_STATE  GetState
+#define MID_STATE_ON   on
+#define MID_STATE_DISCONNECT   disconnect
+#define TIMEOUT5000
+
+static struct ofono_modem *ste_modem;
+static guint mid_api_watch;
+static guint mid_state_watch;
+
+static void handle_stemodem(const char *state)
+{
+
+   DBG(state:%s, state);
+
+   if (strcmp(state, MID_STATE_ON) == 0) {
+   int err;
+
+   if (ste_modem != NULL)
+   return;
+
+   ste_modem = ofono_modem_create(ste, ste);
+   DBG(register STE modem);
+   err = ofono_modem_register(ste_modem);
+   } else {
+
+   if (ste_modem == NULL)
+   return;
+
+   ofono_modem_remove(ste_modem);
+   ste_modem = NULL;
+   }
+}
+
+static void mid_getstate_reply(DBusPendingCall *call, void *user_data)
+{
+   DBusMessage *reply;
+   char *state;
+
+   reply = dbus_pending_call_steal_reply(call);
+
+   if (dbus_message_is_error(reply, DBUS_ERROR_SERVICE_UNKNOWN)) {
+   ofono_error(STE Modem Init Daemon is unavailable);
+   goto error;
+   }
+
+   if (dbus_message_get_args(reply, NULL, DBUS_TYPE_STRING, state,
+   DBUS_TYPE_INVALID) == FALSE) {
+   ofono_error(STE Modem Init Damon: bad signature for GetState);
+   goto error;
+   }
+
+   handle_stemodem(state);
+
+error:
+   dbus_message_unref(reply);
+}
+
+static gboolean mid_signal_status_change(DBusConnection *connection,
+   DBusMessage *message, void *user_data)

Re: [PATCH] stkutil: mask the DCS value to keep only the intersting bits

2010-11-17 Thread Denis Kenzior
Hi Guillaume,

On 11/15/2010 08:17 AM, Lucas, GuillaumeX wrote:
 From: Guillaume Lucas guillaumex.lu...@intel.com
 
 For SIM tool kit only the bits 2 and 3 are interesting
 for the DCS value. The others ones sould be masked. The
 masking is necessary because some SIM car set the
 upper bits to 1.
 ---
  src/stkutil.c |2 +-
  1 files changed, 1 insertions(+), 1 deletions(-)
 
 diff --git a/src/stkutil.c b/src/stkutil.c
 index cdd66bd..a54dd02 100644
 --- a/src/stkutil.c
 +++ b/src/stkutil.c
 @@ -78,7 +78,7 @@ static char *decode_text(unsigned char dcs, int len, const 
 unsigned char *data)
  {
   char *utf8;
  
 - switch (dcs) {
 + switch (dcs  0x06) {

Do you mean to bitwise and with 0xc here?  Otherwise you break the UCS2
case.  Also do any SIMs use the '' Coding Bits Entry entry from
23.038 Section 4?  If so, then we need to use sms_dcs_decode to retrieve
the character set.

   case 0x00:
   {
   long written;

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


Re: [PATCH] coding-style: Add exception to M12 rule for external enums

2010-11-17 Thread Denis Kenzior
Hi Sjur,

On 11/17/2010 01:09 AM, Sjur Brændeland wrote:
 From: Sjur Brændeland sjur.brandel...@stericsson.com
 
 ---
  doc/coding-style.txt |4 
  1 files changed, 4 insertions(+), 0 deletions(-)
 

Patch has been applied.  Thanks.

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


Re: [PATCH] todo: Add Location Service (AGPS) task.

2010-11-17 Thread Denis Kenzior
Hi Sjur,

On 11/17/2010 01:09 AM, Sjur Brændeland wrote:
 From: Sjur Brændeland sjur.brandel...@stericsson.com
 
 ---
  TODO |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: [PATCH] util: Remove extra tab

2010-11-17 Thread Denis Kenzior
Hi Jeevaka,

On 11/17/2010 09:32 AM, Jeevaka Badrappan wrote:
 ---
  src/util.c |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


[isi-voicecall-fix PATCHv3 1/6] voicecall: fix dial result handling

2010-11-17 Thread Pekka . Pessi
From: Pekka Pessi pekka.pe...@nokia.com

If there is an existing active call when dialing the existing call will
be automatically put on hold. The dialing result handling depended on
the voicecall driver putting the call on hold before the dial command
callback is called.

However, this is not true on isimodem driver, where the dial request
returns immediately before the existing call have changed its
status. The dial result handling now checks if the active call has been
resulted from the dial request.
---
 src/voicecall.c |   18 --
 1 files changed, 16 insertions(+), 2 deletions(-)

diff --git a/src/voicecall.c b/src/voicecall.c
index bd64432..e3ce2a5 100644
--- a/src/voicecall.c
+++ b/src/voicecall.c
@@ -68,6 +68,7 @@ struct voicecall {
char *message;
uint8_t icon_id;
gboolean untracked;
+   gboolean dial_result_handled;
 };
 
 struct dial_request {
@@ -1096,9 +1097,20 @@ static struct voicecall *dial_handle_result(struct 
ofono_voicecall *vc,
v = l-data;
 
if (v-call-status == CALL_STATUS_DIALING ||
-   v-call-status == CALL_STATUS_ALERTING ||
-   v-call-status == CALL_STATUS_ACTIVE)
+   v-call-status == CALL_STATUS_ALERTING)
return v;
+
+   /*
+* Dial request may return before existing active call
+* is put on hold or after dialed call has got active
+*/
+   if (v-call-status == CALL_STATUS_ACTIVE 
+   v-call-direction ==
+   CALL_DIRECTION_MOBILE_ORIGINATED 
+   !v-dial_result_handled) {
+   v-dial_result_handled = TRUE;
+   return v;
+   }
}
 
call = synthesize_outgoing_call(vc, number);
@@ -1119,6 +1131,8 @@ static struct voicecall *dial_handle_result(struct 
ofono_voicecall *vc,
 
*need_to_emit = TRUE;
 
+   v-dial_result_handled = TRUE;
+
return v;
 }
 
-- 
1.7.1

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


[isi-voicecall-fix PATCHv3 5/6] isi/voicecall: release COMING calls with BUSY cause

2010-11-17 Thread Pekka . Pessi
From: Pekka Pessi pekka.pe...@nokia.com

Very early incoming calls were not released with BUSY cause.
---
 drivers/isimodem/voicecall.c |1 +
 1 files changed, 1 insertions(+), 0 deletions(-)

diff --git a/drivers/isimodem/voicecall.c b/drivers/isimodem/voicecall.c
index 76aa8f5..cdd5d11 100644
--- a/drivers/isimodem/voicecall.c
+++ b/drivers/isimodem/voicecall.c
@@ -1220,6 +1220,7 @@ static void isi_release_specific(struct ofono_voicecall 
*ovc, int id,
uint8_t cause = CALL_CAUSE_RELEASE_BY_USER;
 
switch (status-status) {
+   case CALL_STATUS_COMING:
case CALL_STATUS_MT_ALERTING:
case CALL_STATUS_WAITING:
cause = CALL_CAUSE_BUSY_USER_REQUEST;
-- 
1.7.1

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


[isi-voicecall-fix PATCHv3 2/6] isi/voicecall: fix status reporting

2010-11-17 Thread Pekka . Pessi
From: Pekka Pessi pekka.pe...@nokia.com

Report early incoming calls as waiting or incoming, depending on the
state of other calls.

Report MT_RELEASED or MO_RELEASED via ofono_voicecall_notify(),
TERMINATED calls via ofono_voicecall_disconnected().
---
 drivers/isimodem/voicecall.c |  401 +-
 1 files changed, 203 insertions(+), 198 deletions(-)

diff --git a/drivers/isimodem/voicecall.c b/drivers/isimodem/voicecall.c
index c3365f6..c450f12 100644
--- a/drivers/isimodem/voicecall.c
+++ b/drivers/isimodem/voicecall.c
@@ -62,13 +62,6 @@ struct isi_voicecall {
 
 /* - */
 
-static void isi_call_notify(struct ofono_voicecall *ovc,
-   struct isi_call *call);
-static void isi_call_release(struct ofono_voicecall *, struct isi_call *);
-static struct ofono_call isi_call_as_ofono_call(struct isi_call const *);
-static int isi_call_status_to_clcc(struct isi_call const *call);
-static struct isi_call *isi_call_set_idle(struct isi_call *call);
-
 typedef void GIsiIndication(GIsiClient *client,
const void *restrict data, size_t len,
uint16_t object, void *opaque);
@@ -80,9 +73,6 @@ typedef gboolean GIsiResponse(GIsiClient *client,
void const *restrict data, size_t len,
uint16_t object, void *opaque);
 
-static GIsiVerify isi_call_verify_cb;
-static gboolean isi_call_register(gpointer);
-
 enum {
ISI_CALL_TIMEOUT = 1000,
 };
@@ -205,6 +195,174 @@ static gboolean isi_ctx_return_success(struct 
isi_call_req_context *irc)
 }
 
 /* - */
+/* Notify */
+
+enum clcc_status {
+   CLCC_STATUS_ACTIVE = 0,
+   CLCC_STATUS_HOLD = 1,
+   CLCC_STATUS_DIALING = 2,
+   CLCC_STATUS_ALERTING = 3,
+   CLCC_STATUS_INCOMING = 4,
+   CLCC_STATUS_WAITING = 5,
+   CLCC_STATUS_DISCONNECTED = 6, /* Nonstandard */
+};
+
+static int isi_call_waiting_or_incoming(struct isi_voicecall const *ivc)
+{
+   int id;
+
+   for (id = 1; id = 7; id++) {
+   switch (ivc-calls[id].status) {
+   case CALL_STATUS_ANSWERED:
+   case CALL_STATUS_ACTIVE:
+   case CALL_STATUS_HOLD_INITIATED:
+   case CALL_STATUS_HOLD:
+   case CALL_STATUS_RETRIEVE_INITIATED:
+   case CALL_STATUS_RECONNECT_PENDING:
+   case CALL_STATUS_SWAP_INITIATED:
+   return CLCC_STATUS_WAITING;
+   }
+   }
+
+   return CLCC_STATUS_INCOMING;
+}
+
+/** Get +CLCC status */
+static int isi_call_status_to_clcc(struct isi_voicecall const *ivc,
+   struct isi_call const *call)
+{
+   switch (call-status) {
+   case CALL_STATUS_CREATE:
+   return CLCC_STATUS_DIALING;
+
+   case CALL_STATUS_COMING:
+   return isi_call_waiting_or_incoming(ivc);
+
+   case CALL_STATUS_PROCEEDING:
+   if ((call-mode_info  CALL_MODE_ORIGINATOR))
+   return isi_call_waiting_or_incoming(ivc); /* MT */
+   else
+   return CLCC_STATUS_DIALING; /* MO */
+
+   case CALL_STATUS_MO_ALERTING:
+   return CLCC_STATUS_ALERTING;
+
+   case CALL_STATUS_MT_ALERTING:
+   return CLCC_STATUS_INCOMING;
+
+   case CALL_STATUS_WAITING:
+   return CLCC_STATUS_WAITING;
+
+   case CALL_STATUS_ANSWERED:
+   case CALL_STATUS_ACTIVE:
+   case CALL_STATUS_HOLD_INITIATED:
+   case CALL_STATUS_RECONNECT_PENDING:
+   case CALL_STATUS_SWAP_INITIATED:
+   return CLCC_STATUS_ACTIVE;
+
+   case CALL_STATUS_HOLD:
+   case CALL_STATUS_RETRIEVE_INITIATED:
+   return CLCC_STATUS_HOLD;
+
+   case CALL_STATUS_MO_RELEASE:
+   case CALL_STATUS_MT_RELEASE:
+   case CALL_STATUS_TERMINATED:
+   case CALL_STATUS_IDLE:
+   return CLCC_STATUS_DISCONNECTED;
+   }
+
+   return CLCC_STATUS_ACTIVE;
+}
+
+static struct ofono_call isi_call_as_ofono_call(struct isi_voicecall const 
*ivc,
+   struct isi_call const *call)
+{
+   struct ofono_call ocall = { call-id };
+   struct ofono_phone_number *number = ocall.phone_number;
+
+   ocall.type = 0; /* Voice call */
+   ocall.direction = call-mode_info  CALL_MODE_ORIGINATOR;
+   ocall.status = isi_call_status_to_clcc(ivc, call);
+   memcpy(number-number, call-address, sizeof number-number);
+   number-type = 0x80 | call-addr_type;
+   ocall.clip_validity = call-presentation  3;
+
+   if (ocall.clip_validity == 0  strlen(number-number) == 0)
+   ocall.clip_validity = 2;
+
+   return ocall;
+}
+
+static struct isi_call *isi_call_set_idle(struct isi_call *call)
+{
+   uint8_t id;
+
+ 

[isi-voicecall-fix PATCHv3 4/6] isi/voicecall: fix answering early incoming calls

2010-11-17 Thread Pekka . Pessi
From: Pekka Pessi pekka.pe...@nokia.com

The voicecall driver must wait until the incoming call is mt-alerting or
waiting before answering.
---
 drivers/isimodem/voicecall.c |   49 +-
 1 files changed, 48 insertions(+), 1 deletions(-)

diff --git a/drivers/isimodem/voicecall.c b/drivers/isimodem/voicecall.c
index 60052d4..76aa8f5 100644
--- a/drivers/isimodem/voicecall.c
+++ b/drivers/isimodem/voicecall.c
@@ -671,18 +671,65 @@ static void isi_call_status_ind_cb(GIsiClient *client,
isi_call_notify(ovc, call);
 }
 
+static void isi_wait_incoming(struct isi_call_req_context *irc, int event);
+
 static struct isi_call_req_context *
 isi_call_answer_req(struct ofono_voicecall *ovc,
uint8_t call_id, ofono_voicecall_cb_t cb, void *data)
 {
+   struct isi_voicecall *ivc = ofono_voicecall_get_data(ovc);
+   int id;
+
uint8_t const req[] = {
CALL_ANSWER_REQ, call_id, 0
};
size_t rlen = sizeof req;
 
+   for (id = 1; id = 7; id++) {
+   struct isi_call_req_context *irc;
+
+   if (!(ivc-calls[id].mode_info  CALL_MODE_ORIGINATOR))
+   continue;
+
+   if (ivc-calls[id].status != CALL_STATUS_PROCEEDING 
+   ivc-calls[id].status != CALL_STATUS_COMING)
+   continue;
+
+   irc = isi_call_req_new(ovc, cb, data);
+   if (irc)
+   isi_ctx_queue(irc, isi_wait_incoming, id);
+
+   return irc;
+   }
+
return isi_call_req(ovc, req, rlen, isi_call_answer_resp, cb, data);
 }
 
+static void isi_wait_incoming(struct isi_call_req_context *irc,
+   int event)
+{
+   struct isi_voicecall *ivc;
+
+   DBG(irc=%p event=%u, (void *)irc, event);
+
+   switch (event) {
+   case CALL_STATUS_MT_ALERTING:
+   case CALL_STATUS_WAITING:
+   isi_call_answer_req(irc-ovc, irc-id, irc-cb, irc-data);
+   isi_ctx_free(irc);
+   return;
+   }
+
+   ivc = ofono_voicecall_get_data(irc-ovc);
+   switch (ivc-calls[irc-id].status) {
+   case CALL_STATUS_MO_RELEASE:
+   case CALL_STATUS_MT_RELEASE:
+   case CALL_STATUS_TERMINATED:
+   case CALL_STATUS_IDLE:
+   isi_ctx_return_failure(irc);
+   }
+}
+
 static gboolean isi_call_answer_resp(GIsiClient *client,
void const *restrict data,
size_t len,
@@ -1018,7 +1065,7 @@ static void isi_hangup_current(struct ofono_voicecall 
*ovc,
 * active calls or calls in progress.
 */
struct isi_voicecall *ivc = ofono_voicecall_get_data(ovc);
-   int id = 0;
+   int id;
 
for (id = 1; id = 7; id++) {
if (ivc-calls[id].call_id  CALL_ID_WAITING)
-- 
1.7.1

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


[isi-voicecall-fix PATCHv3 3/6] isi/voicecall: save call id when queueing requests

2010-11-17 Thread Pekka . Pessi
From: Pekka Pessi pekka.pe...@nokia.com

---
 drivers/isimodem/voicecall.c |   64 +++---
 1 files changed, 41 insertions(+), 23 deletions(-)

diff --git a/drivers/isimodem/voicecall.c b/drivers/isimodem/voicecall.c
index c450f12..60052d4 100644
--- a/drivers/isimodem/voicecall.c
+++ b/drivers/isimodem/voicecall.c
@@ -80,41 +80,57 @@ enum {
 /* - */
 /* Request context for voicecall cb */
 
-struct isi_call_req_context;
-
 typedef void isi_call_req_step(struct isi_call_req_context *, int reason);
 
 struct isi_call_req_context {
-   struct isi_call_req_context *next, **prev;
+   struct isi_call_req_context *next;
+   struct isi_call_req_context **prev;
isi_call_req_step *step;
+   int id;
struct ofono_voicecall *ovc;
ofono_voicecall_cb_t cb;
void *data;
 };
 
-static struct isi_call_req_context *
-isi_call_req(struct ofono_voicecall *ovc,
-   void const *restrict req,
-   size_t len,
-   GIsiResponse *handler,
-   ofono_voicecall_cb_t cb, void *data)
+static struct isi_call_req_context *isi_call_req_new(
+   struct ofono_voicecall *ovc,
+   ofono_voicecall_cb_t cb,
+   void *data)
 {
-   struct isi_voicecall *ivc;
struct isi_call_req_context *irc;
 
-   ivc = ofono_voicecall_get_data(ovc);
-
irc = g_try_new0(struct isi_call_req_context, 1);
+   if (irc == NULL) {
+   if (cb)
+   CALLBACK_WITH_FAILURE(cb, data);
+   return NULL;
+   }
 
-   if (irc) {
-   irc-ovc = ovc;
-   irc-cb = cb;
-   irc-data = data;
+   irc-ovc = ovc;
+   irc-cb = cb;
+   irc-data = data;
 
-   if (g_isi_request_make(ivc-client, req, len,
-   ISI_CALL_TIMEOUT, handler, irc))
-   return irc;
-   }
+   return irc;
+}
+
+static struct isi_call_req_context *isi_call_req(struct ofono_voicecall *ovc,
+   void const *restrict req,
+   size_t len,
+   GIsiResponse *handler,
+   ofono_voicecall_cb_t cb,
+   void *data)
+{
+   struct isi_voicecall *ivc;
+   struct isi_call_req_context *irc;
+
+   irc = isi_call_req_new(ovc, cb, data);
+   if (!irc)
+   return NULL;
+
+   ivc = ofono_voicecall_get_data(ovc);
+   if (g_isi_send(ivc-client, req, len,
+   ISI_CALL_TIMEOUT, handler, irc, NULL))
+   return irc;
 
g_free(irc);
 
@@ -125,7 +141,8 @@ isi_call_req(struct ofono_voicecall *ovc,
 }
 
 static void isi_ctx_queue(struct isi_call_req_context *irc,
-   isi_call_req_step *next)
+   isi_call_req_step *next,
+   int id)
 {
if (irc-prev == NULL) {
struct isi_voicecall *ivc = ofono_voicecall_get_data(irc-ovc);
@@ -139,6 +156,7 @@ static void isi_ctx_queue(struct isi_call_req_context *irc,
}
 
irc-step = next;
+   irc-id = id;
 }
 
 static void isi_ctx_remove(struct isi_call_req_context *irc)
@@ -1078,9 +1096,9 @@ static void isi_release_all_active(struct ofono_voicecall 
*ovc,
if (irc == NULL)
;
else if (waiting)
-   isi_ctx_queue(irc, isi_wait_and_answer);
+   isi_ctx_queue(irc, isi_wait_and_answer, 0);
else if (hold)
-   isi_ctx_queue(irc, isi_wait_and_retrieve);
+   isi_ctx_queue(irc, isi_wait_and_retrieve, 0);
} else
CALLBACK_WITH_FAILURE(cb, data);
 }
-- 
1.7.1

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


[isi-voicecall-fix PATCHv3 6/6] isi/voicecall: fix isi_release_all_active()

2010-11-17 Thread Pekka . Pessi
From: Pekka Pessi pekka.pe...@nokia.com

Handle to-be-waiting calls properly.
---
 drivers/isimodem/voicecall.c |   66 +
 1 files changed, 46 insertions(+), 20 deletions(-)

diff --git a/drivers/isimodem/voicecall.c b/drivers/isimodem/voicecall.c
index cdd5d11..360994a 100644
--- a/drivers/isimodem/voicecall.c
+++ b/drivers/isimodem/voicecall.c
@@ -292,6 +292,23 @@ static int isi_call_status_to_clcc(struct isi_voicecall 
const *ivc,
return CLCC_STATUS_ACTIVE;
 }
 
+static gboolean is_call_waiting(struct isi_voicecall const *ivc,
+   struct isi_call const *call)
+{
+   if (!(call-mode_info  CALL_MODE_ORIGINATOR))
+   return FALSE;
+
+   switch (call-status) {
+   case CALL_STATUS_COMING:
+   case CALL_STATUS_PROCEEDING:
+   return isi_call_waiting_or_incoming(ivc) == CLCC_STATUS_WAITING;
+   case CALL_STATUS_WAITING:
+   return TRUE;
+   }
+
+   return FALSE;
+}
+
 static struct ofono_call isi_call_as_ofono_call(struct isi_voicecall const 
*ivc,
struct isi_call const *call)
 {
@@ -1119,35 +1136,40 @@ static isi_call_req_step isi_wait_and_answer, 
isi_wait_and_retrieve;
 static void isi_release_all_active(struct ofono_voicecall *ovc,
ofono_voicecall_cb_t cb, void *data)
 {
-   /* AT+CHLD=1 */
struct isi_voicecall *ivc = ofono_voicecall_get_data(ovc);
-   int id = 0, waiting = 0, active = 0, hold = 0;
+   struct isi_call_req_context *irc;
+   int id;
+   int waiting_id = 0;
+   int active = 0;
+   int hold = 0;
 
for (id = 1; id = 7; id++) {
-   if (ivc-calls[id].call_id  CALL_ID_WAITING)
-   waiting++;
+   if (is_call_waiting(ivc, ivc-calls[id]))
+   waiting_id = id;
+
if (ivc-calls[id].call_id  CALL_ID_HOLD)
hold++;
+
if (ivc-calls[id].call_id  CALL_ID_ACTIVE)
active++;
}
 
-   if (active) {
-   struct isi_call_req_context *irc;
-
-   irc = isi_call_release_req(ovc, CALL_ID_ACTIVE,
-   CALL_CAUSE_TYPE_CLIENT,
-   CALL_CAUSE_RELEASE_BY_USER,
-   cb, data);
-
-   if (irc == NULL)
-   ;
-   else if (waiting)
-   isi_ctx_queue(irc, isi_wait_and_answer, 0);
-   else if (hold)
-   isi_ctx_queue(irc, isi_wait_and_retrieve, 0);
-   } else
+   if (!active) {
CALLBACK_WITH_FAILURE(cb, data);
+   return;
+   }
+
+   irc = isi_call_release_req(ovc, CALL_ID_ACTIVE,
+   CALL_CAUSE_TYPE_CLIENT,
+   CALL_CAUSE_RELEASE_BY_USER,
+   cb, data);
+   if (!irc)
+   return;
+
+   if (waiting_id)
+   isi_ctx_queue(irc, isi_wait_and_answer, waiting_id);
+   else if (hold)
+   isi_ctx_queue(irc, isi_wait_and_retrieve, 0);
 }
 
 static void isi_wait_and_answer(struct isi_call_req_context *irc,
@@ -1155,8 +1177,10 @@ static void isi_wait_and_answer(struct 
isi_call_req_context *irc,
 {
DBG(irc=%p event=%u, (void *)irc, event);
switch (event) {
+   case CALL_STATUS_MO_RELEASE:
+   case CALL_STATUS_MT_RELEASE:
case CALL_STATUS_TERMINATED:
-   isi_answer(irc-ovc, irc-cb, irc-data);
+   isi_call_answer_req(irc-ovc, irc-id, irc-cb, irc-data);
isi_ctx_free(irc);
break;
}
@@ -1167,6 +1191,8 @@ static void isi_wait_and_retrieve(struct 
isi_call_req_context *irc,
 {
DBG(irc=%p event=%u, (void *)irc, event);
switch (event) {
+   case CALL_STATUS_MO_RELEASE:
+   case CALL_STATUS_MT_RELEASE:
case CALL_STATUS_TERMINATED:
isi_retrieve(irc-ovc, irc-cb, irc-data);
isi_ctx_free(irc);
-- 
1.7.1

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


[PATCH 1/3] Add ofono_modem_reset()

2010-11-17 Thread Gustavo F. Padovan
Some modems can screw up everything and then we will need to do a silent
reset of the modem. This patch take the modem back to the OFFLINE state.
---
 include/modem.h |2 ++
 src/modem.c |   44 +++-
 2 files changed, 45 insertions(+), 1 deletions(-)

diff --git a/include/modem.h b/include/modem.h
index 7b13ee0..a92eb88 100644
--- a/include/modem.h
+++ b/include/modem.h
@@ -46,6 +46,8 @@ int ofono_modem_register(struct ofono_modem *modem);
 ofono_bool_t ofono_modem_is_registered(struct ofono_modem *modem);
 void ofono_modem_remove(struct ofono_modem *modem);
 
+void ofono_modem_reset(struct ofono_modem *modem);
+
 void ofono_modem_set_powered(struct ofono_modem *modem, ofono_bool_t powered);
 ofono_bool_t ofono_modem_get_powered(struct ofono_modem *modem);
 
diff --git a/src/modem.c b/src/modem.c
index 6d346c3..e57f8fc 100644
--- a/src/modem.c
+++ b/src/modem.c
@@ -70,6 +70,7 @@ struct ofono_modem {
guint   interface_update;
ofono_bool_tpowered;
ofono_bool_tpowered_pending;
+   ofono_bool_treset;
guint   timeout;
ofono_bool_tonline;
GHashTable  *properties;
@@ -433,6 +434,8 @@ static void sim_state_watch(enum ofono_sim_state new_state, 
void *user)
if (modem-driver-set_online == NULL)
modem_change_state(modem, MODEM_STATE_ONLINE);
 
+   modem-reset = FALSE;
+
break;
}
 }
@@ -784,7 +787,8 @@ void ofono_modem_set_powered(struct ofono_modem *modem, 
ofono_bool_t powered)
return;
}
 
-   ofono_dbus_signal_property_changed(conn, modem-path,
+   if (!modem-reset)
+   ofono_dbus_signal_property_changed(conn, modem-path,
OFONO_MODEM_INTERFACE,
Powered, DBUS_TYPE_BOOLEAN,
dbus_powered);
@@ -799,6 +803,17 @@ void ofono_modem_set_powered(struct ofono_modem *modem, 
ofono_bool_t powered)
} else
modem_change_state(modem, MODEM_STATE_POWER_OFF);
 
+   if (modem-reset  !powering_down) {
+   if (!modem-powered) {
+   int err = set_powered(modem, TRUE);
+
+   if (err == -EINPROGRESS)
+   return;
+
+   modem_change_state(modem, MODEM_STATE_PRE_SIM);
+   }
+   }
+
 out:
if (powering_down  powered == FALSE) {
modems_remaining -= 1;
@@ -806,6 +821,7 @@ out:
if (modems_remaining == 0)
__ofono_exit();
}
+
 }
 
 ofono_bool_t ofono_modem_get_powered(struct ofono_modem *modem)
@@ -1565,6 +1581,32 @@ void ofono_modem_remove(struct ofono_modem *modem)
g_free(modem);
 }
 
+static gboolean __reset_modem(void *data)
+{
+   struct ofono_modem *modem = data;
+   int err;
+
+   modem-reset = TRUE;
+
+   err = set_powered(modem, FALSE);
+   if (err == -EINPROGRESS)
+   return FALSE;
+
+   err = set_powered(modem, TRUE);
+   if (err == -EINPROGRESS)
+   return FALSE;
+
+   modem_change_state(modem, MODEM_STATE_PRE_SIM);
+   return FALSE;
+}
+
+void ofono_modem_reset(struct ofono_modem *modem)
+{
+   DBG(%p, modem);
+
+   g_idle_add(__reset_modem, modem);
+}
+
 int ofono_modem_driver_register(const struct ofono_modem_driver *d)
 {
DBG(driver: %p, name: %s, d, d-name);
-- 
1.7.3.1

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


[PATCH 3/3] modem: add support to restore state when resetting the modem

2010-11-17 Thread Gustavo F. Padovan
---
 src/modem.c |   72 --
 1 files changed, 40 insertions(+), 32 deletions(-)

diff --git a/src/modem.c b/src/modem.c
index e57f8fc..95b5efa 100644
--- a/src/modem.c
+++ b/src/modem.c
@@ -61,6 +61,7 @@ enum modem_state {
 struct ofono_modem {
char*path;
enum modem_statemodem_state;
+   enum modem_stateold_state;
GSList  *atoms;
struct ofono_watchlist  *atom_watches;
GSList  *interface_list;
@@ -414,48 +415,26 @@ static void modem_change_state(struct ofono_modem *modem,
}
 }
 
-static void sim_state_watch(enum ofono_sim_state new_state, void *user)
-{
-   struct ofono_modem *modem = user;
-
-   switch (new_state) {
-   case OFONO_SIM_STATE_NOT_PRESENT:
-   modem_change_state(modem, MODEM_STATE_PRE_SIM);
-   break;
-   case OFONO_SIM_STATE_INSERTED:
-   break;
-   case OFONO_SIM_STATE_READY:
-   modem_change_state(modem, MODEM_STATE_OFFLINE);
-
-   /*
-* If we don't have the set_online method, also proceed
-* straight to the online state
-*/
-   if (modem-driver-set_online == NULL)
-   modem_change_state(modem, MODEM_STATE_ONLINE);
-
-   modem-reset = FALSE;
-
-   break;
-   }
-}
-
 static void online_cb(const struct ofono_error *error, void *data)
 {
struct ofono_modem *modem = data;
DBusMessage *reply;
 
if (error-type == OFONO_ERROR_TYPE_NO_ERROR 
-   modem-modem_state == MODEM_STATE_OFFLINE)
+   modem-modem_state == MODEM_STATE_OFFLINE) {
+   modem_change_state(modem, MODEM_STATE_ONLINE);
+
+   if (modem-reset) {
+   modem-reset = FALSE;
+   return;
+   }
+
reply = dbus_message_new_method_return(modem-pending);
-   else
+   } else {
reply = __ofono_error_failed(modem-pending);
+   }
 
__ofono_dbus_pending_reply(modem-pending, reply);
-
-   if (error-type == OFONO_ERROR_TYPE_NO_ERROR 
-   modem-modem_state == MODEM_STATE_OFFLINE)
-   modem_change_state(modem, MODEM_STATE_ONLINE);
 }
 
 static void offline_cb(const struct ofono_error *error, void *data)
@@ -475,6 +454,34 @@ static void offline_cb(const struct ofono_error *error, 
void *data)
modem_change_state(modem, MODEM_STATE_OFFLINE);
 }
 
+static void sim_state_watch(enum ofono_sim_state new_state, void *user)
+{
+   struct ofono_modem *modem = user;
+
+   switch (new_state) {
+   case OFONO_SIM_STATE_NOT_PRESENT:
+   modem_change_state(modem, MODEM_STATE_PRE_SIM);
+   break;
+   case OFONO_SIM_STATE_INSERTED:
+   break;
+   case OFONO_SIM_STATE_READY:
+   modem_change_state(modem, MODEM_STATE_OFFLINE);
+
+   /*
+* If we don't have the set_online method, also proceed
+* straight to the online state
+*/
+   if (modem-driver-set_online == NULL)
+   modem_change_state(modem, MODEM_STATE_ONLINE);
+   else if (modem-old_state  MODEM_STATE_OFFLINE)
+   modem-driver-set_online(modem, 1, online_cb, modem);
+   else
+   modem-reset = FALSE;
+
+   break;
+   }
+}
+
 static DBusMessage *set_property_online(struct ofono_modem *modem,
DBusMessage *msg,
DBusMessageIter *var)
@@ -1586,6 +1593,7 @@ static gboolean __reset_modem(void *data)
struct ofono_modem *modem = data;
int err;
 
+   modem-old_state = modem-modem_state;
modem-reset = TRUE;
 
err = set_powered(modem, FALSE);
-- 
1.7.3.1

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


[PATCH 2/3] phonesim: Add modem reset trigger

2010-11-17 Thread Gustavo F. Padovan
---
 plugins/phonesim.c |   10 ++
 1 files changed, 10 insertions(+), 0 deletions(-)

diff --git a/plugins/phonesim.c b/plugins/phonesim.c
index d2faf42..7426da6 100644
--- a/plugins/phonesim.c
+++ b/plugins/phonesim.c
@@ -237,6 +237,13 @@ static void cfun_set_on_cb(gboolean ok, GAtResult *result, 
gpointer user_data)
ofono_modem_set_powered(modem, ok);
 }
 
+static void crst_notify(GAtResult *result, gpointer user_data)
+{
+   struct ofono_modem *modem = user_data;
+
+   ofono_modem_reset(modem);
+}
+
 static void phonesim_disconnected(gpointer user_data)
 {
struct ofono_modem *modem = user_data;
@@ -389,6 +396,9 @@ static int phonesim_enable(struct ofono_modem *modem)
g_at_chat_send(data-chat, AT+CSCS=\GSM\, none_prefix,
NULL, NULL, NULL);
 
+   g_at_chat_register(data-chat, +CRST:,
+   crst_notify, FALSE, modem, NULL);
+
return 0;
 }
 
-- 
1.7.3.1

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


[PATCH 1/3] Add TTY (hearing impaired) support

2010-11-17 Thread Lucas De Marchi
---
 Makefile.am  |5 +-
 include/dbus.h   |1 +
 include/text-telephony.h |   71 ++
 src/modem.c  |1 +
 src/ofono.h  |2 +
 src/text-telephony.c |  333 ++
 6 files changed, 411 insertions(+), 2 deletions(-)
 create mode 100644 include/text-telephony.h
 create mode 100644 src/text-telephony.c

diff --git a/Makefile.am b/Makefile.am
index f841b4c..ee1313d 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -13,7 +13,8 @@ include_HEADERS = include/log.h include/plugin.h 
include/history.h \
include/cbs.h include/call-volume.h \
include/gprs.h include/gprs-context.h \
include/radio-settings.h include/stk.h \
-   include/audio-settings.h include/nettime.h
+   include/audio-settings.h include/nettime.h \
+   include/text-telephony.h
 
 nodist_include_HEADERS = include/version.h
 
@@ -318,7 +319,7 @@ src_ofonod_SOURCES = $(gdbus_sources) $(builtin_sources) 
src/ofono.ver \
src/radio-settings.c src/stkutil.h src/stkutil.c \
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/smsagent.c src/smsagent.h src/text-telephony.c
 
 src_ofonod_LDADD = $(builtin_libadd) @GLIB_LIBS@ @DBUS_LIBS@ @CAPNG_LIBS@ -ldl
 
diff --git a/include/dbus.h b/include/dbus.h
index 59b2aae..9e29afb 100644
--- a/include/dbus.h
+++ b/include/dbus.h
@@ -48,6 +48,7 @@ extern C {
 #define OFONO_PHONEBOOK_INTERFACE org.ofono.Phonebook
 #define OFONO_RADIO_SETTINGS_INTERFACE org.ofono.RadioSettings
 #define OFONO_AUDIO_SETTINGS_INTERFACE org.ofono.AudioSettings
+#define OFONO_TEXT_TELEPHONY_INTERFACE org.ofono.TextTelephony
 #define OFONO_SIM_MANAGER_INTERFACE org.ofono.SimManager
 #define OFONO_VOICECALL_INTERFACE org.ofono.VoiceCall
 #define OFONO_VOICECALL_MANAGER_INTERFACE org.ofono.VoiceCallManager
diff --git a/include/text-telephony.h b/include/text-telephony.h
new file mode 100644
index 000..fafa7dd
--- /dev/null
+++ b/include/text-telephony.h
@@ -0,0 +1,71 @@
+/*
+ *
+ *  oFono - Open Source Telephony
+ *
+ *  Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+ *  Copyright (C) 2010  Intel 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
+ *
+ */
+
+#ifndef __OFONO_TEXT_TELEPHONY_H
+#define __OFONO_TEXT_TELEPHONY_H
+
+#ifdef __cplusplus
+extern C {
+#endif
+
+#include ofono/types.h
+
+struct ofono_text_telephony;
+
+typedef void (*ofono_text_telephony_set_cb_t)(const struct ofono_error *error,
+   void *data);
+typedef void (*ofono_text_telephony_query_cb_t)(const struct ofono_error 
*error,
+   ofono_bool_t enable, void 
*data);
+
+struct ofono_text_telephony_driver {
+   const char *name;
+   int (*probe)(struct ofono_text_telephony *tt, unsigned int vendor,
+   void *data);
+   void (*remove)(struct ofono_text_telephony *tt);
+   void (*query_tty)(struct ofono_text_telephony *tt,
+   ofono_text_telephony_query_cb_t cb,
+   void *data);
+   void (*set_tty)(struct ofono_text_telephony *tt,
+   int enable,
+   ofono_text_telephony_set_cb_t cb,
+   void *data);
+};
+
+int ofono_text_telephony_driver_register(const struct 
ofono_text_telephony_driver *d);
+void ofono_text_telephony_driver_unregister(const struct 
ofono_text_telephony_driver *d);
+
+struct ofono_text_telephony *ofono_text_telephony_create(struct ofono_modem 
*modem,
+   unsigned int 
vendor,
+   const char 
*driver,
+   void *data);
+
+void ofono_text_telephony_register(struct ofono_text_telephony *tt);
+void ofono_text_telephony_remove(struct ofono_text_telephony *tt);
+
+void ofono_text_telephony_set_data(struct ofono_text_telephony *tt, void 

[PATCH] Add responses for TTY commands

2010-11-17 Thread Lucas De Marchi
---
 src/default.xml |   16 
 1 files changed, 16 insertions(+), 0 deletions(-)

diff --git a/src/default.xml b/src/default.xml
index e16e18d..216b2b8 100644
--- a/src/default.xml
+++ b/src/default.xml
@@ -301,6 +301,9 @@
 !-- CGSMS Bearer control --
 set name=CGSMS value=3/
 
+!-- TTY (hearing impared) state --
+set name=PTTY value=1 /
+
 !-- Time --
 !-- Enable for testing
 unsolicited delay=3000 once=true*TTZ: 2, 11/25/2007, 12:12:12+40, 
0/unsolicited
@@ -3207,6 +3210,19 @@ Z
 OK/response
 /chat
 
+chat
+!-- Set TTY (hearing impaired) set --
+commandAT+PTTY=*/command
+responseOK/response
+set name=PTTY value=*/
+/chat
+
+chat
+!-- Query TTY (hearing impaired) state --
+commandAT+PTTY?/command
+response+PTTY: ${PTTY}\n\nOK/response
+/chat
+
 !-- SIM filesystem definition, based on standard test strings
  presented in GSM 11.10-4.  This is primarily intended for
  testing icon definitions within SIM toolkit applications --
-- 
1.7.3.2

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


[PATCH 2/3] phonesim: implement TTY interface

2010-11-17 Thread Lucas De Marchi
---
 plugins/phonesim.c |  148 ++--
 1 files changed, 144 insertions(+), 4 deletions(-)

diff --git a/plugins/phonesim.c b/plugins/phonesim.c
index d2faf42..8c31df4 100644
--- a/plugins/phonesim.c
+++ b/plugins/phonesim.c
@@ -54,6 +54,7 @@
 #include ofono/stk.h
 #include ofono/sms.h
 #include ofono/ssn.h
+#include ofono/text-telephony.h
 #include ofono/ussd.h
 #include ofono/voicecall.h
 #include ofono/gprs.h
@@ -64,6 +65,7 @@
 #include drivers/atmodem/atutil.h
 
 static const char *none_prefix[] = { NULL };
+static const char *ptty_prefix[] = { +PTTY:, NULL };
 static int next_iface = 0;
 
 struct phonesim_data {
@@ -78,6 +80,11 @@ struct gprs_context_data {
char *interface;
 };
 
+struct text_telephony_data {
+   GAtChat *chat;
+   char *interface;
+};
+
 static void at_cgact_up_cb(gboolean ok, GAtResult *result, gpointer user_data)
 {
struct cb_data *cbd = user_data;
@@ -190,12 +197,140 @@ static void phonesim_context_remove(struct 
ofono_gprs_context *gc)
g_free(gcd);
 }
 
+static int phonesim_tty_probe(struct ofono_text_telephony *tt,
+   unsigned int vendor, void *data)
+{
+   GAtChat *chat = data;
+   struct text_telephony_data *ttd;
+
+   ttd = g_try_new0(struct text_telephony_data, 1);
+   if (!ttd)
+   return -ENOMEM;
+
+   ttd-chat = g_at_chat_clone(chat);
+   ttd-interface = g_strdup_printf(dummy%d, next_iface++);
+
+   ofono_text_telephony_set_data(tt, ttd);
+   ofono_text_telephony_register(tt);
+
+   return 0;
+}
+
+static void phonesim_tty_remove(struct ofono_text_telephony *tt)
+{
+   struct text_telephony_data *ttd = ofono_text_telephony_get_data(tt);
+
+   DBG();
+
+   ofono_text_telephony_set_data(tt, NULL);
+
+   g_at_chat_unref(ttd-chat);
+   g_free(ttd-interface);
+
+   g_free(ttd);
+}
+
+static void tty_query_cb(gboolean ok, GAtResult *result, gpointer user_data)
+{
+   struct cb_data *cbd = user_data;
+   struct ofono_error error;
+   GAtResultIter iter;
+   ofono_text_telephony_query_cb_t cb = cbd-cb;
+   int value;
+
+   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, +PTTY:) == FALSE)
+   goto error;
+
+   if (g_at_result_iter_next_number(iter, value) == FALSE)
+   goto error;
+
+   cb(error, value, cbd-data);
+
+   return;
+
+error:
+
+   CALLBACK_WITH_FAILURE(cb, -1, cbd-data);
+}
+
+static void phonesim_tty_query(struct ofono_text_telephony *tt,
+   ofono_text_telephony_query_cb_t cb, void *data)
+{
+   struct text_telephony_data *ttd = ofono_text_telephony_get_data(tt);
+   struct cb_data *cbd = cb_data_new(cb, data);
+
+   DBG();
+
+   if (!cbd)
+   goto error;
+
+   if (g_at_chat_send(ttd-chat, AT+PTTY?, ptty_prefix,
+   tty_query_cb, cbd, g_free)  0)
+   return;
+
+error:
+   g_free(cbd);
+
+   CALLBACK_WITH_FAILURE(cb, 0, data);
+}
+
+static void tty_set_cb(gboolean ok, GAtResult *result, gpointer user_data)
+{
+   struct cb_data *cbd = user_data;
+   ofono_text_telephony_set_cb_t cb = cbd-cb;
+   struct ofono_error error;
+
+   decode_at_error(error, g_at_result_final_response(result));
+   cb(error, cbd-data);
+}
+
+static void phonesim_tty_set(struct ofono_text_telephony *tt, int enable,
+   ofono_text_telephony_set_cb_t cb, void *data)
+{
+   struct text_telephony_data *ttd = ofono_text_telephony_get_data(tt);
+   struct cb_data *cbd = cb_data_new(cb, data);
+   char buf[12];
+
+   DBG();
+
+   if (!cbd)
+   goto error;
+
+   enable = !!enable;
+   snprintf(buf, sizeof(buf), AT+PTTY=%d, enable);
+
+   if (g_at_chat_send(ttd-chat, buf, none_prefix,
+   tty_set_cb, cbd, g_free)  0)
+   return;
+
+error:
+   CALLBACK_WITH_FAILURE(cb, data);
+   g_free(cbd);
+}
+
 static struct ofono_gprs_context_driver context_driver = {
+   .name   = phonesim,
+   .probe  = phonesim_context_probe,
+   .remove = phonesim_context_remove,
+   .activate_primary   = phonesim_activate_primary,
+   .deactivate_primary = phonesim_deactivate_primary,
+};
+
+static struct ofono_text_telephony_driver tty_driver = {
.name   = phonesim,
-   .probe  = phonesim_context_probe,
-   .remove = phonesim_context_remove,
-   .activate_primary   = phonesim_activate_primary,
-   .deactivate_primary = phonesim_deactivate_primary,
+   .probe  = 

[PATCH 3/3] Add script to enable/disable TTY support

2010-11-17 Thread Lucas De Marchi
---
 test/set-tty |   25 +
 1 files changed, 25 insertions(+), 0 deletions(-)
 create mode 100755 test/set-tty

diff --git a/test/set-tty b/test/set-tty
new file mode 100755
index 000..cbbb043
--- /dev/null
+++ b/test/set-tty
@@ -0,0 +1,25 @@
+#!/usr/bin/python
+
+import dbus
+import sys
+
+bus = dbus.SystemBus()
+
+if len(sys.argv) == 3:
+   path = sys.argv[1]
+   enable = int(sys.argv[2])
+elif len(sys.argv) == 2:
+   manager = dbus.Interface(bus.get_object('org.ofono', '/'),
+   'org.ofono.Manager')
+   modems = manager.GetModems()
+   path = modems[0][0]
+   enable = int(sys.argv[1])
+else:
+   print %s [PATH] {0|1} % (sys.argv[0])
+   exit(1)
+
+print Setting TTY for modem %s... % path
+texttelephony = dbus.Interface(bus.get_object('org.ofono', path),
+   'org.ofono.TextTelephony')
+
+texttelephony.SetProperty(Powered, dbus.Boolean(enable));
-- 
1.7.3.2

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


Re: [PATCH] ifxmodem: Adding fast dormancy support to Infineon modem

2010-11-17 Thread Marcel Holtmann
Hi Robertino,

 Initial patch to add fast dormancy to Infineon modem. Timeout is not
 supported yet.
 
 Thanks,
 -- r.
 
 ---
  drivers/ifxmodem/radio-settings.c |   40 
 -
  1 files changed, 39 insertions(+), 1 deletions(-)
 
 diff --git a/drivers/ifxmodem/radio-settings.c 
 b/drivers/ifxmodem/radio-settings.c
 index 89e97e7..68077db 100644
 --- a/drivers/ifxmodem/radio-settings.c
 +++ b/drivers/ifxmodem/radio-settings.c
 @@ -27,6 +27,7 @@
  #include string.h
  #include stdlib.h
  #include stdio.h
 +#include stdint.h
  #include errno.h
  
  #include glib.h
 @@ -45,6 +46,7 @@ static const char *xrat_prefix[] = { +XRAT:, NULL };
  
  struct radio_settings_data {
   GAtChat *chat;
 + uint16_t fast_dormancy;
  };
  
  static void xrat_query_cb(gboolean ok, GAtResult *result, gpointer user_data)
 @@ -196,12 +198,48 @@ static void ifx_radio_settings_remove(struct 
 ofono_radio_settings *rs)
   g_free(rsd);
  }
  
 +static void update_fast_dormancy(struct radio_settings_data *rsd)
 +{
 + char buf[20];
 +
 + snprintf(buf, sizeof(buf), AT+XFDOR=%u, rsd-fast_dormancy);

is this command for fast dormancy really doing exactly what is expected
according to doc/radio-settings.txt. In my last documentation from
Infineon, that is still not the case.

Regards

Marcel


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


Re: [PATCH 1/3] Add TTY (hearing impaired) support

2010-11-17 Thread Marcel Holtmann
Hi Lucas,

  Makefile.am  |5 +-
  include/dbus.h   |1 +
  include/text-telephony.h |   71 ++
  src/modem.c  |1 +
  src/ofono.h  |2 +
  src/text-telephony.c |  333 
 ++
  6 files changed, 411 insertions(+), 2 deletions(-)
  create mode 100644 include/text-telephony.h
  create mode 100644 src/text-telephony.c

did I miss the patch for doc/text-telephony.txt?

Regards

Marcel


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