added ylwrap to .cvsignore
authorChristoph Hohmann <reboot@gmx.ch>
Fri, 23 Nov 2001 15:58:59 +0000 (15:58 +0000)
committerChristoph Hohmann <reboot@gmx.ch>
Fri, 23 Nov 2001 15:58:59 +0000 (15:58 +0000)
fixed gpg signing and encodin
added --status option to get new, unread and total message count from a running sylpheed
temporary fix for reply_with_quote problem (don't call functions for non existing widget)
one more check for ignored threads

ChangeLog.claws
configure.in
src/.cvsignore
src/compose.c
src/folder.c
src/folder.h
src/main.c
src/prefs_common.c
src/procmsg.c

index af37ca8fa0e74e04f0c11ae6bddd9af387209b7e..b32eb3ce47d2c6a9e00f10b5cc5bb18262fadc29 100644 (file)
@@ -1,3 +1,21 @@
+2001-11-23 [christoph] 0.6.5claws29
+
+       * src/.cvsignore
+               added ylwrap
+       * src/compose.c
+               fixed gpg signing and encoding
+       * src/folder.[ch]
+       * src/main.c
+               added --status option to get new, unread and total
+               message count from a running sylpheed
+       * src/prefs_common.c
+               temporary fix for reply_with_quote problem
+               (don't call functions for non existing widget)
+       * src/procmsg.c
+               one more check for ignored threads but still not
+               always working correctly. probably a recursive
+               check for all parents is needed
+
 2001-11-23 [darko]     0.6.5claws28
 
        * src/compose.c
 2001-11-23 [darko]     0.6.5claws28
 
        * src/compose.c
 
 2001-11-13 [christoph] 0.6.5claws11
 
 
 2001-11-13 [christoph] 0.6.5claws11
 
+       * src/compose.c
                Cleanup a mess i add before commiting
 
 2001-11-13 [hoa]       0.6.5claws10
                Cleanup a mess i add before commiting
 
 2001-11-13 [hoa]       0.6.5claws10
index 264b2c41f8699b507610d3b5af67a14aeb44521c..e2f3d01e80c30371fbfa2c448dd05a30b8da3558 100644 (file)
@@ -8,7 +8,7 @@ MINOR_VERSION=6
 MICRO_VERSION=5
 INTERFACE_AGE=0
 BINARY_AGE=0
 MICRO_VERSION=5
 INTERFACE_AGE=0
 BINARY_AGE=0
-EXTRA_VERSION=claws28
+EXTRA_VERSION=claws29
 VERSION=$MAJOR_VERSION.$MINOR_VERSION.$MICRO_VERSION$EXTRA_VERSION
 
 dnl
 VERSION=$MAJOR_VERSION.$MINOR_VERSION.$MICRO_VERSION$EXTRA_VERSION
 
 dnl
index 5ef28fb0f988262d34f10203cc457ae244fcadae..9692b5f2d839045f56bf53dde89f9bf2f65524e1 100644 (file)
@@ -13,3 +13,4 @@ matcher_parser_lex.c
 matcher_parser_parse.c
 matcher_parser_parse.h
 version.h
 matcher_parser_parse.c
 matcher_parser_parse.h
 version.h
+ylwrap
index aab357d525f34d25869410f5f5fb449bd131b154..cf4b4c2e61fe0cf5905f95418e086dbf5be1b6cc 100644 (file)
@@ -2840,7 +2840,7 @@ static gint compose_bounce_write_to_file(Compose *compose, const gchar *file)
                return -1;
        }
 
                return -1;
        }
 
-       if ((fdest = fopen(file, "a+")) == NULL) {
+       if ((fdest = fopen(file, "w")) == NULL) {
                FILE_OP_ERROR(file, "fopen");
                fclose(fp);
                return -1;
                FILE_OP_ERROR(file, "fopen");
                fclose(fp);
                return -1;
@@ -2893,7 +2893,7 @@ static gint compose_write_to_file(Compose *compose, const gchar *file,
        const gchar *out_codeset;
        EncodingType encoding;
 
        const gchar *out_codeset;
        EncodingType encoding;
 
-       if ((fp = fopen(file, "a+")) == NULL) {
+       if ((fp = fopen(file, "w")) == NULL) {
                FILE_OP_ERROR(file, "fopen");
                return -1;
        }
                FILE_OP_ERROR(file, "fopen");
                return -1;
        }
@@ -3117,7 +3117,7 @@ static gint compose_remove_reedit_target(Compose *compose)
 static gint compose_queue(Compose *compose, gint *msgnum, FolderItem **item)
 {
        FolderItem *queue;
 static gint compose_queue(Compose *compose, gint *msgnum, FolderItem **item)
 {
        FolderItem *queue;
-       gchar *tmpfilename, *queue_path;
+       gchar *tmp, *tmp2, *queue_path;
        FILE *fp, *src_fp;
        GSList *cur;
        gchar buf[BUFFSIZE];
        FILE *fp, *src_fp;
        GSList *cur;
        gchar buf[BUFFSIZE];
@@ -3143,22 +3143,6 @@ static gint compose_queue(Compose *compose, gint *msgnum, FolderItem **item)
                 return -1;
         }
 
                 return -1;
         }
 
-        if (prefs_common.linewrap_at_send)
-               compose_wrap_line_all(compose);
-                       
-       /* write to temporary file */
-       tmpfilename = g_strdup_printf("%s%cqueue.%d", g_get_tmp_dir(),
-                                     G_DIR_SEPARATOR, (gint)compose);
-       if ((fp = fopen(tmpfilename, "w")) == NULL) {
-               FILE_OP_ERROR(tmpfilename, "fopen");
-               g_free(tmpfilename);
-               return -1;
-       }
-       if (change_file_mode_rw(fp, tmpfilename) < 0) {
-               FILE_OP_ERROR(tmpfilename, "chmod");
-               g_warning(_("can't change file mode\n"));
-       }
-
        if(compose->to_list) {
                if (compose->account->protocol != A_NNTP)
                        mailac = compose->account;
        if(compose->to_list) {
                if (compose->account->protocol != A_NNTP)
                        mailac = compose->account;
@@ -3167,7 +3151,6 @@ static gint compose_queue(Compose *compose, gint *msgnum, FolderItem **item)
                else if (cur_account && cur_account->protocol != A_NNTP)
                        mailac = cur_account;
                else if (!(mailac = compose_current_mail_account())) {
                else if (cur_account && cur_account->protocol != A_NNTP)
                        mailac = cur_account;
                else if (!(mailac = compose_current_mail_account())) {
-                       unlink(tmpfilename);
                        lock = FALSE;
                        alertpanel_error(_("No account for sending mails available!"));
                        return -1;
                        lock = FALSE;
                        alertpanel_error(_("No account for sending mails available!"));
                        return -1;
@@ -3178,13 +3161,56 @@ static gint compose_queue(Compose *compose, gint *msgnum, FolderItem **item)
                 if (compose->account->protocol == A_NNTP)
                         newsac = compose->account;
                 else if(!(newsac = compose->orig_account) || (newsac->protocol != A_NNTP)) {
                 if (compose->account->protocol == A_NNTP)
                         newsac = compose->account;
                 else if(!(newsac = compose->orig_account) || (newsac->protocol != A_NNTP)) {
-                       unlink(tmpfilename);
                        lock = FALSE;
                        alertpanel_error(_("No account for posting news available!"));
                        return -1;
                }                       
        }
 
                        lock = FALSE;
                        alertpanel_error(_("No account for posting news available!"));
                        return -1;
                }                       
        }
 
+        if (prefs_common.linewrap_at_send)
+               compose_wrap_line_all(compose);
+                       
+       /* write to temporary file */
+       tmp2 = g_strdup_printf("%s%ctmp%d", g_get_tmp_dir(),
+                                     G_DIR_SEPARATOR, (gint)compose);
+
+       if (compose->bounce_filename != NULL) {
+               if (compose_bounce_write_to_file(compose, tmp2) < 0) {
+                       unlink(tmp2);
+                       lock = FALSE;
+                       return -1;
+               }
+       }
+       else {
+               if (compose_write_to_file(compose, tmp2, FALSE) < 0) {
+                       unlink(tmp2);
+                       lock = FALSE;
+                       return -1;
+               }
+       }
+
+       /* add queue header */
+       tmp = g_strdup_printf("%s%cqueue.%d", g_get_tmp_dir(),
+                                     G_DIR_SEPARATOR, (gint)compose);
+       if ((fp = fopen(tmp, "w")) == NULL) {
+               FILE_OP_ERROR(tmp, "fopen");
+               g_free(tmp);
+               return -1;
+       }
+       if ((src_fp = fopen(tmp2, "r")) == NULL) {
+               FILE_OP_ERROR(tmp2, "fopen");
+               fclose(fp);
+               unlink(tmp);
+               g_free(tmp);
+               unlink(tmp2);
+               g_free(tmp2);
+               return -1;
+       }
+       if (change_file_mode_rw(fp, tmp) < 0) {
+               FILE_OP_ERROR(tmp, "chmod");
+               g_warning(_("can't change file mode\n"));
+       }
+
        /* queueing variables */
        fprintf(fp, "AF:\n");
        fprintf(fp, "NF:0\n");
        /* queueing variables */
        fprintf(fp, "AF:\n");
        fprintf(fp, "NF:0\n");
@@ -3233,21 +3259,27 @@ static gint compose_queue(Compose *compose, gint *msgnum, FolderItem **item)
                fprintf(fp, "NAID:%d\n", newsac->account_id);
        }
        fprintf(fp, "\n");
                fprintf(fp, "NAID:%d\n", newsac->account_id);
        }
        fprintf(fp, "\n");
-       fclose(fp);
 
 
-       if (compose->bounce_filename != NULL) {
-               if (compose_bounce_write_to_file(compose, tmpfilename) < 0) {
-                       unlink(tmpfilename);
-                       lock = FALSE;
+       while (fgets(buf, sizeof(buf), src_fp) != NULL) {
+               if (fputs(buf, fp) == EOF) {
+                       FILE_OP_ERROR(tmp, "fputs");
+                       fclose(fp);
+                       fclose(src_fp);
+                       unlink(tmp);
+                       g_free(tmp);
+                       unlink(tmp2);
+                       g_free(tmp2);
                        return -1;
                }
        }
                        return -1;
                }
        }
-       else {
-               if (compose_write_to_file(compose, tmpfilename, FALSE) < 0) {
-                       unlink(tmpfilename);
-                       lock = FALSE;
-                       return -1;
-               }
+       fclose(src_fp);
+       if (fclose(fp) == EOF) {
+               FILE_OP_ERROR(tmp, "fclose");
+               unlink(tmp);
+               g_free(tmp);
+               unlink(tmp2);
+               g_free(tmp2);
+               return -1;
        }
                                                
        /* queue message */
        }
                                                
        /* queue message */
@@ -3257,14 +3289,17 @@ static gint compose_queue(Compose *compose, gint *msgnum, FolderItem **item)
        queue_path = folder_item_get_path(queue);
        if (!is_dir_exist(queue_path))
                make_dir_hier(queue_path);
        queue_path = folder_item_get_path(queue);
        if (!is_dir_exist(queue_path))
                make_dir_hier(queue_path);
-       if ((num = folder_item_add_msg(queue, tmpfilename, TRUE)) < 0) {
+       if ((num = folder_item_add_msg(queue, tmp, TRUE)) < 0) {
                g_warning(_("can't queue the message\n"));
                g_warning(_("can't queue the message\n"));
-               unlink(tmpfilename);
-               g_free(tmpfilename);
+               unlink(tmp);
+               g_free(tmp);
                g_free(queue_path);
                return -1;
        }
                g_free(queue_path);
                return -1;
        }
-       g_free(tmpfilename);
+       unlink(tmp);
+       g_free(tmp);
+       unlink(tmp2);
+       g_free(tmp2);
 
        if (compose->mode == COMPOSE_REEDIT) {
                compose_remove_reedit_target(compose);
 
        if (compose->mode == COMPOSE_REEDIT) {
                compose_remove_reedit_target(compose);
index 1f467868408231e98d8dc5e60543067c9bcae8ed..55ea06b74fe32d4ac61fd4af6c3dd0d0b5be7177 100644 (file)
@@ -1499,3 +1499,41 @@ FolderItem * folder_find_item_from_identifier(const gchar *identifier)
                        folder_item_find_func, d);
        return d[1];
 }
                        folder_item_find_func, d);
        return d[1];
 }
+
+static void folder_count_total_newmsgs_func(const GNode *node, guint *newmsgs, 
+                                           guint *unreadmsgs, guint *totalmsgs)
+{
+       if (node->data) {
+               FolderItem *item = node->data;
+               *newmsgs += item->new;
+               *unreadmsgs += item->unread;
+               *totalmsgs += item->total;
+       }
+       if (node->children)
+               folder_count_total_newmsgs_func(node->children, newmsgs, unreadmsgs, totalmsgs);
+       if (node->next)
+               folder_count_total_newmsgs_func(node->next, newmsgs, unreadmsgs, totalmsgs);
+}
+
+void folder_count_total_msgs(guint *newmsgs, guint *unreadmsgs, guint *totalmsgs)
+{
+       GList *list;
+       Folder *folder;
+
+       *newmsgs = 0;
+       *unreadmsgs = 0;
+       *totalmsgs = 0;
+
+       debug_print(_("Counting total number of messages...\n"));
+       list = folder_get_list();
+       for (; list != NULL; list = list->next) {
+               folder = FOLDER(list->data);
+               if (folder->node)
+                       folder_count_total_newmsgs_func(folder->node, newmsgs, unreadmsgs, totalmsgs);
+       }
+       debug_print(_("  New: %d\n"), *newmsgs);
+       debug_print(_("  Unread: %d\n"), *unreadmsgs);
+       debug_print(_("  Total: %d\n"), *totalmsgs);
+
+       return;
+}
index 82e5adf30e66769c48cfabb87b0cb0accc682807..66cfe1f8e2afdbf8a9be9264c7a8cfe0f2b5d6b4 100644 (file)
@@ -262,10 +262,13 @@ void        folder_tree_destroy   (Folder         *folder);
 
 void   folder_add              (Folder         *folder);
 
 
 void   folder_add              (Folder         *folder);
 
-GList *folder_get_list         (void);
-gint   folder_read_list                (void);
-void   folder_write_list       (void);
-void   folder_update_op_count  (void);
+GList *folder_get_list                 (void);
+gint   folder_read_list                        (void);
+void   folder_write_list               (void);
+void   folder_update_op_count          (void);
+void   folder_count_total_msgs         (guint *newmsgs,
+                                        guint *unreadmsgs,
+                                        guint *totalmsgs);
 
 Folder     *folder_find_from_path      (const gchar    *path);
 FolderItem *folder_find_item_from_path (const gchar    *path);
 
 Folder     *folder_find_from_path      (const gchar    *path);
 FolderItem *folder_find_item_from_path (const gchar    *path);
index b0b05b3a7958df69db610b3a0964ca955e1eb837..393021c471bdf04666c3d61ccb284d8991dff19d 100644 (file)
@@ -93,6 +93,7 @@ static struct Cmd {
        gboolean receive_all;
        gboolean compose;
        const gchar *compose_mailto;
        gboolean receive_all;
        gboolean compose;
        const gchar *compose_mailto;
+       gboolean status;
 } cmd;
 
 static void parse_cmd_opt(int argc, char *argv[]);
 } cmd;
 
 static void parse_cmd_opt(int argc, char *argv[]);
@@ -194,7 +195,11 @@ int main(int argc, char *argv[])
        /* check and create unix domain socket */
        lock_socket = prohibit_duplicate_launch();
        if (lock_socket < 0) return 0;
        /* check and create unix domain socket */
        lock_socket = prohibit_duplicate_launch();
        if (lock_socket < 0) return 0;
-    
+       if (cmd.status) {
+               puts("0 Sylpheed not running.\n");
+               return 0;
+       }
+
        /* backup if old rc file exists */
        if (is_file_exist(RC_DIR)) {
                if (rename(RC_DIR, RC_DIR ".bak") < 0)
        /* backup if old rc file exists */
        if (is_file_exist(RC_DIR)) {
                if (rename(RC_DIR, RC_DIR ".bak") < 0)
@@ -333,6 +338,8 @@ static void parse_cmd_opt(int argc, char *argv[])
                } else if (!strncmp(argv[i], "--version", 9)) {
                        puts("Sylpheed version " VERSION);
                        exit(0);
                } else if (!strncmp(argv[i], "--version", 9)) {
                        puts("Sylpheed version " VERSION);
                        exit(0);
+               } else if (!strncmp(argv[i], "--status", 5)) {
+                       cmd.status = TRUE;
                } else if (!strncmp(argv[i], "--help", 6)) {
                        g_print(_("Usage: %s [OPTION]...\n"),
                                g_basename(argv[0]));
                } else if (!strncmp(argv[i], "--help", 6)) {
                        g_print(_("Usage: %s [OPTION]...\n"),
                                g_basename(argv[0]));
@@ -470,6 +477,12 @@ static gint prohibit_duplicate_launch(void)
 
                fd_write(uxsock, compose_str, strlen(compose_str));
                g_free(compose_str);
 
                fd_write(uxsock, compose_str, strlen(compose_str));
                g_free(compose_str);
+       } else if (cmd.status) {
+               gchar buf[BUFFSIZE];
+
+               fd_write(uxsock, "status\n", 9);
+               fd_gets(uxsock, buf, sizeof(buf));
+               puts(buf);
        } else
                fd_write(uxsock, "popup\n", 6);
 
        } else
                fd_write(uxsock, "popup\n", 6);
 
@@ -487,7 +500,6 @@ static void lock_socket_input_cb(gpointer data,
 
        sock = fd_accept(source);
        fd_gets(sock, buf, sizeof(buf));
 
        sock = fd_accept(source);
        fd_gets(sock, buf, sizeof(buf));
-       fd_close(sock);
 
        if (!strncmp(buf, "popup", 5)){
                main_window_popup(mainwin);
 
        if (!strncmp(buf, "popup", 5)){
                main_window_popup(mainwin);
@@ -499,7 +511,15 @@ static void lock_socket_input_cb(gpointer data,
                inc_mail(mainwin);
        } else if (!strncmp(buf, "compose", 7)) {
                open_compose_new_with_recipient(buf + strlen("compose") + 1);
                inc_mail(mainwin);
        } else if (!strncmp(buf, "compose", 7)) {
                open_compose_new_with_recipient(buf + strlen("compose") + 1);
+       } else if (!strncmp(buf, "status", 6)) {
+               gchar buf[BUFFSIZE];
+               guint newmsgs, unreadmsgs, totalmsgs;
+
+               folder_count_total_msgs(&newmsgs, &unreadmsgs, &totalmsgs);
+               snprintf(buf, sizeof(buf), "%d %d %d\n", newmsgs, unreadmsgs, totalmsgs);
+               fd_write(sock, buf, strlen(buf));
        }
        }
+       fd_close(sock);
 }
 
 static void open_compose_new_with_recipient(const gchar *address)
 }
 
 static void open_compose_new_with_recipient(const gchar *address)
index d9e0bfeb794c0ee5ed4b07fdcf9bb53c3af1fd86..c06c429271b0b4781e3df35eb8faf4c9bb29ee5c 100644 (file)
@@ -350,8 +350,7 @@ static PrefParam param[] = {
         prefs_dictionary_set_data_from_optmenu, prefs_dictionary_set_optmenu },
 #endif
        {"reply_with_quote", "TRUE", &prefs_common.reply_with_quote, P_BOOL,
         prefs_dictionary_set_data_from_optmenu, prefs_dictionary_set_optmenu },
 #endif
        {"reply_with_quote", "TRUE", &prefs_common.reply_with_quote, P_BOOL,
-        &compose.checkbtn_quote,
-        prefs_set_data_from_toggle, prefs_set_toggle},
+        NULL, NULL, NULL},
 
        /* Account autoselection */
        {"reply_account_autoselect", "TRUE",
 
        /* Account autoselection */
        {"reply_account_autoselect", "TRUE",
index 17b80c00c0f96ba4ef46113736b91b90472296aa..c141f09264fcefa10b9d96463e6a7cf31d2ecdf2 100644 (file)
@@ -547,13 +547,13 @@ GNode *procmsg_get_thread_tree(GSList *mlist)
                next = node->next;
                msginfo = (MsgInfo *)node->data;
                parent = NULL;
                next = node->next;
                msginfo = (MsgInfo *)node->data;
                parent = NULL;
-               /* CLAWS: ignore thread */
                if (msginfo->inreplyto) 
                        parent = g_hash_table_lookup(msgid_table, msginfo->inreplyto);
                if (parent && parent != node) {
                        g_node_unlink(node);
                        g_node_insert_before
                                (parent, parent->children, node);
                if (msginfo->inreplyto) 
                        parent = g_hash_table_lookup(msgid_table, msginfo->inreplyto);
                if (parent && parent != node) {
                        g_node_unlink(node);
                        g_node_insert_before
                                (parent, parent->children, node);
+                       /* CLAWS: ignore thread */
                        if(MSG_IS_IGNORE_THREAD(((MsgInfo *)parent->data)->flags)) {
                                MSG_SET_PERM_FLAGS(msginfo->flags, MSG_IGNORE_THREAD);
                        }
                        if(MSG_IS_IGNORE_THREAD(((MsgInfo *)parent->data)->flags)) {
                                MSG_SET_PERM_FLAGS(msginfo->flags, MSG_IGNORE_THREAD);
                        }
@@ -584,6 +584,10 @@ GNode *procmsg_get_thread_tree(GSList *mlist)
                        if (parent) {
                                g_node_unlink(node);
                                g_node_append(parent, node);
                        if (parent) {
                                g_node_unlink(node);
                                g_node_append(parent, node);
+                               /* CLAWS: ignore thread */
+                               if(MSG_IS_IGNORE_THREAD(((MsgInfo *)parent->data)->flags)) {
+                                       MSG_SET_PERM_FLAGS(msginfo->flags, MSG_IGNORE_THREAD);
+                               }
                        }
                }                                       
                node = next;
                        }
                }                                       
                node = next;