Diff between 2cad93864e878a9e7041230745098de8cde5fd10 and 916d09bf045825779a289978d164e2b4eb3d84f7

Changed Files

File Additions Deletions Status
obexd/plugins/phonebook-tracker.c +3 -7 modified
obexd/plugins/vcard.c +16 -25 modified
obexd/plugins/vcard.h +1 -7 modified

Full Patch

diff --git a/obexd/plugins/phonebook-tracker.c b/obexd/plugins/phonebook-tracker.c
index 1f1f693..bff85b8 100644
--- a/obexd/plugins/phonebook-tracker.c
+++ b/obexd/plugins/phonebook-tracker.c
@@ -803,13 +803,9 @@ add_entry:
 	contact->additional = g_strdup(reply[4]);
 	contact->prefix = g_strdup(reply[5]);
 	contact->suffix = g_strdup(reply[6]);
-	contact->pobox = g_strdup(reply[9]);
-	contact->extended = g_strdup(reply[10]);
-	contact->street = g_strdup(reply[11]);
-	contact->locality = g_strdup(reply[12]);
-	contact->region = g_strdup(reply[13]);
-	contact->postal = g_strdup(reply[14]);
-	contact->country = g_strdup(reply[15]);
+	contact->address = g_strdup_printf("%s;%s;%s;%s;%s;%s;%s",
+				reply[9], reply[10], reply[11], reply[12],
+				reply[13], reply[14], reply[15]);
 	contact->birthday = g_strdup(reply[18]);
 	contact->nickname = g_strdup(reply[19]);
 	contact->website = g_strdup(reply[20]);
diff --git a/obexd/plugins/vcard.c b/obexd/plugins/vcard.c
index 09f4f40..33a1ede 100644
--- a/obexd/plugins/vcard.c
+++ b/obexd/plugins/vcard.c
@@ -31,6 +31,7 @@
 
 #include "vcard.h"
 
+#define ADDR_FIELD_AMOUNT 7
 #define LEN_MAX 128
 #define TYPE_INTERNATIONAL 145
 
@@ -157,20 +158,19 @@ static gboolean contact_fields_present(struct phonebook_contact * contact)
 
 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;
+	gchar **address_fields = g_strsplit(contact->address, ";",
+							ADDR_FIELD_AMOUNT);
+	int i = 0;
+
+	for (; i < ADDR_FIELD_AMOUNT; ++i) {
+
+		if (strlen(address_fields[i]) != 0) {
+			g_strfreev(address_fields);
+			return TRUE;
+		}
+	}
+
+	g_strfreev(address_fields);
 
 	return FALSE;
 }
@@ -384,10 +384,7 @@ static void vcard_printf_adr(GString *vcards,
 		return;
 	}
 
-	vcard_printf(vcards, "ADR:%s;%s;%s;%s;%s;%s;%s", contact->pobox,
-					contact->extended, contact->street,
-					contact->locality, contact->region,
-					contact->postal, contact->country);
+	vcard_printf(vcards, "ADR:%s", contact->address);
 }
 
 static void vcard_printf_datetime(GString *vcards,
@@ -529,13 +526,7 @@ void phonebook_contact_free(struct phonebook_contact *contact)
 	g_free(contact->additional);
 	g_free(contact->prefix);
 	g_free(contact->suffix);
-	g_free(contact->pobox);
-	g_free(contact->extended);
-	g_free(contact->street);
-	g_free(contact->locality);
-	g_free(contact->region);
-	g_free(contact->postal);
-	g_free(contact->country);
+	g_free(contact->address);
 	g_free(contact->birthday);
 	g_free(contact->nickname);
 	g_free(contact->website);
diff --git a/obexd/plugins/vcard.h b/obexd/plugins/vcard.h
index a22dfc1..b1e971e 100644
--- a/obexd/plugins/vcard.h
+++ b/obexd/plugins/vcard.h
@@ -59,13 +59,7 @@ struct phonebook_contact {
 	GSList *emails;
 	char *prefix;
 	char *suffix;
-	char *pobox;
-	char *extended;
-	char *street;
-	char *locality;
-	char *region;
-	char *postal;
-	char *country;
+	char *address;
 	char *birthday;
 	char *nickname;
 	char *website;