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

Proposed by Ken VanDine
Status: Merged
Merged at revision: 314
Proposed branch: lp:~ken-vandine/content-hub/trust_session_wip
Merge into: lp:content-hub
Diff against target: 1425 lines (+1032/-9)
25 files modified
CMakeLists.txt (+4/-2)
debian/content-hub.install (+1/-0)
debian/control (+2/-0)
import/Ubuntu/Content/contenthub.h (+1/-0)
include/com/ubuntu/content/transfer.h (+4/-0)
src/CMakeLists.txt (+2/-1)
src/com/ubuntu/applicationmanager/application_manager.h (+14/-0)
src/com/ubuntu/content/CMakeLists.txt (+3/-0)
src/com/ubuntu/content/detail/app_manager.cpp (+29/-1)
src/com/ubuntu/content/detail/app_manager.h (+2/-0)
src/com/ubuntu/content/detail/com.ubuntu.content.Service.xml (+4/-0)
src/com/ubuntu/content/detail/com.ubuntu.content.Transfer.xml (+9/-0)
src/com/ubuntu/content/detail/mir-helper.cpp (+235/-0)
src/com/ubuntu/content/detail/mir-helper.h (+69/-0)
src/com/ubuntu/content/detail/service.cpp (+54/-4)
src/com/ubuntu/content/detail/service.h (+5/-1)
src/com/ubuntu/content/detail/transfer.cpp (+38/-0)
src/com/ubuntu/content/detail/transfer.h (+7/-0)
src/com/ubuntu/content/transfer.cpp (+10/-0)
src/com/ubuntu/content/transfer_p.h (+19/-0)
src/helper/CMakeLists.txt (+61/-0)
src/helper/exec-tool.c (+222/-0)
src/helper/exec-tool.cpp (+107/-0)
src/helper/mir-connection-demangler.c (+126/-0)
tests/acceptance-tests/app_manager_mock.h (+4/-0)
To merge this branch: bzr merge lp:~ken-vandine/content-hub/trust_session_wip
Reviewer Review Type Date Requested Status
system-apps-ci-bot continuous-integration Needs Fixing
PS Jenkins bot continuous-integration Needs Fixing
Ubuntu Phablet Team Pending
Review via email: mp+250843@code.launchpad.net

Description of the change

Just to get a CI run

To post a comment you must log in.
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :

FAILED: Continuous integration, rev:187
No commit message was specified in the merge proposal. Click on the following link and set the commit message (if you want a jenkins rebuild you need to trigger it yourself):
https://code.launchpad.net/~ken-vandine/content-hub/trust_session_wip/+merge/250843/+edit-commit-message

http://jenkins.qa.ubuntu.com/job/content-hub-ci/216/
Executed test runs:
    SUCCESS: http://jenkins.qa.ubuntu.com/job/content-hub-vivid-amd64-ci/12
    SUCCESS: http://jenkins.qa.ubuntu.com/job/content-hub-vivid-armhf-ci/12
        deb: http://jenkins.qa.ubuntu.com/job/content-hub-vivid-armhf-ci/12/artifact/work/output/*zip*/output.zip
    SUCCESS: http://jenkins.qa.ubuntu.com/job/content-hub-vivid-i386-ci/12

Click here to trigger a rebuild:
http://s-jenkins.ubuntu-ci:8080/job/content-hub-ci/216/rebuild

review: Needs Fixing (continuous-integration)
188. By Ken VanDine

Moved the session creation to the service

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :

FAILED: Continuous integration, rev:188
No commit message was specified in the merge proposal. Click on the following link and set the commit message (if you want a jenkins rebuild you need to trigger it yourself):
https://code.launchpad.net/~ken-vandine/content-hub/trust_session_wip/+merge/250843/+edit-commit-message

http://jenkins.qa.ubuntu.com/job/content-hub-ci/217/
Executed test runs:
    FAILURE: http://jenkins.qa.ubuntu.com/job/content-hub-vivid-amd64-ci/13/console
    FAILURE: http://jenkins.qa.ubuntu.com/job/content-hub-vivid-armhf-ci/13/console
    FAILURE: http://jenkins.qa.ubuntu.com/job/content-hub-vivid-i386-ci/13/console

Click here to trigger a rebuild:
http://s-jenkins.ubuntu-ci:8080/job/content-hub-ci/217/rebuild

review: Needs Fixing (continuous-integration)
189. By Ken VanDine

Fixed getting proper clientPid

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :

FAILED: Continuous integration, rev:189
No commit message was specified in the merge proposal. Click on the following link and set the commit message (if you want a jenkins rebuild you need to trigger it yourself):
https://code.launchpad.net/~ken-vandine/content-hub/trust_session_wip/+merge/250843/+edit-commit-message

http://jenkins.qa.ubuntu.com/job/content-hub-ci/218/
Executed test runs:
    FAILURE: http://jenkins.qa.ubuntu.com/job/content-hub-vivid-amd64-ci/14/console
    FAILURE: http://jenkins.qa.ubuntu.com/job/content-hub-vivid-armhf-ci/14/console
    FAILURE: http://jenkins.qa.ubuntu.com/job/content-hub-vivid-i386-ci/14/console

Click here to trigger a rebuild:
http://s-jenkins.ubuntu-ci:8080/job/content-hub-ci/218/rebuild

review: Needs Fixing (continuous-integration)
190. By Ken VanDine

fixed a crash on systems without Mir

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :

FAILED: Continuous integration, rev:190
No commit message was specified in the merge proposal. Click on the following link and set the commit message (if you want a jenkins rebuild you need to trigger it yourself):
https://code.launchpad.net/~ken-vandine/content-hub/trust_session_wip/+merge/250843/+edit-commit-message

http://jenkins.qa.ubuntu.com/job/content-hub-ci/219/
Executed test runs:
    SUCCESS: http://jenkins.qa.ubuntu.com/job/content-hub-vivid-amd64-ci/15
    SUCCESS: http://jenkins.qa.ubuntu.com/job/content-hub-vivid-armhf-ci/15
        deb: http://jenkins.qa.ubuntu.com/job/content-hub-vivid-armhf-ci/15/artifact/work/output/*zip*/output.zip
    SUCCESS: http://jenkins.qa.ubuntu.com/job/content-hub-vivid-i386-ci/15

Click here to trigger a rebuild:
http://s-jenkins.ubuntu-ci:8080/job/content-hub-ci/219/rebuild

review: Needs Fixing (continuous-integration)
191. By Ken VanDine

Re-implemetation of the exec-tool based on the one from pay-service

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :

FAILED: Continuous integration, rev:191
No commit message was specified in the merge proposal. Click on the following link and set the commit message (if you want a jenkins rebuild you need to trigger it yourself):
https://code.launchpad.net/~ken-vandine/content-hub/trust_session_wip/+merge/250843/+edit-commit-message

http://jenkins.qa.ubuntu.com/job/content-hub-ci/220/
Executed test runs:
    FAILURE: http://jenkins.qa.ubuntu.com/job/content-hub-vivid-amd64-ci/16/console
    FAILURE: http://jenkins.qa.ubuntu.com/job/content-hub-vivid-armhf-ci/16/console
    FAILURE: http://jenkins.qa.ubuntu.com/job/content-hub-vivid-i386-ci/16/console

Click here to trigger a rebuild:
http://s-jenkins.ubuntu-ci:8080/job/content-hub-ci/220/rebuild

review: Needs Fixing (continuous-integration)
192. By Ken VanDine

use mir-connection-demangler

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :

FAILED: Continuous integration, rev:192
No commit message was specified in the merge proposal. Click on the following link and set the commit message (if you want a jenkins rebuild you need to trigger it yourself):
https://code.launchpad.net/~ken-vandine/content-hub/trust_session_wip/+merge/250843/+edit-commit-message

http://jenkins.qa.ubuntu.com/job/content-hub-ci/221/
Executed test runs:
    FAILURE: http://jenkins.qa.ubuntu.com/job/content-hub-vivid-amd64-ci/17/console
    FAILURE: http://jenkins.qa.ubuntu.com/job/content-hub-vivid-armhf-ci/17/console
    FAILURE: http://jenkins.qa.ubuntu.com/job/content-hub-vivid-i386-ci/17/console

Click here to trigger a rebuild:
http://s-jenkins.ubuntu-ci:8080/job/content-hub-ci/221/rebuild

review: Needs Fixing (continuous-integration)
193. By Ken VanDine

fixed CONTENT_HUB_MIR_SOCKET env

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :

FAILED: Continuous integration, rev:193
No commit message was specified in the merge proposal. Click on the following link and set the commit message (if you want a jenkins rebuild you need to trigger it yourself):
https://code.launchpad.net/~ken-vandine/content-hub/trust_session_wip/+merge/250843/+edit-commit-message

http://jenkins.qa.ubuntu.com/job/content-hub-ci/222/
Executed test runs:
    SUCCESS: http://jenkins.qa.ubuntu.com/job/content-hub-vivid-amd64-ci/18
    SUCCESS: http://jenkins.qa.ubuntu.com/job/content-hub-vivid-armhf-ci/18
        deb: http://jenkins.qa.ubuntu.com/job/content-hub-vivid-armhf-ci/18/artifact/work/output/*zip*/output.zip
    SUCCESS: http://jenkins.qa.ubuntu.com/job/content-hub-vivid-i386-ci/18

Click here to trigger a rebuild:
http://s-jenkins.ubuntu-ci:8080/job/content-hub-ci/222/rebuild

review: Needs Fixing (continuous-integration)
194. By Ken VanDine

pass just the fd id

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :

FAILED: Continuous integration, rev:194
No commit message was specified in the merge proposal. Click on the following link and set the commit message (if you want a jenkins rebuild you need to trigger it yourself):
https://code.launchpad.net/~ken-vandine/content-hub/trust_session_wip/+merge/250843/+edit-commit-message

http://jenkins.qa.ubuntu.com/job/content-hub-ci/223/
Executed test runs:
    FAILURE: http://jenkins.qa.ubuntu.com/job/content-hub-vivid-amd64-ci/19/console
    SUCCESS: http://jenkins.qa.ubuntu.com/job/content-hub-vivid-armhf-ci/19
        deb: http://jenkins.qa.ubuntu.com/job/content-hub-vivid-armhf-ci/19/artifact/work/output/*zip*/output.zip
    SUCCESS: http://jenkins.qa.ubuntu.com/job/content-hub-vivid-i386-ci/19

Click here to trigger a rebuild:
http://s-jenkins.ubuntu-ci:8080/job/content-hub-ci/223/rebuild

review: Needs Fixing (continuous-integration)
195. By Ken VanDine

fixed dbus call to service

196. By Ken VanDine

ensure the id for the socket is returned as a string

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :

FAILED: Continuous integration, rev:196
No commit message was specified in the merge proposal. Click on the following link and set the commit message (if you want a jenkins rebuild you need to trigger it yourself):
https://code.launchpad.net/~ken-vandine/content-hub/trust_session_wip/+merge/250843/+edit-commit-message

http://jenkins.qa.ubuntu.com/job/content-hub-ci/224/
Executed test runs:
    SUCCESS: http://jenkins.qa.ubuntu.com/job/content-hub-vivid-amd64-ci/20
    SUCCESS: http://jenkins.qa.ubuntu.com/job/content-hub-vivid-armhf-ci/20
        deb: http://jenkins.qa.ubuntu.com/job/content-hub-vivid-armhf-ci/20/artifact/work/output/*zip*/output.zip
    SUCCESS: http://jenkins.qa.ubuntu.com/job/content-hub-vivid-i386-ci/20

Click here to trigger a rebuild:
http://s-jenkins.ubuntu-ci:8080/job/content-hub-ci/224/rebuild

review: Needs Fixing (continuous-integration)
197. By Ken VanDine

Fixed reference

198. By Ken VanDine

MirHelper fixes

199. By Ken VanDine

more debug output

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :

FAILED: Continuous integration, rev:199
No commit message was specified in the merge proposal. Click on the following link and set the commit message (if you want a jenkins rebuild you need to trigger it yourself):
https://code.launchpad.net/~ken-vandine/content-hub/trust_session_wip/+merge/250843/+edit-commit-message

http://jenkins.qa.ubuntu.com/job/content-hub-ci/225/
Executed test runs:
    SUCCESS: http://jenkins.qa.ubuntu.com/job/content-hub-vivid-amd64-ci/21
    SUCCESS: http://jenkins.qa.ubuntu.com/job/content-hub-vivid-armhf-ci/21
        deb: http://jenkins.qa.ubuntu.com/job/content-hub-vivid-armhf-ci/21/artifact/work/output/*zip*/output.zip
    SUCCESS: http://jenkins.qa.ubuntu.com/job/content-hub-vivid-i386-ci/21

Click here to trigger a rebuild:
http://s-jenkins.ubuntu-ci:8080/job/content-hub-ci/225/rebuild

review: Needs Fixing (continuous-integration)
200. By Ken VanDine

more debug output

201. By Ken VanDine

Hold a reference to the promptSession with the Transfer

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :

FAILED: Continuous integration, rev:200
No commit message was specified in the merge proposal. Click on the following link and set the commit message (if you want a jenkins rebuild you need to trigger it yourself):
https://code.launchpad.net/~ken-vandine/content-hub/trust_session_wip/+merge/250843/+edit-commit-message

http://jenkins.qa.ubuntu.com/job/content-hub-ci/226/
Executed test runs:
    SUCCESS: http://jenkins.qa.ubuntu.com/job/content-hub-vivid-amd64-ci/22
    SUCCESS: http://jenkins.qa.ubuntu.com/job/content-hub-vivid-armhf-ci/22
        deb: http://jenkins.qa.ubuntu.com/job/content-hub-vivid-armhf-ci/22/artifact/work/output/*zip*/output.zip
    SUCCESS: http://jenkins.qa.ubuntu.com/job/content-hub-vivid-i386-ci/22

Click here to trigger a rebuild:
http://s-jenkins.ubuntu-ci:8080/job/content-hub-ci/226/rebuild

review: Needs Fixing (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :

FAILED: Continuous integration, rev:201
No commit message was specified in the merge proposal. Click on the following link and set the commit message (if you want a jenkins rebuild you need to trigger it yourself):
https://code.launchpad.net/~ken-vandine/content-hub/trust_session_wip/+merge/250843/+edit-commit-message

http://jenkins.qa.ubuntu.com/job/content-hub-ci/227/
Executed test runs:
    SUCCESS: http://jenkins.qa.ubuntu.com/job/content-hub-vivid-amd64-ci/23
    SUCCESS: http://jenkins.qa.ubuntu.com/job/content-hub-vivid-armhf-ci/23
        deb: http://jenkins.qa.ubuntu.com/job/content-hub-vivid-armhf-ci/23/artifact/work/output/*zip*/output.zip
    SUCCESS: http://jenkins.qa.ubuntu.com/job/content-hub-vivid-i386-ci/23

Click here to trigger a rebuild:
http://s-jenkins.ubuntu-ci:8080/job/content-hub-ci/227/rebuild

review: Needs Fixing (continuous-integration)
202. By Ken VanDine

Removed un-needed unref

203. By Ken VanDine

ensure the promptSession is destroyed in the Transfer destructor

204. By Ken VanDine

Delete reference to promptSession in the destructor

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :

FAILED: Continuous integration, rev:204
No commit message was specified in the merge proposal. Click on the following link and set the commit message (if you want a jenkins rebuild you need to trigger it yourself):
https://code.launchpad.net/~ken-vandine/content-hub/trust_session_wip/+merge/250843/+edit-commit-message

http://jenkins.qa.ubuntu.com/job/content-hub-ci/228/
Executed test runs:
    FAILURE: http://jenkins.qa.ubuntu.com/job/content-hub-vivid-amd64-ci/24/console
    FAILURE: http://jenkins.qa.ubuntu.com/job/content-hub-vivid-armhf-ci/24/console
    FAILURE: http://jenkins.qa.ubuntu.com/job/content-hub-vivid-i386-ci/24/console

Click here to trigger a rebuild:
http://s-jenkins.ubuntu-ci:8080/job/content-hub-ci/228/rebuild

review: Needs Fixing (continuous-integration)
205. By Ken VanDine

fixed ref

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :

FAILED: Continuous integration, rev:205
No commit message was specified in the merge proposal. Click on the following link and set the commit message (if you want a jenkins rebuild you need to trigger it yourself):
https://code.launchpad.net/~ken-vandine/content-hub/trust_session_wip/+merge/250843/+edit-commit-message

http://jenkins.qa.ubuntu.com/job/content-hub-ci/229/
Executed test runs:
    FAILURE: http://jenkins.qa.ubuntu.com/job/content-hub-vivid-amd64-ci/25/console
    SUCCESS: http://jenkins.qa.ubuntu.com/job/content-hub-vivid-armhf-ci/25
        deb: http://jenkins.qa.ubuntu.com/job/content-hub-vivid-armhf-ci/25/artifact/work/output/*zip*/output.zip
    SUCCESS: http://jenkins.qa.ubuntu.com/job/content-hub-vivid-i386-ci/25

Click here to trigger a rebuild:
http://s-jenkins.ubuntu-ci:8080/job/content-hub-ci/229/rebuild

review: Needs Fixing (continuous-integration)
206. By Ken VanDine

Debugging output

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :

FAILED: Continuous integration, rev:206
No commit message was specified in the merge proposal. Click on the following link and set the commit message (if you want a jenkins rebuild you need to trigger it yourself):
https://code.launchpad.net/~ken-vandine/content-hub/trust_session_wip/+merge/250843/+edit-commit-message

http://jenkins.qa.ubuntu.com/job/content-hub-ci/230/
Executed test runs:
    FAILURE: http://jenkins.qa.ubuntu.com/job/content-hub-vivid-amd64-ci/26/console
    SUCCESS: http://jenkins.qa.ubuntu.com/job/content-hub-vivid-armhf-ci/26
        deb: http://jenkins.qa.ubuntu.com/job/content-hub-vivid-armhf-ci/26/artifact/work/output/*zip*/output.zip
    SUCCESS: http://jenkins.qa.ubuntu.com/job/content-hub-vivid-i386-ci/26

Click here to trigger a rebuild:
http://s-jenkins.ubuntu-ci:8080/job/content-hub-ci/230/rebuild

review: Needs Fixing (continuous-integration)
207. By Ken VanDine

fixed shell quoting

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :

FAILED: Continuous integration, rev:207
No commit message was specified in the merge proposal. Click on the following link and set the commit message (if you want a jenkins rebuild you need to trigger it yourself):
https://code.launchpad.net/~ken-vandine/content-hub/trust_session_wip/+merge/250843/+edit-commit-message

http://jenkins.qa.ubuntu.com/job/content-hub-ci/234/
Executed test runs:
    SUCCESS: http://jenkins.qa.ubuntu.com/job/content-hub-vivid-amd64-ci/30
    SUCCESS: http://jenkins.qa.ubuntu.com/job/content-hub-vivid-armhf-ci/30
        deb: http://jenkins.qa.ubuntu.com/job/content-hub-vivid-armhf-ci/30/artifact/work/output/*zip*/output.zip
    SUCCESS: http://jenkins.qa.ubuntu.com/job/content-hub-vivid-i386-ci/30

Click here to trigger a rebuild:
http://s-jenkins.ubuntu-ci:8080/job/content-hub-ci/234/rebuild

review: Needs Fixing (continuous-integration)
208. By Ken VanDine

working, mostly

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :

FAILED: Continuous integration, rev:208
No commit message was specified in the merge proposal. Click on the following link and set the commit message (if you want a jenkins rebuild you need to trigger it yourself):
https://code.launchpad.net/~ken-vandine/content-hub/trust_session_wip/+merge/250843/+edit-commit-message

http://jenkins.qa.ubuntu.com/job/content-hub-ci/235/
Executed test runs:
    SUCCESS: http://jenkins.qa.ubuntu.com/job/content-hub-vivid-amd64-ci/31
    SUCCESS: http://jenkins.qa.ubuntu.com/job/content-hub-vivid-armhf-ci/31
        deb: http://jenkins.qa.ubuntu.com/job/content-hub-vivid-armhf-ci/31/artifact/work/output/*zip*/output.zip
    SUCCESS: http://jenkins.qa.ubuntu.com/job/content-hub-vivid-i386-ci/31

Click here to trigger a rebuild:
http://s-jenkins.ubuntu-ci:8080/job/content-hub-ci/235/rebuild

review: Needs Fixing (continuous-integration)
209. By Ken VanDine

use ubuntu_app_launch_stop_helper to stop apps started with a PromptSession

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :

FAILED: Continuous integration, rev:209
No commit message was specified in the merge proposal. Click on the following link and set the commit message (if you want a jenkins rebuild you need to trigger it yourself):
https://code.launchpad.net/~ken-vandine/content-hub/trust_session_wip/+merge/250843/+edit-commit-message

http://jenkins.qa.ubuntu.com/job/content-hub-ci/243/
Executed test runs:
    SUCCESS: http://jenkins.qa.ubuntu.com/job/content-hub-vivid-amd64-ci/39
    SUCCESS: http://jenkins.qa.ubuntu.com/job/content-hub-vivid-armhf-ci/39
        deb: http://jenkins.qa.ubuntu.com/job/content-hub-vivid-armhf-ci/39/artifact/work/output/*zip*/output.zip
    SUCCESS: http://jenkins.qa.ubuntu.com/job/content-hub-vivid-i386-ci/39

Click here to trigger a rebuild:
http://s-jenkins.ubuntu-ci:8080/job/content-hub-ci/243/rebuild

review: Needs Fixing (continuous-integration)
Revision history for this message
system-apps-ci-bot (system-apps-ci-bot) wrote :

FAILED: Continuous integration, rev:209
No commit message was specified in the merge proposal. Click on the following link and set the commit message (if you want a jenkins rebuild you need to trigger it yourself):
https://code.launchpad.net/~ken-vandine/content-hub/trust_session_wip/+merge/250843/+edit-commit-message

https://jenkins.canonical.com/system-apps/job/lp-content-hub-ci/4/
Executed test runs:
    FAILURE: https://jenkins.canonical.com/system-apps/job/build/565/console
    FAILURE: https://jenkins.canonical.com/system-apps/job/build-0-fetch/565/console

Click here to trigger a rebuild:
https://jenkins.canonical.com/system-apps/job/lp-content-hub-ci/4/rebuild

review: Needs Fixing (continuous-integration)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'CMakeLists.txt'
2--- CMakeLists.txt 2014-08-14 11:49:28 +0000
3+++ CMakeLists.txt 2015-03-18 18:55:05 +0000
4@@ -16,7 +16,7 @@
5
6 cmake_minimum_required(VERSION 2.8)
7
8-project(content-hub)
9+project (content-hub C CXX)
10
11 set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${CMAKE_CURRENT_SOURCE_DIR}/cmake)
12
13@@ -24,7 +24,7 @@
14 include (EnableCoverageReport)
15 include (GSettings)
16
17-set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Werror -Wall -pedantic -Wextra -fPIC -pthread")
18+#set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Werror -Wall -std=c99 -pedantic -Wextra -fPIC -pthread")
19 set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -Werror -Wall -fno-strict-aliasing -pedantic -Wextra -fPIC -pthread -Wno-unused-function")
20 set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -Wl,--no-undefined")
21
22@@ -68,6 +68,8 @@
23 pkg_check_modules(DBUS REQUIRED dbus-1)
24 pkg_check_modules(UBUNTU_DOWNLOAD_MANAGER REQUIRED ubuntu-download-manager-client)
25 pkg_check_modules(NOTIFY REQUIRED libnotify)
26+pkg_check_modules(MIRCLIENT REQUIRED mirclient)
27+pkg_check_modules(CLICK REQUIRED click-0.4)
28
29 add_definitions(-DDEBUG_ENABLED)
30
31
32=== modified file 'debian/content-hub.install'
33--- debian/content-hub.install 2014-11-18 14:59:03 +0000
34+++ debian/content-hub.install 2015-03-18 18:55:05 +0000
35@@ -1,5 +1,6 @@
36 usr/bin/content-hub-service
37 usr/lib/*/content-hub
38+usr/lib/*/ubuntu-app-launch
39 usr/share/click/hooks
40 usr/share/dbus-1
41 usr/share/glib-2.0/schemas
42
43=== modified file 'debian/control'
44--- debian/control 2014-11-18 14:59:03 +0000
45+++ debian/control 2015-03-18 18:55:05 +0000
46@@ -9,8 +9,10 @@
47 doxygen,
48 google-mock,
49 lcov,
50+ libclick-0.4-dev,
51 libglib2.0-dev,
52 libgsettings-qt-dev,
53+ libmirclient-dev [!powerpc !ppc64 !ppc64el],
54 libnih-dbus-dev,
55 libnotify-dev,
56 libubuntu-download-manager-client-dev,
57
58=== modified file 'import/Ubuntu/Content/contenthub.h'
59--- import/Ubuntu/Content/contenthub.h 2014-08-04 17:57:26 +0000
60+++ import/Ubuntu/Content/contenthub.h 2015-03-18 18:55:05 +0000
61@@ -71,6 +71,7 @@
62 void updateState();
63
64 private:
65+ QString setupPromptSession();
66 QList<ContentTransfer *> m_finishedImports;
67 QHash<com::ubuntu::content::Transfer *, ContentTransfer *> m_activeImports;
68 com::ubuntu::content::Hub *m_hub;
69
70=== modified file 'include/com/ubuntu/content/transfer.h'
71--- include/com/ubuntu/content/transfer.h 2014-08-27 13:49:13 +0000
72+++ include/com/ubuntu/content/transfer.h 2015-03-18 18:55:05 +0000
73@@ -64,6 +64,7 @@
74 Q_PROPERTY(QString contentType READ contentType)
75 Q_PROPERTY(QString source READ source)
76 Q_PROPERTY(QString destination READ destination)
77+ Q_PROPERTY(QString mirSocket READ mirSocket WRITE setMirSocket NOTIFY mirSocketChanged)
78
79 public:
80 enum State
81@@ -115,11 +116,14 @@
82 Q_INVOKABLE virtual QString contentType() const;
83 Q_INVOKABLE virtual QString source() const;
84 Q_INVOKABLE virtual QString destination() const;
85+ Q_INVOKABLE virtual QString mirSocket() const;
86+ Q_INVOKABLE virtual bool setMirSocket(const QString);
87
88 Q_SIGNAL void stateChanged();
89 Q_SIGNAL void storeChanged();
90 Q_SIGNAL void selectionTypeChanged();
91 Q_SIGNAL void downloadIdChanged();
92+ Q_SIGNAL void mirSocketChanged();
93
94 private:
95 struct Private;
96
97=== modified file 'src/CMakeLists.txt'
98--- src/CMakeLists.txt 2013-07-15 11:07:50 +0000
99+++ src/CMakeLists.txt 2015-03-18 18:55:05 +0000
100@@ -14,4 +14,5 @@
101 #
102 # Authored by: Thomas Voss <thomas.voss@canonical.com>
103
104-add_subdirectory(com)
105\ No newline at end of file
106+add_subdirectory(com)
107+add_subdirectory(helper)
108
109=== modified file 'src/com/ubuntu/applicationmanager/application_manager.h'
110--- src/com/ubuntu/applicationmanager/application_manager.h 2014-05-26 06:45:57 +0000
111+++ src/com/ubuntu/applicationmanager/application_manager.h 2015-03-18 18:55:05 +0000
112@@ -38,6 +38,20 @@
113 * \param app_id ID for the application (for example "gallery-app" - used for the desktop)
114 */
115 virtual bool invoke_application(const std::string &app_id) = 0;
116+
117+ /*!
118+ * \brief invoke_application_with_socket starts an application without a trusted session
119+ * \param app_id ID for the application (for example "gallery-app" - used for the desktop)
120+ * \param socket path to MIR_SOCKET
121+ */
122+ virtual bool invoke_application_with_socket(const std::string &app_id, const std::string &socket) = 0;
123+
124+ /*!
125+ * \brief stop_application_with_helper stops an application started by the content-hub helper
126+ * \param app_id ID for the application (for example "gallery-app" - used for the desktop)
127+ */
128+ virtual bool stop_application_with_helper(const std::string &app_id) = 0;
129+
130 /*!
131 * \brief stop_application stops an application started by ubuntu
132 * \param app_id ID for the application (for example "gallery-app" - used for the desktop)
133
134=== modified file 'src/com/ubuntu/content/CMakeLists.txt'
135--- src/com/ubuntu/content/CMakeLists.txt 2014-05-26 06:45:57 +0000
136+++ src/com/ubuntu/content/CMakeLists.txt 2015-03-18 18:55:05 +0000
137@@ -28,6 +28,7 @@
138 ${UBUNTU_LAUNCH_INCLUDE_DIRS}
139 ${UBUNTU_DOWNLOAD_MANAGER_INCLUDE_DIRS}
140 ${NOTIFY_INCLUDE_DIRS}
141+ ${MIRCLIENT_INCLUDE_DIRS}
142 )
143
144 qt5_add_dbus_interface(
145@@ -77,6 +78,7 @@
146 detail/transfer.cpp
147 detail/handler.cpp
148 detail/i18n.cpp
149+ detail/mir-helper.cpp
150
151 ${CONTENT_HUB_MOCS}
152 ${CONTENT_SERVICE_STUB}
153@@ -105,6 +107,7 @@
154 ${GIO_LIBRARIES}
155 ${UBUNTU_DOWNLOAD_MANAGER_LIBRARIES}
156 ${NOTIFY_LIBRARIES}
157+ ${MIRCLIENT_LIBRARIES}
158 )
159
160 install(
161
162=== modified file 'src/com/ubuntu/content/detail/app_manager.cpp'
163--- src/com/ubuntu/content/detail/app_manager.cpp 2014-05-26 06:45:57 +0000
164+++ src/com/ubuntu/content/detail/app_manager.cpp 2015-03-18 18:55:05 +0000
165@@ -24,7 +24,6 @@
166 /*!
167 * \reimp
168 */
169-
170 bool cucd::AppManager::invoke_application(const std::string &app_id)
171 {
172 TRACE() << Q_FUNC_INFO << "APP_ID:" << app_id.c_str();
173@@ -36,6 +35,35 @@
174 /*!
175 * \reimp
176 */
177+bool cucd::AppManager::invoke_application_with_socket(const std::string &app_id, const std::string &socket)
178+{
179+ TRACE() << Q_FUNC_INFO << "APP_ID:" << app_id.c_str();
180+ QVector<const gchar*> uris;
181+ uris.append(g_strdup_printf("%s", socket.c_str()));
182+ uris.append("");
183+ uris.append(NULL);
184+ TRACE() << Q_FUNC_INFO << "URIS:" << g_strdup_printf("%s", socket.c_str());
185+ gboolean ok = ubuntu_app_launch_start_helper("content-hub",
186+ app_id.c_str(),
187+ uris.constData());
188+ return static_cast<bool>(ok);
189+}
190+
191+/*!
192+ * \reimp
193+ */
194+bool cucd::AppManager::stop_application_with_helper(const std::string &app_id)
195+{
196+ TRACE() << Q_FUNC_INFO << "APP_ID:" << app_id.c_str();
197+
198+ gboolean ok = ubuntu_app_launch_stop_helper("content-hub",
199+ app_id.c_str());
200+ return static_cast<bool>(ok);
201+}
202+
203+/*!
204+ * \reimp
205+ */
206 bool cucd::AppManager::stop_application(const std::string &app_id)
207 {
208 TRACE() << Q_FUNC_INFO << "APP_ID:" << app_id.c_str();
209
210=== modified file 'src/com/ubuntu/content/detail/app_manager.h'
211--- src/com/ubuntu/content/detail/app_manager.h 2014-02-13 19:11:43 +0000
212+++ src/com/ubuntu/content/detail/app_manager.h 2015-03-18 18:55:05 +0000
213@@ -36,6 +36,8 @@
214 AppManager& operator=(const AppManager&) = default;
215
216 virtual bool invoke_application(const std::string &app_id);
217+ virtual bool invoke_application_with_socket(const std::string &app_id, const std::string &socket);
218+ virtual bool stop_application_with_helper(const std::string &app_id);
219 virtual bool stop_application(const std::string &app_id);
220 virtual bool is_application_started(const std::string &app_id);
221 };
222
223=== modified file 'src/com/ubuntu/content/detail/com.ubuntu.content.Service.xml'
224--- src/com/ubuntu/content/detail/com.ubuntu.content.Service.xml 2014-08-04 17:56:09 +0000
225+++ src/com/ubuntu/content/detail/com.ubuntu.content.Service.xml 2015-03-18 18:55:05 +0000
226@@ -43,5 +43,9 @@
227 <method name="HandlerActive">
228 <arg name="peer_id" type="s" direction="in" />
229 </method>
230+ <method name="GetMirSocket">
231+ <arg type="i" name="fd" direction="in" />
232+ <arg type="h" name="handle" direction="out" />
233+ </method>
234 </interface>
235 </node>
236
237=== modified file 'src/com/ubuntu/content/detail/com.ubuntu.content.Transfer.xml'
238--- src/com/ubuntu/content/detail/com.ubuntu.content.Transfer.xml 2014-08-27 13:49:13 +0000
239+++ src/com/ubuntu/content/detail/com.ubuntu.content.Transfer.xml 2015-03-18 18:55:05 +0000
240@@ -64,5 +64,14 @@
241 <method name="destination">
242 <arg name="destination" type="s" direction="out" />
243 </method>
244+ <method name="MirSocket">
245+ <arg name="mir_socket" type="s" direction="out" />
246+ </method>
247+ <method name="SetMirSocket">
248+ <arg name="mir_socket" type="s" direction="in" />
249+ </method>
250+ <signal name="MirSocketChanged">
251+ <arg name="mir_socket" type="s"/>
252+ </signal>
253 </interface>
254 </node>
255
256=== added file 'src/com/ubuntu/content/detail/mir-helper.cpp'
257--- src/com/ubuntu/content/detail/mir-helper.cpp 1970-01-01 00:00:00 +0000
258+++ src/com/ubuntu/content/detail/mir-helper.cpp 2015-03-18 18:55:05 +0000
259@@ -0,0 +1,235 @@
260+/*
261+ * Copyright 2015 Canonical Ltd.
262+ *
263+ * This program is free software; you can redistribute it and/or modify
264+ * it under the terms of the GNU Lesser General Public License as published by
265+ * the Free Software Foundation; version 3.
266+ *
267+ * This program is distributed in the hope that it will be useful,
268+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
269+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
270+ * GNU Lesser General Public License for more details.
271+ *
272+ * You should have received a copy of the GNU Lesser General Public License
273+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
274+ */
275+
276+#include "debug.h"
277+#include "mir-helper.h"
278+
279+#include <mir_toolkit/mir_client_library.h>
280+#include <mir_toolkit/mir_prompt_session.h>
281+
282+#include <QHash>
283+#include <QStandardPaths>
284+#include <QWeakPointer>
285+
286+static MirHelper *m_instance = 0;
287+
288+class PromptSessionPrivate
289+{
290+public:
291+ inline PromptSessionPrivate(MirPromptSession *session, pid_t initiatorPid);
292+ inline ~PromptSessionPrivate();
293+
294+ void emitFinished() { Q_EMIT q_ptr->finished(); }
295+
296+ MirPromptSession *m_mirSession;
297+ pid_t m_initiatorPid;
298+ QList<int> m_fds;
299+ mutable PromptSession *q_ptr;
300+};
301+
302+class MirHelperPrivate: public QObject
303+{
304+ Q_OBJECT
305+ Q_DECLARE_PUBLIC(MirHelper)
306+
307+public:
308+ inline MirHelperPrivate(MirHelper *helper);
309+ inline ~MirHelperPrivate();
310+
311+ PromptSession *createPromptSession(pid_t initiatorPid);
312+ void onSessionStopped(MirPromptSession *mirSession);
313+
314+private:
315+ friend class PromptSession;
316+ MirConnection *m_connection;
317+ QHash<pid_t,QWeakPointer<PromptSession> > m_sessions;
318+ mutable MirHelper *q_ptr;
319+};
320+
321+PromptSessionPrivate::PromptSessionPrivate(MirPromptSession *session,
322+ pid_t initiatorPid):
323+ m_mirSession(session),
324+ m_initiatorPid(initiatorPid)
325+{
326+ TRACE() << Q_FUNC_INFO;
327+}
328+
329+PromptSessionPrivate::~PromptSessionPrivate()
330+{
331+ mir_prompt_session_release_sync(m_mirSession);
332+ m_mirSession = 0;
333+}
334+
335+PromptSession::PromptSession(PromptSessionPrivate *priv):
336+ d_ptr(priv)
337+{
338+ TRACE() << Q_FUNC_INFO;
339+ priv->q_ptr = this;
340+}
341+
342+PromptSession::~PromptSession()
343+{
344+ TRACE() << Q_FUNC_INFO;
345+ Q_D(PromptSession);
346+ MirHelperPrivate *helperPrivate = MirHelper::instance()->d_ptr;
347+ helperPrivate->m_sessions.remove(d->m_initiatorPid);
348+ delete d_ptr;
349+}
350+
351+static void client_fd_callback(MirPromptSession *, size_t count,
352+ int const *fds, void *context)
353+{
354+ TRACE() << Q_FUNC_INFO;
355+ PromptSessionPrivate *priv = (PromptSessionPrivate *)context;
356+ for (size_t i = 0; i < count; i++) {
357+ priv->m_fds.append(fds[i]);
358+ }
359+}
360+
361+void PromptSession::release()
362+{
363+ TRACE() << Q_FUNC_INFO;
364+ Q_D(PromptSession);
365+ if (d->m_mirSession)
366+ mir_prompt_session_release_sync(d->m_mirSession);
367+ d->m_mirSession = NULL;
368+}
369+
370+QString PromptSession::requestSocket()
371+{
372+ TRACE() << Q_FUNC_INFO;
373+ Q_D(PromptSession);
374+
375+ d->m_fds.clear();
376+ mir_wait_for(mir_prompt_session_new_fds_for_prompt_providers(
377+ d->m_mirSession, 1, client_fd_callback, d));
378+ if (!d->m_fds.isEmpty()) {
379+ return QString("%1").arg(d->m_fds[0]);
380+ } else {
381+ return QString();
382+ }
383+}
384+
385+MirHelperPrivate::MirHelperPrivate(MirHelper *helper):
386+ QObject(helper),
387+ q_ptr(helper)
388+{
389+ TRACE() << Q_FUNC_INFO;
390+ QString mirSocket =
391+ QStandardPaths::writableLocation(QStandardPaths::RuntimeLocation) +
392+ "/mir_socket_trusted";
393+ m_connection = mir_connect_sync(mirSocket.toUtf8().constData(),
394+ "content-hub-service");
395+ if (Q_UNLIKELY(!mir_connection_is_valid(m_connection))) {
396+ qWarning() << "Invalid Mir connection:" <<
397+ mir_connection_get_error_message(m_connection);
398+ return;
399+ }
400+}
401+
402+MirHelperPrivate::~MirHelperPrivate()
403+{
404+ TRACE() << Q_FUNC_INFO;
405+ if (m_connection) {
406+ mir_connection_release(m_connection);
407+ m_connection = 0;
408+ }
409+}
410+
411+static void session_event_callback(MirPromptSession *mirSession,
412+ MirPromptSessionState state,
413+ void *self)
414+{
415+ TRACE() << Q_FUNC_INFO;
416+ MirHelperPrivate *helper = reinterpret_cast<MirHelperPrivate*>(self);
417+ TRACE() << "Prompt Session state updated to" << state;
418+ if (state == mir_prompt_session_state_stopped) {
419+ helper->onSessionStopped(mirSession);
420+ }
421+}
422+
423+void MirHelperPrivate::onSessionStopped(MirPromptSession *mirSession)
424+{
425+ TRACE() << Q_FUNC_INFO;
426+ Q_FOREACH(PromptSessionP session, m_sessions) {
427+ if (mirSession == session->d_ptr->m_mirSession) {
428+ session->d_ptr->emitFinished();
429+ }
430+ }
431+}
432+
433+PromptSession *MirHelperPrivate::createPromptSession(pid_t initiatorPid)
434+{
435+ TRACE() << Q_FUNC_INFO << initiatorPid;
436+ if (Q_UNLIKELY(!m_connection)) return 0;
437+ if (Q_UNLIKELY(!mir_connection_is_valid(m_connection))) return 0;
438+
439+ MirPromptSession *mirSession =
440+ mir_connection_create_prompt_session_sync(m_connection,
441+ initiatorPid,
442+ session_event_callback,
443+ this);
444+ if (!mirSession) return 0;
445+
446+ if (Q_UNLIKELY(!mir_prompt_session_is_valid(mirSession))) {
447+ qWarning() << "Invalid prompt session:" <<
448+ mir_prompt_session_error_message(mirSession);
449+ return 0;
450+ }
451+
452+ return new PromptSession(new PromptSessionPrivate(mirSession, initiatorPid));
453+}
454+
455+MirHelper::MirHelper(QObject *parent):
456+ QObject(parent),
457+ d_ptr(new MirHelperPrivate(this))
458+{
459+ TRACE() << Q_FUNC_INFO;
460+}
461+
462+MirHelper::~MirHelper()
463+{
464+ TRACE() << Q_FUNC_INFO;
465+ m_instance = 0;
466+}
467+
468+MirHelper *MirHelper::instance()
469+{
470+ TRACE() << Q_FUNC_INFO;
471+ if (!m_instance) {
472+ m_instance = new MirHelper;
473+ }
474+ return m_instance;
475+}
476+
477+PromptSessionP MirHelper::createPromptSession(pid_t initiatorPid)
478+{
479+ Q_D(MirHelper);
480+ TRACE() << Q_FUNC_INFO << initiatorPid;
481+ PromptSessionP session = d->m_sessions.value(initiatorPid);
482+ if (session.isNull()) {
483+ TRACE() << Q_FUNC_INFO << "Session is NULL";
484+ PromptSession *s = d->createPromptSession(initiatorPid);
485+ if (s) {
486+ TRACE() << Q_FUNC_INFO << "Creating new session";
487+ session = PromptSessionP(s);
488+ d->m_sessions.insert(initiatorPid, session);
489+ }
490+ }
491+ return session;
492+}
493+
494+#include "mir-helper.moc"
495
496=== added file 'src/com/ubuntu/content/detail/mir-helper.h'
497--- src/com/ubuntu/content/detail/mir-helper.h 1970-01-01 00:00:00 +0000
498+++ src/com/ubuntu/content/detail/mir-helper.h 2015-03-18 18:55:05 +0000
499@@ -0,0 +1,69 @@
500+/*
501+ * Copyright 2015 Canonical Ltd.
502+ *
503+ * This program is free software; you can redistribute it and/or modify
504+ * it under the terms of the GNU Lesser General Public License as published by
505+ * the Free Software Foundation; version 3.
506+ *
507+ * This program is distributed in the hope that it will be useful,
508+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
509+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
510+ * GNU Lesser General Public License for more details.
511+ *
512+ * You should have received a copy of the GNU Lesser General Public License
513+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
514+ */
515+
516+#ifndef MIR_HELPER_H
517+#define MIR_HELPER_H
518+
519+#include <QObject>
520+#include <QSharedPointer>
521+
522+class PromptSessionPrivate;
523+class MirHelperPrivate;
524+
525+class PromptSession: public QObject
526+{
527+ Q_OBJECT
528+
529+public:
530+ ~PromptSession();
531+
532+ QString requestSocket();
533+ void release();
534+
535+Q_SIGNALS:
536+ void finished();
537+
538+private:
539+ explicit PromptSession(PromptSessionPrivate *priv);
540+
541+private:
542+ friend class MirHelperPrivate;
543+ PromptSessionPrivate *d_ptr;
544+ Q_DECLARE_PRIVATE(PromptSession)
545+};
546+
547+typedef QSharedPointer<PromptSession> PromptSessionP;
548+
549+class MirHelper: public QObject
550+{
551+ Q_OBJECT
552+
553+public:
554+ static MirHelper *instance();
555+
556+ PromptSessionP createPromptSession(pid_t initiatorPid);
557+
558+private:
559+ explicit MirHelper(QObject *parent = 0);
560+ ~MirHelper();
561+
562+private:
563+ friend class PromptSession;
564+ MirHelperPrivate *d_ptr;
565+ Q_DECLARE_PRIVATE(MirHelper)
566+};
567+
568+#endif // MIR_HELPER_H
569
570=== modified file 'src/com/ubuntu/content/detail/service.cpp'
571--- src/com/ubuntu/content/detail/service.cpp 2014-11-19 18:37:26 +0000
572+++ src/com/ubuntu/content/detail/service.cpp 2015-03-18 18:55:05 +0000
573@@ -168,7 +168,7 @@
574
575 QDBusObjectPath cucd::Service::CreateImportFromPeer(const QString& peer_id, const QString& app_id, const QString& type_id)
576 {
577- TRACE() << Q_FUNC_INFO;
578+ TRACE() << Q_FUNC_INFO << "APP_ID:" << app_id << "SERVICE:" << this->message().service();
579 QString dest_id = app_id;
580 if (dest_id.isEmpty())
581 {
582@@ -314,6 +314,12 @@
583 }
584
585 auto transfer = new cucd::Transfer(import_counter, src_id, dest_id, dir, type_id, this);
586+ if (dir == cuc::Transfer::Import) {
587+ uint clientPid = d->connection.interface()->servicePid(this->message().service());
588+ auto mirSocket = setupPromptSession(transfer, clientPid);
589+ if (!mirSocket.isEmpty())
590+ transfer->SetMirSocket(mirSocket);
591+ }
592 new TransferAdaptor(transfer);
593 d->active_transfers.insert(transfer);
594
595@@ -338,6 +344,28 @@
596 return QDBusObjectPath{source};
597 }
598
599+QString cucd::Service::setupPromptSession(cucd::Transfer* t, uint clientPid)
600+{
601+ TRACE() << Q_FUNC_INFO << "PID:" << clientPid;
602+ if (!m_mirHelper) {
603+ TRACE() << "No MirHelper, creating one";
604+ m_mirHelper = MirHelper::instance();
605+ }
606+ PromptSessionP session = m_mirHelper->createPromptSession(clientPid);
607+ if (!session) return "";
608+
609+ QString mirSocket = session->requestSocket();
610+ t->SetPromptSession(session);
611+ TRACE() << Q_FUNC_INFO << "mirSocket:" << mirSocket;
612+
613+ /*
614+ QObject::connect(session.data(), SIGNAL(finished()),
615+ q, SIGNAL(finished()));
616+ */
617+
618+ return mirSocket;
619+}
620+
621 void cucd::Service::handle_imports(int state)
622 {
623 TRACE() << Q_FUNC_INFO << state;
624@@ -365,14 +393,27 @@
625 }
626 }
627
628- d->app_manager->invoke_application(transfer->source().toStdString());
629+ if (transfer->MirSocket().isEmpty() || !transfer->WasSourceStartedByContentHub())
630+ d->app_manager->invoke_application(transfer->source().toStdString());
631+ else
632+ d->app_manager->invoke_application_with_socket(transfer->source().toStdString(), transfer->MirSocket().toStdString());
633 }
634
635 if (state == cuc::Transfer::charged)
636 {
637 TRACE() << Q_FUNC_INFO << "Charged";
638- if (transfer->WasSourceStartedByContentHub())
639- d->app_manager->stop_application(transfer->source().toStdString());
640+ if (transfer->WasSourceStartedByContentHub()) {
641+ if (!transfer->MirSocket().isEmpty()) {
642+ PromptSessionP pSession = transfer->PromptSession();
643+ PromptSession* session = pSession.data();
644+ if (session)
645+ session->release();
646+ pSession.clear();
647+ d->app_manager->stop_application_with_helper(transfer->source().toStdString());
648+ }
649+ else
650+ d->app_manager->stop_application(transfer->source().toStdString());
651+ }
652
653 d->app_manager->invoke_application(transfer->destination().toStdString());
654
655@@ -598,3 +639,12 @@
656 }
657 }
658 }
659+
660+QDBusUnixFileDescriptor cucd::Service::GetMirSocket(int fd_id)
661+{
662+ TRACE() << Q_FUNC_INFO << fd_id;
663+ auto fd = QDBusUnixFileDescriptor(fd_id);
664+ TRACE() << Q_FUNC_INFO << "FD isValid" << fd.isValid();
665+ return fd;
666+
667+}
668
669=== modified file 'src/com/ubuntu/content/detail/service.h'
670--- src/com/ubuntu/content/detail/service.h 2014-11-19 18:37:26 +0000
671+++ src/com/ubuntu/content/detail/service.h 2015-03-18 18:55:05 +0000
672@@ -25,9 +25,11 @@
673 #include <QtDBus/QDBusMessage>
674 #include <QtDBus/QDBusServiceWatcher>
675 #include <QtDBus/QDBusContext>
676+#include <QDBusUnixFileDescriptor>
677
678 #include <com/ubuntu/applicationmanager/application_manager.h>
679 #include "handler.h"
680+#include "mir-helper.h"
681 #include "transfer.h"
682
683 namespace com
684@@ -66,6 +68,7 @@
685 void HandlerActive(const QString&);
686 void Quit();
687 void DownloadManagerError(QString);
688+ QDBusUnixFileDescriptor GetMirSocket(int);
689
690 private:
691 bool should_cancel(int);
692@@ -73,6 +76,7 @@
693 struct RegHandler;
694 QDBusServiceWatcher* m_watcher;
695 QScopedPointer<Private> d;
696+ MirHelper* m_mirHelper = 0;
697
698 private Q_SLOTS:
699 void handle_imports(int);
700@@ -80,7 +84,7 @@
701 void handler_unregistered(const QString&);
702 QDBusObjectPath CreateTransfer(const QString&, const QString&, int, const QString&);
703 void download_notify (com::ubuntu::content::detail::Transfer*);
704-
705+ QString setupPromptSession(com::ubuntu::content::detail::Transfer*, uint);
706 };
707 }
708 }
709
710=== modified file 'src/com/ubuntu/content/detail/transfer.cpp'
711--- src/com/ubuntu/content/detail/transfer.cpp 2014-09-26 10:34:39 +0000
712+++ src/com/ubuntu/content/detail/transfer.cpp 2015-03-18 18:55:05 +0000
713@@ -17,6 +17,7 @@
714 */
715
716 #include "debug.h"
717+#include "mir-helper.h"
718 #include "transfer.h"
719 #include "utils.cpp"
720
721@@ -59,6 +60,8 @@
722 bool source_started_by_content_hub;
723 QString download_id;
724 const QString content_type;
725+ QString mir_socket = "";
726+ PromptSessionP promptSession;
727 };
728
729 cucd::Transfer::Transfer(const int id,
730@@ -357,12 +360,14 @@
731 /* sets, if the source app is freshly started by the content hub */
732 void cucd::Transfer::SetSourceStartedByContentHub(bool started)
733 {
734+ TRACE() << Q_FUNC_INFO << started;
735 d->source_started_by_content_hub = started;
736 }
737
738 /* returns if the source app was started by the content hub */
739 bool com::ubuntu::content::detail::Transfer::WasSourceStartedByContentHub() const
740 {
741+ TRACE() << Q_FUNC_INFO << d->source_started_by_content_hub;;
742 return d->source_started_by_content_hub;
743 }
744
745@@ -371,3 +376,36 @@
746 TRACE() << __PRETTY_FUNCTION__;
747 return d->content_type;
748 }
749+
750+QString cucd::Transfer::MirSocket()
751+{
752+ TRACE() << Q_FUNC_INFO << d->mir_socket;
753+ return d->mir_socket;
754+}
755+
756+void cucd::Transfer::SetMirSocket(QString mir_socket)
757+{
758+ TRACE() << Q_FUNC_INFO << mir_socket;
759+
760+ if (d->mir_socket == mir_socket)
761+ return;
762+
763+ d->mir_socket = mir_socket;
764+ Q_EMIT(MirSocketChanged(d->mir_socket));
765+}
766+
767+PromptSessionP cucd::Transfer::PromptSession()
768+{
769+ TRACE() << Q_FUNC_INFO;
770+ return d->promptSession;
771+}
772+
773+void cucd::Transfer::SetPromptSession(PromptSessionP promptSession)
774+{
775+ TRACE() << Q_FUNC_INFO;
776+
777+ if (d->promptSession == promptSession)
778+ return;
779+
780+ d->promptSession = promptSession;
781+}
782
783=== modified file 'src/com/ubuntu/content/detail/transfer.h'
784--- src/com/ubuntu/content/detail/transfer.h 2014-09-26 10:34:39 +0000
785+++ src/com/ubuntu/content/detail/transfer.h 2015-03-18 18:55:05 +0000
786@@ -18,6 +18,7 @@
787 #ifndef TRANSFER_H_
788 #define TRANSFER_H_
789
790+#include "mir-helper.h"
791 #include <QObject>
792 #include <QStringList>
793 #include <QDir>
794@@ -43,6 +44,7 @@
795 Q_PROPERTY(QString destination READ destination)
796 Q_PROPERTY(int direction READ Direction)
797 Q_PROPERTY(QString ContentType READ ContentType)
798+ Q_PROPERTY(QString MirSocket READ MirSocket WRITE SetMirSocket NOTIFY MirSocketChanged)
799
800 public:
801 Transfer(const int, const QString&, const QString&, const int, const QString&, QObject* parent = nullptr);
802@@ -60,6 +62,7 @@
803 void SelectionTypeChanged(int SelectionType);
804 void DownloadIdChanged(QString DownloadId);
805 void DownloadManagerError(QString ErrorMessage);
806+ void MirSocketChanged(QString MirSocket);
807
808 public Q_SLOTS:
809 int State();
810@@ -86,6 +89,10 @@
811 void DownloadError(Ubuntu::DownloadManager::Error* error);
812 QString ContentType();
813 void AddItemsFromDir(QDir dir);
814+ QString MirSocket();
815+ void SetMirSocket(QString MirSocket);
816+ PromptSessionP PromptSession();
817+ void SetPromptSession(PromptSessionP promptSession);
818
819 private:
820 struct Private;
821
822=== modified file 'src/com/ubuntu/content/transfer.cpp'
823--- src/com/ubuntu/content/transfer.cpp 2014-08-27 13:49:13 +0000
824+++ src/com/ubuntu/content/transfer.cpp 2015-03-18 18:55:05 +0000
825@@ -136,3 +136,13 @@
826 {
827 return d->destination();
828 }
829+
830+QString cuc::Transfer::mirSocket() const
831+{
832+ return d->mirSocket();
833+}
834+
835+bool cuc::Transfer::setMirSocket(QString socket)
836+{
837+ return d->setMirSocket(socket);
838+}
839
840=== modified file 'src/com/ubuntu/content/transfer_p.h'
841--- src/com/ubuntu/content/transfer_p.h 2014-08-27 13:49:13 +0000
842+++ src/com/ubuntu/content/transfer_p.h 2015-03-18 18:55:05 +0000
843@@ -243,6 +243,25 @@
844 return static_cast<QString>(reply.value());
845 }
846
847+ QString mirSocket()
848+ {
849+ auto reply = remote_transfer->MirSocket();
850+ reply.waitForFinished();
851+
852+ if (reply.isError())
853+ return QString();
854+
855+ return static_cast<QString>(reply.value());
856+ }
857+
858+ bool setMirSocket(QString mir_socket)
859+ {
860+ auto reply = remote_transfer->SetMirSocket(mir_socket);
861+ reply.waitForFinished();
862+
863+ return not reply.isError();
864+ }
865+
866 com::ubuntu::content::dbus::Transfer* remote_transfer;
867 };
868 }
869
870=== added directory 'src/helper'
871=== added file 'src/helper/CMakeLists.txt'
872--- src/helper/CMakeLists.txt 1970-01-01 00:00:00 +0000
873+++ src/helper/CMakeLists.txt 2015-03-18 18:55:05 +0000
874@@ -0,0 +1,61 @@
875+# Copyright © 2013 Canonical Ltd.
876+#
877+# This program is free software: you can redistribute it and/or modify
878+# it under the terms of the GNU General Public License version 3 as
879+# published by the Free Software Foundation.
880+#
881+# This program is distributed in the hope that it will be useful,
882+# but WITHOUT ANY WARRANTY; without even the implied warranty of
883+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
884+# GNU General Public License for more details.
885+#
886+# You should have received a copy of the GNU General Public License
887+# along with this program. If not, see <http://www.gnu.org/licenses/>.
888+#
889+# Authored by: Thomas Voss <thomas.voss@canonical.com>
890+
891+set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -g -fPIE ${GCOV_FLAGS}")
892+
893+include_directories(
894+ ${CMAKE_CURRENT_BINARY_DIR}
895+ ${UBUNTU_LAUNCH_INCLUDE_DIRS}
896+ ${GIO_INCLUDE_DIRS}
897+ ${GLIB_INCLUDE_DIRS}
898+ ${CLICK_INCLUDE_DIRS}
899+)
900+
901+###########################
902+# Mir Connection Demangler
903+###########################
904+
905+add_executable(mir-connection-demangler mir-connection-demangler.c)
906+target_link_libraries(mir-connection-demangler ${GLIB_LDFLAGS} ${GIO_LDFLAGS})
907+#install(
908+# RUNTIME "${CMAKE_CURRENT_BINARY_DIR}/mir-connection-demangler"
909+# DESTINATION "${CMAKE_INSTALL_FULL_PKGLIBEXECDIR}"
910+#)
911+
912+#############################
913+# Untrusted Helper Exec Tool
914+#############################
915+
916+add_definitions(-DSOCKET_TOOL="${CMAKE_INSTALL_FULL_LIBEXECDIR}/ubuntu-app-launch/content-hub/mir-connection-demangler")
917+add_executable(
918+ exec-tool
919+
920+ exec-tool.c
921+)
922+
923+target_link_libraries(
924+ exec-tool
925+
926+ ${UBUNTU_LAUNCH_LDFLAGS}
927+ ${CLICK_LDFLAGS}
928+ ${GLIB_LDFLAGS}
929+ ${GIO_LDFLAGS}
930+)
931+
932+install(
933+ PROGRAMS "${CMAKE_CURRENT_BINARY_DIR}/exec-tool" "${CMAKE_CURRENT_BINARY_DIR}/mir-connection-demangler"
934+ DESTINATION "${CMAKE_INSTALL_FULL_LIBEXECDIR}/ubuntu-app-launch/content-hub"
935+)
936
937=== added file 'src/helper/exec-tool.c'
938--- src/helper/exec-tool.c 1970-01-01 00:00:00 +0000
939+++ src/helper/exec-tool.c 2015-03-18 18:55:05 +0000
940@@ -0,0 +1,222 @@
941+/*
942+ * Copyright © 2014 Canonical Ltd.
943+ *
944+ * This program is free software: you can redistribute it and/or modify it
945+ * under the terms of the GNU General Public License version 3, as published
946+ * by the Free Software Foundation.
947+ *
948+ * This program is distributed in the hope that it will be useful, but
949+ * WITHOUT ANY WARRANTY; without even the implied warranties of
950+ * MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
951+ * PURPOSE. See the GNU General Public License for more details.
952+ *
953+ * You should have received a copy of the GNU General Public License along
954+ * with this program. If not, see <http://www.gnu.org/licenses/>.
955+ *
956+ * Authors:
957+ * Ted Gould <ted.gould@canonical.com>
958+ */
959+
960+#include <glib.h>
961+#include <click.h>
962+#include <ubuntu-app-launch.h>
963+
964+gchar *
965+build_exec_envvar (const gchar * appid)
966+{
967+ gchar * appid_desktop = g_strdup_printf("%s.desktop", appid);
968+ /* FIXME: We need our hook to create our own symlink to the desktop file to use */
969+ gchar * desktopfilepath = g_build_filename(g_get_user_cache_dir(), "ubuntu-app-launch", "desktop", appid_desktop, NULL);
970+ g_free(appid_desktop);
971+
972+ if (!g_file_test(desktopfilepath, G_FILE_TEST_EXISTS)) {
973+ g_error("Can not file desktop file for '%s', expecting: '%s'", appid, desktopfilepath);
974+ g_free(desktopfilepath);
975+ return NULL;
976+ }
977+
978+ GError * error = NULL;
979+ GKeyFile * keyfile = g_key_file_new();
980+ g_key_file_load_from_file(keyfile, desktopfilepath, G_KEY_FILE_NONE, &error);
981+
982+ if (error != NULL) {
983+ g_error("Unable to read content-hub desktop file '%s': %s", desktopfilepath, error->message);
984+ g_free(desktopfilepath);
985+ g_key_file_free(keyfile);
986+ g_error_free(error);
987+ return NULL;
988+ }
989+
990+ g_free(desktopfilepath);
991+
992+ if (!g_key_file_has_key(keyfile, "Desktop Entry", "Exec", NULL)) {
993+ g_error("Desktop file does not have 'Exec' key");
994+ g_key_file_free(keyfile);
995+ return NULL;
996+ }
997+
998+ gchar * exec = g_key_file_get_string(keyfile, "Desktop Entry", "Exec", NULL);
999+ g_key_file_free(keyfile);
1000+
1001+ gchar * prepend = g_strdup_printf("%s %s", SOCKET_TOOL, exec);
1002+ g_free(exec);
1003+ g_debug("Final Exec line: %s", prepend);
1004+
1005+ gchar * envvar = g_strdup_printf("APP_EXEC=%s", prepend);
1006+ g_free(prepend);
1007+
1008+ return envvar;
1009+}
1010+
1011+gboolean
1012+build_uri_envvar(const gchar * appuris, gchar ** euri, gchar ** esocket)
1013+{
1014+ gint argc;
1015+ gchar ** argv;
1016+ GError * error = NULL;
1017+
1018+ g_shell_parse_argv(appuris, &argc, &argv, &error);
1019+ if (error != NULL) {
1020+ g_critical("Unable to parse URIs '%s': %s", appuris, error->message);
1021+ g_error_free(error);
1022+ return FALSE;
1023+ }
1024+
1025+ if (argc != 2) {
1026+ g_critical("We should be getting 2 entries from '%s' but got %d", appuris, argc);
1027+ g_strfreev(argv);
1028+ return FALSE;
1029+ }
1030+
1031+ *esocket = g_strdup_printf("CONTENT_HUB_MIR_SOCKET=%s", g_shell_quote(argv[0]));
1032+ gchar * quoted = g_shell_quote(argv[1]);
1033+ *euri = g_strdup_printf("APP_URIS=%s", quoted);
1034+
1035+ g_free(quoted);
1036+ g_strfreev(argv);
1037+
1038+ return TRUE;
1039+}
1040+
1041+gchar *
1042+build_dir_envvar (const gchar * appid)
1043+{
1044+ GError * error = NULL;
1045+ gchar * package = NULL;
1046+ /* 'Parse' the App ID */
1047+ if (!ubuntu_app_launch_app_id_parse(appid, &package, NULL, NULL)) {
1048+ g_warning("Unable to parse App ID: '%s'", appid);
1049+ return NULL;
1050+ }
1051+
1052+ /* Check click to find out where the files are */
1053+ ClickDB * db = click_db_new();
1054+ /* If TEST_CLICK_DB is unset, this reads the system database. */
1055+ click_db_read(db, g_getenv("TEST_CLICK_DB"), &error);
1056+ if (error != NULL) {
1057+ g_warning("Unable to read Click database: %s", error->message);
1058+ g_error_free(error);
1059+ g_free(package);
1060+ return NULL;
1061+ }
1062+ /* If TEST_CLICK_USER is unset, this uses the current user name. */
1063+ ClickUser * user = click_user_new_for_user(db, g_getenv("TEST_CLICK_USER"), &error);
1064+ if (error != NULL) {
1065+ g_warning("Unable to read Click database: %s", error->message);
1066+ g_error_free(error);
1067+ g_free(package);
1068+ g_object_unref(db);
1069+ return NULL;
1070+ }
1071+ gchar * pkgdir = click_user_get_path(user, package, &error);
1072+
1073+ g_object_unref(user);
1074+ g_object_unref(db);
1075+ g_free(package);
1076+
1077+ if (error != NULL) {
1078+ g_warning("Unable to get the Click package directory for %s: %s", package, error->message);
1079+ g_error_free(error);
1080+ return NULL;
1081+ }
1082+
1083+ gchar * envvar = g_strdup_printf("APP_DIR=%s", pkgdir);
1084+ g_free(pkgdir);
1085+ return envvar;
1086+}
1087+
1088+int
1089+main (int argc, char * argv[])
1090+{
1091+ g_debug("argc: %d", argc);
1092+ g_debug("argv: %s", g_shell_quote(argv[0]));
1093+ GError * error = NULL;
1094+
1095+ /* Build up our exec */
1096+ const gchar * appid = g_getenv("APP_ID");
1097+ if (appid == NULL) {
1098+ g_error("Environment variable 'APP_ID' required");
1099+ return -1;
1100+ }
1101+
1102+ gchar * envexec = build_exec_envvar(appid);
1103+ if (envexec == NULL) {
1104+ return -1;
1105+ }
1106+
1107+ /* Build up our socket name URL */
1108+ const gchar * appuris = g_getenv("APP_URIS");
1109+ if (appuris == NULL) {
1110+ g_error("Environment variable 'APP_URIS' required");
1111+ g_free(envexec);
1112+ return -1;
1113+ }
1114+
1115+ gchar * envuri = NULL;
1116+ gchar * envsocket = NULL;
1117+
1118+ if (!build_uri_envvar(appuris, &envuri, &envsocket)) {
1119+ g_free(envexec);
1120+ return -1;
1121+ }
1122+
1123+ gchar * envdir = build_dir_envvar(appid);
1124+ /* envdir might be NULL if not a click */
1125+
1126+ /* Execute the setting of the variables! */
1127+
1128+ gchar * initctlargv[7] = {
1129+ "initctl",
1130+ "set-env",
1131+ envexec,
1132+ envuri,
1133+ envsocket,
1134+ envdir,
1135+ NULL
1136+ };
1137+
1138+ g_spawn_sync(
1139+ NULL, /* pwd */
1140+ initctlargv,
1141+ NULL, /* env */
1142+ G_SPAWN_SEARCH_PATH,
1143+ NULL, /* child setup */
1144+ NULL, /* user data ^ */
1145+ NULL, /* stdout */
1146+ NULL, /* stderr */
1147+ NULL, /* return code */
1148+ &error
1149+ );
1150+
1151+ g_free(envexec);
1152+ g_free(envuri);
1153+ g_free(envsocket);
1154+
1155+ if (error == NULL) {
1156+ return 0;
1157+ } else {
1158+ g_error("Unable to spawn 'initctl': %s", error->message);
1159+ g_error_free(error);
1160+ return -1;
1161+ }
1162+}
1163
1164=== added file 'src/helper/exec-tool.cpp'
1165--- src/helper/exec-tool.cpp 1970-01-01 00:00:00 +0000
1166+++ src/helper/exec-tool.cpp 2015-03-18 18:55:05 +0000
1167@@ -0,0 +1,107 @@
1168+/*
1169+ * Copyright (C) 2014-2015 Canonical Ltd.
1170+ *
1171+ * Contact: Ken VanDine <ken.vandine@canonical.com>
1172+ *
1173+ * This file is part of content-hub
1174+ *
1175+ * This program is free software: you can redistribute it and/or modify it
1176+ * under the terms of the GNU General Public License version 3, as published
1177+ * by the Free Software Foundation.
1178+ *
1179+ * This program is distributed in the hope that it will be useful, but
1180+ * WITHOUT ANY WARRANTY; without even the implied warranties of
1181+ * MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
1182+ * PURPOSE. See the GNU General Public License for more details.
1183+ *
1184+ * You should have received a copy of the GNU General Public License along
1185+ * with this program. If not, see <http://www.gnu.org/licenses/>.
1186+ */
1187+
1188+#include <QByteArray>
1189+#include <QCoreApplication>
1190+#include <QDebug>
1191+#include <QProcess>
1192+#include <QStringList>
1193+
1194+QStringList parseParameters(const QByteArray &cmdLine)
1195+{
1196+ QStringList params;
1197+ QByteArray nextParam;
1198+
1199+ bool insideDoubleQuotes = false;
1200+
1201+ for (int i = 0; i < cmdLine.count(); i++) {
1202+ char c = cmdLine.at(i);
1203+ if (c == '\'' && !insideDoubleQuotes) {
1204+ int endQuote = cmdLine.indexOf('\'', i + 1);
1205+ if (Q_UNLIKELY(endQuote < 0)) {
1206+ qWarning() << "Cannot parse parameters" << cmdLine;
1207+ return params;
1208+ }
1209+ nextParam += cmdLine.mid(i + 1, endQuote - i - 1);
1210+ i = endQuote;
1211+ } else if (c == '"') {
1212+ if (insideDoubleQuotes) {
1213+ insideDoubleQuotes = false;
1214+ } else {
1215+ insideDoubleQuotes = true;
1216+ }
1217+ } else if (c == '\\') {
1218+ i++;
1219+ if (Q_UNLIKELY(i == cmdLine.count())) {
1220+ qWarning() << "Incomplete command line" << cmdLine;
1221+ return params;
1222+ }
1223+ nextParam += cmdLine.at(i);
1224+ } else if (c == ' ' && !insideDoubleQuotes) {
1225+ params.append(QString::fromUtf8(nextParam));
1226+ nextParam.clear();
1227+ } else {
1228+ nextParam += cmdLine.at(i);
1229+ }
1230+ }
1231+
1232+ if (!nextParam.isEmpty()) {
1233+ params.append(QString::fromUtf8(nextParam));
1234+ }
1235+
1236+ return params;
1237+}
1238+
1239+int main(int argc, char **argv)
1240+{
1241+ QCoreApplication app(argc, argv);
1242+
1243+ QStringList appUris = parseParameters(qgetenv("APP_URIS"));
1244+ if (Q_UNLIKELY(appUris.count() < 1)) {
1245+ qCritical() << "Missing URIs" << appUris;
1246+ return EXIT_FAILURE;
1247+ }
1248+
1249+ QStringList arguments;
1250+ arguments.append("set-env");
1251+ QString app_id(qgetenv("APP_ID"));
1252+ arguments.append("APP_EXEC=");
1253+ arguments.append(app_id);
1254+
1255+ // Mir socket URL; might be invalid
1256+ QString mirSocket = appUris[0];
1257+ if (!mirSocket.startsWith("invalid")) {
1258+ QString mirUrl =
1259+ QString("MIR_SOCKET=%1").arg(mirSocket);
1260+ arguments.append(mirUrl);
1261+ }
1262+
1263+ arguments.append("CONTENT_HUB_LOGGING_LEVEL=2");
1264+
1265+ QStringList newAppUrisList = appUris.mid(1);
1266+ QString newAppUris = QString("APP_URIS=%1").arg(newAppUrisList.join(' '));
1267+
1268+ arguments.append(newAppUris);
1269+
1270+ int ret = QProcess::execute("initctl", arguments);
1271+
1272+ return (ret >= 0) ? EXIT_SUCCESS : EXIT_FAILURE;
1273+}
1274+
1275
1276=== added file 'src/helper/mir-connection-demangler.c'
1277--- src/helper/mir-connection-demangler.c 1970-01-01 00:00:00 +0000
1278+++ src/helper/mir-connection-demangler.c 2015-03-18 18:55:05 +0000
1279@@ -0,0 +1,126 @@
1280+/*
1281+ * Copyright © 2014-2015 Canonical Ltd.
1282+ *
1283+ * This program is free software: you can redistribute it and/or modify it
1284+ * under the terms of the GNU General Public License version 3, as published
1285+ * by the Free Software Foundation.
1286+ *
1287+ * This program is distributed in the hope that it will be useful, but
1288+ * WITHOUT ANY WARRANTY; without even the implied warranties of
1289+ * MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
1290+ * PURPOSE. See the GNU General Public License for more details.
1291+ *
1292+ * You should have received a copy of the GNU General Public License along
1293+ * with this program. If not, see <http://www.gnu.org/licenses/>.
1294+ *
1295+ * Authors:
1296+ * Ted Gould <ted.gould@canonical.com>
1297+ * Ken VanDine <ken.vandine@canonical.com>
1298+ */
1299+
1300+#include <gio/gio.h>
1301+#include <gio/gunixfdlist.h>
1302+
1303+#include <errno.h>
1304+#include <fcntl.h>
1305+
1306+int
1307+main (int argc, char * argv[])
1308+{
1309+ const gchar * mir_socket = g_getenv("CONTENT_HUB_MIR_SOCKET");
1310+ if (mir_socket == NULL || mir_socket[0] == '\0') {
1311+ g_error("Unable to find Mir connection from Content Hub");
1312+ return -1;
1313+ }
1314+ gchar * mir_socket_unquoted = g_shell_unquote(mir_socket, NULL);
1315+ if (mir_socket_unquoted == NULL) {
1316+ mir_socket_unquoted = g_strdup(mir_socket);
1317+ }
1318+
1319+ g_print("Mir Connection Path: %s\n", mir_socket_unquoted);
1320+
1321+ GError * error = NULL;
1322+ GDBusConnection * bus = g_bus_get_sync(G_BUS_TYPE_SESSION, NULL, &error);
1323+
1324+ if (error != NULL) {
1325+ g_error("Unable to get session bus: %s", error->message);
1326+ g_error_free(error);
1327+ return -1;
1328+ }
1329+
1330+ GVariant * retval;
1331+ GUnixFDList * fdlist;
1332+
1333+ /* Index into fds */
1334+ GVariant* id = g_variant_new_int32(g_strtod(mir_socket_unquoted, NULL));
1335+ g_free(mir_socket_unquoted);
1336+ GVariant* params = g_variant_new_tuple(&id, 1);
1337+
1338+ retval = g_dbus_connection_call_with_unix_fd_list_sync(
1339+ bus,
1340+ "com.ubuntu.content.dbus.Service",
1341+ "/",
1342+ "com.ubuntu.content.dbus.Service",
1343+ "GetMirSocket",
1344+ params,
1345+ G_VARIANT_TYPE("(h)"),
1346+ G_DBUS_CALL_FLAGS_NO_AUTO_START,
1347+ -1, /* timeout */
1348+ NULL, /* fd list in */
1349+ &fdlist,
1350+ NULL, /* cancelable */
1351+ &error);
1352+
1353+ g_clear_object(&bus);
1354+
1355+ if (error != NULL) {
1356+ g_error("Unable to get Mir socket over dbus: %s", error->message);
1357+ g_error_free(error);
1358+ return -1;
1359+ }
1360+
1361+ GVariant * outhandle = g_variant_get_child_value(retval, 0);
1362+
1363+ if (outhandle == NULL) {
1364+ g_error("Unable to get data from function");
1365+ return -1;
1366+ }
1367+
1368+ gint32 handle = g_variant_get_handle(outhandle);
1369+ g_variant_unref(outhandle);
1370+ g_variant_unref(retval);
1371+
1372+ if (handle >= g_unix_fd_list_get_length(fdlist)) {
1373+ g_error("Handle is %d but the FD list only has %d entries", handle, g_unix_fd_list_get_length(fdlist));
1374+ g_clear_object(&fdlist);
1375+ return -1;
1376+ }
1377+
1378+ gint32 fd = g_unix_fd_list_get(fdlist, handle, &error);
1379+ g_clear_object(&fdlist);
1380+
1381+ if (error != NULL) {
1382+ g_error("Unable to Unix FD: %s", error->message);
1383+ g_error_free(error);
1384+ return -1;
1385+ }
1386+
1387+ errno = 0;
1388+ fcntl(fd, F_GETFD);
1389+ if (errno != 0) {
1390+ perror("File descriptor is invalid");
1391+ return -1;
1392+ }
1393+
1394+ /* Make sure the FD doesn't close on exec */
1395+ fcntl(fd, F_SETFD, 0);
1396+
1397+ gchar * mirsocketbuf = g_strdup_printf("fd://%d", fd);
1398+ setenv("MIR_SOCKET", mirsocketbuf, 1);
1399+ g_print("Setting MIR_SOCKET to: '%s'\n", mirsocketbuf);
1400+
1401+ g_free(mirsocketbuf);
1402+
1403+ /* Thought, is argv NULL terminated? */
1404+ return execvp(argv[1], argv + 1);
1405+}
1406
1407=== modified file 'tests/acceptance-tests/app_manager_mock.h'
1408--- tests/acceptance-tests/app_manager_mock.h 2014-02-13 19:11:43 +0000
1409+++ tests/acceptance-tests/app_manager_mock.h 2015-03-18 18:55:05 +0000
1410@@ -30,11 +30,15 @@
1411 using namespace ::testing;
1412
1413 ON_CALL(*this, invoke_application(_)).WillByDefault(Return(true));
1414+ ON_CALL(*this, invoke_application_with_socket(_,_)).WillByDefault(Return(true));
1415+ ON_CALL(*this, stop_application_with_helper(_)).WillByDefault(Return(true));
1416 ON_CALL(*this, stop_application(_)).WillByDefault(Return(true));
1417 ON_CALL(*this, is_application_started(_)).WillByDefault(Return(true));
1418 }
1419
1420 MOCK_METHOD1(invoke_application, bool(const std::string &));
1421+ MOCK_METHOD2(invoke_application_with_socket, bool(const std::string &, const std::string &));
1422+ MOCK_METHOD1(stop_application_with_helper, bool(const std::string &));
1423 MOCK_METHOD1(stop_application, bool(const std::string &));
1424 MOCK_METHOD1(is_application_started, bool(const std::string &));
1425 };

Subscribers

People subscribed via source and target branches