Ticket #8013: 8013.patch

File 8013.patch, 20.9 KB (added by Tautvydas Andrikys, 8 years ago)

Implemented this feature

  • src/engine/ControlSocket.cpp

    diff -r c04cba15ffba -r 92b83b739411 src/engine/ControlSocket.cpp
    a b  
    468468
    469469    CFileExistsNotification *pNotification = new CFileExistsNotification;
    470470
     471    pNotification->localFileAlias = pData->localFileAlias;
    471472    pNotification->download = pData->download;
    472473    pNotification->localFile = pData->localFile;
    473474    pNotification->remoteFile = pData->remoteFile;
     
    12711272            }
    12721273            else
    12731274            {
    1274                 LogMessage(Status, _("Skipping upload of %s"), pData->localFile.c_str());
     1275                LogMessage(
     1276                    Status, _("Skipping upload of %s"),
     1277                    (pData->localFileAlias.empty() ? pData->localFile : pData->localFileAlias).c_str()
     1278                );
    12751279            }
    12761280            ResetOperation(FZ_REPLY_OK);
    12771281        }
     
    12901294            }
    12911295            else
    12921296            {
    1293                 LogMessage(Status, _("Skipping upload of %s"), pData->localFile.c_str());
     1297                LogMessage(
     1298                    Status, _("Skipping upload of %s"),
     1299                    (pData->localFileAlias.empty() ? pData->localFile : pData->localFileAlias).c_str()
     1300                );
    12941301            }
    12951302            ResetOperation(FZ_REPLY_OK);
    12961303        }
     
    13151322            }
    13161323            else
    13171324            {
    1318                 LogMessage(Status, _("Skipping upload of %s"), pData->localFile.c_str());
     1325                LogMessage(
     1326                    Status, _("Skipping upload of %s"),
     1327                    (pData->localFileAlias.empty() ? pData->localFile : pData->localFileAlias).c_str()
     1328                );
    13191329            }
    13201330            ResetOperation(FZ_REPLY_OK);
    13211331        }
     
    13811391        }
    13821392        else
    13831393        {
    1384             LogMessage(Status, _("Skipping upload of %s"), pData->localFile.c_str());
     1394            LogMessage(
     1395                Status, _("Skipping upload of %s"),
     1396                        (pData->localFileAlias.empty() ? pData->localFile : pData->localFileAlias).c_str()
     1397            );
    13851398        }
    13861399        ResetOperation(FZ_REPLY_OK);
    13871400        break;
  • src/engine/ControlSocket.h

    diff -r c04cba15ffba -r 92b83b739411 src/engine/ControlSocket.h
    a b  
    3939    CFileTransferOpData(bool is_download, const wxString& local_file, const wxString& remote_file, const CServerPath& remote_path);
    4040    virtual ~CFileTransferOpData();
    4141    // Transfer data
    42     wxString localFile, remoteFile;
     42    wxString localFileAlias, localFile, remoteFile;
    4343    CServerPath remotePath;
    4444    const bool download;
    4545
     
    124124    virtual int List(CServerPath path = CServerPath(), wxString subDir = _T(""), int flags = 0) { return FZ_REPLY_NOTSUPPORTED; }
    125125    virtual int FileTransfer(const wxString localFile, const CServerPath &remotePath,
    126126                             const wxString &remoteFile, bool download,
    127                              const CFileTransferCommand::t_transferSettings& transferSettings) { return FZ_REPLY_NOTSUPPORTED; }
     127                             const CFileTransferCommand::t_transferSettings& transferSettings,
     128                             const wxString& localFileAlias) { return FZ_REPLY_NOTSUPPORTED; }
    128129    virtual int RawCommand(const wxString& command = _T("")) { return FZ_REPLY_NOTSUPPORTED; }
    129130    virtual int Delete(const CServerPath& path, const std::list<wxString>& files) { return FZ_REPLY_NOTSUPPORTED; }
    130131    virtual int RemoveDir(const CServerPath& path = CServerPath(), const wxString& subDir = _T("")) { return FZ_REPLY_NOTSUPPORTED; }
  • src/engine/commands.cpp

    diff -r c04cba15ffba -r 92b83b739411 src/engine/commands.cpp
    a b  
    3333
    3434CFileTransferCommand::CFileTransferCommand(const wxString &localFile, const CServerPath& remotePath,
    3535                                           const wxString &remoteFile, bool download,
    36                                            const CFileTransferCommand::t_transferSettings& transferSettings)
    37     : m_localFile(localFile), m_remotePath(remotePath), m_remoteFile(remoteFile)
     36                                           const CFileTransferCommand::t_transferSettings& transferSettings,
     37                                             const wxString& localFileAlias)
     38    : m_localFile(localFile), m_remotePath(remotePath), m_remoteFile(remoteFile),
     39        m_localFileAlias(localFileAlias)
    3840{
    3941    m_download = download;
    4042    m_transferSettings = transferSettings;
     
    4547    return m_localFile;
    4648}
    4749
     50wxString CFileTransferCommand::GetLocalFileAlias() const
     51{
     52    return m_localFileAlias;
     53}
     54
    4855CServerPath CFileTransferCommand::GetRemotePath() const
    4956{
    5057    return m_remotePath;
  • src/engine/engineprivate.cpp

    diff -r c04cba15ffba -r 92b83b739411 src/engine/engineprivate.cpp
    a b  
    400400        return FZ_REPLY_BUSY;
    401401
    402402    m_pCurrentCommand = command.Clone();
    403     return m_pControlSocket->FileTransfer(command.GetLocalFile(), command.GetRemotePath(), command.GetRemoteFile(), command.Download(), command.GetTransferSettings());
     403    return m_pControlSocket->FileTransfer(
     404        command.GetLocalFile(), command.GetRemotePath(), command.GetRemoteFile(), command.Download(),
     405        command.GetTransferSettings(), command.GetLocalFileAlias()
     406    );
    404407}
    405408
    406409int CFileZillaEnginePrivate::RawCommand(const CRawCommand& command)
  • src/engine/ftpcontrolsocket.cpp

    diff -r c04cba15ffba -r 92b83b739411 src/engine/ftpcontrolsocket.cpp
    a b  
    22062206
    22072207int CFtpControlSocket::FileTransfer(const wxString localFile, const CServerPath &remotePath,
    22082208                                    const wxString &remoteFile, bool download,
    2209                                     const CFileTransferCommand::t_transferSettings& transferSettings)
     2209                                    const CFileTransferCommand::t_transferSettings& transferSettings,
     2210                                    const wxString& localFileAlias)
    22102211{
    22112212    LogMessage(Debug_Verbose, _T("CFtpControlSocket::FileTransfer()"));
    22122213
     
    22262227    }
    22272228    else
    22282229    {
    2229         LogMessage(Status, _("Starting upload of %s"), localFile.c_str());
     2230        LogMessage(
     2231            Status, _("Starting upload of %s"),
     2232            (localFileAlias.empty() ? localFile : localFileAlias).c_str()
     2233        );
    22302234    }
    22312235    if (m_pCurOpData)
    22322236    {
     
    22352239    }
    22362240
    22372241    CFtpFileTransferOpData *pData = new CFtpFileTransferOpData(download, localFile, remoteFile, remotePath);
     2242    pData->localFileAlias = localFileAlias;
    22382243    m_pCurOpData = pData;
    22392244
    22402245    pData->transferSettings = transferSettings;
  • src/engine/ftpcontrolsocket.h

    diff -r c04cba15ffba -r 92b83b739411 src/engine/ftpcontrolsocket.h
    a b  
    4040
    4141    virtual int FileTransfer(const wxString localFile, const CServerPath &remotePath,
    4242                             const wxString &remoteFile, bool download,
    43                              const CFileTransferCommand::t_transferSettings& transferSettings);
     43                             const CFileTransferCommand::t_transferSettings& transferSettings,
     44                             const wxString& localFileAlias);
    4445    int FileTransferParseResponse();
    4546    int FileTransferSubcommandResult(int prevResult);
    4647    int FileTransferSend();
  • src/engine/httpcontrolsocket.cpp

    diff -r c04cba15ffba -r 92b83b739411 src/engine/httpcontrolsocket.cpp
    a b  
    351351
    352352int CHttpControlSocket::FileTransfer(const wxString localFile, const CServerPath &remotePath,
    353353                              const wxString &remoteFile, bool download,
    354                               const CFileTransferCommand::t_transferSettings& transferSettings)
     354                              const CFileTransferCommand::t_transferSettings& transferSettings,
     355                                const wxString& localFileAlias)
    355356{
    356357    LogMessage(Debug_Verbose, _T("CHttpControlSocket::FileTransfer()"));
    357358
     
    370371    }
    371372
    372373    CHttpFileTransferOpData *pData = new CHttpFileTransferOpData(download, localFile, remoteFile, remotePath);
     374    pData->localFileAlias = localFileAlias;
    373375    m_pCurOpData = pData;
    374376    m_pHttpOpData = pData;
    375377
  • src/engine/httpcontrolsocket.h

    diff -r c04cba15ffba -r 92b83b739411 src/engine/httpcontrolsocket.h
    a b  
    1919
    2020    virtual int FileTransfer(const wxString localFile, const CServerPath &remotePath,
    2121                             const wxString &remoteFile, bool download,
    22                              const CFileTransferCommand::t_transferSettings& transferSettings);
     22                             const CFileTransferCommand::t_transferSettings& transferSettings,
     23                             const wxString& localFileAlias);
    2324    virtual int FileTransferSend();
    2425    virtual int FileTransferParseResponse(char* p, unsigned int len);
    2526    virtual int FileTransferSubcommandResult(int prevResult);
  • src/engine/sftpcontrolsocket.cpp

    diff -r c04cba15ffba -r 92b83b739411 src/engine/sftpcontrolsocket.cpp
    a b  
    16141614
    16151615int CSftpControlSocket::FileTransfer(const wxString localFile, const CServerPath &remotePath,
    16161616                                    const wxString &remoteFile, bool download,
    1617                                     const CFileTransferCommand::t_transferSettings& transferSettings)
     1617                                    const CFileTransferCommand::t_transferSettings& transferSettings,
     1618                                    const wxString& localFileAlias
     1619)
    16181620{
    16191621    LogMessage(Debug_Verbose, _T("CSftpControlSocket::FileTransfer(...)"));
    16201622
     
    16341636    }
    16351637    else
    16361638    {
    1637         LogMessage(Status, _("Starting upload of %s"), localFile.c_str());
     1639        LogMessage(
     1640            Status, _("Starting upload of %s"),
     1641            (localFileAlias.empty() ? localFile : localFileAlias).c_str()
     1642        );
    16381643    }
    16391644    if (m_pCurOpData)
    16401645    {
     
    16431648    }
    16441649
    16451650    CSftpFileTransferOpData *pData = new CSftpFileTransferOpData(download, localFile, remoteFile, remotePath);
     1651    pData->localFileAlias = localFileAlias;
    16461652    m_pCurOpData = pData;
    16471653
    16481654    pData->transferSettings = transferSettings;
     
    18501856            wxString localFile = QuoteFilename(pData->localFile) + _T(" ");
    18511857            wxString remoteFile = QuoteFilename(pData->remotePath.FormatFilename(pData->remoteFile, !pData->tryAbsolutePath));
    18521858
    1853             logstr += localFile;
    1854             logstr += remoteFile;
     1859            logstr += (pData->localFileAlias.empty() ? pData->localFile : pData->localFileAlias);
     1860            logstr += _T(" ") + remoteFile;
    18551861            LogMessageRaw(Command, logstr);
    18561862
    18571863            if (!AddToStream(cmd) || !AddToStream(localFile, true) ||
  • src/engine/sftpcontrolsocket.h

    diff -r c04cba15ffba -r 92b83b739411 src/engine/sftpcontrolsocket.h
    a b  
    8181
    8282    virtual int FileTransfer(const wxString localFile, const CServerPath &remotePath,
    8383                             const wxString &remoteFile, bool download,
    84                              const CFileTransferCommand::t_transferSettings& transferSettings);
     84                             const CFileTransferCommand::t_transferSettings& transferSettings,
     85                             const wxString& localFileAlias);
    8586    int FileTransferSubcommandResult(int prevResult);
    8687    int FileTransferSend();
    8788    int FileTransferParseResponse(bool successful, const wxString& reply);
  • src/include/commands.h

    diff -r c04cba15ffba -r 92b83b739411 src/include/commands.h
    a b  
    133133    // For downloads, localFile can be left empty if supported by protocol.
    134134    // Check for nId_data notification.
    135135    // FIXME: localFile empty iff protocol is HTTP.
    136     CFileTransferCommand(const wxString &localFile, const CServerPath& remotePath, const wxString &remoteFile, bool download, const t_transferSettings& m_transferSettings);
     136    CFileTransferCommand(
     137        const wxString &localFile, const CServerPath& remotePath, const wxString &remoteFile,
     138        bool download, const t_transferSettings& m_transferSettings, const wxString& localFileAlias
     139    );
    137140
    138141    wxString GetLocalFile() const;
     142    wxString GetLocalFileAlias() const;
    139143    CServerPath GetRemotePath() const;
    140144    wxString GetRemoteFile() const;
    141145    bool Download() const;
    142146    const t_transferSettings& GetTransferSettings() const { return m_transferSettings; }
    143147
    144148protected:
     149    wxString m_localFileAlias;
    145150    wxString m_localFile;
    146151    CServerPath m_remotePath;
    147152    wxString m_remoteFile;
  • src/include/notification.h

    diff -r c04cba15ffba -r 92b83b739411 src/include/notification.h
    a b  
    136136
    137137    bool download;
    138138
     139    wxString localFileAlias;
    139140    wxString localFile;
    140141    wxLongLong localSize;
    141142    wxDateTime localTime;
  • src/interface/QueueView.cpp

    diff -r c04cba15ffba -r 92b83b739411 src/interface/QueueView.cpp
    a b  
    529529bool CQueueView::QueueFile(const bool queueOnly, const bool download,
    530530                           const wxString& sourceFile, const wxString& targetFile,
    531531                           const CLocalPath& localPath, const CServerPath& remotePath,
    532                            const CServer& server, const wxLongLong size, enum CEditHandler::fileType edit /*=CEditHandler::none*/)
     532                           const CServer& server, const wxLongLong size,
     533                             enum CEditHandler::fileType edit /*=CEditHandler::none*/,
     534                             const wxString& sourceFileAlias
     535)
    533536{
    534537    CServerItem* pServerItem = CreateServerItem(server);
    535538
     
    549552    else
    550553    {
    551554        fileItem = new CFileItem(pServerItem, queueOnly, download, sourceFile, targetFile, localPath, remotePath, size);
     555        fileItem->SetSourceAlias(sourceFileAlias);
    552556        if (download)
    553557            fileItem->m_transferSettings.binary = !CAutoAsciiFiles::TransferRemoteAsAscii(sourceFile, remotePath.GetType());
    554558        else
     
    14921496            RefreshItem(engineData.pItem);
    14931497
    14941498            int res = engineData.pEngine->Command(CFileTransferCommand(fileItem->GetLocalPath().GetPath() + fileItem->GetLocalFile(), fileItem->GetRemotePath(),
    1495                                                 fileItem->GetRemoteFile(), fileItem->Download(), fileItem->m_transferSettings));
     1499                fileItem->GetRemoteFile(), fileItem->Download(), fileItem->m_transferSettings, fileItem->GetSourceAlias()));
    14961500            wxASSERT((res & FZ_REPLY_BUSY) != FZ_REPLY_BUSY);
    14971501            if (res == FZ_REPLY_WOULDBLOCK)
    14981502                return;
  • src/interface/QueueView.h

    diff -r c04cba15ffba -r 92b83b739411 src/interface/QueueView.h
    a b  
    9898    bool QueueFile(const bool queueOnly, const bool download,
    9999        const wxString& localFile, const wxString& remoteFile,
    100100        const CLocalPath& localPath, const CServerPath& remotePath,
    101         const CServer& server, const wxLongLong size, enum CEditHandler::fileType edit = CEditHandler::none);
     101        const CServer& server, const wxLongLong size,
     102        enum CEditHandler::fileType edit = CEditHandler::none, const wxString& sourceFileAlias = _T("")
     103    );
    102104
    103105    void QueueFile_Finish(const bool start); // Need to be called after QueueFile
    104106    bool QueueFiles(const bool queueOnly, const CLocalPath& localPath, const CRemoteDataObject& dataObject);
  • src/interface/RemoteListView.cpp

    diff -r c04cba15ffba -r 92b83b739411 src/interface/RemoteListView.cpp
    a b  
    338338    EVT_MENU(XRCID("ID_DOWNLOAD"), CRemoteListView::OnMenuDownload)
    339339    EVT_MENU(XRCID("ID_ADDTOQUEUE"), CRemoteListView::OnMenuDownload)
    340340    EVT_MENU(XRCID("ID_MKDIR"), CRemoteListView::OnMenuMkdir)
     341    EVT_MENU(XRCID("ID_MKFILE"), CRemoteListView::OnMenuMkfile)
    341342    EVT_MENU(XRCID("ID_DELETE"), CRemoteListView::OnMenuDelete)
    342343    EVT_MENU(XRCID("ID_RENAME"), CRemoteListView::OnMenuRename)
    343344    EVT_MENU(XRCID("ID_CHMOD"), CRemoteListView::OnMenuChmod)
     
    14091410        pMenu->Enable(XRCID("ID_DOWNLOAD"), false);
    14101411        pMenu->Enable(XRCID("ID_ADDTOQUEUE"), false);
    14111412        pMenu->Enable(XRCID("ID_MKDIR"), false);
     1413        pMenu->Enable(XRCID("ID_MKFILE"), false);       
    14121414        pMenu->Enable(XRCID("ID_DELETE"), false);
    14131415        pMenu->Enable(XRCID("ID_RENAME"), false);
    14141416        pMenu->Enable(XRCID("ID_CHMOD"), false);
     
    16541656    m_pState->m_pCommandQueue->ProcessCommand(new CMkdirCommand(path));
    16551657}
    16561658
     1659void CRemoteListView::OnMenuMkfile(wxCommandEvent& event) {
     1660    if (!m_pDirectoryListing || !m_pState->IsRemoteIdle())
     1661    {
     1662        wxBell();
     1663        return;
     1664    }
     1665
     1666    CInputDialog dlg;
     1667    if (!dlg.Create(this, _("Create file"), _("Please enter the name of the file which should be created:")))
     1668        return;
     1669
     1670    CServerPath path = m_pDirectoryListing->path;
     1671    wxString newName = _("New file");   
     1672    wxString pathName = path.GetPath() + _T("/");
     1673    int pos = pathName.Length();
     1674    pathName += newName;   
     1675    wxASSERT(pos != -1);
     1676    dlg.SetValue(pathName);
     1677    dlg.SelectText(pos, pos + newName.Length());
     1678
     1679    const CServerPath oldPath = m_pDirectoryListing->path;
     1680
     1681    if (dlg.ShowModal() != wxID_OK)
     1682        return;
     1683   
     1684    if (
     1685        path.GetParent().GetPath().compare(dlg.GetValue()) == 0 ||
     1686        wxString(path.GetParent().GetPath() + _T("/")).compare(dlg.GetValue()) == 0
     1687    ) {
     1688        wxBell();
     1689        return;
     1690    }
     1691   
     1692    if (!m_pDirectoryListing || oldPath != m_pDirectoryListing->path ||
     1693        !m_pState->IsRemoteIdle())
     1694    {
     1695        wxBell();
     1696        return;
     1697    }
     1698
     1699    path = m_pDirectoryListing->path;
     1700    if (!path.ChangePath(dlg.GetValue()))
     1701    {
     1702        wxBell();
     1703        return;
     1704    }
     1705   
     1706    CLocalPath pathLocal(wxGetApp().GetResourceDir());
     1707    wxString filename(_T("dummy"));
     1708    wxString pathDummy(pathLocal.GetPath() + filename);
     1709    if (!wxFile::Exists(pathDummy)) {
     1710        wxFile tempFile;
     1711        if (!tempFile.Create(pathDummy)) {
     1712            wxBell();
     1713            return;
     1714        }
     1715        tempFile.Close();
     1716    }
     1717    m_pQueue->QueueFile(
     1718        false, false,
     1719        filename, path.GetLastSegment(), pathLocal, path.GetParent(),
     1720        *(m_pState->GetServer()), 0, CEditHandler::none, _T("New empty file")
     1721    );
     1722    m_pQueue->QueueFile_Finish(true);
     1723}
     1724
    16571725void CRemoteListView::OnMenuDelete(wxCommandEvent& event)
    16581726{
    16591727    if (!m_pState->IsRemoteIdle())
  • src/interface/RemoteListView.h

    diff -r c04cba15ffba -r 92b83b739411 src/interface/RemoteListView.h
    a b  
    105105    void OnContextMenu(wxContextMenuEvent& event);
    106106    void OnMenuDownload(wxCommandEvent& event);
    107107    void OnMenuMkdir(wxCommandEvent& event);
     108    void OnMenuMkfile(wxCommandEvent& event);
    108109    void OnMenuDelete(wxCommandEvent& event);
    109110    void OnMenuRename(wxCommandEvent& event);
    110111    void OnKeyDown(wxKeyEvent& event);
  • src/interface/fileexistsdlg.cpp

    diff -r c04cba15ffba -r 92b83b739411 src/interface/fileexistsdlg.cpp
    a b  
    4444    m_pAction6 = wxDynamicCast(FindWindow(XRCID("ID_ACTION6")), wxRadioButton);
    4545    m_pAction7 = wxDynamicCast(FindWindow(XRCID("ID_ACTION7")), wxRadioButton);
    4646
    47     wxString localFile = m_pNotification->localFile;
     47    wxString localFile = m_pNotification->localFileAlias.empty() ?
     48        m_pNotification->localFile : m_pNotification->localFileAlias;
    4849
    4950    wxString remoteFile = m_pNotification->remotePath.FormatFilename(m_pNotification->remoteFile);
    5051    localFile = GetPathEllipsis(localFile, FindWindow(XRCID("ID_FILE1_NAME")));
  • src/interface/queue.cpp

    diff -r c04cba15ffba -r 92b83b739411 src/interface/queue.cpp
    a b  
    885885            switch (column)
    886886            {
    887887            case colLocalName:
    888                 return pFileItem->GetIndent() + pFileItem->GetLocalPath().GetPath() + pFileItem->GetLocalFile();
     888                return pFileItem->GetIndent() +
     889                    (
     890                        pFileItem->GetSourceAlias().empty() ?
     891                            pFileItem->GetLocalPath().GetPath() + pFileItem->GetLocalFile() :
     892                            pFileItem->GetSourceAlias()
     893                    );
    889894            case colDirection:
    890895                if (pFileItem->Download())
    891896                    if (pFileItem->queued())
  • src/interface/queue.h

    diff -r c04cba15ffba -r 92b83b739411 src/interface/queue.h
    a b  
    162162    const CServerPath& GetRemotePath() const { return m_remotePath; }
    163163    const wxLongLong& GetSize() const { return m_size; }
    164164    void SetSize(wxLongLong size) { m_size = size; }
     165   
     166    const wxString& GetSourceAlias() const { return m_sourceAlias; }
     167    void SetSourceAlias(wxString alias) {
     168        m_sourceAlias = alias.empty() ? alias : _T("[") + alias + _T("]");
     169    }
     170   
    165171    inline bool Download() const { return flags & flag_download; }
    166172   
    167173    inline bool queued() const { return (flags & flag_queued) != 0; }
     
    234240    const CLocalPath m_localPath;
    235241    const CServerPath m_remotePath;
    236242    wxLongLong m_size;
     243    wxString m_sourceAlias;
    237244};
    238245
    239246class CFolderItem : public CFileItem
  • src/interface/resources/menus.xrc

    diff -r c04cba15ffba -r 92b83b739411 src/interface/resources/menus.xrc
    a b  
    299299      <label>&amp;Create directory</label>
    300300      <help>Create a new subdirectory in the current directory</help>
    301301    </object>
     302    <object class="wxMenuItem" name="ID_MKFILE">
     303      <label>&amp;Create empty file</label>
     304      <help>Create a empty file in the current directory</help>
     305    </object>
    302306    <object class="wxMenuItem" name="ID_CONTEXT_REFRESH">
    303307      <label>Re&amp;fresh</label>
    304308    </object>
  • src/interface/updatewizard.cpp

    diff -r c04cba15ffba -r 92b83b739411 src/interface/updatewizard.cpp
    a b  
    11391139    wxString file = m_urlFile;
    11401140    path.SetPath(file, true);
    11411141
    1142     CFileTransferCommand cmd(m_localFile, path, file, true, transferSettings);
     1142    CFileTransferCommand cmd(m_localFile, path, file, true, transferSettings, _T(""));
    11431143    return m_pEngine->Command(cmd);
    11441144}
    11451145