Diff between 1be9a90b736c2173d3b7871d50bb678b33ec2b39 and 1d8b84a34d2a7e63aea1ac3108e6279a152640b5

Changed Files

File Additions Deletions Status
obexd/plugins/ebook.c +22 -0 modified
obexd/src/pbap.c +26 -0 modified
obexd/src/phonebook.c +10 -0 modified
obexd/src/phonebook.h +4 -1 modified

Full Patch

diff --git a/obexd/plugins/ebook.c b/obexd/plugins/ebook.c
index 96990ea..da8bc9b 100644
--- a/obexd/plugins/ebook.c
+++ b/obexd/plugins/ebook.c
@@ -125,12 +125,34 @@ static int ebook_pullvcardlisting(struct phonebook_context *context,
 	return 0;
 }
 
+static int ebook_pullvcardentry(struct phonebook_context *context,
+		gchar *objname, guint64 filter, guint8 format)
+{
+	EBook *book;
+	EBookQuery *query;
+
+	DBG("context %p", context);
+
+	phonebook_ref(context);
+
+	book = e_book_new_default_addressbook(NULL);
+
+	e_book_open(book, FALSE, NULL);
+
+	query = e_book_query_any_field_contains("");
+
+	e_book_async_get_contacts(book, query, ebooklist_cb, context);
+
+	return 0;
+}
+
 static struct phonebook_driver ebook_driver = {
 	.name		= "ebook",
 	.create		= ebook_create,
 	.destroy	= ebook_destroy,
 	.pullphonebook	= ebook_pullphonebook,
 	.pullvcardlisting = ebook_pullvcardlisting,
+	.pullvcardentry = ebook_pullvcardentry,
 };
 
 static int ebook_init(void)
diff --git a/obexd/src/pbap.c b/obexd/src/pbap.c
index d9ebdb0..70f3d8e 100644
--- a/obexd/src/pbap.c
+++ b/obexd/src/pbap.c
@@ -37,6 +37,7 @@
 
 #define PHONEBOOK_TYPE		"x-bt/phonebook"
 #define VCARDLISTING_TYPE	"x-bt/vcard-listing"
+#define VCARDENTRY_TYPE		"x-bt/vcard"
 
 #define ORDER_TAG		0x01
 #define SEARCHVALUE_TAG		0x02
@@ -302,6 +303,29 @@ done:
 	return err;
 }
 
+static int pbap_pullvcardentry(obex_t *obex, obex_object_t *obj)
+{
+	struct obex_session *session = OBEX_GetUserData(obex);
+	gchar *fullname;
+	struct apparam_field apparam;
+	int err;
+
+	memset(&apparam, 0, sizeof(struct apparam_field));
+	err = pbap_parse_apparam_header(obex, obj, &apparam);
+	if (err < 0)
+		return err;
+
+	fullname = g_build_filename(session->current_folder,
+						session->name, NULL);
+	err = phonebook_pullvcardentry(session->pbctx, fullname,
+					apparam.filter, apparam.format);
+
+	g_free(apparam.searchval);
+	g_free(fullname);
+	return err;
+}
+
+
 void pbap_get(obex_t *obex, obex_object_t *obj)
 {
 	struct obex_session *session = OBEX_GetUserData(obex);
@@ -321,6 +345,8 @@ void pbap_get(obex_t *obex, obex_object_t *obj)
 		err = pbap_pullphonebook(obex, obj, &addbody);
 	else if (g_str_equal(session->type, VCARDLISTING_TYPE) == TRUE)
 		err = pbap_pullvcardlisting(obex, obj, &addbody);
+	else if (g_str_equal(session->type, VCARDENTRY_TYPE) == TRUE)
+		err = pbap_pullvcardentry(obex, obj);
 	else
 		goto fail;
 
diff --git a/obexd/src/phonebook.c b/obexd/src/phonebook.c
index 239fbaf..ab97b97 100644
--- a/obexd/src/phonebook.c
+++ b/obexd/src/phonebook.c
@@ -128,6 +128,16 @@ int phonebook_pullvcardlisting(struct phonebook_context *context,
 				liststartoffset, phonebooksize, newmissedcalls);
 }
 
+int phonebook_pullvcardentry(struct phonebook_context *context, gchar *objname,
+						guint64 filter, guint8 format)
+{
+	if (!context->driver->pullvcardentry)
+		return -1;
+
+	return context->driver->pullvcardentry(context, objname, filter,
+								format);
+}
+
 /* if buf is NULL or size is 0, this indicate that no more result will
  * be returned by PBAP plugin
  * */
diff --git a/obexd/src/phonebook.h b/obexd/src/phonebook.h
index 311213c..4a270e8 100644
--- a/obexd/src/phonebook.h
+++ b/obexd/src/phonebook.h
@@ -58,6 +58,8 @@ extern int phonebook_pullvcardlisting(struct phonebook_context *context,
 			guint8 searchattrib, guint16 maxlistcount,
 			guint16 liststartoffset, guint16 *phonebooksize,
 			guint8 *newmissedcalls);
+extern int phonebook_pullvcardentry(struct phonebook_context *context,
+			gchar *objname, guint64 filter, guint8 format);
 extern void phonebook_return(struct phonebook_context *context,
 						char *buf, int size);
 
@@ -74,7 +76,8 @@ struct phonebook_driver {
 			guint8 searchattrib, guint16 maxlistcount,
 			guint16 liststartoffset, guint16 *phonebooksize,
 			guint8 *newmissedcalls);
-	int (*pullvcardentry) (struct phonebook_context *context);
+	int (*pullvcardentry) (struct phonebook_context *context,
+			gchar *objname, guint64 filter, guint8 format);
 };
 
 extern int phonebook_driver_register(struct phonebook_driver *driver);