2 * Funambol is a mobile platform developed by Funambol, Inc.
3 * Copyright (C) 2003 - 2007 Funambol, Inc.
5 * This program is free software; you can redistribute it and/or modify it under
6 * the terms of the GNU Affero General Public License version 3 as published by
7 * the Free Software Foundation with the addition of the following permission
8 * added to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED
9 * WORK IN WHICH THE COPYRIGHT IS OWNED BY FUNAMBOL, FUNAMBOL DISCLAIMS THE
10 * WARRANTY OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
12 * This program is distributed in the hope that it will be useful, but WITHOUT
13 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
14 * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
17 * You should have received a copy of the GNU Affero General Public License
18 * along with this program; if not, see http://www.gnu.org/licenses or write to
19 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
22 * You can contact Funambol, Inc. headquarters at 643 Bair Island Road, Suite
23 * 305, Redwood City, CA 94063, USA, or at email address info@funambol.com.
25 * The interactive user interfaces in modified source and object code versions
26 * of this program must display Appropriate Legal Notices, as required under
27 * Section 5 of the GNU Affero General Public License version 3.
29 * In accordance with Section 7(b) of the GNU Affero General Public License
30 * version 3, these Appropriate Legal Notices must retain the display of the
31 * "Powered by Funambol" logo. If the display of the logo is not reasonably
32 * feasible for technical reasons, the Appropriate Legal Notices must display
33 * the words "Powered by Funambol".
37 #ifndef INCL_FORMATTER
38 #define INCL_FORMATTER
41 #include "base/fscapi.h"
42 #include "base/util/utils.h"
43 #include "base/util/StringBuffer.h"
44 #include "base/util/XMLProcessor.h"
45 #include "base/util/ArrayList.h"
47 #include "syncml/core/TagNames.h"
48 #include "syncml/core/ObjectDel.h"
49 #include "base/globalsdef.h"
57 // ---------------------------------------------------------- Public data
60 static StringBuffer* getValue (const char* tagName, const char* value, const char *params = NULL);
61 static StringBuffer* getValue (const char* tagName, StringBuffer* value, const char *params = NULL);
62 static StringBuffer* getValue (const char* tagName, long value, const char *params = NULL);
63 static StringBuffer* getValue (const char* tagName, int value, const char *params = NULL) { return getValue(tagName, (long)value, params); }
64 static StringBuffer* getValue (const char* tagName, bool value, const char *params = NULL);
65 static StringBuffer* getValueNotEmpty (const char* tagName, const char* value, const char *params = NULL);
67 static StringBuffer* getSyncML (SyncML* syncML);
68 static StringBuffer* getSyncHdr (SyncHdr* syncHdr);
69 static StringBuffer* getSyncBody (SyncBody* syncBody);
70 static StringBuffer* getSessionID (SessionID* sessionID);
71 static StringBuffer* getVerDTD (VerDTD* verDTD);
72 static StringBuffer* getVerProto (VerProto* verProto);
73 static StringBuffer* getTarget (Target* target);
74 static StringBuffer* getSource (Source* source);
75 static StringBuffer* getCred (Cred* cred);
76 static StringBuffer* getMeta (Meta* meta);
77 static StringBuffer* getMsgID (const char* value);
78 static StringBuffer* getRespURI (const char* value);
79 static StringBuffer* getAuthentication (Authentication* auth);
80 static StringBuffer* getAnchor (Anchor* anchor);
81 static StringBuffer* getMetInf (MetInf* metInf);
82 static StringBuffer* getNextNonce (NextNonce* nextNonce);
83 static StringBuffer* getMem (Mem* mem);
84 static StringBuffer* getCmdID (CmdID* cmdID);
86 static StringBuffer* getAlerts (ArrayList* alerts);
87 static StringBuffer* getAlert (Alert* alert);
88 static StringBuffer* getItems (ArrayList* items);
89 static StringBuffer* getItem (Item* item);
91 static StringBuffer* getDevInf (DevInf* devInf);
92 static StringBuffer* getData (ComplexData* data);
93 static StringBuffer* getData (Data* data);
94 static StringBuffer* getDataStores (ArrayList* dataStores);
95 static StringBuffer* getDataStore (DataStore* dataStore);
96 static StringBuffer* getSourceRef (SourceRef* sourceRef);
97 static StringBuffer* getTargetRef (TargetRef* targetRef);
98 static StringBuffer* getSourceRefs (ArrayList* sourceRefs);
99 static StringBuffer* getTargetRefs (ArrayList* targetRefs);
100 static StringBuffer* getDSMem (DSMem* dsMem);
101 static StringBuffer* getContentTypeInfos (ArrayList* contentTypeInfos, const char* TAG);
102 static StringBuffer* getContentTypeInfo (ContentTypeInfo* contentTypeInfo, const char* TAG);
103 static StringBuffer* getSyncCap (SyncCap* syncCap);
104 static StringBuffer* getSyncTypes (ArrayList* syncTypes);
105 static StringBuffer* getSyncType (SyncType* syncType);
106 static StringBuffer* getCTCaps (ArrayList* ctCaps);
107 static StringBuffer* getCTCap (CTCap* ctCap);
109 static StringBuffer* getExts (ArrayList* exts);
110 static StringBuffer* getExt (Ext* ext);
111 static StringBuffer* getXVals (ArrayList* xvals);
112 static StringBuffer* getXVal (StringElement* xval);
113 static StringBuffer* getStatusArray (ArrayList* statusArray);
114 static StringBuffer* getStatus (Status* status);
115 static StringBuffer* getChal (Chal* chal);
116 static StringBuffer* getAdds (ArrayList* adds);
117 static StringBuffer* getAdd (Add* add);
118 static StringBuffer* getDels (ArrayList* adds);
119 static StringBuffer* getDelete (Delete* add);
120 static StringBuffer* getReplaces (ArrayList* replaces);
121 static StringBuffer* getReplace (Replace* replace);
122 static StringBuffer* getCopies (ArrayList* copies);
123 static StringBuffer* getCopy (Copy* copy);
124 static StringBuffer* getCommonCommandList(ArrayList* commands);
125 static StringBuffer* getSync (Sync* sync);
126 static StringBuffer* getMapItem (MapItem* mapItem);
127 static StringBuffer* getMapItems (ArrayList* mapItems);
128 static StringBuffer* getMap (Map* map);
129 static StringBuffer* getExec (Exec* exec);
130 static StringBuffer* getGet (Get* get);
131 static StringBuffer* getPut (Put* put);
132 static StringBuffer* getResults (Results* results);
133 static StringBuffer* getSearch (Search* search);
134 static StringBuffer* getSources (ArrayList* sources);
135 static StringBuffer* getSourceArray (SourceArray* sourceArray);
136 static StringBuffer* getExtraCommandList (ArrayList* commands);
137 static StringBuffer* getSequence (Sequence* sequence);
138 static StringBuffer* getSpecificCommand (ArrayList* commands, const char* commandName);
139 static StringBuffer* getAtomic (Atomic* atomic);
140 static StringBuffer* getFilter (Filter* filter);
141 static StringBuffer* getProperty (Property* property);
142 static StringBuffer* getPropParam (PropParam* param);