Update change log and spec for wrt-plugins-tizen_0.4.9
[platform/framework/web/wrt-plugins-tizen.git] / src / Application / ApplicationControl.cpp
1 //
2 // Tizen Web Device API
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 /**
20  * @file        ApplicationControl.cpp
21  * @author      Youngkyeong Yun (yk.yun@samsung.com)
22  * @version     0.1
23  */
24
25
26 #include "ApplicationControl.h"
27
28 namespace DeviceAPI {
29 namespace Application {
30
31 ApplicationControl::ApplicationControl() :
32         m_appControl(NULL)
33 {
34     LogDebug("entered");
35 }
36
37 ApplicationControl::ApplicationControl(const std::string &op, const std::string &uri,
38                 const std::string &mime, const std::string &category,
39                 std::vector<ApplicationControlDataPtr> &dataArray) :
40         m_appControl(NULL)
41 {
42     LogDebug("entered");
43         m_operation = op;
44         m_uri = uri;
45         m_mime = mime;
46         m_category = category;  
47         m_appControlDataArray = dataArray;
48 }
49
50 ApplicationControl::~ApplicationControl()
51 {
52     LogDebug("entered");
53 }
54
55 std::string ApplicationControl::getOperation() const
56 {
57         return m_operation;
58 }
59
60 void ApplicationControl::setOperation(const std::string &operation)
61 {
62         m_operation = operation;
63 }
64
65 std::string ApplicationControl::getUri() const
66 {
67         return m_uri;
68 }
69
70 void ApplicationControl::setUri(const std::string &uri)
71 {
72         m_uri = uri;
73 }
74
75 std::string ApplicationControl::getMime() const
76 {
77         return m_mime;
78 }
79
80 void ApplicationControl::setMime(const std::string &mime)
81 {
82         m_mime = mime;
83 }
84
85 std::string ApplicationControl::getCategory() const
86 {
87         return m_category;
88 }
89
90 void ApplicationControl::setCategory(const std::string &category)
91 {
92         m_category = category;
93 }
94
95 std::vector<ApplicationControlDataPtr> ApplicationControl::getAppControlDataArray() const
96 {
97         return m_appControlDataArray;
98 }
99
100 void ApplicationControl::setAppControlDataArray(const std::vector<ApplicationControlDataPtr> &dataArray)
101 {
102         m_appControlDataArray = dataArray;
103 }
104
105 void ApplicationControl::addAppControlData(const ApplicationControlDataPtr &data)
106 {
107         m_appControlDataArray.push_back(data);
108         
109 }
110
111 service_h ApplicationControl::getService_h() const
112 {
113         return m_appControl;
114 }
115
116 void ApplicationControl::setService_h(const service_h service)
117 {
118         m_appControl = service;
119 }
120
121
122 #if 0
123 void ApplicationControl::replyResult(std::vector<ApplicationControlDataPtr> &appControlDataArray)
124 {
125         service_h reply;
126         service_create(&reply);
127
128         const char* key = NULL;
129         const char** arr = NULL;
130
131         if (!appControlDataArray.empty())
132         {
133                 LogDebug("appControlDataArray.size() : "<<appControlDataArray.size());
134                 for (size_t i = 0; i < appControlDataArray.size(); ++i) {
135                         key = appControlDataArray.at(i)->getKey().c_str();
136                         std::vector<std::string> valueArray = appControlDataArray.at(i)->getValue();
137                         
138                         arr = (const char**) calloc (sizeof(char*), valueArray.size());
139         
140                         for (size_t j = 0; j < valueArray.size(); j++) {
141                                 arr[j] = valueArray.at(j).c_str();
142                         }
143                         service_add_extra_data_array(reply, key, arr, valueArray.size());
144                 }
145         } else {
146                 LogError("==[replyResult] appControlDataArray is empty");
147         }
148
149         service_reply_to_launch_request(reply, m_appControl, SERVICE_RESULT_SUCCEEDED);
150
151         service_destroy(reply);
152
153         if (arr) {
154                 free (arr);
155         }
156         
157 }
158
159 void ApplicationControl::replyFailure()
160 {
161         service_h reply;
162         service_create(&reply);
163
164         LogError("==[replyFailure] enter ApplicationControl::replyFailure");
165         service_reply_to_launch_request(reply, m_appControl, SERVICE_RESULT_FAILED);
166
167         service_destroy(reply);
168 }
169 #endif
170
171 }
172 }