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 "WindowsDeviceConfig.h" 00050 00051 #include <string> 00052 00053 00056 #define PROPERTY_USE_SUBFOLDERS "useSubfolders" 00057 #define PROPERTY_FOLDER_PATH "folderPath" 00058 #define PROPERTY_SCHEDULED_SYNC "isScheduled" 00059 #define PROPERTY_SOURCE_ORDER "sourceOrder" 00060 00062 #define PROPERTY_FILTER_DATE_LOWER "filterDateLower" 00063 #define PROPERTY_FILTER_DATE_UPPER "filterDateUpper" 00064 #define PROPERTY_FILTER_DATE_DIRECTION "filterDateDirection" 00065 00067 #define PROPERTY_SP "portal" 00068 #define PROPERTY_INSTALLDIR "installDir" 00069 #define PROPERTY_FUNAMBOL_SWV "funambol_swv" 00070 #define PROPERTY_CUSTOMER "Customer" 00071 00073 #define APPLICATION_URI PROGRAM_NAME "/OutlookClient" 00074 00075 #define TIMEZONE_CONTEXT L"SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\Time Zones" 00076 00080 typedef struct TimeZone { 00081 int index; // Unique index of timezone 00082 std::wstring keyName; // Unique name of timezone (english) 00083 std::wstring displayName; // The display name 00084 bool isDaylight; // 'true' if currently under Daylight Saving Time (DST). 00085 LONG bias; // The current bias for local time translation on this computer, in minutes. 00086 std::wstring standardName; // A description for standard time. 00087 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. 00088 LONG standardBias; // The bias value to be used during local time translations that occur during standard time 00089 std::wstring daylightName; // A description for daylight saving time. 00090 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. 00091 LONG daylightBias; // The bias value to be used during local time translations that occur during daylight saving time. 00092 } TimeZoneInformation; 00093 00094 00095 00096 00104 class OutlookConfig : public DMTClientConfig { 00105 00106 private: 00107 00109 static OutlookConfig* pinstance; 00110 00111 char* workingDir; // The path of current working directory 00112 char* logDir; // The path of current log directory (under app data) 00113 bool fullSync; // true if we are running a full sync (slow/refresh) 00114 bool abortSync; // set to true when we want to (soft) abort the current sync 00115 bool upgraded; // Flag to specify that we have upgraded the config. 00116 int oldSwv; // Value of old software version installed (used during upgrades). 00117 StringBuffer funambolSwv; // The Funambol product sw version (can be different in branded clients). 00118 int oldFunambolSwv; // The old Funambol product sw version value in case of upgrade. 00119 00120 bool attach; // Flag to require outlook be open to sync 00121 00125 bool oneWayRemoval; 00126 00128 TimeZoneInformation currentTimezone; 00129 00131 WindowsSyncSourceConfig* winSourceConfigs; 00132 00133 // 00134 WindowsDeviceConfig* winDC; 00135 00138 unsigned int winSourceConfigsCount; 00139 00145 ArrayList sourcesVisible; 00146 00147 00148 void readWinSourceConfig(unsigned int i); 00149 void saveWinSourceConfig(unsigned int i); 00150 00151 00152 // Returns the value of the given property, from rootKey tree (read only). 00153 char* readPropertyValue(const char* context, const char* propertyName, HKEY rootKey); 00154 00155 // Username/Password are stored encrypted (new since 6.0.9). 00156 int decryptPrivateData(); 00157 void encryptPrivateData(); 00158 00159 int readCurrentTimezone(); 00160 00167 void readSourcesVisible(HKEY rootKey = HKEY_CURRENT_USER); 00168 00173 void saveSourcesVisible(); 00174 00181 void savePropertyValue(const StringBuffer& context, const StringBuffer& name, const StringBuffer& value); 00182 00186 UpdaterConfig updaterConfig; 00187 00188 protected: 00189 00191 OutlookConfig(); 00192 00193 public: 00194 00196 _declspec(dllexport) 00197 static OutlookConfig* getInstance(); 00198 00200 static bool isInstantiated(); 00201 00203 virtual ~OutlookConfig(); 00204 00205 00206 // Override read/save methods of DMT (use specific winSourceConfig) 00207 bool read(); 00208 bool save(); 00209 bool save(SyncReport* report); 00210 00211 00213 void readSourcesTimestamps(); 00214 00215 00217 const ArrayList& getSourcesVisible(); 00218 00219 00221 _declspec(dllexport) WindowsSyncSourceConfig* getSyncSourceConfig(const char* name); 00222 WindowsSyncSourceConfig* getSyncSourceConfig(unsigned int i); 00223 00233 bool addWindowsSyncSourceConfig(const std::wstring& sourceName); 00234 00240 bool safeAddSourceVisible(const char* sourceName); 00241 00246 bool removeSourceVisible(const char* sourceName); 00247 00248 00249 // Replace setSyncSourceConfig() of SyncManagerConfig (set specific winSourceConfig) 00250 bool setSyncSourceConfig(WindowsSyncSourceConfig& wsc); 00251 bool addSyncSourceConfig(WindowsSyncSourceConfig& wsc); 00252 00253 00254 // get/set of internal members 00255 void setWorkingDir (const char* v); 00256 void setLogDir (const char* v); 00257 void setFullSync (const bool v); 00258 void setScheduledSync(const bool v); 00259 void setAbortSync (const bool v); 00260 void setFunambolSwv (const StringBuffer& v); 00261 00262 00263 const bool getScheduledSync() const; 00264 const bool getAbortSync() const; 00265 _declspec(dllexport) const char* getWorkingDir() const; 00266 _declspec(dllexport) const char* getLogDir() const; 00267 _declspec(dllexport) const bool getFullSync() const; 00268 const StringBuffer& getFunambolSwv(); 00269 00270 _declspec(dllexport) 00271 const TimeZoneInformation* getCurrentTimezone() const; 00272 00273 00275 void createDefaultConfig(); 00276 00278 _declspec(dllexport) 00279 bool checkToUpgrade(); 00280 00282 void upgradeConfig(); 00283 00285 bool isUpgraded(); 00286 00288 _declspec(dllexport) 00289 int getOldSwv(); 00290 int getOldFunambolSwv(); 00291 00293 char* readCurrentSwv(); 00294 00299 StringBuffer readFunambolSwv(HKEY rootKey); 00300 00302 int setUniqueDevID(); 00303 00304 // Check if it's a normal/portal build (from HKLM keys). 00305 // DEPRECATED: portal build is now a normal build. 00306 //bool checkPortalBuild(); 00307 00309 void saveBeginSync(); 00310 00312 void OutlookConfig::saveFunambolSwv(); 00313 00315 void saveSyncModes(); 00316 00318 _declspec(dllexport) void readSyncModes(); 00319 00320 BOOL readUpdaterConfig(bool refresh); 00321 00325 void storeUpdaterConfig(); 00326 00327 UpdaterConfig& getUpdaterConfig(); 00328 00330 void initializeVersionsAndUserAgent(); 00331 00332 00333 void setDeviceConfig(const WindowsDeviceConfig & wdc); 00334 _declspec(dllexport) WindowsDeviceConfig & getWindowsDeviceConfig(); 00335 WindowsDeviceConfig & getDeviceConfig(); 00336 00337 void saveDeviceConfig(ManagementNode& n, bool server = false); 00338 bool readDeviceConfig(ManagementNode& n, bool server = false); 00339 00341 void setOneWayRemoval(const bool val) { oneWayRemoval = val; } 00342 00344 bool getOneWayRemoval() { return oneWayRemoval; } 00345 00346 }; 00347 00350 #endif