summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDenis Kenzior <denkenz@gmail.com>2009-08-14 18:49:01 -0500
committerDenis Kenzior <denkenz@gmail.com>2009-08-14 18:49:01 -0500
commit314c0facc3a64483c18c20bae8b42b275a6476d7 (patch)
treebb0673359587a46251d43da93842b0801d3e66fa
parent6482d98e56852f6b80abf6fc89e3b14a7c3da2f0 (diff)
downloadofono-314c0facc3a64483c18c20bae8b42b275a6476d7.tar.bz2
Refactor cssn into ofono_ssn
Make this into a fully fledged entity, with a driver instead of the current kludge. This means modem drivers can actually choose whether to instantiate a CSSN atom or not Move the notification functions from voicecall.c into ssn.c. Move the cssn.h header into include/ssn.h and refactor Update call barring to utilize ofono_ssn and use the new atom_watch functionality to detect when ssn has been added or removed
-rw-r--r--include/Makefile.am3
-rw-r--r--include/ssn.h60
-rw-r--r--src/Makefile.am2
-rw-r--r--src/call-barring.c47
-rw-r--r--src/cssn.c174
-rw-r--r--src/cssn.h35
-rw-r--r--src/modem.c3
-rw-r--r--src/ofono.h20
-rw-r--r--src/ssn.c303
-rw-r--r--src/voicecall.c1
10 files changed, 423 insertions, 225 deletions
diff --git a/include/Makefile.am b/include/Makefile.am
index 9ea2af41..22244228 100644
--- a/include/Makefile.am
+++ b/include/Makefile.am
@@ -3,7 +3,8 @@ includedir = @includedir@/ofono
include_HEADERS = log.h plugin.h history.h dbus.h modem.h \
types.h call-barring.h call-forwarding.h \
- call-meter.h call-settings.h phonebook.h
+ call-meter.h call-settings.h phonebook.h \
+ ssn.h
nodist_include_HEADERS = version.h
diff --git a/include/ssn.h b/include/ssn.h
new file mode 100644
index 00000000..e808bec3
--- /dev/null
+++ b/include/ssn.h
@@ -0,0 +1,60 @@
+/*
+ *
+ * oFono - Open Source Telephony
+ *
+ * Copyright (C) 2008-2009 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_SSN_H
+#define __OFONO_SSN_H
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#include <ofono/types.h>
+
+struct ofono_ssn;
+
+struct ofono_ssn_driver {
+ const char *name;
+ int (*probe)(struct ofono_ssn *ssn);
+ int (*remove)(struct ofono_ssn *ssn);
+};
+
+/* SSN notifications (CSSI and CSSU). */
+void ofono_ssn_cssi_notify(struct ofono_ssn *ssn, int code, int index);
+void ofono_ssn_cssu_notify(struct ofono_ssn *ssn, int code, int index,
+ const struct ofono_phone_number *number);
+
+int ofono_ssn_driver_register(const struct ofono_ssn_driver *d);
+void ofono_ssn_driver_unregister(const struct ofono_ssn_driver *d);
+
+struct ofono_ssn *ofono_ssn_create(struct ofono_modem *modem,
+ const char *driver, void *data);
+
+void ofono_ssn_register(struct ofono_ssn *ssn);
+void ofono_ssn_remove(struct ofono_ssn *ssn);
+
+void ofono_ssn_set_data(struct ofono_ssn *ssn, void *data);
+void *ofono_ssn_get_data(struct ofono_ssn *ssn);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* __OFONO_SSN_H */
diff --git a/src/Makefile.am b/src/Makefile.am
index f17e926e..334e9303 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -12,7 +12,7 @@ ofonod_SOURCES = main.c ofono.h log.c plugin.c \
manager.c dbus.c util.h util.c \
network.c voicecall.c ussd.h ussd.c sms.c \
call-settings.c call-forwarding.c call-meter.c \
- smsutil.h smsutil.c cssn.h cssn.c call-barring.c sim.h sim.c \
+ smsutil.h smsutil.c ssn.c call-barring.c sim.h sim.c \
phonebook.c history.c simutil.h simutil.c \
message-waiting.c
diff --git a/src/call-barring.c b/src/call-barring.c
index 65873b32..47f1c845 100644
--- a/src/call-barring.c
+++ b/src/call-barring.c
@@ -36,7 +36,6 @@
#include "driver.h"
#include "common.h"
-#include "cssn.h"
#include "ussd.h"
#define CALL_BARRING_FLAG_CACHED 0x1
@@ -58,6 +57,9 @@ struct ofono_call_barring {
int ss_req_type;
int ss_req_cls;
int ss_req_lock;
+ struct ofono_ssn *ssn;
+ unsigned int incoming_bar_watch;
+ unsigned int outgoing_bar_watch;
const struct ofono_call_barring_driver *driver;
void *driver_data;
struct ofono_atom *atom;
@@ -1064,10 +1066,10 @@ static void call_barring_unregister(struct ofono_atom *atom)
cb_unregister_ss_controls(cb);
- ofono_mo_ss_unregister(modem, SS_MO_INCOMING_BARRING,
- call_barring_incoming_enabled_notify, cb);
- ofono_mo_ss_unregister(modem, SS_MO_OUTGOING_BARRING,
- call_barring_outgoing_enabled_notify, cb);
+ if (cb->incoming_bar_watch)
+ __ofono_ssn_mo_watch_remove(cb->ssn, cb->incoming_bar_watch);
+ if (cb->outgoing_bar_watch)
+ __ofono_ssn_mt_watch_remove(cb->ssn, cb->outgoing_bar_watch);
modem->call_barring = NULL;
}
@@ -1129,11 +1131,35 @@ struct ofono_call_barring *ofono_call_barring_create(struct ofono_modem *modem,
return cb;
}
+static void ssn_watch(struct ofono_atom *atom,
+ enum ofono_atom_watch_condition cond, void *data)
+{
+ struct ofono_call_barring *cb = data;
+
+ if (cond == OFONO_ATOM_WATCH_CONDITION_UNREGISTERED) {
+ cb->ssn = NULL;
+ cb->incoming_bar_watch = 0;
+ cb->outgoing_bar_watch = 0;
+ return;
+ }
+
+ cb->ssn = __ofono_atom_get_data(atom);
+
+ cb->incoming_bar_watch =
+ __ofono_ssn_mo_watch_add(cb->ssn, SS_MO_INCOMING_BARRING,
+ call_barring_incoming_enabled_notify, cb, NULL);
+
+ cb->outgoing_bar_watch =
+ __ofono_ssn_mo_watch_add(cb->ssn, SS_MO_OUTGOING_BARRING,
+ call_barring_outgoing_enabled_notify, cb, NULL);
+}
+
void ofono_call_barring_register(struct ofono_call_barring *cb)
{
DBusConnection *conn = ofono_dbus_get_connection();
const char *path = __ofono_atom_get_path(cb->atom);
struct ofono_modem *modem = __ofono_atom_get_modem(cb->atom);
+ struct ofono_atom *ssn_atom;
if (!g_dbus_register_interface(conn, path,
OFONO_CALL_BARRING_INTERFACE,
@@ -1148,12 +1174,15 @@ void ofono_call_barring_register(struct ofono_call_barring *cb)
modem->call_barring = cb;
ofono_modem_add_interface(modem, OFONO_CALL_BARRING_INTERFACE);
+
cb_register_ss_controls(cb);
- ofono_mo_ss_register(modem, SS_MO_INCOMING_BARRING,
- call_barring_incoming_enabled_notify, cb);
- ofono_mo_ss_register(modem, SS_MO_OUTGOING_BARRING,
- call_barring_outgoing_enabled_notify, cb);
+ __ofono_modem_add_atom_watch(modem, OFONO_ATOM_TYPE_SSN,
+ ssn_watch, cb, NULL);
+ ssn_atom = __ofono_modem_find_atom(modem, OFONO_ATOM_TYPE_SSN);
+
+ if (ssn_atom && __ofono_atom_get_registered(ssn_atom))
+ ssn_watch(ssn_atom, OFONO_ATOM_WATCH_CONDITION_REGISTERED, cb);
__ofono_atom_register(cb->atom, call_barring_unregister);
}
diff --git a/src/cssn.c b/src/cssn.c
deleted file mode 100644
index 1e5e3353..00000000
--- a/src/cssn.c
+++ /dev/null
@@ -1,174 +0,0 @@
-/*
- *
- * oFono - Open Source Telephony
- *
- * Copyright (C) 2008-2009 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 <glib.h>
-
-#include "ofono.h"
-
-#include "driver.h"
-#include "common.h"
-#include "cssn.h"
-
-struct cssn_data {
- GSList *mo_handler_list;
- GSList *mt_handler_list;
-};
-
-struct mo_handler {
- enum ss_cssi code1;
- mo_ss_notify_cb cb;
- void *cb_data;
-};
-
-struct mt_handler {
- enum ss_cssu code2;
- mt_ss_notify_cb cb;
- void *cb_data;
-};
-
-static gint ss_handler_compare(gconstpointer a, gconstpointer b)
-{
- return memcmp(a, b, sizeof(struct mo_handler));
-}
-
-void ofono_mo_ss_register(struct ofono_modem *modem, enum ss_cssi code1,
- mo_ss_notify_cb cb, void *userdata)
-{
- struct cssn_data *ss = modem->cssn;
- struct mo_handler *handler = g_try_new0(struct mo_handler, 1);
-
- handler->code1 = code1;
- handler->cb = cb;
- handler->cb_data = userdata;
-
- ss->mo_handler_list = g_slist_prepend(ss->mo_handler_list, handler);
-}
-
-void ofono_mo_ss_unregister(struct ofono_modem *modem, enum ss_cssi code1,
- mo_ss_notify_cb cb, void *userdata)
-{
- struct cssn_data *ss = modem->cssn;
- struct mo_handler val = { code1, cb, userdata };
- GSList *l = g_slist_find_custom(ss->mo_handler_list, &val,
- ss_handler_compare);
-
- if (!l) {
- ofono_error("An unregistered handler passed to "
- "ofono_mo_ss_unregister");
- return;
- }
-
- g_free(l->data);
- ss->mo_handler_list = g_slist_delete_link(ss->mo_handler_list, l);
-}
-
-void ofono_mt_ss_register(struct ofono_modem *modem, enum ss_cssu code2,
- mt_ss_notify_cb cb, void *userdata)
-{
- struct cssn_data *ss = modem->cssn;
- struct mt_handler *handler = g_try_new0(struct mt_handler, 1);
-
- handler->code2 = code2;
- handler->cb = cb;
- handler->cb_data = userdata;
-
- ss->mt_handler_list = g_slist_prepend(ss->mt_handler_list, handler);
-}
-
-void ofono_mt_ss_unregister(struct ofono_modem *modem, enum ss_cssu code2,
- mt_ss_notify_cb cb, void *userdata)
-{
- struct cssn_data *ss = modem->cssn;
- struct mt_handler val = { code2, cb, userdata };
- GSList *l = g_slist_find_custom(ss->mt_handler_list, &val,
- ss_handler_compare);
-
- if (!l) {
- ofono_error("An unregistered handler passed to "
- "ofono_mt_ss_unregister");
- return;
- }
-
- g_free(l->data);
- ss->mt_handler_list = g_slist_delete_link(ss->mt_handler_list, l);
-}
-
-void ofono_cssn_init(struct ofono_modem *modem)
-{
- struct cssn_data *ss = g_try_new0(struct cssn_data, 1);
-
- modem->cssn = ss;
-}
-
-static void cssn_free_handlers(GSList *l)
-{
- GSList *iter;
-
- for (iter = l; iter; iter = iter->next)
- g_free(iter->data);
- g_slist_free(l);
-}
-
-void ofono_cssn_exit(struct ofono_modem *modem)
-{
- if (!modem->cssn)
- return;
-
- cssn_free_handlers(modem->cssn->mo_handler_list);
- cssn_free_handlers(modem->cssn->mt_handler_list);
- g_free(modem->cssn);
-
- modem->cssn = NULL;
-}
-
-void ofono_cssi_notify(struct ofono_modem *modem, int code1, int index)
-{
- struct cssn_data *ss = modem->cssn;
- struct mo_handler *h;
- GSList *l;
-
- for (l = ss->mo_handler_list; l; l = l->next) {
- h = l->data;
- if (h->code1 == (enum ss_cssi) code1)
- h->cb(index, h->cb_data);
- }
-}
-
-void ofono_cssu_notify(struct ofono_modem *modem, int code2, int index,
- const struct ofono_phone_number *ph)
-{
- struct cssn_data *ss = modem->cssn;
- struct mt_handler *h;
- GSList *l;
-
- for (l = ss->mt_handler_list; l; l = l->next) {
- h = l->data;
- if (h->code2 == (enum ss_cssu) code2)
- h->cb(index, ph, h->cb_data);
- }
-}
diff --git a/src/cssn.h b/src/cssn.h
deleted file mode 100644
index 2f45c303..00000000
--- a/src/cssn.h
+++ /dev/null
@@ -1,35 +0,0 @@
-/*
- *
- * oFono - Open Source Telephony
- *
- * Copyright (C) 2008-2009 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
- *
- */
-
-typedef void (*mo_ss_notify_cb)(int index, void *userdata);
-typedef void (*mt_ss_notify_cb)(int index, const struct ofono_phone_number *ph,
- void *userdata);
-
-void ofono_cssn_init(struct ofono_modem *modem);
-void ofono_cssn_exit(struct ofono_modem *modem);
-void ofono_mo_ss_register(struct ofono_modem *modem, enum ss_cssi code1,
- mo_ss_notify_cb cb, void *userdata);
-void ofono_mo_ss_unregister(struct ofono_modem *modem, enum ss_cssi code1,
- mo_ss_notify_cb cb, void *userdata);
-void ofono_mt_ss_register(struct ofono_modem *modem, enum ss_cssu code2,
- mt_ss_notify_cb cb, void *userdata);
-void ofono_mt_ss_unregister(struct ofono_modem *modem, enum ss_cssu code2,
- mt_ss_notify_cb cb, void *userdata);
diff --git a/src/modem.c b/src/modem.c
index 157f8d87..22a614fe 100644
--- a/src/modem.c
+++ b/src/modem.c
@@ -33,7 +33,6 @@
#include "driver.h"
#include "common.h"
-#include "cssn.h"
#include "sim.h"
#define MODEM_FLAG_INITIALIZING_ATTRS 1
@@ -639,7 +638,6 @@ static struct ofono_modem *modem_create(int id,
}
ofono_sim_manager_init(modem);
- ofono_cssn_init(modem);
modem->modem_info->flags |= MODEM_FLAG_INITIALIZING_ATTRS;
g_timeout_add(0, query_manufacturer, modem);
@@ -658,7 +656,6 @@ static void modem_remove(struct ofono_modem *modem)
remove_all_atoms(modem);
remove_all_watches(modem);
- ofono_cssn_exit(modem);
ofono_sim_manager_exit(modem);
g_dbus_unregister_interface(conn, path, OFONO_MODEM_INTERFACE);
diff --git a/src/ofono.h b/src/ofono.h
index 03b5da73..10d94434 100644
--- a/src/ofono.h
+++ b/src/ofono.h
@@ -108,7 +108,8 @@ enum ofono_atom_type {
OFONO_ATOM_TYPE_SIM = 8,
OFONO_ATOM_TYPE_USSD = 9,
OFONO_ATOM_TYPE_VOICECALL = 10,
- OFONO_ATOM_TYPE_HISTORY = 11
+ OFONO_ATOM_TYPE_HISTORY = 11,
+ OFONO_ATOM_TYPE_SSN = 12,
};
enum ofono_atom_watch_condition {
@@ -152,6 +153,23 @@ void __ofono_atom_free(struct ofono_atom *atom);
#include <ofono/call-settings.h>
#include <ofono/phonebook.h>
+#include <ofono/ssn.h>
+
+typedef void (*ofono_ssn_mo_notify_cb)(int index, void *user);
+typedef void (*ofono_ssn_mt_notify_cb)(int index,
+ const struct ofono_phone_number *ph,
+ void *user);
+
+unsigned int __ofono_ssn_mo_watch_add(struct ofono_ssn *ssn, int code1,
+ ofono_ssn_mo_notify_cb cb, void *user,
+ ofono_destroy_func destroy);
+gboolean __ofono_ssn_mo_watch_remove(struct ofono_ssn *ssn, int id);
+
+unsigned int __ofono_ssn_mt_watch_add(struct ofono_ssn *ssn, int code2,
+ ofono_ssn_mt_notify_cb cb, void *user,
+ ofono_destroy_func destroy);
+gboolean __ofono_ssn_mt_watch_remove(struct ofono_ssn *ssn, int id);
+
#include <ofono/history.h>
void __ofono_history_probe_drivers(struct ofono_modem *modem);
diff --git a/src/ssn.c b/src/ssn.c
new file mode 100644
index 00000000..2bc047d3
--- /dev/null
+++ b/src/ssn.c
@@ -0,0 +1,303 @@
+/*
+ *
+ * oFono - Open Source Telephony
+ *
+ * Copyright (C) 2008-2009 Intel Corporation. All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+ *
+ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include <string.h>
+#include <stdio.h>
+#include <errno.h>
+
+#include <glib.h>
+
+#include "ofono.h"
+
+#include "common.h"
+
+static GSList *g_drivers = NULL;
+
+struct ssn_handler {
+ unsigned int id;
+ int code;
+ void *notify;
+ void *data;
+ ofono_destroy_func destroy;
+};
+
+struct ofono_ssn {
+ GSList *mo_handler_list;
+ GSList *mt_handler_list;
+ unsigned int next_id;
+ const struct ofono_ssn_driver *driver;
+ void *driver_data;
+ struct ofono_atom *atom;
+};
+
+static unsigned int add_ssn_handler(GSList **l, unsigned int *id,
+ int code, void *notify, void *data,
+ ofono_destroy_func destroy)
+{
+ struct ssn_handler *handler;
+
+ if (notify == NULL)
+ return 0;
+
+ handler = g_new0(struct ssn_handler, 1);
+
+ handler->code = code;
+ handler->id = *id;
+ *id = *id + 1;
+ handler->notify = notify;
+ handler->destroy = destroy;
+ handler->data = data;
+
+ *l = g_slist_prepend(*l, handler);
+
+ return handler->id;
+}
+
+static gboolean remove_ssn_handler_by_id(GSList **l, unsigned int id)
+{
+ struct ssn_handler *handler;
+ GSList *p;
+ GSList *c;
+
+ p = NULL;
+ c = *l;
+
+ while (c) {
+ handler = c->data;
+
+ if (handler->id != id) {
+ p = c;
+ c = c->next;
+ continue;
+ }
+
+ if (p)
+ p->next = c->next;
+ else
+ *l = c->next;
+
+ if (handler->destroy)
+ handler->destroy(handler->data);
+
+ g_free(handler);
+ g_slist_free_1(c);
+
+ return TRUE;
+ }
+
+ return FALSE;
+}
+
+static void remove_all_handlers(GSList **l)
+{
+ struct ssn_handler *handler;
+ GSList *c;
+
+ for (c = *l; c; c = c->next) {
+ handler = c->data;
+
+ if (handler->destroy)
+ handler->destroy(handler->data);
+
+ g_free(handler);
+ }
+
+ g_slist_free(*l);
+ *l = NULL;
+}
+
+unsigned int __ofono_ssn_mo_watch_add(struct ofono_ssn *ssn, int code1,
+ ofono_ssn_mo_notify_cb cb, void *user,
+ ofono_destroy_func destroy)
+{
+ if (ssn == NULL)
+ return 0;
+
+ DBG("%p, %d", ssn, code1);
+
+ return add_ssn_handler(&ssn->mo_handler_list, &ssn->next_id,
+ code1, cb, user, destroy);
+}
+
+gboolean __ofono_ssn_mo_watch_remove(struct ofono_ssn *ssn, int id)
+{
+ if (ssn == NULL)
+ return FALSE;
+
+ DBG("%p, %u", ssn, id);
+
+ return remove_ssn_handler_by_id(&ssn->mo_handler_list, id);
+}
+
+unsigned int __ofono_ssn_mt_watch_add(struct ofono_ssn *ssn, int code2,
+ ofono_ssn_mt_notify_cb cb, void *user,
+ ofono_destroy_func destroy)
+{
+ if (ssn == NULL)
+ return 0;
+
+ DBG("%p, %d", ssn, code2);
+
+ return add_ssn_handler(&ssn->mt_handler_list, &ssn->next_id,
+ code2, cb, user, destroy);
+}
+
+gboolean __ofono_ssn_mt_watch_remove(struct ofono_ssn *ssn, int id)
+{
+ if (ssn == NULL)
+ return FALSE;
+
+ DBG("%p, %u", ssn, id);
+
+ return remove_ssn_handler_by_id(&ssn->mt_handler_list, id);
+}
+
+void ofono_ssn_cssi_notify(struct ofono_ssn *ssn, int code1, int index)
+{
+ struct ssn_handler *h;
+ GSList *l;
+ ofono_ssn_mo_notify_cb notify;
+
+ for (l = ssn->mo_handler_list; l; l = l->next) {
+ h = l->data;
+ notify = h->notify;
+
+ if (h->code == code1)
+ notify(index, h->data);
+ }
+}
+
+void ofono_ssn_cssu_notify(struct ofono_ssn *ssn, int code2, int index,
+ const struct ofono_phone_number *ph)
+{
+ struct ssn_handler *h;
+ GSList *l;
+ ofono_ssn_mt_notify_cb notify;
+
+ for (l = ssn->mt_handler_list; l; l = l->next) {
+ h = l->data;
+ notify = h->notify;
+
+ if (h->code == code2)
+ notify(index, ph, h->data);
+ }
+}
+
+int ofono_ssn_driver_register(const struct ofono_ssn_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_ssn_driver_unregister(const struct ofono_ssn_driver *d)
+{
+ DBG("driver: %p, name: %s", d, d->name);
+
+ g_drivers = g_slist_remove(g_drivers, (void *)d);
+}
+
+static void ssn_unregister(struct ofono_atom *atom)
+{
+ struct ofono_ssn *ssn = __ofono_atom_get_data(atom);
+
+ remove_all_handlers(&ssn->mo_handler_list);
+ remove_all_handlers(&ssn->mt_handler_list);
+}
+
+static void ssn_remove(struct ofono_atom *atom)
+{
+ struct ofono_ssn *ssn = __ofono_atom_get_data(atom);
+
+ DBG("atom: %p", atom);
+
+ if (ssn == NULL)
+ return;
+
+ if (ssn->driver && ssn->driver->remove)
+ ssn->driver->remove(ssn);
+
+ g_free(ssn);
+}
+
+struct ofono_ssn *ofono_ssn_create(struct ofono_modem *modem,
+ const char *driver,
+ void *data)
+{
+ struct ofono_ssn *ssn;
+ GSList *l;
+
+ if (driver == NULL)
+ return NULL;
+
+ ssn = g_try_new0(struct ofono_ssn, 1);
+
+ if (ssn == NULL)
+ return NULL;
+
+ ssn->driver_data = data;
+ ssn->atom = __ofono_modem_add_atom(modem, OFONO_ATOM_TYPE_SSN,
+ ssn_remove, ssn);
+
+ for (l = g_drivers; l; l = l->next) {
+ const struct ofono_ssn_driver *drv = l->data;
+
+ if (g_strcmp0(drv->name, driver))
+ continue;
+
+ if (drv->probe(ssn) < 0)
+ continue;
+
+ ssn->driver = drv;
+ break;
+ }
+
+ return ssn;
+}
+
+void ofono_ssn_register(struct ofono_ssn *ssn)
+{
+ __ofono_atom_register(ssn->atom, ssn_unregister);
+}
+
+void ofono_ssn_remove(struct ofono_ssn *ssn)
+{
+ __ofono_atom_free(ssn->atom);
+}
+
+void ofono_ssn_set_data(struct ofono_ssn *ssn, void *data)
+{
+ ssn->driver_data = data;
+}
+
+void *ofono_ssn_get_data(struct ofono_ssn *ssn)
+{
+ return ssn->driver_data;
+}
diff --git a/src/voicecall.c b/src/voicecall.c
index 61806617..8bcc8cdc 100644
--- a/src/voicecall.c
+++ b/src/voicecall.c
@@ -34,7 +34,6 @@
#include "driver.h"
#include "common.h"
-#include "cssn.h"
#define VOICECALL_MANAGER_INTERFACE "org.ofono.VoiceCallManager"
#define VOICECALL_INTERFACE "org.ofono.VoiceCall"