This is an automated email from the git hooks/post-receive script.
git pushed a commit to branch master
in repository xdg-desktop-portal-efl.
View the commit online.
commit f32710871ed0a40478f2a953d8566d5d2edef400
Author: Carsten Haitzler (Rasterman) <[email protected]>
AuthorDate: Thu Nov 26 15:14:58 2026 +0000
clean up tree
---
README.md | 33 ++--
meson.build | 2 +-
src/bin/frontend.h | 3 -
src/bin/frontend_filechooser.c | 75 --------
src/bin/frontend_request.c | 60 ------
src/bin/meson.build | 13 +-
src/bin/portal.h | 3 -
src/bin/service_filechooser.c | 131 ++++++++++++-
src/bin/service_settings.c | 12 +-
src/bin/{app_paths.c => shared_app_paths.c} | 0
src/bin/{service_choices.c => shared_choices.c} | 0
...ce_dialog_process.c => shared_dialog_process.c} | 0
src/bin/{service_options.c => shared_options.c} | 0
src/bin/{service_request.c => shared_request.c} | 0
src/{bin => lib/access}/dialog_access.c | 0
src/lib/access/meson.build | 5 +
src/{bin => lib/filechooser}/dialog_filechooser.c | 0
src/lib/filechooser/meson.build | 5 +
src/lib/meson.build | 9 +
src/{bin => lib/shared}/choices.h | 0
src/{bin => lib/shared}/dialog.c | 0
src/{bin => lib/shared}/dialog.h | 0
src/{bin => lib/shared}/dialog_choices.c | 0
src/{bin => lib/shared}/dialog_model.c | 0
src/lib/shared/dialog_ui.h | 19 ++
src/{bin => lib/shared}/dialog_util_win.c | 0
src/{bin => lib/shared}/dialog_util_win.h | 0
src/{bin => lib/shared}/dialog_wire.c | 0
src/lib/shared/meson.build | 3 +
src/lib/xdg-desktop-portal-efl/dialogs/meson.build | 18 +-
src/tests/dialog_wire_test.c | 202 +++++++++++++++++++++
.../lib/xdg-desktop-portal-efl/dialogs/meson.build | 6 +-
src/tests/meson.build | 12 +-
supported.txt | 19 ++
34 files changed, 444 insertions(+), 186 deletions(-)
diff --git a/README.md b/README.md
index 84b6373..51cae68 100644
--- a/README.md
+++ b/README.md
@@ -4,8 +4,9 @@
An initial EFL desktop portal backend written in C. A parent process uses Eldbus
for the D-Bus services and executes a separate child process for each Elementary
dialog. The layout follows the small
-EFL applications Rage and Terminology: top-level Meson configuration, application
-modules in `src/bin`, installed resources in `data`, and tests in the same tree.
+EFL applications Rage and Terminology: top-level Meson configuration, service
+modules in `src/bin`, dialog helpers and shared code in `src/lib`, installed
+resources in `data`, and tests in the same tree.
The executable always provides the backend name
`org.freedesktop.impl.portal.desktop.efl` at
@@ -287,21 +288,27 @@ activation environment needs the display environment for Elementary dialogs.
- `src/bin/frontend_filechooser.c`, `frontend_settings.c`,
`frontend_request.c`: fallback frontend methods, public request handles,
and Response signal declarations.
-- `src/bin/app_paths.c`: Eina prefix setup and cleanup for installed helper discovery.
-- `src/bin/service_request.c`: parent-side asynchronous request ownership and cancellation.
-- `src/bin/service_dialog_process.c`: child execution, asynchronous pipe I/O, result
+- `src/bin/shared_app_paths.c`: Eina prefix setup and cleanup for installed helper discovery.
+- `src/bin/shared_request.c`: parent-side asynchronous request ownership and cancellation.
+- `src/bin/shared_dialog_process.c`: child execution, asynchronous pipe I/O, result
handling, termination, and reaping.
-- `src/bin/dialog_wire.c`, `dialog_model.c`, `dialog.h`: framed Eet protocol,
+- `src/lib/shared/dialog_wire.c`, `dialog_model.c`, `dialog.h`: framed Eet protocol,
data validation, and shared value model.
-- `src/bin/dialog.c`, `dialog_ui.h`: shared child lifetime, result writing, and common widgets.
-- `src/bin/dialog_util_win.c`, `dialog_util_win.h`: shared window creation, modal hints, transient parenting,
+- `src/lib/shared/dialog.c`, `dialog_ui.h`: shared child lifetime, result writing, and common widgets.
+- `src/lib/shared/dialog_util_win.c`, `dialog_util_win.h`: shared window creation, modal hints, transient parenting,
sizing, visibility, destruction, and in-window overlays for all dialogs.
-- `src/bin/dialog_filechooser.c`, `dialog_access.c`: dialog UI and helper entry points.
-- `src/bin/service_options.c`: one-pass typed option parsing; Eldbus iterators are
+- `src/lib/filechooser/dialog_filechooser.c`: file chooser UI and helper entry point.
+- `src/lib/access/dialog_access.c`: access dialog UI and helper entry point.
+- `src/lib/filechooser/meson.build`, `src/lib/access/meson.build`: build and install
+ each dialog helper from its own directory.
+- `src/bin/shared_options.c`: one-pass typed option parsing; Eldbus iterators are
consumable, so scalar options are cached.
-- `src/bin/service_choices.c`: parent-side portal choice parsing and result encoding.
-- `src/bin/dialog_choices.c`: child-side choice widgets and selection collection.
-- `src/lib/xdg-desktop-portal-efl/dialogs`: helper build and installation targets.
+- `src/bin/shared_choices.c`: parent-side portal choice parsing and result encoding.
+- `src/lib/shared/dialog_choices.c`, `choices.h`: child-side choice widgets,
+ selection collection, and shared choice model.
+- `src/lib/shared/meson.build`: shared protocol and UI source lists. Each binary
+ compiles the shared sources it needs directly.
+- `src/lib/xdg-desktop-portal-efl/dialogs`: build-tree links for helper discovery.
- `src/bin/service_filechooser.c`, `service_access.c`, `service_settings.c`: parent-side backend services.
- `src/tests`: Eldbus clients, test option fixtures, and GUI response tests.
- `tests/run.py`, `tests/processes.py`: isolated process test supervisors.
diff --git a/meson.build b/meson.build
index 36c3275..271e44b 100644
--- a/meson.build
+++ b/meson.build
@@ -27,8 +27,8 @@ foreach dir : ['bin', 'lib', 'data', 'locale']
get_option('prefix') / get_option(dir + 'dir'))
endforeach
configure_file(output: 'config.h', configuration: cfg)
+subdir('src/lib')
subdir('src/bin')
-subdir('src/lib/xdg-desktop-portal-efl/dialogs')
portal_devenv = environment()
portal_devenv.set('XDG_DESKTOP_PORTAL_EFL_LIB_DIR', meson.project_build_root() / 'src/lib')
meson.add_devenv(portal_devenv)
diff --git a/src/bin/frontend.h b/src/bin/frontend.h
index 094437c..d5971f0 100644
--- a/src/bin/frontend.h
+++ b/src/bin/frontend.h
@@ -13,8 +13,5 @@ void frontend_shutdown(void);
extern const Eldbus_Service_Interface_Desc frontend_filechooser_desc;
extern const Eldbus_Service_Interface_Desc frontend_settings_desc;
-extern const Eldbus_Service_Interface_Desc frontend_request_desc;
-
-char *request_frontend_path(const Eldbus_Message *msg, Options *options);
#endif
diff --git a/src/bin/frontend_filechooser.c b/src/bin/frontend_filechooser.c
deleted file mode 100644
index 268f187..0000000
--- a/src/bin/frontend_filechooser.c
+++ /dev/null
@@ -1,75 +0,0 @@
-#include "frontend.h"
-#include "dialog.h"
-#include <stdlib.h>
-
-static Eldbus_Message *
-_choose(const Eldbus_Service_Interface *iface EINA_UNUSED, const Eldbus_Message *msg)
-{
- const char *parent, *title, *app_id;
- Eldbus_Message_Iter *options;
- AUTO_OPTIONS Options *opts = NULL;
- Dialog *d;
- Request *r;
- char *path;
- Eldbus_Message *reply, *error = NULL;
-
- if (!eldbus_message_arguments_get(msg, "ssa{sv}", &parent, &title, &options))
- return portal_error(msg, "Expected parent_window, title, and options");
- /* The public protocol has no caller-supplied app_id. Do not invent
- * a trusted application identity from the options dictionary. */
- app_id = eldbus_message_sender_get(msg);
- opts = options_parse(options);
- if (!opts) return portal_error(msg, "Invalid options");
- d = filechooser_dialog_new(msg, app_id, parent, title, opts, &error);
- if (!d) return error;
- path = request_frontend_path(msg, opts);
- if (!path)
- {
- dialog_free(d);
- return portal_error(msg, "Invalid handle_token");
- }
- r = request_new(msg, path, &frontend_request_desc, EINA_TRUE);
- free(path);
- if (!r)
- {
- dialog_free(d);
- return portal_error(msg, "Invalid, duplicate, or excessive request handle");
- }
- /* Queue the handle before any possible synchronous failure signal. */
- reply = eldbus_message_method_return_new(msg);
- eldbus_message_arguments_append(reply, "o", eldbus_service_object_path_get(r->iface));
- eldbus_connection_send(portal_conn, reply, NULL, NULL, -1);
- filechooser_dialog_start(r, d);
- return NULL;
-}
-
-static Eina_Bool
-_version(const Eldbus_Service_Interface *iface EINA_UNUSED,
- const char *name EINA_UNUSED, Eldbus_Message_Iter *it,
- const Eldbus_Message *msg EINA_UNUSED,
- Eldbus_Message **error EINA_UNUSED)
-{
- return eldbus_message_iter_basic_append(it, 'u', 4u);
-}
-
-#define FRONT_FILE_ARGS ELDBUS_ARGS({"s", "parent_window"}, {"s", "title"}, {"a{sv}", "options"})
-
-static const Eldbus_Method methods[] =
-{
- {"OpenFile", FRONT_FILE_ARGS, ELDBUS_ARGS({"o", "handle"}), _choose, 0},
- {"SaveFile", FRONT_FILE_ARGS, ELDBUS_ARGS({"o", "handle"}), _choose, 0},
- {"SaveFiles", FRONT_FILE_ARGS, ELDBUS_ARGS({"o", "handle"}), _choose, 0},
- {NULL, NULL, NULL, NULL, 0}
-};
-
-static const Eldbus_Property properties[] =
-{
- {"version", "u", _version, NULL, 0}, {NULL, NULL, NULL, NULL, 0}
-};
-
-const Eldbus_Service_Interface_Desc frontend_filechooser_desc =
-{
- .interface = FRONT "FileChooser",
- .methods = methods,
- .properties = properties
-};
diff --git a/src/bin/frontend_request.c b/src/bin/frontend_request.c
deleted file mode 100644
index d101990..0000000
--- a/src/bin/frontend_request.c
+++ /dev/null
@@ -1,60 +0,0 @@
-#define _GNU_SOURCE
-#include "frontend.h"
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-
-static const Eldbus_Method methods[] =
-{
- { "Close", NULL, NULL, request_close, 0},
- { NULL, NULL, NULL, NULL, 0}
-};
-
-static const Eldbus_Signal frontend_signals[] =
-{
- { "Response", RESULT_ARGS, 0},
- { NULL, NULL, 0}
-};
-
-const Eldbus_Service_Interface_Desc frontend_request_desc =
-{
- .interface = FRONT "Request",
- .methods = methods,
- .signals = frontend_signals
-};
-
-char *
-request_frontend_path(const Eldbus_Message *msg, Options *options)
-{
- static unsigned long serial;
- char generated[64];
- const char *token;
- const char *sender;
- char *name, *path = NULL;
- const char *token_char;
- char *p;
-
- snprintf(generated, sizeof(generated), "efl_%lu", ++serial);
- token = option_string(options, "handle_token", generated);
- if (!token[0] || strlen(token) > 255) return NULL;
- for (token_char = token; *token_char; token_char++)
- {
- if (!(((*token_char >= 'a') && (*token_char <= 'z')) ||
- ((*token_char >= 'A') && (*token_char <= 'Z')) ||
- ((*token_char >= '0') && (*token_char <= '9')) ||
- (*token_char == '_')))
- return NULL;
- }
- sender = eldbus_message_sender_get(msg);
- if (!sender || sender[0] != ':') return NULL;
- name = strdup(sender + 1);
- if (!name) return NULL;
- for (p = name; *p; p++)
- {
- if (*p == '.') *p = '_';
- }
- if (asprintf(&path, PORTAL_PATH "/request/%s/%s", name, token) < 0) path = NULL;
- free(name);
- return path;
-}
-
diff --git a/src/bin/meson.build b/src/bin/meson.build
index 06863b0..b91c51d 100644
--- a/src/bin/meson.build
+++ b/src/bin/meson.build
@@ -1,12 +1,7 @@
-dialog_shared_sources = files('dialog_model.c', 'dialog_wire.c')
-dialog_ui_sources = files('dialog.c', 'dialog_choices.c', 'dialog_util_win.c')
-filechooser_ui = files('dialog_filechooser.c')
-access_ui = files('dialog_access.c')
-frontend_sources = files('frontend.c', 'frontend_filechooser.c',
- 'frontend_settings.c', 'frontend_request.c')
-portal_sources = files('service_request.c', 'service_options.c', 'service_choices.c', 'service_filechooser.c',
- 'service_access.c', 'service_settings.c', 'service_dialog_process.c', 'app_paths.c') + dialog_shared_sources + frontend_sources
+frontend_sources = files('frontend.c', 'frontend_settings.c')
+portal_sources = files('shared_request.c', 'shared_options.c', 'shared_choices.c', 'service_filechooser.c',
+ 'service_access.c', 'service_settings.c', 'shared_dialog_process.c', 'shared_app_paths.c') + frontend_sources + dialog_shared_sources
portal = executable('xdg-desktop-portal-efl', ['service_main.c', portal_sources],
- include_directories: inc,
+ include_directories: [inc, dialog_inc],
dependencies: portal_deps,
install: true)
diff --git a/src/bin/portal.h b/src/bin/portal.h
index 80351eb..e567690 100644
--- a/src/bin/portal.h
+++ b/src/bin/portal.h
@@ -8,9 +8,6 @@
#define PORTAL_BUS "org.freedesktop.impl.portal.desktop.efl"
#define PORTAL_PATH "/org/freedesktop/portal/desktop"
#define IMPL "org.freedesktop.impl.portal."
-#define APPEARANCE "org.freedesktop.appearance"
-#define FILE_ARGS ELDBUS_ARGS({"o", "handle"}, {"s", "app_id"}, \
- {"s", "parent_window"}, {"s", "title"}, {"a{sv}", "options"})
#define RESULT_ARGS ELDBUS_ARGS({"u", "response"}, {"a{sv}", "results"})
typedef struct Request Request;
diff --git a/src/bin/service_filechooser.c b/src/bin/service_filechooser.c
index c9c24df..38d5647 100644
--- a/src/bin/service_filechooser.c
+++ b/src/bin/service_filechooser.c
@@ -1,6 +1,6 @@
#define _GNU_SOURCE
#include "config.h"
-#include "portal.h"
+#include "frontend.h"
#include "dialog.h"
#include <stdlib.h>
#include <string.h>
@@ -248,6 +248,9 @@ _choose(const Eldbus_Service_Interface *iface EINA_UNUSED,
return NULL;
}
+#define FILE_ARGS ELDBUS_ARGS({"o", "handle"}, {"s", "app_id"}, \
+ {"s", "parent_window"}, {"s", "title"}, {"a{sv}", "options"})
+
static const Eldbus_Method methods[] =
{
{"OpenFile", FILE_ARGS, RESULT_ARGS, _choose, 0},
@@ -262,3 +265,129 @@ const Eldbus_Service_Interface_Desc filechooser_desc =
.methods = methods
};
+/* Public file chooser interface used by the optional fallback frontend. */
+static const Eldbus_Method frontend_request_methods[] =
+{
+ { "Close", NULL, NULL, request_close, 0},
+ { NULL, NULL, NULL, NULL, 0}
+};
+
+static const Eldbus_Signal frontend_signals[] =
+{
+ { "Response", RESULT_ARGS, 0},
+ { NULL, NULL, 0}
+};
+
+static const Eldbus_Service_Interface_Desc frontend_request_desc =
+{
+ .interface = FRONT "Request",
+ .methods = frontend_request_methods,
+ .signals = frontend_signals
+};
+
+static char *
+_request_frontend_path(const Eldbus_Message *msg, Options *options)
+{
+ static unsigned long serial;
+ char generated[64];
+ const char *token;
+ const char *sender;
+ char *name, *path = NULL;
+ const char *token_char;
+ char *p;
+
+ snprintf(generated, sizeof(generated), "efl_%lu", ++serial);
+ token = option_string(options, "handle_token", generated);
+ if (!token[0] || strlen(token) > 255) return NULL;
+ for (token_char = token; *token_char; token_char++)
+ {
+ if (!(((*token_char >= 'a') && (*token_char <= 'z')) ||
+ ((*token_char >= 'A') && (*token_char <= 'Z')) ||
+ ((*token_char >= '0') && (*token_char <= '9')) ||
+ (*token_char == '_')))
+ return NULL;
+ }
+ sender = eldbus_message_sender_get(msg);
+ if (!sender || sender[0] != ':') return NULL;
+ name = strdup(sender + 1);
+ if (!name) return NULL;
+ for (p = name; *p; p++)
+ {
+ if (*p == '.') *p = '_';
+ }
+ if (asprintf(&path, PORTAL_PATH "/request/%s/%s", name, token) < 0) path = NULL;
+ free(name);
+ return path;
+}
+
+static Eldbus_Message *
+_frontend_choose(const Eldbus_Service_Interface *iface EINA_UNUSED, const Eldbus_Message *msg)
+{
+ const char *parent, *title, *app_id;
+ Eldbus_Message_Iter *options;
+ AUTO_OPTIONS Options *opts = NULL;
+ Dialog *d;
+ Request *r;
+ char *path;
+ Eldbus_Message *reply, *error = NULL;
+
+ if (!eldbus_message_arguments_get(msg, "ssa{sv}", &parent, &title, &options))
+ return portal_error(msg, "Expected parent_window, title, and options");
+ /* The public protocol has no caller-supplied app_id. Do not invent
+ * a trusted application identity from the options dictionary. */
+ app_id = eldbus_message_sender_get(msg);
+ opts = options_parse(options);
+ if (!opts) return portal_error(msg, "Invalid options");
+ d = filechooser_dialog_new(msg, app_id, parent, title, opts, &error);
+ if (!d) return error;
+ path = _request_frontend_path(msg, opts);
+ if (!path)
+ {
+ dialog_free(d);
+ return portal_error(msg, "Invalid handle_token");
+ }
+ r = request_new(msg, path, &frontend_request_desc, EINA_TRUE);
+ free(path);
+ if (!r)
+ {
+ dialog_free(d);
+ return portal_error(msg, "Invalid, duplicate, or excessive request handle");
+ }
+ /* Queue the handle before any possible synchronous failure signal. */
+ reply = eldbus_message_method_return_new(msg);
+ eldbus_message_arguments_append(reply, "o", eldbus_service_object_path_get(r->iface));
+ eldbus_connection_send(portal_conn, reply, NULL, NULL, -1);
+ filechooser_dialog_start(r, d);
+ return NULL;
+}
+
+static Eina_Bool
+_version(const Eldbus_Service_Interface *iface EINA_UNUSED,
+ const char *name EINA_UNUSED, Eldbus_Message_Iter *it,
+ const Eldbus_Message *msg EINA_UNUSED,
+ Eldbus_Message **error EINA_UNUSED)
+{
+ return eldbus_message_iter_basic_append(it, 'u', 4u);
+}
+
+#define FRONT_FILE_ARGS ELDBUS_ARGS({"s", "parent_window"}, {"s", "title"}, {"a{sv}", "options"})
+
+static const Eldbus_Method frontend_methods[] =
+{
+ {"OpenFile", FRONT_FILE_ARGS, ELDBUS_ARGS({"o", "handle"}), _frontend_choose, 0},
+ {"SaveFile", FRONT_FILE_ARGS, ELDBUS_ARGS({"o", "handle"}), _frontend_choose, 0},
+ {"SaveFiles", FRONT_FILE_ARGS, ELDBUS_ARGS({"o", "handle"}), _frontend_choose, 0},
+ {NULL, NULL, NULL, NULL, 0}
+};
+
+static const Eldbus_Property frontend_properties[] =
+{
+ {"version", "u", _version, NULL, 0}, {NULL, NULL, NULL, NULL, 0}
+};
+
+const Eldbus_Service_Interface_Desc frontend_filechooser_desc =
+{
+ .interface = FRONT "FileChooser",
+ .methods = frontend_methods,
+ .properties = frontend_properties
+};
diff --git a/src/bin/service_settings.c b/src/bin/service_settings.c
index 736724b..469e9e6 100644
--- a/src/bin/service_settings.c
+++ b/src/bin/service_settings.c
@@ -1,13 +1,19 @@
#include "portal.h"
#include <string.h>
+#define APPEARANCE "org.freedesktop.appearance"
+
+// https://flatpak.github.io/xdg-desktop-portal/docs/doc-org.freedesktop.portal.Settings.html
+
/* No desktop preference source is available yet. Zero is the specified
* "no preference" value, not a guess based on the current theme name. */
static const char *keys[] =
{
- "color-scheme",
- "contrast",
- "reduced-motion"
+ "color-scheme", // (u) 0 (no preference), 1 (prefer dark), 2 (prefer light)
+ "accent-color", // ((ddd)) RGB color tuple with values in [0, 1]
+ "contrast", // (u) 0 (normal), 1 (higher contrast).
+ "reduced-motion", // (uuu) 0 (no preference), 1 (reduced motion).
+ "button-placement", // ((asas)) left("close", maximize), right ("minimize", "close")
};
Eldbus_Message *
diff --git a/src/bin/app_paths.c b/src/bin/shared_app_paths.c
similarity index 100%
rename from src/bin/app_paths.c
rename to src/bin/shared_app_paths.c
diff --git a/src/bin/service_choices.c b/src/bin/shared_choices.c
similarity index 100%
rename from src/bin/service_choices.c
rename to src/bin/shared_choices.c
diff --git a/src/bin/service_dialog_process.c b/src/bin/shared_dialog_process.c
similarity index 100%
rename from src/bin/service_dialog_process.c
rename to src/bin/shared_dialog_process.c
diff --git a/src/bin/service_options.c b/src/bin/shared_options.c
similarity index 100%
rename from src/bin/service_options.c
rename to src/bin/shared_options.c
diff --git a/src/bin/service_request.c b/src/bin/shared_request.c
similarity index 100%
rename from src/bin/service_request.c
rename to src/bin/shared_request.c
diff --git a/src/bin/dialog_access.c b/src/lib/access/dialog_access.c
similarity index 100%
rename from src/bin/dialog_access.c
rename to src/lib/access/dialog_access.c
diff --git a/src/lib/access/meson.build b/src/lib/access/meson.build
new file mode 100644
index 0000000..8107445
--- /dev/null
+++ b/src/lib/access/meson.build
@@ -0,0 +1,5 @@
+access_ui = files('dialog_access.c')
+access_worker = executable('access',
+ [access_ui, dialog_shared_sources, dialog_ui_sources],
+ include_directories: [inc, dialog_inc], dependencies: dialog_deps,
+ install: true, install_dir: dialog_install_dir)
diff --git a/src/bin/dialog_filechooser.c b/src/lib/filechooser/dialog_filechooser.c
similarity index 100%
rename from src/bin/dialog_filechooser.c
rename to src/lib/filechooser/dialog_filechooser.c
diff --git a/src/lib/filechooser/meson.build b/src/lib/filechooser/meson.build
new file mode 100644
index 0000000..30e01b9
--- /dev/null
+++ b/src/lib/filechooser/meson.build
@@ -0,0 +1,5 @@
+filechooser_ui = files('dialog_filechooser.c')
+filechooser_worker = executable('filechooser',
+ [filechooser_ui, dialog_shared_sources, dialog_ui_sources],
+ include_directories: [inc, dialog_inc], dependencies: dialog_deps + [efreet, ecore_file],
+ install: true, install_dir: dialog_install_dir)
diff --git a/src/lib/meson.build b/src/lib/meson.build
new file mode 100644
index 0000000..19a603e
--- /dev/null
+++ b/src/lib/meson.build
@@ -0,0 +1,9 @@
+dialog_install_dir = get_option('libdir') / 'xdg-desktop-portal-efl/dialogs'
+
+subdir('shared')
+
+subdir('filechooser')
+subdir('access')
+
+# Match the installed helper layout in the build tree for development runs.
+subdir('xdg-desktop-portal-efl/dialogs')
diff --git a/src/bin/choices.h b/src/lib/shared/choices.h
similarity index 100%
rename from src/bin/choices.h
rename to src/lib/shared/choices.h
diff --git a/src/bin/dialog.c b/src/lib/shared/dialog.c
similarity index 100%
rename from src/bin/dialog.c
rename to src/lib/shared/dialog.c
diff --git a/src/bin/dialog.h b/src/lib/shared/dialog.h
similarity index 100%
rename from src/bin/dialog.h
rename to src/lib/shared/dialog.h
diff --git a/src/bin/dialog_choices.c b/src/lib/shared/dialog_choices.c
similarity index 100%
rename from src/bin/dialog_choices.c
rename to src/lib/shared/dialog_choices.c
diff --git a/src/bin/dialog_model.c b/src/lib/shared/dialog_model.c
similarity index 100%
rename from src/bin/dialog_model.c
rename to src/lib/shared/dialog_model.c
diff --git a/src/lib/shared/dialog_ui.h b/src/lib/shared/dialog_ui.h
new file mode 100644
index 0000000..47173e8
--- /dev/null
+++ b/src/lib/shared/dialog_ui.h
@@ -0,0 +1,19 @@
+#ifndef DIALOG_UI_H
+#define DIALOG_UI_H
+
+#include <Elementary.h>
+#include "dialog.h"
+
+void dialog_file_show(Dialog *d);
+void dialog_access_show(Dialog *d);
+void dialog_finish(Dialog *d, unsigned response);
+int dialog_main(int argc, char **argv, unsigned kind,
+ void (*show)(Dialog *), void (*ready)(void));
+void dialog_label(Evas_Object *win, Evas_Object *box, const char *text);
+Evas_Object *dialog_button_row(Evas_Object *win, Evas_Object *box);
+Evas_Object *dialog_button(Evas_Object *win, Evas_Object *box, const char *text, Evas_Smart_Cb cb, void *data);
+void dialog_cancel(void *data, Evas_Object *obj, void *event);
+void choices_show(Choices *choices, Evas_Object *win, Evas_Object *box);
+Eina_Bool choices_collect(Choices *choices);
+
+#endif
diff --git a/src/bin/dialog_util_win.c b/src/lib/shared/dialog_util_win.c
similarity index 100%
rename from src/bin/dialog_util_win.c
rename to src/lib/shared/dialog_util_win.c
diff --git a/src/bin/dialog_util_win.h b/src/lib/shared/dialog_util_win.h
similarity index 100%
rename from src/bin/dialog_util_win.h
rename to src/lib/shared/dialog_util_win.h
diff --git a/src/bin/dialog_wire.c b/src/lib/shared/dialog_wire.c
similarity index 100%
rename from src/bin/dialog_wire.c
rename to src/lib/shared/dialog_wire.c
diff --git a/src/lib/shared/meson.build b/src/lib/shared/meson.build
new file mode 100644
index 0000000..06ee600
--- /dev/null
+++ b/src/lib/shared/meson.build
@@ -0,0 +1,3 @@
+dialog_inc = include_directories('.')
+dialog_shared_sources = files('dialog_model.c', 'dialog_wire.c')
+dialog_ui_sources = files('dialog.c', 'dialog_choices.c', 'dialog_util_win.c')
diff --git a/src/lib/xdg-desktop-portal-efl/dialogs/meson.build b/src/lib/xdg-desktop-portal-efl/dialogs/meson.build
index d25795b..260661e 100644
--- a/src/lib/xdg-desktop-portal-efl/dialogs/meson.build
+++ b/src/lib/xdg-desktop-portal-efl/dialogs/meson.build
@@ -1,9 +1,9 @@
-dialog_install_dir = get_option('libdir') / 'xdg-desktop-portal-efl/dialogs'
-filechooser_worker = executable('filechooser',
- [dialog_shared_sources, dialog_ui_sources, filechooser_ui],
- include_directories: inc, dependencies: dialog_deps + [efreet, ecore_file],
- install: true, install_dir: dialog_install_dir)
-access_worker = executable('access',
- [dialog_shared_sources, dialog_ui_sources, access_ui],
- include_directories: inc, dependencies: dialog_deps,
- install: true, install_dir: dialog_install_dir)
+# Keep development helper lookup identical to the installed layout.
+dialog_link = find_program('ln')
+dialog_worker_links = []
+foreach worker : [filechooser_worker, access_worker]
+ dialog_worker_links += custom_target(worker.name() + '-build-link',
+ input: worker, output: worker.name(),
+ command: [dialog_link, '-sfn', worker.full_path(), '@OUTPUT@'],
+ build_by_default: true)
+endforeach
diff --git a/src/tests/dialog_wire_test.c b/src/tests/dialog_wire_test.c
new file mode 100644
index 0000000..076851d
--- /dev/null
+++ b/src/tests/dialog_wire_test.c
@@ -0,0 +1,202 @@
+#include "dialog.h"
+#include <arpa/inet.h>
+#include <assert.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+static unsigned
+_length(const unsigned char *chunk)
+{
+ return (unsigned)chunk[4] | ((unsigned)chunk[5] << 8) |
+ ((unsigned)chunk[6] << 16) | ((unsigned)chunk[7] << 24);
+}
+
+static void
+_length_set(unsigned char *chunk, unsigned length)
+{
+ unsigned i;
+
+ for (i = 0; i < 4; i++) chunk[4 + i] = length >> (8 * i);
+}
+
+static void
+_frame_size_set(unsigned char *frame, int size)
+{
+ uint32_t length = htonl(size - DIALOG_WIRE_HEADER);
+
+ memcpy(frame + 8, &length, sizeof(length));
+}
+
+/* Find a field through both the named field wrappers and Eet struct chunks. */
+static size_t
+_find(const unsigned char *frame, size_t parent, const char *name)
+{
+ size_t end = parent + 8 + _length(frame + parent);
+ size_t offset = parent + 8 + strlen((const char *)frame + parent + 8) + 1;
+
+ while (offset < end)
+ {
+ if (!strcmp((const char *)frame + offset + 8, name)) return offset;
+ offset += 8 + _length(frame + offset);
+ }
+ abort();
+}
+
+static unsigned char *
+_duplicate(const unsigned char *frame, int size, const char *const *path, int *out_size)
+{
+ size_t parents[16], count = 0, offset = DIALOG_WIRE_HEADER, extra, i;
+ unsigned char *copy;
+
+ while (*path)
+ {
+ assert(count < sizeof(parents) / sizeof(parents[0]));
+ parents[count++] = offset;
+ offset = _find(frame, offset, *path++);
+ }
+ extra = 8 + _length(frame + offset);
+ *out_size = size + extra;
+ copy = malloc(*out_size);
+ assert(copy);
+ memcpy(copy, frame, offset);
+ memcpy(copy + offset, frame + offset, extra);
+ memcpy(copy + offset + extra, frame + offset, size - offset);
+ for (i = 0; i < count; i++)
+ _length_set(copy + parents[i], _length(copy + parents[i]) + extra);
+ _frame_size_set(copy, *out_size);
+ return copy;
+}
+
+static void
+_round_trip(Dialog *d)
+{
+ int size, reply_size;
+ void *frame = dialog_wire_encode(d, &size), *reply;
+ Dialog *child, *parent;
+ Choice *choice;
+
+ assert(frame);
+ child = dialog_wire_decode(frame, size);
+ assert(child);
+ free(frame); /* Decoded values must outlive the input buffer. */
+ assert(!strcmp(child->title, d->title));
+ assert(eina_list_count(child->files) == 2);
+ assert(eina_list_count(child->uris) == 2);
+ assert(eina_list_count(child->filters) == 2);
+ choice = eina_list_data_get(child->choices->list);
+ assert(eina_list_count(choice->items) == 2);
+ free(choice->selected);
+ choice->selected = strdup("two");
+ child->response = 1;
+ reply = dialog_wire_encode(child, &reply_size);
+ assert(reply);
+ dialog_free(child);
+ parent = dialog_wire_decode(reply, reply_size);
+ free(reply);
+ assert(parent && parent->response == 1);
+ choice = eina_list_data_get(parent->choices->list);
+ assert(!strcmp(choice->selected, "two"));
+ dialog_free(parent);
+}
+
+int
+main(void)
+{
+ Item _one_ = {.id = "one", .label = "One"};
+ Item two = {.id = "two", .label = "Two"};
+ Choice choice = {.id = "choice", .label = "Choice", .selected = "one"};
+ Choices choices = {0};
+ Rule rule = {.pattern = "*"};
+ Filter filter = {.name = "All"};
+ Dialog d = {
+ .kind = DIALOG_FILE, .app = "app", .title = "Title", .app_id = "",
+ .parent = "", .accept_label = "Open", .name = "", .choices = &choices,
+ .subtitle = "Subtitle", .body = "Body", .cancel_label = "Cancel",
+ .folder = "/tmp", .file = "/tmp/file"
+ };
+ const char *duplicates[][9] = {
+ {"title", NULL},
+ {"choices", NULL},
+ {"choices", "Choices", "list", "Choice", "selected", NULL},
+ {"choices", "Choices", "list", "Choice", "items", "Item", "label", NULL},
+ {"filters", "Filter", "name", NULL},
+ {"filters", "Filter", "rules", "Rule", "pattern", NULL}
+ };
+ const char *lists[][9] = {
+ {"files", NULL}, {"uris", NULL}, {"filters", NULL},
+ {"choices", "Choices", "list", NULL},
+ {"choices", "Choices", "list", "Choice", "items", NULL},
+ {"filters", "Filter", "rules", NULL}
+ };
+ unsigned char *frame, *copy;
+ int size, copy_size, n;
+ unsigned i;
+
+ assert(dialog_wire_init());
+ choice.items = eina_list_append(NULL, &one);
+ choice.items = eina_list_append(choice.items, &two);
+ choices.list = eina_list_append(NULL, &choice);
+ filter.rules = eina_list_append(NULL, &rule);
+ d.filters = eina_list_append(NULL, &filter);
+ d.filters = eina_list_append(d.filters, &filter);
+ d.files = eina_list_append(NULL, "file");
+ d.files = eina_list_append(d.files, "other");
+ d.uris = eina_list_append(NULL, "file:///tmp/file");
+ d.uris = eina_list_append(d.uris, "file:///tmp/other");
+
+ for (n = 0; n < 20; n++)
+ {
+ d.kind = n % 2 ? DIALOG_FILE : DIALOG_ACCESS;
+ _round_trip(&d);
+ }
+ frame = dialog_wire_encode(&d, &size);
+ assert(frame);
+ for (i = 0; i < sizeof(duplicates) / sizeof(duplicates[0]); i++)
+ {
+ copy = _duplicate(frame, size, duplicates[i], ©_size);
+ for (n = 0; n < 20; n++)
+ assert(!dialog_wire_decode(copy, copy_size));
+ free(copy);
+ }
+ for (i = 0; i < sizeof(lists) / sizeof(lists[0]); i++)
+ {
+ Dialog *decoded;
+
+ copy = _duplicate(frame, size, lists[i], ©_size);
+ decoded = dialog_wire_decode(copy, copy_size);
+ assert(decoded);
+ dialog_free(decoded);
+ free(copy);
+ }
+ /* A valid outer frame must not hide a truncated Eet payload. */
+ copy = malloc(size);
+ assert(copy);
+ for (n = DIALOG_WIRE_HEADER + 16; n < size; n++)
+ {
+ Dialog *decoded;
+
+ memcpy(copy, frame, n);
+ _frame_size_set(copy, n);
+ _length_set(copy + DIALOG_WIRE_HEADER, n - DIALOG_WIRE_HEADER - 8);
+ /* Cutting exactly between optional fields can leave a valid dialog. */
+ decoded = dialog_wire_decode(copy, n);
+ dialog_free(decoded);
+ }
+ free(copy);
+ free(frame);
+ d.response = 3;
+ frame = dialog_wire_encode(&d, &size);
+ assert(frame && !dialog_wire_decode(frame, size));
+ free(frame);
+
+ eina_list_free(d.uris);
+ eina_list_free(d.files);
+ eina_list_free(d.filters);
+ eina_list_free(filter.rules);
+ eina_list_free(choices.list);
+ eina_list_free(choice.items);
+ dialog_wire_shutdown();
+ puts("PASS: dialog wire round trips, duplicate fields, lists and truncated payloads");
+ return 0;
+}
diff --git a/src/tests/lib/xdg-desktop-portal-efl/dialogs/meson.build b/src/tests/lib/xdg-desktop-portal-efl/dialogs/meson.build
index c76f401..39d6087 100644
--- a/src/tests/lib/xdg-desktop-portal-efl/dialogs/meson.build
+++ b/src/tests/lib/xdg-desktop-portal-efl/dialogs/meson.build
@@ -1,8 +1,8 @@
dialog_test_workers = []
foreach worker : [['filechooser', 'DIALOG_FILE', 'dialog_file_show', filechooser_ui],
['access', 'DIALOG_ACCESS', 'dialog_access_show', access_ui]]
- dialog_test_workers += executable(worker[0], ['../../../dialog_worker_test.c', dialog_shared_sources,
- dialog_ui_sources, worker[3]],
+ dialog_test_workers += executable(worker[0],
+ ['../../../dialog_worker_test.c', worker[3], dialog_shared_sources, dialog_ui_sources],
c_args: ['-DDIALOG_TEST', '-DWORKER_KIND=' + worker[1], '-DWORKER_SHOW=' + worker[2]],
- include_directories: inc, dependencies: dialog_deps + [efreet, ecore_file], install: false)
+ include_directories: [inc, dialog_inc], dependencies: dialog_deps + [efreet, ecore_file], install: false)
endforeach
diff --git a/src/tests/meson.build b/src/tests/meson.build
index cf36eb6..ef0c71e 100644
--- a/src/tests/meson.build
+++ b/src/tests/meson.build
@@ -1,7 +1,7 @@
subdir('lib/xdg-desktop-portal-efl/dialogs')
dialog_wire_test = executable('dialog-wire-test',
['dialog_wire_test.c', dialog_shared_sources],
- include_directories: inc, dependencies: portal_deps)
+ include_directories: [inc, dialog_inc], dependencies: portal_deps)
test('dialog-wire', dialog_wire_test)
worker_env = environment()
worker_env.set('ELM_ENGINE', 'buffer')
@@ -18,27 +18,27 @@ python = find_program('python3')
dbus_run = find_program('dbus-run-session')
test('backend-protocol', dbus_run,
args: ['--', python.full_path(), files('../../tests/run.py'), portal, portal_test],
- env: worker_env, depends: [filechooser_worker, access_worker], timeout: 60)
+ env: worker_env, depends: dialog_worker_links, timeout: 60)
test('dialog-lifecycle', dbus_run,
args: ['--', python.full_path(), files('../../tests/run.py'), portal, portal_test, 'gui'],
- env: worker_env, depends: [filechooser_worker, access_worker], timeout: 60)
+ env: worker_env, depends: dialog_worker_links, timeout: 60)
dialog_test = executable('dialog-test', ['dialog_test.c', portal_sources],
- include_directories: inc, dependencies: portal_deps + [efreet, ecore_file])
+ include_directories: [inc, dialog_inc], dependencies: portal_deps + [efreet, ecore_file])
test('dialog-responses', dbus_run, args: ['--', dialog_test],
env: gui_env, depends: dialog_test_workers, timeout: 45)
test('frontend-protocol', dbus_run,
args: ['--', python.full_path(), files('../../tests/frontend.py'), portal, portal_test],
- env: worker_env, depends: [filechooser_worker, access_worker], timeout: 60)
+ env: worker_env, depends: dialog_worker_links, timeout: 60)
test('frontend-dialog-responses', dbus_run, args: ['--', dialog_test, '--frontend'],
env: gui_env, depends: dialog_test_workers, timeout: 45)
test('dialog-processes', dbus_run,
args: ['--', python.full_path(), files('../../tests/processes.py'), portal, portal_test],
- env: worker_env, depends: [filechooser_worker, access_worker], timeout: 45)
+ env: worker_env, depends: dialog_worker_links, timeout: 45)
test('dialog-install-paths', dbus_run,
args: ['--', python.full_path(), files('../../tests/paths.py'), portal,
diff --git a/supported.txt b/supported.txt
new file mode 100644
index 0000000..93ed532
--- /dev/null
+++ b/supported.txt
@@ -0,0 +1,19 @@
+* Access
+ Account
+ App chooser
+ Background
+ Clipboard
+ Dynamic launcher
+ Email
+* File chooser
+ Global shortcuts
+ Inhibit
+ Input capture
+ Notification
+ Print
+ Remote desktop
+ Screencast
+ Screenshot
+ Secret
+. Settings (no actual storage - just api)
+ Wallpaper
--
To stop receiving notification emails like this one, please contact
the administrator of this repository.