aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorhiro <hiro@ee746299-78ed-0310-b773-934348b2243d>2007-05-10 03:48:56 +0000
committerhiro <hiro@ee746299-78ed-0310-b773-934348b2243d>2007-05-10 03:48:56 +0000
commit6b2af6b8b67b7d0abc2d19a89c895f64239487f3 (patch)
treebd51c844e1227e2ec5659d3c77b4c22d55c51b16
parent3be7497b4d410c1097bb19bcb7acfc10559585e1 (diff)
implemented '--open' command line option which open messages specified with command-line in new window.
git-svn-id: svn://sylpheed.sraoss.jp/sylpheed/trunk@1686 ee746299-78ed-0310-b773-934348b2243d
-rw-r--r--ChangeLog7
-rw-r--r--ChangeLog.ja7
-rw-r--r--libsylph/mh.c3
-rw-r--r--src/main.c46
4 files changed, 62 insertions, 1 deletions
diff --git a/ChangeLog b/ChangeLog
index d3efe48c..4890c5c9 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+2007-05-09
+
+ * src/main.c: implemented '--open' command line option which open
+ messages specified with command-line in new window.
+ * libsylph/mh.c: mh_fetch_msg(): don't show warning when num is
+ out of range.
+
2007-05-08
* src/prefs_common_dialog.c: prefs_account_ssl_create(): automatically
diff --git a/ChangeLog.ja b/ChangeLog.ja
index 23215eb8..aa965d90 100644
--- a/ChangeLog.ja
+++ b/ChangeLog.ja
@@ -1,3 +1,10 @@
+2007-05-09
+
+ * src/main.c: コマンドラインで指定されたメッセージを新規ウィンドウで
+ 開く '--open' コマンドラインオプションを実装。
+ * libsylph/mh.c: mh_fetch_msg(): num が範囲外でも警告を表示しない
+ ようにした。
+
2007-05-08
* src/prefs_common_dialog.c: prefs_account_ssl_create(): ラジオボタン
diff --git a/libsylph/mh.c b/libsylph/mh.c
index 67be7a7a..386d7557 100644
--- a/libsylph/mh.c
+++ b/libsylph/mh.c
@@ -331,7 +331,8 @@ static gchar *mh_fetch_msg(Folder *folder, FolderItem *item, gint num)
if (item->last_num < 0) return NULL;
}
- g_return_val_if_fail(num <= item->last_num, NULL);
+ if (num > item->last_num)
+ return NULL;
path = folder_item_get_path(item);
file = g_strconcat(path, G_DIR_SEPARATOR_S, itos(num), NULL);
diff --git a/src/main.c b/src/main.c
index 1ad4cf1f..649d79f1 100644
--- a/src/main.c
+++ b/src/main.c
@@ -114,6 +114,7 @@ static struct RemoteCmd {
gboolean status_full;
GPtrArray *status_folders;
GPtrArray *status_full_folders;
+ gchar *open_msg;
gboolean configdir;
gboolean exit;
#ifdef G_OS_WIN32
@@ -470,6 +471,14 @@ static void parse_cmd_opt(int argc, char *argv[])
i++;
p = argv[i + 1];
}
+ } else if (!strncmp(argv[i], "--open", 6)) {
+ const gchar *p = argv[i + 1];
+
+ if (p && *p != '\0' && *p != '-') {
+ cmd.open_msg = g_locale_to_utf8
+ (p, -1, NULL, NULL, NULL);
+ i++;
+ }
} else if (!strncmp(argv[i], "--configdir", 11)) {
const gchar *p = argv[i + 1];
@@ -1112,6 +1121,12 @@ static gint prohibit_duplicate_launch(void)
if (!strncmp(buf, ".\n", 2)) break;
fputs(buf, stdout);
}
+ } else if (cmd.open_msg) {
+ gchar *str;
+
+ str = g_strdup_printf("open %s\n", cmd.open_msg);
+ fd_write_all(sock, str, strlen(str));
+ g_free(str);
} else if (cmd.exit) {
fd_write_all(sock, "exit\n", 5);
} else {
@@ -1237,6 +1252,37 @@ static gboolean lock_socket_input_cb(GIOChannel *source, GIOCondition condition,
fd_write_all(sock, ".\n", 2);
g_free(status);
if (folders) g_ptr_array_free(folders, TRUE);
+ } else if (!strncmp(buf, "open", 4)) {
+ gchar *path;
+ gchar *id;
+ gchar *msg;
+ gint num;
+ FolderItem *item;
+ MsgInfo *msginfo;
+ MessageView *msgview;
+
+ strretchomp(buf);
+ if (strlen(buf) < 6 || buf[4] != ' ') {
+ fd_close(sock);
+ return TRUE;
+ }
+
+ path = buf + 5;
+ id = g_path_get_dirname(path);
+ msg = g_path_get_basename(path);
+ num = to_number(msg);
+ item = folder_find_item_from_identifier(id);
+ debug_print("open folder id: %s (msg %d)\n", id, num);
+ if (num > 0 && item) {
+ msginfo = folder_item_get_msginfo(item, num);
+ if (msginfo) {
+ msgview = messageview_create_with_new_window();
+ messageview_show(msgview, msginfo, FALSE);
+ } else
+ debug_print("message %d not found\n", num);
+ }
+ g_free(msg);
+ g_free(id);
} else if (!strncmp(buf, "exit", 4)) {
fd_close(sock);
app_will_exit(TRUE);