mirror of
https://github.com/inverse-inc/sogo.git
synced 2026-09-26 15:40:32 +00:00
Monotone-Parent: 5be6c87443be578d119d408f0aa2b86f5a6bbc31
Monotone-Revision: 7ad56d517ee86167bc71b34f0a08fd92931aa4cc Monotone-Author: wsourdeau@inverse.ca Monotone-Date: 2010-04-15T18:27:08 Monotone-Branch: ca.inverse.sogo
This commit is contained in:
@@ -49,7 +49,10 @@
|
||||
|
||||
/* messages */
|
||||
- (NSException *) deleteUIDs: (NSArray *) uids inContext: (id) context;
|
||||
- (WOResponse *) archiveUIDs: (NSArray *) uids inContext: (id) context;
|
||||
- (WOResponse *) archiveUIDs: (NSArray *) uids
|
||||
inArchiveNamed: (NSString *) archiveName
|
||||
inContext: (id) context;
|
||||
- (WOResponse *) archiveAllMessagesInContext: (id) localContext;
|
||||
|
||||
- (NSArray *) fetchUIDsMatchingQualifier: (id)_q sortOrdering: (id) _so;
|
||||
- (NSArray *) fetchUIDs: (NSArray *) _uids parts: (NSArray *) _parts;
|
||||
|
||||
@@ -331,11 +331,12 @@ static NSString *defaultUserID = @"anyone";
|
||||
}
|
||||
|
||||
- (WOResponse *) archiveUIDs: (NSArray *) uids
|
||||
inArchiveNamed: (NSString *) archiveName
|
||||
inContext: (id) localContext
|
||||
{
|
||||
NSException *error;
|
||||
NSFileManager *fm;
|
||||
NSString *spoolPath, *fileName, *zipPath;
|
||||
NSString *spoolPath, *fileName, *zipPath, *qpFileName;
|
||||
NSDictionary *msgs;
|
||||
NSArray *messages;
|
||||
NSData *content, *zipContent;
|
||||
@@ -344,6 +345,9 @@ static NSString *defaultUserID = @"anyone";
|
||||
WOResponse *response;
|
||||
int i;
|
||||
|
||||
if (!archiveName)
|
||||
archiveName = @"SavedMessages.zip";
|
||||
|
||||
#warning this method should be rewritten according to our coding styles
|
||||
spoolPath = [self userSpoolFolderPath];
|
||||
if (![self ensureSpoolFolderPath]) {
|
||||
@@ -369,18 +373,16 @@ static NSString *defaultUserID = @"anyone";
|
||||
[zipTaskArguments addObject: @"SavedMessages.zip"];
|
||||
|
||||
msgs = (NSDictionary *)[self fetchUIDs: uids
|
||||
parts: [NSArray arrayWithObject: @"RFC822"]];
|
||||
parts: [NSArray arrayWithObject: @"RFC822"]];
|
||||
messages = [msgs objectForKey: @"fetch"];
|
||||
|
||||
for (i = 0; i < [messages count]; i++) {
|
||||
content = [[messages objectAtIndex: i] objectForKey: @"message"];
|
||||
|
||||
[content writeToFile:
|
||||
[NSString stringWithFormat:@"%@/%d.eml", spoolPath, [uids objectAtIndex: i]]
|
||||
atomically: YES];
|
||||
fileName = [NSString stringWithFormat:@"%@/%@.eml", spoolPath, [uids objectAtIndex: i]];;
|
||||
[content writeToFile: fileName atomically: YES];
|
||||
|
||||
[zipTaskArguments addObject:
|
||||
[NSString stringWithFormat:@"%d.eml", [uids objectAtIndex: i]]];
|
||||
[NSString stringWithFormat:@"%@.eml", [uids objectAtIndex: i]]];
|
||||
}
|
||||
|
||||
[zipTask setArguments: zipTaskArguments];
|
||||
@@ -400,15 +402,46 @@ static NSString *defaultUserID = @"anyone";
|
||||
|
||||
response = [[WOResponse alloc] init];
|
||||
[response autorelease];
|
||||
[response setHeader: @"application/zip" forKey:@"content-type"];
|
||||
[response setHeader: @"attachment;filename=SavedMessages.zip" forKey: @"Content-Disposition"];
|
||||
qpFileName = [archiveName asQPSubjectString: @"utf-8"];
|
||||
[response setHeader: [NSString stringWithFormat: @"application/zip;"
|
||||
@" name=\"%@\"",
|
||||
qpFileName]
|
||||
forKey:@"content-type"];
|
||||
[response setHeader: [NSString stringWithFormat: @"attachment; filename=\"%@\"",
|
||||
qpFileName]
|
||||
forKey: @"Content-Disposition"];
|
||||
[response setContent: zipContent];
|
||||
|
||||
|
||||
[zipContent release];
|
||||
|
||||
return response;
|
||||
}
|
||||
|
||||
- (WOResponse *) archiveAllMessagesInContext: (id) localContext
|
||||
{
|
||||
WOResponse *response;
|
||||
NSArray *uids;
|
||||
NSString *archiveName;
|
||||
EOQualifier *notDeleted;
|
||||
|
||||
if ([[self imap4Connection] doesMailboxExistAtURL: [self imap4URL]])
|
||||
{
|
||||
notDeleted = [EOQualifier qualifierWithQualifierFormat:
|
||||
@"(not (flags = %@))", @"deleted"];
|
||||
uids = [self fetchUIDsMatchingQualifier: notDeleted
|
||||
sortOrdering: @"ARRIVAL"];
|
||||
archiveName = [NSString stringWithFormat: @"%@.zip", [self relativeImap4Name]];
|
||||
response = [self archiveUIDs: uids inArchiveNamed: archiveName
|
||||
inContext: localContext];
|
||||
}
|
||||
else
|
||||
response = (WOResponse *)
|
||||
[NSException exceptionWithHTTPStatus: 404
|
||||
reason: @"Folder does not exist."];
|
||||
|
||||
return response;
|
||||
}
|
||||
|
||||
- (WOResponse *) copyUIDs: (NSArray *) uids
|
||||
toFolder: (NSString *) destinationFolder
|
||||
inContext: (id) localContext
|
||||
|
||||
@@ -401,7 +401,7 @@ static int cssEscapingCount;
|
||||
if ([qpString length] > [self length])
|
||||
{
|
||||
qpString = [qpString stringByReplacingString: @" " withString: @"_"];
|
||||
subjectString = [NSString stringWithFormat: @"=?%@?Q?%@?=",
|
||||
subjectString = [NSString stringWithFormat: @"=?%@?q?%@?=",
|
||||
encoding, qpString];
|
||||
}
|
||||
else
|
||||
|
||||
Reference in New Issue
Block a user