aboutsummaryrefslogtreecommitdiff
path: root/debian/patches/105_nxagent_export-remote-keyboard-config.patch
blob: ec8575efb57b120cb21fda4c37491288d2b90c71 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
#! /bin/sh /usr/share/dpatch/dpatch-run
## 93_export_remote_keyboar_config.dpatch by  <marceloshima@gmail.com>
##
## All lines beginning with `## DP:' are a description of the patch.
## DP: Export the client keyboard configurations to a file

--- a/nx-X11/programs/Xserver/hw/nxagent/Error.c
+++ b/nx-X11/programs/Xserver/hw/nxagent/Error.c
@@ -497,7 +497,7 @@
   return rootPath;
 }
 
-char *nxagentGetSessionPath()
+char *nxagentGetSessionPath(void)
 {
 
   char *rootPath;
--- a/nx-X11/programs/Xserver/hw/nxagent/Error.h
+++ b/nx-X11/programs/Xserver/hw/nxagent/Error.h
@@ -34,4 +34,6 @@
 
 void nxagentEndRedirectToClientsLog(void);
 
+char *nxagentGetSessionPath(void);
+
 #endif /* __Error_H__ */
--- a/nx-X11/programs/Xserver/hw/nxagent/Keyboard.c
+++ b/nx-X11/programs/Xserver/hw/nxagent/Keyboard.c
@@ -52,6 +52,7 @@
 #include "Keyboard.h"
 #include "Events.h"
 #include "Options.h"
+#include "Error.h"
 
 #include "NXlib.h"
 
@@ -1790,6 +1791,42 @@
   }
   #endif
 
+  if (drulesLen != 0)
+  {
+    char *sessionpath = nxagentGetSessionPath();
+    if (sessionpath != NULL){
+      int keyboard_file_path_size = strlen(sessionpath) + strlen("/keyboard");
+      char *keyboard_file_path = malloc((keyboard_file_path_size + 1) * sizeof(char));
+      FILE *keyboard_file;
+      if ( keyboard_file_path == NULL)
+      {
+        FatalError("nxagentKeyboardProc: malloc failed.");
+      }
+      strcpy(keyboard_file_path, sessionpath);
+      strcat(keyboard_file_path, "/keyboard");
+      if ((keyboard_file = fopen(keyboard_file_path, "w")) != NULL) {
+        if ( drules != NULL )
+          fprintf(keyboard_file, "rules=%s\n", drules);
+        if ( dmodel != NULL )
+          fprintf(keyboard_file, "model=%s\n", dmodel);
+        if ( dlayout != NULL )
+          fprintf(keyboard_file, "layout=%s\n", dlayout);
+        if ( dvariant != NULL )
+          fprintf(keyboard_file, "variant=%s\n", dvariant);
+        if ( doptions != NULL )
+          fprintf(keyboard_file, "options=%s\n", doptions);
+        fclose(keyboard_file);
+      }
+      free(keyboard_file_path);
+      fprintf(stderr, "keyboard file created\n");
+    }
+    fprintf(stderr, "SessionPath not defined\n");
+  }
+  else
+  {
+    fprintf(stderr, "Failed to create the keyboard file\n");
+  }
+
   if (nxagentOption(ClientOs) == ClientOsLinux &&
             drules != NULL && dmodel != NULL &&
                 (strcmp(drules, "evdev") == 0 ||