2006-06-15 21:34:10 +02:00
|
|
|
/*
|
|
|
|
Copyright (C) 2004-2005 SKYRIX Software AG
|
|
|
|
|
|
|
|
This file is part of OpenGroupware.org.
|
|
|
|
|
|
|
|
OGo 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.
|
|
|
|
|
|
|
|
OGo 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.
|
|
|
|
*/
|
|
|
|
|
2007-08-01 20:22:45 +02:00
|
|
|
#import <Foundation/NSArray.h>
|
2008-09-02 06:02:46 +02:00
|
|
|
#import <Foundation/NSURL.h>
|
|
|
|
#import <Foundation/NSValue.h>
|
2007-08-01 20:22:45 +02:00
|
|
|
|
|
|
|
#import <NGObjWeb/NSException+HTTP.h>
|
|
|
|
#import <NGExtensions/NSNull+misc.h>
|
|
|
|
#import <NGImap4/NGImap4Connection.h>
|
|
|
|
#import <NGImap4/NGImap4ConnectionManager.h>
|
|
|
|
|
|
|
|
#import "SOGoMailManager.h"
|
2006-06-15 21:34:10 +02:00
|
|
|
|
|
|
|
/*
|
|
|
|
Could check read-write state:
|
|
|
|
dict = [[self->context client] select:[self absoluteName]];
|
|
|
|
self->isReadOnly =
|
|
|
|
[[dict objectForKey:@"access"] isEqualToString:@"READ-WRITE"]
|
|
|
|
? NoNumber : YesNumber;
|
|
|
|
|
|
|
|
TODO: to implement copy, use "uid copy" instead of "copy" as used by
|
|
|
|
NGImap4Client.
|
|
|
|
*/
|
|
|
|
|
2008-09-22 23:31:42 +02:00
|
|
|
@implementation NGImap4ConnectionManager (SOGoMailManager)
|
2006-06-15 21:34:10 +02:00
|
|
|
|
2008-09-22 23:31:42 +02:00
|
|
|
- (NSException *) copyMailURL: (NSURL *) srcurl
|
|
|
|
toFolderURL: (NSURL *) desturl
|
|
|
|
password: (NSString *) pwd
|
2006-06-15 21:34:10 +02:00
|
|
|
{
|
|
|
|
NGImap4Connection *entry;
|
2008-09-02 06:02:46 +02:00
|
|
|
NSNumber *destPort, *srcPort;
|
2008-09-22 23:31:42 +02:00
|
|
|
NSException *error;
|
2008-09-02 06:02:46 +02:00
|
|
|
|
2006-06-15 21:34:10 +02:00
|
|
|
/* check connection cache */
|
|
|
|
|
2008-09-22 23:31:42 +02:00
|
|
|
entry = [self connectionForURL: srcurl password: pwd];
|
|
|
|
if (entry)
|
|
|
|
{
|
|
|
|
/* check whether URLs are on different servers */
|
|
|
|
srcPort = [srcurl port];
|
|
|
|
destPort = [desturl port];
|
|
|
|
|
|
|
|
if ([[desturl host] isEqualToString: [srcurl host]]
|
|
|
|
&& (srcPort == destPort
|
|
|
|
|| [destPort isEqualToNumber: srcPort]))
|
|
|
|
error = [entry copyMailURL: srcurl toFolderURL: desturl];
|
|
|
|
else
|
|
|
|
error = [NSException exceptionWithHTTPStatus: 502 /* Bad Gateway */
|
|
|
|
reason: @"source and destination on different servers"];
|
|
|
|
}
|
|
|
|
else
|
|
|
|
error = [NSException exceptionWithHTTPStatus: 404 /* Not Found */
|
|
|
|
reason: @"Did not find mail URL"];
|
|
|
|
|
|
|
|
return error;
|
2006-06-15 21:34:10 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
@end /* NGImap4ConnectionManager(SOGoMailManager) */
|