static void property_append_cf_conditions(DBusMessageIter *dict, GSList *cf_list, int mask, const char *postfix) { GSList *l; int i; struct ofono_call_forwarding_condition *cf; const char *number; for (i = 1, l = cf_list; i <= BEARER_CLASS_PAD; i = i << 1) { if (!(mask & i)) continue; while (l && (cf = l->data) && (cf->cls < i)) l = l->next; if (l == NULL || cf->cls != i) { property_append_cf_condition(dict, i, postfix, "", DEFAULT_NO_REPLY_TIMEOUT); continue; } number = phone_number_to_string(&cf->phone_number); property_append_cf_condition(dict, i, postfix, number, cf->time); } }
static void example_history_call_missed(struct ofono_history_context *context, const struct ofono_call *call, time_t when) { const char *from = "Unknown"; char buf[128]; ofono_debug("Call Missed on modem: %p", context->modem); if (call->type != 0) return; ofono_debug("Voice Call, %s", call->direction ? "Incoming" : "Outgoing"); if (call->clip_validity == 0) from = phone_number_to_string(&call->phone_number); ofono_debug("From: %s", from); if (call->cnap_validity == 0) ofono_debug("Name from Network: %s\n", call->name); strftime(buf, 127, "%Y-%m-%dT%H:%M:%S%z", localtime(&when)); buf[127] = '\0'; ofono_debug("When: %s", buf); }
static void ril_dial(struct ofono_voicecall *vc, const struct ofono_phone_number *ph, enum ofono_clir_option clir, ofono_voicecall_cb_t cb, void *data) { struct voicecall_data *vd = ofono_voicecall_get_data(vc); struct cb_data *cbd = cb_data_new(cb, data); struct parcel rilp; int ret; cbd->user = vc; parcel_init(&rilp); /* Number to dial */ parcel_w_string(&rilp, phone_number_to_string(ph)); /* CLIR mode */ parcel_w_int32(&rilp, clir); /* USS, need it twice for absent */ /* TODO: Deal with USS properly */ parcel_w_int32(&rilp, 0); parcel_w_int32(&rilp, 0); /* Send request to RIL */ ret = g_ril_send(vd->ril, RIL_REQUEST_DIAL, rilp.data, rilp.size, rild_cb, cbd, g_free); parcel_free(&rilp); /* In case of error free cbd and return the cb with failure */ if (ret <= 0) { g_free(cbd); CALLBACK_WITH_FAILURE(cb, data); } }
static void append_subscriber_numbers(GSList *subscriber_numbers, DBusMessageIter *iter) { DBusMessageIter entry; DBusMessageIter variant, array; GSList *l; const char *subscriber_number_string; char arraysig[3]; const char *key = "SubscriberNumbers"; arraysig[0] = DBUS_TYPE_ARRAY; arraysig[1] = DBUS_TYPE_STRING; arraysig[2] = '\0'; dbus_message_iter_open_container(iter, DBUS_TYPE_DICT_ENTRY, NULL, &entry); dbus_message_iter_append_basic(&entry, DBUS_TYPE_STRING, &key); dbus_message_iter_open_container(&entry, DBUS_TYPE_VARIANT, arraysig, &variant); dbus_message_iter_open_container(&variant, DBUS_TYPE_ARRAY, DBUS_TYPE_STRING_AS_STRING, &array); for (l = subscriber_numbers; l; l = l->next) { subscriber_number_string = phone_number_to_string(l->data); dbus_message_iter_append_basic(&array, DBUS_TYPE_STRING, &subscriber_number_string); } dbus_message_iter_close_container(&variant, &array); dbus_message_iter_close_container(&entry, &variant); dbus_message_iter_close_container(iter, &entry); }
static DBusMessage *generate_get_properties_reply(struct ofono_sms *sms, DBusMessage *msg) { DBusMessage *reply; DBusMessageIter iter; DBusMessageIter dict; const char *sca; const char *bearer; reply = dbus_message_new_method_return(msg); if (!reply) return NULL; dbus_message_iter_init_append(reply, &iter); dbus_message_iter_open_container(&iter, DBUS_TYPE_ARRAY, OFONO_PROPERTIES_ARRAY_SIGNATURE, &dict); sca = phone_number_to_string(&sms->sca); ofono_dbus_dict_append(&dict, "ServiceCenterAddress", DBUS_TYPE_STRING, &sca); ofono_dbus_dict_append(&dict, "UseDeliveryReports", DBUS_TYPE_BOOLEAN, &sms->use_delivery_reports); bearer = sms_bearer_to_string(sms->bearer); ofono_dbus_dict_append(&dict, "Bearer", DBUS_TYPE_STRING, &bearer); dbus_message_iter_close_container(&iter, &dict); return reply; }
void g_ril_request_dial(GRil *gril, const struct ofono_phone_number *ph, enum ofono_clir_option clir, struct parcel *rilp) { parcel_init(rilp); /* Number to dial */ parcel_w_string(rilp, phone_number_to_string(ph)); /* CLIR mode */ parcel_w_int32(rilp, clir); /* USS, empty string */ /* TODO: Deal with USS properly */ parcel_w_int32(rilp, 0); parcel_w_int32(rilp, 0); g_ril_append_print_buf(gril, "(%s,%d,0,0)", phone_number_to_string(ph), clir); }
static void set_sca(struct ofono_sms *sms, const struct ofono_phone_number *sca) { DBusConnection *conn = ofono_dbus_get_connection(); const char *path = __ofono_atom_get_path(sms->atom); const char *value; if (sms->sca.type == sca->type && !strcmp(sms->sca.number, sca->number)) return; sms->sca.type = sca->type; strncpy(sms->sca.number, sca->number, OFONO_MAX_PHONE_NUMBER_LENGTH); sms->sca.number[OFONO_MAX_PHONE_NUMBER_LENGTH] = '\0'; value = phone_number_to_string(&sms->sca); ofono_dbus_signal_property_changed(conn, path, OFONO_MESSAGE_MANAGER_INTERFACE, "ServiceCenterAddress", DBUS_TYPE_STRING, &value); }
static void request_phone_number_cb(const struct ofono_error *error, const struct ofono_phone_number *number, void *data) { struct ofono_handsfree *hf = data; DBusMessage *reply; const char *phone_number; if (error->type != OFONO_ERROR_TYPE_NO_ERROR) { DBG("Phone number request callback returned error: %s", telephony_error_to_str(error)); reply = __ofono_error_failed(hf->pending); __ofono_dbus_pending_reply(&hf->pending, reply); return; } phone_number = phone_number_to_string(number); reply = dbus_message_new_method_return(hf->pending); dbus_message_append_args(reply, DBUS_TYPE_STRING, &phone_number, DBUS_TYPE_INVALID); __ofono_dbus_pending_reply(&hf->pending, reply); }
static void set_new_cond_list(struct ofono_call_forwarding *cf, int type, GSList *list) { GSList *old = cf->cf_conditions[type]; DBusConnection *conn = ofono_dbus_get_connection(); const char *path = __ofono_atom_get_path(cf->atom); GSList *l; GSList *o; struct ofono_call_forwarding_condition *lc; struct ofono_call_forwarding_condition *oc; const char *number; dbus_uint16_t timeout; char attr[64]; char tattr[64]; gboolean update_sim = FALSE; gboolean old_cfu; gboolean new_cfu; if ((cf->flags & CALL_FORWARDING_FLAG_CPHS_CFF) || cf->cfis_record_id > 0) old_cfu = is_cfu_enabled(cf, NULL); else old_cfu = FALSE; for (l = list; l; l = l->next) { lc = l->data; /* * New condition lists might have attributes we don't care about * triggered by e.g. ss control magic strings just skip them * here. For now we only support Voice, although Fax & all Data * basic services are applicable as well. */ if (lc->cls > BEARER_CLASS_VOICE) continue; timeout = lc->time; number = phone_number_to_string(&lc->phone_number); snprintf(attr, sizeof(attr), "%s%s", bearer_class_to_string(lc->cls), cf_type_lut[type]); if (type == CALL_FORWARDING_TYPE_NO_REPLY) snprintf(tattr, sizeof(tattr), "%sTimeout", attr); o = g_slist_find_custom(old, GINT_TO_POINTER(lc->cls), cf_condition_find_with_cls); if (o) { /* On the old list, must be active */ oc = o->data; if (oc->phone_number.type != lc->phone_number.type || strcmp(oc->phone_number.number, lc->phone_number.number)) { ofono_dbus_signal_property_changed(conn, path, OFONO_CALL_FORWARDING_INTERFACE, attr, DBUS_TYPE_STRING, &number); if (type == CALL_FORWARDING_TYPE_UNCONDITIONAL) update_sim = TRUE; } if (type == CALL_FORWARDING_TYPE_NO_REPLY && oc->time != lc->time) ofono_dbus_signal_property_changed(conn, path, OFONO_CALL_FORWARDING_INTERFACE, tattr, DBUS_TYPE_UINT16, &timeout); /* Remove from the old list */ g_free(o->data); old = g_slist_remove(old, o->data); } else { number = phone_number_to_string(&lc->phone_number); ofono_dbus_signal_property_changed(conn, path, OFONO_CALL_FORWARDING_INTERFACE, attr, DBUS_TYPE_STRING, &number); if (type == CALL_FORWARDING_TYPE_UNCONDITIONAL) update_sim = TRUE; if (type == CALL_FORWARDING_TYPE_NO_REPLY && lc->time != DEFAULT_NO_REPLY_TIMEOUT) ofono_dbus_signal_property_changed(conn, path, OFONO_CALL_FORWARDING_INTERFACE, tattr, DBUS_TYPE_UINT16, &timeout); } } timeout = DEFAULT_NO_REPLY_TIMEOUT; number = ""; for (o = old; o; o = o->next) { oc = o->data; /* * For now we only support Voice, although Fax & all Data * basic services are applicable as well. */ if (oc->cls > BEARER_CLASS_VOICE) continue; snprintf(attr, sizeof(attr), "%s%s", bearer_class_to_string(oc->cls), cf_type_lut[type]); if (type == CALL_FORWARDING_TYPE_NO_REPLY) snprintf(tattr, sizeof(tattr), "%sTimeout", attr); ofono_dbus_signal_property_changed(conn, path, OFONO_CALL_FORWARDING_INTERFACE, attr, DBUS_TYPE_STRING, &number); if (type == CALL_FORWARDING_TYPE_UNCONDITIONAL) update_sim = TRUE; if (type == CALL_FORWARDING_TYPE_NO_REPLY && oc->time != DEFAULT_NO_REPLY_TIMEOUT) ofono_dbus_signal_property_changed(conn, path, OFONO_CALL_FORWARDING_INTERFACE, tattr, DBUS_TYPE_UINT16, &timeout); } cf_list_clear(old); cf->cf_conditions[type] = list; if (update_sim == TRUE) sim_set_cf_indicator(cf); if ((cf->flags & CALL_FORWARDING_FLAG_CPHS_CFF) || cf->cfis_record_id > 0) new_cfu = is_cfu_enabled(cf, NULL); else new_cfu = FALSE; if (new_cfu != old_cfu) { ofono_bool_t status = new_cfu; ofono_dbus_signal_property_changed(conn, path, OFONO_CALL_FORWARDING_INTERFACE, "ForwardingFlagOnSim", DBUS_TYPE_BOOLEAN, &status); } }
static void sim_cfis_read_cb(int ok, int total_length, int record, const unsigned char *data, int record_length, void *userdata) { struct ofono_call_forwarding *cf = userdata; DBusConnection *conn = ofono_dbus_get_connection(); const char *path = __ofono_atom_get_path(cf->atom); if (!ok || record_length < 16 || total_length < record_length) { cf->cfis_record_id = 0; return; } /* * Multiple Subscriber Profile number which can have values 1-4. * Profile id 1 is assumed as the current profile. */ if (data[0] != 1) return; cf->cfis_record_id = record; if (cf->flags & CALL_FORWARDING_FLAG_CACHED) return; /* * For now we only support Voice, although Fax & all Data * basic services are applicable as well. */ if (data[1] & 0x01) { int ton_npi; int number_len; const char *number; char attr[64]; struct ofono_call_forwarding_condition *cond; dbus_bool_t status; number_len = data[2]; ton_npi = data[3]; if (number_len > 11 || ton_npi == 0xff) return; cond = g_try_new0(struct ofono_call_forwarding_condition, 1); if (cond == NULL) return; status = TRUE; cond->status = TRUE; cond->cls = BEARER_CLASS_VOICE; cond->time = 0; cond->phone_number.type = ton_npi; sim_extract_bcd_number(data + 4, number_len - 1, cond->phone_number.number); number = phone_number_to_string(&cond->phone_number); snprintf(attr, sizeof(attr), "%s%s", bearer_class_to_string(BEARER_CLASS_VOICE), cf_type_lut[CALL_FORWARDING_TYPE_UNCONDITIONAL]); cf->cf_conditions[CALL_FORWARDING_TYPE_UNCONDITIONAL] = g_slist_append(NULL, cond); ofono_dbus_signal_property_changed(conn, path, OFONO_CALL_FORWARDING_INTERFACE, attr, DBUS_TYPE_STRING, &number); ofono_dbus_signal_property_changed(conn, path, OFONO_CALL_FORWARDING_INTERFACE, "ForwardingFlagOnSim", DBUS_TYPE_BOOLEAN, &status); }