/*
* Sylpheed -- a GTK+ based, lightweight, and fast e-mail client
- * Copyright (C) 1999-2012 Hiroyuki Yamamoto and the Claws Mail team
+ * Copyright (C) 1999-2013 Hiroyuki Yamamoto and the Claws Mail 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
#include <sys/file.h>
#endif
+#include "file_checker.h"
#include "wizard.h"
#ifdef HAVE_STARTUP_NOTIFICATION
# define SN_API_NOT_YET_FROZEN
#include "procmsg.h"
#include "inc.h"
#include "imap.h"
+#include "send_message.h"
+#include "md5.h"
#include "import.h"
#include "manage_window.h"
#include "alertpanel.h"
#include "menu.h"
#include "quicksearch.h"
#include "advsearch.h"
+#include "avatars.h"
#ifdef HAVE_LIBETPAN
#include "imap-thread.h"
#include "timing.h"
-#ifdef MAEMO
-#ifdef CHINOOK
-#include <hildon/hildon-banner.h>
-#include <hildon/hildon-program.h>
-#else
-#include <hildon-widgets/hildon-banner.h>
-#include <hildon-widgets/hildon-program.h>
-#endif
-#include <libosso.h>
-#include <libgnomevfs/gnome-vfs-volume.h>
-#include <libgnomevfs/gnome-vfs-volume-monitor.h>
-#include <libgnomevfs/gnome-vfs-utils.h>
-
-#define OSSO_NAME "claws_mail"
-#define OSSO_SERVICE "com.nokia."OSSO_NAME
-#define OSSO_OBJECT "/com/nokia/"OSSO_NAME
-#define OSSO_IFACE "com.nokia."OSSO_NAME
-
-typedef struct _AppData AppData;
-struct _AppData {
- HildonProgram *program;
- HildonWindow *window;
- osso_context_t *osso_context;
-};
-
-static GnomeVFSVolumeMonitor *volmon;
-#endif
-
#ifdef HAVE_NETWORKMANAGER_SUPPORT
/* Went offline due to NetworkManager */
static gboolean went_offline_nm;
gchar *prog_version;
gchar *argv0;
-#ifdef MAEMO
-HildonProgram *hildon_program;
-#endif
-
#ifdef HAVE_STARTUP_NOTIFICATION
static SnLauncheeContext *sn_context = NULL;
static SnDisplay *sn_display = NULL;
gboolean subscribe;
const gchar *subscribe_uri;
const gchar *target;
+ gboolean debug;
} cmd;
SessionStats session_stats;
static MainWindow *static_mainwindow;
-#ifdef MAEMO
-static osso_context_t *static_osso_context;
-
-void exit_event_handler(gboolean die_now, gpointer data)
-{
- AppData *appdata;
- appdata = (AppData *) data;
- /* Do whatever application needs to do before exiting */
- exit_claws(static_mainwindow);
- hildon_banner_show_information(GTK_WIDGET(appdata->window), NULL,
- _("Exiting..."));
-
-}
-
-/* Callback for hardware D-BUS events */
-void hw_event_handler(osso_hw_state_t *state, gpointer data)
-{
- AppData *appdata;
- appdata = (AppData *) data;
-
- if (state->shutdown_ind) {
- exit_claws(static_mainwindow);
- hildon_banner_show_information(GTK_WIDGET(appdata->window), NULL,
- _("Exiting..."));
- }
-}
-
-/* Callback for normal D-BUS messages */
-gint dbus_req_handler(const gchar * interface, const gchar * method,
- GArray * arguments, gpointer data,
- osso_rpc_t * retval)
-{
- AppData *appdata;
- appdata = (AppData *) data;
-
- if (!strcmp(method, "top_application")) {
- osso_rpc_free_val(retval);
- return OSSO_OK;
- }
- osso_system_note_infoprint(appdata->osso_context, method, retval);
- osso_rpc_free_val(retval);
-
- return OSSO_OK;
-}
-#endif
static gboolean emergency_exit = FALSE;
#ifdef HAVE_STARTUP_NOTIFICATION
inc_all_account_mail(static_mainwindow, autochk,
prefs_common.newmail_notify_manu);
- /* Accounts using a specific timer need to be checked separately
- * at startup
- */
- inc_all_account_spec_timer_check_mail();
-
if (sc_starting) {
sc_starting = FALSE;
main_window_set_menu_sensitive(static_mainwindow);
show_at_startup = show;
}
-#ifdef MAEMO
-static void main_vol_mount_cb(GnomeVFSVolumeMonitor *vfs, GnomeVFSVolume *vol, MainWindow *mainwin)
-{
- gchar *uri = gnome_vfs_volume_get_activation_uri (vol);
- gchar *mount_path = uri?gnome_vfs_get_local_path_from_uri (uri):NULL;
- g_free (uri);
- if (mount_path) {
- if(!strcmp(mount_path, prefs_common.data_root)) {
- gtk_widget_set_sensitive(mainwin->window, TRUE);
- inc_unlock();
- }
- }
- g_free(mount_path);
-}
-static void main_vol_unmount_cb(GnomeVFSVolumeMonitor *vfs, GnomeVFSVolume *vol, MainWindow *mainwin)
-{
- gchar *uri = gnome_vfs_volume_get_activation_uri (vol);
- gchar *mount_path = uri?gnome_vfs_get_local_path_from_uri (uri):NULL;
- g_free (uri);
- if (mount_path) {
- if(!strcmp(mount_path, prefs_common.data_root)) {
- gtk_widget_set_sensitive(mainwin->window, FALSE);
- inc_lock();
- }
- }
- g_free(mount_path);
-}
-#endif
-
#ifdef G_OS_WIN32
static FILE* win32_debug_fp=NULL;
static guint win32_log_handler_app_id;
static void win32_print_stdout(const gchar *string)
{
if (win32_debug_fp) {
- fprintf(win32_debug_fp, string);
+ fprintf(win32_debug_fp, "%s", string);
fflush(win32_debug_fp);
}
}
static void win32_print_stderr(const gchar *string)
{
if (win32_debug_fp) {
- fprintf(win32_debug_fp, string);
+ fprintf(win32_debug_fp, "%s", string);
fflush(win32_debug_fp);
}
}
#endif
#if USE_ENCHANT
if (show_debug_only)
- debug_print(" aspell\n");
+ debug_print(" Enchant\n");
else
- g_print(" aspell\n");
+ g_print(" Enchant\n");
#endif
#if USE_GNUTLS
if (show_debug_only)
- debug_print(" gnutls\n");
+ debug_print(" GnuTLS\n");
else
- g_print(" gnutls\n");
+ g_print(" GnuTLS\n");
#endif
#if INET6
if (show_debug_only)
- debug_print(" ipv6\n");
+ debug_print(" IPv6\n");
else
- g_print(" ipv6\n");
+ g_print(" IPv6\n");
#endif
#if HAVE_ICONV
if (show_debug_only)
#endif
#if USE_JPILOT
if (show_debug_only)
- debug_print(" jpilot\n");
+ debug_print(" JPilot\n");
else
- g_print(" jpilot\n");
+ g_print(" JPilot\n");
#endif
#if USE_LDAP
if (show_debug_only)
- debug_print(" ldap\n");
+ debug_print(" LDAP\n");
else
- g_print(" ldap\n");
+ g_print(" LDAP\n");
#endif
#if HAVE_LIBETPAN
if (show_debug_only)
#endif
#if HAVE_LIBSM
if (show_debug_only)
- debug_print(" libsm\n");
+ debug_print(" libSM\n");
else
- g_print(" libsm\n");
+ g_print(" libSM\n");
#endif
#if HAVE_NETWORKMANAGER_SUPPORT
if (show_debug_only)
int main(int argc, char *argv[])
{
-#ifdef MAEMO
- osso_context_t *osso_context;
- osso_return_t result;
-#endif
#ifdef HAVE_DBUS_GLIB
DBusGConnection *connection;
GError *error;
if (cmd.status || cmd.status_full || cmd.search ||
cmd.statistics || cmd.reset_statistics ||
- cmd.cancel_receiving || cmd.cancel_sending) {
+ cmd.cancel_receiving || cmd.cancel_sending ||
+ cmd.debug) {
puts("0 Claws Mail not running.");
lock_socket_remove();
return 0;
if (cmd.exit)
return 0;
+#if !GLIB_CHECK_VERSION(2,32,0)
if (!g_thread_supported())
g_thread_init(NULL);
+#endif
reset_statistics();
}
#endif
-
-#ifdef MAEMO
- osso_context = osso_initialize(OSSO_SERVICE, "2.8.1", TRUE, NULL);
- if (osso_context == NULL) {
- return OSSO_ERROR;
- }
- hildon_program = HILDON_PROGRAM(hildon_program_get_instance());
- static_osso_context = osso_context;
-#endif
#if !GTK_CHECK_VERSION(3, 0, 0)
gtk_widget_set_default_colormap(
gdk_screen_get_system_colormap(
prefs_spelling_init();
#endif
+#ifdef G_OS_WIN32
+ if(prefs_common.gtk_theme && strcmp(prefs_common.gtk_theme, DEFAULT_W32_GTK_THEME))
+ gtk_settings_set_string_property(gtk_settings_get_default(),
+ "gtk-theme-name",
+ prefs_common.gtk_theme,
+ "XProperty");
+#endif
+
+
sock_set_io_timeout(prefs_common.io_timeout_secs);
prefs_actions_read_config();
prefs_display_header_read_config();
mainwin = main_window_create();
+ if (!check_file_integrity())
+ exit(1);
+
#ifdef HAVE_NETWORKMANAGER_SUPPORT
networkmanager_state_change_cb(nm_proxy,NULL,mainwin);
#endif
-#ifdef MAEMO
- AppData *appdata;
- appdata = g_new0(AppData, 1);
- appdata->program = hildon_program;
- appdata->window = HILDON_WINDOW(mainwin->window);
- appdata->osso_context = osso_context;
- result = osso_rpc_set_cb_f(appdata->osso_context,
- OSSO_SERVICE,
- OSSO_OBJECT,
- OSSO_IFACE,
- dbus_req_handler, appdata);
- if (result != OSSO_OK) {
- return OSSO_ERROR;
- }
-
-#ifndef CHINOOK
- /* Add handler for Exit D-BUS messages */
- result = osso_application_set_exit_cb(appdata->osso_context,
- exit_event_handler,
- (gpointer) appdata);
- if (result != OSSO_OK) {
- return OSSO_ERROR;
- }
-#endif
- osso_hw_set_event_cb( appdata->osso_context,
- NULL, hw_event_handler, (gpointer) appdata );
-#endif
manage_window_focus_in(mainwin->window, NULL, NULL);
folderview = mainwin->folderview;
claws_register_idle_function(claws_gtk_idle);
+ avatars_init();
prefs_toolbar_init();
num_folder_class = g_list_length(folder_get_list());
static_mainwindow = mainwin;
-#ifdef MAEMO
- if (prefs_common.data_root != NULL && *prefs_common.data_root != '\0') {
- GnomeVFSVolume *vol = NULL;
- gchar *uri, *mount_path;
-
- volmon = gnome_vfs_get_volume_monitor();
- vol = gnome_vfs_volume_monitor_get_volume_for_path(volmon, prefs_common.data_root);
-
- uri = gnome_vfs_volume_get_activation_uri (vol);
- mount_path = uri?gnome_vfs_get_local_path_from_uri (uri):NULL;
- g_free(uri);
-
- if (vol == NULL || !gnome_vfs_volume_is_mounted(vol)
- || strcmp(mount_path, prefs_common.data_root)) {
- alertpanel_error(_("Claws Mail can not start without its data volume (%s)."),
- prefs_common.data_root);
- g_free(mount_path);
- gnome_vfs_volume_unref(vol);
- exit_claws(mainwin);
- exit(1);
- }
- g_free(mount_path);
- gnome_vfs_volume_unref(vol);
- g_signal_connect(G_OBJECT(volmon),
- "volume-mounted", G_CALLBACK(main_vol_mount_cb), mainwin);
- g_signal_connect(G_OBJECT(volmon),
- "volume-unmounted", G_CALLBACK(main_vol_unmount_cb), mainwin);
- }
-#endif
-
#ifdef HAVE_STARTUP_NOTIFICATION
startup_notification_complete(FALSE);
#endif
gtk_main();
-#ifdef MAEMO
- osso_deinitialize(osso_context);
-#endif
#ifdef HAVE_NETWORKMANAGER_SUPPORT
if(nm_proxy)
g_object_unref(nm_proxy);
matcher_done();
prefs_toolbar_done();
+ avatars_done();
#ifndef USE_NEW_ADDRBOOK
addressbook_destroy();
cmd.online_mode = ONLINE_MODE_ONLINE;
} else if (!strncmp(argv[i], "--offline", 9)) {
cmd.online_mode = ONLINE_MODE_OFFLINE;
+ } else if (!strncmp(argv[i], "--toggle-debug", 14)) {
+ cmd.debug = TRUE;
} else if (!strncmp(argv[i], "--statistics", 12)) {
cmd.statistics = TRUE;
} else if (!strncmp(argv[i], "--reset-statistics", 18)) {
g_print("%s\n", _(" --offline switch to offline mode"));
g_print("%s\n", _(" --exit --quit -q exit Claws Mail"));
g_print("%s\n", _(" --debug debug mode"));
+ g_print("%s\n", _(" --toggle-debug toggle debug mode"));
g_print("%s\n", _(" --help -h display this help and exit"));
g_print("%s\n", _(" --version -v output version information and exit"));
g_print("%s\n", _(" --version-full -V output version and built-in features information and exit"));
return sc_starting;
}
+#ifdef G_OS_UNIX
/*
* CLAWS: want this public so crash dialog can delete the
* lock file too
{
static gchar *filename = NULL;
const gchar *socket_dir = NULL;
-
- if (rc_dir_is_alt())
- socket_dir = get_rc_dir();
- else
- socket_dir = g_get_tmp_dir();
+ gchar md5sum[33];
+
if (filename == NULL) {
- filename = g_strdup_printf("%s%cclaws-mail-%d",
- socket_dir, G_DIR_SEPARATOR,
+ struct stat st;
+ socket_dir = g_strdup_printf("%s%cclaws-mail-%d",
+ g_get_tmp_dir(), G_DIR_SEPARATOR,
#if HAVE_GETUID
getuid());
#else
- 0);
-#endif
+ 0);
+#endif
+ if (stat(socket_dir, &st) < 0 && errno != ENOENT) {
+ g_print("Error stat'ing socket_dir %s: %s\n",
+ socket_dir, strerror(errno));
+ } else if (S_ISSOCK(st.st_mode)) {
+ /* old versions used a sock in $TMPDIR/claws-mail-$UID */
+ debug_print("Using legacy socket %s\n", socket_dir);
+ filename = g_strdup(socket_dir);
+ return filename;
+ }
+
+ if (!is_dir_exist(socket_dir) && make_dir(socket_dir) < 0) {
+ g_print("Error creating socket_dir %s: %s\n",
+ socket_dir, strerror(errno));
+ }
+
+ md5_hex_digest(md5sum, get_rc_dir());
+
+ filename = g_strdup_printf("%s%c%s", socket_dir, G_DIR_SEPARATOR,
+ md5sum);
+ debug_print("Using control socket %s\n", filename);
}
return filename;
}
+#endif
static gchar *get_crashfile_name(void)
{
x_display = g_strdup(g_getenv("DISPLAY"));
if (uxsock < 0) {
+ gint ret;
#if HAVE_FLOCK
gchar *socket_lock;
gint lock_fd;
- gint ret;
/* If connect failed, no other process is running.
* Unlink the potentially existing socket, then
* open it. This has to be done locking a temporary
fd_write(uxsock, "online\n", 6);
} else if (cmd.online_mode == ONLINE_MODE_OFFLINE) {
fd_write(uxsock, "offline\n", 7);
+ } else if (cmd.debug) {
+ fd_write(uxsock, "debug\n", 7);
} else if (cmd.status || cmd.status_full) {
gchar buf[BUFFSIZE];
gint i;
static gint lock_socket_remove(void)
{
#ifdef G_OS_UNIX
- gchar *filename;
+ gchar *filename, *dirname;
#endif
if (lock_socket < 0) {
return -1;
#ifdef G_OS_UNIX
filename = claws_get_socket_name();
+ dirname = g_path_get_dirname(filename);
claws_unlink(filename);
+ g_rmdir(dirname);
+ g_free(dirname);
#endif
return 0;
main_window_toggle_work_offline(mainwin, FALSE, FALSE);
} else if (!strncmp(buf, "offline", 7)) {
main_window_toggle_work_offline(mainwin, TRUE, FALSE);
+ } else if (!strncmp(buf, "debug", 5)) {
+ debug_set_mode(debug_get_mode() ? FALSE : TRUE);
} else if (!strncmp(buf, "status-full", 11) ||
!strncmp(buf, "status", 6)) {
gchar *status;
}
#endif /* linux && SIGIO */
-#ifdef MAEMO
-osso_context_t *get_osso_context(void)
-{
- return static_osso_context;
-}
-#endif
-
-
#ifdef HAVE_NETWORKMANAGER_SUPPORT
static void networkmanager_state_change_cb(DBusGProxy *proxy, gchar *dev,
gpointer data)