]> git.saurik.com Git - wxWidgets.git/blob - src/palmos/volume.cpp
Better alphabetized the event handler macros
[wxWidgets.git] / src / palmos / volume.cpp
1 ///////////////////////////////////////////////////////////////////////////////
2 // Name: src/palmos/volume.cpp
3 // Purpose: wxFSVolume - encapsulates system volume information
4 // Author: William Osborne
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 #if defined(__GNUG__) && !defined(NO_GCC_PRAGMA)
21 #pragma implementation "fsvolume.h"
22 #endif
23
24 #include "wx/wxprec.h"
25
26 #ifdef __BORLANDC__
27 #pragma hdrstop
28 #endif
29
30 #if wxUSE_FSVOLUME
31
32 #ifndef WX_PRECOMP
33 #if wxUSE_GUI
34 #include "wx/icon.h"
35 #endif
36 #include "wx/intl.h"
37 #endif // WX_PRECOMP
38
39 #include "wx/dir.h"
40 #include "wx/hashmap.h"
41 #include "wx/dynlib.h"
42 #include "wx/arrimpl.cpp"
43
44 #include "wx/volume.h"
45
46 #include "wx/palmos/missing.h"
47
48 #if wxUSE_BASE
49
50 //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
51 // Dynamic library function defs.
52 //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
53
54 static wxDynamicLibrary s_mprLib;
55
56 typedef DWORD (WINAPI* WNetOpenEnumPtr)(DWORD, DWORD, DWORD, LPNETRESOURCE, LPHANDLE);
57 typedef DWORD (WINAPI* WNetEnumResourcePtr)(HANDLE, LPDWORD, LPVOID, LPDWORD);
58 typedef DWORD (WINAPI* WNetCloseEnumPtr)(HANDLE);
59
60 static WNetOpenEnumPtr s_pWNetOpenEnum;
61 static WNetEnumResourcePtr s_pWNetEnumResource;
62 static WNetCloseEnumPtr s_pWNetCloseEnum;
63
64 //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
65 // Globals/Statics
66 //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
67 static long s_cancelSearch = FALSE;
68
69 struct FileInfo
70 {
71 FileInfo(unsigned flag=0, wxFSVolumeKind type=wxFS_VOL_OTHER) :
72 m_flags(flag), m_type(type) {}
73
74 FileInfo(const FileInfo& other) { *this = other; }
75 FileInfo& operator=(const FileInfo& other)
76 {
77 m_flags = other.m_flags;
78 m_type = other.m_type;
79 return *this;
80 }
81
82 unsigned m_flags;
83 wxFSVolumeKind m_type;
84 };
85 WX_DECLARE_STRING_HASH_MAP(FileInfo, FileInfoMap);
86 // Cygwin bug (?) destructor for global s_fileInfo is called twice...
87 static FileInfoMap& GetFileInfoMap()
88 {
89 static FileInfoMap s_fileInfo(25);
90
91 return s_fileInfo;
92 }
93 #define s_fileInfo (GetFileInfoMap())
94
95 //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
96 // Local helper functions.
97 //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
98
99 //=============================================================================
100 // Function: GetBasicFlags
101 // Purpose: Set basic flags, primarily wxFS_VOL_REMOTE and wxFS_VOL_REMOVABLE.
102 // Notes: - Local and mapped drives are mounted by definition. We have no
103 // way to determine mounted status of network drives, so assume that
104 // all drives are mounted, and let the caller decide otherwise.
105 // - Other flags are 'best guess' from type of drive. The system will
106 // not report the file attributes with any degree of accuracy.
107 //=============================================================================
108 static unsigned GetBasicFlags(const wxChar* filename)
109 {
110 unsigned flags = wxFS_VOL_MOUNTED;
111
112 return flags;
113 } // GetBasicFlags
114
115 //=============================================================================
116 // Function: FilteredAdd
117 // Purpose: Add a file to the list if it meets the filter requirement.
118 // Notes: - See GetBasicFlags for remarks about the Mounted flag.
119 //=============================================================================
120 static bool FilteredAdd(wxArrayString& list, const wxChar* filename,
121 unsigned flagsSet, unsigned flagsUnset)
122 {
123 return false;
124 } // FilteredAdd
125
126 //=============================================================================
127 // Function: BuildListFromNN
128 // Purpose: Append or remove items from the list
129 // Notes: - There is no way to find all disconnected NN items, or even to find
130 // all items while determining which are connected and not. So this
131 // function will find either all items or connected items.
132 //=============================================================================
133 static void BuildListFromNN(wxArrayString& list, NETRESOURCE* pResSrc,
134 unsigned flagsSet, unsigned flagsUnset)
135 {
136 } // BuildListFromNN
137
138 //=============================================================================
139 // Function: CompareFcn
140 // Purpose: Used to sort the NN list alphabetically, case insensitive.
141 //=============================================================================
142 static int CompareFcn(wxString* first, wxString* second)
143 {
144 return wxStricmp(first->c_str(), second->c_str());
145 } // CompareFcn
146
147 //=============================================================================
148 // Function: BuildRemoteList
149 // Purpose: Append Network Neighborhood items to the list.
150 // Notes: - Mounted gets transalated into Connected. FilteredAdd is told
151 // to ignore the Mounted flag since we need to handle it in a weird
152 // way manually.
153 // - The resulting list is sorted alphabetically.
154 //=============================================================================
155 static bool BuildRemoteList(wxArrayString& list, NETRESOURCE* pResSrc,
156 unsigned flagsSet, unsigned flagsUnset)
157 {
158 return false;
159 } // BuildRemoteList
160
161 //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
162 // wxFSVolume
163 //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
164
165 //=============================================================================
166 // Function: GetVolumes
167 // Purpose: Generate and return a list of all volumes (drives) available.
168 // Notes:
169 //=============================================================================
170 wxArrayString wxFSVolumeBase::GetVolumes(int flagsSet, int flagsUnset)
171 {
172 wxArrayString list;
173
174 return list;
175 } // GetVolumes
176
177 //=============================================================================
178 // Function: CancelSearch
179 // Purpose: Instruct an active search to stop.
180 // Notes: - This will only sensibly be called by a thread other than the one
181 // performing the search. This is the only thread-safe function
182 // provided by the class.
183 //=============================================================================
184 void wxFSVolumeBase::CancelSearch()
185 {
186 } // CancelSearch
187
188 //=============================================================================
189 // Function: constructor
190 // Purpose: default constructor
191 //=============================================================================
192 wxFSVolumeBase::wxFSVolumeBase()
193 {
194 } // wxVolume
195
196 //=============================================================================
197 // Function: constructor
198 // Purpose: constructor that calls Create
199 //=============================================================================
200 wxFSVolumeBase::wxFSVolumeBase(const wxString& name)
201 {
202 } // wxVolume
203
204 //=============================================================================
205 // Function: Create
206 // Purpose: Finds, logs in, etc. to the request volume.
207 //=============================================================================
208 bool wxFSVolumeBase::Create(const wxString& name)
209 {
210 return false;
211 } // Create
212
213 //=============================================================================
214 // Function: IsOk
215 // Purpose: returns TRUE if the volume is legal.
216 // Notes: For fixed disks, it must exist. For removable disks, it must also
217 // be present. For Network Shares, it must also be logged in, etc.
218 //=============================================================================
219 bool wxFSVolumeBase::IsOk() const
220 {
221 return false;
222 } // IsOk
223
224 //=============================================================================
225 // Function: GetKind
226 // Purpose: Return the type of the volume.
227 //=============================================================================
228 wxFSVolumeKind wxFSVolumeBase::GetKind() const
229 {
230 return wxFS_VOL_OTHER;
231 }
232
233 //=============================================================================
234 // Function: GetFlags
235 // Purpose: Return the caches flags for this volume.
236 // Notes: - Returns -1 if no flags were cached.
237 //=============================================================================
238 int wxFSVolumeBase::GetFlags() const
239 {
240 return -1;
241 } // GetFlags
242
243 #endif // wxUSE_BASE
244
245 // ============================================================================
246 // wxFSVolume
247 // ============================================================================
248
249 #if wxUSE_GUI
250
251 void wxFSVolume::InitIcons()
252 {
253 }
254
255 //=============================================================================
256 // Function: GetIcon
257 // Purpose: return the requested icon.
258 //=============================================================================
259
260 wxIcon wxFSVolume::GetIcon(wxFSIconType type) const
261 {
262 return m_icons[type];
263 } // GetIcon
264
265 #endif // wxUSE_GUI
266
267 #endif // wxUSE_FSVOLUME
268