Coder Social home page Coder Social logo

frandieguez / xdg-desktop-portal Goto Github PK

View Code? Open in Web Editor NEW

This project forked from flatpak/xdg-desktop-portal

0.0 2.0 0.0 2.1 MB

Desktop integration portal

License: GNU Lesser General Public License v2.1

Makefile 0.60% Shell 1.58% M4 0.57% C 89.40% C++ 1.09% Assembly 0.22% Meson 1.62% Python 4.93%

xdg-desktop-portal's Introduction

xdg-desktop-portal

A portal frontend service for Flatpak and possibly other desktop containment frameworks.

xdg-desktop-portal works by exposing a series of D-Bus interfaces known as portals under a well-known name (org.freedesktop.portal.Desktop) and object path (/org/freedesktop/portal/desktop).

The portal interfaces include APIs for file access, opening URIs, printing and others.

Documentation for the available D-Bus interfaces can be found here.

Building xdg-desktop-portal

xdg-desktop-portal depends on GLib and Flatpak. To build the documentation, you will need xmlto and the docbook stylesheets.

Using portals

Flatpak grants sandboxed applications talk access to names in the org.freedesktop.portal.* prefix. One possible way to use the portal APIs is thus just to make D-Bus calls. For many of the portals, toolkits (e.g. GTK+) are expected to support portals transparently if you use suitable high-level APIs.

To implement most portals, xdg-desktop-portal relies on a backend that provides implementations of the org.freedesktop.impl.portal.* interfaces. Different backends are available see:

Design considerations

There are several reasons for the frontend/backend separation of the portal code:

  • We want to have native portal dialogs that match the session desktop (i.e. GTK+ dialogs for GNOME, Qt dialogs for KDE)
  • One of the limitations of the D-Bus proxying in flatpak is that allowing a sandboxed app to talk to a name implicitly also allows it to talk to any other name owned by the same unique name. Therefore, sandbox-facing D-Bus apis should generally be hosted on a dedicated bus connection. For portals, the frontend takes care of this for us.
  • The frontend can handle all the interaction with portal infrastructure, such as the permission store and the document store, freeing the backends to focus on just providing a user interface.
  • The frontend can also handle argument validation, and be strict about only letting valid requests through to the backend.

The portal apis are all following the pattern of an initial method call, whose response returns an object handle for an org.freedesktop.portal.Request object that represents the portal interaction. The end of the interaction is done via a Response signal that gets emitted on that object. This pattern was chosen over a simple method call with return, since portal apis are expected to show dialogs and interact with the user, which may well take longer than the maximum method call timeout of D-Bus. Another advantage is that the caller can cancel an ongoing interaction by calling the Cancel method on the request object.

One consideration for deciding the shape of portal APIs is that we want them to 'hide' behind existing library APIs where possible, to make it as easy as possible to have apps use them transparently. For example, the OpenFile portal is working well as a backend for the GtkFileChooserNative API.

When it comes to files, we need to be careful to not let portal apis subvert the limited filesystem view that apps have in their sandbox. Therefore, files should only be passed into portal APIs in one of two forms:

  • As a document ID referring to a file that has been exported in the document portal
  • As an open fd. The portal can work its way back to a file path from the fd, and passing an fd proves that the app inside the sandbox has access to the file to open it.

When it comes to processes, passing pids around is not useful in a sandboxed world where apps are likely in their own pid namespace. And passing pids from inside the sandbox is problematic, since the app can just lie.

xdg-desktop-portal's People

Contributors

matthiasclasen avatar alexlarsson avatar smcv avatar whot avatar mwleeds avatar georgesstavracas avatar hadess avatar jadahl avatar 3v1n0 avatar gostsdmitry avatar tingping avatar grulja avatar piotrdrag avatar mariospr avatar aleixpol avatar gicmo avatar jhenstridge avatar asciiwolf avatar bilelmoussaoui avatar arrowd avatar felipeborges avatar cho2 avatar robert-ancell avatar wtay avatar yurchor avatar cosimoc avatar welaq avatar fmuellner avatar hfiguiere avatar jtojnar avatar

Watchers

James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.