diff --git a/obexd/plugins/phonebook-tracker.c b/obexd/plugins/phonebook-tracker.c
index 730cbb2..e60cf74 100644
--- a/obexd/plugins/phonebook-tracker.c
+++ b/obexd/plugins/phonebook-tracker.c
"}) " \
"nco:birthDate(?_contact) " \
"nco:nickname(?_contact) " \
-"nco:url(?_contact) " \
+"(SELECT GROUP_CONCAT(fn:concat( " \
+ "?url_val, \"\31\", rdfs:label(?_role) " \
+ "), \"\30\") " \
+ "WHERE {" \
+ "?_role nco:url ?url_val . " \
+"})" \
"nie:url(nco:photo(?_contact)) " \
"nco:role(?_role) " \
"nco:contactUID(?_contact) " \
"}) " \
"nco:birthDate(?_contact) " \
"nco:nickname(?_contact) " \
- "nco:url(?_contact) " \
+"(SELECT GROUP_CONCAT(fn:concat( " \
+ "?url_value, \"\31\", ?aff_type " \
+ "), \"\30\") " \
+ "WHERE {" \
+ "?_contact nco:hasAffiliation ?c_role . " \
+ "?c_role nco:url ?url_value . " \
+ "?c_role rdfs:label ?aff_type . " \
+"})" \
"nie:url(nco:photo(?_contact)) " \
"nco:role(?_role) " \
"nco:contactUID(?_contact) " \
"}) " \
"nco:birthDate(?_contact) " \
"nco:nickname(?_contact) " \
- "nco:url(?_contact) " \
+"(SELECT GROUP_CONCAT(fn:concat( " \
+ "?url_value, \"\31\", ?aff_type " \
+ "), \"\30\") " \
+ "WHERE {" \
+ "?_contact nco:hasAffiliation ?c_role . " \
+ "?c_role nco:url ?url_value . " \
+ "?c_role rdfs:label ?aff_type . " \
+"})" \
"nie:url(nco:photo(?_contact)) " \
"nco:role(?_role) " \
"nco:contactUID(?_contact) " \
"}) " \
"nco:birthDate(?_contact) " \
"nco:nickname(?_contact) " \
- "nco:url(?_contact) " \
+"(SELECT GROUP_CONCAT(fn:concat( " \
+ "?url_value, \"\31\", ?aff_type " \
+ "), \"\30\") " \
+ "WHERE {" \
+ "?_contact nco:hasAffiliation ?c_role . " \
+ "?c_role nco:url ?url_value . " \
+ "?c_role rdfs:label ?aff_type . " \
+"})" \
"nie:url(nco:photo(?_contact)) " \
"nco:role(?_role) " \
"nco:contactUID(?_contact) " \
"}) " \
"nco:birthDate(?_contact) " \
"nco:nickname(?_contact) " \
- "nco:url(?_contact) " \
+"(SELECT GROUP_CONCAT(fn:concat( " \
+ "?url_value, \"\31\", ?aff_type " \
+ "), \"\30\") " \
+ "WHERE {" \
+ "?_contact nco:hasAffiliation ?c_role . " \
+ "?c_role nco:url ?url_value . " \
+ "?c_role rdfs:label ?aff_type . " \
+"})" \
"nie:url(nco:photo(?_contact)) " \
"nco:role(?_role) " \
"nco:contactUID(?_contact) " \
"}) " \
"nco:birthDate(<%s>) " \
"nco:nickname(<%s>) " \
-"nco:url(<%s>) " \
+"(SELECT GROUP_CONCAT(fn:concat( " \
+ "?url_val, \"\31\", rdfs:label(?_role) " \
+ "), \"\30\") " \
+ "WHERE {" \
+ "?_role nco:url ?url_val . " \
+"})" \
"nie:url(nco:photo(<%s>)) " \
"nco:role(?_role) " \
"nco:contactUID(<%s>) " \
contact->addresses = g_slist_append(contact->addresses, addr);
}
+static void add_url(struct phonebook_contact *contact, const char *url_val,
+ int type)
+{
+ struct phonebook_field *url;
+
+ if (url_val == NULL || strlen(url_val) == 0)
+ return;
+
+ /* Not adding url if there is already added with the same value */
+ if (find_field(contact->urls, url_val, type))
+ return;
+
+ url = g_new0(struct phonebook_field, 1);
+
+ url->text = g_strdup(url_val);
+ url->type = type;
+
+ contact->urls = g_slist_append(contact->urls, url);
+}
+
static GString *gen_vcards(GSList *contacts,
const struct apparam_field *params)
{
contact->suffix = g_strdup(reply[COL_NAME_SUFFIX]);
contact->birthday = g_strdup(reply[COL_BIRTH_DATE]);
contact->nickname = g_strdup(reply[COL_NICKNAME]);
- contact->website = g_strdup(reply[COL_URL]);
contact->photo = g_strdup(reply[COL_PHOTO]);
contact->company = g_strdup(reply[COL_ORG_NAME]);
contact->department = g_strdup(reply[COL_ORG_DEPARTMENT]);
g_strfreev(aff_addr);
}
+static void contact_add_urls(struct phonebook_contact *contact, char **reply)
+{
+ char **aff_url;
+ int i;
+
+ /* Addresses from affilation */
+ aff_url = g_strsplit(reply[COL_URL], MAIN_DELIM, MAX_FIELDS);
+
+ if (aff_url)
+ for(i = 0; aff_url[i] != NULL; ++i)
+ add_aff_field(contact, aff_url[i], add_url);
+
+ g_strfreev(aff_url);
+}
+
static void contact_add_organization(struct phonebook_contact *contact,
char **reply)
{
contact_add_numbers(contact, reply);
contact_add_emails(contact, reply);
contact_add_addresses(contact, reply);
+ contact_add_urls(contact, reply);
contact_add_organization(contact, reply);
DBG("contact %p", contact);
if (strncmp(id, CONTACT_ID_PREFIX, strlen(CONTACT_ID_PREFIX)) == 0)
query = g_strdup_printf(CONTACTS_QUERY_FROM_URI, id, id, id, id,
id, id, id, id, id, id, id, id,
- id, id, id);
+ id, id);
else
query = g_strdup_printf(CONTACTS_OTHER_QUERY_FROM_URI,
id, id, id);
diff --git a/obexd/plugins/vcard.c b/obexd/plugins/vcard.c
index 261e264..efeba17 100644
--- a/obexd/plugins/vcard.c
+++ b/obexd/plugins/vcard.c
vcard_printf(vcards,"EMAIL;%s:%s", category_string, field);
}
+static void vcard_printf_url(GString *vcards, uint8_t format,
+ const char *url,
+ enum phonebook_field_type category)
+{
+ const char *category_string = "";
+
+ if (!url || strlen(url) == 0) {
+ vcard_printf(vcards, "URL:");
+ return;
+ }
+
+ switch (category) {
+ case FIELD_TYPE_HOME:
+ if (format == FORMAT_VCARD21)
+ category_string = "INTERNET;HOME";
+ else if (format == FORMAT_VCARD30)
+ category_string = "TYPE=INTERNET;TYPE=HOME";
+ break;
+ case FIELD_TYPE_WORK:
+ if (format == FORMAT_VCARD21)
+ category_string = "INTERNET;WORK";
+ else if (format == FORMAT_VCARD30)
+ category_string = "TYPE=INTERNET;TYPE=WORK";
+ break;
+ default:
+ if (format == FORMAT_VCARD21)
+ category_string = "INTERNET";
+ else if (format == FORMAT_VCARD30)
+ category_string = "TYPE=INTERNET";
+ break;
+ }
+
+ vcard_printf(vcards,"URL;%s:%s", category_string, url);
+}
+
static gboolean org_fields_present(struct phonebook_contact *contact)
{
if (contact->company && strlen(contact->company))
vcard_printf_slash_tag(vcards, format, "NICKNAME", NULL,
contact->nickname);
- if (filter & FILTER_URL)
- vcard_printf_slash_tag(vcards, format, "URL", "INTERNET",
- contact->website);
+ if (filter & FILTER_URL) {
+ GSList *l = contact->urls;
+
+ if (g_slist_length(l) == 0)
+ vcard_printf_url(vcards, format, NULL,
+ FIELD_TYPE_OTHER);
+
+ for (; l; l = l->next) {
+ struct phonebook_field *url = l->data;
+ vcard_printf_url(vcards, format, url->text, url->type);
+ }
+ }
if (filter & FILTER_PHOTO)
vcard_printf_tag(vcards, format, "PHOTO", NULL,
g_slist_foreach(contact->addresses, field_free, NULL);
g_slist_free(contact->addresses);
+ g_slist_foreach(contact->urls, field_free, NULL);
+ g_slist_free(contact->urls);
+
g_free(contact->uid);
g_free(contact->fullname);
g_free(contact->given);
g_free(contact->suffix);
g_free(contact->birthday);
g_free(contact->nickname);
- g_free(contact->website);
g_free(contact->photo);
g_free(contact->company);
g_free(contact->department);
diff --git a/obexd/plugins/vcard.h b/obexd/plugins/vcard.h
index 379f92c..88cdbed 100644
--- a/obexd/plugins/vcard.h
+++ b/obexd/plugins/vcard.h
GSList *addresses;
char *birthday;
char *nickname;
- char *website;
+ GSList *urls;
char *photo;
char *company;
char *department;