From 11e00e771428bcfdd38cc516caa7729003eeb07d Mon Sep 17 00:00:00 2001 From: helge Date: Wed, 17 Nov 2004 13:50:58 +0000 Subject: [PATCH] cleanups in Sieve client git-svn-id: http://svn.opengroupware.org/SOPE/trunk@383 e4a50df8-12e2-0310-a44c-efbce7f8a7e3 --- sope-mime/ChangeLog | 4 +++ sope-mime/NGImap4/ChangeLog | 4 +++ sope-mime/NGImap4/NGSieveClient.h | 19 ++++++-------- sope-mime/NGImap4/NGSieveClient.m | 42 ++++++++++++++++++------------- sope-mime/Version | 2 +- 5 files changed, 42 insertions(+), 29 deletions(-) diff --git a/sope-mime/ChangeLog b/sope-mime/ChangeLog index 986c1d2b..fa39c5c3 100644 --- a/sope-mime/ChangeLog +++ b/sope-mime/ChangeLog @@ -1,3 +1,7 @@ +2004-11-16 Helge Hess + + * NGImap4: minor code cleanups in NGSieveClient (v4.5.199) + 2004-11-13 Helge Hess * NGMime: added support for 'reply-type' parameter in text MIME types diff --git a/sope-mime/NGImap4/ChangeLog b/sope-mime/NGImap4/ChangeLog index 78529adc..bc32078b 100644 --- a/sope-mime/NGImap4/ChangeLog +++ b/sope-mime/NGImap4/ChangeLog @@ -1,3 +1,7 @@ +2004-11-16 Helge Hess + + * NGSieveClient.m: some code cleanups, needs fixes for UTF-8 scripts + 2004-11-08 Helge Hess * NGImap4ResponseParser.m(_parseQuotedStringOrNIL): added support for diff --git a/sope-mime/NGImap4/NGSieveClient.h b/sope-mime/NGImap4/NGSieveClient.h index d44c7205..2545ce5e 100644 --- a/sope-mime/NGImap4/NGSieveClient.h +++ b/sope-mime/NGImap4/NGSieveClient.h @@ -1,7 +1,7 @@ /* Copyright (C) 2000-2004 SKYRIX Software AG - This file is part of OGo + 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 @@ -18,7 +18,6 @@ Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ -// $Id$ #ifndef __Networking_NGImap4_NGSieveClient_H__ #define __Networking_NGImap4_NGSieveClient_H__ @@ -60,24 +59,19 @@ typedef enum { - (id)initWithHost:(id)_host; - (id)initWithAddress:(id)_address; -// equality - -- (BOOL)isEqual:(id)_obj; -- (BOOL)isEqualToSieveClient:(NGSieveClient *)_obj; - -// accessors +/* accessors */ - (id)socket; - (id)address; -// connection +/* connection */ - (NSDictionary *)openConnection; - (void)closeConnection; - (NSNumber *)isConnected; - (void)reconnect; -// commands +/* commands */ - (NSDictionary *)login:(NSString *)_login password:(NSString *)_passwd; - (NSDictionary *)logout; @@ -88,7 +82,10 @@ typedef enum { - (NSDictionary *)deleteScript:(NSString *)_script; - (NSDictionary *)listScript:(NSString *)_script; -- (NSString *)description; +/* equality */ + +- (BOOL)isEqualToSieveClient:(NGSieveClient *)_obj; @end + #endif /* __Networking_NGSieve_NGSieveClient_H__ */ diff --git a/sope-mime/NGImap4/NGSieveClient.m b/sope-mime/NGImap4/NGSieveClient.m index a25db587..dfa78e13 100644 --- a/sope-mime/NGImap4/NGSieveClient.m +++ b/sope-mime/NGImap4/NGSieveClient.m @@ -1,7 +1,7 @@ /* Copyright (C) 2000-2004 SKYRIX Software AG - This file is part of OGo + 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 @@ -18,7 +18,6 @@ Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ -// $Id$ #include @@ -234,37 +233,43 @@ static BOOL debugImap4 = NO; [self->password cString]); buf[logLen] = '\0'; - buf[logLen*2+1] = '\0'; + buf[logLen * 2 + 1] = '\0'; auth = [NSData dataWithBytesNoCopy:buf length:bufLen]; auth = [auth dataByEncodingBase64]; - + if (LOG_PASSWORD == 1) { - map = [self processCommand:[NSString stringWithFormat: - @"AUTHENTICATE \"PLAIN\" {%d+}\r\n%s", - [auth length], [auth bytes]]]; + NSString *s; + + s = [NSString stringWithFormat:@"AUTHENTICATE \"PLAIN\" {%d+}\r\n%s", + [auth length], [auth bytes]]; + map = [self processCommand:s]; } else { - map = [self processCommand:[NSString stringWithFormat: - @"AUTHENTICATE \"PLAIN\" {%d+}\r\n%s", - [auth length], [auth bytes]] + NSString *s; + + s = [NSString stringWithFormat:@"AUTHENTICATE \"PLAIN\" {%d+}\r\n%s", + [auth length], [auth bytes]]; + map = [self processCommand:s logText:@"AUTHENTICATE \"PLAIN\" {%d+}\r\nLOGIN:PASSWORD\r\n"]; } return [self normalizeResponse:map]; } /* -** logout from the connected host and close the connection + logout from the connected host and close the connection */ - (NSDictionary *)logout { - NGHashMap *map = [self processCommand:@"logout"]; + NGHashMap *map; + map = [self processCommand:@"logout"]; // TODO: check for success! [self closeConnection]; return [self normalizeResponse:map]; } - (NSDictionary *)getScript:(NSString *)_scriptName { + // TODO: implement [self notImplemented:_cmd]; return nil; } @@ -274,6 +279,7 @@ static BOOL debugImap4 = NO; } - (NSDictionary *)putScript:(NSString *)_name script:(NSString *)_script { + // TODO: script should be send in UTF-8! NGHashMap *map; NSString *s; @@ -286,9 +292,11 @@ static BOOL debugImap4 = NO; return nil; } - s = [NSString stringWithFormat: - @"PUTSCRIPT \"%@\" {%d+}\r\n%@\r\n", - _name, [_script length], _script]; + s = @"PUTSCRIPT \""; + s = [s stringByAppendingString:_name]; + s = [s stringByAppendingString:@"\" {"]; + s = [s stringByAppendingFormat:@"{%d+}\r\n%@", [_script length], _script]; + s = [s stringByAppendingString:@"\r\n"]; map = [self processCommand:s]; return [self normalizeResponse:map]; } @@ -417,7 +425,6 @@ static BOOL debugImap4 = NO; NGHashMap *map = nil; BOOL repeatCommand = NO; int repeatCnt = 0; - struct timeval tv; double ti = 0.0; @@ -463,7 +470,8 @@ static BOOL debugImap4 = NO; } - (void)sendCommand:(NSString *)_command logText:(NSString *)_txt { - NSString *command = nil; + // TODO: should accept 'NSData' commands + NSString *command = nil; command = _command; diff --git a/sope-mime/Version b/sope-mime/Version index 34666946..268ab9f7 100644 --- a/sope-mime/Version +++ b/sope-mime/Version @@ -2,6 +2,6 @@ MAJOR_VERSION:=4 MINOR_VERSION:=5 -SUBMINOR_VERSION:=198 +SUBMINOR_VERSION:=199 # v4.2.149 requires libNGStreams v4.2.34 -- 2.39.5