edbrowse-dev - development list for edbrowse
 help / color / mirror / Atom feed
* [Edbrowse-dev] [PATCH] A couple new directories for future mail features.
@ 2011-04-03 22:01 Karl Dahlke
  0 siblings, 0 replies; only message in thread
From: Karl Dahlke @ 2011-04-03 22:01 UTC (permalink / raw)
  To: edbrowse-dev

I'd rather do this in small steps.
Not one big patch that changes everything about how mail works.
This one just sets up a couple directories for unread mail and for
unformatted mail that you probably won't need, but if you do it's there.
---
 src/eb.h   |    4 ++++
 src/main.c |   24 ++++++++++++++++++++++++
 2 files changed, 28 insertions(+), 0 deletions(-)

diff --git a/src/eb.h b/src/eb.h
index 3dd14d3..5b28cd5 100644
--- a/src/eb.h
+++ b/src/eb.h
@@ -224,6 +224,10 @@ extern void *jdloc;		/* javascript document.location */
 extern int maxAccount;		/* how many email accounts specified */
 extern int localAccount;	/* this is the smtp server for outgoing mail */
 extern char *mailDir;		/* move to this directory when fetching mail */
+extern char *mailUnread; /* place to hold fetched but unread mail */
+/* Keep a copy of unformatted mail that you probably won't need again,
+ * but you never know. Should probably live somewhere under .Trash */
+extern char *mailStash;
 extern struct MACCOUNT accounts[];	/* all the email accounts */
 extern int maxMime;		/* how many mime types specified */
 extern struct MIMETYPE mimetypes[];
diff --git a/src/main.c b/src/main.c
index e14c7f7..40215ee 100644
--- a/src/main.c
+++ b/src/main.c
@@ -42,6 +42,7 @@ uchar dirWrite, endMarks;
 int context = 1;
 uchar linePending[MAXTTYLINE];
 char *changeFileName, *mailDir;
+char *mailUnread, *mailStash;
 char *addressFile, *ipbFile;
 char *home, *recycleBin, *configFile, *sigFile, *sigFileEnd;
 char *cookieFile, *spamCan;
@@ -543,6 +544,14 @@ readConfigFile(void)
 	    mailDir = v;
 	    if(fileTypeByName(v, false) != 'd')
 		i_printfExit(MSG_ERBC_NotDir, v);
+	    mailUnread = allocMem(strlen(v) + 12);
+	    sprintf(mailUnread, "%s/unread", v);
+/* We need the unread directory, else we can't fetch mail. */
+/* Create it if it isn't there. */
+	    if(fileTypeByName(mailUnread, false) != 'd') {
+		if(mkdir(mailUnread, 0700))
+		    i_printfExit(MSG_ERBC_NotDir, mailUnread);
+	    }
 	    continue;
 
 	case 20:
@@ -1012,6 +1021,7 @@ main(int argc, char **argv)
 
     recycleBin = allocMem(strlen(home) + 8);
     sprintf(recycleBin, "%s/.Trash", home);
+
     edbrowseTempFile = allocMem(strlen(recycleBin) + 8 + 6);
 /* The extra 6 is for the suffix */
     sprintf(edbrowseTempFile, "%s/eb_tmp", recycleBin);
@@ -1019,13 +1029,27 @@ main(int argc, char **argv)
     sprintf(edbrowseTempPDF, "%s/eb_pdf", recycleBin);
     edbrowseTempHTML = allocMem(strlen(recycleBin) + 13);
     sprintf(edbrowseTempHTML, "%s/eb_pdf.html", recycleBin);
+
     if(fileTypeByName(recycleBin, false) != 'd') {
 	if(mkdir(recycleBin, 0700)) {
+/* Don't want to abort here; we might be on a readonly filesystem.
+ * Don't have a Trash directory and can't creat one; yet we should move on. */
 	    free(recycleBin);
 	    recycleBin = 0;
 	}
     }
 
+    if(recycleBin) {
+	mailStash = allocMem(strlen(recycleBin) + 12);
+	sprintf(mailStash, "%s/rawmail", recycleBin);
+	if(fileTypeByName(mailStash, false) != 'd') {
+	    if(mkdir(mailStash, 0700)) {
+		free(mailStash);
+		mailStash = 0;
+	    }
+	}
+    }
+
     sigFile = allocMem(strlen(home) + 20);
     sprintf(sigFile, "%s/.signature", home);
     sigFileEnd = sigFile + strlen(sigFile);
-- 
1.7.4


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2011-04-03 22:16 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-04-03 22:01 [Edbrowse-dev] [PATCH] A couple new directories for future mail features Karl Dahlke

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).