• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2023 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 OHOS_REQUEST_DOWNLOAD_MANAGER_H
17 #define OHOS_REQUEST_DOWNLOAD_MANAGER_H
18 
19 #include "i_notify_data_listener.h"
20 #include "i_response_listener.h"
21 #include "js_common.h"
22 #include "visibility.h"
23 
24 namespace OHOS::Request {
25 
26 class RequestManager {
27 public:
28     REQUEST_API static const std::unique_ptr<RequestManager> &GetInstance();
29     REQUEST_API int32_t Create(const Config &config, int32_t seq, std::string &tid);
30     REQUEST_API int32_t GetTask(const std::string &tid, const std::string &token, Config &config);
31     REQUEST_API int32_t Start(const std::string &tid);
32     REQUEST_API int32_t Stop(const std::string &tid);
33     REQUEST_API int32_t Query(const std::string &tid, TaskInfo &info);
34     REQUEST_API int32_t Touch(const std::string &tid, const std::string &token, TaskInfo &info);
35     REQUEST_API int32_t Search(const Filter &filter, std::vector<std::string> &tids);
36     REQUEST_API int32_t Show(const std::string &tid, TaskInfo &info);
37     REQUEST_API int32_t Pause(const std::string &tid, Version version);
38     REQUEST_API int32_t QueryMimeType(const std::string &tid, std::string &mimeType);
39     REQUEST_API int32_t Remove(const std::string &tid, Version version);
40     REQUEST_API int32_t Resume(const std::string &tid);
41 
42     REQUEST_API int32_t Subscribe(const std::string &taskId);
43     REQUEST_API int32_t Unsubscribe(const std::string &taskId);
44 
45     REQUEST_API int32_t AddListener(
46         const std::string &taskId, const SubscribeType &type, const std::shared_ptr<IResponseListener> &listener);
47     REQUEST_API int32_t RemoveListener(
48         const std::string &taskId, const SubscribeType &type, const std::shared_ptr<IResponseListener> &listener);
49     REQUEST_API int32_t AddListener(
50         const std::string &taskId, const SubscribeType &type, const std::shared_ptr<INotifyDataListener> &listener);
51     REQUEST_API int32_t RemoveListener(
52         const std::string &taskId, const SubscribeType &type, const std::shared_ptr<INotifyDataListener> &listener);
53     REQUEST_API void RemoveAllListeners(const std::string &taskId);
54 
55     REQUEST_API void RestoreListener(void (*callback)());
56     REQUEST_API bool LoadRequestServer();
57     REQUEST_API bool IsSaReady();
58     REQUEST_API void ReopenChannel();
59     REQUEST_API bool SubscribeSA();
60     REQUEST_API bool UnsubscribeSA();
61     REQUEST_API int32_t GetNextSeq();
62 
63 private:
64     RequestManager() = default;
65     RequestManager(const RequestManager &) = delete;
66     RequestManager(RequestManager &&) = delete;
67     RequestManager &operator=(const RequestManager &) = delete;
68 };
69 
70 } // namespace OHOS::Request
71 #endif // OHOS_REQUEST_DOWNLOAD_MANAGER_H
72