| 61 |
61 |
#include "account.h"
|
| 62 |
62 |
#include "account_dialog.h"
|
| 63 |
63 |
#include "procmsg.h"
|
|
64 |
#include "procheader.h"
|
| 64 |
65 |
#include "filter.h"
|
| 65 |
66 |
#include "send_message.h"
|
| 66 |
67 |
#include "inc.h"
|
| ... | ... | |
| 566 |
567 |
const gchar *p = argv[i + 1];
|
| 567 |
568 |
|
| 568 |
569 |
if (p && *p != '\0' && *p != '-') {
|
|
570 |
if (cmd.open_msg)
|
|
571 |
g_free(cmd.open_msg);
|
| 569 |
572 |
cmd.open_msg = g_locale_to_utf8
|
| 570 |
573 |
(p, -1, NULL, NULL, NULL);
|
| 571 |
574 |
i++;
|
| ... | ... | |
| 609 |
612 |
} else if (!strncmp(argv[i], "--help", 6)) {
|
| 610 |
613 |
init_console();
|
| 611 |
614 |
|
| 612 |
|
g_print(_("Usage: %s [OPTION]...\n"),
|
|
615 |
g_print(_("Usage: %s [OPTIONS ...] [URL]\n"),
|
| 613 |
616 |
g_basename(argv[0]));
|
| 614 |
617 |
|
| 615 |
|
g_print("%s\n", _(" --compose [address] open composition window"));
|
|
618 |
g_print("%s\n", _(" --compose [mailto URL] open composition window"));
|
| 616 |
619 |
g_print("%s\n", _(" --attach file1 [file2]...\n"
|
| 617 |
620 |
" open composition window with specified files\n"
|
| 618 |
621 |
" attached"));
|
| ... | ... | |
| 622 |
625 |
g_print("%s\n", _(" --status [folder]... show the total number of messages"));
|
| 623 |
626 |
g_print("%s\n", _(" --status-full [folder]...\n"
|
| 624 |
627 |
" show the status of each folder"));
|
| 625 |
|
g_print("%s\n", _(" --open folderid/msgnum open message in new window"));
|
|
628 |
g_print("%s\n", _(" --open folderid/msgnum open existing message in a new window"));
|
|
629 |
g_print("%s\n", _(" --open <file URL> open an rfc822 message file in a new window"));
|
| 626 |
630 |
g_print("%s\n", _(" --configdir dirname specify directory which stores configuration files"));
|
| 627 |
631 |
#ifdef G_OS_WIN32
|
| 628 |
632 |
g_print("%s\n", _(" --ipcport portnum specify port for IPC remote commands"));
|
| ... | ... | |
| 640 |
644 |
|
| 641 |
645 |
cleanup_console();
|
| 642 |
646 |
exit(1);
|
|
647 |
} else {
|
|
648 |
/* file or URL */
|
|
649 |
const gchar *p = argv[i];
|
|
650 |
|
|
651 |
if (p && *p != '\0') {
|
|
652 |
if (!strncmp(p, "mailto:", 7)) {
|
|
653 |
cmd.compose = TRUE;
|
|
654 |
cmd.compose_mailto = p + 7;
|
|
655 |
} else {
|
|
656 |
if (cmd.open_msg)
|
|
657 |
g_free(cmd.open_msg);
|
|
658 |
cmd.open_msg = g_locale_to_utf8
|
|
659 |
(p, -1, NULL, NULL, NULL);
|
|
660 |
}
|
|
661 |
}
|
| 643 |
662 |
}
|
| 644 |
663 |
}
|
| 645 |
664 |
|
| ... | ... | |
| 1794 |
1813 |
utf8addr = g_locale_to_utf8(address, -1, NULL, NULL, NULL);
|
| 1795 |
1814 |
if (utf8addr)
|
| 1796 |
1815 |
g_strstrip(utf8addr);
|
|
1816 |
debug_print("open compose: %s\n", utf8addr ? utf8addr : "");
|
| 1797 |
1817 |
}
|
| 1798 |
1818 |
|
| 1799 |
1819 |
#ifdef G_OS_WIN32
|
| ... | ... | |
| 1822 |
1842 |
g_free(utf8addr);
|
| 1823 |
1843 |
}
|
| 1824 |
1844 |
|
|
1845 |
static void open_message_file(const gchar *file)
|
|
1846 |
{
|
|
1847 |
MsgInfo *msginfo;
|
|
1848 |
MsgFlags flags = {0};
|
|
1849 |
MessageView *msgview;
|
|
1850 |
|
|
1851 |
g_return_if_fail(file != NULL);
|
|
1852 |
|
|
1853 |
debug_print("open message file: %s\n", file);
|
|
1854 |
|
|
1855 |
if (!is_file_exist(file) || get_file_size(file) <= 0) {
|
|
1856 |
debug_print("file not found: %s\n", file);
|
|
1857 |
return;
|
|
1858 |
}
|
|
1859 |
|
|
1860 |
msginfo = procheader_parse_file(file, flags, FALSE);
|
|
1861 |
if (msginfo) {
|
|
1862 |
msginfo->file_path = g_strdup(file);
|
|
1863 |
msgview = messageview_create_with_new_window();
|
|
1864 |
messageview_show(msgview, msginfo, FALSE);
|
|
1865 |
procmsg_msginfo_free(msginfo);
|
|
1866 |
} else
|
|
1867 |
debug_print("cannot open message: %s\n", file);
|
|
1868 |
}
|
|
1869 |
|
| 1825 |
1870 |
static void open_message(const gchar *path)
|
| 1826 |
1871 |
{
|
| 1827 |
|
gchar *id;
|
|
1872 |
gchar *fid;
|
| 1828 |
1873 |
gchar *msg;
|
| 1829 |
1874 |
gint num;
|
| 1830 |
1875 |
FolderItem *item;
|
| 1831 |
1876 |
MsgInfo *msginfo;
|
| 1832 |
1877 |
MessageView *msgview;
|
|
1878 |
gchar *file;
|
| 1833 |
1879 |
|
|
1880 |
g_return_if_fail(path != NULL);
|
|
1881 |
|
| 1834 |
1882 |
if (gtkut_window_modal_exist())
|
| 1835 |
1883 |
return;
|
| 1836 |
1884 |
|
| 1837 |
|
id = g_path_get_dirname(path);
|
|
1885 |
debug_print("open message: %s\n", path);
|
|
1886 |
|
|
1887 |
if (!strncmp(path, "file:", 5)) {
|
|
1888 |
file = g_filename_from_uri(path, NULL, NULL);
|
|
1889 |
open_message_file(file);
|
|
1890 |
g_free(file);
|
|
1891 |
return;
|
|
1892 |
} else if (g_path_is_absolute(path)) {
|
|
1893 |
open_message_file(path);
|
|
1894 |
return;
|
|
1895 |
}
|
|
1896 |
|
|
1897 |
/* relative path, or folder identifier */
|
|
1898 |
|
|
1899 |
fid = g_path_get_dirname(path);
|
| 1838 |
1900 |
msg = g_path_get_basename(path);
|
| 1839 |
1901 |
num = to_number(msg);
|
| 1840 |
|
item = folder_find_item_from_identifier(id);
|
| 1841 |
|
debug_print("open folder id: %s (msg %d)\n", id, num);
|
|
1902 |
item = folder_find_item_from_identifier(fid);
|
| 1842 |
1903 |
|
| 1843 |
1904 |
if (num > 0 && item) {
|
|
1905 |
debug_print("open folder id: %s (msg %d)\n", fid, num);
|
| 1844 |
1906 |
msginfo = folder_item_get_msginfo(item, num);
|
| 1845 |
1907 |
if (msginfo) {
|
| 1846 |
1908 |
msgview = messageview_create_with_new_window();
|
| 1847 |
1909 |
messageview_show(msgview, msginfo, FALSE);
|
| 1848 |
1910 |
procmsg_msginfo_free(msginfo);
|
|
1911 |
g_free(msg);
|
|
1912 |
g_free(fid);
|
|
1913 |
return;
|
| 1849 |
1914 |
} else
|
| 1850 |
1915 |
debug_print("message %d not found\n", num);
|
| 1851 |
1916 |
}
|
| 1852 |
1917 |
|
| 1853 |
1918 |
g_free(msg);
|
| 1854 |
|
g_free(id);
|
|
1919 |
g_free(fid);
|
|
1920 |
|
|
1921 |
/* relative path */
|
|
1922 |
|
|
1923 |
file = g_strconcat(get_startup_dir(), G_DIR_SEPARATOR_S, path, NULL);
|
|
1924 |
open_message_file(file);
|
|
1925 |
g_free(file);
|
| 1855 |
1926 |
}
|
| 1856 |
1927 |
|
| 1857 |
1928 |
static void send_queue(void)
|