]>
git.saurik.com Git - wxWidgets.git/blob - src/palmos/utils.cpp
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
8 // Copyright: (c) William Osborne, Wlodzimierz Skiba
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
12 // ============================================================================
14 // ============================================================================
16 // ----------------------------------------------------------------------------
18 // ----------------------------------------------------------------------------
20 // For compilers that support precompilation, includes "wx.h".
21 #include "wx/wxprec.h"
35 #include "wx/apptrait.h"
36 #include "wx/dynload.h"
37 #include "wx/confbase.h"
40 #include <MemoryMgr.h>
45 // ============================================================================
47 // ============================================================================
49 // ----------------------------------------------------------------------------
50 // get host name and related
51 // ----------------------------------------------------------------------------
53 // Get hostname only (without domain name)
54 bool wxGetHostName(wxChar
*buf
, int maxSize
)
59 // get full hostname (with domain name if possible)
60 bool wxGetFullHostName(wxChar
*buf
, int maxSize
)
65 // Get user ID e.g. jacs
66 bool wxGetUserId(wxChar
*buf
, int maxSize
)
68 return wxGetUserName(buf
, maxSize
);
71 // Get user name e.g. Julian Smart
72 bool wxGetUserName(wxChar
*buf
, int maxSize
)
77 MemHandle handle
= MemHandleNew(maxSize
-1);
82 char *id
= (char *)MemHandleLock(handle
);
87 if( DlkGetSyncInfo(NULL
, NULL
, NULL
, id
, NULL
, NULL
) != errNone
)
93 wxStrncpy (buf
, wxSafeConvertMB2WX(id
), maxSize
- 1);
101 const wxChar
* wxGetHomeDir(wxString
*pstr
)
106 wxChar
*wxGetUserHome(const wxString
& WXUNUSED(user
))
111 bool wxGetDiskSpace(const wxString
& path
, wxDiskspaceSize_t
*pTotal
, wxDiskspaceSize_t
*pFree
)
116 // ----------------------------------------------------------------------------
118 // ----------------------------------------------------------------------------
120 bool wxGetEnv(const wxString
& var
, wxString
*value
)
125 bool wxSetEnv(const wxString
& var
, const wxChar
*value
)
130 bool wxUnsetEnv(const wxString
& var
)
135 // ----------------------------------------------------------------------------
136 // process management
137 // ----------------------------------------------------------------------------
139 int wxKill(long pid
, wxSignal sig
, wxKillError
*krc
, int flags
)
144 // Execute a program in an Interactive Shell
145 bool wxShell(const wxString
& command
)
150 // Shutdown or reboot the PC
151 bool wxShutdown(wxShutdownFlags wFlags
)
156 // ----------------------------------------------------------------------------
158 // ----------------------------------------------------------------------------
160 wxPowerType
wxGetPowerType()
162 return wxPOWER_BATTERY
;
165 wxBatteryState
wxGetBatteryState()
168 return wxBATTERY_UNKNOWN_STATE
;
171 // ----------------------------------------------------------------------------
173 // ----------------------------------------------------------------------------
175 // Get free memory in bytes, or -1 if cannot determine amount (e.g. on UNIX)
176 wxMemorySize
wxGetFreeMemory()
178 uint32_t freeTotal
= 0;
182 // executed twice: for the dynamic heap, and for the non-secure RAM storage heap
183 for ( uint16_t i
=0; i
<MemNumRAMHeaps(); i
++)
185 status_t err
= MemHeapFreeBytes(i
, &freeHeap
, &freeChunk
);
191 return (wxMemorySize
)freeTotal
;
194 unsigned long wxGetProcessId()
202 SndPlaySystemSound(sndWarning
);
205 bool wxIsPlatform64Bit()
210 wxString
wxGetOsDescription()
212 wxString strOS
= _T("PalmOS");
214 char *version
= SysGetOSVersionString();
217 wxString str
= wxString::FromAscii(version
);
221 strOS
<< _(" ") << str
;
228 wxOperatingSystemId
wxGetOsVersion(int *verMaj
, int *verMin
)
235 // ----------------------------------------------------------------------------
237 // ----------------------------------------------------------------------------
239 void wxMilliSleep(unsigned long milliseconds
)
243 void wxMicroSleep(unsigned long microseconds
)
247 void wxSleep(int nSecs
)
251 // ----------------------------------------------------------------------------
252 // font encoding <-> Win32 codepage conversion functions
253 // ----------------------------------------------------------------------------
255 extern WXDLLIMPEXP_BASE
long wxEncodingToCharset(wxFontEncoding encoding
)
260 // we have 2 versions of wxCharsetToCodepage(): the old one which directly
261 // looks up the vlaues in the registry and the new one which is more
262 // politically correct and has more chances to work on other Windows versions
263 // as well but the old version is still needed for !wxUSE_FONTMAP case
266 #include "wx/fontmap.h"
268 extern WXDLLIMPEXP_BASE
long wxEncodingToCodepage(wxFontEncoding encoding
)
273 extern long wxCharsetToCodepage(const wxChar
*name
)
278 #else // !wxUSE_FONTMAP
280 // this should work if Internet Exploiter is installed
281 extern long wxCharsetToCodepage(const wxChar
*name
)
286 #endif // wxUSE_FONTMAP/!wxUSE_FONTMAP