1 /****************************************************************************
3 ** Copyright (C) 2002-2003 Tim Jansen <tim@tjansen.de>
4 ** Copyright (C) 2007 Urs Wolfer <uwolfer @ kde.org>
6 ** This file is part of KDE.
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.
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.
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.
23 ****************************************************************************/
25 #include "remoteview.h"
29 #include <KStandardDirs>
31 RemoteView::RemoteView(QWidget
*parent
)
33 m_status(Disconnected
),
38 m_dotCursorState(CursorOff
)
42 RemoteView::RemoteStatus
RemoteView::status()
47 void RemoteView::setStatus(RemoteView::RemoteStatus s
)
52 if (((1 + (int)m_status
) != (int)s
) && (s
!= Disconnected
)) {
53 // follow state transition rules
55 if (s
== Disconnecting
) {
56 if (m_status
== Disconnected
)
59 Q_ASSERT(((int) s
) >= 0);
60 if (((int)m_status
) > ((int)s
)) {
61 m_status
= Disconnected
;
62 emit
statusChanged(Disconnected
);
64 // smooth state transition
65 int origState
= (int)m_status
;
66 for (int i
= origState
; i
< (int)s
; i
++) {
67 m_status
= (RemoteStatus
) i
;
68 emit
statusChanged((RemoteStatus
) i
);
73 emit
statusChanged(m_status
);
76 RemoteView::~RemoteView()
80 bool RemoteView::supportsScaling() const
85 bool RemoteView::supportsLocalCursor() const
90 QString
RemoteView::host()
95 QSize
RemoteView::framebufferSize()
100 void RemoteView::startQuitting()
104 bool RemoteView::isQuitting()
109 int RemoteView::port()
114 void RemoteView::keyEvent(QKeyEvent
*)
118 bool RemoteView::viewOnly()
123 void RemoteView::setViewOnly(bool viewOnly
)
125 m_viewOnly
= viewOnly
;
128 void RemoteView::showDotCursor(DotCursorState state
)
130 m_dotCursorState
= state
;
133 RemoteView::DotCursorState
RemoteView::dotCursorState() const
135 return m_dotCursorState
;
138 bool RemoteView::scaling() const
143 void RemoteView::enableScaling(bool)
147 void RemoteView::switchFullscreen(bool)
151 KUrl
RemoteView::url()
156 QString
RemoteView::readWalletPassword()
158 QString krdc_folder
= "KRDC";
160 m_wallet
= KWallet::Wallet::openWallet(KWallet::Wallet::NetworkWallet(), window()->winId());
163 bool walletOK
= m_wallet
->hasFolder(krdc_folder
);
165 walletOK
= m_wallet
->createFolder(krdc_folder
);
166 kDebug(5010) << "Wallet folder created";
169 kDebug(5010) << "Wallet OK";
170 m_wallet
->setFolder(krdc_folder
);
173 if (m_wallet
->hasEntry(m_url
.prettyUrl(KUrl::RemoveTrailingSlash
)) &&
174 !m_wallet
->readPassword(m_url
.prettyUrl(KUrl::RemoveTrailingSlash
), password
)) {
175 kDebug(5010) << "Password read OK";
184 void RemoteView::saveWalletPassword(const QString
&password
)
186 if (m_wallet
&& m_wallet
->isOpen() && !m_wallet
->hasEntry(m_url
.prettyUrl(KUrl::RemoveTrailingSlash
))) {
187 kDebug(5010) << "Write wallet password";
188 m_wallet
->writePassword(m_url
.prettyUrl(KUrl::RemoveTrailingSlash
), password
);
192 QCursor
RemoteView::localDotCursor() const
194 QBitmap
cursorBitmap(KGlobal::dirs()->findResource("appdata",
195 "pics/pointcursor.png"));
196 QBitmap
cursorMask(KGlobal::dirs()->findResource("appdata",
197 "pics/pointcursormask.png"));
198 return QCursor(cursorBitmap
, cursorMask
);
201 #include "remoteview.moc"