From: helge Date: Fri, 19 Nov 2004 16:59:17 +0000 (+0000) Subject: minor code cleanups X-Git-Url: https://err.no/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=0dc9c6379b0c70625aea420a919e8caa1fc96ea5;p=sope minor code cleanups git-svn-id: http://svn.opengroupware.org/SOPE/trunk@403 e4a50df8-12e2-0310-a44c-efbce7f8a7e3 --- diff --git a/sope-core/NGStreams/NGStreams/NGActiveSocket.h b/sope-core/NGStreams/NGStreams/NGActiveSocket.h index b80808a5..c7dcbae3 100644 --- a/sope-core/NGStreams/NGStreams/NGActiveSocket.h +++ b/sope-core/NGStreams/NGStreams/NGActiveSocket.h @@ -1,7 +1,7 @@ /* - Copyright (C) 2000-2003 SKYRIX Software AG + 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 __NGNet_NGActiveSocket_H__ #define __NGNet_NGActiveSocket_H__ @@ -31,10 +30,12 @@ @class NSData, NSFileHandle; /* - Represents an active STREAM socket based on the standard Unix sockets library. + Represents an active STREAM socket based on the standard Unix sockets + library. An active socket can be either a socket gained by calling accept with an - passive socket or by explicitly connecting one to an address (a client socket). + passive socket or by explicitly connecting one to an address (a client + socket). Therefore an active socket has two addresses, the local and the remote one. There are three methods to perform a close, this is rooted in the fact that diff --git a/sope-core/NGStreams/NGStreams/NGSocketProtocols.h b/sope-core/NGStreams/NGStreams/NGSocketProtocols.h index e3f9796a..56d77e59 100644 --- a/sope-core/NGStreams/NGStreams/NGSocketProtocols.h +++ b/sope-core/NGStreams/NGStreams/NGSocketProtocols.h @@ -1,7 +1,7 @@ /* - Copyright (C) 2000-2003 SKYRIX Software AG + 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 __NGNet_NGSocketProtocols_H__ #define __NGNet_NGSocketProtocols_H__ diff --git a/sope-core/NGStreams/NGStreams/NGStream.h b/sope-core/NGStreams/NGStreams/NGStream.h index b4afec55..fbf3a4aa 100644 --- a/sope-core/NGStreams/NGStreams/NGStream.h +++ b/sope-core/NGStreams/NGStreams/NGStream.h @@ -1,7 +1,7 @@ /* - Copyright (C) 2000-2003 SKYRIX Software AG + 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 __NGStreams_NGStream_H__ #define __NGStreams_NGStream_H__ @@ -57,6 +56,7 @@ static inline BOOL NGCanWriteInStreamMode(NGStreamMode _mode) { /* methods which read/write exactly _len bytes */ +// TODO: should return exception? (would change the API significantly) - (BOOL)safeReadBytes:(void *)_buf count:(unsigned)_len; - (BOOL)safeWriteBytes:(const void *)_buf count:(unsigned)_len; diff --git a/sope-core/NGStreams/NGStreams/NGTextStream.h b/sope-core/NGStreams/NGStreams/NGTextStream.h index 7a5b4f21..2eb9ba86 100644 --- a/sope-core/NGStreams/NGStreams/NGTextStream.h +++ b/sope-core/NGStreams/NGStreams/NGTextStream.h @@ -1,7 +1,7 @@ /* - Copyright (C) 2000-2003 SKYRIX Software AG + 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 __NGStreams_NGTextStream_H__ #define __NGStreams_NGTextStream_H__ @@ -41,7 +40,7 @@ - (void)setLastException:(NSException *)_exception; - (void)resetLastException; -// NGExtendedTextInputStream +/* NGExtendedTextInputStream */ - (NSString *)readLineAsString; // inefficient - (unsigned)readCharacters:(unichar *)_chars count:(unsigned)_count; diff --git a/sope-mime/ChangeLog b/sope-mime/ChangeLog index fa39c5c3..a1c8175a 100644 --- a/sope-mime/ChangeLog +++ b/sope-mime/ChangeLog @@ -1,3 +1,7 @@ +2004-11-19 Helge Hess + + * NGImap4: minor code cleanups (v4.5.200) + 2004-11-16 Helge Hess * NGImap4: minor code cleanups in NGSieveClient (v4.5.199) diff --git a/sope-mime/NGImap4/ChangeLog b/sope-mime/NGImap4/ChangeLog index bc32078b..141136db 100644 --- a/sope-mime/NGImap4/ChangeLog +++ b/sope-mime/NGImap4/ChangeLog @@ -1,3 +1,7 @@ +2004-11-19 Helge Hess + + * NGSieveClient.m, NGImap4Client.m: minor code cleanups + 2004-11-16 Helge Hess * NGSieveClient.m: some code cleanups, needs fixes for UTF-8 scripts diff --git a/sope-mime/NGImap4/NGImap4Client.m b/sope-mime/NGImap4/NGImap4Client.m index 94df12f0..d06f6eb6 100644 --- a/sope-mime/NGImap4/NGImap4Client.m +++ b/sope-mime/NGImap4/NGImap4Client.m @@ -1322,13 +1322,14 @@ static BOOL ImapDebugEnabled = NO; [self sendCommand:_command withTag:YES logText:_command]; } -static inline NSArray *_flags2ImapFlags(NGImap4Client *self, NSArray *_flags) { +- (NSArray *)_flags2ImapFlags:(NSArray *)_flags { + /* adds backslashes in front of the flags */ NSEnumerator *enumerator; NSArray *result; id obj; id *objs; unsigned cnt; - + objs = calloc([_flags count] + 2, sizeof(id)); cnt = 0; enumerator = [_flags objectEnumerator]; @@ -1337,9 +1338,12 @@ static inline NSArray *_flags2ImapFlags(NGImap4Client *self, NSArray *_flags) { cnt++; } result = [NSArray arrayWithObjects:objs count:cnt]; - if (objs) free(objs); + if (objs != NULL) free(objs); return result; } +static inline NSArray *_flags2ImapFlags(NGImap4Client *self, NSArray *_flags) { + return [self _flags2ImapFlags:_flags]; +} - (NSString *)_folder2ImapFolder:(NSString *)_folder { NSArray *array; diff --git a/sope-mime/NGImap4/NGSieveClient.m b/sope-mime/NGImap4/NGSieveClient.m index dfa78e13..4d4a8d43 100644 --- a/sope-mime/NGImap4/NGSieveClient.m +++ b/sope-mime/NGImap4/NGSieveClient.m @@ -42,18 +42,30 @@ @end -/*" -** An implementation of an Imap4 client -** -** A folder name always looks like an absolute filename (/inbox/doof) -** -"*/ +/* + An implementation of an Imap4 client + + A folder name always looks like an absolute filename (/inbox/blah) + + NOTE: Sieve is just the filtering language ... + + This should be ACAP? + http://asg.web.cmu.edu/rfc/rfc2244.html + + ---snip--- +"IMPLEMENTATION" "Cyrus timsieved v2.1.15-IPv6-Debian-2.1.15-0woody.1.0" +"SASL" "PLAIN" +"SIEVE" "fileinto reject envelope vacation imapflags notify subaddress relational regex" +"STARTTLS" +OK + ---snap--- +*/ @implementation NGSieveClient -static int defaultSievePort = 143; -static NSNumber *YesNumber = nil; -static NSNumber *NoNumber = nil; +static int defaultSievePort = 2000; +static NSNumber *YesNumber = nil; +static NSNumber *NoNumber = nil; static BOOL ProfileImapEnabled = NO; static BOOL LOG_PASSWORD = NO; static BOOL debugImap4 = NO; @@ -84,15 +96,12 @@ static BOOL debugImap4 = NO; - (id)initWithHost:(id)_host { NGInternetSocketAddress *a; + a = [NGInternetSocketAddress addressWithPort:defaultSievePort onHost:_host]; return [self initWithAddress:a]; } -/**" - ** designated initializer -"**/ - -- (id)initWithAddress:(id)_address { +- (id)initWithAddress:(id)_address { // di if ((self = [super init])) { self->address = [_address retain]; self->debug = debugImap4; @@ -138,9 +147,7 @@ static BOOL debugImap4 = NO; /* connection */ -/*" -** Opens a connection to given Host. -"*/ +/* Opens a connection to given Host. */ - (NSDictionary *)openConnection { struct timeval tv; @@ -194,14 +201,12 @@ static BOOL debugImap4 = NO; [self->parser release]; self->parser = nil; } -/*" -** login with plaintext password authenticating -"*/ +/* login with plaintext password authenticating */ - (NSDictionary *)login:(NSString *)_login password:(NSString *)_passwd { if ((_login == nil) || (_passwd == nil)) return nil; - + [self->login release]; self->login = nil; [self->password release]; self->password = nil; @@ -224,8 +229,8 @@ static BOOL debugImap4 = NO; logLen = [self->login cStringLength]; - bufLen = (logLen*2) + [self->password cStringLength] +2; - + bufLen = (logLen * 2) + [self->password cStringLength] +2; + buf = calloc(sizeof(char), bufLen); sprintf(buf, "%s %s %s", @@ -256,9 +261,7 @@ static BOOL debugImap4 = NO; 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; @@ -472,9 +475,9 @@ static BOOL debugImap4 = NO; - (void)sendCommand:(NSString *)_command logText:(NSString *)_txt { // TODO: should accept 'NSData' commands NSString *command = nil; - + command = _command; - + if (self->debug) fprintf(stderr, "C: %s\n", [_txt cString]); diff --git a/sope-mime/Version b/sope-mime/Version index 268ab9f7..31c4d5bd 100644 --- a/sope-mime/Version +++ b/sope-mime/Version @@ -2,6 +2,6 @@ MAJOR_VERSION:=4 MINOR_VERSION:=5 -SUBMINOR_VERSION:=199 +SUBMINOR_VERSION:=200 # v4.2.149 requires libNGStreams v4.2.34