]>
Commit | Line | Data |
---|---|---|
1 | ///////////////////////////////////////////////////////////////////////////// | |
2 | // Name: src/palmos/utils.cpp | |
3 | // Purpose: Various utilities | |
4 | // Author: William Osborne - minimal working wxPalmOS port | |
5 | // Modified by: Wlodzimierz ABX Skiba - real functionality | |
6 | // Created: 10/13/04 | |
7 | // RCS-ID: $Id$ | |
8 | // Copyright: (c) William Osborne, Wlodzimierz Skiba | |
9 | // Licence: wxWindows licence | |
10 | ///////////////////////////////////////////////////////////////////////////// | |
11 | ||
12 | // ============================================================================ | |
13 | // declarations | |
14 | // ============================================================================ | |
15 | ||
16 | // ---------------------------------------------------------------------------- | |
17 | // headers | |
18 | // ---------------------------------------------------------------------------- | |
19 | ||
20 | // For compilers that support precompilation, includes "wx.h". | |
21 | #include "wx/wxprec.h" | |
22 | ||
23 | #ifdef __BORLANDC__ | |
24 | #pragma hdrstop | |
25 | #endif | |
26 | ||
27 | #ifndef WX_PRECOMP | |
28 | #include "wx/utils.h" | |
29 | #include "wx/app.h" | |
30 | #include "wx/intl.h" | |
31 | #include "wx/log.h" | |
32 | #include "wx/timer.h" | |
33 | #endif //WX_PRECOMP | |
34 | ||
35 | #include "wx/apptrait.h" | |
36 | #include "wx/dynload.h" | |
37 | #include "wx/confbase.h" | |
38 | #include "wx/power.h" | |
39 | ||
40 | #include <MemoryMgr.h> | |
41 | #include <DLServer.h> | |
42 | #include <SoundMgr.h> | |
43 | #include <SysUtils.h> | |
44 | ||
45 | // ============================================================================ | |
46 | // implementation | |
47 | // ============================================================================ | |
48 | ||
49 | // ---------------------------------------------------------------------------- | |
50 | // get host name and related | |
51 | // ---------------------------------------------------------------------------- | |
52 | ||
53 | // Get hostname only (without domain name) | |
54 | bool wxGetHostName(wxChar *buf, int maxSize) | |
55 | { | |
56 | return false; | |
57 | } | |
58 | ||
59 | // get full hostname (with domain name if possible) | |
60 | bool wxGetFullHostName(wxChar *buf, int maxSize) | |
61 | { | |
62 | return false; | |
63 | } | |
64 | ||
65 | // Get user ID e.g. jacs | |
66 | bool wxGetUserId(wxChar *buf, int maxSize) | |
67 | { | |
68 | return wxGetUserName(buf, maxSize); | |
69 | } | |
70 | ||
71 | // Get user name e.g. Julian Smart | |
72 | bool wxGetUserName(wxChar *buf, int maxSize) | |
73 | { | |
74 | *buf = wxT('\0'); | |
75 | ||
76 | // buffer allocation | |
77 | MemHandle handle = MemHandleNew(maxSize-1); | |
78 | if( handle == NULL ) | |
79 | return false; | |
80 | ||
81 | // lock the buffer | |
82 | char *id = (char *)MemHandleLock(handle); | |
83 | if( id == NULL ) | |
84 | return false; | |
85 | ||
86 | // get user's name | |
87 | if( DlkGetSyncInfo(NULL, NULL, NULL, id, NULL, NULL) != errNone ) | |
88 | { | |
89 | MemPtrUnlock(id); | |
90 | return false; | |
91 | } | |
92 | ||
93 | wxStrncpy (buf, wxSafeConvertMB2WX(id), maxSize - 1); | |
94 | ||
95 | // free the buffer | |
96 | MemPtrUnlock(id); | |
97 | ||
98 | return true; | |
99 | } | |
100 | ||
101 | const wxChar* wxGetHomeDir(wxString *pstr) | |
102 | { | |
103 | return NULL; | |
104 | } | |
105 | ||
106 | wxString wxGetUserHome(const wxString& WXUNUSED(user)) | |
107 | { | |
108 | return wxString(); | |
109 | } | |
110 | ||
111 | bool wxGetDiskSpace(const wxString& path, wxDiskspaceSize_t *pTotal, wxDiskspaceSize_t *pFree) | |
112 | { | |
113 | return false; | |
114 | } | |
115 | ||
116 | // ---------------------------------------------------------------------------- | |
117 | // env vars | |
118 | // ---------------------------------------------------------------------------- | |
119 | ||
120 | bool wxGetEnv(const wxString& var, wxString *value) | |
121 | { | |
122 | return false; | |
123 | } | |
124 | ||
125 | #if ! WXWIN_COMPATIBILITY_2_8 | |
126 | bool wxSetEnv(const wxString& var, const wxChar *value) | |
127 | { | |
128 | return false; | |
129 | } | |
130 | #endif // ! WXWIN_COMPATIBILITY_2_8 | |
131 | ||
132 | bool wxUnsetEnv(const wxString& var) | |
133 | { | |
134 | return false; | |
135 | } | |
136 | ||
137 | // ---------------------------------------------------------------------------- | |
138 | // process management | |
139 | // ---------------------------------------------------------------------------- | |
140 | ||
141 | int wxKill(long pid, wxSignal sig, wxKillError *krc, int flags) | |
142 | { | |
143 | return 0; | |
144 | } | |
145 | ||
146 | // Execute a program in an Interactive Shell | |
147 | bool wxShell(const wxString& command) | |
148 | { | |
149 | return false; | |
150 | } | |
151 | ||
152 | // Shutdown or reboot the PC | |
153 | bool wxShutdown(wxShutdownFlags wFlags) | |
154 | { | |
155 | return false; | |
156 | } | |
157 | ||
158 | // ---------------------------------------------------------------------------- | |
159 | // power management | |
160 | // ---------------------------------------------------------------------------- | |
161 | ||
162 | wxPowerType wxGetPowerType() | |
163 | { | |
164 | return wxPOWER_BATTERY; | |
165 | } | |
166 | ||
167 | wxBatteryState wxGetBatteryState() | |
168 | { | |
169 | // TODO | |
170 | return wxBATTERY_UNKNOWN_STATE; | |
171 | } | |
172 | ||
173 | // ---------------------------------------------------------------------------- | |
174 | // misc | |
175 | // ---------------------------------------------------------------------------- | |
176 | ||
177 | // Get free memory in bytes, or -1 if cannot determine amount (e.g. on UNIX) | |
178 | wxMemorySize wxGetFreeMemory() | |
179 | { | |
180 | uint32_t freeTotal = 0; | |
181 | uint32_t freeHeap; | |
182 | uint32_t freeChunk; | |
183 | ||
184 | // executed twice: for the dynamic heap, and for the non-secure RAM storage heap | |
185 | for ( uint16_t i=0; i<MemNumRAMHeaps(); i++) | |
186 | { | |
187 | status_t err = MemHeapFreeBytes(i, &freeHeap, &freeChunk); | |
188 | if( err != errNone ) | |
189 | return -1; | |
190 | freeTotal+=freeHeap; | |
191 | } | |
192 | ||
193 | return (wxMemorySize)freeTotal; | |
194 | } | |
195 | ||
196 | unsigned long wxGetProcessId() | |
197 | { | |
198 | return 0; | |
199 | } | |
200 | ||
201 | // Emit a beeeeeep | |
202 | void wxBell() | |
203 | { | |
204 | SndPlaySystemSound(sndWarning); | |
205 | } | |
206 | ||
207 | bool wxIsPlatform64Bit() | |
208 | { | |
209 | return false; | |
210 | } | |
211 | ||
212 | wxString wxGetOsDescription() | |
213 | { | |
214 | wxString strOS = _T("PalmOS"); | |
215 | ||
216 | char *version = SysGetOSVersionString(); | |
217 | if(version) | |
218 | { | |
219 | wxString str = wxString::FromAscii(version); | |
220 | MemPtrFree(version); | |
221 | if(!str.empty()) | |
222 | { | |
223 | strOS << _(" ") << str; | |
224 | } | |
225 | } | |
226 | ||
227 | return strOS; | |
228 | } | |
229 | ||
230 | wxOperatingSystemId wxGetOsVersion(int *verMaj, int *verMin) | |
231 | { | |
232 | // TODO | |
233 | ||
234 | return wxOS_UNKNOWN; | |
235 | } | |
236 | ||
237 | // ---------------------------------------------------------------------------- | |
238 | // sleep functions | |
239 | // ---------------------------------------------------------------------------- | |
240 | ||
241 | void wxMilliSleep(unsigned long milliseconds) | |
242 | { | |
243 | } | |
244 | ||
245 | void wxMicroSleep(unsigned long microseconds) | |
246 | { | |
247 | } | |
248 | ||
249 | void wxSleep(int nSecs) | |
250 | { | |
251 | } | |
252 | ||
253 | // ---------------------------------------------------------------------------- | |
254 | // font encoding <-> Win32 codepage conversion functions | |
255 | // ---------------------------------------------------------------------------- | |
256 | ||
257 | extern WXDLLIMPEXP_BASE long wxEncodingToCharset(wxFontEncoding encoding) | |
258 | { | |
259 | return 0; | |
260 | } | |
261 | ||
262 | // we have 2 versions of wxCharsetToCodepage(): the old one which directly | |
263 | // looks up the vlaues in the registry and the new one which is more | |
264 | // politically correct and has more chances to work on other Windows versions | |
265 | // as well but the old version is still needed for !wxUSE_FONTMAP case | |
266 | #if wxUSE_FONTMAP | |
267 | ||
268 | #include "wx/fontmap.h" | |
269 | ||
270 | extern WXDLLIMPEXP_BASE long wxEncodingToCodepage(wxFontEncoding encoding) | |
271 | { | |
272 | return 0; | |
273 | } | |
274 | ||
275 | extern long wxCharsetToCodepage(const wxChar *name) | |
276 | { | |
277 | return 0; | |
278 | } | |
279 | ||
280 | #else // !wxUSE_FONTMAP | |
281 | ||
282 | // this should work if Internet Exploiter is installed | |
283 | extern long wxCharsetToCodepage(const wxChar *name) | |
284 | { | |
285 | return 0; | |
286 | } | |
287 | ||
288 | #endif // wxUSE_FONTMAP/!wxUSE_FONTMAP |