• R/O
  • HTTP
  • SSH
  • HTTPS

Commit

Tags
Keine Tags

Frequently used words (click to add to your profile)

javac++androidlinuxc#windowsobjective-ccocoa誰得qtpythonphprubygameguibathyscaphec計画中(planning stage)翻訳omegatframeworktwitterdomtestvb.netdirectxゲームエンジンbtronarduinopreviewer

FFFTPのソースコードです。


Commit MetaInfo

Revision37269d46eda5e8abda8a42ed8854e1f2dc968b7a (tree)
Zeit2017-11-11 10:32:52
Autort.masuda <masuda@moon...>
Commitert.masuda

Log Message

FtpWndProc を仮呼び出し

Ändern Zusammenfassung

Diff

--- a/src/FFFTP2/FFFTP2.rc
+++ b/src/FFFTP2/FFFTP2.rc
@@ -469,12 +469,12 @@ FONT 9, "MS UI Gothic", 0, 0, 0x1
469469 BEGIN
470470 PUSHBUTTON "上",IDC_BUTTON_LOCAL_UP,7,7,17,14,BS_BITMAP | BS_CENTER
471471 PUSHBUTTON "開",IDC_BUTTON_LOCAL_OPEN,26,7,17,14,BS_BITMAP | BS_CENTER
472- CONTROL "",IDC_COMBOBOX_LOCAL,"ComboBoxEx32",CBS_DROPDOWN | CBS_SORT | WS_VSCROLL | WS_TABSTOP,48,7,74,30
473- CONTROL "",IDC_LIST_REMOTE,"SysListView32",LVS_REPORT | LVS_ALIGNLEFT | WS_BORDER | WS_TABSTOP,130,32,115,129
472+ CONTROL "",IDC_LIST_REMOTE,"SysListView32",LVS_REPORT | LVS_ALIGNLEFT | WS_BORDER | WS_TABSTOP,130,32,115,129,WS_EX_ACCEPTFILES
474473 PUSHBUTTON "上",IDC_BUTTON_REMOTE_UP,128,7,17,14,BS_BITMAP
475474 PUSHBUTTON "開",IDC_BUTTON_REMOTE_OPEN,151,7,17,14,BS_BITMAP
476- CONTROL "",IDC_COMBOBOX_REMOTE,"ComboBoxEx32",CBS_DROPDOWN | CBS_SORT | WS_VSCROLL | WS_TABSTOP,171,7,74,30
477- CONTROL "",IDC_LIST_LOCAL,"SysListView32",LVS_REPORT | LVS_SHOWSELALWAYS | LVS_ALIGNLEFT | WS_BORDER | WS_TABSTOP,7,32,115,129
475+ CONTROL "",IDC_LIST_LOCAL,"SysListView32",LVS_REPORT | LVS_SHOWSELALWAYS | LVS_ALIGNLEFT | WS_BORDER | WS_TABSTOP,7,32,115,129,WS_EX_ACCEPTFILES
476+ COMBOBOX IDC_COMBOBOX_LOCAL,49,7,72,30,CBS_DROPDOWN | CBS_SORT | WS_VSCROLL | WS_TABSTOP
477+ COMBOBOX IDC_COMBOBOX_REMOTE,174,7,70,30,CBS_DROPDOWN | CBS_SORT | WS_VSCROLL | WS_TABSTOP
478478 END
479479
480480 about_dlg DIALOGEX 0, 0, 319, 315
--- a/src/FFFTP2/FFFTP2View.cpp
+++ b/src/FFFTP2/FFFTP2View.cpp
@@ -14,6 +14,11 @@
1414
1515 extern "C" {
1616 #include "common.h"
17+
18+void SetWndDirLocal(HWND hwnd);
19+void SetWndDirRemote(HWND hwnd);
20+void SetWndDirLocalEdit(HWND hwnd);
21+void SetWndDirRemoteEdit(HWND hwnd);
1722 }
1823
1924 #ifdef _DEBUG
@@ -85,6 +90,11 @@ void CFFFTP2View::OnInitialUpdate()
8590 SetWndListRemote(m_lvRemote.GetSafeHwnd());
8691 SetWndListLocal(m_lvLocal.GetSafeHwnd());
8792
93+ SetWndDirLocal(m_cbLocal.GetSafeHwnd());
94+ SetWndDirRemote(m_cbRemote.GetSafeHwnd());
95+ // SetWndDirLocalEdit(m_cbLocal.GetEditCtrl()->GetSafeHwnd());
96+ // SetWndDirRemoteEdit(m_cbRemote.GetEditCtrl()->GetSafeHwnd());
97+
8898 m_imageList.Create(dirattr_bmp, 16, 5, RGB(255, 0, 0));
8999 m_lvLocal.SetImageList(&m_imageList, LVSIL_SMALL);
90100 m_lvRemote.SetImageList(&m_imageList, LVSIL_SMALL);
@@ -206,7 +216,7 @@ void CFFFTP2View::OnItemactivateListRemote(NMHDR *pNMHDR, LRESULT *pResult)
206216 void CFFFTP2View::OnDblclkListRemote(NMHDR *pNMHDR, LRESULT *pResult)
207217 {
208218 LPNMITEMACTIVATE pNMItemActivate = reinterpret_cast<LPNMITEMACTIVATE>(pNMHDR);
209- DoubleClickProc(WIN_REMOTE, YES, -1);
219+ DoubleClickProc(WIN_REMOTE, NO, -1);
210220 *pResult = 0;
211221 }
212222
@@ -230,7 +240,7 @@ void CFFFTP2View::OnItemactivateListLocal(NMHDR *pNMHDR, LRESULT *pResult)
230240 void CFFFTP2View::OnDblclkListLocal(NMHDR *pNMHDR, LRESULT *pResult)
231241 {
232242 LPNMITEMACTIVATE pNMItemActivate = reinterpret_cast<LPNMITEMACTIVATE>(pNMHDR);
233- DoubleClickProc(WIN_LOCAL, YES, -1);
243+ DoubleClickProc(WIN_LOCAL, NO, -1);
234244 *pResult = 0;
235245 }
236246
--- a/src/FFFTP2/FFFTP2View.h
+++ b/src/FFFTP2/FFFTP2View.h
@@ -51,11 +51,11 @@ protected:
5151 public:
5252 CButton m_btnLocalUp;
5353 CButton m_btnLocalOpen;
54- CComboBoxEx m_cbLocal;
54+ CComboBox m_cbLocal;
5555 CListCtrl m_lvLocal;
5656 CButton m_btnRemoteUp;
5757 CButton m_btnRemoteOpen;
58- CComboBoxEx m_cbRemote;
58+ CComboBox m_cbRemote;
5959 CListCtrl m_lvRemote;
6060
6161 CImageList m_imageList, m_imageBtn;
--- a/src/FFFTP2/MainFrm.cpp
+++ b/src/FFFTP2/MainFrm.cpp
@@ -12,6 +12,8 @@
1212 extern "C" {
1313 #include "common.h"
1414 #include "ui.h"
15+
16+extern int InitApp(LPSTR lpszCmdLine, int cmdShow);
1517 }
1618
1719 #include "HostnameDlg.h"
@@ -37,7 +39,7 @@ BEGIN_MESSAGE_MAP(CMainFrame, CMDIFrameWndEx)
3739 ON_COMMAND_RANGE(ID_VIEW_APPLOOK_WIN_2000, ID_VIEW_APPLOOK_WINDOWS_7, &CMainFrame::OnApplicationLook)
3840 ON_UPDATE_COMMAND_UI_RANGE(ID_VIEW_APPLOOK_WIN_2000, ID_VIEW_APPLOOK_WINDOWS_7, &CMainFrame::OnUpdateApplicationLook)
3941 ON_WM_SETTINGCHANGE()
40-
42+ ON_WM_COPYDATA()
4143 // menu
4244 ON_COMMAND(MENU_CONNECT, &CMainFrame::OnMenuConnect)
4345 ON_COMMAND(MENU_QUICK, &CMainFrame::OnMenuQuick)
@@ -146,21 +148,28 @@ static UINT indicators[] =
146148
147149 // CMainFrame コンストラクション/デストラクション
148150
151+static HWND _mainHwnd;
149152
150153 void uiSetOutput(const char *fmt, va_list args)
151154 {
152155 static char buf[10 * 1024 + 3];
153156 vsprintf(buf, fmt, args);
154- auto frame = (CMainFrame*)AfxGetMainWnd();
155- TRACE1("%s\n", buf);
156- frame->SetOutput(buf);
157+ COPYDATASTRUCT data;
158+ data.dwData = 0;
159+ data.cbData = 10 * 1024 + 3;
160+ data.lpData = buf;
161+ SendMessageA(_mainHwnd, WM_COPYDATA, (WPARAM)_mainHwnd, (LPARAM)&data);
162+ // frame->SetOutput(buf);
157163 }
158164 void uiSetStatusBar(const char *fmt, va_list args) {
159165
160166 static char buf[1024 + 3];
161167 vsprintf(buf, fmt, args);
162- auto frame = (CMainFrame*)AfxGetMainWnd();
163- frame->SetStatusBar(buf);
168+ COPYDATASTRUCT data;
169+ data.dwData = 1;
170+ data.cbData = 10 * 1024 + 3;
171+ data.lpData = buf;
172+ SendMessageA(_mainHwnd, WM_COPYDATA, (WPARAM)_mainHwnd, (LPARAM)&data);
164173 }
165174
166175 void CMainFrame::SetOutput(const char *s) {
@@ -308,12 +317,57 @@ int CMainFrame::OnCreate(LPCREATESTRUCT lpCreateStruct)
308317 OnApplicationLook(ID_VIEW_APPLOOK_VS_2008);
309318 m_wndMenuBar.SetShowAllCommands(TRUE);
310319
320+ _mainHwnd = this->GetSafeHwnd();
321+
322+ // 初期化
323+ InitApp("", 0);
311324 // ソケットウィンドウを作成
312325 int StsSocket = MakeSocketWin(m_hWnd, AfxGetInstanceHandle());
326+ // 転送スレッドを起動
327+ // FtpWndProc の設定
328+ SetMainHwnd(this->GetSafeHwnd());
313329
314330 return 0;
315331 }
316332
333+
334+extern "C" LRESULT CALLBACK FtpWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam);
335+
336+
337+LRESULT CMainFrame::WindowProc(UINT message, WPARAM wParam, LPARAM lParam)
338+{
339+ switch ( wParam)
340+ {
341+ default:
342+ FtpWndProc(this->m_hWnd, message, wParam, lParam);
343+ break;
344+ }
345+ return CMDIFrameWndEx::WindowProc(message, wParam, lParam);
346+}
347+
348+BOOL CMainFrame::OnCopyData(CWnd *wnd, COPYDATASTRUCT *data)
349+{
350+ switch (data->dwData) {
351+ case 0:
352+ {
353+ /// 出力メッセージ
354+ auto frame = (CMainFrame*)AfxGetMainWnd();
355+ frame->SetOutput((const char *)data->lpData);
356+ }
357+ break;
358+ case 1:
359+ {
360+ /// ステータスバーへ表示
361+ auto frame = (CMainFrame*)AfxGetMainWnd();
362+ frame->SetStatusBar((const char *)data->lpData);
363+ }
364+ break;
365+ }
366+ return TRUE;
367+}
368+
369+
370+
317371 BOOL CMainFrame::PreCreateWindow(CREATESTRUCT& cs)
318372 {
319373 if( !CMDIFrameWndEx::PreCreateWindow(cs) )
@@ -547,12 +601,14 @@ void CMainFrame::OnMenuConnect()
547601 /// クイック接続
548602 void CMainFrame::OnMenuQuick()
549603 {
604+ /*
550605 CHostnameDlg dlg;
551606 if (dlg.DoModal() == IDOK) {
552607 QuickConnectProc2((LPCSTR)dlg.Hostname, (LPCSTR)dlg.User, (LPCSTR)dlg.Pass);
553608 int CancelFlg = 0;
554609 GetRemoteDirForWnd(CACHE_NORMAL, &CancelFlg);
555610 }
611+ */
556612 }
557613 /// 切断
558614 void CMainFrame::OnMenuDisconnect()
--- a/src/FFFTP2/MainFrm.h
+++ b/src/FFFTP2/MainFrm.h
@@ -141,6 +141,7 @@ protected:
141141 afx_msg void OnUpdateMenuReport(CCmdUI *pCmdUI);
142142 afx_msg void OnUpdateMenuSync(CCmdUI *pCmdUI);
143143
144+ afx_msg BOOL OnCopyData(CWnd*, COPYDATASTRUCT*);
144145
145146 DECLARE_MESSAGE_MAP()
146147
@@ -148,6 +149,7 @@ protected:
148149 void SetDockingWindowIcons(BOOL bHiColorIcons);
149150
150151 virtual void OnUpdateFrameTitle(BOOL bAddToTitle);
152+ virtual LRESULT WindowProc(UINT message, WPARAM wParam, LPARAM lParam);
151153
152154 protected:
153155 // ツールバーのボタン制御
--- a/src/FFFTP2/Resource.h
+++ b/src/FFFTP2/Resource.h
@@ -504,6 +504,7 @@
504504 #define HOST_SET_DEFAULT 1350
505505 #define TRMODE_LISTERROR 1351
506506 #define MIRROR_NO_TRANSFER 1352
507+#define IDC_COMBOBOX_R 1354
507508 #define MENU_END 40000
508509 #define MENU_EXIT 40001
509510 #define MENU_CONNECT 40002
@@ -708,9 +709,9 @@
708709 //
709710 #ifdef APSTUDIO_INVOKED
710711 #ifndef APSTUDIO_READONLY_SYMBOLS
711-#define _APS_NEXT_RESOURCE_VALUE 214
712+#define _APS_NEXT_RESOURCE_VALUE 215
712713 #define _APS_NEXT_COMMAND_VALUE 40198
713-#define _APS_NEXT_CONTROL_VALUE 1353
714+#define _APS_NEXT_CONTROL_VALUE 1355
714715 #define _APS_NEXT_SYMED_VALUE 101
715716 #endif
716717 #endif
--- a/src/FFFTP2/common.h
+++ b/src/FFFTP2/common.h
@@ -2047,7 +2047,7 @@ void SaveUpdateBellInfo(void);
20472047 void ChangeDir(int Win, char *Path);
20482048 void SetWndSocket(HWND h);
20492049 void QuickConnectProc2(const char *Host, const char *User, const char *Pass);
2050-
2050+void SetMainHwnd(HWND);
20512051 #ifndef SUCCESS
20522052 #define SUCCESS 0
20532053 #endif // !SUCCESS
--- a/src/FFFTP2/connect_w.c
+++ b/src/FFFTP2/connect_w.c
@@ -3404,6 +3404,7 @@ int AskMaxThreadCount(void)
34043404
34053405 int AskReuseCmdSkt(void)
34063406 {
3407+ // return YES; // by masuda
34073408 return(CurHost.ReuseCmdSkt);
34083409 }
34093410
--- a/src/FFFTP2/filelist_w.c
+++ b/src/FFFTP2/filelist_w.c
@@ -164,11 +164,18 @@ extern int DispPermissionsNumber;
164164
165165 static HWND hWndListLocal = NULL;
166166 static HWND hWndListRemote = NULL;
167-void SetWndListLocal(HWND h) { hWndListLocal = h; }
168-void SetWndListRemote(HWND h) { hWndListRemote = h; }
169-
170167 static WNDPROC LocalProcPtr;
171168 static WNDPROC RemoteProcPtr;
169+void SetWndListLocal(HWND h) {
170+ hWndListLocal = h;
171+ LocalProcPtr = (WNDPROC)SetWindowLongPtr(h, GWLP_WNDPROC, (LONG_PTR)LocalWndProc);
172+
173+}
174+void SetWndListRemote(HWND h) {
175+ hWndListRemote = h;
176+ RemoteProcPtr = (WNDPROC)SetWindowLongPtr(h, GWLP_WNDPROC, (LONG_PTR)RemoteWndProc);
177+}
178+
172179
173180 static HIMAGELIST ListImg = NULL;
174181 void SetListImg(HIMAGELIST h) { ListImg = h; }
--- a/src/FFFTP2/getput_w.c
+++ b/src/FFFTP2/getput_w.c
@@ -724,7 +724,8 @@ void InitTransCurDir(void)
724724 * Return Value
725725 * なし
726726 *----------------------------------------------------------------------------*/
727-
727+// by masuda
728+#if 0
728729 static ULONG WINAPI TransferThread(void *Dummy)
729730 {
730731 TRANSPACKET *Pos;
@@ -755,7 +756,7 @@ static ULONG WINAPI TransferThread(void *Dummy)
755756 ThreadCount = (int)Dummy;
756757 TrnSkt = INVALID_SOCKET;
757758 LastError = NO;
758- SetThreadPriority(GetCurrentThread(), THREAD_PRIORITY_LOWEST);
759+ // SetThreadPriority(GetCurrentThread(), THREAD_PRIORITY_LOWEST);
759760
760761 while((TransPacketBase != NULL) ||
761762 (WaitForSingleObject(hRunMutex, 200) == WAIT_TIMEOUT))
@@ -1359,6 +1360,487 @@ static ULONG WINAPI TransferThread(void *Dummy)
13591360 }
13601361 return 0;
13611362 }
1363+#else
1364+static ULONG WINAPI TransferThread(void *Dummy)
1365+{
1366+ TRANSPACKET *Pos;
1367+ HWND hWndTrans;
1368+ char Tmp[FMAX_PATH + 1];
1369+ int CwdSts;
1370+ int GoExit;
1371+ // int Down;
1372+ // int Up;
1373+ static int Down;
1374+ static int Up;
1375+ int DelNotify;
1376+ int ThreadCount;
1377+ SOCKET TrnSkt;
1378+ RECT WndRect;
1379+ int i;
1380+ DWORD LastUsed;
1381+ int LastError;
1382+ int Sts;
1383+
1384+ hWndTrans = NULL;
1385+ Down = NO;
1386+ Up = NO;
1387+ GoExit = NO;
1388+ DelNotify = NO;
1389+ // 同時接続対応
1390+ // ソケットは各転送スレッドが管理
1391+ ThreadCount = (int)Dummy;
1392+ TrnSkt = INVALID_SOCKET;
1393+ LastError = NO;
1394+ // SetThreadPriority(GetCurrentThread(), THREAD_PRIORITY_LOWEST);
1395+
1396+ while ((TransPacketBase != NULL) ||
1397+ (WaitForSingleObject(hRunMutex, 200) == WAIT_TIMEOUT))
1398+ {
1399+ if (fTransferThreadExit == TRUE)
1400+ break;
1401+
1402+ if (WaitForMainThread == YES)
1403+ {
1404+ Sleep(100);
1405+ continue;
1406+ }
1407+
1408+ WaitForSingleObject(hListAccMutex, INFINITE);
1409+ memset(GetErrMsg(), NUL, ERR_MSG_LEN + 7);
1410+ Canceled[ThreadCount] = NO;
1411+
1412+ while (TransPacketBase != NULL && strcmp(TransPacketBase->Cmd, "") == 0)
1413+ {
1414+ Pos = TransPacketBase;
1415+ TransPacketBase = TransPacketBase->Next;
1416+ free(Pos);
1417+ if (TransPacketBase == NULL)
1418+ GoExit = YES;
1419+ }
1420+ if (AskReuseCmdSkt() == YES && ThreadCount == 0)
1421+ {
1422+ TrnSkt = AskTrnCtrlSkt();
1423+ // セッションあたりの転送量制限対策
1424+ if (TrnSkt != INVALID_SOCKET && AskErrorReconnect() == YES && LastError == YES)
1425+ {
1426+ ReleaseMutex(hListAccMutex);
1427+ PostMessage(GetMainHwnd(), WM_RECONNECTSOCKET, 0, 0);
1428+ Sleep(100);
1429+ TrnSkt = INVALID_SOCKET;
1430+ WaitForSingleObject(hListAccMutex, INFINITE);
1431+ }
1432+ }
1433+ else
1434+ {
1435+ // セッションあたりの転送量制限対策
1436+ if (TrnSkt != INVALID_SOCKET && AskErrorReconnect() == YES && LastError == YES)
1437+ {
1438+ ReleaseMutex(hListAccMutex);
1439+ DoQUIT(TrnSkt, &Canceled[ThreadCount]);
1440+ DoClose(TrnSkt);
1441+ TrnSkt = INVALID_SOCKET;
1442+ WaitForSingleObject(hListAccMutex, INFINITE);
1443+ }
1444+ if (TransPacketBase && AskConnecting() == YES && ThreadCount < AskMaxThreadCount())
1445+ {
1446+ ReleaseMutex(hListAccMutex);
1447+ if (TrnSkt == INVALID_SOCKET)
1448+ ReConnectTrnSkt(&TrnSkt, &Canceled[ThreadCount]);
1449+ else
1450+ CheckClosedAndReconnectTrnSkt(&TrnSkt, &Canceled[ThreadCount]);
1451+ // 同時ログイン数制限対策
1452+ if (TrnSkt == INVALID_SOCKET)
1453+ {
1454+ // 同時ログイン数制限に引っかかった可能性あり
1455+ // 負荷を下げるために約10秒間待機
1456+ Sleep(10 * 1000);
1457+ }
1458+ LastUsed = timeGetTime();
1459+ WaitForSingleObject(hListAccMutex, INFINITE);
1460+ }
1461+ else
1462+ {
1463+ if (TrnSkt != INVALID_SOCKET)
1464+ {
1465+ // 同時ログイン数制限対策
1466+ // 60秒間使用されなければログアウト
1467+ if (timeGetTime() - LastUsed > 60000 || AskConnecting() == NO || ThreadCount >= AskMaxThreadCount())
1468+ {
1469+ ReleaseMutex(hListAccMutex);
1470+ DoQUIT(TrnSkt, &Canceled[ThreadCount]);
1471+ DoClose(TrnSkt);
1472+ TrnSkt = INVALID_SOCKET;
1473+ WaitForSingleObject(hListAccMutex, INFINITE);
1474+ }
1475+ }
1476+ }
1477+ }
1478+ LastError = NO;
1479+ if (TrnSkt != INVALID_SOCKET && NextTransPacketBase != NULL)
1480+ {
1481+ Pos = NextTransPacketBase;
1482+ NextTransPacketBase = NextTransPacketBase->Next;
1483+ // ディレクトリ操作は非同期で行わない
1484+ // ReleaseMutex(hListAccMutex);
1485+ if (hWndTrans == NULL)
1486+ {
1487+ if ((strncmp(Pos->Cmd, "RETR", 4) == 0) ||
1488+ (strncmp(Pos->Cmd, "STOR", 4) == 0) ||
1489+ (strncmp(Pos->Cmd, "MKD", 3) == 0) ||
1490+ (strncmp(Pos->Cmd, "L-", 2) == 0) ||
1491+ (strncmp(Pos->Cmd, "R-", 2) == 0))
1492+ {
1493+ hWndTrans = CreateDialog(GetFtpInst(), MAKEINTRESOURCE(transfer_dlg), HWND_DESKTOP, (DLGPROC)TransDlgProc);
1494+ if (MoveToForeground == YES)
1495+ SetForegroundWindow(hWndTrans);
1496+ ShowWindow(hWndTrans, SW_SHOWNOACTIVATE);
1497+ GetWindowRect(hWndTrans, &WndRect);
1498+ SetWindowPos(hWndTrans, NULL, WndRect.left, WndRect.top + (WndRect.bottom - WndRect.top) * ThreadCount - (WndRect.bottom - WndRect.top) * (AskMaxThreadCount() - 1) / 2, 0, 0, SWP_NOSIZE | SWP_NOZORDER);
1499+ }
1500+ }
1501+ Pos->hWndTrans = hWndTrans;
1502+ Pos->ctrl_skt = TrnSkt;
1503+ Pos->Abort = ABORT_NONE;
1504+ Pos->ThreadCount = ThreadCount;
1505+
1506+ if (hWndTrans != NULL)
1507+ {
1508+ if (MoveToForeground == YES)
1509+ {
1510+ SetForegroundWindow(hWndTrans);
1511+ MoveToForeground = NO;
1512+ }
1513+ }
1514+
1515+ if (hWndTrans != NULL)
1516+ SendMessage(hWndTrans, WM_SET_PACKET, 0, (LPARAM)Pos);
1517+
1518+ // 中断後に受信バッファに応答が残っていると次のコマンドの応答が正しく処理できない
1519+ RemoveReceivedData(TrnSkt);
1520+
1521+ /* ダウンロード */
1522+ if (strncmp(Pos->Cmd, "RETR", 4) == 0)
1523+ {
1524+ // 一部TYPE、STOR(RETR)、PORT(PASV)を並列に処理できないホストがあるため
1525+ /* 不正なパスを検出 */
1526+ if (CheckPathViolation(Pos) == NO)
1527+ {
1528+ /* フルパスを使わないための処理 */
1529+ if (MakeNonFullPath(Pos, CurDir[Pos->ThreadCount], Tmp) == FFFTP_SUCCESS)
1530+ {
1531+ if (strncmp(Pos->Cmd, "RETR-S", 6) == 0)
1532+ {
1533+ /* サイズと日付を取得 */
1534+ DoSIZE(TrnSkt, Pos->RemoteFile, &Pos->Size, &Canceled[Pos->ThreadCount]);
1535+ DoMDTM(TrnSkt, Pos->RemoteFile, &Pos->Time, &Canceled[Pos->ThreadCount]);
1536+ strcpy(Pos->Cmd, "RETR ");
1537+ }
1538+
1539+ Down = YES;
1540+ // ミラーリング設定追加
1541+ if (Pos->NoTransfer == NO)
1542+ {
1543+ Sts = DoDownload(TrnSkt, Pos, NO, &Canceled[Pos->ThreadCount]) / 100;
1544+ if (Sts != FTP_COMPLETE)
1545+ LastError = YES;
1546+ }
1547+
1548+ // ミラーリング設定追加
1549+ if ((SaveTimeStamp == YES) &&
1550+ ((Pos->Time.dwLowDateTime != 0) || (Pos->Time.dwHighDateTime != 0)))
1551+ {
1552+ SetDownloadedFileTime(Pos);
1553+ }
1554+ }
1555+ }
1556+ // 一部TYPE、STOR(RETR)、PORT(PASV)を並列に処理できないホストがあるため
1557+ ReleaseMutex(hListAccMutex);
1558+ }
1559+ /* アップロード */
1560+ else if (strncmp(Pos->Cmd, "STOR", 4) == 0)
1561+ {
1562+ // 一部TYPE、STOR(RETR)、PORT(PASV)を並列に処理できないホストがあるため
1563+ /* フルパスを使わないための処理 */
1564+ if (MakeNonFullPath(Pos, CurDir[Pos->ThreadCount], Tmp) == FFFTP_SUCCESS)
1565+ {
1566+ Up = YES;
1567+ // ミラーリング設定追加
1568+ if (Pos->NoTransfer == NO)
1569+ {
1570+ Sts = DoUpload(TrnSkt, Pos) / 100;
1571+ if (Sts != FTP_COMPLETE)
1572+ LastError = YES;
1573+ }
1574+
1575+ // ホスト側の日時設定
1576+ /* ファイルのタイムスタンプを合わせる */
1577+ if ((SaveTimeStamp == YES) &&
1578+ ((Pos->Time.dwLowDateTime != 0) || (Pos->Time.dwHighDateTime != 0)))
1579+ {
1580+ DoMFMT(TrnSkt, Pos->RemoteFile, &Pos->Time, &Canceled[Pos->ThreadCount]);
1581+ }
1582+ }
1583+ // 一部TYPE、STOR(RETR)、PORT(PASV)を並列に処理できないホストがあるため
1584+ ReleaseMutex(hListAccMutex);
1585+ }
1586+ /* フォルダ作成(ローカルまたはホスト) */
1587+ else if (strncmp(Pos->Cmd, "MKD", 3) == 0)
1588+ {
1589+ DispTransFileInfo(Pos, MSGJPN078, FALSE, YES);
1590+
1591+ if (strlen(Pos->RemoteFile) > 0)
1592+ {
1593+ /* フルパスを使わないための処理 */
1594+ CwdSts = FTP_COMPLETE;
1595+ strcpy(Tmp, Pos->RemoteFile);
1596+ if (ProcForNonFullpath(TrnSkt, Tmp, CurDir[Pos->ThreadCount], hWndTrans, &Canceled[Pos->ThreadCount]) == FFFTP_FAIL)
1597+ {
1598+ ClearAll = YES;
1599+ CwdSts = FTP_ERROR;
1600+ }
1601+
1602+ if (CwdSts == FTP_COMPLETE)
1603+ {
1604+ Up = YES;
1605+ CommandProcTrn(TrnSkt, NULL, &Canceled[Pos->ThreadCount], "MKD %s", Tmp);
1606+ /* すでにフォルダがある場合もあるので、 */
1607+ /* ここではエラーチェックはしない */
1608+
1609+ if (FolderAttr)
1610+ CommandProcTrn(TrnSkt, NULL, &Canceled[Pos->ThreadCount], "%s %03d %s", AskHostChmodCmd(), FolderAttrNum, Tmp);
1611+ }
1612+ }
1613+ else if (strlen(Pos->LocalFile) > 0)
1614+ {
1615+ Down = YES;
1616+ DoLocalMKD(Pos->LocalFile);
1617+ }
1618+ ReleaseMutex(hListAccMutex);
1619+ }
1620+ /* ディレクトリ作成(常にホスト側) */
1621+ else if (strncmp(Pos->Cmd, "R-MKD", 5) == 0)
1622+ {
1623+ DispTransFileInfo(Pos, MSGJPN079, FALSE, YES);
1624+
1625+ /* フルパスを使わないための処理 */
1626+ if (MakeNonFullPath(Pos, CurDir[Pos->ThreadCount], Tmp) == FFFTP_SUCCESS)
1627+ {
1628+ Up = YES;
1629+ CommandProcTrn(TrnSkt, NULL, &Canceled[Pos->ThreadCount], "%s%s", Pos->Cmd + 2, Pos->RemoteFile);
1630+ if (FolderAttr)
1631+ CommandProcTrn(TrnSkt, NULL, &Canceled[Pos->ThreadCount], "%s %03d %s", AskHostChmodCmd(), FolderAttrNum, Pos->RemoteFile);
1632+ }
1633+ ReleaseMutex(hListAccMutex);
1634+ }
1635+ /* ディレクトリ削除(常にホスト側) */
1636+ else if (strncmp(Pos->Cmd, "R-RMD", 5) == 0)
1637+ {
1638+ DispTransFileInfo(Pos, MSGJPN080, FALSE, YES);
1639+ DelNotify = MirrorDelNotify(WIN_REMOTE, DelNotify, Pos);
1640+ if ((DelNotify == YES) || (DelNotify == YES_ALL))
1641+ {
1642+ /* フルパスを使わないための処理 */
1643+ if (MakeNonFullPath(Pos, CurDir[Pos->ThreadCount], Tmp) == FFFTP_SUCCESS)
1644+ {
1645+ Up = YES;
1646+ CommandProcTrn(TrnSkt, NULL, &Canceled[Pos->ThreadCount], "%s%s", Pos->Cmd + 2, Pos->RemoteFile);
1647+ }
1648+ }
1649+ ReleaseMutex(hListAccMutex);
1650+ }
1651+ /* ファイル削除(常にホスト側) */
1652+ else if (strncmp(Pos->Cmd, "R-DELE", 6) == 0)
1653+ {
1654+ DispTransFileInfo(Pos, MSGJPN081, FALSE, YES);
1655+ DelNotify = MirrorDelNotify(WIN_REMOTE, DelNotify, Pos);
1656+ if ((DelNotify == YES) || (DelNotify == YES_ALL))
1657+ {
1658+ /* フルパスを使わないための処理 */
1659+ if (MakeNonFullPath(Pos, CurDir[Pos->ThreadCount], Tmp) == FFFTP_SUCCESS)
1660+ {
1661+ Up = YES;
1662+ CommandProcTrn(TrnSkt, NULL, &Canceled[Pos->ThreadCount], "%s%s", Pos->Cmd + 2, Pos->RemoteFile);
1663+ }
1664+ }
1665+ ReleaseMutex(hListAccMutex);
1666+ }
1667+ /* ディレクトリ作成(常にローカル側) */
1668+ else if (strncmp(Pos->Cmd, "L-MKD", 5) == 0)
1669+ {
1670+ DispTransFileInfo(Pos, MSGJPN082, FALSE, YES);
1671+ Down = YES;
1672+ DoLocalMKD(Pos->LocalFile);
1673+ ReleaseMutex(hListAccMutex);
1674+ }
1675+ /* ディレクトリ削除(常にローカル側) */
1676+ else if (strncmp(Pos->Cmd, "L-RMD", 5) == 0)
1677+ {
1678+ DispTransFileInfo(Pos, MSGJPN083, FALSE, YES);
1679+ DelNotify = MirrorDelNotify(WIN_LOCAL, DelNotify, Pos);
1680+ if ((DelNotify == YES) || (DelNotify == YES_ALL))
1681+ {
1682+ Down = YES;
1683+ DoLocalRMD(Pos->LocalFile);
1684+ }
1685+ ReleaseMutex(hListAccMutex);
1686+ }
1687+ /* ファイル削除(常にローカル側) */
1688+ else if (strncmp(Pos->Cmd, "L-DELE", 6) == 0)
1689+ {
1690+ DispTransFileInfo(Pos, MSGJPN084, FALSE, YES);
1691+ DelNotify = MirrorDelNotify(WIN_LOCAL, DelNotify, Pos);
1692+ if ((DelNotify == YES) || (DelNotify == YES_ALL))
1693+ {
1694+ Down = YES;
1695+ DoLocalDELE(Pos->LocalFile);
1696+ }
1697+ ReleaseMutex(hListAccMutex);
1698+ }
1699+ /* カレントディレクトリを設定 */
1700+ else if (strcmp(Pos->Cmd, "SETCUR") == 0)
1701+ {
1702+ // if(AskShareProh() == YES)
1703+ if (AskReuseCmdSkt() == NO || AskShareProh() == YES)
1704+ {
1705+ if (strcmp(CurDir[Pos->ThreadCount], Pos->RemoteFile) != 0)
1706+ {
1707+ if (CommandProcTrn(TrnSkt, NULL, &Canceled[Pos->ThreadCount], "CWD %s", Pos->RemoteFile) / 100 != FTP_COMPLETE)
1708+ {
1709+ DispCWDerror(hWndTrans);
1710+ ClearAll = YES;
1711+ }
1712+ }
1713+ }
1714+ strcpy(CurDir[Pos->ThreadCount], Pos->RemoteFile);
1715+ ReleaseMutex(hListAccMutex);
1716+ }
1717+ /* カレントディレクトリを戻す */
1718+ else if (strcmp(Pos->Cmd, "BACKCUR") == 0)
1719+ {
1720+ if (AskReuseCmdSkt() == YES && AskShareProh() == NO)
1721+ {
1722+ if (strcmp(CurDir[Pos->ThreadCount], Pos->RemoteFile) != 0)
1723+ CommandProcTrn(TrnSkt, NULL, &Canceled[Pos->ThreadCount], "CWD %s", Pos->RemoteFile);
1724+ strcpy(CurDir[Pos->ThreadCount], Pos->RemoteFile);
1725+ }
1726+ ReleaseMutex(hListAccMutex);
1727+ }
1728+ /* 自動終了のための通知 */
1729+ else if (strcmp(Pos->Cmd, "NULL") == 0)
1730+ {
1731+ Sleep(0);
1732+ Sleep(100);
1733+ ReleaseMutex(hListAccMutex);
1734+ }
1735+ else
1736+ ReleaseMutex(hListAccMutex);
1737+
1738+ /*===== 1つの処理終わり =====*/
1739+
1740+ if (ForceAbort == NO)
1741+ {
1742+ WaitForSingleObject(hListAccMutex, INFINITE);
1743+ if (ClearAll == YES)
1744+ // EraseTransFileList();
1745+ {
1746+ for (i = 0; i < MAX_DATA_CONNECTION; i++)
1747+ Canceled[i] = YES;
1748+ if (Pos != NULL)
1749+ strcpy(Pos->Cmd, "");
1750+ Pos = NULL;
1751+ EraseTransFileList();
1752+ GoExit = YES;
1753+ }
1754+ else
1755+ {
1756+ if ((strncmp(Pos->Cmd, "RETR", 4) == 0) ||
1757+ (strncmp(Pos->Cmd, "STOR", 4) == 0) ||
1758+ (strncmp(Pos->Cmd, "STOU", 4) == 0))
1759+ {
1760+ // TransFiles--;
1761+ if (TransFiles > 0)
1762+ TransFiles--;
1763+ // タスクバー進捗表示
1764+ if (TransferSizeLeft > 0)
1765+ TransferSizeLeft -= Pos->Size;
1766+ if (TransferSizeLeft < 0)
1767+ TransferSizeLeft = 0;
1768+ if (TransFiles == 0)
1769+ TransferSizeTotal = 0;
1770+ PostMessage(GetMainHwnd(), WM_CHANGE_COND, 0, 0);
1771+ }
1772+ }
1773+ ReleaseMutex(hListAccMutex);
1774+ }
1775+ if (hWndTrans != NULL)
1776+ SendMessage(hWndTrans, WM_SET_PACKET, 0, 0);
1777+ if (Pos != NULL)
1778+ strcpy(Pos->Cmd, "");
1779+ LastUsed = timeGetTime();
1780+ }
1781+ // else
1782+ else if (TransPacketBase == NULL)
1783+ {
1784+ ClearAll = NO;
1785+ DelNotify = NO;
1786+
1787+ if (GoExit == YES)
1788+ {
1789+ SoundPlay(SND_TRANS);
1790+ if (AskAutoExit() == NO)
1791+ {
1792+ if (Down == YES)
1793+ PostMessage(GetMainHwnd(), WM_REFRESH_LOCAL_FLG, 0, 0);
1794+ if (Up == YES)
1795+ PostMessage(GetMainHwnd(), WM_REFRESH_REMOTE_FLG, 0, 0);
1796+ }
1797+ Down = NO;
1798+ Up = NO;
1799+ PostMessage(GetMainHwnd(), WM_COMMAND, MAKEWPARAM(MENU_AUTO_EXIT, 0), 0);
1800+ GoExit = NO;
1801+ }
1802+
1803+ ReleaseMutex(hListAccMutex);
1804+ if (KeepDlg == NO)
1805+ {
1806+ if (hWndTrans != NULL)
1807+ {
1808+ DestroyWindow(hWndTrans);
1809+ hWndTrans = NULL;
1810+ }
1811+ }
1812+ Sleep(100);
1813+
1814+ // 再転送対応
1815+ TransferErrorMode = AskTransferErrorMode();
1816+ TransferErrorNotify = AskTransferErrorNotify();
1817+ }
1818+ else
1819+ {
1820+ ReleaseMutex(hListAccMutex);
1821+ if (hWndTrans != NULL)
1822+ {
1823+ DestroyWindow(hWndTrans);
1824+ hWndTrans = NULL;
1825+ }
1826+ if (ThreadCount < AskMaxThreadCount())
1827+ Sleep(1);
1828+ else
1829+ Sleep(100);
1830+ }
1831+ }
1832+ if (AskReuseCmdSkt() == NO || ThreadCount > 0)
1833+ {
1834+ if (TrnSkt != INVALID_SOCKET)
1835+ {
1836+ SendData(TrnSkt, "QUIT\r\n", 6, 0, &Canceled[ThreadCount]);
1837+ DoClose(TrnSkt);
1838+ }
1839+ }
1840+ return 0;
1841+}
1842+
1843+#endif
13621844
13631845
13641846 /*----- フルパスを使わないファイルアクセスの準備 ------------------------------
--- a/src/FFFTP2/main_w.c
+++ b/src/FFFTP2/main_w.c
@@ -76,10 +76,10 @@
7676
7777 /*===== プロトタイプ =====*/
7878
79-static int InitApp(LPSTR lpszCmdLine, int cmdShow);
79+int InitApp(LPSTR lpszCmdLine, int cmdShow);
8080 static int MakeAllWindows(int cmdShow);
8181 static void DeleteAllObject(void);
82-static LRESULT CALLBACK FtpWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam);
82+LRESULT CALLBACK FtpWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam);
8383 static void StartupProc(char *Cmd);
8484 static int AnalyzeComLine(char *Str, int *AutoConnect, int *CmdOption, char *unc, int Max);
8585 static int CheckIniFileName(char *Str, char *Ini);
@@ -568,7 +568,7 @@ int PASCAL _WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpszCmdL
568568 * FFFTP_SUCCESS/FFFTP_FAIL
569569 *----------------------------------------------------------------------------*/
570570
571-static int InitApp(LPSTR lpszCmdLine, int cmdShow)
571+int InitApp(LPSTR lpszCmdLine, int cmdShow)
572572 {
573573 int sts;
574574 int Err;
@@ -749,7 +749,8 @@ static int InitApp(LPSTR lpszCmdLine, int cmdShow)
749749
750750 CountPrevFfftpWindows();
751751
752- if(MakeAllWindows(cmdShow) == FFFTP_SUCCESS)
752+ // by masuda
753+ // if(MakeAllWindows(cmdShow) == FFFTP_SUCCESS)
753754 {
754755 hWndCurFocus = GetLocalHwnd();
755756
@@ -1056,6 +1057,9 @@ HWND GetMainHwnd(void)
10561057 {
10571058 return(hWndFtp);
10581059 }
1060+void SetMainHwnd(HWND hwnd) {
1061+ hWndFtp = hwnd;
1062+}
10591063
10601064
10611065 /*----- 現在フォーカスがあるウインドウのウインドウハンドルを返す --------------
@@ -1115,8 +1119,8 @@ HINSTANCE GetFtpInst(void)
11151119 * Return Value
11161120 * メッセージに対応する戻り値
11171121 *----------------------------------------------------------------------------*/
1118-
1119-static LRESULT CALLBACK FtpWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
1122+#define DefWindowProc
1123+LRESULT CALLBACK FtpWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
11201124 {
11211125 PAINTSTRUCT ps;
11221126 LPTOOLTIPTEXT lpttt;
@@ -2132,6 +2136,7 @@ static LRESULT CALLBACK FtpWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARA
21322136 }
21332137 return(0L);
21342138 }
2139+#define DefWindowProc DefWindowProcM
21352140
21362141
21372142 /*----- プログラム開始時の処理 ------------------------------------------------
--- a/src/FFFTP2/toolmenu_w.c
+++ b/src/FFFTP2/toolmenu_w.c
@@ -86,6 +86,12 @@ static HWND hWndDirLocal = NULL;
8686 static HWND hWndDirRemote = NULL;
8787 static HWND hWndDirLocalEdit = NULL;
8888 static HWND hWndDirRemoteEdit = NULL;
89+// by masuda
90+void SetWndDirLocal(HWND hwnd) { hWndDirLocal = hwnd; }
91+void SetWndDirRemote(HWND hwnd) { hWndDirRemote = hwnd; }
92+void SetWndDirLocalEdit(HWND hwnd) { hWndDirLocalEdit = hwnd; }
93+void SetWndDirRemoteEdit(HWND hwnd) { hWndDirRemoteEdit = hwnd; }
94+
8995
9096 static WNDPROC HistEditBoxProcPtr;
9197