00001 // $Id: optsinet.cpp 1282 2006-06-09 09:46:49Z alex $ 00002 /* @@tag:xara-cn@@ DO NOT MODIFY THIS LINE 00003 ================================XARAHEADERSTART=========================== 00004 00005 Xara LX, a vector drawing and manipulation program. 00006 Copyright (C) 1993-2006 Xara Group Ltd. 00007 Copyright on certain contributions may be held in joint with their 00008 respective authors. See AUTHORS file for details. 00009 00010 LICENSE TO USE AND MODIFY SOFTWARE 00011 ---------------------------------- 00012 00013 This file is part of Xara LX. 00014 00015 Xara LX is free software; you can redistribute it and/or modify it 00016 under the terms of the GNU General Public License version 2 as published 00017 by the Free Software Foundation. 00018 00019 Xara LX and its component source files are distributed in the hope 00020 that it will be useful, but WITHOUT ANY WARRANTY; without even the 00021 implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 00022 See the GNU General Public License for more details. 00023 00024 You should have received a copy of the GNU General Public License along 00025 with Xara LX (see the file GPL in the root directory of the 00026 distribution); if not, write to the Free Software Foundation, Inc., 51 00027 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 00028 00029 00030 ADDITIONAL RIGHTS 00031 ----------------- 00032 00033 Conditional upon your continuing compliance with the GNU General Public 00034 License described above, Xara Group Ltd grants to you certain additional 00035 rights. 00036 00037 The additional rights are to use, modify, and distribute the software 00038 together with the wxWidgets library, the wxXtra library, and the "CDraw" 00039 library and any other such library that any version of Xara LX relased 00040 by Xara Group Ltd requires in order to compile and execute, including 00041 the static linking of that library to XaraLX. In the case of the 00042 "CDraw" library, you may satisfy obligation under the GNU General Public 00043 License to provide source code by providing a binary copy of the library 00044 concerned and a copy of the license accompanying it. 00045 00046 Nothing in this section restricts any of the rights you have under 00047 the GNU General Public License. 00048 00049 00050 SCOPE OF LICENSE 00051 ---------------- 00052 00053 This license applies to this program (XaraLX) and its constituent source 00054 files only, and does not necessarily apply to other Xara products which may 00055 in part share the same code base, and are subject to their own licensing 00056 terms. 00057 00058 This license does not apply to files in the wxXtra directory, which 00059 are built into a separate library, and are subject to the wxWindows 00060 license contained within that directory in the file "WXXTRA-LICENSE". 00061 00062 This license does not apply to the binary libraries (if any) within 00063 the "libs" directory, which are subject to a separate license contained 00064 within that directory in the file "LIBS-LICENSE". 00065 00066 00067 ARRANGEMENTS FOR CONTRIBUTION OF MODIFICATIONS 00068 ---------------------------------------------- 00069 00070 Subject to the terms of the GNU Public License (see above), you are 00071 free to do whatever you like with your modifications. However, you may 00072 (at your option) wish contribute them to Xara's source tree. You can 00073 find details of how to do this at: 00074 http://www.xaraxtreme.org/developers/ 00075 00076 Prior to contributing your modifications, you will need to complete our 00077 contributor agreement. This can be found at: 00078 http://www.xaraxtreme.org/developers/contribute/ 00079 00080 Please note that Xara will not accept modifications which modify any of 00081 the text between the start and end of this header (marked 00082 XARAHEADERSTART and XARAHEADEREND). 00083 00084 00085 MARKS 00086 ----- 00087 00088 Xara, Xara LX, Xara X, Xara X/Xtreme, Xara Xtreme, the Xtreme and Xara 00089 designs are registered or unregistered trademarks, design-marks, and/or 00090 service marks of Xara Group Ltd. All rights in these marks are reserved. 00091 00092 00093 Xara Group Ltd, Gaddesden Place, Hemel Hempstead, HP2 6EX, UK. 00094 http://www.xara.com/ 00095 00096 =================================XARAHEADEREND============================ 00097 */ 00098 00099 #include "camtypes.h" 00100 #include "appprefs.h" 00101 #include "optsinet.h" // dialog/gadget ids 00102 //#include "optsres.h" // _R(IDS_PROXY)... 00103 //#include "app.h" // Camelot object - in camtypes.h [AUTOMATICALLY REMOVED] 00104 //#include "document.h" // document object - in camtypes.h [AUTOMATICALLY REMOVED] 00105 //#include "spread.h" // spread object - in camtypes.h [AUTOMATICALLY REMOVED] 00106 #include "page.h" // page object 00107 //#include "webster.h" 00108 #include "camnet.h" 00109 00110 //#include "resource.h" // _R(IDS_CANCEL)# 00111 00112 CC_IMPLEMENT_DYNAMIC(InternetTab, OptionsTabs) 00113 00114 /****************************************************************************************** 00115 00116 > BOOL InternetTab::CommitSection() 00117 00118 Author: Adrian_Stoicar (Xara Group Ltd) <camelotdev@xara.com> 00119 Created: 18/06/97 00120 Returns: TRUE if succesful, FALSE otherwise 00121 Purpose: Effect any changes made to the Internet settings 00122 00123 ******************************************************************************************/ 00124 00125 BOOL InternetTab::CommitSection() 00126 { 00127 ERROR2IF(pPrefsDlg==NULL,FALSE,"GridTab::CommitSection() - pPrefsDlg==NULL"); 00128 if (pPrefsDlg->TalkToPage(_R(IDD_OPTSTAB_INTERNET))==FALSE) 00129 return TRUE; // just return with no error 00130 00131 // Read in the new potential cache size 00132 BOOL Valid = TRUE; 00133 UINT32 lCacheSize = pPrefsDlg->GetMemoryGadgetValue(_R(IDC_CACHESIZE),1024,UINT32_MAX,_R(IDS_INVALIDCACHESIZE),&Valid); 00134 00135 if ((lCacheSize < 500 * SIZEOFKILOBYTE) || (lCacheSize == UINT32_MAX)) 00136 { 00137 InformWarning(_R(IDS_INVALIDCACHESIZE)); 00138 00139 if (lCacheSize < 500 * SIZEOFKILOBYTE) 00140 { 00141 lCacheSize = 500 * SIZEOFKILOBYTE; 00142 } 00143 else 00144 { 00145 lCacheSize = UINT32_MAX; 00146 } 00147 00148 pPrefsDlg->SetMemoryGadgetValue(_R(IDC_CACHESIZE), lCacheSize); 00149 } 00150 00151 if(!Valid) return FALSE; 00152 00153 if (Valid && !DownloadCache::SetSize(lCacheSize)) 00154 { 00155 InformError(_R(IDS_INSUFFICIENT_DISK_SPACE)); 00156 return FALSE; 00157 } 00158 00159 UINT32 lCacheUsage = DownloadCache::GetUsage(); 00160 pPrefsDlg->SetLongGadgetValue(_R(IDC_CACHEUSAGE), lCacheUsage); 00161 00162 // Sort out the connection type 00163 if (pPrefsDlg->GetBoolGadgetSelected(_R(IDC_14K))) 00164 InternetManager::SetConnectionType(CONNECTION_SLOWMODEM); 00165 else if (pPrefsDlg->GetBoolGadgetSelected(_R(IDC_28K))) 00166 InternetManager::SetConnectionType(CONNECTION_FASTMODEM); 00167 else if (pPrefsDlg->GetBoolGadgetSelected(_R(IDC_56K))) 00168 InternetManager::SetConnectionType(CONNECTION_X2); 00169 else if (pPrefsDlg->GetBoolGadgetSelected(_R(IDC_ISDN))) 00170 InternetManager::SetConnectionType(CONNECTION_ISDN); 00171 return TRUE; 00172 } 00173 00174 00175 /******************************************************************************************** 00176 00177 > BOOL InternetTab::HandleMsg(DialogMsg* Msg) 00178 00179 Author: Adrian_Stoicar (Xara Group Ltd) <camelotdev@xara.com> 00180 Created: 5/07/97 00181 Inputs: - 00182 Outputs: - 00183 Returns: - 00184 Purpose: Handles all the Internet options tabs messages 00185 Errors: - 00186 SeeAlso: - 00187 00188 ********************************************************************************************/ 00189 00190 BOOL InternetTab::HandleMsg(DialogMsg* Msg) 00191 { 00192 ERROR2IF(Msg == NULL,FALSE,"Null message received"); 00193 ERROR2IF(pPrefsDlg == NULL,FALSE,"HandleMsg called with no dialog pointer"); 00194 00195 BOOL ok = pPrefsDlg->TalkToPage(_R(IDD_OPTSTAB_INTERNET)); // The Page page identifier 00196 if (!ok) 00197 return TRUE; // page not present 00198 00199 switch(Msg->DlgMsg) 00200 { 00201 case DIM_CREATE: // Initialise controls 00202 ok = InitSection(); 00203 if (!ok) 00204 InformError(); 00205 break; 00206 case DIM_TEXT_CHANGED: 00207 OptionsTabs::SetApplyNowState(TRUE); 00208 OptionsTabs::UngreyApplyNow(); 00209 break; 00210 case DIM_LFT_BN_CLICKED: 00211 switch (Msg->GadgetID) 00212 { 00213 case _R(IDC_FLUSHCACHE): 00214 { 00215 DownloadCache::Flush(); 00216 UINT32 lCacheUsage = DownloadCache::GetUsage(); 00217 pPrefsDlg->SetMemoryGadgetValue(_R(IDC_CACHEUSAGE), lCacheUsage); 00218 } 00219 break; 00220 default: 00221 OptionsTabs::SetApplyNowState(TRUE); 00222 } 00223 break; 00224 } 00225 return TRUE; 00226 } 00227 00228 00229 /****************************************************************************************** 00230 00231 > BOOL GridTab::InitSection() 00232 00233 Author: Neville_Humphrys (Xara Group Ltd) <camelotdev@xara.com> 00234 Created: 5/10/95 00235 Inputs: - 00236 Outputs: - 00237 Returns: TRUE if successful, else FALSE 00238 Purpose: Sets initial values for the Page section of the options dialog box. 00239 This section includes the:- 00240 Errors: - 00241 SeeAlso: AppPrefsDlg; OptionsTabs; UpdateSection; 00242 00243 ******************************************************************************************/ 00244 00245 BOOL InternetTab::InitSection() 00246 { 00247 ERROR2IF(pPrefsDlg == NULL,FALSE,"InitSection called with no dialog pointer"); 00248 00249 // Fill in the data regardless of whether the proxy is enabled or not 00250 // Now get the current settings 00251 TCHAR szHostName[INTERNET_MAX_PATH_LENGTH]; 00252 SERVENT proxyEntry = {szHostName, NULL, 0x0000, NULL}; 00253 bool bProxyEnabled; 00254 00255 String_256 strProxyNote(_T("")); 00256 00257 if (!InternetManager::GetProxyServer(&proxyEntry, &bProxyEnabled)) 00258 { 00259 // failed to read proxy settings 00260 String_256 strProxyError(_R(IDS_PROXY_SUB_ERROR)); 00261 strProxyNote.MakeMsg(_R(IDS_PROXY_NOTE), static_cast<TCHAR *>(strProxyError)); 00262 } 00263 else 00264 { 00265 // read settings ok 00266 if (bProxyEnabled) 00267 { 00268 // proxy server enabled 00269 String_256 strProxyEnabled; 00270 strProxyEnabled.MakeMsg(_R(IDS_PROXY_SUB_ENABLED), proxyEntry.s_name, proxyEntry.s_port); 00271 strProxyNote.MakeMsg(_R(IDS_PROXY_NOTE), static_cast<TCHAR *>(strProxyEnabled)); 00272 } 00273 else 00274 { 00275 // proxy server disabled 00276 String_256 strProxyDisabled(_R(IDS_PROXY_SUB_DISABLED)); 00277 strProxyNote.MakeMsg(_R(IDS_PROXY_NOTE), static_cast<TCHAR *>(strProxyDisabled)); 00278 } 00279 } 00280 00281 pPrefsDlg->SetStringGadgetValue(_R(IDC_PROXY_DETAILS), &strProxyNote); 00282 00283 // Sort out the connection type 00284 UINT32 nSelID; 00285 switch (InternetManager::GetConnectionType()) 00286 { 00287 case CONNECTION_SLOWMODEM: 00288 nSelID = _R(IDC_14K); 00289 break; 00290 case CONNECTION_FASTMODEM: 00291 nSelID = _R(IDC_28K); 00292 break; 00293 case CONNECTION_X2: 00294 nSelID = _R(IDC_56K); 00295 break; 00296 case CONNECTION_ISDN: 00297 nSelID = _R(IDC_ISDN); 00298 } 00299 pPrefsDlg->SetBoolGadgetSelected(nSelID, TRUE); 00300 00301 00302 // Sort out the download cache section. 00303 UINT32 lCacheUsage = DownloadCache::GetUsage(); 00304 pPrefsDlg->SetLongGadgetValue(_R(IDC_CACHEUSAGE), lCacheUsage); 00305 00306 UINT32 lCacheSize = DownloadCache::GetSize(); 00307 pPrefsDlg->SetMemoryGadgetValue(_R(IDC_CACHESIZE), lCacheSize); 00308 return TRUE; 00309 } 00310 00311