2010-11-20 00:01:33 +01:00
|
|
|
/* SOGoTaskObject+MAPIStore.m - this file is part of SOGo
|
|
|
|
*
|
|
|
|
* Copyright (C) 2010 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
|
2010-12-13 17:53:32 +01:00
|
|
|
* the Free Software Foundation; either version 3, or (at your option)
|
2010-11-20 00:01:33 +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.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <stdbool.h>
|
|
|
|
#include <gen_ndr/exchange.h>
|
2010-12-30 15:53:11 +01:00
|
|
|
#include <mapistore/mapistore_nameid.h>
|
2010-11-20 00:01:33 +01:00
|
|
|
|
|
|
|
#import <Foundation/NSDictionary.h>
|
|
|
|
#import <Foundation/NSTimeZone.h>
|
|
|
|
#import <Foundation/NSString.h>
|
|
|
|
|
|
|
|
#import <NGExtensions/NSObject+Logs.h>
|
|
|
|
|
|
|
|
#import <NGCards/iCalCalendar.h>
|
|
|
|
#import <NGCards/iCalDateTime.h>
|
|
|
|
#import <NGCards/iCalEvent.h>
|
|
|
|
#import <NGCards/iCalTimeZone.h>
|
|
|
|
|
|
|
|
#import <SOGo/SOGoUser.h>
|
|
|
|
#import <SOGo/SOGoUserDefaults.h>
|
|
|
|
|
|
|
|
#import "MAPIStoreTypes.h"
|
|
|
|
|
|
|
|
#import "SOGoTaskObject+MAPIStore.h"
|
|
|
|
|
|
|
|
@implementation SOGoTaskObject (MAPIStoreMessage)
|
|
|
|
|
|
|
|
/* TODO: merge with events */
|
|
|
|
- (void) setMAPIProperties: (NSDictionary *) properties
|
|
|
|
{
|
2011-01-07 21:00:27 +01:00
|
|
|
// MAPIStoreDumpMessageProperties (properties);
|
2010-11-20 00:01:33 +01:00
|
|
|
|
|
|
|
iCalCalendar *vCalendar;
|
|
|
|
iCalToDo *vToDo;
|
|
|
|
id value;
|
|
|
|
SOGoUserDefaults *ud;
|
|
|
|
iCalTimeZone *tz;
|
2010-11-22 16:18:45 +01:00
|
|
|
iCalDateTime *date;
|
2010-11-20 00:01:33 +01:00
|
|
|
NSString *status, *priority;
|
2011-01-07 21:00:27 +01:00
|
|
|
NSCalendarDate *now;
|
2010-11-20 00:01:33 +01:00
|
|
|
|
|
|
|
vToDo = [self component: YES secure: NO];
|
|
|
|
vCalendar = [vToDo parent];
|
|
|
|
[vCalendar setProdID: @"-//Inverse inc.//OpenChange+SOGo//EN"];
|
|
|
|
|
|
|
|
// summary
|
|
|
|
value = [properties
|
2010-12-13 17:53:32 +01:00
|
|
|
objectForKey: MAPIPropertyKey (PR_NORMALIZED_SUBJECT_UNICODE)];
|
2010-11-20 00:01:33 +01:00
|
|
|
if (value)
|
|
|
|
[vToDo setSummary: value];
|
|
|
|
|
2010-11-22 16:18:45 +01:00
|
|
|
// comment
|
|
|
|
value = [properties
|
2010-12-13 17:53:32 +01:00
|
|
|
objectForKey: MAPIPropertyKey (PR_BODY_UNICODE)];
|
2010-11-22 16:18:45 +01:00
|
|
|
if (value)
|
|
|
|
[vToDo setComment: value];
|
|
|
|
|
2010-11-20 00:01:33 +01:00
|
|
|
// Location
|
2010-12-30 15:53:11 +01:00
|
|
|
value = [properties objectForKey: MAPIPropertyKey (PidLidLocation)];
|
2010-11-20 00:01:33 +01:00
|
|
|
if (value)
|
|
|
|
[vToDo setLocation: value];
|
|
|
|
|
|
|
|
/* created */
|
2010-12-13 17:53:32 +01:00
|
|
|
value = [properties objectForKey: MAPIPropertyKey (PR_CREATION_TIME)];
|
2010-11-20 00:01:33 +01:00
|
|
|
if (value)
|
|
|
|
[vToDo setCreated: value];
|
|
|
|
|
|
|
|
/* last-modified + dtstamp */
|
2010-12-13 17:53:32 +01:00
|
|
|
value = [properties objectForKey: MAPIPropertyKey (PR_LAST_MODIFICATION_TIME)];
|
2010-11-20 00:01:33 +01:00
|
|
|
if (value)
|
|
|
|
{
|
|
|
|
[vToDo setLastModified: value];
|
|
|
|
[vToDo setTimeStampAsDate: value];
|
|
|
|
}
|
|
|
|
|
|
|
|
ud = [[SOGoUser userWithLogin: owner] userDefaults];
|
|
|
|
tz = [iCalTimeZone timeZoneForName: [ud timeZoneName]];
|
|
|
|
[vCalendar addTimeZone: tz];
|
|
|
|
|
|
|
|
// start
|
2010-12-30 15:53:11 +01:00
|
|
|
value = [properties objectForKey: MAPIPropertyKey (PidLidTaskStartDate)];
|
2010-11-22 16:18:45 +01:00
|
|
|
if (value)
|
|
|
|
{
|
|
|
|
date = (iCalDateTime *) [vToDo uniqueChildWithTag: @"dtstart"];
|
|
|
|
[date setTimeZone: tz];
|
|
|
|
[date setDateTime: value];
|
|
|
|
}
|
|
|
|
|
|
|
|
// due
|
2010-12-30 15:53:11 +01:00
|
|
|
value = [properties objectForKey: MAPIPropertyKey (PidLidTaskDueDate)];
|
2010-11-20 00:01:33 +01:00
|
|
|
if (value)
|
|
|
|
{
|
2010-11-22 16:18:45 +01:00
|
|
|
date = (iCalDateTime *) [vToDo uniqueChildWithTag: @"due"];
|
|
|
|
[date setTimeZone: tz];
|
|
|
|
[date setDateTime: value];
|
2010-11-20 00:01:33 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
// status
|
2010-12-30 15:53:11 +01:00
|
|
|
value = [properties objectForKey: MAPIPropertyKey (PidLidTaskStatus)];
|
2010-11-20 00:01:33 +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
|
2010-12-13 17:53:32 +01:00
|
|
|
value = [properties objectForKey: MAPIPropertyKey (PR_IMPORTANCE)];
|
2010-11-20 00:01:33 +01:00
|
|
|
if (value)
|
|
|
|
{
|
|
|
|
switch ([value intValue])
|
|
|
|
{
|
2011-01-14 14:13:32 +01:00
|
|
|
case 0: // IMPORTANCE_LOW
|
2010-11-20 00:01:33 +01:00
|
|
|
priority = @"9";
|
|
|
|
break;
|
2011-01-14 14:13:32 +01:00
|
|
|
case 2: // IMPORTANCE_HIGH
|
2010-11-20 00:01:33 +01:00
|
|
|
priority = @"1";
|
|
|
|
break;
|
2011-01-14 14:13:32 +01:00
|
|
|
default: // IMPORTANCE_NORMAL
|
2010-11-20 00:01:33 +01:00
|
|
|
priority = @"5";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
priority = @"0"; // None
|
|
|
|
[vToDo setPriority: priority];
|
|
|
|
|
2011-01-07 21:00:27 +01:00
|
|
|
now = [NSCalendarDate date];
|
|
|
|
if ([self isNew])
|
|
|
|
{
|
|
|
|
[vToDo setCreated: now];
|
|
|
|
}
|
|
|
|
[vToDo setTimeStampAsDate: now];
|
|
|
|
|
2010-11-20 00:01:33 +01:00
|
|
|
// due
|
2010-12-13 17:53:32 +01:00
|
|
|
// value = [properties objectForKey: MAPIPropertyKey (PR_DUE_DATE)];
|
2010-11-20 00:01:33 +01:00
|
|
|
// if (value)
|
|
|
|
// {
|
|
|
|
// due = (iCalDateTime *) [vToDo uniqueChildWithTag: @"due"];
|
|
|
|
// [due setTimeZone: tz];
|
|
|
|
// [due setDateTime: value];
|
|
|
|
// }
|
|
|
|
|
|
|
|
// MAPIStoreDumpMessageProperties (properties);
|
2010-11-22 22:32:11 +01:00
|
|
|
ASSIGN (content, [vCalendar versitString]);
|
2011-01-12 01:23:10 +01:00
|
|
|
|
|
|
|
[fullCalendar release];
|
|
|
|
fullCalendar = nil;
|
|
|
|
[safeCalendar release];
|
|
|
|
safeCalendar = nil;
|
2010-11-20 00:01:33 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
@end
|