2 * Sylpheed -- a GTK+ based, lightweight, and fast e-mail client
3 * Copyright (C) 1999-2007 Hiroyuki Yamamoto and the Claws Mail team
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
27 #include <glib/gi18n.h>
28 #include <gtk/gtkmain.h>
29 #include <gtk/gtkrc.h>
38 #include <sys/types.h>
43 #include <X11/SM/SMlib.h>
48 #ifdef HAVE_STARTUP_NOTIFICATION
49 # define SN_API_NOT_YET_FROZEN
50 # include <libsn/sn-launchee.h>
51 # include <gdk/gdkx.h>
56 #include "mainwindow.h"
57 #include "folderview.h"
58 #include "image_viewer.h"
59 #include "summaryview.h"
60 #include "prefs_common.h"
61 #include "prefs_account.h"
62 #include "prefs_actions.h"
63 #include "prefs_ext_prog.h"
64 #include "prefs_fonts.h"
65 #include "prefs_image_viewer.h"
66 #include "prefs_message.h"
67 #include "prefs_receive.h"
68 #include "prefs_msg_colors.h"
69 #include "prefs_quote.h"
70 #include "prefs_spelling.h"
71 #include "prefs_summaries.h"
72 #include "prefs_themes.h"
73 #include "prefs_other.h"
74 #include "prefs_logging.h"
75 #include "prefs_send.h"
76 #include "prefs_wrapping.h"
77 #include "prefs_compose_writing.h"
78 #include "prefs_display_header.h"
83 #include "manage_window.h"
84 #include "alertpanel.h"
85 #include "statusbar.h"
86 #include "addressbook.h"
94 #include "prefs_toolbar.h"
101 #include "imap-thread.h"
103 #include "stock_pixmap.h"
105 #include "valgrind.h"
118 #include <hildon-widgets/hildon-program.h>
119 #include <gtk/gtkmain.h>
122 #define OSSO_NAME "claws_mail"
123 #define OSSO_SERVICE "com.nokia."OSSO_NAME
124 #define OSSO_OBJECT "/com/nokia/"OSSO_NAME
125 #define OSSO_IFACE "com.nokia."OSSO_NAME
127 typedef struct _AppData AppData;
129 HildonProgram *program;
130 HildonWindow *window;
131 osso_context_t *osso_context;
138 #ifdef HAVE_STARTUP_NOTIFICATION
139 static SnLauncheeContext *sn_context = NULL;
140 static SnDisplay *sn_display = NULL;
143 static gint lock_socket = -1;
144 static gint lock_socket_tag = 0;
145 static gchar *x_display = NULL;
148 ONLINE_MODE_DONT_CHANGE,
153 static struct RemoteCmd {
155 gboolean receive_all;
157 const gchar *compose_mailto;
158 GPtrArray *attach_files;
160 gboolean status_full;
161 GPtrArray *status_folders;
162 GPtrArray *status_full_folders;
169 const gchar *subscribe_uri;
173 static void parse_cmd_opt(int argc, char *argv[]);
175 static gint prohibit_duplicate_launch (void);
176 static gchar * get_crashfile_name (void);
177 static gint lock_socket_remove (void);
178 static void lock_socket_input_cb (gpointer data,
180 GdkInputCondition condition);
182 static void open_compose_new (const gchar *address,
183 GPtrArray *attach_files);
185 static void send_queue (void);
186 static void initial_processing (FolderItem *item, gpointer data);
187 static void quit_signal_handler (int sig);
188 static void install_basic_sighandlers (void);
189 static void exit_claws (MainWindow *mainwin);
191 #define MAKE_DIR_IF_NOT_EXIST(dir) \
193 if (!is_dir_exist(dir)) { \
194 if (is_file_exist(dir)) { \
196 (_("File '%s' already exists.\n" \
197 "Can't create folder."), \
201 if (make_dir(dir) < 0) \
206 static MainWindow *static_mainwindow;
209 static HildonProgram *static_hildonprogram;
210 static osso_context_t *static_osso_context;
212 void exit_event_handler(gboolean die_now, gpointer data)
215 appdata = (AppData *) data;
216 /* Do whatever application needs to do before exiting */
217 exit_claws(static_mainwindow);
218 hildon_banner_show_information(GTK_WIDGET(appdata->window), NULL,
223 /* Callback for normal D-BUS messages */
224 gint dbus_req_handler(const gchar * interface, const gchar * method,
225 GArray * arguments, gpointer data,
229 appdata = (AppData *) data;
231 osso_system_note_infoprint(appdata->osso_context, method, retval);
232 osso_rpc_free_val(retval);
237 static gboolean emergency_exit = FALSE;
239 #ifdef HAVE_STARTUP_NOTIFICATION
240 static void sn_error_trap_push(SnDisplay *display, Display *xdisplay)
242 gdk_error_trap_push();
245 static void sn_error_trap_pop(SnDisplay *display, Display *xdisplay)
247 gdk_error_trap_pop();
250 static void startup_notification_complete(gboolean with_window)
253 GtkWidget *hack = NULL;
256 /* this is needed to make the startup notification leave,
257 * if we have been launched from a menu.
258 * We have to display a window, so let it be very little */
259 hack = gtk_window_new(GTK_WINDOW_POPUP);
260 gtk_widget_set_uposition(hack, 0, 0);
261 gtk_widget_set_size_request(hack, 1, 1);
262 gtk_widget_show(hack);
265 xdisplay = GDK_DISPLAY();
266 sn_display = sn_display_new(xdisplay,
269 sn_context = sn_launchee_context_new_from_environment(sn_display,
270 DefaultScreen(xdisplay));
272 if (sn_context != NULL) {
273 sn_launchee_context_complete(sn_context);
274 sn_launchee_context_unref(sn_context);
275 sn_display_unref(sn_display);
278 gtk_widget_destroy(hack);
281 #endif /* HAVE_STARTUP_NOTIFICATION */
283 static void claws_gtk_idle(void)
285 while(gtk_events_pending()) {
286 gtk_main_iteration();
291 static gboolean defer_check_all(void *data)
293 gboolean autochk = GPOINTER_TO_INT(data);
295 inc_all_account_mail(static_mainwindow, autochk,
296 prefs_common.newmail_notify_manu);
301 static gboolean defer_check(void *data)
303 inc_mail(static_mainwindow, prefs_common.newmail_notify_manu);
308 static gboolean defer_jump(void *data)
310 if (cmd.receive_all) {
311 defer_check_all(GINT_TO_POINTER(FALSE));
312 } else if (prefs_common.chk_on_startup) {
313 defer_check_all(GINT_TO_POINTER(TRUE));
314 } else if (cmd.receive) {
317 mainwindow_jump_to(data);
321 static void chk_update_val(GtkWidget *widget, gpointer data)
323 gboolean *val = (gboolean *)data;
324 *val = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widget));
327 static gboolean migrate_old_config(const gchar *old_cfg_dir, const gchar *new_cfg_dir, const gchar *oldversion)
329 gchar *message = g_strdup_printf(_("Configuration for %s (or previous) found.\n"
330 "Do you want to migrate this configuration?"), oldversion);
332 GtkWidget *window = NULL;
333 GtkWidget *keep_backup_chk;
334 GtkTooltips *tips = gtk_tooltips_new();
335 gboolean backup = TRUE;
337 keep_backup_chk = gtk_check_button_new_with_label (_("Keep old configuration"));
338 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(keep_backup_chk), TRUE);
339 gtk_tooltips_set_tip(GTK_TOOLTIPS(tips), keep_backup_chk,
340 _("Keeping a backup will allow you to go back to an "
341 "older version, but may take a while if you have "
342 "cached IMAP or News data, and will take some extra "
343 "room on your disk."),
346 g_signal_connect(G_OBJECT(keep_backup_chk), "toggled",
347 G_CALLBACK(chk_update_val), &backup);
349 if (alertpanel_full(_("Migration of configuration"), message,
350 GTK_STOCK_NO, "+" GTK_STOCK_YES, NULL, FALSE,
351 keep_backup_chk, ALERT_QUESTION, G_ALERTDEFAULT) != G_ALERTALTERNATE) {
355 /* we can either do a fast migration requiring not any extra disk
356 * space, or a slow one that copies the old configuration and leaves
360 window = label_window_create(_("Copying configuration... This may take a while..."));
363 r = copy_dir(old_cfg_dir, new_cfg_dir);
364 label_window_destroy(window);
366 /* if copy failed, we'll remove the partially copied
369 alertpanel_error(_("Migration failed!"));
370 remove_dir_recursive(new_cfg_dir);
373 /* fast mode failed, but we don't want backup */
374 remove_dir_recursive(old_cfg_dir);
378 window = label_window_create(_("Migrating configuration..."));
381 r = g_rename(old_cfg_dir, new_cfg_dir);
382 label_window_destroy(window);
384 /* if g_rename failed, we'll try to copy */
386 FILE_OP_ERROR(new_cfg_dir, "g_rename failed, trying copy\n");
393 static void migrate_common_rc(const gchar *old_rc, const gchar *new_rc)
396 gchar *plugin_path, *old_plugin_path, *new_plugin_path;
398 oldfp = g_fopen(old_rc, "r");
401 newfp = g_fopen(new_rc, "w");
407 plugin_path = g_strdup(get_plugin_dir());
408 new_plugin_path = g_strdup(plugin_path);
410 if (strstr(plugin_path, "/claws-mail/")) {
411 gchar *end = g_strdup(strstr(plugin_path, "/claws-mail/")+strlen("/claws-mail/"));
412 *(strstr(plugin_path, "/claws-mail/")) = '\0';
413 old_plugin_path = g_strconcat(plugin_path, "/sylpheed-claws/", end, NULL);
416 old_plugin_path = g_strdup(new_plugin_path);
418 debug_print("replacing %s with %s\n", old_plugin_path, new_plugin_path);
419 while (fgets(buf, sizeof(buf), oldfp)) {
420 if (strncmp(buf, old_plugin_path, strlen(old_plugin_path))) {
423 debug_print("->replacing %s", buf);
424 debug_print(" with %s%s", new_plugin_path, buf+strlen(old_plugin_path));
425 fputs(new_plugin_path, newfp);
426 fputs(buf+strlen(old_plugin_path), newfp);
430 g_free(new_plugin_path);
431 g_free(old_plugin_path);
438 sc_client_set_value (MainWindow *mainwin,
449 prop.num_vals = num_vals;
453 if (mainwin->smc_conn)
454 SmcSetProperties ((SmcConn) mainwin->smc_conn, 1, proplist);
457 static void sc_die_callback (SmcConn smc_conn, SmPointer client_data)
462 static void sc_save_complete_callback(SmcConn smc_conn, SmPointer client_data)
466 static void sc_shutdown_cancelled_callback (SmcConn smc_conn, SmPointer client_data)
468 MainWindow *mainwin = (MainWindow *)client_data;
469 if (mainwin->smc_conn)
470 SmcSaveYourselfDone ((SmcConn) mainwin->smc_conn, TRUE);
473 static void sc_save_yourself_callback (SmcConn smc_conn,
474 SmPointer client_data,
480 MainWindow *mainwin = (MainWindow *)client_data;
481 if (mainwin->smc_conn)
482 SmcSaveYourselfDone ((SmcConn) mainwin->smc_conn, TRUE);
485 static IceIOErrorHandler sc_ice_installed_handler;
487 static void sc_ice_io_error_handler (IceConn connection)
489 if (sc_ice_installed_handler)
490 (*sc_ice_installed_handler) (connection);
492 static gboolean sc_process_ice_messages (GIOChannel *source,
493 GIOCondition condition,
496 IceConn connection = (IceConn) data;
497 IceProcessMessagesStatus status;
499 status = IceProcessMessages (connection, NULL, NULL);
501 if (status == IceProcessMessagesIOError) {
502 IcePointer context = IceGetConnectionContext (connection);
504 if (context && GTK_IS_OBJECT (context)) {
505 guint disconnect_id = g_signal_lookup ("disconnect", G_OBJECT_TYPE (context));
507 if (disconnect_id > 0)
508 g_signal_emit (context, disconnect_id, 0);
510 IceSetShutdownNegotiation (connection, False);
511 IceCloseConnection (connection);
518 static void new_ice_connection (IceConn connection, IcePointer client_data, Bool opening,
519 IcePointer *watch_data)
525 /* Make sure we don't pass on these file descriptors to any
527 fcntl(IceConnectionNumber(connection),F_SETFD,
528 fcntl(IceConnectionNumber(connection),F_GETFD,0) | FD_CLOEXEC);
530 channel = g_io_channel_unix_new (IceConnectionNumber (connection));
531 input_id = g_io_add_watch (channel,
532 G_IO_IN | G_IO_HUP | G_IO_ERR | G_IO_PRI,
533 sc_process_ice_messages,
535 g_io_channel_unref (channel);
537 *watch_data = (IcePointer) GUINT_TO_POINTER (input_id);
539 input_id = GPOINTER_TO_UINT ((gpointer) *watch_data);
540 g_source_remove (input_id);
544 static void sc_session_manager_connect(MainWindow *mainwin)
546 static gboolean connected = FALSE;
547 SmcCallbacks callbacks;
549 IceIOErrorHandler default_handler;
556 sc_ice_installed_handler = IceSetIOErrorHandler (NULL);
557 default_handler = IceSetIOErrorHandler (sc_ice_io_error_handler);
559 if (sc_ice_installed_handler == default_handler)
560 sc_ice_installed_handler = NULL;
562 IceAddConnectionWatch (new_ice_connection, NULL);
565 callbacks.save_yourself.callback = sc_save_yourself_callback;
566 callbacks.die.callback = sc_die_callback;
567 callbacks.save_complete.callback = sc_save_complete_callback;
568 callbacks.shutdown_cancelled.callback = sc_shutdown_cancelled_callback;
570 callbacks.save_yourself.client_data =
571 callbacks.die.client_data =
572 callbacks.save_complete.client_data =
573 callbacks.shutdown_cancelled.client_data = (SmPointer) mainwin;
574 if (g_getenv ("SESSION_MANAGER")) {
575 gchar error_string_ret[256] = "";
577 mainwin->smc_conn = (gpointer)
578 SmcOpenConnection (NULL, mainwin,
579 SmProtoMajor, SmProtoMinor,
580 SmcSaveYourselfProcMask | SmcDieProcMask |
581 SmcSaveCompleteProcMask |
582 SmcShutdownCancelledProcMask,
585 256, error_string_ret);
587 if (error_string_ret[0] || mainwin->smc_conn == NULL)
588 g_warning ("While connecting to session manager:\n%s.",
592 vals = g_new (SmPropValue, 1);
593 vals[0].length = strlen(argv0);
594 vals[0].value = argv0;
595 sc_client_set_value (mainwin, SmCloneCommand, SmLISTofARRAY8, 1, vals);
596 sc_client_set_value (mainwin, SmRestartCommand, SmLISTofARRAY8, 1, vals);
597 sc_client_set_value (mainwin, SmProgram, SmARRAY8, 1, vals);
599 vals[0].length = strlen(g_get_user_name()?g_get_user_name():"");
600 vals[0].value = g_strdup(g_get_user_name()?g_get_user_name():"");
601 sc_client_set_value (mainwin, SmUserID, SmARRAY8, 1, vals);
607 static gboolean sc_exiting = FALSE;
608 static gboolean sc_starting = FALSE;
609 static gboolean show_at_startup = TRUE;
611 void main_set_show_at_startup(gboolean show)
613 show_at_startup = show;
616 int main(int argc, char *argv[])
619 osso_context_t *osso_context;
620 osso_return_t result;
624 FolderView *folderview;
626 gboolean crash_file_present = FALSE;
627 gint num_folder_class = 0;
628 gboolean asked_for_migration = FALSE;
630 START_TIMING("startup");
634 if (!claws_init(&argc, &argv)) {
638 prefs_prepare_cache();
639 prog_version = PROG_VERSION;
640 argv0 = g_strdup(argv[0]);
642 parse_cmd_opt(argc, argv);
647 gtk_init(&argc, &argv);
648 crash_main(cmd.crash_params);
651 crash_install_handlers();
653 install_basic_sighandlers();
656 /* check and create unix domain socket for remote operation */
658 lock_socket = prohibit_duplicate_launch();
659 if (lock_socket < 0) {
660 #ifdef HAVE_STARTUP_NOTIFICATION
661 if(gtk_init_check(&argc, &argv))
662 startup_notification_complete(TRUE);
667 if (cmd.status || cmd.status_full) {
668 puts("0 Claws Mail not running.");
669 lock_socket_remove();
676 if (!g_thread_supported())
680 gtk_init(&argc, &argv);
683 osso_context = osso_initialize(OSSO_SERVICE, "2.8.1", TRUE, NULL);
684 if (osso_context == NULL) {
687 static_hildonprogram = HILDON_PROGRAM(hildon_program_get_instance());
688 static_osso_context = osso_context;
691 gtk_widget_set_default_colormap(gdk_rgb_get_colormap());
692 gtk_widget_set_default_visual(gdk_rgb_get_visual());
694 if (!g_thread_supported()) {
695 g_error(_("g_thread is not supported by glib.\n"));
698 /* check that we're not on a too recent/old gtk+ */
699 #if GTK_CHECK_VERSION(2, 9, 0)
700 if (gtk_check_version(2, 9, 0) != NULL) {
701 alertpanel_error(_("Claws Mail has been compiled with "
702 "a more recent GTK+ library than is "
703 "currently available. This will cause "
704 "crashes. You need to upgrade GTK+ or "
705 "recompile Claws Mail."));
709 if (gtk_check_version(2, 9, 0) == NULL) {
710 alertpanel_error(_("Claws Mail has been compiled with "
711 "an older GTK+ library than is "
712 "currently available. This will cause "
713 "crashes. You need to recompile "
718 /* parse gtkrc files */
719 userrc = g_strconcat(get_home_dir(), G_DIR_SEPARATOR_S, ".gtkrc-2.0",
721 gtk_rc_parse(userrc);
723 userrc = g_strconcat(get_home_dir(), G_DIR_SEPARATOR_S, ".gtk",
724 G_DIR_SEPARATOR_S, "gtkrc-2.0", NULL);
725 gtk_rc_parse(userrc);
728 CHDIR_RETURN_VAL_IF_FAIL(get_home_dir(), 1);
730 /* no config dir exists. See if we can migrate an old config. */
731 if (!is_dir_exist(RC_DIR)) {
732 prefs_destroy_cache();
735 /* if one of the old dirs exist, we'll ask if the user
736 * want to migrates, and r will be TRUE if he said yes
737 * and migration succeeded, and FALSE otherwise.
739 if (is_dir_exist(OLD_GTK2_RC_DIR)) {
740 r = migrate_old_config(OLD_GTK2_RC_DIR, RC_DIR, "Sylpheed-Claws 2.6.0");
741 asked_for_migration = TRUE;
742 } else if (is_dir_exist(OLDER_GTK2_RC_DIR)) {
743 r = migrate_old_config(OLDER_GTK2_RC_DIR, RC_DIR, "Sylpheed-Claws 1.9.15");
744 asked_for_migration = TRUE;
745 } else if (is_dir_exist(OLD_GTK1_RC_DIR)) {
746 r = migrate_old_config(OLD_GTK1_RC_DIR, RC_DIR, "Sylpheed-Claws 1.0.5");
747 asked_for_migration = TRUE;
750 /* If migration failed or the user didn't want to do it,
751 * we create a new one (and we'll hit wizard later).
753 if (r == FALSE && !is_dir_exist(RC_DIR) && make_dir(RC_DIR) < 0)
758 if (!is_file_exist(RC_DIR G_DIR_SEPARATOR_S COMMON_RC) &&
759 is_file_exist(RC_DIR G_DIR_SEPARATOR_S OLD_COMMON_RC)) {
760 /* post 2.6 name change */
761 migrate_common_rc(RC_DIR G_DIR_SEPARATOR_S OLD_COMMON_RC,
762 RC_DIR G_DIR_SEPARATOR_S COMMON_RC);
766 plugin_load_all("Common");
768 userrc = g_strconcat(get_rc_dir(), G_DIR_SEPARATOR_S, "gtkrc-2.0", NULL);
769 gtk_rc_parse(userrc);
772 userrc = g_strconcat(get_rc_dir(), G_DIR_SEPARATOR_S, MENU_RC, NULL);
773 gtk_accel_map_load (userrc);
776 CHDIR_RETURN_VAL_IF_FAIL(get_rc_dir(), 1);
778 MAKE_DIR_IF_NOT_EXIST(get_mail_base_dir());
779 MAKE_DIR_IF_NOT_EXIST(get_imap_cache_dir());
780 MAKE_DIR_IF_NOT_EXIST(get_news_cache_dir());
781 MAKE_DIR_IF_NOT_EXIST(get_mime_tmp_dir());
782 MAKE_DIR_IF_NOT_EXIST(get_tmp_dir());
783 MAKE_DIR_IF_NOT_EXIST(UIDL_DIR);
785 crash_file_present = is_file_exist(get_crashfile_name());
786 /* remove temporary files */
787 remove_all_files(get_tmp_dir());
788 remove_all_files(get_mime_tmp_dir());
790 if (is_file_exist("claws.log")) {
791 if (rename_force("claws.log", "claws.log.bak") < 0)
792 FILE_OP_ERROR("claws.log", "rename");
794 set_log_file(LOG_PROTOCOL, "claws.log");
796 if (is_file_exist("filtering.log")) {
797 if (rename_force("filtering.log", "filtering.log.bak") < 0)
798 FILE_OP_ERROR("filtering.log", "rename");
800 set_log_file(LOG_DEBUG_FILTERING, "filtering.log");
802 CHDIR_RETURN_VAL_IF_FAIL(get_home_dir(), 1);
804 folder_system_init();
805 prefs_common_read_config();
809 prefs_ext_prog_init();
810 prefs_wrapping_init();
811 prefs_compose_writing_init();
812 prefs_msg_colors_init();
814 prefs_image_viewer_init();
816 prefs_summaries_init();
817 prefs_message_init();
819 prefs_logging_init();
820 prefs_receive_init();
823 gtkaspell_checkers_init();
824 prefs_spelling_init();
827 sock_set_io_timeout(prefs_common.io_timeout_secs);
829 imap_main_set_timeout(prefs_common.io_timeout_secs);
831 prefs_actions_read_config();
832 prefs_display_header_read_config();
833 /* prefs_filtering_read_config(); */
834 addressbook_read_file();
835 renderer_read_config();
838 stock_pixbuf_gdk(NULL, STOCK_PIXMAP_CLAWS_MAIL_ICON, &icon);
839 gtk_window_set_default_icon(icon);
841 folderview_initialize();
847 mainwin = main_window_create();
850 appdata = g_new0(AppData, 1);
851 appdata->program = static_hildonprogram;
852 appdata->window = mainwin->window;
853 appdata->osso_context = osso_context;
854 result = osso_rpc_set_cb_f(appdata->osso_context,
858 dbus_req_handler, appdata);
859 if (result != OSSO_OK) {
863 /* Add handler for Exit D-BUS messages */
864 result = osso_application_set_exit_cb(appdata->osso_context,
867 if (result != OSSO_OK) {
871 manage_window_focus_in(mainwin->window, NULL, NULL);
872 folderview = mainwin->folderview;
874 gtk_clist_freeze(GTK_CLIST(mainwin->folderview->ctree));
875 folder_item_update_freeze();
877 /* register the callback of unix domain socket input */
879 lock_socket_tag = gdk_input_add(lock_socket,
880 GDK_INPUT_READ | GDK_INPUT_EXCEPTION,
881 lock_socket_input_cb,
885 prefs_account_init();
886 account_read_config_all();
888 /* If we can't read a folder list or don't have accounts,
889 * it means the configuration's not done. Either this is
890 * a brand new install, either a failed/refused migration.
891 * So we'll start the wizard.
893 if (folder_read_list() < 0) {
894 prefs_destroy_cache();
896 /* if run_wizard returns FALSE it's because it's
897 * been cancelled. We can't do much but exit.
898 * however, if the user was asked for a migration,
899 * we remove the newly created directory so that
900 * he's asked again for migration on next launch.*/
901 if (!run_wizard(mainwin, TRUE)) {
902 if (asked_for_migration)
903 remove_dir_recursive(RC_DIR);
906 main_window_reflect_prefs_all_now();
910 if (!account_get_list()) {
911 prefs_destroy_cache();
912 if (!run_wizard(mainwin, FALSE)) {
913 if (asked_for_migration)
914 remove_dir_recursive(RC_DIR);
917 account_read_config_all();
918 if(!account_get_list()) {
925 toolbar_main_set_sensitive(mainwin);
926 main_window_set_menu_sensitive(mainwin);
928 /* if crashed, show window early so that the user
929 * sees what's happening */
930 if (!cmd.crash && crash_file_present)
931 main_window_popup(mainwin);
934 imap_main_init(prefs_common.skip_ssl_cert_check);
936 account_set_missing_folder();
937 folder_set_missing_folders();
938 folderview_set(folderview);
940 prefs_matcher_read_config();
942 /* make one all-folder processing before using claws */
943 main_window_cursor_wait(mainwin);
944 folder_func_to_all_folders(initial_processing, (gpointer *)mainwin);
946 /* if claws crashed, rebuild caches */
947 if (!cmd.crash && crash_file_present) {
949 debug_print("Claws Mail crashed, checking for new messages in local folders\n");
950 folder_item_update_thaw();
951 folderview_check_new(NULL);
952 folder_clean_cache_memory_force();
953 folder_item_update_freeze();
955 /* make the crash-indicator file */
956 str_write_to_file("foo", get_crashfile_name());
958 inc_autocheck_timer_init(mainwin);
960 /* ignore SIGPIPE signal for preventing sudden death of program */
962 signal(SIGPIPE, SIG_IGN);
964 if (cmd.online_mode == ONLINE_MODE_OFFLINE) {
965 main_window_toggle_work_offline(mainwin, TRUE, FALSE);
967 if (cmd.online_mode == ONLINE_MODE_ONLINE) {
968 main_window_toggle_work_offline(mainwin, FALSE, FALSE);
971 if (cmd.status_folders) {
972 g_ptr_array_free(cmd.status_folders, TRUE);
973 cmd.status_folders = NULL;
975 if (cmd.status_full_folders) {
976 g_ptr_array_free(cmd.status_full_folders, TRUE);
977 cmd.status_full_folders = NULL;
980 claws_register_idle_function(claws_gtk_idle);
982 prefs_toolbar_init();
984 num_folder_class = g_list_length(folder_get_list());
986 plugin_load_all("GTK2");
988 if (g_list_length(folder_get_list()) != num_folder_class) {
989 debug_print("new folders loaded, reloading processing rules\n");
990 prefs_matcher_read_config();
993 if (plugin_get_unloaded_list() != NULL) {
994 main_window_cursor_normal(mainwin);
995 alertpanel_warning(_("Some plugin(s) failed to load. "
996 "Check the Plugins configuration "
997 "for more information."));
998 main_window_cursor_wait(mainwin);
1001 plugin_load_standard_plugins ();
1003 /* if not crashed, show window now */
1004 if (!(!cmd.crash && crash_file_present)) {
1005 /* apart if something told not to show */
1006 if (show_at_startup)
1007 main_window_popup(mainwin);
1010 if (!folder_have_mailbox()) {
1011 prefs_destroy_cache();
1012 main_window_cursor_normal(mainwin);
1013 if (folder_get_list() != NULL) {
1014 alertpanel_error(_("Claws Mail has detected a configured "
1015 "mailbox, but it is incomplete. It is "
1016 "possibly due to a failing IMAP account. Use "
1017 "\"Rebuild folder tree\" on the mailbox parent "
1018 "folder's context menu to try to fix it."));
1020 alertpanel_error(_("Claws Mail has detected a configured "
1021 "mailbox, but could not load it. It is "
1022 "probably provided by an out-of-date "
1023 "external plugin. Please reinstall the "
1024 "plugin and try again."));
1025 exit_claws(mainwin);
1030 static_mainwindow = mainwin;
1032 #ifdef HAVE_STARTUP_NOTIFICATION
1033 startup_notification_complete(FALSE);
1036 sc_session_manager_connect(mainwin);
1038 folder_item_update_thaw();
1039 gtk_clist_thaw(GTK_CLIST(mainwin->folderview->ctree));
1040 main_window_cursor_normal(mainwin);
1042 if (cmd.receive_all && !cmd.target) {
1043 g_timeout_add(1000, defer_check_all, GINT_TO_POINTER(FALSE));
1044 } else if (prefs_common.chk_on_startup && !cmd.target) {
1045 g_timeout_add(1000, defer_check_all, GINT_TO_POINTER(TRUE));
1046 } else if (cmd.receive && !cmd.target) {
1047 g_timeout_add(1000, defer_check, NULL);
1049 gtk_widget_grab_focus(folderview->ctree);
1053 open_compose_new(cmd.compose_mailto, cmd.attach_files);
1055 if (cmd.attach_files) {
1056 ptr_array_free_strings(cmd.attach_files);
1057 g_ptr_array_free(cmd.attach_files, TRUE);
1058 cmd.attach_files = NULL;
1060 if (cmd.subscribe) {
1061 folder_subscribe(cmd.subscribe_uri);
1069 g_timeout_add(500, defer_jump, (gpointer)cmd.target);
1072 prefs_destroy_cache();
1074 compose_reopen_exit_drafts();
1076 sc_starting = FALSE;
1082 osso_deinitialize(osso_context);
1084 exit_claws(mainwin);
1089 static void save_all_caches(FolderItem *item, gpointer data)
1096 folder_item_close(item);
1098 folder_item_free_cache(item, TRUE);
1101 static void exit_claws(MainWindow *mainwin)
1107 debug_print("shutting down\n");
1108 inc_autocheck_timer_remove();
1110 if (prefs_common.clean_on_exit && !emergency_exit) {
1111 main_window_empty_trash(mainwin, prefs_common.ask_on_clean);
1114 /* save prefs for opened folder */
1115 if(mainwin->folderview->opened) {
1118 item = gtk_ctree_node_get_row_data(GTK_CTREE(mainwin->folderview->ctree), mainwin->folderview->opened);
1119 summary_save_prefs_to_folderitem(mainwin->folderview->summaryview, item);
1122 /* save all state before exiting */
1123 folder_func_to_all_folders(save_all_caches, NULL);
1124 folder_write_list();
1126 main_window_get_size(mainwin);
1127 main_window_get_position(mainwin);
1129 prefs_common_write_config();
1130 account_write_config_all();
1131 addressbook_export_to_file();
1133 filename = g_strconcat(get_rc_dir(), G_DIR_SEPARATOR_S, MENU_RC, NULL);
1134 gtk_accel_map_save(filename);
1137 /* delete temporary files */
1138 remove_all_files(get_tmp_dir());
1139 remove_all_files(get_mime_tmp_dir());
1141 close_log_file(LOG_PROTOCOL);
1142 close_log_file(LOG_DEBUG_FILTERING);
1144 #ifdef HAVE_LIBETPAN
1147 /* delete crashfile */
1149 g_unlink(get_crashfile_name());
1151 lock_socket_remove();
1154 if (mainwin->smc_conn)
1155 SmcCloseConnection ((SmcConn)mainwin->smc_conn, 0, NULL);
1156 mainwin->smc_conn = NULL;
1159 main_window_destroy_all();
1161 plugin_unload_all("GTK2");
1163 prefs_toolbar_done();
1165 addressbook_destroy();
1167 prefs_themes_done();
1169 prefs_ext_prog_done();
1170 prefs_wrapping_done();
1171 prefs_compose_writing_done();
1172 prefs_msg_colors_done();
1173 prefs_image_viewer_done();
1174 image_viewer_done();
1176 prefs_summaries_done();
1177 prefs_message_done();
1179 prefs_receive_done();
1182 prefs_spelling_done();
1183 gtkaspell_checkers_quit();
1185 plugin_unload_all("Common");
1189 static void parse_cmd_opt(int argc, char *argv[])
1193 for (i = 1; i < argc; i++) {
1194 if (!strncmp(argv[i], "--receive-all", 13)) {
1195 cmd.receive_all = TRUE;
1196 } else if (!strncmp(argv[i], "--receive", 9)) {
1198 } else if (!strncmp(argv[i], "--compose", 9)) {
1199 const gchar *p = argv[i + 1];
1202 cmd.compose_mailto = NULL;
1203 if (p && *p != '\0' && *p != '-') {
1204 if (!strncmp(p, "mailto:", 7)) {
1205 cmd.compose_mailto = p + 7;
1207 cmd.compose_mailto = p;
1211 } else if (!strncmp(argv[i], "--subscribe", 11)) {
1212 const gchar *p = argv[i + 1];
1213 if (p && *p != '\0' && *p != '-') {
1214 cmd.subscribe = TRUE;
1215 cmd.subscribe_uri = p;
1217 } else if (!strncmp(argv[i], "--attach", 8)) {
1218 const gchar *p = argv[i + 1];
1221 while (p && *p != '\0' && *p != '-') {
1222 if (!cmd.attach_files) {
1223 cmd.attach_files = g_ptr_array_new();
1225 if ((file = g_filename_from_uri(p, NULL, NULL)) != NULL) {
1226 if (!is_file_exist(file)) {
1231 if (file == NULL && *p != G_DIR_SEPARATOR) {
1232 file = g_strconcat(claws_get_startup_dir(),
1235 } else if (file == NULL) {
1238 g_ptr_array_add(cmd.attach_files, file);
1242 } else if (!strncmp(argv[i], "--send", 6)) {
1244 } else if (!strncmp(argv[i], "--version", 9) ||
1245 !strncmp(argv[i], "-v", 2)) {
1246 puts("Claws Mail version " VERSION);
1248 } else if (!strncmp(argv[i], "--status-full", 13)) {
1249 const gchar *p = argv[i + 1];
1251 cmd.status_full = TRUE;
1252 while (p && *p != '\0' && *p != '-') {
1253 if (!cmd.status_full_folders) {
1254 cmd.status_full_folders =
1257 g_ptr_array_add(cmd.status_full_folders,
1262 } else if (!strncmp(argv[i], "--status", 8)) {
1263 const gchar *p = argv[i + 1];
1266 while (p && *p != '\0' && *p != '-') {
1267 if (!cmd.status_folders)
1268 cmd.status_folders = g_ptr_array_new();
1269 g_ptr_array_add(cmd.status_folders,
1274 } else if (!strncmp(argv[i], "--online", 8)) {
1275 cmd.online_mode = ONLINE_MODE_ONLINE;
1276 } else if (!strncmp(argv[i], "--offline", 9)) {
1277 cmd.online_mode = ONLINE_MODE_OFFLINE;
1278 } else if (!strncmp(argv[i], "--help", 6) ||
1279 !strncmp(argv[i], "-h", 2)) {
1280 gchar *base = g_path_get_basename(argv[0]);
1281 g_print(_("Usage: %s [OPTION]...\n"), base);
1283 g_print("%s\n", _(" --compose [address] open composition window"));
1284 g_print("%s\n", _(" --subscribe [uri] subscribe to the given URI if possible"));
1285 g_print("%s\n", _(" --attach file1 [file2]...\n"
1286 " open composition window with specified files\n"
1288 g_print("%s\n", _(" --receive receive new messages"));
1289 g_print("%s\n", _(" --receive-all receive new messages of all accounts"));
1290 g_print("%s\n", _(" --send send all queued messages"));
1291 g_print("%s\n", _(" --status [folder]... show the total number of messages"));
1292 g_print("%s\n", _(" --status-full [folder]...\n"
1293 " show the status of each folder"));
1294 g_print("%s\n", _(" --select folder[/msg] jumps to the specified folder/message\n"
1295 " folder is a folder id like 'folder/sub_folder'"));
1296 g_print("%s\n", _(" --online switch to online mode"));
1297 g_print("%s\n", _(" --offline switch to offline mode"));
1298 g_print("%s\n", _(" --exit --quit -q exit Claws Mail"));
1299 g_print("%s\n", _(" --debug debug mode"));
1300 g_print("%s\n", _(" --help -h display this help and exit"));
1301 g_print("%s\n", _(" --version -v output version information and exit"));
1302 g_print("%s\n", _(" --config-dir output configuration directory"));
1306 } else if (!strncmp(argv[i], "--crash", 7)) {
1308 cmd.crash_params = g_strdup(argv[i + 1]);
1310 } else if (!strncmp(argv[i], "--config-dir", sizeof "--config-dir" - 1)) {
1313 } else if (!strncmp(argv[i], "--exit", 6) ||
1314 !strncmp(argv[i], "--quit", 6) ||
1315 !strncmp(argv[i], "-q", 2)) {
1317 } else if (!strncmp(argv[i], "--select", 8) && i+1 < argc) {
1318 cmd.target = argv[i+1];
1319 } else if (i == 1 && argc == 2) {
1320 /* only one parameter. Do something intelligent about it */
1321 if (strstr(argv[i], "@") && !strstr(argv[i], "://")) {
1322 const gchar *p = argv[i];
1325 cmd.compose_mailto = NULL;
1326 if (p && *p != '\0' && *p != '-') {
1327 if (!strncmp(p, "mailto:", 7)) {
1328 cmd.compose_mailto = p + 7;
1330 cmd.compose_mailto = p;
1333 } else if (strstr(argv[i], "://")) {
1334 const gchar *p = argv[i];
1335 if (p && *p != '\0' && *p != '-') {
1336 cmd.subscribe = TRUE;
1337 cmd.subscribe_uri = p;
1339 } else if (!strcmp(argv[i], "--sync")) {
1342 g_print(_("Unknown option\n"));
1348 if (cmd.attach_files && cmd.compose == FALSE) {
1350 cmd.compose_mailto = NULL;
1354 static void initial_processing(FolderItem *item, gpointer data)
1356 MainWindow *mainwin = (MainWindow *)data;
1359 g_return_if_fail(item);
1360 buf = g_strdup_printf(_("Processing (%s)..."),
1363 : _("top level folder"));
1367 if (item->prefs->enable_processing) {
1368 folder_item_apply_processing(item);
1371 STATUSBAR_POP(mainwin);
1374 static void draft_all_messages(void)
1376 GList *compose_list = NULL;
1378 compose_clear_exit_drafts();
1379 while ((compose_list = compose_get_compose_list()) != NULL) {
1380 Compose *c = (Compose*)compose_list->data;
1381 compose_draft(c, COMPOSE_DRAFT_FOR_EXIT);
1384 gboolean clean_quit(gpointer data)
1386 static gboolean firstrun = TRUE;
1393 /*!< Good idea to have the main window stored in a
1394 * static variable so we can check that variable
1395 * to see if we're really allowed to do things
1396 * that actually the spawner is supposed to
1397 * do (like: sending mail, composing messages).
1398 * Because, really, if we're the spawnee, and
1399 * we touch GTK stuff, we're hosed. See the
1402 /* FIXME: Use something else to signal that we're
1403 * in the original spawner, and not in a spawned
1405 if (!static_mainwindow) {
1409 draft_all_messages();
1410 emergency_exit = TRUE;
1411 exit_claws(static_mainwindow);
1417 void app_will_exit(GtkWidget *widget, gpointer data)
1419 MainWindow *mainwin = data;
1421 if (sc_exiting == TRUE) {
1422 debug_print("exit pending\n");
1426 debug_print("exiting\n");
1427 if (compose_get_compose_list()) {
1428 draft_all_messages();
1431 if (prefs_common.warn_queued_on_exit && procmsg_have_queued_mails_fast()) {
1432 if (alertpanel(_("Queued messages"),
1433 _("Some unsent messages are queued. Exit now?"),
1434 GTK_STOCK_CANCEL, GTK_STOCK_OK, NULL)
1435 != G_ALERTALTERNATE) {
1436 main_window_popup(mainwin);
1440 manage_window_focus_in(mainwin->window, NULL, NULL);
1444 #ifdef HAVE_VALGRIND
1445 if (RUNNING_ON_VALGRIND) {
1446 summary_clear_list(mainwin->summaryview);
1449 if (folderview_get_selected_item(mainwin->folderview))
1450 folder_item_close(folderview_get_selected_item(mainwin->folderview));
1454 gboolean claws_is_exiting(void)
1459 gboolean claws_is_starting(void)
1465 * CLAWS: want this public so crash dialog can delete the
1468 gchar *claws_get_socket_name(void)
1470 static gchar *filename = NULL;
1472 if (filename == NULL) {
1473 filename = g_strdup_printf("%s%cclaws-mail-%d",
1474 g_get_tmp_dir(), G_DIR_SEPARATOR,
1485 static gchar *get_crashfile_name(void)
1487 static gchar *filename = NULL;
1489 if (filename == NULL) {
1490 filename = g_strdup_printf("%s%cclaws-crashed",
1491 get_tmp_dir(), G_DIR_SEPARATOR);
1497 static gint prohibit_duplicate_launch(void)
1502 path = claws_get_socket_name();
1503 uxsock = fd_connect_unix(path);
1505 if (x_display == NULL)
1506 x_display = g_strdup(g_getenv("DISPLAY"));
1510 return fd_open_unix(path);
1513 /* remote command mode */
1515 debug_print("another Claws Mail instance is already running.\n");
1517 if (cmd.receive_all) {
1518 fd_write_all(uxsock, "receive_all\n", 12);
1519 } else if (cmd.receive) {
1520 fd_write_all(uxsock, "receive\n", 8);
1521 } else if (cmd.compose && cmd.attach_files) {
1522 gchar *str, *compose_str;
1525 if (cmd.compose_mailto) {
1526 compose_str = g_strdup_printf("compose_attach %s\n",
1527 cmd.compose_mailto);
1529 compose_str = g_strdup("compose_attach\n");
1532 fd_write_all(uxsock, compose_str, strlen(compose_str));
1533 g_free(compose_str);
1535 for (i = 0; i < cmd.attach_files->len; i++) {
1536 str = g_ptr_array_index(cmd.attach_files, i);
1537 fd_write_all(uxsock, str, strlen(str));
1538 fd_write_all(uxsock, "\n", 1);
1541 fd_write_all(uxsock, ".\n", 2);
1542 } else if (cmd.compose) {
1545 if (cmd.compose_mailto) {
1546 compose_str = g_strdup_printf
1547 ("compose %s\n", cmd.compose_mailto);
1549 compose_str = g_strdup("compose\n");
1552 fd_write_all(uxsock, compose_str, strlen(compose_str));
1553 g_free(compose_str);
1554 } else if (cmd.subscribe) {
1555 gchar *str = g_strdup_printf("subscribe %s\n", cmd.subscribe_uri);
1556 fd_write_all(uxsock, str, strlen(str));
1558 } else if (cmd.send) {
1559 fd_write_all(uxsock, "send\n", 5);
1560 } else if (cmd.online_mode == ONLINE_MODE_ONLINE) {
1561 fd_write(uxsock, "online\n", 6);
1562 } else if (cmd.online_mode == ONLINE_MODE_OFFLINE) {
1563 fd_write(uxsock, "offline\n", 7);
1564 } else if (cmd.status || cmd.status_full) {
1565 gchar buf[BUFFSIZE];
1567 const gchar *command;
1571 command = cmd.status_full ? "status-full\n" : "status\n";
1572 folders = cmd.status_full ? cmd.status_full_folders :
1575 fd_write_all(uxsock, command, strlen(command));
1576 for (i = 0; folders && i < folders->len; ++i) {
1577 folder = g_ptr_array_index(folders, i);
1578 fd_write_all(uxsock, folder, strlen(folder));
1579 fd_write_all(uxsock, "\n", 1);
1581 fd_write_all(uxsock, ".\n", 2);
1583 fd_gets(uxsock, buf, sizeof(buf));
1584 if (!strncmp(buf, ".\n", 2)) break;
1587 } else if (cmd.exit) {
1588 fd_write_all(uxsock, "exit\n", 5);
1589 } else if (cmd.target) {
1590 gchar *str = g_strdup_printf("select %s\n", cmd.target);
1591 fd_write_all(uxsock, str, strlen(str));
1595 fd_write_all(uxsock, "get_display\n", 12);
1596 memset(buf, 0, sizeof(buf));
1597 fd_gets(uxsock, buf, sizeof(buf));
1598 if (strcmp2(buf, x_display)) {
1599 printf("Claws Mail is already running on display %s.\n",
1603 uxsock = fd_connect_unix(path);
1604 fd_write_all(uxsock, "popup\n", 6);
1612 static gint lock_socket_remove(void)
1617 if (lock_socket < 0) {
1621 if (lock_socket_tag > 0) {
1622 gdk_input_remove(lock_socket_tag);
1624 fd_close(lock_socket);
1625 filename = claws_get_socket_name();
1632 static GPtrArray *get_folder_item_list(gint sock)
1634 gchar buf[BUFFSIZE];
1636 GPtrArray *folders = NULL;
1639 fd_gets(sock, buf, sizeof(buf));
1640 if (!strncmp(buf, ".\n", 2)) {
1645 folders = g_ptr_array_new();
1647 item = folder_find_item_from_identifier(buf);
1649 g_ptr_array_add(folders, item);
1651 g_warning("no such folder: %s\n", buf);
1658 static void lock_socket_input_cb(gpointer data,
1660 GdkInputCondition condition)
1662 MainWindow *mainwin = (MainWindow *)data;
1664 gchar buf[BUFFSIZE];
1666 sock = fd_accept(source);
1667 fd_gets(sock, buf, sizeof(buf));
1669 if (!strncmp(buf, "popup", 5)) {
1670 main_window_popup(mainwin);
1671 } else if (!strncmp(buf, "get_display", 11)) {
1672 fd_write_all(sock, x_display, strlen(x_display));
1673 } else if (!strncmp(buf, "receive_all", 11)) {
1674 inc_all_account_mail(mainwin, FALSE,
1675 prefs_common.newmail_notify_manu);
1676 } else if (!strncmp(buf, "receive", 7)) {
1677 inc_mail(mainwin, prefs_common.newmail_notify_manu);
1678 } else if (!strncmp(buf, "compose_attach", 14)) {
1682 mailto = g_strdup(buf + strlen("compose_attach") + 1);
1683 files = g_ptr_array_new();
1684 while (fd_gets(sock, buf, sizeof(buf)) > 0) {
1685 if (buf[0] == '.' && buf[1] == '\n') {
1689 g_ptr_array_add(files, g_strdup(buf));
1691 open_compose_new(mailto, files);
1692 ptr_array_free_strings(files);
1693 g_ptr_array_free(files, TRUE);
1695 } else if (!strncmp(buf, "compose", 7)) {
1696 open_compose_new(buf + strlen("compose") + 1, NULL);
1697 } else if (!strncmp(buf, "subscribe", 9)) {
1698 main_window_popup(mainwin);
1699 folder_subscribe(buf + strlen("subscribe") + 1);
1700 } else if (!strncmp(buf, "send", 4)) {
1702 } else if (!strncmp(buf, "online", 6)) {
1703 main_window_toggle_work_offline(mainwin, FALSE, FALSE);
1704 } else if (!strncmp(buf, "offline", 7)) {
1705 main_window_toggle_work_offline(mainwin, TRUE, FALSE);
1706 } else if (!strncmp(buf, "status-full", 11) ||
1707 !strncmp(buf, "status", 6)) {
1711 folders = get_folder_item_list(sock);
1712 status = folder_get_status
1713 (folders, !strncmp(buf, "status-full", 11));
1714 fd_write_all(sock, status, strlen(status));
1715 fd_write_all(sock, ".\n", 2);
1717 if (folders) g_ptr_array_free(folders, TRUE);
1718 } else if (!strncmp(buf, "select ", 7)) {
1719 const gchar *target = buf+7;
1720 mainwindow_jump_to(target);
1721 } else if (!strncmp(buf, "exit", 4)) {
1722 app_will_exit(NULL, mainwin);
1728 static void open_compose_new(const gchar *address, GPtrArray *attach_files)
1733 Xstrdup_a(addr, address, return);
1737 compose_new(NULL, addr, attach_files);
1740 static void send_queue(void)
1743 gchar *errstr = NULL;
1744 gboolean error = FALSE;
1745 for (list = folder_get_list(); list != NULL; list = list->next) {
1746 Folder *folder = list->data;
1748 if (folder->queue) {
1749 gint res = procmsg_send_queue
1750 (folder->queue, prefs_common.savemsg,
1754 folder_item_scan(folder->queue);
1762 gchar *tmp = g_strdup_printf(_("Some errors occurred "
1763 "while sending queued messages:\n%s"), errstr);
1765 alertpanel_error_log(tmp);
1768 alertpanel_error_log("Some errors occurred "
1769 "while sending queued messages.");
1773 static void quit_signal_handler(int sig)
1775 debug_print("Quitting on signal %d\n", sig);
1777 g_timeout_add(0, clean_quit, NULL);
1780 static void install_basic_sighandlers()
1784 struct sigaction act;
1789 sigaddset(&mask, SIGTERM);
1792 sigaddset(&mask, SIGINT);
1795 sigaddset(&mask, SIGHUP);
1798 act.sa_handler = quit_signal_handler;
1803 sigaction(SIGTERM, &act, 0);
1806 sigaction(SIGINT, &act, 0);
1809 sigaction(SIGHUP, &act, 0);
1812 sigprocmask(SIG_UNBLOCK, &mask, 0);
1813 #endif /* !G_OS_WIN32 */
1817 HildonProgram *hildon_program(void)
1819 return static_hildonprogram;
1821 osso_context_t *get_osso_context(void)
1823 return static_osso_context;