Monotone-Parent: 28e4a1d052d55c17348b711981d2a96fc17a6509

Monotone-Revision: efb5beac382de5b2c393a2be3885d1e75fd11625

Monotone-Author: wsourdeau@inverse.ca
Monotone-Date: 2006-09-28T17:26:02
Monotone-Branch: ca.inverse.sogo
This commit is contained in:
Wolfgang Sourdeau
2006-09-28 17:26:02 +00:00
parent 46b53de956
commit e3ba378b87
4 changed files with 136 additions and 83 deletions
+6
View File
@@ -1,5 +1,11 @@
2006-09-28 Wolfgang Sourdeau <wsourdeau@inverse.ca>
* UI/Scheduler/UIxAppointmentView.m ([UIxAppointmentView
-categoriesAsString]): same as below.
* UI/Scheduler/UIxAppointmentEditor.m: adapted by using the new
vcalendar API's iCalEvent instead of the removed SOGoAppointment.
* SoObjects/Appointments/SOGoAppointmentObject.m
([SOGoAppointmentObject -calendarFromContent:cnt]): new helper method.
([SOGoAppointmentObject -firstEventFromCalendar:calendar]): new
+48 -31
View File
@@ -19,6 +19,8 @@
02111-1307, USA.
*/
#import <NGCards/NSString+NGCards.h>
#import <SOGoUI/UIxComponent.h>
/* TODO: CLEAN UP */
@@ -26,7 +28,6 @@
@class NSString;
@class iCalPerson;
@class iCalRecurrenceRule;
@class SOGoAppointment;
@interface UIxAppointmentEditor : UIxComponent
{
@@ -91,17 +92,12 @@
#include <NGCards/NGCards.h>
#include <NGExtensions/NGCalendarDateRange.h>
#include <SOGoUI/SOGoDateFormatter.h>
#include <SOGo/SOGoAppointment.h>
#include <SOGo/AgenorUserManager.h>
#include <Appointments/SOGoAppointmentFolder.h>
#include <Appointments/SOGoAppointmentObject.h>
#include "iCalPerson+UIx.h"
#include "UIxComponent+Agenor.h"
@interface iCalRecurrenceRule (SOGoExtensions)
- (NSString *)cycleRepresentationForSOGo;
@end
@interface NSDate(UsedPrivates)
- (NSString *)icalString; // TODO: this is in NGCards
@end
@@ -426,7 +422,7 @@
if (!_rrule)
return [[self cycles] objectAtIndex:0];
cycleRep = [_rrule cycleRepresentationForSOGo];
cycleRep = [_rrule versitString];
cycles = [self cycles];
count = [cycles count];
for (i = 1; i < count; i++) {
@@ -765,7 +761,8 @@
return nil;
}
- (void)loadValuesFromAppointment:(SOGoAppointment *)_appointment {
- (void)loadValuesFromAppointment: (iCalEvent *)_appointment
{
NSString *s;
iCalRecurrenceRule *rrule;
@@ -782,7 +779,7 @@
location = [[_appointment location] copy];
comment = [[_appointment comment] copy];
priority = [[_appointment priority] copy];
categories = [[_appointment categories] retain];
categories = [[[_appointment categories] commaSeparatedValues] retain];
organizer = [[_appointment organizer] retain];
participants = [[_appointment participants] retain];
resources = [[_appointment resources] retain];
@@ -796,13 +793,17 @@
[self setIsPrivate:YES]; /* we're possibly loosing information here */
/* cycles */
rrule = [_appointment recurrenceRule];
[self adjustCycleControlsForRRule:rrule];
if ([_appointment isRecurrent])
{
rrule = [[_appointment recurrenceRules] objectAtIndex: 0];
[self adjustCycleControlsForRRule:rrule];
}
}
- (void)saveValuesIntoAppointment:(SOGoAppointment *)_appointment {
- (void)saveValuesIntoAppointment:(iCalEvent *)_appointment {
/* merge in form values */
NSArray *attendees, *lResources;
iCalRecurrenceRule *rrule;
[_appointment setStartDate:[self aptStartDate]];
[_appointment setEndDate:[self aptEndDate]];
@@ -811,8 +812,8 @@
[_appointment setLocation: [self location]];
[_appointment setComment: [self comment]];
[_appointment setPriority:[self priority]];
[_appointment setCategories:[self categories]];
[_appointment setCategories: [[self categories] componentsJoinedByString: @","]];
[_appointment setAccessClass:[self accessClass]];
[_appointment setTransparency:[self transparency]];
@@ -830,18 +831,33 @@
? [attendees arrayByAddingObjectsFromArray:lResources]
: lResources;
}
[attendees makeObjectsPerformSelector: @selector (setTag:)
withObject: @"attendee"];
[_appointment setAttendees:attendees];
/* cycles */
[_appointment setRecurrenceRule:[self rrule]];
[_appointment removeAllRecurrenceRules];
rrule = [self rrule];
if (rrule)
[_appointment addToRecurrenceRules: rrule];
}
- (void)loadValuesFromICalString:(NSString *)_ical {
SOGoAppointment *apt;
- (iCalEvent *) appointmentFromString: (NSString *) _iCalString
{
iCalCalendar *calendar;
iCalEvent *appointment;
SOGoAppointmentObject *clientObject;
apt = [[SOGoAppointment alloc] initWithICalString:_ical];
[self loadValuesFromAppointment:apt];
[apt release];
clientObject = [self clientObject];
calendar = [clientObject calendarFromContent: _iCalString];
appointment = [clientObject firstEventFromCalendar: calendar];
return appointment;
}
- (void) loadValuesFromICalString: (NSString *) _iCalString
{
[self loadValuesFromAppointment: [self appointmentFromString: _iCalString]];
}
/* contact editor compatibility */
@@ -879,7 +895,7 @@
/* conflict management */
- (BOOL)containsConflict:(SOGoAppointment *)_apt {
- (BOOL)containsConflict:(iCalEvent *)_apt {
NSArray *attendees, *uids;
SOGoAppointmentFolder *groupCalendar;
NSArray *infos;
@@ -942,17 +958,17 @@
- (id)testAction {
/* for testing only */
WORequest *req;
SOGoAppointment *apt;
iCalEvent *apt;
NSString *content;
req = [[self context] request];
apt = [[SOGoAppointment alloc] initWithICalString:[self iCalString]];
apt = [self appointmentFromString: [self iCalString]];
[self saveValuesIntoAppointment:apt];
content = [apt iCalString];
content = [[apt parent] versitString];
[self logWithFormat:@"%s -- iCal:\n%@",
__PRETTY_FUNCTION__,
content];
[apt release];
return self;
}
@@ -962,7 +978,8 @@
/* load iCalendar file */
// TODO: can't we use [clientObject contentAsString]?
ical = [[self clientObject] valueForKey:@"iCalString"];
// ical = [[self clientObject] valueForKey:@"iCalString"];
ical = [[self clientObject] contentAsString];
if ([ical length] == 0) /* a new appointment */
ical = [self contentStringTemplate];
@@ -977,7 +994,7 @@
}
- (id)saveAction {
SOGoAppointment *apt;
iCalEvent *apt;
iCalPerson *p;
NSString *content;
NSException *ex;
@@ -989,7 +1006,7 @@
@"the specified object"];
}
apt = [[SOGoAppointment alloc] initWithICalString:[self iCalString]];
apt = [self appointmentFromString: [self iCalString]];
if (apt == nil) {
NSString *s;
@@ -1010,12 +1027,12 @@
s = [self labelForKey:@"Conflicts found!"];
[self setErrorText:s];
[apt release];
return self;
}
}
content = [apt iCalString];
[apt release]; apt = nil;
content = [[apt parent] versitString];
// [apt release]; apt = nil;
if (content == nil) {
NSString *s;
+5 -4
View File
@@ -6,18 +6,19 @@
#include <SOGoUI/UIxComponent.h>
@class NSCalendarDate;
@class SOGoAppointment;
@class iCalEvent;
@class iCalPerson;
@class SOGoDateFormatter;
@interface UIxAppointmentView : UIxComponent
{
id appointment;
id attendee;
iCalEvent* appointment;
iCalPerson* attendee;
SOGoDateFormatter *dateFormatter;
id item;
}
- (SOGoAppointment *)appointment;
- (iCalEvent *)appointment;
/* permissions */
- (BOOL)canAccessApt;
+77 -48
View File
@@ -19,14 +19,13 @@
02111-1307, USA.
*/
#include "UIxAppointmentView.h"
#include <NGCards/NGCards.h>
#include <SOGo/SOGoAppointment.h>
#include <SOGo/WOContext+Agenor.h>
#include <Appointments/SOGoAppointmentObject.h>
#include <SOGoUI/SOGoDateFormatter.h>
#include "UIxComponent+Agenor.h"
#include "common.h"
#import "UIxAppointmentView.h"
#import <NGCards/NGCards.h>
#import <SOGo/WOContext+Agenor.h>
#import <Appointments/SOGoAppointmentObject.h>
#import <SOGoUI/SOGoDateFormatter.h>
#import "UIxComponent+Agenor.h"
#import "common.h"
@interface UIxAppointmentView (PrivateAPI)
- (BOOL)isAttendeeActiveUser;
@@ -35,10 +34,10 @@
@implementation UIxAppointmentView
- (void)dealloc {
[self->appointment release];
[self->attendee release];
[self->dateFormatter release];
[self->item release];
[appointment release];
[attendee release];
[dateFormatter release];
[item release];
[super dealloc];
}
@@ -54,19 +53,22 @@
}
- (void)setAttendee:(id)_attendee {
ASSIGN(self->attendee, _attendee);
ASSIGN(attendee, _attendee);
}
- (id)attendee {
return self->attendee;
return attendee;
}
- (BOOL)isAttendeeActiveUser {
NSString *email, *attEmail;
email = [[[self context] activeUser] email];
attEmail = [[self attendee] rfc822Email];
return [email isEqualToString:attEmail];
attendee = [self attendee];
attEmail = [attendee rfc822Email];
return [email isEqualToString: attEmail];
}
- (BOOL)showAcceptButton {
return [[self attendee] participationStatus] != iCalPersonPartStatAccepted;
}
@@ -78,19 +80,19 @@
}
- (void)setItem:(id)_item {
ASSIGN(self->item, _item);
ASSIGN(item, _item);
}
- (id)item {
return self->item;
return item;
}
- (SOGoDateFormatter *)dateFormatter {
if (self->dateFormatter == nil) {
self->dateFormatter =
if (dateFormatter == nil) {
dateFormatter =
[[SOGoDateFormatter alloc] initWithLocale:[self locale]];
[self->dateFormatter setFullWeekdayNameAndDetails];
[dateFormatter setFullWeekdayNameAndDetails];
}
return self->dateFormatter;
return dateFormatter;
}
- (NSCalendarDate *)startTime {
@@ -117,43 +119,70 @@
return [cns componentsJoinedByString:@"<br />"];
}
- (NSString *)categoriesAsString {
unsigned i, count;
NSArray *cats;
NSMutableString *s;
s = [NSMutableString stringWithCapacity:32];
cats = [((SOGoAppointment *)self->appointment) categories];
count = [cats count];
for(i = 0; i < count; i++) {
NSString *cat, *label;
- (NSString *) categoriesAsString
{
NSEnumerator *categories;
NSArray *rawCategories;
NSMutableArray *l10nCategories;
NSString *currentCategory, *l10nCategory;
cat = [cats objectAtIndex:i];
label = [self labelForKey:cat];
[s appendString:label];
if(i != (count - 1))
[s appendString:@", "];
}
return s;
rawCategories
= [[appointment categories] componentsSeparatedByString: @","];
l10nCategories = [NSMutableArray arrayWithCapacity: [rawCategories count]];
categories = [rawCategories objectEnumerator];
currentCategory = [categories nextObject];
while (currentCategory)
{
l10nCategory
= [self labelForKey: [currentCategory stringByTrimmingSpaces]];
if (l10nCategory)
[l10nCategories addObject: l10nCategory];
currentCategory = [categories nextObject];
}
return [l10nCategories componentsJoinedByString: @", "];
}
// appointment.organizer.cnForDisplay
- (NSString *) eventOrganizer
{
CardElement *organizer;
organizer = [[self appointment] uniqueChildWithTag: @"organizer"];
return [organizer value: 0 ofAttribute: @"cn"];
}
- (NSString *) priorityLabelKey
{
return [NSString stringWithFormat: @"prio_%@", [appointment priority]];
}
/* backend */
- (SOGoAppointment *)appointment {
- (iCalEvent *) appointment
{
NSString *iCalString;
iCalCalendar *calendar;
SOGoAppointmentObject *clientObject;
if (self->appointment != nil)
return self->appointment;
if (appointment != nil)
return appointment;
clientObject = [self clientObject];
iCalString = [[self clientObject] valueForKey:@"iCalString"];
if (![iCalString isNotNull] || [iCalString length] == 0) {
[self errorWithFormat:@"(%s): missing iCal string!",
__PRETTY_FUNCTION__];
return nil;
}
self->appointment = [[SOGoAppointment alloc] initWithICalString:iCalString];
return self->appointment;
calendar = [clientObject calendarFromContent: iCalString];
appointment = [clientObject firstEventFromCalendar: calendar];
[appointment retain];
return appointment;
}
@@ -210,7 +239,7 @@
return YES;
/* not my apt - can access if it's public */
if ([[self appointment] isPublic])
if ([[[self appointment] accessClass] isEqualToString: @"PUBLIC"])
return YES;
/* can access it if I'm invited :-) */