obexd: add support for PBAP Pullvcardentry

This commit is contained in:
Forrest Zhao 2008-12-12 06:27:23 +08:00 committed by Marcel Holtmann
parent 1be9a90b73
commit 1d8b84a34d
4 changed files with 62 additions and 1 deletions

View File

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

View File

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

View File

@ -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
* */

View File

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