예제 #1
0
static int get_params(struct obex_session *os, struct mns_session *mns)
{
	const uint8_t *buffer;
	ssize_t size;

	size = obex_get_apparam(os, &buffer);
	if (size < 0)
		size = 0;

	mns->inparams = g_obex_apparam_decode(buffer, size);
	if (mns->inparams == NULL) {
		DBG("Error when parsing parameters!");
		return -EBADR;
	}

	return 0;
}
예제 #2
0
파일: pbap.c 프로젝트: ghent360/bluez
static int pbap_get(struct obex_session *os, 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_get_apparam(os, &buffer);
	if (rsize < 0) {
		if (g_ascii_strcasecmp(type, VCARDENTRY_TYPE) != 0)
			return -EBADR;

		rsize = 0;
	}

	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);

			/* clear cache */
			pbap->cache.valid = FALSE;
			pbap->cache.index = 0;
			cache_clear(&pbap->cache);
		}
	} 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;
}