Monotone-Parent: 0ad1e10fb7587b8444bd502de4908d1aabf70c96
Monotone-Revision: a6b977673a1cc94b1269e19c469101dca9fd17bc Monotone-Author: wsourdeau@inverse.ca Monotone-Date: 2012-07-01T20:58:46 Monotone-Branch: ca.inverse.sogomaint-2.0.2
parent
674fb1081c
commit
b3acd2e2ad
|
@ -1,5 +1,13 @@
|
|||
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
|
||||
function for sorting array of NSDate instances.
|
||||
|
||||
|
|
Binary file not shown.
|
@ -28,11 +28,8 @@
|
|||
#import <Foundation/NSTimeZone.h>
|
||||
#import <NGExtensions/NSObject+Logs.h>
|
||||
#import <NGCards/iCalAlarm.h>
|
||||
#import <NGCards/iCalDateTime.h>
|
||||
#import <NGCards/iCalEvent.h>
|
||||
#import <NGCards/iCalPerson.h>
|
||||
#import <NGCards/iCalRecurrenceRule.h>
|
||||
#import <NGCards/iCalTimeZone.h>
|
||||
#import <NGCards/iCalTrigger.h>
|
||||
#import <NGCards/NSString+NGCards.h>
|
||||
#import <SOGo/SOGoUser.h>
|
||||
|
@ -580,7 +577,7 @@ static NSCharacterSet *hexCharacterSet = nil;
|
|||
}
|
||||
|
||||
- (int) getPidTagMessageClass: (void **) data
|
||||
inMemCtx: (TALLOC_CTX *) memCtx
|
||||
inMemCtx: (TALLOC_CTX *) memCtx
|
||||
{
|
||||
const char *className;
|
||||
|
||||
|
@ -633,7 +630,7 @@ static NSCharacterSet *hexCharacterSet = nil;
|
|||
}
|
||||
|
||||
- (int) getPidTagStartDate: (void **) data
|
||||
inMemCtx: (TALLOC_CTX *) memCtx
|
||||
inMemCtx: (TALLOC_CTX *) memCtx
|
||||
{
|
||||
NSCalendarDate *dateValue;
|
||||
NSInteger offset;
|
||||
|
@ -827,7 +824,7 @@ static NSCharacterSet *hexCharacterSet = nil;
|
|||
|
||||
/* sender (organizer) */
|
||||
- (int) getPidTagSenderEmailAddress: (void **) data
|
||||
inMemCtx: (TALLOC_CTX *) memCtx
|
||||
inMemCtx: (TALLOC_CTX *) memCtx
|
||||
{
|
||||
return [self _getEmailAddress: data
|
||||
forICalPerson: [event organizer]
|
||||
|
@ -835,7 +832,7 @@ static NSCharacterSet *hexCharacterSet = nil;
|
|||
}
|
||||
|
||||
- (int) getPidTagSenderAddressType: (void **) data
|
||||
inMemCtx: (TALLOC_CTX *) memCtx
|
||||
inMemCtx: (TALLOC_CTX *) memCtx
|
||||
{
|
||||
return [self _getAddrType: data
|
||||
forICalPerson: [event organizer]
|
||||
|
@ -843,7 +840,7 @@ static NSCharacterSet *hexCharacterSet = nil;
|
|||
}
|
||||
|
||||
- (int) getPidTagSenderName: (void **) data
|
||||
inMemCtx: (TALLOC_CTX *) memCtx
|
||||
inMemCtx: (TALLOC_CTX *) memCtx
|
||||
{
|
||||
return [self _getName: data
|
||||
forICalPerson: [event organizer]
|
||||
|
@ -851,7 +848,7 @@ static NSCharacterSet *hexCharacterSet = nil;
|
|||
}
|
||||
|
||||
- (int) getPidTagSenderEntryId: (void **) data
|
||||
inMemCtx: (TALLOC_CTX *) memCtx
|
||||
inMemCtx: (TALLOC_CTX *) memCtx
|
||||
{
|
||||
return [self _getEntryId: data
|
||||
forICalPerson: [event organizer]
|
||||
|
@ -860,7 +857,7 @@ static NSCharacterSet *hexCharacterSet = nil;
|
|||
|
||||
/* attendee */
|
||||
- (int) getPidTagReceivedByEmailAddress: (void **) data
|
||||
inMemCtx: (TALLOC_CTX *) memCtx
|
||||
inMemCtx: (TALLOC_CTX *) memCtx
|
||||
{
|
||||
return [self _getEmailAddress: data
|
||||
forICalPerson: [event userAsAttendee: user]
|
||||
|
@ -868,7 +865,7 @@ static NSCharacterSet *hexCharacterSet = nil;
|
|||
}
|
||||
|
||||
- (int) getPidTagReceivedByAddressType: (void **) data
|
||||
inMemCtx: (TALLOC_CTX *) memCtx
|
||||
inMemCtx: (TALLOC_CTX *) memCtx
|
||||
{
|
||||
return [self _getAddrType: data
|
||||
forICalPerson: [event userAsAttendee: user]
|
||||
|
@ -876,7 +873,7 @@ static NSCharacterSet *hexCharacterSet = nil;
|
|||
}
|
||||
|
||||
- (int) getPidTagReceivedByName: (void **) data
|
||||
inMemCtx: (TALLOC_CTX *) memCtx
|
||||
inMemCtx: (TALLOC_CTX *) memCtx
|
||||
{
|
||||
return [self _getName: data
|
||||
forICalPerson: [event userAsAttendee: user]
|
||||
|
@ -884,7 +881,7 @@ static NSCharacterSet *hexCharacterSet = nil;
|
|||
}
|
||||
|
||||
- (int) getPidTagReceivedByEntryId: (void **) data
|
||||
inMemCtx: (TALLOC_CTX *) memCtx
|
||||
inMemCtx: (TALLOC_CTX *) memCtx
|
||||
{
|
||||
return [self _getEntryId: data
|
||||
forICalPerson: [event userAsAttendee: user]
|
||||
|
@ -893,7 +890,7 @@ static NSCharacterSet *hexCharacterSet = nil;
|
|||
/* /attendee */
|
||||
|
||||
- (int) getPidTagEndDate: (void **) data
|
||||
inMemCtx: (TALLOC_CTX *) memCtx
|
||||
inMemCtx: (TALLOC_CTX *) memCtx
|
||||
{
|
||||
NSCalendarDate *dateValue;
|
||||
NSInteger offset;
|
||||
|
@ -995,7 +992,8 @@ static NSCharacterSet *hexCharacterSet = nil;
|
|||
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
|
||||
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];
|
||||
}
|
||||
|
||||
- (int) getPidLidServerProcessingActions: (void **) data inMemCtx: (TALLOC_CTX *) memCtx
|
||||
- (int) getPidLidServerProcessingActions: (void **) data
|
||||
inMemCtx: (TALLOC_CTX *) memCtx
|
||||
{
|
||||
*data = MAPILongValue (memCtx,
|
||||
0x00000010 /* cpsCreatedOnPrincipal */
|
||||
|
@ -1020,14 +1019,14 @@ static NSCharacterSet *hexCharacterSet = nil;
|
|||
}
|
||||
|
||||
- (int) getPidTagSensitivity: (void **) data // not implemented, depends on CLASS
|
||||
inMemCtx: (TALLOC_CTX *) memCtx
|
||||
inMemCtx: (TALLOC_CTX *) memCtx
|
||||
{
|
||||
// normal = 0, personal?? = 1, private = 2, confidential = 3
|
||||
return [self getLongZero: data inMemCtx: memCtx];
|
||||
}
|
||||
|
||||
- (int) getPidTagImportance: (void **) data
|
||||
inMemCtx: (TALLOC_CTX *) memCtx
|
||||
inMemCtx: (TALLOC_CTX *) memCtx
|
||||
{
|
||||
uint32_t v;
|
||||
if ([[event priority] isEqualToString: @"9"])
|
||||
|
@ -1043,7 +1042,7 @@ static NSCharacterSet *hexCharacterSet = nil;
|
|||
}
|
||||
|
||||
- (int) getPidTagBody: (void **) data
|
||||
inMemCtx: (TALLOC_CTX *) memCtx
|
||||
inMemCtx: (TALLOC_CTX *) memCtx
|
||||
{
|
||||
int rc = MAPISTORE_SUCCESS;
|
||||
NSString *stringValue;
|
||||
|
@ -1074,29 +1073,6 @@ static NSCharacterSet *hexCharacterSet = nil;
|
|||
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
|
||||
|
||||
{
|
||||
|
@ -1105,6 +1081,7 @@ _fillAppointmentRecurrencePattern (struct AppointmentRecurrencePattern *arp,
|
|||
struct SBinary_short *sBin;
|
||||
NSCalendarDate *firstStartDate;
|
||||
iCalRecurrenceRule *rule;
|
||||
NSUInteger startMinutes;
|
||||
|
||||
rule = [[event recurrenceRules] objectAtIndex: 0];
|
||||
|
||||
|
@ -1114,10 +1091,27 @@ _fillAppointmentRecurrencePattern (struct AppointmentRecurrencePattern *arp,
|
|||
[firstStartDate setTimeZone: timeZone];
|
||||
|
||||
arp = talloc_zero (memCtx, struct AppointmentRecurrencePattern);
|
||||
_fillAppointmentRecurrencePattern (arp, firstStartDate,
|
||||
[event durationAsTimeInterval],
|
||||
[event lastPossibleRecurrenceStartDate],
|
||||
rule);
|
||||
[rule fillRecurrencePattern: &arp->RecurrencePattern
|
||||
withEvent: event
|
||||
inTimeZone: timeZone
|
||||
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);
|
||||
bin = set_AppointmentRecurrencePattern (sBin, arp);
|
||||
sBin->cb = bin->cb;
|
||||
|
|
|
@ -23,10 +23,14 @@
|
|||
#ifndef MAPISTORERECURRENCEUTILS_H
|
||||
#define MAPISTORERECURRENCEUTILS_H
|
||||
|
||||
#include <talloc.h>
|
||||
|
||||
#import <NGCards/iCalCalendar.h>
|
||||
#import <NGCards/iCalRecurrenceRule.h>
|
||||
|
||||
@class NSCalendarDate;
|
||||
@class NSTimeZone;
|
||||
|
||||
@class iCalEvent;
|
||||
@class iCalRepeatableEntityObject;
|
||||
@class iCalRecurrenceRule;
|
||||
|
||||
|
@ -44,8 +48,9 @@
|
|||
@interface iCalRecurrenceRule (MAPIStoreRecurrence)
|
||||
|
||||
- (void) fillRecurrencePattern: (struct RecurrencePattern *) rp
|
||||
withStartDate: (NSCalendarDate *) startDate
|
||||
andEndDate: (NSCalendarDate *) endDate;
|
||||
withEvent: (iCalEvent *) event
|
||||
inTimeZone: (NSTimeZone *) timeZone
|
||||
inMemCtx: (TALLOC_CTX *) memCtx;
|
||||
|
||||
@end
|
||||
|
||||
|
|
|
@ -21,17 +21,22 @@
|
|||
*/
|
||||
|
||||
#import <Foundation/NSArray.h>
|
||||
#import <Foundation/NSCalendarDate.h>
|
||||
#import <Foundation/NSString.h>
|
||||
|
||||
#import <NGExtensions/NSCalendarDate+misc.h>
|
||||
#import <NGExtensions/NSObject+Logs.h>
|
||||
|
||||
#import <NGCards/iCalByDayMask.h>
|
||||
#import <NGCards/iCalDateTime.h>
|
||||
#import <NGCards/iCalEvent.h>
|
||||
#import <NGCards/iCalRepeatableEntityObject.h>
|
||||
#import <NGCards/iCalRecurrenceRule.h>
|
||||
#import <NGCards/iCalByDayMask.h>
|
||||
#import <NGCards/iCalTimeZone.h>
|
||||
|
||||
#import "NSDate+MAPIStore.h"
|
||||
#import "MAPIStoreRecurrenceUtils.h"
|
||||
#import "MAPIStoreTypes.h"
|
||||
|
||||
#include <stdbool.h>
|
||||
#include <talloc.h>
|
||||
|
@ -43,7 +48,7 @@
|
|||
- (void) setupRecurrenceWithMasterEntity: (iCalRepeatableEntityObject *) entity
|
||||
fromRecurrencePattern: (struct RecurrencePattern *) rp
|
||||
{
|
||||
NSCalendarDate *startDate, *olEndDate, *untilDate;
|
||||
NSCalendarDate *startDate, *olEndDate, *untilDate, *exDate;
|
||||
NSString *monthDay, *month;
|
||||
iCalRecurrenceRule *rule;
|
||||
iCalByDayMask *byDayMask;
|
||||
|
@ -203,6 +208,17 @@
|
|||
[self errorWithFormat: @"invalid value for EndType: %.4x",
|
||||
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
|
||||
|
@ -210,17 +226,24 @@
|
|||
@implementation iCalRecurrenceRule (MAPIStoreRecurrence)
|
||||
|
||||
- (void) fillRecurrencePattern: (struct RecurrencePattern *) rp
|
||||
withStartDate: (NSCalendarDate *) startDate
|
||||
andEndDate: (NSCalendarDate *) endDate
|
||||
withEvent: (iCalEvent *) event
|
||||
inTimeZone: (NSTimeZone *) timeZone
|
||||
inMemCtx: (TALLOC_CTX *) memCtx
|
||||
{
|
||||
iCalRecurrenceFrequency freq;
|
||||
iCalByDayMask *byDayMask;
|
||||
NSString *byMonthDay, *bySetPos;
|
||||
NSCalendarDate *untilDate, *beginOfWeek, *minimumDate, *moduloDate, *midnight;
|
||||
NSCalendarDate *startDate, *endDate, *untilDate, *beginOfWeek, *minimumDate, *moduloDate, *midnight;
|
||||
iCalWeekOccurrences *days;
|
||||
NSInteger dayOfWeek, repeatInterval, repeatCount, count, firstOccurrence;
|
||||
NSInteger dayOfWeek, repeatInterval, repeatCount, count, firstOccurrence, max;
|
||||
uint32_t nbrMonths, mask;
|
||||
NSArray *exDates;
|
||||
|
||||
startDate = [event firstRecurrenceStartDate];
|
||||
[startDate setTimeZone: timeZone];
|
||||
endDate = [event lastPossibleRecurrenceStartDate];
|
||||
[endDate setTimeZone: timeZone];
|
||||
|
||||
rp->ReaderVersion = 0x3004;
|
||||
rp->WriterVersion = 0x3004;
|
||||
|
||||
|
@ -370,6 +393,19 @@
|
|||
[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
|
||||
|
|
Loading…
Reference in New Issue