Ejemplo n.º 1
0
static DBusMessage *cv_get_properties(DBusConnection *conn,
						DBusMessage *msg, void *data)
{
	struct ofono_call_volume *cv = data;
	DBusMessage *reply;
	DBusMessageIter iter, dict;
	dbus_bool_t muted;

	reply = dbus_message_new_method_return(msg);
	if (reply == NULL)
		return NULL;

	dbus_message_iter_init_append(reply, &iter);

	dbus_message_iter_open_container(&iter, DBUS_TYPE_ARRAY,
					OFONO_PROPERTIES_ARRAY_SIGNATURE,
					&dict);

	ofono_dbus_dict_append(&dict, "SpeakerVolume", DBUS_TYPE_BYTE,
					&cv->speaker_volume);

	ofono_dbus_dict_append(&dict, "MicrophoneVolume",
					DBUS_TYPE_BYTE, &cv->microphone_volume);

	muted = cv->muted;
	ofono_dbus_dict_append(&dict, "Muted", DBUS_TYPE_BOOLEAN, &muted);

	dbus_message_iter_close_container(&iter, &dict);

	return reply;
}
Ejemplo n.º 2
0
static void cm_get_properties_reply(struct ofono_call_meter *cm)
{
	DBusMessage *reply;
	DBusMessageIter iter, dict;
	const char *currency = cm->currency;

	reply = dbus_message_new_method_return(cm->pending);
	if (reply == NULL)
		return;

	dbus_message_iter_init_append(reply, &iter);

	dbus_message_iter_open_container(&iter, DBUS_TYPE_ARRAY,
					OFONO_PROPERTIES_ARRAY_SIGNATURE,
					&dict);

	ofono_dbus_dict_append(&dict, "CallMeter", DBUS_TYPE_UINT32,
				&cm->call_meter);

	ofono_dbus_dict_append(&dict, "AccumulatedCallMeter", DBUS_TYPE_UINT32,
				&cm->acm);

	ofono_dbus_dict_append(&dict, "AccumulatedCallMeterMaximum",
				DBUS_TYPE_UINT32, &cm->acm_max);

	ofono_dbus_dict_append(&dict, "PricePerUnit", DBUS_TYPE_DOUBLE,
				&cm->ppu);

	ofono_dbus_dict_append(&dict, "Currency", DBUS_TYPE_STRING, &currency);

	dbus_message_iter_close_container(&iter, &dict);

	__ofono_dbus_pending_reply(&cm->pending, reply);
}
Ejemplo n.º 3
0
static DBusMessage *location_reporting_get_properties(DBusConnection *conn,
						DBusMessage *msg, void *data)

{
	struct ofono_location_reporting *lr = data;
	DBusMessage *reply;
	DBusMessageIter iter;
	DBusMessageIter dict;
	const char *type;
	int value;

	reply = dbus_message_new_method_return(msg);
	if (reply == NULL)
		return NULL;

	dbus_message_iter_init_append(reply, &iter);
	dbus_message_iter_open_container(&iter, DBUS_TYPE_ARRAY,
					OFONO_PROPERTIES_ARRAY_SIGNATURE,
					&dict);

	value = lr->enabled;
	ofono_dbus_dict_append(&dict, "Enabled", DBUS_TYPE_BOOLEAN, &value);

	type = location_reporting_type_to_string(lr->driver->type);
	ofono_dbus_dict_append(&dict, "Type", DBUS_TYPE_STRING, &type);

	dbus_message_iter_close_container(&iter, &dict);

	return reply;
}
Ejemplo n.º 4
0
static DBusMessage *audio_get_properties_reply(DBusMessage *msg,
					struct ofono_audio_settings *as)
{
	DBusMessage *reply;
	DBusMessageIter iter;
	DBusMessageIter dict;

	reply = dbus_message_new_method_return(msg);
	if (reply == NULL)
		return NULL;

	dbus_message_iter_init_append(reply, &iter);

	dbus_message_iter_open_container(&iter, DBUS_TYPE_ARRAY,
					OFONO_PROPERTIES_ARRAY_SIGNATURE,
					&dict);

	ofono_dbus_dict_append(&dict, "Active", DBUS_TYPE_BOOLEAN, &as->active);

	if (as->mode)
		ofono_dbus_dict_append(&dict, "Mode",
					DBUS_TYPE_STRING, &as->mode);

	dbus_message_iter_close_container(&iter, &dict);

	return reply;
}
Ejemplo n.º 5
0
Archivo: sms.c Proyecto: yongsu/oFono
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;
}
Ejemplo n.º 6
0
static DBusMessage *radio_get_properties_reply(DBusMessage *msg,
						struct ofono_radio_settings *rs)
{
	DBusMessage *reply;
	DBusMessageIter iter;
	DBusMessageIter dict;

	const char *mode = radio_access_mode_to_string(rs->mode);

	reply = dbus_message_new_method_return(msg);
	if (reply == NULL)
		return NULL;

	dbus_message_iter_init_append(reply, &iter);

	dbus_message_iter_open_container(&iter, DBUS_TYPE_ARRAY,
					OFONO_PROPERTIES_ARRAY_SIGNATURE,
					&dict);

	ofono_dbus_dict_append(&dict, "TechnologyPreference",
					DBUS_TYPE_STRING, &mode);

	if (rs->driver->query_band) {
		const char *band = radio_band_gsm_to_string(rs->band_gsm);

		ofono_dbus_dict_append(&dict, "GsmBand",
					DBUS_TYPE_STRING, &band);

		band = radio_band_umts_to_string(rs->band_umts);

		ofono_dbus_dict_append(&dict, "UmtsBand",
					DBUS_TYPE_STRING, &band);
	}

	if (rs->driver->query_fast_dormancy) {
		dbus_bool_t value = rs->fast_dormancy;
		ofono_dbus_dict_append(&dict, "FastDormancy",
					DBUS_TYPE_BOOLEAN, &value);
	}

	if (rs->driver->query_modem_rats) {
		const char *rats_strs[OFONO_RADIO_ACCESS_MODE_LAST + 1];
		const char *(*strs)[] = &rats_strs;
		int i, str_i;

		for (i = 0, str_i = 0; i < OFONO_RADIO_ACCESS_MODE_LAST; ++i)
			if (rs->modem_rats[i])
				rats_strs[str_i++] =
						radio_access_mode_to_string(i);
		rats_strs[str_i] = NULL;

		ofono_dbus_dict_append_array(&dict, "ModemTechnologies",
						DBUS_TYPE_STRING, &strs);
	}

	dbus_message_iter_close_container(&iter, &dict);

	return reply;
}
Ejemplo n.º 7
0
void __dundee_device_append_properties(struct dundee_device *device,
                                       DBusMessageIter *dict)
{
    settings_append_dict(device, dict);

    ofono_dbus_dict_append(dict, "Name", DBUS_TYPE_STRING,
                           &device->name);

    ofono_dbus_dict_append(dict, "Active", DBUS_TYPE_BOOLEAN,
                           &device->active);
}
Ejemplo n.º 8
0
static DBusMessage *network_get_properties(DBusConnection *conn,
						DBusMessage *msg, void *data)
{
	struct ofono_cdma_netreg *cdma_netreg = data;
	DBusMessage *reply;
	DBusMessageIter iter;
	DBusMessageIter dict;

	const char *status = cdma_netreg_status_to_string(cdma_netreg->status);

	reply = dbus_message_new_method_return(msg);
	if (reply == NULL)
		return NULL;

	dbus_message_iter_init_append(reply, &iter);

	dbus_message_iter_open_container(&iter, DBUS_TYPE_ARRAY,
					OFONO_PROPERTIES_ARRAY_SIGNATURE,
					&dict);

	ofono_dbus_dict_append(&dict, "Status", DBUS_TYPE_STRING, &status);

	if (cdma_netreg->strength != -1) {
		unsigned char strength = cdma_netreg->strength;

		ofono_dbus_dict_append(&dict, "Strength", DBUS_TYPE_BYTE,
					&strength);
	}

	if (cdma_netreg->hdr_strength != -1) {
		unsigned char strength = cdma_netreg->hdr_strength;

		ofono_dbus_dict_append(&dict, "DataStrength", DBUS_TYPE_BYTE,
					&strength);
	}

	if (cdma_netreg->sid)
		ofono_dbus_dict_append(&dict, "SystemIdentifier",
						DBUS_TYPE_STRING,
						&cdma_netreg->sid);

	if (cdma_netreg->provider_name)
		ofono_dbus_dict_append(&dict, "Name", DBUS_TYPE_STRING,
						&cdma_netreg->provider_name);

	dbus_message_iter_close_container(&iter, &dict);

	return reply;
}
Ejemplo n.º 9
0
static void card_append_properties(struct ofono_handsfree_card *card,
					DBusMessageIter *dict)
{
	const char *type;

	type = card_type_to_string(card->type);
	ofono_dbus_dict_append(dict, "Type",
				DBUS_TYPE_STRING, &type);

	ofono_dbus_dict_append(dict, "RemoteAddress",
				DBUS_TYPE_STRING, &card->remote);

	ofono_dbus_dict_append(dict, "LocalAddress",
				DBUS_TYPE_STRING, &card->local);
}
Ejemplo n.º 10
0
static DBusMessage *ussd_get_properties(DBusConnection *conn,
					DBusMessage *msg, void *data)
{
	struct ofono_ussd *ussd = data;
	DBusMessage *reply;
	DBusMessageIter iter;
	DBusMessageIter dict;
	const char *value;

	reply = dbus_message_new_method_return(msg);
	if (reply == NULL)
		return NULL;

	dbus_message_iter_init_append(reply, &iter);

	dbus_message_iter_open_container(&iter, DBUS_TYPE_ARRAY,
					OFONO_PROPERTIES_ARRAY_SIGNATURE,
					&dict);

	value = ussd_get_state_string(ussd);
	ofono_dbus_dict_append(&dict, "State", DBUS_TYPE_STRING, &value);

	dbus_message_iter_close_container(&iter, &dict);

	return reply;
}
Ejemplo n.º 11
0
static DBusMessage *thermal_management_get_properties(DBusConnection *conn,
							DBusMessage *msg,
							void *data)
{
	struct ril_thermal_management *tm = data;
	DBusMessage *reply;
	DBusMessageIter iter;
	DBusMessageIter dict;

	DBG("");

	reply = dbus_message_new_method_return(msg);
	if (reply == NULL)
		return NULL;

	dbus_message_iter_init_append(reply, &iter);

	dbus_message_iter_open_container(&iter, DBUS_TYPE_ARRAY,
					OFONO_PROPERTIES_ARRAY_SIGNATURE,
					&dict);

	ofono_dbus_dict_append(&dict, "TransmitPowerThrottling",
				DBUS_TYPE_BOOLEAN,
				&tm->throttling);

	dbus_message_iter_close_container(&iter, &dict);

	return reply;
}
Ejemplo n.º 12
0
Archivo: stk.c Proyecto: yongsu/oFono
static DBusMessage *stk_get_properties(DBusConnection *conn,
					DBusMessage *msg, void *data)
{
	struct ofono_stk *stk = data;
	DBusMessage *reply;
	DBusMessageIter iter;
	DBusMessageIter dict;
	const char *idle_mode_text;

	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);

	idle_mode_text = stk->idle_mode_text ? stk->idle_mode_text : "";
	ofono_dbus_dict_append(&dict, "IdleModeText",
				DBUS_TYPE_STRING, &idle_mode_text);

	if (stk->main_menu)
		dict_append_menu(&dict, stk->main_menu);

	dbus_message_iter_close_container(&iter, &dict);

	return reply;
}
Ejemplo n.º 13
0
static DBusMessage *generate_get_properties_reply(struct ofono_handsfree *hf,
						DBusMessage *msg)
{
	DBusMessage *reply;
	DBusMessageIter iter;
	DBusMessageIter dict;
	dbus_bool_t inband_ringing;
	dbus_bool_t voice_recognition;
	const char **features;

	reply = dbus_message_new_method_return(msg);
	if (reply == NULL)
		return NULL;

	dbus_message_iter_init_append(reply, &iter);

	dbus_message_iter_open_container(&iter, DBUS_TYPE_ARRAY,
					OFONO_PROPERTIES_ARRAY_SIGNATURE,
					&dict);

	inband_ringing = hf->inband_ringing;
	ofono_dbus_dict_append(&dict, "InbandRinging", DBUS_TYPE_BOOLEAN,
				&inband_ringing);

	if (hf->ag_features & HFP_AG_FEATURE_ECNR)
		ofono_dbus_dict_append(&dict, "EchoCancelingNoiseReduction",
						DBUS_TYPE_BOOLEAN, &hf->nrec);

	voice_recognition = hf->voice_recognition;
	ofono_dbus_dict_append(&dict, "VoiceRecognition", DBUS_TYPE_BOOLEAN,
				&voice_recognition);

	features = ag_features_list(hf->ag_features, hf->ag_chld_features);
	ofono_dbus_dict_append_array(&dict, "Features", DBUS_TYPE_STRING,
					&features);

	ofono_dbus_dict_append(&dict, "BatteryChargeLevel", DBUS_TYPE_BYTE,
				&hf->battchg);

	if (hf->subscriber_numbers)
		append_subscriber_numbers(hf->subscriber_numbers, &dict);

	dbus_message_iter_close_container(&iter, &dict);

	return reply;
}
Ejemplo n.º 14
0
static DBusMessage *radio_get_properties_reply(DBusMessage *msg,
						struct ofono_radio_settings *rs)
{
	DBusMessage *reply;
	DBusMessageIter iter;
	DBusMessageIter dict;

	const char *mode = radio_access_mode_to_string(rs->mode);

	reply = dbus_message_new_method_return(msg);
	if (reply == NULL)
		return NULL;

	dbus_message_iter_init_append(reply, &iter);

	dbus_message_iter_open_container(&iter, DBUS_TYPE_ARRAY,
					OFONO_PROPERTIES_ARRAY_SIGNATURE,
					&dict);

	ofono_dbus_dict_append(&dict, "TechnologyPreference",
					DBUS_TYPE_STRING, &mode);

	if (rs->driver->query_band) {
		const char *band = radio_band_gsm_to_string(rs->band_gsm);

		ofono_dbus_dict_append(&dict, "GsmBand",
					DBUS_TYPE_STRING, &band);

		band = radio_band_umts_to_string(rs->band_umts);

		ofono_dbus_dict_append(&dict, "UmtsBand",
					DBUS_TYPE_STRING, &band);
	}

	if (rs->driver->query_fast_dormancy) {
		dbus_bool_t value = rs->fast_dormancy;
		ofono_dbus_dict_append(&dict, "FastDormancy",
					DBUS_TYPE_BOOLEAN, &value);
	}

	dbus_message_iter_close_container(&iter, &dict);

	return reply;
}
Ejemplo n.º 15
0
Archivo: stk.c Proyecto: yongsu/oFono
static void emit_menu_changed(struct ofono_stk *stk)
{
	static struct stk_menu_item end_item = {};
	static struct stk_menu no_menu = {
		.title = "",
		.items = &end_item,
		.has_help = FALSE,
		.default_item = -1,
	};
	static char *name = "MainMenu";
	DBusConnection *conn = ofono_dbus_get_connection();
	const char *path = __ofono_atom_get_path(stk->atom);
	struct stk_menu *menu = stk->main_menu ? stk->main_menu : &no_menu;
	DBusMessage *signal;
	DBusMessageIter iter;

	ofono_dbus_signal_property_changed(conn, path,
						OFONO_STK_INTERFACE,
						"MainMenuTitle",
						DBUS_TYPE_STRING, &menu->title);

	signal = dbus_message_new_signal(path, OFONO_STK_INTERFACE,
						"PropertyChanged");
	if (!signal) {
		ofono_error("Unable to allocate new %s.PropertyChanged signal",
				OFONO_SIM_APP_INTERFACE);

		return;
	}

	dbus_message_iter_init_append(signal, &iter);

	dbus_message_iter_append_basic(&iter, DBUS_TYPE_STRING, &name);

	append_menu_items_variant(&iter, menu->items);

	g_dbus_send_message(conn, signal);
}

static void dict_append_menu(DBusMessageIter *dict, struct stk_menu *menu)
{
	DBusMessageIter entry;
	const char *key = "MainMenu";

	ofono_dbus_dict_append(dict, "MainMenuTitle",
				DBUS_TYPE_STRING, &menu->title);

	dbus_message_iter_open_container(dict, DBUS_TYPE_DICT_ENTRY,
						NULL, &entry);

	dbus_message_iter_append_basic(&entry, DBUS_TYPE_STRING, &key);

	append_menu_items_variant(&entry, menu->items);

	dbus_message_iter_close_container(dict, &entry);
}
Ejemplo n.º 16
0
static void settings_append(struct dundee_device *device,
                            DBusMessageIter *iter)
{
    DBusMessageIter variant;
    DBusMessageIter array;
    char typesig[5];
    char arraysig[6];

    arraysig[0] = DBUS_TYPE_ARRAY;
    arraysig[1] = typesig[0] = DBUS_DICT_ENTRY_BEGIN_CHAR;
    arraysig[2] = typesig[1] = DBUS_TYPE_STRING;
    arraysig[3] = typesig[2] = DBUS_TYPE_VARIANT;
    arraysig[4] = typesig[3] = DBUS_DICT_ENTRY_END_CHAR;
    arraysig[5] = typesig[4] = '\0';

    dbus_message_iter_open_container(iter, DBUS_TYPE_VARIANT,
                                     arraysig, &variant);

    dbus_message_iter_open_container(&variant, DBUS_TYPE_ARRAY,
                                     typesig, &array);

    if (device->active == FALSE)
        goto out;

    if (device->settings.interface)
        ofono_dbus_dict_append(&array, "Interface",
                               DBUS_TYPE_STRING, &device->settings.interface);

    if (device->settings.ip)
        ofono_dbus_dict_append(&array, "Address", DBUS_TYPE_STRING,
                               &device->settings.ip);

    if (device->settings.nameservers)
        ofono_dbus_dict_append_array(&array, "DomainNameServers",
                                     DBUS_TYPE_STRING,
                                     &device->settings.nameservers);

out:
    dbus_message_iter_close_container(&variant, &array);

    dbus_message_iter_close_container(iter, &variant);
}
Ejemplo n.º 17
0
static inline void property_append_cf_condition(DBusMessageIter *dict, int cls,
						const char *postfix,
						const char *value,
						dbus_uint16_t timeout)
{
	char attr[64];
	char tattr[64];
	int addt = !strcmp(postfix, "NoReply");

	snprintf(attr, sizeof(attr), "%s%s",
			bearer_class_to_string(cls), postfix);

	if (addt)
		snprintf(tattr, sizeof(tattr), "%s%sTimeout",
				bearer_class_to_string(cls), postfix);

	ofono_dbus_dict_append(dict, attr, DBUS_TYPE_STRING, &value);

	if (addt)
		ofono_dbus_dict_append(dict, tattr, DBUS_TYPE_UINT16, &timeout);
}
Ejemplo n.º 18
0
static DBusMessage *handsfree_get_properties(DBusConnection *conn,
						DBusMessage *msg, void *data)
{
	struct ofono_handsfree *hf = data;
	DBusMessage *reply;
	DBusMessageIter iter;
	DBusMessageIter dict;
	dbus_bool_t inband_ringing;
	dbus_bool_t voice_recognition;
	const char **features;

	reply = dbus_message_new_method_return(msg);
	if (reply == NULL)
		return NULL;

	dbus_message_iter_init_append(reply, &iter);

	dbus_message_iter_open_container(&iter, DBUS_TYPE_ARRAY,
					OFONO_PROPERTIES_ARRAY_SIGNATURE,
					&dict);

	inband_ringing = hf->inband_ringing;
	ofono_dbus_dict_append(&dict, "InbandRinging", DBUS_TYPE_BOOLEAN,
				&inband_ringing);

	voice_recognition = hf->voice_recognition;
	ofono_dbus_dict_append(&dict, "VoiceRecognition", DBUS_TYPE_BOOLEAN,
				&voice_recognition);

	features = ag_features_list(hf->ag_features);
	ofono_dbus_dict_append_array(&dict, "Features", DBUS_TYPE_STRING,
					&features);

	ofono_dbus_dict_append(&dict, "BatteryChargeLevel", DBUS_TYPE_BYTE,
				&hf->battchg);

	dbus_message_iter_close_container(&iter, &dict);

	return reply;
}
Ejemplo n.º 19
0
static void cb_ss_property_append(struct ofono_call_barring *cb,
					DBusMessageIter *dict, int lock,
					int mask)
{
	int i;
	char property_name[64];
	const char *strvalue;

	for (i = 1; i <= BEARER_CLASS_PAD; i = i << 1) {
		if (!(mask & i))
			continue;

		strvalue = (cb->new_locks[lock] & i) ? "enabled" : "disabled";

		snprintf(property_name, sizeof(property_name), "%s%s",
				bearer_class_to_string(i),
				cb_locks[lock].name);

		ofono_dbus_dict_append(dict, property_name, DBUS_TYPE_STRING,
					&strvalue);
	}
}
Ejemplo n.º 20
0
static void cdma_dispatch_text_message(struct ofono_cdma_sms *cdma_sms,
					const char *message,
					const char *oaddr)
{
	const char *path = __ofono_atom_get_path(cdma_sms->atom);
	DBusConnection *conn = ofono_dbus_get_connection();
	DBusMessage *signal;
	DBusMessageIter iter;
	DBusMessageIter dict;
	const char *signal_name;

	/* TODO: Support ImmediateMessage */
	signal_name = "IncomingMessage";

	signal = dbus_message_new_signal(path,
					OFONO_CDMA_MESSAGE_MANAGER_INTERFACE,
					signal_name);
	if (signal == NULL)
		return;

	dbus_message_iter_init_append(signal, &iter);

	dbus_message_iter_append_basic(&iter, DBUS_TYPE_STRING, &message);

	dbus_message_iter_open_container(&iter, DBUS_TYPE_ARRAY,
					OFONO_PROPERTIES_ARRAY_SIGNATURE,
					&dict);

	ofono_dbus_dict_append(&dict, "Sender", DBUS_TYPE_STRING, &oaddr);

	/* TODO: Other properties not supported yet */

	dbus_message_iter_close_container(&iter, &dict);

	g_dbus_send_message(conn, signal);

	/*TODO: Add the message to history*/
}
Ejemplo n.º 21
0
static DBusMessage *cf_get_properties_reply(DBusMessage *msg,
						struct ofono_call_forwarding *cf)
{
	DBusMessage *reply;
	DBusMessageIter iter;
	DBusMessageIter dict;
	int i;
	dbus_bool_t status;

	reply = dbus_message_new_method_return(msg);
	if (reply == NULL)
		return NULL;

	dbus_message_iter_init_append(reply, &iter);

	dbus_message_iter_open_container(&iter, DBUS_TYPE_ARRAY,
					OFONO_PROPERTIES_ARRAY_SIGNATURE,
						&dict);

	for (i = 0; i < 4; i++)
		property_append_cf_conditions(&dict, cf->cf_conditions[i],
						BEARER_CLASS_VOICE,
						cf_type_lut[i]);

	if ((cf->flags & CALL_FORWARDING_FLAG_CPHS_CFF) ||
			cf->cfis_record_id > 0)
		status = is_cfu_enabled(cf, NULL);
	else
		status = FALSE;

	ofono_dbus_dict_append(&dict, "ForwardingFlagOnSim", DBUS_TYPE_BOOLEAN,
					&status);

	dbus_message_iter_close_container(&iter, &dict);

	return reply;
}
Ejemplo n.º 22
0
Archivo: sms.c Proyecto: AndriusA/ofono
static void dispatch_text_message(struct ofono_sms *sms,
					const struct ofono_uuid *uuid,
					const char *message,
					enum sms_class cls,
					const struct sms_address *addr,
					const struct sms_scts *scts)
{
	struct ofono_modem *modem = __ofono_atom_get_modem(sms->atom);
	DBusConnection *conn = ofono_dbus_get_connection();
	const char *path = __ofono_atom_get_path(sms->atom);
	DBusMessage *signal;
	DBusMessageIter iter;
	DBusMessageIter dict;
	char buf[128];
	const char *signal_name;
	time_t ts;
	struct tm remote;
	struct tm local;
	const char *str = buf;
	ofono_sms_text_notify_cb_t notify;
	struct sms_handler *h;
	GSList *l;

	if (message == NULL)
		return;

	if (cls == SMS_CLASS_0)
		signal_name = "ImmediateMessage";
	else
		signal_name = "IncomingMessage";

	signal = dbus_message_new_signal(path, OFONO_MESSAGE_MANAGER_INTERFACE,
						signal_name);

	if (signal == NULL)
		return;

	dbus_message_iter_init_append(signal, &iter);

	dbus_message_iter_append_basic(&iter, DBUS_TYPE_STRING, &message);

	dbus_message_iter_open_container(&iter, DBUS_TYPE_ARRAY,
					OFONO_PROPERTIES_ARRAY_SIGNATURE,
						&dict);

	ts = sms_scts_to_time(scts, &remote);
	localtime_r(&ts, &local);

	strftime(buf, 127, "%Y-%m-%dT%H:%M:%S%z", &local);
	buf[127] = '\0';
	ofono_dbus_dict_append(&dict, "LocalSentTime", DBUS_TYPE_STRING, &str);

	strftime(buf, 127, "%Y-%m-%dT%H:%M:%S%z", &remote);
	buf[127] = '\0';
	ofono_dbus_dict_append(&dict, "SentTime", DBUS_TYPE_STRING, &str);

	str = sms_address_to_string(addr);
	ofono_dbus_dict_append(&dict, "Sender", DBUS_TYPE_STRING, &str);

	dbus_message_iter_close_container(&iter, &dict);

	g_dbus_send_message(conn, signal);

	if (cls == SMS_CLASS_0)
		return;

	for (l = sms->text_handlers->items; l; l = l->next) {
		h = l->data;
		notify = h->item.notify;

		notify(str, &remote, &local, message, h->item.notify_data);
	}

	__ofono_history_sms_received(modem, uuid, str, &remote, &local,
					message);
}
Ejemplo n.º 23
0
void __ofono_modem_append_properties(struct ofono_modem *modem,
						DBusMessageIter *dict)
{
	char **interfaces;
	char **features;
	int i;
	GSList *l;
	struct ofono_devinfo *info;
	dbus_bool_t emergency = ofono_modem_get_emergency_mode(modem);
	const char *strtype;

	ofono_dbus_dict_append(dict, "Online", DBUS_TYPE_BOOLEAN,
				&modem->online);

	ofono_dbus_dict_append(dict, "Powered", DBUS_TYPE_BOOLEAN,
				&modem->powered);

	ofono_dbus_dict_append(dict, "Lockdown", DBUS_TYPE_BOOLEAN,
				&modem->lockdown);

	ofono_dbus_dict_append(dict, "Emergency", DBUS_TYPE_BOOLEAN,
				&emergency);

	info = __ofono_atom_find(OFONO_ATOM_TYPE_DEVINFO, modem);
	if (info) {
		if (info->manufacturer)
			ofono_dbus_dict_append(dict, "Manufacturer",
						DBUS_TYPE_STRING,
						&info->manufacturer);

		if (info->model)
			ofono_dbus_dict_append(dict, "Model", DBUS_TYPE_STRING,
						&info->model);

		if (info->revision)
			ofono_dbus_dict_append(dict, "Revision",
						DBUS_TYPE_STRING,
						&info->revision);

		if (info->serial)
			ofono_dbus_dict_append(dict, "Serial",
						DBUS_TYPE_STRING,
						&info->serial);
	}

	interfaces = g_new0(char *, g_slist_length(modem->interface_list) + 1);
	for (i = 0, l = modem->interface_list; l; l = l->next, i++)
		interfaces[i] = l->data;
	ofono_dbus_dict_append_array(dict, "Interfaces", DBUS_TYPE_STRING,
					&interfaces);
	g_free(interfaces);

	features = g_new0(char *, g_slist_length(modem->feature_list) + 1);
	for (i = 0, l = modem->feature_list; l; l = l->next, i++)
		features[i] = l->data;
	ofono_dbus_dict_append_array(dict, "Features", DBUS_TYPE_STRING,
					&features);
	g_free(features);

	if (modem->name)
		ofono_dbus_dict_append(dict, "Name", DBUS_TYPE_STRING,
					&modem->name);

	strtype = modem_type_to_string(modem->driver->modem_type);
	ofono_dbus_dict_append(dict, "Type", DBUS_TYPE_STRING, &strtype);
}
Ejemplo n.º 24
0
static void sms_history_sms_send_status(
					struct ofono_history_context *context,
					const struct ofono_uuid *uuid,
					time_t when,
					enum ofono_history_sms_status s)
{
	if ((s == OFONO_HISTORY_SMS_STATUS_DELIVERED)
			|| (s == OFONO_HISTORY_SMS_STATUS_DELIVER_FAILED)) {

		DBusMessage *signal;
		DBusMessageIter iter;
		DBusMessageIter dict;
		const char *uuid_str;
		char *msg_uuid_str;
		size_t msg_len;
		struct ofono_atom *atom;
		const char *path;
		DBusConnection *conn;
		int delivered;

		atom = __ofono_modem_find_atom(context->modem,
						OFONO_ATOM_TYPE_SMS);
		if (atom == NULL)
			return;

		path = __ofono_atom_get_path(atom);
		if (path == NULL)
			return;

		conn = ofono_dbus_get_connection();
		if (conn == NULL)
			return;

		delivered = (s == OFONO_HISTORY_SMS_STATUS_DELIVERED);

		uuid_str = ofono_uuid_to_str(uuid);
		/* sizeof adds extra space for one '\0' */
		msg_len = strlen(path) + sizeof(msg_prefix)
				+ strlen(uuid_str);

		msg_uuid_str = g_try_malloc(msg_len);
		if (msg_uuid_str == NULL)
			return;

		/* modem path + msg_prefix + UUID as string */
		snprintf(msg_uuid_str, msg_len, "%s%s%s", path,
				msg_prefix, uuid_str);

		DBG("SMS %s delivery success: %d", msg_uuid_str, delivered);

		signal = dbus_message_new_signal(path,
					OFONO_MESSAGE_MANAGER_INTERFACE,
					"StatusReport");
		if (signal != NULL) {
			dbus_message_iter_init_append(signal, &iter);
			dbus_message_iter_append_basic(&iter, DBUS_TYPE_STRING,
							&msg_uuid_str);

			dbus_message_iter_open_container(
					&iter,
					DBUS_TYPE_ARRAY,
					OFONO_PROPERTIES_ARRAY_SIGNATURE,
					&dict);
			ofono_dbus_dict_append(&dict, "Delivered",
						DBUS_TYPE_BOOLEAN,
						&delivered);
			dbus_message_iter_close_container(&iter, &dict);

			g_dbus_send_message(conn, signal);
		}

		g_free(msg_uuid_str);
	}
}
Ejemplo n.º 25
0
static DBusMessage *radio_get_properties_reply(DBusMessage *msg,
						struct ofono_radio_settings *rs)
{
	DBusMessage *reply;
	DBusMessageIter iter;
	DBusMessageIter dict;

	const char *mode = radio_access_mode_to_string(rs->mode);

	reply = dbus_message_new_method_return(msg);
	if (reply == NULL)
		return NULL;

	dbus_message_iter_init_append(reply, &iter);

	dbus_message_iter_open_container(&iter, DBUS_TYPE_ARRAY,
					OFONO_PROPERTIES_ARRAY_SIGNATURE,
					&dict);

	ofono_dbus_dict_append(&dict, "TechnologyPreference",
					DBUS_TYPE_STRING, &mode);

	if (rs->driver->query_band) {
		const char *band = radio_band_gsm_to_string(rs->band_gsm);

		ofono_dbus_dict_append(&dict, "GsmBand",
					DBUS_TYPE_STRING, &band);

		band = radio_band_umts_to_string(rs->band_umts);

		ofono_dbus_dict_append(&dict, "UmtsBand",
					DBUS_TYPE_STRING, &band);
	}

	if (rs->driver->query_fast_dormancy) {
		dbus_bool_t value = rs->fast_dormancy;
		ofono_dbus_dict_append(&dict, "FastDormancy",
					DBUS_TYPE_BOOLEAN, &value);
	}

	if (rs->available_rats) {
		const char *rats[sizeof(uint32_t) * CHAR_BIT + 1];
		const char **dbus_rats = rats;
		int n = 0;
		unsigned int i;

		for (i = 0; i < sizeof(uint32_t) * CHAR_BIT; i++) {
			int tech = 1 << i;

			if (!(rs->available_rats & tech))
				continue;

			rats[n++] = radio_access_mode_to_string(tech);
		}

		rats[n] = NULL;

		ofono_dbus_dict_append_array(&dict, "AvailableTechnologies",
						DBUS_TYPE_STRING, &dbus_rats);
	}

	dbus_message_iter_close_container(&iter, &dict);

	return reply;
}
Ejemplo n.º 26
0
void message_append_properties(struct message *m, DBusMessageIter *dict)
{
	const char *state = message_state_to_string(m->state);

	ofono_dbus_dict_append(dict, "State", DBUS_TYPE_STRING, &state);
}