Monotone-Parent: 88aa0604fa28680daef426d3364f7f10665edb11

Monotone-Revision: 917c16cbc72247a3b9d3bc68547572f93349255c

Monotone-Author: flachapelle@inverse.ca
Monotone-Date: 2007-12-13T21:07:09
Monotone-Branch: ca.inverse.sogo
This commit is contained in:
Francis Lachapelle 2007-12-13 21:07:09 +00:00
parent 6b5da3c2ea
commit 438e9bb635
6 changed files with 138 additions and 6 deletions

View file

@ -1,3 +1,9 @@
2007-12-13 Francis Lachapelle <flachapelle@inverse.ca>
* UI/MailerUI/UIxMailMainFrame.m ([UIxMailMainFrame -saveFoldersStateAction])
([UIxMailMainFrame -getFoldersStateAction]): new methods to get
and set the folders state of the user's web view.
2007-12-13 Wolfgang Sourdeau <wsourdeau@inverse.ca>
* UI/MainUI/SOGoRootPage.m ([SOGoRootPage -crashAction]): new

View file

@ -26,7 +26,10 @@
#import "../SOGoUI/UIxComponent.h"
@interface UIxMailMainFrame : UIxComponent
{
NSUserDefaults *ud;
NSMutableDictionary *moduleSettings;
}
@end
#endif /* UIXMAILMAINFRAME_H */

View file

@ -36,6 +36,28 @@
@implementation UIxMailMainFrame
- (void) _setupContext
{
SOGoUser *activeUser;
NSString *login, *module;
SOGoMailAccounts *clientObject;
activeUser = [context activeUser];
login = [activeUser login];
clientObject = [self clientObject];
module = [clientObject nameInContainer];
ud = [activeUser userSettings];
moduleSettings = [ud objectForKey: module];
if (!moduleSettings)
{
moduleSettings = [NSMutableDictionary new];
[moduleSettings autorelease];
}
[ud setObject: moduleSettings forKey: module];
}
/* accessors */
- (NSString *) mailAccounts
{
@ -111,4 +133,31 @@
return [self redirectToLocation: newLocation];
}
- (WOResponse *) getFoldersStateAction
{
NSString *expandedFolders;
[self _setupContext];
expandedFolders = [moduleSettings objectForKey: @"ExpandedFolders"];
return [self responseWithStatus: 200 andString: expandedFolders];
}
- (WOResponse *) saveFoldersStateAction
{
WORequest *request;
NSString *expandedFolders;
[self _setupContext];
request = [context request];
expandedFolders = [request formValueForKey: @"expandedFolders"];
[moduleSettings setObject: expandedFolders
forKey: @"ExpandedFolders"];
[ud synchronize];
return [self responseWithStatus: 204];
}
@end /* UIxMailMainFrame */

View file

@ -328,7 +328,17 @@
compose = {
protectedBy = "View";
pageName = "UIxMailMainFrame";
actionName = "compose";
actionName = "compose";
};
foldersState = {
protectedBy = "View";
pageName = "UIxMailMainFrame";
actionName = "getFoldersState";
};
saveFoldersState = {
protectedBy = "View";
pageName = "UIxMailMainFrame";
actionName = "saveFoldersState";
};
};
};

View file

@ -29,8 +29,31 @@ var MailerUIdTreeExtension = {
this._addFolder(thisCounter, folder.children[i]);
},
addMailAccount: function (mailAccount) {
this._addFolder(0, mailAccount);
}
this._addFolder(0, mailAccount);
},
setCookie: function(cookieName, cookieValue, expires, path, domain, secure) {
},
getCookie: function(cookieName) {
return ("");
},
updateCookie: function () {
if (Mailer.foldersStateTimer)
clearTimeout(Mailer.foldersStateTimer);
Mailer.foldersStateTimer = setTimeout('saveFoldersState()', 3000); // 3 seconds
},
getFoldersState: function () {
var expandedFolders = new Array();
for (var n = 0; n < this.aNodes.length; n++) {
if (this.aNodes[n]._io && this.aNodes[n].pid != this.root.id) {
expandedFolders.push(this.aNodes[n].dataname);
}
}
return expandedFolders.toJSON();
},
autoSync: function() {
this.config.useCookies = true;
}
};
Object.extend(dTree.prototype, MailerUIdTreeExtension);

View file

@ -14,7 +14,8 @@ var Mailer = {
currentMailboxType: "",
currentMessages: {},
maxCachedMessages: 20,
cachedMessages: new Array()
cachedMessages: new Array(),
foldersStateTimer: false
};
var usersRightsWindowHeight = 320;
@ -1254,7 +1255,7 @@ function initMailer(event) {
initMailboxTree();
initMessageCheckTimer();
}
// Default sort options
sorting["attribute"] = "date";
sorting["ascending"] = false;
@ -1434,6 +1435,7 @@ function onLoadMailboxesCallback(http) {
updateMailboxTreeInPage();
updateMailboxMenus();
checkAjaxRequestsState();
getFoldersState();
}
}
}
@ -1482,6 +1484,45 @@ function buildMailboxes(accountName, encoded) {
return account;
}
function getFoldersState() {
if (mailAccounts.length > 0) {
var urlstr = ApplicationBaseURL + "foldersState";
triggerAjaxRequest(urlstr, getFoldersStateCallback);
}
}
function getFoldersStateCallback(http) {
if (http.readyState == 4
&& http.status == 200) {
if (http.responseText.length > 0) {
// The response text is a JSOn representation
// of the folders that were left opened.
var data = http.responseText.evalJSON(true);
for (var i = 1; i < mailboxTree.aNodes.length; i++) {
if ($(data).indexOf(mailboxTree.aNodes[i].dataname) > 0)
// If the folder is found, open it
mailboxTree.o(i);
}
}
}
mailboxTree.autoSync();
}
function saveFoldersState() {
if (mailAccounts.length > 0) {
var foldersState = mailboxTree.getFoldersState();
var urlstr = ApplicationBaseURL + "saveFoldersState" + "?expandedFolders=" + foldersState;
triggerAjaxRequest(urlstr, saveFoldersStateCallback);
}
}
function saveFoldersStateCallback(http) {
if (http.readyState == 4
&& isHttpStatus204(http.status)) {
log ("folders state saved");
}
}
function onMenuCreateFolder(event) {
var name = window.prompt(labels["Name :"], "");
if (name && name.length > 0) {