]>
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
, wxConvertMB2WX(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 // ----------------------------------------------------------------------------
131 // process management
132 // ----------------------------------------------------------------------------
134 int wxKill(long pid
, wxSignal sig
, wxKillError
*krc
, int flags
)
139 // Execute a program in an Interactive Shell
140 bool wxShell(const wxString
& command
)
145 // Shutdown or reboot the PC
146 bool wxShutdown(wxShutdownFlags wFlags
)
151 // ----------------------------------------------------------------------------
153 // ----------------------------------------------------------------------------
155 wxPowerType
wxGetPowerType()
157 return wxPOWER_BATTERY
;
160 wxBatteryState
wxGetBatteryState()
163 return wxBATTERY_UNKNOWN_STATE
;
166 // ----------------------------------------------------------------------------
168 // ----------------------------------------------------------------------------
170 // Get free memory in bytes, or -1 if cannot determine amount (e.g. on UNIX)
171 wxMemorySize
wxGetFreeMemory()
173 uint32_t freeTotal
= 0;
177 // executed twice: for the dynamic heap, and for the non-secure RAM storage heap
178 for ( uint16_t i
=0; i
<MemNumRAMHeaps(); i
++)
180 status_t err
= MemHeapFreeBytes(i
, &freeHeap
, &freeChunk
);
186 return (wxMemorySize
)freeTotal
;
189 unsigned long wxGetProcessId()
197 SndPlaySystemSound(sndWarning
);
200 bool wxIsPlatform64Bit()
205 wxString
wxGetOsDescription()
207 wxString strOS
= _T("PalmOS");
209 char *version
= SysGetOSVersionString();
212 wxString str
= wxString::FromAscii(version
);
216 strOS
<< _(" ") << str
;
223 wxOperatingSystemId
wxGetOsVersion(int *verMaj
, int *verMin
)
230 // ----------------------------------------------------------------------------
232 // ----------------------------------------------------------------------------
234 void wxMilliSleep(unsigned long milliseconds
)
238 void wxMicroSleep(unsigned long microseconds
)
242 void wxSleep(int nSecs
)
246 // ----------------------------------------------------------------------------
247 // font encoding <-> Win32 codepage conversion functions
248 // ----------------------------------------------------------------------------
250 extern WXDLLIMPEXP_BASE
long wxEncodingToCharset(wxFontEncoding encoding
)
255 // we have 2 versions of wxCharsetToCodepage(): the old one which directly
256 // looks up the vlaues in the registry and the new one which is more
257 // politically correct and has more chances to work on other Windows versions
258 // as well but the old version is still needed for !wxUSE_FONTMAP case
261 #include "wx/fontmap.h"
263 extern WXDLLIMPEXP_BASE
long wxEncodingToCodepage(wxFontEncoding encoding
)
268 extern long wxCharsetToCodepage(const wxChar
*name
)
273 #else // !wxUSE_FONTMAP
275 // this should work if Internet Exploiter is installed
276 extern long wxCharsetToCodepage(const wxChar
*name
)
281 #endif // wxUSE_FONTMAP/!wxUSE_FONTMAP