diff --git a/briar-desktop/src/main/kotlin/org/briarproject/briar/desktop/notification/linux/GErrorStruct.kt b/briar-desktop/src/main/kotlin/org/briarproject/briar/desktop/notification/linux/GErrorStruct.kt new file mode 100644 index 0000000000000000000000000000000000000000..95356744fad927f6fc1693638284627135a14903 --- /dev/null +++ b/briar-desktop/src/main/kotlin/org/briarproject/briar/desktop/notification/linux/GErrorStruct.kt @@ -0,0 +1,45 @@ +/* + * Briar Desktop + * Copyright (C) 2021-2022 The Briar Project + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see <https://www.gnu.org/licenses/>. + */ +package org.briarproject.briar.desktop.notification.linux + +import com.sun.jna.Pointer +import com.sun.jna.Structure +import com.sun.jna.Structure.FieldOrder + +@FieldOrder("domain", "code", "message") // NON-NLS +class GErrorStruct : Structure { + @JvmField + @Volatile + var domain /* GQuark */ = 0 + + @JvmField + @Volatile + var code = 0 + + @JvmField + @Volatile + var message: String? = null + + constructor() { + clear() + } + + constructor(ptr: Pointer?) : super(ptr) { + read() + } +} diff --git a/briar-desktop/src/main/kotlin/org/briarproject/briar/desktop/notification/linux/LibnotifyNotificationProvider.kt b/briar-desktop/src/main/kotlin/org/briarproject/briar/desktop/notification/linux/LibnotifyNotificationProvider.kt index 3a0c44f4e05e15d639ebceec29faac1bc2845fc0..5527fa230c1fdf76561a07600378b28bd518c9e8 100644 --- a/briar-desktop/src/main/kotlin/org/briarproject/briar/desktop/notification/linux/LibnotifyNotificationProvider.kt +++ b/briar-desktop/src/main/kotlin/org/briarproject/briar/desktop/notification/linux/LibnotifyNotificationProvider.kt @@ -20,6 +20,7 @@ package org.briarproject.briar.desktop.notification.linux import com.sun.jna.Library import com.sun.jna.Native import com.sun.jna.Pointer +import com.sun.jna.ptr.PointerByReference import mu.KotlinLogging import org.briarproject.briar.desktop.notification.VisualNotificationProvider import org.briarproject.briar.desktop.utils.InternationalizationUtils.i18n @@ -126,9 +127,11 @@ object LibnotifyNotificationProvider : VisualNotificationProvider { */ libNotify.notify_notification_set_category(notification, "im.received") - if (!libNotify.notify_notification_show(notification, null)) { - // todo: error handling + val errorPointer = PointerByReference() + if (!libNotify.notify_notification_show(notification, errorPointer)) { LOG.e { "error while sending notification via libnotify" } + val error = GErrorStruct(errorPointer.value) + LOG.e { "error code: ${error.code}, message: '${error.message}'" } } } @@ -210,7 +213,7 @@ object LibnotifyNotificationProvider : VisualNotificationProvider { * * @return true if successful. On error, this will return false and set [error]. */ - fun notify_notification_show(notification: Pointer, error: Pointer?): Boolean + fun notify_notification_show(notification: Pointer, error: PointerByReference?): Boolean /** * Sets a hint for [key] with value [value]. If [value] is null,