Upstream tarball 20080304
[amule.git] / src / utils / wxCas / src / wxcascte.cpp
blobceacf580c776c04602db5bdbc052f6865bce6d42
1 //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
2 /// Name: wxCasCte Structure
3 ///
4 /// Purpose: Store constants used in wxCas application
5 ///
6 /// Author: ThePolish <thepolish@vipmail.ru>
7 ///
8 /// Copyright (C) 2004 by ThePolish
9 ///
10 /// Derived from CAS by Pedro de Oliveira <falso@rdk.homeip.net>
11 ///
12 /// Pixmats from aMule http://www.amule.org
13 ///
14 /// This program is free software; you can redistribute it and/or modify
15 /// it under the terms of the GNU General Public License as published by
16 /// the Free Software Foundation; either version 2 of the License, or
17 /// (at your option) any later version.
18 ///
19 /// This program is distributed in the hope that it will be useful,
20 /// but WITHOUT ANY WARRANTY; without even the implied warranty of
21 /// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22 /// GNU General Public License for more details.
23 ///
24 /// You should have received a copy of the GNU General Public License
25 /// along with this program; if not, write to the
26 /// Free Software Foundation, Inc.,
27 /// 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
28 //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
30 // For compilers that support precompilation
32 #ifdef __BORLANDC__
33 #pragma hdrstop
34 #endif
36 #include <wx/filename.h>
38 #ifdef __WXMAC__
39 #include <CoreServices/CoreServices.h> // Do_not_auto_remove
40 #include <wx/mac/corefoundation/cfstring.h> // Do_not_auto_remove
41 #include <wx/intl.h> // Do_not_auto_remove
42 #elif defined(__WINDOWS__)
43 #include <winerror.h> // Do_not_auto_remove
44 #include <shlobj.h> // Do_not_auto_remove
45 #endif
47 #include "wxcascte.h"
49 const wxString
50 WxCasCte::AMULESIG_FILENAME ( wxT( "amulesig.dat" ) );
51 const wxString
52 WxCasCte::AMULESIG_IMG_NAME ( wxT( "aMule-online-sign" ) );
54 // Refresh rate limits
55 const wxUint32
56 WxCasCte::MIN_REFRESH_RATE = 1;
57 const wxUint32
58 WxCasCte::MAX_REFRESH_RATE = 3600;
60 // FTP update limits
61 const wxUint32
62 WxCasCte::MIN_FTP_RATE = 1;
63 const wxUint32
64 WxCasCte::MAX_FTP_RATE = 1440;
67 // Key config names
68 const wxString
69 WxCasCte::AMULESIG_PATH_KEY ( wxT( "OSDirectory" ) );
70 const wxString
71 WxCasCte::REFRESH_RATE_KEY ( wxT( "RefreshRate" ) );
73 const wxString
74 WxCasCte::ENABLE_AUTOSTATIMG_KEY ( wxT( "EnableAutoStatImg" ) );
75 const wxString
76 WxCasCte::AUTOSTATIMG_DIR_KEY ( wxT( "StatImgDirectory" ) );
77 const wxString
78 WxCasCte::AUTOSTATIMG_TYPE_KEY ( wxT( "StatImgType" ) );
80 const wxString
81 WxCasCte::ENABLE_FTP_UPDATE_KEY( wxT( "EnableFtpUpdate" ) );
82 const wxString
83 WxCasCte::FTP_UPDATE_RATE_KEY ( wxT( "FtpUpdateRate" ) );
84 const wxString
85 WxCasCte::FTP_URL_KEY ( wxT( "FtpUrl" ) );
86 const wxString
87 WxCasCte::FTP_PATH_KEY ( wxT( "FtpPath" ) );
88 const wxString
89 WxCasCte::FTP_USER_KEY ( wxT( "FtpUser" ) );
90 const wxString
91 WxCasCte::FTP_PASSWD_KEY ( wxT( "FtpPasswd" ) );
93 const wxString
94 WxCasCte::ABSOLUTE_MAX_DL_KEY ( wxT( "AbsoluteMaxDL" ) );
95 const wxString
96 WxCasCte::ABSOLUTE_MAX_DL_DATE_KEY ( wxT( "AbsoluteMaxDlDate" ) );
98 // Default config parameters
99 const wxString
100 WxCasCte::DEFAULT_AMULESIG_PATH ( GetDefaultAmulesigPath() );
101 const wxUint32
102 WxCasCte::DEFAULT_REFRESH_RATE = 5;
104 const bool
105 WxCasCte::DEFAULT_AUTOSTATIMG_ISENABLED = FALSE;
106 const wxString
107 WxCasCte::DEFAULT_AUTOSTATIMG_PATH ( wxFileName::GetHomeDir () );
108 const wxString
109 WxCasCte::DEFAULT_AUTOSTATIMG_TYPE ( wxT( "PNG" ) );
111 const bool
112 WxCasCte::DEFAULT_FTP_UPDATE_ISENABLED = FALSE;
113 const wxUint32
114 WxCasCte::DEFAULT_FTP_UPDATE_RATE = 10;
115 const wxString
116 WxCasCte::DEFAULT_FTP_URL( wxT( "ftp.myftp.cx" ) );
117 const wxString
118 WxCasCte::DEFAULT_FTP_PATH( wxT( "/pub/myamuledir" ) );
119 const wxString
120 WxCasCte::DEFAULT_FTP_USER( wxT( "anonymous" ) );
121 const wxString
122 WxCasCte::DEFAULT_FTP_PASSWD( wxT( "whiterabit@here" ) );
124 wxString GetDefaultAmulesigPath()
126 wxString strDir;
128 #ifdef __WXMAC__
130 FSRef fsRef;
131 if (FSFindFolder(kUserDomain, kApplicationSupportFolderType, kCreateFolder, &fsRef) == noErr)
133 CFURLRef urlRef = CFURLCreateFromFSRef(NULL, &fsRef);
134 CFStringRef cfString = CFURLCopyFileSystemPath(urlRef, kCFURLPOSIXPathStyle);
135 CFRelease(urlRef) ;
136 strDir = wxMacCFStringHolder(cfString).AsString(wxLocale::GetSystemEncoding())
137 + wxFileName::GetPathSeparator() + wxT("aMule");
140 #elif defined(__WINDOWS__)
142 LPITEMIDLIST pidl;
144 HRESULT hr = SHGetSpecialFolderLocation(NULL, CSIDL_APPDATA, &pidl);
146 if (SUCCEEDED(hr)) {
147 if (!SHGetPathFromIDList(pidl, wxStringBuffer(strDir, MAX_PATH))) {
148 strDir = wxEmptyString;
149 } else {
150 strDir = strDir + wxFileName::GetPathSeparator() + wxT("aMule");
154 if (pidl) {
155 LPMALLOC pMalloc;
156 SHGetMalloc(&pMalloc);
157 if (pMalloc) {
158 pMalloc->Free(pidl);
159 pMalloc->Release();
163 #else
165 strDir = wxFileName::GetHomeDir() + wxFileName::GetPathSeparator() + wxT(".aMule");
167 #endif
169 return strDir;
171 // File_checked_for_headers