Skip to content
Snippets Groups Projects
Select Git revision
  • 5aa17595d30c22ff781290c030ad7158ae9ae4e2
  • master default protected
  • release/202005
  • release/202001
  • release/201912
  • release/201911
  • release/releaseWindowsTestOne
  • release/windowsReleaseTest
  • release/releaseTest
  • release/releaseWindowsTest
  • release/201910
  • release/qt/201910
  • release/windows-test/201910
  • release/201908
  • release/201906
  • release/201905
  • release/201904
  • release/201903
  • release/201902
  • release/201901
  • release/201812
  • 4.0.0
  • 2.2.0
  • 2.1.0
  • 2.0.1
  • 2.0.0
  • 1.4.1
  • 1.4.0
  • 1.3.0
  • 1.2.0
  • 1.1.0
31 results

ftp_server.h

Blame
  • Sébastien Blin's avatar
    Sébastien Blin authored
    Currently, when an incoming request is cancelled the transfer id
    is lost. This patch avoid this case and allow the cancel part in
    p2p.cpp to clear the data related to this transfer.
    
    Change-Id: Ia5b69b514fce19e80ee3344d40eb395470212ef3
    540a3025
    History
    Code owners
    Assign users and groups as approvers for specific file changes. Learn more.
    ftp_server.h 2.00 KiB
    /*
     *  Copyright (C) 2017-2019 Savoir-faire Linux Inc.
     *
     *  Author: Guillaume Roguez <guillaume.roguez@savoirfairelinux.com>
     *
     *  This program is free software; you can redistribute it and/or modify
     *  it under the terms of the GNU General Public License as published by
     *  the Free Software Foundation; either version 3 of the License, or
     *  (at your option) any later version.
     *
     *  This program is distributed in the hope that it will be useful,
     *  but WITHOUT ANY WARRANTY; without even the implied warranty of
     *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
     *  GNU General Public License for more details.
     *
     *  You should have received a copy of the GNU General Public License
     *  along with this program; if not, write to the Free Software
     *  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301 USA.
     */
    
    #pragma once
    
    #include "data_transfer.h"
    #include "peer_connection.h"
    
    #include <vector>
    #include <array>
    #include <sstream>
    #include <memory>
    
    namespace jami {
    
    class FtpServer final : public Stream
    {
    public:
        FtpServer(const std::string& account_id, const std::string& peer_uri);
    
        bool read(std::vector<uint8_t>& buffer) const override;
        bool write(const std::vector<uint8_t>& buffer) override;
        DRing::DataTransferId getId() const override;
        void close() noexcept override;
    
    private:
        bool parseStream(const std::vector<uint8_t>&);
        bool parseLine(const std::string&);
        void handleHeader(const std::string&, const std::string&);
        bool startNewFile();
        void closeCurrentFile();
    
        enum class FtpState {
            PARSE_HEADERS,
            READ_DATA,
        };
    
        const std::string accountId_;
        const std::string peerUri_;
        IncomingFileInfo out_ {0, nullptr};
        std::size_t fileSize_ {0};
        std::size_t rx_ {0};
        std::stringstream headerStream_;
        std::string displayName_;
        std::array<char, 1000> line_;
        mutable bool closed_ {false};
        mutable bool go_ {false};
        FtpState state_ {FtpState::PARSE_HEADERS};
    };
    
    } // namespace jami