1 /*
2  * Copyright (C) 2024 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 RINGTONE_COLUMN_DATA_COMMAND_H
17 #define RINGTONE_COLUMN_DATA_COMMAND_H
18 
19 #include "abs_rdb_predicates.h"
20 #include "datashare_predicates.h"
21 #include "ringtone_db_const.h"
22 #include "uri.h"
23 #include "values_bucket.h"
24 
25 namespace OHOS {
26 namespace Media {
27 #define EXPORT __attribute__ ((visibility ("default")))
28 enum class EXPORT RingtoneOperationType : uint32_t {
29     UNKNOWN_TYPE = 0,
30     OPEN,
31     INSERT,
32     DELETE,
33     UPDATE,
34     QUERY,
35     SCAN,
36 };
37 
38 class RingtoneDataCommand {
39 public:
40     EXPORT explicit RingtoneDataCommand(const Uri &uri, const std::string &table, const RingtoneOperationType type);
41     EXPORT RingtoneDataCommand() = delete;
42     EXPORT ~RingtoneDataCommand();
43     EXPORT RingtoneDataCommand(const RingtoneDataCommand &) = delete;
44     EXPORT RingtoneDataCommand &operator=(const RingtoneDataCommand &) = delete;
45     EXPORT RingtoneDataCommand(RingtoneDataCommand &&) = delete;
46     EXPORT RingtoneDataCommand &operator=(RingtoneDataCommand &&) = delete;
47 
48     const Uri &GetUri() const;
49     const std::string &GetTableName();
50     NativeRdb::ValuesBucket &GetValueBucket();
51     EXPORT NativeRdb::AbsRdbPredicates *GetAbsRdbPredicates();
52     EXPORT const std::string &GetBundleName();
53     EXPORT const std::string &GetResult();
54 
55     EXPORT void SetDataSharePred(const DataShare::DataSharePredicates &pred);
56     EXPORT void SetValueBucket(const NativeRdb::ValuesBucket &value);
57     EXPORT void SetBundleName(const std::string &bundleName);
58     EXPORT void SetResult(const std::string &result);
59     EXPORT RingtoneOperationType GetOprnType() const;
60 private:
61     static int32_t GetToneIdFromUri(Uri &uri);
62 
63     Uri uri_ {""};
64     std::string tableName_;
65     RingtoneOperationType oprnType_ {RingtoneOperationType::UNKNOWN_TYPE};
66     int32_t toneId_;
67     NativeRdb::ValuesBucket insertValue_;
68     std::unique_ptr<NativeRdb::AbsRdbPredicates> absRdbPredicates_;
69     std::unique_ptr<const DataShare::DataSharePredicates> datasharePred_;
70     std::string bundleName_;
71     std::string result_;
72 };
73 } // namespace Media
74 } // namespace OHOS
75 
76 #endif // RINGTONE_COLUMN_DATA_COMMAND_H
77