mirror of
https://github.com/inverse-inc/sogo.git
synced 2026-11-22 23:14:22 +00:00
see ChangeLog
Monotone-Revision: 9054022ef1ca8aeba6e34842d27d9b94ce002b89 Monotone-Author: dev-unix.inverse.qc.ca Monotone-Date: 2006-06-15T19:34:10 Monotone-Branch: ca.inverse.sogo
This commit is contained in:
commit
f18c764ffa
965 files changed
+99196
No files matched your search
@@ -0,0 +1,266 @@
|
||||
2005-08-02 Helge Hess <helge.hess@skyrix.com>
|
||||
|
||||
* SOGoAppointmentObject.[hm]: added method to change participation
|
||||
status of logged-in user (v0.9.50)
|
||||
|
||||
2005-07-21 Marcus Mueller <znek@mulle-kybernetik.com>
|
||||
|
||||
* SOGoAppointmentFolder.m: place a hint ('isRecurrent') into flattened
|
||||
rows created from recurrent events so these can be signaled in the
|
||||
UI (v0.9.49)
|
||||
|
||||
2005-07-20 Marcus Mueller <znek@mulle-kybernetik.com>
|
||||
|
||||
* v0.9.48
|
||||
|
||||
* SOGoAptMailInvitation.m, SOGoAptMailUpdate.m, SOGoAptMailDeletion.m,
|
||||
SOGoAptMailRemoval.m: updated to contain new classes for additional
|
||||
languages
|
||||
|
||||
* SOGoAptMailInvitation.wo, SOGoAptMailUpdate.wo,
|
||||
SOGoAptMailDeletion.wo, SOGoAptMailRemoval.wo: replaced with language
|
||||
dependend counterparts
|
||||
|
||||
* SOGoAptMail{English,French}Invitation.wo,
|
||||
SOGoAptMail{English,French}Update.wo,
|
||||
SOGoAptMail{English,French}Deletion.wo,
|
||||
SOGoAptMail{English,French}Removal.wo: new language dependend
|
||||
templates. Please note that due to an unresolved bug we cannot use
|
||||
the standard WO lookup mechanism here.
|
||||
|
||||
2005-07-15 Marcus Mueller <znek@mulle-kybernetik.com>
|
||||
|
||||
* v0.9.47
|
||||
|
||||
* SOGoAptMailDeletion.[wo,m]: new template being used when appointment
|
||||
is deleted
|
||||
|
||||
* SOGoAptMailRemoval.[wo,m]: new template being used when attendee is
|
||||
removed from appointment
|
||||
|
||||
* SOGoAppointmentObject.m: now sends emails for removal of attendees
|
||||
and deletion of appointment
|
||||
|
||||
2005-07-15 Helge Hess <helge.hess@opengroupware.org>
|
||||
|
||||
* SOGoAppointmentFolder.m: fixed Cocoa warnings (v0.9.46)
|
||||
|
||||
* SOGoAppointmentFolder.m: fixed gcc 4.0 warnings (v0.9.45)
|
||||
|
||||
2005-07-14 Marcus Mueller <znek@mulle-kybernetik.com>
|
||||
|
||||
* v0.9.44
|
||||
|
||||
* SOGoAppointmentFolder.m: explicitly set encoding for text and
|
||||
calendar attachment parts
|
||||
|
||||
* SOGoAptMailNotification.m: added -appointmentURL accessor
|
||||
|
||||
* SOGoAptMailInvitation.wo, SOGoAptMailUpdate.wo: display
|
||||
-appointmentURL instead of -homePageURL
|
||||
|
||||
* v0.9.43
|
||||
|
||||
* SOGoAppointmentFolder.m: changed redirect from 'schedule' to
|
||||
'weekoverview'
|
||||
|
||||
2005-07-14 Helge Hess <helge.hess@opengroupware.org>
|
||||
|
||||
* SOGoAppointmentFolder.m: moved +globallyUniqueObjectId method to
|
||||
SOGoFolder.m baseclass (v0.9.42)
|
||||
|
||||
2005-07-13 Helge Hess <helge.hess@opengroupware.org>
|
||||
|
||||
* SOGoAppointmentFolder.m: added a method to determine the resource
|
||||
name from a vevent UID (v0.9.41)
|
||||
|
||||
2005-07-12 Marcus Mueller <znek@mulle-kybernetik.com>
|
||||
|
||||
* SOGoAppointmentObject.m: tries ambitiously to detect the baseURL in
|
||||
-homePageURLForPerson: now. This code doesn't really belong here
|
||||
but currently there's no appropriate controller for dealing with it
|
||||
around. Also removed mail notification testing code. (v0.9.40)
|
||||
|
||||
2005-07-12 Helge Hess <helge.hess@opengroupware.org>
|
||||
|
||||
* fixed compilation (v0.9.39)
|
||||
|
||||
2005-07-12 Marcus Mueller <znek@mulle-kybernetik.com>
|
||||
|
||||
* v0.9.38
|
||||
|
||||
* GNUmakefile: changed inclusion of bundle.make to wobundle.make
|
||||
because of new components
|
||||
|
||||
* v0.9.37
|
||||
|
||||
* SOGoAptMailNotification.[hm]: new component forming the basis for
|
||||
the mail notification templates
|
||||
|
||||
* SOGoAptMailInvitation.[wo, m]: invitation mail template, sent to all
|
||||
new attendees of an appointment
|
||||
|
||||
* SOGoAptMailUpdate.[wo, m]: update mail template, sent to all
|
||||
attendees when appointment time is changed
|
||||
|
||||
* SOGoAppointmentObject.m: rewritten to use the iCalEventChanges object
|
||||
from NGiCal to discover changes to saved appointments. Additionaly
|
||||
email notifications are emitted on certain occasions (this is not
|
||||
full iMip, yet). In case the appointment time changes, state for
|
||||
all attendees is reset to NEEDS-ACTION.
|
||||
|
||||
2005-07-08 Marcus Mueller <znek@mulle-kybernetik.com>
|
||||
|
||||
* SOGoAppointmentFolder.m: added 'partmails' and 'partstates' to
|
||||
infos returned by -fetchOverviewInfosFrom:to: (v0.9.36)
|
||||
|
||||
2005-07-06 Marcus Mueller <znek@mulle-kybernetik.com>
|
||||
|
||||
* v0.9.35
|
||||
|
||||
* GNUMakefile: added SOGoFreeBusyObject.m
|
||||
|
||||
* product.plist: added SOGoFreeBusyObject
|
||||
|
||||
* SOGoFreeBusyObject.[hm]: new class resembling free/busy information
|
||||
for a particular user. Because free/busy information isn't solely
|
||||
based upon appointments, this is now a part of the user folder.
|
||||
However the information contained therein is still based on
|
||||
information provided by appointments, only. This should be fixed in
|
||||
a later release.
|
||||
|
||||
* SOGoAppointmentFolder.m: new API to lookup freeBusyObjects for an
|
||||
array of uids.
|
||||
|
||||
2005-07-05 Marcus Mueller <znek@mulle-kybernetik.com>
|
||||
|
||||
* SOGoAppointmentFolder.m: fetch new priority field in core infos
|
||||
(v0.9.34)
|
||||
|
||||
2005-07-04 Marcus Mueller <znek@mulle-kybernetik.com>
|
||||
|
||||
* SOGoAppointmentFolder.m: fetch new priority field in overview infos
|
||||
(v0.9.33)
|
||||
|
||||
2005-03-20 Helge Hess <helge.hess@opengroupware.org>
|
||||
|
||||
* SOGoAppointmentFolder.m: changed to use GDLContentStore (v0.9.32)
|
||||
|
||||
2005-03-03 Marcus Mueller <znek@mulle-kybernetik.com>
|
||||
|
||||
* SOGoGroupAppointmentFolder.m: fixed incorrect creation of a mutable
|
||||
dictionary (was still immutable) (v0.9.31)
|
||||
|
||||
2005-03-02 Marcus Mueller <znek@mulle-kybernetik.com>
|
||||
|
||||
* SOGoAppointmentFolder.m: make sure fetchedInfos are sorted
|
||||
ascending - this simplifies client code (v0.9.30)
|
||||
|
||||
* SOGoAppointmentFolder.m: changed debugLog to use NGLogging (v0.9.29)
|
||||
|
||||
2005-03-01 Marcus Mueller <znek@mulle-kybernetik.com>
|
||||
|
||||
* SOGoAppointmentFolder.m: significantly changed handling of cyclic
|
||||
events. Information for cyclic event calculation is now contained
|
||||
in the quick info, making full fetches obsolete - performance
|
||||
should improve significantly this way (v0.9.28)
|
||||
|
||||
2005-02-22 Helge Hess <helge.hess@skyrix.com>
|
||||
|
||||
* SOGoAppointmentFolder.m: minor code cleanups (v0.9.27)
|
||||
|
||||
2005-02-17 Helge Hess <helge.hess@opengroupware.org>
|
||||
|
||||
* fixed for removal of SOGoLogic (v0.9.26)
|
||||
|
||||
2005-02-06 Helge Hess <helge.hess@opengroupware.org>
|
||||
|
||||
* SOGoAppointmentObject.m, SOGoAppointmentFolder.m: added proper
|
||||
message/folder class (v0.9.25)
|
||||
|
||||
2004-11-09 Helge Hess <helge.hess@skyrix.com>
|
||||
|
||||
* SOGoAppointmentObject.m: improved error handling in save method
|
||||
(v0.9.16)
|
||||
|
||||
2004-10-20 Helge Hess <helge.hess@opengroupware.org>
|
||||
|
||||
* SOGoAppointmentFolder.m: fixed a warning on MacOSX (v0.9.15)
|
||||
|
||||
* SOGoAppointmentObject.m(saveContentString:): fixed a warning with new
|
||||
objects (v0.9.14)
|
||||
|
||||
2004-10-19 Helge Hess <helge.hess@opengroupware.org>
|
||||
|
||||
* SOGoAppointmentFolder.h: added -fetchAllSOGoAppointments method
|
||||
which performs a bulk fetch on all files contained in the folder
|
||||
and parses all contents into an array of SOGoAppointment objects
|
||||
(used in the iCal file support, try to avoid this method, expensive!)
|
||||
(v0.9.13)
|
||||
|
||||
2004-09-25 Helge Hess <helge.hess@opengroupware.org>
|
||||
|
||||
* fixed compilation on MacOSX (v0.9.12)
|
||||
|
||||
2004-09-08 Helge Hess <helge.hess@opengroupware.org>
|
||||
|
||||
* SOGoGroupAppointmentFolder.m: do not call -sleep in fetch method
|
||||
(disconnects the folder from the parent folder), instead added a
|
||||
-resetFolderCaches methods which performs some cleanups before a
|
||||
fetch (v0.9.11)
|
||||
|
||||
2004-08-16 Helge Hess <helge.hess@skyrix.com>
|
||||
|
||||
* SOGoAppointmentFolder.m: added method to create a group folder and
|
||||
a group calendar for a set of IDs (for internal queries) (v0.9.10)
|
||||
|
||||
* SOGoAppointmentObject.m, SOGoAppointmentFolder.m: moved calendar
|
||||
folder lookup methods to folder class (the object uses its container
|
||||
to lookup the folder) (v0.9.9)
|
||||
|
||||
* SOGoAppointmentObject.m: finished multi folder storage methods
|
||||
(v0.9.8)
|
||||
|
||||
* SOGoAppointmentObject.m: added multi folder storage methods (v0.9.7)
|
||||
|
||||
2004-08-14 Helge Hess <helge.hess@skyrix.com>
|
||||
|
||||
* SOGoGroupAppointmentFolder.m: implemented proper URL generation for
|
||||
group calendars (will lookup the appointment in the proper "exact"
|
||||
folder (v0.9.6)
|
||||
|
||||
* SOGoAppointmentFolder.m: fetch location, isallday, iscycle and
|
||||
partmails fields in -fetchCoreInfo (v0.9.5)
|
||||
|
||||
2004-08-12 Helge Hess <helge.hess@skyrix.com>
|
||||
|
||||
* v0.9.4
|
||||
|
||||
* SOGoAppointmentFolder.m: added -baseURLForAptWithUID:inContext: for
|
||||
determining the resource URL of an appointment, used by calendar
|
||||
views to locate the viewer page
|
||||
|
||||
2004-08-11 Helge Hess <helge.hess@skyrix.com>
|
||||
|
||||
* SOGoGroupAppointmentFolder: can merge input folders, tracks conflicts
|
||||
in 'conflicts' key of the record (should be displayed somehow in the
|
||||
UI) (v0.9.3)
|
||||
|
||||
* v0.9.2
|
||||
|
||||
* SOGoAppointmentFolder.m, SOGoGroupAppointmentFolder: added
|
||||
-calendarUIDs method which returns the UIDs of the currently
|
||||
displayed persons (eg the members of a group)
|
||||
|
||||
* started SOGoGroupAppointmentFolder
|
||||
|
||||
2004-07-02 Helge Hess <helge.hess@opengroupware.org>
|
||||
|
||||
* SOGoAppointmentFolder.m: added method to fetch core info from other
|
||||
OCS folders, correct timezone to MET after fetch core info
|
||||
|
||||
2004-07-01 Helge Hess <helge.hess@opengroupware.org>
|
||||
|
||||
* redirect to weekoverview if GET is run on the folder itself
|
||||
|
||||
* created ChangeLog
|
||||
@@ -0,0 +1,42 @@
|
||||
# GNUstep makefile
|
||||
|
||||
include ../common.make
|
||||
|
||||
WOBUNDLE_NAME = Appointments
|
||||
|
||||
Appointments_PRINCIPAL_CLASS = SOGoAppointmentsProduct
|
||||
|
||||
# Appointments_LANGUAGES = English French
|
||||
|
||||
Appointments_OBJC_FILES = \
|
||||
Product.m \
|
||||
\
|
||||
SOGoAppointmentObject.m \
|
||||
SOGoAppointmentFolder.m \
|
||||
SOGoGroupAppointmentFolder.m \
|
||||
SOGoFreeBusyObject.m \
|
||||
\
|
||||
SOGoAptMailNotification.m \
|
||||
SOGoAptMailInvitation.m \
|
||||
SOGoAptMailUpdate.m \
|
||||
SOGoAptMailRemoval.m \
|
||||
SOGoAptMailDeletion.m \
|
||||
|
||||
Appointments_RESOURCE_FILES += \
|
||||
Version \
|
||||
product.plist \
|
||||
|
||||
Appointments_COMPONENTS += \
|
||||
SOGoAptMailEnglishInvitation.wo \
|
||||
SOGoAptMailFrenchInvitation.wo \
|
||||
SOGoAptMailEnglishUpdate.wo \
|
||||
SOGoAptMailFrenchUpdate.wo \
|
||||
SOGoAptMailEnglishRemoval.wo \
|
||||
SOGoAptMailFrenchRemoval.wo \
|
||||
SOGoAptMailEnglishDeletion.wo \
|
||||
SOGoAptMailFrenchDeletion.wo \
|
||||
|
||||
-include GNUmakefile.preamble
|
||||
include $(GNUSTEP_MAKEFILES)/wobundle.make
|
||||
-include GNUmakefile.postamble
|
||||
include ../../fhsbundle.make
|
||||
@@ -0,0 +1,33 @@
|
||||
/*
|
||||
Copyright (C) 2004 SKYRIX Software AG
|
||||
|
||||
This file is part of OpenGroupware.org.
|
||||
|
||||
OGo is free software; you can redistribute it and/or modify it under
|
||||
the terms of the GNU Lesser General Public License as published by the
|
||||
Free Software Foundation; either version 2, or (at your option) any
|
||||
later version.
|
||||
|
||||
OGo 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 Lesser General Public
|
||||
License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with OGo; see the file COPYING. If not, write to the
|
||||
Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA
|
||||
02111-1307, USA.
|
||||
*/
|
||||
// $Id: Product.m 98 2004-06-30 08:54:28Z helge $
|
||||
|
||||
#import <Foundation/NSObject.h>
|
||||
|
||||
@interface SOGoAppointmentsProduct : NSObject
|
||||
{
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
@implementation SOGoAppointmentsProduct
|
||||
|
||||
@end /* SOGoAppointmentsProduct */
|
||||
@@ -0,0 +1,101 @@
|
||||
/*
|
||||
Copyright (C) 2004-2005 SKYRIX Software AG
|
||||
|
||||
This file is part of OpenGroupware.org.
|
||||
|
||||
OGo is free software; you can redistribute it and/or modify it under
|
||||
the terms of the GNU Lesser General Public License as published by the
|
||||
Free Software Foundation; either version 2, or (at your option) any
|
||||
later version.
|
||||
|
||||
OGo 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 Lesser General Public
|
||||
License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with OGo; see the file COPYING. If not, write to the
|
||||
Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA
|
||||
02111-1307, USA.
|
||||
*/
|
||||
|
||||
#ifndef __Appointments_SOGoAppointmentFolder_H__
|
||||
#define __Appointments_SOGoAppointmentFolder_H__
|
||||
|
||||
#include <SOGo/SOGoFolder.h>
|
||||
|
||||
/*
|
||||
SOGoAppointmentFolder
|
||||
Parent object: the SOGoUserFolder
|
||||
Child objects: SOGoAppointmentObject
|
||||
|
||||
The SOGoAppointmentFolder maps to an GCS folder of type 'appointment', that
|
||||
is, a content folder containing iCalendar files (and a proper quicktable).
|
||||
|
||||
Important:
|
||||
The folder assumes a 1:1 mapping between the vevent UID field and the
|
||||
resource name in the content store. In other words, you are not allowed to
|
||||
create two different vevent-files with the same uid in the store.
|
||||
*/
|
||||
|
||||
@class NSString, NSArray, NSCalendarDate, NSException, NSMutableDictionary;
|
||||
@class GCSFolder;
|
||||
|
||||
@interface SOGoAppointmentFolder : SOGoFolder
|
||||
{
|
||||
NSMutableDictionary *uidToFilename;
|
||||
}
|
||||
|
||||
/* selection */
|
||||
|
||||
- (NSArray *)calendarUIDs;
|
||||
|
||||
/* vevent UID handling */
|
||||
|
||||
- (NSString *)resourceNameForEventUID:(NSString *)_uid;
|
||||
|
||||
/* fetching */
|
||||
|
||||
- (NSArray *)fetchFields:(NSArray *)_fields
|
||||
fromFolder:(GCSFolder *)_folder
|
||||
from:(NSCalendarDate *)_startDate
|
||||
to:(NSCalendarDate *)_endDate;
|
||||
|
||||
- (NSArray *)fetchFields:(NSArray *)_fields
|
||||
from:(NSCalendarDate *)_startDate
|
||||
to:(NSCalendarDate *)_endDate;
|
||||
|
||||
- (NSArray *)fetchCoreInfosFrom:(NSCalendarDate *)_startDate
|
||||
to:(NSCalendarDate *)_endDate;
|
||||
|
||||
- (NSArray *)fetchOverviewInfosFrom:(NSCalendarDate *)_startDate
|
||||
to:(NSCalendarDate *)_endDate;
|
||||
|
||||
- (NSArray *)fetchFreebusyInfosFrom:(NSCalendarDate *)_startDate
|
||||
to:(NSCalendarDate *)_endDate;
|
||||
|
||||
/* URL generation */
|
||||
|
||||
- (NSString *)baseURLForAptWithUID:(NSString *)_uid inContext:(id)_ctx;
|
||||
|
||||
/* folder management */
|
||||
|
||||
- (id)lookupHomeFolderForUID:(NSString *)_uid inContext:(id)_ctx;
|
||||
|
||||
- (NSArray *)lookupCalendarFoldersForUIDs:(NSArray *)_uids inContext:(id)_ctx;
|
||||
- (NSArray *)lookupFreeBusyObjectsForUIDs:(NSArray *)_uids inContext:(id)_ctx;
|
||||
|
||||
- (NSArray *)uidsFromICalPersons:(NSArray *)_persons;
|
||||
- (NSArray *)lookupCalendarFoldersForICalPerson:(NSArray *)_persons
|
||||
inContext:(id)_ctx;
|
||||
|
||||
- (id)lookupGroupFolderForUIDs:(NSArray *)_uids inContext:(id)_ctx;
|
||||
- (id)lookupGroupCalendarFolderForUIDs:(NSArray *)_uids inContext:(id)_ctx;
|
||||
|
||||
/* bulk fetches */
|
||||
|
||||
- (NSArray *)fetchAllSOGoAppointments;
|
||||
|
||||
@end
|
||||
|
||||
#endif /* __Appointments_SOGoAppointmentFolder_H__ */
|
||||
@@ -0,0 +1,716 @@
|
||||
/*
|
||||
Copyright (C) 2004-2005 SKYRIX Software AG
|
||||
|
||||
This file is part of OpenGroupware.org.
|
||||
|
||||
OGo is free software; you can redistribute it and/or modify it under
|
||||
the terms of the GNU Lesser General Public License as published by the
|
||||
Free Software Foundation; either version 2, or (at your option) any
|
||||
later version.
|
||||
|
||||
OGo 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 Lesser General Public
|
||||
License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with OGo; see the file COPYING. If not, write to the
|
||||
Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA
|
||||
02111-1307, USA.
|
||||
*/
|
||||
|
||||
#include "SOGoAppointmentFolder.h"
|
||||
#include <SOGo/SOGoCustomGroupFolder.h>
|
||||
#include <SOGo/SOGoAppointment.h>
|
||||
#include <SOGo/AgenorUserManager.h>
|
||||
#include <GDLContentStore/GCSFolder.h>
|
||||
#include <SaxObjC/SaxObjC.h>
|
||||
#include <NGiCal/NGiCal.h>
|
||||
#include <NGExtensions/NGCalendarDateRange.h>
|
||||
#include "common.h"
|
||||
|
||||
#if APPLE_Foundation_LIBRARY || NeXT_Foundation_LIBRARY
|
||||
@interface NSDate(UsedPrivates)
|
||||
- (id)initWithTimeIntervalSince1970:(NSTimeInterval)_interval;
|
||||
@end
|
||||
#endif
|
||||
|
||||
@implementation SOGoAppointmentFolder
|
||||
|
||||
static NGLogger *logger = nil;
|
||||
static NSTimeZone *MET = nil;
|
||||
static NSNumber *sharedYes = nil;
|
||||
|
||||
+ (int)version {
|
||||
return [super version] + 1 /* v1 */;
|
||||
}
|
||||
+ (void)initialize {
|
||||
NGLoggerManager *lm;
|
||||
static BOOL didInit = NO;
|
||||
|
||||
if (didInit) return;
|
||||
didInit = YES;
|
||||
|
||||
NSAssert2([super version] == 0,
|
||||
@"invalid superclass (%@) version %i !",
|
||||
NSStringFromClass([self superclass]), [super version]);
|
||||
|
||||
lm = [NGLoggerManager defaultLoggerManager];
|
||||
logger = [lm loggerForDefaultKey:@"SOGoAppointmentFolderDebugEnabled"];
|
||||
|
||||
MET = [[NSTimeZone timeZoneWithAbbreviation:@"MET"] retain];
|
||||
sharedYes = [[NSNumber numberWithBool:YES] retain];
|
||||
}
|
||||
|
||||
- (void)dealloc {
|
||||
[self->uidToFilename release];
|
||||
[super dealloc];
|
||||
}
|
||||
|
||||
|
||||
/* logging */
|
||||
|
||||
- (id)debugLogger {
|
||||
return logger;
|
||||
}
|
||||
|
||||
/* selection */
|
||||
|
||||
- (NSArray *)calendarUIDs {
|
||||
/* this is used for group calendars (this folder just returns itself) */
|
||||
NSString *s;
|
||||
|
||||
s = [[self container] nameInContainer];
|
||||
return [s isNotNull] ? [NSArray arrayWithObjects:&s count:1] : nil;
|
||||
}
|
||||
|
||||
/* name lookup */
|
||||
|
||||
- (BOOL)isValidAppointmentName:(NSString *)_key {
|
||||
if ([_key length] == 0)
|
||||
return NO;
|
||||
|
||||
return YES;
|
||||
}
|
||||
|
||||
- (id)appointmentWithName:(NSString *)_key inContext:(id)_ctx {
|
||||
static Class aptClass = Nil;
|
||||
id apt;
|
||||
|
||||
if (aptClass == Nil)
|
||||
aptClass = NSClassFromString(@"SOGoAppointmentObject");
|
||||
if (aptClass == Nil) {
|
||||
[self errorWithFormat:@"missing SOGoAppointmentObject class!"];
|
||||
return nil;
|
||||
}
|
||||
|
||||
apt = [[aptClass alloc] initWithName:_key inContainer:self];
|
||||
return [apt autorelease];
|
||||
}
|
||||
|
||||
- (id)lookupName:(NSString *)_key inContext:(id)_ctx acquire:(BOOL)_flag {
|
||||
id obj;
|
||||
|
||||
/* first check attributes directly bound to the application */
|
||||
if ((obj = [super lookupName:_key inContext:_ctx acquire:NO]))
|
||||
return obj;
|
||||
|
||||
if ([self isValidAppointmentName:_key])
|
||||
return [self appointmentWithName:_key inContext:_ctx];
|
||||
|
||||
/* return 404 to stop acquisition */
|
||||
return [NSException exceptionWithHTTPStatus:404 /* Not Found */];
|
||||
}
|
||||
|
||||
/* timezone */
|
||||
|
||||
- (NSTimeZone *)viewTimeZone {
|
||||
// TODO: should use a cookie for configuration? we default to MET
|
||||
return MET;
|
||||
}
|
||||
|
||||
/* vevent UID handling */
|
||||
|
||||
- (NSString *)resourceNameForEventUID:(NSString *)_u inFolder:(GCSFolder *)_f {
|
||||
static NSArray *nameFields = nil;
|
||||
EOQualifier *qualifier;
|
||||
NSArray *records;
|
||||
|
||||
if (![_u isNotNull]) return nil;
|
||||
if (_f == nil) {
|
||||
[self errorWithFormat:@"(%s): missing folder for fetch!",
|
||||
__PRETTY_FUNCTION__];
|
||||
return nil;
|
||||
}
|
||||
|
||||
if (nameFields == nil)
|
||||
nameFields = [[NSArray alloc] initWithObjects:@"c_name", nil];
|
||||
|
||||
qualifier = [EOQualifier qualifierWithQualifierFormat:@"uid = %@", _u];
|
||||
records = [_f fetchFields:nameFields matchingQualifier:qualifier];
|
||||
|
||||
if ([records count] == 1)
|
||||
return [[records objectAtIndex:0] valueForKey:@"c_name"];
|
||||
if ([records count] == 0)
|
||||
return nil;
|
||||
|
||||
[self errorWithFormat:
|
||||
@"The storage contains more than file with the same UID!"];
|
||||
return [[records objectAtIndex:0] valueForKey:@"c_name"];
|
||||
}
|
||||
|
||||
- (NSString *)resourceNameForEventUID:(NSString *)_uid {
|
||||
/* caches UIDs */
|
||||
GCSFolder *folder;
|
||||
NSString *rname;
|
||||
|
||||
if (![_uid isNotNull])
|
||||
return nil;
|
||||
if ((rname = [self->uidToFilename objectForKey:_uid]) != nil)
|
||||
return [rname isNotNull] ? rname : nil;
|
||||
|
||||
if ((folder = [self ocsFolder]) == nil) {
|
||||
[self errorWithFormat:@"(%s): missing folder for fetch!",
|
||||
__PRETTY_FUNCTION__];
|
||||
return nil;
|
||||
}
|
||||
|
||||
if (self->uidToFilename == nil)
|
||||
self->uidToFilename = [[NSMutableDictionary alloc] initWithCapacity:16];
|
||||
|
||||
if ((rname = [self resourceNameForEventUID:_uid inFolder:folder]) == nil)
|
||||
[self->uidToFilename setObject:[NSNull null] forKey:_uid];
|
||||
else
|
||||
[self->uidToFilename setObject:rname forKey:_uid];
|
||||
|
||||
return rname;
|
||||
}
|
||||
|
||||
/* fetching */
|
||||
|
||||
- (NSMutableDictionary *)fixupRecord:(NSDictionary *)_record
|
||||
fetchRange:(NGCalendarDateRange *)_r
|
||||
{
|
||||
NSMutableDictionary *md;
|
||||
id tmp;
|
||||
|
||||
md = [[_record mutableCopy] autorelease];
|
||||
|
||||
if ((tmp = [_record objectForKey:@"startdate"])) {
|
||||
tmp = [[NSCalendarDate alloc] initWithTimeIntervalSince1970:
|
||||
(NSTimeInterval)[tmp unsignedIntValue]];
|
||||
[tmp setTimeZone:[self viewTimeZone]];
|
||||
if (tmp) [md setObject:tmp forKey:@"startDate"];
|
||||
[tmp release];
|
||||
}
|
||||
else
|
||||
[self logWithFormat:@"missing 'startdate' in record?"];
|
||||
|
||||
if ((tmp = [_record objectForKey:@"enddate"])) {
|
||||
tmp = [[NSCalendarDate alloc] initWithTimeIntervalSince1970:
|
||||
(NSTimeInterval)[tmp unsignedIntValue]];
|
||||
[tmp setTimeZone:[self viewTimeZone]];
|
||||
if (tmp) [md setObject:tmp forKey:@"endDate"];
|
||||
[tmp release];
|
||||
}
|
||||
else
|
||||
[self logWithFormat:@"missing 'enddate' in record?"];
|
||||
|
||||
return md;
|
||||
}
|
||||
|
||||
- (NSMutableDictionary *)fixupCycleRecord:(NSDictionary *)_record
|
||||
cycleRange:(NGCalendarDateRange *)_r
|
||||
{
|
||||
NSMutableDictionary *md;
|
||||
id tmp;
|
||||
|
||||
md = [[_record mutableCopy] autorelease];
|
||||
|
||||
/* cycle is in _r */
|
||||
tmp = [_r startDate];
|
||||
[tmp setTimeZone:[self viewTimeZone]];
|
||||
[md setObject:tmp forKey:@"startDate"];
|
||||
tmp = [_r endDate];
|
||||
[tmp setTimeZone:[self viewTimeZone]];
|
||||
[md setObject:tmp forKey:@"endDate"];
|
||||
|
||||
return md;
|
||||
}
|
||||
|
||||
- (void)_flattenCycleRecord:(NSDictionary *)_row
|
||||
forRange:(NGCalendarDateRange *)_r
|
||||
intoArray:(NSMutableArray *)_ma
|
||||
{
|
||||
NSMutableDictionary *row;
|
||||
NSDictionary *cycleinfo;
|
||||
NSCalendarDate *startDate, *endDate;
|
||||
NGCalendarDateRange *fir;
|
||||
NSArray *rules, *exRules, *exDates, *ranges;
|
||||
unsigned i, count;
|
||||
|
||||
cycleinfo = [[_row objectForKey:@"cycleinfo"] propertyList];
|
||||
if (cycleinfo == nil) {
|
||||
[self errorWithFormat:@"cyclic record doesn't have cycleinfo -> %@", _row];
|
||||
return;
|
||||
}
|
||||
|
||||
row = [self fixupRecord:_row fetchRange:_r];
|
||||
[row removeObjectForKey:@"cycleinfo"];
|
||||
[row setObject:sharedYes forKey:@"isRecurrentEvent"];
|
||||
|
||||
startDate = [row objectForKey:@"startDate"];
|
||||
endDate = [row objectForKey:@"endDate"];
|
||||
fir = [NGCalendarDateRange calendarDateRangeWithStartDate:startDate
|
||||
endDate:endDate];
|
||||
rules = [cycleinfo objectForKey:@"rules"];
|
||||
exRules = [cycleinfo objectForKey:@"exRules"];
|
||||
exDates = [cycleinfo objectForKey:@"exDates"];
|
||||
|
||||
ranges = [iCalRecurrenceCalculator recurrenceRangesWithinCalendarDateRange:_r
|
||||
firstInstanceCalendarDateRange:fir
|
||||
recurrenceRules:rules
|
||||
exceptionRules:exRules
|
||||
exceptionDates:exDates];
|
||||
count = [ranges count];
|
||||
for (i = 0; i < count; i++) {
|
||||
NGCalendarDateRange *rRange;
|
||||
id fixedRow;
|
||||
|
||||
rRange = [ranges objectAtIndex:i];
|
||||
fixedRow = [self fixupCycleRecord:row cycleRange:rRange];
|
||||
if (fixedRow != nil) [_ma addObject:fixedRow];
|
||||
}
|
||||
}
|
||||
|
||||
- (NSArray *)fixupRecords:(NSArray *)_records
|
||||
fetchRange:(NGCalendarDateRange *)_r
|
||||
{
|
||||
// TODO: is the result supposed to be sorted by date?
|
||||
NSMutableArray *ma;
|
||||
unsigned i, count;
|
||||
|
||||
if (_records == nil) return nil;
|
||||
if ((count = [_records count]) == 0)
|
||||
return _records;
|
||||
|
||||
ma = [NSMutableArray arrayWithCapacity:count];
|
||||
for (i = 0; i < count; i++) {
|
||||
id row; // TODO: what is the type of the record?
|
||||
|
||||
row = [_records objectAtIndex:i];
|
||||
row = [self fixupRecord:row fetchRange:_r];
|
||||
if (row != nil) [ma addObject:row];
|
||||
}
|
||||
return ma;
|
||||
}
|
||||
|
||||
- (NSArray *)fixupCyclicRecords:(NSArray *)_records
|
||||
fetchRange:(NGCalendarDateRange *)_r
|
||||
{
|
||||
// TODO: is the result supposed to be sorted by date?
|
||||
NSMutableArray *ma;
|
||||
unsigned i, count;
|
||||
|
||||
if (_records == nil) return nil;
|
||||
if ((count = [_records count]) == 0)
|
||||
return _records;
|
||||
|
||||
ma = [NSMutableArray arrayWithCapacity:count];
|
||||
for (i = 0; i < count; i++) {
|
||||
id row; // TODO: what is the type of the record?
|
||||
|
||||
row = [_records objectAtIndex:i];
|
||||
[self _flattenCycleRecord:row forRange:_r intoArray:ma];
|
||||
}
|
||||
return ma;
|
||||
}
|
||||
|
||||
- (NSArray *)fetchFields:(NSArray *)_fields
|
||||
fromFolder:(GCSFolder *)_folder
|
||||
from:(NSCalendarDate *)_startDate
|
||||
to:(NSCalendarDate *)_endDate
|
||||
{
|
||||
EOQualifier *qualifier;
|
||||
NSMutableArray *fields, *ma = nil;
|
||||
NSArray *records;
|
||||
NSString *sql;
|
||||
NGCalendarDateRange *r;
|
||||
|
||||
if (_folder == nil) {
|
||||
[self errorWithFormat:@"(%s): missing folder for fetch!",
|
||||
__PRETTY_FUNCTION__];
|
||||
return nil;
|
||||
}
|
||||
|
||||
r = [NGCalendarDateRange calendarDateRangeWithStartDate:_startDate
|
||||
endDate:_endDate];
|
||||
|
||||
/* prepare mandatory fields */
|
||||
|
||||
fields = [NSMutableArray arrayWithArray:_fields];
|
||||
[fields addObject:@"uid"];
|
||||
[fields addObject:@"startdate"];
|
||||
[fields addObject:@"enddate"];
|
||||
|
||||
if (logger)
|
||||
[self debugWithFormat:@"should fetch (%@=>%@) ...", _startDate, _endDate];
|
||||
|
||||
sql = [NSString stringWithFormat:@"(startdate < %d) AND (enddate > %d)"
|
||||
@" AND (iscycle = 0)",
|
||||
(unsigned int)[_endDate timeIntervalSince1970],
|
||||
(unsigned int)[_startDate timeIntervalSince1970]];
|
||||
|
||||
/* fetch non-recurrent apts first */
|
||||
qualifier = [EOQualifier qualifierWithQualifierFormat:sql];
|
||||
|
||||
records = [_folder fetchFields:fields matchingQualifier:qualifier];
|
||||
if (records != nil) {
|
||||
records = [self fixupRecords:records fetchRange:r];
|
||||
if (logger)
|
||||
[self debugWithFormat:@"fetched %i records: %@",[records count],records];
|
||||
ma = [NSMutableArray arrayWithArray:records];
|
||||
}
|
||||
|
||||
/* fetch recurrent apts now */
|
||||
sql = [NSString stringWithFormat:@"(startdate < %d) AND (cycleenddate > %d)"
|
||||
@" AND (iscycle = 1)",
|
||||
(unsigned int)[_endDate timeIntervalSince1970],
|
||||
(unsigned int)[_startDate timeIntervalSince1970]];
|
||||
qualifier = [EOQualifier qualifierWithQualifierFormat:sql];
|
||||
|
||||
[fields addObject:@"cycleinfo"];
|
||||
|
||||
records = [_folder fetchFields:fields matchingQualifier:qualifier];
|
||||
if (records != nil) {
|
||||
if (logger)
|
||||
[self debugWithFormat:@"fetched %i cyclic records: %@",
|
||||
[records count], records];
|
||||
records = [self fixupCyclicRecords:records fetchRange:r];
|
||||
if (!ma) ma = [NSMutableArray arrayWithCapacity:[records count]];
|
||||
[ma addObjectsFromArray:records];
|
||||
}
|
||||
else if (ma == nil) {
|
||||
[self errorWithFormat:@"(%s): fetch failed!", __PRETTY_FUNCTION__];
|
||||
return nil;
|
||||
}
|
||||
/* NOTE: why do we sort here?
|
||||
This probably belongs to UI but cannot be achieved as fast there as
|
||||
we can do it here because we're operating on a mutable array -
|
||||
having the apts sorted is never a bad idea, though
|
||||
*/
|
||||
[ma sortUsingSelector:@selector(compareAptsAscending:)];
|
||||
if (logger)
|
||||
[self debugWithFormat:@"returning %i records", [ma count]];
|
||||
return ma;
|
||||
}
|
||||
|
||||
/* override this in subclasses */
|
||||
- (NSArray *)fetchFields:(NSArray *)_fields
|
||||
from:(NSCalendarDate *)_startDate
|
||||
to:(NSCalendarDate *)_endDate
|
||||
{
|
||||
GCSFolder *folder;
|
||||
|
||||
if ((folder = [self ocsFolder]) == nil) {
|
||||
[self errorWithFormat:@"(%s): missing folder for fetch!",
|
||||
__PRETTY_FUNCTION__];
|
||||
return nil;
|
||||
}
|
||||
return [self fetchFields:_fields fromFolder:folder
|
||||
from:_startDate to:_endDate];
|
||||
}
|
||||
|
||||
|
||||
- (NSArray *)fetchFreebusyInfosFrom:(NSCalendarDate *)_startDate
|
||||
to:(NSCalendarDate *)_endDate
|
||||
{
|
||||
static NSArray *infos = nil; // TODO: move to a plist file
|
||||
if (infos == nil) {
|
||||
infos = [[NSArray alloc] initWithObjects:@"partmails", @"partstates", nil];
|
||||
}
|
||||
return [self fetchFields:infos from:_startDate to:_endDate];
|
||||
}
|
||||
|
||||
|
||||
- (NSArray *)fetchOverviewInfosFrom:(NSCalendarDate *)_startDate
|
||||
to:(NSCalendarDate *)_endDate
|
||||
{
|
||||
static NSArray *infos = nil; // TODO: move to a plist file
|
||||
if (infos == nil) {
|
||||
infos = [[NSArray alloc] initWithObjects:
|
||||
@"title",
|
||||
@"location", @"orgmail", @"status", @"ispublic",
|
||||
@"isallday", @"priority",
|
||||
@"partmails", @"partstates",
|
||||
nil];
|
||||
}
|
||||
return [self fetchFields:infos
|
||||
from:_startDate
|
||||
to:_endDate];
|
||||
}
|
||||
|
||||
- (NSArray *)fetchCoreInfosFrom:(NSCalendarDate *)_startDate
|
||||
to:(NSCalendarDate *)_endDate
|
||||
{
|
||||
static NSArray *infos = nil; // TODO: move to a plist file
|
||||
if (infos == nil) {
|
||||
infos = [[NSArray alloc] initWithObjects:
|
||||
@"title", @"location", @"orgmail",
|
||||
@"status", @"ispublic",
|
||||
@"isallday", @"isopaque",
|
||||
@"participants", @"partmails",
|
||||
@"partstates", @"sequence", @"priority", nil];
|
||||
}
|
||||
return [self fetchFields:infos
|
||||
from:_startDate
|
||||
to:_endDate];
|
||||
}
|
||||
|
||||
/* URL generation */
|
||||
|
||||
- (NSString *)baseURLForAptWithUID:(NSString *)_uid inContext:(id)_ctx {
|
||||
// TODO: who calls this?
|
||||
NSString *url;
|
||||
|
||||
if ([_uid length] == 0)
|
||||
return nil;
|
||||
|
||||
url = [self baseURLInContext:_ctx];
|
||||
if (![url hasSuffix:@"/"])
|
||||
url = [url stringByAppendingString:@"/"];
|
||||
|
||||
// TODO: this should run a query to determine the uid!
|
||||
return [url stringByAppendingString:_uid];
|
||||
}
|
||||
|
||||
/* folder management */
|
||||
|
||||
- (id)lookupHomeFolderForUID:(NSString *)_uid inContext:(id)_ctx {
|
||||
// TODO: DUP to SOGoGroupFolder
|
||||
NSException *error = nil;
|
||||
NSArray *path;
|
||||
id ctx, result;
|
||||
|
||||
if (![_uid isNotNull])
|
||||
return nil;
|
||||
|
||||
if (_ctx == nil) _ctx = [[WOApplication application] context];
|
||||
|
||||
/* create subcontext, so that we don't destroy our environment */
|
||||
|
||||
if ((ctx = [_ctx createSubContext]) == nil) {
|
||||
[self errorWithFormat:@"could not create SOPE subcontext!"];
|
||||
return nil;
|
||||
}
|
||||
|
||||
/* build path */
|
||||
|
||||
path = _uid != nil ? [NSArray arrayWithObjects:&_uid count:1] : nil;
|
||||
|
||||
/* traverse path */
|
||||
|
||||
result = [[ctx application] traversePathArray:path inContext:ctx
|
||||
error:&error acquire:NO];
|
||||
if (error != nil) {
|
||||
[self errorWithFormat:@"folder lookup failed (uid=%@): %@",
|
||||
_uid, error];
|
||||
return nil;
|
||||
}
|
||||
|
||||
[self debugWithFormat:@"Note: got folder for uid %@ path %@: %@",
|
||||
_uid, [path componentsJoinedByString:@"=>"], result];
|
||||
return result;
|
||||
}
|
||||
|
||||
- (NSArray *)lookupCalendarFoldersForUIDs:(NSArray *)_uids inContext:(id)_ctx {
|
||||
/* Note: can return NSNull objects in the array! */
|
||||
NSMutableArray *folders;
|
||||
NSEnumerator *e;
|
||||
NSString *uid;
|
||||
|
||||
if ([_uids count] == 0) return nil;
|
||||
folders = [NSMutableArray arrayWithCapacity:16];
|
||||
e = [_uids objectEnumerator];
|
||||
while ((uid = [e nextObject])) {
|
||||
id folder;
|
||||
|
||||
folder = [self lookupHomeFolderForUID:uid inContext:nil];
|
||||
if ([folder isNotNull]) {
|
||||
folder = [folder lookupName:@"Calendar" inContext:nil acquire:NO];
|
||||
if ([folder isKindOfClass:[NSException class]])
|
||||
folder = nil;
|
||||
}
|
||||
if (![folder isNotNull])
|
||||
[self logWithFormat:@"Note: did not find folder for uid: '%@'", uid];
|
||||
|
||||
/* Note: intentionally add 'null' folders to allow a mapping */
|
||||
[folders addObject:folder ? folder : [NSNull null]];
|
||||
}
|
||||
return folders;
|
||||
}
|
||||
|
||||
- (NSArray *)lookupFreeBusyObjectsForUIDs:(NSArray *)_uids inContext:(id)_ctx {
|
||||
/* Note: can return NSNull objects in the array! */
|
||||
NSMutableArray *objs;
|
||||
NSEnumerator *e;
|
||||
NSString *uid;
|
||||
|
||||
if ([_uids count] == 0) return nil;
|
||||
objs = [NSMutableArray arrayWithCapacity:16];
|
||||
e = [_uids objectEnumerator];
|
||||
while ((uid = [e nextObject])) {
|
||||
id obj;
|
||||
|
||||
obj = [self lookupHomeFolderForUID:uid inContext:nil];
|
||||
if ([obj isNotNull]) {
|
||||
obj = [obj lookupName:@"freebusy.ifb" inContext:nil acquire:NO];
|
||||
if ([obj isKindOfClass:[NSException class]])
|
||||
obj = nil;
|
||||
}
|
||||
if (![obj isNotNull])
|
||||
[self logWithFormat:@"Note: did not find freebusy.ifb for uid: '%@'", uid];
|
||||
|
||||
/* Note: intentionally add 'null' folders to allow a mapping */
|
||||
[objs addObject:obj ? obj : [NSNull null]];
|
||||
}
|
||||
return objs;
|
||||
}
|
||||
|
||||
- (NSArray *)uidsFromICalPersons:(NSArray *)_persons {
|
||||
/* Note: can return NSNull objects in the array! */
|
||||
NSMutableArray *uids;
|
||||
AgenorUserManager *um;
|
||||
unsigned i, count;
|
||||
|
||||
if (_persons == nil)
|
||||
return nil;
|
||||
|
||||
count = [_persons count];
|
||||
uids = [NSMutableArray arrayWithCapacity:count + 1];
|
||||
um = [AgenorUserManager sharedUserManager];
|
||||
|
||||
for (i = 0; i < count; i++) {
|
||||
iCalPerson *person;
|
||||
NSString *email;
|
||||
NSString *uid;
|
||||
|
||||
person = [_persons objectAtIndex:i];
|
||||
email = [person rfc822Email];
|
||||
if ([email isNotNull]) {
|
||||
uid = [um getUIDForEmail:email];
|
||||
}
|
||||
else
|
||||
uid = nil;
|
||||
|
||||
[uids addObject:(uid != nil ? uid : (id)[NSNull null])];
|
||||
}
|
||||
return uids;
|
||||
}
|
||||
|
||||
- (NSArray *)lookupCalendarFoldersForICalPerson:(NSArray *)_persons
|
||||
inContext:(id)_ctx
|
||||
{
|
||||
/* Note: can return NSNull objects in the array! */
|
||||
NSArray *uids;
|
||||
|
||||
if ((uids = [self uidsFromICalPersons:_persons]) == nil)
|
||||
return nil;
|
||||
|
||||
return [self lookupCalendarFoldersForUIDs:uids inContext:_ctx];
|
||||
}
|
||||
|
||||
- (id)lookupGroupFolderForUIDs:(NSArray *)_uids inContext:(id)_ctx {
|
||||
SOGoCustomGroupFolder *folder;
|
||||
|
||||
if (_uids == nil)
|
||||
return nil;
|
||||
|
||||
folder = [[SOGoCustomGroupFolder alloc] initWithUIDs:_uids inContainer:self];
|
||||
return [folder autorelease];
|
||||
}
|
||||
- (id)lookupGroupCalendarFolderForUIDs:(NSArray *)_uids inContext:(id)_ctx {
|
||||
SOGoCustomGroupFolder *folder;
|
||||
|
||||
if ((folder = [self lookupGroupFolderForUIDs:_uids inContext:_ctx]) == nil)
|
||||
return nil;
|
||||
|
||||
folder = [folder lookupName:@"Calendar" inContext:_ctx acquire:NO];
|
||||
if (![folder isNotNull])
|
||||
return nil;
|
||||
if ([folder isKindOfClass:[NSException class]]) {
|
||||
[self debugWithFormat:@"Note: could not lookup 'Calendar' in folder: %@",
|
||||
folder];
|
||||
return nil;
|
||||
}
|
||||
|
||||
return folder;
|
||||
}
|
||||
|
||||
/* bulk fetches */
|
||||
|
||||
- (NSArray *)fetchAllSOGoAppointments {
|
||||
/*
|
||||
Note: very expensive method, do not use unless absolutely required.
|
||||
returns an array of SOGoAppointment objects.
|
||||
|
||||
Note that we can leave out the filenames, supposed to be stored
|
||||
in the 'uid' field of the iCalendar object!
|
||||
*/
|
||||
NSMutableArray *events;
|
||||
NSDictionary *files;
|
||||
NSEnumerator *contents;
|
||||
NSString *content;
|
||||
|
||||
/* fetch all raw contents */
|
||||
|
||||
files = [self fetchContentStringsAndNamesOfAllObjects];
|
||||
if (![files isNotNull]) return nil;
|
||||
if ([files isKindOfClass:[NSException class]]) return (id)files;
|
||||
|
||||
/* transform to SOGo appointments */
|
||||
|
||||
events = [NSMutableArray arrayWithCapacity:[files count]];
|
||||
contents = [files objectEnumerator];
|
||||
while ((content = [contents nextObject]) != nil) {
|
||||
SOGoAppointment *event;
|
||||
|
||||
event = [[SOGoAppointment alloc] initWithICalString:content];
|
||||
if (![event isNotNull]) {
|
||||
[self errorWithFormat:@"(%s): could not parse an iCal file!",
|
||||
__PRETTY_FUNCTION__];
|
||||
continue;
|
||||
}
|
||||
|
||||
[events addObject:event];
|
||||
[event release];
|
||||
}
|
||||
|
||||
return events;
|
||||
}
|
||||
|
||||
/* GET */
|
||||
|
||||
- (id)GETAction:(id)_ctx {
|
||||
// TODO: I guess this should really be done by SOPE (redirect to
|
||||
// default method)
|
||||
WOResponse *r;
|
||||
NSString *uri;
|
||||
|
||||
uri = [[(WOContext *)_ctx request] uri];
|
||||
if (![uri hasSuffix:@"/"]) uri = [uri stringByAppendingString:@"/"];
|
||||
uri = [uri stringByAppendingString:@"weekoverview"];
|
||||
|
||||
r = [_ctx response];
|
||||
[r setStatus:302 /* moved */];
|
||||
[r setHeader:uri forKey:@"location"];
|
||||
return r;
|
||||
}
|
||||
|
||||
/* folder type */
|
||||
|
||||
- (NSString *)outlookFolderClass {
|
||||
return @"IPF.Appointment";
|
||||
}
|
||||
|
||||
@end /* SOGoAppointmentFolder */
|
||||
@@ -0,0 +1,72 @@
|
||||
/*
|
||||
Copyright (C) 2004-2005 SKYRIX Software AG
|
||||
|
||||
This file is part of OpenGroupware.org.
|
||||
|
||||
OGo is free software; you can redistribute it and/or modify it under
|
||||
the terms of the GNU Lesser General Public License as published by the
|
||||
Free Software Foundation; either version 2, or (at your option) any
|
||||
later version.
|
||||
|
||||
OGo 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 Lesser General Public
|
||||
License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with OGo; see the file COPYING. If not, write to the
|
||||
Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA
|
||||
02111-1307, USA.
|
||||
*/
|
||||
|
||||
#ifndef __Appointments_SOGoAppointmentObject_H__
|
||||
#define __Appointments_SOGoAppointmentObject_H__
|
||||
|
||||
#include <SOGo/SOGoContentObject.h>
|
||||
|
||||
/*
|
||||
SOGoAppointmentObject
|
||||
|
||||
Represents a single appointment. This SOPE controller object manages all the
|
||||
attendee storages (that is, it might store into multiple folders for meeting
|
||||
appointments!).
|
||||
|
||||
Note: SOGoAppointmentObject do not need to exist yet. They can also be "new"
|
||||
appointments with an externally generated unique key.
|
||||
*/
|
||||
|
||||
@class NSString, NSArray, NSException, iCalEvent;
|
||||
|
||||
@interface SOGoAppointmentObject : SOGoContentObject
|
||||
{
|
||||
}
|
||||
|
||||
/* accessors */
|
||||
|
||||
- (NSString *)iCalString;
|
||||
- (iCalEvent *)event;
|
||||
|
||||
/* folder management */
|
||||
|
||||
- (id)lookupHomeFolderForUID:(NSString *)_uid inContext:(id)_ctx;
|
||||
- (NSArray *)lookupCalendarFoldersForUIDs:(NSArray *)_uids inContext:(id)_ctx;
|
||||
|
||||
/* raw saving */
|
||||
|
||||
- (NSException *)primarySaveContentString:(NSString *)_iCalString;
|
||||
- (NSException *)primaryDelete;
|
||||
|
||||
/* "iCal multifolder saves" */
|
||||
|
||||
- (NSException *)saveContentString:(NSString *)_iCal baseSequence:(int)_v;
|
||||
- (NSException *)deleteWithBaseSequence:(int)_v;
|
||||
|
||||
- (NSException *)saveContentString:(NSString *)_iCalString;
|
||||
- (NSException *)delete;
|
||||
|
||||
- (NSException *)changeParticipationStatus:(NSString *)_status
|
||||
inContext:(id)_ctx;
|
||||
|
||||
@end
|
||||
|
||||
#endif /* __Appointments_SOGoAppointmentObject_H__ */
|
||||
@@ -0,0 +1,772 @@
|
||||
/*
|
||||
Copyright (C) 2004-2005 SKYRIX Software AG
|
||||
|
||||
This file is part of OpenGroupware.org.
|
||||
|
||||
OGo is free software; you can redistribute it and/or modify it under
|
||||
the terms of the GNU Lesser General Public License as published by the
|
||||
Free Software Foundation; either version 2, or (at your option) any
|
||||
later version.
|
||||
|
||||
OGo 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 Lesser General Public
|
||||
License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with OGo; see the file COPYING. If not, write to the
|
||||
Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA
|
||||
02111-1307, USA.
|
||||
*/
|
||||
|
||||
#include "SOGoAppointmentObject.h"
|
||||
#include <SOGo/AgenorUserManager.h>
|
||||
#include <SOGo/SOGoAppointment.h>
|
||||
#include <SaxObjC/SaxObjC.h>
|
||||
#include <NGiCal/NGiCal.h>
|
||||
#include <NGMime/NGMime.h>
|
||||
#include <NGMail/NGMail.h>
|
||||
#include <NGMail/NGSendMail.h>
|
||||
#include "SOGoAptMailNotification.h"
|
||||
#include "common.h"
|
||||
|
||||
@interface NSMutableArray (iCalPersonConvenience)
|
||||
- (void)removePerson:(iCalPerson *)_person;
|
||||
@end
|
||||
|
||||
@interface SOGoAppointmentObject (PrivateAPI)
|
||||
- (NSString *)homePageURLForPerson:(iCalPerson *)_person;
|
||||
- (NSTimeZone *)viewTimeZoneForPerson:(iCalPerson *)_person;
|
||||
|
||||
- (void)sendEMailUsingTemplateNamed:(NSString *)_pageName
|
||||
forOldAppointment:(SOGoAppointment *)_newApt
|
||||
andNewAppointment:(SOGoAppointment *)_oldApt
|
||||
toAttendees:(NSArray *)_attendees;
|
||||
|
||||
- (void)sendInvitationEMailForAppointment:(SOGoAppointment *)_apt
|
||||
toAttendees:(NSArray *)_attendees;
|
||||
- (void)sendAppointmentUpdateEMailForOldAppointment:(SOGoAppointment *)_oldApt
|
||||
newAppointment:(SOGoAppointment *)_newApt
|
||||
toAttendees:(NSArray *)_attendees;
|
||||
- (void)sendAttendeeRemovalEMailForAppointment:(SOGoAppointment *)_apt
|
||||
toAttendees:(NSArray *)_attendees;
|
||||
- (void)sendAppointmentDeletionEMailForAppointment:(SOGoAppointment *)_apt
|
||||
toAttendees:(NSArray *)_attendees;
|
||||
@end
|
||||
|
||||
@implementation SOGoAppointmentObject
|
||||
|
||||
static id<NSObject,SaxXMLReader> parser = nil;
|
||||
static SaxObjectDecoder *sax = nil;
|
||||
static NGLogger *logger = nil;
|
||||
static NSTimeZone *MET = nil;
|
||||
static NSString *mailTemplateDefaultLanguage = nil;
|
||||
|
||||
+ (void)initialize {
|
||||
NSUserDefaults *ud;
|
||||
NGLoggerManager *lm;
|
||||
SaxXMLReaderFactory *factory;
|
||||
static BOOL didInit = NO;
|
||||
|
||||
if (didInit) return;
|
||||
didInit = YES;
|
||||
|
||||
lm = [NGLoggerManager defaultLoggerManager];
|
||||
logger = [lm loggerForClass:self];
|
||||
|
||||
factory = [SaxXMLReaderFactory standardXMLReaderFactory];
|
||||
parser = [[factory createXMLReaderForMimeType:@"text/calendar"]
|
||||
retain];
|
||||
if (parser == nil)
|
||||
[logger fatalWithFormat:@"did not find a parser for text/calendar!"];
|
||||
sax = [[SaxObjectDecoder alloc] initWithMappingNamed:@"NGiCal"];
|
||||
if (sax == nil)
|
||||
[logger fatalWithFormat:@"could not create the iCal SAX handler!"];
|
||||
|
||||
[parser setContentHandler:sax];
|
||||
[parser setErrorHandler:sax];
|
||||
|
||||
MET = [[NSTimeZone timeZoneWithAbbreviation:@"MET"] retain];
|
||||
|
||||
ud = [NSUserDefaults standardUserDefaults];
|
||||
mailTemplateDefaultLanguage = [[ud stringForKey:@"SOGoDefaultLanguage"]
|
||||
retain];
|
||||
if (!mailTemplateDefaultLanguage)
|
||||
mailTemplateDefaultLanguage = @"French";
|
||||
}
|
||||
|
||||
- (void)dealloc {
|
||||
[super dealloc];
|
||||
}
|
||||
|
||||
/* accessors */
|
||||
|
||||
- (NSString *)iCalString {
|
||||
// for UI-X appointment viewer
|
||||
return [self contentAsString];
|
||||
}
|
||||
|
||||
- (iCalEvent *)event {
|
||||
NSString *iCalString;
|
||||
iCalEvent *event;
|
||||
|
||||
iCalString = [self iCalString];
|
||||
if ([iCalString length] > 0) {
|
||||
iCalCalendar *cal;
|
||||
|
||||
[parser parseFromSource:iCalString];
|
||||
cal = [sax rootObject];
|
||||
[sax reset];
|
||||
event = [[cal events] lastObject];
|
||||
return event;
|
||||
}
|
||||
return nil;
|
||||
}
|
||||
|
||||
/* iCal handling */
|
||||
|
||||
- (NSArray *)attendeeUIDsFromAppointment:(SOGoAppointment *)_apt {
|
||||
AgenorUserManager *um;
|
||||
NSMutableArray *uids;
|
||||
NSArray *attendees;
|
||||
unsigned i, count;
|
||||
NSString *email, *uid;
|
||||
|
||||
if (![_apt isNotNull])
|
||||
return nil;
|
||||
|
||||
if ((attendees = [_apt attendees]) == nil)
|
||||
return nil;
|
||||
count = [attendees count];
|
||||
uids = [NSMutableArray arrayWithCapacity:count + 1];
|
||||
|
||||
um = [AgenorUserManager sharedUserManager];
|
||||
|
||||
/* add organizer */
|
||||
|
||||
email = [[_apt organizer] rfc822Email];
|
||||
if ([email isNotNull]) {
|
||||
uid = [um getUIDForEmail:email];
|
||||
if ([uid isNotNull]) {
|
||||
[uids addObject:uid];
|
||||
}
|
||||
else
|
||||
[self logWithFormat:@"Note: got no uid for organizer: '%@'", email];
|
||||
}
|
||||
|
||||
/* add attendees */
|
||||
|
||||
for (i = 0; i < count; i++) {
|
||||
iCalPerson *person;
|
||||
|
||||
person = [attendees objectAtIndex:i];
|
||||
email = [person rfc822Email];
|
||||
if (![email isNotNull]) continue;
|
||||
|
||||
uid = [um getUIDForEmail:email];
|
||||
if (![uid isNotNull]) {
|
||||
[self logWithFormat:@"Note: got no uid for email: '%@'", email];
|
||||
continue;
|
||||
}
|
||||
if (![uids containsObject:uid])
|
||||
[uids addObject:uid];
|
||||
}
|
||||
|
||||
return uids;
|
||||
}
|
||||
|
||||
/* raw saving */
|
||||
|
||||
- (NSException *)primarySaveContentString:(NSString *)_iCalString {
|
||||
return [super saveContentString:_iCalString];
|
||||
}
|
||||
- (NSException *)primaryDelete {
|
||||
return [super delete];
|
||||
}
|
||||
|
||||
/* folder management */
|
||||
|
||||
- (id)lookupHomeFolderForUID:(NSString *)_uid inContext:(id)_ctx {
|
||||
// TODO: what does this do? lookup the home of the organizer?
|
||||
return [[self container] lookupHomeFolderForUID:_uid inContext:_ctx];
|
||||
}
|
||||
- (NSArray *)lookupCalendarFoldersForUIDs:(NSArray *)_uids inContext:(id)_ctx {
|
||||
return [[self container] lookupCalendarFoldersForUIDs:_uids inContext:_ctx];
|
||||
}
|
||||
|
||||
/* store in all the other folders */
|
||||
|
||||
- (NSException *)saveContentString:(NSString *)_iCal inUIDs:(NSArray *)_uids {
|
||||
NSEnumerator *e;
|
||||
id folder;
|
||||
NSException *allErrors = nil;
|
||||
id ctx;
|
||||
|
||||
ctx = [[WOApplication application] context];
|
||||
|
||||
e = [[self lookupCalendarFoldersForUIDs:_uids inContext:ctx]
|
||||
objectEnumerator];
|
||||
while ((folder = [e nextObject]) != nil) {
|
||||
NSException *error;
|
||||
SOGoAppointmentObject *apt;
|
||||
|
||||
if (![folder isNotNull]) /* no folder was found for given UID */
|
||||
continue;
|
||||
|
||||
apt = [folder lookupName:[self nameInContainer] inContext:ctx
|
||||
acquire:NO];
|
||||
if (![apt isNotNull]) {
|
||||
[self logWithFormat:@"Note: did not find '%@' in folder: %@",
|
||||
[self nameInContainer], folder];
|
||||
continue;
|
||||
}
|
||||
|
||||
if ((error = [apt primarySaveContentString:_iCal]) != nil) {
|
||||
[self logWithFormat:@"Note: failed to save iCal in folder: %@", folder];
|
||||
// TODO: make compound
|
||||
allErrors = error;
|
||||
}
|
||||
}
|
||||
return allErrors;
|
||||
}
|
||||
- (NSException *)deleteInUIDs:(NSArray *)_uids {
|
||||
NSEnumerator *e;
|
||||
id folder;
|
||||
NSException *allErrors = nil;
|
||||
id ctx;
|
||||
|
||||
ctx = [[WOApplication application] context];
|
||||
|
||||
e = [[self lookupCalendarFoldersForUIDs:_uids inContext:ctx]
|
||||
objectEnumerator];
|
||||
while ((folder = [e nextObject])) {
|
||||
NSException *error;
|
||||
SOGoAppointmentObject *apt;
|
||||
|
||||
apt = [folder lookupName:[self nameInContainer] inContext:ctx
|
||||
acquire:NO];
|
||||
if (![apt isNotNull]) {
|
||||
[self logWithFormat:@"Note: did not find '%@' in folder: %@",
|
||||
[self nameInContainer], folder];
|
||||
continue;
|
||||
}
|
||||
|
||||
if ((error = [apt primaryDelete]) != nil) {
|
||||
[self logWithFormat:@"Note: failed to delete in folder: %@", folder];
|
||||
// TODO: make compound
|
||||
allErrors = error;
|
||||
}
|
||||
}
|
||||
return allErrors;
|
||||
}
|
||||
|
||||
/* "iCal multifolder saves" */
|
||||
|
||||
- (NSException *)saveContentString:(NSString *)_iCal baseSequence:(int)_v {
|
||||
/*
|
||||
Note: we need to delete in all participants folders and send iMIP messages
|
||||
for all external accounts.
|
||||
|
||||
Steps:
|
||||
- fetch stored content
|
||||
- parse old content
|
||||
- check if sequence matches (or if 0=ignore)
|
||||
- extract old attendee list + organizer (make unique)
|
||||
- parse new content (ensure that sequence is increased!)
|
||||
- extract new attendee list + organizer (make unique)
|
||||
- make a diff => new, same, removed
|
||||
- write to new, same
|
||||
- delete in removed folders
|
||||
- send iMIP mail for all folders not found
|
||||
*/
|
||||
AgenorUserManager *um;
|
||||
SOGoAppointment *oldApt, *newApt;
|
||||
iCalEventChanges *changes;
|
||||
iCalPerson *organizer;
|
||||
NSString *oldContent, *uid;
|
||||
NSArray *uids, *props;
|
||||
NSMutableArray *attendees, *storeUIDs, *removedUIDs;
|
||||
NSException *storeError, *delError;
|
||||
BOOL updateForcesReconsider;
|
||||
|
||||
updateForcesReconsider = NO;
|
||||
|
||||
if ([_iCal length] == 0) {
|
||||
return [NSException exceptionWithHTTPStatus:400 /* Bad Request */
|
||||
reason:@"got no iCalendar content to store!"];
|
||||
}
|
||||
|
||||
um = [AgenorUserManager sharedUserManager];
|
||||
|
||||
/* handle old content */
|
||||
|
||||
oldContent = [self iCalString]; /* if nil, this is a new appointment */
|
||||
if ([oldContent length] == 0) {
|
||||
/* new appointment */
|
||||
[self debugWithFormat:@"saving new appointment: %@", _iCal];
|
||||
oldApt = nil;
|
||||
}
|
||||
else {
|
||||
oldApt =
|
||||
[[[SOGoAppointment alloc] initWithICalString:oldContent] autorelease];
|
||||
}
|
||||
|
||||
/* compare sequence if requested */
|
||||
|
||||
if (_v != 0) {
|
||||
// TODO
|
||||
}
|
||||
|
||||
|
||||
/* handle new content */
|
||||
|
||||
newApt = [[[SOGoAppointment alloc] initWithICalString:_iCal] autorelease];
|
||||
if (newApt == nil) {
|
||||
return [NSException exceptionWithHTTPStatus:400 /* Bad Request */
|
||||
reason:@"could not parse iCalendar content!"];
|
||||
}
|
||||
|
||||
/* diff */
|
||||
|
||||
changes = [iCalEventChanges changesFromEvent:[oldApt event]
|
||||
toEvent:[newApt event]];
|
||||
|
||||
uids = [um getUIDsForICalPersons:[changes deletedAttendees]
|
||||
applyStrictMapping:NO];
|
||||
removedUIDs = [NSMutableArray arrayWithArray:uids];
|
||||
|
||||
uids = [um getUIDsForICalPersons:[newApt attendees]
|
||||
applyStrictMapping:NO];
|
||||
storeUIDs = [NSMutableArray arrayWithArray:uids];
|
||||
props = [changes updatedProperties];
|
||||
|
||||
/* detect whether sequence has to be increased */
|
||||
if ([changes hasChanges])
|
||||
[newApt increaseSequence];
|
||||
|
||||
/* preserve organizer */
|
||||
|
||||
organizer = [[newApt event] organizer];
|
||||
uid = [um getUIDForICalPerson:organizer];
|
||||
if (uid) {
|
||||
if (![storeUIDs containsObject:uid])
|
||||
[storeUIDs addObject:uid];
|
||||
[removedUIDs removeObject:uid];
|
||||
}
|
||||
|
||||
/* organizer might have changed completely */
|
||||
|
||||
if ((oldApt != nil) && ([props containsObject:@"organizer"])) {
|
||||
uid = [um getUIDForICalPerson:[[oldApt event] organizer]];
|
||||
if (uid) {
|
||||
if (![storeUIDs containsObject:uid]) {
|
||||
if (![removedUIDs containsObject:uid]) {
|
||||
[removedUIDs addObject:uid];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
[self debugWithFormat:@"UID ops:\n store: %@\n remove: %@",
|
||||
storeUIDs, removedUIDs];
|
||||
|
||||
/* if time did change, all participants have to re-decide ...
|
||||
* ... exception from that rule: the organizer
|
||||
*/
|
||||
|
||||
if (oldApt != nil &&
|
||||
([props containsObject:@"startDate"] ||
|
||||
[props containsObject:@"endDate"] ||
|
||||
[props containsObject:@"duration"]))
|
||||
{
|
||||
NSArray *ps;
|
||||
unsigned i, count;
|
||||
|
||||
ps = [newApt attendees];
|
||||
count = [ps count];
|
||||
for (i = 0; i < count; i++) {
|
||||
iCalPerson *p;
|
||||
|
||||
p = [ps objectAtIndex:i];
|
||||
if (![p hasSameEmailAddress:organizer])
|
||||
[p setParticipationStatus:iCalPersonPartStatNeedsAction];
|
||||
}
|
||||
_iCal = [newApt iCalString];
|
||||
updateForcesReconsider = YES;
|
||||
}
|
||||
|
||||
/* perform storing */
|
||||
|
||||
storeError = [self saveContentString:_iCal inUIDs:storeUIDs];
|
||||
delError = [self deleteInUIDs:removedUIDs];
|
||||
|
||||
// TODO: make compound
|
||||
if (storeError != nil) return storeError;
|
||||
if (delError != nil) return delError;
|
||||
|
||||
/* email notifications */
|
||||
|
||||
attendees = [NSMutableArray arrayWithArray:[changes insertedAttendees]];
|
||||
[attendees removePerson:organizer];
|
||||
[self sendInvitationEMailForAppointment:newApt
|
||||
toAttendees:attendees];
|
||||
|
||||
if (updateForcesReconsider) {
|
||||
attendees = [NSMutableArray arrayWithArray:[[newApt event] attendees]];
|
||||
[attendees removeObjectsInArray:[changes insertedAttendees]];
|
||||
[attendees removePerson:organizer];
|
||||
[self sendAppointmentUpdateEMailForOldAppointment:oldApt
|
||||
newAppointment:newApt
|
||||
toAttendees:attendees];
|
||||
}
|
||||
|
||||
attendees = [NSMutableArray arrayWithArray:[changes deletedAttendees]];
|
||||
[attendees removePerson:organizer];
|
||||
if ([attendees count]) {
|
||||
SOGoAppointment *canceledApt;
|
||||
|
||||
canceledApt = [newApt copy];
|
||||
[canceledApt cancelWithoutIncreasingSequence];
|
||||
[self sendAttendeeRemovalEMailForAppointment:canceledApt
|
||||
toAttendees:attendees];
|
||||
[canceledApt release];
|
||||
}
|
||||
return nil;
|
||||
}
|
||||
|
||||
- (NSException *)deleteWithBaseSequence:(int)_v {
|
||||
/*
|
||||
Note: We need to delete in all participants folders and send iMIP messages
|
||||
for all external accounts.
|
||||
Delete is basically identical to save with all attendees and the
|
||||
organizer being deleted.
|
||||
|
||||
Steps:
|
||||
- fetch stored content
|
||||
- parse old content
|
||||
- check if sequence matches (or if 0=ignore)
|
||||
- extract old attendee list + organizer (make unique)
|
||||
- delete in removed folders
|
||||
- send iMIP mail for all folders not found
|
||||
*/
|
||||
SOGoAppointment *apt;
|
||||
NSString *econtent;
|
||||
NSArray *removedUIDs;
|
||||
NSMutableArray *attendees;
|
||||
|
||||
/* load existing content */
|
||||
|
||||
econtent = [self iCalString]; /* if nil, this is a new appointment */
|
||||
apt = [[[SOGoAppointment alloc] initWithICalString:econtent] autorelease];
|
||||
|
||||
/* compare sequence if requested */
|
||||
|
||||
if (_v != 0) {
|
||||
// TODO
|
||||
}
|
||||
|
||||
removedUIDs = [self attendeeUIDsFromAppointment:apt];
|
||||
|
||||
/* send notification email to attendees excluding organizer */
|
||||
attendees = [NSMutableArray arrayWithArray:[[apt event] attendees]];
|
||||
[attendees removePerson:[apt organizer]];
|
||||
|
||||
/* flag appointment as being canceled */
|
||||
[apt cancelAndIncreaseSequence];
|
||||
/* remove all attendees to signal complete removal */
|
||||
[apt removeAllAttendees];
|
||||
|
||||
/* send notification email */
|
||||
[self sendAppointmentDeletionEMailForAppointment:apt
|
||||
toAttendees:attendees];
|
||||
|
||||
/* perform */
|
||||
|
||||
return [self deleteInUIDs:removedUIDs];
|
||||
}
|
||||
|
||||
- (NSException *)saveContentString:(NSString *)_iCalString {
|
||||
return [self saveContentString:_iCalString baseSequence:0];
|
||||
}
|
||||
- (NSException *)delete {
|
||||
return [self deleteWithBaseSequence:0];
|
||||
}
|
||||
|
||||
|
||||
- (NSException *)changeParticipationStatus:(NSString *)_status
|
||||
inContext:(id)_ctx
|
||||
{
|
||||
SOGoAppointment *apt;
|
||||
iCalPerson *p;
|
||||
NSString *newContent;
|
||||
NSException *ex;
|
||||
NSString *myEMail;
|
||||
|
||||
// TODO: do we need to use SOGoAppointment? (prefer iCalEvent?)
|
||||
apt = [[SOGoAppointment alloc] initWithICalString:[self iCalString]];
|
||||
if (apt == nil) {
|
||||
return [NSException exceptionWithHTTPStatus:500 /* Server Error */
|
||||
reason:@"unable to parse appointment record"];
|
||||
}
|
||||
|
||||
myEMail = [[_ctx activeUser] email];
|
||||
if ((p = [apt findParticipantWithEmail:myEMail]) == nil) {
|
||||
return [NSException exceptionWithHTTPStatus:404 /* Not Found */
|
||||
reason:@"user does not participate in this "
|
||||
@"appointment"];
|
||||
}
|
||||
|
||||
[p setPartStat:_status];
|
||||
newContent = [[[apt iCalString] copy] autorelease];
|
||||
|
||||
// TODO: send iMIP reply mails?
|
||||
|
||||
[apt release]; apt = nil;
|
||||
|
||||
if (newContent == nil) {
|
||||
return [NSException exceptionWithHTTPStatus:500 /* Server Error */
|
||||
reason:@"Could not generate iCalendar data ..."];
|
||||
}
|
||||
|
||||
if ((ex = [self saveContentString:newContent]) != nil) {
|
||||
// TODO: why is the exception wrapped?
|
||||
return [NSException exceptionWithHTTPStatus:500 /* Server Error */
|
||||
reason:[ex reason]];
|
||||
}
|
||||
|
||||
return nil /* means: no error */;
|
||||
}
|
||||
|
||||
|
||||
/* message type */
|
||||
|
||||
- (NSString *)outlookMessageClass {
|
||||
return @"IPM.Appointment";
|
||||
}
|
||||
|
||||
/* EMail Notifications */
|
||||
|
||||
- (NSString *)homePageURLForPerson:(iCalPerson *)_person {
|
||||
static AgenorUserManager *um = nil;
|
||||
static NSString *baseURL = nil;
|
||||
NSString *uid;
|
||||
|
||||
if (!um) {
|
||||
WOContext *ctx;
|
||||
NSArray *traversalObjects;
|
||||
|
||||
um = [[AgenorUserManager sharedUserManager] retain];
|
||||
|
||||
/* generate URL from traversal stack */
|
||||
ctx = [[WOApplication application] context];
|
||||
traversalObjects = [ctx objectTraversalStack];
|
||||
if ([traversalObjects count] >= 1) {
|
||||
baseURL = [[[traversalObjects objectAtIndex:0] baseURLInContext:ctx]
|
||||
retain];
|
||||
}
|
||||
else {
|
||||
[self warnWithFormat:@"Unable to create baseURL from context!"];
|
||||
baseURL = @"http://localhost/";
|
||||
}
|
||||
}
|
||||
uid = [um getUIDForEmail:[_person rfc822Email]];
|
||||
if (!uid) return nil;
|
||||
return [NSString stringWithFormat:@"%@%@", baseURL, uid];
|
||||
}
|
||||
|
||||
- (NSTimeZone *)viewTimeZoneForPerson:(iCalPerson *)_person {
|
||||
/* TODO: get this from user config as soon as this is available and only
|
||||
* fall back to default timeZone if config data is not available
|
||||
*/
|
||||
return MET;
|
||||
}
|
||||
|
||||
|
||||
- (void)sendEMailUsingTemplateNamed:(NSString *)_pageName
|
||||
forOldAppointment:(SOGoAppointment *)_oldApt
|
||||
andNewAppointment:(SOGoAppointment *)_newApt
|
||||
toAttendees:(NSArray *)_attendees
|
||||
{
|
||||
NSString *pageName;
|
||||
iCalPerson *organizer;
|
||||
NSString *cn, *sender, *iCalString;
|
||||
NGSendMail *sendmail;
|
||||
WOApplication *app;
|
||||
unsigned i, count;
|
||||
|
||||
if (![_attendees count]) return; // another job neatly done :-)
|
||||
|
||||
/* sender */
|
||||
|
||||
organizer = [_newApt organizer];
|
||||
cn = [organizer cnWithoutQuotes];
|
||||
if (cn) {
|
||||
sender = [NSString stringWithFormat:@"%@ <%@>",
|
||||
cn,
|
||||
[organizer rfc822Email]];
|
||||
}
|
||||
else {
|
||||
sender = [organizer rfc822Email];
|
||||
}
|
||||
|
||||
/* generate iCalString once */
|
||||
iCalString = [_newApt iCalString];
|
||||
|
||||
/* get sendmail object */
|
||||
sendmail = [NGSendMail sharedSendMail];
|
||||
|
||||
/* get WOApplication instance */
|
||||
app = [WOApplication application];
|
||||
|
||||
/* generate dynamic message content */
|
||||
|
||||
count = [_attendees count];
|
||||
for (i = 0; i < count; i++) {
|
||||
iCalPerson *attendee;
|
||||
NSString *recipient;
|
||||
SOGoAptMailNotification *p;
|
||||
NSString *subject, *text, *header;
|
||||
NGMutableHashMap *headerMap;
|
||||
NGMimeMessage *msg;
|
||||
NGMimeBodyPart *bodyPart;
|
||||
NGMimeMultipartBody *body;
|
||||
|
||||
attendee = [_attendees objectAtIndex:i];
|
||||
|
||||
/* construct recipient */
|
||||
cn = [attendee cn];
|
||||
if (cn) {
|
||||
recipient = [NSString stringWithFormat:@"%@ <%@>",
|
||||
cn,
|
||||
[attendee rfc822Email]];
|
||||
}
|
||||
else {
|
||||
recipient = [attendee rfc822Email];
|
||||
}
|
||||
|
||||
/* create page name */
|
||||
// TODO: select user's default language?
|
||||
pageName = [NSString stringWithFormat:@"SOGoAptMail%@%@",
|
||||
mailTemplateDefaultLanguage,
|
||||
_pageName];
|
||||
/* construct message content */
|
||||
p = [app pageWithName:pageName inContext:[WOContext context]];
|
||||
[p setNewApt:_newApt];
|
||||
[p setOldApt:_oldApt];
|
||||
[p setHomePageURL:[self homePageURLForPerson:attendee]];
|
||||
[p setViewTZ:[self viewTimeZoneForPerson:attendee]];
|
||||
subject = [p getSubject];
|
||||
text = [p getBody];
|
||||
|
||||
/* construct message */
|
||||
headerMap = [NGMutableHashMap hashMapWithCapacity:5];
|
||||
|
||||
/* NOTE: multipart/alternative seems like the correct choice but
|
||||
* unfortunately Thunderbird doesn't offer the rich content alternative
|
||||
* at all. Mail.app shows the rich content alternative _only_
|
||||
* so we'll stick with multipart/mixed for the time being.
|
||||
*/
|
||||
[headerMap setObject:@"multipart/mixed" forKey:@"content-type"];
|
||||
[headerMap setObject:sender forKey:@"From"];
|
||||
[headerMap setObject:recipient forKey:@"To"];
|
||||
[headerMap setObject:[NSCalendarDate date] forKey:@"date"];
|
||||
[headerMap setObject:subject forKey:@"Subject"];
|
||||
msg = [NGMimeMessage messageWithHeader:headerMap];
|
||||
|
||||
/* multipart body */
|
||||
body = [[NGMimeMultipartBody alloc] initWithPart:msg];
|
||||
|
||||
/* text part */
|
||||
headerMap = [NGMutableHashMap hashMapWithCapacity:1];
|
||||
[headerMap setObject:@"text/plain; charset=utf-8" forKey:@"content-type"];
|
||||
bodyPart = [NGMimeBodyPart bodyPartWithHeader:headerMap];
|
||||
[bodyPart setBody:[text dataUsingEncoding:NSUTF8StringEncoding]];
|
||||
|
||||
/* attach text part to multipart body */
|
||||
[body addBodyPart:bodyPart];
|
||||
|
||||
/* calendar part */
|
||||
header = [NSString stringWithFormat:@"text/calendar; method=%@;"
|
||||
@" charset=utf-8",
|
||||
[_newApt method]];
|
||||
headerMap = [NGMutableHashMap hashMapWithCapacity:1];
|
||||
[headerMap setObject:header forKey:@"content-type"];
|
||||
bodyPart = [NGMimeBodyPart bodyPartWithHeader:headerMap];
|
||||
[bodyPart setBody:[iCalString dataUsingEncoding:NSUTF8StringEncoding]];
|
||||
|
||||
/* attach calendar part to multipart body */
|
||||
[body addBodyPart:bodyPart];
|
||||
|
||||
/* attach multipart body to message */
|
||||
[msg setBody:body];
|
||||
[body release];
|
||||
|
||||
/* send the damn thing */
|
||||
[sendmail sendMimePart:msg
|
||||
toRecipients:[NSArray arrayWithObject:[attendee rfc822Email]]
|
||||
sender:[organizer rfc822Email]];
|
||||
}
|
||||
}
|
||||
|
||||
- (void)sendInvitationEMailForAppointment:(SOGoAppointment *)_apt
|
||||
toAttendees:(NSArray *)_attendees
|
||||
{
|
||||
if (![_attendees count]) return; // another job neatly done :-)
|
||||
|
||||
[self sendEMailUsingTemplateNamed:@"Invitation"
|
||||
forOldAppointment:nil
|
||||
andNewAppointment:_apt
|
||||
toAttendees:_attendees];
|
||||
}
|
||||
|
||||
- (void)sendAppointmentUpdateEMailForOldAppointment:(SOGoAppointment *)_oldApt
|
||||
newAppointment:(SOGoAppointment *)_newApt
|
||||
toAttendees:(NSArray *)_attendees
|
||||
{
|
||||
if (![_attendees count]) return;
|
||||
|
||||
[self sendEMailUsingTemplateNamed:@"Update"
|
||||
forOldAppointment:_oldApt
|
||||
andNewAppointment:_newApt
|
||||
toAttendees:_attendees];
|
||||
}
|
||||
|
||||
- (void)sendAttendeeRemovalEMailForAppointment:(SOGoAppointment *)_apt
|
||||
toAttendees:(NSArray *)_attendees
|
||||
{
|
||||
if (![_attendees count]) return;
|
||||
|
||||
[self sendEMailUsingTemplateNamed:@"Removal"
|
||||
forOldAppointment:nil
|
||||
andNewAppointment:_apt
|
||||
toAttendees:_attendees];
|
||||
}
|
||||
|
||||
- (void)sendAppointmentDeletionEMailForAppointment:(SOGoAppointment *)_apt
|
||||
toAttendees:(NSArray *)_attendees
|
||||
{
|
||||
if (![_attendees count]) return;
|
||||
|
||||
[self sendEMailUsingTemplateNamed:@"Deletion"
|
||||
forOldAppointment:nil
|
||||
andNewAppointment:_apt
|
||||
toAttendees:_attendees];
|
||||
}
|
||||
|
||||
@end /* SOGoAppointmentObject */
|
||||
|
||||
@implementation NSMutableArray (iCalPersonConvenience)
|
||||
|
||||
- (void)removePerson:(iCalPerson *)_person {
|
||||
int i;
|
||||
|
||||
for (i = [self count] - 1; i >= 0; i--) {
|
||||
iCalPerson *p;
|
||||
|
||||
p = [self objectAtIndex:i];
|
||||
if ([p hasSameEmailAddress:_person])
|
||||
[self removeObjectAtIndex:i];
|
||||
}
|
||||
}
|
||||
|
||||
@end /* NSMutableArray (iCalPersonConvenience) */
|
||||
@@ -0,0 +1,38 @@
|
||||
/*
|
||||
Copyright (C) 2000-2005 SKYRIX Software AG
|
||||
|
||||
This file is part of OpenGroupware.org.
|
||||
|
||||
OGo is free software; you can redistribute it and/or modify it under
|
||||
the terms of the GNU Lesser General Public License as published by the
|
||||
Free Software Foundation; either version 2, or (at your option) any
|
||||
later version.
|
||||
|
||||
OGo 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 Lesser General Public
|
||||
License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with OGo; see the file COPYING. If not, write to the
|
||||
Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA
|
||||
02111-1307, USA.
|
||||
*/
|
||||
|
||||
#include "SOGoAptMailNotification.h"
|
||||
|
||||
@interface SOGoAptMailEnglishDeletion : SOGoAptMailNotification
|
||||
{
|
||||
}
|
||||
@end
|
||||
|
||||
@implementation SOGoAptMailEnglishDeletion
|
||||
@end
|
||||
|
||||
@interface SOGoAptMailFrenchDeletion : SOGoAptMailNotification
|
||||
{
|
||||
}
|
||||
@end
|
||||
|
||||
@implementation SOGoAptMailFrenchDeletion
|
||||
@end
|
||||
@@ -0,0 +1,4 @@
|
||||
<#IsSubject>Appointment <#AptStartDate /> at <#AptStartTime /> has been canceled</#IsSubject>
|
||||
<#IsBody>
|
||||
The appointment at <#AptStartDate /> <#AptStartTime /> has been cancelled by <#Organizer />.
|
||||
</#IsBody>
|
||||
@@ -0,0 +1,34 @@
|
||||
AptStartDate: WOString {
|
||||
value = newStartDate;
|
||||
dateformat = "%d/%m/%y";
|
||||
escapeHTML = NO;
|
||||
}
|
||||
|
||||
AptStartTime: WOString {
|
||||
value = newStartDate;
|
||||
dateformat = "%H:%M";
|
||||
escapeHTML = NO;
|
||||
}
|
||||
|
||||
Organizer: WOString {
|
||||
value = newApt.organizer.cnWithoutQuotes;
|
||||
escapeHTML = NO;
|
||||
}
|
||||
|
||||
HasHomePageURL: WOConditional {
|
||||
condition = homePageURL.length;
|
||||
}
|
||||
|
||||
HomePageURL: WOString {
|
||||
value = appointmentURL;
|
||||
escapeHTML = NO;
|
||||
}
|
||||
|
||||
IsSubject: WOConditional {
|
||||
condition = isSubject;
|
||||
}
|
||||
|
||||
IsBody: WOConditional {
|
||||
condition = isSubject;
|
||||
negate = YES;
|
||||
}
|
||||
+7
@@ -0,0 +1,7 @@
|
||||
<#IsSubject>Apt le <#AptStartDate /> at <#AptStartTime /></#IsSubject>
|
||||
<#IsBody>
|
||||
You're invited by <#Organizer /> to a meeting.
|
||||
<#HasHomePageURL>
|
||||
Please make a decision for this invitation at <#HomePageURL />.
|
||||
</#HasHomePageURL>
|
||||
</#IsBody>
|
||||
+34
@@ -0,0 +1,34 @@
|
||||
AptStartDate: WOString {
|
||||
value = newStartDate;
|
||||
dateformat = "%d/%m/%y";
|
||||
escapeHTML = NO;
|
||||
}
|
||||
|
||||
AptStartTime: WOString {
|
||||
value = newStartDate;
|
||||
dateformat = "%H:%M";
|
||||
escapeHTML = NO;
|
||||
}
|
||||
|
||||
Organizer: WOString {
|
||||
value = newApt.organizer.cnWithoutQuotes;
|
||||
escapeHTML = NO;
|
||||
}
|
||||
|
||||
HasHomePageURL: WOConditional {
|
||||
condition = homePageURL.length;
|
||||
}
|
||||
|
||||
HomePageURL: WOString {
|
||||
value = appointmentURL;
|
||||
escapeHTML = NO;
|
||||
}
|
||||
|
||||
IsSubject: WOConditional {
|
||||
condition = isSubject;
|
||||
}
|
||||
|
||||
IsBody: WOConditional {
|
||||
condition = isSubject;
|
||||
negate = YES;
|
||||
}
|
||||
@@ -0,0 +1,4 @@
|
||||
<#IsSubject>Removed from appointment <#AptStartDate /> at <#AptStartTime /></#IsSubject>
|
||||
<#IsBody>
|
||||
You have been removed by <#Organizer /> from the appointment scheduled at <#AptStartDate /> <#AptStartTime />.
|
||||
</#IsBody>
|
||||
@@ -0,0 +1,34 @@
|
||||
AptStartDate: WOString {
|
||||
value = newStartDate;
|
||||
dateformat = "%d/%m/%y";
|
||||
escapeHTML = NO;
|
||||
}
|
||||
|
||||
AptStartTime: WOString {
|
||||
value = newStartDate;
|
||||
dateformat = "%H:%M";
|
||||
escapeHTML = NO;
|
||||
}
|
||||
|
||||
Organizer: WOString {
|
||||
value = newApt.organizer.cnWithoutQuotes;
|
||||
escapeHTML = NO;
|
||||
}
|
||||
|
||||
HasHomePageURL: WOConditional {
|
||||
condition = homePageURL.length;
|
||||
}
|
||||
|
||||
HomePageURL: WOString {
|
||||
value = appointmentURL;
|
||||
escapeHTML = NO;
|
||||
}
|
||||
|
||||
IsSubject: WOConditional {
|
||||
condition = isSubject;
|
||||
}
|
||||
|
||||
IsBody: WOConditional {
|
||||
condition = isSubject;
|
||||
negate = YES;
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
<#IsSubject>*E* Apt for the <#OldAptStartDate /> at <#OldAptStartTime /> changed</#IsSubject>
|
||||
<#IsBody>
|
||||
This appointment, previously set for <#OldAptStartDate />
|
||||
at <#OldAptStartTime /> is now scheduled for <#NewAptStartDate /> at <#NewAptStartTime />
|
||||
<#HasHomePageURL>
|
||||
Please make a decision for these new settings at <#HomePageURL />.
|
||||
</#HasHomePageURL>
|
||||
</#IsBody>
|
||||
@@ -0,0 +1,46 @@
|
||||
OldAptStartDate: WOString {
|
||||
value = oldStartDate;
|
||||
dateformat = "%d/%m/%y";
|
||||
escapeHTML = NO;
|
||||
}
|
||||
|
||||
OldAptStartTime: WOString {
|
||||
value = oldStartDate;
|
||||
dateformat = "%H:%M";
|
||||
escapeHTML = NO;
|
||||
}
|
||||
|
||||
NewAptStartDate: WOString {
|
||||
value = newStartDate;
|
||||
dateformat = "%d/%m/%y";
|
||||
escapeHTML = NO;
|
||||
}
|
||||
|
||||
NewAptStartTime: WOString {
|
||||
value = newStartDate;
|
||||
dateformat = "%H:%M";
|
||||
escapeHTML = NO;
|
||||
}
|
||||
|
||||
Organizer: WOString {
|
||||
value = newApt.organizer.cnWithoutQuotes;
|
||||
escapeHTML = NO;
|
||||
}
|
||||
|
||||
HasHomePageURL: WOConditional {
|
||||
condition = homePageURL.length;
|
||||
}
|
||||
|
||||
HomePageURL: WOString {
|
||||
value = appointmentURL;
|
||||
escapeHTML = NO;
|
||||
}
|
||||
|
||||
IsSubject: WOConditional {
|
||||
condition = isSubject;
|
||||
}
|
||||
|
||||
IsBody: WOConditional {
|
||||
condition = isSubject;
|
||||
negate = YES;
|
||||
}
|
||||
@@ -0,0 +1,4 @@
|
||||
<#IsSubject>Le rendez-vous du <#AptStartDate /> à <#AptStartTime /> a été supprimé</#IsSubject>
|
||||
<#IsBody>
|
||||
Le rendez-vous du <#AptStartDate /> à <#AptStartTime /> a été supprimé par <#Organizer />.
|
||||
</#IsBody>
|
||||
@@ -0,0 +1,34 @@
|
||||
AptStartDate: WOString {
|
||||
value = newStartDate;
|
||||
dateformat = "%d/%m/%y";
|
||||
escapeHTML = NO;
|
||||
}
|
||||
|
||||
AptStartTime: WOString {
|
||||
value = newStartDate;
|
||||
dateformat = "%H:%M";
|
||||
escapeHTML = NO;
|
||||
}
|
||||
|
||||
Organizer: WOString {
|
||||
value = newApt.organizer.cnWithoutQuotes;
|
||||
escapeHTML = NO;
|
||||
}
|
||||
|
||||
HasHomePageURL: WOConditional {
|
||||
condition = homePageURL.length;
|
||||
}
|
||||
|
||||
HomePageURL: WOString {
|
||||
value = appointmentURL;
|
||||
escapeHTML = NO;
|
||||
}
|
||||
|
||||
IsSubject: WOConditional {
|
||||
condition = isSubject;
|
||||
}
|
||||
|
||||
IsBody: WOConditional {
|
||||
condition = isSubject;
|
||||
negate = YES;
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
<#IsSubject>Rendez-vous le <#AptStartDate /> à <#AptStartTime /></#IsSubject>
|
||||
<#IsBody>
|
||||
Vous êtes invité par <#Organizer /> à une réunion.
|
||||
<#HasHomePageURL>
|
||||
Veuillez donner votre réponse à l'adresse <#HomePageURL />.
|
||||
</#HasHomePageURL>
|
||||
</#IsBody>
|
||||
@@ -0,0 +1,34 @@
|
||||
AptStartDate: WOString {
|
||||
value = newStartDate;
|
||||
dateformat = "%d/%m/%y";
|
||||
escapeHTML = NO;
|
||||
}
|
||||
|
||||
AptStartTime: WOString {
|
||||
value = newStartDate;
|
||||
dateformat = "%H:%M";
|
||||
escapeHTML = NO;
|
||||
}
|
||||
|
||||
Organizer: WOString {
|
||||
value = newApt.organizer.cnWithoutQuotes;
|
||||
escapeHTML = NO;
|
||||
}
|
||||
|
||||
HasHomePageURL: WOConditional {
|
||||
condition = homePageURL.length;
|
||||
}
|
||||
|
||||
HomePageURL: WOString {
|
||||
value = appointmentURL;
|
||||
escapeHTML = NO;
|
||||
}
|
||||
|
||||
IsSubject: WOConditional {
|
||||
condition = isSubject;
|
||||
}
|
||||
|
||||
IsBody: WOConditional {
|
||||
condition = isSubject;
|
||||
negate = YES;
|
||||
}
|
||||
@@ -0,0 +1,4 @@
|
||||
<#IsSubject>Supprimé de la réunion du <#AptStartDate /> à <#AptStartTime /></#IsSubject>
|
||||
<#IsBody>
|
||||
Vous ne faites plus parti de la liste des invités de la réunion du <#AptStartDate /> à <#AptStartTime /> organisée par <#Organizer />.
|
||||
</#IsBody>
|
||||
@@ -0,0 +1,34 @@
|
||||
AptStartDate: WOString {
|
||||
value = newStartDate;
|
||||
dateformat = "%d/%m/%y";
|
||||
escapeHTML = NO;
|
||||
}
|
||||
|
||||
AptStartTime: WOString {
|
||||
value = newStartDate;
|
||||
dateformat = "%H:%M";
|
||||
escapeHTML = NO;
|
||||
}
|
||||
|
||||
Organizer: WOString {
|
||||
value = newApt.organizer.cnWithoutQuotes;
|
||||
escapeHTML = NO;
|
||||
}
|
||||
|
||||
HasHomePageURL: WOConditional {
|
||||
condition = homePageURL.length;
|
||||
}
|
||||
|
||||
HomePageURL: WOString {
|
||||
value = appointmentURL;
|
||||
escapeHTML = NO;
|
||||
}
|
||||
|
||||
IsSubject: WOConditional {
|
||||
condition = isSubject;
|
||||
}
|
||||
|
||||
IsBody: WOConditional {
|
||||
condition = isSubject;
|
||||
negate = YES;
|
||||
}
|
||||
@@ -0,0 +1,5 @@
|
||||
<#IsSubject>Rendez-vous du <#OldAptStartDate /> à <#OldAptStartTime /> modifié</#IsSubject>
|
||||
<#IsBody>
|
||||
La réunion qui devait se dérouler le <#OldAptStartDate /> à <#OldAptStartTime /> est maintenant prévue le <#NewAptStartDate /> à <#NewAptStartTime />.
|
||||
Vous êtes invité à accepter ou refuser de participer à la réunion pour cette nouvelle date à l'adresse <#HomePageURL />.
|
||||
</#IsBody>
|
||||
@@ -0,0 +1,46 @@
|
||||
OldAptStartDate: WOString {
|
||||
value = oldStartDate;
|
||||
dateformat = "%d/%m/%y";
|
||||
escapeHTML = NO;
|
||||
}
|
||||
|
||||
OldAptStartTime: WOString {
|
||||
value = oldStartDate;
|
||||
dateformat = "%H:%M";
|
||||
escapeHTML = NO;
|
||||
}
|
||||
|
||||
NewAptStartDate: WOString {
|
||||
value = newStartDate;
|
||||
dateformat = "%d/%m/%y";
|
||||
escapeHTML = NO;
|
||||
}
|
||||
|
||||
NewAptStartTime: WOString {
|
||||
value = newStartDate;
|
||||
dateformat = "%H:%M";
|
||||
escapeHTML = NO;
|
||||
}
|
||||
|
||||
Organizer: WOString {
|
||||
value = newApt.organizer.cnWithoutQuotes;
|
||||
escapeHTML = NO;
|
||||
}
|
||||
|
||||
HasHomePageURL: WOConditional {
|
||||
condition = homePageURL.length;
|
||||
}
|
||||
|
||||
HomePageURL: WOString {
|
||||
value = appointmentURL;
|
||||
escapeHTML = NO;
|
||||
}
|
||||
|
||||
IsSubject: WOConditional {
|
||||
condition = isSubject;
|
||||
}
|
||||
|
||||
IsBody: WOConditional {
|
||||
condition = isSubject;
|
||||
negate = YES;
|
||||
}
|
||||
@@ -0,0 +1,38 @@
|
||||
/*
|
||||
Copyright (C) 2000-2005 SKYRIX Software AG
|
||||
|
||||
This file is part of OpenGroupware.org.
|
||||
|
||||
OGo is free software; you can redistribute it and/or modify it under
|
||||
the terms of the GNU Lesser General Public License as published by the
|
||||
Free Software Foundation; either version 2, or (at your option) any
|
||||
later version.
|
||||
|
||||
OGo 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 Lesser General Public
|
||||
License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with OGo; see the file COPYING. If not, write to the
|
||||
Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA
|
||||
02111-1307, USA.
|
||||
*/
|
||||
|
||||
#include "SOGoAptMailNotification.h"
|
||||
|
||||
@interface SOGoAptMailEnglishInvitation : SOGoAptMailNotification
|
||||
{
|
||||
}
|
||||
@end
|
||||
|
||||
@implementation SOGoAptMailEnglishInvitation
|
||||
@end
|
||||
|
||||
@interface SOGoAptMailFrenchInvitation : SOGoAptMailNotification
|
||||
{
|
||||
}
|
||||
@end
|
||||
|
||||
@implementation SOGoAptMailFrenchInvitation
|
||||
@end
|
||||
@@ -0,0 +1,68 @@
|
||||
/*
|
||||
Copyright (C) 2000-2005 SKYRIX Software AG
|
||||
|
||||
This file is part of OpenGroupware.org.
|
||||
|
||||
OGo is free software; you can redistribute it and/or modify it under
|
||||
the terms of the GNU Lesser General Public License as published by the
|
||||
Free Software Foundation; either version 2, or (at your option) any
|
||||
later version.
|
||||
|
||||
OGo 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 Lesser General Public
|
||||
License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with OGo; see the file COPYING. If not, write to the
|
||||
Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA
|
||||
02111-1307, USA.
|
||||
*/
|
||||
|
||||
#ifndef __Appointments_SOGoAptMailNotification_H_
|
||||
#define __Appointments_SOGoAptMailNotification_H_
|
||||
|
||||
#include <NGObjWeb/SoComponent.h>
|
||||
|
||||
@class NSString, NSTimeZone, NSCalendarDate;
|
||||
|
||||
/*
|
||||
* NOTE: We inherit from SoComponent in order to get the correct
|
||||
* resourceManager required for this product
|
||||
*/
|
||||
@interface SOGoAptMailNotification : SoComponent
|
||||
{
|
||||
id oldApt;
|
||||
id newApt;
|
||||
NSString *homePageURL;
|
||||
NSTimeZone *viewTZ;
|
||||
NSCalendarDate *oldStartDate;
|
||||
NSCalendarDate *newStartDate;
|
||||
BOOL isSubject;
|
||||
}
|
||||
|
||||
- (id)oldApt;
|
||||
- (void)setOldApt:(id)_oldApt;
|
||||
|
||||
- (id)newApt;
|
||||
- (void)setNewApt:(id)_newApt;
|
||||
|
||||
- (NSString *)homePageURL;
|
||||
- (void)setHomePageURL:(NSString *)_homePageURL;
|
||||
|
||||
- (NSTimeZone *)viewTZ;
|
||||
- (void)setViewTZ:(NSTimeZone *)_viewTZ;
|
||||
|
||||
/* Helpers */
|
||||
|
||||
- (NSCalendarDate *)oldStartDate;
|
||||
- (NSCalendarDate *)newStartDate;
|
||||
|
||||
/* Content Generation */
|
||||
|
||||
- (NSString *)getSubject;
|
||||
- (NSString *)getBody;
|
||||
|
||||
@end
|
||||
|
||||
#endif /* __Appointments_SOGoAptMailNotification_H_ */
|
||||
@@ -0,0 +1,143 @@
|
||||
/*
|
||||
Copyright (C) 2000-2005 SKYRIX Software AG
|
||||
|
||||
This file is part of OpenGroupware.org.
|
||||
|
||||
OGo is free software; you can redistribute it and/or modify it under
|
||||
the terms of the GNU Lesser General Public License as published by the
|
||||
Free Software Foundation; either version 2, or (at your option) any
|
||||
later version.
|
||||
|
||||
OGo 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 Lesser General Public
|
||||
License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with OGo; see the file COPYING. If not, write to the
|
||||
Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA
|
||||
02111-1307, USA.
|
||||
*/
|
||||
|
||||
#include "SOGoAptMailNotification.h"
|
||||
#include <SOGo/SOGoAppointment.h>
|
||||
#include "common.h"
|
||||
|
||||
@interface SOGoAptMailNotification (PrivateAPI)
|
||||
- (BOOL)isSubject;
|
||||
- (void)setIsSubject:(BOOL)_isSubject;
|
||||
@end
|
||||
|
||||
@implementation SOGoAptMailNotification
|
||||
|
||||
static NSCharacterSet *wsSet = nil;
|
||||
static NSTimeZone *MET = nil;
|
||||
|
||||
+ (void)initialize {
|
||||
static BOOL didInit = NO;
|
||||
|
||||
if (didInit) return;
|
||||
didInit = YES;
|
||||
|
||||
wsSet = [[NSCharacterSet whitespaceAndNewlineCharacterSet] retain];
|
||||
MET = [[NSTimeZone timeZoneWithAbbreviation:@"MET"] retain];
|
||||
}
|
||||
|
||||
- (void)dealloc {
|
||||
[self->oldApt release];
|
||||
[self->newApt release];
|
||||
[self->homePageURL release];
|
||||
[self->viewTZ release];
|
||||
|
||||
[self->oldStartDate release];
|
||||
[self->newStartDate release];
|
||||
[super dealloc];
|
||||
}
|
||||
|
||||
- (id)oldApt {
|
||||
return self->oldApt;
|
||||
}
|
||||
- (void)setOldApt:(id)_oldApt {
|
||||
ASSIGN(self->oldApt, _oldApt);
|
||||
}
|
||||
|
||||
- (id)newApt {
|
||||
return self->newApt;
|
||||
}
|
||||
- (void)setNewApt:(id)_newApt {
|
||||
ASSIGN(self->newApt, _newApt);
|
||||
}
|
||||
|
||||
- (NSString *)homePageURL {
|
||||
return self->homePageURL;
|
||||
}
|
||||
- (void)setHomePageURL:(NSString *)_homePageURL {
|
||||
ASSIGN(self->homePageURL, _homePageURL);
|
||||
}
|
||||
|
||||
- (NSString *)appointmentURL {
|
||||
NSString *aptUID;
|
||||
|
||||
aptUID = [[self newApt] uid];
|
||||
return [NSString stringWithFormat:@"%@/Calendar/%@/view?tab=participants",
|
||||
[self homePageURL],
|
||||
aptUID];
|
||||
}
|
||||
|
||||
- (NSTimeZone *)viewTZ {
|
||||
if (self->viewTZ) return self->viewTZ;
|
||||
return MET;
|
||||
}
|
||||
- (void)setViewTZ:(NSTimeZone *)_viewTZ {
|
||||
ASSIGN(self->viewTZ, _viewTZ);
|
||||
}
|
||||
|
||||
- (BOOL)isSubject {
|
||||
return self->isSubject;
|
||||
}
|
||||
- (void)setIsSubject:(BOOL)_isSubject {
|
||||
self->isSubject = _isSubject;
|
||||
}
|
||||
|
||||
|
||||
/* Helpers */
|
||||
|
||||
- (NSCalendarDate *)oldStartDate {
|
||||
if (!self->oldStartDate) {
|
||||
ASSIGN(self->oldStartDate, [[self oldApt] startDate]);
|
||||
[self->oldStartDate setTimeZone:[self viewTZ]];
|
||||
}
|
||||
return self->oldStartDate;
|
||||
}
|
||||
|
||||
- (NSCalendarDate *)newStartDate {
|
||||
if (!self->newStartDate) {
|
||||
ASSIGN(self->newStartDate, [[self newApt] startDate]);
|
||||
[self->newStartDate setTimeZone:[self viewTZ]];
|
||||
}
|
||||
return self->newStartDate;
|
||||
}
|
||||
|
||||
/* Generate Response */
|
||||
|
||||
- (NSString *)getSubject {
|
||||
NSString *subject;
|
||||
|
||||
[self setIsSubject:YES];
|
||||
subject = [[[self generateResponse] contentAsString]
|
||||
stringByTrimmingCharactersInSet:wsSet];
|
||||
if (!subject) {
|
||||
[self errorWithFormat:@"Failed to properly generate subject! Please check "
|
||||
@"template for component '%@'!",
|
||||
[self name]];
|
||||
subject = @"ERROR: missing subject!";
|
||||
}
|
||||
return subject;
|
||||
}
|
||||
|
||||
- (NSString *)getBody {
|
||||
[self setIsSubject:NO];
|
||||
return [[self generateResponse] contentAsString];
|
||||
}
|
||||
|
||||
@end
|
||||
@@ -0,0 +1,38 @@
|
||||
/*
|
||||
Copyright (C) 2000-2005 SKYRIX Software AG
|
||||
|
||||
This file is part of OpenGroupware.org.
|
||||
|
||||
OGo is free software; you can redistribute it and/or modify it under
|
||||
the terms of the GNU Lesser General Public License as published by the
|
||||
Free Software Foundation; either version 2, or (at your option) any
|
||||
later version.
|
||||
|
||||
OGo 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 Lesser General Public
|
||||
License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with OGo; see the file COPYING. If not, write to the
|
||||
Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA
|
||||
02111-1307, USA.
|
||||
*/
|
||||
|
||||
#include "SOGoAptMailNotification.h"
|
||||
|
||||
@interface SOGoAptMailEnglishRemoval : SOGoAptMailNotification
|
||||
{
|
||||
}
|
||||
@end
|
||||
|
||||
@implementation SOGoAptMailEnglishRemoval
|
||||
@end
|
||||
|
||||
@interface SOGoAptMailFrenchRemoval : SOGoAptMailNotification
|
||||
{
|
||||
}
|
||||
@end
|
||||
|
||||
@implementation SOGoAptMailFrenchRemoval
|
||||
@end
|
||||
@@ -0,0 +1,38 @@
|
||||
/*
|
||||
Copyright (C) 2000-2005 SKYRIX Software AG
|
||||
|
||||
This file is part of OpenGroupware.org.
|
||||
|
||||
OGo is free software; you can redistribute it and/or modify it under
|
||||
the terms of the GNU Lesser General Public License as published by the
|
||||
Free Software Foundation; either version 2, or (at your option) any
|
||||
later version.
|
||||
|
||||
OGo 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 Lesser General Public
|
||||
License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with OGo; see the file COPYING. If not, write to the
|
||||
Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA
|
||||
02111-1307, USA.
|
||||
*/
|
||||
|
||||
#include "SOGoAptMailNotification.h"
|
||||
|
||||
@interface SOGoAptMailEnglishUpdate : SOGoAptMailNotification
|
||||
{
|
||||
}
|
||||
@end
|
||||
|
||||
@implementation SOGoAptMailEnglishUpdate
|
||||
@end
|
||||
|
||||
@interface SOGoAptMailFrenchUpdate : SOGoAptMailNotification
|
||||
{
|
||||
}
|
||||
@end
|
||||
|
||||
@implementation SOGoAptMailFrenchUpdate
|
||||
@end
|
||||
@@ -0,0 +1,53 @@
|
||||
/*
|
||||
Copyright (C) 2000-2004 SKYRIX Software AG
|
||||
|
||||
This file is part of OGo
|
||||
|
||||
OGo is free software; you can redistribute it and/or modify it under
|
||||
the terms of the GNU Lesser General Public License as published by the
|
||||
Free Software Foundation; either version 2, or (at your option) any
|
||||
later version.
|
||||
|
||||
OGo 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 Lesser General Public
|
||||
License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with OGo; see the file COPYING. If not, write to the
|
||||
Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA
|
||||
02111-1307, USA.
|
||||
*/
|
||||
// $Id: SOGoFreeBusyObject.h 675 2005-07-06 20:56:09Z znek $
|
||||
|
||||
|
||||
#ifndef __Appointments_SOGoFreeBusyObject_H_
|
||||
#define __Appointments_SOGoFreeBusyObject_H_
|
||||
|
||||
#include <SOGo/SOGoContentObject.h>
|
||||
|
||||
/*
|
||||
SOGoFreeBusyObject
|
||||
|
||||
Represents Free/Busy information for a single user as specified in RFC2445.
|
||||
*/
|
||||
|
||||
@class NSArray, NSCalendarDate;
|
||||
|
||||
@interface SOGoFreeBusyObject : SOGoContentObject
|
||||
{
|
||||
}
|
||||
|
||||
/* accessors */
|
||||
|
||||
- (NSString *)iCalString;
|
||||
|
||||
- (NSString *)contentAsStringFrom:(NSCalendarDate *)_startDate
|
||||
to:(NSCalendarDate *)_endDate;
|
||||
|
||||
- (NSArray *)fetchFreebusyInfosFrom:(NSCalendarDate *)_startDate
|
||||
to:(NSCalendarDate *)_endDate;
|
||||
|
||||
@end
|
||||
|
||||
#endif /* __Appointments_SOGoFreeBusyObject_H_ */
|
||||
@@ -0,0 +1,213 @@
|
||||
/*
|
||||
Copyright (C) 2000-2004 SKYRIX Software AG
|
||||
|
||||
This file is part of OGo
|
||||
|
||||
OGo is free software; you can redistribute it and/or modify it under
|
||||
the terms of the GNU Lesser General Public License as published by the
|
||||
Free Software Foundation; either version 2, or (at your option) any
|
||||
later version.
|
||||
|
||||
OGo 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 Lesser General Public
|
||||
License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with OGo; see the file COPYING. If not, write to the
|
||||
Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA
|
||||
02111-1307, USA.
|
||||
*/
|
||||
// $Id: SOGoFreeBusyObject.m 675 2005-07-06 20:56:09Z znek $
|
||||
|
||||
#include "SOGoFreeBusyObject.h"
|
||||
#include "common.h"
|
||||
#include <SOGo/AgenorUserManager.h>
|
||||
#include <NGiCal/NGiCal.h>
|
||||
#include <NGiCal/iCalRenderer.h>
|
||||
|
||||
@interface NSDate(UsedPrivates)
|
||||
- (NSString *)icalString; // declared in NGiCal
|
||||
@end
|
||||
|
||||
@interface SOGoFreeBusyObject (PrivateAPI)
|
||||
- (NSString *)iCalStringForFreeBusyInfos:(NSArray *)_infos
|
||||
from:(NSCalendarDate *)_startDate
|
||||
to:(NSCalendarDate *)_endDate;
|
||||
@end
|
||||
|
||||
@implementation SOGoFreeBusyObject
|
||||
|
||||
- (NSString *)iCalString {
|
||||
// for UI-X appointment viewer
|
||||
return [self contentAsString];
|
||||
}
|
||||
|
||||
- (NSString *)contentAsString {
|
||||
NSCalendarDate *startDate, *endDate;
|
||||
|
||||
startDate = [[[NSCalendarDate calendarDate] mondayOfWeek] beginOfDay];
|
||||
endDate = [startDate dateByAddingYears:0
|
||||
months:0
|
||||
days:7
|
||||
hours:23
|
||||
minutes:59
|
||||
seconds:59];
|
||||
return [self contentAsStringFrom:startDate to:endDate];
|
||||
}
|
||||
|
||||
- (NSString *)contentAsStringFrom:(NSCalendarDate *)_startDate
|
||||
to:(NSCalendarDate *)_endDate
|
||||
{
|
||||
NSArray *infos;
|
||||
|
||||
infos = [self fetchFreebusyInfosFrom:_startDate to:_endDate];
|
||||
return [self iCalStringForFreeBusyInfos:infos from:_startDate to:_endDate];
|
||||
}
|
||||
|
||||
- (NSArray *)fetchFreebusyInfosFrom:(NSCalendarDate *)_startDate
|
||||
to:(NSCalendarDate *)_endDate
|
||||
{
|
||||
id userFolder, calFolder;
|
||||
NSArray *infos;
|
||||
AgenorUserManager *um;
|
||||
NSString *email;
|
||||
NSMutableArray *filtered;
|
||||
unsigned i, count;
|
||||
|
||||
userFolder = [self container];
|
||||
calFolder = [userFolder lookupName:@"Calendar" inContext:nil acquire:NO];
|
||||
infos = [calFolder fetchFreebusyInfosFrom:_startDate to:_endDate];
|
||||
um = [AgenorUserManager sharedUserManager];
|
||||
email = [um getEmailForUID:[userFolder login]];
|
||||
count = [infos count];
|
||||
filtered = [[[NSMutableArray alloc] initWithCapacity:count] autorelease];
|
||||
|
||||
for (i = 0; i < count; i++) {
|
||||
NSDictionary *info;
|
||||
NSArray *partmails;
|
||||
unsigned p, pCount;
|
||||
|
||||
info = [infos objectAtIndex:i];
|
||||
partmails = [[info objectForKey:@"partmails"]
|
||||
componentsSeparatedByString:@"\n"];
|
||||
pCount = [partmails count];
|
||||
for (p = 0; p < pCount; p++) {
|
||||
NSString *pEmail;
|
||||
|
||||
pEmail = [partmails objectAtIndex:p];
|
||||
if ([pEmail isEqualToString:email]) {
|
||||
NSArray *partstates;
|
||||
NSString *state;
|
||||
|
||||
partstates = [[info objectForKey:@"partstates"]
|
||||
componentsSeparatedByString:@"\n"];
|
||||
state = [partstates objectAtIndex:p];
|
||||
if ([state intValue] == iCalPersonPartStatAccepted) {
|
||||
// TODO: add tentative apts as well, but put state and email
|
||||
// into info
|
||||
[filtered addObject:info];
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
return filtered;
|
||||
}
|
||||
|
||||
/* Private API */
|
||||
|
||||
- (NSString *)iCalStringForFreeBusyInfos:(NSArray *)_infos
|
||||
from:(NSCalendarDate *)_startDate
|
||||
to:(NSCalendarDate *)_endDate
|
||||
{
|
||||
AgenorUserManager *um;
|
||||
NSMutableString *ms;
|
||||
NSString *uid, *x;
|
||||
unsigned i, count;
|
||||
|
||||
um = [AgenorUserManager sharedUserManager];
|
||||
uid = [[self container] login];
|
||||
ms = [[[NSMutableString alloc] initWithCapacity:128] autorelease];
|
||||
|
||||
/* preamble */
|
||||
[ms appendString:@"BEGIN:VCALENDAR\r\n"];
|
||||
[ms appendString:@"BEGIN:VFREEBUSY\r\n"];
|
||||
/* PRODID */
|
||||
[ms appendString:@"PRODID:SOGo/0.9\r\n"];
|
||||
/* VERSION */
|
||||
[ms appendString:@"VERSION:2.0\r\n"];
|
||||
/* DTSTAMP */
|
||||
[ms appendString:@"DTSTAMP:"];
|
||||
[ms appendString:[[NSCalendarDate calendarDate] icalString]];
|
||||
[ms appendString:@"\r\n"];
|
||||
|
||||
/* ORGANIZER - strictly required but missing for now */
|
||||
|
||||
/* ATTENDEE */
|
||||
[ms appendString:@"ATTENDEE"];
|
||||
if ((x = [um getCNForUID:uid])) {
|
||||
[ms appendString:@";CN=\""];
|
||||
[ms appendString:[x iCalDQUOTESafeString]];
|
||||
[ms appendString:@"\""];
|
||||
}
|
||||
if ((x = [um getEmailForUID:uid])) {
|
||||
[ms appendString:@":"]; /* sic! */
|
||||
[ms appendString:[x iCalSafeString]];
|
||||
}
|
||||
[ms appendString:@"\r\n"];
|
||||
|
||||
/* DTSTART */
|
||||
[ms appendString:@"DTSTART:"];
|
||||
[ms appendString:[_startDate icalString]];
|
||||
[ms appendString:@"\r\n"];
|
||||
|
||||
/* DTEND */
|
||||
[ms appendString:@"DTEND:"];
|
||||
[ms appendString:[_endDate icalString]];
|
||||
[ms appendString:@"\r\n"];
|
||||
|
||||
/* FREEBUSY */
|
||||
count = [_infos count];
|
||||
for (i = 0; i < count; i++) {
|
||||
NSDictionary *info;
|
||||
NSCalendarDate *startDate, *endDate;
|
||||
|
||||
info = [_infos objectAtIndex:i];
|
||||
startDate = [info objectForKey:@"startDate"];
|
||||
endDate = [info objectForKey:@"endDate"];
|
||||
|
||||
/* NOTE: currently we cannot differentiate between all the types defined
|
||||
* in RFC2445, Section 4.2.9.
|
||||
* These are: FREE" / "BUSY" / "BUSY-UNAVAILABLE" / "BUSY-TENTATIVE"
|
||||
*/
|
||||
|
||||
[ms appendString:@"FREEBUSY;FBTYPE=BUSY:"];
|
||||
[ms appendString:[startDate icalString]];
|
||||
[ms appendString:@"/"];
|
||||
[ms appendString:[endDate icalString]];
|
||||
[ms appendString:@"\r\n"];
|
||||
}
|
||||
|
||||
/* postamble */
|
||||
[ms appendString:@"END:VFREEBUSY\r\n"];
|
||||
[ms appendString:@"END:VCALENDAR\r\n"];
|
||||
return ms;
|
||||
}
|
||||
|
||||
/* deliver content without need for view method */
|
||||
|
||||
- (id)GETAction:(id)_ctx {
|
||||
WOResponse *r;
|
||||
NSData *contentData;
|
||||
|
||||
contentData = [[self contentAsString] dataUsingEncoding:NSUTF8StringEncoding];
|
||||
|
||||
r = [(WOContext *)_ctx response];
|
||||
[r setHeader:@"text/calendar" forKey:@"content-type"];
|
||||
[r setContent:contentData];
|
||||
[r setStatus:200];
|
||||
return r;
|
||||
}
|
||||
|
||||
@end
|
||||
@@ -0,0 +1,52 @@
|
||||
/*
|
||||
Copyright (C) 2004 SKYRIX Software AG
|
||||
|
||||
This file is part of OpenGroupware.org.
|
||||
|
||||
OGo is free software; you can redistribute it and/or modify it under
|
||||
the terms of the GNU Lesser General Public License as published by the
|
||||
Free Software Foundation; either version 2, or (at your option) any
|
||||
later version.
|
||||
|
||||
OGo 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 Lesser General Public
|
||||
License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with OGo; see the file COPYING. If not, write to the
|
||||
Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA
|
||||
02111-1307, USA.
|
||||
*/
|
||||
// $Id: SOGoAppointmentFolder.h 137 2004-07-02 17:42:14Z helge $
|
||||
|
||||
#ifndef __Appointments_SOGoGroupAppointmentFolder_H__
|
||||
#define __Appointments_SOGoGroupAppointmentFolder_H__
|
||||
|
||||
#include "SOGoAppointmentFolder.h"
|
||||
|
||||
/*
|
||||
SOGoGroupAppointmentFolder
|
||||
Parent object: an SOGoGroupFolder (or subclass)
|
||||
Child objects: SOGoAppointmentObject
|
||||
|
||||
Note: this is only a subclass of SOGoAppointmentFolder to inherit all the
|
||||
SOPE methods (it provides the same API). It is not an ocsFolder but
|
||||
rather looks up the "child" folders for aggregation using regular SOPE
|
||||
techniques.
|
||||
=> hm, do we need "aspects" in SOPE? ;-)
|
||||
|
||||
Note: this class retains appointment folders looked up, so watch out for
|
||||
reference cycles!
|
||||
*/
|
||||
|
||||
@class NSMutableDictionary;
|
||||
|
||||
@interface SOGoGroupAppointmentFolder : SOGoAppointmentFolder
|
||||
{
|
||||
NSMutableDictionary *uidToFolder;
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
#endif /* __Appointments_SOGoGroupAppointmentFolder_H__ */
|
||||
@@ -0,0 +1,233 @@
|
||||
/*
|
||||
Copyright (C) 2004-2005 SKYRIX Software AG
|
||||
|
||||
This file is part of OpenGroupware.org.
|
||||
|
||||
OGo is free software; you can redistribute it and/or modify it under
|
||||
the terms of the GNU Lesser General Public License as published by the
|
||||
Free Software Foundation; either version 2, or (at your option) any
|
||||
later version.
|
||||
|
||||
OGo 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 Lesser General Public
|
||||
License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with OGo; see the file COPYING. If not, write to the
|
||||
Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA
|
||||
02111-1307, USA.
|
||||
*/
|
||||
|
||||
#include "SOGoGroupAppointmentFolder.h"
|
||||
#include "common.h"
|
||||
|
||||
@implementation SOGoGroupAppointmentFolder
|
||||
|
||||
+ (int)version {
|
||||
return [super version] + 0 /* v1 */;
|
||||
}
|
||||
+ (void)initialize {
|
||||
NSAssert2([super version] == 1,
|
||||
@"invalid superclass (%@) version %i !",
|
||||
NSStringFromClass([self superclass]), [super version]);
|
||||
}
|
||||
|
||||
- (void)dealloc {
|
||||
[self->uidToFolder release];
|
||||
[super dealloc];
|
||||
}
|
||||
|
||||
/* looking up shared objects */
|
||||
|
||||
- (SOGoGroupsFolder *)lookupGroupsFolder {
|
||||
return [[self container] lookupGroupsFolder];
|
||||
}
|
||||
|
||||
/* selection */
|
||||
|
||||
- (NSArray *)calendarUIDs {
|
||||
return [[self container] valueForKey:@"uids"];
|
||||
}
|
||||
|
||||
/* folders */
|
||||
|
||||
- (void)resetFolderCaches {
|
||||
[self->uidToFolder release]; self->uidToFolder = nil;
|
||||
}
|
||||
|
||||
- (SOGoAppointmentFolder *)folderForUID:(NSString *)_uid {
|
||||
if (self->uidToFolder == nil) {
|
||||
// TODO: can we trigger a fetch?
|
||||
[self errorWithFormat:
|
||||
@"called -folderForUID method before fetchCoreInfos .."];
|
||||
return nil;
|
||||
}
|
||||
|
||||
return [self->uidToFolder objectForKey:_uid];
|
||||
}
|
||||
|
||||
/* merging */
|
||||
|
||||
- (BOOL)doesRecord:(NSDictionary *)_rec conflictWith:(NSDictionary *)_other {
|
||||
if (_rec == _other)
|
||||
return NO;
|
||||
if ([_rec isEqual:_other])
|
||||
return NO;
|
||||
|
||||
return YES;
|
||||
}
|
||||
|
||||
- (NSDictionary *)_registerConflictingRecord:(NSDictionary *)_other
|
||||
inRecord:(NSDictionary *)_record
|
||||
{
|
||||
NSMutableArray *conflicts;
|
||||
|
||||
if (_record == nil) return _other;
|
||||
if (_other == nil) return _record;
|
||||
|
||||
if ((conflicts = [_record objectForKey:@"conflicts"]) == nil) {
|
||||
NSMutableDictionary *md;
|
||||
|
||||
md = [[_record mutableCopy] autorelease];
|
||||
conflicts = [NSMutableArray arrayWithCapacity:4];
|
||||
[md setObject:conflicts forKey:@"conflicts"];
|
||||
_record = md;
|
||||
}
|
||||
[conflicts addObject:_other];
|
||||
return _record;
|
||||
}
|
||||
|
||||
/* functionality */
|
||||
|
||||
- (SOGoAppointmentFolder *)calendarFolderForMemberFolder:(id)_folder {
|
||||
SOGoAppointmentFolder *aptFolder;
|
||||
|
||||
if (![_folder isNotNull])
|
||||
return nil;
|
||||
|
||||
aptFolder = [_folder lookupName:@"Calendar" inContext:nil acquire:NO];
|
||||
if (![aptFolder isNotNull])
|
||||
return nil;
|
||||
|
||||
if (![aptFolder respondsToSelector:@selector(fetchCoreInfosFrom:to:)]) {
|
||||
[self errorWithFormat:@"folder does not implemented required API: %@",
|
||||
_folder];
|
||||
return nil;
|
||||
}
|
||||
return aptFolder;
|
||||
}
|
||||
|
||||
/* overridden */
|
||||
- (NSArray *)fetchFields:(NSArray *)_fields
|
||||
from:(NSCalendarDate *)_startDate
|
||||
to:(NSCalendarDate *)_endDate
|
||||
{
|
||||
NSArray *folders;
|
||||
NSMutableArray *result;
|
||||
NSMutableDictionary *uidToRecord;
|
||||
unsigned i, count;
|
||||
|
||||
if ((folders = [[self container] valueForKey:@"memberFolders"]) == nil) {
|
||||
[self errorWithFormat:@"calendar container has no 'memberFolders'?!"];
|
||||
return nil;
|
||||
}
|
||||
|
||||
[self resetFolderCaches];
|
||||
|
||||
if ((count = [folders count]) == 0)
|
||||
return [NSArray array];
|
||||
|
||||
if (self->uidToFolder == nil)
|
||||
self->uidToFolder = [[NSMutableDictionary alloc] initWithCapacity:7*count];
|
||||
else
|
||||
[self->uidToFolder removeAllObjects];
|
||||
|
||||
uidToRecord = [NSMutableDictionary dictionaryWithCapacity:(7 * count)];
|
||||
result = [NSMutableArray arrayWithCapacity:(7 * count)];
|
||||
for (i = 0; i < count; i++) {
|
||||
SOGoAppointmentFolder *aptFolder;
|
||||
id results;
|
||||
NSDictionary *record;
|
||||
|
||||
aptFolder = [self calendarFolderForMemberFolder:
|
||||
[folders objectAtIndex:i]];
|
||||
if (![aptFolder isNotNull]) {
|
||||
[self debugWithFormat:@"did not find a Calendar folder in folder: %@",
|
||||
[folders objectAtIndex:i]];
|
||||
continue;
|
||||
}
|
||||
|
||||
results = [aptFolder fetchFields:_fields
|
||||
from:_startDate
|
||||
to:_endDate];
|
||||
if (![results isNotNull]) continue;
|
||||
|
||||
results = [results objectEnumerator];
|
||||
while ((record = [results nextObject])) {
|
||||
NSString *uid;
|
||||
NSDictionary *existingRecord;
|
||||
|
||||
uid = [record objectForKey:@"uid"];
|
||||
if (![uid isNotNull]) {
|
||||
[self warnWithFormat:@"record without uid: %@", result];
|
||||
[result addObject:record];
|
||||
continue;
|
||||
}
|
||||
|
||||
if ((existingRecord = [uidToRecord objectForKey:uid]) == nil) {
|
||||
/* record not yet in result set */
|
||||
[uidToRecord setObject:record forKey:uid];
|
||||
[result addObject:record];
|
||||
|
||||
[self->uidToFolder setObject:aptFolder forKey:uid];
|
||||
}
|
||||
else if ([self doesRecord:existingRecord conflictWith:record]) {
|
||||
/* record already registered and it conflicts (diff values) */
|
||||
NSDictionary *newRecord;
|
||||
int idx;
|
||||
|
||||
newRecord = [self _registerConflictingRecord:record
|
||||
inRecord:existingRecord];
|
||||
[uidToRecord setObject:newRecord forKey:uid];
|
||||
|
||||
if ((idx = [result indexOfObject:existingRecord]) != NSNotFound)
|
||||
[result replaceObjectAtIndex:idx withObject:newRecord];
|
||||
}
|
||||
else {
|
||||
/* record already registered, but values in sync, nothing to do */
|
||||
}
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
/* URL generation */
|
||||
|
||||
- (NSString *)baseURLForAptWithUID:(NSString *)_uid inContext:(id)_ctx {
|
||||
/* Note: fetchCore must have been called before this works */
|
||||
SOGoAppointmentFolder *folder;
|
||||
|
||||
if ([_uid length] == 0) {
|
||||
[self errorWithFormat:@"got invalid UID."];
|
||||
return nil;
|
||||
}
|
||||
|
||||
if ((folder = [self folderForUID:_uid]) == nil) {
|
||||
[self errorWithFormat:@"did not find a folder containing UID: '%@'",
|
||||
_uid];
|
||||
return nil;
|
||||
}
|
||||
if (![folder respondsToSelector:_cmd]) {
|
||||
[self errorWithFormat:@"found folder cannot construct UID URLs: %@",
|
||||
folder];
|
||||
return nil;
|
||||
}
|
||||
|
||||
[self debugWithFormat:@"found ID %@ in folder: %@", _uid, folder];
|
||||
|
||||
return [folder baseURLForAptWithUID:_uid inContext:_ctx];
|
||||
}
|
||||
|
||||
@end /* SOGoGroupAppointmentFolder */
|
||||
@@ -0,0 +1,10 @@
|
||||
# Version file
|
||||
|
||||
SUBMINOR_VERSION:=50
|
||||
|
||||
# v0.9.42 requires libSOGo v0.9.54
|
||||
# v0.9.32 requires libGDLContentStore v4.5.26
|
||||
# v0.9.28 requires libNGiCal v4.5.47
|
||||
# v0.9.26 requires libSOGo v0.9.30
|
||||
# v0.9.19 requires libNGiCal v4.5.36
|
||||
# v0.9.13 requires libSOGo v0.9.26
|
||||
@@ -0,0 +1,2 @@
|
||||
{
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
/*
|
||||
Copyright (C) 2002-2005 SKYRIX Software AG
|
||||
|
||||
This file is part of OpenGroupware.org.
|
||||
|
||||
OGo is free software; you can redistribute it and/or modify it under
|
||||
the terms of the GNU Lesser General Public License as published by the
|
||||
Free Software Foundation; either version 2, or (at your option) any
|
||||
later version.
|
||||
|
||||
OGo 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 Lesser General Public
|
||||
License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with OGo; see the file COPYING. If not, write to the
|
||||
Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA
|
||||
02111-1307, USA.
|
||||
*/
|
||||
|
||||
#import <Foundation/Foundation.h>
|
||||
|
||||
#if NeXT_Foundation_LIBRARY || COCOA_Foundation_LIBRARY
|
||||
# include <NGExtensions/NGObjectMacros.h>
|
||||
# include <NGExtensions/NSString+Ext.h>
|
||||
#endif
|
||||
|
||||
#include <NGExtensions/NGExtensions.h>
|
||||
#include <NGObjWeb/NGObjWeb.h>
|
||||
#include <NGObjWeb/SoObjects.h>
|
||||
@@ -0,0 +1,26 @@
|
||||
{
|
||||
requires = ( MAIN );
|
||||
|
||||
publicResources = (
|
||||
);
|
||||
|
||||
factories = {
|
||||
};
|
||||
|
||||
classes = {
|
||||
SOGoAppointmentFolder = {
|
||||
superclass = "SOGoFolder";
|
||||
};
|
||||
SOGoGroupAppointmentFolder = {
|
||||
superclass = "SOGoAppointmentFolder";
|
||||
};
|
||||
|
||||
SOGoAppointmentObject = {
|
||||
superclass = "SOGoContentObject";
|
||||
};
|
||||
|
||||
SOGoFreeBusyObject = {
|
||||
superclass = "SOGoContentObject";
|
||||
};
|
||||
};
|
||||
}
|
||||
Reference in new issue
Block a user