From f4f4e04e0e921ff653a67dac37c620d945317e82 Mon Sep 17 00:00:00 2001 From: Michael Jumper Date: Thu, 6 Sep 2012 20:37:16 -0700 Subject: [PATCH] Call accept/reject handler of associated resource if resource is valid. --- libguac/src/client-handlers.c | 37 +++++++++++++++++++++++++++++++---- 1 file changed, 33 insertions(+), 4 deletions(-) diff --git a/libguac/src/client-handlers.c b/libguac/src/client-handlers.c index f7397041..459b6d47 100644 --- a/libguac/src/client-handlers.c +++ b/libguac/src/client-handlers.c @@ -123,12 +123,41 @@ int __guac_handle_disconnect(guac_client* client, guac_instruction* instruction) } int __guac_handle_accept(guac_client* client, guac_instruction* instruction) { - /* STUB */ - return -1; + + /* Get index, check validity */ + int index = __guac_parse_int(instruction->argv[0]); + if (index < client->__available_resource_slots) { + + /* Build parameters */ + char* mimetype = instruction->argv[1]; + guac_resource* resource = client->__resource_map[index]; + + /* If accept handler defined, call it */ + if (resource->accept_handler) + return resource->accept_handler(resource, mimetype); + + } + + /* Ignore invalid indices */ + return 0; + } int __guac_handle_reject(guac_client* client, guac_instruction* instruction) { - /* STUB */ - return -1; + + /* Get index, check validity */ + int index = __guac_parse_int(instruction->argv[0]); + if (index < client->__available_resource_slots) { + + /* Build parameters */ + guac_resource* resource = client->__resource_map[index]; + + /* If reject handler defined, call it */ + if (resource->reject_handler) + return resource->reject_handler(resource); + + } + + return 0; }