balsa r8015 - in trunk: . libbalsa libbalsa/imap po src
- From: pawels svn gnome org
- To: svn-commits-list gnome org
- Subject: balsa r8015 - in trunk: . libbalsa libbalsa/imap po src
- Date: Sun, 14 Dec 2008 20:21:17 +0000 (UTC)
Author: pawels
Date: Sun Dec 14 20:21:17 2008
New Revision: 8015
URL: http://svn.gnome.org/viewvc/balsa?rev=8015&view=rev
Log:
* src/main-window.c: Add ability to display recent messages only.
* libbalsa/imap-server.c: give more details in error messages.
* libbalsa/imap/imap-handle.c: ditto.
* libbalsa/imap/imap-commands.[ch]: Add "peek" argument to
imap_mbox_handle_fetch_rfc822().
Modified:
trunk/ChangeLog
trunk/libbalsa/imap-server.c
trunk/libbalsa/imap/imap-commands.c
trunk/libbalsa/imap/imap-commands.h
trunk/libbalsa/imap/imap-handle.c
trunk/libbalsa/imap/imap_tst.c
trunk/po/ChangeLog
trunk/po/pl.po
trunk/src/main-window.c
Modified: trunk/libbalsa/imap-server.c
==============================================================================
--- trunk/libbalsa/imap-server.c (original)
+++ trunk/libbalsa/imap-server.c Sun Dec 14 20:21:17 2008
@@ -576,7 +576,7 @@
case IMAP_CONNECT_FAILED:
g_set_error(err, LIBBALSA_MAILBOX_ERROR,
LIBBALSA_MAILBOX_NETWORK_ERROR,
- _("Cannot connect to the server"));
+ _("Cannot connect to %s"), server->host);
break;
case IMAP_AUTH_CANCELLED:
g_set_error(err, LIBBALSA_MAILBOX_ERROR,
Modified: trunk/libbalsa/imap/imap-commands.c
==============================================================================
--- trunk/libbalsa/imap/imap-commands.c (original)
+++ trunk/libbalsa/imap/imap-commands.c Sun Dec 14 20:21:17 2008
@@ -1040,6 +1040,10 @@
struct FetchBodyPassthroughData {
ImapFetchBodyCb cb;
void *arg;
+ char *body;
+ size_t body_length;
+ unsigned seqno;
+ unsigned pipeline_error;
};
static void
@@ -1049,13 +1053,54 @@
size_t buflen, void* arg)
{
struct FetchBodyPassthroughData* data = (struct FetchBodyPassthroughData*)arg;
-
- data->cb(seqno, buf, buflen, data->arg);
+ switch(body_type) {
+ case IMAP_BODY_TYPE_RFC822:
+ data->cb(seqno, buf, buflen, data->arg);
+ break;
+ case IMAP_BODY_TYPE_HEADER:
+ if(data->seqno == 0) {
+ data->seqno = seqno;
+ data->cb(seqno, buf, buflen, data->arg);
+ } else {
+ if(data->seqno == seqno) {
+ data->cb(seqno, buf, buflen, data->arg);
+ data->cb(seqno, data->body, data->body_length, data->arg);
+ g_free(data->body);
+ data->body = NULL;
+ data->seqno = 0;
+ } else {
+ /* This server sends data in a strange order that makes
+ efficient pipeline processing impossible. Just signal an
+ error. */
+ data->pipeline_error++;
+ }
+ }
+ break;
+ case IMAP_BODY_TYPE_TEXT:
+ if(data->seqno == seqno) {
+ data->cb(seqno, buf, buflen, data->arg);
+ data->seqno = 0;
+ } else {
+ /* Text before header. Still, we can afford to invert it.. */
+ if(data->body)
+ data->pipeline_error++; /* Unlikely... */
+ else {
+ data->body = g_malloc(buflen);
+ memcpy(data->body, buf, buflen);
+ data->body_length = buflen;
+ data->seqno = seqno;
+ }
+ }
+ break;
+ default:
+ data->pipeline_error++;
+ }
}
ImapResponse
imap_mbox_handle_fetch_rfc822(ImapMboxHandle* handle,
unsigned cnt, unsigned *set,
+ gboolean peek_only,
ImapFetchBodyCb fetch_cb,
void *fetch_cb_data)
{
@@ -1070,10 +1115,16 @@
if(seq) {
ImapFetchBodyInternalCb cb = handle->body_cb;
void *arg = handle->body_arg;
- gchar *cmd = g_strdup_printf("FETCH %s RFC822", seq);
+ gchar *cmd = g_strdup_printf("FETCH %s %s", seq,
+ peek_only
+ ? "(BODY.PEEK[HEADER] BODY.PEEK[TEXT])"
+ : "RFC822");
struct FetchBodyPassthroughData passthrough_data;
passthrough_data.cb = fetch_cb;
passthrough_data.arg = fetch_cb_data;
+ passthrough_data.body = NULL;
+ passthrough_data.seqno = 0;
+ passthrough_data.pipeline_error = 0;
handle->body_cb = fetch_cb ? fetch_body_passthrough : NULL;
handle->body_arg = &passthrough_data;
rc = imap_cmd_exec(handle, cmd);
@@ -1081,6 +1132,10 @@
handle->body_arg = arg;
g_free(cmd);
g_free(seq);
+ if(passthrough_data.pipeline_error){
+ rc = IMR_NO;
+ imap_mbox_handle_set_msg(handle, "Unordered data received from server");
+ }
}
HANDLE_UNLOCK(handle);
Modified: trunk/libbalsa/imap/imap-commands.h
==============================================================================
--- trunk/libbalsa/imap/imap-commands.h (original)
+++ trunk/libbalsa/imap/imap-commands.h Sun Dec 14 20:21:17 2008
@@ -118,7 +118,8 @@
size_t buflen, void* arg);
ImapResponse imap_mbox_handle_fetch_rfc822(ImapMboxHandle* handle,
- unsigned cnt, unsigned *seqno,
+ unsigned cnt, unsigned *seqno,
+ gboolean peek_only,
ImapFetchBodyCb cb,
void *cb_data);
Modified: trunk/libbalsa/imap/imap-handle.c
==============================================================================
--- trunk/libbalsa/imap/imap-handle.c (original)
+++ trunk/libbalsa/imap/imap-handle.c Sun Dec 14 20:21:17 2008
@@ -876,7 +876,9 @@
char*
imap_mbox_handle_get_last_msg(ImapMboxHandle *handle)
{
- return g_strdup(handle->last_msg ? handle->last_msg : "");
+ return g_strdup(handle->state == IMHS_DISCONNECTED
+ ? "Connection severed"
+ : (handle->last_msg ? handle->last_msg : "") );
}
void
Modified: trunk/libbalsa/imap/imap_tst.c
==============================================================================
--- trunk/libbalsa/imap/imap_tst.c (original)
+++ trunk/libbalsa/imap/imap_tst.c Sun Dec 14 20:21:17 2008
@@ -280,7 +280,7 @@
unsigned batch_length = i+FETCH_AT_ONCE > cnt ? cnt-i : FETCH_AT_ONCE;
printf("Fetching %u:%u\n", i+1, i+batch_length);
for(j=0; j<batch_length; j++) arr[j] = i+1+j;
- if( imap_mbox_handle_fetch_rfc822(h, batch_length, arr,
+ if( imap_mbox_handle_fetch_rfc822(h, batch_length, arr, TRUE,
cb, cb_data) != IMR_OK) {
fprintf(stderr, "Fetching %u:%u failed: %s\n", i+1,
i+batch_length,
Modified: trunk/src/main-window.c
==============================================================================
--- trunk/src/main-window.c (original)
+++ trunk/src/main-window.c Sun Dec 14 20:21:17 2008
@@ -1137,6 +1137,16 @@
} else return NULL;
}
+static LibBalsaCondition *
+bw_filter_recent(const char *str)
+{
+ int days;
+ if(str && sscanf(str, "%d", &days) == 1) {
+ time_t lowerbound = time(NULL)-(days-1)*24*3600;
+ return libbalsa_condition_new_date(FALSE, &lowerbound, NULL);
+ } else return NULL;
+}
+
/* Subject or sender must match FILTER_SENDER, and Subject or
Recipient must match FILTER_RECIPIENT constant. */
static struct {
@@ -1147,7 +1157,8 @@
{ N_("Subject or Recipient Contains:"), bw_filter_sor },
{ N_("Subject Contains:"), bw_filter_s },
{ N_("Body Contains:"), bw_filter_body },
- { N_("Older than (days):"), bw_filter_old }
+ { N_("Older than (days):"), bw_filter_old },
+ { N_("Old at most (days):"), bw_filter_recent }
};
static gboolean view_filters_translated = FALSE;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]