/*
 *
 *    Copyright (c) 2023 Project CHIP Authors
 *    All rights reserved.
 *
 *    Licensed under the Apache License, Version 2.0 (the "License");
 *    you may not use this file except in compliance with the License.
 *    You may obtain a copy of the License at
 *
 *        http://www.apache.org/licenses/LICENSE-2.0
 *
 *    Unless required by applicable law or agreed to in writing, software
 *    distributed under the License is distributed on an "AS IS" BASIS,
 *    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 *    See the License for the specific language governing permissions and
 *    limitations under the License.
 */

#pragma once

#include "BdxTransferServerDelegate.h"

#include <messaging/ExchangeMgr.h>
#include <protocols/bdx/BdxTransferProxyDiagnosticLog.h>
#include <protocols/bdx/TransferFacilitator.h>
#include <system/SystemLayer.h>

namespace chip {
namespace bdx {

class BDXTransferServer : public Responder
{
public:
    BDXTransferServer(){};

    ~BDXTransferServer() { Shutdown(); };

    CHIP_ERROR ListenForSendInit(System::Layer * systemLayer, Messaging::ExchangeManager * exchangeMgr);

    void Shutdown();

    void SetDelegate(BDXTransferServerDelegate * delegate) { mDelegate = delegate; }

    /**
     * This method handles BDX messages and other TransferSession events.
     *
     * @param[in] event An OutputEvent that contains output from the TransferSession object.
     */
    void HandleTransferSessionOutput(TransferSession::OutputEvent & event) override;

    void OnExchangeClosing(Messaging::ExchangeContext * ec) override;

protected:
    /**
     * Called when a BDX message is received over the exchange context
     *
     * @param[in] ec The exchange context
     *
     * @param[in] payloadHeader The payload header of the message
     *
     * @param[in] payload The payload of the message
     */
    CHIP_ERROR OnMessageReceived(Messaging::ExchangeContext * ec, const PayloadHeader & payloadHeader,
                                 System::PacketBufferHandle && payload) override;

private:
    /**
     * Called to send a BDX MsgToSend message over the exchange
     *
     *
     * @param[in] event The output event to be send
     */
    CHIP_ERROR OnMessageToSend(TransferSession::OutputEvent & event);

    /**
     * Called to begin the transfer session when an init message has been received
     *
     * @param[in] event The output event received
     */
    CHIP_ERROR OnTransferSessionBegin(TransferSession::OutputEvent & event);

    /**
     * Called to end the transfer session when a BlockAckEOF message has been sent over the exchange
     * or an error has occurred during the BDX session
     *
     * @param[in] error The error type
     */
    CHIP_ERROR OnTransferSessionEnd(CHIP_ERROR error);

    /**
     * Called when a block has been received from the Sender. The block is processed
     * and written to a file and a block ack is sent back to the sender.
     *
     * @param[in] event The output event received
     */
    CHIP_ERROR OnBlockReceived(TransferSession::OutputEvent & event);

    /**
     * This method is called to reset state. It resets the transfer and cleans up the
     * exchange and the fabric index and peer node id.
     */
    void Reset();

    void AbortTransferOnFailure(CHIP_ERROR error);

    System::Layer * mSystemLayer;
    Messaging::ExchangeManager * mExchangeMgr;
    BDXTransferServerDelegate * mDelegate;

    BDXTransferProxyDiagnosticLog mTransferProxy;
    bool mIsExchangeClosing = false;
};

} // namespace bdx
} // namespace chip
