X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/27b2dd53f629a78266c51d1b0b5db918401dcd4f..f81bd28859d95c2a8f8b6ec71885f8770b5e5e1a:/src/palmos/utils.cpp diff --git a/src/palmos/utils.cpp b/src/palmos/utils.cpp index 81988757ca..a03694b0dc 100644 --- a/src/palmos/utils.cpp +++ b/src/palmos/utils.cpp @@ -29,16 +29,25 @@ #include "wx/app.h" #include "wx/intl.h" #include "wx/log.h" + #include "wx/timer.h" #endif //WX_PRECOMP #include "wx/apptrait.h" #include "wx/dynload.h" #include "wx/confbase.h" -#include "wx/timer.h" +#include "wx/power.h" +#include #include #include #include +#include // SysDoze()... +#include + +#ifdef __WXPALMOS6__ +extern void SysReset (void); +extern UInt32 SysTaskID (void); +#endif // ============================================================================ // implementation @@ -88,7 +97,7 @@ bool wxGetUserName(wxChar *buf, int maxSize) return false; } - wxStrncpy (buf, wxConvertMB2WX(id), maxSize - 1); + wxStrlcpy(buf, wxSafeConvertMB2WX(id), maxSize); // free the buffer MemPtrUnlock(id); @@ -98,15 +107,18 @@ bool wxGetUserName(wxChar *buf, int maxSize) const wxChar* wxGetHomeDir(wxString *pstr) { - return NULL; + if (NULL != pstr) { + *pstr = "/palmos"; + } + return wxT("/palmos"); } -wxChar *wxGetUserHome(const wxString& WXUNUSED(user)) +wxString wxGetUserHome(const wxString& WXUNUSED(user)) { - return NULL; + return wxString("/palmos"); } -bool wxGetDiskSpace(const wxString& path, wxLongLong *pTotal, wxLongLong *pFree) +bool wxGetDiskSpace(const wxString& path, wxDiskspaceSize_t *pTotal, wxDiskspaceSize_t *pFree) { return false; } @@ -120,10 +132,17 @@ bool wxGetEnv(const wxString& var, wxString *value) return false; } +#if ! WXWIN_COMPATIBILITY_2_8 bool wxSetEnv(const wxString& var, const wxChar *value) { return false; } +#endif // ! WXWIN_COMPATIBILITY_2_8 + +bool wxUnsetEnv(const wxString& var) +{ + return false; +} // ---------------------------------------------------------------------------- // process management @@ -143,18 +162,52 @@ bool wxShell(const wxString& command) // Shutdown or reboot the PC bool wxShutdown(wxShutdownFlags wFlags) { + switch (wFlags) { + case wxSHUTDOWN_POWEROFF: + // TODO: turn off lamps +#ifdef __WXPALMOS6__ + //extern void SysReset (void); + //extern UInt32 SysTaskID (void); + #define SysReset() + #define SysTaskID() (0) + SysSleep (); +#else + //SysSleep (false, false);// undocument API + SysDoze (true); +#endif + break; + case wxSHUTDOWN_REBOOT: + SysReset (); + break; + } return false; } +// ---------------------------------------------------------------------------- +// power management +// ---------------------------------------------------------------------------- + wxPowerType wxGetPowerType() { + //SysBatteryKind kind; + //POS_SysBatteryInfo (false, NULL, NULL, NULL, NULL, NULL, &kind, NULL); + //return wxPOWER_SOCKET; return wxPOWER_BATTERY; } wxBatteryState wxGetBatteryState() { - // TODO - return wxBATTERY_UNKNOWN_STATE; + //#include "SystemMgr.h" + UInt8 percent; + POS_SysBatteryInfo (false, NULL, NULL, NULL, NULL, NULL, NULL, &percent); + if (percent < 3) + return wxBATTERY_SHUTDOWN_STATE; + else if (percent < 5) + return wxBATTERY_CRITICAL_STATE; + else if (percent < 15) + return wxBATTERY_LOW_STATE; + //return wxBATTERY_UNKNOWN_STATE; + return wxBATTERY_NORMAL_STATE; } // ---------------------------------------------------------------------------- @@ -169,7 +222,7 @@ wxMemorySize wxGetFreeMemory() uint32_t freeChunk; // executed twice: for the dynamic heap, and for the non-secure RAM storage heap - for ( uint16_t i=0; i= 0x02000000) v20 = true; char *version = SysGetOSVersionString(); if(version) { @@ -209,11 +269,10 @@ wxString wxGetOsDescription() return strOS; } -wxToolkitInfo& wxAppTraits::GetToolkitInfo() +wxOperatingSystemId wxGetOsVersion(int *verMaj, int *verMin) { - static wxToolkitInfo info; - info.name = _T("wxBase"); - return info; + // TODO + return wxOS_PALM_OS; } // ---------------------------------------------------------------------------- @@ -222,14 +281,35 @@ wxToolkitInfo& wxAppTraits::GetToolkitInfo() void wxMilliSleep(unsigned long milliseconds) { + UInt16 ticks_sec; + Int32 delay; + ticks_sec = SysTicksPerSecond (); + delay = milliseconds * ticks_sec / 1000; + if (delay > 0) { + SysTaskDelay (delay); + } } void wxMicroSleep(unsigned long microseconds) { + UInt16 ticks_sec; + Int32 delay; + ticks_sec = SysTicksPerSecond (); + delay = microseconds * ticks_sec / 1000000; + if (delay > 0) { + SysTaskDelay (delay); + } } void wxSleep(int nSecs) { + UInt16 ticks_sec; + Int32 delay; + ticks_sec = SysTicksPerSecond (); + delay = nSecs * ticks_sec; + if (delay > 0) { + SysTaskDelay (delay); + } } // ---------------------------------------------------------------------------- @@ -268,4 +348,3 @@ extern long wxCharsetToCodepage(const wxChar *name) } #endif // wxUSE_FONTMAP/!wxUSE_FONTMAP -