Monotone-Parent: 34791f35dbfae81d89b325cab373497ac8267859
Monotone-Revision: d60b33f55567caeee757661e23d65eee6e952ed9 Monotone-Author: wsourdeau@inverse.ca Monotone-Date: 2010-08-03T18:52:49 Monotone-Branch: ca.inverse.sogo
This commit is contained in:
parent
05ef0e573e
commit
9100c3db2f
28
ChangeLog
28
ChangeLog
|
@ -1,5 +1,33 @@
|
||||||
2010-08-03 Wolfgang Sourdeau <wsourdeau@inverse.ca>
|
2010-08-03 Wolfgang Sourdeau <wsourdeau@inverse.ca>
|
||||||
|
|
||||||
|
* UI/WebServerResources/MailerUI.js (composeNewMessage): the first
|
||||||
|
account is always identified as "0".
|
||||||
|
|
||||||
|
* UI/MailerUI/UIxMailMainFrame.m (-mailAccounts): we now return
|
||||||
|
tje JSON rep. of a simple and flat array containing the account
|
||||||
|
display names, since the account are represented with an integer
|
||||||
|
index.
|
||||||
|
(-inboxData): we directly fetch the first mail account by using
|
||||||
|
the "0" key.
|
||||||
|
(-composeAction): same as above.
|
||||||
|
|
||||||
|
* SoObjects/Mailer/SOGoMailAccount.m (-imap4URLString): the
|
||||||
|
"nameInContainer" now represents the index of the current account
|
||||||
|
in the array of user mail accounts, which simplifies this method.
|
||||||
|
We also handle the "encryption" key, albeit currently unused, and
|
||||||
|
we now add the port to the url as needed.
|
||||||
|
(-shortTitle): removed method.
|
||||||
|
(-davDisplayName): we only need to return the "name" key of the
|
||||||
|
current account.
|
||||||
|
|
||||||
|
* SoObjects/Mailer/SOGoMailAccounts.m (-mailAccounts): new utility
|
||||||
|
method that returns the mail account dictionaries corresponding to
|
||||||
|
the owner.
|
||||||
|
(-toManyRelationshipKeys): we now identify mail accounts via their
|
||||||
|
index in the array of accounts, since the order will never vary,
|
||||||
|
this simplifies the code.
|
||||||
|
(-lookupName:inContext:acquire:): same as the above.
|
||||||
|
|
||||||
* UI/WebServerResources/RowEditionController.js:
|
* UI/WebServerResources/RowEditionController.js:
|
||||||
RowEditionController.startEditing: keep the "_selected" class
|
RowEditionController.startEditing: keep the "_selected" class
|
||||||
when starting edition, if exists.
|
when starting edition, if exists.
|
||||||
|
|
|
@ -50,7 +50,6 @@ typedef enum {
|
||||||
|
|
||||||
@interface SOGoMailAccount : SOGoMailBaseObject
|
@interface SOGoMailAccount : SOGoMailBaseObject
|
||||||
{
|
{
|
||||||
NSString *accountName;
|
|
||||||
SOGoMailFolder *inboxFolder;
|
SOGoMailFolder *inboxFolder;
|
||||||
SOGoDraftsFolder *draftsFolder;
|
SOGoDraftsFolder *draftsFolder;
|
||||||
SOGoSentFolder *sentFolder;
|
SOGoSentFolder *sentFolder;
|
||||||
|
@ -58,8 +57,6 @@ typedef enum {
|
||||||
SOGoIMAPAclStyle imapAclStyle;
|
SOGoIMAPAclStyle imapAclStyle;
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void) setAccountName: (NSString *) newAccountName;
|
|
||||||
|
|
||||||
- (SOGoIMAPAclStyle) imapAclStyle;
|
- (SOGoIMAPAclStyle) imapAclStyle;
|
||||||
- (BOOL) imapAclConformsToIMAPExt;
|
- (BOOL) imapAclConformsToIMAPExt;
|
||||||
|
|
||||||
|
|
|
@ -69,7 +69,6 @@ static NSString *sieveScriptName = @"sogo";
|
||||||
draftsFolder = nil;
|
draftsFolder = nil;
|
||||||
sentFolder = nil;
|
sentFolder = nil;
|
||||||
trashFolder = nil;
|
trashFolder = nil;
|
||||||
accountName = nil;
|
|
||||||
imapAclStyle = undefined;
|
imapAclStyle = undefined;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -82,15 +81,9 @@ static NSString *sieveScriptName = @"sogo";
|
||||||
[draftsFolder release];
|
[draftsFolder release];
|
||||||
[sentFolder release];
|
[sentFolder release];
|
||||||
[trashFolder release];
|
[trashFolder release];
|
||||||
[accountName release];
|
|
||||||
[super dealloc];
|
[super dealloc];
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void) setAccountName: (NSString *) newAccountName
|
|
||||||
{
|
|
||||||
ASSIGN (accountName, newAccountName);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* listing the available folders */
|
/* listing the available folders */
|
||||||
|
|
||||||
- (BOOL) isInDraftsFolder
|
- (BOOL) isInDraftsFolder
|
||||||
|
@ -475,11 +468,6 @@ static NSString *sieveScriptName = @"sogo";
|
||||||
|
|
||||||
/* IMAP4 */
|
/* IMAP4 */
|
||||||
|
|
||||||
- (BOOL) useSSL
|
|
||||||
{
|
|
||||||
return NO;
|
|
||||||
}
|
|
||||||
|
|
||||||
- (NSString *) imap4LoginFromHTTP
|
- (NSString *) imap4LoginFromHTTP
|
||||||
{
|
{
|
||||||
WORequest *rq;
|
WORequest *rq;
|
||||||
|
@ -505,46 +493,52 @@ static NSString *sieveScriptName = @"sogo";
|
||||||
return [creds objectAtIndex:0]; /* the user */
|
return [creds objectAtIndex:0]; /* the user */
|
||||||
}
|
}
|
||||||
|
|
||||||
- (NSString *) _urlHostString
|
- (NSDictionary *) _mailAccount
|
||||||
{
|
{
|
||||||
NSDictionary *mailAccount;
|
NSDictionary *mailAccount;
|
||||||
NSString *username, *escUsername, *hostString;
|
NSArray *accounts;
|
||||||
|
SOGoUser *user;
|
||||||
|
|
||||||
mailAccount = [[context activeUser] accountWithName: accountName];
|
user = [SOGoUser userWithLogin: [self ownerInContext: nil]];
|
||||||
if (mailAccount)
|
accounts = [user mailAccounts];
|
||||||
{
|
mailAccount = [accounts objectAtIndex: [nameInContainer intValue]];
|
||||||
username = [mailAccount objectForKey: @"userName"];
|
|
||||||
escUsername
|
|
||||||
= [[username stringByEscapingURL] stringByReplacingString: @"@"
|
|
||||||
withString: @"%40"];
|
|
||||||
hostString = [NSString stringWithFormat: @"%@@%@", escUsername,
|
|
||||||
[mailAccount objectForKey: @"serverName"]];
|
|
||||||
}
|
|
||||||
else
|
|
||||||
hostString = @"localhost";
|
|
||||||
|
|
||||||
return hostString;
|
return mailAccount;
|
||||||
}
|
}
|
||||||
|
|
||||||
- (NSMutableString *) imap4URLString
|
- (NSMutableString *) imap4URLString
|
||||||
{
|
{
|
||||||
/* private, overridden by SOGoSharedMailAccount */
|
NSMutableString *imap4URLString;
|
||||||
NSMutableString *urlString;
|
NSDictionary *mailAccount;
|
||||||
NSString *host;
|
NSString *encryption, *protocol, *username, *escUsername;
|
||||||
|
int defaultPort, port;
|
||||||
|
|
||||||
urlString = [NSMutableString string];
|
mailAccount = [self _mailAccount];
|
||||||
|
encryption = [mailAccount objectForKey: @"encryption"];
|
||||||
if ([self useSSL])
|
if ([encryption isEqualToString: @"ssl"])
|
||||||
[urlString appendString: @"imaps://"];
|
{
|
||||||
|
protocol = @"imaps";
|
||||||
|
defaultPort = 993;
|
||||||
|
}
|
||||||
else
|
else
|
||||||
[urlString appendString: @"imap://"];
|
{
|
||||||
|
protocol = @"imap";
|
||||||
|
defaultPort = 143;
|
||||||
|
}
|
||||||
|
|
||||||
host = [self _urlHostString];
|
username = [mailAccount objectForKey: @"userName"];
|
||||||
if (![host rangeOfString: @"@"].length)
|
escUsername
|
||||||
[urlString appendFormat: @"%@@", [self imap4LoginFromHTTP]];
|
= [[username stringByEscapingURL] stringByReplacingString: @"@"
|
||||||
[urlString appendFormat: @"%@/", host];
|
withString: @"%40"];
|
||||||
|
imap4URLString = [NSMutableString stringWithFormat: @"%@://%@@%@",
|
||||||
|
protocol, escUsername,
|
||||||
|
[mailAccount objectForKey: @"serverName"]];
|
||||||
|
port = [[mailAccount objectForKey: @"port"] intValue];
|
||||||
|
if (port && port != defaultPort)
|
||||||
|
[imap4URLString appendFormat: @":%d", port];
|
||||||
|
[imap4URLString appendString: @"/"];
|
||||||
|
|
||||||
return urlString;
|
return imap4URLString;
|
||||||
}
|
}
|
||||||
|
|
||||||
- (NSMutableString *) traversalFromMailAccount
|
- (NSMutableString *) traversalFromMailAccount
|
||||||
|
@ -800,40 +794,9 @@ static NSString *sieveScriptName = @"sogo";
|
||||||
return [[self imap4Connection] createMailbox:_name atURL:[self imap4URL]];
|
return [[self imap4Connection] createMailbox:_name atURL:[self imap4URL]];
|
||||||
}
|
}
|
||||||
|
|
||||||
- (NSString *) shortTitle
|
|
||||||
{
|
|
||||||
NSString *login, *host;
|
|
||||||
NSRange r;
|
|
||||||
|
|
||||||
r = [accountName rangeOfString:@"@"];
|
|
||||||
if (r.length > 0)
|
|
||||||
{
|
|
||||||
login = [accountName substringToIndex:r.location];
|
|
||||||
host = [accountName substringFromIndex:(r.location + r.length)];
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
login = nil;
|
|
||||||
host = accountName;
|
|
||||||
}
|
|
||||||
|
|
||||||
r = [host rangeOfString:@"."];
|
|
||||||
if (r.length > 0)
|
|
||||||
host = [host substringToIndex:r.location];
|
|
||||||
|
|
||||||
if ([login length] == 0)
|
|
||||||
return host;
|
|
||||||
|
|
||||||
r = [login rangeOfString:@"."];
|
|
||||||
if (r.length > 0)
|
|
||||||
login = [login substringToIndex:r.location];
|
|
||||||
|
|
||||||
return [NSString stringWithFormat:@"%@@%@", login, host];
|
|
||||||
}
|
|
||||||
|
|
||||||
- (NSString *) davDisplayName
|
- (NSString *) davDisplayName
|
||||||
{
|
{
|
||||||
return [self shortTitle];
|
return [[self _mailAccount] objectForKey: @"name"];
|
||||||
}
|
}
|
||||||
|
|
||||||
@end /* SOGoMailAccount */
|
@end /* SOGoMailAccount */
|
||||||
|
|
|
@ -41,12 +41,10 @@
|
||||||
@class NSMutableDictionary;
|
@class NSMutableDictionary;
|
||||||
|
|
||||||
@interface SOGoMailAccounts : SOGoFolder
|
@interface SOGoMailAccounts : SOGoFolder
|
||||||
{
|
|
||||||
NSMutableDictionary *accountKeys;
|
- (NSArray *) mailAccounts;
|
||||||
}
|
|
||||||
|
|
||||||
- (NSArray *) toManyRelationshipKeys;
|
- (NSArray *) toManyRelationshipKeys;
|
||||||
- (NSDictionary *) accountKeys;
|
|
||||||
|
|
||||||
@end
|
@end
|
||||||
|
|
||||||
|
|
|
@ -36,113 +36,55 @@
|
||||||
|
|
||||||
@implementation SOGoMailAccounts
|
@implementation SOGoMailAccounts
|
||||||
|
|
||||||
/* listing the available mailboxes */
|
- (NSArray *) mailAccounts
|
||||||
|
|
||||||
// - (BOOL) isInHomeFolderBranchOfLoggedInAccount: (NSString *) userLogin
|
|
||||||
// {
|
|
||||||
// return [[container nameInContainer] isEqualToString: userLogin];
|
|
||||||
// }
|
|
||||||
|
|
||||||
- (id) init
|
|
||||||
{
|
{
|
||||||
if ((self = [super init]))
|
SOGoUser *user;
|
||||||
{
|
|
||||||
accountKeys = nil;
|
|
||||||
}
|
|
||||||
|
|
||||||
return self;
|
user = [SOGoUser userWithLogin: [self ownerInContext: nil]];
|
||||||
}
|
|
||||||
|
|
||||||
- (void) dealloc
|
return [user mailAccounts];
|
||||||
{
|
|
||||||
[accountKeys release];
|
|
||||||
[super dealloc];
|
|
||||||
}
|
|
||||||
|
|
||||||
- (void) _initAccountKeys
|
|
||||||
{
|
|
||||||
NSArray *accounts;
|
|
||||||
NSString *currentName;
|
|
||||||
int count, max;
|
|
||||||
|
|
||||||
if (!accountKeys)
|
|
||||||
{
|
|
||||||
accountKeys = [NSMutableDictionary new];
|
|
||||||
|
|
||||||
accounts = [[context activeUser] mailAccounts];
|
|
||||||
max = [accounts count];
|
|
||||||
for (count = 0; count < max; count++)
|
|
||||||
{
|
|
||||||
currentName = [[accounts objectAtIndex: count] objectForKey: @"name"];
|
|
||||||
[accountKeys setObject: currentName
|
|
||||||
forKey: [currentName asCSSIdentifier]];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
- (NSDictionary *) accountKeys
|
|
||||||
{
|
|
||||||
[self _initAccountKeys];
|
|
||||||
|
|
||||||
return accountKeys;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
- (NSArray *) toManyRelationshipKeys
|
- (NSArray *) toManyRelationshipKeys
|
||||||
{
|
{
|
||||||
[self _initAccountKeys];
|
NSMutableArray *keys;
|
||||||
|
NSArray *accounts;
|
||||||
|
int count, max;
|
||||||
|
SOGoUser *user;
|
||||||
|
|
||||||
return [accountKeys allKeys];
|
user = [SOGoUser userWithLogin: [self ownerInContext: nil]];
|
||||||
|
accounts = [user mailAccounts];
|
||||||
|
max = [accounts count];
|
||||||
|
|
||||||
|
keys = [NSMutableArray arrayWithCapacity: max];
|
||||||
|
for (count = 0; count < max; count++)
|
||||||
|
[keys addObject: [NSString stringWithFormat: @"%d", count]];
|
||||||
|
|
||||||
|
return keys;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* name lookup */
|
/* name lookup */
|
||||||
|
|
||||||
// - (id) mailAccountWithName: (NSString *) _key
|
|
||||||
// inContext: (id) _ctx
|
|
||||||
// {
|
|
||||||
// static Class ctClass = Nil;
|
|
||||||
// id ct;
|
|
||||||
|
|
||||||
// if (ctClass == Nil)
|
|
||||||
// ctClass = NSClassFromString(@"SOGoMailAccount");
|
|
||||||
// if (ctClass == Nil) {
|
|
||||||
// [self errorWithFormat:@"missing SOGoMailAccount class!"];
|
|
||||||
// return nil;
|
|
||||||
// }
|
|
||||||
|
|
||||||
// ct = [[ctClass alloc] initWithName:_key inContainer:self];
|
|
||||||
|
|
||||||
// return [ct autorelease];
|
|
||||||
// }
|
|
||||||
|
|
||||||
- (id) lookupName: (NSString *) _key
|
- (id) lookupName: (NSString *) _key
|
||||||
inContext: (id) _ctx
|
inContext: (id) _ctx
|
||||||
acquire: (BOOL) _flag
|
acquire: (BOOL) _flag
|
||||||
{
|
{
|
||||||
id obj;
|
id obj;
|
||||||
NSString *accountName;
|
NSArray *accounts;
|
||||||
// NSString *userLogin;
|
SOGoUser *user;
|
||||||
|
int keyCount;
|
||||||
// userLogin = [[context activeUser] login];
|
|
||||||
|
|
||||||
// if (![self isInHomeFolderBranchOfLoggedInAccount: userLogin]) {
|
|
||||||
// [self warnWithFormat:@ "User %@ tried to access mail hierarchy of %@",
|
|
||||||
// userLogin, [container nameInContainer]];
|
|
||||||
|
|
||||||
// return [NSException exceptionWithHTTPStatus:403 /* Forbidden */
|
|
||||||
// reason:@"Tried to access the mail of another user"];
|
|
||||||
// }
|
|
||||||
|
|
||||||
/* first check attributes directly bound to the application */
|
/* first check attributes directly bound to the application */
|
||||||
obj = [super lookupName:_key inContext:_ctx acquire:NO];
|
obj = [super lookupName:_key inContext:_ctx acquire:NO];
|
||||||
if (!obj)
|
if (!obj)
|
||||||
{
|
{
|
||||||
[self _initAccountKeys];
|
user = [SOGoUser userWithLogin: [self ownerInContext: nil]];
|
||||||
accountName = [accountKeys objectForKey: _key];
|
accounts = [user mailAccounts];
|
||||||
if ([accountName length])
|
|
||||||
{
|
keyCount = [_key intValue];
|
||||||
|
if ([_key isEqualToString: [NSString stringWithFormat: @"%d", keyCount]]
|
||||||
|
&& keyCount > -1 && keyCount < [accounts count])
|
||||||
obj = [SOGoMailAccount objectWithName: _key inContainer: self];
|
obj = [SOGoMailAccount objectWithName: _key inContainer: self];
|
||||||
[obj setAccountName: accountName];
|
|
||||||
}
|
|
||||||
else
|
else
|
||||||
obj = [NSException exceptionWithHTTPStatus: 404 /* Not Found */];
|
obj = [NSException exceptionWithHTTPStatus: 404 /* Not Found */];
|
||||||
}
|
}
|
||||||
|
|
|
@ -103,27 +103,12 @@
|
||||||
|
|
||||||
- (NSString *) mailAccounts
|
- (NSString *) mailAccounts
|
||||||
{
|
{
|
||||||
SOGoMailAccounts *accounts;
|
NSArray *accounts, *names;
|
||||||
NSDictionary *accountKeys;
|
|
||||||
NSArray *keys, *entry;
|
|
||||||
NSMutableArray *values;
|
|
||||||
NSString *key;
|
|
||||||
int i, max;
|
|
||||||
|
|
||||||
accounts = [self clientObject];
|
accounts = [[self clientObject] mailAccounts];
|
||||||
accountKeys = [accounts accountKeys];
|
names = [accounts objectsForKey: @"name" notFoundMarker: nil];
|
||||||
keys = [accountKeys allKeys];
|
|
||||||
values = [NSMutableArray array];
|
|
||||||
|
|
||||||
max = [keys count];
|
return [names jsonRepresentation];
|
||||||
for (i = 0; i < max; i++)
|
|
||||||
{
|
|
||||||
key = [keys objectAtIndex: i];
|
|
||||||
entry = [NSArray arrayWithObjects: key, [accountKeys objectForKey: key], nil];
|
|
||||||
[values addObject: entry];
|
|
||||||
}
|
|
||||||
|
|
||||||
return [values jsonRepresentation];
|
|
||||||
}
|
}
|
||||||
|
|
||||||
- (NSString *) defaultColumnsOrder
|
- (NSString *) defaultColumnsOrder
|
||||||
|
@ -182,21 +167,18 @@
|
||||||
SOGoMailAccounts *accounts;
|
SOGoMailAccounts *accounts;
|
||||||
SOGoMailAccount *account;
|
SOGoMailAccount *account;
|
||||||
SOGoMailFolder *inbox;
|
SOGoMailFolder *inbox;
|
||||||
|
|
||||||
NSString *firstAccount;
|
|
||||||
NSDictionary *data;
|
NSDictionary *data;
|
||||||
SOGoUser *activeUser;
|
SOGoUser *activeUser;
|
||||||
UIxMailListActions *actions;
|
UIxMailListActions *actions;
|
||||||
|
|
||||||
[self _setupContext];
|
[self _setupContext];
|
||||||
|
|
||||||
|
#warning this code is dirty: we should not invoke UIxMailListActions from here!
|
||||||
actions = [[[UIxMailListActions new] initWithRequest: [context request]] autorelease];
|
actions = [[[UIxMailListActions new] initWithRequest: [context request]] autorelease];
|
||||||
activeUser = [context activeUser];
|
activeUser = [context activeUser];
|
||||||
accounts = [self clientObject];
|
accounts = [self clientObject];
|
||||||
|
|
||||||
firstAccount = [[[accounts accountKeys] allKeys]
|
account = [accounts lookupName: @"0" inContext: context acquire: NO];
|
||||||
objectAtIndex: 0];
|
|
||||||
account = [accounts lookupName: firstAccount inContext: context acquire: NO];
|
|
||||||
inbox = [account inboxFolderInContext: context];
|
inbox = [account inboxFolderInContext: context];
|
||||||
|
|
||||||
data = [actions getUIDsAndHeadersInFolder: inbox];
|
data = [actions getUIDsAndHeadersInFolder: inbox];
|
||||||
|
@ -207,8 +189,8 @@
|
||||||
- (id <WOActionResults>) composeAction
|
- (id <WOActionResults>) composeAction
|
||||||
{
|
{
|
||||||
id contact;
|
id contact;
|
||||||
NSArray *accounts, *contactsId, *cards;
|
NSArray *contactsId, *cards;
|
||||||
NSString *firstAccount, *firstEscapedAccount, *newLocation, *parameters, *folderId, *uid, *formattedMail;
|
NSString *newLocation, *parameters, *folderId, *uid, *formattedMail;
|
||||||
NSEnumerator *uids;
|
NSEnumerator *uids;
|
||||||
NSMutableArray *addresses;
|
NSMutableArray *addresses;
|
||||||
NGVCard *card;
|
NGVCard *card;
|
||||||
|
@ -222,11 +204,6 @@
|
||||||
parameters = nil;
|
parameters = nil;
|
||||||
co = [self clientObject];
|
co = [self clientObject];
|
||||||
|
|
||||||
// We use the first mail account
|
|
||||||
accounts = [[context activeUser] mailAccounts];
|
|
||||||
firstAccount = [[accounts objectsForKey: @"name" notFoundMarker: nil]
|
|
||||||
objectAtIndex: 0];
|
|
||||||
firstEscapedAccount = [firstAccount asCSSIdentifier];
|
|
||||||
request = [context request];
|
request = [context request];
|
||||||
|
|
||||||
if ((folderId = [request formValueForKey: @"folder"]) &&
|
if ((folderId = [request formValueForKey: @"folder"]) &&
|
||||||
|
@ -290,9 +267,8 @@
|
||||||
// No parameter passed; simply open the compose window
|
// No parameter passed; simply open the compose window
|
||||||
parameters = @"?mailto=";
|
parameters = @"?mailto=";
|
||||||
|
|
||||||
newLocation = [NSString stringWithFormat: @"%@/%@/compose%@",
|
newLocation = [NSString stringWithFormat: @"%@/0/compose%@",
|
||||||
[co baseURLInContext: context],
|
[co baseURLInContext: context],
|
||||||
firstEscapedAccount,
|
|
||||||
parameters];
|
parameters];
|
||||||
|
|
||||||
return [self redirectToLocation: newLocation];
|
return [self redirectToLocation: newLocation];
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
/* -*- Mode: js2; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
/* -*- Mode: js2; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
||||||
|
|
||||||
/* JavaScript for SOGoMail */
|
/* JavaScript for SOGoMail */
|
||||||
var accounts = {};
|
var accounts = [];
|
||||||
var mailboxTree;
|
var mailboxTree;
|
||||||
var mailAccounts;
|
var mailAccounts;
|
||||||
if (typeof textMailAccounts != 'undefined') {
|
if (typeof textMailAccounts != 'undefined') {
|
||||||
|
@ -611,11 +611,11 @@ function composeNewMessage() {
|
||||||
if (Mailer.currentMailbox)
|
if (Mailer.currentMailbox)
|
||||||
account = Mailer.currentMailbox.split("/")[1];
|
account = Mailer.currentMailbox.split("/")[1];
|
||||||
else if (mailAccounts.length)
|
else if (mailAccounts.length)
|
||||||
account = mailAccounts[0][0];
|
account = "0";
|
||||||
else
|
else
|
||||||
account = null;
|
account = null;
|
||||||
if (account) {
|
if (account) {
|
||||||
var url = ApplicationBaseURL + "/" + encodeURI(account) + "/compose";
|
var url = ApplicationBaseURL + encodeURI(account) + "/compose";
|
||||||
openMailComposeWindow(url);
|
openMailComposeWindow(url);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1773,8 +1773,8 @@ function initMailboxTree() {
|
||||||
mailboxTree.pendingRequests = mailAccounts.length;
|
mailboxTree.pendingRequests = mailAccounts.length;
|
||||||
activeAjaxRequests += mailAccounts.length;
|
activeAjaxRequests += mailAccounts.length;
|
||||||
for (var i = 0; i < mailAccounts.length; i++) {
|
for (var i = 0; i < mailAccounts.length; i++) {
|
||||||
var url = ApplicationBaseURL + encodeURI(mailAccounts[i][0]) + "/mailboxes";
|
var url = ApplicationBaseURL + i + "/mailboxes";
|
||||||
triggerAjaxRequest(url, onLoadMailboxesCallback, mailAccounts[i]);
|
triggerAjaxRequest(url, onLoadMailboxesCallback, i);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1909,9 +1909,7 @@ function generateMenuForMailbox(mailbox, prefix, callback) {
|
||||||
callbacks.push(callback);
|
callbacks.push(callback);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
var menuWidth = parseInt(menu.offsetWidth) + 15
|
menu.style.width = (parseInt(menu.offsetWidth) + 15) + "px";
|
||||||
menuWidth = menuWidth + "px";
|
|
||||||
menu.style.width = menuWidth;
|
|
||||||
|
|
||||||
initMenu(menuDIV, callbacks);
|
initMenu(menuDIV, callbacks);
|
||||||
|
|
||||||
|
@ -1940,9 +1938,9 @@ function updateMailboxMenus() {
|
||||||
|
|
||||||
var submenuIds = new Array();
|
var submenuIds = new Array();
|
||||||
for (var i = 0; i < mailAccounts.length; i++) {
|
for (var i = 0; i < mailAccounts.length; i++) {
|
||||||
var menuEntry = mailboxMenuNode("account", mailAccounts[i][1]);
|
var menuEntry = mailboxMenuNode("account", mailAccounts[i]);
|
||||||
menu.appendChild(menuEntry);
|
menu.appendChild(menuEntry);
|
||||||
var mailbox = accounts[mailAccounts[i]];
|
var mailbox = accounts[i];
|
||||||
var newSubmenuId = generateMenuForMailbox(mailbox,
|
var newSubmenuId = generateMenuForMailbox(mailbox,
|
||||||
key, mailboxActions[key]);
|
key, mailboxActions[key]);
|
||||||
submenuIds.push(newSubmenuId);
|
submenuIds.push(newSubmenuId);
|
||||||
|
@ -1955,9 +1953,9 @@ function onLoadMailboxesCallback(http) {
|
||||||
if (http.status == 200) {
|
if (http.status == 200) {
|
||||||
checkAjaxRequestsState();
|
checkAjaxRequestsState();
|
||||||
if (http.responseText.length > 0) {
|
if (http.responseText.length > 0) {
|
||||||
var newAccount = buildMailboxes(http.callbackData,
|
var accountIdx = parseInt(http.callbackData);
|
||||||
http.responseText);
|
var newAccount = buildMailboxes(accountIdx, http.responseText);
|
||||||
accounts[http.callbackData] = newAccount;
|
accounts[accountIdx] = newAccount;
|
||||||
mailboxTree.addMailAccount(newAccount);
|
mailboxTree.addMailAccount(newAccount);
|
||||||
mailboxTree.pendingRequests--;
|
mailboxTree.pendingRequests--;
|
||||||
activeAjaxRequests--;
|
activeAjaxRequests--;
|
||||||
|
@ -1991,10 +1989,10 @@ function onLoadMailboxesCallback(http) {
|
||||||
// }
|
// }
|
||||||
}
|
}
|
||||||
|
|
||||||
function buildMailboxes(accountKeys, encoded) {
|
function buildMailboxes(accountIdx, encoded) {
|
||||||
var account = new Mailbox("account", accountKeys[1],
|
var account = new Mailbox("account", "" + accountIdx,
|
||||||
undefined, //necessary, null will cause issues
|
undefined, //necessary, null will cause issues
|
||||||
accountKeys[1]);
|
mailAccounts[accountIdx]);
|
||||||
var data = encoded.evalJSON(true);
|
var data = encoded.evalJSON(true);
|
||||||
var mailboxes = data.mailboxes;
|
var mailboxes = data.mailboxes;
|
||||||
var unseen = (data.status? data.status.unseen : 0);
|
var unseen = (data.status? data.status.unseen : 0);
|
||||||
|
|
Loading…
Reference in a new issue