From: Lukasz Pawlik <lucas.pawlik@gmail.com>
To: linux-bluetooth@vger.kernel.org
Cc: Lukasz Pawlik <lucas.pawlik@gmail.com>
Subject: [PATCH] Fix problem with filling ADR with unneeded semicolons
Date: Mon, 16 Aug 2010 17:38:10 +0300 [thread overview]
Message-ID: <1281969490-22315-1-git-send-email-lucas.pawlik@gmail.com> (raw)
Previously in a phonebook pull request ADR was filled with six
semicolons when contact address entry was empty in phonebook. This
patch fixes this problem. Address is send as an empty string.
---
plugins/vcard.c | 25 +++++++++++++++++++++++++
1 files changed, 25 insertions(+), 0 deletions(-)
diff --git a/plugins/vcard.c b/plugins/vcard.c
index 80f8265..7333a68 100644
--- a/plugins/vcard.c
+++ b/plugins/vcard.c
@@ -155,6 +155,26 @@ static gboolean contact_fields_present(struct phonebook_contact * contact)
return FALSE;
}
+static gboolean address_fields_present(struct phonebook_contact * contact)
+{
+ if (contact->pobox && strlen(contact->pobox))
+ return TRUE;
+ if (contact->extended && strlen(contact->extended))
+ return TRUE;
+ if (contact->street && strlen(contact->street))
+ return TRUE;
+ if (contact->locality && strlen(contact->locality))
+ return TRUE;
+ if (contact->region && strlen(contact->region))
+ return TRUE;
+ if (contact->postal && strlen(contact->postal))
+ return TRUE;
+ if (contact->country && strlen(contact->country))
+ return TRUE;
+
+ return FALSE;
+}
+
static void vcard_printf_name(GString *vcards,
struct phonebook_contact *contact)
{
@@ -253,6 +273,11 @@ static void vcard_printf_email(GString *vcards, const char *email)
static void vcard_printf_adr(GString *vcards, struct phonebook_contact *contact)
{
+ if (address_fields_present(contact) == FALSE) {
+ vcard_printf(vcards, "ADR:");
+ return;
+ }
+
vcard_printf(vcards, "ADR:%s;%s;%s;%s;%s;%s;%s", contact->pobox,
contact->extended, contact->street,
contact->locality, contact->region,
--
1.7.0.4
next reply other threads:[~2010-08-16 14:38 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-08-16 14:38 Lukasz Pawlik [this message]
2010-08-16 15:16 ` [PATCH] Fix problem with filling ADR with unneeded semicolons Johan Hedberg
-- strict thread matches above, loose matches on Subject: below --
2010-08-17 11:10 Lukasz Pawlik
2010-08-17 11:50 ` 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=1281969490-22315-1-git-send-email-lucas.pawlik@gmail.com \
--to=lucas.pawlik@gmail.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