From c113f68eb1e7dc51e759bd4e10d1e685edb081a6 Mon Sep 17 00:00:00 2001 From: helge Date: Sun, 26 Sep 2004 17:32:06 +0000 Subject: [PATCH] fixed samples makefile for compilation, some cleanups git-svn-id: http://svn.opengroupware.org/SOPE/trunk@172 e4a50df8-12e2-0310-a44c-efbce7f8a7e3 --- sope-mime/NGImap4/NGImap4Client.h | 13 ++- sope-mime/NGImap4/NGImap4Client.m | 1 + sope-mime/NGImap4/NGImap4Context.h | 11 +- sope-mime/samples/ChangeLog | 4 + sope-mime/samples/GNUmakefile.preamble | 21 ++-- sope-mime/samples/imap_tool.m | 138 +++++++++++++------------ sope-mime/samples/imapls.m | 3 +- sope-mime/samples/imapquota.m | 1 - 8 files changed, 106 insertions(+), 86 deletions(-) diff --git a/sope-mime/NGImap4/NGImap4Client.h b/sope-mime/NGImap4/NGImap4Client.h index 4cff2b42..a0b86667 100644 --- a/sope-mime/NGImap4/NGImap4Client.h +++ b/sope-mime/NGImap4/NGImap4Client.h @@ -18,10 +18,9 @@ Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ -// $Id$ -#ifndef __OGo_NGImap4_NGImap4Client_H__ -#define __OGo_NGImap4_NGImap4Client_H__ +#ifndef __SOPE_NGImap4_NGImap4Client_H__ +#define __SOPE_NGImap4_NGImap4Client_H__ #import #include @@ -31,7 +30,11 @@ /* NGImap4Client - An IMAP4 client object. + An IMAP4 client object. This object is a thin wrapper around the TCP/IP + socket (id object) connecting to the IMAP4 server. + + Responses are send to all registered response receivers. + TODO: explain notification system. */ @class NSMutableArray, NSString, NSNumber, NSDictionary, NSArray, NSURL; @@ -145,4 +148,4 @@ typedef enum { @end -#endif /* __OGo_NGImap4_NGImap4Client_H__ */ +#endif /* __SOPE_NGImap4_NGImap4Client_H__ */ diff --git a/sope-mime/NGImap4/NGImap4Client.m b/sope-mime/NGImap4/NGImap4Client.m index d2ab39dd..9594e274 100644 --- a/sope-mime/NGImap4/NGImap4Client.m +++ b/sope-mime/NGImap4/NGImap4Client.m @@ -347,6 +347,7 @@ static BOOL ImapDebugEnabled = NO; } - (NSNumber *)isConnected { + // TODO: why is that an NSNummber? /* Check whether stream is already open (could be closed because server-timeout) diff --git a/sope-mime/NGImap4/NGImap4Context.h b/sope-mime/NGImap4/NGImap4Context.h index d0599874..2dd1d2af 100644 --- a/sope-mime/NGImap4/NGImap4Context.h +++ b/sope-mime/NGImap4/NGImap4Context.h @@ -18,7 +18,6 @@ Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ -// $Id$ #ifndef __OGo_NGImap4_NGImap4Context_H__ #define __OGo_NGImap4_NGImap4Context_H__ @@ -26,6 +25,16 @@ #import #include +/* + NGImap4Context + + This object is a higher level client object build on top of the NGImap4Client + object which represents the connection to the IMAP4 server and handles the + raw IMAP4 processing. + The NGImap4Context adds to that higher level functionality like caching of + folders. +*/ + @class NSDictionary, NGHashMap, NSMutableArray, NSURL, NSException; @class EOGlobalID; @class NGImap4Client, NGImap4Folder, NGImap4ServerRoot; diff --git a/sope-mime/samples/ChangeLog b/sope-mime/samples/ChangeLog index e3025527..7585aaf0 100644 --- a/sope-mime/samples/ChangeLog +++ b/sope-mime/samples/ChangeLog @@ -1,3 +1,7 @@ +2004-09-26 Helge Hess + + * imap_tool.m: code cleanups + 2004-08-29 Helge Hess * added hack to install the tools in FHS locations - the executables diff --git a/sope-mime/samples/GNUmakefile.preamble b/sope-mime/samples/GNUmakefile.preamble index f7215e85..6f1e792d 100644 --- a/sope-mime/samples/GNUmakefile.preamble +++ b/sope-mime/samples/GNUmakefile.preamble @@ -1,22 +1,23 @@ -# $Id: GNUmakefile.preamble 9 2004-08-20 18:40:42Z helge $ +# compilation flags + +SOPE_CORE="../../sope-core" +SOPE_XML="../../sope-xml" ADDITIONAL_INCLUDE_DIRS += \ -I.. \ -I../NGMime \ - -I../NGStreams \ - -I../NGExtensions \ + -I$(SOPE_CORE)/NGStreams\ + -I$(SOPE_CORE)/NGExtensions ADDITIONAL_LIB_DIRS += \ - -L../EOControl/$(GNUSTEP_OBJ_DIR) \ - -L../NGExtensions/$(GNUSTEP_OBJ_DIR) \ - -L../NGStreams/$(GNUSTEP_OBJ_DIR) \ -L../NGMime/$(GNUSTEP_OBJ_DIR) \ - -L../NGLdap/$(GNUSTEP_OBJ_DIR) \ - -L../NGiCal/$(GNUSTEP_OBJ_DIR) \ + -L$(SOPE_CORE)/EOControl/$(GNUSTEP_OBJ_DIR) \ + -L$(SOPE_CORE)/NGExtensions/$(GNUSTEP_OBJ_DIR) \ + -L$(SOPE_CORE)/NGStreams/$(GNUSTEP_OBJ_DIR) \ + -L$(SOPE_XML)/DOM/$(GNUSTEP_OBJ_DIR) \ + -L$(SOPE_XML)/SaxObjC/$(GNUSTEP_OBJ_DIR) \ -L/usr/local/lib -L/usr/lib - ADDITIONAL_TOOL_LIBS += \ -lNGMime -lNGStreams -lNGExtensions -lEOControl \ -lDOM -lSaxObjC - diff --git a/sope-mime/samples/imap_tool.m b/sope-mime/samples/imap_tool.m index a4c2154d..151140cd 100644 --- a/sope-mime/samples/imap_tool.m +++ b/sope-mime/samples/imap_tool.m @@ -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,12 +18,78 @@ Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ -// $Id: imap_tool.m 4 2004-08-20 17:04:31Z helge $ - #include "common.h" #include "NGImap4.h" +static void usage(void) { + fprintf(stderr, "usage: imap_tool" + " -login " + " -pwd " + " [-host ]\n"); + exit(1); +} + +static void runAction(NGImap4Client *client, NSString *action, NSString *arg) { + if ([action length] == 0) + return; + + if ([action isEqualToString:@"select"]) { + result = [client select:arg]; + } + else if ([action isEqualToString:@"thread"]) { + result = [client threadBySubject:[arg boolValue] charset:nil]; + } + else if ([action isEqualToString:@"list"]) { + result = [client list:arg pattern:@"*"]; + } + else if ([action isEqualToString:@"fetch"]) { + NSArray *args; + + args = [arg componentsSeparatedByString:@":"]; + result = [client fetchFrom:[[args objectAtIndex:0] intValue] + to:[[args objectAtIndex:1] intValue] + parts:[args subarrayWithRange: + NSMakeRange(2,[args count] - 2)]]; + } + + NSLog(@"action: %@:%@ : %@", action, arg, result); +} + +static void run(void) { + NSString *login, *pwd, *host; + NSUserDefaults *ud; + NGImap4Client *client; + int cnt; + + ud = [NSUserDefaults standardUserDefaults]; + + if ((login = [ud stringForKey:@"login"]) == nil) + usage(); + if ((pwd = [ud stringForKey:@"pwd"]) == nil) + usage(); + if ((host = [ud stringForKey:@"host"]) == nil) + host = @"localhost"; + + client = [NGImap4Client clientWithHost:host]; + + NSLog(@"attempt login '%@' ...", login); + [client login:login password:pwd]; + NSLog(@" got client: %@", client); + + for (cnt = 0; YES; cnt++) { + NSString *action; + NSString *arg; + id result; + + action = [ud stringForKey: + [NSString stringWithFormat:@"action_%d", cnt]]; + arg = [ud stringForKey: + [NSString stringWithFormat:@"arg_%d", cnt]]; + if (!runAction(client, action, arg)) + break; + } +} int main(int argc, char **argv, char **env) { NSAutoreleasePool *pool; @@ -33,69 +99,7 @@ int main(int argc, char **argv, char **env) { #endif pool = [[NSAutoreleasePool alloc] init]; - - { - NSString *login, *pwd, *host; - NSUserDefaults *ud; - NGImap4Client *client; - - ud = [NSUserDefaults standardUserDefaults]; - - if (!(login = [ud stringForKey:@"login"])) { - login = @"j"; - } - if (!(pwd = [ud stringForKey:@"pwd"])) { - pwd = @"system"; - } - if (!(host = [ud stringForKey:@"host"])) { - host = @"defiant"; - } - - client = [NGImap4Client clientWithHost:host]; - - [client login:login password:pwd]; - NSLog(@"client %@", client); - - { - int cnt = 0; - - while (1) { - NSString *action; - NSString *arg; - id result; - - action = [ud stringForKey: - [NSString stringWithFormat:@"action_%d", cnt]]; - arg = [ud stringForKey: - [NSString stringWithFormat:@"arg_%d", cnt]]; - - if (![action length]) - break; - - if ([action isEqualToString:@"select"]) { - result = [client select:arg]; - } - else if ([action isEqualToString:@"thread"]) { - result = [client threadBySubject:[arg boolValue] charset:nil]; - } - else if ([action isEqualToString:@"list"]) { - result = [client list:arg pattern:@"*"]; - } - else if ([action isEqualToString:@"fetch"]) { - NSArray *args; - - args = [arg componentsSeparatedByString:@":"]; - result = [client fetchFrom:[[args objectAtIndex:0] intValue] - to:[[args objectAtIndex:1] intValue] - parts:[args subarrayWithRange: - NSMakeRange(2,[args count] - 2)]]; - } - NSLog(@"action %d: %@:%@ : %@", cnt, action, arg, - result); - cnt++; - } - } - } + run(); [pool release]; return 0; } diff --git a/sope-mime/samples/imapls.m b/sope-mime/samples/imapls.m index 87cec062..f1b56f49 100644 --- a/sope-mime/samples/imapls.m +++ b/sope-mime/samples/imapls.m @@ -18,10 +18,9 @@ Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ -// $Id: imapls.m 4 2004-08-20 17:04:31Z helge $ /* - scan through imap folders/messages using the NGImap4FileManager + Scan through IMAP4 folders/messages using the NGImap4FileManager */ #include "ImapListTool.h" diff --git a/sope-mime/samples/imapquota.m b/sope-mime/samples/imapquota.m index c9abc64d..3671d196 100644 --- a/sope-mime/samples/imapquota.m +++ b/sope-mime/samples/imapquota.m @@ -19,7 +19,6 @@ 02111-1307, USA. */ - #include "ImapQuotaTool.h" #include "common.h" -- 2.39.5