Example #1
0
static inline void emit_barring_changed(struct ofono_call_barring *cb,
					int start, int end,
					const char *type, int cls)
{
	DBusConnection *conn = ofono_dbus_get_connection();
	const char *path = __ofono_atom_get_path(cb->atom);
	char property_name[64];
	const char *value;
	int i;
	int j;

	for (i = start; i <= end; i++)
		if (cb->cur_locks[i] & cls)
			break;

	for (j = start; j <= end; j++)
		if (cb->new_locks[j] & cls)
			break;

	if (i == j)
		return;

	if (j > end)
		value = "disabled";
	else
		value = cb_locks[j].value;

	snprintf(property_name, sizeof(property_name), "%s%s",
			bearer_class_to_string(cls), type);

	ofono_dbus_signal_property_changed(conn, path,
						OFONO_CALL_BARRING_INTERFACE,
						property_name, DBUS_TYPE_STRING,
						&value);
}
Example #2
0
static void radio_set_band(struct ofono_radio_settings *rs)
{
	DBusConnection *conn = ofono_dbus_get_connection();
	const char *path;
	const char *str_band;

	path = __ofono_atom_get_path(rs->atom);

	if (rs->band_gsm != rs->pending_band_gsm) {
		rs->band_gsm = rs->pending_band_gsm;
		str_band = radio_band_gsm_to_string(rs->band_gsm);

		ofono_dbus_signal_property_changed(conn, path,
						OFONO_RADIO_SETTINGS_INTERFACE,
						"GsmBand", DBUS_TYPE_STRING,
						&str_band);
	}

	if (rs->band_umts != rs->pending_band_umts) {
		rs->band_umts = rs->pending_band_umts;
		str_band = radio_band_umts_to_string(rs->band_umts);

		ofono_dbus_signal_property_changed(conn, path,
						OFONO_RADIO_SETTINGS_INTERFACE,
						"UmtsBand", DBUS_TYPE_STRING,
						&str_band);
	}

}
Example #3
0
static void set_currency(struct ofono_call_meter *cm, const char *value)
{
	DBusConnection *conn;
	const char *path;
	const char *dbusval;

	if (strlen(value) > 3) {
		ofono_error("Currency reported with size > 3: %s", value);
		return;
	}

	if (!strcmp(cm->currency, value))
		return;

	strncpy(cm->currency, value, 3);
	cm->currency[3] = '\0';

	conn = ofono_dbus_get_connection();
	path = __ofono_atom_get_path(cm->atom);
	dbusval = cm->currency;

	ofono_dbus_signal_property_changed(conn, path,
						OFONO_CALL_METER_INTERFACE,
						"Currency", DBUS_TYPE_STRING,
						&dbusval);
}
Example #4
0
File: sms.c Project: AndriusA/ofono
/*
 * 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);
}
Example #5
0
static void strength_notify_common(struct ofono_cdma_netreg *netreg,
					int strength, const char *property,
					int *dest)
{
	if (netreg == NULL)
		return;

	if (*dest == strength)
		return;

	/*
	 * Theoretically we can get signal strength even when not registered
	 * to any network.  However, what do we do with it in that case?
	 */
	if (netreg->status == CDMA_NETWORK_REGISTRATION_STATUS_NOT_REGISTERED)
		return;

	*dest = strength;

	if (strength != -1) {
		DBusConnection *conn = ofono_dbus_get_connection();
		const char *path = __ofono_atom_get_path(netreg->atom);
		unsigned char val = strength;

		ofono_dbus_signal_property_changed(conn, path,
				OFONO_CDMA_NETWORK_REGISTRATION_INTERFACE,
				property, DBUS_TYPE_BYTE, &val);
	}
}
Example #6
0
void message_emit_added(struct message *m, const char *interface)
{
	DBusMessage *signal;
	DBusMessageIter iter;
	DBusMessageIter dict;
	const char *path;
	const char *atompath = __ofono_atom_get_path(m->atom);

	signal = dbus_message_new_signal(atompath, interface, "MessageAdded");
	if (signal == NULL)
		return;

	path = message_path_from_uuid(m->atom, &m->uuid);

	dbus_message_iter_init_append(signal, &iter);

	dbus_message_iter_append_basic(&iter, DBUS_TYPE_OBJECT_PATH, &path);

	dbus_message_iter_open_container(&iter, DBUS_TYPE_ARRAY,
					OFONO_PROPERTIES_ARRAY_SIGNATURE,
					&dict);
	message_append_properties(m, &dict);
	dbus_message_iter_close_container(&iter, &dict);

	g_dbus_send_message(ofono_dbus_get_connection(), signal);
}
Example #7
0
void ofono_call_meter_maximum_notify(struct ofono_call_meter *cm)
{
	DBusConnection *conn = ofono_dbus_get_connection();
	const char *path = __ofono_atom_get_path(cm->atom);

	g_dbus_emit_signal(conn, path, OFONO_CALL_METER_INTERFACE,
			"NearMaximumWarning", DBUS_TYPE_INVALID);
}
Example #8
0
File: stk.c Project: 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);
}
Example #9
0
static void call_volume_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);

	ofono_modem_remove_interface(modem, OFONO_CALL_VOLUME_INTERFACE);
	g_dbus_unregister_interface(conn, path,
					OFONO_CALL_VOLUME_INTERFACE);
}
Example #10
0
static void call_meter_unregister(struct ofono_atom *atom)
{
	struct ofono_call_meter *cm = __ofono_atom_get_data(atom);
	const char *path = __ofono_atom_get_path(cm->atom);
	DBusConnection *conn = ofono_dbus_get_connection();
	struct ofono_modem *modem = __ofono_atom_get_modem(cm->atom);

	ofono_modem_remove_interface(modem, OFONO_CALL_METER_INTERFACE);
	g_dbus_unregister_interface(conn, path, OFONO_CALL_METER_INTERFACE);
}
Example #11
0
static void audio_settings_unregister(struct ofono_atom *atom)
{
	struct ofono_audio_settings *as = __ofono_atom_get_data(atom);
	const char *path = __ofono_atom_get_path(as->atom);
	DBusConnection *conn = ofono_dbus_get_connection();
	struct ofono_modem *modem = __ofono_atom_get_modem(as->atom);

	ofono_modem_remove_interface(modem, OFONO_AUDIO_SETTINGS_INTERFACE);
	g_dbus_unregister_interface(conn, path, OFONO_AUDIO_SETTINGS_INTERFACE);
}
Example #12
0
static void signal_enabled(const struct ofono_location_reporting *lr)
{
	DBusConnection *conn = ofono_dbus_get_connection();
	const char *path = __ofono_atom_get_path(lr->atom);
	int value = lr->enabled;

	ofono_dbus_signal_property_changed(conn, path,
					OFONO_LOCATION_REPORTING_INTERFACE,
					"Enabled", DBUS_TYPE_BOOLEAN, &value);
}
Example #13
0
static void location_reporting_unregister(struct ofono_atom *atom)
{
	struct ofono_location_reporting *lr = __ofono_atom_get_data(atom);
	const char *path = __ofono_atom_get_path(lr->atom);
	DBusConnection *conn = ofono_dbus_get_connection();
	struct ofono_modem *modem = __ofono_atom_get_modem(lr->atom);

	ofono_modem_remove_interface(modem, OFONO_LOCATION_REPORTING_INTERFACE);
	g_dbus_unregister_interface(conn, path,
					OFONO_LOCATION_REPORTING_INTERFACE);
}
Example #14
0
const char *message_path_from_uuid(struct ofono_atom *atom,
						const struct ofono_uuid *uuid)
{
	static char path[256];
	const char *atompath = __ofono_atom_get_path(atom);

	snprintf(path, sizeof(path), "%s/message_%s", atompath,
						ofono_uuid_to_str(uuid));

	return path;
}
Example #15
0
void message_emit_removed(struct message *m, const char *interface)
{
	DBusConnection *conn = ofono_dbus_get_connection();
	const char *atompath = __ofono_atom_get_path(m->atom);
	const char *path = message_path_from_uuid(m->atom, &m->uuid);

	g_dbus_emit_signal(conn, atompath, interface, "MessageRemoved",
							DBUS_TYPE_OBJECT_PATH,
							&path,
							DBUS_TYPE_INVALID);
}
Example #16
0
static void cdma_netreg_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);

	g_dbus_unregister_interface(conn, path,
				OFONO_CDMA_NETWORK_REGISTRATION_INTERFACE);

	ofono_modem_remove_interface(modem,
				OFONO_CDMA_NETWORK_REGISTRATION_INTERFACE);
}
Example #17
0
File: sms.c Project: AndriusA/ofono
static void sms_unregister(struct ofono_atom *atom)
{
	struct ofono_sms *sms = __ofono_atom_get_data(atom);
	DBusConnection *conn = ofono_dbus_get_connection();
	struct ofono_modem *modem = __ofono_atom_get_modem(atom);
	const char *path = __ofono_atom_get_path(atom);

	g_dbus_unregister_interface(conn, path,
					OFONO_MESSAGE_MANAGER_INTERFACE);
	ofono_modem_remove_interface(modem, OFONO_MESSAGE_MANAGER_INTERFACE);

	if (sms->mw_watch) {
		__ofono_modem_remove_atom_watch(modem, sms->mw_watch);
		sms->mw_watch = 0;
		sms->mw = NULL;
	}

	if (sms->status_watch) {
		__ofono_netreg_remove_status_watch(sms->netreg,
							sms->status_watch);
		sms->status_watch = 0;
	}

	if (sms->netreg_watch) {
		__ofono_modem_remove_atom_watch(modem, sms->netreg_watch);
		sms->netreg_watch = 0;
	}

	sms->netreg = NULL;

	if (sms->messages) {
		GHashTableIter iter;
		struct message *m;
		gpointer key, value;

		g_hash_table_iter_init(&iter, sms->messages);

		while (g_hash_table_iter_next(&iter, &key, &value)) {
			m = value;
			message_dbus_unregister(m);
		}

		g_hash_table_destroy(sms->messages);
		sms->messages = NULL;
	}

	__ofono_watchlist_free(sms->text_handlers);
	sms->text_handlers = NULL;

	__ofono_watchlist_free(sms->datagram_handlers);
	sms->datagram_handlers = NULL;
}
Example #18
0
static void gnss_unregister(struct ofono_atom *atom)
{
	struct ofono_gnss *gnss = __ofono_atom_get_data(atom);
	DBusConnection *conn = ofono_dbus_get_connection();
	struct ofono_modem *modem = __ofono_atom_get_modem(atom);
	const char *path = __ofono_atom_get_path(atom);

	if (gnss->posr_agent)
		gnss_agent_free(gnss->posr_agent);

	ofono_modem_remove_interface(modem, OFONO_GNSS_INTERFACE);
	g_dbus_unregister_interface(conn, path, OFONO_GNSS_INTERFACE);
}
Example #19
0
static void oem_raw_dbus_unregister(struct ofono_atom *atom)
{
	DBG("");
	struct ofono_oem_raw *oemraw = __ofono_atom_get_data(atom);
	const char *path = __ofono_atom_get_path(oemraw->atom);
	DBusConnection *conn = ofono_dbus_get_connection();
	struct ofono_modem *modem = __ofono_atom_get_modem(oemraw->atom);

	ofono_modem_remove_interface(modem, OFONO_OEM_RAW_INTERFACE);

	if (!g_dbus_unregister_interface(conn, path, OFONO_OEM_RAW_INTERFACE))
		ofono_error("Failed to unregister interface %s",
				OFONO_OEM_RAW_INTERFACE);
}
Example #20
0
void ofono_call_volume_set_muted(struct ofono_call_volume *cv, int muted)
{
	DBusConnection *conn = ofono_dbus_get_connection();
	const char *path = __ofono_atom_get_path(cv->atom);
	dbus_bool_t m;

	cv->muted = muted;

	if (__ofono_atom_get_registered(cv->atom) == FALSE)
		return;

	m = muted;
	ofono_dbus_signal_property_changed(conn, path,
						OFONO_CALL_VOLUME_INTERFACE,
						"Muted", DBUS_TYPE_BOOLEAN, &m);
}
Example #21
0
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);
}
Example #22
0
static void ussd_change_state(struct ofono_ussd *ussd, int state)
{
	const char *value;
	DBusConnection *conn = ofono_dbus_get_connection();
	const char *path = __ofono_atom_get_path(ussd->atom);

	if (state == ussd->state)
		return;

	ussd->state = state;

	value = ussd_get_state_string(ussd);
	ofono_dbus_signal_property_changed(conn, path,
			OFONO_SUPPLEMENTARY_SERVICES_INTERFACE,
			"State", DBUS_TYPE_STRING, &value);
}
Example #23
0
void ofono_call_volume_set_microphone_volume(struct ofono_call_volume *cv,
						unsigned char percent)
{
	DBusConnection *conn = ofono_dbus_get_connection();
	const char *path = __ofono_atom_get_path(cv->atom);

	cv->microphone_volume = percent;

	if (__ofono_atom_get_registered(cv->atom) == FALSE)
		return;

	ofono_dbus_signal_property_changed(conn, path,
						OFONO_CALL_VOLUME_INTERFACE,
						"MicrophoneVolume",
						DBUS_TYPE_BYTE, &percent);
}
Example #24
0
static void radio_set_fast_dormancy(struct ofono_radio_settings *rs,
					ofono_bool_t enable)
{
	DBusConnection *conn = ofono_dbus_get_connection();
	const char *path = __ofono_atom_get_path(rs->atom);
	dbus_bool_t value = enable;

	if (rs->fast_dormancy == enable)
		return;

	ofono_dbus_signal_property_changed(conn, path,
						OFONO_RADIO_SETTINGS_INTERFACE,
						"FastDormancy",
						DBUS_TYPE_BOOLEAN, &value);
	rs->fast_dormancy = enable;
}
Example #25
0
void ofono_handsfree_voice_recognition_notify(struct ofono_handsfree *hf,
						ofono_bool_t enabled)
{
	DBusConnection *conn = ofono_dbus_get_connection();
	const char *path = __ofono_atom_get_path(hf->atom);
	dbus_bool_t dbus_enabled = enabled;

	if (hf->voice_recognition == enabled)
		return;

	hf->voice_recognition = enabled;

	ofono_dbus_signal_property_changed(conn, path,
					OFONO_HANDSFREE_INTERFACE,
					"VoiceRecognition", DBUS_TYPE_BOOLEAN,
					&dbus_enabled);
}
Example #26
0
static void query_serial_cb(const struct ofono_error *error,
				const char *serial, void *user)
{
	struct ofono_devinfo *info = user;
	DBusConnection *conn = ofono_dbus_get_connection();
	const char *path = __ofono_atom_get_path(info->atom);

	if (error->type != OFONO_ERROR_TYPE_NO_ERROR)
		return;

	info->serial = g_strdup(serial);

	ofono_dbus_signal_property_changed(conn, path,
						OFONO_MODEM_INTERFACE,
						"Serial", DBUS_TYPE_STRING,
						&info->serial);
}
Example #27
0
File: sms.c Project: AndriusA/ofono
static void set_alphabet(struct ofono_sms *sms, enum sms_alphabet alphabet)
{
	DBusConnection *conn = ofono_dbus_get_connection();
	const char *path = __ofono_atom_get_path(sms->atom);
	const char *value;

	if (sms->alphabet == alphabet)
		return;

	sms->alphabet = alphabet;

	value = sms_alphabet_to_string(sms->alphabet);

	ofono_dbus_signal_property_changed(conn, path,
						OFONO_MESSAGE_MANAGER_INTERFACE,
						"Alphabet",
						DBUS_TYPE_STRING, &value);
}
Example #28
0
File: sms.c Project: AndriusA/ofono
static void set_bearer(struct ofono_sms *sms, int bearer)
{
	DBusConnection *conn = ofono_dbus_get_connection();
	const char *path = __ofono_atom_get_path(sms->atom);
	const char *value;

	if (sms->bearer == bearer)
		return;

	sms->bearer = bearer;

	value = sms_bearer_to_string(sms->bearer);

	ofono_dbus_signal_property_changed(conn, path,
						OFONO_MESSAGE_MANAGER_INTERFACE,
						"Bearer",
						DBUS_TYPE_STRING, &value);
}
Example #29
0
void ofono_audio_settings_active_notify(struct ofono_audio_settings *as,
					ofono_bool_t active)
{
	const char *path = __ofono_atom_get_path(as->atom);
	DBusConnection *conn = ofono_dbus_get_connection();

	if (as->active == active)
		return;

	DBG("active %d", active);

	as->active = active;

	ofono_dbus_signal_property_changed(conn, path,
				OFONO_AUDIO_SETTINGS_INTERFACE,
				"Active", DBUS_TYPE_BOOLEAN, &as->active);

}
Example #30
0
void ofono_audio_settings_mode_notify(struct ofono_audio_settings *as,
						const char *mode)
{
	const char *path = __ofono_atom_get_path(as->atom);
	DBusConnection *conn = ofono_dbus_get_connection();

	DBG("mode %s", mode);

	g_free(as->mode);
	as->mode = g_strdup(mode);

	if (as->mode == NULL)
		return;

	ofono_dbus_signal_property_changed(conn, path,
				OFONO_AUDIO_SETTINGS_INTERFACE,
				"Mode", DBUS_TYPE_STRING, &as->mode);
}