Private
Public Access
1
0

Use generated dbus interface rather than editing it every time

This commit is contained in:
2025-04-30 14:53:17 -07:00
parent 907a69385d
commit 56fba9b72c
6 changed files with 141 additions and 20 deletions

View File

@@ -8,7 +8,7 @@ public class ConversationListModel : Object, ListModel
} }
private SortedSet<Conversation> _conversations; private SortedSet<Conversation> _conversations;
private RepositoryService repository; private DBusService.Repository repository;
private uint dbus_watch_id; private uint dbus_watch_id;
public ConversationListModel() { public ConversationListModel() {

View File

@@ -9,7 +9,7 @@ sources = [
'application/kordophone-application.vala', 'application/kordophone-application.vala',
'application/main-window.vala', 'application/main-window.vala',
'service/repository-service.vala', 'service/interface/dbusservice.vala',
'conversation-list/conversation-list-view.vala', 'conversation-list/conversation-list-view.vala',
'conversation-list/conversation-list-model.vala', 'conversation-list/conversation-list-model.vala',

View File

@@ -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<string, GLib.Variant>[] 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<string, GLib.Variant>[] get_messages(string conversation_id, string last_message_id) throws DBusError, IOError;
[DBus (name = "MessagesUpdated")]
public signal void messages_updated(string conversation_id);
}
}

View File

@@ -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/

View File

@@ -0,0 +1,79 @@
<!DOCTYPE node PUBLIC "-//freedesktop//DTD D-BUS Object Introspection 1.0//EN"
"http://www.freedesktop.org/standards/dbus/1.0/introspect.dtd">
<node>
<interface name="net.buzzert.kordophone.Repository">
<method name="GetVersion">
<arg type="s" name="version" direction="out" />
<annotation name="org.freedesktop.DBus.DocString"
value="Returns the version of the client daemon."/>
</method>
<!-- Conversations -->
<method name="GetConversations">
<arg type="aa{sv}" direction="out" name="conversations">
<annotation name="org.freedesktop.DBus.DocString"
value="Array of dictionaries. Each dictionary has keys:
'id' (string): Unique identifier
'display_name' (string): Display name
'last_message_preview' (string): Preview text
'is_unread' (boolean): Unread status
'date' (int64): Date of last message
'participants' (array of strings): List of participants
'unread_count' (int32): Number of unread messages"/>
</arg>
</method>
<method name="SyncAllConversations">
<annotation name="org.freedesktop.DBus.DocString"
value="Initiates a background sync of all conversations with the server."/>
</method>
<method name="SyncConversation">
<arg type="s" name="conversation_id" direction="in"/>
<annotation name="org.freedesktop.DBus.DocString"
value="Initiates a background sync of a single conversation with the server."/>
</method>
<signal name="ConversationsUpdated">
<annotation name="org.freedesktop.DBus.DocString"
value="Emitted when the list of conversations is updated."/>
</signal>
<!-- Messages -->
<method name="GetMessages">
<arg type="s" name="conversation_id" direction="in"/>
<arg type="s" name="last_message_id" direction="in"/>
<arg type="aa{sv}" direction="out" name="messages"/>
</method>
<signal name="MessagesUpdated">
<arg type="s" name="conversation_id" direction="in"/>
<annotation name="org.freedesktop.DBus.DocString"
value="Emitted when the list of messages is updated."/>
</signal>
</interface>
<interface name="net.buzzert.kordophone.Settings">
<!-- editable properties -->
<property name="ServerURL" type="s" access="readwrite"/>
<property name="Username" type="s" access="readwrite"/>
<!-- Secret-Service handle (object path) -->
<property name="CredentialItem" type="o" access="readwrite">
<annotation name="org.freedesktop.DBus.Property.EmitsChangedSignal"
value="true"/>
</property>
<!-- helpers for atomic updates -->
<method name="SetServer">
<arg name="url" type="s" direction="in"/>
<arg name="user" type="s" direction="in"/>
</method>
<!-- emitted when anything changes -->
<signal name="ConfigChanged"/>
</interface>
</node>

View File

@@ -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);
}