]> git.saurik.com Git - wxWidgets.git/blame - src/palmos/volume.cpp
Implement wxGetMouseState
[wxWidgets.git] / src / palmos / volume.cpp
CommitLineData
ffecfa5a
JS
1///////////////////////////////////////////////////////////////////////////////
2// Name: src/palmos/volume.cpp
3// Purpose: wxFSVolume - encapsulates system volume information
e2731512 4// Author: William Osborne - minimal working wxPalmOS port
ffecfa5a
JS
5// Modified by:
6// Created: 10/13/04
e2731512 7// RCS-ID: $Id$
ffecfa5a
JS
8// Copyright: (c) William Osborne
9// Licence: wxWindows licence
10///////////////////////////////////////////////////////////////////////////////
11
12// ============================================================================
13// declarations
14// ============================================================================
15
16// ----------------------------------------------------------------------------
17// headers
18// ----------------------------------------------------------------------------
19
ffecfa5a
JS
20#include "wx/wxprec.h"
21
22#ifdef __BORLANDC__
23 #pragma hdrstop
24#endif
25
26#if wxUSE_FSVOLUME
27
34deaa93
WS
28#include "wx/volume.h"
29
ffecfa5a
JS
30#ifndef WX_PRECOMP
31 #if wxUSE_GUI
32 #include "wx/icon.h"
33 #endif
34 #include "wx/intl.h"
aaa6d89a 35 #include "wx/arrstr.h"
ffecfa5a
JS
36#endif // WX_PRECOMP
37
34deaa93 38#include "wx/hashmap.h"
ffecfa5a 39
20bc5ad8
WS
40#include <VFSMgr.h>
41#include <PalmTypesCompatibility.h>
ffecfa5a
JS
42
43#if wxUSE_BASE
44
ffecfa5a
JS
45//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
46// Globals/Statics
47//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
48static long s_cancelSearch = FALSE;
49
50struct FileInfo
51{
52 FileInfo(unsigned flag=0, wxFSVolumeKind type=wxFS_VOL_OTHER) :
53 m_flags(flag), m_type(type) {}
54
55 FileInfo(const FileInfo& other) { *this = other; }
56 FileInfo& operator=(const FileInfo& other)
57 {
58 m_flags = other.m_flags;
59 m_type = other.m_type;
60 return *this;
61 }
62
63 unsigned m_flags;
64 wxFSVolumeKind m_type;
65};
12839f76 66
ffecfa5a 67WX_DECLARE_STRING_HASH_MAP(FileInfo, FileInfoMap);
12839f76 68
ffecfa5a
JS
69// Cygwin bug (?) destructor for global s_fileInfo is called twice...
70static FileInfoMap& GetFileInfoMap()
71{
72 static FileInfoMap s_fileInfo(25);
73
74 return s_fileInfo;
75}
76#define s_fileInfo (GetFileInfoMap())
77
78//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
79// Local helper functions.
80//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
81
82//=============================================================================
83// Function: GetBasicFlags
84// Purpose: Set basic flags, primarily wxFS_VOL_REMOTE and wxFS_VOL_REMOVABLE.
85// Notes: - Local and mapped drives are mounted by definition. We have no
86// way to determine mounted status of network drives, so assume that
87// all drives are mounted, and let the caller decide otherwise.
88// - Other flags are 'best guess' from type of drive. The system will
89// not report the file attributes with any degree of accuracy.
90//=============================================================================
91static unsigned GetBasicFlags(const wxChar* filename)
92{
93 unsigned flags = wxFS_VOL_MOUNTED;
94
95 return flags;
96} // GetBasicFlags
97
98//=============================================================================
99// Function: FilteredAdd
100// Purpose: Add a file to the list if it meets the filter requirement.
101// Notes: - See GetBasicFlags for remarks about the Mounted flag.
102//=============================================================================
e2731512 103static bool FilteredAdd(wxArrayString& list, const wxChar* filename,
ffecfa5a
JS
104 unsigned flagsSet, unsigned flagsUnset)
105{
106 return false;
107} // FilteredAdd
108
ffecfa5a
JS
109//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
110// wxFSVolume
111//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
112
113//=============================================================================
114// Function: GetVolumes
115// Purpose: Generate and return a list of all volumes (drives) available.
116// Notes:
117//=============================================================================
118wxArrayString wxFSVolumeBase::GetVolumes(int flagsSet, int flagsUnset)
119{
120 wxArrayString list;
121
12839f76
WS
122 UInt16 refNum;
123 UInt32 it = vfsIteratorStart;
124
125 while (it != vfsIteratorStop)
126 {
127 status_t err = VFSVolumeEnumerate(&refNum, &it);
128 if (err == errNone)
129 {
130 // manual: "Volume labels can be up to 255 characters long."
131 char label[256];
132 err = VFSVolumeGetLabel(refNum,label,256);
133 if (err == errNone)
134 {
135 list.Add(wxString::FromAscii(label));
136 }
137 }
138
139 if (err != errNone)
140 break;
e2731512 141 }
12839f76 142
ffecfa5a
JS
143 return list;
144} // GetVolumes
145
146//=============================================================================
147// Function: CancelSearch
148// Purpose: Instruct an active search to stop.
149// Notes: - This will only sensibly be called by a thread other than the one
150// performing the search. This is the only thread-safe function
151// provided by the class.
152//=============================================================================
153void wxFSVolumeBase::CancelSearch()
154{
155} // CancelSearch
156
157//=============================================================================
158// Function: constructor
159// Purpose: default constructor
160//=============================================================================
161wxFSVolumeBase::wxFSVolumeBase()
162{
163} // wxVolume
164
165//=============================================================================
166// Function: constructor
167// Purpose: constructor that calls Create
168//=============================================================================
169wxFSVolumeBase::wxFSVolumeBase(const wxString& name)
170{
171} // wxVolume
172
173//=============================================================================
174// Function: Create
175// Purpose: Finds, logs in, etc. to the request volume.
176//=============================================================================
177bool wxFSVolumeBase::Create(const wxString& name)
178{
179 return false;
180} // Create
181
182//=============================================================================
183// Function: IsOk
12839f76 184// Purpose: returns true if the volume is legal.
ffecfa5a
JS
185// Notes: For fixed disks, it must exist. For removable disks, it must also
186// be present. For Network Shares, it must also be logged in, etc.
187//=============================================================================
188bool wxFSVolumeBase::IsOk() const
189{
190 return false;
191} // IsOk
192
193//=============================================================================
194// Function: GetKind
195// Purpose: Return the type of the volume.
196//=============================================================================
197wxFSVolumeKind wxFSVolumeBase::GetKind() const
198{
199 return wxFS_VOL_OTHER;
200}
201
202//=============================================================================
203// Function: GetFlags
204// Purpose: Return the caches flags for this volume.
205// Notes: - Returns -1 if no flags were cached.
206//=============================================================================
207int wxFSVolumeBase::GetFlags() const
208{
209 return -1;
210} // GetFlags
211
212#endif // wxUSE_BASE
213
214// ============================================================================
215// wxFSVolume
216// ============================================================================
217
218#if wxUSE_GUI
219
220void wxFSVolume::InitIcons()
221{
222}
223
224//=============================================================================
225// Function: GetIcon
226// Purpose: return the requested icon.
227//=============================================================================
228
229wxIcon wxFSVolume::GetIcon(wxFSIconType type) const
230{
231 return m_icons[type];
232} // GetIcon
233
234#endif // wxUSE_GUI
235
236#endif // wxUSE_FSVOLUME