change Copyright headers, change line endings to Unix format
[platform/core/system/swap-probe.git] / probe_ui / osp_scenemanager.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  * 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 "osp_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, LC_SCENE, "pp", &previousSceneId, &currentSceneId);
96                                 PACK_COMMON_END(0, 0, 0);
97                                 PACK_SCENE(scene_name, formid, pform, panelid, ppanel, transition, user);
98                                 FLUSH_LOCAL_BUF();
99                         }
100                 }
101                 else
102                 {
103                         // never happened
104                         assert(false);
105                 }
106
107                 SCREENSHOT_SET();
108 //              SCREENSHOT_DONE();
109         }
110
111         SceneManagerUsed = 0;
112         probeBlockEnd();
113 }
114
115 void SceneManagerEventListener::OnSceneTransitionStarted(const SceneId &currentSceneId, const SceneId &nextSceneId)
116 {
117         probeBlockStart();
118         SceneManagerUsed = 1;
119         startTime = getCurrentTime();
120         probeBlockEnd();
121 }
122
123 SceneManagerEventListener& SceneManagerEventListener::GetInstance()
124 {
125         return rInstance;
126 }
127
128
129 namespace Tizen { namespace Ui { namespace Scenes {
130
131 SceneManager* SceneManager::GetInstance(void)
132 {
133         typedef SceneManager* (*methodType)(void);
134         static methodType scenemanager_getinstancep;
135         static int initialized = 0;
136         SceneManager* ret;
137
138         GET_REAL_FUNC_OSP(_ZN5Tizen2Ui6Scenes12SceneManager11GetInstanceEv, LIBOSP_UIFW, scenemanager_getinstancep);
139
140         ret = scenemanager_getinstancep();
141
142         probeBlockStart();
143         if(unlikely(initialized == 0))
144         {
145                 if(likely(ret != NULL))
146                 {
147                         ret->AddSceneManagerEventListener(SceneManagerEventListener::GetInstance());
148                         initialized = 1;
149                 }
150         }
151         probeBlockEnd();
152
153         return ret;
154 }
155
156
157 } } }   // end of namespace