mirror of
https://github.com/inverse-inc/sogo.git
synced 2026-04-11 16:28:51 +00:00
Monotone-Parent: 8433690e83501187848cc751a754f1f1fdf2d8c5
Monotone-Revision: 8387e16ec4baa1ac1d8fd5958d3681e5bcf43e92 Monotone-Author: wsourdeau@inverse.ca Monotone-Date: 2011-11-09T15:02:04 Monotone-Branch: ca.inverse.sogo
This commit is contained in:
@@ -1,5 +1,9 @@
|
||||
2011-11-09 Wolfgang Sourdeau <wsourdeau@inverse.ca>
|
||||
|
||||
* OpenChange/MAPIStoreMessage.m (-addProperties): intercept
|
||||
PR_RTF_COMPRESSED attributes and convert them automatically to a
|
||||
PR_HTML attribute.
|
||||
|
||||
* OpenChange/MAPIStoreVolatileMessage.m (-addProperties:):
|
||||
transfer the content of the "properties" ivar instead of the
|
||||
"newProperties" parameter, so as to benefit from treatment that
|
||||
|
||||
@@ -7,6 +7,8 @@ include ../Version
|
||||
|
||||
BACKEND_VERSION = 1.0.0
|
||||
|
||||
UNRTF_VERSION = 0.21.2
|
||||
|
||||
### bootstrap library
|
||||
MAPISTORESOGO = MAPIStoreSOGo
|
||||
LIBRARY_NAME = $(MAPISTORESOGO)
|
||||
@@ -23,6 +25,12 @@ BUNDLE_NAME = $(SOGOBACKEND)
|
||||
BUNDLE_EXTENSION = .MAPIStore
|
||||
BUNDLE_INSTALL_DIR = $(SOGO_LIBDIR)
|
||||
|
||||
UNRTF_DIR = unrtf-$(UNRTF_VERSION)
|
||||
|
||||
$(SOGOBACKEND)_CPPFLAGS += -I$(UNRTF_DIR)/src
|
||||
|
||||
$(SOGOBACKEND)_SUBPROJECTS = $(UNRTF_DIR)/src
|
||||
|
||||
$(SOGOBACKEND)_PRINCIPAL_CLASS = MAPIApplication
|
||||
|
||||
$(SOGOBACKEND)_OBJC_FILES += \
|
||||
@@ -120,7 +128,27 @@ $(SOGOBACKEND)_OBJC_FILES += \
|
||||
|
||||
|
||||
$(SOGOBACKEND)_RESOURCE_FILES += \
|
||||
product.plist
|
||||
product.plist \
|
||||
$(UNRTF_DIR)/charmaps/SYMBOL.charmap \
|
||||
$(UNRTF_DIR)/outputs/html.conf
|
||||
|
||||
### unrtf
|
||||
all:: $(UNRTF_DIR)/config.h $(UNRTF_DIR)/src/GNUmakefile
|
||||
|
||||
$(UNRTF_DIR): $(UNRTF_DIR).tar.gz $(UNRTF_DIR).diff
|
||||
rm -rf $(UNRTF_DIR)
|
||||
$(TAR) -xvzf $<
|
||||
(cd $(UNRTF_DIR) && patch -p1 < ../$(UNRTF_DIR).diff)
|
||||
touch $(UNRTF_DIR)
|
||||
|
||||
$(UNRTF_DIR)-stamp: $(UNRTF_DIR)
|
||||
touch $@
|
||||
|
||||
$(UNRTF_DIR)/config.h: $(UNRTF_DIR)-stamp unrtf_config_h
|
||||
cp unrtf_config_h $(UNRTF_DIR)/config.h
|
||||
|
||||
$(UNRTF_DIR)/src/GNUmakefile: $(UNRTF_DIR)-stamp GNUmakefile.unrtf
|
||||
cp GNUmakefile.unrtf $@
|
||||
|
||||
### pl reader
|
||||
PLREADER_TOOL = plreader
|
||||
@@ -160,6 +188,7 @@ SAMBA_LIB_DIR = $(shell pkg-config libmapistore --variable=libdir)
|
||||
include $(GNUSTEP_MAKEFILES)/bundle.make
|
||||
include $(GNUSTEP_MAKEFILES)/library.make
|
||||
include $(GNUSTEP_MAKEFILES)/test-tool.make
|
||||
include $(GNUSTEP_MAKEFILES)/aggregate.make
|
||||
-include GNUmakefile.postamble
|
||||
|
||||
endif
|
||||
|
||||
34
OpenChange/GNUmakefile.unrtf
Normal file
34
OpenChange/GNUmakefile.unrtf
Normal file
@@ -0,0 +1,34 @@
|
||||
# -*-makefile-*-
|
||||
|
||||
# GNUstep makefile
|
||||
|
||||
include $(GNUSTEP_MAKEFILES)/common.make
|
||||
|
||||
UNRTF = unrtf
|
||||
|
||||
SUBPROJECT_NAME = $(UNRTF)
|
||||
|
||||
$(UNRTF)_C_FILES = \
|
||||
attr.c \
|
||||
convert.c \
|
||||
error.c \
|
||||
hash.c \
|
||||
malloc.c \
|
||||
my_iconv.c \
|
||||
output.c \
|
||||
parse.c \
|
||||
unicode.c \
|
||||
user.c \
|
||||
util.c \
|
||||
word.c
|
||||
|
||||
$(UNRTF)_CFLAGS = -DHAVE_CONFIG_H=1 -I. -I../
|
||||
|
||||
# Option include to set any additional variables
|
||||
-include GNUmakefile.preamble
|
||||
|
||||
# Include in the rules for making libraries
|
||||
include $(GNUSTEP_MAKEFILES)/subproject.make
|
||||
|
||||
# Option include to define any additional rules
|
||||
-include GNUmakefile.postamble
|
||||
@@ -21,6 +21,7 @@
|
||||
*/
|
||||
|
||||
#import <Foundation/NSArray.h>
|
||||
#import <Foundation/NSBundle.h>
|
||||
#import <Foundation/NSData.h>
|
||||
#import <Foundation/NSDictionary.h>
|
||||
#import <Foundation/NSString.h>
|
||||
@@ -42,6 +43,8 @@
|
||||
|
||||
#import "MAPIStoreMessage.h"
|
||||
|
||||
#include <unrtf.h>
|
||||
|
||||
#undef DEBUG
|
||||
#include <stdbool.h>
|
||||
#include <gen_ndr/exchange.h>
|
||||
@@ -49,6 +52,8 @@
|
||||
#include <mapistore/mapistore_errors.h>
|
||||
#include <mapistore/mapistore_nameid.h>
|
||||
|
||||
static NSString *resourcesDir = nil;
|
||||
|
||||
NSData *
|
||||
MAPIStoreInternalEntryId (NSString *username)
|
||||
{
|
||||
@@ -147,6 +152,64 @@ MAPIStoreExternalEntryId (NSString *cn, NSString *email)
|
||||
return entryId;
|
||||
}
|
||||
|
||||
/* rtf conversion via unrtf */
|
||||
static int
|
||||
unrtf_data_output (void *data, const char *str, size_t str_len)
|
||||
{
|
||||
NSMutableData *rtfData = data;
|
||||
|
||||
[rtfData appendBytes: str length: str_len];
|
||||
|
||||
return str_len;
|
||||
}
|
||||
|
||||
static NSData *
|
||||
uncompressRTF (NSData *compressedRTF)
|
||||
{
|
||||
NSData *rtfData = nil;
|
||||
DATA_BLOB *rtf;
|
||||
TALLOC_CTX *mem_ctx;
|
||||
|
||||
mem_ctx = talloc_zero (NULL, TALLOC_CTX);
|
||||
rtf = talloc_zero (mem_ctx, DATA_BLOB);
|
||||
|
||||
if (uncompress_rtf (mem_ctx,
|
||||
(uint8_t *) [compressedRTF bytes], [compressedRTF length],
|
||||
rtf)
|
||||
== MAPI_E_SUCCESS)
|
||||
rtfData = [NSData dataWithBytes: rtf->data length: rtf->length];
|
||||
|
||||
talloc_free (mem_ctx);
|
||||
|
||||
return rtfData;
|
||||
}
|
||||
|
||||
static NSData *
|
||||
rtf2html (NSData *compressedRTF)
|
||||
{
|
||||
NSData *rtf;
|
||||
NSMutableData *html = nil;
|
||||
int rc;
|
||||
struct unRTFOptions unrtfOptions;
|
||||
|
||||
rtf = uncompressRTF (compressedRTF);
|
||||
if (rtf)
|
||||
{
|
||||
html = [NSMutableData data];
|
||||
memset (&unrtfOptions, 0, sizeof (struct unRTFOptions));
|
||||
unrtf_set_output_device (&unrtfOptions, unrtf_data_output, html);
|
||||
unrtfOptions.config_directory = [resourcesDir UTF8String];
|
||||
unrtfOptions.output_format = "html";
|
||||
unrtfOptions.nopict_mode = YES;
|
||||
rc = unrtf_convert_from_string (&unrtfOptions,
|
||||
[rtf bytes], [rtf length]);
|
||||
if (!rc)
|
||||
html = nil;
|
||||
}
|
||||
|
||||
return html;
|
||||
}
|
||||
|
||||
@interface SOGoObject (MAPIStoreProtocol)
|
||||
|
||||
- (NSString *) davEntityTag;
|
||||
@@ -156,6 +219,15 @@ MAPIStoreExternalEntryId (NSString *cn, NSString *email)
|
||||
|
||||
@implementation MAPIStoreMessage
|
||||
|
||||
+ (void) initialize
|
||||
{
|
||||
if (!resourcesDir)
|
||||
{
|
||||
resourcesDir = [[NSBundle bundleForClass: self] resourcePath];
|
||||
[resourcesDir retain];
|
||||
}
|
||||
}
|
||||
|
||||
- (id) init
|
||||
{
|
||||
if ((self = [super init]))
|
||||
@@ -304,6 +376,38 @@ MAPIStoreExternalEntryId (NSString *cn, NSString *email)
|
||||
return MAPISTORE_SUCCESS;
|
||||
}
|
||||
|
||||
- (void) addProperties: (NSDictionary *) newNewProperties
|
||||
{
|
||||
NSData *htmlData, *rtfData;
|
||||
static NSNumber *htmlKey = nil, *rtfKey = nil;
|
||||
|
||||
[super addProperties: newNewProperties];
|
||||
|
||||
if (!htmlKey)
|
||||
{
|
||||
htmlKey = MAPIPropertyKey (PR_HTML);
|
||||
[htmlKey retain];
|
||||
}
|
||||
|
||||
if (!rtfKey)
|
||||
{
|
||||
rtfKey = MAPIPropertyKey (PR_RTF_COMPRESSED);
|
||||
[rtfKey retain];
|
||||
}
|
||||
|
||||
if (![properties objectForKey: htmlKey])
|
||||
{
|
||||
rtfData = [properties objectForKey: rtfKey];
|
||||
if (rtfData)
|
||||
{
|
||||
htmlData = rtf2html (rtfData);
|
||||
[properties setObject: htmlData forKey: htmlKey];
|
||||
[properties removeObjectForKey: rtfKey];
|
||||
[properties removeObjectForKey: MAPIPropertyKey (PR_RTF_IN_SYNC)];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
- (MAPIStoreAttachment *) createAttachment
|
||||
{
|
||||
MAPIStoreAttachment *newAttachment;
|
||||
|
||||
11516
OpenChange/unrtf-0.21.2.diff
Normal file
11516
OpenChange/unrtf-0.21.2.diff
Normal file
File diff suppressed because it is too large
Load Diff
BIN
OpenChange/unrtf-0.21.2.tar.gz
Normal file
BIN
OpenChange/unrtf-0.21.2.tar.gz
Normal file
Binary file not shown.
75
OpenChange/unrtf_config_h
Normal file
75
OpenChange/unrtf_config_h
Normal file
@@ -0,0 +1,75 @@
|
||||
/* config.h. Generated from config.h.in by configure. */
|
||||
/* config.h.in. Generated from configure.ac by autoheader. */
|
||||
|
||||
/* Define to 1 if you have the <ctype.h> header file. */
|
||||
#define HAVE_CTYPE_H 1
|
||||
|
||||
/* Define to 1 if you have the <inttypes.h> header file. */
|
||||
#define HAVE_INTTYPES_H 1
|
||||
|
||||
/* Define to 1 if your system has a GNU libc compatible `malloc' function, and
|
||||
to 0 otherwise. */
|
||||
#define HAVE_MALLOC 1
|
||||
|
||||
/* Define to 1 if you have the <memory.h> header file. */
|
||||
#define HAVE_MEMORY_H 1
|
||||
|
||||
/* Define to 1 if you have the `memset' function. */
|
||||
#define HAVE_MEMSET 1
|
||||
|
||||
/* Define to 1 if you have the <stdint.h> header file. */
|
||||
#define HAVE_STDINT_H 1
|
||||
|
||||
/* Define to 1 if you have the <stdio.h> header file. */
|
||||
#define HAVE_STDIO_H 1
|
||||
|
||||
/* Define to 1 if you have the <stdlib.h> header file. */
|
||||
#define HAVE_STDLIB_H 1
|
||||
|
||||
/* Define to 1 if you have the `strchr' function. */
|
||||
#define HAVE_STRCHR 1
|
||||
|
||||
/* Define to 1 if you have the <strings.h> header file. */
|
||||
#define HAVE_STRINGS_H 1
|
||||
|
||||
/* Define to 1 if you have the <string.h> header file. */
|
||||
#define HAVE_STRING_H 1
|
||||
|
||||
/* Define to 1 if you have the `strstr' function. */
|
||||
#define HAVE_STRSTR 1
|
||||
|
||||
/* Define to 1 if you have the <sys/stat.h> header file. */
|
||||
#define HAVE_SYS_STAT_H 1
|
||||
|
||||
/* Define to 1 if you have the <sys/types.h> header file. */
|
||||
#define HAVE_SYS_TYPES_H 1
|
||||
|
||||
/* Define to 1 if you have the <unistd.h> header file. */
|
||||
#define HAVE_UNISTD_H 1
|
||||
|
||||
/* Name of package */
|
||||
#define PACKAGE "unrtf"
|
||||
|
||||
/* Define to the address where bug reports for this package should be sent. */
|
||||
#define PACKAGE_BUGREPORT "bug-unrtf@gnu.org"
|
||||
|
||||
/* Define to the full name of this package. */
|
||||
#define PACKAGE_NAME "unrtf"
|
||||
|
||||
/* Define to the full name and version of this package. */
|
||||
#define PACKAGE_STRING "unrtf 0.21.2"
|
||||
|
||||
/* Define to the one symbol short name of this package. */
|
||||
#define PACKAGE_TARNAME "unrtf"
|
||||
|
||||
/* Define to the version of this package. */
|
||||
#define PACKAGE_VERSION "0.21.2"
|
||||
|
||||
/* Define to 1 if you have the ANSI C header files. */
|
||||
#define STDC_HEADERS 1
|
||||
|
||||
/* Version number of package */
|
||||
#define VERSION "0.21.2"
|
||||
|
||||
/* Define to rpl_malloc if the replacement function should be used. */
|
||||
/* #undef malloc */
|
||||
Reference in New Issue
Block a user