Update User Agent String
[framework/web/wrt-commons.git] / modules / widget_dao / dao / WrtDatabase.cpp
1 /*
2  * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
3  *
4  *    Licensed under the Apache License, Version 2.0 (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
7  *
8  *        http://www.apache.org/licenses/LICENSE-2.0
9  *
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.
15  */
16
17 #include <dpl/wrt-dao-ro/WrtDatabase.h>
18
19 #include <dpl/db/thread_database_support.h>
20 #include <dpl/db/sql_connection.h>
21 #include <dpl/mutex.h>
22 #include <dpl/thread.h>
23 #include <dpl/wrt-dao-ro/global_config.h>
24
25 namespace WrtDB {
26
27 const char* WrtDatabase::Address()
28 {
29     using namespace WrtDB;
30     return GlobalConfig::GetWrtDatabaseFilePath();
31 }
32
33 DPL::DB::SqlConnection::Flag::Type WrtDatabase::Flags()
34 {
35     return DPL::DB::SqlConnection::Flag::UseLucene;
36 }
37
38 DPL::DB::ThreadDatabaseSupport WrtDatabase::m_interface(
39         WrtDatabase::Address(),
40         WrtDatabase::Flags());
41
42 void WrtDatabase::attachToThreadRO()
43 {
44     m_interface.AttachToThread(DPL::DB::SqlConnection::Flag::RO);
45 }
46
47 void WrtDatabase::attachToThreadRW()
48 {
49     m_interface.AttachToThread(DPL::DB::SqlConnection::Flag::RW);
50 }
51
52 void WrtDatabase::detachFromThread()
53 {
54     m_interface.DetachFromThread();
55 }
56
57 DPL::DB::ThreadDatabaseSupport& WrtDatabase::interface()
58 {
59     return m_interface;
60 }
61
62 bool WrtDatabase::CheckTableExist(const char *name)
63 {
64     return m_interface.CheckTableExist(name);
65 }
66
67 }