* [PATCH 0/8] Prototype to integrate gatserver with oFono
@ 2010-04-13 14:18 Zhenhua Zhang
2010-04-13 14:18 ` [PATCH 1/8] Add signal watches for atom Zhenhua Zhang
0 siblings, 1 reply; 10+ messages in thread
From: Zhenhua Zhang @ 2010-04-13 14:18 UTC (permalink / raw)
To: ofono
[-- Attachment #1: Type: text/plain, Size: 479 bytes --]
These 8 patches are prototypes to integrate gatserver with oFono core:
1. Move watch_list into struct ofono_atom so that each component can be watched in an unique way.
2. Add src/emulator.c and dbus interface to create emulator.
3. Add at emulator plugin to watch call status and handle dial command request. Now it calls modem's "Dial" method through dbus interface, so it's not so effective. To avoid dbus method call, however, require big changes in ofono core code.
^ permalink raw reply [flat|nested] 10+ messages in thread
* [PATCH 1/8] Add signal watches for atom
2010-04-13 14:18 [PATCH 0/8] Prototype to integrate gatserver with oFono Zhenhua Zhang
@ 2010-04-13 14:18 ` Zhenhua Zhang
2010-04-13 14:18 ` [PATCH 2/8] Refactor netreg watchlist with atom watchlist Zhenhua Zhang
0 siblings, 1 reply; 10+ messages in thread
From: Zhenhua Zhang @ 2010-04-13 14:18 UTC (permalink / raw)
To: ofono
[-- Attachment #1: Type: text/plain, Size: 4282 bytes --]
It replaces watch lists dispersed in each component. So that each
component like Voicecall, SMS can be watched in unique way.
---
src/modem.c | 55 +++++++++++++++++++++++++++++++++++++++++++++++++++++++
src/ofono.h | 19 +++++++++++++++++++
2 files changed, 74 insertions(+), 0 deletions(-)
diff --git a/src/modem.c b/src/modem.c
index b935328..47ac172 100644
--- a/src/modem.c
+++ b/src/modem.c
@@ -86,6 +86,7 @@ struct ofono_atom {
void (*unregister)(struct ofono_atom *atom);
void *data;
struct ofono_modem *modem;
+ struct ofono_watchlist *signal_watches;
};
struct ofono_atom_watch {
@@ -93,6 +94,11 @@ struct ofono_atom_watch {
enum ofono_atom_type type;
};
+struct ofono_signal_watch {
+ struct ofono_watchlist_item item;
+ enum ofono_signal_type type;
+};
+
struct ofono_property {
enum ofono_property_type type;
void *value;
@@ -211,6 +217,8 @@ void __ofono_atom_register(struct ofono_atom *atom,
atom->unregister = unregister;
+ atom->signal_watches = __ofono_watchlist_new(g_free);
+
call_watches(atom, OFONO_ATOM_WATCH_CONDITION_REGISTERED);
}
@@ -221,6 +229,9 @@ void __ofono_atom_unregister(struct ofono_atom *atom)
call_watches(atom, OFONO_ATOM_WATCH_CONDITION_UNREGISTERED);
+ __ofono_watchlist_free(atom->signal_watches);
+ atom->signal_watches = NULL;
+
atom->unregister(atom);
}
@@ -229,6 +240,50 @@ gboolean __ofono_atom_get_registered(struct ofono_atom *atom)
return atom->unregister ? TRUE : FALSE;
}
+GSList *__ofono_atom_get_signal_watches(struct ofono_atom *atom,
+ enum ofono_signal_type type)
+{
+ struct ofono_signal_watch *item;
+ GSList *watches = NULL;
+ GSList *l;
+
+ for (l = atom->signal_watches->items; l; l = l->next) {
+ item = l->data;
+
+ if (item->type == type)
+ watches = g_slist_prepend(watches, &item->item);
+ }
+
+ return watches;
+}
+
+unsigned int __ofono_atom_add_signal_watch(struct ofono_atom *atom,
+ enum ofono_signal_type type,
+ ofono_signal_watch_func notify,
+ void *data, ofono_destroy_func destroy)
+{
+ struct ofono_signal_watch *watch;
+
+ if (notify == NULL)
+ return 0;
+
+ watch = g_new0(struct ofono_signal_watch, 1);
+
+ watch->type = type;
+ watch->item.notify = notify;
+ watch->item.destroy = destroy;
+ watch->item.notify_data = data;
+
+ return __ofono_watchlist_add_item(atom->signal_watches,
+ (struct ofono_watchlist_item *) watch);
+}
+
+gboolean __ofono_atom_remove_signal_watch(struct ofono_atom *atom,
+ unsigned int id)
+{
+ return __ofono_watchlist_remove_item(atom->signal_watches, id);
+}
+
unsigned int __ofono_modem_add_atom_watch(struct ofono_modem *modem,
enum ofono_atom_type type,
ofono_atom_watch_func notify,
diff --git a/src/ofono.h b/src/ofono.h
index ff67728..115ad6b 100644
--- a/src/ofono.h
+++ b/src/ofono.h
@@ -121,12 +121,20 @@ enum ofono_atom_watch_condition {
OFONO_ATOM_WATCH_CONDITION_UNREGISTERED
};
+enum ofono_signal_type {
+ OFONO_SIGNAL_TYPE_NETREG_STATUS = 0,
+ OFONO_SIGNAL_TYPE_SIM_READY = 1,
+};
+
typedef void (*ofono_atom_watch_func)(struct ofono_atom *atom,
enum ofono_atom_watch_condition cond,
void *data);
typedef void (*ofono_atom_func)(struct ofono_atom *atom, void *data);
+typedef void (*ofono_signal_watch_func)(struct ofono_atom *atom,
+ void *data);
+
struct ofono_atom *__ofono_modem_add_atom(struct ofono_modem *modem,
enum ofono_atom_type type,
void (*destruct)(struct ofono_atom *),
@@ -149,6 +157,17 @@ void __ofono_atom_unregister(struct ofono_atom *atom);
gboolean __ofono_atom_get_registered(struct ofono_atom *atom);
+GSList *__ofono_atom_get_signal_watches(struct ofono_atom *atom,
+ enum ofono_signal_type type);
+
+unsigned int __ofono_atom_add_signal_watch(struct ofono_atom *atom,
+ enum ofono_signal_type type,
+ ofono_signal_watch_func notify,
+ void *data, ofono_destroy_func destroy);
+
+gboolean __ofono_atom_remove_signal_watch(struct ofono_atom *atom,
+ unsigned int id);
+
unsigned int __ofono_modem_add_atom_watch(struct ofono_modem *modem,
enum ofono_atom_type type,
ofono_atom_watch_func notify,
--
1.6.6.1
^ permalink raw reply related [flat|nested] 10+ messages in thread
* [PATCH 2/8] Refactor netreg watchlist with atom watchlist
2010-04-13 14:18 ` [PATCH 1/8] Add signal watches for atom Zhenhua Zhang
@ 2010-04-13 14:18 ` Zhenhua Zhang
2010-04-13 14:18 ` [PATCH 3/8] Refactor sim " Zhenhua Zhang
0 siblings, 1 reply; 10+ messages in thread
From: Zhenhua Zhang @ 2010-04-13 14:18 UTC (permalink / raw)
To: ofono
[-- Attachment #1: Type: text/plain, Size: 2818 bytes --]
---
src/network.c | 32 +++++++++++---------------------
1 files changed, 11 insertions(+), 21 deletions(-)
diff --git a/src/network.c b/src/network.c
index b2e5821..c975c7d 100644
--- a/src/network.c
+++ b/src/network.c
@@ -79,7 +79,6 @@ struct ofono_netreg {
struct ofono_sim *sim;
GKeyFile *settings;
char *imsi;
- struct ofono_watchlist *status_watches;
const struct ofono_netreg_driver *driver;
void *driver_data;
struct ofono_atom *atom;
@@ -978,23 +977,15 @@ unsigned int __ofono_netreg_add_status_watch(struct ofono_netreg *netreg,
ofono_netreg_status_notify_cb_t notify,
void *data, ofono_destroy_func destroy)
{
- struct ofono_watchlist_item *item;
-
DBG("%p", netreg);
if (netreg == NULL)
return 0;
- if (notify == NULL)
- return 0;
-
- item = g_new0(struct ofono_watchlist_item, 1);
-
- item->notify = notify;
- item->destroy = destroy;
- item->notify_data = data;
-
- return __ofono_watchlist_add_item(netreg->status_watches, item);
+ return __ofono_atom_add_signal_watch(netreg->atom,
+ OFONO_SIGNAL_TYPE_NETREG_STATUS,
+ (ofono_signal_watch_func) notify,
+ data, destroy);
}
gboolean __ofono_netreg_remove_status_watch(struct ofono_netreg *netreg,
@@ -1002,23 +993,27 @@ gboolean __ofono_netreg_remove_status_watch(struct ofono_netreg *netreg,
{
DBG("%p", netreg);
- return __ofono_watchlist_remove_item(netreg->status_watches, id);
+ return __ofono_atom_remove_signal_watch(netreg->atom, id);
}
static void notify_status_watches(struct ofono_netreg *netreg)
{
struct ofono_watchlist_item *item;
- GSList *l;
ofono_netreg_status_notify_cb_t notify;
const char *mcc = NULL;
const char *mnc = NULL;
+ GSList *status_watches;
+ GSList *l;
if (netreg->current_operator) {
mcc = netreg->current_operator->mcc;
mnc = netreg->current_operator->mnc;
}
- for (l = netreg->status_watches->items; l; l = l->next) {
+ status_watches = __ofono_atom_get_signal_watches(netreg->atom,
+ OFONO_SIGNAL_TYPE_NETREG_STATUS);
+
+ for (l = status_watches; l; l = l->next) {
item = l->data;
notify = item->notify;
@@ -1620,9 +1615,6 @@ static void netreg_unregister(struct ofono_atom *atom)
const char *path = __ofono_atom_get_path(atom);
GSList *l;
- __ofono_watchlist_free(netreg->status_watches);
- netreg->status_watches = NULL;
-
for (l = netreg->operator_list; l; l = l->next) {
struct network_operator_data *opd = l->data;
@@ -1765,8 +1757,6 @@ void ofono_netreg_register(struct ofono_netreg *netreg)
return;
}
- netreg->status_watches = __ofono_watchlist_new(g_free);
-
ofono_modem_add_interface(modem, OFONO_NETWORK_REGISTRATION_INTERFACE);
if (netreg->driver->registration_status)
--
1.6.6.1
^ permalink raw reply related [flat|nested] 10+ messages in thread
* [PATCH 3/8] Refactor sim watchlist with atom watchlist
2010-04-13 14:18 ` [PATCH 2/8] Refactor netreg watchlist with atom watchlist Zhenhua Zhang
@ 2010-04-13 14:18 ` Zhenhua Zhang
2010-04-13 14:18 ` [PATCH 4/8] Add skeleton of src/emulator.c Zhenhua Zhang
0 siblings, 1 reply; 10+ messages in thread
From: Zhenhua Zhang @ 2010-04-13 14:18 UTC (permalink / raw)
To: ofono
[-- Attachment #1: Type: text/plain, Size: 2810 bytes --]
---
src/sim.c | 30 ++++++++++--------------------
1 files changed, 10 insertions(+), 20 deletions(-)
diff --git a/src/sim.c b/src/sim.c
index f64c7d4..b9e6b4a 100644
--- a/src/sim.c
+++ b/src/sim.c
@@ -89,7 +89,6 @@ struct ofono_sim {
unsigned char efli_length;
enum ofono_sim_cphs_phase cphs_phase;
unsigned char cphs_service_table[2];
- struct ofono_watchlist *ready_watches;
const struct ofono_sim_driver *driver;
void *driver_data;
struct ofono_atom *atom;
@@ -1779,28 +1778,20 @@ unsigned int ofono_sim_add_ready_watch(struct ofono_sim *sim,
ofono_sim_ready_notify_cb_t notify,
void *data, ofono_destroy_func destroy)
{
- struct ofono_watchlist_item *item;
-
DBG("%p", sim);
if (sim == NULL)
return 0;
- if (notify == NULL)
- return 0;
-
- item = g_new0(struct ofono_watchlist_item, 1);
-
- item->notify = notify;
- item->destroy = destroy;
- item->notify_data = data;
-
- return __ofono_watchlist_add_item(sim->ready_watches, item);
+ return __ofono_atom_add_signal_watch(sim->atom,
+ OFONO_SIGNAL_TYPE_SIM_READY,
+ (ofono_signal_watch_func) notify,
+ data, destroy);
}
void ofono_sim_remove_ready_watch(struct ofono_sim *sim, unsigned int id)
{
- __ofono_watchlist_remove_item(sim->ready_watches, id);
+ __ofono_atom_remove_signal_watch(sim->atom, id);
}
int ofono_sim_get_ready(struct ofono_sim *sim)
@@ -1816,6 +1807,7 @@ int ofono_sim_get_ready(struct ofono_sim *sim)
void ofono_sim_set_ready(struct ofono_sim *sim)
{
+ GSList *ready_watches;
GSList *l;
ofono_sim_ready_notify_cb_t notify;
@@ -1827,7 +1819,10 @@ void ofono_sim_set_ready(struct ofono_sim *sim)
sim->ready = TRUE;
- for (l = sim->ready_watches->items; l; l = l->next) {
+ ready_watches = __ofono_atom_get_signal_watches(sim->atom,
+ OFONO_SIGNAL_TYPE_SIM_READY);
+
+ for (l = ready_watches; l; l = l->next) {
struct ofono_watchlist_item *item = l->data;
notify = item->notify;
@@ -1895,10 +1890,6 @@ static void sim_unregister(struct ofono_atom *atom)
DBusConnection *conn = ofono_dbus_get_connection();
struct ofono_modem *modem = __ofono_atom_get_modem(atom);
const char *path = __ofono_atom_get_path(atom);
- struct ofono_sim *sim = __ofono_atom_get_data(atom);
-
- __ofono_watchlist_free(sim->ready_watches);
- sim->ready_watches = NULL;
g_dbus_unregister_interface(conn, path, OFONO_SIM_MANAGER_INTERFACE);
ofono_modem_remove_interface(modem, OFONO_SIM_MANAGER_INTERFACE);
@@ -2012,7 +2003,6 @@ void ofono_sim_register(struct ofono_sim *sim)
}
ofono_modem_add_interface(modem, OFONO_SIM_MANAGER_INTERFACE);
- sim->ready_watches = __ofono_watchlist_new(g_free);
__ofono_atom_register(sim->atom, sim_unregister);
--
1.6.6.1
^ permalink raw reply related [flat|nested] 10+ messages in thread
* [PATCH 4/8] Add skeleton of src/emulator.c
2010-04-13 14:18 ` [PATCH 3/8] Refactor sim " Zhenhua Zhang
@ 2010-04-13 14:18 ` Zhenhua Zhang
2010-04-13 14:18 ` [PATCH 5/8] Add emulator dialing call support Zhenhua Zhang
2010-04-16 20:17 ` [PATCH 4/8] Add skeleton of src/emulator.c Denis Kenzior
0 siblings, 2 replies; 10+ messages in thread
From: Zhenhua Zhang @ 2010-04-13 14:18 UTC (permalink / raw)
To: ofono
[-- Attachment #1: Type: text/plain, Size: 10779 bytes --]
---
Makefile.am | 7 +-
include/dbus.h | 1 +
include/emulator.h | 75 +++++++++++++++++++
src/emulator.c | 203 ++++++++++++++++++++++++++++++++++++++++++++++++++++
src/ofono.h | 4 +
5 files changed, 287 insertions(+), 3 deletions(-)
create mode 100644 include/emulator.h
create mode 100644 src/emulator.c
diff --git a/Makefile.am b/Makefile.am
index 20dff39..eda7ad6 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -12,7 +12,7 @@ include_HEADERS = include/log.h include/plugin.h include/history.h \
include/netreg.h include/voicecall.h include/devinfo.h \
include/cbs.h include/call-volume.h \
include/gprs.h include/gprs-context.h \
- include/radio-settings.h
+ include/radio-settings.h include/emulator.h
nodist_include_HEADERS = include/version.h
@@ -238,9 +238,10 @@ src_ofonod_SOURCES = $(gdbus_sources) $(builtin_sources) \
src/simutil.h src/simutil.c src/storage.h \
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/radio-settings.c src/stkutil.h src/stkutil.c \
+ src/emulator.c
-src_ofonod_LDADD = $(builtin_libadd) @GLIB_LIBS@ @DBUS_LIBS@ @CAPNG_LIBS@ -ldl
+src_ofonod_LDADD = $(builtin_libadd) @GLIB_LIBS@ @DBUS_LIBS@ @CAPNG_LIBS@ -ldl -lutil
src_ofonod_LDFLAGS = -Wl,--export-dynamic -Wl,--version-script=src/ofono.ver
diff --git a/include/dbus.h b/include/dbus.h
index 5bf0505..9007da2 100644
--- a/include/dbus.h
+++ b/include/dbus.h
@@ -47,6 +47,7 @@ extern "C" {
#define OFONO_SMS_MANAGER_INTERFACE "org.ofono.SmsManager"
#define OFONO_VOICECALL_INTERFACE "org.ofono.VoiceCall"
#define OFONO_VOICECALL_MANAGER_INTERFACE "org.ofono.VoiceCallManager"
+#define OFONO_EMULATOR_INTERFACE "org.ofono.ModemEmulator"
/* Essentially a{sv} */
#define OFONO_PROPERTIES_ARRAY_SIGNATURE DBUS_DICT_ENTRY_BEGIN_CHAR_AS_STRING \
diff --git a/include/emulator.h b/include/emulator.h
new file mode 100644
index 0000000..3d07e36
--- /dev/null
+++ b/include/emulator.h
@@ -0,0 +1,75 @@
+/*
+ *
+ * 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
+ *
+ */
+
+#ifndef __OFONO_EMULATOR_H
+#define __OFONO_EMULATOR_H
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#include <ofono/types.h>
+
+struct ofono_emulator;
+
+typedef void (*ofono_emulator_cb_t)(const struct ofono_error *error,
+ void *data);
+
+struct ofono_emulator_driver {
+ const char *name;
+
+ /* Detect existence of device and initialize any device-specific data
+ * structures */
+ int (*probe)(struct ofono_emulator *emulator);
+
+ /* Destroy data structures allocated during probe and cleanup */
+ void (*remove)(struct ofono_emulator *emulator);
+
+ /* Power up device */
+ int (*enable)(struct ofono_emulator *emulator);
+
+ /* Power down device */
+ int (*disable)(struct ofono_emulator *emulator);
+
+ /* Notify a new call from real modem */
+ void (*notify_call)(struct ofono_emulator *emulator,
+ struct ofono_call *nc);
+};
+
+int ofono_emulator_driver_register(const struct ofono_emulator_driver *d);
+void ofono_emulator_driver_unregister(const struct ofono_emulator_driver *d);
+
+void ofono_emulator_register(struct ofono_emulator *emulator);
+
+struct ofono_emulator *ofono_emulator_create(struct ofono_modem *modem,
+ unsigned int vendor,
+ const char *driver, void *data);
+
+void ofono_emulator_watch_voicecall(struct ofono_emulator *emulator);
+
+void ofono_emulator_set_data(struct ofono_emulator *emulator, void *data);
+void *ofono_emulator_get_data(struct ofono_emulator *emulator);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* __OFONO_EMULATOR_H */
diff --git a/src/emulator.c b/src/emulator.c
new file mode 100644
index 0000000..33e0a85
--- /dev/null
+++ b/src/emulator.c
@@ -0,0 +1,203 @@
+/*
+ *
+ * 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
+
+#include <string.h>
+#include <stdio.h>
+#include <time.h>
+#include <errno.h>
+
+#include <glib.h>
+#include <gdbus.h>
+
+#include "ofono.h"
+
+#include "common.h"
+
+static GSList *g_drivers = NULL;
+
+struct ofono_emulator {
+ const struct ofono_emulator_driver *driver;
+ void *driver_data;
+ struct ofono_atom *atom;
+};
+
+static DBusMessage *emulator_get_properties(DBusConnection *conn,
+ DBusMessage *msg, void *data)
+{
+ DBusMessage *reply;
+
+ reply = dbus_message_new_method_return(msg);
+ if (!reply)
+ return NULL;
+
+ return reply;
+}
+
+static DBusMessage *emulator_enable(DBusConnection *conn,
+ DBusMessage *msg, void *data)
+{
+ struct ofono_emulator *emulator = data;
+
+ if (emulator->driver->enable)
+ emulator->driver->enable(emulator);
+
+ return dbus_message_new_method_return(msg);
+}
+
+static DBusMessage *emulator_disable(DBusConnection *conn,
+ DBusMessage *msg, void *data)
+{
+ struct ofono_emulator *emulator = data;
+
+ if (emulator == NULL)
+ return __ofono_error_failed(msg);
+
+ if (emulator->driver->disable)
+ emulator->driver->disable(emulator);
+
+ return dbus_message_new_method_return(msg);
+}
+
+static GDBusMethodTable emulator_methods[] = {
+ { "GetProperties", "", "a{sv}", emulator_get_properties },
+ { "EnableEmulator", "", "", emulator_enable },
+ { "DisableEmulator", "", "", emulator_disable },
+ { }
+};
+
+static GDBusSignalTable emulator_signals[] = {
+ { "PropertyChanged", "sv" },
+};
+
+int ofono_emulator_driver_register(const struct ofono_emulator_driver *d)
+{
+ DBG("driver: %p, name: %s", d, d->name);
+
+ if (d->probe == NULL)
+ return -EINVAL;
+
+ g_drivers = g_slist_prepend(g_drivers, (void *)d);
+
+ return 0;
+}
+
+void ofono_emulator_driver_unregister(const struct ofono_emulator_driver *d)
+{
+ DBG("driver: %p, name: %s", d, d->name);
+
+ g_drivers = g_slist_remove(g_drivers, (void *)d);
+}
+
+static void emulator_unregister(struct ofono_atom *atom)
+{
+ DBusConnection *conn = ofono_dbus_get_connection();
+ struct ofono_modem *modem = __ofono_atom_get_modem(atom);
+ const char *path = __ofono_atom_get_path(atom);
+
+ ofono_modem_remove_interface(modem, OFONO_EMULATOR_INTERFACE);
+ g_dbus_unregister_interface(conn, path,
+ OFONO_EMULATOR_INTERFACE);
+}
+
+void ofono_emulator_register(struct ofono_emulator *emulator)
+{
+ DBusConnection *conn = ofono_dbus_get_connection();
+ struct ofono_modem *modem = __ofono_atom_get_modem(emulator->atom);
+ const char *path = __ofono_atom_get_path(emulator->atom);
+
+ if (!g_dbus_register_interface(conn, path,
+ OFONO_EMULATOR_INTERFACE,
+ emulator_methods, emulator_signals,
+ NULL, emulator, NULL)) {
+ ofono_error("Could not create %s interface",
+ OFONO_EMULATOR_INTERFACE);
+
+ return;
+ }
+
+ ofono_modem_add_interface(modem, OFONO_EMULATOR_INTERFACE);
+
+ __ofono_atom_register(emulator->atom, emulator_unregister);
+}
+
+static void emulator_remove(struct ofono_atom *atom)
+{
+ struct ofono_emulator *emulator = __ofono_atom_get_data(atom);
+
+ DBG("atom: %p", atom);
+
+ if (emulator == NULL)
+ return;
+
+ if (emulator->driver && emulator->driver->remove)
+ emulator->driver->remove(emulator);
+
+ g_free(emulator);
+}
+
+struct ofono_emulator *ofono_emulator_create(struct ofono_modem *modem,
+ unsigned int vendor,
+ const char *driver,
+ void *data)
+{
+ struct ofono_emulator *emulator;
+ GSList *l;
+
+ if (driver == NULL)
+ return NULL;
+
+ emulator = g_try_new0(struct ofono_emulator, 1);
+
+ if (emulator == NULL)
+ return NULL;
+
+ emulator->atom = __ofono_modem_add_atom(modem, OFONO_ATOM_TYPE_EMULATOR,
+ emulator_remove, emulator);
+
+ for (l = g_drivers; l; l = l->next) {
+ const struct ofono_emulator_driver *drv = l->data;
+
+ if (g_strcmp0(drv->name, driver))
+ continue;
+
+ if (drv->probe(emulator) < 0)
+ continue;
+
+ emulator->driver = drv;
+ break;
+ }
+
+ return emulator;
+}
+
+void ofono_emulator_set_data(struct ofono_emulator *emulator, void *data)
+{
+ emulator->driver_data = data;
+}
+
+void *ofono_emulator_get_data(struct ofono_emulator *emulator)
+{
+ return emulator->driver_data;
+}
diff --git a/src/ofono.h b/src/ofono.h
index 115ad6b..118406d 100644
--- a/src/ofono.h
+++ b/src/ofono.h
@@ -114,6 +114,7 @@ enum ofono_atom_type {
OFONO_ATOM_TYPE_GPRS = 16,
OFONO_ATOM_TYPE_GPRS_CONTEXT = 17,
OFONO_ATOM_TYPE_RADIO_SETTINGS = 18,
+ OFONO_ATOM_TYPE_EMULATOR = 19,
};
enum ofono_atom_watch_condition {
@@ -168,6 +169,8 @@ unsigned int __ofono_atom_add_signal_watch(struct ofono_atom *atom,
gboolean __ofono_atom_remove_signal_watch(struct ofono_atom *atom,
unsigned int id);
+#include <gdbus/gdbus.h>
+
unsigned int __ofono_modem_add_atom_watch(struct ofono_modem *modem,
enum ofono_atom_type type,
ofono_atom_watch_func notify,
@@ -189,6 +192,7 @@ void __ofono_atom_free(struct ofono_atom *atom);
#include <ofono/gprs.h>
#include <ofono/gprs-context.h>
#include <ofono/radio-settings.h>
+#include <ofono/emulator.h>
#include <ofono/sim.h>
--
1.6.6.1
^ permalink raw reply related [flat|nested] 10+ messages in thread
* [PATCH 5/8] Add emulator dialing call support
2010-04-13 14:18 ` [PATCH 4/8] Add skeleton of src/emulator.c Zhenhua Zhang
@ 2010-04-13 14:18 ` Zhenhua Zhang
2010-04-13 14:18 ` [PATCH 6/8] Add prototype to watch voicecall Zhenhua Zhang
2010-04-16 20:17 ` [PATCH 4/8] Add skeleton of src/emulator.c Denis Kenzior
1 sibling, 1 reply; 10+ messages in thread
From: Zhenhua Zhang @ 2010-04-13 14:18 UTC (permalink / raw)
To: ofono
[-- Attachment #1: Type: text/plain, Size: 4134 bytes --]
---
include/emulator.h | 4 +-
src/emulator.c | 110 ++++++++++++++++++++++++++++++++++++++++++++++++++++
2 files changed, 112 insertions(+), 2 deletions(-)
diff --git a/include/emulator.h b/include/emulator.h
index 3d07e36..0412f5a 100644
--- a/include/emulator.h
+++ b/include/emulator.h
@@ -63,11 +63,11 @@ struct ofono_emulator *ofono_emulator_create(struct ofono_modem *modem,
unsigned int vendor,
const char *driver, void *data);
-void ofono_emulator_watch_voicecall(struct ofono_emulator *emulator);
-
void ofono_emulator_set_data(struct ofono_emulator *emulator, void *data);
void *ofono_emulator_get_data(struct ofono_emulator *emulator);
+gboolean ofono_emulator_dial(struct ofono_emulator *emulator,
+ const char *number);
#ifdef __cplusplus
}
#endif
diff --git a/src/emulator.c b/src/emulator.c
index 33e0a85..e21d826 100644
--- a/src/emulator.c
+++ b/src/emulator.c
@@ -41,8 +41,116 @@ struct ofono_emulator {
const struct ofono_emulator_driver *driver;
void *driver_data;
struct ofono_atom *atom;
+ struct ofono_atom *voicecall; /* emulated voicecall atom */
};
+/* steal from plugins/hfp.c */
+static int send_method_call_with_reply(const char *dest, const char *path,
+ const char *interface, const char *method,
+ DBusPendingCallNotifyFunction cb,
+ void *user_data, DBusFreeFunction free_func,
+ int timeout, int type, ...)
+{
+ DBusConnection *connection = ofono_dbus_get_connection();
+ DBusMessage *msg;
+ DBusPendingCall *call;
+ va_list args;
+ int err;
+
+ msg = dbus_message_new_method_call(dest, path, interface, method);
+ if (!msg) {
+ ofono_error("Unable to allocate new D-Bus %s message", method);
+ err = -ENOMEM;
+ goto fail;
+ }
+
+ va_start(args, type);
+
+ if (!dbus_message_append_args_valist(msg, type, args)) {
+ va_end(args);
+ err = -EIO;
+ goto fail;
+ }
+
+ va_end(args);
+
+ if (timeout > 0)
+ timeout *= 1000;
+
+ if (!dbus_connection_send_with_reply(connection, msg, &call, timeout)) {
+ ofono_error("Sending %s failed", method);
+ err = -EIO;
+ goto fail;
+ }
+
+ dbus_pending_call_set_notify(call, cb, user_data, free_func);
+ dbus_pending_call_unref(call);
+ dbus_message_unref(msg);
+
+ return 0;
+
+fail:
+ if (free_func && user_data)
+ free_func(user_data);
+
+ if (msg)
+ dbus_message_unref(msg);
+
+ return err;
+}
+
+static void emulator_dial_cb(DBusPendingCall *call, gpointer user_data)
+{
+ DBusMessage *reply;
+ DBusError derr;
+
+ reply = dbus_pending_call_steal_reply(call);
+
+ dbus_error_init(&derr);
+ if (dbus_set_error_from_message(&derr, reply)) {
+ DBG("Call reply: %s", derr.message);
+ dbus_error_free(&derr);
+ goto done;
+ }
+
+done:
+ dbus_message_unref(reply);
+}
+
+gboolean ofono_emulator_dial(struct ofono_emulator *emulator,
+ const char *number)
+{
+ struct ofono_atom *voicecall = emulator->voicecall;
+ struct ofono_voicecall *vc;
+ const char *path;
+ const char *clir = "default";
+
+ if (number == NULL)
+ return FALSE;
+
+ vc = __ofono_atom_get_data(voicecall);
+ path = __ofono_atom_get_path(voicecall);
+
+ send_method_call_with_reply(OFONO_SERVICE, path,
+ OFONO_VOICECALL_MANAGER_INTERFACE,
+ "Dial", emulator_dial_cb, vc, NULL, 15,
+ DBUS_TYPE_STRING, &number,
+ DBUS_TYPE_STRING, &clir,
+ DBUS_TYPE_INVALID);
+
+ return TRUE;
+}
+
+static void ofono_emulator_watch_voicecall(struct ofono_emulator *emulator)
+{
+ struct ofono_modem *modem = __ofono_atom_get_modem(emulator->atom);
+ struct ofono_atom *voicecall;
+
+ voicecall = __ofono_modem_find_atom(modem, OFONO_ATOM_TYPE_VOICECALL);
+
+ emulator->voicecall = voicecall;
+}
+
static DBusMessage *emulator_get_properties(DBusConnection *conn,
DBusMessage *msg, void *data)
{
@@ -60,6 +168,8 @@ static DBusMessage *emulator_enable(DBusConnection *conn,
{
struct ofono_emulator *emulator = data;
+ ofono_emulator_watch_voicecall(emulator);
+
if (emulator->driver->enable)
emulator->driver->enable(emulator);
--
1.6.6.1
^ permalink raw reply related [flat|nested] 10+ messages in thread
* [PATCH 6/8] Add prototype to watch voicecall
2010-04-13 14:18 ` [PATCH 5/8] Add emulator dialing call support Zhenhua Zhang
@ 2010-04-13 14:18 ` Zhenhua Zhang
2010-04-13 14:18 ` [PATCH 7/8] Add atemulator plugin Zhenhua Zhang
0 siblings, 1 reply; 10+ messages in thread
From: Zhenhua Zhang @ 2010-04-13 14:18 UTC (permalink / raw)
To: ofono
[-- Attachment #1: Type: text/plain, Size: 4911 bytes --]
---
src/emulator.c | 77 +++++++++++++++++++++++++++++++++++++++++++++++++++++++
src/ofono.h | 4 +++
src/voicecall.c | 33 +++++++++++++++++++++++
3 files changed, 114 insertions(+), 0 deletions(-)
diff --git a/src/emulator.c b/src/emulator.c
index e21d826..4b4591f 100644
--- a/src/emulator.c
+++ b/src/emulator.c
@@ -42,8 +42,24 @@ struct ofono_emulator {
void *driver_data;
struct ofono_atom *atom;
struct ofono_atom *voicecall; /* emulated voicecall atom */
+ GSList *calls;
+ int call_watch;
};
+static gint call_compare(gconstpointer a, gconstpointer b)
+{
+ const struct ofono_call *ca = a;
+ const struct ofono_call *cb = b;
+
+ if (ca->id < cb->id)
+ return -1;
+
+ if (ca->id > cb->id)
+ return 1;
+
+ return 0;
+}
+
/* steal from plugins/hfp.c */
static int send_method_call_with_reply(const char *dest, const char *path,
const char *interface, const char *method,
@@ -141,6 +157,62 @@ gboolean ofono_emulator_dial(struct ofono_emulator *emulator,
return TRUE;
}
+static GSList *parse_call_list(GSList *calls)
+{
+ GSList *new_calls = NULL;
+ GSList *l = NULL;
+ struct ofono_call *c;
+ struct ofono_call *nc;
+
+ for (l = calls; l; l = l->next) {
+ c = l->data;
+
+ nc = g_try_new0(struct ofono_call, 1);
+ if (!nc)
+ break;
+
+ memcpy(nc, c, sizeof(struct ofono_call));
+
+ new_calls = g_slist_insert_sorted(new_calls, nc, call_compare);
+ }
+
+ return new_calls;
+}
+
+static void voicecall_call_watch(GSList *calls, void *user_data)
+{
+ struct ofono_emulator *emulator = user_data;
+ GSList *new_calls, *n, *o;
+ struct ofono_call *nc, *oc;
+
+ new_calls = parse_call_list(calls);
+ n = new_calls;
+ o = emulator->calls;
+
+ while (n || o) {
+ nc = n ? n->data : NULL;
+ oc = o ? o->data : NULL;
+
+ if (oc && (!nc || (nc->id > oc->id))) {
+ /* a call is released */
+ o = o->next;
+ } else if (nc && (!oc || (nc->id < oc->id))) {
+ if (emulator->driver->notify_call)
+ emulator->driver->notify_call(emulator, nc);
+
+ n = n->next;
+ } else {
+ n = n->next;
+ o = o->next;
+ }
+ }
+
+ g_slist_foreach(emulator->calls, (GFunc) g_free, NULL);
+ g_slist_free(emulator->calls);
+
+ emulator->calls = new_calls;
+}
+
static void ofono_emulator_watch_voicecall(struct ofono_emulator *emulator)
{
struct ofono_modem *modem = __ofono_atom_get_modem(emulator->atom);
@@ -149,6 +221,11 @@ static void ofono_emulator_watch_voicecall(struct ofono_emulator *emulator)
voicecall = __ofono_modem_find_atom(modem, OFONO_ATOM_TYPE_VOICECALL);
emulator->voicecall = voicecall;
+ emulator->call_watch = __ofono_atom_add_signal_watch(voicecall,
+ OFONO_SIGNAL_TYPE_VOICECALL_STATUS,
+ (ofono_signal_watch_func)
+ voicecall_call_watch,
+ emulator, NULL);
}
static DBusMessage *emulator_get_properties(DBusConnection *conn,
diff --git a/src/ofono.h b/src/ofono.h
index 118406d..54c0a7b 100644
--- a/src/ofono.h
+++ b/src/ofono.h
@@ -125,6 +125,7 @@ enum ofono_atom_watch_condition {
enum ofono_signal_type {
OFONO_SIGNAL_TYPE_NETREG_STATUS = 0,
OFONO_SIGNAL_TYPE_SIM_READY = 1,
+ OFONO_SIGNAL_TYPE_VOICECALL_STATUS = 2,
};
typedef void (*ofono_atom_watch_func)(struct ofono_atom *atom,
@@ -189,6 +190,9 @@ void __ofono_atom_free(struct ofono_atom *atom);
#include <ofono/phonebook.h>
#include <ofono/sms.h>
#include <ofono/voicecall.h>
+
+typedef void (*ofono_voicecall_status_notify_cb_t)(GSList *calls, void *data);
+
#include <ofono/gprs.h>
#include <ofono/gprs-context.h>
#include <ofono/radio-settings.h>
diff --git a/src/voicecall.c b/src/voicecall.c
index 8bf6379..a80678a 100644
--- a/src/voicecall.c
+++ b/src/voicecall.c
@@ -682,6 +682,37 @@ static gboolean voicecalls_have_incoming(struct ofono_voicecall *vc)
return voicecalls_have_with_status(vc, CALL_STATUS_INCOMING);
}
+static void notify_call_watches(struct ofono_voicecall *vc)
+{
+ struct ofono_watchlist_item *item;
+ GSList *calls = NULL;
+ GSList *call_watches;
+ GSList *l;
+ struct voicecall *v;
+ ofono_voicecall_status_notify_cb_t notify;
+
+ for (l = vc->call_list; l; l = l->next) {
+ v = l->data;
+
+ calls = g_slist_prepend(calls, v->call);
+ }
+
+ if (calls)
+ calls = g_slist_reverse(calls);
+
+ call_watches = __ofono_atom_get_signal_watches(vc->atom,
+ OFONO_SIGNAL_TYPE_VOICECALL_STATUS);
+
+ for (l = call_watches; l; l = l->next) {
+ item = l->data;
+ notify = item->notify;
+
+ notify(calls, item->notify_data);
+ }
+
+ g_slist_free(calls);
+}
+
static gboolean real_emit_call_list_changed(void *data)
{
struct ofono_voicecall *vc = data;
@@ -700,6 +731,8 @@ static gboolean real_emit_call_list_changed(void *data)
vc->emit_calls_source = 0;
+ notify_call_watches(vc);
+
return FALSE;
}
--
1.6.6.1
^ permalink raw reply related [flat|nested] 10+ messages in thread
* [PATCH 7/8] Add atemulator plugin
2010-04-13 14:18 ` [PATCH 6/8] Add prototype to watch voicecall Zhenhua Zhang
@ 2010-04-13 14:18 ` Zhenhua Zhang
2010-04-13 14:18 ` [PATCH 8/8] Add emulator interface for phonesim Zhenhua Zhang
0 siblings, 1 reply; 10+ messages in thread
From: Zhenhua Zhang @ 2010-04-13 14:18 UTC (permalink / raw)
To: ofono
[-- Attachment #1: Type: text/plain, Size: 7838 bytes --]
---
Makefile.am | 3 +
plugins/atemulator.c | 299 ++++++++++++++++++++++++++++++++++++++++++++++++++
2 files changed, 302 insertions(+), 0 deletions(-)
create mode 100644 plugins/atemulator.c
diff --git a/Makefile.am b/Makefile.am
index eda7ad6..3abd577 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -217,6 +217,9 @@ builtin_sources += plugins/palmpre.c
builtin_modules += ste
builtin_sources += plugins/ste.c
+builtin_modules += atemulator
+builtin_sources += plugins/atemulator.c
+
endif
if MAINTAINER_MODE
diff --git a/plugins/atemulator.c b/plugins/atemulator.c
new file mode 100644
index 0000000..8a8c79c
--- /dev/null
+++ b/plugins/atemulator.c
@@ -0,0 +1,299 @@
+/*
+ *
+ * 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
+
+#include <errno.h>
+#include <unistd.h>
+#include <stdlib.h>
+#include <string.h>
+#include <sys/socket.h>
+#include <netinet/in.h>
+#include <arpa/inet.h>
+
+#include <glib.h>
+
+#define OFONO_API_SUBJECT_TO_CHANGE
+#include <ofono/plugin.h>
+#include <ofono/log.h>
+#include <ofono/modem.h>
+#include <ofono/emulator.h>
+
+#include <utmp.h>
+#include <pty.h>
+
+#include "gatserver.h"
+
+struct at_emulator_data {
+ GAtServer *server;
+ GIOChannel *client_io;
+};
+
+static GAtServerResult dial_voicecall(struct ofono_emulator *emulator,
+ const char *dial_str)
+{
+ GAtServerResult res = G_AT_SERVER_RESULT_ERROR;
+ char c;
+ char *number;
+ int len = strlen(dial_str);
+
+ /* Skip last comma */
+ len--;
+
+ c = dial_str[len-1];
+ /* Skip closed user group flag */
+ if (c == 'G' || c == 'g')
+ len--;
+
+ c = dial_str[len-1];
+ /* Skip caller id suppress flag */
+ if (c == 'I' || c == 'i')
+ len--;
+
+ number = g_strndup(dial_str, len);
+
+ if (!ofono_emulator_dial(emulator, number))
+ goto done;
+
+ res = G_AT_SERVER_RESULT_OK;
+
+done:
+ if (number)
+ g_free(number);
+
+ return res;
+}
+
+static GAtServerResult dial_call(struct ofono_emulator *emulator,
+ const char *dial_str)
+{
+ struct at_emulator_data *data = ofono_emulator_get_data(emulator);
+ GAtServer *server = data->server;
+ GAtServerResult res = G_AT_SERVER_RESULT_ERROR;
+
+ if (dial_str[0] == '*' || dial_str[0] == '#') {
+ /* Supplementary service request */
+ sleep(2);
+ g_at_server_send_intermediate(server, "CONNECT");
+ sleep(2);
+
+ /* Perform PPP connection */
+ res = G_AT_SERVER_RESULT_OK;
+ } else
+ /* Voice call */
+ res = dial_voicecall(emulator, dial_str);
+
+ return res;
+}
+
+static void dial_cb(GAtServerRequestType type, GAtResult *result,
+ gpointer user_data)
+{
+ struct ofono_emulator *emulator = user_data;
+ struct at_emulator_data *data = ofono_emulator_get_data(emulator);
+ GAtServer *server = data->server;
+ GAtServerResult res = G_AT_SERVER_RESULT_ERROR;
+ GAtResultIter iter;
+ const char *dial_str;
+
+ if (type != G_AT_SERVER_REQUEST_TYPE_SET)
+ goto done;
+
+ g_at_result_iter_init(&iter, result);
+
+ if (!g_at_result_iter_next(&iter, "D"))
+ goto done;
+
+ dial_str = g_at_result_iter_raw_line(&iter);
+ if (!dial_str)
+ goto done;
+
+ res = dial_call(emulator, dial_str);
+
+done:
+ g_at_server_send_final(server, res);
+}
+
+static void at_notify_call(struct ofono_emulator *emulator,
+ struct ofono_call *nc)
+{
+ DBG("notify new call %s\n", nc->phone_number.number);
+}
+
+static void voicecall_enable(struct ofono_emulator *emulator)
+{
+ struct at_emulator_data *data = ofono_emulator_get_data(emulator);
+ GAtServer *server = data->server;
+
+ g_at_server_register(server, "D", dial_cb, emulator, NULL);
+}
+
+static int at_emulator_probe(struct ofono_emulator *emulator)
+{
+ struct at_emulator_data *data;
+
+ DBG("%p", emulator);
+
+ data = g_try_new0(struct at_emulator_data, 1);
+ if (!data)
+ return -ENOMEM;
+
+ ofono_emulator_set_data(emulator, data);
+
+ ofono_emulator_register(emulator);
+
+ return 0;
+}
+
+static void at_emulator_remove(struct ofono_emulator *emulator)
+{
+ struct at_emulator_data *data = ofono_emulator_get_data(emulator);
+
+ DBG("%p", emulator);
+
+ g_free(data);
+ ofono_emulator_set_data(emulator, NULL);
+}
+
+static void at_emulator_debug(const char *str, void *user_data)
+{
+ ofono_info("%s", str);
+}
+
+static void set_raw_mode(int fd)
+{
+ struct termios options;
+
+ tcgetattr(fd, &options);
+
+ /* Set TTY as raw mode to disable echo back of input characters
+ * when they are received from Modem to avoid feedback loop */
+ options.c_lflag &= ~(ICANON | ECHO | ECHOE | ISIG);
+
+ tcsetattr(fd, TCSANOW, &options);
+}
+
+static int create_tty(GIOChannel *client_io)
+{
+ int master, slave;
+ char pty_name[256];
+
+ if (openpty(&master, &slave, pty_name, NULL, NULL) < 0)
+ return 0;
+
+ set_raw_mode(slave);
+
+ client_io = g_io_channel_unix_new(slave);
+ g_io_channel_set_close_on_unref(client_io, TRUE);
+
+ DBG("new pty is created@%s\n", pty_name);
+
+ return master;
+}
+
+static int at_emulator_enable(struct ofono_emulator *emulator)
+{
+ GAtServer *server;
+ GIOChannel *server_io;
+ GIOChannel *client_io = NULL;
+ int master;
+ int ret = 0;
+ struct at_emulator_data *data = ofono_emulator_get_data(emulator);
+
+ DBG("%p", emulator);
+
+ master = create_tty(client_io);
+ if (!master) {
+ ret = -EIO;
+ goto error;
+ }
+
+ server_io = g_io_channel_unix_new(master);
+ if (!server_io) {
+ g_io_channel_shutdown(server_io, FALSE, NULL);
+ g_io_channel_unref(server_io);
+
+ ret = -EIO;
+ goto error;
+ }
+
+ server = g_at_server_new(server_io);
+ if (!server) {
+ g_io_channel_shutdown(server_io, FALSE, NULL);
+ g_io_channel_unref(server_io);
+
+ return FALSE;
+ }
+
+ data->server = server;
+ data->client_io = client_io;
+
+ if (getenv("OFONO_AT_DEBUG"))
+ g_at_server_set_debug(server, at_emulator_debug, NULL);
+
+ voicecall_enable(emulator);
+
+ return 0;
+
+error:
+ g_free(data);
+
+ return ret;
+}
+
+static int at_emulator_disable(struct ofono_emulator *emulator)
+{
+ struct at_emulator_data *data = ofono_emulator_get_data(emulator);
+
+ DBG("%p", emulator);
+
+ g_io_channel_unref(data->client_io);
+ g_at_server_unref(data->server);
+ g_at_server_shutdown(data->server);
+ data->server = NULL;
+
+ return 0;
+}
+
+static struct ofono_emulator_driver at_emulator_driver = {
+ .name = "atemulator",
+ .probe = at_emulator_probe,
+ .remove = at_emulator_remove,
+ .enable = at_emulator_enable,
+ .disable = at_emulator_disable,
+ .notify_call = at_notify_call,
+};
+
+static int at_emulator_init(void)
+{
+ return ofono_emulator_driver_register(&at_emulator_driver);
+}
+
+static void at_emulator_exit(void)
+{
+ ofono_emulator_driver_unregister(&at_emulator_driver);
+}
+
+OFONO_PLUGIN_DEFINE(atemulator, "AT server emulator", VERSION,
+ OFONO_PLUGIN_PRIORITY_DEFAULT, at_emulator_init,
+ at_emulator_exit)
--
1.6.6.1
^ permalink raw reply related [flat|nested] 10+ messages in thread
* [PATCH 8/8] Add emulator interface for phonesim
2010-04-13 14:18 ` [PATCH 7/8] Add atemulator plugin Zhenhua Zhang
@ 2010-04-13 14:18 ` Zhenhua Zhang
0 siblings, 0 replies; 10+ messages in thread
From: Zhenhua Zhang @ 2010-04-13 14:18 UTC (permalink / raw)
To: ofono
[-- Attachment #1: Type: text/plain, Size: 770 bytes --]
---
plugins/phonesim.c | 3 +++
1 files changed, 3 insertions(+), 0 deletions(-)
diff --git a/plugins/phonesim.c b/plugins/phonesim.c
index ca12cf2..15dabca 100644
--- a/plugins/phonesim.c
+++ b/plugins/phonesim.c
@@ -56,6 +56,7 @@
#include <ofono/voicecall.h>
#include <ofono/gprs.h>
#include <ofono/gprs-context.h>
+#include <ofono/emulator.h>
#include <drivers/atmodem/vendor.h>
@@ -287,6 +288,8 @@ static void phonesim_pre_sim(struct ofono_modem *modem)
ofono_voicecall_create(modem, 0, "calypsomodem", data->chat);
else
ofono_voicecall_create(modem, 0, "atmodem", data->chat);
+
+ ofono_emulator_create(modem, 0, "atemulator", data->chat);
}
static void phonesim_post_sim(struct ofono_modem *modem)
--
1.6.6.1
^ permalink raw reply related [flat|nested] 10+ messages in thread
* Re: [PATCH 4/8] Add skeleton of src/emulator.c
2010-04-13 14:18 ` [PATCH 4/8] Add skeleton of src/emulator.c Zhenhua Zhang
2010-04-13 14:18 ` [PATCH 5/8] Add emulator dialing call support Zhenhua Zhang
@ 2010-04-16 20:17 ` Denis Kenzior
1 sibling, 0 replies; 10+ messages in thread
From: Denis Kenzior @ 2010-04-16 20:17 UTC (permalink / raw)
To: ofono
[-- Attachment #1: Type: text/plain, Size: 963 bytes --]
Hi Zhenhua,
> ---
> Makefile.am | 7 +-
> include/dbus.h | 1 +
> include/emulator.h | 75 +++++++++++++++++++
> src/emulator.c | 203
> ++++++++++++++++++++++++++++++++++++++++++++++++++++ src/ofono.h
|
> 4 +
> 5 files changed, 287 insertions(+), 3 deletions(-)
> create mode 100644 include/emulator.h
> create mode 100644 src/emulator.c
>
I suggest we handle this one a bit differently. Let us create an Emulator atom
that has no driver (similar to how MessageWaiting atom works). Then have each
interested atom declare an atom watch on the Emulator atom. When one is
created, let the atom get notified and register any AT command handlers it
wishes. If the atom itself goes away, it needs to de-register at commands
from all relevant emulators.
Potentially there might be several emulators at once in the system (e.g. one
for DUN, one for HFP, one for SPP, etc)
Regards,
-Denis
^ permalink raw reply [flat|nested] 10+ messages in thread
end of thread, other threads:[~2010-04-16 20:17 UTC | newest]
Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-04-13 14:18 [PATCH 0/8] Prototype to integrate gatserver with oFono Zhenhua Zhang
2010-04-13 14:18 ` [PATCH 1/8] Add signal watches for atom Zhenhua Zhang
2010-04-13 14:18 ` [PATCH 2/8] Refactor netreg watchlist with atom watchlist Zhenhua Zhang
2010-04-13 14:18 ` [PATCH 3/8] Refactor sim " Zhenhua Zhang
2010-04-13 14:18 ` [PATCH 4/8] Add skeleton of src/emulator.c Zhenhua Zhang
2010-04-13 14:18 ` [PATCH 5/8] Add emulator dialing call support Zhenhua Zhang
2010-04-13 14:18 ` [PATCH 6/8] Add prototype to watch voicecall Zhenhua Zhang
2010-04-13 14:18 ` [PATCH 7/8] Add atemulator plugin Zhenhua Zhang
2010-04-13 14:18 ` [PATCH 8/8] Add emulator interface for phonesim Zhenhua Zhang
2010-04-16 20:17 ` [PATCH 4/8] Add skeleton of src/emulator.c Denis Kenzior
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.