• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // Copyright (C) 2023 Huawei Device Co., Ltd.
2 // Licensed under the Apache License, Version 2.0 (the "License");
3 // you may not use this file except in compliance with the License.
4 // You may obtain a copy of the License at
5 //
6 //     http://www.apache.org/licenses/LICENSE-2.0
7 //
8 // Unless required by applicable law or agreed to in writing, software
9 // distributed under the License is distributed on an "AS IS" BASIS,
10 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11 // See the License for the specific language governing permissions and
12 // limitations under the License.
13 
14 mod database;
15 mod notification_config;
16 mod notify_flow;
17 mod publish;
18 mod task_handle;
19 mod typology;
20 
21 pub(crate) use notification_config::NotificationConfig;
22 pub use publish::NotificationDispatcher;
23 pub(crate) use publish::NOTIFY_PROGRESS_INTERVAL;
24 pub(crate) use task_handle::subscribe_notification_bar;
25 use task_handle::TaskManagerWrapper;
26 
27 #[cxx::bridge(namespace = "OHOS::Request")]
28 mod ffi {
29     #[derive(Eq, PartialEq, Debug)]
30     pub(crate) struct NotifyContent {
31         title: String,
32         text: String,
33         request_id: u32,
34         uid: u32,
35         live_view: bool,
36         progress_circle: ProgressCircle,
37         x_mark: bool,
38     }
39 
40     #[derive(Eq, PartialEq, Debug)]
41     struct ProgressCircle {
42         open: bool,
43         current: u64,
44         total: u64,
45     }
46 
47     extern "Rust" {
48         type TaskManagerWrapper;
pause_task(self: &TaskManagerWrapper, task_id: u32) -> bool49         fn pause_task(self: &TaskManagerWrapper, task_id: u32) -> bool;
resume_task(self: &TaskManagerWrapper, task_id: u32) -> bool50         fn resume_task(self: &TaskManagerWrapper, task_id: u32) -> bool;
stop_task(self: &TaskManagerWrapper, task_id: u32) -> bool51         fn stop_task(self: &TaskManagerWrapper, task_id: u32) -> bool;
52     }
53 
54     unsafe extern "C++" {
55         include!("notification_bar.h");
56 
CancelNotification(notificationId: u32) -> i3257         fn CancelNotification(notificationId: u32) -> i32;
GetSystemResourceString(name: &str) -> String58         fn GetSystemResourceString(name: &str) -> String;
PublishNotification(content: &NotifyContent) -> i3259         fn PublishNotification(content: &NotifyContent) -> i32;
SubscribeNotification(task_manager: Box<TaskManagerWrapper>)60         fn SubscribeNotification(task_manager: Box<TaskManagerWrapper>);
61     }
62 }
63