[FIX] argument types conformance
[platform/core/system/swap-probe.git] / probe_ui / tizen_scenemanager.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 <assert.h>
34 #include <FBase.h>
35 #include <FUi.h>
36
37 #include "daprobe.h"
38 #include "dacollection.h"       // for find_object_hash
39 #include "dahelper.h"           // for captureScreen
40 #include "tizen_probe.h"
41
42 #include "binproto.h"
43
44 using namespace Tizen::Base;
45 using namespace Tizen::Ui::Controls;
46 using namespace Tizen::Ui::Scenes;
47
48 int SceneManagerUsed = 0;
49
50 class SceneManagerEventListener : public ISceneManagerEventListener
51 {
52 public:
53         virtual void OnSceneTransitionCompleted(const SceneId &previousSceneId, const SceneId &currentSceneId);
54         virtual void OnSceneTransitionStarted(const SceneId &currentSceneId, const SceneId &nextSceneId);
55         static SceneManagerEventListener& GetInstance();
56 private:
57         static SceneManagerEventListener rInstance;
58         unsigned long startTime;
59 };
60
61 SceneManagerEventListener SceneManagerEventListener::rInstance;
62
63 void SceneManagerEventListener::OnSceneTransitionCompleted(const SceneId &previousSceneId, const SceneId &currentSceneId)
64 {
65         probeBlockStart();
66         {
67                 SceneManager* scenemanager = SceneManager::GetInstance();
68
69                 if(scenemanager->GetCurrentSceneId() == currentSceneId)
70                 {
71                         if(isOptionEnabled(OPT_UI))
72                         {
73                                 probeInfo_t     probeInfo;
74                                 Scene* scene;
75                                 String sceneid, formid, panelid;
76                                 Form* pform;
77                                 Panel* ppanel;
78                                 unsigned long transition, user = 0;
79
80                                 setProbePoint(&probeInfo);
81
82                                 scene = scenemanager->GetCurrentScene();
83                                 sceneid = scene->GetSceneId();
84                                 formid = scene->GetFormId();
85                                 panelid = scene->GetPanelId();
86                                 pform = scene->GetForm();
87                                 ppanel = scene->GetPanel();
88
89                                 transition = (probeInfo.currentTime - startTime);
90
91                                 char scene_name[50];
92                                 WcharToChar(scene_name, sceneid.GetPointer());
93
94                                 PREPARE_LOCAL_BUF();
95                                 PACK_COMMON_BEGIN(MSG_PROBE_SCENE,
96                                                   API_ID_void_SceneManagerEventListener__OnSceneTransitionCompleted_const_SceneId__previousSceneId__const_SceneId__currentSceneId_,
97                                                   "pp",
98                                                   voidp_to_uint64(&previousSceneId),
99                                                   voidp_to_uint64(&currentSceneId));
100                                 PACK_COMMON_END(0, 0, 0);
101                                 PACK_SCENE(scene_name, formid, pform, panelid, ppanel, transition, user);
102                                 FLUSH_LOCAL_BUF();
103                         }
104                 }
105                 else
106                 {
107                         // never happened
108                         assert(false);
109                 }
110
111                 SCREENSHOT_SET();
112 //              SCREENSHOT_DONE();
113         }
114
115         SceneManagerUsed = 0;
116         probeBlockEnd();
117 }
118
119 void SceneManagerEventListener::OnSceneTransitionStarted(const SceneId&,
120                                                          const SceneId&)
121 {
122         probeBlockStart();
123         SceneManagerUsed = 1;
124         startTime = getCurrentTime();
125         probeBlockEnd();
126 }
127
128 SceneManagerEventListener& SceneManagerEventListener::GetInstance()
129 {
130         return rInstance;
131 }
132
133
134 namespace Tizen { namespace Ui { namespace Scenes {
135
136 SceneManager* SceneManager::GetInstance(void)
137 {
138         typedef SceneManager* (*methodType)(void);
139         static methodType scenemanager_getinstancep;
140         static int initialized = 0;
141         SceneManager* ret;
142
143         GET_REAL_FUNC_TIZEN(_ZN5Tizen2Ui6Scenes12SceneManager11GetInstanceEv, LIBOSP_UIFW, scenemanager_getinstancep);
144
145         ret = scenemanager_getinstancep();
146
147         probeBlockStart();
148         if(unlikely(initialized == 0))
149         {
150                 if(likely(ret != NULL))
151                 {
152                         ret->AddSceneManagerEventListener(SceneManagerEventListener::GetInstance());
153                         initialized = 1;
154                 }
155         }
156         probeBlockEnd();
157
158         return ret;
159 }
160
161
162 } } }   // end of namespace