]> git.saurik.com Git - wxWidgets.git/blob - src/palmos/utils.cpp
Implemented user dashes for gnome print.
[wxWidgets.git] / 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
6 // Created: 10/13/04
7 // RCS-ID: $Id$
8 // Copyright: (c) William Osborne, Wlodzimierz Skiba
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
11
12 // ============================================================================
13 // declarations
14 // ============================================================================
15
16 // ----------------------------------------------------------------------------
17 // headers
18 // ----------------------------------------------------------------------------
19
20 // For compilers that support precompilation, includes "wx.h".
21 #include "wx/wxprec.h"
22
23 #ifdef __BORLANDC__
24 #pragma hdrstop
25 #endif
26
27 #ifndef WX_PRECOMP
28 #include "wx/utils.h"
29 #include "wx/app.h"
30 #include "wx/intl.h"
31 #include "wx/log.h"
32 #endif //WX_PRECOMP
33
34 #include "wx/apptrait.h"
35 #include "wx/dynload.h"
36 #include "wx/confbase.h"
37 #include "wx/timer.h"
38
39 #include <MemoryMgr.h>
40 #include <DLServer.h>
41 #include <SoundMgr.h>
42 #include <SysUtils.h>
43
44 // ============================================================================
45 // implementation
46 // ============================================================================
47
48 // ----------------------------------------------------------------------------
49 // get host name and related
50 // ----------------------------------------------------------------------------
51
52 // Get hostname only (without domain name)
53 bool wxGetHostName(wxChar *buf, int maxSize)
54 {
55 return false;
56 }
57
58 // get full hostname (with domain name if possible)
59 bool wxGetFullHostName(wxChar *buf, int maxSize)
60 {
61 return false;
62 }
63
64 // Get user ID e.g. jacs
65 bool wxGetUserId(wxChar *buf, int maxSize)
66 {
67 return wxGetUserName(buf, maxSize);
68 }
69
70 // Get user name e.g. Julian Smart
71 bool wxGetUserName(wxChar *buf, int maxSize)
72 {
73 *buf = wxT('\0');
74
75 // buffer allocation
76 MemHandle handle = MemHandleNew(maxSize-1);
77 if( handle == NULL )
78 return false;
79
80 // lock the buffer
81 char *id = (char *)MemHandleLock(handle);
82 if( id == NULL )
83 return false;
84
85 // get user's name
86 if( DlkGetSyncInfo(NULL, NULL, NULL, id, NULL, NULL) != errNone )
87 {
88 MemPtrUnlock(id);
89 return false;
90 }
91
92 wxStrncpy (buf, wxConvertMB2WX(id), maxSize - 1);
93
94 // free the buffer
95 MemPtrUnlock(id);
96
97 return true;
98 }
99
100 const wxChar* wxGetHomeDir(wxString *pstr)
101 {
102 return NULL;
103 }
104
105 wxChar *wxGetUserHome(const wxString& WXUNUSED(user))
106 {
107 return NULL;
108 }
109
110 bool wxGetDiskSpace(const wxString& path, wxDiskspaceSize_t *pTotal, wxDiskspaceSize_t *pFree)
111 {
112 return false;
113 }
114
115 // ----------------------------------------------------------------------------
116 // env vars
117 // ----------------------------------------------------------------------------
118
119 bool wxGetEnv(const wxString& var, wxString *value)
120 {
121 return false;
122 }
123
124 bool wxSetEnv(const wxString& var, const wxChar *value)
125 {
126 return false;
127 }
128
129 // ----------------------------------------------------------------------------
130 // process management
131 // ----------------------------------------------------------------------------
132
133 int wxKill(long pid, wxSignal sig, wxKillError *krc, int flags)
134 {
135 return 0;
136 }
137
138 // Execute a program in an Interactive Shell
139 bool wxShell(const wxString& command)
140 {
141 return false;
142 }
143
144 // Shutdown or reboot the PC
145 bool wxShutdown(wxShutdownFlags wFlags)
146 {
147 return false;
148 }
149
150 wxPowerType wxGetPowerType()
151 {
152 return wxPOWER_BATTERY;
153 }
154
155 wxBatteryState wxGetBatteryState()
156 {
157 // TODO
158 return wxBATTERY_UNKNOWN_STATE;
159 }
160
161 // ----------------------------------------------------------------------------
162 // misc
163 // ----------------------------------------------------------------------------
164
165 // Get free memory in bytes, or -1 if cannot determine amount (e.g. on UNIX)
166 wxMemorySize wxGetFreeMemory()
167 {
168 uint32_t freeTotal = 0;
169 uint32_t freeHeap;
170 uint32_t freeChunk;
171
172 // executed twice: for the dynamic heap, and for the non-secure RAM storage heap
173 for ( uint16_t i=0; i<MemNumRAMHeaps(); i++)
174 {
175 status_t err = MemHeapFreeBytes(i, &freeHeap, &freeChunk);
176 if( err != errNone )
177 return -1;
178 freeTotal+=freeHeap;
179 }
180
181 return (wxMemorySize)freeTotal;
182 }
183
184 unsigned long wxGetProcessId()
185 {
186 return 0;
187 }
188
189 // Emit a beeeeeep
190 void wxBell()
191 {
192 SndPlaySystemSound(sndWarning);
193 }
194
195 wxString wxGetOsDescription()
196 {
197 wxString strOS = _T("PalmOS");
198
199 char *version = SysGetOSVersionString();
200 if(version)
201 {
202 wxString str = wxString::FromAscii(version);
203 MemPtrFree(version);
204 if(!str.empty())
205 {
206 strOS << _(" ") << str;
207 }
208 }
209
210 return strOS;
211 }
212
213 wxToolkitInfo& wxAppTraits::GetToolkitInfo()
214 {
215 static wxToolkitInfo info;
216 info.os = wxPALMOS;
217 info.name = _T("wxBase");
218 return info;
219 }
220
221 // ----------------------------------------------------------------------------
222 // sleep functions
223 // ----------------------------------------------------------------------------
224
225 void wxMilliSleep(unsigned long milliseconds)
226 {
227 }
228
229 void wxMicroSleep(unsigned long microseconds)
230 {
231 }
232
233 void wxSleep(int nSecs)
234 {
235 }
236
237 // ----------------------------------------------------------------------------
238 // font encoding <-> Win32 codepage conversion functions
239 // ----------------------------------------------------------------------------
240
241 extern WXDLLIMPEXP_BASE long wxEncodingToCharset(wxFontEncoding encoding)
242 {
243 return 0;
244 }
245
246 // we have 2 versions of wxCharsetToCodepage(): the old one which directly
247 // looks up the vlaues in the registry and the new one which is more
248 // politically correct and has more chances to work on other Windows versions
249 // as well but the old version is still needed for !wxUSE_FONTMAP case
250 #if wxUSE_FONTMAP
251
252 #include "wx/fontmap.h"
253
254 extern WXDLLIMPEXP_BASE long wxEncodingToCodepage(wxFontEncoding encoding)
255 {
256 return 0;
257 }
258
259 extern long wxCharsetToCodepage(const wxChar *name)
260 {
261 return 0;
262 }
263
264 #else // !wxUSE_FONTMAP
265
266 // this should work if Internet Exploiter is installed
267 extern long wxCharsetToCodepage(const wxChar *name)
268 {
269 return 0;
270 }
271
272 #endif // wxUSE_FONTMAP/!wxUSE_FONTMAP
273