/*
- * 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 */
if (VCMime == NULL)
return NULL;
- MimeLoadData(VCMime);
+ if (VCMime->Data == NULL)
+ MimeLoadData(VCMime);
return VCMime;
}
}
}
if (is_qp) {
- // %ff can become 6 bytes in utf8
+ /* %ff can become 6 bytes in utf8 */
*storename = malloc(len * 2 + 3);
j = CtdlDecodeQuotedPrintable(
*storename, name,
(*storename)[j] = 0;
}
else if (is_b64) {
- // ff will become one byte..
+ /* ff will become one byte.. */
*storename = malloc(len + 50);
CtdlDecodeBase64(
*storename, name,
StrBufDecodeBase64(Val);
}
- syslog(1, "%s [%s][%s]",
+ syslog(LOG_DEBUG, "%s [%s][%s]",
firsttoken,
ChrPtr(Val),
v->prop[i].value);
{
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
void tmplput_VCARD_ITEM(StrBuf *Target, WCTemplputParams *TP)
{
- HashList *VC = CTX;
+ HashList *VC = CTX(CTX_VCARD);
eVC evc;
void *vStr;
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;
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");
* parse edited vcard from the browser
*/
void submit_vcard(void) {
- wcsession *WCC = WC;
struct vCard *v;
char *serialized_vcard;
char buf[SIZ];
StrBuf *Buf;
+ const StrBuf *ForceRoom;
int i;
if (!havebstr("ok_button")) {
}
if (havebstr("force_room")) {
- if (gotoroom(sbstr("force_room")) != 200) {
- StrBufAppendBufPlain(WCC->ImportantMsg,
- _("Unable to enter the room to save your message"),
- -1, 0);
- StrBufAppendBufPlain(WCC->ImportantMsg,
- HKEY(": "), 0);
- StrBufAppendBuf(WCC->ImportantMsg, sbstr("force_room"), 0);
- StrBufAppendBufPlain(WCC->ImportantMsg,
- HKEY("; "), 0);
-
- StrBufAppendBufPlain(WCC->ImportantMsg,
- _("Aborting."),
- -1, 0);
+ ForceRoom = sbstr("force_room");
+ if (gotoroom(ForceRoom) != 200) {
+ AppendImportantMessage(_("Unable to enter the room to save your message"), -1);
+ AppendImportantMessage(HKEY(": "));
+ AppendImportantMessage(SKEY(ForceRoom));
+ AppendImportantMessage(HKEY("; "));
+ AppendImportantMessage(_("Aborting."), -1);
if (!strcmp(bstr("return_to"), "select_user_to_edit")) {
select_user_to_edit(NULL);
}
}
- sprintf(buf, "ENT0 1|||4||");
- serv_puts(buf);
- serv_getln(buf, sizeof buf);
- if (buf[0] != '4') {
+ Buf = NewStrBuf();
+ serv_write(HKEY("ENT0 1|||4\n"));
+ if (!StrBuf_ServGetln(Buf) && (GetServerStatus(Buf, NULL) != 4))
+ {
edit_vcard();
return;
}
/* Make a vCard structure out of the data supplied in the form */
- Buf = NewStrBuf();
StrBufPrintf(Buf, "begin:vcard\r\n%s\r\nend:vcard\r\n",
bstr("extrafields")
);
v = VCardLoad(Buf); /* Start with the extra fields */
- FreeStrBuf(&Buf);
if (v == NULL) {
AppendImportantMessage(_("An error has occurred."), -1);
edit_vcard();
+ FreeStrBuf(&Buf);
return;
}
if (serialized_vcard == NULL) {
AppendImportantMessage(_("An error has occurred."), -1);
edit_vcard();
+ FreeStrBuf(&Buf);
return;
}
- serv_puts("Content-type: text/x-vcard; charset=UTF-8");
- serv_puts("");
+ serv_write(HKEY("Content-type: text/x-vcard; charset=UTF-8\n"));
+ serv_write(HKEY("\n"));
serv_printf("%s\r\n", serialized_vcard);
- serv_puts("000");
+ serv_write(HKEY("000\n"));
free(serialized_vcard);
if (!strcmp(bstr("return_to"), "select_user_to_edit")) {
else {
readloop(readnew, eUseDefault);
}
+ FreeStrBuf(&Buf);
}
void **ViewSpecific,
long oper,
char *cmd,
- long len)
+ long len,
+ char *filter,
+ long flen)
{
vcardview_struct *VS;
InitModule_VCARD
(void)
{
+ RegisterCTX(CTX_VCARD);
RegisterReadLoopHandlerset(
VIEW_ADDRESSBOOK,
vcard_GetParamsGetServerCall,
NULL,
+ NULL,
NULL,
vcard_LoadMsgFromServer,
vcard_RenderView_or_Tail,