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

krfb

  • sources
  • kde-4.12
  • kdenetwork
  • krfb
  • krfb
invitationsrfbclient.cpp
Go to the documentation of this file.
1 /*
2  Copyright (C) 2009-2010 Collabora Ltd <info@collabora.co.uk>
3  @author George Goldberg <george.goldberg@collabora.co.uk>
4  @author George Kiagiadakis <george.kiagiadakis@collabora.co.uk>
5  Copyright (C) 2007 Alessandro Praduroux <pradu@pradu.it>
6  Copyright (C) 2001-2003 by Tim Jansen <tim@tjansen.de>
7 
8  This program is free software; you can redistribute it and/or
9  modify it under the terms of the GNU General Public
10  License as published by the Free Software Foundation; either
11  version 2 of the License, or (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 Lesser General Public License
19  along with this program. If not, see <http://www.gnu.org/licenses/>.
20 */
21 #include "invitationsrfbclient.h"
22 #include "invitationmanager.h"
23 #include "krfbconfig.h"
24 #include "sockethelpers.h"
25 #include "connectiondialog.h"
26 #include <KNotification>
27 #include <KLocale>
28 
29 bool InvitationsRfbClient::checkPassword(const QByteArray & encryptedPassword)
30 {
31  bool allowUninvited = KrfbConfig::allowUninvitedConnections();
32  QByteArray password = KrfbConfig::uninvitedConnectionPassword().toLocal8Bit();
33 
34  bool authd = false;
35  kDebug() << "about to start autentication";
36 
37  if (allowUninvited) {
38  authd = vncAuthCheckPassword(password, encryptedPassword);
39  }
40 
41  if (!authd) {
42  QList<Invitation> invlist = InvitationManager::self()->invitations();
43 
44  foreach(const Invitation & it, invlist) {
45  kDebug() << "checking password";
46 
47  if (vncAuthCheckPassword(it.password().toLocal8Bit(), encryptedPassword)
48  && it.isValid())
49  {
50  authd = true;
51  InvitationManager::self()->removeInvitation(it);
52  break;
53  }
54  }
55  }
56 
57  if (!authd) {
58  if (InvitationManager::self()->invitations().size() > 0) {
59  KNotification::event("InvalidPasswordInvitations",
60  i18n("Failed login attempt from %1: wrong password", name()));
61  } else {
62  KNotification::event("InvalidPassword",
63  i18n("Failed login attempt from %1: wrong password", name()));
64  }
65 
66  return false;
67  }
68 
69  return true;
70 }
71 
72 
73 void PendingInvitationsRfbClient::processNewClient()
74 {
75  QString host = peerAddress(m_rfbClient->sock) + ":" + QString::number(peerPort(m_rfbClient->sock));
76  bool allowUninvited = KrfbConfig::allowUninvitedConnections();
77 
78  if (!allowUninvited && InvitationManager::self()->activeInvitations() == 0) {
79  KNotification::event("UnexpectedConnection",
80  i18n("Refused uninvited connection attempt from %1", host));
81  reject();
82  } else if (!KrfbConfig::askOnConnect()) {
83  KNotification::event("NewConnectionAutoAccepted",
84  i18n("Accepted connection from %1", host));
85  accept(new InvitationsRfbClient(m_rfbClient, parent()));
86  } else {
87  KNotification::event("NewConnectionOnHold",
88  i18n("Received connection from %1, on hold (waiting for confirmation)",
89  host));
90 
91  InvitationsConnectionDialog *dialog = new InvitationsConnectionDialog(0);
92  dialog->setRemoteHost(host);
93  dialog->setAllowRemoteControl(KrfbConfig::allowDesktopControl());
94 
95  connect(dialog, SIGNAL(okClicked()), SLOT(dialogAccepted()));
96  connect(dialog, SIGNAL(cancelClicked()), SLOT(reject()));
97 
98  dialog->show();
99  }
100 }
101 
102 void PendingInvitationsRfbClient::dialogAccepted()
103 {
104  InvitationsConnectionDialog *dialog = qobject_cast<InvitationsConnectionDialog *>(sender());
105  Q_ASSERT(dialog);
106 
107  InvitationsRfbClient *client = new InvitationsRfbClient(m_rfbClient, parent());
108  client->setControlEnabled(dialog->allowRemoteControl());
109  accept(client);
110 }
111 
112 #include "invitationsrfbclient.moc"
InvitationManager::self
static InvitationManager * self()
Definition: invitationmanager.cpp:26
connectiondialog.h
InvitationManager::invitations
const QList< Invitation > & invitations()
Definition: invitationmanager.cpp:92
KrfbConfig::allowDesktopControl
static bool allowDesktopControl()
Get Allow remote connections to manage the desktop.
Definition: krfbconfig.h:51
KrfbConfig::allowUninvitedConnections
static bool allowUninvitedConnections()
Get Allow connections without an invitation.
Definition: krfbconfig.h:71
ConnectionDialog::allowRemoteControl
bool allowRemoteControl()
Definition: connectiondialog.h:51
InvitationsConnectionDialog::setRemoteHost
void setRemoteHost(const QString &host)
Definition: connectiondialog.cpp:65
Invitation::isValid
bool isValid() const
Definition: invitation.cpp:112
peerPort
unsigned short peerPort(int sock)
Definition: sockethelpers.cpp:54
ConnectionDialog::setAllowRemoteControl
void setAllowRemoteControl(bool b)
Definition: connectiondialog.h:44
_rfbClientRec::sock
SOCKET sock
Definition: libvncserver/rfb/rfb.h:437
InvitationsRfbClient::checkPassword
virtual bool checkPassword(const QByteArray &encryptedPassword)
This method is supposed to check if the provided encryptedPassword matches the criteria for authentic...
Definition: invitationsrfbclient.cpp:29
InvitationsRfbClient
Definition: invitationsrfbclient.h:23
peerAddress
QString peerAddress(int sock)
Definition: sockethelpers.cpp:29
krfbconfig.h
InvitationsConnectionDialog
Definition: connectiondialog.h:58
Invitation
Definition: invitation.h:29
InvitationManager::removeInvitation
void removeInvitation(const Invitation &inv)
Definition: invitationmanager.cpp:118
size
lzo_uint lzo_uint size
Definition: lzoconf.h:275
PendingRfbClient::accept
void accept()
Definition: pendingrfbclient.cpp:30
invitationsrfbclient.h
RfbClient::vncAuthCheckPassword
bool vncAuthCheckPassword(const QByteArray &password, const QByteArray &encryptedPassword) const
This method checks if the encryptedPassword that was sent from the remote user matches the password t...
Definition: rfbclient.cpp:127
Invitation::password
QString password() const
Definition: invitation.cpp:97
KrfbConfig::uninvitedConnectionPassword
static QString uninvitedConnectionPassword()
Get Password for uninvited connections.
Definition: krfbconfig.h:81
PendingRfbClient::reject
void reject()
Definition: pendingrfbclient.cpp:40
invitationmanager.h
RfbClient::name
virtual QString name() const
Returns a name for the client, to be shown to the user.
Definition: rfbclient.cpp:61
PendingRfbClient::m_rfbClient
rfbClientPtr m_rfbClient
Definition: pendingrfbclient.h:43
KrfbConfig::askOnConnect
static bool askOnConnect()
Get Ask before allowing a remote connection.
Definition: krfbconfig.h:61
PendingInvitationsRfbClient::processNewClient
virtual void processNewClient()
Definition: invitationsrfbclient.cpp:73
sockethelpers.h
RfbClient::setControlEnabled
void setControlEnabled(bool enabled)
Definition: rfbclient.cpp:77
This file is part of the KDE documentation.
Documentation copyright © 1996-2014 The KDE developers.
Generated on Tue Oct 14 2014 22:54:10 by doxygen 1.8.7 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

krfb

Skip menu "krfb"
  • Main Page
  • Alphabetical List
  • Class List
  • Class Hierarchy
  • Class Members
  • File List
  • File Members
  • Modules
  • Related Pages

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