]>
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 wxString
wxGetOsDescription()
202 wxString strOS
= _T("PalmOS");
204 char *version
= SysGetOSVersionString();
207 wxString str
= wxString::FromAscii(version
);
211 strOS
<< _(" ") << str
;
218 wxOperatingSystemId
wxGetOsVersion(int *verMaj
, int *verMin
)
225 // ----------------------------------------------------------------------------
227 // ----------------------------------------------------------------------------
229 void wxMilliSleep(unsigned long milliseconds
)
233 void wxMicroSleep(unsigned long microseconds
)
237 void wxSleep(int nSecs
)
241 // ----------------------------------------------------------------------------
242 // font encoding <-> Win32 codepage conversion functions
243 // ----------------------------------------------------------------------------
245 extern WXDLLIMPEXP_BASE
long wxEncodingToCharset(wxFontEncoding encoding
)
250 // we have 2 versions of wxCharsetToCodepage(): the old one which directly
251 // looks up the vlaues in the registry and the new one which is more
252 // politically correct and has more chances to work on other Windows versions
253 // as well but the old version is still needed for !wxUSE_FONTMAP case
256 #include "wx/fontmap.h"
258 extern WXDLLIMPEXP_BASE
long wxEncodingToCodepage(wxFontEncoding encoding
)
263 extern long wxCharsetToCodepage(const wxChar
*name
)
268 #else // !wxUSE_FONTMAP
270 // this should work if Internet Exploiter is installed
271 extern long wxCharsetToCodepage(const wxChar
*name
)
276 #endif // wxUSE_FONTMAP/!wxUSE_FONTMAP