Merge lp:~nick-dedekind/unity-mir/unity-mir.trusted_sessions into lp:unity-mir

Proposed by Nick Dedekind
Status: Merged
Merged at revision: 241
Proposed branch: lp:~nick-dedekind/unity-mir/unity-mir.trusted_sessions
Merge into: lp:unity-mir
Diff against target: 1073 lines (+438/-123)
14 files modified
src/modules/Unity/Application/ApplicationImage.qml (+8/-0)
src/modules/Unity/Application/CMakeLists.txt (+4/-2)
src/modules/Unity/Application/application.cpp (+33/-11)
src/modules/Unity/Application/application.h (+18/-4)
src/modules/Unity/Application/application_manager.cpp (+196/-86)
src/modules/Unity/Application/application_manager.h (+11/-6)
src/modules/Unity/Application/applicationscreenshotprovider.cpp (+4/-2)
src/modules/Unity/Application/dbuswindowstack.cpp (+1/-1)
src/modules/Unity/Application/mirsurfacemanager.cpp (+13/-10)
src/modules/Unity/Application/session.cpp (+70/-0)
src/modules/Unity/Application/session.h (+60/-0)
src/unity-mir/sessionlistener.cpp (+13/-0)
src/unity-mir/sessionlistener.h (+6/-0)
src/unity-mir/shellserverconfiguration.cpp (+1/-1)
To merge this branch: bzr merge lp:~nick-dedekind/unity-mir/unity-mir.trusted_sessions
Reviewer Review Type Date Requested Status
Mir development team Pending
Review via email: mp+208324@code.launchpad.net
To post a comment you must log in.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'src/modules/Unity/Application/ApplicationImage.qml'
--- src/modules/Unity/Application/ApplicationImage.qml 2013-10-01 17:45:26 +0000
+++ src/modules/Unity/Application/ApplicationImage.qml 2014-02-26 10:27:46 +0000
@@ -40,4 +40,12 @@
40 source: (root.source) ? "image://screenshot/" + root.source.appId : ""40 source: (root.source) ? "image://screenshot/" + root.source.appId : ""
41 cache: false41 cache: false
42 }42 }
43
44 Connections {
45 target: source
46 onSessionChanged: {
47 console.log("SESSION CHANGED");
48 scheduleUpdate();
49 }
50 }
43}51}
4452
=== modified file 'src/modules/Unity/Application/CMakeLists.txt'
--- src/modules/Unity/Application/CMakeLists.txt 2014-01-27 11:29:44 +0000
+++ src/modules/Unity/Application/CMakeLists.txt 2014-02-26 10:27:46 +0000
@@ -32,6 +32,7 @@
32 processcontroller.h32 processcontroller.h
33 processcontroller.cpp33 processcontroller.cpp
34 shellinputarea.cpp34 shellinputarea.cpp
35 session.cpp
35 ubuntukeyboardinfo.cpp36 ubuntukeyboardinfo.cpp
3637
37 upstart/applicationcontroller.h38 upstart/applicationcontroller.h
@@ -47,10 +48,11 @@
47 mirsurface.h48 mirsurface.h
48 mirsurfacemanager.h49 mirsurfacemanager.h
49 shellinputarea.h50 shellinputarea.h
51 session.h
50 inputarea.h52 inputarea.h
51 inputfilterarea.h53 inputfilterarea.h
52 ubuntukeyboardinfo.h54 ubuntukeyboardinfo.h
53 55
54 # We need to pull in some external header files56 # We need to pull in some external header files
55 /usr/include/unity/shell/application/ApplicationManagerInterface.h57 /usr/include/unity/shell/application/ApplicationManagerInterface.h
56 /usr/include/unity/shell/application/ApplicationInfoInterface.h58 /usr/include/unity/shell/application/ApplicationInfoInterface.h
@@ -62,7 +64,7 @@
6264
63target_link_libraries(65target_link_libraries(
64 unityapplicationplugin66 unityapplicationplugin
65 67
66 unity-mir68 unity-mir
6769
68 ubuntu_application_api_mirserver70 ubuntu_application_api_mirserver
6971
=== modified file 'src/modules/Unity/Application/application.cpp'
--- src/modules/Unity/Application/application.cpp 2014-01-27 11:29:44 +0000
+++ src/modules/Unity/Application/application.cpp 2014-02-26 10:27:46 +0000
@@ -22,11 +22,13 @@
2222
23// unity-mir23// unity-mir
24#include "logging.h"24#include "logging.h"
25#include "session.h"
2526
26// mir27// mir
27#include <mir/shell/session.h>
28#include <mir/shell/snapshot.h>28#include <mir/shell/snapshot.h>
2929
30#include <QDebug>
31
30Application::Application(const QSharedPointer<TaskController>& taskController,32Application::Application(const QSharedPointer<TaskController>& taskController,
31 DesktopFileReader *desktopFileReader,33 DesktopFileReader *desktopFileReader,
32 State state,34 State state,
@@ -120,9 +122,16 @@
120 return m_fullscreen;122 return m_fullscreen;
121}123}
122124
123std::shared_ptr<mir::shell::Session> Application::session() const125QSharedPointer<Session> Application::session() const
124{126{
125 return m_session;127 if (!m_overrideSession.isNull())
128 return m_overrideSession;
129 return m_session.toStrongRef();
130}
131
132QSharedPointer<Session> Application::overrideSession() const
133{
134 return m_overrideSession;
126}135}
127136
128pid_t Application::pid() const137pid_t Application::pid() const
@@ -135,12 +144,25 @@
135 m_pid = pid;144 m_pid = pid;
136}145}
137146
138void Application::setSession(const std::shared_ptr<mir::shell::Session>& session)147void Application::setSession(const QSharedPointer<Session>& new_session)
139{148{
140 DLOG("Application::setSession (this=%p, session=%p)", this, session.get());149 DLOG("Application::setSession (this=%p, session=%p)", this, new_session ? new_session->mirSession().get() : nullptr);
141150
142 // TODO(greyback) what if called with new surface?151 // TODO(greyback) what if called with new surface?
143 m_session = session;152 m_session = new_session.toWeakRef();
153 if (session()) {
154 Q_EMIT sessionChanged();
155 }
156}
157
158void Application::setOverrideSession(const QSharedPointer<Session>& override_session)
159{
160 DLOG("Application::setOverrideSession (this=%p, session=%p)", this, override_session ? override_session->mirSession().get() : nullptr);
161
162 m_overrideSession = override_session;
163 if (session()) {
164 Q_EMIT sessionChanged();
165 }
144}166}
145167
146void Application::setSessionName(const QString& name)168void Application::setSessionName(const QString& name)
@@ -169,8 +191,8 @@
169 switch (state)191 switch (state)
170 {192 {
171 case Application::Suspended:193 case Application::Suspended:
172 if (m_state == Application::Running) {194 if (session() && m_state == Application::Running) {
173 session()->set_lifecycle_state(mir_lifecycle_state_will_suspend);195 session()->setLifecycleState(mir_lifecycle_state_will_suspend);
174 m_suspendTimer->start(3000);196 m_suspendTimer->start(3000);
175 }197 }
176 break;198 break;
@@ -178,9 +200,9 @@
178 if (m_suspendTimer->isActive())200 if (m_suspendTimer->isActive())
179 m_suspendTimer->stop();201 m_suspendTimer->stop();
180202
181 if (m_state == Application::Suspended) {203 if (session() && m_state == Application::Suspended) {
182 resume();204 resume();
183 session()->set_lifecycle_state(mir_lifecycle_state_resumed);205 session()->setLifecycleState(mir_lifecycle_state_resumed);
184 } else if (m_state == Application::Stopped) {206 } else if (m_state == Application::Stopped) {
185 respawn();207 respawn();
186 state = Application::Starting;208 state = Application::Starting;
187209
=== modified file 'src/modules/Unity/Application/application.h'
--- src/modules/Unity/Application/application.h 2014-01-27 11:29:44 +0000
+++ src/modules/Unity/Application/application.h 2014-02-26 10:27:46 +0000
@@ -31,7 +31,14 @@
31class QImage;31class QImage;
32class DesktopFileReader;32class DesktopFileReader;
33class TaskController;33class TaskController;
34namespace mir { namespace shell { class Session; }}34class Session;
35namespace mir
36{
37namespace shell
38{
39class TrustedSession;
40}
41}
3542
36class Application : public unity::shell::application::ApplicationInfoInterface {43class Application : public unity::shell::application::ApplicationInfoInterface {
37 Q_OBJECT44 Q_OBJECT
@@ -63,9 +70,11 @@
63 QString desktopFile() const;70 QString desktopFile() const;
64 QString exec() const;71 QString exec() const;
65 bool fullscreen() const;72 bool fullscreen() const;
66 std::shared_ptr<mir::shell::Session> session() const;
67 pid_t pid() const;73 pid_t pid() const;
6874
75 QSharedPointer<Session> session() const;
76 QSharedPointer<Session> overrideSession() const;
77
69public Q_SLOTS:78public Q_SLOTS:
70 void suspend();79 void suspend();
71 void resume();80 void resume();
@@ -74,15 +83,18 @@
74Q_SIGNALS:83Q_SIGNALS:
75 void fullscreenChanged();84 void fullscreenChanged();
76 void stageChanged(Stage stage);85 void stageChanged(Stage stage);
86 void sessionChanged();
7787
78private:88private:
79 void setPid(pid_t pid);89 void setPid(pid_t pid);
80 void setState(State state);90 void setState(State state);
81 void setFocused(bool focus);91 void setFocused(bool focus);
82 void setFullscreen(bool fullscreen);92 void setFullscreen(bool fullscreen);
83 void setSession(const std::shared_ptr<mir::shell::Session>& session);
84 void setSessionName(const QString& name);93 void setSessionName(const QString& name);
8594
95 void setSession(const QSharedPointer<Session>& session);
96 void setOverrideSession(const QSharedPointer<Session>& session);
97
86 QSharedPointer<TaskController> m_taskController;98 QSharedPointer<TaskController> m_taskController;
87 DesktopFileReader* m_desktopData;99 DesktopFileReader* m_desktopData;
88 qint64 m_pid;100 qint64 m_pid;
@@ -90,7 +102,9 @@
90 State m_state;102 State m_state;
91 bool m_focused;103 bool m_focused;
92 bool m_fullscreen;104 bool m_fullscreen;
93 std::shared_ptr<mir::shell::Session> m_session;105 QWeakPointer<Session> m_session;
106 QSharedPointer<Session> m_overrideSession;
107
94 QString m_sessionName;108 QString m_sessionName;
95 QStringList m_arguments;109 QStringList m_arguments;
96 QTimer* m_suspendTimer;110 QTimer* m_suspendTimer;
97111
=== modified file 'src/modules/Unity/Application/application_manager.cpp'
--- src/modules/Unity/Application/application_manager.cpp 2014-02-11 09:47:56 +0000
+++ src/modules/Unity/Application/application_manager.cpp 2014-02-26 10:27:46 +0000
@@ -31,15 +31,18 @@
31#include "surfacefactory.h"31#include "surfacefactory.h"
32#include "taskcontroller.h"32#include "taskcontroller.h"
33#include "logging.h"33#include "logging.h"
34#include "session.h"
3435
35// mir36// mir
36#include <mir/scene/depth_id.h>37#include <mir/scene/depth_id.h>
37#include <mir/shell/session.h>38#include <mir/shell/session.h>
38#include <mir/shell/focus_controller.h>39#include <mir/shell/focus_controller.h>
39#include <mir/shell/surface.h>40#include <mir/shell/surface.h>
41#include <mir/shell/trusted_session.h>
40#include <mir/graphics/display.h>42#include <mir/graphics/display.h>
41#include <mir/graphics/display_buffer.h>43#include <mir/graphics/display_buffer.h>
42#include <mircommon/mir/geometry/rectangles.h>44#include <mircommon/mir/geometry/rectangles.h>
45#include <mir/frontend/shell.h>
4346
44// Qt47// Qt
45#include <QCoreApplication>48#include <QCoreApplication>
@@ -53,6 +56,11 @@
5356
54ApplicationManager *ApplicationManager::the_application_manager = nullptr;57ApplicationManager *ApplicationManager::the_application_manager = nullptr;
5558
59QList<QByteArray> ApplicationManager::whiteListApps({ "maliit-server",
60 "/usr/lib/arm-linux-gnueabihf/qt5/libexec/QtWebProcess",
61 "/usr/bin/signon-ui",
62 "/usr/bin/mir_demo_client_trusted_session_trusted" });
63
56ApplicationManager* ApplicationManager::singleton()64ApplicationManager* ApplicationManager::singleton()
57{65{
58 if (!the_application_manager) {66 if (!the_application_manager) {
@@ -82,7 +90,6 @@
82 , m_taskController(taskController)90 , m_taskController(taskController)
83 , m_desktopFileReaderFactory(desktopFileReaderFactory)91 , m_desktopFileReaderFactory(desktopFileReaderFactory)
84 , m_gridUnitPx(8)92 , m_gridUnitPx(8)
85 , m_fenceNext(false)
86 , m_panelHeight(54)93 , m_panelHeight(54)
87{94{
88 DLOG("ApplicationManager::ApplicationManager (this=%p)", this);95 DLOG("ApplicationManager::ApplicationManager (this=%p)", this);
@@ -105,6 +112,10 @@
105 this, &ApplicationManager::onSessionUnfocused);112 this, &ApplicationManager::onSessionUnfocused);
106 QObject::connect(m_mirServer->sessionListener(), &SessionListener::sessionCreatedSurface,113 QObject::connect(m_mirServer->sessionListener(), &SessionListener::sessionCreatedSurface,
107 this, &ApplicationManager::onSessionCreatedSurface);114 this, &ApplicationManager::onSessionCreatedSurface);
115 QObject::connect(m_mirServer->sessionListener(), &SessionListener::trustedSessionStarted,
116 this, &ApplicationManager::onTrustedSessionStarted);
117 QObject::connect(m_mirServer->sessionListener(), &SessionListener::trustedSessionStopped,
118 this, &ApplicationManager::onTrustedSessionStopped);
108 QObject::connect(m_mirServer->sessionAuthorizer(), &SessionAuthorizer::requestAuthorizationForSession,119 QObject::connect(m_mirServer->sessionAuthorizer(), &SessionAuthorizer::requestAuthorizationForSession,
109 this, &ApplicationManager::authorizeSession, Qt::BlockingQueuedConnection);120 this, &ApplicationManager::authorizeSession, Qt::BlockingQueuedConnection);
110 QObject::connect(m_mirServer->placementStrategy(), &InitialSurfacePlacementStrategy::requestPlacementForSession,121 QObject::connect(m_mirServer->placementStrategy(), &InitialSurfacePlacementStrategy::requestPlacementForSession,
@@ -130,7 +141,7 @@
130 {141 {
131 view_area.add(db.view_area());142 view_area.add(db.view_area());
132 });143 });
133 144
134 m_displaySize = QSize(145 m_displaySize = QSize(
135 view_area.bounding_rectangle().size.width.as_uint32_t(),146 view_area.bounding_rectangle().size.width.as_uint32_t(),
136 view_area.bounding_rectangle().size.height.as_uint32_t()147 view_area.bounding_rectangle().size.height.as_uint32_t()
@@ -239,15 +250,15 @@
239 DLOG("No such running application '%s'", qPrintable(appId));250 DLOG("No such running application '%s'", qPrintable(appId));
240 return false;251 return false;
241 }252 }
242 253
243 if (application->stage() == Application::MainStage && m_sideStageApplication)254 if (application->stage() == Application::MainStage && m_sideStageApplication)
244 suspendApplication(m_sideStageApplication);255 suspendApplication(m_sideStageApplication);
245 256
246 if (application->stage() == Application::MainStage)257 if (application->stage() == Application::MainStage)
247 m_msApplicationToBeFocused = application;258 m_msApplicationToBeFocused = application;
248 else259 else
249 m_ssApplicationToBeFocused = application;260 m_ssApplicationToBeFocused = application;
250 261
251 if (application->state() == Application::Stopped) {262 if (application->state() == Application::Stopped) {
252 // Respawning this app, move to end of application list so onSessionStarting works ok263 // Respawning this app, move to end of application list so onSessionStarting works ok
253 // FIXME: this happens pretty late, shell could request respawn earlier264 // FIXME: this happens pretty late, shell could request respawn earlier
@@ -255,8 +266,9 @@
255 int from = m_applications.indexOf(application);266 int from = m_applications.indexOf(application);
256 move(from, m_applications.length()-1);267 move(from, m_applications.length()-1);
257 } else {268 } else {
258 if (application->session())269 if (application->session()) {
259 m_mirServer->the_focus_controller()->set_focus_to(application->session());270 m_mirServer->the_focus_controller()->set_focus_to(application->session()->mirSession());
271 }
260 }272 }
261273
262 // FIXME(dandrader): lying here. The operation is async. So we will only know whether274 // FIXME(dandrader): lying here. The operation is async. So we will only know whether
@@ -353,15 +365,24 @@
353365
354 if (application == m_focusedApplication) {366 if (application == m_focusedApplication) {
355 // TODO(greyback) What to do?? Focus next app, or unfocus everything??367 // TODO(greyback) What to do?? Focus next app, or unfocus everything??
368 auto lastFocusedApp = m_focusedApplication;
356 m_focusedApplication = NULL;369 m_focusedApplication = NULL;
357 Q_EMIT focusedApplicationIdChanged();370 Q_EMIT focusedApplicationIdChanged();
371
372 // stop trusted session when focus changes.
373 if (lastFocusedApp && lastFocusedApp->overrideSession()) {
374 auto overrideMirSession = lastFocusedApp->overrideSession()->mirSession();
375 if (overrideMirSession->get_trusted_session()) {
376 m_mirServer->the_frontend_shell()->stop_trusted_session(overrideMirSession->get_trusted_session()->id());
377 }
378 }
358 }379 }
359380
360 if (application == m_mainStageApplication)381 if (application == m_mainStageApplication)
361 m_mainStageApplication = nullptr;382 m_mainStageApplication = nullptr;
362 if (application == m_sideStageApplication)383 if (application == m_sideStageApplication)
363 m_sideStageApplication = nullptr;384 m_sideStageApplication = nullptr;
364 385
365 remove(application);386 remove(application);
366 m_dbusWindowStack->WindowDestroyed(0, application->appId());387 m_dbusWindowStack->WindowDestroyed(0, application->appId());
367388
@@ -388,9 +409,18 @@
388409
389 if (application == m_focusedApplication) {410 if (application == m_focusedApplication) {
390 // Very bad case where focused application dies. Remove from list. Should give error message411 // Very bad case where focused application dies. Remove from list. Should give error message
412 auto lastFocusedApp = m_focusedApplication;
391 m_focusedApplication = nullptr;413 m_focusedApplication = nullptr;
392 Q_EMIT focusedApplicationIdChanged();414 Q_EMIT focusedApplicationIdChanged();
393 removeApplication = true;415 removeApplication = true;
416
417 // stop trusted session when focus changes.
418 if (lastFocusedApp && lastFocusedApp->overrideSession()) {
419 auto overrideMirSession = lastFocusedApp->overrideSession()->mirSession();
420 if (overrideMirSession->get_trusted_session()) {
421 m_mirServer->the_frontend_shell()->stop_trusted_session(overrideMirSession->get_trusted_session()->id());
422 }
423 }
394 }424 }
395425
396 if (application->state() == Application::Running || application->state() == Application::Starting) {426 if (application->state() == Application::Running || application->state() == Application::Starting) {
@@ -399,7 +429,7 @@
399 removeApplication = true;429 removeApplication = true;
400 } else if (application->state() == Application::Suspended) {430 } else if (application->state() == Application::Suspended) {
401 application->setState(Application::Stopped);431 application->setState(Application::Stopped);
402 application->setSession(nullptr);432 application->setSession(QSharedPointer<Session>());
403 }433 }
404434
405 if (removeApplication) {435 if (removeApplication) {
@@ -471,12 +501,14 @@
471501
472 QByteArray command = cmdline.readLine().replace('\0', ' ');502 QByteArray command = cmdline.readLine().replace('\0', ' ');
473503
474 // FIXME: special exception for the OSK - maliit-server - not very secure504 // FIXME: special exceptions - not very secure
475 if (command.startsWith("maliit-server") || command.startsWith("/usr/lib/arm-linux-gnueabihf/qt5/libexec/QtWebProcess")505 for( auto const& whiteListApp : whiteListApps) {
476 || command.startsWith("/usr/bin/signon-ui")) {506 if (command.startsWith(whiteListApp)) {
477 authorized = true;507 DLOG("ApplicationManager ACCEPTED connection from white-list app with pid %lld", pid);
478 m_fenceNext = true;508 authorized = true;
479 return;509 m_fencePIDs << pid;
510 return;
511 }
480 }512 }
481513
482 QString pattern = QRegularExpression::escape("--desktop_file_hint=") + "(\\S+)";514 QString pattern = QRegularExpression::escape("--desktop_file_hint=") + "(\\S+)";
@@ -484,7 +516,7 @@
484 QRegularExpressionMatch regExpMatch = regExp.match(command);516 QRegularExpressionMatch regExpMatch = regExp.match(command);
485517
486 if (!regExpMatch.hasMatch()) {518 if (!regExpMatch.hasMatch()) {
487 LOG("ApplicationManager REJECTED connection from app with pid %lld as no desktop_file_hint specified", pid);519 LOG("ApplicationManager REJECTED connection from app with pid %lld (%s) as no desktop_file_hint specified", pid, command.data());
488 return;520 return;
489 }521 }
490522
@@ -543,10 +575,10 @@
543void ApplicationManager::placeSession(msh::Session const* session, uint32_t &x, uint32_t &y)575void ApplicationManager::placeSession(msh::Session const* session, uint32_t &x, uint32_t &y)
544{576{
545 DLOG("ApplicationManager::placeSession (this=%p, session=%p)", this, session);577 DLOG("ApplicationManager::placeSession (this=%p, session=%p)", this, session);
546 578
547 Application* application = findApplicationWithSession(session);579 Application* application = findApplicationWithSession(session, true);
548580
549 // Application defaults 581 // Application defaults
550 x = 0;582 x = 0;
551 y = m_panelHeight;583 y = m_panelHeight;
552584
@@ -563,7 +595,7 @@
563 // SideStage override595 // SideStage override
564 if (application && application->stage() == Application::SideStage)596 if (application && application->stage() == Application::SideStage)
565 x = m_displaySize.width() - (SIDE_STAGE_WIDTH_GU * m_gridUnitPx);597 x = m_displaySize.width() - (SIDE_STAGE_WIDTH_GU * m_gridUnitPx);
566 598
567 DLOG("ApplicationManager::placeSession (x=%d, y=%d)", x, y);599 DLOG("ApplicationManager::placeSession (x=%d, y=%d)", x, y);
568}600}
569601
@@ -571,21 +603,22 @@
571{603{
572 DLOG("ApplicationManager::onSessionStarting (this=%p, application=%s)", this, session->name().c_str());604 DLOG("ApplicationManager::onSessionStarting (this=%p, application=%s)", this, session->name().c_str());
573605
574 if (m_fenceNext) {606 pid_t pid = session->process_id();
575 m_fenceNext = false;607
576 return;608 QSharedPointer<Session> new_session(new Session(session));
577 }609 m_sessions[pid] = new_session;
578610
579 //FIXME(greyback) Mir not supplying any identifier that we can use to link the PID to the session611 Application* application = findApplicationWithPid(session->process_id(), false);
580 // so am assuming that the *most recently* launched application session is the one that connects
581 Application* application = findLastExecutedApplication();
582 if (application && application->state() != Application::Running) {612 if (application && application->state() != Application::Running) {
583 application->setSession(session);613 application->setSession(new_session);
584 if (application->stage() == Application::MainStage)614 if (application->stage() == Application::MainStage)
585 m_msApplicationToBeFocused = application;615 m_msApplicationToBeFocused = application;
586 else616 else
587 m_ssApplicationToBeFocused = application;617 m_ssApplicationToBeFocused = application;
588 } else {618 } else {
619 if (m_fencePIDs.contains(pid)) {
620 return;
621 }
589 DLOG("ApplicationManager::onSessionStarting - unauthorized application!!");622 DLOG("ApplicationManager::onSessionStarting - unauthorized application!!");
590 }623 }
591}624}
@@ -594,44 +627,56 @@
594{627{
595 DLOG("ApplicationManager::onSessionStopping (this=%p, application=%s)", this, session->name().c_str());628 DLOG("ApplicationManager::onSessionStopping (this=%p, application=%s)", this, session->name().c_str());
596629
597 // in case application closed not by hand of shell, check again here:630 auto sit = m_sessions.find(session->process_id());
598 Application* application = findApplicationWithSession(session);631 if (sit != m_sessions.end()) {
599 if (application) {632 QSharedPointer<Session> localSession = sit.value();
600 bool removeApplication = true;633
601634 // in case application closed not by hand of shell, check again here:
602 if (application->state() != Application::Starting) {635 Application* application = findApplicationWithSession(session, false); // only check app sessions
603 application->setState(Application::Stopped);636 if (application) {
604 application->setSession(nullptr);637
605 m_dbusWindowStack->WindowDestroyed(0, application->appId());638 if (session->get_trusted_session()) {
606 if (application != m_focusedApplication) {639 m_mirServer->the_frontend_shell()->stop_trusted_session(session->get_trusted_session()->id());
607 removeApplication = false;640 }
608 }641
609 }642 bool removeApplication = true;
610643 if (application->state() != Application::Starting) {
611 if (m_mainStageApplication == application)644 application->setState(Application::Stopped);
612 m_mainStageApplication = nullptr;645 application->setSession(QSharedPointer<Session>());
613 646 m_dbusWindowStack->WindowDestroyed(0, application->appId());
614 if (m_sideStageApplication == application)647 if (application != m_focusedApplication) {
615 m_sideStageApplication = nullptr;648 removeApplication = false;
616649 }
617 if (removeApplication) {650 }
618 // TODO(greyback) What to do?? Focus next app, or unfocus everything??651
619 m_focusedApplication = NULL;652 if (m_mainStageApplication == application)
620 remove(application);653 m_mainStageApplication = nullptr;
621 delete application;654
622 Q_EMIT focusedApplicationIdChanged();655 if (m_sideStageApplication == application)
623 }656 m_sideStageApplication = nullptr;
657
658 if (removeApplication) {
659 // TODO(greyback) What to do?? Focus next app, or unfocus everything??
660 m_focusedApplication = NULL;
661 remove(application);
662 delete application;
663 Q_EMIT focusedApplicationIdChanged();
664 }
665 }
666
667 m_sessions.erase(sit);
668 m_fencePIDs.removeAll(session->process_id());
624 }669 }
625}670}
626671
627void ApplicationManager::onSessionFocused(std::shared_ptr<msh::Session> const& session)672void ApplicationManager::onSessionFocused(std::shared_ptr<msh::Session> const& session)
628{673{
629 DLOG("ApplicationManager::onSessionFocused (this=%p, session=%p)", this, session.get());674 DLOG("ApplicationManager::onSessionFocused (this=%p, application=%s)", this, session->name().c_str());
630 Application* application = findApplicationWithSession(session);675 Application* application = findApplicationWithSession(session, true);
631676
632 // Don't give application focus until it has created it's surface, when it is set as state "Running"677 // Don't give application focus until it has created it's surface, when it is set as state "Running"
633 // and only notify shell of focus changes that it actually expects678 // and only notify shell of focus changes that it actually expects
634 if (application && application->state() != Application::Starting && 679 if (application && application->state() != Application::Starting &&
635 (application == m_msApplicationToBeFocused ||680 (application == m_msApplicationToBeFocused ||
636 application == m_ssApplicationToBeFocused)681 application == m_ssApplicationToBeFocused)
637 && application != m_focusedApplication) {682 && application != m_focusedApplication) {
@@ -640,9 +685,10 @@
640 Q_EMIT dataChanged(appIndex, appIndex, QVector<int>() << RoleFocused);685 Q_EMIT dataChanged(appIndex, appIndex, QVector<int>() << RoleFocused);
641 } else {686 } else {
642 if (application == nullptr) {687 if (application == nullptr) {
643 DLOG("Invalid application focused, discarding the event");688 DLOG("Invalid application focused, discarding the event (m_focusedApplication=%p)", m_focusedApplication);
644 if (NULL != m_focusedApplication)689 if (NULL != m_focusedApplication) {
645 focusApplication(m_focusedApplication->appId());690 focusApplication(m_focusedApplication->appId());
691 }
646 }692 }
647 }693 }
648}694}
@@ -653,7 +699,8 @@
653 if (NULL != m_focusedApplication) {699 if (NULL != m_focusedApplication) {
654 Q_ASSERT(m_focusedApplication->focused());700 Q_ASSERT(m_focusedApplication->focused());
655 m_focusedApplication->setFocused(false);701 m_focusedApplication->setFocused(false);
656 702
703 auto lastFocusedApp = m_focusedApplication;
657 suspendApplication(m_focusedApplication);704 suspendApplication(m_focusedApplication);
658705
659 m_focusedApplication = NULL;706 m_focusedApplication = NULL;
@@ -662,16 +709,23 @@
662709
663 QModelIndex appIndex = findIndex(m_focusedApplication);710 QModelIndex appIndex = findIndex(m_focusedApplication);
664 Q_EMIT dataChanged(appIndex, appIndex, QVector<int>() << RoleFocused << RoleState);711 Q_EMIT dataChanged(appIndex, appIndex, QVector<int>() << RoleFocused << RoleState);
712
713 if (lastFocusedApp->overrideSession()) {
714 auto overrideMirSession = lastFocusedApp->overrideSession()->mirSession();
715 if (overrideMirSession->get_trusted_session()) {
716 m_mirServer->the_frontend_shell()->stop_trusted_session(overrideMirSession->get_trusted_session()->id());
717 }
718 }
665 }719 }
666}720}
667721
668void ApplicationManager::onSessionCreatedSurface(msh::Session const* session,722void ApplicationManager::onSessionCreatedSurface(msh::Session const* session,
669 std::shared_ptr<msh::Surface> const& surface)723 std::shared_ptr<msh::Surface> const& surface)
670{724{
671 DLOG("ApplicationManager::onSessionCreatedSurface (this=%p)", this);725 DLOG("ApplicationManager::onSessionCreatedSurface (this=%p, application=%p)", this, session->name().c_str());
672 Q_UNUSED(surface);726 Q_UNUSED(surface);
673727
674 Application* application = findApplicationWithSession(session);728 Application* application = findApplicationWithSession(session, true);
675 if (application && application->state() == Application::Starting) {729 if (application && application->state() == Application::Starting) {
676 m_dbusWindowStack->WindowCreated(0, application->appId());730 m_dbusWindowStack->WindowCreated(0, application->appId());
677 // only when Session creates a Surface will we actually mark it focused731 // only when Session creates a Surface will we actually mark it focused
@@ -681,6 +735,51 @@
681 }735 }
682}736}
683737
738void ApplicationManager::onTrustedSessionStarted(std::shared_ptr<mir::shell::TrustedSession> const& mir_trusted_session)
739{
740 DLOG("ApplicationManager::onTrustedSessionStarted (this=%p, application=%p)", this, mir_trusted_session->name().c_str());
741
742 QSharedPointer<Session> trusted_session(new Session(mir_trusted_session));
743
744 bool overrideSet = false;
745 std::vector<pid_t> trusted_apps = mir_trusted_session->get_applications();
746 for (pid_t pid : trusted_apps) {
747 Application* app = findApplicationWithPid(pid, false);
748 if (!app) {
749 continue;
750 }
751
752 overrideSet = true;
753 app->setOverrideSession(trusted_session);
754
755 if (m_focusedApplication == app) {
756 focusApplication(app->appId());
757 }
758 }
759
760 if (!overrideSet) {
761 DLOG("ApplicationManager::onTrustedSessionStarted - no trusted helper to start");
762 }
763}
764
765void ApplicationManager::onTrustedSessionStopped(std::shared_ptr<mir::shell::TrustedSession> const& trusted_session)
766{
767 auto trusted_helper = trusted_session->get_trusted_helper();
768 DLOG("ApplicationManager::onTrustedSessionStopped (this=%p, application=%s)", this, trusted_helper->name().c_str());
769
770 for (Application *app : m_applications) {
771
772 if (app->overrideSession() && app->overrideSession()->mirSession() == trusted_session) {
773 app->setOverrideSession(QSharedPointer<Session>());
774 }
775
776 if (m_focusedApplication == app) {
777 focusApplication(app->appId());
778 }
779 }
780}
781
782
684void ApplicationManager::setFocused(Application *application)783void ApplicationManager::setFocused(Application *application)
685{784{
686 DLOG("ApplicationManager::setFocused (appId=%s)", qPrintable(application->appId()));785 DLOG("ApplicationManager::setFocused (appId=%s)", qPrintable(application->appId()));
@@ -699,29 +798,34 @@
699 else798 else
700 m_sideStageApplication = application;799 m_sideStageApplication = application;
701800
801 auto lastFocusedApp = m_focusedApplication;
702 m_focusedApplication = application;802 m_focusedApplication = application;
703 m_focusedApplication->setFocused(true);803 m_focusedApplication->setFocused(true);
704 m_focusedApplication->setState(Application::Running);804 m_focusedApplication->setState(Application::Running);
705 Q_EMIT focusedApplicationIdChanged();805 Q_EMIT focusedApplicationIdChanged();
706 m_dbusWindowStack->FocusedWindowChanged(0, application->appId(), application->stage());806 m_dbusWindowStack->FocusedWindowChanged(0, application->appId(), application->stage());
707}807
708808 // stop trusted session when focus changes.
709Application* ApplicationManager::findApplicationWithSession(const std::shared_ptr<msh::Session> &session)809 if (lastFocusedApp && lastFocusedApp->overrideSession()) {
710{810 auto overrideMirSession = lastFocusedApp->overrideSession()->mirSession();
711 return findApplicationWithSession(session.get());811 if (overrideMirSession->get_trusted_session()) {
712}812 m_mirServer->the_frontend_shell()->stop_trusted_session(overrideMirSession->get_trusted_session()->id());
713
714Application* ApplicationManager::findApplicationWithSession(const msh::Session *session)
715{
716 for (Application *app : m_applications) {
717 if (app->session().get() == session) {
718 return app;
719 }813 }
720 }814 }
721 return nullptr;815}
722}816
723817Application* ApplicationManager::findApplicationWithSession(const std::shared_ptr<msh::Session> &session, bool checkSessions)
724Application* ApplicationManager::findApplicationWithPid(const qint64 pid)818{
819 return findApplicationWithSession(session.get(), checkSessions);
820}
821
822Application* ApplicationManager::findApplicationWithSession(const msh::Session *session, bool checkSessions)
823{
824 if (!session) { return NULL; }
825 return findApplicationWithPid(session->process_id(), checkSessions);
826}
827
828Application* ApplicationManager::findApplicationWithPid(const qint64 pid, bool checkSessions)
725{829{
726 if (pid <= 0)830 if (pid <= 0)
727 return nullptr;831 return nullptr;
@@ -730,17 +834,23 @@
730 if (app->m_pid == pid) {834 if (app->m_pid == pid) {
731 return app;835 return app;
732 }836 }
837
838 if (checkSessions && app->session()) {
839 if (app->session()->hasProcess(pid)) {
840 return app;
841 }
842 }
733 }843 }
734 return nullptr;844 return nullptr;
735}845}
736846
737Application* ApplicationManager::findLastExecutedApplication()847QSharedPointer<Session> ApplicationManager::findSessionForPid(pid_t pid)
738{848{
739 if (m_applications.length() > 0) {849 auto iter = m_sessions.find(pid);
740 return m_applications.last();850 if (iter != m_sessions.end()) {
741 } else {851 return *iter;
742 return NULL;
743 }852 }
853 return QSharedPointer<Session>();
744}854}
745855
746Application* ApplicationManager::applicationForStage(Application::Stage stage)856Application* ApplicationManager::applicationForStage(Application::Stage stage)
747857
=== modified file 'src/modules/Unity/Application/application_manager.h'
--- src/modules/Unity/Application/application_manager.h 2014-01-27 11:29:44 +0000
+++ src/modules/Unity/Application/application_manager.h 2014-02-26 10:27:46 +0000
@@ -46,6 +46,7 @@
46 namespace shell {46 namespace shell {
47 class Session;47 class Session;
48 class Surface;48 class Surface;
49 class TrustedSession;
49 }50 }
50}51}
5152
@@ -87,7 +88,7 @@
87 Q_INVOKABLE void move(int from, int to);88 Q_INVOKABLE void move(int from, int to);
8889
89 const QList<Application*> &list() const { return m_applications; }90 const QList<Application*> &list() const { return m_applications; }
90 Application* findApplicationWithPid(const qint64 pid);91 Application* findApplicationWithPid(const qint64 pid, bool checkSessions);
9192
92 // Internal helpers93 // Internal helpers
93 void suspendApplication(Application *application);94 void suspendApplication(Application *application);
@@ -97,11 +98,13 @@
97public Q_SLOTS:98public Q_SLOTS:
98 void authorizeSession(const quint64 pid, bool &authorized);99 void authorizeSession(const quint64 pid, bool &authorized);
99 void placeSession(mir::shell::Session const*, uint32_t &x, uint32_t &y);100 void placeSession(mir::shell::Session const*, uint32_t &x, uint32_t &y);
100 101
101 void onSessionStarting(std::shared_ptr<mir::shell::Session> const& session);102 void onSessionStarting(std::shared_ptr<mir::shell::Session> const& session);
102 void onSessionStopping(std::shared_ptr<mir::shell::Session> const& session);103 void onSessionStopping(std::shared_ptr<mir::shell::Session> const& session);
103 void onSessionFocused(std::shared_ptr<mir::shell::Session> const& session);104 void onSessionFocused(std::shared_ptr<mir::shell::Session> const& session);
104 void onSessionUnfocused();105 void onSessionUnfocused();
106 void onTrustedSessionStarted(std::shared_ptr<mir::shell::TrustedSession> const& trusted_session);
107 void onTrustedSessionStopped(std::shared_ptr<mir::shell::TrustedSession> const& trusted_session);
105108
106 void onSessionCreatedSurface(mir::shell::Session const*, std::shared_ptr<mir::shell::Surface> const&);109 void onSessionCreatedSurface(mir::shell::Session const*, std::shared_ptr<mir::shell::Surface> const&);
107110
@@ -117,11 +120,11 @@
117 void setFocused(Application *application);120 void setFocused(Application *application);
118 void add(Application *application);121 void add(Application *application);
119 void remove(Application* application);122 void remove(Application* application);
120 Application* findApplicationWithSession(const std::shared_ptr<mir::shell::Session> &session);123 Application* findApplicationWithSession(const std::shared_ptr<mir::shell::Session> &session, bool checkSessions);
121 Application* findApplicationWithSession(const mir::shell::Session *session);124 Application* findApplicationWithSession(const mir::shell::Session *session, bool checkSessions);
122 Application* findLastExecutedApplication();
123 Application* applicationForStage(Application::Stage stage);125 Application* applicationForStage(Application::Stage stage);
124 QModelIndex findIndex(Application* application);126 QModelIndex findIndex(Application* application);
127 QSharedPointer<Session> findSessionForPid(pid_t pid);
125128
126 QList<Application*> m_applications;129 QList<Application*> m_applications;
127 Application* m_focusedApplication; // remove as Mir has API for this130 Application* m_focusedApplication; // remove as Mir has API for this
@@ -135,8 +138,10 @@
135 QSharedPointer<TaskController> m_taskController;138 QSharedPointer<TaskController> m_taskController;
136 QSharedPointer<DesktopFileReader::Factory> m_desktopFileReaderFactory;139 QSharedPointer<DesktopFileReader::Factory> m_desktopFileReaderFactory;
137 static ApplicationManager* the_application_manager;140 static ApplicationManager* the_application_manager;
141 static QList<QByteArray> whiteListApps;
138 int m_gridUnitPx;142 int m_gridUnitPx;
139 bool m_fenceNext;143 QList<pid_t> m_fencePIDs;
144 QMap<pid_t, QSharedPointer<Session>> m_sessions;
140 QSize m_displaySize;145 QSize m_displaySize;
141 int m_panelHeight;146 int m_panelHeight;
142147
143148
=== modified file 'src/modules/Unity/Application/applicationscreenshotprovider.cpp'
--- src/modules/Unity/Application/applicationscreenshotprovider.cpp 2013-12-20 03:38:43 +0000
+++ src/modules/Unity/Application/applicationscreenshotprovider.cpp 2014-02-26 10:27:46 +0000
@@ -20,6 +20,7 @@
20#include "application.h"20#include "application.h"
2121
22// unity-mir22// unity-mir
23#include "session.h"
23#include "logging.h"24#include "logging.h"
2425
25// mir26// mir
@@ -51,7 +52,8 @@
5152
52 // TODO: if app not ready, return an app-provided splash image. If app has been stopped with saved state53 // TODO: if app not ready, return an app-provided splash image. If app has been stopped with saved state
53 // return the screenshot that was saved to disk.54 // return the screenshot that was saved to disk.
54 if (!app->session() || !app->session()->default_surface()) {55 QSharedPointer<Session> session = app->session();
56 if (!session || !session->mirSession() || !session->mirSession()->default_surface()) {
55 LOG("ApplicationScreenshotProvider - app session not found - taking screenshot too early");57 LOG("ApplicationScreenshotProvider - app session not found - taking screenshot too early");
56 return QImage();58 return QImage();
57 }59 }
@@ -67,7 +69,7 @@
6769
68 QImage image;70 QImage image;
6971
70 app->session()->take_snapshot(72 session->mirSession()->take_snapshot(
71 [&](mir::shell::Snapshot const& snapshot)73 [&](mir::shell::Snapshot const& snapshot)
72 {74 {
73 DLOG("ApplicationScreenshotProvider - Mir snapshot ready with size %d x %d",75 DLOG("ApplicationScreenshotProvider - Mir snapshot ready with size %d x %d",
7476
=== modified file 'src/modules/Unity/Application/dbuswindowstack.cpp'
--- src/modules/Unity/Application/dbuswindowstack.cpp 2013-10-09 09:02:23 +0000
+++ src/modules/Unity/Application/dbuswindowstack.cpp 2014-02-26 10:27:46 +0000
@@ -44,7 +44,7 @@
44{44{
45 AppIdDesktopFile res;45 AppIdDesktopFile res;
46 ApplicationManager *appMgr = static_cast<ApplicationManager*>(parent());46 ApplicationManager *appMgr = static_cast<ApplicationManager*>(parent());
47 const Application* app = static_cast<Application*>(appMgr->findApplicationWithPid(pid));47 const Application* app = static_cast<Application*>(appMgr->findApplicationWithPid(pid, false));
48 if (app) {48 if (app) {
49 res.app_id = app->appId();49 res.app_id = app->appId();
50 res.desktop_file = app->desktopFile();50 res.desktop_file = app->desktopFile();
5151
=== modified file 'src/modules/Unity/Application/mirsurfacemanager.cpp'
--- src/modules/Unity/Application/mirsurfacemanager.cpp 2013-12-20 03:38:43 +0000
+++ src/modules/Unity/Application/mirsurfacemanager.cpp 2014-02-26 10:27:46 +0000
@@ -103,8 +103,8 @@
103{103{
104 DLOG("MirSurfaceManager::sessionCreatedSurface (this=%p) with surface name '%s'", this, surface->name().c_str());104 DLOG("MirSurfaceManager::sessionCreatedSurface (this=%p) with surface name '%s'", this, surface->name().c_str());
105 ApplicationManager* appMgr = static_cast<ApplicationManager*>(ApplicationManager::singleton());105 ApplicationManager* appMgr = static_cast<ApplicationManager*>(ApplicationManager::singleton());
106 Application* application = appMgr->findApplicationWithSession(session);106 Application* application = appMgr->findApplicationWithSession(session, true);
107 107
108 auto qmlSurface = new MirSurface(surface, application);108 auto qmlSurface = new MirSurface(surface, application);
109 m_surfaces.insert(surface.get(), qmlSurface);109 m_surfaces.insert(surface.get(), qmlSurface);
110 Q_EMIT surfaceCreated(qmlSurface);110 Q_EMIT surfaceCreated(qmlSurface);
@@ -134,7 +134,7 @@
134 if (fs) {134 if (fs) {
135 fs->set_default_keyboard_target(surface);135 fs->set_default_keyboard_target(surface);
136 }136 }
137 137
138 Q_EMIT shellSurfaceChanged(m_shellSurface);138 Q_EMIT shellSurfaceChanged(m_shellSurface);
139}139}
140140
@@ -145,18 +145,21 @@
145145
146 auto it = m_surfaces.find(surface);146 auto it = m_surfaces.find(surface);
147 if (it != m_surfaces.end()) {147 if (it != m_surfaces.end()) {
148 it.value()->setAttribute(attribute, value);148 auto const& surface = it.value();
149
150 surface->setAttribute(attribute, value);
149 if (attribute == mir_surface_attrib_state &&151 if (attribute == mir_surface_attrib_state &&
150 value == mir_surface_state_fullscreen) {152 value == mir_surface_state_fullscreen) {
153
151 // Only screen-wide applications are allowed to go fullscreen154 // Only screen-wide applications are allowed to go fullscreen
152 if (it.value()->application()->stage() == Application::MainStage) {155 if (surface->application() && surface->application()->stage() == Application::MainStage) {
153 it.value()->application()->setFullscreen(static_cast<bool>(value));156 surface->application()->setFullscreen(static_cast<bool>(value));
154 ApplicationManager* appMgr = static_cast<ApplicationManager*>(ApplicationManager::singleton());157 ApplicationManager* appMgr = static_cast<ApplicationManager*>(ApplicationManager::singleton());
155 QSize displaySize = appMgr->displaySize();158 QSize displaySize = appMgr->displaySize();
156 it.value()->setWidth(displaySize.width());159 surface->setWidth(displaySize.width());
157 it.value()->setHeight(displaySize.height());160 surface->setHeight(displaySize.height());
158 it.value()->setX(0);161 surface->setX(0);
159 it.value()->setY(0);162 surface->setY(0);
160 }163 }
161 }164 }
162 }165 }
163166
=== added file 'src/modules/Unity/Application/session.cpp'
--- src/modules/Unity/Application/session.cpp 1970-01-01 00:00:00 +0000
+++ src/modules/Unity/Application/session.cpp 2014-02-26 10:27:46 +0000
@@ -0,0 +1,70 @@
1/*
2 * Copyright (C) 2014 Canonical, Ltd.
3 *
4 * This program is free software: you can redistribute it and/or modify it under
5 * the terms of the GNU Lesser General Public License version 3, as published by
6 * the Free Software Foundation.
7 *
8 * This program is distributed in the hope that it will be useful, but WITHOUT
9 * ANY WARRANTY; without even the implied warranties of MERCHANTABILITY,
10 * SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 * 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 "session.h"
18
19// mir
20#include <mir/shell/session.h>
21#include <mir/shell/trusted_session.h>
22
23Session::Session(const std::shared_ptr<mir::shell::Session>& session)
24: m_session(session)
25, m_application(NULL)
26{
27}
28
29Session::~Session()
30{
31}
32
33std::shared_ptr<mir::shell::Session> Session::mirSession() const
34{
35 return m_session;
36}
37
38void Session::setLifecycleState(MirLifecycleState state)
39{
40 m_session->set_lifecycle_state(state);
41}
42
43void Session::setApplication(Application* application)
44{
45 m_application = application;
46}
47
48Application* Session::application() const
49{
50 return m_application;
51}
52
53bool Session::hasProcess(pid_t pid) const
54{
55 if (mirSession()->process_id() == pid) {
56 return true;
57 }
58 auto trusted_session = mirSession()->get_trusted_session();
59 if (trusted_session) {
60 if (trusted_session->get_trusted_helper()->process_id() == pid) {
61 return true;
62 }
63 for (pid_t application_pid : trusted_session->get_applications()) {
64 if (application_pid == pid) {
65 return true;
66 }
67 }
68 }
69 return false;
70}
0\ No newline at end of file71\ No newline at end of file
172
=== added file 'src/modules/Unity/Application/session.h'
--- src/modules/Unity/Application/session.h 1970-01-01 00:00:00 +0000
+++ src/modules/Unity/Application/session.h 2014-02-26 10:27:46 +0000
@@ -0,0 +1,60 @@
1/*
2 * Copyright (C) 2014 Canonical, Ltd.
3 *
4 * This program is free software: you can redistribute it and/or modify it under
5 * the terms of the GNU Lesser General Public License version 3, as published by
6 * the Free Software Foundation.
7 *
8 * This program is distributed in the hope that it will be useful, but WITHOUT
9 * ANY WARRANTY; without even the implied warranties of MERCHANTABILITY,
10 * SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 * 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 SESSION_H
18#define SESSION_H
19
20// std
21#include <memory>
22
23// Mir
24#include <mir_toolkit/common.h>
25
26 // Qt
27#include <QSharedPointer>
28
29class Application;
30namespace mir
31{
32namespace shell
33{
34class Session;
35}
36}
37
38class Session {
39public:
40 Session(const std::shared_ptr<mir::shell::Session>& session);
41 virtual ~Session();
42
43 std::shared_ptr<mir::shell::Session> mirSession() const;
44
45 void setLifecycleState(MirLifecycleState state);
46
47 void setApplication(Application* application);
48 Application* application() const;
49
50 bool hasProcess(pid_t pid) const;
51
52protected:
53 void setParent(const QSharedPointer<Session>& parent);
54
55private:
56 std::shared_ptr<mir::shell::Session> m_session;
57 Application* m_application;
58};
59
60#endif // SESSION_H
061
=== modified file 'src/unity-mir/sessionlistener.cpp'
--- src/unity-mir/sessionlistener.cpp 2013-11-20 14:39:50 +0000
+++ src/unity-mir/sessionlistener.cpp 2014-02-26 10:27:46 +0000
@@ -27,6 +27,7 @@
27 DLOG("SessionListener::SessionListener (this=%p)", this);27 DLOG("SessionListener::SessionListener (this=%p)", this);
28 // need to register type to send over threads with signal/slot28 // need to register type to send over threads with signal/slot
29 qRegisterMetaType<std::shared_ptr<msh::Session>>("std::shared_ptr<mir::shell::Session>");29 qRegisterMetaType<std::shared_ptr<msh::Session>>("std::shared_ptr<mir::shell::Session>");
30 qRegisterMetaType<std::shared_ptr<msh::TrustedSession>>("std::shared_ptr<mir::shell::TrustedSession>");
30}31}
3132
32SessionListener::~SessionListener()33SessionListener::~SessionListener()
@@ -71,3 +72,15 @@
71 DLOG("SessionListener::destroying_surface (this=%p, session=%p, surface=%p)", this, &session, (void*)surface.get());72 DLOG("SessionListener::destroying_surface (this=%p, session=%p, surface=%p)", this, &session, (void*)surface.get());
72 Q_EMIT sessionDestroyingSurface(&session, surface);73 Q_EMIT sessionDestroyingSurface(&session, surface);
73}74}
75
76void SessionListener::trusted_session_started(std::shared_ptr<mir::shell::TrustedSession> const& trusted_session)
77{
78 DLOG("SessionListener::trusted_session_started (this=%p, trusted_session=%p)", this, (void*)trusted_session.get());
79 Q_EMIT trustedSessionStarted(trusted_session);
80}
81
82void SessionListener::trusted_session_stopped(std::shared_ptr<mir::shell::TrustedSession> const& trusted_session)
83{
84 DLOG("SessionListener::trusted_session_stopped (this=%p, session=%p)", this, (void*)trusted_session.get());
85 Q_EMIT trustedSessionStopped(trusted_session);
86}
7487
=== modified file 'src/unity-mir/sessionlistener.h'
--- src/unity-mir/sessionlistener.h 2013-11-15 17:40:27 +0000
+++ src/unity-mir/sessionlistener.h 2014-02-26 10:27:46 +0000
@@ -36,6 +36,9 @@
36 void surface_created(mir::shell::Session&, std::shared_ptr<mir::shell::Surface> const&) override;36 void surface_created(mir::shell::Session&, std::shared_ptr<mir::shell::Surface> const&) override;
37 void destroying_surface(mir::shell::Session&, std::shared_ptr<mir::shell::Surface> const&) override;37 void destroying_surface(mir::shell::Session&, std::shared_ptr<mir::shell::Surface> const&) override;
3838
39 void trusted_session_started(std::shared_ptr<mir::shell::TrustedSession> const& trusted_session) override;
40 void trusted_session_stopped(std::shared_ptr<mir::shell::TrustedSession> const& trusted_session) override;
41
39Q_SIGNALS:42Q_SIGNALS:
40 void sessionStarting(std::shared_ptr<mir::shell::Session> const& session);43 void sessionStarting(std::shared_ptr<mir::shell::Session> const& session);
41 void sessionStopping(std::shared_ptr<mir::shell::Session> const& session);44 void sessionStopping(std::shared_ptr<mir::shell::Session> const& session);
@@ -44,6 +47,9 @@
4447
45 void sessionCreatedSurface(mir::shell::Session const*, std::shared_ptr<mir::shell::Surface> const&);48 void sessionCreatedSurface(mir::shell::Session const*, std::shared_ptr<mir::shell::Surface> const&);
46 void sessionDestroyingSurface(mir::shell::Session const*, std::shared_ptr<mir::shell::Surface> const&);49 void sessionDestroyingSurface(mir::shell::Session const*, std::shared_ptr<mir::shell::Surface> const&);
50
51 void trustedSessionStarted(std::shared_ptr<mir::shell::TrustedSession> const&);
52 void trustedSessionStopped(std::shared_ptr<mir::shell::TrustedSession> const&);
47};53};
4854
49#endif // SESSIONLISTENER_H55#endif // SESSIONLISTENER_H
5056
=== modified file 'src/unity-mir/shellserverconfiguration.cpp'
--- src/unity-mir/shellserverconfiguration.cpp 2014-02-07 16:10:12 +0000
+++ src/unity-mir/shellserverconfiguration.cpp 2014-02-26 10:27:46 +0000
@@ -136,7 +136,7 @@
136// The rationale is that if when you do136// The rationale is that if when you do
137// the_session_authorizer()137// the_session_authorizer()
138// get a pointer that is unique means that Mir is not138// get a pointer that is unique means that Mir is not
139// holding the pointer and thus when we return from the 139// holding the pointer and thus when we return from the
140// sessionAuthorizer()140// sessionAuthorizer()
141// scope the unique pointer will be destroyed so we return 0141// scope the unique pointer will be destroyed so we return 0
142//142//

Subscribers

People subscribed via source and target branches