6ad36ad3fd8370f4345ef713eba26c1d0debc801
[platform/core/appfw/watchface-complication.git] / watchface-complication / db-manager.h
1 /*
2  * Copyright (c) 2018 Samsung Electronics Co., Ltd.
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 #ifndef WATCHFACE_COMPLICATION_DB_MANAGER_H_
18 #define WATCHFACE_COMPLICATION_DB_MANAGER_H_
19
20 #include <gio/gio.h>
21 #include <sqlite3.h>
22 #include <watchface-common.h>
23 #include <bundle_cpp.h>
24
25 #include <string>
26 #include <memory>
27 #include <list>
28
29 namespace watchface_complication {
30
31 class EXPORT_API DBManager {
32  public:
33   class ProviderInfo {
34     std::string provider_id_;
35     int type_;
36    public:
37     ProviderInfo(std::string provider_id, int type)
38       : provider_id_(provider_id), type_(type) {
39     }
40     std::string& GetProviderId() {
41       return provider_id_;
42     }
43     int GetType() {
44       return type_;
45     }
46   };
47   static std::unique_ptr<tizen_base::Bundle> GetDefaultData(
48       const char* provider_id, int support_type);
49   static std::string GetProviderAppId(const char* provider_id);
50   static std::list<std::string> GetRequiredPrivilegeList(
51                   std::string& provider_id);
52   static int GetRequiredSupportEvents(std::string& provider_id);
53   static std::list<std::unique_ptr<ProviderInfo>> GetProviderListWithTypes(
54                   int supported_types);
55   static int GetSupportTypes(std::string& provider_id, int* types);
56   static int GetProviderPeriod(std::string& provider_id, int* period);
57   static std::string GetLabel(const char* provider_id);
58   static std::string GetSetupAppId(const char* provider_id);
59   static bool IsProviderExist(std::string& provider_id, int support_type);
60   static std::list<std::string> GetProviderListWithAppId(const char* provider_id);
61   static int GetTrustedInfo(std::string& provider_id, bool* trusted);
62
63  private:
64   DBManager(); /* LCOV_EXCL_LINE */
65   virtual ~DBManager(); /* LCOV_EXCL_LINE */
66   static sqlite3* OpenDB();
67   static void CloseDB(sqlite3* db);
68   static const char* GetParserDataPath();
69   static char* GetSystemLocale();
70 };
71
72 }  // namespace watchface_complication
73
74 #endif  // WATCHFACE_COMPLICATION_DB_MANAGER_H_