merge of 'ccb49b853f2059fd3133a0ab1c7e4f79f4b87c23'

and 'fb42e2a1670666605ac484d419b64d92c83f004d'

Monotone-Parent: ccb49b853f2059fd3133a0ab1c7e4f79f4b87c23
Monotone-Parent: fb42e2a1670666605ac484d419b64d92c83f004d
Monotone-Revision: 2c76ac8192cf2138f05a94de5eff80eec5e71f7b

Monotone-Author: wsourdeau@inverse.ca
Monotone-Date: 2010-10-28T15:52:11
Monotone-Branch: ca.inverse.sogo
This commit is contained in:
Wolfgang Sourdeau
2010-10-28 15:52:11 +00:00
2 changed files with 55 additions and 5 deletions
+8
View File
@@ -4,6 +4,14 @@
(-mimeHeaderMapWithHeaders:excluding:): added the X-Forward header
with the user's IP address, if available and not equal to 'localhost'.
2010-10-28 Wolfgang Sourdeau <wsourdeau@inverse.ca>
* SoObjects/Appointments/SOGoAppointmentFolders.m
(-_migrateWebCalendarsSettings): fixed a bug where the active
user's login name would be used as comparison prefix, leading to a
corrupted and very long calendar key. Added code to migrate those
previously corrupted keys to their proper form.
2010-10-27 Wolfgang Sourdeau <wsourdeau@inverse.ca>
* UI/Contacts/UIxContactView.m (-categories): new accessor for
@@ -414,6 +414,44 @@ static SoSecurityManager *sm = nil;
return componentSet;
}
/* This method fixes an issue that occurred previously in
_migrateWebCalendarsSettings, where the active user, rather than the
owner's login would be taken to compose the expected key prefix, leading to
a corrupted calendar key with an endless chain of
[user]:/Calendar/[user]:/Calendar/[user].... occurrences. */
- (NSString *) _fixedWebCalendarKey: (NSString *) oldKey
{
NSString *newKey;
NSRange lastOccurrence, fullOccurrence;
lastOccurrence = [oldKey rangeOfString: @":Calendar/"
options: NSBackwardsSearch];
if ([oldKey rangeOfString: @":Calendar/"].location != lastOccurrence.location)
{
fullOccurrence
= [oldKey rangeOfString:
[NSString stringWithFormat: @"%@:Calendar/",
owner]
options: NSBackwardsSearch];
if (fullOccurrence.location != NSNotFound)
{
newKey = [oldKey substringFromIndex: fullOccurrence.location];
[self logWithFormat: @"fixed erroneous calendar key: '%@' -> '%@'",
oldKey, newKey];
}
else
{
[self errorWithFormat: @"calendar key cannot be fixed: '%@'",
oldKey];
newKey = nil;
}
}
else
newKey = nil;
return newKey;
}
- (void) _migrateWebCalendarsSettings
{
SOGoUserSettings *us;
@@ -426,20 +464,24 @@ static SoSecurityManager *sm = nil;
hasChanged = NO;
us = [[context activeUser] userSettings];
prefix = [NSString stringWithFormat: @"%@:Calendar/",
[self ownerInContext: context]];
us = [[SOGoUser userWithLogin: owner] 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])
if ([oldKey hasPrefix: prefix])
newKey = [self _fixedWebCalendarKey: oldKey];
else
newKey = [prefix stringByAppendingString: oldKey];
if (newKey)
{
newKey = [prefix stringByAppendingString: oldKey];
[webCalendars setObject: [webCalendars objectForKey: oldKey]
forKey: newKey];
[webCalendars removeObjectForKey: oldKey];