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("MSG0 %ld|0", Msg->msgnum); /** unfortunately we need the mime info now */
serv_getln(buf, sizeof buf);
if (buf[0] != '1') return;
* 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;
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_ServGetln(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 */
msgnum = lbstr("msgnum");
partnum = bstr("partnum");
- do_edit_vcard(msgnum, partnum, "", NULL);
+ do_edit_vcard(msgnum, partnum, NULL, NULL, "", NULL);
}
* 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);
+ }
+ 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;
free(serialized_vcard);
if (!strcmp(bstr("return_to"), "select_user_to_edit")) {
- select_user_to_edit(NULL, NULL);
+ select_user_to_edit(NULL);
}
else if (!strcmp(bstr("return_to"), "do_welcome")) {
do_welcome();