* remove unneeded vcard function...
authorWilfried Göesgens <willi@citadel.org>
Sun, 31 Jan 2010 22:10:55 +0000 (22:10 +0000)
committerWilfried Göesgens <willi@citadel.org>
Sun, 31 Jan 2010 22:10:55 +0000 (22:10 +0000)
* put the mime struct through into the vcard functions instead of just parts
* evaluate the (new) charset from part= and DLAT

webcit/messages.c
webcit/msg_renderers.c
webcit/vcard_edit.c
webcit/webcit.h

index bb17f729665e5264d78800f37797c7cbb1b7eb5e..9579688559610499737438d17e9ec94d337f5460 100644 (file)
@@ -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);
index c50532555f2a7adcc46b8c201e04ab76221b2d37..5de3f3ba3d54ac4059563d0d13a55dbb292d26fe 100644 (file)
@@ -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);
index ae513934c68f2ad65c1d92087b1ad22f4aad1115..d9537cb42c4586479f835fb689b04abdb787091f 100644 (file)
@@ -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("<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.
  */
@@ -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);
index 3bd09471e32818038b483e883f075281aefb016f..8d919464dc239841234e448fcea3d70712fc01c5 100644 (file)
@@ -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 *);