From 6951e6a527411ac19b1e4a461a2a12a08be1bf69 Mon Sep 17 00:00:00 2001 From: Wolfgang Sourdeau Date: Fri, 1 Feb 2008 15:49:33 +0000 Subject: [PATCH 1/2] Monotone-Parent: d07959b964a2582bf5674d383b0dac7303346571 Monotone-Revision: 0bf13271077dfd22aaca8a2663fe7490f9d84cb3 Monotone-Author: wsourdeau@inverse.ca Monotone-Date: 2008-02-01T15:49:33 Monotone-Branch: ca.inverse.sogo --- UI/WebServerResources/MailerUI.js | 102 +++++++++----------- UI/WebServerResources/UIxAttendeesEditor.js | 6 +- UI/WebServerResources/generic.js | 101 +++++++++---------- 3 files changed, 101 insertions(+), 108 deletions(-) diff --git a/UI/WebServerResources/MailerUI.js b/UI/WebServerResources/MailerUI.js index 9604045a4..a86f3d554 100644 --- a/UI/WebServerResources/MailerUI.js +++ b/UI/WebServerResources/MailerUI.js @@ -179,15 +179,14 @@ function mailListMarkMessage(event) { } 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 */ @@ -235,31 +234,29 @@ function deleteSelectedMessages(sender) { } 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]); } } } @@ -488,8 +485,7 @@ function openMailbox(mailbox, reload, idx) { currentMessage); var quotasUrl = ApplicationBaseURL + mailbox + "/quotas"; - document.quotasAjaxRequest - = triggerAjaxRequest(quotasUrl, quotasCallback); + triggerAjaxRequest(quotasUrl, quotasCallback); } } @@ -503,8 +499,7 @@ function messageListCallback(http) { var div = $('mailboxContent'); var table = $('messageList'); - if (http.readyState == 4 - && http.status == 200) { + if (http.status == 200) { document.messageListAjaxRequest = null; if (table) { @@ -571,8 +566,7 @@ function messageListCallback(http) { } function quotasCallback(http) { - if (http.readyState == 4 - && http.status == 200) { + if (http.status == 200) { var hasQuotas = false; if (http.responseText.length > 0) { @@ -822,18 +816,16 @@ function onICalendarButtonClick(event) { } 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() { @@ -878,8 +870,7 @@ function onImageClick(event) { 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(); @@ -1418,8 +1409,7 @@ function updateMailboxMenus() { } 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, @@ -1489,8 +1479,7 @@ function getFoldersState() { } 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 // of the folders that were left opened. @@ -1501,8 +1490,8 @@ function getFoldersStateCallback(http) { mailboxTree.o(i); } } + mailboxTree.autoSync(); } - mailboxTree.autoSync(); } function saveFoldersState() { @@ -1514,8 +1503,7 @@ function saveFoldersState() { } function saveFoldersStateCallback(http) { - if (http.readyState == 4 - && isHttpStatus204(http.status)) { + if (isHttpStatus204(http.status)) { log ("folders state saved"); } } diff --git a/UI/WebServerResources/UIxAttendeesEditor.js b/UI/WebServerResources/UIxAttendeesEditor.js index 21b4ae462..e7fe2a3a7 100644 --- a/UI/WebServerResources/UIxAttendeesEditor.js +++ b/UI/WebServerResources/UIxAttendeesEditor.js @@ -322,7 +322,8 @@ function displayFreeBusyForNode(input) { } 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 @@ -601,7 +602,8 @@ function prepareAttendees() { $(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; diff --git a/UI/WebServerResources/generic.js b/UI/WebServerResources/generic.js index 98b92030a..d25ea6670 100644 --- a/UI/WebServerResources/generic.js +++ b/UI/WebServerResources/generic.js @@ -309,39 +309,47 @@ function appendDifferentiator(url) { 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) { @@ -367,36 +375,31 @@ function triggerAjaxRequest(url, callback, userdata, content, 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() { From c6b8cb5a1cacfc72662845f38b01f5f340c566bb Mon Sep 17 00:00:00 2001 From: Wolfgang Sourdeau Date: Fri, 1 Feb 2008 16:28:53 +0000 Subject: [PATCH 2/2] Monotone-Parent: 0bf13271077dfd22aaca8a2663fe7490f9d84cb3 Monotone-Revision: a216f87669942e793f9124b63661a5ae82105c1d Monotone-Author: wsourdeau@inverse.ca Monotone-Date: 2008-02-01T16:28:53 Monotone-Branch: ca.inverse.sogo --- ChangeLog | 10 ++++++++ SoObjects/Mailer/SOGoMailAccount.h | 2 ++ SoObjects/Mailer/SOGoMailAccount.m | 11 ++++++++ SoObjects/Mailer/SOGoMailAccounts.h | 2 ++ SoObjects/Mailer/SOGoMailAccounts.m | 1 + UI/MailerUI/UIxMailMainFrame.m | 29 +++++++++++++++++++++- UI/Templates/MailerUI/UIxMailMainFrame.wox | 1 + UI/WebServerResources/MailerUI.js | 23 ++++++++++++++--- 8 files changed, 74 insertions(+), 5 deletions(-) diff --git a/ChangeLog b/ChangeLog index b492fefdf..f9f799d1e 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,13 @@ +2008-02-01 Wolfgang Sourdeau + + * 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 * SoObjects/SOGo/SOGoGCSFolder.m ([SOGoGCSFolder diff --git a/SoObjects/Mailer/SOGoMailAccount.h b/SoObjects/Mailer/SOGoMailAccount.h index 8c720e1f1..e907d8cdb 100644 --- a/SoObjects/Mailer/SOGoMailAccount.h +++ b/SoObjects/Mailer/SOGoMailAccount.h @@ -48,6 +48,8 @@ SOGoTrashFolder *trashFolder; } +- (BOOL) supportsQuotas; + /* folder pathes */ - (NSArray *) allFolderPaths; diff --git a/SoObjects/Mailer/SOGoMailAccount.m b/SoObjects/Mailer/SOGoMailAccount.m index 4f2f59110..8b3559860 100644 --- a/SoObjects/Mailer/SOGoMailAccount.m +++ b/SoObjects/Mailer/SOGoMailAccount.m @@ -31,6 +31,8 @@ #import #import #import +#import +#import #import #import @@ -170,6 +172,15 @@ static NSString *otherUsersFolderName = @""; // TODO: add English default return folders; } +- (BOOL) supportsQuotas +{ + NGImap4Client *imapClient; + + imapClient = [[self imap4Connection] client]; + + return [[imapClient context] canQuota]; +} + /* hierarchy */ - (SOGoMailAccount *) mailAccountFolder diff --git a/SoObjects/Mailer/SOGoMailAccounts.h b/SoObjects/Mailer/SOGoMailAccounts.h index 623ffcb2f..afd7404cd 100644 --- a/SoObjects/Mailer/SOGoMailAccounts.h +++ b/SoObjects/Mailer/SOGoMailAccounts.h @@ -41,6 +41,8 @@ @interface SOGoMailAccounts : SOGoFolder +- (NSArray *) toManyRelationshipKeys; + @end #endif /* __Mailer_SOGoMailAccounts_H__ */ diff --git a/SoObjects/Mailer/SOGoMailAccounts.m b/SoObjects/Mailer/SOGoMailAccounts.m index 515c66523..3188052ca 100644 --- a/SoObjects/Mailer/SOGoMailAccounts.m +++ b/SoObjects/Mailer/SOGoMailAccounts.m @@ -76,6 +76,7 @@ static NSString *AgenorShareLoginMarker = @".-."; } ct = [[ctClass alloc] initWithName:_key inContainer:self]; + return [ct autorelease]; } diff --git a/UI/MailerUI/UIxMailMainFrame.m b/UI/MailerUI/UIxMailMainFrame.m index e45d9d301..10e0a8f06 100644 --- a/UI/MailerUI/UIxMailMainFrame.m +++ b/UI/MailerUI/UIxMailMainFrame.m @@ -20,6 +20,7 @@ */ #import +#import #import #import @@ -28,6 +29,7 @@ #import #import +#import #import #import #import @@ -71,6 +73,29 @@ 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; @@ -127,7 +152,9 @@ 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, diff --git a/UI/Templates/MailerUI/UIxMailMainFrame.wox b/UI/Templates/MailerUI/UIxMailMainFrame.wox index 355c89998..cd847feba 100644 --- a/UI/Templates/MailerUI/UIxMailMainFrame.wox +++ b/UI/Templates/MailerUI/UIxMailMainFrame.wox @@ -10,6 +10,7 @@ const:jsFiles="dtree.js,MailerUI+dTree.js">