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
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
-#include <bluetooth/bluetooth.h>
#include <openobex/obex.h>
#include <openobex/obex_const.h>
#include "obex.h"
#include "service.h"
#include "phonebook.h"
-#include "telephony.h"
#include "mimetype.h"
#include "filesystem.h"
#include "dbus.h"
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!");
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
#include <string.h>
#include <glib.h>
-#include <openobex/obex.h>
-#include <openobex/obex_const.h>
-
#include "logging.h"
#include "phonebook.h"
"TEL:+001122334455\n" \
"END:VCARD\n"
-
struct dummy_data {
phonebook_cb cb;
gpointer user_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
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
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);