Monotone-Parent: 4f12ba210dcd4149e7496ee80e06c65b94793dd3

Monotone-Revision: 7db08f6967ccc793434ea22058755fb137e85d45

Monotone-Author: wsourdeau@inverse.ca
Monotone-Date: 2007-11-01T12:48:19
Monotone-Branch: ca.inverse.sogo
This commit is contained in:
Wolfgang Sourdeau
2007-11-01 12:48:19 +00:00
parent 891ab5f97a
commit 1da963ff19
12 changed files with 248 additions and 175 deletions
+56 -35
View File
@@ -31,6 +31,7 @@
#import <SoObjects/Mailer/SOGoMailAccount.h>
#import <SoObjects/Mailer/SOGoDraftObject.h>
#import <SoObjects/Mailer/SOGoDraftsFolder.h>
#import <SoObjects/SOGo/NSArray+Utilities.h>
#import <SoObjects/SOGo/NSObject+Utilities.h>
#import <SoObjects/SOGo/NSString+Utilities.h>
@@ -40,17 +41,56 @@
@implementation UIxMailAccountActions
- (NSString *) _folderType: (NSString *) baseName
- (id) init
{
if ((self = [super init]))
{
inboxFolderName = nil;
draftsFolderName = nil;
sentFolderName = nil;
trashFolderName = nil;
}
return self;
}
- (void) dealloc
{
[inboxFolderName release];
[draftsFolderName release];
[sentFolderName release];
[trashFolderName release];
[super dealloc];
}
- (NSString *) _folderType: (NSString *) folderName
{
NSString *folderType;
SOGoMailAccount *co;
NSArray *specialFolders;
if ([baseName isEqualToString: @"INBOX"])
if (!inboxFolderName)
{
co = [self clientObject];
specialFolders = [[NSArray arrayWithObjects:
[co inboxFolderNameInContext: context],
[co draftsFolderNameInContext: context],
[co sentFolderNameInContext: context],
[co trashFolderNameInContext: context],
nil] stringsWithFormat: @"/%@"];
ASSIGN (inboxFolderName, [specialFolders objectAtIndex: 0]);
ASSIGN (draftsFolderName, [specialFolders objectAtIndex: 1]);
ASSIGN (sentFolderName, [specialFolders objectAtIndex: 2]);
ASSIGN (trashFolderName, [specialFolders objectAtIndex: 3]);
}
if ([folderName isEqualToString: inboxFolderName])
folderType = @"inbox";
else if ([baseName isEqualToString: draftFolderName])
else if ([folderName isEqualToString: draftsFolderName])
folderType = @"draft";
else if ([baseName isEqualToString: sentFolderName])
else if ([folderName isEqualToString: sentFolderName])
folderType = @"sent";
else if ([baseName isEqualToString: trashFolderName])
else if ([folderName isEqualToString: trashFolderName])
folderType = @"trash";
else
folderType = @"folder";
@@ -58,34 +98,20 @@
return folderType;
}
- (NSDictionary *) _lineForFolder: (NSString *) folder
{
NSArray *parts;
NSMutableDictionary *folderData;
NSString *baseName;
folderData = [NSMutableDictionary dictionary];
parts = [folder componentsSeparatedByString: @"/"];
baseName = [parts lastObject];
[folderData setObject: folder forKey: @"path"];
[folderData setObject: [self _folderType: baseName]
forKey: @"type"];
return folderData;
}
- (NSArray *) _jsonFolders: (NSEnumerator *) rawFolders
{
NSMutableArray *folders;
NSString *currentFolder;
NSDictionary *folderData;
folders = [NSMutableArray array];
currentFolder = [rawFolders nextObject];
while (currentFolder)
while ((currentFolder = [rawFolders nextObject]))
{
[folders addObject: [self _lineForFolder: currentFolder]];
currentFolder = [rawFolders nextObject];
folderData = [NSDictionary dictionaryWithObjectsAndKeys:
currentFolder, @"path",
[self _folderType: currentFolder], @"type",
nil];
[folders addObject: folderData];
}
return folders;
@@ -94,19 +120,14 @@
- (WOResponse *) listMailboxesAction
{
SOGoMailAccount *co;
NSArray *rawFolders, *folders;
NSEnumerator *rawFolders;
NSArray *folders;
WOResponse *response;
co = [self clientObject];
draftFolderName = [[co draftsFolderNameInContext: context]
substringFromIndex: 6];
sentFolderName = [[co sentFolderNameInContext: context]
substringFromIndex: 6];
trashFolderName = [[co trashFolderNameInContext: context]
substringFromIndex: 6];
rawFolders = [co allFolderPaths];
folders = [self _jsonFolders: [rawFolders objectEnumerator]];
rawFolders = [[co allFolderPaths] objectEnumerator];
folders = [self _jsonFolders: rawFolders];
response = [self responseWithStatus: 200];
[response setHeader: @"text/plain; charset=utf-8"