static DBusMessage *gnss_register_agent(DBusConnection *conn, DBusMessage *msg, void *data) { struct ofono_gnss *gnss = data; const char *agent_path; if (gnss->pending) return __ofono_error_busy(msg); if (gnss->posr_agent) return __ofono_error_busy(msg); if (dbus_message_get_args(msg, NULL, DBUS_TYPE_OBJECT_PATH, &agent_path, DBUS_TYPE_INVALID) == FALSE) return __ofono_error_invalid_args(msg); if (!__ofono_dbus_valid_object_path(agent_path)) return __ofono_error_invalid_format(msg); gnss->posr_agent = gnss_agent_new(agent_path, dbus_message_get_sender(msg)); if (gnss->posr_agent == NULL) return __ofono_error_failed(msg); gnss_agent_set_removed_notify(gnss->posr_agent, gnss_agent_notify, gnss); gnss->driver->set_position_reporting(gnss, TRUE, gnss_register_agent_cb, gnss); gnss->pending = dbus_message_ref(msg); return NULL; }
static DBusMessage *gnss_send_element(DBusConnection *conn, DBusMessage *msg, void *data) { const char *caller = dbus_message_get_sender(msg); struct ofono_gnss *gnss = data; const char *xml; DBG(""); if (gnss->pending) return __ofono_error_busy(msg); if (!dbus_message_get_args(msg, NULL, DBUS_TYPE_STRING, &xml, DBUS_TYPE_INVALID)) return __ofono_error_invalid_args(msg); if (gnss->posr_agent == NULL) return __ofono_error_not_available(msg); if (!gnss_agent_sender_matches(gnss->posr_agent, caller)) return __ofono_error_access_denied(msg); gnss->pending = dbus_message_ref(msg); gnss->driver->send_element(gnss, xml, gnss_send_element_cb, gnss); return NULL; }
static DBusMessage *gnss_unregister_agent(DBusConnection *conn, DBusMessage *msg, void *data) { struct ofono_gnss *gnss = data; const char *agent_path; const char *agent_bus = dbus_message_get_sender(msg); if (gnss->pending) return __ofono_error_busy(msg); if (dbus_message_get_args(msg, NULL, DBUS_TYPE_OBJECT_PATH, &agent_path, DBUS_TYPE_INVALID) == FALSE) return __ofono_error_invalid_args(msg); if (gnss->posr_agent == NULL) return __ofono_error_failed(msg); if (!gnss_agent_matches(gnss->posr_agent, agent_path, agent_bus)) return __ofono_error_access_denied(msg); gnss->pending = dbus_message_ref(msg); gnss->enabled = FALSE; gnss->driver->set_position_reporting(gnss, FALSE, gnss_unregister_agent_cb, gnss); return NULL; }
static DBusMessage *stk_register_agent(DBusConnection *conn, DBusMessage *msg, void *data) { struct ofono_stk *stk = data; const char *agent_path; if (stk->default_agent) return __ofono_error_busy(msg); if (dbus_message_get_args(msg, NULL, DBUS_TYPE_OBJECT_PATH, &agent_path, DBUS_TYPE_INVALID) == FALSE) return __ofono_error_invalid_args(msg); if (!__ofono_dbus_valid_object_path(agent_path)) return __ofono_error_invalid_format(msg); stk->default_agent = stk_agent_new(agent_path, dbus_message_get_sender(msg), FALSE); if (!stk->default_agent) return __ofono_error_failed(msg); stk_agent_set_removed_notify(stk->default_agent, default_agent_notify, stk); if (!stk->session_agent) stk->current_agent = stk->default_agent; return dbus_message_new_method_return(msg); }
static DBusMessage *set_property_online(struct ofono_modem *modem, DBusMessage *msg, DBusMessageIter *var) { ofono_bool_t online; const struct ofono_modem_driver *driver = modem->driver; if (modem->powered == FALSE) return __ofono_error_not_available(msg); if (dbus_message_iter_get_arg_type(var) != DBUS_TYPE_BOOLEAN) return __ofono_error_invalid_args(msg); dbus_message_iter_get_basic(var, &online); if (modem->pending != NULL) return __ofono_error_busy(msg); if (modem->online == online) return dbus_message_new_method_return(msg); if (ofono_modem_get_emergency_mode(modem) == TRUE) return __ofono_error_emergency_active(msg); if (modem_is_always_online(modem) == TRUE) return __ofono_error_not_implemented(msg); modem->pending = dbus_message_ref(msg); driver->set_online(modem, online, online ? online_cb : offline_cb, modem); return NULL; }
static DBusMessage *ussd_respond(DBusConnection *conn, DBusMessage *msg, void *data) { struct ofono_ussd *ussd = data; const char *str; int dcs = 0x0f; unsigned char buf[160]; long num_packed; if (ussd->pending) return __ofono_error_busy(msg); if (ussd->state != USSD_STATE_USER_ACTION) return __ofono_error_not_active(msg); if (dbus_message_get_args(msg, NULL, DBUS_TYPE_STRING, &str, DBUS_TYPE_INVALID) == FALSE) return __ofono_error_invalid_args(msg); if (strlen(str) == 0) return __ofono_error_invalid_format(msg); if (!ussd_encode(str, &num_packed, buf)) return __ofono_error_invalid_format(msg); if (ussd->driver->request == NULL) return __ofono_error_not_implemented(msg); ussd->pending = dbus_message_ref(msg); ussd->driver->request(ussd, dcs, buf, num_packed, ussd_response_callback, ussd); return NULL; }
static DBusMessage *location_reporting_release(DBusConnection *conn, DBusMessage *msg, void *data) { struct ofono_location_reporting *lr = data; const char *caller = dbus_message_get_sender(msg); /* * Avoid a race by not trying to release the device if there is a * pending message or client already signaled it's exiting. In the * later case, the device will eventually be released in * client_exited_disable_cb(). */ if (lr->pending != NULL || (lr->enabled && !lr->disconnect_watch)) return __ofono_error_busy(msg); if (lr->enabled == FALSE) return __ofono_error_not_available(msg); if (g_strcmp0(caller, lr->client_owner)) return __ofono_error_access_denied(msg); lr->pending = dbus_message_ref(msg); lr->driver->disable(lr, location_reporting_disable_cb, lr); return NULL; }
static DBusMessage *cm_acm_reset(DBusConnection *conn, DBusMessage *msg, void *data) { struct ofono_call_meter *cm = data; const char *pin2; if (cm->driver->acm_reset == NULL) return __ofono_error_not_implemented(msg); if (cm->pending) return __ofono_error_busy(msg); if (dbus_message_get_args(msg, NULL, DBUS_TYPE_STRING, &pin2, DBUS_TYPE_INVALID) == FALSE) return __ofono_error_invalid_args(msg); if (!__ofono_is_valid_sim_pin(pin2, OFONO_SIM_PASSWORD_SIM_PIN2)) return __ofono_error_invalid_format(msg); cm->pending = dbus_message_ref(msg); cm->driver->acm_reset(cm, pin2, acm_reset_callback, cm); return NULL; }
static DBusMessage *handsfree_set_property(DBusConnection *conn, DBusMessage *msg, void *data) { struct ofono_handsfree *hf = data; DBusMessageIter iter, var; ofono_bool_t enabled; const char *name; if (hf->pending) return __ofono_error_busy(msg); if (dbus_message_iter_init(msg, &iter) == FALSE) return __ofono_error_invalid_args(msg); if (dbus_message_iter_get_arg_type(&iter) != DBUS_TYPE_STRING) return __ofono_error_invalid_args(msg); dbus_message_iter_get_basic(&iter, &name); dbus_message_iter_next(&iter); if (dbus_message_iter_get_arg_type(&iter) != DBUS_TYPE_VARIANT) return __ofono_error_invalid_args(msg); dbus_message_iter_recurse(&iter, &var); if (dbus_message_iter_get_arg_type(&var) != DBUS_TYPE_BOOLEAN) return __ofono_error_invalid_args(msg); dbus_message_iter_get_basic(&var, &enabled); if (g_str_equal(name, "VoiceRecognition") == TRUE) { if (!hf->driver->voice_recognition) return __ofono_error_not_implemented(msg); if (hf->voice_recognition == enabled) return dbus_message_new_method_return(msg); hf->voice_recognition_pending = enabled; hf->pending = dbus_message_ref(msg); hf->driver->voice_recognition(hf, enabled, voicerec_set_cb, hf); } else if (g_str_equal(name, "EchoCancelingNoiseReduction") == TRUE) { if (!(hf->ag_features & HFP_AG_FEATURE_ECNR)) return __ofono_error_not_supported(msg); if (!hf->driver->disable_nrec || enabled == TRUE) return __ofono_error_not_implemented(msg); if (hf->nrec == FALSE) return dbus_message_new_method_return(msg); hf->pending = dbus_message_ref(msg); hf->driver->disable_nrec(hf, nrec_set_cb, hf); } else return __ofono_error_invalid_args(msg); return NULL; }
static DBusMessage *stk_select_item(DBusConnection *conn, DBusMessage *msg, void *data) { struct ofono_stk *stk = data; const char *agent_path; unsigned char selection, i; struct stk_envelope e; struct stk_menu *menu = stk->main_menu; if (stk->pending) return __ofono_error_busy(msg); if (stk->session_agent || !menu) return __ofono_error_busy(msg); if (dbus_message_get_args(msg, NULL, DBUS_TYPE_BYTE, &selection, DBUS_TYPE_OBJECT_PATH, &agent_path, DBUS_TYPE_INVALID) == FALSE) return __ofono_error_invalid_args(msg); if (!__ofono_dbus_valid_object_path(agent_path)) return __ofono_error_invalid_format(msg); for (i = 0; i < selection && menu->items[i].text; i++); if (i != selection) return __ofono_error_invalid_format(msg); memset(&e, 0, sizeof(e)); e.type = STK_ENVELOPE_TYPE_MENU_SELECTION; e.src = STK_DEVICE_IDENTITY_TYPE_KEYPAD, e.menu_selection.item_id = menu->items[selection].item_id; e.menu_selection.help_request = FALSE; if (stk_send_envelope(stk, &e, menu_selection_envelope_cb, 0)) return __ofono_error_failed(msg); stk->pending = dbus_message_ref(msg); return NULL; }
static DBusMessage *ussd_initiate(DBusConnection *conn, DBusMessage *msg, void *data) { struct ofono_ussd *ussd = data; struct ofono_modem *modem = __ofono_atom_get_modem(ussd->atom); struct ofono_voicecall *vc; gboolean call_in_progress; const char *str; int dcs = 0x0f; unsigned char buf[160]; long num_packed; if (__ofono_ussd_is_busy(ussd)) return __ofono_error_busy(msg); if (dbus_message_get_args(msg, NULL, DBUS_TYPE_STRING, &str, DBUS_TYPE_INVALID) == FALSE) return __ofono_error_invalid_args(msg); if (strlen(str) == 0) return __ofono_error_invalid_format(msg); DBG("checking if this is a recognized control string"); if (recognized_control_string(ussd, str, msg)) return NULL; vc = __ofono_atom_find(OFONO_ATOM_TYPE_VOICECALL, modem); if (vc) call_in_progress = __ofono_voicecall_is_busy(vc, OFONO_VOICECALL_INTERACTION_NONE); else call_in_progress = FALSE; DBG("No.., checking if this is a USSD string"); if (!valid_ussd_string(str, call_in_progress)) return __ofono_error_not_recognized(msg); if (!ussd_encode(str, &num_packed, buf)) return __ofono_error_invalid_format(msg); if (ussd->driver->request == NULL) return __ofono_error_not_implemented(msg); DBG("OK, running USSD request"); ussd->pending = dbus_message_ref(msg); ussd->driver->request(ussd, dcs, buf, num_packed, ussd_callback, ussd); return NULL; }
static DBusMessage *cm_set_property(DBusConnection *conn, DBusMessage *msg, void *data) { struct ofono_call_meter *cm = data; DBusMessageIter iter; DBusMessageIter var; const char *name, *passwd = ""; struct call_meter_property *property; if (cm->pending) return __ofono_error_busy(msg); if (!dbus_message_iter_init(msg, &iter)) return __ofono_error_invalid_args(msg); if (dbus_message_iter_get_arg_type(&iter) != DBUS_TYPE_STRING) return __ofono_error_invalid_args(msg); dbus_message_iter_get_basic(&iter, &name); dbus_message_iter_next(&iter); if (dbus_message_iter_get_arg_type(&iter) != DBUS_TYPE_VARIANT) return __ofono_error_invalid_args(msg); dbus_message_iter_recurse(&iter, &var); if (!dbus_message_iter_next(&iter)) return __ofono_error_invalid_args(msg); if (dbus_message_iter_get_arg_type(&iter) != DBUS_TYPE_STRING) return __ofono_error_invalid_args(msg); dbus_message_iter_get_basic(&iter, &passwd); if (!__ofono_is_valid_sim_pin(passwd, OFONO_SIM_PASSWORD_SIM_PIN2)) return __ofono_error_invalid_format(msg); for (property = cm_properties; property->name; property++) { if (strcmp(name, property->name)) continue; if (dbus_message_iter_get_arg_type(&var) != property->type) return __ofono_error_invalid_args(msg); return property->set(msg, cm, &var, passwd); } return __ofono_error_invalid_args(msg); }
static DBusMessage *ussd_cancel(DBusConnection *conn, DBusMessage *msg, void *data) { struct ofono_ussd *ussd = data; if (ussd->state == USSD_STATE_IDLE) return __ofono_error_not_active(msg); /* We have called Respond() but not returned from its callback yet */ if (ussd->state == USSD_STATE_USER_ACTION && ussd->pending) return __ofono_error_busy(msg); if (ussd->cancel) return __ofono_error_busy(msg); if (ussd->driver->cancel == NULL) return __ofono_error_not_implemented(msg); ussd->cancel = dbus_message_ref(msg); ussd->driver->cancel(ussd, ussd_cancel_callback, ussd); return NULL; }
static DBusMessage *handsfree_request_phone_number(DBusConnection *conn, DBusMessage *msg, void *data) { struct ofono_handsfree *hf = data; if (hf->pending) return __ofono_error_busy(msg); if (!hf->driver->request_phone_number) return __ofono_error_not_supported(msg); hf->pending = dbus_message_ref(msg); hf->driver->request_phone_number(hf, request_phone_number_cb, hf); return NULL; }
static DBusMessage *location_reporting_request(DBusConnection *conn, DBusMessage *msg, void *data) { struct ofono_location_reporting *lr = data; if (lr->pending != NULL) return __ofono_error_busy(msg); if (lr->enabled) return __ofono_error_in_use(msg); lr->pending = dbus_message_ref(msg); lr->driver->enable(lr, location_reporting_enable_cb, lr); return NULL; }
static DBusMessage *handsfree_get_properties(DBusConnection *conn, DBusMessage *msg, void *data) { struct ofono_handsfree *hf = data; if (hf->pending != NULL) return __ofono_error_busy(msg); if (hf->flags & HANDSFREE_FLAG_CACHED) return generate_get_properties_reply(hf, msg); /* Query the settings and report back */ hf->pending = dbus_message_ref(msg); query_cnum(hf); return NULL; }
static DBusMessage *radio_get_properties(DBusConnection *conn, DBusMessage *msg, void *data) { struct ofono_radio_settings *rs = data; if (rs->flags & RADIO_SETTINGS_FLAG_CACHED) return radio_get_properties_reply(msg, rs); if (rs->driver->query_rat_mode == NULL) return __ofono_error_not_implemented(msg); if (rs->pending) return __ofono_error_busy(msg); rs->pending = dbus_message_ref(msg); rs->driver->query_rat_mode(rs, radio_rat_mode_query_callback, rs); return NULL; }
static DBusMessage *sms_get_properties(DBusConnection *conn, DBusMessage *msg, void *data) { struct ofono_sms *sms = data; if (sms->flags & MESSAGE_MANAGER_FLAG_CACHED) return generate_get_properties_reply(sms, msg); if (sms->pending) return __ofono_error_busy(msg); if (sms->driver->sca_query == NULL) return __ofono_error_not_implemented(msg); sms->pending = dbus_message_ref(msg); sms->driver->sca_query(sms, sms_sca_query_cb, sms); return NULL; }
static DBusMessage *push_notification_register_agent(DBusConnection *conn, DBusMessage *msg, void *data) { struct push_notification *pn = data; const char *agent_path; if (pn->agent) return __ofono_error_busy(msg); if (dbus_message_get_args(msg, NULL, DBUS_TYPE_OBJECT_PATH, &agent_path, DBUS_TYPE_INVALID) == FALSE) return __ofono_error_invalid_args(msg); if (!__ofono_dbus_valid_object_path(agent_path)) return __ofono_error_invalid_format(msg); pn->agent = sms_agent_new(AGENT_INTERFACE, dbus_message_get_sender(msg), agent_path); if (pn->agent == NULL) return __ofono_error_failed(msg); sms_agent_set_removed_notify(pn->agent, agent_exited, pn); pn->push_watch[0] = __ofono_sms_datagram_watch_add(pn->sms, push_received, WAP_PUSH_DST_PORT, WAP_PUSH_SRC_PORT, pn, NULL); pn->push_watch[1] = __ofono_sms_datagram_watch_add(pn->sms, push_received, WAP_PUSH_DST_PORT, 0, pn, NULL); return dbus_message_new_method_return(msg); }
static DBusMessage *card_connect(DBusConnection *conn, DBusMessage *msg, void *data) { struct ofono_handsfree_card *card = data; const struct ofono_handsfree_card_driver *driver = card->driver; const char *sender; int err; if (agent == NULL) return __ofono_error_not_available(msg); sender = dbus_message_get_sender(msg); if (!g_str_equal(sender, agent->owner)) return __ofono_error_not_allowed(msg); if (card->msg) return __ofono_error_busy(msg); if (!driver || !driver->connect) goto fallback; card->msg = dbus_message_ref(msg); driver->connect(card, card_connect_reply_cb, card); return NULL; fallback: /* There's no driver, fallback to direct SCO connection */ err = ofono_handsfree_card_connect_sco(card); if (err < 0) return __ofono_error_failed(msg); card->msg = dbus_message_ref(msg); return NULL; }
static DBusMessage *cm_get_properties(DBusConnection *conn, DBusMessage *msg, void *data) { struct ofono_call_meter *cm = data; if (cm->pending) return __ofono_error_busy(msg); cm->pending = dbus_message_ref(msg); /* * We don't need to query ppu, currency & acm_max every time * Not sure if we have to query acm & call_meter every time * so lets play on the safe side and query them. They should be * fast to query anyway */ if (cm->flags & CALL_METER_FLAG_CACHED) query_acm(cm); else query_puct(cm); return NULL; }
static DBusMessage *set_rf_power_status(DBusMessage *msg, dbus_bool_t enable, void *data) { struct ril_thermal_management *tm = data; struct ril_data *rd = ofono_modem_get_data(tm->modem); struct parcel rilp; int cmd_id; char buf[4]; DBG(""); if (tm->pending) return __ofono_error_busy(msg); parcel_init(&rilp); parcel_w_int32(&rilp, 2); /* RIL_OEM_HOOK_STRING_SET_RF_POWER_STATUS = 0x000000AC */ cmd_id = 0x000000AC; sprintf(buf, "%d", cmd_id); parcel_w_string(&rilp, buf); memset(buf, 0, sizeof(buf)); sprintf(buf, "%d", enable ? 1 : 0); parcel_w_string(&rilp, buf); g_ril_append_print_buf(rd->ril, "{cmd_id=0x%02X,arg=%s}", cmd_id, buf); if (g_ril_send(rd->ril, RIL_REQUEST_OEM_HOOK_STRINGS, &rilp, set_rf_power_status_cb, tm, NULL) == 0) return __ofono_error_failed(msg); tm->pending = dbus_message_ref(msg); return NULL; }
static DBusMessage *cf_get_properties(DBusConnection *conn, DBusMessage *msg, void *data) { struct ofono_call_forwarding *cf = data; struct ofono_modem *modem = __ofono_atom_get_modem(cf->atom); if ((cf->flags & CALL_FORWARDING_FLAG_CACHED) || ofono_modem_get_online(modem) == FALSE) return cf_get_properties_reply(msg, cf); if (cf->driver->query == NULL) return __ofono_error_not_implemented(msg); if (__ofono_call_forwarding_is_busy(cf) || __ofono_ussd_is_busy(cf->ussd)) return __ofono_error_busy(msg); cf->pending = dbus_message_ref(msg); cf->query_next = 0; get_query_next_cf_cond(cf); return NULL; }
static DBusMessage *cf_disable_all(DBusConnection *conn, DBusMessage *msg, void *data) { struct ofono_call_forwarding *cf = data; const char *strtype; int type; if (cf->driver->erasure == NULL) return __ofono_error_not_implemented(msg); if (__ofono_call_forwarding_is_busy(cf) || __ofono_ussd_is_busy(cf->ussd)) return __ofono_error_busy(msg); if (dbus_message_get_args(msg, NULL, DBUS_TYPE_STRING, &strtype, DBUS_TYPE_INVALID) == FALSE) return __ofono_error_invalid_args(msg); if (!strcmp(strtype, "all") || !strcmp(strtype, "")) type = CALL_FORWARDING_TYPE_ALL; else if (!strcmp(strtype, "conditional")) type = CALL_FORWARDING_TYPE_ALL_CONDITIONAL; else return __ofono_error_invalid_format(msg); cf->pending = dbus_message_ref(msg); if (type == CALL_FORWARDING_TYPE_ALL) cf->driver->erasure(cf, type, BEARER_CLASS_DEFAULT, disable_all_callback, cf); else cf->driver->erasure(cf, type, BEARER_CLASS_DEFAULT, disable_conditional_callback, cf); return NULL; }
static DBusMessage *set_property_lockdown(struct ofono_modem *modem, DBusMessage *msg, DBusMessageIter *var) { DBusConnection *conn = ofono_dbus_get_connection(); ofono_bool_t lockdown; dbus_bool_t powered; const char *caller; int err; if (dbus_message_iter_get_arg_type(var) != DBUS_TYPE_BOOLEAN) return __ofono_error_invalid_args(msg); dbus_message_iter_get_basic(var, &lockdown); if (modem->pending != NULL) return __ofono_error_busy(msg); caller = dbus_message_get_sender(msg); if (modem->lockdown && g_strcmp0(caller, modem->lock_owner)) return __ofono_error_access_denied(msg); if (modem->lockdown == lockdown) return dbus_message_new_method_return(msg); if (lockdown == FALSE) { lockdown_remove(modem); goto done; } if (ofono_modem_get_emergency_mode(modem) == TRUE) return __ofono_error_emergency_active(msg); modem->lock_owner = g_strdup(caller); modem->lock_watch = g_dbus_add_disconnect_watch(conn, modem->lock_owner, lockdown_disconnect, modem, NULL); if (modem->lock_watch == 0) { g_free(modem->lock_owner); modem->lock_owner = NULL; return __ofono_error_failed(msg); } modem->lockdown = lockdown; if (modem->powered == FALSE) goto done; err = set_powered(modem, FALSE); if (err < 0) { if (err != -EINPROGRESS) { lockdown_remove(modem); return __ofono_error_failed(msg); } modem->pending = dbus_message_ref(msg); modem->timeout = g_timeout_add_seconds(20, set_powered_timeout, modem); return NULL; } set_online(modem, FALSE); powered = FALSE; ofono_dbus_signal_property_changed(conn, modem->path, OFONO_MODEM_INTERFACE, "Powered", DBUS_TYPE_BOOLEAN, &powered); done: g_dbus_send_reply(conn, msg, DBUS_TYPE_INVALID); ofono_dbus_signal_property_changed(conn, modem->path, OFONO_MODEM_INTERFACE, "Lockdown", DBUS_TYPE_BOOLEAN, &lockdown); return NULL; }
static DBusMessage *modem_set_property(DBusConnection *conn, DBusMessage *msg, void *data) { struct ofono_modem *modem = data; DBusMessageIter iter, var; const char *name; if (dbus_message_iter_init(msg, &iter) == FALSE) return __ofono_error_invalid_args(msg); if (dbus_message_iter_get_arg_type(&iter) != DBUS_TYPE_STRING) return __ofono_error_invalid_args(msg); dbus_message_iter_get_basic(&iter, &name); dbus_message_iter_next(&iter); if (dbus_message_iter_get_arg_type(&iter) != DBUS_TYPE_VARIANT) return __ofono_error_invalid_args(msg); if (powering_down == TRUE) return __ofono_error_failed(msg); dbus_message_iter_recurse(&iter, &var); if (g_str_equal(name, "Online")) return set_property_online(modem, msg, &var); if (g_str_equal(name, "Powered") == TRUE) { ofono_bool_t powered; int err; if (dbus_message_iter_get_arg_type(&var) != DBUS_TYPE_BOOLEAN) return __ofono_error_invalid_args(msg); dbus_message_iter_get_basic(&var, &powered); if (modem->pending != NULL) return __ofono_error_busy(msg); if (modem->powered == powered) return dbus_message_new_method_return(msg); if (ofono_modem_get_emergency_mode(modem) == TRUE) return __ofono_error_emergency_active(msg); if (modem->lockdown) return __ofono_error_access_denied(msg); err = set_powered(modem, powered); if (err < 0) { if (err != -EINPROGRESS) return __ofono_error_failed(msg); modem->pending = dbus_message_ref(msg); modem->timeout = g_timeout_add_seconds(20, set_powered_timeout, modem); return NULL; } g_dbus_send_reply(conn, msg, DBUS_TYPE_INVALID); ofono_dbus_signal_property_changed(conn, modem->path, OFONO_MODEM_INTERFACE, "Powered", DBUS_TYPE_BOOLEAN, &powered); if (powered) { modem_change_state(modem, MODEM_STATE_PRE_SIM); /* Force SIM Ready for devies with no sim atom */ if (modem_has_sim(modem) == FALSE) sim_state_watch(OFONO_SIM_STATE_READY, modem); } else { set_online(modem, FALSE); modem_change_state(modem, MODEM_STATE_POWER_OFF); } return NULL; } if (g_str_equal(name, "Lockdown")) return set_property_lockdown(modem, msg, &var); return __ofono_error_invalid_args(msg); }
static gboolean cb_ss_control(int type, const char *sc, const char *sia, const char *sib, const char *sic, const char *dn, DBusMessage *msg, void *data) { struct ofono_call_barring *cb = data; DBusConnection *conn = ofono_dbus_get_connection(); int cls = BEARER_CLASS_DEFAULT; const char *fac; DBusMessage *reply; void *operation = NULL; int i; if (cb->pending) { reply = __ofono_error_busy(msg); g_dbus_send_message(conn, reply); return TRUE; } DBG("Received call barring ss control request"); DBG("type: %d, sc: %s, sia: %s, sib: %s, sic: %s, dn: %s", type, sc, sia, sib, sic, dn); fac = cb_ss_service_to_fac(sc); if (!fac) return FALSE; cb_set_query_bounds(cb, fac, type == SS_CONTROL_TYPE_QUERY); i = 0; while (cb_locks[i].name && strcmp(cb_locks[i].fac, fac)) i++; cb->ss_req_lock = i; if (strlen(sic) > 0) goto bad_format; if (strlen(dn) > 0) goto bad_format; if (type != SS_CONTROL_TYPE_QUERY && !is_valid_pin(sia, PIN_TYPE_NET)) goto bad_format; switch (type) { case SS_CONTROL_TYPE_ACTIVATION: case SS_CONTROL_TYPE_DEACTIVATION: case SS_CONTROL_TYPE_REGISTRATION: case SS_CONTROL_TYPE_ERASURE: operation = cb->driver->set; break; case SS_CONTROL_TYPE_QUERY: operation = cb->driver->query; break; default: break; } if (!operation) { reply = __ofono_error_not_implemented(msg); g_dbus_send_message(conn, reply); return TRUE; } /* According to 27.007, AG, AC and AB only work with mode = 0 * We support query by querying all relevant types, since we must * do this for the deactivation case anyway */ if ((!strcmp(fac, "AG") || !strcmp(fac, "AC") || !strcmp(fac, "AB")) && (type == SS_CONTROL_TYPE_ACTIVATION || type == SS_CONTROL_TYPE_REGISTRATION)) goto bad_format; if (strlen(sib) > 0) { long service_code; char *end; service_code = strtoul(sib, &end, 10); if (end == sib || *end != '\0') goto bad_format; cls = mmi_service_code_to_bearer_class(service_code); if (cls == 0) goto bad_format; } cb->ss_req_cls = cls; cb->pending = dbus_message_ref(msg); switch (type) { case SS_CONTROL_TYPE_ACTIVATION: case SS_CONTROL_TYPE_REGISTRATION: cb->ss_req_type = SS_CONTROL_TYPE_ACTIVATION; cb->driver->set(cb, fac, 1, sia, cls, cb_ss_set_lock_callback, cb); break; case SS_CONTROL_TYPE_ERASURE: case SS_CONTROL_TYPE_DEACTIVATION: cb->ss_req_type = SS_CONTROL_TYPE_DEACTIVATION; cb->driver->set(cb, fac, 0, sia, cls, cb_ss_set_lock_callback, cb); break; case SS_CONTROL_TYPE_QUERY: cb->ss_req_type = SS_CONTROL_TYPE_QUERY; cb_ss_query_next_lock(cb); break; } return TRUE; bad_format: reply = __ofono_error_invalid_format(msg); g_dbus_send_message(conn, reply); return TRUE; }
static DBusMessage *radio_set_property(DBusConnection *conn, DBusMessage *msg, void *data) { struct ofono_radio_settings *rs = data; DBusMessageIter iter; DBusMessageIter var; const char *property; if (rs->pending) return __ofono_error_busy(msg); if (!dbus_message_iter_init(msg, &iter)) return __ofono_error_invalid_args(msg); if (dbus_message_iter_get_arg_type(&iter) != DBUS_TYPE_STRING) return __ofono_error_invalid_args(msg); dbus_message_iter_get_basic(&iter, &property); dbus_message_iter_next(&iter); if (dbus_message_iter_get_arg_type(&iter) != DBUS_TYPE_VARIANT) return __ofono_error_invalid_args(msg); dbus_message_iter_recurse(&iter, &var); if (g_strcmp0(property, "TechnologyPreference") == 0) { const char *value; enum ofono_radio_access_mode mode; if (rs->driver->set_rat_mode == NULL) return __ofono_error_not_implemented(msg); if (dbus_message_iter_get_arg_type(&var) != DBUS_TYPE_STRING) return __ofono_error_invalid_args(msg); dbus_message_iter_get_basic(&var, &value); if (radio_access_mode_from_string(value, &mode) == FALSE) return __ofono_error_invalid_args(msg); if (rs->mode == mode) return dbus_message_new_method_return(msg); rs->pending = dbus_message_ref(msg); rs->pending_mode = mode; rs->driver->set_rat_mode(rs, mode, radio_mode_set_callback, rs); return NULL; } else if (g_strcmp0(property, "GsmBand") == 0) { const char *value; enum ofono_radio_band_gsm band; if (rs->driver->set_band == NULL) return __ofono_error_not_implemented(msg); if (dbus_message_iter_get_arg_type(&var) != DBUS_TYPE_STRING) return __ofono_error_invalid_args(msg); dbus_message_iter_get_basic(&var, &value); if (radio_band_gsm_from_string(value, &band) == FALSE) return __ofono_error_invalid_args(msg); if (rs->band_gsm == band) return dbus_message_new_method_return(msg); rs->pending = dbus_message_ref(msg); rs->pending_band_gsm = band; rs->driver->set_band(rs, band, rs->band_umts, radio_band_set_callback, rs); return NULL; } else if (g_strcmp0(property, "UmtsBand") == 0) { const char *value; enum ofono_radio_band_umts band; if (rs->driver->set_band == NULL) return __ofono_error_not_implemented(msg); if (dbus_message_iter_get_arg_type(&var) != DBUS_TYPE_STRING) return __ofono_error_invalid_args(msg); dbus_message_iter_get_basic(&var, &value); if (radio_band_umts_from_string(value, &band) == FALSE) return __ofono_error_invalid_args(msg); if (rs->band_umts == band) return dbus_message_new_method_return(msg); rs->pending = dbus_message_ref(msg); rs->pending_band_umts = band; rs->driver->set_band(rs, rs->band_gsm, band, radio_band_set_callback, rs); return NULL; } else if (g_strcmp0(property, "FastDormancy") == 0) { dbus_bool_t value; int target; if (rs->driver->set_fast_dormancy == NULL) return __ofono_error_not_implemented(msg); if (dbus_message_iter_get_arg_type(&var) != DBUS_TYPE_BOOLEAN) return __ofono_error_invalid_args(msg); dbus_message_iter_get_basic(&var, &value); target = value; if (rs->fast_dormancy_pending == target) return dbus_message_new_method_return(msg); rs->pending = dbus_message_ref(msg); rs->fast_dormancy_pending = target; rs->driver->set_fast_dormancy(rs, target, radio_fast_dormancy_set_callback, rs); return NULL; } return __ofono_error_invalid_args(msg); }
static DBusMessage *sms_set_property(DBusConnection *conn, DBusMessage *msg, void *data) { struct ofono_sms *sms = data; DBusMessageIter iter; DBusMessageIter var; const char *property; if (sms->pending) return __ofono_error_busy(msg); if (!dbus_message_iter_init(msg, &iter)) return __ofono_error_invalid_args(msg); if (dbus_message_iter_get_arg_type(&iter) != DBUS_TYPE_STRING) return __ofono_error_invalid_args(msg); dbus_message_iter_get_basic(&iter, &property); dbus_message_iter_next(&iter); if (dbus_message_iter_get_arg_type(&iter) != DBUS_TYPE_VARIANT) return __ofono_error_invalid_args(msg); dbus_message_iter_recurse(&iter, &var); if (!strcmp(property, "ServiceCenterAddress")) { const char *value; struct ofono_phone_number sca; if (dbus_message_iter_get_arg_type(&var) != DBUS_TYPE_STRING) return __ofono_error_invalid_args(msg); dbus_message_iter_get_basic(&var, &value); if (strlen(value) == 0 || !valid_phone_number_format(value)) return __ofono_error_invalid_format(msg); if (sms->driver->sca_set == NULL || sms->driver->sca_query == NULL) return __ofono_error_not_implemented(msg); string_to_phone_number(value, &sca); sms->pending = dbus_message_ref(msg); sms->driver->sca_set(sms, &sca, sca_set_callback, sms); return NULL; } if (!strcmp(property, "Bearer")) { const char *value; int bearer; if (dbus_message_iter_get_arg_type(&var) != DBUS_TYPE_STRING) return __ofono_error_invalid_args(msg); dbus_message_iter_get_basic(&var, &value); if (sms_bearer_from_string(value, &bearer) != TRUE) return __ofono_error_invalid_format(msg); if (sms->driver->bearer_set == NULL || sms->driver->bearer_query == NULL) return __ofono_error_not_implemented(msg); sms->pending = dbus_message_ref(msg); sms->driver->bearer_set(sms, bearer, bearer_set_callback, sms); return NULL; } if (!strcmp(property, "UseDeliveryReports")) { const char *path = __ofono_atom_get_path(sms->atom); dbus_bool_t value; if (dbus_message_iter_get_arg_type(&var) != DBUS_TYPE_BOOLEAN) return __ofono_error_invalid_args(msg); dbus_message_iter_get_basic(&var, &value); g_dbus_send_reply(conn, msg, DBUS_TYPE_INVALID); if (sms->use_delivery_reports != (ofono_bool_t) value) { sms->use_delivery_reports = value; ofono_dbus_signal_property_changed(conn, path, OFONO_MESSAGE_MANAGER_INTERFACE, "UseDeliveryReports", DBUS_TYPE_BOOLEAN, &value); } return NULL; } if (!strcmp(property, "Alphabet")) { const char *value; enum sms_alphabet alphabet; if (dbus_message_iter_get_arg_type(&var) != DBUS_TYPE_STRING) return __ofono_error_invalid_args(msg); dbus_message_iter_get_basic(&var, &value); if (!sms_alphabet_from_string(value, &alphabet)) return __ofono_error_invalid_format(msg); set_alphabet(sms, alphabet); g_dbus_send_reply(conn, msg, DBUS_TYPE_INVALID); return NULL; } return __ofono_error_invalid_args(msg); }
static DBusMessage *cv_set_property(DBusConnection *conn, DBusMessage *msg, void *data) { struct ofono_call_volume *cv = data; DBusMessageIter iter; DBusMessageIter var; const char *property; if (cv->pending) return __ofono_error_busy(msg); if (!dbus_message_iter_init(msg, &iter)) return __ofono_error_invalid_args(msg); if (dbus_message_iter_get_arg_type(&iter) != DBUS_TYPE_STRING) return __ofono_error_invalid_args(msg); dbus_message_iter_get_basic(&iter, &property); dbus_message_iter_next(&iter); if (dbus_message_iter_get_arg_type(&iter) != DBUS_TYPE_VARIANT) return __ofono_error_invalid_args(msg); dbus_message_iter_recurse(&iter, &var); if (g_str_equal(property, "SpeakerVolume") == TRUE) { unsigned char percent; if (cv->driver->speaker_volume == NULL) return __ofono_error_not_implemented(msg); if (dbus_message_iter_get_arg_type(&var) != DBUS_TYPE_BYTE) return __ofono_error_invalid_args(msg); dbus_message_iter_get_basic(&var, &percent); if (percent > 100) return __ofono_error_invalid_format(msg); if (percent == cv->speaker_volume) return dbus_message_new_method_return(msg); cv->pending_volume = percent; cv->pending = dbus_message_ref(msg); cv->driver->speaker_volume(cv, percent, sv_set_callback, cv); return NULL; } else if (g_str_equal(property, "MicrophoneVolume") == TRUE) { unsigned char percent; if (cv->driver->microphone_volume == NULL) return __ofono_error_not_implemented(msg); if (dbus_message_iter_get_arg_type(&var) != DBUS_TYPE_BYTE) return __ofono_error_invalid_args(msg); dbus_message_iter_get_basic(&var, &percent); if (percent > 100) return __ofono_error_invalid_format(msg); if (percent == cv->microphone_volume) return dbus_message_new_method_return(msg); cv->pending_volume = percent; cv->pending = dbus_message_ref(msg); cv->driver->microphone_volume(cv, percent, mv_set_callback, cv); return NULL; } else if (g_str_equal(property, "Muted") == TRUE) { dbus_bool_t muted; if (cv->driver->mute == NULL) return __ofono_error_not_implemented(msg); if (dbus_message_iter_get_arg_type(&var) != DBUS_TYPE_BOOLEAN) return __ofono_error_invalid_args(msg); dbus_message_iter_get_basic(&var, &muted); if (muted == (dbus_bool_t) cv->muted) return dbus_message_new_method_return(msg); cv->muted_pending = muted; cv->pending = dbus_message_ref(msg); cv->driver->mute(cv, muted, muted_set_callback, cv); return NULL; } return __ofono_error_invalid_args(msg); }