* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
* USA.
*/
+#include <assert.h>
#include <stdio.h>
#include <string.h>
CMsgHandler::setExtendedDesktopSize(reason, result, w, h, layout);
}
-void CConnection::serverInit()
+void CConnection::serverInit(int width, int height,
+ const PixelFormat& pf,
+ const char* name)
{
+ CMsgHandler::serverInit(width, height, pf, name);
+
state_ = RFBSTATE_NORMAL;
vlog.debug("initialisation done");
initDone();
+ assert(framebuffer != NULL);
+ assert(framebuffer->width() == server.width());
+ assert(framebuffer->height() == server.height());
}
void CConnection::readAndDecodeRect(const Rect& r, int encoding,
int w, int h,
const ScreenSet& layout);
- virtual void serverInit();
+ virtual void serverInit(int width, int height,
+ const PixelFormat& pf,
+ const char* name);
virtual void readAndDecodeRect(const Rect& r, int encoding,
ModifiablePixelBuffer* pb);
// initDone() is called when the connection is fully established
// and standard messages can be sent. This is called before the
// initial FramebufferUpdateRequest giving a derived class the
- // chance to modify pixel format and settings.
- virtual void initDone();
+ // chance to modify pixel format and settings. The derived class
+ // must also make sure it has provided a valid framebuffer before
+ // returning.
+ virtual void initDone() = 0;
// Other methods
server.supportsQEMUKeyEvent = true;
}
+void CMsgHandler::serverInit(int width, int height,
+ const PixelFormat& pf,
+ const char* name)
+{
+ server.setDimensions(width, height);
+ server.setPF(pf);
+ server.setName(name);
+}
+
void CMsgHandler::framebufferUpdateStart()
{
}
// The following methods are called as corresponding messages are read. A
// derived class should override these methods as desired. Note that for
- // the setDesktopSize(), setExtendedDesktopSize(), setPixelFormat() and
- // setName() methods, a derived class should call on to CMsgHandler's
- // methods to set the members of "server" appropriately.
+ // the setDesktopSize(), setExtendedDesktopSize(), setPixelFormat(),
+ // setName() and serverInit() methods, a derived class should call on to
+ // CMsgHandler's methods to set the members of "server" appropriately.
virtual void setDesktopSize(int w, int h);
virtual void setExtendedDesktopSize(unsigned reason, unsigned result,
virtual void fence(rdr::U32 flags, unsigned len, const char data[]);
virtual void endOfContinuousUpdates();
virtual void supportsQEMUKeyEvent();
- virtual void serverInit() = 0;
+ virtual void serverInit(int width, int height,
+ const PixelFormat& pf,
+ const char* name) = 0;
virtual void readAndDecodeRect(const Rect& r, int encoding,
ModifiablePixelBuffer* pb) = 0;
{
int width = is->readU16();
int height = is->readU16();
- handler->setDesktopSize(width, height);
PixelFormat pf;
pf.read(is);
- handler->setPixelFormat(pf);
CharArray name(is->readString());
- handler->setName(name.buf);
- handler->serverInit();
+ handler->serverInit(width, height, pf, name.buf);
}
void CMsgReader::readMsg()
CConn(const char *filename);
~CConn();
- virtual void setDesktopSize(int w, int h);
+ virtual void initDone();
virtual void setPixelFormat(const rfb::PixelFormat& pf);
virtual void setCursor(int, int, const rfb::Point&, const rdr::U8*);
virtual void framebufferUpdateStart();
delete in;
}
-void CConn::setDesktopSize(int w, int h)
+void CConn::initDone()
{
- CConnection::setDesktopSize(w, h);
-
setFramebuffer(new rfb::ManagedPixelBuffer(filePF,
server.width(),
server.height()));
void getStats(double& ratio, unsigned long long& bytes,
unsigned long long& rawEquivalent);
- virtual void setDesktopSize(int w, int h);
+ virtual void initDone();
virtual void setCursor(int, int, const rfb::Point&, const rdr::U8*);
virtual void framebufferUpdateStart();
virtual void framebufferUpdateEnd();
sc->getStats(ratio, bytes, rawEquivalent);
}
-void CConn::setDesktopSize(int w, int h)
+void CConn::initDone()
{
rfb::ModifiablePixelBuffer *pb;
- CConnection::setDesktopSize(w, h);
-
pb = new rfb::ManagedPixelBuffer((bool)translate ? fbPF : server.pf(),
server.width(), server.height());
setFramebuffer(pb);
void CConn::setName(const char* name)
{
CConnection::setName(name);
- if (desktop)
- desktop->setName(name);
+ desktop->setName(name);
}
// framebufferUpdateStart() is called at the beginning of an update.
void CConn::resizeFramebuffer()
{
- if (!desktop)
- return;
-
if (continuousUpdates)
writer()->writeEnableContinuousUpdates(true, 0, 0,
server.width(),