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
|
|
|
|
2012-07-20 17:42:52 +02:00
|
|
|
#import "iCalEvent+MAPIStore.h"
|
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
|
|
|
|
|
2012-07-20 16:36:05 +02:00
|
|
|
+ (enum mapistore_error) getAvailableProperties: (struct SPropTagArray **) propertiesP
|
|
|
|
inMemCtx: (TALLOC_CTX *) memCtx
|
|
|
|
{
|
|
|
|
BOOL listedProperties[65536];
|
|
|
|
NSUInteger count;
|
|
|
|
|
|
|
|
memset (listedProperties, NO, 65536 * sizeof (BOOL));
|
|
|
|
[super getAvailableProperties: propertiesP inMemCtx: memCtx];
|
|
|
|
for (count = 0; count < (*propertiesP)->cValues; count++)
|
|
|
|
listedProperties[(*propertiesP)->aulPropTag[count] >> 16] = YES;
|
|
|
|
[MAPIStoreAppointmentWrapper fillAvailableProperties: *propertiesP
|
|
|
|
withExclusions: listedProperties];
|
|
|
|
|
|
|
|
return MAPISTORE_SUCCESS;
|
|
|
|
}
|
|
|
|
|
2012-07-20 17:42:52 +02:00
|
|
|
- (id) init
|
|
|
|
{
|
|
|
|
if ((self = [super init]))
|
|
|
|
{
|
|
|
|
calendar = nil;
|
|
|
|
masterEvent = nil;
|
|
|
|
}
|
|
|
|
|
|
|
|
return self;
|
|
|
|
}
|
|
|
|
|
2012-07-19 22:26:33 +02:00
|
|
|
- (id) initWithSOGoObject: (id) newSOGoObject
|
|
|
|
inContainer: (MAPIStoreObject *) newFolder
|
2011-02-24 21:30:01 +01:00
|
|
|
{
|
2011-11-17 17:15:38 +01:00
|
|
|
MAPIStoreContext *context;
|
2012-01-29 20:55:21 +01:00
|
|
|
MAPIStoreUserContext *userContext;
|
2012-07-20 17:42:52 +02:00
|
|
|
iCalCalendar *origCalendar;
|
2012-07-19 22:26:33 +02:00
|
|
|
MAPIStoreAppointmentWrapper *appointmentWrapper;
|
2012-07-20 17:42:52 +02:00
|
|
|
|
2012-07-19 22:26:33 +02:00
|
|
|
if ((self = [super initWithSOGoObject: newSOGoObject
|
|
|
|
inContainer: newFolder]))
|
2011-07-21 17:05:17 +02:00
|
|
|
{
|
2012-07-20 17:42:52 +02:00
|
|
|
if ([newSOGoObject isNew])
|
|
|
|
{
|
|
|
|
ASSIGN (calendar, [iCalCalendar groupWithTag: @"vcalendar"]);
|
|
|
|
[calendar setVersion: @"2.0"];
|
|
|
|
[calendar setProdID: @"-//Inverse inc.//OpenChange+SOGo//EN"];
|
|
|
|
masterEvent = [iCalEvent groupWithTag: @"vevent"];
|
|
|
|
[calendar addChild: masterEvent];
|
|
|
|
[masterEvent setCreated: [NSCalendarDate date]];
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
origCalendar = [sogoObject calendar: YES secure: YES];
|
|
|
|
calendar = [origCalendar mutableCopy];
|
|
|
|
masterEvent = [[calendar events] objectAtIndex: 0];
|
|
|
|
}
|
2011-11-17 17:15:38 +01:00
|
|
|
context = [self context];
|
2012-01-29 20:55:21 +01:00
|
|
|
userContext = [self userContext];
|
2012-07-19 22:26:33 +02:00
|
|
|
appointmentWrapper
|
2012-07-20 17:42:52 +02:00
|
|
|
= [MAPIStoreAppointmentWrapper wrapperWithICalEvent: masterEvent
|
2012-07-19 22:26:33 +02:00
|
|
|
andUser: [userContext sogoUser]
|
|
|
|
andSenderEmail: nil
|
|
|
|
inTimeZone: [userContext timeZone]
|
|
|
|
withConnectionInfo: [context connectionInfo]];
|
|
|
|
[self addProxy: appointmentWrapper];
|
2011-07-21 17:05:17 +02:00
|
|
|
}
|
2012-07-20 17:42:52 +02:00
|
|
|
|
2012-07-19 22:26:33 +02:00
|
|
|
return self;
|
2011-07-21 17:05:17 +02:00
|
|
|
}
|
|
|
|
|
2012-07-20 17:42:52 +02:00
|
|
|
- (void) dealloc
|
|
|
|
{
|
|
|
|
[calendar release];
|
|
|
|
[super dealloc];
|
|
|
|
}
|
|
|
|
|
2011-07-21 17:05:17 +02:00
|
|
|
/* getters */
|
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;
|
|
|
|
}
|
|
|
|
|
|
|
|
- (int) getPidLidSideEffects: (void **) data // TODO
|
|
|
|
inMemCtx: (TALLOC_CTX *) memCtx
|
|
|
|
{
|
|
|
|
*data = MAPILongValue (memCtx,
|
|
|
|
seOpenToDelete | seOpenToCopy | seOpenToMove
|
|
|
|
| seCoerceToInbox | seOpenForCtxMenu);
|
|
|
|
|
|
|
|
return MAPISTORE_SUCCESS;
|
|
|
|
}
|
|
|
|
|
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];
|
|
|
|
}
|
|
|
|
|
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];
|
2012-07-19 22:26:33 +02:00
|
|
|
/* HACK: we know the first (and only) proxy is our appointment wrapper
|
|
|
|
instance, but this might not always be true */
|
|
|
|
[[proxies objectAtIndex: 0] fillMessageData: msgData
|
|
|
|
inMemCtx: memCtx];
|
2012-07-20 17:42:52 +02:00
|
|
|
|
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 representing */
|
2012-07-19 22:26:33 +02:00
|
|
|
// - (int) getPidTagSentRepresentingEmailAddress: (void **) data
|
|
|
|
// inMemCtx: (TALLOC_CTX *) memCtx
|
|
|
|
// {
|
|
|
|
// return [self getPidTagSenderEmailAddress: data inMemCtx: memCtx];
|
|
|
|
// }
|
2011-10-03 22:55:02 +02:00
|
|
|
|
2012-07-19 22:26:33 +02:00
|
|
|
// - (int) getPidTagSentRepresentingAddressType: (void **) data
|
|
|
|
// inMemCtx: (TALLOC_CTX *) memCtx
|
|
|
|
// {
|
|
|
|
// return [self getSMTPAddrType: data inMemCtx: memCtx];
|
|
|
|
// }
|
2011-10-03 22:55:02 +02:00
|
|
|
|
2012-07-19 22:26:33 +02:00
|
|
|
// - (int) getPidTagSentRepresentingName: (void **) data
|
|
|
|
// inMemCtx: (TALLOC_CTX *) memCtx
|
|
|
|
// {
|
|
|
|
// return [self getPidTagSenderName: data inMemCtx: memCtx];
|
|
|
|
// }
|
2011-10-03 22:55:02 +02:00
|
|
|
|
2012-07-19 22:26:33 +02:00
|
|
|
// - (int) getPidTagSentRepresentingEntryId: (void **) data
|
|
|
|
// inMemCtx: (TALLOC_CTX *) memCtx
|
|
|
|
// {
|
|
|
|
// 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-07-20 17:42:52 +02:00
|
|
|
// return [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-07-20 17:42:52 +02:00
|
|
|
// return [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-07-20 17:42:52 +02:00
|
|
|
// return [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-07-20 17:42:52 +02:00
|
|
|
// return [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];
|
|
|
|
}
|
|
|
|
|
|
|
|
- (NSString *) _uidFromGlobalObjectId
|
|
|
|
{
|
|
|
|
NSData *objectId;
|
|
|
|
NSString *uid = nil;
|
|
|
|
char *bytesDup, *uidStart;
|
|
|
|
NSUInteger length;
|
|
|
|
|
|
|
|
/* NOTE: we only handle the generic case at the moment, see
|
|
|
|
MAPIStoreAppointmentWrapper */
|
2012-07-20 17:42:52 +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-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
|
|
|
{
|
2011-04-13 21:59:04 +02:00
|
|
|
iCalEvent *newEvent;
|
2012-03-12 01:06:06 +01:00
|
|
|
// iCalPerson *userPerson;
|
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:
|
2012-07-20 17:42:52 +02:00
|
|
|
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. */
|
2012-03-12 01:06:06 +01:00
|
|
|
[self _fixupAppointmentObjectWithUID: uid];
|
|
|
|
}
|
|
|
|
else
|
|
|
|
uid = [SOGoObject globallyUniqueObjectId];
|
2012-07-20 17:42:52 +02:00
|
|
|
[masterEvent setUid: uid];
|
|
|
|
[sogoObject setNameInContainer:
|
|
|
|
[NSString stringWithFormat: @"%@.ics", uid]];
|
2011-10-03 22:55:02 +02:00
|
|
|
}
|
|
|
|
|
2012-07-20 17:42:52 +02:00
|
|
|
// [self logWithFormat: @"-save, event props:"];
|
2011-02-24 21:30:01 +01:00
|
|
|
// MAPIStoreDumpMessageProperties (newProperties);
|
|
|
|
|
2012-07-20 17:42:52 +02:00
|
|
|
// now = [NSCalendarDate date];
|
2011-08-08 21:02:49 +02:00
|
|
|
|
2012-07-20 17:42:52 +02:00
|
|
|
activeUser = [[self context] activeUser];
|
|
|
|
[masterEvent updateFromMAPIProperties: properties
|
|
|
|
inUserContext: [self userContext]
|
|
|
|
withActiveUser: activeUser];
|
|
|
|
[sogoObject updateContentWithCalendar: calendar
|
|
|
|
fromRequest: nil];
|
2012-03-12 01:06:06 +01:00
|
|
|
|
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
|
2012-06-29 19:59:38 +02:00
|
|
|
mapiStoreObjectInContainer: self];
|
2011-04-01 00:59:12 +02:00
|
|
|
[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
|