linux-bluetooth.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Bartosz Szatkowski <bulislaw@linux.com>
To: linux-bluetooth@vger.kernel.org
Cc: Bartosz Szatkowski <bulislaw@linux.com>
Subject: [PATCH obexd 4/5 v2] Add 0.vcf (me contact) when generating cache
Date: Tue,  5 Jul 2011 22:53:21 +0200	[thread overview]
Message-ID: <1309899202-23849-4-git-send-email-bulislaw@linux.com> (raw)
In-Reply-To: <1309899202-23849-1-git-send-email-bulislaw@linux.com>

When pulling all contacts self is already present, but it have to
be manually added when generating cache.
---
 plugins/phonebook-ebook.c |   40 ++++++++++++++++++++++++++++++++++++++++
 1 files changed, 40 insertions(+), 0 deletions(-)

diff --git a/plugins/phonebook-ebook.c b/plugins/phonebook-ebook.c
index 97785b5..181585a 100644
--- a/plugins/phonebook-ebook.c
+++ b/plugins/phonebook-ebook.c
@@ -616,6 +616,13 @@ void *phonebook_create_cache(const char *name, phonebook_entry_cb entry_cb,
 	EBookQuery *query;
 	gboolean ret;
 	GSList *ebook;
+	EContact *me;
+	EVCard *evcard;
+	GError *gerr;
+	EBook *eb;
+	EVCardAttribute *attrib;
+	char *uid, *tel, *cname;
+
 
 	if (g_strcmp0("/telecom/pb", name) != 0) {
 		if (err)
@@ -634,6 +641,39 @@ void *phonebook_create_cache(const char *name, phonebook_entry_cb entry_cb,
 	data->user_data = user_data;
 	data->query = query;
 
+	/* Add 0.vcf */
+	if (e_book_get_self(&me, &eb, &gerr) == FALSE) {
+		g_error_free(gerr);
+		goto next;
+	}
+
+	evcard = E_VCARD(me);
+
+	cname = evcard_name_attribute_to_string(evcard);
+	if (!cname)
+		cname = g_strdup("");
+
+	attrib = e_vcard_get_attribute(evcard, EVC_UID);
+	uid = e_vcard_attribute_get_value(attrib);
+	if (!uid)
+		uid = g_strdup("");
+
+	attrib = e_vcard_get_attribute(evcard, EVC_TEL);
+	if (attrib)
+		tel =  e_vcard_attribute_get_value(attrib);
+	else
+		tel = g_strdup("");
+
+	data->entry_cb(uid, 0, cname, NULL, tel, data->user_data);
+
+	data->count++;
+
+	g_free(cname);
+	g_free(uid);
+	g_free(tel);
+	g_object_unref(eb);
+
+next:
 	ebook = ebooks;
 	while (ebook != NULL) {
 		if (e_book_is_opened(ebook->data) == TRUE) {
-- 
1.7.5.3


  parent reply	other threads:[~2011-07-05 20:53 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-07-05 20:53 [PATCH obexd 1/5 v2] Change EDS backend to support multiple ebooks Bartosz Szatkowski
2011-07-05 20:53 ` [PATCH obexd 2/5 v2] Add constraint on pulled path Bartosz Szatkowski
2011-07-05 20:53 ` [PATCH obexd 3/5 v2] Add checking ebook availability before processing Bartosz Szatkowski
2011-07-05 20:53 ` Bartosz Szatkowski [this message]
2011-07-05 20:53 ` [PATCH obexd 5/5 v2] Add proper finishing/canceling requests Bartosz Szatkowski
2011-07-11  9:34 ` [PATCH obexd 1/5 v2] Change EDS backend to support multiple ebooks Johan Hedberg

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1309899202-23849-4-git-send-email-bulislaw@linux.com \
    --to=bulislaw@linux.com \
    --cc=linux-bluetooth@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).