Exemple #1
0
static DBusMessage *gnss_send_element(DBusConnection *conn,
					DBusMessage *msg, void *data)
{
	const char *caller = dbus_message_get_sender(msg);
	struct ofono_gnss *gnss = data;
	const char *xml;

	DBG("");

	if (gnss->pending)
		return __ofono_error_busy(msg);

	if (!dbus_message_get_args(msg, NULL, DBUS_TYPE_STRING, &xml,
					DBUS_TYPE_INVALID))
		return __ofono_error_invalid_args(msg);

	if (gnss->posr_agent == NULL)
		return __ofono_error_not_available(msg);

	if (!gnss_agent_sender_matches(gnss->posr_agent, caller))
		return __ofono_error_access_denied(msg);

	gnss->pending = dbus_message_ref(msg);

	gnss->driver->send_element(gnss, xml, gnss_send_element_cb, gnss);

	return NULL;
}
Exemple #2
0
static DBusMessage *set_property_online(struct ofono_modem *modem,
					DBusMessage *msg,
					DBusMessageIter *var)
{
	ofono_bool_t online;
	const struct ofono_modem_driver *driver = modem->driver;

	if (modem->powered == FALSE)
		return __ofono_error_not_available(msg);

	if (dbus_message_iter_get_arg_type(var) != DBUS_TYPE_BOOLEAN)
		return __ofono_error_invalid_args(msg);

	dbus_message_iter_get_basic(var, &online);

	if (modem->pending != NULL)
		return __ofono_error_busy(msg);

	if (modem->online == online)
		return dbus_message_new_method_return(msg);

	if (ofono_modem_get_emergency_mode(modem) == TRUE)
		return __ofono_error_emergency_active(msg);

	if (modem_is_always_online(modem) == TRUE)
		return __ofono_error_not_implemented(msg);

	modem->pending = dbus_message_ref(msg);

	driver->set_online(modem, online,
				online ? online_cb : offline_cb, modem);

	return NULL;
}
Exemple #3
0
static DBusMessage *message_cancel(DBusConnection *conn,
					DBusMessage *msg, void *data)
{
	struct message *m = data;
	int res;

	if (dbus_message_get_args(msg, NULL, DBUS_TYPE_INVALID) == FALSE)
		return __ofono_error_invalid_args(msg);

	if (m->state != MESSAGE_STATE_PENDING)
		return __ofono_error_not_available(msg);

	res = __ofono_sms_txq_cancel(__ofono_atom_get_data(m->atom), &m->uuid);

	switch (res) {
	case -ENOENT:
		return __ofono_error_not_found(msg);
	case -EPERM:
		return __ofono_error_access_denied(msg);
	case 0:
		return dbus_message_new_method_return(msg);
	default:
		return __ofono_error_failed(msg);
	}
}
Exemple #4
0
static DBusMessage *location_reporting_release(DBusConnection *conn,
						DBusMessage *msg, void *data)
{
	struct ofono_location_reporting *lr = data;
	const char *caller = dbus_message_get_sender(msg);


	/*
	 * Avoid a race by not trying to release the device if there is a
	 * pending message or client already signaled it's exiting. In the
	 * later case, the device will eventually be released in
	 * client_exited_disable_cb().
	 */
	if (lr->pending != NULL || (lr->enabled && !lr->disconnect_watch))
		return __ofono_error_busy(msg);

	if (lr->enabled == FALSE)
		return __ofono_error_not_available(msg);

	if (g_strcmp0(caller, lr->client_owner))
		return __ofono_error_access_denied(msg);

	lr->pending = dbus_message_ref(msg);

	lr->driver->disable(lr, location_reporting_disable_cb, lr);

	return NULL;
}
Exemple #5
0
static DBusMessage *thermal_management_set_property(DBusConnection *conn,
							DBusMessage *msg,
							void *data)
{
	struct ril_thermal_management *tm = data;
	DBusMessageIter iter;
	DBusMessageIter var;
	const char *name;
	dbus_bool_t throttling;

	DBG("");

	if (!ofono_modem_get_online(tm->modem))
		return __ofono_error_not_available(msg);

	if (!dbus_message_iter_init(msg, &iter))
		return __ofono_error_invalid_args(msg);

	if (dbus_message_iter_get_arg_type(&iter) != DBUS_TYPE_STRING)
		return __ofono_error_invalid_args(msg);

	dbus_message_iter_get_basic(&iter, &name);

	if (!strcmp(name, "TransmitPowerThrottling")) {
		dbus_message_iter_next(&iter);

		if (dbus_message_iter_get_arg_type(&iter) != DBUS_TYPE_VARIANT)
			return __ofono_error_invalid_args(msg);

		dbus_message_iter_recurse(&iter, &var);

		if (dbus_message_iter_get_arg_type(&var) != DBUS_TYPE_BOOLEAN)
			return __ofono_error_invalid_args(msg);

		dbus_message_iter_get_basic(&var, &throttling);

		if (tm->throttling == throttling)
			/* Ignore set request if new state == current state */
			return dbus_message_new_method_return(msg);

		return set_rf_power_status(msg, throttling, tm);
	}

	return __ofono_error_invalid_args(msg);
}
static DBusMessage *card_connect(DBusConnection *conn,
						DBusMessage *msg, void *data)
{
	struct ofono_handsfree_card *card = data;
	const struct ofono_handsfree_card_driver *driver = card->driver;
	const char *sender;
	int err;

	if (agent == NULL)
		return __ofono_error_not_available(msg);

	sender = dbus_message_get_sender(msg);

	if (!g_str_equal(sender, agent->owner))
		return __ofono_error_not_allowed(msg);

	if (card->msg)
		return __ofono_error_busy(msg);

	if (!driver || !driver->connect)
		goto fallback;

	card->msg = dbus_message_ref(msg);

	driver->connect(card, card_connect_reply_cb, card);

	return NULL;

fallback:
	/* There's no driver, fallback to direct SCO connection */
	err = ofono_handsfree_card_connect_sco(card);
	if (err < 0)
		return __ofono_error_failed(msg);

	card->msg = dbus_message_ref(msg);

	return NULL;
}
Exemple #7
0
static DBusMessage *cf_set_property(DBusConnection *conn, DBusMessage *msg,
					void *data)
{
	struct ofono_call_forwarding *cf = data;
	struct ofono_modem *modem = __ofono_atom_get_modem(cf->atom);
	DBusMessageIter iter;
	DBusMessageIter var;
	const char *property;
	int cls;
	int type;

	if (ofono_modem_get_online(modem) == FALSE)
		return __ofono_error_not_available(msg);

	if (__ofono_call_forwarding_is_busy(cf) ||
			__ofono_ussd_is_busy(cf->ussd))
		return __ofono_error_busy(msg);

	if (!dbus_message_iter_init(msg, &iter))
		return __ofono_error_invalid_args(msg);

	if (dbus_message_iter_get_arg_type(&iter) != DBUS_TYPE_STRING)
		return __ofono_error_invalid_args(msg);

	dbus_message_iter_get_basic(&iter, &property);
	dbus_message_iter_next(&iter);

	if (dbus_message_iter_get_arg_type(&iter) != DBUS_TYPE_VARIANT)
		return __ofono_error_invalid_args(msg);

	dbus_message_iter_recurse(&iter, &var);

	if (cf_condition_timeout_property(property, &cls)) {
		dbus_uint16_t timeout;
		GSList *l;
		struct ofono_call_forwarding_condition *c;

		type = CALL_FORWARDING_TYPE_NO_REPLY;

		if (dbus_message_iter_get_arg_type(&var) != DBUS_TYPE_UINT16)
			return __ofono_error_invalid_args(msg);

		dbus_message_iter_get_basic(&var, &timeout);

		if (timeout < 1 || timeout > 30)
			return __ofono_error_invalid_format(msg);

		l = g_slist_find_custom(cf->cf_conditions[type],
				GINT_TO_POINTER(cls),
				cf_condition_find_with_cls);

		if (l == NULL)
			return __ofono_error_failed(msg);

		c = l->data;

		return set_property_request(cf, msg, type, cls,
						&c->phone_number, timeout);
	} else if (cf_condition_enabled_property(cf, property, &type, &cls)) {
		struct ofono_phone_number ph;
		const char *number;
		int timeout;

		ph.number[0] = '\0';
		ph.type = 129;

		if (dbus_message_iter_get_arg_type(&var) != DBUS_TYPE_STRING)
			return __ofono_error_invalid_args(msg);

		dbus_message_iter_get_basic(&var, &number);

		if (strlen(number) > 0 && !valid_phone_number_format(number))
			return __ofono_error_invalid_format(msg);

		if (number[0] != '\0')
			string_to_phone_number(number, &ph);

		timeout = cf_find_timeout(cf->cf_conditions[type], cls);

		return set_property_request(cf, msg, type, cls, &ph,
						timeout);
	}

	return __ofono_error_invalid_args(msg);
}