Mir
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
session_mediator.h
Go to the documentation of this file.
1 /*
2  * Copyright © 2012-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,
6  * as published by the Free Software Foundation.
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 General Public License for more details.
12  *
13  * You should have received a copy of the GNU General Public License
14  * along with this program. If not, see <http://www.gnu.org/licenses/>.
15  *
16  * Authored by: Alan Griffiths <alan@octopull.co.uk>
17  */
18 
19 #ifndef MIR_FRONTEND_SESSION_MEDIATOR_H_
20 #define MIR_FRONTEND_SESSION_MEDIATOR_H_
21 
22 #include "display_server.h"
25 #include "mir/graphics/platform.h"
27 #include "mir_toolkit/common.h"
28 #include "surface_tracker.h"
29 
30 #include <functional>
31 #include <memory>
32 #include <mutex>
33 #include <vector>
34 
35 namespace mir
36 {
37 namespace graphics
38 {
39 class Buffer;
40 class Platform;
41 class Display;
42 class GraphicBufferAllocator;
43 }
44 namespace input
45 {
46 class CursorImages;
47 }
48 
51 namespace frontend
52 {
53 class ClientBufferTracker;
54 class Shell;
55 class Session;
56 class Surface;
57 class MessageResourceCache;
58 class SessionMediatorReport;
59 class EventSink;
60 class DisplayChanger;
61 class Screencast;
62 class PromptSession;
63 
64 // SessionMediator relays requests from the client process into the server.
66 {
67 public:
68 
70  std::shared_ptr<Shell> const& shell,
71  std::shared_ptr<graphics::Platform> const& graphics_platform,
72  std::shared_ptr<frontend::DisplayChanger> const& display_changer,
73  std::vector<MirPixelFormat> const& surface_pixel_formats,
74  std::shared_ptr<SessionMediatorReport> const& report,
75  std::shared_ptr<EventSink> const& event_sink,
76  std::shared_ptr<MessageResourceCache> const& resource_cache,
77  std::shared_ptr<Screencast> const& screencast,
78  ConnectionContext const& connection_context,
79  std::shared_ptr<input::CursorImages> const& cursor_images);
80 
81  ~SessionMediator() noexcept;
82 
83  void client_pid(int pid) override;
84 
85  /* Platform independent requests */
86  void connect(::google::protobuf::RpcController* controller,
87  const ::mir::protobuf::ConnectParameters* request,
88  ::mir::protobuf::Connection* response,
89  ::google::protobuf::Closure* done) override;
90 
91  void create_surface(google::protobuf::RpcController* controller,
92  const mir::protobuf::SurfaceParameters* request,
93  mir::protobuf::Surface* response,
94  google::protobuf::Closure* done) override;
95 
96  void next_buffer(
97  google::protobuf::RpcController* controller,
98  mir::protobuf::SurfaceId const* request,
99  mir::protobuf::Buffer* response,
100  google::protobuf::Closure* done) override;
101 
102  void exchange_buffer(
103  google::protobuf::RpcController* controller,
104  mir::protobuf::BufferRequest const* request,
105  mir::protobuf::Buffer* response,
106  google::protobuf::Closure* done) override;
107 
108  void release_surface(google::protobuf::RpcController* controller,
111  google::protobuf::Closure* done) override;
112 
113  void disconnect(google::protobuf::RpcController* controller,
114  const mir::protobuf::Void* request,
115  mir::protobuf::Void* response,
116  google::protobuf::Closure* done) override;
117 
118  void configure_surface(google::protobuf::RpcController* controller,
121  google::protobuf::Closure* done) override;
122 
123  void configure_display(::google::protobuf::RpcController* controller,
124  const ::mir::protobuf::DisplayConfiguration* request,
126  ::google::protobuf::Closure* done) override;
127 
128  void create_screencast(google::protobuf::RpcController*,
131  google::protobuf::Closure* done) override;
132 
133  void release_screencast(google::protobuf::RpcController*,
136  google::protobuf::Closure* done) override;
137 
138  void screencast_buffer(google::protobuf::RpcController*,
141  google::protobuf::Closure* done);
142 
143  void configure_cursor(google::protobuf::RpcController*,
146  google::protobuf::Closure* done);
147 
148  void start_prompt_session(::google::protobuf::RpcController* controller,
149  const ::mir::protobuf::PromptSessionParameters* request,
150  ::mir::protobuf::Void* response,
151  ::google::protobuf::Closure* done);
152 
153  void stop_prompt_session(::google::protobuf::RpcController* controller,
154  const ::mir::protobuf::Void* request,
155  ::mir::protobuf::Void* response,
156  ::google::protobuf::Closure* done);
157 
158  /* Platform specific requests */
159  void drm_auth_magic(google::protobuf::RpcController* controller,
160  const mir::protobuf::DRMMagic* request,
162  google::protobuf::Closure* done) override;
163 
165  ::google::protobuf::RpcController* controller,
166  ::mir::protobuf::SocketFDRequest const* parameters,
167  ::mir::protobuf::SocketFD* response,
168  ::google::protobuf::Closure* done) override;
169 
170 private:
171  void pack_protobuf_buffer(protobuf::Buffer& protobuf_buffer,
172  graphics::Buffer* graphics_buffer,
173  graphics::BufferIpcMsgType msg_type);
174 
175  void advance_buffer(
176  SurfaceId surf_id,
177  Surface& surface,
178  std::function<void(graphics::Buffer*, graphics::BufferIpcMsgType)> complete);
179 
180  virtual std::function<void(std::shared_ptr<Session> const&)> prompt_session_connect_handler() const;
181 
182  pid_t client_pid_;
183  std::shared_ptr<Shell> const shell;
184  std::shared_ptr<graphics::Platform> const graphics_platform;
185  std::shared_ptr<graphics::PlatformIpcOperations> const ipc_operations;
186 
187  std::vector<MirPixelFormat> const surface_pixel_formats;
188 
189  std::shared_ptr<frontend::DisplayChanger> const display_changer;
190  std::shared_ptr<SessionMediatorReport> const report;
191  std::shared_ptr<EventSink> const event_sink;
192  std::shared_ptr<MessageResourceCache> const resource_cache;
193  std::shared_ptr<Screencast> const screencast;
194  ConnectionContext const connection_context;
195  std::shared_ptr<input::CursorImages> const cursor_images;
196 
197  SurfaceTracker surface_tracker;
198 
199  std::mutex session_mutex;
200  std::weak_ptr<Session> weak_session;
201  std::weak_ptr<PromptSession> weak_prompt_session;
202 };
203 
204 }
205 }
206 
207 #endif /* MIR_FRONTEND_SESSION_MEDIATOR_H_ */
Definition: mir_protobuf.pb.h:2880
Definition: mir_protobuf.pb.h:1453
SessionMediator(std::shared_ptr< Shell > const &shell, std::shared_ptr< graphics::Platform > const &graphics_platform, std::shared_ptr< frontend::DisplayChanger > const &display_changer, std::vector< MirPixelFormat > const &surface_pixel_formats, std::shared_ptr< SessionMediatorReport > const &report, std::shared_ptr< EventSink > const &event_sink, std::shared_ptr< MessageResourceCache > const &resource_cache, std::shared_ptr< Screencast > const &screencast, ConnectionContext const &connection_context, std::shared_ptr< input::CursorImages > const &cursor_images)
Definition: session_mediator.cpp:66
All things Mir.
Definition: aging_buffer.h:24
void new_fds_for_prompt_providers(::google::protobuf::RpcController *controller,::mir::protobuf::SocketFDRequest const *parameters,::mir::protobuf::SocketFD *response,::google::protobuf::Closure *done) override
Definition: session_mediator.cpp:522
void release_surface(google::protobuf::RpcController *controller, const mir::protobuf::SurfaceId *, mir::protobuf::Void *, google::protobuf::Closure *done) override
Definition: session_mediator.cpp:292
Definition: mir_protobuf.pb.h:2687
void configure_surface(google::protobuf::RpcController *controller, const mir::protobuf::SurfaceSetting *, mir::protobuf::SurfaceSetting *, google::protobuf::Closure *done) override
Definition: session_mediator.cpp:341
BufferIpcMsgType
Definition: platform_ipc_operations.h:28
void configure_display(::google::protobuf::RpcController *controller, const ::mir::protobuf::DisplayConfiguration *request,::mir::protobuf::DisplayConfiguration *response,::google::protobuf::Closure *done) override
Definition: session_mediator.cpp:374
void next_buffer(google::protobuf::RpcController *controller, mir::protobuf::SurfaceId const *request, mir::protobuf::Buffer *response, google::protobuf::Closure *done) override
Definition: session_mediator.cpp:229
void release_screencast(google::protobuf::RpcController *, const mir::protobuf::ScreencastId *, mir::protobuf::Void *, google::protobuf::Closure *done) override
Definition: session_mediator.cpp:447
Definition: mir_protobuf.pb.h:2769
void disconnect(google::protobuf::RpcController *controller, const mir::protobuf::Void *request, mir::protobuf::Void *response, google::protobuf::Closure *done) override
Definition: session_mediator.cpp:318
Definition: mir_protobuf.pb.h:156
Definition: session_mediator.h:65
void drm_auth_magic(google::protobuf::RpcController *controller, const mir::protobuf::DRMMagic *request, mir::protobuf::DRMAuthMagicStatus *response, google::protobuf::Closure *done) override
Definition: session_mediator.cpp:554
void client_pid(int pid) override
Definition: session_mediator.cpp:102
Definition: mir_protobuf.pb.h:375
void configure_cursor(google::protobuf::RpcController *, mir::protobuf::CursorSetting const *, mir::protobuf::Void *, google::protobuf::Closure *done)
Definition: session_mediator.cpp:490
~SessionMediator() noexcept
Definition: session_mediator.cpp:93
void stop_prompt_session(::google::protobuf::RpcController *controller, const ::mir::protobuf::Void *request,::mir::protobuf::Void *response,::google::protobuf::Closure *done)
Definition: session_mediator.cpp:620
Definition: mir_protobuf.pb.h:1834
void start_prompt_session(::google::protobuf::RpcController *controller, const ::mir::protobuf::PromptSessionParameters *request,::mir::protobuf::Void *response,::google::protobuf::Closure *done)
Definition: session_mediator.cpp:594
Definition: mir_protobuf.pb.h:1921
Definition: mir_protobuf.pb.h:3061
Definition: mir_protobuf.pb.h:2127
void create_surface(google::protobuf::RpcController *controller, const mir::protobuf::SurfaceParameters *request, mir::protobuf::Surface *response, google::protobuf::Closure *done) override
Definition: session_mediator.cpp:168
Definition: connection_context.h:32
Definition: mir_protobuf.pb.h:2979
Definition: surface_tracker.h:37
Definition: int_wrapper.h:27
Definition: mir_protobuf.pb.h:1737
void connect(::google::protobuf::RpcController *controller, const ::mir::protobuf::ConnectParameters *request,::mir::protobuf::Connection *response,::google::protobuf::Closure *done) override
Definition: session_mediator.cpp:107
Definition: mir_protobuf.pb.h:1640
void screencast_buffer(google::protobuf::RpcController *, const mir::protobuf::ScreencastId *, mir::protobuf::Buffer *, google::protobuf::Closure *done)
Definition: session_mediator.cpp:459
Definition: surface.h:41
Definition: mir_protobuf.pb.h:293
Definition: buffer.h:34
void create_screencast(google::protobuf::RpcController *, const mir::protobuf::ScreencastParameters *, mir::protobuf::Screencast *, google::protobuf::Closure *done) override
Definition: session_mediator.cpp:420
Definition: mir_protobuf.pb.h:2573
void exchange_buffer(google::protobuf::RpcController *controller, mir::protobuf::BufferRequest const *request, mir::protobuf::Buffer *response, google::protobuf::Closure *done) override
Definition: session_mediator.cpp:260
Definition: mir_protobuf.pb.h:471
Definition: display_server.h:30
Definition: mir_protobuf.pb.h:1304

Copyright © 2012,2013 Canonical Ltd.
Generated on Fri Oct 10 14:07:14 UTC 2014