Remove warning message and Update doxygen
[framework/osp/web.git] / src / controls / FWebCtrl_AppControlListener.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_AppControlListener.cpp
20  * @brief               The file contains the definition of _AppControlListener classes.
21  *
22  * The file contains the definition of _AppControlListener classes.
23  */
24 #include <EWebKit2.h>
25 #include <FAppAppControl.h>
26 #include <FBaseSysLog.h>
27 #include <FBaseUtilStringTokenizer.h>
28 #include "FWebCtrl_AppControlListener.h"
29
30
31 using namespace Tizen::App;
32 using namespace Tizen::Base;
33 using namespace Tizen::Base::Collection;
34 using namespace Tizen::Base::Utility;
35
36 namespace Tizen { namespace Web { namespace Controls
37 {
38
39
40 _CertificateListener::_CertificateListener(void)
41 {
42 }
43
44
45 _CertificateListener::~_CertificateListener(void)
46 {
47 }
48
49
50 void
51 _CertificateListener::OnAppControlCompleteResponseReceived(const Tizen::App::AppId& providerId, const Tizen::Base::String& operationId, Tizen::App::AppCtrlResult appControlResult, const Tizen::Base::Collection::IMap* pAppData)
52 {
53         if (providerId == L"tizen.certificatemanager" && operationId == L"http://tizen.org/appcontrol/operation/pick")
54         {
55                 SysTryReturnVoidResult(NID_WEB_CTRL, pAppData, E_SYSTEM, "[E_SYSTEM] Certificate Manager AppControl failed");
56
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);
61         }
62
63         delete this;
64 }
65
66
67 _LocationSettingListener::_LocationSettingListener(Ewk_Geolocation_Permission_Request* pGeoLocationObject)
68         : __pGeoLocationObject(pGeoLocationObject)
69 {
70 }
71
72
73 _LocationSettingListener::~_LocationSettingListener(void)
74 {
75 }
76
77
78 void
79 _LocationSettingListener::OnAppControlCompleteResponseReceived(const Tizen::App::AppId& providerId, const Tizen::Base::String& operationId, Tizen::App::AppCtrlResult appControlResult, const Tizen::Base::Collection::IMap* pAppData)
80 {
81         if (providerId == L"tizen.settings")
82         {
83                 SysTryReturnVoidResult(NID_WEB_CTRL, pAppData, E_SYSTEM, "[E_SYSTEM] Settings AppControl failed");
84
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"))));
87
88                 if (pCategoryStr && pCategoryStr->Equals(String(L"Location")) && pGPSStr && pGPSStr->Equals(String(L"GPSEnabled")))
89                 {
90                         ewk_geolocation_permission_request_set(__pGeoLocationObject, true);
91                 }
92                 else
93                 {
94                         ewk_geolocation_permission_request_set(__pGeoLocationObject, false);
95                 }
96         }
97         delete this;
98 }
99
100
101 _MediaSelectionListener::_MediaSelectionListener(void)
102         : __isSelectionCompleted(false)
103         , __pSelectedFiles(null)
104 {
105
106 }
107
108
109 _MediaSelectionListener::~_MediaSelectionListener(void)
110 {
111
112 }
113
114
115 const ArrayList*
116 _MediaSelectionListener::GetSelectedFiles(void) const
117 {
118         return __pSelectedFiles.get();
119 }
120
121
122 bool
123 _MediaSelectionListener::IsSelectionCompleted(void) const
124 {
125         return __isSelectionCompleted;
126 }
127
128
129 void
130 _MediaSelectionListener::OnAppControlCompleteResponseReceived(const Tizen::App::AppId& providerId, const Tizen::Base::String& operationId, Tizen::App::AppCtrlResult appControlResult, const Tizen::Base::Collection::IMap* pAppData)
131 {
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");
134
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));
137
138         result r = pSelectedFiles->Construct();
139         SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
140
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));
143
144         StringTokenizer strTok(*pFiles, L";");
145         String token;
146
147         while (strTok.HasMoreTokens())
148         {
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));
152
153                 r = pSelectedFiles->Add(*pFile);
154                 SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
155                 pFile.release();
156         }
157
158         __pSelectedFiles = std::move(pSelectedFiles);
159 }
160
161
162 }}} // Tizen::Web::Controls