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
--- /dev/null
+/*
+ *
+ * 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 */
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
#include "driver.h"
#include "common.h"
-#include "cssn.h"
#include "ussd.h"
#define CALL_BARRING_FLAG_CACHED 0x1
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;
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;
}
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,
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);
}
+++ /dev/null
-/*
- *
- * 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);
- }
-}
+++ /dev/null
-/*
- *
- * 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);
#include "driver.h"
#include "common.h"
-#include "cssn.h"
#include "sim.h"
#define MODEM_FLAG_INITIALIZING_ATTRS 1
}
ofono_sim_manager_init(modem);
- ofono_cssn_init(modem);
modem->modem_info->flags |= MODEM_FLAG_INITIALIZING_ATTRS;
g_timeout_add(0, query_manufacturer, 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);
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 {
#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);
--- /dev/null
+/*
+ *
+ * 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;
+}
#include "driver.h"
#include "common.h"
-#include "cssn.h"
#define VOICECALL_MANAGER_INTERFACE "org.ofono.VoiceCallManager"
#define VOICECALL_INTERFACE "org.ofono.VoiceCall"