Linux bluetooth development
 help / color / mirror / Atom feed
* [PATCH] Fix problem with filling ADR with unneeded semicolons
@ 2010-08-16 14:38 Lukasz Pawlik
  2010-08-16 15:16 ` Johan Hedberg
  0 siblings, 1 reply; 4+ messages in thread
From: Lukasz Pawlik @ 2010-08-16 14:38 UTC (permalink / raw)
  To: linux-bluetooth; +Cc: Lukasz Pawlik

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


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH] Fix problem with filling ADR with unneeded semicolons
  2010-08-16 14:38 [PATCH] Fix problem with filling ADR with unneeded semicolons Lukasz Pawlik
@ 2010-08-16 15:16 ` Johan Hedberg
  0 siblings, 0 replies; 4+ messages in thread
From: Johan Hedberg @ 2010-08-16 15:16 UTC (permalink / raw)
  To: Lukasz Pawlik; +Cc: linux-bluetooth

Hi Lucasz,

On Mon, Aug 16, 2010, Lukasz Pawlik wrote:
> 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(-)

Thanks for the patch, but it'll need some coding style cleanup before
going upstream:

> +static gboolean address_fields_present(struct phonebook_contact * contact)

No space after *

> +	if (contact->country && strlen(contact->country))
> +		return TRUE;
> +	

The last line isn't really empty byt has an extra tab. Please remove it.

> +	if (address_fields_present(contact) == FALSE) {
> +		vcard_printf(vcards, "ADR:");
> +		return;		

There's an extra tab at the end of the line. Please remove it.

> +	}
> +	

Same here.

Johan

^ permalink raw reply	[flat|nested] 4+ messages in thread

* [PATCH] Fix problem with filling ADR with unneeded semicolons
@ 2010-08-17 11:10 Lukasz Pawlik
  2010-08-17 11:50 ` Johan Hedberg
  0 siblings, 1 reply; 4+ messages in thread
From: Lukasz Pawlik @ 2010-08-17 11:10 UTC (permalink / raw)
  To: linux-bluetooth; +Cc: Lukasz Pawlik

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


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH] Fix problem with filling ADR with unneeded semicolons
  2010-08-17 11:10 Lukasz Pawlik
@ 2010-08-17 11:50 ` Johan Hedberg
  0 siblings, 0 replies; 4+ messages in thread
From: Johan Hedberg @ 2010-08-17 11:50 UTC (permalink / raw)
  To: Lukasz Pawlik; +Cc: linux-bluetooth

Hi Lukasz,

On Tue, Aug 17, 2010, Lukasz Pawlik wrote:
> 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(-)

Thanks. The patch is now upstream.

Johan

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2010-08-17 11:50 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-08-16 14:38 [PATCH] Fix problem with filling ADR with unneeded semicolons Lukasz Pawlik
2010-08-16 15:16 ` 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

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox