Skip to content
Snippets Groups Projects
Verified Commit 8de44d43 authored by Sebastian's avatar Sebastian
Browse files

Get errors back from libnotify

parent 8880a857
No related branches found
No related tags found
1 merge request!231Error handling for libnotify
Pipeline #12044 passed
/*
* 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()
}
}
......@@ -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,
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment