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 #include "auto_launch_callback.h"
16
17 #include <algorithm>
18 #include "distributeddb_log_print.h"
19
20 using namespace DistributedDB;
21 using namespace std;
22
23 #ifdef RELEASE_MODE_V2
AutoLaunchNotifier(const std::string & userId,const std::string & appId,const std::string & storeId,AutoLaunchStatus status)24 void AutoLaunchCallback::AutoLaunchNotifier(const std::string &userId, const std::string &appId,
25 const std::string &storeId, AutoLaunchStatus status)
26 {
27 MST_LOG("The db: %s,%s,%s is set to sync by closed status and comes some data changes now.", userId.c_str(),
28 appId.c_str(), storeId.c_str());
29 this->realStatus_ = status;
30 }
31
GetStatus()32 int AutoLaunchCallback::GetStatus()
33 {
34 return realStatus_;
35 }
36
Clear()37 void AutoLaunchCallback::Clear()
38 {
39 this->realStatus_ = 0;
40 }
41
42 #ifdef RELEASE_MODE_V3
AutoLaunchRequestNotifier(const std::string & identifier,AutoLaunchParam & param)43 bool AutoLaunchCallback::AutoLaunchRequestNotifier(const std::string &identifier, AutoLaunchParam ¶m)
44 {
45 auto iter = find(hashIdentities_.begin(), hashIdentities_.end(), identifier);
46 if (iter != hashIdentities_.end()) {
47 param.userId = autoLaunchParam_.userId;
48 param.appId = autoLaunchParam_.appId;
49 param.storeId = autoLaunchParam_.storeId;
50 param.option = autoLaunchParam_.option;
51 param.notifier = autoLaunchParam_.notifier;
52 return true;
53 }
54 return false;
55 }
56
AddHashIdentity(const string & hashIdentity)57 void AutoLaunchCallback::AddHashIdentity(const string &hashIdentity)
58 {
59 hashIdentities_.push_back(hashIdentity);
60 }
61
ClearHashIdentities()62 void AutoLaunchCallback::ClearHashIdentities()
63 {
64 hashIdentities_.clear();
65 }
66
SetAutoLaunchParam(AutoLaunchParam & autoLaunchParam)67 void AutoLaunchCallback::SetAutoLaunchParam(AutoLaunchParam &autoLaunchParam)
68 {
69 autoLaunchParam_ = autoLaunchParam;
70 }
71 #endif // end of RELEASE_MODE_V3
72 #endif // end of RELEASE_MODE_V2