static void set_puct_query_callback(const struct ofono_error *error, const char *currency, double ppu, void *data) { struct ofono_call_meter *cm = data; DBusMessage *reply; if (cm->pending == NULL) return; if (error->type != OFONO_ERROR_TYPE_NO_ERROR) { ofono_error("Setting PUCT successful, but query was not"); cm->flags &= ~CALL_METER_FLAG_CACHED; __ofono_dbus_pending_reply(&cm->pending, __ofono_error_failed(cm->pending)); return; } reply = dbus_message_new_method_return(cm->pending); __ofono_dbus_pending_reply(&cm->pending, reply); set_currency(cm, currency); set_ppu(cm, ppu); }
static void cb_ss_query_next_lock_callback(const struct ofono_error *error, int status, void *data) { struct ofono_call_barring *cb = data; if (error->type != OFONO_ERROR_TYPE_NO_ERROR) { if (cb->ss_req_type != SS_CONTROL_TYPE_QUERY) ofono_error("Enabling/disabling Call Barring via SS " "successful, but query was not"); cb->flags &= ~CALL_BARRING_FLAG_CACHED; __ofono_dbus_pending_reply(&cb->pending, __ofono_error_failed(cb->pending)); return; } cb->new_locks[cb->query_next] = status; if (cb->query_next < cb->query_end) { cb->query_next += 1; cb_ss_query_next_lock(cb); return; } generate_ss_query_reply(cb); update_barrings(cb, BEARER_CLASS_VOICE); }
static void gnss_register_agent_cb(const struct ofono_error *error, void *data) { DBusMessage *reply; struct ofono_gnss *gnss = data; DBG(""); if (error->type != OFONO_ERROR_TYPE_NO_ERROR) { ofono_error("Enabling Location Reporting Failed"); reply = __ofono_error_failed(gnss->pending); if (gnss->posr_agent) gnss_agent_free(gnss->posr_agent); __ofono_dbus_pending_reply(&gnss->pending, reply); return; } reply = dbus_message_new_method_return(gnss->pending); __ofono_dbus_pending_reply(&gnss->pending, reply); gnss->enabled = TRUE; if (gnss->posr_agent == NULL) gnss->driver->set_position_reporting(gnss, FALSE, gnss_disable_posr_cb, gnss); }
static void set_rf_power_status_cb(struct ril_msg *message, gpointer user_data) { DBusConnection *conn = ofono_dbus_get_connection(); struct ril_thermal_management *tm = user_data; struct ril_data *rd = ofono_modem_get_data(tm->modem); const char *path = ofono_modem_get_path(tm->modem); DBG(""); if (message->error != RIL_E_SUCCESS) { ofono_error("%s RILD reply failure: %s", g_ril_request_id_to_string(rd->ril, message->req), ril_error_to_string(message->error)); __ofono_dbus_pending_reply(&tm->pending, __ofono_error_failed(tm->pending)); return; } /* Change the throttling state */ tm->throttling = tm->throttling ? false : true; __ofono_dbus_pending_reply(&tm->pending, dbus_message_new_method_return(tm->pending)); ofono_dbus_signal_property_changed(conn, path, THERMAL_MANAGEMENT_INTERFACE, "TransmitPowerThrottling", DBUS_TYPE_BOOLEAN, &tm->throttling); }
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 void set_query_cf_callback(const struct ofono_error *error, int total, const struct ofono_call_forwarding_condition *list, void *data) { struct ofono_call_forwarding *cf = data; GSList *l; DBusMessage *reply; if (error->type != OFONO_ERROR_TYPE_NO_ERROR) { ofono_error("Setting succeeded, but query failed"); cf->flags &= ~CALL_FORWARDING_FLAG_CACHED; reply = __ofono_error_failed(cf->pending); __ofono_dbus_pending_reply(&cf->pending, reply); return; } if (cf->query_next == cf->query_end) { reply = dbus_message_new_method_return(cf->pending); __ofono_dbus_pending_reply(&cf->pending, reply); } l = cf_cond_list_create(total, list); set_new_cond_list(cf, cf->query_next, l); DBG("%s conditions:", cf_type_lut[cf->query_next]); cf_cond_list_print(l); if (cf->query_next != cf->query_end) { cf->query_next++; set_query_next_cf_cond(cf); } }
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 void offline_cb(const struct ofono_error *error, void *data) { struct ofono_modem *modem = data; DBusMessage *reply; if (error->type == OFONO_ERROR_TYPE_NO_ERROR) reply = dbus_message_new_method_return(modem->pending); else reply = __ofono_error_failed(modem->pending); __ofono_dbus_pending_reply(&modem->pending, reply); if (error->type == OFONO_ERROR_TYPE_NO_ERROR) { switch (modem->modem_state) { case MODEM_STATE_PRE_SIM: set_online(modem, FALSE); break; case MODEM_STATE_ONLINE: set_online(modem, FALSE); modem_change_state(modem, MODEM_STATE_OFFLINE); break; default: break; } } }
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 void ussd_cancel_callback(const struct ofono_error *error, void *data) { struct ofono_ussd *ussd = data; DBusMessage *reply; if (error->type != OFONO_ERROR_TYPE_NO_ERROR) { DBG("ussd cancel failed with error: %s", telephony_error_to_str(error)); reply = __ofono_error_failed(ussd->cancel); __ofono_dbus_pending_reply(&ussd->cancel, reply); return; } if (ussd->pending) { reply = __ofono_error_canceled(ussd->pending); __ofono_dbus_pending_reply(&ussd->pending, reply); } reply = dbus_message_new_method_return(ussd->cancel); __ofono_dbus_pending_reply(&ussd->cancel, reply); if (ussd->req) ussd_request_finish(ussd, -ECANCELED, 0, NULL, 0); ussd_change_state(ussd, USSD_STATE_IDLE); }
static DBusMessage *message_cancel(DBusConnection *conn, DBusMessage *msg, void *data) { struct message *m = data; int res; if (dbus_message_get_args(msg, NULL, DBUS_TYPE_INVALID) == FALSE) return __ofono_error_invalid_args(msg); if (m->state != MESSAGE_STATE_PENDING) return __ofono_error_not_available(msg); res = __ofono_sms_txq_cancel(__ofono_atom_get_data(m->atom), &m->uuid); switch (res) { case -ENOENT: return __ofono_error_not_found(msg); case -EPERM: return __ofono_error_access_denied(msg); case 0: return dbus_message_new_method_return(msg); default: return __ofono_error_failed(msg); } }
static void location_reporting_enable_cb(const struct ofono_error *error, int fd, void *data) { struct ofono_location_reporting *lr = data; DBusConnection *conn = ofono_dbus_get_connection(); DBusMessage *reply; if (error->type != OFONO_ERROR_TYPE_NO_ERROR) { ofono_error("Enabling location-reporting failed"); reply = __ofono_error_failed(lr->pending); __ofono_dbus_pending_reply(&lr->pending, reply); return; } lr->enabled = TRUE; lr->client_owner = g_strdup(dbus_message_get_sender(lr->pending)); lr->disconnect_watch = g_dbus_add_disconnect_watch(conn, lr->client_owner, client_exited, lr, NULL); reply = dbus_message_new_method_return(lr->pending); dbus_message_append_args(reply, DBUS_TYPE_UNIX_FD, &fd, DBUS_TYPE_INVALID); __ofono_dbus_pending_reply(&lr->pending, reply); signal_enabled(lr); }
static void menu_selection_envelope_cb(struct ofono_stk *stk, gboolean ok, const unsigned char *data, int len) { unsigned char selection; const char *agent_path; DBusMessage *reply; if (!ok) { ofono_error("Sending Menu Selection to UICC failed"); reply = __ofono_error_failed(stk->pending); goto out; } if (len) ofono_error("Menu Selection returned %i bytes of unwanted data", len); DBG("Menu Selection envelope submission gave no error"); dbus_message_get_args(stk->pending, NULL, DBUS_TYPE_BYTE, &selection, DBUS_TYPE_OBJECT_PATH, &agent_path, DBUS_TYPE_INVALID); stk->session_agent = stk_agent_new(agent_path, dbus_message_get_sender(stk->pending), TRUE); if (!stk->session_agent) { reply = __ofono_error_failed(stk->pending); goto out; } stk_agent_set_removed_notify(stk->session_agent, session_agent_notify, stk); stk->current_agent = stk->session_agent; reply = dbus_message_new_method_return(stk->pending); out: __ofono_dbus_pending_reply(&stk->pending, reply); }
static void card_connect_reply_cb(const struct ofono_error *error, void *data) { struct ofono_handsfree_card *card = data; DBusMessage *reply; if (error->type == OFONO_ERROR_TYPE_NO_ERROR) reply = dbus_message_new_method_return(card->msg); else reply = __ofono_error_failed(card->msg); __ofono_dbus_pending_reply(&card->msg, reply); }
static void sca_set_callback(const struct ofono_error *error, void *data) { struct ofono_sms *sms = data; if (error->type != OFONO_ERROR_TYPE_NO_ERROR) { DBG("Setting SCA failed"); __ofono_dbus_pending_reply(&sms->pending, __ofono_error_failed(sms->pending)); return; } sms->driver->sca_query(sms, sca_set_query_callback, sms); }
static DBusMessage *stk_unregister_agent(DBusConnection *conn, DBusMessage *msg, void *data) { struct ofono_stk *stk = data; const char *agent_path; const char *agent_bus = dbus_message_get_sender(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 (!stk->default_agent) return __ofono_error_failed(msg); if (!stk_agent_matches(stk->default_agent, agent_path, agent_bus)) return __ofono_error_failed(msg); stk_agent_free(stk->default_agent); return dbus_message_new_method_return(msg); }
static void ofono_oem_raw_query_cb(const struct ofono_error *error, const struct ofono_oem_raw_results *res, void *data) { char *ptr; char byte; int i; DBusMessage *reply; DBusMessageIter iter; DBusMessageIter subiter; struct ofono_oem_raw_request *req = data; if (error && error->type == OFONO_ERROR_TYPE_NO_ERROR) { reply = dbus_message_new_method_return(req->pending); } else { /* * Log error messages in driver when completing a request, * logging here provides no extra information. */ goto error; } dbus_message_iter_init_append(reply, &iter); if (!dbus_message_iter_open_container(&iter, DBUS_TYPE_ARRAY, "y", &subiter)) { DBG("Failed to open a dbus iterator"); goto error; } ptr = (char *)res->data; for (i = 0; i < res->length; i++) { byte = ptr[i]; dbus_message_iter_append_basic(&subiter, DBUS_TYPE_BYTE, &byte); } dbus_message_iter_close_container(&iter, &subiter); goto end; error: reply = __ofono_error_failed(req->pending); end: __ofono_dbus_pending_reply(&req->pending, reply); g_free(req); return; }
static void set_property_callback(const struct ofono_error *error, void *data) { struct ofono_call_forwarding *cf = data; if (error->type != OFONO_ERROR_TYPE_NO_ERROR) { DBG("Error occurred during set/erasure"); __ofono_dbus_pending_reply(&cf->pending, __ofono_error_failed(cf->pending)); return; } /* Successfully set, query the entire set just in case */ set_query_next_cf_cond(cf); }
static void cb_set_passwd_callback(const struct ofono_error *error, void *data) { struct ofono_call_barring *cb = data; DBusMessage *reply; if (error->type == OFONO_ERROR_TYPE_NO_ERROR) reply = dbus_message_new_method_return(cb->pending); else { reply = __ofono_error_failed(cb->pending); DBG("Changing Call Barring password via SS failed"); } __ofono_dbus_pending_reply(&cb->pending, reply); }
static DBusMessage *push_notification_unregister_agent(DBusConnection *conn, DBusMessage *msg, void *data) { struct push_notification *pn = data; const char *agent_path; const char *agent_bus = dbus_message_get_sender(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 (pn->agent == NULL) return __ofono_error_failed(msg); if (sms_agent_matches(pn->agent, agent_bus, agent_path) == FALSE) return __ofono_error_failed(msg); sms_agent_free(pn->agent); pn->agent = NULL; return dbus_message_new_method_return(msg); }
/* * Pre-process a SMS text message and deliver it [D-Bus SendMessage()] * * @conn: D-Bus connection * @msg: message data (telephone number and text) * @data: SMS object to use for transmision * * An alphabet is chosen for the text and it (might be) segmented in * fragments by sms_text_prepare() into @msg_list. A queue list @entry * is created by tx_queue_entry_new() and g_queue_push_tail() * appends that entry to the SMS transmit queue. Then the tx_next() * function is scheduled to run to process the queue. */ static DBusMessage *sms_send_message(DBusConnection *conn, DBusMessage *msg, void *data) { struct ofono_sms *sms = data; const char *to; const char *text; GSList *msg_list; struct ofono_modem *modem; unsigned int flags; gboolean use_16bit_ref = FALSE; int err; struct ofono_uuid uuid; if (!dbus_message_get_args(msg, NULL, DBUS_TYPE_STRING, &to, DBUS_TYPE_STRING, &text, DBUS_TYPE_INVALID)) return __ofono_error_invalid_args(msg); if (valid_phone_number_format(to) == FALSE) return __ofono_error_invalid_format(msg); msg_list = sms_text_prepare_with_alphabet(to, text, sms->ref, use_16bit_ref, sms->use_delivery_reports, sms->alphabet); if (msg_list == NULL) return __ofono_error_invalid_format(msg); flags = OFONO_SMS_SUBMIT_FLAG_RECORD_HISTORY; flags |= OFONO_SMS_SUBMIT_FLAG_RETRY; flags |= OFONO_SMS_SUBMIT_FLAG_EXPOSE_DBUS; if (sms->use_delivery_reports) flags |= OFONO_SMS_SUBMIT_FLAG_REQUEST_SR; err = __ofono_sms_txq_submit(sms, msg_list, flags, &uuid, message_queued, msg); g_slist_foreach(msg_list, (GFunc) g_free, NULL); g_slist_free(msg_list); if (err < 0) return __ofono_error_failed(msg); modem = __ofono_atom_get_modem(sms->atom); __ofono_history_sms_send_pending(modem, &uuid, to, time(NULL), text); return NULL; }
static void acm_reset_callback(const struct ofono_error *error, void *data) { struct ofono_call_meter *cm = data; if (error->type != OFONO_ERROR_TYPE_NO_ERROR) { DBG("reseting acm failed"); __ofono_dbus_pending_reply(&cm->pending, __ofono_error_failed(cm->pending)); check_pin2_state(cm); return; } /* Assume if we have acm_reset, we have acm_query */ cm->driver->acm_query(cm, reset_acm_query_callback, cm); }
static void cb_ss_set_lock_callback(const struct ofono_error *error, void *data) { struct ofono_call_barring *cb = data; if (error->type != OFONO_ERROR_TYPE_NO_ERROR) { DBG("Enabling/disabling Call Barring via SS failed"); __ofono_dbus_pending_reply(&cb->pending, __ofono_error_failed(cb->pending)); return; } /* Assume we have query always */ cb_ss_query_next_lock(cb); }
static void cf_ss_control_callback(const struct ofono_error *error, void *data) { struct ofono_call_forwarding *cf = data; if (error->type != OFONO_ERROR_TYPE_NO_ERROR) { DBG("Error occurred during cf ss control set/erasure"); __ofono_dbus_pending_reply(&cf->pending, __ofono_error_failed(cf->pending)); g_free(cf->ss_req); cf->ss_req = NULL; return; } ss_set_query_next_cf_cond(cf); }
static void handsfree_unregister(struct ofono_atom *atom) { DBusConnection *conn = ofono_dbus_get_connection(); struct ofono_modem *modem = __ofono_atom_get_modem(atom); const char *path = __ofono_atom_get_path(atom); struct ofono_handsfree *hf = __ofono_atom_get_data(atom); if (hf->pending) { DBusMessage *reply = __ofono_error_failed(hf->pending); __ofono_dbus_pending_reply(&hf->pending, reply); } ofono_modem_remove_interface(modem, OFONO_HANDSFREE_INTERFACE); g_dbus_unregister_interface(conn, path, OFONO_HANDSFREE_INTERFACE); }
static void gnss_send_element_cb(const struct ofono_error *error, void *data) { DBusMessage *reply; struct ofono_gnss *gnss = data; DBG(""); if (error->type != OFONO_ERROR_TYPE_NO_ERROR) { ofono_error("Sending Positioning Element failed"); reply = __ofono_error_failed(gnss->pending); } else reply = dbus_message_new_method_return(gnss->pending); __ofono_dbus_pending_reply(&gnss->pending, reply); }
static void disable_all_callback(const struct ofono_error *error, void *data) { struct ofono_call_forwarding *cf = data; if (error->type != OFONO_ERROR_TYPE_NO_ERROR) { DBG("Error occurred during erasure of all"); __ofono_dbus_pending_reply(&cf->pending, __ofono_error_failed(cf->pending)); return; } /* Query all cf types */ cf->query_next = CALL_FORWARDING_TYPE_UNCONDITIONAL; cf->query_end = CALL_FORWARDING_TYPE_NOT_REACHABLE; set_query_next_cf_cond(cf); }
static void radio_fast_dormancy_query_callback(const struct ofono_error *error, ofono_bool_t enable, void *data) { struct ofono_radio_settings *rs = data; DBusMessage *reply; if (error->type != OFONO_ERROR_TYPE_NO_ERROR) { DBG("Error during fast dormancy query"); reply = __ofono_error_failed(rs->pending); __ofono_dbus_pending_reply(&rs->pending, reply); return; } radio_set_fast_dormancy(rs, enable); radio_query_available_rats(rs); }
static void bearer_set_query_callback(const struct ofono_error *error, int bearer, void *data) { struct ofono_sms *sms = data; DBusMessage *reply; if (error->type != OFONO_ERROR_TYPE_NO_ERROR) { ofono_error("Set Bearer succeeded, but query failed"); reply = __ofono_error_failed(sms->pending); __ofono_dbus_pending_reply(&sms->pending, reply); return; } reply = dbus_message_new_method_return(sms->pending); __ofono_dbus_pending_reply(&sms->pending, reply); set_bearer(sms, bearer); }
static void online_cb(const struct ofono_error *error, void *data) { struct ofono_modem *modem = data; DBusMessage *reply; if (!modem->pending) goto out; if (error->type == OFONO_ERROR_TYPE_NO_ERROR) reply = dbus_message_new_method_return(modem->pending); else reply = __ofono_error_failed(modem->pending); __ofono_dbus_pending_reply(&modem->pending, reply); out: common_online_cb(error, data); }