Merge lp:~carlos-mazieri/ubuntu-filemanager-app/samba-browsing-05 into lp:ubuntu-filemanager-app
- samba-browsing-05
- Merge into trunk
Proposed by
Carlos Jose Mazieri
Status: | Merged |
---|---|
Approved by: | Arto Jalkanen |
Approved revision: | 392 |
Merged at revision: | 407 |
Proposed branch: | lp:~carlos-mazieri/ubuntu-filemanager-app/samba-browsing-05 |
Merge into: | lp:ubuntu-filemanager-app |
Prerequisite: | lp:~carlos-mazieri/ubuntu-filemanager-app/samba-browsing-04 |
Diff against target: |
586 lines (+518/-3) 8 files modified
src/plugin/folderlistmodel/CMakeLists.txt (+7/-1) src/plugin/folderlistmodel/folderlistmodel.pri (+5/-2) src/plugin/folderlistmodel/smb/qsambaclient/src/smbiteminfo.cpp (+167/-0) src/plugin/folderlistmodel/smb/qsambaclient/src/smbiteminfo.h (+52/-0) src/plugin/folderlistmodel/smb/qsambaclient/src/smbobject.cpp (+50/-0) src/plugin/folderlistmodel/smb/qsambaclient/src/smbobject.h (+45/-0) src/plugin/folderlistmodel/urliteminfo.cpp (+139/-0) src/plugin/folderlistmodel/urliteminfo.h (+53/-0) |
To merge this branch: | bzr merge lp:~carlos-mazieri/ubuntu-filemanager-app/samba-browsing-05 |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Arto Jalkanen | Approve | ||
Ubuntu Phone Apps Jenkins Bot | continuous-integration | Approve | |
Review via email: mp+252974@code.launchpad.net |
Commit message
Introduces the class SmbItemInfo which represents an Samba Item (folder,
Description of the change
Introduces the class SmbItemInfo which represents an Samba Item (folder,
To post a comment you must log in.
Revision history for this message
Ubuntu Phone Apps Jenkins Bot (ubuntu-phone-apps-jenkins-bot) wrote : | # |
review:
Approve
(continuous-integration)
Revision history for this message
Arto Jalkanen (ajalkane) : | # |
review:
Approve
Preview Diff
[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1 | === modified file 'src/plugin/folderlistmodel/CMakeLists.txt' | |||
2 | --- src/plugin/folderlistmodel/CMakeLists.txt 2015-03-14 17:44:21 +0000 | |||
3 | +++ src/plugin/folderlistmodel/CMakeLists.txt 2015-03-14 17:44:21 +0000 | |||
4 | @@ -46,7 +46,9 @@ | |||
5 | 46 | locationitemdiriterator.cpp | 46 | locationitemdiriterator.cpp |
6 | 47 | locationitemdiriterator.h | 47 | locationitemdiriterator.h |
7 | 48 | cleanurl.cpp | 48 | cleanurl.cpp |
9 | 49 | cleanurl.h | 49 | cleanurl.h |
10 | 50 | urliteminfo.cpp | ||
11 | 51 | urliteminfo.h | ||
12 | 50 | disk/disklocation.cpp | 52 | disk/disklocation.cpp |
13 | 51 | disk/disklocation.h | 53 | disk/disklocation.h |
14 | 52 | trash/qtrashdir.cpp | 54 | trash/qtrashdir.cpp |
15 | @@ -59,6 +61,10 @@ | |||
16 | 59 | trash/trashlocation.h | 61 | trash/trashlocation.h |
17 | 60 | smb/qsambaclient/src/smbutil.cpp | 62 | smb/qsambaclient/src/smbutil.cpp |
18 | 61 | smb/qsambaclient/src/smbutil.h | 63 | smb/qsambaclient/src/smbutil.h |
19 | 64 | smb/qsambaclient/src/smbiteminfo.cpp | ||
20 | 65 | smb/qsambaclient/src/smbiteminfo.h | ||
21 | 66 | smb/qsambaclient/src/smbobject.cpp | ||
22 | 67 | smb/qsambaclient/src/smbobject.h | ||
23 | 62 | net/netauthenticationdata.cpp | 68 | net/netauthenticationdata.cpp |
24 | 63 | net/netauthenticationdata.h | 69 | net/netauthenticationdata.h |
25 | 64 | net/netutil.cpp | 70 | net/netutil.cpp |
26 | 65 | 71 | ||
27 | === modified file 'src/plugin/folderlistmodel/folderlistmodel.pri' | |||
28 | --- src/plugin/folderlistmodel/folderlistmodel.pri 2015-03-14 17:44:21 +0000 | |||
29 | +++ src/plugin/folderlistmodel/folderlistmodel.pri 2015-03-14 17:44:21 +0000 | |||
30 | @@ -8,7 +8,8 @@ | |||
31 | 8 | $$PWD/clipboard.cpp \ | 8 | $$PWD/clipboard.cpp \ |
32 | 9 | $$PWD/fmutil.cpp \ | 9 | $$PWD/fmutil.cpp \ |
33 | 10 | $$PWD/dirselection.cpp \ | 10 | $$PWD/dirselection.cpp \ |
35 | 11 | $$PWD/diriteminfo.cpp \ | 11 | $$PWD/diriteminfo.cpp \ |
36 | 12 | $$PWD/urliteminfo.cpp \ | ||
37 | 12 | $$PWD/location.cpp \ | 13 | $$PWD/location.cpp \ |
38 | 13 | $$PWD/locationsfactory.cpp \ | 14 | $$PWD/locationsfactory.cpp \ |
39 | 14 | $$PWD/locationurl.cpp \ | 15 | $$PWD/locationurl.cpp \ |
40 | @@ -25,7 +26,9 @@ | |||
41 | 25 | $$PWD/clipboard.h \ | 26 | $$PWD/clipboard.h \ |
42 | 26 | $$PWD/fmutil.h \ | 27 | $$PWD/fmutil.h \ |
43 | 27 | $$PWD/dirselection.h \ | 28 | $$PWD/dirselection.h \ |
45 | 28 | $$PWD/diritemabstractlistmodel.h \ | 29 | $$PWD/diritemabstractlistmodel.h \ |
46 | 30 | $$PWD/diriteminfo.h \ | ||
47 | 31 | $$PWD/urliteminfo.h \ | ||
48 | 29 | $$PWD/location.h \ | 32 | $$PWD/location.h \ |
49 | 30 | $$PWD/locationsfactory.h \ | 33 | $$PWD/locationsfactory.h \ |
50 | 31 | $$PWD/locationurl.h \ | 34 | $$PWD/locationurl.h \ |
51 | 32 | 35 | ||
52 | === added file 'src/plugin/folderlistmodel/smb/qsambaclient/src/smbiteminfo.cpp' | |||
53 | --- src/plugin/folderlistmodel/smb/qsambaclient/src/smbiteminfo.cpp 1970-01-01 00:00:00 +0000 | |||
54 | +++ src/plugin/folderlistmodel/smb/qsambaclient/src/smbiteminfo.cpp 2015-03-14 17:44:21 +0000 | |||
55 | @@ -0,0 +1,167 @@ | |||
56 | 1 | /************************************************************************** | ||
57 | 2 | * | ||
58 | 3 | * Copyright 2014 Canonical Ltd. | ||
59 | 4 | * Copyright 2014 Carlos J Mazieri <carlos.mazieri@gmail.com> | ||
60 | 5 | * | ||
61 | 6 | * This program is free software; you can redistribute it and/or modify | ||
62 | 7 | * it under the terms of the GNU Lesser General Public License as published by | ||
63 | 8 | * the Free Software Foundation; version 3. | ||
64 | 9 | * | ||
65 | 10 | * This program is distributed in the hope that it will be useful, | ||
66 | 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
67 | 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
68 | 13 | * GNU Lesser General Public License for more details. | ||
69 | 14 | * | ||
70 | 15 | * You should have received a copy of the GNU Lesser General Public License | ||
71 | 16 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
72 | 17 | * | ||
73 | 18 | * File: smbiteminfo.cpp | ||
74 | 19 | * Date: 08/12/2014 | ||
75 | 20 | */ | ||
76 | 21 | |||
77 | 22 | #include "smbiteminfo.h" | ||
78 | 23 | #include "locationurl.h" | ||
79 | 24 | #include "smbutil.h" | ||
80 | 25 | |||
81 | 26 | #include <QUrl> | ||
82 | 27 | |||
83 | 28 | SmbItemInfo::SmbItemInfo() : UrlItemInfo(), SmbObject(QLatin1String(0)) | ||
84 | 29 | { | ||
85 | 30 | |||
86 | 31 | } | ||
87 | 32 | |||
88 | 33 | SmbItemInfo::SmbItemInfo(const QString &urlPath, Const_SmbUtil_Ptr smb) : | ||
89 | 34 | UrlItemInfo(urlPath, LocationUrl::SmbURL) | ||
90 | 35 | ,SmbObject(urlPath, smb) | ||
91 | 36 | { | ||
92 | 37 | if (isValid() && !isRoot()) | ||
93 | 38 | { | ||
94 | 39 | setInfo(cleanUrl()); | ||
95 | 40 | } | ||
96 | 41 | } | ||
97 | 42 | |||
98 | 43 | |||
99 | 44 | SmbItemInfo::~SmbItemInfo() | ||
100 | 45 | { | ||
101 | 46 | |||
102 | 47 | } | ||
103 | 48 | |||
104 | 49 | |||
105 | 50 | void SmbItemInfo::setInfo(const QString& smb_path) | ||
106 | 51 | { | ||
107 | 52 | SmbUtil *smb = const_cast<SmbUtil*> (m_smb); | ||
108 | 53 | struct stat st; | ||
109 | 54 | int ret = smb->getStatInfo(smb_path, &st); | ||
110 | 55 | //lets start with true | ||
111 | 56 | d_ptr->_exists = d_ptr->_isReadable = true; | ||
112 | 57 | switch(ret) | ||
113 | 58 | { | ||
114 | 59 | case SmbUtil::StatInvalid: | ||
115 | 60 | case SmbUtil::StatDoesNotExist: | ||
116 | 61 | //reset _isHost because it might be set in UrlItemInfo | ||
117 | 62 | d_ptr->_isHost = false; | ||
118 | 63 | d_ptr->_exists = d_ptr->_isReadable = false; | ||
119 | 64 | break; | ||
120 | 65 | case SmbUtil::StatDir: | ||
121 | 66 | //if directories does not have permissions lets set default | ||
122 | 67 | //some smb stat functions does not work, this code will not hurt | ||
123 | 68 | if ((st.st_mode & S_IFMT) == 0) | ||
124 | 69 | { | ||
125 | 70 | st.st_mode |= S_IRUSR | S_IWUSR | S_IXUSR | | ||
126 | 71 | S_IRGRP | S_IWGRP | S_IXGRP | | ||
127 | 72 | S_IROTH | S_IXOTH; | ||
128 | 73 | } | ||
129 | 74 | st.st_mode |= S_IFDIR; | ||
130 | 75 | break; | ||
131 | 76 | case SmbUtil::StatHost: | ||
132 | 77 | d_ptr->_isHost = true; | ||
133 | 78 | break; | ||
134 | 79 | case SmbUtil::StatShare: | ||
135 | 80 | d_ptr->_isNetworkShare = true; | ||
136 | 81 | break; | ||
137 | 82 | case SmbUtil::StatWorkgroup: | ||
138 | 83 | d_ptr->_isHost = false; | ||
139 | 84 | d_ptr->_isWorkGroup = true; | ||
140 | 85 | break; | ||
141 | 86 | case SmbUtil::StatNoAccess: | ||
142 | 87 | //it is special case where the authentication might have failed | ||
143 | 88 | d_ptr->_isReadable = false; | ||
144 | 89 | d_ptr->_needsAuthentication = true; | ||
145 | 90 | break; | ||
146 | 91 | } | ||
147 | 92 | //all the information should be in place now | ||
148 | 93 | fillFromStatBuf(st); | ||
149 | 94 | } | ||
150 | 95 | |||
151 | 96 | |||
152 | 97 | QString SmbItemInfo::authenticationPath() const | ||
153 | 98 | { | ||
154 | 99 | return sharePath(); | ||
155 | 100 | } | ||
156 | 101 | |||
157 | 102 | /*! | ||
158 | 103 | * \brief SmbItemInfo::sharePath() returns the share part of the item | ||
159 | 104 | * \return NULL if the item is root | ||
160 | 105 | */ | ||
161 | 106 | QString SmbItemInfo::sharePath() const | ||
162 | 107 | { | ||
163 | 108 | QString share; | ||
164 | 109 | if (isWorkGroup() || isHost() || isShare()) | ||
165 | 110 | { | ||
166 | 111 | share = absoluteFilePath(); | ||
167 | 112 | } | ||
168 | 113 | else | ||
169 | 114 | if (!isRoot()) | ||
170 | 115 | { | ||
171 | 116 | //0 1 2 3 4 6 | ||
172 | 117 | //s m b : / / smb://host/share[/dir] | ||
173 | 118 | int slashIndex = 6; | ||
174 | 119 | int found = 0; | ||
175 | 120 | QString fullpath(absoluteFilePath()); | ||
176 | 121 | for (; found < 2 && slashIndex != -1; ++found) | ||
177 | 122 | { | ||
178 | 123 | slashIndex = fullpath.indexOf(QDir::separator(), slashIndex +1); | ||
179 | 124 | } | ||
180 | 125 | switch(found) | ||
181 | 126 | { | ||
182 | 127 | case 1: share = fullpath; break; | ||
183 | 128 | case 2: share = fullpath.left(slashIndex); break; | ||
184 | 129 | default: break; | ||
185 | 130 | } | ||
186 | 131 | } | ||
187 | 132 | return share; | ||
188 | 133 | } | ||
189 | 134 | |||
190 | 135 | |||
191 | 136 | void SmbItemInfo::setFile(const QString &dir, const QString &file) | ||
192 | 137 | { | ||
193 | 138 | QString smb_path; | ||
194 | 139 | if (dir.startsWith(LocationUrl::SmbURL)) | ||
195 | 140 | { | ||
196 | 141 | smb_path = dir; | ||
197 | 142 | } | ||
198 | 143 | else | ||
199 | 144 | { | ||
200 | 145 | QUrl url(urlPath()); | ||
201 | 146 | QFileInfo f(url.path() + QDir::separator() + dir); | ||
202 | 147 | url.setPath(f.canonicalFilePath()); | ||
203 | 148 | smb_path = url.toString(); | ||
204 | 149 | } | ||
205 | 150 | smb_path += QDir::separator() + file; | ||
206 | 151 | SmbItemInfo *other = new SmbItemInfo( LocationUrl::SmbURL + DirItemInfo::removeExtraSlashes(smb_path), | ||
207 | 152 | m_smb); | ||
208 | 153 | if (other->isValid()) | ||
209 | 154 | { | ||
210 | 155 | *this = *other; | ||
211 | 156 | } | ||
212 | 157 | else | ||
213 | 158 | { | ||
214 | 159 | delete other; | ||
215 | 160 | } | ||
216 | 161 | } | ||
217 | 162 | |||
218 | 163 | |||
219 | 164 | void SmbItemInfo::setAsShare() | ||
220 | 165 | { | ||
221 | 166 | d_ptr->_isNetworkShare = true; | ||
222 | 167 | } | ||
223 | 0 | 168 | ||
224 | === added file 'src/plugin/folderlistmodel/smb/qsambaclient/src/smbiteminfo.h' | |||
225 | --- src/plugin/folderlistmodel/smb/qsambaclient/src/smbiteminfo.h 1970-01-01 00:00:00 +0000 | |||
226 | +++ src/plugin/folderlistmodel/smb/qsambaclient/src/smbiteminfo.h 2015-03-14 17:44:21 +0000 | |||
227 | @@ -0,0 +1,52 @@ | |||
228 | 1 | /************************************************************************** | ||
229 | 2 | * | ||
230 | 3 | * Copyright 2014 Canonical Ltd. | ||
231 | 4 | * Copyright 2014 Carlos J Mazieri <carlos.mazieri@gmail.com> | ||
232 | 5 | * | ||
233 | 6 | * This program is free software; you can redistribute it and/or modify | ||
234 | 7 | * it under the terms of the GNU Lesser General Public License as published by | ||
235 | 8 | * the Free Software Foundation; version 3. | ||
236 | 9 | * | ||
237 | 10 | * This program is distributed in the hope that it will be useful, | ||
238 | 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
239 | 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
240 | 13 | * GNU Lesser General Public License for more details. | ||
241 | 14 | * | ||
242 | 15 | * You should have received a copy of the GNU Lesser General Public License | ||
243 | 16 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
244 | 17 | * | ||
245 | 18 | * File: smbiteminfo.h | ||
246 | 19 | * Date: 08/12/2014 | ||
247 | 20 | */ | ||
248 | 21 | |||
249 | 22 | #ifndef SMBITEMINFO_H | ||
250 | 23 | #define SMBITEMINFO_H | ||
251 | 24 | |||
252 | 25 | #include "urliteminfo.h" | ||
253 | 26 | #include "smbobject.h" | ||
254 | 27 | |||
255 | 28 | class QUrl; | ||
256 | 29 | |||
257 | 30 | class SmbItemInfo : public UrlItemInfo, public SmbObject | ||
258 | 31 | { | ||
259 | 32 | public: | ||
260 | 33 | /*! | ||
261 | 34 | * \brief SmbItemInfo | ||
262 | 35 | * \param urlPath a url | ||
263 | 36 | * \param smb an instance of \ref SmbUtil that has an authentication callback already set | ||
264 | 37 | */ | ||
265 | 38 | SmbItemInfo(const QString& urlPath, Const_SmbUtil_Ptr smb = 0); | ||
266 | 39 | SmbItemInfo(); | ||
267 | 40 | ~SmbItemInfo(); | ||
268 | 41 | |||
269 | 42 | public: | ||
270 | 43 | QString sharePath() const; | ||
271 | 44 | void setAsShare(); | ||
272 | 45 | virtual QString authenticationPath() const; | ||
273 | 46 | virtual void setFile(const QString &dir, const QString & file); | ||
274 | 47 | |||
275 | 48 | protected: | ||
276 | 49 | void setInfo(const QString &smb_path); | ||
277 | 50 | }; | ||
278 | 51 | |||
279 | 52 | #endif // SMBITEMINFO_H | ||
280 | 0 | 53 | ||
281 | === added file 'src/plugin/folderlistmodel/smb/qsambaclient/src/smbobject.cpp' | |||
282 | --- src/plugin/folderlistmodel/smb/qsambaclient/src/smbobject.cpp 1970-01-01 00:00:00 +0000 | |||
283 | +++ src/plugin/folderlistmodel/smb/qsambaclient/src/smbobject.cpp 2015-03-14 17:44:21 +0000 | |||
284 | @@ -0,0 +1,50 @@ | |||
285 | 1 | /************************************************************************** | ||
286 | 2 | * | ||
287 | 3 | * Copyright 2015 Canonical Ltd. | ||
288 | 4 | * Copyright 2015 Carlos J Mazieri <carlos.mazieri@gmail.com> | ||
289 | 5 | * | ||
290 | 6 | * This program is free software; you can redistribute it and/or modify | ||
291 | 7 | * it under the terms of the GNU Lesser General Public License as published by | ||
292 | 8 | * the Free Software Foundation; version 3. | ||
293 | 9 | * | ||
294 | 10 | * This program is distributed in the hope that it will be useful, | ||
295 | 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
296 | 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
297 | 13 | * GNU Lesser General Public License for more details. | ||
298 | 14 | * | ||
299 | 15 | * You should have received a copy of the GNU Lesser General Public License | ||
300 | 16 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
301 | 17 | * | ||
302 | 18 | * File: smbobject.cpp | ||
303 | 19 | * Date: 02/01/2015 | ||
304 | 20 | */ | ||
305 | 21 | |||
306 | 22 | #include "smbobject.h" | ||
307 | 23 | #include "smbutil.h" | ||
308 | 24 | |||
309 | 25 | #include <QUrl> | ||
310 | 26 | |||
311 | 27 | SmbObject::SmbObject(const QString &urlPath, Const_SmbUtil_Ptr smb) | ||
312 | 28 | : CleanUrl(urlPath), m_smb(smb), m_smbOwnInstance(0) | ||
313 | 29 | { | ||
314 | 30 | if (m_smb == 0) | ||
315 | 31 | { | ||
316 | 32 | m_smb = m_smbOwnInstance = new SmbUtil(cleanUrl()); | ||
317 | 33 | } | ||
318 | 34 | } | ||
319 | 35 | |||
320 | 36 | |||
321 | 37 | SmbObject::~SmbObject() | ||
322 | 38 | { | ||
323 | 39 | if (m_smbOwnInstance != 0) | ||
324 | 40 | { | ||
325 | 41 | delete m_smbOwnInstance; | ||
326 | 42 | m_smbOwnInstance = 0; | ||
327 | 43 | } | ||
328 | 44 | } | ||
329 | 45 | |||
330 | 46 | |||
331 | 47 | SmbUtil_Ptr SmbObject::smbObj() const | ||
332 | 48 | { | ||
333 | 49 | return const_cast<SmbUtil_Ptr>(m_smb); | ||
334 | 50 | } | ||
335 | 0 | 51 | ||
336 | === added file 'src/plugin/folderlistmodel/smb/qsambaclient/src/smbobject.h' | |||
337 | --- src/plugin/folderlistmodel/smb/qsambaclient/src/smbobject.h 1970-01-01 00:00:00 +0000 | |||
338 | +++ src/plugin/folderlistmodel/smb/qsambaclient/src/smbobject.h 2015-03-14 17:44:21 +0000 | |||
339 | @@ -0,0 +1,45 @@ | |||
340 | 1 | /************************************************************************** | ||
341 | 2 | * | ||
342 | 3 | * Copyright 2015 Canonical Ltd. | ||
343 | 4 | * Copyright 2015 Carlos J Mazieri <carlos.mazieri@gmail.com> | ||
344 | 5 | * | ||
345 | 6 | * This program is free software; you can redistribute it and/or modify | ||
346 | 7 | * it under the terms of the GNU Lesser General Public License as published by | ||
347 | 8 | * the Free Software Foundation; version 3. | ||
348 | 9 | * | ||
349 | 10 | * This program is distributed in the hope that it will be useful, | ||
350 | 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
351 | 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
352 | 13 | * GNU Lesser General Public License for more details. | ||
353 | 14 | * | ||
354 | 15 | * You should have received a copy of the GNU Lesser General Public License | ||
355 | 16 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
356 | 17 | * | ||
357 | 18 | * File: smbobject.h | ||
358 | 19 | * Date: 02/01/2015 | ||
359 | 20 | */ | ||
360 | 21 | |||
361 | 22 | #ifndef SMBOBJECT_H | ||
362 | 23 | #define SMBOBJECT_H | ||
363 | 24 | |||
364 | 25 | #include "cleanurl.h" | ||
365 | 26 | |||
366 | 27 | #include <QString> | ||
367 | 28 | |||
368 | 29 | class SmbUtil; | ||
369 | 30 | typedef SmbUtil const * Const_SmbUtil_Ptr; | ||
370 | 31 | typedef SmbUtil * SmbUtil_Ptr; | ||
371 | 32 | |||
372 | 33 | class SmbObject : public CleanUrl | ||
373 | 34 | { | ||
374 | 35 | protected: | ||
375 | 36 | SmbObject(const QString &urlPath, Const_SmbUtil_Ptr smb = 0); | ||
376 | 37 | SmbUtil_Ptr smbObj() const; | ||
377 | 38 | public: | ||
378 | 39 | virtual ~SmbObject(); | ||
379 | 40 | protected: | ||
380 | 41 | Const_SmbUtil_Ptr m_smb; | ||
381 | 42 | SmbUtil_Ptr m_smbOwnInstance; //!< not zero only if smb == 0 | ||
382 | 43 | }; | ||
383 | 44 | |||
384 | 45 | #endif // SMBOBJECT_H | ||
385 | 0 | 46 | ||
386 | === added file 'src/plugin/folderlistmodel/urliteminfo.cpp' | |||
387 | --- src/plugin/folderlistmodel/urliteminfo.cpp 1970-01-01 00:00:00 +0000 | |||
388 | +++ src/plugin/folderlistmodel/urliteminfo.cpp 2015-03-14 17:44:21 +0000 | |||
389 | @@ -0,0 +1,139 @@ | |||
390 | 1 | /************************************************************************** | ||
391 | 2 | * | ||
392 | 3 | * Copyright 2014 Canonical Ltd. | ||
393 | 4 | * Copyright 2014 Carlos J Mazieri <carlos.mazieri@gmail.com> | ||
394 | 5 | * | ||
395 | 6 | * This program is free software; you can redistribute it and/or modify | ||
396 | 7 | * it under the terms of the GNU Lesser General Public License as published by | ||
397 | 8 | * the Free Software Foundation; version 3. | ||
398 | 9 | * | ||
399 | 10 | * This program is distributed in the hope that it will be useful, | ||
400 | 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
401 | 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
402 | 13 | * GNU Lesser General Public License for more details. | ||
403 | 14 | * | ||
404 | 15 | * You should have received a copy of the GNU Lesser General Public License | ||
405 | 16 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
406 | 17 | * | ||
407 | 18 | * File: urliteminfo.cpp | ||
408 | 19 | * Date: 08/12/2014 | ||
409 | 20 | */ | ||
410 | 21 | |||
411 | 22 | #include "urliteminfo.h" | ||
412 | 23 | |||
413 | 24 | #include <QUrl> | ||
414 | 25 | |||
415 | 26 | UrlItemInfo::UrlItemInfo(): DirItemInfo() | ||
416 | 27 | { | ||
417 | 28 | |||
418 | 29 | } | ||
419 | 30 | |||
420 | 31 | UrlItemInfo::UrlItemInfo(const QString& urlPath, const QString& urlRoot): | ||
421 | 32 | DirItemInfo() | ||
422 | 33 | { | ||
423 | 34 | if (urlPath == urlRoot) | ||
424 | 35 | { | ||
425 | 36 | setRoot(urlPath); | ||
426 | 37 | } | ||
427 | 38 | else | ||
428 | 39 | { | ||
429 | 40 | if (!urlPath.startsWith(urlRoot)) | ||
430 | 41 | { | ||
431 | 42 | d_ptr->_isValid = false; | ||
432 | 43 | d_ptr->_isAbsolute = false; | ||
433 | 44 | } | ||
434 | 45 | else | ||
435 | 46 | { | ||
436 | 47 | init(urlPath); | ||
437 | 48 | } | ||
438 | 49 | } | ||
439 | 50 | |||
440 | 51 | } | ||
441 | 52 | |||
442 | 53 | |||
443 | 54 | void UrlItemInfo::setRoot(const QString& urlPath) | ||
444 | 55 | { | ||
445 | 56 | d_ptr->_isValid = true; | ||
446 | 57 | d_ptr->_isRoot = true; | ||
447 | 58 | d_ptr->_isDir = true; | ||
448 | 59 | d_ptr->_isReadable = true; | ||
449 | 60 | d_ptr->_isExecutable = true; | ||
450 | 61 | d_ptr->_exists = true; | ||
451 | 62 | d_ptr->_isAbsolute = true; | ||
452 | 63 | d_ptr->_isRemote = true; | ||
453 | 64 | d_ptr->_fileName.clear(); | ||
454 | 65 | d_ptr->_path = urlPath; | ||
455 | 66 | d_ptr->_normalizedPath = d_ptr->_path; | ||
456 | 67 | } | ||
457 | 68 | |||
458 | 69 | |||
459 | 70 | /*! | ||
460 | 71 | * \brief UrlItemInfo::init() fill basic item information | ||
461 | 72 | * | ||
462 | 73 | * It is supposed the URL does contain duplicates slashes | ||
463 | 74 | * | ||
464 | 75 | * \param urlPath | ||
465 | 76 | */ | ||
466 | 77 | void UrlItemInfo::init(const QString& urlPath) | ||
467 | 78 | { | ||
468 | 79 | d_ptr->_isValid = true; | ||
469 | 80 | d_ptr->_isAbsolute = true; | ||
470 | 81 | d_ptr->_isRemote = true; | ||
471 | 82 | |||
472 | 83 | //veryfy if the item is a host | ||
473 | 84 | verifyHost(urlPath); | ||
474 | 85 | |||
475 | 86 | QStringList pathAndFile = separatePathFilename(urlPath); | ||
476 | 87 | if (pathAndFile.count() == 2) | ||
477 | 88 | { | ||
478 | 89 | d_ptr->_path = pathAndFile.at(0); | ||
479 | 90 | d_ptr->_fileName = pathAndFile.at(1); | ||
480 | 91 | } | ||
481 | 92 | else | ||
482 | 93 | { | ||
483 | 94 | d_ptr->_path = urlPath; | ||
484 | 95 | } | ||
485 | 96 | d_ptr->_normalizedPath = d_ptr->_path; | ||
486 | 97 | } | ||
487 | 98 | |||
488 | 99 | |||
489 | 100 | void UrlItemInfo::verifyHost(const QString urlPath) | ||
490 | 101 | { | ||
491 | 102 | QUrl url(urlPath); | ||
492 | 103 | if (url.isValid() && !url.isLocalFile()) | ||
493 | 104 | { | ||
494 | 105 | if (url.path().isEmpty()) | ||
495 | 106 | { | ||
496 | 107 | //!< initial set is "host", Samba shares also have Workspace which will be handled in \ref SmbItemInfo | ||
497 | 108 | d_ptr->_isHost = true; | ||
498 | 109 | //set as it exists so far | ||
499 | 110 | d_ptr->_exists = true; | ||
500 | 111 | d_ptr->_isReadable = true; | ||
501 | 112 | d_ptr->_isExecutable = true; | ||
502 | 113 | } | ||
503 | 114 | } | ||
504 | 115 | } | ||
505 | 116 | |||
506 | 117 | |||
507 | 118 | /*! | ||
508 | 119 | * \brief UrlItemInfo::separatePathFilename() | ||
509 | 120 | * \param urlPath | ||
510 | 121 | * \return [0]=path [1]=filename when it exists | ||
511 | 122 | */ | ||
512 | 123 | QStringList UrlItemInfo::separatePathFilename(const QString &urlPath) | ||
513 | 124 | { | ||
514 | 125 | QStringList separated; | ||
515 | 126 | int lastDir = urlPath.lastIndexOf(QDir::separator()); | ||
516 | 127 | //path and filename must fill the url, | ||
517 | 128 | // smb://localost path=smb:// filename=localhost | ||
518 | 129 | // smb://localhost/dir path=smb://localhost filename=dir | ||
519 | 130 | if (lastDir != -1) | ||
520 | 131 | { | ||
521 | 132 | QString path = urlPath.at(lastDir-1) == QDir::separator() ? | ||
522 | 133 | urlPath.left(lastDir+1) : urlPath.left(lastDir); | ||
523 | 134 | |||
524 | 135 | separated.append(path); | ||
525 | 136 | separated.append(urlPath.mid(lastDir + 1)); | ||
526 | 137 | } | ||
527 | 138 | return separated; | ||
528 | 139 | } | ||
529 | 0 | 140 | ||
530 | === added file 'src/plugin/folderlistmodel/urliteminfo.h' | |||
531 | --- src/plugin/folderlistmodel/urliteminfo.h 1970-01-01 00:00:00 +0000 | |||
532 | +++ src/plugin/folderlistmodel/urliteminfo.h 2015-03-14 17:44:21 +0000 | |||
533 | @@ -0,0 +1,53 @@ | |||
534 | 1 | /************************************************************************** | ||
535 | 2 | * | ||
536 | 3 | * Copyright 2014 Canonical Ltd. | ||
537 | 4 | * Copyright 2014 Carlos J Mazieri <carlos.mazieri@gmail.com> | ||
538 | 5 | * | ||
539 | 6 | * This program is free software; you can redistribute it and/or modify | ||
540 | 7 | * it under the terms of the GNU Lesser General Public License as published by | ||
541 | 8 | * the Free Software Foundation; version 3. | ||
542 | 9 | * | ||
543 | 10 | * This program is distributed in the hope that it will be useful, | ||
544 | 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
545 | 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
546 | 13 | * GNU Lesser General Public License for more details. | ||
547 | 14 | * | ||
548 | 15 | * You should have received a copy of the GNU Lesser General Public License | ||
549 | 16 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
550 | 17 | * | ||
551 | 18 | * File: urliteminfo.h | ||
552 | 19 | * Date: 08/12/2014 | ||
553 | 20 | */ | ||
554 | 21 | |||
555 | 22 | #ifndef URLITEMINFO_H | ||
556 | 23 | #define URLITEMINFO_H | ||
557 | 24 | |||
558 | 25 | #include "diriteminfo.h" | ||
559 | 26 | |||
560 | 27 | |||
561 | 28 | /*! | ||
562 | 29 | * \brief The UrlItemInfo is an abstract class that provides URL root | ||
563 | 30 | * | ||
564 | 31 | * Basically it differs from DirItemInfo in the field \a d_ptr->_normalizedPath, it must store the | ||
565 | 32 | * url like trash:///Item, while the field d_ptr->_path stores the current path in the file system as usual. | ||
566 | 33 | * | ||
567 | 34 | */ | ||
568 | 35 | |||
569 | 36 | class UrlItemInfo : public DirItemInfo | ||
570 | 37 | { | ||
571 | 38 | public: | ||
572 | 39 | static QStringList separatePathFilename(const QString& urlPath); | ||
573 | 40 | protected: | ||
574 | 41 | UrlItemInfo(const QString& urlPath, const QString& urlRoot); | ||
575 | 42 | UrlItemInfo(); | ||
576 | 43 | |||
577 | 44 | protected: | ||
578 | 45 | void setRoot(const QString& urlRoot); | ||
579 | 46 | |||
580 | 47 | |||
581 | 48 | private: | ||
582 | 49 | void init(const QString& urlPath); | ||
583 | 50 | void verifyHost(const QString urlPath); | ||
584 | 51 | }; | ||
585 | 52 | |||
586 | 53 | #endif // URLITEMINFO_H |
PASSED: Continuous integration, rev:392 91.189. 93.70:8080/ job/ubuntu- filemanager- app-ci/ 477/ 91.189. 93.70:8080/ job/generic- mediumtests- utopic/ 2343 91.189. 93.70:8080/ job/generic- mediumtests- utopic/ 2343/artifact/ work/output/ *zip*/output. zip 91.189. 93.70:8080/ job/ubuntu- filemanager- app-utopic- amd64-ci/ 193 91.189. 93.70:8080/ job/ubuntu- filemanager- app-vivid- amd64-ci/ 99
http://
Executed test runs:
SUCCESS: http://
deb: http://
SUCCESS: http://
SUCCESS: http://
Click here to trigger a rebuild: 91.189. 93.70:8080/ job/ubuntu- filemanager- app-ci/ 477/rebuild
http://