Scoop API

scoop:scoop.desktop:0.1.0

src/notification/values.scoop

Selected production source · src/notification/values.scoop

1package scoop.desktop.notification
3import scoop.desktop.checkDesktopText
4import scoop.collections.HashSet
6public struct NotificationId(val value: String): Equals<NotificationId>, Hash {
7 public override operator fun equals(other: NotificationId): Boolean = value == other.value
8 public override fun hash(): Long = value.hash()
9}
11public struct NotificationActionId(val value: String): Equals<NotificationActionId>, Hash {
12 public override operator fun equals(other: NotificationActionId): Boolean = value == other.value
13 public override fun hash(): Long = value.hash()
16public struct NotificationAction(val id: NotificationActionId, val title: String)
18public enum NotificationSound {
19 Default, Silent
22public class NotificationContent public constructor(
23 public val title: String,
24 public val body: String = "",
25 public val payload: String = "",
26 public val sound: NotificationSound = NotificationSound.Default,
27 public val actions: Array<NotificationAction> = []
28) {
29 init {
30 notificationLabel(title)
31 checkDesktopText(body)
32 checkDesktopText(payload)
33 val ids = HashSet<NotificationActionId>()
34 for (action in actions) {
35 notificationLabel(action.id.value)
36 notificationLabel(action.title)
37 if (!ids.add(action.id))
38 throw IllegalArgumentException(Some("notification action ids must be unique"))
39 }
40 }
43public enum NotificationAvailability {
44 Available, PermissionRequired, Disabled, NotConfigured, ServiceUnavailable
47public struct NotificationCapabilities(
48 val actions: Boolean,
49 val replace: Boolean,
50 val withdraw: Boolean,
51 val activation: Boolean,
52 val closedEvents: Boolean,
53 val coldActivation: Boolean
56public struct NotificationSettings(
57 val availability: NotificationAvailability,
58 val capabilities: NotificationCapabilities
61public enum NotificationErrorKind {
62 Unsupported, PermissionRequired, Disabled, NotConfigured, Unavailable, InvalidContent, NativeFailure
65public struct NotificationError(
66 val kind: NotificationErrorKind,
67 val nativeCode: Long? = None,
68 val message: String? = None
71public enum NotificationSubmission {
72 Submitted
75public enum NotificationWithdrawal {
76 Requested, NotFound
79public enum NotificationCloseReason {
80 Expired, Dismissed, Withdrawn, Unknown
83public enum NotificationEvent {
84 Activated(val id: NotificationId, val action: NotificationActionId?, val payload: String),
85 Closed(val id: NotificationId, val reason: NotificationCloseReason),
86 Failed(val id: NotificationId, val error: NotificationError)
89internal fun notificationLabel(value: String) {
90 if (value.byteLength == 0L)
91 throw IllegalArgumentException(Some("notification label is empty"))
92 checkDesktopText(value)