1
0
mirror of https://invent.kde.org/network/krfb synced 2024-07-03 00:18:36 +00:00

use KConfig XT

svn path=/trunk/KDE/kdenetwork/krfb/; revision=651410
This commit is contained in:
Alessandro Praduroux 2007-04-07 16:16:51 +00:00
parent cb1280f2b7
commit 67cac2140a
11 changed files with 322 additions and 59 deletions

View File

@ -23,16 +23,19 @@ set(krfb_SRCS
connectioncontroller.cpp
events.cpp
framebuffer.cpp
# rfbcontroller.cc
# xupdatescanner.cc
)
kde4_automoc(${krfb_SRCS})
kde4_add_kcfg_files(krfb_SRCS krfbconfig.kcfgc)
kde4_add_ui_files(krfb_SRCS connectionwidget.ui
manageinvitations.ui
personalinvitewidget.ui
invitewidget.ui)
invitewidget.ui
configtcp.ui
configsecurity.ui
)
kde4_add_executable(krfb ${krfb_SRCS})

139
configsecurity.ui Normal file
View File

@ -0,0 +1,139 @@
<ui version="4.0" >
<class>Security</class>
<widget class="QWidget" name="Security" >
<property name="geometry" >
<rect>
<x>0</x>
<y>0</y>
<width>507</width>
<height>201</height>
</rect>
</property>
<property name="windowTitle" >
<string>Form</string>
</property>
<layout class="QVBoxLayout" >
<item>
<widget class="QCheckBox" name="kcfg_allowUninvitedConnections" >
<property name="text" >
<string>Allow uninvited connections</string>
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="kcfg_allowDesktopControl" >
<property name="text" >
<string>Allow remote connections to control your desktop</string>
</property>
<property name="checked" >
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="kcfg_askOnConnect" >
<property name="enabled" >
<bool>false</bool>
</property>
<property name="text" >
<string>Ask before accepting an uninvited connection</string>
</property>
<property name="checked" >
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="label" >
<property name="enabled" >
<bool>false</bool>
</property>
<property name="text" >
<string>Uninvited connections password</string>
</property>
<property name="buddy" >
<cstring>kcfg_uninvitedConnectionPassword</cstring>
</property>
</widget>
</item>
<item>
<widget class="KLineEdit" name="kcfg_uninvitedConnectionPassword" >
<property name="enabled" >
<bool>false</bool>
</property>
</widget>
</item>
<item>
<spacer>
<property name="orientation" >
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" >
<size>
<width>20</width>
<height>40</height>
</size>
</property>
</spacer>
</item>
</layout>
</widget>
<customwidgets>
<customwidget>
<class>KLineEdit</class>
<extends>QLineEdit</extends>
<header>klineedit.h</header>
</customwidget>
</customwidgets>
<resources/>
<connections>
<connection>
<sender>kcfg_allowUninvitedConnections</sender>
<signal>toggled(bool)</signal>
<receiver>kcfg_askOnConnect</receiver>
<slot>setEnabled(bool)</slot>
<hints>
<hint type="sourcelabel" >
<x>22</x>
<y>24</y>
</hint>
<hint type="destinationlabel" >
<x>29</x>
<y>80</y>
</hint>
</hints>
</connection>
<connection>
<sender>kcfg_allowUninvitedConnections</sender>
<signal>toggled(bool)</signal>
<receiver>kcfg_uninvitedConnectionPassword</receiver>
<slot>setEnabled(bool)</slot>
<hints>
<hint type="sourcelabel" >
<x>98</x>
<y>21</y>
</hint>
<hint type="destinationlabel" >
<x>192</x>
<y>137</y>
</hint>
</hints>
</connection>
<connection>
<sender>kcfg_allowUninvitedConnections</sender>
<signal>toggled(bool)</signal>
<receiver>label</receiver>
<slot>setEnabled(bool)</slot>
<hints>
<hint type="sourcelabel" >
<x>117</x>
<y>20</y>
</hint>
<hint type="destinationlabel" >
<x>120</x>
<y>94</y>
</hint>
</hints>
</connection>
</connections>
</ui>

90
configtcp.ui Normal file
View File

@ -0,0 +1,90 @@
<ui version="4.0" >
<class>TCP</class>
<widget class="QWidget" name="TCP" >
<property name="geometry" >
<rect>
<x>0</x>
<y>0</y>
<width>400</width>
<height>169</height>
</rect>
</property>
<property name="windowTitle" >
<string>Form</string>
</property>
<layout class="QVBoxLayout" >
<item>
<widget class="QCheckBox" name="kcfg_useDefaultPort" >
<property name="text" >
<string>Use default port</string>
</property>
<property name="checked" >
<bool>true</bool>
</property>
</widget>
</item>
<item>
<layout class="QHBoxLayout" >
<property name="spacing" >
<number>6</number>
</property>
<property name="leftMargin" >
<number>0</number>
</property>
<property name="topMargin" >
<number>0</number>
</property>
<property name="rightMargin" >
<number>0</number>
</property>
<property name="bottomMargin" >
<number>0</number>
</property>
<item>
<widget class="QLabel" name="label" >
<property name="text" >
<string>Listening Port:</string>
</property>
<property name="buddy" >
<cstring>kcfg_port</cstring>
</property>
</widget>
</item>
<item>
<widget class="QSpinBox" name="kcfg_port" >
<property name="enabled" >
<bool>false</bool>
</property>
<property name="maximum" >
<number>65535</number>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</widget>
<tabstops>
<tabstop>kcfg_useDefaultPort</tabstop>
<tabstop>kcfg_port</tabstop>
</tabstops>
<resources/>
<connections>
<connection>
<sender>kcfg_useDefaultPort</sender>
<signal>toggled(bool)</signal>
<receiver>kcfg_port</receiver>
<slot>setDisabled(bool)</slot>
<hints>
<hint type="sourcelabel" >
<x>120</x>
<y>53</y>
</hint>
<hint type="destinationlabel" >
<x>277</x>
<y>122</y>
</hint>
</hints>
</connection>
</connections>
</ui>

View File

@ -28,6 +28,7 @@
#include "events.h"
#include "krfbserver.h"
#include "krfbconfig.h"
#include <X11/Xutil.h>
@ -73,24 +74,19 @@ ConnectionController::~ConnectionController()
enum rfbNewClientAction ConnectionController::handleNewClient()
{
KSharedConfigPtr conf = KGlobal::config();
KConfigGroup srvconf(conf, "Server");
bool allowDesktopControl = srvconf.readEntry("allowDesktopControl",false);
bool askOnConnect = srvconf.readEntry("askOnConnect",true);
bool allowDesktopControl = KrfbConfig::allowDesktopControl();
bool askOnConnect = KrfbConfig::askOnConnect();
int socket = cl->sock;
// cl->negotiationFinishedHook = negotiationFinishedHook; ???
QString remoteIp;
#if 0
// TODO: this drops the connection >.<
QTcpSocket t;
t.setSocketDescriptor(socket); //, QAbstractSocket::ConnectedState, QIODevice::NotOpen);
host = t.peerAddress().toString();
remoteIp = t.peerAddress().toString();
#endif
QString remoteIp;
if (!askOnConnect && InvitationManager::self()->invitations().size() == 0) {
KNotification::event("NewConnectionAutoAccepted",
i18n("Accepted uninvited connection from %1",
@ -121,11 +117,8 @@ enum rfbNewClientAction ConnectionController::handleNewClient()
bool ConnectionController::handleCheckPassword(rfbClientPtr cl, const char *response, int len)
{
KSharedConfigPtr conf = KGlobal::config();
KConfigGroup srvconf(conf, "Server");
bool allowUninvited = srvconf.readEntry("allowUninvitedConnections",false);
QString password = srvconf.readEntry("uninvitedConnectionPassword",QString());
bool allowUninvited = KrfbConfig::allowUninvitedConnections();
QString password = KrfbConfig::uninvitedConnectionPassword();
bool authd = false;
kDebug() << "about to start autentication" << endl;
@ -138,7 +131,7 @@ bool ConnectionController::handleCheckPassword(rfbClientPtr cl, const char *resp
QList<Invitation> invlist = InvitationManager::self()->invitations();
foreach(Invitation it, invlist) {
kDebug() << "checking password????!?!?!" << endl;
kDebug() << "checking password" << endl;
if (checkPassword(it.password(), cl->authChallenge, response, len) && it.isValid()) {
authd = true;
//configuration->removeInvitation(it);

View File

@ -6,7 +6,7 @@
<x>0</x>
<y>0</y>
<width>521</width>
<height>328</height>
<height>318</height>
</rect>
</property>
<layout class="QGridLayout" >
@ -70,7 +70,7 @@
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter</set>
</property>
<property name="wordWrap" >
<bool>false</bool>
<bool>true</bool>
</property>
<property name="margin" >
<number>0</number>
@ -175,38 +175,6 @@
</property>
</widget>
</item>
<item row="4" column="1" >
<spacer>
<property name="orientation" >
<enum>Qt::Vertical</enum>
</property>
<property name="sizeType" >
<enum>QSizePolicy::Minimum</enum>
</property>
<property name="sizeHint" >
<size>
<width>20</width>
<height>84</height>
</size>
</property>
</spacer>
</item>
<item row="2" column="1" >
<spacer>
<property name="orientation" >
<enum>Qt::Vertical</enum>
</property>
<property name="sizeType" >
<enum>QSizePolicy::Minimum</enum>
</property>
<property name="sizeHint" >
<size>
<width>20</width>
<height>80</height>
</size>
</property>
</spacer>
</item>
</layout>
</widget>
<layoutdefault spacing="6" margin="11" />

View File

@ -20,6 +20,9 @@ const int UPDATE_TIME = 500;
FrameBuffer::FrameBuffer(WId id, QObject *parent)
: QObject(parent), win(id)
{
//TODO: implement reference counting to avoid update the screen
// while no client is connected.
fbImage = QPixmap::grabWindow(win).toImage();
fb = new char[fbImage.numBytes()];
QTimer *t = new QTimer(this);

33
krfb.kcfg Normal file
View File

@ -0,0 +1,33 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE kcfg SYSTEM
"http://www.kde.org/standards/kcfg/1.0/kcfg.xsd">
<kcfg>
<kcfgfile />
<group name="TCP">
<entry name="useDefaultPort" type="Bool">
<label>Use the default port for VNC (5900)</label>
<default>true</default>
</entry>
<entry name="port" type="Int">
<label>This is the port on wich krfb will listen.</label>
<default>5900</default>
</entry>
</group>
<group name="Security">
<entry name="allowDesktopControl" type="Bool">
<label>Allow remote connections to manage the desktop.</label>
<default>true</default>
</entry>
<entry name="askOnConnect" type="Bool">
<label>Ask before allowing a remote connection.</label>
<default>true</default>
</entry>
<entry name="allowUninvitedConnections" type="Bool">
<label>Allow connections without an invitation.</label>
<default>false</default>
</entry>
<entry name="uninvitedConnectionPassword" type="String">
<label>Password for uninvited connections.</label>
</entry>
</group>
</kcfg>

3
krfbconfig.kcfgc Normal file
View File

@ -0,0 +1,3 @@
File=krfb.kcfg
ClassName=KrfbConfig
Singleton=true

View File

@ -20,7 +20,6 @@
#include <QApplication>
#include <QDesktopWidget>
#include <KConfig>
#include <KGlobal>
#include <KUser>
#include <KLocale>
@ -29,6 +28,7 @@
#include "connectioncontroller.h"
#include "framebuffer.h"
#include "krfbconfig.h"
static const char* cur=
@ -109,8 +109,6 @@ static void clipboardHook(char* str,int len, rfbClientPtr cl)
}
const int DEFAULT_TCP_PORT = 5900;
static KStaticDeleter<KrfbServer> sd;
KrfbServer * KrfbServer::_self = 0;
KrfbServer * KrfbServer::self() {
@ -130,10 +128,7 @@ void KrfbServer::startListening()
{
rfbScreenInfoPtr screen;
KSharedConfigPtr conf = KGlobal::config();
KConfigGroup tcpConfig(conf, "TCP");
int port = tcpConfig.readEntry("port",DEFAULT_TCP_PORT);
int port = KrfbConfig::port();
int w = fb->width();
int h = fb->height();

View File

@ -12,6 +12,7 @@
#include "personalinvitedialog.h"
#include "invitationmanager.h"
#include "invitation.h"
#include "krfbconfig.h"
#include <QWidget>
#include <QToolTip>
@ -23,6 +24,27 @@
#include <KIconLoader>
#include <KLocale>
#include <KGlobal>
#include <KConfigDialog>
// settings dialog
#include "ui_configtcp.h"
#include "ui_configsecurity.h"
class TCP: public QWidget, public Ui::TCP {
public:
TCP(QWidget *parent=0) :QWidget(parent)
{
setupUi(this);
}
};
class Security: public QWidget, public Ui::Security {
public:
Security(QWidget *parent=0) :QWidget(parent)
{
setupUi(this);
}
};
ManageInvitationsDialog::ManageInvitationsDialog(QWidget *parent)
@ -48,6 +70,7 @@ ManageInvitationsDialog::ManageInvitationsDialog(QWidget *parent)
SLOT( inviteByMail() ));
connect( InvitationManager::self(), SIGNAL( invitationNumChanged( int )),
SLOT( reloadInvitations() ));
connect( this, SIGNAL(user1Clicked()),SLOT(showConfiguration()));
reloadInvitations();
}
@ -95,3 +118,15 @@ void ManageInvitationsDialog::reloadInvitations()
invitationWidget->resizeColumnToContents(0);
}
void ManageInvitationsDialog::showConfiguration()
{
if(KConfigDialog::showDialog("settings"))
return;
KConfigDialog *dialog = new KConfigDialog(this, "settings", KrfbConfig::self());
dialog->addPage(new TCP, i18n("Network"), "network");
dialog->addPage(new Security, i18n("Security"), "encrypted");
dialog->show();
}

View File

@ -29,6 +29,7 @@ public Q_SLOTS:
void inviteManually();
void inviteByMail();
void reloadInvitations();
void showConfiguration();
private: