2 // Tizen Web Device API
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.
20 * @file ApplicationControl.cpp
21 * @author Youngkyeong Yun (yk.yun@samsung.com)
25 #include "ApplicationControl.h"
29 namespace Application {
31 ApplicationControl::ApplicationControl() :
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) :
46 m_category = category;
47 m_appControlDataArray = dataArray;
50 ApplicationControl::~ApplicationControl()
55 std::string ApplicationControl::getOperation() const
60 void ApplicationControl::setOperation(const std::string &operation)
62 m_operation = operation;
65 std::string ApplicationControl::getUri() const
70 void ApplicationControl::setUri(const std::string &uri)
75 std::string ApplicationControl::getMime() const
80 void ApplicationControl::setMime(const std::string &mime)
85 std::string ApplicationControl::getCategory() const
90 void ApplicationControl::setCategory(const std::string &category)
92 m_category = category;
95 std::vector<ApplicationControlDataPtr> ApplicationControl::getAppControlDataArray() const
97 return m_appControlDataArray;
100 void ApplicationControl::setAppControlDataArray(const std::vector<ApplicationControlDataPtr> &dataArray)
102 m_appControlDataArray = dataArray;
105 void ApplicationControl::addAppControlData(const ApplicationControlDataPtr &data)
107 m_appControlDataArray.push_back(data);
111 service_h ApplicationControl::getService_h() const
116 void ApplicationControl::setService_h(const service_h service)
118 m_appControl = service;
123 void ApplicationControl::replyResult(std::vector<ApplicationControlDataPtr> &appControlDataArray)
126 service_create(&reply);
128 const char* key = NULL;
129 const char** arr = NULL;
131 if (!appControlDataArray.empty())
133 LoggerD("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();
138 arr = (const char**) calloc (sizeof(char*), valueArray.size());
140 for (size_t j = 0; j < valueArray.size(); j++) {
141 arr[j] = valueArray.at(j).c_str();
143 service_add_extra_data_array(reply, key, arr, valueArray.size());
146 LoggerE("==[replyResult] appControlDataArray is empty");
149 service_reply_to_launch_request(reply, m_appControl, SERVICE_RESULT_SUCCEEDED);
151 service_destroy(reply);
159 void ApplicationControl::replyFailure()
162 service_create(&reply);
164 LoggerE("==[replyFailure] enter ApplicationControl::replyFailure");
165 service_reply_to_launch_request(reply, m_appControl, SERVICE_RESULT_FAILED);
167 service_destroy(reply);