diff options
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/atmodem/at.h | 4 | ||||
-rw-r--r-- | drivers/atmodem/atmodem.c | 5 | ||||
-rw-r--r-- | drivers/atmodem/ussd.c | 61 |
3 files changed, 47 insertions, 23 deletions
diff --git a/drivers/atmodem/at.h b/drivers/atmodem/at.h index 767635af..3b42f616 100644 --- a/drivers/atmodem/at.h +++ b/drivers/atmodem/at.h @@ -74,8 +74,8 @@ extern void at_call_forwarding_exit(); extern void at_call_settings_init(); extern void at_call_settings_exit(); -extern void at_ussd_init(struct ofono_modem *modem); -extern void at_ussd_exit(struct ofono_modem *modem); +extern void at_ussd_init(); +extern void at_ussd_exit(); extern void at_voicecall_init(struct ofono_modem *modem); extern void at_voicecall_exit(struct ofono_modem *modem); diff --git a/drivers/atmodem/atmodem.c b/drivers/atmodem/atmodem.c index 9ff10cce..f5919c23 100644 --- a/drivers/atmodem/atmodem.c +++ b/drivers/atmodem/atmodem.c @@ -103,7 +103,6 @@ static void interface_exit(struct at_data *at) at_sms_exit(at->modem); at_network_registration_exit(at->modem); at_voicecall_exit(at->modem); - at_ussd_exit(at->modem); at_sim_exit(at->modem); } @@ -360,7 +359,7 @@ static void create_cb(GIOChannel *io, gboolean success, gpointer user) ofono_modem_set_userdata(at->modem, at); - at_ussd_init(at->modem); + ofono_ussd_create(at->modem, "generic_at", at->parser); at_sim_init(at->modem); ofono_call_forwarding_create(at->modem, "generic_at", at->parser); ofono_call_settings_create(at->modem, "generic_at", at->parser); @@ -533,6 +532,7 @@ static int atmodem_init(void) at_call_settings_init(); at_phonebook_init(); at_ssn_init(); + at_ussd_init(); manager_init(conn); @@ -545,6 +545,7 @@ static void atmodem_exit(void) manager_exit(conn); + at_ussd_exit(); at_ssn_exit(); at_phonebook_exit(); at_call_settings_exit(); diff --git a/drivers/atmodem/ussd.c b/drivers/atmodem/ussd.c index 02727155..c3793229 100644 --- a/drivers/atmodem/ussd.c +++ b/drivers/atmodem/ussd.c @@ -32,7 +32,7 @@ #include <ofono/log.h> #include <ofono/modem.h> -#include "driver.h" +#include <ofono/ussd.h> #include "util.h" #include "gatchat.h" @@ -45,7 +45,7 @@ static const char *none_prefix[] = { NULL }; static void cusd_request_cb(gboolean ok, GAtResult *result, gpointer user_data) { struct cb_data *cbd = user_data; - ofono_generic_cb_t cb = cbd->cb; + ofono_ussd_cb_t cb = cbd->cb; struct ofono_error error; dump_response("cusd_request_cb", ok, result); @@ -54,11 +54,11 @@ static void cusd_request_cb(gboolean ok, GAtResult *result, gpointer user_data) cb(&error, cbd->data); } -static void at_ussd_request(struct ofono_modem *modem, const char *str, - ofono_generic_cb_t cb, void *data) +static void at_ussd_request(struct ofono_ussd *ussd, const char *str, + ofono_ussd_cb_t cb, void *data) { - struct at_data *at = ofono_modem_get_userdata(modem); - struct cb_data *cbd = cb_data_new(modem, cb, data); + GAtChat *chat = ofono_ussd_get_data(ussd); + struct cb_data *cbd = cb_data_new(NULL, cb, data); unsigned char *converted; int dcs; int max_len; @@ -85,7 +85,7 @@ static void at_ussd_request(struct ofono_modem *modem, const char *str, sprintf(buf, "AT+CUSD=1,\"%s\",%d", converted, dcs); - if (g_at_chat_send(at->parser, buf, none_prefix, + if (g_at_chat_send(chat, buf, none_prefix, cusd_request_cb, cbd, g_free) > 0) return; @@ -102,7 +102,7 @@ error: static void cusd_cancel_cb(gboolean ok, GAtResult *result, gpointer user_data) { struct cb_data *cbd = user_data; - ofono_generic_cb_t cb = cbd->cb; + ofono_ussd_cb_t cb = cbd->cb; struct ofono_error error; dump_response("cusd_cancel_cb", ok, result); @@ -111,16 +111,16 @@ static void cusd_cancel_cb(gboolean ok, GAtResult *result, gpointer user_data) cb(&error, cbd->data); } -static void at_ussd_cancel(struct ofono_modem *modem, - ofono_generic_cb_t cb, void *data) +static void at_ussd_cancel(struct ofono_ussd *ussd, + ofono_ussd_cb_t cb, void *data) { - struct at_data *at = ofono_modem_get_userdata(modem); - struct cb_data *cbd = cb_data_new(modem, cb, data); + GAtChat *chat = ofono_ussd_get_data(ussd); + struct cb_data *cbd = cb_data_new(NULL, cb, data); if (!cbd) goto error; - if (g_at_chat_send(at->parser, "AT+CUSD=2", none_prefix, + if (g_at_chat_send(chat, "AT+CUSD=2", none_prefix, cusd_cancel_cb, cbd, g_free) > 0) return; @@ -134,18 +134,41 @@ error: } } -static struct ofono_ussd_ops ops = { +static gboolean at_ussd_register(gpointer user) +{ + struct ofono_ussd *ussd = user; + + ofono_ussd_register(ussd); + + return FALSE; +} + +static int at_ussd_probe(struct ofono_ussd *ussd) +{ + g_idle_add(at_ussd_register, ussd); + + return 0; +} + +static int at_ussd_remove(struct ofono_ussd *ussd) +{ + return 0; +} + +static struct ofono_ussd_driver driver = { + .name = "generic_at", + .probe = at_ussd_probe, + .remove = at_ussd_remove, .request = at_ussd_request, .cancel = at_ussd_cancel }; -void at_ussd_init(struct ofono_modem *modem) +void at_ussd_init() { - /* TODO: Register for USSD Notifications */ - ofono_ussd_register(modem, &ops); + ofono_ussd_driver_register(&driver); } -void at_ussd_exit(struct ofono_modem *modem) +void at_ussd_exit() { - ofono_ussd_unregister(modem); + ofono_ussd_driver_unregister(&driver); } |