char buf[1024];
StrBuf *encoded_subject = NULL;
static long dont_post = (-1L);
- wc_mime_attachment *att;
int is_anonymous = 0;
const StrBuf *display_name = NULL;
wcsession *WCC = WC;
}
}
- if (WCC->upload_length > 0) {
- const char *pch;
- int n;
- const char *newn;
- long newnlen;
- void *v;
-
- /* There's an attachment. Save it to this struct... */
- lprintf(9, "Client is uploading %d bytes\n", WCC->upload_length);
- att = malloc(sizeof(wc_mime_attachment));
- memset(att, 0, sizeof(wc_mime_attachment ));
- att->length = WCC->upload_length;
- att->ContentType = NewStrBufPlain(WCC->upload_content_type, -1);
- att->FileName = NewStrBufDup(WCC->upload_filename);
-
- if (WCC->attachments == NULL) {
- WCC->attachments = NewHash(1, Flathash);
- }
-
- /* And add it to the list. */
- n = 0;
- if ((GetCount(WCC->attachments) > 0) &&
- GetHashAt(WCC->attachments,
- GetCount(WCC->attachments) -1,
- &newnlen, &newn, &v))
- n = *((int*) newn) + 1;
- Put(WCC->attachments, IKEY(n), att, DestroyMime);
-
- /*
- * Mozilla sends a simple filename, which is what we want,
- * but Satan's Browser sends an entire pathname. Reduce
- * the path to just a filename if we need to.
- */
- pch = strrchr(ChrPtr(att->FileName), '/');
- if (pch != NULL) {
- StrBufCutLeft(att->FileName, pch - ChrPtr(att->FileName) + 1);
- }
- pch = strrchr(ChrPtr(att->FileName), '\\');
- if (pch != NULL) {
- StrBufCutLeft(att->FileName, pch - ChrPtr(att->FileName) + 1);
- }
-
- /*
- * Transfer control of this memory from the upload struct
- * to the attachment struct.
- */
- att->Data = WCC->upload;
- WCC->upload = NULL;
- WCC->upload_length = 0;
- display_enter();
- return;
- }
-
if (!strcasecmp(bstr("submit_action"), "cancel")) {
sprintf(WCC->ImportantMessage,
_("Cancelled. Message was not posted."));
- } else if (havebstr("attach_button")) {
- display_enter();
- return;
} else if (lbstr("postseq") == dont_post) {
sprintf(WCC->ImportantMessage,
_("Automatically cancelled because you have already "
"saved this message."));
- } else if (havebstr("remove_attach_button")) {
- /* now thats st00pit. need to find it by name. */
- void *vAtt;
- StrBuf *WhichAttachment;
- HashPos *at;
- long len;
- const char *key;
-
- WhichAttachment = NewStrBufDup(sbstr("which_attachment"));
- StrBufUnescape(WhichAttachment, 0);
- at = GetNewHashPos(WCC->attachments, 0);
- do {
- GetHashPos(WCC->attachments, at, &len, &key, &vAtt);
-
- att = (wc_mime_attachment*) vAtt;
- if ((att != NULL) &&
- (strcmp(ChrPtr(WhichAttachment),
- ChrPtr(att->FileName) ) == 0))
- {
- DeleteEntryFromHash(WCC->attachments, at);
- break;
- }
- }
- while (NextHashPos(WCC->attachments, at));
- FreeStrBuf(&WhichAttachment);
- display_enter();
- return;
} else {
const char CMD[] = "ENT0 1|%s|%d|4|%s|%s||%s|%s|%s|%s|%s";
StrBuf *Recp = NULL;
return;
}
}
+ FreeStrBuf(&Recp);
FreeStrBuf(&Buf);
FreeStrBuf(&Cc);
FreeStrBuf(&Bcc);
}
+/*
+ * Client is uploading an attachment
+ */
+void upload_attachment(void) {
+ wcsession *WCC = WC;
+ const char *pch;
+ int n;
+ const char *newn;
+ long newnlen;
+ void *v;
+ wc_mime_attachment *att;
+
+ lprintf(9, "upload_attachment()\n");
+ wc_printf("upload_attachment()<br>\n");
+
+ if (WCC->upload_length <= 0) {
+ lprintf(9, "ERROR no attachment was uploaded\n");
+ wc_printf("ERROR no attachment was uploaded<br>\n");
+ return;
+ }
+
+ lprintf(9, "Client is uploading %d bytes\n", WCC->upload_length);
+ wc_printf("Client is uploading %d bytes<br>\n", WCC->upload_length);
+ att = malloc(sizeof(wc_mime_attachment));
+ memset(att, 0, sizeof(wc_mime_attachment ));
+ att->length = WCC->upload_length;
+ att->ContentType = NewStrBufPlain(WCC->upload_content_type, -1);
+ att->FileName = NewStrBufDup(WCC->upload_filename);
+
+ if (WCC->attachments == NULL) {
+ WCC->attachments = NewHash(1, Flathash);
+ }
+
+ /* And add it to the list. */
+ n = 0;
+ if ((GetCount(WCC->attachments) > 0) &&
+ GetHashAt(WCC->attachments,
+ GetCount(WCC->attachments) -1,
+ &newnlen, &newn, &v))
+ n = *((int*) newn) + 1;
+ Put(WCC->attachments, IKEY(n), att, DestroyMime);
+
+ /*
+ * Mozilla sends a simple filename, which is what we want,
+ * but Satan's Browser sends an entire pathname. Reduce
+ * the path to just a filename if we need to.
+ */
+ pch = strrchr(ChrPtr(att->FileName), '/');
+ if (pch != NULL) {
+ StrBufCutLeft(att->FileName, pch - ChrPtr(att->FileName) + 1);
+ }
+ pch = strrchr(ChrPtr(att->FileName), '\\');
+ if (pch != NULL) {
+ StrBufCutLeft(att->FileName, pch - ChrPtr(att->FileName) + 1);
+ }
+
+ /*
+ * Transfer control of this memory from the upload struct
+ * to the attachment struct.
+ */
+ att->Data = WCC->upload;
+ WCC->upload = NULL;
+ WCC->upload_length = 0;
+}
+
/*
}
-
-
void view_mimepart(void) {
mimepart(0);
}
FreeStrBuf(&partnum);
}
+
+
+void show_num_attachments(void) {
+ wc_printf("%d", GetCount(WC->attachments));
+}
+
+
void h_readnew(void) { readloop(readnew, eUseDefault);}
void h_readold(void) { readloop(readold, eUseDefault);}
void h_readfwd(void) { readloop(readfwd, eUseDefault);}
WebcitAddUrlHandler(HKEY("mimepart_download"), "", 0, download_mimepart, NEED_URL);
WebcitAddUrlHandler(HKEY("postpart"), "", 0, view_postpart, NEED_URL|PROHIBIT_STARTPAGE);
WebcitAddUrlHandler(HKEY("postpart_download"), "", 0, download_postpart, NEED_URL|PROHIBIT_STARTPAGE);
+ WebcitAddUrlHandler(HKEY("upload_attachment"), "", 0, upload_attachment, AJAX);
+ WebcitAddUrlHandler(HKEY("show_num_attachments"), "", 0, show_num_attachments, AJAX);
/* json */
WebcitAddUrlHandler(HKEY("roommsgs"), "", 0, jsonMessageList,0);