/* * Indicate oFono that a SMS driver is ready for operation * * This is called after ofono_sms_create() was done and the modem * driver determined that a modem supports SMS correctly. Once this * call succeeds, the D-BUS interface for SMS goes live. */ void ofono_sms_register(struct ofono_sms *sms) { DBusConnection *conn = ofono_dbus_get_connection(); struct ofono_modem *modem = __ofono_atom_get_modem(sms->atom); const char *path = __ofono_atom_get_path(sms->atom); struct ofono_sim *sim; if (!g_dbus_register_interface(conn, path, OFONO_MESSAGE_MANAGER_INTERFACE, sms_manager_methods, sms_manager_signals, NULL, sms, NULL)) { ofono_error("Could not create %s interface", OFONO_MESSAGE_MANAGER_INTERFACE); return; } ofono_modem_add_interface(modem, OFONO_MESSAGE_MANAGER_INTERFACE); sms->mw_watch = __ofono_modem_add_atom_watch(modem, OFONO_ATOM_TYPE_MESSAGE_WAITING, mw_watch, sms, NULL); sms->netreg_watch = __ofono_modem_add_atom_watch(modem, OFONO_ATOM_TYPE_NETREG, netreg_watch, sms, NULL); sim = __ofono_atom_find(OFONO_ATOM_TYPE_SIM, modem); /* * If we have a sim atom, we can uniquely identify the SIM, * otherwise create an sms assembly which doesn't backup the fragment * store. */ if (sim) { const char *imsi; imsi = ofono_sim_get_imsi(sim); sms->assembly = sms_assembly_new(imsi); sms->sr_assembly = status_report_assembly_new(imsi); sms_load_settings(sms, imsi); } else { sms->assembly = sms_assembly_new(NULL); sms->sr_assembly = status_report_assembly_new(NULL); sms->bearer = 3; /* Default to CS then PS */ } if (sms->driver->bearer_set) sms->driver->bearer_set(sms, sms->bearer, bearer_init_callback, sms); sms_restore_tx_queue(sms); sms->text_handlers = __ofono_watchlist_new(g_free); sms->datagram_handlers = __ofono_watchlist_new(g_free); __ofono_atom_register(sms->atom, sms_unregister); }
static gboolean ril_roaming_allowed() { GError *error; error = NULL; GKeyFile *settings; struct ofono_sim *sim; sim = get_sim(); const char *imsi = ofono_sim_get_imsi(sim); settings = storage_open(imsi, "gprs"); gboolean roaming_allowed = g_key_file_get_boolean(settings, "Settings", "RoamingAllowed", &error); if (error) g_error_free(error); storage_close(imsi, "gprs", settings, FALSE); return roaming_allowed; }
/* * sim_state_watch listens to SIM state changes and creates/removes atoms * accordingly. This is needed because we cannot rely on the modem core code, * which handles modem state transitions, to do this due to the SIM not being * accessible in the offline state for mtk modems. This causes a mismatch * between what the core thinks it can do in some states and what the mtk modem * can really do in those. This is a workaround to solve that. */ static void sim_state_watch(enum ofono_sim_state new_state, void *data) { struct ofono_modem *modem = data; struct mtk_data *md = ofono_modem_get_data(modem); if (new_state == OFONO_SIM_STATE_READY) { struct ofono_gprs_context *gc; struct ril_gprs_driver_data gprs_data = { md->ril, modem }; struct ril_gprs_context_data inet_ctx = { md->ril, OFONO_GPRS_CONTEXT_TYPE_INTERNET }; struct ril_gprs_context_data mms_ctx = { md->ril, OFONO_GPRS_CONTEXT_TYPE_MMS }; DBG("SIM ready, creating more atoms"); /* * TODO: this function should setup: * - stk ( SIM toolkit ) */ md->sms = ofono_sms_create(modem, OFONO_RIL_VENDOR_MTK, RILMODEM, md->ril); /* netreg needs access to the SIM (SPN, SPDI) */ md->netreg = ofono_netreg_create(modem, OFONO_RIL_VENDOR_MTK, RILMODEM, md->ril); md->ussd = ofono_ussd_create(modem, OFONO_RIL_VENDOR_MTK, RILMODEM, md->ril); md->call_settings = ofono_call_settings_create(modem, OFONO_RIL_VENDOR_MTK, RILMODEM, md->ril); md->call_forwarding = ofono_call_forwarding_create(modem, OFONO_RIL_VENDOR_MTK, RILMODEM, md->ril); md->call_barring = ofono_call_barring_create(modem, OFONO_RIL_VENDOR_MTK, RILMODEM, md->ril); md->phonebook = ofono_phonebook_create(modem, OFONO_RIL_VENDOR_MTK, RILMODEM, modem); md->gprs = ofono_gprs_create(modem, OFONO_RIL_VENDOR_MTK, MTKMODEM, &gprs_data); gc = ofono_gprs_context_create(modem, OFONO_RIL_VENDOR_MTK, RILMODEM, &inet_ctx); if (gc) { ofono_gprs_context_set_type(gc, OFONO_GPRS_CONTEXT_TYPE_INTERNET); ofono_gprs_add_context(md->gprs, gc); } gc = ofono_gprs_context_create(modem, OFONO_RIL_VENDOR_MTK, RILMODEM, &mms_ctx); if (gc) { ofono_gprs_context_set_type(gc, OFONO_GPRS_CONTEXT_TYPE_MMS); ofono_gprs_add_context(md->gprs, gc); } md->message_waiting = ofono_message_waiting_create(modem); if (md->message_waiting) ofono_message_waiting_register(md->message_waiting); /* * Now that we can access IMSI, see if a FW change is needed. */ md->sim_plmn_type = get_plmn_type(ofono_sim_get_imsi(md->sim)); check_modem_fw(modem); } else if (new_state == OFONO_SIM_STATE_LOCKED_OUT) { DBG("SIM locked, removing atoms"); if (md->message_waiting) { ofono_message_waiting_remove(md->message_waiting); md->message_waiting = NULL; } if (md->gprs) { ofono_gprs_remove(md->gprs); md->gprs = NULL; } if (md->phonebook) { ofono_phonebook_remove(md->phonebook); md->phonebook = NULL; } if (md->call_barring) { ofono_call_barring_remove(md->call_barring); md->call_barring = NULL; } if (md->call_forwarding) { ofono_call_forwarding_remove(md->call_forwarding); md->call_forwarding = NULL; } if (md->call_settings) { ofono_call_settings_remove(md->call_settings); md->call_settings = NULL; } if (md->ussd) { ofono_ussd_remove(md->ussd); md->ussd = NULL; } if (md->netreg) { ofono_netreg_remove(md->netreg); md->netreg = NULL; } if (md->sms) { ofono_sms_remove(md->sms); md->sms = NULL; } } }