summaryrefslogtreecommitdiffstats
path: root/binding/bluetooth-pbap-binding.c
diff options
context:
space:
mode:
authorMatt Ranostay <matt.ranostay@konsulko.com>2019-05-14 00:31:03 -0700
committerMatt Ranostay <matt.ranostay@konsulko.com>2019-05-16 02:20:38 -0700
commitd2237bb1d53d5ee870a8ecb2601bc1daad393f3a (patch)
treeb3d8987007373c81b8712ce35fc0d122255e496c /binding/bluetooth-pbap-binding.c
parent10563449b9c9a01f9b1d25d13a19dbf5fa0ee501 (diff)
binding: bluetooth-pbap: add vcard parser framework
Parse the vCard information within the binding itself, and reduce service consumers processing and dependencies. Bug-AGL: SPEC-2392 Change-Id: Ie7654c4ba6d269cb8224e61021e19739614afb4e Signed-off-by: Matt Ranostay <matt.ranostay@konsulko.com>
Diffstat (limited to 'binding/bluetooth-pbap-binding.c')
-rw-r--r--binding/bluetooth-pbap-binding.c27
1 files changed, 13 insertions, 14 deletions
diff --git a/binding/bluetooth-pbap-binding.c b/binding/bluetooth-pbap-binding.c
index 76ee9ad..8dfba3d 100644
--- a/binding/bluetooth-pbap-binding.c
+++ b/binding/bluetooth-pbap-binding.c
@@ -35,6 +35,8 @@
#include "obex_phonebookaccess1_interface.h"
#include "freedesktop_dbus_properties_interface.h"
+#include "bluetooth-pbap-common.h"
+
static GDBusObjectManager *obj_manager;
static OrgBluezObexClient1 *client;
static OrgBluezObexSession1 *session;
@@ -152,10 +154,9 @@ static void on_interface_proxy_properties_changed(
}
}
-static json_object *get_vcard_xfer(gchar *filename)
+static char *get_vcard_xfer(gchar *filename)
{
FILE *fp;
- json_object *vcard_str;
gchar *vcard_data;
size_t size, n;
@@ -170,12 +171,10 @@ static json_object *get_vcard_xfer(gchar *filename)
return NULL;
}
- vcard_str = json_object_new_string(vcard_data);
- free(vcard_data);
fclose(fp);
unlink(filename);
- return vcard_str;
+ return vcard_data;
}
static void get_filename(gchar *filename)
@@ -224,8 +223,8 @@ static gchar *pull_vcard(const gchar *handle)
static json_object *get_vcard(const gchar *handle)
{
- json_object *vcard_str = NULL, *vcard = NULL;
- gchar *tpath, *filename;
+ json_object *vcard;
+ gchar *tpath, *filename, *vcard_str = NULL;
tpath = pull_vcard(handle);
@@ -240,10 +239,9 @@ static json_object *get_vcard(const gchar *handle)
g_free(filename);
g_mutex_unlock(&xfer_complete_mutex);
- if (vcard_str) {
- vcard = json_object_new_object();
- json_object_object_add(vcard, "vcard", vcard_str);
- }
+ vcard = json_object_new_object();
+ json_object_object_add(vcard, "vcards", parse_vcards(vcard_str));
+ g_free(vcard_str);
return vcard;
}
@@ -276,8 +274,8 @@ static gchar *pull_vcards(int max_entries)
static json_object *get_vcards(int max_entries)
{
- json_object *vcards_str, *vcards;
- gchar *tpath, *filename;
+ json_object *vcards;
+ gchar *tpath, *filename, *vcards_str = NULL;
tpath = pull_vcards(max_entries);
g_mutex_lock(&xfer_complete_mutex);
@@ -290,7 +288,8 @@ static json_object *get_vcards(int max_entries)
g_mutex_unlock(&xfer_complete_mutex);
vcards = json_object_new_object();
- json_object_object_add(vcards, "vcards", vcards_str);
+ json_object_object_add(vcards, "vcards", parse_vcards(vcards_str));
+ g_free(vcards_str);
return vcards;
}