Merge lp:~carlos-mazieri/ubuntu-filemanager-app/samba-browsing-06 into lp:ubuntu-filemanager-app

Proposed by Carlos Jose Mazieri
Status: Merged
Approved by: Arto Jalkanen
Approved revision: 393
Merged at revision: 408
Proposed branch: lp:~carlos-mazieri/ubuntu-filemanager-app/samba-browsing-06
Merge into: lp:ubuntu-filemanager-app
Prerequisite: lp:~carlos-mazieri/ubuntu-filemanager-app/samba-browsing-05
Diff against target: 341 lines (+294/-2)
6 files modified
src/plugin/folderlistmodel/CMakeLists.txt (+5/-1)
src/plugin/folderlistmodel/iorequest.h (+2/-1)
src/plugin/folderlistmodel/smb/qsambaclient/src/smblocationdiriterator.cpp (+136/-0)
src/plugin/folderlistmodel/smb/qsambaclient/src/smblocationdiriterator.h (+48/-0)
src/plugin/folderlistmodel/smb/smblistworker.cpp (+63/-0)
src/plugin/folderlistmodel/smb/smblistworker.h (+40/-0)
To merge this branch: bzr merge lp:~carlos-mazieri/ubuntu-filemanager-app/samba-browsing-06
Reviewer Review Type Date Requested Status
Arto Jalkanen Approve
Ubuntu Phone Apps Jenkins Bot continuous-integration Approve
Review via email: mp+252975@code.launchpad.net

Commit message

Samba Listing classes

Description of the change

Introduces classes:
             SmbListWorker which is a IORequest and will build a list of samba items to the model
             SmbLocationDirIterator which is a implementation of Qt QDirIterator class for Samba

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) wrote :

If you can, revert changes to po/com.ubuntu.filemanager.pot

review: Approve
393. By Carlos Jose Mazieri

Introduces classes:
             SmbListWorker which is a IORequest and will build a list of samba items to the model
             SmbLocationDirIterator which is a implementation of Qt QDirIterator class for Samba

Revision history for this message
Carlos Jose Mazieri (carlos-mazieri) wrote :

po/com.ubuntu.filemanager.pot reverted

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:38:50 +0000
3+++ src/plugin/folderlistmodel/CMakeLists.txt 2015-04-29 22:35:22 +0000
4@@ -58,11 +58,15 @@
5 trash/trashiteminfo.cpp
6 trash/trashiteminfo.h
7 trash/trashlocation.cpp
8- trash/trashlocation.h
9+ trash/trashlocation.h
10+ smb/smblistworker.cpp
11+ smb/smblistworker.h
12 smb/qsambaclient/src/smbutil.cpp
13 smb/qsambaclient/src/smbutil.h
14 smb/qsambaclient/src/smbiteminfo.cpp
15 smb/qsambaclient/src/smbiteminfo.h
16+ smb/qsambaclient/src/smblocationdiriterator.cpp
17+ smb/qsambaclient/src/smblocationdiriterator.h
18 smb/qsambaclient/src/smbobject.cpp
19 smb/qsambaclient/src/smbobject.h
20 net/netauthenticationdata.cpp
21
22=== modified file 'src/plugin/folderlistmodel/iorequest.h'
23--- src/plugin/folderlistmodel/iorequest.h 2015-03-01 15:32:42 +0000
24+++ src/plugin/folderlistmodel/iorequest.h 2015-04-29 22:35:22 +0000
25@@ -48,7 +48,8 @@
26 enum RequestType
27 {
28 DirList,
29- DirListExternalFSChanges
30+ DirListExternalFSChanges,
31+ SambaList
32 };
33 virtual void run() = 0;
34 RequestType type() const;
35
36=== added file 'src/plugin/folderlistmodel/smb/qsambaclient/src/smblocationdiriterator.cpp'
37--- src/plugin/folderlistmodel/smb/qsambaclient/src/smblocationdiriterator.cpp 1970-01-01 00:00:00 +0000
38+++ src/plugin/folderlistmodel/smb/qsambaclient/src/smblocationdiriterator.cpp 2015-04-29 22:35:22 +0000
39@@ -0,0 +1,136 @@
40+/**************************************************************************
41+ *
42+ * Copyright 2015 Canonical Ltd.
43+ * Copyright 2015 Carlos J Mazieri <carlos.mazieri@gmail.com>
44+ *
45+ * This program is free software; you can redistribute it and/or modify
46+ * it under the terms of the GNU Lesser General Public License as published by
47+ * the Free Software Foundation; version 3.
48+ *
49+ * This program is distributed in the hope that it will be useful,
50+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
51+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
52+ * GNU Lesser General Public License for more details.
53+ *
54+ * You should have received a copy of the GNU Lesser General Public License
55+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
56+ *
57+ * File: smblocationdiriterator.cpp
58+ * Date: 10/01/2015
59+ */
60+
61+#include "smblocationdiriterator.h"
62+#include "smbiteminfo.h"
63+#include "smbutil.h"
64+
65+#define INIT_ATTR(path,smb) SmbObject(path,smb), m_curItem(-1)
66+
67+#define GOOD_INDEX() (m_curItem >= 0 && m_curItem < m_urlItems.count())
68+
69+
70+SmbLocationDirIterator::SmbLocationDirIterator(const QString &path,
71+ const QStringList &nameFilters,
72+ QDir::Filters filters,
73+ QDirIterator::IteratorFlags flags,
74+ Const_SmbUtil_Ptr smb)
75+ : LocationItemDirIterator(path, nameFilters, filters, flags)
76+ , INIT_ATTR(path, smb)
77+{
78+ bool recursive = flags == QDirIterator::Subdirectories ? true : false;
79+ m_urlItems = smbObj()->listContent(path, recursive, filters, nameFilters);
80+}
81+
82+
83+SmbLocationDirIterator::SmbLocationDirIterator(const QString &path,
84+ QDir::Filters filters,
85+ QDirIterator::IteratorFlags flags,
86+ Const_SmbUtil_Ptr smb)
87+ : LocationItemDirIterator(path,filters,flags)
88+ , INIT_ATTR(path, smb)
89+{
90+ bool recursive = flags == QDirIterator::Subdirectories ? true : false;
91+ m_urlItems = smbObj()->listContent(path, recursive, filters);
92+}
93+
94+
95+SmbLocationDirIterator::SmbLocationDirIterator(const QString &path,
96+ QDirIterator::IteratorFlags flags,
97+ Const_SmbUtil_Ptr smb)
98+ : LocationItemDirIterator(path,flags)
99+ , INIT_ATTR(path, smb)
100+{
101+ bool recursive = flags == QDirIterator::Subdirectories ? true : false;
102+ m_urlItems = smbObj()->listContent(path, recursive);
103+}
104+
105+
106+SmbLocationDirIterator::~SmbLocationDirIterator()
107+{
108+
109+}
110+
111+
112+QString SmbLocationDirIterator::next()
113+{
114+ QString ret;
115+ if (hasNext())
116+ {
117+ ret = m_urlItems.at(++m_curItem);
118+ }
119+ return ret;
120+}
121+
122+
123+bool SmbLocationDirIterator::hasNext() const
124+{
125+ return m_urlItems.count() > 0 && m_curItem < (m_urlItems.count() -1);
126+}
127+
128+
129+DirItemInfo SmbLocationDirIterator::fileInfo() const
130+{
131+ if (GOOD_INDEX())
132+ {
133+ SmbItemInfo info(m_urlItems.at(m_curItem), m_smb);
134+ return info;
135+ }
136+ return SmbItemInfo();
137+}
138+
139+
140+QString SmbLocationDirIterator::fileName() const
141+{
142+ QString file;
143+ if (GOOD_INDEX())
144+ {
145+ QStringList paths = UrlItemInfo::separatePathFilename(m_urlItems.at(m_curItem));
146+ if (paths.count() == 2)
147+ {
148+ file = paths.at(1);
149+ }
150+ }
151+ return file;
152+}
153+
154+
155+QString SmbLocationDirIterator::path() const
156+{
157+ QString ret;
158+ QStringList separated = UrlItemInfo::separatePathFilename(cleanUrl());
159+ if (separated.count() > 0)
160+ {
161+ ret = separated.at(0);
162+ }
163+ return ret;
164+}
165+
166+
167+QString SmbLocationDirIterator::filePath() const
168+{
169+ QString fullpathname;
170+ if (GOOD_INDEX())
171+ {
172+ fullpathname = m_urlItems.at(m_curItem);
173+ }
174+ return fullpathname;
175+}
176
177=== added file 'src/plugin/folderlistmodel/smb/qsambaclient/src/smblocationdiriterator.h'
178--- src/plugin/folderlistmodel/smb/qsambaclient/src/smblocationdiriterator.h 1970-01-01 00:00:00 +0000
179+++ src/plugin/folderlistmodel/smb/qsambaclient/src/smblocationdiriterator.h 2015-04-29 22:35:22 +0000
180@@ -0,0 +1,48 @@
181+/**************************************************************************
182+ *
183+ * Copyright 2015 Canonical Ltd.
184+ * Copyright 2015 Carlos J Mazieri <carlos.mazieri@gmail.com>
185+ *
186+ * This program is free software; you can redistribute it and/or modify
187+ * it under the terms of the GNU Lesser General Public License as published by
188+ * the Free Software Foundation; version 3.
189+ *
190+ * This program is distributed in the hope that it will be useful,
191+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
192+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
193+ * GNU Lesser General Public License for more details.
194+ *
195+ * You should have received a copy of the GNU Lesser General Public License
196+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
197+ *
198+ * File: smblocationdiriterator.h
199+ * Date: 10/01/2015
200+ */
201+
202+#ifndef SMBLOCATIONDIRITERATOR_H
203+#define SMBLOCATIONDIRITERATOR_H
204+
205+#include "locationitemdiriterator.h"
206+#include "smbobject.h"
207+
208+class SmbLocationDirIterator: public LocationItemDirIterator, public SmbObject
209+{
210+public:
211+ ~SmbLocationDirIterator();
212+public:
213+ virtual DirItemInfo fileInfo() const;
214+ virtual QString fileName() const;
215+ virtual QString filePath() const;
216+ virtual bool hasNext() const;
217+ virtual QString next() ;
218+ virtual QString path() const;
219+public:
220+ SmbLocationDirIterator(const QString & path, QDirIterator::IteratorFlags flags = QDirIterator::NoIteratorFlags, Const_SmbUtil_Ptr smb = 0);
221+ SmbLocationDirIterator(const QString & path, QDir::Filters filters, QDirIterator::IteratorFlags flags = QDirIterator::NoIteratorFlags, Const_SmbUtil_Ptr smb = 0);
222+ SmbLocationDirIterator(const QString & path, const QStringList & nameFilters, QDir::Filters filters = QDir::NoFilter, QDirIterator::IteratorFlags flags = QDirIterator::NoIteratorFlags, Const_SmbUtil_Ptr smb = 0);
223+private:
224+ QStringList m_urlItems;
225+ int m_curItem;
226+};
227+
228+#endif // SMBLOCATIONDIRITERATOR_H
229
230=== added file 'src/plugin/folderlistmodel/smb/smblistworker.cpp'
231--- src/plugin/folderlistmodel/smb/smblistworker.cpp 1970-01-01 00:00:00 +0000
232+++ src/plugin/folderlistmodel/smb/smblistworker.cpp 2015-04-29 22:35:22 +0000
233@@ -0,0 +1,63 @@
234+/**************************************************************************
235+ *
236+ * Copyright 2015 Canonical Ltd.
237+ * Copyright 2015 Carlos J Mazieri <carlos.mazieri@gmail.com>
238+ *
239+ * This program is free software; you can redistribute it and/or modify
240+ * it under the terms of the GNU Lesser General Public License as published by
241+ * the Free Software Foundation; version 3.
242+ *
243+ * This program is distributed in the hope that it will be useful,
244+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
245+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
246+ * GNU Lesser General Public License for more details.
247+ *
248+ * You should have received a copy of the GNU Lesser General Public License
249+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
250+ *
251+ * File: smblistworker.cpp
252+ * Date: 17/01/2015
253+ */
254+
255+#include "smblistworker.h"
256+#include "smblocationdiriterator.h"
257+
258+SmbListWorker::SmbListWorker(const QString &pathName,
259+ QDir::Filter filter,
260+ const bool isRecursive,
261+ bool parentIsHost,
262+ Const_SmbUtil_Ptr smb)
263+ : DirListWorker(pathName, filter, isRecursive)
264+ , SmbObject(pathName, smb)
265+ , m_parentIsHost(parentIsHost)
266+{
267+ mLoaderType = NetworkLoader;
268+}
269+
270+/*!
271+ * \brief SmbListWorker::getNetworkContent() it fills a \ref DirItemInfoList with samba (share/directory) content
272+ * \return the list of \ref SmbItemInfo items
273+ */
274+DirItemInfoList SmbListWorker::getNetworkContent()
275+{
276+ DirItemInfoList smbContent;
277+
278+ QDirIterator::IteratorFlags flags = mIsRecursive ?
279+ QDirIterator::Subdirectories :
280+ QDirIterator::NoIteratorFlags;
281+
282+ SmbLocationDirIterator dir(mPathName, mFilter, flags, m_smb);
283+ while (dir.hasNext())
284+ {
285+ QString next = dir.next();
286+ SmbItemInfo item (next, m_smb);
287+ if (m_parentIsHost)
288+ {
289+ item.setAsShare();
290+ }
291+ smbContent.append(item);
292+ }
293+
294+ return smbContent;
295+}
296+
297
298=== added file 'src/plugin/folderlistmodel/smb/smblistworker.h'
299--- src/plugin/folderlistmodel/smb/smblistworker.h 1970-01-01 00:00:00 +0000
300+++ src/plugin/folderlistmodel/smb/smblistworker.h 2015-04-29 22:35:22 +0000
301@@ -0,0 +1,40 @@
302+/**************************************************************************
303+ *
304+ * Copyright 2015 Canonical Ltd.
305+ * Copyright 2015 Carlos J Mazieri <carlos.mazieri@gmail.com>
306+ *
307+ * This program is free software; you can redistribute it and/or modify
308+ * it under the terms of the GNU Lesser General Public License as published by
309+ * the Free Software Foundation; version 3.
310+ *
311+ * This program is distributed in the hope that it will be useful,
312+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
313+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
314+ * GNU Lesser General Public License for more details.
315+ *
316+ * You should have received a copy of the GNU Lesser General Public License
317+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
318+ *
319+ * File: smblistworker.h
320+ * Date: 17/01/2015
321+ */
322+
323+#ifndef SMBLISTWORKER_H
324+#define SMBLISTWORKER_H
325+
326+#include "iorequestworker.h"
327+#include "smbiteminfo.h"
328+
329+class SmbListWorker : public DirListWorker, public SmbObject
330+{
331+ Q_OBJECT
332+public:
333+ explicit SmbListWorker(const QString &pathName, QDir::Filter filter, const bool isRecursive, bool parentIsHost, Const_SmbUtil_Ptr smb);
334+
335+private:
336+ DirItemInfoList getNetworkContent();
337+private:
338+ bool m_parentIsHost;
339+};
340+
341+#endif // SMBLISTWORKER_H

Subscribers

People subscribed via source and target branches