Diff between 84786d598b5352b509351daa7aeddf130bf21e3e and 8920177e4b87ec2e95583c2c235d9444123fc282

Changed Files

File Additions Deletions Status
obexd/plugins/pbap.c +12 -71 modified
obexd/plugins/phonebook-dummy.c +6 -4 modified
obexd/plugins/phonebook-ebook.c +7 -1 modified
obexd/plugins/phonebook.h +2 -1 modified

Full Patch

diff --git a/obexd/plugins/pbap.c b/obexd/plugins/pbap.c
index 91c1712..79ee4a8 100644
--- a/obexd/plugins/pbap.c
+++ b/obexd/plugins/pbap.c
@@ -34,7 +34,6 @@
 #include <sys/types.h>
 #include <sys/stat.h>
 #include <fcntl.h>
-#include <bluetooth/bluetooth.h>
 
 #include <openobex/obex.h>
 #include <openobex/obex_const.h>
@@ -44,7 +43,6 @@
 #include "obex.h"
 #include "service.h"
 #include "phonebook.h"
-#include "telephony.h"
 #include "mimetype.h"
 #include "filesystem.h"
 #include "dbus.h"
@@ -186,33 +184,13 @@ static int pbap_get(struct OBEX_session *os, obex_object_t *obj)
 	return ret;
 }
 
-static gboolean pbap_is_valid_folder(struct obex_session *session)
-{
-	if (session->current_folder == NULL) {
-		if (g_str_equal(session->name, "telecom") == TRUE ||
-			g_str_equal(session->name, "SIM1") == TRUE)
-			return TRUE;
-	} else if (g_str_equal(session->current_folder, "SIM1") == TRUE) {
-		if (g_str_equal(session->name, "telecom") == TRUE)
-			return TRUE;
-	} else if (g_str_equal(session->current_folder, "telecom") == TRUE ||
-		g_str_equal(session->current_folder, "SIM1/telecom") == TRUE) {
-		if (g_str_equal(session->name, "pb") == TRUE ||
-				g_str_equal(session->name, "ich") == TRUE ||
-				g_str_equal(session->name, "och") == TRUE ||
-				g_str_equal(session->name, "mch") == TRUE ||
-				g_str_equal(session->name, "cch") == TRUE)
-			return TRUE;
-	}
-
-	return FALSE;
-}
 
 static int pbap_setpath(struct OBEX_session *os, obex_object_t *obj)
 {
 	const gchar *current_folder, *name;
 	guint8 *nonhdr;
 	gchar *fullname;
+	int ret;
 
 	if (OBEX_ObjectGetNonHdrData(obj, &nonhdr) != 2) {
 		error("Set path failed: flag and constants not found!");
@@ -222,60 +200,23 @@ static int pbap_setpath(struct OBEX_session *os, obex_object_t *obj)
 	current_folder = obex_get_folder(os);
 	name = obex_get_name(os);
 
-	/* Check "Backup" flag */
-	if ((nonhdr[0] & 0x01) == 0x01) {
-		debug("Set to parent path");
-
-		if (current_folder == NULL) {
-			/* we are already in top level folder */
-			return -EPERM;
-		}
-
-		fullname = g_path_get_dirname(current_folder);
-
-		if (strlen(fullname) == 1 && *fullname == '.')
-			obex_set_folder(os, NULL);
-		else
-			obex_set_folder(os, fullname);
-
-		g_free(fullname);
-
-		debug("Set to parent path: %s", current_folder);
-
-		return 0;
-	}
-
-	if (!name) {
-		error("Set path failed: name missing!");
-		return -EBADR;
-	}
-
-	if (strlen(name) == 0) {
-		debug("Set to root");
-
-		obex_set_folder(os, NULL);
-
-		return 0;
-	}
-
-	/* Check and set to name path */
-	if (strstr(name, "/")) {
-		error("Set path failed: name incorrect!");
-		return -EPERM;
-	}
+	ret = phonebook_set_folder(current_folder, name, nonhdr[0]);
+	if (ret < 0)
+		return ret;
 
-	if (pbap_is_valid_folder(os) == FALSE)
-		return -ENOENT;
-
-	if (current_folder == NULL)
-		fullname = g_build_filename("", name, NULL);
+	/*
+	 * TODO: current folder should not be stored in the
+	 * "core", it is a service specific attribute.
+	 */
+	if (!current_folder)
+		fullname = g_strdup(name);
 	else
 		fullname = g_build_filename(current_folder, name, NULL);
 
-	debug("Fullname: %s", fullname);
-
 	obex_set_folder(os, fullname);
 
+	g_free(fullname);
+
 	return 0;
 }
 
diff --git a/obexd/plugins/phonebook-dummy.c b/obexd/plugins/phonebook-dummy.c
index 38b2803..3915f87 100644
--- a/obexd/plugins/phonebook-dummy.c
+++ b/obexd/plugins/phonebook-dummy.c
@@ -29,9 +29,6 @@
 #include <string.h>
 #include <glib.h>
 
-#include <openobex/obex.h>
-#include <openobex/obex_const.h>
-
 #include "logging.h"
 #include "phonebook.h"
 
@@ -43,7 +40,6 @@
         "TEL:+001122334455\n"		\
         "END:VCARD\n"
 
-
 struct dummy_data {
 	phonebook_cb	cb;
 	gpointer	user_data;
@@ -67,6 +63,12 @@ static gboolean dummy_result(gpointer data)
 	return FALSE;
 }
 
+int phonebook_set_folder(const gchar *current_folder,
+		const gchar *new_folder, guint8 flags)
+{
+	return 0;
+}
+
 int phonebook_query(const gchar *name, phonebook_cb cb, gpointer user_data)
 {
 	struct dummy_data *dummy;
diff --git a/obexd/plugins/phonebook-ebook.c b/obexd/plugins/phonebook-ebook.c
index e1a7996..9291415 100644
--- a/obexd/plugins/phonebook-ebook.c
+++ b/obexd/plugins/phonebook-ebook.c
@@ -109,7 +109,13 @@ void phonebook_exit(void)
 		g_object_unref(ebook);
 }
 
-int phonebook_query(const gchar *name, phonebook_cb cb, gpointer user_data)
+int phonebook_set_folder(const gchar *current_folder,
+		const gchar *new_folder, guint8 flags)
+{
+	return 0;
+}
+
+gint phonebook_query(const gchar *name, phonebook_cb cb, gpointer user_data)
 {
 	struct query_data *data;
 	EBookQuery *query;
diff --git a/obexd/plugins/phonebook.h b/obexd/plugins/phonebook.h
index dc8e5e0..b5bc10e 100644
--- a/obexd/plugins/phonebook.h
+++ b/obexd/plugins/phonebook.h
@@ -37,6 +37,7 @@ typedef void (*phonebook_cb) (const gchar *buffer, size_t bufsize,
 int phonebook_init(void);
 void phonebook_exit(void);
 
-int phonebook_setfolder(const gchar *name);
+int phonebook_set_folder(const gchar *current_folder,
+		const gchar *new_folder, guint8 flags);
 
 int phonebook_query(const gchar *name, phonebook_cb cb, gpointer user_data);