• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 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 SERVICES_EDM_INCLUDE_EDM_IPLUGIN_H
17 #define SERVICES_EDM_INCLUDE_EDM_IPLUGIN_H
18 
19 #include <iostream>
20 #include <map>
21 #include <string>
22 #include "edm_errors.h"
23 #include "func_code_utils.h"
24 #include "message_parcel.h"
25 
26 namespace OHOS {
27 namespace EDM {
28 class IPlugin {
29 public:
30     /*
31      * handle policy
32      *
33      * @param funcCode func code
34      * @param data Data sent from the DPC
35      * @param policyData Policy data after processing
36      * @param isChanged Whether the data is changed
37      * @return If the operation is successful, ERR_OK is returned.
38      */
39     virtual ErrCode OnHandlePolicy(std::uint32_t funcCode, MessageParcel &data, std::string &policyData,
40         bool &isChanged) = 0;
41 
42     /*
43      * Merge policy data
44      *
45      * @param adminName current admin name
46      * @param policyData in:Current cached policy data,out:comprehensive data of all admins currently cached.
47      * @return If ERR_OK is returned,policyData incoming and outgoing data will be saved to a file.
48      */
49     virtual ErrCode MergePolicyData(const std::string &adminName, std::string &policyData);
50     virtual void OnHandlePolicyDone(std::uint32_t funcCode, const std::string &adminName, bool isGlobalChanged) = 0;
51     virtual ErrCode OnAdminRemove(const std::string &adminName, const std::string &policyData) = 0;
52     virtual void OnAdminRemoveDone(const std::string &adminName, const std::string &currentJsonData) = 0;
53     virtual ErrCode WritePolicyToParcel(const std::string &policyData, MessageParcel &reply);
54     std::uint32_t GetCode();
55     std::string GetPolicyName();
56     bool NeedSavePolicy();
57     bool IsGlobalPolicy();
58     std::string GetPermission();
59     virtual ~IPlugin();
60 
61 protected:
62     std::uint32_t policyCode_;
63     std::string policyName_;
64     std::string permission_;
65     bool needSave_ = true;
66     bool isGlobal_ = true;
67 };
68 } // namespace EDM
69 } // namespace OHOS
70 
71 #endif // SERVICES_EDM_INCLUDE_EDM_IPLUGIN_H
72