1 /* 2 * Copyright (c) 2021-2022 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 MERGERCONTACT_H 17 #define MERGERCONTACT_H 18 19 #include "datashare_predicates.h" 20 #include "rdb_store.h" 21 #include "result_set.h" 22 23 namespace OHOS { 24 namespace Contacts { 25 class MergerContacts { 26 public: 27 MergerContacts(); 28 ~MergerContacts(); 29 int ForceContactMerge(std::shared_ptr<OHOS::NativeRdb::RdbStore>, std::set<int>); 30 int ContactMerge(std::shared_ptr<OHOS::NativeRdb::RdbStore>); 31 int ReContactMerge(std::shared_ptr<OHOS::NativeRdb::RdbStore>, const DataShare::DataSharePredicates &); 32 std::shared_ptr<OHOS::NativeRdb::ResultSet> SelectCandidate(std::shared_ptr<OHOS::NativeRdb::RdbStore>); 33 34 private: 35 void UpdateIdsByName( 36 std::shared_ptr<OHOS::NativeRdb::RdbStore>, std::set<std::string>, std::set<int>, std::vector<std::set<int>> &); 37 std::vector<std::set<int>> SelectIdsByName(std::shared_ptr<OHOS::NativeRdb::RdbStore>, std::set<int>); 38 void UpdateCandidate(std::shared_ptr<OHOS::NativeRdb::RdbStore>, std::vector<int>, std::vector<std::set<int>> &); 39 int MergeCircle(std::shared_ptr<OHOS::NativeRdb::RdbStore>, std::vector<std::set<int>>); 40 std::vector<std::set<int>> QueryMergeContacts(std::shared_ptr<OHOS::NativeRdb::RdbStore>, int); 41 std::string QueryCandidateName(std::shared_ptr<OHOS::NativeRdb::RdbStore>, int); 42 void UpdateRawContacts(std::shared_ptr<OHOS::NativeRdb::RdbStore>, int, std::set<int>); 43 void UpdateRawContactsExecute( 44 std::shared_ptr<OHOS::NativeRdb::RdbStore> store, int minContactId, std::set<int> Ids); 45 std::set<int> HandleIds(std::shared_ptr<OHOS::NativeRdb::RdbStore>, std::set<int>); 46 int DeleteContacts(std::shared_ptr<OHOS::NativeRdb::RdbStore>, int, std::set<int>); 47 std::set<int> QueryTargetName(std::shared_ptr<OHOS::NativeRdb::RdbStore>, int, std::set<std::string>); 48 bool isNameMatch(std::shared_ptr<OHOS::NativeRdb::RdbStore>, std::set<int>); 49 int ManualMergeOperation(std::shared_ptr<OHOS::NativeRdb::RdbStore> store, int minId, std::set<int> handledIds); 50 std::string getUpdateSql(int minId); 51 }; 52 } // namespace Contacts 53 } // namespace OHOS 54 55 #endif // MERGERCONTACT_H 56