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