scoop:scoop.desktop:0.1.0
src/notification/values.scoop
Selected production source · src/notification/values.scoop
1
package scoop.desktop.notification3
import scoop.desktop.checkDesktopText4
import scoop.collections.HashSet6
public struct NotificationId(val value: String): Equals<NotificationId>, Hash {7
public override operator fun equals(other: NotificationId): Boolean = value == other.value8
public override fun hash(): Long = value.hash()9
}11
public struct NotificationActionId(val value: String): Equals<NotificationActionId>, Hash {12
public override operator fun equals(other: NotificationActionId): Boolean = value == other.value13
public override fun hash(): Long = value.hash()14
}16
public struct NotificationAction(val id: NotificationActionId, val title: String)18
public enum NotificationSound {19
Default, Silent20
}22
public 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
}41
}43
public enum NotificationAvailability {44
Available, PermissionRequired, Disabled, NotConfigured, ServiceUnavailable45
}47
public 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: Boolean54
)56
public struct NotificationSettings(57
val availability: NotificationAvailability,58
val capabilities: NotificationCapabilities59
)61
public enum NotificationErrorKind {62
Unsupported, PermissionRequired, Disabled, NotConfigured, Unavailable, InvalidContent, NativeFailure63
}65
public struct NotificationError(66
val kind: NotificationErrorKind,67
val nativeCode: Long? = None,68
val message: String? = None69
)71
public enum NotificationSubmission {72
Submitted73
}75
public enum NotificationWithdrawal {76
Requested, NotFound77
}79
public enum NotificationCloseReason {80
Expired, Dismissed, Withdrawn, Unknown81
}83
public 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)87
}89
internal fun notificationLabel(value: String) {90
if (value.byteLength == 0L)91
throw IllegalArgumentException(Some("notification label is empty"))92
checkDesktopText(value)93
}