2010-05-27 16:41:59 +02:00
|
|
|
/*
|
|
|
|
Copyright (C) 2004-2005 SKYRIX Software AG
|
2013-11-11 16:49:58 +01:00
|
|
|
Copyright (C) 2006-2013 Inverse inc.
|
2010-05-27 16:41:59 +02:00
|
|
|
|
|
|
|
This file is part of SOGo
|
|
|
|
|
|
|
|
SOGo is free software; you can redistribute it and/or modify it under
|
|
|
|
the terms of the GNU Lesser General Public License as published by the
|
|
|
|
Free Software Foundation; either version 2, or (at your option) any
|
|
|
|
later version.
|
|
|
|
|
|
|
|
SOGo is distributed in the hope that it will be useful, but WITHOUT ANY
|
|
|
|
WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
|
|
|
FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
|
|
|
|
License for more details.
|
|
|
|
|
|
|
|
You should have received a copy of the GNU Lesser General Public
|
|
|
|
License along with OGo; see the file COPYING. If not, write to the
|
|
|
|
Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA
|
|
|
|
02111-1307, USA.
|
|
|
|
*/
|
|
|
|
|
|
|
|
/*
|
|
|
|
UIxMailListActions
|
|
|
|
|
|
|
|
This component represent a list of mails and is attached to an SOGoMailFolder
|
|
|
|
object.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#import <Foundation/NSCalendarDate.h>
|
|
|
|
#import <Foundation/NSCharacterSet.h>
|
|
|
|
#import <Foundation/NSDictionary.h>
|
|
|
|
#import <Foundation/NSEnumerator.h>
|
|
|
|
#import <Foundation/NSTimeZone.h>
|
|
|
|
#import <Foundation/NSValue.h>
|
|
|
|
|
2010-05-27 19:09:02 +02:00
|
|
|
#import <NGObjWeb/WOContext+SoObjects.h>
|
2010-05-27 16:41:59 +02:00
|
|
|
#import <NGObjWeb/WOResponse.h>
|
|
|
|
#import <NGObjWeb/WORequest.h>
|
|
|
|
#import <NGObjWeb/SoObject+SoDAV.h>
|
|
|
|
#import <NGObjWeb/NSException+HTTP.h>
|
|
|
|
#import <NGExtensions/NSNull+misc.h>
|
|
|
|
#import <NGExtensions/NSString+misc.h>
|
|
|
|
#import <NGExtensions/NSObject+Logs.h>
|
|
|
|
#import <NGImap4/NGImap4Envelope.h>
|
|
|
|
|
|
|
|
#import <EOControl/EOQualifier.h>
|
|
|
|
|
|
|
|
#import <Mailer/NSString+Mail.h>
|
|
|
|
#import <Mailer/SOGoDraftsFolder.h>
|
2011-07-07 15:58:50 +02:00
|
|
|
#import <Mailer/SOGoMailAccount.h>
|
2010-05-27 16:41:59 +02:00
|
|
|
#import <Mailer/SOGoMailFolder.h>
|
|
|
|
#import <Mailer/SOGoMailObject.h>
|
|
|
|
#import <Mailer/SOGoSentFolder.h>
|
|
|
|
#import <SOGo/NSArray+Utilities.h>
|
|
|
|
#import <SOGo/NSDictionary+Utilities.h>
|
2014-08-11 15:25:09 +02:00
|
|
|
#import <SOGo/NSString+Utilities.h>
|
2010-05-27 16:41:59 +02:00
|
|
|
#import <SOGo/SOGoDateFormatter.h>
|
|
|
|
#import <SOGo/SOGoUser.h>
|
|
|
|
#import <SOGo/SOGoUserDefaults.h>
|
2012-10-22 16:09:13 +02:00
|
|
|
#import <SOGo/SOGoUserSettings.h>
|
2010-05-27 16:41:59 +02:00
|
|
|
|
2010-05-27 19:09:02 +02:00
|
|
|
#import <UI/Common/WODirectAction+SOGo.h>
|
2013-12-18 14:38:03 +01:00
|
|
|
#import <UI/MailPartViewers/UIxMailSizeFormatter.h>
|
2010-05-27 16:41:59 +02:00
|
|
|
|
2010-05-27 19:09:02 +02:00
|
|
|
#import "WOContext+UIxMailer.h"
|
2010-05-27 23:56:04 +02:00
|
|
|
#import "UIxMailFormatter.h"
|
|
|
|
|
2010-05-27 16:41:59 +02:00
|
|
|
#import "UIxMailListActions.h"
|
|
|
|
|
2010-06-25 21:58:30 +02:00
|
|
|
// The maximum number of headers to prefetch when querying the UIDs list
|
|
|
|
#define headersPrefetchMaxSize 100
|
|
|
|
|
2010-05-27 16:41:59 +02:00
|
|
|
@implementation UIxMailListActions
|
|
|
|
|
2010-05-27 19:09:02 +02:00
|
|
|
- (id) initWithRequest: (WORequest *) newRequest
|
2010-05-27 16:41:59 +02:00
|
|
|
{
|
|
|
|
SOGoUser *user;
|
|
|
|
|
2010-05-27 19:09:02 +02:00
|
|
|
if ((self = [super initWithRequest: newRequest]))
|
2010-05-27 16:41:59 +02:00
|
|
|
{
|
2010-05-27 19:09:02 +02:00
|
|
|
user = [[self context] activeUser];
|
2010-05-27 16:41:59 +02:00
|
|
|
ASSIGN (dateFormatter, [user dateFormatterInContext: context]);
|
|
|
|
ASSIGN (userTimeZone, [[user userDefaults] timeZone]);
|
2011-06-01 23:10:25 +02:00
|
|
|
sortByThread = [[user userDefaults] mailSortByThreads];
|
2010-05-27 16:41:59 +02:00
|
|
|
folderType = 0;
|
|
|
|
specificMessageNumber = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
return self;
|
|
|
|
}
|
|
|
|
|
|
|
|
- (void) dealloc
|
|
|
|
{
|
|
|
|
[sortedUIDs release];
|
|
|
|
[messages release];
|
|
|
|
[message release];
|
|
|
|
[dateFormatter release];
|
|
|
|
[userTimeZone release];
|
|
|
|
[super dealloc];
|
|
|
|
}
|
|
|
|
|
|
|
|
/* accessors */
|
|
|
|
|
|
|
|
- (void) setMessage: (id) _msg
|
|
|
|
{
|
|
|
|
ASSIGN (message, _msg);
|
|
|
|
}
|
|
|
|
|
|
|
|
- (id) message
|
|
|
|
{
|
|
|
|
return message;
|
|
|
|
}
|
|
|
|
|
|
|
|
- (NSString *) messageDate
|
|
|
|
{
|
|
|
|
NSCalendarDate *messageDate;
|
|
|
|
|
|
|
|
messageDate = [[message valueForKey: @"envelope"] date];
|
|
|
|
[messageDate setTimeZone: userTimeZone];
|
|
|
|
|
|
|
|
return [dateFormatter formattedDateAndTime: messageDate];
|
|
|
|
}
|
|
|
|
|
2013-12-18 14:38:03 +01:00
|
|
|
- (UIxMailSizeFormatter *) sizeFormatter
|
2010-05-27 16:41:59 +02:00
|
|
|
{
|
2013-12-18 14:38:03 +01:00
|
|
|
return [UIxMailSizeFormatter sharedMailSizeFormatter];
|
2010-05-27 16:41:59 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
//
|
|
|
|
// Priorities are defined like this:
|
|
|
|
//
|
|
|
|
// X-Priority: 1 (Highest)
|
|
|
|
// X-Priority: 2 (High)
|
|
|
|
// X-Priority: 3 (Normal)
|
|
|
|
// X-Priority: 4 (Low)
|
|
|
|
// X-Priority: 5 (Lowest)
|
|
|
|
//
|
|
|
|
// Sometimes, the MUAs don't send over the string in () so we ignore it.
|
|
|
|
//
|
|
|
|
- (NSString *) messagePriority
|
|
|
|
{
|
|
|
|
NSString *result;
|
|
|
|
NSData *data;
|
|
|
|
|
|
|
|
data = [message objectForKey: @"header"];
|
|
|
|
result = @"";
|
|
|
|
|
|
|
|
if (data)
|
|
|
|
{
|
|
|
|
NSString *s;
|
|
|
|
|
|
|
|
s = [[NSString alloc] initWithData: data
|
|
|
|
encoding: NSASCIIStringEncoding];
|
|
|
|
|
|
|
|
if (s)
|
|
|
|
{
|
|
|
|
NSRange r;
|
|
|
|
|
|
|
|
[s autorelease];
|
|
|
|
r = [s rangeOfString: @":"];
|
|
|
|
|
|
|
|
if (r.length)
|
|
|
|
{
|
|
|
|
s = [[s substringFromIndex: r.location+1]
|
|
|
|
stringByTrimmingCharactersInSet: [NSCharacterSet whitespaceAndNewlineCharacterSet]];
|
|
|
|
|
|
|
|
if ([s hasPrefix: @"1"]) result = [self labelForKey: @"highest"];
|
|
|
|
else if ([s hasPrefix: @"2"]) result = [self labelForKey: @"high"];
|
|
|
|
else if ([s hasPrefix: @"4"]) result = [self labelForKey: @"low"];
|
|
|
|
else if ([s hasPrefix: @"5"]) result = [self labelForKey: @"lowest"];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
|
|
|
- (NSString *) messageSubject
|
|
|
|
{
|
|
|
|
id baseSubject;
|
|
|
|
NSString *subject;
|
|
|
|
|
|
|
|
baseSubject = [[message valueForKey: @"envelope"] subject];
|
|
|
|
subject = [baseSubject decodedHeader];
|
|
|
|
if (![subject length])
|
2012-05-29 16:20:06 +02:00
|
|
|
subject = @"";
|
2010-05-27 16:41:59 +02:00
|
|
|
|
2014-09-29 20:28:13 +02:00
|
|
|
return [[subject safeString] stringByEscapingHTMLString];
|
2010-05-27 16:41:59 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
- (BOOL) showToAddress
|
|
|
|
{
|
|
|
|
SOGoMailFolder *co;
|
|
|
|
|
|
|
|
if (!folderType)
|
|
|
|
{
|
|
|
|
co = [self clientObject];
|
|
|
|
if ([co isKindOfClass: [SOGoSentFolder class]]
|
|
|
|
|| [co isKindOfClass: [SOGoDraftsFolder class]])
|
|
|
|
folderType = 1;
|
|
|
|
else
|
|
|
|
folderType = -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
return (folderType == 1);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* title */
|
|
|
|
|
|
|
|
- (NSString *) objectTitle
|
|
|
|
{
|
|
|
|
return [[self clientObject] nameInContainer];
|
|
|
|
}
|
|
|
|
|
|
|
|
- (NSString *) panelTitle
|
|
|
|
{
|
|
|
|
NSString *s;
|
|
|
|
|
|
|
|
s = [self labelForKey:@"View Mail Folder"];
|
|
|
|
s = [s stringByAppendingString:@": "];
|
|
|
|
s = [s stringByAppendingString:[self objectTitle]];
|
|
|
|
return s;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* derived accessors */
|
|
|
|
|
|
|
|
- (BOOL) isMessageDeleted
|
|
|
|
{
|
|
|
|
NSArray *flags;
|
|
|
|
|
|
|
|
flags = [[self message] valueForKey:@"flags"];
|
|
|
|
return [flags containsObject:@"deleted"];
|
|
|
|
}
|
|
|
|
|
|
|
|
- (BOOL) isMessageRead
|
|
|
|
{
|
|
|
|
NSArray *flags;
|
|
|
|
|
|
|
|
flags = [[self message] valueForKey:@"flags"];
|
|
|
|
return [flags containsObject:@"seen"];
|
|
|
|
}
|
|
|
|
|
|
|
|
- (BOOL) isMessageFlagged
|
|
|
|
{
|
|
|
|
NSArray *flags;
|
|
|
|
|
|
|
|
flags = [[self message] valueForKey:@"flags"];
|
|
|
|
return [flags containsObject:@"flagged"];
|
|
|
|
}
|
|
|
|
|
|
|
|
- (NSString *) messageUidString
|
|
|
|
{
|
|
|
|
return [[[self message] valueForKey:@"uid"] stringValue];
|
|
|
|
}
|
|
|
|
|
|
|
|
- (NSString *) messageRowStyleClass
|
|
|
|
{
|
|
|
|
NSArray *flags;
|
|
|
|
NSString *cellClass = @"";
|
|
|
|
|
|
|
|
flags = [[self message] valueForKey:@"flags"];
|
|
|
|
|
|
|
|
if ([self isMessageDeleted])
|
|
|
|
cellClass = [cellClass stringByAppendingString: @"mailer_listcell_deleted "];
|
|
|
|
|
|
|
|
if (![self isMessageRead])
|
|
|
|
cellClass = [cellClass stringByAppendingString: @"mailer_unreadmail "];
|
|
|
|
|
|
|
|
if ([flags containsObject: @"answered"])
|
|
|
|
{
|
|
|
|
if ([flags containsObject: @"$forwarded"])
|
|
|
|
cellClass = [cellClass stringByAppendingString: @"mailer_forwardedrepliedmailsubject"];
|
|
|
|
else
|
|
|
|
cellClass = [cellClass stringByAppendingString: @"mailer_repliedmailsubject"];
|
|
|
|
}
|
|
|
|
else if ([flags containsObject: @"$forwarded"])
|
|
|
|
cellClass = [cellClass stringByAppendingString: @"mailer_forwardedmailsubject"];
|
|
|
|
else
|
|
|
|
cellClass = [cellClass stringByAppendingString: @"mailer_readmailsubject"];
|
|
|
|
|
|
|
|
return cellClass;
|
|
|
|
}
|
|
|
|
|
|
|
|
- (BOOL) hasMessageAttachment
|
|
|
|
{
|
|
|
|
NSArray *parts;
|
|
|
|
NSEnumerator *dispositions;
|
|
|
|
NSDictionary *currentDisp;
|
|
|
|
BOOL hasAttachment;
|
|
|
|
|
|
|
|
hasAttachment = NO;
|
|
|
|
|
2012-10-06 18:19:30 +02:00
|
|
|
parts = [[message objectForKey: @"bodystructure"] objectForKey: @"parts"];
|
2010-05-27 16:41:59 +02:00
|
|
|
if ([parts count] > 1)
|
|
|
|
{
|
|
|
|
dispositions = [[parts objectsForKey: @"disposition"
|
|
|
|
notFoundMarker: nil] objectEnumerator];
|
|
|
|
while (!hasAttachment
|
|
|
|
&& (currentDisp = [dispositions nextObject]))
|
|
|
|
hasAttachment = ([[currentDisp objectForKey: @"type"] length]);
|
|
|
|
}
|
|
|
|
|
|
|
|
return hasAttachment;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* fetching messages */
|
|
|
|
|
|
|
|
- (NSArray *) fetchKeys
|
|
|
|
{
|
|
|
|
/* Note: see SOGoMailManager.m for allowed IMAP4 keys */
|
|
|
|
static NSArray *keys = nil;
|
|
|
|
|
|
|
|
if (!keys)
|
|
|
|
keys = [[NSArray alloc] initWithObjects: @"UID",
|
|
|
|
@"FLAGS", @"ENVELOPE", @"RFC822.SIZE",
|
|
|
|
@"BODYSTRUCTURE", @"BODY.PEEK[HEADER.FIELDS (X-PRIORITY)]", nil];
|
|
|
|
return keys;
|
|
|
|
}
|
|
|
|
|
2010-05-28 21:18:52 +02:00
|
|
|
- (NSString *) defaultSortKey
|
2010-05-27 16:41:59 +02:00
|
|
|
{
|
|
|
|
return @"ARRIVAL";
|
|
|
|
}
|
|
|
|
|
|
|
|
- (NSString *) imap4SortOrdering
|
|
|
|
{
|
2014-08-13 23:41:58 +02:00
|
|
|
WORequest *request;
|
|
|
|
NSString *sort, *module;
|
2010-05-28 21:18:52 +02:00
|
|
|
NSMutableDictionary *moduleSettings;
|
2014-08-06 20:49:36 +02:00
|
|
|
NSDictionary *urlParams, *sortingAttributes;
|
2010-05-28 21:18:52 +02:00
|
|
|
SOGoUser *activeUser;
|
|
|
|
SOGoUserSettings *us;
|
2014-08-13 23:41:58 +02:00
|
|
|
BOOL asc;
|
2010-05-27 16:41:59 +02:00
|
|
|
|
2014-08-06 20:49:36 +02:00
|
|
|
request = [context request];
|
|
|
|
urlParams = [[request contentAsString] objectFromJSONString];
|
|
|
|
sortingAttributes = [urlParams objectForKey:@"sortingAttributes"];
|
2014-08-13 23:41:58 +02:00
|
|
|
sort = [[sortingAttributes objectForKey:@"sort"] uppercaseString];
|
2014-08-06 20:49:36 +02:00
|
|
|
asc = [[sortingAttributes objectForKey:@"asc"] boolValue];
|
2010-05-28 21:18:52 +02:00
|
|
|
|
2010-06-25 21:58:30 +02:00
|
|
|
activeUser = [context activeUser];
|
2011-03-22 01:30:26 +01:00
|
|
|
module = @"Mail";
|
2010-06-25 21:58:30 +02:00
|
|
|
us = [activeUser userSettings];
|
|
|
|
moduleSettings = [us objectForKey: module];
|
|
|
|
|
2011-03-22 01:30:26 +01:00
|
|
|
if ([sort length])
|
2010-06-25 21:58:30 +02:00
|
|
|
{
|
2011-03-22 01:30:26 +01:00
|
|
|
if ([sort isEqualToString: [self defaultSortKey]] && !asc)
|
|
|
|
{
|
|
|
|
if (moduleSettings)
|
|
|
|
{
|
|
|
|
[moduleSettings removeObjectForKey: @"SortingState"];
|
|
|
|
[us synchronize];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
// Save the sorting state in the user settings
|
|
|
|
if (!moduleSettings)
|
|
|
|
{
|
|
|
|
moduleSettings = [NSMutableDictionary dictionary];
|
|
|
|
[us setObject: moduleSettings forKey: module];
|
|
|
|
}
|
|
|
|
[moduleSettings setObject: [NSArray arrayWithObjects: [sort lowercaseString], [NSString stringWithFormat: @"%d", (asc?1:0)], nil]
|
|
|
|
forKey: @"SortingState"];
|
|
|
|
[us synchronize];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (moduleSettings)
|
|
|
|
{
|
|
|
|
NSArray *sortState = [moduleSettings objectForKey: @"SortingState"];
|
2011-03-23 22:59:22 +01:00
|
|
|
if ([sortState count])
|
|
|
|
{
|
|
|
|
sort = [[sortState objectAtIndex: 0] uppercaseString];
|
|
|
|
asc = [[sortState objectAtIndex: 1] boolValue];
|
|
|
|
}
|
2011-03-22 01:30:26 +01:00
|
|
|
}
|
2011-03-23 22:59:22 +01:00
|
|
|
if (![sort length])
|
2011-03-22 01:30:26 +01:00
|
|
|
sort = [self defaultSortKey];
|
|
|
|
|
2010-05-28 21:18:52 +02:00
|
|
|
// Construct and return the final IMAP ordering constraint
|
|
|
|
if (!asc)
|
2010-05-27 16:41:59 +02:00
|
|
|
sort = [@"REVERSE " stringByAppendingString: sort];
|
|
|
|
|
|
|
|
return sort;
|
|
|
|
}
|
|
|
|
|
|
|
|
- (EOQualifier *) searchQualifier
|
|
|
|
{
|
2014-08-06 20:49:36 +02:00
|
|
|
EOQualifier *qualifier, *searchQualifier;
|
|
|
|
WORequest *request;
|
2014-08-11 15:25:09 +02:00
|
|
|
NSDictionary *sortingAttributes, *content;
|
|
|
|
NSArray *filters;
|
2014-08-06 20:49:36 +02:00
|
|
|
NSString *searchBy, *searchArgument, *searchInput, *searchString, *match;
|
|
|
|
NSMutableArray *searchArray;
|
2014-08-13 23:41:58 +02:00
|
|
|
int nbFilters = 0, i;
|
2014-08-06 20:49:36 +02:00
|
|
|
|
2010-05-27 16:41:59 +02:00
|
|
|
request = [context request];
|
2014-08-06 20:49:36 +02:00
|
|
|
content = [[request contentAsString] objectFromJSONString];
|
2010-05-27 16:41:59 +02:00
|
|
|
qualifier = nil;
|
2014-08-06 20:49:36 +02:00
|
|
|
searchString = nil;
|
|
|
|
|
|
|
|
if ([content objectForKey:@"filters"])
|
2010-05-27 16:41:59 +02:00
|
|
|
{
|
2014-08-06 20:49:36 +02:00
|
|
|
filters = [content objectForKey:@"filters"];
|
|
|
|
sortingAttributes = [content objectForKey:@"sortingAttributes"];
|
|
|
|
nbFilters = [filters count];
|
|
|
|
match = [NSString stringWithString:[sortingAttributes objectForKey:@"match"]]; // AND, OR
|
|
|
|
|
2014-08-13 23:41:58 +02:00
|
|
|
searchArray = [NSMutableArray arrayWithCapacity:nbFilters];
|
2014-08-06 20:49:36 +02:00
|
|
|
for (i = 0; i < nbFilters; i++)
|
|
|
|
{
|
|
|
|
searchBy = [NSString stringWithString:[[filters objectAtIndex:i] objectForKey:@"searchBy"]];
|
|
|
|
searchArgument = [NSString stringWithString:[[filters objectAtIndex:i] objectForKey:@"searchArgument"]];
|
|
|
|
searchInput = [NSString stringWithString:[[filters objectAtIndex:i] objectForKey:@"searchInput"]];
|
2014-08-11 15:25:09 +02:00
|
|
|
|
|
|
|
if ([[[filters objectAtIndex:i] objectForKey:@"negative"] boolValue])
|
|
|
|
searchString = [NSString stringWithFormat:@"(not (%@ %@: '%@'))", searchBy, searchArgument, searchInput];
|
|
|
|
else
|
|
|
|
searchString = [NSString stringWithFormat:@"(%@ %@: '%@')", searchBy, searchArgument, searchInput];
|
|
|
|
|
2014-08-06 20:49:36 +02:00
|
|
|
searchQualifier = [EOQualifier qualifierWithQualifierFormat:searchString];
|
|
|
|
[searchArray addObject:searchQualifier];
|
|
|
|
}
|
|
|
|
if ([match isEqualToString:@"OR"])
|
|
|
|
qualifier = [[EOOrQualifier alloc] initWithQualifierArray: searchArray];
|
|
|
|
else
|
|
|
|
qualifier = [[EOAndQualifier alloc] initWithQualifierArray: searchArray];
|
|
|
|
}
|
2014-08-13 23:41:58 +02:00
|
|
|
|
2010-05-27 16:41:59 +02:00
|
|
|
return qualifier;
|
|
|
|
}
|
|
|
|
|
2010-06-25 21:58:30 +02:00
|
|
|
- (NSArray *) getSortedUIDsInFolder: (SOGoMailFolder *) mailFolder
|
2010-05-27 16:41:59 +02:00
|
|
|
{
|
|
|
|
EOQualifier *qualifier, *fetchQualifier, *notDeleted;
|
2014-08-13 23:41:58 +02:00
|
|
|
|
2010-05-27 16:41:59 +02:00
|
|
|
if (!sortedUIDs)
|
|
|
|
{
|
2014-08-06 20:49:36 +02:00
|
|
|
notDeleted = [EOQualifier qualifierWithQualifierFormat: @"(not (flags = %@))", @"deleted"];
|
2010-05-27 16:41:59 +02:00
|
|
|
qualifier = [self searchQualifier];
|
|
|
|
if (qualifier)
|
2014-08-06 20:49:36 +02:00
|
|
|
{
|
|
|
|
fetchQualifier = [[EOAndQualifier alloc] initWithQualifiers: notDeleted, qualifier, nil];
|
|
|
|
[fetchQualifier autorelease];
|
|
|
|
}
|
2010-05-27 16:41:59 +02:00
|
|
|
else
|
2014-08-06 20:49:36 +02:00
|
|
|
fetchQualifier = notDeleted;
|
|
|
|
|
|
|
|
sortedUIDs = [mailFolder fetchUIDsMatchingQualifier: fetchQualifier
|
|
|
|
sortOrdering: [self imap4SortOrdering]
|
|
|
|
threaded: sortByThread];
|
|
|
|
|
2010-05-27 16:41:59 +02:00
|
|
|
[sortedUIDs retain];
|
|
|
|
}
|
2014-08-13 23:41:58 +02:00
|
|
|
|
2010-05-27 16:41:59 +02:00
|
|
|
return sortedUIDs;
|
|
|
|
}
|
|
|
|
|
2011-06-01 23:10:25 +02:00
|
|
|
/**
|
2014-08-14 20:49:44 +02:00
|
|
|
* Returns a
|
|
|
|
of the messages threads as triples of
|
2011-06-01 23:10:25 +02:00
|
|
|
* metadata, including the message UID, thread level and root position.
|
|
|
|
* @param _sortedUIDs the interleaved arrays representation of the messages UIDs
|
|
|
|
* @return an flatten array representation of the messages UIDs
|
|
|
|
*/
|
|
|
|
- (NSArray *) threadedUIDs: (NSArray *) _sortedUIDs
|
|
|
|
{
|
|
|
|
NSMutableArray *threads;
|
|
|
|
NSMutableArray *currentThreads;
|
|
|
|
NSEnumerator *rootThreads;
|
|
|
|
id thread;
|
|
|
|
int count;
|
|
|
|
int i;
|
|
|
|
BOOL first;
|
|
|
|
BOOL expected;
|
|
|
|
int previousLevel;
|
|
|
|
|
|
|
|
count = 0;
|
|
|
|
i = 0;
|
|
|
|
previousLevel = 0;
|
|
|
|
expected = YES;
|
|
|
|
threads = [NSMutableArray arrayWithObject: [NSArray arrayWithObjects: @"uid", @"level", @"first", nil]];
|
|
|
|
rootThreads = [_sortedUIDs objectEnumerator];
|
|
|
|
thread = [rootThreads nextObject];
|
|
|
|
|
|
|
|
// Make sure rootThreads starts with an NSArray
|
|
|
|
if (![thread respondsToSelector: @selector(objectEnumerator)])
|
|
|
|
return nil;
|
|
|
|
|
|
|
|
first = [thread count] > 1;
|
|
|
|
thread = [thread objectEnumerator];
|
|
|
|
|
|
|
|
currentThreads = [NSMutableArray array];
|
|
|
|
|
|
|
|
while (thread)
|
|
|
|
{
|
|
|
|
unsigned int ecount = 0;
|
|
|
|
id t;
|
|
|
|
|
|
|
|
if ([thread isKindOfClass: [NSEnumerator class]])
|
|
|
|
{
|
|
|
|
t = [thread nextObject];
|
|
|
|
}
|
|
|
|
else
|
|
|
|
t = thread; // never happen?
|
|
|
|
while (t && ![t isKindOfClass: [NSArray class]])
|
|
|
|
{
|
|
|
|
BOOL currentFirst;
|
|
|
|
int currentLevel;
|
|
|
|
NSArray *currentThread;
|
|
|
|
|
|
|
|
currentFirst = (first && ecount == 0) || (i == 0 && count > 0) || (count > 0 && previousLevel < 0);
|
|
|
|
currentLevel = (first && ecount == 0)? 0 : (count > 0? count : -1);
|
|
|
|
currentThread = [NSArray arrayWithObjects: t,
|
|
|
|
[NSNumber numberWithInt: currentLevel],
|
|
|
|
[NSNumber numberWithInt: currentFirst], nil];
|
|
|
|
[threads addObject: currentThread];
|
|
|
|
i++;
|
|
|
|
count++;
|
|
|
|
ecount++;
|
|
|
|
expected = NO;
|
|
|
|
previousLevel = currentLevel;
|
|
|
|
t = [thread nextObject];
|
|
|
|
}
|
|
|
|
if (t)
|
|
|
|
{
|
|
|
|
// If t is defined, it has to be an NSArray
|
|
|
|
if (expected)
|
|
|
|
{
|
|
|
|
count++;
|
|
|
|
expected = NO;
|
|
|
|
}
|
|
|
|
thread = [thread allObjects];
|
|
|
|
if ([thread count] > 0)
|
|
|
|
[currentThreads addObject: [thread objectEnumerator]];
|
|
|
|
thread = [t objectEnumerator];
|
|
|
|
}
|
|
|
|
else if ([currentThreads count] > 0)
|
|
|
|
{
|
|
|
|
thread = [currentThreads objectAtIndex: 0];
|
|
|
|
[currentThreads removeObjectAtIndex: 0];
|
|
|
|
count -= ecount;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
thread = [[rootThreads nextObject] objectEnumerator]; // assume all objects of rootThreads are NSArrays
|
|
|
|
count = 0;
|
|
|
|
expected = YES;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Prepare next iteration
|
|
|
|
thread = [thread allObjects];
|
|
|
|
first = !first && (thread != nil) && [thread count] > 1;
|
|
|
|
thread = [thread objectEnumerator];
|
|
|
|
}
|
|
|
|
|
|
|
|
return threads;
|
|
|
|
}
|
|
|
|
|
2010-05-27 16:41:59 +02:00
|
|
|
- (int) indexOfMessageUID: (int) messageNbr
|
|
|
|
{
|
|
|
|
NSArray *messageNbrs;
|
|
|
|
int index;
|
|
|
|
|
2010-06-25 21:58:30 +02:00
|
|
|
messageNbrs = [self getSortedUIDsInFolder: [self clientObject]];
|
2010-05-27 16:41:59 +02:00
|
|
|
index
|
|
|
|
= [messageNbrs indexOfObject: [NSNumber numberWithInt: messageNbr]];
|
|
|
|
// if (index < 0)
|
|
|
|
// index = 0;
|
|
|
|
|
|
|
|
return index;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* JavaScript */
|
|
|
|
|
|
|
|
- (NSString *) msgRowID
|
|
|
|
{
|
|
|
|
return [@"row_" stringByAppendingString:[self messageUidString]];
|
|
|
|
}
|
|
|
|
|
|
|
|
- (NSString *) msgIconReadImgID
|
|
|
|
{
|
|
|
|
return [@"readdiv_" stringByAppendingString:[self messageUidString]];
|
|
|
|
}
|
|
|
|
|
|
|
|
- (NSString *) msgIconUnreadImgID
|
|
|
|
{
|
|
|
|
return [@"unreaddiv_" stringByAppendingString:[self messageUidString]];
|
|
|
|
}
|
|
|
|
|
|
|
|
/* error redirects */
|
|
|
|
|
|
|
|
/*
|
|
|
|
- (id) redirectToViewWithError: (id) _error
|
|
|
|
{
|
|
|
|
// TODO: DUP in UIxMailAccountView
|
|
|
|
// TODO: improve, localize
|
|
|
|
// TODO: there is a bug in the treeview which preserves the current URL for
|
|
|
|
// the active object (displaying the error again)
|
|
|
|
id url;
|
|
|
|
|
|
|
|
if (![_error isNotNull])
|
|
|
|
return [self redirectToLocation:@"view"];
|
|
|
|
|
|
|
|
if ([_error isKindOfClass:[NSException class]])
|
|
|
|
_error = [_error reason];
|
|
|
|
else if ([_error isKindOfClass:[NSString class]])
|
|
|
|
_error = [_error stringValue];
|
|
|
|
|
|
|
|
url = [_error stringByEscapingURL];
|
|
|
|
url = [@"view?error=" stringByAppendingString:url];
|
|
|
|
return [self redirectToLocation:url];
|
|
|
|
}
|
|
|
|
*/
|
|
|
|
|
2011-07-08 19:38:27 +02:00
|
|
|
- (NSDictionary *) getUIDsInFolder: (SOGoMailFolder *) folder
|
|
|
|
withHeaders: (BOOL) includeHeaders
|
2010-05-27 16:41:59 +02:00
|
|
|
{
|
2011-07-08 19:38:27 +02:00
|
|
|
NSMutableDictionary *data;
|
2011-06-01 23:10:25 +02:00
|
|
|
NSArray *uids, *threadedUids, *headers;
|
2010-05-27 16:41:59 +02:00
|
|
|
NSRange r;
|
2011-07-07 15:58:50 +02:00
|
|
|
SOGoMailAccount *account;
|
|
|
|
id quota;
|
2011-07-08 19:38:27 +02:00
|
|
|
int count;
|
|
|
|
|
|
|
|
data = [NSMutableDictionary dictionary];
|
2010-05-27 16:41:59 +02:00
|
|
|
|
2011-07-08 19:38:27 +02:00
|
|
|
// TODO: we might want to flush the caches?
|
|
|
|
//[folder flushMailCaches];
|
|
|
|
[folder expungeLastMarkedFolder];
|
|
|
|
|
|
|
|
// Retrieve messages UIDs using form parameters "sort" and "asc"
|
|
|
|
uids = [self getSortedUIDsInFolder: folder];
|
2014-08-14 20:49:44 +02:00
|
|
|
|
|
|
|
// Get rid of the extra parenthesis
|
|
|
|
// uids = [[[[uids stringValue] stringByReplacingOccurrencesOfString:@"(" withString:@""] stringByReplacingOccurrencesOfString:@")" withString:@""] componentsSeparatedByString:@","];
|
2011-07-08 19:38:27 +02:00
|
|
|
|
|
|
|
if (includeHeaders)
|
|
|
|
{
|
|
|
|
// Also retrieve the first headers, up to 'headersPrefetchMaxSize'
|
2014-08-14 20:49:44 +02:00
|
|
|
count = [[uids flattenedArray] count];
|
2011-07-08 19:38:27 +02:00
|
|
|
if (count > headersPrefetchMaxSize) count = headersPrefetchMaxSize;
|
|
|
|
r = NSMakeRange(0, count);
|
|
|
|
headers = [self getHeadersForUIDs: [[uids flattenedArray] subarrayWithRange: r]
|
|
|
|
inFolder: folder];
|
|
|
|
|
|
|
|
[data setObject: headers forKey: @"headers"];
|
|
|
|
}
|
|
|
|
|
2011-06-01 23:10:25 +02:00
|
|
|
if (sortByThread)
|
|
|
|
{
|
2011-07-08 19:38:27 +02:00
|
|
|
// Add threads information
|
2011-06-01 23:10:25 +02:00
|
|
|
threadedUids = [self threadedUIDs: uids];
|
|
|
|
if (threadedUids != nil)
|
|
|
|
uids = threadedUids;
|
|
|
|
else
|
|
|
|
sortByThread = NO;
|
|
|
|
}
|
2011-07-26 18:25:34 +02:00
|
|
|
if (uids != nil)
|
|
|
|
[data setObject: uids forKey: @"uids"];
|
2011-07-08 19:38:27 +02:00
|
|
|
[data setObject: [NSNumber numberWithBool: sortByThread] forKey: @"threaded"];
|
|
|
|
|
2011-07-07 15:58:50 +02:00
|
|
|
// We also return the inbox quota
|
2011-07-08 19:38:27 +02:00
|
|
|
account = [folder mailAccountFolder];
|
2011-07-07 15:58:50 +02:00
|
|
|
quota = [account getInboxQuota];
|
2011-07-14 17:26:49 +02:00
|
|
|
if (quota != nil)
|
|
|
|
[data setObject: quota forKey: @"quotas"];
|
2010-05-27 16:41:59 +02:00
|
|
|
|
2010-06-25 21:58:30 +02:00
|
|
|
return data;
|
|
|
|
}
|
2010-05-27 16:41:59 +02:00
|
|
|
|
2011-06-01 23:10:25 +02:00
|
|
|
/* Module actions */
|
|
|
|
|
2011-07-08 19:38:27 +02:00
|
|
|
- (id <WOActionResults>) getUIDsAction
|
2010-06-25 21:58:30 +02:00
|
|
|
{
|
2014-08-13 23:41:58 +02:00
|
|
|
NSDictionary *data, *requestContent;
|
2010-11-05 22:32:00 +01:00
|
|
|
NSString *noHeaders;
|
2010-06-25 21:58:30 +02:00
|
|
|
SOGoMailFolder *folder;
|
2010-11-05 22:32:00 +01:00
|
|
|
WORequest *request;
|
2010-06-25 21:58:30 +02:00
|
|
|
WOResponse *response;
|
2010-05-27 16:41:59 +02:00
|
|
|
|
2010-11-05 22:32:00 +01:00
|
|
|
request = [context request];
|
2010-05-27 16:41:59 +02:00
|
|
|
response = [context response];
|
2014-08-13 23:41:58 +02:00
|
|
|
requestContent = [[request contentAsString] objectFromJSONString];
|
|
|
|
|
2010-05-27 16:41:59 +02:00
|
|
|
[response setHeader: @"text/plain; charset=utf-8"
|
2014-08-13 23:41:58 +02:00
|
|
|
forKey: @"content-type"];
|
2014-08-06 20:49:36 +02:00
|
|
|
|
2010-11-05 22:32:00 +01:00
|
|
|
folder = [self clientObject];
|
2011-07-07 15:58:50 +02:00
|
|
|
|
2014-08-13 23:41:58 +02:00
|
|
|
noHeaders = [[requestContent objectForKey: @"sortingAttributes"] objectForKey:@"no_headers"];
|
2011-07-08 19:38:27 +02:00
|
|
|
data = [self getUIDsInFolder: folder
|
|
|
|
withHeaders: ([noHeaders length] == 0)];
|
2011-06-01 23:10:25 +02:00
|
|
|
|
2010-06-25 21:58:30 +02:00
|
|
|
[response appendContentString: [data jsonRepresentation]];
|
2011-03-15 20:36:25 +01:00
|
|
|
|
2010-05-27 16:41:59 +02:00
|
|
|
return response;
|
|
|
|
}
|
|
|
|
|
2010-06-25 21:58:30 +02:00
|
|
|
- (NSArray *) getHeadersForUIDs: (NSArray *) uids
|
|
|
|
inFolder: (SOGoMailFolder *) mailFolder
|
2010-05-27 16:41:59 +02:00
|
|
|
{
|
2010-06-25 21:58:30 +02:00
|
|
|
NSArray *to, *from;
|
2010-05-27 16:41:59 +02:00
|
|
|
NSDictionary *msgs;
|
2010-06-25 21:58:30 +02:00
|
|
|
NSMutableArray *headers, *msg;
|
2010-05-27 16:41:59 +02:00
|
|
|
NSEnumerator *msgsList;
|
2010-06-07 15:24:17 +02:00
|
|
|
NSString *msgIconStatus, *msgDate;
|
2010-05-27 23:56:04 +02:00
|
|
|
UIxEnvelopeAddressFormatter *addressFormatter;
|
2010-05-27 16:41:59 +02:00
|
|
|
|
|
|
|
headers = [NSMutableArray arrayWithCapacity: [uids count]];
|
|
|
|
addressFormatter = [context mailEnvelopeAddressFormatter];
|
|
|
|
|
|
|
|
// Fetch headers
|
|
|
|
msgs = (NSDictionary *)[mailFolder fetchUIDs: uids
|
|
|
|
parts: [self fetchKeys]];
|
|
|
|
|
|
|
|
msgsList = [[msgs objectForKey: @"fetch"] objectEnumerator];
|
|
|
|
[self setMessage: [msgsList nextObject]];
|
2010-06-25 21:58:30 +02:00
|
|
|
|
|
|
|
msg = [NSMutableArray arrayWithObjects: @"To", @"Attachment", @"Flagged", @"Subject", @"From", @"Unread", @"Priority", @"Date", @"Size", @"rowClasses", @"labels", @"rowID", @"uid", nil];
|
|
|
|
[headers addObject: msg];
|
2010-05-27 16:41:59 +02:00
|
|
|
while (message)
|
|
|
|
{
|
2010-09-15 12:33:07 +02:00
|
|
|
// We must check for "umimportant" untagged responses.
|
|
|
|
//
|
|
|
|
// It's generally caused by IMAP server processes sending untagged IMAP responses to SOGo in differnent IMAP
|
|
|
|
// connections (SOGo might use 2-3 per user). Say you ask your messages:
|
|
|
|
//
|
|
|
|
// 127.000.000.001.40725-127.000.000.001.00143: 59 uid fetch 62 (UID FLAGS ENVELOPE RFC822.SIZE BODYSTRUCTURE BODY.PEEK[HEADER.FIELDS (X-PRIORITY)])
|
|
|
|
// 127.000.000.001.00143-127.000.000.001.40725: * 62 FETCH (UID 62 FLAGS (\Seen) RFC822.SIZE 854 ENVELOPE .... (
|
|
|
|
// * 61 FETCH (FLAGS (\Deleted \Seen))
|
|
|
|
// * 62 FETCH (FLAGS (\Deleted \Seen))
|
|
|
|
// * 63 FETCH (FLAGS (\Deleted \Seen))
|
|
|
|
// 59 OK Fetch completed.
|
|
|
|
//
|
|
|
|
// We must ignore the * 61 .. * 63 untagged responses.
|
|
|
|
//
|
|
|
|
if (![message objectForKey: @"uid"])
|
|
|
|
{
|
|
|
|
[self setMessage: [msgsList nextObject]];
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
2010-06-25 21:58:30 +02:00
|
|
|
msg = [NSMutableArray arrayWithCapacity: 12];
|
2010-05-27 16:41:59 +02:00
|
|
|
|
|
|
|
// Columns data
|
|
|
|
|
2010-06-25 21:58:30 +02:00
|
|
|
// To
|
2010-05-27 16:41:59 +02:00
|
|
|
to = [[message objectForKey: @"envelope"] to];
|
|
|
|
if ([to count] > 0)
|
2013-07-16 17:31:08 +02:00
|
|
|
[msg addObject: [[addressFormatter stringForArray: to] stringByEscapingHTMLString]];
|
2010-06-25 21:58:30 +02:00
|
|
|
else
|
|
|
|
[msg addObject: @""];
|
2010-05-27 16:41:59 +02:00
|
|
|
|
2010-06-25 21:58:30 +02:00
|
|
|
// Attachment
|
2010-05-27 16:41:59 +02:00
|
|
|
if ([self hasMessageAttachment])
|
2010-06-25 21:58:30 +02:00
|
|
|
[msg addObject: [NSString stringWithFormat: @"<img src=\"%@\"/>", [self urlForResourceFilename: @"title_attachment_14x14.png"]]];
|
|
|
|
else
|
|
|
|
[msg addObject: @""];
|
2010-05-27 16:41:59 +02:00
|
|
|
|
2010-06-25 21:58:30 +02:00
|
|
|
// Flagged
|
2010-05-27 16:41:59 +02:00
|
|
|
if ([self isMessageFlagged])
|
2010-06-25 21:58:30 +02:00
|
|
|
[msg addObject: [NSString stringWithFormat: @"<img src=\"%@\" class=\"messageIsFlagged\">",
|
|
|
|
[self urlForResourceFilename: @"flag.png"]]];
|
2010-05-27 16:41:59 +02:00
|
|
|
else
|
2010-06-25 21:58:30 +02:00
|
|
|
[msg addObject: [NSString stringWithFormat: @"<img src=\"%@\">",
|
|
|
|
[self urlForResourceFilename: @"dot.png"]]];
|
2010-05-27 16:41:59 +02:00
|
|
|
|
2010-06-25 21:58:30 +02:00
|
|
|
// Subject
|
|
|
|
[msg addObject: [NSString stringWithFormat: @"<span>%@</span>",
|
|
|
|
[self messageSubject]]];
|
2010-05-27 16:41:59 +02:00
|
|
|
|
2010-06-25 21:58:30 +02:00
|
|
|
// From
|
2010-06-07 15:34:10 +02:00
|
|
|
from = [[message objectForKey: @"envelope"] from];
|
|
|
|
if ([from count] > 0)
|
2013-07-16 17:31:08 +02:00
|
|
|
[msg addObject: [[addressFormatter stringForArray: from] stringByEscapingHTMLString]];
|
2010-06-07 15:34:10 +02:00
|
|
|
else
|
2010-06-25 21:58:30 +02:00
|
|
|
[msg addObject: @""];
|
2010-06-07 15:34:10 +02:00
|
|
|
|
2010-06-25 21:58:30 +02:00
|
|
|
|
|
|
|
// Unread
|
2010-05-27 16:41:59 +02:00
|
|
|
if ([self isMessageRead])
|
|
|
|
msgIconStatus = @"dot.png";
|
|
|
|
else
|
2011-10-24 22:30:08 +02:00
|
|
|
msgIconStatus = @"unread.png";
|
2010-05-27 16:41:59 +02:00
|
|
|
|
2010-06-25 21:58:30 +02:00
|
|
|
[msg addObject: [NSString stringWithFormat: @"<img src=\"%@\" class=\"mailerReadIcon\" title=\"%@\" title-markread=\"%@\" title-markunread=\"%@\" id=\"%@\"/>",
|
2010-05-27 16:41:59 +02:00
|
|
|
[self urlForResourceFilename: msgIconStatus],
|
|
|
|
[self labelForKey: @"Mark Unread"],
|
|
|
|
[self labelForKey: @"Mark Read"],
|
|
|
|
[self labelForKey: @"Mark Unread"],
|
2010-06-25 21:58:30 +02:00
|
|
|
[self msgIconReadImgID]]];
|
2010-05-27 16:41:59 +02:00
|
|
|
|
2010-06-25 21:58:30 +02:00
|
|
|
// Priority
|
|
|
|
[msg addObject: [self messagePriority]];
|
2010-05-27 16:41:59 +02:00
|
|
|
|
2010-06-25 21:58:30 +02:00
|
|
|
// Date
|
2010-06-07 15:24:17 +02:00
|
|
|
msgDate = [self messageDate];
|
|
|
|
if (msgDate == nil)
|
|
|
|
msgDate = @"";
|
2010-06-25 21:58:30 +02:00
|
|
|
[msg addObject: msgDate];
|
2010-05-27 16:41:59 +02:00
|
|
|
|
2010-06-25 21:58:30 +02:00
|
|
|
// Size
|
2013-12-18 14:38:03 +01:00
|
|
|
[msg addObject: [[self sizeFormatter] stringForObjectValue: [message objectForKey: @"size"]]];
|
2010-05-27 16:41:59 +02:00
|
|
|
|
2010-06-25 21:58:30 +02:00
|
|
|
// rowClasses
|
|
|
|
[msg addObject: [self messageRowStyleClass]];
|
2010-05-27 16:41:59 +02:00
|
|
|
|
2010-06-25 21:58:30 +02:00
|
|
|
// labels
|
|
|
|
[msg addObject: [self msgLabels]];
|
2010-05-27 16:41:59 +02:00
|
|
|
|
2010-06-25 21:58:30 +02:00
|
|
|
// rowID
|
|
|
|
[msg addObject: [self msgRowID]];
|
2010-05-27 16:41:59 +02:00
|
|
|
|
2010-06-25 21:58:30 +02:00
|
|
|
// uid
|
2010-09-15 12:33:07 +02:00
|
|
|
[msg addObject: [message objectForKey: @"uid"]];
|
2010-05-27 16:41:59 +02:00
|
|
|
[headers addObject: msg];
|
|
|
|
|
|
|
|
[self setMessage: [msgsList nextObject]];
|
|
|
|
}
|
|
|
|
|
2010-06-25 21:58:30 +02:00
|
|
|
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]];
|
2010-05-27 16:41:59 +02:00
|
|
|
response = [context response];
|
|
|
|
[response setHeader: @"text/plain; charset=utf-8"
|
|
|
|
forKey: @"content-type"];
|
|
|
|
[response appendContentString: [headers jsonRepresentation]];
|
|
|
|
|
|
|
|
return response;
|
|
|
|
}
|
|
|
|
|
|
|
|
- (NSString *) msgLabels
|
|
|
|
{
|
|
|
|
NSMutableArray *labels;
|
|
|
|
NSEnumerator *flags;
|
|
|
|
NSString *currentFlag;
|
|
|
|
|
|
|
|
labels = [NSMutableArray array];
|
|
|
|
|
|
|
|
flags = [[message objectForKey: @"flags"] objectEnumerator];
|
|
|
|
while ((currentFlag = [flags nextObject]))
|
2013-11-11 16:49:58 +01:00
|
|
|
{
|
|
|
|
[labels addObject: currentFlag];
|
|
|
|
}
|
2010-05-27 16:41:59 +02:00
|
|
|
|
|
|
|
return [labels componentsJoinedByString: @" "];
|
|
|
|
}
|
|
|
|
|
|
|
|
@end
|
|
|
|
|
|
|
|
/* UIxMailListActions */
|