sync with 0.8.1cvs4
authorPaul Mangan <paul@claws-mail.org>
Tue, 30 Jul 2002 09:49:51 +0000 (09:49 +0000)
committerPaul Mangan <paul@claws-mail.org>
Tue, 30 Jul 2002 09:49:51 +0000 (09:49 +0000)
ChangeLog
ChangeLog.claws
ChangeLog.jp
configure.in
src/compose.c
src/compose.h
src/main.c
src/mainwindow.c
src/textview.c

index ccc374cfa34b9c018cbe7c83250b159f76317bca..b430042b86940568a3ccaf7bb632e27014c24478 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,16 @@
+2002-07-29
+
+       * implemented --attach command line option.
+       * src/main.c:
+         Cmd::attach_files: new member to store file paths.
+         parse_cmd_opt(): added --attach option. --compose option is implied.
+         prohibit_duplicate_launch()
+         lock_socket_input_cb(): added "compose_attach" message.
+       * src/compose.c
+         src/mainwindow.c
+         src/textview.c: renamed compose_new_with_recipient() to
+         compose_new(), and added an argument for attachment files.
+
 2002-07-29
 
        * src/logwindow.c: freeze GtkText widget while hidden.
index 207f720f65a091169527cc9388930f6b6c596f7b..2f4f8e85585cdf59baccc41fec4cdefa74632546 100644 (file)
@@ -1,3 +1,8 @@
+2002-07-30 [paul]      0.8.0claws26
+
+       * sync with 0.8.1cvs4
+               see ChangeLog 2002-07-29
+
 2002-07-29 [thorsten]  0.8.0claws25
 
        * README.claws
index dbc114cc3111dc627658c7dcdf5238f3a5deac1e..d1a80393b502dc5fabe67ccd79482401e8246e94 100644 (file)
@@ -1,3 +1,17 @@
+2002-07-29
+
+       * --attach ¥³¥Þ¥ó¥É¥é¥¤¥ó¥ª¥×¥·¥ç¥ó¤ò¼ÂÁõ¡£
+       * src/main.c:
+         Cmd::attach_files: ¥Õ¥¡¥¤¥ë¥Ñ¥¹¤òÊݸ¤¹¤ë¿·µ¬¥á¥ó¥Ð¡£
+         parse_cmd_opt(): --attach ¥ª¥×¥·¥ç¥ó¤òÄɲᣠ--compose ¥ª¥×¥·¥ç¥ó
+         ¤¬°ÅÌۤ˻ØÄꤵ¤ì¤ë¡£
+         prohibit_duplicate_launch()
+         lock_socket_input_cb(): "compose_attach" ¥á¥Ã¥»¡¼¥¸¤òÄɲá£
+       * src/compose.c
+         src/mainwindow.c
+         src/textview.c: compose_new_with_recipient() ¤ò compose_new() ¤Ë
+         Ì¾¾ÎÊѹ¹¤·¡¢ÅºÉÕ¥Õ¥¡¥¤¥ë¤Î¤¿¤á¤Î°ú¿ô¤òÄɲá£
+
 2002-07-29
 
        * src/logwindow.c: ±£¤·¤Æ¤¤¤ë¤È¤­¤Ï GtkText ¥¦¥£¥¸¥§¥Ã¥È¤ò¥Õ¥ê¡¼¥º¡£
index 55aecdc67efdea5d7456578de0b3f16ade3d7763..03dbb3af372cf847d67836213e13a333ab8bb2a5 100644 (file)
@@ -8,7 +8,7 @@ MINOR_VERSION=8
 MICRO_VERSION=0
 INTERFACE_AGE=0
 BINARY_AGE=0
-EXTRA_VERSION=claws25
+EXTRA_VERSION=claws26
 VERSION=$MAJOR_VERSION.$MINOR_VERSION.$MICRO_VERSION$EXTRA_VERSION
 
 dnl set $target
index 495d89ad7eeb36b17d9e8c2b5478152e025cf44c..075469b7d93f47f5cb889887c6e6d45083592d74 100644 (file)
@@ -158,7 +158,8 @@ static GList *compose_list = NULL;
 
 Compose *compose_generic_new                   (PrefsAccount   *account,
                                                 const gchar    *to,
-                                                FolderItem     *item);
+                                                FolderItem     *item,
+                                                GPtrArray      *attach_files);
 
 static Compose *compose_create                 (PrefsAccount   *account,
                                                 ComposeMode     mode);
@@ -672,18 +673,13 @@ static GtkTargetEntry compose_mime_types[] =
        {"text/uri-list", 0, 0}
 };
 
-Compose *compose_new(PrefsAccount *account)
-{
-       return compose_generic_new(account, NULL, NULL);
-}
-
 Compose *compose_redirect(PrefsAccount *account, MsgInfo *msginfo)
 {
        Compose *c;
        gchar *filename;
        GtkItemFactory *ifactory;
        
-       c = compose_generic_new(account, NULL, NULL);
+       c = compose_generic_new(account, NULL, NULL, NULL);
 
        filename = procmsg_get_message_file(msginfo);
        if (filename == NULL)
@@ -729,17 +725,19 @@ Compose *compose_redirect(PrefsAccount *account, MsgInfo *msginfo)
        return c;
 }
 
-Compose *compose_new_with_recipient(PrefsAccount *account, const gchar *mailto)
+Compose *compose_new(PrefsAccount *account, const gchar *mailto,
+                    GPtrArray *attach_files)
 {
-       return compose_generic_new(account, mailto, NULL);
+       return compose_generic_new(account, mailto, NULL, attach_files);
 }
 
 Compose *compose_new_with_folderitem(PrefsAccount *account, FolderItem *item)
 {
-       return compose_generic_new(account, NULL, item);
+       return compose_generic_new(account, NULL, item, NULL);
 }
 
-Compose *compose_generic_new(PrefsAccount *account, const gchar *mailto, FolderItem *item)
+Compose *compose_generic_new(PrefsAccount *account, const gchar *mailto, FolderItem *item,
+                            GPtrArray *attach_files)
 {
        Compose *compose;
        GtkSText *text;
@@ -771,9 +769,8 @@ Compose *compose_generic_new(PrefsAccount *account, const gchar *mailto, FolderI
        gtk_widget_grab_focus(compose->text);
        gtkut_widget_wait_for_draw(compose->text);
 
-
        if (account->protocol != A_NNTP) {
-               if (mailto) {
+               if (mailto && *mailto != '\0') {
                        compose_entries_set(compose, mailto);
 
                } else if(item && item->prefs->enable_default_to) {
@@ -794,6 +791,17 @@ Compose *compose_generic_new(PrefsAccount *account, const gchar *mailto, FolderI
                 */
                menu_set_sensitive(ifactory, "/Message/Request Return Receipt", FALSE); 
        }
+
+       if (attach_files) {
+               gint i;
+               gchar *file;
+
+               for (i = 0; i < attach_files->len; i++) {
+                       file = g_ptr_array_index(attach_files, i);
+                       compose_attach_append(compose, file, file, NULL);
+               }
+       }
+
        compose_show_first_last_header(compose, TRUE);
 
        /* Set save folder */
index afb967c8386f2bc96015c65362f70421bcb4ba4a..309dde102ed0fef5ef40504fb78331756700508a 100644 (file)
@@ -212,10 +212,9 @@ struct _AttachInfo
        off_t size;
 };
 
-Compose *compose_new                   (PrefsAccount   *account);
-
-Compose *compose_new_with_recipient    (PrefsAccount   *account,
-                                        const gchar    *to);
+Compose *compose_new                   (PrefsAccount   *account,
+                                        const gchar    *mailto,
+                                        GPtrArray      *attach_files);
 
 Compose *compose_new_with_folderitem   (PrefsAccount   *account,
                                         FolderItem     *item);
index 3b7cb574e09b453cd60ea8d9901ec54ba1cb0f66..4b6ee0d5d2a6f37a6c86449cee75cc5a5f2d7ec5 100644 (file)
@@ -96,6 +96,7 @@ static struct Cmd {
        gboolean receive_all;
        gboolean compose;
        const gchar *compose_mailto;
+       GPtrArray *attach_files;
        gboolean status;
        gboolean send;
 } cmd;
@@ -112,7 +113,8 @@ static void lock_socket_input_cb    (gpointer          data,
                                         GdkInputCondition condition);
 static gchar *get_socket_name          (void);
 
-static void open_compose_new_with_recipient    (const gchar    *address);
+static void open_compose_new           (const gchar    *address,
+                                        GPtrArray      *attach_files);
 
 static void send_queue                 (void);
 static void initial_processing         (FolderItem *item, gpointer data);
@@ -148,6 +150,9 @@ int main(int argc, char *argv[])
        bindtextdomain(PACKAGE, LOCALEDIR);
        textdomain(PACKAGE);
 
+       prog_version = PROG_VERSION;
+       startup_dir = g_get_current_dir();
+
        parse_cmd_opt(argc, argv);
 
        gtk_set_locale();
@@ -190,9 +195,6 @@ int main(int argc, char *argv[])
        gtk_item_factory_parse_rc(userrc);
        g_free(userrc);
 
-       prog_version = PROG_VERSION;
-       startup_dir = g_get_current_dir();
-
        CHDIR_RETURN_VAL_IF_FAIL(get_home_dir(), 1);
 
        /* check and create unix domain socket */
@@ -318,7 +320,12 @@ int main(int argc, char *argv[])
                gtk_widget_grab_focus(folderview->ctree);
 
        if (cmd.compose)
-               open_compose_new_with_recipient(cmd.compose_mailto);
+               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);
+               cmd.attach_files = NULL;
+       }
        if (cmd.send)
                send_queue();
 
@@ -356,6 +363,23 @@ static void parse_cmd_opt(int argc, char *argv[])
                                        cmd.compose_mailto = p;
                                i++;
                        }
+               } else if (!strncmp(argv[i], "--attach", 8)) {
+                       const gchar *p = argv[i + 1];
+                       gchar *file;
+
+                       while (p && *p != '\0' && *p != '-') {
+                               if (!cmd.attach_files)
+                                       cmd.attach_files = g_ptr_array_new();
+                               if (*p != G_DIR_SEPARATOR)
+                                       file = g_strconcat(startup_dir,
+                                                          G_DIR_SEPARATOR_S,
+                                                          p, NULL);
+                               else
+                                       file = g_strdup(p);
+                               g_ptr_array_add(cmd.attach_files, file);
+                               i++;
+                               p = argv[i + 1];
+                       }
                } else if (!strncmp(argv[i], "--send", 6)) {
                        cmd.send = TRUE;
                } else if (!strncmp(argv[i], "--version", 9)) {
@@ -368,6 +392,9 @@ static void parse_cmd_opt(int argc, char *argv[])
                                g_basename(argv[0]));
 
                        puts(_("  --compose [address]    open composition window"));
+                       puts(_("  --attach file1 [file2]...\n"
+                              "                         open composition window with specified files\n"
+                              "                         attached"));
                        puts(_("  --receive              receive new messages"));
                        puts(_("  --receive-all          receive new messages of all accounts"));
                        puts(_("  --send                 send all queued messages"));
@@ -379,6 +406,11 @@ static void parse_cmd_opt(int argc, char *argv[])
                        exit(1);
                }
        }
+
+       if (cmd.attach_files && cmd.compose == FALSE) {
+               cmd.compose = TRUE;
+               cmd.compose_mailto = NULL;
+       }
 }
 
 static gint get_queued_message_num(void)
@@ -523,7 +555,27 @@ static gint prohibit_duplicate_launch(void)
                fd_write(uxsock, "receive_all\n", 12);
        else if (cmd.receive)
                fd_write(uxsock, "receive\n", 8);
-       else if (cmd.compose) {
+       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",
+                                                     cmd.compose_mailto);
+               else
+                       compose_str = g_strdup("compose_attach\n");
+
+               fd_write(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);
+                       fd_write(uxsock, str, strlen(str));
+                       fd_write(uxsock, "\n", 1);
+               }
+
+               fd_write(uxsock, ".\n", 2);
+       } else if (cmd.compose) {
                gchar *compose_str;
 
                if (cmd.compose_mailto)
@@ -559,16 +611,31 @@ static void lock_socket_input_cb(gpointer data,
        sock = fd_accept(source);
        fd_gets(sock, buf, sizeof(buf));
 
-       if (!strncmp(buf, "popup", 5)){
+       if (!strncmp(buf, "popup", 5)) {
                main_window_popup(mainwin);
-       } else if (!strncmp(buf, "receive_all", 11)){
+       } else if (!strncmp(buf, "receive_all", 11)) {
                main_window_popup(mainwin);
                inc_all_account_mail(mainwin, prefs_common.newmail_notify_manu);
-       } else if (!strncmp(buf, "receive", 7)){
+       } else if (!strncmp(buf, "receive", 7)) {
                main_window_popup(mainwin);
                inc_mail(mainwin, prefs_common.newmail_notify_manu);
+       } else if (!strncmp(buf, "compose_attach", 14)) {
+               GPtrArray *files;
+               gchar *mailto;
+
+               mailto = g_strdup(buf + strlen("compose_attach") + 1);
+               files = g_ptr_array_new();
+               while (fd_gets(sock, buf, sizeof(buf)) > 0) {
+                       if (buf[0] == '.' && buf[1] == '\n') break;
+                       strretchomp(buf);
+                       g_ptr_array_add(files, g_strdup(buf));
+               }
+               open_compose_new(mailto, files);
+               ptr_array_free_strings(files);
+               g_ptr_array_free(files, TRUE);
+               g_free(mailto);
        } else if (!strncmp(buf, "compose", 7)) {
-               open_compose_new_with_recipient(buf + strlen("compose") + 1);
+               open_compose_new(buf + strlen("compose") + 1, NULL);
        } else if (!strncmp(buf, "send", 4)) {
                send_queue();
        } else if (!strncmp(buf, "status", 6)) {
@@ -582,7 +649,7 @@ static void lock_socket_input_cb(gpointer data,
        fd_close(sock);
 }
 
-static void open_compose_new_with_recipient(const gchar *address)
+static void open_compose_new(const gchar *address, GPtrArray *attach_files)
 {
        gchar *addr = NULL;
 
@@ -591,10 +658,7 @@ static void open_compose_new_with_recipient(const gchar *address)
                g_strstrip(addr);
        }
 
-       if (addr && *addr != '\0')
-               compose_new_with_recipient(NULL, addr);
-       else
-               compose_new(NULL);
+       compose_new(NULL, addr, attach_files);
 }
 
 static void send_queue(void)
index 62c427c3d5a817ba69f6ae3fc3e946d3194928ee..cf344482f29f822d4156351b941faa959e14c49a 100644 (file)
@@ -2865,8 +2865,9 @@ static void compose_news_cb(MainWindow *mainwin, guint action,
        if (mainwin->summaryview->folder_item) {
                ac = mainwin->summaryview->folder_item->folder->account;
                if (ac && ac->protocol == A_NNTP) {
-                       compose_new_with_recipient
-                               (ac, mainwin->summaryview->folder_item->path);
+                       compose_new(ac,
+                                   mainwin->summaryview->folder_item->path,
+                                   NULL);
                        return;
                }
        }
@@ -2875,7 +2876,7 @@ static void compose_news_cb(MainWindow *mainwin, guint action,
        for(cur = list ; cur != NULL ; cur = g_list_next(cur)) {
                ac = (PrefsAccount *) cur->data;
                if (ac->protocol == A_NNTP) {
-                       compose_new(ac);
+                       compose_new(ac, NULL, NULL);
                        return;
                }
        }
index aba9fcbe556c10d555d8a41b50b5311c3f15b9c4..612c7a53fc167d2a1a2a65269204479752a10ed7 100644 (file)
@@ -1774,8 +1774,7 @@ static gint textview_button_released(GtkWidget *widget, GdkEventButton *event,
                                                        if (folder_item->prefs && folder_item->prefs->enable_default_account)
                                                                account = account_find_from_id(folder_item->prefs->default_account);
                                                }
-                                               compose_new_with_recipient
-                                                       (account, uri->uri + 7);
+                                               compose_new(account, uri->uri + 7, NULL);
                                        }
                                } else {
                                        open_uri(uri->uri,