• 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 PASTEBOARD_INTERFACES_KITS_NAPI_SRC_PASTE_BOARD_DAILOG_H
17 #define PASTEBOARD_INTERFACES_KITS_NAPI_SRC_PASTE_BOARD_DAILOG_H
18 #include <functional>
19 #include <mutex>
20 #include <string>
21 
22 #include "ability_manager_interface.h"
23 #include "refbase.h"
24 
25 namespace OHOS::MiscServices {
26 class DialogConnection;
27 class PasteBoardDialog {
28 public:
29     struct MessageInfo {
30         std::string appName{ "unknown" };
31         std::string deviceType{ "unknown" };
32     };
33     static constexpr uint32_t POPUP_INTERVAL = 1;  // seconds
34     static constexpr uint32_t MAX_LIFE_TIME = 300; // seconds
35     static constexpr const char *DEFAULT_LABEL = "unknown";
36     using Cancel = std::function<void()>;
37     static PasteBoardDialog &GetInstance();
38     int32_t ShowDialog(const MessageInfo &message, const Cancel &cancel);
39     void CancelDialog();
40 
41 private:
42     static sptr<OHOS::AAFwk::IAbilityManager> GetAbilityManagerService();
43 
44     static constexpr const char *PASTEBOARD_DIALOG_APP = "cn.openharmony.pasteboarddialog";
45     static constexpr const char *PASTEBOARD_DIALOG_ABILITY = "DialogExtensionAbility";
46 
47     std::mutex connectionLock_;
48     sptr<DialogConnection> connection_;
49 };
50 } // namespace OHOS::MiscServices
51 #endif // PASTEBOARD_INTERFACES_KITS_NAPI_SRC_PASTE_BOARD_DAILOG_H
52