Monotone-Parent: 18351673f3b02540c95a8695b70dd0067da408d5
Monotone-Revision: 36de46e421cb49879d5821734892284e4035c708 Monotone-Author: flachapelle@inverse.ca Monotone-Date: 2008-09-17T19:44:11 Monotone-Branch: ca.inverse.sogomaint-2.0.2
parent
bad7450a84
commit
52bcec0fea
|
@ -1,3 +1,9 @@
|
|||
2008-09-17 Francis Lachapelle <flachapelle@inverse.ca>
|
||||
|
||||
* UI/MailerUI/UIxMailAccountActions.m ([WOResponse
|
||||
-listMailboxesAction]): also returns the inbox quota, wrapped in a
|
||||
new dictionary with keys "mailboxes" and "quotas".
|
||||
|
||||
2008-09-17 Wolfgang Sourdeau <wsourdeau@inverse.ca>
|
||||
|
||||
* SoObjects/Mailer/SOGoMailObject.m ([SOGoMailObject
|
||||
|
|
|
@ -199,7 +199,8 @@
|
|||
= "Weet u zeker dat u deze map wilt verplaatsen naar de prullenbak";
|
||||
"Operation failed" = "Operatie mislukt.";
|
||||
|
||||
"quotasFormat" = "Quota: %{0} van %{1} KB gebruikt; %{2}%";
|
||||
"Quota" = "Quota";
|
||||
"quotasFormat" = "%{0} van %{1} KB gebruikt (%{2}%)";
|
||||
|
||||
"Please select a message." = "Selecteer een bericht.";
|
||||
"Please select a message to print." = "Selecteer een bericht om af te drukken.";
|
||||
|
|
|
@ -215,7 +215,8 @@
|
|||
= "Do you really want to move this folder into the trash ?";
|
||||
"Operation failed" = "Operation failed";
|
||||
|
||||
"quotasFormat" = "Quotas: %{0} used on %{1} Kb; %{2}%";
|
||||
"Quota" = "Quota";
|
||||
"quotasFormat" = "%{0} used on %{1} Kb (%{2}%)";
|
||||
|
||||
"Please select a message." = "Please select a message.";
|
||||
"Please select a message to print." = "Please select a message to print.";
|
||||
|
|
|
@ -216,7 +216,8 @@
|
|||
= "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}%";
|
||||
"Quota" = "Quota";
|
||||
"quotasFormat" = "%{0} Ko utilisés sur %{1} (%{2}%)";
|
||||
|
||||
"Please select a message." = "Veuillez sélectionner un message.";
|
||||
"Please select a message to print." = "Veuillez sélectionner un message à imprimer.";
|
||||
|
|
|
@ -198,7 +198,8 @@
|
|||
= "Wollen Sie diesen Ordner wirklich in den Papierkorb verschieben?";
|
||||
"Operation failed" = "L'opération a échoué.";
|
||||
|
||||
"quotasFormat" = "Quota: %{0} von %{1} KB verwendet; %{2}%";
|
||||
"Quota" = "Quota";
|
||||
"quotasFormat" = "%{0} von %{1} KB verwendet (%{2}%)";
|
||||
|
||||
"Please select a message." = "Sie müssen eine Nachricht auswählen.";
|
||||
"Please select a message to print." = "Sie müssen eine Nachricht zum Drucken auswählen.";
|
||||
|
|
|
@ -222,7 +222,8 @@
|
|||
= "Sei sicuro di voler spostare la cartella nel cestino ?";
|
||||
"Operation failed" = "Operazione non riuscita";
|
||||
|
||||
"quotasFormat" = "Spazio usato: %{0} su %{1} Kb; %{2}%";
|
||||
"Quota" = "Spazio usato";
|
||||
"quotasFormat" = "%{0} su %{1} Kb (%{2}%)";
|
||||
|
||||
"Please select a message." = "Per favore seleziona un messaggio.";
|
||||
"Please select a message to print." = "Per favore seleziona un messaggio da stampare.";
|
||||
|
|
|
@ -218,7 +218,8 @@
|
|||
= "¿Seguro que desea mover la carpeta a la papelera?";
|
||||
"Operation failed" = "Operación fallida";
|
||||
|
||||
"quotasFormat" = "Quotas: %{0} de %{1} Kb usados ; %{2}%";
|
||||
"Quota" = "Quotas";
|
||||
"quotasFormat" = "%{0} de %{1} Kb usados (%{2}%)";
|
||||
|
||||
"Please select a message." = "Seleccione un mensaje primero.";
|
||||
"Please select a message to print." = "Seleccione el mensaje que desea imprimir.";
|
||||
|
|
|
@ -28,6 +28,7 @@
|
|||
#import <NGObjWeb/WORequest.h>
|
||||
#import <NGObjWeb/WOResponse.h>
|
||||
#import <NGImap4/NGImap4Connection.h>
|
||||
#import <NGImap4/NGImap4Client.h>
|
||||
|
||||
#import <SoObjects/Mailer/SOGoMailAccount.h>
|
||||
#import <SoObjects/Mailer/SOGoDraftObject.h>
|
||||
|
@ -121,9 +122,14 @@
|
|||
|
||||
- (WOResponse *) listMailboxesAction
|
||||
{
|
||||
id infos;
|
||||
SOGoMailAccount *co;
|
||||
SOGoMailFolder *inbox;
|
||||
NGImap4Client *client;
|
||||
NSEnumerator *rawFolders;
|
||||
NSArray *folders;
|
||||
NSDictionary *data;
|
||||
NSString *inboxName;
|
||||
WOResponse *response;
|
||||
|
||||
co = [self clientObject];
|
||||
|
@ -131,10 +137,19 @@
|
|||
rawFolders = [[co allFolderPaths] objectEnumerator];
|
||||
folders = [self _jsonFolders: rawFolders];
|
||||
|
||||
// Retrieve INBOX quota
|
||||
inbox = [co inboxFolderInContext: context];
|
||||
inboxName = [NSString stringWithFormat: @"/%@", [inbox relativeImap4Name]];
|
||||
client = [[inbox imap4Connection] client];
|
||||
infos = [client getQuotaRoot: [inbox relativeImap4Name]];
|
||||
|
||||
data = [NSDictionary dictionaryWithObjectsAndKeys: folders, @"mailboxes",
|
||||
[[infos objectForKey: @"quotas"] objectForKey: inboxName], @"quotas",
|
||||
nil];
|
||||
response = [self responseWithStatus: 200];
|
||||
[response setHeader: @"text/plain; charset=utf-8"
|
||||
forKey: @"content-type"];
|
||||
[response appendContentString: [folders jsonRepresentation]];
|
||||
[response appendContentString: [data jsonRepresentation]];
|
||||
|
||||
return response;
|
||||
}
|
||||
|
|
|
@ -10,7 +10,6 @@
|
|||
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>
|
||||
<style type="text/css">
|
||||
<var:if condition="horizontalDragHandleStyle">
|
||||
|
@ -192,6 +191,13 @@
|
|||
</ul>
|
||||
</div>
|
||||
|
||||
<div id="quotaDialog" style="display: none;">
|
||||
<div>
|
||||
<h1><var:string label:value="Quota"/></h1>
|
||||
<p><!-- space --></p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div id="leftPanel">
|
||||
<div class="titlediv"><var:string label:value="Folders" /></div>
|
||||
<div id="folderTreeContent"><!-- space --></div>
|
||||
|
|
|
@ -631,6 +631,60 @@ TABLE#messageList TR[labels~="label1"]._selected TD
|
|||
{ color: #fff;
|
||||
background-color: #f00; }
|
||||
|
||||
/* quota indicator */
|
||||
DIV.quota
|
||||
{ border-bottom: 1px solid #ccc;
|
||||
margin: 2px 4px 2px 2px; }
|
||||
DIV.quota DIV.level
|
||||
{ background-image: url(quota-level.png);
|
||||
background-repeat: repeat-x;
|
||||
background-position: 25% 0;
|
||||
border-left: 1px solid #999;
|
||||
border-right: 1px solid #999;
|
||||
height: 20px; }
|
||||
DIV.quota DIV.marks DIV
|
||||
{ float: left;
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
width: 25%;
|
||||
border: 0;
|
||||
border-right: 1px solid #999;
|
||||
height: 5px; }
|
||||
DIV.quota DIV.level DIV.value
|
||||
{ background-repeat: repeat-x;
|
||||
border-left: 1px solid transparent;
|
||||
height: 15px;
|
||||
margin: 0;
|
||||
position: relative; }
|
||||
DIV.quota DIV.level DIV.value.ok
|
||||
{ background-image: url(quota-level-ok.png); }
|
||||
DIV.quota DIV.level DIV.value.warn
|
||||
{ background-image: url(quota-level-warn.png); }
|
||||
DIV.quota DIV.level DIV.value.alert
|
||||
{ background-image: url(quota-level-alert.png); }
|
||||
DIV#quotaDialog
|
||||
{ background-image: url("dialog-left.png");
|
||||
background-repeat: no-repeat;
|
||||
background-position: top left;
|
||||
position: absolute;
|
||||
top: 100px;
|
||||
left: 75px;
|
||||
width: 200px;
|
||||
z-index: 50; }
|
||||
DIV#quotaDialog DIV
|
||||
{ border: 1px solid #444;
|
||||
background-color: #fff;
|
||||
padding: 5px; }
|
||||
DIV#quotaDialog DIV
|
||||
{ border-left: 0;
|
||||
margin-left: 19px;
|
||||
text-align: left; }
|
||||
DIV#quotaDialog H1,
|
||||
DIV#quotaDialog P
|
||||
{ font-size: 10px;
|
||||
margin: 0;
|
||||
padding: 0; }
|
||||
|
||||
/* drag handles */
|
||||
DIV#verticalDragHandle
|
||||
{ cursor: e-resize;
|
||||
|
|
|
@ -4,19 +4,12 @@
|
|||
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,
|
||||
|
@ -25,7 +18,8 @@ var Mailer = {
|
|||
maxCachedMessages: 20,
|
||||
cachedMessages: new Array(),
|
||||
foldersStateTimer: false,
|
||||
popups: new Array()
|
||||
popups: new Array(),
|
||||
quotas: null
|
||||
};
|
||||
|
||||
var usersRightsWindowHeight = 320;
|
||||
|
@ -515,16 +509,6 @@ function openMailbox(mailbox, reload, idx) {
|
|||
document.messageListAjaxRequest
|
||||
= triggerAjaxRequest(url, messageListCallback,
|
||||
currentMessage);
|
||||
|
||||
var account = Mailer.currentMailbox.split("/")[1];
|
||||
if (accounts[account].supportsQuotas) {
|
||||
var quotasUrl = ApplicationBaseURL + encodeURI(mailbox) + "/quotas";
|
||||
if (document.quotaAjaxRequest) {
|
||||
document.quotaAjaxRequest.aborted = true;
|
||||
document.quotaAjaxRequest.abort();
|
||||
}
|
||||
document.quotaAjaxRequest = triggerAjaxRequest(quotasUrl, quotasCallback);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -606,36 +590,6 @@ function messageListCallback(http) {
|
|||
}
|
||||
}
|
||||
|
||||
function quotasCallback(http) {
|
||||
if (http.status == 200) {
|
||||
var hasQuotas = false;
|
||||
|
||||
if (http.responseText.length > 0) {
|
||||
var quotas = http.responseText.evalJSON(true);
|
||||
for (var i in quotas) {
|
||||
hasQuotas = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (hasQuotas) {
|
||||
var treePath = Mailer.currentMailbox.split("/");
|
||||
var quotasMB = new Array();
|
||||
for (var i = 2; i < treePath.length; i++)
|
||||
quotasMB.push(treePath[i].substr(6));
|
||||
var mbQuotas = quotas["/" + quotasMB.join("/")];
|
||||
var used = mbQuotas["usedSpace"];
|
||||
var max = mbQuotas["maxQuota"];
|
||||
var percents = (Math.round(used * 10000 / max) / 100);
|
||||
var format = labels["quotasFormat"];
|
||||
var text = format.formatted(used, max, percents);
|
||||
window.status = text;
|
||||
}
|
||||
}
|
||||
|
||||
document.quotaAjaxRequest = null;
|
||||
}
|
||||
|
||||
function onMessageContextMenu(event) {
|
||||
var menu = $('messageListMenu');
|
||||
var topNode = $('messageList');
|
||||
|
@ -1388,7 +1342,8 @@ function initMailboxTree() {
|
|||
}
|
||||
|
||||
function updateMailboxTreeInPage() {
|
||||
$("folderTreeContent").update(mailboxTree);
|
||||
var treeContent = $("folderTreeContent");
|
||||
treeContent.update(mailboxTree);
|
||||
|
||||
var inboxFound = false;
|
||||
var tree = $("mailboxTree");
|
||||
|
@ -1405,6 +1360,38 @@ function updateMailboxTreeInPage() {
|
|||
inboxFound = true;
|
||||
}
|
||||
}
|
||||
if (Mailer.quotas) {
|
||||
// Build quota indicator
|
||||
var percents = (Math.round(Mailer.quotas.usedSpace * 10000 / Mailer.quotas.maxQuota) / 100);
|
||||
var level = (percents > 85)? "alert" : (percents > 70)? "warn" : "ok";
|
||||
var format = labels["quotasFormat"];
|
||||
var text = format.formatted(Mailer.quotas.usedSpace, Mailer.quotas.maxQuota, percents);
|
||||
var quotaDiv = new Element('div', { 'class': 'quota', 'info': text });
|
||||
var levelDiv = new Element('div', { 'class': 'level' });
|
||||
var valueDiv = new Element('div', { 'class': 'value ' + level, 'style': 'width: ' + percents + '%' });
|
||||
var marksDiv = new Element('div', { 'class': 'marks' });
|
||||
marksDiv.appendChild(new Element('div'));
|
||||
marksDiv.appendChild(new Element('div'));
|
||||
marksDiv.appendChild(new Element('div'));
|
||||
levelDiv.appendChild(valueDiv);
|
||||
levelDiv.appendChild(marksDiv);
|
||||
quotaDiv.appendChild(levelDiv);
|
||||
|
||||
treeContent.insertBefore(quotaDiv, tree);
|
||||
quotaDiv.observe("mouseover", onViewQuota);
|
||||
quotaDiv.observe("mouseout", function(event) { $("quotaDialog").hide(); });
|
||||
}
|
||||
}
|
||||
|
||||
function onViewQuota(event) {
|
||||
var div = $("quotaDialog");
|
||||
if (div.visible()) return;
|
||||
var position = this.cumulativeOffset();
|
||||
position[0] += this.getWidth();
|
||||
div.down("p").update(this.readAttribute("info"));
|
||||
div.setStyle({ left: position[0] + "px",
|
||||
top: position[1] + "px" });
|
||||
div.show();
|
||||
}
|
||||
|
||||
function mailboxMenuNode(type, name) {
|
||||
|
@ -1538,14 +1525,16 @@ function onLoadMailboxesCallback(http) {
|
|||
|
||||
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 mailboxes = data.mailboxes;
|
||||
|
||||
if (data.quotas)
|
||||
Mailer.quotas = data.quotas;
|
||||
|
||||
for (var i = 0; i < mailboxes.length; i++) {
|
||||
var currentNode = account;
|
||||
var names = data[i].path.split("/");
|
||||
var names = mailboxes[i].path.split("/");
|
||||
for (var j = 1; j < (names.length - 1); j++) {
|
||||
var node = currentNode.findMailboxByName(names[j]);
|
||||
if (!node) {
|
||||
|
@ -1557,9 +1546,9 @@ function buildMailboxes(accountName, encoded) {
|
|||
var basename = names[names.length-1];
|
||||
var leaf = currentNode.findMailboxByName(basename);
|
||||
if (leaf)
|
||||
leaf.type = data[i].type;
|
||||
leaf.type = mailboxes[i].type;
|
||||
else {
|
||||
leaf = new Mailbox(data[i].type, basename);
|
||||
leaf = new Mailbox(mailboxes[i].type, basename);
|
||||
currentNode.addMailbox(leaf);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue