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 <Foundation/NSObject.h>
#include <NGStreams/NGStreams.h>
/*
NGImap4Client
- An IMAP4 client object.
+ An IMAP4 client object. This object is a thin wrapper around the TCP/IP
+ socket (id<NGActiveSocket> 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;
@end
-#endif /* __OGo_NGImap4_NGImap4Client_H__ */
+#endif /* __SOPE_NGImap4_NGImap4Client_H__ */
-# $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
-
/*
- 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
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 <login>"
+ " -pwd <pwd>"
+ " [-host <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;
#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;
}