* [PATCH 3/6] ims: add implementation for IMS atom
@ 2017-10-05 17:15 Ankit Navik
2017-10-05 17:15 ` [PATCH 4/6] xmm7modem: Add ims atom driver Ankit Navik
` (2 more replies)
0 siblings, 3 replies; 9+ messages in thread
From: Ankit Navik @ 2017-10-05 17:15 UTC (permalink / raw)
To: ofono
[-- Attachment #1: Type: text/plain, Size: 11503 bytes --]
This implementation includes:
* D-Bus interface
* interaction with driver
---
Makefile.am | 2 +-
src/ims.c | 389 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
src/ofono.h | 2 +
3 files changed, 392 insertions(+), 1 deletion(-)
create mode 100644 src/ims.c
diff --git a/Makefile.am b/Makefile.am
index 165235e..199de08 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -630,7 +630,7 @@ src_ofonod_SOURCES = $(builtin_sources) $(gatchat_sources) src/ofono.ver \
src/cdma-provision.c src/handsfree.c \
src/handsfree-audio.c src/bluetooth.h \
src/hfp.h src/siri.c \
- src/netmon.c src/lte.c \
+ src/netmon.c src/lte.c src/ims.c \
src/netmonagent.c src/netmonagent.h
src_ofonod_LDADD = gdbus/libgdbus-internal.la $(builtin_libadd) \
diff --git a/src/ims.c b/src/ims.c
new file mode 100644
index 0000000..626d5d2
--- /dev/null
+++ b/src/ims.c
@@ -0,0 +1,389 @@
+/*
+ *
+ * oFono - Open Source Telephony
+ *
+ * Copyright (C) 2017 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 <stdint.h>
+#include <stdarg.h>
+#include <errno.h>
+
+#include <glib.h>
+#include <gdbus.h>
+
+#include "ofono.h"
+
+#include "common.h"
+
+#define VOICE_CAPABLE_FLAG 0x1
+#define SMS_CAPABLE_FLAG 0x4
+
+struct ofono_ims {
+ int reg_info;
+ int ext_info;
+ const struct ofono_ims_driver *driver;
+ void *driver_data;
+ struct ofono_atom *atom;
+ DBusMessage *pending;
+};
+
+static GSList *g_drivers = NULL;
+
+static DBusMessage *ims_get_properties(DBusConnection *conn,
+ DBusMessage *msg, void *data)
+{
+ struct ofono_ims *ims = data;
+ 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 = ims->reg_info ? TRUE : FALSE;
+ ofono_dbus_dict_append(&dict, "Registered", DBUS_TYPE_BOOLEAN, &value);
+
+ if (ims->ext_info != -1) {
+ value = ims->ext_info & VOICE_CAPABLE_FLAG ? TRUE : FALSE;
+ ofono_dbus_dict_append(&dict, "VoiceCapable",
+ DBUS_TYPE_BOOLEAN, &value);
+
+ value = ims->ext_info & SMS_CAPABLE_FLAG ? TRUE : FALSE;
+ ofono_dbus_dict_append(&dict, "SmsCapable",
+ DBUS_TYPE_BOOLEAN, &value);
+ }
+
+ dbus_message_iter_close_container(&iter, &dict);
+
+ return reply;
+}
+
+static void ims_set_sms_capable(struct ofono_ims *ims, ofono_bool_t status)
+{
+ const char *path = __ofono_atom_get_path(ims->atom);
+ DBusConnection *conn = ofono_dbus_get_connection();
+ dbus_bool_t new_value = status;
+ dbus_bool_t old_value = ims->ext_info & SMS_CAPABLE_FLAG ? TRUE :
+ FALSE;
+
+ if (old_value == new_value)
+ return;
+
+ ofono_dbus_signal_property_changed(conn, path,
+ OFONO_IMS_INTERFACE,
+ "SmsCapable",
+ DBUS_TYPE_BOOLEAN,
+ &new_value);
+}
+
+static void ims_set_voice_capable(struct ofono_ims *ims, ofono_bool_t status)
+{
+ const char *path = __ofono_atom_get_path(ims->atom);
+ DBusConnection *conn = ofono_dbus_get_connection();
+ dbus_bool_t new_value = status;
+ dbus_bool_t old_value = ims->ext_info & VOICE_CAPABLE_FLAG ? TRUE :
+ FALSE;
+
+ if (old_value == new_value)
+ return;
+
+ ofono_dbus_signal_property_changed(conn, path,
+ OFONO_IMS_INTERFACE,
+ "VoiceCapable",
+ DBUS_TYPE_BOOLEAN,
+ &new_value);
+}
+
+static void ims_set_registered(struct ofono_ims *ims, ofono_bool_t status)
+{
+ const char *path = __ofono_atom_get_path(ims->atom);
+ DBusConnection *conn = ofono_dbus_get_connection();
+ dbus_bool_t new_value = status;
+ dbus_bool_t old_value = ims->reg_info ? TRUE : FALSE;
+
+ if (old_value == new_value)
+ return;
+
+ ofono_dbus_signal_property_changed(conn, path,
+ OFONO_IMS_INTERFACE,
+ "Registered",
+ DBUS_TYPE_BOOLEAN,
+ &new_value);
+}
+
+void ofono_ims_status_notify(struct ofono_ims *ims, int reg_info, int ext_info)
+{
+ dbus_bool_t new_reg_info;
+ dbus_bool_t new_voice_capable, new_sms_capable;
+
+ if (ims == NULL)
+ return;
+
+ DBG("%s reg_info:%d ext_info:%d", __ofono_atom_get_path(ims->atom),
+ reg_info, ext_info);
+
+ if (ims->ext_info == ext_info && ims->reg_info == reg_info)
+ return;
+
+ new_reg_info = reg_info ? TRUE : FALSE;
+ ims_set_registered(ims, new_reg_info);
+
+ if (ext_info < 0)
+ goto skip;
+
+ new_voice_capable = ext_info & VOICE_CAPABLE_FLAG ? TRUE : FALSE;
+ ims_set_voice_capable(ims, new_voice_capable);
+
+ new_sms_capable = ext_info & SMS_CAPABLE_FLAG ? TRUE: FALSE;
+ ims_set_sms_capable(ims, new_sms_capable);
+
+skip:
+ ims->reg_info = reg_info;
+ ims->ext_info = ext_info;
+}
+
+static void registration_status_cb(const struct ofono_error *error,
+ int reg_info, int ext_info,
+ void *data)
+{
+ struct ofono_ims *ims = data;
+
+ if (error->type != OFONO_ERROR_TYPE_NO_ERROR) {
+ DBG("Error during IMS registration/unregistration");
+ return;
+ }
+
+ ofono_ims_status_notify(ims, reg_info, ext_info);
+}
+
+static void register_cb(const struct ofono_error *error, void *data)
+{
+ struct ofono_ims *ims = data;
+ DBusMessage *reply;
+
+ if (error->type == OFONO_ERROR_TYPE_NO_ERROR)
+ reply = dbus_message_new_method_return(ims->pending);
+ else
+ reply = __ofono_error_failed(ims->pending);
+
+ __ofono_dbus_pending_reply(&ims->pending, reply);
+
+ if (ims->driver->registration_status == NULL)
+ return;
+
+ ims->driver->registration_status(ims, registration_status_cb, ims);
+}
+
+static DBusMessage *ofono_ims_send_register(DBusConnection *conn,
+ DBusMessage *msg, void *data)
+{
+ struct ofono_ims *ims = data;
+
+ if (ims->pending)
+ return __ofono_error_busy(msg);
+
+ if (ims->driver->ims_register == NULL)
+ return __ofono_error_not_implemented(msg);
+
+ ims->pending = dbus_message_ref(msg);
+
+ ims->driver->ims_register(ims, register_cb, ims);
+
+ return NULL;
+}
+
+static DBusMessage *ofono_ims_unregister(DBusConnection *conn,
+ DBusMessage *msg, void *data)
+{
+ struct ofono_ims *ims = data;
+
+ if (ims->pending)
+ return __ofono_error_busy(msg);
+
+ if (ims->driver->ims_unregister == NULL)
+ return __ofono_error_not_implemented(msg);
+
+ ims->pending = dbus_message_ref(msg);
+
+ ims->driver->ims_unregister(ims, register_cb, ims);
+
+ return NULL;
+}
+
+static const GDBusMethodTable ims_methods[] = {
+ { GDBUS_METHOD("GetProperties",
+ NULL, GDBUS_ARGS({ "properties", "a{sv}" }),
+ ims_get_properties) },
+ { GDBUS_ASYNC_METHOD("Register", NULL, NULL,
+ ofono_ims_send_register) },
+ { GDBUS_ASYNC_METHOD("Unregister", NULL, NULL,
+ ofono_ims_unregister) },
+ { }
+};
+
+static const GDBusSignalTable ims_signals[] = {
+ { GDBUS_SIGNAL("PropertyChanged",
+ GDBUS_ARGS({ "name", "s" }, { "value", "v" })) },
+ { }
+};
+
+static void ims_atom_remove(struct ofono_atom *atom)
+{
+ struct ofono_ims *ims = __ofono_atom_get_data(atom);
+
+ DBG("atom: %p", atom);
+
+ if (ims == NULL)
+ return;
+
+ if (ims->driver && ims->driver->remove)
+ ims->driver->remove(ims);
+
+ g_free(ims);
+}
+
+struct ofono_ims *ofono_ims_create(struct ofono_modem *modem,
+ const char *driver, void *data)
+{
+ struct ofono_ims *ims;
+ GSList *l;
+
+ if (driver == NULL)
+ return NULL;
+
+ ims = g_try_new0(struct ofono_ims, 1);
+
+ if (ims == NULL)
+ return NULL;
+
+ ims->atom = __ofono_modem_add_atom(modem, OFONO_ATOM_TYPE_IMS,
+ ims_atom_remove, ims);
+
+ for (l = g_drivers; l; l = l->next) {
+ const struct ofono_ims_driver *drv = l->data;
+
+ if (g_strcmp0(drv->name, driver))
+ continue;
+
+ if (drv->probe(ims, data) < 0)
+ continue;
+
+ ims->driver = drv;
+ break;
+ }
+
+ DBG("IMS atom created");
+
+ return ims;
+}
+
+int ofono_ims_driver_register(const struct ofono_ims_driver *d)
+{
+ DBG("driver: %p, name: %s", d, d->name);
+
+ if (d->probe == NULL)
+ return -EINVAL;
+
+ g_drivers = g_slist_prepend(g_drivers, (void *) d);
+
+ return 0;
+}
+
+void ofono_ims_driver_unregister(const struct ofono_ims_driver *d)
+{
+ DBG("driver: %p, name: %s", d, d->name);
+
+ g_drivers = g_slist_remove(g_drivers, (void *) d);
+}
+
+static void ims_atom_unregister(struct ofono_atom *atom)
+{
+ DBusConnection *conn = ofono_dbus_get_connection();
+ struct ofono_modem *modem = __ofono_atom_get_modem(atom);
+ const char *path = __ofono_atom_get_path(atom);
+
+ ofono_modem_remove_interface(modem, OFONO_IMS_INTERFACE);
+ g_dbus_unregister_interface(conn, path, OFONO_IMS_INTERFACE);
+}
+
+static void ofono_ims_finish_register(struct ofono_ims *ims)
+{
+ DBusConnection *conn = ofono_dbus_get_connection();
+ struct ofono_modem *modem = __ofono_atom_get_modem(ims->atom);
+ const char *path = __ofono_atom_get_path(ims->atom);
+
+ if (!g_dbus_register_interface(conn, path,
+ OFONO_IMS_INTERFACE,
+ ims_methods, ims_signals, NULL,
+ ims, NULL)) {
+ ofono_error("could not create %s interface",
+ OFONO_IMS_INTERFACE);
+ return;
+ }
+
+ ofono_modem_add_interface(modem, OFONO_IMS_INTERFACE);
+
+ if (ims->driver->registration_status)
+ ims->driver->registration_status(ims,
+ registration_status_cb, ims);
+
+ __ofono_atom_register(ims->atom, ims_atom_unregister);
+}
+
+void ofono_ims_register(struct ofono_ims *ims)
+{
+ struct ofono_modem *modem = __ofono_atom_get_modem(ims->atom);
+ struct ofono_sim *sim = __ofono_atom_find(OFONO_ATOM_TYPE_SIM, modem);
+ const char *imsi = ofono_sim_get_imsi(sim);
+
+ if (imsi == NULL) {
+ ofono_error("No sim atom required for registering IMS atom.");
+ return;
+ }
+
+ ofono_ims_finish_register(ims);
+}
+
+void ofono_ims_remove(struct ofono_ims *ims)
+{
+ __ofono_atom_free(ims->atom);
+}
+
+void ofono_ims_set_data(struct ofono_ims *ims, void *data)
+{
+ ims->driver_data = data;
+}
+
+void *ofono_ims_get_data(const struct ofono_ims *ims)
+{
+ return ims->driver_data;
+}
diff --git a/src/ofono.h b/src/ofono.h
index a797b7f..0da11a2 100644
--- a/src/ofono.h
+++ b/src/ofono.h
@@ -154,6 +154,7 @@ enum ofono_atom_type {
OFONO_ATOM_TYPE_SIRI,
OFONO_ATOM_TYPE_NETMON,
OFONO_ATOM_TYPE_LTE,
+ OFONO_ATOM_TYPE_IMS,
};
enum ofono_atom_watch_condition {
@@ -534,3 +535,4 @@ ofono_bool_t __ofono_private_network_request(ofono_private_network_cb_t cb,
#include <ofono/netmon.h>
#include <ofono/lte.h>
+#include <ofono/ims.h>
--
1.9.1
^ permalink raw reply related [flat|nested] 9+ messages in thread
* [PATCH 4/6] xmm7modem: Add ims atom driver
2017-10-05 17:15 [PATCH 3/6] ims: add implementation for IMS atom Ankit Navik
@ 2017-10-05 17:15 ` Ankit Navik
2017-10-09 16:42 ` Denis Kenzior
2017-10-05 17:15 ` [PATCH 5/6] xmm7modem: Add support for ims Ankit Navik
2017-10-09 16:41 ` [PATCH 3/6] ims: add implementation for IMS atom Denis Kenzior
2 siblings, 1 reply; 9+ messages in thread
From: Ankit Navik @ 2017-10-05 17:15 UTC (permalink / raw)
To: ofono
[-- Attachment #1: Type: text/plain, Size: 8348 bytes --]
---
Makefile.am | 3 +-
drivers/xmm7modem/ims.c | 255 ++++++++++++++++++++++++++++++++++++++++++
drivers/xmm7modem/xmm7modem.c | 2 +
drivers/xmm7modem/xmm7modem.h | 3 +
plugins/xmm7xxx.c | 1 +
5 files changed, 263 insertions(+), 1 deletion(-)
create mode 100755 drivers/xmm7modem/ims.c
diff --git a/Makefile.am b/Makefile.am
index 199de08..1a03229 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -401,7 +401,8 @@ builtin_modules += xmm7modem
builtin_sources += drivers/atmodem/atutil.h \
drivers/xmm7modem/xmm7modem.h \
drivers/xmm7modem/xmm7modem.c \
- drivers/xmm7modem/radio-settings.c
+ drivers/xmm7modem/radio-settings.c \
+ drivers/xmm7modem/ims.c
if PHONESIM
builtin_modules += phonesim
diff --git a/drivers/xmm7modem/ims.c b/drivers/xmm7modem/ims.c
new file mode 100755
index 0000000..a86948f
--- /dev/null
+++ b/drivers/xmm7modem/ims.c
@@ -0,0 +1,255 @@
+/*
+ *
+ * oFono - Open Source Telephony
+ *
+ * Copyright (C) 2017 Intel Corporation. All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+ *
+ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#define _GNU_SOURCE
+#include <stdlib.h>
+#include <stdio.h>
+#include <string.h>
+#include <errno.h>
+
+#include <glib.h>
+
+#include <ofono/modem.h>
+#include <ofono/log.h>
+#include <ofono/ims.h>
+
+#include "gatchat.h"
+#include "gatresult.h"
+
+#include "xmm7modem.h"
+
+static const char *none_prefix[] = { NULL };
+static const char *cireg_prefix[] = { "+CIREG:", NULL };
+
+struct ims_driver_data {
+ GAtChat *chat;
+};
+
+static void xmm_cireg_cb(gboolean ok, GAtResult *result,
+ gpointer user_data)
+{
+ struct cb_data *cbd = user_data;
+ ofono_ims_status_cb_t cb = cbd->cb;
+ struct ofono_error error;
+ GAtResultIter iter;
+ int reg_info, ext_info;
+
+ DBG("ok %d", ok);
+
+ decode_at_error(&error, g_at_result_final_response(result));
+
+ if (!ok) {
+ cb(&error, -1, -1, cbd->data);
+ return;
+ }
+
+ g_at_result_iter_init(&iter, result);
+
+ if (g_at_result_iter_next(&iter, "+CIREG:") == FALSE)
+ goto error;
+
+ /* skip value of n */
+ g_at_result_iter_skip_next(&iter);
+
+ if (g_at_result_iter_next_number(&iter, ®_info) == FALSE)
+ goto error;
+
+ if (reg_info == 0)
+ ext_info = -1;
+ else
+ if (g_at_result_iter_next_number(&iter, &ext_info) == FALSE)
+ goto error;
+
+ cb(&error, reg_info, ext_info, cbd->data);
+
+ return;
+
+error:
+ CALLBACK_WITH_FAILURE(cb, -1, -1, cbd->data);
+}
+
+static void xmm_ims_registration_status(struct ofono_ims *ims,
+ ofono_ims_status_cb_t cb, void *data)
+{
+ struct ims_driver_data *idd = ofono_ims_get_data(ims);
+ struct cb_data *cbd = cb_data_new(cb, data);
+
+ if (g_at_chat_send(idd->chat, "AT+CIREG?", cireg_prefix,
+ xmm_cireg_cb, cbd, g_free) > 0)
+ return;
+
+ CALLBACK_WITH_FAILURE(cb, -1, -1, data);
+ g_free(cbd);
+}
+
+static void xmm_ims_register_cb(gboolean ok, GAtResult *result,
+ gpointer user_data)
+{
+ struct cb_data *cbd = user_data;
+ ofono_ims_register_cb_t cb = cbd->cb;
+ struct ofono_error error;
+
+ DBG("ok %d", ok);
+
+ decode_at_error(&error, g_at_result_final_response(result));
+ cb(&error, cbd->data);
+}
+
+static void xmm_ims_register(struct ofono_ims *ims,
+ ofono_ims_register_cb_t cb, void *data)
+{
+ struct ims_driver_data *idd = ofono_ims_get_data(ims);
+ struct cb_data *cbd = cb_data_new(cb, data);
+
+ if (g_at_chat_send(idd->chat, "AT+XIREG=1", none_prefix,
+ xmm_ims_register_cb, cbd, g_free) > 0)
+ return;
+
+ CALLBACK_WITH_FAILURE(cb, data);
+ g_free(cbd);
+}
+
+static void xmm_ims_unregister(struct ofono_ims *ims,
+ ofono_ims_register_cb_t cb, void *data)
+{
+ struct ims_driver_data *idd = ofono_ims_get_data(ims);
+ struct cb_data *cbd = cb_data_new(cb, data);
+
+ if (g_at_chat_send(idd->chat, "AT+XIREG=0", none_prefix,
+ xmm_ims_register_cb, cbd, g_free) > 0)
+ return;
+
+ CALLBACK_WITH_FAILURE(cb, data);
+ g_free(cbd);
+}
+
+static void ciregu_notify(GAtResult *result, gpointer user_data)
+{
+ struct ofono_ims *ims = user_data;
+ int reg_info, ext_info;
+ GAtResultIter iter;
+
+ g_at_result_iter_init(&iter, result);
+
+ if (!g_at_result_iter_next(&iter, "+CIREGU:"))
+ return;
+
+ if (!g_at_result_iter_next_number(&iter, ®_info))
+ return;
+
+ if (reg_info == 0)
+ ext_info = -1;
+ else
+ if (!g_at_result_iter_next_number(&iter, &ext_info))
+ return;
+
+ DBG("reg_info:%d, ext_info:%d", reg_info, ext_info);
+
+ ofono_ims_status_notify(ims, reg_info, ext_info);
+}
+
+static void xmm_cireg_set_cb(gboolean ok, GAtResult *result,
+ gpointer user_data)
+{
+ struct ofono_ims *ims = user_data;
+
+ if (!ok) {
+ ofono_ims_remove(ims);
+ return;
+ }
+
+ ofono_ims_register(ims);
+}
+
+static void cireg_support_cb(gboolean ok, GAtResult *result,
+ gpointer user_data)
+{
+ struct ofono_ims *ims = user_data;
+ struct ims_driver_data *idd = ofono_ims_get_data(ims);
+
+ if (!ok) {
+ ofono_ims_remove(ims);
+ return;
+ }
+
+ g_at_chat_register(idd->chat, "+CIREGU:", ciregu_notify,
+ FALSE, ims, NULL);
+
+ g_at_chat_send(idd->chat, "AT+CIREG=2", none_prefix,
+ xmm_cireg_set_cb, ims, NULL);
+}
+
+static int xmm_ims_probe(struct ofono_ims *ims, void *data)
+{
+ GAtChat *chat = data;
+ struct ims_driver_data *idd;
+
+ DBG("at ims probe");
+
+ idd = g_try_new0(struct ims_driver_data, 1);
+ if (!idd)
+ return -ENOMEM;
+
+ idd->chat = g_at_chat_clone(chat);
+
+ ofono_ims_set_data(ims, idd);
+
+ g_at_chat_send(idd->chat, "AT+CIREG=?", cireg_prefix,
+ cireg_support_cb, ims, NULL);
+
+ return 0;
+}
+
+static void xmm_ims_remove(struct ofono_ims *ims)
+{
+ struct ims_driver_data *idd = ofono_ims_get_data(ims);
+
+ DBG("at ims remove");
+
+ g_at_chat_unref(idd->chat);
+
+ ofono_ims_set_data(ims, NULL);
+
+ g_free(idd);
+}
+
+static struct ofono_ims_driver driver = {
+ .name = "xmm7modem",
+ .probe = xmm_ims_probe,
+ .remove = xmm_ims_remove,
+ .ims_register = xmm_ims_register,
+ .ims_unregister = xmm_ims_unregister,
+ .registration_status = xmm_ims_registration_status,
+};
+
+void xmm_ims_init(void)
+{
+ ofono_ims_driver_register(&driver);
+}
+
+void xmm_ims_exit(void)
+{
+ ofono_ims_driver_unregister(&driver);
+}
diff --git a/drivers/xmm7modem/xmm7modem.c b/drivers/xmm7modem/xmm7modem.c
index db1864e..5c08343 100644
--- a/drivers/xmm7modem/xmm7modem.c
+++ b/drivers/xmm7modem/xmm7modem.c
@@ -36,6 +36,7 @@
static int xmm7modem_init(void)
{
xmm_radio_settings_init();
+ xmm_ims_init();
return 0;
}
@@ -43,6 +44,7 @@ static int xmm7modem_init(void)
static void xmm7modem_exit(void)
{
xmm_radio_settings_exit();
+ xmm_ims_exit();
}
OFONO_PLUGIN_DEFINE(xmm7modem, "Intel xmm7xxx series modem driver",
diff --git a/drivers/xmm7modem/xmm7modem.h b/drivers/xmm7modem/xmm7modem.h
index 44fa3d6..5f8f172 100644
--- a/drivers/xmm7modem/xmm7modem.h
+++ b/drivers/xmm7modem/xmm7modem.h
@@ -25,3 +25,6 @@
extern void xmm_radio_settings_init(void);
extern void xmm_radio_settings_exit(void);
+
+extern void xmm_ims_init(void);
+extern void xmm_ims_exit(void);
diff --git a/plugins/xmm7xxx.c b/plugins/xmm7xxx.c
index 4443d4c..24b7d31 100644
--- a/plugins/xmm7xxx.c
+++ b/plugins/xmm7xxx.c
@@ -48,6 +48,7 @@
#include <ofono/gprs-context.h>
#include <ofono/stk.h>
#include <ofono/lte.h>
+#include <ofono/ims.h>
#include <drivers/atmodem/atutil.h>
#include <drivers/atmodem/vendor.h>
--
1.9.1
^ permalink raw reply related [flat|nested] 9+ messages in thread
* [PATCH 5/6] xmm7modem: Add support for ims
2017-10-05 17:15 [PATCH 3/6] ims: add implementation for IMS atom Ankit Navik
2017-10-05 17:15 ` [PATCH 4/6] xmm7modem: Add ims atom driver Ankit Navik
@ 2017-10-05 17:15 ` Ankit Navik
2017-10-09 16:42 ` Denis Kenzior
2017-10-09 16:41 ` [PATCH 3/6] ims: add implementation for IMS atom Denis Kenzior
2 siblings, 1 reply; 9+ messages in thread
From: Ankit Navik @ 2017-10-05 17:15 UTC (permalink / raw)
To: ofono
[-- Attachment #1: Type: text/plain, Size: 472 bytes --]
---
plugins/xmm7xxx.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/plugins/xmm7xxx.c b/plugins/xmm7xxx.c
index 24b7d31..5cb843b 100644
--- a/plugins/xmm7xxx.c
+++ b/plugins/xmm7xxx.c
@@ -341,6 +341,8 @@ static void xmm7xxx_post_online(struct ofono_modem *modem)
if (gprs && gc)
ofono_gprs_add_context(gprs, gc);
+
+ ofono_ims_create(modem, "xmm7modem", data->chat);
}
static int xmm7xxx_probe(struct ofono_modem *modem)
--
1.9.1
^ permalink raw reply related [flat|nested] 9+ messages in thread
* Re: [PATCH 3/6] ims: add implementation for IMS atom
2017-10-05 17:15 [PATCH 3/6] ims: add implementation for IMS atom Ankit Navik
2017-10-05 17:15 ` [PATCH 4/6] xmm7modem: Add ims atom driver Ankit Navik
2017-10-05 17:15 ` [PATCH 5/6] xmm7modem: Add support for ims Ankit Navik
@ 2017-10-09 16:41 ` Denis Kenzior
2 siblings, 0 replies; 9+ messages in thread
From: Denis Kenzior @ 2017-10-09 16:41 UTC (permalink / raw)
To: ofono
[-- Attachment #1: Type: text/plain, Size: 528 bytes --]
Hi Ankit,
On 10/05/2017 12:15 PM, Ankit Navik wrote:
> This implementation includes:
> * D-Bus interface
> * interaction with driver
> ---
> Makefile.am | 2 +-
> src/ims.c | 389 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
> src/ofono.h | 2 +
> 3 files changed, 392 insertions(+), 1 deletion(-)
> create mode 100644 src/ims.c
>
I applied this patch but reworked it slightly in 2 follow on commits.
Please review and let me know if I screwed anything up.
Regards,
-Denis
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH 4/6] xmm7modem: Add ims atom driver
2017-10-05 17:15 ` [PATCH 4/6] xmm7modem: Add ims atom driver Ankit Navik
@ 2017-10-09 16:42 ` Denis Kenzior
0 siblings, 0 replies; 9+ messages in thread
From: Denis Kenzior @ 2017-10-09 16:42 UTC (permalink / raw)
To: ofono
[-- Attachment #1: Type: text/plain, Size: 545 bytes --]
Hi Ankit,
On 10/05/2017 12:15 PM, Ankit Navik wrote:
> ---
> Makefile.am | 3 +-
> drivers/xmm7modem/ims.c | 255 ++++++++++++++++++++++++++++++++++++++++++
> drivers/xmm7modem/xmm7modem.c | 2 +
> drivers/xmm7modem/xmm7modem.h | 3 +
> plugins/xmm7xxx.c | 1 +
I squashed this change inside plugins/xmm7xxx.c into the next commit.
> 5 files changed, 263 insertions(+), 1 deletion(-)
> create mode 100755 drivers/xmm7modem/ims.c
>
Applied, thanks.
Regards,
-Denis
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH 5/6] xmm7modem: Add support for ims
2017-10-05 17:15 ` [PATCH 5/6] xmm7modem: Add support for ims Ankit Navik
@ 2017-10-09 16:42 ` Denis Kenzior
0 siblings, 0 replies; 9+ messages in thread
From: Denis Kenzior @ 2017-10-09 16:42 UTC (permalink / raw)
To: ofono
[-- Attachment #1: Type: text/plain, Size: 177 bytes --]
Hi Ankit,
On 10/05/2017 12:15 PM, Ankit Navik wrote:
> ---
> plugins/xmm7xxx.c | 2 ++
> 1 file changed, 2 insertions(+)
>
Applied, thanks.
Regards,
-Denis
^ permalink raw reply [flat|nested] 9+ messages in thread
* [PATCH 3/6] ims: add implementation for IMS atom
@ 2017-10-04 6:03 Ankit Navik
0 siblings, 0 replies; 9+ messages in thread
From: Ankit Navik @ 2017-10-04 6:03 UTC (permalink / raw)
To: ofono
[-- Attachment #1: Type: text/plain, Size: 11503 bytes --]
This implementation includes:
* D-Bus interface
* interaction with driver
---
Makefile.am | 2 +-
src/ims.c | 389 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
src/ofono.h | 2 +
3 files changed, 392 insertions(+), 1 deletion(-)
create mode 100644 src/ims.c
diff --git a/Makefile.am b/Makefile.am
index 165235e..199de08 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -630,7 +630,7 @@ src_ofonod_SOURCES = $(builtin_sources) $(gatchat_sources) src/ofono.ver \
src/cdma-provision.c src/handsfree.c \
src/handsfree-audio.c src/bluetooth.h \
src/hfp.h src/siri.c \
- src/netmon.c src/lte.c \
+ src/netmon.c src/lte.c src/ims.c \
src/netmonagent.c src/netmonagent.h
src_ofonod_LDADD = gdbus/libgdbus-internal.la $(builtin_libadd) \
diff --git a/src/ims.c b/src/ims.c
new file mode 100644
index 0000000..626d5d2
--- /dev/null
+++ b/src/ims.c
@@ -0,0 +1,389 @@
+/*
+ *
+ * oFono - Open Source Telephony
+ *
+ * Copyright (C) 2017 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 <stdint.h>
+#include <stdarg.h>
+#include <errno.h>
+
+#include <glib.h>
+#include <gdbus.h>
+
+#include "ofono.h"
+
+#include "common.h"
+
+#define VOICE_CAPABLE_FLAG 0x1
+#define SMS_CAPABLE_FLAG 0x4
+
+struct ofono_ims {
+ int reg_info;
+ int ext_info;
+ const struct ofono_ims_driver *driver;
+ void *driver_data;
+ struct ofono_atom *atom;
+ DBusMessage *pending;
+};
+
+static GSList *g_drivers = NULL;
+
+static DBusMessage *ims_get_properties(DBusConnection *conn,
+ DBusMessage *msg, void *data)
+{
+ struct ofono_ims *ims = data;
+ 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 = ims->reg_info ? TRUE : FALSE;
+ ofono_dbus_dict_append(&dict, "Registered", DBUS_TYPE_BOOLEAN, &value);
+
+ if (ims->ext_info != -1) {
+ value = ims->ext_info & VOICE_CAPABLE_FLAG ? TRUE : FALSE;
+ ofono_dbus_dict_append(&dict, "VoiceCapable",
+ DBUS_TYPE_BOOLEAN, &value);
+
+ value = ims->ext_info & SMS_CAPABLE_FLAG ? TRUE : FALSE;
+ ofono_dbus_dict_append(&dict, "SmsCapable",
+ DBUS_TYPE_BOOLEAN, &value);
+ }
+
+ dbus_message_iter_close_container(&iter, &dict);
+
+ return reply;
+}
+
+static void ims_set_sms_capable(struct ofono_ims *ims, ofono_bool_t status)
+{
+ const char *path = __ofono_atom_get_path(ims->atom);
+ DBusConnection *conn = ofono_dbus_get_connection();
+ dbus_bool_t new_value = status;
+ dbus_bool_t old_value = ims->ext_info & SMS_CAPABLE_FLAG ? TRUE :
+ FALSE;
+
+ if (old_value == new_value)
+ return;
+
+ ofono_dbus_signal_property_changed(conn, path,
+ OFONO_IMS_INTERFACE,
+ "SmsCapable",
+ DBUS_TYPE_BOOLEAN,
+ &new_value);
+}
+
+static void ims_set_voice_capable(struct ofono_ims *ims, ofono_bool_t status)
+{
+ const char *path = __ofono_atom_get_path(ims->atom);
+ DBusConnection *conn = ofono_dbus_get_connection();
+ dbus_bool_t new_value = status;
+ dbus_bool_t old_value = ims->ext_info & VOICE_CAPABLE_FLAG ? TRUE :
+ FALSE;
+
+ if (old_value == new_value)
+ return;
+
+ ofono_dbus_signal_property_changed(conn, path,
+ OFONO_IMS_INTERFACE,
+ "VoiceCapable",
+ DBUS_TYPE_BOOLEAN,
+ &new_value);
+}
+
+static void ims_set_registered(struct ofono_ims *ims, ofono_bool_t status)
+{
+ const char *path = __ofono_atom_get_path(ims->atom);
+ DBusConnection *conn = ofono_dbus_get_connection();
+ dbus_bool_t new_value = status;
+ dbus_bool_t old_value = ims->reg_info ? TRUE : FALSE;
+
+ if (old_value == new_value)
+ return;
+
+ ofono_dbus_signal_property_changed(conn, path,
+ OFONO_IMS_INTERFACE,
+ "Registered",
+ DBUS_TYPE_BOOLEAN,
+ &new_value);
+}
+
+void ofono_ims_status_notify(struct ofono_ims *ims, int reg_info, int ext_info)
+{
+ dbus_bool_t new_reg_info;
+ dbus_bool_t new_voice_capable, new_sms_capable;
+
+ if (ims == NULL)
+ return;
+
+ DBG("%s reg_info:%d ext_info:%d", __ofono_atom_get_path(ims->atom),
+ reg_info, ext_info);
+
+ if (ims->ext_info == ext_info && ims->reg_info == reg_info)
+ return;
+
+ new_reg_info = reg_info ? TRUE : FALSE;
+ ims_set_registered(ims, new_reg_info);
+
+ if (ext_info < 0)
+ goto skip;
+
+ new_voice_capable = ext_info & VOICE_CAPABLE_FLAG ? TRUE : FALSE;
+ ims_set_voice_capable(ims, new_voice_capable);
+
+ new_sms_capable = ext_info & SMS_CAPABLE_FLAG ? TRUE: FALSE;
+ ims_set_sms_capable(ims, new_sms_capable);
+
+skip:
+ ims->reg_info = reg_info;
+ ims->ext_info = ext_info;
+}
+
+static void registration_status_cb(const struct ofono_error *error,
+ int reg_info, int ext_info,
+ void *data)
+{
+ struct ofono_ims *ims = data;
+
+ if (error->type != OFONO_ERROR_TYPE_NO_ERROR) {
+ DBG("Error during IMS registration/unregistration");
+ return;
+ }
+
+ ofono_ims_status_notify(ims, reg_info, ext_info);
+}
+
+static void register_cb(const struct ofono_error *error, void *data)
+{
+ struct ofono_ims *ims = data;
+ DBusMessage *reply;
+
+ if (error->type == OFONO_ERROR_TYPE_NO_ERROR)
+ reply = dbus_message_new_method_return(ims->pending);
+ else
+ reply = __ofono_error_failed(ims->pending);
+
+ __ofono_dbus_pending_reply(&ims->pending, reply);
+
+ if (ims->driver->registration_status == NULL)
+ return;
+
+ ims->driver->registration_status(ims, registration_status_cb, ims);
+}
+
+static DBusMessage *ofono_ims_send_register(DBusConnection *conn,
+ DBusMessage *msg, void *data)
+{
+ struct ofono_ims *ims = data;
+
+ if (ims->pending)
+ return __ofono_error_busy(msg);
+
+ if (ims->driver->ims_register == NULL)
+ return __ofono_error_not_implemented(msg);
+
+ ims->pending = dbus_message_ref(msg);
+
+ ims->driver->ims_register(ims, register_cb, ims);
+
+ return NULL;
+}
+
+static DBusMessage *ofono_ims_unregister(DBusConnection *conn,
+ DBusMessage *msg, void *data)
+{
+ struct ofono_ims *ims = data;
+
+ if (ims->pending)
+ return __ofono_error_busy(msg);
+
+ if (ims->driver->ims_unregister == NULL)
+ return __ofono_error_not_implemented(msg);
+
+ ims->pending = dbus_message_ref(msg);
+
+ ims->driver->ims_unregister(ims, register_cb, ims);
+
+ return NULL;
+}
+
+static const GDBusMethodTable ims_methods[] = {
+ { GDBUS_METHOD("GetProperties",
+ NULL, GDBUS_ARGS({ "properties", "a{sv}" }),
+ ims_get_properties) },
+ { GDBUS_ASYNC_METHOD("Register", NULL, NULL,
+ ofono_ims_send_register) },
+ { GDBUS_ASYNC_METHOD("Unregister", NULL, NULL,
+ ofono_ims_unregister) },
+ { }
+};
+
+static const GDBusSignalTable ims_signals[] = {
+ { GDBUS_SIGNAL("PropertyChanged",
+ GDBUS_ARGS({ "name", "s" }, { "value", "v" })) },
+ { }
+};
+
+static void ims_atom_remove(struct ofono_atom *atom)
+{
+ struct ofono_ims *ims = __ofono_atom_get_data(atom);
+
+ DBG("atom: %p", atom);
+
+ if (ims == NULL)
+ return;
+
+ if (ims->driver && ims->driver->remove)
+ ims->driver->remove(ims);
+
+ g_free(ims);
+}
+
+struct ofono_ims *ofono_ims_create(struct ofono_modem *modem,
+ const char *driver, void *data)
+{
+ struct ofono_ims *ims;
+ GSList *l;
+
+ if (driver == NULL)
+ return NULL;
+
+ ims = g_try_new0(struct ofono_ims, 1);
+
+ if (ims == NULL)
+ return NULL;
+
+ ims->atom = __ofono_modem_add_atom(modem, OFONO_ATOM_TYPE_IMS,
+ ims_atom_remove, ims);
+
+ for (l = g_drivers; l; l = l->next) {
+ const struct ofono_ims_driver *drv = l->data;
+
+ if (g_strcmp0(drv->name, driver))
+ continue;
+
+ if (drv->probe(ims, data) < 0)
+ continue;
+
+ ims->driver = drv;
+ break;
+ }
+
+ DBG("IMS atom created");
+
+ return ims;
+}
+
+int ofono_ims_driver_register(const struct ofono_ims_driver *d)
+{
+ DBG("driver: %p, name: %s", d, d->name);
+
+ if (d->probe == NULL)
+ return -EINVAL;
+
+ g_drivers = g_slist_prepend(g_drivers, (void *) d);
+
+ return 0;
+}
+
+void ofono_ims_driver_unregister(const struct ofono_ims_driver *d)
+{
+ DBG("driver: %p, name: %s", d, d->name);
+
+ g_drivers = g_slist_remove(g_drivers, (void *) d);
+}
+
+static void ims_atom_unregister(struct ofono_atom *atom)
+{
+ DBusConnection *conn = ofono_dbus_get_connection();
+ struct ofono_modem *modem = __ofono_atom_get_modem(atom);
+ const char *path = __ofono_atom_get_path(atom);
+
+ ofono_modem_remove_interface(modem, OFONO_IMS_INTERFACE);
+ g_dbus_unregister_interface(conn, path, OFONO_IMS_INTERFACE);
+}
+
+static void ofono_ims_finish_register(struct ofono_ims *ims)
+{
+ DBusConnection *conn = ofono_dbus_get_connection();
+ struct ofono_modem *modem = __ofono_atom_get_modem(ims->atom);
+ const char *path = __ofono_atom_get_path(ims->atom);
+
+ if (!g_dbus_register_interface(conn, path,
+ OFONO_IMS_INTERFACE,
+ ims_methods, ims_signals, NULL,
+ ims, NULL)) {
+ ofono_error("could not create %s interface",
+ OFONO_IMS_INTERFACE);
+ return;
+ }
+
+ ofono_modem_add_interface(modem, OFONO_IMS_INTERFACE);
+
+ if (ims->driver->registration_status)
+ ims->driver->registration_status(ims,
+ registration_status_cb, ims);
+
+ __ofono_atom_register(ims->atom, ims_atom_unregister);
+}
+
+void ofono_ims_register(struct ofono_ims *ims)
+{
+ struct ofono_modem *modem = __ofono_atom_get_modem(ims->atom);
+ struct ofono_sim *sim = __ofono_atom_find(OFONO_ATOM_TYPE_SIM, modem);
+ const char *imsi = ofono_sim_get_imsi(sim);
+
+ if (imsi == NULL) {
+ ofono_error("No sim atom required for registering IMS atom.");
+ return;
+ }
+
+ ofono_ims_finish_register(ims);
+}
+
+void ofono_ims_remove(struct ofono_ims *ims)
+{
+ __ofono_atom_free(ims->atom);
+}
+
+void ofono_ims_set_data(struct ofono_ims *ims, void *data)
+{
+ ims->driver_data = data;
+}
+
+void *ofono_ims_get_data(const struct ofono_ims *ims)
+{
+ return ims->driver_data;
+}
diff --git a/src/ofono.h b/src/ofono.h
index a797b7f..0da11a2 100644
--- a/src/ofono.h
+++ b/src/ofono.h
@@ -154,6 +154,7 @@ enum ofono_atom_type {
OFONO_ATOM_TYPE_SIRI,
OFONO_ATOM_TYPE_NETMON,
OFONO_ATOM_TYPE_LTE,
+ OFONO_ATOM_TYPE_IMS,
};
enum ofono_atom_watch_condition {
@@ -534,3 +535,4 @@ ofono_bool_t __ofono_private_network_request(ofono_private_network_cb_t cb,
#include <ofono/netmon.h>
#include <ofono/lte.h>
+#include <ofono/ims.h>
--
1.9.1
^ permalink raw reply related [flat|nested] 9+ messages in thread
* RE: [PATCH 3/6] ims: add implementation for IMS atom
2017-10-04 5:07 Ankit Navik
@ 2017-10-04 5:57 ` Navik, Ankit P
0 siblings, 0 replies; 9+ messages in thread
From: Navik, Ankit P @ 2017-10-04 5:57 UTC (permalink / raw)
To: ofono
[-- Attachment #1: Type: text/plain, Size: 11990 bytes --]
Ignore this patch.
Regards, Ankit
-----Original Message-----
From: Navik, Ankit P
Sent: Wednesday, October 4, 2017 10:37 AM
To: ofono(a)ofono.org
Cc: Navik, Ankit P <ankit.p.navik@intel.com>
Subject: [PATCH 3/6] ims: add implementation for IMS atom
This implementation includes:
* D-Bus interface
* interaction with driver
---
Makefile.am | 2 +-
src/ims.c | 400 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
src/ofono.h | 2 +
3 files changed, 403 insertions(+), 1 deletion(-) create mode 100644 src/ims.c
diff --git a/Makefile.am b/Makefile.am
index 165235e..199de08 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -630,7 +630,7 @@ src_ofonod_SOURCES = $(builtin_sources) $(gatchat_sources) src/ofono.ver \
src/cdma-provision.c src/handsfree.c \
src/handsfree-audio.c src/bluetooth.h \
src/hfp.h src/siri.c \
- src/netmon.c src/lte.c \
+ src/netmon.c src/lte.c src/ims.c \
src/netmonagent.c src/netmonagent.h
src_ofonod_LDADD = gdbus/libgdbus-internal.la $(builtin_libadd) \ diff --git a/src/ims.c b/src/ims.c new file mode 100644 index 0000000..fb90dee
--- /dev/null
+++ b/src/ims.c
@@ -0,0 +1,400 @@
+/*
+ *
+ * oFono - Open Source Telephony
+ *
+ * Copyright (C) 2017 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 <stdint.h>
+#include <stdarg.h>
+#include <errno.h>
+
+#include <glib.h>
+#include <gdbus.h>
+
+#include "ofono.h"
+
+#include "common.h"
+
+#define VOICE_CAPABLE_FLAG 0x1
+#define SMS_CAPABLE_FLAG 0x4
+
+struct ofono_ims {
+ int reg_info;
+ int ext_info;
+ const struct ofono_ims_driver *driver;
+ void *driver_data;
+ struct ofono_atom *atom;
+ DBusMessage *pending;
+};
+
+static GSList *g_drivers = NULL;
+
+static DBusMessage *ims_get_properties(DBusConnection *conn,
+ DBusMessage *msg, void *data)
+{
+ struct ofono_ims *ims = data;
+ 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 = ims->reg_info ? TRUE : FALSE;
+ ofono_dbus_dict_append(&dict, "Registered", DBUS_TYPE_BOOLEAN,
+&value);
+
+ if (ims->ext_info != -1) {
+ value = ims->ext_info & VOICE_CAPABLE_FLAG ? TRUE : FALSE;
+ ofono_dbus_dict_append(&dict, "VoiceCapable",
+ DBUS_TYPE_BOOLEAN, &value);
+
+ value = ims->ext_info & SMS_CAPABLE_FLAG ? TRUE : FALSE;
+ ofono_dbus_dict_append(&dict, "SmsCapable",
+ DBUS_TYPE_BOOLEAN, &value);
+ }
+
+ dbus_message_iter_close_container(&iter, &dict);
+
+ return reply;
+}
+
+static void ims_set_sms_capable(struct ofono_ims *ims, ofono_bool_t
+status) {
+ const char *path = __ofono_atom_get_path(ims->atom);
+ DBusConnection *conn = ofono_dbus_get_connection();
+ dbus_bool_t new_value = status;
+ dbus_bool_t old_value = ims->ext_info & SMS_CAPABLE_FLAG ? TRUE :
+ FALSE;
+
+ if (old_value == new_value)
+ return;
+
+ ofono_dbus_signal_property_changed(conn, path,
+ OFONO_IMS_INTERFACE,
+ "SmsCapable",
+ DBUS_TYPE_BOOLEAN,
+ &new_value);
+}
+
+static void ims_set_voice_capable(struct ofono_ims *ims, ofono_bool_t
+status) {
+ const char *path = __ofono_atom_get_path(ims->atom);
+ DBusConnection *conn = ofono_dbus_get_connection();
+ dbus_bool_t new_value = status;
+ dbus_bool_t old_value = ims->ext_info & VOICE_CAPABLE_FLAG ? TRUE :
+ FALSE;
+
+ if (old_value == new_value)
+ return;
+
+ ofono_dbus_signal_property_changed(conn, path,
+ OFONO_IMS_INTERFACE,
+ "VoiceCapable",
+ DBUS_TYPE_BOOLEAN,
+ &new_value);
+}
+
+static void ims_set_registered(struct ofono_ims *ims, ofono_bool_t
+status) {
+ const char *path = __ofono_atom_get_path(ims->atom);
+ DBusConnection *conn = ofono_dbus_get_connection();
+ dbus_bool_t new_value = status;
+ dbus_bool_t old_value = ims->reg_info ? TRUE : FALSE;
+
+ if (old_value == new_value)
+ return;
+
+ ofono_dbus_signal_property_changed(conn, path,
+ OFONO_IMS_INTERFACE,
+ "Registered",
+ DBUS_TYPE_BOOLEAN,
+ &new_value);
+}
+
+void ofono_ims_status_notify(struct ofono_ims *ims, int reg_info, int
+ext_info) {
+ dbus_bool_t new_reg_info;
+ dbus_bool_t new_voice_capable, new_sms_capable;
+
+ if (ims == NULL)
+ return;
+
+ DBG("%s reg_info:%d ext_info:%d", __ofono_atom_get_path(ims->atom),
+ reg_info, ext_info);
+
+ if (ims->ext_info == ext_info && ims->reg_info == reg_info)
+ return;
+
+ new_reg_info = reg_info ? TRUE : FALSE;
+ ims_set_registered(ims, new_reg_info);
+
+ if (ext_info < 0)
+ goto skip;
+
+ new_voice_capable = ext_info & VOICE_CAPABLE_FLAG ? TRUE : FALSE;
+ ims_set_voice_capable(ims, new_voice_capable);
+
+ new_sms_capable = ext_info & SMS_CAPABLE_FLAG ? TRUE: FALSE;
+ ims_set_sms_capable(ims, new_sms_capable);
+
+skip:
+ ims->reg_info = reg_info;
+ ims->ext_info = ext_info;
+}
+
+static void registration_status_cb(const struct ofono_error *error,
+ int reg_info, int ext_info,
+ void *data)
+{
+ struct ofono_ims *ims = data;
+
+ if (error->type != OFONO_ERROR_TYPE_NO_ERROR) {
+ DBG("Error during IMS registration/unregistration");
+ return;
+ }
+
+ ofono_ims_status_notify(ims, reg_info, ext_info); }
+
+static void register_cb(const struct ofono_error *error, void *data) {
+ struct ofono_ims *ims = data;
+ DBusMessage *reply;
+
+ if (error->type == OFONO_ERROR_TYPE_NO_ERROR)
+ reply = dbus_message_new_method_return(ims->pending);
+ else
+ reply = __ofono_error_failed(ims->pending);
+
+ __ofono_dbus_pending_reply(&ims->pending, reply);
+
+ if (ims->driver->registration_status == NULL)
+ return;
+
+ ims->driver->registration_status(ims, registration_status_cb, ims); }
+
+static DBusMessage *ofono_ims_send_register(DBusConnection *conn,
+ DBusMessage *msg, void *data)
+{
+ struct ofono_ims *ims = data;
+
+ if (ims->pending)
+ return __ofono_error_busy(msg);
+
+ if (ims->driver->ims_register == NULL)
+ return __ofono_error_not_implemented(msg);
+
+ ims->pending = dbus_message_ref(msg);
+
+ ims->driver->ims_register(ims, register_cb, ims);
+
+ return NULL;
+}
+
+static DBusMessage *ofono_ims_unregister(DBusConnection *conn,
+ DBusMessage *msg, void *data)
+{
+ struct ofono_ims *ims = data;
+
+ if (ims->pending)
+ return __ofono_error_busy(msg);
+
+ if (ims->driver->ims_unregister == NULL)
+ return __ofono_error_not_implemented(msg);
+
+ ims->pending = dbus_message_ref(msg);
+
+ ims->driver->ims_unregister(ims, register_cb, ims);
+
+ return NULL;
+}
+
+static const GDBusMethodTable ims_methods[] = {
+ { GDBUS_METHOD("GetProperties",
+ NULL, GDBUS_ARGS({ "properties", "a{sv}" }),
+ ims_get_properties) },
+ { GDBUS_ASYNC_METHOD("Register", NULL, NULL,
+ ofono_ims_send_register) },
+ { GDBUS_ASYNC_METHOD("Unregister", NULL, NULL,
+ ofono_ims_unregister) },
+ { }
+};
+
+static const GDBusSignalTable ims_signals[] = {
+ { GDBUS_SIGNAL("PropertyChanged",
+ GDBUS_ARGS({ "name", "s" }, { "value", "v" })) },
+ { }
+};
+
+static void ims_atom_remove(struct ofono_atom *atom) {
+ struct ofono_ims *ims = __ofono_atom_get_data(atom);
+
+ DBG("atom: %p", atom);
+
+ if (ims == NULL)
+ return;
+
+ if (ims->driver && ims->driver->remove)
+ ims->driver->remove(ims);
+
+ g_free(ims);
+}
+
+struct ofono_ims *ofono_ims_create(struct ofono_modem *modem,
+ const char *driver, void *data)
+{
+ struct ofono_ims *ims;
+ GSList *l;
+
+ if (driver == NULL)
+ return NULL;
+
+ ims = g_try_new0(struct ofono_ims, 1);
+
+ if (ims == NULL)
+ return NULL;
+
+ ims->atom = __ofono_modem_add_atom(modem, OFONO_ATOM_TYPE_IMS,
+ ims_atom_remove, ims);
+
+ for (l = g_drivers; l; l = l->next) {
+ const struct ofono_ims_driver *drv = l->data;
+
+ if (g_strcmp0(drv->name, driver))
+ continue;
+
+ if (drv->probe(ims, data) < 0)
+ continue;
+
+ ims->driver = drv;
+ break;
+ }
+
+ DBG("IMS atom created");
+
+ return ims;
+}
+
+int ofono_ims_driver_register(const struct ofono_ims_driver *d) {
+ DBG("driver: %p, name: %s", d, d->name);
+
+ if (d->probe == NULL)
+ return -EINVAL;
+
+ g_drivers = g_slist_prepend(g_drivers, (void *) d);
+
+ return 0;
+}
+
+void ofono_ims_driver_unregister(const struct ofono_ims_driver *d) {
+ DBG("driver: %p, name: %s", d, d->name);
+
+ g_drivers = g_slist_remove(g_drivers, (void *) d); }
+
+static void ims_atom_unregister(struct ofono_atom *atom) {
+ DBusConnection *conn = ofono_dbus_get_connection();
+ struct ofono_modem *modem = __ofono_atom_get_modem(atom);
+ const char *path = __ofono_atom_get_path(atom);
+
+ ofono_modem_remove_interface(modem, OFONO_IMS_INTERFACE);
+ g_dbus_unregister_interface(conn, path, OFONO_IMS_INTERFACE); }
+
+static void ofono_ims_finish_register(struct ofono_ims *ims) {
+ DBusConnection *conn = ofono_dbus_get_connection();
+ struct ofono_modem *modem = __ofono_atom_get_modem(ims->atom);
+ const char *path = __ofono_atom_get_path(ims->atom);
+
+ if (!g_dbus_register_interface(conn, path,
+ OFONO_IMS_INTERFACE,
+ ims_methods, ims_signals, NULL,
+ ims, NULL)) {
+ ofono_error("could not create %s interface",
+ OFONO_IMS_INTERFACE);
+ return;
+ }
+
+ ofono_modem_add_interface(modem, OFONO_IMS_INTERFACE);
+
+ __ofono_atom_register(ims->atom, ims_atom_unregister); }
+
+static void ims_init_registration_status_cb(const struct ofono_error *error,
+ int reg_info, int ext_info,
+ void *data)
+{
+ struct ofono_ims *ims = data;
+
+ ofono_ims_finish_register(ims);
+}
+
+void ofono_ims_register(struct ofono_ims *ims) {
+ struct ofono_modem *modem = __ofono_atom_get_modem(ims->atom);
+ struct ofono_sim *sim = __ofono_atom_find(OFONO_ATOM_TYPE_SIM, modem);
+ const char *imsi = ofono_sim_get_imsi(sim);
+
+ if (imsi == NULL) {
+ ofono_error("No sim atom required for registering IMS atom.");
+ return;
+ }
+
+ if (ims->driver->registration_status) {
+ ims->driver->registration_status(ims,
+ ims_init_registration_status_cb, ims);
+ return;
+ }
+
+ ofono_ims_finish_register(ims);
+}
+
+void ofono_ims_remove(struct ofono_ims *ims) {
+ __ofono_atom_free(ims->atom);
+}
+
+void ofono_ims_set_data(struct ofono_ims *ims, void *data) {
+ ims->driver_data = data;
+}
+
+void *ofono_ims_get_data(const struct ofono_ims *ims) {
+ return ims->driver_data;
+}
diff --git a/src/ofono.h b/src/ofono.h
index a797b7f..0da11a2 100644
--- a/src/ofono.h
+++ b/src/ofono.h
@@ -154,6 +154,7 @@ enum ofono_atom_type {
OFONO_ATOM_TYPE_SIRI,
OFONO_ATOM_TYPE_NETMON,
OFONO_ATOM_TYPE_LTE,
+ OFONO_ATOM_TYPE_IMS,
};
enum ofono_atom_watch_condition {
@@ -534,3 +535,4 @@ ofono_bool_t __ofono_private_network_request(ofono_private_network_cb_t cb,
#include <ofono/netmon.h>
#include <ofono/lte.h>
+#include <ofono/ims.h>
--
1.9.1
^ permalink raw reply related [flat|nested] 9+ messages in thread
* [PATCH 3/6] ims: add implementation for IMS atom
@ 2017-10-04 5:07 Ankit Navik
2017-10-04 5:57 ` Navik, Ankit P
0 siblings, 1 reply; 9+ messages in thread
From: Ankit Navik @ 2017-10-04 5:07 UTC (permalink / raw)
To: ofono
[-- Attachment #1: Type: text/plain, Size: 11748 bytes --]
This implementation includes:
* D-Bus interface
* interaction with driver
---
Makefile.am | 2 +-
src/ims.c | 400 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
src/ofono.h | 2 +
3 files changed, 403 insertions(+), 1 deletion(-)
create mode 100644 src/ims.c
diff --git a/Makefile.am b/Makefile.am
index 165235e..199de08 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -630,7 +630,7 @@ src_ofonod_SOURCES = $(builtin_sources) $(gatchat_sources) src/ofono.ver \
src/cdma-provision.c src/handsfree.c \
src/handsfree-audio.c src/bluetooth.h \
src/hfp.h src/siri.c \
- src/netmon.c src/lte.c \
+ src/netmon.c src/lte.c src/ims.c \
src/netmonagent.c src/netmonagent.h
src_ofonod_LDADD = gdbus/libgdbus-internal.la $(builtin_libadd) \
diff --git a/src/ims.c b/src/ims.c
new file mode 100644
index 0000000..fb90dee
--- /dev/null
+++ b/src/ims.c
@@ -0,0 +1,400 @@
+/*
+ *
+ * oFono - Open Source Telephony
+ *
+ * Copyright (C) 2017 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 <stdint.h>
+#include <stdarg.h>
+#include <errno.h>
+
+#include <glib.h>
+#include <gdbus.h>
+
+#include "ofono.h"
+
+#include "common.h"
+
+#define VOICE_CAPABLE_FLAG 0x1
+#define SMS_CAPABLE_FLAG 0x4
+
+struct ofono_ims {
+ int reg_info;
+ int ext_info;
+ const struct ofono_ims_driver *driver;
+ void *driver_data;
+ struct ofono_atom *atom;
+ DBusMessage *pending;
+};
+
+static GSList *g_drivers = NULL;
+
+static DBusMessage *ims_get_properties(DBusConnection *conn,
+ DBusMessage *msg, void *data)
+{
+ struct ofono_ims *ims = data;
+ 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 = ims->reg_info ? TRUE : FALSE;
+ ofono_dbus_dict_append(&dict, "Registered", DBUS_TYPE_BOOLEAN, &value);
+
+ if (ims->ext_info != -1) {
+ value = ims->ext_info & VOICE_CAPABLE_FLAG ? TRUE : FALSE;
+ ofono_dbus_dict_append(&dict, "VoiceCapable",
+ DBUS_TYPE_BOOLEAN, &value);
+
+ value = ims->ext_info & SMS_CAPABLE_FLAG ? TRUE : FALSE;
+ ofono_dbus_dict_append(&dict, "SmsCapable",
+ DBUS_TYPE_BOOLEAN, &value);
+ }
+
+ dbus_message_iter_close_container(&iter, &dict);
+
+ return reply;
+}
+
+static void ims_set_sms_capable(struct ofono_ims *ims, ofono_bool_t status)
+{
+ const char *path = __ofono_atom_get_path(ims->atom);
+ DBusConnection *conn = ofono_dbus_get_connection();
+ dbus_bool_t new_value = status;
+ dbus_bool_t old_value = ims->ext_info & SMS_CAPABLE_FLAG ? TRUE :
+ FALSE;
+
+ if (old_value == new_value)
+ return;
+
+ ofono_dbus_signal_property_changed(conn, path,
+ OFONO_IMS_INTERFACE,
+ "SmsCapable",
+ DBUS_TYPE_BOOLEAN,
+ &new_value);
+}
+
+static void ims_set_voice_capable(struct ofono_ims *ims, ofono_bool_t status)
+{
+ const char *path = __ofono_atom_get_path(ims->atom);
+ DBusConnection *conn = ofono_dbus_get_connection();
+ dbus_bool_t new_value = status;
+ dbus_bool_t old_value = ims->ext_info & VOICE_CAPABLE_FLAG ? TRUE :
+ FALSE;
+
+ if (old_value == new_value)
+ return;
+
+ ofono_dbus_signal_property_changed(conn, path,
+ OFONO_IMS_INTERFACE,
+ "VoiceCapable",
+ DBUS_TYPE_BOOLEAN,
+ &new_value);
+}
+
+static void ims_set_registered(struct ofono_ims *ims, ofono_bool_t status)
+{
+ const char *path = __ofono_atom_get_path(ims->atom);
+ DBusConnection *conn = ofono_dbus_get_connection();
+ dbus_bool_t new_value = status;
+ dbus_bool_t old_value = ims->reg_info ? TRUE : FALSE;
+
+ if (old_value == new_value)
+ return;
+
+ ofono_dbus_signal_property_changed(conn, path,
+ OFONO_IMS_INTERFACE,
+ "Registered",
+ DBUS_TYPE_BOOLEAN,
+ &new_value);
+}
+
+void ofono_ims_status_notify(struct ofono_ims *ims, int reg_info, int ext_info)
+{
+ dbus_bool_t new_reg_info;
+ dbus_bool_t new_voice_capable, new_sms_capable;
+
+ if (ims == NULL)
+ return;
+
+ DBG("%s reg_info:%d ext_info:%d", __ofono_atom_get_path(ims->atom),
+ reg_info, ext_info);
+
+ if (ims->ext_info == ext_info && ims->reg_info == reg_info)
+ return;
+
+ new_reg_info = reg_info ? TRUE : FALSE;
+ ims_set_registered(ims, new_reg_info);
+
+ if (ext_info < 0)
+ goto skip;
+
+ new_voice_capable = ext_info & VOICE_CAPABLE_FLAG ? TRUE : FALSE;
+ ims_set_voice_capable(ims, new_voice_capable);
+
+ new_sms_capable = ext_info & SMS_CAPABLE_FLAG ? TRUE: FALSE;
+ ims_set_sms_capable(ims, new_sms_capable);
+
+skip:
+ ims->reg_info = reg_info;
+ ims->ext_info = ext_info;
+}
+
+static void registration_status_cb(const struct ofono_error *error,
+ int reg_info, int ext_info,
+ void *data)
+{
+ struct ofono_ims *ims = data;
+
+ if (error->type != OFONO_ERROR_TYPE_NO_ERROR) {
+ DBG("Error during IMS registration/unregistration");
+ return;
+ }
+
+ ofono_ims_status_notify(ims, reg_info, ext_info);
+}
+
+static void register_cb(const struct ofono_error *error, void *data)
+{
+ struct ofono_ims *ims = data;
+ DBusMessage *reply;
+
+ if (error->type == OFONO_ERROR_TYPE_NO_ERROR)
+ reply = dbus_message_new_method_return(ims->pending);
+ else
+ reply = __ofono_error_failed(ims->pending);
+
+ __ofono_dbus_pending_reply(&ims->pending, reply);
+
+ if (ims->driver->registration_status == NULL)
+ return;
+
+ ims->driver->registration_status(ims, registration_status_cb, ims);
+}
+
+static DBusMessage *ofono_ims_send_register(DBusConnection *conn,
+ DBusMessage *msg, void *data)
+{
+ struct ofono_ims *ims = data;
+
+ if (ims->pending)
+ return __ofono_error_busy(msg);
+
+ if (ims->driver->ims_register == NULL)
+ return __ofono_error_not_implemented(msg);
+
+ ims->pending = dbus_message_ref(msg);
+
+ ims->driver->ims_register(ims, register_cb, ims);
+
+ return NULL;
+}
+
+static DBusMessage *ofono_ims_unregister(DBusConnection *conn,
+ DBusMessage *msg, void *data)
+{
+ struct ofono_ims *ims = data;
+
+ if (ims->pending)
+ return __ofono_error_busy(msg);
+
+ if (ims->driver->ims_unregister == NULL)
+ return __ofono_error_not_implemented(msg);
+
+ ims->pending = dbus_message_ref(msg);
+
+ ims->driver->ims_unregister(ims, register_cb, ims);
+
+ return NULL;
+}
+
+static const GDBusMethodTable ims_methods[] = {
+ { GDBUS_METHOD("GetProperties",
+ NULL, GDBUS_ARGS({ "properties", "a{sv}" }),
+ ims_get_properties) },
+ { GDBUS_ASYNC_METHOD("Register", NULL, NULL,
+ ofono_ims_send_register) },
+ { GDBUS_ASYNC_METHOD("Unregister", NULL, NULL,
+ ofono_ims_unregister) },
+ { }
+};
+
+static const GDBusSignalTable ims_signals[] = {
+ { GDBUS_SIGNAL("PropertyChanged",
+ GDBUS_ARGS({ "name", "s" }, { "value", "v" })) },
+ { }
+};
+
+static void ims_atom_remove(struct ofono_atom *atom)
+{
+ struct ofono_ims *ims = __ofono_atom_get_data(atom);
+
+ DBG("atom: %p", atom);
+
+ if (ims == NULL)
+ return;
+
+ if (ims->driver && ims->driver->remove)
+ ims->driver->remove(ims);
+
+ g_free(ims);
+}
+
+struct ofono_ims *ofono_ims_create(struct ofono_modem *modem,
+ const char *driver, void *data)
+{
+ struct ofono_ims *ims;
+ GSList *l;
+
+ if (driver == NULL)
+ return NULL;
+
+ ims = g_try_new0(struct ofono_ims, 1);
+
+ if (ims == NULL)
+ return NULL;
+
+ ims->atom = __ofono_modem_add_atom(modem, OFONO_ATOM_TYPE_IMS,
+ ims_atom_remove, ims);
+
+ for (l = g_drivers; l; l = l->next) {
+ const struct ofono_ims_driver *drv = l->data;
+
+ if (g_strcmp0(drv->name, driver))
+ continue;
+
+ if (drv->probe(ims, data) < 0)
+ continue;
+
+ ims->driver = drv;
+ break;
+ }
+
+ DBG("IMS atom created");
+
+ return ims;
+}
+
+int ofono_ims_driver_register(const struct ofono_ims_driver *d)
+{
+ DBG("driver: %p, name: %s", d, d->name);
+
+ if (d->probe == NULL)
+ return -EINVAL;
+
+ g_drivers = g_slist_prepend(g_drivers, (void *) d);
+
+ return 0;
+}
+
+void ofono_ims_driver_unregister(const struct ofono_ims_driver *d)
+{
+ DBG("driver: %p, name: %s", d, d->name);
+
+ g_drivers = g_slist_remove(g_drivers, (void *) d);
+}
+
+static void ims_atom_unregister(struct ofono_atom *atom)
+{
+ DBusConnection *conn = ofono_dbus_get_connection();
+ struct ofono_modem *modem = __ofono_atom_get_modem(atom);
+ const char *path = __ofono_atom_get_path(atom);
+
+ ofono_modem_remove_interface(modem, OFONO_IMS_INTERFACE);
+ g_dbus_unregister_interface(conn, path, OFONO_IMS_INTERFACE);
+}
+
+static void ofono_ims_finish_register(struct ofono_ims *ims)
+{
+ DBusConnection *conn = ofono_dbus_get_connection();
+ struct ofono_modem *modem = __ofono_atom_get_modem(ims->atom);
+ const char *path = __ofono_atom_get_path(ims->atom);
+
+ if (!g_dbus_register_interface(conn, path,
+ OFONO_IMS_INTERFACE,
+ ims_methods, ims_signals, NULL,
+ ims, NULL)) {
+ ofono_error("could not create %s interface",
+ OFONO_IMS_INTERFACE);
+ return;
+ }
+
+ ofono_modem_add_interface(modem, OFONO_IMS_INTERFACE);
+
+ __ofono_atom_register(ims->atom, ims_atom_unregister);
+}
+
+static void ims_init_registration_status_cb(const struct ofono_error *error,
+ int reg_info, int ext_info,
+ void *data)
+{
+ struct ofono_ims *ims = data;
+
+ ofono_ims_finish_register(ims);
+}
+
+void ofono_ims_register(struct ofono_ims *ims)
+{
+ struct ofono_modem *modem = __ofono_atom_get_modem(ims->atom);
+ struct ofono_sim *sim = __ofono_atom_find(OFONO_ATOM_TYPE_SIM, modem);
+ const char *imsi = ofono_sim_get_imsi(sim);
+
+ if (imsi == NULL) {
+ ofono_error("No sim atom required for registering IMS atom.");
+ return;
+ }
+
+ if (ims->driver->registration_status) {
+ ims->driver->registration_status(ims,
+ ims_init_registration_status_cb, ims);
+ return;
+ }
+
+ ofono_ims_finish_register(ims);
+}
+
+void ofono_ims_remove(struct ofono_ims *ims)
+{
+ __ofono_atom_free(ims->atom);
+}
+
+void ofono_ims_set_data(struct ofono_ims *ims, void *data)
+{
+ ims->driver_data = data;
+}
+
+void *ofono_ims_get_data(const struct ofono_ims *ims)
+{
+ return ims->driver_data;
+}
diff --git a/src/ofono.h b/src/ofono.h
index a797b7f..0da11a2 100644
--- a/src/ofono.h
+++ b/src/ofono.h
@@ -154,6 +154,7 @@ enum ofono_atom_type {
OFONO_ATOM_TYPE_SIRI,
OFONO_ATOM_TYPE_NETMON,
OFONO_ATOM_TYPE_LTE,
+ OFONO_ATOM_TYPE_IMS,
};
enum ofono_atom_watch_condition {
@@ -534,3 +535,4 @@ ofono_bool_t __ofono_private_network_request(ofono_private_network_cb_t cb,
#include <ofono/netmon.h>
#include <ofono/lte.h>
+#include <ofono/ims.h>
--
1.9.1
^ permalink raw reply related [flat|nested] 9+ messages in thread
end of thread, other threads:[~2017-10-09 16:42 UTC | newest]
Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-10-05 17:15 [PATCH 3/6] ims: add implementation for IMS atom Ankit Navik
2017-10-05 17:15 ` [PATCH 4/6] xmm7modem: Add ims atom driver Ankit Navik
2017-10-09 16:42 ` Denis Kenzior
2017-10-05 17:15 ` [PATCH 5/6] xmm7modem: Add support for ims Ankit Navik
2017-10-09 16:42 ` Denis Kenzior
2017-10-09 16:41 ` [PATCH 3/6] ims: add implementation for IMS atom Denis Kenzior
-- strict thread matches above, loose matches on Subject: below --
2017-10-04 6:03 Ankit Navik
2017-10-04 5:07 Ankit Navik
2017-10-04 5:57 ` Navik, Ankit P
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.