* evaluate result of gotoroom; this needs to be done elsewhere too.
* fix roomname thing in useredit
void become_logged_in(const StrBuf *user, const StrBuf *pass, StrBuf *serv_response)
{
wcsession *WCC = WC;
- char buf[SIZ];
+ StrBuf *Buf;
StrBuf *FloorDiv;
StrBuf *Language = NULL;
- WC->logged_in = 1;
+ WCC->logged_in = 1;
if (WCC->wc_fullname == NULL)
WCC->wc_fullname = NewStrBufPlain(NULL, StrLength(serv_response));
load_preferences();
+ Buf = NewStrBuf();
serv_puts("CHEK");
- serv_getln(buf, sizeof buf);
- if (buf[0] == '2') {
- WC->new_mail = extract_int(&buf[4], 0);
- WC->need_regi = extract_int(&buf[4], 1);
- WC->need_vali = extract_int(&buf[4], 2);
- extract_token(WC->cs_inet_email, &buf[4], 3, '|', sizeof WC->cs_inet_email);
+ StrBuf_ServGetln(Buf);
+ if (GetServerStatus(Buf, NULL) == 2) {
+ const char *pch;
+
+ pch = ChrPtr(Buf) + 4;
+ WCC->new_mail = StrBufExtractNext_long(Buf, &pch, '|');
+ WCC->need_regi = StrBufExtractNext_long(Buf, &pch, '|');
+ WCC->need_vali = StrBufExtractNext_long(Buf, &pch, '|');
+ if (WCC->cs_inet_email == NULL)
+ WCC->cs_inet_email = NewStrBuf();
+ StrBufExtract_NextToken(WCC->cs_inet_email, Buf, &pch, '|');
}
if (havebstr("language"))
set_preference("language", NewStrBufDup(SBSTR("language")), 1);
}
}
get_preference("floordiv_expanded", &FloorDiv);
- WC->floordiv_expanded = FloorDiv;
+ WCC->floordiv_expanded = FloorDiv;
+ FreeStrBuf(&Buf);
}
FreeStrBuf(&((*sessions_to_kill)->wc_roomname));
FreeStrBuf(&((*sessions_to_kill)->httpauth_user));
FreeStrBuf(&((*sessions_to_kill)->httpauth_pass));
+ FreeStrBuf(&((*sessions_to_kill)->ImportantMsg));
+ FreeStrBuf(&((*sessions_to_kill)->cs_inet_email));
free((*sessions_to_kill));
(*sessions_to_kill) = NULL;
}
pthread_mutex_lock(&TheSession->SessionMutex); /* bind */
pthread_setspecific(MyConKey, (void *)TheSession);
+ if (TheSession->ImportantMsg == NULL)
+ TheSession->ImportantMsg = NewStrBuf();
TheSession->urlstrings = NewHash(1,NULL);
TheSession->vars = NewHash(1,NULL);
TheSession->http_sock = *sock;
*/
if (icalcomponent_get_first_property(vevent, ICAL_ORGANIZER_PROPERTY)
== NULL) {
- sprintf(organizer_string, "MAILTO:%s", WC->cs_inet_email);
+ sprintf(organizer_string, "MAILTO:%s", ChrPtr(WC->cs_inet_email));
icalcomponent_add_property(vevent,
icalproperty_new_organizer(organizer_string)
);
if (GetServerStatus(Buf, &err) != 2) {
serv_puts("GOTO _BASEROOM_");
StrBuf_ServGetln(Buf);
- if (GetServerStatus(Buf, &err) != 2) {
+ /*
+ * well, we know that this is the fallback case,
+ * but we're interested that the first command
+ * didn't work out in first place.
+ */
+ if (GetServerStatus(Buf, NULL) != 2) {
FreeStrBuf(&Buf);
return err;
}
void display_edit_address_book_entry(const char *username, long usernum) {
message_summary *VCMsg = NULL;
wc_mime_attachment *VCAtt = NULL;
- char roomname[SIZ];
+ StrBuf *roomname;
StrBuf *Buf;
char error_message[SIZ];
long vcard_msgnum = (-1L);
/** Locate the user's config room, creating it if necessary */
Buf = NewStrBuf();
- serv_printf("GOTO %010ld.%s||1", usernum, USERCONFIGROOM);
+ roomname = NewStrBuf();
+ StrBufPrintf(roomname, "%010ld.%s", usernum, USERCONFIGROOM);
+ serv_printf("GOTO %s||1", ChrPtr(roomname));
StrBuf_ServGetlnBuffered(Buf);
if (GetServerStatus(Buf, NULL) != 2) {
- serv_printf("CRE8 1|%010ld.%s|5|||1|", usernum, USERCONFIGROOM);
+ serv_printf("CRE8 1|%s|5|||1|", ChrPtr(roomname));
StrBuf_ServGetlnBuffered(Buf);
GetServerStatus(Buf, NULL);
- serv_printf("GOTO %010ld.%s||1", usernum, USERCONFIGROOM);
+ serv_printf("GOTO %s||1", ChrPtr(roomname));
StrBuf_ServGetlnBuffered(Buf);
if (GetServerStatus(Buf, NULL) != 2) {
StrBufCutLeft(Buf, 4);
"%s<br /><br />\n", ChrPtr(Buf));
select_user_to_edit(error_message, username);
FreeStrBuf(&Buf);
+ FreeStrBuf(&roomname);
return;
}
}
_("An error occurred while trying to create or edit this address book entry.")
);
select_user_to_edit(error_message, username);
+ FreeStrBuf(&roomname);
return;
}
VCMsg,
VCAtt,
"select_user_to_edit",
- roomname);
+ ChrPtr(roomname));
+ FreeStrBuf(&roomname);
}
memset(&summ, 0, sizeof(summ));
//////safestrncpy(summ.subj, "(no subject)", sizeof summ.subj);
- sprintf(buf, "MSG0 %ld|0", Msg->msgnum); /** unfortunately we need the mime info now */
- serv_puts(buf);
+ serv_printf(buf, "MSG0 %ld|0", Msg->msgnum); /** unfortunately we need the mime info now */
serv_getln(buf, sizeof buf);
if (buf[0] != '1') return;
* parse edited vcard from the browser
*/
void submit_vcard(void) {
+ wcsession *WCC = WC;
struct vCard *v;
char *serialized_vcard;
char buf[SIZ];
}
if (havebstr("force_room")) {
- gotoroom(sbstr("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);
+ /// todo: call the master dispatcher again...
+ if (!strcmp(bstr("return_to"), "select_user_to_edit")) {
+ select_user_to_edit(NULL, NULL);
+ }
+ else if (!strcmp(bstr("return_to"), "do_welcome")) {
+ do_welcome();
+ }
+ else {
+ readloop(readnew);
+ }
+ return;
+ }
}
sprintf(buf, "ENT0 1|||4||");
v = VCardLoad(Buf); /** Start with the extra fields */
FreeStrBuf(&Buf);
if (v == NULL) {
- safestrncpy(WC->ImportantMessage,
+ safestrncpy(WCC->ImportantMessage,
_("An error has occurred."),
- sizeof WC->ImportantMessage
+ sizeof WCC->ImportantMessage
);
edit_vcard();
return;
serialized_vcard = vcard_serialize(v);
vcard_free(v);
if (serialized_vcard == NULL) {
- safestrncpy(WC->ImportantMessage,
+ safestrncpy(WCC->ImportantMessage,
_("An error has occurred."),
- sizeof WC->ImportantMessage
+ sizeof WCC->ImportantMessage
);
edit_vcard();
return;
do_template("head", NULL);
/* check for ImportantMessages (these display in a div overlaying the main screen) */
- if (!IsEmptyStr(WC->ImportantMessage)) {
+ if (!IsEmptyStr(WCC->ImportantMessage)) {
wprintf("<div id=\"important_message\">\n"
"<span class=\"imsg\">");
- escputs(WC->ImportantMessage);
+ StrEscAppend(WCC->WBuf, NULL, WCC->ImportantMessage, 0, 0);
wprintf("</span><br />\n"
"</div>\n"
);
- StrBufAppendPrintf(WCC->trailing_javascript,
- "setTimeout('hide_imsg_popup()', 5000); \n"
+ StrBufAppendBufPlain(WCC->trailing_javascript,
+ HKEY("setTimeout('hide_imsg_popup()', 5000); \n"),
+ 0
);
WCC->ImportantMessage[0] = 0;
}
-
+ else if (StrLength(WCC->ImportantMsg) > 0) {
+ wprintf("<div id=\"important_message\">\n"
+ "<span class=\"imsg\">");
+ StrEscAppend(WCC->WBuf, WCC->ImportantMsg, NULL, 0, 0);
+ wprintf("</span><br />\n"
+ "</div>\n"
+ );
+ StrBufAppendBufPlain(WCC->trailing_javascript,
+ HKEY("setTimeout('hide_imsg_popup()', 5000); \n"),
+ 0
+ );
+ FlushStrBuf(WCC->ImportantMsg);
+ }
if ( (WCC->logged_in) && (!unset_cookies) ) {
- //DoTemplate(HKEY("iconbar"), NULL, &NoCtx);
+ /*DoTemplate(HKEY("iconbar"), NULL, &NoCtx);*/
page_popup();
}
{
wcsession *WCC = WC;
if (WCC != NULL)
- return (!IsEmptyStr(WCC->ImportantMessage));
+ return ((!IsEmptyStr(WCC->ImportantMessage)) ||
+ (StrLength(WCC->ImportantMsg) > 0));
else
return 0;
}
wcsession *WCC = WC;
if (WCC != NULL) {
-/*
- StrBufAppendTemplate(Target, nArgs, Tokens, Context, ContextType,
- WCC->ImportantMessage, 0);
-*/
- StrEscAppend(Target, NULL, WCC->ImportantMessage, 0, 0);
- WCC->ImportantMessage[0] = '\0';
+ if (!IsEmptyStr(WCC->ImportantMessage)) {
+ StrEscAppend(Target, NULL, WCC->ImportantMessage, 0, 0);
+ WCC->ImportantMessage[0] = '\0';
+ }
+ else if (StrLength(WCC->ImportantMsg) > 0) {
+ StrEscAppend(Target, WCC->ImportantMsg, NULL, 0, 0);
+ FlushStrBuf(WCC->ImportantMsg);
+ }
}
}
StrBuf *trailing_javascript; /**< extra javascript to be appended to page */
char ImportantMessage[SIZ]; /**< ??? todo */
+ StrBuf *ImportantMsg;
/* accounting */
StrBuf *wc_username; /**< login name of current user */
int need_vali; /**< New users require validation. */
/* Preferences */
- char cs_inet_email[256]; /**< User's preferred Internet addr. */
+ StrBuf *cs_inet_email; /**< User's preferred Internet addr. */
char reply_to[512]; /**< reply-to address */
HashList *hash_prefs; /**< WebCit preferences for this user */
StrBuf *DefaultCharset; /**< Charset the user preferes */