• 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/json.h"
24 
25 struct ResolutionParam {
ResolutionParamResolutionParam26     ResolutionParam(int32_t orignalWidth, int32_t orignalHeight,
27         int32_t compressionWidth, int32_t compressionHeight)
28     {
29         this->orignalWidth = orignalWidth;
30         this->orignalHeight = orignalHeight;
31         this->compressionWidth = compressionWidth;
32         this->compressionHeight = compressionHeight;
33     }
34     int32_t orignalWidth;
35     int32_t orignalHeight;
36     int32_t compressionWidth;
37     int32_t compressionHeight;
38 };
39 
40 class JsApp {
41 public:
42     JsApp& operator=(const JsApp&) = delete;
43     JsApp(const JsApp&) = delete;
44     virtual void Start() = 0;
45     virtual void Restart() = 0;
46     virtual void Interrupt() = 0;
47     void Stop();
48     void SetJsAppPath(const std::string& value);
49     void SetUrlPath(const std::string& value);
50     void SetPipeName(const std::string& name);
51     void SetPipePort(const std::string& port);
52     void SetBundleName(const std::string& name);
53     void SetRunning(bool flag);
54     bool GetRunning();
55     void SetIsDebug(bool value);
56     void SetDebugServerPort(uint16_t value);
57     void SetJSHeapSize(uint32_t size);
58     virtual std::string GetJSONTree();
59     virtual std::string GetDefaultJSONTree();
60     virtual void OrientationChanged(std::string commandOrientation);
61     virtual void ResolutionChanged(ResolutionParam&, int32_t, std::string);
62     virtual void SetArgsColorMode(const std::string& value);
63     virtual void SetArgsAceVersion(const std::string& value);
64     virtual std::string GetOrientation() const;
65     virtual std::string GetColorMode() const;
66     virtual void ColorModeChanged(const std::string commandColorMode);
67     static bool IsLiteDevice(std::string deviceType);
68     virtual void ReloadRuntimePage(const std::string);
69     virtual void SetScreenDensity(const std::string value);
70     virtual void SetConfigChanges(const std::string value);
71     virtual bool MemoryRefresh(const std::string) const;
72     virtual void LoadDocument(const std::string, const std::string, const Json::Value);
73     virtual void FoldStatusChanged(const std::string commandFoldStatus, int32_t width, int32_t height);
74 
75 protected:
76     JsApp();
~JsApp()77     virtual ~JsApp() {};
78     std::string pipeName;
79     std::string pipePort;
80     std::string jsAppPath;
81     std::string bundleName;
82     std::string urlPath;
83     std::atomic<bool> isFinished;
84     std::atomic<bool> isRunning;
85     bool isDebug;
86     uint16_t debugServerPort;
87     uint32_t jsHeapSize;
88     std::string colorMode;
89     std::string orientation;
90     std::string aceVersion;
91     std::string screenDensity;
92     std::string configChanges;
93 };
94 
95 #endif // JSAPP_H
96