[FIX] argument types conformance
[platform/core/system/swap-probe.git] / probe_tizenapi / tizen_lifecycle.cpp
1 /*
2  *  DA probe
3  *
4  * Copyright (File::*c) 2000 - 2013 Samsung Electronics Co., Ltd. All rights reserved.
5  *
6  * Contact:
7  *
8  * Jaewon Lim <jaewon81.lim@samsung.com>
9  * Woojin Jung <woojin2.jung@samsung.com>
10  * Juyoung Kim <j0.kim@samsung.com>
11  * Anastasia Lyupa <a.lyupa@samsung.com>
12  *
13  * This library is free software; you can redistribute it and/or modify it under
14  * the terms of the GNU Lesser General Public License as published by the
15  * Free Software Foundation; either version 2.1 of the License, or (at your option)
16  * any later version.
17  *
18  * This library is distributed in the hope that it will be useful, but WITHOUT ANY
19  * WARRANTY; without even the implied warranty of MERCHANTABILITY or
20  * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
21  * License for more details.
22  *
23  * You should have received a copy of the GNU Lesser General Public License
24  * along with this library; if not, write to the Free Software Foundation, Inc., 51
25  * Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
26  *
27  * Contributors:
28  * - S-Core Co., Ltd
29  * - Samsung RnD Institute Russia
30  *
31  */
32
33 #include <app.h>
34 #include <Ecore.h>
35 #include <FApp.h>
36 #include <FBase.h>
37
38 #include "daprobe.h"
39 #include "dahelper.h"
40 #include "probeinfo.h"
41 #include "tizen_probe.h"
42
43 #include "binproto.h"
44 extern "C"
45 {
46 Ecore_Event_Handler* register_orientation_event_listener();
47 void unregister_orientation_event_listener(Ecore_Event_Handler* handler);
48 }
49
50 using namespace Tizen::Base;
51 using namespace Tizen::Base::Collection;
52
53 namespace Tizen { namespace App
54 {
55
56 //class _IAppImpl
57 //{
58 //      virtual void OnDeviceOrientationChanged(app_device_orientation_e orientation) = 0;
59 //};
60
61 class _AppImpl
62 {
63         static void OnTerminate(void* user_data);
64 //      static void OnDeviceOrientationChanged(app_device_orientation_e orientation, void* user_data);
65 };
66
67 class _UiAppImpl
68 //      : public Tizen::Base::Object
69 //      , public _IAppImpl
70 {
71         void OnBackground(void);
72         void OnForeground(void);
73 //      virtual void OnDeviceOrientationChanged(app_device_orientation_e orientation);
74 };
75
76 class _AppInfo
77 {
78         static void SetAppState(AppState appstate);
79 };
80
81 result UiApp::Execute(UiAppInstanceFactory pUiAppFactory,
82                 const IList* pArguments)
83 {
84         typedef result (*methodType)(UiAppInstanceFactory pFactory, const IList* pArgs);
85         static methodType uiapp_executep;
86         probeInfo_t     probeInfo;
87         int __attribute__((unused)) ret;
88         Ecore_Event_Handler* handler;
89
90         GET_REAL_FUNC_TIZEN(_ZN5Tizen3App5UiApp7ExecuteEPFPS1_vEPKNS_4Base10Collection5IListE,
91                 LIBOSP_UIFW, uiapp_executep);
92
93         probeBlockStart();
94         handler = register_orientation_event_listener();
95         if(gTraceInfo.exec_map.map_start == NULL)
96         {
97                 get_map_address(CALLER_ADDRESS, &(gTraceInfo.exec_map.map_start),
98                                                 &(gTraceInfo.exec_map.map_end));
99         }
100         setProbePoint(&probeInfo);
101         probeBlockEnd();
102
103         ret = uiapp_executep(pUiAppFactory, pArguments);
104
105         probeBlockStart();
106
107         PREPARE_LOCAL_BUF();
108         PACK_COMMON_BEGIN(MSG_PROBE_LIFECYCLE,
109                           API_ID_result_UiApp__Execute_UiAppInstanceFactory_pUiAppFactory__const_IList__pArguments_,
110                           "pp", (uint64_t)(pUiAppFactory),
111                           voidp_to_uint64(pArguments));
112         PACK_COMMON_END(ret, 0, 0);
113         FLUSH_LOCAL_BUF();
114
115         unregister_orientation_event_listener(handler);
116         probeBlockEnd();
117
118         return ret;
119 }
120
121 void _AppImpl::OnTerminate(void* user_data)
122 {
123         typedef void (*methodType)(void*);
124         static methodType appimpl_onterminatep;
125         probeInfo_t     probeInfo;
126
127         GET_REAL_FUNC_TIZEN(_ZN5Tizen3App8_AppImpl11OnTerminateEPv, LIBOSP_APPFW, appimpl_onterminatep);
128
129         probeBlockStart();
130         setProbePoint(&probeInfo);
131
132         PREPARE_LOCAL_BUF();
133         PACK_COMMON_BEGIN(MSG_PROBE_LIFECYCLE,
134                           API_ID_void__AppImpl__OnTerminate_void__user_data_,
135                           "p", voidp_to_uint64(user_data));
136         PACK_COMMON_END(0, 0, 0);
137         FLUSH_LOCAL_BUF();
138
139         probeBlockEnd();
140
141         appimpl_onterminatep(user_data);
142 }
143 /*
144 void _AppImpl::OnDeviceOrientationChanged(app_device_orientation_e orientation, void* user_data)
145 {
146         typedef void (*methodType)(app_device_orientation_e, void*);
147         static methodType appimpl_ondeviceorientationchangedp;
148
149         GET_REAL_FUNC_TIZEN(_ZN5Tizen3App8_AppImpl26OnDeviceOrientationChangedE24app_device_orientation_ePv,
150                         LIBOSP_APPFW, appimpl_ondeviceorientationchangedp);
151
152         probeBlockStart();
153         on_orientation_changed((int)orientation, false);
154         probeBlockEnd();
155
156         appimpl_ondeviceorientationchangedp(orientation, user_data);
157 }
158 */
159 void _AppInfo::SetAppState(AppState appState)
160 {
161         typedef void (*methodType)(AppState appstate);
162         static methodType appinfo_setappstatep;
163         probeInfo_t     probeInfo;
164
165         GET_REAL_FUNC_TIZEN(_ZN5Tizen3App8_AppInfo11SetAppStateENS0_8AppStateE, LIBOSP_APPFW, appinfo_setappstatep);
166
167         probeBlockStart();
168         if(appState == RUNNING)
169         {
170                 setProbePoint(&probeInfo);
171
172                 PREPARE_LOCAL_BUF();
173                 PACK_COMMON_BEGIN(MSG_PROBE_LIFECYCLE,
174                                   API_ID_void__AppInfo__SetAppState_AppState_appState_,
175                                   "p", (uint64_t)(appState));
176                 PACK_COMMON_END(0, 0, 0);
177                 FLUSH_LOCAL_BUF();
178         }
179         probeBlockEnd();
180
181         appinfo_setappstatep(appState);
182 }
183
184 void _UiAppImpl::OnBackground(void)
185 {
186         typedef void (_UiAppImpl::*methodType)(void);
187         static methodType uiappimpl_onbackgroundp;
188         probeInfo_t     probeInfo;
189
190         GET_REAL_FUNC_TIZEN(_ZN5Tizen3App10_UiAppImpl12OnBackgroundEv, LIBOSP_UIFW, uiappimpl_onbackgroundp);
191
192         probeBlockStart();
193         SCREENSHOT_LOCK();
194         setProbePoint(&probeInfo);
195
196         PREPARE_LOCAL_BUF();
197         PACK_COMMON_BEGIN(MSG_PROBE_LIFECYCLE,
198                           API_ID_void__UiAppImpl__OnBackground_void_,
199                           "", 0);
200         PACK_COMMON_END(0, 0, 0);
201         FLUSH_LOCAL_BUF();
202
203         probeBlockEnd();
204
205         (this->*uiappimpl_onbackgroundp)();
206 }
207
208 void _UiAppImpl::OnForeground(void)
209 {
210         typedef void (_UiAppImpl::*methodType)(void);
211         static methodType uiappimpl_onforegroundp;
212         probeInfo_t     probeInfo;
213
214         GET_REAL_FUNC_TIZEN(_ZN5Tizen3App10_UiAppImpl12OnForegroundEv, LIBOSP_UIFW, uiappimpl_onforegroundp);
215
216         probeBlockStart();
217         setProbePoint(&probeInfo);
218
219         PREPARE_LOCAL_BUF();
220         PACK_COMMON_BEGIN(MSG_PROBE_LIFECYCLE,
221                           API_ID_void__UiAppImpl__OnForeground_void_,
222                           "", 0);
223         PACK_COMMON_END(0, 0, 0);
224         FLUSH_LOCAL_BUF();
225
226         SCREENSHOT_UNLOCK();
227 //      SCREENSHOT_DONE();
228         probeBlockEnd();
229
230         (this->*uiappimpl_onforegroundp)();
231 }
232
233 /*
234 void _UiAppImpl::OnDeviceOrientationChanged(app_device_orientation_e orientation)
235 {
236         typedef void (*methodType)(_UiAppImpl* th, app_device_orientation_e orientation);
237         static methodType uiappimpl_ondeviceorientationchangedp;
238
239         GET_REAL_FUNC_TIZEN(_ZThn4_N5Tizen3App10_UiAppImpl26OnDeviceOrientationChangedE24app_device_orientation_e,
240                         LIBOSP_UIFW, uiappimpl_ondeviceorientationchangedp);
241
242         probeBlockStart();
243         on_orientation_changed((int)orientation, false);
244         probeBlockEnd();
245
246         uiappimpl_ondeviceorientationchangedp(static_cast<_UiAppImpl*>(dynamic_cast<_IAppImpl*>(this)), orientation);
247 }
248 */
249 } }     // end of namespace