necouchman commented on a change in pull request #243: GUACAMOLE-249: Migrate 
to FreeRDP 2.x
URL: https://github.com/apache/guacamole-server/pull/243#discussion_r364476956
 
 

 ##########
 File path: src/protocols/rdp/channels/pipe-svc.c
 ##########
 @@ -0,0 +1,230 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+#include "channels/common-svc.h"
+#include "channels/pipe-svc.h"
+#include "common/list.h"
+#include "rdp.h"
+
+#include <freerdp/settings.h>
+#include <guacamole/client.h>
+#include <guacamole/protocol.h>
+#include <guacamole/socket.h>
+#include <guacamole/stream.h>
+#include <guacamole/user.h>
+#include <winpr/stream.h>
+
+#include <stdlib.h>
+#include <string.h>
+
+void guac_rdp_pipe_svc_send_pipe(guac_socket* socket, guac_rdp_pipe_svc* 
pipe_svc) {
+
+    /* Send pipe instruction for the SVC's output stream */
+    guac_protocol_send_pipe(socket, pipe_svc->output_pipe,
+            "application/octet-stream", pipe_svc->svc->name);
+
+}
+
+void guac_rdp_pipe_svc_send_pipes(guac_user* user) {
+
+    guac_client* client = user->client;
+    guac_rdp_client* rdp_client = (guac_rdp_client*) client->data;
+
+    guac_common_list_lock(rdp_client->available_svc);
+
+    /* Send pipe for each allocated SVC's output stream */
+    guac_common_list_element* current = rdp_client->available_svc->head;
+    while (current != NULL) {
+        guac_rdp_pipe_svc_send_pipe(user->socket, (guac_rdp_pipe_svc*) 
current->data);
+        current = current->next;
+    }
+
+    guac_common_list_unlock(rdp_client->available_svc);
+
+}
+
+void guac_rdp_pipe_svc_add(guac_client* client, guac_rdp_pipe_svc* pipe_svc) {
+
+    guac_rdp_client* rdp_client = (guac_rdp_client*) client->data;
+
+    /* Add to list of available SVC */
+    guac_common_list_lock(rdp_client->available_svc);
+    guac_common_list_add(rdp_client->available_svc, pipe_svc);
+    guac_common_list_unlock(rdp_client->available_svc);
+
+}
+
+guac_rdp_pipe_svc* guac_rdp_pipe_svc_get(guac_client* client, const char* 
name) {
+
+    guac_rdp_client* rdp_client = (guac_rdp_client*) client->data;
+    guac_common_list_element* current;
+    guac_rdp_pipe_svc* found = NULL;
+
+    /* For each available SVC */
+    guac_common_list_lock(rdp_client->available_svc);
+    current = rdp_client->available_svc->head;
+    while (current != NULL) {
+
+        /* If name matches, found */
+        guac_rdp_pipe_svc* current_svc = (guac_rdp_pipe_svc*) current->data;
+        if (strcmp(current_svc->svc->name, name) == 0) {
+            found = current_svc;
+            break;
+        }
+
+        current = current->next;
+
+    }
+    guac_common_list_unlock(rdp_client->available_svc);
+
+    return found;
+
+}
+
+guac_rdp_pipe_svc* guac_rdp_pipe_svc_remove(guac_client* client, const char* 
name) {
+
+    guac_rdp_client* rdp_client = (guac_rdp_client*) client->data;
+    guac_common_list_element* current;
+    guac_rdp_pipe_svc* found = NULL;
+
+    /* For each available SVC */
+    guac_common_list_lock(rdp_client->available_svc);
+    current = rdp_client->available_svc->head;
+    while (current != NULL) {
+
+        /* If name matches, remove entry */
+        guac_rdp_pipe_svc* current_svc = (guac_rdp_pipe_svc*) current->data;
+        if (strcmp(current_svc->svc->name, name) == 0) {
+            guac_common_list_remove(rdp_client->available_svc, current);
+            found = current_svc;
+            break;
+        }
+
+        current = current->next;
+
+    }
+    guac_common_list_unlock(rdp_client->available_svc);
+
+    /* Return removed entry, if any */
+    return found;
+
+}
+
+int guac_rdp_pipe_svc_pipe_handler(guac_user* user, guac_stream* stream,
+        char* mimetype, char* name) {
+
+    guac_rdp_pipe_svc* pipe_svc = guac_rdp_pipe_svc_get(user->client, name);
+
+    /* Fail if no such SVC */
+    if (pipe_svc == NULL) {
+        guac_user_log(user, GUAC_LOG_WARNING, "User requested non-existent "
+                "pipe (no such SVC configured): \"%s\"", name);
+        guac_protocol_send_ack(user->socket, stream, "FAIL (NO SUCH PIPE)",
+                GUAC_PROTOCOL_STATUS_CLIENT_BAD_REQUEST);
+        guac_socket_flush(user->socket);
+        return 0;
 
 Review comment:
   I assume returning 0 here, and in the other handlers, is the expected 
behavior??

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
[email protected]


With regards,
Apache Git Services

Reply via email to