#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
