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_AppControlListener.cpp
20 * @brief The file contains the definition of _AppControlListener classes.
22 * The file contains the definition of _AppControlListener classes.
25 #include <FAppAppControl.h>
26 #include <FBaseSysLog.h>
27 #include <FBaseUtilStringTokenizer.h>
28 #include "FWebCtrl_AppControlListener.h"
31 using namespace Tizen::App;
32 using namespace Tizen::Base;
33 using namespace Tizen::Base::Collection;
34 using namespace Tizen::Base::Utility;
36 namespace Tizen { namespace Web { namespace Controls
40 _CertificateListener::_CertificateListener(void)
45 _CertificateListener::~_CertificateListener(void)
51 _CertificateListener::OnAppControlCompleteResponseReceived(const Tizen::App::AppId& providerId, const Tizen::Base::String& operationId, Tizen::App::AppCtrlResult appControlResult, const Tizen::Base::Collection::IMap* pAppData)
53 if (providerId == L"tizen.certificatemanager" && operationId == L"http://tizen.org/appcontrol/operation/pick")
55 SysTryReturnVoidResult(NID_WEB_CTRL, pAppData, E_SYSTEM, "[E_SYSTEM] Certificate Manager AppControl failed");
57 String* pCertID = static_cast< String* >(const_cast< Object* >(pAppData->GetValue(String(L"Id"))));
58 // TODO : test if the result of Certificate AppControl complies with the following
59 // const char* pCertificateFile;
60 // ewk_set_certificate_file(pCertificateFile);
67 _LocationSettingListener::_LocationSettingListener(Ewk_Geolocation_Permission_Request* pGeoLocationObject)
68 : __pGeoLocationObject(pGeoLocationObject)
73 _LocationSettingListener::~_LocationSettingListener(void)
79 _LocationSettingListener::OnAppControlCompleteResponseReceived(const Tizen::App::AppId& providerId, const Tizen::Base::String& operationId, Tizen::App::AppCtrlResult appControlResult, const Tizen::Base::Collection::IMap* pAppData)
81 if (providerId == L"tizen.settings")
83 SysTryReturnVoidResult(NID_WEB_CTRL, pAppData, E_SYSTEM, "[E_SYSTEM] Settings AppControl failed");
85 String* pCategoryStr = static_cast< String* >(const_cast< Object* >(pAppData->GetValue(String("category"))));
86 String* pGPSStr = static_cast< String* >(const_cast< Object* >(pAppData->GetValue(String("GPS"))));
88 if (pCategoryStr && pCategoryStr->Equals(String(L"Location")) && pGPSStr && pGPSStr->Equals(String(L"GPSEnabled")))
90 ewk_geolocation_permission_request_set(__pGeoLocationObject, true);
94 ewk_geolocation_permission_request_set(__pGeoLocationObject, false);
101 _MediaSelectionListener::_MediaSelectionListener(void)
102 : __isSelectionCompleted(false)
103 , __pSelectedFiles(null)
109 _MediaSelectionListener::~_MediaSelectionListener(void)
116 _MediaSelectionListener::GetSelectedFiles(void) const
118 return __pSelectedFiles.get();
123 _MediaSelectionListener::IsSelectionCompleted(void) const
125 return __isSelectionCompleted;
130 _MediaSelectionListener::OnAppControlCompleteResponseReceived(const Tizen::App::AppId& providerId, const Tizen::Base::String& operationId, Tizen::App::AppCtrlResult appControlResult, const Tizen::Base::Collection::IMap* pAppData)
132 __isSelectionCompleted = true;
133 SysTryReturnVoidResult(NID_WEB_CTRL, pAppData && providerId == L"tizen.filemanager" && operationId == L"http://tizen.org/appcontrol/operation/pick", E_INVALID_ARG, "[E_INVALID_ARG] Invalid arguments to _MediaSelectionListener::OnAppControlCompleted");
135 std::unique_ptr<ArrayList, AllElementsDeleter> pSelectedFiles(new (std::nothrow) ArrayList());
136 SysTryReturnVoidResult(NID_WEB_CTRL, pSelectedFiles.get(), E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
138 result r = pSelectedFiles->Construct();
139 SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
141 String *pFiles = static_cast< String* >(const_cast< Object* >(pAppData->GetValue(String("path"))));
142 SysTryReturnVoidResult(NID_WEB_CTRL, pFiles, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
144 StringTokenizer strTok(*pFiles, L";");
147 while (strTok.HasMoreTokens())
149 strTok.GetNextToken(token);
150 std::unique_ptr<String> pFile(new (std::nothrow) String(token));
151 SysTryReturnVoidResult(NID_WEB_CTRL, pFile, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
153 r = pSelectedFiles->Add(*pFile);
154 SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
158 __pSelectedFiles = std::move(pSelectedFiles);
162 }}} // Tizen::Web::Controls