mirror of
https://invent.kde.org/network/krfb
synced 2024-07-01 07:24:29 +00:00
Use Configuration class for kcontrol
svn path=/trunk/kdenetwork/krfb/; revision=147626
This commit is contained in:
parent
6f0c4515ab
commit
2eb101c6ba
|
@ -1,4 +1,4 @@
|
|||
SUBDIRS = kinetd kcm_krfb libvncserver krfb
|
||||
SUBDIRS = kinetd libvncserver krfb kcm_krfb
|
||||
|
||||
EXTRA_DIST = AUTHORS COPYING ChangeLog INSTALL README TODO NOTES \
|
||||
ROADMAP DCOP-INTERFACE krfb.lsm
|
||||
|
|
13
TODO
13
TODO
|
@ -1,7 +1,16 @@
|
|||
Known bugs:
|
||||
- when the server closes the connection in kinetd mode krfb crashes for
|
||||
unknown reasons. (After this kinetd will not accept new connections
|
||||
because some threads will not be killed properly, use "killall krfb")
|
||||
|
||||
Todo (soon):
|
||||
- fix shutdown connection in kinetd nide
|
||||
- remove the standalone & command line modes (="run on demand" in kcontrol)
|
||||
|
||||
Todo (unscheduled features):
|
||||
- SLP support (or UPnP, or whatever KDE will use)
|
||||
- NAT traversal support (MIDCOM stun/turn, UPnP)
|
||||
- look into adding extension to xfree to improve speed (get noticed of
|
||||
- look into adding an extension to xfree to improve speed (get noticed of
|
||||
screen updates)
|
||||
|
||||
see ROADMAP for planned features!
|
||||
|
||||
|
|
|
@ -5,7 +5,7 @@ lib_LTLIBRARIES = libkcm_krfb.la
|
|||
|
||||
libkcm_krfb_la_SOURCES = kcm_krfb.cpp kcm_krfb.h configurationwidget.ui
|
||||
libkcm_krfb_la_LDFLAGS = $(all_libraries) -module -avoid-version -no-undefined
|
||||
libkcm_krfb_la_LIBADD = $(LIB_QT) $(LIB_KDECORE) $(LIB_KDEUI)
|
||||
libkcm_krfb_la_LIBADD = ../krfb/libkrfbconfig.a $(LIB_QT) $(LIB_KDECORE) $(LIB_KDEUI)
|
||||
|
||||
# Services
|
||||
kcmdir = $(kde_appsdir)/Settings/System
|
||||
|
|
|
@ -43,31 +43,32 @@ K_EXPORT_COMPONENT_FACTORY( libkcm_krfb, KcmKRfbFactory("kcm_krfb") );
|
|||
|
||||
KcmKRfb::KcmKRfb(QWidget *p, const char *name, const QStringList &) :
|
||||
KCModule(p, name),
|
||||
confWidget(this) {
|
||||
m_configuration(KRFB_CONFIGURATION_MODE),
|
||||
m_confWidget(this) {
|
||||
|
||||
QVBoxLayout *l = new QVBoxLayout(this, 0, KDialog::spacingHint());
|
||||
l->add(&confWidget);
|
||||
l->add(&m_confWidget);
|
||||
|
||||
setButtons(Default|Apply|Reset);
|
||||
|
||||
about = new KAboutData( "kcm_krfb", I18N_NOOP("Desktop Sharing Control Module"),
|
||||
m_about = new KAboutData( "kcm_krfb", I18N_NOOP("Desktop Sharing Control Module"),
|
||||
VERSION,
|
||||
I18N_NOOP("Configure desktop sharing"), KAboutData::License_GPL,
|
||||
"(c) 2002, Tim Jansen\n",
|
||||
0, "http://www.tjansen.de/krfb", "tim@tjansen.de");
|
||||
about->addAuthor("Tim Jansen", 0, "tim@tjansen.de");
|
||||
m_about->addAuthor("Tim Jansen", 0, "tim@tjansen.de");
|
||||
|
||||
load();
|
||||
|
||||
connect(confWidget.passwordInput, SIGNAL(textChanged(const QString&)), SLOT(configChanged()) );
|
||||
connect(confWidget.runOnDemandRB, SIGNAL(toggled(bool)), SLOT(configChanged()) );
|
||||
connect(confWidget.allowUninvitedCB, SIGNAL(clicked()), SLOT(configChanged()) );
|
||||
connect(confWidget.confirmConnectionsCB, SIGNAL(clicked()), SLOT(configChanged()) );
|
||||
connect(confWidget.allowDesktopControlCB, SIGNAL(clicked()), SLOT(configChanged()) );
|
||||
connect(m_confWidget.passwordInput, SIGNAL(textChanged(const QString&)), SLOT(configChanged()) );
|
||||
connect(m_confWidget.runOnDemandRB, SIGNAL(toggled(bool)), SLOT(configChanged()) );
|
||||
connect(m_confWidget.allowUninvitedCB, SIGNAL(clicked()), SLOT(configChanged()) );
|
||||
connect(m_confWidget.confirmConnectionsCB, SIGNAL(clicked()), SLOT(configChanged()) );
|
||||
connect(m_confWidget.allowDesktopControlCB, SIGNAL(clicked()), SLOT(configChanged()) );
|
||||
}
|
||||
|
||||
KcmKRfb::~KcmKRfb() {
|
||||
delete about;
|
||||
delete m_about;
|
||||
}
|
||||
|
||||
void KcmKRfb::configChanged() {
|
||||
|
@ -95,86 +96,35 @@ void KcmKRfb::checkKInetd(bool &kinetdAvailable, bool &krfbAvailable) {
|
|||
kinetdAvailable = true;
|
||||
}
|
||||
|
||||
void KcmKRfb::setKInetd(bool enabled) {
|
||||
DCOPClient *d = KApplication::dcopClient();
|
||||
|
||||
QByteArray sdata;
|
||||
QDataStream arg(sdata, IO_WriteOnly);
|
||||
arg << QString("krfb");
|
||||
arg << enabled;
|
||||
if (!d->send ("kded", "kinetd", "setEnabled(QString,bool)", sdata)) {
|
||||
confWidget.runInBackgroundRB->setEnabled(false);
|
||||
confWidget.runOnDemandRB->setChecked(true);
|
||||
}
|
||||
}
|
||||
|
||||
void KcmKRfb::setKInetd(const QDateTime &date) {
|
||||
DCOPClient *d = KApplication::dcopClient();
|
||||
|
||||
QByteArray sdata;
|
||||
QDataStream arg(sdata, IO_WriteOnly);
|
||||
arg << QString("krfb");
|
||||
arg << date;
|
||||
if (!d->send ("kded", "kinetd", "setEnabled(QString,QDateTime)", sdata)) {
|
||||
confWidget.runInBackgroundRB->setEnabled(false);
|
||||
confWidget.runOnDemandRB->setChecked(true);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void KcmKRfb::load() {
|
||||
bool kinetdAvailable, krfbAvailable;
|
||||
checkKInetd(kinetdAvailable, krfbAvailable);
|
||||
|
||||
KConfig c("krfbrc");
|
||||
if (!krfbAvailable) {
|
||||
confWidget.runInBackgroundRB->setEnabled(false);
|
||||
confWidget.runOnDemandRB->setChecked(true);
|
||||
m_confWidget.runInBackgroundRB->setEnabled(false);
|
||||
m_confWidget.runOnDemandRB->setChecked(true);
|
||||
}
|
||||
else {
|
||||
bool daemonMode = c.readBoolEntry("daemonMode", true);
|
||||
confWidget.runInBackgroundRB->setChecked(daemonMode);
|
||||
confWidget.runOnDemandRB->setChecked(!daemonMode);
|
||||
bool daemonMode = m_configuration.daemonMode();
|
||||
m_confWidget.runInBackgroundRB->setChecked(daemonMode);
|
||||
m_confWidget.runOnDemandRB->setChecked(!daemonMode);
|
||||
}
|
||||
confWidget.allowUninvitedCB->setChecked(c.readBoolEntry("allowUninvited", false));
|
||||
confWidget.confirmConnectionsCB->setChecked(c.readBoolEntry("confirmUninvitedConnection", false));
|
||||
confWidget.allowDesktopControlCB->setChecked(c.readBoolEntry("allowDesktopControl", false));
|
||||
confWidget.passwordInput->setText(c.readEntry("uninvitedPassword", ""));
|
||||
m_confWidget.allowUninvitedCB->setChecked(m_configuration.allowUninvitedConnections());
|
||||
m_confWidget.confirmConnectionsCB->setChecked(m_configuration.askOnConnect());
|
||||
m_confWidget.allowDesktopControlCB->setChecked(m_configuration.allowDesktopControl());
|
||||
m_confWidget.passwordInput->setText(m_configuration.password());
|
||||
}
|
||||
|
||||
void KcmKRfb::save() {
|
||||
KConfig c("krfbrc");
|
||||
|
||||
bool allowUninvited = confWidget.allowUninvitedCB->isChecked();
|
||||
bool daemonMode = !confWidget.runOnDemandRB->isChecked();
|
||||
c.writeEntry("daemonMode", daemonMode);
|
||||
c.writeEntry("allowUninvited", allowUninvited);
|
||||
c.writeEntry("confirmUninvitedConnection", confWidget.confirmConnectionsCB->isChecked());
|
||||
c.writeEntry("allowDesktopControl", confWidget.allowDesktopControlCB->isChecked());
|
||||
c.writeEntry("uninvitedPassword", confWidget.passwordInput->text());
|
||||
|
||||
if (!daemonMode)
|
||||
return;
|
||||
|
||||
if (allowUninvited) {
|
||||
setKInetd(true);
|
||||
return;
|
||||
}
|
||||
|
||||
c.setGroup("invitations");
|
||||
int num = c.readNumEntry("invitation_num", 0);
|
||||
QDateTime lastExpiration;
|
||||
for (int i = 0; i < num; i++) {
|
||||
QDateTime e = c.readDateTimeEntry(QString("expiration%1").arg(i));
|
||||
if ((e.isNull()) || (e < QDateTime::currentDateTime()))
|
||||
continue;
|
||||
if (e > lastExpiration)
|
||||
lastExpiration = e;
|
||||
}
|
||||
if (lastExpiration.isNull())
|
||||
setKInetd(false);
|
||||
else
|
||||
setKInetd(lastExpiration);
|
||||
bool allowUninvited = m_confWidget.allowUninvitedCB->isChecked();
|
||||
bool daemonMode = !m_confWidget.runOnDemandRB->isChecked();
|
||||
m_configuration.setDaemonMode(daemonMode);
|
||||
m_configuration.setAllowUninvited(allowUninvited);
|
||||
m_configuration.setAskOnConnect(m_confWidget.confirmConnectionsCB->isChecked());
|
||||
m_configuration.setAllowDesktopControl(m_confWidget.allowDesktopControlCB->isChecked());
|
||||
m_configuration.setPassword(m_confWidget.passwordInput->text());
|
||||
m_configuration.save();
|
||||
}
|
||||
|
||||
void KcmKRfb::defaults() {
|
||||
|
@ -182,23 +132,23 @@ void KcmKRfb::defaults() {
|
|||
checkKInetd(kinetdAvailable, krfbAvailable);
|
||||
|
||||
if (!krfbAvailable) {
|
||||
confWidget.runInBackgroundRB->setEnabled(false);
|
||||
confWidget.runOnDemandRB->setChecked(true);
|
||||
m_confWidget.runInBackgroundRB->setEnabled(false);
|
||||
m_confWidget.runOnDemandRB->setChecked(true);
|
||||
}
|
||||
else {
|
||||
confWidget.runInBackgroundRB->setEnabled(true);
|
||||
confWidget.runInBackgroundRB->setChecked(true);
|
||||
confWidget.runOnDemandRB->setChecked(false);
|
||||
m_confWidget.runInBackgroundRB->setEnabled(true);
|
||||
m_confWidget.runInBackgroundRB->setChecked(true);
|
||||
m_confWidget.runOnDemandRB->setChecked(false);
|
||||
}
|
||||
confWidget.allowUninvitedCB->setChecked(false);
|
||||
confWidget.confirmConnectionsCB->setChecked(false);
|
||||
confWidget.allowDesktopControlCB->setChecked(false);
|
||||
confWidget.passwordInput->setText("");
|
||||
m_confWidget.allowUninvitedCB->setChecked(false);
|
||||
m_confWidget.confirmConnectionsCB->setChecked(false);
|
||||
m_confWidget.allowDesktopControlCB->setChecked(false);
|
||||
m_confWidget.passwordInput->setText("");
|
||||
}
|
||||
|
||||
const KAboutData *KcmKRfb::aboutData() const
|
||||
{
|
||||
return about;
|
||||
return m_about;
|
||||
}
|
||||
|
||||
QString KcmKRfb::quickHelp() const
|
||||
|
|
|
@ -23,15 +23,15 @@
|
|||
#include <qdatetime.h>
|
||||
#include <kcmodule.h>
|
||||
#include "configurationwidget.h"
|
||||
#include "../krfb/configuration.h"
|
||||
|
||||
class KcmKRfb : public KCModule {
|
||||
Q_OBJECT
|
||||
private:
|
||||
ConfigurationWidget confWidget;
|
||||
KAboutData *about;
|
||||
Configuration m_configuration;
|
||||
ConfigurationWidget m_confWidget;
|
||||
KAboutData *m_about;
|
||||
void checkKInetd(bool&, bool&);
|
||||
void setKInetd(bool enabled);
|
||||
void setKInetd(const QDateTime &d);
|
||||
public:
|
||||
KcmKRfb(QWidget *p, const char *name, const QStringList &);
|
||||
~KcmKRfb();
|
||||
|
|
|
@ -1,12 +1,17 @@
|
|||
METASOURCES = AUTO
|
||||
|
||||
bin_PROGRAMS = krfb
|
||||
krfb_SOURCES = rfbcontroller.cc configuration.cc trayicon.cpp \
|
||||
xupdatescanner.cc main.cpp configurationdialog.ui newconnectiondialog.ui \
|
||||
krfbifaceimpl.cc krfbiface.skel manageinvitations.ui personalinvitation.ui \
|
||||
|
||||
noinst_LIBRARIES = libkrfbconfig.a
|
||||
libkrfbconfig_a_SOURCES = configuration.cc configurationdialog.ui manageinvitations.ui personalinvitation.ui \
|
||||
invite.ui invitation.cc configuration_hostname.cpp
|
||||
krfb_LDADD = ../libvncserver/libvncserver.a -lz -lpthread -ljpeg -lXtst \
|
||||
|
||||
|
||||
bin_PROGRAMS = krfb
|
||||
krfb_SOURCES = rfbcontroller.cc trayicon.cpp xupdatescanner.cc main.cpp newconnectiondialog.ui \
|
||||
krfbifaceimpl.cc krfbiface.skel
|
||||
krfb_LDADD = libkrfbconfig.a ../libvncserver/libvncserver.a -lz -lpthread -ljpeg -lXtst \
|
||||
$(LIB_QT) $(LIB_KDECORE) $(LIB_KDEUI) $(LIBSOCKET)
|
||||
krfb_LDFLAGS = $(all_libraries) $(KDE_RPATH)
|
||||
|
||||
kde_services_DATA = kinetd_krfb.desktop
|
||||
|
||||
|
@ -49,8 +54,6 @@ KDE_ICON = krfb
|
|||
# set the include path for X, qt and KDE
|
||||
INCLUDES= -I$(top_srcdir)/krfb/libvncserver $(all_includes)
|
||||
|
||||
# the library search path.
|
||||
krfb_LDFLAGS = $(all_libraries) $(KDE_RPATH)
|
||||
|
||||
CXXFLAGS = @CXXFLAGS@ -DQT_THREAD_SUPPORT
|
||||
|
||||
|
|
|
@ -79,7 +79,8 @@ Configuration::Configuration(krfb_mode mode) :
|
|||
connect(&persInvDlg, SIGNAL(closed()), SLOT(persInvDlgClosed()));
|
||||
|
||||
if ((m_mode == KRFB_STAND_ALONE) ||
|
||||
(m_mode == KRFB_KINETD_MODE)) {
|
||||
(m_mode == KRFB_KINETD_MODE) ||
|
||||
(m_mode == KRFB_CONFIGURATION_MODE)) {
|
||||
connect(&expirationTimer, SIGNAL(timeout()), SLOT(invalidateOldInvitations()));
|
||||
expirationTimer.start(1000*60);
|
||||
}
|
||||
|
@ -149,8 +150,10 @@ void Configuration::removeInvitation(QValueList<Invitation>::iterator it) {
|
|||
}
|
||||
|
||||
void Configuration::doKinetdConf() {
|
||||
if (!daemonFlag)
|
||||
if (!daemonFlag) {
|
||||
setKInetd(false);
|
||||
return;
|
||||
}
|
||||
|
||||
if (allowUninvitedFlag) {
|
||||
setKInetd(true);
|
||||
|
@ -265,10 +268,17 @@ void Configuration::reload() {
|
|||
saveToDialogs();
|
||||
}
|
||||
|
||||
void Configuration::save() {
|
||||
saveToKConfig();
|
||||
saveToDialogs();
|
||||
doKinetdConf();
|
||||
}
|
||||
|
||||
Invitation Configuration::createInvitation() {
|
||||
Invitation inv;
|
||||
invitationList.push_back(inv);
|
||||
emit passwordChanged();
|
||||
doKinetdConf();
|
||||
return inv;
|
||||
}
|
||||
|
||||
|
@ -305,7 +315,7 @@ bool Configuration::allowDesktopControl() const {
|
|||
return allowDesktopControlFlag;
|
||||
}
|
||||
|
||||
bool Configuration::allowUninvitedConnects() const {
|
||||
bool Configuration::allowUninvitedConnections() const {
|
||||
return allowUninvitedFlag;
|
||||
}
|
||||
|
||||
|
@ -325,33 +335,33 @@ QValueList<Invitation> &Configuration::invitations() {
|
|||
return invitationList;
|
||||
}
|
||||
|
||||
void Configuration::setDaemonMode(bool daemonMode) {
|
||||
daemonFlag = daemonMode;
|
||||
}
|
||||
|
||||
void Configuration::setAllowUninvited(bool allowUninvited) {
|
||||
allowUninvitedFlag = allowUninvited;
|
||||
}
|
||||
|
||||
void Configuration::setOnceConnection(bool oneConnection)
|
||||
{
|
||||
oneConnectionFlag = oneConnection;
|
||||
saveToKConfig();
|
||||
saveToDialogs();
|
||||
}
|
||||
|
||||
void Configuration::setAskOnConnect(bool askOnConnect)
|
||||
{
|
||||
askOnConnectFlag = askOnConnect;
|
||||
saveToKConfig();
|
||||
saveToDialogs();
|
||||
}
|
||||
|
||||
void Configuration::setAllowDesktopControl(bool allowDesktopControl)
|
||||
{
|
||||
allowDesktopControlFlag = allowDesktopControl;
|
||||
saveToKConfig();
|
||||
saveToDialogs();
|
||||
}
|
||||
|
||||
void Configuration::setPassword(QString password)
|
||||
{
|
||||
passwordString = password;
|
||||
emit passwordChanged();
|
||||
saveToKConfig();
|
||||
saveToDialogs();
|
||||
}
|
||||
|
||||
int Configuration::port() const
|
||||
|
@ -466,7 +476,6 @@ void Configuration::showPersonalInvitationDialog() {
|
|||
Invitation inv = createInvitation();
|
||||
saveToDialogs();
|
||||
saveToKConfig();
|
||||
doKinetdConf();
|
||||
|
||||
invDlg.createInvitationButton->setEnabled(false);
|
||||
persInvDlg.hostLabel->setText(QString("%1:%2").arg(hostname()).arg(port()));
|
||||
|
@ -490,7 +499,6 @@ void Configuration::inviteEmail() {
|
|||
Invitation inv = createInvitation();
|
||||
saveToDialogs();
|
||||
saveToKConfig();
|
||||
doKinetdConf();
|
||||
|
||||
KApplication *app = KApplication::kApplication();
|
||||
app->invokeMailer(QString::null, QString::null, QString::null,
|
||||
|
|
|
@ -36,7 +36,8 @@ enum krfb_mode {
|
|||
KRFB_STAND_ALONE,
|
||||
KRFB_STAND_ALONE_CMDARG,
|
||||
KRFB_KINETD_MODE,
|
||||
KRFB_INVITATION_MODE
|
||||
KRFB_INVITATION_MODE,
|
||||
KRFB_CONFIGURATION_MODE
|
||||
};
|
||||
|
||||
class ConfigurationDialog2 : public ConfigurationDialog {
|
||||
|
@ -87,18 +88,21 @@ public:
|
|||
bool oneConnection() const;
|
||||
bool askOnConnect() const;
|
||||
bool allowDesktopControl() const;
|
||||
bool allowUninvitedConnects() const;
|
||||
bool allowUninvitedConnections() const;
|
||||
bool showInvitationDialogOnStartup() const;
|
||||
bool daemonMode() const;
|
||||
QString password() const;
|
||||
QString hostname() const;
|
||||
int port() const;
|
||||
|
||||
void setDaemonMode(bool daemonMode);
|
||||
void setAllowUninvited(bool allowUninvited);
|
||||
void setOnceConnection(bool oneConnection);
|
||||
void setAskOnConnect(bool askOnConnect);
|
||||
void setAllowDesktopControl(bool allowDesktopControl);
|
||||
void setPassword(QString password);
|
||||
void reload();
|
||||
void save();
|
||||
|
||||
QValueList<Invitation> &invitations();
|
||||
void removeInvitation(QValueList<Invitation>::iterator it);
|
||||
|
|
|
@ -14,7 +14,7 @@ k_dcop:
|
|||
virtual void disconnect() = 0;
|
||||
|
||||
/**
|
||||
* Quites krfb, connected clients will be disconnected.
|
||||
* Quits krfb, connected clients will be disconnected.
|
||||
*/
|
||||
virtual void exit() = 0;
|
||||
|
||||
|
|
|
@ -42,6 +42,7 @@ bool KRfbIfaceImpl::oneConnection()
|
|||
void KRfbIfaceImpl::setOneConnection(bool b)
|
||||
{
|
||||
configuration->setOnceConnection(b);
|
||||
configuration->save();
|
||||
}
|
||||
bool KRfbIfaceImpl::askOnConnect()
|
||||
{
|
||||
|
@ -50,6 +51,7 @@ bool KRfbIfaceImpl::askOnConnect()
|
|||
void KRfbIfaceImpl::setAskOnConnect(bool b)
|
||||
{
|
||||
configuration->setAskOnConnect(b);
|
||||
configuration->save();
|
||||
}
|
||||
bool KRfbIfaceImpl::allowDesktopControl()
|
||||
{
|
||||
|
@ -58,10 +60,12 @@ bool KRfbIfaceImpl::allowDesktopControl()
|
|||
void KRfbIfaceImpl::setAllowDesktopControl(bool b)
|
||||
{
|
||||
configuration->setAllowDesktopControl(b);
|
||||
configuration->save();
|
||||
}
|
||||
void KRfbIfaceImpl::setPassword(QString password)
|
||||
{
|
||||
configuration->setPassword(password);
|
||||
configuration->save();
|
||||
}
|
||||
int KRfbIfaceImpl::port()
|
||||
{
|
||||
|
|
|
@ -198,7 +198,7 @@ int main(int argc, char *argv[])
|
|||
config = new Configuration(mode);
|
||||
|
||||
if ((mode == KRFB_KINETD_MODE) &&
|
||||
(!config->allowUninvitedConnects()) &&
|
||||
(!config->allowUninvitedConnections()) &&
|
||||
(config->invitations().size() == 0)) {
|
||||
KNotifyClient::event("UnexpectedConnection");
|
||||
return 1;
|
||||
|
|
|
@ -533,7 +533,7 @@ bool RFBController::handleCheckPassword(rfbClientPtr cl,
|
|||
|
||||
bool authd = false;
|
||||
|
||||
if (configuration->allowUninvitedConnects())
|
||||
if (configuration->allowUninvitedConnections())
|
||||
authd = checkPassword(configuration->password(),
|
||||
cl->authChallenge, response, len);
|
||||
|
||||
|
@ -635,7 +635,7 @@ void RFBController::handlePointerEvent(int button_mask, int x, int y) {
|
|||
}
|
||||
|
||||
void RFBController::passwordChanged() {
|
||||
bool authRequired = (!configuration->allowUninvitedConnects()) ||
|
||||
bool authRequired = (!configuration->allowUninvitedConnections()) ||
|
||||
(configuration->password().length() != 0) ||
|
||||
(configuration->invitations().count() > 0);
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user