diff options
author | Oleksandr Shneyder <o.shneyder@phoca-gmbh.de> | 2015-02-10 19:43:41 +0100 |
---|---|---|
committer | Mike Gabriel <mike.gabriel@das-netzwerkteam.de> | 2015-02-10 19:43:41 +0100 |
commit | 8c1b852abf692af4898368132292eb8c7278a7c2 (patch) | |
tree | 71be8528bc49423444534c510f9c4e1e23a7eff7 /nx-X11/programs/Xserver/hw/nxagent/Reconnect.c | |
parent | 4a6ccd5037c8410f24dc177c9286272c2f47cd9d (diff) | |
download | nx-libs-8c1b852abf692af4898368132292eb8c7278a7c2.tar.gz nx-libs-8c1b852abf692af4898368132292eb8c7278a7c2.tar.bz2 nx-libs-8c1b852abf692af4898368132292eb8c7278a7c2.zip |
Save session state in file.
210_nxagent_save_session_state.full.patch
210_nxcomp_save_session_state.full+lite.patch
This patch adds a "state" option to NX (agent) which
allows one to specify a file where nxagent will write
its session state into.
Diffstat (limited to 'nx-X11/programs/Xserver/hw/nxagent/Reconnect.c')
-rw-r--r-- | nx-X11/programs/Xserver/hw/nxagent/Reconnect.c | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/nx-X11/programs/Xserver/hw/nxagent/Reconnect.c b/nx-X11/programs/Xserver/hw/nxagent/Reconnect.c index 3c576c6e0..b26fa9cfe 100644 --- a/nx-X11/programs/Xserver/hw/nxagent/Reconnect.c +++ b/nx-X11/programs/Xserver/hw/nxagent/Reconnect.c @@ -118,6 +118,33 @@ void *reconnectLossyLevel[STEP_NONE]; static enum RECONNECTION_STEP failedStep; +#include <limits.h> + +/* + * Path of state File + */ +char stateFile[PATH_MAX]; + + +void setStatePath(char* path) +{ + strncpy(stateFile, path, PATH_MAX-1); +} + +void saveAgentState(char* state) +{ + FILE* fptr; + if(strlen(stateFile)) + { + fptr=fopen(stateFile, "w"); + if(!fptr) + return; + fprintf(fptr,"%s", state); + fclose(fptr); + } +} + + int nxagentHandleConnectionStates(void) { #ifdef TEST @@ -211,6 +238,7 @@ TODO: This should be reset only when fprintf(stderr, "Session: Display failure detected at '%s'.\n", GetTimeAsString()); fprintf(stderr, "Session: Suspending session at '%s'.\n", GetTimeAsString()); + saveAgentState("SUSPENDING"); } nxagentDisconnectSession(); @@ -265,6 +293,7 @@ TODO: This should be reset only when fprintf(stderr, "Session: Session suspended at '%s'.\n", GetTimeAsString()); #endif } + saveAgentState("SUSPENDED"); nxagentResetDisplayHandlers(); @@ -622,6 +651,7 @@ Bool nxagentReconnectSession(void) #else fprintf(stderr, "Session: Session resumed at '%s'.\n", GetTimeAsString()); #endif + saveAgentState("RUNNING"); nxagentRemoveSplashWindow(NULL); @@ -785,12 +815,14 @@ void nxagentHandleConnectionChanges() if (nxagentSessionState == SESSION_GOING_DOWN) { fprintf(stderr, "Session: Suspending session at '%s'.\n", GetTimeAsString()); + saveAgentState("SUSPENDING"); nxagentDisconnectSession(); } else if (nxagentSessionState == SESSION_GOING_UP) { fprintf(stderr, "Session: Resuming session at '%s'.\n", GetTimeAsString()); + saveAgentState("RESUMING"); if (nxagentReconnectSession()) { @@ -803,6 +835,7 @@ void nxagentHandleConnectionChanges() fprintf(stderr, "Session: Display failure detected at '%s'.\n", GetTimeAsString()); fprintf(stderr, "Session: Suspending session at '%s'.\n", GetTimeAsString()); + saveAgentState("SUSPENDING"); nxagentDisconnectSession(); } |