18e9cee63Sopenharmony_ci/*
28e9cee63Sopenharmony_ci * Copyright (C) 2023 Huawei Device Co., Ltd.
38e9cee63Sopenharmony_ci * Licensed under the Apache License, Version 2.0 (the "License");
48e9cee63Sopenharmony_ci * you may not use this file except in compliance with the License.
58e9cee63Sopenharmony_ci * You may obtain a copy of the License at
68e9cee63Sopenharmony_ci *
78e9cee63Sopenharmony_ci *     http://www.apache.org/licenses/LICENSE-2.0
88e9cee63Sopenharmony_ci *
98e9cee63Sopenharmony_ci * Unless required by applicable law or agreed to in writing, software
108e9cee63Sopenharmony_ci * distributed under the License is distributed on an "AS IS" BASIS,
118e9cee63Sopenharmony_ci * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
128e9cee63Sopenharmony_ci * See the License for the specific language governing permissions and
138e9cee63Sopenharmony_ci * limitations under the License.
148e9cee63Sopenharmony_ci */
158e9cee63Sopenharmony_ci
168e9cee63Sopenharmony_ci#ifndef OHOS_REQUEST_DOWNLOAD_MANAGER_H
178e9cee63Sopenharmony_ci#define OHOS_REQUEST_DOWNLOAD_MANAGER_H
188e9cee63Sopenharmony_ci
198e9cee63Sopenharmony_ci#include "i_notify_data_listener.h"
208e9cee63Sopenharmony_ci#include "i_response_listener.h"
218e9cee63Sopenharmony_ci#include "js_common.h"
228e9cee63Sopenharmony_ci#include "visibility.h"
238e9cee63Sopenharmony_ci
248e9cee63Sopenharmony_cinamespace OHOS::Request {
258e9cee63Sopenharmony_ci
268e9cee63Sopenharmony_ciclass RequestManager {
278e9cee63Sopenharmony_cipublic:
288e9cee63Sopenharmony_ci    REQUEST_API static const std::unique_ptr<RequestManager> &GetInstance();
298e9cee63Sopenharmony_ci    REQUEST_API int32_t Create(const Config &config, int32_t seq, std::string &tid);
308e9cee63Sopenharmony_ci    REQUEST_API int32_t GetTask(const std::string &tid, const std::string &token, Config &config);
318e9cee63Sopenharmony_ci    REQUEST_API int32_t Start(const std::string &tid);
328e9cee63Sopenharmony_ci    REQUEST_API int32_t Stop(const std::string &tid);
338e9cee63Sopenharmony_ci    REQUEST_API int32_t Query(const std::string &tid, TaskInfo &info);
348e9cee63Sopenharmony_ci    REQUEST_API int32_t Touch(const std::string &tid, const std::string &token, TaskInfo &info);
358e9cee63Sopenharmony_ci    REQUEST_API int32_t Search(const Filter &filter, std::vector<std::string> &tids);
368e9cee63Sopenharmony_ci    REQUEST_API int32_t Show(const std::string &tid, TaskInfo &info);
378e9cee63Sopenharmony_ci    REQUEST_API int32_t Pause(const std::string &tid, Version version);
388e9cee63Sopenharmony_ci    REQUEST_API int32_t QueryMimeType(const std::string &tid, std::string &mimeType);
398e9cee63Sopenharmony_ci    REQUEST_API int32_t Remove(const std::string &tid, Version version);
408e9cee63Sopenharmony_ci    REQUEST_API int32_t Resume(const std::string &tid);
418e9cee63Sopenharmony_ci
428e9cee63Sopenharmony_ci    REQUEST_API int32_t Subscribe(const std::string &taskId);
438e9cee63Sopenharmony_ci    REQUEST_API int32_t Unsubscribe(const std::string &taskId);
448e9cee63Sopenharmony_ci
458e9cee63Sopenharmony_ci    REQUEST_API int32_t AddListener(
468e9cee63Sopenharmony_ci        const std::string &taskId, const SubscribeType &type, const std::shared_ptr<IResponseListener> &listener);
478e9cee63Sopenharmony_ci    REQUEST_API int32_t RemoveListener(
488e9cee63Sopenharmony_ci        const std::string &taskId, const SubscribeType &type, const std::shared_ptr<IResponseListener> &listener);
498e9cee63Sopenharmony_ci    REQUEST_API int32_t AddListener(
508e9cee63Sopenharmony_ci        const std::string &taskId, const SubscribeType &type, const std::shared_ptr<INotifyDataListener> &listener);
518e9cee63Sopenharmony_ci    REQUEST_API int32_t RemoveListener(
528e9cee63Sopenharmony_ci        const std::string &taskId, const SubscribeType &type, const std::shared_ptr<INotifyDataListener> &listener);
538e9cee63Sopenharmony_ci    REQUEST_API void RemoveAllListeners(const std::string &taskId);
548e9cee63Sopenharmony_ci
558e9cee63Sopenharmony_ci    REQUEST_API void RestoreListener(void (*callback)());
568e9cee63Sopenharmony_ci    REQUEST_API bool LoadRequestServer();
578e9cee63Sopenharmony_ci    REQUEST_API bool IsSaReady();
588e9cee63Sopenharmony_ci    REQUEST_API void ReopenChannel();
598e9cee63Sopenharmony_ci    REQUEST_API bool SubscribeSA();
608e9cee63Sopenharmony_ci    REQUEST_API bool UnsubscribeSA();
618e9cee63Sopenharmony_ci    REQUEST_API int32_t GetNextSeq();
628e9cee63Sopenharmony_ci
638e9cee63Sopenharmony_ciprivate:
648e9cee63Sopenharmony_ci    RequestManager() = default;
658e9cee63Sopenharmony_ci    RequestManager(const RequestManager &) = delete;
668e9cee63Sopenharmony_ci    RequestManager(RequestManager &&) = delete;
678e9cee63Sopenharmony_ci    RequestManager &operator=(const RequestManager &) = delete;
688e9cee63Sopenharmony_ci};
698e9cee63Sopenharmony_ci
708e9cee63Sopenharmony_ci} // namespace OHOS::Request
718e9cee63Sopenharmony_ci#endif // OHOS_REQUEST_DOWNLOAD_MANAGER_H
72