+2008-02-01 Wolfgang Sourdeau <wsourdeau@inverse.ca>
+
+ * UI/MailerUI/UIxMailMainFrame.m ([UIxMailMainFrame
+ -quotaSupport]): new json string that lists the quota support
+ among the user's mail accounts.
+
+ * SoObjects/Mailer/SOGoMailAccount.m ([SOGoMailAccount
+ -supportsQuotas]): new method that returns whether the current
+ account server has support for quotas.
+
2008-01-29 Wolfgang Sourdeau <wsourdeau@inverse.ca>
* SoObjects/SOGo/SOGoGCSFolder.m ([SOGoGCSFolder
SOGoTrashFolder *trashFolder;
}
+- (BOOL) supportsQuotas;
+
/* folder pathes */
- (NSArray *) allFolderPaths;
#import <NGExtensions/NSObject+Logs.h>
#import <NGExtensions/NSNull+misc.h>
#import <NGImap4/NGImap4Connection.h>
+#import <NGImap4/NGImap4Client.h>
+#import <NGImap4/NGImap4Context.h>
#import <SoObjects/SOGo/NSArray+Utilities.h>
#import <SoObjects/SOGo/SOGoUser.h>
return folders;
}
+- (BOOL) supportsQuotas
+{
+ NGImap4Client *imapClient;
+
+ imapClient = [[self imap4Connection] client];
+
+ return [[imapClient context] canQuota];
+}
+
/* hierarchy */
- (SOGoMailAccount *) mailAccountFolder
@interface SOGoMailAccounts : SOGoFolder
+- (NSArray *) toManyRelationshipKeys;
+
@end
#endif /* __Mailer_SOGoMailAccounts_H__ */
}
ct = [[ctClass alloc] initWithName:_key inContainer:self];
+
return [ct autorelease];
}
NSUserDefaults *ud;
NSMutableDictionary *moduleSettings;
}
+
+- (WOResponse *) getDragHandlesStateAction;
+- (WOResponse *) getFoldersStateAction;
+
+- (WOResponse *) saveDragHandlesStateAction;
+- (WOResponse *) saveFoldersStateAction;
+
@end
#endif /* UIXMAILMAINFRAME_H */
*/
#import <Foundation/NSUserDefaults.h>
+#import <Foundation/NSValue.h>
#import <NGObjWeb/WOContext.h>
#import <NGObjWeb/WORequest.h>
#import <NGExtensions/NSString+misc.h>
#import <SoObjects/Mailer/SOGoMailObject.h>
+#import <SoObjects/Mailer/SOGoMailAccount.h>
#import <SoObjects/Mailer/SOGoMailAccounts.h>
#import <SoObjects/SOGo/NSDictionary+URL.h>
#import <SoObjects/SOGo/NSArray+Utilities.h>
return [accountNames jsonRepresentation];
}
+- (NSString *) quotaSupport
+{
+ NSEnumerator *accountNames;
+ NSMutableArray *quotas;
+ NSString *currentAccount;
+ SOGoMailAccounts *co;
+ BOOL supportsQuota;
+
+ co = [self clientObject];
+ accountNames = [[co toManyRelationshipKeys] objectEnumerator];
+
+ quotas = [NSMutableArray array];
+ while ((currentAccount = [accountNames nextObject]))
+ {
+ supportsQuota = [[co lookupName: currentAccount
+ inContext: context
+ acquire: NO] supportsQuotas];
+ [quotas addObject: [NSNumber numberWithInt: supportsQuota]];
+ }
+
+ return [quotas jsonRepresentation];
+}
+
- (NSString *) pageFormURL
{
NSString *u;
accounts = [[context activeUser] mailAccounts];
firstAccount = [[accounts objectsForKey: @"name"] objectAtIndex: 0];
formValues = [[context request] formValues];
- parameters = [formValues count] > 0 ? [formValues asURLParameters] : @"?mailto=";
+ parameters = ([formValues count] > 0
+ ? [formValues asURLParameters]
+ : @"?mailto=");
newLocation = [NSString stringWithFormat: @"%@/%@/compose%@",
[co baseURLInContext: context],
firstAccount,
return [self redirectToLocation: newLocation];
}
+- (WOResponse *) getDragHandlesStateAction
+{
+ NSString *dragHandles;
+
+ [self _setupContext];
+ dragHandles = [moduleSettings objectForKey: @"DragHandles"];
+
+ return [self responseWithStatus: 200 andString: dragHandles];
+}
+
- (WOResponse *) getFoldersStateAction
{
NSString *expandedFolders;
return [self responseWithStatus: 200 andString: expandedFolders];
}
+- (WOResponse *) saveDragHandlesStateAction
+{
+ WORequest *request;
+ NSString *dragHandles;
+
+ [self _setupContext];
+ request = [context request];
+ dragHandles = [request formValueForKey: @"dragHandles"];
+
+ [moduleSettings setObject: dragHandles
+ forKey: @"DragHandles"];
+
+ [ud synchronize];
+
+ return [self responseWithStatus: 204];
+}
+
- (WOResponse *) saveFoldersStateAction
{
WORequest *request;
pageName = "UIxMailMainFrame";
actionName = "compose";
};
+ dragHandlesState = {
+ protectedBy = "View";
+ pageName = "UIxMailMainFrame";
+ actionName = "getDragHandlesState";
+ };
foldersState = {
protectedBy = "View";
pageName = "UIxMailMainFrame";
actionName = "getFoldersState";
};
+ saveDragHandlesState = {
+ protectedBy = "View";
+ pageName = "UIxMailMainFrame";
+ actionName = "saveDragHandlesState";
+ };
saveFoldersState = {
protectedBy = "View";
pageName = "UIxMailMainFrame";
const:jsFiles="dtree.js,MailerUI+dTree.js">
<script type="text/javascript">
var textMailAccounts = '<var:string value="mailAccounts" const:escapeHTML="NO"/>';
+ var textQuotaSupport = '<var:string value="quotaSupport" const:escapeHTML="NO"/>';
</script>
<div class="menu" id="accountIconMenu">
<ul>
}
}
+function saveDragHandlesState() {
+ // Call from SOGoDragHandles.js
+}
+
function onMenuSharing(event) {
if ($(this).hasClassName("disabled"))
return;
var accounts = {};
var mailboxTree;
var mailAccounts;
+var quotaSupport;
if (typeof textMailAccounts != 'undefined') {
if (textMailAccounts.length > 0)
mailAccounts = textMailAccounts.evalJSON(true);
else
mailAccounts = new Array();
}
+if (typeof textQuotaSupport != 'undefined') {
+ if (textQuotaSupport.length > 0)
+ quotaSupport = textQuotaSupport.evalJSON(true);
+ else
+ quotaSupport = new Array();
+}
var Mailer = {
currentMailbox: null,
}
function mailListMarkMessageCallback(http) {
- if (http.readyState == 4)
- if (isHttpStatus204(http.status)) {
- var data = http.callbackData;
- markMailInWindow(data["window"], data["msguid"], data["markread"]);
- }
- else {
- alert("Message Mark Failed (" + http.status + "): " + http.statusText);
- window.location.reload();
- }
+ if (isHttpStatus204(http.status)) {
+ var data = http.callbackData;
+ markMailInWindow(data["window"], data["msguid"], data["markread"]);
+ }
+ else {
+ alert("Message Mark Failed (" + http.status + "): " + http.statusText);
+ window.location.reload();
+ }
}
/* maillist row highlight */
}
function deleteSelectedMessagesCallback(http) {
- if (http.readyState == 4) {
- if (isHttpStatus204(http.status)) {
- var data = http.callbackData;
- deleteCachedMessage(data["messageId"]);
- deleteMessageRequestCount--;
- if (Mailer.currentMailbox == data["mailbox"]) {
- var div = $('messageContent');
- if (Mailer.currentMessages[Mailer.currentMailbox] == data["id"]) {
- div.update();
- Mailer.currentMessages[Mailer.currentMailbox] = null;
- }
+ if (isHttpStatus204(http.status)) {
+ var data = http.callbackData;
+ deleteCachedMessage(data["messageId"]);
+ deleteMessageRequestCount--;
+ if (Mailer.currentMailbox == data["mailbox"]) {
+ var div = $('messageContent');
+ if (Mailer.currentMessages[Mailer.currentMailbox] == data["id"]) {
+ div.update();
+ Mailer.currentMessages[Mailer.currentMailbox] = null;
+ }
- var row = $("row_" + data["id"]);
- var nextRow = row.next("tr");
- if (!nextRow)
- nextRow = row.previous("tr");
- row.parentNode.removeChild(row);
+ var row = $("row_" + data["id"]);
+ var nextRow = row.next("tr");
+ if (!nextRow)
+ nextRow = row.previous("tr");
+ row.parentNode.removeChild(row);
// row.addClassName("deleted"); // when we'll offer "mark as deleted"
- if (deleteMessageRequestCount == 0) {
- if (nextRow) {
- Mailer.currentMessages[Mailer.currentMailbox] = nextRow.getAttribute("id").substr(4);
- nextRow.select();
- loadMessage(Mailer.currentMessages[Mailer.currentMailbox]);
- }
+ if (deleteMessageRequestCount == 0) {
+ if (nextRow) {
+ Mailer.currentMessages[Mailer.currentMailbox] = nextRow.getAttribute("id").substr(4);
+ nextRow.select();
+ loadMessage(Mailer.currentMessages[Mailer.currentMailbox]);
}
}
}
= triggerAjaxRequest(url, messageListCallback,
currentMessage);
- var quotasUrl = ApplicationBaseURL + mailbox + "/quotas";
- document.quotasAjaxRequest
- = triggerAjaxRequest(quotasUrl, quotasCallback);
+ var account = Mailer.currentMailbox.split("/")[1];
+ if (accounts[account].supportsQuotas) {
+ var quotasUrl = ApplicationBaseURL + mailbox + "/quotas";
+ triggerAjaxRequest(quotasUrl, quotasCallback);
+ }
}
}
var div = $('mailboxContent');
var table = $('messageList');
- if (http.readyState == 4
- && http.status == 200) {
+ if (http.status == 200) {
document.messageListAjaxRequest = null;
if (table) {
}
function quotasCallback(http) {
- if (http.readyState == 4
- && http.status == 200) {
+ if (http.status == 200) {
var hasQuotas = false;
if (http.responseText.length > 0) {
function onFolderMenuClick(event) {
var onhide, menuName;
-
+
var menutype = this.parentNode.getAttribute("datatype");
if (menutype) {
if (menutype == "inbox") {
}
function ICalendarButtonCallback(http) {
- if (http.readyState == 4)
- if (isHttpStatus204(http.status)) {
- var oldMsg = http.callbackData;
- var msg = Mailer.currentMailbox + "/" + Mailer.currentMessages[Mailer.currentMailbox];
- if (oldMsg == msg) {
- deleteCachedMessage(oldMsg);
- loadMessage(Mailer.currentMessages[Mailer.currentMailbox]);
- }
- }
- else {
- window.alert("received code: " + http.status);
+ if (isHttpStatus204(http.status)) {
+ var oldMsg = http.callbackData;
+ var msg = Mailer.currentMailbox + "/" + Mailer.currentMessages[Mailer.currentMailbox];
+ if (oldMsg == msg) {
+ deleteCachedMessage(oldMsg);
+ loadMessage(Mailer.currentMessages[Mailer.currentMailbox]);
}
+ }
+ else
+ window.alert("received code: " + http.status);
}
function resizeMailContent() {
function messageCallback(http) {
var div = $('messageContent');
- if (http.readyState == 4
- && http.status == 200) {
+ if (http.status == 200) {
document.messageAjaxRequest = null;
div.update(http.responseText);
configureLinksInMessage();
if ($(cell).hasClassName("tbtv_navcell")) {
var anchors = $(cell).childNodesWithTag("a");
for (var i = 0; i < anchors.length; i++)
- Event.observe(anchors[i], "click", openMailboxAtIndex.bindAsEventListener(anchors[i]));
+ Event.observe(anchors[i], "click",
+ openMailboxAtIndex.bindAsEventListener(anchors[i]));
}
rows = table.tBodies[0].rows;
// initDnd();
initMailboxTree();
initMessageCheckTimer();
+ getDragHandlesState();
}
// Default sort options
}
function onLoadMailboxesCallback(http) {
- if (http.readyState == 4
- && http.status == 200) {
+ if (http.status == 200) {
checkAjaxRequestsState();
if (http.responseText.length > 0) {
var newAccount = buildMailboxes(http.callbackData,
function buildMailboxes(accountName, encoded) {
var account = new Mailbox("account", accountName);
+
+ var accountIndex = mailAccounts.indexOf(accountName);
+ account.supportsQuotas = (quotaSupport[accountIndex] != 0);
+
var data = encoded.evalJSON(true);
for (var i = 0; i < data.length; i++) {
var currentNode = account;
return account;
}
+function getDragHandlesState() {
+ var urlstr = ApplicationBaseURL + "dragHandlesState";
+ triggerAjaxRequest(urlstr, getDragHandlesStateCallback);
+}
+
+function getDragHandlesStateCallback(http) {
+ if (http.status == 200) {
+ if (http.responseText.length > 0) {
+ // The response text is a JSON array
+ // of the right and top offsets.
+ var data = http.responseText.evalJSON(true);
+
+ $("leftPanel").setStyle({ width: data[0] });
+ $("rightPanel").setStyle({ left: data[0] });
+ $("verticalDragHandle").setStyle({ left: data[0] });
+ $("mailboxContent").setStyle({ height: data[1] });
+ $("messageContent").setStyle({ top: data[1] });
+ $("rightDragHandle").setStyle({ top: data[1] });
+ }
+ }
+}
+
function getFoldersState() {
if (mailAccounts.length > 0) {
var urlstr = ApplicationBaseURL + "foldersState";
}
function getFoldersStateCallback(http) {
- if (http.readyState == 4
- && http.status == 200) {
+ if (http.status == 200) {
if (http.responseText.length > 0) {
- // The response text is a JSOn representation
+ // The response text is a JSON array
// of the folders that were left opened.
var data = http.responseText.evalJSON(true);
for (var i = 1; i < mailboxTree.aNodes.length; i++) {
mailboxTree.o(i);
}
}
+ mailboxTree.autoSync();
+ }
+}
+
+function saveDragHandlesState() {
+ // Call from SOGoDragHandles.js
+ var leftBlock = $("leftPanel");
+ var upperBlock = $("mailboxContent");
+
+ if (leftBlock && upperBlock) {
+ var dragHandlesState = new Array(leftBlock.getStyle("width"),
+ upperBlock.getStyle("height"));
+ var urlstr = ApplicationBaseURL + "saveDragHandlesState" + "?dragHandles=" + dragHandlesState.toJSON();
+ triggerAjaxRequest(urlstr, saveDragHandlesStateCallback);
+ }
+}
+
+function saveDragHandlesStateCallback(http) {
+ if (http.readyState == 4
+ && isHttpStatus204(http.status)) {
+ log ("drag handles state saved");
}
- mailboxTree.autoSync();
}
function saveFoldersState() {
}
function saveFoldersStateCallback(http) {
- if (http.readyState == 4
- && isHttpStatus204(http.status)) {
+ if (isHttpStatus204(http.status)) {
log ("folders state saved");
}
}
document.body.setAttribute('style', '');
Event.stop(event);
+
+ saveDragHandlesState();
},
move: function (event) {
if (!this.dhType)
log ("ajax problem 5: " + http.status);
}
+function saveDragHandlesState() {
+ // Call from SOGoDragHandles.js
+}
+
function configureLists() {
var list = $("tasksList");
list.multiselect = true;
}
var sd = $('startTime_date').valueAsShortDateString();
var ed = $('endTime_date').valueAsShortDateString();
- var urlstr = ( UserFolderURL + "../" + input.uid + "/freebusy.ifb/ajaxRead?"
+ var urlstr = ( UserFolderURL + "../" + input.uid
+ + "/freebusy.ifb/ajaxRead?"
+ "sday=" + sd + "&eday=" + ed + "&additional=" +
additionalDays );
document.contactFreeBusyAjaxRequest
$(row).addClassName(attendeesEditor.states[i]);
var input = $(row).down("input");
var value = "";
- if (attendeesEditor.names[i].length > 0 && attendeesEditor.names[i] != attendeesEditor.emails[i])
+ if (attendeesEditor.names[i].length > 0
+ && attendeesEditor.names[i] != attendeesEditor.emails[i])
value += attendeesEditor.names[i] + " ";
value += "<" + attendeesEditor.emails[i] + ">";
input.value = value;
attendeesEditor.names = new Array();
attendeesEditor.UIDs = new Array();
attendeesEditor.emails = new Array();
+ newAttendee(null);
}
var inputs = tableAttendees.getElementsByTagName("input");
return url_nocache;
}
+function onAjaxRequestStateChange(http) {
+ try {
+ if (http.readyState == 4
+ && activeAjaxRequests > 0) {
+ if (!http.aborted)
+ http.callback(http);
+ activeAjaxRequests--;
+ checkAjaxRequestsState();
+ http.onreadystatechange = Prototype.emptyFunction;
+ http.callback = Prototype.emptyFunction;
+ http.callbackData = null;
+ }
+ }
+ catch (e) {
+ activeAjaxRequests--;
+ checkAjaxRequestsState();
+ http.onreadystatechange = Prototype.emptyFunction;
+ http.callback = Prototype.emptyFunction;
+ http.callbackData = null;
+ log("AJAX Request, Caught Exception: " + e.name);
+ log(e.message);
+ log(backtrace());
+ }
+}
+
function triggerAjaxRequest(url, callback, userdata, content, headers) {
var http = createHTTPClient();
- activeAjaxRequests += 1;
- document.animTimer = setTimeout("checkAjaxRequestsState();", 50);
+ activeAjaxRequests++;
+ document.animTimer = setTimeout("checkAjaxRequestsState();", 250);
//url = appendDifferentiator(url);
if (http) {
http.open("POST", url, true);
http.url = url;
- http.onreadystatechange
- = function() {
-// log ("state changed (" + http.readyState + "): " + url);
- try {
- if (http.readyState == 4
- && activeAjaxRequests > 0) {
- if (!http.aborted) {
- if (userdata)
- http.callbackData = userdata;
- callback(http);
- }
- activeAjaxRequests -= 1;
- checkAjaxRequestsState();
- }
- }
- catch (e) {
- activeAjaxRequests -= 1;
- checkAjaxRequestsState();
- log("AJAX Request, Caught Exception: " + e.name);
- log(e.message);
- log(backtrace());
- }
- };
+ http.callback = callback;
+ http.callbackData = userdata;
+ http.onreadystatechange = function() { onAjaxRequestStateChange(http) };
+// = function() {
+// // log ("state changed (" + http.readyState + "): " + url);
+// };
var hasContentLength = false;
if (headers) {
for (var i in headers) {
function startAnimation(parent, nextNode) {
var anim = $("progressIndicator");
- if (anim) return anim;
-
- anim = document.createElement("img");
- anim = $(anim);
- anim.id = "progressIndicator";
- anim.src = ResourcesURL + "/busy.gif";
- anim.setStyle({ visibility: "hidden" });
- if (nextNode)
- parent.insertBefore(anim, nextNode);
- else
- parent.appendChild(anim);
- anim.setStyle({ visibility: "visible" });
+ if (!anim) {
+ anim = createElement("img", "progressIndicator", null,
+ {src: ResourcesURL + "/busy.gif"});
+ anim.setStyle({ visibility: "hidden" });
+ if (nextNode)
+ parent.insertBefore(anim, nextNode);
+ else
+ parent.appendChild(anim);
+ anim.setStyle({ visibility: "visible" });
+ }
return anim;
}
function checkAjaxRequestsState() {
- var toolbar = document.getElementById("toolbar");
- if (toolbar) {
- if (activeAjaxRequests > 0
- && !document.busyAnim) {
- document.busyAnim = startAnimation(toolbar);
- }
- else if (activeAjaxRequests == 0
- && document.busyAnim
- && document.busyAnim.parentNode) {
- document.busyAnim.parentNode.removeChild(document.busyAnim);
- document.busyAnim = null;
- }
+ var progressImage = $("progressIndicator");
+ if (activeAjaxRequests > 0
+ && !progressImage) {
+ var toolbar = $("toolbar");
+ if (toolbar)
+ startAnimation(toolbar);
}
+ else if (!activeAjaxRequests
+ && progressImage)
+ progressImage.parentNode.removeChild(progressImage);
}
function isSafari3() {