0e91985a4cfa0118e6c52d9243ceac514794dd89
[platform/core/system/swap-probe.git] / probe_badaapi / osp_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 "osp_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 namespace Tizen { namespace App {
53
54 result UiApp::AddFrame(const Tizen::Ui::Controls::Frame& frame)
55 {
56         typedef result (UiApp::*methodType)(const Tizen::Ui::Controls::Frame& frame);
57         static methodType uiapp_addframep;
58         probeInfo_t     probeInfo;
59         result ret;
60
61         GET_REAL_FUNC_OSP(_ZN5Tizen3App5UiApp8AddFrameERKNS_2Ui8Controls5FrameE, LIBOSP_UIFW, uiapp_addframep);
62
63         ret = (this->*uiapp_addframep)(frame);
64
65         probeBlockStart();
66         if(ret == E_SUCCESS)
67         {
68                 frame.IsInTouchMode();
69
70                 if(isOptionEnabled(OPT_UI))
71                 {
72                         Control* parent = NULL;
73                         setProbePoint(&probeInfo);
74
75                         PREPARE_LOCAL_BUF();
76                         PACK_COMMON_BEGIN(MSG_PROBE_UICONTROL,
77                                           API_ID_result_UiApp__AddFrame_const_Tizen__Ui__Controls__Frame__frame_,
78                                           "p", &frame);
79                         PACK_COMMON_END(ret, 0, 0);
80                         PACK_UICONTROL(parent);
81                         PACK_UICONTROL(&frame);
82                         FLUSH_LOCAL_BUF();
83                 }
84         }
85         probeBlockEnd();
86
87         return ret;
88 }
89
90 result UiApp::RemoveFrame(const Tizen::Ui::Controls::Frame &frame)
91 {
92         typedef result (UiApp::*methodType)(const Tizen::Ui::Controls::Frame& frame);
93         static methodType uiapp_removeframep;
94         probeInfo_t     probeInfo;
95         result ret;
96         bool bOption;
97
98         GET_REAL_FUNC_OSP(_ZN5Tizen3App5UiApp11RemoveFrameERKNS_2Ui8Controls5FrameE, LIBOSP_UIFW, uiapp_removeframep);
99
100         probeBlockStart();
101         
102         PREPARE_LOCAL_BUF();
103         
104         frame.IsInTouchMode();
105
106         if((bOption = isOptionEnabled(OPT_UI)))
107         {
108                 Control* parent = NULL;
109                 setProbePoint(&probeInfo);
110                 
111                 PACK_COMMON_BEGIN(MSG_PROBE_UICONTROL,
112                                   API_ID_result_UiApp__RemoveFrame_const_Tizen__Ui__Controls__Frame__frame_,
113                                   "p", &frame);
114                 PACK_COMMON_END(0, 0, 0);
115                 PACK_UICONTROL(parent);
116                 PACK_UICONTROL(&frame);
117         }
118         probeBlockEnd();
119
120         ret = (this->*uiapp_removeframep)(frame);
121
122         probeBlockStart();
123         
124         if(bOption)
125         {
126                 PACK_RETURN_END(ret);
127         }
128         
129         FLUSH_LOCAL_BUF();
130                 
131         probeBlockEnd();
132         
133         return ret;
134 }
135
136 } }             // end of namespce Tizen::App
137
138
139 namespace Tizen { namespace Ui {
140
141 bool Control::IsInTouchMode(void) const
142 {
143         typedef bool (Control::*methodType)(void) const;
144         static methodType control_isintouchmodep;
145
146         GET_REAL_FUNC_OSP(_ZNK5Tizen2Ui7Control13IsInTouchModeEv, LIBOSP_UIFW, control_isintouchmodep);
147
148         probeBlockStart();
149         add_object_hash_class((void*)(this), typeid(*this).name());
150         probeBlockEnd();
151
152         return (this->*control_isintouchmodep)();
153 }
154
155 void Control::SetName(const Tizen::Base::String &name)
156 {
157         typedef void (Control::*methodType)(const Tizen::Base::String &name);
158         static methodType control_setnamep;
159         probeInfo_t     probeInfo;
160
161         GET_REAL_FUNC_OSP(_ZN5Tizen2Ui7Control7SetNameERKNS_4Base6StringE, LIBOSP_UIFW, control_setnamep);
162
163         (this->*control_setnamep)(name);
164
165         probeBlockStart();
166         IsInTouchMode();
167
168         if(isOptionEnabled(OPT_UI))
169         {
170                 Control* parent = NULL;
171                 setProbePoint(&probeInfo);
172                 
173                 PREPARE_LOCAL_BUF();
174                 PACK_COMMON_BEGIN(MSG_PROBE_UICONTROL,
175                                   API_ID_void_Control__SetName_const_Tizen__Base__String__name_,
176                                   "p", this);
177                 PACK_COMMON_END(0, 0, 0);
178                 PACK_UICONTROL(this);
179                 PACK_UICONTROL(parent);
180                 FLUSH_LOCAL_BUF();
181         }
182         probeBlockEnd();
183 }
184
185 result Container::AddControl(const Control &control)
186 {
187         typedef result (Container::*methodType)(const Control &control);
188         static methodType container_addcontrolp;
189         probeInfo_t     probeInfo;
190         result ret;
191
192         GET_REAL_FUNC_OSP(_ZN5Tizen2Ui9Container10AddControlERKNS0_7ControlE, LIBOSP_UIFW, container_addcontrolp);
193
194         probeBlockStart();
195         if(unlikely(IsRegisteredFrameAnimatorEventListener == false))
196         {
197                 char *type = NULL, *classname = NULL;
198                 if(likely(find_object_hash((void*)this, &type, &classname) == 1))       // there is entry in object hash
199                 {
200                         if(strcmp(type, "Frame") == 0)
201                         {
202                                 FrameAnimator* fa = ((Frame*)this)->GetFrameAnimator();
203                                 if(fa != NULL)
204                                 {
205                                         fa->AddFrameAnimatorEventListener(GetFrameAnimatorEventListener());
206                                         IsRegisteredFrameAnimatorEventListener = true;
207                                 }
208                                 else    // frame is not yet constructed
209                                 {
210                                 }
211                         }
212                 }
213         }
214         probeBlockEnd();
215
216         ret = (this->*container_addcontrolp)(control);
217
218         probeBlockStart();
219         if(ret == E_SUCCESS)
220         {
221                 IsInTouchMode();
222                 control.IsInTouchMode();
223
224                 if(isOptionEnabled(OPT_UI))
225                 {
226                         setProbePoint(&probeInfo);
227                         
228                         PREPARE_LOCAL_BUF();
229                         PACK_COMMON_BEGIN(MSG_PROBE_UICONTROL,
230                                           API_ID_result_Container__AddControl_const_Control__control_,
231                                           "p", this);
232                         PACK_COMMON_END(ret, 0, 0);
233                         PACK_UICONTROL(this);
234                         PACK_UICONTROL(&control);
235                         FLUSH_LOCAL_BUF();
236                 }
237         }
238         probeBlockEnd();
239
240         return ret;
241 }
242
243 result Container::RemoveControl(const Control &control)
244 {
245         typedef result (Container::*methodType)(const Control &control);
246         static methodType container_removecontrolp;
247         probeInfo_t     probeInfo;
248         result ret;
249         bool bOption;
250
251         GET_REAL_FUNC_OSP(_ZN5Tizen2Ui9Container13RemoveControlERKNS0_7ControlE, LIBOSP_UIFW, container_removecontrolp);
252
253         probeBlockStart();
254
255         PREPARE_LOCAL_BUF();
256
257         control.IsInTouchMode();
258
259         if((bOption = isOptionEnabled(OPT_UI)))
260         {
261                 setProbePoint(&probeInfo);
262                 
263                 PACK_COMMON_BEGIN(MSG_PROBE_UICONTROL,
264                                   API_ID_result_Container__RemoveControl_const_Control__control_,
265                                   "p", this);
266                 PACK_COMMON_END(0, 0, 0);
267                 PACK_UICONTROL(this);
268                 PACK_UICONTROL(&control);
269         }
270         probeBlockEnd();
271
272         ret = (this->*container_removecontrolp)(control);
273
274         probeBlockStart();
275
276         if(bOption)
277         {
278                 PACK_RETURN_END(ret);
279         }
280         
281         FLUSH_LOCAL_BUF();      
282
283         probeBlockEnd();
284                         
285         return ret;
286 }
287
288 result Container::RemoveControl(int index)
289 {
290         typedef result (Container::*methodType)(int index);
291         static methodType container_removecontrolip;
292         probeInfo_t     probeInfo;
293         result ret;
294         bool bOption;
295
296         GET_REAL_FUNC_OSP(_ZN5Tizen2Ui9Container13RemoveControlEi, LIBOSP_UIFW, container_removecontrolip);
297
298         probeBlockStart();
299
300         PREPARE_LOCAL_BUF();
301
302         Control* pcontrol = GetControl(index);
303         pcontrol->IsInTouchMode();
304
305         if((bOption = isOptionEnabled(OPT_UI)))
306         {
307                 setProbePoint(&probeInfo);
308                 
309                 PACK_COMMON_BEGIN(MSG_PROBE_UICONTROL,
310                                   API_ID_result_Container__RemoveControl_int_index_,
311                                   "p", this);
312                 PACK_COMMON_END(0, 0, 0);
313                 PACK_UICONTROL(this);
314                 PACK_UICONTROL(pcontrol);
315         }
316         probeBlockEnd();
317
318         ret = (this->*container_removecontrolip)(index);
319
320         probeBlockStart();
321
322         if(bOption)
323         {
324                 PACK_RETURN_END(ret);
325         }
326
327         FLUSH_LOCAL_BUF();
328
329         probeBlockEnd();
330         
331         return ret;
332 }
333
334 void Container::RemoveAllControls(void)
335 {
336         typedef void (Container::*methodType)(void);
337         static methodType container_removeallcontrolp;
338         probeInfo_t     probeInfo;
339
340         GET_REAL_FUNC_OSP(_ZN5Tizen2Ui9Container17RemoveAllControlsEv, LIBOSP_UIFW, container_removeallcontrolp);
341
342         probeBlockStart();
343         if(isOptionEnabled(OPT_UI))
344         {
345                 Control* pcontrol = NULL;
346                 setProbePoint(&probeInfo);
347                 
348                 PREPARE_LOCAL_BUF();
349                 PACK_COMMON_BEGIN(MSG_PROBE_UICONTROL,
350                                   API_ID_void_Container__RemoveAllControls_void_,
351                                   "p", this);
352                 PACK_COMMON_END(0, 0, 0);
353                 PACK_UICONTROL(this);
354                 PACK_UICONTROL(pcontrol);
355                 FLUSH_LOCAL_BUF();
356         }
357         probeBlockEnd();
358
359         (this->*container_removeallcontrolp)();
360 }
361
362 } }     // end of namespace Tizen::Ui