2011-02-24 21:30:01 +01:00
|
|
|
/* MAPIStoreCalendarMessage.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-02-24 21:30:01 +01: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.
|
|
|
|
*/
|
|
|
|
|
2011-03-21 02:01:06 +01:00
|
|
|
/* TODO:
|
|
|
|
- merge common code with tasks
|
|
|
|
- take the tz definitions from Outlook */
|
|
|
|
|
2011-07-21 17:05:17 +02:00
|
|
|
#include <talloc.h>
|
2011-11-09 16:02:29 +01:00
|
|
|
#include <util/attr.h>
|
2011-07-21 17:05:17 +02:00
|
|
|
|
2011-02-24 21:30:01 +01:00
|
|
|
#import <Foundation/NSArray.h>
|
2011-05-30 23:12:56 +02:00
|
|
|
#import <Foundation/NSCalendarDate.h>
|
2011-03-21 02:01:06 +01:00
|
|
|
#import <Foundation/NSData.h>
|
2011-02-24 21:30:01 +01:00
|
|
|
#import <Foundation/NSDictionary.h>
|
|
|
|
#import <Foundation/NSString.h>
|
2011-03-22 22:28:16 +01:00
|
|
|
#import <Foundation/NSTimeZone.h>
|
2011-02-24 21:30:01 +01:00
|
|
|
#import <NGObjWeb/WOContext+SoObjects.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/iCalCalendar.h>
|
2011-02-24 21:30:01 +01:00
|
|
|
#import <NGCards/iCalEvent.h>
|
2011-07-21 17:05:17 +02:00
|
|
|
#import <NGCards/iCalDateTime.h>
|
2011-02-24 21:30:01 +01:00
|
|
|
#import <NGCards/iCalPerson.h>
|
2011-07-21 17:05:17 +02:00
|
|
|
#import <NGCards/iCalTimeZone.h>
|
2011-10-11 21:46:02 +02:00
|
|
|
#import <NGCards/iCalTrigger.h>
|
2011-12-01 22:13:09 +01:00
|
|
|
#import <SOGo/SOGoPermissions.h>
|
2011-02-24 21:30:01 +01:00
|
|
|
#import <SOGo/SOGoUser.h>
|
2011-10-03 22:55:02 +02:00
|
|
|
#import <Appointments/SOGoAppointmentFolder.h>
|
2011-02-24 21:30:01 +01:00
|
|
|
#import <Appointments/SOGoAppointmentObject.h>
|
2011-07-21 17:05:17 +02:00
|
|
|
#import <Appointments/iCalEntityObject+SOGo.h>
|
2011-11-09 21:47:08 +01:00
|
|
|
#import <Mailer/NSString+Mail.h>
|
2011-02-24 21:30:01 +01:00
|
|
|
|
2011-07-21 17:05:17 +02:00
|
|
|
#import "MAPIStoreAppointmentWrapper.h"
|
2011-04-01 00:59:12 +02:00
|
|
|
#import "MAPIStoreCalendarAttachment.h"
|
2011-08-12 20:41:25 +02:00
|
|
|
#import "MAPIStoreCalendarFolder.h"
|
2011-02-24 21:30:01 +01:00
|
|
|
#import "MAPIStoreContext.h"
|
2011-10-03 22:55:02 +02:00
|
|
|
#import "MAPIStoreMapping.h"
|
2011-04-01 00:59:12 +02:00
|
|
|
#import "MAPIStoreRecurrenceUtils.h"
|
2011-02-24 21:30:01 +01:00
|
|
|
#import "MAPIStoreTypes.h"
|
2012-01-29 20:55:21 +01:00
|
|
|
#import "MAPIStoreUserContext.h"
|
2011-05-30 23:12:56 +02:00
|
|
|
#import "NSDate+MAPIStore.h"
|
2011-03-21 02:01:06 +01:00
|
|
|
#import "NSData+MAPIStore.h"
|
2011-07-20 20:28:37 +02:00
|
|
|
#import "NSObject+MAPIStore.h"
|
2011-02-24 21:30:01 +01:00
|
|
|
#import "NSString+MAPIStore.h"
|
2011-04-01 00:59:12 +02:00
|
|
|
#import "NSValue+MAPIStore.h"
|
2011-02-24 21:30:01 +01:00
|
|
|
|
|
|
|
#import "MAPIStoreCalendarMessage.h"
|
|
|
|
|
|
|
|
#undef DEBUG
|
|
|
|
#include <stdbool.h>
|
|
|
|
#include <gen_ndr/exchange.h>
|
2011-03-21 02:01:06 +01:00
|
|
|
#include <gen_ndr/property.h>
|
|
|
|
#include <libmapi/libmapi.h>
|
2011-02-24 21:30:01 +01:00
|
|
|
#include <mapistore/mapistore.h>
|
2011-04-01 00:59:12 +02:00
|
|
|
#include <mapistore/mapistore_errors.h>
|
2011-02-24 21:30:01 +01:00
|
|
|
#include <mapistore/mapistore_nameid.h>
|
|
|
|
|
2011-03-22 22:28:16 +01:00
|
|
|
// extern void ndr_print_AppointmentRecurrencePattern(struct ndr_print *ndr, const char *name, const struct AppointmentRecurrencePattern *r);
|
|
|
|
|
2011-09-23 17:36:49 +02:00
|
|
|
@implementation SOGoAppointmentObject (MAPIStoreExtension)
|
|
|
|
|
|
|
|
- (Class) mapistoreMessageClass
|
|
|
|
{
|
|
|
|
return [MAPIStoreCalendarMessage class];
|
|
|
|
}
|
|
|
|
|
|
|
|
@end
|
|
|
|
|
2011-02-24 21:30:01 +01:00
|
|
|
@implementation MAPIStoreCalendarMessage
|
|
|
|
|
2011-03-22 22:28:16 +01:00
|
|
|
- (id) init
|
|
|
|
{
|
|
|
|
if ((self = [super init]))
|
|
|
|
{
|
2011-07-21 17:05:17 +02:00
|
|
|
appointmentWrapper = nil;
|
2011-03-22 22:28:16 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
return self;
|
|
|
|
}
|
|
|
|
|
2011-07-21 17:05:17 +02:00
|
|
|
- (void) dealloc
|
|
|
|
{
|
|
|
|
[appointmentWrapper release];
|
|
|
|
[super dealloc];
|
|
|
|
}
|
|
|
|
|
|
|
|
- (MAPIStoreAppointmentWrapper *) appointmentWrapper
|
2011-02-24 21:30:01 +01:00
|
|
|
{
|
2011-06-07 02:17:46 +02:00
|
|
|
iCalEvent *event;
|
2011-11-17 17:15:38 +01:00
|
|
|
MAPIStoreContext *context;
|
2012-01-29 20:55:21 +01:00
|
|
|
MAPIStoreUserContext *userContext;
|
2011-06-07 02:17:46 +02:00
|
|
|
|
2011-07-21 17:05:17 +02:00
|
|
|
if (!appointmentWrapper)
|
|
|
|
{
|
2011-12-01 23:20:22 +01:00
|
|
|
event = [sogoObject component: NO secure: YES];
|
2011-11-17 17:15:38 +01:00
|
|
|
context = [self context];
|
2012-01-29 20:55:21 +01:00
|
|
|
userContext = [self userContext];
|
2011-07-21 17:05:17 +02:00
|
|
|
ASSIGN (appointmentWrapper,
|
|
|
|
[MAPIStoreAppointmentWrapper wrapperWithICalEvent: event
|
2012-01-29 20:55:21 +01:00
|
|
|
andUser: [userContext sogoUser]
|
2011-10-12 22:00:46 +02:00
|
|
|
andSenderEmail: nil
|
2011-11-17 17:15:38 +01:00
|
|
|
inTimeZone: [self ownerTimeZone]
|
|
|
|
withConnectionInfo: [context connectionInfo]]);
|
2011-07-21 17:05:17 +02:00
|
|
|
}
|
2011-04-13 21:59:04 +02:00
|
|
|
|
2011-07-21 17:05:17 +02:00
|
|
|
return appointmentWrapper;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* getters */
|
2012-03-02 21:44:24 +01:00
|
|
|
- (int) getPidTagIconIndex: (void **) data
|
|
|
|
inMemCtx: (TALLOC_CTX *) memCtx
|
2011-07-21 17:05:17 +02:00
|
|
|
{
|
2012-03-02 21:44:24 +01:00
|
|
|
return [[self appointmentWrapper] getPidTagIconIndex: data inMemCtx: memCtx];
|
2011-04-13 21:59:04 +02:00
|
|
|
}
|
|
|
|
|
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) getPidTagMessageClass: (void **) data
|
|
|
|
inMemCtx: (TALLOC_CTX *) memCtx
|
2011-04-13 21:59:04 +02:00
|
|
|
{
|
2011-10-03 22:55:02 +02:00
|
|
|
*data = talloc_strdup (memCtx, "IPM.Appointment");
|
|
|
|
|
|
|
|
return MAPISTORE_SUCCESS;
|
2011-04-13 21:59:04 +02:00
|
|
|
}
|
|
|
|
|
2012-03-12 01:06:06 +01:00
|
|
|
- (int) getPidLidAppointmentMessageClass: (void **) data
|
|
|
|
inMemCtx: (TALLOC_CTX *) memCtx
|
|
|
|
{
|
|
|
|
*data = talloc_strdup (memCtx, "IPM.Appointment");
|
|
|
|
|
|
|
|
return MAPISTORE_SUCCESS;
|
|
|
|
}
|
|
|
|
|
2012-03-02 21:44:24 +01:00
|
|
|
- (int) getPidTagOwnerAppointmentId: (void **) data
|
|
|
|
inMemCtx: (TALLOC_CTX *) memCtx
|
2011-08-08 21:02:49 +02:00
|
|
|
{
|
2012-03-02 21:44:24 +01:00
|
|
|
return [[self appointmentWrapper] getPidTagOwnerAppointmentId: data inMemCtx: memCtx];
|
2011-08-08 21:02:49 +02:00
|
|
|
}
|
|
|
|
|
2012-03-02 21:44:24 +01:00
|
|
|
- (int) getPidTagStartDate: (void **) data
|
|
|
|
inMemCtx: (TALLOC_CTX *) memCtx
|
2011-04-13 21:59:04 +02:00
|
|
|
{
|
2012-03-02 21:44:24 +01:00
|
|
|
return [[self appointmentWrapper] getPidTagStartDate: data inMemCtx: memCtx];
|
2011-04-13 21:59:04 +02:00
|
|
|
}
|
|
|
|
|
2011-08-08 21:02:49 +02:00
|
|
|
- (int) getPidLidAppointmentStateFlags: (void **) data
|
|
|
|
inMemCtx: (TALLOC_CTX *) memCtx
|
|
|
|
{
|
|
|
|
return [[self appointmentWrapper] getPidLidAppointmentStateFlags: data inMemCtx: memCtx];
|
|
|
|
}
|
|
|
|
|
2011-10-03 22:55:02 +02:00
|
|
|
- (int) getPidLidResponseStatus: (void **) data
|
|
|
|
inMemCtx: (TALLOC_CTX *) memCtx
|
|
|
|
{
|
|
|
|
return [[self appointmentWrapper] getPidLidResponseStatus: data
|
|
|
|
inMemCtx: memCtx];
|
|
|
|
}
|
|
|
|
|
2011-04-13 21:59:04 +02:00
|
|
|
- (int) getPidLidAppointmentStartWhole: (void **) data
|
2011-07-11 23:40:47 +02:00
|
|
|
inMemCtx: (TALLOC_CTX *) memCtx
|
2011-04-13 21:59:04 +02:00
|
|
|
{
|
2011-07-21 17:05:17 +02:00
|
|
|
return [[self appointmentWrapper] getPidLidAppointmentStartWhole: data inMemCtx: memCtx];
|
2011-04-13 21:59:04 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
- (int) getPidLidCommonStart: (void **) data
|
2011-07-11 23:40:47 +02:00
|
|
|
inMemCtx: (TALLOC_CTX *) memCtx
|
2011-04-13 21:59:04 +02:00
|
|
|
{
|
2011-07-21 17:05:17 +02:00
|
|
|
return [[self appointmentWrapper] getPidLidCommonStart: data inMemCtx: memCtx];
|
2011-04-13 21:59:04 +02:00
|
|
|
}
|
|
|
|
|
2012-03-02 21:44:24 +01:00
|
|
|
- (int) getPidTagEndDate: (void **) data
|
|
|
|
inMemCtx: (TALLOC_CTX *) memCtx
|
2011-04-13 21:59:04 +02:00
|
|
|
{
|
2012-03-02 21:44:24 +01:00
|
|
|
return [[self appointmentWrapper] getPidTagEndDate: data inMemCtx: memCtx];
|
2011-04-13 21:59:04 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
- (int) getPidLidAppointmentEndWhole: (void **) data
|
2011-07-11 23:40:47 +02:00
|
|
|
inMemCtx: (TALLOC_CTX *) memCtx
|
2011-04-13 21:59:04 +02:00
|
|
|
{
|
2011-07-21 17:05:17 +02:00
|
|
|
return [[self appointmentWrapper] getPidLidAppointmentEndWhole: data inMemCtx: memCtx];
|
2011-04-13 21:59:04 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
- (int) getPidLidCommonEnd: (void **) data
|
2011-07-11 23:40:47 +02:00
|
|
|
inMemCtx: (TALLOC_CTX *) memCtx
|
2011-04-13 21:59:04 +02:00
|
|
|
{
|
2011-07-21 17:05:17 +02:00
|
|
|
return [[self appointmentWrapper] getPidLidCommonEnd: data inMemCtx: memCtx];
|
2011-04-13 21:59:04 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
- (int) getPidLidAppointmentDuration: (void **) data
|
2011-07-11 23:40:47 +02:00
|
|
|
inMemCtx: (TALLOC_CTX *) memCtx
|
2011-04-13 21:59:04 +02:00
|
|
|
{
|
2011-07-21 17:05:17 +02:00
|
|
|
return [[self appointmentWrapper] getPidLidAppointmentDuration: data inMemCtx: memCtx];
|
2011-04-13 21:59:04 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
- (int) getPidLidAppointmentSubType: (void **) data
|
2011-07-11 23:40:47 +02:00
|
|
|
inMemCtx: (TALLOC_CTX *) memCtx
|
2011-04-13 21:59:04 +02:00
|
|
|
{
|
2012-01-12 17:06:57 +01:00
|
|
|
return [[self appointmentWrapper] getPidLidAppointmentSubType: data
|
|
|
|
inMemCtx: memCtx];
|
2011-04-13 21:59:04 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
- (int) getPidLidBusyStatus: (void **) data // TODO
|
2011-07-11 23:40:47 +02:00
|
|
|
inMemCtx: (TALLOC_CTX *) memCtx
|
2011-04-13 21:59:04 +02:00
|
|
|
{
|
2011-07-21 17:05:17 +02:00
|
|
|
return [[self appointmentWrapper] getPidLidBusyStatus: data inMemCtx: memCtx];
|
2011-04-13 21:59:04 +02:00
|
|
|
}
|
2011-02-24 21:30:01 +01:00
|
|
|
|
2012-03-02 21:44:24 +01:00
|
|
|
- (int) getPidTagSubject: (void **) data // SUMMARY
|
|
|
|
inMemCtx: (TALLOC_CTX *) memCtx
|
2011-04-13 21:59:04 +02:00
|
|
|
{
|
2012-03-02 21:44:24 +01:00
|
|
|
return [[self appointmentWrapper] getPidTagSubject: data inMemCtx: memCtx];
|
2011-04-13 21:59:04 +02:00
|
|
|
}
|
|
|
|
|
2012-03-12 01:06:06 +01:00
|
|
|
- (int) getPidLidSideEffects: (void **) data // TODO
|
|
|
|
inMemCtx: (TALLOC_CTX *) memCtx
|
|
|
|
{
|
|
|
|
*data = MAPILongValue (memCtx,
|
|
|
|
seOpenToDelete | seOpenToCopy | seOpenToMove
|
|
|
|
| seCoerceToInbox | seOpenForCtxMenu);
|
|
|
|
|
|
|
|
return MAPISTORE_SUCCESS;
|
|
|
|
}
|
|
|
|
|
2011-04-13 21:59:04 +02:00
|
|
|
- (int) getPidLidLocation: (void **) data // LOCATION
|
2011-07-11 23:40:47 +02:00
|
|
|
inMemCtx: (TALLOC_CTX *) memCtx
|
2011-04-13 21:59:04 +02:00
|
|
|
{
|
2011-07-21 17:05:17 +02:00
|
|
|
return [[self appointmentWrapper] getPidLidLocation: data inMemCtx: memCtx];
|
2011-04-13 21:59:04 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
- (int) getPidLidPrivate: (void **) data // private (bool), should depend on CLASS and permissions
|
2011-07-11 23:40:47 +02:00
|
|
|
inMemCtx: (TALLOC_CTX *) memCtx
|
2011-04-13 21:59:04 +02:00
|
|
|
{
|
2011-07-21 17:05:17 +02:00
|
|
|
return [[self appointmentWrapper] getPidLidPrivate: data inMemCtx: memCtx];
|
2011-04-13 21:59:04 +02:00
|
|
|
}
|
|
|
|
|
2012-03-02 21:44:24 +01:00
|
|
|
- (int) getPidTagSensitivity: (void **) data // not implemented, depends on CLASS
|
|
|
|
inMemCtx: (TALLOC_CTX *) memCtx
|
2011-04-13 21:59:04 +02:00
|
|
|
{
|
2012-03-02 21:44:24 +01:00
|
|
|
return [[self appointmentWrapper] getPidTagSensitivity: data inMemCtx: memCtx];
|
2011-04-13 21:59:04 +02:00
|
|
|
}
|
|
|
|
|
2012-03-02 21:44:24 +01:00
|
|
|
- (int) getPidTagImportance: (void **) data
|
|
|
|
inMemCtx: (TALLOC_CTX *) memCtx
|
2011-04-13 21:59:04 +02:00
|
|
|
{
|
2012-03-02 21:44:24 +01:00
|
|
|
return [[self appointmentWrapper] getPidTagImportance: data inMemCtx: memCtx];
|
2011-04-13 21:59:04 +02:00
|
|
|
}
|
|
|
|
|
2012-03-02 21:44:24 +01:00
|
|
|
- (int) getPidTagBody: (void **) data
|
|
|
|
inMemCtx: (TALLOC_CTX *) memCtx
|
2011-11-09 21:47:08 +01:00
|
|
|
{
|
2012-03-02 21:44:24 +01:00
|
|
|
return [[self appointmentWrapper] getPidTagBody: data inMemCtx: memCtx];
|
2011-11-09 21:47:08 +01:00
|
|
|
}
|
|
|
|
|
2011-04-13 21:59:04 +02:00
|
|
|
- (int) getPidLidIsRecurring: (void **) data
|
2011-07-11 23:40:47 +02:00
|
|
|
inMemCtx: (TALLOC_CTX *) memCtx
|
2011-04-13 21:59:04 +02:00
|
|
|
{
|
2011-07-21 17:05:17 +02:00
|
|
|
return [[self appointmentWrapper] getPidLidIsRecurring: data inMemCtx: memCtx];
|
2011-04-13 21:59:04 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
- (int) getPidLidRecurring: (void **) data
|
2011-07-11 23:40:47 +02:00
|
|
|
inMemCtx: (TALLOC_CTX *) memCtx
|
2011-04-13 21:59:04 +02:00
|
|
|
{
|
2011-07-21 17:05:17 +02:00
|
|
|
return [[self appointmentWrapper] getPidLidRecurring: data inMemCtx: memCtx];
|
2011-04-13 21:59:04 +02:00
|
|
|
}
|
|
|
|
|
2011-07-21 17:05:17 +02:00
|
|
|
- (int) getPidLidAppointmentRecur: (void **) data
|
|
|
|
inMemCtx: (TALLOC_CTX *) memCtx
|
2011-07-19 23:47:01 +02:00
|
|
|
{
|
2011-07-21 17:05:17 +02:00
|
|
|
return [[self appointmentWrapper] getPidLidAppointmentRecur: data
|
|
|
|
inMemCtx: memCtx];
|
2011-07-19 23:47:01 +02:00
|
|
|
}
|
|
|
|
|
2011-07-21 17:05:17 +02:00
|
|
|
- (int) getPidLidGlobalObjectId: (void **) data
|
|
|
|
inMemCtx: (TALLOC_CTX *) memCtx
|
2011-07-19 23:47:01 +02:00
|
|
|
{
|
2011-07-21 17:05:17 +02:00
|
|
|
return [[self appointmentWrapper] getPidLidGlobalObjectId: data
|
|
|
|
inMemCtx: memCtx];
|
2011-07-19 23:47:01 +02:00
|
|
|
}
|
|
|
|
|
2011-07-21 17:05:17 +02:00
|
|
|
- (int) getPidLidCleanGlobalObjectId: (void **) data
|
|
|
|
inMemCtx: (TALLOC_CTX *) memCtx
|
2011-04-13 21:59:04 +02:00
|
|
|
{
|
2011-07-21 17:05:17 +02:00
|
|
|
return [[self appointmentWrapper] getPidLidCleanGlobalObjectId: data
|
|
|
|
inMemCtx: memCtx];
|
2011-02-24 21:30:01 +01:00
|
|
|
}
|
|
|
|
|
2012-03-02 21:44:24 +01:00
|
|
|
- (int) getPidTagProcessed: (void **) data inMemCtx: (TALLOC_CTX *) memCtx
|
2011-10-03 22:55:02 +02:00
|
|
|
{
|
|
|
|
return [self getYes: data inMemCtx: memCtx];
|
|
|
|
}
|
|
|
|
|
|
|
|
- (int) getPidLidServerProcessed: (void **) data inMemCtx: (TALLOC_CTX *) memCtx
|
|
|
|
{
|
|
|
|
return [[self appointmentWrapper] getPidLidServerProcessed: data
|
|
|
|
inMemCtx: memCtx];
|
|
|
|
}
|
|
|
|
|
|
|
|
- (int) getPidLidServerProcessingActions: (void **) data inMemCtx: (TALLOC_CTX *) memCtx
|
|
|
|
{
|
|
|
|
return [[self appointmentWrapper] getPidLidServerProcessingActions: data
|
|
|
|
inMemCtx: memCtx];
|
|
|
|
}
|
|
|
|
|
|
|
|
- (int) getPidLidAppointmentReplyTime: (void **) data inMemCtx: (TALLOC_CTX *) memCtx
|
|
|
|
{
|
|
|
|
return [[self appointmentWrapper] getPidLidAppointmentReplyTime: data
|
|
|
|
inMemCtx: memCtx];
|
|
|
|
}
|
|
|
|
|
2011-07-13 23:41:58 +02:00
|
|
|
- (void) getMessageData: (struct mapistore_message **) dataPtr
|
|
|
|
inMemCtx: (TALLOC_CTX *) memCtx
|
2011-02-24 21:30:01 +01:00
|
|
|
{
|
2011-07-13 23:41:58 +02:00
|
|
|
struct mapistore_message *msgData;
|
2011-02-24 21:30:01 +01:00
|
|
|
|
2011-07-13 23:41:58 +02:00
|
|
|
[super getMessageData: &msgData inMemCtx: memCtx];
|
2011-09-30 22:01:50 +02:00
|
|
|
[[self appointmentWrapper] fillMessageData: msgData
|
|
|
|
inMemCtx: memCtx];
|
2011-07-13 23:41:58 +02:00
|
|
|
*dataPtr = msgData;
|
2011-02-24 21:30:01 +01:00
|
|
|
}
|
|
|
|
|
2011-10-03 22:55:02 +02:00
|
|
|
/* sender */
|
2012-03-02 21:44:24 +01:00
|
|
|
- (int) getPidTagSenderEmailAddress: (void **) data
|
|
|
|
inMemCtx: (TALLOC_CTX *) memCtx
|
2011-10-03 22:55:02 +02:00
|
|
|
{
|
2012-03-02 21:44:24 +01:00
|
|
|
return [[self appointmentWrapper] getPidTagSenderEmailAddress: data
|
|
|
|
inMemCtx: memCtx];
|
2011-10-03 22:55:02 +02:00
|
|
|
}
|
|
|
|
|
2012-03-02 21:44:24 +01:00
|
|
|
- (int) getPidTagSenderAddressType: (void **) data
|
|
|
|
inMemCtx: (TALLOC_CTX *) memCtx
|
2011-10-03 22:55:02 +02:00
|
|
|
{
|
2012-03-02 21:44:24 +01:00
|
|
|
return [[self appointmentWrapper] getPidTagSenderAddressType: data
|
|
|
|
inMemCtx: memCtx];
|
2011-10-03 22:55:02 +02:00
|
|
|
}
|
|
|
|
|
2012-03-02 21:44:24 +01:00
|
|
|
- (int) getPidTagSenderName: (void **) data
|
|
|
|
inMemCtx: (TALLOC_CTX *) memCtx
|
2011-10-03 22:55:02 +02:00
|
|
|
{
|
2012-03-02 21:44:24 +01:00
|
|
|
return [[self appointmentWrapper] getPidTagSenderName: data
|
|
|
|
inMemCtx: memCtx];
|
2011-10-03 22:55:02 +02:00
|
|
|
}
|
|
|
|
|
2012-03-02 21:44:24 +01:00
|
|
|
- (int) getPidTagSenderEntryId: (void **) data inMemCtx: (TALLOC_CTX *) memCtx
|
2011-10-03 22:55:02 +02:00
|
|
|
{
|
2012-03-02 21:44:24 +01:00
|
|
|
return [[self appointmentWrapper] getPidTagSenderEntryId: data
|
|
|
|
inMemCtx: memCtx];
|
2011-10-03 22:55:02 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/* sender representing */
|
2012-03-02 21:44:24 +01:00
|
|
|
- (int) getPidTagSentRepresentingEmailAddress: (void **) data
|
|
|
|
inMemCtx: (TALLOC_CTX *) memCtx
|
2011-10-03 22:55:02 +02:00
|
|
|
{
|
2012-03-02 21:44:24 +01:00
|
|
|
return [self getPidTagSenderEmailAddress: data inMemCtx: memCtx];
|
2011-10-03 22:55:02 +02:00
|
|
|
}
|
|
|
|
|
2012-03-02 21:44:24 +01:00
|
|
|
- (int) getPidTagSentRepresentingAddressType: (void **) data
|
|
|
|
inMemCtx: (TALLOC_CTX *) memCtx
|
2011-10-03 22:55:02 +02:00
|
|
|
{
|
|
|
|
return [self getSMTPAddrType: data inMemCtx: memCtx];
|
|
|
|
}
|
|
|
|
|
2012-03-02 21:44:24 +01:00
|
|
|
- (int) getPidTagSentRepresentingName: (void **) data
|
|
|
|
inMemCtx: (TALLOC_CTX *) memCtx
|
2011-10-03 22:55:02 +02:00
|
|
|
{
|
2012-03-02 21:44:24 +01:00
|
|
|
return [self getPidTagSenderName: data inMemCtx: memCtx];
|
2011-10-03 22:55:02 +02:00
|
|
|
}
|
|
|
|
|
2012-03-02 21:44:24 +01:00
|
|
|
- (int) getPidTagSentRepresentingEntryId: (void **) data
|
|
|
|
inMemCtx: (TALLOC_CTX *) memCtx
|
2011-10-03 22:55:02 +02:00
|
|
|
{
|
2012-03-02 21:44:24 +01:00
|
|
|
return [self getPidTagSenderEntryId: data inMemCtx: memCtx];
|
2011-10-03 22:55:02 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/* attendee */
|
2012-03-02 21:44:24 +01:00
|
|
|
// - (int) getPidTagReceivedByAddressType: (void **) data
|
2011-10-03 22:55:02 +02:00
|
|
|
// inMemCtx: (TALLOC_CTX *) memCtx
|
|
|
|
// {
|
2012-03-02 21:44:24 +01:00
|
|
|
// return [[self appointmentWrapper] getPidTagReceivedByAddressType: data
|
2011-10-03 22:55:02 +02:00
|
|
|
// inMemCtx: memCtx];
|
|
|
|
// }
|
|
|
|
|
2012-03-02 21:44:24 +01:00
|
|
|
// - (int) getPidTagReceivedByEmailAddress: (void **) data
|
2011-10-03 22:55:02 +02:00
|
|
|
// inMemCtx: (TALLOC_CTX *) memCtx
|
|
|
|
// {
|
2012-03-02 21:44:24 +01:00
|
|
|
// return [[self appointmentWrapper] getPidTagReceivedByEmailAddress: data
|
2011-10-03 22:55:02 +02:00
|
|
|
// 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
|
|
|
|
// {
|
2012-03-02 21:44:24 +01:00
|
|
|
// return [[self appointmentWrapper] getPidTagReceivedByName: data
|
2011-10-03 22:55:02 +02:00
|
|
|
// 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 appointmentWrapper] getPidTagReceivedByEntryId: data
|
2011-10-03 22:55:02 +02:00
|
|
|
// inMemCtx: memCtx];
|
|
|
|
// }
|
|
|
|
|
|
|
|
// /* attendee representing */
|
2012-03-02 21:44:24 +01:00
|
|
|
// - (int) getPidTagReceivedRepresentingEmailAddress: (void **) data
|
2011-10-03 22:55:02 +02:00
|
|
|
// inMemCtx: (TALLOC_CTX *) memCtx
|
|
|
|
// {
|
2012-03-02 21:44:24 +01:00
|
|
|
// return [self getPidTagReceivedByEmailAddress: data inMemCtx: memCtx];
|
2011-10-03 22:55:02 +02:00
|
|
|
// }
|
|
|
|
|
2012-03-02 21:44:24 +01:00
|
|
|
// - (int) getPidTagReceivedRepresentingAddressType: (void **) data
|
2011-10-03 22:55:02 +02:00
|
|
|
// inMemCtx: (TALLOC_CTX *) memCtx
|
|
|
|
// {
|
|
|
|
// return [self getSMTPAddrType: data inMemCtx: memCtx];
|
|
|
|
// }
|
|
|
|
|
2012-03-02 21:44:24 +01:00
|
|
|
// - (int) getPidTagReceivedRepresentingName: (void **) data
|
2011-10-03 22:55:02 +02:00
|
|
|
// inMemCtx: (TALLOC_CTX *) memCtx
|
|
|
|
// {
|
2012-03-02 21:44:24 +01:00
|
|
|
// return [self getPidTagReceivedByName: data inMemCtx: memCtx];
|
2011-10-03 22:55:02 +02:00
|
|
|
// }
|
|
|
|
|
2012-03-02 21:44:24 +01:00
|
|
|
// - (int) getPidTagReceivedRepresentingEntryId: (void **) data
|
2011-10-03 22:55:02 +02:00
|
|
|
// inMemCtx: (TALLOC_CTX *) memCtx
|
|
|
|
// {
|
2012-03-02 21:44:24 +01:00
|
|
|
// return [self getPidTagReceivedByEntryId: data inMemCtx: memCtx];
|
2011-10-03 22:55:02 +02:00
|
|
|
// }
|
|
|
|
|
2012-03-02 21:44:24 +01:00
|
|
|
- (int) getPidTagResponseRequested: (void **) data
|
|
|
|
inMemCtx: (TALLOC_CTX *) memCtx
|
2011-10-03 22:55:02 +02:00
|
|
|
{
|
|
|
|
return [self getYes: data inMemCtx: memCtx];
|
|
|
|
}
|
|
|
|
|
2011-10-11 21:46:02 +02:00
|
|
|
/* alarms */
|
|
|
|
- (int) getPidLidReminderSet: (void **) data
|
|
|
|
inMemCtx: (TALLOC_CTX *) memCtx
|
|
|
|
{
|
|
|
|
return [[self appointmentWrapper] getPidLidReminderSet: data
|
|
|
|
inMemCtx: memCtx];
|
|
|
|
}
|
|
|
|
|
|
|
|
- (int) getPidLidReminderDelta: (void **) data
|
|
|
|
inMemCtx: (TALLOC_CTX *) memCtx
|
|
|
|
{
|
|
|
|
return [[self appointmentWrapper] getPidLidReminderDelta: data
|
|
|
|
inMemCtx: memCtx];
|
|
|
|
}
|
|
|
|
|
|
|
|
- (int) getPidLidReminderTime: (void **) data
|
|
|
|
inMemCtx: (TALLOC_CTX *) memCtx
|
|
|
|
{
|
|
|
|
return [[self appointmentWrapper] getPidLidReminderTime: data
|
|
|
|
inMemCtx: memCtx];
|
|
|
|
}
|
|
|
|
|
|
|
|
- (int) getPidLidReminderSignalTime: (void **) data
|
|
|
|
inMemCtx: (TALLOC_CTX *) memCtx
|
|
|
|
{
|
|
|
|
return [[self appointmentWrapper] getPidLidReminderSignalTime: data
|
|
|
|
inMemCtx: memCtx];
|
|
|
|
}
|
|
|
|
|
|
|
|
- (int) getPidLidReminderOverride: (void **) data
|
|
|
|
inMemCtx: (TALLOC_CTX *) memCtx
|
|
|
|
{
|
|
|
|
return [[self appointmentWrapper] getPidLidReminderOverride: data
|
|
|
|
inMemCtx: memCtx];
|
|
|
|
}
|
|
|
|
|
|
|
|
- (int) getPidLidReminderType: (void **) data
|
|
|
|
inMemCtx: (TALLOC_CTX *) memCtx
|
|
|
|
{
|
|
|
|
return [[self appointmentWrapper] getPidLidReminderType: data
|
|
|
|
inMemCtx: memCtx];
|
|
|
|
}
|
|
|
|
|
|
|
|
- (int) getPidLidReminderPlaySound: (void **) data
|
|
|
|
inMemCtx: (TALLOC_CTX *) memCtx
|
|
|
|
{
|
|
|
|
return [[self appointmentWrapper] getPidLidReminderPlaySound: data
|
|
|
|
inMemCtx: memCtx];
|
|
|
|
}
|
|
|
|
|
|
|
|
- (int) getPidLidReminderFileParameter: (void **) data
|
|
|
|
inMemCtx: (TALLOC_CTX *) memCtx
|
|
|
|
{
|
|
|
|
return [[self appointmentWrapper] getPidLidReminderFileParameter: data
|
|
|
|
inMemCtx: memCtx];
|
|
|
|
}
|
|
|
|
|
2011-10-03 22:55:02 +02:00
|
|
|
/* attendee */
|
2011-07-19 23:47:01 +02:00
|
|
|
- (void) _setupRecurrenceInCalendar: (iCalCalendar *) calendar
|
2011-09-23 20:16:46 +02:00
|
|
|
withEvent: (iCalEvent *) event
|
2011-07-19 23:47:01 +02:00
|
|
|
fromData: (NSData *) mapiRecurrenceData
|
|
|
|
{
|
|
|
|
struct Binary_r *blob;
|
|
|
|
struct AppointmentRecurrencePattern *pattern;
|
|
|
|
NSMutableArray *otherEvents;
|
|
|
|
|
|
|
|
/* cleanup */
|
|
|
|
otherEvents = [[calendar events] mutableCopy];
|
|
|
|
[otherEvents removeObject: event];
|
|
|
|
[calendar removeChildren: otherEvents];
|
|
|
|
[otherEvents release];
|
|
|
|
|
|
|
|
blob = [mapiRecurrenceData asBinaryInMemCtx: NULL];
|
|
|
|
pattern = get_AppointmentRecurrencePattern (blob, blob);
|
|
|
|
[calendar setupRecurrenceWithMasterEntity: event
|
|
|
|
fromRecurrencePattern: &pattern->RecurrencePattern];
|
|
|
|
talloc_free (blob);
|
|
|
|
}
|
|
|
|
|
2011-10-03 22:55:02 +02:00
|
|
|
- (NSString *) _uidFromGlobalObjectId
|
|
|
|
{
|
|
|
|
NSData *objectId;
|
|
|
|
NSString *uid = nil;
|
|
|
|
char *bytesDup, *uidStart;
|
|
|
|
NSUInteger length;
|
|
|
|
|
|
|
|
/* NOTE: we only handle the generic case at the moment, see
|
|
|
|
MAPIStoreAppointmentWrapper */
|
2011-10-26 17:15:17 +02:00
|
|
|
objectId = [properties objectForKey: MAPIPropertyKey (PidLidGlobalObjectId)];
|
2011-10-03 22:55:02 +02:00
|
|
|
if (objectId)
|
|
|
|
{
|
|
|
|
length = [objectId length];
|
|
|
|
bytesDup = talloc_array (NULL, char, length + 1);
|
|
|
|
memcpy (bytesDup, [objectId bytes], length);
|
|
|
|
bytesDup[length] = 0;
|
|
|
|
uidStart = bytesDup + length - 1;
|
|
|
|
while (uidStart != bytesDup && *(uidStart - 1))
|
|
|
|
uidStart--;
|
|
|
|
if (uidStart > bytesDup && *uidStart)
|
|
|
|
uid = [NSString stringWithUTF8String: uidStart];
|
|
|
|
talloc_free (bytesDup);
|
|
|
|
}
|
|
|
|
|
|
|
|
return uid;
|
|
|
|
}
|
|
|
|
|
2012-03-12 01:06:06 +01:00
|
|
|
- (void) _fixupAppointmentObjectWithUID: (NSString *) uid
|
2011-10-03 22:55:02 +02:00
|
|
|
{
|
2012-03-12 01:06:06 +01:00
|
|
|
NSString *cname, *url;
|
2011-10-03 22:55:02 +02:00
|
|
|
MAPIStoreMapping *mapping;
|
|
|
|
uint64_t objectId;
|
2012-03-12 01:06:06 +01:00
|
|
|
SOGoAppointmentFolder *folder;
|
|
|
|
SOGoAppointmentObject *newObject;
|
2011-10-03 22:55:02 +02:00
|
|
|
WOContext *woContext;
|
|
|
|
|
2012-03-12 01:06:06 +01:00
|
|
|
cname = [[container sogoObject] resourceNameForEventUID: uid];
|
|
|
|
if (cname)
|
|
|
|
isNew = NO;
|
|
|
|
else
|
|
|
|
cname = [NSString stringWithFormat: @"%@.ics", uid];
|
2011-10-03 22:55:02 +02:00
|
|
|
|
2012-03-12 01:06:06 +01:00
|
|
|
mapping = [self mapping];
|
|
|
|
|
|
|
|
url = [NSString stringWithFormat: @"%@%@", [container url], cname];
|
|
|
|
folder = [container sogoObject];
|
|
|
|
/* reinstantiate the old sogo object and attach it to self */
|
|
|
|
woContext = [[self userContext] woContext];
|
|
|
|
if (isNew)
|
|
|
|
newObject = [SOGoAppointmentObject objectWithName: cname
|
|
|
|
inContainer: folder];
|
|
|
|
else
|
|
|
|
{
|
2011-10-04 01:13:00 +02:00
|
|
|
/* dissociate the object url from the old object's id */
|
2012-03-12 01:06:06 +01:00
|
|
|
objectId = [mapping idFromURL: url];
|
2011-10-03 22:55:02 +02:00
|
|
|
[mapping unregisterURLWithID: objectId];
|
2012-03-12 01:06:06 +01:00
|
|
|
newObject = [folder lookupName: cname
|
|
|
|
inContext: woContext
|
|
|
|
acquire: NO];
|
|
|
|
}
|
2011-10-03 22:55:02 +02:00
|
|
|
|
2012-03-12 01:06:06 +01:00
|
|
|
/* dissociate the object url associated with this object, as we want to
|
|
|
|
discard it */
|
|
|
|
objectId = [self objectId];
|
|
|
|
[mapping unregisterURLWithID: objectId];
|
2011-10-04 01:13:00 +02:00
|
|
|
|
2012-03-12 01:06:06 +01:00
|
|
|
/* associate the new object url with this object id */
|
|
|
|
[mapping registerURL: url withID: objectId];
|
|
|
|
|
|
|
|
[newObject setContext: woContext];
|
|
|
|
ASSIGN (sogoObject, newObject);
|
2011-10-03 22:55:02 +02:00
|
|
|
}
|
|
|
|
|
2011-10-11 21:46:02 +02:00
|
|
|
- (void) _setupAlarmDataInEvent: (iCalEvent *) newEvent
|
|
|
|
{
|
|
|
|
NSArray *alarms;
|
|
|
|
iCalAlarm *currentAlarm, *alarm = nil;
|
|
|
|
iCalTrigger *trigger;
|
|
|
|
NSNumber *delta;
|
|
|
|
NSString *action;
|
|
|
|
NSUInteger count, max;
|
|
|
|
|
|
|
|
/* find and remove first display alarm */
|
|
|
|
alarms = [newEvent alarms];
|
|
|
|
max = [alarms count];
|
|
|
|
for (count = 0; !alarm && count < max; count++)
|
|
|
|
{
|
|
|
|
currentAlarm = [alarms objectAtIndex: count];
|
|
|
|
action = [[currentAlarm action] lowercaseString];
|
|
|
|
if (!action || [action isEqualToString: @"display"])
|
|
|
|
alarm = currentAlarm;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (alarm)
|
|
|
|
[newEvent removeChild: alarm];
|
|
|
|
|
2011-10-26 17:15:17 +02:00
|
|
|
if ([[properties objectForKey: MAPIPropertyKey (PidLidReminderSet)]
|
2011-10-11 21:46:02 +02:00
|
|
|
boolValue])
|
|
|
|
{
|
2011-10-26 17:15:17 +02:00
|
|
|
delta
|
|
|
|
= [properties objectForKey: MAPIPropertyKey (PidLidReminderDelta)];
|
2011-10-11 21:46:02 +02:00
|
|
|
if (delta)
|
|
|
|
{
|
|
|
|
alarm = [iCalAlarm new];
|
|
|
|
[alarm setAction: @"DISPLAY"];
|
|
|
|
trigger = [iCalTrigger elementWithTag: @"trigger"];
|
|
|
|
[trigger setValueType: @"DURATION"];
|
2011-11-14 04:26:50 +01:00
|
|
|
[trigger
|
|
|
|
setSingleValue: [NSString stringWithFormat: @"-PT%@M", delta]
|
|
|
|
forKey: @""];
|
2011-10-11 21:46:02 +02:00
|
|
|
[alarm setTrigger: trigger];
|
|
|
|
[newEvent addToAlarms: alarm];
|
|
|
|
[alarm release];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-12-01 22:13:09 +01:00
|
|
|
- (BOOL) subscriberCanReadMessage
|
|
|
|
{
|
2012-02-14 15:33:17 +01:00
|
|
|
NSArray *roles;
|
|
|
|
|
|
|
|
roles = [self activeUserRoles];
|
|
|
|
|
|
|
|
return ([roles containsObject: SOGoCalendarRole_ComponentViewer]
|
|
|
|
|| [roles containsObject: SOGoCalendarRole_ComponentDAndTViewer]
|
2011-12-01 22:13:09 +01:00
|
|
|
|| [self subscriberCanModifyMessage]);
|
|
|
|
}
|
|
|
|
|
|
|
|
- (BOOL) subscriberCanModifyMessage
|
|
|
|
{
|
|
|
|
BOOL rc;
|
|
|
|
NSArray *roles = [self activeUserRoles];
|
|
|
|
|
|
|
|
if (isNew)
|
|
|
|
rc = [roles containsObject: SOGoRole_ObjectCreator];
|
|
|
|
else
|
|
|
|
rc = ([roles containsObject: SOGoCalendarRole_ComponentModifier]
|
|
|
|
|| [roles containsObject: SOGoCalendarRole_ComponentResponder]);
|
|
|
|
|
|
|
|
return rc;
|
|
|
|
}
|
|
|
|
|
2011-02-24 21:30:01 +01:00
|
|
|
- (void) save
|
|
|
|
{
|
|
|
|
iCalCalendar *vCalendar;
|
2011-11-02 13:43:36 +01:00
|
|
|
BOOL isAllDay;
|
2011-02-24 21:30:01 +01:00
|
|
|
iCalDateTime *start, *end;
|
2011-03-22 22:28:16 +01:00
|
|
|
iCalTimeZone *tz;
|
|
|
|
NSCalendarDate *now;
|
2012-03-12 01:06:06 +01:00
|
|
|
NSString *uid, *content, *tzName, *priority, *newParticipationStatus = nil;
|
2011-04-13 21:59:04 +02:00
|
|
|
iCalEvent *newEvent;
|
2012-03-12 01:06:06 +01:00
|
|
|
// iCalPerson *userPerson;
|
2011-07-21 17:05:17 +02:00
|
|
|
NSUInteger responseStatus = 0;
|
2012-01-12 17:06:57 +01:00
|
|
|
NSInteger tzOffset;
|
2011-12-01 23:30:25 +01:00
|
|
|
SOGoUser *activeUser, *ownerUser;
|
2011-03-22 22:28:16 +01:00
|
|
|
id value;
|
2011-02-24 21:30:01 +01:00
|
|
|
|
2011-10-03 22:55:02 +02:00
|
|
|
if (isNew)
|
|
|
|
{
|
2012-03-12 01:06:06 +01:00
|
|
|
uid = [self _uidFromGlobalObjectId];
|
|
|
|
if (uid)
|
|
|
|
{
|
|
|
|
/* Hack required because of what's explained in oxocal 3.1.4.7.1:
|
|
|
|
basically, Outlook creates a copy of the event and then removes the
|
|
|
|
old instance. We perform a trickery to avoid performing those
|
|
|
|
operations in the backend, in a way that enables us to recover the
|
|
|
|
initial instance and act solely on it. */
|
|
|
|
[self _fixupAppointmentObjectWithUID: uid];
|
|
|
|
}
|
|
|
|
else
|
|
|
|
uid = [SOGoObject globallyUniqueObjectId];
|
2011-10-03 22:55:02 +02:00
|
|
|
}
|
|
|
|
|
2011-02-24 21:30:01 +01:00
|
|
|
[self logWithFormat: @"-save, event props:"];
|
|
|
|
// MAPIStoreDumpMessageProperties (newProperties);
|
|
|
|
|
2011-08-08 21:02:49 +02:00
|
|
|
now = [NSCalendarDate date];
|
|
|
|
|
2011-02-24 21:30:01 +01:00
|
|
|
content = [sogoObject contentAsString];
|
|
|
|
if (![content length])
|
|
|
|
{
|
2011-04-13 21:59:04 +02:00
|
|
|
newEvent = [sogoObject component: YES secure: NO];
|
2011-06-07 02:17:46 +02:00
|
|
|
vCalendar = [newEvent parent];
|
2011-02-24 21:30:01 +01:00
|
|
|
[vCalendar setProdID: @"-//Inverse inc.//OpenChange+SOGo//EN"];
|
2011-08-08 21:02:49 +02:00
|
|
|
[newEvent setCreated: now];
|
2012-03-12 01:06:06 +01:00
|
|
|
[newEvent setUid: uid];
|
|
|
|
content = [vCalendar versitString];
|
2011-02-24 21:30:01 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
vCalendar = [iCalCalendar parseSingleFromSource: content];
|
2011-04-13 21:59:04 +02:00
|
|
|
newEvent = [[vCalendar events] objectAtIndex: 0];
|
2011-08-08 21:02:49 +02:00
|
|
|
[newEvent setTimeStampAsDate: now];
|
2012-03-12 01:06:06 +01:00
|
|
|
[newEvent setLastModified: now];
|
2011-02-24 21:30:01 +01:00
|
|
|
|
2012-03-12 01:06:06 +01:00
|
|
|
// summary
|
|
|
|
value = [properties
|
|
|
|
objectForKey: MAPIPropertyKey (PR_NORMALIZED_SUBJECT_UNICODE)];
|
|
|
|
if (value)
|
|
|
|
[newEvent setSummary: value];
|
2011-02-24 21:30:01 +01:00
|
|
|
|
2012-03-12 01:06:06 +01:00
|
|
|
// Location
|
|
|
|
value = [properties objectForKey: MAPIPropertyKey (PidLidLocation)];
|
|
|
|
if (value)
|
|
|
|
[newEvent setLocation: value];
|
2011-08-08 21:02:49 +02:00
|
|
|
|
2012-03-12 01:06:06 +01:00
|
|
|
isAllDay = [newEvent isAllDay];
|
|
|
|
value = [properties
|
|
|
|
objectForKey: MAPIPropertyKey (PidLidAppointmentSubType)];
|
|
|
|
if (value)
|
|
|
|
isAllDay = [value boolValue];
|
|
|
|
if (!isAllDay)
|
|
|
|
{
|
|
|
|
tzName = [[self ownerTimeZone] name];
|
|
|
|
tz = [iCalTimeZone timeZoneForName: tzName];
|
|
|
|
[vCalendar addTimeZone: tz];
|
|
|
|
}
|
|
|
|
|
|
|
|
// start
|
|
|
|
value = [properties objectForKey: MAPIPropertyKey (PR_START_DATE)];
|
|
|
|
if (!value)
|
|
|
|
value = [properties
|
|
|
|
objectForKey: MAPIPropertyKey (PidLidAppointmentStartWhole)];
|
|
|
|
if (value)
|
|
|
|
{
|
|
|
|
start = (iCalDateTime *) [newEvent uniqueChildWithTag: @"dtstart"];
|
|
|
|
if (isAllDay)
|
2011-08-08 21:02:49 +02:00
|
|
|
{
|
2012-03-12 01:06:06 +01:00
|
|
|
tzOffset = [[value timeZone] secondsFromGMTForDate: value];
|
|
|
|
value = [value dateByAddingYears: 0 months: 0 days: 0
|
|
|
|
hours: 0 minutes: 0
|
|
|
|
seconds: -tzOffset];
|
|
|
|
[start setTimeZone: nil];
|
|
|
|
[start setDate: value];
|
2011-08-08 21:02:49 +02:00
|
|
|
}
|
2012-03-12 01:06:06 +01:00
|
|
|
else
|
2011-08-08 21:02:49 +02:00
|
|
|
{
|
2012-03-12 01:06:06 +01:00
|
|
|
[start setTimeZone: tz];
|
|
|
|
[start setDateTime: value];
|
2011-08-08 21:02:49 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-03-12 01:06:06 +01:00
|
|
|
/* end */
|
|
|
|
value = [properties objectForKey: MAPIPropertyKey (PR_END_DATE)];
|
|
|
|
if (!value)
|
|
|
|
value = [properties objectForKey: MAPIPropertyKey (PidLidAppointmentEndWhole)];
|
|
|
|
if (value)
|
|
|
|
{
|
|
|
|
end = (iCalDateTime *) [newEvent uniqueChildWithTag: @"dtend"];
|
|
|
|
if (isAllDay)
|
2011-11-02 19:18:32 +01:00
|
|
|
{
|
2012-03-12 01:06:06 +01:00
|
|
|
tzOffset = [[value timeZone] secondsFromGMTForDate: value];
|
|
|
|
value = [value dateByAddingYears: 0 months: 0 days: 0
|
|
|
|
hours: 0 minutes: 0
|
|
|
|
seconds: -tzOffset];
|
|
|
|
[end setTimeZone: nil];
|
|
|
|
[end setDate: value];
|
2011-11-02 19:18:32 +01:00
|
|
|
}
|
2012-03-12 01:06:06 +01:00
|
|
|
else
|
2011-08-08 21:02:49 +02:00
|
|
|
{
|
2012-03-12 01:06:06 +01:00
|
|
|
[end setTimeZone: tz];
|
|
|
|
[end setDateTime: value];
|
2011-08-08 21:02:49 +02:00
|
|
|
}
|
2012-03-12 01:06:06 +01:00
|
|
|
}
|
2011-08-08 21:02:49 +02:00
|
|
|
|
2012-03-12 01:06:06 +01:00
|
|
|
/* priority */
|
|
|
|
value = [properties objectForKey: MAPIPropertyKey(PR_IMPORTANCE)];
|
|
|
|
if (value)
|
|
|
|
{
|
|
|
|
switch ([value intValue])
|
2011-08-08 21:02:49 +02:00
|
|
|
{
|
2012-03-12 01:06:06 +01:00
|
|
|
case 0: // IMPORTANCE_LOW
|
|
|
|
priority = @"9";
|
|
|
|
break;
|
|
|
|
case 2: // IMPORTANCE_HIGH
|
|
|
|
priority = @"1";
|
|
|
|
break;
|
|
|
|
default: // IMPORTANCE_NORMAL
|
|
|
|
priority = @"5";
|
2011-08-08 21:02:49 +02:00
|
|
|
}
|
2012-03-12 01:06:06 +01:00
|
|
|
}
|
|
|
|
else
|
|
|
|
priority = @"0"; // None
|
|
|
|
[newEvent setPriority: priority];
|
|
|
|
|
|
|
|
/* show time as free/busy/tentative/out of office. Possible values are:
|
|
|
|
0x00000000 - olFree
|
|
|
|
0x00000001 - olTentative
|
|
|
|
0x00000002 - olBusy
|
|
|
|
0x00000003 - olOutOfOffice */
|
|
|
|
value = [properties objectForKey: MAPIPropertyKey(PidLidBusyStatus)];
|
|
|
|
if (value)
|
|
|
|
{
|
|
|
|
switch ([value intValue])
|
|
|
|
{
|
|
|
|
case 0:
|
|
|
|
[newEvent setTransparency: @"TRANSPARENT"];
|
|
|
|
break;
|
|
|
|
case 1:
|
|
|
|
case 2:
|
|
|
|
case 3:
|
|
|
|
default:
|
|
|
|
[newEvent setTransparency: @"OPAQUE"];
|
|
|
|
}
|
|
|
|
}
|
2011-08-08 21:02:49 +02:00
|
|
|
|
2012-03-12 01:06:06 +01:00
|
|
|
/* Comment */
|
|
|
|
value = [properties objectForKey: MAPIPropertyKey (PR_BODY_UNICODE)];
|
|
|
|
if (!value)
|
|
|
|
{
|
|
|
|
value = [properties objectForKey: MAPIPropertyKey (PR_HTML)];
|
2011-09-20 01:33:48 +02:00
|
|
|
if (value)
|
2011-11-09 21:47:08 +01:00
|
|
|
{
|
2012-03-12 01:06:06 +01:00
|
|
|
value = [[NSString alloc] initWithData: value
|
|
|
|
encoding: NSUTF8StringEncoding];
|
|
|
|
[value autorelease];
|
|
|
|
value = [value htmlToText];
|
2011-11-09 21:47:08 +01:00
|
|
|
}
|
2012-03-12 01:06:06 +01:00
|
|
|
}
|
|
|
|
if (value && [value length] == 0)
|
|
|
|
value = nil;
|
|
|
|
[newEvent setComment: value];
|
2011-09-20 01:33:48 +02:00
|
|
|
|
2012-03-12 01:06:06 +01:00
|
|
|
/* recurrence */
|
|
|
|
value = [properties
|
2011-08-08 21:02:49 +02:00
|
|
|
objectForKey: MAPIPropertyKey (PidLidAppointmentRecur)];
|
2012-03-12 01:06:06 +01:00
|
|
|
if (value)
|
|
|
|
[self _setupRecurrenceInCalendar: vCalendar
|
|
|
|
withEvent: newEvent
|
|
|
|
fromData: value];
|
2011-08-08 21:02:49 +02:00
|
|
|
|
2012-03-12 01:06:06 +01:00
|
|
|
[newEvent setOrganizer: nil];
|
|
|
|
[newEvent removeAllAttendees];
|
2011-10-03 22:55:02 +02:00
|
|
|
|
2012-03-12 01:06:06 +01:00
|
|
|
/* alarm */
|
|
|
|
[self _setupAlarmDataInEvent: newEvent];
|
2011-10-11 21:46:02 +02:00
|
|
|
|
2012-03-12 01:06:06 +01:00
|
|
|
if ([[properties objectForKey: MAPIPropertyKey (PidLidAppointmentStateFlags)] intValue]
|
|
|
|
!= 0)
|
|
|
|
{
|
|
|
|
// Organizer
|
|
|
|
value = [properties objectForKey: @"recipients"];
|
|
|
|
if (value)
|
2011-07-21 17:05:17 +02:00
|
|
|
{
|
2012-03-12 01:06:06 +01:00
|
|
|
NSArray *recipients;
|
|
|
|
NSDictionary *dict;
|
|
|
|
NSString *orgEmail, *sentBy, *attEmail;
|
|
|
|
iCalPerson *person;
|
|
|
|
iCalPersonPartStat newPartStat;
|
|
|
|
NSNumber *flags, *trackStatus;
|
|
|
|
int i, effective;
|
|
|
|
BOOL organizerIsSet = NO;
|
|
|
|
|
|
|
|
recipients = [value objectForKey: @"to"];
|
|
|
|
effective = 0;
|
|
|
|
for (i = 0; i < [recipients count]; i++)
|
2011-07-21 17:05:17 +02:00
|
|
|
{
|
2012-03-12 01:06:06 +01:00
|
|
|
dict = [recipients objectAtIndex: i];
|
2011-07-21 17:05:17 +02:00
|
|
|
person = [iCalPerson new];
|
|
|
|
[person setCn: [dict objectForKey: @"fullName"]];
|
2012-03-12 01:06:06 +01:00
|
|
|
attEmail = [dict objectForKey: @"email"];
|
|
|
|
[person setEmail: attEmail];
|
|
|
|
|
|
|
|
flags = [dict objectForKey: MAPIPropertyKey (PR_RECIPIENT_FLAGS)];
|
|
|
|
if (!flags)
|
2011-12-01 23:30:25 +01:00
|
|
|
{
|
2012-03-12 01:06:06 +01:00
|
|
|
[self logWithFormat:
|
|
|
|
@"no recipient flags specified: skipping recipient"];
|
|
|
|
continue;
|
2011-12-01 23:30:25 +01:00
|
|
|
}
|
2011-10-03 22:55:02 +02:00
|
|
|
|
2012-03-12 01:06:06 +01:00
|
|
|
if (([flags unsignedIntValue] & 0x0002)) /* recipOrganizer */
|
2011-10-03 22:55:02 +02:00
|
|
|
{
|
2012-03-12 01:06:06 +01:00
|
|
|
[newEvent setOrganizer: person];
|
|
|
|
organizerIsSet = YES;
|
|
|
|
[self logWithFormat: @"organizer set via recipient flags"];
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
BOOL isOrganizer = NO;
|
|
|
|
|
|
|
|
// /* 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 (PidTagRecipientTrackStatus)];
|
|
|
|
if (trackStatus)
|
2011-10-03 22:55:02 +02:00
|
|
|
{
|
2012-03-12 01:06:06 +01:00
|
|
|
/* FIXME: we should provide a data converter between OL
|
|
|
|
partstats and SOGo */
|
|
|
|
switch ([trackStatus unsignedIntValue])
|
|
|
|
{
|
|
|
|
case 0x01: /* respOrganized */
|
|
|
|
isOrganizer = YES;
|
|
|
|
break;
|
|
|
|
case 0x02: /* respTentative */
|
|
|
|
newPartStat = iCalPersonPartStatTentative;
|
|
|
|
break;
|
|
|
|
case 0x03: /* respAccepted */
|
|
|
|
newPartStat = iCalPersonPartStatAccepted;
|
|
|
|
break;
|
|
|
|
case 0x04: /* respDeclined */
|
|
|
|
newPartStat = iCalPersonPartStatDeclined;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
newPartStat = iCalPersonPartStatNeedsAction;
|
|
|
|
}
|
2011-10-03 22:55:02 +02:00
|
|
|
|
2012-03-12 01:06:06 +01:00
|
|
|
if (isOrganizer)
|
|
|
|
{
|
|
|
|
[newEvent setOrganizer: person];
|
|
|
|
organizerIsSet = YES;
|
|
|
|
[self logWithFormat: @"organizer set via track status"];
|
|
|
|
}
|
|
|
|
else
|
2011-11-02 22:20:02 +01:00
|
|
|
{
|
2012-03-12 01:06:06 +01:00
|
|
|
[person setParticipationStatus: newPartStat];
|
|
|
|
[person setRsvp: @"TRUE"];
|
|
|
|
[person setRole: @"REQ-PARTICIPANT"];
|
|
|
|
[newEvent addToAttendees: person];
|
|
|
|
effective++;
|
2011-11-02 22:20:02 +01:00
|
|
|
}
|
2012-03-12 01:06:06 +01:00
|
|
|
}
|
|
|
|
else
|
|
|
|
[self errorWithFormat: @"skipped recipient due"
|
|
|
|
@" to missing track status"];
|
|
|
|
}
|
2011-11-02 22:20:02 +01:00
|
|
|
|
2012-03-12 01:06:06 +01:00
|
|
|
[person release];
|
|
|
|
}
|
2011-11-02 21:40:32 +01:00
|
|
|
|
2012-03-12 01:06:06 +01:00
|
|
|
if (effective == 0) /* See work-around above */
|
|
|
|
[newEvent setOrganizer: nil];
|
|
|
|
else
|
|
|
|
{
|
|
|
|
ownerUser = [[self userContext] sogoUser];
|
|
|
|
if (organizerIsSet)
|
|
|
|
{
|
|
|
|
/* We must reset the participation status to the value
|
|
|
|
obtained from PidLidResponseStatus as the value in
|
|
|
|
PidTagRecipientTrackStatus is not correct. Note (hack):
|
|
|
|
the method used here requires that the user directory
|
|
|
|
from LDAP and Samba matches perfectly. This can be solved
|
|
|
|
more appropriately by making use of the sender
|
|
|
|
properties... */
|
|
|
|
person = [newEvent userAsAttendee: ownerUser];
|
|
|
|
if (person)
|
|
|
|
{
|
|
|
|
value
|
|
|
|
= [properties objectForKey: MAPIPropertyKey (PidLidResponseStatus)];
|
|
|
|
if (value)
|
|
|
|
responseStatus = [value unsignedLongValue];
|
|
|
|
|
|
|
|
/* FIXME: we should provide a data converter between OL partstats and
|
|
|
|
SOGo */
|
|
|
|
switch (responseStatus)
|
2011-11-02 21:40:32 +01:00
|
|
|
{
|
|
|
|
case 0x02: /* respTentative */
|
|
|
|
newPartStat = iCalPersonPartStatTentative;
|
|
|
|
break;
|
|
|
|
case 0x03: /* respAccepted */
|
|
|
|
newPartStat = iCalPersonPartStatAccepted;
|
|
|
|
break;
|
|
|
|
case 0x04: /* respDeclined */
|
|
|
|
newPartStat = iCalPersonPartStatDeclined;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
newPartStat = iCalPersonPartStatNeedsAction;
|
|
|
|
}
|
|
|
|
[person setParticipationStatus: newPartStat];
|
2012-03-12 01:06:06 +01:00
|
|
|
newParticipationStatus = [person partStatWithDefault];
|
|
|
|
|
|
|
|
// if (newPartStat // != iCalPersonPartStatUndefined
|
|
|
|
// )
|
|
|
|
// {
|
|
|
|
// // iCalPerson *participant;
|
|
|
|
|
|
|
|
// // participant = [newEvent userAsAttendee: ownerUser];
|
|
|
|
// // [participant setParticipationStatus: newPartStat];
|
|
|
|
// // [sogoObject saveComponent: newEvent];
|
|
|
|
|
|
|
|
// [sogoObject changeParticipationStatus: newPartStat
|
|
|
|
// withDelegate: nil];
|
|
|
|
// // [[self context] tearDownRequest];
|
|
|
|
// }
|
|
|
|
// // }1005
|
|
|
|
|
|
|
|
// // else
|
|
|
|
// // {
|
2011-11-02 21:40:32 +01:00
|
|
|
}
|
2012-03-12 01:06:06 +01:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
[self errorWithFormat: @"organizer was not set although a"
|
|
|
|
@" recipient list was specified"];
|
|
|
|
/* 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 = [ownerUser primaryIdentity];
|
|
|
|
person = [iCalPerson new];
|
|
|
|
[person setCn: [dict objectForKey: @"fullName"]];
|
|
|
|
orgEmail = [dict objectForKey: @"email"];
|
|
|
|
[person setEmail: orgEmail];
|
|
|
|
|
|
|
|
activeUser = [[self context] activeUser];
|
|
|
|
if (![activeUser isEqual: ownerUser])
|
|
|
|
{
|
|
|
|
dict = [activeUser primaryIdentity];
|
|
|
|
sentBy = [NSString stringWithFormat: @"mailto:%@",
|
|
|
|
[dict objectForKey: @"email"]];
|
|
|
|
[person setSentBy: sentBy];
|
|
|
|
}
|
|
|
|
[newEvent setOrganizer: person];
|
2011-11-02 21:40:32 +01:00
|
|
|
[person release];
|
|
|
|
}
|
2011-07-21 17:05:17 +02:00
|
|
|
}
|
|
|
|
}
|
2011-02-24 21:30:01 +01:00
|
|
|
}
|
2012-03-12 01:06:06 +01:00
|
|
|
|
|
|
|
[sogoObject saveComponent: newEvent];
|
|
|
|
if (newParticipationStatus)
|
|
|
|
[sogoObject changeParticipationStatus: newParticipationStatus
|
|
|
|
withDelegate: nil];
|
2012-03-16 22:05:41 +01:00
|
|
|
[self updateVersions];
|
2011-02-24 21:30:01 +01:00
|
|
|
}
|
|
|
|
|
2011-07-26 21:02:45 +02:00
|
|
|
- (id) lookupAttachment: (NSString *) childKey
|
2011-03-22 22:28:16 +01:00
|
|
|
{
|
|
|
|
return [attachmentParts objectForKey: childKey];
|
|
|
|
}
|
|
|
|
|
|
|
|
- (MAPIStoreAttachment *) createAttachment
|
|
|
|
{
|
2011-04-01 00:59:12 +02:00
|
|
|
MAPIStoreCalendarAttachment *newAttachment;
|
|
|
|
uint32_t newAid;
|
|
|
|
NSString *newKey;
|
|
|
|
|
2011-07-26 22:13:10 +02:00
|
|
|
newAid = [[self attachmentKeys] count];
|
2011-04-01 00:59:12 +02:00
|
|
|
|
|
|
|
newAttachment = [MAPIStoreCalendarAttachment
|
|
|
|
mapiStoreObjectWithSOGoObject: nil
|
|
|
|
inContainer: self];
|
|
|
|
[newAttachment setIsNew: YES];
|
|
|
|
[newAttachment setAID: newAid];
|
|
|
|
newKey = [NSString stringWithFormat: @"%ul", newAid];
|
2011-03-22 22:28:16 +01:00
|
|
|
[attachmentParts setObject: newAttachment
|
2011-04-01 00:59:12 +02:00
|
|
|
forKey: newKey];
|
2011-07-26 22:13:10 +02:00
|
|
|
[attachmentKeys release];
|
|
|
|
attachmentKeys = nil;
|
2011-03-22 22:28:16 +01:00
|
|
|
|
|
|
|
return newAttachment;
|
|
|
|
}
|
|
|
|
|
2011-11-01 15:30:20 +01:00
|
|
|
- (int) setReadFlag: (uint8_t) flag
|
|
|
|
{
|
|
|
|
return MAPISTORE_SUCCESS;
|
|
|
|
}
|
|
|
|
|
2011-02-24 21:30:01 +01:00
|
|
|
@end
|