nxagent: export remote keyboard configurations by marceloshima@gmail.com
authordimbor <i@dimbor.ru>
Wed, 3 Dec 2014 10:30:46 +0000 (13:30 +0300)
committerdimbor <i@dimbor.ru>
Tue, 9 Dec 2014 10:25:22 +0000 (13:25 +0300)
nx-X11/programs/Xserver/hw/nxagent/Error.c
nx-X11/programs/Xserver/hw/nxagent/Error.h
nx-X11/programs/Xserver/hw/nxagent/Keyboard.c

index 43bf8590046d56c4ea650e374a7c7105fb087201..31ff4cf250b2c35fc20df3d59aff254c6760e8c6 100644 (file)
@@ -497,7 +497,7 @@ char *nxagentGetRootPath(void)
   return rootPath;
 }
 
-char *nxagentGetSessionPath()
+char *nxagentGetSessionPath(void)
 {
 
   char *rootPath;
index e55fd71a5e6a65e9efbe84267c8186a45031ec76..51d6171dafe585ba94c6d3a960d67316f158e252 100644 (file)
@@ -34,4 +34,6 @@ void nxagentStartRedirectToClientsLog(void);
 
 void nxagentEndRedirectToClientsLog(void);
 
+char *nxagentGetSessionPath(void);
+
 #endif /* __Error_H__ */
index 6039e5c437965b21d48c44fa81e979c486697b09..dfafe1ebb0d804c78f8edf1ba2366b157e35841e 100644 (file)
@@ -52,6 +52,7 @@ is" without express or implied warranty.
 #include "Keyboard.h"
 #include "Events.h"
 #include "Options.h"
+#include "Error.h"
 
 #include "NXlib.h"
 
@@ -1790,6 +1791,42 @@ void nxagentKeycodeConversionSetup(void)
   }
   #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 ||