]>
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 wxString
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 #if ! WXWIN_COMPATIBILITY_2_8
126 bool wxSetEnv(const wxString
& var
, const wxChar
*value
)
130 #endif // ! WXWIN_COMPATIBILITY_2_8
132 bool wxUnsetEnv(const wxString
& var
)
137 // ----------------------------------------------------------------------------
138 // process management
139 // ----------------------------------------------------------------------------
141 int wxKill(long pid
, wxSignal sig
, wxKillError
*krc
, int flags
)
146 // Execute a program in an Interactive Shell
147 bool wxShell(const wxString
& command
)
152 // Shutdown or reboot the PC
153 bool wxShutdown(wxShutdownFlags wFlags
)
158 // ----------------------------------------------------------------------------
160 // ----------------------------------------------------------------------------
162 wxPowerType
wxGetPowerType()
164 return wxPOWER_BATTERY
;
167 wxBatteryState
wxGetBatteryState()
170 return wxBATTERY_UNKNOWN_STATE
;
173 // ----------------------------------------------------------------------------
175 // ----------------------------------------------------------------------------
177 // Get free memory in bytes, or -1 if cannot determine amount (e.g. on UNIX)
178 wxMemorySize
wxGetFreeMemory()
180 uint32_t freeTotal
= 0;
184 // executed twice: for the dynamic heap, and for the non-secure RAM storage heap
185 for ( uint16_t i
=0; i
<MemNumRAMHeaps(); i
++)
187 status_t err
= MemHeapFreeBytes(i
, &freeHeap
, &freeChunk
);
193 return (wxMemorySize
)freeTotal
;
196 unsigned long wxGetProcessId()
204 SndPlaySystemSound(sndWarning
);
207 bool wxIsPlatform64Bit()
212 wxString
wxGetOsDescription()
214 wxString strOS
= _T("PalmOS");
216 char *version
= SysGetOSVersionString();
219 wxString str
= wxString::FromAscii(version
);
223 strOS
<< _(" ") << str
;
230 wxOperatingSystemId
wxGetOsVersion(int *verMaj
, int *verMin
)
237 // ----------------------------------------------------------------------------
239 // ----------------------------------------------------------------------------
241 void wxMilliSleep(unsigned long milliseconds
)
245 void wxMicroSleep(unsigned long microseconds
)
249 void wxSleep(int nSecs
)
253 // ----------------------------------------------------------------------------
254 // font encoding <-> Win32 codepage conversion functions
255 // ----------------------------------------------------------------------------
257 extern WXDLLIMPEXP_BASE
long wxEncodingToCharset(wxFontEncoding encoding
)
262 // we have 2 versions of wxCharsetToCodepage(): the old one which directly
263 // looks up the vlaues in the registry and the new one which is more
264 // politically correct and has more chances to work on other Windows versions
265 // as well but the old version is still needed for !wxUSE_FONTMAP case
268 #include "wx/fontmap.h"
270 extern WXDLLIMPEXP_BASE
long wxEncodingToCodepage(wxFontEncoding encoding
)
275 extern long wxCharsetToCodepage(const wxChar
*name
)
280 #else // !wxUSE_FONTMAP
282 // this should work if Internet Exploiter is installed
283 extern long wxCharsetToCodepage(const wxChar
*name
)
288 #endif // wxUSE_FONTMAP/!wxUSE_FONTMAP