[Ttssh2-commit] [4381] SCP 転送で、経過時間と転送速度を表示するようにした。

svnno****@sourc***** svnno****@sourc*****
2011年 3月 10日 (木) 19:04:51 JST


Revision: 4381
          http://sourceforge.jp/projects/ttssh2/svn/view?view=rev&revision=4381
Author:   doda
Date:     2011-03-10 19:04:51 +0900 (Thu, 10 Mar 2011)

Log Message:
-----------
SCP 転送で、経過時間と転送速度を表示するようにした。

Modified Paths:
--------------
    trunk/ttssh2/ttxssh/resource.h
    trunk/ttssh2/ttxssh/ssh.c
    trunk/ttssh2/ttxssh/ttxssh.rc


-------------- next part --------------
Modified: trunk/ttssh2/ttxssh/resource.h
===================================================================
--- trunk/ttssh2/ttxssh/resource.h	2011-03-09 14:21:45 UTC (rev 4380)
+++ trunk/ttssh2/ttxssh/resource.h	2011-03-10 10:04:51 UTC (rev 4381)
@@ -159,6 +159,7 @@
 #define IDC_KEYBITS                     1106
 #define IDC_KEYGEN_PROGRESS_LABEL       1107
 #define IDC_PROGBAR                     1108
+#define IDC_PROGTIME                    1109
 #define IDC_SSHUSEPASSWORD              1201
 #define IDC_SSHUSERSA                   1202
 #define IDC_SSHFWDREMOTETOLOCAL         1202

Modified: trunk/ttssh2/ttxssh/ssh.c
===================================================================
--- trunk/ttssh2/ttxssh/ssh.c	2011-03-09 14:21:45 UTC (rev 4380)
+++ trunk/ttssh2/ttxssh/ssh.c	2011-03-10 10:04:51 UTC (rev 4381)
@@ -7468,12 +7468,17 @@
 	HWND hWnd = c->scp.progress_window;
 	scp_dlg_parm_t parm;
 	int rate, ProgStat;
+	DWORD stime;
+	int elapsed, prev_elapsed;
 
 	//SendMessage(GetDlgItem(hWnd, IDC_FILENAME), WM_SETTEXT, 0, (LPARAM)c->scp.localfile);
 	SendMessage(GetDlgItem(hWnd, IDC_FILENAME), WM_SETTEXT, 0, (LPARAM)c->scp.localfilefull);
 
 	InitDlgProgress(hWnd, IDC_PROGBAR, &ProgStat);
 
+	stime = GetTickCount();
+	prev_elapsed = 0;
+
 	do {
 		// Cancelƒ{ƒ^ƒ“‚ª‰Ÿ‰º‚³‚ꂽ‚çƒEƒBƒ“ƒhƒE‚ªÁ‚¦‚éB
 		if (is_canceled_window(hWnd))
@@ -7512,6 +7517,27 @@
 			SendDlgItemMessage(hWnd, IDC_PROGBAR, PBM_SETPOS, (WPARAM)ProgStat, 0);
 		}
 
+		elapsed = (GetTickCount() - stime) / 1000;
+		if (elapsed > prev_elapsed) {
+			if (elapsed > 2) {
+				rate = (int)(total_size / elapsed);
+				if (rate < 1200) {
+					_snprintf_s(s, sizeof(s), _TRUNCATE, "%d:%02d (%d %s)", elapsed / 60, elapsed % 60, rate, "Bytes/s");
+				}
+				else if (rate < 1200000) {
+					_snprintf_s(s, sizeof(s), _TRUNCATE, "%d:%02d (%d.%02d %s)", elapsed / 60, elapsed % 60, rate / 1000, rate / 10 % 100, "KBytes/s");
+				}
+				else {
+					_snprintf_s(s, sizeof(s), _TRUNCATE, "%d:%02d (%d.%02d %s)", elapsed / 60, elapsed % 60, rate / (1000 * 1000), rate / 100000 % 100, "MBytes/s");
+				}
+			}
+			else {
+				_snprintf_s(s, sizeof(s), _TRUNCATE, "%d:%02d", elapsed / 60, elapsed % 60);
+			}
+			SendDlgItemMessage(hWnd, IDC_PROGTIME, WM_SETTEXT, 0, (LPARAM)s);
+			prev_elapsed = elapsed;
+		}
+
 	} while (ret <= sizeof(buf));
 
 	// eof
@@ -7602,9 +7628,14 @@
 	unsigned int buflen;
 	int eof;
 	int rate, ProgStat;
+	DWORD stime;
+	int elapsed, prev_elapsed;
 
 	InitDlgProgress(hWnd, IDC_PROGBAR, &ProgStat);
 
+	stime = GetTickCount();
+	prev_elapsed = 0;
+
 	for (;;) {
 		// Cancelƒ{ƒ^ƒ“‚ª‰Ÿ‰º‚³‚ꂽ‚çƒEƒBƒ“ƒhƒE‚ªÁ‚¦‚éB
 		if (is_canceled_window(hWnd))
@@ -7644,6 +7675,27 @@
 					SendDlgItemMessage(c->scp.progress_window, IDC_PROGBAR, PBM_SETPOS, (WPARAM)ProgStat, 0);
 				}
 
+				elapsed = (GetTickCount() - stime) / 1000;
+				if (elapsed > prev_elapsed) {
+					if (elapsed > 2) {
+						rate = (int)(c->scp.filercvsize / elapsed);
+						if (rate < 1200) {
+							_snprintf_s(s, sizeof(s), _TRUNCATE, "%d:%02d (%d %s)", elapsed / 60, elapsed % 60, rate, "Bytes/s");
+						}
+						else if (rate < 1200000) {
+							_snprintf_s(s, sizeof(s), _TRUNCATE, "%d:%02d (%d.%02d %s)", elapsed / 60, elapsed % 60, rate / 1000, rate / 10 % 100, "KBytes/s");
+						}
+						else {
+							_snprintf_s(s, sizeof(s), _TRUNCATE, "%d:%02d (%d.%02d %s)", elapsed / 60, elapsed % 60, rate / (1000 * 1000), rate / 10000 % 100, "MBytes/s");
+						}
+					}
+					else {
+						_snprintf_s(s, sizeof(s), _TRUNCATE, "%d:%02d", elapsed / 60, elapsed % 60);
+					}
+					SendDlgItemMessage(hWnd, IDC_PROGTIME, WM_SETTEXT, 0, (LPARAM)s);
+					prev_elapsed = elapsed;
+				}
+
 				if (eof)
 					goto done;
 

Modified: trunk/ttssh2/ttxssh/ttxssh.rc
===================================================================
--- trunk/ttssh2/ttxssh/ttxssh.rc	2011-03-09 14:21:45 UTC (rev 4380)
+++ trunk/ttssh2/ttxssh/ttxssh.rc	2011-03-10 10:04:51 UTC (rev 4381)
@@ -340,11 +340,14 @@
 CAPTION "TTSSH: SCP sending file"
 FONT 8, "Tahoma", 0, 0, 0x0
 BEGIN
-    PUSHBUTTON      "Cancel",IDCANCEL,43,68,73,14
-    LTEXT           "0%",IDC_PROGRESS,7,29,141,10
-    EDITTEXT        IDC_FILENAME,45,7,114,14,ES_AUTOHSCROLL | ES_READONLY
     LTEXT           "Filename:",IDC_FN_STATIC,7,7,32,8
-    CONTROL         "",IDC_PROGBAR,"msctls_progress32",WS_BORDER,7,48,152,14
+    EDITTEXT        IDC_FILENAME,45,6,114,14,ES_AUTOHSCROLL | ES_READONLY
+    LTEXT           "Bytes:",IDC_STATIC,7,29,32,8
+    LTEXT           "0%",IDC_PROGRESS,40,29,141,8
+    LTEXT           "Time:",IDC_STATIC,7,39,32,8
+    LTEXT           "0:00",IDC_PROGTIME,40,39,141,8
+    CONTROL         "",IDC_PROGBAR,"msctls_progress32",WS_BORDER,7,52,152,14
+    DEFPUSHBUTTON   "Cancel",IDCANCEL,43,76,73,14
 END
 
 IDD_SSHPASSWD_INPUT DIALOGEX 0, 0, 231, 95



Ttssh2-commit メーリングリストの案内