diff --git a/ChangeLog b/ChangeLog index db1360497..ac27d2ad8 100644 --- a/ChangeLog +++ b/ChangeLog @@ -8,6 +8,13 @@ -recurrenceRangesWithinCalendarDateRange:_r]): idem. Also fixed the handling of intervals. +2008-12-19 Wolfgang Sourdeau + + * UI/Common/UIxPageFrame.m ([UIxPageFrame -userSettings]): new + accessor method to avoid loading the user settings with an + additional json request. + ([UIxPageFrame -userDefaults]): same as above for user defaults. + 2008-12-17 Wolfgang Sourdeau * SoObjects/SOGo/SOGoParentFolder.m ([SOGoParentFolder diff --git a/SOPE/GDLContentStore/GCSChannelManager.m b/SOPE/GDLContentStore/GCSChannelManager.m index 17d796bbb..4bf881add 100644 --- a/SOPE/GDLContentStore/GCSChannelManager.m +++ b/SOPE/GDLContentStore/GCSChannelManager.m @@ -46,7 +46,8 @@ */ #if defined(THREADSAFE) -static NSLock *lock; +static NSLock *channelLock; +static NSLock *adaptorLock; #endif @interface GCSChannelHandle : NSObject @@ -89,7 +90,8 @@ static NSTimeInterval ChannelCollectionTimer = 5 * 60; ChannelCollectionTimer = 5*60; #if defined(THREADSAFE) - lock = [NSLock new]; + channelLock = [NSLock new]; + adaptorLock = [NSLock new]; #endif } @@ -104,12 +106,12 @@ static NSTimeInterval ChannelCollectionTimer = 5 * 60; static GCSChannelManager *cm = nil; #if defined(THREADSAFE) - [lock lock]; + [channelLock lock]; #endif if (!cm) cm = [self new]; #if defined(THREADSAFE) - [lock unlock]; + [channelLock unlock]; #endif return cm; @@ -125,7 +127,7 @@ static NSTimeInterval ChannelCollectionTimer = 5 * 60; gcTimer = [[NSTimer scheduledTimerWithTimeInterval: ChannelCollectionTimer - target: self selector: @selector (_garbageCollect: ) + target: self selector: @selector (_garbageCollect:) userInfo: nil repeats: YES] retain]; } @@ -200,7 +202,7 @@ static NSTimeInterval ChannelCollectionTimer = 5 * 60; if ((key = [self databaseKeyForURL: _url])) { #if defined(THREADSAFE) - [lock lock]; + [adaptorLock lock]; #endif adaptor = [urlToAdaptor objectForKey: key]; if (adaptor) @@ -209,7 +211,7 @@ static NSTimeInterval ChannelCollectionTimer = 5 * 60; { [self debugWithFormat: @"creating new adaptor for URL: %@", _url]; - if ([EOAdaptor respondsToSelector: @selector (adaptorForURL: )]) + if ([EOAdaptor respondsToSelector: @selector (adaptorForURL:)]) adaptor = [EOAdaptor adaptorForURL: _url]; else { @@ -234,7 +236,7 @@ static NSTimeInterval ChannelCollectionTimer = 5 * 60; [urlToAdaptor setObject: adaptor forKey: key]; } #if defined(THREADSAFE) - [lock unlock]; + [adaptorLock unlock]; #endif } } @@ -317,7 +319,7 @@ static NSTimeInterval ChannelCollectionTimer = 5 * 60; /* look for cached handles */ #if defined(THREADSAFE) - [lock lock]; + [channelLock lock]; #endif handle = [self findAvailChannelHandleForURL: _url]; if (handle) @@ -364,7 +366,7 @@ static NSTimeInterval ChannelCollectionTimer = 5 * 60; } } #if defined(THREADSAFE) - [lock unlock]; + [channelLock unlock]; #endif return channel; @@ -375,7 +377,7 @@ static NSTimeInterval ChannelCollectionTimer = 5 * 60; GCSChannelHandle *handle; #if defined(THREADSAFE) - [lock lock]; + [channelLock lock]; #endif handle = [self findBusyChannelHandleForChannel: _channel]; if (handle) @@ -411,7 +413,7 @@ static NSTimeInterval ChannelCollectionTimer = 5 * 60; [_channel release]; } #if defined(THREADSAFE) - [lock unlock]; + [channelLock unlock]; #endif } @@ -462,7 +464,7 @@ static NSTimeInterval ChannelCollectionTimer = 5 * 60; GCSChannelHandle *handle; #if defined(THREADSAFE) - [lock lock]; + [channelLock lock]; #endif count = [availableChannels count]; if (count) @@ -499,7 +501,7 @@ static NSTimeInterval ChannelCollectionTimer = 5 * 60; [handlesToRemove release]; } #if defined(THREADSAFE) - [lock unlock]; + [channelLock unlock]; #endif } diff --git a/SoObjects/SOGo/LDAPSource.m b/SoObjects/SOGo/LDAPSource.m index 94d8f4c6b..e9fa32e28 100644 --- a/SoObjects/SOGo/LDAPSource.m +++ b/SoObjects/SOGo/LDAPSource.m @@ -22,6 +22,7 @@ #import #import +#import #import #import @@ -41,6 +42,10 @@ static NSString *LDAPContactInfoAttribute = nil; static int timeLimit; static int sizeLimit; +#if defined(THREADSAFE) +static NSLock *lock; +#endif + @implementation LDAPSource + (void) initialize @@ -126,6 +131,10 @@ static int sizeLimit; @"calFBURL", @"proxyAddresses", nil]; [commonSearchFields retain]; + +#if defined(THREADSAFE) + lock = [NSLock new]; +#endif } } @@ -312,6 +321,10 @@ static int sizeLimit; NSString *userDN; NGLdapConnection *bindConnection; +#if defined(THREADSAFE) + [lock lock]; +#endif + didBind = NO; if ([loginToCheck length] > 0) @@ -337,6 +350,10 @@ static int sizeLimit; [bindConnection release]; } +#if defined(THREADSAFE) + [lock unlock]; +#endif + return didBind; } @@ -431,6 +448,10 @@ static int sizeLimit; NGLdapEntry *currentEntry; NSString *value; +#if defined(THREADSAFE) + [lock lock]; +#endif + ids = [NSMutableArray array]; if ([self _initLDAPConnection]) @@ -455,6 +476,10 @@ static int sizeLimit; [ldapConnection autorelease]; +#if defined(THREADSAFE) + [lock unlock]; +#endif + return ids; } @@ -552,6 +577,10 @@ static int sizeLimit; NGLdapEntry *currentEntry; NSEnumerator *entries; +#if defined(THREADSAFE) + [lock lock]; +#endif + contacts = [NSMutableArray array]; if ([match length] > 0) @@ -571,6 +600,10 @@ static int sizeLimit; [ldapConnection release]; } +#if defined(THREADSAFE) + [lock unlock]; +#endif + return contacts; } @@ -579,6 +612,10 @@ static int sizeLimit; NSDictionary *contactEntry; NGLdapEntry *ldapEntry; +#if defined(THREADSAFE) + [lock lock]; +#endif + contactEntry = nil; if ([entryID length] > 0) @@ -597,6 +634,10 @@ static int sizeLimit; [ldapConnection autorelease]; } +#if defined(THREADSAFE) + [lock unlock]; +#endif + return contactEntry; } @@ -607,6 +648,10 @@ static int sizeLimit; NSEnumerator *entries; EOQualifier *qualifier; +#if defined(THREADSAFE) + [lock lock]; +#endif + contactEntry = nil; if ([uid length] > 0) @@ -628,6 +673,10 @@ static int sizeLimit; [ldapConnection release]; } +#if defined(THREADSAFE) + [lock unlock]; +#endif + return contactEntry; } diff --git a/SoObjects/SOGo/LDAPUserManager.m b/SoObjects/SOGo/LDAPUserManager.m index bf5ff00ba..f0f6f7b56 100644 --- a/SoObjects/SOGo/LDAPUserManager.m +++ b/SoObjects/SOGo/LDAPUserManager.m @@ -40,7 +40,7 @@ static BOOL defaultMailDomainIsConfigured = NO; static BOOL forceImapLoginWithEmail = NO; #if defined(THREADSAFE) -static NSLock *lock; +static NSLock *lock = nil; #endif @implementation LDAPUserManager @@ -134,13 +134,14 @@ static NSLock *lock; udSources = [ud arrayForKey: @"SOGoLDAPSources"]; - if (udSources && [udSources isKindOfClass: [NSArray class]]) { - max = [udSources count]; - for (count = 0; count < max; count++) - [self _registerSource: [udSources objectAtIndex: count]]; - } else { + if (udSources && [udSources isKindOfClass: [NSArray class]]) + { + max = [udSources count]; + for (count = 0; count < max; count++) + [self _registerSource: [udSources objectAtIndex: count]]; + } + else [self errorWithFormat: @"SOGoLDAPSources is not defined or it is not an array. Check your defaults."]; - } } - (id) init diff --git a/SoObjects/SOGo/SOGoUser.m b/SoObjects/SOGo/SOGoUser.m index dd0c84843..c9c6a1322 100644 --- a/SoObjects/SOGo/SOGoUser.m +++ b/SoObjects/SOGo/SOGoUser.m @@ -244,9 +244,7 @@ _timeValue (NSString *key) LDAPUserManager *um; NSString *realUID; - if (// acceptAnyUser -// || - [newLogin isEqualToString: @"anonymous"] + if ([newLogin isEqualToString: @"anonymous"] || [newLogin isEqualToString: @"freebusy"]) realUID = newLogin; else diff --git a/UI/Common/UIxPageFrame.m b/UI/Common/UIxPageFrame.m index 11dd97d16..8eda4fcda 100644 --- a/UI/Common/UIxPageFrame.m +++ b/UI/Common/UIxPageFrame.m @@ -397,6 +397,34 @@ return language; } +- (NSString *) userSettings +{ + NSUserDefaults *userSettings; + NSString *jsonResult; + + userSettings = [[context activeUser] userSettings]; + if (userSettings) + jsonResult = [userSettings jsonRepresentation]; + else + jsonResult = @"{}"; + + return jsonResult; +} + +- (NSString *) userDefaults +{ + NSUserDefaults *userDefaults; + NSString *jsonResult; + + userDefaults = [[context activeUser] userDefaults]; + if (userDefaults) + jsonResult = [userDefaults jsonRepresentation]; + else + jsonResult = @"{}"; + + return jsonResult; +} + /* browser/os identification */ - (BOOL) isCompatibleBrowser diff --git a/UI/MainUI/product.plist b/UI/MainUI/product.plist index 194b03cd6..621cf8eaf 100644 --- a/UI/MainUI/product.plist +++ b/UI/MainUI/product.plist @@ -88,6 +88,12 @@ categories = { SOGo = { // TODO: move decls to class + slots = { + toolbar = { + value = "none"; // keep this in order to avoid lookups on username + // "toolbar" + }; + }; methods = { view = { protectedBy = ""; diff --git a/UI/Templates/UIxPageFrame.wox b/UI/Templates/UIxPageFrame.wox index 7625fa6b6..afde244d1 100644 --- a/UI/Templates/UIxPageFrame.wox +++ b/UI/Templates/UIxPageFrame.wox @@ -108,9 +108,11 @@ var UserFolderURL = ''; - var UserLogin = ''; - var UserLanguage = ''; + >var UserFolderURL = ''; + var UserLogin = ''; + var UserLanguage = ''; + var UserSettings = ; + var UserDefaults = ; diff --git a/UI/WebServerResources/MailerUI.js b/UI/WebServerResources/MailerUI.js index 4c48e2b92..d67214dcf 100644 --- a/UI/WebServerResources/MailerUI.js +++ b/UI/WebServerResources/MailerUI.js @@ -583,7 +583,7 @@ function messageListCallback(http) { var div = $('mailboxContent'); var table = $('messageList'); - var columnsOrder = userSettings["SOGoMailListViewColumnsOrder"]; + var columnsOrder = UserSettings["SOGoMailListViewColumnsOrder"]; if ( typeof(columnsOrder) == "undefined" ) { columnsOrder = defaultColumnsOrder; } @@ -1363,7 +1363,7 @@ function configureMessageListBodyEvents(table) { // 4 => Unread // 5 => Date // 6 => Priority - var columnsOrder = userSettings["SOGoMailListViewColumnsOrder"]; + var columnsOrder = UserSettings["SOGoMailListViewColumnsOrder"]; if ( typeof(columnsOrder) == "undefined" ) { columnsOrder = defaultColumnsOrder; } @@ -1474,7 +1474,7 @@ function initMailer(event) { } function initMessageCheckTimer() { - var messageCheck = userDefaults["MessageCheck"]; + var messageCheck = UserDefaults["MessageCheck"]; if (messageCheck && messageCheck != "manually") { var interval; if (messageCheck == "once_per_hour") diff --git a/UI/WebServerResources/UIxMailEditor.js b/UI/WebServerResources/UIxMailEditor.js index 8a4390f0c..a51376f93 100644 --- a/UI/WebServerResources/UIxMailEditor.js +++ b/UI/WebServerResources/UIxMailEditor.js @@ -312,7 +312,7 @@ function onTextIEUpdateCursorPos(event) { function onTextFirstFocus() { var content = this.getValue(); - var replyPlacement = userDefaults["ReplyPlacement"]; + var replyPlacement = UserDefaults["ReplyPlacement"]; if (replyPlacement == "above") { this.insertBefore(document.createTextNode("\r\r"), this.lastChild); @@ -547,7 +547,7 @@ function initMailEditor() { if (sigLimit > -1) MailEditor.signatureLength = (textContent.length - sigLimit); } - if (userDefaults["ReplyPlacement"] != "above") { + if (UserDefaults["ReplyPlacement"] != "above") { textarea.scrollTop = textarea.scrollHeight; } textarea.observe("focus", onTextFirstFocus); @@ -655,7 +655,7 @@ function lineBreakCount(str){ function hasSignature() { try { - return(userDefaults.MailAccounts[0].identities[0].signature.length > 0); + return(UserDefaults.MailAccounts[0].identities[0].signature.length > 0); } catch(e) { return false; } diff --git a/UI/WebServerResources/generic.js b/UI/WebServerResources/generic.js index 721c64be7..3fc6d568e 100644 --- a/UI/WebServerResources/generic.js +++ b/UI/WebServerResources/generic.js @@ -38,9 +38,6 @@ var lastClickedRow = -1; // logArea = null; var allDocumentElements = null; -var userDefaults = null; -var userSettings = null; - // Ajax requests counts var activeAjaxRequests = 0; var removeFolderRequestCount = 0; @@ -1402,7 +1399,7 @@ function indexColor(number) { return color; } -function loadPreferences() { +function reloadPreferences() { var url = UserFolderURL + "jsonDefaults"; var http = createHTTPClient(); http.open("GET", url, false); @@ -1410,9 +1407,9 @@ function loadPreferences() { if (http.status == 200) { if (http.responseText.length > 0) - userDefaults = http.responseText.evalJSON(true); + UserDefaults = http.responseText.evalJSON(true); else - userDefaults = {}; + UserDefaults = {}; } url = UserFolderURL + "jsonSettings"; @@ -1420,15 +1417,13 @@ function loadPreferences() { http.send(""); if (http.status == 200) { if (http.responseText.length > 0) - userSettings = http.responseText.evalJSON(true); + UserSettings = http.responseText.evalJSON(true); else - userSettings = {}; + UserSettings = {}; } } function onLoadHandler(event) { - if (typeof UserLogin != "undefined" && UserLogin != "wrongusernamepassword") - loadPreferences(); queryParameters = parseQueryParameters('' + window.location); if (!$(document.body).hasClassName("popup")) { initLogConsole();