summaryrefslogtreecommitdiff
path: root/src/controls/FWebCtrl_AppControlListener.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/controls/FWebCtrl_AppControlListener.cpp')
-rwxr-xr-xsrc/controls/FWebCtrl_AppControlListener.cpp163
1 files changed, 163 insertions, 0 deletions
diff --git a/src/controls/FWebCtrl_AppControlListener.cpp b/src/controls/FWebCtrl_AppControlListener.cpp
new file mode 100755
index 0000000..e533eab
--- /dev/null
+++ b/src/controls/FWebCtrl_AppControlListener.cpp
@@ -0,0 +1,163 @@
+//
+// Open Service Platform
+// Copyright (c) 2012 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Apache License, Version 2.0 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
+/**
+ * @file FWebCtrl_AppControlListener.cpp
+ * @brief The file contains the definition of _AppControlListener classes.
+ *
+ * The file contains the definition of _AppControlListener classes.
+ */
+#include <EWebKit2.h>
+#include <FAppAppControl.h>
+#include <FBaseSysLog.h>
+#include <FBaseUtilStringTokenizer.h>
+#include "FWebCtrl_AppControlListener.h"
+
+
+using namespace Tizen::App;
+using namespace Tizen::Base;
+using namespace Tizen::Base::Collection;
+using namespace Tizen::Base::Utility;
+
+namespace Tizen { namespace Web { namespace Controls
+{
+
+
+_CertificateListener::_CertificateListener(void)
+{
+}
+
+
+_CertificateListener::~_CertificateListener(void)
+{
+}
+
+
+void
+_CertificateListener::OnAppControlCompleteResponseReceived(const Tizen::App::AppId& providerId, const Tizen::Base::String& operationId, Tizen::App::AppCtrlResult appControlResult, const Tizen::Base::Collection::IMap* pAppData)
+{
+ if (providerId == L"tizen.certificatemanager" && operationId == L"http://tizen.org/appcontrol/operation/pick")
+ {
+ SysTryReturnVoidResult(NID_WEB_CTRL, pAppData, E_SYSTEM, "[E_SYSTEM] Certificate Manager AppControl failed");
+
+ String* pCertID = static_cast< String* >(const_cast< Object* >(pAppData->GetValue(String(L"Id"))));
+ // TODO : test if the result of Certificate AppControl complies with the following
+ // const char* pCertificateFile;
+ // ewk_set_certificate_file(pCertificateFile);
+ }
+
+ delete this;
+}
+
+
+_LocationSettingListener::_LocationSettingListener(Ewk_Geolocation_Permission_Data* pGeoLocationObject)
+ : __pGeoLocationObject(pGeoLocationObject)
+{
+}
+
+
+_LocationSettingListener::~_LocationSettingListener(void)
+{
+}
+
+
+void
+_LocationSettingListener::OnAppControlCompleteResponseReceived(const Tizen::App::AppId& providerId, const Tizen::Base::String& operationId, Tizen::App::AppCtrlResult appControlResult, const Tizen::Base::Collection::IMap* pAppData)
+{
+ if (providerId == L"tizen.settings")
+ {
+ SysTryReturnVoidResult(NID_WEB_CTRL, pAppData, E_SYSTEM, "[E_SYSTEM] Settings AppControl failed");
+
+ String* pCategoryStr = static_cast< String* >(const_cast< Object* >(pAppData->GetValue(String("category"))));
+ String* pGPSStr = static_cast< String* >(const_cast< Object* >(pAppData->GetValue(String("GPS"))));
+
+ Ewk_Geolocation_Permission_Request permistionRequest = ewk_geolocation_permission_request_get(__pGeoLocationObject);
+ if (pCategoryStr && pCategoryStr->Equals(String(L"Location")) && pGPSStr && pGPSStr->Equals(String(L"GPSEnabled")))
+ {
+ ewk_geolocation_permission_request_allow_set(permistionRequest, true);
+ }
+ else
+ {
+ ewk_geolocation_permission_request_allow_set(permistionRequest, false);
+ }
+ }
+ delete this;
+}
+
+
+_MediaSelectionListener::_MediaSelectionListener(void)
+ : __isSelectionCompleted(false)
+ , __pSelectedFiles(null)
+{
+
+}
+
+
+_MediaSelectionListener::~_MediaSelectionListener(void)
+{
+
+}
+
+
+const ArrayList*
+_MediaSelectionListener::GetSelectedFiles(void) const
+{
+ return __pSelectedFiles.get();
+}
+
+
+bool
+_MediaSelectionListener::IsSelectionCompleted(void) const
+{
+ return __isSelectionCompleted;
+}
+
+
+void
+_MediaSelectionListener::OnAppControlCompleteResponseReceived(const Tizen::App::AppId& providerId, const Tizen::Base::String& operationId, Tizen::App::AppCtrlResult appControlResult, const Tizen::Base::Collection::IMap* pAppData)
+{
+ __isSelectionCompleted = true;
+ 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");
+
+ std::unique_ptr<ArrayList, AllElementsDeleter> pSelectedFiles(new (std::nothrow) ArrayList());
+ SysTryReturnVoidResult(NID_WEB_CTRL, pSelectedFiles.get(), E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+
+ result r = pSelectedFiles->Construct();
+ SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
+
+ String *pFiles = static_cast< String* >(const_cast< Object* >(pAppData->GetValue(String("path"))));
+ SysTryReturnVoidResult(NID_WEB_CTRL, pFiles, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+
+ StringTokenizer strTok(*pFiles, L";");
+ String token;
+
+ while (strTok.HasMoreTokens())
+ {
+ strTok.GetNextToken(token);
+ std::unique_ptr<String> pFile(new (std::nothrow) String(token));
+ SysTryReturnVoidResult(NID_WEB_CTRL, pFile, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+
+ r = pSelectedFiles->Add(*pFile);
+ SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
+ pFile.release();
+ }
+
+ __pSelectedFiles = std::move(pSelectedFiles);
+}
+
+
+}}} // Tizen::Web::Controls