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