propagate from branch 'ca.inverse.sogo.1_3_10' (head 00afe1e795cd37cafff7687d6f1b8502f4f5735e)

to branch 'ca.inverse.sogo' (head dd0644b62704e75dfed8a39a7e286d593f0014e0)

Monotone-Parent: 00afe1e795cd37cafff7687d6f1b8502f4f5735e
Monotone-Parent: dd0644b62704e75dfed8a39a7e286d593f0014e0
Monotone-Revision: 6927dc6b0ecbc6c5c3061a56fd1e91ef658279ae

Monotone-Author: flachapelle@inverse.ca
Monotone-Date: 2011-11-17T19:08:52
Monotone-Branch: ca.inverse.sogo
maint-2.0.2
Francis Lachapelle 2011-11-17 19:08:52 +00:00
commit 01be7b7d8f
45 changed files with 12354 additions and 327 deletions

View File

@ -4,9 +4,7 @@ obj
err$
build\.log
imgs-.*
diff
.*\.bak$
.*\.diff$
.*\.d$
.*\.log$
.*\.ifb$

View File

@ -1,3 +1,22 @@
2011-11-17 Wolfgang Sourdeau <wsourdeau@inverse.ca>
* OpenChange/MAPIStoreSamDBUtils.m: new module containing helpers
pertaining to the SamDB.
(MAPIStoreSamDBUserAttribute): new function that returns the value
of a specified key from a user record matching one simple criteria.
(MAPIStoreInternalEntrydId, MAPIStoreExternalEntryId): moved
functions from MAPIStoreMessage.m.
* OpenChange/MAPIStoreMessage.m (MAPIStoreInternalEntryId): now
takes a ldb_context * parameter pointing to the samdb, which
enables us: 1) to return the real legacyExchangeDN 2) to make use
of sAMAccountName as search parameter for the username.
2011-11-16 Ludovic Marcotte <lmarcotte@inverse.ca>
* SoObjects/SOGo/SOGoSieveManager.m (-updateFiltersForLogin:...)
We now handle connection exceptions to avoid crashing sogod.
2011-11-13 Wolfgang Sourdeau <wsourdeau@inverse.ca>
* OpenChange/MAPIStoreContactsMessage.m (-getPrBody:inMemCtx:):

View File

@ -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,28 @@ $(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
@echo " Extracting and patching $(UNRTF_DIR)..."
@rm -rf $(UNRTF_DIR)
@$(TAR) -xvzf $< > /dev/null
@(cd $(UNRTF_DIR) && patch -p1 < ../$(UNRTF_DIR).diff) > /dev/null
@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
@ -133,7 +162,7 @@ TEST_TOOL_NAME += $(PLREADER_TOOL)
LIBMAPI_CFLAGS = $(shell pkg-config libmapi --cflags)
LIBMAPISTORE_CFLAGS = $(shell pkg-config libmapistore --cflags) -DSAMBA_PREFIX="\"$(shell pkg-config libmapistore --variable=prefix)\""
ifeq ($(LIBMAPISTORE_CFLAGS),)
ifeq ($(LIBMAPI_CFLAGS),)
all install::
@echo "Cannot build the OpenChange SOGo backend (empty CFLAGS for libmapistore)"
else
@ -160,6 +189,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

View 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

View File

@ -39,6 +39,7 @@ extern NSTimeZone *utcTZ;
@interface MAPIStoreAppointmentWrapper : NSObject
{
struct mapistore_connection_info *connInfo;
iCalCalendar *calendar;
iCalEvent *event;
NSTimeZone *timeZone;
@ -56,11 +57,13 @@ extern NSTimeZone *utcTZ;
+ (id) wrapperWithICalEvent: (iCalEvent *) newEvent
andUser: (SOGoUser *) newUser
andSenderEmail: (NSString *) newSenderEmail
inTimeZone: (NSTimeZone *) newTimeZone;
inTimeZone: (NSTimeZone *) newTimeZone
withConnectionInfo: (struct mapistore_connection_info *) newConnInfo;
- (id) initWithICalEvent: (iCalEvent *) newEvent
andUser: (SOGoUser *) newUser
andSenderEmail: (NSString *) newSenderEmail
inTimeZone: (NSTimeZone *) newTimeZone;
inTimeZone: (NSTimeZone *) newTimeZone
withConnectionInfo: (struct mapistore_connection_info *) newConnInfo;
/* getters */
- (void) fillMessageData: (struct mapistore_message *) dataPtr
@ -92,8 +95,6 @@ extern NSTimeZone *utcTZ;
inMemCtx: (TALLOC_CTX *) memCtx;
- (int) getPrMessageClass: (void **) data
inMemCtx: (TALLOC_CTX *) memCtx;
- (int) getPrBody: (void **) data
inMemCtx: (TALLOC_CTX *) memCtx;
- (int) getPrStartDate: (void **) data
inMemCtx: (TALLOC_CTX *) memCtx;
- (int) getPidLidAppointmentStateFlags: (void **) data
@ -129,6 +130,8 @@ extern NSTimeZone *utcTZ;
inMemCtx: (TALLOC_CTX *) memCtx;
- (int) getPrImportance: (void **) data
inMemCtx: (TALLOC_CTX *) memCtx;
- (int) getPrBody: (void **) data
inMemCtx: (TALLOC_CTX *) memCtx;
- (int) getPidLidIsRecurring: (void **) data
inMemCtx: (TALLOC_CTX *) memCtx;
- (int) getPidLidRecurring: (void **) data

View File

@ -37,8 +37,8 @@
#import <NGCards/NSString+NGCards.h>
#import <SOGo/SOGoUserManager.h>
#import "MAPIStoreMessage.h"
#import "MAPIStoreRecurrenceUtils.h"
#import "MAPIStoreSamDBUtils.h"
#import "MAPIStoreTypes.h"
#import "NSData+MAPIStore.h"
#import "NSDate+MAPIStore.h"
@ -53,6 +53,7 @@
#include <gen_ndr/exchange.h>
#include <gen_ndr/property.h>
#include <gen_ndr/ndr_property.h>
#include <util/attr.h>
#include <libmapi/libmapi.h>
#include <mapistore/mapistore.h>
#include <mapistore/mapistore_errors.h>
@ -79,13 +80,15 @@ static NSCharacterSet *hexCharacterSet = nil;
andUser: (SOGoUser *) newUser
andSenderEmail: (NSString *) newSenderEmail
inTimeZone: (NSTimeZone *) newTimeZone
withConnectionInfo: (struct mapistore_connection_info *) newConnInfo
{
MAPIStoreAppointmentWrapper *wrapper;
wrapper = [[self alloc] initWithICalEvent: newEvent
andUser: newUser
andSenderEmail: newSenderEmail
inTimeZone: newTimeZone];
inTimeZone: newTimeZone
withConnectionInfo: newConnInfo];
[wrapper autorelease];
return wrapper;
@ -95,6 +98,7 @@ static NSCharacterSet *hexCharacterSet = nil;
{
if ((self = [super init]))
{
connInfo = NULL;
calendar = nil;
event = nil;
timeZone = nil;
@ -177,9 +181,11 @@ static NSCharacterSet *hexCharacterSet = nil;
andUser: (SOGoUser *) newUser
andSenderEmail: (NSString *) newSenderEmail
inTimeZone: (NSTimeZone *) newTimeZone
withConnectionInfo: (struct mapistore_connection_info *) newConnInfo
{
if ((self = [self init]))
{
connInfo = newConnInfo;
ASSIGN (event, newEvent);
ASSIGN (calendar, [event parent]);
ASSIGN (timeZone, newTimeZone);
@ -255,7 +261,7 @@ static NSCharacterSet *hexCharacterSet = nil;
{
username = [contactInfos objectForKey: @"c_uid"];
recipient->username = [username asUnicodeInMemCtx: msgData];
entryId = MAPIStoreInternalEntryId (username);
entryId = MAPIStoreInternalEntryId (connInfo->sam_ctx, username);
}
else
{
@ -356,7 +362,7 @@ static NSCharacterSet *hexCharacterSet = nil;
{
username = [contactInfos objectForKey: @"c_uid"];
recipient->username = [username asUnicodeInMemCtx: msgData];
entryId = MAPIStoreInternalEntryId (username);
entryId = MAPIStoreInternalEntryId (connInfo->sam_ctx, username);
}
else
{
@ -628,20 +634,6 @@ static NSCharacterSet *hexCharacterSet = nil;
return [self getYes: data inMemCtx: memCtx];
}
- (int) getPrBody: (void **) data
inMemCtx: (TALLOC_CTX *) memCtx
{
NSString *stringValue;
stringValue = [event comment];
if (!stringValue)
stringValue = @"";
*data = [stringValue asUnicodeInMemCtx: memCtx];
return MAPISTORE_SUCCESS;
}
- (int) getPrStartDate: (void **) data
inMemCtx: (TALLOC_CTX *) memCtx
{
@ -740,7 +732,7 @@ static NSCharacterSet *hexCharacterSet = nil;
if (contactInfos)
{
username = [contactInfos objectForKey: @"c_uid"];
entryId = MAPIStoreInternalEntryId (username);
entryId = MAPIStoreInternalEntryId (connInfo->sam_ctx, username);
}
else
entryId = MAPIStoreExternalEntryId (cn, email);
@ -1034,6 +1026,22 @@ static NSCharacterSet *hexCharacterSet = nil;
return MAPISTORE_SUCCESS;
}
- (int) getPrBody: (void **) data
inMemCtx: (TALLOC_CTX *) memCtx
{
int rc = MAPISTORE_SUCCESS;
NSString *stringValue;
/* FIXME: there is a confusion in NGCards around "comment" and "description" */
stringValue = [event comment];
if ([stringValue length] > 0)
*data = [stringValue asUnicodeInMemCtx: memCtx];
else
rc = MAPISTORE_ERR_NOT_FOUND;
return rc;
}
- (int) getPidLidIsRecurring: (void **) data
inMemCtx: (TALLOC_CTX *) memCtx
{
@ -1402,7 +1410,8 @@ _fillAppointmentRecurrencePattern (struct AppointmentRecurrencePattern *arp,
{
startDate = [event startDate];
relation = [[trigger relationType] lowercaseString];
interval = [[trigger value] durationAsTimeInterval];
interval = [[trigger flattenedValuesForKey: @""]
durationAsTimeInterval];
if ([relation isEqualToString: @"end"])
relationDate = [event endDate];
else

View File

@ -25,6 +25,7 @@
- take the tz definitions from Outlook */
#include <talloc.h>
#include <util/attr.h>
#import <Foundation/NSArray.h>
#import <Foundation/NSCalendarDate.h>
@ -45,6 +46,7 @@
#import <Appointments/SOGoAppointmentFolder.h>
#import <Appointments/SOGoAppointmentObject.h>
#import <Appointments/iCalEntityObject+SOGo.h>
#import <Mailer/NSString+Mail.h>
#import "MAPIStoreAppointmentWrapper.h"
#import "MAPIStoreCalendarAttachment.h"
@ -102,15 +104,18 @@
- (MAPIStoreAppointmentWrapper *) appointmentWrapper
{
iCalEvent *event;
MAPIStoreContext *context;
if (!appointmentWrapper)
{
event = [sogoObject component: NO secure: NO];
context = [self context];
ASSIGN (appointmentWrapper,
[MAPIStoreAppointmentWrapper wrapperWithICalEvent: event
andUser: [[self context] activeUser]
andUser: [context activeUser]
andSenderEmail: nil
inTimeZone: [self ownerTimeZone]]);
inTimeZone: [self ownerTimeZone]
withConnectionInfo: [context connectionInfo]]);
}
return appointmentWrapper;
@ -240,6 +245,12 @@
return [[self appointmentWrapper] getPrImportance: data inMemCtx: memCtx];
}
- (int) getPrBody: (void **) data
inMemCtx: (TALLOC_CTX *) memCtx
{
return [[self appointmentWrapper] getPrBody: data inMemCtx: memCtx];
}
- (int) getPidLidIsRecurring: (void **) data
inMemCtx: (TALLOC_CTX *) memCtx
{
@ -599,7 +610,9 @@
[alarm setAction: @"DISPLAY"];
trigger = [iCalTrigger elementWithTag: @"trigger"];
[trigger setValueType: @"DURATION"];
[trigger setValue: [NSString stringWithFormat: @"-PT%@M", delta]];
[trigger
setSingleValue: [NSString stringWithFormat: @"-PT%@M", delta]
forKey: @""];
[alarm setTrigger: trigger];
[newEvent addToAlarms: alarm];
[alarm release];
@ -610,6 +623,7 @@
- (void) save
{
iCalCalendar *vCalendar;
BOOL isAllDay;
iCalDateTime *start, *end;
iCalTimeZone *tz;
NSCalendarDate *now;
@ -711,9 +725,16 @@
if (value)
[newEvent setLocation: value];
tzName = [[self ownerTimeZone] name];
tz = [iCalTimeZone timeZoneForName: tzName];
[vCalendar addTimeZone: tz];
isAllDay = [[properties
objectForKey: MAPIPropertyKey (PidLidAppointmentSubType)]
boolValue];
if (!isAllDay)
{
tzName = [[self ownerTimeZone] name];
tz = [iCalTimeZone timeZoneForName: tzName];
[vCalendar addTimeZone: tz];
}
// start
value = [properties objectForKey: MAPIPropertyKey (PR_START_DATE)];
@ -723,8 +744,13 @@
if (value)
{
start = (iCalDateTime *) [newEvent uniqueChildWithTag: @"dtstart"];
[start setTimeZone: tz];
[start setDateTime: value];
if (isAllDay)
[start setDate: value];
else
{
[start setTimeZone: tz];
[start setDateTime: value];
}
}
/* end */
@ -734,8 +760,13 @@
if (value)
{
end = (iCalDateTime *) [newEvent uniqueChildWithTag: @"dtend"];
[end setTimeZone: tz];
[end setDateTime: value];
if (isAllDay)
[end setDate: value];
else
{
[end setTimeZone: tz];
[end setDateTime: value];
}
}
/* priority */
@ -778,6 +809,22 @@
[newEvent setTransparency: @"OPAQUE"];
}
}
/* Comment */
value = [properties objectForKey: MAPIPropertyKey (PR_BODY_UNICODE)];
if (!value)
{
value = [properties objectForKey: MAPIPropertyKey (PR_HTML)];
if (value)
{
value = [[NSString alloc] initWithData: value
encoding: NSUTF8StringEncoding];
[value autorelease];
value = [value htmlToText];
}
}
if (value)
[newEvent setComment: value];
/* recurrence */
value = [properties
@ -793,75 +840,101 @@
/* alarm */
[self _setupAlarmDataInEvent: newEvent];
// Organizer
value = [properties objectForKey: @"recipients"];
if (value)
if ([[properties objectForKey: MAPIPropertyKey (PidLidAppointmentStateFlags)] intValue]
!= 0)
{
NSArray *recipients;
NSDictionary *dict;
iCalPerson *person;
iCalPersonPartStat newPartStat;
NSNumber *flags, *trackStatus;
int i;
/* We must set the organizer preliminarily here because, unlike what
the doc states, Outlook does not always pass the real organizer
in the recipients list. */
dict = [activeUser primaryIdentity];
person = [iCalPerson new];
[person setCn: [dict objectForKey: @"fullName"]];
[person setEmail: [dict objectForKey: @"email"]];
[newEvent setOrganizer: person];
[person release];
recipients = [value objectForKey: @"to"];
for (i = 0; i < [recipients count]; i++)
// Organizer
value = [properties objectForKey: @"recipients"];
if (value)
{
dict = [recipients objectAtIndex: i];
flags = [dict objectForKey: MAPIPropertyKey (PR_RECIPIENT_FLAGS)];
if (!flags)
{
[self logWithFormat: @"no recipient flags specified"];
break;
}
NSArray *recipients;
NSDictionary *dict;
NSString *orgEmail, *attEmail;
iCalPerson *person;
iCalPersonPartStat newPartStat;
NSNumber *flags, *trackStatus;
int i, effective;
/* We must set the organizer preliminarily here because, unlike what
the doc states, Outlook does not always pass the real organizer
in the recipients list. */
dict = [activeUser primaryIdentity];
person = [iCalPerson new];
[person setCn: [dict objectForKey: @"fullName"]];
[person setEmail: [dict objectForKey: @"email"]];
orgEmail = [dict objectForKey: @"email"];
[person setEmail: orgEmail];
[newEvent setOrganizer: person];
[person release];
if (([flags unsignedIntValue] & 0x0002)) /* recipOrganizer */
[newEvent setOrganizer: person];
else
recipients = [value objectForKey: @"to"];
effective = 0;
for (i = 0; i < [recipients count]; i++)
{
trackStatus
= [dict
objectForKey: MAPIPropertyKey (PR_RECIPIENT_TRACKSTATUS)];
dict = [recipients objectAtIndex: i];
/* FIXME: we should provide a data converter between OL
partstats and SOGo */
switch ([trackStatus unsignedIntValue])
flags = [dict objectForKey: MAPIPropertyKey (PR_RECIPIENT_FLAGS)];
if (!flags)
{
case 0x02: /* respTentative */
newPartStat = iCalPersonPartStatTentative;
break;
case 0x03: /* respAccepted */
newPartStat = iCalPersonPartStatAccepted;
break;
case 0x04: /* respDeclined */
newPartStat = iCalPersonPartStatDeclined;
break;
default:
newPartStat = iCalPersonPartStatNeedsAction;
[self logWithFormat:
@"no recipient flags specified: skipping recipient"];
continue;
}
[person setParticipationStatus: newPartStat];
[person setRsvp: @"TRUE"];
[person setRole: @"REQ-PARTICIPANT"];
[newEvent addToAttendees: person];
person = [iCalPerson new];
[person setCn: [dict objectForKey: @"fullName"]];
attEmail = [dict objectForKey: @"email"];
[person setEmail: attEmail];
if (([flags unsignedIntValue] & 0x0002)) /* recipOrganizer */
[newEvent setOrganizer: person];
else
{
/* Work-around: it happens that Outlook still passes the
organizer as a recipient, maybe because of a feature
documented in a pre-mesozoic PDF still buried in a
cavern... In that case we remove it, and we keep the
number of effective recipients in "effective". If the
total is 0, we remove the "ORGANIZER" too. */
if ([attEmail isEqualToString: orgEmail])
{
[self logWithFormat:
@"avoiding setting organizer as recipient"];
continue;
}
trackStatus
= [dict
objectForKey: MAPIPropertyKey (PR_RECIPIENT_TRACKSTATUS)];
/* FIXME: we should provide a data converter between OL
partstats and SOGo */
switch ([trackStatus unsignedIntValue])
{
case 0x02: /* respTentative */
newPartStat = iCalPersonPartStatTentative;
break;
case 0x03: /* respAccepted */
newPartStat = iCalPersonPartStatAccepted;
break;
case 0x04: /* respDeclined */
newPartStat = iCalPersonPartStatDeclined;
break;
default:
newPartStat = iCalPersonPartStatNeedsAction;
}
[person setParticipationStatus: newPartStat];
[person setRsvp: @"TRUE"];
[person setRole: @"REQ-PARTICIPANT"];
[newEvent addToAttendees: person];
effective++;
}
[person release];
}
[person release];
if (effective == 0) /* See work-around above */
[newEvent setOrganizer: nil];
}
}

View File

@ -142,7 +142,8 @@ extern NSTimeZone *utcTZ;
inMemCtx: (TALLOC_CTX *) memCtx
{
if (!photoData)
ASSIGN (photoData, [[photo value: 0] dataByDecodingBase64]);
ASSIGN (photoData,
[[photo flattenedValuesForKey: @""] dataByDecodingBase64]);
*data = [photoData asBinaryInMemCtx: memCtx];
@ -153,7 +154,8 @@ extern NSTimeZone *utcTZ;
inMemCtx: (TALLOC_CTX *) memCtx
{
if (!photoData)
ASSIGN (photoData, [[photo value: 0] dataByDecodingBase64]);
ASSIGN (photoData,
[[photo flattenedValuesForKey: @""] dataByDecodingBase64]);
*data = MAPILongValue (memCtx, [photoData length]);

View File

@ -27,10 +27,12 @@
#import <Foundation/NSString.h>
#import <NGExtensions/NGBase64Coding.h>
#import <NGExtensions/NSObject+Logs.h>
#import <NGCards/NSArray+NGCards.h>
#import <NGCards/NGVCard.h>
#import <NGCards/NGVCardPhoto.h>
#import <NGCards/NSArray+NGCards.h>
#import <NGCards/NSString+NGCards.h>
#import <Contacts/SOGoContactGCSEntry.h>
#import <Mailer/NSString+Mail.h>
#import "MAPIStoreContactsAttachment.h"
#import "MAPIStoreContactsFolder.h"
@ -147,18 +149,11 @@
- (int) getPrCompanyName: (void **) data
inMemCtx: (TALLOC_CTX *) memCtx
{
NSArray *values;
NSString *stringValue;
CardElement *org;
values = [[sogoObject vCard] org];
stringValue = nil;
if ([values count] > 0)
stringValue = [values objectAtIndex: 0];
else
stringValue = @"";
*data = [stringValue asUnicodeInMemCtx: memCtx];
org = [[sogoObject vCard] org];
*data = [[org flattenedValueAtIndex: 0 forKey: @""]
asUnicodeInMemCtx: memCtx];
return MAPISTORE_SUCCESS;
}
@ -166,18 +161,11 @@
- (int) getPrDepartmentName: (void **) data
inMemCtx: (TALLOC_CTX *) memCtx
{
NSArray *values;
NSString *stringValue;
CardElement *org;
values = [[sogoObject vCard] org];
stringValue = nil;
if ([values count] > 1)
stringValue = [values objectAtIndex: 1];
else
stringValue = @"";
*data = [stringValue asUnicodeInMemCtx: memCtx];
org = [[sogoObject vCard] org];
*data = [[org flattenedValueAtIndex: 1 forKey: @""]
asUnicodeInMemCtx: memCtx];
return MAPISTORE_SUCCESS;
}
@ -312,7 +300,7 @@
max = [emails count];
for (count = 0; !stringValue && count < max; count++)
{
email = [[emails objectAtIndex: count] value: 0];
email = [[emails objectAtIndex: count] flattenedValuesForKey: @""];
if ([email caseInsensitiveCompare: [card preferredEMail]] != NSOrderedSame)
stringValue = email;
@ -372,7 +360,7 @@
ce = [elements objectAtIndex: count];
if (!aTypeToExclude
|| ![ce hasAttribute: @"type" havingValue: aTypeToExclude])
stringValue = [ce value: pos];
stringValue = [ce flattenedValueAtIndex: pos forKey: @""];
}
if (!stringValue)
@ -463,7 +451,7 @@
NSString *stringValue;
stringValue = [[[sogoObject vCard] uniqueChildWithTag: @"x-aim"]
value: 0];
flattenedValuesForKey: @""];
if (!stringValue)
stringValue = @"";
*data = [stringValue asUnicodeInMemCtx: memCtx];
@ -697,7 +685,9 @@
{
NSString *stringValue;
stringValue = [[[sogoObject vCard] firstChildWithTag: @"n"] value: 0];
stringValue = [[[sogoObject vCard] firstChildWithTag: @"n"]
flattenedValueAtIndex: 0
forKey: @""];
*data = [stringValue asUnicodeInMemCtx: memCtx];
return MAPISTORE_SUCCESS;
@ -708,7 +698,9 @@
{
NSString *stringValue;
stringValue = [[[sogoObject vCard] firstChildWithTag: @"n"] value: 1];
stringValue = [[[sogoObject vCard] firstChildWithTag: @"n"]
flattenedValueAtIndex: 1
forKey: @""];
*data = [stringValue asUnicodeInMemCtx: memCtx];
return MAPISTORE_SUCCESS;
@ -719,7 +711,9 @@
{
NSString *stringValue;
stringValue = [[[sogoObject vCard] firstChildWithTag: @"n"] value: 2];
stringValue = [[[sogoObject vCard] firstChildWithTag: @"n"]
flattenedValueAtIndex: 2
forKey: @""];
*data = [stringValue asUnicodeInMemCtx: memCtx];
return MAPISTORE_SUCCESS;
@ -730,7 +724,9 @@
{
NSString *stringValue;
stringValue = [[[sogoObject vCard] firstChildWithTag: @"n"] value: 3];
stringValue = [[[sogoObject vCard] firstChildWithTag: @"n"]
flattenedValueAtIndex: 3
forKey: @""];
*data = [stringValue asUnicodeInMemCtx: memCtx];
return MAPISTORE_SUCCESS;
@ -741,7 +737,9 @@
{
NSString *stringValue;
stringValue = [[[sogoObject vCard] firstChildWithTag: @"n"] value: 4];
stringValue = [[[sogoObject vCard] firstChildWithTag: @"n"]
flattenedValueAtIndex: 4
forKey: @""];
*data = [stringValue asUnicodeInMemCtx: memCtx];
return MAPISTORE_SUCCESS;
@ -836,9 +834,9 @@
to: photoType];
[photo setValue: 0 ofAttribute: @"encoding"
to: @"b"];
[photo setValue: 0
to: [content stringByReplacingString: @"\n"
withString: @""]];
[photo setSingleValue: [content stringByReplacingString: @"\n"
withString: @""]
atIndex: 0 forKey: @""];
}
}
}
@ -885,7 +883,7 @@
if (value)
{
if ([elements count] > 0)
[[elements objectAtIndex: 0] setValue: 0 to: value];
[[elements objectAtIndex: 0] setSingleValue: value forKey: @""];
else
[newCard addEmail: value
types: [NSArray arrayWithObject: @"pref"]];
@ -894,7 +892,7 @@
if (value)
{
if ([elements count] > 1)
[[elements objectAtIndex: 1] setValue: 0 to: value];
[[elements objectAtIndex: 1] setSingleValue: value forKey: @""];
else
[newCard addEmail: value types: nil];
}
@ -902,7 +900,7 @@
if (value)
{
if ([elements count] > 2)
[[elements objectAtIndex: 2] setValue: 0 to: value];
[[elements objectAtIndex: 2] setSingleValue: value forKey: @""];
else
[newCard addEmail: value types: nil];
}
@ -942,7 +940,7 @@
[element addAttribute: @"type"
value: @"pref"];
}
[element setValue: 0 to: value];
[element setSingleValue: value forKey: @""];
}
elements = [newCard childrenWithTag: @"adr"
@ -960,22 +958,22 @@
[element addAttribute: @"type" value: @"pref"];
value = [properties objectForKey: MAPIPropertyKey(PidLidWorkAddressPostOfficeBox)];
if (value)
[element setValue: 0 to: value];
[element setSingleValue: value atIndex: 0 forKey: @""];
value = [properties objectForKey: MAPIPropertyKey(PidLidWorkAddressStreet)];
if (value)
[element setValue: 2 to: value];
[element setSingleValue: value atIndex: 2 forKey: @""];
value = [properties objectForKey: MAPIPropertyKey(PidLidWorkAddressCity)];
if (value)
[element setValue: 3 to: value];
[element setSingleValue: value atIndex: 3 forKey: @""];
value = [properties objectForKey: MAPIPropertyKey(PidLidWorkAddressState)];
if (value)
[element setValue: 4 to: value];
[element setSingleValue: value atIndex: 4 forKey: @""];
value = [properties objectForKey: MAPIPropertyKey(PidLidWorkAddressPostalCode)];
if (value)
[element setValue: 5 to: value];
[element setSingleValue: value atIndex: 5 forKey: @""];
value = [properties objectForKey: MAPIPropertyKey(PidLidWorkAddressCountry)];
if (value)
[element setValue: 6 to: value];
[element setSingleValue: value atIndex: 6 forKey: @""];
//
// home postal addresses handling
@ -1001,7 +999,7 @@
[element addAttribute: @"type"
value: @"pref"];
}
[element setValue: 0 to: value];
[element setSingleValue: value forKey: @""];
}
elements = [newCard childrenWithTag: @"adr"
@ -1020,22 +1018,22 @@
value = [properties objectForKey: MAPIPropertyKey(PR_HOME_ADDRESS_POST_OFFICE_BOX_UNICODE)];
if (value)
[element setValue: 0 to: value];
[element setSingleValue: value atIndex: 0 forKey: @""];
value = [properties objectForKey: MAPIPropertyKey( PR_HOME_ADDRESS_STREET_UNICODE)];
if (value)
[element setValue: 2 to: value];
[element setSingleValue: value atIndex: 2 forKey: @""];
value = [properties objectForKey: MAPIPropertyKey(PR_HOME_ADDRESS_CITY_UNICODE)];
if (value)
[element setValue: 3 to: value];
[element setSingleValue: value atIndex: 3 forKey: @""];
value = [properties objectForKey: MAPIPropertyKey(PR_HOME_ADDRESS_STATE_OR_PROVINCE_UNICODE)];
if (value)
[element setValue: 4 to: value];
[element setSingleValue: value atIndex: 4 forKey: @""];
value = [properties objectForKey: MAPIPropertyKey(PR_HOME_ADDRESS_POSTAL_CODE_UNICODE)];
if (value)
[element setValue: 5 to: value];
[element setSingleValue: value atIndex: 5 forKey: @""];
value = [properties objectForKey: MAPIPropertyKey(PR_HOME_ADDRESS_COUNTRY_UNICODE)];
if (value)
[element setValue: 6 to: value];
[element setSingleValue: value atIndex: 6 forKey: @""];
//
@ -1044,27 +1042,27 @@
element = [self _elementWithTag: @"tel" ofType: @"work" forCard: newCard];
value = [properties objectForKey: MAPIPropertyKey(PR_OFFICE_TELEPHONE_NUMBER_UNICODE)];
if (value)
[element setValue: 0 to: value];
[element setSingleValue: value forKey: @""];
element = [self _elementWithTag: @"tel" ofType: @"home" forCard: newCard];
value = [properties objectForKey: MAPIPropertyKey(PR_HOME_TELEPHONE_NUMBER_UNICODE)];
if (value)
[element setValue: 0 to: value];
[element setSingleValue: value forKey: @""];
element = [self _elementWithTag: @"tel" ofType: @"fax" forCard: newCard];
value = [properties objectForKey: MAPIPropertyKey(PR_BUSINESS_FAX_NUMBER_UNICODE)];
if (value)
[element setValue: 0 to: value];
[element setSingleValue: value forKey: @""];
element = [self _elementWithTag: @"tel" ofType: @"pager" forCard: newCard];
value = [properties objectForKey: MAPIPropertyKey(PR_PAGER_TELEPHONE_NUMBER_UNICODE)];
if (value)
[element setValue: 0 to: value];
[element setSingleValue: value forKey: @""];
element = [self _elementWithTag: @"tel" ofType: @"cell" forCard: newCard];
value = [properties objectForKey: MAPIPropertyKey(PR_MOBILE_TELEPHONE_NUMBER_UNICODE)];
if (value)
[element setValue: 0 to: value];
[element setSingleValue: value forKey: @""];
//
@ -1092,15 +1090,14 @@
if (value)
{
[[self _elementWithTag: @"url" ofType: @"work" forCard: newCard]
setValue: 0 to: value];
setSingleValue: value forKey: @""];
}
value = [properties objectForKey: MAPIPropertyKey(PidLidInstantMessagingAddress)];
if (value)
{
[[newCard uniqueChildWithTag: @"x-aim"]
setValue: 0
to: value];
setSingleValue: value forKey: @""];
}
value = [properties objectForKey: MAPIPropertyKey(PR_BIRTHDAY)];
@ -1117,6 +1114,22 @@
fromProperties: [attachment properties]];
}
/* Note */
value = [properties objectForKey: MAPIPropertyKey (PR_BODY_UNICODE)];
if (!value)
{
value = [properties objectForKey: MAPIPropertyKey (PR_HTML)];
if (value)
{
value = [[NSString alloc] initWithData: value
encoding: NSUTF8StringEncoding];
[value autorelease];
value = [value htmlToText];
}
}
if (value)
[newCard setNote: value];
//
// we save the new/modified card
//

View File

@ -56,6 +56,7 @@
#undef DEBUG
#include <stdbool.h>
#include <gen_ndr/exchange.h>
#include <util/attr.h>
#include <libmapiproxy.h>
#include <mapistore/mapistore.h>
#include <mapistore/mapistore_errors.h>

View File

@ -26,6 +26,8 @@
#import "MAPIStoreFAIMessage.h"
#undef DEBUG
#include <talloc.h>
#include <util/time.h>
#include <mapistore/mapistore.h>
@implementation MAPIStoreFAIMessage

View File

@ -28,6 +28,8 @@
#import "MAPIStoreFAIMessageTable.h"
#undef DEBUG
#include <talloc.h>
#include <util/time.h>
#include <mapistore/mapistore.h>
static Class MAPIStoreFAIMessageK = Nil;

View File

@ -34,9 +34,6 @@
#import "MAPIStoreFSBaseContext.h"
#undef DEBUG
#include <mapistore/mapistore.h>
static Class MAPIStoreFSFolderK;
@implementation MAPIStoreFSBaseContext

View File

@ -80,7 +80,7 @@
[sogoObject appendProperties: properties];
[sogoObject save];
[self resetProperties];
[properties removeAllObjects];
}
- (NSDate *) creationTime

View File

@ -51,6 +51,7 @@
#include <gen_ndr/exchange.h>
#undef DEBUG
#include <util/attr.h>
#include <libmapiproxy.h>
#include <mapistore/mapistore.h>
#include <mapistore/mapistore_nameid.h>
@ -898,33 +899,28 @@ Class NSExceptionK, MAPIStoreFAIMessageK, MAPIStoreMessageTableK, MAPIStoreFAIMe
return rc;
}
- (int) addPropertiesFromRow: (struct SRow *) aRow
- (void) addProperties: (NSDictionary *) newProperties
{
static enum MAPITAGS bannedProps[] = { PR_MID, PR_FID, PR_PARENT_FID,
PR_SOURCE_KEY, PR_PARENT_SOURCE_KEY,
PR_CHANGE_KEY, 0x00000000 };
enum MAPITAGS *currentProp;
int rc;
rc = [super addPropertiesFromRow: aRow];
NSMutableDictionary *propsCopy;
/* TODO: this should no longer be required once mapistore v2 API is in
place, when we can then do this from -dealloc below */
if ([properties count] > 0)
{
currentProp = bannedProps;
while (*currentProp)
{
[properties removeObjectForKey: MAPIPropertyKey (*currentProp)];
currentProp++;
}
[propsMessage appendProperties: properties];
[propsMessage save];
[self resetProperties];
propsCopy = [newProperties mutableCopy];
currentProp = bannedProps;
while (*currentProp)
{
[propsCopy removeObjectForKey: MAPIPropertyKey (*currentProp)];
currentProp++;
}
return rc;
[propsMessage appendProperties: propsCopy];
[propsMessage save];
[propsCopy release];
}
- (void) dealloc

View File

@ -64,6 +64,7 @@
static Class SOGoMailFolderK;
#undef DEBUG
#include <util/attr.h>
#include <libmapi/libmapi.h>
#include <mapistore/mapistore.h>
#include <mapistore/mapistore_errors.h>

View File

@ -48,6 +48,7 @@
#import "MAPIStoreMailAttachment.h"
#import "MAPIStoreMailFolder.h"
#import "MAPIStoreMapping.h"
#import "MAPIStoreSamDBUtils.h"
#import "MAPIStoreTypes.h"
#import "MAPIStoreMailMessage.h"
@ -263,6 +264,7 @@ _compareBodyKeysByPriority (id entry1, id entry2, void *data)
iCalCalendar *calendar;
iCalEvent *event;
NSString *stringValue, *senderEmail;
MAPIStoreContext *context;
if (!appointmentWrapper)
{
@ -280,11 +282,13 @@ _compareBodyKeysByPriority (id entry1, id entry2, void *data)
senderEmail = [[from objectAtIndex: 0] email];
else
senderEmail = nil;
context = [self context];
appointmentWrapper = [MAPIStoreAppointmentWrapper
wrapperWithICalEvent: event
andUser: [[self context] activeUser]
andUser: [context activeUser]
andSenderEmail: senderEmail
inTimeZone: [self ownerTimeZone]];
inTimeZone: [self ownerTimeZone]
withConnectionInfo: [context connectionInfo]];
[appointmentWrapper retain];
}
}
@ -721,6 +725,7 @@ _compareBodyKeysByPriority (id entry1, id entry2, void *data)
NSDictionary *contactInfos;
NGMailAddress *ngAddress;
NSData *entryId;
struct ldb_context *samCtx;
int rc;
if (fullMail)
@ -743,7 +748,8 @@ _compareBodyKeysByPriority (id entry1, id entry2, void *data)
if (contactInfos)
{
username = [contactInfos objectForKey: @"c_uid"];
entryId = MAPIStoreInternalEntryId (username);
samCtx = [[self context] connectionInfo]->sam_ctx;
entryId = MAPIStoreInternalEntryId (samCtx, username);
}
else
entryId = MAPIStoreExternalEntryId (cn, email);
@ -1349,9 +1355,11 @@ _compareBodyKeysByPriority (id entry1, id entry2, void *data)
NSData *entryId;
NSDictionary *contactInfos;
SOGoUserManager *mgr;
struct ldb_context *samCtx;
struct mapistore_message *msgData;
struct mapistore_message_recipient *recipient;
samCtx = [[self context] connectionInfo]->sam_ctx;
[super getMessageData: &msgData inMemCtx: memCtx];
if (!headerSetup)
@ -1397,7 +1405,7 @@ _compareBodyKeysByPriority (id entry1, id entry2, void *data)
{
username = [contactInfos objectForKey: @"c_uid"];
recipient->username = [username asUnicodeInMemCtx: msgData];
entryId = MAPIStoreInternalEntryId (username);
entryId = MAPIStoreInternalEntryId (samCtx, username);
}
else
{

View File

@ -54,6 +54,7 @@
#import "MAPIStoreMailFolder.h"
#import "MAPIStoreMIME.h"
#import "MAPIStoreMapping.h"
#import "MAPIStoreSamDBUtils.h"
#import "MAPIStoreTypes.h"
#import "NSData+MAPIStore.h"
#import "NSObject+MAPIStore.h"
@ -249,10 +250,13 @@ static NSString *recTypes[] = { @"orig", @"to", @"cc", @"bcc" };
NSData *entryId;
NSDictionary *allRecipients, *dict, *contactInfos;
SOGoUserManager *mgr;
struct ldb_context *samCtx;
struct mapistore_message *msgData;
struct mapistore_message_recipient *recipient;
enum ulRecipClass type;
samCtx = [[self context] connectionInfo]->sam_ctx;
[super getMessageData: &msgData inMemCtx: memCtx];
allRecipients = [[sogoObject properties] objectForKey: @"recipients"];
@ -295,7 +299,7 @@ static NSString *recTypes[] = { @"orig", @"to", @"cc", @"bcc" };
{
username = [contactInfos objectForKey: @"c_uid"];
recipient->username = [username asUnicodeInMemCtx: msgData];
entryId = MAPIStoreInternalEntryId (username);
entryId = MAPIStoreInternalEntryId (samCtx, username);
}
else
{
@ -759,7 +763,7 @@ MakeMessageBody (NSDictionary *mailProperties, NSDictionary *attachmentParts,
messageData = cleanedMessage;
}
[messageData writeToFile: @"/tmp/mimegen.eml" atomically: NO];
// [messageData writeToFile: @"/tmp/mimegen.eml" atomically: NO];
return messageData;
}
@ -812,7 +816,7 @@ MakeMessageBody (NSDictionary *mailProperties, NSDictionary *attachmentParts,
mapping = [[self context] mapping];
[mapping unregisterURLWithID: [self objectId]];
[self setIsNew: NO];
[self resetProperties];
[properties removeAllObjects];
[[self container] cleanupCaches];
return MAPISTORE_SUCCESS;

View File

@ -37,9 +37,6 @@
#import "MAPIStoreObject.h"
extern NSData *MAPIStoreInternalEntryId (NSString *username);
extern NSData *MAPIStoreExternalEntryId (NSString *cn, NSString *email);
@interface MAPIStoreMessage : MAPIStoreObject
{
NSArray *attachmentKeys;

View File

@ -21,6 +21,7 @@
*/
#import <Foundation/NSArray.h>
#import <Foundation/NSBundle.h>
#import <Foundation/NSData.h>
#import <Foundation/NSDictionary.h>
#import <Foundation/NSString.h>
@ -35,6 +36,7 @@
#import "MAPIStoreContext.h"
#import "MAPIStoreFolder.h"
#import "MAPIStorePropertySelectors.h"
#import "MAPIStoreSamDBUtils.h"
#import "MAPIStoreTypes.h"
#import "NSData+MAPIStore.h"
#import "NSObject+MAPIStore.h"
@ -42,6 +44,8 @@
#import "MAPIStoreMessage.h"
#include <unrtf.h>
#undef DEBUG
#include <stdbool.h>
#include <gen_ndr/exchange.h>
@ -49,102 +53,64 @@
#include <mapistore/mapistore_errors.h>
#include <mapistore/mapistore_nameid.h>
NSData *
MAPIStoreInternalEntryId (NSString *username)
static NSString *resourcesDir = nil;
/* rtf conversion via unrtf */
static int
unrtf_data_output (void *data, const char *str, size_t str_len)
{
NSMutableData *entryId;
static uint8_t providerUid[] = { 0xdc, 0xa7, 0x40, 0xc8,
0xc0, 0x42, 0x10, 0x1a,
0xb4, 0xb9, 0x08, 0x00,
0x2b, 0x2f, 0xe1, 0x82 };
NSString *x500dn;
NSMutableData *rtfData = data;
/* structure:
flags: 32
provideruid: 32 * 4
version: 32
type: 32
X500DN: variable */
[rtfData appendBytes: str length: str_len];
entryId = [NSMutableData dataWithCapacity: 256];
[entryId appendUInt32: 0]; // flags
[entryId appendBytes: providerUid length: 16]; // provideruid
[entryId appendUInt32: 1]; // version
[entryId appendUInt32: 0]; // type (local mail user)
/* X500DN */
/* FIXME: the DN will likely work on DEMO installations for now but we
really should get the dn prefix from the server */
x500dn = [NSString stringWithFormat: @"/O=FIRST ORGANIZATION"
@"/OU=FIRST ADMINISTRATIVE GROUP"
@"/CN=RECIPIENTS/CN=%@", username];
[entryId appendData: [x500dn dataUsingEncoding: NSISOLatin1StringEncoding]];
[entryId appendUInt8: 0];
return entryId;
return str_len;
}
NSData *
MAPIStoreExternalEntryId (NSString *cn, NSString *email)
static NSData *
uncompressRTF (NSData *compressedRTF)
{
NSMutableData *entryId;
static uint8_t providerUid[] = { 0x81, 0x2b, 0x1f, 0xa4,
0xbe, 0xa3, 0x10, 0x19,
0x9d, 0x6e, 0x00, 0xdd,
0x01, 0x0f, 0x54, 0x02 };
uint8_t flags21, flags22;
NSData *rtfData = nil;
DATA_BLOB *rtf;
TALLOC_CTX *mem_ctx;
/* structure:
flags: 32
provideruid: 32 * 4
version: 16
{
PaD: 1
MAE: 2
Format: 4
M: 1
U: 1
R: 2
L: 1
Pad: 4
}
DisplayName: variable
AddressType: variable
EmailAddress: variable */
mem_ctx = talloc_zero (NULL, TALLOC_CTX);
rtf = talloc_zero (mem_ctx, DATA_BLOB);
entryId = [NSMutableData dataWithCapacity: 256];
[entryId appendUInt32: 0]; // flags
[entryId appendBytes: providerUid length: 16]; // provideruid
[entryId appendUInt16: 0]; // version
if (uncompress_rtf (mem_ctx,
(uint8_t *) [compressedRTF bytes], [compressedRTF length],
rtf)
== MAPI_E_SUCCESS)
rtfData = [NSData dataWithBytes: rtf->data length: rtf->length];
flags21 = 0; /* PaD, MAE, R, Pad = 0 */
flags21 |= 0x16; /* Format: text and HTML */
flags21 |= 0x01; /* M: mime format */
talloc_free (mem_ctx);
flags22 = 0x90; /* U: unicode, L: no lookup */
[entryId appendUInt8: flags21];
[entryId appendUInt8: flags22];
return rtfData;
}
/* DisplayName */
if (!cn)
cn = @"";
[entryId
appendData: [cn dataUsingEncoding: NSUTF16LittleEndianStringEncoding]];
[entryId appendUInt16: 0];
static NSData *
rtf2html (NSData *compressedRTF)
{
NSData *rtf;
NSMutableData *html = nil;
int rc;
struct unRTFOptions unrtfOptions;
/* AddressType */
[entryId
appendData: [@"SMTP" dataUsingEncoding: NSUTF16LittleEndianStringEncoding]];
[entryId appendUInt16: 0];
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;
}
/* EMailAddress */
if (!email)
email = @"";
[entryId
appendData: [email dataUsingEncoding: NSUTF16LittleEndianStringEncoding]];
[entryId appendUInt16: 0];
return entryId;
return html;
}
@interface SOGoObject (MAPIStoreProtocol)
@ -156,6 +122,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 +279,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;
@ -460,7 +467,7 @@ MAPIStoreExternalEntryId (NSString *cn, NSString *email)
[[containerTables objectAtIndex: count]
notifyChangesForChild: self];
[self setIsNew: NO];
[self resetProperties];
[properties removeAllObjects];
[container cleanupCaches];
return MAPISTORE_SUCCESS;
@ -744,7 +751,7 @@ MAPIStoreExternalEntryId (NSString *cn, NSString *email)
- (int) setReadFlag: (uint8_t) flag
{
[self subclassResponsibility: _cmd];
// [self subclassResponsibility: _cmd];
return MAPISTORE_ERROR;
}

View File

@ -86,7 +86,6 @@
- (void) addProperties: (NSDictionary *) newProperties;
- (NSDictionary *) properties;
- (void) resetProperties;
/* ops */
- (int) getAvailableProperties: (struct SPropTagArray **) propertiesP

View File

@ -235,11 +235,6 @@ static Class NSExceptionK, MAPIStoreFolderK;
return properties;
}
- (void) resetProperties
{
[properties removeAllObjects];
}
- (int) getProperty: (void **) data
withTag: (enum MAPITAGS) propTag
inMemCtx: (TALLOC_CTX *) memCtx
@ -451,14 +446,18 @@ static Class NSExceptionK, MAPIStoreFolderK;
{
struct SPropValue *cValue;
NSUInteger counter;
NSMutableDictionary *newProperties;
newProperties = [NSMutableDictionary dictionaryWithCapacity: aRow->cValues];
for (counter = 0; counter < aRow->cValues; counter++)
{
cValue = aRow->lpProps + counter;
[properties setObject: NSObjectFromSPropValue (cValue)
forKey: MAPIPropertyKey (cValue->ulPropTag)];
[newProperties setObject: NSObjectFromSPropValue (cValue)
forKey: MAPIPropertyKey (cValue->ulPropTag)];
}
[self addProperties: newProperties];
return MAPISTORE_SUCCESS;
}

View File

@ -26,9 +26,6 @@
#import <NGCards/iCalCalendar.h>
#import <NGCards/iCalRecurrenceRule.h>
#include <stdbool.h>
#include <gen_ndr/property.h>
@class NSCalendarDate;
@class iCalRepeatableEntityObject;
@class iCalRecurrenceRule;

View File

@ -32,6 +32,10 @@
#import "NSDate+MAPIStore.h"
#import "MAPIStoreRecurrenceUtils.h"
#include <talloc.h>
#include <util/time.h>
#include <gen_ndr/property.h>
@implementation iCalCalendar (MAPIStoreRecurrence)
- (void) setupRecurrenceWithMasterEntity: (iCalRepeatableEntityObject *) entity
@ -92,7 +96,7 @@
[rule setFrequency: iCalRecurrenceFrequenceYearly];
[rule setRepeatInterval: rp->Period / 12];
month = [NSString stringWithFormat: @"%d", [startDate monthOfYear]];
[rule setNamedValue: @"bymonth" to: month];
[rule setSingleValue: month forKey: @"bymonth"];
}
else
[self errorWithFormat:
@ -112,7 +116,7 @@
else
monthDay = [NSString stringWithFormat: @"%d",
rp->PatternTypeSpecific.MonthRecurrencePattern.N];
[rule setNamedValue: @"bymonthday" to: monthDay];
[rule setSingleValue: monthDay forKey: @"bymonthday"];
}
else if ((rp->PatternTypeSpecific.MonthRecurrencePattern.WeekRecurrencePattern
== 0x3e) /* Nth week day */
@ -135,8 +139,9 @@
else
bySetPos = rp->PatternTypeSpecific.MonthRecurrencePattern.N;
[rule setNamedValue: @"bysetpos"
to: [NSString stringWithFormat: @"%d", bySetPos]];
[rule
setSingleValue: [NSString stringWithFormat: @"%d", bySetPos]
forKey: @"bysetpos"];
}
else
{
@ -163,9 +168,10 @@
|| (rp->PatternType & 4) == 4)
{
/* MonthEnd, HjMonth and HjMonthEnd */
[rule setNamedValue: @"bymonthday"
to: [NSString stringWithFormat: @"%d",
rp->PatternTypeSpecific.Day]];
[rule
setSingleValue: [NSString stringWithFormat: @"%d",
rp->PatternTypeSpecific.Day]
forKey: @"bymonthday"];
}
else
[self errorWithFormat: @"invalid value for PatternType: %.4x",
@ -305,6 +311,14 @@
rp->FirstDateTime = [moduloDate asMinutesSince1601];
byMonthDay = [[self byMonthDay] objectAtIndex: 0];
if (!byMonthDay && (freq == iCalRecurrenceFrequenceYearly))
{
byMonthDay = [NSString stringWithFormat: @"%d", [startDate dayOfMonth]];
[self warnWithFormat: @"no month day specified in yearly"
@" recurrence: we deduce it from the start date: %@",
byMonthDay];
}
if (byMonthDay)
{
if ([byMonthDay intValue] < 0)
@ -325,15 +339,18 @@
{
rp->PatternType = PatternType_MonthNth;
byDayMask = [self byDayMask];
days = [byDayMask weekDayOccurrences];
mask = 0;
for (count = 0; count < 7; count++)
if (days[0][count])
mask |= 1 << count;
days = [byDayMask weekDayOccurrences];
if (days)
{
for (count = 0; count < 7; count++)
if (days[0][count])
mask |= 1 << count;
}
if (mask)
{
rp->PatternTypeSpecific.MonthRecurrencePattern.WeekRecurrencePattern = mask;
bySetPos = [self namedValue: @"bysetpos"];
bySetPos = [self flattenedValuesForKey: @"bysetpos"];
if ([bySetPos length])
rp->PatternTypeSpecific.MonthRecurrencePattern.N
= ([bySetPos hasPrefix: @"-"]

View File

@ -0,0 +1,37 @@
/* MAPIStoreSamDBUtils.h - this file is part of SOGo
*
* Copyright (C) 2011 Inverse inc
*
* Author: Wolfgang Sourdeau <wsourdeau@inverse.ca>
*
* This file 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 2, or (at your option)
* any later version.
*
* This file 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; see the file COPYING. If not, write to
* the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/
#ifndef MAPISTORESAMDBUTILS_H
#define MAPISTORESAMDBUTILS_H
@class NSString;
struct ldb_context;
NSString *MAPIStoreSamDBUserAttribute (struct ldb_context *samCtx,
NSString *userKey,
NSString *value,
NSString *attributeName);
NSData *MAPIStoreInternalEntryId (struct ldb_context *, NSString *username);
NSData *MAPIStoreExternalEntryId (NSString *cn, NSString *email);
#endif /* MAPISTORESAMDBUTILS_H */

View File

@ -0,0 +1,165 @@
/* MAPIStoreSamDBUtils.m - this file is part of SOGo
*
* Copyright (C) 2011 Inverse inc
*
* Author: Wolfgang Sourdeau <wsourdeau@inverse.ca>
*
* This file 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 2, or (at your option)
* any later version.
*
* This file 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; see the file COPYING. If not, write to
* the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/
#import <Foundation/NSData.h>
#import <Foundation/NSString.h>
#include <talloc.h>
#include <ldb.h>
#import "NSData+MAPIStore.h"
#import "MAPIStoreSamDBUtils.h"
NSString *
MAPIStoreSamDBUserAttribute (struct ldb_context *samCtx,
NSString *userKey,
NSString *value,
NSString *attributeName)
{
NSString *resultValue = nil;
const char *attrs[] = { "", NULL };
NSString *searchFormat;
const char *result;
struct ldb_result *res = NULL;
TALLOC_CTX *memCtx;
int ret;
memCtx = talloc_zero(NULL, TALLOC_CTX);
attrs[0] = [attributeName UTF8String];
searchFormat
= [NSString stringWithFormat: @"(&(objectClass=user)(%@=%%s))", userKey];
ret = ldb_search (samCtx, memCtx, &res, ldb_get_default_basedn(samCtx),
LDB_SCOPE_SUBTREE, attrs,
[searchFormat UTF8String],
[value UTF8String]);
if (ret == LDB_SUCCESS && res->count == 1)
{
result = ldb_msg_find_attr_as_string (res->msgs[0], attrs[0], NULL);
if (result)
resultValue = [NSString stringWithUTF8String: result];
}
talloc_free (memCtx);
return resultValue;
}
NSData *
MAPIStoreInternalEntryId (struct ldb_context *samCtx, NSString *username)
{
static const uint8_t const providerUid[] = { 0xdc, 0xa7, 0x40, 0xc8,
0xc0, 0x42, 0x10, 0x1a,
0xb4, 0xb9, 0x08, 0x00,
0x2b, 0x2f, 0xe1, 0x82 };
NSMutableData *entryId;
NSData *legacyDNData;
NSString *legacyDN;
/* structure:
flags: 32
provideruid: 32 * 4
version: 32
type: 32
X500DN: variable */
legacyDN = MAPIStoreSamDBUserAttribute (samCtx, @"sAMAccountName", username,
@"legacyExchangeDN");
if (legacyDN)
{
entryId = [NSMutableData dataWithCapacity: 256];
[entryId appendUInt32: 0]; // flags
[entryId appendBytes: providerUid length: 16]; // provideruid
[entryId appendUInt32: 1]; // version
[entryId appendUInt32: 0]; // type (local mail user)
legacyDNData = [legacyDN dataUsingEncoding: NSASCIIStringEncoding];
[entryId appendData: legacyDNData]; // x500dn
[entryId appendUInt8: 0]; // end of string
}
else
entryId = nil;
return entryId;
}
NSData *
MAPIStoreExternalEntryId (NSString *cn, NSString *email)
{
NSMutableData *entryId;
static uint8_t providerUid[] = { 0x81, 0x2b, 0x1f, 0xa4,
0xbe, 0xa3, 0x10, 0x19,
0x9d, 0x6e, 0x00, 0xdd,
0x01, 0x0f, 0x54, 0x02 };
uint8_t flags21, flags22;
/* structure:
flags: 32
provideruid: 32 * 4
version: 16
{
PaD: 1
MAE: 2
Format: 4
M: 1
U: 1
R: 2
L: 1
Pad: 4
}
DisplayName: variable
AddressType: variable
EmailAddress: variable */
entryId = [NSMutableData dataWithCapacity: 256];
[entryId appendUInt32: 0]; // flags
[entryId appendBytes: providerUid length: 16]; // provideruid
[entryId appendUInt16: 0]; // version
flags21 = 0; /* PaD, MAE, R, Pad = 0 */
flags21 |= 0x16; /* Format: text and HTML */
flags21 |= 0x01; /* M: mime format */
flags22 = 0x90; /* U: unicode, L: no lookup */
[entryId appendUInt8: flags21];
[entryId appendUInt8: flags22];
/* DisplayName */
if (!cn)
cn = @"";
[entryId
appendData: [cn dataUsingEncoding: NSUTF16LittleEndianStringEncoding]];
[entryId appendUInt16: 0];
/* AddressType */
[entryId
appendData: [@"SMTP" dataUsingEncoding: NSUTF16LittleEndianStringEncoding]];
[entryId appendUInt16: 0];
/* EMailAddress */
if (!email)
email = @"";
[entryId
appendData: [email dataUsingEncoding: NSUTF16LittleEndianStringEncoding]];
[entryId appendUInt16: 0];
return entryId;
}

View File

@ -26,6 +26,8 @@
#import <Foundation/NSValue.h>
#include <stdbool.h>
#include <talloc.h>
#include <util/time.h>
#include <gen_ndr/exchange.h>
@class NSData;

View File

@ -20,13 +20,6 @@
* Boston, MA 02111-1307, USA.
*/
#undef DEBUG
#include <talloc.h>
#include <mapistore/mapistore.h>
#include <mapistore/mapistore_errors.h>
#include <libmapi/libmapi.h>
#include <libmapiproxy.h>
#import <Foundation/NSArray.h>
#import <Foundation/NSDictionary.h>
#import <Foundation/NSException.h>
@ -38,6 +31,10 @@
#import "MAPIStoreTypes.h"
#undef DEBUG
#include <mapistore/mapistore.h>
#include <mapistore/mapistore_errors.h>
uint8_t *
MAPIBoolValue (void *memCtx, BOOL value)
{

View File

@ -80,25 +80,10 @@ Class NSNumberK;
[super dealloc];
}
- (int) addPropertiesFromRow: (struct SRow *) aRow
{
int rc;
rc = [super addPropertiesFromRow: aRow];
if (rc == MAPISTORE_SUCCESS)
{
[sogoObject appendProperties: properties];
[properties removeAllObjects];
ASSIGN (lastModificationTime, [NSDate date]);
}
return rc;
}
- (void) addProperties: (NSDictionary *) newProperties
{
[super addProperties: newProperties];
[sogoObject appendProperties: newProperties];
[sogoObject appendProperties: properties];
[properties removeAllObjects];
ASSIGN (lastModificationTime, [NSDate date]);
}

View File

@ -28,6 +28,7 @@
#undef DEBUG
#include <talloc.h>
#include <util/time.h>
#include <mapistore/mapistore.h>
@implementation NSArray (MAPIStoreFolders)

View File

@ -24,8 +24,9 @@
#undef DEBUG
#include <stdbool.h>
#include <gen_ndr/exchange.h>
#include <talloc.h>
#include <util/time.h>
#include <gen_ndr/exchange.h>
@implementation NSData (MAPIStoreDataTypes)

View File

@ -27,8 +27,9 @@
#import "NSDate+MAPIStore.h"
#undef DEBUG
#include <mapistore/mapistore.h>
#include <talloc.h>
#include <util/time.h>
#include <mapistore/mapistore.h>
static NSCalendarDate *refDate = nil;

View File

@ -28,6 +28,8 @@
#import "NSString+MAPIStore.h"
#undef DEBUG
#include <talloc.h>
#include <util/time.h>
#include <mapistore/mapistore.h>
@implementation NSString (MAPIStoreDataTypes)

View File

@ -35,6 +35,8 @@
#import "SOGoMAPIFSFolder.h"
#undef DEBUG
#include <talloc.h>
#include <util/time.h>
#include <mapistore/mapistore.h>
#include <mapistore/mapistore_errors.h>
#include <libmapiproxy.h>

View File

@ -81,6 +81,8 @@ h_template = """/* %(filename)s (auto-generated) - this file is part of SOGo
#import <Foundation/NSObjCRuntime.h>
#include <stdbool.h>
#include <talloc.h>
#include <util/time.h>
#include <gen_ndr/exchange.h>
extern const NSUInteger MAPIStorePropertyGettersCount;

File diff suppressed because it is too large Load Diff

Binary file not shown.

View 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 */

View File

@ -1986,7 +1986,7 @@ static NSArray *childRecordFields = nil;
[r appendFormat: @"<D:response><D:href>"];
[r appendString: baseURL];
[r appendString: [object objectForKey: @"c_name"]];
[r appendString: [[object objectForKey: @"c_name"] stringByEscapingURL]];
[r appendString: @"</D:href>"];
// NSLog (@"(appendPropstats...): %@", [NSDate date]);
@ -2032,7 +2032,7 @@ static NSArray *childRecordFields = nil;
for (count = 0; count < max; count++)
{
element = [refs objectAtIndex: count];
currentURL = [[element firstChild] nodeValue];
currentURL = [[[element firstChild] nodeValue] stringByUnescapingURL];
[urls addObject: currentURL];
}

View File

@ -629,7 +629,7 @@ static NSString *sieveScriptName = @"sogo";
NGSieveClient *client;
NSString *filterScript, *v, *sieveServer;
int sievePort;
BOOL b;
BOOL b, connected;
dd = [user domainDefaults];
if (!([dd sieveScriptsEnabled] || [dd vacationEnabled] || [dd forwardEnabled]))
@ -637,6 +637,8 @@ static NSString *sieveScriptName = @"sogo";
req = [NSMutableArray arrayWithCapacity: 15];
ud = [user userDefaults];
connected = YES;
b = NO;
script = [NSMutableString string];
@ -793,7 +795,23 @@ static NSString *sieveScriptName = @"sogo";
[client closeConnection];
return NO;
}
result = [client login: theLogin authname: theAuthName password: thePassword];
NS_DURING
{
result = [client login: theLogin authname: theAuthName password: thePassword];
}
NS_HANDLER
{
connected = NO;
}
NS_ENDHANDLER
if (!connected)
{
NSLog(@"Sieve connection failed on %@", [address description]);
return NO;
}
if (![[result valueForKey:@"result"] boolValue]) {
NSLog(@"failure. Attempting with a renewed password (no authname supported)");
thePassword = [theAccount imap4PasswordRenewed: YES];

View File

@ -282,4 +282,4 @@
"Password change is not supported." = "Changement de mot de passe non-supporté.";
"Unhandled HTTP error code: %{0}" = "Code HTTP non-géré: %{0}";
"New password:" = "Nova senha:";
"Confirmation:" = "Confirmação:";
"Confirmation:" = "Confirmação:";

View File

@ -282,4 +282,4 @@
"Password change is not supported." = "Changement de mot de passe non-supporté.";
"Unhandled HTTP error code: %{0}" = "Code HTTP non-géré: %{0}";
"New password:" = "Új jelszó:";
"Confirmation:" = "Megerősítés:";
"Confirmation:" = "Megerősítés:";

View File

@ -282,4 +282,4 @@
"Password change is not supported." = "Changement de mot de passe non-supporté.";
"Unhandled HTTP error code: %{0}" = "Code HTTP non-géré: %{0}";
"New password:" = "Nytt passord:";
"Confirmation:" = "Bekreft:";
"Confirmation:" = "Bekreft:";

View File

@ -284,4 +284,4 @@ Servernamn:";
"Password change is not supported." = "Changement de mot de passe non-supporté.";
"Unhandled HTTP error code: %{0}" = "Code HTTP non-géré: %{0}";
"New password:" = "Nytt lösenord:";
"Confirmation:" = "Bekräfta:";
"Confirmation:" = "Bekräfta:";

View File

@ -282,4 +282,4 @@
"Password change is not supported." = "Changement de mot de passe non-supporté.";
"Unhandled HTTP error code: %{0}" = "Code HTTP non-géré: %{0}";
"New password:" = "New password:";
"Confirmation:" = "Confirmation:";
"Confirmation:" = "Confirmation:";