Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA
02111-1307, USA.
*/
-// $Id$
+#import <Foundation/NSCalendarDate.h>
+#import <Foundation/NSDictionary.h>
+#import <Foundation/NSEnumerator.h>
+#import <Foundation/NSValue.h>
+
+#import <NGObjWeb/WOContext+SoObjects.h>
+#import <NGObjWeb/WOResponse.h>
+#import <NGExtensions/NSCalendarDate+misc.h>
#import <NGCards/iCalCalendar.h>
#import <NGCards/iCalFreeBusy.h>
+#import <NGCards/iCalPerson.h>
-#import "common.h"
-
-#import <SOGo/AgenorUserManager.h>
+#import <SOGo/LDAPUserManager.h>
+#import <SOGo/SOGoUser.h>
#import <SOGo/SOGoPermissions.h>
+#import "SOGoAppointmentFolder.h"
+
#import "SOGoFreeBusyObject.h"
@interface SOGoFreeBusyObject (PrivateAPI)
- (NSString *) contentAsString
{
NSCalendarDate *today, *startDate, *endDate;
+ NSTimeZone *timeZone;
today = [[NSCalendarDate calendarDate] beginOfDay];
- [today setTimeZone: [self userTimeZone]];
+ timeZone = [[context activeUser] timeZone];
+ [today setTimeZone: timeZone];
startDate = [today dateByAddingYears: 0 months: 0 days: -14
hours: 0 minutes: 0 seconds: 0];
endDate = [startDate dateByAddingYears: 0 months: 1 days: 0
hours: 0 minutes: 0 seconds: 0];
+
return [self contentAsStringFrom: startDate to: endDate];
}
- (NSArray *) fetchFreeBusyInfosFrom: (NSCalendarDate *) _startDate
to: (NSCalendarDate *) _endDate
{
- id calFolder;
- SoSecurityManager *sm;
- WOApplication *woApp;
+ SOGoAppointmentFolder *calFolder;
+// SoSecurityManager *sm;
NSArray *infos;
- woApp = [WOApplication application];
-
- calFolder = [container lookupName: @"Calendar" inContext: nil acquire: NO];
- sm = [SoSecurityManager sharedSecurityManager];
- if (![sm validatePermission: SOGoPerm_FreeBusyLookup
- onObject: calFolder
- inContext: [woApp context]])
- infos = [calFolder fetchFreeBusyInfosFrom: _startDate
- to: _endDate];
- else
- {
- infos = [NSArray new];
- [infos autorelease];
- }
+ calFolder = [[container lookupName: @"Calendar" inContext: nil acquire: NO]
+ lookupName: @"personal" inContext: nil acquire: NO];
+// sm = [SoSecurityManager sharedSecurityManager];
+// if (![sm validatePermission: SOGoPerm_FreeBusyLookup
+// onObject: calFolder
+// inContext: context])
+ infos = [calFolder fetchFreeBusyInfosFrom: _startDate
+ to: _endDate];
+// else
+// {
+// infos = [NSArray new];
+// [infos autorelease];
+// }
return infos;
}
return fbType;
}
+- (iCalPerson *) iCalPersonWithUID: (NSString *) uid
+{
+ iCalPerson *person;
+ LDAPUserManager *um;
+ NSDictionary *contactInfos;
+
+ um = [LDAPUserManager sharedUserManager];
+ contactInfos = [um contactInfosForUserWithUIDorEmail: uid];
+
+ person = [iCalPerson new];
+ [person autorelease];
+ [person setCn: [contactInfos objectForKey: @"cn"]];
+ [person setEmail: [contactInfos objectForKey: @"c_email"]];
+
+ return person;
+}
+
- (NSString *) iCalStringForFreeBusyInfos: (NSArray *) _infos
from: (NSCalendarDate *) _startDate
to: (NSCalendarDate *) _endDate
{
- AgenorUserManager *um;
NSString *uid;
NSEnumerator *events;
iCalCalendar *calendar;
NSDictionary *info;
iCalFreeBusyType type;
- um = [AgenorUserManager sharedUserManager];
uid = [[self container] login];
calendar = [iCalCalendar groupWithTag: @"vcalendar"];
[calendar setVersion: @"2.0"];
freebusy = [iCalFreeBusy groupWithTag: @"vfreebusy"];
- [freebusy addToAttendees: [um iCalPersonWithUid: uid]];
+ [freebusy addToAttendees: [self iCalPersonWithUID: uid]];
[freebusy setTimeStampAsDate: [NSCalendarDate calendarDate]];
[freebusy setStartDate: _startDate];
[freebusy setEndDate: _endDate];
/* ORGANIZER - strictly required but missing for now */
/* ATTENDEE */
-// person = [um iCalPersonWithUid: uid];
+// person = [self iCalPersonWithUid: uid];
// [person setTag: @"ATTENDEE"];
// [ms appendString: [person versitString]];
info = [events nextObject];
while (info)
{
- if ([[info objectForKey: @"isopaque"] boolValue])
+ if ([[info objectForKey: @"c_isopaque"] boolValue])
{
- type = [self _fbTypeForEventStatus: [info objectForKey: @"status"]];
+ type = [self _fbTypeForEventStatus: [info objectForKey: @"c_status"]];
[freebusy addFreeBusyFrom: [info objectForKey: @"startDate"]
to: [info objectForKey: @"endDate"]
type: type];
return r;
}
+- (NSString *) davContentType
+{
+ return @"text/calendar";
+}
+
@end