talons

Fork of Claws Mail https://www.claws-mail
Log | Files | Refs | README | LICENSE

commit 3a8a9a3168989c69ce55528f17cbfe435abe3195
parent 5ea10da69d1d34d422ed2876179d364ad3b2a674
Author: Oliver Lowe <o@olowe.co>
Date:   Wed, 13 Aug 2025 17:22:57 +1000

Drop windows support

it sucks, still does

Diffstat:
Mclaws-features.h.in | 1-
Mconfigure.ac | 82++++++++++++-------------------------------------------------------------------
Msrc/Makefile.am | 30------------------------------
Msrc/account.c | 5-----
Msrc/action.c | 9---------
Msrc/addressbook.c | 7+------
Msrc/addrindex.c | 4----
Msrc/addrindex.h | 5-----
Msrc/common/Makefile.am | 5-----
Msrc/common/codeconv.c | 25+++++++------------------
Msrc/common/defs.h | 13+++----------
Msrc/common/file-utils.c | 36++++++------------------------------
Msrc/common/prefs.c | 20+++++++-------------
Msrc/common/proxy.c | 12+++---------
Msrc/common/socket.c | 219++++++++-----------------------------------------------------------------------
Msrc/common/ssl.c | 10----------
Msrc/common/ssl_certificate.c | 72++++++++++++++++++++++++++++++++++--------------------------------------
Msrc/common/utils.c | 336++-----------------------------------------------------------------------------
Msrc/common/utils.h | 15+--------------
Dsrc/common/w32_reg.c | 129-------------------------------------------------------------------------------
Dsrc/common/w32_reg.h | 40----------------------------------------
Msrc/compose.c | 87+------------------------------------------------------------------------------
Msrc/etpan/etpan-thread-manager.c | 208+++++++++++++++++++++++++++++++++++++++----------------------------------------
Msrc/etpan/imap-thread.c | 709++++++++++++++++++++++++++++++++++++++-----------------------------------------
Msrc/etpan/imap-thread.h | 10++++------
Msrc/etpan/nntp-thread.c | 208+++++++++++++++++++++++++++++++++++++------------------------------------------
Msrc/filtering.c | 10+---------
Msrc/folder.c | 23-----------------------
Msrc/gtk/Makefile.am | 8+-------
Msrc/gtk/description_window.c | 4----
Msrc/gtk/gtkutils.c | 14+-------------
Dsrc/gtk/w32_filesel.c | 499-------------------------------------------------------------------------------
Msrc/imap.c | 43+------------------------------------------
Msrc/main.c | 212++-----------------------------------------------------------------------------
Msrc/mainwindow.c | 178++-----------------------------------------------------------------------------
Msrc/manual.c | 11-----------
Msrc/messageview.c | 14++------------
Msrc/mh.c | 47-----------------------------------------------
Msrc/mimeview.c | 57---------------------------------------------------------
Msrc/mimeview.h | 22++++++++++------------
Msrc/msgcache.c | 66+-----------------------------------------------------------------
Msrc/news.c | 4----
Msrc/password.c | 5-----
Msrc/pop.c | 7++-----
Msrc/prefs_account.c | 44--------------------------------------------
Msrc/prefs_account.h | 2--
Msrc/prefs_common.c | 125++++++++++++-------------------------------------------------------------------
Msrc/prefs_common.h | 4----
Msrc/prefs_ext_prog.c | 13-------------
Msrc/prefs_spelling.c | 9---------
Msrc/prefs_themes.c | 27+--------------------------
Msrc/procheader.c | 61-------------------------------------------------------------
Msrc/procmime.c | 23+----------------------
Msrc/recv.c | 2--
Msrc/send_message.c | 10+---------
Msrc/stock_pixmap.c | 8--------
Msrc/textview.c | 8--------
Dsrc/w32-logo.ico | 0
Dsrc/w32-resource.rc.in | 36------------------------------------
Msrc/wizard.c | 16+---------------
60 files changed, 693 insertions(+), 3216 deletions(-)

diff --git a/claws-features.h.in b/claws-features.h.in @@ -6,4 +6,3 @@ #undef USE_ENCHANT #undef USE_GNUTLS #undef USE_GPGME -#undef __CYGWIN__ diff --git a/configure.ac b/configure.ac @@ -97,11 +97,6 @@ dnl AC_PROG_RANLIB AC_PROG_LEX(noyywrap) AC_PROG_YACC AC_LIB_PREFIX -AU_DEFUN([AC_LIBTOOL_WIN32_DLL], -[AC_REQUIRE(AC_CANONICAL_HOST)_LT_SET_OPTION([LT_INIT],[win32-dll]) -m4_warn([obsolete],[AC_LIBTOOL_WIN32_DLL: Remove this warning and the call to _LT_SET_OPTION when you -put the 'win32-dll' option into LT_INIT's first parameter.]) -]) LT_INIT LT_PROG_RC @@ -124,47 +119,15 @@ AC_SYS_LARGEFILE dnl Copied from the official gtk+-2 configure.in AC_MSG_CHECKING([for host platform]) case "$host" in - *-*-mingw*|*-*-cygwin*) - platform_win32=yes - LDFLAGS="$LDFLAGS -mwindows -Wl,--export-all-symbols" - ;; *-apple-*) platform_osx=yes LDFLAGS="$LDFLAGS -Wl,-export_dynamic" ;; - *) - platform_win32=no + *) platform_osx=no LDFLAGS="$LDFLAGS -Wl,--export-dynamic" - ;; -esac -AM_CONDITIONAL(PLATFORM_WIN32, test x"$platform_win32" = x"yes") -AM_CONDITIONAL(PLATFORM_OSX, test x"$platform_osx" = x"yes") -AC_MSG_RESULT([$host]) - -AC_MSG_CHECKING([for native Win32]) -case "$host" in - *-*-mingw*) - os_win32=yes - ;; - *) - os_win32=no - ;; -esac -AC_MSG_RESULT([$os_win32]) -AM_CONDITIONAL(OS_WIN32, test x"$os_win32" = x"yes") - -AC_MSG_CHECKING([for Cygwin]) -case "$host" in - *-*-cygwin*) - env_cygwin=yes - ;; - *) - env_cygwin=no - ;; + ;; esac -AC_MSG_RESULT([$env_cygwin]) -AM_CONDITIONAL(CYGWIN, test x"$env_cygwin" = x"yes") AC_MSG_CHECKING([for time_t format specifier]) _gcc_cflags_save=$CFLAGS @@ -196,10 +159,6 @@ case "$target" in *-darwin*) AM_CFLAGS="$AM_CFLAGS -fno-common" ;; -*-*-mingw*) - AM_CFLAGS="$AM_CFLAGS -mms-bitfields" - LIBS="$LIBS -lws2_32 -lregex" - ;; *-*-solaris*) AM_CFLAGS="$AM_CFLAGS -std=gnu99" AC_DEFINE([SOLARIS], [], [Target is Solaris]) @@ -389,13 +348,8 @@ dnl RC dir (will be default at a certain point in time) AC_ARG_WITH(config-dir, [ --with-config-dir=RCDIR Local configuration dir (default: .claws-mail)], ac_cv_with_config_dir="$withval", ac_cv_with_config_dir="") -dnl Set correct default value based on platform if test x"$ac_cv_with_config_dir" = x""; then - if test x"$platform_win32" = xyes; then - ac_cv_with_config_dir="Claws-mail" - else - ac_cv_with_config_dir=".claws-mail" - fi + ac_cv_with_config_dir=".claws-mail" fi AC_DEFINE_UNQUOTED(CFG_RC_DIR, "$ac_cv_with_config_dir", Configuration directory) @@ -419,11 +373,6 @@ else enable_oauth2=no fi -dnl ************************ -dnl ** GTK user interface ** -dnl ************************ - -dnl Checks for GTK PKG_CHECK_MODULES(GTK, gtk+-3.0 >= 3.20 cairo) AC_ARG_ENABLE(deprecated, @@ -463,34 +412,28 @@ fi dnl dnl Check whether we need to pass -lresolv -dnl We know that we don't need it for W32. dnl -if test x$os_win32 = xno; then - t_oldLibs="$LIBS" - LIBS="$LIBS" - ac_cv_var__res_options=no - AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include <sys/types.h> - #include <sys/socket.h> +t_oldLibs="$LIBS" +LIBS="$LIBS" +ac_cv_var__res_options=no +AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include <sys/types.h> + #include <sys/socket.h> #include <netinet/in.h> #include <arpa/nameser.h> #include <resolv.h>]], [[_res.options = RES_INIT;]])],[ac_cv_var__res_options=yes],[]); - if test "$ac_cv_var__res_options" != "yes"; then +if test "$ac_cv_var__res_options" != "yes"; then LIBRESOLV="-lresolv" - fi - LIBS="$t_oldLibs" +fi +LIBS="$t_oldLibs" - if test "x$LIBRESOLV" = "x"; then +if test "x$LIBRESOLV" = "x"; then AC_CHECK_LIB(resolv, res_query, [LIBRESOLV=-lresolv]) LIBS="$t_oldLibs" - fi fi AC_SUBST(LIBRESOLV) LIBS="$LIBS $LIBRESOLV" -dnl ####################################################################### -dnl # Check for startup notification -dnl ####################################################################### if test "x$enable_startup_notification" = "xyes"; then PKG_CHECK_MODULES(STARTUP_NOTIFICATION, pkg_info libstartup-notification-1.0 >= 0.5, [ @@ -715,7 +658,6 @@ Makefile po/Makefile.in src/common/version.h src/Makefile -src/w32-resource.rc src/common/Makefile src/common/passcrypt.h src/common/tests/Makefile diff --git a/src/Makefile.am b/src/Makefile.am @@ -19,18 +19,6 @@ endif bin_PROGRAMS = claws-mail -if PLATFORM_WIN32 -%.o : %.rc - $(LIBTOOL) --mode=compile --tag=RC $(RC) -I$(srcdir) -i $< -o $@ - -claws_mail_platform_ldflags = -Wl,w32-resource.o \ - -Wl,--export-all-symbols,--out-implib=libclaws.a -claws_mail_deps = w32-resource.o -else -claws_mail_platform_ldflags = -claws_mail_deps = -endif - abook_source = \ addrbook.c \ addrclip.c \ @@ -312,7 +300,6 @@ CLEANFILES = \ $(BUILT_SOURCES) EXTRA_DIST = \ - w32-logo.ico \ pixmaps/addr_one.xpm \ pixmaps/addr_two.xpm \ pixmaps/address_book.xpm \ @@ -568,20 +555,3 @@ matcher_parser_lex.$(OBJEXT) : AM_CFLAGS += -Wno-unused-function quote_fmt_lex.$(OBJEXT) : AM_CFLAGS += -Wno-unused-function AM_YFLAGS = -d - -if CYGWIN -claws-mail$(EXEEXT): $(claws_mail_OBJECTS) $(claws_mail_DEPENDENCIES) - @rm -f claws-mail$(EXEEXT) - @rm -f claws-mail.def claws-mail.base claws-mail.exp libclaws-mail.a .libs/libclaws-mail.a - $(LINK) -shared $(claws_mailLDFLAGS) -Wl,--out-implib=libclaws-mail.a -Wl,--export-all-symbols,--exclude-symbols,main $(claws_mail_OBJECTS) -Wl,--no-whole-archive $(claws_mail_LDADD) $(LIBS) - dlltool --output-def claws-mail.def --dllname claws-mail$(EXEEXT) --export-all-symbols --exclude-symbols main $(claws_mail_OBJECTS) gtk/.libs/libclawsgtk.a - $(LINK) $(claws_mail_LDFLAGS) -Wl,--base-file,claws-mail.base $(claws_mail_OBJECTS) $(claws_mail_LDADD) $(LIBS) - sleep 5 - dlltool --base-file claws-mail.base --input-def claws-mail.def --output-exp claws-mail.exp - $(LINK) $(claws_mail_LDFLAGS) -Wl,claws-mail.exp $(claws_mail_OBJECTS) $(claws_mail_LDADD) $(LIBS) - @cp libclaws-mail.a .libs/libclaws-mail.a -else -#claws-mail$(EXEEXT): $(claws_mail_OBJECTS) $(claws_mail_DEPENDENCIES) -# @rm -f claws-mail$(EXEEXT) -# $(LINK) $(claws_mail_LDFLAGS) $(claws_mail_OBJECTS) $(claws_mail_LDADD) $(LIBS) -endif diff --git a/src/account.c b/src/account.c @@ -867,9 +867,6 @@ static void account_edit_create(void) GDK_HINT_MIN_SIZE); gtk_window_set_default_size(GTK_WINDOW(window), prefs_common.accountswin_width, prefs_common.accountswin_height); -#ifdef G_OS_WIN32 - gtk_window_move(GTK_WINDOW(window), 48, 48); -#endif edit_account.window = window; edit_account.list_view = list_view; @@ -1062,10 +1059,8 @@ static void account_clone(GtkWidget *widget, gpointer data) ACP_FASSIGN(mark_crosspost_read); ACP_FASSIGN(crosspost_col); -#ifndef G_OS_WIN32 ACP_FASSIGN(set_tunnelcmd); ACP_FDUP(tunnelcmd); -#endif ACP_FDUP(imap_dir); ACP_FASSIGN(imap_subsonly); diff --git a/src/action.c b/src/action.c @@ -60,10 +60,6 @@ #include "filtering.h" #include "procheader.h" -#ifdef G_OS_WIN32 -#include <windows.h> -#endif - typedef struct _Children Children; typedef struct _ChildInfo ChildInfo; typedef struct _UserStringDialog UserStringDialog; @@ -1072,15 +1068,10 @@ static void kill_children_cb(GtkWidget *widget, gpointer data) for (cur = children->list; cur; cur = cur->next) { child_info = (ChildInfo *)(cur->data); -#ifdef G_OS_WIN32 - debug_print("Killing child group HANDLE %p\n", child_info->pid); - TerminateProcess(child_info->pid, 0); -#else debug_print("Killing child group id %d\n", child_info->pid); if (child_info->pid && kill(child_info->pid, child_info->next_sig) < 0) perror("kill"); child_info->next_sig = SIGKILL; -#endif } } diff --git a/src/addressbook.c b/src/addressbook.c @@ -74,9 +74,7 @@ #include "adbookbase.h" #include "exphtmldlg.h" #include "addrcustomattr.h" -#ifdef G_OS_WIN32 -#undef interface -#endif + typedef enum { COL_SOURCES = 0, @@ -1219,9 +1217,6 @@ static void addressbook_create(void) GDK_HINT_MIN_SIZE); gtk_window_set_default_size(GTK_WINDOW(window), prefs_common.addressbookwin_width, prefs_common.addressbookwin_height); -#ifdef G_OS_WIN32 - gtk_window_move(GTK_WINDOW(window), 48, 48); -#endif if (!prefs_common.addressbook_use_editaddress_dialog) { if (prefs_common.addressbook_vpaned_pos > 0) diff --git a/src/addrindex.c b/src/addrindex.c @@ -51,10 +51,6 @@ #include "vcard.h" -#ifdef G_OS_WIN32 -#undef interface -#endif - #define TAG_ADDRESS_INDEX "addressbook" #define TAG_IF_ADDRESS_BOOK "book_list" diff --git a/src/addrindex.h b/src/addrindex.h @@ -89,11 +89,6 @@ struct _AddressInterface { void (*stopSearch)( void * ); }; -#ifdef G_OS_WIN32 -/* W32 headers define INTERFACE to "struct". */ -#undef interface -#endif - typedef struct _AddressDataSource AddressDataSource; struct _AddressDataSource { AddrItemObject obj; diff --git a/src/common/Makefile.am b/src/common/Makefile.am @@ -12,13 +12,8 @@ DESKTOPFILEPATH=$(datadir)/applications/claws-mail.desktop noinst_LTLIBRARIES = libclawscommon.la -if OS_WIN32 -arch_sources = w32_reg.c -arch_headers = w32_reg.h -else arch_files = arch_header = -endif libclawscommon_la_SOURCES = $(arch_sources) \ codeconv.c \ diff --git a/src/common/codeconv.c b/src/common/codeconv.c @@ -14,7 +14,7 @@ * * You should have received a copy of the GNU General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. - * + * */ #ifdef HAVE_CONFIG_H @@ -550,7 +550,7 @@ static gint conv_anytoutf8(gchar *outbuf, gint outlen, const gchar *inbuf) strncpy2(outbuf, inbuf, outlen); break; } - + return r; } @@ -605,7 +605,7 @@ static gint conv_utf8tojis(gchar *outbuf, gint outlen, const gchar *inbuf) return -1; if (conv_euctojis(outbuf, outlen, eucstr) < 0) return -1; - + return 0; } @@ -720,7 +720,7 @@ static gint conv_ustodisp(gchar *outbuf, gint outlen, const gchar *inbuf) strncpy2(outbuf, inbuf, outlen); conv_unreadable_8bit(outbuf); - + return 0; } @@ -742,7 +742,7 @@ void conv_localetodisp(gchar *outbuf, gint outlen, const gchar *inbuf) } else if (tmpstr && !g_utf8_validate(tmpstr, -1, NULL)) { g_free(tmpstr); codeconv_set_strict(TRUE); - tmpstr = conv_iconv_strdup(inbuf, + tmpstr = conv_iconv_strdup(inbuf, conv_get_locale_charset_str_no_utf8(), CS_INTERNAL); codeconv_set_strict(FALSE); @@ -971,7 +971,7 @@ static gchar *conv_iconv_strdup(const gchar *inbuf, cm_return_val_if_fail(inbuf != NULL, NULL); - if (!src_code && !dest_code && + if (!src_code && !dest_code && g_utf8_validate(inbuf, -1, NULL)) return g_strdup(inbuf); @@ -1161,11 +1161,7 @@ static const struct { {"ja_JP.ujis" , C_EUC_JP , C_ISO_2022_JP}, {"ja_JP.SJIS" , C_SHIFT_JIS , C_ISO_2022_JP}, {"ja_JP.JIS" , C_ISO_2022_JP , C_ISO_2022_JP}, -#ifdef G_OS_WIN32 - {"ja_JP" , C_SHIFT_JIS , C_ISO_2022_JP}, -#else {"ja_JP" , C_EUC_JP , C_ISO_2022_JP}, -#endif {"ko_KR.EUC-KR" , C_EUC_KR , C_EUC_KR}, {"ko_KR" , C_EUC_KR , C_EUC_KR}, {"zh_CN.GB18030" , C_GB18030 , C_GB18030}, @@ -1181,11 +1177,8 @@ static const struct { {"ru_RU.KOI8-R" , C_KOI8_R , C_KOI8_R}, {"ru_RU.KOI8R" , C_KOI8_R , C_KOI8_R}, {"ru_RU.CP1251" , C_WINDOWS_1251, C_KOI8_R}, -#ifdef G_OS_WIN32 - {"ru_RU" , C_WINDOWS_1251, C_KOI8_R}, -#else {"ru_RU" , C_ISO_8859_5 , C_KOI8_R}, -#endif + {"tg_TJ" , C_KOI8_T , C_KOI8_T}, {"ru_UA" , C_KOI8_U , C_KOI8_U}, {"uk_UA.CP1251" , C_WINDOWS_1251, C_KOI8_U}, @@ -1582,14 +1575,10 @@ const gchar *conv_get_current_locale(void) { const gchar *cur_locale; -#ifdef G_OS_WIN32 - cur_locale = g_win32_getlocale(); -#else cur_locale = g_getenv("LC_ALL"); if (!cur_locale) cur_locale = g_getenv("LC_CTYPE"); if (!cur_locale) cur_locale = g_getenv("LANG"); if (!cur_locale) cur_locale = setlocale(LC_CTYPE, NULL); -#endif /* G_OS_WIN32 */ debug_print("current locale: %s\n", cur_locale ? cur_locale : "(none)"); diff --git a/src/common/defs.h b/src/common/defs.h @@ -102,16 +102,9 @@ #define MARK_VERSION 2 #define TAGS_VERSION 1 -#ifdef G_OS_WIN32 -# define ACTIONS_RC "actionswinrc" -# define COMMAND_HISTORY "command_history_win" -# define DEFAULT_SIGNATURE "signature.txt" -# define DEFAULT_W32_GTK_THEME "MS-Windows" -#else -# define ACTIONS_RC "actionsrc" -# define COMMAND_HISTORY "command_history" -# define DEFAULT_SIGNATURE ".signature" -#endif +#define ACTIONS_RC "actionsrc" +#define COMMAND_HISTORY "command_history" +#define DEFAULT_SIGNATURE ".signature" #define DEFAULT_INC_PATH "/usr/bin/mh/inc" #define DEFAULT_INC_PROGRAM "inc" diff --git a/src/common/file-utils.c b/src/common/file-utils.c @@ -23,11 +23,7 @@ #include <glib.h> -#ifndef G_OS_WIN32 #include <sys/wait.h> -#else -#define WEXITSTATUS(x) (x) -#endif #include <errno.h> #include <stdio.h> @@ -83,10 +79,10 @@ gint file_strip_crs(const gchar *file) if (safe_fclose(outfp) == EOF) { goto unlinkout; } - + if (move_file(out, file, TRUE) < 0) goto unlinkout; - + g_free(out); return 0; unlinkout: @@ -519,12 +515,10 @@ static gchar *file_read_to_str_full(const gchar *file, gboolean recode) FILE *fp; gchar *str; GStatBuf s; -#ifndef G_OS_WIN32 gint fd, err; struct timeval timeout = {1, 0}; fd_set fds; int fflags = 0; -#endif cm_return_val_if_fail(file != NULL, NULL); @@ -537,13 +531,6 @@ static gchar *file_read_to_str_full(const gchar *file, gboolean recode) return NULL; } -#ifdef G_OS_WIN32 - fp = g_fopen (file, "rb"); - if (fp == NULL) { - FILE_OP_ERROR(file, "open"); - return NULL; - } -#else /* test whether the file is readable without blocking */ fd = g_open(file, O_RDONLY | O_NONBLOCK, 0); if (fd == -1) { @@ -565,7 +552,7 @@ static gchar *file_read_to_str_full(const gchar *file, gboolean recode) close(fd); return NULL; } - + /* Now clear O_NONBLOCK */ if ((fflags = fcntl(fd, F_GETFL)) < 0) { FILE_OP_ERROR(file, "fcntl (F_GETFL)"); @@ -577,7 +564,7 @@ static gchar *file_read_to_str_full(const gchar *file, gboolean recode) close(fd); return NULL; } - + /* get the FILE pointer */ fp = fdopen(fd, "rb"); @@ -586,7 +573,6 @@ static gchar *file_read_to_str_full(const gchar *file, gboolean recode) close(fd); /* if fp isn't NULL, we'll use fclose instead! */ return NULL; } -#endif str = file_read_stream_to_str_full(fp, recode); @@ -652,10 +638,6 @@ gint copy_dir(const gchar *src, const gchar *dst) if (g_file_test(old_file, G_FILE_TEST_IS_REGULAR)) { r = copy_file(old_file, new_file, TRUE); } -#ifndef G_OS_WIN32 - /* Windows has no symlinks. Or well, Vista seems to - have something like this but the semantics might be - different. Thus we don't use it under Windows. */ else if (g_file_test(old_file, G_FILE_TEST_IS_SYMLINK)) { GError *error = NULL; gchar *target = g_file_read_link(old_file, &error); @@ -668,7 +650,6 @@ gint copy_dir(const gchar *src, const gchar *dst) g_free(target); } } -#endif /*G_OS_WIN32*/ else if (g_file_test(old_file, G_FILE_TEST_IS_DIR)) { r = copy_dir(old_file, new_file); } @@ -702,9 +683,7 @@ FILE *my_tmpfile(void) gchar *fname; gint fd; FILE *fp; -#ifndef G_OS_WIN32 gchar buf[2]="\0"; -#endif tmpdir = get_tmp_dir(); tmplen = strlen(tmpdir); @@ -724,16 +703,13 @@ FILE *my_tmpfile(void) if (fd < 0) return tmpfile(); -#ifndef G_OS_WIN32 unlink(fname); - + /* verify that we can write in the file after unlinking */ if (write(fd, buf, 1) < 0) { close(fd); return tmpfile(); } - -#endif fp = fdopen(fd, "w+b"); if (!fp) @@ -782,7 +758,7 @@ FILE *str_open_as_stream(const gchar *str) return fp; } -gint prefs_chmod_mode(gchar *chmod_pref) +gint prefs_chmod_mode(gchar *chmod_pref) { gint newmode = 0; gchar *tmp; diff --git a/src/common/prefs.c b/src/common/prefs.c @@ -14,7 +14,7 @@ * * You should have received a copy of the GNU General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. - * + * */ #ifdef HAVE_CONFIG_H @@ -143,18 +143,18 @@ gint prefs_file_close(PrefFile *pfile) if (fputs(buf, fp) == EOF) { g_warning("failed to write configuration to file"); prefs_file_close_revert(pfile); - + return -1; } break; } } - + while (fgets(buf, sizeof(buf), orig_fp) != NULL) if (fputs(buf, fp) == EOF) { g_warning("failed to write configuration to file"); - prefs_file_close_revert(pfile); - + prefs_file_close_revert(pfile); + return -1; } fclose(orig_fp); @@ -172,9 +172,6 @@ gint prefs_file_close(PrefFile *pfile) if (is_file_exist(path)) { bakpath = g_strconcat(path, ".bak", NULL); -#ifdef G_OS_WIN32 - unlink(bakpath); -#endif if (g_rename(path, bakpath) < 0) { FILE_OP_ERROR(path, "rename"); unlink(tmppath); @@ -185,9 +182,6 @@ gint prefs_file_close(PrefFile *pfile) } } -#ifdef G_OS_WIN32 - unlink(path); -#endif if (g_rename(tmppath, path) < 0) { FILE_OP_ERROR(tmppath, "rename"); unlink(tmppath); @@ -276,7 +270,7 @@ gint prefs_set_block_label(PrefFile *pfile, const gchar *label) if (!pfile->writing) { while (fgets(buf, sizeof(buf), pfile->fp) != NULL) { gint val; - + val = strncmp(buf, block_label, strlen(block_label)); if (val == 0) { debug_print("Found %s\n", block_label); @@ -300,7 +294,7 @@ gint prefs_set_block_label(PrefFile *pfile, const gchar *label) g_warning("failed to write configuration to file"); prefs_file_close_revert(pfile); g_free(block_label); - + return -1; } } diff --git a/src/common/proxy.c b/src/common/proxy.c @@ -22,15 +22,9 @@ #include <glib.h> -#ifdef G_OS_WIN32 -# include <winsock2.h> -# include <ws2tcpip.h> -# include <stdint.h> -#else -# include <sys/socket.h> -# include <netinet/in.h> -# include <netinet/ip.h> -#endif +#include <sys/socket.h> +#include <netinet/in.h> +#include <netinet/ip.h> #include "proxy.h" #include "socket.h" diff --git a/src/common/socket.c b/src/common/socket.c @@ -26,26 +26,17 @@ #include <sys/time.h> #include <sys/types.h> -#ifdef G_OS_WIN32 -# include <ws2tcpip.h> -# ifndef EINPROGRESS -# define EINPROGRESS WSAEINPROGRESS -# endif -#else -# if HAVE_SYS_WAIT_H -# include <sys/wait.h> -# endif -# include <sys/socket.h> -# include <sys/stat.h> -# include <sys/un.h> -# include <netinet/in.h> -# include <arpa/inet.h> -# include <resolv.h> -# ifndef _PATH_RESCONF -# define _PATH_RESCONF "/etc/resolv.conf" -# endif -# include <netdb.h> -#endif /* G_OS_WIN32 */ +#include <sys/wait.h> +#include <sys/socket.h> +#include <sys/stat.h> +#include <sys/un.h> +#include <netinet/in.h> +#include <arpa/inet.h> +#include <resolv.h> +#ifndef _PATH_RESCONF +# define _PATH_RESCONF "/etc/resolv.conf" +#endif +#include <netdb.h> #include <unistd.h> #include <stdio.h> #include <string.h> @@ -69,12 +60,7 @@ #error USE_GIO is currently not supported #endif -#if G_IO_WIN32 -#define BUFFSIZE 8191 -#else #define BUFFSIZE 8192 -#endif - typedef gint (*SockAddrFunc) (GList *addr_list, gpointer data); @@ -179,24 +165,11 @@ static gint sock_get_address_info_async_cancel (SockLookupData *lookup_data); gint sock_init(void) { -#ifdef G_OS_WIN32 - WSADATA wsadata; - gint result; - - result = WSAStartup(MAKEWORD(2, 2), &wsadata); - if (result != NO_ERROR) { - g_warning("WSAStartup() failed"); - return -1; - } -#endif - return 0; +return 0; } gint sock_cleanup(void) { -#ifdef G_OS_WIN32 - WSACleanup(); -#endif return 0; } @@ -227,25 +200,7 @@ void refresh_resolvers(void) #endif /*G_OS_UNIX*/ } -#ifdef G_OS_WIN32 -#define SOCKET_IS_VALID(s) ((s) != INVALID_SOCKET) -#else #define SOCKET_IS_VALID(s) (s != -1) -#endif - -#ifdef G_OS_WIN32 -/* Due to the fact that socket under Windows are not represented by - standard file descriptors, we sometimes need to check whether a - given file descriptor is actually a socket. This is done by - testing for an error. Returns true under W32 if FD is a socket. */ -static int fd_is_w32_socket(gint fd) -{ - gint optval; - gint retval = sizeof(optval); - - return !getsockopt(fd, SOL_SOCKET, SO_TYPE, (char*)&optval, &retval); -} -#endif gint fd_connect_inet(gushort port) { @@ -254,12 +209,7 @@ gint fd_connect_inet(gushort port) sock = socket(AF_INET, SOCK_STREAM, 0); if (!SOCKET_IS_VALID(sock)) { -#ifdef G_OS_WIN32 - debug_print("fd_connect_inet(): socket() failed: %d\n", - WSAGetLastError()); -#else perror("fd_connect_inet(): socket"); -#endif return -1; } @@ -269,12 +219,13 @@ gint fd_connect_inet(gushort port) addr.sin_addr.s_addr = htonl(INADDR_LOOPBACK); if (connect(sock, (struct sockaddr *)&addr, sizeof(addr)) < 0) { - fd_close(sock); + close(sock); return -1; } return sock; } + gint fd_open_inet(gushort port) { gint sock; @@ -283,12 +234,7 @@ gint fd_open_inet(gushort port) sock = socket(AF_INET, SOCK_STREAM, 0); if (!SOCKET_IS_VALID(sock)) { -#ifdef G_OS_WIN32 - g_warning("fd_open_inet(): socket() failed: %d", - WSAGetLastError()); -#else perror("fd_open_inet(): socket"); -#endif return -1; } @@ -296,7 +242,7 @@ gint fd_open_inet(gushort port) if (setsockopt(sock, SOL_SOCKET, SO_REUSEADDR, (char *)&val, sizeof(val)) < 0) { perror("setsockopt"); - fd_close(sock); + close(sock); return -1; } @@ -307,13 +253,13 @@ gint fd_open_inet(gushort port) if (bind(sock, (struct sockaddr *)&addr, sizeof(addr)) < 0) { perror("bind"); - fd_close(sock); + close(sock); return -1; } if (listen(sock, 1) < 0) { perror("listen"); - fd_close(sock); + close(sock); return -1; } @@ -638,11 +584,6 @@ static gint sock_connect_by_getaddrinfo(const gchar *hostname, gushort port) sock = socket(ai->ai_family, ai->ai_socktype, ai->ai_protocol); if (sock < 0 ) continue; -#ifdef G_OS_WIN32 - if (sock == INVALID_SOCKET) - continue; -#endif - if (sock_connect_with_timeout (sock, ai->ai_addr, ai->ai_addrlen, io_timeout) == 0) break; @@ -661,11 +602,7 @@ static gint sock_connect_by_getaddrinfo(const gchar *hostname, gushort port) SockInfo *sock_connect(const gchar *hostname, gushort port) { -#ifdef G_OS_WIN32 - SOCKET sock; -#else gint sock; -#endif if ((sock = sock_connect_by_getaddrinfo(hostname, port)) < 0) { return NULL; @@ -727,11 +664,7 @@ static gboolean sock_connect_async_cb(GIOChannel *source, sockinfo = g_new0(SockInfo, 1); sockinfo->sock = fd; -#ifndef G_OS_WIN32 sockinfo->sock_ch = g_io_channel_unix_new(fd); -#else - sockinfo->sock_ch = g_io_channel_win32_new_socket(fd); -#endif sockinfo->hostname = g_strdup(conn_data->hostname); sockinfo->port = conn_data->port; sockinfo->state = CONN_ESTABLISHED; @@ -870,12 +803,7 @@ static gint sock_connect_address_list_async(SockConnectData *conn_data) } conn_data->cur_addr = conn_data->cur_addr->next; - -#ifndef G_OS_WIN32 conn_data->channel = g_io_channel_unix_new(sock); -#else - conn_data->channel = g_io_channel_win32_new_socket(sock); -#endif conn_data->io_tag = g_io_add_watch(conn_data->channel, G_IO_IN|G_IO_OUT, sock_connect_async_cb, conn_data); @@ -998,12 +926,9 @@ static gboolean sock_get_address_info_async_cb(GIOChannel *source, g_error_free(err); g_io_channel_unref(source); -#ifdef G_OS_WIN32 - /* FIXME: We would need to cancel the thread. */ -#else kill(lookup_data->child_pid, SIGKILL); waitpid(lookup_data->child_pid, NULL, 0); -#endif + lookup_data->canonical_name = canonical_name; lookup_data->func(addr_list, lookup_data->data); @@ -1028,10 +953,8 @@ static void address_info_async_child(void *opaque) gchar port_str[6]; gint ai_member[4] = {AF_UNSPEC, 0, 0, 0}; -#ifndef G_OS_WIN32 close(parm->pipe_fds[0]); parm->pipe_fds[0] = -1; -#endif memset(&hints, 0, sizeof(hints)); hints.ai_flags = AI_CANONNAME | AI_ADDRCONFIG; @@ -1054,11 +977,8 @@ static void address_info_async_child(void *opaque) sizeof(ai_member)); close(parm->pipe_fds[1]); parm->pipe_fds[1] = -1; -#ifdef G_OS_WIN32 - _endthread(); -#else + _exit(1); -#endif } if (res != NULL) { @@ -1097,11 +1017,7 @@ static void address_info_async_child(void *opaque) close(parm->pipe_fds[1]); parm->pipe_fds[1] = -1; -#ifdef G_OS_WIN32 - _endthread(); -#else _exit(0); -#endif } static SockLookupData *sock_get_address_info_async(const gchar *hostname, @@ -1130,7 +1046,6 @@ static SockLookupData *sock_get_address_info_async(const gchar *hostname, return NULL; } -#ifndef G_OS_WIN32 if ((lookup_data->child_pid = fork()) < 0) { perror("fork"); func(NULL, data); @@ -1147,21 +1062,11 @@ static SockLookupData *sock_get_address_info_async(const gchar *hostname, /* Parent process. */ close(lookup_data->pipe_fds[1]); lookup_data->pipe_fds[1] = -1; -#endif /*!G_OS_WIN32 */ -#ifndef G_OS_WIN32 lookup_data->channel = g_io_channel_unix_new(lookup_data->pipe_fds[0]); -#else - lookup_data->channel = g_io_channel_win32_new_fd(lookup_data->pipe_fds[0]); -#endif lookup_data->io_tag = g_io_add_watch(lookup_data->channel, G_IO_IN, sock_get_address_info_async_cb, lookup_data); -#ifdef G_OS_WIN32 - lookup_data->child_pid = _beginthread( - address_info_async_child, 0, lookup_data); -#endif - return lookup_data; } @@ -1179,12 +1084,8 @@ static gint sock_get_address_info_async_cancel(SockLookupData *lookup_data) } if (lookup_data->child_pid > 0) { -#ifdef G_OS_WIN32 - /* FIXME: Need a way to cancel the thread. */ -#else kill(lookup_data->child_pid, SIGKILL); waitpid(lookup_data->child_pid, NULL, 0); -#endif } g_free(lookup_data->canonical_name); @@ -1203,11 +1104,7 @@ static SockInfo *sockinfo_from_fd(const gchar *hostname, sockinfo = g_new0(SockInfo, 1); sockinfo->sock = sock; -#ifndef G_OS_WIN32 sockinfo->sock_ch = g_io_channel_unix_new(sock); -#else - sockinfo->sock_ch = g_io_channel_win32_new_socket(sock); -#endif sockinfo->hostname = g_strdup(hostname); sockinfo->port = port; sockinfo->state = CONN_ESTABLISHED; @@ -1219,12 +1116,6 @@ static gint fd_read(gint fd, gchar *buf, gint len) { if (fd_check_io(fd, G_IO_IN) < 0) return -1; - -#ifdef G_OS_WIN32 - if (fd_is_w32_socket(fd)) - return recv(fd, buf, len, 0); -#endif - return read(fd, buf, len); } @@ -1293,12 +1184,6 @@ gint fd_write(gint fd, const gchar *buf, gint len) { if (fd_check_io(fd, G_IO_OUT) < 0) return -1; - -#ifdef G_OS_WIN32 - if (fd_is_w32_socket (fd)) - return send(fd, buf, len, 0); -#endif - return write(fd, buf, len); } @@ -1351,16 +1236,8 @@ gint fd_write_all(gint fd, const gchar *buf, gint len) while (len) { if (fd_check_io(fd, G_IO_OUT) < 0) return -1; -#ifndef G_OS_WIN32 signal(SIGPIPE, SIG_IGN); -#endif - -#ifdef G_OS_WIN32 - if (fd_is_w32_socket(fd)) - n = send(fd, buf, len, 0); - else -#endif - n = write(fd, buf, len); + n = write(fd, buf, len); if (n <= 0) { log_error(LOG_PROTOCOL, _("write on fd%d: %s\n"), fd, g_strerror(errno)); @@ -1410,7 +1287,6 @@ gint sock_write_all(SockInfo *sock, const gchar *buf, gint len) return ret; } -#ifndef G_OS_WIN32 static gint fd_recv(gint fd, gchar *buf, gint len, gint flags) { if (fd_check_io(fd, G_IO_IN) < 0) @@ -1418,7 +1294,6 @@ static gint fd_recv(gint fd, gchar *buf, gint len, gint flags) return recv(fd, buf, len, flags); } -#endif gint fd_gets(gint fd, gchar *buf, gint len) { @@ -1426,45 +1301,6 @@ gint fd_gets(gint fd, gchar *buf, gint len) if (--len < 1) return -1; - -#ifdef G_OS_WIN32 - fd_check_io(fd, G_IO_IN); - do { -/* -XXX:tm try nonblock -MSKB Article ID: Q147714 -Windows Sockets 2 Service Provider Interface Limitations -Polling with recv(MSG_PEEK) to determine when a complete message -has arrived. - Reason and Workaround not available. - -Single-byte send() and recv(). - Reason: Couple one-byte sends with Nagle disabled. - Workaround: Send modest amounts and receive as much as possible. -(still unused) -*/ - if (recv(fd, bp, 1, 0) <= 0) - return -1; - if (*bp == '\n') - break; - bp++; - len--; - } while (0 < len); -#else /*!G_OS_WIN32*/ - gchar *newline; - gint n; - do { - if ((n = fd_recv(fd, bp, len, MSG_PEEK)) <= 0) - return -1; - if ((newline = memchr(bp, '\n', n)) != NULL) - n = newline - bp + 1; - if ((n = fd_read(fd, bp, n)) < 0) - return -1; - bp += n; - len -= n; - } while (!newline && len); -#endif /*!G_OS_WIN32*/ - *bp = '\0'; return bp - buf; } @@ -1486,14 +1322,8 @@ gint sock_close(SockInfo *sock, gboolean close_fd) g_source_remove(sock->g_source); sock->g_source = 0; #endif - if (close_fd) { -#ifdef G_OS_WIN32 - shutdown(sock->sock, 1); /* complete transfer before close */ - ret = closesocket(sock->sock); -#else - ret = fd_close(sock->sock); -#endif - } + if (close_fd) + ret = close(sock->sock); g_free(sock->canonical_name); g_free(sock->hostname); @@ -1501,8 +1331,3 @@ gint sock_close(SockInfo *sock, gboolean close_fd) return ret; } - -gint fd_close(gint fd) -{ - return close(fd); -} diff --git a/src/common/ssl.c b/src/common/ssl.c @@ -189,7 +189,6 @@ static int gnutls_cert_cb(gnutls_session_t session, const gchar *claws_ssl_get_cert_file(void) { -#ifndef G_OS_WIN32 const char *cert_files[]={ "/etc/ssl/cert.pem", "/etc/pki/tls/certs/ca-bundle.crt", @@ -204,28 +203,22 @@ const gchar *claws_ssl_get_cert_file(void) "/usr/lib/ssl/cert.pem", NULL}; int i; -#endif /* We honor this environment variable on all platforms. */ if (g_getenv("SSL_CERT_FILE")) return g_getenv("SSL_CERT_FILE"); -#ifndef G_OS_WIN32 for (i = 0; cert_files[i]; i++) { if (is_file_exist(cert_files[i])) return cert_files[i]; } return NULL; -#else - return w32_get_cert_file(); -#endif } const gchar *claws_ssl_get_cert_dir(void) { if (g_getenv("SSL_CERT_DIR")) return g_getenv("SSL_CERT_DIR"); -#ifndef G_OS_WIN32 const char *cert_dirs[]={ "/etc/pki/tls/certs", "/etc/certs", @@ -243,9 +236,6 @@ const gchar *claws_ssl_get_cert_dir(void) return cert_dirs[i]; } return NULL; -#else - return NULL; -#endif } void ssl_init(void) diff --git a/src/common/ssl_certificate.c b/src/common/ssl_certificate.c @@ -33,13 +33,9 @@ #include <glib.h> #include <glib/gi18n.h> #include <errno.h> -#ifdef G_OS_WIN32 -# include <winsock2.h> -#else -# include <sys/socket.h> -# include <netinet/in.h> -# include <netdb.h> -#endif /* G_OS_WIN32 */ +#include <sys/socket.h> +#include <netinet/in.h> +#include <netdb.h> #include "ssl_certificate.h" #include "utils.h" #include "log.h" @@ -82,11 +78,11 @@ static gchar *get_certificate_chain_path(const gchar *host, const gchar *port, c return result; } -char * readable_fingerprint(unsigned char *src, int len) +char * readable_fingerprint(unsigned char *src, int len) { int i=0; char * ret; - + if (src == NULL) return NULL; ret = g_strdup(""); @@ -112,13 +108,13 @@ static gnutls_x509_crt_t x509_crt_copy(gnutls_x509_crt_t src) gnutls_datum_t tmp; gnutls_x509_crt_t dest; size = 0; - + if (gnutls_x509_crt_init(&dest) != 0) { g_warning("couldn't gnutls_x509_crt_init"); return NULL; } - if (gnutls_x509_crt_export(src, GNUTLS_X509_FMT_DER, NULL, &size) + if (gnutls_x509_crt_export(src, GNUTLS_X509_FMT_DER, NULL, &size) != GNUTLS_E_SHORT_MEMORY_BUFFER) { g_warning("couldn't gnutls_x509_crt_export to get size"); gnutls_x509_crt_deinit(dest); @@ -151,7 +147,7 @@ static SSLCertificate *ssl_certificate_new(gnutls_x509_crt_t x509_cert, const gc { SSLCertificate *cert = g_new0(SSLCertificate, 1); size_t n; - unsigned char md[128]; + unsigned char md[128]; if (host == NULL || x509_cert == NULL) { ssl_certificate_destroy(cert); @@ -161,7 +157,7 @@ static SSLCertificate *ssl_certificate_new(gnutls_x509_crt_t x509_cert, const gc cert->status = (guint)-1; cert->host = g_strdup(host); cert->port = port; - + /* fingerprint */ n = sizeof(md); gnutls_x509_crt_get_fingerprint(cert->x509_cert, GNUTLS_DIG_MD5, md, &n); @@ -174,7 +170,7 @@ static void gnutls_export_X509_fp(FILE *fp, gnutls_x509_crt_t x509_cert, gnutls_ char output[10*1024]; size_t cert_size = 10*1024; int r; - + if ((r = gnutls_x509_crt_export(x509_cert, format, output, &cert_size)) < 0) { g_warning("couldn't export cert %s (%"G_GSIZE_FORMAT")", gnutls_strerror(r), cert_size); return; @@ -189,10 +185,10 @@ size_t gnutls_i2d_X509(gnutls_x509_crt_t x509_cert, unsigned char **output) { size_t cert_size = 10*1024; int r; - + if (output == NULL) return 0; - + *output = malloc(cert_size); if ((r = gnutls_x509_crt_export(x509_cert, GNUTLS_X509_FMT_DER, *output, &cert_size)) < 0) { @@ -208,10 +204,10 @@ size_t gnutls_i2d_PrivateKey(gnutls_x509_privkey_t pkey, unsigned char **output) { size_t key_size = 10*1024; int r; - + if (output == NULL) return 0; - + *output = malloc(key_size); if ((r = gnutls_x509_privkey_export(pkey, GNUTLS_X509_FMT_DER, *output, &key_size)) < 0) { @@ -255,7 +251,7 @@ static int gnutls_import_X509_list_fp(FILE *fp, gnutls_x509_crt_fmt_t format, return -EIO; } - if ((r = gnutls_x509_crt_list_import(crt_list, &max, + if ((r = gnutls_x509_crt_list_import(crt_list, &max, &tmp, format, flags)) < 0) { debug_print("cert import failed: %s\n", gnutls_strerror(r)); free(tmp.data); @@ -363,9 +359,9 @@ static void ssl_certificate_save (SSLCertificate *cert) gchar *file, *port; FILE *fp; - file = g_strconcat(get_rc_dir(), G_DIR_SEPARATOR_S, + file = g_strconcat(get_rc_dir(), G_DIR_SEPARATOR_S, "certs", G_DIR_SEPARATOR_S, NULL); - + if (!is_dir_exist(file)) make_dir_hier(file); g_free(file); @@ -388,7 +384,7 @@ static void ssl_certificate_save (SSLCertificate *cert) } -void ssl_certificate_destroy(SSLCertificate *cert) +void ssl_certificate_destroy(SSLCertificate *cert) { if (cert == NULL) return; @@ -425,7 +421,7 @@ SSLCertificate *ssl_certificate_find (const gchar *host, gushort port, const gch gboolean must_rename = FALSE; buf = g_strdup_printf("%d", port); - + if (fingerprint != NULL) { file = get_certificate_path(host, buf, fingerprint); fp = g_fopen(file, "rb"); @@ -449,7 +445,7 @@ SSLCertificate *ssl_certificate_find (const gchar *host, gushort port, const gch g_free(buf); return NULL; } - + if ((tmp_x509 = gnutls_import_X509_fp(fp, GNUTLS_X509_FMT_DER)) != NULL) { cert = ssl_certificate_new(tmp_x509, host, port); debug_print("got cert %p\n", cert); @@ -458,7 +454,7 @@ SSLCertificate *ssl_certificate_find (const gchar *host, gushort port, const gch fclose(fp); g_free(file); - + if (must_rename) { gchar *old = get_certificate_path(host, buf, NULL); gchar *new = get_certificate_path(host, buf, fingerprint); @@ -482,7 +478,7 @@ static gboolean ssl_certificate_compare (SSLCertificate *cert_a, SSLCertificate if (cert_a == NULL || cert_b == NULL) return FALSE; - if ((r = gnutls_x509_crt_export(cert_a->x509_cert, GNUTLS_X509_FMT_DER, NULL, &cert_size_a)) + if ((r = gnutls_x509_crt_export(cert_a->x509_cert, GNUTLS_X509_FMT_DER, NULL, &cert_size_a)) != GNUTLS_E_SHORT_MEMORY_BUFFER) { g_warning("couldn't gnutls_x509_crt_export to get size a %s", gnutls_strerror(r)); return FALSE; @@ -521,7 +517,7 @@ static gboolean ssl_certificate_compare (SSLCertificate *cert_a, SSLCertificate } g_free(output_a); g_free(output_b); - + return TRUE; } @@ -551,7 +547,7 @@ static guint check_cert(SSLCertificate *cert) } fclose(fp); fp = NULL; - + buf = g_strdup_printf("%d", cert->port); chain_file = get_certificate_chain_path(cert->host, buf, cert->fingerprint); g_free(buf); @@ -581,7 +577,7 @@ static guint check_cert(SSLCertificate *cert) if (!fingerprint || strcmp(fingerprint, cert->fingerprint)) { debug_print("saved chain fingerprint does not match current : %s / %s\n", cert->fingerprint, fingerprint); - + return (guint)-1; } g_free(fingerprint); @@ -627,11 +623,11 @@ static gboolean ssl_certificate_is_valid(SSLCertificate *cert, guint status) return ssl_certificate_check_subject_cn(cert); } -char *ssl_certificate_check_signer (SSLCertificate *cert, guint status) +char *ssl_certificate_check_signer (SSLCertificate *cert, guint status) { gnutls_x509_crt_t x509_cert = cert ? cert->x509_cert : NULL; - if (!cert) + if (!cert) return g_strdup(_("Internal error")); if (status == (guint)-1) { @@ -659,10 +655,10 @@ static void ssl_certificate_save_chain(gnutls_x509_crt_t *certs, gint len, const gint i; gchar *file = NULL; FILE *fp = NULL; - + for (i = 0; i < len; i++) { size_t n; - unsigned char md[128]; + unsigned char md[128]; gnutls_x509_crt_t cert = certs[i]; if (i == 0) { @@ -692,7 +688,7 @@ static void ssl_certificate_save_chain(gnutls_x509_crt_t *certs, gint len, const safe_fclose(fp); } -gboolean ssl_certificate_check (gnutls_x509_crt_t x509_cert, guint status, +gboolean ssl_certificate_check (gnutls_x509_crt_t x509_cert, guint status, const gchar *host, gushort port, gboolean accept_if_valid) { @@ -832,7 +828,7 @@ gboolean ssl_certificate_check_chain(gnutls_x509_crt_t *certs, gint chain_len, if (r < 0) g_warning("can't read SSL_CERT_FILE '%s': %s", - claws_ssl_get_cert_file(), + claws_ssl_get_cert_file(), gnutls_strerror(r)); } else { debug_print("Can't find SSL ca-certificates file\n"); @@ -865,7 +861,7 @@ gnutls_x509_crt_t ssl_certificate_get_x509_from_pem_file(const gchar *file) gnutls_x509_crt_t x509 = NULL; if (!file) return NULL; - + if (is_file_exist(file)) { FILE *fp = g_fopen(file, "r"); if (fp) { @@ -888,7 +884,7 @@ gnutls_x509_privkey_t ssl_certificate_get_pkey_from_pem_file(const gchar *file) gnutls_x509_privkey_t key = NULL; if (!file) return NULL; - + if (is_file_exist(file)) { FILE *fp = g_fopen(file, "r"); if (fp) { @@ -1078,7 +1074,7 @@ gchar *ssl_certificate_get_subject_cn(SSLCertificate *cert) gchar subject_cn[BUFFSIZE]; size_t n = BUFFSIZE; - if(gnutls_x509_crt_get_dn_by_oid(cert->x509_cert, + if(gnutls_x509_crt_get_dn_by_oid(cert->x509_cert, GNUTLS_OID_X520_COMMON_NAME, 0, 0, subject_cn, &n)) return g_strdup(_("<not in certificate>")); diff --git a/src/common/utils.c b/src/common/utils.c @@ -45,11 +45,7 @@ #include <ctype.h> #include <errno.h> #include <sys/param.h> -#ifdef G_OS_WIN32 -# include <ws2tcpip.h> -#else -# include <sys/socket.h> -#endif +#include <sys/socket.h> #if (HAVE_WCTYPE_H && HAVE_WCHAR_H) # include <wchar.h> @@ -69,11 +65,6 @@ #include <fcntl.h> -#ifdef G_OS_WIN32 -# include <direct.h> -# include <io.h> -#endif - #include "utils.h" #include "socket.h" #include "codeconv.h" @@ -196,39 +187,20 @@ gchar *to_human_readable(goffset size) } } -/* compare paths */ gint path_cmp(const gchar *s1, const gchar *s2) { gint len1, len2; - int rc; -#ifdef G_OS_WIN32 - gchar *s1buf, *s2buf; -#endif if (s1 == NULL || s2 == NULL) return -1; if (*s1 == '\0' || *s2 == '\0') return -1; -#ifdef G_OS_WIN32 - s1buf = g_strdup (s1); - s2buf = g_strdup (s2); - subst_char (s1buf, '/', G_DIR_SEPARATOR); - subst_char (s2buf, '/', G_DIR_SEPARATOR); - s1 = s1buf; - s2 = s2buf; -#endif /* !G_OS_WIN32 */ - len1 = strlen(s1); len2 = strlen(s2); if (s1[len1 - 1] == G_DIR_SEPARATOR) len1--; if (s2[len2 - 1] == G_DIR_SEPARATOR) len2--; - rc = strncmp(s1, s2, MAX(len1, len2)); -#ifdef G_OS_WIN32 - g_free (s1buf); - g_free (s2buf); -#endif /* !G_OS_WIN32 */ - return rc; + return strncmp(s1, s2, MAX(len1, len2)); } /* remove trailing return code */ @@ -941,11 +913,7 @@ void subst_for_filename(gchar *str) { if (!str) return; -#ifdef G_OS_WIN32 - subst_chars(str, "\t\r\n\\/*?:", '_'); -#else subst_chars(str, "\t\r\n\\/*", '_'); -#endif } void subst_for_shellsafe_filename(gchar *str) @@ -1267,7 +1235,6 @@ GList *uri_list_extract_filenames(const gchar *uri_list) * g_filename_from_uri() rejects escaped/locale encoded uri * string which come from Nautilus. */ -#ifndef G_OS_WIN32 if (g_utf8_validate(file, -1, NULL)) locale_file = conv_codeset_strdup( @@ -1276,9 +1243,6 @@ GList *uri_list_extract_filenames(const gchar *uri_list) conv_get_locale_charset_str()); if (!locale_file) locale_file = g_strdup(file + 5); -#else - locale_file = g_filename_from_uri(escaped_utf8uri, NULL, NULL); -#endif result = g_list_append(result, locale_file); } } @@ -1558,165 +1522,18 @@ gint scan_mailto_url(const gchar *mailto, gchar **from, gchar **to, gchar **cc, return 0; } - -#ifdef G_OS_WIN32 -#include <windows.h> -#ifndef CSIDL_APPDATA -#define CSIDL_APPDATA 0x001a -#endif -#ifndef CSIDL_LOCAL_APPDATA -#define CSIDL_LOCAL_APPDATA 0x001c -#endif -#ifndef CSIDL_FLAG_CREATE -#define CSIDL_FLAG_CREATE 0x8000 -#endif -#define DIM(v) (sizeof(v)/sizeof((v)[0])) - -#define RTLD_LAZY 0 -const char * -w32_strerror (int w32_errno) -{ - static char strerr[256]; - int ec = (int)GetLastError (); - - if (w32_errno == 0) - w32_errno = ec; - FormatMessage (FORMAT_MESSAGE_FROM_SYSTEM, NULL, w32_errno, - MAKELANGID (LANG_NEUTRAL, SUBLANG_DEFAULT), - strerr, DIM (strerr)-1, NULL); - return strerr; -} - -static __inline__ void * -dlopen (const char * name, int flag) -{ - void * hd = LoadLibrary (name); - return hd; -} - -static __inline__ void * -dlsym (void * hd, const char * sym) -{ - if (hd && sym) - { - void * fnc = GetProcAddress (hd, sym); - if (!fnc) - return NULL; - return fnc; - } - return NULL; -} - - -static __inline__ const char * -dlerror (void) -{ - return w32_strerror (0); -} - - -static __inline__ int -dlclose (void * hd) -{ - if (hd) - { - FreeLibrary (hd); - return 0; - } - return -1; -} - -static HRESULT -w32_shgetfolderpath (HWND a, int b, HANDLE c, DWORD d, LPSTR e) -{ - static int initialized; - static HRESULT (WINAPI * func)(HWND,int,HANDLE,DWORD,LPSTR); - - if (!initialized) - { - static char *dllnames[] = { "shell32.dll", "shfolder.dll", NULL }; - void *handle; - int i; - - initialized = 1; - - for (i=0, handle = NULL; !handle && dllnames[i]; i++) - { - handle = dlopen (dllnames[i], RTLD_LAZY); - if (handle) - { - func = dlsym (handle, "SHGetFolderPathW"); - if (!func) - { - dlclose (handle); - handle = NULL; - } - } - } - } - - if (func) - return func (a,b,c,d,e); - else - return -1; -} - -/* Returns a static string with the directroy from which the module - has been loaded. Returns an empty string on error. */ -static char *w32_get_module_dir(void) -{ - static char *moddir; - - if (!moddir) { - char name[MAX_PATH+10]; - char *p; - - if ( !GetModuleFileNameA (0, name, sizeof (name)-10) ) - *name = 0; - else { - p = strrchr (name, '\\'); - if (p) - *p = 0; - else - *name = 0; - } - moddir = g_strdup (name); - } - return moddir; -} -#endif /* G_OS_WIN32 */ - /* Return a static string with the locale dir. */ const gchar *get_locale_dir(void) { static gchar *loc_dir; - -#ifdef G_OS_WIN32 - if (!loc_dir) - loc_dir = g_strconcat(w32_get_module_dir(), G_DIR_SEPARATOR_S, - "\\share\\locale", NULL); -#endif if (!loc_dir) loc_dir = LOCALEDIR; - return loc_dir; } const gchar *get_home_dir(void) { -#ifdef G_OS_WIN32 - static char home_dir_utf16[MAX_PATH] = ""; - static gchar *home_dir_utf8 = NULL; - if (home_dir_utf16[0] == '\0') { - if (w32_shgetfolderpath - (NULL, CSIDL_APPDATA|CSIDL_FLAG_CREATE, - NULL, 0, home_dir_utf16) < 0) - strcpy (home_dir_utf16, "C:\\Claws Mail"); - home_dir_utf8 = g_utf16_to_utf8 ((const gunichar2 *)home_dir_utf16, -1, NULL, NULL, NULL); - } - return home_dir_utf8; -#else static const gchar *homeenv = NULL; if (homeenv) @@ -1728,7 +1545,6 @@ const gchar *get_home_dir(void) homeenv = g_get_home_dir(); return homeenv; -#endif } static gchar *claws_rc_dir = NULL; @@ -1829,19 +1645,6 @@ const gchar *get_template_dir(void) return template_dir; } -#ifdef G_OS_WIN32 -const gchar *w32_get_cert_file(void) -{ - const gchar *cert_file = NULL; - if (!cert_file) - cert_file = g_strconcat(w32_get_module_dir(), - "\\share\\claws-mail\\", - "ca-certificates.crt", - NULL); - return cert_file; -} -#endif - /* Return the filepath of the claws-mail.desktop file */ const gchar *get_desktop_file(void) { @@ -1852,20 +1655,6 @@ const gchar *get_desktop_file(void) #endif } -#ifdef G_OS_WIN32 -/* Return the default directory for Themes. */ -const gchar *w32_get_themes_dir(void) -{ - static gchar *themes_dir = NULL; - - if (!themes_dir) - themes_dir = g_strconcat(w32_get_module_dir(), - "\\share\\claws-mail\\themes", - NULL); - return themes_dir; -} -#endif - const gchar *get_tmp_dir(void) { static gchar *tmp_dir = NULL; @@ -1950,36 +1739,12 @@ gboolean is_numeric_host_address(const gchar *hostaddress) off_t get_file_size(const gchar *file) { -#ifdef G_OS_WIN32 - GFile *f; - GFileInfo *fi; - GError *error = NULL; - goffset size; - - f = g_file_new_for_path(file); - fi = g_file_query_info(f, "standard::size", - G_FILE_QUERY_INFO_NONE, NULL, &error); - if (error != NULL) { - debug_print("get_file_size error: %s\n", error->message); - g_error_free(error); - g_object_unref(f); - return -1; - } - size = g_file_info_get_size(fi); - g_object_unref(fi); - g_object_unref(f); - return size; - -#else GStatBuf s; - if (g_stat(file, &s) < 0) { FILE_OP_ERROR(file, "stat"); return -1; } - return s.st_size; -#endif } time_t get_file_mtime(const gchar *file) @@ -2013,26 +1778,12 @@ gboolean file_exist(const gchar *file, gboolean allow_fifo) } -/* Test on whether FILE is a relative file name. This is - * straightforward for Unix but more complex for Windows. */ +/* Test on whether FILE is a relative file name. */ gboolean is_relative_filename(const gchar *file) { if (!file) return TRUE; -#ifdef G_OS_WIN32 - if ( *file == '\\' && file[1] == '\\' && strchr (file+2, '\\') ) - return FALSE; /* Prefixed with a hostname - this can't - * be a relative name. */ - - if ( ((*file >= 'a' && *file <= 'z') - || (*file >= 'A' && *file <= 'Z')) - && file[1] == ':') - file += 2; /* Skip drive letter. */ - - return !(*file == '\\' || *file == '/'); -#else return !(*file == G_DIR_SEPARATOR); -#endif } @@ -2648,7 +2399,6 @@ FILE *get_command_output_stream(const char* cmdline) return fdopen(fd, "r"); } -#ifndef G_OS_WIN32 static gint is_unchanged_uri_char(char c) { switch (c) { @@ -2684,12 +2434,10 @@ static void encode_uri(gchar *encoded_uri, gint bufsize, const gchar *uri) } encoded_uri[k] = 0; } -#endif gint open_uri(const gchar *uri, const gchar *cmdline) { -#ifndef G_OS_WIN32 gchar buf[BUFFSIZE]; gchar *p; gchar encoded_uri[BUFFSIZE]; @@ -2711,9 +2459,6 @@ gint open_uri(const gchar *uri, const gchar *cmdline) } execute_command_line(buf, TRUE, NULL); -#else - ShellExecute(NULL, "open", uri, NULL, NULL, SW_SHOW); -#endif return 0; } @@ -2814,10 +2559,7 @@ time_t tzoffset_sec(time_t *now) struct tm gmt, *lt; gint off; struct tm buf1, buf2; -#ifdef G_OS_WIN32 - if (now && *now < 0) - return 0; -#endif + gmt = *gmtime_r(now, &buf1); lt = localtime_r(now, &buf2); @@ -2848,10 +2590,7 @@ gchar *tzoffset(time_t *now) gint off; gchar sign = '+'; struct tm buf1, buf2; -#ifdef G_OS_WIN32 - if (now && *now < 0) - return 0; -#endif + gmt = *gmtime_r(now, &buf1); lt = localtime_r(now, &buf2); @@ -4249,11 +3988,7 @@ size_t fast_strftime(gchar *buf, gint buflen, const gchar *format, struct tm *lt } break; case 'r': -#ifdef G_OS_WIN32 - strftime(subbuf, 64, "%I:%M:%S %p", lt); -#else strftime(subbuf, 64, "%r", lt); -#endif len = strlen(subbuf); CHECK_SIZE(); strncpy2(curpos, subbuf, buflen - total_done); break; @@ -4357,30 +4092,13 @@ size_t fast_strftime(gchar *buf, gint buflen, const gchar *format, struct tm *lt return total_done; } -#ifdef G_OS_WIN32 -#define WEXITSTATUS(x) (x) -#endif - static gchar *canonical_list_to_file(GSList *list) { GString *result = g_string_new(NULL); GSList *pathlist = g_slist_reverse(g_slist_copy(list)); GSList *cur; -#ifndef G_OS_WIN32 result = g_string_append(result, G_DIR_SEPARATOR_S); -#else - if (pathlist->data) { - const gchar *root = (gchar *)pathlist->data; - if (root[0] != '\0' && g_ascii_isalpha(root[0]) && - root[1] == ':') { - /* drive - don't prepend dir separator */ - } else { - result = g_string_append(result, G_DIR_SEPARATOR_S); - } - } -#endif - for (cur = pathlist; cur; cur = cur->next) { result = g_string_append(result, (gchar *)cur->data); if (cur->next) @@ -4397,16 +4115,10 @@ static GSList *cm_split_path(const gchar *filename, int depth) GSList *canonical_parts = NULL; GStatBuf st; int i; -#ifndef G_OS_WIN32 gboolean follow_symlinks = TRUE; -#endif if (depth > 32) { -#ifndef G_OS_WIN32 - errno = ELOOP; -#else errno = EINVAL; /* can't happen, no symlink handling */ -#endif return NULL; } @@ -4443,9 +4155,7 @@ static GSList *cm_split_path(const gchar *filename, int depth) if(g_stat(tmp_path, &st) < 0) { if (errno == ENOENT) { errno = 0; -#ifndef G_OS_WIN32 follow_symlinks = FALSE; -#endif } if (errno != 0) { g_free(tmp_path); @@ -4455,7 +4165,6 @@ static GSList *cm_split_path(const gchar *filename, int depth) return NULL; } } -#ifndef G_OS_WIN32 if (follow_symlinks && g_file_test(tmp_path, G_FILE_TEST_IS_SYMLINK)) { GError *error = NULL; gchar *target = g_file_read_link(tmp_path, &error); @@ -4488,7 +4197,6 @@ static GSList *cm_split_path(const gchar *filename, int depth) } g_free(target); } -#endif g_free(tmp_path); } } @@ -4552,16 +4260,6 @@ guchar *g_base64_decode_zero(const gchar *text, gsize *out_len) gboolean get_random_bytes(void *buf, size_t count) { - /* Open our prng source. */ -#if defined G_OS_WIN32 - HCRYPTPROV rnd; - - if (!CryptAcquireContext(&rnd, NULL, NULL, PROV_RSA_FULL, 0) && - !CryptAcquireContext(&rnd, NULL, NULL, PROV_RSA_FULL, CRYPT_NEWKEYSET)) { - debug_print("Could not acquire a CSP handle.\n"); - return FALSE; - } -#else int rnd; ssize_t ret; @@ -4571,16 +4269,8 @@ get_random_bytes(void *buf, size_t count) debug_print("Could not open /dev/urandom.\n"); return FALSE; } -#endif /* Read data from the source into buf. */ -#if defined G_OS_WIN32 - if (!CryptGenRandom(rnd, count, buf)) { - debug_print("Could not read %"G_GSIZE_FORMAT" random bytes.\n", count); - CryptReleaseContext(rnd, 0); - return FALSE; - } -#else ret = read(rnd, buf, count); if (ret != count) { FILE_OP_ERROR("/dev/urandom", "read"); @@ -4588,15 +4278,7 @@ get_random_bytes(void *buf, size_t count) close(rnd); return FALSE; } -#endif - - /* Close the prng source. */ -#if defined G_OS_WIN32 - CryptReleaseContext(rnd, 0); -#else close(rnd); -#endif - return TRUE; } @@ -4665,11 +4347,3 @@ gboolean get_serverportfp_from_filename(const gchar *str, gchar **server, gchar else return TRUE; } - -#ifdef G_OS_WIN32 -gchar *win32_debug_log_path(void) -{ - return g_strconcat(g_get_tmp_dir(), G_DIR_SEPARATOR_S, - "claws-win32.log", NULL); -} -#endif diff --git a/src/common/utils.h b/src/common/utils.h @@ -57,12 +57,6 @@ /* Handling Base64 content in procmime and prefs_customheader */ #define B64_LINE_SIZE 57 -#ifdef G_OS_WIN32 - -#define fsync _commit - -#define pipe(phandles) _pipe (phandles, 4096, _O_BINARY) -#endif /* Wrappers for C library function that take pathname arguments. */ # include <glib/gstdio.h> @@ -415,10 +409,7 @@ gchar *get_tmp_file (void); const gchar *get_domain_name (void); gboolean is_numeric_host_address (const gchar *hostaddress); const gchar *get_desktop_file(void); -#ifdef G_OS_WIN32 -const gchar *w32_get_themes_dir (void); -const gchar *w32_get_cert_file (void); -#endif + /* file / directory handling */ off_t get_file_size (const gchar *file); time_t get_file_mtime (const gchar *file); @@ -557,8 +548,4 @@ gboolean get_random_bytes(void *buf, size_t count); gboolean get_serverportfp_from_filename(const gchar *str, gchar **server, gchar **port, gchar **fp); -#ifdef G_OS_WIN32 -gchar *win32_debug_log_path(void); -#endif - #endif /* __UTILS_H__ */ diff --git a/src/common/w32_reg.c b/src/common/w32_reg.c @@ -1,129 +0,0 @@ -/* - * Claws Mail -- a GTK based, lightweight, and fast e-mail client - * Copyright (C) 1999-2021 the Claws Mail team and Hiroyuki Yamamoto - * - * 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 - * the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see <http://www.gnu.org/licenses/>. - */ - -#include "config.h" - -#include "w32_reg.h" -#include "utils.h" - -gboolean reg_set_value(HKEY root, - const gchar *subkey, - const gchar *value, - DWORD type, - const BYTE *data, - DWORD data_size) -{ - DWORD ret; - HKEY key; - gchar *tmp; - - ret = RegCreateKeyEx(root, subkey, 0, NULL, REG_OPTION_NON_VOLATILE, KEY_WRITE, NULL, &key, NULL); - if (ret != ERROR_SUCCESS) { - tmp = g_win32_error_message(ret); - debug_print("RegCreateKeyEx %p \"%s\" had error: \"%s\"\n", root, subkey, tmp); - g_free(tmp); - return FALSE; - } - - ret = RegSetValueEx(key, value, 0, type, data, data_size); - if (ret != ERROR_SUCCESS) { - tmp = g_win32_error_message(ret); - debug_print("RegSetValueEx %p \"%s\" had error: \"%s\"\n", root, subkey, tmp); - g_free(tmp); - } - - RegCloseKey(key); - return (ret == ERROR_SUCCESS); -} - -gboolean write_w32_registry_string(HKEY root, - const gchar *subkey, - const gchar *value, - const gchar *data) -{ - return reg_set_value(root, subkey, value, REG_SZ, (BYTE *)data, strlen(data) + 1); -} - -gboolean write_w32_registry_dword(HKEY root, - const gchar *subkey, - const gchar *value, - DWORD data) -{ - return reg_set_value(root, subkey, value, REG_DWORD, (BYTE *)&data, sizeof(DWORD)); -} - -gchar *read_w32_registry_string(HKEY root, const gchar *subkey, const gchar *value) -{ - HKEY hkey; - DWORD ret; - DWORD type; - BYTE *data; - DWORD data_size; - gchar *tmp; - - if (subkey == NULL) - return NULL; - - ret = RegOpenKeyEx(root, subkey, 0, KEY_READ, &hkey); - if (ret != ERROR_SUCCESS) { - tmp = g_win32_error_message(ret); - debug_print("RegOpenKeyEx %p \"%s\" had error: \"%s\"\n", root, subkey, tmp); - g_free(tmp); - return NULL; - } - - // Get the needed buffer size - ret = RegQueryValueEx(hkey, value, 0, &type, NULL, &data_size); - if (ret != ERROR_SUCCESS) { - tmp = g_win32_error_message(ret); - debug_print("RegQueryValueEx %p \"%s\" \"%s\" had error: \"%s\" when getting buffer size\n", - root, subkey, value, tmp); - RegCloseKey(hkey); - g_free(tmp); - return NULL; - } else if (type != REG_SZ) { - debug_print("RegQueryValueEx %p \"%s\" \"%s\" returned type %lu instead of REG_SZ\n", - root, subkey, value, type); - RegCloseKey(hkey); - return NULL; - } else if (data_size == 0) { - debug_print("RegQueryValueEx %p \"%s\" \"%s\" returned data size 0\n", - root, subkey, value); - RegCloseKey(hkey); - return NULL; - } - - // The raw value is not necessarily NUL-terminated - data = g_malloc(data_size + 1); - - ret = RegQueryValueEx(hkey, value, 0, NULL, data, &data_size); - if (ret == ERROR_SUCCESS) { - data[data_size] = '\0'; - } else { - tmp = g_win32_error_message(ret); - debug_print("RegQueryValueEx %p \"%s\" \"%s\" had error: \"%s\"\n", - root, subkey, value, tmp); - RegCloseKey(hkey); - g_free(data); - g_free(tmp); - return NULL; - } - - RegCloseKey(hkey); - return (gchar *)data; -} diff --git a/src/common/w32_reg.h b/src/common/w32_reg.h @@ -1,40 +0,0 @@ -/* - * Claws Mail -- a GTK based, lightweight, and fast e-mail client - * Copyright (C) 1999-2021 the Claws Mail team and Hiroyuki Yamamoto - * - * 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 - * the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see <http://www.gnu.org/licenses/>. - */ - -#ifndef __W32_REG_H__ -#define __W32_REG_H__ - -#include <windows.h> -#include <glib.h> - -gboolean write_w32_registry_string(HKEY root, - const gchar *subkey, - const gchar *value, - const gchar *data); - -gboolean write_w32_registry_dword(HKEY root, - const gchar *subkey, - const gchar *value, - DWORD data); - -// Caller should deallocate the return value with g_free() -gchar *read_w32_registry_string(HKEY root, - const gchar *subkey, - const gchar *value); - -#endif diff --git a/src/compose.c b/src/compose.c @@ -49,12 +49,7 @@ #endif #include <signal.h> #include <errno.h> -#ifndef G_OS_WIN32 /* fixme we should have a configure test. */ #include <libgen.h> -#endif -#ifdef G_OS_WIN32 -#include <windows.h> -#endif #if (HAVE_WCTYPE_H && HAVE_WCHAR_H) # include <wchar.h> @@ -181,11 +176,7 @@ typedef enum { "message.")); \ } -#ifdef G_OS_WIN32 -#define INVALID_PID INVALID_HANDLE_VALUE -#else #define INVALID_PID -1 -#endif static GdkRGBA default_header_bgcolor = {0, 0, 0, 1}; @@ -3568,13 +3559,7 @@ static ComposeInsertResult compose_insert_file(Compose *compose, const gchar *fi gint len; FILE *fp; gboolean prev_autowrap; -#ifdef G_OS_WIN32 - GFile *f; - GFileInfo *fi; - GError *error = NULL; -#else GStatBuf file_stat; -#endif int ret; goffset size; GString *file_contents = NULL; @@ -3583,33 +3568,15 @@ static ComposeInsertResult compose_insert_file(Compose *compose, const gchar *fi cm_return_val_if_fail(file != NULL, COMPOSE_INSERT_NO_FILE); /* get the size of the file we are about to insert */ -#ifdef G_OS_WIN32 - f = g_file_new_for_path(file); - fi = g_file_query_info(f, "standard::size", - G_FILE_QUERY_INFO_NONE, NULL, &error); - ret = 0; - if (error != NULL) { - g_warning(error->message); - ret = 1; - g_error_free(error); - g_object_unref(f); - } -#else + ret = g_stat(file, &file_stat); -#endif if (ret != 0) { gchar *shortfile = g_path_get_basename(file); alertpanel_error(_("Could not get size of file '%s'."), shortfile); g_free(shortfile); return COMPOSE_INSERT_NO_FILE; } else if (prefs_common.warn_large_insert == TRUE) { -#ifdef G_OS_WIN32 - size = g_file_info_get_size(fi); - g_object_unref(fi); - g_object_unref(f); -#else size = file_stat.st_size; -#endif /* ask user for confirmation if the file is large */ if (prefs_common.warn_large_insert_size < 0 || @@ -6325,13 +6292,7 @@ static int compose_add_attachments(Compose *compose, MimeInfo *parent, gint acti AttachInfo *ainfo; GtkTreeView *tree_view = GTK_TREE_VIEW(compose->attach_clist); MimeInfo *mimepart; -#ifdef G_OS_WIN32 - GFile *f; - GFileInfo *fi; - GError *error = NULL; -#else GStatBuf statbuf; -#endif goffset size; gchar *type, *subtype; GtkTreeModel *model; @@ -6356,24 +6317,9 @@ static int compose_add_attachments(Compose *compose, MimeInfo *parent, gint acti } continue; } -#ifdef G_OS_WIN32 - f = g_file_new_for_path(ainfo->file); - fi = g_file_query_info(f, "standard::size", - G_FILE_QUERY_INFO_NONE, NULL, &error); - if (error != NULL) { - g_warning(error->message); - g_error_free(error); - g_object_unref(f); - return -1; - } - size = g_file_info_get_size(fi); - g_object_unref(fi); - g_object_unref(f); -#else if (g_stat(ainfo->file, &statbuf) < 0) return -1; size = statbuf.st_size; -#endif mimepart = procmime_mimeinfo_new(); mimepart->content = MIMECONTENT_FILE; @@ -9595,13 +9541,8 @@ static gboolean compose_ext_editor_kill(Compose *compose) if (val == G_ALERTALTERNATE) { g_source_remove(compose->exteditor_tag); -#ifdef G_OS_WIN32 - if (!TerminateProcess(compose->exteditor_pid, 0)) - perror("TerminateProcess"); -#else if (kill(pid, SIGTERM) < 0) perror("kill"); waitpid(compose->exteditor_pid, NULL, 0); -#endif /* G_OS_WIN32 */ g_warning("terminated %s, temporary file: %s", pidmsg, compose->exteditor_file); @@ -10257,14 +10198,7 @@ warn_err: compose_close(compose); return TRUE; } else { -#ifdef G_OS_WIN32 - GFile *f; - GFileInfo *fi; - GTimeVal tv; - GError *error = NULL; -#else GStatBuf s; -#endif gchar *path; goffset size, mtime; @@ -10273,24 +10207,6 @@ warn_err: debug_print("can't fetch %s:%d\n", draft->path, msgnum); goto unlock; } -#ifdef G_OS_WIN32 - f = g_file_new_for_path(path); - fi = g_file_query_info(f, "standard::size,time::modified", - G_FILE_QUERY_INFO_NONE, NULL, &error); - if (error != NULL) { - debug_print("couldn't query file info for '%s': %s\n", - path, error->message); - g_error_free(error); - g_free(path); - g_object_unref(f); - goto unlock; - } - size = g_file_info_get_size(fi); - g_file_info_get_modification_time(fi, &tv); - mtime = tv.tv_sec; - g_object_unref(fi); - g_object_unref(f); -#else if (g_stat(path, &s) < 0) { FILE_OP_ERROR(path, "stat"); g_free(path); @@ -10298,7 +10214,6 @@ warn_err: } size = s.st_size; mtime = s.st_mtime; -#endif g_free(path); procmsg_msginfo_free(&(compose->targetinfo)); diff --git a/src/etpan/etpan-thread-manager.c b/src/etpan/etpan-thread-manager.c @@ -14,7 +14,7 @@ * * You should have received a copy of the GNU General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. - * + * */ #ifdef HAVE_CONFIG_H @@ -72,11 +72,11 @@ struct etpan_thread_manager * etpan_thread_manager_new(void) { struct etpan_thread_manager * manager; int r; - + manager = malloc(sizeof(* manager)); if (manager == NULL) goto err; - + manager->thread_pool = carray_new(POOL_INIT_SIZE); if (manager->thread_pool == NULL) goto free; @@ -84,16 +84,16 @@ struct etpan_thread_manager * etpan_thread_manager_new(void) manager->thread_pending = carray_new(POOL_INIT_SIZE); if (manager->thread_pending == NULL) goto free_pool; - + manager->can_create_thread = 1; manager->unbound_count = 0; - + r = pipe(manager->notify_fds); if (r < 0) goto free_pending; - + return manager; - + free_pending: carray_free(manager->thread_pending); free_pool: @@ -117,11 +117,11 @@ static struct etpan_thread * etpan_thread_new(void) { struct etpan_thread * thread; int r; - + thread = malloc(sizeof(* thread)); if (thread == NULL) goto err; - + r = pthread_mutex_init(&thread->lock, NULL); if (r != 0) goto free; @@ -129,29 +129,29 @@ static struct etpan_thread * etpan_thread_new(void) thread->op_list = carray_new(OP_INIT_SIZE); if (thread->op_list == NULL) goto destroy_lock; - + thread->op_done_list = carray_new(OP_INIT_SIZE); if (thread->op_done_list == NULL) goto free_op_list; - + thread->start_sem = mailsem_new(); if (thread->start_sem == NULL) goto free_op_done_list; - + thread->stop_sem = mailsem_new(); if (thread->stop_sem == NULL) goto free_startsem; - + thread->op_sem = mailsem_new(); if (thread->op_sem == NULL) goto free_stopsem; - + thread->manager = NULL; thread->bound_count = 0; thread->terminate_state = TERMINATE_STATE_NONE; - + return thread; - + free_stopsem: mailsem_free(thread->stop_sem); free_startsem: @@ -183,7 +183,7 @@ struct etpan_thread_op * etpan_thread_op_new(void) { struct etpan_thread_op * op; int r; - + op = malloc(sizeof(* op)); if (op == NULL) goto err; @@ -193,9 +193,9 @@ struct etpan_thread_op * etpan_thread_op_new(void) r = pthread_mutex_init(&op->lock, NULL); if (r != 0) goto free; - + return op; - + free: free(op); err: @@ -213,25 +213,25 @@ etpan_thread_manager_create_thread(struct etpan_thread_manager * manager) { struct etpan_thread * thread; int r; - + thread = etpan_thread_new(); if (thread == NULL) goto err; - + thread->manager = manager; - + r = etpan_thread_start(thread); if (r != NO_ERROR) goto free_thread; - + r = carray_add(manager->thread_pool, thread, NULL); if (r < 0) { etpan_thread_stop(thread); goto free_thread; } - + return thread; - + free_thread: etpan_thread_free(thread); err: @@ -244,22 +244,22 @@ etpan_thread_manager_terminate_thread(struct etpan_thread_manager * manager, { unsigned int i; int r; - + for(i = 0 ; i < carray_count(manager->thread_pool) ; i ++) { if (carray_get(manager->thread_pool, i) == thread) { carray_delete(manager->thread_pool, i); break; } } - + if (!etpan_thread_is_bound(thread)) manager->unbound_count --; - + r = carray_add(manager->thread_pending, thread, NULL); if (r < 0) { g_warning("complete failure of thread due to lack of memory (thread stop)"); } - + etpan_thread_stop(thread); } @@ -267,7 +267,7 @@ static void manager_notify(struct etpan_thread_manager * manager) { char ch; ssize_t r; - + ch = 1; r = write(manager->notify_fds[1], &ch, 1); if (r < 0) { @@ -277,16 +277,12 @@ static void manager_notify(struct etpan_thread_manager * manager) static void manager_ack(struct etpan_thread_manager * manager) { -#ifndef G_OS_WIN32 - char ch; - ssize_t r; - r = read(manager->notify_fds[0], &ch, 1); - if (r != 1) { - g_warning("error reading notification from etpan thread manager"); - } -#else - /* done in the GIOChannel handler in imap-thread.c and nntp-thread.c */ -#endif + char ch; + ssize_t r; + r = read(manager->notify_fds[0], &ch, 1); + if (r != 1) { + g_warning("error reading notification from etpan thread manager"); + } } static void thread_lock(struct etpan_thread * thread) @@ -308,17 +304,17 @@ static void * thread_run(void * data) { struct etpan_thread * thread; int r; - + thread = data; - + mailsem_up(thread->start_sem); - + while (1) { int do_quit; struct etpan_thread_op * op; - + mailsem_down(thread->op_sem); - + do_quit = 0; op = NULL; thread_lock(thread); @@ -330,47 +326,47 @@ static void * thread_run(void * data) do_quit = 1; } thread_unlock(thread); - + if (do_quit) { break; } - + if (!etpan_thread_op_cancelled(op)) { if (op->run != NULL) op->run(op); } - + thread_lock(thread); r = carray_add(thread->op_done_list, op, NULL); if (r < 0) { g_warning("complete failure of thread due to lack of memory (op done)"); } thread_unlock(thread); - + thread_notify(thread); } - + thread_lock(thread); thread->terminate_state = TERMINATE_STATE_DONE; thread_unlock(thread); - + thread_notify(thread); - + mailsem_up(thread->stop_sem); - + return NULL; } static int etpan_thread_start(struct etpan_thread * thread) { int r; - + r = pthread_create(&thread->th_id, NULL, thread_run, thread); if (r != 0) return ERROR_MEMORY; - + mailsem_down(thread->start_sem); - + return NO_ERROR; } @@ -379,20 +375,20 @@ static void etpan_thread_stop(struct etpan_thread * thread) thread_lock(thread); thread->terminate_state = TERMINATE_STATE_REQUESTED; thread_unlock(thread); - + mailsem_up(thread->op_sem); - + /* this thread will be joined in the manager loop */ } static int etpan_thread_is_stopped(struct etpan_thread * thread) { int stopped; - + thread_lock(thread); stopped = (thread->terminate_state == TERMINATE_STATE_DONE); thread_unlock(thread); - + return stopped; } @@ -409,57 +405,57 @@ etpan_thread_manager_get_thread(struct etpan_thread_manager * manager) unsigned int chosen_thread_load; unsigned int i; struct etpan_thread * thread; - + /* chose a thread */ - + chosen_thread = NULL; chosen_thread_load = 0; - + for(i = 0 ; i < carray_count(manager->thread_pool) ; i ++) { thread = carray_get(manager->thread_pool, i); if (etpan_thread_is_bound(thread)) continue; - + if (chosen_thread == NULL) { chosen_thread = thread; chosen_thread_load = etpan_thread_get_load(thread); - + if (chosen_thread_load == 0) break; } else { unsigned int load; - + load = etpan_thread_get_load(thread); - + if (load < chosen_thread_load) { chosen_thread = thread; chosen_thread_load = load; } } } - + if (chosen_thread != NULL) { if (manager->can_create_thread && (chosen_thread_load != 0)) { chosen_thread = NULL; } } - + /* choice done */ - + if (chosen_thread != NULL) return chosen_thread; - + thread = etpan_thread_manager_create_thread(manager); if (thread == NULL) goto err; - + manager->unbound_count ++; if (manager->unbound_count >= POOL_UNBOUND_MAX) manager->can_create_thread = 0; - + return thread; - + err: return NULL; } @@ -467,11 +463,11 @@ etpan_thread_manager_get_thread(struct etpan_thread_manager * manager) static unsigned int etpan_thread_get_load(struct etpan_thread * thread) { unsigned int load; - + thread_lock(thread); load = carray_count(thread->op_list); thread_unlock(thread); - + return load; } @@ -496,20 +492,20 @@ int etpan_thread_op_schedule(struct etpan_thread * thread, struct etpan_thread_op * op) { int r; - + if (thread->terminate_state != TERMINATE_STATE_NONE) return ERROR_INVAL; - + thread_lock(thread); r = carray_add(thread->op_list, op, NULL); thread_unlock(thread); - + if (r < 0) return ERROR_MEMORY; - + op->thread = thread; mailsem_up(thread->op_sem); - + return NO_ERROR; } @@ -526,13 +522,13 @@ static void etpan_thread_op_unlock(struct etpan_thread_op * op) static int etpan_thread_op_cancelled(struct etpan_thread_op * op) { int cancelled; - + cancelled = 0; etpan_thread_op_lock(op); if (op->cancellable) cancelled = op->cancelled; etpan_thread_op_unlock(op); - + return cancelled; } @@ -546,18 +542,18 @@ static void loop_thread_list(carray * op_to_notify, { unsigned int i; int r; - + for(i = 0 ; i < carray_count(thread_list) ; i ++) { struct etpan_thread * thread; unsigned int j; - + thread = carray_get(thread_list, i); - + thread_lock(thread); - + for(j = 0 ; j < carray_count(thread->op_done_list) ; j ++) { struct etpan_thread_op * op; - + op = carray_get(thread->op_done_list, j); r = carray_add(op_to_notify, op, NULL); if (r < 0) { @@ -566,7 +562,7 @@ static void loop_thread_list(carray * op_to_notify, } } carray_set_size(thread->op_done_list, 0); - + thread_unlock(thread); } } @@ -575,45 +571,45 @@ void etpan_thread_manager_loop(struct etpan_thread_manager * manager) { carray * op_to_notify; unsigned int i; - + manager_ack(manager); - + op_to_notify = carray_new(OP_INIT_SIZE); - + loop_thread_list(op_to_notify, manager->thread_pool); loop_thread_list(op_to_notify, manager->thread_pending); - + for(i = 0 ; i < carray_count(op_to_notify) ; i ++) { struct etpan_thread_op * op; - + op = carray_get(op_to_notify, i); - + etpan_thread_op_lock(op); - + if (!op->callback_called) { if (op->callback != NULL) op->callback(op->cancelled, op->result, op->callback_data); } - + etpan_thread_op_unlock(op); - + if (op->cleanup != NULL) op->cleanup(op); } - + carray_free(op_to_notify); - + i = 0; while (i < carray_count(manager->thread_pending)) { struct etpan_thread * thread; - + thread = carray_get(manager->thread_pending, i); - + if (etpan_thread_is_stopped(thread)) { etpan_thread_join(thread); - + etpan_thread_free(thread); - + carray_delete_slow(manager->thread_pending, i); } else { @@ -633,7 +629,7 @@ void etpan_thread_manager_stop(struct etpan_thread_manager * manager) { while (carray_count(manager->thread_pool) > 0) { struct etpan_thread * thread; - + thread = carray_get(manager->thread_pool, 0); etpan_thread_manager_terminate_thread(manager, thread); } @@ -641,7 +637,7 @@ void etpan_thread_manager_stop(struct etpan_thread_manager * manager) static int etpan_thread_manager_is_stopped(struct etpan_thread_manager * manager) { - return ((carray_count(manager->thread_pending) == 0) && + return ((carray_count(manager->thread_pending) == 0) && (carray_count(manager->thread_pool) == 0)); } diff --git a/src/etpan/imap-thread.c b/src/etpan/imap-thread.c @@ -30,11 +30,9 @@ #include <sys/types.h> #include <sys/stat.h> #include <fcntl.h> -#ifndef G_OS_WIN32 #include <sys/socket.h> #include <sys/mman.h> #include <sys/wait.h> -#endif #include <gtk/gtk.h> #include <log.h> #include "etpan-thread-manager.h" @@ -147,24 +145,16 @@ static gboolean thread_manager_event(GIOChannel * source, GIOCondition condition, gpointer data) { -#ifdef G_OS_WIN32 - gsize bytes_read; - gchar ch; - - if (condition & G_IO_IN) - g_io_channel_read_chars(source, &ch, 1, &bytes_read, NULL); -#endif etpan_thread_manager_loop(thread_manager); - return TRUE; } -static void imap_logger_noop(int direction, const char * str, size_t size) +static void imap_logger_noop(int direction, const char * str, size_t size) { /* inhibit logging */ } -static void imap_logger_cmd(int direction, const char * str, size_t size) +static void imap_logger_cmd(int direction, const char * str, size_t size) { gchar *buf; gchar **lines; @@ -179,7 +169,7 @@ static void imap_logger_cmd(int direction, const char * str, size_t size) strncpy(buf, str, size); buf[size] = '\0'; - if (!strncmp(buf, "<<<<<<<", 7) + if (!strncmp(buf, "<<<<<<<", 7) || !strncmp(buf, ">>>>>>>", 7)) { free(buf); return; @@ -199,7 +189,7 @@ static void imap_logger_cmd(int direction, const char * str, size_t size) free(buf); } -static void imap_logger_fetch(int direction, const char * str, size_t size) +static void imap_logger_fetch(int direction, const char * str, size_t size) { gchar *buf; gchar **lines; @@ -209,12 +199,12 @@ static void imap_logger_fetch(int direction, const char * str, size_t size) log_print(LOG_PROTOCOL, "IMAP%c [FETCH data - %"G_GSIZE_FORMAT" bytes]\n", direction?'>':'<', size); return; } - + buf = malloc(size+1); memset(buf, 0, size+1); strncpy(buf, str, size); buf[size] = '\0'; - if (!strncmp(buf, "<<<<<<<", 7) + if (!strncmp(buf, "<<<<<<<", 7) || !strncmp(buf, ">>>>>>>", 7)) { free(buf); return; @@ -238,7 +228,7 @@ static void imap_logger_fetch(int direction, const char * str, size_t size) free(buf); } -static void imap_logger_uid(int direction, const char * str, size_t size) +static void imap_logger_uid(int direction, const char * str, size_t size) { gchar *buf; gchar **lines; @@ -252,7 +242,7 @@ static void imap_logger_uid(int direction, const char * str, size_t size) memset(buf, 0, size+1); strncpy(buf, str, size); buf[size] = '\0'; - if (!strncmp(buf, "<<<<<<<", 7) + if (!strncmp(buf, "<<<<<<<", 7) || !strncmp(buf, ">>>>>>>", 7)) { free(buf); return; @@ -280,7 +270,7 @@ static void imap_logger_uid(int direction, const char * str, size_t size) free(buf); } -static void imap_logger_append(int direction, const char * str, size_t size) +static void imap_logger_append(int direction, const char * str, size_t size) { gchar *buf; gchar **lines; @@ -292,12 +282,12 @@ static void imap_logger_append(int direction, const char * str, size_t size) } else if (direction == 0 && size > 64) { log_print(LOG_PROTOCOL, "IMAP%c [APPEND data - %"G_GSIZE_FORMAT" bytes]\n", direction?'>':'<', size); return; - } + } buf = malloc(size+1); memset(buf, 0, size+1); strncpy(buf, str, size); buf[size] = '\0'; - if (!strncmp(buf, "<<<<<<<", 7) + if (!strncmp(buf, "<<<<<<<", 7) || !strncmp(buf, ">>>>>>>", 7)) { free(buf); return; @@ -328,28 +318,24 @@ extern void mailsasl_ref(void); void imap_main_init(gboolean skip_ssl_cert_check) { int fd_thread_manager; - + etpan_skip_ssl_cert_check = skip_ssl_cert_check; mailstream_network_delay.tv_sec = ETPAN_DEFAULT_NETWORK_TIMEOUT; mailstream_network_delay.tv_usec = 0; - + mailstream_debug = 1; mailstream_logger = imap_logger_cmd; mailsasl_ref(); - + imap_hash = chash_new(CHASH_COPYKEY, CHASH_DEFAULTSIZE); session_hash = chash_new(CHASH_COPYKEY, CHASH_DEFAULTSIZE); courier_workaround_hash = chash_new(CHASH_COPYKEY, CHASH_DEFAULTSIZE); - + thread_manager = etpan_thread_manager_new(); - + fd_thread_manager = etpan_thread_manager_get_fd(thread_manager); - -#ifndef G_OS_WIN32 + io_channel = g_io_channel_unix_new(fd_thread_manager); -#else - io_channel = g_io_channel_win32_new_fd(fd_thread_manager); -#endif thread_manager_signal = g_io_add_watch_full(io_channel, 0, G_IO_IN, thread_manager_event, (gpointer) NULL, @@ -370,12 +356,12 @@ void imap_main_done(gboolean have_connectivity) return; #endif etpan_thread_manager_join(thread_manager); - + g_source_remove(thread_manager_signal); g_io_channel_unref(io_channel); - + etpan_thread_manager_free(thread_manager); - + chash_free(courier_workaround_hash); chash_free(session_hash); chash_free(imap_hash); @@ -386,14 +372,14 @@ void imap_init(Folder * folder) struct etpan_thread * thread; chashdatum key; chashdatum value; - + thread = etpan_thread_manager_get_thread(thread_manager); - + key.data = &folder; key.len = sizeof(folder); value.data = thread; value.len = 0; - + chash_set(imap_hash, &key, &value, NULL); } @@ -403,20 +389,20 @@ void imap_done(Folder * folder) chashdatum key; chashdatum value; int r; - + key.data = &folder; key.len = sizeof(folder); - + r = chash_get(imap_hash, &key, &value); if (r < 0) return; - + thread = value.data; - + etpan_thread_unbind(thread); - + chash_delete(imap_hash, &key, NULL); - + debug_print("remove thread\n"); } @@ -445,14 +431,14 @@ static mailimap * get_imap(Folder * folder) chashdatum key; chashdatum value; int r; - + key.data = &folder; key.len = sizeof(folder); - + r = chash_get(session_hash, &key, &value); if (r < 0) return NULL; - + imap = value.data; debug_print("found imap %p\n", imap); return imap; @@ -467,7 +453,7 @@ static gboolean cb_show_error(gpointer data) static void generic_cb(int cancelled, void * result, void * callback_data) { struct etpan_thread_op * op; - + op = (struct etpan_thread_op *) callback_data; debug_print("generic_cb\n"); @@ -476,7 +462,7 @@ static void generic_cb(int cancelled, void * result, void * callback_data) log_error(LOG_PROTOCOL, "IMAP< Alert: %s\n", op->imap->imap_response_info->rsp_alert); g_timeout_add(10, cb_show_error, NULL); - } + } op->finished = 1; } @@ -491,22 +477,22 @@ static int threaded_run(Folder * folder, void * param, void * result, struct etpan_thread_op * op; struct etpan_thread * thread; struct mailimap * imap = get_imap(folder); - + imap_folder_ref(folder); op = etpan_thread_op_new(); - + op->imap = imap; op->param = param; op->result = result; - + op->run = func; op->callback = generic_cb; op->callback_data = op; thread = get_thread(folder); etpan_thread_op_schedule(thread, op); - + while (!op->finished) { gtk_main_iteration(); } @@ -599,15 +585,15 @@ static void connect_run(struct etpan_thread_op * op) int r; struct connect_param * param; struct connect_result * result; - + param = op->param; result = op->result; - + CHECK_IMAP(); r = do_mailimap_socket_connect(param->imap, param->server, param->port, param->proxy_info); - + result->error = r; } @@ -619,16 +605,16 @@ int imap_threaded_connect(Folder * folder, const char * server, int port, ProxyI chashdatum key; chashdatum value; mailimap * imap, * oldimap; - + oldimap = get_imap(folder); imap = mailimap_new(0, NULL); - + if (oldimap) { debug_print("deleting old imap %p\n", oldimap); delete_imap(folder, oldimap); } - + key.data = &folder; key.len = sizeof(folder); value.data = imap; @@ -653,10 +639,10 @@ static void connect_ssl_run(struct etpan_thread_op * op) int r; struct connect_param * param; struct connect_result * result; - + param = op->param; result = op->result; - + CHECK_IMAP(); r = do_mailimap_ssl_connect_with_callback(param->imap, @@ -732,11 +718,11 @@ static void capability_run(struct etpan_thread_op * op) param = op->param; result = op->result; - + CHECK_IMAP(); r = mailimap_capability(param->imap, &caps); - + result->error = r; result->caps = (r == 0 ? caps : NULL); } @@ -747,22 +733,22 @@ int imap_threaded_capability(Folder *folder, struct mailimap_capability_data ** struct capa_param param; struct capa_result result; mailimap *imap; - + imap = get_imap(folder); - + param.imap = imap; - + threaded_run(folder, &param, &result, capability_run); - + debug_print("capa %d\n", result.error); - + if (result.error == MAILIMAP_NO_ERROR) *caps = result.caps; return result.error; - + } - + struct disconnect_param { mailimap * imap; }; @@ -776,14 +762,14 @@ static void disconnect_run(struct etpan_thread_op * op) int r; struct disconnect_param * param; struct disconnect_result * result; - + param = op->param; result = op->result; - + CHECK_IMAP(); r = mailimap_logout(param->imap); - + result->error = r; } @@ -792,22 +778,22 @@ void imap_threaded_disconnect(Folder * folder) struct connect_param param; struct connect_result result; mailimap * imap; - + imap = get_imap(folder); if (imap == NULL) { debug_print("was disconnected\n"); return; } - + param.imap = imap; - + if (threaded_run(folder, &param, &result, disconnect_run)) { debug_print("imap already deleted %p\n", imap); } else { debug_print("deleting old imap %p\n", imap); delete_imap(folder, imap); } - + debug_print("disconnect ok\n"); } @@ -830,14 +816,14 @@ static void list_run(struct etpan_thread_op * op) struct list_result * result; int r; clist * list; - + param = op->param; result = op->result; CHECK_IMAP(); list = NULL; - + if (param->base == NULL || param->wildcard == NULL) { result->list = list; result->error = -1; @@ -861,20 +847,20 @@ int imap_threaded_list(Folder * folder, const char * base, { struct list_param param; struct list_result result; - + debug_print("imap list - begin\n"); - + param.imap = get_imap(folder); param.base = base; param.wildcard = wildcard; param.sub_only = FALSE; threaded_run(folder, &param, &result, list_run); - + * p_result = result.list; - + debug_print("imap list - end %p\n", result.list); - + return result.error; } @@ -884,20 +870,20 @@ int imap_threaded_lsub(Folder * folder, const char * base, { struct list_param param; struct list_result result; - + debug_print("imap lsub - begin\n"); - + param.imap = get_imap(folder); param.base = base; param.wildcard = wildcard; param.sub_only = TRUE; - + threaded_run(folder, &param, &result, list_run); - + * p_result = result.list; - + debug_print("imap lsub - end %p\n", result.list); - + return result.error; } @@ -916,7 +902,7 @@ static void subscribe_run(struct etpan_thread_op * op) struct subscribe_param * param; struct subscribe_result * result; int r; - + param = op->param; result = op->result; @@ -940,15 +926,15 @@ int imap_threaded_subscribe(Folder * folder, const char * mb, { struct subscribe_param param; struct subscribe_result result; - + debug_print("imap list - begin\n"); - + param.imap = get_imap(folder); param.mb = mb; param.subscribe = subscribe; threaded_run(folder, &param, &result, subscribe_run); - + return result.error; } @@ -972,7 +958,7 @@ static void login_run(struct etpan_thread_op * op) #ifdef DISABLE_LOG_DURING_LOGIN int old_debug; #endif - + param = op->param; result = op->result; @@ -1011,7 +997,7 @@ static void login_run(struct etpan_thread_op * op) #ifdef DISABLE_LOG_DURING_LOGIN mailstream_debug = old_debug; #endif - + result->error = r; if (param->imap->imap_response) imap_logger_cmd(0, param->imap->imap_response, strlen(param->imap->imap_response)); @@ -1024,9 +1010,9 @@ int imap_threaded_login(Folder * folder, { struct login_param param; struct login_result result; - + debug_print("imap login - begin\n"); - + if (!folder) return MAILIMAP_ERROR_INVAL; @@ -1040,9 +1026,9 @@ int imap_threaded_login(Folder * folder, param.server = NULL; threaded_run(folder, &param, &result, login_run); - + debug_print("imap login - end\n"); - + return result.error; } @@ -1063,16 +1049,16 @@ static void status_run(struct etpan_thread_op * op) struct status_param * param; struct status_result * result; int r; - + param = op->param; result = op->result; - + CHECK_IMAP(); r = mailimap_status(param->imap, param->mb, param->status_att_list, &result->data_status); - + result->error = r; debug_print("imap status run - end %i\n", r); } @@ -1084,9 +1070,9 @@ int imap_threaded_status(Folder * folder, const char * mb, struct status_param param; struct status_result result; struct mailimap_status_att_list * status_att_list; - + debug_print("imap status - begin\n"); - + status_att_list = mailimap_status_att_list_new_empty(); if (mask & 1 << 0) { mailimap_status_att_list_add(status_att_list, @@ -1111,15 +1097,15 @@ int imap_threaded_status(Folder * folder, const char * mb, param.imap = get_imap(folder); param.mb = mb; param.status_att_list = status_att_list; - + threaded_run(folder, &param, &result, status_run); - + debug_print("imap status - end\n"); - + * data_status = result.data_status; - + mailimap_status_att_list_free(status_att_list); - + return result.error; } @@ -1138,20 +1124,20 @@ static void noop_run(struct etpan_thread_op * op) struct noop_param * param; struct noop_result * result; int r; - + param = op->param; result = op->result; CHECK_IMAP(); r = mailimap_noop(param->imap); - + result->error = r; debug_print("imap noop run - end %i\n", r); } -int imap_threaded_noop(Folder * folder, unsigned int * p_exists, - unsigned int *p_recent, +int imap_threaded_noop(Folder * folder, unsigned int * p_exists, + unsigned int *p_recent, unsigned int *p_expunge, unsigned int *p_unseen, unsigned int *p_uidnext, @@ -1160,9 +1146,9 @@ int imap_threaded_noop(Folder * folder, unsigned int * p_exists, struct noop_param param; struct noop_result result; mailimap * imap; - + debug_print("imap noop - begin\n"); - + imap = get_imap(folder); param.imap = imap; @@ -1187,11 +1173,11 @@ int imap_threaded_noop(Folder * folder, unsigned int * p_exists, * p_expunge = clist_count(imap->imap_response_info->rsp_expunged); } else { * p_expunge = 0; - } + } debug_print("imap noop - end [EXISTS %d RECENT %d EXPUNGE %d UNSEEN %d UIDNEXT %d UIDVAL %d]\n", *p_exists, *p_recent, *p_expunge, *p_unseen, *p_uidnext, *p_uidval); - + return result.error; } @@ -1212,16 +1198,16 @@ static void starttls_run(struct etpan_thread_op * op) CHECK_IMAP(); r = mailimap_starttls(param->imap); - + result->error = r; debug_print("imap STARTTLS run - end %i\n", r); - + if (r == 0) { mailimap *imap = param->imap; mailstream_low *plain_low = NULL; mailstream_low *tls_low = NULL; int fd = -1; - + plain_low = mailstream_get_low(imap->imap_stream); fd = mailstream_low_get_fd(plain_low); if (fd == -1) { @@ -1266,7 +1252,7 @@ int imap_threaded_starttls(Folder * folder, const gchar *host, int port) if (etpan_certificate_check(param.imap->imap_stream, host, port, accept_if_valid) != TRUE) return MAILIMAP_ERROR_SSL; - } + } return result.error; } #endif @@ -1285,14 +1271,14 @@ static void create_run(struct etpan_thread_op * op) struct create_param * param; struct create_result * result; int r; - + param = op->param; result = op->result; CHECK_IMAP(); r = mailimap_create(param->imap, param->mb); - + result->error = r; debug_print("imap create run - end %i\n", r); } @@ -1301,16 +1287,16 @@ int imap_threaded_create(Folder * folder, const char * mb) { struct create_param param; struct create_result result; - + debug_print("imap create - begin\n"); - + param.imap = get_imap(folder); param.mb = mb; - + threaded_run(folder, &param, &result, create_run); - + debug_print("imap create - end\n"); - + return result.error; } @@ -1332,14 +1318,14 @@ static void rename_run(struct etpan_thread_op * op) struct rename_param * param; struct rename_result * result; int r; - + param = op->param; result = op->result; CHECK_IMAP(); r = mailimap_rename(param->imap, param->mb, param->new_name); - + result->error = r; debug_print("imap rename run - end %i\n", r); } @@ -1349,17 +1335,17 @@ int imap_threaded_rename(Folder * folder, { struct rename_param param; struct rename_result result; - + debug_print("imap rename - begin\n"); - + param.imap = get_imap(folder); param.mb = mb; param.new_name = new_name; - + threaded_run(folder, &param, &result, rename_run); - + debug_print("imap rename - end\n"); - + return result.error; } @@ -1380,14 +1366,14 @@ static void delete_run(struct etpan_thread_op * op) struct delete_param * param; struct delete_result * result; int r; - + param = op->param; result = op->result; CHECK_IMAP(); r = mailimap_delete(param->imap, param->mb); - + result->error = r; debug_print("imap delete run - end %i\n", r); } @@ -1396,16 +1382,16 @@ int imap_threaded_delete(Folder * folder, const char * mb) { struct delete_param param; struct delete_result result; - + debug_print("imap delete - begin\n"); - + param.imap = get_imap(folder); param.mb = mb; - + threaded_run(folder, &param, &result, delete_run); - + debug_print("imap delete - end\n"); - + return result.error; } @@ -1425,14 +1411,14 @@ static void select_run(struct etpan_thread_op * op) struct select_param * param; struct select_result * result; int r; - + param = op->param; result = op->result; CHECK_IMAP(); r = mailimap_select(param->imap, param->mb); - + result->error = r; debug_print("imap select run - end %i\n", r); } @@ -1447,20 +1433,20 @@ int imap_threaded_select(Folder * folder, const char * mb, mailimap * imap; debug_print("imap select - begin\n"); - + imap = get_imap(folder); param.imap = imap; param.mb = mb; - + if (threaded_run(folder, &param, &result, select_run)) return MAILIMAP_ERROR_INVAL; if (result.error != MAILIMAP_NO_ERROR) return result.error; - + if (!imap || imap->imap_selection_info == NULL) return MAILIMAP_ERROR_PARSE; - + * exists = imap->imap_selection_info->sel_exists; * recent = imap->imap_selection_info->sel_recent; * unseen = imap->imap_selection_info->sel_unseen; @@ -1477,10 +1463,10 @@ int imap_threaded_select(Folder * folder, const char * mb, struct mailimap_flag_perm *flag = (struct mailimap_flag_perm *)clist_content(cur); if (flag->fl_type == MAILIMAP_FLAG_PERM_ALL) *can_create_flags = TRUE; - else if (flag->fl_flag && + else if (flag->fl_flag && flag->fl_flag->fl_type == 6 && !strcmp(flag->fl_flag->fl_data.fl_extension, "*")) - *can_create_flags = TRUE; + *can_create_flags = TRUE; if (flag->fl_flag && ok_flags) { MsgPermFlags c_flag = 0; switch (flag->fl_flag->fl_type) { @@ -1513,7 +1499,7 @@ int imap_threaded_select(Folder * folder, const char * mb, break; } if (c_flag != 0) { - t_flags = g_slist_prepend(t_flags, + t_flags = g_slist_prepend(t_flags, GUINT_TO_POINTER(c_flag)); } } @@ -1522,7 +1508,7 @@ int imap_threaded_select(Folder * folder, const char * mb, *ok_flags = t_flags; } debug_print("imap select - end\n"); - + return result.error; } @@ -1531,14 +1517,14 @@ static void close_run(struct etpan_thread_op * op) struct select_param * param; struct select_result * result; int r; - + param = op->param; result = op->result; CHECK_IMAP(); r = mailimap_close(param->imap); - + result->error = r; debug_print("imap close run - end %i\n", r); } @@ -1548,19 +1534,19 @@ int imap_threaded_close(Folder * folder) struct select_param param; struct select_result result; mailimap * imap; - + debug_print("imap close - begin\n"); - + imap = get_imap(folder); param.imap = imap; - + threaded_run(folder, &param, &result, close_run); - + if (result.error != MAILIMAP_NO_ERROR) return result.error; - + debug_print("imap close - end\n"); - + return result.error; } @@ -1578,14 +1564,14 @@ static void examine_run(struct etpan_thread_op * op) struct examine_param * param; struct examine_result * result; int r; - + param = op->param; result = op->result; CHECK_IMAP(); r = mailimap_examine(param->imap, param->mb); - + result->error = r; debug_print("imap examine run - end %i\n", r); } @@ -1597,29 +1583,29 @@ int imap_threaded_examine(Folder * folder, const char * mb, struct examine_param param; struct examine_result result; mailimap * imap; - + debug_print("imap examine - begin\n"); - + imap = get_imap(folder); param.imap = imap; param.mb = mb; - + if (threaded_run(folder, &param, &result, examine_run)) return MAILIMAP_ERROR_INVAL; if (result.error != MAILIMAP_NO_ERROR) return result.error; - + if (!imap || imap->imap_selection_info == NULL) return MAILIMAP_ERROR_PARSE; - + * exists = imap->imap_selection_info->sel_exists; * recent = imap->imap_selection_info->sel_recent; * unseen = imap->imap_selection_info->sel_unseen; * uid_validity = imap->imap_selection_info->sel_uidvalidity; - + debug_print("imap examine - end\n"); - + return result.error; } @@ -1718,7 +1704,7 @@ static void search_run(struct etpan_thread_op * op) search_type_key = param->key; break; } - + if (search_type_key != NULL) { if (param->set != NULL) { key = mailimap_search_key_new_multiple_empty(); @@ -1730,7 +1716,7 @@ static void search_run(struct etpan_thread_op * op) } else if (uid_key != NULL) { key = uid_key; } - + if (key == NULL) { g_warning("no key!"); result = op->result; @@ -1759,7 +1745,7 @@ int imap_threaded_search(Folder * folder, int search_type, IMAPSearchKey* key, struct search_param param; struct search_result result; mailimap * imap; - + debug_print("imap search - begin\n"); imap = get_imap(folder); @@ -1770,14 +1756,14 @@ int imap_threaded_search(Folder * folder, int search_type, IMAPSearchKey* key, param.key = key; threaded_run(folder, &param, &result, search_run); - + if (result.error != MAILIMAP_NO_ERROR) return result.error; - + debug_print("imap search - end\n"); - + * search_result = result.search_result; - + return result.error; } @@ -1786,7 +1772,7 @@ struct _IMAPSearchKey { struct mailimap_search_key* key; }; -IMAPSearchKey* imap_search_new(gint criteria, +IMAPSearchKey* imap_search_new(gint criteria, const gchar *header, const gchar *expr, int value) @@ -1950,13 +1936,13 @@ result_to_uid_list(clist * fetch_result, carray ** result) int r; int res; carray * tab; - + tab = carray_new(128); if (tab == NULL) { res = MAILIMAP_ERROR_MEMORY; goto err; } - + if (fetch_result) cur = clist_begin(fetch_result); @@ -1964,19 +1950,19 @@ result_to_uid_list(clist * fetch_result, carray ** result) struct mailimap_msg_att * msg_att; uint32_t uid; uint32_t * puid; - + msg_att = clist_content(cur); - + uid = 0; imap_get_msg_att_info(msg_att, &uid, NULL, NULL, NULL); - + puid = malloc(sizeof(* puid)); if (puid == NULL) { res = MAILIMAP_ERROR_MEMORY; goto free_list; } * puid = uid; - + r = carray_add(tab, puid, NULL); if (r < 0) { free(puid); @@ -1984,11 +1970,11 @@ result_to_uid_list(clist * fetch_result, carray ** result) goto free_list; } } - + * result = tab; return MAILIMAP_NO_ERROR; - + free_list: imap_fetch_uid_list_free(tab); err: @@ -2006,7 +1992,7 @@ static int imap_get_messages_list(mailimap * imap, struct mailimap_set * set; clist * fetch_result; int res; - + set = mailimap_set_new_interval(first_index, 0); if (set == NULL) { res = MAILIMAP_ERROR_MEMORY; @@ -2033,7 +2019,7 @@ static int imap_get_messages_list(mailimap * imap, } mailstream_logger = imap_logger_fetch; - + r = mailimap_uid_fetch(imap, set, fetch_type, &fetch_result); @@ -2049,7 +2035,7 @@ static int imap_get_messages_list(mailimap * imap, env_list = NULL; r = result_to_uid_list(fetch_result, &env_list); mailimap_fetch_list_free(fetch_result); - + * result = env_list; return MAILIMAP_NO_ERROR; @@ -2081,7 +2067,7 @@ static void fetch_uid_run(struct etpan_thread_op * op) struct fetch_uid_result * result; carray * fetch_result; int r; - + param = op->param; result = op->result; @@ -2093,7 +2079,7 @@ static void fetch_uid_run(struct etpan_thread_op * op) r = imap_get_messages_list(param->imap, param->first_index, &fetch_result); - + mailstream_logger = imap_logger_cmd; result->error = r; @@ -2107,22 +2093,22 @@ int imap_threaded_fetch_uid(Folder * folder, uint32_t first_index, struct fetch_uid_param param; struct fetch_uid_result result; mailimap * imap; - + debug_print("imap fetch_uid - begin\n"); - + imap = get_imap(folder); param.imap = imap; param.first_index = first_index; - + threaded_run(folder, &param, &result, fetch_uid_run); - + if (result.error != MAILIMAP_NO_ERROR) return result.error; - + debug_print("imap fetch_uid - end\n"); - + * fetch_result = result.fetch_result; - + return result.error; } @@ -2130,10 +2116,10 @@ int imap_threaded_fetch_uid(Folder * folder, uint32_t first_index, void imap_fetch_uid_list_free(carray * uid_list) { unsigned int i; - + for(i = 0 ; i < carray_count(uid_list) ; i ++) { uint32_t * puid; - + puid = carray_get(uid_list, i); free(puid); } @@ -2170,11 +2156,11 @@ result_to_uid_flags_list(clist * fetch_result, carray ** result) struct mailimap_msg_att_dynamic * att_dyn; int flags; int * pflags; - + tags = NULL; msg_att = clist_content(cur); - + uid = 0; att_dyn = NULL; imap_get_msg_att_info(msg_att, &uid, NULL, NULL, &att_dyn); @@ -2182,16 +2168,16 @@ result_to_uid_flags_list(clist * fetch_result, carray ** result) continue; if (att_dyn == NULL) continue; - + flags = imap_flags_to_flags(att_dyn, &tags); - + puid = malloc(sizeof(* puid)); if (puid == NULL) { res = MAILIMAP_ERROR_MEMORY; goto free_list; } * puid = uid; - + r = carray_add(tab, puid, NULL); if (r < 0) { free(puid); @@ -2217,11 +2203,11 @@ result_to_uid_flags_list(clist * fetch_result, carray ** result) goto free_list; } } - + * result = tab; return MAILIMAP_NO_ERROR; - + free_list: imap_fetch_uid_flags_list_free(tab); slist_free_strings_full(tags); @@ -2240,7 +2226,7 @@ static int imap_get_messages_flags_list(mailimap * imap, struct mailimap_set * set; clist * fetch_result; int res; - + set = mailimap_set_new_interval(first_index, 0); if (set == NULL) { res = MAILIMAP_ERROR_MEMORY; @@ -2258,14 +2244,14 @@ static int imap_get_messages_flags_list(mailimap * imap, res = MAILIMAP_ERROR_MEMORY; goto free_fetch_type; } - + r = mailimap_fetch_type_new_fetch_att_list_add(fetch_type, fetch_att); if (r != MAILIMAP_NO_ERROR) { mailimap_fetch_att_free(fetch_att); res = MAILIMAP_ERROR_MEMORY; goto free_fetch_type; } - + fetch_att = mailimap_fetch_att_new_uid(); if (fetch_att == NULL) { res = MAILIMAP_ERROR_MEMORY; @@ -2280,7 +2266,7 @@ static int imap_get_messages_flags_list(mailimap * imap, } mailstream_logger = imap_logger_fetch; - + r = mailimap_uid_fetch(imap, set, fetch_type, &fetch_result); @@ -2296,7 +2282,7 @@ static int imap_get_messages_flags_list(mailimap * imap, env_list = NULL; r = result_to_uid_flags_list(fetch_result, &env_list); mailimap_fetch_list_free(fetch_result); - + * result = env_list; return MAILIMAP_NO_ERROR; @@ -2317,7 +2303,7 @@ static void fetch_uid_flags_run(struct etpan_thread_op * op) struct fetch_uid_result * result; carray * fetch_result; int r; - + param = op->param; result = op->result; @@ -2326,7 +2312,7 @@ static void fetch_uid_flags_run(struct etpan_thread_op * op) fetch_result = NULL; r = imap_get_messages_flags_list(param->imap, param->first_index, &fetch_result); - + result->error = r; result->fetch_result = fetch_result; debug_print("imap fetch_uid run - end %i\n", r); @@ -2338,13 +2324,13 @@ int imap_threaded_fetch_uid_flags(Folder * folder, uint32_t first_index, struct fetch_uid_param param; struct fetch_uid_result result; mailimap * imap; - + debug_print("imap fetch_uid - begin\n"); - + imap = get_imap(folder); param.imap = imap; param.first_index = first_index; - + mailstream_logger = imap_logger_noop; log_print(LOG_PROTOCOL, "IMAP- [fetching flags...]\n"); @@ -2352,14 +2338,14 @@ int imap_threaded_fetch_uid_flags(Folder * folder, uint32_t first_index, mailstream_logger = imap_logger_cmd; - + if (result.error != MAILIMAP_NO_ERROR) return result.error; - + debug_print("imap fetch_uid - end\n"); - + * fetch_result = result.fetch_result; - + return result.error; } @@ -2367,10 +2353,10 @@ int imap_threaded_fetch_uid_flags(Folder * folder, uint32_t first_index, void imap_fetch_uid_flags_list_free(carray * uid_flags_list) { unsigned int i; - + for(i = 0 ; i < carray_count(uid_flags_list) ; i += 3) { void * data; - + data = carray_get(uid_flags_list, i); free(data); data = carray_get(uid_flags_list, i + 1); @@ -2410,14 +2396,14 @@ static int imap_fetch(mailimap * imap, res = MAILIMAP_ERROR_MEMORY; goto free_set; } - + fetch_att = mailimap_fetch_att_new_body_peek_section(section); if (fetch_att == NULL) { mailimap_section_free(section); res = MAILIMAP_ERROR_MEMORY; goto free_set; } - + fetch_type = mailimap_fetch_type_new_fetch_att(fetch_att); if (fetch_type == NULL) { res = MAILIMAP_ERROR_MEMORY; @@ -2425,22 +2411,22 @@ static int imap_fetch(mailimap * imap, } mailstream_logger = imap_logger_fetch; - + r = mailimap_uid_fetch(imap, set, fetch_type, &fetch_result); - + mailstream_logger = imap_logger_cmd; - + mailimap_fetch_type_free(fetch_type); mailimap_set_free(set); - + switch (r) { case MAILIMAP_NO_ERROR: break; default: return r; } - + if (fetch_result == NULL || clist_begin(fetch_result) == NULL) { mailimap_fetch_list_free(fetch_result); return MAILIMAP_ERROR_FETCH; @@ -2478,7 +2464,7 @@ static int imap_fetch(mailimap * imap, * result = text; * result_len = text_length; - + return MAILIMAP_NO_ERROR; free_fetch_att: @@ -2506,7 +2492,7 @@ static int imap_fetch_header(mailimap * imap, int res; clistiter * cur; struct mailimap_section * section; - + set = mailimap_set_new_single(msg_index); if (set == NULL) { res = MAILIMAP_ERROR_MEMORY; @@ -2518,14 +2504,14 @@ static int imap_fetch_header(mailimap * imap, res = MAILIMAP_ERROR_MEMORY; goto free_set; } - + fetch_att = mailimap_fetch_att_new_body_peek_section(section); if (fetch_att == NULL) { mailimap_section_free(section); res = MAILIMAP_ERROR_MEMORY; goto free_set; } - + fetch_type = mailimap_fetch_type_new_fetch_att(fetch_att); if (fetch_type == NULL) { res = MAILIMAP_ERROR_MEMORY; @@ -2533,9 +2519,9 @@ static int imap_fetch_header(mailimap * imap, } mailstream_logger = imap_logger_fetch; - + r = mailimap_uid_fetch(imap, set, fetch_type, &fetch_result); - + mailstream_logger = imap_logger_cmd; mailimap_fetch_type_free(fetch_type); mailimap_set_free(set); @@ -2616,7 +2602,7 @@ static void fetch_content_run(struct etpan_thread_op * op) int r; int fd; FILE * f; - + param = op->param; result = op->result; @@ -2630,34 +2616,34 @@ static void fetch_content_run(struct etpan_thread_op * op) else r = imap_fetch_header(param->imap, param->msg_index, &content, &content_size); - + result->error = r; - + if (r == MAILIMAP_NO_ERROR) { fd = g_open(param->filename, O_RDWR | O_CREAT, 0600); if (fd < 0) { result->error = MAILIMAP_ERROR_FETCH; goto free; } - + f = fdopen(fd, "wb"); if (f == NULL) { result->error = MAILIMAP_ERROR_FETCH; goto close; } - + r = fwrite(content, 1, content_size, f); if (r < content_size) { result->error = MAILIMAP_ERROR_FETCH; goto do_fclose; } - + if (safe_fclose(f) == EOF) { result->error = MAILIMAP_ERROR_FETCH; goto unlink; } goto free; - + do_fclose: fclose(f); goto unlink; @@ -2666,14 +2652,14 @@ static void fetch_content_run(struct etpan_thread_op * op) unlink: if (unlink(param->filename) < 0) FILE_OP_ERROR(param->filename, "unlink"); - + free: /* mmap_string_unref is a simple free in libetpan * when it has MMAP_UNAVAILABLE defined */ if (mmap_string_unref(content) != 0) free(content); } - + debug_print("imap fetch_content run - end %i\n", result->error); } @@ -2684,22 +2670,22 @@ int imap_threaded_fetch_content(Folder * folder, uint32_t msg_index, struct fetch_content_param param; struct fetch_content_result result; mailimap * imap; - + debug_print("imap fetch_content - begin\n"); - + imap = get_imap(folder); param.imap = imap; param.msg_index = msg_index; param.filename = filename; param.with_body = with_body; - + threaded_run(folder, &param, &result, fetch_content_run); - + if (result.error != MAILIMAP_NO_ERROR) return result.error; - + debug_print("imap fetch_content - end\n"); - + return result.error; } @@ -2713,15 +2699,15 @@ static int imap_flags_to_flags(struct mailimap_msg_att_dynamic * att_dyn, GSList GSList *tags = NULL; flags = MSG_UNREAD; - + flag_list = att_dyn->att_list; if (flag_list == NULL) return flags; - + for(cur = clist_begin(flag_list) ; cur != NULL ; cur = clist_next(cur)) { struct mailimap_flag_fetch * flag_fetch; - + flag_fetch = clist_content(cur); if (flag_fetch->fl_type == MAILIMAP_FLAG_FETCH_RECENT) flags |= MSG_NEW; @@ -2743,11 +2729,11 @@ static int imap_flags_to_flags(struct mailimap_msg_att_dynamic * att_dyn, GSList case MAILIMAP_FLAG_KEYWORD: if (!strcasecmp(flag_fetch->fl_flag->fl_data.fl_keyword, RTAG_FORWARDED)) flags |= MSG_FORWARDED; - else if (!strcasecmp(flag_fetch->fl_flag->fl_data.fl_keyword, RTAG_JUNK)) + else if (!strcasecmp(flag_fetch->fl_flag->fl_data.fl_keyword, RTAG_JUNK)) flags |= MSG_SPAM; else if (!strcasecmp(flag_fetch->fl_flag->fl_data.fl_keyword, RTAG_NON_JUNK) || !strcasecmp(flag_fetch->fl_flag->fl_data.fl_keyword, RTAG_NO_JUNK) || - !strcasecmp(flag_fetch->fl_flag->fl_data.fl_keyword, RTAG_NOT_JUNK)) + !strcasecmp(flag_fetch->fl_flag->fl_data.fl_keyword, RTAG_NOT_JUNK)) flags &= ~MSG_SPAM; else if (s_tags) tags = g_slist_prepend(tags, g_strdup(flag_fetch->fl_flag->fl_data.fl_keyword)); @@ -2785,7 +2771,7 @@ static int imap_get_msg_att_info(struct mailimap_msg_att * msg_att, struct mailimap_msg_att_item * item; item = clist_content(item_cur); - + switch (item->att_type) { case MAILIMAP_MSG_ATT_ITEM_STATIC: switch (item->att_data.att_static->att_type) { @@ -2803,7 +2789,7 @@ static int imap_get_msg_att_info(struct mailimap_msg_att * msg_att, break; } break; - + case MAILIMAP_MSG_ATT_ITEM_DYNAMIC: if (att_dyn == NULL) { att_dyn = item->att_data.att_dyn; @@ -2835,7 +2821,7 @@ fetch_to_env_info(struct mailimap_msg_att * msg_att, GSList **tags) imap_get_msg_att_info(msg_att, &uid, &headers, &size, &att_dyn); - + if (!headers) return NULL; info = malloc(sizeof(* info)); @@ -2843,7 +2829,7 @@ fetch_to_env_info(struct mailimap_msg_att * msg_att, GSList **tags) info->headers = strdup(headers); info->size = size; info->flags = imap_flags_to_flags(att_dyn, tags); - + return info; } @@ -2919,11 +2905,11 @@ static int imap_add_header_fetch_att(struct mailimap_fetch_type * fetch_type) { struct mailimap_fetch_att * fetch_att; struct mailimap_section * section; - + section = mailimap_section_new_header(); fetch_att = mailimap_fetch_att_new_body_peek_section(section); mailimap_fetch_type_new_fetch_att_list_add(fetch_type, fetch_att); - + return MAIL_NO_ERROR; } @@ -2939,21 +2925,21 @@ imap_get_envelopes_list(mailimap * imap, struct mailimap_set * set, carray * env_list = NULL; chashdatum key; chashdatum value; - + fetch_type = mailimap_fetch_type_new_fetch_att_list_empty(); - + /* uid */ fetch_att = mailimap_fetch_att_new_uid(); r = mailimap_fetch_type_new_fetch_att_list_add(fetch_type, fetch_att); - + /* flags */ fetch_att = mailimap_fetch_att_new_flags(); r = mailimap_fetch_type_new_fetch_att_list_add(fetch_type, fetch_att); - + /* rfc822 size */ fetch_att = mailimap_fetch_att_new_rfc822_size(); r = mailimap_fetch_type_new_fetch_att_list_add(fetch_type, fetch_att); - + /* headers */ key.data = &imap; key.len = sizeof(imap); @@ -2969,9 +2955,9 @@ imap_get_envelopes_list(mailimap * imap, struct mailimap_set * set, } mailstream_logger = imap_logger_fetch; - + r = mailimap_uid_fetch(imap, set, fetch_type, &fetch_result); - + mailstream_logger = imap_logger_cmd; switch (r) { case MAILIMAP_NO_ERROR: @@ -2981,29 +2967,29 @@ imap_get_envelopes_list(mailimap * imap, struct mailimap_set * set, debug_print("uid_fetch: %d\n", r); return r; } - + if (fetch_result == NULL || clist_begin(fetch_result) == NULL) { res = MAILIMAP_ERROR_FETCH; debug_print("clist_begin = NULL\n"); goto err; } - + r = imap_fetch_result_to_envelop_list(fetch_result, &env_list); mailimap_fetch_list_free(fetch_result); - + if (r != MAILIMAP_NO_ERROR) { mailimap_fetch_type_free(fetch_type); res = MAILIMAP_ERROR_MEMORY; debug_print("fetch_result_to_envelop_list: %d\n", res); goto err; } - + mailimap_fetch_type_free(fetch_type); - + * p_env_list = env_list; - + return MAILIMAP_NO_ERROR; - + err: return res; } @@ -3024,7 +3010,7 @@ static void fetch_env_run(struct etpan_thread_op * op) struct fetch_env_result * result; carray * env_list; int r; - + param = op->param; result = op->result; @@ -3033,10 +3019,10 @@ static void fetch_env_run(struct etpan_thread_op * op) env_list = NULL; r = imap_get_envelopes_list(param->imap, param->set, &env_list); - + result->error = r; result->fetch_env_result = env_list; - + debug_print("imap fetch_env run - end %i\n", r); } @@ -3046,13 +3032,13 @@ int imap_threaded_fetch_env(Folder * folder, struct mailimap_set * set, struct fetch_env_param param; struct fetch_env_result result; mailimap * imap; - + debug_print("imap fetch_env - begin\n"); - + imap = get_imap(folder); param.imap = imap; param.set = set; - + if (threaded_run(folder, &param, &result, fetch_env_run)) return MAILIMAP_ERROR_INVAL; @@ -3060,7 +3046,7 @@ int imap_threaded_fetch_env(Folder * folder, struct mailimap_set * set, chashdatum key; chashdatum value; int r; - + key.data = &imap; key.len = sizeof(imap); r = chash_get(courier_workaround_hash, &key, &value); @@ -3068,28 +3054,28 @@ int imap_threaded_fetch_env(Folder * folder, struct mailimap_set * set, value.data = NULL; value.len = 0; chash_set(courier_workaround_hash, &key, &value, NULL); - + threaded_run(folder, &param, &result, fetch_env_run); } } - + if (result.error != MAILIMAP_NO_ERROR) return result.error; - + debug_print("imap fetch_env - end\n"); - + * p_env_list = result.fetch_env_result; - + return result.error; } void imap_fetch_env_free(carray * env_list) { unsigned int i; - + for(i = 0 ; i < carray_count(env_list) ; i += 2) { struct imap_fetch_env_info * env_info; - + env_info = carray_get(env_list, i); free(env_info->headers); free(env_info); @@ -3120,60 +3106,46 @@ static void append_run(struct etpan_thread_op * op) int r; char * data; size_t size; -#ifndef G_OS_WIN32 struct stat stat_buf; int fd; -#endif guint32 uid = 0, val = 0; - + param = op->param; result = op->result; - + CHECK_IMAP(); -#ifndef G_OS_WIN32 r = stat(param->filename, &stat_buf); if (r < 0) { result->error = MAILIMAP_ERROR_APPEND; return; } size = stat_buf.st_size; - + fd = g_open(param->filename, O_RDONLY, 0); if (fd < 0) { result->error = MAILIMAP_ERROR_APPEND; return; } - + data = mmap(NULL, size, PROT_READ, MAP_PRIVATE, fd, 0); if (data == (void *) MAP_FAILED) { close(fd); result->error = MAILIMAP_ERROR_APPEND; return; } -#else - data = file_read_to_str_no_recode(param->filename); - if (data == NULL) { - result->error = MAILIMAP_ERROR_APPEND; - return; - } - size = strlen(data); -#endif + mailstream_logger = imap_logger_append; - + r = mailimap_uidplus_append(param->imap, param->mailbox, param->flag_list, NULL, data, size, &val, &uid); mailstream_logger = imap_logger_cmd; - -#ifndef G_OS_WIN32 + munmap(data, size); close(fd); -#else - g_free(data); -#endif - + result->error = r; result->uid = uid; debug_print("imap append run - end %i uid %d\n", r, uid); @@ -3187,20 +3159,20 @@ int imap_threaded_append(Folder * folder, const char * mailbox, struct append_param param; struct append_result result; mailimap * imap; - + debug_print("imap append - begin\n"); - + imap = get_imap(folder); param.imap = imap; param.mailbox = mailbox; param.filename = filename; param.flag_list = flag_list; - + threaded_run(folder, &param, &result, append_run); - + if (result.error != MAILIMAP_NO_ERROR) return result.error; - + debug_print("imap append - end\n"); if (uid != NULL) *uid = result.uid; @@ -3224,14 +3196,14 @@ static void expunge_run(struct etpan_thread_op * op) struct expunge_param * param; struct expunge_result * result; int r; - + param = op->param; result = op->result; CHECK_IMAP(); r = mailimap_expunge(param->imap); - + result->error = r; debug_print("imap expunge run - end %i\n", r); } @@ -3240,15 +3212,15 @@ int imap_threaded_expunge(Folder * folder) { struct expunge_param param; struct expunge_result result; - + debug_print("imap expunge - begin\n"); - + param.imap = get_imap(folder); - + threaded_run(folder, &param, &result, expunge_run); - + debug_print("imap expunge - end\n"); - + return result.error; } @@ -3280,7 +3252,7 @@ static void copy_run(struct etpan_thread_op * op) r = mailimap_uidplus_uid_copy(param->imap, param->set, param->mb, &val, &source, &dest); - + result->error = r; if (r == 0) { result->source = source; @@ -3299,26 +3271,26 @@ int imap_threaded_copy(Folder * folder, struct mailimap_set * set, struct copy_param param; struct copy_result result; mailimap * imap; - + debug_print("imap copy - begin\n"); - + imap = get_imap(folder); param.imap = imap; param.set = set; param.mb = mb; - + threaded_run(folder, &param, &result, copy_run); *source = NULL; *dest = NULL; - + if (result.error != MAILIMAP_NO_ERROR) return result.error; - + *source = result.source; *dest = result.dest; debug_print("imap copy - end\n"); - + return result.error; } @@ -3339,7 +3311,7 @@ static void store_run(struct etpan_thread_op * op) struct store_param * param; struct store_result * result; int r; - + param = op->param; result = op->result; @@ -3347,9 +3319,9 @@ static void store_run(struct etpan_thread_op * op) r = mailimap_uid_store(param->imap, param->set, param->store_att_flags); - + result->error = r; - + debug_print("imap store run - end %i\n", r); } @@ -3359,64 +3331,62 @@ int imap_threaded_store(Folder * folder, struct mailimap_set * set, struct store_param param; struct store_result result; mailimap * imap; - + debug_print("imap store - begin\n"); - + imap = get_imap(folder); param.imap = imap; param.set = set; param.store_att_flags = store_att_flags; - + threaded_run(folder, &param, &result, store_run); - + if (result.error != MAILIMAP_NO_ERROR) return result.error; - + debug_print("imap store - end\n"); - + return result.error; } - -#ifndef G_OS_WIN32 static void do_exec_command(int fd, const char * command, const char * servername, uint16_t port) { int i, maxopen; - + if (fork() > 0) { /* Fork again to become a child of init rather than the etpan client. */ exit(0); } - + if (servername) g_setenv("ETPANSERVER", servername, TRUE); else g_unsetenv("ETPANSERVER"); - + if (port) { char porttext[20]; - + snprintf(porttext, sizeof(porttext), "%d", port); g_setenv("ETPANPORT", porttext, TRUE); } else { g_unsetenv("ETPANPORT"); } - + /* Not a lot we can do if there's an error other than bail. */ if (dup2(fd, 0) == -1) exit(1); if (dup2(fd, 1) == -1) exit(1); - + /* Should we close stderr and reopen /dev/null? */ - + maxopen = sysconf(_SC_OPEN_MAX); for (i=3; i < maxopen; i++) close(i); - + #ifdef TIOCNOTTY /* Detach from the controlling tty if we have one. Otherwise, SSH might do something stupid like trying to use it instead @@ -3429,7 +3399,7 @@ static void do_exec_command(int fd, const char * command, #endif /* TIOCNOTTY */ execl("/bin/sh", "/bin/sh", "-c", command, NULL); - + /* Eep. Shouldn't reach this */ exit(1); } @@ -3440,10 +3410,10 @@ static int subcommand_connect(const char *command, /* SEB unsupported on Windows */ int sockfds[2]; pid_t childpid; - + if (socketpair(AF_UNIX, SOCK_STREAM, 0, sockfds)) return -1; - + childpid = fork(); if (!childpid) { do_exec_command(sockfds[1], command, servername, port); @@ -3453,12 +3423,12 @@ static int subcommand_connect(const char *command, close(sockfds[1]); return -1; } - + close(sockfds[1]); - + /* Reap child, leaving grandchild process to run */ waitpid(childpid, NULL, 0); - + return sockfds[0]; } @@ -3468,17 +3438,17 @@ static int socket_connect_cmd(mailimap * imap, const char * command, int fd; mailstream * s; int r; - + fd = subcommand_connect(command, server, port); if (fd < 0) return MAILIMAP_ERROR_STREAM; - + s = mailstream_socket_open(fd); if (s == NULL) { close(fd); return MAILIMAP_ERROR_STREAM; } - + r = mailimap_connect(imap, s); if (r != MAILIMAP_NO_ERROR_AUTHENTICATED && r != MAILIMAP_NO_ERROR_NON_AUTHENTICATED) { @@ -3487,7 +3457,7 @@ static int socket_connect_cmd(mailimap * imap, const char * command, imap->imap_stream = NULL; return r; } - + return r; } @@ -3509,15 +3479,15 @@ static void connect_cmd_run(struct etpan_thread_op * op) int r; struct connect_cmd_param * param; struct connect_cmd_result * result; - + param = op->param; result = op->result; - + CHECK_IMAP(); r = socket_connect_cmd(param->imap, param->command, param->server, param->port); - + result->error = r; } @@ -3530,11 +3500,11 @@ int imap_threaded_connect_cmd(Folder * folder, const char * command, chashdatum key; chashdatum value; mailimap * imap, * oldimap; - + oldimap = get_imap(folder); imap = mailimap_new(0, NULL); - + if (oldimap) { debug_print("deleting old imap %p\n", oldimap); delete_imap(folder, oldimap); @@ -3545,24 +3515,23 @@ int imap_threaded_connect_cmd(Folder * folder, const char * command, value.data = imap; value.len = 0; chash_set(session_hash, &key, &value, NULL); - + param.imap = imap; param.command = command; param.server = server; param.port = port; - + threaded_run(folder, &param, &result, connect_cmd_run); - + debug_print("connect_cmd ok %i with imap %p\n", result.error, imap); - + return result.error; } -#endif /* G_OS_WIN32 */ void imap_threaded_cancel(Folder * folder) { mailimap * imap; - + imap = get_imap(folder); if (imap && imap->imap_stream != NULL) mailstream_cancel(imap->imap_stream); diff --git a/src/etpan/imap-thread.h b/src/etpan/imap-thread.h @@ -14,7 +14,7 @@ * * You should have received a copy of the GNU General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. - * + * */ #ifndef IMAP_THREAD_H @@ -47,10 +47,8 @@ int imap_threaded_connect(Folder * folder, const char * server, int port, ProxyI int imap_threaded_connect_ssl(Folder * folder, const char * server, int port, ProxyInfo *proxy_info); int imap_threaded_capability(Folder *folder, struct mailimap_capability_data ** caps); -#ifndef G_OS_WIN32 int imap_threaded_connect_cmd(Folder * folder, const char * command, const char * server, int port); -#endif void imap_threaded_disconnect(Folder * folder); int imap_threaded_list(Folder * folder, const char * base, @@ -67,8 +65,8 @@ int imap_threaded_status(Folder * folder, const char * mb, guint mask); int imap_threaded_close(Folder * folder); -int imap_threaded_noop(Folder * folder, unsigned int * p_exists, - unsigned int *p_recent, +int imap_threaded_noop(Folder * folder, unsigned int * p_exists, + unsigned int *p_recent, unsigned int *p_expunge, unsigned int *p_unseen, unsigned int *p_uidnext, @@ -125,7 +123,7 @@ enum { IMAP_SEARCH_CRITERIA_SIZE_SMALLER, }; -IMAPSearchKey* imap_search_new(gint criteria, +IMAPSearchKey* imap_search_new(gint criteria, const gchar *header, const gchar *expr, int value); diff --git a/src/etpan/nntp-thread.c b/src/etpan/nntp-thread.c @@ -30,10 +30,8 @@ #include <sys/types.h> #include <sys/stat.h> #include <fcntl.h> -#ifndef G_OS_WIN32 #include <sys/mman.h> #include <sys/wait.h> -#endif #include <gtk/gtk.h> #include <log.h> #include "etpan-thread-manager.h" @@ -137,7 +135,7 @@ static int do_newsnntp_ssl_connect_with_callback(newsnntp * imap, const char * s } #endif -static void nntp_logger(int direction, const char * str, size_t size) +static void nntp_logger(int direction, const char * str, size_t size) { gchar *buf; gchar **lines; @@ -152,7 +150,7 @@ static void nntp_logger(int direction, const char * str, size_t size) strncpy(buf, str, size); buf[size] = '\0'; - if (!strncmp(buf, "<<<<<<<", 7) + if (!strncmp(buf, "<<<<<<<", 7) || !strncmp(buf, ">>>>>>>", 7)) { free(buf); return; @@ -179,7 +177,7 @@ static void delete_nntp(Folder *folder, newsnntp *nntp) key.data = &folder; key.len = sizeof(folder); chash_delete(session_hash, &key, NULL); - + key.data = &nntp; key.len = sizeof(nntp); if (nntp && nntp->nntp_stream) { @@ -188,22 +186,14 @@ static void delete_nntp(Folder *folder, newsnntp *nntp) nntp->nntp_stream = NULL; } debug_print("removing newsnntp %p\n", nntp); - newsnntp_free(nntp); + newsnntp_free(nntp); } static gboolean thread_manager_event(GIOChannel * source, GIOCondition condition, gpointer data) { -#ifdef G_OS_WIN32 - gsize bytes_read; - gchar ch; - - if (condition & G_IO_IN) - g_io_channel_read_chars(source, &ch, 1, &bytes_read, NULL); -#endif etpan_thread_manager_loop(thread_manager); - return TRUE; } @@ -213,22 +203,18 @@ extern gboolean etpan_skip_ssl_cert_check; void nntp_main_init(gboolean skip_ssl_cert_check) { int fd_thread_manager; - + etpan_skip_ssl_cert_check = skip_ssl_cert_check; - + nntp_hash = chash_new(CHASH_COPYKEY, CHASH_DEFAULTSIZE); session_hash = chash_new(CHASH_COPYKEY, CHASH_DEFAULTSIZE); - + thread_manager = etpan_thread_manager_new(); - + fd_thread_manager = etpan_thread_manager_get_fd(thread_manager); - -#ifndef G_OS_WIN32 + io_channel = g_io_channel_unix_new(fd_thread_manager); -#else - io_channel = g_io_channel_win32_new_fd(fd_thread_manager); -#endif - + thread_manager_signal = g_io_add_watch_full(io_channel, 0, G_IO_IN, thread_manager_event, (gpointer) NULL, @@ -243,12 +229,12 @@ void nntp_main_done(gboolean have_connectivity) return; #endif etpan_thread_manager_join(thread_manager); - + g_source_remove(thread_manager_signal); g_io_channel_unref(io_channel); - + etpan_thread_manager_free(thread_manager); - + chash_free(session_hash); chash_free(nntp_hash); } @@ -258,14 +244,14 @@ void nntp_init(Folder * folder) struct etpan_thread * thread; chashdatum key; chashdatum value; - + thread = etpan_thread_manager_get_thread(thread_manager); - + key.data = &folder; key.len = sizeof(folder); value.data = thread; value.len = 0; - + chash_set(nntp_hash, &key, &value, NULL); } @@ -275,20 +261,20 @@ void nntp_done(Folder * folder) chashdatum key; chashdatum value; int r; - + key.data = &folder; key.len = sizeof(folder); - + r = chash_get(nntp_hash, &key, &value); if (r < 0) return; - + thread = value.data; - + etpan_thread_unbind(thread); - + chash_delete(nntp_hash, &key, NULL); - + debug_print("remove thread\n"); } @@ -317,14 +303,14 @@ static newsnntp * get_nntp(Folder * folder) chashdatum key; chashdatum value; int r; - + key.data = &folder; key.len = sizeof(folder); - + r = chash_get(session_hash, &key, &value); if (r < 0) return NULL; - + nntp = value.data; debug_print("found nntp %p\n", nntp); return nntp; @@ -334,7 +320,7 @@ static newsnntp * get_nntp(Folder * folder) static void generic_cb(int cancelled, void * result, void * callback_data) { struct etpan_thread_op * op; - + op = (struct etpan_thread_op *) callback_data; debug_print("generic_cb\n"); @@ -352,7 +338,7 @@ static void threaded_run(Folder * folder, void * param, void * result, nntp_folder_ref(folder); op = etpan_thread_op_new(); - + op->nntp = get_nntp(folder); op->param = param; op->result = result; @@ -360,17 +346,17 @@ static void threaded_run(Folder * folder, void * param, void * result, op->run = func; op->callback = generic_cb; op->callback_data = op; - + previous_stream_logger = mailstream_logger; mailstream_logger = nntp_logger; thread = get_thread(folder); etpan_thread_op_schedule(thread, op); - + while (!op->finished) { gtk_main_iteration(); } - + mailstream_logger = previous_stream_logger; etpan_thread_op_free(op); @@ -405,16 +391,16 @@ static void connect_run(struct etpan_thread_op * op) int r; struct connect_param * param; struct connect_result * result; - + param = op->param; result = op->result; - + CHECK_NNTP(); r = do_newsnntp_socket_connect(param->nntp, param->server, param->port, param->proxy_info); - + result->error = r; } @@ -426,22 +412,22 @@ int nntp_threaded_connect(Folder * folder, const char * server, int port, ProxyI chashdatum key; chashdatum value; newsnntp * nntp, * oldnntp; - + oldnntp = get_nntp(folder); nntp = newsnntp_new(0, NULL); - + if (oldnntp) { debug_print("deleting old nntp %p\n", oldnntp); delete_nntp(folder, oldnntp); } - + key.data = &folder; key.len = sizeof(folder); value.data = nntp; value.len = 0; chash_set(session_hash, &key, &value, NULL); - + param.nntp = nntp; param.server = server; param.port = port; @@ -449,9 +435,9 @@ int nntp_threaded_connect(Folder * folder, const char * server, int port, ProxyI refresh_resolvers(); threaded_run(folder, &param, &result, connect_run); - + debug_print("connect ok %i with nntp %p\n", result.error, nntp); - + return result.error; } #ifdef USE_GNUTLS @@ -460,10 +446,10 @@ static void connect_ssl_run(struct etpan_thread_op * op) int r; struct connect_param * param; struct connect_result * result; - + param = op->param; result = op->result; - + CHECK_NNTP(); r = do_newsnntp_ssl_connect_with_callback(param->nntp, @@ -515,7 +501,7 @@ int nntp_threaded_connect_ssl(Folder * folder, const char * server, int port, Pr return -1; } debug_print("connect %d with nntp %p\n", result.error, nntp); - + return result.error; } #endif @@ -523,23 +509,23 @@ int nntp_threaded_connect_ssl(Folder * folder, const char * server, int port, Pr void nntp_threaded_disconnect(Folder * folder) { newsnntp * nntp; - + nntp = get_nntp(folder); if (nntp == NULL) { debug_print("was disconnected\n"); return; } - + debug_print("deleting old nntp %p\n", nntp); delete_nntp(folder, nntp); - + debug_print("disconnect ok\n"); } void nntp_threaded_cancel(Folder * folder) { newsnntp * nntp; - + nntp = get_nntp(folder); if (nntp->nntp_stream != NULL) mailstream_cancel(nntp->nntp_stream); @@ -564,7 +550,7 @@ static void login_run(struct etpan_thread_op * op) #ifdef DISABLE_LOG_DURING_LOGIN int old_debug; #endif - + param = op->param; result = op->result; @@ -581,13 +567,13 @@ static void login_run(struct etpan_thread_op * op) if (r == NEWSNNTP_WARNING_REQUEST_AUTHORIZATION_PASSWORD) { r = newsnntp_authinfo_password(param->nntp, param->password); } - + #ifdef DISABLE_LOG_DURING_LOGIN mailstream_debug = old_debug; #endif - + result->error = r; if (param->nntp->nntp_response) nntp_logger(0, param->nntp->nntp_response, strlen(param->nntp->nntp_response)); @@ -599,17 +585,17 @@ int nntp_threaded_login(Folder * folder, const char * login, const char * passwo { struct login_param param; struct login_result result; - + debug_print("nntp login - begin\n"); - + param.nntp = get_nntp(folder); param.login = login; param.password = password; threaded_run(folder, &param, &result, login_run); - + debug_print("nntp login - end\n"); - + return result.error; } @@ -627,14 +613,14 @@ static void date_run(struct etpan_thread_op * op) struct date_param * param; struct date_result * result; int r; - + param = op->param; result = op->result; CHECK_NNTP(); r = newsnntp_date(param->nntp, param->lt); - + result->error = r; debug_print("nntp date run - end %i\n", r); } @@ -643,16 +629,16 @@ int nntp_threaded_date(Folder * folder, struct tm *lt) { struct date_param param; struct date_result result; - + debug_print("nntp date - begin\n"); - + param.nntp = get_nntp(folder); param.lt = lt; threaded_run(folder, &param, &result, date_run); - + debug_print("nntp date - end\n"); - + return result.error; } @@ -670,14 +656,14 @@ static void list_run(struct etpan_thread_op * op) struct list_param * param; struct list_result * result; int r; - + param = op->param; result = op->result; CHECK_NNTP(); r = newsnntp_list(param->nntp, param->grouplist); - + result->error = r; debug_print("nntp list run - end %i\n", r); } @@ -686,16 +672,16 @@ int nntp_threaded_list(Folder * folder, clist **grouplist) { struct list_param param; struct list_result result; - + debug_print("nntp list - begin\n"); - + param.nntp = get_nntp(folder); param.grouplist = grouplist; threaded_run(folder, &param, &result, list_run); - + debug_print("nntp list - end\n"); - + return result.error; } @@ -714,14 +700,14 @@ static void post_run(struct etpan_thread_op * op) struct post_param * param; struct post_result * result; int r; - + param = op->param; result = op->result; CHECK_NNTP(); r = newsnntp_post(param->nntp, param->contents, param->len); - + result->error = r; debug_print("nntp post run - end %i\n", r); } @@ -730,17 +716,17 @@ int nntp_threaded_post(Folder * folder, char *contents, size_t len) { struct post_param param; struct post_result result; - + debug_print("nntp post - begin\n"); - + param.nntp = get_nntp(folder); param.contents = contents; param.len = len; threaded_run(folder, &param, &result, post_run); - + debug_print("nntp post - end\n"); - + return result.error; } @@ -760,14 +746,14 @@ static void article_run(struct etpan_thread_op * op) struct article_param * param; struct article_result * result; int r; - + param = op->param; result = op->result; CHECK_NNTP(); r = newsnntp_article(param->nntp, param->num, param->contents, param->len); - + result->error = r; debug_print("nntp article run - end %i\n", r); } @@ -776,18 +762,18 @@ int nntp_threaded_article(Folder * folder, guint32 num, char **contents, size_t { struct article_param param; struct article_result result; - + debug_print("nntp article - begin\n"); - + param.nntp = get_nntp(folder); param.num = num; param.contents = contents; param.len = len; threaded_run(folder, &param, &result, article_run); - + debug_print("nntp article - end\n"); - + return result.error; } @@ -806,14 +792,14 @@ static void group_run(struct etpan_thread_op * op) struct group_param * param; struct group_result * result; int r; - + param = op->param; result = op->result; CHECK_NNTP(); r = newsnntp_group(param->nntp, param->group, param->info); - + result->error = r; debug_print("nntp group run - end %i\n", r); } @@ -822,17 +808,17 @@ int nntp_threaded_group(Folder * folder, const char *group, struct newsnntp_grou { struct group_param param; struct group_result result; - + debug_print("nntp group - begin\n"); - + param.nntp = get_nntp(folder); param.group = group; param.info = info; threaded_run(folder, &param, &result, group_run); - + debug_print("nntp group - end\n"); - + return result.error; } @@ -849,14 +835,14 @@ static void mode_reader_run(struct etpan_thread_op * op) struct mode_reader_param * param; struct mode_reader_result * result; int r; - + param = op->param; result = op->result; CHECK_NNTP(); r = newsnntp_mode_reader(param->nntp); - + result->error = r; debug_print("nntp mode_reader run - end %i\n", r); } @@ -865,15 +851,15 @@ int nntp_threaded_mode_reader(Folder * folder) { struct mode_reader_param param; struct mode_reader_result result; - + debug_print("nntp mode_reader - begin\n"); - + param.nntp = get_nntp(folder); threaded_run(folder, &param, &result, mode_reader_run); - + debug_print("nntp mode_reader - end\n"); - + return result.error; } @@ -894,18 +880,18 @@ static void xover_run(struct etpan_thread_op * op) struct xover_param * param; struct xover_result * result; int r; - + param = op->param; result = op->result; CHECK_NNTP(); - + if (param->result) { r = newsnntp_xover_single(param->nntp, param->beg, param->result); } else { r = newsnntp_xover_range(param->nntp, param->beg, param->end, param->msglist); } - + result->error = r; debug_print("nntp xover run %d-%d - end %i\n", param->beg, param->end, r); @@ -966,7 +952,7 @@ int nntp_threaded_xover(Folder * folder, guint32 beg, guint32 end, struct newsnn } statusbar_progress_all(0, 0, 0); - + debug_print("nntp xover - end\n"); *multiple_result = h; @@ -991,18 +977,18 @@ static void xhdr_run(struct etpan_thread_op * op) struct xhdr_param * param; struct xhdr_result * result; int r; - + param = op->param; result = op->result; CHECK_NNTP(); - + if (param->beg == param->end) { r = newsnntp_xhdr_single(param->nntp, param->header, param->beg, param->hdrlist); } else { r = newsnntp_xhdr_range(param->nntp, param->header, param->beg, param->end, param->hdrlist); } - + result->error = r; debug_print("nntp xhdr '%s %d-%d' run - end %i\n", param->header, param->beg, param->end, r); @@ -1065,7 +1051,7 @@ int nntp_threaded_xhdr(Folder * folder, const char *header, guint32 beg, guint32 } statusbar_progress_all(0, 0, 0); - + debug_print("nntp xhdr %s - end (%d-%d)\n", header, beg, end); *hdrlist = h; diff --git a/src/filtering.c b/src/filtering.c @@ -1185,9 +1185,7 @@ gboolean filtering_action_list_rename_path(GSList *action_list, const gchar *old GSList * action_cur; const gchar *separator=G_DIR_SEPARATOR_S; gboolean matched = FALSE; -#ifdef G_OS_WIN32 -again: -#endif + oldpathlen = strlen(old_path); old_path_with_sep = g_strconcat(old_path,separator,NULL); @@ -1248,12 +1246,6 @@ again: } g_free(old_path_with_sep); -#ifdef G_OS_WIN32 - if (!strcmp(separator, G_DIR_SEPARATOR_S) && !matched) { - separator = "/"; - goto again; - } -#endif return matched; } diff --git a/src/folder.c b/src/folder.c @@ -65,17 +65,10 @@ /* Dependecies to be removed ?! */ #include "prefs_account.h" -/* Define possible missing constants for Windows. */ -#ifdef G_OS_WIN32 -# ifndef S_IRGRP -# define S_IRGRP 0 -# define S_IWGRP 0 -# endif # ifndef S_IROTH # define S_IROTH 0 # define S_IWOTH 0 # endif -#endif static GList *folder_list = NULL; static GSList *class_list = NULL; @@ -4057,11 +4050,6 @@ static gchar *folder_item_get_tags_file(FolderItem *item) identifier = folder_item_get_identifier(item); cm_return_val_if_fail(identifier != NULL, NULL); -#ifdef G_OS_WIN32 - while (strchr(identifier, '/')) - *strchr(identifier, '/') = '\\'; -#endif - path = g_strconcat(get_rc_dir(), G_DIR_SEPARATOR_S, TAGS_DIR, G_DIR_SEPARATOR_S, identifier, NULL); @@ -4866,16 +4854,5 @@ gint folder_item_search_msgs_local (Folder *folder, /* Tests if a local (on disk) folder name is acceptable. */ gboolean folder_local_name_ok(const gchar *name) { -#ifdef G_OS_WIN32 - if (name[0] == '.' || name[strlen(name) - 1] == '.') { - alertpanel_error(_("A folder name cannot begin or end with a dot.")); - return FALSE; - } - if (name[strlen(name) - 1] == ' ') { - alertpanel_error(_("A folder name can not end with a space.")); - return FALSE; - } -#endif - return TRUE; } diff --git a/src/gtk/Makefile.am b/src/gtk/Makefile.am @@ -10,18 +10,12 @@ noinst_LTLIBRARIES = libclawsgtk.la EXTRA_DIST = \ claws-marshal.list -if OS_WIN32 -arch_sources = w32_filesel.c -else -arch_sources = filesel.c -endif - libclawsgtk_la_SOURCES = \ about.c \ colorlabel.c \ combobox.c \ description_window.c \ - $(arch_sources) \ + filesel.c \ foldersort.c \ gtkaspell.c \ gtkcmctree.c \ diff --git a/src/gtk/description_window.c b/src/gtk/description_window.c @@ -52,11 +52,7 @@ void description_window_create(DescriptionWindow *dwindow) gtk_window_set_transient_for(GTK_WINDOW(dwindow->window), GTK_WINDOW(dwindow->parent)); dwindow->parent_modal = gtk_window_get_modal(GTK_WINDOW(dwindow->parent)); -#ifndef G_OS_WIN32 gtk_window_set_modal(GTK_WINDOW(dwindow->parent), TRUE); -#else - gtk_window_set_modal(GTK_WINDOW(dwindow->window), TRUE); -#endif gtk_window_set_destroy_with_parent(GTK_WINDOW(dwindow->window), TRUE); gtk_widget_show(dwindow->window); diff --git a/src/gtk/gtkutils.c b/src/gtk/gtkutils.c @@ -1406,12 +1406,7 @@ claws_io_invoke (GIOChannel *source, gpointer data) { ClawsIOClosure *closure = data; - int fd; -#ifndef G_OS_WIN32 - fd = g_io_channel_unix_get_fd (source); -#else - fd = g_io_channel_win32_get_fd (source); -#endif + int fd = g_io_channel_unix_get_fd (source); if (closure->condition & condition) closure->function (closure->data, fd, condition); @@ -1445,14 +1440,7 @@ claws_input_add (gint source, closure->notify = NULL; closure->data = data; -#ifndef G_OS_WIN32 channel = g_io_channel_unix_new (source); -#else - if (is_sock) - channel = g_io_channel_win32_new_socket(source); - else - channel = g_io_channel_win32_new_fd(source); -#endif result = g_io_add_watch_full (channel, G_PRIORITY_DEFAULT, condition, claws_io_invoke, closure, claws_io_destroy); diff --git a/src/gtk/w32_filesel.c b/src/gtk/w32_filesel.c @@ -1,499 +0,0 @@ -/* - * Claws Mail -- a GTK based, lightweight, and fast e-mail client - * Copyright (C) 2016 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 - * the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see <http://www.gnu.org/licenses/>. - * - */ - -#ifdef HAVE_CONFIG_H -# include "config.h" -#endif - -#define UNICODE -#define _UNICODE - -#include <glib.h> -#include <glib/gi18n.h> -#include <gdk/gdkwin32.h> - -#include <windows.h> -#include <shlobj.h> - -#include "claws.h" -#include "alertpanel.h" -#include "manage_window.h" -#include "utils.h" - -static OPENFILENAME o; -static BROWSEINFO b; - -/* Since running the native dialogs in the same thread stops GTK - * loop from redrawing other windows on the background, we need - * to run the dialogs in a separate thread. */ - -/* TODO: There's a lot of code repeat in this file, it could be - * refactored to be neater. */ - -struct _WinChooserCtx { - void *data; - gboolean return_value; - PIDLIST_ABSOLUTE return_value_pidl; - gboolean done; -}; - -typedef struct _WinChooserCtx WinChooserCtx; - -static void *threaded_GetOpenFileName(void *arg) -{ - WinChooserCtx *ctx = (WinChooserCtx *)arg; - - g_return_val_if_fail(ctx != NULL, NULL); - g_return_val_if_fail(ctx->data != NULL, NULL); - - ctx->return_value = GetOpenFileName(ctx->data); - ctx->done = TRUE; - - return NULL; -} - -static void *threaded_GetSaveFileName(void *arg) -{ - WinChooserCtx *ctx = (WinChooserCtx *)arg; - - g_return_val_if_fail(ctx != NULL, NULL); - g_return_val_if_fail(ctx->data != NULL, NULL); - - ctx->return_value = GetSaveFileName(ctx->data); - ctx->done = TRUE; - - return NULL; -} - -static void *threaded_SHBrowseForFolder(void *arg) -{ - WinChooserCtx *ctx = (WinChooserCtx *)arg; - - g_return_val_if_fail(ctx != NULL, NULL); - g_return_val_if_fail(ctx->data != NULL, NULL); - - ctx->return_value_pidl = SHBrowseForFolder(ctx->data); - - ctx->done = TRUE; - - return NULL; -} - -/* This function handles calling GetOpenFilename(), using - * global static variable o. - * It expects o.lpstrFile to point to an already allocated buffer, - * of size at least MAXPATHLEN. */ -static const gboolean _file_open_dialog(const gchar *path, const gchar *title, - const gchar *filter, const gboolean multi) -{ - gboolean ret; - gunichar2 *path16 = NULL; - gunichar2 *title16 = NULL; - gunichar2 *filter16 = NULL; - gunichar2 *win_filter16 = NULL; - glong conv_items, sz; - GError *error = NULL; - WinChooserCtx *ctx; - - /* Path needs to be converted to UTF-16, so that the native chooser - * can understand it. */ - path16 = g_utf8_to_utf16(path ? path : "", - -1, NULL, NULL, &error); - if (error != NULL) { - alertpanel_error(_("Could not convert file path to UTF-16:\n\n%s"), - error->message); - debug_print("file path '%s' conversion to UTF-16 failed\n", path); - g_error_free(error); - error = NULL; - return FALSE; - } - - /* Chooser dialog title needs to be UTF-16 as well. */ - title16 = g_utf8_to_utf16(title ? title : "", - -1, NULL, NULL, &error); - if (error != NULL) { - debug_print("dialog title '%s' conversion to UTF-16 failed\n", title); - g_error_free(error); - error = NULL; - } - - o.lStructSize = sizeof(OPENFILENAME); - if (focus_window != NULL) - o.hwndOwner = GDK_WINDOW_HWND(gtk_widget_get_window(focus_window)); - else - o.hwndOwner = NULL; - o.hInstance = NULL; - o.lpstrFilter = NULL; - o.lpstrCustomFilter = NULL; - o.nFilterIndex = 0; - o.nMaxFile = MAXPATHLEN; - o.lpstrFileTitle = NULL; - o.lpstrInitialDir = path16; - o.lpstrTitle = title16; - if (multi) - o.Flags = OFN_LONGNAMES | OFN_EXPLORER | OFN_ALLOWMULTISELECT; - else - o.Flags = OFN_LONGNAMES | OFN_EXPLORER; - - if (filter != NULL && strlen(filter) > 0) { - debug_print("Setting filter '%s'\n", filter); - filter16 = g_utf8_to_utf16(filter, -1, NULL, &conv_items, &error); - /* We're creating a UTF16 (2 bytes for each character) string: - * "filter\0filter\0\0" - * As g_utf8_to_utf16() will stop on first null byte, even if - * we pass string length in its second argument, we have to - * construct this string manually. - * conv_items contains number of UTF16 characters of our filter. - * Therefore we need enough bytes to store the filter string twice - * and three null chars. */ - sz = sizeof(gunichar2); - win_filter16 = g_malloc0(conv_items*sz*2 + sz*3); - memcpy(win_filter16, filter16, conv_items*sz); - memcpy(win_filter16 + conv_items + 1, filter16, conv_items*sz); - g_free(filter16); - - if (error != NULL) { - debug_print("dialog title '%s' conversion to UTF-16 failed\n", title); - g_error_free(error); - error = NULL; - } - o.lpstrFilter = (LPCTSTR)win_filter16; - o.nFilterIndex = 1; - } - - ctx = g_new0(WinChooserCtx, 1); - ctx->data = &o; - ctx->done = FALSE; - - ret = GetOpenFileName(&o); - - g_free(win_filter16); - if (path16 != NULL) { - g_free(path16); - } - g_free(title16); - g_free(ctx); - - return ret; -} - -gchar *filesel_select_file_open_with_filter(const gchar *title, const gchar *path, - const gchar *filter) -{ - gchar *str = NULL; - GError *error = NULL; - - o.lpstrFile = g_malloc0(MAXPATHLEN); - if (!_file_open_dialog(path, title, filter, FALSE)) { - g_free(o.lpstrFile); - return NULL; - } - - /* Now convert the returned file path back from UTF-16. */ - str = g_utf16_to_utf8(o.lpstrFile, o.nMaxFile, NULL, NULL, &error); - if (error != NULL) { - alertpanel_error(_("Could not convert file path back to UTF-8:\n\n%s"), - error->message); - debug_print("returned file path conversion to UTF-8 failed\n"); - g_error_free(error); - } - - g_free(o.lpstrFile); - return str; -} - -GList *filesel_select_multiple_files_open_with_filter(const gchar *title, - const gchar *path, const gchar *filter) -{ - GList *file_list = NULL; - gchar *str = NULL; - gchar *dir = NULL; - gunichar2 *f; - GError *error = NULL; - glong n, items_read; - - o.lpstrFile = g_malloc0(MAXPATHLEN); - if (!_file_open_dialog(path, title, filter, TRUE)) { - g_free(o.lpstrFile); - return NULL; - } - - /* Now convert the returned directory and file names back from UTF-16. - * The content of o.lpstrFile is: - * "directory0file0file0...0file00" for multiple files selected, - * "fullfilepath0" for single file. */ - str = g_utf16_to_utf8(o.lpstrFile, -1, &items_read, NULL, &error); - - if (error != NULL) { - alertpanel_error(_("Could not convert file path back to UTF-8:\n\n%s"), - error->message); - debug_print("returned file path conversion to UTF-8 failed\n"); - g_error_free(error); - return NULL; - } - - /* The part before the first null char is always a full path. If it is - * a path to a file, then only this one file has been selected, - * and we can bail out early. */ - if (g_file_test(str, G_FILE_TEST_IS_REGULAR)) { - debug_print("Selected one file: '%s'\n", str); - file_list = g_list_append(file_list, g_strdup(str)); - g_free(str); - return file_list; - } - - /* So the path was to a directory. We need to parse more after - * the fist null char, until we get to two null chars in a row. */ - dir = g_strdup(str); - g_free(str); - debug_print("Selected multiple files in dir '%s'\n", dir); - - n = items_read + 1; - f = &o.lpstrFile[n]; - while (items_read > 0) { - str = g_utf16_to_utf8(f, -1, &items_read, NULL, &error); - if (error != NULL) { - alertpanel_error(_("Could not convert file path back to UTF-8:\n\n%s"), - error->message); - debug_print("returned file path conversion to UTF-8 failed\n"); - g_error_free(error); - g_free(o.lpstrFile); - return NULL; - } - - if (items_read > 0) { - debug_print("selected file '%s'\n", str); - file_list = g_list_append(file_list, - g_strconcat(dir, G_DIR_SEPARATOR_S, str, NULL)); - } - g_free(str); - - n += items_read + 1; - f = &o.lpstrFile[n]; - } - - g_free(o.lpstrFile); - return file_list; -} - -gchar *filesel_select_file_open(const gchar *title, const gchar *path) -{ - return filesel_select_file_open_with_filter(title, path, NULL); -} - -GList *filesel_select_multiple_files_open(const gchar *title, const gchar *path) -{ - return filesel_select_multiple_files_open_with_filter(title, path, NULL); -} - -gchar *filesel_select_file_save(const gchar *title, const gchar *path) -{ - gboolean ret; - gchar *str, *filename = NULL; - gunichar2 *filename16, *path16, *title16; - glong conv_items; - GError *error = NULL; - WinChooserCtx *ctx; - - /* Find the filename part, if any */ - if (path == NULL || path[strlen(path)-1] == G_DIR_SEPARATOR) { - filename = ""; - } else if ((filename = strrchr(path, G_DIR_SEPARATOR)) != NULL) { - filename++; - } else { - filename = (char *) path; - } - - /* Convert it to UTF-16. */ - filename16 = g_utf8_to_utf16(filename, -1, NULL, &conv_items, &error); - if (error != NULL) { - alertpanel_error(_("Could not convert attachment name to UTF-16:\n\n%s"), - error->message); - debug_print("filename '%s' conversion to UTF-16 failed\n", filename); - g_error_free(error); - return NULL; - } - - /* Path needs to be converted to UTF-16, so that the native chooser - * can understand it. */ - path16 = g_utf8_to_utf16(path, -1, NULL, NULL, &error); - if (error != NULL) { - alertpanel_error(_("Could not convert file path to UTF-16:\n\n%s"), - error->message); - debug_print("file path '%s' conversion to UTF-16 failed\n", path); - g_error_free(error); - g_free(filename16); - return NULL; - } - - /* Chooser dialog title needs to be UTF-16 as well. */ - title16 = g_utf8_to_utf16(title, -1, NULL, NULL, &error); - if (error != NULL) { - debug_print("dialog title '%s' conversion to UTF-16 failed\n", title); - g_error_free(error); - } - - o.lStructSize = sizeof(OPENFILENAME); - if (focus_window != NULL) - o.hwndOwner = GDK_WINDOW_HWND(gtk_widget_get_window(focus_window)); - else - o.hwndOwner = NULL; - o.lpstrFilter = NULL; - o.lpstrCustomFilter = NULL; - o.lpstrFile = g_malloc0(MAXPATHLEN); - if (path16 != NULL) - memcpy(o.lpstrFile, filename16, conv_items * sizeof(gunichar2)); - o.nMaxFile = MAXPATHLEN; - o.lpstrFileTitle = NULL; - o.lpstrInitialDir = path16; - o.lpstrTitle = title16; - o.Flags = OFN_LONGNAMES | OFN_EXPLORER; - - ctx = g_new0(WinChooserCtx, 1); - ctx->data = &o; - ctx->return_value = FALSE; - ctx->done = FALSE; - - ret = GetSaveFileName(&o); - - g_free(filename16); - g_free(path16); - g_free(title16); - g_free(ctx); - - if (!ret) { - g_free(o.lpstrFile); - return NULL; - } - - /* Now convert the returned file path back from UTF-16. */ - str = g_utf16_to_utf8(o.lpstrFile, o.nMaxFile, NULL, NULL, &error); - if (error != NULL) { - alertpanel_error(_("Could not convert file path back to UTF-8:\n\n%s"), - error->message); - debug_print("returned file path conversion to UTF-8 failed\n"); - g_error_free(error); - } - - g_free(o.lpstrFile); - return str; -} - -/* This callback function is used to set the folder browse dialog - * selection from filesel_select_file_open_folder() to set - * chosen starting folder ("path" argument to that function. */ -static int CALLBACK _open_folder_callback(HWND hwnd, UINT uMsg, - LPARAM lParam, LPARAM lpData) -{ - if (uMsg != BFFM_INITIALIZED) - return 0; - - SendMessage(hwnd, BFFM_SETSELECTION, TRUE, lpData); - return 0; -} - -gchar *filesel_select_file_open_folder(const gchar *title, const gchar *path) -{ - PIDLIST_ABSOLUTE pidl; - gchar *str; - gunichar2 *path16, *title16; - glong conv_items; - GError *error = NULL; - WinChooserCtx *ctx; - - /* Path needs to be converted to UTF-16, so that the native chooser - * can understand it. */ - path16 = g_utf8_to_utf16(path ? path : "", - -1, NULL, &conv_items, &error); - if (error != NULL) { - alertpanel_error(_("Could not convert file path to UTF-16:\n\n%s"), - error->message); - debug_print("file path '%s' conversion to UTF-16 failed\n", path); - g_error_free(error); - return NULL; - } - - /* Chooser dialog title needs to be UTF-16 as well. */ - title16 = g_utf8_to_utf16(title ? title : "", - -1, NULL, NULL, &error); - if (error != NULL) { - debug_print("dialog title '%s' conversion to UTF-16 failed\n", title); - g_error_free(error); - } - - if (focus_window != NULL) - b.hwndOwner = GDK_WINDOW_HWND(gtk_widget_get_window(focus_window)); - else - b.hwndOwner = NULL; - b.pszDisplayName = g_malloc(MAXPATHLEN); - b.lpszTitle = title16; - b.ulFlags = 0; - b.pidlRoot = NULL; - b.lpfn = _open_folder_callback; - b.lParam = (LPARAM)path16; - - CoInitialize(NULL); - - ctx = g_new0(WinChooserCtx, 1); - ctx->data = &b; - ctx->done = FALSE; - pidl = SHBrowseForFolder(&b); - - g_free(b.pszDisplayName); - g_free(title16); - g_free(path16); - - if (pidl == NULL) { - CoUninitialize(); - g_free(ctx); - return NULL; - } - - path16 = malloc(MAX_PATH); - if (!SHGetPathFromIDList(pidl, path16)) { - CoTaskMemFree(pidl); - CoUninitialize(); - g_free(path16); - g_free(ctx); - return NULL; - } - - /* Now convert the returned file path back from UTF-16. */ - /* Unfortunately, there is no field in BROWSEINFO struct to indicate - * actual length of string in pszDisplayName, so we have to assume - * the string is null-terminated. */ - str = g_utf16_to_utf8(path16, -1, NULL, NULL, &error); - if (error != NULL) { - alertpanel_error(_("Could not convert file path back to UTF-8:\n\n%s"), - error->message); - debug_print("returned file path conversion to UTF-8 failed\n"); - g_error_free(error); - } - CoTaskMemFree(pidl); - CoUninitialize(); - g_free(ctx); - g_free(path16); - - return str; -} - -gchar *filesel_select_file_save_folder(const gchar *title, const gchar *path) -{ - return filesel_select_file_open_folder(title, path); -} diff --git a/src/imap.c b/src/imap.c @@ -1263,7 +1263,6 @@ static IMAPSession *imap_session_new(Folder * folder, } } -#ifndef G_OS_WIN32 if (account->set_tunnelcmd) { r = imap_threaded_connect_cmd(folder, account->tunnelcmd, @@ -1271,7 +1270,6 @@ static IMAPSession *imap_session_new(Folder * folder, port); } else -#endif { #ifdef USE_GNUTLS @@ -3187,36 +3185,6 @@ static FolderItem *imap_create_special_folder(Folder *folder, return new_item; } -#ifdef G_OS_WIN32 -static gchar *imap_encode_unsafe_chars(const gchar *str) -{ - gchar *ret = NULL, *o_ret; - gchar *i; - if (!str) - return NULL; - ret = g_malloc(3*strlen(str)+1); - o_ret = ret; - for (i = (gchar *)str; *i; i++) { - switch(*i) { - case ':': - case '|': - case '<': - case '>': - case '*': - case '?': - case '#': - *ret++ = '%'; - *ret++ = '0'+(*i/10); - *ret++ = '0'+(*i%10); - break; - default: - *ret++ = *i; - } - } - *ret++ = '\0'; - return o_ret; -} -#endif static gchar *imap_item_get_path(Folder *folder, FolderItem *item) { gchar *folder_path, *path; @@ -3229,11 +3197,7 @@ static gchar *imap_item_get_path(Folder *folder, FolderItem *item) g_return_val_if_fail(folder_path != NULL, NULL); -#ifdef G_OS_UNIX item_path = g_strdup(item->path); -#else - item_path = imap_encode_unsafe_chars(item->path); -#endif if (g_path_is_absolute(folder_path)) { if (item_path) @@ -3252,12 +3216,7 @@ static gchar *imap_item_get_path(Folder *folder, FolderItem *item) } g_free(folder_path); g_free(item_path); -#ifdef G_OS_WIN32 - while (strchr(path, '/')) - *strchr(path, '/') = '\\'; -#endif - - return path; + return path; } static FolderItem *imap_create_folder(Folder *folder, FolderItem *parent, diff --git a/src/main.c b/src/main.c @@ -138,9 +138,6 @@ #include "version.h" #include "timing.h" -#ifdef G_OS_WIN32 -#include <windows.h> -#endif gchar *prog_version; @@ -201,9 +198,7 @@ static void open_compose_new (const gchar *address, static void send_queue (void); static void initial_processing (FolderItem *item, gpointer data); -#ifndef G_OS_WIN32 static void quit_signal_handler (int sig); -#endif static void install_basic_sighandlers (void); static void exit_claws (MainWindow *mainwin); @@ -423,149 +418,6 @@ void main_set_show_at_startup(gboolean show) show_at_startup = show; } -#ifdef G_OS_WIN32 -static HANDLE win32_debug_log = NULL; -static guint win32_log_handler_app_id; -static guint win32_log_handler_glib_id; -static guint win32_log_handler_gtk_id; - -static void win32_log_WriteFile(const gchar *string) -{ - BOOL ret; - DWORD bytes_written; - - ret = WriteFile(win32_debug_log, string, strlen(string), &bytes_written, NULL); - if (!ret) { - DWORD err = GetLastError(); - gchar *tmp; - - tmp = g_strdup_printf("Error: WriteFile in failed with error 0x%lx. Buffer contents:\n%s", err, string); - OutputDebugString(tmp); - g_free(tmp); - } -} - -static void win32_print_stdout(const gchar *string) -{ - if (win32_debug_log) { - win32_log_WriteFile(string); - } -} - -GLogWriterOutput win32_log_writer(GLogLevelFlags log_level, const GLogField *fields, gsize n_fields, gpointer user_data) -{ - gchar *formatted; - gchar *out; - - g_return_val_if_fail(win32_debug_log != NULL, G_LOG_WRITER_UNHANDLED); - g_return_val_if_fail(fields != NULL, G_LOG_WRITER_UNHANDLED); - g_return_val_if_fail(n_fields > 0, G_LOG_WRITER_UNHANDLED); - - formatted = g_log_writer_format_fields(log_level, fields, n_fields, FALSE); - out = g_strdup_printf("%s\n", formatted); - - win32_log_WriteFile(out); - - g_free(formatted); - g_free(out); - - return G_LOG_WRITER_HANDLED; -} - -static void win32_log(const gchar *log_domain, GLogLevelFlags log_level, const gchar* message, gpointer user_data) -{ - gchar *out; - - if (win32_debug_log) { - const gchar* type; - - switch(log_level & G_LOG_LEVEL_MASK) - { - case G_LOG_LEVEL_ERROR: - type="error"; - break; - case G_LOG_LEVEL_CRITICAL: - type="critical"; - break; - case G_LOG_LEVEL_WARNING: - type="warning"; - break; - case G_LOG_LEVEL_MESSAGE: - type="message"; - break; - case G_LOG_LEVEL_INFO: - type="info"; - break; - case G_LOG_LEVEL_DEBUG: - type="debug"; - break; - default: - type="N/A"; - } - - if (log_domain) - out = g_strdup_printf("%s: %s: %s", log_domain, type, message); - else - out = g_strdup_printf("%s: %s", type, message); - - win32_log_WriteFile(out); - - g_free(out); - } -} - -static void win32_open_log(void) -{ - gchar *logfile = win32_debug_log_path(); - gchar *oldlogfile = g_strconcat(logfile, ".bak", NULL); - - if (is_file_exist(logfile)) { - if (rename_force(logfile, oldlogfile) < 0) - FILE_OP_ERROR(logfile, "rename"); - } - - win32_debug_log = CreateFile(logfile, - GENERIC_WRITE, - FILE_SHARE_READ, - NULL, - CREATE_NEW, - FILE_ATTRIBUTE_NORMAL, - NULL); - - if (win32_debug_log == INVALID_HANDLE_VALUE) { - win32_debug_log = NULL; - } - - g_free(logfile); - g_free(oldlogfile); - - if (win32_debug_log) { - g_set_print_handler(win32_print_stdout); - g_set_printerr_handler(win32_print_stdout); - - win32_log_handler_app_id = g_log_set_handler(NULL, G_LOG_LEVEL_MASK | G_LOG_FLAG_FATAL - | G_LOG_FLAG_RECURSION, win32_log, NULL); - win32_log_handler_glib_id = g_log_set_handler("GLib", G_LOG_LEVEL_MASK | G_LOG_FLAG_FATAL - | G_LOG_FLAG_RECURSION, win32_log, NULL); - win32_log_handler_gtk_id = g_log_set_handler("Gtk", G_LOG_LEVEL_MASK | G_LOG_FLAG_FATAL - | G_LOG_FLAG_RECURSION, win32_log, NULL); - - g_log_set_writer_func(&win32_log_writer, NULL, NULL); - } -} - -static void win32_close_log(void) -{ - if (win32_debug_log) { - g_log_remove_handler("", win32_log_handler_app_id); - g_log_remove_handler("GLib", win32_log_handler_glib_id); - g_log_remove_handler("Gtk", win32_log_handler_gtk_id); - CloseHandle(win32_debug_log); - win32_debug_log = NULL; - } -} -#endif - bool verify_folderlist_xml() { GNode *node; @@ -718,13 +570,7 @@ int main(int argc, char *argv[]) sc_starting = TRUE; -#ifdef G_OS_WIN32 - win32_open_log(); -#endif if (!claws_init(&argc, &argv)) { -#ifdef G_OS_WIN32 - win32_close_log(); -#endif return 0; } @@ -770,11 +616,7 @@ int main(int argc, char *argv[]) /* Create container for all the menus we will be adding */ MENUITEM_ADDUI("/", "Menus", NULL, GTK_UI_MANAGER_MENUBAR); -#ifdef G_OS_WIN32 - CHDIR_EXEC_CODE_RETURN_VAL_IF_FAIL(get_home_dir(), 1, win32_close_log();); -#else CHDIR_RETURN_VAL_IF_FAIL(get_home_dir(), 1); -#endif /* no config dir exists. See if we can migrate an old config. */ if (!is_dir_exist(get_rc_dir())) { @@ -810,9 +652,6 @@ int main(int argc, char *argv[]) if (copy_dir(SYSCONFDIR "/skel/.claws-mail", get_rc_dir()) < 0) { #endif if (!is_dir_exist(get_rc_dir()) && make_dir(get_rc_dir()) < 0) { -#ifdef G_OS_WIN32 - win32_close_log(); -#endif exit(1); } #ifdef G_OS_UNIX @@ -834,12 +673,7 @@ int main(int argc, char *argv[]) gtk_accel_map_load (userrc); g_free(userrc); - -#ifdef G_OS_WIN32 - CHDIR_EXEC_CODE_RETURN_VAL_IF_FAIL(get_rc_dir(), 1, win32_close_log();); -#else CHDIR_RETURN_VAL_IF_FAIL(get_rc_dir(), 1); -#endif MAKE_DIR_IF_NOT_EXIST(get_mail_base_dir()); MAKE_DIR_IF_NOT_EXIST(get_imap_cache_dir()); @@ -863,20 +697,13 @@ int main(int argc, char *argv[]) } set_log_file(LOG_DEBUG_FILTERING, "filtering.log"); -#ifdef G_OS_WIN32 - CHDIR_EXEC_CODE_RETURN_VAL_IF_FAIL(get_home_dir(), 1, win32_close_log();); -#else CHDIR_RETURN_VAL_IF_FAIL(get_home_dir(), 1); -#endif folder_system_init(); prefs_common_read_config(); if (prefs_update_config_version_common() < 0) { debug_print("Main configuration file version upgrade failed, exiting\n"); -#ifdef G_OS_WIN32 - win32_close_log(); -#endif exit(200); } @@ -906,15 +733,6 @@ int main(int argc, char *argv[]) codeconv_set_allow_jisx0201_kana(prefs_common.allow_jisx0201_kana); codeconv_set_broken_are_utf8(prefs_common.broken_are_utf8); -#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(); @@ -943,9 +761,6 @@ int main(int argc, char *argv[]) if ((ret = passwd_store_read_config()) < 0) { debug_print("Password store configuration file version upgrade failed (%d), exiting\n", ret); -#ifdef G_OS_WIN32 - win32_close_log(); -#endif exit(202); } @@ -957,9 +772,6 @@ int main(int argc, char *argv[]) if (prefs_update_config_version_accounts() < 0) { debug_print("Accounts configuration file version upgrade failed, exiting\n"); -#ifdef G_OS_WIN32 - win32_close_log(); -#endif exit(201); } @@ -981,9 +793,6 @@ int main(int argc, char *argv[]) /* config_version update failed in folder_read_list(). We * do not want to run the wizard, just exit. */ debug_print("Folderlist version upgrade failed, exiting\n"); -#ifdef G_OS_WIN32 - win32_close_log(); -#endif exit(203); } @@ -995,9 +804,6 @@ int main(int argc, char *argv[]) if (!run_wizard(mainwin, TRUE)) { if (asked_for_migration) remove_dir_recursive(RC_DIR); -#ifdef G_OS_WIN32 - win32_close_log(); -#endif exit(1); } main_window_reflect_prefs_all_now(); @@ -1010,9 +816,6 @@ int main(int argc, char *argv[]) if (!run_wizard(mainwin, FALSE)) { if (asked_for_migration) remove_dir_recursive(RC_DIR); -#ifdef G_OS_WIN32 - win32_close_log(); -#endif exit(1); } if(!account_get_list()) { @@ -1278,9 +1081,6 @@ static void exit_claws(MainWindow *mainwin) prefs_spelling_done(); gtkaspell_checkers_quit(); #endif -#ifdef G_OS_WIN32 - win32_close_log(); -#endif claws_done(); } @@ -2036,7 +1836,7 @@ static gint prohibit_duplicate_launch(int *argc, char ***argv) } else { g_print("Claws Mail is already running on this display (%s).\n", buf); - fd_close(sock); + close(sock); sock = fd_connect_unix(path); CM_FD_WRITE_ALL("popup\n"); } @@ -2045,7 +1845,7 @@ static gint prohibit_duplicate_launch(int *argc, char ***argv) #endif } - fd_close(sock); + close(sock); return -1; } @@ -2061,7 +1861,7 @@ static gint lock_socket_remove(void) if (lock_socket_tag > 0) { g_source_remove(lock_socket_tag); } - fd_close(lock_socket); + close(lock_socket); #ifdef G_OS_UNIX filename = claws_get_socket_name(); @@ -2278,7 +2078,7 @@ search_exit: } app_will_exit(NULL, mainwin); } - fd_close(sock); + close(sock); } @@ -2325,18 +2125,15 @@ static void send_queue(void) } } -#ifndef G_OS_WIN32 static void quit_signal_handler(int sig) { debug_print("Quitting on signal %d\n", sig); g_timeout_add(0, clean_quit, NULL); } -#endif static void install_basic_sighandlers() { -#ifndef G_OS_WIN32 sigset_t mask; struct sigaction act; @@ -2367,5 +2164,4 @@ static void install_basic_sighandlers() #endif sigprocmask(SIG_UNBLOCK, &mask, 0); -#endif /* !G_OS_WIN32 */ } diff --git a/src/mainwindow.c b/src/mainwindow.c @@ -19,11 +19,6 @@ #include "config.h" #include "defs.h" -#ifdef G_OS_WIN32 -#define UNICODE -#define _UNICODE -#endif - #include <glib.h> #include <glib/gi18n.h> #include <gdk/gdkkeysyms.h> @@ -93,9 +88,6 @@ #include "socket.h" #include "printing.h" #include "send_message.h" -#ifdef G_OS_WIN32 -#include "w32_reg.h" -#endif /* list of all instantiated MainWindow */ static GList *mainwin_list = NULL; @@ -179,9 +171,6 @@ static void log_window_show_cb (GtkAction *action, gpointer data); static void filtering_debug_window_show_cb (GtkAction *action, gpointer data); -#ifdef G_OS_WIN32 -static void debug_log_show_cb(GtkAction *action, gpointer data); -#endif static void inc_cancel_cb (GtkAction *action, gpointer data); @@ -394,11 +383,6 @@ static void manual_faq_open_cb (GtkAction *action, static void legend_open_cb (GtkAction *action, gpointer data); -#ifdef G_OS_WIN32 -static void set_default_client_cb (GtkAction *action, - gpointer data); -#endif - static void scan_tree_func (Folder *folder, FolderItem *item, gpointer data); @@ -450,9 +434,7 @@ static gboolean any_folder_want_synchronise(void); static void save_part_as_cb(GtkAction *action, gpointer data); static void view_part_as_text_cb(GtkAction *action, gpointer data); static void open_part_cb(GtkAction *action, gpointer data); -#ifndef G_OS_WIN32 static void open_part_with_cb(GtkAction *action, gpointer data); -#endif static void check_signature_cb(GtkAction *action, gpointer data); static void goto_next_part_cb(GtkAction *action, gpointer data); static void goto_prev_part_cb(GtkAction *action, gpointer data); @@ -609,9 +591,7 @@ static GtkActionEntry mainwin_entries[] = {"View/Part", NULL, N_("Message part"), NULL, NULL, NULL }, {"View/Part/AsText", NULL, N_("View as text"), "T", NULL, G_CALLBACK(view_part_as_text_cb) }, {"View/Part/Open", NULL, N_("Open"), "L", NULL, G_CALLBACK(open_part_cb) }, -#ifndef G_OS_WIN32 {"View/Part/OpenWith", NULL, N_("Open with..."), "O", NULL, G_CALLBACK(open_part_with_cb) }, -#endif /* {"View/---", NULL, "---", NULL, NULL, NULL }, */ {"View/Quotes", NULL, N_("Quotes"), NULL, NULL, NULL }, @@ -752,9 +732,7 @@ static GtkActionEntry mainwin_entries[] = /* {"Tools/---", NULL, "---", NULL, NULL, NULL }, */ {"Tools/FilteringLog", NULL, N_("Filtering Lo_g"), NULL, NULL, G_CALLBACK(filtering_debug_window_show_cb) }, {"Tools/NetworkLog", NULL, N_("Network _Log"), "<shift><control>L", NULL, G_CALLBACK(log_window_show_cb) }, -#ifdef G_OS_WIN32 - {"Tools/DebugLog", NULL, N_("Debug _Log"), NULL, NULL, G_CALLBACK(debug_log_show_cb) }, -#endif + /* {"Tools/---", NULL, "---", NULL, NULL, NULL }, */ {"Tools/ForgetSessionPasswords", NULL, N_("_Forget all session passwords"), NULL, NULL, G_CALLBACK(forget_session_passwords_cb) }, {"Tools/ForgetPrimaryPassphrase", NULL, N_("Forget _primary passphrase"), NULL, NULL, G_CALLBACK(forget_primary_passphrase_cb) }, @@ -779,9 +757,6 @@ static GtkActionEntry mainwin_entries[] = {"Help/Manual", NULL, N_("_Manual"), NULL, NULL, G_CALLBACK(manual_open_cb) }, {"Help/FAQ", NULL, N_("_Online User-contributed FAQ"), NULL, NULL, G_CALLBACK(manual_faq_open_cb) }, {"Help/IconLegend", NULL, N_("Icon _Legend"), NULL, NULL, G_CALLBACK(legend_open_cb) }, -#ifdef G_OS_WIN32 - {"Help/SetDefault", NULL, N_("Set as default client"), NULL, NULL, G_CALLBACK(set_default_client_cb) }, -#endif {"Help/---", NULL, "---", NULL, NULL, NULL }, {"Help/About", NULL, N_("_About"), NULL, NULL, G_CALLBACK(about_cb) }, }; @@ -1658,9 +1633,7 @@ MainWindow *main_window_create() MENUITEM_ADDUI_MANAGER(mainwin->ui_manager, "/Menu/View", "Part", "View/Part", GTK_UI_MANAGER_MENU) MENUITEM_ADDUI_MANAGER(mainwin->ui_manager, "/Menu/View/Part", "AsText", "View/Part/AsText", GTK_UI_MANAGER_MENUITEM) MENUITEM_ADDUI_MANAGER(mainwin->ui_manager, "/Menu/View/Part", "Open", "View/Part/Open", GTK_UI_MANAGER_MENUITEM) -#ifndef G_OS_WIN32 MENUITEM_ADDUI_MANAGER(mainwin->ui_manager, "/Menu/View/Part", "OpenWith", "View/Part/OpenWith", GTK_UI_MANAGER_MENUITEM) -#endif MENUITEM_ADDUI_MANAGER(mainwin->ui_manager, "/Menu/View", "Separator8", "View/---", GTK_UI_MANAGER_SEPARATOR) MENUITEM_ADDUI_MANAGER(mainwin->ui_manager, "/Menu/View", "UpdateSummary", "View/UpdateSummary", GTK_UI_MANAGER_MENUITEM) @@ -1788,9 +1761,6 @@ MainWindow *main_window_create() MENUITEM_ADDUI_MANAGER(mainwin->ui_manager, "/Menu/Tools", "Separator7", "Tools/---", GTK_UI_MANAGER_SEPARATOR) MENUITEM_ADDUI_MANAGER(mainwin->ui_manager, "/Menu/Tools", "FilteringLog", "Tools/FilteringLog", GTK_UI_MANAGER_MENUITEM) MENUITEM_ADDUI_MANAGER(mainwin->ui_manager, "/Menu/Tools", "NetworkLog", "Tools/NetworkLog", GTK_UI_MANAGER_MENUITEM) -#ifdef G_OS_WIN32 - MENUITEM_ADDUI_MANAGER(mainwin->ui_manager, "/Menu/Tools", "DebugLog", "Tools/DebugLog", GTK_UI_MANAGER_MENUITEM) -#endif MENUITEM_ADDUI_MANAGER(mainwin->ui_manager, "/Menu/Tools", "Separator8", "Tools/---", GTK_UI_MANAGER_SEPARATOR) MENUITEM_ADDUI_MANAGER(mainwin->ui_manager, "/Menu/Tools", "ForgetSessionPasswords", "Tools/ForgetSessionPasswords", GTK_UI_MANAGER_MENUITEM) MENUITEM_ADDUI_MANAGER(mainwin->ui_manager, "/Menu/Tools", "ForgetPrimaryPassphrase", "Tools/ForgetPrimaryPassphrase", GTK_UI_MANAGER_MENUITEM) @@ -1818,10 +1788,6 @@ MainWindow *main_window_create() MENUITEM_ADDUI_MANAGER(mainwin->ui_manager, "/Menu/Help", "Manual", "Help/Manual", GTK_UI_MANAGER_MENUITEM) MENUITEM_ADDUI_MANAGER(mainwin->ui_manager, "/Menu/Help", "FAQ", "Help/FAQ", GTK_UI_MANAGER_MENUITEM) MENUITEM_ADDUI_MANAGER(mainwin->ui_manager, "/Menu/Help", "IconLegend", "Help/IconLegend", GTK_UI_MANAGER_MENUITEM) -#ifdef G_OS_WIN32 - MENUITEM_ADDUI_MANAGER(mainwin->ui_manager, "/Menu/Help", "Separator1", "Help/---", GTK_UI_MANAGER_SEPARATOR) - MENUITEM_ADDUI_MANAGER(mainwin->ui_manager, "/Menu/Help", "SetDefault", "Help/SetDefault", GTK_UI_MANAGER_MENUITEM) -#endif MENUITEM_ADDUI_MANAGER(mainwin->ui_manager, "/Menu/Help", "Separator2", "Help/---", GTK_UI_MANAGER_SEPARATOR) MENUITEM_ADDUI_MANAGER(mainwin->ui_manager, "/Menu/Help", "About", "Help/About", GTK_UI_MANAGER_MENUITEM) @@ -4168,34 +4134,6 @@ static void filtering_debug_window_show_cb(GtkAction *action, gpointer data) log_window_show(mainwin->filtering_debugwin); } -#ifdef G_OS_WIN32 -static void debug_log_show_cb(GtkAction *action, gpointer data) -{ - GError *error = NULL; - gchar *logpath8 = win32_debug_log_path(); - gunichar2 *logpath16; - - debug_print("opening '%s'\n", logpath8); - - logpath16 = g_utf8_to_utf16(logpath8, -1, NULL, NULL, &error); - - if (error != NULL) { - g_warning("couldn't convert debug log path '%s' to UTF-16: %s", - logpath8, error->message); - g_error_free(error); - g_free(logpath16); - return; - } - - HINSTANCE ret = ShellExecute(NULL, NULL, (LPCWSTR)logpath16, - NULL, NULL, SW_SHOW); - - g_free(logpath8); - g_free(logpath16); - debug_print("ShellExecute result: %"G_GSIZE_FORMAT"\n", (gsize)ret); -} -#endif - static void inc_cancel_cb(GtkAction *action, gpointer data) { inc_cancel_all(); @@ -4991,116 +4929,6 @@ static void legend_open_cb(GtkAction *action, gpointer data) legend_show(); } -#ifdef G_OS_WIN32 -static void set_default_client_cb(GtkAction *action, gpointer data) -{ - char exename[MAX_PATH]; - gchar *binary_icon = NULL; - gchar *binary_compose = NULL; - gchar *binary_run = NULL; - gboolean r; - if ( !GetModuleFileNameA (0, exename, sizeof (exename)) ) { - alertpanel_error(_("Can not register as default client: impossible to get executable path.")); - return; - } - binary_icon = g_strconcat(exename, ",0", NULL); - binary_compose = g_strconcat(exename, " --compose %1", NULL); - binary_run = g_strconcat(exename, NULL); - - /* Try to set the Mail Start menu item to Claws. It may fail if we're not root; we don't care */ - r = write_w32_registry_string(HKEY_LOCAL_MACHINE, - "Software\\Clients\\Mail", - "", - "Claws Mail"); - - r = write_w32_registry_string(HKEY_CURRENT_USER, - "Software\\Clients\\Mail\\Claws Mail", - "", - "Claws Mail"); - if (r) - r = write_w32_registry_string(HKEY_CURRENT_USER, - "Software\\Clients\\Mail\\Claws Mail", - "DLLPath", - ""); - if (r) - r = write_w32_registry_string(HKEY_CURRENT_USER, - "Software\\Clients\\Mail\\Claws Mail\\Protocols\\mailto", - "", - "URL:MailTo-Protocol"); - if (r) - r = write_w32_registry_string(HKEY_CURRENT_USER, - "Software\\Clients\\Mail\\Claws Mail\\Protocols\\mailto", - "URL Protocol", - ""); - if (r) - r = write_w32_registry_dword (HKEY_CURRENT_USER, - "Software\\Clients\\Mail\\Claws Mail\\Protocols\\mailto", - "EditFlags", - 2); - if (r) - r = write_w32_registry_string(HKEY_CURRENT_USER, - "Software\\Clients\\Mail\\Claws Mail\\Protocols\\mailto", - "FriendlyTypeName", - "Claws-Mail URL"); - if (r) - r = write_w32_registry_string(HKEY_CURRENT_USER, - "Software\\Clients\\Mail\\Claws Mail\\Protocols\\mailto\\DefaultIcon", - "", - binary_icon); - if (r) - r = write_w32_registry_string(HKEY_CURRENT_USER, - "Software\\Clients\\Mail\\Claws Mail\\Protocols\\mailto\\shell\\open\\command", - "", - binary_compose); - if (r) - r = write_w32_registry_string(HKEY_CURRENT_USER, - "Software\\Clients\\Mail\\Claws Mail\\shell\\open\\command", - "", - binary_run); - - if (r) - r = write_w32_registry_string(HKEY_CURRENT_USER, - "Software\\Classes\\mailto", - "", - "URL:MailTo-Protocol"); - if (r) - r = write_w32_registry_string(HKEY_CURRENT_USER, - "Software\\Classes\\mailto", - "URL Protocol", - ""); - if (r) - r = write_w32_registry_dword (HKEY_CURRENT_USER, - "Software\\Classes\\mailto", - "EditFlags", - 2); - if (r) - r = write_w32_registry_string(HKEY_CURRENT_USER, - "Software\\Classes\\mailto", - "FriendlyTypeName", - "Claws-Mail URL"); - if (r) - r = write_w32_registry_string(HKEY_CURRENT_USER, - "Software\\Classes\\mailto\\DefaultIcon", - "", - binary_icon); - if (r) - r = write_w32_registry_string(HKEY_CURRENT_USER, - "Software\\Classes\\mailto\\shell\\open\\command", - "", - binary_compose); - - if (r) { - SendMessage(HWND_BROADCAST, WM_SETTINGCHANGE, 0, (LPARAM)"Software\\Clients\\Mail"); - alertpanel_notice(_("Claws Mail has been registered as default client.")); - } else { - alertpanel_error(_("Can not register as default client: impossible to write to the registry.")); - } - g_free(binary_icon); - g_free(binary_compose); - g_free(binary_run); -} -#endif - static void scan_tree_func(Folder *folder, FolderItem *item, gpointer data) { MainWindow *mainwin = (MainWindow *)data; @@ -5390,7 +5218,7 @@ static void open_part_cb(GtkAction *action, gpointer data) && mainwin->messageview->mimeview) mimeview_launch(mainwin->messageview->mimeview, NULL); } -#ifndef G_OS_WIN32 + static void open_part_with_cb(GtkAction *action, gpointer data) { MainWindow *mainwin = (MainWindow *)data; @@ -5399,7 +5227,7 @@ static void open_part_with_cb(GtkAction *action, gpointer data) && mainwin->messageview->mimeview) mimeview_open_with(mainwin->messageview->mimeview); } -#endif + static void check_signature_cb(GtkAction *action, gpointer data) { MainWindow *mainwin = (MainWindow *)data; diff --git a/src/manual.c b/src/manual.c @@ -31,26 +31,15 @@ # include <locale.h> #endif -#if !defined(LC_MESSAGES) && defined(G_OS_WIN32) -#include <libintl.h> -#endif - - #include "prefs_common.h" #include "manual.h" #include "utils.h" - static gchar *get_language() { gchar *language; gchar *c; - -#ifdef G_OS_WIN32 - language = g_win32_getlocale(); -#else language = g_strdup(setlocale(LC_MESSAGES, NULL)); -#endif if (!language) return g_strdup("en"); diff --git a/src/messageview.c b/src/messageview.c @@ -179,9 +179,7 @@ static gboolean messageview_update_msg (gpointer source, gpointer data); static void save_part_as_cb(GtkAction *action, gpointer data); static void view_part_as_text_cb(GtkAction *action, gpointer data); static void open_part_cb(GtkAction *action, gpointer data); -#ifndef G_OS_WIN32 static void open_part_with_cb(GtkAction *action, gpointer data); -#endif static void check_signature_cb(GtkAction *action, gpointer data); static void goto_next_part_cb(GtkAction *action, gpointer data); static void goto_prev_part_cb(GtkAction *action, gpointer data); @@ -272,9 +270,7 @@ static GtkActionEntry msgview_entries[] = {"View/Part", NULL, N_("Message part"), NULL, NULL, NULL }, {"View/Part/AsText", NULL, N_("View as text"), "T", NULL, G_CALLBACK(view_part_as_text_cb) }, {"View/Part/Open", NULL, N_("Open"), "L", NULL, G_CALLBACK(open_part_cb) }, -#ifndef G_OS_WIN32 {"View/Part/OpenWith", NULL, N_("Open with..."), "O", NULL, G_CALLBACK(open_part_with_cb) }, -#endif {"View/Quotes", NULL, N_("Quotes"), NULL, NULL, NULL }, @@ -594,9 +590,7 @@ static void messageview_add_toolbar(MessageView *msgview, GtkWidget *window) MENUITEM_ADDUI_MANAGER(msgview->ui_manager, "/Menu/View", "Part", "View/Part", GTK_UI_MANAGER_MENU) MENUITEM_ADDUI_MANAGER(msgview->ui_manager, "/Menu/View/Part", "AsText", "View/Part/AsText", GTK_UI_MANAGER_MENUITEM) MENUITEM_ADDUI_MANAGER(msgview->ui_manager, "/Menu/View/Part", "Open", "View/Part/Open", GTK_UI_MANAGER_MENUITEM) -#ifndef G_OS_WIN32 MENUITEM_ADDUI_MANAGER(msgview->ui_manager, "/Menu/View/Part", "OpenWith", "View/Part/OpenWith", GTK_UI_MANAGER_MENUITEM) -#endif /* Message menu */ MENUITEM_ADDUI_MANAGER(msgview->ui_manager, "/Menu/Message", "Compose", "Message/Compose", GTK_UI_MANAGER_MENUITEM) @@ -694,10 +688,6 @@ static MessageView *messageview_create_with_new_window_visible(MainWindow *mainw gtk_window_set_geometry_hints(GTK_WINDOW(window), NULL, &geometry, GDK_HINT_MIN_SIZE); -#ifdef G_OS_WIN32 - gtk_window_move(GTK_WINDOW(window), 48, 48); -#endif - msgview = messageview_create(mainwin); g_signal_connect(G_OBJECT(window), "size_allocate", @@ -3043,7 +3033,7 @@ static void open_part_cb(GtkAction *action, gpointer data) if (messageview->mimeview) mimeview_launch(messageview->mimeview, NULL); } -#ifndef G_OS_WIN32 + static void open_part_with_cb(GtkAction *action, gpointer data) { MessageView *messageview = (MessageView *)data; @@ -3051,7 +3041,7 @@ static void open_part_with_cb(GtkAction *action, gpointer data) if (messageview->mimeview) mimeview_open_with(messageview->mimeview); } -#endif + static void check_signature_cb(GtkAction *action, gpointer data) { MessageView *messageview = (MessageView *)data; diff --git a/src/mh.c b/src/mh.c @@ -45,19 +45,6 @@ #include "file-utils.h" #include "prefs_common.h" -/* Define possible missing constants for Windows. */ -#ifdef G_OS_WIN32 -# ifndef S_IRGRP -# define S_IRGRP 0 -# define S_IWGRP 0 -# endif -# ifndef S_IROTH -# define S_IROTH 0 -# define S_IWOTH 0 -# endif -#endif - - static void mh_folder_init (Folder *folder, const gchar *name, const gchar *path); @@ -731,15 +718,8 @@ static gint mh_remove_all_msg(Folder *folder, FolderItem *item) static gboolean mh_is_msg_changed(Folder *folder, FolderItem *item, MsgInfo *msginfo) { -#ifdef G_OS_WIN32 - GFile *f; - GFileInfo *fi; - GTimeVal tv; - GError *error = NULL; -#else GStatBuf s; int r; -#endif gchar *path; gchar *parent_path; @@ -748,27 +728,6 @@ static gboolean mh_is_msg_changed(Folder *folder, FolderItem *item, G_DIR_SEPARATOR, msginfo->msgnum); g_free(parent_path); -#ifdef G_OS_WIN32 - f = g_file_new_for_path(path); - g_free(path); - fi = g_file_query_info(f, "standard::size,time::modified", - G_FILE_QUERY_INFO_NONE, NULL, &error); - if (error != NULL) { - g_warning(error->message); - g_error_free(error); - g_object_unref(f); - return TRUE; - } - - g_file_info_get_modification_time(fi, &tv); - if (msginfo->size != g_file_info_get_size(fi) || ( - (msginfo->mtime - tv.tv_sec != 0) && - abs(msginfo->mtime - tv.tv_sec) != 3600)) { - g_error_free(error); - g_object_unref(f); - return TRUE; - } -#else r = g_stat(path, &s); g_free(path); if (r < 0 || @@ -778,8 +737,6 @@ static gboolean mh_is_msg_changed(Folder *folder, FolderItem *item, (msginfo->mtime - s.st_mtime != -3600))) { return TRUE; } -#endif - return FALSE; } @@ -833,11 +790,7 @@ static gint mh_create_tree(Folder *folder) cm_return_val_if_fail(folder != NULL, -1); rootpath = LOCAL_FOLDER(folder)->rootpath; -#ifdef G_OS_UNIX if (*rootpath == '/') { -#elif defined G_OS_WIN32 - if (g_ascii_isalpha(*rootpath) && !strncmp(rootpath + 1, ":\\", 2)) { -#endif /* Folder path is absolute. */ rootpath = g_strdup(rootpath); } else { diff --git a/src/mimeview.c b/src/mimeview.c @@ -23,11 +23,6 @@ #include "defs.h" -#ifdef G_OS_WIN32 -#define UNICODE -#define _UNICODE -#endif - #include <glib.h> #include <glib/gi18n.h> #include <gdk/gdkkeysyms.h> @@ -53,9 +48,6 @@ #include "gtk/gtkvscrollbutton.h" #include "gtk/logwindow.h" #include "timing.h" -#ifdef G_OS_WIN32 -#include <windows.h> -#endif #include "manage_window.h" #include "privacy.h" #include "file-utils.h" @@ -107,11 +99,9 @@ static gboolean mimeview_scrolled (GtkWidget *widget, static void mimeview_save_all (MimeView *mimeview, gboolean attachments_only); -#ifndef G_OS_WIN32 static void mimeview_open_part_with (MimeView *mimeview, MimeInfo *partinfo, gboolean automatic); -#endif static void mimeview_send_to (MimeView *mimeview, MimeInfo *partinfo); static void mimeview_view_file (const gchar *filename, @@ -155,12 +145,10 @@ static void mimeview_launch_cb(GtkAction *action, gpointer data) mimeview_launch(mimeview, mimeview_get_part_to_use(mimeview)); } -#ifndef G_OS_WIN32 static void mimeview_open_with_cb(GtkAction *action, gpointer data) { mimeview_open_with((MimeView *)data); } -#endif static void mimeview_copy_cb(GtkAction *action, gpointer data) { @@ -228,9 +216,7 @@ static void mimeview_select_prev_part_cb(GtkAction *action, gpointer data) static GtkActionEntry mimeview_menu_actions[] = { { "MimeView", NULL, "MimeView", NULL, NULL, NULL }, { "MimeView/Open", NULL, N_("_Open"), NULL, "Open MIME part", G_CALLBACK(mimeview_launch_cb) }, -#if (!defined G_OS_WIN32) { "MimeView/OpenWith", NULL, N_("Open _with..."), NULL, "Open MIME part with...", G_CALLBACK(mimeview_open_with_cb) }, -#endif { "MimeView/Copy", NULL, N_("Copy"), NULL, "Copy", G_CALLBACK(mimeview_copy_cb) }, { "MimeView/SendTo", NULL, N_("Send to..."), NULL, "Send to", G_CALLBACK(mimeview_send_to_cb) }, { "MimeView/DisplayAsText", NULL, N_("_Display as text"), NULL, "Display as text", G_CALLBACK(mimeview_display_as_text_cb) }, @@ -436,11 +422,9 @@ MimeView *mimeview_create(MainWindow *mainwin) MENUITEM_ADDUI_MANAGER(mimeview->ui_manager, "/Menus/MimeView/", "Open", "MimeView/Open", GTK_UI_MANAGER_MENUITEM); -#if (!defined G_OS_WIN32) MENUITEM_ADDUI_MANAGER(mimeview->ui_manager, "/Menus/MimeView/", "OpenWith", "MimeView/OpenWith", GTK_UI_MANAGER_MENUITEM); -#endif MENUITEM_ADDUI_MANAGER(mimeview->ui_manager, "/Menus/MimeView/", "Copy", "MimeView/Copy", GTK_UI_MANAGER_MENUITEM); @@ -1491,13 +1475,11 @@ static gboolean part_button_pressed(MimeView *mimeview, GdkEventButton *event, cm_menu_set_sensitive_full(mimeview->ui_manager, "Menus/MimeView/Copy", TRUE); else cm_menu_set_sensitive_full(mimeview->ui_manager, "Menus/MimeView/Copy", FALSE); -#ifndef G_OS_WIN32 if (partinfo && partinfo->type == MIMETYPE_APPLICATION && !g_ascii_strcasecmp(partinfo->subtype, "octet-stream")) cm_menu_set_sensitive_full(mimeview->ui_manager, "Menus/MimeView/Open", FALSE); else -#endif cm_menu_set_sensitive_full(mimeview->ui_manager, "Menus/MimeView/Open", TRUE); if (mainwin) main_window_set_menu_sensitive(mainwin); @@ -2103,7 +2085,6 @@ void mimeview_launch(MimeView *mimeview, MimeInfo *partinfo) g_free(filename); } -#ifndef G_OS_WIN32 void mimeview_open_with(MimeView *mimeview) { MimeInfo *partinfo; @@ -2208,7 +2189,6 @@ static void mimeview_open_part_with(MimeView *mimeview, MimeInfo *partinfo, gboo g_free(content_type); g_free(filename); } -#endif static void mimeview_send_to(MimeView *mimeview, MimeInfo *partinfo) { @@ -2251,7 +2231,6 @@ static void mimeview_send_to(MimeView *mimeview, MimeInfo *partinfo) static void mimeview_view_file(const gchar *filename, MimeInfo *partinfo, const gchar *cmd, MimeView *mimeview) { -#ifndef G_OS_WIN32 gchar *p; gchar buf[BUFFSIZE]; @@ -2276,38 +2255,6 @@ static void mimeview_view_file(const gchar *filename, MimeInfo *partinfo, mimeview_open_part_with(mimeview, partinfo, FALSE); } } -#else - SHFILEINFO file_info; - GError *error = NULL; - gunichar2 *fn16 = g_utf8_to_utf16(filename, -1, NULL, NULL, &error); - - if (error != NULL) { - alertpanel_error(_("Could not convert attachment name to UTF-16:\n\n%s"), - error->message); - debug_print("filename '%s' conversion to UTF-16 failed\n", filename); - g_error_free(error); - return; - } - - if ((SHGetFileInfo((LPCWSTR)fn16, 0, &file_info, sizeof(SHFILEINFO), SHGFI_EXETYPE)) != 0) { - AlertValue val = alertpanel_full(_("Execute untrusted binary?"), - _("This attachment is an executable file. Executing " - "untrusted binaries is dangerous and could compromise " - "your computer.\n\n" - "Do you want to run this file?"), NULL, _("_Cancel"), - NULL, _("Run binary"), NULL, NULL, ALERTFOCUS_FIRST, - FALSE, NULL, ALERT_WARNING); - if (val == G_ALERTALTERNATE) { - debug_print("executing binary\n"); - ShellExecute(NULL, L"open", (LPCWSTR)fn16, NULL, NULL, SW_SHOW); - } - } else { - ShellExecute(NULL, L"open", (LPCWSTR)fn16, NULL, NULL, SW_SHOW); - } - - g_free(fn16); - -#endif } void mimeview_register_viewer_factory(MimeViewerFactory *factory) @@ -2429,12 +2376,10 @@ static gint icon_key_pressed(GtkWidget *button, GdkEventKey *event, BREAK_ON_MODIFIER_KEY(); mimeview_launch(mimeview, NULL); return TRUE; -#ifndef G_OS_WIN32 case GDK_KEY_o: BREAK_ON_MODIFIER_KEY(); mimeview_open_with(mimeview); return TRUE; -#endif case GDK_KEY_c: BREAK_ON_MODIFIER_KEY(); mimeview_check_signature(mimeview); @@ -2813,10 +2758,8 @@ void mimeview_handle_cmd(MimeView *mimeview, const gchar *cmd, GdkEventButton *e mimeview_save_as(mimeview); else if (!strcmp(cmd, "cm://display_as_text")) mimeview_display_as_text(mimeview); -#ifndef G_OS_WIN32 else if (!strcmp(cmd, "cm://open_with")) mimeview_open_with(mimeview); -#endif else if (!strcmp(cmd, "cm://open")) mimeview_launch(mimeview, NULL); else if (!strcmp(cmd, "cm://select_attachment") && data != NULL) { diff --git a/src/mimeview.h b/src/mimeview.h @@ -14,7 +14,7 @@ * * You should have received a copy of the GNU General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. - * + * */ #ifndef MIMEVIEW_H @@ -94,14 +94,14 @@ struct _MimeViewerFactory */ gchar **content_types; gint priority; - + MimeViewer *(*create_viewer) (void); }; struct _MimeViewer { MimeViewerFactory *factory; - + GtkWidget *(*get_widget) (MimeViewer *); void (*show_mimepart) (MimeViewer *, const gchar *infile, MimeInfo *); void (*clear_viewer) (MimeViewer *); @@ -110,7 +110,7 @@ struct _MimeViewer gboolean (*scroll_page) (MimeViewer *, gboolean up); void (*scroll_one_line) (MimeViewer *, gboolean up); gboolean (*text_search) (MimeViewer *, gboolean backward, - const gchar *str, + const gchar *str, gboolean case_sensitive); void (*print) (MimeViewer *); MimeView *mimeview; @@ -126,7 +126,7 @@ void mimeview_init (MimeView *mimeview); void mimeview_show_message (MimeView *mimeview, MimeInfo *mimeinfo, const gchar *file); -gboolean mimeview_show_part (MimeView *mimeview, +gboolean mimeview_show_part (MimeView *mimeview, MimeInfo *partinfo); void mimeview_show_part_as_text (MimeView *mimeview, MimeInfo *partinfo); @@ -141,18 +141,18 @@ gboolean mimeview_pass_key_press_event (MimeView *mimeview, void mimeview_register_viewer_factory (MimeViewerFactory *factory); void mimeview_unregister_viewer_factory (MimeViewerFactory *factory); -void mimeview_handle_cmd (MimeView *mimeview, +void mimeview_handle_cmd (MimeView *mimeview, const gchar *cmd, GdkEventButton *event, gpointer data); -void mimeview_select_mimepart_icon (MimeView *mimeview, +void mimeview_select_mimepart_icon (MimeView *mimeview, MimeInfo *partinfo); -gboolean mimeview_scroll_page (MimeView *mimeview, +gboolean mimeview_scroll_page (MimeView *mimeview, gboolean up); -void mimeview_scroll_one_line (MimeView *mimeview, +void mimeview_scroll_one_line (MimeView *mimeview, gboolean up); gint mimeview_get_selected_part_num (MimeView *mimeview); -void mimeview_select_part_num (MimeView *mimeview, +void mimeview_select_part_num (MimeView *mimeview, gint i); gboolean mimeview_has_viewer_for_content_type (MimeView *mimeview, @@ -162,9 +162,7 @@ void mimeview_save_as (MimeView *mimeview); void mimeview_display_as_text (MimeView *mimeview); void mimeview_launch (MimeView *mimeview, MimeInfo *partinfo); -#ifndef G_OS_WIN32 void mimeview_open_with (MimeView *mimeview); -#endif void mimeview_check_signature(MimeView *mimeview); void mimeview_select_next_part(MimeView *mimeview); void mimeview_select_prev_part(MimeView *mimeview); diff --git a/src/msgcache.c b/src/msgcache.c @@ -28,11 +28,7 @@ #include <glib.h> #include <glib/gi18n.h> -#ifdef _WIN32 -# define MAP_FAILED ((char *) -1) -#else -# include <sys/mman.h> -#endif +#include <sys/mman.h> #include <sys/types.h> #include <sys/stat.h> @@ -43,9 +39,6 @@ #include "procmsg.h" #include "codeconv.h" #include "timing.h" -#ifdef G_OS_WIN32 -#include <windows.h> -#endif #include "tags.h" #include "prefs_common.h" #include "file-utils.h" @@ -642,22 +635,7 @@ MsgCache *msgcache_read_cache(FolderItem *item, const gchar *cache_file) else map_len = -1; if (map_len > 0) { -#ifdef G_OS_WIN32 - cache_data = NULL; - HANDLE hFile, hMapping; - hFile = (HANDLE) _get_osfhandle (fileno(fp)); - if (hFile == (HANDLE) -1) - goto w32_fail; - hMapping = CreateFileMapping(hFile, NULL, PAGE_WRITECOPY, 0, 0, NULL); - if (!hMapping) - goto w32_fail; - cache_data = (unsigned char *)MapViewOfFile(hMapping, FILE_MAP_COPY, 0, 0, 0); - CloseHandle (hMapping); - w32_fail: - ; -#else cache_data = mmap(NULL, map_len, PROT_READ, MAP_PRIVATE, fileno(fp), 0); -#endif } } else { cache_data = NULL; @@ -780,11 +758,7 @@ MsgCache *msgcache_read_cache(FolderItem *item, const gchar *cache_file) } bail_err: if (cache_data != NULL && cache_data != MAP_FAILED) { -#ifdef G_OS_WIN32 - UnmapViewOfFile((void*) cache_data); -#else munmap(cache_data, map_len); -#endif } fclose(fp); if (conv != NULL) { @@ -840,22 +814,7 @@ void msgcache_read_mark(MsgCache *cache, const gchar *mark_file) else map_len = -1; if (map_len > 0) { -#ifdef G_OS_WIN32 - cache_data = NULL; - HANDLE hFile, hMapping; - hFile = (HANDLE) _get_osfhandle (fileno(fp)); - if (hFile == (HANDLE) -1) - goto w32_fail2; - hMapping = CreateFileMapping(hFile, NULL, PAGE_WRITECOPY, 0, 0, NULL); - if (!hMapping) - goto w32_fail2; - cache_data = (unsigned char *)MapViewOfFile(hMapping, FILE_MAP_COPY, 0, 0, 0); - CloseHandle (hMapping); - w32_fail2: - ; -#else cache_data = mmap(NULL, map_len, PROT_READ, MAP_PRIVATE, fileno(fp), 0); -#endif } } else { cache_data = NULL; @@ -890,11 +849,7 @@ void msgcache_read_mark(MsgCache *cache, const gchar *mark_file) } bail_err: if (cache_data != NULL && cache_data != MAP_FAILED) { -#ifdef G_OS_WIN32 - UnmapViewOfFile((void*) cache_data); -#else munmap(cache_data, map_len); -#endif } fclose(fp); if (error) { @@ -934,22 +889,7 @@ void msgcache_read_tags(MsgCache *cache, const gchar *tags_file) else map_len = -1; if (map_len > 0) { -#ifdef G_OS_WIN32 - cache_data = NULL; - HANDLE hFile, hMapping; - hFile = (HANDLE) _get_osfhandle (fileno(fp)); - if (hFile == (HANDLE) -1) - goto w32_fail6; - hMapping = CreateFileMapping(hFile, NULL, PAGE_WRITECOPY, 0, 0, NULL); - if (!hMapping) - goto w32_fail6; - cache_data = (unsigned char *)MapViewOfFile(hMapping, FILE_MAP_COPY, 0, 0, 0); - CloseHandle (hMapping); - w32_fail6: - ; -#else cache_data = mmap(NULL, map_len, PROT_READ, MAP_PRIVATE, fileno(fp), 0); -#endif } } else { cache_data = NULL; @@ -1002,11 +942,7 @@ void msgcache_read_tags(MsgCache *cache, const gchar *tags_file) } bail_err: if (cache_data != NULL && cache_data != MAP_FAILED) { -#ifdef G_OS_WIN32 - UnmapViewOfFile((void*) cache_data); -#else munmap(cache_data, map_len); -#endif } fclose(fp); if (error) { diff --git a/src/news.c b/src/news.c @@ -1026,10 +1026,6 @@ static gchar *news_item_get_path(Folder *folder, FolderItem *item) folder_path, NULL); } g_free(folder_path); -#ifdef G_OS_WIN32 - while (strchr(path, '/')) - *strchr(path, '/') = '\\'; -#endif return path; } diff --git a/src/password.c b/src/password.c @@ -27,13 +27,8 @@ #include <glib.h> #include <glib/gi18n.h> -#if defined G_OS_UNIX #include <fcntl.h> #include <unistd.h> -#elif defined G_OS_WIN32 -#include <windows.h> -#include <wincrypt.h> -#endif #include "common/passcrypt.h" #include "common/pkcs5_pbkdf2.h" diff --git a/src/pop.c b/src/pop.c @@ -644,8 +644,8 @@ Session *pop3_session_new(PrefsAccount *account) debug_print("POP - Oauth2 name: %s Two stage POP: %i\n", oa2->oa2_name, oa2->oa2_two_stage_pop); session->two_stage_pop = oa2->oa2_two_stage_pop; } -#endif - +#endif + return SESSION(session); } @@ -810,9 +810,6 @@ gint pop3_write_uidl_list(Pop3Session *session) goto err_write; } fp = NULL; -#ifdef G_OS_WIN32 - unlink(path); -#endif if (g_rename(tmp_path, path) < 0) { FILE_OP_ERROR(path, "rename"); goto err_write; diff --git a/src/prefs_account.c b/src/prefs_account.c @@ -23,13 +23,8 @@ #include "defs.h" -#ifdef G_OS_WIN32 -#include <winsock2.h> -#include <ws2tcpip.h> -#else #include <sys/socket.h> #include <netinet/in.h> -#endif #include <glib.h> #include <glib/gi18n.h> @@ -370,10 +365,8 @@ typedef struct AdvancedPage GtkWidget *crosspost_checkbtn; GtkWidget *crosspost_colormenu; -#ifndef G_OS_WIN32 GtkWidget *tunnelcmd_checkbtn; GtkWidget *tunnelcmd_entry; -#endif GtkWidget *sent_folder_checkbtn; GtkWidget *sent_folder_entry; @@ -1024,7 +1017,6 @@ static PrefParam advanced_param[] = { NULL, NULL, NULL}, #endif -#ifndef G_OS_WIN32 {"set_tunnelcmd", "FALSE", &tmp_ac_prefs.set_tunnelcmd, P_BOOL, &advanced_page.tunnelcmd_checkbtn, prefs_set_data_from_toggle, prefs_set_toggle}, @@ -1032,7 +1024,6 @@ static PrefParam advanced_param[] = { {"tunnelcmd", NULL, &tmp_ac_prefs.tunnelcmd, P_STRING, &advanced_page.tunnelcmd_entry, prefs_set_data_from_entry, prefs_set_entry}, -#endif {"mark_crosspost_read", "FALSE", &tmp_ac_prefs.mark_crosspost_read, P_BOOL, &advanced_page.crosspost_checkbtn, prefs_set_data_from_toggle, prefs_set_toggle}, @@ -3355,10 +3346,8 @@ static void advanced_create_widget_func(PrefsPage * _page, gchar *tip_domain; GtkWidget *checkbtn_crosspost; GtkWidget *colormenu_crosspost; -#ifndef G_OS_WIN32 GtkWidget *checkbtn_tunnelcmd; GtkWidget *entry_tunnelcmd; -#endif GtkWidget *folder_frame; GtkWidget *vbox3; GtkWidget *table; @@ -3436,7 +3425,6 @@ static void advanced_create_widget_func(PrefsPage * _page, SET_TOGGLE_SENSITIVITY (checkbtn_domain, entry_domain); CLAWS_SET_TIP(entry_domain, tip_domain); -#ifndef G_OS_WIN32 PACK_HBOX (hbox1); PACK_CHECK_BUTTON (hbox1, checkbtn_tunnelcmd, _("Use command to communicate with server")); @@ -3444,7 +3432,6 @@ static void advanced_create_widget_func(PrefsPage * _page, gtk_widget_show (entry_tunnelcmd); gtk_box_pack_start (GTK_BOX (hbox1), entry_tunnelcmd, TRUE, TRUE, 0); SET_TOGGLE_SENSITIVITY (checkbtn_tunnelcmd, entry_tunnelcmd); -#endif PACK_HBOX (hbox1); PACK_CHECK_BUTTON (hbox1, checkbtn_crosspost, @@ -3521,11 +3508,8 @@ static void advanced_create_widget_func(PrefsPage * _page, page->domain_entry = entry_domain; page->crosspost_checkbtn = checkbtn_crosspost; page->crosspost_colormenu = colormenu_crosspost; - -#ifndef G_OS_WIN32 page->tunnelcmd_checkbtn = checkbtn_tunnelcmd; page->tunnelcmd_entry = entry_tunnelcmd; -#endif page->sent_folder_checkbtn = sent_folder_checkbtn; page->sent_folder_entry = sent_folder_entry; page->queue_folder_checkbtn = queue_folder_checkbtn; @@ -5476,10 +5460,8 @@ static void prefs_account_protocol_changed(GtkComboBox *combobox, gpointer data) gtk_widget_show(advanced_page.nntpport_hbox); gtk_widget_show(advanced_page.crosspost_checkbtn); gtk_widget_show(advanced_page.crosspost_colormenu); -#ifndef G_OS_WIN32 gtk_widget_hide(advanced_page.tunnelcmd_checkbtn); gtk_widget_hide(advanced_page.tunnelcmd_entry); -#endif gtk_widget_hide(receive_page.imapdir_label); gtk_widget_hide(receive_page.imapdir_entry); gtk_widget_hide(receive_page.subsonly_checkbtn); @@ -5558,10 +5540,8 @@ static void prefs_account_protocol_changed(GtkComboBox *combobox, gpointer data) gtk_widget_hide(advanced_page.nntpport_hbox); gtk_widget_hide(advanced_page.crosspost_checkbtn); gtk_widget_hide(advanced_page.crosspost_colormenu); -#ifndef G_OS_WIN32 gtk_widget_hide(advanced_page.tunnelcmd_checkbtn); gtk_widget_hide(advanced_page.tunnelcmd_entry); -#endif gtk_widget_hide(receive_page.imapdir_label); gtk_widget_hide(receive_page.imapdir_entry); gtk_widget_hide(receive_page.subsonly_checkbtn); @@ -5649,10 +5629,8 @@ static void prefs_account_protocol_changed(GtkComboBox *combobox, gpointer data) gtk_widget_hide(advanced_page.nntpport_hbox); gtk_widget_hide(advanced_page.crosspost_checkbtn); gtk_widget_hide(advanced_page.crosspost_colormenu); -#ifndef G_OS_WIN32 gtk_widget_show(advanced_page.tunnelcmd_checkbtn); gtk_widget_show(advanced_page.tunnelcmd_entry); -#endif gtk_widget_show(receive_page.imapdir_label); gtk_widget_show(receive_page.imapdir_entry); gtk_widget_show(receive_page.subsonly_checkbtn); @@ -5729,10 +5707,8 @@ static void prefs_account_protocol_changed(GtkComboBox *combobox, gpointer data) gtk_widget_hide(advanced_page.nntpport_hbox); gtk_widget_hide(advanced_page.crosspost_checkbtn); gtk_widget_hide(advanced_page.crosspost_colormenu); -#ifndef G_OS_WIN32 gtk_widget_hide(advanced_page.tunnelcmd_checkbtn); gtk_widget_hide(advanced_page.tunnelcmd_entry); -#endif gtk_widget_hide(receive_page.imapdir_label); gtk_widget_hide(receive_page.imapdir_entry); gtk_widget_hide(receive_page.subsonly_checkbtn); @@ -5816,10 +5792,8 @@ static void prefs_account_protocol_changed(GtkComboBox *combobox, gpointer data) gtk_widget_hide(advanced_page.nntpport_hbox); gtk_widget_hide(advanced_page.crosspost_checkbtn); gtk_widget_hide(advanced_page.crosspost_colormenu); -#ifndef G_OS_WIN32 gtk_widget_hide(advanced_page.tunnelcmd_checkbtn); gtk_widget_hide(advanced_page.tunnelcmd_entry); -#endif gtk_widget_hide(receive_page.imapdir_label); gtk_widget_hide(receive_page.imapdir_entry); gtk_widget_hide(receive_page.subsonly_checkbtn); @@ -6019,39 +5993,21 @@ void prefs_account_unregister_page(PrefsPage *page) gchar *prefs_account_cache_dir(PrefsAccount *ac_prefs, gboolean for_server) { gchar *dir = NULL; -#ifdef G_OS_WIN32 - gchar *sanitized_server; -#endif if (ac_prefs->protocol == A_IMAP4) { -#ifdef G_OS_WIN32 - sanitized_server = g_strdup(ac_prefs->recv_server); - g_strdelimit(sanitized_server, ":", ','); -#endif if (for_server) { dir = g_strconcat(get_imap_cache_dir(), G_DIR_SEPARATOR_S, -#ifdef G_OS_WIN32 - sanitized_server, -#else ac_prefs->recv_server, -#endif NULL); } else { dir = g_strconcat(get_imap_cache_dir(), G_DIR_SEPARATOR_S, -#ifdef G_OS_WIN32 - sanitized_server, -#else ac_prefs->recv_server, -#endif G_DIR_SEPARATOR_S, ac_prefs->userid, NULL); } -#ifdef G_OS_WIN32 - g_free(sanitized_server); -#endif } return dir; diff --git a/src/prefs_account.h b/src/prefs_account.h @@ -193,7 +193,6 @@ struct _PrefsAccount gboolean mark_crosspost_read; gint crosspost_col; -#ifndef G_OS_WIN32 /* Use this command to open a socket, rather than doing so * directly. Good if you want to perhaps use a special socks * tunnel command, or run IMAP-over-SSH. In this case the @@ -204,7 +203,6 @@ struct _PrefsAccount * as a particular user. */ gboolean set_tunnelcmd; gchar *tunnelcmd; -#endif gchar *imap_dir; gboolean imap_subsonly; diff --git a/src/prefs_common.c b/src/prefs_common.c @@ -74,75 +74,6 @@ PrefsCommon prefs_common; GtkWidget *notebook; -#ifdef G_OS_WIN32 -/* - * In the Windows version prefs_common contains - * - the non-OS-specific settings of the "Common" section and - * - the OS-specific settings of the "CommonWin32" section - * The OS-specific settings of the "Common" section are not used - * but saved in prefs_unix. - */ - -# define SPECIFIC_PREFS prefs_unix - -static PrefsCommon prefs_unix; - -static PrefParam param_os_specific[] = { - /* Receive */ - {"ext_inc_path", "", - &prefs_common.extinc_cmd, P_STRING, NULL, NULL, NULL}, - {"newmail_notify_cmd", "", - &prefs_common.newmail_notify_cmd, P_STRING, NULL, NULL, NULL}, - - /* new fonts */ - {"message_font_gtk2", "Monospace 9", - &prefs_common.textfont, P_STRING, NULL, NULL, NULL}, - {"print_font_gtk2", "Monospace 9", - &prefs_common.printfont, P_STRING, NULL, NULL, NULL}, - {"small_font_gtk2", "Sans 9", - &prefs_common.smallfont, P_STRING, NULL, NULL, NULL}, - {"normal_font_gtk2", "Sans 9", - &prefs_common.normalfont, P_STRING, NULL, NULL, NULL}, - {"bold_font_gtk2", "Sans 9 Bold", - &prefs_common.boldfont, P_STRING, NULL, NULL, NULL}, - /* Message */ - {"attach_save_directory", NULL, - &prefs_common.attach_save_dir, P_STRING, NULL, NULL, NULL}, - {"attach_save_chmod", "", - &prefs_common.attach_save_chmod, P_INT, NULL, NULL, NULL}, - {"attach_load_directory", NULL, - &prefs_common.attach_load_dir, P_STRING, NULL, NULL, NULL}, - - /* MIME viewer */ - {"mime_textviewer", NULL, - &prefs_common.mime_textviewer, P_STRING, NULL, NULL, NULL}, - {"mime_open_command", "notepad '%s'", - &prefs_common.mime_open_cmd, P_STRING, NULL, NULL, NULL}, - - /* Interface */ - {"pixmap_theme_path", DEFAULT_PIXMAP_THEME, - &prefs_common.pixmap_theme_path, P_STRING, NULL, NULL, NULL}, -#ifdef HAVE_SVG - {"enable_alpha_svg", "TRUE", - &prefs_common.enable_alpha_svg, P_BOOL, NULL, NULL, NULL}, - {"enable_pixmap_scaling", "TRUE", - &prefs_common.enable_pixmap_scaling, P_BOOL, NULL, NULL, NULL}, - {"pixmap_scaling_auto", "TRUE", - &prefs_common.pixmap_scaling_auto, P_BOOL, NULL, NULL, NULL}, - {"pixmap_scaling_ppi", "96", - &prefs_common.pixmap_scaling_ppi, P_INT, NULL, NULL, NULL}, -#endif - - /* Other */ - {"ext_editor_command", "notepad %s", - &prefs_common.ext_editor_cmd, P_STRING, NULL, NULL, NULL}, - - {NULL, NULL, NULL, P_OTHER, NULL, NULL, NULL} -}; -#else -# define SPECIFIC_PREFS prefs_common -#endif - /* parameter name, default value, pointer to the prefs variable, data type, pointer to the widget pointer, @@ -157,7 +88,7 @@ static PrefParam param[] = { /* Receive */ {"use_ext_inc", "FALSE", &prefs_common.use_extinc, P_BOOL, NULL, NULL, NULL}, - {"ext_inc_path", DEFAULT_INC_PATH, &SPECIFIC_PREFS.extinc_cmd, P_STRING, + {"ext_inc_path", DEFAULT_INC_PATH, &prefs_common.extinc_cmd, P_STRING, NULL, NULL, NULL}, {"autochk_newmail", "FALSE", &prefs_common.autochk_newmail, P_BOOL, @@ -174,7 +105,7 @@ static PrefParam param[] = { P_BOOL, NULL, NULL, NULL}, {"newmail_notify_auto", "FALSE", &prefs_common.newmail_notify_auto, P_BOOL, NULL, NULL, NULL}, - {"newmail_notify_cmd", "", &SPECIFIC_PREFS.newmail_notify_cmd, P_STRING, + {"newmail_notify_cmd", "", &prefs_common.newmail_notify_cmd, P_STRING, NULL, NULL, NULL}, {"receive_dialog_mode", "2", &prefs_common.recv_dialog_mode, P_ENUM, NULL, NULL, NULL}, @@ -317,15 +248,15 @@ static PrefParam param[] = { /* Display */ {"message_font_gtk2", "Monospace 9", - &SPECIFIC_PREFS.textfont, P_STRING, NULL, NULL, NULL}, + &prefs_common.textfont, P_STRING, NULL, NULL, NULL}, {"print_font_gtk2", "Monospace 9", - &SPECIFIC_PREFS.printfont, P_STRING, NULL, NULL, NULL}, + &prefs_common.printfont, P_STRING, NULL, NULL, NULL}, {"small_font_gtk2", "Sans 9", - &SPECIFIC_PREFS.smallfont, P_STRING, NULL, NULL, NULL}, + &prefs_common.smallfont, P_STRING, NULL, NULL, NULL}, {"normal_font_gtk2", "Sans 9", - &SPECIFIC_PREFS.normalfont, P_STRING, NULL, NULL, NULL}, + &prefs_common.normalfont, P_STRING, NULL, NULL, NULL}, {"bold_font_gtk2", "Sans Bold 9", - &SPECIFIC_PREFS.boldfont, P_STRING, NULL, NULL, NULL}, + &prefs_common.boldfont, P_STRING, NULL, NULL, NULL}, {"use_different_print_font", "FALSE", &prefs_common.use_different_print_font, P_BOOL, NULL, NULL, NULL}, @@ -720,17 +651,17 @@ static PrefParam param[] = { {"attach_desc", "TRUE", &prefs_common.attach_desc, P_BOOL, NULL, NULL, NULL}, {"attach_save_directory", NULL, - &SPECIFIC_PREFS.attach_save_dir, P_STRING, NULL, NULL, NULL}, + &prefs_common.attach_save_dir, P_STRING, NULL, NULL, NULL}, {"attach_save_chmod", "", - &SPECIFIC_PREFS.attach_save_chmod, P_INT, NULL, NULL, NULL}, + &prefs_common.attach_save_chmod, P_INT, NULL, NULL, NULL}, {"attach_load_directory", NULL, - &SPECIFIC_PREFS.attach_load_dir, P_STRING, NULL, NULL, NULL}, + &prefs_common.attach_load_dir, P_STRING, NULL, NULL, NULL}, /* MIME viewer */ {"mime_textviewer", NULL, - &SPECIFIC_PREFS.mime_textviewer, P_STRING, NULL, NULL, NULL}, + &prefs_common.mime_textviewer, P_STRING, NULL, NULL, NULL}, {"mime_open_command", "xdg-open '%s'", - &SPECIFIC_PREFS.mime_open_cmd, P_STRING, NULL, NULL, NULL}, + &prefs_common.mime_open_cmd, P_STRING, NULL, NULL, NULL}, {"show_inline_attachments", "TRUE", &prefs_common.show_inline_attachments, P_BOOL, NULL, NULL, NULL}, @@ -798,20 +729,20 @@ static PrefParam param[] = { NULL, NULL, NULL}, {"pixmap_theme_path", DEFAULT_PIXMAP_THEME, - &SPECIFIC_PREFS.pixmap_theme_path, P_STRING, + &prefs_common.pixmap_theme_path, P_STRING, NULL, NULL, NULL}, #ifdef HAVE_SVG {"enable_alpha_svg", "TRUE", - &SPECIFIC_PREFS.enable_alpha_svg, P_BOOL, + &prefs_common.enable_alpha_svg, P_BOOL, NULL, NULL, NULL}, {"enable_pixmap_scaling", "TRUE", - &SPECIFIC_PREFS.enable_pixmap_scaling, P_BOOL, + &prefs_common.enable_pixmap_scaling, P_BOOL, NULL, NULL, NULL}, {"pixmap_scaling_auto", "TRUE", - &SPECIFIC_PREFS.pixmap_scaling_auto, P_BOOL, + &prefs_common.pixmap_scaling_auto, P_BOOL, NULL, NULL, NULL}, {"pixmap_scaling_ppi", "96", - &SPECIFIC_PREFS.pixmap_scaling_ppi, P_INT, + &prefs_common.pixmap_scaling_ppi, P_INT, NULL, NULL, NULL}, #endif @@ -836,15 +767,10 @@ static PrefParam param[] = { P_INT, NULL, NULL, NULL}, /* Other */ -#ifndef G_OS_WIN32 {"uri_open_command", DEFAULT_BROWSER_CMD, - &SPECIFIC_PREFS.uri_cmd, P_STRING, NULL, NULL, NULL}, -#else - {"gtk_theme", DEFAULT_W32_GTK_THEME, - &SPECIFIC_PREFS.gtk_theme, P_STRING, NULL, NULL, NULL}, -#endif + &prefs_common.uri_cmd, P_STRING, NULL, NULL, NULL}, {"ext_editor_command", DEFAULT_EDITOR_CMD, - &SPECIFIC_PREFS.ext_editor_cmd, P_STRING, NULL, NULL, NULL}, + &prefs_common.ext_editor_cmd, P_STRING, NULL, NULL, NULL}, {"cmds_use_system_default", "TRUE", &prefs_common.cmds_use_system_default, P_BOOL, NULL, NULL, NULL}, {"add_address_by_click", "FALSE", &prefs_common.add_address_by_click, @@ -1267,9 +1193,6 @@ void prefs_common_read_config(void) rcpath = g_strconcat(get_rc_dir(), G_DIR_SEPARATOR_S, COMMON_RC, NULL); prefs_read_config(param, "Common", rcpath, NULL); -#ifdef G_OS_WIN32 - prefs_read_config(param_os_specific, "CommonWin32", rcpath, NULL); -#endif g_free(rcpath); @@ -1346,9 +1269,6 @@ static void prefs_common_save_history_to_dir(const gchar *dirname, const gchar * goto out; } fp = NULL; -#ifdef G_OS_WIN32 - unlink(path); -#endif if (g_rename(tmp_path, path) < 0) { FILE_OP_ERROR(path, "rename"); goto out; @@ -1374,9 +1294,6 @@ static void prefs_common_save_history(const gchar *history, GList *list) void prefs_common_write_config(void) { prefs_write_config(param, "Common", COMMON_RC); -#ifdef G_OS_WIN32 - prefs_write_config(param_os_specific, "CommonWin32", COMMON_RC); -#endif prefs_common_save_history(COMMAND_HISTORY, prefs_common.mime_open_cmd_history); @@ -1598,9 +1515,6 @@ const gchar *prefs_common_translated_header_name(const gchar *header_name) const gchar *prefs_common_get_uri_cmd(void) { -#ifdef G_OS_WIN32 - return NULL; -#else gchar *tmp = NULL; if (!prefs_common.cmds_use_system_default) @@ -1612,7 +1526,6 @@ const gchar *prefs_common_get_uri_cmd(void) g_free(tmp); return "xdg-open %s"; -#endif } const gchar *prefs_common_get_ext_editor_cmd(void) diff --git a/src/prefs_common.h b/src/prefs_common.h @@ -428,11 +428,7 @@ struct _PrefsCommon gint apply_per_account_filtering_rules; /* Other */ -#ifndef G_OS_WIN32 gchar *uri_cmd; -#else - gchar *gtk_theme; -#endif gchar *ext_editor_cmd; gboolean cmds_use_system_default; diff --git a/src/prefs_ext_prog.c b/src/prefs_ext_prog.c @@ -48,11 +48,9 @@ typedef struct _ExtProgPage GtkWidget *window; /* do not modify */ GtkWidget *cmds_use_system_default_checkbtn; -#ifndef G_OS_WIN32 GtkWidget *uri_label; GtkWidget *uri_combo; GtkWidget *uri_entry; -#endif /* !G_OS_WIN32 */ GtkWidget *exteditor_label; GtkWidget *exteditor_combo; @@ -72,11 +70,9 @@ static void prefs_ext_prog_create_widget(PrefsPage *_page, GtkWindow *window, GtkWidget *hint_label; GtkWidget *table2; GtkWidget *cmds_use_system_default_checkbtn; -#ifndef G_OS_WIN32 GtkWidget *uri_label; GtkWidget *uri_combo; GtkWidget *uri_entry; -#endif /* !G_OS_WIN32 */ GtkWidget *exteditor_label; GtkWidget *exteditor_combo; GtkWidget *exteditor_entry; @@ -141,8 +137,6 @@ static void prefs_ext_prog_create_widget(PrefsPage *_page, GtkWindow *window, gtk_grid_attach(GTK_GRID(table2), cmds_use_system_default_checkbtn, 0, i, 2, 1); - -#ifndef G_OS_WIN32 uri_label = gtk_label_new (_("Web browser")); gtk_widget_show(uri_label); i++; @@ -167,7 +161,6 @@ static void prefs_ext_prog_create_widget(PrefsPage *_page, GtkWindow *window, uri_entry = gtk_bin_get_child(GTK_BIN((uri_combo))); gtk_entry_set_text(GTK_ENTRY(uri_entry), prefs_common.uri_cmd ? prefs_common.uri_cmd : ""); -#endif /* !G_OS_WIN32 */ exteditor_label = gtk_label_new (_("Text editor")); gtk_widget_show(exteditor_label); @@ -220,10 +213,8 @@ static void prefs_ext_prog_create_widget(PrefsPage *_page, GtkWindow *window, gtk_entry_set_text(GTK_ENTRY(astextviewer_entry), prefs_common.mime_textviewer ? prefs_common.mime_textviewer : ""); -#ifndef G_OS_WIN32 SET_TOGGLE_SENSITIVITY_REVERSE (cmds_use_system_default_checkbtn, uri_label); SET_TOGGLE_SENSITIVITY_REVERSE (cmds_use_system_default_checkbtn, uri_combo); -#endif /* !G_OS_WIN32 */ #if 0 /* we should do that, but it detaches the editor and breaks compose.c's external composition. */ @@ -232,9 +223,7 @@ static void prefs_ext_prog_create_widget(PrefsPage *_page, GtkWindow *window, #endif prefs_ext_prog->window = GTK_WIDGET(window); -#ifndef G_OS_WIN32 prefs_ext_prog->uri_entry = uri_entry; -#endif prefs_ext_prog->exteditor_entry = exteditor_entry; prefs_ext_prog->astextviewer_entry = astextviewer_entry; prefs_ext_prog->cmds_use_system_default_checkbtn = cmds_use_system_default_checkbtn; @@ -245,10 +234,8 @@ static void prefs_ext_prog_save(PrefsPage *_page) { ExtProgPage *ext_prog = (ExtProgPage *) _page; -#ifndef G_OS_WIN32 prefs_common.uri_cmd = gtk_editable_get_chars (GTK_EDITABLE(ext_prog->uri_entry), 0, -1); -#endif /* !G_OS_WIN32 */ prefs_common.ext_editor_cmd = gtk_editable_get_chars (GTK_EDITABLE(ext_prog->exteditor_entry), 0, -1); prefs_common.mime_textviewer = gtk_editable_get_chars diff --git a/src/prefs_spelling.c b/src/prefs_spelling.c @@ -95,9 +95,6 @@ static void prefs_spelling_create_widget(PrefsPage *_page, GtkWindow *window, gp GtkWidget *default_alt_dict_label; GtkWidget *default_alt_dict_combo; GtkWidget *both_dict_check; -#ifdef WIN32 - GtkWidget *get_dictionaries_btn; -#endif GtkWidget *misspelled_label; GtkWidget *misspelled_hbox; @@ -169,12 +166,6 @@ static void prefs_spelling_create_widget(PrefsPage *_page, GtkWindow *window, gp gtk_widget_show(both_dict_check); gtk_grid_attach(GTK_GRID(table), both_dict_check, 1, 2, 1, 1); -#ifdef WIN32 - get_dictionaries_btn = gtk_link_button_new_with_label( - DICTS_URI, _("Get more dictionaries...")); - gtk_widget_show(get_dictionaries_btn); - gtk_grid_attach(GTK_GRID(table), get_dictionaries_btn, 1, 3, 1, 1); -#endif misspelled_hbox = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 10); gtk_widget_show(misspelled_hbox); gtk_box_pack_start(GTK_BOX(vbox1), misspelled_hbox, FALSE, FALSE, 0); diff --git a/src/prefs_themes.c b/src/prefs_themes.c @@ -179,37 +179,13 @@ static void prefs_themes_file_install (const gchar *filename, gpointer data); static void prefs_themes_file_stats(const gchar *filename, gpointer data) { -#ifdef G_OS_WIN32 - GFile *f; - GFileInfo *fi; - GError *error = NULL; -#else + GStatBuf s; -#endif goffset size; DirInfo *di = (DirInfo *)data; gint len; gint i; -#ifdef G_OS_WIN32 - f = g_file_new_for_path(filename); - fi = g_file_query_info(f, "standard::size,standard::type", - G_FILE_QUERY_INFO_NONE, NULL, &error); - if (error != NULL) { - g_warning(error->message); - g_error_free(error); - g_object_unref(f); - return; - } - if (g_file_info_get_file_type(fi) != G_FILE_TYPE_REGULAR) { - g_object_unref(fi); - g_object_unref(f); - return; - } - size = g_file_info_get_size(fi); - g_object_unref(fi); - g_object_unref(f); -#else if ((i = g_stat(filename, &s)) != 0) { debug_print("g_stat on '%s' failed: %d\n", filename, i); return; @@ -218,7 +194,6 @@ static void prefs_themes_file_stats(const gchar *filename, gpointer data) return; } size = s.st_size; -#endif di->bytes += size; di->files++; diff --git a/src/procheader.c b/src/procheader.c @@ -418,43 +418,16 @@ void procheader_get_header_fields(FILE *fp, HeaderEntry hentry[]) MsgInfo *procheader_parse_file(const gchar *file, MsgFlags flags, gboolean full, gboolean decrypted) { -#ifdef G_OS_WIN32 - GFile *f; - GFileInfo *fi; - GTimeVal tv; - GError *error = NULL; -#else GStatBuf s; -#endif FILE *fp; MsgInfo *msginfo; -#ifdef G_OS_WIN32 - f = g_file_new_for_path(file); - fi = g_file_query_info(f, "standard::size,standard::type,time::modified", - G_FILE_QUERY_INFO_NONE, NULL, &error); - if (error != NULL) { - g_warning(error->message); - g_error_free(error); - g_object_unref(f); - } -#else if (g_stat(file, &s) < 0) { FILE_OP_ERROR(file, "stat"); return NULL; } -#endif - -#ifdef G_OS_WIN32 - if (g_file_info_get_file_type(fi) != G_FILE_TYPE_REGULAR) { - g_object_unref(fi); - g_object_unref(f); - return NULL; - } -#else if (!S_ISREG(s.st_mode)) return NULL; -#endif if ((fp = g_fopen(file, "rb")) == NULL) { FILE_OP_ERROR(file, "g_fopen"); @@ -465,21 +438,9 @@ MsgInfo *procheader_parse_file(const gchar *file, MsgFlags flags, fclose(fp); if (msginfo) { -#ifdef G_OS_WIN32 - msginfo->size = g_file_info_get_size(fi); - g_file_info_get_modification_time(fi, &tv); - msginfo->mtime = tv.tv_sec; -#else msginfo->size = s.st_size; msginfo->mtime = s.st_mtime; -#endif } - -#ifdef G_OS_WIN32 - g_object_unref(fi); - g_object_unref(f); -#endif - return msginfo; } @@ -1170,27 +1131,6 @@ time_t procheader_date_parse(gchar *dest, const gchar *src, gint len) break; } } - -#ifdef G_OS_WIN32 - GTimeZone *tz; - GDateTime *dt, *dt2; - -#if GLIB_CHECK_VERSION(2,68,0) - tz = g_time_zone_new_identifier(zone); - if (tz == NULL) - tz = g_time_zone_new_utc(); -#else - tz = g_time_zone_new(zone); // can't return NULL no need to check for it -#endif - dt = g_date_time_new(tz, 1, 1, 1, 0, 0, 0); - g_time_zone_unref(tz); - dt2 = g_date_time_add_full(dt, year-1, dmonth-1, day-1, hh, mm, ss); - g_date_time_unref(dt); - - timer = g_date_time_to_unix(dt2); - g_date_time_unref(dt2); - -#else struct tm t; time_t tz_offset; @@ -1217,7 +1157,6 @@ time_t procheader_date_parse(gchar *dest, const gchar *src, gint len) if (tz_offset != -1) timer += tzoffset_sec(&timer) - tz_offset; -#endif if (dest) procheader_date_get_localtime(dest, len, timer); diff --git a/src/procmime.c b/src/procmime.c @@ -54,14 +54,7 @@ #include "account.h" #include "file-utils.h" -#ifdef G_OS_WIN32 -#include "w32_reg.h" -#define REG_MIME_TYPE_VALUE "Content Type" -#endif - -#ifndef G_OS_WIN32 static GHashTable *procmime_get_mime_type_table (void); -#endif static MimeInfo *procmime_scan_file_short(const gchar *filename); static MimeInfo *procmime_scan_queue_file_short(const gchar *filename); static MimeInfo *procmime_scan_queue_file_full(const gchar *filename, gboolean short_scan); @@ -1069,7 +1062,6 @@ gchar *procmime_get_mime_type(const gchar *filename) gchar *ext = NULL; gchar *base; gchar *str; -#ifndef G_OS_WIN32 static GHashTable *mime_type_table = NULL; MimeType *mime_type; @@ -1077,23 +1069,17 @@ gchar *procmime_get_mime_type(const gchar *filename) mime_type_table = procmime_get_mime_type_table(); if (!mime_type_table) return NULL; } -#endif if (filename == NULL) return NULL; base = g_path_get_basename(filename); if ((p = strrchr(base, '.')) != NULL) -#ifndef G_OS_WIN32 ext = g_utf8_strdown(p + 1, -1); -#else - ext = g_utf8_strdown(p, -1); -#endif else ext = g_utf8_strdown(base, -1); g_free(base); -#ifndef G_OS_WIN32 mime_type = g_hash_table_lookup(mime_type_table, ext); if (mime_type) { @@ -1105,15 +1091,9 @@ gchar *procmime_get_mime_type(const gchar *filename) } g_free(ext); return NULL; -#else - str = read_w32_registry_string(HKEY_CLASSES_ROOT, ext, REG_MIME_TYPE_VALUE); - debug_print("got type %s for %s\n", str, ext); - g_free(ext); - return str; -#endif } -#ifndef G_OS_WIN32 + static guint procmime_str_hash(gconstpointer gptr) { guint hash_result = 0; @@ -1170,7 +1150,6 @@ static GHashTable *procmime_get_mime_type_table(void) return table; } -#endif GList *procmime_get_mime_type_list(void) { diff --git a/src/recv.c b/src/recv.c @@ -30,9 +30,7 @@ #include <string.h> #include <unistd.h> -#ifndef G_OS_WIN32 #include <sys/time.h> -#endif #include "recv.h" #include "socket.h" diff --git a/src/send_message.c b/src/send_message.c @@ -31,9 +31,7 @@ #include <string.h> #include <signal.h> #include <sys/types.h> -#ifndef G_OS_WIN32 #include <sys/wait.h> -#endif #include "send_message.h" #include "session.h" @@ -158,11 +156,7 @@ gint send_message_local(const gchar *command, FILE *fp) argv = strsplit_with_quote(command, " ", 0); if (g_spawn_async_with_pipes(NULL, argv, NULL, -#ifdef G_OS_WIN32 - 0, -#else G_SPAWN_DO_NOT_REAP_CHILD, -#endif NULL, NULL, &pid, &child_stdin, NULL, NULL, NULL) == FALSE) { @@ -190,14 +184,12 @@ gint send_message_local(const gchar *command, FILE *fp) } } - fd_close(child_stdin); + close(child_stdin); -#ifndef G_OS_WIN32 gint status; waitpid(pid, &status, 0); if (!WIFEXITED(status) || WEXITSTATUS(status) != 0) err = TRUE; -#endif g_spawn_close_pid(pid); diff --git a/src/stock_pixmap.c b/src/stock_pixmap.c @@ -867,19 +867,11 @@ static void stock_pixmap_find_themes_in_dir(GList **list, const gchar *dirname) gchar *stock_pixmap_get_system_theme_dir_for_theme(const gchar *theme) { if (theme && *theme) { -#ifndef G_OS_WIN32 return g_strconcat(PACKAGE_DATA_DIR, G_DIR_SEPARATOR_S, PIXMAP_THEME_DIR, G_DIR_SEPARATOR_S, theme, NULL); -#else - return g_strconcat(w32_get_themes_dir(), G_DIR_SEPARATOR_S, theme, NULL); -#endif } else { -#ifndef G_OS_WIN32 return g_strconcat(PACKAGE_DATA_DIR, G_DIR_SEPARATOR_S, PIXMAP_THEME_DIR, NULL); -#else - return g_strdup(w32_get_themes_dir()); -#endif } } diff --git a/src/textview.c b/src/textview.c @@ -974,7 +974,6 @@ void textview_show_mime_part(TextView *textview, MimeInfo *partinfo) TEXTVIEW_INSERT(_("')\n")); TEXTVIEW_INSERT(_(" (alternately double-click, or click the middle ")); TEXTVIEW_INSERT(_("mouse button)\n")); -#ifndef G_OS_WIN32 TEXTVIEW_INSERT(_(" - Or use ")); TEXTVIEW_INSERT_LINK(_("'Open with...'"), "cm://open_with", NULL); TEXTVIEW_INSERT(_(" (Shortcut key: '")); @@ -982,7 +981,6 @@ void textview_show_mime_part(TextView *textview, MimeInfo *partinfo) TEXTVIEW_INSERT(shortcut); g_free(shortcut); TEXTVIEW_INSERT(_("')")); -#endif TEXTVIEW_INSERT("\n"); textview_show_icon(textview, "dialog-information"); @@ -994,9 +992,7 @@ static void textview_write_body(TextView *textview, MimeInfo *mimeinfo) gchar buf[BUFFSIZE]; CodeConverter *conv; const gchar *charset; -#ifndef G_OS_WIN32 const gchar *p, *cmd; -#endif GSList *cur; gboolean continue_write = TRUE; glong wrote = 0, i = 0; @@ -1065,7 +1061,6 @@ static void textview_write_body(TextView *textview, MimeInfo *mimeinfo) unlink(filename); } g_free(filename); -#ifndef G_OS_WIN32 } else if ( g_ascii_strcasecmp(mimeinfo->subtype, "plain") && (cmd = prefs_common.mime_textviewer) && *cmd && (p = strchr(cmd, '%')) && *(p + 1) == 's') { @@ -1128,11 +1123,8 @@ static void textview_write_body(TextView *textview, MimeInfo *mimeinfo) fclose(tmpfp); waitpid(pid, pfd, 0); g_unlink(fname); -#endif } else { -#ifndef G_OS_WIN32 textview_default: -#endif if (!g_ascii_strcasecmp(mimeinfo->subtype, "x-patch") || !g_ascii_strcasecmp(mimeinfo->subtype, "x-diff")) textview->is_diff = TRUE; diff --git a/src/w32-logo.ico b/src/w32-logo.ico Binary files differ. diff --git a/src/w32-resource.rc.in b/src/w32-resource.rc.in @@ -1,36 +0,0 @@ -#include <winver.h> - -1 ICON "w32-logo.ico" - -VS_VERSION_INFO VERSIONINFO -FILEVERSION @MAJOR_VERSION@,@MINOR_VERSION@,@MICRO_VERSION@,@EXTRA_VERSION@ -PRODUCTVERSION @MAJOR_VERSION@,@MINOR_VERSION@,@MICRO_VERSION@,@EXTRA_VERSION@ -FILEFLAGSMASK VS_FFI_FILEFLAGSMASK -FILEFLAGS 0x0L -FILEOS VOS_NT_WINDOWS32 -FILETYPE VFT_APP -FILESUBTYPE 0x0L -BEGIN - BLOCK "StringFileInfo" - BEGIN - BLOCK "040904b0" - BEGIN -// VALUE "Comments", "" - VALUE "CompanyName", "The Claws Mail Team" - VALUE "FileDescription", "Claws Mail" - VALUE "FileVersion", "@VERSION@" - VALUE "InternalName", "claws-mail" - VALUE "LegalCopyright", "GPL-3.0-or-later / © 1999-2021 The Claws Mail Team & Hiroyuki Yamamoto" -// VALUE "LegalTrademarks", "" - VALUE "OriginalFilename", "claws-mail.exe" -// VALUE "PrivateBuild", "" - VALUE "ProductName", "Claws Mail" - VALUE "ProductVersion", "@GIT_VERSION@ for Windows" -// VALUE "SpecialBuild", "" - END - END - BLOCK "VarFileInfo" - BEGIN - VALUE "Translation", 0x0409, 1200 - END -END diff --git a/src/wizard.c b/src/wizard.c @@ -436,21 +436,7 @@ static void initialize_fonts(WizardWindow *wizard) gtk_widget_get_style(widget)->font_desc) /PANGO_SCALE; gchar *tmp, *new; -#ifdef G_OS_WIN32 - PangoFontDescription *bold_desc; - gchar *curfont = pango_font_description_to_string( - gtk_widget_get_style(widget)->font_desc); - g_free(prefs_common.smallfont); - g_free(prefs_common.normalfont); - g_free(prefs_common.boldfont); - prefs_common.smallfont = g_strdup(curfont); - prefs_common.normalfont = g_strdup(curfont); - bold_desc = pango_font_description_from_string(curfont); - pango_font_description_set_weight(bold_desc, PANGO_WEIGHT_BOLD); - prefs_common.boldfont = pango_font_description_to_string(bold_desc); - pango_font_description_free(bold_desc); - g_free(curfont); -#endif + tmp = g_strdup(prefs_common.textfont); if (strrchr(tmp, ' ')) { *(strrchr(tmp, ' ')) = '\0';