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