2 * Copyright (c) 2021 Samsung Electronics Co., Ltd.
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
17 #ifndef TIZEN_CPP_APP_CORE_CPP_APP_CORE_BASE_HH_
18 #define TIZEN_CPP_APP_CORE_CPP_APP_CORE_BASE_HH_
23 #include <interface_app_core.hh>
24 #include <interface_main_loop.hh>
27 #define EXPORT_API __attribute__((visibility("default")))
31 class EXPORT_API AppCoreBase : public IAppCore, public IMainLoop {
35 ROTATION_PORTRAIT_NORMAL,
36 ROTATION_PORTRAIT_REVERSE,
37 ROTATION_LANDSCAPE_NORMAL,
38 ROTATION_LANDSCAPE_REVERSE,
42 SUSPENDED_STATE_WILL_ENTER_SUSPEND = 0,
43 SUSPENDED_STATE_DID_EXIT_FROM_SUSPEND
47 DISPLAY_STATE_UNKNOWN,
53 FEATURE_BACKGROUND_MANAGEMENT = 0x1,
54 FEATURE_CHARGER_STATUS = 0x2
57 class EventBase : public IEvent {
59 explicit EventBase(Type type);
61 Type GetType() const override;
62 std::string GetVal(std::string cur) const;
63 int GetVal(int cur) const;
64 virtual void SetVal(std::string val);
65 virtual void SetVal(int val);
69 std::unique_ptr<Impl> impl_;
73 virtual ~AppCoreBase();
74 static AppCoreBase* GetContext();
76 virtual void Run(int argc, char** argv);
78 virtual void Dispose();
79 void Init(int argc, char** argv);
81 int OnReceive(aul_type type, tizen_base::Bundle b) override;
82 int OnCreate() override;
83 int OnControl(tizen_base::Bundle b) override;
84 int OnTerminate() override;
85 int OnSetI18n() override;
86 int OnSetEvent(IEvent::Type event) override;
87 int OnUnsetEvent(IEvent::Type event) override;
88 int OnTrimMemory() override;
89 void AddEvent(std::shared_ptr<EventBase> event);
90 bool RemoveEvent(std::shared_ptr<EventBase> event);
91 void RaiseEvent(int event, IEvent::Type type);
92 void RaiseEvent(const std::string& event, IEvent::Type type);
96 void ToggleSuspendedState();
97 int SetI18n(std::string domain_name, std::string dir_name);
98 void AddSuspendTimer();
99 void RemoveSuspendTimer();
100 void SetFeature(int feature);
101 int GetFeature() const;
102 static RotationState GetRotationState();
103 static void SetDisplayState(DisplayState state);
104 static DisplayState GetDisplayState();
105 static int EnableWatchdog();
106 static int DisableWatchdog();
107 static int KickWatchdog();
110 void SetCoreDelegator(IAppCore* delegator);
111 void SetLoopDelegator(IMainLoop* delegator);
112 static AppCoreBase* context_;
116 std::unique_ptr<Impl> impl_;
119 } // namespace tizen_cpp
121 #endif // TIZEN_CPP_APP_CORE_CPP_APP_CORE_BASE_HH_