add sync probes in bada_sync.cpp
[platform/core/system/swap-probe.git] / probe_badaapi / osp_controls.cpp
1 /*
2  *  DA probe
3  *
4  * Copyright (c) 2000 - 2011 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  *
12  * This library is free software; you can redistribute it and/or modify it under
13  * the terms of the GNU Lesser General Public License as published by the
14  * Free Software Foundation; either version 2.1 of the License, or (at your option)
15  * any later version.
16  *
17  * This library is distributed in the hope that it will be useful, but WITHOUT ANY
18  * WARRANTY; without even the implied warranty of MERCHANTABILITY or
19  * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
20  * License for more details.
21  *
22  * You should have received a copy of the GNU Lesser General Public License
23  * along with this library; if not, write to the Free Software Foundation, Inc., 51
24  * Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
25  *
26  * Contributors:
27  * - S-Core Co., Ltd
28  *
29  */
30
31 #include <typeinfo>
32 #include <FApp.h>
33 #include <FUi.h>
34
35 #include "daprobe.h"
36 #include "dacollection.h"
37 #include "dahelper.h"
38 #include "osp_probe.h"
39
40 #include "binproto.h"
41
42 using namespace Tizen::Ui;
43 using namespace Tizen::Ui::Controls;
44 using namespace Tizen::Ui::Animations;
45
46 #define APPEND_LOG_CONTROL_OSP(CONTROL)                                                                                                         \
47         do {                                                                                                                                                                    \
48                 if(unlikely(CONTROL == NULL)) {                                                                                                         \
49                         log.length += sprintf(log.data + log.length, "`,`,`,");                                                 \
50                 } else {                                                                                                                                                        \
51                         char *type = NULL, *name = NULL;                                                                                                \
52                         if(find_object_hash((void*)(CONTROL), &type, &name) == 1) {                                             \
53                                 log.length += sprintf(log.data + log.length, "`,%s`,%s", type, name);           \
54                         } else {                                                                                                                                                \
55                                 log.length += sprintf(log.data + log.length, "`,`,");                                           \
56                         }                                                                                                                                                               \
57                         log.length += sprintf(log.data + log.length, "`,%p",                                                    \
58                                         (void*)(CONTROL));                                                                                                              \
59                 }                                                                                                                                                                       \
60         } while(0)
61
62 extern IFrameAnimatorEventListener& GetFrameAnimatorEventListener();
63
64 bool IsRegisteredFrameAnimatorEventListener = false;
65
66 namespace Tizen { namespace App {
67
68 result UiApp::AddFrame(const Tizen::Ui::Controls::Frame& frame)
69 {
70         typedef result (UiApp::*methodType)(const Tizen::Ui::Controls::Frame& frame);
71         static methodType uiapp_addframep;
72         DECLARE_COMMON_VARIABLE;
73         result ret;
74
75         GET_REAL_FUNC_OSP(_ZN5Tizen3App5UiApp8AddFrameERKNS_2Ui8Controls5FrameE, LIBOSP_UIFW, uiapp_addframep);
76
77         ret = (this->*uiapp_addframep)(frame);
78
79         probeBlockStart();
80         if(ret == E_SUCCESS)
81         {
82                 frame.IsInTouchMode();
83
84                 if(isOptionEnabled(OPT_UI))
85                 {
86                         Control* parent = NULL;
87                         setProbePoint(&probeInfo);
88                         INIT_LOG;
89                         APPEND_LOG_BASIC_NAME(LC_UICREATE, "AddFrame");
90                         APPEND_LOG_COMMON_NONE(CALLER_ADDRESS);
91                         APPEND_LOG_CONTROL_OSP(parent);
92                         APPEND_LOG_CONTROL_OSP(&frame);
93                         printLog(&log, MSG_LOG);
94
95                         PREPARE_LOCAL_BUF();
96                         PACK_COMMON_BEGIN(MSG_PROBE_UICONTROL,
97                                           LC_UICREATE,
98                                           "p", &frame);
99                         PACK_COMMON_END(ret, 0, 0);
100                         PACK_UICONTROL(parent);
101                         PACK_UICONTROL(&frame);
102                         FLUSH_LOCAL_BUF();
103                 }
104         }
105         probeBlockEnd();
106
107         return ret;
108 }
109
110 result UiApp::RemoveFrame(const Tizen::Ui::Controls::Frame &frame)
111 {
112         typedef result (UiApp::*methodType)(const Tizen::Ui::Controls::Frame& frame);
113         static methodType uiapp_removeframep;
114         DECLARE_COMMON_VARIABLE;
115         result ret;
116         bool bOption;
117
118         PREPARE_LOCAL_BUF();
119
120         GET_REAL_FUNC_OSP(_ZN5Tizen3App5UiApp11RemoveFrameERKNS_2Ui8Controls5FrameE, LIBOSP_UIFW, uiapp_removeframep);
121
122         probeBlockStart();
123         frame.IsInTouchMode();
124
125         if((bOption = isOptionEnabled(OPT_UI)))
126         {
127                 Control* parent = NULL;
128                 setProbePoint(&probeInfo);
129                 INIT_LOG;
130                 APPEND_LOG_BASIC_NAME(LC_UICREATE, "RemoveFrame");
131                 APPEND_LOG_COMMON_NONE(CALLER_ADDRESS);
132                 APPEND_LOG_CONTROL_OSP(parent);
133                 APPEND_LOG_CONTROL_OSP(&frame);
134                 
135                 PACK_COMMON_BEGIN(MSG_PROBE_UICONTROL,
136                           LC_UICREATE,
137                           "p", &frame);
138                 PACK_COMMON_END(0, 0, 0);
139                 PACK_UICONTROL(parent);
140                 PACK_UICONTROL(&frame);
141         }
142         probeBlockEnd();
143
144         ret = (this->*uiapp_removeframep)(frame);
145
146         probeBlockStart();
147         if(ret == E_SUCCESS)
148         {
149                 if(bOption)
150                         printLog(&log, MSG_LOG);
151         }
152         probeBlockEnd();
153         
154         if(bOption)
155                 PACK_RETURN_END(ret);
156                 
157         FLUSH_LOCAL_BUF();
158         
159         return ret;
160 }
161
162 } }             // end of namespce Tizen::App
163
164
165 namespace Tizen { namespace Ui {
166
167 bool Control::IsInTouchMode(void) const
168 {
169         typedef bool (Control::*methodType)(void) const;
170         static methodType control_isintouchmodep;
171
172         GET_REAL_FUNC_OSP(_ZNK5Tizen2Ui7Control13IsInTouchModeEv, LIBOSP_UIFW, control_isintouchmodep);
173
174         probeBlockStart();
175         add_object_hash_class((void*)(this), typeid(*this).name());
176         probeBlockEnd();
177
178         return (this->*control_isintouchmodep)();
179 }
180
181 void Control::SetName(const Tizen::Base::String &name)
182 {
183         typedef void (Control::*methodType)(const Tizen::Base::String &name);
184         static methodType control_setnamep;
185         DECLARE_COMMON_VARIABLE;
186
187         GET_REAL_FUNC_OSP(_ZN5Tizen2Ui7Control7SetNameERKNS_4Base6StringE, LIBOSP_UIFW, control_setnamep);
188
189         (this->*control_setnamep)(name);
190
191         probeBlockStart();
192         IsInTouchMode();
193
194         if(isOptionEnabled(OPT_UI))
195         {
196                 Control* parent = NULL;
197                 setProbePoint(&probeInfo);
198                 INIT_LOG;
199                 APPEND_LOG_BASIC_NAME(LC_UICREATE, "SetName");
200                 APPEND_LOG_COMMON_NONE(CALLER_ADDRESS);
201                 APPEND_LOG_CONTROL_OSP(this);
202                 APPEND_LOG_CONTROL_OSP(parent);
203                 printLog(&log, MSG_LOG);
204                 
205                 PREPARE_LOCAL_BUF();
206                 PACK_COMMON_BEGIN(MSG_PROBE_UICONTROL,
207                                   LC_UICREATE,
208                                   "p", this);
209                 PACK_COMMON_END(0, 0, 0);
210                 PACK_UICONTROL(this);
211                 PACK_UICONTROL(parent);
212                 FLUSH_LOCAL_BUF();
213         }
214         probeBlockEnd();
215 }
216
217 result Container::AddControl(const Control &control)
218 {
219         typedef result (Container::*methodType)(const Control &control);
220         static methodType container_addcontrolp;
221         DECLARE_COMMON_VARIABLE;
222         result ret;
223
224         GET_REAL_FUNC_OSP(_ZN5Tizen2Ui9Container10AddControlERKNS0_7ControlE, LIBOSP_UIFW, container_addcontrolp);
225
226         probeBlockStart();
227         if(unlikely(IsRegisteredFrameAnimatorEventListener == false))
228         {
229                 char *type = NULL, *classname = NULL;
230                 if(likely(find_object_hash((void*)this, &type, &classname) == 1))       // there is entry in object hash
231                 {
232                         if(strcmp(type, "Frame") == 0)
233                         {
234                                 FrameAnimator* fa = ((Frame*)this)->GetFrameAnimator();
235                                 if(fa != NULL)
236                                 {
237                                         fa->AddFrameAnimatorEventListener(GetFrameAnimatorEventListener());
238                                         IsRegisteredFrameAnimatorEventListener = true;
239                                 }
240                                 else    // frame is not yet constructed
241                                 {
242                                 }
243                         }
244                 }
245         }
246         probeBlockEnd();
247
248         ret = (this->*container_addcontrolp)(control);
249
250         probeBlockStart();
251         if(ret == E_SUCCESS)
252         {
253                 IsInTouchMode();
254                 control.IsInTouchMode();
255
256                 if(isOptionEnabled(OPT_UI))
257                 {
258                         setProbePoint(&probeInfo);
259                         INIT_LOG;
260                         APPEND_LOG_BASIC_NAME(LC_UICREATE, "AddControl");
261                         APPEND_LOG_COMMON_NONE(CALLER_ADDRESS);
262                         APPEND_LOG_CONTROL_OSP(this);
263                         APPEND_LOG_CONTROL_OSP(&control);
264                         printLog(&log, MSG_LOG);
265                         
266                         PREPARE_LOCAL_BUF();
267                         PACK_COMMON_BEGIN(MSG_PROBE_UICONTROL,
268                                           LC_UICREATE,
269                                           "p", this);
270                         PACK_COMMON_END(ret, 0, 0);
271                         PACK_UICONTROL(this);
272                         PACK_UICONTROL(&control);
273                         FLUSH_LOCAL_BUF();
274                 }
275         }
276         probeBlockEnd();
277
278         return ret;
279 }
280
281 result Container::RemoveControl(const Control &control)
282 {
283         typedef result (Container::*methodType)(const Control &control);
284         static methodType container_removecontrolp;
285         DECLARE_COMMON_VARIABLE;
286         result ret;
287         bool bOption;
288
289         PREPARE_LOCAL_BUF();
290
291         GET_REAL_FUNC_OSP(_ZN5Tizen2Ui9Container13RemoveControlERKNS0_7ControlE, LIBOSP_UIFW, container_removecontrolp);
292
293         probeBlockStart();
294         control.IsInTouchMode();
295
296         if((bOption = isOptionEnabled(OPT_UI)))
297         {
298                 setProbePoint(&probeInfo);
299                 INIT_LOG;
300                 APPEND_LOG_BASIC_NAME(LC_UICREATE, "RemoveControl");
301                 APPEND_LOG_COMMON_NONE(CALLER_ADDRESS);
302                 APPEND_LOG_CONTROL_OSP(this);
303                 APPEND_LOG_CONTROL_OSP(&control);
304                 
305                 PACK_COMMON_BEGIN(MSG_PROBE_UICONTROL,
306                                   LC_UICREATE,
307                                   "p", this);
308                 PACK_COMMON_END(0, 0, 0);
309                 PACK_UICONTROL(this);
310                 PACK_UICONTROL(&control);
311         }
312         probeBlockEnd();
313
314         ret = (this->*container_removecontrolp)(control);
315
316         probeBlockStart();
317         if(ret == E_SUCCESS)
318         {
319                 if(bOption)
320                         printLog(&log, MSG_LOG);
321         }
322         probeBlockEnd();
323
324         if(bOption)
325                 PACK_RETURN_END(ret);
326         
327         FLUSH_LOCAL_BUF();
328                         
329         return ret;
330 }
331
332 result Container::RemoveControl(int index)
333 {
334         typedef result (Container::*methodType)(int index);
335         static methodType container_removecontrolip;
336         DECLARE_COMMON_VARIABLE;
337         result ret;
338         bool bOption;
339
340         PREPARE_LOCAL_BUF();
341
342         GET_REAL_FUNC_OSP(_ZN5Tizen2Ui9Container13RemoveControlEi, LIBOSP_UIFW, container_removecontrolip);
343
344         probeBlockStart();
345         Control* pcontrol = GetControl(index);
346         pcontrol->IsInTouchMode();
347
348         if((bOption = isOptionEnabled(OPT_UI)))
349         {
350                 setProbePoint(&probeInfo);
351                 INIT_LOG;
352                 APPEND_LOG_BASIC_NAME(LC_UICREATE, "RemoveControl");
353                 APPEND_LOG_COMMON_NONE(CALLER_ADDRESS);
354                 APPEND_LOG_CONTROL_OSP(this);
355                 APPEND_LOG_CONTROL_OSP(pcontrol);
356                 
357                 PACK_COMMON_BEGIN(MSG_PROBE_UICONTROL,
358                                   LC_UICREATE,
359                                   "p", this);
360                 PACK_COMMON_END(0, 0, 0);
361                 PACK_UICONTROL(this);
362                 PACK_UICONTROL(pcontrol);
363         }
364         probeBlockEnd();
365
366         ret = (this->*container_removecontrolip)(index);
367
368         probeBlockStart();
369         if(ret == E_SUCCESS)
370         {
371                 if(bOption)
372                         printLog(&log, MSG_LOG);
373         }
374         probeBlockEnd();
375
376         if(bOption)
377                 PACK_RETURN_END(ret);
378         
379         FLUSH_LOCAL_BUF();
380         
381         return ret;
382 }
383
384 void Container::RemoveAllControls(void)
385 {
386         typedef void (Container::*methodType)(void);
387         static methodType container_removeallcontrolp;
388         DECLARE_COMMON_VARIABLE;
389
390         GET_REAL_FUNC_OSP(_ZN5Tizen2Ui9Container17RemoveAllControlsEv, LIBOSP_UIFW, container_removeallcontrolp);
391
392         probeBlockStart();
393         if(isOptionEnabled(OPT_UI))
394         {
395                 Control* pcontrol = NULL;
396                 setProbePoint(&probeInfo);
397                 INIT_LOG;
398                 APPEND_LOG_BASIC_NAME(LC_UICREATE, "RemoveAllControl");
399                 APPEND_LOG_COMMON_NONE(CALLER_ADDRESS);
400                 APPEND_LOG_CONTROL_OSP(this);
401                 APPEND_LOG_CONTROL_OSP(pcontrol);
402                 printLog(&log, MSG_LOG);
403                 
404                 PREPARE_LOCAL_BUF();
405                 PACK_COMMON_BEGIN(MSG_PROBE_UICONTROL,
406                                   LC_UICREATE,
407                                   "p", this);
408                 PACK_COMMON_END(0, 0, 0);
409                 PACK_UICONTROL(this);
410                 PACK_UICONTROL(pcontrol);
411                 FLUSH_LOCAL_BUF();
412         }
413         probeBlockEnd();
414
415         (this->*container_removeallcontrolp)();
416 }
417
418 } }     // end of namespace Tizen::Ui