0.8.11claws60
authorChristoph Hohmann <reboot@gmx.ch>
Thu, 27 Mar 2003 21:52:32 +0000 (21:52 +0000)
committerChristoph Hohmann <reboot@gmx.ch>
Thu, 27 Mar 2003 21:52:32 +0000 (21:52 +0000)
* src/folder.c
* src/imap.c
* src/common/socket.[ch]
        set socket state to DISCONNECTED when any operation
        fails to allow reconnecting in IMAP code without
        checking the return code of all calls to the command
        functions

* src/folderview.c
* src/summaryview.c
        remove some more stuff that depends on specific
        folder types

ChangeLog.claws
configure.ac
src/common/socket.c
src/common/socket.h
src/folder.c
src/folderview.c
src/imap.c
src/summaryview.c

index 4192964..50c676f 100644 (file)
@@ -1,3 +1,18 @@
+2003-03-27 [christoph] 0.8.11claws60
+
+       * src/folder.c
+       * src/imap.c
+       * src/common/socket.[ch]
+               set socket state to DISCONNECTED when any operation
+               fails to allow reconnecting in IMAP code without
+               checking the return code of all calls to the command
+               functions
+
+       * src/folderview.c
+       * src/summaryview.c
+               remove some more stuff that depends on specific
+               folder types
+
 2003-03-27 [paul]      0.8.11claws59
 
        * sync with 0.8.11cvs14
index 3e7a866..f659c28 100644 (file)
@@ -11,7 +11,7 @@ MINOR_VERSION=8
 MICRO_VERSION=11
 INTERFACE_AGE=0
 BINARY_AGE=0
-EXTRA_VERSION=claws59
+EXTRA_VERSION=claws60
 VERSION=$MAJOR_VERSION.$MINOR_VERSION.$MICRO_VERSION$EXTRA_VERSION
 
 dnl set $target
index fbfca36..ddaa802 100644 (file)
@@ -453,13 +453,20 @@ gint sock_printf(SockInfo *sock, const gchar *format, ...)
 
 gint sock_read(SockInfo *sock, gchar *buf, gint len)
 {
+       gint ret;
+
        g_return_val_if_fail(sock != NULL, -1);
 
 #if USE_OPENSSL
        if (sock->ssl)
-               return ssl_read(sock->ssl, buf, len);
+               ret = ssl_read(sock->ssl, buf, len);
+       else
 #endif
-       return fd_read(sock->sock, buf, len);
+               ret = fd_read(sock->sock, buf, len);
+       
+       if (ret < 0)
+               sock->state = CONN_DISCONNECTED;
+       return ret;
 }
 
 gint fd_read(gint fd, gchar *buf, gint len)
@@ -479,13 +486,20 @@ gint ssl_read(SSL *ssl, gchar *buf, gint len)
 
 gint sock_write(SockInfo *sock, const gchar *buf, gint len)
 {
+       gint ret;
+
        g_return_val_if_fail(sock != NULL, -1);
 
 #if USE_OPENSSL
        if (sock->ssl)
-               return ssl_write(sock->ssl, buf, len);
+               ret = ssl_write(sock->ssl, buf, len);
+       else
 #endif
-       return fd_write(sock->sock, buf, len);
+               ret = fd_write(sock->sock, buf, len);
+
+       if (ret < 0)
+               sock->state = CONN_DISCONNECTED;
+       return ret;
 }
 
 gint fd_write(gint fd, const gchar *buf, gint len)
@@ -505,13 +519,20 @@ gint ssl_write(SSL *ssl, const gchar *buf, gint len)
 
 gint sock_write_all(SockInfo *sock, const gchar *buf, gint len)
 {
+       gint ret;
+
        g_return_val_if_fail(sock != NULL, -1);
 
 #if USE_OPENSSL
        if (sock->ssl)
-               return ssl_write_all(sock->ssl, buf, len);
+               ret = ssl_write_all(sock->ssl, buf, len);
+       else
 #endif
-       return fd_write_all(sock->sock, buf, len);
+               ret = fd_write_all(sock->sock, buf, len);
+
+       if (ret < 0)
+               sock->state = CONN_DISCONNECTED;
+       return ret;
 }
 
 gint fd_write_all(gint fd, const gchar *buf, gint len)
@@ -609,13 +630,20 @@ gint ssl_gets(SSL *ssl, gchar *buf, gint len)
 
 gint sock_gets(SockInfo *sock, gchar *buf, gint len)
 {
+       gint ret;
+
        g_return_val_if_fail(sock != NULL, -1);
 
 #if USE_OPENSSL
        if (sock->ssl)
                return ssl_gets(sock->ssl, buf, len);
+       else
 #endif
-       return fd_gets(sock->sock, buf, len);
+               return fd_gets(sock->sock, buf, len);
+
+       if (ret < 0)
+               sock->state = CONN_DISCONNECTED;
+       return ret;
 }
 
 gchar *fd_getline(gint fd)
@@ -673,13 +701,20 @@ gchar *ssl_getline(SSL *ssl)
 
 gchar *sock_getline(SockInfo *sock)
 {
+       gint ret;
+
        g_return_val_if_fail(sock != NULL, NULL);
 
 #if USE_OPENSSL
        if (sock->ssl)
-               return ssl_getline(sock->ssl);
+               ret = ssl_getline(sock->ssl);
+       else
 #endif
-       return fd_getline(sock->sock);
+               ret = fd_getline(sock->sock);
+
+       if (ret < 0)
+               sock->state = CONN_DISCONNECTED;
+       return ret;
 }
 
 gint sock_puts(SockInfo *sock, const gchar *buf)
@@ -694,7 +729,7 @@ gint sock_puts(SockInfo *sock, const gchar *buf)
 /* peek at the next socket character without actually reading it */
 gint sock_peek(SockInfo *sock)
 {
-       gint n;
+       gint ret, n;
        gchar ch;
 
        g_return_val_if_fail(sock != NULL, -1);
@@ -702,15 +737,22 @@ gint sock_peek(SockInfo *sock)
 #if USE_OPENSSL
        if (sock->ssl) {
                if ((n = SSL_peek(sock->ssl, &ch, 1)) < 0)
-                       return -1;
+                       ret = -1;
                else
-                       return ch;
+                       ret = ch;
+       } else {
+#endif
+               if ((n = recv(sock->sock, &ch, 1, MSG_PEEK)) < 0)
+                       ret = -1;
+               else
+                       ret = ch;
+#if USE_OPENSSL
        }
 #endif
-       if ((n = recv(sock->sock, &ch, 1, MSG_PEEK)) < 0)
-               return -1;
-       else
-               return ch;
+
+       if (ret < 0)
+               sock->state = CONN_DISCONNECTED;
+       return ret;
 }
 
 gint sock_close(SockInfo *sock)
index 135e654..76e219d 100644 (file)
@@ -39,7 +39,8 @@ typedef enum
        CONN_LOOKUPSUCCESS,
        CONN_ESTABLISHED,
        CONN_LOOKUPFAILED,
-       CONN_FAILED
+       CONN_FAILED,
+       CONN_DISCONNECTED,
 } ConnectionState;
 
 struct _SockInfo
index 19088bb..ee4ea11 100644 (file)
@@ -675,28 +675,23 @@ gchar *folder_item_get_name(FolderItem *item)
 
        switch (item->stype) {
        case F_INBOX:
-               name = g_strdup(FOLDER_IS_LOCAL(item->folder) &&
-                               !strcmp2(item->name, INBOX_DIR) ? _("Inbox") :
+               name = g_strdup(!strcmp2(item->name, INBOX_DIR) ? _("Inbox") :
                                item->name);
                break;
        case F_OUTBOX:
-               name = g_strdup(FOLDER_IS_LOCAL(item->folder) &&
-                               !strcmp2(item->name, OUTBOX_DIR) ? _("Sent") :
+               name = g_strdup(!strcmp2(item->name, OUTBOX_DIR) ? _("Sent") :
                                item->name);
                break;
        case F_QUEUE:
-               name = g_strdup(FOLDER_IS_LOCAL(item->folder) &&
-                               !strcmp2(item->name, QUEUE_DIR) ? _("Queue") :
+               name = g_strdup(!strcmp2(item->name, QUEUE_DIR) ? _("Queue") :
                                item->name);
                break;
        case F_TRASH:
-               name = g_strdup(FOLDER_IS_LOCAL(item->folder) &&
-                               !strcmp2(item->name, TRASH_DIR) ? _("Trash") :
+               name = g_strdup(!strcmp2(item->name, TRASH_DIR) ? _("Trash") :
                                item->name);
                break;
        case F_DRAFT:
-               name = g_strdup(FOLDER_IS_LOCAL(item->folder) &&
-                               !strcmp2(item->name, DRAFT_DIR) ? _("Drafts") :
+               name = g_strdup(!strcmp2(item->name, DRAFT_DIR) ? _("Drafts") :
                                item->name);
                break;
        default:
index 92a2283..326c896 100644 (file)
@@ -783,18 +783,6 @@ static void folderview_scan_tree_func(Folder *folder, FolderItem *item,
                                      gpointer data)
 {
        GList *list;
-       gchar *rootpath;
-
-       if (FOLDER_IS_LOCAL(folder))
-               rootpath = LOCAL_FOLDER(folder)->rootpath;
-       else if (FOLDER_TYPE(folder) == F_IMAP && folder->account &&
-                folder->account->recv_server)
-               rootpath = folder->account->recv_server;
-       else if (FOLDER_TYPE(folder) == F_NEWS && folder->account &&
-                folder->account->nntp_server)
-               rootpath = folder->account->nntp_server;
-       else
-               return;
 
        for (list = folderview_list; list != NULL; list = list->next) {
                FolderView *folderview = (FolderView *)list->data;
@@ -803,11 +791,11 @@ static void folderview_scan_tree_func(Folder *folder, FolderItem *item,
 
                if (item->path)
                        str = g_strdup_printf(_("Scanning folder %s%c%s ..."),
-                                             rootpath, G_DIR_SEPARATOR,
+                                             item->folder->name, G_DIR_SEPARATOR,
                                              item->path);
                else
                        str = g_strdup_printf(_("Scanning folder %s ..."),
-                                             rootpath);
+                                             item->folder->name);
 
                STATUSBAR_PUSH(mainwin, str);
                STATUSBAR_POP(mainwin);
index 6cb9b7f..bcf8411 100644 (file)
@@ -446,6 +446,13 @@ static IMAPSession *imap_session_get(Folder *folder)
        if(session == NULL)
                return NULL;
 
+       if (session->sock->state == CONN_DISCONNECTED) {
+               debug_print("IMAP server disconnected\n");
+               session_destroy(session);
+               imap_reset_uid_lists(folder);
+               session = imap_session_new(folder->account);
+       }               
+
        /* Get CAPABILITY */
        imap_get_capability(session); 
 
index 739345a..807f4db 100644 (file)
@@ -1978,18 +1978,12 @@ static void summary_status_show(SummaryView *summaryview)
        g_free(cp);
        g_free(itstr);
 
-       if (FOLDER_IS_LOCAL(summaryview->folder_item->folder)) {
-               str = g_strdup_printf(_("%d new, %d unread, %d total (%s)"),
-                                     summaryview->newmsgs,
-                                     summaryview->unread,
-                                     summaryview->messages,
-                                     to_human_readable(summaryview->total_size));
-       } else {
-               str = g_strdup_printf(_("%d new, %d unread, %d total"),
-                                     summaryview->newmsgs,
-                                     summaryview->unread,
-                                     summaryview->messages);
-       }
+       str = g_strdup_printf(_("%d new, %d unread, %d total (%s)"),
+                             summaryview->newmsgs,
+                             summaryview->unread,
+                             summaryview->messages,
+                             to_human_readable(summaryview->total_size));
+
        gtk_label_set(GTK_LABEL(summaryview->statlabel_msgs), str);
        g_free(str);
 }