summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMihai Moldovan <ionic@ionic.de>2023-07-20 02:54:58 +0200
committerMike Gabriel <mike.gabriel@das-netzwerkteam.de>2023-09-15 21:17:29 +0200
commit685e6c3f471c226b43464212238731c7a86dbe99 (patch)
treeaf32a411c69dbf51b07a7a324936fafec6031f90 /src
parentfa330e8b9844e838fa8a8e1d01ab9d72d61e6bce (diff)
downloadlibrda-685e6c3f471c226b43464212238731c7a86dbe99.tar.gz
librda-685e6c3f471c226b43464212238731c7a86dbe99.tar.bz2
librda-685e6c3f471c226b43464212238731c7a86dbe99.zip
src/rda_x2go.{c,h}: add generic protocol support.
X2Go supports both NX and KDrive sessions, so parse the session ID (X2GO_SESSION) to find out what protocol the session uses.
Diffstat (limited to 'src')
-rw-r--r--src/rda_x2go.c86
-rw-r--r--src/rda_x2go.h6
2 files changed, 91 insertions, 1 deletions
diff --git a/src/rda_x2go.c b/src/rda_x2go.c
index 7b8cb6c..76f7652 100644
--- a/src/rda_x2go.c
+++ b/src/rda_x2go.c
@@ -25,18 +25,102 @@
#include <glib/gi18n.h>
#include <rda.h>
+#include <rda_protocol.h>
+#include <rda_util.h>
#ifdef WITH_REMOTE_AWARENESS_X2GO
+const rda_protocol_t
+rda_supported_protocols_x2go[] = { RDA_PROTOCOL_NX, RDA_PROTOCOL_KDRIVE };
+const gsize
+rda_supported_protocols_x2go_len = static_arr_size(rda_supported_protocols_x2go);
+
+static gboolean
+rda_x2go_session_is_kdrive (const gchar *session_id)
+{
+ gboolean ret = FALSE;
+ const gchar *ptr = session_id;
+
+ /* Sanity check. */
+ if (!(ptr))
+ {
+ return (ret);
+ }
+
+ /* Skip user name. */
+ while ((ptr) && (*(ptr)) && ('-' != (*(ptr))))
+ {
+ ++ptr;
+ }
+
+ if ((!(ptr)) || (!(*(ptr++))))
+ {
+ return (ret);
+ }
+
+ /* Skip port. */
+ while ((ptr) && (*(ptr)) && ('-' != (*(ptr))))
+ {
+ ++ptr;
+ }
+
+ if ((!(ptr)) || (!(*(ptr++))))
+ {
+ return (ret);
+ }
+
+ /* Skip date. */
+ while ((ptr) && (*(ptr)) && ('_' != (*(ptr))))
+ {
+ ++ptr;
+ }
+
+ if ((!(ptr)) || (!(*(ptr++))))
+ {
+ return (ret);
+ }
+
+ /* Don't supply a null pointer to strncmp() by accident. */
+ if (!(ptr))
+ {
+ return (ret);
+ }
+
+ /* Check for "st". */
+ if (!(strncmp("st", ptr, 2)))
+ {
+ ptr += 2;
+
+ /*
+ * Next character must be 'K' for KDrive sessions.
+ * Note that this might change in future versions.
+ */
+ if ((ptr) && ('K' == (*(ptr))))
+ {
+ ret = TRUE;
+ }
+ }
+
+ return (ret);
+}
+
gboolean
rda_session_is_x2go (void)
{
if (remote_technology == REMOTE_TECHNOLOGY_X2GO)
return TRUE;
- if (g_getenv("X2GO_SESSION"))
+ const gchar *session_id = g_getenv("X2GO_SESSION");
+ if (session_id)
{
remote_technology = REMOTE_TECHNOLOGY_X2GO;
+ rda_protocol = RDA_PROTOCOL_NX;
+
+ if (rda_x2go_session_is_kdrive(session_id))
+ {
+ rda_protocol = RDA_PROTOCOL_KDRIVE;
+ }
+
return TRUE;
}
diff --git a/src/rda_x2go.h b/src/rda_x2go.h
index 5759e79..fc9c986 100644
--- a/src/rda_x2go.h
+++ b/src/rda_x2go.h
@@ -27,9 +27,15 @@
#include <glib.h>
#include <rda.h>
+#include <rda_protocol.h>
#ifdef WITH_REMOTE_AWARENESS_X2GO
+extern const rda_protocol_t
+rda_supported_protocols_x2go[];
+extern const gsize
+rda_supported_protocols_x2go_len;
+
gboolean
rda_session_is_x2go (void);