Ticket #2161: prot_c.diff

File prot_c.diff, 4.1 KB (added by Albert, 7 years ago)

Patch for svn revision 5003. Adds support for PROT C command.

  • src/interface/xmlfunctions.cpp

     
    653653    }
    654654
    655655    server.SetBypassProxy(GetTextElementInt(node, "BypassProxy", false) == 1);
     656    server.SetProtLevel(GetTextElement_Trimmed(node, "ProtLevel"));
    656657    server.SetName(GetTextElement_Trimmed(node, "Name"));
    657658
    658659    if (server.GetName().empty())
     
    738739    }
    739740
    740741    AddTextElementRaw(node, "BypassProxy", server.GetBypassProxy() ? "1" : "0");
     742    AddTextElement(node, "ProtLevel", server.GetProtLevel());
     743
    741744    const wxString& name = server.GetName();
    742745    if (name != _T(""))
    743746        AddTextElement(node, "Name", name);
  • src/include/server.h

     
    8484    enum PasvMode GetPasvMode() const;
    8585    int MaximumMultipleConnections() const;
    8686    bool GetBypassProxy() const;
     87    wxString GetProtLevel() const;
    8788
    8889    // Return true if URL could be parsed correctly, false otherwise.
    8990    // If parsing fails, pError is filled with the reason and the CServer instance may be left an undefined state.
     
    9798    bool SetUser(const wxString& user, const wxString& pass = _T(""));
    9899    bool SetAccount(const wxString& account);
    99100
     101    bool SetProtLevel(const wxString &level);
     102
    100103    CServer& operator=(const CServer &op);
    101104    bool operator==(const CServer &op) const;
    102105    bool operator<(const CServer &op) const;
     
    164167
    165168    std::vector<wxString> m_postLoginCommands;
    166169    bool m_bypassProxy;
     170
     171    wxString m_protLevel;
    167172};
    168173
    169174#endif
  • src/engine/server.cpp

     
    312312    m_postLoginCommands = op.m_postLoginCommands;
    313313    m_bypassProxy = op.m_bypassProxy;
    314314    m_name = op.m_name;
     315    m_protLevel = op.m_protLevel;
    315316
    316317    return *this;
    317318}
     
    361362        return false;
    362363    if (m_bypassProxy != op.m_bypassProxy)
    363364        return false;
     365    if (m_protLevel != op.m_protLevel)
     366        return false;
    364367
    365368    // Do not compare number of allowed multiple connections
    366369
     
    453456    else if (m_bypassProxy > op.m_bypassProxy)
    454457        return false;
    455458
     459    if (m_protLevel < op.m_protLevel)
     460        return true;
     461    else if (m_protLevel > op.m_protLevel)
     462        return false;
     463
    456464    // Do not compare number of allowed multiple connections
    457465
    458466    return false;
     
    500508        return false;
    501509    if (m_bypassProxy != op.m_bypassProxy)
    502510        return false;
     511    if (m_protLevel != op.m_protLevel)
     512        return false;
    503513
    504514    // Do not compare number of allowed multiple connections
    505515
     
    686696    m_encodingType = ENCODING_AUTO;
    687697    m_customEncoding = _T("");
    688698    m_bypassProxy = false;
     699    m_protLevel = _T("P");
    689700}
    690701
    691702bool CServer::SetEncodingType(enum CharsetEncoding type, const wxString& encoding /*=_T("")*/)
     
    823834  return m_bypassProxy;
    824835}
    825836
     837wxString CServer::GetProtLevel() const
     838{
     839    return m_protLevel;
     840}
     841
     842bool CServer::SetProtLevel(const wxString &level)
     843{
     844    if (level != _T("P") && level != _T("C"))
     845      return false;
     846
     847    m_protLevel = level;
     848    return true;
     849}
     850
    826851bool CServer::ProtocolHasDataTypeConcept(const enum ServerProtocol protocol)
    827852{
    828853    if (protocol == FTP || protocol == FTPS || protocol == FTPES)
     
    881906        return _("Anonymous");
    882907    }
    883908}
     909
     910
  • src/engine/ftpcontrolsocket.cpp

     
    925925    else if (pData->opState == LOGON_PROT)
    926926    {
    927927        if (code == 2 || code == 3)
    928             m_protectDataChannel = true;
     928            m_protectDataChannel = m_pCurrentServer->GetProtLevel() != _T("C");
    929929    }
    930930    else if (pData->opState == LOGON_CUSTOMCOMMANDS)
    931931    {
     
    11911191        res = Send(_T("PBSZ 0"));
    11921192        break;
    11931193    case LOGON_PROT:
    1194         res = Send(_T("PROT P"));
     1194        res = Send(_T("PROT ") + m_pCurrentServer->GetProtLevel());
    11951195        break;
    11961196    case LOGON_CUSTOMCOMMANDS:
    11971197        if (pData->customCommandIndex >= m_pCurrentServer->GetPostLoginCommands().size())