blob: 929e5b55e2863c80c413c3c363042cb68655991e [file] [log] [blame]
Constantin Kaplinskyb30ae7f2006-05-25 05:04:46 +00001/* Copyright (C) 2002-2005 RealVNC Ltd. All Rights Reserved.
Pierre Ossman49f88222009-03-20 13:02:50 +00002 * Copyright 2009 Pierre Ossman for Cendio AB
Constantin Kaplinskyb30ae7f2006-05-25 05:04:46 +00003 *
4 * This is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 2 of the License, or
7 * (at your option) any later version.
8 *
9 * This software is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this software; if not, write to the Free Software
16 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
17 * USA.
18 */
19//
20// CConn represents a client connection to a VNC server.
21//
22
23#ifndef __CCONN_H__
24#define __CCONN_H__
25
26#include <rfb/CConnection.h>
27#include <rfb/Exception.h>
28#include <rfb/UserPasswdGetter.h>
Adam Tkac27b2f772010-11-18 13:33:57 +000029#include <rfb/UserMsgBox.h>
Constantin Kaplinskyb30ae7f2006-05-25 05:04:46 +000030#include <rdr/FdInStream.h>
31#include <list>
32
33#include "TXWindow.h"
34#include "AboutDialog.h"
35#include "InfoDialog.h"
36#include "TXMenu.h"
37#include "OptionsDialog.h"
38
39class TXWindow;
40class TXViewport;
41class DesktopWindow;
42namespace network { class Socket; }
43
44class CConn : public rfb::CConnection, public rfb::UserPasswdGetter,
45 public TXDeleteWindowCallback,
46 public rdr::FdInStreamBlockCallback,
47 public TXMenuCallback , public OptionsDialogCallback,
Adam Tkac27b2f772010-11-18 13:33:57 +000048 public TXEventHandler, public rfb::UserMsgBox
Constantin Kaplinskyb30ae7f2006-05-25 05:04:46 +000049{
50public:
51
52 CConn(Display* dpy_, int argc_, char** argv_, network::Socket* sock_,
53 char* vncServerName, bool reverse=false);
54 ~CConn();
55
56 // TXDeleteWindowCallback methods
57 void deleteWindow(TXWindow* w);
58
59 // FdInStreamBlockCallback methods
60 void blockCallback();
61
62 // UserPasswdGetter methods
63 virtual void getUserPasswd(char** user, char** password);
64
Adam Tkac27b2f772010-11-18 13:33:57 +000065 // UserMsgBox methods
66 virtual bool showMsgBox(int flags, const char* title, const char* text);
67
Constantin Kaplinskyb30ae7f2006-05-25 05:04:46 +000068 // TXMenuCallback methods
69 void menuSelect(long id, TXMenu* m);
70
71 // OptionsDialogCallback methods
72 virtual void setOptions();
73 virtual void getOptions();
74
75 // TXEventHandler callback method
76 virtual void handleEvent(TXWindow* w, XEvent* ev);
77
78 // CConnection callback methods
Constantin Kaplinskyb30ae7f2006-05-25 05:04:46 +000079 void serverInit();
80 void setDesktopSize(int w, int h);
Pierre Ossmancbd1b2c2009-03-20 16:05:04 +000081 void setExtendedDesktopSize(int reason, int result, int w, int h,
82 const rfb::ScreenSet& layout);
Peter Åstrandc39e0782009-01-15 12:21:42 +000083 void setName(const char* name);
Constantin Kaplinskyb30ae7f2006-05-25 05:04:46 +000084 void setColourMapEntries(int firstColour, int nColours, rdr::U16* rgbs);
85 void bell();
Adam Tkac141c1722009-06-16 10:43:59 +000086 void serverCutText(const char* str, rdr::U32 len);
Pierre Ossman42d20e72009-04-01 14:42:34 +000087 void framebufferUpdateStart();
Constantin Kaplinskyb30ae7f2006-05-25 05:04:46 +000088 void framebufferUpdateEnd();
Peter Åstrand98fe98c2010-02-10 07:43:02 +000089 void beginRect(const rfb::Rect& r, int encoding);
90 void endRect(const rfb::Rect& r, int encoding);
Constantin Kaplinskyb30ae7f2006-05-25 05:04:46 +000091 void fillRect(const rfb::Rect& r, rfb::Pixel p);
92 void imageRect(const rfb::Rect& r, void* p);
93 void copyRect(const rfb::Rect& r, int sx, int sy);
94 void setCursor(int width, int height, const rfb::Point& hotspot,
95 void* data, void* mask);
96
97private:
98
Pierre Ossman49f88222009-03-20 13:02:50 +000099 void resizeFramebuffer();
Constantin Kaplinskyb30ae7f2006-05-25 05:04:46 +0000100 void recreateViewport();
101 void reconfigureViewport();
102 void initMenu();
103 void showMenu(int x, int y);
104 void autoSelectFormatAndEncoding();
105 void checkEncodings();
106 void requestNewUpdate();
107
108 Display* dpy;
109 int argc;
110 char** argv;
111 char* serverHost;
112 int serverPort;
113 network::Socket* sock;
114 rfb::PixelFormat serverPF;
115 TXViewport* viewport;
116 DesktopWindow* desktop;
117 TXEventHandler* desktopEventHandler;
118 rfb::PixelFormat fullColourPF;
119 std::list<rfb::Rect> debugRects;
Peter Åstrand98fe98c2010-02-10 07:43:02 +0000120 int currentEncoding, lastServerEncoding;
Constantin Kaplinskyb30ae7f2006-05-25 05:04:46 +0000121 bool fullColour;
122 bool autoSelect;
123 bool shared;
124 bool formatChange;
125 bool encodingChange;
126 bool sameMachine;
127 bool fullScreen;
128 bool ctrlDown;
129 bool altDown;
130 KeySym menuKeysym;
131 TXMenu menu;
132 TXEventHandler* menuEventHandler;
133 OptionsDialog options;
134 AboutDialog about;
135 InfoDialog info;
136 bool reverseConnection;
Pierre Ossmaneb3cecb2009-03-23 16:49:47 +0000137 bool firstUpdate;
Adam Tkac12c0fc32010-03-04 15:33:11 +0000138 bool pendingUpdate;
Constantin Kaplinskyb30ae7f2006-05-25 05:04:46 +0000139};
140
141#endif