* src/imap.c
o Fix build without USE_PTHREAD
o Factorize imap_open
o Alertpanel in case of impossible connection
o Alertpanel in case of impossible login
o Fix deferred flags processing to force a
flush before adding some more flags to process,
but in another folder.
+2005-06-11 [colin] 1.9.11cvs58
+
+ * src/imap.c
+ o Fix build without USE_PTHREAD
+ o Factorize imap_open
+ o Alertpanel in case of impossible connection
+ o Alertpanel in case of impossible login
+ o Fix deferred flags processing to force a
+ flush before adding some more flags to process,
+ but in another folder.
+
2005-06-10 [colin] 1.9.11cvs57
* src/imap.c
2005-06-10 [colin] 1.9.11cvs57
* src/imap.c
( cvs diff -u -r 1.179.2.22 -r 1.179.2.23 src/imap.c; ) > 1.9.11cvs55.patchset
( cvs diff -u -r 1.179.2.23 -r 1.179.2.24 src/imap.c; ) > 1.9.11cvs56.patchset
( cvs diff -u -r 1.179.2.24 -r 1.179.2.25 src/imap.c; cvs diff -u -r 1.49.2.46 -r 1.49.2.47 src/procmime.c; cvs diff -u -r 1.11.2.11 -r 1.11.2.12 src/common/smtp.c; cvs diff -u -r 1.2.2.8 -r 1.2.2.9 src/gtk/inputdialog.c; ) > 1.9.11cvs57.patchset
( cvs diff -u -r 1.179.2.22 -r 1.179.2.23 src/imap.c; ) > 1.9.11cvs55.patchset
( cvs diff -u -r 1.179.2.23 -r 1.179.2.24 src/imap.c; ) > 1.9.11cvs56.patchset
( cvs diff -u -r 1.179.2.24 -r 1.179.2.25 src/imap.c; cvs diff -u -r 1.49.2.46 -r 1.49.2.47 src/procmime.c; cvs diff -u -r 1.11.2.11 -r 1.11.2.12 src/common/smtp.c; cvs diff -u -r 1.2.2.8 -r 1.2.2.9 src/gtk/inputdialog.c; ) > 1.9.11cvs57.patchset
+( cvs diff -u -r 1.179.2.25 -r 1.179.2.26 src/imap.c; ) > 1.9.11cvs58.patchset
MICRO_VERSION=11
INTERFACE_AGE=0
BINARY_AGE=0
MICRO_VERSION=11
INTERFACE_AGE=0
BINARY_AGE=0
EXTRA_RELEASE=
EXTRA_GTK2_VERSION=
EXTRA_RELEASE=
EXTRA_GTK2_VERSION=
#include "alertpanel.h"
#include "sylpheed.h"
#include "statusbar.h"
#include "alertpanel.h"
#include "sylpheed.h"
#include "statusbar.h"
-#ifdef USE_PTHREAD
-#include <pthread.h>
-#endif
-typedef struct _thread_data {
- gchar *server;
- gushort port;
- gboolean done;
- SockInfo *sock;
-#ifdef USE_OPENSSL
- SSLType ssl_type;
-#endif
-} thread_data;
typedef struct _IMAPFolder IMAPFolder;
typedef struct _IMAPSession IMAPSession;
typedef struct _IMAPNameSpace IMAPNameSpace;
typedef struct _IMAPFolder IMAPFolder;
typedef struct _IMAPSession IMAPSession;
typedef struct _IMAPNameSpace IMAPNameSpace;
static FolderClass imap_class;
static FolderClass imap_class;
+typedef struct _thread_data {
+ gchar *server;
+ gushort port;
+ gboolean done;
+ SockInfo *sock;
+#ifdef USE_OPENSSL
+ SSLType ssl_type;
+#endif
+} thread_data;
#ifdef USE_PTHREAD
void *imap_getline_thread(void *data)
#ifdef USE_PTHREAD
void *imap_getline_thread(void *data)
if (imap_auth(session, account->userid, pass, account->imap_auth_type) != IMAP_SUCCESS) {
imap_cmd_logout(session);
statusbar_pop_all();
if (imap_auth(session, account->userid, pass, account->imap_auth_type) != IMAP_SUCCESS) {
imap_cmd_logout(session);
statusbar_pop_all();
+ alertpanel_error(_("Can't authenticate on IMAP4 server: %s"),
+ account->recv_server);
+
return;
}
statusbar_pop_all();
return;
}
statusbar_pop_all();
void *imap_open_thread(void *data)
{
SockInfo *sock = NULL;
void *imap_open_thread(void *data)
{
SockInfo *sock = NULL;
td->done = TRUE;
return sock;
}
td->done = TRUE;
return sock;
}
-#endif
-
-#if USE_OPENSSL
-static SockInfo *imap_open_blocking(const gchar *server, gushort port,
- SSLType ssl_type)
-#else
-static SockInfo *imap_open_blocking(const gchar *server, gushort port)
-#endif
-{
- SockInfo *sock;
- if ((sock = sock_connect(server, port)) == NULL) {
- log_warning(_("Can't connect to IMAP4 server: %s:%d\n"),
- server, port);
- return NULL;
- }
-
-#if USE_OPENSSL
- if (ssl_type == SSL_TUNNEL && !ssl_init_socket(sock)) {
- log_warning(_("Can't establish IMAP4 session with: %s:%d\n"),
- server, port);
- sock_close(sock);
- sock = NULL;
- return NULL;
- }
-#endif
- return sock;
-}
#if USE_OPENSSL
static SockInfo *imap_open(const gchar *server, gushort port,
#if USE_OPENSSL
static SockInfo *imap_open(const gchar *server, gushort port,
static SockInfo *imap_open(const gchar *server, gushort port)
#endif
{
static SockInfo *imap_open(const gchar *server, gushort port)
#endif
{
-#if (defined USE_PTHREAD && defined __GLIBC__ && (__GLIBC__ > 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ >= 3)))
- /* non blocking stuff */
thread_data *td = g_new0(thread_data, 1);
thread_data *td = g_new0(thread_data, 1);
#if USE_OPENSSL
td->ssl_type = ssl_type;
#endif
#if USE_OPENSSL
td->ssl_type = ssl_type;
#endif
statusbar_print_all(_("Connecting to IMAP4 server: %s..."), server);
statusbar_print_all(_("Connecting to IMAP4 server: %s..."), server);
+#if (defined USE_PTHREAD && defined __GLIBC__ && (__GLIBC__ > 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ >= 3)))
if (pthread_create(&pt, PTHREAD_CREATE_JOINABLE,
imap_open_thread, td) != 0) {
statusbar_pop_all();
if (pthread_create(&pt, PTHREAD_CREATE_JOINABLE,
imap_open_thread, td) != 0) {
statusbar_pop_all();
- g_free(td->server);
- g_free(td);
-#if USE_OPENSSL
- return imap_open_blocking(server, port, ssl_type);
+ sock = imap_open_thread(td);
+ } else {
+ debug_print("+++waiting for imap_open_thread...\n");
+ while(!td->done) {
+ /* don't let the interface freeze while waiting */
+ sylpheed_do_idle();
+ }
+
+ /* get the thread's return value and clean its resources */
+ pthread_join(pt, (void *)&sock);
+ }
- return imap_open_blocking(server, port);
+ sock = imap_open_thread(td);
- }
-
- debug_print("+++waiting for imap_open_thread...\n");
- while(!td->done) {
- /* don't let the interface freeze while waiting */
- sylpheed_do_idle();
- }
-
- /* get the thread's return value and clean its resources */
- pthread_join(pt, (void *)&sock);
#if USE_OPENSSL
if (sock && td->ssl_type == SSL_TUNNEL && !ssl_init_socket(sock)) {
log_warning(_("Can't establish IMAP4 session with: %s:%d\n"),
#if USE_OPENSSL
if (sock && td->ssl_type == SSL_TUNNEL && !ssl_init_socket(sock)) {
log_warning(_("Can't establish IMAP4 session with: %s:%d\n"),
sock_close(sock);
sock = NULL;
td->done = TRUE;
sock_close(sock);
sock = NULL;
td->done = TRUE;
}
#endif
g_free(td->server);
}
#endif
g_free(td->server);
debug_print("---imap_open_thread returned %p\n", sock);
statusbar_pop_all();
debug_print("---imap_open_thread returned %p\n", sock);
statusbar_pop_all();
+
+ if(!sock && !prefs_common.no_recv_err_panel) {
+ alertpanel_error(_("Can't connect to IMAP4 server: %s:%d"),
+ server, port);
+ }
+
-#else
-#if USE_OPENSSL
- return imap_open_blocking(server, port, ssl_type);
-#else
- return imap_open_blocking(server, port);
-#endif
-#endif
typedef struct _hashtable_data {
IMAPSession *session;
GSList *msglist;
typedef struct _hashtable_data {
IMAPSession *session;
GSList *msglist;
} hashtable_data;
static gboolean process_flags(gpointer key, gpointer value, gpointer user_data)
} hashtable_data;
static gboolean process_flags(gpointer key, gpointer value, gpointer user_data)
+static FolderItem *last_deferred_item = NULL;
static gboolean process_hashtable(void *data)
{
static gboolean process_hashtable(void *data)
{
+ FolderItem *item = (FolderItem *)data;
debug_print("processing flags change hashtables\n");
if (flags_set_table) {
g_hash_table_foreach_remove(flags_set_table, process_flags, GINT_TO_POINTER(TRUE));
debug_print("processing flags change hashtables\n");
if (flags_set_table) {
g_hash_table_foreach_remove(flags_set_table, process_flags, GINT_TO_POINTER(TRUE));
flags_unset_table = NULL;
}
flags_unset_table = NULL;
}
+ folder_item_scan_full(item, FALSE);
+ hashtable_process_tag = -1;
session = imap_session_get(folder);
if (!session) return;
printf("changing flags\n");
session = imap_session_get(folder);
if (!session) return;
printf("changing flags\n");
+
+ if (hashtable_process_tag != -1 && item != last_deferred_item
+ && last_deferred_item != NULL) {
+ debug_print("forcing flush for %s (!= %s)\n",
+ last_deferred_item->path,
+ item->path);
+ gtk_timeout_remove(hashtable_process_tag);
+ process_hashtable(last_deferred_item);
+ hashtable_process_tag = -1;
+ }
+ last_deferred_item = item;
+
if ((ok = imap_select(session, IMAP_FOLDER(folder), msginfo->folder->path,
NULL, NULL, NULL, NULL, FALSE)) != IMAP_SUCCESS)
return;
if ((ok = imap_select(session, IMAP_FOLDER(folder), msginfo->folder->path,
NULL, NULL, NULL, NULL, FALSE)) != IMAP_SUCCESS)
return;
/* instead of performing an UID STORE command for each message change,
* as a lot of them can change "together", we just fill in hashtables
/* instead of performing an UID STORE command for each message change,
* as a lot of them can change "together", we just fill in hashtables
- * and defer the treatment 500ms so that we're able to send only one
+ * and defer the treatment 100ms so that we're able to send only one
* command.
*/
if (flags_set) {
* command.
*/
if (flags_set) {
if (hashtable_process_tag != -1)
gtk_timeout_remove(hashtable_process_tag);
if (hashtable_process_tag != -1)
gtk_timeout_remove(hashtable_process_tag);
- hashtable_process_tag = gtk_timeout_add(500, process_hashtable, NULL);
+ hashtable_process_tag = gtk_timeout_add(100, process_hashtable, item);
session = imap_session_get(folder);
if (!session) return -1;
session = imap_session_get(folder);
if (!session) return -1;
+ if (hashtable_process_tag != -1 && item != last_deferred_item
+ && last_deferred_item != NULL) {
+ debug_print("forcing flush for %s (!= %s)\n",
+ last_deferred_item->path,
+ item->path);
+ gtk_timeout_remove(hashtable_process_tag);
+ process_hashtable(last_deferred_item);
+ hashtable_process_tag = -1;
+ }
+ last_deferred_item = item;
+
printf("removing messages\n");
ok = imap_select(session, IMAP_FOLDER(folder), item->path,
NULL, NULL, NULL, NULL, FALSE);
printf("removing messages\n");
ok = imap_select(session, IMAP_FOLDER(folder), item->path,
NULL, NULL, NULL, NULL, FALSE);
if (hashtable_process_tag != -1)
gtk_timeout_remove(hashtable_process_tag);
if (hashtable_process_tag != -1)
gtk_timeout_remove(hashtable_process_tag);
- hashtable_process_tag = gtk_timeout_add(500, process_hashtable, NULL);
+ hashtable_process_tag = gtk_timeout_add(100, process_hashtable, item);
IMAP_FOLDER_ITEM(item)->uid_list = g_slist_remove(
IMAP_FOLDER_ITEM(item)->uid_list, numlist.data);
IMAP_FOLDER_ITEM(item)->uid_list = g_slist_remove(
IMAP_FOLDER_ITEM(item)->uid_list, numlist.data);