2011-02-24 21:30:01 +01:00
|
|
|
/* MAPIStoreTasksMessage.m - this file is part of SOGo
|
|
|
|
*
|
2012-08-17 21:04:57 +02:00
|
|
|
* Copyright (C) 2011-2012 Inverse inc
|
2011-02-24 21:30:01 +01:00
|
|
|
*
|
|
|
|
* Author: Wolfgang Sourdeau <wsourdeau@inverse.ca>
|
2011-09-14 20:33:44 +02:00
|
|
|
* Ludovic Marcotte <lmarcotte@inverse.ca>
|
2011-02-24 21:30:01 +01:00
|
|
|
*
|
|
|
|
* 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.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#import <NGObjWeb/WOContext+SoObjects.h>
|
|
|
|
#import <NGExtensions/NSObject+Logs.h>
|
2011-12-01 23:20:22 +01:00
|
|
|
#import <Appointments/iCalEntityObject+SOGo.h>
|
2012-03-26 21:25:14 +02:00
|
|
|
#import <Mailer/NSString+Mail.h>
|
2011-02-24 21:30:01 +01:00
|
|
|
|
2011-05-30 23:12:56 +02:00
|
|
|
#import "NSDate+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"
|
|
|
|
|
|
|
|
|
|
|
|
#undef DEBUG
|
|
|
|
|
2011-09-23 17:36:49 +02:00
|
|
|
@implementation SOGoTaskObject (MAPIStoreExtension)
|
|
|
|
|
|
|
|
- (Class) mapistoreMessageClass
|
|
|
|
{
|
|
|
|
return [MAPIStoreTasksMessage class];
|
|
|
|
}
|
|
|
|
|
|
|
|
@end
|
|
|
|
|
2011-02-24 21:30:01 +01:00
|
|
|
@implementation MAPIStoreTasksMessage
|
|
|
|
|
2012-03-02 21:44:24 +01:00
|
|
|
- (int) getPidTagIconIndex: (void **) data // TODO
|
|
|
|
inMemCtx: (TALLOC_CTX *) memCtx
|
2011-04-13 21:59:04 +02:00
|
|
|
{
|
|
|
|
/* see http://msdn.microsoft.com/en-us/library/cc815472.aspx */
|
|
|
|
// Unassigned recurring task 0x00000501
|
|
|
|
// Assignee's task 0x00000502
|
|
|
|
// Assigner's task 0x00000503
|
|
|
|
// Task request 0x00000504
|
|
|
|
// Task acceptance 0x00000505
|
|
|
|
// Task rejection 0x00000506
|
|
|
|
*data = MAPILongValue (memCtx, 0x00000500);
|
|
|
|
|
|
|
|
return MAPISTORE_SUCCESS;
|
|
|
|
}
|
|
|
|
|
2012-03-02 21:44:24 +01:00
|
|
|
- (int) getPidTagMessageClass: (void **) data
|
|
|
|
inMemCtx: (TALLOC_CTX *) memCtx
|
2011-04-13 21:59:04 +02:00
|
|
|
{
|
|
|
|
*data = talloc_strdup(memCtx, "IPM.Task");
|
|
|
|
|
|
|
|
return MAPISTORE_SUCCESS;
|
|
|
|
}
|
|
|
|
|
2012-07-20 16:13:56 +02:00
|
|
|
- (int) getPidTagNormalizedSubject: (void **) data // SUMMARY
|
|
|
|
inMemCtx: (TALLOC_CTX *) memCtx
|
2011-04-13 21:59:04 +02:00
|
|
|
{
|
2011-06-07 02:17:46 +02:00
|
|
|
iCalToDo *task;
|
|
|
|
|
2011-12-01 23:20:22 +01:00
|
|
|
task = [sogoObject component: NO secure: YES];
|
2011-04-13 21:59:04 +02:00
|
|
|
*data = [[task summary] asUnicodeInMemCtx: memCtx];
|
|
|
|
|
|
|
|
return MAPISTORE_SUCCESS;
|
|
|
|
}
|
|
|
|
|
2012-09-17 12:06:18 +02:00
|
|
|
/* FIXME: Should be combined somehow with the code in MAPIStoreAppointmentWrapper.m */
|
2012-09-12 12:16:20 +02:00
|
|
|
- (int) getPidTagBody: (void **) data
|
|
|
|
inMemCtx: (TALLOC_CTX *) memCtx
|
|
|
|
{
|
|
|
|
int rc = MAPISTORE_SUCCESS;
|
|
|
|
NSString *stringValue;
|
|
|
|
iCalToDo *task;
|
|
|
|
|
|
|
|
/* FIXME: there is a confusion in NGCards around "comment" and "description" */
|
|
|
|
task = [sogoObject component: NO secure: YES];
|
|
|
|
stringValue = [task comment];
|
|
|
|
if ([stringValue length] > 0)
|
|
|
|
*data = [stringValue asUnicodeInMemCtx: memCtx];
|
|
|
|
else
|
|
|
|
*data = [@"" asUnicodeInMemCtx: memCtx];
|
|
|
|
|
|
|
|
return rc;
|
|
|
|
}
|
|
|
|
|
2012-09-17 12:06:18 +02:00
|
|
|
/* FIXME: Should be combined somehow with the code in MAPIStoreAppointmentWrapper.m */
|
|
|
|
- (int) getPidLidPrivate: (void **) data // private (bool), should depend on CLASS and permissions
|
|
|
|
inMemCtx: (TALLOC_CTX *) memCtx
|
|
|
|
{
|
|
|
|
iCalToDo *task;
|
|
|
|
|
|
|
|
task = [sogoObject component: NO secure: YES];
|
|
|
|
|
|
|
|
if ([task symbolicAccessClass] == iCalAccessPublic)
|
|
|
|
return [self getNo: data inMemCtx: memCtx];
|
|
|
|
|
|
|
|
return [self getYes: data inMemCtx: memCtx];
|
|
|
|
}
|
|
|
|
|
2012-03-02 21:44:24 +01:00
|
|
|
- (int) getPidTagImportance: (void **) data
|
|
|
|
inMemCtx: (TALLOC_CTX *) memCtx
|
2011-04-13 21:59:04 +02:00
|
|
|
{
|
|
|
|
uint32_t v;
|
2011-06-07 02:17:46 +02:00
|
|
|
iCalToDo *task;
|
|
|
|
|
2011-12-01 23:20:22 +01:00
|
|
|
task = [sogoObject component: NO secure: YES];
|
2011-04-13 21:59:04 +02:00
|
|
|
if ([[task priority] isEqualToString: @"9"])
|
|
|
|
v = 0x0;
|
|
|
|
else if ([[task priority] isEqualToString: @"1"])
|
|
|
|
v = 0x2;
|
|
|
|
else
|
|
|
|
v = 0x1;
|
|
|
|
|
|
|
|
*data = MAPILongValue (memCtx, v);
|
|
|
|
|
|
|
|
return MAPISTORE_SUCCESS;
|
|
|
|
}
|
|
|
|
|
|
|
|
- (int) getPidLidTaskComplete: (void **) data
|
2011-07-11 23:40:47 +02:00
|
|
|
inMemCtx: (TALLOC_CTX *) memCtx
|
2011-04-13 21:59:04 +02:00
|
|
|
{
|
2011-06-07 02:17:46 +02:00
|
|
|
iCalToDo *task;
|
|
|
|
|
2011-12-01 23:20:22 +01:00
|
|
|
task = [sogoObject component: NO secure: YES];
|
2011-04-13 21:59:04 +02:00
|
|
|
*data = MAPIBoolValue (memCtx,
|
|
|
|
[[task status] isEqualToString: @"COMPLETED"]);
|
|
|
|
|
|
|
|
return MAPISTORE_SUCCESS;
|
|
|
|
}
|
|
|
|
|
|
|
|
- (int) getPidLidPercentComplete: (void **) data
|
2011-07-11 23:40:47 +02:00
|
|
|
inMemCtx: (TALLOC_CTX *) memCtx
|
2011-04-13 21:59:04 +02:00
|
|
|
{
|
|
|
|
double doubleValue;
|
2011-06-07 02:17:46 +02:00
|
|
|
iCalToDo *task;
|
|
|
|
|
2011-12-01 23:20:22 +01:00
|
|
|
task = [sogoObject component: NO secure: YES];
|
2011-04-13 21:59:04 +02:00
|
|
|
|
|
|
|
doubleValue = ((double) [[task percentComplete] intValue] / 100);
|
|
|
|
*data = MAPIDoubleValue (memCtx, doubleValue);
|
|
|
|
|
|
|
|
return MAPISTORE_SUCCESS;
|
|
|
|
}
|
|
|
|
|
|
|
|
- (int) getPidLidTaskDateCompleted: (void **) data
|
2011-07-11 23:40:47 +02:00
|
|
|
inMemCtx: (TALLOC_CTX *) memCtx
|
2011-04-13 21:59:04 +02:00
|
|
|
{
|
|
|
|
int rc = MAPISTORE_SUCCESS;
|
2011-06-07 02:17:46 +02:00
|
|
|
NSCalendarDate *dateValue;
|
|
|
|
iCalToDo *task;
|
|
|
|
|
2011-12-01 23:20:22 +01:00
|
|
|
task = [sogoObject component: NO secure: YES];
|
2011-04-13 21:59:04 +02:00
|
|
|
|
|
|
|
dateValue = [task completed];
|
|
|
|
if (dateValue)
|
|
|
|
*data = [dateValue asFileTimeInMemCtx: memCtx];
|
|
|
|
else
|
|
|
|
rc = MAPISTORE_ERR_NOT_FOUND;
|
|
|
|
|
2011-02-24 21:30:01 +01:00
|
|
|
return rc;
|
|
|
|
}
|
|
|
|
|
2011-04-13 21:59:04 +02:00
|
|
|
- (int) getPidLidTaskState: (void **) data
|
2011-07-11 23:40:47 +02:00
|
|
|
inMemCtx: (TALLOC_CTX *) memCtx
|
2011-04-13 21:59:04 +02:00
|
|
|
{
|
|
|
|
*data = MAPILongValue (memCtx, 0x1); // not assigned
|
|
|
|
|
|
|
|
return MAPISTORE_SUCCESS;
|
|
|
|
}
|
|
|
|
|
|
|
|
- (int) getPidLidTaskMode: (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-11 23:40:47 +02:00
|
|
|
return [self getLongZero: data inMemCtx: memCtx];
|
2011-04-13 21:59:04 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
- (int) getPidLidTaskFRecurring: (void **) data
|
2011-07-11 23:40:47 +02:00
|
|
|
inMemCtx: (TALLOC_CTX *) memCtx
|
2011-04-13 21:59:04 +02:00
|
|
|
{
|
2011-07-11 23:40:47 +02:00
|
|
|
return [self getNo: data inMemCtx: memCtx];
|
2011-04-13 21:59:04 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
- (int) getPidLidTaskAccepted: (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-11 23:40:47 +02:00
|
|
|
return [self getNo: data inMemCtx: memCtx];
|
2011-04-13 21:59:04 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
- (int) getPidLidTaskActualEffort: (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-11 23:40:47 +02:00
|
|
|
return [self getLongZero: data inMemCtx: memCtx];
|
2011-04-13 21:59:04 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
- (int) getPidLidTaskEstimatedEffort: (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-11 23:40:47 +02:00
|
|
|
return [self getLongZero: data inMemCtx: memCtx];
|
2011-04-13 21:59:04 +02:00
|
|
|
}
|
|
|
|
|
2012-03-02 21:44:24 +01:00
|
|
|
- (int) getPidTagHasAttachments: (void **) data
|
|
|
|
inMemCtx: (TALLOC_CTX *) memCtx
|
2011-04-13 21:59:04 +02:00
|
|
|
{
|
2011-07-11 23:40:47 +02:00
|
|
|
return [self getNo: data inMemCtx: memCtx];
|
2011-04-13 21:59:04 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
- (int) getPidLidTaskDueDate: (void **) data
|
2011-07-11 23:40:47 +02:00
|
|
|
inMemCtx: (TALLOC_CTX *) memCtx
|
2011-04-13 21:59:04 +02:00
|
|
|
{
|
|
|
|
int rc = MAPISTORE_SUCCESS;
|
2011-06-07 02:17:46 +02:00
|
|
|
NSCalendarDate *dateValue;
|
|
|
|
iCalToDo *task;
|
2011-04-13 21:59:04 +02:00
|
|
|
|
2011-12-01 23:20:22 +01:00
|
|
|
task = [sogoObject component: NO secure: YES];
|
2011-04-13 21:59:04 +02:00
|
|
|
dateValue = [task due];
|
|
|
|
if (dateValue)
|
|
|
|
*data = [dateValue asFileTimeInMemCtx: memCtx];
|
|
|
|
else
|
|
|
|
rc = MAPISTORE_ERR_NOT_FOUND;
|
|
|
|
|
2011-06-07 02:17:46 +02:00
|
|
|
return rc;
|
2011-04-13 21:59:04 +02:00
|
|
|
}
|
|
|
|
|
2011-09-14 20:33:44 +02:00
|
|
|
- (int) getPidLidTaskStartDate: (void **) data
|
|
|
|
inMemCtx: (TALLOC_CTX *) memCtx
|
|
|
|
{
|
|
|
|
int rc = MAPISTORE_SUCCESS;
|
|
|
|
NSCalendarDate *dateValue;
|
|
|
|
iCalToDo *task;
|
|
|
|
|
2011-12-01 23:20:22 +01:00
|
|
|
task = [sogoObject component: NO secure: YES];
|
2011-09-14 20:33:44 +02:00
|
|
|
dateValue = [task startDate];
|
|
|
|
if (dateValue)
|
|
|
|
*data = [dateValue asFileTimeInMemCtx: memCtx];
|
|
|
|
else
|
|
|
|
rc = MAPISTORE_ERR_NOT_FOUND;
|
|
|
|
|
|
|
|
return rc;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2012-03-02 21:44:24 +01:00
|
|
|
- (int) getPidTagMessageDeliveryTime: (void **) data
|
|
|
|
inMemCtx: (TALLOC_CTX *) memCtx
|
2011-04-13 21:59:04 +02:00
|
|
|
{
|
2012-03-02 21:44:24 +01:00
|
|
|
return [self getPidTagLastModificationTime: data inMemCtx: memCtx];
|
2011-04-13 21:59:04 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
- (int) getClientSubmitTime: (void **) data
|
2011-07-11 23:40:47 +02:00
|
|
|
inMemCtx: (TALLOC_CTX *) memCtx
|
2011-04-13 21:59:04 +02:00
|
|
|
{
|
2012-03-02 21:44:24 +01:00
|
|
|
return [self getPidTagLastModificationTime: data inMemCtx: memCtx];
|
2011-04-13 21:59:04 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
- (int) getLocalCommitTime: (void **) data
|
2011-07-11 23:40:47 +02:00
|
|
|
inMemCtx: (TALLOC_CTX *) memCtx
|
2011-04-13 21:59:04 +02:00
|
|
|
{
|
2012-03-02 21:44:24 +01:00
|
|
|
return [self getPidTagLastModificationTime: data inMemCtx: memCtx];
|
2011-04-13 21:59:04 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
- (int) getPidLidTaskStatus: (void **) data // status
|
2011-07-11 23:40:47 +02:00
|
|
|
inMemCtx: (TALLOC_CTX *) memCtx
|
2011-04-13 21:59:04 +02:00
|
|
|
{
|
|
|
|
NSString *status;
|
|
|
|
uint32_t longValue;
|
2011-06-07 02:17:46 +02:00
|
|
|
iCalToDo *task;
|
2011-04-13 21:59:04 +02:00
|
|
|
|
2011-12-01 23:20:22 +01:00
|
|
|
task = [sogoObject component: NO secure: YES];
|
2011-04-13 21:59:04 +02:00
|
|
|
status = [task status];
|
|
|
|
if (![status length]
|
|
|
|
|| [status isEqualToString: @"NEEDS-ACTION"])
|
|
|
|
longValue = 0;
|
|
|
|
else if ([status isEqualToString: @"IN-PROCESS"])
|
|
|
|
longValue = 1;
|
|
|
|
else if ([status isEqualToString: @"COMPLETED"])
|
|
|
|
longValue = 2;
|
|
|
|
else
|
|
|
|
longValue = 0xff;
|
|
|
|
*data = MAPILongValue (memCtx, longValue);
|
|
|
|
|
|
|
|
return MAPISTORE_SUCCESS;
|
|
|
|
}
|
|
|
|
|
|
|
|
- (int) getPidLidTaskOwner: (void **) data
|
2011-07-11 23:40:47 +02:00
|
|
|
inMemCtx: (TALLOC_CTX *) memCtx
|
2011-04-13 21:59:04 +02:00
|
|
|
{
|
2011-09-14 20:33:44 +02:00
|
|
|
NSString *owner;
|
|
|
|
|
|
|
|
owner = [sogoObject ownerInContext: nil];
|
|
|
|
|
|
|
|
*data = [owner asUnicodeInMemCtx: memCtx];
|
2011-04-13 21:59:04 +02:00
|
|
|
|
|
|
|
return MAPISTORE_SUCCESS;
|
|
|
|
}
|
|
|
|
|
|
|
|
- (int) getPidLidTaskOwnership: (void **) data
|
2011-07-11 23:40:47 +02:00
|
|
|
inMemCtx: (TALLOC_CTX *) memCtx
|
2011-04-13 21:59:04 +02:00
|
|
|
{
|
2011-07-11 23:40:47 +02:00
|
|
|
return [self getLongZero: data inMemCtx: memCtx];
|
2011-04-13 21:59:04 +02:00
|
|
|
}
|
|
|
|
|
2011-12-01 22:13:09 +01:00
|
|
|
- (BOOL) subscriberCanReadMessage
|
|
|
|
{
|
|
|
|
return ([[self activeUserRoles]
|
|
|
|
containsObject: SOGoCalendarRole_ComponentViewer]
|
|
|
|
|| [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;
|
|
|
|
}
|
|
|
|
|
2013-04-16 18:06:17 +02:00
|
|
|
- (void) save:(TALLOC_CTX *) memCtx
|
2011-02-24 21:30:01 +01:00
|
|
|
{
|
|
|
|
iCalCalendar *vCalendar;
|
|
|
|
iCalToDo *vToDo;
|
|
|
|
id value;
|
|
|
|
iCalDateTime *date;
|
2012-03-30 21:58:16 +02:00
|
|
|
iCalTimeZone *tz;
|
|
|
|
NSString *status, *priority, *tzName;
|
2011-02-24 21:30:01 +01:00
|
|
|
NSCalendarDate *now;
|
2012-01-12 14:39:18 +01:00
|
|
|
NSInteger tzOffset;
|
2015-01-16 00:09:01 +01:00
|
|
|
NSTimeZone *userTZ;
|
2012-03-22 16:23:59 +01:00
|
|
|
double doubleValue;
|
2011-02-24 21:30:01 +01:00
|
|
|
|
|
|
|
vToDo = [sogoObject component: YES secure: NO];
|
|
|
|
vCalendar = [vToDo parent];
|
|
|
|
[vCalendar setProdID: @"-//Inverse inc.//OpenChange+SOGo//EN"];
|
|
|
|
|
2015-01-16 00:09:01 +01:00
|
|
|
userTZ = [[self userContext] timeZone];
|
|
|
|
tzName = [userTZ name];
|
2012-03-30 21:58:16 +02:00
|
|
|
tz = [iCalTimeZone timeZoneForName: tzName];
|
|
|
|
[vCalendar addTimeZone: tz];
|
|
|
|
|
2011-02-24 21:30:01 +01:00
|
|
|
// summary
|
2011-10-26 17:15:17 +02:00
|
|
|
value = [properties
|
2011-02-24 21:30:01 +01:00
|
|
|
objectForKey: MAPIPropertyKey (PR_NORMALIZED_SUBJECT_UNICODE)];
|
|
|
|
if (value)
|
|
|
|
[vToDo setSummary: value];
|
|
|
|
|
|
|
|
// comment
|
2011-10-26 17:15:17 +02:00
|
|
|
value = [properties
|
2011-02-24 21:30:01 +01:00
|
|
|
objectForKey: MAPIPropertyKey (PR_BODY_UNICODE)];
|
2012-03-26 21:25:14 +02:00
|
|
|
if (!value)
|
|
|
|
{
|
|
|
|
value = [properties objectForKey: MAPIPropertyKey (PR_HTML)];
|
|
|
|
if (value)
|
|
|
|
{
|
|
|
|
value = [[NSString alloc] initWithData: value
|
|
|
|
encoding: NSUTF8StringEncoding];
|
|
|
|
[value autorelease];
|
|
|
|
value = [value htmlToText];
|
|
|
|
}
|
|
|
|
}
|
2011-02-24 21:30:01 +01:00
|
|
|
if (value)
|
2012-03-30 21:58:16 +02:00
|
|
|
{
|
2012-03-30 22:02:33 +02:00
|
|
|
if ([value length] == 0 || [value isEqualToString: @"\\n"])
|
2012-03-30 21:58:16 +02:00
|
|
|
value = nil;
|
|
|
|
[vToDo setComment: value];
|
|
|
|
}
|
2011-02-24 21:30:01 +01:00
|
|
|
|
2011-09-14 20:33:44 +02:00
|
|
|
// location
|
2011-10-26 17:15:17 +02:00
|
|
|
value = [properties objectForKey: MAPIPropertyKey (PidLidLocation)];
|
2011-02-24 21:30:01 +01:00
|
|
|
if (value)
|
|
|
|
[vToDo setLocation: value];
|
|
|
|
|
2011-09-14 20:33:44 +02:00
|
|
|
// created
|
2011-10-26 17:15:17 +02:00
|
|
|
value = [properties objectForKey: MAPIPropertyKey (PR_CREATION_TIME)];
|
2011-02-24 21:30:01 +01:00
|
|
|
if (value)
|
|
|
|
[vToDo setCreated: value];
|
|
|
|
|
2011-09-14 20:33:44 +02:00
|
|
|
// last-modified + dtstamp
|
2011-10-26 17:15:17 +02:00
|
|
|
value = [properties objectForKey: MAPIPropertyKey (PR_LAST_MODIFICATION_TIME)];
|
2011-02-24 21:30:01 +01:00
|
|
|
if (value)
|
|
|
|
{
|
|
|
|
[vToDo setLastModified: value];
|
|
|
|
[vToDo setTimeStampAsDate: value];
|
|
|
|
}
|
|
|
|
|
|
|
|
// start
|
2011-10-26 17:15:17 +02:00
|
|
|
value = [properties objectForKey: MAPIPropertyKey (PidLidTaskStartDate)];
|
2011-02-24 21:30:01 +01:00
|
|
|
if (value)
|
|
|
|
{
|
|
|
|
date = (iCalDateTime *) [vToDo uniqueChildWithTag: @"dtstart"];
|
2012-03-30 21:58:16 +02:00
|
|
|
[date setTimeZone: tz];
|
2015-01-16 00:09:01 +01:00
|
|
|
/* The property is set to user's local time zone.
|
|
|
|
See: [MS-OXOTASK] 2.2.2.2.4
|
|
|
|
TODO: Ignore when the PT_SYSTIME is 0x5AE980E0*/
|
|
|
|
tzOffset = [userTZ secondsFromGMTForDate: value];
|
|
|
|
value = [value dateByAddingYears: 0 months: 0 days: 0
|
|
|
|
hours: 0 minutes: 0
|
|
|
|
seconds: -tzOffset];
|
2012-03-30 21:58:16 +02:00
|
|
|
[date setDateTime: value];
|
2011-09-14 20:33:44 +02:00
|
|
|
}
|
2012-03-30 21:58:16 +02:00
|
|
|
|
2011-02-24 21:30:01 +01:00
|
|
|
// due
|
2011-10-26 17:15:17 +02:00
|
|
|
value = [properties objectForKey: MAPIPropertyKey (PidLidTaskDueDate)];
|
2011-02-24 21:30:01 +01:00
|
|
|
if (value)
|
|
|
|
{
|
|
|
|
date = (iCalDateTime *) [vToDo uniqueChildWithTag: @"due"];
|
2012-03-30 21:58:16 +02:00
|
|
|
[date setTimeZone: tz];
|
2015-01-16 00:09:01 +01:00
|
|
|
/* The property is set to user's local time zone.
|
|
|
|
See: [MS-OXOTASK] 2.2.2.2.5
|
|
|
|
TODO: Ignore when the PT_SYSTIME is 0x5AE980E0*/
|
|
|
|
tzOffset = [userTZ secondsFromGMTForDate: value];
|
|
|
|
value = [value dateByAddingYears: 0 months: 0 days: 0
|
|
|
|
hours: 0 minutes: 0
|
|
|
|
seconds: -tzOffset];
|
2012-03-30 21:58:16 +02:00
|
|
|
[date setDateTime: value];
|
2011-09-14 20:33:44 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
// completed
|
2011-10-26 17:15:17 +02:00
|
|
|
value = [properties objectForKey: MAPIPropertyKey (PidLidTaskDateCompleted)];
|
2011-09-14 20:33:44 +02:00
|
|
|
if (value)
|
|
|
|
{
|
|
|
|
date = (iCalDateTime *) [vToDo uniqueChildWithTag: @"completed"];
|
2015-01-16 00:09:01 +01:00
|
|
|
/* The property is set to midnight in local time zone converted to UTC:
|
|
|
|
See: [MS-OXOTASK] 2.2.2.2.9 */
|
|
|
|
tzOffset = [userTZ secondsFromGMTForDate: value];
|
2012-01-12 14:39:18 +01:00
|
|
|
value = [value dateByAddingYears: 0 months: 0 days: 0
|
|
|
|
hours: 0 minutes: 0
|
|
|
|
seconds: -tzOffset];
|
|
|
|
[date setDate: value];
|
2011-09-14 20:33:44 +02:00
|
|
|
}
|
2011-02-24 21:30:01 +01:00
|
|
|
|
|
|
|
// status
|
2011-10-26 17:15:17 +02:00
|
|
|
value = [properties objectForKey: MAPIPropertyKey (PidLidTaskStatus)];
|
2011-02-24 21:30:01 +01:00
|
|
|
if (value)
|
|
|
|
{
|
|
|
|
switch ([value intValue])
|
|
|
|
{
|
|
|
|
case 1: status = @"IN-PROCESS"; break;
|
|
|
|
case 2: status = @"COMPLETED"; break;
|
|
|
|
default: status = @"NEEDS-ACTION";
|
|
|
|
}
|
|
|
|
[vToDo setStatus: status];
|
|
|
|
}
|
|
|
|
|
|
|
|
// priority
|
2011-10-26 17:15:17 +02:00
|
|
|
value = [properties objectForKey: MAPIPropertyKey (PR_IMPORTANCE)];
|
2011-02-24 21:30:01 +01: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";
|
|
|
|
}
|
2012-03-30 21:58:16 +02:00
|
|
|
[vToDo setPriority: priority];
|
2011-02-24 21:30:01 +01:00
|
|
|
}
|
|
|
|
|
2011-09-14 20:33:44 +02:00
|
|
|
// percent complete
|
|
|
|
// NOTE: this does not seem to work on Outlook 2003. PidLidPercentComplete's value
|
|
|
|
// is always set to 0, no matter what value is set in Outlook
|
2012-03-16 22:10:48 +01:00
|
|
|
value = [properties objectForKey: MAPIPropertyKey (PidLidPercentComplete)];
|
2011-09-14 20:33:44 +02:00
|
|
|
if (value)
|
2012-03-22 16:23:59 +01:00
|
|
|
{
|
|
|
|
doubleValue = [value doubleValue];
|
|
|
|
[vToDo setPercentComplete:
|
|
|
|
[NSString stringWithFormat: @"%d", (int) (doubleValue * 100)]];
|
|
|
|
}
|
2011-09-14 20:33:44 +02:00
|
|
|
|
2012-09-17 12:06:18 +02:00
|
|
|
/* privacy */
|
|
|
|
/* FIXME: this should be combined with the code found in iCalEvent+MAPIStore.m */
|
|
|
|
value = [properties objectForKey: MAPIPropertyKey(PidLidPrivate)];
|
|
|
|
|
|
|
|
if (value)
|
|
|
|
{
|
|
|
|
if ([value boolValue])
|
|
|
|
[vToDo setAccessClass: @"PRIVATE"];
|
|
|
|
else
|
|
|
|
[vToDo setAccessClass: @"PUBLIC"];
|
|
|
|
}
|
|
|
|
|
2011-02-24 21:30:01 +01:00
|
|
|
now = [NSCalendarDate date];
|
|
|
|
if ([sogoObject isNew])
|
|
|
|
{
|
|
|
|
[vToDo setCreated: now];
|
|
|
|
}
|
|
|
|
[vToDo setTimeStampAsDate: now];
|
|
|
|
|
2015-09-10 17:26:41 +02:00
|
|
|
[sogoObject saveCalendar: vCalendar];
|
2012-03-16 22:05:41 +01:00
|
|
|
|
|
|
|
[self updateVersions];
|
2011-02-24 21:30:01 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
@end
|