From d9791705fbb27dbe3684db6a02ac7d7c67c02dfb Mon Sep 17 00:00:00 2001 From: Ludovic Marcotte Date: Tue, 2 Dec 2008 01:36:53 +0000 Subject: [PATCH 1/2] See ChangeLog Monotone-Parent: 136367702e2d0a66ecd8c78c0f55fe81a6d9d1be Monotone-Revision: 694105995f89f2830e19da5ab10400813c23741f Monotone-Author: ludovic@Sophos.ca Monotone-Date: 2008-12-02T01:36:53 Monotone-Branch: ca.inverse.sogo --- ChangeLog | 5 ++++ SoObjects/SOGo/SOGoCache.m | 10 +++++++ SoObjects/SOGo/SOGoUserDefaults.m | 45 ++++++++++++++++--------------- 3 files changed, 39 insertions(+), 21 deletions(-) diff --git a/ChangeLog b/ChangeLog index 5a0c50f7f..39b7b00c7 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2008-12-01 Ludovic Marcotte + + * Improved the cache sync process and added + safetiness using a db transaction. + 2008-12-01 Francis Lachapelle * SoObjects/Appointments/SOGoAppointmentObject.m diff --git a/SoObjects/SOGo/SOGoCache.m b/SoObjects/SOGo/SOGoCache.m index 92344d77a..2bc62fe5e 100644 --- a/SoObjects/SOGo/SOGoCache.m +++ b/SoObjects/SOGo/SOGoCache.m @@ -248,6 +248,11 @@ static SOGoCache *sharedCache = nil; if ((user = [users objectForKey: uid])) { [[user userDefaults] setValues: [[theNotification userInfo] objectForKey: @"values"]]; + [self setCachedUserDefaults: [user userDefaults] forKey: uid]; + } + else + { + [s_userDefaults removeObjectForKey: uid]; } } @@ -261,6 +266,11 @@ static SOGoCache *sharedCache = nil; if ((user = [users objectForKey: uid])) { [[user userSettings] setValues: [[theNotification userInfo] objectForKey: @"values"]]; + [self setCachedUserSettings: [user userSettings] forKey: uid]; + } + else + { + [s_userSettings removeObjectForKey: uid]; } } diff --git a/SoObjects/SOGo/SOGoUserDefaults.m b/SoObjects/SOGo/SOGoUserDefaults.m index 984659e12..73e837d9a 100644 --- a/SoObjects/SOGo/SOGoUserDefaults.m +++ b/SoObjects/SOGo/SOGoUserDefaults.m @@ -1,5 +1,6 @@ /* Copyright (C) 2005 SKYRIX Software AG + Copyright (C) 2008 Inverse inc. This file is part of OpenGroupware.org. @@ -264,33 +265,19 @@ static NSString *uidColumnName = @"c_uid"; channel = [cm acquireOpenChannelForURL: [self tableURL]]; if (channel) { + [[channel adaptorContext] beginTransaction]; ex = [channel evaluateExpressionX:sql]; if (ex) - [self errorWithFormat: @"could not run SQL '%@': %@", sql, ex]; + { + [self errorWithFormat: @"could not run SQL '%@': %@", sql, ex]; + [[channel adaptorContext] rollbackTransaction]; + } else { - NSMutableDictionary *d; - - d = [[NSMutableDictionary alloc] init]; - [d setObject: values forKey: @"values"]; - [d setObject: uid forKey: @"uid"]; - - [[NSDistributedNotificationCenter defaultCenter] - postNotificationName: ([fieldName isEqualToString: @"c_defaults"] ? @"SOGoUserDefaultsHaveChanged" : @"SOGoUserSettingsHaveChanged") - object: nil - userInfo: d]; - [d release]; - - if ([[channel adaptorContext] hasOpenTransaction]) + if ([[channel adaptorContext] commitTransaction]) { - ex = [channel evaluateExpressionX: @"COMMIT TRANSACTION"]; - if (ex) - [self errorWithFormat:@"could not commit transaction for update: %@", ex]; - else - rc = YES; + rc = YES; } - else - rc = YES; defFlags.modified = NO; defFlags.isNew = NO; @@ -305,6 +292,22 @@ static NSString *uidColumnName = @"c_uid"; else [self errorWithFormat: @"failed to generate SQL for storing defaults"]; + if (rc) + { + NSMutableDictionary *d; + + d = [[NSMutableDictionary alloc] init]; + [d setObject: values forKey: @"values"]; + [d setObject: uid forKey: @"uid"]; + + [[NSDistributedNotificationCenter defaultCenter] + postNotificationName: ([fieldName isEqualToString: @"c_defaults"] ? @"SOGoUserDefaultsHaveChanged" : @"SOGoUserSettingsHaveChanged") + object: nil + userInfo: d + deliverImmediately: YES]; + [d release]; + } + return rc; } From fdabc48820ff07676c9eacfecd79f1ea520cd490 Mon Sep 17 00:00:00 2001 From: Ludovic Marcotte Date: Tue, 2 Dec 2008 12:27:41 +0000 Subject: [PATCH 2/2] Minor fix in the SENT-BY handling. Monotone-Parent: 694105995f89f2830e19da5ab10400813c23741f Monotone-Revision: 8a7076e816120408558e4add54151b80aeeb69d8 Monotone-Author: ludovic@Sophos.ca Monotone-Date: 2008-12-02T12:27:41 Monotone-Branch: ca.inverse.sogo --- UI/MailPartViewers/UIxMailPartICalActions.m | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/UI/MailPartViewers/UIxMailPartICalActions.m b/UI/MailPartViewers/UIxMailPartICalActions.m index 1ce6137c7..ad506bea0 100644 --- a/UI/MailPartViewers/UIxMailPartICalActions.m +++ b/UI/MailPartViewers/UIxMailPartICalActions.m @@ -203,7 +203,14 @@ [otherAttendee addAttribute: @"SENT-BY" value: [NSString stringWithFormat: @"\"MAILTO:%@\"", currentEmail]]; } - + else + { + // We must REMOVE any SENT-BY here. This is important since if A accepted + // the event for B and then, B changes by himself his participation status, + // we don't want to keep the previous SENT-BY attribute there. + [(NSMutableDictionary *)[otherAttendee attributes] removeObjectForKey: @"SENT-BY"]; + } + iCalString = [[event parent] versitString]; [eventObject saveContentString: iCalString]; }