Mir
socket_messenger.h
Go to the documentation of this file.
1 /*
2  * Copyright © 2013-2014 Canonical Ltd.
3  *
4  * This program is free software: you can redistribute it and/or modify
5  * it under the terms of the GNU General Public License version 3 as
6  * 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: Kevin DuBois <kevin.dubois@canonical.com>
17  */
18 
19 #ifndef MIR_FRONTEND_SOCKET_MESSENGER_H_
20 #define MIR_FRONTEND_SOCKET_MESSENGER_H_
21 #include "message_sender.h"
22 #include "message_receiver.h"
24 #include <mutex>
25 
26 namespace mir
27 {
28 namespace frontend
29 {
30 namespace detail
31 {
33  public MessageReceiver
34 {
35 public:
36  SocketMessenger(std::shared_ptr<boost::asio::local::stream_protocol::socket> const& socket);
37 
38  void send(char const* data, size_t length, FdSets const& fds) override;
39 
40  void async_receive_msg(MirReadHandler const& handler, boost::asio::mutable_buffers_1 const& buffer) override;
41  boost::system::error_code receive_msg(boost::asio::mutable_buffers_1 const& buffer) override;
42  size_t available_bytes() override;
44  void receive_fds(std::vector<Fd>& fds) override;
45 
46 private:
47  void set_passcred(int opt);
48  void update_session_creds();
49  SessionCredentials creator_creds() const;
50 
51  std::shared_ptr<boost::asio::local::stream_protocol::socket> socket;
52  mir::Fd socket_fd;
53 
54  std::mutex message_lock;
55  SessionCredentials session_creds{0, 0, 0};
56 };
57 }
58 }
59 }
60 
61 #endif /* MIR_FRONTEND_SOCKET_MESSENGER_H_ */
Definition: message_sender.h:29
All things Mir.
Definition: atomic_callback.h:25
Definition: socket_messenger.h:32
void send(char const *data, size_t length, FdSets const &fds) override
Definition: fd.h:33
boost::system::error_code receive_msg(boost::asio::mutable_buffers_1 const &buffer) override
SocketMessenger(std::shared_ptr< boost::asio::local::stream_protocol::socket > const &socket)
Definition: session_credentials.h:27
void async_receive_msg(MirReadHandler const &handler, boost::asio::mutable_buffers_1 const &buffer) override
SessionCredentials client_creds() override
Definition: message_receiver.h:32
std::function< void(boost::system::error_code const &, size_t)> MirReadHandler
Definition: message_receiver.h:36
void receive_fds(std::vector< Fd > &fds) override
std::vector< std::vector< Fd > > FdSets
Definition: fd_sets.h:29

Copyright © 2012-2015 Canonical Ltd.
Generated on Thu Sep 8 14:50:19 UTC 2016