From 74782318bd2c7dd91a782aae72bd996c74de92e9 Mon Sep 17 00:00:00 2001 From: Aki Niemi Date: Tue, 25 Aug 2009 14:04:42 +0300 Subject: Rename all files under drivers/isimodem/ --- Makefile.am | 24 +- drivers/isimodem/call-barring.c | 114 +++++++++ drivers/isimodem/call-forwarding.c | 130 ++++++++++ drivers/isimodem/call-meter.c | 140 +++++++++++ drivers/isimodem/call-settings.c | 136 ++++++++++ drivers/isimodem/devinfo.c | 426 +++++++++++++++++++++++++++++++ drivers/isimodem/isicall-barring.c | 114 --------- drivers/isimodem/isicall-forwarding.c | 130 ---------- drivers/isimodem/isicall-meter.c | 140 ----------- drivers/isimodem/isicall-settings.c | 136 ---------- drivers/isimodem/isidevinfo.c | 426 ------------------------------- drivers/isimodem/isinetwork.c | 235 ----------------- drivers/isimodem/isiphonebook.c | 432 -------------------------------- drivers/isimodem/isisim.c | 150 ----------- drivers/isimodem/isisms.c | 114 --------- drivers/isimodem/isissn.c | 94 ------- drivers/isimodem/isiussd.c | 106 -------- drivers/isimodem/isivoicecall.c | 188 -------------- drivers/isimodem/network-registration.c | 235 +++++++++++++++++ drivers/isimodem/phonebook.c | 432 ++++++++++++++++++++++++++++++++ drivers/isimodem/sim.c | 150 +++++++++++ drivers/isimodem/sms.c | 114 +++++++++ drivers/isimodem/ssn.c | 94 +++++++ drivers/isimodem/ussd.c | 106 ++++++++ drivers/isimodem/voicecall.c | 188 ++++++++++++++ 25 files changed, 2277 insertions(+), 2277 deletions(-) create mode 100644 drivers/isimodem/call-barring.c create mode 100644 drivers/isimodem/call-forwarding.c create mode 100644 drivers/isimodem/call-meter.c create mode 100644 drivers/isimodem/call-settings.c create mode 100644 drivers/isimodem/devinfo.c delete mode 100644 drivers/isimodem/isicall-barring.c delete mode 100644 drivers/isimodem/isicall-forwarding.c delete mode 100644 drivers/isimodem/isicall-meter.c delete mode 100644 drivers/isimodem/isicall-settings.c delete mode 100644 drivers/isimodem/isidevinfo.c delete mode 100644 drivers/isimodem/isinetwork.c delete mode 100644 drivers/isimodem/isiphonebook.c delete mode 100644 drivers/isimodem/isisim.c delete mode 100644 drivers/isimodem/isisms.c delete mode 100644 drivers/isimodem/isissn.c delete mode 100644 drivers/isimodem/isiussd.c delete mode 100644 drivers/isimodem/isivoicecall.c create mode 100644 drivers/isimodem/network-registration.c create mode 100644 drivers/isimodem/phonebook.c create mode 100644 drivers/isimodem/sim.c create mode 100644 drivers/isimodem/sms.c create mode 100644 drivers/isimodem/ssn.c create mode 100644 drivers/isimodem/ussd.c create mode 100644 drivers/isimodem/voicecall.c diff --git a/Makefile.am b/Makefile.am index f381ea16..7ee65360 100644 --- a/Makefile.am +++ b/Makefile.am @@ -43,18 +43,18 @@ if ISIMODEM builtin_modules += isimodem builtin_sources += $(gisi_sources) drivers/isimodem/isi.h \ drivers/isimodem/isimodem.c \ - drivers/isimodem/isiphonebook.c \ - drivers/isimodem/isidevinfo.c \ - drivers/isimodem/isinetwork.c \ - drivers/isimodem/isivoicecall.c \ - drivers/isimodem/isisms.c \ - drivers/isimodem/isisim.c \ - drivers/isimodem/isissn.c \ - drivers/isimodem/isiussd.c \ - drivers/isimodem/isicall-forwarding.c \ - drivers/isimodem/isicall-settings.c \ - drivers/isimodem/isicall-barring.c \ - drivers/isimodem/isicall-meter.c + drivers/isimodem/phonebook.c \ + drivers/isimodem/devinfo.c \ + drivers/isimodem/network-registration.c \ + drivers/isimodem/voicecall.c \ + drivers/isimodem/sms.c \ + drivers/isimodem/sim.c \ + drivers/isimodem/ssn.c \ + drivers/isimodem/ussd.c \ + drivers/isimodem/call-forwarding.c \ + drivers/isimodem/call-settings.c \ + drivers/isimodem/call-barring.c \ + drivers/isimodem/call-meter.c endif if ATMODEM diff --git a/drivers/isimodem/call-barring.c b/drivers/isimodem/call-barring.c new file mode 100644 index 00000000..a35dd9bc --- /dev/null +++ b/drivers/isimodem/call-barring.c @@ -0,0 +1,114 @@ +/* + * This file is part of oFono - Open Source Telephony + * + * Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). + * + * Contact: Aki Niemi + * + * 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 +#endif + +#define _GNU_SOURCE +#include +#include +#include +#include + +#include + +#include + +#include +#include +#include + +#include "isi.h" + +#define PN_SS 0x06 + +struct call_barring_data { + GIsiClient *client; + struct isi_version version; +}; + +static void isi_set(struct ofono_call_barring *barr, const char *lock, + int enable, const char *passwd, int cls, + ofono_call_barring_set_cb_t cb, void *data) +{ +} + +static void isi_query(struct ofono_call_barring *barr, const char *lock, int cls, + ofono_call_barring_query_cb_t cb, void *data) +{ +} + +static void isi_set_passwd(struct ofono_call_barring *barr, const char *lock, + const char *old_passwd, const char *new_passwd, + ofono_call_barring_set_cb_t cb, void *data) +{ +} + +static int isi_call_barring_probe(struct ofono_call_barring *barr) +{ + GIsiModem *idx = ofono_call_barring_get_data(barr); + struct call_barring_data *data = g_try_new0(struct call_barring_data, 1); + + if (!data) + return -ENOMEM; + + data->client = g_isi_client_create(idx, PN_SS); + if (!data->client) + return -ENOMEM; + + ofono_call_barring_set_data(barr, data); + + return 0; +} + +static int isi_call_barring_remove(struct ofono_call_barring *barr) +{ + struct call_barring_data *data = ofono_call_barring_get_data(barr); + + if (data) { + g_isi_client_destroy(data->client); + g_free(data); + } + + return 0; +} + +static struct ofono_call_barring_driver driver = { + .name = "isi", + .probe = isi_call_barring_probe, + .remove = isi_call_barring_remove, + .set = isi_set, + .query = isi_query, + .set_passwd = isi_set_passwd +}; + +void isi_call_barring_init() +{ + ofono_call_barring_driver_register(&driver); +} + +void isi_call_barring_exit() +{ + ofono_call_barring_driver_unregister(&driver); +} diff --git a/drivers/isimodem/call-forwarding.c b/drivers/isimodem/call-forwarding.c new file mode 100644 index 00000000..08236c8c --- /dev/null +++ b/drivers/isimodem/call-forwarding.c @@ -0,0 +1,130 @@ +/* + * This file is part of oFono - Open Source Telephony + * + * Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). + * + * Contact: Aki Niemi + * + * 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 +#endif + +#define _GNU_SOURCE +#include +#include +#include +#include + +#include + +#include + +#include +#include +#include + +#include "isi.h" + +#define PN_SS 0x06 + +struct call_forwarding_data { + GIsiClient *client; + struct isi_version version; +}; + +static void isi_activation(struct ofono_call_forwarding *cf, + int type, int cls, + ofono_call_forwarding_set_cb_t cb, void *data) +{ +} + +static void isi_registration(struct ofono_call_forwarding *cf, + int type, int cls, + const struct ofono_phone_number *number, + int time, + ofono_call_forwarding_set_cb_t cb, void *data) +{ +} + +static void isi_deactivation(struct ofono_call_forwarding *cf, + int type, int cls, + ofono_call_forwarding_set_cb_t cb, void *data) +{ +} + +static void isi_erasure(struct ofono_call_forwarding *cf, int type, int cls, + ofono_call_forwarding_set_cb_t cb, void *data) +{ +} + +static void isi_query(struct ofono_call_forwarding *cf, int type, int cls, + ofono_call_forwarding_query_cb_t cb, + void *data) +{ +} + +static int isi_call_forwarding_probe(struct ofono_call_forwarding *cf) +{ + GIsiModem *idx = ofono_call_forwarding_get_data(cf); + struct call_forwarding_data *data = g_try_new0(struct call_forwarding_data, 1); + + if (!data) + return -ENOMEM; + + data->client = g_isi_client_create(idx, PN_SS); + if (!data->client) + return -ENOMEM; + + ofono_call_forwarding_set_data(cf, data); + + return 0; +} + +static int isi_call_forwarding_remove(struct ofono_call_forwarding *cf) +{ + struct call_forwarding_data *data = ofono_call_forwarding_get_data(cf); + + if (data) { + g_isi_client_destroy(data->client); + g_free(data); + } + + return 0; +} + +static struct ofono_call_forwarding_driver driver = { + .name = "isi", + .probe = isi_call_forwarding_probe, + .remove = isi_call_forwarding_remove, + .activation = isi_activation, + .registration = isi_registration, + .deactivation = isi_deactivation, + .erasure = isi_erasure, + .query = isi_query +}; + +void isi_call_forwarding_init() +{ + ofono_call_forwarding_driver_register(&driver); +} + +void isi_call_forwarding_exit() +{ + ofono_call_forwarding_driver_unregister(&driver); +} diff --git a/drivers/isimodem/call-meter.c b/drivers/isimodem/call-meter.c new file mode 100644 index 00000000..7a7930f7 --- /dev/null +++ b/drivers/isimodem/call-meter.c @@ -0,0 +1,140 @@ +/* + * This file is part of oFono - Open Source Telephony + * + * Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). + * + * Contact: Aki Niemi + * + * 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 +#endif + +#define _GNU_SOURCE +#include +#include +#include +#include + +#include + +#include + +#include +#include +#include + +#include "isi.h" + +#define PN_SS 0x06 + +struct call_meter_data { + GIsiClient *client; + struct isi_version version; +}; + +static void isi_call_meter_query(struct ofono_call_meter *cm, + ofono_call_meter_query_cb_t cb, + void *data) +{ +} + +static void isi_acm_query(struct ofono_call_meter *cm, + ofono_call_meter_query_cb_t cb, + void *data) +{ +} + +static void isi_acm_reset(struct ofono_call_meter *cm, const char *sim_pin2, + ofono_call_meter_set_cb_t cb, void *data) +{ +} + +static void isi_acm_max_query(struct ofono_call_meter *cm, + ofono_call_meter_query_cb_t cb, void *data) +{ +} + +static void isi_acm_max_set(struct ofono_call_meter *cm, int new_value, + const char *sim_pin2, + ofono_call_meter_set_cb_t cb, void *data) +{ +} + +static void isi_puct_query(struct ofono_call_meter *cm, + ofono_call_meter_puct_query_cb_t cb, void *data) +{ +} + +static void isi_puct_set(struct ofono_call_meter *cm, const char *currency, + double ppu, const char *sim_pin2, + ofono_call_meter_set_cb_t cb, void *data) +{ +} + +static int isi_call_meter_probe(struct ofono_call_meter *cm) +{ + GIsiModem *idx = ofono_call_meter_get_data(cm); + struct call_meter_data *data = g_try_new0(struct call_meter_data, 1); + + if (!data) + return -ENOMEM; + + data->client = g_isi_client_create(idx, PN_SS); + if (!data->client) + return -ENOMEM; + + ofono_call_meter_set_data(cm, data); + + return 0; +} + +static int isi_call_meter_remove(struct ofono_call_meter *cm) +{ + struct call_meter_data *data = ofono_call_meter_get_data(cm); + + if (data) { + g_isi_client_destroy(data->client); + g_free(data); + } + + return 0; +} + +static struct ofono_call_meter_driver driver = { + .name = "isi", + .probe = isi_call_meter_probe, + .remove = isi_call_meter_remove, + .call_meter_query = isi_call_meter_query, + .acm_query = isi_acm_query, + .acm_reset = isi_acm_reset, + .acm_max_query = isi_acm_max_query, + .acm_max_set = isi_acm_max_set, + .puct_query = isi_puct_query, + .puct_set = isi_puct_set +}; + +void isi_call_meter_init() +{ + ofono_call_meter_driver_register(&driver); +} + +void isi_call_meter_exit() +{ + ofono_call_meter_driver_unregister(&driver); +} diff --git a/drivers/isimodem/call-settings.c b/drivers/isimodem/call-settings.c new file mode 100644 index 00000000..99129618 --- /dev/null +++ b/drivers/isimodem/call-settings.c @@ -0,0 +1,136 @@ +/* + * This file is part of oFono - Open Source Telephony + * + * Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). + * + * Contact: Aki Niemi + * + * 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 +#endif + +#define _GNU_SOURCE +#include +#include +#include +#include + +#include + +#include + +#include +#include +#include + +#include "isi.h" + +#define PN_SS 0x06 + +struct call_settings_data { + GIsiClient *client; + struct isi_version version; +}; + +static void isi_clip_query(struct ofono_call_settings *cs, + ofono_call_settings_status_cb_t cb, void *data) +{ +} + +static void isi_colp_query(struct ofono_call_settings *cs, + ofono_call_settings_status_cb_t cb, void *data) +{ +} + +static void isi_clir_query(struct ofono_call_settings *cs, + ofono_call_settings_clir_cb_t cb, void *data) +{ +} + +static void isi_colr_query(struct ofono_call_settings *cs, + ofono_call_settings_status_cb_t cb, void *data) +{ +} + +static void isi_clir_set(struct ofono_call_settings *cs, int mode, + ofono_call_settings_set_cb_t cb, void *data) +{ +} + +static void isi_cw_query(struct ofono_call_settings *cs, int cls, + ofono_call_settings_status_cb_t cb, void *data) +{ +} + +static void isi_cw_set(struct ofono_call_settings *cs, int mode, int cls, + ofono_call_settings_set_cb_t cb, void *data) +{ +} + +static int isi_call_settings_probe(struct ofono_call_settings *cs) +{ + GIsiModem *idx = ofono_call_settings_get_data(cs); + struct call_settings_data *data = g_try_new0(struct call_settings_data, 1); + + if (!data) + return -ENOMEM; + + data->client = g_isi_client_create(idx, PN_SS); + if (!data->client) + return -ENOMEM; + + ofono_call_settings_set_data(cs, data); + + return 0; +} + +static int isi_call_settings_remove(struct ofono_call_settings *cs) +{ + struct call_settings_data *data = ofono_call_settings_get_data(cs); + + if (data) { + g_isi_client_destroy(data->client); + g_free(data); + } + + return 0; +} + +static struct ofono_call_settings_driver driver = { + .name = "isi", + .probe = isi_call_settings_probe, + .remove = isi_call_settings_remove, + .clip_query = isi_clip_query, + .colp_query = isi_colp_query, + .clir_query = isi_clir_query, + .colr_query = isi_colr_query, + .clir_set = isi_clir_set, + .cw_query = isi_cw_query, + .cw_set = isi_cw_set +}; + +void isi_call_settings_init() +{ + ofono_call_settings_driver_register(&driver); +} + +void isi_call_settings_exit() +{ + ofono_call_settings_driver_unregister(&driver); +} diff --git a/drivers/isimodem/devinfo.c b/drivers/isimodem/devinfo.c new file mode 100644 index 00000000..6c479bb4 --- /dev/null +++ b/drivers/isimodem/devinfo.c @@ -0,0 +1,426 @@ +/* + * This file is part of oFono - Open Source Telephony + * + * Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). + * + * Contact: Aki Niemi + * + * 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 +#endif + +#define _GNU_SOURCE +#include +#include +#include +#include + +#include + +#include + +#include +#include +#include + +#include "isi.h" + +#define PN_PHONE_INFO 0x1B +#define INFO_TIMEOUT 5 + +enum return_code { + INFO_OK = 0x00, + INFO_FAIL = 0x01, + INFO_NO_NUMBER = 0x02, + INFO_NOT_SUPPORTED = 0x03 +}; + +enum message_id { + INFO_SERIAL_NUMBER_READ_REQ = 0x00, + INFO_SERIAL_NUMBER_READ_RESP = 0x01, + INFO_VERSION_READ_REQ = 0x07, + INFO_VERSION_READ_RESP = 0x08, + INFO_PRODUCT_INFO_READ_REQ = 0x15, + INFO_PRODUCT_INFO_READ_RESP = 0x16 +}; + +enum sub_block_id { + INFO_SB_PRODUCT_INFO_NAME = 0x01, + INFO_SB_PRODUCT_INFO_MANUFACTURER = 0x07, + INFO_SB_SN_IMEI_PLAIN = 0x41, + INFO_SB_MCUSW_VERSION = 0x48 +}; + +enum product_info_type { + INFO_PRODUCT_NAME = 0x01, + INFO_PRODUCT_MANUFACTURER = 0x07 +}; + +enum serial_number_type { + INFO_SN_IMEI_PLAIN = 0x41 +}; + +enum version_type { + INFO_MCUSW = 0x01 +}; + +struct devinfo_data { + GIsiClient *client; +}; + +static gboolean decode_sb_and_report(const unsigned char *msg, size_t len, int id, + ofono_devinfo_query_cb_t cb, + void *data) +{ + if (msg[1] != INFO_OK) { + DBG("Query failed: 0x%02x", msg[1]); + return false; + } + + if (msg[2] == 0 || len < 8 || msg[6] == 0 || len < (size_t)(msg[6] + 7)) { + DBG("Truncated message"); + return false; + } + + if (msg[3] == id) { + char str[msg[6] + 1]; + + memcpy(str, msg + 7, msg[6]); + str[msg[6]] = '\0'; + DBG("<%s>", str); + + { + DECLARE_SUCCESS(error); + cb(&error, str, data); + return true; + } + } + + DBG("Unexpected sub-block: 0x%02x", msg[3]); + return false; +} + +static bool manufacturer_resp_cb(GIsiClient *client, const void *restrict data, + size_t len, uint16_t object, void *opaque) +{ + const unsigned char *msg = data; + struct isi_cb_data *cbd = opaque; + ofono_devinfo_query_cb_t cb = cbd->cb; + + if(!msg) { + DBG("ISI client error: %d", g_isi_client_error(client)); + goto error; + } + + if (msg[0] != INFO_PRODUCT_INFO_READ_RESP) { + DBG("Unexpected message ID: 0x%02x", msg[0]); + goto error; + } + + if (decode_sb_and_report(msg, len, INFO_SB_PRODUCT_INFO_MANUFACTURER, + cb, cbd->data)) + goto out; + +error: + { + DECLARE_FAILURE(error); + cb(&error, "", cbd->data); + } + +out: + g_free(cbd); + return true; +} + +static void isi_query_manufacturer(struct ofono_devinfo *info, + ofono_devinfo_query_cb_t cb, + void *data) +{ + struct devinfo_data *dev = ofono_devinfo_get_data(info); + struct isi_cb_data *cbd = isi_cb_data_new(NULL, cb, data); + + const unsigned char msg[] = { + INFO_PRODUCT_INFO_READ_REQ, + INFO_PRODUCT_MANUFACTURER + }; + + if (!cbd) + goto error; + + if (g_isi_request_make(dev->client, msg, sizeof(msg), INFO_TIMEOUT, + manufacturer_resp_cb, cbd)) + return; + +error: + if (cbd) + g_free(cbd); + + { + DECLARE_FAILURE(error); + cb(&error, "", data); + } +} + +static bool model_resp_cb(GIsiClient *client, const void *restrict data, + size_t len, uint16_t object, void *opaque) +{ + const unsigned char *msg = data; + struct isi_cb_data *cbd = opaque; + ofono_devinfo_query_cb_t cb = cbd->cb; + + if(!msg) { + DBG("ISI client error: %d", g_isi_client_error(client)); + goto error; + } + + if (msg[0] != INFO_PRODUCT_INFO_READ_RESP) { + DBG("Unexpected message ID: 0x%02x", msg[0]); + goto error; + } + + if (decode_sb_and_report(msg, len, INFO_SB_PRODUCT_INFO_NAME, + cb, cbd->data)) + goto out; + +error: + { + DECLARE_FAILURE(error); + cb(&error, "", cbd->data); + } + +out: + g_free(cbd); + return true; +} + +static void isi_query_model(struct ofono_devinfo *info, + ofono_devinfo_query_cb_t cb, + void *data) +{ + struct devinfo_data *dev = ofono_devinfo_get_data(info); + struct isi_cb_data *cbd = isi_cb_data_new(NULL, cb, data); + + const unsigned char msg[] = { + INFO_PRODUCT_INFO_READ_REQ, + INFO_PRODUCT_NAME + }; + + if (!cbd) + goto error; + + if (g_isi_request_make(dev->client, msg, sizeof(msg), INFO_TIMEOUT, + model_resp_cb, cbd)) + return; + +error: + if (cbd) + g_free(cbd); + + { + DECLARE_FAILURE(error); + cb(&error, "", data); + } +} + +static bool revision_resp_cb(GIsiClient *client, const void *restrict data, + size_t len, uint16_t object, void *opaque) +{ + const unsigned char *msg = data; + struct isi_cb_data *cbd = opaque; + ofono_devinfo_query_cb_t cb = cbd->cb; + + if(!msg) { + DBG("ISI client error: %d", g_isi_client_error(client)); + goto error; + } + + if (msg[0] != INFO_VERSION_READ_RESP) { + DBG("Unexpected message ID: 0x%02x", msg[0]); + goto error; + } + + if (decode_sb_and_report(msg, len, INFO_SB_MCUSW_VERSION, + cb, cbd->data)) + goto out; + +error: + { + DECLARE_FAILURE(error); + cb(&error, "", cbd->data); + } + +out: + g_free(cbd); + return true; +} + +static void isi_query_revision(struct ofono_devinfo *info, + ofono_devinfo_query_cb_t cb, + void *data) +{ + struct devinfo_data *dev = ofono_devinfo_get_data(info); + struct isi_cb_data *cbd = isi_cb_data_new(NULL, cb, data); + + const unsigned char msg[] = { + INFO_VERSION_READ_REQ, + 0x00, INFO_MCUSW, + 0x00, 0x00, 0x00, 0x00 + }; + + if (!cbd) + goto error; + + if (g_isi_request_make(dev->client, msg, sizeof(msg), INFO_TIMEOUT, + revision_resp_cb, cbd)) + return; + +error: + if (cbd) + g_free(cbd); + + { + DECLARE_FAILURE(error); + cb(&error, "", data); + } +} + +static bool serial_resp_cb(GIsiClient *client, const void *restrict data, + size_t len, uint16_t object, void *opaque) +{ + const unsigned char *msg = data; + struct isi_cb_data *cbd = opaque; + ofono_devinfo_query_cb_t cb = cbd->cb; + + if(!msg) { + DBG("ISI client error: %d", g_isi_client_error(client)); + goto error; + } + + if (msg[0] != INFO_SERIAL_NUMBER_READ_RESP) { + DBG("Unexpected message ID: 0x%02x", msg[0]); + goto error; + } + + if (decode_sb_and_report(msg, len, INFO_SB_SN_IMEI_PLAIN, + cb, cbd->data)) + goto out; + +error: + { + DECLARE_FAILURE(error); + cb(&error, "", cbd->data); + } + +out: + g_free(cbd); + return true; +} + +static void isi_query_serial(struct ofono_devinfo *info, + ofono_devinfo_query_cb_t cb, + void *data) +{ + struct devinfo_data *dev = ofono_devinfo_get_data(info); + struct isi_cb_data *cbd = isi_cb_data_new(NULL, cb, data); + + const unsigned char msg[] = { + INFO_SERIAL_NUMBER_READ_REQ, + INFO_SN_IMEI_PLAIN + }; + + if (!cbd) + goto error; + + if (g_isi_request_make(dev->client, msg, sizeof(msg), INFO_TIMEOUT, + serial_resp_cb, cbd)) + return; + +error: + if (cbd) + g_free(cbd); + + { + DECLARE_FAILURE(error); + cb(&error, "", data); + } +} + +static gboolean isi_devinfo_register(gpointer user) +{ + struct ofono_devinfo *info = user; + + ofono_devinfo_register(info); + + return FALSE; +} + +static int isi_devinfo_probe(struct ofono_devinfo *info) +{ + GIsiModem *idx = ofono_devinfo_get_data(info); + struct devinfo_data *data = g_try_new0(struct devinfo_data, 1); + + if (!data) + return -ENOMEM; + + DBG("idx=%p", idx); + + data->client = g_isi_client_create(idx, PN_PHONE_INFO); + if (!data->client) { + g_free(data); + return -ENOMEM; + } + + ofono_devinfo_set_data(info, data); + + g_idle_add(isi_devinfo_register, info); + + return 0; +} + +static int isi_devinfo_remove(struct ofono_devinfo *info) +{ + struct devinfo_data *data = ofono_devinfo_get_data(info); + + if (data) { + g_isi_client_destroy(data->client); + g_free(data); + } + + return 0; +} + +static struct ofono_devinfo_driver driver = { + .name = "isi", + .probe = isi_devinfo_probe, + .remove = isi_devinfo_remove, + .query_manufacturer = isi_query_manufacturer, + .query_model = isi_query_model, + .query_revision = isi_query_revision, + .query_serial = isi_query_serial +}; + +void isi_devinfo_init() +{ + ofono_devinfo_driver_register(&driver); +} + +void isi_devinfo_exit() +{ + ofono_devinfo_driver_unregister(&driver); +} diff --git a/drivers/isimodem/isicall-barring.c b/drivers/isimodem/isicall-barring.c deleted file mode 100644 index a35dd9bc..00000000 --- a/drivers/isimodem/isicall-barring.c +++ /dev/null @@ -1,114 +0,0 @@ -/* - * This file is part of oFono - Open Source Telephony - * - * Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). - * - * Contact: Aki Niemi - * - * 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 -#endif - -#define _GNU_SOURCE -#include -#include -#include -#include - -#include - -#include - -#include -#include -#include - -#include "isi.h" - -#define PN_SS 0x06 - -struct call_barring_data { - GIsiClient *client; - struct isi_version version; -}; - -static void isi_set(struct ofono_call_barring *barr, const char *lock, - int enable, const char *passwd, int cls, - ofono_call_barring_set_cb_t cb, void *data) -{ -} - -static void isi_query(struct ofono_call_barring *barr, const char *lock, int cls, - ofono_call_barring_query_cb_t cb, void *data) -{ -} - -static void isi_set_passwd(struct ofono_call_barring *barr, const char *lock, - const char *old_passwd, const char *new_passwd, - ofono_call_barring_set_cb_t cb, void *data) -{ -} - -static int isi_call_barring_probe(struct ofono_call_barring *barr) -{ - GIsiModem *idx = ofono_call_barring_get_data(barr); - struct call_barring_data *data = g_try_new0(struct call_barring_data, 1); - - if (!data) - return -ENOMEM; - - data->client = g_isi_client_create(idx, PN_SS); - if (!data->client) - return -ENOMEM; - - ofono_call_barring_set_data(barr, data); - - return 0; -} - -static int isi_call_barring_remove(struct ofono_call_barring *barr) -{ - struct call_barring_data *data = ofono_call_barring_get_data(barr); - - if (data) { - g_isi_client_destroy(data->client); - g_free(data); - } - - return 0; -} - -static struct ofono_call_barring_driver driver = { - .name = "isi", - .probe = isi_call_barring_probe, - .remove = isi_call_barring_remove, - .set = isi_set, - .query = isi_query, - .set_passwd = isi_set_passwd -}; - -void isi_call_barring_init() -{ - ofono_call_barring_driver_register(&driver); -} - -void isi_call_barring_exit() -{ - ofono_call_barring_driver_unregister(&driver); -} diff --git a/drivers/isimodem/isicall-forwarding.c b/drivers/isimodem/isicall-forwarding.c deleted file mode 100644 index 08236c8c..00000000 --- a/drivers/isimodem/isicall-forwarding.c +++ /dev/null @@ -1,130 +0,0 @@ -/* - * This file is part of oFono - Open Source Telephony - * - * Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). - * - * Contact: Aki Niemi - * - * 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 -#endif - -#define _GNU_SOURCE -#include -#include -#include -#include - -#include - -#include - -#include -#include -#include - -#include "isi.h" - -#define PN_SS 0x06 - -struct call_forwarding_data { - GIsiClient *client; - struct isi_version version; -}; - -static void isi_activation(struct ofono_call_forwarding *cf, - int type, int cls, - ofono_call_forwarding_set_cb_t cb, void *data) -{ -} - -static void isi_registration(struct ofono_call_forwarding *cf, - int type, int cls, - const struct ofono_phone_number *number, - int time, - ofono_call_forwarding_set_cb_t cb, void *data) -{ -} - -static void isi_deactivation(struct ofono_call_forwarding *cf, - int type, int cls, - ofono_call_forwarding_set_cb_t cb, void *data) -{ -} - -static void isi_erasure(struct ofono_call_forwarding *cf, int type, int cls, - ofono_call_forwarding_set_cb_t cb, void *data) -{ -} - -static void isi_query(struct ofono_call_forwarding *cf, int type, int cls, - ofono_call_forwarding_query_cb_t cb, - void *data) -{ -} - -static int isi_call_forwarding_probe(struct ofono_call_forwarding *cf) -{ - GIsiModem *idx = ofono_call_forwarding_get_data(cf); - struct call_forwarding_data *data = g_try_new0(struct call_forwarding_data, 1); - - if (!data) - return -ENOMEM; - - data->client = g_isi_client_create(idx, PN_SS); - if (!data->client) - return -ENOMEM; - - ofono_call_forwarding_set_data(cf, data); - - return 0; -} - -static int isi_call_forwarding_remove(struct ofono_call_forwarding *cf) -{ - struct call_forwarding_data *data = ofono_call_forwarding_get_data(cf); - - if (data) { - g_isi_client_destroy(data->client); - g_free(data); - } - - return 0; -} - -static struct ofono_call_forwarding_driver driver = { - .name = "isi", - .probe = isi_call_forwarding_probe, - .remove = isi_call_forwarding_remove, - .activation = isi_activation, - .registration = isi_registration, - .deactivation = isi_deactivation, - .erasure = isi_erasure, - .query = isi_query -}; - -void isi_call_forwarding_init() -{ - ofono_call_forwarding_driver_register(&driver); -} - -void isi_call_forwarding_exit() -{ - ofono_call_forwarding_driver_unregister(&driver); -} diff --git a/drivers/isimodem/isicall-meter.c b/drivers/isimodem/isicall-meter.c deleted file mode 100644 index 7a7930f7..00000000 --- a/drivers/isimodem/isicall-meter.c +++ /dev/null @@ -1,140 +0,0 @@ -/* - * This file is part of oFono - Open Source Telephony - * - * Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). - * - * Contact: Aki Niemi - * - * 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 -#endif - -#define _GNU_SOURCE -#include -#include -#include -#include - -#include - -#include - -#include -#include -#include - -#include "isi.h" - -#define PN_SS 0x06 - -struct call_meter_data { - GIsiClient *client; - struct isi_version version; -}; - -static void isi_call_meter_query(struct ofono_call_meter *cm, - ofono_call_meter_query_cb_t cb, - void *data) -{ -} - -static void isi_acm_query(struct ofono_call_meter *cm, - ofono_call_meter_query_cb_t cb, - void *data) -{ -} - -static void isi_acm_reset(struct ofono_call_meter *cm, const char *sim_pin2, - ofono_call_meter_set_cb_t cb, void *data) -{ -} - -static void isi_acm_max_query(struct ofono_call_meter *cm, - ofono_call_meter_query_cb_t cb, void *data) -{ -} - -static void isi_acm_max_set(struct ofono_call_meter *cm, int new_value, - const char *sim_pin2, - ofono_call_meter_set_cb_t cb, void *data) -{ -} - -static void isi_puct_query(struct ofono_call_meter *cm, - ofono_call_meter_puct_query_cb_t cb, void *data) -{ -} - -static void isi_puct_set(struct ofono_call_meter *cm, const char *currency, - double ppu, const char *sim_pin2, - ofono_call_meter_set_cb_t cb, void *data) -{ -} - -static int isi_call_meter_probe(struct ofono_call_meter *cm) -{ - GIsiModem *idx = ofono_call_meter_get_data(cm); - struct call_meter_data *data = g_try_new0(struct call_meter_data, 1); - - if (!data) - return -ENOMEM; - - data->client = g_isi_client_create(idx, PN_SS); - if (!data->client) - return -ENOMEM; - - ofono_call_meter_set_data(cm, data); - - return 0; -} - -static int isi_call_meter_remove(struct ofono_call_meter *cm) -{ - struct call_meter_data *data = ofono_call_meter_get_data(cm); - - if (data) { - g_isi_client_destroy(data->client); - g_free(data); - } - - return 0; -} - -static struct ofono_call_meter_driver driver = { - .name = "isi", - .probe = isi_call_meter_probe, - .remove = isi_call_meter_remove, - .call_meter_query = isi_call_meter_query, - .acm_query = isi_acm_query, - .acm_reset = isi_acm_reset, - .acm_max_query = isi_acm_max_query, - .acm_max_set = isi_acm_max_set, - .puct_query = isi_puct_query, - .puct_set = isi_puct_set -}; - -void isi_call_meter_init() -{ - ofono_call_meter_driver_register(&driver); -} - -void isi_call_meter_exit() -{ - ofono_call_meter_driver_unregister(&driver); -} diff --git a/drivers/isimodem/isicall-settings.c b/drivers/isimodem/isicall-settings.c deleted file mode 100644 index 99129618..00000000 --- a/drivers/isimodem/isicall-settings.c +++ /dev/null @@ -1,136 +0,0 @@ -/* - * This file is part of oFono - Open Source Telephony - * - * Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). - * - * Contact: Aki Niemi - * - * 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 -#endif - -#define _GNU_SOURCE -#include -#include -#include -#include - -#include - -#include - -#include -#include -#include - -#include "isi.h" - -#define PN_SS 0x06 - -struct call_settings_data { - GIsiClient *client; - struct isi_version version; -}; - -static void isi_clip_query(struct ofono_call_settings *cs, - ofono_call_settings_status_cb_t cb, void *data) -{ -} - -static void isi_colp_query(struct ofono_call_settings *cs, - ofono_call_settings_status_cb_t cb, void *data) -{ -} - -static void isi_clir_query(struct ofono_call_settings *cs, - ofono_call_settings_clir_cb_t cb, void *data) -{ -} - -static void isi_colr_query(struct ofono_call_settings *cs, - ofono_call_settings_status_cb_t cb, void *data) -{ -} - -static void isi_clir_set(struct ofono_call_settings *cs, int mode, - ofono_call_settings_set_cb_t cb, void *data) -{ -} - -static void isi_cw_query(struct ofono_call_settings *cs, int cls, - ofono_call_settings_status_cb_t cb, void *data) -{ -} - -static void isi_cw_set(struct ofono_call_settings *cs, int mode, int cls, - ofono_call_settings_set_cb_t cb, void *data) -{ -} - -static int isi_call_settings_probe(struct ofono_call_settings *cs) -{ - GIsiModem *idx = ofono_call_settings_get_data(cs); - struct call_settings_data *data = g_try_new0(struct call_settings_data, 1); - - if (!data) - return -ENOMEM; - - data->client = g_isi_client_create(idx, PN_SS); - if (!data->client) - return -ENOMEM; - - ofono_call_settings_set_data(cs, data); - - return 0; -} - -static int isi_call_settings_remove(struct ofono_call_settings *cs) -{ - struct call_settings_data *data = ofono_call_settings_get_data(cs); - - if (data) { - g_isi_client_destroy(data->client); - g_free(data); - } - - return 0; -} - -static struct ofono_call_settings_driver driver = { - .name = "isi", - .probe = isi_call_settings_probe, - .remove = isi_call_settings_remove, - .clip_query = isi_clip_query, - .colp_query = isi_colp_query, - .clir_query = isi_clir_query, - .colr_query = isi_colr_query, - .clir_set = isi_clir_set, - .cw_query = isi_cw_query, - .cw_set = isi_cw_set -}; - -void isi_call_settings_init() -{ - ofono_call_settings_driver_register(&driver); -} - -void isi_call_settings_exit() -{ - ofono_call_settings_driver_unregister(&driver); -} diff --git a/drivers/isimodem/isidevinfo.c b/drivers/isimodem/isidevinfo.c deleted file mode 100644 index 6c479bb4..00000000 --- a/drivers/isimodem/isidevinfo.c +++ /dev/null @@ -1,426 +0,0 @@ -/* - * This file is part of oFono - Open Source Telephony - * - * Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). - * - * Contact: Aki Niemi - * - * 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 -#endif - -#define _GNU_SOURCE -#include -#include -#include -#include - -#include - -#include - -#include -#include -#include - -#include "isi.h" - -#define PN_PHONE_INFO 0x1B -#define INFO_TIMEOUT 5 - -enum return_code { - INFO_OK = 0x00, - INFO_FAIL = 0x01, - INFO_NO_NUMBER = 0x02, - INFO_NOT_SUPPORTED = 0x03 -}; - -enum message_id { - INFO_SERIAL_NUMBER_READ_REQ = 0x00, - INFO_SERIAL_NUMBER_READ_RESP = 0x01, - INFO_VERSION_READ_REQ = 0x07, - INFO_VERSION_READ_RESP = 0x08, - INFO_PRODUCT_INFO_READ_REQ = 0x15, - INFO_PRODUCT_INFO_READ_RESP = 0x16 -}; - -enum sub_block_id { - INFO_SB_PRODUCT_INFO_NAME = 0x01, - INFO_SB_PRODUCT_INFO_MANUFACTURER = 0x07, - INFO_SB_SN_IMEI_PLAIN = 0x41, - INFO_SB_MCUSW_VERSION = 0x48 -}; - -enum product_info_type { - INFO_PRODUCT_NAME = 0x01, - INFO_PRODUCT_MANUFACTURER = 0x07 -}; - -enum serial_number_type { - INFO_SN_IMEI_PLAIN = 0x41 -}; - -enum version_type { - INFO_MCUSW = 0x01 -}; - -struct devinfo_data { - GIsiClient *client; -}; - -static gboolean decode_sb_and_report(const unsigned char *msg, size_t len, int id, - ofono_devinfo_query_cb_t cb, - void *data) -{ - if (msg[1] != INFO_OK) { - DBG("Query failed: 0x%02x", msg[1]); - return false; - } - - if (msg[2] == 0 || len < 8 || msg[6] == 0 || len < (size_t)(msg[6] + 7)) { - DBG("Truncated message"); - return false; - } - - if (msg[3] == id) { - char str[msg[6] + 1]; - - memcpy(str, msg + 7, msg[6]); - str[msg[6]] = '\0'; - DBG("<%s>", str); - - { - DECLARE_SUCCESS(error); - cb(&error, str, data); - return true; - } - } - - DBG("Unexpected sub-block: 0x%02x", msg[3]); - return false; -} - -static bool manufacturer_resp_cb(GIsiClient *client, const void *restrict data, - size_t len, uint16_t object, void *opaque) -{ - const unsigned char *msg = data; - struct isi_cb_data *cbd = opaque; - ofono_devinfo_query_cb_t cb = cbd->cb; - - if(!msg) { - DBG("ISI client error: %d", g_isi_client_error(client)); - goto error; - } - - if (msg[0] != INFO_PRODUCT_INFO_READ_RESP) { - DBG("Unexpected message ID: 0x%02x", msg[0]); - goto error; - } - - if (decode_sb_and_report(msg, len, INFO_SB_PRODUCT_INFO_MANUFACTURER, - cb, cbd->data)) - goto out; - -error: - { - DECLARE_FAILURE(error); - cb(&error, "", cbd->data); - } - -out: - g_free(cbd); - return true; -} - -static void isi_query_manufacturer(struct ofono_devinfo *info, - ofono_devinfo_query_cb_t cb, - void *data) -{ - struct devinfo_data *dev = ofono_devinfo_get_data(info); - struct isi_cb_data *cbd = isi_cb_data_new(NULL, cb, data); - - const unsigned char msg[] = { - INFO_PRODUCT_INFO_READ_REQ, - INFO_PRODUCT_MANUFACTURER - }; - - if (!cbd) - goto error; - - if (g_isi_request_make(dev->client, msg, sizeof(msg), INFO_TIMEOUT, - manufacturer_resp_cb, cbd)) - return; - -error: - if (cbd) - g_free(cbd); - - { - DECLARE_FAILURE(error); - cb(&error, "", data); - } -} - -static bool model_resp_cb(GIsiClient *client, const void *restrict data, - size_t len, uint16_t object, void *opaque) -{ - const unsigned char *msg = data; - struct isi_cb_data *cbd = opaque; - ofono_devinfo_query_cb_t cb = cbd->cb; - - if(!msg) { - DBG("ISI client error: %d", g_isi_client_error(client)); - goto error; - } - - if (msg[0] != INFO_PRODUCT_INFO_READ_RESP) { - DBG("Unexpected message ID: 0x%02x", msg[0]); - goto error; - } - - if (decode_sb_and_report(msg, len, INFO_SB_PRODUCT_INFO_NAME, - cb, cbd->data)) - goto out; - -error: - { - DECLARE_FAILURE(error); - cb(&error, "", cbd->data); - } - -out: - g_free(cbd); - return true; -} - -static void isi_query_model(struct ofono_devinfo *info, - ofono_devinfo_query_cb_t cb, - void *data) -{ - struct devinfo_data *dev = ofono_devinfo_get_data(info); - struct isi_cb_data *cbd = isi_cb_data_new(NULL, cb, data); - - const unsigned char msg[] = { - INFO_PRODUCT_INFO_READ_REQ, - INFO_PRODUCT_NAME - }; - - if (!cbd) - goto error; - - if (g_isi_request_make(dev->client, msg, sizeof(msg), INFO_TIMEOUT, - model_resp_cb, cbd)) - return; - -error: - if (cbd) - g_free(cbd); - - { - DECLARE_FAILURE(error); - cb(&error, "", data); - } -} - -static bool revision_resp_cb(GIsiClient *client, const void *restrict data, - size_t len, uint16_t object, void *opaque) -{ - const unsigned char *msg = data; - struct isi_cb_data *cbd = opaque; - ofono_devinfo_query_cb_t cb = cbd->cb; - - if(!msg) { - DBG("ISI client error: %d", g_isi_client_error(client)); - goto error; - } - - if (msg[0] != INFO_VERSION_READ_RESP) { - DBG("Unexpected message ID: 0x%02x", msg[0]); - goto error; - } - - if (decode_sb_and_report(msg, len, INFO_SB_MCUSW_VERSION, - cb, cbd->data)) - goto out; - -error: - { - DECLARE_FAILURE(error); - cb(&error, "", cbd->data); - } - -out: - g_free(cbd); - return true; -} - -static void isi_query_revision(struct ofono_devinfo *info, - ofono_devinfo_query_cb_t cb, - void *data) -{ - struct devinfo_data *dev = ofono_devinfo_get_data(info); - struct isi_cb_data *cbd = isi_cb_data_new(NULL, cb, data); - - const unsigned char msg[] = { - INFO_VERSION_READ_REQ, - 0x00, INFO_MCUSW, - 0x00, 0x00, 0x00, 0x00 - }; - - if (!cbd) - goto error; - - if (g_isi_request_make(dev->client, msg, sizeof(msg), INFO_TIMEOUT, - revision_resp_cb, cbd)) - return; - -error: - if (cbd) - g_free(cbd); - - { - DECLARE_FAILURE(error); - cb(&error, "", data); - } -} - -static bool serial_resp_cb(GIsiClient *client, const void *restrict data, - size_t len, uint16_t object, void *opaque) -{ - const unsigned char *msg = data; - struct isi_cb_data *cbd = opaque; - ofono_devinfo_query_cb_t cb = cbd->cb; - - if(!msg) { - DBG("ISI client error: %d", g_isi_client_error(client)); - goto error; - } - - if (msg[0] != INFO_SERIAL_NUMBER_READ_RESP) { - DBG("Unexpected message ID: 0x%02x", msg[0]); - goto error; - } - - if (decode_sb_and_report(msg, len, INFO_SB_SN_IMEI_PLAIN, - cb, cbd->data)) - goto out; - -error: - { - DECLARE_FAILURE(error); - cb(&error, "", cbd->data); - } - -out: - g_free(cbd); - return true; -} - -static void isi_query_serial(struct ofono_devinfo *info, - ofono_devinfo_query_cb_t cb, - void *data) -{ - struct devinfo_data *dev = ofono_devinfo_get_data(info); - struct isi_cb_data *cbd = isi_cb_data_new(NULL, cb, data); - - const unsigned char msg[] = { - INFO_SERIAL_NUMBER_READ_REQ, - INFO_SN_IMEI_PLAIN - }; - - if (!cbd) - goto error; - - if (g_isi_request_make(dev->client, msg, sizeof(msg), INFO_TIMEOUT, - serial_resp_cb, cbd)) - return; - -error: - if (cbd) - g_free(cbd); - - { - DECLARE_FAILURE(error); - cb(&error, "", data); - } -} - -static gboolean isi_devinfo_register(gpointer user) -{ - struct ofono_devinfo *info = user; - - ofono_devinfo_register(info); - - return FALSE; -} - -static int isi_devinfo_probe(struct ofono_devinfo *info) -{ - GIsiModem *idx = ofono_devinfo_get_data(info); - struct devinfo_data *data = g_try_new0(struct devinfo_data, 1); - - if (!data) - return -ENOMEM; - - DBG("idx=%p", idx); - - data->client = g_isi_client_create(idx, PN_PHONE_INFO); - if (!data->client) { - g_free(data); - return -ENOMEM; - } - - ofono_devinfo_set_data(info, data); - - g_idle_add(isi_devinfo_register, info); - - return 0; -} - -static int isi_devinfo_remove(struct ofono_devinfo *info) -{ - struct devinfo_data *data = ofono_devinfo_get_data(info); - - if (data) { - g_isi_client_destroy(data->client); - g_free(data); - } - - return 0; -} - -static struct ofono_devinfo_driver driver = { - .name = "isi", - .probe = isi_devinfo_probe, - .remove = isi_devinfo_remove, - .query_manufacturer = isi_query_manufacturer, - .query_model = isi_query_model, - .query_revision = isi_query_revision, - .query_serial = isi_query_serial -}; - -void isi_devinfo_init() -{ - ofono_devinfo_driver_register(&driver); -} - -void isi_devinfo_exit() -{ - ofono_devinfo_driver_unregister(&driver); -} diff --git a/drivers/isimodem/isinetwork.c b/drivers/isimodem/isinetwork.c deleted file mode 100644 index 88483903..00000000 --- a/drivers/isimodem/isinetwork.c +++ /dev/null @@ -1,235 +0,0 @@ -/* - * This file is part of oFono - Open Source Telephony - * - * Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). - * - * Contact: Aki Niemi - * - * 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 -#endif - -#define _GNU_SOURCE -#include -#include -#include -#include -#include - -#include - -#include -#include - -#include -#include -#include - -#include "isi.h" - -#define PN_NETWORK 0x0A -#define NETWORK_TIMEOUT 5 -#define NETWORK_SCAN_TIMEOUT 60 - -/* Used with COMMON_MESSAGE */ -enum sub_message_id { - COMM_ISI_VERSION_GET_REQ = 0x12, - COMM_ISI_VERSION_GET_RESP = 0x13, - COMM_ISA_ENTITY_NOT_REACHABLE_RESP = 0x14 -}; - -enum message_id { - NET_SET_REQ = 0x07, - NET_SET_RESP = 0x08, - NET_SET_CANCEL_REQ = 0x09, - NET_SET_CANCEL_RESP = 0x0A, - NET_RSSI_GET_REQ = 0x0B, - NET_RSSI_GET_RESP = 0x0C, - NET_RSSI_IND = 0x1E, - NET_NITZ_NAME_IND = 0x43, - NET_REG_STATUS_GET_REQ = 0xE0, - NET_REG_STATUS_GET_RESP = 0xE1, - NET_REG_STATUS_IND = 0xE2, - NET_AVAILABLE_GET_REQ = 0xE3, - NET_AVAILABLE_GET_RESP = 0xE4, - NET_OPER_NAME_GET_REQ = 0xE5, - NET_OPER_NAME_GET_RESP = 0xE6, - COMMON_MESSAGE = 0xF0 -}; - -enum sub_block_id { - NET_REG_INFO_COMMON = 0x00, - NET_RSSI_CURRENT = 0x04, - NET_GSM_REG_INFO = 0x09, - NET_GSM_BAND_INFO = 0x11 -}; - -enum reg_status { - NET_REG_STATUS_HOME = 0x00, - NET_REG_STATUS_ROAM = 0x01, - NET_REG_STATUS_NOSERV = 0x03, - NET_REG_STATUS_NOSERV_SEARCHING = 0x04, - NET_REG_STATUS_NOSERV_NOTSEARCHING = 0x05, - NET_REG_STATUS_NOSERV_NOSIM = 0x06, - NET_REG_STATUS_POWER_OFF = 0x08, - NET_REG_STATUS_NSPS = 0x09, - NET_REG_STATUS_NSPS_NO_COVERAGE = 0x0A, - NET_REG_STATUS_NOSERV_SIM_REJECTED_BY_NW = 0x0B -}; - -enum cs_type { - NET_CS_GSM = 0x00 -}; - -enum measurement_type { - NET_CURRENT_CELL_RSSI = 0x02 -}; - -enum search_mode { - NET_MANUAL_SEARCH = 0x00 -}; - -enum band_info { - NET_GSM_BAND_ALL_SUPPORTED_BANDS = 0x03 -}; - -enum select_mode { - NET_SELECT_MODE_UNKNOWN = 0x00, - NET_SELECT_MODE_MANUAL = 0x01, - NET_SELECT_MODE_AUTOMATIC = 0x02 -}; - -enum return_code { - NET_CAUSE_OK = 0x00, - NET_CAUSE_COMMUNICATION_ERROR = 0x01, - NET_CAUSE_NET_NOT_FOUND = 0x05, - NET_CAUSE_NO_SELECTED_NETWORK = 0x11 -}; - -struct netreg_data { - GIsiClient *client; - struct isi_version version; -}; - -static void isi_registration_status(struct ofono_netreg *netreg, - ofono_netreg_status_cb_t cb, - void *data) -{ -} - -static void isi_current_operator(struct ofono_netreg *netreg, - ofono_netreg_operator_cb_t cb, - void *data) -{ -} - -static void isi_list_operators(struct ofono_netreg *netreg, - ofono_netreg_operator_list_cb_t cb, - void *data) -{ -} - -static void isi_register_auto(struct ofono_netreg *netreg, - ofono_netreg_register_cb_t cb, - void *data) -{ -} - -static void isi_register_manual(struct ofono_netreg *netreg, - const struct ofono_network_operator *oper, - ofono_netreg_register_cb_t cb, void *data) -{ -} - -static void isi_deregister(struct ofono_netreg *netreg, - ofono_netreg_register_cb_t cb, - void *data) -{ -} - -static void isi_strength(struct ofono_netreg *netreg, - ofono_netreg_strength_cb_t cb, - void *data) -{ -} - -static gboolean isi_netreg_register(gpointer user) -{ - struct ofono_netreg *net = user; - - ofono_netreg_register(net); - - return FALSE; -} - -static int isi_netreg_probe(struct ofono_netreg *netreg) -{ - GIsiModem *idx = ofono_netreg_get_data(netreg); - struct netreg_data *user = g_try_new0(struct netreg_data, 1); - - if (!user) - return -ENOMEM; - - user->client = g_isi_client_create(idx, PN_NETWORK); - if (!user->client) { - g_free(user); - return -ENOMEM; - } - - ofono_netreg_set_data(netreg, user); - - g_idle_add(isi_netreg_register, netreg); - - return 0; -} - -static int isi_netreg_remove(struct ofono_netreg *net) -{ - struct netreg_data *data = ofono_netreg_get_data(net); - - if (data && data->client) { - g_isi_client_destroy(data->client); - g_free(data); - } - - return 0; -} - -static struct ofono_netreg_driver driver = { - .name = "isi", - .probe = isi_netreg_probe, - .remove = isi_netreg_remove, - .registration_status = isi_registration_status, - .current_operator = isi_current_operator, - .list_operators = isi_list_operators, - .register_auto = isi_register_auto, - .register_manual = isi_register_manual, - .deregister = isi_deregister, - .strength = isi_strength, -}; - -void isi_netreg_init() -{ - ofono_netreg_driver_register(&driver); -} - -void isi_netreg_exit() -{ - ofono_netreg_driver_unregister(&driver); -} diff --git a/drivers/isimodem/isiphonebook.c b/drivers/isimodem/isiphonebook.c deleted file mode 100644 index 7c544741..00000000 --- a/drivers/isimodem/isiphonebook.c +++ /dev/null @@ -1,432 +0,0 @@ -/* - * This file is part of oFono - Open Source Telephony - * - * Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). - * - * Contact: Alexander Kanavin - * - * 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 -#endif - -#include -#include -#include -#include - -#include -#include - -#include -#include -#include -#include "util.h" - -#include "isi.h" - -#define PHONEBOOK_TIMEOUT 5 -#define PN_SIM 0x09 - -enum pb_message_id { - SIM_PB_REQ_SIM_PB_READ = 0xDC, - SIM_PB_RESP_SIM_PB_READ = 0xDD -}; - -enum pb_service_types { - SIM_PB_READ = 0x0F -}; - -enum pb_sub_block_id { - SIM_PB_INFO_REQUEST = 0xE4, - SIM_PB_STATUS = 0xFB, - SIM_PB_LOCATION = 0xFE, - SIM_PB_LOCATION_SEARCH = 0xFF -}; - -enum pb_type { - SIM_PB_ADN = 0xC8 -}; - -enum pb_tag { - SIM_PB_ANR = 0xCA, - SIM_PB_EMAIL = 0xDD, - SIM_PB_SNE = 0xF7 -}; - -enum pb_status { - SIM_SERV_OK = 0x01 -}; - -struct pb_data { - GIsiClient *client; -}; - -static char *ucs2_to_utf8(const unsigned char *str, long len) -{ - char *utf8; - utf8 = g_convert((const char *)str, len, "UTF-8//TRANSLIT", "UCS-2BE", - NULL, NULL, NULL); - return utf8; -} - -static int decode_read_response(const unsigned char *msg, size_t len, - struct ofono_phonebook *pb) -{ - int retval = -1; - - unsigned int i; - unsigned int p; - - char *name = NULL; - char *number = NULL; - char *adn = NULL; - char *snr = NULL; - char *email = NULL; - - unsigned int location = 0; - unsigned int status = 0; - - unsigned int messageid; - unsigned int servicetype; - unsigned int num_subblocks; - - if (len < 3) - goto cleanup; - - messageid = msg[0]; - servicetype = msg[1]; - num_subblocks = msg[2]; - - if (messageid != SIM_PB_RESP_SIM_PB_READ || servicetype != SIM_PB_READ) - goto cleanup; - - p = 3; - for (i=0; i < num_subblocks; i++) { - unsigned int subblock_type; - unsigned int subblock_len; - - if (p + 4 > len) - goto cleanup; - - subblock_type = (msg[p] << 8) + msg[p + 1]; - subblock_len = (msg[p + 2] << 8) + msg[p + 3]; - - switch (subblock_type) { - - case SIM_PB_ADN: { - unsigned int namelength; - unsigned int numberlength; - - if (p + 8 > len) - goto cleanup; - - location = (msg[p + 4] << 8) + msg[p + 5]; - namelength = msg[p + 6]; - numberlength = msg[p + 7]; - - if (p + 8 + namelength * 2 + numberlength * 2 > len) - goto cleanup; - - name = ucs2_to_utf8(msg + p + 8, namelength * 2); - number = ucs2_to_utf8(msg + p + 8 + namelength * 2, - numberlength * 2); - DBG("ADN subblock: name %s number %s location %i", - name, number, location); - break; - } - - case SIM_PB_SNE: { - unsigned int locsne; - unsigned int snelength; - unsigned int snefiller; - - if (p + 8 > len) - goto cleanup; - - locsne = (msg[p + 4] << 8) + msg[p + 5]; - snelength = msg[p + 6]; - snefiller = msg[p + 7]; - - if (p + 8 + snelength * 2 > len) - goto cleanup; - - adn = ucs2_to_utf8(msg + p + 8, snelength * 2); - DBG("SNE subblock: name %s", adn); - break; - } - - case SIM_PB_ANR: { - unsigned int locanr; - unsigned int anrlength; - unsigned int anrfiller; - - if (p + 8 > len) - goto cleanup; - - locanr = (msg[p + 4] << 8) + msg[p + 5]; - anrlength = msg[p + 6]; - anrfiller = msg[p + 7]; - - if (p + 8 + anrlength * 2 > len) - goto cleanup; - - snr = ucs2_to_utf8(msg + p + 8, anrlength * 2); - DBG("ANR subblock: number %s", snr); - break; - } - - case SIM_PB_EMAIL: { - unsigned int locemail; - unsigned int emaillength; - unsigned int emailfiller; - - if (p + 8 > len) - goto cleanup; - - locemail = (msg[p + 4] << 8) + msg[p + 5]; - emaillength = msg[p + 6]; - emailfiller = msg[p + 7]; - - if (p + 8 + emaillength * 2 > len) - goto cleanup; - - email = ucs2_to_utf8(msg + p + 8, emaillength * 2); - DBG("EMAIL subblock: email %s", email); - break; - } - - case SIM_PB_STATUS: - if (p + 5 > len) - goto cleanup; - - status = msg[p + 4]; - DBG("STATUS subblock: status %i", status); - break; - - default: - DBG("Unknown subblock in read response: type %i length %i", - subblock_type, subblock_len); - break; - } - - p += subblock_len; - } - - if (status == SIM_SERV_OK) { - - ofono_phonebook_entry(pb, -1, number, -1, name, -1, NULL, - snr, -1, adn, email, NULL, NULL); - retval = location; - } - -cleanup: - g_free(name); - g_free(number); - g_free(adn); - g_free(snr); - g_free(email); - - return retval; -} - -static void read_next_entry(GIsiClient *client, int location, GIsiResponseFunc read_cb, struct isi_cb_data *cbd) -{ - ofono_phonebook_cb_t cb = cbd->cb; - const unsigned char msg[] = { - SIM_PB_REQ_SIM_PB_READ, - SIM_PB_READ, - 2, /* number of subblocks */ - 0, SIM_PB_LOCATION_SEARCH, /* subblock id */ - 0, 8, /* subblock size */ - 0, SIM_PB_ADN, - location >> 8, location & 0xFF, /* read next entry after specified by location */ - 0, SIM_PB_INFO_REQUEST, /* subblock id */ - 0, 16, /* subblock size */ - 4, /* number of tags */ - 0, /* filler */ - 0, SIM_PB_ADN, /* tags */ - 0, SIM_PB_SNE, - 0, SIM_PB_ANR, - 0, SIM_PB_EMAIL, - 0, 0 /* filler */ - }; - - if (location < 0) - goto error; - - if (!cbd) - goto error; - - if (g_isi_request_make(client, msg, sizeof(msg), PHONEBOOK_TIMEOUT, - read_cb, cbd)) - return; - -error: - { - DECLARE_FAILURE(error); - cb(&error, cbd->data); - g_free(cbd); - } -} - -static bool read_resp_cb(GIsiClient *client, const void *restrict data, - size_t len, uint16_t object, void *opaque) -{ - const unsigned char *msg = data; - struct isi_cb_data *cbd = opaque; - ofono_phonebook_cb_t cb = cbd->cb; - int location; - - if(!msg) { - DBG("ISI client error: %d", g_isi_client_error(client)); - goto error; - } - - location = decode_read_response(data, len, cbd->user); - if (location != -1) { - read_next_entry(client, location, read_resp_cb, cbd); - return true; - } - - { - DECLARE_SUCCESS(error); - cb(&error, cbd->data); - goto out; - } - -error: - { - DECLARE_FAILURE(error); - cb(&error, cbd->data); - } - -out: - g_free(cbd); - return true; -} - -static void isi_export_entries(struct ofono_phonebook *pb, const char *storage, - ofono_phonebook_cb_t cb, void *data) -{ - struct pb_data *pbd = ofono_phonebook_get_data(pb); - struct isi_cb_data *cbd = isi_cb_data_new(NULL, cb, data); - const unsigned char msg[] = { - SIM_PB_REQ_SIM_PB_READ, - SIM_PB_READ, - 2, /* number of subblocks */ - 0, SIM_PB_LOCATION, /* subblock id */ - 0, 8, /* subblock size */ - 0, SIM_PB_ADN, - 0xFF, 0xFF, /* read first entry in the phonebook */ - 0, SIM_PB_INFO_REQUEST, /* subblock id */ - 0, 16, /* subblock size */ - 4, /* number of tags */ - 0, /* filler */ - 0, SIM_PB_ADN, /* tags */ - 0, SIM_PB_SNE, - 0, SIM_PB_ANR, - 0, SIM_PB_EMAIL, - 0, 0 /* filler */ - }; - - if (!cbd) - goto error; - - if (strcmp(storage, "SM")) - goto error; - - cbd->user = pb; - - if (g_isi_request_make(pbd->client, msg, sizeof(msg), PHONEBOOK_TIMEOUT, - read_resp_cb, cbd)) - return; - -error: - if (cbd) - g_free(cbd); - - { - DECLARE_FAILURE(error); - cb(&error, data); - } -} - -static gboolean isi_phonebook_register(gpointer user) -{ - struct ofono_phonebook *pb = user; - - ofono_phonebook_register(pb); - - return FALSE; -} - -static int isi_phonebook_probe(struct ofono_phonebook *pb) -{ - GIsiModem *idx = ofono_phonebook_get_data(pb); - struct pb_data *data = g_try_new0(struct pb_data, 1); - - if (!data) - return -ENOMEM; - - DBG("idx=%p", idx); - - data->client = g_isi_client_create(idx, PN_SIM); - if (!data->client) { - g_free(data); - return -ENOMEM; - } - - ofono_phonebook_set_data(pb, data); - - /* FIXME: If this is running on a phone itself, phonebook - * initialization needs to be done here */ - - g_idle_add(isi_phonebook_register, pb); - - return 0; -} - -static int isi_phonebook_remove(struct ofono_phonebook *pb) -{ - struct pb_data *data = ofono_phonebook_get_data(pb); - - if (data) { - g_isi_client_destroy(data->client); - g_free(data); - } - - return 0; -} - -static struct ofono_phonebook_driver driver = { - .name = "isi", - .probe = isi_phonebook_probe, - .remove = isi_phonebook_remove, - .export_entries = isi_export_entries -}; - -void isi_phonebook_init() -{ - ofono_phonebook_driver_register(&driver); -} - -void isi_phonebook_exit() -{ - ofono_phonebook_driver_unregister(&driver); -} diff --git a/drivers/isimodem/isisim.c b/drivers/isimodem/isisim.c deleted file mode 100644 index e0e64252..00000000 --- a/drivers/isimodem/isisim.c +++ /dev/null @@ -1,150 +0,0 @@ -/* - * This file is part of oFono - Open Source Telephony - * - * Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). - * - * Contact: Aki Niemi - * - * 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 -#endif - -#define _GNU_SOURCE -#include -#include -#include -#include - -#include - -#include - -#include -#include -#include - -#include "isi.h" - -#define PN_SIM 0x09 - -struct sim_data { - GIsiClient *client; - struct isi_version version; -}; - -static void isi_read_file_info(struct ofono_sim *sim, int fileid, - ofono_sim_file_info_cb_t cb, void *data) -{ -} - -static void isi_read_file_transparent(struct ofono_sim *sim, int fileid, - int start, int length, - ofono_sim_read_cb_t cb, void *data) -{ -} - -static void isi_read_file_linear(struct ofono_sim *sim, int fileid, - int record, int length, - ofono_sim_read_cb_t cb, void *data) -{ -} - -static void isi_read_file_cyclic(struct ofono_sim *sim, int fileid, - int record, int length, - ofono_sim_read_cb_t cb, void *data) -{ -} - -static void isi_write_file_transparent(struct ofono_sim *sim, int fileid, - int start, int length, - const unsigned char *value, - ofono_sim_write_cb_t cb, void *data) -{ -} - -static void isi_write_file_linear(struct ofono_sim *sim, int fileid, - int record, int length, - const unsigned char *value, - ofono_sim_write_cb_t cb, void *data) -{ -} - -static void isi_write_file_cyclic(struct ofono_sim *sim, int fileid, - int length, const unsigned char *value, - ofono_sim_write_cb_t cb, void *data) -{ -} - -static void isi_read_imsi(struct ofono_sim *sim, - ofono_sim_imsi_cb_t cb, void *data) -{ -} - -static int isi_sim_probe(struct ofono_sim *sim) -{ - GIsiModem *idx = ofono_sim_get_data(sim); - struct sim_data *data = g_try_new0(struct sim_data, 1); - - if (!data) - return -ENOMEM; - - data->client = g_isi_client_create(idx, PN_SIM); - if (!data->client) - return -ENOMEM; - - ofono_sim_set_data(sim, data); - - return 0; -} - -static int isi_sim_remove(struct ofono_sim *sim) -{ - struct sim_data *data = ofono_sim_get_data(sim); - - if (data) { - g_isi_client_destroy(data->client); - g_free(data); - } - - return 0; -} - -static struct ofono_sim_driver driver = { - .name = "isi", - .probe = isi_sim_probe, - .remove = isi_sim_remove, - .read_file_info = isi_read_file_info, - .read_file_transparent = isi_read_file_transparent, - .read_file_linear = isi_read_file_linear, - .read_file_cyclic = isi_read_file_cyclic, - .write_file_transparent = isi_write_file_transparent, - .write_file_linear = isi_write_file_linear, - .write_file_cyclic = isi_write_file_cyclic, - .read_imsi = isi_read_imsi -}; - -void isi_sim_init() -{ - ofono_sim_driver_register(&driver); -} - -void isi_sim_exit() -{ - ofono_sim_driver_unregister(&driver); -} diff --git a/drivers/isimodem/isisms.c b/drivers/isimodem/isisms.c deleted file mode 100644 index 52ce4d1a..00000000 --- a/drivers/isimodem/isisms.c +++ /dev/null @@ -1,114 +0,0 @@ -/* - * This file is part of oFono - Open Source Telephony - * - * Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). - * - * Contact: Aki Niemi - * - * 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 -#endif - -#define _GNU_SOURCE -#include -#include -#include -#include - -#include - -#include - -#include -#include -#include - -#include "isi.h" - -#define PN_SMS 0x02 - -struct sms_data { - GIsiClient *client; - struct isi_version version; -}; - -static void isi_sca_query(struct ofono_sms *sms, ofono_sms_sca_query_cb_t cb, - void *data) -{ -} - -static void isi_sca_set(struct ofono_sms *sms, - const struct ofono_phone_number *sca, - ofono_sms_sca_set_cb_t cb, void *data) -{ -} - -static void isi_submit(struct ofono_sms *sms, unsigned char *pdu, - int pdu_len, int tpdu_len, int mms, - ofono_sms_submit_cb_t cb, void *data) -{ -} - -static int isi_sms_probe(struct ofono_sms *sms) -{ - GIsiModem *idx = ofono_sms_get_data(sms); - struct sms_data *data = g_try_new0(struct sms_data, 1); - - if (!data) - return -ENOMEM; - - data->client = g_isi_client_create(idx, PN_SMS); - if (!data->client) - return -ENOMEM; - - ofono_sms_set_data(sms, data); - - return 0; -} - -static int isi_sms_remove(struct ofono_sms *sms) -{ - struct sms_data *data = ofono_sms_get_data(sms); - - if (data) { - g_isi_client_destroy(data->client); - g_free(data); - } - - return 0; -} - -static struct ofono_sms_driver driver = { - .name = "isi", - .probe = isi_sms_probe, - .remove = isi_sms_remove, - .sca_query = isi_sca_query, - .sca_set = isi_sca_set, - .submit = isi_submit -}; - -void isi_sms_init() -{ - ofono_sms_driver_register(&driver); -} - -void isi_sms_exit() -{ - ofono_sms_driver_unregister(&driver); -} diff --git a/drivers/isimodem/isissn.c b/drivers/isimodem/isissn.c deleted file mode 100644 index 4225ffc2..00000000 --- a/drivers/isimodem/isissn.c +++ /dev/null @@ -1,94 +0,0 @@ -/* - * This file is part of oFono - Open Source Telephony - * - * Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). - * - * Contact: Aki Niemi - * - * 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 -#endif - -#define _GNU_SOURCE -#include -#include -#include -#include - -#include - -#include - -#include -#include -#include - -#include "isi.h" - -#define PN_SS 0x06 - -struct ssn_data { - GIsiClient *client; - struct isi_version version; -}; - -static int isi_ssn_probe(struct ofono_ssn *ssn) -{ - GIsiModem *idx = ofono_ssn_get_data(ssn); - struct ssn_data *data = g_try_new0(struct ssn_data, 1); - - if (!data) - return -ENOMEM; - - data->client = g_isi_client_create(idx, PN_SS); - if (!data->client) - return -ENOMEM; - - ofono_ssn_set_data(ssn, data); - - return 0; -} - -static int isi_ssn_remove(struct ofono_ssn *ssn) -{ - struct ssn_data *data = ofono_ssn_get_data(ssn); - - if (data) { - g_isi_client_destroy(data->client); - g_free(data); - } - - return 0; -} - -static struct ofono_ssn_driver driver = { - .name = "isi", - .probe = isi_ssn_probe, - .remove = isi_ssn_remove -}; - -void isi_ssn_init() -{ - ofono_ssn_driver_register(&driver); -} - -void isi_ssn_exit() -{ - ofono_ssn_driver_unregister(&driver); -} diff --git a/drivers/isimodem/isiussd.c b/drivers/isimodem/isiussd.c deleted file mode 100644 index e2cbd605..00000000 --- a/drivers/isimodem/isiussd.c +++ /dev/null @@ -1,106 +0,0 @@ -/* - * This file is part of oFono - Open Source Telephony - * - * Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). - * - * Contact: Aki Niemi - * - * 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 -#endif - -#define _GNU_SOURCE -#include -#include -#include -#include - -#include - -#include - -#include -#include -#include - -#include "isi.h" - -#define PN_SS 0x06 - -struct ussd_data { - GIsiClient *client; - struct isi_version version; -}; - -static void isi_request(struct ofono_ussd *ussd, const char *str, - ofono_ussd_cb_t cb, void *data) -{ -} - -static void isi_cancel(struct ofono_ussd *ussd, - ofono_ussd_cb_t cb, void *data) -{ -} - -static int isi_ussd_probe(struct ofono_ussd *ussd) -{ - GIsiModem *idx = ofono_ussd_get_data(ussd); - struct ussd_data *data = g_try_new0(struct ussd_data, 1); - - if (!data) - return -ENOMEM; - - data->client = g_isi_client_create(idx, PN_SS); - if (!data->client) - return -ENOMEM; - - ofono_ussd_set_data(ussd, data); - - return 0; -} - -static int isi_ussd_remove(struct ofono_ussd *ussd) -{ - struct ussd_data *data = ofono_ussd_get_data(ussd); - - if (data) { - g_isi_client_destroy(data->client); - g_free(data); - } - - return 0; -} - -static struct ofono_ussd_driver driver = { - .name = "isi", - .probe = isi_ussd_probe, - .remove = isi_ussd_remove, - .request = isi_request, - .cancel = isi_cancel -}; - -void isi_ussd_init() -{ - ofono_ussd_driver_register(&driver); -} - -void isi_ussd_exit() -{ - ofono_ussd_driver_unregister(&driver); -} diff --git a/drivers/isimodem/isivoicecall.c b/drivers/isimodem/isivoicecall.c deleted file mode 100644 index 423c0268..00000000 --- a/drivers/isimodem/isivoicecall.c +++ /dev/null @@ -1,188 +0,0 @@ -/* - * This file is part of oFono - Open Source Telephony - * - * Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). - * - * Contact: Aki Niemi - * - * 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 -#endif - -#define _GNU_SOURCE -#include -#include -#include -#include - -#include - -#include -#include - -#include -#include -#include - -#include "isi.h" - -#define PN_CALL 0x01 - -struct voicecall_data { - GIsiClient *client; - struct isi_version version; -}; - -static void isi_dial(struct ofono_voicecall *vc, - const struct ofono_phone_number *number, - enum ofono_clir_option clir, enum ofono_cug_option cug, - ofono_voicecall_cb_t cb, void *data) -{ -} - -static void isi_answer(struct ofono_voicecall *vc, - ofono_voicecall_cb_t cb, void *data) -{ -} - -static void isi_hangup(struct ofono_voicecall *vc, - ofono_voicecall_cb_t cb, void *data) -{ -} - -static void isi_list_calls(struct ofono_voicecall *vc, - ofono_call_list_cb_t cb, void *data) -{ -} - -static void isi_hold_all_active(struct ofono_voicecall *vc, - ofono_voicecall_cb_t cb, void *data) -{ -} - -static void isi_release_all_held(struct ofono_voicecall *vc, - ofono_voicecall_cb_t cb, void *data) -{ -} - -static void isi_set_udub(struct ofono_voicecall *vc, - ofono_voicecall_cb_t cb, void *data) -{ -} - -static void isi_release_all_active(struct ofono_voicecall *vc, - ofono_voicecall_cb_t cb, void *data) -{ -} - -static void isi_release_specific(struct ofono_voicecall *vc, int id, - ofono_voicecall_cb_t cb, void *data) -{ -} - -static void isi_private_chat(struct ofono_voicecall *vc, int id, - ofono_voicecall_cb_t cb, void *data) -{ -} - -static void isi_create_multiparty(struct ofono_voicecall *vc, - ofono_voicecall_cb_t cb, void *data) -{ -} - -static void isi_transfer(struct ofono_voicecall *vc, - ofono_voicecall_cb_t cb, void *data) -{ -} - -static void isi_deflect(struct ofono_voicecall *vc, - const struct ofono_phone_number *ph, - ofono_voicecall_cb_t cb, void *data) -{ -} - -static void isi_swap_without_accept(struct ofono_voicecall *vc, - ofono_voicecall_cb_t cb, void *data) -{ -} - -static void isi_send_tones(struct ofono_voicecall *vc, const char *tones, - ofono_voicecall_cb_t cb, void *data) -{ -} - -static int isi_voicecall_probe(struct ofono_voicecall *call) -{ - GIsiModem *idx = ofono_voicecall_get_data(call); - struct voicecall_data *data = g_try_new0(struct voicecall_data, 1); - - if (!data) - return -ENOMEM; - - data->client = g_isi_client_create(idx, PN_CALL); - if (!data->client) - return -ENOMEM; - - ofono_voicecall_set_data(call, data); - - return 0; -} - -static int isi_voicecall_remove(struct ofono_voicecall *call) -{ - struct voicecall_data *data = ofono_voicecall_get_data(call); - - if (data) { - g_isi_client_destroy(data->client); - g_free(data); - } - - return 0; -} - -static struct ofono_voicecall_driver driver = { - .name = "isi", - .probe = isi_voicecall_probe, - .remove = isi_voicecall_remove, - .dial = isi_dial, - .answer = isi_answer, - .hangup = isi_hangup, - .list_calls = isi_list_calls, - .hold_all_active = isi_hold_all_active, - .release_all_held = isi_release_all_held, - .set_udub = isi_set_udub, - .release_all_active = isi_release_all_active, - .release_specific = isi_release_specific, - .private_chat = isi_private_chat, - .create_multiparty = isi_create_multiparty, - .transfer = isi_transfer, - .deflect = isi_deflect, - .swap_without_accept = isi_swap_without_accept, - .send_tones = isi_send_tones, -}; - -void isi_voicecall_init() -{ - ofono_voicecall_driver_register(&driver); -} - -void isi_voicecall_exit() -{ - ofono_voicecall_driver_unregister(&driver); -} diff --git a/drivers/isimodem/network-registration.c b/drivers/isimodem/network-registration.c new file mode 100644 index 00000000..88483903 --- /dev/null +++ b/drivers/isimodem/network-registration.c @@ -0,0 +1,235 @@ +/* + * This file is part of oFono - Open Source Telephony + * + * Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). + * + * Contact: Aki Niemi + * + * 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 +#endif + +#define _GNU_SOURCE +#include +#include +#include +#include +#include + +#include + +#include +#include + +#include +#include +#include + +#include "isi.h" + +#define PN_NETWORK 0x0A +#define NETWORK_TIMEOUT 5 +#define NETWORK_SCAN_TIMEOUT 60 + +/* Used with COMMON_MESSAGE */ +enum sub_message_id { + COMM_ISI_VERSION_GET_REQ = 0x12, + COMM_ISI_VERSION_GET_RESP = 0x13, + COMM_ISA_ENTITY_NOT_REACHABLE_RESP = 0x14 +}; + +enum message_id { + NET_SET_REQ = 0x07, + NET_SET_RESP = 0x08, + NET_SET_CANCEL_REQ = 0x09, + NET_SET_CANCEL_RESP = 0x0A, + NET_RSSI_GET_REQ = 0x0B, + NET_RSSI_GET_RESP = 0x0C, + NET_RSSI_IND = 0x1E, + NET_NITZ_NAME_IND = 0x43, + NET_REG_STATUS_GET_REQ = 0xE0, + NET_REG_STATUS_GET_RESP = 0xE1, + NET_REG_STATUS_IND = 0xE2, + NET_AVAILABLE_GET_REQ = 0xE3, + NET_AVAILABLE_GET_RESP = 0xE4, + NET_OPER_NAME_GET_REQ = 0xE5, + NET_OPER_NAME_GET_RESP = 0xE6, + COMMON_MESSAGE = 0xF0 +}; + +enum sub_block_id { + NET_REG_INFO_COMMON = 0x00, + NET_RSSI_CURRENT = 0x04, + NET_GSM_REG_INFO = 0x09, + NET_GSM_BAND_INFO = 0x11 +}; + +enum reg_status { + NET_REG_STATUS_HOME = 0x00, + NET_REG_STATUS_ROAM = 0x01, + NET_REG_STATUS_NOSERV = 0x03, + NET_REG_STATUS_NOSERV_SEARCHING = 0x04, + NET_REG_STATUS_NOSERV_NOTSEARCHING = 0x05, + NET_REG_STATUS_NOSERV_NOSIM = 0x06, + NET_REG_STATUS_POWER_OFF = 0x08, + NET_REG_STATUS_NSPS = 0x09, + NET_REG_STATUS_NSPS_NO_COVERAGE = 0x0A, + NET_REG_STATUS_NOSERV_SIM_REJECTED_BY_NW = 0x0B +}; + +enum cs_type { + NET_CS_GSM = 0x00 +}; + +enum measurement_type { + NET_CURRENT_CELL_RSSI = 0x02 +}; + +enum search_mode { + NET_MANUAL_SEARCH = 0x00 +}; + +enum band_info { + NET_GSM_BAND_ALL_SUPPORTED_BANDS = 0x03 +}; + +enum select_mode { + NET_SELECT_MODE_UNKNOWN = 0x00, + NET_SELECT_MODE_MANUAL = 0x01, + NET_SELECT_MODE_AUTOMATIC = 0x02 +}; + +enum return_code { + NET_CAUSE_OK = 0x00, + NET_CAUSE_COMMUNICATION_ERROR = 0x01, + NET_CAUSE_NET_NOT_FOUND = 0x05, + NET_CAUSE_NO_SELECTED_NETWORK = 0x11 +}; + +struct netreg_data { + GIsiClient *client; + struct isi_version version; +}; + +static void isi_registration_status(struct ofono_netreg *netreg, + ofono_netreg_status_cb_t cb, + void *data) +{ +} + +static void isi_current_operator(struct ofono_netreg *netreg, + ofono_netreg_operator_cb_t cb, + void *data) +{ +} + +static void isi_list_operators(struct ofono_netreg *netreg, + ofono_netreg_operator_list_cb_t cb, + void *data) +{ +} + +static void isi_register_auto(struct ofono_netreg *netreg, + ofono_netreg_register_cb_t cb, + void *data) +{ +} + +static void isi_register_manual(struct ofono_netreg *netreg, + const struct ofono_network_operator *oper, + ofono_netreg_register_cb_t cb, void *data) +{ +} + +static void isi_deregister(struct ofono_netreg *netreg, + ofono_netreg_register_cb_t cb, + void *data) +{ +} + +static void isi_strength(struct ofono_netreg *netreg, + ofono_netreg_strength_cb_t cb, + void *data) +{ +} + +static gboolean isi_netreg_register(gpointer user) +{ + struct ofono_netreg *net = user; + + ofono_netreg_register(net); + + return FALSE; +} + +static int isi_netreg_probe(struct ofono_netreg *netreg) +{ + GIsiModem *idx = ofono_netreg_get_data(netreg); + struct netreg_data *user = g_try_new0(struct netreg_data, 1); + + if (!user) + return -ENOMEM; + + user->client = g_isi_client_create(idx, PN_NETWORK); + if (!user->client) { + g_free(user); + return -ENOMEM; + } + + ofono_netreg_set_data(netreg, user); + + g_idle_add(isi_netreg_register, netreg); + + return 0; +} + +static int isi_netreg_remove(struct ofono_netreg *net) +{ + struct netreg_data *data = ofono_netreg_get_data(net); + + if (data && data->client) { + g_isi_client_destroy(data->client); + g_free(data); + } + + return 0; +} + +static struct ofono_netreg_driver driver = { + .name = "isi", + .probe = isi_netreg_probe, + .remove = isi_netreg_remove, + .registration_status = isi_registration_status, + .current_operator = isi_current_operator, + .list_operators = isi_list_operators, + .register_auto = isi_register_auto, + .register_manual = isi_register_manual, + .deregister = isi_deregister, + .strength = isi_strength, +}; + +void isi_netreg_init() +{ + ofono_netreg_driver_register(&driver); +} + +void isi_netreg_exit() +{ + ofono_netreg_driver_unregister(&driver); +} diff --git a/drivers/isimodem/phonebook.c b/drivers/isimodem/phonebook.c new file mode 100644 index 00000000..7c544741 --- /dev/null +++ b/drivers/isimodem/phonebook.c @@ -0,0 +1,432 @@ +/* + * This file is part of oFono - Open Source Telephony + * + * Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). + * + * Contact: Alexander Kanavin + * + * 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 +#endif + +#include +#include +#include +#include + +#include +#include + +#include +#include +#include +#include "util.h" + +#include "isi.h" + +#define PHONEBOOK_TIMEOUT 5 +#define PN_SIM 0x09 + +enum pb_message_id { + SIM_PB_REQ_SIM_PB_READ = 0xDC, + SIM_PB_RESP_SIM_PB_READ = 0xDD +}; + +enum pb_service_types { + SIM_PB_READ = 0x0F +}; + +enum pb_sub_block_id { + SIM_PB_INFO_REQUEST = 0xE4, + SIM_PB_STATUS = 0xFB, + SIM_PB_LOCATION = 0xFE, + SIM_PB_LOCATION_SEARCH = 0xFF +}; + +enum pb_type { + SIM_PB_ADN = 0xC8 +}; + +enum pb_tag { + SIM_PB_ANR = 0xCA, + SIM_PB_EMAIL = 0xDD, + SIM_PB_SNE = 0xF7 +}; + +enum pb_status { + SIM_SERV_OK = 0x01 +}; + +struct pb_data { + GIsiClient *client; +}; + +static char *ucs2_to_utf8(const unsigned char *str, long len) +{ + char *utf8; + utf8 = g_convert((const char *)str, len, "UTF-8//TRANSLIT", "UCS-2BE", + NULL, NULL, NULL); + return utf8; +} + +static int decode_read_response(const unsigned char *msg, size_t len, + struct ofono_phonebook *pb) +{ + int retval = -1; + + unsigned int i; + unsigned int p; + + char *name = NULL; + char *number = NULL; + char *adn = NULL; + char *snr = NULL; + char *email = NULL; + + unsigned int location = 0; + unsigned int status = 0; + + unsigned int messageid; + unsigned int servicetype; + unsigned int num_subblocks; + + if (len < 3) + goto cleanup; + + messageid = msg[0]; + servicetype = msg[1]; + num_subblocks = msg[2]; + + if (messageid != SIM_PB_RESP_SIM_PB_READ || servicetype != SIM_PB_READ) + goto cleanup; + + p = 3; + for (i=0; i < num_subblocks; i++) { + unsigned int subblock_type; + unsigned int subblock_len; + + if (p + 4 > len) + goto cleanup; + + subblock_type = (msg[p] << 8) + msg[p + 1]; + subblock_len = (msg[p + 2] << 8) + msg[p + 3]; + + switch (subblock_type) { + + case SIM_PB_ADN: { + unsigned int namelength; + unsigned int numberlength; + + if (p + 8 > len) + goto cleanup; + + location = (msg[p + 4] << 8) + msg[p + 5]; + namelength = msg[p + 6]; + numberlength = msg[p + 7]; + + if (p + 8 + namelength * 2 + numberlength * 2 > len) + goto cleanup; + + name = ucs2_to_utf8(msg + p + 8, namelength * 2); + number = ucs2_to_utf8(msg + p + 8 + namelength * 2, + numberlength * 2); + DBG("ADN subblock: name %s number %s location %i", + name, number, location); + break; + } + + case SIM_PB_SNE: { + unsigned int locsne; + unsigned int snelength; + unsigned int snefiller; + + if (p + 8 > len) + goto cleanup; + + locsne = (msg[p + 4] << 8) + msg[p + 5]; + snelength = msg[p + 6]; + snefiller = msg[p + 7]; + + if (p + 8 + snelength * 2 > len) + goto cleanup; + + adn = ucs2_to_utf8(msg + p + 8, snelength * 2); + DBG("SNE subblock: name %s", adn); + break; + } + + case SIM_PB_ANR: { + unsigned int locanr; + unsigned int anrlength; + unsigned int anrfiller; + + if (p + 8 > len) + goto cleanup; + + locanr = (msg[p + 4] << 8) + msg[p + 5]; + anrlength = msg[p + 6]; + anrfiller = msg[p + 7]; + + if (p + 8 + anrlength * 2 > len) + goto cleanup; + + snr = ucs2_to_utf8(msg + p + 8, anrlength * 2); + DBG("ANR subblock: number %s", snr); + break; + } + + case SIM_PB_EMAIL: { + unsigned int locemail; + unsigned int emaillength; + unsigned int emailfiller; + + if (p + 8 > len) + goto cleanup; + + locemail = (msg[p + 4] << 8) + msg[p + 5]; + emaillength = msg[p + 6]; + emailfiller = msg[p + 7]; + + if (p + 8 + emaillength * 2 > len) + goto cleanup; + + email = ucs2_to_utf8(msg + p + 8, emaillength * 2); + DBG("EMAIL subblock: email %s", email); + break; + } + + case SIM_PB_STATUS: + if (p + 5 > len) + goto cleanup; + + status = msg[p + 4]; + DBG("STATUS subblock: status %i", status); + break; + + default: + DBG("Unknown subblock in read response: type %i length %i", + subblock_type, subblock_len); + break; + } + + p += subblock_len; + } + + if (status == SIM_SERV_OK) { + + ofono_phonebook_entry(pb, -1, number, -1, name, -1, NULL, + snr, -1, adn, email, NULL, NULL); + retval = location; + } + +cleanup: + g_free(name); + g_free(number); + g_free(adn); + g_free(snr); + g_free(email); + + return retval; +} + +static void read_next_entry(GIsiClient *client, int location, GIsiResponseFunc read_cb, struct isi_cb_data *cbd) +{ + ofono_phonebook_cb_t cb = cbd->cb; + const unsigned char msg[] = { + SIM_PB_REQ_SIM_PB_READ, + SIM_PB_READ, + 2, /* number of subblocks */ + 0, SIM_PB_LOCATION_SEARCH, /* subblock id */ + 0, 8, /* subblock size */ + 0, SIM_PB_ADN, + location >> 8, location & 0xFF, /* read next entry after specified by location */ + 0, SIM_PB_INFO_REQUEST, /* subblock id */ + 0, 16, /* subblock size */ + 4, /* number of tags */ + 0, /* filler */ + 0, SIM_PB_ADN, /* tags */ + 0, SIM_PB_SNE, + 0, SIM_PB_ANR, + 0, SIM_PB_EMAIL, + 0, 0 /* filler */ + }; + + if (location < 0) + goto error; + + if (!cbd) + goto error; + + if (g_isi_request_make(client, msg, sizeof(msg), PHONEBOOK_TIMEOUT, + read_cb, cbd)) + return; + +error: + { + DECLARE_FAILURE(error); + cb(&error, cbd->data); + g_free(cbd); + } +} + +static bool read_resp_cb(GIsiClient *client, const void *restrict data, + size_t len, uint16_t object, void *opaque) +{ + const unsigned char *msg = data; + struct isi_cb_data *cbd = opaque; + ofono_phonebook_cb_t cb = cbd->cb; + int location; + + if(!msg) { + DBG("ISI client error: %d", g_isi_client_error(client)); + goto error; + } + + location = decode_read_response(data, len, cbd->user); + if (location != -1) { + read_next_entry(client, location, read_resp_cb, cbd); + return true; + } + + { + DECLARE_SUCCESS(error); + cb(&error, cbd->data); + goto out; + } + +error: + { + DECLARE_FAILURE(error); + cb(&error, cbd->data); + } + +out: + g_free(cbd); + return true; +} + +static void isi_export_entries(struct ofono_phonebook *pb, const char *storage, + ofono_phonebook_cb_t cb, void *data) +{ + struct pb_data *pbd = ofono_phonebook_get_data(pb); + struct isi_cb_data *cbd = isi_cb_data_new(NULL, cb, data); + const unsigned char msg[] = { + SIM_PB_REQ_SIM_PB_READ, + SIM_PB_READ, + 2, /* number of subblocks */ + 0, SIM_PB_LOCATION, /* subblock id */ + 0, 8, /* subblock size */ + 0, SIM_PB_ADN, + 0xFF, 0xFF, /* read first entry in the phonebook */ + 0, SIM_PB_INFO_REQUEST, /* subblock id */ + 0, 16, /* subblock size */ + 4, /* number of tags */ + 0, /* filler */ + 0, SIM_PB_ADN, /* tags */ + 0, SIM_PB_SNE, + 0, SIM_PB_ANR, + 0, SIM_PB_EMAIL, + 0, 0 /* filler */ + }; + + if (!cbd) + goto error; + + if (strcmp(storage, "SM")) + goto error; + + cbd->user = pb; + + if (g_isi_request_make(pbd->client, msg, sizeof(msg), PHONEBOOK_TIMEOUT, + read_resp_cb, cbd)) + return; + +error: + if (cbd) + g_free(cbd); + + { + DECLARE_FAILURE(error); + cb(&error, data); + } +} + +static gboolean isi_phonebook_register(gpointer user) +{ + struct ofono_phonebook *pb = user; + + ofono_phonebook_register(pb); + + return FALSE; +} + +static int isi_phonebook_probe(struct ofono_phonebook *pb) +{ + GIsiModem *idx = ofono_phonebook_get_data(pb); + struct pb_data *data = g_try_new0(struct pb_data, 1); + + if (!data) + return -ENOMEM; + + DBG("idx=%p", idx); + + data->client = g_isi_client_create(idx, PN_SIM); + if (!data->client) { + g_free(data); + return -ENOMEM; + } + + ofono_phonebook_set_data(pb, data); + + /* FIXME: If this is running on a phone itself, phonebook + * initialization needs to be done here */ + + g_idle_add(isi_phonebook_register, pb); + + return 0; +} + +static int isi_phonebook_remove(struct ofono_phonebook *pb) +{ + struct pb_data *data = ofono_phonebook_get_data(pb); + + if (data) { + g_isi_client_destroy(data->client); + g_free(data); + } + + return 0; +} + +static struct ofono_phonebook_driver driver = { + .name = "isi", + .probe = isi_phonebook_probe, + .remove = isi_phonebook_remove, + .export_entries = isi_export_entries +}; + +void isi_phonebook_init() +{ + ofono_phonebook_driver_register(&driver); +} + +void isi_phonebook_exit() +{ + ofono_phonebook_driver_unregister(&driver); +} diff --git a/drivers/isimodem/sim.c b/drivers/isimodem/sim.c new file mode 100644 index 00000000..e0e64252 --- /dev/null +++ b/drivers/isimodem/sim.c @@ -0,0 +1,150 @@ +/* + * This file is part of oFono - Open Source Telephony + * + * Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). + * + * Contact: Aki Niemi + * + * 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 +#endif + +#define _GNU_SOURCE +#include +#include +#include +#include + +#include + +#include + +#include +#include +#include + +#include "isi.h" + +#define PN_SIM 0x09 + +struct sim_data { + GIsiClient *client; + struct isi_version version; +}; + +static void isi_read_file_info(struct ofono_sim *sim, int fileid, + ofono_sim_file_info_cb_t cb, void *data) +{ +} + +static void isi_read_file_transparent(struct ofono_sim *sim, int fileid, + int start, int length, + ofono_sim_read_cb_t cb, void *data) +{ +} + +static void isi_read_file_linear(struct ofono_sim *sim, int fileid, + int record, int length, + ofono_sim_read_cb_t cb, void *data) +{ +} + +static void isi_read_file_cyclic(struct ofono_sim *sim, int fileid, + int record, int length, + ofono_sim_read_cb_t cb, void *data) +{ +} + +static void isi_write_file_transparent(struct ofono_sim *sim, int fileid, + int start, int length, + const unsigned char *value, + ofono_sim_write_cb_t cb, void *data) +{ +} + +static void isi_write_file_linear(struct ofono_sim *sim, int fileid, + int record, int length, + const unsigned char *value, + ofono_sim_write_cb_t cb, void *data) +{ +} + +static void isi_write_file_cyclic(struct ofono_sim *sim, int fileid, + int length, const unsigned char *value, + ofono_sim_write_cb_t cb, void *data) +{ +} + +static void isi_read_imsi(struct ofono_sim *sim, + ofono_sim_imsi_cb_t cb, void *data) +{ +} + +static int isi_sim_probe(struct ofono_sim *sim) +{ + GIsiModem *idx = ofono_sim_get_data(sim); + struct sim_data *data = g_try_new0(struct sim_data, 1); + + if (!data) + return -ENOMEM; + + data->client = g_isi_client_create(idx, PN_SIM); + if (!data->client) + return -ENOMEM; + + ofono_sim_set_data(sim, data); + + return 0; +} + +static int isi_sim_remove(struct ofono_sim *sim) +{ + struct sim_data *data = ofono_sim_get_data(sim); + + if (data) { + g_isi_client_destroy(data->client); + g_free(data); + } + + return 0; +} + +static struct ofono_sim_driver driver = { + .name = "isi", + .probe = isi_sim_probe, + .remove = isi_sim_remove, + .read_file_info = isi_read_file_info, + .read_file_transparent = isi_read_file_transparent, + .read_file_linear = isi_read_file_linear, + .read_file_cyclic = isi_read_file_cyclic, + .write_file_transparent = isi_write_file_transparent, + .write_file_linear = isi_write_file_linear, + .write_file_cyclic = isi_write_file_cyclic, + .read_imsi = isi_read_imsi +}; + +void isi_sim_init() +{ + ofono_sim_driver_register(&driver); +} + +void isi_sim_exit() +{ + ofono_sim_driver_unregister(&driver); +} diff --git a/drivers/isimodem/sms.c b/drivers/isimodem/sms.c new file mode 100644 index 00000000..52ce4d1a --- /dev/null +++ b/drivers/isimodem/sms.c @@ -0,0 +1,114 @@ +/* + * This file is part of oFono - Open Source Telephony + * + * Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). + * + * Contact: Aki Niemi + * + * 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 +#endif + +#define _GNU_SOURCE +#include +#include +#include +#include + +#include + +#include + +#include +#include +#include + +#include "isi.h" + +#define PN_SMS 0x02 + +struct sms_data { + GIsiClient *client; + struct isi_version version; +}; + +static void isi_sca_query(struct ofono_sms *sms, ofono_sms_sca_query_cb_t cb, + void *data) +{ +} + +static void isi_sca_set(struct ofono_sms *sms, + const struct ofono_phone_number *sca, + ofono_sms_sca_set_cb_t cb, void *data) +{ +} + +static void isi_submit(struct ofono_sms *sms, unsigned char *pdu, + int pdu_len, int tpdu_len, int mms, + ofono_sms_submit_cb_t cb, void *data) +{ +} + +static int isi_sms_probe(struct ofono_sms *sms) +{ + GIsiModem *idx = ofono_sms_get_data(sms); + struct sms_data *data = g_try_new0(struct sms_data, 1); + + if (!data) + return -ENOMEM; + + data->client = g_isi_client_create(idx, PN_SMS); + if (!data->client) + return -ENOMEM; + + ofono_sms_set_data(sms, data); + + return 0; +} + +static int isi_sms_remove(struct ofono_sms *sms) +{ + struct sms_data *data = ofono_sms_get_data(sms); + + if (data) { + g_isi_client_destroy(data->client); + g_free(data); + } + + return 0; +} + +static struct ofono_sms_driver driver = { + .name = "isi", + .probe = isi_sms_probe, + .remove = isi_sms_remove, + .sca_query = isi_sca_query, + .sca_set = isi_sca_set, + .submit = isi_submit +}; + +void isi_sms_init() +{ + ofono_sms_driver_register(&driver); +} + +void isi_sms_exit() +{ + ofono_sms_driver_unregister(&driver); +} diff --git a/drivers/isimodem/ssn.c b/drivers/isimodem/ssn.c new file mode 100644 index 00000000..4225ffc2 --- /dev/null +++ b/drivers/isimodem/ssn.c @@ -0,0 +1,94 @@ +/* + * This file is part of oFono - Open Source Telephony + * + * Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). + * + * Contact: Aki Niemi + * + * 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 +#endif + +#define _GNU_SOURCE +#include +#include +#include +#include + +#include + +#include + +#include +#include +#include + +#include "isi.h" + +#define PN_SS 0x06 + +struct ssn_data { + GIsiClient *client; + struct isi_version version; +}; + +static int isi_ssn_probe(struct ofono_ssn *ssn) +{ + GIsiModem *idx = ofono_ssn_get_data(ssn); + struct ssn_data *data = g_try_new0(struct ssn_data, 1); + + if (!data) + return -ENOMEM; + + data->client = g_isi_client_create(idx, PN_SS); + if (!data->client) + return -ENOMEM; + + ofono_ssn_set_data(ssn, data); + + return 0; +} + +static int isi_ssn_remove(struct ofono_ssn *ssn) +{ + struct ssn_data *data = ofono_ssn_get_data(ssn); + + if (data) { + g_isi_client_destroy(data->client); + g_free(data); + } + + return 0; +} + +static struct ofono_ssn_driver driver = { + .name = "isi", + .probe = isi_ssn_probe, + .remove = isi_ssn_remove +}; + +void isi_ssn_init() +{ + ofono_ssn_driver_register(&driver); +} + +void isi_ssn_exit() +{ + ofono_ssn_driver_unregister(&driver); +} diff --git a/drivers/isimodem/ussd.c b/drivers/isimodem/ussd.c new file mode 100644 index 00000000..e2cbd605 --- /dev/null +++ b/drivers/isimodem/ussd.c @@ -0,0 +1,106 @@ +/* + * This file is part of oFono - Open Source Telephony + * + * Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). + * + * Contact: Aki Niemi + * + * 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 +#endif + +#define _GNU_SOURCE +#include +#include +#include +#include + +#include + +#include + +#include +#include +#include + +#include "isi.h" + +#define PN_SS 0x06 + +struct ussd_data { + GIsiClient *client; + struct isi_version version; +}; + +static void isi_request(struct ofono_ussd *ussd, const char *str, + ofono_ussd_cb_t cb, void *data) +{ +} + +static void isi_cancel(struct ofono_ussd *ussd, + ofono_ussd_cb_t cb, void *data) +{ +} + +static int isi_ussd_probe(struct ofono_ussd *ussd) +{ + GIsiModem *idx = ofono_ussd_get_data(ussd); + struct ussd_data *data = g_try_new0(struct ussd_data, 1); + + if (!data) + return -ENOMEM; + + data->client = g_isi_client_create(idx, PN_SS); + if (!data->client) + return -ENOMEM; + + ofono_ussd_set_data(ussd, data); + + return 0; +} + +static int isi_ussd_remove(struct ofono_ussd *ussd) +{ + struct ussd_data *data = ofono_ussd_get_data(ussd); + + if (data) { + g_isi_client_destroy(data->client); + g_free(data); + } + + return 0; +} + +static struct ofono_ussd_driver driver = { + .name = "isi", + .probe = isi_ussd_probe, + .remove = isi_ussd_remove, + .request = isi_request, + .cancel = isi_cancel +}; + +void isi_ussd_init() +{ + ofono_ussd_driver_register(&driver); +} + +void isi_ussd_exit() +{ + ofono_ussd_driver_unregister(&driver); +} diff --git a/drivers/isimodem/voicecall.c b/drivers/isimodem/voicecall.c new file mode 100644 index 00000000..423c0268 --- /dev/null +++ b/drivers/isimodem/voicecall.c @@ -0,0 +1,188 @@ +/* + * This file is part of oFono - Open Source Telephony + * + * Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). + * + * Contact: Aki Niemi + * + * 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 +#endif + +#define _GNU_SOURCE +#include +#include +#include +#include + +#include + +#include +#include + +#include +#include +#include + +#include "isi.h" + +#define PN_CALL 0x01 + +struct voicecall_data { + GIsiClient *client; + struct isi_version version; +}; + +static void isi_dial(struct ofono_voicecall *vc, + const struct ofono_phone_number *number, + enum ofono_clir_option clir, enum ofono_cug_option cug, + ofono_voicecall_cb_t cb, void *data) +{ +} + +static void isi_answer(struct ofono_voicecall *vc, + ofono_voicecall_cb_t cb, void *data) +{ +} + +static void isi_hangup(struct ofono_voicecall *vc, + ofono_voicecall_cb_t cb, void *data) +{ +} + +static void isi_list_calls(struct ofono_voicecall *vc, + ofono_call_list_cb_t cb, void *data) +{ +} + +static void isi_hold_all_active(struct ofono_voicecall *vc, + ofono_voicecall_cb_t cb, void *data) +{ +} + +static void isi_release_all_held(struct ofono_voicecall *vc, + ofono_voicecall_cb_t cb, void *data) +{ +} + +static void isi_set_udub(struct ofono_voicecall *vc, + ofono_voicecall_cb_t cb, void *data) +{ +} + +static void isi_release_all_active(struct ofono_voicecall *vc, + ofono_voicecall_cb_t cb, void *data) +{ +} + +static void isi_release_specific(struct ofono_voicecall *vc, int id, + ofono_voicecall_cb_t cb, void *data) +{ +} + +static void isi_private_chat(struct ofono_voicecall *vc, int id, + ofono_voicecall_cb_t cb, void *data) +{ +} + +static void isi_create_multiparty(struct ofono_voicecall *vc, + ofono_voicecall_cb_t cb, void *data) +{ +} + +static void isi_transfer(struct ofono_voicecall *vc, + ofono_voicecall_cb_t cb, void *data) +{ +} + +static void isi_deflect(struct ofono_voicecall *vc, + const struct ofono_phone_number *ph, + ofono_voicecall_cb_t cb, void *data) +{ +} + +static void isi_swap_without_accept(struct ofono_voicecall *vc, + ofono_voicecall_cb_t cb, void *data) +{ +} + +static void isi_send_tones(struct ofono_voicecall *vc, const char *tones, + ofono_voicecall_cb_t cb, void *data) +{ +} + +static int isi_voicecall_probe(struct ofono_voicecall *call) +{ + GIsiModem *idx = ofono_voicecall_get_data(call); + struct voicecall_data *data = g_try_new0(struct voicecall_data, 1); + + if (!data) + return -ENOMEM; + + data->client = g_isi_client_create(idx, PN_CALL); + if (!data->client) + return -ENOMEM; + + ofono_voicecall_set_data(call, data); + + return 0; +} + +static int isi_voicecall_remove(struct ofono_voicecall *call) +{ + struct voicecall_data *data = ofono_voicecall_get_data(call); + + if (data) { + g_isi_client_destroy(data->client); + g_free(data); + } + + return 0; +} + +static struct ofono_voicecall_driver driver = { + .name = "isi", + .probe = isi_voicecall_probe, + .remove = isi_voicecall_remove, + .dial = isi_dial, + .answer = isi_answer, + .hangup = isi_hangup, + .list_calls = isi_list_calls, + .hold_all_active = isi_hold_all_active, + .release_all_held = isi_release_all_held, + .set_udub = isi_set_udub, + .release_all_active = isi_release_all_active, + .release_specific = isi_release_specific, + .private_chat = isi_private_chat, + .create_multiparty = isi_create_multiparty, + .transfer = isi_transfer, + .deflect = isi_deflect, + .swap_without_accept = isi_swap_without_accept, + .send_tones = isi_send_tones, +}; + +void isi_voicecall_init() +{ + ofono_voicecall_driver_register(&driver); +} + +void isi_voicecall_exit() +{ + ofono_voicecall_driver_unregister(&driver); +} -- cgit v1.2.3