1 /*
2 * Copyright (c) 2024 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 #include "cj_request_ffi.h"
17 #include <cinttypes>
18 #include "cj_request_common.h"
19 #include "cj_request_impl.h"
20 #include "cj_request_task.h"
21 #include "log.h"
22
23 namespace OHOS::CJSystemapi::Request {
24
25 extern "C" {
FfiOHOSRequestFreeTask(const char * taskId)26 void FfiOHOSRequestFreeTask(const char *taskId)
27 {
28 CJRequestImpl::FreeTask(taskId);
29 }
30
FfiOHOSRequestTaskProgressOn(char * event,const char * taskId,void * callback)31 RetError FfiOHOSRequestTaskProgressOn(char *event, const char *taskId, void *callback)
32 {
33 return CJRequestImpl::ProgressOn(event, taskId, callback);
34 }
35
FfiOHOSRequestTaskProgressOff(char * event,const char * taskId,void * callback)36 RetError FfiOHOSRequestTaskProgressOff(char *event, const char *taskId, void *callback)
37 {
38 return CJRequestImpl::ProgressOff(event, taskId, callback);
39 }
40
FfiOHOSRequestTaskStart(const char * taskId)41 RetError FfiOHOSRequestTaskStart(const char *taskId)
42 {
43 return CJRequestImpl::TaskStart(taskId);
44 }
45
FfiOHOSRequestTaskPause(const char * taskId)46 RetError FfiOHOSRequestTaskPause(const char *taskId)
47 {
48 return CJRequestImpl::TaskPause(taskId);
49 }
50
FfiOHOSRequestTaskResume(const char * taskId)51 RetError FfiOHOSRequestTaskResume(const char *taskId)
52 {
53 return CJRequestImpl::TaskResume(taskId);
54 }
55
FfiOHOSRequestTaskStop(const char * taskId)56 RetError FfiOHOSRequestTaskStop(const char *taskId)
57 {
58 return CJRequestImpl::TaskStop(taskId);
59 }
60
FfiOHOSRequestCreateTask(void * context,CConfig config)61 RetReqData FfiOHOSRequestCreateTask(void *context, CConfig config)
62 {
63 return CJRequestImpl::CreateTask((OHOS::AbilityRuntime::Context *)context, &config);
64 }
65
FfiOHOSRequestGetTask(void * context,const char * taskId,RequestNativeOptionCString token)66 RetTask FfiOHOSRequestGetTask(void *context, const char *taskId, RequestNativeOptionCString token)
67 {
68 return CJRequestImpl::GetTask((OHOS::AbilityRuntime::Context *)context, taskId, token);
69 }
70
FfiOHOSRequestRemoveTask(const char * taskId)71 RetError FfiOHOSRequestRemoveTask(const char *taskId)
72 {
73 return CJRequestImpl::RemoveTask(taskId);
74 }
75
FfiOHOSRequestShowTask(const char * taskId)76 RetTaskInfo FfiOHOSRequestShowTask(const char *taskId)
77 {
78 return CJRequestImpl::ShowTask(taskId);
79 }
80
FfiOHOSRequestTouchTask(const char * taskId,char * token)81 RetTaskInfo FfiOHOSRequestTouchTask(const char *taskId, char *token)
82 {
83 return CJRequestImpl::TouchTask(taskId, token);
84 }
85
FfiOHOSRequestSearchTask(CFilter filter)86 RetTaskArr FfiOHOSRequestSearchTask(CFilter filter)
87 {
88 return CJRequestImpl::SearchTask(filter);
89 }
90 }
91 } // namespace OHOS::CJSystemapi::Request