00001 /* 00002 * Funambol is a mobile platform developed by Funambol, Inc. 00003 * Copyright (C) 2003 - 2007 Funambol, Inc. 00004 * 00005 * This program is free software; you can redistribute it and/or modify it under 00006 * the terms of the GNU Affero General Public License version 3 as published by 00007 * the Free Software Foundation with the addition of the following permission 00008 * added to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED 00009 * WORK IN WHICH THE COPYRIGHT IS OWNED BY FUNAMBOL, FUNAMBOL DISCLAIMS THE 00010 * WARRANTY OF NON INFRINGEMENT OF THIRD PARTY RIGHTS. 00011 * 00012 * This program is distributed in the hope that it will be useful, but WITHOUT 00013 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS 00014 * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more 00015 * details. 00016 * 00017 * You should have received a copy of the GNU Affero General Public License 00018 * along with this program; if not, see http://www.gnu.org/licenses or write to 00019 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, 00020 * MA 02110-1301 USA. 00021 * 00022 * You can contact Funambol, Inc. headquarters at 643 Bair Island Road, Suite 00023 * 305, Redwood City, CA 94063, USA, or at email address info@funambol.com. 00024 * 00025 * The interactive user interfaces in modified source and object code versions 00026 * of this program must display Appropriate Legal Notices, as required under 00027 * Section 5 of the GNU Affero General Public License version 3. 00028 * 00029 * In accordance with Section 7(b) of the GNU Affero General Public License 00030 * version 3, these Appropriate Legal Notices must retain the display of the 00031 * "Powered by Funambol" logo. If the display of the logo is not reasonably 00032 * feasible for technical reasons, the Appropriate Legal Notices must display 00033 * the words "Powered by Funambol". 00034 */ 00035 00036 00037 00038 #ifndef INCL_SYNC_SOURCE_CONFIG 00039 #define INCL_SYNC_SOURCE_CONFIG 00040 /** @cond API */ 00041 /** @addtogroup Client */ 00042 /** @{ */ 00043 00044 #include "spds/AbstractSyncSourceConfig.h" 00045 #include "base/globalsdef.h" 00046 00047 BEGIN_NAMESPACE 00048 00049 /** 00050 * This class is one possible implementation of the 00051 * AbstractSyncSourceConfig API: it implements all attributes as 00052 * read/write members. 00053 */ 00054 class SyncSourceConfig : public AbstractSyncSourceConfig { 00055 00056 protected: 00057 00058 char* name ; 00059 char* uri ; 00060 char* syncModes ; 00061 char* type ; 00062 char* sync ; 00063 char* encodings ; 00064 char* version ; 00065 char* supportedTypes ; 00066 char* encryption ; 00067 // last anchor, set by the engine. 00068 unsigned long last ; 00069 // CTCap data 00070 bool fieldLevel ; 00071 ArrayList ctCaps ; 00072 00073 /** 00074 * Create a new CTCap object, based on the current source configuration. 00075 * To obtain a complete CTCap, the client must have set previously the 00076 * list of CTCap properties with the method setCtCapProperties(). 00077 */ 00078 CTCap* createCtCap(ArrayList *props, const char *ct_Type, const char *ver_CT, bool fLevel); 00079 00080 public: 00081 00082 /** 00083 * Constructs a new SyncSourceConfig object 00084 */ 00085 SyncSourceConfig(); 00086 00087 /** 00088 * Destructor 00089 */ 00090 ~SyncSourceConfig(); 00091 00092 /** 00093 * Returns the SyncSource name. 00094 */ 00095 const char* getName() const; 00096 00097 /** 00098 * Sets the SyncSource name 00099 * 00100 * @param n the new name 00101 */ 00102 void setName(const char* n); 00103 00104 /** 00105 * Returns the SyncSource URI (used in SyncML addressing). 00106 */ 00107 const char* getURI() const; 00108 00109 /** 00110 * Sets the SyncSource URI (used in SyncML addressing). 00111 * 00112 * @param u the new uri 00113 */ 00114 void setURI(const char* u); 00115 00116 /** 00117 * Returns a comma separated list of the possible syncModes for the 00118 * SyncSource. Sync modes can be one of 00119 * - slow 00120 * - two-way 00121 * - one-way-from-server 00122 * - one-way-from-client 00123 * - refresh-from-server 00124 * - refresh-from-client 00125 * - one-way-from-server 00126 * - one-way-from-client 00127 * - addrchange 00128 */ 00129 const char* getSyncModes() const; 00130 00131 /** 00132 * Sets the available syncModes for the SyncSource as comma separated 00133 * values. 00134 * 00135 * @param s the new list 00136 */ 00137 void setSyncModes(const char* s); 00138 00139 /** 00140 * Returns the mime type of the items handled by the sync source. 00141 */ 00142 const char* getType() const; 00143 00144 /** 00145 * Sets the mime type of the items handled by the sync source. 00146 * 00147 * @param t the mime type 00148 */ 00149 void setType(const char* t); 00150 00151 /** 00152 * Gets the default syncMode as one of the strings listed in setSyncModes. 00153 */ 00154 const char* getSync() const; 00155 00156 /** 00157 * Returns the default syncMode as one of the strings above. 00158 */ 00159 void setSync(const char* s); 00160 00161 /** 00162 * Specifies how the content of an outgoing item should be 00163 * encoded by the client library if the sync source does not 00164 * set an encoding on the item that it created. Valid values 00165 * are listed in SyncItem::encodings. 00166 */ 00167 const char* getEncoding() const; 00168 void setEncoding(const char* s); 00169 00170 00171 /** 00172 * Returns the version of the source type used by client. 00173 */ 00174 const char* getVersion() const; 00175 00176 /** 00177 * Sets the SyncSource version 00178 * 00179 * @param n the new version 00180 */ 00181 void setVersion(const char* n); 00182 00183 00184 /** 00185 * A string representing the source types (with versions) supported by the SyncSource. 00186 * The string must be formatted as a sequence of "type:version" separated by commas ','. 00187 * For example: "text/x-vcard:2.1,text/vcard:3.0". 00188 * The version can be left empty, for example: "text/x-s4j-sifc:". 00189 * Supported types will be sent as part of the DevInf. 00190 */ 00191 const char* getSupportedTypes() const; 00192 00193 /** 00194 * Sets the supported source types for this source. 00195 * 00196 * @param s the supported types string 00197 */ 00198 void setSupportedTypes(const char* s); 00199 00200 /** 00201 * Sets the last sync timestamp 00202 * 00203 * @param timestamp the last sync timestamp 00204 */ 00205 void setLast(unsigned long timestamp); 00206 00207 /** 00208 * Returns the last sync timestamp 00209 */ 00210 unsigned long getLast() const; 00211 00212 /** 00213 * Specifies if the content of an outgoing item should be encrypted. 00214 * If this property is not empty and valid, the 'encodings' value is ignored 00215 * for outgoing items. The only valid value is "des". 00216 */ 00217 const char* getEncryption() const; 00218 00219 /** 00220 * Sets the encryption type 00221 * 00222 * @param n the encryption type 00223 */ 00224 void setEncryption(const char* n); 00225 00226 /** 00227 * Sets the list of properties to use in the CTCap sent to the server in 00228 * the DevInfo. 00229 * 00230 * @param props an ArrayList of Property 00231 */ 00232 //void setCtCapProperties(ArrayList* props); 00233 00234 /** 00235 * Returns the list of properties to use in the CTCap sent to the server 00236 * in the DevInfo. 00237 * 00238 * @returns an ArrayList of Property 00239 */ 00240 //ArrayList& getCtCapProperties(); 00241 00242 /** 00243 * Returns an array of CtCap with all the capabilities for this Source 00244 * 00245 * @return an ArrayList of CTCap 00246 */ 00247 const ArrayList& getCtCaps() const {return ctCaps;}; 00248 ArrayList& getCtCaps() {return ctCaps;}; 00249 00250 /** 00251 * add a CTCap to the ArrayList. If ctType, verCT and FieldLevel are null 00252 * we set a CTCap with the default verCT, fieldLevel and ctType taken 00253 * from the config 00254 * 00255 * the fieldLevel param has three status 00256 * FLEVEL_DISABLED - to disable the FieldLevel param in the CtCap 00257 * FLEVEL_ENABLED - to enable the FieldLevel param in the CtCap 00258 * FLEVEL_UNDEFINED - not set. In this case the code sets the param to 00259 * the value in the config. Now setted to disable the FieldLevel param 00260 * 00261 * @param ArrayList* props - the arrayList with the properties 00262 * @param const char* ct_Type - optional 00263 * @param const char* ver_CT - optional 00264 * @param int fieldLevel - three different status 00265 */ 00266 void addCtCap(ArrayList* props, const char* ct_Type = 0 , const char* ver_CT = 0, int fLevel = FLEVEL_UNDEFINED); 00267 00268 /** 00269 * Initialize this object with the given SyncSourceConfig 00270 * 00271 * @param sc the source config object 00272 */ 00273 void assign(const SyncSourceConfig& sc); 00274 00275 /** 00276 * Return fieldLevel param. Not implemented yet. Now just returns false 00277 * 00278 * @return bool fieldLevel 00279 */ 00280 bool getFieldLevel(){ return false;} 00281 00282 /** 00283 * Assign operator 00284 */ 00285 SyncSourceConfig& operator = (const SyncSourceConfig& sc) { 00286 assign(sc); 00287 return *this; 00288 } 00289 }; 00290 00291 00292 END_NAMESPACE 00293 00294 /** @} */ 00295 /** @endcond */ 00296 #endif