maemo: disable updates when screen is off
[presencevnc] / src / vncview.h
1 /****************************************************************************
2 **
3 ** Copyright (C) 2007-2008 Urs Wolfer <uwolfer @ kde.org>
4 **
5 ** This file is part of KDE.
6 **
7 ** This program is free software; you can redistribute it and/or modify
8 ** it under the terms of the GNU General Public License as published by
9 ** the Free Software Foundation; either version 2 of the License, or
10 ** (at your option) any later version.
11 **
12 ** This program is distributed in the hope that it will be useful,
13 ** but WITHOUT ANY WARRANTY; without even the implied warranty of
14 ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 ** GNU General Public License for more details.
16 **
17 ** You should have received a copy of the GNU General Public License
18 ** along with this program; see the file COPYING. If not, write to
19 ** the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
20 ** Boston, MA 02110-1301, USA.
21 **
22 ****************************************************************************/
23
24 #ifndef VNCVIEW_H
25 #define VNCVIEW_H
26
27 #include "remoteview.h"
28 #include "vncclientthread.h"
29
30 class KConfigGroup{};
31
32 #include <QClipboard>
33 #include <QTextEdit>
34
35 extern "C" {
36 #include <rfb/rfbclient.h>
37 }
38
39 class VncView: public RemoteView
40 {
41     Q_OBJECT
42
43 public:
44     explicit VncView(QWidget *parent = 0, const KUrl &url = KUrl(), RemoteView::Quality quality = RemoteView::Medium, int listen_port = 0);
45     ~VncView();
46
47     QSize framebufferSize();
48     QSize sizeHint() const;
49     QSize minimumSizeHint() const;
50     bool isQuitting();
51     qreal zoomFactor() { return m_horizontalFactor;} //assumes fixed aspect ratio
52     void reloadSettings();
53     bool start();
54     bool supportsScaling() const;
55     bool supportsLocalCursor() const;
56     
57     void setQuality(int q);
58     void setViewOnly(bool viewOnly);
59     void showDotCursor(DotCursorState state);
60     void useFastTransformations(bool enabled);
61     QPoint cursorPosition() { return QPoint(cursor_x, cursor_y); }
62                 void setDisplayOff(bool off) { display_off = off; }
63     
64 public slots:
65     void setZoomLevel(int level = -1); //'level' doesn't correspond to actual magnification, though mapping is done here
66     void sendKey(Qt::Key key);
67     void sendKeySequence(QKeySequence keys);
68     void startQuitting();
69
70 protected:
71     void paintEvent(QPaintEvent *event);
72     bool event(QEvent *event);
73     void resizeEvent(QResizeEvent *event);
74     bool eventFilter(QObject *obj, QEvent *event);
75     void inputMethodEvent(QInputMethodEvent *event);
76
77 private:
78     VncClientThread vncThread;
79     QClipboard *m_clipboard;
80     bool m_initDone;
81     int m_buttonMask;
82     QMap<unsigned int, bool> m_mods;
83     int m_x, m_y, m_w, m_h;
84     int cursor_x, cursor_y;
85     bool m_quitFlag;
86     bool m_firstPasswordTry;
87     bool m_dontSendClipboard;
88     qreal m_horizontalFactor;
89     qreal m_verticalFactor;
90     QImage m_frame;
91     bool m_forceLocalCursor;
92     int left_zoom, right_zoom;
93     bool disable_tapping;
94     RemoteView::Quality quality;
95     int listen_port;
96     Qt::TransformationMode transformation_mode;
97                 bool display_off;
98
99     void keyEventHandler(QKeyEvent *e);
100     void unpressModifiers();
101     void wheelEventHandler(QWheelEvent *event);
102     
103 private slots:
104     void mouseEventHandler(QMouseEvent *event = 0);
105
106     void updateImage(int x, int y, int w, int h);
107     void setCut(const QString &text);
108     void requestPassword();
109     void outputErrorMessage(const QString &message);
110     void clipboardSelectionChanged();
111     void clipboardDataChanged();
112 };
113
114 #endif