nntp account / forwarding / scoring
authorHoà Viêt Dinh <dinh.viet.hoa@free.fr>
Wed, 13 Jun 2001 09:38:24 +0000 (09:38 +0000)
committerHoà Viêt Dinh <dinh.viet.hoa@free.fr>
Wed, 13 Jun 2001 09:38:24 +0000 (09:38 +0000)
ChangeLog.claws
src/compose.c
src/prefs_account.c
src/summaryview.c

index 8349229..c58894d 100644 (file)
@@ -1,3 +1,16 @@
+2001-06-13 [hoa]
+
+       * src/compose.c
+       * src/prefs_account.c
+
+               SMTP server can be defined in the news account
+               mime type of attachment are kept.
+
+       * src/summaryview.c
+
+               now choose the highest important score between default
+               and important score of folder.
+
 2001-06-09 [alfons]
        
        * src/prefs_common.c: 
index bb16a76..1dbcba5 100644 (file)
@@ -152,6 +152,10 @@ static void compose_insert_file                    (Compose        *compose,
 static void compose_attach_append              (Compose        *compose,
                                                 const gchar    *file,
                                                 ContentType     cnttype);
+static void compose_attach_append_with_type(Compose *compose,
+                                           const gchar *file,
+                                           const gchar *type,
+                                           ContentType cnttype);
 static void compose_wrap_line                  (Compose        *compose);
 static void compose_set_title                  (Compose        *compose);
 
@@ -572,12 +576,23 @@ static gchar *procmime_get_file_name(MimeInfo *mimeinfo)
        base = mimeinfo->filename ? mimeinfo->filename
                : mimeinfo->name ? mimeinfo->name : NULL;
 
-       if (MIME_TEXT_HTML == mimeinfo->mime_type && base == NULL)
-               base = "mimetmp.html";
+       if (MIME_TEXT_HTML == mimeinfo->mime_type && base == NULL){
+               filename = g_strdup_printf("%s%smimetmp%i.html",
+                                          get_mime_tmp_dir(),
+                                          G_DIR_SEPARATOR_S,
+                                          mimeinfo);
+               return filename;
+       }
        else {
-               base = base ? base : "mimetmp";
+               base = base ? base : "";
                base = g_basename(base);
-               if (*base == '\0') base = "mimetmp";
+               if (*base == '\0') {
+                       filename = g_strdup_printf("%s%smimetmp%i",
+                                                  get_mime_tmp_dir(),
+                                                  G_DIR_SEPARATOR_S,
+                                                  mimeinfo);
+                       return filename;
+               }
        }
 
        filename = g_strconcat(get_mime_tmp_dir(), G_DIR_SEPARATOR_S,
@@ -725,8 +740,9 @@ static void compose_attach_parts(Compose * compose,
                {
                        filename = mime_extract_file(source, mimeinfo);
 
-                       compose_attach_append(compose, filename,
-                                             mimeinfo->mime_type);
+                       compose_attach_append_with_type(compose, filename,
+                                                       mimeinfo->content_type,
+                                                       mimeinfo->mime_type);
 
                        g_free(filename);
                }
@@ -735,8 +751,9 @@ static void compose_attach_parts(Compose * compose,
                {
                        filename = mime_extract_file(source, mimeinfo->sub);
 
-                       compose_attach_append(compose, filename,
-                                             mimeinfo->sub->mime_type);
+                       compose_attach_append_with_type(compose, filename,
+                                                       mimeinfo->content_type,
+                                                       mimeinfo->sub->mime_type);
 
                        g_free(filename);
                }
@@ -748,8 +765,9 @@ static void compose_attach_parts(Compose * compose,
                while (child) {
                        filename = mime_extract_file(source, child);
 
-                       compose_attach_append(compose, filename,
-                                             child->mime_type);
+                       compose_attach_append_with_type(compose, filename,
+                                                       child->content_type,
+                                                       child->mime_type);
 
                        g_free(filename);
 
@@ -1499,6 +1517,73 @@ static void compose_insert_file(Compose *compose, const gchar *file)
        fclose(fp);
 }
 
+static void compose_attach_info(Compose * compose, AttachInfo * ainfo,
+                               ContentType cnttype)
+{
+       gchar *text[N_ATTACH_COLS];
+       gint row;
+
+       text[COL_MIMETYPE] = ainfo->content_type;
+       text[COL_SIZE] = to_human_readable(ainfo->size);
+       text[COL_NAME] = ainfo->name;
+
+       row = gtk_clist_append(GTK_CLIST(compose->attach_clist), text);
+       gtk_clist_set_row_data(GTK_CLIST(compose->attach_clist), row, ainfo);
+
+       if (cnttype != MIME_MESSAGE_RFC822)
+               compose_changed_cb(NULL, compose);
+}
+
+static void compose_attach_append_with_type(Compose *compose,
+                                           const gchar *file,
+                                           const gchar *type,
+                                           ContentType cnttype)
+{
+       AttachInfo *ainfo;
+       off_t size;
+
+       if (!is_file_exist(file)) {
+               g_warning(_("File %s doesn't exist\n"), file);
+               return;
+       }
+       if ((size = get_file_size(file)) < 0) {
+               g_warning(_("Can't get file size of %s\n"), file);
+               return;
+       }
+       if (size == 0) {
+               alertpanel_notice(_("File %s is empty\n"), file);
+               return;
+       }
+
+       if (!compose->use_attach) {
+               GtkItemFactory *ifactory;
+               GtkWidget *menuitem;
+
+               ifactory = gtk_item_factory_from_widget(compose->menubar);
+               menuitem = gtk_item_factory_get_item(ifactory,
+                                                    "/Message/Attach");
+               gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem),
+                                              TRUE);
+       }
+
+       ainfo = g_new0(AttachInfo, 1);
+       ainfo->file = g_strdup(file);
+
+       if (cnttype == MIME_MESSAGE_RFC822) {
+               ainfo->encoding = ENC_7BIT;
+               ainfo->name = g_strdup_printf(_("Message: %s"),
+                                             g_basename(file));
+       } else {
+               ainfo->encoding = ENC_BASE64;
+               ainfo->name = g_strdup(g_basename(file));
+       }
+
+       ainfo->content_type = g_strdup(type);
+       ainfo->size = size;
+
+       compose_attach_info(compose, ainfo, cnttype);
+}
+
 static void compose_attach_append(Compose *compose, const gchar *file,
                                  ContentType cnttype)
 {
@@ -1549,15 +1634,7 @@ static void compose_attach_append(Compose *compose, const gchar *file,
        }
        ainfo->size = size;
 
-       text[COL_MIMETYPE] = ainfo->content_type;
-       text[COL_SIZE] = to_human_readable(size);
-       text[COL_NAME] = ainfo->name;
-
-       row = gtk_clist_append(GTK_CLIST(compose->attach_clist), text);
-       gtk_clist_set_row_data(GTK_CLIST(compose->attach_clist), row, ainfo);
-
-       if (cnttype != MIME_MESSAGE_RFC822)
-               compose_changed_cb(NULL, compose);
+       compose_attach_info(compose, ainfo, cnttype);
 }
 
 static void compose_wrap_line(Compose *compose)
@@ -1724,6 +1801,7 @@ gint compose_send(Compose *compose)
        if (compose->to_list) {
                PrefsAccount *ac;
 
+               /*
                if (compose->account->protocol != A_NNTP)
                        ac = compose->account;
                else if (compose->orig_account->protocol != A_NNTP)
@@ -1736,6 +1814,9 @@ gint compose_send(Compose *compose)
                                return -1;
                        }
                }
+               */
+               ac = compose->account;
+
                ok = send_message(tmp, ac, compose->to_list);
                statusbar_pop_all();
        }
index f9083f5..b4fb9e0 100644 (file)
@@ -724,12 +724,6 @@ static void prefs_account_basic_create(void)
        gtk_table_set_row_spacing (GTK_TABLE (serv_table), 3, 0);
        gtk_table_set_col_spacings (GTK_TABLE (serv_table), 8);
 
-       nntpauth_chkbtn = gtk_check_button_new_with_label
-               (_("This server requires authentication"));
-       gtk_widget_show (nntpauth_chkbtn);
-       gtk_table_attach (GTK_TABLE (serv_table), nntpauth_chkbtn, 0, 4, 4, 5,
-                         GTK_FILL, 0, 0, 0);
-
        nntpserv_entry = gtk_entry_new ();
        gtk_widget_show (nntpserv_entry);
        gtk_table_attach (GTK_TABLE (serv_table), nntpserv_entry, 1, 4, 0, 1,
@@ -737,41 +731,47 @@ static void prefs_account_basic_create(void)
                          GTK_EXPAND | GTK_SHRINK | GTK_FILL, 0, 0);
 /*     gtk_table_set_row_spacing (GTK_TABLE (serv_table), 0, 0); */
 
+       nntpauth_chkbtn = gtk_check_button_new_with_label
+               (_("This server requires authentication"));
+       gtk_widget_show (nntpauth_chkbtn);
+       gtk_table_attach (GTK_TABLE (serv_table), nntpauth_chkbtn, 0, 4, 1, 2,
+                         GTK_FILL, 0, 0, 0);
+
        recvserv_entry = gtk_entry_new ();
        gtk_widget_show (recvserv_entry);
-       gtk_table_attach (GTK_TABLE (serv_table), recvserv_entry, 1, 4, 1, 2,
+       gtk_table_attach (GTK_TABLE (serv_table), recvserv_entry, 1, 4, 2, 3,
                          GTK_EXPAND | GTK_SHRINK | GTK_FILL,
                          GTK_EXPAND | GTK_SHRINK | GTK_FILL, 0, 0);
 
        localmbox_entry = gtk_entry_new ();
        gtk_widget_show (localmbox_entry);
-       gtk_table_attach (GTK_TABLE (serv_table), localmbox_entry, 1, 4, 0, 1,
+       gtk_table_attach (GTK_TABLE (serv_table), localmbox_entry, 1, 4, 3, 4,
                          GTK_EXPAND | GTK_SHRINK | GTK_FILL,
                          GTK_EXPAND | GTK_SHRINK | GTK_FILL, 0, 0);
 
        smtpserv_entry = gtk_entry_new ();
        gtk_widget_show (smtpserv_entry);
-       gtk_table_attach (GTK_TABLE (serv_table), smtpserv_entry, 1, 4, 2, 3,
+       gtk_table_attach (GTK_TABLE (serv_table), smtpserv_entry, 1, 4, 4, 5,
                          GTK_EXPAND | GTK_SHRINK | GTK_FILL,
                          GTK_EXPAND | GTK_SHRINK | GTK_FILL, 0, 0);
 
        mailcmd_entry = gtk_entry_new ();
        gtk_widget_show (mailcmd_entry);
-       gtk_table_attach (GTK_TABLE (serv_table), mailcmd_entry, 1, 4, 7, 8,
+       gtk_table_attach (GTK_TABLE (serv_table), mailcmd_entry, 1, 4, 6, 7,
                          GTK_EXPAND | GTK_SHRINK | GTK_FILL,
                          GTK_EXPAND | GTK_SHRINK | GTK_FILL, 0, 0);
 
        uid_entry = gtk_entry_new ();
        gtk_widget_show (uid_entry);
        gtk_widget_set_usize (uid_entry, DEFAULT_ENTRY_WIDTH, -1);
-       gtk_table_attach (GTK_TABLE (serv_table), uid_entry, 1, 2, 5, 6,
+       gtk_table_attach (GTK_TABLE (serv_table), uid_entry, 1, 2, 7, 8,
                          GTK_EXPAND | GTK_SHRINK | GTK_FILL,
                          GTK_EXPAND | GTK_SHRINK | GTK_FILL, 0, 0);
 
        pass_entry = gtk_entry_new ();
        gtk_widget_show (pass_entry);
        gtk_widget_set_usize (pass_entry, DEFAULT_ENTRY_WIDTH, -1);
-       gtk_table_attach (GTK_TABLE (serv_table), pass_entry, 3, 4, 5, 6,
+       gtk_table_attach (GTK_TABLE (serv_table), pass_entry, 3, 4, 7, 8,
                          GTK_EXPAND | GTK_SHRINK | GTK_FILL,
                          GTK_EXPAND | GTK_SHRINK | GTK_FILL, 0, 0);
        gtk_entry_set_visibility (GTK_ENTRY (pass_entry), FALSE);
@@ -784,20 +784,20 @@ static void prefs_account_basic_create(void)
 
        recvserv_label = gtk_label_new (_("Server for receiving"));
        gtk_widget_show (recvserv_label);
-       gtk_table_attach (GTK_TABLE (serv_table), recvserv_label, 0, 1, 1, 2,
+       gtk_table_attach (GTK_TABLE (serv_table), recvserv_label, 0, 1, 2, 3,
                          GTK_FILL, 0, 0, 0);
        gtk_misc_set_alignment (GTK_MISC (recvserv_label), 1, 0.5);
 
        localmbox_label = gtk_label_new (_("Local mailbox file"));
        gtk_widget_show (localmbox_label);
-       gtk_table_attach (GTK_TABLE (serv_table), localmbox_label, 0, 1, 0, 1,
+       gtk_table_attach (GTK_TABLE (serv_table), localmbox_label, 0, 1, 3, 4,
                          GTK_FILL, 0, 0, 0);
        gtk_misc_set_alignment (GTK_MISC (localmbox_label), 1, 0.5);
 /*     gtk_table_set_row_spacing (GTK_TABLE (serv_table), 2, 0); */
 
        smtpserv_label = gtk_label_new (_("SMTP server (send)"));
        gtk_widget_show (smtpserv_label);
-       gtk_table_attach (GTK_TABLE (serv_table), smtpserv_label, 0, 1, 2, 3,
+       gtk_table_attach (GTK_TABLE (serv_table), smtpserv_label, 0, 1, 4, 5,
                          GTK_FILL, 0, 0, 0);
        gtk_misc_set_alignment (GTK_MISC (smtpserv_label), 1, 0.5);
 /*     gtk_table_set_row_spacing (GTK_TABLE (serv_table), 2, 0); */
@@ -805,7 +805,7 @@ static void prefs_account_basic_create(void)
        mailcmd_chkbtn = gtk_check_button_new_with_label
                (_("Use mail command rather than SMTP server"));
        gtk_widget_show (mailcmd_chkbtn);
-       gtk_table_attach (GTK_TABLE (serv_table), mailcmd_chkbtn, 0, 4, 6, 7,
+       gtk_table_attach (GTK_TABLE (serv_table), mailcmd_chkbtn, 0, 4, 5, 6,
                          GTK_EXPAND | GTK_FILL,
                          0, 0, TABLE_YPAD);
        gtk_signal_connect(GTK_OBJECT(mailcmd_chkbtn), "toggled",
@@ -814,20 +814,20 @@ static void prefs_account_basic_create(void)
 
        mailcmd_label = gtk_label_new (_("command to send mails"));
        gtk_widget_show (mailcmd_label);
-       gtk_table_attach (GTK_TABLE (serv_table), mailcmd_label, 0, 1, 7, 8,
+       gtk_table_attach (GTK_TABLE (serv_table), mailcmd_label, 0, 1, 6, 7,
                          GTK_FILL, 0, 0, 0);
        gtk_misc_set_alignment (GTK_MISC (mailcmd_label), 1, 0.5);
 /*     gtk_table_set_row_spacing (GTK_TABLE (serv_table), 2, 0); */
 
        uid_label = gtk_label_new (_("User ID"));
        gtk_widget_show (uid_label);
-       gtk_table_attach (GTK_TABLE (serv_table), uid_label, 0, 1, 5, 6,
+       gtk_table_attach (GTK_TABLE (serv_table), uid_label, 0, 1, 7, 8,
                          GTK_FILL, 0, 0, 0);
        gtk_misc_set_alignment (GTK_MISC (uid_label), 1, 0.5);
 
        pass_label = gtk_label_new (_("Password"));
        gtk_widget_show (pass_label);
-       gtk_table_attach (GTK_TABLE (serv_table), pass_label, 2, 3, 5, 6,
+       gtk_table_attach (GTK_TABLE (serv_table), pass_label, 2, 3, 7, 8,
                          0, 0, 0, 0);
 
        SET_TOGGLE_SENSITIVITY (nntpauth_chkbtn, uid_label);
@@ -1402,13 +1402,23 @@ static void prefs_account_protocol_activated(GtkMenuItem *menuitem)
                gtk_widget_show(basic.nntpauth_chkbtn);
                gtk_widget_hide(basic.recvserv_label);
                gtk_widget_hide(basic.recvserv_entry);
-               gtk_widget_hide(basic.smtpserv_label);
-               gtk_widget_hide(basic.smtpserv_entry);
+               gtk_widget_show(basic.smtpserv_label);
+               gtk_widget_show(basic.smtpserv_entry);
                gtk_widget_hide(basic.localmbox_label);
                gtk_widget_hide(basic.localmbox_entry);
                gtk_widget_hide(basic.mailcmd_label);
                gtk_widget_hide(basic.mailcmd_entry);
                gtk_widget_hide(basic.mailcmd_chkbtn);
+               gtk_widget_show(basic.uid_label);
+               gtk_widget_show(basic.pass_label);
+               gtk_widget_show(basic.uid_entry);
+               gtk_widget_show(basic.pass_entry);
+
+               gtk_widget_set_sensitive(basic.uid_label,  TRUE);
+               gtk_widget_set_sensitive(basic.pass_label, TRUE);
+               gtk_widget_set_sensitive(basic.uid_entry,  TRUE);
+               gtk_widget_set_sensitive(basic.pass_entry, TRUE);
+
 /*             gtk_table_set_row_spacing (GTK_TABLE (basic.serv_table), 3, 0); */
                /* update userid/passwd sensitive state */
                prefs_account_nntpauth_toggled
@@ -1433,6 +1443,10 @@ static void prefs_account_protocol_activated(GtkMenuItem *menuitem)
                gtk_widget_show(basic.mailcmd_label);
                gtk_widget_show(basic.mailcmd_entry);
                gtk_widget_show(basic.mailcmd_chkbtn);
+               gtk_widget_hide(basic.uid_label);
+               gtk_widget_hide(basic.pass_label);
+               gtk_widget_hide(basic.uid_entry);
+               gtk_widget_hide(basic.pass_entry);
 /*             gtk_table_set_row_spacing */
 /*                     (GTK_TABLE (basic.serv_table), 3, VSPACING_NARROW); */
                gtk_widget_set_sensitive(basic.uid_label,  TRUE);
@@ -1443,36 +1457,9 @@ static void prefs_account_protocol_activated(GtkMenuItem *menuitem)
                prefs_account_mailcmd_toggled
                        (GTK_TOGGLE_BUTTON(basic.mailcmd_chkbtn), NULL);
                break;
-               /*
-       case A_LOCAL_CMD:
-               gtk_widget_set_sensitive(basic.inbox_label, TRUE);
-               gtk_widget_set_sensitive(basic.inbox_entry, TRUE);
-               gtk_widget_hide(basic.nntpserv_label);
-               gtk_widget_hide(basic.nntpserv_entry);
-               gtk_widget_hide(basic.nntpauth_chkbtn);
-               gtk_widget_set_sensitive(basic.recvserv_label, FALSE);
-               gtk_widget_set_sensitive(basic.recvserv_entry, FALSE);
-               gtk_widget_hide(basic.recvserv_label);
-               gtk_widget_hide(basic.recvserv_entry);
-               gtk_widget_hide(basic.smtpserv_label);
-               gtk_widget_hide(basic.smtpserv_entry);
-               gtk_widget_show(basic.localmbox_label);
-               gtk_widget_show(basic.localmbox_entry);
-               gtk_widget_show(basic.mailcmd_label);
-               gtk_widget_show(basic.mailcmd_entry);
-               gtk_widget_hide(basic.mailcmd_chkbtn);
-               gtk_table_set_row_spacing
-                       (GTK_TABLE (basic.serv_table), 3, VSPACING_NARROW);
-               gtk_widget_set_sensitive(basic.uid_label,  FALSE);
-               gtk_widget_set_sensitive(basic.pass_label, FALSE);
-               gtk_widget_set_sensitive(basic.uid_entry,  FALSE);
-               gtk_widget_set_sensitive(basic.pass_entry, FALSE);
-               gtk_widget_set_sensitive(receive.pop3_frame, FALSE);
-               break;
-               */
        case A_IMAP4:
-               gtk_widget_set_sensitive(basic.inbox_label, TRUE);
-               gtk_widget_set_sensitive(basic.inbox_entry, TRUE);
+               gtk_widget_set_sensitive(basic.inbox_label, FALSE);
+               gtk_widget_set_sensitive(basic.inbox_entry, FALSE);
                gtk_widget_hide(basic.nntpserv_label);
                gtk_widget_hide(basic.nntpserv_entry);
                gtk_widget_set_sensitive(basic.nntpauth_chkbtn, FALSE);
@@ -1488,6 +1475,10 @@ static void prefs_account_protocol_activated(GtkMenuItem *menuitem)
                gtk_widget_hide(basic.mailcmd_label);
                gtk_widget_hide(basic.mailcmd_entry);
                gtk_widget_hide(basic.mailcmd_chkbtn);
+               gtk_widget_show(basic.uid_label);
+               gtk_widget_show(basic.pass_label);
+               gtk_widget_show(basic.uid_entry);
+               gtk_widget_show(basic.pass_entry);
 /*             gtk_table_set_row_spacing */
 /*                     (GTK_TABLE (basic.serv_table), 3, VSPACING_NARROW); */
                gtk_widget_set_sensitive(basic.uid_label,  TRUE);
@@ -1518,6 +1509,10 @@ static void prefs_account_protocol_activated(GtkMenuItem *menuitem)
                gtk_widget_hide(basic.mailcmd_label);
                gtk_widget_hide(basic.mailcmd_entry);
                gtk_widget_hide(basic.mailcmd_chkbtn);
+               gtk_widget_show(basic.uid_label);
+               gtk_widget_show(basic.pass_label);
+               gtk_widget_show(basic.uid_entry);
+               gtk_widget_show(basic.pass_entry);
 /*             gtk_table_set_row_spacing */
 /*                     (GTK_TABLE (basic.serv_table), 3, VSPACING_NARROW); */
                gtk_widget_set_sensitive(basic.uid_label,  TRUE);
index 2030e52..4c104bc 100644 (file)
@@ -1512,7 +1512,7 @@ static void summary_set_ctree_from_list(SummaryView *summaryview,
 
        if (global_scoring || summaryview->folder_item->prefs->scoring) {
                summaryview->important_score = prefs_common.important_score;
-               if (summaryview->folder_item->prefs->important_score <
+               if (summaryview->folder_item->prefs->important_score >
                    summaryview->important_score)
                        summaryview->important_score =
                                summaryview->folder_item->prefs->important_score;