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-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"
|
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-07-21 17:05:17 +02:00
|
|
|
if (!appointmentWrapper)
|
|
|
|
{
|
|
|
|
event = [sogoObject component: NO secure: NO];
|
|
|
|
ASSIGN (appointmentWrapper,
|
|
|
|
[MAPIStoreAppointmentWrapper wrapperWithICalEvent: event
|
2011-10-03 22:55:02 +02:00
|
|
|
andUser: [[self context] activeUser]
|
2011-10-12 22:00:46 +02:00
|
|
|
andSenderEmail: nil
|
2011-10-03 22:55:02 +02:00
|
|
|
inTimeZone: [self ownerTimeZone]]);
|
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 */
|
|
|
|
- (int) getPrIconIndex: (void **) data
|
|
|
|
inMemCtx: (TALLOC_CTX *) memCtx
|
|
|
|
{
|
|
|
|
return [[self appointmentWrapper] getPrIconIndex: 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];
|
|
|
|
}
|
|
|
|
|
2011-04-13 21:59:04 +02:00
|
|
|
- (int) getPrMessageClass: (void **) data
|
2011-07-11 23:40:47 +02:00
|
|
|
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
|
|
|
}
|
|
|
|
|
2011-08-08 21:02:49 +02:00
|
|
|
- (int) getPrOwnerApptId: (void **) data
|
|
|
|
inMemCtx: (TALLOC_CTX *) memCtx
|
|
|
|
{
|
|
|
|
return [[self appointmentWrapper] getPrOwnerApptId: data inMemCtx: memCtx];
|
|
|
|
}
|
|
|
|
|
2011-04-13 21:59:04 +02:00
|
|
|
- (int) getPrStartDate: (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] getPrStartDate: 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
|
|
|
}
|
|
|
|
|
|
|
|
- (int) getPrEndDate: (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] getPrEndDate: 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
|
|
|
{
|
2011-07-21 17:05:17 +02: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
|
|
|
|
2011-04-13 21:59:04 +02:00
|
|
|
- (int) getPrSubject: (void **) data // SUMMARY
|
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] getPrSubject: data inMemCtx: memCtx];
|
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
|
|
|
}
|
|
|
|
|
|
|
|
- (int) getPrSensitivity: (void **) data // not implemented, depends on CLASS
|
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] getPrSensitivity: data inMemCtx: memCtx];
|
2011-04-13 21:59:04 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
- (int) getPrImportance: (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] getPrImportance: data inMemCtx: memCtx];
|
2011-04-13 21:59:04 +02:00
|
|
|
}
|
|
|
|
|
2011-11-09 21:47:08 +01:00
|
|
|
- (int) getPrBody: (void **) data
|
|
|
|
inMemCtx: (TALLOC_CTX *) memCtx
|
|
|
|
{
|
|
|
|
return [[self appointmentWrapper] getPrBody: data inMemCtx: memCtx];
|
|
|
|
}
|
|
|
|
|
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
|
|
|
}
|
|
|
|
|
2011-10-03 22:55:02 +02:00
|
|
|
- (int) getPrProcessed: (void **) data inMemCtx: (TALLOC_CTX *) memCtx
|
|
|
|
{
|
|
|
|
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 */
|
|
|
|
- (int) getPrSenderEmailAddress: (void **) data
|
|
|
|
inMemCtx: (TALLOC_CTX *) memCtx
|
|
|
|
{
|
|
|
|
return [[self appointmentWrapper] getPrSenderEmailAddress: data
|
|
|
|
inMemCtx: memCtx];
|
|
|
|
}
|
|
|
|
|
|
|
|
- (int) getPrSenderAddrtype: (void **) data
|
|
|
|
inMemCtx: (TALLOC_CTX *) memCtx
|
|
|
|
{
|
|
|
|
return [[self appointmentWrapper] getPrSenderAddrtype: data
|
|
|
|
inMemCtx: memCtx];
|
|
|
|
}
|
|
|
|
|
|
|
|
- (int) getPrSenderName: (void **) data
|
|
|
|
inMemCtx: (TALLOC_CTX *) memCtx
|
|
|
|
{
|
|
|
|
return [[self appointmentWrapper] getPrSenderName: data
|
|
|
|
inMemCtx: memCtx];
|
|
|
|
}
|
|
|
|
|
|
|
|
- (int) getPrSenderEntryid: (void **) data inMemCtx: (TALLOC_CTX *) memCtx
|
|
|
|
{
|
|
|
|
return [[self appointmentWrapper] getPrSenderEntryid: data
|
|
|
|
inMemCtx: memCtx];
|
|
|
|
}
|
|
|
|
|
|
|
|
/* sender representing */
|
|
|
|
- (int) getPrSentRepresentingEmailAddress: (void **) data
|
|
|
|
inMemCtx: (TALLOC_CTX *) memCtx
|
|
|
|
{
|
|
|
|
return [self getPrSenderEmailAddress: data inMemCtx: memCtx];
|
|
|
|
}
|
|
|
|
|
|
|
|
- (int) getPrSentRepresentingAddrtype: (void **) data
|
|
|
|
inMemCtx: (TALLOC_CTX *) memCtx
|
|
|
|
{
|
|
|
|
return [self getSMTPAddrType: data inMemCtx: memCtx];
|
|
|
|
}
|
|
|
|
|
|
|
|
- (int) getPrSentRepresentingName: (void **) data
|
|
|
|
inMemCtx: (TALLOC_CTX *) memCtx
|
|
|
|
{
|
|
|
|
return [self getPrSenderName: data inMemCtx: memCtx];
|
|
|
|
}
|
|
|
|
|
|
|
|
- (int) getPrSentRepresentingEntryid: (void **) data
|
|
|
|
inMemCtx: (TALLOC_CTX *) memCtx
|
|
|
|
{
|
|
|
|
return [self getPrSenderEntryid: data inMemCtx: memCtx];
|
|
|
|
}
|
|
|
|
|
|
|
|
/* attendee */
|
|
|
|
// - (int) getPrReceivedByAddrtype: (void **) data
|
|
|
|
// inMemCtx: (TALLOC_CTX *) memCtx
|
|
|
|
// {
|
|
|
|
// return [[self appointmentWrapper] getPrReceivedByAddrtype: data
|
|
|
|
// inMemCtx: memCtx];
|
|
|
|
// }
|
|
|
|
|
|
|
|
// - (int) getPrReceivedByEmailAddress: (void **) data
|
|
|
|
// inMemCtx: (TALLOC_CTX *) memCtx
|
|
|
|
// {
|
|
|
|
// return [[self appointmentWrapper] getPrReceivedByEmailAddress: data
|
|
|
|
// inMemCtx: memCtx];
|
|
|
|
// }
|
|
|
|
|
|
|
|
// - (int) getPrReceivedByName: (void **) data
|
|
|
|
// inMemCtx: (TALLOC_CTX *) memCtx
|
|
|
|
// {
|
|
|
|
// return [[self appointmentWrapper] getPrReceivedByName: data
|
|
|
|
// inMemCtx: memCtx];
|
|
|
|
// }
|
|
|
|
|
|
|
|
// - (int) getPrReceivedByEntryid: (void **) data
|
|
|
|
// inMemCtx: (TALLOC_CTX *) memCtx
|
|
|
|
// {
|
|
|
|
// return [[self appointmentWrapper] getPrReceivedByEntryid: data
|
|
|
|
// inMemCtx: memCtx];
|
|
|
|
// }
|
|
|
|
|
|
|
|
// /* attendee representing */
|
|
|
|
// - (int) getPrRcvdRepresentingEmailAddress: (void **) data
|
|
|
|
// inMemCtx: (TALLOC_CTX *) memCtx
|
|
|
|
// {
|
|
|
|
// return [self getPrReceivedByEmailAddress: data inMemCtx: memCtx];
|
|
|
|
// }
|
|
|
|
|
|
|
|
// - (int) getPrRcvdRepresentingAddrtype: (void **) data
|
|
|
|
// inMemCtx: (TALLOC_CTX *) memCtx
|
|
|
|
// {
|
|
|
|
// return [self getSMTPAddrType: data inMemCtx: memCtx];
|
|
|
|
// }
|
|
|
|
|
|
|
|
// - (int) getPrRcvdRepresentingName: (void **) data
|
|
|
|
// inMemCtx: (TALLOC_CTX *) memCtx
|
|
|
|
// {
|
|
|
|
// return [self getPrReceivedByName: data inMemCtx: memCtx];
|
|
|
|
// }
|
|
|
|
|
|
|
|
// - (int) getPrRcvdRepresentingEntryid: (void **) data
|
|
|
|
// inMemCtx: (TALLOC_CTX *) memCtx
|
|
|
|
// {
|
|
|
|
// return [self getPrReceivedByEntryid: data inMemCtx: memCtx];
|
|
|
|
// }
|
|
|
|
|
|
|
|
- (int) getPrResponseRequested: (void **) data
|
|
|
|
inMemCtx: (TALLOC_CTX *) memCtx
|
|
|
|
{
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
|
|
|
- (void) _fixupEventWithExistingUID
|
|
|
|
{
|
|
|
|
NSString *uid, *existingCName, *existingURL;
|
|
|
|
MAPIStoreMapping *mapping;
|
|
|
|
uint64_t objectId;
|
|
|
|
SOGoAppointmentObject *existingObject;
|
|
|
|
WOContext *woContext;
|
|
|
|
|
|
|
|
uid = [self _uidFromGlobalObjectId];
|
|
|
|
existingCName = [[container sogoObject] resourceNameForEventUID: uid];
|
|
|
|
if (existingCName)
|
|
|
|
{
|
|
|
|
mapping = [[self context] mapping];
|
|
|
|
|
2011-10-04 01:13:00 +02:00
|
|
|
/* dissociate the object url from the old object's id */
|
2011-10-03 22:55:02 +02:00
|
|
|
existingURL = [NSString stringWithFormat: @"%@%@",
|
|
|
|
[container url], existingCName];
|
|
|
|
objectId = [mapping idFromURL: existingURL];
|
|
|
|
[mapping unregisterURLWithID: objectId];
|
|
|
|
|
2011-10-04 01:13:00 +02:00
|
|
|
/* dissociate the object url associated with this object, as we want to
|
|
|
|
discard it */
|
2011-10-03 22:55:02 +02:00
|
|
|
objectId = [self objectId];
|
|
|
|
[mapping unregisterURLWithID: objectId];
|
2011-10-04 01:13:00 +02:00
|
|
|
|
|
|
|
/* associate the object url with this object id */
|
2011-10-03 22:55:02 +02:00
|
|
|
[mapping registerURL: existingURL withID: objectId];
|
|
|
|
|
2011-10-04 01:13:00 +02:00
|
|
|
/* reinstantiate the old sogo object and attach it to self */
|
2011-10-03 22:55:02 +02:00
|
|
|
woContext = [[self context] woContext];
|
|
|
|
existingObject = [[container sogoObject] lookupName: existingCName
|
|
|
|
inContext: woContext
|
|
|
|
acquire: NO];
|
|
|
|
[existingObject setContext: woContext];
|
|
|
|
ASSIGN (sogoObject, existingObject);
|
|
|
|
isNew = NO;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
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"];
|
|
|
|
[trigger setValue: [NSString stringWithFormat: @"-PT%@M", delta]];
|
|
|
|
[alarm setTrigger: trigger];
|
|
|
|
[newEvent addToAlarms: alarm];
|
|
|
|
[alarm release];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
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;
|
2011-09-20 01:33:48 +02:00
|
|
|
NSString *content, *tzName, *priority;
|
2011-04-13 21:59:04 +02:00
|
|
|
iCalEvent *newEvent;
|
2011-08-08 21:02:49 +02:00
|
|
|
iCalPerson *userPerson;
|
2011-07-21 17:05:17 +02:00
|
|
|
NSUInteger responseStatus = 0;
|
2011-08-08 21:02:49 +02:00
|
|
|
SOGoUser *activeUser;
|
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)
|
|
|
|
{
|
2011-10-04 01:13:00 +02:00
|
|
|
/* 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. */
|
2011-10-03 22:55:02 +02:00
|
|
|
[self _fixupEventWithExistingUID];
|
|
|
|
}
|
|
|
|
|
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"];
|
|
|
|
content = [vCalendar versitString];
|
2011-08-08 21:02:49 +02:00
|
|
|
[newEvent setCreated: now];
|
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-02-24 21:30:01 +01:00
|
|
|
|
2011-08-08 21:02:49 +02:00
|
|
|
activeUser = [[self context] activeUser];
|
|
|
|
userPerson = [newEvent userAsAttendee: activeUser];
|
|
|
|
[newEvent setTimeStampAsDate: now];
|
2011-02-24 21:30:01 +01:00
|
|
|
|
2011-08-08 21:02:49 +02:00
|
|
|
if (userPerson)
|
2011-02-24 21:30:01 +01:00
|
|
|
{
|
2011-08-08 21:02:49 +02:00
|
|
|
// iCalPersonPartStat newPartStat;
|
|
|
|
NSString *newPartStat;
|
2011-02-24 21:30:01 +01:00
|
|
|
|
2011-08-08 21:02:49 +02:00
|
|
|
value
|
2011-10-26 17:15:17 +02:00
|
|
|
= [properties objectForKey: MAPIPropertyKey (PidLidResponseStatus)];
|
2011-08-08 21:02:49 +02:00
|
|
|
if (value)
|
|
|
|
responseStatus = [value unsignedLongValue];
|
|
|
|
|
2011-10-03 22:55:02 +02:00
|
|
|
/* FIXME: we should provide a data converter between OL partstats and
|
|
|
|
SOGo */
|
2011-08-08 21:02:49 +02:00
|
|
|
switch (responseStatus)
|
|
|
|
{
|
|
|
|
case 0x02: /* respTentative */
|
|
|
|
// newPartStat = iCalPersonPartStatTentative;
|
|
|
|
newPartStat = @"TENTATIVE";
|
|
|
|
break;
|
|
|
|
case 0x03: /* respAccepted */
|
|
|
|
// newPartStat = iCalPersonPartStatAccepted;
|
|
|
|
newPartStat = @"ACCEPTED";
|
|
|
|
break;
|
|
|
|
case 0x04: /* respDeclined */
|
|
|
|
// newPartStat = iCalPersonPartStatDeclined;
|
|
|
|
newPartStat = @"DECLINED";
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
newPartStat = nil;
|
|
|
|
}
|
2011-02-24 21:30:01 +01:00
|
|
|
|
2011-08-08 21:02:49 +02:00
|
|
|
if (newPartStat // != iCalPersonPartStatUndefined
|
|
|
|
)
|
|
|
|
{
|
|
|
|
// iCalPerson *participant;
|
2011-07-21 17:05:17 +02:00
|
|
|
|
2011-08-08 21:02:49 +02:00
|
|
|
// participant = [newEvent userAsAttendee: activeUser];
|
|
|
|
// [participant setParticipationStatus: newPartStat];
|
|
|
|
// [sogoObject saveComponent: newEvent];
|
|
|
|
|
|
|
|
[sogoObject changeParticipationStatus: newPartStat
|
|
|
|
withDelegate: nil];
|
|
|
|
// [[self context] tearDownRequest];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
2011-02-24 21:30:01 +01:00
|
|
|
{
|
2011-08-08 21:02:49 +02:00
|
|
|
[newEvent setLastModified: now];
|
|
|
|
|
|
|
|
// summary
|
2011-10-26 17:15:17 +02:00
|
|
|
value = [properties
|
2011-08-08 21:02:49 +02:00
|
|
|
objectForKey: MAPIPropertyKey (PR_NORMALIZED_SUBJECT_UNICODE)];
|
|
|
|
if (value)
|
|
|
|
[newEvent setSummary: value];
|
|
|
|
|
|
|
|
// Location
|
2011-10-26 17:15:17 +02:00
|
|
|
value = [properties objectForKey: MAPIPropertyKey (PidLidLocation)];
|
2011-08-08 21:02:49 +02:00
|
|
|
if (value)
|
|
|
|
[newEvent setLocation: value];
|
|
|
|
|
2011-11-02 13:43:36 +01:00
|
|
|
isAllDay = [[properties
|
|
|
|
objectForKey: MAPIPropertyKey (PidLidAppointmentSubType)]
|
|
|
|
boolValue];
|
|
|
|
|
2011-11-02 19:18:32 +01:00
|
|
|
if (!isAllDay)
|
|
|
|
{
|
|
|
|
tzName = [[self ownerTimeZone] name];
|
|
|
|
tz = [iCalTimeZone timeZoneForName: tzName];
|
|
|
|
[vCalendar addTimeZone: tz];
|
|
|
|
}
|
|
|
|
|
2011-08-08 21:02:49 +02:00
|
|
|
// start
|
2011-10-26 17:15:17 +02:00
|
|
|
value = [properties objectForKey: MAPIPropertyKey (PR_START_DATE)];
|
2011-08-08 21:02:49 +02:00
|
|
|
if (!value)
|
2011-10-26 17:15:17 +02:00
|
|
|
value = [properties
|
2011-08-08 21:02:49 +02:00
|
|
|
objectForKey: MAPIPropertyKey (PidLidAppointmentStartWhole)];
|
|
|
|
if (value)
|
|
|
|
{
|
|
|
|
start = (iCalDateTime *) [newEvent uniqueChildWithTag: @"dtstart"];
|
2011-11-02 13:43:36 +01:00
|
|
|
if (isAllDay)
|
|
|
|
[start setDate: value];
|
|
|
|
else
|
|
|
|
{
|
|
|
|
[start setTimeZone: tz];
|
|
|
|
[start setDateTime: value];
|
|
|
|
}
|
2011-08-08 21:02:49 +02:00
|
|
|
}
|
|
|
|
|
2011-09-20 01:33:48 +02:00
|
|
|
/* end */
|
2011-10-26 17:15:17 +02:00
|
|
|
value = [properties objectForKey: MAPIPropertyKey(PR_END_DATE)];
|
2011-08-08 21:02:49 +02:00
|
|
|
if (!value)
|
2011-10-26 17:15:17 +02:00
|
|
|
value = [properties objectForKey: MAPIPropertyKey(PidLidAppointmentEndWhole)];
|
2011-08-08 21:02:49 +02:00
|
|
|
if (value)
|
|
|
|
{
|
|
|
|
end = (iCalDateTime *) [newEvent uniqueChildWithTag: @"dtend"];
|
2011-11-02 13:43:36 +01:00
|
|
|
if (isAllDay)
|
|
|
|
[end setDate: value];
|
|
|
|
else
|
|
|
|
{
|
|
|
|
[end setTimeZone: tz];
|
|
|
|
[end setDateTime: value];
|
|
|
|
}
|
2011-08-08 21:02:49 +02:00
|
|
|
}
|
|
|
|
|
2011-09-20 01:33:48 +02:00
|
|
|
/* priority */
|
2011-10-26 17:15:17 +02:00
|
|
|
value = [properties objectForKey: MAPIPropertyKey(PR_IMPORTANCE)];
|
2011-09-20 01:33:48 +02:00
|
|
|
if (value)
|
|
|
|
{
|
|
|
|
switch ([value intValue])
|
|
|
|
{
|
|
|
|
case 0: // IMPORTANCE_LOW
|
|
|
|
priority = @"9";
|
|
|
|
break;
|
|
|
|
case 2: // IMPORTANCE_HIGH
|
|
|
|
priority = @"1";
|
|
|
|
break;
|
|
|
|
default: // IMPORTANCE_NORMAL
|
|
|
|
priority = @"5";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
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 */
|
2011-10-26 17:15:17 +02:00
|
|
|
value = [properties objectForKey: MAPIPropertyKey(PidLidBusyStatus)];
|
2011-09-20 01:33:48 +02:00
|
|
|
if (value)
|
|
|
|
{
|
|
|
|
switch ([value intValue])
|
|
|
|
{
|
|
|
|
case 0:
|
|
|
|
[newEvent setTransparency: @"TRANSPARENT"];
|
|
|
|
break;
|
|
|
|
case 1:
|
|
|
|
case 2:
|
|
|
|
case 3:
|
|
|
|
default:
|
|
|
|
[newEvent setTransparency: @"OPAQUE"];
|
|
|
|
}
|
|
|
|
}
|
2011-11-09 21:47:08 +01:00
|
|
|
|
|
|
|
/* Comment */
|
|
|
|
value = [properties objectForKey: MAPIPropertyKey (PR_BODY_UNICODE)];
|
|
|
|
if (!value)
|
|
|
|
{
|
|
|
|
value = [properties objectForKey: MAPIPropertyKey (PR_HTML)];
|
|
|
|
if (value)
|
|
|
|
{
|
|
|
|
value = [[NSString alloc] initWithData: value
|
|
|
|
encoding: NSUTF8StringEncoding];
|
|
|
|
[value autorelease];
|
|
|
|
value = [value htmlToText];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (value)
|
|
|
|
[newEvent setComment: value];
|
2011-09-20 01:33:48 +02:00
|
|
|
|
2011-08-08 21:02:49 +02:00
|
|
|
/* recurrence */
|
2011-10-26 17:15:17 +02:00
|
|
|
value = [properties
|
2011-08-08 21:02:49 +02:00
|
|
|
objectForKey: MAPIPropertyKey (PidLidAppointmentRecur)];
|
|
|
|
if (value)
|
|
|
|
[self _setupRecurrenceInCalendar: vCalendar
|
2011-09-23 20:16:46 +02:00
|
|
|
withEvent: newEvent
|
2011-08-08 21:02:49 +02:00
|
|
|
fromData: value];
|
|
|
|
|
2011-10-03 22:55:02 +02:00
|
|
|
[newEvent setOrganizer: nil];
|
|
|
|
[newEvent removeAllAttendees];
|
|
|
|
|
2011-10-11 21:46:02 +02:00
|
|
|
/* alarm */
|
|
|
|
[self _setupAlarmDataInEvent: newEvent];
|
|
|
|
|
2011-11-02 21:40:32 +01:00
|
|
|
if ([[properties objectForKey: MAPIPropertyKey (PidLidAppointmentStateFlags)] intValue]
|
|
|
|
!= 0)
|
2011-07-21 17:05:17 +02:00
|
|
|
{
|
2011-11-02 21:40:32 +01:00
|
|
|
// Organizer
|
|
|
|
value = [properties objectForKey: @"recipients"];
|
|
|
|
if (value)
|
2011-07-21 17:05:17 +02:00
|
|
|
{
|
2011-11-02 21:40:32 +01:00
|
|
|
NSArray *recipients;
|
|
|
|
NSDictionary *dict;
|
|
|
|
NSString *orgEmail, *attEmail;
|
|
|
|
iCalPerson *person;
|
|
|
|
iCalPersonPartStat newPartStat;
|
|
|
|
NSNumber *flags, *trackStatus;
|
|
|
|
int i, effective;
|
|
|
|
|
|
|
|
/* We must set the organizer preliminarily here because, unlike what
|
|
|
|
the doc states, Outlook does not always pass the real organizer
|
|
|
|
in the recipients list. */
|
|
|
|
dict = [activeUser primaryIdentity];
|
2011-07-21 17:05:17 +02:00
|
|
|
person = [iCalPerson new];
|
|
|
|
[person setCn: [dict objectForKey: @"fullName"]];
|
2011-11-02 21:40:32 +01:00
|
|
|
orgEmail = [dict objectForKey: @"email"];
|
|
|
|
[person setEmail: orgEmail];
|
|
|
|
[newEvent setOrganizer: person];
|
|
|
|
[person release];
|
2011-10-03 22:55:02 +02:00
|
|
|
|
2011-11-02 21:40:32 +01:00
|
|
|
recipients = [value objectForKey: @"to"];
|
|
|
|
effective = 0;
|
|
|
|
for (i = 0; i < [recipients count]; i++)
|
2011-10-03 22:55:02 +02:00
|
|
|
{
|
2011-11-02 21:40:32 +01:00
|
|
|
dict = [recipients objectAtIndex: i];
|
|
|
|
|
|
|
|
flags = [dict objectForKey: MAPIPropertyKey (PR_RECIPIENT_FLAGS)];
|
|
|
|
if (!flags)
|
2011-10-03 22:55:02 +02:00
|
|
|
{
|
2011-11-02 22:20:02 +01:00
|
|
|
[self logWithFormat:
|
|
|
|
@"no recipient flags specified: skipping recipient"];
|
|
|
|
continue;
|
2011-10-03 22:55:02 +02:00
|
|
|
}
|
|
|
|
|
2011-11-02 21:40:32 +01:00
|
|
|
person = [iCalPerson new];
|
|
|
|
[person setCn: [dict objectForKey: @"fullName"]];
|
2011-11-02 22:20:02 +01:00
|
|
|
attEmail = [dict objectForKey: @"email"];
|
2011-11-02 21:40:32 +01:00
|
|
|
[person setEmail: attEmail];
|
2011-10-03 22:55:02 +02:00
|
|
|
|
2011-11-02 21:40:32 +01:00
|
|
|
if (([flags unsignedIntValue] & 0x0002)) /* recipOrganizer */
|
|
|
|
[newEvent setOrganizer: person];
|
|
|
|
else
|
|
|
|
{
|
2011-11-02 22:20:02 +01:00
|
|
|
/* 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;
|
|
|
|
}
|
|
|
|
|
2011-11-02 21:40:32 +01:00
|
|
|
trackStatus
|
|
|
|
= [dict
|
|
|
|
objectForKey: MAPIPropertyKey (PR_RECIPIENT_TRACKSTATUS)];
|
|
|
|
|
|
|
|
/* FIXME: we should provide a data converter between OL
|
|
|
|
partstats and SOGo */
|
|
|
|
switch ([trackStatus unsignedIntValue])
|
|
|
|
{
|
|
|
|
case 0x02: /* respTentative */
|
|
|
|
newPartStat = iCalPersonPartStatTentative;
|
|
|
|
break;
|
|
|
|
case 0x03: /* respAccepted */
|
|
|
|
newPartStat = iCalPersonPartStatAccepted;
|
|
|
|
break;
|
|
|
|
case 0x04: /* respDeclined */
|
|
|
|
newPartStat = iCalPersonPartStatDeclined;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
newPartStat = iCalPersonPartStatNeedsAction;
|
|
|
|
}
|
|
|
|
|
|
|
|
[person setParticipationStatus: newPartStat];
|
|
|
|
[person setRsvp: @"TRUE"];
|
|
|
|
[person setRole: @"REQ-PARTICIPANT"];
|
|
|
|
[newEvent addToAttendees: person];
|
2011-11-02 22:20:02 +01:00
|
|
|
effective++;
|
2011-11-02 21:40:32 +01:00
|
|
|
}
|
2011-11-01 21:45:59 +01:00
|
|
|
|
2011-11-02 21:40:32 +01:00
|
|
|
[person release];
|
|
|
|
}
|
2011-11-02 22:20:02 +01:00
|
|
|
|
|
|
|
if (effective == 0) /* See work-around above */
|
|
|
|
[newEvent setOrganizer: nil];
|
2011-07-21 17:05:17 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-08-08 21:02:49 +02:00
|
|
|
[sogoObject saveComponent: newEvent];
|
2011-02-24 21:30:01 +01:00
|
|
|
}
|
2011-08-12 20:41:25 +02:00
|
|
|
[(MAPIStoreCalendarFolder *) container synchroniseCache];
|
2011-10-26 17:15:17 +02:00
|
|
|
value = [properties objectForKey: MAPIPropertyKey (PR_CHANGE_KEY)];
|
2011-09-20 21:37:03 +02:00
|
|
|
if (value)
|
|
|
|
[(MAPIStoreCalendarFolder *) container
|
|
|
|
setChangeKey: value forMessageWithKey: [self nameInContainer]];
|
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
|