2010-11-19 22:11:01 +01:00
|
|
|
/* SOGoAppointmentObject+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-19 22:11: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.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <stdbool.h>
|
|
|
|
#include <gen_ndr/exchange.h>
|
2010-12-30 15:53:11 +01:00
|
|
|
#include <mapistore/mapistore_nameid.h>
|
2010-11-19 22:11:01 +01:00
|
|
|
|
|
|
|
#import <Foundation/NSDictionary.h>
|
|
|
|
#import <Foundation/NSTimeZone.h>
|
|
|
|
#import <Foundation/NSString.h>
|
|
|
|
|
2010-12-13 17:53:32 +01:00
|
|
|
#import <NGExtensions/NSObject+Logs.h>
|
|
|
|
|
2010-11-19 22:11:01 +01:00
|
|
|
#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 "SOGoAppointmentObject+MAPIStore.h"
|
|
|
|
|
2010-12-30 15:53:11 +01:00
|
|
|
|
2010-11-19 22:11:01 +01:00
|
|
|
@implementation SOGoAppointmentObject (MAPIStoreMessage)
|
|
|
|
|
2010-11-20 00:01:49 +01:00
|
|
|
/* TODO: merge with tasks */
|
2010-11-19 22:11:01 +01:00
|
|
|
- (void) setMAPIProperties: (NSDictionary *) properties
|
|
|
|
{
|
|
|
|
iCalCalendar *vCalendar;
|
|
|
|
iCalEvent *vEvent;
|
|
|
|
id value;
|
|
|
|
SOGoUserDefaults *ud;
|
2011-01-07 21:00:27 +01:00
|
|
|
NSCalendarDate *now;
|
2010-11-19 22:11:01 +01:00
|
|
|
iCalTimeZone *tz;
|
|
|
|
iCalDateTime *start, *end;
|
|
|
|
|
2010-12-13 17:53:32 +01:00
|
|
|
[self logWithFormat: @"event props:"];
|
|
|
|
MAPIStoreDumpMessageProperties (properties);
|
|
|
|
|
2010-11-19 22:11:01 +01:00
|
|
|
vEvent = [self component: YES secure: NO];
|
|
|
|
vCalendar = [vEvent 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-19 22:11:01 +01:00
|
|
|
if (value)
|
|
|
|
[vEvent setSummary: value];
|
|
|
|
|
|
|
|
// Location
|
2010-12-30 15:53:11 +01:00
|
|
|
value = [properties objectForKey: MAPIPropertyKey (PidLidLocation)];
|
2010-11-19 22:11:01 +01:00
|
|
|
if (value)
|
|
|
|
[vEvent setLocation: value];
|
|
|
|
|
|
|
|
ud = [[SOGoUser userWithLogin: owner] userDefaults];
|
|
|
|
tz = [iCalTimeZone timeZoneForName: [ud timeZoneName]];
|
|
|
|
[vCalendar addTimeZone: tz];
|
|
|
|
|
|
|
|
// start
|
2010-12-13 17:53:32 +01:00
|
|
|
value = [properties objectForKey: MAPIPropertyKey (PR_START_DATE)];
|
2010-12-30 15:53:11 +01:00
|
|
|
if (!value)
|
|
|
|
value = [properties objectForKey: MAPIPropertyKey (PidLidAppointmentStartWhole)];
|
2010-11-19 22:11:01 +01:00
|
|
|
if (value)
|
|
|
|
{
|
|
|
|
start = (iCalDateTime *) [vEvent uniqueChildWithTag: @"dtstart"];
|
|
|
|
[start setTimeZone: tz];
|
|
|
|
[start setDateTime: value];
|
|
|
|
}
|
|
|
|
|
|
|
|
// end
|
2010-12-13 17:53:32 +01:00
|
|
|
value = [properties objectForKey: MAPIPropertyKey (PR_END_DATE)];
|
2010-12-30 15:53:11 +01:00
|
|
|
if (!value)
|
|
|
|
value = [properties objectForKey: MAPIPropertyKey (PidLidAppointmentEndWhole)];
|
2010-11-19 22:11:01 +01:00
|
|
|
if (value)
|
|
|
|
{
|
|
|
|
end = (iCalDateTime *) [vEvent uniqueChildWithTag: @"dtend"];
|
|
|
|
[end setTimeZone: tz];
|
|
|
|
[end setDateTime: value];
|
|
|
|
}
|
|
|
|
|
2011-01-07 21:00:27 +01:00
|
|
|
now = [NSCalendarDate date];
|
|
|
|
if ([self isNew])
|
|
|
|
{
|
|
|
|
[vEvent setCreated: now];
|
|
|
|
}
|
|
|
|
[vEvent setTimeStampAsDate: now];
|
|
|
|
|
2010-11-19 22:11:01 +01:00
|
|
|
// 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-19 22:11:01 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
@end
|