Fix i586 build error
[platform/core/uifw/dali-adaptor.git] / adaptors / libuv / framework-libuv.cpp
1 /*
2  * Copyright (c) 2015 Samsung Electronics Co., Ltd.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  *
16  */
17
18 // CLASS HEADER
19 #include "framework.h"
20
21 // EXTERNAL INCLUDES
22 #include <uv.h>
23
24
25 #include <dali/integration-api/debug.h>
26
27 // INTERNAL INCLUDES
28 #include <callback-manager.h>
29
30 namespace Dali
31 {
32
33 namespace Internal
34 {
35
36 namespace Adaptor
37 {
38
39
40 /**
41  * Impl to hide LibUV data members
42  */
43 struct Framework::Impl
44 {
45   // Constructor
46
47   Impl(void* data)
48   : mAbortCallBack( NULL ),
49     mCallbackManager( NULL )
50   {
51      mCallbackManager = CallbackManager::New();
52      mMainLoop = new uv_loop_t;
53      uv_loop_init( mMainLoop );
54
55   }
56
57   ~Impl()
58   {
59     delete mAbortCallBack;
60
61     // we're quiting the main loop so
62     // mCallbackManager->RemoveAllCallBacks() does not need to be called
63     // to delete our abort handler
64     delete mCallbackManager;
65
66     delete mMainLoop;
67   }
68
69   void Run()
70   {
71     uv_run( mMainLoop , UV_RUN_DEFAULT);
72
73     uv_loop_close( mMainLoop );
74
75   }
76
77   void Quit()
78   {
79     uv_stop( mMainLoop );
80   }
81
82   // Data
83
84   CallbackBase* mAbortCallBack;
85   CallbackManager *mCallbackManager;
86   uv_loop_t* mMainLoop;
87
88
89 private:
90   // Undefined
91   Impl( const Impl& impl );
92
93   // Undefined
94   Impl& operator=( const Impl& impl );
95 };
96
97 Framework::Framework( Framework::Observer& observer, int *argc, char ***argv, Type type )
98 : mObserver(observer),
99   mInitialised(false),
100   mRunning(false),
101   mArgc(argc),
102   mArgv(argv),
103   mBundleName(""),
104   mBundleId(""),
105   mAbortHandler( MakeCallback( this, &Framework::AbortCallback ) ),
106   mImpl(NULL)
107 {
108
109   mImpl = new Impl(this);
110 }
111
112 Framework::~Framework()
113 {
114   if (mRunning)
115   {
116     Quit();
117   }
118
119   delete mImpl;
120 }
121
122 void Framework::Run()
123 {
124   mRunning = true;
125
126   mImpl->Run();
127
128
129   mRunning = false;
130 }
131
132 void Framework::Quit()
133 {
134   mImpl->Quit();
135 }
136
137 bool Framework::IsMainLoopRunning()
138 {
139   return mRunning;
140 }
141
142 void Framework::AddAbortCallback( CallbackBase* callback )
143 {
144   mImpl->mAbortCallBack = callback;
145 }
146
147 std::string Framework::GetBundleName() const
148 {
149   return mBundleName;
150 }
151
152 void Framework::SetBundleName(const std::string& name)
153 {
154 }
155
156 std::string Framework::GetBundleId() const
157 {
158   return "";
159 }
160
161 std::string Framework::GetResourcePath()
162 {
163   // TIZEN_PLATFORM_CONFIG_SUPPORTED not defined for libuv so path not available.
164   return "";
165 }
166
167 void Framework::SetBundleId(const std::string& id)
168 {
169 }
170
171 void Framework::AbortCallback( )
172 {
173   // if an abort call back has been installed run it.
174   if (mImpl->mAbortCallBack)
175   {
176     CallbackBase::Execute( *mImpl->mAbortCallBack );
177   }
178   else
179   {
180     Quit();
181   }
182 }
183
184 bool Framework::AppStatusHandler(int type, void *bundleData)
185 {
186   return true;
187 }
188
189 } // namespace Adaptor
190
191 } // namespace Internal
192
193 } // namespace Dali