sync with 0.9.2cvs6
authorPaul Mangan <paul@claws-mail.org>
Thu, 26 Jun 2003 09:52:33 +0000 (09:52 +0000)
committerPaul Mangan <paul@claws-mail.org>
Thu, 26 Jun 2003 09:52:33 +0000 (09:52 +0000)
ChangeLog
ChangeLog.claws
ChangeLog.jp
configure.ac
src/common/session.c
src/common/socket.c
src/inc.c
src/pop.c

index ca5421e..4068a01 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+2003-06-26
+
+       * src/socket.c: made socket connection protocol independent.
+       * src/session.c: removed debug g_print().
+       * src/inc.c: made status bar output less verbose, and show counter
+         on main window's progressbar.
+
 2003-06-26
 
        * src/session.c: added missing #include <errno.h>.
index 82910e3..80637ab 100644 (file)
@@ -1,3 +1,8 @@
+2003-06-26 [paul]      0.9.0claws64
+
+       * sync with 0.9.2cvs6
+               see ChangeLog 2003-06-26
+
 2003-06-26 [paul]      0.9.0claws63
 
        * sync with 0.9.2cvs5
index b043122..bb0a7fd 100644 (file)
@@ -1,3 +1,10 @@
+2003-06-26
+
+       * src/socket.c: ¥½¥±¥Ã¥ÈÀܳ¤ò¥×¥í¥È¥³¥ëÆÈΩ¤Ë¤·¤¿¡£
+       * src/session.c: ¥Ç¥Ð¥Ã¥°ÍÑ g_print() ¤òºï½ü¡£
+       * src/inc.c: ¥¹¥Æ¡¼¥¿¥¹¥Ð¡¼¤Î½ÐÎϤξéĹÅÙ¤ò¸º¤é¤·¡¢¥á¥¤¥ó¥¦¥£¥ó¥É¥¦
+         ¤Î¥×¥í¥°¥ì¥¹¥Ð¡¼¤Ë¥«¥¦¥ó¥¿¤òɽ¼¨¡£
+
 2003-06-26
 
        * src/session.c: #include <errno.h> ¤¬Â­¤ê¤Ê¤«¤Ã¤¿¤Î¤ÇÄɲá£
index 2c4e951..37712b7 100644 (file)
@@ -11,7 +11,7 @@ MINOR_VERSION=9
 MICRO_VERSION=0
 INTERFACE_AGE=0
 BINARY_AGE=0
-EXTRA_VERSION=claws63
+EXTRA_VERSION=claws64
 VERSION=$MAJOR_VERSION.$MINOR_VERSION.$MICRO_VERSION$EXTRA_VERSION
 
 dnl set $target
index 7ecc573..16815ba 100644 (file)
@@ -391,7 +391,6 @@ static gboolean session_read_msg_cb(GIOChannel *source, GIOCondition condition,
        if (read_len < 0) {
                switch (errno) {
                case EAGAIN:
-                       g_print("session_read_msg_cb: %s\n", g_strerror(errno));
                        return TRUE;
                default:
                        g_warning("sock_peek: %s\n", g_strerror(errno));
@@ -411,7 +410,6 @@ static gboolean session_read_msg_cb(GIOChannel *source, GIOCondition condition,
        if (read_len < 0) {
                switch (errno) {
                case EAGAIN:
-                       g_print("session_read_msg_cb: %s\n", g_strerror(errno));
                        return TRUE;
                default:
                        g_warning("sock_read: %s\n", g_strerror(errno));
@@ -470,7 +468,6 @@ static gboolean session_read_data_cb(GIOChannel     *source, GIOCondition condition,
        if (read_len < 0) {
                switch (errno) {
                case EAGAIN:
-                       g_print("session_read_data_cb: %s\n", g_strerror(errno));
                        return TRUE;
                default:
                        g_warning("sock_read: %s\n", g_strerror(errno));
@@ -553,7 +550,6 @@ static gint session_write_buf(Session *session)
        if (write_len < 0) {
                switch (errno) {
                case EAGAIN:
-                       g_print("session_write_cb: %s\n", g_strerror(errno));
                        write_len = 0;
                        break;
                default:
index 65fc007..a843d5f 100644 (file)
@@ -85,8 +85,11 @@ struct _SockLookupData {
 };
 
 struct _SockAddrData {
+       gint family;
+       gint socktype;
+       gint protocol;
        gint addr_len;
-       gpointer addr_data;
+       struct sockaddr *addr;
 };
 
 static guint io_timeout = 60;
@@ -494,7 +497,7 @@ static void sock_address_list_free(GList *addr_list)
 
        for (cur = addr_list; cur != NULL; cur = cur->next) {
                SockAddrData *addr_data = (SockAddrData *)cur->data;
-               g_free(addr_data->addr_data);
+               g_free(addr_data->addr);
                g_free(addr_data);
        }
 
@@ -630,78 +633,21 @@ gint sock_connect_async_cancel(gint id)
 static gint sock_connect_address_list_async(SockConnectData *conn_data)
 {
        SockAddrData *addr_data;
-       struct sockaddr_in ad;
-#ifdef INET6
-       struct sockaddr_in6 ad6;
-#endif
-       struct sockaddr *sa;
-       gint sa_size;
        gint sock = -1;
 
        for (; conn_data->cur_addr != NULL;
             conn_data->cur_addr = conn_data->cur_addr->next) {
                addr_data = (SockAddrData *)conn_data->cur_addr->data;
 
-#ifdef INET6
-               if (addr_data->addr_len != 4 && addr_data->addr_len != 16)
-                       continue;
-
-               if (addr_data->addr_len == 4) {
-                       /* IPv4 address */
-                       if ((sock = socket(AF_INET, SOCK_STREAM, 0)) < 0) {
-                               perror("socket");
-                               conn_data->cur_addr = NULL;
-                               break;
-                       }
-
-                       memset(&ad, 0, sizeof(ad));
-                       ad.sin_family = AF_INET;
-                       ad.sin_port = htons(conn_data->port);
-                       memcpy(&ad.sin_addr, addr_data->addr_data,
-                              addr_data->addr_len);
-
-                       sa = (struct sockaddr *)&ad;
-                       sa_size = sizeof(ad);
-               } else {
-                       /* IPv6 address */
-                       if ((sock = socket(AF_INET6, SOCK_STREAM, 0)) < 0) {
-                               perror("socket");
-                               conn_data->cur_addr = NULL;
-                               break;
-                       }
-
-                       memset(&ad6, 0, sizeof(ad6));
-                       ad6.sin6_family = AF_INET6;
-                       ad6.sin6_port = htons(conn_data->port);
-                       memcpy(&ad6.sin6_addr, addr_data->addr_data,
-                              addr_data->addr_len);
-
-                       sa = (struct sockaddr *)&ad6;
-                       sa_size = sizeof(ad6);
-               }
-#else /* !INET6 */
-               /* IPv4 only */
-               if (addr_data->addr_len != 4)
-                       continue;
-
-               if ((sock = socket(AF_INET, SOCK_STREAM, 0)) < 0) {
+               if ((sock = socket(addr_data->family, addr_data->socktype,
+                                  addr_data->protocol)) < 0) {
                        perror("socket");
-                       conn_data->cur_addr = NULL;
-                       break;
+                       continue;
                }
 
-               memset(&ad, 0, sizeof(ad));
-               ad.sin_family = AF_INET;
-               ad.sin_port = htons(conn_data->port);
-               memcpy(&ad.sin_addr, addr_data->addr_data, addr_data->addr_len);
-
-               sa = (struct sockaddr *)&ad;
-               sa_size = sizeof(ad);
-#endif
-
                set_nonblocking_mode(sock, TRUE);
 
-               if (connect(sock, sa, sa_size) < 0) {
+               if (connect(sock, addr_data->addr, addr_data->addr_len) < 0) {
                        if (EINPROGRESS == errno) {
                                break;
                        } else {
@@ -740,45 +686,49 @@ static gboolean sock_get_address_info_async_cb(GIOChannel *source,
        GList *addr_list = NULL;
        SockAddrData *addr_data;
        guint bytes_read;
-       guint8 addr_len;
-       gchar buf[16];
+       gint ai_member[4];
+       struct sockaddr *addr;
 
        for (;;) {
-               if (g_io_channel_read(source, &addr_len, 1, &bytes_read)
+               if (g_io_channel_read(source, (gchar *)ai_member,
+                                     sizeof(ai_member), &bytes_read)
                    != G_IO_ERROR_NONE) {
                        g_warning("sock_get_address_info_async_cb: "
                                  "address length read error\n");
                        break;
                }
 
-               if (bytes_read == 0)
+               if (bytes_read == 0 || bytes_read != sizeof(ai_member))
                        break;
 
-               if (addr_len == 'e') {
+               if (ai_member[0] == AF_UNSPEC) {
                        g_warning("DNS lookup failed\n");
                        break;
-               } else if (addr_len != 4 && addr_len != 16) {
-                       g_warning("illegal address length: %d\n", addr_len);
-                       break;
                }
 
-               if (g_io_channel_read(source, buf, addr_len, &bytes_read)
+               addr = g_malloc(ai_member[3]);
+               if (g_io_channel_read(source, (gchar *)addr, ai_member[3],
+                                     &bytes_read)
                    != G_IO_ERROR_NONE) {
                        g_warning("sock_get_address_info_async_cb: "
                                  "address data read error\n");
+                       g_free(addr);
                        break;
                }
 
-               if (bytes_read != addr_len) {
+               if (bytes_read != ai_member[3]) {
                        g_warning("sock_get_address_info_async_cb: "
                                  "incomplete address data\n");
+                       g_free(addr);
                        break;
                }
 
                addr_data = g_new0(SockAddrData, 1);
-               addr_data->addr_len = addr_len;
-               addr_data->addr_data = g_malloc(addr_len);
-               memcpy(addr_data->addr_data, buf, addr_len);
+               addr_data->family = ai_member[0];
+               addr_data->socktype = ai_member[1];
+               addr_data->protocol = ai_member[2];
+               addr_data->addr_len = ai_member[3];
+               addr_data->addr = addr;
 
                addr_list = g_list_append(addr_list, addr_data);
        }
@@ -827,8 +777,9 @@ static SockLookupData *sock_get_address_info_async(const gchar *hostname,
 #else /* !INET6 */
                struct hostent *hp;
                gchar **addr_list_p;
+               struct sockaddr_in ad;
 #endif /* INET6 */
-               guint8 addr_len;
+               gint ai_member[4] = {AF_UNSPEC, 0, 0, 0};
 
                close(pipe_fds[0]);
 
@@ -845,51 +796,50 @@ static SockLookupData *sock_get_address_info_async(const gchar *hostname,
                if (gai_err != 0) {
                        g_warning("getaddrinfo for %s:%s failed: %s\n",
                                  hostname, port_str, gai_strerror(gai_err));
-                       fd_write(pipe_fds[1], "e", 1);
+                       fd_write_all(pipe_fds[1], (gchar *)ai_member,
+                                    sizeof(ai_member));
                        close(pipe_fds[1]);
                        _exit(1);
                }
 
                for (ai = res; ai != NULL; ai = ai->ai_next) {
-                       if (ai->ai_family == AF_INET) {
-                               struct sockaddr_in *ad;
-
-                               ad = (struct sockaddr_in *)ai->ai_addr;
-                               addr_len = sizeof(ad->sin_addr);
-
-                               fd_write(pipe_fds[1], &addr_len, 1);
-                               fd_write_all(pipe_fds[1],
-                                            (gchar *)&ad->sin_addr,
-                                            sizeof(ad->sin_addr));
-                       } else if (ai->ai_family == AF_INET6) {
-                               struct sockaddr_in6 *ad;
-
-                               ad = (struct sockaddr_in6 *)ai->ai_addr;
-                               addr_len = sizeof(ad->sin6_addr);
-
-                               fd_write(pipe_fds[1], &addr_len, 1);
-                               fd_write_all(pipe_fds[1],
-                                            (gchar *)&ad->sin6_addr,
-                                            sizeof(ad->sin6_addr));
-                       }
+                       ai_member[0] = ai->ai_family;
+                       ai_member[1] = ai->ai_socktype;
+                       ai_member[2] = ai->ai_protocol;
+                       ai_member[3] = ai->ai_addrlen;
+
+                       fd_write_all(pipe_fds[1], (gchar *)ai_member,
+                                    sizeof(ai_member));
+                       fd_write_all(pipe_fds[1], (gchar *)ai->ai_addr,
+                                    ai->ai_addrlen);
                }
 
                if (res != NULL)
                        freeaddrinfo(res);
 #else /* !INET6 */
                hp = my_gethostbyname(hostname);
-               if (hp == NULL) {
-                       fd_write(pipe_fds[1], "e", 1);
+               if (hp == NULL || hp->h_addrtype != AF_INET) {
+                       fd_write_all(pipe_fds[1], (gchar *)ai_member,
+                                    sizeof(ai_member));
                        close(pipe_fds[1]);
                        _exit(1);
                }
 
-               addr_len = (guint8)hp->h_length;
+               ai_member[0] = AF_INET;
+               ai_member[1] = SOCK_STREAM;
+               ai_member[2] = IPPROTO_TCP;
+               ai_member[3] = sizeof(ad);
+
+               memset(&ad, 0, sizeof(ad));
+               ad.sin_family = AF_INET;
+               ad.sin_port = htons(port);
 
                for (addr_list_p = hp->h_addr_list; *addr_list_p != NULL;
                     addr_list_p++) {
-                       fd_write(pipe_fds[1], &addr_len, 1);
-                       fd_write_all(pipe_fds[1], *addr_list_p, hp->h_length);
+                       memcpy(&ad.sin_addr, *addr_list_p, hp->h_length);
+                       fd_write_all(pipe_fds[1], (gchar *)ai_member,
+                                    sizeof(ai_member));
+                       fd_write_all(pipe_fds[1], (gchar *)&ad, sizeof(ad));
                }
 #endif /* INET6 */
 
@@ -931,8 +881,6 @@ static gint sock_get_address_info_async_cancel(SockLookupData *lookup_data)
        g_free(lookup_data->hostname);
        g_free(lookup_data);
 
-       g_print("DNS lookup cancelled\n");
-
        return 0;
 }
 
index d5b7b99..cee3734 100644 (file)
--- a/src/inc.c
+++ b/src/inc.c
@@ -406,6 +406,8 @@ static void inc_progress_dialog_clear(IncProgressDialog *inc_dialog)
 {
        progress_dialog_set_value(inc_dialog->dialog, 0.0);
        progress_dialog_set_label(inc_dialog->dialog, "");
+       gtk_progress_set_show_text
+               (GTK_PROGRESS(inc_dialog->mainwin->progressbar), FALSE);
        if (inc_dialog->mainwin)
                gtk_progress_bar_update
                        (GTK_PROGRESS_BAR(inc_dialog->mainwin->progressbar), 0.0);
@@ -416,6 +418,9 @@ static void inc_progress_dialog_destroy(IncProgressDialog *inc_dialog)
        g_return_if_fail(inc_dialog != NULL);
 
        inc_dialog_list = g_list_remove(inc_dialog_list, inc_dialog);
+
+       gtk_progress_set_show_text
+               (GTK_PROGRESS(inc_dialog->mainwin->progressbar), FALSE);
        if (inc_dialog->mainwin)
                gtk_progress_bar_update
                        (GTK_PROGRESS_BAR(inc_dialog->mainwin->progressbar), 0.0);
@@ -616,6 +621,7 @@ static gint inc_start(IncProgressDialog *inc_dialog)
 
                folder_item_update_thaw();
 
+               statusbar_pop_all();
 
                new_msgs += pop3_session->cur_total_num;
 
@@ -718,15 +724,13 @@ static IncState inc_pop3_session_do(IncSession *session)
                pop3_session->ac_prefs->popport : 110;
 #endif
 
-       statusbar_verbosity_set(TRUE);
-       buf = g_strdup_printf(_("Connecting to POP3 server: %s ..."), server);
+       buf = g_strdup_printf(_("Connecting to POP3 server: %s..."), server);
        log_message("%s\n", buf);
 
        progress_dialog_set_label(inc_dialog->dialog, buf);
        g_free(buf);
        GTK_EVENTS_FLUSH();
 
-       statusbar_verbosity_set(FALSE);
 
        if (session_connect(SESSION(pop3_session), server, port) < 0) {
                log_warning(_("Can't connect to POP3 server: %s:%d\n"),
@@ -741,18 +745,17 @@ static IncState inc_pop3_session_do(IncSession *session)
                        manage_window_focus_out(inc_dialog->dialog->window, NULL, NULL);
                }
                session->inc_state = INC_CONNECT_ERROR;
+               statusbar_pop_all();
                return INC_CONNECT_ERROR;
        }
 
-       statusbar_verbosity_set(TRUE);
-
        while (SESSION(pop3_session)->state != SESSION_DISCONNECTED &&
               SESSION(pop3_session)->state != SESSION_ERROR &&
               session->inc_state != INC_CANCEL)
                gtk_main_iteration();
 
+       statusbar_pop_all();
 
-       statusbar_verbosity_set(FALSE);
        if (session->inc_state == INC_SUCCESS) {
                switch (pop3_session->error_val) {
                case PS_SUCCESS:
@@ -803,6 +806,8 @@ static void inc_progress_dialog_set_label(IncProgressDialog *inc_dialog,
        case POP3_GETAUTH_PASS:
        case POP3_GETAUTH_APOP:
                progress_dialog_set_label(dialog, _("Authenticating..."));
+               statusbar_print_all(_("Retrieving messages from %s..."),
+                                   SESSION(session)->server);
                break;
        case POP3_GETRANGE_STAT:
                progress_dialog_set_label
@@ -821,6 +826,12 @@ static void inc_progress_dialog_set_label(IncProgressDialog *inc_dialog,
                        (dialog, _("Getting the size of messages (LIST)..."));
                break;
        case POP3_RETR:
+               gtk_progress_set_show_text
+                       (GTK_PROGRESS(inc_dialog->mainwin->progressbar), TRUE);
+               g_snprintf(buf, sizeof(buf), "%d / %d",
+                          session->cur_msg, session->count);
+               gtk_progress_set_format_string
+                       (GTK_PROGRESS(inc_dialog->mainwin->progressbar), buf);
                inc_recv_data_progressive
                        (SESSION(session), 0,
                         session->msg[session->cur_msg].size,
@@ -860,6 +871,8 @@ static gint inc_recv_data_progressive(Session *session, guint cur_len,
            pop3_session->state != POP3_DELETE &&
            pop3_session->state != POP3_LOGOUT) return 0;
 
+       if (!pop3_session->new_msg_exist) return 0;
+
        inc_dialog = (IncProgressDialog *)inc_session->data;
        dialog = inc_dialog->dialog;
 
index 0f39391..b03e8f8 100644 (file)
--- a/src/pop.c
+++ b/src/pop.c
@@ -212,9 +212,10 @@ static gint pop3_getrange_last_recv(Pop3Session *session, const gchar *msg)
                session->error_val = PS_PROTOCOL;
                return -1;
        } else {
-               if (session->count > last)
+               if (session->count > last) {
+                       session->new_msg_exist = TRUE;
                        session->cur_msg = last + 1;
-               else
+               else
                        session->cur_msg = 0;
        }