summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKristian Høgsberg <krh@bitplanet.net>2011-09-01 09:53:33 -0400
committerKristian Høgsberg <krh@bitplanet.net>2011-09-01 09:53:33 -0400
commit25fddf65a8df409195616b308051d7e426cfa97a (patch)
tree603a8be8bb9ecd9a10993123e732e7856fb7b94e
parentc640571c00b0c1ffafb05b1ad5cd02cd511cb06a (diff)
server: Make error posting functions take a resource instead of a client
-rw-r--r--src/wayland-server.c53
-rw-r--r--src/wayland-server.h4
-rw-r--r--src/wayland-shm.c22
3 files changed, 39 insertions, 40 deletions
diff --git a/src/wayland-server.c b/src/wayland-server.c
index fbf413b..df6b769 100644
--- a/src/wayland-server.c
+++ b/src/wayland-server.c
@@ -109,9 +109,10 @@ wl_resource_post_event(struct wl_resource *resource, uint32_t opcode, ...)
}
WL_EXPORT void
-wl_client_post_error(struct wl_client *client, struct wl_object *object,
- uint32_t code, const char *msg, ...)
+wl_resource_post_error(struct wl_resource *resource,
+ uint32_t code, const char *msg, ...)
{
+ struct wl_client *client = resource->client;
char buffer[128];
va_list ap;
@@ -121,7 +122,7 @@ wl_client_post_error(struct wl_client *client, struct wl_object *object,
client->error = 1;
wl_resource_post_event(client->display_resource,
- WL_DISPLAY_ERROR, object, code, buffer);
+ WL_DISPLAY_ERROR, resource, code, buffer);
}
static int
@@ -157,19 +158,19 @@ wl_client_connection_data(int fd, uint32_t mask, void *data)
resource = wl_map_lookup(&client->objects, p[0]);
if (resource == NULL) {
- wl_client_post_error(client, &resource->object,
- WL_DISPLAY_ERROR_INVALID_OBJECT,
- "invalid object %d", p[0]);
+ wl_resource_post_error(resource,
+ WL_DISPLAY_ERROR_INVALID_OBJECT,
+ "invalid object %d", p[0]);
break;
}
object = &resource->object;
if (opcode >= object->interface->method_count) {
- wl_client_post_error(client, &resource->object,
- WL_DISPLAY_ERROR_INVALID_METHOD,
- "invalid method %d, object %s@%d",
- object->interface->name,
- object->id, opcode);
+ wl_resource_post_error(resource,
+ WL_DISPLAY_ERROR_INVALID_METHOD,
+ "invalid method %d, object %s@%d",
+ object->interface->name,
+ object->id, opcode);
break;
}
@@ -179,15 +180,15 @@ wl_client_connection_data(int fd, uint32_t mask, void *data)
len -= size;
if (closure == NULL && errno == EINVAL) {
- wl_client_post_error(client, &resource->object,
- WL_DISPLAY_ERROR_INVALID_METHOD,
- "invalid arguments for %s@%d.%s",
- object->interface->name,
- object->id,
- message->name);
+ wl_resource_post_error(resource,
+ WL_DISPLAY_ERROR_INVALID_METHOD,
+ "invalid arguments for %s@%d.%s",
+ object->interface->name,
+ object->id,
+ message->name);
break;
} else if (closure == NULL && errno == ENOMEM) {
- wl_client_post_no_memory(client);
+ wl_resource_post_no_memory(resource);
break;
}
@@ -288,10 +289,10 @@ wl_client_add_resource(struct wl_client *client,
}
WL_EXPORT void
-wl_client_post_no_memory(struct wl_client *client)
+wl_resource_post_no_memory(struct wl_resource *resource)
{
- wl_client_post_error(client, &client->display_resource->object,
- WL_DISPLAY_ERROR_NO_MEMORY, "no memory");
+ wl_resource_post_error(resource->client->display_resource,
+ WL_DISPLAY_ERROR_NO_MEMORY, "no memory");
}
static void
@@ -526,9 +527,9 @@ display_bind(struct wl_client *client,
break;
if (&global->link == &display->global_list)
- wl_client_post_error(client, &resource->object,
- WL_DISPLAY_ERROR_INVALID_OBJECT,
- "invalid global %d", name);
+ wl_resource_post_error(resource,
+ WL_DISPLAY_ERROR_INVALID_OBJECT,
+ "invalid global %d", name);
else
global->bind(client, global->data, version, id);
}
@@ -826,7 +827,7 @@ wl_client_add_object(struct wl_client *client,
resource = malloc(sizeof *resource);
if (resource == NULL) {
- wl_client_post_no_memory(client);
+ wl_resource_post_no_memory(client->display_resource);
return NULL;
}
@@ -839,7 +840,7 @@ wl_client_add_object(struct wl_client *client,
wl_list_init(&resource->destroy_listener_list);
if (wl_map_insert_at(&client->objects, resource->object.id, resource) < 0) {
- wl_client_post_no_memory(client);
+ wl_resource_post_no_memory(client->display_resource);
free(resource);
return NULL;
}
diff --git a/src/wayland-server.h b/src/wayland-server.h
index 95b44c1..afd3e69 100644
--- a/src/wayland-server.h
+++ b/src/wayland-server.h
@@ -98,9 +98,6 @@ void wl_display_remove_global(struct wl_display *display,
struct wl_client *wl_client_create(struct wl_display *display, int fd);
void wl_client_destroy(struct wl_client *client);
-void wl_client_post_error(struct wl_client *client, struct wl_object *object,
- uint32_t code, const char *msg, ...);
-void wl_client_post_no_memory(struct wl_client *client);
void wl_client_flush(struct wl_client *client);
struct wl_resource *
@@ -221,6 +218,7 @@ void wl_resource_post_event(struct wl_resource *resource,
uint32_t opcode, ...);
void wl_resource_post_error(struct wl_resource *resource,
uint32_t code, const char *msg, ...);
+void wl_resource_post_no_memory(struct wl_resource *resource);
int
wl_display_set_compositor(struct wl_display *display,
diff --git a/src/wayland-shm.c b/src/wayland-shm.c
index b2a873d..c6020ae 100644
--- a/src/wayland-shm.c
+++ b/src/wayland-shm.c
@@ -128,18 +128,18 @@ shm_create_buffer(struct wl_client *client, struct wl_resource *resource,
case WL_SHM_FORMAT_XRGB32:
break;
default:
- wl_client_post_error(client, &resource->object,
- WL_SHM_ERROR_INVALID_FORMAT,
- "invalid format");
+ wl_resource_post_error(resource,
+ WL_SHM_ERROR_INVALID_FORMAT,
+ "invalid format");
close(fd);
return;
}
if (width < 0 || height < 0 || stride < width) {
- wl_client_post_error(client, &resource->object,
- WL_SHM_ERROR_INVALID_STRIDE,
- "invalid width, height or stride (%dx%d, %u)",
- width, height, stride);
+ wl_resource_post_error(resource,
+ WL_SHM_ERROR_INVALID_STRIDE,
+ "invalid width, height or stride (%dx%d, %u)",
+ width, height, stride);
close(fd);
return;
}
@@ -149,9 +149,9 @@ shm_create_buffer(struct wl_client *client, struct wl_resource *resource,
close(fd);
if (data == MAP_FAILED) {
- wl_client_post_error(client, &resource->object,
- WL_SHM_ERROR_INVALID_FD,
- "failed mmap fd %d", fd);
+ wl_resource_post_error(resource,
+ WL_SHM_ERROR_INVALID_FD,
+ "failed mmap fd %d", fd);
return;
}
@@ -159,7 +159,7 @@ shm_create_buffer(struct wl_client *client, struct wl_resource *resource,
width, height, stride, format, data);
if (buffer == NULL) {
munmap(data, stride * height);
- wl_client_post_no_memory(client);
+ wl_resource_post_no_memory(resource);
return;
}