#pragma once

#include "ikvm_args.hpp"
#include "ikvm_input.hpp"
#include "ikvm_video.hpp"

#include <rfb/rfb.h>

#include <vector>

namespace ikvm
{
/*
 * @class Server
 * @brief Manages the RFB server connection and updates
 */
class Server
{
  public:
    /*
     * @struct ClientData
     * @brief Store necessary data for each connected RFB client
     */
    struct ClientData
    {
        /*
         * @brief Constructs ClientData object
         *
         * @param[in] s - Number of frames to skip when client connects
         * @param[in] i - Pointer to Input object
         */
        ClientData(int s, Input* i) : skipFrame(s), input(i), last_crc{-1}
        {
            needUpdate = false;
        }
        ~ClientData() = default;
        ClientData(const ClientData&) = default;
        ClientData& operator=(const ClientData&) = default;
        ClientData(ClientData&&) = default;
        ClientData& operator=(ClientData&&) = default;

        int skipFrame;
        Input* input;
        bool needUpdate;
        int64_t last_crc;
    };

    /*
     * @brief Constructs Server object
     *
     * @param[in] args - Reference to Args object
     * @param[in] i    - Reference to Input object
     * @param[in] v    - Reference to Video object
     */
    Server(const Args& args, Input& i, Video& v);
    ~Server();
    Server(const Server&) = default;
    Server& operator=(const Server&) = default;
    Server(Server&&) = default;
    Server& operator=(Server&&) = default;

    /* @brief Resizes the RFB framebuffer */
    void resize();
    /* @brief Executes any pending RFB updates and client input */
    void run();
    /* @brief Sends pending video frame to clients */
    void sendFrame();

    /*
     * @brief Indicates whether or not video data is desired
     *
     * @return Boolean to indicate whether any clients need a video frame
     */
    inline bool wantsFrame() const
    {
        return server->clientHead;
    }
    /*
     * @brief Get the Video object
     *
     * @return Reference to the Video object
     */
    inline const Video& getVideo() const
    {
        return video;
    }

  private:
    /*
     * @brief Handler for a client frame update message
     *
     * @param[in] cl - Handle to the client object
     * @param[in] furMsg - Pointer of the FUR message
     */
    static void clientFramebufferUpdateRequest(
        rfbClientPtr cl, rfbFramebufferUpdateRequestMsg* furMsg);
    /*
     * @brief Handler for a client disconnecting
     *
     * @param[in] cl - Handle to the client object
     */
    static void clientGone(rfbClientPtr cl);
    /*
     * @brief Handler for client connecting
     *
     * @param[in] cl - Handle to the client object
     */
    static enum rfbNewClientAction newClient(rfbClientPtr cl);

    /* @brief Performs the resize operation on the framebuffer */
    void doResize();

    /* @brief Boolean to indicate if a resize operation is on-going */
    bool pendingResize;
    /* @brief Number of frames handled since a client connected */
    int frameCounter;
    /* @brief Number of connected clients */
    unsigned int numClients;
    /* @brief Microseconds to process RFB events every frame */
    long int processTime;
    /* @brief Handle to the RFB server object */
    rfbScreenInfoPtr server;
    /* @brief Reference to the Input object */
    Input& input;
    /* @brief Reference to the Video object */
    Video& video;
    /* @brief Default framebuffer storage */
    std::vector<char> framebuffer;
    /* @brief Identical frames detection */
    bool calcFrameCRC;
    /* @brief Cursor bitmap width */
    static constexpr int cursorWidth = 20;
    /* @brief Cursor bitmap height */
    static constexpr int cursorHeight = 20;
    /* @brief Cursor bitmap */
    static constexpr char cursor[] =
        "                    "
        " x                  "
        " xx                 "
        " xxx                "
        " xxxx               "
        " xxxxx              "
        " xxxxxx             "
        " xxxxxxx            "
        " xxxxxxxx           "
        " xxxxxxxxx          "
        " xxxxxxxxxx         "
        " xxxxxxxxxxx        "
        " xxxxxxx            "
        " xxxxxxx            "
        " xxx  xxx           "
        " xx   xxx           "
        " x     xxx          "
        "       xxx          "
        "        x           "
        "                    ";
    /* @brief Cursor bitmap mask */
    static constexpr char cursorMask[] =
        " o                  "
        "oxo                 "
        "oxxo                "
        "oxxxo               "
        "oxxxxo              "
        "oxxxxxo             "
        "oxxxxxxo            "
        "oxxxxxxxo           "
        "oxxxxxxxxo          "
        "oxxxxxxxxxo         "
        "oxxxxxxxxxxo        "
        "oxxxxxxxxxxxo       "
        "oxxxxxxxoooo        "
        "oxxxxxxxo           "
        "oxxxooxxxo          "
        "oxxo oxxxo          "
        "oxo   oxxxo         "
        " o    oxxxo         "
        "       oxo          "
        "        o           ";
};

} // namespace ikvm
