Merge lp:~ken-vandine/content-hub/has_pending into lp:content-hub

Proposed by Ken VanDine
Status: Merged
Approved by: Renato Araujo Oliveira Filho
Approved revision: 238
Merged at revision: 238
Proposed branch: lp:~ken-vandine/content-hub/has_pending
Merge into: lp:content-hub
Diff against target: 165 lines (+52/-0)
8 files modified
import/Ubuntu/Content/contenthub.cpp (+15/-0)
import/Ubuntu/Content/contenthub.h (+3/-0)
include/com/ubuntu/content/hub.h (+1/-0)
src/com/ubuntu/content/detail/com.ubuntu.content.Service.xml (+4/-0)
src/com/ubuntu/content/detail/service.cpp (+15/-0)
src/com/ubuntu/content/detail/service.h (+1/-0)
src/com/ubuntu/content/hub.cpp (+11/-0)
tests/acceptance-tests/app_hub_communication_transfer.cpp (+2/-0)
To merge this branch: bzr merge lp:~ken-vandine/content-hub/has_pending
Reviewer Review Type Date Requested Status
Michael Sheldon (community) Approve
Renato Araujo Oliveira Filho (community) Approve
PS Jenkins bot continuous-integration Approve
Review via email: mp+268618@code.launchpad.net

Commit message

added hasPending property on ContentHub

Description of the change

added hasPending property on ContentHub

To post a comment you must log in.
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
Revision history for this message
Renato Araujo Oliveira Filho (renatofilho) wrote :

works as expected.

review: Approve
239. By Ken VanDine

Added test for has_pending

Revision history for this message
Ken VanDine (ken-vandine) wrote :

Are there any related MPs required for this MP to build/function as expected? Please list.

 * No

Is your branch in sync with latest trunk (e.g. bzr pull lp:trunk -> no changes)

 * Yes

Did you perform an exploratory manual test run of your code change and any related functionality on device or emulator?

 * Yes

Did you successfully run all tests found in your component's Test Plan (https://wiki.ubuntu.com/Process/Merges/TestPlan/content-hub) on device or emulator?

 * Yes

If you changed the UI, was the change specified/approved by design?

 * No change

If you changed UI labels, did you update the pot file?

 * No change

If you changed the packaging (debian), did you add a core-dev as a reviewer to this MP?

 * No change

240. By Ken VanDine

added docstring for hasPending

241. By Ken VanDine

mark hasPending as internal

Revision history for this message
Michael Sheldon (michael-sheldon) wrote :

Did you perform an exploratory manual test run of the code change and any related functionality on device or emulator?

 * Yes, tested with modified addressbook-app and was able to see when there were pending transfers at start up

Did CI run pass? If not, please explain why.

 * Yes

Have you checked that submitter has accurately filled out the submitter checklist and has taken no shortcut?

 * Yes

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'import/Ubuntu/Content/contenthub.cpp'
2--- import/Ubuntu/Content/contenthub.cpp 2014-08-05 20:03:08 +0000
3+++ import/Ubuntu/Content/contenthub.cpp 2015-08-21 14:49:49 +0000
4@@ -15,6 +15,7 @@
5 */
6
7 #include "../../../src/com/ubuntu/content/debug.h"
8+#include "../../../src/com/ubuntu/content/utils.cpp"
9 #include "contenthub.h"
10 #include "contentpeer.h"
11 #include "contentstore.h"
12@@ -122,6 +123,9 @@
13 m_hub = cuc::Hub::Client::instance();
14 m_handler = new QmlImportExportHandler(this);
15 m_hub->register_import_export_handler(m_handler);
16+ QString id = app_id();
17+ if (!id.isEmpty())
18+ m_hasPending = m_hub->has_pending(id);
19
20 connect(m_handler, SIGNAL(importRequested(com::ubuntu::content::Transfer*)),
21 this, SLOT(handleImport(com::ubuntu::content::Transfer*)));
22@@ -301,6 +305,17 @@
23 }
24
25 /*!
26+ * \qmlproperty bool ContentHub::hasPending
27+ * True if there is a pending transfer for the handler
28+ * \internal
29+ */
30+bool ContentHub::hasPending()
31+{
32+ TRACE() << Q_FUNC_INFO;
33+ return m_hasPending;
34+}
35+
36+/*!
37 * \qmlsignal ContentHub::importRequested(ContentTransfer transfer)
38 *
39 * The signal is triggered when an import is requested.
40
41=== modified file 'import/Ubuntu/Content/contenthub.h'
42--- import/Ubuntu/Content/contenthub.h 2014-08-04 17:57:26 +0000
43+++ import/Ubuntu/Content/contenthub.h 2015-08-21 14:49:49 +0000
44@@ -43,6 +43,7 @@
45 {
46 Q_OBJECT
47 Q_PROPERTY(QQmlListProperty<ContentTransfer> finishedImports READ finishedImports NOTIFY finishedImportsChanged)
48+ Q_PROPERTY(bool hasPending READ hasPending)
49
50 public:
51 ContentHub(const ContentHub&) = delete;
52@@ -52,6 +53,7 @@
53 Q_INVOKABLE void restoreImports();
54
55 QQmlListProperty<ContentTransfer> finishedImports();
56+ bool hasPending();
57
58 Q_INVOKABLE ContentTransfer* importContent(com::ubuntu::content::Peer peer, ContentType::Type type);
59 Q_INVOKABLE ContentTransfer* exportContent(com::ubuntu::content::Peer peer, ContentType::Type type);
60@@ -75,6 +77,7 @@
61 QHash<com::ubuntu::content::Transfer *, ContentTransfer *> m_activeImports;
62 com::ubuntu::content::Hub *m_hub;
63 QmlImportExportHandler *m_handler;
64+ bool m_hasPending = false;
65
66 protected:
67 ContentHub(QObject* = nullptr);
68
69=== modified file 'include/com/ubuntu/content/hub.h'
70--- include/com/ubuntu/content/hub.h 2014-08-04 17:56:09 +0000
71+++ include/com/ubuntu/content/hub.h 2015-08-21 14:49:49 +0000
72@@ -64,6 +64,7 @@
73 Q_INVOKABLE virtual Transfer* create_import_from_peer_for_type(Peer peer, Type type);
74 Q_INVOKABLE virtual Transfer* create_export_to_peer_for_type(Peer peer, Type type);
75 Q_INVOKABLE virtual Transfer* create_share_to_peer_for_type(Peer peer, Type type);
76+ Q_INVOKABLE virtual bool has_pending(QString peer_id);
77
78 protected:
79 Hub(QObject* = nullptr);
80
81=== modified file 'src/com/ubuntu/content/detail/com.ubuntu.content.Service.xml'
82--- src/com/ubuntu/content/detail/com.ubuntu.content.Service.xml 2014-08-04 17:56:09 +0000
83+++ src/com/ubuntu/content/detail/com.ubuntu.content.Service.xml 2015-08-21 14:49:49 +0000
84@@ -43,5 +43,9 @@
85 <method name="HandlerActive">
86 <arg name="peer_id" type="s" direction="in" />
87 </method>
88+ <method name="HasPending">
89+ <arg name="peer_id" type="s" direction="in" />
90+ <arg name="pending" type="b" direction="out" />
91+ </method>
92 </interface>
93 </node>
94
95=== modified file 'src/com/ubuntu/content/detail/service.cpp'
96--- src/com/ubuntu/content/detail/service.cpp 2015-05-27 15:30:31 +0000
97+++ src/com/ubuntu/content/detail/service.cpp 2015-08-21 14:49:49 +0000
98@@ -598,3 +598,18 @@
99 }
100 }
101 }
102+
103+bool cucd::Service::HasPending(const QString& peer_id)
104+{
105+ TRACE() << Q_FUNC_INFO << peer_id;
106+ Q_FOREACH (cucd::Transfer *t, d->active_transfers)
107+ {
108+ TRACE() << Q_FUNC_INFO << "SOURCE: " << t->source() << "DEST:" << t->destination() << "STATE:" << t->State();
109+ if (((t->source() == peer_id) || (t->destination() == peer_id)) && (t->State() == cuc::Transfer::initiated))
110+ {
111+ TRACE() << Q_FUNC_INFO << "Has pending:" << peer_id;
112+ return true;
113+ }
114+ }
115+ return false;
116+}
117
118=== modified file 'src/com/ubuntu/content/detail/service.h'
119--- src/com/ubuntu/content/detail/service.h 2015-05-27 15:30:31 +0000
120+++ src/com/ubuntu/content/detail/service.h 2015-08-21 14:49:49 +0000
121@@ -66,6 +66,7 @@
122 void HandlerActive(const QString&);
123 void Quit();
124 void DownloadManagerError(QString);
125+ bool HasPending(const QString&);
126
127 private:
128 bool should_cancel(int);
129
130=== modified file 'src/com/ubuntu/content/hub.cpp'
131--- src/com/ubuntu/content/hub.cpp 2014-08-04 17:56:09 +0000
132+++ src/com/ubuntu/content/hub.cpp 2015-08-21 14:49:49 +0000
133@@ -299,3 +299,14 @@
134 {
135 d->service->Quit();
136 }
137+
138+bool cuc::Hub::has_pending(QString peer_id)
139+{
140+ auto reply = d->service->HasPending(peer_id);
141+ reply.waitForFinished();
142+
143+ if (reply.isError())
144+ return false;
145+
146+ return reply.value();
147+}
148
149=== modified file 'tests/acceptance-tests/app_hub_communication_transfer.cpp'
150--- tests/acceptance-tests/app_hub_communication_transfer.cpp 2015-04-03 18:23:12 +0000
151+++ tests/acceptance-tests/app_hub_communication_transfer.cpp 2015-08-21 14:49:49 +0000
152@@ -152,11 +152,13 @@
153 hub->default_source_for_type(cuc::Type::Known::pictures()));
154 ASSERT_TRUE(transfer != nullptr);
155 EXPECT_EQ(cuc::Transfer::created, transfer->state());
156+ ASSERT_FALSE(hub->has_pending(transfer->destination()));
157 EXPECT_TRUE(transfer->setSelectionType(cuc::Transfer::SelectionType::multiple));
158 ASSERT_EQ(cuc::Transfer::SelectionType::multiple, transfer->selectionType());
159 transfer->setStore(new cuc::Store{store_dir.path()});
160 EXPECT_TRUE(transfer->start());
161 EXPECT_EQ(cuc::Transfer::initiated, transfer->state());
162+ ASSERT_TRUE(hub->has_pending(transfer->destination()));
163 EXPECT_TRUE(transfer->setSelectionType(cuc::Transfer::SelectionType::single));
164 ASSERT_EQ(cuc::Transfer::SelectionType::multiple, transfer->selectionType());
165 EXPECT_TRUE(transfer->charge(source_items));

Subscribers

People subscribed via source and target branches