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.
24 #include <FAppAppControl.h>
25 #include <FBaseSysLog.h>
26 #include <FBaseUtilStringUtil.h>
27 #include "FWebCtrl_AppControlListener.h"
30 using namespace Tizen::App;
31 using namespace Tizen::Base;
32 using namespace Tizen::Base::Collection;
33 using namespace Tizen::Base::Utility;
35 namespace Tizen { namespace Web { namespace Controls
39 _CertificateListener::_CertificateListener(void)
44 _CertificateListener::~_CertificateListener(void)
50 _CertificateListener::OnAppControlCompleteResponseReceived(const Tizen::App::AppId& providerId, const Tizen::Base::String& operationId, Tizen::App::AppCtrlResult appControlResult, const Tizen::Base::Collection::IMap* pAppData)
52 if (providerId == L"tizen.certificatemanager" && operationId == L"http://tizen.org/appcontrol/operation/pick")
54 SysTryReturnVoidResult(NID_WEB_CTRL, pAppData, E_SYSTEM, "[E_SYSTEM] Certificate Manager AppControl failed");
56 //String* pCertID = static_cast< String* >(const_cast< Object* >(pAppData->GetValue(String(L"Id"))));
57 // TODO : test if the result of Certificate AppControl complies with the following
58 // const char* pCertificateFile;
59 // ewk_set_certificate_file(pCertificateFile);
66 _LocationSettingListener::_LocationSettingListener(Ewk_Geolocation_Permission_Request* pGeoLocationObject)
67 : __pGeoLocationObject(pGeoLocationObject)
72 _LocationSettingListener::~_LocationSettingListener(void)
78 _LocationSettingListener::OnAppControlCompleteResponseReceived(const Tizen::App::AppId& providerId, const Tizen::Base::String& operationId, Tizen::App::AppCtrlResult appControlResult, const Tizen::Base::Collection::IMap* pAppData)
80 if (providerId == L"tizen.settings")
82 SysTryReturnVoidResult(NID_WEB_CTRL, pAppData, E_SYSTEM, "[E_SYSTEM] Settings AppControl failed");
84 String* pCategoryStr = static_cast< String* >(const_cast< Object* >(pAppData->GetValue(String("category"))));
85 String* pGPSStr = static_cast< String* >(const_cast< Object* >(pAppData->GetValue(String("GPS"))));
87 if (pCategoryStr && pCategoryStr->Equals(String(L"Location")) && pGPSStr && pGPSStr->Equals(String(L"GPSEnabled")))
89 ewk_geolocation_permission_request_set(__pGeoLocationObject, true);
93 ewk_geolocation_permission_request_set(__pGeoLocationObject, false);
100 _MediaSelectionListener::_MediaSelectionListener(void)
102 , __pMediaAppControl(null)
108 _MediaSelectionListener::Construct(Evas_Object* pWebFrame, Tizen::App::AppControl* pMediaAppControl)
110 __pWebFrame = pWebFrame;
111 std::unique_ptr<AppControl> pAppControl(pMediaAppControl);
112 __pMediaAppControl = std::move(pAppControl);
116 _MediaSelectionListener::~_MediaSelectionListener(void)
123 _MediaSelectionListener::OnAppControlCompleteResponseReceived(const Tizen::App::AppId& providerId, const Tizen::Base::String& operationId, Tizen::App::AppCtrlResult appControlResult, const Tizen::Base::Collection::IMap* pAppData)
125 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");
127 Eina_List* pSelectedFileNames = null;
130 ArrayList *pSelectedFiles = dynamic_cast< ArrayList* >(const_cast< Object* >(pAppData->GetValue(String("http://tizen.org/appcontrol/data/selected"))));
131 SysTryCatch(NID_WEB_CTRL, pSelectedFiles, , E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
133 fileCount = pSelectedFiles->GetCount();
135 for (int i = 0; i < fileCount; i++)
137 std::unique_ptr<String> pFile((String*)pSelectedFiles->GetAt(i));
138 SysTryCatch(NID_WEB_CTRL, pFile, , GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
140 std::unique_ptr<ByteBuffer> pByteBuf(StringUtil::StringToUtf8N(*pFile));
141 SysTryCatch(NID_WEB_CTRL, pByteBuf.get(), , GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
143 pSelectedFileNames = eina_list_append(pSelectedFileNames, strdup((const char*)pByteBuf->GetPointer()));
144 SysTryCatch(NID_WEB_CTRL, pSelectedFileNames, , E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
147 ewk_view_open_panel_reply(__pWebFrame, pSelectedFileNames, EINA_TRUE);
148 eina_list_free(pSelectedFileNames);
154 ewk_view_open_panel_reply(__pWebFrame, null, EINA_TRUE);
155 eina_list_free(pSelectedFileNames);
160 }}} // Tizen::Web::Controls