mirror of
https://github.com/inverse-inc/sogo.git
synced 2026-08-25 16:33:22 +00:00
See ChangeLog
Monotone-Parent: 2b83c62317d266d5f7a2e2046fc19f68f88a385f Monotone-Revision: 763ab7e667a159d6b727544a067a085d622ab598 Monotone-Author: flachapelle@inverse.ca Monotone-Date: 2010-06-25T19:58:30 Monotone-Branch: ca.inverse.sogo
This commit is contained in:
@@ -65,6 +65,8 @@
|
||||
NSArray *cc;
|
||||
NSArray *bcc;
|
||||
NSString *subject;
|
||||
NSString *sourceUID;
|
||||
NSString *sourceFolder;
|
||||
NSString *text;
|
||||
NSMutableArray *fromEMails;
|
||||
NSString *from;
|
||||
@@ -116,6 +118,8 @@ static NSArray *infoKeys = nil;
|
||||
[to release];
|
||||
[cc release];
|
||||
[bcc release];
|
||||
[sourceUID release];
|
||||
[sourceFolder release];
|
||||
[attachmentName release];
|
||||
[attachmentNames release];
|
||||
[attachedFiles release];
|
||||
@@ -245,6 +249,29 @@ static NSArray *infoKeys = nil;
|
||||
return text;
|
||||
}
|
||||
|
||||
- (void) setSourceUID: (int) newSourceUID
|
||||
{
|
||||
NSString *s;
|
||||
|
||||
s = [NSString stringWithFormat: @"%i", newSourceUID];
|
||||
ASSIGN (sourceUID, s);
|
||||
}
|
||||
|
||||
- (NSString *) sourceUID
|
||||
{
|
||||
return sourceUID;
|
||||
}
|
||||
|
||||
- (void) setSourceFolder: (NSString *) newSourceFolder
|
||||
{
|
||||
ASSIGN (sourceFolder, newSourceFolder);
|
||||
}
|
||||
|
||||
- (NSString *) sourceFolder
|
||||
{
|
||||
return sourceFolder;
|
||||
}
|
||||
|
||||
- (void) setTo: (NSArray *) newTo
|
||||
{
|
||||
if ([newTo isKindOfClass: [NSNull class]])
|
||||
@@ -490,6 +517,11 @@ static NSArray *infoKeys = nil;
|
||||
return [[self attachmentNames] count] > 0 ? YES : NO;
|
||||
}
|
||||
|
||||
- (NSString *) uid
|
||||
{
|
||||
return [[self clientObject] nameInContainer];
|
||||
}
|
||||
|
||||
- (id) defaultAction
|
||||
{
|
||||
SOGoDraftObject *co;
|
||||
@@ -498,6 +530,8 @@ static NSArray *infoKeys = nil;
|
||||
[co fetchInfo];
|
||||
[self loadInfo: [co headers]];
|
||||
[self setText: [co text]];
|
||||
[self setSourceUID: [co IMAP4ID]];
|
||||
[self setSourceFolder: [co sourceFolder]];
|
||||
|
||||
return self;
|
||||
}
|
||||
@@ -537,6 +571,7 @@ static NSArray *infoKeys = nil;
|
||||
- (id <WOActionResults>) sendAction
|
||||
{
|
||||
id <WOActionResults> result;
|
||||
SOGoDraftObject *co;
|
||||
|
||||
// TODO: need to validate whether we have a To etc
|
||||
|
||||
@@ -548,7 +583,12 @@ static NSArray *infoKeys = nil;
|
||||
{
|
||||
result = (id <WOActionResults>) [[self clientObject] sendMail];
|
||||
if (!result)
|
||||
result = [self jsCloseWithRefreshMethod: @"refreshCurrentFolder()"];
|
||||
{
|
||||
co = [self clientObject];
|
||||
result = [self jsCloseWithRefreshMethod: [NSString stringWithFormat: @"refreshMessage(\"%@\", %i)",
|
||||
[co sourceFolder],
|
||||
[co IMAP4ID]]];
|
||||
}
|
||||
}
|
||||
else
|
||||
result = [self failedToSaveFormResponse];
|
||||
|
||||
@@ -45,6 +45,11 @@
|
||||
- (EOQualifier *) searchQualifier;
|
||||
- (NSString *) msgLabels;
|
||||
|
||||
- (NSArray *) getSortedUIDsInFolder: (SOGoMailFolder *) mailFolder;
|
||||
- (NSArray *) getHeadersForUIDs: (NSArray *) uids
|
||||
inFolder: (SOGoMailFolder *) mailFolder;
|
||||
- (NSDictionary *) getUIDsAndHeadersInFolder: (SOGoMailFolder *) mailFolder;
|
||||
|
||||
- (id) getMailAction;
|
||||
- (id <WOActionResults>) getSortedUIDsAction;
|
||||
- (id <WOActionResults>) getHeadersAction;
|
||||
|
||||
@@ -64,6 +64,9 @@
|
||||
|
||||
#import "UIxMailListActions.h"
|
||||
|
||||
// The maximum number of headers to prefetch when querying the UIDs list
|
||||
#define headersPrefetchMaxSize 100
|
||||
|
||||
@implementation UIxMailListActions
|
||||
|
||||
- (id) initWithRequest: (WORequest *) newRequest
|
||||
@@ -341,7 +344,7 @@
|
||||
- (NSString *) imap4SortOrdering
|
||||
{
|
||||
NSString *sort, *ascending;
|
||||
NSString *module; //*login
|
||||
NSString *module;
|
||||
NSMutableDictionary *moduleSettings;
|
||||
BOOL asc;
|
||||
SOGoUser *activeUser;
|
||||
@@ -352,14 +355,23 @@
|
||||
ascending = [[context request] formValueForKey: @"asc"];
|
||||
asc = [ascending boolValue];
|
||||
|
||||
if (![sort isEqualToString: [self defaultSortKey]])
|
||||
activeUser = [context activeUser];
|
||||
clientObject = [self clientObject];
|
||||
module = [[[clientObject container] container] nameInContainer];
|
||||
us = [activeUser userSettings];
|
||||
moduleSettings = [us objectForKey: module];
|
||||
|
||||
if ([sort isEqualToString: [self defaultSortKey]] && !asc)
|
||||
{
|
||||
if (moduleSettings)
|
||||
{
|
||||
[moduleSettings removeObjectForKey: @"SortingState"];
|
||||
[us synchronize];
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// Save the sorting state in the user settings
|
||||
activeUser = [context activeUser];
|
||||
clientObject = [self clientObject];
|
||||
module = [[[clientObject container] container] nameInContainer];
|
||||
us = [activeUser userSettings];
|
||||
moduleSettings = [us objectForKey: module];
|
||||
if (!moduleSettings)
|
||||
{
|
||||
moduleSettings = [NSMutableDictionary dictionary];
|
||||
@@ -413,10 +425,9 @@
|
||||
return qualifier;
|
||||
}
|
||||
|
||||
- (NSArray *) sortedUIDs
|
||||
- (NSArray *) getSortedUIDsInFolder: (SOGoMailFolder *) mailFolder
|
||||
{
|
||||
EOQualifier *qualifier, *fetchQualifier, *notDeleted;
|
||||
SOGoMailFolder *folder;
|
||||
|
||||
if (!sortedUIDs)
|
||||
{
|
||||
@@ -434,10 +445,9 @@
|
||||
else
|
||||
fetchQualifier = notDeleted;
|
||||
|
||||
folder = [self clientObject];
|
||||
sortedUIDs
|
||||
= [folder fetchUIDsMatchingQualifier: fetchQualifier
|
||||
sortOrdering: [self imap4SortOrdering]];
|
||||
= [mailFolder fetchUIDsMatchingQualifier: fetchQualifier
|
||||
sortOrdering: [self imap4SortOrdering]];
|
||||
[sortedUIDs retain];
|
||||
}
|
||||
|
||||
@@ -449,7 +459,7 @@
|
||||
NSArray *messageNbrs;
|
||||
int index;
|
||||
|
||||
messageNbrs = [self sortedUIDs];
|
||||
messageNbrs = [self getSortedUIDsInFolder: [self clientObject]];
|
||||
index
|
||||
= [messageNbrs indexOfObject: [NSNumber numberWithInt: messageNbr]];
|
||||
// if (index < 0)
|
||||
@@ -524,75 +534,55 @@
|
||||
return [self redirectToLocation:@"view"];
|
||||
}
|
||||
|
||||
- (NSDictionary *) getUIDsAndHeadersInFolder: (SOGoMailFolder *) mailFolder
|
||||
{
|
||||
NSArray *uids, *headers;
|
||||
NSDictionary *data;
|
||||
NSRange r;
|
||||
int count;
|
||||
|
||||
uids = [self getSortedUIDsInFolder: mailFolder]; // retrieves the form parameters "sort" and "asc"
|
||||
|
||||
// Also retrieve the first headers, up to 'headersPrefetchMaxSize'
|
||||
count = [uids count];
|
||||
if (count > headersPrefetchMaxSize) count = headersPrefetchMaxSize;
|
||||
r = NSMakeRange(0, count);
|
||||
headers = [self getHeadersForUIDs: [uids subarrayWithRange: r]
|
||||
inFolder: mailFolder];
|
||||
|
||||
data = [NSDictionary dictionaryWithObjectsAndKeys: uids, @"uids",
|
||||
headers, @"headers", nil];
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
- (id <WOActionResults>) getSortedUIDsAction
|
||||
{
|
||||
NSArray *uids;
|
||||
NSRange r;
|
||||
WORequest *request;
|
||||
NSDictionary *data;
|
||||
SOGoMailFolder *folder;
|
||||
WOResponse *response;
|
||||
int firstUID, firstIndex, count;
|
||||
|
||||
request = [context request];
|
||||
uids = [self sortedUIDs]; // retrieves the form parameters "sort" and "asc"
|
||||
|
||||
if ([request formValueForKey: @"start"] != nil)
|
||||
{
|
||||
firstUID = [[request formValueForKey: @"start"] intValue];
|
||||
firstIndex = [self indexOfMessageUID: firstUID];
|
||||
if (firstIndex == NSNotFound)
|
||||
return [NSException exceptionWithHTTPStatus: 404
|
||||
reason: @"Message not found"];
|
||||
}
|
||||
else
|
||||
firstIndex = -1;
|
||||
|
||||
if ([request formValueForKey: @"count"] != nil)
|
||||
{
|
||||
count = [[request formValueForKey: @"count"] intValue];
|
||||
}
|
||||
else
|
||||
count = 0;
|
||||
|
||||
if (firstIndex > -1)
|
||||
{
|
||||
if (count <= 0 || (count + firstIndex) > [uids count])
|
||||
count = [uids count] - firstIndex;
|
||||
r = NSMakeRange(firstIndex, count);
|
||||
uids = [uids subarrayWithRange: r];
|
||||
}
|
||||
|
||||
response = [context response];
|
||||
folder = [self clientObject];
|
||||
data = [self getUIDsAndHeadersInFolder: folder];
|
||||
[response setHeader: @"text/plain; charset=utf-8"
|
||||
forKey: @"content-type"];
|
||||
[response appendContentString: [uids jsonRepresentation]];
|
||||
[response appendContentString: [data jsonRepresentation]];
|
||||
|
||||
return response;
|
||||
}
|
||||
|
||||
- (id <WOActionResults>) getHeadersAction
|
||||
- (NSArray *) getHeadersForUIDs: (NSArray *) uids
|
||||
inFolder: (SOGoMailFolder *) mailFolder
|
||||
{
|
||||
NSArray *uids, *to, *from;
|
||||
NSArray *to, *from;
|
||||
NSDictionary *msgs;
|
||||
NSMutableArray *headers;
|
||||
NSMutableDictionary *msg;
|
||||
NSMutableArray *headers, *msg;
|
||||
NSEnumerator *msgsList;
|
||||
NSString *msgIconStatus, *msgDate;
|
||||
SOGoMailFolder *mailFolder;
|
||||
WORequest *request;
|
||||
WOResponse *response;
|
||||
UIxEnvelopeAddressFormatter *addressFormatter;
|
||||
|
||||
request = [context request];
|
||||
|
||||
if ([request formValueForKey: @"uids"] == nil)
|
||||
{
|
||||
return [NSException exceptionWithHTTPStatus: 404
|
||||
reason: @"No UID specified"];
|
||||
}
|
||||
|
||||
uids = [[request formValueForKey: @"uids"] componentsSeparatedByString: @","]; // Should we support ranges? ie "x-y"
|
||||
headers = [NSMutableArray arrayWithCapacity: [uids count]];
|
||||
mailFolder = [self clientObject];
|
||||
addressFormatter = [context mailEnvelopeAddressFormatter];
|
||||
|
||||
// Fetch headers
|
||||
@@ -601,78 +591,109 @@
|
||||
|
||||
msgsList = [[msgs objectForKey: @"fetch"] objectEnumerator];
|
||||
[self setMessage: [msgsList nextObject]];
|
||||
|
||||
msg = [NSMutableArray arrayWithObjects: @"To", @"Attachment", @"Flagged", @"Subject", @"From", @"Unread", @"Priority", @"Date", @"Size", @"rowClasses", @"labels", @"rowID", @"uid", nil];
|
||||
[headers addObject: msg];
|
||||
while (message)
|
||||
{
|
||||
msg = [NSMutableDictionary dictionaryWithCapacity: 11];
|
||||
msg = [NSMutableArray arrayWithCapacity: 12];
|
||||
|
||||
// Columns data
|
||||
|
||||
// To
|
||||
to = [[message objectForKey: @"envelope"] to];
|
||||
if ([to count] > 0)
|
||||
[msg setObject: [addressFormatter stringForArray: to]
|
||||
forKey: @"To"];
|
||||
|
||||
if ([self hasMessageAttachment])
|
||||
[msg setObject: [NSString stringWithFormat: @"<img src=\"%@\"/>", [self urlForResourceFilename: @"title_attachment_14x14.png"]]
|
||||
forKey: @"Attachment"];
|
||||
|
||||
if ([self isMessageFlagged])
|
||||
{
|
||||
[msg setObject: [NSString stringWithFormat: @"<img src=\"%@\" class=\"messageIsFlagged\">",
|
||||
[self urlForResourceFilename: @"flag.png"]]
|
||||
forKey: @"Flagged"];
|
||||
}
|
||||
[msg addObject: [addressFormatter stringForArray: to]];
|
||||
else
|
||||
{
|
||||
[msg setObject: [NSString stringWithFormat: @"<img src=\"%@\">",
|
||||
[self urlForResourceFilename: @"dot.png"]]
|
||||
forKey: @"Flagged"];
|
||||
}
|
||||
[msg addObject: @""];
|
||||
|
||||
[msg setObject: [NSString stringWithFormat: @"<span>%@</span>",
|
||||
[self messageSubject]]
|
||||
forKey: @"Subject"];
|
||||
// Attachment
|
||||
if ([self hasMessageAttachment])
|
||||
[msg addObject: [NSString stringWithFormat: @"<img src=\"%@\"/>", [self urlForResourceFilename: @"title_attachment_14x14.png"]]];
|
||||
else
|
||||
[msg addObject: @""];
|
||||
|
||||
// Flagged
|
||||
if ([self isMessageFlagged])
|
||||
[msg addObject: [NSString stringWithFormat: @"<img src=\"%@\" class=\"messageIsFlagged\">",
|
||||
[self urlForResourceFilename: @"flag.png"]]];
|
||||
else
|
||||
[msg addObject: [NSString stringWithFormat: @"<img src=\"%@\">",
|
||||
[self urlForResourceFilename: @"dot.png"]]];
|
||||
|
||||
// Subject
|
||||
[msg addObject: [NSString stringWithFormat: @"<span>%@</span>",
|
||||
[self messageSubject]]];
|
||||
|
||||
// From
|
||||
from = [[message objectForKey: @"envelope"] from];
|
||||
if ([from count] > 0)
|
||||
[msg setObject: [addressFormatter stringForArray: from] forKey: @"From"];
|
||||
[msg addObject: [addressFormatter stringForArray: from]];
|
||||
else
|
||||
[msg setObject: @"" forKey: @"From"];
|
||||
[msg addObject: @""];
|
||||
|
||||
|
||||
// Unread
|
||||
if ([self isMessageRead])
|
||||
msgIconStatus = @"dot.png";
|
||||
else
|
||||
msgIconStatus = @"icon_unread.gif";
|
||||
|
||||
[msg setObject: [self messageRowStyleClass] forKey: @"rowClasses"];
|
||||
[msg setObject: [NSString stringWithFormat: @"<img src=\"%@\" class=\"mailerReadIcon\" title=\"%@\" title-markread=\"%@\" title-markunread=\"%@\" id=\"%@\"/>",
|
||||
[msg addObject: [NSString stringWithFormat: @"<img src=\"%@\" class=\"mailerReadIcon\" title=\"%@\" title-markread=\"%@\" title-markunread=\"%@\" id=\"%@\"/>",
|
||||
[self urlForResourceFilename: msgIconStatus],
|
||||
[self labelForKey: @"Mark Unread"],
|
||||
[self labelForKey: @"Mark Read"],
|
||||
[self labelForKey: @"Mark Unread"],
|
||||
[self msgIconReadImgID]]
|
||||
forKey: @"Unread"];
|
||||
[self msgIconReadImgID]]];
|
||||
|
||||
[msg setObject: [self messagePriority] forKey: @"Priority"];
|
||||
// Priority
|
||||
[msg addObject: [self messagePriority]];
|
||||
|
||||
// Date
|
||||
msgDate = [self messageDate];
|
||||
if (msgDate == nil)
|
||||
msgDate = @"";
|
||||
[msg setObject: msgDate forKey: @"Date"];
|
||||
[msg addObject: msgDate];
|
||||
|
||||
[msg setObject: [self messageSize] forKey: @"Size"];
|
||||
// Size
|
||||
[msg addObject: [self messageSize]];
|
||||
|
||||
[msg setObject: [self msgLabels] forKey: @"labels"];
|
||||
// rowClasses
|
||||
[msg addObject: [self messageRowStyleClass]];
|
||||
|
||||
[msg setObject: [self msgRowID] forKey: @"rowID"];
|
||||
// labels
|
||||
[msg addObject: [self msgLabels]];
|
||||
|
||||
[msg setObject: [message objectForKey: @"uid"] forKey: @"uid"];
|
||||
// rowID
|
||||
[msg addObject: [self msgRowID]];
|
||||
|
||||
// uid
|
||||
[msg addObject: [message objectForKey: @"uid"]];
|
||||
|
||||
[headers addObject: msg];
|
||||
|
||||
[self setMessage: [msgsList nextObject]];
|
||||
}
|
||||
|
||||
return headers;
|
||||
}
|
||||
|
||||
- (id <WOActionResults>) getHeadersAction
|
||||
{
|
||||
NSArray *uids, *headers;
|
||||
WORequest *request;
|
||||
WOResponse *response;
|
||||
|
||||
request = [context request];
|
||||
if ([request formValueForKey: @"uids"] == nil)
|
||||
{
|
||||
return [NSException exceptionWithHTTPStatus: 404
|
||||
reason: @"No UID specified"];
|
||||
}
|
||||
|
||||
uids = [[request formValueForKey: @"uids"] componentsSeparatedByString: @","]; // Should we support ranges? ie "x-y"
|
||||
headers = [self getHeadersForUIDs: uids
|
||||
inFolder: [self clientObject]];
|
||||
response = [context response];
|
||||
[response setHeader: @"text/plain; charset=utf-8"
|
||||
forKey: @"content-type"];
|
||||
|
||||
@@ -23,6 +23,8 @@
|
||||
#import <Foundation/NSEnumerator.h>
|
||||
#import <Foundation/NSValue.h>
|
||||
|
||||
#import <EOControl/EOQualifier.h>
|
||||
|
||||
#import <NGCards/NGVCard.h>
|
||||
#import <NGCards/NGVCardReference.h>
|
||||
#import <NGCards/NGVList.h>
|
||||
@@ -42,6 +44,7 @@
|
||||
#import <Mailer/SOGoMailObject.h>
|
||||
#import <Mailer/SOGoMailAccount.h>
|
||||
#import <Mailer/SOGoMailAccounts.h>
|
||||
#import <Mailer/SOGoMailFolder.h>
|
||||
#import <SOGo/NSDictionary+URL.h>
|
||||
#import <SOGo/NSArray+Utilities.h>
|
||||
#import <SOGo/NSString+Utilities.h>
|
||||
@@ -54,6 +57,7 @@
|
||||
#import <SOGoUI/UIxComponent.h>
|
||||
|
||||
#import "UIxMailMainFrame.h"
|
||||
#import "UIxMailListActions.h"
|
||||
|
||||
// Avoid compilation warnings
|
||||
@interface SOGoUserFolder (private)
|
||||
@@ -173,6 +177,33 @@
|
||||
return [u hasSuffix:@"/"] ? @"view" : @"#";
|
||||
}
|
||||
|
||||
- (NSString *) inboxData
|
||||
{
|
||||
SOGoMailAccounts *accounts;
|
||||
SOGoMailAccount *account;
|
||||
SOGoMailFolder *inbox;
|
||||
|
||||
NSString *firstAccount;
|
||||
NSDictionary *data;
|
||||
SOGoUser *activeUser;
|
||||
UIxMailListActions *actions;
|
||||
|
||||
[self _setupContext];
|
||||
|
||||
actions = [[[UIxMailListActions new] initWithRequest: [context request]] autorelease];
|
||||
activeUser = [context activeUser];
|
||||
accounts = [self clientObject];
|
||||
|
||||
firstAccount = [[[accounts accountKeys] allKeys]
|
||||
objectAtIndex: 0];
|
||||
account = [accounts lookupName: firstAccount inContext: context acquire: NO];
|
||||
inbox = [account inboxFolderInContext: context];
|
||||
|
||||
data = [actions getUIDsAndHeadersInFolder: inbox];
|
||||
|
||||
return [data jsonRepresentation];
|
||||
}
|
||||
|
||||
- (id <WOActionResults>) composeAction
|
||||
{
|
||||
id contact;
|
||||
@@ -333,7 +364,7 @@
|
||||
[self _setupContext];
|
||||
vertical = [moduleSettings objectForKey: @"DragHandleVertical"];
|
||||
|
||||
return ((vertical && [vertical intValue] > 0) ? (id)[vertical stringByAppendingFormat: @"px"] : nil);
|
||||
return ((vertical && [vertical intValue] > 0) ? (id)[vertical stringByAppendingString: @"px"] : nil);
|
||||
}
|
||||
|
||||
- (NSString *) horizontalDragHandleStyle
|
||||
@@ -343,7 +374,7 @@
|
||||
[self _setupContext];
|
||||
horizontal = [moduleSettings objectForKey: @"DragHandleHorizontal"];
|
||||
|
||||
return ((horizontal && [horizontal intValue] > 0) ? (id)[horizontal stringByAppendingFormat: @"px"] : nil);
|
||||
return ((horizontal && [horizontal intValue] > 0) ? (id)[horizontal stringByAppendingString: @"px"] : nil);
|
||||
}
|
||||
|
||||
- (NSString *) mailboxContentStyle
|
||||
|
||||
Reference in New Issue
Block a user