• Skip to content
  • Skip to link menu
KDE API Reference
  • KDE API Reference
  • kdenetwork API Reference
  • KDE Home
  • Contact Us
 

krdc

  • sources
  • kde-4.12
  • kdenetwork
  • krdc
  • core
remoteview.cpp
Go to the documentation of this file.
1 /****************************************************************************
2 **
3 ** Copyright (C) 2002-2003 Tim Jansen <tim@tjansen.de>
4 ** Copyright (C) 2007-2008 Urs Wolfer <uwolfer @ kde.org>
5 **
6 ** This file is part of KDE.
7 **
8 ** This program is free software; you can redistribute it and/or modify
9 ** it under the terms of the GNU General Public License as published by
10 ** the Free Software Foundation; either version 2 of the License, or
11 ** (at your option) any later version.
12 **
13 ** This program is distributed in the hope that it will be useful,
14 ** but WITHOUT ANY WARRANTY; without even the implied warranty of
15 ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 ** GNU General Public License for more details.
17 **
18 ** You should have received a copy of the GNU General Public License
19 ** along with this program; see the file COPYING. If not, write to
20 ** the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
21 ** Boston, MA 02110-1301, USA.
22 **
23 ****************************************************************************/
24 
25 #include "remoteview.h"
26 
27 #ifndef QTONLY
28  #include <KDebug>
29  #include <KStandardDirs>
30 #endif
31 
32 #include <QBitmap>
33 
34 RemoteView::RemoteView(QWidget *parent)
35  : QWidget(parent),
36  m_status(Disconnected),
37  m_host(QString()),
38  m_port(0),
39  m_viewOnly(false),
40  m_grabAllKeys(false),
41  m_scale(false),
42  m_keyboardIsGrabbed(false),
43 #ifndef QTONLY
44  m_wallet(0),
45 #endif
46  m_dotCursorState(CursorOff)
47 {
48 }
49 
50 RemoteView::~RemoteView()
51 {
52 #ifndef QTONLY
53  delete m_wallet;
54 #endif
55 }
56 
57 RemoteView::RemoteStatus RemoteView::status()
58 {
59  return m_status;
60 }
61 
62 void RemoteView::setStatus(RemoteView::RemoteStatus s)
63 {
64  if (m_status == s)
65  return;
66 
67  if (((1+ m_status) != s) && (s != Disconnected)) {
68  // follow state transition rules
69 
70  if (s == Disconnecting) {
71  if (m_status == Disconnected)
72  return;
73  } else {
74  Q_ASSERT(((int) s) >= 0);
75  if (m_status > s) {
76  m_status = Disconnected;
77  emit statusChanged(Disconnected);
78  }
79  // smooth state transition
80  RemoteStatus origState = m_status;
81  for (int i = origState; i < s; ++i) {
82  m_status = (RemoteStatus) i;
83  emit statusChanged((RemoteStatus) i);
84  }
85  }
86  }
87  m_status = s;
88  emit statusChanged(m_status);
89 }
90 
91 bool RemoteView::supportsScaling() const
92 {
93  return false;
94 }
95 
96 bool RemoteView::supportsLocalCursor() const
97 {
98  return false;
99 }
100 
101 QString RemoteView::host()
102 {
103  return m_host;
104 }
105 
106 QSize RemoteView::framebufferSize()
107 {
108  return QSize(0, 0);
109 }
110 
111 void RemoteView::startQuitting()
112 {
113 }
114 
115 bool RemoteView::isQuitting()
116 {
117  return false;
118 }
119 
120 int RemoteView::port()
121 {
122  return m_port;
123 }
124 
125 void RemoteView::updateConfiguration()
126 {
127 }
128 
129 void RemoteView::keyEvent(QKeyEvent *)
130 {
131 }
132 
133 bool RemoteView::viewOnly()
134 {
135  return m_viewOnly;
136 }
137 
138 void RemoteView::setViewOnly(bool viewOnly)
139 {
140  m_viewOnly = viewOnly;
141 }
142 
143 bool RemoteView::grabAllKeys()
144 {
145  return m_grabAllKeys;
146 }
147 
148 void RemoteView::setGrabAllKeys(bool grabAllKeys)
149 {
150  m_grabAllKeys = grabAllKeys;
151 
152  if (grabAllKeys) {
153  m_keyboardIsGrabbed = true;
154  grabKeyboard();
155  } else if (m_keyboardIsGrabbed) {
156  releaseKeyboard();
157  }
158 }
159 
160 QPixmap RemoteView::takeScreenshot()
161 {
162  return QPixmap::grabWidget(this);
163 }
164 
165 void RemoteView::showDotCursor(DotCursorState state)
166 {
167  m_dotCursorState = state;
168 }
169 
170 RemoteView::DotCursorState RemoteView::dotCursorState() const
171 {
172  return m_dotCursorState;
173 }
174 
175 bool RemoteView::scaling() const
176 {
177  return m_scale;
178 }
179 
180 void RemoteView::enableScaling(bool scale)
181 {
182  m_scale = scale;
183 }
184 
185 void RemoteView::switchFullscreen(bool)
186 {
187 }
188 
189 void RemoteView::scaleResize(int, int)
190 {
191 }
192 
193 KUrl RemoteView::url()
194 {
195  return m_url;
196 }
197 
198 #ifndef QTONLY
199 QString RemoteView::readWalletPassword(bool fromUserNameOnly)
200 {
201  const QString KRDCFOLDER = "KRDC";
202 
203  window()->setDisabled(true); // WORKAROUND: disable inputs so users cannot close the current tab (see #181230)
204  m_wallet = KWallet::Wallet::openWallet(KWallet::Wallet::NetworkWallet(), window()->winId());
205  window()->setDisabled(false);
206 
207  if (m_wallet) {
208  bool walletOK = m_wallet->hasFolder(KRDCFOLDER);
209  if (!walletOK) {
210  walletOK = m_wallet->createFolder(KRDCFOLDER);
211  kDebug(5010) << "Wallet folder created";
212  }
213  if (walletOK) {
214  kDebug(5010) << "Wallet OK";
215  m_wallet->setFolder(KRDCFOLDER);
216  QString password;
217 
218  QString key;
219  if (fromUserNameOnly)
220  key = m_url.userName();
221  else
222  key = m_url.prettyUrl(KUrl::RemoveTrailingSlash);
223 
224  if (m_wallet->hasEntry(key) &&
225  !m_wallet->readPassword(key, password)) {
226  kDebug(5010) << "Password read OK";
227 
228  return password;
229  }
230  }
231  }
232  return QString();
233 }
234 
235 void RemoteView::saveWalletPassword(const QString &password, bool fromUserNameOnly)
236 {
237  QString key;
238  if (fromUserNameOnly)
239  key = m_url.userName();
240  else
241  key = m_url.prettyUrl(KUrl::RemoveTrailingSlash);
242 
243  if (m_wallet && m_wallet->isOpen()) {
244  kDebug(5010) << "Write wallet password";
245  m_wallet->writePassword(key, password);
246  }
247 }
248 #endif
249 
250 QCursor RemoteView::localDotCursor() const
251 {
252 #ifdef QTONLY
253  return QCursor(); //TODO
254 #else
255  QBitmap cursorBitmap(KGlobal::dirs()->findResource("appdata",
256  "pics/pointcursor.png"));
257  QBitmap cursorMask(KGlobal::dirs()->findResource("appdata",
258  "pics/pointcursormask.png"));
259  return QCursor(cursorBitmap, cursorMask);
260 #endif
261 }
262 
263 void RemoteView::focusInEvent(QFocusEvent *event)
264 {
265  if (m_grabAllKeys) {
266  m_keyboardIsGrabbed = true;
267  grabKeyboard();
268  }
269 
270  QWidget::focusInEvent(event);
271 }
272 
273 void RemoteView::focusOutEvent(QFocusEvent *event)
274 {
275  if (m_grabAllKeys || m_keyboardIsGrabbed) {
276  m_keyboardIsGrabbed = false;
277  releaseKeyboard();
278  }
279 
280  QWidget::focusOutEvent(event);
281 }
282 
283 #include "moc_remoteview.cpp"
RemoteView::takeScreenshot
virtual QPixmap takeScreenshot()
Definition: remoteview.cpp:160
RemoteView::m_grabAllKeys
bool m_grabAllKeys
Definition: remoteview.h:401
RemoteView::RemoteStatus
RemoteStatus
State of the connection.
Definition: remoteview.h:108
RemoteView::showDotCursor
virtual void showDotCursor(DotCursorState state)
Sets the state of the dot cursor, if supported by the backend.
Definition: remoteview.cpp:165
RemoteView::isQuitting
virtual bool isQuitting()
Checks whether the view is currently quitting.
Definition: remoteview.cpp:115
RemoteView::supportsScaling
virtual bool supportsScaling() const
Checks whether the backend supports scaling.
Definition: remoteview.cpp:91
RemoteView::keyEvent
virtual void keyEvent(QKeyEvent *event)
Sends a QKeyEvent to the remote server.
Definition: remoteview.cpp:129
QWidget
RemoteView::localDotCursor
QCursor localDotCursor() const
Definition: remoteview.cpp:250
RemoteView::readWalletPassword
QString readWalletPassword(bool fromUserNameOnly=false)
Definition: remoteview.cpp:199
RemoteView::m_port
int m_port
Definition: remoteview.h:399
RemoteView::m_host
QString m_host
Definition: remoteview.h:398
RemoteView::grabAllKeys
virtual bool grabAllKeys()
Checks whether grabbing all possible keys is enabled.
Definition: remoteview.cpp:143
RemoteView::scaling
virtual bool scaling() const
Checks whether the widget is in scale mode.
Definition: remoteview.cpp:175
RemoteView::statusChanged
void statusChanged(RemoteView::RemoteStatus s)
Emitted when the status of the view changed.
RemoteView::focusInEvent
void focusInEvent(QFocusEvent *event)
Definition: remoteview.cpp:263
RemoteView::Disconnecting
Definition: remoteview.h:113
RemoteView::RemoteView
RemoteView(QWidget *parent=0)
Definition: remoteview.cpp:34
RemoteView::dotCursorState
virtual DotCursorState dotCursorState() const
Returns the state of the local cursor.
Definition: remoteview.cpp:170
RemoteView::m_scale
bool m_scale
Definition: remoteview.h:402
RemoteView::m_keyboardIsGrabbed
bool m_keyboardIsGrabbed
Definition: remoteview.h:403
RemoteView::port
virtual int port()
Definition: remoteview.cpp:120
RemoteView::setViewOnly
virtual void setViewOnly(bool viewOnly)
Enables/disables the view-only mode.
Definition: remoteview.cpp:138
RemoteView::setGrabAllKeys
virtual void setGrabAllKeys(bool grabAllKeys)
Enables/disables grabbing all possible keys.
Definition: remoteview.cpp:148
RemoteView::url
KUrl url()
Definition: remoteview.cpp:193
RemoteView::saveWalletPassword
void saveWalletPassword(const QString &password, bool fromUserNameOnly=false)
Definition: remoteview.cpp:235
RemoteView::m_status
RemoteStatus m_status
The status of the remote view.
Definition: remoteview.h:380
RemoteView::viewOnly
virtual bool viewOnly()
Checks whether the view is in view-only mode.
Definition: remoteview.cpp:133
RemoteView::scaleResize
virtual void scaleResize(int w, int h)
Called when the visible place changed so remote view can resize itself.
Definition: remoteview.cpp:189
RemoteView::enableScaling
virtual void enableScaling(bool scale)
Called to enable or disable scaling.
Definition: remoteview.cpp:180
RemoteView::startQuitting
virtual void startQuitting()
Initiate the disconnection.
Definition: remoteview.cpp:111
RemoteView::updateConfiguration
virtual void updateConfiguration()
Called when the configuration is changed.
Definition: remoteview.cpp:125
RemoteView::focusOutEvent
void focusOutEvent(QFocusEvent *event)
Definition: remoteview.cpp:273
RemoteView::supportsLocalCursor
virtual bool supportsLocalCursor() const
Checks whether the backend supports the concept of local cursors.
Definition: remoteview.cpp:96
RemoteView::host
virtual QString host()
Definition: remoteview.cpp:101
RemoteView::switchFullscreen
virtual void switchFullscreen(bool on)
Called to let the backend know it when we switch from/to fullscreen.
Definition: remoteview.cpp:185
RemoteView::m_viewOnly
bool m_viewOnly
Definition: remoteview.h:400
RemoteView::setStatus
virtual void setStatus(RemoteStatus s)
Set the status of the connection.
Definition: remoteview.cpp:62
remoteview.h
RemoteView::m_url
KUrl m_url
Definition: remoteview.h:404
RemoteView::status
RemoteStatus status()
Returns the current status of the connection.
Definition: remoteview.cpp:57
RemoteView::m_dotCursorState
DotCursorState m_dotCursorState
Definition: remoteview.h:412
RemoteView::m_wallet
KWallet::Wallet * m_wallet
Definition: remoteview.h:409
RemoteView::~RemoteView
virtual ~RemoteView()
Definition: remoteview.cpp:50
RemoteView::DotCursorState
DotCursorState
Describes the state of a local cursor, if there is such a concept in the backend. ...
Definition: remoteview.h:84
RemoteView::Disconnected
Definition: remoteview.h:114
RemoteView::framebufferSize
virtual QSize framebufferSize()
Returns the resolution of the remote framebuffer.
Definition: remoteview.cpp:106
This file is part of the KDE documentation.
Documentation copyright © 1996-2014 The KDE developers.
Generated on Tue Oct 14 2014 22:54:04 by doxygen 1.8.7 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

krdc

Skip menu "krdc"
  • Main Page
  • Alphabetical List
  • Class List
  • Class Hierarchy
  • Class Members
  • File List
  • File Members

kdenetwork API Reference

Skip menu "kdenetwork API Reference"
  • kget
  • kopete
  •   kopete
  •   libkopete
  • krdc
  • krfb

Search



Report problems with this website to our bug tracking system.
Contact the specific authors with questions and comments about the page contents.

KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal