From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from qmta07.emeryville.ca.mail.comcast.net (qmta07.emeryville.ca.mail.comcast.net [76.96.30.64]) by che.dreamhost.com (Postfix) with ESMTP id D2AD2FEE7 for ; Sun, 3 Apr 2011 15:16:54 -0700 (PDT) Received: from omta18.emeryville.ca.mail.comcast.net ([76.96.30.74]) by qmta07.emeryville.ca.mail.comcast.net with comcast id T9dY1g0071bwxycA7A1yRi; Sun, 03 Apr 2011 22:01:58 +0000 Received: from eklbox.hsd1.mi.comcast.net. ([71.238.29.179]) by omta18.emeryville.ca.mail.comcast.net with comcast id TA1w1g0103rsRL78eA1xcy; Sun, 03 Apr 2011 22:01:58 +0000 From: Karl Dahlke To: edbrowse-dev@lists.the-brannons.com Date: Sun, 3 Apr 2011 18:01:58 -0400 Message-Id: <1301868118-29404-1-git-send-email-eklhad@comcast.net> X-Mailer: git-send-email 1.7.4 Subject: [Edbrowse-dev] [PATCH] A couple new directories for future mail features. X-BeenThere: edbrowse-dev@lists.the-brannons.com X-Mailman-Version: 2.1.14 Precedence: list List-Id: Edbrowse Development List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 03 Apr 2011 22:16:55 -0000 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