2011-12-29 [pawel] 3.8.0cvs8
authorPaweł Pękala <c0rn@gazeta.pl>
Thu, 29 Dec 2011 23:16:23 +0000 (23:16 +0000)
committerPaweł Pękala <c0rn@gazeta.pl>
Thu, 29 Dec 2011 23:16:23 +0000 (23:16 +0000)
* src/compose.c
* src/compose.h
* src/main.c
* src/mimeview.c
Make forwarding selected attachment possible from
mimeview's context menu
Fixex bug #2047 'forward attachments'

ChangeLog
PATCHSETS
configure.ac
src/compose.c
src/compose.h
src/main.c
src/mimeview.c

index 6e68f048085a435ad0866dcf23bde5e902312a8e..d7c434aa6a05833d93257dd6ba42da12001930e2 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,13 @@
+2011-12-29 [pawel]     3.8.0cvs8
+
+       * src/compose.c
+       * src/compose.h
+       * src/main.c
+       * src/mimeview.c
+               Make forwarding selected attachment possible from
+               mimeview's context menu
+               Fixex bug #2047 'forward attachments'
+
 2011-12-28 [paul]      3.8.0cvs7
 
        * src/prefs_account.c
index a4dc1d4d01d8370364c0730b69c1c529c47bc3aa..3dafa820835fffae28a346c8ed759bd5132feb69 100644 (file)
--- a/PATCHSETS
+++ b/PATCHSETS
 ( cvs diff -u -r 1.83.2.184 -r 1.83.2.185 src/mimeview.c;  ) > 3.8.0cvs5.patchset
 ( cvs diff -u -r 1.83.2.185 -r 1.83.2.186 src/mimeview.c;  ) > 3.8.0cvs6.patchset
 ( cvs diff -u -r 1.105.2.171 -r 1.105.2.172 src/prefs_account.c;  ) > 3.8.0cvs7.patchset
+( cvs diff -u -r 1.382.2.597 -r 1.382.2.598 src/compose.c;  cvs diff -u -r 1.50.2.64 -r 1.50.2.65 src/compose.h;  cvs diff -u -r 1.115.2.244 -r 1.115.2.245 src/main.c;  cvs diff -u -r 1.83.2.186 -r 1.83.2.187 src/mimeview.c;  ) > 3.8.0cvs8.patchset
index c892fae2f307afae83e1b879e59c283cdb116307..c2884d8e2f6f2e3d0a230f32748d21b55b969e22 100644 (file)
@@ -12,7 +12,7 @@ MINOR_VERSION=8
 MICRO_VERSION=0
 INTERFACE_AGE=0
 BINARY_AGE=0
-EXTRA_VERSION=7
+EXTRA_VERSION=8
 EXTRA_RELEASE=
 EXTRA_GTK2_VERSION=
 
index 9b5963a4659c00e5f00c5dfcf8a51e6b86dcda82..ae3785d1f8d85939d8ed34aab23881aee110482b 100644 (file)
@@ -180,7 +180,7 @@ static GList *compose_list = NULL;
 static Compose *compose_generic_new                    (PrefsAccount   *account,
                                                 const gchar    *to,
                                                 FolderItem     *item,
-                                                GPtrArray      *attach_files,
+                                                GList          *attach_files,
                                                 GList          *listAddress );
 
 static Compose *compose_create                 (PrefsAccount   *account,
@@ -891,7 +891,7 @@ static void compose_create_tags(GtkTextView *text, Compose *compose)
 }
 
 Compose *compose_new(PrefsAccount *account, const gchar *mailto,
-                    GPtrArray *attach_files)
+                    GList *attach_files)
 {
        return compose_generic_new(account, mailto, NULL, attach_files, NULL);
 }
@@ -951,7 +951,7 @@ static gchar *compose_get_save_to(Compose *compose)
 }
 
 Compose *compose_generic_new(PrefsAccount *account, const gchar *mailto, FolderItem *item,
-                            GPtrArray *attach_files, GList *listAddress )
+                            GList *attach_files, GList *listAddress )
 {
        Compose *compose;
        GtkTextView *textview;
@@ -1159,12 +1159,13 @@ Compose *compose_generic_new(PrefsAccount *account, const gchar *mailto, FolderI
        procmsg_msginfo_free( dummyinfo );
 
        if (attach_files) {
-               gint i;
-               gchar *file;
+               GList *curr;
+               AttachInfo *ainfo;
 
-               for (i = 0; i < attach_files->len; i++) {
-                       file = g_ptr_array_index(attach_files, i);
-                       compose_attach_append(compose, file, file, NULL, NULL);
+               for (curr = attach_files ; curr != NULL ; curr = curr->next) {
+                       ainfo = (AttachInfo *) curr->data;
+                       compose_attach_append(compose, ainfo->file, ainfo->name,
+                                       ainfo->content_type, ainfo->charset);
                }
        }
 
index 25728466010fe0ef4e90446c085314b09ae29400..fee80e6bd9bc47efd7c3dbd4095c2c2242a23736 100644 (file)
@@ -276,7 +276,7 @@ typedef enum
 /* attache_files will be locale encode */
 Compose *compose_new                   (PrefsAccount   *account,
                                         const gchar    *mailto,
-                                        GPtrArray      *attach_files);
+                                        GList          *attach_files);
 
 Compose *compose_new_with_folderitem   (PrefsAccount   *account,
                                         FolderItem     *item,
index b1c0cf190070771ba63f45bce4dfad43a8e165f6..bff1a7a5a06bb0a57aac76d0d10f260ad27d520f 100644 (file)
@@ -195,7 +195,7 @@ static struct RemoteCmd {
        gboolean receive_all;
        gboolean compose;
        const gchar *compose_mailto;
-       GPtrArray *attach_files;
+       GList *attach_files;
        gboolean search;
        const gchar *search_folder;
        const gchar *search_type;
@@ -225,7 +225,7 @@ static void lock_socket_input_cb    (gpointer          data,
                                         GIOCondition      condition);
 
 static void open_compose_new           (const gchar    *address,
-                                        GPtrArray      *attach_files);
+                                        GList          *attach_files);
 
 static void send_queue                 (void);
 static void initial_processing         (FolderItem *item, gpointer data);
@@ -1622,8 +1622,8 @@ int main(int argc, char *argv[])
                open_compose_new(cmd.compose_mailto, cmd.attach_files);
        }
        if (cmd.attach_files) {
-               ptr_array_free_strings(cmd.attach_files);
-               g_ptr_array_free(cmd.attach_files, TRUE);
+               list_free_strings(cmd.attach_files);
+               g_list_free(cmd.attach_files);
                cmd.attach_files = NULL;
        }
        if (cmd.subscribe) {
@@ -1875,6 +1875,7 @@ static GString * parse_cmd_compose_from_file(const gchar *fn)
 
 static void parse_cmd_opt(int argc, char *argv[])
 {
+       AttachInfo *ainfo;
        gint i;
 
        for (i = 1; i < argc; i++) {
@@ -1913,9 +1914,6 @@ static void parse_cmd_opt(int argc, char *argv[])
                        gchar *file = NULL;
 
                        while (p && *p != '\0' && *p != '-') {
-                               if (!cmd.attach_files) {
-                                       cmd.attach_files = g_ptr_array_new();
-                               }
                                if ((file = g_filename_from_uri(p, NULL, NULL)) != NULL) {
                                        if (!is_file_exist(file)) {
                                                g_free(file);
@@ -1929,7 +1927,9 @@ static void parse_cmd_opt(int argc, char *argv[])
                                } else if (file == NULL) {
                                        file = g_strdup(p);
                                }
-                               g_ptr_array_add(cmd.attach_files, file);
+                               ainfo = g_new0(AttachInfo, 1);
+                               ainfo->file = file;
+                               cmd.attach_files = g_list_append(cmd.attach_files, ainfo);
                                i++;
                                p = (i+1 < argc)?argv[i+1]:NULL;
                        }
@@ -2249,6 +2249,7 @@ static gchar *get_crashfile_name(void)
 static gint prohibit_duplicate_launch(void)
 {
        gint uxsock;
+       GList *curr;
 #ifdef G_OS_UNIX
        gchar *path;
 
@@ -2291,7 +2292,6 @@ static gint prohibit_duplicate_launch(void)
                fd_write_all(uxsock, "receive\n", 8);
        } else if (cmd.compose && cmd.attach_files) {
                gchar *str, *compose_str;
-               gint i;
 
                if (cmd.compose_mailto) {
                        compose_str = g_strdup_printf("compose_attach %s\n",
@@ -2303,8 +2303,8 @@ static gint prohibit_duplicate_launch(void)
                fd_write_all(uxsock, compose_str, strlen(compose_str));
                g_free(compose_str);
 
-               for (i = 0; i < cmd.attach_files->len; i++) {
-                       str = g_ptr_array_index(cmd.attach_files, i);
+               for (curr = cmd.attach_files; curr != NULL ; curr = curr->next) {
+                       str = (gchar *) ((AttachInfo *)curr->data)->file;
                        fd_write_all(uxsock, str, strlen(str));
                        fd_write_all(uxsock, "\n", 1);
                }
@@ -2468,20 +2468,29 @@ static void lock_socket_input_cb(gpointer data,
        } else if (!strncmp(buf, "receive", 7)) {
                inc_mail(mainwin, prefs_common.newmail_notify_manu);
        } else if (!strncmp(buf, "compose_attach", 14)) {
-               GPtrArray *files;
+               GList *files = NULL, *curr;
+               AttachInfo *ainfo;
                gchar *mailto;
 
                mailto = g_strdup(buf + strlen("compose_attach") + 1);
-               files = g_ptr_array_new();
                while (fd_gets(sock, buf, sizeof(buf)) > 0) {
                        strretchomp(buf);
                        if (!strcmp2(buf, "."))
                                break;
-                       g_ptr_array_add(files, g_strdup(buf));
+                               
+                       ainfo = g_new0(AttachInfo, 1);
+                       ainfo->file = g_strdup(buf);
+                       files = g_list_append(files, ainfo);
                }
                open_compose_new(mailto, files);
-               ptr_array_free_strings(files);
-               g_ptr_array_free(files, TRUE);
+               
+               curr = g_list_first(files);
+               while (curr != NULL) {
+                       ainfo = (AttachInfo *)curr->data;
+                       g_free(ainfo->file);
+                       g_free(ainfo);
+               }
+               g_list_free(files);
                g_free(mailto);
        } else if (!strncmp(buf, "compose", 7)) {
                open_compose_new(buf + strlen("compose") + 1, NULL);
@@ -2585,7 +2594,7 @@ static void lock_socket_input_cb(gpointer data,
 
 }
 
-static void open_compose_new(const gchar *address, GPtrArray *attach_files)
+static void open_compose_new(const gchar *address, GList *attach_files)
 {
        gchar *addr = NULL;
 
index 5a55e07b7a16613f32a9cd281d93229b2f5073d3..e706fd2ce47b043e44877c5248614dba15977d7d 100644 (file)
@@ -121,6 +121,8 @@ static void mimeview_open_part_with (MimeView       *mimeview,
                                         MimeInfo       *partinfo,
                                         gboolean        automatic);
 #endif
+static void mimeview_send_to           (MimeView       *mimeview,
+                                        MimeInfo       *partinfo);
 static void mimeview_select_next_part  (MimeView       *mimeview);
 static void mimeview_select_prev_part  (MimeView       *mimeview);
 static void mimeview_view_file         (const gchar    *filename,
@@ -171,6 +173,12 @@ static void mimeview_open_with_cb(GtkAction *action, gpointer data)
 }
 #endif
 
+static void mimeview_send_to_cb(GtkAction *action, gpointer data)
+{
+       MimeView *mimeview = (MimeView *)data;  
+       mimeview_send_to(mimeview, mimeview_get_part_to_use(mimeview));
+}
+
 static void mimeview_display_as_text_cb(GtkAction *action, gpointer data)
 {
        mimeview_display_as_text((MimeView *)data);
@@ -202,6 +210,7 @@ static GtkActionEntry mimeview_menu_actions[] = {
 #if (!defined MAEMO && !defined G_OS_WIN32)
        { "MimeView/OpenWith", NULL, N_("Open _with (o)..."), NULL, "Open MIME part with...", G_CALLBACK(mimeview_open_with_cb) },
 #endif
+       { "MimeView/SendTo", NULL, N_("Send to..."), NULL, "Send to", G_CALLBACK(mimeview_send_to_cb) },
        { "MimeView/DisplayAsText", NULL, N_("_Display as text (t)"), NULL, "Display as text", G_CALLBACK(mimeview_display_as_text_cb) },
        { "MimeView/SaveAs", NULL, N_("_Save as (y)..."), NULL, "Save as", G_CALLBACK(mimeview_save_as_cb) },
        { "MimeView/SaveAll", NULL, N_("Save _all..."), NULL, "Save all parts", G_CALLBACK(mimeview_save_all_cb) },
@@ -407,6 +416,9 @@ MimeView *mimeview_create(MainWindow *mainwin)
                        "/Menus/MimeView/", "OpenWith", "MimeView/OpenWith",
                        GTK_UI_MANAGER_MENUITEM);
 #endif
+       MENUITEM_ADDUI_MANAGER(mimeview->ui_manager, 
+                       "/Menus/MimeView/", "SendTo", "MimeView/SendTo",
+                       GTK_UI_MANAGER_MENUITEM);
        MENUITEM_ADDUI_MANAGER(mimeview->ui_manager, 
                        "/Menus/MimeView/", "DisplayAsText", "MimeView/DisplayAsText",
                        GTK_UI_MANAGER_MENUITEM);
@@ -2198,6 +2210,44 @@ out:
 }
 #endif
 
+static void mimeview_send_to(MimeView *mimeview, MimeInfo *partinfo)
+{
+       GList *attach_file = NULL;
+       AttachInfo *ainfo = NULL;
+       gchar *filename;
+       gint err;
+
+       if (!mimeview->opened) return;
+       if (!mimeview->file) return;
+
+       cm_return_if_fail(partinfo != NULL);
+
+       filename = procmime_get_tmp_file_name(partinfo);
+
+       if (!(err = procmime_get_part(filename, partinfo))) {
+               ainfo = g_new0(AttachInfo, 1);
+               ainfo->file = filename;
+               ainfo->name = g_strdup(get_part_name(partinfo));
+               ainfo->content_type = procmime_get_content_type_str(
+                                       partinfo->type, partinfo->subtype);
+               ainfo->charset = g_strdup(procmime_mimeinfo_get_parameter(
+                                       partinfo, "charset"));
+               attach_file = g_list_append(attach_file, ainfo);
+               
+               compose_new(NULL, NULL, attach_file);
+               
+               g_free(ainfo->name);
+               g_free(ainfo->content_type);
+               g_free(ainfo->charset);
+               g_free(ainfo);
+               g_list_free(attach_file);
+       } else
+               alertpanel_error
+                       (_("Couldn't save the part of multipart message: %s"), 
+                               strerror(-err));
+       g_free(filename);
+}
+
 static void mimeview_view_file(const gchar *filename, MimeInfo *partinfo,
                               const gchar *cmd, MimeView *mimeview)
 {