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".
36 #ifndef INCL_CTP_CONFIG
37 #define INCL_CTP_CONFIG
40 #include "base/fscapi.h"
41 #include "client/DMTClientConfig.h"
42 #include "spdm/ManagementNode.h"
43 #include "spdm/DMTreeFactory.h"
44 #include "spdm/DMTree.h"
45 #include "base/util/utils.h"
46 #include "base/util/StringBuffer.h"
48 /// This is the root for the configuration
49 #define APPLICATION_URI "Funambol/SyncClient"
51 /// This is the context for the CTP push parameters
52 #define CONTEXT_PUSH_CTP "/push/ctp"
55 class CTPConfig : public DMTClientConfig {
60 * This key enables the push feature. It is a bitmask,
61 * with bit 0 enabling the STP and bit 1 enabling the CTP.
65 * 3: STP with fallback CTP
70 * This key enables the polling feature if the value is
71 * greater than 0, otherwise the polling is disabled.
76 * Enable or disable the feature of storing the pending
77 * push requests during a sync.
82 * The time interval, in seconds, after which the
83 * client will restore the connection.
88 * The time interval, in seconds, for the maximum
89 * retry timeout (see failure handling).
94 * The time, in seconds, for which the client
95 * shall wait for the server response, after sending a command.
97 int32_t ctpCmdTimeout;
100 * The time, in seconds, for which the connection with
101 * the server shall be kept open once it has been established.
102 * A value of zero indicates that the connection must be
105 int32_t ctpConnTimeout;
108 * TCP/IP port used by the server to listen for CTP requests.
113 /// the nonce used for the MD5 auth. The nonce is sent by the server
114 /// in b64 encoding. It's the same nonce used for synchronization, so
115 /// the value is linked directly to 'accessConfig::serverNonce'.
119 * The interval of the heartbeat
124 * The url to contact. From DM
129 * The url populated after a JUMP server command.
130 * it is in format <(ipAddress|address):port>
132 StringBuffer urlFrom;
135 * Timeout (seconds) for the address-change notification sync.
136 * CTP will wait until this sync ends, after this timeout the
139 int32_t notifyTimeout;
142 * The device id. From DM
147 * The username. From DM
149 StringBuffer username;
152 void setUsername(StringBuffer v) { username = v; }
153 void setDeviceId(StringBuffer v) { devid = v; }
155 StringBuffer checkPrefix(char* url);
162 CTPConfig(const char* application_uri);
170 * Read the parameter configuration from the registry
172 void readCTPConfig();
175 * Save the parameter configuration to the registry.
176 * Actually the only needed parameter to be saved is the
177 * nonce sent by the server
179 void saveCTPConfig();
182 * set/get method for push parameter
184 void setPush(int32_t v) { push = v; }
185 int getPush() { return push; }
188 * set/get method for polling parameter
190 int32_t getPolling() { return polling; }
191 void setPolling(int32_t v) { polling = v; }
194 * set/get method for queuePush parameter
196 bool getQueuePush() { return queuePush; }
197 void setQueuePush(bool v) { queuePush = v; }
200 * set/get method for ctpRetry parameter
202 int32_t getCtpRetry() { return ctpRetry; }
203 void setCtpRetry(int32_t v) { ctpRetry = v; }
206 * set/get method for maxCtpRetry parameter
208 int32_t getMaxCtpRetry() { return maxCtpRetry; }
209 void setMaxCtpRetry(int32_t v) { maxCtpRetry = v; }
212 * set/get method for ctpCmdTimeout parameter
214 int32_t getCtpCmdTimeout() { return ctpCmdTimeout; }
215 void setCtpCmdTimeout(int32_t v) { ctpCmdTimeout = v; }
218 * set/get method for ctpConnTimeout parameter
220 int32_t getCtpConnTimeout() { return ctpConnTimeout; }
221 void setCtpConnTimeout(int32_t v) { ctpConnTimeout = v; }
224 * set/get method for ctpPort parameter
226 int32_t getCtpPort() { return ctpPort; }
227 void setCtpPort(int32_t v) { ctpPort = v; }
230 * set/get method for ctpReady parameter
232 int32_t getCtpReady() { return ctpReady; }
233 void setCtpReady(int32_t v) { ctpReady = v; }
237 * set/get method for nonce parameter: it's the 'accessConfig::clientNonce' so
238 * we ridirect to that property.
240 const char* getCtpNonce() { return accessConfig.getClientNonce(); }
241 void setCtpNonce(const char* v) { accessConfig.setClientNonce(v); }
244 * set/get method for urlTo parameter
246 StringBuffer& getUrlTo() { return urlTo; }
247 void setUrlTo(StringBuffer v) { urlTo = v; }
250 * set/get method for urlFrom parameter
252 StringBuffer& getUrlFrom() { return urlFrom; }
253 void setUrlFrom(StringBuffer v) { urlFrom = v; }
256 * set/get method for notifyTimeout parameter
258 int getNotifyTimeout() { return notifyTimeout; }
259 void setNotifyTimeout(int v) { notifyTimeout = v; }
262 * get method for username parameter
264 StringBuffer& getUsername() { return username; }
267 * get method for deviceId parameter
269 StringBuffer& getDeviceId() { return devid; }
273 * get the host name form the url
275 StringBuffer getHostName(StringBuffer syncUrl);
278 * get the host port form the url. If the port doesn't exist
281 int getHostPort(StringBuffer syncUrl);
283 char* decodePassword(const char* password);
284 StringBuffer encodePassword(const char* password);