2 // Open Service Platform
3 // Copyright (c) 2012 Samsung Electronics Co., Ltd.
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
9 // http://www.apache.org/licenses/LICENSE-2.0
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.
19 * @file FWebCtrl_WebEventArg.cpp
20 * @brief The file contains the definition of _WebEventArg class.
22 * The file contains the definition of _WebEventArg class.
25 #include <FBaseInteger.h>
26 #include <FBaseSysLog.h>
27 #include "FWebCtrl_WebEventArg.h"
30 using namespace Tizen::Base;
31 using namespace Tizen::Base::Collection;
34 namespace Tizen { namespace Web { namespace Controls
38 //// _WebEventArg /////////////
39 _WebEventArg::_WebEventArg(int eventType, const Tizen::Base::String& message)
40 : __eventType(eventType)
46 _WebEventArg::~_WebEventArg(void)
52 _WebEventArg::GetEventType(void) const
59 _WebEventArg::GetEventGroup(void) const
61 return (0xf00 & __eventType);
66 _WebEventArg::GetEventMessage(void) const
72 //// _JsBridgeArg/////////////
73 _JsBridgeArg::_JsBridgeArg(void)
74 : _WebEventArg(WEB_EVENT_DELIVER_JSBRIDGE_REQUEST, L"")
80 _JsBridgeArg::~_JsBridgeArg(void)
86 _JsBridgeArg::Construct(const char* pJsonText)
88 SysTryReturnResult(NID_WEB_CTRL, pJsonText, E_INVALID_ARG, "[%s] Invalid argument(s) is used. json text is null." , GetErrorMessage(E_INVALID_ARG));
93 std::unique_ptr<Tizen::Base::ByteBuffer> pNewJsonText(new (std::nothrow) ByteBuffer());
94 SysTryReturn(NID_WEB_CTRL, pNewJsonText.get(), E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed", GetErrorMessage(E_OUT_OF_MEMORY));
96 length = strlen(pJsonText);
97 r = pNewJsonText->Construct(length);
98 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Failed to construct bytebuffer for jsonText.", GetErrorMessage(r));
100 r = pNewJsonText->SetArray(reinterpret_cast< const byte* >(pJsonText), 0, length);
101 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Failed to set json text to ByteBuffer. ", GetErrorMessage(r));
103 __pJsonText = std::move(pNewJsonText);
109 const Tizen::Base::ByteBuffer*
110 _JsBridgeArg::GetJsonData(void) const
112 return __pJsonText.get();
116 _LoadingEventArg::_LoadingEventArg(int loadingEvent)
117 : _WebEventArg(loadingEvent, L"")
123 _LoadingEventArg::~_LoadingEventArg(void)
129 _LoadingEventArg::SetEventInfo(EventInfoKey key, const Tizen::Base::Object& value)
131 result r = E_SUCCESS;
133 std::unique_ptr<Integer> pKey(new (std::nothrow) Integer(key));
134 SysTryReturn(NID_WEB_CTRL, pKey.get(), E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed", GetErrorMessage(E_OUT_OF_MEMORY));
136 if (__pEventInfo.get() == null)
138 std::unique_ptr<HashMap, AllElementsDeleter> pEventInfo(new (std::nothrow) HashMap());
139 SysTryReturn(NID_WEB_CTRL, pEventInfo.get(), E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed", GetErrorMessage(E_OUT_OF_MEMORY));
141 r = pEventInfo->Construct();
142 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
144 __pEventInfo = std::move(pEventInfo);
147 r = __pEventInfo->Add(*pKey.get(), value);
148 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
157 const Tizen::Base::Object*
158 _LoadingEventArg::GetEventInfo(EventInfoKey key) const
160 SysTryReturn(NID_WEB_CTRL, __pEventInfo.get(), null, E_OBJ_NOT_FOUND, "[%s] The required instance is not available.", GetErrorMessage(E_OBJ_NOT_FOUND));
161 Integer int_key(key);
163 return __pEventInfo->GetValue(int_key);
167 _WebDownloadEventArg::_WebDownloadEventArg(int webDonwloadEvent)
168 : _WebEventArg(webDonwloadEvent, L"")
174 _WebDownloadEventArg::~_WebDownloadEventArg(void)
180 _WebDownloadEventArg::SetEventInfo(EventInfoKey key, const Tizen::Base::Object& value)
182 result r = E_SUCCESS;
184 std::unique_ptr<Integer> pKey(new (std::nothrow) Integer(key));
185 SysTryReturn(NID_WEB_CTRL, pKey.get(), E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed", GetErrorMessage(E_OUT_OF_MEMORY));
187 if (__pEventInfo.get() == null)
189 std::unique_ptr<HashMap, AllElementsDeleter> pEventInfo(new (std::nothrow) HashMap());
190 SysTryReturn(NID_WEB_CTRL, pEventInfo.get(), E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed", GetErrorMessage(E_OUT_OF_MEMORY));
192 r = pEventInfo->Construct();
193 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
195 __pEventInfo = std::move(pEventInfo);
198 r = __pEventInfo->Add(*pKey.get(), value);
199 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
207 const Tizen::Base::Object*
208 _WebDownloadEventArg::GetEventInfo(EventInfoKey key) const
210 SysTryReturn(NID_WEB_CTRL, __pEventInfo.get(), null, E_OBJ_NOT_FOUND, "[%s] The required instance is not available.", GetErrorMessage(E_OBJ_NOT_FOUND));
211 Integer int_key(key);
213 return __pEventInfo->GetValue(int_key);
217 _WebUiEventArg::_WebUiEventArg(int webUiEvent)
218 : _WebEventArg(webUiEvent, L"")
224 _WebUiEventArg::~_WebUiEventArg(void)
230 _WebUiEventArg::SetEventInfo(EventInfoKey key, const Tizen::Base::Object& value)
232 result r = E_SUCCESS;
234 std::unique_ptr<Integer> pKey(new (std::nothrow) Integer(key));
235 SysTryReturn(NID_WEB_CTRL, pKey.get(), E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed", GetErrorMessage(E_OUT_OF_MEMORY));
237 if (__pEventInfo.get() == null)
239 std::unique_ptr<HashMap, AllElementsDeleter> pEventInfo(new (std::nothrow) HashMap());
240 SysTryReturn(NID_WEB_CTRL, pEventInfo.get(), E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed", GetErrorMessage(E_OUT_OF_MEMORY));
242 r = pEventInfo->Construct();
243 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
245 __pEventInfo = std::move(pEventInfo);
248 r = __pEventInfo->Add(*pKey.get(), value);
249 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
257 const Tizen::Base::Object*
258 _WebUiEventArg::GetEventInfo(EventInfoKey key) const
260 SysTryReturn(NID_WEB_CTRL, __pEventInfo.get(), null, E_OBJ_NOT_FOUND, "[%s] The required instance is not available.", GetErrorMessage(E_OBJ_NOT_FOUND));
261 Integer int_key(key);
263 return __pEventInfo->GetValue(int_key);
267 _TextSearchEventArg::_TextSearchEventArg(int textSearchEvent)
268 : _WebEventArg(textSearchEvent, L"")
274 _TextSearchEventArg::~_TextSearchEventArg(void)
280 _TextSearchEventArg::SetEventInfo(EventInfoKey key, const Tizen::Base::Object& value)
282 result r = E_SUCCESS;
284 std::unique_ptr<Integer> pKey(new (std::nothrow) Integer(key));
285 SysTryReturn(NID_WEB_CTRL, pKey.get(), E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed", GetErrorMessage(E_OUT_OF_MEMORY));
287 if (__pEventInfo.get() == null)
289 std::unique_ptr<HashMap, AllElementsDeleter> pEventInfo(new (std::nothrow) HashMap());
290 SysTryReturn(NID_WEB_CTRL, pEventInfo.get(), E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed", GetErrorMessage(E_OUT_OF_MEMORY));
292 r = pEventInfo->Construct();
293 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
295 __pEventInfo = std::move(pEventInfo);
298 r = __pEventInfo->Add(*pKey.get(), value);
299 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
307 const Tizen::Base::Object*
308 _TextSearchEventArg::GetEventInfo(EventInfoKey key) const
310 SysTryReturn(NID_WEB_CTRL, __pEventInfo.get(), null, E_OBJ_NOT_FOUND, "[%s] The required instance is not available.", GetErrorMessage(E_OBJ_NOT_FOUND));
311 Integer int_key(key);
313 return __pEventInfo->GetValue(int_key);
317 }}} // Tizen::Web::Controls