-/*
- * fetch the display name off a vCard
- */
-void fetch_ab_name(message_summary *Msg, char **namebuf) {
- long len;
- int i;
- wc_mime_attachment *VCMime = NULL;
-
- if (namebuf == NULL) return;
-
- VCMime = load_vcard(Msg);
- if (VCMime == NULL)
- return;
-
- /* Grab the name off the card */
- display_vcard(WC->WBuf, VCMime, 0, 0, namebuf, Msg->msgnum);
-
- if (*namebuf != NULL) {
- lastfirst_firstlast(*namebuf);
- striplt(*namebuf);
- len = strlen(*namebuf);
- for (i=0; i<len; ++i) {
- if ((*namebuf)[i] != ';') return;
- }
- free (*namebuf);
- (*namebuf) = strdup(_("(no name)"));
- }
- else {
- (*namebuf) = strdup(_("(no name)"));
- }
-}
-
-
-
-/*
- * Turn a vCard "n" (name) field into something displayable.
- */
-void vcard_n_prettyize(char *name)
-{
- char *original_name;
- int i, j, len;
-
- original_name = strdup(name);
- len = strlen(original_name);
- for (i=0; i<5; ++i) {
- if (len > 0) {
- if (original_name[len-1] == ' ') {
- original_name[--len] = 0;
- }
- if (original_name[len-1] == ';') {
- original_name[--len] = 0;
- }
- }
- }
- strcpy(name, "");
- j=0;
- for (i=0; i<len; ++i) {
- if (original_name[i] == ';') {
- name[j++] = ',';
- name[j++] = ' ';
- }
- else {
- name[j++] = original_name[i];
- }
- }
- name[j] = '\0';
- free(original_name);
-}
-
-
-
-
-/*
- * preparse a vcard name
- * display_vcard() calls this after parsing the textual vCard into
- * our 'struct vCard' data object.
- * This gets called instead of display_parsed_vcard() if we are only looking
- * to extract the person's name instead of displaying the card.
- */
-void fetchname_parsed_vcard(struct vCard *v, char **storename) {
- char *name;
- char *prop;
- char buf[SIZ];
- int j, n, len;
- int is_qp = 0;
- int is_b64 = 0;
-
- *storename = NULL;
-
- name = vcard_get_prop(v, "n", 1, 0, 0);
- if (name != NULL) {
- len = strlen(name);
- prop = vcard_get_prop(v, "n", 1, 0, 1);
- n = num_tokens(prop, ';');
-
- for (j=0; j<n; ++j) {
- extract_token(buf, prop, j, ';', sizeof buf);
- if (!strcasecmp(buf, "encoding=quoted-printable")) {
- is_qp = 1;
- }
- if (!strcasecmp(buf, "encoding=base64")) {
- is_b64 = 1;
- }
- }
- if (is_qp) {
- /* %ff can become 6 bytes in utf8 */
- *storename = malloc(len * 2 + 3);
- j = CtdlDecodeQuotedPrintable(
- *storename, name,
- len);
- (*storename)[j] = 0;
- }
- else if (is_b64) {
- /* ff will become one byte.. */
- *storename = malloc(len + 50);
- CtdlDecodeBase64(
- *storename, name,
- len);
- }
- else {
- size_t len;
-
- len = strlen (name);
-
- *storename = malloc(len + 3); /* \0 + eventualy missing ', '*/
- memcpy(*storename, name, len + 1);
- }
- /* vcard_n_prettyize(storename); */
- }
-
-}
-
-
-
-