summaryrefslogtreecommitdiff
path: root/src/Portal.vala
diff options
context:
space:
mode:
authorJörg Frings-Fürst <debian@jff.email>2023-04-10 15:07:27 +0200
committerJörg Frings-Fürst <debian@jff.email>2023-04-10 15:07:27 +0200
commit2f7fd6adc286008a8c1f3b6cb7b63f3540d0e2e0 (patch)
treeeac0bbdb792ced73207004b9c71c699dfc302ce7 /src/Portal.vala
parent10fbc2942e6833ed36bd4ea663a33f52f3a35d03 (diff)
parentbb9797c14470641b082ebf635e2ae3cfd5f27a3b (diff)
Update upstream source from tag 'upstream/0.30.18'
Update to upstream version '0.30.18' with Debian dir d1ea682c56714cd4c2a932161997cb833722fcb9
Diffstat (limited to 'src/Portal.vala')
-rw-r--r--src/Portal.vala71
1 files changed, 0 insertions, 71 deletions
diff --git a/src/Portal.vala b/src/Portal.vala
deleted file mode 100644
index c2e8e1e..0000000
--- a/src/Portal.vala
+++ /dev/null
@@ -1,71 +0,0 @@
-[DBus (name="org.freedesktop.portal.Email")]
-private interface PortalEmail : DBusProxy {
- [DBus (name = "version")]
- public abstract uint version { get; }
-}
-
-public class Portal : GLib.Object {
- private static Portal portal;
- public static Portal get_instance () {
- if (portal == null){
- portal = new Portal ();
- }
- return portal;
- }
-
- private const string BUS_NAME = "org.freedesktop.portal.Desktop";
- private const string OBJECT_PATH = "/org/freedesktop/portal/desktop";
-
- private GLib.DBusConnection bus;
-
- public async Variant compose_email (HashTable<string, Variant> options,
- UnixFDList attachments) throws Error{
- if (bus == null){
- bus = yield Bus.get(BusType.SESSION);
- }
-
- options.insert ("handle_token", Portal.generate_handle());
-
- var options_builder = new VariantBuilder (VariantType.VARDICT);
- options.foreach ((key, val) => {
- options_builder.add ("{sv}", key, val);
- });
-
- PortalEmail? email = yield bus.get_proxy(BUS_NAME, OBJECT_PATH);
-
- var response = email.call_with_unix_fd_list_sync (
- "ComposeEmail",
- new Variant ("(sa{sv})", yield Portal.get_parent_window(), options_builder),
- DBusCallFlags.NONE,
- -1,
- attachments
- );
- return response;
- }
-
- private static string generate_handle () {
- return "%s_%i".printf (
- GLib.Application.get_default ().application_id.replace (".", "_").replace("-", "_"),
- Random.int_range (0, int32.MAX)
- );
- }
-
- private static async string get_parent_window () {
- var window = AppWindow.get_instance().get_window ();
-
- if (window is Gdk.Wayland.Window) {
- var handle = "wayland:";
- ((Gdk.Wayland.Window) window).export_handle ((w, h) => {
- handle += h;
- get_parent_window.callback ();
- });
- yield;
- return handle;
- } else if (window is Gdk.X11.Window) {
- return "x11:%x".printf ((uint) ((Gdk.X11.Window) window).get_xid ());
- } else {
- warning ("Could not get parent window");
- return "";
- }
- }
-}