2011-02-24 21:30:01 +01:00
|
|
|
/* MAPIStoreTasksMessage.m - this file is part of SOGo
|
|
|
|
*
|
|
|
|
* Copyright (C) 2011 Inverse inc
|
|
|
|
*
|
|
|
|
* 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 <Foundation/NSArray.h>
|
2012-01-12 14:39:18 +01:00
|
|
|
#import <Foundation/NSCalendarDate.h>
|
2011-02-24 21:30:01 +01:00
|
|
|
#import <Foundation/NSDictionary.h>
|
|
|
|
#import <Foundation/NSString.h>
|
2012-01-12 14:39:18 +01:00
|
|
|
#import <Foundation/NSTimeZone.h>
|
2011-02-24 21:30:01 +01:00
|
|
|
#import <NGObjWeb/WOContext+SoObjects.h>
|
|
|
|
#import <NGExtensions/NSObject+Logs.h>
|
|
|
|
#import <NGCards/iCalCalendar.h>
|
|
|
|
#import <NGCards/iCalDateTime.h>
|
|
|
|
#import <NGCards/iCalTimeZone.h>
|
|
|
|
#import <NGCards/iCalToDo.h>
|
|
|
|
#import <NGCards/iCalPerson.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>
|
|
|
|
#import <SOGo/SOGoUserDefaults.h>
|
2011-12-01 23:20:22 +01:00
|
|
|
#import <Appointments/iCalEntityObject+SOGo.h>
|
2011-09-23 17:36:49 +02:00
|
|
|
#import <Appointments/SOGoTaskObject.h>
|
2012-03-26 21:25:14 +02:00
|
|
|
#import <Mailer/NSString+Mail.h>
|
2011-02-24 21:30:01 +01:00
|
|
|
|
2011-12-01 23:20:22 +01:00
|
|
|
#import "MAPIStoreContext.h"
|
2011-08-12 20:41:25 +02:00
|
|
|
#import "MAPIStoreTasksFolder.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-07-20 20:28:37 +02:00
|
|
|
#import "NSObject+MAPIStore.h"
|
2011-02-24 21:30:01 +01:00
|
|
|
#import "NSString+MAPIStore.h"
|
|
|
|
|
|
|
|
#import "MAPIStoreTasksMessage.h"
|
|
|
|
|
|
|
|
#undef DEBUG
|
|
|
|
#include <stdbool.h>
|
|
|
|
#include <gen_ndr/exchange.h>
|
|
|
|
#include <mapistore/mapistore.h>
|
2011-03-07 20:15:16 +01:00
|
|
|
#include <mapistore/mapistore_errors.h>
|
2011-02-24 21:30:01 +01:00
|
|
|
#include <mapistore/mapistore_nameid.h>
|
|
|
|
|
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-03-02 21:44:24 +01:00
|
|
|
- (int) getPidTagSubject: (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-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;
|
|
|
|
}
|
|
|
|
|
2011-02-24 21:30:01 +01:00
|
|
|
- (void) save
|
|
|
|
{
|
|
|
|
iCalCalendar *vCalendar;
|
|
|
|
iCalToDo *vToDo;
|
|
|
|
id value;
|
|
|
|
iCalDateTime *date;
|
2012-01-12 14:39:18 +01:00
|
|
|
NSString *status, *priority;
|
2011-02-24 21:30:01 +01:00
|
|
|
NSCalendarDate *now;
|
2012-01-12 14:39:18 +01:00
|
|
|
NSInteger tzOffset;
|
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"];
|
|
|
|
|
|
|
|
// 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];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (value && [value length] == 0)
|
|
|
|
value = nil;
|
|
|
|
[vToDo setComment: value];
|
|
|
|
|
2011-02-24 21:30:01 +01:00
|
|
|
if (value)
|
|
|
|
[vToDo setComment: value];
|
|
|
|
|
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-01-12 14:39:18 +01:00
|
|
|
tzOffset = [[value timeZone] secondsFromGMTForDate: value];
|
|
|
|
value = [value dateByAddingYears: 0 months: 0 days: 0
|
|
|
|
hours: 0 minutes: 0
|
|
|
|
seconds: -tzOffset];
|
|
|
|
[date setDate: value];
|
2011-02-24 21:30:01 +01:00
|
|
|
}
|
2011-09-14 20:33:44 +02:00
|
|
|
else
|
|
|
|
{
|
|
|
|
[vToDo setStartDate: nil];
|
|
|
|
}
|
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-01-12 14:39:18 +01:00
|
|
|
tzOffset = [[value timeZone] secondsFromGMTForDate: value];
|
|
|
|
value = [value dateByAddingYears: 0 months: 0 days: 0
|
|
|
|
hours: 0 minutes: 0
|
|
|
|
seconds: -tzOffset];
|
|
|
|
[date setDate: value];
|
2011-02-24 21:30:01 +01:00
|
|
|
}
|
2011-09-14 20:33:44 +02:00
|
|
|
else
|
|
|
|
{
|
|
|
|
[vToDo setDue: nil];
|
|
|
|
}
|
|
|
|
|
|
|
|
// 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"];
|
2012-01-12 14:39:18 +01:00
|
|
|
tzOffset = [[value timeZone] secondsFromGMTForDate: value];
|
|
|
|
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
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
[vToDo setCompleted: nil];
|
|
|
|
}
|
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";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
priority = @"0"; // None
|
|
|
|
[vToDo setPriority: priority];
|
|
|
|
|
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
|
|
|
|
2011-02-24 21:30:01 +01:00
|
|
|
now = [NSCalendarDate date];
|
|
|
|
if ([sogoObject isNew])
|
|
|
|
{
|
|
|
|
[vToDo setCreated: now];
|
|
|
|
}
|
|
|
|
[vToDo setTimeStampAsDate: now];
|
|
|
|
|
|
|
|
[sogoObject saveContentString: [vCalendar versitString]];
|
2012-03-16 22:05:41 +01:00
|
|
|
|
|
|
|
[self updateVersions];
|
2011-02-24 21:30:01 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
@end
|