Fix default landing mechanism
[citadel.git] / webcit / vcard_edit.c
index 9c8bd3b0c4c76b899883eb610e0df2308d633a7e..1a9f11a67142c9feac94dd66df2d1c2a3330e31d 100644 (file)
@@ -1,26 +1,20 @@
 /*
- * Copyright (c) 1996-2011 by the citadel.org team
+ * Copyright (c) 1996-2012 by the citadel.org team
  *
  * This program is open source software.  You can redistribute it and/or
- * modify it under the terms of the GNU General Public License as
- * published by the Free Software Foundation; either version 3 of the
- * License, or (at your option) any later version.
+ * modify it under the terms of the GNU General Public License, version 3.
  *
  * This program is distributed in the hope that it will be useful,
  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  */
 
 #include "webcit.h"
 #include "webserver.h"
 #include "calendar.h"
 
-
+CtxType CTX_VCARD = CTX_NONE;
 
 ConstStr VCStr [] = {
        {HKEY("n")}, /* N is name, but only if there's no FN already there */
@@ -143,7 +137,8 @@ wc_mime_attachment *load_vcard(message_summary *Msg)
        if (VCMime == NULL)
                return NULL;
 
-       MimeLoadData(VCMime);
+       if (VCMime->Data == NULL)
+               MimeLoadData(VCMime);
        return VCMime;
 }
 
@@ -605,7 +600,7 @@ void parse_vcard(StrBuf *Target, struct vCard *v, HashList *VC, int full, wc_mim
                        StrBufDecodeBase64(Val);
 
                }
-               syslog(1, "%s [%s][%s]",
+               syslog(LOG_DEBUG, "%s [%s][%s]",
                        firsttoken,
                        ChrPtr(Val),
                        v->prop[i].value);
@@ -613,11 +608,11 @@ void parse_vcard(StrBuf *Target, struct vCard *v, HashList *VC, int full, wc_mim
                {
                        eVC evc = (eVC) V;
                        Put(VC, IKEY(evc), Val, HFreeStrBuf);
-                       syslog(1, "[%ul]\n", evc);
+                       syslog(LOG_DEBUG, "[%ul]\n", evc);
                        Val = NULL;
                }
                else
-                       syslog(1, "[]\n");
+                       syslog(LOG_DEBUG, "[]\n");
 /*
 TODO: check for layer II
                else 
@@ -657,7 +652,7 @@ TODO: check for layer II
 
 void tmplput_VCARD_ITEM(StrBuf *Target, WCTemplputParams *TP)
 {
-       HashList *VC = CTX;
+       HashList *VC = CTX(CTX_VCARD);
        eVC evc;
        void *vStr;
 
@@ -876,6 +871,7 @@ void do_edit_vcard(long msgnum, char *partnum,
                   wc_mime_attachment *VCAtt,
                   const char *return_to, 
                   const char *force_room) {
+       wcsession *WCC = WC;
        message_summary *Msg = NULL;
        wc_mime_attachment *VCMime = NULL;
        struct vCard *v;
@@ -1056,6 +1052,12 @@ void do_edit_vcard(long msgnum, char *partnum,
                escputs(force_room);
                wc_printf("\">\n");
        }
+       else
+       {
+               wc_printf("<input type=\"hidden\" name=\"go\" value=\"");
+               StrEscAppend(WCC->WBuf, WCC->CurRoom.name, NULL, 0, 0);
+               wc_printf("\">\n");
+       }
 
        wc_printf("<table class=\"vcard_edit_background\"><tr><td>\n");
 
@@ -1281,7 +1283,7 @@ void submit_vcard(void) {
        }
 
        Buf = NewStrBuf();
-       serv_write(HKEY("ENT0 1|||4||||||1\n"));
+       serv_write(HKEY("ENT0 1|||4\n"));
        if (!StrBuf_ServGetln(Buf) && (GetServerStatus(Buf, NULL) != 4))
        {
                edit_vcard();
@@ -1350,8 +1352,6 @@ void submit_vcard(void) {
        serv_write(HKEY("000\n"));
        free(serialized_vcard);
 
-       StrBuf_ServGetln(Buf);
-
        if (!strcmp(bstr("return_to"), "select_user_to_edit")) {
                select_user_to_edit(NULL);
        }
@@ -1512,6 +1512,7 @@ void
 InitModule_VCARD
 (void)
 {
+       RegisterCTX(CTX_VCARD);
        RegisterReadLoopHandlerset(
                VIEW_ADDRESSBOOK,
                vcard_GetParamsGetServerCall,