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 00049 #include <string> 00050 00051 00054 #define PROPERTY_USE_SUBFOLDERS "useSubfolders" 00055 #define PROPERTY_FOLDER_PATH "folderPath" 00056 #define PROPERTY_SCHEDULED_SYNC "isScheduled" 00057 00059 #define PROPERTY_FILTER_DATE_LOWER "filterDateLower" 00060 #define PROPERTY_FILTER_DATE_UPPER "filterDateUpper" 00061 #define PROPERTY_FILTER_DATE_DIRECTION "filterDateDirection" 00062 00064 #define PROPERTY_SP "portal" 00065 #define PROPERTY_INSTALLDIR "installDir" 00066 00068 #define APPLICATION_URI "Funambol/OutlookClient" 00069 00070 00071 #define TIMEZONE_CONTEXT L"SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\Time Zones" 00072 00073 // it must be in the format 00074 // #define PASS_KEY<4 blanks>NULL 00075 #define PASS_KEY NULL 00076 00077 // to use the pass key customized also if no portal 00078 #define CARED_KEY false 00079 00083 typedef struct TimeZone { 00084 int index; // Unique index of timezone 00085 std::wstring keyName; // Unique name of timezone (english) 00086 std::wstring displayName; // The display name 00087 bool isDaylight; // 'true' if currently under Daylight Saving Time (DST). 00088 LONG bias; // The current bias for local time translation on this computer, in minutes. 00089 std::wstring standardName; // A description for standard time. 00090 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. 00091 LONG standardBias; // The bias value to be used during local time translations that occur during standard time 00092 std::wstring daylightName; // A description for daylight saving time. 00093 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. 00094 LONG daylightBias; // The bias value to be used during local time translations that occur during daylight saving time. 00095 } TimeZoneInformation; 00096 00097 00098 00099 00107 class OutlookConfig : public DMTClientConfig { 00108 00109 private: 00110 00112 static OutlookConfig* pinstance; 00113 00114 char* workingDir; // The path of current working directory 00115 char* logDir; // The path of current log directory (under app data) 00116 bool fullSync; // true if we are running a full sync (slow/refresh) 00117 bool abortSync; // set to true when we want to (soft) abort the current sync 00118 bool upgraded; // Flag to specify that we have upgraded the config. 00119 int oldSwv; // Value of old software version installed (used during upgrades). 00120 00122 TimeZoneInformation currentTimezone; 00123 00125 WindowsSyncSourceConfig* winSourceConfigs; 00126 00129 unsigned int winSourceConfigsCount; 00130 00131 00132 00133 void readWinSourceConfig(unsigned int i); 00134 void saveWinSourceConfig(unsigned int i); 00135 00136 00137 // Returns the value of the given property, from rootKey tree (read only). 00138 char* readPropertyValue(const char* context, const char* propertyName, HKEY rootKey); 00139 00140 // Username/Password are stored encrypted (new since 6.0.9). 00141 int decryptPrivateData(); 00142 void encryptPrivateData(); 00143 00144 int readCurrentTimezone(); 00145 00146 00147 protected: 00148 00150 OutlookConfig(); 00151 00152 00153 public: 00154 00156 static OutlookConfig* getInstance(); 00157 00159 static bool isInstantiated(); 00160 00162 ~OutlookConfig(); 00163 00164 00165 // Override read/save methods of DMT (use specific winSourceConfig) 00166 bool read(); 00167 bool save(); 00168 bool save(SyncReport* report); 00169 00170 00172 void readSourcesTimestamps(); 00173 00174 00176 _declspec(dllexport) WindowsSyncSourceConfig* getSyncSourceConfig(const char* name); 00177 WindowsSyncSourceConfig* getSyncSourceConfig(unsigned int i); 00178 00179 // Replace setSyncSourceConfig() of SyncManagerConfig (set specific winSourceConfig) 00180 BOOL setSyncSourceConfig(WindowsSyncSourceConfig& wsc); 00181 BOOL addSyncSourceConfig(WindowsSyncSourceConfig& wsc); 00182 00183 00184 // get/set of internal members 00185 void setWorkingDir (const char* v); 00186 void setLogDir (const char* v); 00187 void setFullSync (const bool v); 00188 void setScheduledSync(const bool v); 00189 void setAbortSync (const bool v); 00190 00191 const bool getScheduledSync() const; 00192 const bool getAbortSync() const; 00193 _declspec(dllexport) const char* getWorkingDir() const; 00194 _declspec(dllexport) const char* getLogDir() const; 00195 _declspec(dllexport) const bool getFullSync() const; 00196 00197 const TimeZoneInformation* getCurrentTimezone() const; 00198 00199 00201 void createDefaultConfig(); 00202 00204 bool checkToUpgrade(); 00205 00207 void upgradeConfig(); 00208 00210 bool isUpgraded(); 00211 00213 int getOldSwv(); 00214 00216 char* readCurrentSwv(); 00217 00219 int setUniqueDevID(); 00220 00222 bool checkPortalBuild(); 00223 00225 void saveBeginSync(); 00226 00228 void saveSyncModes(); 00230 _declspec(dllexport) void readSyncModes(); 00231 }; 00232 00235 #endif