diff --git a/ChangeLog b/ChangeLog index 607614a8d..2b35e8087 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2007-07-11 Wolfgang Sourdeau + + * UI/MailerUI/UIxMailFolderActions.m ([UIxMailFolderActions + -quotasAction]): new method that returns a json representation of + the mailbox quotas. + 2007-07-10 Wolfgang Sourdeau * SoObjects/Mailer/SOGoMailBaseObject.m ([SOGoMailBaseObject diff --git a/NEWS b/NEWS index e003261cc..9f170c71d 100644 --- a/NEWS +++ b/NEWS @@ -3,14 +3,16 @@ - added the ability to specify a super user through the SOGoSuperUsername user default; - added the ability to view the message source; -- no longer autocreate folders if we are not their owners; +- don't autocreate folders if we are not their owners; - made compatible with PostgreSQL 8.2; - the months and years menus of the date selector would no longer appear; - fixed a bug which would produce task SQL records which would violate non-null constraints on the quick calendar tables; +- the tasks due date was wrongly set because of a change in the API; - it was impossible to reset the start and the due date in the task editor whenever they were set once; - imap folders with non-ascii characters are now correctly accessed; +- display the quotas of the selected mailbox on servers that support quotas; Local variables: mode: text diff --git a/SoObjects/Contacts/common.h b/SoObjects/Contacts/common.h index 1726b97cf..475935b2d 100644 --- a/SoObjects/Contacts/common.h +++ b/SoObjects/Contacts/common.h @@ -18,7 +18,7 @@ Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ -// $Id: common.h 577 2005-02-17 14:38:14Z helge $ +// $Id: common.h 1101 2007-07-10 19:27:48Z wolfgang $ #import diff --git a/UI/Contacts/common.h b/UI/Contacts/common.h index 48d9932d0..6cb44dd7b 100644 --- a/UI/Contacts/common.h +++ b/UI/Contacts/common.h @@ -18,7 +18,7 @@ Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ -// $Id: common.h 269 2004-08-25 16:06:10Z znek $ +// $Id: common.h 1101 2007-07-10 19:27:48Z wolfgang $ #import diff --git a/UI/MailerUI/English.lproj/Localizable.strings b/UI/MailerUI/English.lproj/Localizable.strings index 26912cf69..e00c4c37a 100644 --- a/UI/MailerUI/English.lproj/Localizable.strings +++ b/UI/MailerUI/English.lproj/Localizable.strings @@ -126,3 +126,5 @@ "Do you really want to move this folder into the trash ?" = "Do you really want to move this folder into the trash ?"; "Operation failed" = "Operation failed"; + +"quotasFormat" = "Quotas: %{0} used on %{1} Kb; %{2}%"; diff --git a/UI/MailerUI/French.lproj/Localizable.strings b/UI/MailerUI/French.lproj/Localizable.strings index b3c4aaf4e..eb928182f 100644 --- a/UI/MailerUI/French.lproj/Localizable.strings +++ b/UI/MailerUI/French.lproj/Localizable.strings @@ -176,3 +176,5 @@ "Do you really want to move this folder into the trash ?" = "Voulez-vous vraiment déplacer le dossier sélectionné dans la corbeille?"; "Operation failed" = "L'opération a échoué."; + +"quotasFormat" = "Quotas: %{0} Ko utilisés sur %{1}; %{2}%"; diff --git a/UI/MailerUI/UIxMailFolderActions.m b/UI/MailerUI/UIxMailFolderActions.m index 8f971f53a..52b9d3563 100644 --- a/UI/MailerUI/UIxMailFolderActions.m +++ b/UI/MailerUI/UIxMailFolderActions.m @@ -29,10 +29,12 @@ #import #import #import +#import #import #import #import +#import #import "UIxMailFolderActions.h" @@ -249,4 +251,29 @@ return [self _subscriptionStubAction]; } +- (WOResponse *) quotasAction +{ + SOGoMailFolder *folder; + NSURL *folderURL; + id infos; + WOResponse *response; + NGImap4Client *client; + NSString *responseString; + + response = [context response]; + [response setStatus: 200]; + [response setHeader: @"text/plain; charset=UTF-8" + forKey: @"content-type"]; + + folder = [self clientObject]; + folderURL = [folder imap4URL]; + + client = [[folder imap4Connection] client]; + infos = [client getQuotaRoot: [folder nameInContainer]]; + responseString = [[infos objectForKey: @"quotas"] jsonRepresentation]; + [response appendContentString: responseString]; + + return response; +} + @end diff --git a/UI/MailerUI/product.plist b/UI/MailerUI/product.plist index 32f6c3eb7..6746f77a8 100644 --- a/UI/MailerUI/product.plist +++ b/UI/MailerUI/product.plist @@ -95,6 +95,11 @@ categories = { actionClass = "UIxMailFolderActions"; actionName = "unsubscribe"; }; + quotas = { + protectedBy = "View"; + actionClass = "UIxMailFolderActions"; + actionName = "quotas"; + }; view = { protectedBy = "View"; pageName = "UIxMailListView"; diff --git a/UI/MainUI/common.h b/UI/MainUI/common.h index 31ebcf927..41b1b5939 100644 --- a/UI/MainUI/common.h +++ b/UI/MainUI/common.h @@ -18,7 +18,7 @@ Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ -// $Id: common.h 91 2004-06-30 07:48:53Z helge $ +// $Id: common.h 1101 2007-07-10 19:27:48Z wolfgang $ #import diff --git a/UI/Scheduler/common.h b/UI/Scheduler/common.h index 6510c2ea2..80c19bf13 100644 --- a/UI/Scheduler/common.h +++ b/UI/Scheduler/common.h @@ -18,7 +18,7 @@ Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ -// $Id: common.h 181 2004-08-11 15:13:25Z helge $ +// $Id: common.h 1101 2007-07-10 19:27:48Z wolfgang $ #import diff --git a/UI/WebServerResources/JavascriptAPIExtensions.js b/UI/WebServerResources/JavascriptAPIExtensions.js index 7cdc85ec0..cc07602a6 100644 --- a/UI/WebServerResources/JavascriptAPIExtensions.js +++ b/UI/WebServerResources/JavascriptAPIExtensions.js @@ -2,6 +2,15 @@ String.prototype.trim = function() { return this.replace(/(^\s+|\s+$)/g, ''); } +String.prototype.formatted = function() { + var newString = this; + + for (var i = 0; i < arguments.length; i++) + newString = newString.replace("%{" + i + "}", arguments[i], "g"); + + return newString; +} + String.prototype.repeat = function(count) { var newString = ""; for (var i = 0; i < count; i++) { diff --git a/UI/WebServerResources/MailerUI.js b/UI/WebServerResources/MailerUI.js index 0534c65f3..434753d48 100644 --- a/UI/WebServerResources/MailerUI.js +++ b/UI/WebServerResources/MailerUI.js @@ -461,6 +461,10 @@ function openMailbox(mailbox, reload, idx) { document.messageListAjaxRequest = triggerAjaxRequest(url, messageListCallback, currentMessages[mailbox]); + + var quotasUrl = ApplicationBaseURL + mailbox + "/quotas"; + document.quotasAjaxRequest + = triggerAjaxRequest(quotasUrl, quotasCallback); } } @@ -509,6 +513,30 @@ function messageListCallback(http) { log("messageListCallback: problem during ajax request (readyState = " + http.readyState + ", status = " + http.status + ")"); } +function quotasCallback(http) { + if (http.readyState == 4 + && http.status == 200) { + var hasQuotas = false; + + var quotas = http.responseText.evalJSON(true); + for (var i in quotas) { + hasQuotas = true; + break; + } + + if (hasQuotas) { + var treePath = currentMailbox.split("/"); + var mbQuotas = quotas["/" + treePath[2]]; + var used = mbQuotas["usedSpace"]; + var max = mbQuotas["maxQuota"]; + var percents = (Math.round(used * 10000 / max) / 100); + var format = labels["quotasFormat"].decodeEntities(); + var text = format.formatted(used, max, percents); + window.status = text; + } + } +} + function onMessageContextMenu(event) { var menu = $('messageListMenu'); Event.observe(menu, "hideMenu", onMessageContextMenuHide); @@ -815,18 +843,6 @@ function onMenuViewMessageSource(event) { function newContactFromEmail(event) { var mailto = document.menuTarget.innerHTML; - // var emailre - // = /([a-zA-Z][\w\.-]*[a-zA-Z0-9]@[a-zA-Z0-9][\w\.-]*[a-zA-Z0-9]\.[a-zA-Z][a-zA-Z\.]*[a-zA-Z])/g; - // emailre.exec(mailto); - // email = RegExp.$1; - - // var namere = /(\w[\w\ _-]+)\ (<|<)/; - // var c_name = ''; - // if (namere.test(mailto)) { - // namere.exec(mailto); - // c_name += RegExp.$1; - // } - var email = extractEmailAddress(mailto); var c_name = extractEmailName(mailto); if (email.length > 0) @@ -841,7 +857,7 @@ function newContactFromEmail(event) { } return false; /* stop following the link */ - } +} function newEmailTo(sender) { return openMailTo(document.menuTarget.innerHTML);