From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from qmta12.emeryville.ca.mail.comcast.net (qmta12.emeryville.ca.mail.comcast.net [76.96.27.227]) by che.dreamhost.com (Postfix) with ESMTP id 2E921FE98 for ; Sat, 9 Apr 2011 05:10:44 -0700 (PDT) Received: from omta15.emeryville.ca.mail.comcast.net ([76.96.30.71]) by qmta12.emeryville.ca.mail.comcast.net with comcast id VQ9f1g0011Y3wxoACQAZ9h; Sat, 09 Apr 2011 12:10:33 +0000 Received: from eklbox.hsd1.mi.comcast.net. ([71.238.29.179]) by omta15.emeryville.ca.mail.comcast.net with comcast id VQAX1g00W3rsRL78bQAYUf; Sat, 09 Apr 2011 12:10:32 +0000 From: Karl Dahlke To: edbrowse-dev@lists.the-brannons.com Date: Sat, 9 Apr 2011 08:10:31 -0400 Message-Id: <1302351031-17409-1-git-send-email-eklhad@comcast.net> X-Mailer: git-send-email 1.7.4 Subject: [Edbrowse-dev] [PATCH] Load address book, and redirect files properly. 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: Sat, 09 Apr 2011 12:10:45 -0000 I forgot to load the address book, so filtering based on the people you know wasn't going to work. Also fixed a bug regarding redirection. Finally, edbrowse now prints one line of output, a comprehensive summary of what went on. How many messages fetched, over one or many accounts, or how many messages to be read if -m is included. One summary statement, and then off you go reading your mail. Enjoy. --- src/eb.p | 2 +- src/fetchmail.c | 34 ++++++++++++++++------------------ src/main.c | 11 +++++++++-- src/messages.c | 6 ------ src/messages.h | 2 -- 5 files changed, 26 insertions(+), 29 deletions(-) diff --git a/src/eb.p b/src/eb.p index 39d8d74..4a19bf0 100644 --- a/src/eb.p +++ b/src/eb.p @@ -109,7 +109,7 @@ bool sendMailCurrent(int sm_account, bool dosig) ; /* sourcefile=fetchmail.c */ void loadBlacklist(void) ; bool onBlacklist1(IP32bit tip) ; -void fetchMail(int account) ; +int fetchMail(int account) ; void scanMail(void) ; bool emailTest(void) ; void unpackUploadedFile(const char *post, const char *boundary, char **postb, int *postb_l) ; diff --git a/src/fetchmail.c b/src/fetchmail.c index a0fe001..63c8d63 100644 --- a/src/fetchmail.c +++ b/src/fetchmail.c @@ -310,7 +310,8 @@ static int mailstring_l; static char *mailu8; static int mailu8_l; -void +/* Returns number of messages fetched */ +int fetchMail(int account) { const struct MACCOUNT *a = accounts + account - 1; @@ -318,6 +319,7 @@ fetchMail(int account) const char *pass = a->password; const char *host = a->inurl; int nmsgs, m, j, k; + int nfetch = 0; /* number of messages actually fetched */ if(!mailDir) i_printfExit(MSG_NoMailDir); @@ -339,7 +341,7 @@ fetchMail(int account) if(memcmp(serverLine, "+OK ", 4)) { i_printf(MSG_BadPopIntro, serverLine); mailClose(); - return; + return nfetch; } sprintf(serverLine, "user %s%s", login, eol); mailPutGetError(serverLine); @@ -350,7 +352,7 @@ fetchMail(int account) if(memcmp(serverLine, "+OK", 3)) { i_printf(MSG_PopNotComplete, serverLine); mailClose(); - return; + return nfetch; } /* How many mail messages? */ @@ -358,15 +360,13 @@ fetchMail(int account) if(memcmp(serverLine, "+OK ", 4)) { i_printf(MSG_NoStatusMailBox, serverLine); mailClose(); - return; + return nfetch; } nmsgs = atoi(serverLine + 4); if(!nmsgs) { - i_puts(MSG_NoMail); mailClose(); - return; + return nfetch; } - i_printf(MSG_MessagesX, nmsgs); for(m = 1; m <= nmsgs; ++m) { char retrbuf[5000]; @@ -389,7 +389,7 @@ fetchMail(int account) i_printf(MSG_ErrorReadMess, errno); mailClose(); nzFree(mailstring); - return; + return nfetch; } if(retr1) { @@ -400,7 +400,7 @@ fetchMail(int account) i_printf(MSG_ErrorFetchMess, m, retrbuf); mailClose(); nzFree(mailstring); - return; + return nfetch; } j = 3; /* skip past ok */ @@ -457,6 +457,7 @@ fetchMail(int account) if(write(umfd, mailstring, mailstring_l) < mailstring_l) i_printfExit(MSG_NoWrite, umf); close(umfd); + ++nfetch; nzFree(mailstring); mailstring = 0; @@ -470,6 +471,7 @@ fetchMail(int account) } /* loop over mail messages */ mailClose(); + return nfetch; } /* fetchMail */ void @@ -495,10 +497,12 @@ scanMail(void) unreadStats(); nmsgs = unreadCount; if(!nmsgs) { - i_puts(MSG_NoUnread); + i_puts(MSG_NoMail); exit(0); } - i_printf(MSG_UnreadX, nmsgs); + i_printf(MSG_MessagesX, nmsgs); + + loadAddressBook(); for(m = 1; m <= nmsgs; ++m) { const char *redirect = 0; /* send mail elsewhere */ @@ -552,6 +556,7 @@ scanMail(void) } if(redirect) { + delflag = true; key = 'w'; if(*redirect == '-') ++redirect, key = 'u'; @@ -571,13 +576,6 @@ scanMail(void) printf("%s", lastMailInfo->reply); } nl(); - } else if(!nattach && /* drop empty mail message */ - cw->dol - - (strlen(lastMailInfo->subject) != 0) - - (strlen(lastMailInfo->from) != 0) - - (strlen(lastMailInfo->reply) != 0) <= 1) { - redirect = "x"; - i_puts(MSG_Empty); } /* display the next page of mail and get a command from the keyboard */ diff --git a/src/main.c b/src/main.c index 407ec48..cfd0797 100644 --- a/src/main.c +++ b/src/main.c @@ -1165,8 +1165,9 @@ main(int argc, char **argv) if(!argc) { /* This is fetch / read mode */ if(dofetch) { + int nfetch = 0; if(account) { - fetchMail(account); + nfetch = fetchMail(account); } else { int i, j; for(i = 1; i <= maxAccount; ++i) { @@ -1181,9 +1182,15 @@ main(int argc, char **argv) accounts[j - 1].login)) break; if(j == i) - fetchMail(i); + nfetch += fetchMail(i); } } + if(!domail) { + if(nfetch) + i_printf(MSG_MessagesX, nfetch); + else + i_puts(MSG_NoMail); + } } if(domail) { diff --git a/src/messages.c b/src/messages.c index 6378f0c..b7c6cc3 100644 --- a/src/messages.c +++ b/src/messages.c @@ -678,8 +678,6 @@ static const char *englishMessages[] = { "SSL connect error in libcurl: %s", "input tty", "input readline()", - "nothing pending", - "%d pending\n", }; /* Translation by Erwin Bliesenick: erwinb@no-log.org */ @@ -1339,8 +1337,6 @@ static const char *frenchMessages[] = { 0, 0, 0, - 0, - 0, }; /* Translation by Cleverson: clever92000@yahoo.com.br */ @@ -2000,8 +1996,6 @@ static const char *brazilianPortugueseMessages[] = { 0, 0, 0, - 0, - 0, }; /* Translation by Jan Mura: jan.mura@volny.cz */ diff --git a/src/messages.h b/src/messages.h index 82aaeeb..bec55d7 100644 --- a/src/messages.h +++ b/src/messages.h @@ -678,6 +678,4 @@ enum { MSG_SSLConnectError, MSG_InputTTY, MSG_InputReadLine, - MSG_NoUnread, - MSG_UnreadX, }; -- 1.7.4