static DBusMessage *am_agent_unregister(DBusConnection *conn,
					DBusMessage *msg, void *user_data)
{
	const char *sender, *path;
	DBusMessageIter iter;

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

	sender = dbus_message_get_sender(msg);

	if (dbus_message_iter_init(msg, &iter) == FALSE)
		return __ofono_error_invalid_args(msg);

	dbus_message_iter_get_basic(&iter, &path);

	if (strcmp(sender, agent->owner) != 0)
		return __ofono_error_not_allowed(msg);

	if (strcmp(path, agent->path) != 0)
		return __ofono_error_not_found(msg);

	agent_free(agent);
	agent = NULL;

	has_wideband = FALSE;

	DBG("Agent %s unregistered", sender);

	return dbus_message_new_method_return(msg);
}
示例#2
0
文件: message.c 项目: Conjuror/ofono
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);
	}
}