From a773f0786e2b7884703bdc4067bef08526881f57 Mon Sep 17 00:00:00 2001 From: Art Cancro Date: Sun, 12 Dec 2010 19:11:39 -0500 Subject: [PATCH] Wrote the ajax call for remove_attachment(), todo: js binding --- webcit/messages.c | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) diff --git a/webcit/messages.c b/webcit/messages.c index 2cda9c6b0..6e30c98d3 100644 --- a/webcit/messages.c +++ b/webcit/messages.c @@ -1269,6 +1269,41 @@ void upload_attachment(void) { } +/* + * Remove an attachment from the message currently being composed. + * + * Currently we identify the attachment to be removed by its filename. + * There is probably a better way to do this. + */ +void remove_attachment(void) { + wcsession *WCC = WC; + wc_mime_attachment *att; + 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); + wc_printf("remove_attachment() completed\n"); +} + /* * display the message entry screen @@ -1805,6 +1840,7 @@ InitModule_MSG 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("remove_attachment"), "", 0, remove_attachment, AJAX); WebcitAddUrlHandler(HKEY("show_num_attachments"), "", 0, show_num_attachments, AJAX); /* json */ -- 2.30.2