]> err.no Git - sope/blob - sope-xml/XmlRpc/XmlRpcRequestEncoder.m
lF fixes
[sope] / sope-xml / XmlRpc / XmlRpcRequestEncoder.m
1 /*
2   Copyright (C) 2000-2005 SKYRIX Software AG
3
4   This file is part of SOPE.
5
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
9   later version.
10
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.
15
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
19   02111-1307, USA.
20 */
21
22 #include "XmlRpcCoder.h"
23 #include "XmlRpcMethodCall.h"
24 #include "common.h"
25
26 @interface XmlRpcEncoder(PrivateMethodes)
27 - (void)_encodeObject:(id)_object;
28 - (void)_reset;
29 @end
30
31 @implementation XmlRpcRequestEncoder
32
33 - (void)encodeRootObject:(XmlRpcMethodCall *)_methodCall {
34   NSEnumerator *paramEnum;
35   id           param;
36
37   if (_methodCall == nil) return;
38
39   if (![_methodCall isKindOfClass:[XmlRpcMethodCall class]]) {
40     NSLog(@"%s: Warning: rootObject MUST be a XmlRpcMethodCall\n "
41           @"(rootObject=%@)",
42           __PRETTY_FUNCTION__,
43           _methodCall);
44     return;
45   }
46   
47   [self _reset];
48   
49   paramEnum = [[_methodCall parameters] objectEnumerator];
50   
51   [self->string appendString:@"<?xml version='1.0'?>\n"];
52   [self->string appendString:@"<methodCall>\n"];
53
54   [self->string appendString:@"<methodName>"];
55   [self->string appendString:[_methodCall methodName]];
56   [self->string appendString:@"</methodName>\n"];
57   
58   [self->string appendString:@"<params>\n"];
59   
60   while ((param = [paramEnum nextObject])) {
61     [self->string appendString:@"<param>\n"];
62     [self->string appendString:@"<value>\n"];
63
64     [self _encodeObject:param];
65     
66     [self->string appendString:@"</value>\n"];
67     [self->string appendString:@"</param>\n"];
68   }
69
70   [self->string appendString:@"</params>\n"];
71   
72   [self->string appendString:@"</methodCall>\n"];
73 }
74
75 @end /* XmlRpcRequestEncoder */