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 00041 #ifndef INCL_OUTLOOKCONFIG 00042 #define INCL_OUTLOOKCONFIG 00043 00044 #include "base/Log.h" 00045 #include "spds/SyncReport.h" 00046 #include "Client/DMTClientConfig.h" 00047 #include "WindowsSyncSourceConfig.h" 00048 #include "updater/UpdaterConfig.h" 00049 #include <string> 00050 00051 00054 #define PROPERTY_USE_SUBFOLDERS "useSubfolders" 00055 #define PROPERTY_FOLDER_PATH "folderPath" 00056 #define PROPERTY_SCHEDULED_SYNC "isScheduled" 00057 #define PROPERTY_SOURCE_ORDER "sourceOrder" 00058 00060 #define PROPERTY_FILTER_DATE_LOWER "filterDateLower" 00061 #define PROPERTY_FILTER_DATE_UPPER "filterDateUpper" 00062 #define PROPERTY_FILTER_DATE_DIRECTION "filterDateDirection" 00063 00065 #define PROPERTY_SP "portal" 00066 #define PROPERTY_INSTALLDIR "installDir" 00067 #define PROPERTY_FUNAMBOL_SWV "funambol_swv" 00068 #define PROPERTY_CUSTOMER "Customer" 00069 00070 #define TIMEZONE_CONTEXT L"SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\Time Zones" 00071 00072 // it must be in the format 00073 // #define PASS_KEY<4 blanks>NULL 00074 #define PASS_KEY NULL 00075 00076 // to use the pass key customized also if no portal 00077 #define CARED_KEY false 00078 00082 typedef struct TimeZone { 00083 int index; // Unique index of timezone 00084 std::wstring keyName; // Unique name of timezone (english) 00085 std::wstring displayName; // The display name 00086 bool isDaylight; // 'true' if currently under Daylight Saving Time (DST). 00087 LONG bias; // The current bias for local time translation on this computer, in minutes. 00088 std::wstring standardName; // A description for standard time. 00089 SYSTEMTIME standardDate; // A SYSTEMTIME structure that contains a date and local time when the transition from daylight saving time to standard time occurs on this operating system. 00090 LONG standardBias; // The bias value to be used during local time translations that occur during standard time 00091 std::wstring daylightName; // A description for daylight saving time. 00092 SYSTEMTIME daylightDate; // A SYSTEMTIME structure that contains a date and local time when the transition from standard time to daylight saving time occurs on this operating system. 00093 LONG daylightBias; // The bias value to be used during local time translations that occur during daylight saving time. 00094 } TimeZoneInformation; 00095 00096 00097 00098 00106 class OutlookConfig : public DMTClientConfig { 00107 00108 private: 00109 00111 static OutlookConfig* pinstance; 00112 00113 char* workingDir; // The path of current working directory 00114 char* logDir; // The path of current log directory (under app data) 00115 bool fullSync; // true if we are running a full sync (slow/refresh) 00116 bool abortSync; // set to true when we want to (soft) abort the current sync 00117 bool upgraded; // Flag to specify that we have upgraded the config. 00118 int oldSwv; // Value of old software version installed (used during upgrades). 00119 StringBuffer funambolSwv; // The Funambol product sw version (can be different in branded clients). 00120 int oldFunambolSwv; // The old Funambol product sw version value in case of upgrade. 00121 00123 TimeZoneInformation currentTimezone; 00124 00126 WindowsSyncSourceConfig* winSourceConfigs; 00127 00130 unsigned int winSourceConfigsCount; 00131 00137 ArrayList sourcesVisible; 00138 00139 00140 void readWinSourceConfig(unsigned int i); 00141 void saveWinSourceConfig(unsigned int i); 00142 00143 00144 // Returns the value of the given property, from rootKey tree (read only). 00145 char* readPropertyValue(const char* context, const char* propertyName, HKEY rootKey); 00146 00147 // Username/Password are stored encrypted (new since 6.0.9). 00148 int decryptPrivateData(); 00149 void encryptPrivateData(); 00150 00151 int readCurrentTimezone(); 00152 00159 void readSourcesVisible(HKEY rootKey = HKEY_CURRENT_USER); 00160 00165 void saveSourcesVisible(); 00166 00173 void savePropertyValue(const StringBuffer& context, const StringBuffer& name, const StringBuffer& value); 00174 00178 UpdaterConfig updaterConfig; 00179 00180 protected: 00181 00183 OutlookConfig(); 00184 00185 // Replace setSyncSourceConfig() of SyncManagerConfig (set specific winSourceConfig) 00186 BOOL setSyncSourceConfig(WindowsSyncSourceConfig& wsc); 00187 BOOL addSyncSourceConfig(WindowsSyncSourceConfig& wsc); 00188 00189 00190 public: 00191 00193 static OutlookConfig* getInstance(); 00194 00196 static bool isInstantiated(); 00197 00199 virtual ~OutlookConfig(); 00200 00201 00202 // Override read/save methods of DMT (use specific winSourceConfig) 00203 bool read(); 00204 bool save(); 00205 bool save(SyncReport* report); 00206 00207 00209 void readSourcesTimestamps(); 00210 00211 00213 const ArrayList& getSourcesVisible(); 00214 00215 00217 _declspec(dllexport) WindowsSyncSourceConfig* getSyncSourceConfig(const char* name); 00218 WindowsSyncSourceConfig* getSyncSourceConfig(unsigned int i); 00219 00229 bool addWindowsSyncSourceConfig(const std::wstring& sourceName); 00230 00236 bool safeAddSourceVisible(const char* sourceName); 00237 00242 bool removeSourceVisible(const char* sourceName); 00243 00244 00245 // get/set of internal members 00246 void setWorkingDir (const char* v); 00247 void setLogDir (const char* v); 00248 void setFullSync (const bool v); 00249 void setScheduledSync(const bool v); 00250 void setAbortSync (const bool v); 00251 void setFunambolSwv (const StringBuffer& v); 00252 00253 const bool getScheduledSync() const; 00254 const bool getAbortSync() const; 00255 _declspec(dllexport) const char* getWorkingDir() const; 00256 _declspec(dllexport) const char* getLogDir() const; 00257 _declspec(dllexport) const bool getFullSync() const; 00258 const StringBuffer& getFunambolSwv(); 00259 00260 00261 const TimeZoneInformation* getCurrentTimezone() const; 00262 00263 00265 void createDefaultConfig(); 00266 00268 bool checkToUpgrade(); 00269 00271 void upgradeConfig(); 00272 00274 bool isUpgraded(); 00275 00277 int getOldSwv(); 00278 int getOldFunambolSwv(); 00279 00281 char* readCurrentSwv(); 00282 00287 StringBuffer readFunambolSwv(HKEY rootKey); 00288 00290 int setUniqueDevID(); 00291 00293 bool checkPortalBuild(); 00294 00296 void saveBeginSync(); 00297 00299 void OutlookConfig::saveFunambolSwv(); 00300 00302 void saveSyncModes(); 00303 00305 _declspec(dllexport) void readSyncModes(); 00306 00307 BOOL readUpdaterConfig(bool refresh); 00308 00312 void storeUpdaterConfig(); 00313 00314 UpdaterConfig& getUpdaterConfig(); 00315 00316 }; 00317 00320 #endif