* [PATCH 1/5] text-telephony: add public header
@ 2010-11-25 17:41 Lucas De Marchi
2010-11-25 17:41 ` [PATCH 2/5] text-telephony: implement interface/atom Lucas De Marchi
` (4 more replies)
0 siblings, 5 replies; 18+ messages in thread
From: Lucas De Marchi @ 2010-11-25 17:41 UTC (permalink / raw)
To: ofono
[-- Attachment #1: Type: text/plain, Size: 3056 bytes --]
---
Makefile.am | 3 +-
include/ctm.h | 71 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++
2 files changed, 73 insertions(+), 1 deletions(-)
create mode 100644 include/ctm.h
diff --git a/Makefile.am b/Makefile.am
index f841b4c..2615be7 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/ctm.h
nodist_include_HEADERS = include/version.h
diff --git a/include/ctm.h b/include/ctm.h
new file mode 100644
index 0000000..4b07192
--- /dev/null
+++ b/include/ctm.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_CTM_H
+#define __OFONO_CTM_H
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#include <ofono/types.h>
+
+struct ofono_ctm;
+
+typedef void (*ofono_ctm_set_cb_t)(const struct ofono_error *error,
+ void *data);
+typedef void (*ofono_ctm_query_cb_t)(const struct ofono_error *error,
+ ofono_bool_t enable, void *data);
+
+struct ofono_ctm_driver {
+ const char *name;
+ int (*probe)(struct ofono_ctm *tt, unsigned int vendor,
+ void *data);
+ void (*remove)(struct ofono_ctm *tt);
+ void (*query_tty)(struct ofono_ctm *tt,
+ ofono_ctm_query_cb_t cb,
+ void *data);
+ void (*set_tty)(struct ofono_ctm *tt,
+ int enable,
+ ofono_ctm_set_cb_t cb,
+ void *data);
+};
+
+int ofono_ctm_driver_register(const struct ofono_ctm_driver *d);
+void ofono_ctm_driver_unregister(const struct ofono_ctm_driver *d);
+
+struct ofono_ctm *ofono_ctm_create(struct ofono_modem *modem,
+ unsigned int vendor,
+ const char *driver,
+ void *data);
+
+void ofono_ctm_register(struct ofono_ctm *tt);
+void ofono_ctm_remove(struct ofono_ctm *tt);
+
+void ofono_ctm_set_data(struct ofono_ctm *tt, void *data);
+void *ofono_ctm_get_data(struct ofono_ctm *tt);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* __OFONO_TEXT_TELEPHONY_H */
--
1.7.3.2
^ permalink raw reply related [flat|nested] 18+ messages in thread
* [PATCH 2/5] text-telephony: implement interface/atom
2010-11-25 17:41 [PATCH 1/5] text-telephony: add public header Lucas De Marchi
@ 2010-11-25 17:41 ` Lucas De Marchi
2010-11-26 19:28 ` Denis Kenzior
2010-11-25 17:41 ` [PATCH 3/5] text-telephony: add documentation Lucas De Marchi
` (3 subsequent siblings)
4 siblings, 1 reply; 18+ messages in thread
From: Lucas De Marchi @ 2010-11-25 17:41 UTC (permalink / raw)
To: ofono
[-- Attachment #1: Type: text/plain, Size: 10012 bytes --]
---
Makefile.am | 2 +-
src/ctm.c | 334 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
src/ofono.h | 2 +
3 files changed, 337 insertions(+), 1 deletions(-)
create mode 100644 src/ctm.c
diff --git a/Makefile.am b/Makefile.am
index 2615be7..93db7ea 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -319,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/ctm.c
src_ofonod_LDADD = $(builtin_libadd) @GLIB_LIBS@ @DBUS_LIBS@ @CAPNG_LIBS@ -ldl
diff --git a/src/ctm.c b/src/ctm.c
new file mode 100644
index 0000000..1d683df
--- /dev/null
+++ b/src/ctm.c
@@ -0,0 +1,334 @@
+/*
+ *
+ * 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
+ *
+ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include <string.h>
+#include <stdio.h>
+#include <errno.h>
+
+#include <glib.h>
+#include <gdbus.h>
+
+#include "ofono.h"
+#include "common.h"
+
+#define CTM_FLAG_CACHED 0x1
+
+static GSList *g_drivers = NULL;
+
+struct ofono_ctm {
+ DBusMessage *pending;
+ int flags;
+ ofono_bool_t enabled;
+ const struct ofono_ctm_driver *driver;
+ void *driver_data;
+ struct ofono_atom *atom;
+};
+
+static DBusMessage *ctm_get_properties_reply(DBusMessage *msg,
+ struct ofono_ctm *ctm)
+{
+ DBusMessage *reply;
+ DBusMessageIter iter;
+ DBusMessageIter dict;
+ dbus_bool_t value;
+
+ reply = dbus_message_new_method_return(msg);
+ if (reply == NULL)
+ return NULL;
+
+ dbus_message_iter_init_append(reply, &iter);
+ dbus_message_iter_open_container(&iter, DBUS_TYPE_ARRAY,
+ OFONO_PROPERTIES_ARRAY_SIGNATURE,
+ &dict);
+
+ value = ctm->enabled;
+ ofono_dbus_dict_append(&dict, "Enabled", DBUS_TYPE_BOOLEAN, &value);
+ dbus_message_iter_close_container(&iter, &dict);
+
+ return reply;
+}
+
+static void ctm_signal_enabled(struct ofono_ctm *ctm)
+{
+ DBusConnection *conn = ofono_dbus_get_connection();
+ const char *path = __ofono_atom_get_path(ctm->atom);
+ ofono_bool_t value = ctm->enabled;
+
+ ofono_dbus_signal_property_changed(conn, path,
+ OFONO_TEXT_TELEPHONY_INTERFACE,
+ "Enabled",
+ DBUS_TYPE_BOOLEAN, &value);
+}
+
+static void ctm_set_enabled_callback(const struct ofono_error *error,
+ void *data)
+{
+ struct ofono_ctm *ctm = data;
+ DBusMessage *reply;
+
+ if (error->type != OFONO_ERROR_TYPE_NO_ERROR) {
+ DBG("Error setting ctm enabled property");
+
+ reply = __ofono_error_failed(ctm->pending);
+ __ofono_dbus_pending_reply(&ctm->pending, reply);
+
+ return;
+ }
+
+ ctm->enabled = !ctm->enabled;
+
+ reply = dbus_message_new_method_return(ctm->pending);
+ __ofono_dbus_pending_reply(&ctm->pending, reply);
+
+ ctm_signal_enabled(ctm);
+}
+
+static void ctm_query_enabled_callback(const struct ofono_error *error,
+ ofono_bool_t enable, void *data)
+{
+ struct ofono_ctm *ctm = data;
+ DBusMessage *reply;
+ ofono_bool_t enabled_old;
+
+ if (error->type != OFONO_ERROR_TYPE_NO_ERROR) {
+ DBusMessage *reply;
+
+ DBG("Error during ctm enabled query");
+
+ reply = __ofono_error_failed(ctm->pending);
+ __ofono_dbus_pending_reply(&ctm->pending, reply);
+
+ return;
+ }
+
+ ctm->flags |= CTM_FLAG_CACHED;
+
+ enabled_old = ctm->enabled;
+ ctm->enabled = enable;
+
+ reply = ctm_get_properties_reply(ctm->pending, ctm);
+ __ofono_dbus_pending_reply(&ctm->pending, reply);
+
+ if (ctm->enabled ^ enabled_old)
+ ctm_signal_enabled(ctm);
+}
+
+static DBusMessage *ctm_get_properties(DBusConnection *conn,
+ DBusMessage *msg, void *data)
+{
+ struct ofono_ctm *ctm = data;
+
+ if (ctm->flags & CTM_FLAG_CACHED)
+ return ctm_get_properties_reply(msg, ctm);
+
+ if (ctm->pending)
+ return __ofono_error_busy(msg);
+
+ ctm->pending = dbus_message_ref(msg);
+
+ ctm->driver->query_tty(ctm, ctm_query_enabled_callback, ctm);
+
+ return NULL;
+}
+
+static DBusMessage *ctm_set_property(DBusConnection *conn, DBusMessage *msg,
+ void *data)
+{
+ struct ofono_ctm *ctm = data;
+ DBusMessageIter iter;
+ DBusMessageIter var;
+ const char *property;
+
+ if (ctm->pending)
+ return __ofono_error_busy(msg);
+
+ if (!dbus_message_iter_init(msg, &iter))
+ return __ofono_error_invalid_args(msg);
+
+ if (dbus_message_iter_get_arg_type(&iter) != DBUS_TYPE_STRING)
+ return __ofono_error_invalid_args(msg);
+
+ dbus_message_iter_get_basic(&iter, &property);
+ dbus_message_iter_next(&iter);
+
+ if (dbus_message_iter_get_arg_type(&iter) != DBUS_TYPE_VARIANT)
+ return __ofono_error_invalid_args(msg);
+
+ dbus_message_iter_recurse(&iter, &var);
+
+ if (g_strcmp0(property, "Enabled") == 0) {
+ dbus_bool_t value;
+ int target;
+
+ if (dbus_message_iter_get_arg_type(&var) != DBUS_TYPE_BOOLEAN)
+ return __ofono_error_invalid_args(msg);
+
+ dbus_message_iter_get_basic(&var, &value);
+ target = value;
+
+ if (ctm->enabled == target)
+ return dbus_message_new_method_return(msg);
+
+ ctm->pending = dbus_message_ref(msg);
+
+ ctm->driver->set_tty(ctm, target,
+ ctm_set_enabled_callback, ctm);
+ return NULL;
+ }
+
+ return __ofono_error_invalid_args(msg);
+}
+
+static GDBusMethodTable ctm_methods[] = {
+ { "GetProperties", "", "a{sv}", ctm_get_properties,
+ G_DBUS_METHOD_FLAG_ASYNC },
+ { "SetProperty", "sv", "", ctm_set_property,
+ G_DBUS_METHOD_FLAG_ASYNC },
+ { }
+};
+
+static GDBusSignalTable ctm_signals[] = {
+ { "PropertyChanged", "sv" },
+ { }
+};
+
+int ofono_ctm_driver_register(const struct ofono_ctm_driver *d)
+{
+ DBG("driver: %p, name: %s", d, d->name);
+
+ if (d == NULL || d->probe == NULL)
+ return -EINVAL;
+
+ g_drivers = g_slist_prepend(g_drivers, (void *)d);
+
+ return 0;
+}
+
+void ofono_ctm_driver_unregister(const struct ofono_ctm_driver *d)
+{
+ DBG("driver: %p, name: %s", d, d->name);
+
+ if (d == NULL)
+ return;
+
+ g_drivers = g_slist_remove(g_drivers, (void *)d);
+}
+
+static void text_telephony_unregister(struct ofono_atom *atom)
+{
+ struct ofono_ctm *ctm = __ofono_atom_get_data(atom);
+ const char *path = __ofono_atom_get_path(ctm->atom);
+ DBusConnection *conn = ofono_dbus_get_connection();
+ struct ofono_modem *modem = __ofono_atom_get_modem(ctm->atom);
+
+ ofono_modem_remove_interface(modem, OFONO_TEXT_TELEPHONY_INTERFACE);
+ g_dbus_unregister_interface(conn, path, OFONO_TEXT_TELEPHONY_INTERFACE);
+}
+
+static void text_telephony_remove(struct ofono_atom *atom)
+{
+ struct ofono_ctm *ctm = __ofono_atom_get_data(atom);
+
+ DBG("atom: %p", atom);
+
+ if (ctm == NULL)
+ return;
+
+ if (ctm->driver && ctm->driver->remove)
+ ctm->driver->remove(ctm);
+
+ g_free(ctm);
+}
+
+struct ofono_ctm *ofono_ctm_create(struct ofono_modem *modem,
+ unsigned int vendor,
+ const char *driver,
+ void *data)
+{
+ struct ofono_ctm *ctm;
+ GSList *l;
+
+ if (driver == NULL)
+ return NULL;
+
+ ctm = g_try_new0(struct ofono_ctm, 1);
+ if (ctm == NULL)
+ return NULL;
+
+ ctm->atom = __ofono_modem_add_atom(modem, OFONO_ATOM_TYPE_CTM,
+ text_telephony_remove, ctm);
+
+ for (l = g_drivers; l; l = l->next) {
+ const struct ofono_ctm_driver *drv = l->data;
+
+ if (g_strcmp0(drv->name, driver) != 0)
+ continue;
+
+ if (drv->probe(ctm, vendor, data) < 0)
+ continue;
+
+ ctm->driver = drv;
+ break;
+ }
+
+ return ctm;
+}
+
+void ofono_ctm_register(struct ofono_ctm *ctm)
+{
+ DBusConnection *conn = ofono_dbus_get_connection();
+ struct ofono_modem *modem = __ofono_atom_get_modem(ctm->atom);
+ const char *path = __ofono_atom_get_path(ctm->atom);
+
+ if (!g_dbus_register_interface(conn, path,
+ OFONO_TEXT_TELEPHONY_INTERFACE,
+ ctm_methods, ctm_signals,
+ NULL, ctm, NULL)) {
+ ofono_error("Could not create %s interface",
+ OFONO_TEXT_TELEPHONY_INTERFACE);
+
+ return;
+ }
+
+ ofono_modem_add_interface(modem, OFONO_TEXT_TELEPHONY_INTERFACE);
+ __ofono_atom_register(ctm->atom, text_telephony_unregister);
+}
+
+void ofono_ctm_remove(struct ofono_ctm *ctm)
+{
+ __ofono_atom_free(ctm->atom);
+}
+
+void ofono_ctm_set_data(struct ofono_ctm *ctm,
+ void *data)
+{
+ ctm->driver_data = data;
+}
+
+void *ofono_ctm_get_data(struct ofono_ctm *ctm)
+{
+ return ctm->driver_data;
+}
diff --git a/src/ofono.h b/src/ofono.h
index d1a4bdc..792134b 100644
--- a/src/ofono.h
+++ b/src/ofono.h
@@ -125,6 +125,7 @@ enum ofono_atom_type {
OFONO_ATOM_TYPE_AUDIO_SETTINGS = 19,
OFONO_ATOM_TYPE_STK = 20,
OFONO_ATOM_TYPE_NETTIME = 21,
+ OFONO_ATOM_TYPE_CTM = 22,
};
enum ofono_atom_watch_condition {
@@ -205,6 +206,7 @@ gboolean __ofono_call_settings_is_busy(struct ofono_call_settings *cs);
#include <ofono/gprs-context.h>
#include <ofono/radio-settings.h>
#include <ofono/audio-settings.h>
+#include <ofono/ctm.h>
#include <ofono/voicecall.h>
--
1.7.3.2
^ permalink raw reply related [flat|nested] 18+ messages in thread
* [PATCH 3/5] text-telephony: add documentation
2010-11-25 17:41 [PATCH 1/5] text-telephony: add public header Lucas De Marchi
2010-11-25 17:41 ` [PATCH 2/5] text-telephony: implement interface/atom Lucas De Marchi
@ 2010-11-25 17:41 ` Lucas De Marchi
2010-11-26 19:29 ` Denis Kenzior
2010-11-25 17:41 ` [PATCH 4/5] phonesim: implement text-telephony atom Lucas De Marchi
` (2 subsequent siblings)
4 siblings, 1 reply; 18+ messages in thread
From: Lucas De Marchi @ 2010-11-25 17:41 UTC (permalink / raw)
To: ofono
[-- Attachment #1: Type: text/plain, Size: 2074 bytes --]
---
Makefile.am | 2 +-
doc/text-telephony-api.txt | 39 +++++++++++++++++++++++++++++++++++++++
2 files changed, 40 insertions(+), 1 deletions(-)
create mode 100644 doc/text-telephony-api.txt
diff --git a/Makefile.am b/Makefile.am
index 93db7ea..77965d4 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -356,7 +356,7 @@ doc_files = doc/overview.txt doc/ofono-paper.txt \
doc/message-api.txt doc/message-waiting-api.txt \
doc/phonebook-api.txt doc/radio-settings-api.txt \
doc/sim-api.txt doc/stk-api.txt \
- doc/audio-settings-api.txt
+ doc/audio-settings-api.txt doc/text-telephony-api.txt
test_scripts = test/backtrace \
diff --git a/doc/text-telephony-api.txt b/doc/text-telephony-api.txt
new file mode 100644
index 0000000..3fa7942
--- /dev/null
+++ b/doc/text-telephony-api.txt
@@ -0,0 +1,39 @@
+Text Telephony hierarchy
+========================
+
+Service org.ofono
+Interface org.ofono.TextTelephony
+Object path [variable prefix]/{modem0,modem1,...}
+
+Methods dict GetProperties()
+
+ Returns all Text Telephony properties. See the
+ properties section for available properties.
+
+ Possible Errors: [service].Error.InProgress
+ [service].Error.Failed
+
+ void SetProperty(string name, variant value)
+
+ Changes the value of the specified property. Only
+ properties that are listed as read-write are
+ changeable. On success a PropertyChanged signal
+ will be emitted.
+
+ Possible Errors: [service].Error.InvalidArguments
+ [service].Error.InProgress
+ [service].Error.Failed
+
+Signals PropertyChanged(string property, variant value)
+
+ This signal indicates a changed value of the given
+ property.
+
+Properties boolean Powered [readwrite]
+
+ This property will enable or disable the text
+ telephony feature in the modem.
+
+ Text telephony (TTY), also known as Cellular Text Modem
+ (CTM), is a feature present in some modems that allow
+ them to be used by hearing impaired people.
--
1.7.3.2
^ permalink raw reply related [flat|nested] 18+ messages in thread
* [PATCH 4/5] phonesim: implement text-telephony atom
2010-11-25 17:41 [PATCH 1/5] text-telephony: add public header Lucas De Marchi
2010-11-25 17:41 ` [PATCH 2/5] text-telephony: implement interface/atom Lucas De Marchi
2010-11-25 17:41 ` [PATCH 3/5] text-telephony: add documentation Lucas De Marchi
@ 2010-11-25 17:41 ` Lucas De Marchi
2010-11-26 19:17 ` Denis Kenzior
2010-11-25 17:42 ` [PATCH 5/5] Add script to enable/disable text-telephony support Lucas De Marchi
2010-11-26 19:27 ` [PATCH 1/5] text-telephony: add public header Denis Kenzior
4 siblings, 1 reply; 18+ messages in thread
From: Lucas De Marchi @ 2010-11-25 17:41 UTC (permalink / raw)
To: ofono
[-- Attachment #1: Type: text/plain, Size: 5284 bytes --]
---
plugins/phonesim.c | 148 ++++++++++++++++++++++++++++++++++++++++++++++++++--
1 files changed, 144 insertions(+), 4 deletions(-)
diff --git a/plugins/phonesim.c b/plugins/phonesim.c
index d2faf42..ec06741 100644
--- a/plugins/phonesim.c
+++ b/plugins/phonesim.c
@@ -46,6 +46,7 @@
#include <ofono/call-settings.h>
#include <ofono/call-volume.h>
#include <ofono/cbs.h>
+#include <ofono/ctm.h>
#include <ofono/devinfo.h>
#include <ofono/message-waiting.h>
#include <ofono/netreg.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_ctm *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_ctm_set_data(tt, ttd);
+ ofono_ctm_register(tt);
+
+ return 0;
+}
+
+static void phonesim_tty_remove(struct ofono_ctm *tt)
+{
+ struct text_telephony_data *ttd = ofono_ctm_get_data(tt);
+
+ DBG("");
+
+ ofono_ctm_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_ctm_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_ctm *tt,
+ ofono_ctm_query_cb_t cb, void *data)
+{
+ struct text_telephony_data *ttd = ofono_ctm_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_ctm_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_ctm *tt, int enable,
+ ofono_ctm_set_cb_t cb, void *data)
+{
+ struct text_telephony_data *ttd = ofono_ctm_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_ctm_driver tty_driver = {
.name = "phonesim",
- .probe = phonesim_context_probe,
- .remove = phonesim_context_remove,
- .activate_primary = phonesim_activate_primary,
- .deactivate_primary = phonesim_deactivate_primary,
+ .probe = phonesim_tty_probe,
+ .remove = phonesim_tty_remove,
+ .query_tty = phonesim_tty_query,
+ .set_tty = phonesim_tty_set,
};
static int phonesim_probe(struct ofono_modem *modem)
@@ -465,6 +600,7 @@ static void phonesim_post_sim(struct ofono_modem *modem)
DBG("%p", modem);
+ ofono_ctm_create(modem, 0, "phonesim", data->chat);
ofono_phonebook_create(modem, 0, "atmodem", data->chat);
if (!data->calypso)
@@ -630,6 +766,8 @@ static int phonesim_init(void)
ofono_gprs_context_driver_register(&context_driver);
+ ofono_ctm_driver_register(&tty_driver);
+
parse_config(CONFIGDIR "/phonesim.conf");
return 0;
@@ -648,6 +786,8 @@ static void phonesim_exit(void)
g_slist_free(modem_list);
modem_list = NULL;
+ ofono_ctm_driver_unregister(&tty_driver);
+
ofono_gprs_context_driver_unregister(&context_driver);
ofono_modem_driver_unregister(&phonesim_driver);
--
1.7.3.2
^ permalink raw reply related [flat|nested] 18+ messages in thread
* [PATCH 5/5] Add script to enable/disable text-telephony support
2010-11-25 17:41 [PATCH 1/5] text-telephony: add public header Lucas De Marchi
` (2 preceding siblings ...)
2010-11-25 17:41 ` [PATCH 4/5] phonesim: implement text-telephony atom Lucas De Marchi
@ 2010-11-25 17:42 ` Lucas De Marchi
2010-11-26 19:29 ` Denis Kenzior
2010-11-26 19:27 ` [PATCH 1/5] text-telephony: add public header Denis Kenzior
4 siblings, 1 reply; 18+ messages in thread
From: Lucas De Marchi @ 2010-11-25 17:42 UTC (permalink / raw)
To: ofono
[-- Attachment #1: Type: text/plain, Size: 935 bytes --]
---
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 0000000..67876af
--- /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("Enabled", dbus.Boolean(enable));
--
1.7.3.2
^ permalink raw reply related [flat|nested] 18+ messages in thread
* Re: [PATCH 4/5] phonesim: implement text-telephony atom
2010-11-25 17:41 ` [PATCH 4/5] phonesim: implement text-telephony atom Lucas De Marchi
@ 2010-11-26 19:17 ` Denis Kenzior
2010-11-27 0:44 ` [PATCH] phonesim: implement ctm atom Lucas De Marchi
0 siblings, 1 reply; 18+ messages in thread
From: Denis Kenzior @ 2010-11-26 19:17 UTC (permalink / raw)
To: ofono
[-- Attachment #1: Type: text/plain, Size: 6494 bytes --]
Hi Lucas,
On 11/25/2010 11:41 AM, Lucas De Marchi wrote:
> ---
> plugins/phonesim.c | 148 ++++++++++++++++++++++++++++++++++++++++++++++++++--
> 1 files changed, 144 insertions(+), 4 deletions(-)
>
> diff --git a/plugins/phonesim.c b/plugins/phonesim.c
> index d2faf42..ec06741 100644
> --- a/plugins/phonesim.c
> +++ b/plugins/phonesim.c
> @@ -46,6 +46,7 @@
> #include <ofono/call-settings.h>
> #include <ofono/call-volume.h>
> #include <ofono/cbs.h>
> +#include <ofono/ctm.h>
> #include <ofono/devinfo.h>
> #include <ofono/message-waiting.h>
> #include <ofono/netreg.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;
You actually do not need the interface string. That is only used by the
gprs context to return a dummy name to oFono core. For CTM you can get
away without having the text_telephony_data structure completely.
Simply use GAtChat as the data.
> +};
> +
> 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_ctm *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_ctm_set_data(tt, ttd);
> + ofono_ctm_register(tt);
In general it is not safe to register the atom before returning from
probe. Some atoms will run initialization operations on the driver once
register is called. Since probe has not returned, the driver is still
NULL. See how some of the other drivers handle this.
> +
> + return 0;
> +}
> +
> +static void phonesim_tty_remove(struct ofono_ctm *tt)
> +{
> + struct text_telephony_data *ttd = ofono_ctm_get_data(tt);
> +
> + DBG("");
> +
> + ofono_ctm_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_ctm_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_ctm *tt,
> + ofono_ctm_query_cb_t cb, void *data)
> +{
> + struct text_telephony_data *ttd = ofono_ctm_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_ctm_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_ctm *tt, int enable,
> + ofono_ctm_set_cb_t cb, void *data)
> +{
> + struct text_telephony_data *ttd = ofono_ctm_get_data(tt);
> + struct cb_data *cbd = cb_data_new(cb, data);
> + char buf[12];
Please give a bit more room for error in the buffer, if someone tweaks
this we can get into buffer overrun situation.
> +
> + DBG("");
> +
> + if (!cbd)
> + goto error;
> +
> + enable = !!enable;
As mentioned on IRC, this is not really necessary
> + 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_ctm_driver tty_driver = {
> .name = "phonesim",
> - .probe = phonesim_context_probe,
> - .remove = phonesim_context_remove,
> - .activate_primary = phonesim_activate_primary,
> - .deactivate_primary = phonesim_deactivate_primary,
> + .probe = phonesim_tty_probe,
> + .remove = phonesim_tty_remove,
> + .query_tty = phonesim_tty_query,
> + .set_tty = phonesim_tty_set,
> };
>
> static int phonesim_probe(struct ofono_modem *modem)
> @@ -465,6 +600,7 @@ static void phonesim_post_sim(struct ofono_modem *modem)
>
> DBG("%p", modem);
>
> + ofono_ctm_create(modem, 0, "phonesim", data->chat);
> ofono_phonebook_create(modem, 0, "atmodem", data->chat);
>
> if (!data->calypso)
> @@ -630,6 +766,8 @@ static int phonesim_init(void)
>
> ofono_gprs_context_driver_register(&context_driver);
>
> + ofono_ctm_driver_register(&tty_driver);
> +
> parse_config(CONFIGDIR "/phonesim.conf");
>
> return 0;
> @@ -648,6 +786,8 @@ static void phonesim_exit(void)
> g_slist_free(modem_list);
> modem_list = NULL;
>
> + ofono_ctm_driver_unregister(&tty_driver);
> +
> ofono_gprs_context_driver_unregister(&context_driver);
>
> ofono_modem_driver_unregister(&phonesim_driver);
Otherwise, looks good.
Regards,
-Denis
^ permalink raw reply [flat|nested] 18+ messages in thread
* Re: [PATCH 1/5] text-telephony: add public header
2010-11-25 17:41 [PATCH 1/5] text-telephony: add public header Lucas De Marchi
` (3 preceding siblings ...)
2010-11-25 17:42 ` [PATCH 5/5] Add script to enable/disable text-telephony support Lucas De Marchi
@ 2010-11-26 19:27 ` Denis Kenzior
2010-11-27 21:04 ` Bastian, Waldo
4 siblings, 1 reply; 18+ messages in thread
From: Denis Kenzior @ 2010-11-26 19:27 UTC (permalink / raw)
To: ofono
[-- Attachment #1: Type: text/plain, Size: 1271 bytes --]
Hi Lucas,
I applied this patch, but amended it a bit afterwards. See below:
<snip>
> +struct ofono_ctm_driver {
> + const char *name;
> + int (*probe)(struct ofono_ctm *tt, unsigned int vendor,
> + void *data);
So I had to change the *tt variable name to *ctm everywhere
> + void (*remove)(struct ofono_ctm *tt);
> + void (*query_tty)(struct ofono_ctm *tt,
> + ofono_ctm_query_cb_t cb,
> + void *data);
> + void (*set_tty)(struct ofono_ctm *tt,
> + int enable,
I also changed this to ofono_bool_t enable
> + ofono_ctm_set_cb_t cb,
> + void *data);
> +};
> +
> +int ofono_ctm_driver_register(const struct ofono_ctm_driver *d);
> +void ofono_ctm_driver_unregister(const struct ofono_ctm_driver *d);
> +
> +struct ofono_ctm *ofono_ctm_create(struct ofono_modem *modem,
> + unsigned int vendor,
> + const char *driver,
> + void *data);
> +
> +void ofono_ctm_register(struct ofono_ctm *tt);
> +void ofono_ctm_remove(struct ofono_ctm *tt);
> +
> +void ofono_ctm_set_data(struct ofono_ctm *tt, void *data);
> +void *ofono_ctm_get_data(struct ofono_ctm *tt);
> +
> +#ifdef __cplusplus
> +}
> +#endif
> +
> +#endif /* __OFONO_TEXT_TELEPHONY_H */
And I fixed up this comment.
Regards,
-Denis
^ permalink raw reply [flat|nested] 18+ messages in thread
* Re: [PATCH 2/5] text-telephony: implement interface/atom
2010-11-25 17:41 ` [PATCH 2/5] text-telephony: implement interface/atom Lucas De Marchi
@ 2010-11-26 19:28 ` Denis Kenzior
0 siblings, 0 replies; 18+ messages in thread
From: Denis Kenzior @ 2010-11-26 19:28 UTC (permalink / raw)
To: ofono
[-- Attachment #1: Type: text/plain, Size: 402 bytes --]
Hi Lucas,
On 11/25/2010 11:41 AM, Lucas De Marchi wrote:
> ---
> Makefile.am | 2 +-
> src/ctm.c | 334 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
> src/ofono.h | 2 +
> 3 files changed, 337 insertions(+), 1 deletions(-)
> create mode 100644 src/ctm.c
>
This patch has been applied, thanks. I made a trivial style fix commit
afterwards.
Regards,
-Denis
^ permalink raw reply [flat|nested] 18+ messages in thread
* Re: [PATCH 3/5] text-telephony: add documentation
2010-11-25 17:41 ` [PATCH 3/5] text-telephony: add documentation Lucas De Marchi
@ 2010-11-26 19:29 ` Denis Kenzior
0 siblings, 0 replies; 18+ messages in thread
From: Denis Kenzior @ 2010-11-26 19:29 UTC (permalink / raw)
To: ofono
[-- Attachment #1: Type: text/plain, Size: 476 bytes --]
Hi Lucas,
On 11/25/2010 11:41 AM, Lucas De Marchi wrote:
> ---
> Makefile.am | 2 +-
> doc/text-telephony-api.txt | 39 +++++++++++++++++++++++++++++++++++++++
> 2 files changed, 40 insertions(+), 1 deletions(-)
> create mode 100644 doc/text-telephony-api.txt
>
Patch has been applied, however I made the following commit afterwards:
> +Properties boolean Powered [readwrite]
> +
This one was renamed to Enabled.
Regards,
-Denis
^ permalink raw reply [flat|nested] 18+ messages in thread
* Re: [PATCH 5/5] Add script to enable/disable text-telephony support
2010-11-25 17:42 ` [PATCH 5/5] Add script to enable/disable text-telephony support Lucas De Marchi
@ 2010-11-26 19:29 ` Denis Kenzior
0 siblings, 0 replies; 18+ messages in thread
From: Denis Kenzior @ 2010-11-26 19:29 UTC (permalink / raw)
To: ofono
[-- Attachment #1: Type: text/plain, Size: 332 bytes --]
Hi Lucas,
On 11/25/2010 11:42 AM, Lucas De Marchi wrote:
> ---
> test/set-tty | 25 +++++++++++++++++++++++++
> 1 files changed, 25 insertions(+), 0 deletions(-)
> create mode 100755 test/set-tty
>
Patch has been applied, however you forgot to add this to the
Makefile.am. Fixed it for you :)
Regards,
-Denis
^ permalink raw reply [flat|nested] 18+ messages in thread
* [PATCH] phonesim: implement ctm atom
2010-11-26 19:17 ` Denis Kenzior
@ 2010-11-27 0:44 ` Lucas De Marchi
2010-11-27 18:00 ` Denis Kenzior
0 siblings, 1 reply; 18+ messages in thread
From: Lucas De Marchi @ 2010-11-27 0:44 UTC (permalink / raw)
To: ofono
[-- Attachment #1: Type: text/plain, Size: 4861 bytes --]
---
plugins/phonesim.c | 140 ++++++++++++++++++++++++++++++++++++++++++++++++++--
1 files changed, 136 insertions(+), 4 deletions(-)
diff --git a/plugins/phonesim.c b/plugins/phonesim.c
index d2faf42..be2f931 100644
--- a/plugins/phonesim.c
+++ b/plugins/phonesim.c
@@ -46,6 +46,7 @@
#include <ofono/call-settings.h>
#include <ofono/call-volume.h>
#include <ofono/cbs.h>
+#include <ofono/ctm.h>
#include <ofono/devinfo.h>
#include <ofono/message-waiting.h>
#include <ofono/netreg.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 {
@@ -190,12 +192,137 @@ static void phonesim_context_remove(struct ofono_gprs_context *gc)
g_free(gcd);
}
+static void phonesim_ctm_support_cb(gboolean ok, GAtResult *result,
+ gpointer user_data)
+{
+ struct ofono_ctm *ctm = user_data;
+
+ if (!ok)
+ return;
+
+ ofono_ctm_register(ctm);
+}
+
+static int phonesim_ctm_probe(struct ofono_ctm *ctm,
+ unsigned int vendor, void *data)
+{
+ GAtChat *chat = data;
+
+ ofono_ctm_set_data(ctm, chat);
+
+ g_at_chat_send(chat, "AT+PTTY=?", ptty_prefix, phonesim_ctm_support_cb,
+ ctm, NULL);
+
+ return 0;
+}
+
+static void phonesim_ctm_remove(struct ofono_ctm *ctm)
+{
+ DBG("");
+
+ ofono_ctm_set_data(ctm, NULL);
+}
+
+static void ctm_query_cb(gboolean ok, GAtResult *result, gpointer user_data)
+{
+ struct cb_data *cbd = user_data;
+ struct ofono_error error;
+ GAtResultIter iter;
+ ofono_ctm_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_ctm_query(struct ofono_ctm *ctm,
+ ofono_ctm_query_cb_t cb, void *data)
+{
+ GAtChat *chat = ofono_ctm_get_data(ctm);
+ struct cb_data *cbd = cb_data_new(cb, data);
+
+ DBG("");
+
+ if (!cbd)
+ goto error;
+
+ if (g_at_chat_send(chat, "AT+PTTY?", ptty_prefix,
+ ctm_query_cb, cbd, g_free) > 0)
+ return;
+
+error:
+ g_free(cbd);
+
+ CALLBACK_WITH_FAILURE(cb, 0, data);
+}
+
+static void ctm_set_cb(gboolean ok, GAtResult *result, gpointer user_data)
+{
+ struct cb_data *cbd = user_data;
+ ofono_ctm_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_ctm_set(struct ofono_ctm *ctm, ofono_bool_t enable,
+ ofono_ctm_set_cb_t cb, void *data)
+{
+ GAtChat *chat = ofono_ctm_get_data(ctm);
+ struct cb_data *cbd = cb_data_new(cb, data);
+ char buf[20];
+
+ DBG("");
+
+ if (!cbd)
+ goto error;
+
+ snprintf(buf, sizeof(buf), "AT+PTTY=%d", enable);
+
+ if (g_at_chat_send(chat, buf, none_prefix,
+ ctm_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_ctm_driver ctm_driver = {
.name = "phonesim",
- .probe = phonesim_context_probe,
- .remove = phonesim_context_remove,
- .activate_primary = phonesim_activate_primary,
- .deactivate_primary = phonesim_deactivate_primary,
+ .probe = phonesim_ctm_probe,
+ .remove = phonesim_ctm_remove,
+ .query_tty = phonesim_ctm_query,
+ .set_tty = phonesim_ctm_set,
};
static int phonesim_probe(struct ofono_modem *modem)
@@ -465,6 +592,7 @@ static void phonesim_post_sim(struct ofono_modem *modem)
DBG("%p", modem);
+ ofono_ctm_create(modem, 0, "phonesim", data->chat);
ofono_phonebook_create(modem, 0, "atmodem", data->chat);
if (!data->calypso)
@@ -630,6 +758,8 @@ static int phonesim_init(void)
ofono_gprs_context_driver_register(&context_driver);
+ ofono_ctm_driver_register(&ctm_driver);
+
parse_config(CONFIGDIR "/phonesim.conf");
return 0;
@@ -648,6 +778,8 @@ static void phonesim_exit(void)
g_slist_free(modem_list);
modem_list = NULL;
+ ofono_ctm_driver_unregister(&ctm_driver);
+
ofono_gprs_context_driver_unregister(&context_driver);
ofono_modem_driver_unregister(&phonesim_driver);
--
1.7.3.2
^ permalink raw reply related [flat|nested] 18+ messages in thread
* Re: [PATCH] phonesim: implement ctm atom
2010-11-27 0:44 ` [PATCH] phonesim: implement ctm atom Lucas De Marchi
@ 2010-11-27 18:00 ` Denis Kenzior
2010-11-27 19:22 ` [PATCH 1/2] " Lucas De Marchi
2010-11-27 19:22 ` [PATCH 2/2] TODO: Mark CTM task as done Lucas De Marchi
0 siblings, 2 replies; 18+ messages in thread
From: Denis Kenzior @ 2010-11-27 18:00 UTC (permalink / raw)
To: ofono
[-- Attachment #1: Type: text/plain, Size: 5681 bytes --]
Hi Lucas,
On 11/26/2010 06:44 PM, Lucas De Marchi wrote:
> ---
> plugins/phonesim.c | 140 ++++++++++++++++++++++++++++++++++++++++++++++++++--
> 1 files changed, 136 insertions(+), 4 deletions(-)
>
> diff --git a/plugins/phonesim.c b/plugins/phonesim.c
> index d2faf42..be2f931 100644
> --- a/plugins/phonesim.c
> +++ b/plugins/phonesim.c
> @@ -46,6 +46,7 @@
> #include <ofono/call-settings.h>
> #include <ofono/call-volume.h>
> #include <ofono/cbs.h>
> +#include <ofono/ctm.h>
> #include <ofono/devinfo.h>
> #include <ofono/message-waiting.h>
> #include <ofono/netreg.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 {
> @@ -190,12 +192,137 @@ static void phonesim_context_remove(struct ofono_gprs_context *gc)
> g_free(gcd);
> }
>
> +static void phonesim_ctm_support_cb(gboolean ok, GAtResult *result,
> + gpointer user_data)
> +{
> + struct ofono_ctm *ctm = user_data;
> +
> + if (!ok)
> + return;
You might want to remove the atom here as well so it doesn't take up space.
> +
> + ofono_ctm_register(ctm);
> +}
> +
> +static int phonesim_ctm_probe(struct ofono_ctm *ctm,
> + unsigned int vendor, void *data)
> +{
> + GAtChat *chat = data;
> +
> + ofono_ctm_set_data(ctm, chat);
You actually need to clone the chat here, see the other drivers for
details. This is used to remove all pending commands from the chat when
the atom is removed.
> +
> + g_at_chat_send(chat, "AT+PTTY=?", ptty_prefix, phonesim_ctm_support_cb,
> + ctm, NULL);
> +
> + return 0;
> +}
> +
> +static void phonesim_ctm_remove(struct ofono_ctm *ctm)
> +{
> + DBG("");
> +
You also need to unref the chat here
> + ofono_ctm_set_data(ctm, NULL);
> +}
> +
> +static void ctm_query_cb(gboolean ok, GAtResult *result, gpointer user_data)
> +{
> + struct cb_data *cbd = user_data;
> + struct ofono_error error;
> + GAtResultIter iter;
> + ofono_ctm_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_ctm_query(struct ofono_ctm *ctm,
> + ofono_ctm_query_cb_t cb, void *data)
> +{
> + GAtChat *chat = ofono_ctm_get_data(ctm);
> + struct cb_data *cbd = cb_data_new(cb, data);
> +
> + DBG("");
> +
> + if (!cbd)
> + goto error;
> +
> + if (g_at_chat_send(chat, "AT+PTTY?", ptty_prefix,
> + ctm_query_cb, cbd, g_free) > 0)
> + return;
> +
> +error:
> + g_free(cbd);
> +
> + CALLBACK_WITH_FAILURE(cb, 0, data);
> +}
> +
> +static void ctm_set_cb(gboolean ok, GAtResult *result, gpointer user_data)
> +{
> + struct cb_data *cbd = user_data;
> + ofono_ctm_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_ctm_set(struct ofono_ctm *ctm, ofono_bool_t enable,
> + ofono_ctm_set_cb_t cb, void *data)
> +{
> + GAtChat *chat = ofono_ctm_get_data(ctm);
> + struct cb_data *cbd = cb_data_new(cb, data);
> + char buf[20];
> +
> + DBG("");
> +
> + if (!cbd)
> + goto error;
> +
> + snprintf(buf, sizeof(buf), "AT+PTTY=%d", enable);
> +
> + if (g_at_chat_send(chat, buf, none_prefix,
> + ctm_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_ctm_driver ctm_driver = {
> .name = "phonesim",
> - .probe = phonesim_context_probe,
> - .remove = phonesim_context_remove,
> - .activate_primary = phonesim_activate_primary,
> - .deactivate_primary = phonesim_deactivate_primary,
> + .probe = phonesim_ctm_probe,
> + .remove = phonesim_ctm_remove,
> + .query_tty = phonesim_ctm_query,
> + .set_tty = phonesim_ctm_set,
> };
>
> static int phonesim_probe(struct ofono_modem *modem)
> @@ -465,6 +592,7 @@ static void phonesim_post_sim(struct ofono_modem *modem)
>
> DBG("%p", modem);
>
> + ofono_ctm_create(modem, 0, "phonesim", data->chat);
> ofono_phonebook_create(modem, 0, "atmodem", data->chat);
>
> if (!data->calypso)
> @@ -630,6 +758,8 @@ static int phonesim_init(void)
>
> ofono_gprs_context_driver_register(&context_driver);
>
> + ofono_ctm_driver_register(&ctm_driver);
> +
> parse_config(CONFIGDIR "/phonesim.conf");
>
> return 0;
> @@ -648,6 +778,8 @@ static void phonesim_exit(void)
> g_slist_free(modem_list);
> modem_list = NULL;
>
> + ofono_ctm_driver_unregister(&ctm_driver);
> +
> ofono_gprs_context_driver_unregister(&context_driver);
>
> ofono_modem_driver_unregister(&phonesim_driver);
Otherwise looks good. Can you also send a patch marking this task as done?
Regards,
-Denis
^ permalink raw reply [flat|nested] 18+ messages in thread
* [PATCH 1/2] phonesim: implement ctm atom
2010-11-27 18:00 ` Denis Kenzior
@ 2010-11-27 19:22 ` Lucas De Marchi
2010-11-29 16:44 ` Denis Kenzior
2010-11-27 19:22 ` [PATCH 2/2] TODO: Mark CTM task as done Lucas De Marchi
1 sibling, 1 reply; 18+ messages in thread
From: Lucas De Marchi @ 2010-11-27 19:22 UTC (permalink / raw)
To: ofono
[-- Attachment #1: Type: text/plain, Size: 5015 bytes --]
---
plugins/phonesim.c | 150 ++++++++++++++++++++++++++++++++++++++++++++++++++--
1 files changed, 146 insertions(+), 4 deletions(-)
diff --git a/plugins/phonesim.c b/plugins/phonesim.c
index d2faf42..d10eda8 100644
--- a/plugins/phonesim.c
+++ b/plugins/phonesim.c
@@ -46,6 +46,7 @@
#include <ofono/call-settings.h>
#include <ofono/call-volume.h>
#include <ofono/cbs.h>
+#include <ofono/ctm.h>
#include <ofono/devinfo.h>
#include <ofono/message-waiting.h>
#include <ofono/netreg.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 {
@@ -190,12 +192,147 @@ static void phonesim_context_remove(struct ofono_gprs_context *gc)
g_free(gcd);
}
+static void phonesim_ctm_support_cb(gboolean ok, GAtResult *result,
+ gpointer user_data)
+{
+ struct ofono_ctm *ctm = user_data;
+
+ if (!ok) {
+ ofono_ctm_remove(ctm);
+ return;
+ }
+
+ ofono_ctm_register(ctm);
+}
+
+static int phonesim_ctm_probe(struct ofono_ctm *ctm,
+ unsigned int vendor, void *data)
+{
+ GAtChat *chat;
+
+ DBG("");
+
+ chat = g_at_chat_clone(data);
+
+ ofono_ctm_set_data(ctm, chat);
+
+ g_at_chat_send(chat, "AT+PTTY=?", ptty_prefix, phonesim_ctm_support_cb,
+ ctm, NULL);
+
+ return 0;
+}
+
+static void phonesim_ctm_remove(struct ofono_ctm *ctm)
+{
+ GAtChat *chat = ofono_ctm_get_data(ctm);
+
+ DBG("");
+
+ ofono_ctm_set_data(ctm, NULL);
+
+ g_at_chat_unref(chat);
+}
+
+static void ctm_query_cb(gboolean ok, GAtResult *result, gpointer user_data)
+{
+ struct cb_data *cbd = user_data;
+ struct ofono_error error;
+ GAtResultIter iter;
+ ofono_ctm_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_ctm_query(struct ofono_ctm *ctm,
+ ofono_ctm_query_cb_t cb, void *data)
+{
+ GAtChat *chat = ofono_ctm_get_data(ctm);
+ struct cb_data *cbd = cb_data_new(cb, data);
+
+ DBG("");
+
+ if (!cbd)
+ goto error;
+
+ if (g_at_chat_send(chat, "AT+PTTY?", ptty_prefix,
+ ctm_query_cb, cbd, g_free) > 0)
+ return;
+
+error:
+ g_free(cbd);
+
+ CALLBACK_WITH_FAILURE(cb, 0, data);
+}
+
+static void ctm_set_cb(gboolean ok, GAtResult *result, gpointer user_data)
+{
+ struct cb_data *cbd = user_data;
+ ofono_ctm_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_ctm_set(struct ofono_ctm *ctm, ofono_bool_t enable,
+ ofono_ctm_set_cb_t cb, void *data)
+{
+ GAtChat *chat = ofono_ctm_get_data(ctm);
+ struct cb_data *cbd = cb_data_new(cb, data);
+ char buf[20];
+
+ DBG("");
+
+ if (!cbd)
+ goto error;
+
+ snprintf(buf, sizeof(buf), "AT+PTTY=%d", enable);
+
+ if (g_at_chat_send(chat, buf, none_prefix,
+ ctm_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_ctm_driver ctm_driver = {
.name = "phonesim",
- .probe = phonesim_context_probe,
- .remove = phonesim_context_remove,
- .activate_primary = phonesim_activate_primary,
- .deactivate_primary = phonesim_deactivate_primary,
+ .probe = phonesim_ctm_probe,
+ .remove = phonesim_ctm_remove,
+ .query_tty = phonesim_ctm_query,
+ .set_tty = phonesim_ctm_set,
};
static int phonesim_probe(struct ofono_modem *modem)
@@ -465,6 +602,7 @@ static void phonesim_post_sim(struct ofono_modem *modem)
DBG("%p", modem);
+ ofono_ctm_create(modem, 0, "phonesim", data->chat);
ofono_phonebook_create(modem, 0, "atmodem", data->chat);
if (!data->calypso)
@@ -630,6 +768,8 @@ static int phonesim_init(void)
ofono_gprs_context_driver_register(&context_driver);
+ ofono_ctm_driver_register(&ctm_driver);
+
parse_config(CONFIGDIR "/phonesim.conf");
return 0;
@@ -648,6 +788,8 @@ static void phonesim_exit(void)
g_slist_free(modem_list);
modem_list = NULL;
+ ofono_ctm_driver_unregister(&ctm_driver);
+
ofono_gprs_context_driver_unregister(&context_driver);
ofono_modem_driver_unregister(&phonesim_driver);
--
1.7.3.2
^ permalink raw reply related [flat|nested] 18+ messages in thread
* [PATCH 2/2] TODO: Mark CTM task as done
2010-11-27 18:00 ` Denis Kenzior
2010-11-27 19:22 ` [PATCH 1/2] " Lucas De Marchi
@ 2010-11-27 19:22 ` Lucas De Marchi
2010-11-29 16:44 ` Denis Kenzior
1 sibling, 1 reply; 18+ messages in thread
From: Lucas De Marchi @ 2010-11-27 19:22 UTC (permalink / raw)
To: ofono
[-- Attachment #1: Type: text/plain, Size: 1577 bytes --]
---
TODO | 11 -----------
doc/features.txt | 7 +++++++
2 files changed, 7 insertions(+), 11 deletions(-)
diff --git a/TODO b/TODO
index c484871..4443ac1 100644
--- a/TODO
+++ b/TODO
@@ -479,17 +479,6 @@ Miscellaneous
Complexity: C2
Owner: Gustavo F Padovan <padovan@profusion.mobi>
-- TTY (hearing impaired) support. Add a new oFono atom type that will enable
- the user to enable or disable the TTY support on the modem. Support for
- automatic detection of TTY (signaled by the driver) is also desired.
-
- This feature is not discussed in 27.007, thus manufacturer specific commands
- are required.
-
- Priority: High
- Complexity: C1
- Owner: Lucas De Marchi <lucas.demarchi@profusion.mobi>
-
- Add support for GPS power control atom. Many modem manufacturers provide
a GPS unit with their modem hardware. This unit can be turned on or off
and frequently takes over one of the tty ports that the modem provides.
diff --git a/doc/features.txt b/doc/features.txt
index 06f5203..ef20cf2 100644
--- a/doc/features.txt
+++ b/doc/features.txt
@@ -216,3 +216,10 @@ Radio settings
cellular modem to conserve power when the end user is not actively
using the device but some networking applications are online using
packet data.
+
+Text Telephony
+==============
+
+- TTY (hearing impaired) support, also known as Cellular Text Modem (CTM).
+ In case it's supported by the modem, oFono allows the user to enabled
+ or disable it through the TextTelephony interface.
--
1.7.3.2
^ permalink raw reply related [flat|nested] 18+ messages in thread
* RE: [PATCH 1/5] text-telephony: add public header
2010-11-26 19:27 ` [PATCH 1/5] text-telephony: add public header Denis Kenzior
@ 2010-11-27 21:04 ` Bastian, Waldo
2010-11-29 13:53 ` Denis Kenzior
0 siblings, 1 reply; 18+ messages in thread
From: Bastian, Waldo @ 2010-11-27 21:04 UTC (permalink / raw)
To: ofono
[-- Attachment #1: Type: text/plain, Size: 649 bytes --]
> > + void (*remove)(struct ofono_ctm *tt);
> > + void (*query_tty)(struct ofono_ctm *tt,
> > + ofono_ctm_query_cb_t cb,
> > + void *data);
> > + void (*set_tty)(struct ofono_ctm *tt,
> > + int enable,
>
> I also changed this to ofono_bool_t enable
Fyi, I noticed that radio-settings.h has this as an int as well:
67 void (*set_fast_dormancy)(struct ofono_radio_settings *rs,
68 int enable,
69 ofono_radio_settings_fast_dormancy_set_cb_t,
70 void *data);
The query callback otoh uses ofono_bool_t.
Cheers,
Waldo
^ permalink raw reply [flat|nested] 18+ messages in thread
* Re: [PATCH 1/5] text-telephony: add public header
2010-11-27 21:04 ` Bastian, Waldo
@ 2010-11-29 13:53 ` Denis Kenzior
0 siblings, 0 replies; 18+ messages in thread
From: Denis Kenzior @ 2010-11-29 13:53 UTC (permalink / raw)
To: ofono
[-- Attachment #1: Type: text/plain, Size: 792 bytes --]
Hi Waldo,
On 11/27/2010 03:04 PM, Bastian, Waldo wrote:
>>> + void (*remove)(struct ofono_ctm *tt);
>>> + void (*query_tty)(struct ofono_ctm *tt,
>>> + ofono_ctm_query_cb_t cb,
>>> + void *data);
>>> + void (*set_tty)(struct ofono_ctm *tt,
>>> + int enable,
>>
>> I also changed this to ofono_bool_t enable
>
> Fyi, I noticed that radio-settings.h has this as an int as well:
>
> 67 void (*set_fast_dormancy)(struct ofono_radio_settings *rs,
> 68 int enable,
> 69 ofono_radio_settings_fast_dormancy_set_cb_t,
> 70 void *data);
>
> The query callback otoh uses ofono_bool_t.
>
Thanks for pointing this out. It has now been fixed.
Regards,
-Denis
^ permalink raw reply [flat|nested] 18+ messages in thread
* Re: [PATCH 1/2] phonesim: implement ctm atom
2010-11-27 19:22 ` [PATCH 1/2] " Lucas De Marchi
@ 2010-11-29 16:44 ` Denis Kenzior
0 siblings, 0 replies; 18+ messages in thread
From: Denis Kenzior @ 2010-11-29 16:44 UTC (permalink / raw)
To: ofono
[-- Attachment #1: Type: text/plain, Size: 265 bytes --]
Hi Lucas,
On 11/27/2010 01:22 PM, Lucas De Marchi wrote:
> ---
> plugins/phonesim.c | 150 ++++++++++++++++++++++++++++++++++++++++++++++++++--
> 1 files changed, 146 insertions(+), 4 deletions(-)
>
Patch has been applied, thanks.
Regards,
-Denis
^ permalink raw reply [flat|nested] 18+ messages in thread
* Re: [PATCH 2/2] TODO: Mark CTM task as done
2010-11-27 19:22 ` [PATCH 2/2] TODO: Mark CTM task as done Lucas De Marchi
@ 2010-11-29 16:44 ` Denis Kenzior
0 siblings, 0 replies; 18+ messages in thread
From: Denis Kenzior @ 2010-11-29 16:44 UTC (permalink / raw)
To: ofono
[-- Attachment #1: Type: text/plain, Size: 257 bytes --]
Hi Lucas,
On 11/27/2010 01:22 PM, Lucas De Marchi wrote:
> ---
> TODO | 11 -----------
> doc/features.txt | 7 +++++++
> 2 files changed, 7 insertions(+), 11 deletions(-)
>
Patch has been applied, thanks.
Regards,
-Denis
^ permalink raw reply [flat|nested] 18+ messages in thread
end of thread, other threads:[~2010-11-29 16:44 UTC | newest]
Thread overview: 18+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-11-25 17:41 [PATCH 1/5] text-telephony: add public header Lucas De Marchi
2010-11-25 17:41 ` [PATCH 2/5] text-telephony: implement interface/atom Lucas De Marchi
2010-11-26 19:28 ` Denis Kenzior
2010-11-25 17:41 ` [PATCH 3/5] text-telephony: add documentation Lucas De Marchi
2010-11-26 19:29 ` Denis Kenzior
2010-11-25 17:41 ` [PATCH 4/5] phonesim: implement text-telephony atom Lucas De Marchi
2010-11-26 19:17 ` Denis Kenzior
2010-11-27 0:44 ` [PATCH] phonesim: implement ctm atom Lucas De Marchi
2010-11-27 18:00 ` Denis Kenzior
2010-11-27 19:22 ` [PATCH 1/2] " Lucas De Marchi
2010-11-29 16:44 ` Denis Kenzior
2010-11-27 19:22 ` [PATCH 2/2] TODO: Mark CTM task as done Lucas De Marchi
2010-11-29 16:44 ` Denis Kenzior
2010-11-25 17:42 ` [PATCH 5/5] Add script to enable/disable text-telephony support Lucas De Marchi
2010-11-26 19:29 ` Denis Kenzior
2010-11-26 19:27 ` [PATCH 1/5] text-telephony: add public header Denis Kenzior
2010-11-27 21:04 ` Bastian, Waldo
2010-11-29 13:53 ` 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.