Scoop API

scoop:scoop.desktop:0.1.0

src/notification/native.scoop

Selected production source · src/notification/native.scoop

1package scoop.desktop.notification
3import scoop.desktop.DesktopNativeResult
5@CLayout
6internal struct NotificationNativeData(
7 val kind: Int,
8 val detail: Int,
9 val request: Long,
10 val status: Int,
11 val capabilities: Int,
12 val code: Long
15@CLayout
16internal struct NotificationNativeText(val bytes: Ptr<UInt8>?, val length: Long)
18internal struct NotificationReply(
19 val data: NotificationNativeData,
20 val id: String,
21 val action: String,
22 val payload: String,
23 val message: String
26@Extern(name = "scoop_notification_create")
27internal fun notificationCreate(id: Ptr<UInt8>, length: Long): DesktopNativeResult
29@Extern(name = "scoop_notification_attach")
30internal fun notificationAttach(
31 pointer: Ptr<Unit>,
32 callback: FunPtr<(Ptr<Unit>, Int) -> Int>,
33 context: Ptr<Unit>
34): Long
36@Extern(name = "scoop_notification_destroy")
37internal fun notificationDestroy(pointer: Ptr<Unit>)
39@Extern(name = "scoop_notification_settings")
40internal fun notificationSettings(pointer: Ptr<Unit>, request: Long, permission: Int): Long
42@Extern(name = "scoop_notification_post")
43internal fun notificationPost(pointer: Ptr<Unit>, request: Long, content: Ptr<Unit>): Long
45@Extern(name = "scoop_notification_withdraw")
46internal fun notificationWithdraw(
47 pointer: Ptr<Unit>,
48 request: Long,
49 id: Ptr<UInt8>,
50 length: Long
51): Long
53@Extern(name = "scoop_notification_next_event")
54internal fun notificationNextEvent(pointer: Ptr<Unit>): Ptr<Unit>?
56@Extern(name = "scoop_notification_event_data")
57internal fun notificationEventData(event: Ptr<Unit>): NotificationNativeData
59@Extern(name = "scoop_notification_event_text")
60internal fun notificationEventText(event: Ptr<Unit>, field: Int): NotificationNativeText
62@Extern(name = "scoop_notification_event_destroy")
63internal fun notificationEventDestroy(event: Ptr<Unit>)
65@Extern(name = "scoop_notification_content_create")
66internal fun notificationContentCreate(silent: Int): DesktopNativeResult
68@Extern(name = "scoop_notification_content_text")
69internal fun notificationContentText(
70 content: Ptr<Unit>,
71 field: Int,
72 text: Ptr<UInt8>,
73 length: Long
74): Long
76@Extern(name = "scoop_notification_content_action")
77internal fun notificationContentAction(
78 content: Ptr<Unit>,
79 id: Ptr<UInt8>,
80 idLength: Long,
81 title: Ptr<UInt8>,
82 titleLength: Long
83): Long
85@Extern(name = "scoop_notification_content_destroy")
86internal fun notificationContentDestroy(content: Ptr<Unit>)
88internal fun notificationText(event: Ptr<Unit>, field: Int): String {
89 @Unsafe
90 {
91 val value = notificationEventText(event, field)
92 return when (value.bytes) {
93 case Some(val bytes) -> String.fromUtf8(bytes, value.length)
94 case None -> ""
95 }
96 }