diff options
-rw-r--r-- | meson.build | 27 | ||||
-rw-r--r-- | src/application.c | 38 | ||||
-rw-r--r-- | src/application.h | 5 | ||||
-rw-r--r-- | src/request.c | 142 | ||||
-rw-r--r-- | src/request.h | 30 | ||||
-rw-r--r-- | src/ui/messenger.c | 2 | ||||
-rw-r--r-- | src/ui/new_contact.c | 35 | ||||
-rw-r--r-- | src/ui/settings.c | 28 |
8 files changed, 229 insertions, 78 deletions
diff --git a/meson.build b/meson.build index b200978..26d2ab8 100644 --- a/meson.build +++ b/meson.build | |||
@@ -25,6 +25,8 @@ project( | |||
25 | version: run_command('contrib/get_version.sh').stdout().strip(), | 25 | version: run_command('contrib/get_version.sh').stdout().strip(), |
26 | ) | 26 | ) |
27 | 27 | ||
28 | use_libportal = true | ||
29 | |||
28 | messenger_gtk_id = 'org.gnunet.Messenger' | 30 | messenger_gtk_id = 'org.gnunet.Messenger' |
29 | 31 | ||
30 | gnome = import('gnome') | 32 | gnome = import('gnome') |
@@ -40,25 +42,36 @@ messenger_gtk_deps = [ | |||
40 | dependency('gtk+-3.0'), | 42 | dependency('gtk+-3.0'), |
41 | dependency('libhandy-1'), | 43 | dependency('libhandy-1'), |
42 | dependency('gstreamer-1.0'), | 44 | dependency('gstreamer-1.0'), |
43 | dependency('libportal'), | ||
44 | dependency('libportal-gtk3'), | ||
45 | dependency('libnotify'), | 45 | dependency('libnotify'), |
46 | dependency('libqrencode'), | 46 | dependency('libqrencode'), |
47 | dependency('libpipewire-0.3'), | 47 | dependency('libpipewire-0.3'), |
48 | declare_dependency(link_args: '-lunistring'), | 48 | declare_dependency(link_args: '-lunistring'), |
49 | ] | 49 | ] |
50 | 50 | ||
51 | messenger_gtk_args = [ | ||
52 | '-DMESSENGER_APPLICATION_BINARY="@0@"'.format(meson.project_name()), | ||
53 | '-DMESSENGER_APPLICATION_ID="@0@"'.format(messenger_gtk_id), | ||
54 | '-DMESSENGER_APPLICATION_VERSION="@0@"'.format(meson.project_version()), | ||
55 | ] | ||
56 | |||
57 | if use_libportal | ||
58 | messenger_gtk_deps += [ | ||
59 | dependency('libportal'), | ||
60 | dependency('libportal-gtk3'), | ||
61 | ] | ||
62 | else | ||
63 | messenger_gtk_args += [ | ||
64 | '-DMESSENGER_APPLICATION_NO_PORTAL=1', | ||
65 | ] | ||
66 | endif | ||
67 | |||
51 | subdir('resources') | 68 | subdir('resources') |
52 | subdir('src') | 69 | subdir('src') |
53 | 70 | ||
54 | messenger_gtk_exec = executable( | 71 | messenger_gtk_exec = executable( |
55 | meson.project_name(), | 72 | meson.project_name(), |
56 | messenger_gtk_resources + messenger_gtk_sources, | 73 | messenger_gtk_resources + messenger_gtk_sources, |
57 | c_args : [ | 74 | c_args: messenger_gtk_args, |
58 | '-DMESSENGER_APPLICATION_BINARY="@0@"'.format(meson.project_name()), | ||
59 | '-DMESSENGER_APPLICATION_ID="@0@"'.format(messenger_gtk_id), | ||
60 | '-DMESSENGER_APPLICATION_VERSION="@0@"'.format(meson.project_version()), | ||
61 | ], | ||
62 | install: true, | 75 | install: true, |
63 | dependencies: messenger_gtk_deps, | 76 | dependencies: messenger_gtk_deps, |
64 | extra_files: submodules_headers, | 77 | extra_files: submodules_headers, |
diff --git a/src/application.c b/src/application.c index bea7209..dd8f93f 100644 --- a/src/application.c +++ b/src/application.c | |||
@@ -29,10 +29,13 @@ | |||
29 | #include <gstreamer-1.0/gst/gst.h> | 29 | #include <gstreamer-1.0/gst/gst.h> |
30 | #include <gtk-3.0/gtk/gtk.h> | 30 | #include <gtk-3.0/gtk/gtk.h> |
31 | #include <libhandy-1/handy.h> | 31 | #include <libhandy-1/handy.h> |
32 | #include <libportal-gtk3/portal-gtk3.h> | ||
33 | #include <libnotify/notify.h> | 32 | #include <libnotify/notify.h> |
34 | #include <pipewire/impl.h> | 33 | #include <pipewire/impl.h> |
35 | 34 | ||
35 | #ifndef MESSENGER_APPLICATION_NO_PORTAL | ||
36 | #include <libportal-gtk3/portal-gtk3.h> | ||
37 | #endif | ||
38 | |||
36 | static void | 39 | static void |
37 | _load_ui_stylesheets(MESSENGER_Application *app) | 40 | _load_ui_stylesheets(MESSENGER_Application *app) |
38 | { | 41 | { |
@@ -76,8 +79,10 @@ _application_init(MESSENGER_Application *app) | |||
76 | 79 | ||
77 | ui_messenger_init(app, &(app->ui.messenger)); | 80 | ui_messenger_init(app, &(app->ui.messenger)); |
78 | 81 | ||
82 | #ifndef MESSENGER_APPLICATION_NO_PORTAL | ||
79 | if (app->portal) | 83 | if (app->portal) |
80 | app->parent = xdp_parent_new_gtk(GTK_WINDOW(app->ui.messenger.main_window)); | 84 | app->parent = xdp_parent_new_gtk(GTK_WINDOW(app->ui.messenger.main_window)); |
85 | #endif | ||
81 | 86 | ||
82 | if (app->chat.identity) | 87 | if (app->chat.identity) |
83 | application_show_window(app); | 88 | application_show_window(app); |
@@ -257,6 +262,7 @@ application_init(MESSENGER_Application *app, | |||
257 | 262 | ||
258 | resources_register(); | 263 | resources_register(); |
259 | 264 | ||
265 | #ifndef MESSENGER_APPLICATION_NO_PORTAL | ||
260 | GError *error = NULL; | 266 | GError *error = NULL; |
261 | app->portal = xdp_portal_initable_new(&error); | 267 | app->portal = xdp_portal_initable_new(&error); |
262 | 268 | ||
@@ -265,6 +271,7 @@ application_init(MESSENGER_Application *app, | |||
265 | g_printerr("ERROR: %s\n", error->message); | 271 | g_printerr("ERROR: %s\n", error->message); |
266 | g_error_free(error); | 272 | g_error_free(error); |
267 | } | 273 | } |
274 | #endif | ||
268 | 275 | ||
269 | notify_init(MESSENGER_APPLICATION_NAME); | 276 | notify_init(MESSENGER_APPLICATION_NAME); |
270 | app->notifications = NULL; | 277 | app->notifications = NULL; |
@@ -479,31 +486,14 @@ application_run(MESSENGER_Application *app) | |||
479 | } | 486 | } |
480 | 487 | ||
481 | static void | 488 | static void |
482 | _request_background_callback(GObject *source_object, | 489 | _request_background_callback(MESSENGER_Application *app, |
483 | GAsyncResult *result, | 490 | gboolean success, |
491 | gboolean error, | ||
484 | gpointer user_data) | 492 | gpointer user_data) |
485 | { | 493 | { |
486 | g_assert((source_object) && (result) && (user_data)); | 494 | g_assert((app) && (user_data)); |
487 | |||
488 | XdpPortal *portal = XDP_PORTAL(source_object); | ||
489 | MESSENGER_Request *request = (MESSENGER_Request*) user_data; | ||
490 | |||
491 | request_cleanup(request); | ||
492 | |||
493 | gboolean *setting = (gboolean*) (request->user_data); | ||
494 | |||
495 | GError *error = NULL; | ||
496 | gboolean success = xdp_portal_request_background_finish( | ||
497 | portal, result, &error | ||
498 | ); | ||
499 | |||
500 | request_drop(request); | ||
501 | |||
502 | if (error) { | ||
503 | g_printerr("ERROR: %s\n", error->message); | ||
504 | g_error_free(error); | ||
505 | } | ||
506 | 495 | ||
496 | gboolean *setting = (gboolean*) user_data; | ||
507 | *setting = success; | 497 | *setting = success; |
508 | } | 498 | } |
509 | 499 | ||
@@ -644,10 +634,12 @@ application_exit(MESSENGER_Application *app, | |||
644 | // GNUnet handles of the application. | 634 | // GNUnet handles of the application. |
645 | write(app->chat.pipe[1], &signal, sizeof(signal)); | 635 | write(app->chat.pipe[1], &signal, sizeof(signal)); |
646 | 636 | ||
637 | #ifndef MESSENGER_APPLICATION_NO_PORTAL | ||
647 | if (app->portal) | 638 | if (app->portal) |
648 | g_object_unref(app->portal); | 639 | g_object_unref(app->portal); |
649 | 640 | ||
650 | app->portal = NULL; | 641 | app->portal = NULL; |
642 | #endif | ||
651 | 643 | ||
652 | if (app->pw.registry) | 644 | if (app->pw.registry) |
653 | pw_proxy_destroy((struct pw_proxy*) app->pw.registry); | 645 | pw_proxy_destroy((struct pw_proxy*) app->pw.registry); |
diff --git a/src/application.h b/src/application.h index 1195cfe..6f0ad72 100644 --- a/src/application.h +++ b/src/application.h | |||
@@ -25,7 +25,10 @@ | |||
25 | #ifndef APPLICATION_H_ | 25 | #ifndef APPLICATION_H_ |
26 | #define APPLICATION_H_ | 26 | #define APPLICATION_H_ |
27 | 27 | ||
28 | #ifndef MESSENGER_APPLICATION_NO_PORTAL | ||
28 | #include <libportal/portal.h> | 29 | #include <libportal/portal.h> |
30 | #endif | ||
31 | |||
29 | #include <pipewire/pipewire.h> | 32 | #include <pipewire/pipewire.h> |
30 | #include <pthread.h> | 33 | #include <pthread.h> |
31 | 34 | ||
@@ -75,8 +78,10 @@ typedef struct MESSENGER_Application | |||
75 | GList *requests; | 78 | GList *requests; |
76 | guint init; | 79 | guint init; |
77 | 80 | ||
81 | #ifndef MESSENGER_APPLICATION_NO_PORTAL | ||
78 | XdpPortal *portal; | 82 | XdpPortal *portal; |
79 | XdpParent *parent; | 83 | XdpParent *parent; |
84 | #endif | ||
80 | 85 | ||
81 | struct { | 86 | struct { |
82 | GQuark widget; | 87 | GQuark widget; |
diff --git a/src/request.c b/src/request.c index d35289e..a3a8107 100644 --- a/src/request.c +++ b/src/request.c | |||
@@ -24,8 +24,47 @@ | |||
24 | 24 | ||
25 | #include "request.h" | 25 | #include "request.h" |
26 | 26 | ||
27 | #ifdef MESSENGER_APPLICATION_NO_PORTAL | ||
28 | |||
29 | static gboolean | ||
30 | _request_timeout_call(gpointer user_data) | ||
31 | { | ||
32 | g_assert(user_data); | ||
33 | |||
34 | MESSENGER_Request* request = (MESSENGER_Request*) user_data; | ||
35 | |||
36 | MESSENGER_Application *app = request->application; | ||
37 | MESSENGER_RequestCallback callback = request->callback; | ||
38 | gpointer data = request->user_data; | ||
39 | |||
40 | request_cleanup(request); | ||
41 | request_drop(request); | ||
42 | |||
43 | if (callback) | ||
44 | callback(app, TRUE, FALSE, data); | ||
45 | |||
46 | return FALSE; | ||
47 | } | ||
48 | |||
49 | static void | ||
50 | _request_cancel_timeout(gpointer user_data) | ||
51 | { | ||
52 | g_assert(user_data); | ||
53 | |||
54 | MESSENGER_Request* request = (MESSENGER_Request*) user_data; | ||
55 | |||
56 | if (request->timeout) | ||
57 | g_source_remove(request->timeout); | ||
58 | |||
59 | request_cleanup(request); | ||
60 | request_drop(request); | ||
61 | } | ||
62 | |||
63 | #endif | ||
64 | |||
27 | MESSENGER_Request* | 65 | MESSENGER_Request* |
28 | request_new(MESSENGER_Application *application, | 66 | request_new(MESSENGER_Application *application, |
67 | MESSENGER_RequestCallback callback, | ||
29 | GCancellable *cancellable, | 68 | GCancellable *cancellable, |
30 | gpointer user_data) | 69 | gpointer user_data) |
31 | { | 70 | { |
@@ -34,9 +73,24 @@ request_new(MESSENGER_Application *application, | |||
34 | MESSENGER_Request* request = g_malloc(sizeof(MESSENGER_Request)); | 73 | MESSENGER_Request* request = g_malloc(sizeof(MESSENGER_Request)); |
35 | 74 | ||
36 | request->application = application; | 75 | request->application = application; |
76 | request->callback = callback; | ||
37 | request->cancellable = cancellable; | 77 | request->cancellable = cancellable; |
38 | request->user_data = user_data; | 78 | request->user_data = user_data; |
39 | 79 | ||
80 | #ifdef MESSENGER_APPLICATION_NO_PORTAL | ||
81 | request->timeout = g_timeout_add( | ||
82 | 0, G_SOURCE_FUNC(_request_timeout_call), request | ||
83 | ); | ||
84 | |||
85 | if (request->cancellable) | ||
86 | g_cancellable_connect ( | ||
87 | request->cancellable, | ||
88 | _request_cancel_timeout, | ||
89 | request, | ||
90 | NULL | ||
91 | ); | ||
92 | #endif | ||
93 | |||
40 | application->requests = g_list_append( | 94 | application->requests = g_list_append( |
41 | application->requests, | 95 | application->requests, |
42 | request | 96 | request |
@@ -45,10 +99,47 @@ request_new(MESSENGER_Application *application, | |||
45 | return request; | 99 | return request; |
46 | } | 100 | } |
47 | 101 | ||
102 | #ifndef MESSENGER_APPLICATION_NO_PORTAL | ||
103 | static void | ||
104 | _request_background_callback(GObject *source_object, | ||
105 | GAsyncResult *result, | ||
106 | gpointer user_data) | ||
107 | { | ||
108 | g_assert((source_object) && (result) && (user_data)); | ||
109 | |||
110 | XdpPortal *portal = XDP_PORTAL(source_object); | ||
111 | MESSENGER_Request *request = (MESSENGER_Request*) user_data; | ||
112 | |||
113 | request_cleanup(request); | ||
114 | |||
115 | MESSENGER_Application *app = request->application; | ||
116 | MESSENGER_RequestCallback callback = request->callback; | ||
117 | gpointer data = request->user_data; | ||
118 | |||
119 | GError *error = NULL; | ||
120 | gboolean success = xdp_portal_request_background_finish( | ||
121 | portal, result, &error | ||
122 | ); | ||
123 | |||
124 | request_drop(request); | ||
125 | |||
126 | gboolean error_value = false; | ||
127 | if (error) { | ||
128 | g_printerr("ERROR: %s\n", error->message); | ||
129 | g_error_free(error); | ||
130 | |||
131 | error_value = true; | ||
132 | } | ||
133 | |||
134 | if (callback) | ||
135 | callback(app, success, error_value, data); | ||
136 | } | ||
137 | #endif | ||
138 | |||
48 | MESSENGER_Request* | 139 | MESSENGER_Request* |
49 | request_new_background(MESSENGER_Application *application, | 140 | request_new_background(MESSENGER_Application *application, |
50 | XdpBackgroundFlags flags, | 141 | XdpBackgroundFlags flags, |
51 | GAsyncReadyCallback callback, | 142 | MESSENGER_RequestCallback callback, |
52 | gpointer user_data) | 143 | gpointer user_data) |
53 | { | 144 | { |
54 | g_assert((application) && (callback)); | 145 | g_assert((application) && (callback)); |
@@ -60,10 +151,12 @@ request_new_background(MESSENGER_Application *application, | |||
60 | 151 | ||
61 | MESSENGER_Request* request = request_new( | 152 | MESSENGER_Request* request = request_new( |
62 | application, | 153 | application, |
154 | callback, | ||
63 | cancellable, | 155 | cancellable, |
64 | user_data | 156 | user_data |
65 | ); | 157 | ); |
66 | 158 | ||
159 | #ifndef MESSENGER_APPLICATION_NO_PORTAL | ||
67 | xdp_portal_request_background( | 160 | xdp_portal_request_background( |
68 | application->portal, | 161 | application->portal, |
69 | application->parent, | 162 | application->parent, |
@@ -71,17 +164,55 @@ request_new_background(MESSENGER_Application *application, | |||
71 | NULL, | 164 | NULL, |
72 | flags, | 165 | flags, |
73 | cancellable, | 166 | cancellable, |
74 | callback, | 167 | _request_background_callback, |
75 | request | 168 | request |
76 | ); | 169 | ); |
170 | #endif | ||
77 | 171 | ||
78 | return request; | 172 | return request; |
79 | } | 173 | } |
80 | 174 | ||
175 | #ifndef MESSENGER_APPLICATION_NO_PORTAL | ||
176 | static void | ||
177 | _request_camera_callback(GObject *source_object, | ||
178 | GAsyncResult *result, | ||
179 | gpointer user_data) | ||
180 | { | ||
181 | g_assert((source_object) && (result) && (user_data)); | ||
182 | |||
183 | XdpPortal *portal = (XdpPortal*) source_object; | ||
184 | MESSENGER_Request *request = (MESSENGER_Request*) user_data; | ||
185 | |||
186 | request_cleanup(request); | ||
187 | |||
188 | MESSENGER_Application *app = request->application; | ||
189 | MESSENGER_RequestCallback callback = request->callback; | ||
190 | gpointer data = request->user_data; | ||
191 | |||
192 | GError *error = NULL; | ||
193 | gboolean success = xdp_portal_access_camera_finish( | ||
194 | portal, result, &error | ||
195 | ); | ||
196 | |||
197 | request_drop(request); | ||
198 | |||
199 | gboolean error_value = false; | ||
200 | if (error) { | ||
201 | g_printerr("ERROR: %s\n", error->message); | ||
202 | g_error_free(error); | ||
203 | |||
204 | error_value = true; | ||
205 | } | ||
206 | |||
207 | if (callback) | ||
208 | callback(app, success, error_value, data); | ||
209 | } | ||
210 | #endif | ||
211 | |||
81 | MESSENGER_Request* | 212 | MESSENGER_Request* |
82 | request_new_camera(MESSENGER_Application *application, | 213 | request_new_camera(MESSENGER_Application *application, |
83 | XdpCameraFlags flags, | 214 | XdpCameraFlags flags, |
84 | GAsyncReadyCallback callback, | 215 | MESSENGER_RequestCallback callback, |
85 | gpointer user_data) | 216 | gpointer user_data) |
86 | { | 217 | { |
87 | g_assert((application) && (callback)); | 218 | g_assert((application) && (callback)); |
@@ -93,18 +224,21 @@ request_new_camera(MESSENGER_Application *application, | |||
93 | 224 | ||
94 | MESSENGER_Request* request = request_new( | 225 | MESSENGER_Request* request = request_new( |
95 | application, | 226 | application, |
227 | callback, | ||
96 | cancellable, | 228 | cancellable, |
97 | user_data | 229 | user_data |
98 | ); | 230 | ); |
99 | 231 | ||
232 | #ifndef MESSENGER_APPLICATION_NO_PORTAL | ||
100 | xdp_portal_access_camera( | 233 | xdp_portal_access_camera( |
101 | application->portal, | 234 | application->portal, |
102 | application->parent, | 235 | application->parent, |
103 | flags, | 236 | flags, |
104 | cancellable, | 237 | cancellable, |
105 | callback, | 238 | _request_camera_callback, |
106 | request | 239 | request |
107 | ); | 240 | ); |
241 | #endif | ||
108 | 242 | ||
109 | return request; | 243 | return request; |
110 | } | 244 | } |
diff --git a/src/request.h b/src/request.h index 18507ae..91789ab 100644 --- a/src/request.h +++ b/src/request.h | |||
@@ -26,14 +26,39 @@ | |||
26 | #define REQUEST_H_ | 26 | #define REQUEST_H_ |
27 | 27 | ||
28 | #include <gio/gio.h> | 28 | #include <gio/gio.h> |
29 | |||
30 | #ifndef MESSENGER_APPLICATION_NO_PORTAL | ||
29 | #include <libportal/portal.h> | 31 | #include <libportal/portal.h> |
32 | #else | ||
33 | typedef enum XdpBackgroundFlags { | ||
34 | XDP_BACKGROUND_FLAG_ACTIVATABLE = 1, | ||
35 | XDP_BACKGROUND_FLAG_AUTOSTART = 2, | ||
36 | XDP_BACKGROUND_FLAG_NONE = 0, | ||
37 | } XdpBackgroundFlags; | ||
38 | |||
39 | typedef enum XdpCameraFlags { | ||
40 | XDP_CAMERA_FLAG_NONE = 0, | ||
41 | } XdpCameraFlags; | ||
42 | #endif | ||
30 | 43 | ||
31 | #include "application.h" | 44 | #include "application.h" |
32 | 45 | ||
46 | typedef void (*MESSENGER_RequestCallback)( | ||
47 | MESSENGER_Application *application, | ||
48 | gboolean success, | ||
49 | gboolean error, | ||
50 | gpointer user_data | ||
51 | ); | ||
52 | |||
33 | typedef struct MESSENGER_Request { | 53 | typedef struct MESSENGER_Request { |
34 | MESSENGER_Application *application; | 54 | MESSENGER_Application *application; |
55 | MESSENGER_RequestCallback callback; | ||
35 | GCancellable *cancellable; | 56 | GCancellable *cancellable; |
36 | gpointer user_data; | 57 | gpointer user_data; |
58 | |||
59 | #ifdef MESSENGER_APPLICATION_NO_PORTAL | ||
60 | guint timeout; | ||
61 | #endif | ||
37 | } MESSENGER_Request; | 62 | } MESSENGER_Request; |
38 | 63 | ||
39 | /** | 64 | /** |
@@ -50,6 +75,7 @@ typedef struct MESSENGER_Request { | |||
50 | */ | 75 | */ |
51 | MESSENGER_Request* | 76 | MESSENGER_Request* |
52 | request_new(MESSENGER_Application *application, | 77 | request_new(MESSENGER_Application *application, |
78 | MESSENGER_RequestCallback callback, | ||
53 | GCancellable *cancellable, | 79 | GCancellable *cancellable, |
54 | gpointer user_data); | 80 | gpointer user_data); |
55 | 81 | ||
@@ -66,7 +92,7 @@ request_new(MESSENGER_Application *application, | |||
66 | MESSENGER_Request* | 92 | MESSENGER_Request* |
67 | request_new_background(MESSENGER_Application *application, | 93 | request_new_background(MESSENGER_Application *application, |
68 | XdpBackgroundFlags flags, | 94 | XdpBackgroundFlags flags, |
69 | GAsyncReadyCallback callback, | 95 | MESSENGER_RequestCallback callback, |
70 | gpointer user_data); | 96 | gpointer user_data); |
71 | 97 | ||
72 | /** | 98 | /** |
@@ -82,7 +108,7 @@ request_new_background(MESSENGER_Application *application, | |||
82 | MESSENGER_Request* | 108 | MESSENGER_Request* |
83 | request_new_camera(MESSENGER_Application *application, | 109 | request_new_camera(MESSENGER_Application *application, |
84 | XdpCameraFlags flags, | 110 | XdpCameraFlags flags, |
85 | GAsyncReadyCallback callback, | 111 | MESSENGER_RequestCallback callback, |
86 | gpointer user_data); | 112 | gpointer user_data); |
87 | 113 | ||
88 | /** | 114 | /** |
diff --git a/src/ui/messenger.c b/src/ui/messenger.c index 84c7ea3..f4d54c3 100644 --- a/src/ui/messenger.c +++ b/src/ui/messenger.c | |||
@@ -362,10 +362,12 @@ handle_main_window_destroy(UNUSED GtkWidget *window, | |||
362 | 362 | ||
363 | MESSENGER_Application *app = (MESSENGER_Application*) user_data; | 363 | MESSENGER_Application *app = (MESSENGER_Application*) user_data; |
364 | 364 | ||
365 | #ifndef MESSENGER_APPLICATION_NO_PORTAL | ||
365 | if (app->parent) | 366 | if (app->parent) |
366 | xdp_parent_free(app->parent); | 367 | xdp_parent_free(app->parent); |
367 | 368 | ||
368 | app->parent = NULL; | 369 | app->parent = NULL; |
370 | #endif | ||
369 | 371 | ||
370 | ui_messenger_cleanup(&(app->ui.messenger)); | 372 | ui_messenger_cleanup(&(app->ui.messenger)); |
371 | ui_accounts_dialog_cleanup(&(app->ui.accounts)); | 373 | ui_accounts_dialog_cleanup(&(app->ui.accounts)); |
diff --git a/src/ui/new_contact.c b/src/ui/new_contact.c index 317957d..9c10ca0 100644 --- a/src/ui/new_contact.c +++ b/src/ui/new_contact.c | |||
@@ -382,7 +382,11 @@ _init_camera_pipeline(MESSENGER_Application *app, | |||
382 | 382 | ||
383 | handle->camera_count = 0; | 383 | handle->camera_count = 0; |
384 | 384 | ||
385 | #ifndef MESSENGER_APPLICATION_NO_PORTAL | ||
385 | if ((app->portal) && ((access) || xdp_portal_is_camera_present(app->portal))) | 386 | if ((app->portal) && ((access) || xdp_portal_is_camera_present(app->portal))) |
387 | #else | ||
388 | if (access) | ||
389 | #endif | ||
386 | { | 390 | { |
387 | app->pw.pending = pw_core_sync(app->pw.core, 0, 0); | 391 | app->pw.pending = pw_core_sync(app->pw.core, 0, 0); |
388 | 392 | ||
@@ -407,31 +411,14 @@ _init_camera_pipeline(MESSENGER_Application *app, | |||
407 | } | 411 | } |
408 | 412 | ||
409 | static void | 413 | static void |
410 | _request_camera_callback(GObject *source_object, | 414 | _request_camera_callback(MESSENGER_Application *app, |
411 | GAsyncResult *result, | 415 | gboolean success, |
416 | gboolean error, | ||
412 | gpointer user_data) | 417 | gpointer user_data) |
413 | { | 418 | { |
414 | g_assert((source_object) && (result) && (user_data)); | 419 | g_assert((app) && (user_data)); |
415 | 420 | ||
416 | XdpPortal *portal = (XdpPortal*) source_object; | 421 | UI_NEW_CONTACT_Handle *handle = (UI_NEW_CONTACT_Handle*) user_data; |
417 | MESSENGER_Request *request = (MESSENGER_Request*) user_data; | ||
418 | |||
419 | request_cleanup(request); | ||
420 | |||
421 | MESSENGER_Application *app = request->application; | ||
422 | UI_NEW_CONTACT_Handle *handle = (UI_NEW_CONTACT_Handle*) request->user_data; | ||
423 | |||
424 | GError *error = NULL; | ||
425 | gboolean success = xdp_portal_access_camera_finish( | ||
426 | portal, result, &error | ||
427 | ); | ||
428 | |||
429 | request_drop(request); | ||
430 | |||
431 | if (error) { | ||
432 | g_printerr("ERROR: %s\n", error->message); | ||
433 | g_error_free(error); | ||
434 | } | ||
435 | 422 | ||
436 | _init_camera_pipeline(app, handle, success); | 423 | _init_camera_pipeline(app, handle, success); |
437 | } | 424 | } |
@@ -446,7 +433,11 @@ ui_new_contact_dialog_init(MESSENGER_Application *app, | |||
446 | 433 | ||
447 | _setup_gst_pipeline(handle); | 434 | _setup_gst_pipeline(handle); |
448 | 435 | ||
436 | #ifndef MESSENGER_APPLICATION_NO_PORTAL | ||
449 | if (app->portal) | 437 | if (app->portal) |
438 | #else | ||
439 | if (FALSE) | ||
440 | #endif | ||
450 | { | 441 | { |
451 | request_new_camera( | 442 | request_new_camera( |
452 | app, | 443 | app, |
diff --git a/src/ui/settings.c b/src/ui/settings.c index 6589778..7855902 100644 --- a/src/ui/settings.c +++ b/src/ui/settings.c | |||
@@ -29,7 +29,10 @@ | |||
29 | 29 | ||
30 | #include <gnunet/gnunet_chat_lib.h> | 30 | #include <gnunet/gnunet_chat_lib.h> |
31 | #include <gnunet/gnunet_common.h> | 31 | #include <gnunet/gnunet_common.h> |
32 | |||
33 | #ifndef MESSENGER_APPLICATION_NO_PORTAL | ||
32 | #include <libportal/background.h> | 34 | #include <libportal/background.h> |
35 | #endif | ||
33 | 36 | ||
34 | static gboolean | 37 | static gboolean |
35 | handle_general_switch_state(UNUSED GtkSwitch *widget, | 38 | handle_general_switch_state(UNUSED GtkSwitch *widget, |
@@ -44,31 +47,16 @@ handle_general_switch_state(UNUSED GtkSwitch *widget, | |||
44 | } | 47 | } |
45 | 48 | ||
46 | static void | 49 | static void |
47 | _request_background_callback(GObject *source_object, | 50 | _request_background_callback(MESSENGER_Application *app, |
48 | GAsyncResult *result, | 51 | gboolean success, |
52 | gboolean error, | ||
49 | gpointer user_data) | 53 | gpointer user_data) |
50 | { | 54 | { |
51 | g_assert((source_object) && (result) && (user_data)); | 55 | g_assert((app) && (user_data)); |
52 | |||
53 | XdpPortal *portal = XDP_PORTAL(source_object); | ||
54 | MESSENGER_Request *request = (MESSENGER_Request*) user_data; | ||
55 | 56 | ||
56 | request_cleanup(request); | 57 | GtkSwitch *widget = GTK_SWITCH(user_data); |
57 | |||
58 | MESSENGER_Application *app = request->application; | ||
59 | GtkSwitch *widget = GTK_SWITCH(request->user_data); | ||
60 | |||
61 | GError *error = NULL; | ||
62 | gboolean success = xdp_portal_request_background_finish( | ||
63 | portal, result, &error | ||
64 | ); | ||
65 | |||
66 | request_drop(request); | ||
67 | 58 | ||
68 | if (error) { | 59 | if (error) { |
69 | g_printerr("ERROR: %s\n", error->message); | ||
70 | g_error_free(error); | ||
71 | |||
72 | gtk_widget_set_sensitive(GTK_WIDGET(widget), !success); | 60 | gtk_widget_set_sensitive(GTK_WIDGET(widget), !success); |
73 | gtk_switch_set_active(widget, success); | 61 | gtk_switch_set_active(widget, success); |
74 | return; | 62 | return; |