[X2Go-Commits] [vcxsrv] 04/11: Show all text received by plink to show to the user (and not only the first part)

git-admin at x2go.org git-admin at x2go.org
Tue May 3 13:47:19 CEST 2016


This is an automated email from the git hooks/post-receive script.

x2go pushed a commit to branch release/1.17.0.0-x
in repository vcxsrv.

commit 6fe71499cd506c11a378c339d1117630c85ab96c
Author: marha <marha at users.sourceforge.net>
Date:   Sun Jun 28 12:56:53 2015 +0200

    Show all text received by plink to show to the user (and not only the first part)
---
 xorg-server/hw/xwin/xlaunch/main.cc             |   62 +++++++++++++++++------
 xorg-server/hw/xwin/xlaunch/resources/dialog.rc |    2 +-
 2 files changed, 48 insertions(+), 16 deletions(-)

diff --git a/xorg-server/hw/xwin/xlaunch/main.cc b/xorg-server/hw/xwin/xlaunch/main.cc
index e6b04d6..372420b 100644
--- a/xorg-server/hw/xwin/xlaunch/main.cc
+++ b/xorg-server/hw/xwin/xlaunch/main.cc
@@ -54,14 +54,17 @@ static bool ContainPrintableChars(const char *Buf, unsigned Nbr)
   return false;
 }
 
+HANDLE g_hChildStdoutRd;
+int g_hStdOut;
+
 /*
  * Process messages for the prompt dialog.
  */
 
 static INT_PTR CALLBACK DisplayPromptDlgProc (HWND hwndDialog, UINT message, WPARAM wParam, LPARAM lParam)
 {
-  static LPARAM Param;
   static UINT PasswordChar;
+  static char *buf_p;
   switch (message)
   {
     case WM_INITDIALOG:
@@ -86,18 +89,39 @@ static INT_PTR CALLBACK DisplayPromptDlgProc (HWND hwndDialog, UINT message, WPA
       0, 0,
       SWP_NOSIZE | SWP_FRAMECHANGED);
 
-      Param=lParam;
-      SendDlgItemMessage(hwndDialog, IDC_PROMPT_DESC, WM_SETTEXT, 0, lParam);
+      buf_p=(char*)lParam;
+      SendDlgItemMessage(hwndDialog, IDC_PROMPT_DESC, WM_SETTEXT, 0, (LPARAM)buf_p);
+      SendDlgItemMessage(hwndDialog, IDC_PROMPT_DESC, EM_LINESCROLL, 0, 1000);
+      SendDlgItemMessage(hwndDialog, IDC_PROMPT_DESC, EM_SETSEL, -1, -1);
+      SetTimer(hwndDialog,1,20,NULL);
       return TRUE;
     }
     break;
 
+    case WM_TIMER:
+    {
+      DWORD nbrAvail=0;
+      PeekNamedPipe(g_hChildStdoutRd, NULL, NULL, NULL, &nbrAvail, NULL);
+      if (nbrAvail)
+      {
+        int curLen=strlen(buf_p);
+	buf_p=(char*)realloc(buf_p, curLen+nbrAvail+1);
+        size_t Nbr = _read(g_hStdOut, buf_p+curLen, nbrAvail);
+        buf_p[curLen+nbrAvail]=0;
+        SendDlgItemMessage(hwndDialog, IDC_PROMPT_DESC, WM_SETTEXT, 0, (LPARAM)buf_p);
+        SendDlgItemMessage(hwndDialog, IDC_PROMPT_DESC, EM_LINESCROLL, 0, 1000);
+        SendDlgItemMessage(hwndDialog, IDC_PROMPT_DESC, EM_SETSEL, -1, -1);
+      }
+      break;
+    }
+
     case WM_COMMAND:
       switch (LOWORD (wParam))
       {
         case IDOK:
-          SendDlgItemMessage(hwndDialog, IDC_INPUT, WM_GETTEXT, 128, Param);
-          EndDialog(hwndDialog, Param);
+	  buf_p=(char*)realloc(buf_p, 128);
+          SendDlgItemMessage(hwndDialog, IDC_INPUT, WM_GETTEXT, 128, (LPARAM)buf_p);
+          EndDialog(hwndDialog, (LPARAM)buf_p);
           return TRUE;
         case IDCANCEL:
           EndDialog(hwndDialog, NULL);
@@ -114,6 +138,11 @@ static INT_PTR CALLBACK DisplayPromptDlgProc (HWND hwndDialog, UINT message, WPA
           }
           InvalidateRect(hDlg, NULL, TRUE);
         }
+	return TRUE;
+	case IDC_PROMPT_DESC:
+	if (HIWORD(wParam)==EN_SETFOCUS)
+          SendDlgItemMessage(hwndDialog, IDC_PROMPT_DESC, EM_SETSEL, -1, -1);
+	
         return TRUE;
       }
       break;
@@ -128,23 +157,26 @@ static INT_PTR CALLBACK DisplayPromptDlgProc (HWND hwndDialog, UINT message, WPA
 
 static bool CheckOutput(HANDLE hChildStdoutRd, int hStdOut, int hStdIn)
 {
+  g_hChildStdoutRd = hChildStdoutRd;
+  g_hStdOut = hStdOut;
   DWORD NbrAvail=0;
   PeekNamedPipe(hChildStdoutRd, NULL, NULL, NULL, &NbrAvail, NULL);
   if (NbrAvail)
   {
-    char Buf[128];
-    size_t Nbr = _read(hStdOut, Buf, sizeof(Buf)-1);
-    if (ContainPrintableChars(Buf,Nbr))
+    char *buf_p=(char*)malloc(NbrAvail+1);
+    size_t Nbr = _read(hStdOut, buf_p, NbrAvail);
+    if (ContainPrintableChars(buf_p,Nbr))
     {
-      Buf[Nbr]=0;
-      INT_PTR Ret = DialogBoxParam (GetModuleHandle(NULL), "IDD_PROMPT", NULL, DisplayPromptDlgProc, (LPARAM)Buf);
+      buf_p[Nbr]=0;
+      INT_PTR Ret = DialogBoxParam (GetModuleHandle(NULL), "IDD_PROMPT", NULL, DisplayPromptDlgProc, (LPARAM)buf_p);
 
       if (Ret)
       {
         char *Data=(char*)Ret;
         // Write it to the client
         _write(hStdIn, Data, strlen(Data));
-        _write(hStdIn, "\x0d\x0a", 2);
+        _write(hStdIn, "\x0a", 1);
+        //_write(hStdIn, "\x0d\x0a", 2);
       }
 
       return true;
@@ -839,15 +871,15 @@ class CMyWizard : public CWizard
                 if (!CreatePipe(&hChildStdinRd, &hChildStdinWr, &saAttr, 0))
                   throw win32_error("CreatePipe failed", GetLastError());
 
-                // Ensure the write handle to the pipe for STDIN is not inherited. 
-                if ( ! SetHandleInformation(hChildStdinWr, HANDLE_FLAG_INHERIT, 0) )
+                // Ensure the write handle to the pipe for STDIN is not inherited. 
+                if ( ! SetHandleInformation(hChildStdinWr, HANDLE_FLAG_INHERIT, 0) )
                   throw win32_error("SetHandleInformation failed", GetLastError());
 
                 if (!CreatePipe(&hChildStdoutRd, &hChildStdoutWr, &saAttr, 0))
                   throw win32_error("CreatePipe failed", GetLastError());
 
-                // Ensure the read handle to the pipe for STDOUT is not inherited. 
-                if ( ! SetHandleInformation(hChildStdoutRd, HANDLE_FLAG_INHERIT, 0) )
+                // Ensure the read handle to the pipe for STDOUT is not inherited. 
+                if ( ! SetHandleInformation(hChildStdoutRd, HANDLE_FLAG_INHERIT, 0) )
                   throw win32_error("SetHandleInformation failed", GetLastError());
 
                 sic.dwFlags = STARTF_USESTDHANDLES;
diff --git a/xorg-server/hw/xwin/xlaunch/resources/dialog.rc b/xorg-server/hw/xwin/xlaunch/resources/dialog.rc
index 3435329..9827f91 100644
--- a/xorg-server/hw/xwin/xlaunch/resources/dialog.rc
+++ b/xorg-server/hw/xwin/xlaunch/resources/dialog.rc
@@ -144,8 +144,8 @@ EXSTYLE WS_EX_NOPARENTNOTIFY
 CAPTION "Input requested?"
 FONT 8, "MS Shell Dlg 2", 0, 0, 0x1
 BEGIN
-    LTEXT           "",IDC_PROMPT_DESC,7,7,245,50, WS_BORDER
     EDITTEXT        IDC_INPUT,7,67,245,12, WS_BORDER | WS_TABSTOP | ES_AUTOHSCROLL | ES_PASSWORD
+    EDITTEXT        IDC_PROMPT_DESC,7,7,245,50, WS_BORDER | WS_TABSTOP | WS_VSCROLL | ES_READONLY | ES_MULTILINE 
     AUTOCHECKBOX    "Show Characters", IDC_PASSWORD, 7,77,245,12, WS_TABSTOP
     DEFPUSHBUTTON   "OK",IDOK,61,95,50,15, WS_TABSTOP
     PUSHBUTTON      "Cancel",IDCANCEL,147,95,50,14, WS_TABSTOP

--
Alioth's /srv/git/code.x2go.org/vcxsrv.git//..//_hooks_/post-receive-email on /srv/git/code.x2go.org/vcxsrv.git


More information about the x2go-commits mailing list