• 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                              "  activate-admin            activate a admin with options\n"
32                              "  activate-super-admin      activate a super admin with options\n"
33                              "  deactivate-admin          deactivate a admin with options\n"
34                              "  deactivate-super-admin    deactivate a super admin with options\n";
35 }  // namespace
36 
37 class EdmCommand : public ShellCommand {
38 public:
39     EdmCommand(int argc, char *argv[]);
~EdmCommand()40     ~EdmCommand() override
41     {}
42 
43 private:
44     ErrCode CreateCommandMap() override;
45     ErrCode CreateMessageMap() override;
46     ErrCode init() override;
47     ErrCode RunAsHelpCommand();
48     ErrCode RunAsActivateCommand(AdminType type);
49     ErrCode RunAsActivateAdminCommand();
50     ErrCode RunAsActivateSuperAdminCommand();
51     ErrCode RunDeactivateNormalAdminCommand();
52     ErrCode RunDeactivateSuperAdminCommand();
53     std::vector<std::string> split(const std::string &str, const std::string &pattern);
54 
55     std::shared_ptr<EnterpriseDeviceMgrProxy> enterpriseDeviceMgrProxy_;
56 };
57 }  // namespace EDM
58 }  // namespace OHOS
59 
60 #endif  // EDM_TOOLS_EDM_INCLUDE_EDM_COMMAND_H