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
=== modified file 'CMakeLists.txt'
--- CMakeLists.txt 2014-08-14 11:49:28 +0000
+++ CMakeLists.txt 2015-03-18 18:55:05 +0000
@@ -16,7 +16,7 @@
1616
17cmake_minimum_required(VERSION 2.8)17cmake_minimum_required(VERSION 2.8)
1818
19project(content-hub)19project (content-hub C CXX)
2020
21set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${CMAKE_CURRENT_SOURCE_DIR}/cmake)21set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${CMAKE_CURRENT_SOURCE_DIR}/cmake)
2222
@@ -24,7 +24,7 @@
24include (EnableCoverageReport)24include (EnableCoverageReport)
25include (GSettings)25include (GSettings)
2626
27set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Werror -Wall -pedantic -Wextra -fPIC -pthread")27#set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Werror -Wall -std=c99 -pedantic -Wextra -fPIC -pthread")
28set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -Werror -Wall -fno-strict-aliasing -pedantic -Wextra -fPIC -pthread -Wno-unused-function")28set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -Werror -Wall -fno-strict-aliasing -pedantic -Wextra -fPIC -pthread -Wno-unused-function")
29set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -Wl,--no-undefined")29set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -Wl,--no-undefined")
3030
@@ -68,6 +68,8 @@
68pkg_check_modules(DBUS REQUIRED dbus-1)68pkg_check_modules(DBUS REQUIRED dbus-1)
69pkg_check_modules(UBUNTU_DOWNLOAD_MANAGER REQUIRED ubuntu-download-manager-client)69pkg_check_modules(UBUNTU_DOWNLOAD_MANAGER REQUIRED ubuntu-download-manager-client)
70pkg_check_modules(NOTIFY REQUIRED libnotify)70pkg_check_modules(NOTIFY REQUIRED libnotify)
71pkg_check_modules(MIRCLIENT REQUIRED mirclient)
72pkg_check_modules(CLICK REQUIRED click-0.4)
7173
72add_definitions(-DDEBUG_ENABLED)74add_definitions(-DDEBUG_ENABLED)
7375
7476
=== modified file 'debian/content-hub.install'
--- debian/content-hub.install 2014-11-18 14:59:03 +0000
+++ debian/content-hub.install 2015-03-18 18:55:05 +0000
@@ -1,5 +1,6 @@
1usr/bin/content-hub-service1usr/bin/content-hub-service
2usr/lib/*/content-hub2usr/lib/*/content-hub
3usr/lib/*/ubuntu-app-launch
3usr/share/click/hooks4usr/share/click/hooks
4usr/share/dbus-15usr/share/dbus-1
5usr/share/glib-2.0/schemas6usr/share/glib-2.0/schemas
67
=== modified file 'debian/control'
--- debian/control 2014-11-18 14:59:03 +0000
+++ debian/control 2015-03-18 18:55:05 +0000
@@ -9,8 +9,10 @@
9 doxygen,9 doxygen,
10 google-mock,10 google-mock,
11 lcov,11 lcov,
12 libclick-0.4-dev,
12 libglib2.0-dev,13 libglib2.0-dev,
13 libgsettings-qt-dev,14 libgsettings-qt-dev,
15 libmirclient-dev [!powerpc !ppc64 !ppc64el],
14 libnih-dbus-dev,16 libnih-dbus-dev,
15 libnotify-dev,17 libnotify-dev,
16 libubuntu-download-manager-client-dev,18 libubuntu-download-manager-client-dev,
1719
=== 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-03-18 18:55:05 +0000
@@ -71,6 +71,7 @@
71 void updateState();71 void updateState();
7272
73private:73private:
74 QString setupPromptSession();
74 QList<ContentTransfer *> m_finishedImports;75 QList<ContentTransfer *> m_finishedImports;
75 QHash<com::ubuntu::content::Transfer *, ContentTransfer *> m_activeImports;76 QHash<com::ubuntu::content::Transfer *, ContentTransfer *> m_activeImports;
76 com::ubuntu::content::Hub *m_hub;77 com::ubuntu::content::Hub *m_hub;
7778
=== modified file 'include/com/ubuntu/content/transfer.h'
--- include/com/ubuntu/content/transfer.h 2014-08-27 13:49:13 +0000
+++ include/com/ubuntu/content/transfer.h 2015-03-18 18:55:05 +0000
@@ -64,6 +64,7 @@
64 Q_PROPERTY(QString contentType READ contentType)64 Q_PROPERTY(QString contentType READ contentType)
65 Q_PROPERTY(QString source READ source)65 Q_PROPERTY(QString source READ source)
66 Q_PROPERTY(QString destination READ destination)66 Q_PROPERTY(QString destination READ destination)
67 Q_PROPERTY(QString mirSocket READ mirSocket WRITE setMirSocket NOTIFY mirSocketChanged)
6768
68 public:69 public:
69 enum State70 enum State
@@ -115,11 +116,14 @@
115 Q_INVOKABLE virtual QString contentType() const;116 Q_INVOKABLE virtual QString contentType() const;
116 Q_INVOKABLE virtual QString source() const;117 Q_INVOKABLE virtual QString source() const;
117 Q_INVOKABLE virtual QString destination() const;118 Q_INVOKABLE virtual QString destination() const;
119 Q_INVOKABLE virtual QString mirSocket() const;
120 Q_INVOKABLE virtual bool setMirSocket(const QString);
118121
119 Q_SIGNAL void stateChanged();122 Q_SIGNAL void stateChanged();
120 Q_SIGNAL void storeChanged();123 Q_SIGNAL void storeChanged();
121 Q_SIGNAL void selectionTypeChanged();124 Q_SIGNAL void selectionTypeChanged();
122 Q_SIGNAL void downloadIdChanged();125 Q_SIGNAL void downloadIdChanged();
126 Q_SIGNAL void mirSocketChanged();
123127
124 private:128 private:
125 struct Private;129 struct Private;
126130
=== modified file 'src/CMakeLists.txt'
--- src/CMakeLists.txt 2013-07-15 11:07:50 +0000
+++ src/CMakeLists.txt 2015-03-18 18:55:05 +0000
@@ -14,4 +14,5 @@
14#14#
15# Authored by: Thomas Voss <thomas.voss@canonical.com>15# Authored by: Thomas Voss <thomas.voss@canonical.com>
1616
17add_subdirectory(com)
18\ No newline at end of file17\ No newline at end of file
18add_subdirectory(com)
19add_subdirectory(helper)
1920
=== modified file 'src/com/ubuntu/applicationmanager/application_manager.h'
--- src/com/ubuntu/applicationmanager/application_manager.h 2014-05-26 06:45:57 +0000
+++ src/com/ubuntu/applicationmanager/application_manager.h 2015-03-18 18:55:05 +0000
@@ -38,6 +38,20 @@
38 * \param app_id ID for the application (for example "gallery-app" - used for the desktop)38 * \param app_id ID for the application (for example "gallery-app" - used for the desktop)
39 */39 */
40 virtual bool invoke_application(const std::string &app_id) = 0;40 virtual bool invoke_application(const std::string &app_id) = 0;
41
42 /*!
43 * \brief invoke_application_with_socket starts an application without a trusted session
44 * \param app_id ID for the application (for example "gallery-app" - used for the desktop)
45 * \param socket path to MIR_SOCKET
46 */
47 virtual bool invoke_application_with_socket(const std::string &app_id, const std::string &socket) = 0;
48
49 /*!
50 * \brief stop_application_with_helper stops an application started by the content-hub helper
51 * \param app_id ID for the application (for example "gallery-app" - used for the desktop)
52 */
53 virtual bool stop_application_with_helper(const std::string &app_id) = 0;
54
41 /*!55 /*!
42 * \brief stop_application stops an application started by ubuntu56 * \brief stop_application stops an application started by ubuntu
43 * \param app_id ID for the application (for example "gallery-app" - used for the desktop)57 * \param app_id ID for the application (for example "gallery-app" - used for the desktop)
4458
=== modified file 'src/com/ubuntu/content/CMakeLists.txt'
--- src/com/ubuntu/content/CMakeLists.txt 2014-05-26 06:45:57 +0000
+++ src/com/ubuntu/content/CMakeLists.txt 2015-03-18 18:55:05 +0000
@@ -28,6 +28,7 @@
28 ${UBUNTU_LAUNCH_INCLUDE_DIRS}28 ${UBUNTU_LAUNCH_INCLUDE_DIRS}
29 ${UBUNTU_DOWNLOAD_MANAGER_INCLUDE_DIRS}29 ${UBUNTU_DOWNLOAD_MANAGER_INCLUDE_DIRS}
30 ${NOTIFY_INCLUDE_DIRS}30 ${NOTIFY_INCLUDE_DIRS}
31 ${MIRCLIENT_INCLUDE_DIRS}
31)32)
3233
33qt5_add_dbus_interface(34qt5_add_dbus_interface(
@@ -77,6 +78,7 @@
77 detail/transfer.cpp78 detail/transfer.cpp
78 detail/handler.cpp79 detail/handler.cpp
79 detail/i18n.cpp80 detail/i18n.cpp
81 detail/mir-helper.cpp
8082
81 ${CONTENT_HUB_MOCS}83 ${CONTENT_HUB_MOCS}
82 ${CONTENT_SERVICE_STUB}84 ${CONTENT_SERVICE_STUB}
@@ -105,6 +107,7 @@
105 ${GIO_LIBRARIES}107 ${GIO_LIBRARIES}
106 ${UBUNTU_DOWNLOAD_MANAGER_LIBRARIES}108 ${UBUNTU_DOWNLOAD_MANAGER_LIBRARIES}
107 ${NOTIFY_LIBRARIES}109 ${NOTIFY_LIBRARIES}
110 ${MIRCLIENT_LIBRARIES}
108)111)
109112
110install(113install(
111114
=== modified file 'src/com/ubuntu/content/detail/app_manager.cpp'
--- src/com/ubuntu/content/detail/app_manager.cpp 2014-05-26 06:45:57 +0000
+++ src/com/ubuntu/content/detail/app_manager.cpp 2015-03-18 18:55:05 +0000
@@ -24,7 +24,6 @@
24/*!24/*!
25 * \reimp25 * \reimp
26 */26 */
27
28bool cucd::AppManager::invoke_application(const std::string &app_id)27bool cucd::AppManager::invoke_application(const std::string &app_id)
29{28{
30 TRACE() << Q_FUNC_INFO << "APP_ID:" << app_id.c_str();29 TRACE() << Q_FUNC_INFO << "APP_ID:" << app_id.c_str();
@@ -36,6 +35,35 @@
36/*!35/*!
37 * \reimp36 * \reimp
38 */37 */
38bool cucd::AppManager::invoke_application_with_socket(const std::string &app_id, const std::string &socket)
39{
40 TRACE() << Q_FUNC_INFO << "APP_ID:" << app_id.c_str();
41 QVector<const gchar*> uris;
42 uris.append(g_strdup_printf("%s", socket.c_str()));
43 uris.append("");
44 uris.append(NULL);
45 TRACE() << Q_FUNC_INFO << "URIS:" << g_strdup_printf("%s", socket.c_str());
46 gboolean ok = ubuntu_app_launch_start_helper("content-hub",
47 app_id.c_str(),
48 uris.constData());
49 return static_cast<bool>(ok);
50}
51
52/*!
53 * \reimp
54 */
55bool cucd::AppManager::stop_application_with_helper(const std::string &app_id)
56{
57 TRACE() << Q_FUNC_INFO << "APP_ID:" << app_id.c_str();
58
59 gboolean ok = ubuntu_app_launch_stop_helper("content-hub",
60 app_id.c_str());
61 return static_cast<bool>(ok);
62}
63
64/*!
65 * \reimp
66 */
39bool cucd::AppManager::stop_application(const std::string &app_id)67bool cucd::AppManager::stop_application(const std::string &app_id)
40{68{
41 TRACE() << Q_FUNC_INFO << "APP_ID:" << app_id.c_str();69 TRACE() << Q_FUNC_INFO << "APP_ID:" << app_id.c_str();
4270
=== modified file 'src/com/ubuntu/content/detail/app_manager.h'
--- src/com/ubuntu/content/detail/app_manager.h 2014-02-13 19:11:43 +0000
+++ src/com/ubuntu/content/detail/app_manager.h 2015-03-18 18:55:05 +0000
@@ -36,6 +36,8 @@
36 AppManager& operator=(const AppManager&) = default;36 AppManager& operator=(const AppManager&) = default;
3737
38 virtual bool invoke_application(const std::string &app_id);38 virtual bool invoke_application(const std::string &app_id);
39 virtual bool invoke_application_with_socket(const std::string &app_id, const std::string &socket);
40 virtual bool stop_application_with_helper(const std::string &app_id);
39 virtual bool stop_application(const std::string &app_id);41 virtual bool stop_application(const std::string &app_id);
40 virtual bool is_application_started(const std::string &app_id);42 virtual bool is_application_started(const std::string &app_id);
41};43};
4244
=== 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-03-18 18:55:05 +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="GetMirSocket">
47 <arg type="i" name="fd" direction="in" />
48 <arg type="h" name="handle" direction="out" />
49 </method>
46 </interface>50 </interface>
47</node>51</node>
4852
=== modified file 'src/com/ubuntu/content/detail/com.ubuntu.content.Transfer.xml'
--- src/com/ubuntu/content/detail/com.ubuntu.content.Transfer.xml 2014-08-27 13:49:13 +0000
+++ src/com/ubuntu/content/detail/com.ubuntu.content.Transfer.xml 2015-03-18 18:55:05 +0000
@@ -64,5 +64,14 @@
64 <method name="destination">64 <method name="destination">
65 <arg name="destination" type="s" direction="out" />65 <arg name="destination" type="s" direction="out" />
66 </method>66 </method>
67 <method name="MirSocket">
68 <arg name="mir_socket" type="s" direction="out" />
69 </method>
70 <method name="SetMirSocket">
71 <arg name="mir_socket" type="s" direction="in" />
72 </method>
73 <signal name="MirSocketChanged">
74 <arg name="mir_socket" type="s"/>
75 </signal>
67 </interface>76 </interface>
68</node>77</node>
6978
=== added file 'src/com/ubuntu/content/detail/mir-helper.cpp'
--- src/com/ubuntu/content/detail/mir-helper.cpp 1970-01-01 00:00:00 +0000
+++ src/com/ubuntu/content/detail/mir-helper.cpp 2015-03-18 18:55:05 +0000
@@ -0,0 +1,235 @@
1/*
2 * Copyright 2015 Canonical Ltd.
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU Lesser General Public License as published by
6 * the Free Software Foundation; version 3.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU Lesser General Public License for more details.
12 *
13 * You should have received a copy of the GNU Lesser General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 */
16
17#include "debug.h"
18#include "mir-helper.h"
19
20#include <mir_toolkit/mir_client_library.h>
21#include <mir_toolkit/mir_prompt_session.h>
22
23#include <QHash>
24#include <QStandardPaths>
25#include <QWeakPointer>
26
27static MirHelper *m_instance = 0;
28
29class PromptSessionPrivate
30{
31public:
32 inline PromptSessionPrivate(MirPromptSession *session, pid_t initiatorPid);
33 inline ~PromptSessionPrivate();
34
35 void emitFinished() { Q_EMIT q_ptr->finished(); }
36
37 MirPromptSession *m_mirSession;
38 pid_t m_initiatorPid;
39 QList<int> m_fds;
40 mutable PromptSession *q_ptr;
41};
42
43class MirHelperPrivate: public QObject
44{
45 Q_OBJECT
46 Q_DECLARE_PUBLIC(MirHelper)
47
48public:
49 inline MirHelperPrivate(MirHelper *helper);
50 inline ~MirHelperPrivate();
51
52 PromptSession *createPromptSession(pid_t initiatorPid);
53 void onSessionStopped(MirPromptSession *mirSession);
54
55private:
56 friend class PromptSession;
57 MirConnection *m_connection;
58 QHash<pid_t,QWeakPointer<PromptSession> > m_sessions;
59 mutable MirHelper *q_ptr;
60};
61
62PromptSessionPrivate::PromptSessionPrivate(MirPromptSession *session,
63 pid_t initiatorPid):
64 m_mirSession(session),
65 m_initiatorPid(initiatorPid)
66{
67 TRACE() << Q_FUNC_INFO;
68}
69
70PromptSessionPrivate::~PromptSessionPrivate()
71{
72 mir_prompt_session_release_sync(m_mirSession);
73 m_mirSession = 0;
74}
75
76PromptSession::PromptSession(PromptSessionPrivate *priv):
77 d_ptr(priv)
78{
79 TRACE() << Q_FUNC_INFO;
80 priv->q_ptr = this;
81}
82
83PromptSession::~PromptSession()
84{
85 TRACE() << Q_FUNC_INFO;
86 Q_D(PromptSession);
87 MirHelperPrivate *helperPrivate = MirHelper::instance()->d_ptr;
88 helperPrivate->m_sessions.remove(d->m_initiatorPid);
89 delete d_ptr;
90}
91
92static void client_fd_callback(MirPromptSession *, size_t count,
93 int const *fds, void *context)
94{
95 TRACE() << Q_FUNC_INFO;
96 PromptSessionPrivate *priv = (PromptSessionPrivate *)context;
97 for (size_t i = 0; i < count; i++) {
98 priv->m_fds.append(fds[i]);
99 }
100}
101
102void PromptSession::release()
103{
104 TRACE() << Q_FUNC_INFO;
105 Q_D(PromptSession);
106 if (d->m_mirSession)
107 mir_prompt_session_release_sync(d->m_mirSession);
108 d->m_mirSession = NULL;
109}
110
111QString PromptSession::requestSocket()
112{
113 TRACE() << Q_FUNC_INFO;
114 Q_D(PromptSession);
115
116 d->m_fds.clear();
117 mir_wait_for(mir_prompt_session_new_fds_for_prompt_providers(
118 d->m_mirSession, 1, client_fd_callback, d));
119 if (!d->m_fds.isEmpty()) {
120 return QString("%1").arg(d->m_fds[0]);
121 } else {
122 return QString();
123 }
124}
125
126MirHelperPrivate::MirHelperPrivate(MirHelper *helper):
127 QObject(helper),
128 q_ptr(helper)
129{
130 TRACE() << Q_FUNC_INFO;
131 QString mirSocket =
132 QStandardPaths::writableLocation(QStandardPaths::RuntimeLocation) +
133 "/mir_socket_trusted";
134 m_connection = mir_connect_sync(mirSocket.toUtf8().constData(),
135 "content-hub-service");
136 if (Q_UNLIKELY(!mir_connection_is_valid(m_connection))) {
137 qWarning() << "Invalid Mir connection:" <<
138 mir_connection_get_error_message(m_connection);
139 return;
140 }
141}
142
143MirHelperPrivate::~MirHelperPrivate()
144{
145 TRACE() << Q_FUNC_INFO;
146 if (m_connection) {
147 mir_connection_release(m_connection);
148 m_connection = 0;
149 }
150}
151
152static void session_event_callback(MirPromptSession *mirSession,
153 MirPromptSessionState state,
154 void *self)
155{
156 TRACE() << Q_FUNC_INFO;
157 MirHelperPrivate *helper = reinterpret_cast<MirHelperPrivate*>(self);
158 TRACE() << "Prompt Session state updated to" << state;
159 if (state == mir_prompt_session_state_stopped) {
160 helper->onSessionStopped(mirSession);
161 }
162}
163
164void MirHelperPrivate::onSessionStopped(MirPromptSession *mirSession)
165{
166 TRACE() << Q_FUNC_INFO;
167 Q_FOREACH(PromptSessionP session, m_sessions) {
168 if (mirSession == session->d_ptr->m_mirSession) {
169 session->d_ptr->emitFinished();
170 }
171 }
172}
173
174PromptSession *MirHelperPrivate::createPromptSession(pid_t initiatorPid)
175{
176 TRACE() << Q_FUNC_INFO << initiatorPid;
177 if (Q_UNLIKELY(!m_connection)) return 0;
178 if (Q_UNLIKELY(!mir_connection_is_valid(m_connection))) return 0;
179
180 MirPromptSession *mirSession =
181 mir_connection_create_prompt_session_sync(m_connection,
182 initiatorPid,
183 session_event_callback,
184 this);
185 if (!mirSession) return 0;
186
187 if (Q_UNLIKELY(!mir_prompt_session_is_valid(mirSession))) {
188 qWarning() << "Invalid prompt session:" <<
189 mir_prompt_session_error_message(mirSession);
190 return 0;
191 }
192
193 return new PromptSession(new PromptSessionPrivate(mirSession, initiatorPid));
194}
195
196MirHelper::MirHelper(QObject *parent):
197 QObject(parent),
198 d_ptr(new MirHelperPrivate(this))
199{
200 TRACE() << Q_FUNC_INFO;
201}
202
203MirHelper::~MirHelper()
204{
205 TRACE() << Q_FUNC_INFO;
206 m_instance = 0;
207}
208
209MirHelper *MirHelper::instance()
210{
211 TRACE() << Q_FUNC_INFO;
212 if (!m_instance) {
213 m_instance = new MirHelper;
214 }
215 return m_instance;
216}
217
218PromptSessionP MirHelper::createPromptSession(pid_t initiatorPid)
219{
220 Q_D(MirHelper);
221 TRACE() << Q_FUNC_INFO << initiatorPid;
222 PromptSessionP session = d->m_sessions.value(initiatorPid);
223 if (session.isNull()) {
224 TRACE() << Q_FUNC_INFO << "Session is NULL";
225 PromptSession *s = d->createPromptSession(initiatorPid);
226 if (s) {
227 TRACE() << Q_FUNC_INFO << "Creating new session";
228 session = PromptSessionP(s);
229 d->m_sessions.insert(initiatorPid, session);
230 }
231 }
232 return session;
233}
234
235#include "mir-helper.moc"
0236
=== added file 'src/com/ubuntu/content/detail/mir-helper.h'
--- src/com/ubuntu/content/detail/mir-helper.h 1970-01-01 00:00:00 +0000
+++ src/com/ubuntu/content/detail/mir-helper.h 2015-03-18 18:55:05 +0000
@@ -0,0 +1,69 @@
1/*
2 * Copyright 2015 Canonical Ltd.
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU Lesser General Public License as published by
6 * the Free Software Foundation; version 3.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU Lesser General Public License for more details.
12 *
13 * You should have received a copy of the GNU Lesser General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 */
16
17#ifndef MIR_HELPER_H
18#define MIR_HELPER_H
19
20#include <QObject>
21#include <QSharedPointer>
22
23class PromptSessionPrivate;
24class MirHelperPrivate;
25
26class PromptSession: public QObject
27{
28 Q_OBJECT
29
30public:
31 ~PromptSession();
32
33 QString requestSocket();
34 void release();
35
36Q_SIGNALS:
37 void finished();
38
39private:
40 explicit PromptSession(PromptSessionPrivate *priv);
41
42private:
43 friend class MirHelperPrivate;
44 PromptSessionPrivate *d_ptr;
45 Q_DECLARE_PRIVATE(PromptSession)
46};
47
48typedef QSharedPointer<PromptSession> PromptSessionP;
49
50class MirHelper: public QObject
51{
52 Q_OBJECT
53
54public:
55 static MirHelper *instance();
56
57 PromptSessionP createPromptSession(pid_t initiatorPid);
58
59private:
60 explicit MirHelper(QObject *parent = 0);
61 ~MirHelper();
62
63private:
64 friend class PromptSession;
65 MirHelperPrivate *d_ptr;
66 Q_DECLARE_PRIVATE(MirHelper)
67};
68
69#endif // MIR_HELPER_H
070
=== modified file 'src/com/ubuntu/content/detail/service.cpp'
--- src/com/ubuntu/content/detail/service.cpp 2014-11-19 18:37:26 +0000
+++ src/com/ubuntu/content/detail/service.cpp 2015-03-18 18:55:05 +0000
@@ -168,7 +168,7 @@
168168
169QDBusObjectPath cucd::Service::CreateImportFromPeer(const QString& peer_id, const QString& app_id, const QString& type_id)169QDBusObjectPath cucd::Service::CreateImportFromPeer(const QString& peer_id, const QString& app_id, const QString& type_id)
170{170{
171 TRACE() << Q_FUNC_INFO;171 TRACE() << Q_FUNC_INFO << "APP_ID:" << app_id << "SERVICE:" << this->message().service();
172 QString dest_id = app_id;172 QString dest_id = app_id;
173 if (dest_id.isEmpty())173 if (dest_id.isEmpty())
174 {174 {
@@ -314,6 +314,12 @@
314 }314 }
315315
316 auto transfer = new cucd::Transfer(import_counter, src_id, dest_id, dir, type_id, this);316 auto transfer = new cucd::Transfer(import_counter, src_id, dest_id, dir, type_id, this);
317 if (dir == cuc::Transfer::Import) {
318 uint clientPid = d->connection.interface()->servicePid(this->message().service());
319 auto mirSocket = setupPromptSession(transfer, clientPid);
320 if (!mirSocket.isEmpty())
321 transfer->SetMirSocket(mirSocket);
322 }
317 new TransferAdaptor(transfer);323 new TransferAdaptor(transfer);
318 d->active_transfers.insert(transfer);324 d->active_transfers.insert(transfer);
319325
@@ -338,6 +344,28 @@
338 return QDBusObjectPath{source};344 return QDBusObjectPath{source};
339}345}
340346
347QString cucd::Service::setupPromptSession(cucd::Transfer* t, uint clientPid)
348{
349 TRACE() << Q_FUNC_INFO << "PID:" << clientPid;
350 if (!m_mirHelper) {
351 TRACE() << "No MirHelper, creating one";
352 m_mirHelper = MirHelper::instance();
353 }
354 PromptSessionP session = m_mirHelper->createPromptSession(clientPid);
355 if (!session) return "";
356
357 QString mirSocket = session->requestSocket();
358 t->SetPromptSession(session);
359 TRACE() << Q_FUNC_INFO << "mirSocket:" << mirSocket;
360
361 /*
362 QObject::connect(session.data(), SIGNAL(finished()),
363 q, SIGNAL(finished()));
364 */
365
366 return mirSocket;
367}
368
341void cucd::Service::handle_imports(int state)369void cucd::Service::handle_imports(int state)
342{370{
343 TRACE() << Q_FUNC_INFO << state;371 TRACE() << Q_FUNC_INFO << state;
@@ -365,14 +393,27 @@
365 }393 }
366 }394 }
367395
368 d->app_manager->invoke_application(transfer->source().toStdString());396 if (transfer->MirSocket().isEmpty() || !transfer->WasSourceStartedByContentHub())
397 d->app_manager->invoke_application(transfer->source().toStdString());
398 else
399 d->app_manager->invoke_application_with_socket(transfer->source().toStdString(), transfer->MirSocket().toStdString());
369 }400 }
370401
371 if (state == cuc::Transfer::charged)402 if (state == cuc::Transfer::charged)
372 {403 {
373 TRACE() << Q_FUNC_INFO << "Charged";404 TRACE() << Q_FUNC_INFO << "Charged";
374 if (transfer->WasSourceStartedByContentHub())405 if (transfer->WasSourceStartedByContentHub()) {
375 d->app_manager->stop_application(transfer->source().toStdString());406 if (!transfer->MirSocket().isEmpty()) {
407 PromptSessionP pSession = transfer->PromptSession();
408 PromptSession* session = pSession.data();
409 if (session)
410 session->release();
411 pSession.clear();
412 d->app_manager->stop_application_with_helper(transfer->source().toStdString());
413 }
414 else
415 d->app_manager->stop_application(transfer->source().toStdString());
416 }
376 417
377 d->app_manager->invoke_application(transfer->destination().toStdString());418 d->app_manager->invoke_application(transfer->destination().toStdString());
378419
@@ -598,3 +639,12 @@
598 }639 }
599 }640 }
600}641}
642
643QDBusUnixFileDescriptor cucd::Service::GetMirSocket(int fd_id)
644{
645 TRACE() << Q_FUNC_INFO << fd_id;
646 auto fd = QDBusUnixFileDescriptor(fd_id);
647 TRACE() << Q_FUNC_INFO << "FD isValid" << fd.isValid();
648 return fd;
649
650}
601651
=== modified file 'src/com/ubuntu/content/detail/service.h'
--- src/com/ubuntu/content/detail/service.h 2014-11-19 18:37:26 +0000
+++ src/com/ubuntu/content/detail/service.h 2015-03-18 18:55:05 +0000
@@ -25,9 +25,11 @@
25#include <QtDBus/QDBusMessage>25#include <QtDBus/QDBusMessage>
26#include <QtDBus/QDBusServiceWatcher>26#include <QtDBus/QDBusServiceWatcher>
27#include <QtDBus/QDBusContext>27#include <QtDBus/QDBusContext>
28#include <QDBusUnixFileDescriptor>
2829
29#include <com/ubuntu/applicationmanager/application_manager.h>30#include <com/ubuntu/applicationmanager/application_manager.h>
30#include "handler.h"31#include "handler.h"
32#include "mir-helper.h"
31#include "transfer.h"33#include "transfer.h"
3234
33namespace com35namespace com
@@ -66,6 +68,7 @@
66 void HandlerActive(const QString&);68 void HandlerActive(const QString&);
67 void Quit();69 void Quit();
68 void DownloadManagerError(QString);70 void DownloadManagerError(QString);
71 QDBusUnixFileDescriptor GetMirSocket(int);
6972
70 private:73 private:
71 bool should_cancel(int);74 bool should_cancel(int);
@@ -73,6 +76,7 @@
73 struct RegHandler;76 struct RegHandler;
74 QDBusServiceWatcher* m_watcher;77 QDBusServiceWatcher* m_watcher;
75 QScopedPointer<Private> d;78 QScopedPointer<Private> d;
79 MirHelper* m_mirHelper = 0;
7680
77 private Q_SLOTS:81 private Q_SLOTS:
78 void handle_imports(int);82 void handle_imports(int);
@@ -80,7 +84,7 @@
80 void handler_unregistered(const QString&);84 void handler_unregistered(const QString&);
81 QDBusObjectPath CreateTransfer(const QString&, const QString&, int, const QString&);85 QDBusObjectPath CreateTransfer(const QString&, const QString&, int, const QString&);
82 void download_notify (com::ubuntu::content::detail::Transfer*);86 void download_notify (com::ubuntu::content::detail::Transfer*);
8387 QString setupPromptSession(com::ubuntu::content::detail::Transfer*, uint);
84};88};
85}89}
86}90}
8791
=== modified file 'src/com/ubuntu/content/detail/transfer.cpp'
--- src/com/ubuntu/content/detail/transfer.cpp 2014-09-26 10:34:39 +0000
+++ src/com/ubuntu/content/detail/transfer.cpp 2015-03-18 18:55:05 +0000
@@ -17,6 +17,7 @@
17 */17 */
1818
19#include "debug.h"19#include "debug.h"
20#include "mir-helper.h"
20#include "transfer.h"21#include "transfer.h"
21#include "utils.cpp"22#include "utils.cpp"
2223
@@ -59,6 +60,8 @@
59 bool source_started_by_content_hub;60 bool source_started_by_content_hub;
60 QString download_id;61 QString download_id;
61 const QString content_type;62 const QString content_type;
63 QString mir_socket = "";
64 PromptSessionP promptSession;
62};65};
6366
64cucd::Transfer::Transfer(const int id,67cucd::Transfer::Transfer(const int id,
@@ -357,12 +360,14 @@
357/* sets, if the source app is freshly started by the content hub */360/* sets, if the source app is freshly started by the content hub */
358void cucd::Transfer::SetSourceStartedByContentHub(bool started)361void cucd::Transfer::SetSourceStartedByContentHub(bool started)
359{362{
363 TRACE() << Q_FUNC_INFO << started;
360 d->source_started_by_content_hub = started;364 d->source_started_by_content_hub = started;
361}365}
362366
363/* returns if the source app was started by the content hub */367/* returns if the source app was started by the content hub */
364bool com::ubuntu::content::detail::Transfer::WasSourceStartedByContentHub() const368bool com::ubuntu::content::detail::Transfer::WasSourceStartedByContentHub() const
365{369{
370 TRACE() << Q_FUNC_INFO << d->source_started_by_content_hub;;
366 return d->source_started_by_content_hub;371 return d->source_started_by_content_hub;
367}372}
368373
@@ -371,3 +376,36 @@
371 TRACE() << __PRETTY_FUNCTION__;376 TRACE() << __PRETTY_FUNCTION__;
372 return d->content_type;377 return d->content_type;
373}378}
379
380QString cucd::Transfer::MirSocket()
381{
382 TRACE() << Q_FUNC_INFO << d->mir_socket;
383 return d->mir_socket;
384}
385
386void cucd::Transfer::SetMirSocket(QString mir_socket)
387{
388 TRACE() << Q_FUNC_INFO << mir_socket;
389
390 if (d->mir_socket == mir_socket)
391 return;
392
393 d->mir_socket = mir_socket;
394 Q_EMIT(MirSocketChanged(d->mir_socket));
395}
396
397PromptSessionP cucd::Transfer::PromptSession()
398{
399 TRACE() << Q_FUNC_INFO;
400 return d->promptSession;
401}
402
403void cucd::Transfer::SetPromptSession(PromptSessionP promptSession)
404{
405 TRACE() << Q_FUNC_INFO;
406
407 if (d->promptSession == promptSession)
408 return;
409
410 d->promptSession = promptSession;
411}
374412
=== modified file 'src/com/ubuntu/content/detail/transfer.h'
--- src/com/ubuntu/content/detail/transfer.h 2014-09-26 10:34:39 +0000
+++ src/com/ubuntu/content/detail/transfer.h 2015-03-18 18:55:05 +0000
@@ -18,6 +18,7 @@
18#ifndef TRANSFER_H_18#ifndef TRANSFER_H_
19#define TRANSFER_H_19#define TRANSFER_H_
2020
21#include "mir-helper.h"
21#include <QObject>22#include <QObject>
22#include <QStringList>23#include <QStringList>
23#include <QDir>24#include <QDir>
@@ -43,6 +44,7 @@
43 Q_PROPERTY(QString destination READ destination)44 Q_PROPERTY(QString destination READ destination)
44 Q_PROPERTY(int direction READ Direction)45 Q_PROPERTY(int direction READ Direction)
45 Q_PROPERTY(QString ContentType READ ContentType)46 Q_PROPERTY(QString ContentType READ ContentType)
47 Q_PROPERTY(QString MirSocket READ MirSocket WRITE SetMirSocket NOTIFY MirSocketChanged)
4648
47 public:49 public:
48 Transfer(const int, const QString&, const QString&, const int, const QString&, QObject* parent = nullptr);50 Transfer(const int, const QString&, const QString&, const int, const QString&, QObject* parent = nullptr);
@@ -60,6 +62,7 @@
60 void SelectionTypeChanged(int SelectionType);62 void SelectionTypeChanged(int SelectionType);
61 void DownloadIdChanged(QString DownloadId);63 void DownloadIdChanged(QString DownloadId);
62 void DownloadManagerError(QString ErrorMessage);64 void DownloadManagerError(QString ErrorMessage);
65 void MirSocketChanged(QString MirSocket);
6366
64 public Q_SLOTS:67 public Q_SLOTS:
65 int State();68 int State();
@@ -86,6 +89,10 @@
86 void DownloadError(Ubuntu::DownloadManager::Error* error);89 void DownloadError(Ubuntu::DownloadManager::Error* error);
87 QString ContentType();90 QString ContentType();
88 void AddItemsFromDir(QDir dir);91 void AddItemsFromDir(QDir dir);
92 QString MirSocket();
93 void SetMirSocket(QString MirSocket);
94 PromptSessionP PromptSession();
95 void SetPromptSession(PromptSessionP promptSession);
8996
90 private:97 private:
91 struct Private;98 struct Private;
9299
=== modified file 'src/com/ubuntu/content/transfer.cpp'
--- src/com/ubuntu/content/transfer.cpp 2014-08-27 13:49:13 +0000
+++ src/com/ubuntu/content/transfer.cpp 2015-03-18 18:55:05 +0000
@@ -136,3 +136,13 @@
136{136{
137 return d->destination();137 return d->destination();
138}138}
139
140QString cuc::Transfer::mirSocket() const
141{
142 return d->mirSocket();
143}
144
145bool cuc::Transfer::setMirSocket(QString socket)
146{
147 return d->setMirSocket(socket);
148}
139149
=== modified file 'src/com/ubuntu/content/transfer_p.h'
--- src/com/ubuntu/content/transfer_p.h 2014-08-27 13:49:13 +0000
+++ src/com/ubuntu/content/transfer_p.h 2015-03-18 18:55:05 +0000
@@ -243,6 +243,25 @@
243 return static_cast<QString>(reply.value());243 return static_cast<QString>(reply.value());
244 }244 }
245245
246 QString mirSocket()
247 {
248 auto reply = remote_transfer->MirSocket();
249 reply.waitForFinished();
250
251 if (reply.isError())
252 return QString();
253
254 return static_cast<QString>(reply.value());
255 }
256
257 bool setMirSocket(QString mir_socket)
258 {
259 auto reply = remote_transfer->SetMirSocket(mir_socket);
260 reply.waitForFinished();
261
262 return not reply.isError();
263 }
264
246 com::ubuntu::content::dbus::Transfer* remote_transfer;265 com::ubuntu::content::dbus::Transfer* remote_transfer;
247};266};
248}267}
249268
=== added directory 'src/helper'
=== added file 'src/helper/CMakeLists.txt'
--- src/helper/CMakeLists.txt 1970-01-01 00:00:00 +0000
+++ src/helper/CMakeLists.txt 2015-03-18 18:55:05 +0000
@@ -0,0 +1,61 @@
1# Copyright © 2013 Canonical Ltd.
2#
3# This program is free software: you can redistribute it and/or modify
4# it under the terms of the GNU General Public License version 3 as
5# published by the Free Software Foundation.
6#
7# This program is distributed in the hope that it will be useful,
8# but WITHOUT ANY WARRANTY; without even the implied warranty of
9# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10# GNU General Public License for more details.
11#
12# You should have received a copy of the GNU General Public License
13# along with this program. If not, see <http://www.gnu.org/licenses/>.
14#
15# Authored by: Thomas Voss <thomas.voss@canonical.com>
16
17set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -g -fPIE ${GCOV_FLAGS}")
18
19include_directories(
20 ${CMAKE_CURRENT_BINARY_DIR}
21 ${UBUNTU_LAUNCH_INCLUDE_DIRS}
22 ${GIO_INCLUDE_DIRS}
23 ${GLIB_INCLUDE_DIRS}
24 ${CLICK_INCLUDE_DIRS}
25)
26
27###########################
28# Mir Connection Demangler
29###########################
30
31add_executable(mir-connection-demangler mir-connection-demangler.c)
32target_link_libraries(mir-connection-demangler ${GLIB_LDFLAGS} ${GIO_LDFLAGS})
33#install(
34# RUNTIME "${CMAKE_CURRENT_BINARY_DIR}/mir-connection-demangler"
35# DESTINATION "${CMAKE_INSTALL_FULL_PKGLIBEXECDIR}"
36#)
37
38#############################
39# Untrusted Helper Exec Tool
40#############################
41
42add_definitions(-DSOCKET_TOOL="${CMAKE_INSTALL_FULL_LIBEXECDIR}/ubuntu-app-launch/content-hub/mir-connection-demangler")
43add_executable(
44 exec-tool
45
46 exec-tool.c
47)
48
49target_link_libraries(
50 exec-tool
51
52 ${UBUNTU_LAUNCH_LDFLAGS}
53 ${CLICK_LDFLAGS}
54 ${GLIB_LDFLAGS}
55 ${GIO_LDFLAGS}
56)
57
58install(
59 PROGRAMS "${CMAKE_CURRENT_BINARY_DIR}/exec-tool" "${CMAKE_CURRENT_BINARY_DIR}/mir-connection-demangler"
60 DESTINATION "${CMAKE_INSTALL_FULL_LIBEXECDIR}/ubuntu-app-launch/content-hub"
61)
062
=== added file 'src/helper/exec-tool.c'
--- src/helper/exec-tool.c 1970-01-01 00:00:00 +0000
+++ src/helper/exec-tool.c 2015-03-18 18:55:05 +0000
@@ -0,0 +1,222 @@
1/*
2 * Copyright © 2014 Canonical Ltd.
3 *
4 * This program is free software: you can redistribute it and/or modify it
5 * under the terms of the GNU General Public License version 3, as published
6 * by the Free Software Foundation.
7 *
8 * This program is distributed in the hope that it will be useful, but
9 * WITHOUT ANY WARRANTY; without even the implied warranties of
10 * MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
11 * PURPOSE. See the GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License along
14 * with this program. If not, see <http://www.gnu.org/licenses/>.
15 *
16 * Authors:
17 * Ted Gould <ted.gould@canonical.com>
18 */
19
20#include <glib.h>
21#include <click.h>
22#include <ubuntu-app-launch.h>
23
24gchar *
25build_exec_envvar (const gchar * appid)
26{
27 gchar * appid_desktop = g_strdup_printf("%s.desktop", appid);
28 /* FIXME: We need our hook to create our own symlink to the desktop file to use */
29 gchar * desktopfilepath = g_build_filename(g_get_user_cache_dir(), "ubuntu-app-launch", "desktop", appid_desktop, NULL);
30 g_free(appid_desktop);
31
32 if (!g_file_test(desktopfilepath, G_FILE_TEST_EXISTS)) {
33 g_error("Can not file desktop file for '%s', expecting: '%s'", appid, desktopfilepath);
34 g_free(desktopfilepath);
35 return NULL;
36 }
37
38 GError * error = NULL;
39 GKeyFile * keyfile = g_key_file_new();
40 g_key_file_load_from_file(keyfile, desktopfilepath, G_KEY_FILE_NONE, &error);
41
42 if (error != NULL) {
43 g_error("Unable to read content-hub desktop file '%s': %s", desktopfilepath, error->message);
44 g_free(desktopfilepath);
45 g_key_file_free(keyfile);
46 g_error_free(error);
47 return NULL;
48 }
49
50 g_free(desktopfilepath);
51
52 if (!g_key_file_has_key(keyfile, "Desktop Entry", "Exec", NULL)) {
53 g_error("Desktop file does not have 'Exec' key");
54 g_key_file_free(keyfile);
55 return NULL;
56 }
57
58 gchar * exec = g_key_file_get_string(keyfile, "Desktop Entry", "Exec", NULL);
59 g_key_file_free(keyfile);
60
61 gchar * prepend = g_strdup_printf("%s %s", SOCKET_TOOL, exec);
62 g_free(exec);
63 g_debug("Final Exec line: %s", prepend);
64
65 gchar * envvar = g_strdup_printf("APP_EXEC=%s", prepend);
66 g_free(prepend);
67
68 return envvar;
69}
70
71gboolean
72build_uri_envvar(const gchar * appuris, gchar ** euri, gchar ** esocket)
73{
74 gint argc;
75 gchar ** argv;
76 GError * error = NULL;
77
78 g_shell_parse_argv(appuris, &argc, &argv, &error);
79 if (error != NULL) {
80 g_critical("Unable to parse URIs '%s': %s", appuris, error->message);
81 g_error_free(error);
82 return FALSE;
83 }
84
85 if (argc != 2) {
86 g_critical("We should be getting 2 entries from '%s' but got %d", appuris, argc);
87 g_strfreev(argv);
88 return FALSE;
89 }
90
91 *esocket = g_strdup_printf("CONTENT_HUB_MIR_SOCKET=%s", g_shell_quote(argv[0]));
92 gchar * quoted = g_shell_quote(argv[1]);
93 *euri = g_strdup_printf("APP_URIS=%s", quoted);
94
95 g_free(quoted);
96 g_strfreev(argv);
97
98 return TRUE;
99}
100
101gchar *
102build_dir_envvar (const gchar * appid)
103{
104 GError * error = NULL;
105 gchar * package = NULL;
106 /* 'Parse' the App ID */
107 if (!ubuntu_app_launch_app_id_parse(appid, &package, NULL, NULL)) {
108 g_warning("Unable to parse App ID: '%s'", appid);
109 return NULL;
110 }
111
112 /* Check click to find out where the files are */
113 ClickDB * db = click_db_new();
114 /* If TEST_CLICK_DB is unset, this reads the system database. */
115 click_db_read(db, g_getenv("TEST_CLICK_DB"), &error);
116 if (error != NULL) {
117 g_warning("Unable to read Click database: %s", error->message);
118 g_error_free(error);
119 g_free(package);
120 return NULL;
121 }
122 /* If TEST_CLICK_USER is unset, this uses the current user name. */
123 ClickUser * user = click_user_new_for_user(db, g_getenv("TEST_CLICK_USER"), &error);
124 if (error != NULL) {
125 g_warning("Unable to read Click database: %s", error->message);
126 g_error_free(error);
127 g_free(package);
128 g_object_unref(db);
129 return NULL;
130 }
131 gchar * pkgdir = click_user_get_path(user, package, &error);
132
133 g_object_unref(user);
134 g_object_unref(db);
135 g_free(package);
136
137 if (error != NULL) {
138 g_warning("Unable to get the Click package directory for %s: %s", package, error->message);
139 g_error_free(error);
140 return NULL;
141 }
142
143 gchar * envvar = g_strdup_printf("APP_DIR=%s", pkgdir);
144 g_free(pkgdir);
145 return envvar;
146}
147
148int
149main (int argc, char * argv[])
150{
151 g_debug("argc: %d", argc);
152 g_debug("argv: %s", g_shell_quote(argv[0]));
153 GError * error = NULL;
154
155 /* Build up our exec */
156 const gchar * appid = g_getenv("APP_ID");
157 if (appid == NULL) {
158 g_error("Environment variable 'APP_ID' required");
159 return -1;
160 }
161
162 gchar * envexec = build_exec_envvar(appid);
163 if (envexec == NULL) {
164 return -1;
165 }
166
167 /* Build up our socket name URL */
168 const gchar * appuris = g_getenv("APP_URIS");
169 if (appuris == NULL) {
170 g_error("Environment variable 'APP_URIS' required");
171 g_free(envexec);
172 return -1;
173 }
174
175 gchar * envuri = NULL;
176 gchar * envsocket = NULL;
177
178 if (!build_uri_envvar(appuris, &envuri, &envsocket)) {
179 g_free(envexec);
180 return -1;
181 }
182
183 gchar * envdir = build_dir_envvar(appid);
184 /* envdir might be NULL if not a click */
185
186 /* Execute the setting of the variables! */
187
188 gchar * initctlargv[7] = {
189 "initctl",
190 "set-env",
191 envexec,
192 envuri,
193 envsocket,
194 envdir,
195 NULL
196 };
197
198 g_spawn_sync(
199 NULL, /* pwd */
200 initctlargv,
201 NULL, /* env */
202 G_SPAWN_SEARCH_PATH,
203 NULL, /* child setup */
204 NULL, /* user data ^ */
205 NULL, /* stdout */
206 NULL, /* stderr */
207 NULL, /* return code */
208 &error
209 );
210
211 g_free(envexec);
212 g_free(envuri);
213 g_free(envsocket);
214
215 if (error == NULL) {
216 return 0;
217 } else {
218 g_error("Unable to spawn 'initctl': %s", error->message);
219 g_error_free(error);
220 return -1;
221 }
222}
0223
=== added file 'src/helper/exec-tool.cpp'
--- src/helper/exec-tool.cpp 1970-01-01 00:00:00 +0000
+++ src/helper/exec-tool.cpp 2015-03-18 18:55:05 +0000
@@ -0,0 +1,107 @@
1/*
2 * Copyright (C) 2014-2015 Canonical Ltd.
3 *
4 * Contact: Ken VanDine <ken.vandine@canonical.com>
5 *
6 * This file is part of content-hub
7 *
8 * This program is free software: you can redistribute it and/or modify it
9 * under the terms of the GNU General Public License version 3, as published
10 * by the Free Software Foundation.
11 *
12 * This program is distributed in the hope that it will be useful, but
13 * WITHOUT ANY WARRANTY; without even the implied warranties of
14 * MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
15 * PURPOSE. See the GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License along
18 * with this program. If not, see <http://www.gnu.org/licenses/>.
19 */
20
21#include <QByteArray>
22#include <QCoreApplication>
23#include <QDebug>
24#include <QProcess>
25#include <QStringList>
26
27QStringList parseParameters(const QByteArray &cmdLine)
28{
29 QStringList params;
30 QByteArray nextParam;
31
32 bool insideDoubleQuotes = false;
33
34 for (int i = 0; i < cmdLine.count(); i++) {
35 char c = cmdLine.at(i);
36 if (c == '\'' && !insideDoubleQuotes) {
37 int endQuote = cmdLine.indexOf('\'', i + 1);
38 if (Q_UNLIKELY(endQuote < 0)) {
39 qWarning() << "Cannot parse parameters" << cmdLine;
40 return params;
41 }
42 nextParam += cmdLine.mid(i + 1, endQuote - i - 1);
43 i = endQuote;
44 } else if (c == '"') {
45 if (insideDoubleQuotes) {
46 insideDoubleQuotes = false;
47 } else {
48 insideDoubleQuotes = true;
49 }
50 } else if (c == '\\') {
51 i++;
52 if (Q_UNLIKELY(i == cmdLine.count())) {
53 qWarning() << "Incomplete command line" << cmdLine;
54 return params;
55 }
56 nextParam += cmdLine.at(i);
57 } else if (c == ' ' && !insideDoubleQuotes) {
58 params.append(QString::fromUtf8(nextParam));
59 nextParam.clear();
60 } else {
61 nextParam += cmdLine.at(i);
62 }
63 }
64
65 if (!nextParam.isEmpty()) {
66 params.append(QString::fromUtf8(nextParam));
67 }
68
69 return params;
70}
71
72int main(int argc, char **argv)
73{
74 QCoreApplication app(argc, argv);
75
76 QStringList appUris = parseParameters(qgetenv("APP_URIS"));
77 if (Q_UNLIKELY(appUris.count() < 1)) {
78 qCritical() << "Missing URIs" << appUris;
79 return EXIT_FAILURE;
80 }
81
82 QStringList arguments;
83 arguments.append("set-env");
84 QString app_id(qgetenv("APP_ID"));
85 arguments.append("APP_EXEC=");
86 arguments.append(app_id);
87
88 // Mir socket URL; might be invalid
89 QString mirSocket = appUris[0];
90 if (!mirSocket.startsWith("invalid")) {
91 QString mirUrl =
92 QString("MIR_SOCKET=%1").arg(mirSocket);
93 arguments.append(mirUrl);
94 }
95
96 arguments.append("CONTENT_HUB_LOGGING_LEVEL=2");
97
98 QStringList newAppUrisList = appUris.mid(1);
99 QString newAppUris = QString("APP_URIS=%1").arg(newAppUrisList.join(' '));
100
101 arguments.append(newAppUris);
102
103 int ret = QProcess::execute("initctl", arguments);
104
105 return (ret >= 0) ? EXIT_SUCCESS : EXIT_FAILURE;
106}
107
0108
=== added file 'src/helper/mir-connection-demangler.c'
--- src/helper/mir-connection-demangler.c 1970-01-01 00:00:00 +0000
+++ src/helper/mir-connection-demangler.c 2015-03-18 18:55:05 +0000
@@ -0,0 +1,126 @@
1/*
2 * Copyright © 2014-2015 Canonical Ltd.
3 *
4 * This program is free software: you can redistribute it and/or modify it
5 * under the terms of the GNU General Public License version 3, as published
6 * by the Free Software Foundation.
7 *
8 * This program is distributed in the hope that it will be useful, but
9 * WITHOUT ANY WARRANTY; without even the implied warranties of
10 * MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
11 * PURPOSE. See the GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License along
14 * with this program. If not, see <http://www.gnu.org/licenses/>.
15 *
16 * Authors:
17 * Ted Gould <ted.gould@canonical.com>
18 * Ken VanDine <ken.vandine@canonical.com>
19 */
20
21#include <gio/gio.h>
22#include <gio/gunixfdlist.h>
23
24#include <errno.h>
25#include <fcntl.h>
26
27int
28main (int argc, char * argv[])
29{
30 const gchar * mir_socket = g_getenv("CONTENT_HUB_MIR_SOCKET");
31 if (mir_socket == NULL || mir_socket[0] == '\0') {
32 g_error("Unable to find Mir connection from Content Hub");
33 return -1;
34 }
35 gchar * mir_socket_unquoted = g_shell_unquote(mir_socket, NULL);
36 if (mir_socket_unquoted == NULL) {
37 mir_socket_unquoted = g_strdup(mir_socket);
38 }
39
40 g_print("Mir Connection Path: %s\n", mir_socket_unquoted);
41
42 GError * error = NULL;
43 GDBusConnection * bus = g_bus_get_sync(G_BUS_TYPE_SESSION, NULL, &error);
44
45 if (error != NULL) {
46 g_error("Unable to get session bus: %s", error->message);
47 g_error_free(error);
48 return -1;
49 }
50
51 GVariant * retval;
52 GUnixFDList * fdlist;
53
54 /* Index into fds */
55 GVariant* id = g_variant_new_int32(g_strtod(mir_socket_unquoted, NULL));
56 g_free(mir_socket_unquoted);
57 GVariant* params = g_variant_new_tuple(&id, 1);
58
59 retval = g_dbus_connection_call_with_unix_fd_list_sync(
60 bus,
61 "com.ubuntu.content.dbus.Service",
62 "/",
63 "com.ubuntu.content.dbus.Service",
64 "GetMirSocket",
65 params,
66 G_VARIANT_TYPE("(h)"),
67 G_DBUS_CALL_FLAGS_NO_AUTO_START,
68 -1, /* timeout */
69 NULL, /* fd list in */
70 &fdlist,
71 NULL, /* cancelable */
72 &error);
73
74 g_clear_object(&bus);
75
76 if (error != NULL) {
77 g_error("Unable to get Mir socket over dbus: %s", error->message);
78 g_error_free(error);
79 return -1;
80 }
81
82 GVariant * outhandle = g_variant_get_child_value(retval, 0);
83
84 if (outhandle == NULL) {
85 g_error("Unable to get data from function");
86 return -1;
87 }
88
89 gint32 handle = g_variant_get_handle(outhandle);
90 g_variant_unref(outhandle);
91 g_variant_unref(retval);
92
93 if (handle >= g_unix_fd_list_get_length(fdlist)) {
94 g_error("Handle is %d but the FD list only has %d entries", handle, g_unix_fd_list_get_length(fdlist));
95 g_clear_object(&fdlist);
96 return -1;
97 }
98
99 gint32 fd = g_unix_fd_list_get(fdlist, handle, &error);
100 g_clear_object(&fdlist);
101
102 if (error != NULL) {
103 g_error("Unable to Unix FD: %s", error->message);
104 g_error_free(error);
105 return -1;
106 }
107
108 errno = 0;
109 fcntl(fd, F_GETFD);
110 if (errno != 0) {
111 perror("File descriptor is invalid");
112 return -1;
113 }
114
115 /* Make sure the FD doesn't close on exec */
116 fcntl(fd, F_SETFD, 0);
117
118 gchar * mirsocketbuf = g_strdup_printf("fd://%d", fd);
119 setenv("MIR_SOCKET", mirsocketbuf, 1);
120 g_print("Setting MIR_SOCKET to: '%s'\n", mirsocketbuf);
121
122 g_free(mirsocketbuf);
123
124 /* Thought, is argv NULL terminated? */
125 return execvp(argv[1], argv + 1);
126}
0127
=== modified file 'tests/acceptance-tests/app_manager_mock.h'
--- tests/acceptance-tests/app_manager_mock.h 2014-02-13 19:11:43 +0000
+++ tests/acceptance-tests/app_manager_mock.h 2015-03-18 18:55:05 +0000
@@ -30,11 +30,15 @@
30 using namespace ::testing;30 using namespace ::testing;
3131
32 ON_CALL(*this, invoke_application(_)).WillByDefault(Return(true));32 ON_CALL(*this, invoke_application(_)).WillByDefault(Return(true));
33 ON_CALL(*this, invoke_application_with_socket(_,_)).WillByDefault(Return(true));
34 ON_CALL(*this, stop_application_with_helper(_)).WillByDefault(Return(true));
33 ON_CALL(*this, stop_application(_)).WillByDefault(Return(true));35 ON_CALL(*this, stop_application(_)).WillByDefault(Return(true));
34 ON_CALL(*this, is_application_started(_)).WillByDefault(Return(true));36 ON_CALL(*this, is_application_started(_)).WillByDefault(Return(true));
35 }37 }
3638
37 MOCK_METHOD1(invoke_application, bool(const std::string &));39 MOCK_METHOD1(invoke_application, bool(const std::string &));
40 MOCK_METHOD2(invoke_application_with_socket, bool(const std::string &, const std::string &));
41 MOCK_METHOD1(stop_application_with_helper, bool(const std::string &));
38 MOCK_METHOD1(stop_application, bool(const std::string &));42 MOCK_METHOD1(stop_application, bool(const std::string &));
39 MOCK_METHOD1(is_application_started, bool(const std::string &));43 MOCK_METHOD1(is_application_started, bool(const std::string &));
40};44};

Subscribers

People subscribed via source and target branches