/*
* Sylpheed -- a GTK+ based, lightweight, and fast e-mail client
- * Copyright (C) 1999-2005 Hiroyuki Yamamoto
+ * Copyright (C) 1999-2006 Hiroyuki Yamamoto and the Sylpheed-Claws team
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
int online_mode;
gchar *crash_params;
gboolean exit;
+ gboolean subscribe;
+ const gchar *subscribe_uri;
} cmd;
static void parse_cmd_opt(int argc, char *argv[]);
{
while(gtk_events_pending())
gtk_main_iteration();
- usleep(50000);
+ g_usleep(50000);
}
gboolean defer_check_all(void *data)
GtkWidget *window = NULL;
if (alertpanel(_("Migration of configuration"),
message,
- GTK_STOCK_YES, GTK_STOCK_NO, NULL) != G_ALERTDEFAULT)
+ GTK_STOCK_NO, GTK_STOCK_YES, NULL) != G_ALERTALTERNATE)
return FALSE;
window = label_window_create(_("Copying configuration..."));
lock_socket_remove();
return 0;
}
+
+ if (cmd.exit)
+ return 0;
#endif
g_thread_init(NULL);
/* gdk_threads_init(); */
CHDIR_RETURN_VAL_IF_FAIL(get_rc_dir(), 1);
+ MAKE_DIR_IF_NOT_EXIST(get_mail_base_dir());
MAKE_DIR_IF_NOT_EXIST(get_imap_cache_dir());
MAKE_DIR_IF_NOT_EXIST(get_news_cache_dir());
MAKE_DIR_IF_NOT_EXIST(get_mime_tmp_dir());
plugin_load_all("GTK2");
+ if (!folder_have_mailbox()) {
+ alertpanel_error(_("Sylpheed-Claws has detected a configured "
+ "mailbox, but could not load it. It is "
+ "probably provided by an out-of-date "
+ "external plugin. Please reinstall the "
+ "plugin and try again."));
+ exit(1);
+ }
+
static_mainwindow = mainwin;
#ifdef HAVE_STARTUP_NOTIFICATION
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();
lock_socket_remove();
- main_window_destroy(mainwin);
+ main_window_destroy_all();
plugin_unload_all("GTK2");
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;
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"));
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;
+ }
+ }
}
}
if (prefs_common.warn_queued_on_exit && get_queued_message_num() > 0) {
if (alertpanel(_("Queued messages"),
_("Some unsent messages are queued. Exit now?"),
- GTK_STOCK_OK, GTK_STOCK_CANCEL, NULL)
- != G_ALERTDEFAULT)
+ GTK_STOCK_CANCEL, GTK_STOCK_OK, NULL)
+ != G_ALERTALTERNATE)
return;
manage_window_focus_in(mainwin->window, NULL, NULL);
}
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) {
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)) {
static void install_basic_sighandlers()
{
+#ifndef G_OS_WIN32
sigset_t mask;
struct sigaction act;
#endif
sigprocmask(SIG_UNBLOCK, &mask, 0);
+#endif /* !G_OS_WIN32 */
}