Esempio n. 1
0
File: ril.c Progetto: jpakkane/ofono
static void ril_send_power(struct ril_data *ril, ofono_bool_t online,
				GRilResponseFunc func,
				gpointer user_data)
{
	struct cb_data *cbd = user_data;
	ofono_modem_online_cb_t cb;
	GDestroyNotify notify = NULL;
	struct parcel rilp;

	if (cbd != NULL) {
		notify = g_free;
		cb = cbd->cb;
	}

	DBG("(online = 1, offline = 0)): %i", online);

	g_ril_request_power(ril->modem, (const gboolean) online, &rilp);

	if (g_ril_send(ril->modem, RIL_REQUEST_RADIO_POWER, &rilp,
			func, cbd, notify) == 0 && cbd != NULL) {

		CALLBACK_WITH_FAILURE(cb, cbd->data);
		g_free(cbd);
	}
}
Esempio n. 2
0
File: mtk.c Progetto: semafor/ofono
static int power_on_off(GRil *ril, gboolean on, struct cb_data *cbd)
{
	int cancel_id;
	int req;
	struct parcel rilp;
	struct parcel *p_rilp;
	GRilResponseFunc resp;
	GDestroyNotify notify;
	ofono_modem_online_cb_t cb = cbd->cb;

	/* Case of modems with just one slot */
	if (mtk_data_1 == NULL) {
		/* Fall back to generic RIL_REQUEST_RADIO_POWER */
		req = RIL_REQUEST_RADIO_POWER;
		g_ril_request_power(ril, on, &rilp);
		p_rilp = &rilp;
	} else {
		req = on ? MTK_RIL_REQUEST_RADIO_POWERON
			: MTK_RIL_REQUEST_RADIO_POWEROFF;
		p_rilp = NULL;
	}

	if (on) {
		resp = poweron_cb;
		notify = NULL;
	} else {
		resp = poweroff_cb;
		notify = g_free;
	}

	if ((cancel_id = g_ril_send(ril, req, p_rilp, resp, cbd, notify))
			== 0) {
		ofono_error("%s: failure sending request", __func__);
		CALLBACK_WITH_FAILURE(cb, cbd->data);
		g_free(cbd);
		return 0;
	}

	return cancel_id;
}