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
=== modified file 'src/plugin/folderlistmodel/CMakeLists.txt'
--- src/plugin/folderlistmodel/CMakeLists.txt 2015-03-14 17:38:50 +0000
+++ src/plugin/folderlistmodel/CMakeLists.txt 2015-04-29 22:35:22 +0000
@@ -58,11 +58,15 @@
58 trash/trashiteminfo.cpp58 trash/trashiteminfo.cpp
59 trash/trashiteminfo.h59 trash/trashiteminfo.h
60 trash/trashlocation.cpp60 trash/trashlocation.cpp
61 trash/trashlocation.h 61 trash/trashlocation.h
62 smb/smblistworker.cpp
63 smb/smblistworker.h
62 smb/qsambaclient/src/smbutil.cpp64 smb/qsambaclient/src/smbutil.cpp
63 smb/qsambaclient/src/smbutil.h65 smb/qsambaclient/src/smbutil.h
64 smb/qsambaclient/src/smbiteminfo.cpp66 smb/qsambaclient/src/smbiteminfo.cpp
65 smb/qsambaclient/src/smbiteminfo.h67 smb/qsambaclient/src/smbiteminfo.h
68 smb/qsambaclient/src/smblocationdiriterator.cpp
69 smb/qsambaclient/src/smblocationdiriterator.h
66 smb/qsambaclient/src/smbobject.cpp70 smb/qsambaclient/src/smbobject.cpp
67 smb/qsambaclient/src/smbobject.h71 smb/qsambaclient/src/smbobject.h
68 net/netauthenticationdata.cpp72 net/netauthenticationdata.cpp
6973
=== modified file 'src/plugin/folderlistmodel/iorequest.h'
--- src/plugin/folderlistmodel/iorequest.h 2015-03-01 15:32:42 +0000
+++ src/plugin/folderlistmodel/iorequest.h 2015-04-29 22:35:22 +0000
@@ -48,7 +48,8 @@
48 enum RequestType48 enum RequestType
49 {49 {
50 DirList,50 DirList,
51 DirListExternalFSChanges51 DirListExternalFSChanges,
52 SambaList
52 };53 };
53 virtual void run() = 0;54 virtual void run() = 0;
54 RequestType type() const;55 RequestType type() const;
5556
=== added file 'src/plugin/folderlistmodel/smb/qsambaclient/src/smblocationdiriterator.cpp'
--- src/plugin/folderlistmodel/smb/qsambaclient/src/smblocationdiriterator.cpp 1970-01-01 00:00:00 +0000
+++ src/plugin/folderlistmodel/smb/qsambaclient/src/smblocationdiriterator.cpp 2015-04-29 22:35:22 +0000
@@ -0,0 +1,136 @@
1/**************************************************************************
2 *
3 * Copyright 2015 Canonical Ltd.
4 * Copyright 2015 Carlos J Mazieri <carlos.mazieri@gmail.com>
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU Lesser General Public License as published by
8 * the Free Software Foundation; version 3.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU Lesser General Public License for more details.
14 *
15 * You should have received a copy of the GNU Lesser General Public License
16 * along with this program. If not, see <http://www.gnu.org/licenses/>.
17 *
18 * File: smblocationdiriterator.cpp
19 * Date: 10/01/2015
20 */
21
22#include "smblocationdiriterator.h"
23#include "smbiteminfo.h"
24#include "smbutil.h"
25
26#define INIT_ATTR(path,smb) SmbObject(path,smb), m_curItem(-1)
27
28#define GOOD_INDEX() (m_curItem >= 0 && m_curItem < m_urlItems.count())
29
30
31SmbLocationDirIterator::SmbLocationDirIterator(const QString &path,
32 const QStringList &nameFilters,
33 QDir::Filters filters,
34 QDirIterator::IteratorFlags flags,
35 Const_SmbUtil_Ptr smb)
36 : LocationItemDirIterator(path, nameFilters, filters, flags)
37 , INIT_ATTR(path, smb)
38{
39 bool recursive = flags == QDirIterator::Subdirectories ? true : false;
40 m_urlItems = smbObj()->listContent(path, recursive, filters, nameFilters);
41}
42
43
44SmbLocationDirIterator::SmbLocationDirIterator(const QString &path,
45 QDir::Filters filters,
46 QDirIterator::IteratorFlags flags,
47 Const_SmbUtil_Ptr smb)
48 : LocationItemDirIterator(path,filters,flags)
49 , INIT_ATTR(path, smb)
50{
51 bool recursive = flags == QDirIterator::Subdirectories ? true : false;
52 m_urlItems = smbObj()->listContent(path, recursive, filters);
53}
54
55
56SmbLocationDirIterator::SmbLocationDirIterator(const QString &path,
57 QDirIterator::IteratorFlags flags,
58 Const_SmbUtil_Ptr smb)
59 : LocationItemDirIterator(path,flags)
60 , INIT_ATTR(path, smb)
61{
62 bool recursive = flags == QDirIterator::Subdirectories ? true : false;
63 m_urlItems = smbObj()->listContent(path, recursive);
64}
65
66
67SmbLocationDirIterator::~SmbLocationDirIterator()
68{
69
70}
71
72
73QString SmbLocationDirIterator::next()
74{
75 QString ret;
76 if (hasNext())
77 {
78 ret = m_urlItems.at(++m_curItem);
79 }
80 return ret;
81}
82
83
84bool SmbLocationDirIterator::hasNext() const
85{
86 return m_urlItems.count() > 0 && m_curItem < (m_urlItems.count() -1);
87}
88
89
90DirItemInfo SmbLocationDirIterator::fileInfo() const
91{
92 if (GOOD_INDEX())
93 {
94 SmbItemInfo info(m_urlItems.at(m_curItem), m_smb);
95 return info;
96 }
97 return SmbItemInfo();
98}
99
100
101QString SmbLocationDirIterator::fileName() const
102{
103 QString file;
104 if (GOOD_INDEX())
105 {
106 QStringList paths = UrlItemInfo::separatePathFilename(m_urlItems.at(m_curItem));
107 if (paths.count() == 2)
108 {
109 file = paths.at(1);
110 }
111 }
112 return file;
113}
114
115
116QString SmbLocationDirIterator::path() const
117{
118 QString ret;
119 QStringList separated = UrlItemInfo::separatePathFilename(cleanUrl());
120 if (separated.count() > 0)
121 {
122 ret = separated.at(0);
123 }
124 return ret;
125}
126
127
128QString SmbLocationDirIterator::filePath() const
129{
130 QString fullpathname;
131 if (GOOD_INDEX())
132 {
133 fullpathname = m_urlItems.at(m_curItem);
134 }
135 return fullpathname;
136}
0137
=== added file 'src/plugin/folderlistmodel/smb/qsambaclient/src/smblocationdiriterator.h'
--- src/plugin/folderlistmodel/smb/qsambaclient/src/smblocationdiriterator.h 1970-01-01 00:00:00 +0000
+++ src/plugin/folderlistmodel/smb/qsambaclient/src/smblocationdiriterator.h 2015-04-29 22:35:22 +0000
@@ -0,0 +1,48 @@
1/**************************************************************************
2 *
3 * Copyright 2015 Canonical Ltd.
4 * Copyright 2015 Carlos J Mazieri <carlos.mazieri@gmail.com>
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU Lesser General Public License as published by
8 * the Free Software Foundation; version 3.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU Lesser General Public License for more details.
14 *
15 * You should have received a copy of the GNU Lesser General Public License
16 * along with this program. If not, see <http://www.gnu.org/licenses/>.
17 *
18 * File: smblocationdiriterator.h
19 * Date: 10/01/2015
20 */
21
22#ifndef SMBLOCATIONDIRITERATOR_H
23#define SMBLOCATIONDIRITERATOR_H
24
25#include "locationitemdiriterator.h"
26#include "smbobject.h"
27
28class SmbLocationDirIterator: public LocationItemDirIterator, public SmbObject
29{
30public:
31 ~SmbLocationDirIterator();
32public:
33 virtual DirItemInfo fileInfo() const;
34 virtual QString fileName() const;
35 virtual QString filePath() const;
36 virtual bool hasNext() const;
37 virtual QString next() ;
38 virtual QString path() const;
39public:
40 SmbLocationDirIterator(const QString & path, QDirIterator::IteratorFlags flags = QDirIterator::NoIteratorFlags, Const_SmbUtil_Ptr smb = 0);
41 SmbLocationDirIterator(const QString & path, QDir::Filters filters, QDirIterator::IteratorFlags flags = QDirIterator::NoIteratorFlags, Const_SmbUtil_Ptr smb = 0);
42 SmbLocationDirIterator(const QString & path, const QStringList & nameFilters, QDir::Filters filters = QDir::NoFilter, QDirIterator::IteratorFlags flags = QDirIterator::NoIteratorFlags, Const_SmbUtil_Ptr smb = 0);
43private:
44 QStringList m_urlItems;
45 int m_curItem;
46};
47
48#endif // SMBLOCATIONDIRITERATOR_H
049
=== added file 'src/plugin/folderlistmodel/smb/smblistworker.cpp'
--- src/plugin/folderlistmodel/smb/smblistworker.cpp 1970-01-01 00:00:00 +0000
+++ src/plugin/folderlistmodel/smb/smblistworker.cpp 2015-04-29 22:35:22 +0000
@@ -0,0 +1,63 @@
1/**************************************************************************
2 *
3 * Copyright 2015 Canonical Ltd.
4 * Copyright 2015 Carlos J Mazieri <carlos.mazieri@gmail.com>
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU Lesser General Public License as published by
8 * the Free Software Foundation; version 3.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU Lesser General Public License for more details.
14 *
15 * You should have received a copy of the GNU Lesser General Public License
16 * along with this program. If not, see <http://www.gnu.org/licenses/>.
17 *
18 * File: smblistworker.cpp
19 * Date: 17/01/2015
20 */
21
22#include "smblistworker.h"
23#include "smblocationdiriterator.h"
24
25SmbListWorker::SmbListWorker(const QString &pathName,
26 QDir::Filter filter,
27 const bool isRecursive,
28 bool parentIsHost,
29 Const_SmbUtil_Ptr smb)
30 : DirListWorker(pathName, filter, isRecursive)
31 , SmbObject(pathName, smb)
32 , m_parentIsHost(parentIsHost)
33{
34 mLoaderType = NetworkLoader;
35}
36
37/*!
38 * \brief SmbListWorker::getNetworkContent() it fills a \ref DirItemInfoList with samba (share/directory) content
39 * \return the list of \ref SmbItemInfo items
40 */
41DirItemInfoList SmbListWorker::getNetworkContent()
42{
43 DirItemInfoList smbContent;
44
45 QDirIterator::IteratorFlags flags = mIsRecursive ?
46 QDirIterator::Subdirectories :
47 QDirIterator::NoIteratorFlags;
48
49 SmbLocationDirIterator dir(mPathName, mFilter, flags, m_smb);
50 while (dir.hasNext())
51 {
52 QString next = dir.next();
53 SmbItemInfo item (next, m_smb);
54 if (m_parentIsHost)
55 {
56 item.setAsShare();
57 }
58 smbContent.append(item);
59 }
60
61 return smbContent;
62}
63
064
=== added file 'src/plugin/folderlistmodel/smb/smblistworker.h'
--- src/plugin/folderlistmodel/smb/smblistworker.h 1970-01-01 00:00:00 +0000
+++ src/plugin/folderlistmodel/smb/smblistworker.h 2015-04-29 22:35:22 +0000
@@ -0,0 +1,40 @@
1/**************************************************************************
2 *
3 * Copyright 2015 Canonical Ltd.
4 * Copyright 2015 Carlos J Mazieri <carlos.mazieri@gmail.com>
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU Lesser General Public License as published by
8 * the Free Software Foundation; version 3.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU Lesser General Public License for more details.
14 *
15 * You should have received a copy of the GNU Lesser General Public License
16 * along with this program. If not, see <http://www.gnu.org/licenses/>.
17 *
18 * File: smblistworker.h
19 * Date: 17/01/2015
20 */
21
22#ifndef SMBLISTWORKER_H
23#define SMBLISTWORKER_H
24
25#include "iorequestworker.h"
26#include "smbiteminfo.h"
27
28class SmbListWorker : public DirListWorker, public SmbObject
29{
30 Q_OBJECT
31public:
32 explicit SmbListWorker(const QString &pathName, QDir::Filter filter, const bool isRecursive, bool parentIsHost, Const_SmbUtil_Ptr smb);
33
34private:
35 DirItemInfoList getNetworkContent();
36private:
37 bool m_parentIsHost;
38};
39
40#endif // SMBLISTWORKER_H

Subscribers

People subscribed via source and target branches