Fix patch.
[gpg4win.git] / patches / claws-mail-2.10.0 / 03-w32-port.patch
1 #! /bin/sh
2 patch -p1 -f $* < $0
3 exit $?
4
5 2007-05-21  Werner Koch  <wk@g10code.com>
6 2007-06-30  Marcus Brinkmann  <marcus@g10code.de>
7
8         * autogen.sh [--build-w32]: Disable bogofilter-plugin and
9         valgrind.
10         * src/common/w32lib.h: Undef "interface".
11         (w32_is_administrator): New prototype.
12         (gmtime_r, ctime_r, localtime_r, asctime_r): New macros.
13         * src/common/Makefile.am (arch_sources): Add w32_account.c.
14         * src/common/w32_account.c: New.
15         * src/common/utils.c (copy_dir) [W32]: Don't use symlinks.
16         (superuser_p): New.
17         * src/common/utils.h (superuser_p): New prototype.
18         * src/prefs_themes.c (prefs_themes_btn_remove_clicked_cb) 
19         (prefs_themes_btn_install_clicked_cb): Replace getuid based test
20         by superuser_p.
21         * src/common/timing.h [G_OS_WIN32]: Include w32lib.h and implement
22         timing macros.
23         * src/gtk/Makefile.am (AM_CPPFLAGS): Add -I../common for version.h.
24         * src/Makefile.am (INCLUDES): Add -Icommon for version.h.
25         * src/msgcache.c [G_OS_WIN32]: Include w32lib.h instead of
26         sys/mman.h and define MAP_FAILED.
27         (msgcache_read_cache, msgcache_read_mark, msgcache_write)
28         [G_OS_WIN32]: Implement memory mapped file access.
29         * src/common/log.c [G_OS_WIN32]: Include <w32lib.h>.
30         * src/common/src/mbox.c [G_OS_WIN32]: Include <w32lib.h>.
31         * src/prefs_summaries.c [G_OS_WIN32]: Include <w32lib.h>.
32         * src/procheader.c [G_OS_WIN32]: Include <w32lib.h>.
33
34         * src/plugins/pgpcore/Makefile.am (INCLUDES): Add
35         -I$(top_builddir)/src/common.
36         * src/plugins/pgpcore/claws.def: Update.
37         * src/plugins/pgpcore/passphrase.c: Include w32lib.h instead of
38         windows.h.  This so that we can fix problems in windows.h.
39         * src/plugins/pgpcore/sgpgme.c [G_OS_WIN32]: Do not include
40         sys/wait.h.
41         * src/plugins/pgpcore/pgp_viewer.c: Ditto.
42         * src/plugins/pgpcore/plugin.def: Add
43         sgpgme_data_release_and_get_mem, prefs_gpg_enable_agent,
44         prefs_gpg_should_skip_encryption_warning,
45         prefs_gpg_add_skip_encryption_warning,
46         prefs_gpg_remove_skip_encryption_warning and plugin_provides.
47
48         * src/plugins/pgpinline/Makefile.am (INCLUDES): Add
49         -I$(top_builddir)/src/common.
50         * src/plugins/pgpinline/plugin.def: Add plugin_provides.
51         * src/plugins/pgpinline/claws.def: Update.
52         * src/plugins/pgpinline/mypgpcore.def: Update.
53
54         * src/plugins/pgpmime/Makefile.am (INCLUDES): Add
55         -I$(top_builddir)/src/common.
56         * src/plugins/pgpmime/plugin.def: Add plugin_provides.
57         * src/plugins/pgpmime/claws.def: Update.
58         * src/plugins/pgpmime/mypgpcore.def: Update.
59
60
61 diff -rupN claws-mail-2.10.0-orig/autogen.sh claws-mail-2.10.0/autogen.sh
62 --- claws-mail-2.10.0-orig/autogen.sh   2007-07-02 10:32:22.000000000 +0200
63 +++ claws-mail-2.10.0/autogen.sh        2007-07-03 18:31:59.000000000 +0200
64 @@ -40,6 +40,7 @@ if test "$1" = "--build-w32"; then
65               --disable-openssl --disable-dillo-viewer-plugin \
66               --disable-nls --disable-libetpan --disable-aspell \
67               --disable-trayicon-plugin --disable-spamassassin-plugin \
68 +             --disable-bogofilter-plugin --disable-valgrind \
69               PKG_CONFIG_LIBDIR="$w32root/lib/pkgconfig"
70  
71      rc=$?
72 diff -rupN claws-mail-2.10.0-orig/src/common/log.c claws-mail-2.10.0/src/common/log.c
73 --- claws-mail-2.10.0-orig/src/common/log.c     2007-07-02 10:32:17.000000000 +0200
74 +++ claws-mail-2.10.0/src/common/log.c  2007-07-03 18:31:59.000000000 +0200
75 @@ -23,6 +23,10 @@
76  
77  #include "defs.h"
78  
79 +#ifdef G_OS_WIN32
80 +#  include <w32lib.h>
81 +#endif
82 +
83  #include <stdio.h>
84  #include <glib.h>
85  #include <glib/gi18n.h>
86 diff -rupN claws-mail-2.10.0-orig/src/common/Makefile.am claws-mail-2.10.0/src/common/Makefile.am
87 --- claws-mail-2.10.0-orig/src/common/Makefile.am       2007-07-02 10:32:17.000000000 +0200
88 +++ claws-mail-2.10.0/src/common/Makefile.am    2007-07-03 18:31:59.000000000 +0200
89 @@ -5,7 +5,7 @@ if OS_WIN32
90  arch_sources = fnmatch.c \
91                 w32_dirent.c w32_reg.c w32_signal.c w32_stat.c \
92                 w32_stdio.c w32_stdlib.c w32_string.c w32_time.c \
93 -               w32_unistd.c w32_wait.c
94 +               w32_unistd.c w32_wait.c w32_account.c
95  arch_headers = fnmatch.h w32lib.h
96  else
97  arch_files = 
98 diff -rupN claws-mail-2.10.0-orig/src/common/timing.h claws-mail-2.10.0/src/common/timing.h
99 --- claws-mail-2.10.0-orig/src/common/timing.h  2007-07-02 10:32:18.000000000 +0200
100 +++ claws-mail-2.10.0/src/common/timing.h       2007-07-03 18:31:59.000000000 +0200
101 @@ -29,6 +29,7 @@
102  #ifndef __TIMING_H__
103  #define __TIMING_H__
104  
105 +#include <glib.h>
106  #include <sys/time.h>
107  #ifdef HAVE_CONFIG_H
108  #  include "config.h"
109 @@ -49,13 +50,38 @@
110  #define START_TIMING(str) do {} while(0);
111  #define END_TIMING() do {} while(0);
112  #else
113 +
114 +#ifdef G_OS_WIN32
115 +
116 +#include <w32lib.h>
117 +
118 +/* no {} by purpose */
119 +#define START_TIMING(str)                                              \
120 +        LARGE_INTEGER frequency;                                       \
121 +       LARGE_INTEGER start;                                            \
122 +       LARGE_INTEGER end;                                              \
123 +       LARGE_INTEGER diff;                                             \
124 +       const char *timing_name=str;                                    \
125 +       QueryPerformanceFrequency (&frequency);                         \
126 +       QueryPerformanceCounter (&start);                               \
127 +
128 +#define END_TIMING()                                                   \
129 +       QueryPerformanceCounter (&end);                                 \
130 +        diff.QuadPart = (double)                                       \
131 +               ((end.QuadPart - start.QuadPart)        \
132 +               * (double)1000.0/(double)frequency.QuadPart);           \
133 +        debug_print("TIMING %s: %ds%03dms\n",                          \
134 +               timing_name, (unsigned int) (diff.QuadPart / 1000000),  \
135 +               (unsigned int) ((diff.QuadPart / 1000) % 1000));
136 +
137 +#else
138  /* no {} by purpose */
139  #define START_TIMING(str)                                              \
140         struct timeval start;                                           \
141         struct timeval end;                                             \
142         struct timeval diff;                                            \
143         const char *timing_name=str;                                    \
144 -       gettimeofday(&start, NULL);                                     \
145 +       gettimeofday(&start, NULL);
146  
147  #ifdef __GLIBC__
148  #define END_TIMING()                                                   \
149 @@ -64,7 +90,7 @@
150         debug_print("TIMING %s %s: %ds%03dms\n",                        \
151                 __FUNCTION__,                                           \
152                 timing_name, (unsigned int)diff.tv_sec,                 \
153 -               (unsigned int)diff.tv_usec/1000);                       
154 +               (unsigned int)diff.tv_usec/1000);
155  #else
156  #define END_TIMING()                                                   \
157         gettimeofday(&end, NULL);                                       \
158 @@ -76,3 +102,4 @@
159  
160  #endif 
161  #endif 
162 +#endif
163 diff -rupN claws-mail-2.10.0-orig/src/common/utils.c claws-mail-2.10.0/src/common/utils.c
164 --- claws-mail-2.10.0-orig/src/common/utils.c   2007-07-02 10:32:18.000000000 +0200
165 +++ claws-mail-2.10.0/src/common/utils.c        2007-07-03 18:31:59.000000000 +0200
166 @@ -57,6 +57,7 @@
167  #  include <direct.h>
168  #  include <io.h>
169  #  include <fcntl.h>
170 +#  include <w32lib.h>
171  #endif
172  
173  #ifdef MAEMO
174 @@ -75,6 +76,18 @@ static gboolean debug_mode = FALSE;
175  static GSList *tempfiles=NULL;
176  #endif
177  
178 +/* Return true if we are running as root.  This function should beused
179 +   instead of getuid () == 0.  */
180 +gboolean superuser_p (void)
181 +{
182 +#ifdef G_OS_WIN32
183 +  return w32_is_administrator ();
184 +#else
185 +  return !getuid();
186 +#endif  
187 +}
188 +
189 +
190  
191  #if !GLIB_CHECK_VERSION(2, 7, 0) && !defined(G_OS_UNIX)
192  gint g_chdir(const gchar *path)
193 @@ -4766,7 +4779,12 @@ gint copy_dir(const gchar *src, const gc
194                                 g_dir_close(dir);
195                                 return r;
196                         }
197 -               } else if (g_file_test(old_file, G_FILE_TEST_IS_SYMLINK)) {
198 +                }
199 +#ifndef G_OS_WIN32
200 +                /* Windows has no symlinks.  Or well, Vista seems to
201 +                   have something like this but the semantics might be
202 +                   different.  Thus we don't use it under Windows. */
203 +                else if (g_file_test(old_file, G_FILE_TEST_IS_SYMLINK)) {
204                         GError *error;
205                         gint r = 0;
206                         gchar *target = g_file_read_link(old_file, &error);
207 @@ -4777,7 +4795,9 @@ gint copy_dir(const gchar *src, const gc
208                                 g_dir_close(dir);
209                                 return r;
210                         }
211 -               } else if (g_file_test(old_file, G_FILE_TEST_IS_DIR)) {
212 +                 }
213 +#endif /*G_OS_WIN32*/
214 +               else if (g_file_test(old_file, G_FILE_TEST_IS_DIR)) {
215                         gint r = copy_dir(old_file, new_file);
216                         if (r < 0) {
217                                 g_dir_close(dir);
218 diff -rupN claws-mail-2.10.0-orig/src/common/utils.h claws-mail-2.10.0/src/common/utils.h
219 --- claws-mail-2.10.0-orig/src/common/utils.h   2007-07-02 10:32:18.000000000 +0200
220 +++ claws-mail-2.10.0/src/common/utils.h        2007-07-03 18:31:59.000000000 +0200
221 @@ -204,6 +204,14 @@ gboolean debug_get_mode            (void);
222  #define Str(x) #x
223  #define Xstr(x)        Str(x)
224  
225 +
226 +/* System related stuff.  */
227 +
228 +gboolean superuser_p (void);
229 +
230 +
231 +/* String utilities.  */
232 +
233  void list_free_strings         (GList          *list);
234  void slist_free_strings                (GSList         *list);
235  
236 diff -rupN claws-mail-2.10.0-orig/src/common/w32_account.c claws-mail-2.10.0/src/common/w32_account.c
237 --- claws-mail-2.10.0-orig/src/common/w32_account.c     1970-01-01 01:00:00.000000000 +0100
238 +++ claws-mail-2.10.0/src/common/w32_account.c  2007-07-03 18:31:59.000000000 +0200
239 @@ -0,0 +1,149 @@
240 +/* w32_account.c - Account related W32 functions.
241 +   Copyright (C) 2007 g10 Code GmbH 
242 +   Copyright (C) 1999-2005 Nullsoft, Inc.
243 +
244 +   This software is provided 'as-is', without any express or implied
245 +   warranty. In no event will the authors be held liable for any
246 +   damages arising from the use of this software.
247 +   
248 +   Permission is granted to anyone to use this software for any
249 +   purpose, including commercial applications, and to alter it and
250 +   redistribute it freely, subject to the following restrictions:
251 +   
252 +   1. The origin of this software must not be misrepresented; you must
253 +      not claim that you wrote the original software. If you use this
254 +      software in a product, an acknowledgment in the product
255 +      documentation would be appreciated but is not required.
256 +   
257 +   2. Altered source versions must be plainly marked as such, and must
258 +      not be misrepresented as being the original software.
259 +   
260 +   3. This notice may not be removed or altered from any source
261 +      distribution.
262 +
263 + =======[ wk 2007-05-21 ]====
264 +   The code for get_group_name has been taken from NSIS 2.05, module
265 +   UserInfo.c.  NSIS bears the above license and along with the
266 +   notice:
267 +     This license applies to everything in the NSIS package, except where
268 +     otherwise noted.
269 +   Thus we make this module available under the same license - note,
270 +   that this lincese is fully compatibe with the GNU GPL 2.0.
271 +*/ 
272 +  
273 +  
274 +
275 +
276 +#include <stdlib.h>
277 +#include <string.h>
278 +
279 +#include "w32lib.h"
280 +
281 +#ifndef DIM
282 +#define DIM(v)  (sizeof(v)/sizeof((v)[0]))
283 +#endif
284 +
285 +
286 +/* Return a malloced name of our user group.  */
287 +static char *
288 +get_group_name (void)
289 +{
290 +  HANDLE        hThread;
291 +  TOKEN_GROUPS  *ptg = NULL;
292 +  DWORD         cbTokenGroups;
293 +  DWORD         i, j;
294 +  SID_IDENTIFIER_AUTHORITY SystemSidAuthority = { SECURITY_NT_AUTHORITY };
295 +  char *group;
296 +  struct
297 +  {
298 +    DWORD auth_id;
299 +    char *name;
300 +  } groups[] = 
301 +    {
302 +      /* Every user belongs to the users group, hence
303 +         users comes before guests */
304 +      {DOMAIN_ALIAS_RID_USERS, "User"},
305 +      {DOMAIN_ALIAS_RID_GUESTS, "Guest"},
306 +      {DOMAIN_ALIAS_RID_POWER_USERS, "Power"},
307 +      {DOMAIN_ALIAS_RID_ADMINS, "Admin"}
308 +    };
309 +
310 +
311 +  group = NULL;
312 +  if (GetVersion() & 0x80000000) 
313 +    {
314 +      /* This is not NT; thus we are always Admin. */
315 +      group = "Admin";
316 +    }
317 +  else if (OpenThreadToken(GetCurrentThread(), TOKEN_QUERY, FALSE, &hThread) 
318 +           || OpenProcessToken(GetCurrentProcess(), TOKEN_QUERY, &hThread))
319 +    {
320 +      /* With the token for the current thread or process in hand we
321 +         query the size of the associated group information.  Note
322 +         that we expect an error because buffer has been passed as
323 +         NULL. cbTokenGroups will then tell use the required size.  */
324 +      if (!GetTokenInformation (hThread, TokenGroups, NULL, 0, &cbTokenGroups)
325 +          && GetLastError () == ERROR_INSUFFICIENT_BUFFER)
326 +        {
327 +          ptg = GlobalAlloc (GPTR, cbTokenGroups);
328 +          if (ptg)
329 +            {
330 +              if (GetTokenInformation ( hThread, TokenGroups, ptg,
331 +                                        cbTokenGroups, &cbTokenGroups))
332 +                {
333 +
334 +                  /* Now iterate through the list of groups for this
335 +                     access token looking for a match against the SID
336 +                     we created above. */
337 +                  for (i = 0; i < DIM (groups); i++)
338 +                    {
339 +                      PSID psid = 0;
340 +                      
341 +                      AllocateAndInitializeSid (&SystemSidAuthority,
342 +                                                2,
343 +                                                SECURITY_BUILTIN_DOMAIN_RID,
344 +                                                groups[i].auth_id,
345 +                                                0, 0, 0, 0, 0, 0,
346 +                                                &psid);
347 +                      if (!psid) 
348 +                        continue;
349 +                      for (j = 0; j < ptg->GroupCount; j++)
350 +                        if (EqualSid(ptg->Groups[j].Sid, psid))
351 +                          group = groups[i].name;
352 +                      FreeSid(psid);
353 +                    }
354 +                }
355 +              
356 +              GlobalFree(ptg);
357 +            }
358 +        }
359 +      
360 +      CloseHandle(hThread);
361 +    }
362 +
363 +  return group? strdup (group):NULL;
364 +}
365 +
366 +
367 +/* Return true if we are an administrator.  The chekc is done only
368 +   once so if the current user has been hadded to the Administrator
369 +   group the process needs to be rerstarted. */
370 +int
371 +w32_is_administrator (void)
372 +{
373 +  static int got_it;
374 +  static int is_admin;
375 +
376 +  if (!got_it)
377 +    {
378 +      char *name = get_group_name ();
379 +
380 +      if (name && !strcmp (name, "Admin"))
381 +        is_admin = 1;
382 +      got_it = 1;
383 +      free (name);
384 +    }
385 +
386 +  return is_admin;
387 +}
388 +
389 diff -rupN claws-mail-2.10.0-orig/src/common/w32lib.h claws-mail-2.10.0/src/common/w32lib.h
390 --- claws-mail-2.10.0-orig/src/common/w32lib.h  2007-07-02 10:32:18.000000000 +0200
391 +++ claws-mail-2.10.0/src/common/w32lib.h       2007-07-03 18:31:59.000000000 +0200
392 @@ -44,6 +44,12 @@
393  
394  /* Changes are:
395  
396 +2007-05-21  Werner Koch  <wk@g10code.com>
397 +
398 +       * src/common/w32_account.c: New.
399 +
400 +       * src/common/w32lib.h: Undef "interface".
401 +
402  2005-11-17  Werner Koch  <wk@g10code.com>
403  
404         Add boilerplate text to all files and explain legal status.
405 @@ -76,6 +82,13 @@
406  #include <dirent.h>
407  #endif
408  
409 +/* Mingw32 3.4.4 defines interface to struct and thus breaks our own
410 +   use of that symbol.  Undef it here. */
411 +#if defined(_BASETYPS_H) && defined(interface) 
412 +#undef interface
413 +#endif
414 +
415 +
416  /* types */
417  /*** ??? ***/
418  #ifndef __MINGW32__
419 @@ -188,8 +201,18 @@ int kill( pid_t pid, int sig );
420  FILE *popen( const char *command, const char *type );
421  int pclose( FILE *stream );
422  
423 +/*** w32_account.c ***/
424 +int w32_is_administrator (void);
425 +
426  /*** misc ***/
427  char *read_w32_registry_string( char *parent, char *section, char *key );
428  char *get_content_type_from_registry_with_ext( char *ext );
429  
430 +\f
431 +/* Simulate thread-safe versions of some functions.  */
432 +#define gmtime_r(time, resultp) gmtime (time)
433 +#define localtime_r(time, resultp) localtime (time)
434 +#define asctime_r(time, buffer) asctime (time)
435 +#define ctime_r(time, buffer) ctime (time)
436 +
437  #endif
438 diff -rupN claws-mail-2.10.0-orig/src/exporthtml.c claws-mail-2.10.0/src/exporthtml.c
439 --- claws-mail-2.10.0-orig/src/exporthtml.c     2007-07-02 10:32:21.000000000 +0200
440 +++ claws-mail-2.10.0/src/exporthtml.c  2007-07-03 18:31:59.000000000 +0200
441 @@ -33,6 +33,10 @@
442  #include <glib.h>
443  #include <glib/gi18n.h>
444  
445 +#ifdef G_OS_WIN32
446 +#  include <w32lib.h>
447 +#endif
448 +
449  #include "mgutils.h"
450  #include "utils.h"
451  #include "exporthtml.h"
452 diff -rupN claws-mail-2.10.0-orig/src/gtk/Makefile.am claws-mail-2.10.0/src/gtk/Makefile.am
453 --- claws-mail-2.10.0-orig/src/gtk/Makefile.am  2007-07-02 10:32:15.000000000 +0200
454 +++ claws-mail-2.10.0/src/gtk/Makefile.am       2007-07-03 18:31:59.000000000 +0200
455 @@ -66,6 +66,7 @@ clawsgtkinclude_HEADERS = \
456  
457  AM_CPPFLAGS = \
458         -I$(srcdir)/../common \
459 +       -I../common \
460         -I$(srcdir)/.. \
461         $(GTK_CFLAGS) \
462         $(OPENSSL_CFLAGS) \
463 diff -rupN claws-mail-2.10.0-orig/src/Makefile.am claws-mail-2.10.0/src/Makefile.am
464 --- claws-mail-2.10.0-orig/src/Makefile.am      2007-07-03 18:28:46.000000000 +0200
465 +++ claws-mail-2.10.0/src/Makefile.am   2007-07-03 18:31:59.000000000 +0200
466 @@ -462,6 +462,7 @@ EXTRA_DIST = \
467  
468  INCLUDES = \
469         -I$(srcdir)/common \
470 +       -Icommon \
471         -I$(srcdir)/gtk \
472         -I$(srcdir)/etpan
473  
474 diff -rupN claws-mail-2.10.0-orig/src/mbox.c claws-mail-2.10.0/src/mbox.c
475 --- claws-mail-2.10.0-orig/src/mbox.c   2007-07-02 10:32:19.000000000 +0200
476 +++ claws-mail-2.10.0/src/mbox.c        2007-07-03 18:31:59.000000000 +0200
477 @@ -37,6 +37,10 @@
478  #include <time.h>
479  #include <errno.h>
480  
481 +#ifdef G_OS_WIN32
482 +#  include <w32lib.h>
483 +#endif
484 +
485  #include "mbox.h"
486  #include "procmsg.h"
487  #include "folder.h"
488 diff -rupN claws-mail-2.10.0-orig/src/msgcache.c claws-mail-2.10.0/src/msgcache.c
489 --- claws-mail-2.10.0-orig/src/msgcache.c       2007-07-02 10:32:18.000000000 +0200
490 +++ claws-mail-2.10.0/src/msgcache.c    2007-07-03 18:31:59.000000000 +0200
491 @@ -28,7 +28,12 @@
492  
493  #include <glib.h>
494  #include <glib/gi18n.h>
495 -#include <sys/mman.h>
496 +#ifdef _WIN32
497 +# include <w32lib.h>
498 +# define MAP_FAILED    ((char *) -1)
499 +#else
500 +# include <sys/mman.h>
501 +#endif
502  #include <sys/types.h>
503  #include <sys/stat.h>
504  
505 @@ -621,8 +626,23 @@ MsgCache *msgcache_read_cache(FolderItem
506                         map_len = st.st_size;
507                 else
508                         map_len = -1;
509 -               if (map_len > 0)
510 +               if (map_len > 0) {
511 +#ifdef G_OS_WIN32
512 +                       cache_data = NULL;
513 +                       HANDLE hFile, hMapping;
514 +                       hFile = (HANDLE) _get_osfhandle (fileno(fp));
515 +                       if (hFile == (HANDLE) -1)
516 +                               goto w32_fail;
517 +                       hMapping = CreateFileMapping(hFile, NULL, PAGE_WRITECOPY, 0, 0, NULL);
518 +                       if (!hMapping)
519 +                               goto w32_fail;
520 +                       cache_data = (unsigned char *)MapViewOfFile(hMapping, FILE_MAP_COPY, 0, 0, 0);
521 +               w32_fail:
522 +                       ;
523 +#else
524                         cache_data = mmap(NULL, map_len, PROT_READ, MAP_PRIVATE, fileno(fp), 0);
525 +#endif
526 +               }
527         } else {
528                 cache_data = NULL;
529         }
530 @@ -678,8 +698,12 @@ MsgCache *msgcache_read_cache(FolderItem
531                         if(msginfo->msgid)
532                                 g_hash_table_insert(cache->msgid_table, msginfo->msgid, msginfo);
533                 }
534 -               
535 +
536 +#ifdef G_OS_WIN32
537 +               UnmapViewOfFile((void*) cache_data);
538 +#else
539                 munmap(cache_data, map_len);
540 +#endif
541         } else {
542                 while (fread(&num, sizeof(num), 1, fp) == 1) {
543                         if (swapping)
544 @@ -784,8 +808,23 @@ void msgcache_read_mark(MsgCache *cache,
545                         map_len = st.st_size;
546                 else
547                         map_len = -1;
548 -               if (map_len > 0)
549 +               if (map_len > 0) {
550 +#ifdef G_OS_WIN32
551 +                       cache_data = NULL;
552 +                       HANDLE hFile, hMapping;
553 +                       hFile = (HANDLE) _get_osfhandle (fileno(fp));
554 +                       if (hFile == (HANDLE) -1)
555 +                               goto w32_fail2;
556 +                       hMapping = CreateFileMapping(hFile, NULL, PAGE_WRITECOPY, 0, 0, NULL);
557 +                       if (!hMapping)
558 +                               goto w32_fail2;
559 +                       cache_data = (unsigned char *)MapViewOfFile(hMapping, FILE_MAP_COPY, 0, 0, 0);
560 +               w32_fail2:
561 +                       ;
562 +#else
563                         cache_data = mmap(NULL, map_len, PROT_READ, MAP_PRIVATE, fileno(fp), 0);
564 +#endif
565 +               }
566         } else {
567                 cache_data = NULL;
568         }
569 @@ -801,7 +840,11 @@ void msgcache_read_mark(MsgCache *cache,
570                                 msginfo->flags.perm_flags = perm_flags;
571                         }
572                 }
573 +#ifdef G_OS_WIN32
574 +               UnmapViewOfFile((void*) cache_data);
575 +#else
576                 munmap(cache_data, map_len);
577 +#endif
578         } else {
579                 while (fread(&num, sizeof(num), 1, fp) == 1) {
580                         if (swapping)
581 @@ -1011,16 +1054,49 @@ gint msgcache_write(const gchar *cache_f
582         if (msgcache_use_mmap_write && cache->memusage > 0) {
583                 map_len = cache->memusage;
584                 if (ftruncate(fileno(write_fps.cache_fp), (off_t)map_len) == 0) {
585 +
586 +#ifdef G_OS_WIN32
587 +                       cache_data = NULL;
588 +                       HANDLE hFile, hMapping;
589 +                       hFile = (HANDLE) _get_osfhandle (fileno(write_fps.cache_fp));
590 +                       if (hFile == (HANDLE) -1)
591 +                               goto w32_fail3;
592 +                       hMapping = CreateFileMapping(hFile, NULL, PAGE_READWRITE, 0, 0, NULL);
593 +                       if (!hMapping)
594 +                               goto w32_fail3;
595 +                       cache_data = (unsigned char *)MapViewOfFile(hMapping, FILE_MAP_COPY, 0, 0, 0);
596 +               w32_fail3:
597 +                       ;
598 +#else
599                         cache_data = mmap(NULL, map_len, PROT_WRITE, MAP_SHARED, 
600                                 fileno(write_fps.cache_fp), 0);
601 +#endif
602                 }
603                 if (cache_data != NULL && cache_data != MAP_FAILED) {
604                         if (ftruncate(fileno(write_fps.mark_fp), (off_t)map_len) == 0) {
605 +#ifdef G_OS_WIN32
606 +                       mark_data = NULL;
607 +                       HANDLE hFile, hMapping;
608 +                       hFile = (HANDLE) _get_osfhandle (fileno(write_fps.mark_fp));
609 +                       if (hFile == (HANDLE) -1)
610 +                               goto w32_fail4;
611 +                       hMapping = CreateFileMapping(hFile, NULL, PAGE_READWRITE, 0, 0, NULL);
612 +                       if (!hMapping)
613 +                               goto w32_fail4;
614 +                       mark_data = (unsigned char *)MapViewOfFile(hMapping, FILE_MAP_COPY, 0, 0, 0);
615 +               w32_fail4:
616 +                       ;
617 +#else
618                                 mark_data = mmap(NULL, map_len, PROT_WRITE, MAP_SHARED, 
619                                         fileno(write_fps.mark_fp), 0);
620 +#endif
621                         } 
622                         if (mark_data == NULL || mark_data == MAP_FAILED) {
623 +#ifdef G_OS_WIN32
624 +                               UnmapViewOfFile((void*) cache_data);
625 +#else
626                                 munmap(cache_data, map_len);
627 +#endif
628                                 cache_data = NULL;
629                         }
630                 }
631 @@ -1030,8 +1106,13 @@ gint msgcache_write(const gchar *cache_f
632                 write_fps.cache_data = cache_data + ftell(write_fps.cache_fp);
633                 write_fps.mark_data = mark_data + ftell(write_fps.mark_fp);
634                 g_hash_table_foreach(cache->msgnum_table, msgcache_write_mmap_func, (gpointer)&write_fps);
635 +#ifdef G_OS_WIN32
636 +               UnmapViewOfFile((void*) cache_data);
637 +               UnmapViewOfFile((void*) mark_data);
638 +#else
639                 munmap(cache_data, map_len);
640                 munmap(mark_data, map_len);
641 +#endif
642                 ftruncate(fileno(write_fps.cache_fp), write_fps.cache_size);
643                 ftruncate(fileno(write_fps.mark_fp), write_fps.mark_size);
644         } else {
645 diff -rupN claws-mail-2.10.0-orig/src/plugins/pgpcore/claws.def claws-mail-2.10.0/src/plugins/pgpcore/claws.def
646 --- claws-mail-2.10.0-orig/src/plugins/pgpcore/claws.def        2007-07-02 10:32:21.000000000 +0200
647 +++ claws-mail-2.10.0/src/plugins/pgpcore/claws.def     2007-07-03 18:31:59.000000000 +0200
648 @@ -1,26 +1,37 @@
649  LIBRARY CLAWS-MAIL.EXE
650  EXPORTS
651 +account_get_default
652  alertpanel
653 -alertpanel_full
654  alertpanel_error
655 +alertpanel_full
656 +check_plugin_version
657  copy_file_part
658  debug_print_real
659  debug_srcname
660 +extract_address
661  get_rc_dir
662  get_tmp_file
663 +gtkut_get_options_frame
664  gtkut_stock_button_set_create
665 +gtkut_window_new
666  input_dialog
667 +label_window_create
668 +label_window_destroy
669  mainwindow_get_mainwindow
670  manage_window_destroy
671  manage_window_focus_in
672  manage_window_focus_out
673  manage_window_set_transient
674  manage_window_unmap
675 +mimeview_register_viewer_factory
676 +mimeview_unregister_viewer_factory
677  prefs_account_get_privacy_prefs
678  prefs_account_register_page
679  prefs_account_set_privacy_prefs
680  prefs_account_unregister_page
681  prefs_button_toggled
682 +prefs_button_toggled_reverse
683 +prefs_common
684  prefs_file_close
685  prefs_file_close_revert
686  prefs_gtk_register_page
687 @@ -30,6 +41,12 @@ prefs_set_block_label
688  prefs_set_default
689  prefs_write_open
690  prefs_write_param
691 -claws_get_version
692 -privacy_set_error
693  privacy_get_error
694 +privacy_set_error
695 +textview_clear
696 +textview_create
697 +textview_destroy
698 +textview_init
699 +textview_set_font
700 +textview_show_icon
701 +textview_show_mime_part
702 diff -rupN claws-mail-2.10.0-orig/src/plugins/pgpcore/Makefile.am claws-mail-2.10.0/src/plugins/pgpcore/Makefile.am
703 --- claws-mail-2.10.0-orig/src/plugins/pgpcore/Makefile.am      2007-07-02 10:32:21.000000000 +0200
704 +++ claws-mail-2.10.0/src/plugins/pgpcore/Makefile.am   2007-07-03 18:31:59.000000000 +0200
705 @@ -72,6 +72,7 @@ pgpcore_la_LIBADD = $(cygwin_export_lib)
706  INCLUDES = \
707         -I$(top_srcdir)/src \
708         -I$(top_srcdir)/src/common \
709 +       -I$(top_builddir)/src/common \
710         -I$(top_srcdir)/src/gtk
711  
712  AM_CPPFLAGS = \
713 diff -rupN claws-mail-2.10.0-orig/src/plugins/pgpcore/passphrase.c claws-mail-2.10.0/src/plugins/pgpcore/passphrase.c
714 --- claws-mail-2.10.0-orig/src/plugins/pgpcore/passphrase.c     2007-07-02 10:32:20.000000000 +0200
715 +++ claws-mail-2.10.0/src/plugins/pgpcore/passphrase.c  2007-07-03 18:31:59.000000000 +0200
716 @@ -44,7 +44,7 @@
717  #include <string.h>
718  #include <sys/types.h>
719  #ifdef G_OS_WIN32
720 -#include <windows.h>
721 +#include <w32lib.h>
722  #else
723  #include <sys/mman.h>
724  #endif
725 diff -rupN claws-mail-2.10.0-orig/src/plugins/pgpcore/pgp_viewer.c claws-mail-2.10.0/src/plugins/pgpcore/pgp_viewer.c
726 --- claws-mail-2.10.0-orig/src/plugins/pgpcore/pgp_viewer.c     2007-07-02 10:32:21.000000000 +0200
727 +++ claws-mail-2.10.0/src/plugins/pgpcore/pgp_viewer.c  2007-07-03 18:31:59.000000000 +0200
728 @@ -26,7 +26,9 @@
729  #include <glib.h>
730  #include <glib/gi18n.h>
731  #include <sys/types.h>
732 -#include <sys/wait.h>
733 +#ifndef G_OS_WIN32
734 +#  include <sys/wait.h>
735 +#endif
736  #if (defined(__DragonFly__) || defined (__NetBSD__) || defined (__FreeBSD__) || defined (__OpenBSD__))
737  #  include <sys/signal.h>
738  #endif
739 diff -rupN claws-mail-2.10.0-orig/src/plugins/pgpcore/plugin.def claws-mail-2.10.0/src/plugins/pgpcore/plugin.def
740 --- claws-mail-2.10.0-orig/src/plugins/pgpcore/plugin.def       2007-07-02 10:32:20.000000000 +0200
741 +++ claws-mail-2.10.0/src/plugins/pgpcore/plugin.def    2007-07-03 18:31:59.000000000 +0200
742 @@ -1,13 +1,15 @@
743  EXPORTS
744 -        plugin_init
745 +        plugin_desc
746          plugin_done
747 +        plugin_init
748 +        plugin_licence
749          plugin_name
750 -        plugin_desc
751 +       plugin_provides
752          plugin_type
753 -        plugin_licence
754          plugin_version
755  
756          sgpgme_data_from_mimeinfo
757 +       sgpgme_data_release_and_get_mem
758          sgpgme_decrypt_verify
759          sgpgme_get_encrypt_data
760          sgpgme_setup_signers
761 @@ -17,4 +19,8 @@ EXPORTS
762          sgpgme_verify_signature
763  
764          gpgmegtk_passphrase_cb
765 +        prefs_gpg_add_skip_encryption_warning
766 +        prefs_gpg_enable_agent
767 +        prefs_gpg_remove_skip_encryption_warning
768 +        prefs_gpg_should_skip_encryption_warning
769          prefs_gpg_get_config
770 diff -rupN claws-mail-2.10.0-orig/src/plugins/pgpcore/sgpgme.c claws-mail-2.10.0/src/plugins/pgpcore/sgpgme.c
771 --- claws-mail-2.10.0-orig/src/plugins/pgpcore/sgpgme.c 2007-07-02 10:32:21.000000000 +0200
772 +++ claws-mail-2.10.0/src/plugins/pgpcore/sgpgme.c      2007-07-03 18:31:59.000000000 +0200
773 @@ -33,7 +33,9 @@
774  #include <stdlib.h>
775  #include <errno.h>
776  #include <sys/types.h>
777 -#include <sys/wait.h>
778 +#ifndef G_OS_WIN32
779 +#  include <sys/wait.h>
780 +#endif
781  #if (defined(__DragonFly__) || defined (__NetBSD__) || defined (__FreeBSD__) || defined (__OpenBSD__))
782  #  include <sys/signal.h>
783  #endif
784 diff -rupN claws-mail-2.10.0-orig/src/plugins/pgpinline/claws.def claws-mail-2.10.0/src/plugins/pgpinline/claws.def
785 --- claws-mail-2.10.0-orig/src/plugins/pgpinline/claws.def      2007-07-02 10:32:20.000000000 +0200
786 +++ claws-mail-2.10.0/src/plugins/pgpinline/claws.def   2007-07-03 18:31:59.000000000 +0200
787 @@ -1,5 +1,6 @@
788  LIBRARY CLAWS-MAIL.EXE
789  EXPORTS
790 +check_plugin_version
791  codeconv_set_strict
792  conv_codeset_strdup
793  conv_get_locale_charset_str_no_utf8
794 @@ -8,6 +9,8 @@ debug_srcname
795  get_mime_tmp_dir
796  my_tmpfile
797  privacy_register_system
798 +privacy_reset_error
799 +privacy_set_error
800  privacy_unregister_system
801  procmime_decode_content
802  procmime_encode_content
803 @@ -16,7 +19,3 @@ procmime_mimeinfo_get_parameter
804  procmime_mimeinfo_parent
805  procmime_scan_file
806  procmime_write_mimeinfo
807 -claws_get_version
808 -privacy_set_error
809 -privacy_get_error
810 -privacy_reset_error
811 diff -rupN claws-mail-2.10.0-orig/src/plugins/pgpinline/Makefile.am claws-mail-2.10.0/src/plugins/pgpinline/Makefile.am
812 --- claws-mail-2.10.0-orig/src/plugins/pgpinline/Makefile.am    2007-07-02 10:32:20.000000000 +0200
813 +++ claws-mail-2.10.0/src/plugins/pgpinline/Makefile.am 2007-07-03 18:31:59.000000000 +0200
814 @@ -71,6 +71,7 @@ pgpinline_la_LIBADD = $(plugin_ldadd) $(
815  INCLUDES = \
816         -I$(top_srcdir)/src \
817         -I$(top_srcdir)/src/common \
818 +       -I$(top_builddir)/src/common \
819         -I$(top_srcdir)/src/gtk
820  
821  AM_CPPFLAGS = \
822 diff -rupN claws-mail-2.10.0-orig/src/plugins/pgpinline/mypgpcore.def claws-mail-2.10.0/src/plugins/pgpinline/mypgpcore.def
823 --- claws-mail-2.10.0-orig/src/plugins/pgpinline/mypgpcore.def  2007-07-02 10:32:20.000000000 +0200
824 +++ claws-mail-2.10.0/src/plugins/pgpinline/mypgpcore.def       2007-07-03 18:31:59.000000000 +0200
825 @@ -1,14 +1,16 @@
826  LIBRARY PGPCORE.DLL
827  EXPORTS
828 -        sgpgme_data_from_mimeinfo
829 -        sgpgme_decrypt_verify
830 -        sgpgme_get_encrypt_data
831 -        sgpgme_setup_signers
832 -        sgpgme_sigstat_gpgme_to_privacy
833 -        sgpgme_sigstat_info_full
834 -        sgpgme_sigstat_info_short
835 -        sgpgme_verify_signature
836 -        gpgmegtk_passphrase_cb
837 -        prefs_gpg_get_config
838 -
839 -
840 +gpgmegtk_passphrase_cb
841 +prefs_gpg_add_skip_encryption_warning
842 +prefs_gpg_enable_agent
843 +prefs_gpg_get_config
844 +prefs_gpg_remove_skip_encryption_warning
845 +prefs_gpg_should_skip_encryption_warning
846 +sgpgme_data_release_and_get_mem
847 +sgpgme_decrypt_verify
848 +sgpgme_get_encrypt_data
849 +sgpgme_setup_signers
850 +sgpgme_sigstat_gpgme_to_privacy
851 +sgpgme_sigstat_info_full
852 +sgpgme_sigstat_info_short
853 +sgpgme_verify_signature
854 diff -rupN claws-mail-2.10.0-orig/src/plugins/pgpinline/plugin.def claws-mail-2.10.0/src/plugins/pgpinline/plugin.def
855 --- claws-mail-2.10.0-orig/src/plugins/pgpinline/plugin.def     2007-07-02 10:32:20.000000000 +0200
856 +++ claws-mail-2.10.0/src/plugins/pgpinline/plugin.def  2007-07-03 18:31:59.000000000 +0200
857 @@ -1,9 +1,10 @@
858  EXPORTS
859 -        plugin_init
860 +        plugin_desc
861          plugin_done
862 +        plugin_init
863 +        plugin_licence
864          plugin_name
865 -        plugin_desc
866          plugin_type
867 -        plugin_licence
868 +       plugin_provides
869          plugin_version
870  
871 diff -rupN claws-mail-2.10.0-orig/src/plugins/pgpmime/claws.def claws-mail-2.10.0/src/plugins/pgpmime/claws.def
872 --- claws-mail-2.10.0-orig/src/plugins/pgpmime/claws.def        2007-07-02 10:32:21.000000000 +0200
873 +++ claws-mail-2.10.0/src/plugins/pgpmime/claws.def     2007-07-03 18:31:59.000000000 +0200
874 @@ -1,6 +1,7 @@
875  LIBRARY CLAWS-MAIL.EXE
876  EXPORTS
877  canonicalize_str
878 +check_plugin_version
879  debug_print_real
880  debug_srcname
881  file_read_stream_to_str
882 @@ -8,6 +9,8 @@ generate_mime_boundary
883  get_mime_tmp_dir
884  my_tmpfile
885  privacy_register_system
886 +privacy_reset_error
887 +privacy_set_error
888  privacy_unregister_system
889  procmime_mimeinfo_free_all
890  procmime_mimeinfo_get_parameter
891 @@ -15,7 +18,3 @@ procmime_mimeinfo_new
892  procmime_mimeinfo_parent
893  procmime_scan_file
894  procmime_write_mimeinfo
895 -claws_get_version
896 -privacy_set_error
897 -privacy_get_error
898 -privacy_reset_error
899 diff -rupN claws-mail-2.10.0-orig/src/plugins/pgpmime/Makefile.am claws-mail-2.10.0/src/plugins/pgpmime/Makefile.am
900 --- claws-mail-2.10.0-orig/src/plugins/pgpmime/Makefile.am      2007-07-02 10:32:21.000000000 +0200
901 +++ claws-mail-2.10.0/src/plugins/pgpmime/Makefile.am   2007-07-03 18:31:59.000000000 +0200
902 @@ -70,6 +70,7 @@ pgpmime_la_LIBADD = $(plugin_ldadd) $(pg
903  INCLUDES = \
904         -I$(top_srcdir)/src \
905         -I$(top_srcdir)/src/common \
906 +       -I$(top_builddir)/src/common \
907         -I$(top_srcdir)/src/gtk
908  
909  AM_CPPFLAGS = \
910 diff -rupN claws-mail-2.10.0-orig/src/plugins/pgpmime/mypgpcore.def claws-mail-2.10.0/src/plugins/pgpmime/mypgpcore.def
911 --- claws-mail-2.10.0-orig/src/plugins/pgpmime/mypgpcore.def    2007-07-02 10:32:21.000000000 +0200
912 +++ claws-mail-2.10.0/src/plugins/pgpmime/mypgpcore.def 2007-07-03 18:31:59.000000000 +0200
913 @@ -1,14 +1,17 @@
914  LIBRARY PGPCORE.DLL
915  EXPORTS
916 -        sgpgme_data_from_mimeinfo
917 -        sgpgme_decrypt_verify
918 -        sgpgme_get_encrypt_data
919 -        sgpgme_setup_signers
920 -        sgpgme_sigstat_gpgme_to_privacy
921 -        sgpgme_sigstat_info_full
922 -        sgpgme_sigstat_info_short
923 -        sgpgme_verify_signature
924 -        gpgmegtk_passphrase_cb
925 -        prefs_gpg_get_config
926 -
927 -
928 +gpgmegtk_passphrase_cb
929 +prefs_gpg_add_skip_encryption_warning
930 +prefs_gpg_enable_agent
931 +prefs_gpg_get_config
932 +prefs_gpg_remove_skip_encryption_warning
933 +prefs_gpg_should_skip_encryption_warning
934 +sgpgme_data_from_mimeinfo
935 +sgpgme_data_release_and_get_mem
936 +sgpgme_decrypt_verify
937 +sgpgme_get_encrypt_data
938 +sgpgme_setup_signers
939 +sgpgme_sigstat_gpgme_to_privacy
940 +sgpgme_sigstat_info_full
941 +sgpgme_sigstat_info_short
942 +sgpgme_verify_signature
943 diff -rupN claws-mail-2.10.0-orig/src/plugins/pgpmime/plugin.def claws-mail-2.10.0/src/plugins/pgpmime/plugin.def
944 --- claws-mail-2.10.0-orig/src/plugins/pgpmime/plugin.def       2007-07-02 10:32:21.000000000 +0200
945 +++ claws-mail-2.10.0/src/plugins/pgpmime/plugin.def    2007-07-03 18:31:59.000000000 +0200
946 @@ -1,8 +1,9 @@
947  EXPORTS
948 -        plugin_init
949 +        plugin_desc
950          plugin_done
951 +        plugin_init
952 +        plugin_licence
953          plugin_name
954 -        plugin_desc
955          plugin_type
956 -        plugin_licence
957 +       plugin_provides
958          plugin_version
959 diff -rupN claws-mail-2.10.0-orig/src/prefs_summaries.c claws-mail-2.10.0/src/prefs_summaries.c
960 --- claws-mail-2.10.0-orig/src/prefs_summaries.c        2007-07-02 10:32:18.000000000 +0200
961 +++ claws-mail-2.10.0/src/prefs_summaries.c     2007-07-03 18:31:59.000000000 +0200
962 @@ -31,6 +31,10 @@
963  #include <gtk/gtk.h>
964  #include <gdk/gdkkeysyms.h>
965  
966 +#ifdef G_OS_WIN32
967 +#  include <w32lib.h>
968 +#endif
969 +
970  #include "prefs_common.h"
971  #include "prefs_gtk.h"
972  #include "prefs_summary_open.h"
973 diff -rupN claws-mail-2.10.0-orig/src/prefs_themes.c claws-mail-2.10.0/src/prefs_themes.c
974 --- claws-mail-2.10.0-orig/src/prefs_themes.c   2007-07-02 10:32:15.000000000 +0200
975 +++ claws-mail-2.10.0/src/prefs_themes.c        2007-07-03 18:31:59.000000000 +0200
976 @@ -445,7 +445,7 @@ static void prefs_themes_btn_remove_clic
977         tmp = g_path_get_basename(theme_str);
978  
979         if (IS_SYSTEM_THEME(theme_str)) {
980 -               if (getuid() != 0) {
981 +               if (!superuser_p()) {
982                         alertpanel_error(_("Only root can remove system themes"));
983                         return;
984                 }
985 @@ -518,7 +518,7 @@ static void prefs_themes_btn_install_cli
986                 if (G_ALERTALTERNATE != val)
987                         goto end_inst;
988         }
989 -       if (getuid() == 0) {
990 +       if (superuser_p ()) {
991                 val = alertpanel(alert_title,
992                                  _("Do you want to install theme for all users?"),
993                                  GTK_STOCK_NO, GTK_STOCK_YES, NULL);
994 diff -rupN claws-mail-2.10.0-orig/src/procheader.c claws-mail-2.10.0/src/procheader.c
995 --- claws-mail-2.10.0-orig/src/procheader.c     2007-07-02 10:32:19.000000000 +0200
996 +++ claws-mail-2.10.0/src/procheader.c  2007-07-03 18:31:59.000000000 +0200
997 @@ -29,6 +29,10 @@
998  #include <time.h>
999  #include <sys/stat.h>
1000  
1001 +#ifdef G_OS_WIN32
1002 +#  include <w32lib.h>
1003 +#endif
1004 +
1005  #include "procheader.h"
1006  #include "procmsg.h"
1007  #include "codeconv.h"