* use load_message in the useredit form
authorWilfried Göesgens <willi@citadel.org>
Sun, 26 Apr 2009 13:36:43 +0000 (13:36 +0000)
committerWilfried Göesgens <willi@citadel.org>
Sun, 26 Apr 2009 13:36:43 +0000 (13:36 +0000)
* enable the vcard editor to work with a preloaded message

webcit/auth.c
webcit/messages.c
webcit/messages.h
webcit/msg_renderers.c
webcit/useredit.c
webcit/vcard_edit.c
webcit/webcit.h
webcit/wiki.c

index a83b98e591eedfd9e212fce52a2d34699990b750..dd240fb09a710464b00e35527c917df0993ed82a 100644 (file)
@@ -733,6 +733,8 @@ void validate(void)
  */
 void display_reg(int during_login)
 {
+       message_summary *VCMsg;
+       wc_mime_attachment *VCAtt;
        long vcard_msgnum;
 
        if (goto_config_room() != 0) {
@@ -741,7 +743,7 @@ void display_reg(int during_login)
                return;
        }
 
-       vcard_msgnum = locate_user_vcard_in_this_room();
+       vcard_msgnum = locate_user_vcard_in_this_room(&VCMsg, &VCAtt);
        if (vcard_msgnum < 0L) {
                if (during_login) do_welcome();
                else display_main_menu();
@@ -749,10 +751,10 @@ void display_reg(int during_login)
        }
 
        if (during_login) {
-               do_edit_vcard(vcard_msgnum, "1", "do_welcome", USERCONFIGROOM);
+               do_edit_vcard(vcard_msgnum, "1", VCMsg, VCAtt, "do_welcome", USERCONFIGROOM);
        }
        else {
-               do_edit_vcard(vcard_msgnum, "1", "display_main_menu", USERCONFIGROOM);
+               do_edit_vcard(vcard_msgnum, "1", VCMsg, VCAtt, "display_main_menu", USERCONFIGROOM);
        }
 
 }
index 99759b788dd5b0d199f7ae76a1b7475c72600441..2edbafcdf07ad841d47dae30460d4a7cabb2bfe9 100644 (file)
@@ -50,7 +50,11 @@ int load_message(message_summary *Msg,
        
        Buf = NewStrBuf();
        lprintf(1, "-------------------MSG4 %ld|%s--------------\n", Msg->msgnum, ChrPtr(Msg->PartNum));
-       serv_printf("MSG4 %ld|%s", Msg->msgnum, ChrPtr(Msg->PartNum));
+       if (Msg->PartNum != NULL)
+               serv_printf("MSG4 %ld|%s", Msg->msgnum, ChrPtr(Msg->PartNum));
+       else
+               serv_printf("MSG4 %ld", Msg->msgnum);
+
        StrBuf_ServGetln(Buf);
        if (GetServerStatus(Buf, NULL) != 1) {
                *Error = NewStrBuf();
@@ -70,7 +74,8 @@ int load_message(message_summary *Msg,
                        Done = 1;
                        if (state < 2) {
                                lprintf(1, _("unexpected end of message"));
-                               
+                               if (Msg->MsgBody->Data == NULL)
+                                       Msg->MsgBody->Data = NewStrBuf();
                                Msg->MsgBody->ContentType = NewStrBufPlain(HKEY("text/html"));
                                StrBufAppendPrintf(Msg->MsgBody->Data, "<div><i>");
                                StrBufAppendPrintf(Msg->MsgBody->Data, _("unexpected end of message"));
@@ -1327,7 +1332,7 @@ void display_enter(void)
         * message" command really means "add new entry."
         */
        if (WCC->wc_default_view == VIEW_ADDRESSBOOK) {
-               do_edit_vcard(-1, "", "", ChrPtr(WCC->wc_roomname));
+               do_edit_vcard(-1, "", NULL, NULL, "",  ChrPtr(WCC->wc_roomname));
                return;
        }
 
index aa24ff558c991a0af1161bc545fe6d61214b854f..c7c3c0a542c711c2374611d8564927b3b9f691f1 100644 (file)
@@ -17,7 +17,7 @@ struct wc_mime_attachment {
        StrBuf *ContentType;
        StrBuf *Charset;
        StrBuf *Data;
-       size_t length;                     /* length of the mimeatachment */
+       size_t length;                     /* length of the mimeattachment */
        long size_known;
        long lvalue;               /* if we put a long... */
        long msgnum;            /**< the message number on the citadel server derived from message_summary */
@@ -48,14 +48,14 @@ typedef struct _message_summary {
        StrBuf *OtherNode;
        const StrBuf *PartNum;
 
-       HashList *Attachments;  /**< list of Accachments */
+       HashList *Attachments;  /**< list of Attachments */
        HashList *Submessages;
        HashList *AttachLinks;
 
        HashList *AllAttach;
 
        int is_new;         /**< is it yet read? */
-       int hasattachments;     /* does it have atachments? */
+       int hasattachments;     /* does it have attachments? */
 
 
        /** The mime part of the message */
@@ -91,7 +91,7 @@ int read_message(StrBuf *Target,
                 const StrBuf *section);
 int load_message(message_summary *Msg, 
                 StrBuf *FoundCharset,
-                StrBuf **Error)
+                StrBuf **Error);
 
 
 int load_msg_ptrs(const char *servcmd, int with_headers);
index 84d9831869d0621e04d40ee91ed8505b02334a8d..e1800d17ee9ae6c6403b487bd5069cbedf552a79 100644 (file)
@@ -463,7 +463,7 @@ void tmplput_MAIL_SUMM_DATE_NO(StrBuf *Target, WCTemplputParams *TP)
 void render_MAIL(wc_mime_attachment *Mime, StrBuf *RawData, StrBuf *FoundCharset)
 {
        Mime->Data = NewStrBufPlain(NULL, Mime->length);
-       read_message(Mime->Data, HKEY("view_submessage"), Mime->msgnum, 0, Mime->PartNum);
+       read_message(Mime->Data, HKEY("view_submessage"), Mime->msgnum, Mime->PartNum);
 /*
        if ( (!IsEmptyStr(mime_submessages)) && (!section[0]) ) {
                for (i=0; i<num_tokens(mime_submessages, '|'); ++i) {
@@ -780,7 +780,7 @@ void tmplput_QUOTED_MAIL_BODY(StrBuf *Target, WCTemplputParams *TP)
 
        MsgNum = LBstr(TKEY(0));
        Buf = NewStrBuf();
-       read_message(Buf, HKEY("view_message_replyquote"), MsgNum, 0, NULL);
+       read_message(Buf, HKEY("view_message_replyquote"), MsgNum, NULL);
        StrBufAppendTemplate(Target, TP, Buf, 1);
        FreeStrBuf(&Buf);
 }
index fc54484480deb6a758654942da24597b785c59f1..02aea240ea596d133049299a0a32907da2bcbb02 100644 (file)
@@ -11,7 +11,7 @@
  *  message the header message???
  *  preselect which user should be selected in the browser
  */
-void select_user_to_edit(char *message, char *preselect)
+void select_user_to_edit(const char *message, const char *preselect)
 {
        output_headers(1, 0, 0, 0, 1, 0);
        do_template("edituser_select", NULL);
@@ -60,6 +60,7 @@ UserListEntry* NewUserListOneEntry(StrBuf *SerializedUser)
 void DeleteUserListEntry(void *vUserList)
 {
        UserListEntry *ul = (UserListEntry*) vUserList;
+       if (!ul) return;
        FreeStrBuf(&ul->UserName);
        FreeStrBuf(&ul->Passvoid);
        free(ul);
@@ -240,9 +241,9 @@ int GroupchangenPosts(const void *vUser1, const void *vUser2)
 
 HashList *iterate_load_userlist(StrBuf *Target, WCTemplputParams *TP)
 {
+       int Done = 0;
        CompareFunc SortIt;
        HashList *Hash;
-       char buf[SIZ];
        StrBuf *Buf;
        UserListEntry* ul;
        char nnn[64];
@@ -252,13 +253,18 @@ HashList *iterate_load_userlist(StrBuf *Target, WCTemplputParams *TP)
 
        memset(&SubTP, 0, sizeof(WCTemplputParams));    
         serv_puts("LIST");
-        serv_getln(buf, sizeof buf);
-        if (buf[0] == '1') {
+       Buf = NewStrBuf();
+       StrBuf_ServGetlnBuffered(Buf);
+       if (GetServerStatus(Buf, NULL) == 1) {
                Hash = NewHash(1, NULL);
 
-               Buf = NewStrBuf();
-               while ((len = StrBuf_ServGetln(Buf),
-                       strcmp(ChrPtr(Buf), "000"))) {
+               while (!Done) {
+                       len = StrBuf_ServGetlnBuffered(Buf);
+                       if ((len == 3) &&
+                           (strcmp(ChrPtr(Buf), "000")==0)) {
+                               Done = 1;
+                               break;
+                       }
                        ul = NewUserListEntry(Buf);
                        if (ul == NULL)
                                continue;
@@ -266,7 +272,6 @@ HashList *iterate_load_userlist(StrBuf *Target, WCTemplputParams *TP)
                        nUsed = snprintf(nnn, sizeof(nnn), "%d", nUsed+1);
                        Put(Hash, nnn, nUsed, ul, DeleteUserListEntry); 
                }
-               FreeStrBuf(&Buf);
                SubTP.Filter.ContextType = CTX_USERLIST;
                SortIt = RetrieveSort(&SubTP, HKEY("USER"), HKEY("user:uid"), 0);
                if (SortIt != NULL)
@@ -275,6 +280,7 @@ HashList *iterate_load_userlist(StrBuf *Target, WCTemplputParams *TP)
                        SortByPayload(Hash, CompareUID);
                return Hash;
         }
+       FreeStrBuf(&Buf);
        return NULL;
 }
 
@@ -385,60 +391,67 @@ int ConditionalUserAccess(StrBuf *Target, WCTemplputParams *TP)
  *  Locate the message number of a user's vCard in the current room
  *  Returns the message id of his vcard
  */
-long locate_user_vcard_in_this_room() {
-       char buf[SIZ];
-       long vcard_msgnum = (-1L);
-       char content_type[SIZ];
-       char partnum[SIZ];
-       int already_tried_creating_one = 0;
+long locate_user_vcard_in_this_room(message_summary **VCMsg,
+                                   wc_mime_attachment **VCAtt)
+{
+       wcsession *WCC = WC;
+       HashPos *at;
+       HashPos *att;
+       const char *HashKey;
+       long HKLen;
+       void *vMsg;
+       message_summary *Msg;
+       wc_mime_attachment *Att;
 
-       struct stuff_t {
-               struct stuff_t *next;
-               long msgnum;
-       };
 
-       struct stuff_t *stuff = NULL;
-       struct stuff_t *ptr;
+       int Done;
+       StrBuf *Buf;
+       long vcard_msgnum = (-1L);
+       int already_tried_creating_one = 0;
+       StrBuf *FoundCharset = NewStrBuf();
+       StrBuf *Error = NULL;
 
+       
+       Buf = NewStrBuf();
 TRYAGAIN:
+       Done = 0;
        /** Search for the user's vCard */
-       serv_puts("MSGS ALL");
-       serv_getln(buf, sizeof buf);
-       if (buf[0] == '1') while (serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
-               ptr = malloc(sizeof(struct stuff_t));
-               ptr->msgnum = atol(buf);
-               ptr->next = stuff;
-               stuff = ptr;
-       }
-
-       /** Iterate through the message list looking for vCards */
-       while (stuff != NULL) {
-               serv_printf("MSG0 %ld|2", stuff->msgnum);
-               serv_getln(buf, sizeof buf);
-               if (buf[0]=='1') {
-                       while(serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
-                               if (!strncasecmp(buf, "part=", 5)) {
-                                       extract_token(partnum, &buf[5], 2, '|', sizeof partnum);
-                                       extract_token(content_type, &buf[5], 4, '|', sizeof content_type);
-                                       if (  (!strcasecmp(content_type, "text/x-vcard"))
-                                          || (!strcasecmp(content_type, "text/vcard")) ) {
-                                               vcard_msgnum = stuff->msgnum;
+       if (load_msg_ptrs("MSGS ALL||||1", 1) > 0) {
+               at = GetNewHashPos(WCC->summ, 0);
+               while (GetNextHashPos(WCC->summ, at, &HKLen, &HashKey, &vMsg)) {
+                       Msg = (message_summary*) vMsg;          
+                       Msg->MsgBody =  (wc_mime_attachment*) malloc(sizeof(wc_mime_attachment));
+                       memset(Msg->MsgBody, 0, sizeof(wc_mime_attachment));
+                       Msg->MsgBody->msgnum = Msg->msgnum;
+
+                       load_message(Msg, 
+                                    FoundCharset,
+                                    &Error);
+                       
+                       if (Msg->AllAttach != NULL) {
+                               att = GetNewHashPos(Msg->AllAttach, 0);
+                               while (GetNextHashPos(Msg->AllAttach, att, &HKLen, &HashKey, &vMsg)) {
+                                       Att = (wc_mime_attachment*) vMsg;
+                                       if (  (strcasecmp(ChrPtr(Att->ContentType), "text/x-vcard") == 0) ||
+                                             (strcasecmp(ChrPtr(Att->ContentType), "text/vcard")   == 0) ) {
+                                               *VCAtt = Att;
+                                               *VCMsg = Msg;
+                                               if (Att->Data == NULL)
+                                                       MimeLoadData(Att);
                                        }
                                }
                        }
+                       FreeStrBuf(&Error); /*< don't care... */
+                       
                }
-
-               ptr = stuff->next;
-               free(stuff);
-               stuff = ptr;
+               DeleteHashPos(&at);             
        }
-
        /** If there's no vcard, create one */
-       if ((vcard_msgnum < 0) && (already_tried_creating_one == 0)) {
+       if ((*VCMsg == NULL) && (already_tried_creating_one == 0)) {
                already_tried_creating_one = 1;
                serv_puts("ENT0 1|||4");
-               serv_getln(buf, sizeof buf);
-               if (buf[0] == '4') {
+               StrBuf_ServGetlnBuffered(Buf);
+               if (GetServerStatus(Buf, NULL) != 4) {
                        serv_puts("Content-type: text/x-vcard");
                        serv_puts("");
                        serv_puts("begin:vcard");
@@ -447,7 +460,7 @@ TRYAGAIN:
                }
                goto TRYAGAIN;
        }
-
+       FreeStrBuf(&Buf);
        return(vcard_msgnum);
 }
 
@@ -457,50 +470,59 @@ TRYAGAIN:
  *  username the name of the user
  *  usernum the citadel-uid of the user
  */
-void display_edit_address_book_entry(char *username, long usernum) {
+void display_edit_address_book_entry(const char *username, long usernum) {
+       message_summary *VCMsg = NULL;
+       wc_mime_attachment *VCAtt = NULL;
        char roomname[SIZ];
-       char buf[SIZ];
+       StrBuf *Buf;
        char error_message[SIZ];
        long vcard_msgnum = (-1L);
 
        /** Locate the user's config room, creating it if necessary */
-       sprintf(roomname, "%010ld.%s", usernum, USERCONFIGROOM);
-       serv_printf("GOTO %s||1", roomname);
-       serv_getln(buf, sizeof buf);
-       if (buf[0] != '2') {
-               serv_printf("CRE8 1|%s|5|||1|", roomname);
-               serv_getln(buf, sizeof buf);
-               serv_printf("GOTO %s||1", roomname);
-               serv_getln(buf, sizeof buf);
-               if (buf[0] != '2') {
+       Buf = NewStrBuf();
+       serv_printf("GOTO %010ld.%s||1", usernum, USERCONFIGROOM);
+       StrBuf_ServGetlnBuffered(Buf);
+       if (GetServerStatus(Buf, NULL) != 2) {
+               serv_printf("CRE8 1|%010ld.%s|5|||1|", usernum, USERCONFIGROOM);
+               StrBuf_ServGetlnBuffered(Buf);
+               GetServerStatus(Buf, NULL);
+               serv_printf("GOTO %010ld.%s||1", usernum, USERCONFIGROOM);
+               StrBuf_ServGetlnBuffered(Buf);
+               if (GetServerStatus(Buf, NULL) != 2) {
+                       StrBufCutLeft(Buf, 4);
                        sprintf(error_message,
                                "<img src=\"static/error.gif\" align=center>"
-                               "%s<br /><br />\n", &buf[4]);
+                               "%s<br /><br />\n", ChrPtr(Buf));
                        select_user_to_edit(error_message, username);
+                       FreeStrBuf(&Buf);
                        return;
                }
        }
+       FreeStrBuf(&Buf);
 
-       vcard_msgnum = locate_user_vcard_in_this_room();
+       locate_user_vcard_in_this_room(&VCMsg, &VCAtt);
 
-       if (vcard_msgnum < 0) {
+       if (VCMsg == NULL) {
                sprintf(error_message,
                        "<img src=\"static/error.gif\" align=center>%s<br /><br />\n",
                        _("An error occurred while trying to create or edit this address book entry.")
-               );
+                       );
                select_user_to_edit(error_message, username);
                return;
        }
 
-       do_edit_vcard(vcard_msgnum, "1", "select_user_to_edit", roomname);
+       do_edit_vcard(vcard_msgnum, "1", 
+                     VCMsg,
+                     VCAtt,
+                     "select_user_to_edit", 
+                     roomname);
 }
 
 
-void display_edituser(char *supplied_username, int is_new) {
+void display_edituser(const char *supplied_username, int is_new) {
        UserListEntry* UL;
        StrBuf *Buf;
        char error_message[1024];
-       char MajorStatus;
        char username[256];
 
        if (supplied_username != NULL) {
@@ -512,10 +534,9 @@ void display_edituser(char *supplied_username, int is_new) {
 
        Buf = NewStrBuf();
        serv_printf("AGUP %s", username);
-       StrBuf_ServGetln(Buf);
-       MajorStatus = ChrPtr(Buf)[0];
-       StrBufCutLeft(Buf, 4);
-       if (MajorStatus != '2') {
+       StrBuf_ServGetlnBuffered(Buf);
+       if (GetServerStatus(Buf, NULL) != 2) {
+               StrBufCutLeft(Buf, 4);
                /*TODO ImportantMessage */
                sprintf(error_message,
                        "<img src=\"static/error.gif\" align=center>"
@@ -525,14 +546,15 @@ void display_edituser(char *supplied_username, int is_new) {
                return;
        }
        else {
+               StrBufCutLeft(Buf, 4);
                UL = NewUserListOneEntry(Buf);
-               if (havebstr("edit_abe_button")) {
+               if ((UL != NULL) && havebstr("edit_abe_button")) {
                        display_edit_address_book_entry(username, UL->UID);
                }
-               else if (havebstr("delete_button")) {
+               else if ((UL != NULL) && havebstr("delete_button")) {
                        delete_user(username);
                }
-               else {
+               else if (UL != NULL) {
                        WCTemplputParams SubTP;
                        memset(&SubTP, 0, sizeof(WCTemplputParams));
                        SubTP.Filter.ContextType = CTX_USERLIST;
@@ -552,10 +574,9 @@ void display_edituser(char *supplied_username, int is_new) {
  */
 void edituser(void) {
        char message[SIZ];
-       char buf[SIZ];
        int is_new = 0;
        unsigned int flags = 0;
-       char *username;
+       const char *username;
 
        is_new = ibstr("is_new");
        safestrncpy(message, "", sizeof message);
@@ -563,9 +584,10 @@ void edituser(void) {
 
        if (!havebstr("ok_button")) {
                safestrncpy(message, _("Changes were not saved."), sizeof message);
-       }
-       
+       }       
        else {
+               StrBuf *Buf = NewStrBuf();
+
                flags = ibstr("flags");
                if (yesbstr("inetmail")) {
                        flags |= US_INTERNET;
@@ -576,11 +598,12 @@ void edituser(void) {
 
                if ((havebstr("newname")) && (strcasecmp(bstr("username"), bstr("newname")))) {
                        serv_printf("RENU %s|%s", bstr("username"), bstr("newname"));
-                       serv_getln(buf, sizeof buf);
-                       if (buf[0] != '2') {
+                       StrBuf_ServGetlnBuffered(Buf);
+                       if (GetServerStatus(Buf, NULL) == 2) {
+                               StrBufCutLeft(Buf, 4);
                                sprintf(&message[strlen(message)],
                                        "<img src=\"static/error.gif\" align=center>"
-                                       "%s<br /><br />\n", &buf[4]);
+                                       "%s<br /><br />\n", ChrPtr(Buf));
                        }
                        else {
                                username = bstr("newname");
@@ -598,12 +621,14 @@ void edituser(void) {
                        bstr("lastcall"),
                        bstr("purgedays")
                );
-               serv_getln(buf, sizeof buf);
-               if (buf[0] != '2') {
+               StrBuf_ServGetlnBuffered(Buf);
+               if (GetServerStatus(Buf, NULL) == 2) {
+                       StrBufCutLeft(Buf, 4);
                        sprintf(&message[strlen(message)],
                                "<img src=\"static/error.gif\" align=center>"
-                               "%s<br /><br />\n", &buf[4]);
+                               "%s<br /><br />\n", ChrPtr(Buf));
                }
+               FreeStrBuf(&Buf);
        }
 
        /**
@@ -623,20 +648,23 @@ void edituser(void) {
  *  username the name of the user to remove
  */
 void delete_user(char *username) {
-       char buf[SIZ];
+       StrBuf *Buf;
        char message[SIZ];
 
+       Buf = NewStrBuf();
        serv_printf("ASUP %s|0|0|0|0|0|", username);
-       serv_getln(buf, sizeof buf);
-       if (buf[0] != '2') {
+       StrBuf_ServGetlnBuffered(Buf);
+       if (GetServerStatus(Buf, NULL) == 2) {
+               StrBufCutLeft(Buf, 4);
                sprintf(message,
                        "<img src=\"static/error.gif\" align=center>"
-                       "%s<br /><br />\n", &buf[4]);
+                       "%s<br /><br />\n", ChrPtr(Buf));
        }
        else {
                safestrncpy(message, "", sizeof message);
        }
        select_user_to_edit(message, bstr("username"));
+       FreeStrBuf(&Buf);
 }
                
 
@@ -646,20 +674,20 @@ void delete_user(char *username) {
  * take the web environment username and create it on the citadel server
  */
 void create_user(void) {
-       char buf[SIZ];
+       long FullState;
+       StrBuf *Buf;
        char error_message[SIZ];
-       char username[SIZ];
-
-       safestrncpy(username, bstr("username"), sizeof username);
+       const char *username;
 
+       Buf = NewStrBuf();
+       username = bstr("username");
        serv_printf("CREU %s", username);
-       serv_getln(buf, sizeof buf);
-
-       if (buf[0] == '2') {
+       StrBuf_ServGetlnBuffered(Buf);
+       if (GetServerStatus(Buf, &FullState) == 2) {
                sprintf(WC->ImportantMessage, _("A new user has been created."));
                display_edituser(username, 1);
        }
-       else if (!strncmp(buf, "570", 3)) {
+       else if (FullState == 570) {
                sprintf(error_message,
                        "<img src=\"static/error.gif\" align=center>"
                        "%s<br /><br />\n",
@@ -670,12 +698,13 @@ void create_user(void) {
                select_user_to_edit(error_message, NULL);
        }
        else {
+               StrBufCutLeft(Buf, 4);
                sprintf(error_message,
                        "<img src=\"static/error.gif\" align=center>"
-                       "%s<br /><br />\n", &buf[4]);
+                       "%s<br /><br />\n", ChrPtr(Buf));
                select_user_to_edit(error_message, NULL);
        }
-
+       FreeStrBuf(&Buf);
 }
 
 
index 311fb3aa83e1f4bf29faa9f2f5fdafb626f7e709..38ab46357d2ff037e8266ca6b18fca7e8b459521 100644 (file)
@@ -696,7 +696,11 @@ void do_addrbook_view(addrbookent *addrbook, int num_ab) {
  * and MIME part number to fetch.  Or, specify -1 for the message number
  * to start with a blank card.
  */
-void do_edit_vcard(long msgnum, char *partnum, char *return_to, const char *force_room) {
+void do_edit_vcard(long msgnum, char *partnum, 
+                  message_summary *VCMsg,
+                  wc_mime_attachment *VCAtt,
+                  char *return_to, 
+                  const char *force_room) {
        StrBuf *Buf;
        char buf[SIZ];
        size_t total_len = 0;
@@ -753,37 +757,44 @@ void do_edit_vcard(long msgnum, char *partnum, char *return_to, const char *forc
 
        safestrncpy(whatuser, "", sizeof whatuser);
 
-       if (msgnum >= 0) {
-               sprintf(buf, "MSG0 %ld|1", msgnum);
-               serv_puts(buf);
-               serv_getln(buf, sizeof buf);
-               if (buf[0] != '1') {
-                       convenience_page("770000", _("Error"), &buf[4]);
-                       return;
-               }
-               while (serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
-                       if (!strncasecmp(buf, "from=", 5)) {
-                               safestrncpy(whatuser, &buf[5], sizeof whatuser);
+       if ((msgnum >= 0) || 
+           ((VCMsg != NULL) && (VCAtt != NULL)))
+       {
+               if ((VCMsg == NULL) && (VCAtt == NULL)) {
+                       sprintf(buf, "MSG0 %ld|1", msgnum);
+                       serv_puts(buf);
+                       serv_getln(buf, sizeof buf);
+                       if (buf[0] != '1') {
+                               convenience_page("770000", _("Error"), &buf[4]);
+                               return;
+                       }
+                       while (serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
+                               if (!strncasecmp(buf, "from=", 5)) {
+                                       safestrncpy(whatuser, &buf[5], sizeof whatuser);
+                               }
+                               else if (!strncasecmp(buf, "node=", 5)) {
+                                       strcat(whatuser, " @ ");
+                                       strcat(whatuser, &buf[5]);
+                               }
                        }
-                       else if (!strncasecmp(buf, "node=", 5)) {
-                               strcat(whatuser, " @ ");
-                               strcat(whatuser, &buf[5]);
+                       Buf = NewStrBuf();
+                       serv_printf(buf, "DLAT %ld|%s", msgnum, partnum);
+                       StrBuf_ServGetlnBuffered(Buf);
+                       if (GetServerStatus(Buf, NULL) != 6) {
+                               convenience_page("770000", "Error", &(ChrPtr(Buf)[4]));
+                               return;
                        }
+                       
+                       StrBufCutLeft(Buf, 4);
+                       total_len = StrBufExtract_long(Buf, 0, '|');
+                       
+                       StrBuf_ServGetBLOBBuffered(Buf, total_len);
+               
+                       v = VCardLoad(Buf);
                }
-               Buf = NewStrBuf();
-               serv_printf(buf, "DLAT %ld|%s", msgnum, partnum);
-               StrBuf_ServGetlnBuffered(Buf);
-               if (GetServerStatus(Buf, NULL) != 6) {
-                       convenience_page("770000", "Error", &(ChrPtr(Buf)[4]));
-                       return;
+               else {
+                       v = VCardLoad(VCAtt->Data);
                }
-               
-               StrBufCutLeft(Buf, 4);
-               total_len = StrBufExtract_long(Buf, 0, '|');
-
-               StrBuf_ServGetBLOBBuffered(Buf, total_len);
-       
-               v = VCardLoad(Buf);
                FreeStrBuf(&Buf);
        
                /* Populate the variables for our form */
@@ -1065,7 +1076,7 @@ void edit_vcard(void) {
 
        msgnum = lbstr("msgnum");
        partnum = bstr("partnum");
-       do_edit_vcard(msgnum, partnum, "", NULL);
+       do_edit_vcard(msgnum, partnum, NULL, NULL, "", NULL);
 }
 
 
index 845bfa445a2175e868b4ec423e34e78b14755932..e1ac1864416137a6145a322fab6f4f9ce0e470e6 100644 (file)
@@ -645,7 +645,11 @@ void remove_token(char *source, int parmnum, char separator);
 StrBuf *load_mimepart(long msgnum, char *partnum);
 void MimeLoadData(wc_mime_attachment *Mime);
 int pattern2(char *search, char *patn);
-void do_edit_vcard(long, char *, char *, const char *);
+void do_edit_vcard(long msgnum, char *partnum, 
+                  message_summary *VCMsg,
+                  wc_mime_attachment *VCAtt,
+                  char *return_to, 
+                  const char *force_room);
 void select_user_to_edit(const char *message, const char *preselect);
 void delete_user(char *);
 void do_change_view(int);
@@ -712,7 +716,8 @@ int StrBuf_ServGetBLOB(StrBuf *buf, long BlobSize);
 int StrBuf_ServGetBLOBBuffered(StrBuf *buf, long BlobSize);
 int read_server_text(StrBuf *Buf, long *nLines);
 int goto_config_room(void);
-long locate_user_vcard_in_this_room(void);
+long locate_user_vcard_in_this_room(message_summary **VCMsg,
+                                   wc_mime_attachment **VCAtt);
 void sleeeeeeeeeep(int);
 void http_transmit_thing(const char *content_type, int is_static);
 long unescape_input(char *buf);
index 1bbb38dbe88711dc7733187081a24c6e839a2a27..ebe660dd1f42163fe62323449f151b59b325b7ce 100644 (file)
@@ -77,7 +77,7 @@ void display_wiki_page(void)
        msgnum = locate_message_by_uid(pagename);
        if (msgnum >= 0L) {
                output_headers(1, 1, 1, 0, 0, 0);
-               read_message(WC->WBuf, HKEY("view_message"), msgnum, 0, NULL);
+               read_message(WC->WBuf, HKEY("view_message"), msgnum, NULL);
                wDumpContent(1);
                return;
        }