add patch
[framework/osp/web.git] / src / controls / FWebCtrl_WebPresenter.cpp
1 //
2 // Open Service Platform
3 // Copyright (c) 2012 Samsung Electronics Co., Ltd.
4 //
5 // Licensed under the Apache License, Version 2.0 (the License);
6 // you may not use this file except in compliance with the License.
7 // You may obtain a copy of the License at
8 //
9 //     http://www.apache.org/licenses/LICENSE-2.0
10 //
11 // Unless required by applicable law or agreed to in writing, software
12 // distributed under the License is distributed on an "AS IS" BASIS,
13 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 // See the License for the specific language governing permissions and
15 // limitations under the License.
16 //
17
18 /**
19  * @file                FWebCtrl_WebImpl.cpp
20  * @brief               The file contains the definition of _WebImpl class.
21  *
22  * The file contains the definition of _WebImpl class.
23  */
24 #include <FBaseSysLog.h>
25 #include <FApp_AppImpl.h>
26 #include "FWebCtrl_WebManager.h"
27 #include "FWebCtrl_WebPresenter.h"
28
29
30 namespace Tizen { namespace Web { namespace Controls
31 {
32
33
34 _WebPresenter::_WebPresenter(const Object* callerAddress)
35         : __stopState(false)
36         , __boolean(false)
37         , __string(L"")
38         , __integer(0)
39         , __pIList(null)
40         , __longInteger(0)
41         , __callerAddress(reinterpret_cast< int >(callerAddress))
42 {
43         _WebManager* pWebManager = _WebManager::GetInstance();
44         pWebManager->AddCallback(__callerAddress, reinterpret_cast< int >(this));
45 }
46
47
48 _WebPresenter::~_WebPresenter(void)
49 {
50         __stopState = false;
51
52         _WebManager* pWebManager = _WebManager::GetInstance();
53         pWebManager->RemoveCallback(__callerAddress, reinterpret_cast< int >(this));
54 }
55
56
57 void
58 _WebPresenter::WaitAsyncProcess(bool& result)
59 {
60         ProcessEvent();
61
62         result = __boolean;
63 }
64
65
66 void
67 _WebPresenter::WaitAsyncProcess(Tizen::Base::String& result)
68 {
69         ProcessEvent();
70
71         result = __string;
72 }
73
74
75 void
76 _WebPresenter::WaitAsyncProcess(int& result)
77 {
78         ProcessEvent();
79
80         result = __integer;
81 }
82
83
84 Eina_List*
85 _WebPresenter::WaitAsyncProcess()
86 {
87         ProcessEvent();
88
89         return __pIList;
90 }
91
92
93 void
94 _WebPresenter::WaitAsyncProcess(long& result)
95 {
96         ProcessEvent();
97
98         result = __longInteger;
99 }
100
101
102 void
103 _WebPresenter::ProcessEvent(void)
104 {
105         while (true)
106         {
107                 if (__stopState)
108                 {
109                         break;
110                 }
111
112                 if (Tizen::App::_AppImpl::IsTerminationRequested())
113                 {
114                         break;
115                 }
116
117                 ecore_main_loop_iterate();
118         }
119 }
120
121
122 void
123 _WebPresenter::EndAsyncProcess(const Tizen::Base::String& result)
124 {
125         __string = const_cast< Tizen::Base::String& >(result);
126         __stopState = true;
127 }
128
129
130 void
131 _WebPresenter::EndAsyncProcess(bool result)
132 {
133         __boolean = result;
134         __stopState = true;
135 }
136
137
138 void
139 _WebPresenter::EndAsyncProcess(int result)
140 {
141         __integer = result;
142         __stopState = true;
143 }
144
145
146 void
147 _WebPresenter::EndAsyncProcess(const Eina_List* result)
148 {
149         __pIList = const_cast<Eina_List*>(result);
150         __stopState = true;
151 }
152
153
154 void
155 _WebPresenter::EndAsyncProcess(long result)
156 {
157         __longInteger = result;
158         __stopState = true;
159 }
160
161
162 }}} // Tizen::Web::Controls