// Copyright (C) 2013 Wolfgang Beer. All Rights Reserved. // email wolfgang@smartlab.at // This file is part of the Mobile VNC server software. // // vncserverlib.h represents the public API for accessing the functionality of // the vnc server library. // // #ifndef VNCSERVERLIB_H #define VNCSERVERLIB_H #include #define SECURITY_TYPE_NONE 1 #define SECURITY_TYPE_PWD 2 #define RAW_ENCODING 0 #define HEXTILE_ENCODING 5 struct VNC_SERVER_CONFIG { int confirm; // server user has to manually confirm an incoming connection int port; // server port offset, portnumber is: 5900 + port int encoding; // image encoding int security; // security setting char pwd[256]; // password for connecting clients int ufreq; // update frequency in milliseconds char sname[256]; // device or server name to display char webroot[256]; // webroot path for the noVNC HTML5 client int websockets; // websocket enabled or disabled }; /** * Interface to implement in order to register for getting notified for * changes within the list of connected clients. */ class ClientChangeListener { public: virtual void ClientAdded() = 0; virtual void ClientRemoved(SOCKET s) = 0; virtual void LastClientLeft() = 0; }; /** * Initializes the vnc server with a given vnc configuration. * The initial call of initialize is necessary for all following functions. * * @param cf the vnc specific configuration * @param hWnd a parent window handle that is necessary for screen capturing * @return returns true if vnc server initialization was successfull, false otherwise */ bool initialize(VNC_SERVER_CONFIG cf, HWND hWnd); /** * Shutdown closes the vnc server operation and frees the memory. * * @return returns true if vnc server was running and shutdown was successfull, false otherwise */ bool shutdown(); /** * Register a listener for receiving notifications on changes within the list of connected * clients. It is only possible to register one listener at a time, so subsequent calls will * overwrite the previous listener. * * @param l the listener */ void registerClientChangeListener(ClientChangeListener* l); /** * Informs on whether the vnc server is running. * * @return returns true if vnc server is running, false otherwise */ bool isRunning(); /** * Returns the number of connected vnc clients. * * @return returns the number of connected clients, returns -1 if any error occurs */ int countClients(); /** * Shuts down and frees all connected vnc clients. * * @return returns true if the shutdown of all clients was successfull, false otherwise */ bool shutdownAllClients(); /** * connect to a vnc viewer in listening mode, or to a listening vnc repeater server. * @param adr the IP or domain address of the listening client or repeater * @param port the port number of the listening client or repeater * @param repeaterId the server id for the repeater, or 0 if client is no repeater! * @return returns true if the connection to the listening client was successfull, false otherwise */ bool connectToViewer(char* adr, int port, int repeaterId); #endif