2 * Copyright (c) 2013 Samsung Electronics Co., Ltd All Rights Reserved
4 * Licensed under the Flora License, Version 1.1 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://floralicense.org/license/
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
17 * @file web_provider_livebox_info.cpp
18 * @author Yunchan Cho (yunchan.cho@samsung.com)
22 #include "WebProviderDB.h"
23 #include "web_provider_livebox_info.h"
25 static const std::string infoTable("LiveboxInfo");
35 // TODO this default type should be retrieved more automatically
36 static const std::string defaultBoxType("app");
38 const char* web_provider_livebox_get_default_type()
40 return defaultBoxType.c_str();
43 const char* web_provider_livebox_get_box_type(const char* box_id)
49 std::shared_ptr<WebProviderDB> handle(new WebProviderDB());
50 if (!handle->openDB()) {
54 std::string query = "select * from " + infoTable + " where box_id = ?";
55 if (!handle->setCommand(query, "s", box_id)) {
60 if (!handle->executeCommand()) {
65 const char* box_type = handle->getText(InfoTableField::BOX_TYPE);
66 const char* box_type_dup = NULL;
69 box_type_dup = strdup(box_type);
77 const char* web_provider_livebox_get_app_id(const char* box_id)
83 std::shared_ptr<WebProviderDB> handle(new WebProviderDB());
84 if (!handle->openDB()) {
88 std::string query = "select * from " + infoTable + " where box_id = ?";
89 if (!handle->setCommand(query, "s", box_id)) {
94 if (!handle->executeCommand()) {
99 const char* app_id = handle->getText(InfoTableField::APP_ID);
100 const char* app_id_dup = NULL;
103 app_id_dup = strdup(app_id);
111 int web_provider_livebox_get_auto_launch(const char* box_id)
117 std::shared_ptr<WebProviderDB> handle(new WebProviderDB());
118 if (!handle->openDB()) {
122 std::string query = "select * from " + infoTable + " where box_id = ?";
123 if (!handle->setCommand(query, "s", box_id)) {
128 if (!handle->executeCommand()) {
133 int autoLaunch = handle->getInt(InfoTableField::AUTO_LAUNCH);
139 int web_provider_livebox_get_mouse_event(const char* box_id)
145 std::shared_ptr<WebProviderDB> handle(new WebProviderDB());
146 if (!handle->openDB()) {
150 std::string query = "select * from " + infoTable + " where box_id = ?";
151 if (!handle->setCommand(query, "s", box_id)) {
156 if (!handle->executeCommand()) {
161 int mouseEvent = handle->getInt(InfoTableField::MOUSE_EVENT);
167 int web_provider_livebox_insert_box_info(
170 const char* box_type,
174 if (!box_id || !app_id || !box_type) {
178 std::shared_ptr<WebProviderDB> handle(new WebProviderDB());
179 if (!handle->openDB()) {
184 "insert into " + infoTable +
185 " (box_id, app_id, box_type, auto_launch, mouse_event) values (?,?,?,?,?)";
187 if (!handle->setCommand(
189 box_id, app_id, box_type, auto_launch, mouse_event)) {
194 if (!handle->executeCommand()) {
203 int web_provider_livebox_insert_box_type(
206 const char* box_type)
208 return web_provider_livebox_insert_box_info(box_id, app_id, box_type, 0, 0);
211 int web_provider_livebox_delete_by_box_id(const char* box_id)
217 std::shared_ptr<WebProviderDB> handle(new WebProviderDB());
218 if (!handle->openDB()) {
223 "delete from " + infoTable + " where box_id=?";
225 if (!handle->setCommand(query, "s", box_id)) {
230 if (!handle->executeCommand()) {
239 int web_provider_livebox_delete_by_app_id(const char* app_id)
245 std::shared_ptr<WebProviderDB> handle(new WebProviderDB());
246 if (!handle->openDB()) {
251 "delete from " + infoTable + " where app_id=?";
253 if (!handle->setCommand(query, "s", app_id)) {
258 if (!handle->executeCommand()) {
267 int web_provider_livebox_delete_by_type(const char* type)
273 std::shared_ptr<WebProviderDB> handle(new WebProviderDB());
274 if (!handle->openDB()) {
279 "delete from " + infoTable + " where type=?";
281 if (!handle->setCommand(query, "s", type)) {
286 if (!handle->executeCommand()) {
295 const char* web_provider_info_get_default_type()
297 return web_provider_livebox_get_default_type();
300 const char* web_provider_info_get_box_type(const char* box_id)
302 return web_provider_livebox_get_box_type(box_id);
305 int web_provider_info_insert_box_type(
308 const char* box_type)
310 return web_provider_livebox_insert_box_info(box_id, app_id, box_type, 0, 0);
313 int web_provider_info_delete_by_box_id(const char* box_id)
315 return web_provider_livebox_delete_by_box_id(box_id);
318 int web_provider_info_delete_by_app_id(const char* app_id)
320 return web_provider_livebox_delete_by_app_id(app_id);
323 int web_provider_info_delete_by_type(const char* type)
325 return web_provider_livebox_delete_by_type(type);