Ejemplo n.º 1
0
Archivo: mtk.c Proyecto: semafor/ofono
static void remove_atoms_on_disconnection(struct ofono_modem *modem)
{
	struct mtk_data *md = ofono_modem_get_data(modem);

	if (__ofono_modem_find_atom(modem, OFONO_ATOM_TYPES_CALL_VOLUME))
		ofono_call_volume_remove(md->callvolume);
	md->callvolume = NULL;
	if (__ofono_modem_find_atom(modem, OFONO_ATOM_TYPE_VOICECALL))
		ofono_voicecall_remove(md->voicecall);
	md->voicecall = NULL;
	if (__ofono_modem_find_atom(modem, OFONO_ATOM_TYPE_DEVINFO))
		ofono_devinfo_remove(md->devinfo);
	md->devinfo = NULL;
}
Ejemplo n.º 2
0
static void voicecall_watch(struct ofono_atom *atom,
				enum ofono_atom_watch_condition cond,
				void *data)
{
	struct ofono_atom *sim_atom;
	struct ofono_sim *sim;
	struct ofono_modem *modem;
	DBusConnection *conn = ofono_dbus_get_connection();

	if (cond == OFONO_ATOM_WATCH_CONDITION_UNREGISTERED)
		return;

	/*
	 * This logic is only intended to handle voicecall atoms
	 * registered in post_sim state or later
	 */
	modem = __ofono_atom_get_modem(atom);

	sim_atom = __ofono_modem_find_atom(modem, OFONO_ATOM_TYPE_SIM);
	if (sim_atom == NULL)
		return;

	sim = __ofono_atom_get_data(sim_atom);
	if (ofono_sim_get_state(sim) != OFONO_SIM_STATE_READY)
		return;

	modems = g_list_append(modems, modem);

	if (modems->next != NULL)
		return;

	bt_register_profile(conn, HFP_AG_UUID, HFP_VERSION_1_5, "hfp_ag",
					HFP_AG_EXT_PROFILE_PATH, NULL, 0);
}
Ejemplo n.º 3
0
static void sim_state_watch(enum ofono_sim_state new_state, void *data)
{
	struct ofono_modem *modem = data;
	DBusConnection *conn = ofono_dbus_get_connection();

	if (new_state != OFONO_SIM_STATE_READY) {
		if (modems == NULL)
			return;

		modems = g_list_remove(modems, modem);
		if (modems != NULL)
			return;

		bt_unregister_profile(conn, HFP_AG_EXT_PROFILE_PATH);

		return;
	}

	if (__ofono_modem_find_atom(modem, OFONO_ATOM_TYPE_VOICECALL) == NULL)
		return;

	modems = g_list_append(modems, modem);

	if (modems->next != NULL)
		return;

	bt_register_profile(conn, HFP_AG_UUID, HFP_VERSION_1_5, "hfp_ag",
					HFP_AG_EXT_PROFILE_PATH, NULL, 0);
}
Ejemplo n.º 4
0
Archivo: stk.c Proyecto: yongsu/oFono
static gboolean handle_command_send_sms(const struct stk_command *cmd,
					struct stk_response *rsp,
					struct ofono_stk *stk)
{
	struct ofono_modem *modem = __ofono_atom_get_modem(stk->atom);
	struct ofono_atom *sms_atom;
	struct ofono_sms *sms;
	GSList msg_list;

	sms_atom = __ofono_modem_find_atom(modem, OFONO_ATOM_TYPE_SMS);

	if (!sms_atom || !__ofono_atom_get_registered(sms_atom)) {
		rsp->result.type = STK_RESULT_TYPE_NOT_CAPABLE;
		return TRUE;
	}

	sms = __ofono_atom_get_data(sms_atom);

	stk->sms_submit_req = g_new0(struct sms_submit_req, 1);
	stk->sms_submit_req->stk = stk;

	msg_list.data = (void *) &cmd->send_sms.gsm_sms;
	msg_list.next = NULL;

	__ofono_sms_txq_submit(sms, &msg_list, 0, send_sms_submit_cb,
				stk->sms_submit_req, g_free);

	stk->cancel_cmd = send_sms_cancel;

	if (cmd->send_sms.alpha_id && cmd->send_sms.alpha_id[0])
		stk_alpha_id_set(stk, cmd->send_sms.alpha_id);

	return FALSE;
}
Ejemplo n.º 5
0
static void get_rs_with_mode(struct ofono_modem *modem, void *data)
{
	struct switch_data *sd = data;
	struct radio_data *rd_ref = sd->rd_1;
	struct ofono_atom *atom;
	struct ofono_radio_settings *rs;
	struct radio_data *rd;
	const char *standby_group, *modem_group;

	atom = __ofono_modem_find_atom(modem, OFONO_ATOM_TYPE_RADIO_SETTINGS);
	if (atom == NULL)
		return;

	rs = __ofono_atom_get_data(atom);
	rd = ofono_radio_settings_get_data(rs);
	if (rd == rd_ref)
		return;

	standby_group = ofono_modem_get_string(rd_ref->modem, "StandbyGroup");
	if (standby_group == NULL)
		return;

	modem_group = ofono_modem_get_string(modem, "StandbyGroup");
	if (g_strcmp0(standby_group, modem_group) != 0)
		return;

	if ((rd->available_rats & sd->mode_to_switch) == 0)
		return;

	sd->rd_2 = rd;
}
Ejemplo n.º 6
0
static void check_pin2_state(struct ofono_call_meter *cm)
{
	struct ofono_atom *sim_atom;

	sim_atom = __ofono_modem_find_atom(__ofono_atom_get_modem(cm->atom),
						OFONO_ATOM_TYPE_SIM);
	if (sim_atom == NULL)
		return;

	__ofono_sim_recheck_pin(__ofono_atom_get_data(sim_atom));
}
Ejemplo n.º 7
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);
	}
}