2006-01-12 [colin] 1.9.100cvs140
authorColin Leroy <colin@colino.net>
Thu, 12 Jan 2006 20:01:48 +0000 (20:01 +0000)
committerColin Leroy <colin@colino.net>
Thu, 12 Jan 2006 20:01:48 +0000 (20:01 +0000)
* src/folder.c
* src/folder.h
* src/main.c
Add --subscribe option
Let sylpheed-claws email@domain.com equivalent to --compose
Let sylpheed-claws proto://blah.com equivalent to --subscribe

ChangeLog
PATCHSETS
configure.ac
src/folder.c
src/folder.h
src/main.c

index d64014fb2d9dc497f7584e204cf8b9a8954f3554..fd9c3bedc75a4800cbe7ed125b312b05b8257d5b 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,12 @@
+2006-01-12 [colin]     1.9.100cvs140
+
+       * src/folder.c
+       * src/folder.h
+       * src/main.c
+               Add --subscribe option
+               Let sylpheed-claws email@domain.com equivalent to --compose
+               Let sylpheed-claws proto://blah.com equivalent to --subscribe
+
 2006-01-12 [paul]      1.9.100cvs139
 
        * src/mainwindow.c
index e2bfdf817d1bd2edf452a402a960747e5eb2bb02..018e52bd48c33975ff4c47e12eca3ee5c72ff358 100644 (file)
--- a/PATCHSETS
+++ b/PATCHSETS
 ( cvs diff -u -r 1.30.2.7 -r 1.30.2.8 tools/README;  cvs diff -u -r 1.1.2.1 -r 1.1.2.2 tools/filter_conv_new.pl;  ) > 1.9.100cvs137.patchset
 ( cvs diff -u -r 1.382.2.218 -r 1.382.2.219 src/compose.c;  ) > 1.9.100cvs138.patchset
 ( cvs diff -u -r 1.274.2.85 -r 1.274.2.86 src/mainwindow.c;  cvs diff -u -r 1.60.2.27 -r 1.60.2.28 src/prefs_actions.c;  cvs diff -u -r 1.1.2.7 -r 1.1.2.8 src/gtk/foldersort.c;  ) > 1.9.100cvs139.patchset
+( cvs diff -u -r 1.213.2.72 -r 1.213.2.73 src/folder.c;  cvs diff -u -r 1.87.2.22 -r 1.87.2.23 src/folder.h;  cvs diff -u -r 1.115.2.70 -r 1.115.2.71 src/main.c;  ) > 1.9.100cvs140.patchset
index 06c30724eca7e5f4d7dcf2adccda7b1fa9f1043d..36107b0e9c32576a99e91a9108976344036c59a3 100644 (file)
@@ -11,7 +11,7 @@ MINOR_VERSION=9
 MICRO_VERSION=100
 INTERFACE_AGE=0
 BINARY_AGE=0
-EXTRA_VERSION=139
+EXTRA_VERSION=140
 EXTRA_RELEASE=
 EXTRA_GTK2_VERSION=
 
index 1fbde2ba4e8a0ca3991d88a9e236a8729b44d5b5..d7d5ce2ceb1984cc5269439cf577b7a8b893f98b 100644 (file)
@@ -3746,4 +3746,18 @@ gboolean folder_has_parent_of_type(FolderItem *item,
        return FALSE;
 }
 
+gboolean folder_subscribe (const gchar *uri)
+{
+       GList *cur;
+       for (cur = folder_get_list(); cur != NULL; cur = g_list_next(cur)) {
+               Folder *folder = (Folder *) cur->data;
+
+               if (folder->klass->subscribe
+               &&  folder->klass->subscribe(folder, uri)) {
+                       return TRUE;
+               }
+       }
+       return FALSE;
+
+}
 #undef PUT_ESCAPE_STR
index 834320ecca7db140a9a0568852dc017b51b30ba8..d618f9c00c0494c8fa1cc2cbe053157d99dbde2a 100644 (file)
@@ -573,6 +573,8 @@ struct _FolderClass
                                                 FolderItem     *item,
                                                 gboolean        batch);
        void            (*synchronise)          (FolderItem     *item);
+       gboolean        (*subscribe)            (Folder         *folder,
+                                                const gchar    *uri);
 };
 
 struct _FolderItem
@@ -816,4 +818,5 @@ void folder_item_process_open               (FolderItem *item,
                                         void (*before_proc_func)(gpointer data),
                                         void (*after_proc_func)(gpointer data),
                                         gpointer data);
+gboolean folder_subscribe              (const gchar *uri);
 #endif /* __FOLDER_H__ */
index 98531f4efcfb5fab0d9ccd432f6fc93f7b5da70d..21f5bf70361499c7abd6de91a1a76baa1b43ce58 100644 (file)
@@ -139,6 +139,8 @@ static struct RemoteCmd {
        int online_mode;
        gchar   *crash_params;
        gboolean exit;
+       gboolean subscribe;
+       const gchar *subscribe_uri;
 } cmd;
 
 static void parse_cmd_opt(int argc, char *argv[]);
@@ -544,6 +546,9 @@ int main(int argc, char *argv[])
                g_ptr_array_free(cmd.attach_files, TRUE);
                cmd.attach_files = NULL;
        }
+       if (cmd.subscribe)
+               folder_subscribe(cmd.subscribe_uri);
+
        if (cmd.send)
                send_queue();
        
@@ -660,6 +665,12 @@ static void parse_cmd_opt(int argc, char *argv[])
                                        cmd.compose_mailto = p;
                                i++;
                        }
+               } else if (!strncmp(argv[i], "--subscribe", 11)) {
+                       const gchar *p = argv[i + 1];
+                       if (p && *p != '\0' && *p != '-') {
+                               cmd.subscribe = TRUE;
+                               cmd.subscribe_uri = p;
+                       }
                } else if (!strncmp(argv[i], "--attach", 8)) {
                        const gchar *p = argv[i + 1];
                        gchar *file;
@@ -716,6 +727,7 @@ static void parse_cmd_opt(int argc, char *argv[])
                        g_print(_("Usage: %s [OPTION]...\n"), base);
 
                        g_print("%s\n", _("  --compose [address]    open composition window"));
+                       g_print("%s\n", _("  --subscribe [uri]      subscribe to the given URI if possible"));
                        g_print("%s\n", _("  --attach file1 [file2]...\n"
                                  "                         open composition window with specified files\n"
                                  "                         attached"));
@@ -744,6 +756,26 @@ static void parse_cmd_opt(int argc, char *argv[])
                        exit(0);
                } else if (!strncmp(argv[i], "--exit", 6)) {
                        cmd.exit = TRUE;
+               } else if (i == 1 && argc == 2) {
+                       /* only one parameter. Do something intelligent about it */
+                       if (strstr(argv[i], "@") && !strstr(argv[i], "://")) {
+                               const gchar *p = argv[i];
+
+                               cmd.compose = TRUE;
+                               cmd.compose_mailto = NULL;
+                               if (p && *p != '\0' && *p != '-') {
+                                       if (!strncmp(p, "mailto:", 7))
+                                               cmd.compose_mailto = p + 7;
+                                       else
+                                               cmd.compose_mailto = p;
+                               }
+                       } else if (strstr(argv[i], "://")) {
+                               const gchar *p = argv[i];
+                               if (p && *p != '\0' && *p != '-') {
+                                       cmd.subscribe = TRUE;
+                                       cmd.subscribe_uri = p;
+                               }
+                       }
                }
                
        }
@@ -948,6 +980,10 @@ static gint prohibit_duplicate_launch(void)
 
                fd_write_all(uxsock, compose_str, strlen(compose_str));
                g_free(compose_str);
+       } else if (cmd.subscribe) {
+               gchar *str = g_strdup_printf("subscribe %s\n", cmd.subscribe_uri);
+               fd_write_all(uxsock, str, strlen(str));
+               g_free(str);
        } else if (cmd.send) {
                fd_write_all(uxsock, "send\n", 5);
        } else if (cmd.online_mode == ONLINE_MODE_ONLINE) {
@@ -1059,6 +1095,9 @@ static void lock_socket_input_cb(gpointer data,
                g_free(mailto);
        } else if (!strncmp(buf, "compose", 7)) {
                open_compose_new(buf + strlen("compose") + 1, NULL);
+       } else if (!strncmp(buf, "subscribe", 9)) {
+               main_window_popup(mainwin);
+               folder_subscribe(buf + strlen("subscribe") + 1);
        } else if (!strncmp(buf, "send", 4)) {
                send_queue();
        } else if (!strncmp(buf, "online", 6)) {