mirror of
https://github.com/edu4rdshl/Strata.git
synced 2026-07-18 07:34:45 +00:00
The D-Bus interface previously returned content as a base64-encoded string (type 's'), requiring the daemon to encode and GJS to decode on every paste. D-Bus natively supports byte arrays (type 'ay'), eliminating both encode and decode steps entirely. Changes: - dbus_service.rs: return (String, Vec<u8>); drop base64 calls - dbus.js: content_b64 arg changed from type 's' to type 'ay' - panel.js: remove GLib.base64_decode(); pass ay bytes directly - Cargo.toml/Cargo.lock: remove base64 dependency (no longer used) For a 1 MB text paste this avoids allocating a 1.33 MB intermediate string and decoding it on the compositor main thread. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
79 lines
2.2 KiB
JavaScript
79 lines
2.2 KiB
JavaScript
/**
|
|
* dbus.js - Async D-Bus proxy for the Strata daemon.
|
|
*
|
|
* Uses Gio.DBusProxy.makeProxyWrapper to generate a typed proxy class.
|
|
* All method calls should use the *Async variants (return Promises) to avoid
|
|
* blocking the GNOME Shell compositor main loop.
|
|
*/
|
|
|
|
import Gio from 'gi://Gio';
|
|
|
|
const STRATA_IFACE_XML = `
|
|
<node>
|
|
<interface name="org.gnome.Strata.Manager">
|
|
|
|
<method name="GetHistory">
|
|
<arg type="u" direction="in" name="offset"/>
|
|
<arg type="u" direction="in" name="limit"/>
|
|
<arg type="s" direction="out" name="json"/>
|
|
</method>
|
|
|
|
<method name="SearchHistory">
|
|
<arg type="s" direction="in" name="query"/>
|
|
<arg type="u" direction="in" name="limit"/>
|
|
<arg type="s" direction="out" name="json"/>
|
|
</method>
|
|
|
|
<method name="GetThumbnail">
|
|
<arg type="s" direction="in" name="id"/>
|
|
<arg type="ay" direction="out" name="png_bytes"/>
|
|
</method>
|
|
|
|
<method name="GetItemContent">
|
|
<arg type="s" direction="in" name="id"/>
|
|
<arg type="s" direction="out" name="mime_type"/>
|
|
<arg type="ay" direction="out" name="content"/>
|
|
</method>
|
|
|
|
<method name="SetClipboard">
|
|
<arg type="s" direction="in" name="id"/>
|
|
</method>
|
|
|
|
<method name="DeleteItem">
|
|
<arg type="s" direction="in" name="id"/>
|
|
</method>
|
|
|
|
<method name="ClearHistory"/>
|
|
|
|
<method name="Shutdown"/>
|
|
|
|
<method name="SetConfig">
|
|
<arg type="u" direction="in" name="max_history"/>
|
|
<arg type="u" direction="in" name="max_text_bytes"/>
|
|
<arg type="u" direction="in" name="max_image_bytes"/>
|
|
</method>
|
|
|
|
<method name="SubmitItem">
|
|
<arg type="s" direction="in" name="mime_type"/>
|
|
<arg type="ay" direction="in" name="content"/>
|
|
</method>
|
|
|
|
<signal name="ItemAdded">
|
|
<arg type="s" name="id"/>
|
|
<arg type="s" name="mime_type"/>
|
|
<arg type="s" name="preview"/>
|
|
</signal>
|
|
|
|
<signal name="ItemDeleted">
|
|
<arg type="s" name="id"/>
|
|
</signal>
|
|
|
|
<signal name="HistoryCleared"/>
|
|
|
|
</interface>
|
|
</node>`;
|
|
|
|
export const StrataProxy = Gio.DBusProxy.makeProxyWrapper(STRATA_IFACE_XML);
|
|
|
|
export const BUS_NAME = 'org.gnome.Strata';
|
|
export const OBJECT_PATH = '/org/gnome/Strata';
|