Change default sound, vibration name
[platform/core/api/notification.git] / notification-ex / db_manager.h
1 /*
2  * Copyright (c) 2019 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 NOTIFICATION_EX_DB_MANAGER_H_
18 #define NOTIFICATION_EX_DB_MANAGER_H_
19
20 #include <sqlite3.h>
21
22 #include <string>
23 #include <memory>
24 #include <map>
25 #include <list>
26
27 #include "notification-ex/abstract_item.h"
28
29 #ifndef EXPORT_API
30 #define EXPORT_API __attribute__((visibility("default")))
31 #endif
32
33 namespace notification {
34
35 class EXPORT_API DBManager {
36  public:
37   static int InitializeDB();
38   static void InitializeData();
39   static int InsertNotification(std::list<std::shared_ptr<item::AbstractItem>> addedItem);
40   static std::map<std::string, std::string> GetHideMap();
41   static int UpdateHideList(std::shared_ptr<item::AbstractItem> updatedItem, const std::string& hide_list);
42   static int UpdateNotification(std::shared_ptr<item::AbstractItem> updatedItem);
43   static int GetCount(int64_t priv_id, const std::string& root_id, const std::string& app_id,  uid_t uid, int* count);
44   static int GetCount(const std::string& app_id, uid_t uid, int* count);
45   static int DeleteNotification(std::shared_ptr<item::AbstractItem> deletedItem);
46   static std::list<std::shared_ptr<item::AbstractItem>> GetNotificationList(uid_t uid, std::string channel = "");
47   static std::list<std::shared_ptr<item::AbstractItem>> GetNotificationList(std::string app_id, uid_t uid, std::string channel = "");
48   static std::list<std::shared_ptr<item::AbstractItem>> GetNotificationList(std::string app_id, std::string root_id, uid_t uid);
49   static std::list<std::shared_ptr<item::AbstractItem>> GetNotificationList(std::string app_id, int64_t private_id, uid_t uid);
50
51  private:
52   DBManager(); /* LCOV_EXCL_LINE */
53   ~DBManager(); /* LCOV_EXCL_LINE */
54   static sqlite3* OpenDB();
55   static void CloseDB(sqlite3* db);
56   static int CheckDBIntegrity(void* user_data, int argc, char** argv, char** notUsed);
57   static int RecoverCorruptedDB(sqlite3* db);
58   static int ExecuteQuery(const char* query, int* num_changes);
59   static int ExecuteQuery(sqlite3* db, const char* query, int* num_changes);
60   static int GetSequence(sqlite3* db, int64_t* seq);
61   static std::string GetPkgId(const std::string& app_id, uid_t uid);
62   static void CheckLimit(std::shared_ptr<item::AbstractItem> addedItem, sqlite3* db);
63   static int UpdateReceiverList(std::shared_ptr<item::AbstractItem> updatedItem,  sqlite3* db);
64   static std::list<std::shared_ptr<item::AbstractItem>> ExecuteGetList(char* query);
65 };
66 }  // namespace notification
67
68 #endif  // NOTIFICATION_EX_DB_MANAGER_H_