Modify AppCoreUiThreadBase class
[platform/core/appfw/app-core.git] / tizen-cpp / app-core-ui-cpp / app_core_ui_delegator_private.cc
1 /*
2  * Copyright (c) 2021 Samsung Electronics Co., Ltd.
3  *
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
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
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.
15  */
16
17 #include "app-core-ui-cpp/app_core_ui_delegator_private.hh"
18
19 namespace tizen_cpp {
20
21 AppCoreUiDelegator::AppCoreUiDelegator(app_core_ui_base_ops ops,
22     AppCoreUiBase* base)
23     : ops_(ops), base_(base) {
24 }
25
26 int AppCoreUiDelegator::OnReceive(aul_type type, tizen_base::Bundle b) {
27   if (ops_.base.receive)
28     return ops_.base.receive(type, b.GetHandle(), base_);
29   return -1;
30 }
31
32 int AppCoreUiDelegator::OnCreate() {
33   if (ops_.base.create)
34     return ops_.base.create(base_);
35   return -1;
36 }
37
38 int AppCoreUiDelegator::OnControl(tizen_base::Bundle b) {
39   if (ops_.base.control)
40     return ops_.base.control(b.GetHandle(), base_);
41   return -1;
42 }
43
44 int AppCoreUiDelegator::OnTerminate() {
45   if (ops_.base.terminate)
46     return ops_.base.terminate(base_);
47   return -1;
48 }
49
50 int AppCoreUiDelegator::OnSetI18n() {
51   if (ops_.base.set_i18n)
52     return ops_.base.set_i18n(base_);
53   return -1;
54 }
55
56 int AppCoreUiDelegator::OnSetEvent(IEvent::Type event) {
57   if (ops_.base.set_event)
58     ops_.base.set_event(static_cast<app_core_ui_base_event_e>(event), base_);
59   return 0;
60 }
61
62 int AppCoreUiDelegator::OnUnsetEvent(IEvent::Type event) {
63   if (ops_.base.unset_event)
64     ops_.base.unset_event(static_cast<app_core_ui_base_event_e>(event), base_);
65   return 0;
66 }
67
68 int AppCoreUiDelegator::OnTrimMemory() {
69   if (ops_.base.trim_memory)
70     ops_.base.trim_memory(base_);
71   return 0;
72 }
73
74 void AppCoreUiDelegator::OnLoopInit(int argc, char** argv) {
75   if (ops_.base.init)
76     ops_.base.init(argc, argv, base_);
77 }
78
79 void AppCoreUiDelegator::OnLoopFinish() {
80   if (ops_.base.finish)
81     ops_.base.finish(base_);
82 }
83
84 void AppCoreUiDelegator::OnLoopRun() {
85   if (ops_.base.run)
86     ops_.base.run(base_);
87 }
88
89 void AppCoreUiDelegator::OnLoopExit() {
90   if (ops_.base.exit)
91     ops_.base.exit(base_);
92 }
93
94 int AppCoreUiDelegator::OnPause() {
95   if (ops_.pause)
96     return ops_.pause(base_);
97   return -1;
98 }
99
100 int AppCoreUiDelegator::OnResume() {
101   if (ops_.resume)
102     return ops_.resume(base_);
103   return -1;
104 }
105
106 void AppCoreUiDelegator::OnShow(int type, void* event) {
107   if (ops_.window.show)
108     ops_.window.show(type, event, base_);
109 }
110
111 void AppCoreUiDelegator::OnHide(int type, void* event) {
112   if (ops_.window.hide)
113     ops_.window.hide(type, event, base_);
114 }
115
116 void AppCoreUiDelegator::OnLower(int type, void* event) {
117   if (ops_.window.lower)
118     ops_.window.lower(type, event, base_);
119 }
120
121 void AppCoreUiDelegator::OnVisibility(int type, void* event) {
122   if (ops_.window.visibility)
123     ops_.window.visibility(type, event, base_);
124 }
125
126 void AppCoreUiDelegator::OnPreVisibility(int type, void* event) {
127   if (ops_.window.pre_visibility)
128     ops_.window.pre_visibility(type, event, base_);
129 }
130
131 void AppCoreUiDelegator::OnAuxMessage(int type, void* event) {
132   if (ops_.window.aux_message)
133     ops_.window.aux_message(type, event, base_);
134 }
135
136 }  // namespace tizen_cpp