fd473f8881e60b335a5c4fc4e73014f697a1ac29
[platform/core/system/swap-probe.git] / probe_tizenapi / tizen_controls.cpp
1 /*
2  *  DA probe
3  *
4  * Copyright (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 <typeinfo>
34 #include <FApp.h>
35 #include <FUi.h>
36
37 #include "daprobe.h"
38 #include "dacollection.h"
39 #include "dahelper.h"
40 #include "tizen_probe.h"
41
42 #include "binproto.h"
43
44 using namespace Tizen::Ui;
45 using namespace Tizen::Ui::Controls;
46 using namespace Tizen::Ui::Animations;
47
48 extern IFrameAnimatorEventListener& GetFrameAnimatorEventListener();
49
50 bool IsRegisteredFrameAnimatorEventListener = false;
51
52 static enum DaOptions _sopt = OPT_UI;
53
54 #define BEFORE_ORIGINAL_TIZEN_UI(FUNCNAME, FUNCTIONPOINTER)                             \
55                 DECLARE_VARIABLE_STANDARD_NORET;                                        \
56                 GET_REAL_FUNC_TIZEN(FUNCNAME, LIBOSP_UIFW, FUNCTIONPOINTER)
57
58 namespace Tizen { namespace App {
59
60 result UiApp::AddFrame(const Tizen::Ui::Controls::Frame& frame)
61 {
62         typedef result (UiApp::*methodType)(const Tizen::Ui::Controls::Frame& frame);
63         static methodType uiapp_addframep;
64         result ret;
65
66         BEFORE_ORIGINAL_TIZEN_UI(_ZN5Tizen3App5UiApp8AddFrameERKNS_2Ui8Controls5FrameE, uiapp_addframep);
67         PRE_PROBEBLOCK();
68
69         ret = (this->*uiapp_addframep)(frame);
70
71         POST_PACK_PROBEBLOCK_BEGIN();
72         if(ret == E_SUCCESS)
73         {
74                 frame.IsInTouchMode();
75
76                 Control* parent = NULL;
77                 setProbePoint(&probeInfo);
78
79                 PREPARE_LOCAL_BUF();
80                 PACK_COMMON_BEGIN(MSG_PROBE_UICONTROL,
81                                   API_ID_result_UiApp__AddFrame_const_Tizen__Ui__Controls__Frame__frame_,
82                                   "p", voidp_to_uint64(&frame));
83                 PACK_COMMON_END('x', ret, 0, 0);
84                 PACK_UICONTROL(parent);
85                 PACK_UICONTROL(&frame);
86                 FLUSH_LOCAL_BUF();
87         }
88         POST_PACK_PROBEBLOCK_END();
89
90         return ret;
91 }
92
93 result UiApp::RemoveFrame(const Tizen::Ui::Controls::Frame &frame)
94 {
95         typedef result (UiApp::*methodType)(const Tizen::Ui::Controls::Frame& frame);
96         static methodType uiapp_removeframep;
97         result ret = 0;
98
99         BEFORE_ORIGINAL_TIZEN_UI(_ZN5Tizen3App5UiApp11RemoveFrameERKNS_2Ui8Controls5FrameE, uiapp_removeframep);
100
101         PREPARE_LOCAL_BUF();
102
103         PRE_PROBEBLOCK_BEGIN();
104         Control *parent = NULL;
105
106         PACK_COMMON_BEGIN(MSG_PROBE_UICONTROL,
107                           API_ID_result_UiApp__RemoveFrame_const_Tizen__Ui__Controls__Frame__frame_,
108                           "p", voidp_to_uint64(&frame));
109         PACK_COMMON_END('x', ret, 0, 0);
110         PACK_UICONTROL(parent);
111         PACK_UICONTROL(&frame);
112         PRE_PROBEBLOCK_END();
113
114         frame.IsInTouchMode();
115
116         ret = (this->*uiapp_removeframep)(frame);
117
118         POST_PACK_PROBEBLOCK_BEGIN();
119         PACK_RETURN_END('x', ret);
120         FLUSH_LOCAL_BUF();
121         POST_PACK_PROBEBLOCK_END();
122
123
124         return ret;
125 }
126
127 } }             // end of namespce Tizen::App
128
129
130 namespace Tizen { namespace Ui {
131
132 bool Control::IsInTouchMode(void) const
133 {
134         typedef bool (Control::*methodType)(void) const;
135         static methodType control_isintouchmodep;
136
137         GET_REAL_FUNC_TIZEN(_ZNK5Tizen2Ui7Control13IsInTouchModeEv, LIBOSP_UIFW, control_isintouchmodep);
138
139         probeBlockStart();
140         add_uiobject_hash_class((void*)(this), typeid(*this).name());
141         probeBlockEnd();
142
143         return (this->*control_isintouchmodep)();
144 }
145
146 void Control::SetName(const Tizen::Base::String &name)
147 {
148         typedef void (Control::*methodType)(const Tizen::Base::String &name);
149         static methodType control_setnamep;
150
151         BEFORE_ORIGINAL_TIZEN_UI(_ZN5Tizen2Ui7Control7SetNameERKNS_4Base6StringE, control_setnamep);
152         PRE_PROBEBLOCK();
153
154         (this->*control_setnamep)(name);
155
156         POST_PACK_PROBEBLOCK_BEGIN();
157
158         IsInTouchMode();
159         Control* parent = NULL;
160
161         PREPARE_LOCAL_BUF();
162         PACK_COMMON_BEGIN(MSG_PROBE_UICONTROL,
163                           API_ID_void_Control__SetName_const_Tizen__Base__String__name_,
164                           "p", voidp_to_uint64(&name));
165         PACK_COMMON_END('v', 0, 0, 0);
166         PACK_UICONTROL(this);
167         PACK_UICONTROL(parent);
168         FLUSH_LOCAL_BUF();
169
170         POST_PACK_PROBEBLOCK_END();
171 }
172
173 result Container::AddControl(const Control &control)
174 {
175         typedef result (Container::*methodType)(const Control &control);
176         static methodType container_addcontrolp;
177         result ret;
178
179         BEFORE_ORIGINAL_TIZEN_UI(_ZN5Tizen2Ui9Container10AddControlERKNS0_7ControlE, container_addcontrolp);
180         bfiltering = false;
181
182         PRE_PROBEBLOCK_BEGIN();
183         if(unlikely(IsRegisteredFrameAnimatorEventListener == false))
184         {
185                 char *type = NULL, *classname = NULL;
186                 if (likely(find_uiobject_hash((void*)this, &type, &classname) == 1))    // there is entry in object hash
187                 {
188                         if (strcmp(type, "Frame") == 0)
189                         {
190                                 FrameAnimator* fa = ((Frame*)this)->GetFrameAnimator();
191                                 if (fa != NULL)
192                                 {
193                                         fa->AddFrameAnimatorEventListener(GetFrameAnimatorEventListener());
194                                         IsRegisteredFrameAnimatorEventListener = true;
195                                 }
196                                 else    // frame is not yet constructed
197                                 {
198                                 }
199                         }
200                 }
201         }
202         PRE_PROBEBLOCK_END();
203
204         ret = (this->*container_addcontrolp)(control);
205
206         POST_PACK_PROBEBLOCK_BEGIN();
207         if(ret == E_SUCCESS)
208         {
209                 IsInTouchMode();
210                 control.IsInTouchMode();
211
212                 PREPARE_LOCAL_BUF();
213                 PACK_COMMON_BEGIN(MSG_PROBE_UICONTROL,
214                                   API_ID_result_Container__AddControl_const_Control__control_,
215                                   "p", voidp_to_uint64(&control));
216                 PACK_COMMON_END('x', ret, 0, 0);
217                 PACK_UICONTROL(this);
218                 PACK_UICONTROL(&control);
219                 FLUSH_LOCAL_BUF();
220         }
221         POST_PACK_PROBEBLOCK_END();
222
223         return ret;
224 }
225
226 result Container::AddControl(Control* control)
227 {
228         typedef result (Container::*methodType)(Control* control);
229         static methodType container_addcontrolp;
230         result ret;
231
232         BEFORE_ORIGINAL_TIZEN_UI(_ZN5Tizen2Ui9Container10AddControlEPNS0_7ControlE, container_addcontrolp);
233         bfiltering = false;
234
235         PRE_PROBEBLOCK_BEGIN();
236         if(unlikely(IsRegisteredFrameAnimatorEventListener == false))
237         {
238                 char *type = NULL, *classname = NULL;
239                 if (likely(find_uiobject_hash((void*)this, &type, &classname) == 1))    // there is entry in object hash
240                 {
241                         if (strcmp(type, "Frame") == 0)
242                         {
243                                 FrameAnimator* fa = ((Frame*)this)->GetFrameAnimator();
244                                 if (fa != NULL)
245                                 {
246                                         fa->AddFrameAnimatorEventListener(GetFrameAnimatorEventListener());
247                                         IsRegisteredFrameAnimatorEventListener = true;
248                                 }
249                                 else    // frame is not yet constructed
250                                 {
251                                 }
252                         }
253                 }
254         }
255         PRE_PROBEBLOCK_END();
256
257         ret = (this->*container_addcontrolp)(control);
258
259         POST_PACK_PROBEBLOCK_BEGIN();
260         if(ret == E_SUCCESS)
261         {
262                 IsInTouchMode();
263                 control->IsInTouchMode();
264
265                 PREPARE_LOCAL_BUF();
266                 PACK_COMMON_BEGIN(MSG_PROBE_UICONTROL,
267                                   API_ID_result_Container__AddControl_Control__control_,
268                                   "p", voidp_to_uint64(control));
269                 PACK_COMMON_END('x', ret, 0, 0);
270                 PACK_UICONTROL(this);
271                 PACK_UICONTROL(control);
272                 FLUSH_LOCAL_BUF();
273         }
274         POST_PACK_PROBEBLOCK_END();
275
276         return ret;
277 }
278
279 result Container::RemoveControl(const Control &control)
280 {
281         typedef result (Container::*methodType)(const Control &control);
282         static methodType container_removecontrolp;
283         result ret = 0;
284
285         BEFORE_ORIGINAL_TIZEN_UI(_ZN5Tizen2Ui9Container13RemoveControlERKNS0_7ControlE, container_removecontrolp);
286         bfiltering = false;
287
288         PREPARE_LOCAL_BUF();
289
290         control.IsInTouchMode();
291
292         PRE_PROBEBLOCK_BEGIN();
293         PACK_COMMON_BEGIN(MSG_PROBE_UICONTROL,
294                           API_ID_result_Container__RemoveControl_const_Control__control_,
295                           "p", voidp_to_uint64(&control));
296         PACK_COMMON_END('x', ret, 0, 0);
297         PACK_UICONTROL(this);
298         PACK_UICONTROL(&control);
299         PRE_PROBEBLOCK_END();
300
301         ret = (this->*container_removecontrolp)(control);
302
303         POST_PACK_PROBEBLOCK_BEGIN();
304         PACK_RETURN_END('x', ret);
305         FLUSH_LOCAL_BUF();
306         POST_PACK_PROBEBLOCK_END();
307
308         return ret;
309 }
310
311 result Container::RemoveControl(Control* control)
312 {
313         typedef result (Container::*methodType)(Control* control);
314         static methodType container_removecontrolp;
315         result ret = 0;
316
317         BEFORE_ORIGINAL_TIZEN_UI(_ZN5Tizen2Ui9Container13RemoveControlEPNS0_7ControlE, container_removecontrolp);
318         bfiltering = false;
319
320         PREPARE_LOCAL_BUF();
321
322         PRE_PROBEBLOCK_BEGIN();
323
324         control->IsInTouchMode();
325
326         PACK_COMMON_BEGIN(MSG_PROBE_UICONTROL,
327                           API_ID_result_Container__RemoveControl_Control__control_,
328                           "p", voidp_to_uint64(control));
329         PACK_COMMON_END('x', ret, 0, 0);
330         PACK_UICONTROL(this);
331         PACK_UICONTROL(control);
332         PRE_PROBEBLOCK_END();
333
334         ret = (this->*container_removecontrolp)(control);
335
336         POST_PACK_PROBEBLOCK_BEGIN();
337         PACK_RETURN_END('x', ret);
338         FLUSH_LOCAL_BUF();
339         POST_PACK_PROBEBLOCK_END();
340
341         return ret;
342 }
343
344 result Container::RemoveControl(int index)
345 {
346         typedef result (Container::*methodType)(int index);
347         static methodType container_removecontrolip;
348         result ret = 0;
349         Control *pcontrol = NULL;
350
351         BEFORE_ORIGINAL_TIZEN_UI(_ZN5Tizen2Ui9Container13RemoveControlEi, container_removecontrolip);
352         bfiltering = false;
353
354         PREPARE_LOCAL_BUF();
355
356         PRE_PROBEBLOCK_BEGIN();
357
358         pcontrol = GetControl(index);
359         pcontrol->IsInTouchMode();
360
361         PACK_COMMON_BEGIN(MSG_PROBE_UICONTROL,
362                           API_ID_result_Container__RemoveControl_int_index_,
363                           "d", index);
364         PACK_COMMON_END('x', ret, 0, 0);
365         PACK_UICONTROL(this);
366         PACK_UICONTROL(pcontrol);
367         PRE_PROBEBLOCK_END();
368
369         ret = (this->*container_removecontrolip)(index);
370
371         POST_PACK_PROBEBLOCK_BEGIN();
372         PACK_RETURN_END('x', ret);
373         FLUSH_LOCAL_BUF();
374         POST_PACK_PROBEBLOCK_END();
375
376         return ret;
377 }
378
379 void Container::RemoveAllControls(void)
380 {
381         typedef void (Container::*methodType)(void);
382         static methodType container_removeallcontrolp;
383
384         BEFORE_ORIGINAL_TIZEN_UI(_ZN5Tizen2Ui9Container17RemoveAllControlsEv, container_removeallcontrolp);
385         bfiltering = false;
386
387         PRE_PROBEBLOCK_BEGIN();
388
389         Control* pcontrol = NULL;
390
391         PREPARE_LOCAL_BUF();
392         PACK_COMMON_BEGIN(MSG_PROBE_UICONTROL,
393                           API_ID_void_Container__RemoveAllControls_void_,
394                           "", 0);
395         PACK_COMMON_END('v', 0, 0, 0);
396         PACK_UICONTROL(this);
397         PACK_UICONTROL(pcontrol);
398         FLUSH_LOCAL_BUF();
399         PRE_PROBEBLOCK_END();
400
401         (this->*container_removeallcontrolp)();
402
403         POST_PACK_PROBEBLOCK_BEGIN();
404         POST_PACK_PROBEBLOCK_END();
405
406 }
407
408 } }     // end of namespace Tizen::Ui