From: ak1 Date: Fri, 14 Jan 2005 22:23:31 +0000 (+0000) Subject: Andreas Krennmair: X-Git-Url: http://git.madism.org/?p=apps%2Fmadmutt.git;a=commitdiff_plain;h=6e0187ce721be4997bef32d724528f8976df89d6 Andreas Krennmair: * integrated rr.compressed patch * changed User-Agent string * added $operating_system to set fake operating system for User-Agent string git-svn-id: svn://svn.berlios.de/mutt-ng/trunk@15 e385b8ad-14ed-0310-8656-cc95a2468c6d --- diff --git a/ChangeLog.mutt-ng b/ChangeLog.mutt-ng index b1216d6..4d29835 100644 --- a/ChangeLog.mutt-ng +++ b/ChangeLog.mutt-ng @@ -1,4 +1,9 @@ Changes specific to mutt-ng: +2004-01-14: + * Integrated the following patches: + * rr.compressed for compressed folders + * Changed User-Agent string + * Added operating_system to set fake operating system for User-Agent string 2004-01-09: * first version of mutt-ng diff --git a/Makefile.am b/Makefile.am index 4b3bd06..d532304 100644 --- a/Makefile.am +++ b/Makefile.am @@ -18,7 +18,7 @@ BUILT_SOURCES = keymap_defs.h patchlist.c bin_PROGRAMS = muttng @DOTLOCK_TARGET@ @PGPAUX_TARGET@ @SMIMEAUX_TARGET@ muttng_SOURCES = $(BUILT_SOURCES) \ addrbook.c alias.c attach.c base64.c browser.c buffy.c color.c \ - crypt.c cryptglue.c \ + compress.c crypt.c cryptglue.c \ commands.c complete.c compose.c copy.c curs_lib.c curs_main.c date.c \ edit.c enter.c flags.c init.c filter.c from.c getdomain.c \ handler.c hash.c hdrline.c headers.c help.c hook.c keymap.c \ @@ -67,6 +67,7 @@ EXTRA_muttng_SOURCES = account.c md5c.c mutt_sasl.c mutt_socket.c mutt_ssl.c \ EXTRA_DIST = COPYRIGHT GPL OPS OPS.PGP OPS.CRYPT OPS.SMIME TODO \ configure acconfig.h account.h \ + compress.h \ attach.h buffy.h charset.h copy.h dotlock.h functions.h gen_defs \ globals.h hash.h history.h init.h keymap.h mutt_crypt.h \ mailbox.h mapping.h md5.h mime.h mutt.h mutt_curses.h mutt_menu.h \ diff --git a/Makefile.in b/Makefile.in index e0b96f6..e0b1482 100644 --- a/Makefile.in +++ b/Makefile.in @@ -197,7 +197,7 @@ BUILT_SOURCES = keymap_defs.h patchlist.c bin_PROGRAMS = muttng @DOTLOCK_TARGET@ @PGPAUX_TARGET@ @SMIMEAUX_TARGET@ muttng_SOURCES = $(BUILT_SOURCES) \ addrbook.c alias.c attach.c base64.c browser.c buffy.c color.c \ - crypt.c cryptglue.c \ + compress.c crypt.c cryptglue.c \ commands.c complete.c compose.c copy.c curs_lib.c curs_main.c date.c \ edit.c enter.c flags.c init.c filter.c from.c getdomain.c \ handler.c hash.c hdrline.c headers.c help.c hook.c keymap.c \ @@ -234,6 +234,7 @@ EXTRA_muttng_SOURCES = account.c md5c.c mutt_sasl.c mutt_socket.c mutt_ssl.c \ EXTRA_DIST = COPYRIGHT GPL OPS OPS.PGP OPS.CRYPT OPS.SMIME TODO \ configure acconfig.h account.h \ + compress.h \ attach.h buffy.h charset.h copy.h dotlock.h functions.h gen_defs \ globals.h hash.h history.h init.h keymap.h mutt_crypt.h \ mailbox.h mapping.h md5.h mime.h mutt.h mutt_curses.h mutt_menu.h \ @@ -284,25 +285,26 @@ mutt_dotlock_LDFLAGS = am__objects_1 = patchlist.$(OBJEXT) am_muttng_OBJECTS = $(am__objects_1) addrbook.$(OBJEXT) alias.$(OBJEXT) \ attach.$(OBJEXT) base64.$(OBJEXT) browser.$(OBJEXT) \ - buffy.$(OBJEXT) color.$(OBJEXT) crypt.$(OBJEXT) \ - cryptglue.$(OBJEXT) commands.$(OBJEXT) complete.$(OBJEXT) \ - compose.$(OBJEXT) copy.$(OBJEXT) curs_lib.$(OBJEXT) \ - curs_main.$(OBJEXT) date.$(OBJEXT) edit.$(OBJEXT) \ - enter.$(OBJEXT) flags.$(OBJEXT) init.$(OBJEXT) filter.$(OBJEXT) \ - from.$(OBJEXT) getdomain.$(OBJEXT) handler.$(OBJEXT) \ - hash.$(OBJEXT) hdrline.$(OBJEXT) headers.$(OBJEXT) \ - help.$(OBJEXT) hook.$(OBJEXT) keymap.$(OBJEXT) main.$(OBJEXT) \ - mbox.$(OBJEXT) menu.$(OBJEXT) mh.$(OBJEXT) mx.$(OBJEXT) \ - pager.$(OBJEXT) parse.$(OBJEXT) pattern.$(OBJEXT) \ - postpone.$(OBJEXT) query.$(OBJEXT) recvattach.$(OBJEXT) \ - recvcmd.$(OBJEXT) rfc822.$(OBJEXT) rfc1524.$(OBJEXT) \ - rfc2047.$(OBJEXT) rfc2231.$(OBJEXT) score.$(OBJEXT) \ - send.$(OBJEXT) sendlib.$(OBJEXT) signal.$(OBJEXT) \ - sort.$(OBJEXT) status.$(OBJEXT) system.$(OBJEXT) \ - thread.$(OBJEXT) charset.$(OBJEXT) history.$(OBJEXT) \ - lib.$(OBJEXT) muttlib.$(OBJEXT) editmsg.$(OBJEXT) \ - utf8.$(OBJEXT) mbyte.$(OBJEXT) wcwidth.$(OBJEXT) url.$(OBJEXT) \ - ascii.$(OBJEXT) mutt_idna.$(OBJEXT) sidebar.$(OBJEXT) + buffy.$(OBJEXT) color.$(OBJEXT) compress.$(OBJEXT) \ + crypt.$(OBJEXT) cryptglue.$(OBJEXT) commands.$(OBJEXT) \ + complete.$(OBJEXT) compose.$(OBJEXT) copy.$(OBJEXT) \ + curs_lib.$(OBJEXT) curs_main.$(OBJEXT) date.$(OBJEXT) \ + edit.$(OBJEXT) enter.$(OBJEXT) flags.$(OBJEXT) init.$(OBJEXT) \ + filter.$(OBJEXT) from.$(OBJEXT) getdomain.$(OBJEXT) \ + handler.$(OBJEXT) hash.$(OBJEXT) hdrline.$(OBJEXT) \ + headers.$(OBJEXT) help.$(OBJEXT) hook.$(OBJEXT) \ + keymap.$(OBJEXT) main.$(OBJEXT) mbox.$(OBJEXT) menu.$(OBJEXT) \ + mh.$(OBJEXT) mx.$(OBJEXT) pager.$(OBJEXT) parse.$(OBJEXT) \ + pattern.$(OBJEXT) postpone.$(OBJEXT) query.$(OBJEXT) \ + recvattach.$(OBJEXT) recvcmd.$(OBJEXT) rfc822.$(OBJEXT) \ + rfc1524.$(OBJEXT) rfc2047.$(OBJEXT) rfc2231.$(OBJEXT) \ + score.$(OBJEXT) send.$(OBJEXT) sendlib.$(OBJEXT) \ + signal.$(OBJEXT) sort.$(OBJEXT) status.$(OBJEXT) \ + system.$(OBJEXT) thread.$(OBJEXT) charset.$(OBJEXT) \ + history.$(OBJEXT) lib.$(OBJEXT) muttlib.$(OBJEXT) \ + editmsg.$(OBJEXT) utf8.$(OBJEXT) mbyte.$(OBJEXT) \ + wcwidth.$(OBJEXT) url.$(OBJEXT) ascii.$(OBJEXT) \ + mutt_idna.$(OBJEXT) sidebar.$(OBJEXT) muttng_OBJECTS = $(am_muttng_OBJECTS) muttng_LDFLAGS = am_pgpring_OBJECTS = pgppubring.$(OBJEXT) pgplib.$(OBJEXT) lib.$(OBJEXT) \ diff --git a/PATCHES b/PATCHES index f2089c8..6f0bdfe 100644 --- a/PATCHES +++ b/PATCHES @@ -1,3 +1,4 @@ +rr.compressed patch-1.5.6i.sidebar.20041122 patch-1.5.4.aw.listreply.1 patch-1.5.4.cd.source_multiple.2 diff --git a/acconfig.h b/acconfig.h index 38f7fc5..245f238 100644 --- a/acconfig.h +++ b/acconfig.h @@ -39,3 +39,6 @@ * all return values other than (size_t)(-1) as equivalent. */ #undef ICONV_NONTRANS +/* The compressed mailboxes support */ +#undef USE_COMPRESSED + diff --git a/config.h.in b/config.h.in index 802857b..f4af89c 100644 --- a/config.h.in +++ b/config.h.in @@ -577,3 +577,6 @@ * all return values other than (size_t)(-1) as equivalent. */ #undef ICONV_NONTRANS +/* The compressed mailboxes support */ +#undef USE_COMPRESSED + diff --git a/configure b/configure index 3e7676a..b179e11 100755 --- a/configure +++ b/configure @@ -863,6 +863,7 @@ Optional Features: --enable-nfs-fix Work around an NFS with broken attributes caching --enable-buffy-size Use file size attribute instead of access time --enable-mailtool Enable Sun mailtool attachments support + --enable-compressed Enable compressed folders support --enable-locales-fix The result of isprint() is unreliable --enable-exact-address Enable regeneration of email addresses --disable-iconv Disable iconv support @@ -11390,6 +11391,17 @@ _ACEOF fi fi; +# Check whether --enable-compressed or --disable-compressed was given. +if test "${enable_compressed+set}" = set; then + enableval="$enable_compressed" + if test x$enableval = xyes; then + cat >>confdefs.h <<\_ACEOF +#define USE_COMPRESSED 1 +_ACEOF + + fi +fi; + # Check whether --enable-locales-fix or --disable-locales-fix was given. if test "${enable_locales_fix+set}" = set; then enableval="$enable_locales_fix" diff --git a/configure.in b/configure.in index 6b42629..f48be12 100644 --- a/configure.in +++ b/configure.in @@ -754,6 +754,11 @@ AC_ARG_ENABLE(mailtool, [ --enable-mailtool Enable Sun mailtool attach AC_DEFINE(SUN_ATTACHMENT,1,[ Define to enable Sun mailtool attachments support. ]) fi]) +AC_ARG_ENABLE(compressed, [ --enable-compressed Enable compressed folders support ], + [if test x$enableval = xyes; then + AC_DEFINE(USE_COMPRESSED) + fi]) + AC_ARG_ENABLE(locales-fix, [ --enable-locales-fix The result of isprint() is unreliable ], [if test x$enableval = xyes; then AC_DEFINE(LOCALES_HACK,1,[ Define if the result of isprint() is unreliable. ]) diff --git a/curs_main.c b/curs_main.c index 3835af7..7137100 100644 --- a/curs_main.c +++ b/curs_main.c @@ -1296,6 +1296,12 @@ CHECK_IMAP_ACL(IMAP_ACL_DELETE); { int check; +#ifdef USE_COMPRESSED + if (Context->compressinfo && Context->realpath) + mutt_str_replace (&LastFolder, Context->realpath); + else +#endif + mutt_str_replace (&LastFolder, Context->path); oldcount = Context ? Context->msgcount : 0; diff --git a/doc/manual.sgml.head b/doc/manual.sgml.head index 8ad8d3b..556cff8 100644 --- a/doc/manual.sgml.head +++ b/doc/manual.sgml.head @@ -2412,6 +2412,168 @@ macro index \cb |urlview\n macro pager \cb |urlview\n +Compressed folders Support (OPTIONAL) +

+ +If Mutt was compiled with compressed folders support (by running the +, + and ) which define commands to uncompress and compress +a folder and to append messages to an existing compressed folder +respectively. + +For example: + + +open-hook \\.gz$ "gzip -cd %f > %t" +close-hook \\.gz$ "gzip -c %t > %f" +append-hook \\.gz$ "gzip -c %t >> %f" + + +You do not have to specify all of the commands. If you omit , the folder will be open and +closed again each time you will add to it. If you omit (or give empty command) , the +folder will be open in the mode. If you specify though you'll be able to append +to the folder. + +Note that Mutt will only try to use hooks if the file is not in one of +the accepted formats. In particular, if the file is empty, mutt +supposes it is not compressed. This is important because it allows the +use of programs that do not have well defined extensions. Just use +&dquot;.&dquot; as a regexp. But this may be surprising if your +compressing script produces empty files. In this situation, unset , so that the compressed file +will be removed if you delete all of the messages. + +Open a compressed mailbox for reading

+Usage: +open-hook \\.gz$ "gzip -cd %f > %t" + + +If the Write a compressed mailbox

+Usage: command after some changes were made to it. + +The command. Temporary folder +in this case is the folder previously produced by the < command. + +The +close-hook \\.gz$ "gzip -c %t > %f" + + +If the is not called when you exit +from the folder if the folder was not changed. + +Append a message to a compressed mailbox

+Usage: command. +The temporary folder in this case contains the messages that are being +appended. + +The +append-hook \\.gz$ "gzip -c %t >> %f" + + +When is used, the folder is +not opened, which saves time, but this means that we can not find out +what the folder type is. Thus the default () type is always supposed (i.e. +this is the format used for the temporary folder). + +If the file does not exist when you save to it, is called, and not . is only +for appending to existing folders. + +If the and respectively) each time you will add to it. + +Encrypted folders +

+The compressed folders support can also be used to handle encrypted +folders. If you want to encrypt a folder with PGP, you may want to use +the following hooks: + + +open-hook \\.pgp$ "pgp -f < %f > %t" +close-hook \\.pgp$ "pgp -fe YourPgpUserIdOrKeyId < %t > %f" + + +Please note, that PGP does not support appending to an encrypted +folder, so there is no append-hook defined. + +Mutt's MIME Support

Quite a bit of effort has been made to make Mutt the premier text-mode @@ -2991,6 +3153,8 @@ The following are the commands understood by mutt. + + + #include #include @@ -88,6 +92,16 @@ int mutt_parse_hook (BUFFER *buf, BUFFER *s, unsigned long data, BUFFER *err) memset (&pattern, 0, sizeof (pattern)); pattern.data = safe_strdup (path); } +#ifdef USE_COMPRESSED + else if (data & (M_APPENDHOOK | M_OPENHOOK | M_CLOSEHOOK)) + { + if (mutt_test_compress_command (command.data)) + { + strfcpy (err->data, _("bad formatted command string"), err->dsize); + return (-1); + } + } +#endif else if (DefaultHook && !(data & (M_CHARSETHOOK | M_ACCOUNTHOOK)) && (!WithCrypto || !(data & M_CRYPTHOOK)) ) diff --git a/init.h b/init.h index f288ff6..111ad72 100644 --- a/init.h +++ b/init.h @@ -1098,6 +1098,13 @@ struct option_t MuttVars[] = { ** This specifies the folder into which read mail in your ``$$spoolfile'' ** folder will be appended. */ + { "operating_system", DT_STR, R_NONE, UL&OperatingSystem, 0 }, + /* + ** .pp + ** This specifies the operating system name for the User-Agent header. If + ** this is unset, it will be set to the operating system name that uname(2) + ** returns. If uname(2) fails, "UNIX" will be used. + */ { "sidebar_visible", DT_BOOL, R_BOTH, OPTMBOXPANE, 0 }, /* ** .pp @@ -3054,6 +3061,11 @@ struct command_t Commands[] = { { "fcc-hook", mutt_parse_hook, M_FCCHOOK }, { "fcc-save-hook", mutt_parse_hook, M_FCCHOOK | M_SAVEHOOK }, { "folder-hook", mutt_parse_hook, M_FOLDERHOOK }, +#ifdef USE_COMPRESSED + { "open-hook", mutt_parse_hook, M_OPENHOOK }, + { "close-hook", mutt_parse_hook, M_CLOSEHOOK }, + { "append-hook", mutt_parse_hook, M_APPENDHOOK }, +#endif { "hdr_order", parse_list, UL &HeaderOrderList }, #ifdef HAVE_ICONV { "iconv-hook", mutt_parse_hook, M_ICONVHOOK }, diff --git a/main.c b/main.c index 58e6079..89fa6d3 100644 --- a/main.c +++ b/main.c @@ -283,6 +283,12 @@ static void show_version (void) "-USE_GNU_REGEX " #endif +#ifdef USE_COMPRESSED + "+COMPRESSED " +#else + "-COMPRESSED " +#endif + "\n" #ifdef HAVE_COLOR diff --git a/mbox.c b/mbox.c index dc900e4..dedf7c6 100644 --- a/mbox.c +++ b/mbox.c @@ -24,6 +24,10 @@ #include "sort.h" #include "copy.h" +#ifdef USE_COMPRESSED +#include "compress.h" +#endif + #include #include #include @@ -1016,6 +1020,12 @@ bail: /* Come here in case of disaster */ int mbox_close_mailbox (CONTEXT *ctx) { mx_unlock_file (ctx->path, fileno (ctx->fp), 1); + +#ifdef USE_COMPRESSED + if (ctx->compressinfo) + mutt_slow_close_compressed (ctx); +#endif + mutt_unblock_signals (); mx_fastclose_mailbox (ctx); return 0; diff --git a/mutt.h b/mutt.h index 6a6b036..c99861c 100644 --- a/mutt.h +++ b/mutt.h @@ -158,6 +158,11 @@ typedef enum #define M_CRYPTHOOK (1<<8) #define M_ACCOUNTHOOK (1<<9) #define M_REPLYHOOK (1<<10) +#ifdef USE_COMPRESSED +#define M_OPENHOOK (1<<12) +#define M_APPENDHOOK (1<<13) +#define M_CLOSEHOOK (1<<14) +#endif /* tree characters for linearize_tree and print_enriched_string */ #define M_TREE_LLCORNER 1 @@ -833,6 +838,11 @@ typedef struct short magic; /* mailbox type */ +#ifdef USE_COMPRESSED + void *compressinfo; /* compressed mbox module private data */ + char *realpath; /* path to compressed mailbox */ +#endif /* USE_COMPRESSED */ + unsigned int locked : 1; /* is the mailbox locked? */ unsigned int changed : 1; /* mailbox has been modified */ unsigned int readonly : 1; /* don't allow changes to the mailbox */ diff --git a/mx.c b/mx.c index 2186651..ed779b2 100644 --- a/mx.c +++ b/mx.c @@ -26,6 +26,10 @@ #include "keymap.h" #include "url.h" +#ifdef USE_COMPRESSED +#include "compress.h" +#endif + #ifdef USE_IMAP #include "imap.h" #endif @@ -475,6 +479,11 @@ int mx_get_magic (const char *path) return (-1); } +#ifdef USE_COMPRESSED + if (magic == 0 && mutt_can_read_compressed (path)) + return M_COMPRESSED; +#endif + return (magic); } @@ -514,6 +523,13 @@ static int mx_open_mailbox_append (CONTEXT *ctx, int flags) { struct stat sb; +#ifdef USE_COMPRESSED + /* special case for appending to compressed folders - + * even if we can not open them for reading */ + if (mutt_can_append_compressed (ctx->path)) + mutt_open_append_compressed (ctx); +#endif + ctx->append = 1; #ifdef USE_IMAP @@ -675,6 +691,11 @@ CONTEXT *mx_open_mailbox (const char *path, int flags, CONTEXT *pctx) ctx->magic = mx_get_magic (path); +#ifdef USE_COMPRESSED + if (ctx->magic == M_COMPRESSED) + mutt_open_read_compressed (ctx); +#endif + if(ctx->magic == 0) mutt_error (_("%s is not a mailbox."), path); @@ -790,6 +811,10 @@ void mx_fastclose_mailbox (CONTEXT *ctx) mutt_free_header (&ctx->hdrs[i]); FREE (&ctx->hdrs); FREE (&ctx->v2r); +#ifdef USE_COMPRESSED + if (ctx->compressinfo) + mutt_fast_close_compressed (ctx); +#endif FREE (&ctx->path); FREE (&ctx->pattern); if (ctx->limit_pattern) @@ -853,6 +878,12 @@ static int sync_mailbox (CONTEXT *ctx, int *index_hint) if (tmp && tmp->new == 0) mutt_update_mailbox (tmp); #endif + +#ifdef USE_COMPRESSED + if (rc == 0 && ctx->compressinfo) + return mutt_sync_compressed (ctx); +#endif + return rc; } @@ -1125,6 +1156,11 @@ int mx_close_mailbox (CONTEXT *ctx, int *index_hint) !mutt_is_spool(ctx->path) && !option (OPTSAVEEMPTY)) mx_unlink_empty (ctx->path); +#ifdef USE_COMPRESSED + if (ctx->compressinfo && mutt_slow_close_compressed (ctx)) + return (-1); +#endif + mx_fastclose_mailbox (ctx); return 0; @@ -1435,6 +1471,11 @@ int mx_check_mailbox (CONTEXT *ctx, int *index_hint, int lock) { int rc; +#ifdef USE_COMPRESSED + if (ctx->compressinfo) + return mutt_check_mailbox_compressed (ctx); +#endif + if (ctx) { if (ctx->locked) lock = 0; diff --git a/mx.h b/mx.h index 3750928..f5a31a7 100644 --- a/mx.h +++ b/mx.h @@ -43,6 +43,9 @@ enum #ifdef USE_NNTP , M_NNTP #endif +#ifdef USE_COMPRESSED + , M_COMPRESSED +#endif }; WHERE short DefaultMagic INITVAL (M_MBOX); diff --git a/po/POTFILES.in b/po/POTFILES.in index 0a570ee..0dbeee9 100644 --- a/po/POTFILES.in +++ b/po/POTFILES.in @@ -8,6 +8,7 @@ charset.c color.c commands.c compose.c +compress.c crypt.c curs_lib.c curs_main.c diff --git a/sendlib.c b/sendlib.c index 8128089..31596c9 100644 --- a/sendlib.c +++ b/sendlib.c @@ -40,6 +40,7 @@ #include #include #include +#include #ifdef USE_NNTP #include @@ -1738,8 +1739,19 @@ int mutt_write_rfc822_header (FILE *fp, ENVELOPE *env, BODY *attach, if (mode == 0 && !privacy && option (OPTXMAILER) && !has_agent) { + struct utsname un; + char * os; + if (OperatingSystem!=NULL) { + os = OperatingSystem; + } else { + if (uname(&un)==-1) { + os = "UNIX"; + } else { + os = un.sysname; + } + } /* Add a vanity header */ - fprintf (fp, "User-Agent: Mutt/%s\n", MUTT_VERSION); + fprintf (fp, "User-Agent: mutt-ng %s (%s)\n", MUTT_VERSION,os); } return (ferror (fp) == 0 ? 0 : -1); diff --git a/status.c b/status.c index 3d175f6..305be60 100644 --- a/status.c +++ b/status.c @@ -93,6 +93,14 @@ status_format_str (char *buf, size_t buflen, char op, const char *src, case 'f': snprintf (fmt, sizeof(fmt), "%%%ss", prefix); +#ifdef USE_COMPRESSED + if (Context && Context->compressinfo && Context->realpath) + { + strfcpy (tmp, Context->realpath, sizeof (tmp)); + mutt_pretty_mailbox (tmp); + } + else +#endif if (Context && Context->path) { strfcpy (tmp, Context->path, sizeof (tmp));