#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
