From: Wilfried Göesgens Date: Sun, 31 Jan 2010 22:10:55 +0000 (+0000) Subject: * remove unneeded vcard function... X-Git-Tag: v7.86~467 X-Git-Url: https://code.citadel.org/?p=citadel.git;a=commitdiff_plain;h=0af85763b23dfbefdc9faee3b62651046084ae22 * remove unneeded vcard function... * put the mime struct through into the vcard functions instead of just parts * evaluate the (new) charset from part= and DLAT --- diff --git a/webcit/messages.c b/webcit/messages.c index bb17f7296..957968855 100644 --- a/webcit/messages.c +++ b/webcit/messages.c @@ -1581,14 +1581,20 @@ StrBuf *load_mimepart(long msgnum, char *partnum) void MimeLoadData(wc_mime_attachment *Mime) { StrBuf *Buf; + const char *Ptr; off_t bytes; /* TODO: is there a chance the content type is different from the one we know? */ + serv_printf("DLAT %ld|%s", Mime->msgnum, ChrPtr(Mime->PartNum)); Buf = NewStrBuf(); StrBuf_ServGetln(Buf); if (GetServerStatus(Buf, NULL) == 6) { - bytes = extract_long(&(ChrPtr(Buf)[4]), 0); - + Ptr = &(ChrPtr(Buf)[4]); + bytes = StrBufExtractNext_long(Buf, &Ptr, '|'); + StrBufSkip_NTokenS(Buf, &Ptr, '|', 3); /* filename, cbtype, mimetype */ + if (Mime->Charset == NULL) Mime->Charset = NewStrBuf(); + StrBufExtract_NextToken(Mime->Charset, Buf, &Ptr, '|'); + if (Mime->Data == NULL) Mime->Data = NewStrBufPlain(NULL, bytes); StrBuf_ServGetBLOBBuffered(Mime->Data, bytes); diff --git a/webcit/msg_renderers.c b/webcit/msg_renderers.c index c50532555..5de3f3ba3 100644 --- a/webcit/msg_renderers.c +++ b/webcit/msg_renderers.c @@ -511,7 +511,7 @@ void render_MIME_VCard(wc_mime_attachment *Mime, StrBuf *RawData, StrBuf *FoundC } /* In all cases, display the full card */ - display_vcard(Buf, Mime->Data, 0, 1, NULL, Mime->msgnum); + display_vcard(Buf, Mime, 0, 1, NULL, -1); FreeStrBuf(&Mime->Data); Mime->Data = Buf; } @@ -566,6 +566,7 @@ void render_MIME_ICS(wc_mime_attachment *Mime, StrBuf *RawData, StrBuf *FoundCha void examine_mime_part(message_summary *Msg, StrBuf *HdrLine, StrBuf *FoundCharset) { + const char *Ptr = NULL; wc_mime_attachment *Mime; StrBuf *Buf; @@ -575,17 +576,17 @@ void examine_mime_part(message_summary *Msg, StrBuf *HdrLine, StrBuf *FoundChars Buf = NewStrBuf(); Mime->Name = NewStrBuf(); - StrBufExtract_token(Buf, HdrLine, 0, '|'); + StrBufExtract_NextToken(Buf, HdrLine, &Ptr, '|'); StrBuf_RFC822_to_Utf8(Mime->Name, Buf, WC->DefaultCharset, FoundCharset); StrBufTrim(Mime->Name); - StrBufExtract_token(Buf, HdrLine, 1, '|'); + StrBufExtract_NextToken(Buf, HdrLine, &Ptr, '|'); Mime->FileName = NewStrBuf(); StrBuf_RFC822_to_Utf8(Mime->FileName, Buf, WC->DefaultCharset, FoundCharset); StrBufTrim(Mime->FileName); Mime->PartNum = NewStrBuf(); - StrBufExtract_token(Mime->PartNum, HdrLine, 2, '|'); + StrBufExtract_NextToken(Mime->PartNum, HdrLine, &Ptr, '|'); StrBufTrim(Mime->PartNum); if (strchr(ChrPtr(Mime->PartNum), '.') != NULL) Mime->level = 2; @@ -593,18 +594,24 @@ void examine_mime_part(message_summary *Msg, StrBuf *HdrLine, StrBuf *FoundChars Mime->level = 1; Mime->Disposition = NewStrBuf(); - StrBufExtract_token(Mime->Disposition, HdrLine, 3, '|'); + StrBufExtract_NextToken(Mime->Disposition, HdrLine, &Ptr, '|'); Mime->ContentType = NewStrBuf(); - StrBufExtract_token(Mime->ContentType, HdrLine, 4, '|'); + StrBufExtract_NextToken(Mime->ContentType, HdrLine, &Ptr, '|'); StrBufTrim(Mime->ContentType); StrBufLowerCase(Mime->ContentType); - if (!strcmp(ChrPtr(Mime->ContentType), "application/octet-stream")) { StrBufPlain(Mime->ContentType, GuessMimeByFilename(SKEY(Mime->FileName)), -1); } - Mime->length = StrBufExtract_int(HdrLine, 5, '|'); + + Mime->length = StrBufExtractNext_int(HdrLine, &Ptr, '|'); + + StrBufSkip_NTokenS(HdrLine, &Ptr, '|', 1); /* cbid?? */ + + Mime->Charset = NewStrBuf(); + StrBufExtract_NextToken(Mime->Charset, HdrLine, &Ptr, '|'); + if ( (StrLength(Mime->FileName) == 0) && (StrLength(Mime->Name) > 0) ) { StrBufAppendBuf(Mime->FileName, Mime->Name, 0); diff --git a/webcit/vcard_edit.c b/webcit/vcard_edit.c index ae513934c..d9537cb42 100644 --- a/webcit/vcard_edit.c +++ b/webcit/vcard_edit.c @@ -29,47 +29,6 @@ void nametab(char *tabbuf, long len, char *name) { } -/* - * display the adressbook overview - */ -void display_addressbook(long msgnum, char alpha) { - //char buf[SIZ]; - /* char mime_partnum[SIZ]; */ - ///char mime_disposition[SIZ]; - //int mime_length; - char vcard_partnum[SIZ]; - StrBuf *vcard_source = NULL; - message_summary summ;////TODO: this will leak - - memset(&summ, 0, sizeof(summ)); - // safestrncpy(summ.subj, _("(no subject)"), sizeof summ.subj); - // Load Message headers - if (!IsEmptyStr(vcard_partnum)) { - vcard_source = load_mimepart(msgnum, vcard_partnum); - if (vcard_source != NULL) { - - /* Display the summary line */ - display_vcard(WC->WBuf, vcard_source, alpha, 0, NULL, msgnum); - - /* If it's my vCard I can edit it */ - if ( (!strcasecmp(ChrPtr(WC->CurRoom.name), USERCONFIGROOM)) - || (!strcasecmp(&(ChrPtr(WC->CurRoom.name)[11]), USERCONFIGROOM)) - || (WC->CurRoom.view == VIEW_ADDRESSBOOK) - ) { - wc_printf("", - msgnum, vcard_partnum); - wc_printf("[%s]", _("edit")); - } - - FreeStrBuf(&vcard_source); - } - } - -} - - - /* * If it's an old "Firstname Lastname" style record, try to convert it. */ @@ -148,7 +107,7 @@ void fetch_ab_name(message_summary *Msg, char **namebuf) { return; /* Grab the name off the card */ - display_vcard(WC->WBuf, VCMime->Data, 0, 0, namebuf, Msg->msgnum); + display_vcard(WC->WBuf, VCMime, 0, 0, namebuf, Msg->msgnum); if (*namebuf != NULL) { lastfirst_firstlast(*namebuf); @@ -284,7 +243,8 @@ void fetchname_parsed_vcard(struct vCard *v, char **storename) { * full display all items of the vcard? * msgnum Citadel message pointer */ -void display_parsed_vcard(StrBuf *Target, struct vCard *v, int full, long msgnum) { +void display_parsed_vcard(StrBuf *Target, struct vCard *v, int full, wc_mime_attachment *Mime) +{ int i, j; char buf[SIZ]; char *name; @@ -539,7 +499,7 @@ void display_parsed_vcard(StrBuf *Target, struct vCard *v, int full, long msgnum * msgnum Citadel message pointer */ void display_vcard(StrBuf *Target, - StrBuf *vcard_source, + wc_mime_attachment *Mime, char alpha, int full, char **storename, @@ -551,7 +511,7 @@ void display_vcard(StrBuf *Target, StrBuf *Buf2; char this_alpha = 0; - v = VCardLoad(vcard_source); + v = VCardLoad(Mime->Data); if (v == NULL) return; @@ -568,12 +528,12 @@ void display_vcard(StrBuf *Target, if (storename != NULL) { fetchname_parsed_vcard(v, storename); } - else if ( - (alpha == 0) - || ((isalpha(alpha)) && (tolower(alpha) == tolower(this_alpha))) - || ((!isalpha(alpha)) && (!isalpha(this_alpha))) - ) { - display_parsed_vcard(Target, v, full,msgnum); + else if ((alpha == 0) || + ((isalpha(alpha)) && (tolower(alpha) == tolower(this_alpha))) || + ((!isalpha(alpha)) && (!isalpha(this_alpha))) + ) + { + display_parsed_vcard(Target, v, full, Mime); } vcard_free(v); diff --git a/webcit/webcit.h b/webcit/webcit.h index 3bd09471e..8d919464d 100644 --- a/webcit/webcit.h +++ b/webcit/webcit.h @@ -662,7 +662,7 @@ void embed_main_menu(void); void do_addrbook_view(addrbookent *addrbook, int num_ab); void fetch_ab_name(message_summary *Msg, char **namebuf); -void display_vcard(StrBuf *Target, StrBuf *vcard_source, char alpha, int full, char **storename, long msgnum); +void display_vcard(StrBuf *Target, wc_mime_attachment *Mime, char alpha, int full, char **storename, long msgnum); void jsonMessageList(void); void new_summary_view(void); void getseen(void); @@ -726,7 +726,6 @@ void folders(void); -void display_addressbook(long msgnum, char alpha); void offer_start_page(StrBuf *Target, WCTemplputParams *TP); void convenience_page(const char *titlebarcolor, const char *titlebarmsg, const char *messagetext); void output_html(const char *, int, int, StrBuf *, StrBuf *);