]>
git.saurik.com Git - wxWidgets.git/blob - src/palmos/utils.cpp
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: palmos/utils.cpp
3 // Purpose: Various utilities
4 // Author: William Osborne
8 // Copyright: (c) William Osborne
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
12 // ============================================================================
14 // ============================================================================
16 // ----------------------------------------------------------------------------
18 // ----------------------------------------------------------------------------
20 // For compilers that support precompilation, includes "wx.h".
21 #include "wx/wxprec.h"
34 #include "wx/apptrait.h"
35 #include "wx/dynload.h"
36 #include "wx/confbase.h"
39 #include <MemoryMgr.h>
43 // ============================================================================
45 // ============================================================================
47 // ----------------------------------------------------------------------------
48 // get host name and related
49 // ----------------------------------------------------------------------------
51 // Get hostname only (without domain name)
52 bool wxGetHostName(wxChar
*buf
, int maxSize
)
57 // get full hostname (with domain name if possible)
58 bool wxGetFullHostName(wxChar
*buf
, int maxSize
)
63 // Get user ID e.g. jacs
64 bool wxGetUserId(wxChar
*buf
, int maxSize
)
66 return wxGetUserName(buf
, maxSize
);
69 // Get user name e.g. Julian Smart
70 bool wxGetUserName(wxChar
*buf
, int maxSize
)
75 MemHandle handle
= MemHandleNew(maxSize
-1);
80 char *id
= (char *)MemHandleLock(handle
);
85 if( DlkGetSyncInfo(NULL
, NULL
, NULL
, id
, NULL
, NULL
) != errNone
)
91 wxStrncpy (buf
, wxConvertMB2WX(id
), maxSize
- 1);
99 const wxChar
* wxGetHomeDir(wxString
*pstr
)
104 wxChar
*wxGetUserHome(const wxString
& WXUNUSED(user
))
109 bool wxDirExists(const wxString
& dir
)
114 bool wxGetDiskSpace(const wxString
& path
, wxLongLong
*pTotal
, wxLongLong
*pFree
)
119 // ----------------------------------------------------------------------------
121 // ----------------------------------------------------------------------------
123 bool wxGetEnv(const wxString
& var
, wxString
*value
)
128 bool wxSetEnv(const wxString
& var
, const wxChar
*value
)
133 // ----------------------------------------------------------------------------
134 // process management
135 // ----------------------------------------------------------------------------
137 int wxKill(long pid
, wxSignal sig
, wxKillError
*krc
, int flags
)
142 // Execute a program in an Interactive Shell
143 bool wxShell(const wxString
& command
)
148 // Shutdown or reboot the PC
149 bool wxShutdown(wxShutdownFlags wFlags
)
154 wxPowerType
wxGetPowerType()
156 return wxPOWER_BATTERY
;
159 wxBatteryState
wxGetBatteryState()
162 return wxBATTERY_UNKNOWN_STATE
;
165 // ----------------------------------------------------------------------------
167 // ----------------------------------------------------------------------------
169 // Get free memory in bytes, or -1 if cannot determine amount (e.g. on UNIX)
170 wxMemorySize
wxGetFreeMemory()
172 uint32_t freeTotal
= 0;
176 // executed twice: for the dynamic heap, and for the non-secure RAM storage heap
177 for ( uint16_t i
=0; i
<MemNumRAMHeaps(); i
++)
179 status_t err
= MemHeapFreeBytes(i
, &freeHeap
, &freeChunk
);
185 return (wxMemorySize
)freeTotal
;
188 unsigned long wxGetProcessId()
196 SndPlaySystemSound(sndWarning
);
199 wxString
wxGetOsDescription()
201 wxString strOS
= _T("PalmOS");
203 char *version
= SysGetOSVersionString();
206 wxString str
= wxString::FromAscii(version
);
209 strOS
<< _(" ") << str
;
216 wxToolkitInfo
& wxAppTraits::GetToolkitInfo()
218 static wxToolkitInfo info
;
219 info
.name
= _T("wxBase");
223 // ----------------------------------------------------------------------------
225 // ----------------------------------------------------------------------------
227 void wxMilliSleep(unsigned long milliseconds
)
231 void wxMicroSleep(unsigned long microseconds
)
235 void wxSleep(int nSecs
)
239 // ----------------------------------------------------------------------------
240 // font encoding <-> Win32 codepage conversion functions
241 // ----------------------------------------------------------------------------
243 extern WXDLLIMPEXP_BASE
long wxEncodingToCharset(wxFontEncoding encoding
)
248 // we have 2 versions of wxCharsetToCodepage(): the old one which directly
249 // looks up the vlaues in the registry and the new one which is more
250 // politically correct and has more chances to work on other Windows versions
251 // as well but the old version is still needed for !wxUSE_FONTMAP case
254 #include "wx/fontmap.h"
256 extern WXDLLIMPEXP_BASE
long wxEncodingToCodepage(wxFontEncoding encoding
)
261 extern long wxCharsetToCodepage(const wxChar
*name
)
266 #else // !wxUSE_FONTMAP
268 // this should work if Internet Exploiter is installed
269 extern long wxCharsetToCodepage(const wxChar
*name
)
274 #endif // wxUSE_FONTMAP/!wxUSE_FONTMAP