[PATCH 1/6] Add STK agent utilities and logic.
by Andrzej Zaborowski
---
Makefile.am | 2 +-
src/stkagent.c | 294 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++
src/stkagent.h | 46 +++++++++
3 files changed, 341 insertions(+), 1 deletions(-)
create mode 100644 src/stkagent.c
create mode 100644 src/stkagent.h
diff --git a/Makefile.am b/Makefile.am
index e256841..0e9086b 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -270,7 +270,7 @@ src_ofonod_SOURCES = $(gdbus_sources) $(builtin_sources) \
src/storage.c src/cbs.c src/watch.c src/call-volume.c \
src/gprs.c src/idmap.h src/idmap.c \
src/radio-settings.c src/stkutil.h src/stkutil.c \
- src/nettime.c
+ src/nettime.c src/stkagent.c src/stkagent.h
src_ofonod_LDADD = $(builtin_libadd) @GLIB_LIBS@ @DBUS_LIBS@ @CAPNG_LIBS@ -ldl
diff --git a/src/stkagent.c b/src/stkagent.c
new file mode 100644
index 0000000..8feda6d
--- /dev/null
+++ b/src/stkagent.c
@@ -0,0 +1,293 @@
+/*
+ *
+ * oFono - Open Source Telephony
+ *
+ * Copyright (C) 2008-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
+ *
+ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#define _GNU_SOURCE
+#include <stdint.h>
+#include <string.h>
+
+#include <glib.h>
+#include <gdbus.h>
+
+#include "ofono.h"
+
+#include "stkagent.h"
+
+typedef void (*app_agent_request_return)(struct stk_app_agent *agent,
+ enum stk_agent_result result,
+ DBusMessage *reply);
+
+struct stk_app_agent {
+ char *path;
+ char *bus;
+ DBusMessage *msg;
+ DBusPendingCall *call;
+ guint disconnect_watch;
+ guint cmd_send_source;
+ app_agent_request_return cmd_cb;
+ int cmd_timeout;
+ app_agent_generic_cb user_cb;
+ void *data;
+ ofono_bool_t is_default;
+ GDestroyNotify notify;
+};
+
+#define OFONO_NAVIGATION_PREFIX OFONO_SERVICE ".Error"
+#define OFONO_NAVIGATION_GOBACK OFONO_NAVIGATION_PREFIX ".GoBack"
+#define OFONO_NAVIGATION_TERMINATED OFONO_NAVIGATION_PREFIX ".EndSession"
+
+static void app_agent_request_send_cancel(struct stk_app_agent *agent)
+{
+ DBusConnection *conn = ofono_dbus_get_connection();
+ DBusMessage *message;
+
+ message = dbus_message_new_method_call(agent->bus, agent->path,
+ OFONO_SIM_APP_INTERFACE,
+ "Cancel");
+ if (message == NULL)
+ return;
+
+ dbus_message_set_no_reply(message, TRUE);
+
+ g_dbus_send_message(conn, message);
+}
+
+static void app_agent_request_end(struct stk_app_agent *agent)
+{
+ agent->cmd_cb = NULL;
+
+ if (agent->cmd_send_source) {
+ g_source_remove(agent->cmd_send_source);
+ agent->cmd_send_source = 0;
+ }
+
+ if (agent->msg) {
+ dbus_message_unref(agent->msg);
+ agent->msg = NULL;
+ }
+
+ if (agent->call) {
+ dbus_pending_call_cancel(agent->call);
+ dbus_pending_call_unref(agent->call);
+ agent->call = NULL;
+ }
+}
+
+ofono_bool_t app_agent_busy(struct stk_app_agent *agent)
+{
+ return agent->cmd_cb != NULL;
+}
+
+ofono_bool_t app_agent_matches(struct stk_app_agent *agent,
+ const char *path, const char *sender)
+{
+ return !strcmp(agent->path, path) && !strcmp(agent->bus, sender);
+}
+
+void app_agent_request_cancel(struct stk_app_agent *agent)
+{
+ if (!app_agent_busy(agent))
+ return;
+
+ agent->cmd_cb(agent, STK_AGENT_RESULT_CANCEL, NULL);
+
+ app_agent_request_end(agent);
+
+ app_agent_request_send_cancel(agent);
+}
+
+static void app_agent_request_terminate(struct stk_app_agent *agent)
+{
+ agent->cmd_cb(agent, STK_AGENT_RESULT_TERMINATE, NULL);
+
+ app_agent_request_end(agent);
+}
+
+void app_agent_remove(struct stk_app_agent *agent)
+{
+ DBusConnection *conn = ofono_dbus_get_connection();
+
+ if (agent->disconnect_watch) {
+ DBusMessage *message;
+
+ if (app_agent_busy(agent)) {
+ app_agent_request_terminate(agent);
+
+ app_agent_request_send_cancel(agent);
+ }
+
+ message = dbus_message_new_method_call(agent->bus, agent->path,
+ OFONO_SIM_APP_INTERFACE,
+ "Release");
+ if (message) {
+ dbus_message_set_no_reply(message, TRUE);
+
+ g_dbus_send_message(conn, message);
+ }
+
+ g_dbus_remove_watch(conn, agent->disconnect_watch);
+ agent->disconnect_watch = 0;
+ } else {
+ if (app_agent_busy(agent))
+ app_agent_request_terminate(agent);
+ }
+
+ if (agent->notify)
+ agent->notify(agent->data);
+
+ g_free(agent->path);
+ g_free(agent->bus);
+ g_free(agent);
+}
+
+static void app_agent_request_reply_handle(DBusPendingCall *call, void *data)
+{
+ struct stk_app_agent *agent = data;
+ DBusError err;
+ DBusMessage *reply = dbus_pending_call_steal_reply(call);
+ enum stk_agent_result result = STK_AGENT_RESULT_OK;
+
+ dbus_error_init(&err);
+ if (dbus_set_error_from_message(&err, reply)) {
+ ofono_error("SimAppAgent %s replied with error %s, %s",
+ agent->path, err.name, err.message);
+
+ if (g_str_equal(err.name, DBUS_ERROR_NO_REPLY))
+ result = STK_AGENT_RESULT_TIMEOUT;
+ if (g_str_equal(err.name, OFONO_NAVIGATION_GOBACK))
+ result = STK_AGENT_RESULT_BACK;
+ else
+ result = STK_AGENT_RESULT_TERMINATE;
+
+ dbus_error_free(&err);
+ }
+
+ agent->cmd_cb(agent, result, reply);
+
+ app_agent_request_end(agent);
+
+ dbus_message_unref(reply);
+
+ if (result != STK_AGENT_RESULT_TERMINATE)
+ return;
+
+ if (agent->is_default)
+ return;
+
+ app_agent_remove(agent);
+}
+
+static gboolean app_agent_request_send(gpointer user_data)
+{
+ struct stk_app_agent *agent = user_data;
+ DBusConnection *conn = ofono_dbus_get_connection();
+
+ agent->cmd_send_source = 0;
+
+ if (dbus_connection_send_with_reply(conn, agent->msg, &agent->call,
+ agent->cmd_timeout) == FALSE ||
+ agent->call == NULL) {
+ ofono_error("Couldn't send a method call");
+
+ app_agent_request_terminate(agent);
+
+ return FALSE;
+ }
+
+ dbus_pending_call_set_notify(agent->call,
+ app_agent_request_reply_handle,
+ agent, NULL);
+
+ return FALSE;
+}
+
+static gboolean app_agent_request_start(struct stk_app_agent *agent,
+ const char *method,
+ app_agent_request_return cb,
+ app_agent_generic_cb user_cb,
+ int timeout)
+{
+ if (agent == NULL) {
+ cb(agent, STK_AGENT_RESULT_TERMINATE, NULL);
+
+ return FALSE;
+ }
+
+ agent->msg = dbus_message_new_method_call(agent->bus, agent->path,
+ OFONO_SIM_APP_INTERFACE,
+ method);
+ if (agent->msg == NULL) {
+ ofono_error("Couldn't make a DBusMessage");
+
+ cb(agent, STK_AGENT_RESULT_TERMINATE, NULL);
+
+ return FALSE;
+ }
+
+ if (app_agent_busy(agent))
+ app_agent_request_cancel(agent);
+
+ agent->cmd_cb = cb;
+ agent->cmd_timeout = timeout;
+ agent->user_cb = user_cb;
+
+ agent->cmd_send_source = g_timeout_add(0, app_agent_request_send,
+ agent);
+
+ return TRUE;
+}
+
+static void app_agent_disconnect_cb(DBusConnection *conn, void *user_data)
+{
+ struct stk_app_agent *agent = user_data;
+
+ ofono_debug("Agent exited without calling Unregister");
+
+ agent->disconnect_watch = 0;
+
+ app_agent_remove(user_data);
+}
+
+struct stk_app_agent *app_agent_create(const char *path, const char *sender,
+ ofono_bool_t is_default,
+ void *user_data, GDestroyNotify notify)
+{
+ struct stk_app_agent *agent = g_try_new0(struct stk_app_agent, 1);
+ DBusConnection *conn = ofono_dbus_get_connection();
+
+ if (!agent)
+ return NULL;
+
+ agent->path = g_strdup(path);
+ agent->bus = g_strdup(sender);
+ agent->data = user_data;
+ agent->notify = notify;
+ agent->is_default = is_default;
+
+ agent->disconnect_watch = g_dbus_add_disconnect_watch(conn, sender,
+ app_agent_disconnect_cb,
+ agent, NULL);
+
+ return agent;
+}
diff --git a/src/stkagent.h b/src/stkagent.h
new file mode 100644
index 0000000..23a65fc
--- /dev/null
+++ b/src/stkagent.h
@@ -0,0 +1,46 @@
+/*
+ *
+ * oFono - Open Source Telephony
+ *
+ * Copyright (C) 2008-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
+ *
+ */
+
+enum stk_agent_result {
+ STK_AGENT_RESULT_OK,
+ STK_AGENT_RESULT_BACK,
+ STK_AGENT_RESULT_TERMINATE,
+ STK_AGENT_RESULT_HELP,
+ STK_AGENT_RESULT_TIMEOUT,
+ STK_AGENT_RESULT_CANCEL,
+};
+
+typedef void (*app_agent_generic_cb)(enum stk_agent_result result,
+ void *user_data);
+
+struct stk_app_agent;
+
+struct stk_app_agent *app_agent_create(const char *path, const char *sender,
+ ofono_bool_t is_default,
+ void *user_data, GDestroyNotify notify);
+
+void app_agent_remove(struct stk_app_agent *agent);
+
+ofono_bool_t app_agent_busy(struct stk_app_agent *agent);
+ofono_bool_t app_agent_matches(struct stk_app_agent *agent,
+ const char *path, const char *sender);
+
+void app_agent_request_cancel(struct stk_app_agent *agent);
--
1.7.1.86.g0e460.dirty
10 years, 5 months
[PATCH] sim: allow partial reads of tranparent files
by Kristen Carlson Accardi
Implement ofono_sim_read_bytes(). For transparent files, this
will read num_bytes from a specified offset of a given fileid.
---
include/sim.h | 5 +++++
src/sim.c | 29 ++++++++++++++++++++++++++---
2 files changed, 31 insertions(+), 3 deletions(-)
diff --git a/include/sim.h b/include/sim.h
index 36a99b9..15cd6b8 100644
--- a/include/sim.h
+++ b/include/sim.h
@@ -198,6 +198,11 @@ int ofono_sim_read(struct ofono_sim *sim, int id,
enum ofono_sim_file_structure expected,
ofono_sim_file_read_cb_t cb, void *data);
+int ofono_sim_read_bytes(struct ofono_sim *sim, int id,
+ enum ofono_sim_file_structure expected,
+ unsigned short offset, int num_bytes,
+ ofono_sim_file_read_cb_t cb, void *data);
+
int ofono_sim_write(struct ofono_sim *sim, int id,
ofono_sim_file_write_cb_t cb,
enum ofono_sim_file_structure structure, int record,
diff --git a/src/sim.c b/src/sim.c
index 2514e7b..cd1cbf5 100644
--- a/src/sim.c
+++ b/src/sim.c
@@ -60,6 +60,8 @@ struct sim_file_op {
int id;
gboolean cache;
enum ofono_sim_file_structure structure;
+ unsigned short offset;
+ int num_bytes;
int length;
int record_length;
int current;
@@ -1434,7 +1436,7 @@ static void sim_op_retrieve_cb(const struct ofono_error *error,
return;
}
- cb(1, op->length, op->current, data, op->record_length, op->userdata);
+ cb(1, len, op->current, data, op->record_length, op->userdata);
if (op->cache && imsi) {
char *path = g_strdup_printf(SIM_CACHE_PATH,
@@ -1472,7 +1474,16 @@ static gboolean sim_op_retrieve_next(gpointer user)
return FALSE;
}
- sim->driver->read_file_transparent(sim, op->id, 0, op->length,
+ if (op->offset + op->num_bytes > op->length) {
+ sim_op_error(sim);
+ return FALSE;
+ }
+
+ if (op->num_bytes < 0)
+ op->num_bytes = op->length;
+
+ sim->driver->read_file_transparent(sim, op->id, op->offset,
+ op->num_bytes,
sim_op_retrieve_cb, sim);
break;
case OFONO_SIM_FILE_STRUCTURE_FIXED:
@@ -1723,8 +1734,9 @@ static gboolean sim_op_next(gpointer user_data)
return FALSE;
}
-int ofono_sim_read(struct ofono_sim *sim, int id,
+int ofono_sim_read_bytes(struct ofono_sim *sim, int id,
enum ofono_sim_file_structure expected_type,
+ unsigned short offset, int num_bytes,
ofono_sim_file_read_cb_t cb, void *data)
{
struct sim_file_op *op;
@@ -1755,6 +1767,10 @@ int ofono_sim_read(struct ofono_sim *sim, int id,
op->cb = cb;
op->userdata = data;
op->is_read = TRUE;
+ op->offset = offset;
+
+ if (num_bytes > 0)
+ op->num_bytes = num_bytes;
g_queue_push_tail(sim->simop_q, op);
@@ -1764,6 +1780,13 @@ int ofono_sim_read(struct ofono_sim *sim, int id,
return 0;
}
+int ofono_sim_read(struct ofono_sim *sim, int id,
+ enum ofono_sim_file_structure expected_type,
+ ofono_sim_file_read_cb_t cb, void *data)
+{
+ return ofono_sim_read_bytes(sim, id, expected_type, 0, -1, cb, data);
+}
+
int ofono_sim_write(struct ofono_sim *sim, int id,
ofono_sim_file_write_cb_t cb,
enum ofono_sim_file_structure structure, int record,
--
1.7.1.1
10 years, 5 months
[PATCH v2] Fix busylooped in ppp_disconnect for huawei modem
by Zhenhua Zhang
Huawei modem closes the modem port after PPP disconnect. So the channel
of gatchat is NULL in ppp_disconnect. In such case, we resume the chat
and it causes huawei_disconnect() get called and the gprs context is
removed later.
Before removing this gprs context, we should reply the pending DBus
message to the client.
---
drivers/atmodem/gprs-context.c | 17 +++++++++++++++--
1 files changed, 15 insertions(+), 2 deletions(-)
diff --git a/drivers/atmodem/gprs-context.c b/drivers/atmodem/gprs-context.c
index fea80b0..2f5be9b 100644
--- a/drivers/atmodem/gprs-context.c
+++ b/drivers/atmodem/gprs-context.c
@@ -88,12 +88,18 @@ static void ppp_disconnect(GAtPPPDisconnectReason reason, gpointer user_data)
{
struct ofono_gprs_context *gc = user_data;
struct gprs_context_data *gcd = ofono_gprs_context_get_data(gc);
+ GAtIO *io = g_at_chat_get_io(gcd->chat);
DBG("");
g_at_ppp_unref(gcd->ppp);
gcd->ppp = NULL;
- g_at_chat_resume(gcd->chat);
+
+ if (g_at_io_get_channel(io) == NULL) {
+ CALLBACK_WITH_FAILURE(gcd->up_cb, NULL, FALSE, NULL,
+ NULL, NULL, NULL, gcd->cb_data);
+ goto done;
+ }
switch (gcd->state) {
case STATE_ENABLING:
@@ -108,8 +114,15 @@ static void ppp_disconnect(GAtPPPDisconnectReason reason, gpointer user_data)
break;
}
+done:
gcd->active_context = 0;
gcd->state = STATE_IDLE;
+ /*
+ * If the channel of gcd->chat is NULL, it might cause
+ * gprs_context_remove get called and the gprs context will be
+ * removed.
+ */
+ g_at_chat_resume(gcd->chat);
}
static gboolean setup_ppp(struct ofono_gprs_context *gc)
@@ -257,7 +270,7 @@ static void at_gprs_context_remove(struct ofono_gprs_context *gc)
DBG("");
- if (gcd->state != STATE_IDLE) {
+ if (gcd->state != STATE_IDLE && gcd->ppp) {
g_at_ppp_unref(gcd->ppp);
g_at_chat_resume(gcd->chat);
}
--
1.7.0.4
10 years, 5 months
[PATCH] Fix busylooped in ppp_disconnect for huawei modem
by Zhenhua Zhang
Huawei modem closes the modem port after PPP disconnect. So the channel
of gatchat is NULL in ppp_disconnect. In such case, we should not resume
the chat and call disconnect function when removing the context.
Secondly, before removing the gprs context, we should reply the pending
DBus message to the client.
---
drivers/atmodem/gprs-context.c | 13 ++++++++++++-
1 files changed, 12 insertions(+), 1 deletions(-)
diff --git a/drivers/atmodem/gprs-context.c b/drivers/atmodem/gprs-context.c
index fea80b0..e2f291a 100644
--- a/drivers/atmodem/gprs-context.c
+++ b/drivers/atmodem/gprs-context.c
@@ -88,11 +88,22 @@ static void ppp_disconnect(GAtPPPDisconnectReason reason, gpointer user_data)
{
struct ofono_gprs_context *gc = user_data;
struct gprs_context_data *gcd = ofono_gprs_context_get_data(gc);
+ GAtIO *io = g_at_chat_get_io(gcd->chat);
DBG("");
g_at_ppp_unref(gcd->ppp);
gcd->ppp = NULL;
+
+ if (g_at_io_get_channel(io) == NULL) {
+ CALLBACK_WITH_FAILURE(gcd->up_cb, NULL, FALSE, NULL,
+ NULL, NULL, NULL, gcd->cb_data);
+ gcd->active_context = 0;
+ gcd->state = STATE_IDLE;
+ g_at_chat_resume(gcd->chat);
+ return;
+ }
+
g_at_chat_resume(gcd->chat);
switch (gcd->state) {
@@ -257,7 +268,7 @@ static void at_gprs_context_remove(struct ofono_gprs_context *gc)
DBG("");
- if (gcd->state != STATE_IDLE) {
+ if (gcd->state != STATE_IDLE && gcd->ppp) {
g_at_ppp_unref(gcd->ppp);
g_at_chat_resume(gcd->chat);
}
--
1.7.0.4
10 years, 5 months
[PATCH 1/6] Add STK agent utilities and logic.
by Andrzej Zaborowski
---
Makefile.am | 2 +-
src/stkagent.c | 260 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++
src/stkagent.h | 60 +++++++++++++
3 files changed, 321 insertions(+), 1 deletions(-)
create mode 100644 src/stkagent.c
create mode 100644 src/stkagent.h
diff --git a/Makefile.am b/Makefile.am
index e256841..0e9086b 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -270,7 +270,7 @@ src_ofonod_SOURCES = $(gdbus_sources) $(builtin_sources) \
src/storage.c src/cbs.c src/watch.c src/call-volume.c \
src/gprs.c src/idmap.h src/idmap.c \
src/radio-settings.c src/stkutil.h src/stkutil.c \
- src/nettime.c
+ src/nettime.c src/stkagent.c src/stkagent.h
src_ofonod_LDADD = $(builtin_libadd) @GLIB_LIBS@ @DBUS_LIBS@ @CAPNG_LIBS@ -ldl
diff --git a/src/stkagent.c b/src/stkagent.c
new file mode 100644
index 0000000..1abd84d
--- /dev/null
+++ b/src/stkagent.c
@@ -0,0 +1,260 @@
+/*
+ *
+ * oFono - Open Source Telephony
+ *
+ * Copyright (C) 2008-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
+ *
+ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#define _GNU_SOURCE
+
+#include <glib.h>
+#include <gdbus.h>
+
+#include "ofono.h"
+
+#include "stkagent.h"
+
+#define OFONO_NAVIGATION_PREFIX OFONO_SERVICE ".Error"
+#define OFONO_NAVIGATION_GOBACK OFONO_NAVIGATION_PREFIX ".GoBack"
+#define OFONO_NAVIGATION_TERMINATED OFONO_NAVIGATION_PREFIX ".EndSession"
+
+static void app_agent_request_send_cancel(struct stk_app_agent *agent)
+{
+ DBusConnection *conn = ofono_dbus_get_connection();
+ DBusMessage *message;
+
+ message = dbus_message_new_method_call(agent->bus, agent->path,
+ OFONO_SIM_APP_INTERFACE,
+ "Cancel");
+ if (message == NULL)
+ return;
+
+ dbus_message_set_no_reply(message, TRUE);
+
+ g_dbus_send_message(conn, message);
+}
+
+static void app_agent_request_end(struct stk_app_agent *agent)
+{
+ agent->cmd_send = NULL;
+ agent->cmd_cb = NULL;
+
+ if (agent->msg) {
+ dbus_message_unref(agent->msg);
+ agent->msg = NULL;
+ }
+
+ if (agent->call) {
+ dbus_pending_call_cancel(agent->call);
+ dbus_pending_call_unref(agent->call);
+ agent->call = NULL;
+ }
+}
+
+static gboolean app_agent_busy(struct stk_app_agent *agent)
+{
+ return agent->cmd_send != NULL;
+}
+
+void app_agent_request_cancel(struct stk_app_agent *agent)
+{
+ if (!app_agent_busy(agent))
+ return;
+
+ agent->cmd_cb(STK_AGENT_RESULT_CANCEL, NULL, agent->data);
+
+ app_agent_request_end(agent);
+
+ app_agent_request_send_cancel(agent);
+}
+
+static void app_agent_request_terminate(struct stk_app_agent *agent)
+{
+ agent->cmd_cb(STK_AGENT_RESULT_TERMINATE, NULL, agent->data);
+
+ app_agent_request_end(agent);
+}
+
+void app_agent_remove(struct stk_app_agent *agent)
+{
+ DBusConnection *conn = ofono_dbus_get_connection();
+
+ if (agent->disconnect_watch) {
+ DBusMessage *message;
+
+ if (app_agent_busy(agent)) {
+ app_agent_request_terminate(agent);
+
+ app_agent_request_send_cancel(agent);
+ }
+
+ message = dbus_message_new_method_call(agent->bus, agent->path,
+ OFONO_SIM_APP_INTERFACE,
+ "Release");
+ if (message) {
+ dbus_message_set_no_reply(message, TRUE);
+
+ g_dbus_send_message(conn, message);
+ }
+
+ g_dbus_remove_watch(conn, agent->disconnect_watch);
+ agent->disconnect_watch = 0;
+ } else {
+ if (app_agent_busy(agent))
+ app_agent_request_terminate(agent);
+ }
+
+ if (agent->notify)
+ agent->notify(agent->data);
+
+ g_free(agent->path);
+ g_free(agent->bus);
+ g_free(agent);
+}
+
+static void app_agent_request_reply_handle(DBusPendingCall *call, void *data)
+{
+ struct stk_app_agent *agent = data;
+ DBusError err;
+ DBusMessage *reply = dbus_pending_call_steal_reply(call);
+ enum stk_agent_result result = STK_AGENT_RESULT_OK;
+
+ dbus_error_init(&err);
+ if (dbus_set_error_from_message(&err, reply)) {
+ ofono_error("SimAppAgent %s replied with error %s, %s",
+ agent->path, err.name, err.message);
+
+ if (g_str_equal(err.name, DBUS_ERROR_NO_REPLY))
+ result = STK_AGENT_RESULT_TIMEOUT;
+ if (g_str_equal(err.name, OFONO_NAVIGATION_GOBACK))
+ result = STK_AGENT_RESULT_BACK;
+ else
+ result = STK_AGENT_RESULT_TERMINATE;
+
+ dbus_error_free(&err);
+ }
+
+ agent->cmd_cb(result, reply, agent->data);
+
+ app_agent_request_end(agent);
+
+ dbus_message_unref(reply);
+
+ if (result != STK_AGENT_RESULT_TERMINATE)
+ return;
+
+ if (agent->is_default)
+ return;
+
+ app_agent_remove(agent);
+}
+
+static gboolean app_agent_request_send(struct stk_app_agent *agent, int timeout)
+{
+ DBusConnection *conn = ofono_dbus_get_connection();
+
+ /*
+ * The cmd_send callback needs to set the method name to
+ * something different than "Cancel".
+ */
+ agent->msg = dbus_message_new_method_call(agent->bus, agent->path,
+ OFONO_SIM_APP_INTERFACE,
+ "Cancel");
+ if (agent->msg == NULL) {
+ ofono_error("Couldn't make a DBusMessage");
+ return FALSE;
+ }
+
+ agent->cmd_send(agent->msg, agent->data);
+
+ if (dbus_connection_send_with_reply(conn,
+ agent->msg, &agent->call, timeout) == FALSE ||
+ agent->call == NULL) {
+ dbus_message_unref(agent->msg);
+ agent->msg = NULL;
+
+ ofono_error("Couldn't send a method call");
+ return FALSE;
+ }
+
+ dbus_pending_call_set_notify(agent->call,
+ app_agent_request_reply_handle,
+ agent, NULL);
+
+ return TRUE;
+}
+
+void app_agent_request_start(struct stk_app_agent *agent,
+ stk_agent_request_send send,
+ stk_agent_request_return cb, int timeout)
+{
+ if (agent == NULL) {
+ cb(STK_AGENT_RESULT_TERMINATE, NULL, agent->data);
+
+ return;
+ }
+
+ if (app_agent_busy(agent))
+ app_agent_request_cancel(agent);
+
+ agent->cmd_send = send;
+ agent->cmd_cb = cb;
+
+ if (!app_agent_request_send(agent, timeout)) {
+ app_agent_request_terminate(agent);
+
+ return;
+ }
+}
+
+static void app_agent_disconnect_cb(DBusConnection *conn, void *user_data)
+{
+ struct stk_app_agent *agent = user_data;
+
+ ofono_debug("Agent exited without calling Unregister");
+
+ agent->disconnect_watch = 0;
+
+ app_agent_remove(user_data);
+}
+
+struct stk_app_agent *app_agent_create(const char *path, const char *sender,
+ ofono_bool_t is_default,
+ void *user_data, GDestroyNotify notify)
+{
+ struct stk_app_agent *agent = g_try_new0(struct stk_app_agent, 1);
+ DBusConnection *conn = ofono_dbus_get_connection();
+
+ if (!agent)
+ return NULL;
+
+ agent->path = g_strdup(path);
+ agent->bus = g_strdup(sender);
+ agent->data = user_data;
+ agent->notify = notify;
+ agent->is_default = is_default;
+
+ agent->disconnect_watch = g_dbus_add_disconnect_watch(conn, sender,
+ app_agent_disconnect_cb,
+ agent, NULL);
+
+ return agent;
+}
diff --git a/src/stkagent.h b/src/stkagent.h
new file mode 100644
index 0000000..1b64fa7
--- /dev/null
+++ b/src/stkagent.h
@@ -0,0 +1,60 @@
+/*
+ *
+ * oFono - Open Source Telephony
+ *
+ * Copyright (C) 2008-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
+ *
+ */
+
+enum stk_agent_result {
+ STK_AGENT_RESULT_OK,
+ STK_AGENT_RESULT_BACK,
+ STK_AGENT_RESULT_TERMINATE,
+ STK_AGENT_RESULT_HELP,
+ STK_AGENT_RESULT_TIMEOUT,
+ STK_AGENT_RESULT_CANCEL,
+};
+
+typedef void (*stk_agent_request_send)(DBusMessage *call, void *user_data);
+
+typedef void (*stk_agent_request_return)(enum stk_agent_result result,
+ DBusMessage *reply,
+ void *user_data);
+
+struct stk_app_agent {
+ char *path;
+ char *bus;
+ DBusMessage *msg;
+ DBusPendingCall *call;
+ guint disconnect_watch;
+ stk_agent_request_send cmd_send;
+ stk_agent_request_return cmd_cb;
+ void *data;
+ ofono_bool_t is_default;
+ GDestroyNotify notify;
+};
+
+struct stk_app_agent *app_agent_create(const char *path, const char *sender,
+ ofono_bool_t is_default,
+ void *user_data, GDestroyNotify notify);
+
+void app_agent_remove(struct stk_app_agent *agent);
+
+void app_agent_request_start(struct stk_app_agent *agent,
+ stk_agent_request_send cmd_send,
+ stk_agent_request_return cmd_cb, int timeout);
+
+void app_agent_request_cancel(struct stk_app_agent *agent);
--
1.7.1.86.g0e460.dirty
10 years, 5 months
[PATCH 0/2] convert images to xpm
by Kristen Carlson Accardi
Changes since last version:
* whitespace changes
* corrected sanity tests
* changed signature to pass clut and clut_len to function
* updated unit tests for new signature
Kristen Carlson Accardi (2):
stkutil: convert img to xpm
test-stkutil: unit test for img to xpm converter
src/stkutil.c | 147 ++++++++++++++++++++++++++++++
src/stkutil.h | 9 ++
unit/test-stkutil.c | 247 +++++++++++++++++++++++++++++++++++++++++++++++++++
3 files changed, 403 insertions(+), 0 deletions(-)
10 years, 5 months
huawei: invalid APN name crashes ofono
by Kalle Valo
Hi,
I was testing my Huawei E1552 with connman and noticed that ofono
crashes if I use incorrect APN name. Under gdb it didn't crash but it
busylooped instead and this was in the log:
Jul 26 16:46:02 tukki ofonod[14367]: Modem:> AT+CGDCONT=1,"IP","foobar"\r
Jul 26 16:46:02 tukki ofonod[14367]: Modem:< \r\nOK\r\n
Jul 26 16:46:02 tukki ofonod[14367]: Modem:> AT+CGDATA="PPP",1\r
Jul 26 16:46:02 tukki ofonod[14367]: Modem:< \r\nCONNECT\r\n
Jul 26 16:46:03 tukki ofonod[14367]: Pcui:< \r\n^RSSI:22\r\n
Jul 26 16:46:04 tukki ofonod[14367]: drivers/atmodem/gprs-context.c:ppp_disconnect()
Jul 26 16:46:04 tukki ofonod[14367]: plugins/huawei.c:huawei_disconnect()
Jul 26 16:46:04 tukki ofonod[14367]: src/gprs.c:gprs_context_remove() atom: 0x6c88a0
Jul 26 16:46:04 tukki ofonod[14367]: drivers/atmodem/gprs-context.c:at_gprs_context_remove()
Jul 26 16:46:04 tukki ofonod[14367]: plugins/huawei.c:huawei_disconnect()
Jul 26 16:46:04 tukki ofonod[14367]: src/gprs.c:gprs_context_remove() atom: 0x6c88a0
Jul 26 16:46:04 tukki ofonod[14367]: drivers/atmodem/gprs-context.c:at_gprs_context_remove()
Jul 26 16:46:04 tukki ofonod[14367]: plugins/huawei.c:huawei_disconnect()
Jul 26 16:46:04 tukki ofonod[14367]: src/gprs.c:gprs_context_remove() atom: 0x6c88a0
Jul 26 16:46:04 tukki ofonod[14367]: drivers/atmodem/gprs-context.c:at_gprs_context_remove()
Jul 26 16:46:04 tukki ofonod[14367]: plugins/huawei.c:huawei_disconnect()
Jul 26 16:46:04 tukki ofonod[14367]: src/gprs.c:gprs_context_remove() atom: 0x6c88a0
Jul 26 16:46:04 tukki ofonod[14367]: drivers/atmodem/gprs-context.c:at_gprs_context_remove()
Jul 26 16:46:04 tukki ofonod[14367]: plugins/huawei.c:huawei_disconnect()
Jul 26 16:46:04 tukki ofonod[14367]: src/gprs.c:gprs_context_remove() atom: 0x6c88a0
Jul 26 16:46:04 tukki ofonod[14367]: drivers/atmodem/gprs-context.c:at_gprs_context_remove()
Jul 26 16:46:04 tukki ofonod[14367]: plugins/huawei.c:huawei_disconnect()
Jul 26 16:46:04 tukki ofonod[14367]: src/gprs.c:gprs_context_remove() atom: 0x6c88a0
Jul 26 16:46:04 tukki ofonod[14367]: drivers/atmodem/gprs-context.c:at_gprs_context_remove()
Jul 26 16:46:04 tukki ofonod[14367]: plugins/huawei.c:huawei_disconnect()
Jul 26 16:46:04 tukki ofonod[14367]: src/gprs.c:gprs_context_remove() atom: 0x6c88a0
Jul 26 16:46:04 tukki ofonod[14367]: drivers/atmodem/gprs-context.c:at_gprs_context_remove()
Jul 26 16:46:04 tukki ofonod[14367]: plugins/huawei.c:huawei_disconnect()
Jul 26 16:46:04 tukki ofonod[14367]: src/gprs.c:gprs_context_remove() atom: 0x6c88a0
Jul 26 16:46:04 tukki ofonod[14367]: drivers/atmodem/gprs-context.c:at_gprs_context_remove()
Jul 26 16:46:04 tukki ofonod[14367]: plugins/huawei.c:huawei_disconnect()
Jul 26 16:46:04 tukki ofonod[14367]: src/gprs.c:gprs_context_remove() atom: 0x6c88a0
Jul 26 16:46:04 tukki ofonod[14367]: drivers/atmodem/gprs-context.c:at_gprs_context_remove()
Jul 26 16:46:04 tukki ofonod[14367]: plugins/huawei.c:huawei_disconnect()
Jul 26 16:46:04 tukki ofonod[14367]: src/gprs.c:gprs_context_remove() atom: 0x6c88a0
Jul 26 16:46:04 tukki ofonod[14367]: drivers/atmodem/gprs-context.c:at_gprs_context_remove()
Jul 26 16:46:04 tukki ofonod[14367]: plugins/huawei.c:huawei_disconnect()
Jul 26 16:46:04 tukki ofonod[14367]: src/gprs.c:gprs_context_remove() atom: 0x6c88a0
Jul 26 16:46:04 tukki ofonod[14367]: drivers/atmodem/gprs-context.c:at_gprs_context_remove()
Jul 26 16:46:04 tukki ofonod[14367]: plugins/huawei.c:huawei_disconnect()
Jul 26 16:46:04 tukki ofonod[14367]: src/gprs.c:gprs_context_remove() atom: 0x6c88a0
So huawei_disconnect() is recursively in an endless loop. Any ideas how
to fix this properly?
--
Kalle Valo
10 years, 5 months
CDMA support in Ofono
by Steven
Hi
Currently, Ofono only support GSM/UTMS, is there any plan to support
CDMA/EVDO and when will Ofono support CDMA?
Any suggestions or ideas about supporting CDMA will be appreciated .
steven
---------------------------------------------------------------------------------------------------
Confidentiality Notice: The information contained in this e-mail and any accompanying attachment(s)
is intended only for the use of the intended recipient and may be confidential and/or privileged of
Neusoft Corporation, its subsidiaries and/or its affiliates. If any reader of this communication is
not the intended recipient, unauthorized use, forwarding, printing, storing, disclosure or copying
is strictly prohibited, and may be unlawful.If you have received this communication in error,please
immediately notify the sender by return e-mail, and delete the original message and all copies from
your system. Thank you.
---------------------------------------------------------------------------------------------------
10 years, 5 months
[PATCH v2] watch: Free service data in service_reply
by Zhenhua Zhang
Avoid the memory leak of server_data.
---
gdbus/watch.c | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/gdbus/watch.c b/gdbus/watch.c
index 1d479fa..29f23e2 100644
--- a/gdbus/watch.c
+++ b/gdbus/watch.c
@@ -533,7 +533,7 @@ static void check_service(DBusConnection *connection, const char *name,
goto done;
}
- dbus_pending_call_set_notify(call, service_reply, data, NULL);
+ dbus_pending_call_set_notify(call, service_reply, data, g_free);
dbus_pending_call_unref(call);
--
1.7.0.4
10 years, 5 months
[PATCH 0/2] convert img to xpm
by Kristen Carlson Accardi
Changes from last version:
* Added length parameter
* created enum for scheme
* added sanity checking for img length
* added character lookup table to keep color strings
to no more than 2 chars per pixel.
Kristen Carlson Accardi (2):
stkutil: convert img to xpm
test-stkutil: unit test for img to xpm converter
src/stkutil.c | 148 +++++++++++++++++++++++++++++++
src/stkutil.h | 8 ++
unit/test-stkutil.c | 240 +++++++++++++++++++++++++++++++++++++++++++++++++++
3 files changed, 396 insertions(+), 0 deletions(-)
10 years, 6 months