Monotone-Parent: fc267c7dc09cc05decc140411d1facce3f441866
Monotone-Revision: c2a5265bbdaf7810309bda5f2f3dd5f2c67b15ed

Monotone-Author: wsourdeau@inverse.ca
Monotone-Date: 2010-06-11T18:43:46
Monotone-Branch: ca.inverse.sogo
maint-2.0.2
Wolfgang Sourdeau 2010-06-11 18:43:46 +00:00
parent bfcaea41c0
commit 676194b020
8 changed files with 130 additions and 123 deletions

View File

@ -1,5 +1,21 @@
2010-06-11 Wolfgang Sourdeau <wsourdeau@inverse.ca>
* UI/Scheduler/UIxCalMainActions.m (-saveUrl:forCalendar:):
removed method since obsoleted by the code below.
* SoObjects/Appointments/SOGoWebAppointmentFolder.m
(-loadWebCalendar): removed the URL parameter since it's
read-only.
(-delete): simplified method.
* SoObjects/Appointments/SOGoAppointmentFolders.m
(-newWebCalendarWithName:atURL:): new self-explicit method.
(-reloadWebCalendars): we now make use of the @"WebCalendar" name
as a property key.
(_migrateWebCalendarsSettings): new method that converts
WebCalendar entry keys in a format suitable for use as a property
key.
* UI/Scheduler/UIxCalFilterPanel.m (+initialize): commented out
the "All Events" option as this could cause a delay too long in IE
when drawing the list.

View File

@ -27,12 +27,16 @@
@class NSArray;
@class SOGoWebAppointmentFolder;
@interface SOGoAppointmentFolders : SOGoParentFolder
{
NSMutableArray *folderObjectKeys;
}
- (NSArray *) webCalendarIds;
- (SOGoWebAppointmentFolder *) newWebCalendarWithName: (NSString *) folderDisplayName
atURL: (NSString *) url;
- (void) reloadWebCalendars: (BOOL) forceReload;
- (BOOL) hasProxyCalendarsWithWriteAccess: (BOOL) write

View File

@ -96,6 +96,30 @@
return [self labelForKey: @"Personal Calendar" inContext: context];
}
- (SOGoWebAppointmentFolder *)
newWebCalendarWithName: (NSString *) folderDisplayName
atURL: (NSString *) url
{
SOGoAppointmentFolder *aptFolder;
SOGoWebAppointmentFolder *webCalendar;
NSString *name;
if (![self newFolderWithName: folderDisplayName
nameInContainer: &name])
{
aptFolder = [subFolders objectForKey: name];
[aptFolder setFolderPropertyValue: url
inCategory: @"WebCalendars"];
webCalendar = [SOGoWebAppointmentFolder objectWithName: name
inContainer: self];
[webCalendar setOCSPath: [aptFolder ocsPath]];
[subFolders setObject: webCalendar forKey: name];
}
return webCalendar;
}
- (NSArray *) toManyRelationshipKeys
{
NSMutableArray *keys;
@ -348,91 +372,102 @@
return componentSet;
}
- (NSArray *) webCalendarIds
{
SOGoUserSettings *us;
NSDictionary *tmp, *calendars;
NSArray *rc;
rc = nil;
us = [[SOGoUser userWithLogin: owner] userSettings];
tmp = [us objectForKey: @"Calendar"];
if (tmp)
{
calendars = [tmp objectForKey: @"WebCalendars"];
if (calendars)
rc = [calendars allKeys];
}
if (!rc)
rc = [NSArray array];
return rc;
}
- (void) reloadWebCalendars: (BOOL) forceReload
{
SOGoUserSettings *settings;
NSMutableDictionary *calendarSettings, *webCalendars;
NSArray *calendarIds;
NSArray *refs;
SOGoWebAppointmentFolder *folder;
NSString *name;
SOGoUserSettings *us;
NSDictionary *calSettings;
NSString *ref;
int count, max;
settings = [[SOGoUser userWithLogin: owner] userSettings];
calendarSettings = [settings objectForKey: @"Calendar"];
webCalendars = [calendarSettings objectForKey: @"WebCalendars"];
calendarIds = [webCalendars allKeys];
max = [calendarIds count];
us = [[SOGoUser userWithLogin: owner] userSettings];
calSettings = [us objectForKey: @"Calendar"];
refs = [[calSettings objectForKey: @"WebCalendars"] allKeys];
max = [refs count];
for (count = 0; count < max; count++)
{
name = [calendarIds objectAtIndex: count];
folder = [self lookupName: name inContext: context acquire: NO];
ref = [refs objectAtIndex: count];
folder = [SOGoWebAppointmentFolder
folderWithSubscriptionReference: ref
inContainer: self];
if (folder
&& [folder isKindOfClass: [SOGoWebAppointmentFolder class]]
&& (forceReload || [folder reloadOnLogin]))
[folder loadWebCalendar: [webCalendars objectForKey: name]];
[folder loadWebCalendar];
}
}
- (void) _migrateWebCalendarsSettings
{
SOGoUserSettings *us;
NSDictionary *module;
NSMutableDictionary *webCalendars;
NSArray *keys;
NSString *oldKey, *prefix, *newKey;
int count, max;
BOOL hasChanged;
hasChanged = NO;
us = [[context activeUser] userSettings];
module = [us objectForKey: @"Calendar"];
webCalendars = [module objectForKey: @"WebCalendars"];
keys = [webCalendars allKeys];
max = [keys count];
prefix = [NSString stringWithFormat: @"%@:Calendar/",
[self ownerInContext: context]];
for (count = 0; count < max; count++)
{
oldKey = [keys objectAtIndex: count];
if (![oldKey hasPrefix: prefix])
{
newKey = [prefix stringByAppendingString: oldKey];
[webCalendars setObject: [webCalendars objectForKey: oldKey]
forKey: newKey];
[webCalendars removeObjectForKey: oldKey];
hasChanged = YES;
}
}
if (hasChanged)
[us synchronize];
}
- (NSException *) _fetchPersonalFolders: (NSString *) sql
withChannel: (EOAdaptorChannel *) fc
{
int count, max;
NSArray *webCalendarIds;
NSString *name;
SOGoAppointmentFolder *old;
SOGoWebAppointmentFolder *folder;
NSException *error;
BOOL isWebRequest;
NSException *error;
NSArray *folders;
int count, max;
SOGoAppointmentFolder *folder;
SOGoWebAppointmentFolder *webFolder;
NSString *name;
isWebRequest = [[context request] handledByDefaultHandler];
error = [super _fetchPersonalFolders: sql withChannel: fc];
if (!error)
{
webCalendarIds = [self webCalendarIds];
max = [webCalendarIds count];
isWebRequest = [[context request] handledByDefaultHandler];
folders = [subFolders allValues];
max = [folders count];
[self _migrateWebCalendarsSettings];
for (count = 0; count < max; count++)
{
name = [webCalendarIds objectAtIndex: count];
if (isWebRequest)
folder = [folders objectAtIndex: count];
if ([folder folderPropertyValueInCategory: @"WebCalendars"])
{
old = [subFolders objectForKey: name];
if (old)
name = [folder nameInContainer];
if (isWebRequest)
{
folder = [SOGoWebAppointmentFolder objectWithName: name
webFolder = [SOGoWebAppointmentFolder objectWithName: name
inContainer: self];
[folder setOCSPath: [old ocsPath]];
[subFolders setObject: folder forKey: name];
[webFolder setOCSPath: [folder ocsPath]];
[subFolders setObject: webFolder forKey: name];
}
else
[self errorWithFormat: @"webcalendar inconsistency: folder with"
@" name '%@' was not found in the database,"
@" conversion skipped", name];
[subFolders removeObjectForKey: name];
}
else
[subFolders removeObjectForKey: name];
}
}

View File

@ -27,7 +27,7 @@
@interface SOGoWebAppointmentFolder : SOGoAppointmentFolder
- (int) loadWebCalendar: (NSString *) location;
- (int) loadWebCalendar;
- (void) deleteAllContent;
- (void) setReloadOnLogin: (BOOL) newReloadOnLogin;

View File

@ -36,16 +36,16 @@
[[self ocsFolder] deleteAllContent];
}
- (int) loadWebCalendar: (NSString *) location
- (int) loadWebCalendar
{
NSURL *url;
NSData *data;
NSString *contents;
NSString *location, *contents;
iCalCalendar *calendar;
int imported = 0;
location = [self folderPropertyValueInCategory: @"WebCalendars"];
url = [NSURL URLWithString: location];
if (url)
{
data = [url resourceDataUsingCache: NO];
@ -89,20 +89,10 @@
- (NSException *) delete
{
NSException *error;
SOGoUserSettings *settings;
NSMutableDictionary *webCalendars;
NSString *name;
error = [super delete];
if (!error)
{
settings = [[context activeUser] userSettings];
webCalendars = [[settings objectForKey: @"Calendar"]
objectForKey: @"WebCalendars"];
name = [self nameInContainer];
[webCalendars removeObjectForKey: name];
[settings synchronize];
}
[self setFolderPropertyValue: nil inCategory: @"WebCalendars"];
return error;
}

View File

@ -27,9 +27,6 @@
@interface UIxCalMainActions : WODirectAction
- (void) saveUrl: (NSURL *) calendarURL
forCalendar: (NSString *) calendarName;
@end
#endif /* UIXCALMAINACTIONS_H */

View File

@ -61,7 +61,7 @@
WOResponse *response;
SOGoWebAppointmentFolder *folder;
NSURL *url;
NSString *name, *displayName;
NSString *urlString, *displayName;
NSMutableDictionary *rc;
SOGoAppointmentFolders *folders;
int imported = 0;
@ -70,25 +70,21 @@
rc = [NSMutableDictionary dictionary];
// Just a check
url = [NSURL URLWithString: [r formValueForKey: @"url"]];
urlString = [r formValueForKey: @"url"];
url = [NSURL URLWithString: urlString];
if (url)
{
folders = [self clientObject];
displayName = [self displayNameForUrl: [r formValueForKey: @"url"]];
[folders newFolderWithName: displayName
nameInContainer: &name];
[self saveUrl: url forCalendar: name];
folder = [folders lookupName: name
inContext: context
acquire: NO];
folder = [folders newWebCalendarWithName: displayName
atURL: urlString];
if (folder)
{
imported = [folder loadWebCalendar: [r formValueForKey: @"url"]];
imported = [folder loadWebCalendar];
if (imported >= 0)
{
[rc setObject: displayName forKey: @"displayname"];
[rc setObject: name forKey: @"name"];
[rc setObject: [folder nameInContainer] forKey: @"name"];
}
else
{
@ -104,24 +100,6 @@
return response;
}
- (void) saveUrl: (NSURL *) calendarURL
forCalendar: (NSString *) calendarName
{
SOGoUserSettings *settings;
NSMutableDictionary *calSettings, *webCalendars;
settings = [[context activeUser] userSettings];
calSettings = [settings objectForKey: @"Calendar"];
webCalendars = [calSettings objectForKey: @"WebCalendars"];
if (!webCalendars)
{
webCalendars = [NSMutableDictionary dictionary];
[calSettings setObject: webCalendars forKey: @"WebCalendars"];
}
[webCalendars setObject: [calendarURL absoluteString] forKey: calendarName];
[settings synchronize];
}
- (WOResponse *) reloadWebCalendarsAction
{
[[self clientObject] reloadWebCalendars: YES];

View File

@ -177,24 +177,6 @@
[calendar setShowCalendarTasks: new];
}
- (NSString *) webCalendarURL
{
SOGoUserSettings *settings;
NSMutableDictionary *calendarSettings;
NSMutableDictionary *webCalendars;
NSString *rc;
settings = [[context activeUser] userSettings];
calendarSettings = [settings objectForKey: @"Calendar"];
webCalendars = [calendarSettings objectForKey: @"WebCalendars"];
if (webCalendars)
rc = [webCalendars objectForKey: [calendar nameInContainer]];
else
rc = nil;
return rc;
}
- (BOOL) userIsOwner
{
NSString *userLogin;
@ -209,6 +191,11 @@
return ([calendar isKindOfClass: [SOGoWebAppointmentFolder class]]);
}
- (NSString *) webCalendarURL
{
return [calendar folderPropertyValueInCategory: @"WebCalendars"];
}
- (void) setReloadOnLogin: (BOOL) newReloadOnLogin
{
if ([calendar respondsToSelector: @selector (setReloadOnLogin:)])