X-Git-Url: https://gerrit.akraino.org/r/gitweb?a=blobdiff_plain;f=src%2Ftype3_AndroidCloud%2Fanbox-master%2Fsrc%2Fanbox%2Fqemu%2Fadb_message_processor.h;fp=src%2Ftype3_AndroidCloud%2Fanbox-master%2Fsrc%2Fanbox%2Fqemu%2Fadb_message_processor.h;h=5b41d5bb583db4c466d67e20f71bfc5242607106;hb=e26c1ec581be598521517829adba8c8dd23a768f;hp=0000000000000000000000000000000000000000;hpb=6699c1aea74eeb0eb400e6299079f0c7576f716f;p=iec.git diff --git a/src/type3_AndroidCloud/anbox-master/src/anbox/qemu/adb_message_processor.h b/src/type3_AndroidCloud/anbox-master/src/anbox/qemu/adb_message_processor.h new file mode 100644 index 0000000..5b41d5b --- /dev/null +++ b/src/type3_AndroidCloud/anbox-master/src/anbox/qemu/adb_message_processor.h @@ -0,0 +1,77 @@ +/* + * Copyright (C) 2016 Simon Fels + * + * This program is free software: you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 3, as published + * by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranties of + * MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR + * PURPOSE. See the GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program. If not, see . + * + */ + +#ifndef ANBOX_QEMU_ADBD_MESSAGE_PROCESSOR_H_ +#define ANBOX_QEMU_ADBD_MESSAGE_PROCESSOR_H_ + +#include "anbox/network/message_processor.h" +#include "anbox/network/socket_connection.h" +#include "anbox/network/socket_messenger.h" +#include "anbox/network/tcp_socket_connector.h" +#include "anbox/network/tcp_socket_messenger.h" +#include "anbox/runtime.h" + +#include + +#include + +namespace anbox { +namespace qemu { +class AdbMessageProcessor : public network::MessageProcessor { + public: + AdbMessageProcessor( + const std::shared_ptr &rt, + const std::shared_ptr &messenger); + ~AdbMessageProcessor(); + + bool process_data(const std::vector &data) override; + + private: + enum State { + waiting_for_guest_accept_command, + waiting_for_host_connection, + waiting_for_guest_start_command, + proxying_data, + closed_by_container, + closed_by_host, + }; + + void advance_state(); + + void wait_for_host_connection(); + void on_host_connection(std::shared_ptr> const &socket); + void read_next_host_message(); + void on_host_read_size(const boost::system::error_code &error, + std::size_t bytes_read); + + std::shared_ptr runtime_; + State state_ = waiting_for_guest_accept_command; + std::string expected_command_; + std::shared_ptr const messenger_; + std::vector buffer_; + std::shared_ptr host_connector_; + std::shared_ptr host_messenger_; + std::array host_buffer_; + std::unique_lock lock_; + + static std::mutex active_instance_; +}; +} // namespace graphics +} // namespace anbox + +#endif