1 /*
2  * Copyright (c) 2023 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 OHOS_ABILITY_RUNTIME_DATA_ABILITY_HELPER_COMMON_H
17 #define OHOS_ABILITY_RUNTIME_DATA_ABILITY_HELPER_COMMON_H
18 
19 #include <vector>
20 #include "abs_shared_result_set.h"
21 #include "data_ability_helper.h"
22 #include "data_ability_predicates.h"
23 #include "feature_ability_common.h"
24 #include "values_bucket.h"
25 
26 namespace OHOS {
27 namespace AppExecFwk {
28 struct DAHelperInsertCB {
29     CBBase cbBase;
30     std::shared_ptr<DataAbilityHelper> dataAbilityHelper;
31     std::string uri;
32     NativeRdb::ValuesBucket valueBucket;
33     int result = 0;
34     int execResult;
35 };
36 
37 struct DAHelperNotifyChangeCB {
38     CBBase cbBase;
39     std::shared_ptr<DataAbilityHelper> dataAbilityHelper;
40     std::string uri;
41     int execResult;
42 };
43 
44 class NAPIDataAbilityObserver;
45 struct DAHelperOnOffCB {
46     CBBase cbBase;
47     std::shared_ptr<DataAbilityHelper> dataAbilityHelper;
48     sptr<NAPIDataAbilityObserver> observer;
49     std::string uri;
50     int result = 0;
51     std::vector<DAHelperOnOffCB *> NotifyList;
52     std::vector<DAHelperOnOffCB *> DestroyList;
53 };
54 
55 struct DAHelperGetTypeCB {
56     CBBase cbBase;
57     std::shared_ptr<DataAbilityHelper> dataAbilityHelper;
58     std::string uri;
59     std::string result = "";
60     int execResult;
61 };
62 
63 struct DAHelperGetFileTypesCB {
64     CBBase cbBase;
65     std::shared_ptr<DataAbilityHelper> dataAbilityHelper;
66     std::string uri;
67     std::string mimeTypeFilter;
68     std::vector<std::string> result;
69     int execResult;
70 };
71 
72 struct DAHelperNormalizeUriCB {
73     CBBase cbBase;
74     std::shared_ptr<DataAbilityHelper> dataAbilityHelper;
75     std::string uri;
76     std::string result = "";
77     int execResult;
78 };
79 struct DAHelperDenormalizeUriCB {
80     CBBase cbBase;
81     std::shared_ptr<DataAbilityHelper> dataAbilityHelper;
82     std::string uri;
83     std::string result = "";
84     int execResult;
85 };
86 
87 struct DAHelperDeleteCB {
88     CBBase cbBase;
89     std::shared_ptr<DataAbilityHelper> dataAbilityHelper;
90     std::string uri;
91     NativeRdb::DataAbilityPredicates predicates;
92     int result = 0;
93     int execResult;
94 };
95 
96 struct DAHelperQueryCB {
97     CBBase cbBase;
98     std::shared_ptr<DataAbilityHelper> dataAbilityHelper;
99     std::string uri;
100     std::vector<std::string> columns;
101     NativeRdb::DataAbilityPredicates predicates;
102     std::shared_ptr<NativeRdb::AbsSharedResultSet> result;
103     int execResult;
104 };
105 
106 struct DAHelperUpdateCB {
107     CBBase cbBase;
108     std::shared_ptr<DataAbilityHelper> dataAbilityHelper;
109     std::string uri;
110     NativeRdb::ValuesBucket valueBucket;
111     NativeRdb::DataAbilityPredicates predicates;
112     int result = 0;
113     int execResult;
114 };
115 
116 struct DAHelperCallCB {
117     CBBase cbBase;
118     std::shared_ptr<DataAbilityHelper> dataAbilityHelper;
119     std::string uri;
120     std::string method;
121     std::string arg;
122     AppExecFwk::PacMap pacMap;
123     std::shared_ptr<AppExecFwk::PacMap> result;
124     int execResult;
125 };
126 
127 struct DAHelperErrorCB {
128     CBBase cbBase;
129     int execResult;
130 };
131 struct DAHelperBatchInsertCB {
132     CBBase cbBase;
133     std::shared_ptr<DataAbilityHelper> dataAbilityHelper;
134     std::string uri;
135     std::vector<NativeRdb::ValuesBucket> values;
136     int result = 0;
137     int execResult;
138 };
139 struct DAHelperOpenFileCB {
140     CBBase cbBase;
141     std::shared_ptr<DataAbilityHelper> dataAbilityHelper;
142     std::string uri;
143     std::string mode;
144     int result = 0;
145     int execResult;
146 };
147 
148 struct DAHelperExecuteBatchCB {
149     CBBase cbBase;
150     std::string uri;
151     std::vector<std::shared_ptr<DataAbilityOperation>> operations;
152     std::shared_ptr<DataAbilityHelper> dataAbilityHelper;
153     std::vector<std::shared_ptr<DataAbilityResult>> result;
154 };
155 } // namespace AppExecFwk
156 } // namespace OHOS
157 #endif /* OHOS_ABILITY_RUNTIME_DATA_ABILITY_HELPER_COMMON_H */
158