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