Ejemplo n.º 1
0
static inline DBusMessage *does_not_exist(DBusMessage *msg,
        const char *description)
{
    return g_dbus_create_error(msg, ERROR_INTERFACE ".DoesNotExist",
                               description);
}
Ejemplo n.º 2
0
DBusMessage *__connman_error_not_unique(DBusMessage *msg)
{
	return g_dbus_create_error(msg, CONNMAN_ERROR_INTERFACE
					".NotUnique", "Not unique");
}
Ejemplo n.º 3
0
static inline DBusMessage *not_supported(DBusMessage *msg)
{
	return g_dbus_create_error(msg,
			ERROR_INTERFACE ".NotSupported",
			"Operation is not supported");
}
Ejemplo n.º 4
0
DBusMessage *__connman_error_invalid_arguments(DBusMessage *msg)
{
	return g_dbus_create_error(msg, CONNMAN_ERROR_INTERFACE
				".InvalidArguments", "Invalid arguments");
}
Ejemplo n.º 5
0
DBusMessage *__connman_error_passphrase_required(DBusMessage *msg)
{
	return g_dbus_create_error(msg, CONNMAN_ERROR_INTERFACE
				".PassphraseRequired", "Passphrase required");
}
Ejemplo n.º 6
0
DBusMessage *__connman_error_operation_aborted(DBusMessage *msg)
{
	return g_dbus_create_error(msg, CONNMAN_ERROR_INTERFACE
				".OperationAborted", "Operation aborted");
}
Ejemplo n.º 7
0
DBusMessage *__connman_error_invalid_service(DBusMessage *msg)
{
	return g_dbus_create_error(msg, CONNMAN_ERROR_INTERFACE
				".InvalidService", "Invalid service");
}
Ejemplo n.º 8
0
static DBusMessage *error_not_found(DBusMessage *msg)
{
	return g_dbus_create_error(msg, NFC_ERROR_INTERFACE
						".NotFound", "Not found");
}
Ejemplo n.º 9
0
static DBusMessage *error_permission_denied(DBusMessage *msg)
{
	return g_dbus_create_error(msg, NFC_ERROR_INTERFACE
				".PermissionDenied", "PermissionDenied");
}
Ejemplo n.º 10
0
static inline DBusMessage *invalid_args(DBusMessage *msg)
{
	return g_dbus_create_error(msg, "org.bluez.Error.InvalidArguments",
					"Invalid arguments in method call");
}
Ejemplo n.º 11
0
static DBusMessage *error_invalid_arguments(DBusMessage *msg)
{
	return g_dbus_create_error(msg, NFC_ERROR_INTERFACE
				".InvalidArguments", "Invalid arguments");
}
Ejemplo n.º 12
0
static DBusMessage *create_proxy(DBusConnection *conn,
                                 DBusMessage *msg, void *data)
{
    struct serial_adapter *adapter = data;
    char path[MAX_PATH_LENGTH + 1];
    const char *pattern, *address, *ppath = path;
    char *uuid_str;
    proxy_type_t type;
    uuid_t uuid;
    int ret;

    if (!dbus_message_get_args(msg, NULL,
                               DBUS_TYPE_STRING, &pattern,
                               DBUS_TYPE_STRING, &address,
                               DBUS_TYPE_INVALID))
        return NULL;

    uuid_str = bt_name2string(pattern);
    if (!uuid_str)
        return invalid_arguments(msg, "Invalid UUID");

    bt_string2uuid(&uuid, uuid_str);

    type = addr2type(address);
    if (type == UNKNOWN_PROXY_TYPE) {
        g_free(uuid_str);
        return invalid_arguments(msg, "Invalid address");
    }

    /* Only one proxy per address(TTY or unix socket) is allowed */
    if (g_slist_find_custom(adapter->proxies, address, proxy_addrcmp)) {
        g_free(uuid_str);
        return g_dbus_create_error(msg, ERROR_INTERFACE ".AlreadyExist",
                                   "Proxy already exists");
    }

    switch (type) {
    case UNIX_SOCKET_PROXY:
        ret = proxy_socket_register(adapter, uuid_str, address,
                                    path, sizeof(path), TRUE);
        break;
    case TTY_PROXY:
        ret = proxy_tty_register(adapter, uuid_str, address,
                                 NULL, path, sizeof(path), TRUE);
        break;
    case TCP_SOCKET_PROXY:
        ret = proxy_tcp_register(adapter, uuid_str, address,
                                 path, sizeof(path), TRUE);
        break;
    default:
        ret = -1;
    }

    g_free(uuid_str);

    if (ret < 0)
        return failed(msg, "Create object path failed");

    g_dbus_emit_signal(adapter->conn,
                       adapter_get_path(adapter->btd_adapter),
                       SERIAL_MANAGER_INTERFACE, "ProxyCreated",
                       DBUS_TYPE_STRING, &ppath,
                       DBUS_TYPE_INVALID);

    return g_dbus_create_reply(msg, DBUS_TYPE_STRING, &ppath,
                               DBUS_TYPE_INVALID);
}
Ejemplo n.º 13
0
static inline DBusMessage *failed(DBusMessage *msg, const char *description)
{
    return g_dbus_create_error(msg, ERROR_INTERFACE ".Failed",
                               description);
}
Ejemplo n.º 14
0
static inline DBusMessage *invalid_arguments(DBusMessage *msg,
        const char *description)
{
    return g_dbus_create_error(msg, ERROR_INTERFACE ".InvalidArguments",
                               description);
}
Ejemplo n.º 15
0
DBusMessage *__connman_error_already_connected(DBusMessage *msg)
{
	return g_dbus_create_error(msg, CONNMAN_ERROR_INTERFACE
				".AlreadyConnected", "Already connected");
}
Ejemplo n.º 16
0
static inline DBusMessage *no_such_adapter(DBusMessage *msg)
{
	return g_dbus_create_error(msg,
			ERROR_INTERFACE ".NoSuchAdapter",
			"No such adapter");
}
Ejemplo n.º 17
0
DBusMessage *__connman_error_not_connected(DBusMessage *msg)
{
	return g_dbus_create_error(msg, CONNMAN_ERROR_INTERFACE
					".NotConnected", "Not connected");
}
Ejemplo n.º 18
0
static inline DBusMessage *invalid_args(DBusMessage *msg)
{
	return g_dbus_create_error(msg,
			ERROR_INTERFACE ".InvalidArguments",
			"Invalid arguments in method call");
}
Ejemplo n.º 19
0
DBusMessage *__connman_error_operation_timeout(DBusMessage *msg)
{
	return g_dbus_create_error(msg, CONNMAN_ERROR_INTERFACE
				".OperationTimeout", "Operation timeout");
}
Ejemplo n.º 20
0
static DBusMessage *profile_new_connection(DBusConnection *conn,
					DBusMessage *msg, void *user_data)
{
	struct hfp *hfp;
	struct ofono_modem *modem;
	struct sockaddr_rc saddr;
	socklen_t optlen;
	DBusMessageIter entry;
	const char *device, *driver;
	char local[18], remote[18];
	uint16_t version = HFP_VERSION_1_5;
	int fd, err;

	DBG("Profile handler NewConnection");

	if (dbus_message_iter_init(msg, &entry) == FALSE)
		goto invalid;

	if (dbus_message_iter_get_arg_type(&entry) != DBUS_TYPE_OBJECT_PATH)
		goto invalid;

	dbus_message_iter_get_basic(&entry, &device);

	dbus_message_iter_next(&entry);
	if (dbus_message_iter_get_arg_type(&entry) != DBUS_TYPE_UNIX_FD)
		goto invalid;

	dbus_message_iter_get_basic(&entry, &fd);
	if (fd < 0)
		goto invalid;

	dbus_message_iter_next(&entry);
	if (dbus_message_iter_get_arg_type(&entry) != DBUS_TYPE_ARRAY)
		goto invalid;

	if (get_version(&entry, &version) < 0)
		goto invalid;

	modem = ofono_modem_find(device_path_compare, (void *) device);
	if (modem == NULL) {
		close(fd);
		return g_dbus_create_error(msg, BLUEZ_ERROR_INTERFACE
					".Rejected",
					"Unknown Bluetooth device");
	}

	err = service_level_connection(modem, fd, version);
	if (err < 0 && err != -EINPROGRESS) {
		close(fd);
		return g_dbus_create_error(msg, BLUEZ_ERROR_INTERFACE
					".Rejected",
					"Not enough resources");
	}

	memset(&saddr, 0, sizeof(saddr));
	optlen = sizeof(saddr);

	if (getsockname(fd, (struct sockaddr *) &saddr, &optlen) < 0) {
		err = errno;
		ofono_error("RFCOMM getsockname(): %s (%d)", strerror(err),
									err);
		close(fd);
		goto invalid;
	}

	bt_ba2str(&saddr.rc_bdaddr, local);

	memset(&saddr, 0, sizeof(saddr));
	optlen = sizeof(saddr);

	if (getpeername(fd, (struct sockaddr *) &saddr, &optlen) < 0) {
		err = errno;
		ofono_error("RFCOMM getpeername(): %s (%d)", strerror(err),
									err);
		close(fd);
		goto invalid;
	}

	bt_ba2str(&saddr.rc_bdaddr, remote);

	hfp = ofono_modem_get_data(modem);
	hfp->msg = dbus_message_ref(msg);

	driver = NULL;

	if (version >= HFP_VERSION_1_6)
		driver = HFP16_HF_DRIVER;

	hfp->card = ofono_handsfree_card_create(0, driver, hfp);
	ofono_handsfree_card_set_data(hfp->card, hfp);

	ofono_handsfree_card_set_local(hfp->card, local);
	ofono_handsfree_card_set_remote(hfp->card, remote);

	return NULL;

invalid:
	return g_dbus_create_error(msg, BLUEZ_ERROR_INTERFACE ".Rejected",
					"Invalid arguments in method call");
}
Ejemplo n.º 21
0
DBusMessage *__connman_error_invalid_property(DBusMessage *msg)
{
	return g_dbus_create_error(msg, CONNMAN_ERROR_INTERFACE
				".InvalidProperty", "Invalid property");
}
Ejemplo n.º 22
0
DBusMessage *__connman_error_not_found(DBusMessage *msg)
{
	return g_dbus_create_error(msg, CONNMAN_ERROR_INTERFACE
						".NotFound", "Not found");
}
Ejemplo n.º 23
0
DBusMessage *__connman_error_permission_denied(DBusMessage *msg)
{
	return g_dbus_create_error(msg, CONNMAN_ERROR_INTERFACE
				".PermissionDenied", "Permission denied");
}
Ejemplo n.º 24
0
DBusMessage *__connman_error_no_carrier(DBusMessage *msg)
{
	return g_dbus_create_error(msg, CONNMAN_ERROR_INTERFACE
						".NoCarrier", "No carrier");
}
Ejemplo n.º 25
0
DBusMessage *__connman_error_not_registered(DBusMessage *msg)
{
	return g_dbus_create_error(msg, CONNMAN_ERROR_INTERFACE
					".NotRegistered", "Not registered");
}
Ejemplo n.º 26
0
DBusMessage *__connman_error_in_progress(DBusMessage *msg)
{
	return g_dbus_create_error(msg, CONNMAN_ERROR_INTERFACE
						".InProgress", "In progress");
}
Ejemplo n.º 27
0
static DBusMessage *properties_set(DBusConnection *connection,
					DBusMessage *message, void *user_data)
{
	struct generic_data *data = user_data;
	DBusMessageIter iter, sub;
	struct interface_data *iface;
	const GDBusPropertyTable *property;
	const char *name, *interface;
	struct property_data *propdata;
	gboolean valid_signature;
	char *signature;

	if (!dbus_message_iter_init(message, &iter))
		return g_dbus_create_error(message, DBUS_ERROR_INVALID_ARGS,
							"No arguments given");

	if (dbus_message_iter_get_arg_type(&iter) != DBUS_TYPE_STRING)
		return g_dbus_create_error(message, DBUS_ERROR_INVALID_ARGS,
					"Invalid argument type: '%c'",
					dbus_message_iter_get_arg_type(&iter));

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

	if (dbus_message_iter_get_arg_type(&iter) != DBUS_TYPE_STRING)
		return g_dbus_create_error(message, DBUS_ERROR_INVALID_ARGS,
					"Invalid argument type: '%c'",
					dbus_message_iter_get_arg_type(&iter));

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

	if (dbus_message_iter_get_arg_type(&iter) != DBUS_TYPE_VARIANT)
		return g_dbus_create_error(message, DBUS_ERROR_INVALID_ARGS,
					"Invalid argument type: '%c'",
					dbus_message_iter_get_arg_type(&iter));

	dbus_message_iter_recurse(&iter, &sub);

	iface = find_interface(data->interfaces, interface);
	if (iface == NULL)
		return g_dbus_create_error(message, DBUS_ERROR_INVALID_ARGS,
					"No such interface '%s'", interface);

	property = find_property(iface->properties, name);
	if (property == NULL)
		return g_dbus_create_error(message,
						DBUS_ERROR_UNKNOWN_PROPERTY,
						"No such property '%s'", name);

	if (property->set == NULL)
		return g_dbus_create_error(message,
					DBUS_ERROR_PROPERTY_READ_ONLY,
					"Property '%s' is not writable", name);

	if (property->exists != NULL &&
			!property->exists(property, iface->user_data))
		return g_dbus_create_error(message,
						DBUS_ERROR_UNKNOWN_PROPERTY,
						"No such property '%s'", name);

	signature = dbus_message_iter_get_signature(&sub);
	valid_signature = strcmp(signature, property->type) ? FALSE : TRUE;
	dbus_free(signature);
	if (!valid_signature)
		return g_dbus_create_error(message,
					DBUS_ERROR_INVALID_SIGNATURE,
					"Invalid signature for '%s'", name);

	propdata = g_new(struct property_data, 1);
	propdata->id = next_pending_property++;
	propdata->message = dbus_message_ref(message);
	propdata->conn = connection;
	pending_property_set = g_slist_prepend(pending_property_set, propdata);

	property->set(property, &sub, propdata->id, iface->user_data);

	return NULL;
}
Ejemplo n.º 28
0
DBusMessage *__connman_error_already_exists(DBusMessage *msg)
{
	return g_dbus_create_error(msg, CONNMAN_ERROR_INTERFACE
				".AlreadyExists", "Already exists");
}
Ejemplo n.º 29
0
static inline DBusMessage *agent_already_exists(DBusMessage *msg)
{
	return g_dbus_create_error(msg,
			ERROR_INTERFACE ".AlreadyExists",
			"Agent already exists");
}
Ejemplo n.º 30
0
static DBusMessage *profile_new_connection(DBusConnection *conn,
						DBusMessage *msg, void *data)
{
	DBusMessageIter entry;
	const char *device;
	GIOChannel *io;
	int fd, fd_dup;
	struct ofono_emulator *em;
	struct ofono_modem *modem;

	DBG("Profile handler NewConnection");

	if (dbus_message_iter_init(msg, &entry) == FALSE)
		goto invalid;

	if (dbus_message_iter_get_arg_type(&entry) != DBUS_TYPE_OBJECT_PATH)
		goto invalid;

	dbus_message_iter_get_basic(&entry, &device);
	dbus_message_iter_next(&entry);

	if (dbus_message_iter_get_arg_type(&entry) != DBUS_TYPE_UNIX_FD)
		goto invalid;

	dbus_message_iter_get_basic(&entry, &fd);
	dbus_message_iter_next(&entry);

	if (fd < 0)
		goto invalid;

	DBG("%s", device);

	/* Pick the first voicecall capable modem */
	if (modems == NULL) {
		close(fd);
		return g_dbus_create_error(msg, BLUEZ_ERROR_INTERFACE
						".Rejected",
						"No voice call capable modem");
	}

	modem = modems->data;
	DBG("Picked modem %p for emulator", modem);

	em = ofono_emulator_create(modem, OFONO_EMULATOR_TYPE_HFP);
	if (em == NULL) {
		close(fd);
		return g_dbus_create_error(msg, BLUEZ_ERROR_INTERFACE
						".Rejected",
						"Not enough resources");
	}

	ofono_emulator_register(em, fd);

	fd_dup = dup(fd);
	io = g_io_channel_unix_new(fd_dup);
	g_io_add_watch_full(io, G_PRIORITY_DEFAULT, G_IO_HUP, io_hup_cb,
						g_strdup(device), g_free);
	g_io_channel_unref(io);

	g_hash_table_insert(connection_hash, g_strdup(device),
						GINT_TO_POINTER(fd_dup));

	return dbus_message_new_method_return(msg);

invalid:
	return g_dbus_create_error(msg, BLUEZ_ERROR_INTERFACE ".Rejected",
					"Invalid arguments in method call");
}