3
* oFono - Open Source Telephony
5
* Copyright (C) 2008-2009 Intel Corporation. All rights reserved.
7
* This program is free software; you can redistribute it and/or modify
8
* it under the terms of the GNU General Public License version 2 as
9
* published by the Free Software Foundation.
11
* This program is distributed in the hope that it will be useful,
12
* but WITHOUT ANY WARRANTY; without even the implied warranty of
13
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
* GNU General Public License for more details.
16
* You should have received a copy of the GNU General Public License
17
* along with this program; if not, write to the Free Software
18
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
38
GSList *mo_handler_list;
39
GSList *mt_handler_list;
54
static gint ss_handler_compare(gconstpointer a, gconstpointer b)
56
return memcmp(a, b, sizeof(struct mo_handler));
59
void ofono_mo_ss_register(struct ofono_modem *modem, enum ss_cssi code1,
60
mo_ss_notify_cb cb, void *userdata)
62
struct cssn_data *ss = modem->cssn;
63
struct mo_handler *handler = g_try_new0(struct mo_handler, 1);
65
handler->code1 = code1;
67
handler->cb_data = userdata;
69
ss->mo_handler_list = g_slist_prepend(ss->mo_handler_list, handler);
72
void ofono_mo_ss_unregister(struct ofono_modem *modem, enum ss_cssi code1,
73
mo_ss_notify_cb cb, void *userdata)
75
struct cssn_data *ss = modem->cssn;
76
struct mo_handler val = { code1, cb, userdata };
77
GSList *l = g_slist_find_custom(ss->mo_handler_list, &val,
81
ofono_error("An unregistered handler passed to "
82
"ofono_mo_ss_unregister");
87
ss->mo_handler_list = g_slist_delete_link(ss->mo_handler_list, l);
90
void ofono_mt_ss_register(struct ofono_modem *modem, enum ss_cssu code2,
91
mt_ss_notify_cb cb, void *userdata)
93
struct cssn_data *ss = modem->cssn;
94
struct mt_handler *handler = g_try_new0(struct mt_handler, 1);
96
handler->code2 = code2;
98
handler->cb_data = userdata;
100
ss->mt_handler_list = g_slist_prepend(ss->mt_handler_list, handler);
103
void ofono_mt_ss_unregister(struct ofono_modem *modem, enum ss_cssu code2,
104
mt_ss_notify_cb cb, void *userdata)
106
struct cssn_data *ss = modem->cssn;
107
struct mt_handler val = { code2, cb, userdata };
108
GSList *l = g_slist_find_custom(ss->mt_handler_list, &val,
112
ofono_error("An unregistered handler passed to "
113
"ofono_mt_ss_unregister");
118
ss->mt_handler_list = g_slist_delete_link(ss->mt_handler_list, l);
121
void ofono_cssn_init(struct ofono_modem *modem)
123
struct cssn_data *ss = g_try_new0(struct cssn_data, 1);
128
static void cssn_free_handlers(GSList *l)
132
for (iter = l; iter; iter = iter->next)
137
void ofono_cssn_exit(struct ofono_modem *modem)
142
cssn_free_handlers(modem->cssn->mo_handler_list);
143
cssn_free_handlers(modem->cssn->mt_handler_list);
149
void ofono_cssi_notify(struct ofono_modem *modem, int code1, int index)
151
struct cssn_data *ss = modem->cssn;
152
struct mo_handler *h;
155
for (l = ss->mo_handler_list; l; l = l->next) {
157
if (h->code1 == (enum ss_cssi) code1)
158
h->cb(index, h->cb_data);
162
void ofono_cssu_notify(struct ofono_modem *modem, int code2, int index,
163
const struct ofono_phone_number *ph)
165
struct cssn_data *ss = modem->cssn;
166
struct mt_handler *h;
169
for (l = ss->mt_handler_list; l; l = l->next) {
171
if (h->code2 == (enum ss_cssu) code2)
172
h->cb(index, ph, h->cb_data);