/* Copyright (C) 2000-2003 SKYRIX Software AG This file is part of OGo 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. */ // $Id: imap_tool.m 4 2004-08-20 17:04:31Z helge $ #include "common.h" #include "NGImap4.h" int main(int argc, char **argv, char **env) { NSAutoreleasePool *pool; #if LIB_FOUNDATION_LIBRARY [NSProcessInfo initializeWithArguments:argv count:argc environment: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++; } } } [pool release]; return 0; }