Monotone-Parent: 533cfe8838587987ff2e1ab8c7ed56d0e4b66bb4

Monotone-Revision: fe2bfcd815039f3fc87b6307a5eb4a89ca9d9022

Monotone-Author: wsourdeau@inverse.ca
Monotone-Date: 2010-08-06T15:34:05
Monotone-Branch: ca.inverse.sogo
maint-2.0.2
Wolfgang Sourdeau 2010-08-06 15:34:05 +00:00
parent 0efbccb592
commit 2b9df19550
5 changed files with 703 additions and 94 deletions

View File

@ -1,5 +1,29 @@
2010-08-06 Wolfgang Sourdeau <wsourdeau@inverse.ca>
* UI/WebServerResources/UIxPreferences.js: (_setupEvents): no
longer take any parameter, which simplifies the method, as
removing the "change" observers on input field is not useful.
(initMailAccounts): new method that parses the mail accounts JSON
dictionary, populates the mail account UL and setup related
events.
(onMailAccountInfoChange, onMailIdentityInfoChange)
(onMailIdentitySignatureClick, onMailIdentitySignatureOK)
(createMailAccountLI, onMailAccountEntryClick, displayMailAccount)
(displayAccountSignature, createMailAccount)
(onMailAccountAdd, onMailAccountDelete, saveMailAccounts)
(compactMailAccounts): new methods completing the above.
* UI/PreferencesUI/UIxPreferences.m (-identitiesList)
(-itemIdentityText, -signature, -setSignature): removed obsolete
methods.
(-defaultAction): when updating filters, we now only need to query
the "0" account since accounts are no longer identified by "name".
(-mailAuxiliaryUserAccountsEnabled): new bool method.
(-setMailAccounts): new accessor that decodes the new mail
accounts dictionary in JSON format and validates it prior to save
it in the user defaults.
(-mailAccounts): new accessor.
* UI/MailerUI/UIxMailFolderActions.m (_setFolderPurpose:): we now
use the corresponding methods on the SOGoUserDefaults instance
rather than in the user settings (old bug) when setting folders

View File

@ -67,6 +67,7 @@
if ((self = [super init]))
{
item = nil;
#warning user should be the owner rather than the activeUser
ASSIGN (user, [context activeUser]);
ASSIGN (userDefaults, [user userDefaults]);
ASSIGN (today, [NSCalendarDate date]);
@ -575,35 +576,6 @@
[userDefaults setMailMessageForwarding: newMessageForwarding];
}
/*
// <label><var:string label:value="Default identity:"/>
// <var:popup list="identitiesList" item="item"
// string="itemIdentityText" selection="defaultIdentity"/></label>
- (NSArray *) identitiesList
{
NSDictionary *primaryAccount;
#warning we manage only one account per user at this time...
primaryAccount = [[user mailAccounts] objectAtIndex: 0];
return [primaryAccount objectForKey: @"identities"];
}
- (NSString *) itemIdentityText
{
return [(NSDictionary *) item keysWithFormat: @"%{fullName} <%{email}>"];
} */
- (NSString *) signature
{
return [userDefaults mailSignature];
}
- (void) setSignature: (NSString *) newSignature
{
[userDefaults setMailSignature: newSignature];
}
- (NSArray *) replyPlacementList
{
return [NSArray arrayWithObjects: @"above", @"below", nil];
@ -676,7 +648,7 @@
- (NSString *) sieveCapabilities
{
#warning this should be deduced from the server
#warning sieve caps should be deduced from the server
static NSArray *capabilities = nil;
if (!capabilities)
@ -931,8 +903,7 @@
if ([[request method] isEqualToString: @"POST"])
{
SOGoMailAccount *account;
id mailAccounts;
id folder;
SOGoMailAccounts *folder;
dd = [[context activeUser] domainDefaults];
if ([dd sieveScriptsEnabled])
@ -943,13 +914,10 @@
[userDefaults setForwardOptions: forwardOptions];
[userDefaults synchronize];
mailAccounts = [[[context activeUser] mailAccounts] objectAtIndex: 0];
folder = [[self clientObject] mailAccountsFolder: @"Mail"
inContext: context];
account = [folder lookupName: [[mailAccounts objectForKey: @"name"] asCSSIdentifier]
inContext: context
acquire: NO];
account = [folder lookupName: @"0" inContext: context acquire: NO];
[account updateFilters];
if (hasChanged)
@ -1093,4 +1061,193 @@
return [self labelForKey: item];
}
- (BOOL) mailAuxiliaryUserAccountsEnabled
{
return [[user domainDefaults] mailAuxiliaryUserAccountsEnabled];
}
- (void) _extractMainSignature: (NSDictionary *) account
{
/* We perform some validation here as we have no guaranty on the input
validity. */
NSString *signature;
NSArray *identities;
NSDictionary *identity;
if ([account isKindOfClass: [NSDictionary class]])
{
identities = [account objectForKey: @"identities"];
if ([identities isKindOfClass: [NSArray class]])
{
signature = nil;
if ([identities count] > 0)
{
identity = [identities objectAtIndex: 0];
if ([identity isKindOfClass: [NSDictionary class]])
{
signature = [identity objectForKey: @"signature"];
if (!signature)
signature = @"";
[userDefaults setMailSignature: signature];
}
}
}
}
}
- (BOOL) _validateAccountIdentities: (NSArray *) identities
{
static NSString *identityKeys[] = { @"fullName", @"email", nil };
static NSArray *knownKeys = nil;
NSString **key, *value;
NSDictionary *identity;
NSMutableDictionary *clone;
BOOL valid;
int count, max;
if (!knownKeys)
{
knownKeys = [NSArray arrayWithObjects: @"fullName", @"email",
@"signature", nil];
[knownKeys retain];
}
valid = [identities isKindOfClass: [NSArray class]];
if (valid)
{
max = [identities count];
valid = (max > 0);
for (count = 0; valid && count < max; count++)
{
identity = [identities objectAtIndex: count];
clone = [identity mutableCopy];
[clone removeObjectsForKeys: knownKeys];
valid = ([clone count] == 0);
[clone autorelease];
if (valid)
{
key = identityKeys;
while (valid && *key)
{
value = [identity objectForKey: *key];
if ([value isKindOfClass: [NSString class]]
&& [value length] > 0)
key++;
else
valid = NO;
}
if (valid)
{
value = [identity objectForKey: @"signature"];
valid = (!value || [value isKindOfClass: [NSString class]]);
}
}
}
}
return valid;
}
- (BOOL) _validateAccount: (NSDictionary *) account
{
static NSString *accountKeys[] = { @"name", @"serverName", @"userName",
@"password", nil };
static NSArray *knownKeys = nil;
NSMutableDictionary *clone;
NSString **key, *value;
BOOL valid;
if (!knownKeys)
{
knownKeys = [NSArray arrayWithObjects: @"name", @"serverName",
@"userName", @"password", @"encryption",
@"identities", @"mailboxes", nil];
[knownKeys retain];
}
valid = [account isKindOfClass: [NSDictionary class]];
if (valid)
{
clone = [account mutableCopy];
[clone removeObjectsForKeys: knownKeys];
valid = ([clone count] == 0);
[clone autorelease];
key = accountKeys;
while (valid && *key)
{
value = [account objectForKey: *key];
if ([value isKindOfClass: [NSString class]]
&& [value length] > 0)
key++;
else
valid = NO;
}
if (valid)
{
value = [account objectForKey: @"security"];
if (value)
valid = ([value isKindOfClass: [NSString class]]
&& ([value isEqualToString: @"none"]
|| [value isEqualToString: @"ssl"]
|| [value isEqualToString: @"tls"]));
valid &= [self _validateAccountIdentities: [account objectForKey: @"identities"]];
}
}
return valid;
}
- (void) _extractAuxiliaryAccounts: (NSArray *) accounts
{
int count, max;
NSMutableArray *auxAccounts;
NSDictionary *account;
max = [accounts count];
auxAccounts = [NSMutableArray arrayWithCapacity: max];
for (count = 1; count < max; count++)
{
account = [accounts objectAtIndex: count];
if ([self _validateAccount: account])
[auxAccounts addObject: account];
}
[userDefaults setAuxiliaryMailAccounts: auxAccounts];
}
- (void) setMailAccounts: (NSString *) newMailAccounts
{
NSArray *accounts;
NSScanner *scanner;
int max;
scanner = [NSScanner scannerWithString: newMailAccounts];
[scanner scanJSONArray: &accounts];
if (accounts && [accounts isKindOfClass: [NSArray class]])
{
max = [accounts count];
if (max > 0)
{
[self _extractMainSignature: [accounts objectAtIndex: 0]];
if (max > 1 && [self mailAuxiliaryUserAccountsEnabled])
[self _extractAuxiliaryAccounts: accounts];
}
}
}
- (NSString *) mailAccounts
{
NSArray *accounts;
accounts = [user mailAccounts];
return [accounts jsonRepresentation];
}
@end

View File

@ -27,8 +27,8 @@
><var:if condition="userHasMailAccess">
<li target="mailOptionsView"><span><var:string
label:value="Mail Options"/></span></li>
<li target="identitiesView"><span><var:string
label:value="Signature"/></span></li>
<li target="mailAccountsView"><span><var:string
label:value="IMAP Accounts"/></span></li>
<var:if condition="isVacationEnabled"><li target="vacationView"><span><var:string
label:value="Vacation"/></span></li></var:if
><var:if condition="isForwardEnabled"><li target="forwardView"><span><var:string
@ -122,8 +122,9 @@
></tr>
</var:foreach>
</tbody>
</table></div>
<div class="bottomToolbar">
</table>
</div>
<div const:id="categoriesToolbar" class="bottomToolbar">
<a const:id="categoryAdd" class="bottomButton" href="#">
<span><img rsrc:src="add-icon.png" label:title="Add" />
</span></a>
@ -195,8 +196,9 @@
<tbody><!--space --></tbody>
</table>
<input type="hidden" const:name="sieveFilters" const:id="sieveFilters"
var:value="sieveFiltersValue"/></div>
<div class="bottomToolbar">
var:value="sieveFiltersValue"/>
</div>
<div const:id="filtersToolbar" class="bottomToolbar">
<a const:id="filterAdd" class="bottomButton" href="#">
<span><img rsrc:src="add-icon.png" label:title="Add" />
</span></a>
@ -212,10 +214,57 @@
</div>
</var:if>
</div>
<div id="identitiesView" class="tab"
><textarea const:id="signature" const:name="signature"
var:value="signature"
/></div>
<div id="mailAccountsView" class="tab">
<input type="hidden" const:name="mailAccountsJSON" const:id="mailAccountsJSON"
var:value="mailAccounts"/>
<div id="mailAccountsListWrapper"
><ul id="mailAccountsList"
><!-- space --></ul
></div>
<var:if condition="mailAuxiliaryUserAccountsEnabled">
<div const:id="mailAccountsToolbar" class="bottomToolbar">
<a const:id="mailAccountAdd" class="bottomButton" href="#">
<span><img rsrc:src="add-icon.png" label:title="Add" />
</span></a>
<a const:id="mailAccountDelete" class="bottomButton" href="#">
<span><img rsrc:src="remove-icon.png" label:title="Delete" />
</span></a>
</div>
</var:if>
<div id="mailAccountEditor">
<fieldset const:id="accountInfo">
<label><var:string label:value="Server Name:"/>
<input const:name="serverName" const:id="serverName" type="text" const:value=""/></label>
<label><var:string label:value="Port:"/>
<input const:name="port" const:id="port" type="text" const:value=""/></label><br/><br/>
<label><var:string label:value="User Name:"/>
<input const:name="userName" const:id="userName" type="text" const:value=""/></label><br/>
<label><var:string label:value="Password:"/>
<input const:name="password" const:id="password" type="password" const:value=""/></label>
<input const:name="encryption" type="hidden" const:value="none"/>
<!-- <hr/> -->
<!-- <var:string label:value="Encryption:"/> -->
<!-- <label><input const:name="encryption" type="radio" const:value="none"/> -->
<!-- <var:string label:value="None"/></label> -->
<!-- <label><input const:name="encryption" type="radio" const:value="ssl"/> -->
<!-- <var:string label:value="SSL"/></label> -->
<!-- <label><input const:name="encryption" type="radio" const:value="tls"/> -->
<!-- <var:string label:value="TLS"/></label> -->
</fieldset>
<fieldset const:id="identityInfo">
<label><var:string label:value="Full Name:"/>
<input const:name="fullName" const:id="fullName" type="text" const:value=""
/></label><br/>
<label><var:string label:value="Email:"/>
<input const:name="email" const:id="email" type="text" const:value=""/></label><br/><br/>
<var:string label:value="Signature:"/>
<span id="actSignature"><!--space --></span>
</fieldset>
</div>
</div>
<var:if condition="isVacationEnabled">
<div id="vacationView" class="tab">
<label><input type="checkbox"

View File

@ -5,10 +5,21 @@ DIV#preferencesTabs
right: 5px;
bottom: 5px; }
TEXTAREA#signature
DIV.bottomToolbar
{ position: absolute;
width: 100%;
height: 100%; }
height: 20px;
margin: 0px;
padding: 0px; }
#categoriesToolbar, #filtersToolbar
{ left: 2em;
right: 2em;
bottom: 8px; }
#mailAccountsToolbar
{ left: 5px;
bottom: 9px;
width: 130px; }
DIV#categoriesListWrapper
{ overflow: auto;
@ -43,14 +54,7 @@ DIV.colorBox
margin: 0 3px 0 0;
width: 1em; }
DIV#windowButtons
{ position: fixed;
bottom: 20px;
left: 0px;
right: 25px;
vertical-align: middle;
text-align: right; }
/* vacation */
#vacation, #forward
{ padding-left: 2.5em; }
#vacation LABEL
@ -67,13 +71,6 @@ DIV#windowButtons
#passwordView BR
{ clear: both; }
DIV.bottomToolbar
{ position: absolute;
bottom: 9px;
left: 2em;
right: 2em;
margin: 0px; }
/* mail filters */
DIV#filtersListWrapper
{ overflow: auto;
@ -114,4 +111,82 @@ P.errorMessage#passwordError
{ color: #f00; }
P.infoMessage#passwordError
{ color: #00f; }
{ color: #00f; }
/* mail accounts */
#mailAccountsListWrapper, #mailAccountEditor
{ position: absolute;
overflow: auto;
bottom: 30px;
top: 5px;
left: 0px;
margin: 0px;
padding: 0px; }
#mailAccountsListWrapper
{ overflow-x: hidden;
left: 5px;
width: 130px;
background: #ccddec;
border-top: 1px solid #9b9b9b;
border-left: 1px solid #9b9b9b; }
#mailAccountsList
{ position: absolute;
top: 0px;
bottom: 0px;
left: 0px;
right: 0px;
margin: 0px;
padding: 0px; }
#mailAccountsList LI
{ cursor: pointer;
white-space: nowrap;
padding-left: 5px;
height: 20px; }
#mailAccountsList LI.readonly
{ cursor: default;
font-style: italic; }
#mailAccountEditor
{ left: 140px;
padding-top: 5px;
right: 5px; }
#serverName
{ width: 100px; }
#port
{ width: 30px; }
#userName, #password
{ width: 180px; }
#fullName, #email
{ width: 180px; }
#actSignature
{ color: #55f;
cursor: pointer;
text-decoration: underline; }
#actSignature.disabled
{ color: #999;
cursor: default;
text-decoration: none; }
#signatureDialog
{ position: absolute;
left: 10px;
width: auto !important;
right: 10px;
height: 200px;
top: 50px; }
#signature
{ width: 100%;
height: 90px;
margin: 0px auto;
margin-bottom: 10px; }

View File

@ -1,7 +1,7 @@
/* -*- Mode: java; tab-width: 2; c-label-minimum-indentation: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
var isSieveScriptsEnabled = false;
var filters = [];
var mailAccounts = null;
var dialogs = {};
function savePreferences(sender) {
var sendForm = true;
@ -45,6 +45,8 @@ function savePreferences(sender) {
$("sieveFilters").setValue(jsonFilters.toJSON());
}
saveMailAccounts();
if (sendForm)
$("mainForm").submit();
@ -77,7 +79,7 @@ function prototypeIfyFilters() {
return newFilters;
}
function _setupEvents(enable) {
function _setupEvents() {
var widgets = [ "timezone", "shortDateFormat", "longDateFormat",
"timeFormat", "weekStartDay", "dayStartTime", "dayEndTime",
"firstWeek", "messageCheck", "subscribedFoldersOnly",
@ -85,10 +87,7 @@ function _setupEvents(enable) {
for (var i = 0; i < widgets.length; i++) {
var widget = $(widgets[i]);
if (widget) {
if (enable)
widget.observe("change", onChoiceChanged);
else
widget.stopObserving("change", onChoiceChanged);
widget.observe("change", onChoiceChanged);
}
}
@ -106,14 +105,12 @@ function _setupEvents(enable) {
function onChoiceChanged(event) {
var hasChanged = $("hasChanged");
hasChanged.value = "1";
_setupEvents(false);
}
function addDefaultEmailAddresses(event) {
var defaultAddresses = $("defaultEmailAddresses").value.split(/, */);
var addresses = $("autoReplyEmailAddresses").value.trim();
if (addresses) addresses = addresses.split(/, */);
else addresses = new Array();
@ -124,7 +121,7 @@ function addDefaultEmailAddresses(event) {
if (i == addresses.length)
addresses.push(adr);
});
$("autoReplyEmailAddresses").value = addresses.join(", ");
event.stop();
@ -139,14 +136,10 @@ function initPreferences() {
if (filtersListWrapper) {
isSieveScriptsEnabled = true;
}
_setupEvents(true);
_setupEvents();
if (typeof (initAdditionalPreferences) != "undefined")
initAdditionalPreferences();
if ($("signature")) {
onComposeMessagesTypeChange();
}
var table = $("categoriesList");
if (table) {
resetCategoriesColors(null);
@ -172,11 +165,12 @@ function initPreferences() {
if (button)
button.observe("click", addDefaultEmailAddresses);
var button = $("changePasswordBtn");
button = $("changePasswordBtn");
if (button)
button.observe("click", onChangePasswordClick);
initSieveFilters();
initMailAccounts();
}
function initSieveFilters() {
@ -342,7 +336,7 @@ function _copyFilterElement(filterElement) { /* element = rule or action */
for (var k in filterElement) {
var value = filterElement[k];
if (typeof(value) == "string" || typeof(value) == "number") {
newElement[k] = value;
newElement[k] = value;
}
}
@ -376,6 +370,316 @@ function updateFilterFromEditor(filterId, filter) {
}
}
/* mail accounts */
function initMailAccounts() {
var mailAccountsJSON = $("mailAccountsJSON");
mailAccounts = mailAccountsJSON.value.evalJSON();
var mailAccountsList = $("mailAccountsList");
if (mailAccountsList) {
var li = createMailAccountLI(mailAccounts[0], true);
mailAccountsList.appendChild(li);
for (var i = 1; i < mailAccounts.length; i++) {
li = createMailAccountLI(mailAccounts[i]);
mailAccountsList.appendChild(li);
}
var lis = mailAccountsList.childNodesWithTag("li");
lis[0].readOnly = true;
lis[0].selectElement();
var button = $("mailAccountAdd");
if (button) {
button.observe("click", onMailAccountAdd);
}
button = $("mailAccountDelete");
if (button) {
button.observe("click", onMailAccountDelete);
}
}
var info = $("accountInfo");
var inputs = info.getElementsByTagName("input");
for (var i = 0; i < inputs.length; i++) {
$(inputs[i]).observe("change", onMailAccountInfoChange);
}
info = $("identityInfo");
inputs = info.getElementsByTagName("input");
for (var i = 0; i < inputs.length; i++) {
$(inputs[i]).observe("change", onMailIdentityInfoChange);
}
$("actSignature").observe("click", onMailIdentitySignatureClick);
displayMailAccount(mailAccounts[0], true);
}
function onMailAccountInfoChange(event) {
this.mailAccount[this.name] = this.value;
var hasChanged = $("hasChanged");
hasChanged.value = "1";
}
function onMailIdentityInfoChange(event) {
if (!this.mailAccount["identities"]) {
this.mailAccount["identities"] = [{}];
}
var identity = this.mailAccount["identities"][0];
identity[this.name] = this.value;
var hasChanged = $("hasChanged");
hasChanged.value = "1";
}
function onMailIdentitySignatureClick(event) {
if (!this.readOnly) {
var dialogId = "signatureDialog";
var dialog = dialogs[dialogId];
if (!dialog) {
var label = _("Please enter your signature below:");
var fields = createElement("p");
fields.appendChild(createElement("textarea", "signature"));
fields.appendChild(createElement("br"));
fields.appendChild(createButton("okBtn", _("OK"),
onMailIdentitySignatureOK));
fields.appendChild(createButton("cancelBtn", _("Cancel"),
onBodyClickDialogHandler.bind(document.body, dialogId)));
var dialog = createDialog(dialogId,
_("Signature"),
label,
fields,
"none");
document.body.appendChild(dialog);
dialog.show();
dialogs[dialogId] = dialog;
if ($("composeMessagesType").value != 0) {
CKEDITOR.replace('signature',
{ height: "70px",
toolbar: [['Bold', 'Italic', '-', 'Link',
'Font','FontSize','-','TextColor',
'BGColor']
],
language: localeCode,
scayt_sLang: localeCode });
}
}
dialog.mailAccount = this.mailAccount;
if (!this.mailAccount["identities"]) {
this.mailAccount["identities"] = [{}];
}
var identity = this.mailAccount["identities"][0];
var area = $("signature");
area.value = identity["signature"];
dialog.show();
$("bgDialogDiv").show();
if (!CKEDITOR.instances["signature"])
area.focus();
event.stop();
}
}
function onMailIdentitySignatureOK(event) {
var dialog = $("signatureDialog");
var mailAccount = dialog.mailAccount;
if (!mailAccount["identities"]) {
mailAccount["identities"] = [{}];
}
var identity = mailAccount["identities"][0];
var content = (CKEDITOR.instances["signature"]
? CKEDITOR.instances["signature"].getData()
: $("signature").value);
identity["signature"] = content;
displayAccountSignature(mailAccount);
dialog.hide();
$("bgDialogDiv").hide();
dialog.mailAccount = null;
var hasChanged = $("hasChanged");
hasChanged.value = "1";
}
function createMailAccountLI(mailAccount, readOnly) {
var li = createElement("li");
li.appendChild(document.createTextNode(mailAccount["name"]));
li.observe("click", onMailAccountEntryClick);
li.observe("mousedown", onRowClick);
if (readOnly) {
li.addClassName("readonly");
}
else {
var editionCtlr = new RowEditionController();
editionCtlr.attachToRowElement(li);
editionCtlr.notifyNewValueCallback = function(ignore, newValue) {
mailAccount["name"] = newValue;
};
li.editionController = editionCtlr;
}
li.mailAccount = mailAccount;
return li;
}
function onMailAccountEntryClick(event) {
displayMailAccount(this.mailAccount, this.readOnly);
}
function displayMailAccount(mailAccount, readOnly) {
var editor = $("mailAccountEditor");
var inputs = editor.getElementsByTagName("input");
for (var i = 0; i < inputs.length; i++) {
inputs[i].disabled = readOnly;
inputs[i].mailAccount = mailAccount;
}
var encryption = "none";
var encRadioValues = [ "none", "ssl", "tls" ];
if (mailAccount["encryption"]) {
encryption = mailAccount["encryption"];
}
var form = $("mainForm");
form.setRadioValue("encryption", encRadioValues.indexOf(encryption));
var port;
if (mailAccount["port"]) {
port = mailAccount["port"];
}
else {
if (encryption == "ssl") {
port = 993;
}
else {
port = 143;
}
}
$("port").value = port;
$("serverName").value = mailAccount["serverName"];
$("userName").value = mailAccount["userName"];
$("password").value = mailAccount["password"];
var identity = (mailAccount["identities"]
? mailAccount["identities"][0]
: {} );
$("fullName").value = identity["fullName"] || "";
$("email").value = identity["email"] || "";
displayAccountSignature(mailAccount);
}
function displayAccountSignature(mailAccount) {
var actSignature = $("actSignature");
actSignature.mailAccount = mailAccount;
var actSignatureValue;
var identity = (mailAccount["identities"]
? mailAccount["identities"][0]
: {} );
var value = identity["signature"];
if (value && value.length > 0) {
if (value.length < 30) {
actSignatureValue = value;
}
else {
actSignatureValue = value.substr(0, 30) + "...";
}
}
else {
actSignatureValue = _("(Click to create)");
}
while (actSignature.firstChild) {
actSignature.removeChild(actSignature.firstChild);
}
actSignature.appendChild(document.createTextNode(actSignatureValue));
}
function createMailAccount() {
var firstIdentity = mailAccounts[0]["identities"][0];
var newIdentity = {};
for (var k in firstIdentity) {
newIdentity[k] = firstIdentity[k];
}
delete newIdentity["isDefault"];
var newMailAccount = { name: _("New Mail Account"),
serverName: "mailserver",
userName: UserLogin,
password: "",
identities: [ newIdentity ] };
return newMailAccount;
}
function onMailAccountAdd(event) {
var newMailAccount = createMailAccount();
mailAccounts.push(newMailAccount);
var li = createMailAccountLI(newMailAccount);
var mailAccountsList = $("mailAccountsList");
mailAccountsList.appendChild(li);
var selection = mailAccountsList.getSelectedNodes();
for (var i = 0; i < selection.length; i++) {
selection[i].deselect();
}
displayMailAccount(newMailAccount, false);
li.selectElement();
li.editionController.startEditing();
event.stop();
}
function onMailAccountDelete(event) {
var mailAccountsList = $("mailAccountsList");
var selection = mailAccountsList.getSelectedNodes();
if (selection.length > 0) {
var li = selection[0];
if (!li.readOnly) {
li.deselect();
li.editionController = null;
var next = li.next();
if (!next) {
next = li.previous();
}
mailAccountsList.removeChild(li);
var index = mailAccounts.indexOf(li.mailAccount);
mailAccounts.splice(index, 1);
next.selectElement();
displayMailAccount(next.mailAccount, next.readOnly);
}
}
event.stop();
}
function saveMailAccounts() {
/* This removal enables us to avoid a few warning from SOPE for the inputs
that were created dynamically. */
var editor = $("mailAccountEditor");
editor.parentNode.removeChild(editor);
compactMailAccounts();
var mailAccountsJSON = $("mailAccountsJSON");
mailAccountsJSON.value = mailAccounts.toJSON();
}
function compactMailAccounts() {
for (var i = 1; i < mailAccounts.length; i++) {
var account = mailAccounts[i];
var encryption = account["encryption"];
if (encryption) {
if (encryption == "none") {
delete account["encryption"];
}
}
else {
encryption = "none";
}
var port = account["port"];
if (port) {
if ((encryption == "ssl" && port == 993)
|| port == 143) {
delete account["port"];
}
}
}
}
/* categories */
function resetTableActions() {
var r = $$("TABLE#categoriesList tbody tr");
for (var i = 0; i < r.length; i++) {
@ -394,7 +698,7 @@ function onColorEdit (e) {
r[i].removeClassName ("colorEditing");
this.addClassName ("colorEditing");
var cPicker = window.open(ApplicationBaseURL + "../" + UserLogin
var cPicker = window.open(ApplicationBaseURL + "../" + UserLogin
+ "/Calendar/colorPicker", "colorPicker",
"width=250,height=200,resizable=0,scrollbars=0"
+ "toolbar=0,location=0,directories=0,status=0,"
@ -490,7 +794,7 @@ function onReplyPlacementListChange() {
function onComposeMessagesTypeChange(event) {
// var textArea = $('signature');
if ($("composeMessagesType").value == 0) /* text */ {
if (this.value == 0) /* text */ {
if (CKEDITOR.instances["signature"]) {
var content = CKEDITOR.instances["signature"].getData();
var htmlEditorWidget = $('cke_signature');
@ -502,16 +806,16 @@ function onComposeMessagesTypeChange(event) {
textArea.style.visibility = "";
}
} else {
if (!CKEDITOR.instances["signature"]) {
if ($("signature") && !CKEDITOR.instances["signature"]) {
CKEDITOR.replace('signature',
{
height: "290px",
toolbar : [['Bold', 'Italic', '-', 'Link',
'Font','FontSize','-','TextColor',
'BGColor']
],
language : localeCode,
scayt_sLang : localeCode
height: "70px",
toolbar: [['Bold', 'Italic', '-', 'Link',
'Font','FontSize','-','TextColor',
'BGColor']
],
language: localeCode,
scayt_sLang: localeCode
}
);
}