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
=== modified file 'import/Ubuntu/Content/contenthub.cpp'
--- import/Ubuntu/Content/contenthub.cpp 2014-08-05 20:03:08 +0000
+++ import/Ubuntu/Content/contenthub.cpp 2015-08-21 14:49:49 +0000
@@ -15,6 +15,7 @@
15 */15 */
1616
17#include "../../../src/com/ubuntu/content/debug.h"17#include "../../../src/com/ubuntu/content/debug.h"
18#include "../../../src/com/ubuntu/content/utils.cpp"
18#include "contenthub.h"19#include "contenthub.h"
19#include "contentpeer.h"20#include "contentpeer.h"
20#include "contentstore.h"21#include "contentstore.h"
@@ -122,6 +123,9 @@
122 m_hub = cuc::Hub::Client::instance();123 m_hub = cuc::Hub::Client::instance();
123 m_handler = new QmlImportExportHandler(this);124 m_handler = new QmlImportExportHandler(this);
124 m_hub->register_import_export_handler(m_handler);125 m_hub->register_import_export_handler(m_handler);
126 QString id = app_id();
127 if (!id.isEmpty())
128 m_hasPending = m_hub->has_pending(id);
125129
126 connect(m_handler, SIGNAL(importRequested(com::ubuntu::content::Transfer*)),130 connect(m_handler, SIGNAL(importRequested(com::ubuntu::content::Transfer*)),
127 this, SLOT(handleImport(com::ubuntu::content::Transfer*)));131 this, SLOT(handleImport(com::ubuntu::content::Transfer*)));
@@ -301,6 +305,17 @@
301}305}
302306
303/*!307/*!
308 * \qmlproperty bool ContentHub::hasPending
309 * True if there is a pending transfer for the handler
310 * \internal
311 */
312bool ContentHub::hasPending()
313{
314 TRACE() << Q_FUNC_INFO;
315 return m_hasPending;
316}
317
318/*!
304 * \qmlsignal ContentHub::importRequested(ContentTransfer transfer)319 * \qmlsignal ContentHub::importRequested(ContentTransfer transfer)
305 *320 *
306 * The signal is triggered when an import is requested.321 * The signal is triggered when an import is requested.
307322
=== modified file 'import/Ubuntu/Content/contenthub.h'
--- import/Ubuntu/Content/contenthub.h 2014-08-04 17:57:26 +0000
+++ import/Ubuntu/Content/contenthub.h 2015-08-21 14:49:49 +0000
@@ -43,6 +43,7 @@
43{43{
44 Q_OBJECT44 Q_OBJECT
45 Q_PROPERTY(QQmlListProperty<ContentTransfer> finishedImports READ finishedImports NOTIFY finishedImportsChanged)45 Q_PROPERTY(QQmlListProperty<ContentTransfer> finishedImports READ finishedImports NOTIFY finishedImportsChanged)
46 Q_PROPERTY(bool hasPending READ hasPending)
4647
47public:48public:
48 ContentHub(const ContentHub&) = delete;49 ContentHub(const ContentHub&) = delete;
@@ -52,6 +53,7 @@
52 Q_INVOKABLE void restoreImports();53 Q_INVOKABLE void restoreImports();
5354
54 QQmlListProperty<ContentTransfer> finishedImports();55 QQmlListProperty<ContentTransfer> finishedImports();
56 bool hasPending();
5557
56 Q_INVOKABLE ContentTransfer* importContent(com::ubuntu::content::Peer peer, ContentType::Type type);58 Q_INVOKABLE ContentTransfer* importContent(com::ubuntu::content::Peer peer, ContentType::Type type);
57 Q_INVOKABLE ContentTransfer* exportContent(com::ubuntu::content::Peer peer, ContentType::Type type);59 Q_INVOKABLE ContentTransfer* exportContent(com::ubuntu::content::Peer peer, ContentType::Type type);
@@ -75,6 +77,7 @@
75 QHash<com::ubuntu::content::Transfer *, ContentTransfer *> m_activeImports;77 QHash<com::ubuntu::content::Transfer *, ContentTransfer *> m_activeImports;
76 com::ubuntu::content::Hub *m_hub;78 com::ubuntu::content::Hub *m_hub;
77 QmlImportExportHandler *m_handler;79 QmlImportExportHandler *m_handler;
80 bool m_hasPending = false;
7881
79protected:82protected:
80 ContentHub(QObject* = nullptr);83 ContentHub(QObject* = nullptr);
8184
=== modified file 'include/com/ubuntu/content/hub.h'
--- include/com/ubuntu/content/hub.h 2014-08-04 17:56:09 +0000
+++ include/com/ubuntu/content/hub.h 2015-08-21 14:49:49 +0000
@@ -64,6 +64,7 @@
64 Q_INVOKABLE virtual Transfer* create_import_from_peer_for_type(Peer peer, Type type);64 Q_INVOKABLE virtual Transfer* create_import_from_peer_for_type(Peer peer, Type type);
65 Q_INVOKABLE virtual Transfer* create_export_to_peer_for_type(Peer peer, Type type);65 Q_INVOKABLE virtual Transfer* create_export_to_peer_for_type(Peer peer, Type type);
66 Q_INVOKABLE virtual Transfer* create_share_to_peer_for_type(Peer peer, Type type);66 Q_INVOKABLE virtual Transfer* create_share_to_peer_for_type(Peer peer, Type type);
67 Q_INVOKABLE virtual bool has_pending(QString peer_id);
67 68
68 protected:69 protected:
69 Hub(QObject* = nullptr);70 Hub(QObject* = nullptr);
7071
=== modified file 'src/com/ubuntu/content/detail/com.ubuntu.content.Service.xml'
--- src/com/ubuntu/content/detail/com.ubuntu.content.Service.xml 2014-08-04 17:56:09 +0000
+++ src/com/ubuntu/content/detail/com.ubuntu.content.Service.xml 2015-08-21 14:49:49 +0000
@@ -43,5 +43,9 @@
43 <method name="HandlerActive">43 <method name="HandlerActive">
44 <arg name="peer_id" type="s" direction="in" />44 <arg name="peer_id" type="s" direction="in" />
45 </method>45 </method>
46 <method name="HasPending">
47 <arg name="peer_id" type="s" direction="in" />
48 <arg name="pending" type="b" direction="out" />
49 </method>
46 </interface>50 </interface>
47</node>51</node>
4852
=== modified file 'src/com/ubuntu/content/detail/service.cpp'
--- src/com/ubuntu/content/detail/service.cpp 2015-05-27 15:30:31 +0000
+++ src/com/ubuntu/content/detail/service.cpp 2015-08-21 14:49:49 +0000
@@ -598,3 +598,18 @@
598 }598 }
599 }599 }
600}600}
601
602bool cucd::Service::HasPending(const QString& peer_id)
603{
604 TRACE() << Q_FUNC_INFO << peer_id;
605 Q_FOREACH (cucd::Transfer *t, d->active_transfers)
606 {
607 TRACE() << Q_FUNC_INFO << "SOURCE: " << t->source() << "DEST:" << t->destination() << "STATE:" << t->State();
608 if (((t->source() == peer_id) || (t->destination() == peer_id)) && (t->State() == cuc::Transfer::initiated))
609 {
610 TRACE() << Q_FUNC_INFO << "Has pending:" << peer_id;
611 return true;
612 }
613 }
614 return false;
615}
601616
=== modified file 'src/com/ubuntu/content/detail/service.h'
--- src/com/ubuntu/content/detail/service.h 2015-05-27 15:30:31 +0000
+++ src/com/ubuntu/content/detail/service.h 2015-08-21 14:49:49 +0000
@@ -66,6 +66,7 @@
66 void HandlerActive(const QString&);66 void HandlerActive(const QString&);
67 void Quit();67 void Quit();
68 void DownloadManagerError(QString);68 void DownloadManagerError(QString);
69 bool HasPending(const QString&);
6970
70 private:71 private:
71 bool should_cancel(int);72 bool should_cancel(int);
7273
=== modified file 'src/com/ubuntu/content/hub.cpp'
--- src/com/ubuntu/content/hub.cpp 2014-08-04 17:56:09 +0000
+++ src/com/ubuntu/content/hub.cpp 2015-08-21 14:49:49 +0000
@@ -299,3 +299,14 @@
299{299{
300 d->service->Quit();300 d->service->Quit();
301}301}
302
303bool cuc::Hub::has_pending(QString peer_id)
304{
305 auto reply = d->service->HasPending(peer_id);
306 reply.waitForFinished();
307
308 if (reply.isError())
309 return false;
310
311 return reply.value();
312}
302313
=== modified file 'tests/acceptance-tests/app_hub_communication_transfer.cpp'
--- tests/acceptance-tests/app_hub_communication_transfer.cpp 2015-04-03 18:23:12 +0000
+++ tests/acceptance-tests/app_hub_communication_transfer.cpp 2015-08-21 14:49:49 +0000
@@ -152,11 +152,13 @@
152 hub->default_source_for_type(cuc::Type::Known::pictures()));152 hub->default_source_for_type(cuc::Type::Known::pictures()));
153 ASSERT_TRUE(transfer != nullptr);153 ASSERT_TRUE(transfer != nullptr);
154 EXPECT_EQ(cuc::Transfer::created, transfer->state());154 EXPECT_EQ(cuc::Transfer::created, transfer->state());
155 ASSERT_FALSE(hub->has_pending(transfer->destination()));
155 EXPECT_TRUE(transfer->setSelectionType(cuc::Transfer::SelectionType::multiple));156 EXPECT_TRUE(transfer->setSelectionType(cuc::Transfer::SelectionType::multiple));
156 ASSERT_EQ(cuc::Transfer::SelectionType::multiple, transfer->selectionType());157 ASSERT_EQ(cuc::Transfer::SelectionType::multiple, transfer->selectionType());
157 transfer->setStore(new cuc::Store{store_dir.path()});158 transfer->setStore(new cuc::Store{store_dir.path()});
158 EXPECT_TRUE(transfer->start());159 EXPECT_TRUE(transfer->start());
159 EXPECT_EQ(cuc::Transfer::initiated, transfer->state());160 EXPECT_EQ(cuc::Transfer::initiated, transfer->state());
161 ASSERT_TRUE(hub->has_pending(transfer->destination()));
160 EXPECT_TRUE(transfer->setSelectionType(cuc::Transfer::SelectionType::single));162 EXPECT_TRUE(transfer->setSelectionType(cuc::Transfer::SelectionType::single));
161 ASSERT_EQ(cuc::Transfer::SelectionType::multiple, transfer->selectionType());163 ASSERT_EQ(cuc::Transfer::SelectionType::multiple, transfer->selectionType());
162 EXPECT_TRUE(transfer->charge(source_items));164 EXPECT_TRUE(transfer->charge(source_items));

Subscribers

People subscribed via source and target branches