* [Edbrowse-dev] [PATCH] Load address book, and redirect files properly.
@ 2011-04-09 12:10 Karl Dahlke
2011-04-09 13:56 ` Chris Brannon
0 siblings, 1 reply; 2+ messages in thread
From: Karl Dahlke @ 2011-04-09 12:10 UTC (permalink / raw)
To: edbrowse-dev
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
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [Edbrowse-dev] [PATCH] Load address book, and redirect files properly.
2011-04-09 12:10 [Edbrowse-dev] [PATCH] Load address book, and redirect files properly Karl Dahlke
@ 2011-04-09 13:56 ` Chris Brannon
0 siblings, 0 replies; 2+ messages in thread
From: Chris Brannon @ 2011-04-09 13:56 UTC (permalink / raw)
To: edbrowse-dev
Applied. Thanks for the patch!
-- Chris
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2011-04-09 13:56 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-04-09 12:10 [Edbrowse-dev] [PATCH] Load address book, and redirect files properly Karl Dahlke
2011-04-09 13:56 ` Chris Brannon
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).