2011-07-21 17:05:17 +02:00
|
|
|
/* MAPIStoreAppointmentWrapper.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
|
2011-08-12 17:02:01 +02:00
|
|
|
* the Free Software Foundation; either version 3, or (at your option)
|
2011-07-21 17:05:17 +02:00
|
|
|
* 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/NSArray.h>
|
|
|
|
#import <Foundation/NSCalendarDate.h>
|
2011-08-06 01:38:18 +02:00
|
|
|
#import <Foundation/NSCharacterSet.h>
|
2011-07-21 17:05:17 +02:00
|
|
|
#import <Foundation/NSData.h>
|
2011-09-30 22:01:50 +02:00
|
|
|
#import <Foundation/NSDictionary.h>
|
2011-07-21 17:05:17 +02:00
|
|
|
#import <Foundation/NSTimeZone.h>
|
|
|
|
#import <NGExtensions/NSObject+Logs.h>
|
2011-10-11 21:46:02 +02:00
|
|
|
#import <NGCards/iCalAlarm.h>
|
2011-07-21 17:05:17 +02:00
|
|
|
#import <NGCards/iCalDateTime.h>
|
|
|
|
#import <NGCards/iCalEvent.h>
|
2011-10-11 21:46:02 +02:00
|
|
|
#import <NGCards/iCalPerson.h>
|
2011-07-21 17:05:17 +02:00
|
|
|
#import <NGCards/iCalRecurrenceRule.h>
|
|
|
|
#import <NGCards/iCalTimeZone.h>
|
2011-10-11 21:46:02 +02:00
|
|
|
#import <NGCards/iCalTrigger.h>
|
|
|
|
#import <NGCards/NSString+NGCards.h>
|
2012-06-01 17:15:30 +02:00
|
|
|
#import <SOGo/SOGoUser.h>
|
2011-09-30 22:01:50 +02:00
|
|
|
#import <SOGo/SOGoUserManager.h>
|
2011-07-21 17:05:17 +02:00
|
|
|
|
|
|
|
#import "MAPIStoreRecurrenceUtils.h"
|
2011-11-17 19:39:42 +01:00
|
|
|
#import "MAPIStoreSamDBUtils.h"
|
2011-07-21 17:05:17 +02:00
|
|
|
#import "MAPIStoreTypes.h"
|
|
|
|
#import "NSData+MAPIStore.h"
|
|
|
|
#import "NSDate+MAPIStore.h"
|
|
|
|
#import "NSObject+MAPIStore.h"
|
|
|
|
#import "NSString+MAPIStore.h"
|
|
|
|
|
|
|
|
#import "MAPIStoreAppointmentWrapper.h"
|
|
|
|
|
|
|
|
#undef DEBUG
|
2011-08-06 01:38:18 +02:00
|
|
|
#include <talloc.h>
|
2011-07-21 17:05:17 +02:00
|
|
|
#include <stdbool.h>
|
|
|
|
#include <gen_ndr/exchange.h>
|
|
|
|
#include <gen_ndr/property.h>
|
2011-08-06 01:38:18 +02:00
|
|
|
#include <gen_ndr/ndr_property.h>
|
2011-11-09 16:02:29 +01:00
|
|
|
#include <util/attr.h>
|
2011-07-21 17:05:17 +02:00
|
|
|
#include <libmapi/libmapi.h>
|
|
|
|
#include <mapistore/mapistore.h>
|
|
|
|
#include <mapistore/mapistore_errors.h>
|
|
|
|
#include <mapistore/mapistore_nameid.h>
|
|
|
|
|
2011-08-06 01:38:18 +02:00
|
|
|
static NSCharacterSet *hexCharacterSet = nil;
|
|
|
|
|
2011-07-21 17:05:17 +02:00
|
|
|
@implementation MAPIStoreAppointmentWrapper
|
|
|
|
|
|
|
|
+ (void) initialize
|
|
|
|
{
|
2011-08-06 01:38:18 +02:00
|
|
|
if (!hexCharacterSet)
|
|
|
|
{
|
|
|
|
hexCharacterSet = [NSCharacterSet characterSetWithCharactersInString: @"1234567890abcdefABCDEF"];
|
|
|
|
[hexCharacterSet retain];
|
|
|
|
}
|
2011-07-21 17:05:17 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
+ (id) wrapperWithICalEvent: (iCalEvent *) newEvent
|
2011-10-03 22:55:02 +02:00
|
|
|
andUser: (SOGoUser *) newUser
|
2011-10-12 22:00:46 +02:00
|
|
|
andSenderEmail: (NSString *) newSenderEmail
|
2011-07-21 17:05:17 +02:00
|
|
|
inTimeZone: (NSTimeZone *) newTimeZone
|
2011-11-17 17:15:38 +01:00
|
|
|
withConnectionInfo: (struct mapistore_connection_info *) newConnInfo
|
2011-07-21 17:05:17 +02:00
|
|
|
{
|
|
|
|
MAPIStoreAppointmentWrapper *wrapper;
|
|
|
|
|
|
|
|
wrapper = [[self alloc] initWithICalEvent: newEvent
|
2011-10-03 22:55:02 +02:00
|
|
|
andUser: newUser
|
2011-10-12 22:00:46 +02:00
|
|
|
andSenderEmail: newSenderEmail
|
2011-11-17 17:15:38 +01:00
|
|
|
inTimeZone: newTimeZone
|
|
|
|
withConnectionInfo: newConnInfo];
|
2011-07-21 17:05:17 +02:00
|
|
|
[wrapper autorelease];
|
|
|
|
|
|
|
|
return wrapper;
|
|
|
|
}
|
|
|
|
|
2011-08-06 01:38:18 +02:00
|
|
|
- (id) init
|
|
|
|
{
|
|
|
|
if ((self = [super init]))
|
|
|
|
{
|
2011-11-17 17:15:38 +01:00
|
|
|
connInfo = NULL;
|
2011-08-06 01:38:18 +02:00
|
|
|
calendar = nil;
|
|
|
|
event = nil;
|
|
|
|
timeZone = nil;
|
2011-10-12 22:00:46 +02:00
|
|
|
senderEmail = nil;
|
2011-08-06 01:38:18 +02:00
|
|
|
globalObjectId = nil;
|
|
|
|
cleanGlobalObjectId = nil;
|
2011-10-03 22:55:02 +02:00
|
|
|
user = nil;
|
2011-10-11 21:46:02 +02:00
|
|
|
alarmSet = NO;
|
2011-10-12 01:38:37 +02:00
|
|
|
itipSetup = NO;
|
2011-10-11 21:46:02 +02:00
|
|
|
alarm = nil;
|
2011-10-12 01:38:37 +02:00
|
|
|
method = nil;
|
2011-08-06 01:38:18 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
return self;
|
|
|
|
}
|
|
|
|
|
2011-10-12 01:38:37 +02:00
|
|
|
- (void) _setupITIPContextFromAttendees
|
|
|
|
{
|
2011-10-12 22:00:46 +02:00
|
|
|
iCalPerson *attendee = nil;
|
|
|
|
NSArray *attendees;
|
2011-10-12 01:38:37 +02:00
|
|
|
|
|
|
|
attendee = [event userAsAttendee: user];
|
|
|
|
if (attendee)
|
2011-10-12 22:00:46 +02:00
|
|
|
method = @"REQUEST";
|
|
|
|
else if ([event userIsOrganizer: user])
|
2011-10-12 01:38:37 +02:00
|
|
|
{
|
2011-10-12 22:00:46 +02:00
|
|
|
if (senderEmail)
|
|
|
|
attendee = [event findAttendeeWithEmail: senderEmail];
|
|
|
|
if (!attendee)
|
|
|
|
{
|
|
|
|
attendees = [event attendees];
|
|
|
|
if ([attendees count] == 1)
|
|
|
|
attendee = [attendees objectAtIndex: 0];
|
|
|
|
}
|
|
|
|
if (attendee)
|
|
|
|
{
|
|
|
|
method = @"REPLY";
|
|
|
|
partstat = [attendee participationStatus];
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
[self logWithFormat: @"no attendee matching sender found"];
|
|
|
|
method = nil;
|
|
|
|
}
|
2011-10-12 01:38:37 +02:00
|
|
|
}
|
|
|
|
else
|
|
|
|
method = nil;
|
|
|
|
|
|
|
|
[method retain];
|
|
|
|
}
|
|
|
|
|
|
|
|
- (void) _setupITIPContext
|
|
|
|
{
|
|
|
|
NSArray *attendees;
|
|
|
|
NSUInteger max;
|
|
|
|
|
|
|
|
/* Here we attempt to determine the type of message from the ITIP method
|
|
|
|
contained in the event. It it fails, we attempt to determine this by
|
|
|
|
checking the identity of the organizer and of the attendees. */
|
|
|
|
itipSetup = YES;
|
|
|
|
method = [[event parent] method];
|
|
|
|
if ([method length] > 0)
|
|
|
|
{
|
2012-03-20 21:31:36 +01:00
|
|
|
method = [method uppercaseString];
|
2011-10-12 01:38:37 +02:00
|
|
|
[method retain];
|
|
|
|
if ([method isEqualToString: @"REPLY"])
|
|
|
|
{
|
|
|
|
attendees = [event attendees];
|
|
|
|
max = [attendees count];
|
|
|
|
if (max == 1)
|
|
|
|
partstat = [[attendees objectAtIndex: 0] participationStatus];
|
|
|
|
else if (max > 1)
|
|
|
|
[self _setupITIPContextFromAttendees];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
[self _setupITIPContextFromAttendees];
|
|
|
|
}
|
|
|
|
|
2011-07-21 17:05:17 +02:00
|
|
|
- (id) initWithICalEvent: (iCalEvent *) newEvent
|
2011-10-03 22:55:02 +02:00
|
|
|
andUser: (SOGoUser *) newUser
|
2011-10-12 22:00:46 +02:00
|
|
|
andSenderEmail: (NSString *) newSenderEmail
|
2011-07-21 17:05:17 +02:00
|
|
|
inTimeZone: (NSTimeZone *) newTimeZone
|
2011-11-17 17:15:38 +01:00
|
|
|
withConnectionInfo: (struct mapistore_connection_info *) newConnInfo
|
2011-07-21 17:05:17 +02:00
|
|
|
{
|
|
|
|
if ((self = [self init]))
|
|
|
|
{
|
2011-11-17 17:15:38 +01:00
|
|
|
connInfo = newConnInfo;
|
2011-07-21 17:05:17 +02:00
|
|
|
ASSIGN (event, newEvent);
|
|
|
|
ASSIGN (calendar, [event parent]);
|
|
|
|
ASSIGN (timeZone, newTimeZone);
|
2011-10-03 22:55:02 +02:00
|
|
|
ASSIGN (user, newUser);
|
2011-10-12 22:00:46 +02:00
|
|
|
ASSIGN (senderEmail, newSenderEmail);
|
2011-10-12 01:38:37 +02:00
|
|
|
[self _setupITIPContext];
|
2011-07-21 17:05:17 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
return self;
|
|
|
|
}
|
|
|
|
|
|
|
|
- (void) dealloc
|
|
|
|
{
|
|
|
|
[calendar release];
|
|
|
|
[event release];
|
2011-08-06 01:38:18 +02:00
|
|
|
[timeZone release];
|
2011-10-12 22:00:46 +02:00
|
|
|
[user release];
|
|
|
|
[senderEmail release];
|
2011-08-06 01:38:18 +02:00
|
|
|
[globalObjectId release];
|
|
|
|
[cleanGlobalObjectId release];
|
2011-10-11 21:46:02 +02:00
|
|
|
[alarm release];
|
2011-10-12 01:38:37 +02:00
|
|
|
[method release];
|
2011-07-21 17:05:17 +02:00
|
|
|
[super dealloc];
|
|
|
|
}
|
|
|
|
|
2011-09-30 22:01:50 +02:00
|
|
|
- (void) fillMessageData: (struct mapistore_message *) msgData
|
|
|
|
inMemCtx: (TALLOC_CTX *) memCtx
|
|
|
|
{
|
|
|
|
NSString *username, *cn, *email;
|
|
|
|
NSData *entryId;
|
|
|
|
NSArray *attendees;
|
|
|
|
iCalPerson *person;
|
|
|
|
iCalPersonPartStat partStat;
|
|
|
|
uint32_t partStatValue;
|
|
|
|
SOGoUserManager *mgr;
|
|
|
|
NSDictionary *contactInfos;
|
|
|
|
struct mapistore_message_recipient *recipient;
|
|
|
|
int count, max, p;
|
|
|
|
|
|
|
|
msgData->columns = set_SPropTagArray (msgData, 9,
|
|
|
|
PR_OBJECT_TYPE,
|
|
|
|
PR_DISPLAY_TYPE,
|
|
|
|
PR_7BIT_DISPLAY_NAME_UNICODE,
|
|
|
|
PR_SMTP_ADDRESS_UNICODE,
|
|
|
|
PR_SEND_INTERNET_ENCODING,
|
|
|
|
PR_RECIPIENT_DISPLAY_NAME_UNICODE,
|
|
|
|
PR_RECIPIENT_FLAGS,
|
|
|
|
PR_RECIPIENT_ENTRYID,
|
|
|
|
PR_RECIPIENT_TRACKSTATUS);
|
|
|
|
// ,
|
|
|
|
// PR_RECORD_KEY);
|
|
|
|
|
|
|
|
attendees = [event attendees];
|
|
|
|
max = [attendees count];
|
|
|
|
|
|
|
|
if (max > 0)
|
|
|
|
{
|
|
|
|
mgr = [SOGoUserManager sharedUserManager];
|
|
|
|
msgData->recipients_count = max + 1;
|
2011-10-28 15:10:47 +02:00
|
|
|
msgData->recipients = talloc_array (msgData, struct mapistore_message_recipient, max + 1);
|
2011-09-30 22:01:50 +02:00
|
|
|
for (count = 0; count < max; count++)
|
|
|
|
{
|
2011-10-28 15:10:47 +02:00
|
|
|
recipient = msgData->recipients + count;
|
2011-09-30 22:01:50 +02:00
|
|
|
|
|
|
|
person = [attendees objectAtIndex: count];
|
|
|
|
cn = [person cn];
|
|
|
|
email = [person rfc822Email];
|
|
|
|
if ([cn length] == 0)
|
|
|
|
cn = email;
|
|
|
|
contactInfos = [mgr contactInfosForUserWithUIDorEmail: email];
|
|
|
|
|
|
|
|
if (contactInfos)
|
|
|
|
{
|
|
|
|
username = [contactInfos objectForKey: @"c_uid"];
|
|
|
|
recipient->username = [username asUnicodeInMemCtx: msgData];
|
2011-11-17 17:15:38 +01:00
|
|
|
entryId = MAPIStoreInternalEntryId (connInfo->sam_ctx, username);
|
2011-09-30 22:01:50 +02:00
|
|
|
}
|
|
|
|
else
|
2011-10-28 15:10:47 +02:00
|
|
|
{
|
|
|
|
recipient->username = NULL;
|
|
|
|
entryId = MAPIStoreExternalEntryId (cn, email);
|
|
|
|
}
|
2011-09-30 22:01:50 +02:00
|
|
|
recipient->type = MAPI_TO;
|
|
|
|
|
|
|
|
/* properties */
|
|
|
|
p = 0;
|
|
|
|
recipient->data = talloc_array (msgData, void *, msgData->columns->cValues);
|
|
|
|
memset (recipient->data, 0, msgData->columns->cValues * sizeof (void *));
|
|
|
|
|
|
|
|
// PR_OBJECT_TYPE = MAPI_MAILUSER (see MAPI_OBJTYPE)
|
|
|
|
recipient->data[p] = MAPILongValue (msgData, MAPI_MAILUSER);
|
|
|
|
p++;
|
|
|
|
|
|
|
|
// PR_DISPLAY_TYPE = DT_MAILUSER (see MS-NSPI)
|
|
|
|
recipient->data[p] = MAPILongValue (msgData, 0);
|
|
|
|
p++;
|
|
|
|
|
|
|
|
// PR_7BIT_DISPLAY_NAME_UNICODE
|
|
|
|
recipient->data[p] = [cn asUnicodeInMemCtx: msgData];
|
|
|
|
p++;
|
|
|
|
|
|
|
|
// PR_SMTP_ADDRESS_UNICODE
|
|
|
|
recipient->data[p] = [email asUnicodeInMemCtx: msgData];
|
|
|
|
p++;
|
|
|
|
|
|
|
|
// PR_SEND_INTERNET_ENCODING = 0x00060000 (plain text, see OXCMAIL)
|
|
|
|
recipient->data[p] = MAPILongValue (msgData, 0x00060000);
|
|
|
|
p++;
|
|
|
|
|
|
|
|
// PR_RECIPIENT_DISPLAY_NAME_UNICODE
|
|
|
|
recipient->data[p] = [cn asUnicodeInMemCtx: msgData];
|
|
|
|
p++;
|
|
|
|
|
|
|
|
// PR_RECIPIENT_FLAGS
|
|
|
|
recipient->data[p] = MAPILongValue (msgData, 1);
|
|
|
|
p++;
|
|
|
|
|
|
|
|
// PR_RECIPIENT_ENTRYID
|
|
|
|
recipient->data[p] = [entryId asBinaryInMemCtx: msgData];
|
|
|
|
p++;
|
|
|
|
|
|
|
|
// PR_RECIPIENT_TRACKSTATUS
|
|
|
|
/*
|
|
|
|
respNone 0x00000000
|
|
|
|
No response is required for this object. This is the case for Appointment objects and Meeting Response objects.
|
|
|
|
respOrganized 0x00000001
|
|
|
|
This Meeting object belongs to the organizer.
|
|
|
|
respTentative 0x00000002
|
|
|
|
This value on the attendee's Meeting object indicates that the
|
|
|
|
attendee has tentatively accepted the Meeting Request object.
|
|
|
|
respAccepted 0x00000003
|
|
|
|
This value on the attendee's Meeting object indicates that the
|
|
|
|
attendee has accepted the Meeting Request object.
|
|
|
|
respDeclined 0x00000004
|
|
|
|
This value on the attendee's Meeting object indicates that the attendee has declined the Meeting Request
|
|
|
|
object.
|
|
|
|
respNotResponded 0x00000005
|
|
|
|
This value on the attendee's Meeting object indicates that the attendee has
|
|
|
|
not yet responded. This value is on the Meet
|
|
|
|
*/
|
|
|
|
partStat = [person participationStatus];
|
|
|
|
switch (partStat)
|
|
|
|
{
|
|
|
|
case iCalPersonPartStatAccepted:
|
|
|
|
partStatValue = 3;
|
|
|
|
break;
|
|
|
|
case iCalPersonPartStatDeclined:
|
|
|
|
partStatValue = 4;
|
|
|
|
break;
|
|
|
|
case iCalPersonPartStatTentative:
|
|
|
|
partStatValue = 2;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
partStatValue = 5;
|
|
|
|
}
|
|
|
|
recipient->data[p] = MAPILongValue (msgData, partStatValue);
|
|
|
|
p++;
|
|
|
|
|
|
|
|
// // PR_RECORD_KEY
|
|
|
|
// recipient->data[p] = [entryId asBinaryInMemCtx: msgData];
|
|
|
|
// p++;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* On with the organizer: */
|
|
|
|
{
|
2011-10-28 15:10:47 +02:00
|
|
|
recipient = msgData->recipients + max;
|
2011-09-30 22:01:50 +02:00
|
|
|
|
|
|
|
person = [event organizer];
|
|
|
|
cn = [person cn];
|
|
|
|
email = [person rfc822Email];
|
|
|
|
contactInfos = [mgr contactInfosForUserWithUIDorEmail: email];
|
|
|
|
|
|
|
|
if (contactInfos)
|
|
|
|
{
|
|
|
|
username = [contactInfos objectForKey: @"c_uid"];
|
|
|
|
recipient->username = [username asUnicodeInMemCtx: msgData];
|
2011-11-17 17:15:38 +01:00
|
|
|
entryId = MAPIStoreInternalEntryId (connInfo->sam_ctx, username);
|
2011-09-30 22:01:50 +02:00
|
|
|
}
|
|
|
|
else
|
2011-10-28 15:10:47 +02:00
|
|
|
{
|
|
|
|
recipient->username = NULL;
|
|
|
|
entryId = MAPIStoreExternalEntryId (cn, email);
|
|
|
|
}
|
2011-09-30 22:01:50 +02:00
|
|
|
recipient->type = MAPI_TO;
|
|
|
|
|
|
|
|
p = 0;
|
|
|
|
recipient->data = talloc_array (msgData, void *, msgData->columns->cValues);
|
|
|
|
memset (recipient->data, 0, msgData->columns->cValues * sizeof (void *));
|
|
|
|
|
|
|
|
// PR_OBJECT_TYPE = MAPI_MAILUSER (see MAPI_OBJTYPE)
|
|
|
|
recipient->data[p] = MAPILongValue (msgData, MAPI_MAILUSER);
|
|
|
|
p++;
|
|
|
|
|
|
|
|
// PR_DISPLAY_TYPE = DT_MAILUSER (see MS-NSPI)
|
|
|
|
recipient->data[p] = MAPILongValue (msgData, 0);
|
|
|
|
p++;
|
|
|
|
|
|
|
|
// PR_7BIT_DISPLAY_NAME_UNICODE
|
|
|
|
recipient->data[p] = [cn asUnicodeInMemCtx: msgData];
|
|
|
|
p++;
|
|
|
|
|
|
|
|
// PR_SMTP_ADDRESS_UNICODE
|
|
|
|
recipient->data[p] = [email asUnicodeInMemCtx: msgData];
|
|
|
|
p++;
|
|
|
|
|
|
|
|
// PR_SEND_INTERNET_ENCODING = 0x00060000 (plain text, see OXCMAIL)
|
|
|
|
recipient->data[p] = MAPILongValue (msgData, 0x00060000);
|
|
|
|
p++;
|
|
|
|
|
|
|
|
// PR_RECIPIENT_DISPLAY_NAME_UNICODE
|
|
|
|
recipient->data[p] = [cn asUnicodeInMemCtx: msgData];
|
|
|
|
p++;
|
|
|
|
|
|
|
|
// PR_RECIPIENT_FLAGS
|
|
|
|
recipient->data[p] = MAPILongValue (msgData, 3);
|
|
|
|
p++;
|
|
|
|
|
|
|
|
// PR_RECIPIENT_ENTRYID = NULL
|
|
|
|
recipient->data[p] = [entryId asBinaryInMemCtx: msgData];
|
|
|
|
p++;
|
|
|
|
|
|
|
|
// PR_RECIPIENT_TRACKSTATUS
|
|
|
|
/*
|
|
|
|
respNone 0x00000000
|
|
|
|
No response is required for this object. This is the case for Appointment objects and Meeting Response objects.
|
|
|
|
respOrganized 0x00000001
|
|
|
|
This Meeting object belongs to the organizer.
|
|
|
|
respTentative 0x00000002
|
|
|
|
This value on the attendee's Meeting object indicates that the
|
|
|
|
attendee has tentatively accepted the Meeting Request object.
|
|
|
|
respAccepted 0x00000003
|
|
|
|
This value on the attendee's Meeting object indicates that the
|
|
|
|
attendee has accepted the Meeting Request object.
|
|
|
|
respDeclined 0x00000004
|
|
|
|
This value on the attendee's Meeting object indicates that the attendee has declined the Meeting Request
|
|
|
|
object.
|
|
|
|
respNotResponded 0x00000005
|
|
|
|
This value on the attendee's Meeting object indicates that the attendee has
|
|
|
|
not yet responded. This value is on the Meet
|
|
|
|
*/
|
|
|
|
recipient->data[p] = MAPILongValue (msgData, 1);
|
|
|
|
p++;
|
|
|
|
|
|
|
|
// // PR_RECORD_KEY
|
|
|
|
// recipient->data[p] = [entryId asBinaryInMemCtx: msgData];
|
|
|
|
// p++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-03-02 21:44:24 +01:00
|
|
|
- (int) getPidTagIconIndex: (void **) data // TODO
|
2011-07-21 17:05:17 +02:00
|
|
|
inMemCtx: (TALLOC_CTX *) memCtx
|
|
|
|
{
|
|
|
|
uint32_t longValue;
|
2011-10-11 23:16:57 +02:00
|
|
|
|
|
|
|
/* see http://msdn.microsoft.com/en-us/library/cc815472.aspx:
|
|
|
|
Single instance appointment: 0x00000400
|
|
|
|
Recurring appointment: 0x00000401
|
|
|
|
Single instance meeting: 0x00000402
|
|
|
|
Recurring meeting: 0x00000403
|
|
|
|
Meeting request: 0x00000404
|
|
|
|
Accept: 0x00000405
|
|
|
|
Decline: 0x00000406
|
|
|
|
Tentativly: 0x00000407
|
|
|
|
Cancellation: 0x00000408
|
|
|
|
Informational update: 0x00000409 */
|
|
|
|
|
|
|
|
// if ([headerMethod isEqualToString: @"REQUEST"])
|
|
|
|
// longValue = 0x0404;
|
|
|
|
// else
|
|
|
|
// longValue = 0x0400;
|
2011-07-21 17:05:17 +02:00
|
|
|
|
2011-10-12 01:38:37 +02:00
|
|
|
if (!itipSetup)
|
|
|
|
[self _setupITIPContext];
|
|
|
|
|
2011-07-21 17:05:17 +02:00
|
|
|
longValue = 0x0400;
|
2011-10-11 23:16:57 +02:00
|
|
|
|
|
|
|
if (method)
|
|
|
|
{
|
|
|
|
if ([method isEqualToString: @"REQUEST"])
|
|
|
|
longValue |= 0x0004;
|
|
|
|
else if ([method isEqualToString: @"REPLY"])
|
|
|
|
{
|
2011-10-12 01:38:37 +02:00
|
|
|
longValue |= 0x0004;
|
|
|
|
switch (partstat)
|
2011-10-11 23:16:57 +02:00
|
|
|
{
|
2011-10-12 01:38:37 +02:00
|
|
|
case iCalPersonPartStatAccepted:
|
|
|
|
longValue |= 0x0001;
|
|
|
|
break;
|
|
|
|
case iCalPersonPartStatDeclined:
|
|
|
|
longValue |= 0x0002;
|
|
|
|
break;
|
|
|
|
case iCalPersonPartStatTentative:
|
|
|
|
longValue |= 0x0003;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
longValue = 0x0400;
|
|
|
|
[self logWithFormat: @"unhandled part stat"];
|
2011-10-11 23:16:57 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else if ([method isEqualToString: @"CANCEL"])
|
|
|
|
longValue |= 0x0008;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if ([event isRecurrent])
|
|
|
|
longValue |= 0x0001;
|
|
|
|
if ([[event attendees] count] > 0)
|
|
|
|
longValue |= 0x0002;
|
|
|
|
}
|
2011-07-21 17:05:17 +02:00
|
|
|
|
|
|
|
*data = MAPILongValue (memCtx, longValue);
|
|
|
|
|
|
|
|
return MAPISTORE_SUCCESS;
|
|
|
|
}
|
|
|
|
|
2012-03-02 21:44:24 +01:00
|
|
|
- (int) getPidTagOwnerAppointmentId: (void **) data
|
|
|
|
inMemCtx: (TALLOC_CTX *) memCtx
|
2011-08-08 21:01:24 +02:00
|
|
|
{
|
|
|
|
int rc;
|
|
|
|
const char *utf8UID;
|
|
|
|
union {
|
|
|
|
uint32_t longValue;
|
|
|
|
char charValue[4];
|
|
|
|
} value;
|
|
|
|
NSUInteger max, length;
|
|
|
|
|
|
|
|
if ([[event attendees] count] > 0)
|
|
|
|
{
|
|
|
|
utf8UID = [[event uid] UTF8String];
|
|
|
|
length = strlen (utf8UID);
|
|
|
|
max = 2;
|
|
|
|
if (length < max)
|
|
|
|
max = length;
|
|
|
|
memcpy (value.charValue, utf8UID, max);
|
|
|
|
memcpy (value.charValue + 2, utf8UID + length - 2, max);
|
|
|
|
|
|
|
|
*data = MAPILongValue (memCtx, value.longValue);
|
|
|
|
|
|
|
|
rc = MAPISTORE_SUCCESS;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
rc = MAPISTORE_ERR_NOT_FOUND;
|
|
|
|
|
|
|
|
return rc;
|
|
|
|
}
|
|
|
|
|
|
|
|
- (int) getPidLidMeetingType: (void **) data
|
|
|
|
inMemCtx: (TALLOC_CTX *) memCtx
|
|
|
|
{
|
|
|
|
/* TODO
|
|
|
|
See 2.2.6.5 PidLidMeetingType (OXOCAL) */
|
|
|
|
*data = MAPILongValue (memCtx, 0x00000001);
|
|
|
|
|
|
|
|
return MAPISTORE_SUCCESS;
|
|
|
|
}
|
|
|
|
|
|
|
|
- (int) getPidLidOwnerCriticalChange: (void **) data
|
|
|
|
inMemCtx: (TALLOC_CTX *) memCtx
|
|
|
|
{
|
|
|
|
int rc = MAPISTORE_ERR_NOT_FOUND;
|
|
|
|
NSCalendarDate *lastModified;
|
|
|
|
|
|
|
|
if ([[event attendees] count] > 0)
|
|
|
|
{
|
|
|
|
lastModified = [event lastModified];
|
|
|
|
if (lastModified)
|
|
|
|
{
|
|
|
|
*data = [lastModified asFileTimeInMemCtx: memCtx];
|
|
|
|
rc = MAPISTORE_SUCCESS;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return rc;
|
|
|
|
}
|
|
|
|
|
|
|
|
- (int) getPidLidAttendeeCriticalChange: (void **) data
|
|
|
|
inMemCtx: (TALLOC_CTX *) memCtx
|
|
|
|
{
|
|
|
|
int rc = MAPISTORE_ERR_NOT_FOUND;
|
|
|
|
NSCalendarDate *lastModified;
|
|
|
|
|
|
|
|
if ([[event attendees] count] > 0)
|
|
|
|
{
|
|
|
|
lastModified = [event lastModified];
|
|
|
|
if (lastModified)
|
|
|
|
{
|
|
|
|
*data = [lastModified asFileTimeInMemCtx: memCtx];
|
|
|
|
rc = MAPISTORE_SUCCESS;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return rc;
|
|
|
|
}
|
|
|
|
|
2012-03-02 21:44:24 +01:00
|
|
|
- (int) getPidTagMessageClass: (void **) data
|
2011-07-21 17:05:17 +02:00
|
|
|
inMemCtx: (TALLOC_CTX *) memCtx
|
|
|
|
{
|
2011-10-03 22:55:02 +02:00
|
|
|
const char *className;
|
|
|
|
|
2011-10-12 01:38:37 +02:00
|
|
|
if (!itipSetup)
|
|
|
|
[self _setupITIPContext];
|
|
|
|
|
2011-10-11 23:16:57 +02:00
|
|
|
if (method)
|
|
|
|
{
|
|
|
|
if ([method isEqualToString: @"REQUEST"])
|
|
|
|
className = "IPM.Schedule.Meeting.Request";
|
|
|
|
else if ([method isEqualToString: @"REPLY"])
|
|
|
|
{
|
2011-10-12 01:38:37 +02:00
|
|
|
switch (partstat)
|
2011-10-11 23:16:57 +02:00
|
|
|
{
|
2011-10-12 01:38:37 +02:00
|
|
|
case iCalPersonPartStatAccepted:
|
|
|
|
className = "IPM.Schedule.Meeting.Resp.Pos";
|
|
|
|
break;
|
|
|
|
case iCalPersonPartStatDeclined:
|
|
|
|
className = "IPM.Schedule.Meeting.Resp.Neg";
|
|
|
|
break;
|
|
|
|
case iCalPersonPartStatTentative:
|
|
|
|
className = "IPM.Schedule.Meeting.Resp.Tent";
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
className = "IPM.Appointment";
|
|
|
|
[self logWithFormat: @"unhandled part stat"];
|
2011-10-11 23:16:57 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else if ([method isEqualToString: @"COUNTER"])
|
|
|
|
className = "IPM.Schedule.Meeting.Resp.Tent";
|
|
|
|
else if ([method isEqualToString: @"CANCEL"])
|
|
|
|
className = "IPM.Schedule.Meeting.Cancelled";
|
|
|
|
else
|
|
|
|
{
|
|
|
|
className = "IPM.Appointment";
|
|
|
|
[self logWithFormat: @"unhandled method: %@", method];
|
|
|
|
}
|
|
|
|
}
|
2011-10-03 22:55:02 +02:00
|
|
|
else
|
|
|
|
className = "IPM.Appointment";
|
|
|
|
*data = talloc_strdup(memCtx, className);
|
2011-07-21 17:05:17 +02:00
|
|
|
|
|
|
|
return MAPISTORE_SUCCESS;
|
|
|
|
}
|
|
|
|
|
2011-10-03 22:55:02 +02:00
|
|
|
- (int) getPidLidFInvited: (void **) data
|
|
|
|
inMemCtx: (TALLOC_CTX *) memCtx
|
|
|
|
{
|
|
|
|
return [self getYes: data inMemCtx: memCtx];
|
|
|
|
}
|
|
|
|
|
2012-03-02 21:44:24 +01:00
|
|
|
- (int) getPidTagStartDate: (void **) data
|
2011-07-21 17:05:17 +02:00
|
|
|
inMemCtx: (TALLOC_CTX *) memCtx
|
|
|
|
{
|
|
|
|
NSCalendarDate *dateValue;
|
2012-01-12 17:06:57 +01:00
|
|
|
NSInteger offset;
|
2011-07-21 17:05:17 +02:00
|
|
|
|
|
|
|
if ([event isRecurrent])
|
|
|
|
dateValue = [event firstRecurrenceStartDate];
|
|
|
|
else
|
|
|
|
dateValue = [event startDate];
|
2012-01-12 17:06:57 +01:00
|
|
|
if ([event isAllDay])
|
|
|
|
{
|
|
|
|
offset = -[timeZone secondsFromGMTForDate: dateValue];
|
|
|
|
dateValue = [dateValue dateByAddingYears: 0 months: 0 days: 0
|
|
|
|
hours: 0 minutes: 0
|
|
|
|
seconds: offset];
|
|
|
|
}
|
2011-07-21 17:05:17 +02:00
|
|
|
[dateValue setTimeZone: utcTZ];
|
|
|
|
*data = [dateValue asFileTimeInMemCtx: memCtx];
|
|
|
|
|
|
|
|
return MAPISTORE_SUCCESS;
|
|
|
|
}
|
|
|
|
|
2012-03-20 19:50:09 +01:00
|
|
|
- (int) getPidLidAppointmentSequence: (void **) data
|
|
|
|
inMemCtx: (TALLOC_CTX *) memCtx
|
|
|
|
{
|
|
|
|
*data = MAPILongValue (memCtx, [[event sequence] unsignedIntValue]);
|
|
|
|
|
|
|
|
return MAPISTORE_SUCCESS;
|
|
|
|
}
|
|
|
|
|
2011-08-08 21:01:24 +02:00
|
|
|
- (int) getPidLidAppointmentStateFlags: (void **) data
|
|
|
|
inMemCtx: (TALLOC_CTX *) memCtx
|
|
|
|
{
|
|
|
|
uint32_t flags = 0x00;
|
|
|
|
|
|
|
|
if ([[event attendees] count] > 0)
|
2011-10-03 22:55:02 +02:00
|
|
|
{
|
|
|
|
flags |= 0x01; /* asfMeeting */
|
|
|
|
if ([event userAsAttendee: user])
|
|
|
|
flags |= 0x02; /* asfReceived */
|
|
|
|
/* TODO: asfCancelled */
|
|
|
|
}
|
2011-08-08 21:01:24 +02:00
|
|
|
|
|
|
|
*data = MAPILongValue (memCtx, flags);
|
|
|
|
|
|
|
|
return MAPISTORE_SUCCESS;
|
|
|
|
}
|
|
|
|
|
2011-10-03 22:55:02 +02:00
|
|
|
- (int) getPidLidResponseStatus: (void **) data
|
|
|
|
inMemCtx: (TALLOC_CTX *) memCtx
|
|
|
|
{
|
|
|
|
uint32_t status = 0x00;
|
|
|
|
iCalPerson *person;
|
|
|
|
|
|
|
|
if ([[event attendees] count] > 0)
|
|
|
|
{
|
|
|
|
if ([event userIsOrganizer: user])
|
|
|
|
status = 1;
|
|
|
|
else
|
|
|
|
{
|
|
|
|
person = [event userAsAttendee: user];
|
|
|
|
if (person)
|
|
|
|
{
|
|
|
|
switch ([person participationStatus])
|
|
|
|
{
|
|
|
|
case iCalPersonPartStatTentative:
|
|
|
|
status = 2;
|
|
|
|
break;
|
|
|
|
case iCalPersonPartStatAccepted:
|
|
|
|
status = 3;
|
|
|
|
break;
|
|
|
|
case iCalPersonPartStatDeclined:
|
|
|
|
status = 4;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
status = 5;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
*data = MAPILongValue (memCtx, status);
|
|
|
|
|
|
|
|
return MAPISTORE_SUCCESS;
|
|
|
|
}
|
|
|
|
|
2011-07-21 17:05:17 +02:00
|
|
|
- (int) getPidLidAppointmentStartWhole: (void **) data
|
|
|
|
inMemCtx: (TALLOC_CTX *) memCtx
|
|
|
|
{
|
2012-03-02 21:44:24 +01:00
|
|
|
return [self getPidTagStartDate: data inMemCtx: memCtx];
|
2011-07-21 17:05:17 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
- (int) getPidLidCommonStart: (void **) data
|
|
|
|
inMemCtx: (TALLOC_CTX *) memCtx
|
|
|
|
{
|
|
|
|
return [self getPidLidAppointmentStartWhole: data inMemCtx: memCtx];
|
|
|
|
}
|
|
|
|
|
2011-10-03 22:55:02 +02:00
|
|
|
- (int) _getEntryIdFromCN: (NSString *) cn
|
|
|
|
andEmail: (NSString *) email
|
|
|
|
inData: (void **) data
|
|
|
|
inMemCtx: (TALLOC_CTX *) memCtx
|
|
|
|
{
|
|
|
|
NSString *username;
|
|
|
|
SOGoUserManager *mgr;
|
|
|
|
NSDictionary *contactInfos;
|
|
|
|
NSData *entryId;
|
|
|
|
|
|
|
|
mgr = [SOGoUserManager sharedUserManager];
|
|
|
|
contactInfos = [mgr contactInfosForUserWithUIDorEmail: email];
|
|
|
|
if (contactInfos)
|
|
|
|
{
|
|
|
|
username = [contactInfos objectForKey: @"c_uid"];
|
2011-11-17 17:15:38 +01:00
|
|
|
entryId = MAPIStoreInternalEntryId (connInfo->sam_ctx, username);
|
2011-10-03 22:55:02 +02:00
|
|
|
}
|
|
|
|
else
|
|
|
|
entryId = MAPIStoreExternalEntryId (cn, email);
|
|
|
|
|
|
|
|
*data = [entryId asBinaryInMemCtx: memCtx];
|
|
|
|
|
|
|
|
return MAPISTORE_SUCCESS;
|
|
|
|
}
|
|
|
|
|
|
|
|
- (int) _getEmailAddress: (void **) data
|
|
|
|
forICalPerson: (iCalPerson *) person
|
|
|
|
inMemCtx: (TALLOC_CTX *) memCtx
|
|
|
|
{
|
|
|
|
int rc;
|
|
|
|
NSString *email;
|
|
|
|
|
|
|
|
email = [person rfc822Email];
|
|
|
|
if ([email length] > 0)
|
|
|
|
{
|
|
|
|
*data = [email asUnicodeInMemCtx: memCtx];
|
|
|
|
rc = MAPISTORE_SUCCESS;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
rc = MAPISTORE_ERR_NOT_FOUND;
|
|
|
|
|
|
|
|
return rc;
|
|
|
|
}
|
|
|
|
|
|
|
|
- (int) _getAddrType: (void **) data
|
|
|
|
forICalPerson: (iCalPerson *) person
|
|
|
|
inMemCtx: (TALLOC_CTX *) memCtx
|
|
|
|
{
|
|
|
|
*data = [@"SMTP" asUnicodeInMemCtx: memCtx];
|
|
|
|
|
|
|
|
return MAPISTORE_SUCCESS;
|
|
|
|
}
|
|
|
|
|
|
|
|
- (int) _getName: (void **) data
|
|
|
|
forICalPerson: (iCalPerson *) person
|
|
|
|
inMemCtx: (TALLOC_CTX *) memCtx
|
|
|
|
{
|
|
|
|
int rc;
|
|
|
|
NSString *cn;
|
|
|
|
|
|
|
|
cn = [person cn];
|
|
|
|
if ([cn length] > 0)
|
|
|
|
{
|
|
|
|
*data = [cn asUnicodeInMemCtx: memCtx];
|
|
|
|
rc = MAPISTORE_SUCCESS;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
rc = MAPISTORE_ERR_NOT_FOUND;
|
|
|
|
|
|
|
|
return rc;
|
|
|
|
}
|
|
|
|
|
2012-03-02 21:44:24 +01:00
|
|
|
- (int) _getEntryId: (void **) data
|
2011-10-03 22:55:02 +02:00
|
|
|
forICalPerson: (iCalPerson *) person
|
|
|
|
inMemCtx: (TALLOC_CTX *) memCtx
|
|
|
|
{
|
|
|
|
int rc = MAPISTORE_ERR_NOT_FOUND;
|
|
|
|
NSString *email, *cn;
|
|
|
|
|
|
|
|
if (person)
|
|
|
|
{
|
|
|
|
email = [person rfc822Email];
|
|
|
|
if ([email length] > 0)
|
|
|
|
{
|
|
|
|
cn = [person cn];
|
|
|
|
rc = [self _getEntryIdFromCN: cn andEmail: email
|
|
|
|
inData: data
|
|
|
|
inMemCtx: memCtx];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return rc;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* sender (organizer) */
|
2012-03-02 21:44:24 +01:00
|
|
|
- (int) getPidTagSenderEmailAddress: (void **) data
|
2011-10-03 22:55:02 +02:00
|
|
|
inMemCtx: (TALLOC_CTX *) memCtx
|
|
|
|
{
|
|
|
|
return [self _getEmailAddress: data
|
|
|
|
forICalPerson: [event organizer]
|
|
|
|
inMemCtx: memCtx];
|
|
|
|
}
|
|
|
|
|
2012-03-02 21:44:24 +01:00
|
|
|
- (int) getPidTagSenderAddressType: (void **) data
|
2011-10-03 22:55:02 +02:00
|
|
|
inMemCtx: (TALLOC_CTX *) memCtx
|
|
|
|
{
|
|
|
|
return [self _getAddrType: data
|
|
|
|
forICalPerson: [event organizer]
|
|
|
|
inMemCtx: memCtx];
|
|
|
|
}
|
|
|
|
|
2012-03-02 21:44:24 +01:00
|
|
|
- (int) getPidTagSenderName: (void **) data
|
2011-10-03 22:55:02 +02:00
|
|
|
inMemCtx: (TALLOC_CTX *) memCtx
|
|
|
|
{
|
|
|
|
return [self _getName: data
|
|
|
|
forICalPerson: [event organizer]
|
|
|
|
inMemCtx: memCtx];
|
|
|
|
}
|
|
|
|
|
2012-03-02 21:44:24 +01:00
|
|
|
- (int) getPidTagSenderEntryId: (void **) data
|
2011-10-03 22:55:02 +02:00
|
|
|
inMemCtx: (TALLOC_CTX *) memCtx
|
|
|
|
{
|
2012-03-02 21:44:24 +01:00
|
|
|
return [self _getEntryId: data
|
2011-10-03 22:55:02 +02:00
|
|
|
forICalPerson: [event organizer]
|
|
|
|
inMemCtx: memCtx];
|
|
|
|
}
|
|
|
|
|
|
|
|
/* attendee */
|
2012-03-02 21:44:24 +01:00
|
|
|
- (int) getPidTagReceivedByEmailAddress: (void **) data
|
2011-10-03 22:55:02 +02:00
|
|
|
inMemCtx: (TALLOC_CTX *) memCtx
|
|
|
|
{
|
|
|
|
return [self _getEmailAddress: data
|
|
|
|
forICalPerson: [event userAsAttendee: user]
|
|
|
|
inMemCtx: memCtx];
|
|
|
|
}
|
|
|
|
|
2012-03-02 21:44:24 +01:00
|
|
|
- (int) getPidTagReceivedByAddressType: (void **) data
|
2011-10-03 22:55:02 +02:00
|
|
|
inMemCtx: (TALLOC_CTX *) memCtx
|
|
|
|
{
|
|
|
|
return [self _getAddrType: data
|
|
|
|
forICalPerson: [event userAsAttendee: user]
|
|
|
|
inMemCtx: memCtx];
|
|
|
|
}
|
|
|
|
|
2012-03-02 21:44:24 +01:00
|
|
|
- (int) getPidTagReceivedByName: (void **) data
|
2011-10-03 22:55:02 +02:00
|
|
|
inMemCtx: (TALLOC_CTX *) memCtx
|
|
|
|
{
|
|
|
|
return [self _getName: data
|
|
|
|
forICalPerson: [event userAsAttendee: user]
|
|
|
|
inMemCtx: memCtx];
|
|
|
|
}
|
|
|
|
|
2012-03-02 21:44:24 +01:00
|
|
|
- (int) getPidTagReceivedByEntryId: (void **) data
|
2011-10-03 22:55:02 +02:00
|
|
|
inMemCtx: (TALLOC_CTX *) memCtx
|
|
|
|
{
|
2012-03-02 21:44:24 +01:00
|
|
|
return [self _getEntryId: data
|
2011-10-03 22:55:02 +02:00
|
|
|
forICalPerson: [event userAsAttendee: user]
|
|
|
|
inMemCtx: memCtx];
|
|
|
|
}
|
|
|
|
/* /attendee */
|
|
|
|
|
2012-03-02 21:44:24 +01:00
|
|
|
- (int) getPidTagEndDate: (void **) data
|
2011-07-21 17:05:17 +02:00
|
|
|
inMemCtx: (TALLOC_CTX *) memCtx
|
|
|
|
{
|
|
|
|
NSCalendarDate *dateValue;
|
2012-01-12 17:06:57 +01:00
|
|
|
NSInteger offset;
|
2011-07-21 17:05:17 +02:00
|
|
|
|
|
|
|
if ([event isRecurrent])
|
|
|
|
dateValue = [event firstRecurrenceStartDate];
|
|
|
|
else
|
|
|
|
dateValue = [event startDate];
|
2012-01-12 17:06:57 +01:00
|
|
|
offset = [event durationAsTimeInterval];
|
|
|
|
if ([event isAllDay])
|
|
|
|
offset -= [timeZone secondsFromGMTForDate: dateValue];
|
|
|
|
dateValue = [dateValue dateByAddingYears: 0 months: 0 days: 0
|
|
|
|
hours: 0 minutes: 0
|
|
|
|
seconds: offset];
|
2011-07-21 17:05:17 +02:00
|
|
|
[dateValue setTimeZone: utcTZ];
|
|
|
|
*data = [dateValue asFileTimeInMemCtx: memCtx];
|
|
|
|
|
|
|
|
return MAPISTORE_SUCCESS;
|
|
|
|
}
|
|
|
|
|
|
|
|
- (int) getPidLidAppointmentEndWhole: (void **) data
|
|
|
|
inMemCtx: (TALLOC_CTX *) memCtx
|
|
|
|
{
|
2012-03-02 21:44:24 +01:00
|
|
|
return [self getPidTagEndDate: data inMemCtx: memCtx];
|
2011-07-21 17:05:17 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
- (int) getPidLidCommonEnd: (void **) data
|
|
|
|
inMemCtx: (TALLOC_CTX *) memCtx
|
|
|
|
{
|
|
|
|
return [self getPidLidAppointmentEndWhole: data inMemCtx: memCtx];
|
|
|
|
}
|
|
|
|
|
|
|
|
- (int) getPidLidAppointmentDuration: (void **) data
|
|
|
|
inMemCtx: (TALLOC_CTX *) memCtx
|
|
|
|
{
|
|
|
|
NSTimeInterval timeValue;
|
|
|
|
|
|
|
|
timeValue = [[event endDate] timeIntervalSinceDate: [event startDate]];
|
|
|
|
*data = MAPILongValue (memCtx, (uint32_t) (timeValue / 60));
|
|
|
|
|
|
|
|
return MAPISTORE_SUCCESS;
|
|
|
|
}
|
|
|
|
|
|
|
|
- (int) getPidLidAppointmentSubType: (void **) data
|
|
|
|
inMemCtx: (TALLOC_CTX *) memCtx
|
|
|
|
{
|
|
|
|
*data = MAPIBoolValue (memCtx, [event isAllDay]);
|
|
|
|
|
|
|
|
return MAPISTORE_SUCCESS;
|
|
|
|
}
|
|
|
|
|
2011-09-20 01:33:48 +02:00
|
|
|
- (int) getPidLidBusyStatus: (void **) data
|
2011-07-21 17:05:17 +02:00
|
|
|
inMemCtx: (TALLOC_CTX *) memCtx
|
|
|
|
{
|
2011-09-20 01:33:48 +02:00
|
|
|
uint8_t value;
|
|
|
|
|
|
|
|
value = 0x2; // olBusy
|
|
|
|
|
|
|
|
if (![event isOpaque])
|
|
|
|
value = 0x0; // olFree
|
|
|
|
|
|
|
|
*data = MAPILongValue (memCtx, value);
|
2011-07-21 17:05:17 +02:00
|
|
|
|
|
|
|
return MAPISTORE_SUCCESS;
|
|
|
|
}
|
|
|
|
|
|
|
|
- (int) getPidLidIndentedBusyStatus: (void **) data // TODO
|
|
|
|
inMemCtx: (TALLOC_CTX *) memCtx
|
|
|
|
{
|
|
|
|
return [self getPidLidBusyStatus: data inMemCtx: memCtx];
|
|
|
|
}
|
|
|
|
|
2012-03-02 21:44:24 +01:00
|
|
|
- (int) getPidTagSubject: (void **) data // SUMMARY
|
2011-07-21 17:05:17 +02:00
|
|
|
inMemCtx: (TALLOC_CTX *) memCtx
|
|
|
|
{
|
|
|
|
*data = [[event summary] asUnicodeInMemCtx: memCtx];
|
|
|
|
|
|
|
|
return MAPISTORE_SUCCESS;
|
|
|
|
}
|
|
|
|
|
|
|
|
- (int) getPidLidLocation: (void **) data // LOCATION
|
|
|
|
inMemCtx: (TALLOC_CTX *) memCtx
|
|
|
|
{
|
2011-10-12 01:38:37 +02:00
|
|
|
int rc = MAPISTORE_SUCCESS;
|
|
|
|
NSString *location;
|
2011-07-21 17:05:17 +02:00
|
|
|
|
2011-10-12 01:38:37 +02:00
|
|
|
location = [event location];
|
|
|
|
if (location)
|
|
|
|
*data = [location asUnicodeInMemCtx: memCtx];
|
|
|
|
else
|
|
|
|
rc = MAPISTORE_ERR_NOT_FOUND;
|
|
|
|
|
|
|
|
return rc;
|
2011-07-21 17:05:17 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
- (int) getPidLidWhere: (void **) data
|
|
|
|
inMemCtx: (TALLOC_CTX *) memCtx
|
|
|
|
{
|
|
|
|
return [self getPidLidLocation: data inMemCtx: memCtx];
|
|
|
|
}
|
|
|
|
|
2011-10-03 22:55:02 +02:00
|
|
|
- (int) getPidLidServerProcessed: (void **) data inMemCtx: (TALLOC_CTX *) memCtx
|
2011-07-21 17:05:17 +02:00
|
|
|
{
|
2011-08-08 21:01:24 +02:00
|
|
|
/* 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
|
|
|
|
here. */
|
|
|
|
return [self getYes: data inMemCtx: memCtx];
|
2011-07-21 17:05:17 +02:00
|
|
|
}
|
|
|
|
|
2011-10-03 22:55:02 +02:00
|
|
|
- (int) getPidLidServerProcessingActions: (void **) data inMemCtx: (TALLOC_CTX *) memCtx
|
|
|
|
{
|
|
|
|
*data = MAPILongValue (memCtx,
|
|
|
|
0x00000010 /* cpsCreatedOnPrincipal */
|
|
|
|
| 0x00000080 /* cpsUpdatedCalItem */
|
|
|
|
| 0x00000100 /* cpsCopiedOldProperties */);
|
|
|
|
|
|
|
|
return MAPISTORE_SUCCESS;
|
|
|
|
}
|
|
|
|
|
2011-07-21 17:05:17 +02:00
|
|
|
- (int) getPidLidPrivate: (void **) data // private (bool), should depend on CLASS and permissions
|
|
|
|
inMemCtx: (TALLOC_CTX *) memCtx
|
|
|
|
{
|
|
|
|
return [self getNo: data inMemCtx: memCtx];
|
|
|
|
}
|
|
|
|
|
2012-03-02 21:44:24 +01:00
|
|
|
- (int) getPidTagSensitivity: (void **) data // not implemented, depends on CLASS
|
2011-07-21 17:05:17 +02:00
|
|
|
inMemCtx: (TALLOC_CTX *) memCtx
|
|
|
|
{
|
|
|
|
// normal = 0, personal?? = 1, private = 2, confidential = 3
|
|
|
|
return [self getLongZero: data inMemCtx: memCtx];
|
|
|
|
}
|
|
|
|
|
2012-03-02 21:44:24 +01:00
|
|
|
- (int) getPidTagImportance: (void **) data
|
2011-07-21 17:05:17 +02:00
|
|
|
inMemCtx: (TALLOC_CTX *) memCtx
|
|
|
|
{
|
|
|
|
uint32_t v;
|
|
|
|
if ([[event priority] isEqualToString: @"9"])
|
|
|
|
v = 0x0;
|
|
|
|
else if ([[event priority] isEqualToString: @"1"])
|
|
|
|
v = 0x2;
|
|
|
|
else
|
|
|
|
v = 0x1;
|
|
|
|
|
|
|
|
*data = MAPILongValue (memCtx, v);
|
|
|
|
|
|
|
|
return MAPISTORE_SUCCESS;
|
|
|
|
}
|
|
|
|
|
2012-03-02 21:44:24 +01:00
|
|
|
- (int) getPidTagBody: (void **) data
|
2011-11-09 21:47:08 +01:00
|
|
|
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)
|
2011-11-14 04:26:50 +01:00
|
|
|
*data = [stringValue asUnicodeInMemCtx: memCtx];
|
2011-11-09 21:47:08 +01:00
|
|
|
else
|
|
|
|
rc = MAPISTORE_ERR_NOT_FOUND;
|
|
|
|
|
|
|
|
return rc;
|
|
|
|
}
|
|
|
|
|
2011-07-21 17:05:17 +02:00
|
|
|
- (int) getPidLidIsRecurring: (void **) data
|
|
|
|
inMemCtx: (TALLOC_CTX *) memCtx
|
|
|
|
{
|
|
|
|
*data = MAPIBoolValue (memCtx, [event isRecurrent]);
|
|
|
|
|
|
|
|
return MAPISTORE_SUCCESS;
|
|
|
|
}
|
|
|
|
|
|
|
|
- (int) getPidLidRecurring: (void **) data
|
|
|
|
inMemCtx: (TALLOC_CTX *) memCtx
|
|
|
|
{
|
|
|
|
*data = MAPIBoolValue (memCtx, [event isRecurrent]);
|
|
|
|
|
|
|
|
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 AppointmentRecurrencePattern *arp;
|
|
|
|
struct Binary_r *bin;
|
|
|
|
struct SBinary_short *sBin;
|
|
|
|
NSCalendarDate *firstStartDate;
|
|
|
|
iCalRecurrenceRule *rule;
|
|
|
|
|
|
|
|
rule = [[event recurrenceRules] objectAtIndex: 0];
|
|
|
|
|
|
|
|
firstStartDate = [event firstRecurrenceStartDate];
|
|
|
|
if (firstStartDate)
|
|
|
|
{
|
|
|
|
[firstStartDate setTimeZone: timeZone];
|
|
|
|
|
|
|
|
arp = talloc_zero (memCtx, struct AppointmentRecurrencePattern);
|
|
|
|
_fillAppointmentRecurrencePattern (arp, firstStartDate,
|
|
|
|
[event durationAsTimeInterval],
|
|
|
|
[event lastPossibleRecurrenceStartDate],
|
|
|
|
rule);
|
|
|
|
sBin = talloc_zero (memCtx, struct SBinary_short);
|
|
|
|
bin = set_AppointmentRecurrencePattern (sBin, arp);
|
|
|
|
sBin->cb = bin->cb;
|
|
|
|
sBin->lpb = bin->lpb;
|
|
|
|
talloc_free (arp);
|
|
|
|
|
|
|
|
// DEBUG(5, ("To client:\n"));
|
|
|
|
// NDR_PRINT_DEBUG (AppointmentRecurrencePattern, arp);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
[self errorWithFormat: @"no first occurrence found in rule: %@", rule];
|
|
|
|
sBin = NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
return sBin;
|
|
|
|
}
|
|
|
|
|
|
|
|
- (int) getPidLidAppointmentRecur: (void **) data
|
|
|
|
inMemCtx: (TALLOC_CTX *) memCtx
|
|
|
|
{
|
|
|
|
int rc = MAPISTORE_SUCCESS;
|
|
|
|
|
|
|
|
if ([event isRecurrent])
|
|
|
|
*data = [self _computeAppointmentRecurInMemCtx: memCtx];
|
|
|
|
else
|
|
|
|
rc = MAPISTORE_ERR_NOT_FOUND;
|
|
|
|
|
|
|
|
return rc;
|
|
|
|
}
|
|
|
|
|
2011-08-06 01:38:18 +02:00
|
|
|
// - (int) getPidLidGlobalObjectId: (void **) data
|
|
|
|
// inMemCtx: (TALLOC_CTX *) memCtx
|
|
|
|
// {
|
|
|
|
// static char byteArrayId[] = {0x04, 0x00, 0x00, 0x00, 0x82, 0x00, 0xE0,
|
|
|
|
// 0x00, 0x74, 0xC5, 0xB7, 0x10, 0x1A, 0x82,
|
|
|
|
// 0xE0, 0x08};
|
|
|
|
// static char X[] = {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
|
|
|
|
// NSMutableData *nsData;
|
|
|
|
// NSData *uidData;
|
|
|
|
// NSCalendarDate *creationTime;
|
|
|
|
// struct FILETIME *creationFileTime;
|
|
|
|
// uint32_t uidDataLength;
|
|
|
|
|
|
|
|
// nsData = [NSMutableData dataWithCapacity: 256];
|
|
|
|
// [nsData appendBytes: byteArrayId length: 16];
|
|
|
|
|
|
|
|
// /* FIXME TODO */
|
|
|
|
// [nsData appendBytes: X length: 4];
|
|
|
|
// /* /FIXME */
|
|
|
|
|
|
|
|
// creationTime = [event created];
|
|
|
|
// if (!creationTime)
|
|
|
|
// {
|
|
|
|
// [self logWithFormat: @"" __location__ ": event has no 'CREATED' tag -> inventing one"];
|
|
|
|
// creationTime = [event lastModified];
|
|
|
|
// if (!creationTime)
|
|
|
|
// creationTime = [NSCalendarDate date];
|
|
|
|
// }
|
|
|
|
// creationFileTime = [creationTime asFileTimeInMemCtx: NULL];
|
|
|
|
// [nsData appendBytes: &creationFileTime->dwLowDateTime length: 4];
|
|
|
|
// [nsData appendBytes: &creationFileTime->dwHighDateTime length: 4];
|
|
|
|
// talloc_free (creationFileTime);
|
|
|
|
|
|
|
|
// uidData = [[event uid] dataUsingEncoding: NSUTF8StringEncoding];
|
|
|
|
// uidDataLength = [uidData length];
|
|
|
|
// [nsData appendBytes: &uidDataLength length: 4];
|
|
|
|
// [nsData appendData: uidData];
|
|
|
|
// *data = [nsData asBinaryInMemCtx: memCtx];
|
|
|
|
|
|
|
|
// return MAPISTORE_SUCCESS;
|
|
|
|
// }
|
|
|
|
|
|
|
|
- (void) _setInstanceDate: (struct GlobalObjectId *) newGlobalId
|
|
|
|
fromDate: (NSCalendarDate *) instanceDate;
|
2011-07-21 17:05:17 +02:00
|
|
|
{
|
2011-08-06 01:38:18 +02:00
|
|
|
uint16_t year;
|
|
|
|
|
|
|
|
if (instanceDate)
|
2011-07-28 00:02:29 +02:00
|
|
|
{
|
2011-08-06 01:38:18 +02:00
|
|
|
[instanceDate setTimeZone: timeZone];
|
|
|
|
year = [instanceDate yearOfCommonEra];
|
|
|
|
newGlobalId->YH = year >> 8;
|
|
|
|
newGlobalId->YL = year & 0xff;
|
|
|
|
newGlobalId->Month = [instanceDate monthOfYear];
|
|
|
|
newGlobalId->D = [instanceDate dayOfMonth];
|
2011-07-28 00:02:29 +02:00
|
|
|
}
|
2011-08-06 01:38:18 +02:00
|
|
|
}
|
2011-07-21 17:05:17 +02:00
|
|
|
|
2011-08-06 01:38:18 +02:00
|
|
|
/* note: returns a retained object */
|
|
|
|
- (NSData *) _objectIdAsNSData: (const struct GlobalObjectId *) newGlobalId
|
|
|
|
{
|
|
|
|
NSData *nsData;
|
|
|
|
TALLOC_CTX *localMemCtx;
|
|
|
|
struct ndr_push *ndr;
|
|
|
|
|
|
|
|
localMemCtx = talloc_zero (NULL, TALLOC_CTX);
|
|
|
|
ndr = ndr_push_init_ctx (localMemCtx);
|
|
|
|
ndr_push_GlobalObjectId (ndr, NDR_SCALARS, newGlobalId);
|
|
|
|
nsData = [[NSData alloc] initWithBytes: ndr->data
|
|
|
|
length: ndr->offset];
|
|
|
|
talloc_free (localMemCtx);
|
|
|
|
|
|
|
|
return nsData;
|
|
|
|
}
|
2011-07-21 17:05:17 +02:00
|
|
|
|
2011-08-06 01:38:18 +02:00
|
|
|
- (void) _computeGlobalObjectIds
|
|
|
|
{
|
|
|
|
static NSString *prefix = @"040000008200e00074c5b7101a82e008";
|
|
|
|
static uint8_t dataPrefix[] = { 0x76, 0x43, 0x61, 0x6c, 0x2d, 0x55, 0x69,
|
|
|
|
0x64, 0x01, 0x00, 0x00, 0x00 };
|
|
|
|
NSString *uid;
|
|
|
|
const char *uidAsUTF8;
|
|
|
|
NSUInteger uidLength;
|
|
|
|
NSData *encodedGlobalIdData;
|
|
|
|
struct Binary_r *encodedGlobalIdBinary;
|
|
|
|
struct GlobalObjectId *encodedGlobalId;
|
|
|
|
struct GlobalObjectId newGlobalId;
|
|
|
|
uint16_t year;
|
|
|
|
NSData *binPrefix;
|
|
|
|
TALLOC_CTX *localMemCtx;
|
|
|
|
|
|
|
|
localMemCtx = talloc_zero (NULL, TALLOC_CTX);
|
|
|
|
|
|
|
|
memset (&newGlobalId, 0, sizeof (struct GlobalObjectId));
|
|
|
|
|
|
|
|
uid = [event uid];
|
|
|
|
uidLength = [uid length];
|
|
|
|
if (uidLength >= 82 && (uidLength % 2) == 0 && [uid hasPrefix: prefix]
|
|
|
|
&& [[uid stringByTrimmingCharactersInSet: hexCharacterSet] length] == 0)
|
|
|
|
{
|
|
|
|
encodedGlobalIdData = [uid convertHexStringToBytes];
|
|
|
|
if (encodedGlobalIdData)
|
|
|
|
{
|
|
|
|
encodedGlobalIdBinary
|
|
|
|
= [encodedGlobalIdData asBinaryInMemCtx: localMemCtx];
|
|
|
|
encodedGlobalId = get_GlobalObjectId (localMemCtx,
|
|
|
|
encodedGlobalIdBinary);
|
|
|
|
if (encodedGlobalId)
|
|
|
|
{
|
|
|
|
memcpy (newGlobalId.ByteArrayID,
|
|
|
|
encodedGlobalId->ByteArrayID,
|
|
|
|
16);
|
|
|
|
year = ((uint16_t) encodedGlobalId->YH << 8) | encodedGlobalId->YL;
|
|
|
|
if (year >= 1601 && year <= 4500
|
|
|
|
&& encodedGlobalId->Month > 0 && encodedGlobalId->Month < 13
|
|
|
|
&& encodedGlobalId->D > 0 && encodedGlobalId->D < 31)
|
|
|
|
{
|
|
|
|
newGlobalId.YH = encodedGlobalId->YH;
|
|
|
|
newGlobalId.YL = encodedGlobalId->YL;
|
|
|
|
newGlobalId.Month = encodedGlobalId->Month;
|
|
|
|
newGlobalId.D = encodedGlobalId->D;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
[self _setInstanceDate: &newGlobalId
|
|
|
|
fromDate: [event recurrenceId]];
|
|
|
|
newGlobalId.CreationTime = encodedGlobalId->CreationTime;
|
|
|
|
memcpy (newGlobalId.X, encodedGlobalId->X, 8);
|
|
|
|
newGlobalId.Size = encodedGlobalId->Size;
|
|
|
|
newGlobalId.Data = encodedGlobalId->Data;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
abort ();
|
|
|
|
}
|
|
|
|
else
|
|
|
|
abort ();
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
binPrefix = [prefix convertHexStringToBytes];
|
|
|
|
[binPrefix getBytes: &newGlobalId.ByteArrayID];
|
|
|
|
[self _setInstanceDate: &newGlobalId
|
|
|
|
fromDate: [event recurrenceId]];
|
|
|
|
uidAsUTF8 = [uid UTF8String];
|
|
|
|
newGlobalId.Size = 0x0c + strlen (uidAsUTF8);
|
|
|
|
newGlobalId.Data = talloc_array (localMemCtx, uint8_t,
|
|
|
|
newGlobalId.Size);
|
|
|
|
memcpy (newGlobalId.Data, dataPrefix, 0x0c);
|
|
|
|
memcpy (newGlobalId.Data + 0x0c, uidAsUTF8, newGlobalId.Size - 0x0c);
|
|
|
|
}
|
|
|
|
|
|
|
|
globalObjectId = [self _objectIdAsNSData: &newGlobalId];
|
|
|
|
|
|
|
|
newGlobalId.YH = 0;
|
|
|
|
newGlobalId.YL = 0;
|
|
|
|
newGlobalId.Month = 0;
|
|
|
|
newGlobalId.D = 0;
|
|
|
|
cleanGlobalObjectId = [self _objectIdAsNSData: &newGlobalId];
|
|
|
|
|
|
|
|
talloc_free (localMemCtx);
|
|
|
|
}
|
|
|
|
|
|
|
|
- (int) getPidLidGlobalObjectId: (void **) data
|
|
|
|
inMemCtx: (TALLOC_CTX *) memCtx
|
|
|
|
{
|
|
|
|
int rc = MAPISTORE_SUCCESS;
|
|
|
|
|
|
|
|
if (!globalObjectId)
|
|
|
|
[self _computeGlobalObjectIds];
|
|
|
|
|
|
|
|
if (globalObjectId)
|
|
|
|
*data = [globalObjectId asBinaryInMemCtx: memCtx];
|
|
|
|
else
|
|
|
|
abort ();
|
|
|
|
|
|
|
|
return rc;
|
2011-07-21 17:05:17 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
- (int) getPidLidCleanGlobalObjectId: (void **) data
|
|
|
|
inMemCtx: (TALLOC_CTX *) memCtx
|
|
|
|
{
|
2011-08-06 01:38:18 +02:00
|
|
|
int rc = MAPISTORE_SUCCESS;
|
|
|
|
|
|
|
|
if (!cleanGlobalObjectId)
|
|
|
|
[self _computeGlobalObjectIds];
|
|
|
|
|
|
|
|
if (cleanGlobalObjectId)
|
|
|
|
*data = [cleanGlobalObjectId asBinaryInMemCtx: memCtx];
|
|
|
|
else
|
|
|
|
abort ();
|
|
|
|
|
|
|
|
return rc;
|
2011-07-21 17:05:17 +02:00
|
|
|
}
|
|
|
|
|
2011-10-03 22:55:02 +02:00
|
|
|
- (int) getPidLidAppointmentReplyTime: (void **) data
|
|
|
|
inMemCtx: (TALLOC_CTX *) memCtx
|
|
|
|
{
|
|
|
|
/* We always return LAST-MODIFIED, which is a hack, but one that works
|
|
|
|
because: the user is either (NOT recipient OR (is recipient AND its
|
|
|
|
status is N/A), where this value should not be taken into account by the
|
|
|
|
client OR the user is recipient and its status is defined, where this
|
|
|
|
value is thus correct because the recipient status is the only property
|
|
|
|
that can be changed. */
|
|
|
|
int rc = MAPISTORE_ERR_NOT_FOUND;
|
|
|
|
NSCalendarDate *lastModified;
|
|
|
|
|
|
|
|
lastModified = [event lastModified];
|
|
|
|
if (lastModified)
|
|
|
|
{
|
|
|
|
*data = [lastModified asFileTimeInMemCtx: memCtx];
|
|
|
|
rc = MAPISTORE_SUCCESS;
|
|
|
|
}
|
|
|
|
|
|
|
|
return rc;
|
|
|
|
}
|
|
|
|
|
2011-10-11 21:46:02 +02:00
|
|
|
/* reminders */
|
|
|
|
- (void) _setupAlarm
|
|
|
|
{
|
|
|
|
NSArray *alarms;
|
|
|
|
NSUInteger count, max;
|
|
|
|
iCalAlarm *currentAlarm;
|
|
|
|
NSString *action;
|
|
|
|
|
|
|
|
alarms = [event alarms];
|
|
|
|
max = [alarms count];
|
|
|
|
for (count = 0; !alarm && count < max; count++)
|
|
|
|
{
|
|
|
|
currentAlarm = [alarms objectAtIndex: count];
|
|
|
|
action = [[currentAlarm action] lowercaseString];
|
|
|
|
if (!action || [action isEqualToString: @"display"])
|
|
|
|
ASSIGN (alarm, currentAlarm);
|
|
|
|
}
|
|
|
|
|
|
|
|
alarmSet = YES;
|
|
|
|
}
|
|
|
|
|
|
|
|
- (int) getPidLidReminderSet: (void **) data
|
|
|
|
inMemCtx: (TALLOC_CTX *) memCtx
|
|
|
|
{
|
|
|
|
if (!alarmSet)
|
|
|
|
[self _setupAlarm];
|
|
|
|
|
|
|
|
*data = MAPIBoolValue (memCtx, (alarm != nil));
|
|
|
|
|
|
|
|
return MAPISTORE_SUCCESS;
|
|
|
|
}
|
|
|
|
|
|
|
|
- (int) getPidLidReminderTime: (void **) data
|
|
|
|
inMemCtx: (TALLOC_CTX *) memCtx
|
|
|
|
{
|
|
|
|
if (!alarmSet)
|
|
|
|
[self _setupAlarm];
|
|
|
|
|
|
|
|
return (alarm
|
2012-03-02 21:44:24 +01:00
|
|
|
? [self getPidTagStartDate: data inMemCtx: memCtx]
|
2011-10-11 21:46:02 +02:00
|
|
|
: MAPISTORE_ERR_NOT_FOUND);
|
|
|
|
}
|
|
|
|
|
|
|
|
- (int) getPidLidReminderDelta: (void **) data
|
|
|
|
inMemCtx: (TALLOC_CTX *) memCtx
|
|
|
|
{
|
|
|
|
int rc = MAPISTORE_ERR_NOT_FOUND;
|
|
|
|
iCalTrigger *trigger;
|
|
|
|
NSCalendarDate *startDate, *relationDate, *alarmDate;
|
|
|
|
NSTimeInterval interval;
|
|
|
|
NSString *relation;
|
|
|
|
|
|
|
|
if (!alarmSet)
|
|
|
|
[self _setupAlarm];
|
|
|
|
|
|
|
|
if (alarm)
|
|
|
|
{
|
|
|
|
trigger = [alarm trigger];
|
|
|
|
if ([[trigger valueType] caseInsensitiveCompare: @"DURATION"] == NSOrderedSame)
|
|
|
|
{
|
|
|
|
startDate = [event startDate];
|
|
|
|
relation = [[trigger relationType] lowercaseString];
|
2011-11-14 04:26:50 +01:00
|
|
|
interval = [[trigger flattenedValuesForKey: @""]
|
|
|
|
durationAsTimeInterval];
|
2011-10-11 21:46:02 +02:00
|
|
|
if ([relation isEqualToString: @"end"])
|
|
|
|
relationDate = [event endDate];
|
|
|
|
else
|
|
|
|
relationDate = startDate;
|
|
|
|
|
|
|
|
// Compute the next alarm date with respect to the reference date
|
|
|
|
if (relationDate)
|
|
|
|
{
|
|
|
|
alarmDate = [relationDate addTimeInterval: interval];
|
|
|
|
interval = [startDate timeIntervalSinceDate: alarmDate];
|
|
|
|
*data = MAPILongValue (memCtx, (int) (interval / 60));
|
|
|
|
rc = MAPISTORE_SUCCESS;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return rc;
|
|
|
|
}
|
|
|
|
|
|
|
|
- (int) getPidLidReminderSignalTime: (void **) data
|
|
|
|
inMemCtx: (TALLOC_CTX *) memCtx
|
|
|
|
{
|
|
|
|
int rc = MAPISTORE_SUCCESS;
|
|
|
|
NSCalendarDate *alarmDate;
|
|
|
|
|
|
|
|
if (!alarmSet)
|
|
|
|
[self _setupAlarm];
|
|
|
|
|
|
|
|
if (alarm)
|
|
|
|
{
|
|
|
|
alarmDate = [alarm nextAlarmDate];
|
|
|
|
[alarmDate setTimeZone: utcTZ];
|
|
|
|
*data = [alarmDate asFileTimeInMemCtx: memCtx];
|
|
|
|
}
|
|
|
|
else
|
|
|
|
rc = MAPISTORE_ERR_NOT_FOUND;
|
|
|
|
|
|
|
|
return rc;
|
|
|
|
}
|
|
|
|
|
|
|
|
- (int) getPidLidReminderOverride: (void **) data
|
|
|
|
inMemCtx: (TALLOC_CTX *) memCtx
|
|
|
|
{
|
|
|
|
int rc = MAPISTORE_SUCCESS;
|
|
|
|
|
|
|
|
if (!alarmSet)
|
|
|
|
[self _setupAlarm];
|
|
|
|
|
|
|
|
if (alarm)
|
|
|
|
*data = MAPIBoolValue (memCtx, YES);
|
|
|
|
else
|
|
|
|
rc = MAPISTORE_ERR_NOT_FOUND;
|
|
|
|
|
|
|
|
return rc;
|
|
|
|
}
|
|
|
|
|
|
|
|
- (int) getPidLidReminderPlaySound: (void **) data
|
|
|
|
inMemCtx: (TALLOC_CTX *) memCtx
|
|
|
|
{
|
|
|
|
int rc = MAPISTORE_SUCCESS;
|
|
|
|
|
|
|
|
if (!alarmSet)
|
|
|
|
[self _setupAlarm];
|
|
|
|
|
|
|
|
if (alarm)
|
|
|
|
*data = MAPIBoolValue (memCtx, YES);
|
|
|
|
else
|
|
|
|
rc = MAPISTORE_ERR_NOT_FOUND;
|
|
|
|
|
|
|
|
return rc;
|
|
|
|
}
|
|
|
|
|
|
|
|
- (int) getPidLidReminderFileParameter: (void **) data
|
|
|
|
inMemCtx: (TALLOC_CTX *) memCtx
|
|
|
|
{
|
|
|
|
// if (!alarmSet)
|
|
|
|
// [self _setupAlarm];
|
|
|
|
|
|
|
|
return MAPISTORE_ERR_NOT_FOUND;
|
|
|
|
}
|
|
|
|
|
|
|
|
- (int) getPidLidReminderType: (void **) data
|
|
|
|
inMemCtx: (TALLOC_CTX *) memCtx
|
|
|
|
{
|
|
|
|
return MAPISTORE_ERR_NOT_FOUND;
|
|
|
|
}
|
|
|
|
|
2011-07-21 17:05:17 +02:00
|
|
|
@end
|