]> git.saurik.com Git - wxWidgets.git/blob - src/palmos/volume.cpp
File/dir dialog styles and other changes (patch 1488371):
[wxWidgets.git] / src / palmos / volume.cpp
1 ///////////////////////////////////////////////////////////////////////////////
2 // Name: src/palmos/volume.cpp
3 // Purpose: wxFSVolume - encapsulates system volume information
4 // Author: William Osborne - minimal working wxPalmOS port
5 // Modified by:
6 // Created: 10/13/04
7 // RCS-ID: $Id$
8 // Copyright: (c) William Osborne
9 // Licence: wxWindows licence
10 ///////////////////////////////////////////////////////////////////////////////
11
12 // ============================================================================
13 // declarations
14 // ============================================================================
15
16 // ----------------------------------------------------------------------------
17 // headers
18 // ----------------------------------------------------------------------------
19
20 #include "wx/wxprec.h"
21
22 #ifdef __BORLANDC__
23 #pragma hdrstop
24 #endif
25
26 #if wxUSE_FSVOLUME
27
28 #include "wx/volume.h"
29
30 #ifndef WX_PRECOMP
31 #if wxUSE_GUI
32 #include "wx/icon.h"
33 #endif
34 #include "wx/intl.h"
35 #endif // WX_PRECOMP
36
37 #include "wx/arrstr.h"
38 #include "wx/hashmap.h"
39
40 #include <VFSMgr.h>
41 #include <PalmTypesCompatibility.h>
42
43 #if wxUSE_BASE
44
45 //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
46 // Globals/Statics
47 //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
48 static long s_cancelSearch = FALSE;
49
50 struct 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 };
66
67 WX_DECLARE_STRING_HASH_MAP(FileInfo, FileInfoMap);
68
69 // Cygwin bug (?) destructor for global s_fileInfo is called twice...
70 static 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 //=============================================================================
91 static 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 //=============================================================================
103 static bool FilteredAdd(wxArrayString& list, const wxChar* filename,
104 unsigned flagsSet, unsigned flagsUnset)
105 {
106 return false;
107 } // FilteredAdd
108
109 //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
110 // wxFSVolume
111 //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
112
113 //=============================================================================
114 // Function: GetVolumes
115 // Purpose: Generate and return a list of all volumes (drives) available.
116 // Notes:
117 //=============================================================================
118 wxArrayString wxFSVolumeBase::GetVolumes(int flagsSet, int flagsUnset)
119 {
120 wxArrayString list;
121
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;
141 }
142
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 //=============================================================================
153 void wxFSVolumeBase::CancelSearch()
154 {
155 } // CancelSearch
156
157 //=============================================================================
158 // Function: constructor
159 // Purpose: default constructor
160 //=============================================================================
161 wxFSVolumeBase::wxFSVolumeBase()
162 {
163 } // wxVolume
164
165 //=============================================================================
166 // Function: constructor
167 // Purpose: constructor that calls Create
168 //=============================================================================
169 wxFSVolumeBase::wxFSVolumeBase(const wxString& name)
170 {
171 } // wxVolume
172
173 //=============================================================================
174 // Function: Create
175 // Purpose: Finds, logs in, etc. to the request volume.
176 //=============================================================================
177 bool wxFSVolumeBase::Create(const wxString& name)
178 {
179 return false;
180 } // Create
181
182 //=============================================================================
183 // Function: IsOk
184 // Purpose: returns true if the volume is legal.
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 //=============================================================================
188 bool wxFSVolumeBase::IsOk() const
189 {
190 return false;
191 } // IsOk
192
193 //=============================================================================
194 // Function: GetKind
195 // Purpose: Return the type of the volume.
196 //=============================================================================
197 wxFSVolumeKind 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 //=============================================================================
207 int 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
220 void wxFSVolume::InitIcons()
221 {
222 }
223
224 //=============================================================================
225 // Function: GetIcon
226 // Purpose: return the requested icon.
227 //=============================================================================
228
229 wxIcon wxFSVolume::GetIcon(wxFSIconType type) const
230 {
231 return m_icons[type];
232 } // GetIcon
233
234 #endif // wxUSE_GUI
235
236 #endif // wxUSE_FSVOLUME