/* * WiVRn VR streaming * Copyright (C) 2024 Guillaume Meunier * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY 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 . */ #pragma once #include #include #include #include #include #include #include class QProcess; class adb : public QObject { Q_OBJECT public: class device { std::string _serial; std::string _state; std::map _properties; friend class adb; public: device() = default; device(const device &) = default; device(device &&) = default; device & operator=(const device &) = default; device & operator=(device &&) = default; const auto & serial() const { return _serial; }; const auto & state() const { return _state; }; const auto & properties() const { return _properties; }; bool operator==(const device & other) const { return _serial == other._serial; } operator bool() const { return _serial != ""; } std::unique_ptr install(const std::filesystem::path & path); std::unique_ptr uninstall(const std::string & app); void start(const std::string & app, const std::string & action, const std::string & uri); void reverse_forward(int local_port, int device_port); std::vector installed_apps(); }; private: QTimer poll_devices_timer; std::unique_ptr poll_devices_process; std::vector _android_devices; void on_poll_devices_timeout(); void on_poll_devices_process_finished(int exit_code, QProcess::ExitStatus exit_status); public: adb(); const std::vector & devices() const { return _android_devices; } void start() { poll_devices_timer.start(); } void stop() { poll_devices_timer.stop(); } Q_SIGNALS: void android_devices_changed(const std::vector &); };