X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/ffecfa5aeb540b54914739dbb8603edbbd4c00a0..4913272f9cdead94a6d1470e51d6fb14946b50e0:/src/palmos/utils.cpp diff --git a/src/palmos/utils.cpp b/src/palmos/utils.cpp index 67fb7c304b..81db337f9b 100644 --- a/src/palmos/utils.cpp +++ b/src/palmos/utils.cpp @@ -1,11 +1,11 @@ ///////////////////////////////////////////////////////////////////////////// -// Name: palmos/utils.cpp +// Name: src/palmos/utils.cpp // Purpose: Various utilities -// Author: William Osborne -// Modified by: +// Author: William Osborne - minimal working wxPalmOS port +// Modified by: Wlodzimierz ABX Skiba - real functionality // Created: 10/13/04 -// RCS-ID: $Id: -// Copyright: (c) William Osborne +// RCS-ID: $Id$ +// Copyright: (c) William Osborne, Wlodzimierz Skiba // Licence: wxWindows licence ///////////////////////////////////////////////////////////////////////////// @@ -29,32 +29,18 @@ #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/power.h" -#include "wx/confbase.h" // for wxExpandEnvVars() - -#include "wx/timer.h" - -// VZ: there is some code using NetXXX() functions to get the full user name: -// I don't think it's a good idea because they don't work under Win95 and -// seem to return the same as wxGetUserId() under NT. If you really want -// to use them, just #define USE_NET_API -#undef USE_NET_API - -#ifdef USE_NET_API - #include -#endif // USE_NET_API - -// ---------------------------------------------------------------------------- -// constants -// ---------------------------------------------------------------------------- - -// In the WIN.INI file -static const wxChar WX_SECTION[] = wxT("wxWindows"); -static const wxChar eUSERNAME[] = wxT("UserName"); +#include +#include +#include +#include // ============================================================================ // implementation @@ -79,13 +65,37 @@ bool wxGetFullHostName(wxChar *buf, int maxSize) // Get user ID e.g. jacs bool wxGetUserId(wxChar *buf, int maxSize) { - return false; + return wxGetUserName(buf, maxSize); } // Get user name e.g. Julian Smart bool wxGetUserName(wxChar *buf, int maxSize) { - return false; + *buf = wxT('\0'); + + // buffer allocation + MemHandle handle = MemHandleNew(maxSize-1); + if( handle == NULL ) + return false; + + // lock the buffer + char *id = (char *)MemHandleLock(handle); + if( id == NULL ) + return false; + + // get user's name + if( DlkGetSyncInfo(NULL, NULL, NULL, id, NULL, NULL) != errNone ) + { + MemPtrUnlock(id); + return false; + } + + wxStrncpy (buf, wxConvertMB2WX(id), maxSize - 1); + + // free the buffer + MemPtrUnlock(id); + + return true; } const wxChar* wxGetHomeDir(wxString *pstr) @@ -98,12 +108,7 @@ wxChar *wxGetUserHome(const wxString& WXUNUSED(user)) return NULL; } -bool wxDirExists(const wxString& dir) -{ - return false; -} - -bool wxGetDiskSpace(const wxString& path, wxLongLong *pTotal, wxLongLong *pFree) +bool wxGetDiskSpace(const wxString& path, wxDiskspaceSize_t *pTotal, wxDiskspaceSize_t *pFree) { return false; } @@ -126,8 +131,7 @@ bool wxSetEnv(const wxString& var, const wxChar *value) // process management // ---------------------------------------------------------------------------- -// structure used to pass parameters from wxKill() to wxEnumFindByPidProc() -int wxKill(long pid, wxSignal sig, wxKillError *krc) +int wxKill(long pid, wxSignal sig, wxKillError *krc, int flags) { return 0; } @@ -144,14 +148,42 @@ bool wxShutdown(wxShutdownFlags wFlags) return false; } +// ---------------------------------------------------------------------------- +// power management +// ---------------------------------------------------------------------------- + +wxPowerType wxGetPowerType() +{ + return wxPOWER_BATTERY; +} + +wxBatteryState wxGetBatteryState() +{ + // TODO + return wxBATTERY_UNKNOWN_STATE; +} + // ---------------------------------------------------------------------------- // misc // ---------------------------------------------------------------------------- // Get free memory in bytes, or -1 if cannot determine amount (e.g. on UNIX) -long wxGetFreeMemory() +wxMemorySize wxGetFreeMemory() { - return 0; + uint32_t freeTotal = 0; + uint32_t freeHeap; + uint32_t freeChunk; + + // executed twice: for the dynamic heap, and for the non-secure RAM storage heap + for ( uint16_t i=0; i