Diff between a6d9a0ea5192b63f3d7072f920ffa7462bdd2295 and aceac1923f45b49f1ca30f0c582d4e7ca8b9522b

Changed Files

File Additions Deletions Status
obexd/plugins/phonebook-tracker.c +1 -1 modified
obexd/plugins/vcard.c +15 -5 modified
obexd/plugins/vcard.h +1 -1 modified

Full Patch

diff --git a/obexd/plugins/phonebook-tracker.c b/obexd/plugins/phonebook-tracker.c
index 9453cd7..894d781 100644
--- a/obexd/plugins/phonebook-tracker.c
+++ b/obexd/plugins/phonebook-tracker.c
@@ -496,7 +496,7 @@ static void pull_contacts(char **reply, int num_fields, void *user_data)
 	contact->suffix = g_strdup(reply[6]);
 	contact->email = g_strdup(reply[7]);
 
-	phonebook_add_contact(vcards, contact, params->filter);
+	phonebook_add_contact(vcards, contact, params->filter, params->format);
 	phonebook_contact_free(contact);
 
 	return;
diff --git a/obexd/plugins/vcard.c b/obexd/plugins/vcard.c
index a9d464f..c0a5f85 100644
--- a/obexd/plugins/vcard.c
+++ b/obexd/plugins/vcard.c
@@ -66,6 +66,9 @@
 #define FILTER_SORT_STRING (1 << 27)
 #define FILTER_X_IRMC_CALL_DATETIME (1 << 28)
 
+#define FORMAT_VCARD21 0x00
+#define FORMAT_VCARD30 0x01
+
 /* according to RFC 2425, the output string may need folding */
 static void vcard_printf(GString *str, const char *fmt, ...)
 {
@@ -120,10 +123,14 @@ static void add_slash(char *dest, const char *src, int len_max, int len)
 	return;
 }
 
-static void vcard_printf_begin(GString *vcards)
+static void vcard_printf_begin(GString *vcards, uint8_t format)
 {
 	vcard_printf(vcards, "BEGIN:VCARD");
-	vcard_printf(vcards, "VERSION:3.0");
+
+	if (format == FORMAT_VCARD30)
+		vcard_printf(vcards, "VERSION:3.0");
+	else if (format == FORMAT_VCARD21)
+		vcard_printf(vcards, "VERSION:2.1");
 }
 
 static void vcard_printf_name(GString *vcards,
@@ -198,7 +205,7 @@ static void vcard_printf_end(GString *vcards)
 }
 
 void phonebook_add_contact(GString *vcards, struct phonebook_contact *contact,
-								uint64_t filter)
+					uint64_t filter, uint8_t format)
 {
 	/* There's really nothing to do */
 	if ((contact->tel == NULL || contact->tel[0] == '\0') &&
@@ -206,9 +213,12 @@ void phonebook_add_contact(GString *vcards, struct phonebook_contact *contact,
 					contact->fullname[0] == '\0'))
 		return;
 
-	filter |= (FILTER_VERSION | FILTER_FN | FILTER_N | FILTER_TEL);
+	if (format == FORMAT_VCARD30)
+		filter |= (FILTER_VERSION | FILTER_FN | FILTER_N | FILTER_TEL);
+	else if (format == FORMAT_VCARD21)
+		filter |= (FILTER_VERSION | FILTER_N | FILTER_TEL);
 
-	vcard_printf_begin(vcards);
+	vcard_printf_begin(vcards, format);
 
 	if (filter & FILTER_FN) {
 		if (contact->fullname == NULL || contact->fullname[0] == '\0')
diff --git a/obexd/plugins/vcard.h b/obexd/plugins/vcard.h
index f015e94..5362a66 100644
--- a/obexd/plugins/vcard.h
+++ b/obexd/plugins/vcard.h
@@ -40,6 +40,6 @@ struct phonebook_contact {
 };
 
 void phonebook_add_contact(GString *vcards, struct phonebook_contact *contact,
-							uint64_t filter);
+					uint64_t filter, uint8_t format);
 
 void phonebook_contact_free(struct phonebook_contact *contact);