Ticket #1464: filezilla_utf8_showstatus.patch
File filezilla_utf8_showstatus.patch, 11.5 KB (added by , 20 years ago) |
---|
-
SFtpIpc.cpp
diff -Nur source/SFtpIpc.cpp source.patch/SFtpIpc.cpp
old new 327 327 return 0; 328 328 } 329 329 330 BOOL CSFtpIpc::Send(const DWORD &nID, const DWORD &nDataLength, const LPVOID pData )330 BOOL CSFtpIpc::Send(const DWORD &nID, const DWORD &nDataLength, const LPVOID pData, CString status) 331 331 { 332 332 USES_CONVERSION; 333 333 ASSERT(m_hSFtpProcess); … … 337 337 ASSERT(!nDataLength || pData); 338 338 339 339 CString str; 340 if (nID==SFTP_DATAID_STC_CONNECT) 341 str.Format( _T("CONNECT %s@%s:%d"), A2CT((char *)pData+strlen((char *)pData)+1+4), A2CT((char *)pData), *(int *)((char *)pData+strlen((char *)pData)+1) ); 340 if (nID==SFTP_DATAID_STC_CONNECT) { 341 if (status == "") 342 str.Format( _T("CONNECT %s@%s:%d"), A2CT((char *)pData+strlen((char *)pData)+1+4), A2CT((char *)pData), *(int *)((char *)pData+strlen((char *)pData)+1) ); 343 else 344 str = _T("CONNECT ") + status; 345 } 342 346 else if (nID==SFTP_DATAID_STC_PWD) 343 347 str="PWD"; 344 else if (nID==SFTP_DATAID_STC_CD) 345 str=(CString)"CD " + (char *)pData; 348 else if (nID==SFTP_DATAID_STC_CD) { 349 if (status == "") 350 str=(CString)"CD " + (char *)pData; 351 else 352 str = _T("CD ") + status; 353 } 346 354 else if (nID==SFTP_DATAID_STC_LIST) 347 355 str="LIST"; 348 else if (nID==SFTP_DATAID_STC_MKD) 349 str=(CString)"MKD " + (char *)pData; 350 else if (nID==SFTP_DATAID_STC_GET) 351 str.Format( _T("GET %s %s %s"), 356 else if (nID==SFTP_DATAID_STC_MKD) { 357 if (status == "") 358 str=(CString)"MKD " + (char *)pData; 359 else 360 str = _T("MKD ") + status; 361 } 362 else if (nID==SFTP_DATAID_STC_GET) { 363 if (status == "") 364 str.Format( _T("GET %s %s %s"), 352 365 A2CT((char *)pData), 353 366 A2CT((char *)pData+strlen((char *)pData)+1), 354 367 ( *(int *)((char *)pData+strlen((char *)pData)+1+strlen((char *)pData+strlen((char *)pData)+1)+1)?_T("TRUE"):_T("FALSE") )); 355 else if (nID==SFTP_DATAID_STC_PUT) 356 str.Format( _T("PUT %s %s %s"), 368 else 369 str = _T("GET ") + status; 370 } 371 else if (nID==SFTP_DATAID_STC_PUT) { 372 if (status == "") 373 str.Format( _T("PUT %s %s %s"), 357 374 A2CT((char *)pData), 358 375 A2CT((char *)pData+strlen((char *)pData)+1), 359 376 ( *(int *)((char *)pData+strlen((char *)pData)+1+strlen((char *)pData+strlen((char *)pData)+1)+1)?_T("TRUE"):_T("FALSE") )); 360 else if (nID==SFTP_DATAID_STC_DELE) 361 str=(CString)"DELE " + (char *)pData; 362 else if (nID==SFTP_DATAID_STC_RMD) 363 str=(CString)"RMD " + (char *)pData; 364 else if (nID==SFTP_DATAID_STC_RENAME) 365 str.Format( _T("RENAME %s %s"), 377 else 378 str = _T("PUT ") + status; 379 } 380 else if (nID==SFTP_DATAID_STC_DELE) { 381 if (status == "") 382 str=(CString)"DELE " + (char *)pData; 383 else 384 str = _T("DELE ") + status; 385 } 386 else if (nID==SFTP_DATAID_STC_RMD) { 387 if (status == "") 388 str=(CString)"RMD " + (char *)pData; 389 else 390 str = _T("RMD ") + status; 391 } 392 else if (nID==SFTP_DATAID_STC_RENAME) { 393 if (status == "") 394 str.Format( _T("RENAME %s %s"), 366 395 A2CT((char *)pData), 367 396 A2CT((char *)pData+strlen((char *)pData)+1)); 368 else if (nID==SFTP_DATAID_STC_CHMOD) 369 str.Format( _T("CHMOD %s %s"), 397 else 398 str = _T("RENAME ") + status; 399 } 400 else if (nID==SFTP_DATAID_STC_CHMOD) { 401 if (status == "") 402 str.Format( _T("CHMOD %s %s"), 370 403 A2CT((char *)pData), 371 404 A2CT((char *)pData+strlen((char *)pData)+1)); 405 else 406 str = _T("CHMOD ") + status; 407 } 372 408 if (str!="") 373 409 m_pOwner->ShowStatus(str, 2); 374 410 … … 428 464 char* utf8 = new char[len + 1]; 429 465 WideCharToMultiByte(CP_UTF8, 0, unicode, -1, utf8, len + 1, 0, 0); 430 466 431 res = Send(nID, (const DWORD)strlen(utf8)+1, (LPVOID)utf8 );467 res = Send(nID, (const DWORD)strlen(utf8)+1, (LPVOID)utf8, str); 432 468 delete [] utf8; 433 469 return res; 434 470 } 435 471 else 436 472 { 437 return Send(nID, (const DWORD)strlen(T2CA(str))+1, (LPVOID)T2CA(str) );473 return Send(nID, (const DWORD)strlen(T2CA(str))+1, (LPVOID)T2CA(str), str); 438 474 } 439 475 } 440 476 else -
SFtpIpc.h
diff -Nur source/SFtpIpc.h source.patch/SFtpIpc.h
old new 34 34 friend CSFtpIpcHelperWindow; 35 35 public: 36 36 BOOL Send(const DWORD &nID, LPCTSTR str); 37 BOOL Send(const DWORD &nID, const DWORD &nDataLength, const LPVOID pData );37 BOOL Send(const DWORD &nID, const DWORD &nDataLength, const LPVOID pData, CString status = ""); 38 38 BOOL AttachProcess(HANDLE hSFtpProcess); 39 39 CString GetHandleString(); 40 40 CSFtpIpc(CSFtpControlSocket *pOwner); -
SftpControlSocket.cpp
diff -Nur source/SftpControlSocket.cpp source.patch/SftpControlSocket.cpp
old new 1468 1468 char *pCmd; 1469 1469 int nLen1; 1470 1470 int nLen2; 1471 CString status = filename + _T(" ") + pData->transferfile.localfile; 1472 if (pData->transferdata.bResume) 1473 status += _T(" TRUE"); 1474 else 1475 status += _T(" FALSE"); 1471 1476 if (m_bUTF8) { 1472 1477 #ifdef _UNICODE 1473 1478 LPCWSTR unicode_remote = T2CW(filename); … … 1526 1531 *pData->pStartTime = CTime::GetCurrentTime(); 1527 1532 if (pData->transferfile.get) 1528 1533 { 1529 if (!m_pDataChannel->Send(SFTP_DATAID_STC_GET, nLen1+nLen2+4, pCmd ))1534 if (!m_pDataChannel->Send(SFTP_DATAID_STC_GET, nLen1+nLen2+4, pCmd, status)) 1530 1535 bError=TRUE; 1531 1536 } 1532 1537 else 1533 if (!m_pDataChannel->Send(SFTP_DATAID_STC_PUT, nLen1+nLen2+4, pCmd ))1538 if (!m_pDataChannel->Send(SFTP_DATAID_STC_PUT, nLen1+nLen2+4, pCmd, status)) 1534 1539 bError=TRUE; 1535 1540 1536 1541 … … 1686 1691 m_Operation.nOpMode = CSMODE_RENAME; 1687 1692 int nLen; 1688 1693 char *pData; 1694 CString s_oldname, s_newname; 1689 1695 if (newPath.IsEmpty()) 1690 1696 { 1691 if (m_bUTF8) { 1692 LPCWSTR uni_oldname = T2CW(path.GetPath() + oldName); 1693 int len = WideCharToMultiByte(CP_UTF8, 0, uni_oldname, -1, 0, 0, 0, 0); 1694 char* utf8_oldname = new char[len + 1]; 1695 WideCharToMultiByte(CP_UTF8, 0, uni_oldname, -1, utf8_oldname, len + 1, 0, 0); 1696 LPCWSTR uni_newname = T2CW(path.GetPath() + newName); 1697 len = WideCharToMultiByte(CP_UTF8, 0, uni_newname, -1, 0, 0, 0, 0); 1698 char* utf8_newname = new char[len + 1]; 1699 WideCharToMultiByte(CP_UTF8, 0, uni_newname, -1, utf8_newname, len + 1, 0, 0); 1700 nLen = strlen(utf8_oldname) + strlen(utf8_newname) + 2; 1701 pData = new char[nLen]; 1702 strcpy(pData, utf8_oldname); 1703 strcpy(pData + strlen(utf8_oldname) + 1, utf8_newname); 1704 delete [] utf8_oldname; 1705 delete [] utf8_newname; 1706 } 1707 else { 1708 nLen = _tcslen( path.GetPath() + oldName + path.GetPath() + newName) + 2; 1709 pData = new char[nLen]; 1710 strcpy(pData, T2CA(path.GetPath() + oldName)); 1711 strcpy(pData + _tcslen(path.GetPath() + oldName) + 1, T2CA(path.GetPath() + newName)); 1712 } 1697 s_oldname = path.GetPath() + oldName; 1698 s_newname = path.GetPath() + newName; 1713 1699 } 1714 else 1715 { 1716 if (m_bUTF8) { 1717 LPCWSTR uni_oldname = T2CW(path.GetPath() + oldName); 1718 int len = WideCharToMultiByte(CP_UTF8, 0, uni_oldname, -1, 0, 0, 0, 0); 1719 char* utf8_oldname = new char[len + 1]; 1720 WideCharToMultiByte(CP_UTF8, 0, uni_oldname, -1, utf8_oldname, len + 1, 0, 0); 1721 LPCWSTR uni_newname = T2CW(newPath.GetPath() + newName); 1722 len = WideCharToMultiByte(CP_UTF8, 0, uni_newname, -1, 0, 0, 0, 0); 1723 char* utf8_newname = new char[len + 1]; 1724 WideCharToMultiByte(CP_UTF8, 0, uni_newname, -1, utf8_newname, len + 1, 0, 0); 1725 nLen = strlen(utf8_oldname) + strlen(utf8_newname) + 2; 1726 pData = new char[nLen]; 1727 strcpy(pData, utf8_oldname); 1728 strcpy(pData + strlen(utf8_oldname) + 1, utf8_newname); 1729 delete [] utf8_oldname; 1730 delete [] utf8_newname; 1731 } 1732 else { 1733 nLen = _tcslen( path.GetPath() + oldName + newPath.GetPath() + newName) + 2; 1734 pData = new char[nLen]; 1735 strcpy(pData, T2CA(path.GetPath() + oldName)); 1736 strcpy(pData + _tcslen(path.GetPath() + oldName) + 1, T2CA(newPath.GetPath() + newName)); 1737 } 1700 else { 1701 s_oldname = path.GetPath() + oldName; 1702 s_newname = newPath.GetPath() + newName; 1703 } 1704 CString status = _T("RENAME ") + s_oldname + _T(" ") + s_newname; 1705 if (m_bUTF8) { 1706 LPCWSTR uni_oldname = T2CW(s_oldname); 1707 int len = WideCharToMultiByte(CP_UTF8, 0, uni_oldname, -1, 0, 0, 0, 0); 1708 char* utf8_oldname = new char[len + 1]; 1709 WideCharToMultiByte(CP_UTF8, 0, uni_oldname, -1, utf8_oldname, len + 1, 0, 0); 1710 LPCWSTR uni_newname = T2CW(s_newname); 1711 len = WideCharToMultiByte(CP_UTF8, 0, uni_newname, -1, 0, 0, 0, 0); 1712 char* utf8_newname = new char[len + 1]; 1713 WideCharToMultiByte(CP_UTF8, 0, uni_newname, -1, utf8_newname, len + 1, 0, 0); 1714 nLen = strlen(utf8_oldname) + strlen(utf8_newname) + 2; 1715 pData = new char[nLen]; 1716 strcpy(pData, utf8_oldname); 1717 strcpy(pData + strlen(utf8_oldname) + 1, utf8_newname); 1718 delete [] utf8_oldname; 1719 delete [] utf8_newname; 1720 } 1721 else { 1722 nLen = _tcslen( s_oldname + s_newname) + 2; 1723 pData = new char[nLen]; 1724 strcpy(pData, T2CA(s_oldname)); 1725 strcpy(pData + _tcslen(s_oldname) + 1, T2CA(s_newname)); 1738 1726 } 1739 if (!m_pDataChannel->Send(SFTP_DATAID_STC_RENAME, nLen, pData ))1727 if (!m_pDataChannel->Send(SFTP_DATAID_STC_RENAME, nLen, pData, status)) 1740 1728 { 1741 1729 delete [] pData; 1742 1730 DoClose(); … … 2410 2398 while (p=strstr(str, "\n")) 2411 2399 { 2412 2400 *p = 0; 2413 ShowStatus(str, 3); 2401 if (m_bUTF8) { 2402 USES_CONVERSION; 2403 2404 // convert from UTF-8 to ANSI 2405 int len = MultiByteToWideChar(CP_UTF8, 0, (LPCSTR)str, -1, NULL, 0); 2406 if (len != 0) 2407 { 2408 LPWSTR p1 = new WCHAR[len + 1]; 2409 MultiByteToWideChar(CP_UTF8, 0, (LPCSTR)str, -1 , (LPWSTR)p1, len*2); 2410 CString tempstr = W2CT(p1); 2411 delete [] p1; 2412 ShowStatus(tempstr, 3); 2413 } 2414 else 2415 ShowStatus(str, 3); 2416 } 2417 else 2418 ShowStatus(str, 3); 2414 2419 str = p+1; 2415 2420 } 2416 ShowStatus(str, 3); 2421 if (m_bUTF8) { 2422 USES_CONVERSION; 2423 2424 // convert from UTF-8 to ANSI 2425 int len = MultiByteToWideChar(CP_UTF8, 0, (LPCSTR)str, -1, NULL, 0); 2426 if (len != 0) 2427 { 2428 LPWSTR p1 = new WCHAR[len + 1]; 2429 MultiByteToWideChar(CP_UTF8, 0, (LPCSTR)str, -1 , (LPWSTR)p1, len*2); 2430 CString tempstr = W2CT(p1); 2431 delete [] p1; 2432 ShowStatus(tempstr, 3); 2433 } 2434 else 2435 ShowStatus(str, 3); 2436 } 2437 else 2438 ShowStatus(str, 3); 2417 2439 } 2418 2440 break; 2419 2441 case SFTP_DATAID_CTS_CRITICALERROR: … … 2458 2480 ResetOperation(FZ_REPLY_ERROR); 2459 2481 else 2460 2482 { 2461 ShowStatus((char *)pData, 3); 2483 if (m_bUTF8) { 2484 USES_CONVERSION; 2485 2486 // convert from UTF-8 to ANSI 2487 int len = MultiByteToWideChar(CP_UTF8, 0, (LPCSTR)pData, -1, NULL, 0); 2488 if (len != 0) 2489 { 2490 LPWSTR p1 = new WCHAR[len + 1]; 2491 MultiByteToWideChar(CP_UTF8, 0, (LPCSTR)pData, -1 , (LPWSTR)p1, len*2); 2492 CString tempstr = W2CT(p1); 2493 delete [] p1; 2494 ShowStatus(tempstr, 3); 2495 } 2496 else 2497 ShowStatus((char *)pData, 3); 2498 } 2499 else 2500 ShowStatus((char *)pData, 3); 2462 2501 ProcessReply(); 2463 2502 } 2464 2503 break; … … 3137 3176 USES_CONVERSION; 3138 3177 m_Operation.nOpMode=CSMODE_CHMOD; 3139 3178 CString str; 3179 CString status; 3140 3180 int nLen; 3141 3181 char *pData; 3142 3182 str.Format( _T("%d %s%s"), nValue, path.GetPath(), filename); 3183 status = _T("CHMOD ") + str; 3143 3184 if (m_bUTF8) { 3144 3185 USES_CONVERSION; 3145 3186 … … 3162 3203 ASSERT(pos!=-1); 3163 3204 pData[pos]=0; 3164 3205 } 3165 if (!m_pDataChannel->Send(SFTP_DATAID_STC_CHMOD, nLen, pData ))3206 if (!m_pDataChannel->Send(SFTP_DATAID_STC_CHMOD, nLen, pData, status)) 3166 3207 DoClose(); 3167 3208 delete [] pData; 3168 3209 }