TYPE3
[iec.git] / src / type3_AndroidCloud / anbox-master / src / anbox / application / manager.h
1 /*
2  * Copyright (C) 2016 Simon Fels <morphis@gravedo.de>
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, as published
6  * by the Free Software Foundation.
7  *
8  * This program is distributed in the hope that it will be useful, but
9  * WITHOUT ANY WARRANTY; without even the implied warranties of
10  * MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
11  * PURPOSE.  See the GNU General Public License for more details.
12  *
13  * You should have received a copy of the GNU General Public License along
14  * with this program.  If not, see <http://www.gnu.org/licenses/>.
15  *
16  */
17
18 #ifndef ANBOX_APPLICATION_MANAGER_H_
19 #define ANBOX_APPLICATION_MANAGER_H_
20
21 #include "anbox/android/intent.h"
22 #include "anbox/do_not_copy_or_move.h"
23 #include "anbox/graphics/rect.h"
24 #include "anbox/wm/stack.h"
25
26 #include <string>
27
28 #include <core/property.h>
29
30 namespace anbox {
31 namespace application {
32 class Manager : public DoNotCopyOrMove {
33  public:
34   virtual void launch(const android::Intent &intent,
35                       const graphics::Rect &launch_bounds = graphics::Rect::Invalid,
36                       const wm::Stack::Id &stack = wm::Stack::Id::Default) = 0;
37
38   virtual core::Property<bool>& ready() = 0;
39 };
40
41 class RestrictedManager : public Manager {
42  public:
43   RestrictedManager(
44       const std::shared_ptr<Manager> &other,
45       const wm::Stack::Id &launch_stack = wm::Stack::Id::Invalid) :
46     other_(other),
47     launch_stack_(launch_stack) {}
48
49   virtual ~RestrictedManager() {}
50
51   void launch(const android::Intent &intent,
52               const graphics::Rect &launch_bounds = graphics::Rect::Invalid,
53               const wm::Stack::Id &stack = wm::Stack::Id::Default) override {
54     auto selected_stack = stack;
55     // If we have a static launch stack set use that one instead of
56     // the one the caller gave us.
57     if (launch_stack_ != wm::Stack::Id::Invalid)
58       selected_stack = launch_stack_;
59     other_->launch(intent, launch_bounds, selected_stack);
60   }
61
62   core::Property<bool>& ready() override { return other_->ready(); }
63
64  private:
65   std::shared_ptr<Manager> other_;
66   wm::Stack::Id launch_stack_;
67 };
68 } // namespace application
69 } // namespace anbox
70
71 #endif