Monotone-Parent: 0ad1e10fb7587b8444bd502de4908d1aabf70c96

Monotone-Revision: a6b977673a1cc94b1269e19c469101dca9fd17bc

Monotone-Author: wsourdeau@inverse.ca
Monotone-Date: 2012-07-01T20:58:46
Monotone-Branch: ca.inverse.sogo
This commit is contained in:
Wolfgang Sourdeau 2012-07-01 20:58:46 +00:00
parent 674fb1081c
commit b3acd2e2ad
5 changed files with 98 additions and 55 deletions

View file

@ -1,5 +1,13 @@
2012-07-01 Wolfgang Sourdeau <wsourdeau@inverse.ca> 2012-07-01 Wolfgang Sourdeau <wsourdeau@inverse.ca>
* OpenChange/MAPIStoreRecurrenceUtils.m
(-setupRecurrenceWithMasterEntity:fromRecurrencePattern:): add
exception dates to master entity based on the
"DeletedInstanceDates" member of the struct.
(-fillRecurrencePattern:withEvent:inTimeZone:inMemCtx:): new name
for fillRecurrencePattern:withStartDate:andEndDate:, add exception
dates to struct.
* OpenChange/NSDate+MAPIStore.m (NSDateCompare): new comparison * OpenChange/NSDate+MAPIStore.m (NSDateCompare): new comparison
function for sorting array of NSDate instances. function for sorting array of NSDate instances.

View file

@ -28,11 +28,8 @@
#import <Foundation/NSTimeZone.h> #import <Foundation/NSTimeZone.h>
#import <NGExtensions/NSObject+Logs.h> #import <NGExtensions/NSObject+Logs.h>
#import <NGCards/iCalAlarm.h> #import <NGCards/iCalAlarm.h>
#import <NGCards/iCalDateTime.h>
#import <NGCards/iCalEvent.h> #import <NGCards/iCalEvent.h>
#import <NGCards/iCalPerson.h> #import <NGCards/iCalPerson.h>
#import <NGCards/iCalRecurrenceRule.h>
#import <NGCards/iCalTimeZone.h>
#import <NGCards/iCalTrigger.h> #import <NGCards/iCalTrigger.h>
#import <NGCards/NSString+NGCards.h> #import <NGCards/NSString+NGCards.h>
#import <SOGo/SOGoUser.h> #import <SOGo/SOGoUser.h>
@ -995,7 +992,8 @@ static NSCharacterSet *hexCharacterSet = nil;
return [self getPidLidLocation: data inMemCtx: memCtx]; return [self getPidLidLocation: data inMemCtx: memCtx];
} }
- (int) getPidLidServerProcessed: (void **) data inMemCtx: (TALLOC_CTX *) memCtx - (int) getPidLidServerProcessed: (void **) data
inMemCtx: (TALLOC_CTX *) memCtx
{ {
/* TODO: we need to check whether the event has been processed internally by /* TODO: we need to check whether the event has been processed internally by
SOGo or if it was received only by mail. We only assume the SOGo case SOGo or if it was received only by mail. We only assume the SOGo case
@ -1003,7 +1001,8 @@ static NSCharacterSet *hexCharacterSet = nil;
return [self getYes: data inMemCtx: memCtx]; return [self getYes: data inMemCtx: memCtx];
} }
- (int) getPidLidServerProcessingActions: (void **) data inMemCtx: (TALLOC_CTX *) memCtx - (int) getPidLidServerProcessingActions: (void **) data
inMemCtx: (TALLOC_CTX *) memCtx
{ {
*data = MAPILongValue (memCtx, *data = MAPILongValue (memCtx,
0x00000010 /* cpsCreatedOnPrincipal */ 0x00000010 /* cpsCreatedOnPrincipal */
@ -1074,29 +1073,6 @@ static NSCharacterSet *hexCharacterSet = nil;
return MAPISTORE_SUCCESS; return MAPISTORE_SUCCESS;
} }
static void
_fillAppointmentRecurrencePattern (struct AppointmentRecurrencePattern *arp,
NSCalendarDate *startDate, NSTimeInterval duration,
NSCalendarDate * endDate, iCalRecurrenceRule *rule)
{
uint32_t startMinutes;
[rule fillRecurrencePattern: &arp->RecurrencePattern
withStartDate: startDate andEndDate: endDate];
arp->ReaderVersion2 = 0x00003006;
arp->WriterVersion2 = 0x00003009;
startMinutes = ([startDate hourOfDay] * 60 + [startDate minuteOfHour]);
arp->StartTimeOffset = startMinutes;
arp->EndTimeOffset = startMinutes + (uint32_t) (duration / 60);
arp->ExceptionCount = 0;
arp->ReservedBlock1Size = 0;
/* Currently ignored in property.idl:
arp->ReservedBlock2Size = 0; */
}
- (struct SBinary_short *) _computeAppointmentRecurInMemCtx: (TALLOC_CTX *) memCtx - (struct SBinary_short *) _computeAppointmentRecurInMemCtx: (TALLOC_CTX *) memCtx
{ {
@ -1105,6 +1081,7 @@ _fillAppointmentRecurrencePattern (struct AppointmentRecurrencePattern *arp,
struct SBinary_short *sBin; struct SBinary_short *sBin;
NSCalendarDate *firstStartDate; NSCalendarDate *firstStartDate;
iCalRecurrenceRule *rule; iCalRecurrenceRule *rule;
NSUInteger startMinutes;
rule = [[event recurrenceRules] objectAtIndex: 0]; rule = [[event recurrenceRules] objectAtIndex: 0];
@ -1114,10 +1091,27 @@ _fillAppointmentRecurrencePattern (struct AppointmentRecurrencePattern *arp,
[firstStartDate setTimeZone: timeZone]; [firstStartDate setTimeZone: timeZone];
arp = talloc_zero (memCtx, struct AppointmentRecurrencePattern); arp = talloc_zero (memCtx, struct AppointmentRecurrencePattern);
_fillAppointmentRecurrencePattern (arp, firstStartDate, [rule fillRecurrencePattern: &arp->RecurrencePattern
[event durationAsTimeInterval], withEvent: event
[event lastPossibleRecurrenceStartDate], inTimeZone: timeZone
rule); inMemCtx: arp];
arp->ReaderVersion2 = 0x00003006;
arp->WriterVersion2 = 0x00003009;
startMinutes = ([firstStartDate hourOfDay] * 60
+ [firstStartDate minuteOfHour]);
arp->StartTimeOffset = startMinutes;
arp->EndTimeOffset = (startMinutes
+ (NSUInteger) ([event durationAsTimeInterval]
/ 60));
arp->ExceptionCount = 0;
arp->ReservedBlock1Size = 0;
/* Currently ignored in property.idl: arp->ReservedBlock2Size = 0; */
/* convert struct to blob */
sBin = talloc_zero (memCtx, struct SBinary_short); sBin = talloc_zero (memCtx, struct SBinary_short);
bin = set_AppointmentRecurrencePattern (sBin, arp); bin = set_AppointmentRecurrencePattern (sBin, arp);
sBin->cb = bin->cb; sBin->cb = bin->cb;

View file

@ -23,10 +23,14 @@
#ifndef MAPISTORERECURRENCEUTILS_H #ifndef MAPISTORERECURRENCEUTILS_H
#define MAPISTORERECURRENCEUTILS_H #define MAPISTORERECURRENCEUTILS_H
#include <talloc.h>
#import <NGCards/iCalCalendar.h> #import <NGCards/iCalCalendar.h>
#import <NGCards/iCalRecurrenceRule.h> #import <NGCards/iCalRecurrenceRule.h>
@class NSCalendarDate; @class NSTimeZone;
@class iCalEvent;
@class iCalRepeatableEntityObject; @class iCalRepeatableEntityObject;
@class iCalRecurrenceRule; @class iCalRecurrenceRule;
@ -44,8 +48,9 @@
@interface iCalRecurrenceRule (MAPIStoreRecurrence) @interface iCalRecurrenceRule (MAPIStoreRecurrence)
- (void) fillRecurrencePattern: (struct RecurrencePattern *) rp - (void) fillRecurrencePattern: (struct RecurrencePattern *) rp
withStartDate: (NSCalendarDate *) startDate withEvent: (iCalEvent *) event
andEndDate: (NSCalendarDate *) endDate; inTimeZone: (NSTimeZone *) timeZone
inMemCtx: (TALLOC_CTX *) memCtx;
@end @end

View file

@ -21,17 +21,22 @@
*/ */
#import <Foundation/NSArray.h> #import <Foundation/NSArray.h>
#import <Foundation/NSCalendarDate.h>
#import <Foundation/NSString.h> #import <Foundation/NSString.h>
#import <NGExtensions/NSCalendarDate+misc.h> #import <NGExtensions/NSCalendarDate+misc.h>
#import <NGExtensions/NSObject+Logs.h> #import <NGExtensions/NSObject+Logs.h>
#import <NGCards/iCalByDayMask.h>
#import <NGCards/iCalDateTime.h>
#import <NGCards/iCalEvent.h>
#import <NGCards/iCalRepeatableEntityObject.h> #import <NGCards/iCalRepeatableEntityObject.h>
#import <NGCards/iCalRecurrenceRule.h> #import <NGCards/iCalRecurrenceRule.h>
#import <NGCards/iCalByDayMask.h> #import <NGCards/iCalTimeZone.h>
#import "NSDate+MAPIStore.h" #import "NSDate+MAPIStore.h"
#import "MAPIStoreRecurrenceUtils.h" #import "MAPIStoreRecurrenceUtils.h"
#import "MAPIStoreTypes.h"
#include <stdbool.h> #include <stdbool.h>
#include <talloc.h> #include <talloc.h>
@ -43,7 +48,7 @@
- (void) setupRecurrenceWithMasterEntity: (iCalRepeatableEntityObject *) entity - (void) setupRecurrenceWithMasterEntity: (iCalRepeatableEntityObject *) entity
fromRecurrencePattern: (struct RecurrencePattern *) rp fromRecurrencePattern: (struct RecurrencePattern *) rp
{ {
NSCalendarDate *startDate, *olEndDate, *untilDate; NSCalendarDate *startDate, *olEndDate, *untilDate, *exDate;
NSString *monthDay, *month; NSString *monthDay, *month;
iCalRecurrenceRule *rule; iCalRecurrenceRule *rule;
iCalByDayMask *byDayMask; iCalByDayMask *byDayMask;
@ -203,6 +208,17 @@
[self errorWithFormat: @"invalid value for EndType: %.4x", [self errorWithFormat: @"invalid value for EndType: %.4x",
rp->EndType]; rp->EndType];
} }
/* exception dates */
for (count = 0; count < rp->DeletedInstanceCount; count++)
{
exDate
= [NSDate dateFromMinutesSince1601: rp->DeletedInstanceDates[count]];
exDate = [exDate hour: [startDate hourOfDay]
minute: [startDate minuteOfHour]
second: [startDate secondOfMinute]];
[entity addToExceptionDates: exDate];
}
} }
@end @end
@ -210,16 +226,23 @@
@implementation iCalRecurrenceRule (MAPIStoreRecurrence) @implementation iCalRecurrenceRule (MAPIStoreRecurrence)
- (void) fillRecurrencePattern: (struct RecurrencePattern *) rp - (void) fillRecurrencePattern: (struct RecurrencePattern *) rp
withStartDate: (NSCalendarDate *) startDate withEvent: (iCalEvent *) event
andEndDate: (NSCalendarDate *) endDate inTimeZone: (NSTimeZone *) timeZone
inMemCtx: (TALLOC_CTX *) memCtx
{ {
iCalRecurrenceFrequency freq; iCalRecurrenceFrequency freq;
iCalByDayMask *byDayMask; iCalByDayMask *byDayMask;
NSString *byMonthDay, *bySetPos; NSString *byMonthDay, *bySetPos;
NSCalendarDate *untilDate, *beginOfWeek, *minimumDate, *moduloDate, *midnight; NSCalendarDate *startDate, *endDate, *untilDate, *beginOfWeek, *minimumDate, *moduloDate, *midnight;
iCalWeekOccurrences *days; iCalWeekOccurrences *days;
NSInteger dayOfWeek, repeatInterval, repeatCount, count, firstOccurrence; NSInteger dayOfWeek, repeatInterval, repeatCount, count, firstOccurrence, max;
uint32_t nbrMonths, mask; uint32_t nbrMonths, mask;
NSArray *exDates;
startDate = [event firstRecurrenceStartDate];
[startDate setTimeZone: timeZone];
endDate = [event lastPossibleRecurrenceStartDate];
[endDate setTimeZone: timeZone];
rp->ReaderVersion = 0x3004; rp->ReaderVersion = 0x3004;
rp->WriterVersion = 0x3004; rp->WriterVersion = 0x3004;
@ -370,6 +393,19 @@
[self errorWithFormat: @"rule for an event that never occurs"]; [self errorWithFormat: @"rule for an event that never occurs"];
} }
} }
exDates = [[event exceptionDatesWithTimeZone: utcTZ]
sortedArrayUsingFunction: NSDateCompare
context: NULL];
max = [exDates count];
rp->DeletedInstanceCount = max;
rp->DeletedInstanceDates = talloc_array (memCtx, uint32_t, max);
for (count = 0; count < max; count++)
{
startDate = [[exDates objectAtIndex: count] hour: 0 minute: 0 second: 0];
*(rp->DeletedInstanceDates + count) = [startDate asMinutesSince1601];
}
} }
@end @end