2 Copyright (C) 2004 Helge Hess
4 This file is part of SOPE.
6 SOPE is free software; you can redistribute it and/or modify it under
7 the terms of the GNU Lesser General Public License as published by the
8 Free Software Foundation; either version 2, or (at your option) any
11 SOPE is distributed in the hope that it will be useful, but WITHOUT ANY
12 WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
14 License for more details.
16 You should have received a copy of the GNU Lesser General Public
17 License along with SOPE; see the file COPYING. If not, write to the
18 Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA
22 #include <NGImap4/NGSieveClient.h>
25 static NSURL *getDefaultsURL(void) {
27 NSString *pwd, *user, *host;
30 ud = [NSUserDefaults standardUserDefaults];
32 if ((url = [ud stringForKey:@"url"]) != nil)
33 return [NSURL URLWithString:url];
35 user = [ud stringForKey:@"user"];
36 pwd = [ud stringForKey:@"password"];
37 host = [ud stringForKey:@"host"];
39 url = [@"http://" stringByAppendingString:user];
40 url = [url stringByAppendingString:@":"];
41 url = [url stringByAppendingString:pwd];
42 url = [url stringByAppendingString:@"@"];
43 url = [url stringByAppendingString:host];
44 url = [url stringByAppendingString:@":2000/"];
45 return [NSURL URLWithString:url];
48 static int test(NSArray *args) {
50 NGSieveClient *client;
54 ud = [NSUserDefaults standardUserDefaults];
56 url = getDefaultsURL();
57 NSLog(@"check URL: %@", url);
59 client = [[NGSieveClient alloc] initWithURL:url];
60 NSLog(@" client: %@", client);
62 res = [client login:[url user] password:[url password]];
63 if (![[res valueForKey:@"result"] boolValue]) {
64 NSLog(@"could not login %@: %@", [url user], client);
68 NSLog(@" login %@: %@", [url user], res);
69 NSLog(@" client: %@", client);
71 res = [client listScripts];
72 NSLog(@" list: %@", res);
74 res = [client getScript:@"ogo"];
75 NSLog(@" get 'ogo': %@", res);
80 int main(int argc, char **argv, char **env) {
81 NSAutoreleasePool *pool;
84 pool = [NSAutoreleasePool new];
85 #if LIB_FOUNDATION_LIBRARY
86 [NSProcessInfo initializeWithArguments:argv count:argc environment:env];
89 res = test([[NSProcessInfo processInfo] argumentsWithoutDefaults]);