From: helge Date: Sun, 24 Oct 2004 18:27:09 +0000 (+0000) Subject: started xmlrpc samples X-Git-Url: https://err.no/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=b7b776cb7b4d7940c156d8b20f1549274558fc7a;p=sope started xmlrpc samples git-svn-id: http://svn.opengroupware.org/SOPE/trunk@315 e4a50df8-12e2-0310-a44c-efbce7f8a7e3 --- diff --git a/sope-appserver/samples/xmlrpc/GNUmakefile b/sope-appserver/samples/xmlrpc/GNUmakefile new file mode 100644 index 00000000..cca0ec94 --- /dev/null +++ b/sope-appserver/samples/xmlrpc/GNUmakefile @@ -0,0 +1,20 @@ +# GNUstep makefile + +-include ../../../config.make +include $(GNUSTEP_MAKEFILES)/common.make + +TOOL_NAME = \ + meerkat_xml_channels \ + blogger_zidestore + +meerkat_xml_channels_OBJC_FILES += meerkat_xml_channels.m + +blogger_zidestore_OBJC_FILES += blogger_zidestore.m NGBloggerClient.m + +ADDITIONAL_TOOL_LIBS += \ + -lNGXmlRpc -lNGObjWeb -lNGMime -lNGStreams -lNGExtensions -lEOControl \ + -lXmlRpc -lDOM -lSaxObjC + +-include GNUmakefile.preamble +include $(GNUSTEP_MAKEFILES)/tool.make +-include GNUmakefile.postamble diff --git a/sope-appserver/samples/xmlrpc/NGBloggerClient.h b/sope-appserver/samples/xmlrpc/NGBloggerClient.h new file mode 100644 index 00000000..22c6fe7a --- /dev/null +++ b/sope-appserver/samples/xmlrpc/NGBloggerClient.h @@ -0,0 +1,64 @@ +/* + Copyright (C) 2004 Helge Hess + + 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; 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. +*/ + +#ifndef __xmlrpc_NGBloggerClient_H__ +#define __xmlrpc_NGBloggerClient_H__ + +#import + +/* + NGBloggerClient + + Note: this is only demo code and far from being a complete Blogger client! + (who knows, it could evolve into one ;-) +*/ + +@class NSString, NSArray; +@class NGXmlRpcClient; + +@interface NGBloggerClient : NSObject +{ + NGXmlRpcClient *xmlrpc; + NSString *appid; + NSString *login; + NSString *password; +} + +- (id)initWithClient:(NGXmlRpcClient *)_client; +- (id)initWithURL:(id)_url; + +/* accessors */ + +- (NGXmlRpcClient *)client; + +- (void)setLogin:(NSString *)_value; +- (NSString *)login; + +- (void)setPassword:(NSString *)_value; +- (NSString *)password; + +/* operations */ + +- (NSArray *)getUsersBlogs; + +@end + +#endif /* __xmlrpc_NGBloggerClient_H__ */ diff --git a/sope-appserver/samples/xmlrpc/NGBloggerClient.m b/sope-appserver/samples/xmlrpc/NGBloggerClient.m new file mode 100644 index 00000000..c34cc3a5 --- /dev/null +++ b/sope-appserver/samples/xmlrpc/NGBloggerClient.m @@ -0,0 +1,92 @@ +/* + Copyright (C) 2004 Helge Hess + + 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; 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. +*/ + +#include "NGBloggerClient.h" +#include +#include "common.h" + +@implementation NGBloggerClient + +- (id)initWithClient:(NGXmlRpcClient *)_client { + if (_client == nil) { + [self release]; + return nil; + } + if ((self = [super init])) { + self->xmlrpc = [_client retain]; + self->appid = @"NGBloggerClient"; + self->login = @"NGBloggerClient"; + self->password = @"NGBloggerClient"; + } + return self; +} + +- (id)initWithURL:(id)_url { + NGXmlRpcClient *client; + + client = [[NGXmlRpcClient alloc] initWithURL:_url]; + self = [self initWithClient:client]; + [client release]; + return self; +} + +- (id)init { + return [self initWithClient:nil]; +} + +- (void)dealloc { + [self->appid release]; + [self->login release]; + [self->password release]; + [self->xmlrpc release]; + [super dealloc]; +} + +/* accessors */ + +- (NGXmlRpcClient *)client { + return self->xmlrpc; +} + +- (void)setLogin:(NSString *)_login { + ASSIGNCOPY(self->login, _login); + [self->xmlrpc setUserName:self->login]; +} +- (NSString *)login { + return self->login; +} + +- (void)setPassword:(NSString *)_value { + ASSIGNCOPY(self->password, _value); + [self->xmlrpc setPassword:_value]; +} +- (NSString *)password { + return self->password; +} + +/* operations */ + +- (NSArray *)getUsersBlogs { + return [self->xmlrpc call:@"blogger.getUsersBlogs", + self->appid, self->login, self->password, nil]; +} + +@end /* NGBloggerClient */ diff --git a/sope-appserver/samples/xmlrpc/blogger_zidestore.m b/sope-appserver/samples/xmlrpc/blogger_zidestore.m new file mode 100644 index 00000000..4ca8f2e8 --- /dev/null +++ b/sope-appserver/samples/xmlrpc/blogger_zidestore.m @@ -0,0 +1,56 @@ +/* + Copyright (C) 2004 SKYRIX Software AG + + 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; 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. +*/ + +#include "NGBloggerClient.h" +#include "common.h" + +static void runIt(void) { + NGBloggerClient *client; + NSString *url, *login, *password; + id result; + + // ADJUST! + login = @"helge"; + password = @"secret"; + url = @"http://localhost/zidestore/so/helge"; + + client = [[NGBloggerClient alloc] initWithURL:url]; + [client setLogin:login]; + [client setPassword:password]; + + result = [client getUsersBlogs]; + NSLog(@"result: %@", result); + + [client release]; +} + +int main(int argc, char **argv, char **env) { + NSAutoreleasePool *pool; + + pool = [[NSAutoreleasePool alloc] init]; +#if LIB_FOUNDATION_LIBRARY || defined(GS_PASS_ARGUMENTS) + [NSProcessInfo initializeWithArguments:argv count:argc environment:env]; +#endif + + runIt(); + [pool release]; + return 0; +} diff --git a/sope-appserver/samples/xmlrpc/common.h b/sope-appserver/samples/xmlrpc/common.h new file mode 100644 index 00000000..da8032a7 --- /dev/null +++ b/sope-appserver/samples/xmlrpc/common.h @@ -0,0 +1,30 @@ +/* + Copyright (C) 2004 Helge Hess + + 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; 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. +*/ + +#import + +#if !LIB_FOUNDATION_LIBRARY +# import +# import +#endif + +#include + diff --git a/sope-appserver/samples/xmlrpc/meerkat_xml_channels.m b/sope-appserver/samples/xmlrpc/meerkat_xml_channels.m new file mode 100644 index 00000000..7f063859 --- /dev/null +++ b/sope-appserver/samples/xmlrpc/meerkat_xml_channels.m @@ -0,0 +1,49 @@ +/* + Copyright (C) 2004 SKYRIX Software AG + + 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; 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. +*/ + +#include +#import + +static void runIt(void) { + NGXmlRpcClient *client; + NSString *url; + + url = @"http://www.oreillynet.com/meerkat/xml-rpc/server.php"; + client = [[NGXmlRpcClient alloc] initWithURL:url]; + + NSLog(@"result: %@", + [client call:@"meerkat.getChannelsBySubstring", @"XML", nil]); + + [client release]; +} + +int main(int argc, char **argv, char **env) { + NSAutoreleasePool *pool; + + pool = [[NSAutoreleasePool alloc] init]; +#if LIB_FOUNDATION_LIBRARY || defined(GS_PASS_ARGUMENTS) + [NSProcessInfo initializeWithArguments:argv count:argc environment:env]; +#endif + + runIt(); + [pool release]; + return 0; +}