• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2021 Huawei Device Co., Ltd.
3  * Licensed under the Apache License, Version 2.0 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at
6  *
7  *     http://www.apache.org/licenses/LICENSE-2.0
8  *
9  * Unless required by applicable law or agreed to in writing, software
10  * distributed under the License is distributed on an "AS IS" BASIS,
11  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12  * See the License for the specific language governing permissions and
13  * limitations under the License.
14  */
15 
16 #ifndef DATA_STORAGE_RDB_SMS_MMS_HELPER_H
17 #define DATA_STORAGE_RDB_SMS_MMS_HELPER_H
18 
19 #include <stdint.h>
20 
21 #include "iosfwd"
22 #include "memory"
23 #include "rdb_base_helper.h"
24 #include "string"
25 #include "vector"
26 
27 namespace OHOS {
28 namespace NativeRdb {
29 class AbsSharedResultSet;
30 class ValuesBucket;
31 } // namespace NativeRdb
32 namespace Telephony {
33 class RdbSmsMmsHelper : public RdbBaseHelper {
34 public:
35     RdbSmsMmsHelper();
36     ~RdbSmsMmsHelper() = default;
37 
38     /**
39      * Delete sms_mms_info table data of the previous 30 days
40      *
41      * @return 0 is succeed else failed
42      */
43     int32_t DeleteDataByThirty();
44 
45     /**
46      * Insert sms_mms_info table data
47      *
48      * @param id id
49      * @param initialValues Table field data
50      * @return 0 is succeed else failed
51      */
52     int32_t InsertSmsMmsInfo(int64_t &id, const NativeRdb::ValuesBucket &initialValues);
53 
54     /**
55      * Batch Insert sms_mms_info table data
56      *
57      * @param id id
58      * @param values Table field data
59      * @return 0 is succeed else failed
60      */
61     int32_t BatchInsertSmsMmsInfo(int64_t &id, const std::vector<NativeRdb::ValuesBucket> &values);
62 
63     /**
64      * Commit the transaction action
65      *
66      * @return 0 is succeed else failed
67      */
68     int CommitTransactionAction();
69 
70     /**
71      * Statistics sms_mms_info table unread quantity
72      *
73      * @return unique_ptr<NativeRdb::AbsSharedResultSet>
74      */
75     std::unique_ptr<NativeRdb::AbsSharedResultSet> StatisticsUnRead();
76 
77     /**
78      * Query sms_mms_info table max group_id
79      *
80      * @return  unique_ptr<NativeRdb::AbsSharedResultSet>
81      */
82     std::unique_ptr<NativeRdb::AbsSharedResultSet> QueryMaxGroupId();
83 
84     /**
85      * Update dataBase path
86      *
87      * @param path path
88      */
89     void UpdateDbPath(const std::string &path);
90 
91     /**
92      * Init dataBase
93      *
94      * @return 0 is succeed else failed
95      */
96     int Init();
97 
98 private:
99     /**
100      * Create SmsMmsInfo table
101      *
102      * @param createTableStr Create table statement
103      */
104     void CreateSmsMmsInfoTableStr(std::string &createTableStr);
105 
106     /**
107      * Create SmsSubsection table
108      *
109      * @param createTableStr Create table statement
110      */
111     void CreateSmsSubsectionTableStr(std::string &createTableStr);
112 
113     /**
114      * Create MmsProtocol table
115      *
116      * @param createTableStr Create table statement
117      */
118     void CreateMmsProtocolTableStr(std::string &createTableStr);
119 
120     /**
121      * Create MmsPart table
122      *
123      * @param createTableStr Create table statement
124      */
125     void CreateMmsPartTableStr(std::string &createTableStr);
126 
127 private:
128     const std::string DB_NAME = "sms_mms.db";
129     std::string dbPath_ = FOLDER_PATH + DB_NAME;
130     const int VERSION = 1;
131 };
132 } // namespace Telephony
133 } // namespace OHOS
134 #endif // DATA_STORAGE_RDB_SMS_MMS_HELPER_H
135