From 56fba9b72cc857a45b9bb1e3a3b787d82aa3b925 Mon Sep 17 00:00:00 2001 From: James Magahern Date: Wed, 30 Apr 2025 14:53:17 -0700 Subject: [PATCH] Use generated dbus interface rather than editing it every time --- .../conversation-list-model.vala | 2 +- src/meson.build | 2 +- src/service/interface/dbusservice.vala | 50 ++++++++++++ src/service/interface/generate.sh | 10 +++ .../xml/net.buzzert.kordophonecd.Server.xml | 79 +++++++++++++++++++ src/service/repository-service.vala | 18 ----- 6 files changed, 141 insertions(+), 20 deletions(-) create mode 100644 src/service/interface/dbusservice.vala create mode 100755 src/service/interface/generate.sh create mode 100644 src/service/interface/xml/net.buzzert.kordophonecd.Server.xml delete mode 100644 src/service/repository-service.vala diff --git a/src/conversation-list/conversation-list-model.vala b/src/conversation-list/conversation-list-model.vala index f16cbec..b2a513d 100644 --- a/src/conversation-list/conversation-list-model.vala +++ b/src/conversation-list/conversation-list-model.vala @@ -8,7 +8,7 @@ public class ConversationListModel : Object, ListModel } private SortedSet _conversations; - private RepositoryService repository; + private DBusService.Repository repository; private uint dbus_watch_id; public ConversationListModel() { diff --git a/src/meson.build b/src/meson.build index 3795d9c..70740ac 100644 --- a/src/meson.build +++ b/src/meson.build @@ -9,7 +9,7 @@ sources = [ 'application/kordophone-application.vala', 'application/main-window.vala', - 'service/repository-service.vala', + 'service/interface/dbusservice.vala', 'conversation-list/conversation-list-view.vala', 'conversation-list/conversation-list-model.vala', diff --git a/src/service/interface/dbusservice.vala b/src/service/interface/dbusservice.vala new file mode 100644 index 0000000..0dbd5af --- /dev/null +++ b/src/service/interface/dbusservice.vala @@ -0,0 +1,50 @@ +/* Generated by vala-dbus-binding-tool 1.0-aa2fb. Do not modify! */ +/* Generated with: vala-dbus-binding-tool --no-synced --strip-namespace=net --strip-namespace=buzzert --rename-namespace=kordophone:DBusService --api-path=xml/ */ +using GLib; + +namespace DBusService { + + [DBus (name = "net.buzzert.kordophone.Settings", timeout = 120000)] + public interface Settings : GLib.Object { + + [DBus (name = "ServerURL")] + public abstract string server_u_r_l { owned get; set; } + + [DBus (name = "Username")] + public abstract string username { owned get; set; } + + [DBus (name = "CredentialItem")] + public abstract GLib.ObjectPath credential_item { owned get; set; } + + [DBus (name = "SetServer")] + public abstract void set_server(string url, string user) throws DBusError, IOError; + + [DBus (name = "ConfigChanged")] + public signal void config_changed(); + } + + [DBus (name = "net.buzzert.kordophone.Repository", timeout = 120000)] + public interface Repository : GLib.Object { + + [DBus (name = "GetVersion")] + public abstract string get_version() throws DBusError, IOError; + + [DBus (name = "GetConversations")] + public abstract GLib.HashTable[] get_conversations() throws DBusError, IOError; + + [DBus (name = "SyncAllConversations")] + public abstract void sync_all_conversations() throws DBusError, IOError; + + [DBus (name = "SyncConversation")] + public abstract void sync_conversation(string conversation_id) throws DBusError, IOError; + + [DBus (name = "ConversationsUpdated")] + public signal void conversations_updated(); + + [DBus (name = "GetMessages")] + public abstract GLib.HashTable[] get_messages(string conversation_id, string last_message_id) throws DBusError, IOError; + + [DBus (name = "MessagesUpdated")] + public signal void messages_updated(string conversation_id); + } +} diff --git a/src/service/interface/generate.sh b/src/service/interface/generate.sh new file mode 100755 index 0000000..72bed52 --- /dev/null +++ b/src/service/interface/generate.sh @@ -0,0 +1,10 @@ +#!/bin/sh + +if ! command -v vala-dbus-binding-tool >/dev/null 2>&1; then + echo "Error: vala-dbus-binding-tool not found. Please install it first." + echo "https://github.com/freesmartphone/vala-dbus-binding-tool" + exit 1 +fi + +vala-dbus-binding-tool --no-synced --strip-namespace=net --strip-namespace=buzzert --rename-namespace=kordophone:DBusService --api-path=xml/ + diff --git a/src/service/interface/xml/net.buzzert.kordophonecd.Server.xml b/src/service/interface/xml/net.buzzert.kordophonecd.Server.xml new file mode 100644 index 0000000..bbe5263 --- /dev/null +++ b/src/service/interface/xml/net.buzzert.kordophonecd.Server.xml @@ -0,0 +1,79 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/service/repository-service.vala b/src/service/repository-service.vala deleted file mode 100644 index 44d90b1..0000000 --- a/src/service/repository-service.vala +++ /dev/null @@ -1,18 +0,0 @@ -using GLib; - -[DBus (name = "net.buzzert.kordophone.Repository")] -public interface RepositoryService : Object { - public abstract string get_version() throws DBusError, IOError; - - [DBus (signature = "aa{sv}")] - public abstract Variant get_conversations() throws DBusError, IOError; - - public abstract void sync_all_conversations() throws DBusError, IOError; - public abstract void sync_conversation(string conversation_id) throws DBusError, IOError; - - [DBus (signature = "aa{sv}")] - public abstract Variant get_messages(string conversation_id, string last_message_id) throws DBusError, IOError; - - public signal void conversations_updated(); - public signal void messages_updated(string conversation_id); -} \ No newline at end of file