mirror of
https://github.com/hyprwm/xdg-desktop-portal-hyprland.git
synced 2024-11-22 06:35:57 +01:00
Add missing request.c
Fixes https://github.com/emersion/xdg-desktop-portal-wlr/issues/3
This commit is contained in:
parent
2b659c42a7
commit
74ee43cf37
1 changed files with 43 additions and 0 deletions
43
request.c
Normal file
43
request.c
Normal file
|
@ -0,0 +1,43 @@
|
||||||
|
#include <errno.h>
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <string.h>
|
||||||
|
#include "xdpw.h"
|
||||||
|
|
||||||
|
static const char interface_name[] = "org.freedesktop.impl.portal.Request";
|
||||||
|
|
||||||
|
static int method_close(sd_bus_message *msg, void *data,
|
||||||
|
sd_bus_error *ret_error) {
|
||||||
|
// struct xdpw_request *req = data;
|
||||||
|
// TODO
|
||||||
|
printf("Request.Close\n");
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
static const sd_bus_vtable request_vtable[] = {
|
||||||
|
SD_BUS_VTABLE_START(0),
|
||||||
|
SD_BUS_METHOD("Close", "", "", method_close, SD_BUS_VTABLE_UNPRIVILEGED),
|
||||||
|
SD_BUS_VTABLE_END
|
||||||
|
};
|
||||||
|
|
||||||
|
struct xdpw_request *request_create(sd_bus *bus, const char *object_path) {
|
||||||
|
struct xdpw_request *req = calloc(1, sizeof(struct xdpw_request));
|
||||||
|
|
||||||
|
if (sd_bus_add_object_vtable(bus, &req->slot, object_path, interface_name,
|
||||||
|
request_vtable, NULL) < 0) {
|
||||||
|
free(req);
|
||||||
|
fprintf(stderr, "sd_bus_add_object_vtable failed: %s\n",
|
||||||
|
strerror(-errno));
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
return req;
|
||||||
|
}
|
||||||
|
|
||||||
|
void request_destroy(struct xdpw_request *req) {
|
||||||
|
if (req == NULL) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
sd_bus_slot_unref(req->slot);
|
||||||
|
free(req);
|
||||||
|
}
|
Loading…
Reference in a new issue