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