[RFC 1/1] doc: Add modem technology type property
by Dara Spieker-Doyle
---
doc/modem-api.txt | 11 +++++++++++
1 files changed, 11 insertions(+), 0 deletions(-)
diff --git a/doc/modem-api.txt b/doc/modem-api.txt
index 45043b0..fe03833 100644
--- a/doc/modem-api.txt
+++ b/doc/modem-api.txt
@@ -82,6 +82,17 @@ Properties boolean Powered [readwrite]
This is usually obtained by using the +CGSN AT command.
+ string TechnologyType [readonly, optional, experimental]
+
+ String representing the technology type of the current
+ modem device.
+
+ The possible values are:
+ "gsm" The 3GPP family of technologies
+ including gsm, edge, umts, hspa, lte.
+ "cdma" The 3GPP2 family of technologies
+ including cdma 1x, evdo.
+
array{string} Features [readonly]
List of currently enabled features. It uses simple
--
1.7.0.4
11 years, 8 months
[PATCHv3 2/2] sms: Introduce message code independent of protocol stack
by Faiyaz Baxamusa
---
Makefile.am | 3 +-
src/message.c | 228 ++++++++++++++++++++++++++++++++++++++++++++++++++++
src/message.h | 54 +++++++++++++
src/sms.c | 247 +++++++--------------------------------------------------
4 files changed, 312 insertions(+), 220 deletions(-)
create mode 100644 src/message.c
create mode 100644 src/message.h
diff --git a/Makefile.am b/Makefile.am
index 2618fa3..9933e32 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -354,7 +354,8 @@ src_ofonod_SOURCES = $(gdbus_sources) $(builtin_sources) src/ofono.ver \
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/ctm.c \
- src/cdma-voicecall.c src/sim-auth.c
+ src/cdma-voicecall.c src/sim-auth.c \
+ src/message.h src/message.c
src_ofonod_LDADD = $(builtin_libadd) @GLIB_LIBS@ @DBUS_LIBS@ @CAPNG_LIBS@ -ldl
diff --git a/src/message.c b/src/message.c
new file mode 100644
index 0000000..050a522
--- /dev/null
+++ b/src/message.c
@@ -0,0 +1,228 @@
+/*
+ *
+ * oFono - Open Source Telephony
+ *
+ * Copyright (C) 2008-2011 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 <gdbus.h>
+#include <stdio.h>
+
+#include "ofono.h"
+#include "message.h"
+
+struct message {
+ struct ofono_uuid uuid;
+ enum message_state state;
+ struct ofono_atom *atom;
+ void *data;
+};
+
+static const char *message_state_to_string(enum message_state s)
+{
+ switch (s) {
+ case MESSAGE_STATE_PENDING:
+ return "pending";
+ case MESSAGE_STATE_SENT:
+ return "sent";
+ case MESSAGE_STATE_FAILED:
+ return "failed";
+ }
+
+ return NULL;
+}
+
+static DBusMessage *message_get_properties(DBusConnection *conn,
+ DBusMessage *msg, void *data)
+{
+ struct message *m = data;
+ DBusMessage *reply;
+ DBusMessageIter iter;
+ DBusMessageIter dict;
+
+ 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);
+ message_append_properties(m, &dict);
+ dbus_message_iter_close_container(&iter, &dict);
+
+ return reply;
+}
+
+static GDBusMethodTable message_methods[] = {
+ { "GetProperties", "", "a{sv}", message_get_properties },
+ { }
+};
+
+static GDBusSignalTable message_signals[] = {
+ { "PropertyChanged", "sv" },
+ { }
+};
+
+struct message *message_create(const struct ofono_uuid *uuid,
+ struct ofono_atom *atom)
+{
+ struct message *v;
+
+ v = g_try_new0(struct message, 1);
+ if (v == NULL)
+ return NULL;
+
+ memcpy(&v->uuid, uuid, sizeof(*uuid));
+
+ v->atom = atom;
+
+ return v;
+}
+
+static void message_destroy(gpointer userdata)
+{
+ struct message *m = userdata;
+
+ g_free(m);
+}
+
+gboolean message_dbus_register(struct message *m)
+{
+ DBusConnection *conn = ofono_dbus_get_connection();
+ const char *path = message_path_from_uuid(m->atom, &m->uuid);
+
+ if (!g_dbus_register_interface(conn, path, OFONO_MESSAGE_INTERFACE,
+ message_methods, message_signals,
+ NULL, m, message_destroy)) {
+ ofono_error("Could not register Message %s", path);
+ message_destroy(m);
+
+ return FALSE;
+ }
+
+ return TRUE;
+}
+
+void message_dbus_unregister(struct message *m)
+{
+ DBusConnection *conn = ofono_dbus_get_connection();
+ const char *path = message_path_from_uuid(m->atom, &m->uuid);
+
+ g_dbus_unregister_interface(conn, path, OFONO_MESSAGE_INTERFACE);
+
+ return;
+}
+
+const struct ofono_uuid *message_get_uuid(const struct message *m)
+{
+ return &m->uuid;
+}
+
+void message_set_state(struct message *m, enum message_state new_state)
+{
+ DBusConnection *conn = ofono_dbus_get_connection();
+ const char *path;
+ const char *state;
+
+ if (m->state == new_state)
+ return;
+
+ path = message_path_from_uuid(m->atom, &m->uuid);
+
+ m->state = new_state;
+ state = message_state_to_string(m->state);
+
+ ofono_dbus_signal_property_changed(conn, path, OFONO_MESSAGE_INTERFACE,
+ "State",
+ DBUS_TYPE_STRING,
+ &state);
+}
+
+void message_append_properties(struct message *m, DBusMessageIter *dict)
+{
+ const char *state = message_state_to_string(m->state);
+
+ ofono_dbus_dict_append(dict, "State", DBUS_TYPE_STRING, &state);
+}
+
+void message_emit_added(struct message *m, const char *interface)
+{
+ DBusMessage *signal;
+ DBusMessageIter iter;
+ DBusMessageIter dict;
+ const char *path;
+ const char *atompath = __ofono_atom_get_path(m->atom);
+
+ signal = dbus_message_new_signal(atompath, interface, "MessageAdded");
+ if (signal == NULL)
+ return;
+
+ path = message_path_from_uuid(m->atom, &m->uuid);
+
+ dbus_message_iter_init_append(signal, &iter);
+
+ dbus_message_iter_append_basic(&iter, DBUS_TYPE_OBJECT_PATH, &path);
+
+ dbus_message_iter_open_container(&iter, DBUS_TYPE_ARRAY,
+ OFONO_PROPERTIES_ARRAY_SIGNATURE,
+ &dict);
+ message_append_properties(m, &dict);
+ dbus_message_iter_close_container(&iter, &dict);
+
+ g_dbus_send_message(ofono_dbus_get_connection(), signal);
+}
+
+void message_emit_removed(struct message *m, const char *interface)
+{
+ DBusConnection *conn = ofono_dbus_get_connection();
+ const char *atompath = __ofono_atom_get_path(m->atom);
+ const char *path = message_path_from_uuid(m->atom, &m->uuid);
+
+ g_dbus_emit_signal(conn, atompath, interface, "MessageRemoved",
+ DBUS_TYPE_OBJECT_PATH,
+ &path,
+ DBUS_TYPE_INVALID);
+}
+
+const char *message_path_from_uuid(struct ofono_atom *atom,
+ const struct ofono_uuid *uuid)
+{
+ static char path[256];
+ const char *atompath = __ofono_atom_get_path(atom);
+
+ snprintf(path, sizeof(path), "%s/message_%s", atompath,
+ ofono_uuid_to_str(uuid));
+
+ return path;
+}
+
+void *message_get_data(struct message *m)
+{
+ return m->data;
+}
+
+void message_set_data(struct message *m, void *data)
+{
+ m->data = data;
+}
diff --git a/src/message.h b/src/message.h
new file mode 100644
index 0000000..14e66c3
--- /dev/null
+++ b/src/message.h
@@ -0,0 +1,54 @@
+/*
+ *
+ * oFono - Open Source Telephony
+ *
+ * Copyright (C) 2008-2011 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
+ *
+ */
+
+#include <ofono/types.h>
+
+enum message_state {
+ MESSAGE_STATE_PENDING,
+ MESSAGE_STATE_SENT,
+ MESSAGE_STATE_FAILED
+};
+
+struct ofono_atom;
+struct message;
+
+struct message *message_create(const struct ofono_uuid *uuid,
+ struct ofono_atom *atom);
+
+gboolean message_dbus_register(struct message *m);
+void message_dbus_unregister(struct message *m);
+
+const struct ofono_uuid *message_get_uuid(const struct message *m);
+
+void message_set_state(struct message *m, enum message_state new_state);
+
+void message_append_properties(struct message *m, DBusMessageIter *dict);
+
+void message_emit_added(struct message *m, const char *interface);
+
+void message_emit_removed(struct message *m, const char *interface);
+
+void *message_get_data(struct message *m);
+
+void message_set_data(struct message *m, void *data);
+
+const char *message_path_from_uuid(struct ofono_atom *atom,
+ const struct ofono_uuid *uuid);
diff --git a/src/sms.c b/src/sms.c
index 4d1a929..7224bdf 100644
--- a/src/sms.c
+++ b/src/sms.c
@@ -2,7 +2,7 @@
*
* oFono - Open Source Telephony
*
- * Copyright (C) 2008-2010 Intel Corporation. All rights reserved.
+ * Copyright (C) 2008-2011 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
@@ -24,7 +24,6 @@
#endif
#include <string.h>
-#include <stdio.h>
#include <errno.h>
#include <glib.h>
@@ -38,6 +37,7 @@
#include "smsutil.h"
#include "storage.h"
#include "simutil.h"
+#include "message.h"
#define uninitialized_var(x) x = x
@@ -52,18 +52,6 @@ static gboolean tx_next(gpointer user_data);
static GSList *g_drivers = NULL;
-enum message_state {
- MESSAGE_STATE_PENDING = 0,
- MESSAGE_STATE_SENT,
- MESSAGE_STATE_FAILED
-};
-
-struct message {
- struct ofono_uuid uuid;
- enum message_state state;
- struct tx_queue_entry *entry;
-};
-
struct sms_handler {
struct ofono_watchlist_item item;
int dst;
@@ -167,28 +155,6 @@ static int sms_bearer_from_string(const char *str)
return -1;
}
-static const char *message_state_to_string(enum message_state s)
-{
- switch (s) {
- case MESSAGE_STATE_PENDING:
- return "pending";
- case MESSAGE_STATE_SENT:
- return "sent";
- case MESSAGE_STATE_FAILED:
- return "failed";
- }
-
- return "invalid";
-}
-
-static void append_message_properties(struct message *m, DBusMessageIter *dict)
-{
- const char *state;
-
- state = message_state_to_string(m->state);
- ofono_dbus_dict_append(dict, "State", DBUS_TYPE_STRING, &state);
-}
-
static unsigned int add_sms_handler(struct ofono_watchlist *watchlist,
int dst, int src, void *notify,
void *data, ofono_destroy_func destroy)
@@ -260,181 +226,10 @@ gboolean __ofono_sms_datagram_watch_remove(struct ofono_sms *sms,
return __ofono_watchlist_remove_item(sms->datagram_handlers, id);
}
-static DBusMessage *message_get_properties(DBusConnection *conn,
- DBusMessage *msg, void *data)
-{
- struct message *m = data;
- DBusMessage *reply;
- DBusMessageIter iter;
- DBusMessageIter dict;
-
- 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);
- append_message_properties(m, &dict);
- dbus_message_iter_close_container(&iter, &dict);
-
- return reply;
-}
-
-static GDBusMethodTable message_methods[] = {
- { "GetProperties", "", "a{sv}", message_get_properties },
- { }
-};
-
-static GDBusSignalTable message_signals[] = {
- { "PropertyChanged", "sv" },
- { }
-};
-
-static struct message *message_create(const struct ofono_uuid *uuid)
-{
- struct message *v;
-
- if (uuid == NULL)
- return NULL;
-
- v = g_try_new0(struct message, 1);
- if (v == NULL)
- return NULL;
-
- memcpy(&v->uuid, uuid, sizeof(*uuid));
-
- return v;
-}
-
-static void message_destroy(gpointer userdata)
-{
- struct message *m = userdata;
-
- g_free(m);
-}
-
const char *__ofono_sms_message_path_from_uuid(struct ofono_sms *sms,
const struct ofono_uuid *uuid)
{
- static char path[256];
-
- snprintf(path, sizeof(path), "%s/message_%s",
- __ofono_atom_get_path(sms->atom),
- ofono_uuid_to_str(uuid));
-
- return path;
-}
-
-static gboolean message_dbus_register(struct ofono_sms *sms, struct message *m)
-{
- DBusConnection *conn = ofono_dbus_get_connection();
- const char *path;
-
- if (m == NULL)
- return FALSE;
-
- path = __ofono_sms_message_path_from_uuid(sms, &m->uuid);
-
- if (!g_dbus_register_interface(conn, path, OFONO_MESSAGE_INTERFACE,
- message_methods, message_signals,
- NULL, m, message_destroy)) {
- ofono_error("Could not register Message %s", path);
- message_destroy(m);
-
- return FALSE;
- }
-
- return TRUE;
-}
-
-static gboolean message_dbus_unregister(struct ofono_sms *sms,
- struct message *m)
-{
- DBusConnection *conn = ofono_dbus_get_connection();
- const char *path = __ofono_sms_message_path_from_uuid(sms, &m->uuid);
-
- return g_dbus_unregister_interface(conn, path,
- OFONO_MESSAGE_INTERFACE);
-}
-
-static void emit_message_added(struct ofono_sms *sms, struct message *m)
-{
- DBusMessage *signal;
- DBusMessageIter iter;
- DBusMessageIter dict;
- const char *path;
-
- path = __ofono_atom_get_path(sms->atom);
-
- signal = dbus_message_new_signal(path,
- OFONO_MESSAGE_MANAGER_INTERFACE,
- "MessageAdded");
-
- if (signal == NULL)
- return;
-
- dbus_message_iter_init_append(signal, &iter);
-
- path = __ofono_sms_message_path_from_uuid(sms, &m->uuid);
- dbus_message_iter_append_basic(&iter, DBUS_TYPE_OBJECT_PATH, &path);
-
- dbus_message_iter_open_container(&iter, DBUS_TYPE_ARRAY,
- OFONO_PROPERTIES_ARRAY_SIGNATURE,
- &dict);
- append_message_properties(m, &dict);
- dbus_message_iter_close_container(&iter, &dict);
-
- g_dbus_send_message(ofono_dbus_get_connection(), signal);
-}
-
-static void emit_message_removed(struct ofono_sms *sms, struct message *m)
-{
- DBusConnection *conn = ofono_dbus_get_connection();
- const char *atompath = __ofono_atom_get_path(sms->atom);
- const char *path = __ofono_sms_message_path_from_uuid(sms, &m->uuid);
-
- g_dbus_emit_signal(conn, atompath, OFONO_MESSAGE_MANAGER_INTERFACE,
- "MessageRemoved", DBUS_TYPE_OBJECT_PATH, &path,
- DBUS_TYPE_INVALID);
-}
-
-static void message_set_state(struct ofono_sms *sms,
- const struct ofono_uuid *uuid,
- enum message_state new_state)
-{
- DBusConnection *conn = ofono_dbus_get_connection();
- const char *path;
- const char *state;
- struct message *m;
-
- m = g_hash_table_lookup(sms->messages, uuid);
-
- if (m == NULL)
- return;
-
- if (m->state == new_state)
- return;
-
- m->state = new_state;
- path = __ofono_sms_message_path_from_uuid(sms, uuid);
- state = message_state_to_string(m->state);
-
- ofono_dbus_signal_property_changed(conn, path,
- OFONO_MESSAGE_INTERFACE,
- "State", DBUS_TYPE_STRING,
- &state);
-
- if (m->state == MESSAGE_STATE_SENT ||
- m->state == MESSAGE_STATE_FAILED) {
- m->entry = NULL;
-
- g_hash_table_remove(sms->messages, uuid);
- emit_message_removed(sms, m);
- message_dbus_unregister(sms, m);
- }
+ return message_path_from_uuid(sms->atom, uuid);
}
static void set_bearer(struct ofono_sms *sms, int bearer)
@@ -747,6 +542,7 @@ static void tx_finished(const struct ofono_error *error, int mr, void *data)
struct ofono_modem *modem = __ofono_atom_get_modem(sms->atom);
struct tx_queue_entry *entry = g_queue_peek_head(sms->txq);
gboolean ok = error->type == OFONO_ERROR_TYPE_NO_ERROR;
+ struct message *m = NULL;
DBG("tx_finished");
@@ -814,7 +610,15 @@ next_q:
else
ms = MESSAGE_STATE_FAILED;
- message_set_state(sms, &entry->uuid, ms);
+ m = g_hash_table_lookup(sms->messages, &entry->uuid);
+
+ if (m != NULL) {
+ message_set_state(m, ms);
+ g_hash_table_remove(sms->messages, &entry->uuid);
+ message_emit_removed(m,
+ OFONO_MESSAGE_MANAGER_INTERFACE);
+ message_dbus_unregister(m);
+ }
}
tx_queue_entry_destroy(entry);
@@ -1089,6 +893,7 @@ static DBusMessage *sms_get_messages(DBusConnection *conn, DBusMessage *msg,
GHashTableIter hashiter;
gpointer key, value;
struct message *m;
+ const struct ofono_uuid *uuid;
reply = dbus_message_new_method_return(msg);
if (reply == NULL)
@@ -1111,8 +916,9 @@ static DBusMessage *sms_get_messages(DBusConnection *conn, DBusMessage *msg,
while (g_hash_table_iter_next(&hashiter, &key, &value)) {
m = value;
+ uuid = message_get_uuid(m);
- path = __ofono_sms_message_path_from_uuid(sms, &m->uuid);
+ path = __ofono_sms_message_path_from_uuid(sms, uuid);
dbus_message_iter_open_container(&array, DBUS_TYPE_STRUCT,
NULL, &entry);
@@ -1122,7 +928,7 @@ static DBusMessage *sms_get_messages(DBusConnection *conn, DBusMessage *msg,
OFONO_PROPERTIES_ARRAY_SIGNATURE,
&dict);
- append_message_properties(m, &dict);
+ message_append_properties(m, &dict);
dbus_message_iter_close_container(&entry, &dict);
dbus_message_iter_close_container(&array, &entry);
}
@@ -1716,7 +1522,7 @@ static void sms_unregister(struct ofono_atom *atom)
while (g_hash_table_iter_next(&iter, &key, &value)) {
m = value;
- message_dbus_unregister(sms, m);
+ message_dbus_unregister(m);
}
g_hash_table_destroy(sms->messages);
@@ -1989,15 +1795,16 @@ int __ofono_sms_txq_submit(struct ofono_sms *sms, GSList *list,
return -ENOMEM;
if (flags & OFONO_SMS_SUBMIT_FLAG_EXPOSE_DBUS) {
- m = message_create(&entry->uuid);
+ m = message_create(&entry->uuid, sms->atom);
if (m == NULL)
goto err;
- if (message_dbus_register(sms, m) == FALSE)
+ if (message_dbus_register(m) == FALSE)
goto err;
- g_hash_table_insert(sms->messages, &m->uuid, m);
- m->entry = entry;
+ message_set_data(m, entry);
+
+ g_hash_table_insert(sms->messages, &entry->uuid, m);
}
if (list->next != NULL) {
@@ -2019,7 +1826,7 @@ int __ofono_sms_txq_submit(struct ofono_sms *sms, GSList *list,
cb(sms, &entry->uuid, data);
if (m && (flags & OFONO_SMS_SUBMIT_FLAG_EXPOSE_DBUS))
- emit_message_added(sms, m);
+ message_emit_added(m, OFONO_MESSAGE_MANAGER_INTERFACE);
return 0;
@@ -2036,15 +1843,17 @@ int __ofono_sms_txq_set_submit_notify(struct ofono_sms *sms,
ofono_destroy_func destroy)
{
struct message *m;
+ struct tx_queue_entry *entry;
m = g_hash_table_lookup(sms->messages, uuid);
if (m == NULL)
return -ENOENT;
- if (m->entry == NULL)
+ entry = message_get_data(m);
+ if (entry == NULL)
return -ENOTSUP;
- tx_queue_entry_set_submit_notify(m->entry, cb, data, destroy);
+ tx_queue_entry_set_submit_notify(entry, cb, data, destroy);
return 0;
}
--
1.7.0.4
11 years, 8 months
[PATCHv3 1/2] doc: Add messagemanager-api and change message-api
by Faiyaz Baxamusa
---
Makefile.am | 4 +-
...message-api.txt => cdma-messagemanager-api.txt} | 0
doc/message-api.txt | 89 --------------------
doc/messagemanager-api.txt | 88 +++++++++++++++++++
4 files changed, 90 insertions(+), 91 deletions(-)
rename doc/{cdma-message-api.txt => cdma-messagemanager-api.txt} (100%)
create mode 100644 doc/messagemanager-api.txt
diff --git a/Makefile.am b/Makefile.am
index 9c8083b..2618fa3 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -392,11 +392,11 @@ doc_files = doc/overview.txt doc/ofono-paper.txt doc/release-faq.txt \
doc/pushnotification-api.txt \
doc/smartmessaging-api.txt \
doc/call-volume-api.txt doc/cell-broadcast-api.txt \
- doc/message-api.txt doc/message-waiting-api.txt \
+ doc/messagemanager-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/text-telephony-api.txt \
- doc/calypso-modem.txt
+ doc/calypso-modem.txt doc/message-api.txt
test_scripts = test/backtrace \
diff --git a/doc/cdma-message-api.txt b/doc/cdma-messagemanager-api.txt
similarity index 100%
rename from doc/cdma-message-api.txt
rename to doc/cdma-messagemanager-api.txt
diff --git a/doc/message-api.txt b/doc/message-api.txt
index f7ab22a..1c68aee 100644
--- a/doc/message-api.txt
+++ b/doc/message-api.txt
@@ -1,92 +1,3 @@
-Message Manager hierarchy
-===============
-
-Service org.ofono
-Interface org.ofono.MessageManager
-Object path [variable prefix]/{modem0,modem1,...}
-
-Methods dict GetProperties()
-
- Returns properties for the manager object. See
- the properties section for available properties.
-
- Possible Errors: [service].Error.InvalidArguments
-
- array{object,dict} GetMessages()
-
- Get an array of message object paths and properties
- that represents the currently pending messages.
-
- This method call should only be used once when an
- application starts up. Further message additions
- and removal shall be monitored via MessageAdded and
- MessageRemoved signals.
-
- void SetProperty(string name, variant value)
-
- Changes the value of the specified property. Only
- properties that are listed as readwrite are
- changeable. On success a PropertyChanged signal
- will be emitted.
-
- Possible Errors: [service].Error.InvalidArguments
- [service].Error.DoesNotExist
-
- object SendMessage(string to, string text)
-
- Send the message in text to the number in to. If the
- message could be queued successfully, this method
- returns an object path to the created Message object.
-
-Signals PropertyChanged(string name, variant value)
-
- This signal indicates a changed value of the given
- property.
-
- ImmediateMessage(string message, dict info)
-
- New immediate (class 0) SMS received. Info has Sender,
- LocalSentTime, and SentTime information. Sender
- address is given in string format. LocalSentTime and
- SentTime are given in string form using ISO8601 format.
-
- IncomingMessage(string message, dict info)
-
- New incoming text SMS received. Info has Sender,
- LocalSentTime, and SentTime information.
-
- MessageAdded(object path, dict properties)
-
- This signal is emitted whenever a new Message object
- has been created.
-
- MessageRemoved(object path)
-
- This signal is emitted whenever a Message object
- has been removed, e.g. when it reaches a final state.
-
-Properties string ServiceCenterAddress
-
- Contains the number of the SMS service center.
-
- boolean UseDeliveryReports
-
- This property controls whether SMS Status Reports,
- sometimes better known as Delivery Reports are to be
- used. If enabled, all outgoing SMS messages will be
- flagged to request a status report from the SMSC.
-
- string Bearer
-
- Contains the bearer to use for SMS messages. Possible
- values are:
- "cs-only" - Circuit Switched only
- "ps-only" - Packet Domain only
- "cs-preferred" - Use PS if CS is unavailable
- "ps-preferred" - Use CS if PS is unavailable
-
- By default oFono uses "cs-preferred" setting.
-
Message hierarchy
===============
diff --git a/doc/messagemanager-api.txt b/doc/messagemanager-api.txt
new file mode 100644
index 0000000..0723e9c
--- /dev/null
+++ b/doc/messagemanager-api.txt
@@ -0,0 +1,88 @@
+Message Manager hierarchy
+===============
+
+Service org.ofono
+Interface org.ofono.MessageManager
+Object path [variable prefix]/{modem0,modem1,...}
+
+Methods dict GetProperties()
+
+ Returns properties for the manager object. See
+ the properties section for available properties.
+
+ Possible Errors: [service].Error.InvalidArguments
+
+ array{object,dict} GetMessages()
+
+ Get an array of message object paths and properties
+ that represents the currently pending messages.
+
+ This method call should only be used once when an
+ application starts up. Further message additions
+ and removal shall be monitored via MessageAdded and
+ MessageRemoved signals.
+
+ void SetProperty(string name, variant value)
+
+ Changes the value of the specified property. Only
+ properties that are listed as readwrite are
+ changeable. On success a PropertyChanged signal
+ will be emitted.
+
+ Possible Errors: [service].Error.InvalidArguments
+ [service].Error.DoesNotExist
+
+ object SendMessage(string to, string text)
+
+ Send the message in text to the number in to. If the
+ message could be queued successfully, this method
+ returns an object path to the created Message object.
+
+Signals PropertyChanged(string name, variant value)
+
+ This signal indicates a changed value of the given
+ property.
+
+ ImmediateMessage(string message, dict info)
+
+ New immediate (class 0) SMS received. Info has Sender,
+ LocalSentTime, and SentTime information. Sender
+ address is given in string format. LocalSentTime and
+ SentTime are given in string form using ISO8601 format.
+
+ IncomingMessage(string message, dict info)
+
+ New incoming text SMS received. Info has Sender,
+ LocalSentTime, and SentTime information.
+
+ MessageAdded(object path, dict properties)
+
+ This signal is emitted whenever a new Message object
+ has been created.
+
+ MessageRemoved(object path)
+
+ This signal is emitted whenever a Message object
+ has been removed, e.g. when it reaches a final state.
+
+Properties string ServiceCenterAddress
+
+ Contains the number of the SMS service center.
+
+ boolean UseDeliveryReports
+
+ This property controls whether SMS Status Reports,
+ sometimes better known as Delivery Reports are to be
+ used. If enabled, all outgoing SMS messages will be
+ flagged to request a status report from the SMSC.
+
+ string Bearer
+
+ Contains the bearer to use for SMS messages. Possible
+ values are:
+ "cs-only" - Circuit Switched only
+ "ps-only" - Packet Domain only
+ "cs-preferred" - Use PS if CS is unavailable
+ "ps-preferred" - Use CS if PS is unavailable
+
+ By default oFono uses "cs-preferred" setting.
--
1.7.0.4
11 years, 8 months
[RFC 0/1] Add modem technology type property
by Dara Spieker-Doyle
This is a RFC to initiate discussion regarding the addition of a modem
technology type indicator property to the modem DBus interface. The need for
such a property has arisen as we cannot use the current interface to
guarantee understanding of a modem device's technology type to the upper layers
at all times.
The current design supports the behaviour where the upper layers can search for
whichever technology interfaces are available and instantiated by the current
modem device and execute accordingly. However, such behaviour only applies in
the case where there are distinguishing atoms (and associated DBus interfaces)
representing fundamentally different behaviour for different modem types. We
need to support the scenario where, for example, the different modem types
share the same DBus interface due to some, e.g. abstraction, in property
meaning, but the upper layers need to behave differently depending on the
technology. Currently, any technology distinguishing atoms are optional, which
means we cannot rely on these to provide interfaces to be used by the upper
layers to establish the technology type, e.g. ofono.cdma.voicecall may not
always be available even if the underlying modem is a CDMA modem. This implies
we would need to assign the responsibility of broadcasting the modem device
technology type through the core modem interface.
An example use case:
In 3GPP, the serial number of a device is referred to as the International
Mobile Equipment Identity (IMEI).
In 3GPP2, the serial number of a device is referred to as the Mobile Equipment
Identifier (MEID).
In oFono, such a feature is abstracted to the same serial number concept so GSM
and CDMA modems can both broadcast through the "Serial" modem interface.
However, the upper layer may need to process this value differently depending
on the current technology for e.g. display purposes. This interface is provided
through the core modem code, but we have no way of communicating the current
modem device type if operating in an initial offline mode without any other
atoms instantiated.
We envisage the potential for more such use cases in the future and look
forward to comments/discussion regarding our options.
Thank you
Dara Spieker-Doyle (1):
doc: Add modem technology type property
doc/modem-api.txt | 11 +++++++++++
1 files changed, 11 insertions(+), 0 deletions(-)
11 years, 8 months
[PATCH v2] TODO: add CDMA Connection Manager tasks
by christian.lam@nokia.com
From: Christian Lam <christian.lam(a)nokia.com>
---
TODO | 15 +++++++++++++++
1 files changed, 15 insertions(+), 0 deletions(-)
diff --git a/TODO b/TODO
index a36e9ed..41f1f7f 100644
--- a/TODO
+++ b/TODO
@@ -640,3 +640,18 @@ CDMA NETWORK ACQUISITION
Priority: Medium
Complexity: C2
+
+CDMA Connection Manager
+=======================
+
+- Support Packet Data Service over CDMA (1xRTT and 1xEV-DO) systems. This
+ includes Mobile Originated connection and disconnection features.
+
+ Priority: Medium
+ Complexity: C4
+
+- Support Network Initiated disconnection of Packet Data Service over CDMA
+ (1xRTT and 1xEV-DO) systems.
+
+ Priority: Medium
+ Complexity: C2
--
1.7.0.4
11 years, 8 months
[PATCHv3 0/2] Make message state feature independent of the stack
by Faiyaz Baxamusa
This set of patches enable the "org.ofono.Message" interface code to be
independent of the protocol stack. This will enable both GSM and CDMA SMS stack
to reuse the interface code.
The changes have been tested with phonesim using send-sms script.
Faiyaz Baxamusa (2):
doc: Add messagemanager-api and change message-api
sms: Introduce message code independent of protocol stack
Makefile.am | 7 +-
...message-api.txt => cdma-messagemanager-api.txt} | 0
doc/message-api.txt | 89 -------
doc/messagemanager-api.txt | 88 +++++++
src/message.c | 228 ++++++++++++++++++
src/message.h | 54 +++++
src/sms.c | 247 +++-----------------
7 files changed, 402 insertions(+), 311 deletions(-)
rename doc/{cdma-message-api.txt => cdma-messagemanager-api.txt} (100%)
create mode 100644 doc/messagemanager-api.txt
create mode 100644 src/message.c
create mode 100644 src/message.h
11 years, 8 months
[PATCH] TODO: add CDMA Connection Manager tasks.
by christian.lam@nokia.com
From: Christian Lam <christian.lam(a)nokia.com>
---
TODO | 16 ++++++++++++++++
1 files changed, 16 insertions(+), 0 deletions(-)
diff --git a/TODO b/TODO
index a36e9ed..2852f23 100644
--- a/TODO
+++ b/TODO
@@ -640,3 +640,19 @@ CDMA NETWORK ACQUISITION
Priority: Medium
Complexity: C2
+
+CDMA Connection Manager
+=======================
+
+- Support Packet Data Service over CDMA (1xRTT and 1xEV-DO) systems. This
+ includes Mobile Originated connection and disconnection features.
+
+ Priority: Medium
+ Complexity: C4
+
+- Support Network Initiated disconnection of Packet Data Service over CDMA
+ (1xRTT and 1xEV-DO) systems.
+
+ Priority: Medium
+ Complexity: C2
+
--
1.7.0.4
11 years, 8 months
[PATCH] README: Annotate kernel dependencies
by Gustavo F. Padovan
---
README | 7 +++++++
1 files changed, 7 insertions(+), 0 deletions(-)
diff --git a/README b/README
index 176a2de..71c8c2d 100644
--- a/README
+++ b/README
@@ -20,3 +20,10 @@ Configure automatically searches for all required components and packages.
To compile and install run:
make && make install
+
+
+Kernel Dependencies
+===================
+
+In order to have the PPP stack working in oFono you need to enable CONFIG_TUN
+(Universal TUN/TAP device driver support) in your kernel .config.
--
1.7.4.rc2
11 years, 8 months
[PATCHv2 2/2] sms: Introduce message code independent of protocol stack
by Faiyaz Baxamusa
---
Makefile.am | 2 +-
src/message.c | 230 +++++++++++++++++++++++++++++++++++++++++++++++++++++
src/message.h | 67 ++++++++++++++++
src/sms.c | 247 +++++++--------------------------------------------------
4 files changed, 326 insertions(+), 220 deletions(-)
create mode 100644 src/message.c
create mode 100644 src/message.h
diff --git a/Makefile.am b/Makefile.am
index c2e5706..9fe2d30 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -349,7 +349,7 @@ src_ofonod_SOURCES = $(gdbus_sources) $(builtin_sources) src/ofono.ver \
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/ctm.c \
- src/cdma-voicecall.c
+ src/cdma-voicecall.c src/message.h src/message.c
src_ofonod_LDADD = $(builtin_libadd) @GLIB_LIBS@ @DBUS_LIBS@ @CAPNG_LIBS@ \
@BLUEZ_LIBS@ -ldl
diff --git a/src/message.c b/src/message.c
new file mode 100644
index 0000000..e39265e
--- /dev/null
+++ b/src/message.c
@@ -0,0 +1,230 @@
+/*
+ *
+ * oFono - Open Source Telephony
+ *
+ * Copyright (C) 2008-2011 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 <gdbus.h>
+#include <stdio.h>
+
+#include "ofono.h"
+#include "message.h"
+
+struct message {
+ struct ofono_uuid uuid;
+ enum message_state state;
+ struct ofono_atom *atom;
+ void *data;
+};
+
+static const char *message_state_to_string(enum message_state s)
+{
+ switch (s) {
+ case MESSAGE_STATE_PENDING:
+ return "pending";
+ case MESSAGE_STATE_SENT:
+ return "sent";
+ case MESSAGE_STATE_FAILED:
+ return "failed";
+ }
+
+ return NULL;
+}
+
+static DBusMessage *message_get_properties(DBusConnection *conn,
+ DBusMessage *msg, void *data)
+{
+ struct message *m = data;
+ DBusMessage *reply;
+ DBusMessageIter iter;
+ DBusMessageIter dict;
+
+ 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);
+ message_append_properties(m, &dict);
+ dbus_message_iter_close_container(&iter, &dict);
+
+ return reply;
+}
+
+static GDBusMethodTable message_methods[] = {
+ { "GetProperties", "", "a{sv}", message_get_properties },
+ { }
+};
+
+static GDBusSignalTable message_signals[] = {
+ { "PropertyChanged", "sv" },
+ { }
+};
+
+struct message *message_create(const struct ofono_uuid *uuid,
+ struct ofono_atom *atom)
+{
+ struct message *v;
+
+ v = g_try_new0(struct message, 1);
+ if (v == NULL)
+ return NULL;
+
+ memcpy(&v->uuid, uuid, sizeof(*uuid));
+
+ v->atom = atom;
+
+ return v;
+}
+
+static void message_destroy(gpointer userdata)
+{
+ struct message *m = userdata;
+
+ m->data = NULL;
+ m->atom = NULL;
+ g_free(m);
+}
+
+gboolean message_dbus_register(struct message *m)
+{
+ DBusConnection *conn = ofono_dbus_get_connection();
+ const char *path = message_path_from_uuid(m->atom, &m->uuid);
+
+ if (!g_dbus_register_interface(conn, path, OFONO_MESSAGE_INTERFACE,
+ message_methods, message_signals,
+ NULL, m, message_destroy)) {
+ ofono_error("Could not register Message %s", path);
+ message_destroy(m);
+
+ return FALSE;
+ }
+
+ return TRUE;
+}
+
+void message_dbus_unregister(struct message *m)
+{
+ DBusConnection *conn = ofono_dbus_get_connection();
+ const char *path = message_path_from_uuid(m->atom, &m->uuid);
+
+ g_dbus_unregister_interface(conn, path, OFONO_MESSAGE_INTERFACE);
+
+ return;
+}
+
+const struct ofono_uuid *message_get_uuid(const struct message *m)
+{
+ return &m->uuid;
+}
+
+void message_set_state(struct message *m, enum message_state new_state)
+{
+ DBusConnection *conn = ofono_dbus_get_connection();
+ const char *path;
+ const char *state;
+
+ if (m->state == new_state)
+ return;
+
+ path = message_path_from_uuid(m->atom, &m->uuid);
+
+ m->state = new_state;
+ state = message_state_to_string(m->state);
+
+ ofono_dbus_signal_property_changed(conn, path, OFONO_MESSAGE_INTERFACE,
+ "State",
+ DBUS_TYPE_STRING,
+ &state);
+}
+
+void message_append_properties(struct message *m, DBusMessageIter *dict)
+{
+ const char *state = message_state_to_string(m->state);
+
+ ofono_dbus_dict_append(dict, "State", DBUS_TYPE_STRING, &state);
+}
+
+void message_emit_added(struct message *m, const char *interface)
+{
+ DBusMessage *signal;
+ DBusMessageIter iter;
+ DBusMessageIter dict;
+ const char *path;
+ const char *atompath = __ofono_atom_get_path(m->atom);
+
+ signal = dbus_message_new_signal(atompath, interface, "MessageAdded");
+ if (signal == NULL)
+ return;
+
+ path = message_path_from_uuid(m->atom, &m->uuid);
+
+ dbus_message_iter_init_append(signal, &iter);
+
+ dbus_message_iter_append_basic(&iter, DBUS_TYPE_OBJECT_PATH, &path);
+
+ dbus_message_iter_open_container(&iter, DBUS_TYPE_ARRAY,
+ OFONO_PROPERTIES_ARRAY_SIGNATURE,
+ &dict);
+ message_append_properties(m, &dict);
+ dbus_message_iter_close_container(&iter, &dict);
+
+ g_dbus_send_message(ofono_dbus_get_connection(), signal);
+}
+
+void message_emit_removed(struct message *m, const char *interface)
+{
+ DBusConnection *conn = ofono_dbus_get_connection();
+ const char *atompath = __ofono_atom_get_path(m->atom);
+ const char *path = message_path_from_uuid(m->atom, &m->uuid);
+
+ g_dbus_emit_signal(conn, atompath, interface, "MessageRemoved",
+ DBUS_TYPE_OBJECT_PATH,
+ &path,
+ DBUS_TYPE_INVALID);
+}
+
+const char *message_path_from_uuid(struct ofono_atom *atom,
+ const struct ofono_uuid *uuid)
+{
+ static char path[256];
+ const char *atompath = __ofono_atom_get_path(atom);
+
+ snprintf(path, sizeof(path), "%s/message_%s", atompath,
+ ofono_uuid_to_str(uuid));
+
+ return path;
+}
+
+void *message_get_data(struct message *m)
+{
+ return m->data;
+}
+
+void message_set_data(struct message *m, void *data)
+{
+ m->data = data;
+}
diff --git a/src/message.h b/src/message.h
new file mode 100644
index 0000000..faa957f
--- /dev/null
+++ b/src/message.h
@@ -0,0 +1,67 @@
+/*
+ *
+ * oFono - Open Source Telephony
+ *
+ * Copyright (C) 2008-2011 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_MESSAGE_H
+#define __OFONO_MESSAGE_H
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#include <ofono/types.h>
+
+enum message_state {
+ MESSAGE_STATE_PENDING,
+ MESSAGE_STATE_SENT,
+ MESSAGE_STATE_FAILED
+};
+
+struct ofono_atom;
+struct message;
+
+struct message *message_create(const struct ofono_uuid *uuid,
+ struct ofono_atom *atom);
+
+gboolean message_dbus_register(struct message *m);
+void message_dbus_unregister(struct message *m);
+
+const struct ofono_uuid *message_get_uuid(const struct message *m);
+
+void message_set_state(struct message *m, enum message_state new_state);
+
+void message_append_properties(struct message *m, DBusMessageIter *dict);
+
+void message_emit_added(struct message *m, const char *interface);
+
+void message_emit_removed(struct message *m, const char *interface);
+
+void *message_get_data(struct message *m);
+
+void message_set_data(struct message *m, void *data);
+
+const char *message_path_from_uuid(struct ofono_atom *atom,
+ const struct ofono_uuid *uuid);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* __OFONO_MESSAGE_H */
diff --git a/src/sms.c b/src/sms.c
index 9bb5c93..5398572 100644
--- a/src/sms.c
+++ b/src/sms.c
@@ -2,7 +2,7 @@
*
* oFono - Open Source Telephony
*
- * Copyright (C) 2008-2010 Intel Corporation. All rights reserved.
+ * Copyright (C) 2008-2011 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
@@ -24,7 +24,6 @@
#endif
#include <string.h>
-#include <stdio.h>
#include <errno.h>
#include <glib.h>
@@ -38,6 +37,7 @@
#include "smsutil.h"
#include "storage.h"
#include "simutil.h"
+#include "message.h"
#define uninitialized_var(x) x = x
@@ -52,18 +52,6 @@ static gboolean tx_next(gpointer user_data);
static GSList *g_drivers = NULL;
-enum message_state {
- MESSAGE_STATE_PENDING = 0,
- MESSAGE_STATE_SENT,
- MESSAGE_STATE_FAILED
-};
-
-struct message {
- struct ofono_uuid uuid;
- enum message_state state;
- struct tx_queue_entry *entry;
-};
-
struct sms_handler {
struct ofono_watchlist_item item;
int dst;
@@ -163,28 +151,6 @@ static int sms_bearer_from_string(const char *str)
return -1;
}
-static const char *message_state_to_string(enum message_state s)
-{
- switch (s) {
- case MESSAGE_STATE_PENDING:
- return "pending";
- case MESSAGE_STATE_SENT:
- return "sent";
- case MESSAGE_STATE_FAILED:
- return "failed";
- }
-
- return "invalid";
-}
-
-static void append_message_properties(struct message *m, DBusMessageIter *dict)
-{
- const char *state;
-
- state = message_state_to_string(m->state);
- ofono_dbus_dict_append(dict, "State", DBUS_TYPE_STRING, &state);
-}
-
static unsigned int add_sms_handler(struct ofono_watchlist *watchlist,
int dst, int src, void *notify,
void *data, ofono_destroy_func destroy)
@@ -256,181 +222,10 @@ gboolean __ofono_sms_datagram_watch_remove(struct ofono_sms *sms,
return __ofono_watchlist_remove_item(sms->datagram_handlers, id);
}
-static DBusMessage *message_get_properties(DBusConnection *conn,
- DBusMessage *msg, void *data)
-{
- struct message *m = data;
- DBusMessage *reply;
- DBusMessageIter iter;
- DBusMessageIter dict;
-
- 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);
- append_message_properties(m, &dict);
- dbus_message_iter_close_container(&iter, &dict);
-
- return reply;
-}
-
-static GDBusMethodTable message_methods[] = {
- { "GetProperties", "", "a{sv}", message_get_properties },
- { }
-};
-
-static GDBusSignalTable message_signals[] = {
- { "PropertyChanged", "sv" },
- { }
-};
-
-static struct message *message_create(const struct ofono_uuid *uuid)
-{
- struct message *v;
-
- if (uuid == NULL)
- return NULL;
-
- v = g_try_new0(struct message, 1);
- if (v == NULL)
- return NULL;
-
- memcpy(&v->uuid, uuid, sizeof(*uuid));
-
- return v;
-}
-
-static void message_destroy(gpointer userdata)
-{
- struct message *m = userdata;
-
- g_free(m);
-}
-
const char *__ofono_sms_message_path_from_uuid(struct ofono_sms *sms,
const struct ofono_uuid *uuid)
{
- static char path[256];
-
- snprintf(path, sizeof(path), "%s/message_%s",
- __ofono_atom_get_path(sms->atom),
- ofono_uuid_to_str(uuid));
-
- return path;
-}
-
-static gboolean message_dbus_register(struct ofono_sms *sms, struct message *m)
-{
- DBusConnection *conn = ofono_dbus_get_connection();
- const char *path;
-
- if (m == NULL)
- return FALSE;
-
- path = __ofono_sms_message_path_from_uuid(sms, &m->uuid);
-
- if (!g_dbus_register_interface(conn, path, OFONO_MESSAGE_INTERFACE,
- message_methods, message_signals,
- NULL, m, message_destroy)) {
- ofono_error("Could not register Message %s", path);
- message_destroy(m);
-
- return FALSE;
- }
-
- return TRUE;
-}
-
-static gboolean message_dbus_unregister(struct ofono_sms *sms,
- struct message *m)
-{
- DBusConnection *conn = ofono_dbus_get_connection();
- const char *path = __ofono_sms_message_path_from_uuid(sms, &m->uuid);
-
- return g_dbus_unregister_interface(conn, path,
- OFONO_MESSAGE_INTERFACE);
-}
-
-static void emit_message_added(struct ofono_sms *sms, struct message *m)
-{
- DBusMessage *signal;
- DBusMessageIter iter;
- DBusMessageIter dict;
- const char *path;
-
- path = __ofono_atom_get_path(sms->atom);
-
- signal = dbus_message_new_signal(path,
- OFONO_MESSAGE_MANAGER_INTERFACE,
- "MessageAdded");
-
- if (signal == NULL)
- return;
-
- dbus_message_iter_init_append(signal, &iter);
-
- path = __ofono_sms_message_path_from_uuid(sms, &m->uuid);
- dbus_message_iter_append_basic(&iter, DBUS_TYPE_OBJECT_PATH, &path);
-
- dbus_message_iter_open_container(&iter, DBUS_TYPE_ARRAY,
- OFONO_PROPERTIES_ARRAY_SIGNATURE,
- &dict);
- append_message_properties(m, &dict);
- dbus_message_iter_close_container(&iter, &dict);
-
- g_dbus_send_message(ofono_dbus_get_connection(), signal);
-}
-
-static void emit_message_removed(struct ofono_sms *sms, struct message *m)
-{
- DBusConnection *conn = ofono_dbus_get_connection();
- const char *atompath = __ofono_atom_get_path(sms->atom);
- const char *path = __ofono_sms_message_path_from_uuid(sms, &m->uuid);
-
- g_dbus_emit_signal(conn, atompath, OFONO_MESSAGE_MANAGER_INTERFACE,
- "MessageRemoved", DBUS_TYPE_OBJECT_PATH, &path,
- DBUS_TYPE_INVALID);
-}
-
-static void message_set_state(struct ofono_sms *sms,
- const struct ofono_uuid *uuid,
- enum message_state new_state)
-{
- DBusConnection *conn = ofono_dbus_get_connection();
- const char *path;
- const char *state;
- struct message *m;
-
- m = g_hash_table_lookup(sms->messages, uuid);
-
- if (m == NULL)
- return;
-
- if (m->state == new_state)
- return;
-
- m->state = new_state;
- path = __ofono_sms_message_path_from_uuid(sms, uuid);
- state = message_state_to_string(m->state);
-
- ofono_dbus_signal_property_changed(conn, path,
- OFONO_MESSAGE_INTERFACE,
- "State", DBUS_TYPE_STRING,
- &state);
-
- if (m->state == MESSAGE_STATE_SENT ||
- m->state == MESSAGE_STATE_FAILED) {
- m->entry = NULL;
-
- g_hash_table_remove(sms->messages, uuid);
- emit_message_removed(sms, m);
- message_dbus_unregister(sms, m);
- }
+ return message_path_from_uuid(sms->atom, uuid);
}
static void set_bearer(struct ofono_sms *sms, int bearer)
@@ -743,6 +538,7 @@ static void tx_finished(const struct ofono_error *error, int mr, void *data)
struct ofono_modem *modem = __ofono_atom_get_modem(sms->atom);
struct tx_queue_entry *entry = g_queue_peek_head(sms->txq);
gboolean ok = error->type == OFONO_ERROR_TYPE_NO_ERROR;
+ struct message *m = NULL;
DBG("tx_finished");
@@ -805,7 +601,15 @@ next_q:
else
ms = MESSAGE_STATE_FAILED;
- message_set_state(sms, &entry->uuid, ms);
+ m = g_hash_table_lookup(sms->messages, &entry->uuid);
+
+ if (m != NULL) {
+ message_set_state(m, ms);
+ g_hash_table_remove(sms->messages, &entry->uuid);
+ message_emit_removed(m,
+ OFONO_MESSAGE_MANAGER_INTERFACE);
+ message_dbus_unregister(m);
+ }
}
tx_queue_entry_destroy(entry);
@@ -1025,6 +829,7 @@ static DBusMessage *sms_get_messages(DBusConnection *conn, DBusMessage *msg,
GHashTableIter hashiter;
gpointer key, value;
struct message *m;
+ const struct ofono_uuid *uuid;
reply = dbus_message_new_method_return(msg);
if (reply == NULL)
@@ -1047,8 +852,9 @@ static DBusMessage *sms_get_messages(DBusConnection *conn, DBusMessage *msg,
while (g_hash_table_iter_next(&hashiter, &key, &value)) {
m = value;
+ uuid = message_get_uuid(m);
- path = __ofono_sms_message_path_from_uuid(sms, &m->uuid);
+ path = __ofono_sms_message_path_from_uuid(sms, uuid);
dbus_message_iter_open_container(&array, DBUS_TYPE_STRUCT,
NULL, &entry);
@@ -1058,7 +864,7 @@ static DBusMessage *sms_get_messages(DBusConnection *conn, DBusMessage *msg,
OFONO_PROPERTIES_ARRAY_SIGNATURE,
&dict);
- append_message_properties(m, &dict);
+ message_append_properties(m, &dict);
dbus_message_iter_close_container(&entry, &dict);
dbus_message_iter_close_container(&array, &entry);
}
@@ -1639,7 +1445,7 @@ static void sms_unregister(struct ofono_atom *atom)
while (g_hash_table_iter_next(&iter, &key, &value)) {
m = value;
- message_dbus_unregister(sms, m);
+ message_dbus_unregister(m);
}
g_hash_table_destroy(sms->messages);
@@ -1904,15 +1710,16 @@ int __ofono_sms_txq_submit(struct ofono_sms *sms, GSList *list,
return -ENOMEM;
if (flags & OFONO_SMS_SUBMIT_FLAG_EXPOSE_DBUS) {
- m = message_create(&entry->uuid);
+ m = message_create(&entry->uuid, sms->atom);
if (m == NULL)
goto err;
- if (message_dbus_register(sms, m) == FALSE)
+ if (message_dbus_register(m) == FALSE)
goto err;
- g_hash_table_insert(sms->messages, &m->uuid, m);
- m->entry = entry;
+ message_set_data(m, entry);
+
+ g_hash_table_insert(sms->messages, &entry->uuid, m);
}
if (list->next != NULL) {
@@ -1934,7 +1741,7 @@ int __ofono_sms_txq_submit(struct ofono_sms *sms, GSList *list,
cb(sms, &entry->uuid, data);
if (m && (flags & OFONO_SMS_SUBMIT_FLAG_EXPOSE_DBUS))
- emit_message_added(sms, m);
+ message_emit_added(m, OFONO_MESSAGE_MANAGER_INTERFACE);
return 0;
@@ -1951,15 +1758,17 @@ int __ofono_sms_txq_set_submit_notify(struct ofono_sms *sms,
ofono_destroy_func destroy)
{
struct message *m;
+ struct tx_queue_entry *entry;
m = g_hash_table_lookup(sms->messages, uuid);
if (m == NULL)
return -ENOENT;
- if (m->entry == NULL)
+ entry = message_get_data(m);
+ if (entry == NULL)
return -ENOTSUP;
- tx_queue_entry_set_submit_notify(m->entry, cb, data, destroy);
+ tx_queue_entry_set_submit_notify(entry, cb, data, destroy);
return 0;
}
--
1.7.0.4
11 years, 8 months
Ofono has too tight limits for SIM lock code lengths
by Jussi Kangas
Hi,
I've been testing SIM locks with Ofono and it looks to me that method
is_valid_pin in src/common.c has somewhat too tight rules for PIN
lenghts. SIM or subsidy lock codes can be longer than 8 digits (as
dictated in 22.022 chapter 14)
There are several ways to fix this. My current favourite is changing the
is_valid_pin so that it takes the actual return value of
sim_string_to_passwd instead of pin_type enumaration as parameter and
checks with 16-digit limit the SIM locks.
Other option that comes to my mind would be separate a valid check
method for SIM locks.
As third option I suggest adding fifth value to pin_type enumeration and
give that as a parameter for is_valid_pin to make it use different
limits. It would require more specific code type recognition in calling
function though.
Opinions? Other ideas?
Br,
-Jussi
11 years, 8 months