• 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 EDM_TOOLS_EDM_INCLUDE_EDM_COMMAND_H
17 #define EDM_TOOLS_EDM_INCLUDE_EDM_COMMAND_H
18 
19 #include "shell_command.h"
20 #include "enterprise_device_mgr_proxy.h"
21 #include "ienterprise_device_mgr.h"
22 
23 namespace OHOS {
24 namespace EDM {
25 namespace {
26 const std::string TOOL_NAME = "edm";
27 
28 const std::string HELP_MSG = "usage: edm <command> <options>\n"
29                              "These are common edm commands list:\n"
30                              "  help                      list available commands\n"
31                              "  enable-admin            enable a admin with options\n"
32                              "  enable-super-admin      enable a super admin with options\n"
33                              "  disable-admin          disable a admin with options\n";
34 }  // namespace
35 
36 class EdmCommand : public ShellCommand {
37 public:
38     EdmCommand(int argc, char *argv[]);
~EdmCommand()39     ~EdmCommand() override
40     {}
41 
42 private:
43     ErrCode CreateCommandMap() override;
44     ErrCode CreateMessageMap() override;
45     ErrCode init() override;
46     ErrCode RunAsHelpCommand();
47     ErrCode RunAsEnableCommand(AdminType type);
48     ErrCode RunAsEnableAdminCommand();
49     ErrCode RunAsEnableSuperAdminCommand();
50     ErrCode RunDisableNormalAdminCommand();
51     std::vector<std::string> split(const std::string &str, const std::string &pattern);
52 
53     std::shared_ptr<EnterpriseDeviceMgrProxy> enterpriseDeviceMgrProxy_;
54 };
55 } // namespace EDM
56 } // namespace OHOS
57 
58 #endif // EDM_TOOLS_EDM_INCLUDE_EDM_COMMAND_H
59