]> git.saurik.com Git - wxWidgets.git/blame - src/palmos/utils.cpp
Fixes/makefiles for building data view control on Windows
[wxWidgets.git] / src / palmos / utils.cpp
CommitLineData
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"
32#endif //WX_PRECOMP
33
34#include "wx/apptrait.h"
35#include "wx/dynload.h"
d1df2399 36#include "wx/confbase.h"
ffecfa5a
JS
37#include "wx/timer.h"
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)
53bool wxGetHostName(wxChar *buf, int maxSize)
54{
55 return false;
56}
57
58// get full hostname (with domain name if possible)
59bool wxGetFullHostName(wxChar *buf, int maxSize)
60{
61 return false;
62}
63
64// Get user ID e.g. jacs
65bool wxGetUserId(wxChar *buf, int maxSize)
66{
d1df2399 67 return wxGetUserName(buf, maxSize);
ffecfa5a
JS
68}
69
70// Get user name e.g. Julian Smart
71bool 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
100const wxChar* wxGetHomeDir(wxString *pstr)
101{
102 return NULL;
103}
104
105wxChar *wxGetUserHome(const wxString& WXUNUSED(user))
106{
107 return NULL;
108}
109
7ba7c4e6 110bool wxGetDiskSpace(const wxString& path, wxDiskspaceSize_t *pTotal, wxDiskspaceSize_t *pFree)
ffecfa5a
JS
111{
112 return false;
113}
114
115// ----------------------------------------------------------------------------
116// env vars
117// ----------------------------------------------------------------------------
118
119bool wxGetEnv(const wxString& var, wxString *value)
120{
121 return false;
122}
123
124bool wxSetEnv(const wxString& var, const wxChar *value)
125{
126 return false;
127}
128
129// ----------------------------------------------------------------------------
130// process management
131// ----------------------------------------------------------------------------
132
e0f6b731 133int 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
139bool wxShell(const wxString& command)
140{
141 return false;
142}
143
144// Shutdown or reboot the PC
145bool wxShutdown(wxShutdownFlags wFlags)
146{
147 return false;
148}
149
8ea92b4d
WS
150wxPowerType wxGetPowerType()
151{
152 return wxPOWER_BATTERY;
153}
154
155wxBatteryState 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 166wxMemorySize 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
184unsigned long wxGetProcessId()
185{
186 return 0;
187}
188
189// Emit a beeeeeep
190void wxBell()
191{
d1df2399 192 SndPlaySystemSound(sndWarning);
ffecfa5a
JS
193}
194
195wxString 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
213wxToolkitInfo& 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
225void wxMilliSleep(unsigned long milliseconds)
226{
227}
228
229void wxMicroSleep(unsigned long microseconds)
230{
231}
232
233void wxSleep(int nSecs)
234{
235}
236
237// ----------------------------------------------------------------------------
238// font encoding <-> Win32 codepage conversion functions
239// ----------------------------------------------------------------------------
240
241extern 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
254extern WXDLLIMPEXP_BASE long wxEncodingToCodepage(wxFontEncoding encoding)
255{
256 return 0;
257}
258
259extern 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
267extern long wxCharsetToCodepage(const wxChar *name)
268{
269 return 0;
270}
271
272#endif // wxUSE_FONTMAP/!wxUSE_FONTMAP
273