예제 #1
0
static int mns_put(struct obex_session *os, void *user_data)
{
	struct mns_session *mns = user_data;
	const char *type = obex_get_type(os);
	const char *name = obex_get_name(os);
	int ret;

	DBG("PUT: name %s type %s mns %p", name, type, mns);

	if (type == NULL)
		return -EBADR;

	ret = get_params(os, mns);
	if (ret < 0)
		goto failed;

	ret = obex_put_stream_start(os, name);
	if (ret < 0)
		goto failed;

	return 0;

failed:
	reset_request(mns);

	return ret;
}
예제 #2
0
파일: irmc.c 프로젝트: bulislaw/map-client
static int irmc_get(struct obex_session *os, void *user_data)
{
	struct irmc_session *irmc = user_data;
	const char *type = obex_get_type(os);
	const char *name = obex_get_name(os);
	char *path;
	int ret;

	DBG("name %s type %s irmc %p", name, type ? type : "NA", irmc);

	path = g_strdup(name);

	ret = obex_get_stream_start(os, path);

	g_free(path);

	return ret;
}
예제 #3
0
static ssize_t synce_write(void *object, const void *buf, size_t count)
{
	struct synce_context *context = object;
	DBusMessage *msg;
	DBusMessageIter iter, array_iter;
	DBusPendingCall *call;
	const char *type = obex_get_type(context->os);

	if (context->lasterr == 0)
		return count;

	if (!context->conn_obj)
		return -EFAULT;

	msg = dbus_message_new_method_call(SYNCE_BUS_NAME, context->conn_obj,
					SYNCE_CONN_INTERFACE, "Process");
	if (!msg)
		return -EFAULT;

	dbus_message_iter_init_append(msg, &iter);
	dbus_message_iter_open_container(&iter, DBUS_TYPE_ARRAY,
				DBUS_TYPE_BYTE_AS_STRING, &array_iter);

	dbus_message_iter_append_fixed_array(&array_iter, DBUS_TYPE_BYTE,
						&buf, count);
	dbus_message_iter_close_container(&iter, &array_iter);

	dbus_message_append_args(msg, DBUS_TYPE_STRING, &type,
						DBUS_TYPE_INVALID);

	if (!dbus_connection_send_with_reply(context->dbus_conn, msg,
								&call, -1)) {
		error("D-Bus call to %s failed.", SYNCE_CONN_INTERFACE);
		dbus_message_unref(msg);
		return -EPERM;
	}

	dbus_pending_call_set_notify(call, process_cb, context, NULL);

	dbus_message_unref(msg);
	dbus_pending_call_unref(call);

	return -EAGAIN;
}
예제 #4
0
파일: opp.c 프로젝트: Sork007/obexd
static int opp_get(struct obex_session *os, obex_object_t *obj, void *user_data)
{
	const char *type;

	if (obex_get_name(os))
		return -EPERM;

	type = obex_get_type(os);

	if (type == NULL)
		return -EPERM;

	if (g_ascii_strcasecmp(type, VCARD_TYPE) == 0) {
		if (obex_get_stream_start(os, VCARD_FILE) < 0)
			return -ENOENT;

	} else
		return -EPERM;

	return 0;
}
예제 #5
0
파일: ftp.c 프로젝트: Siegfriede/obexd-eds
int ftp_get(struct obex_session *os, obex_object_t *obj, gboolean *stream,
							void *user_data)
{
	struct ftp_session *ftp = user_data;
	const char *type = obex_get_type(os);
	int ret;

	DBG("%p", ftp);

	if (ftp->folder == NULL)
		return -ENOENT;

	ret = get_by_type(ftp, type);
	if (ret < 0)
		return ret;

	if (stream)
		*stream = TRUE;

	return 0;
}
예제 #6
0
파일: mas.c 프로젝트: KpuBopy4ka/obexd-map
static int mas_get(struct obex_session *os, obex_object_t *obj, void *user_data)
{
	struct mas_session *mas = user_data;
	const char *type = obex_get_type(os);
	const char *name = obex_get_name(os);
	int ret;

	DBG("GET: name %s type %s mas %p",
			name, type, mas);

	if (type == NULL)
		return -EBADR;

	ret = obex_get_stream_start(os, name);
	if (ret < 0)
		goto failed;

	return 0;

failed:
	reset_request(mas);

	return ret;
}
예제 #7
0
파일: pbap.c 프로젝트: Sork007/obexd
static int pbap_get(struct obex_session *os, obex_object_t *obj,
							void *user_data)
{
	struct pbap_session *pbap = user_data;
	const char *type = obex_get_type(os);
	const char *name = obex_get_name(os);
	struct apparam_field *params;
	const uint8_t *buffer;
	char *path;
	ssize_t rsize;
	int ret;

	DBG("name %s type %s pbap %p", name, type, pbap);

	if (type == NULL)
		return -EBADR;

	rsize = obex_aparam_read(os, obj, &buffer);
	if (rsize < 0)
		return -EBADR;

	params = parse_aparam(buffer, rsize);
	if (params == NULL)
		return -EBADR;

	if (pbap->params) {
		g_free(pbap->params->searchval);
		g_free(pbap->params);
	}

	pbap->params = params;

	if (g_ascii_strcasecmp(type, PHONEBOOK_TYPE) == 0) {
		/* Always contains the absolute path */
		if (g_path_is_absolute(name))
			path = g_strdup(name);
		else
			path = g_build_filename("/", name, NULL);

	} else if (g_ascii_strcasecmp(type, VCARDLISTING_TYPE) == 0) {
		/* Always relative */
		if (!name || strlen(name) == 0)
			/* Current folder */
			path = g_strdup(pbap->folder);
		else
			/* Current folder + relative path */
			path = g_build_filename(pbap->folder, name, NULL);

	} else if (g_ascii_strcasecmp(type, VCARDENTRY_TYPE) == 0) {
		/* File name only */
		path = g_strdup(name);
	} else
		return -EBADR;

	if (path == NULL)
		return -EBADR;

	ret = obex_get_stream_start(os, path);

	g_free(path);

	return ret;
}