• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2023 Huawei Device Co., Ltd.
3  * Licensed under the Apache License, Version 2.0 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at
6  *
7  *     http://www.apache.org/licenses/LICENSE-2.0
8  *
9  * Unless required by applicable law or agreed to in writing, software
10  * distributed under the License is distributed on an "AS IS" BASIS,
11  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12  * See the License for the specific language governing permissions and
13  * limitations under the License.
14  */
15 
16 #ifndef JSAPP_H
17 #define JSAPP_H
18 
19 #include <atomic>
20 #include <string>
21 #include <thread>
22 #include <vector>
23 #include "json.h"
24 
25 class JsApp {
26 public:
27     JsApp& operator=(const JsApp&) = delete;
28     JsApp(const JsApp&) = delete;
29     virtual void Start() = 0;
30     virtual void Restart() = 0;
31     virtual void Interrupt() = 0;
32     void Stop();
33     void SetJsAppPath(const std::string& value);
34     void SetUrlPath(const std::string& value);
35     void SetPipeName(const std::string& name);
36     void SetPipePort(const std::string& port);
37     void SetBundleName(const std::string& name);
38     void SetRunning(bool flag);
39     bool GetRunning();
40     void SetIsDebug(bool value);
41     void SetDebugServerPort(uint16_t value);
42     void SetJSHeapSize(uint32_t size);
43     virtual std::string GetJSONTree();
44     virtual std::string GetDefaultJSONTree();
45     virtual void OrientationChanged(std::string commandOrientation);
46     virtual void ResolutionChanged(int32_t, int32_t, int32_t, int32_t, int32_t);
47     virtual void SetArgsColorMode(const std::string& value);
48     virtual void SetArgsAceVersion(const std::string& value);
49     virtual std::string GetOrientation() const;
50     virtual std::string GetColorMode() const;
51     virtual void ColorModeChanged(const std::string commandColorMode);
52     static bool IsLiteDevice(std::string deviceType);
53     virtual void ReloadRuntimePage(const std::string);
54     virtual void SetScreenDensity(const std::string value);
55     virtual void SetConfigChanges(const std::string value);
56     virtual bool MemoryRefresh(const std::string) const;
57     virtual void LoadDocument(const std::string, const std::string, const Json::Value);
58 
59 protected:
60     JsApp();
~JsApp()61     virtual ~JsApp() {};
62     std::string pipeName;
63     std::string pipePort;
64     std::string jsAppPath;
65     std::string bundleName;
66     std::string urlPath;
67     std::atomic<bool> isFinished;
68     std::atomic<bool> isRunning;
69     bool isDebug;
70     uint16_t debugServerPort;
71     uint32_t jsHeapSize;
72     std::string colorMode;
73     std::string orientation;
74     std::string aceVersion;
75     std::string screenDensity;
76     std::string configChanges;
77 };
78 
79 #endif // JSAPP_H
80