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);
}
/* 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;
}
void examine_mime_part(message_summary *Msg, StrBuf *HdrLine, StrBuf *FoundCharset)
{
+ const char *Ptr = NULL;
wc_mime_attachment *Mime;
StrBuf *Buf;
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;
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);
}
-/*
- * 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("<a href=\"edit_vcard?"
- "msgnum=%ld&partnum=%s\">",
- msgnum, vcard_partnum);
- wc_printf("[%s]</a>", _("edit"));
- }
-
- FreeStrBuf(&vcard_source);
- }
- }
-
-}
-
-
-
/*
* If it's an old "Firstname Lastname" style record, try to convert it.
*/
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);
* 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;
* msgnum Citadel message pointer
*/
void display_vcard(StrBuf *Target,
- StrBuf *vcard_source,
+ wc_mime_attachment *Mime,
char alpha,
int full,
char **storename,
StrBuf *Buf2;
char this_alpha = 0;
- v = VCardLoad(vcard_source);
+ v = VCardLoad(Mime->Data);
if (v == NULL) return;
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);
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);
-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 *);