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

krfb

kcm_krfb.cpp

Go to the documentation of this file.
00001 
00002 /***************************************************************************
00003                                kcm_krfb.cpp
00004                               --------------
00005     begin                : Sat Mar 02 2002
00006     copyright            : (C) 2002 by Tim Jansen
00007     email                : tim@tjansen.de
00008  ***************************************************************************/
00009 
00010 /***************************************************************************
00011  *                                                                         *
00012  *   This program is free software; you can redistribute it and/or modify  *
00013  *   it under the terms of the GNU General Public License as published by  *
00014  *   the Free Software Foundation; either version 2 of the License, or     *
00015  *   (at your option) any later version.                                   *
00016  *                                                                         *
00017  ***************************************************************************/
00018 
00019 #include "kcm_krfb.h"
00020 #include "kcm_krfb.moc"
00021 
00022 #include <qlayout.h>
00023 #include <qcheckbox.h>
00024 #include <qlabel.h>
00025 #include <qradiobutton.h>
00026 #include <qlineedit.h>
00027 #include <qbuttongroup.h>
00028 #include <qdatastream.h>
00029 #include <kdialog.h>
00030 #include <knuminput.h>
00031 #include <klocale.h>
00032 #include <kaboutdata.h>
00033 #include <kconfig.h>
00034 #include <kgenericfactory.h>
00035 #include <kdebug.h>
00036 #include <QDBusInterface>
00037 #include <QDBusReply>
00038 #define VERSION "0.7"
00039 
00040 
00041 typedef KGenericFactory<KcmKRfb, QWidget> KcmKRfbFactory;
00042 K_EXPORT_COMPONENT_FACTORY( krfb, KcmKRfbFactory( "kcm_krfb" ) )
00043 
00044 
00045 
00046 KcmKRfb::KcmKRfb(QWidget *p, const QStringList &) :
00047     KCModule(KcmKRfbFactory::componentData(), p),
00048     m_configuration(KRFB_CONFIGURATION_MODE) {
00049 
00050     KGlobal::locale()->insertCatalog("krfb");
00051         m_confWidget = new ConfigurationWidget(this);
00052 
00053     QVBoxLayout *l = new QVBoxLayout(this);
00054     l->setSpacing(KDialog::spacingHint());
00055     l->setMargin(0);
00056     l->add(m_confWidget);
00057 
00058     setButtons(Default|Apply|Default);
00059 
00060     KAboutData* about = new KAboutData( "kcm_krfb", 0, ki18n("Desktop Sharing Control Module"),
00061         VERSION,
00062         ki18n("Configure desktop sharing"), KAboutData::License_GPL,
00063         ki18n("(c) 2002, Tim Jansen\n"),
00064         KLocalizedString(), "http://www.tjansen.de/krfb", "tim@tjansen.de");
00065     about->addAuthor(ki18n("Tim Jansen"), KLocalizedString(), "tim@tjansen.de");
00066     setAboutData( about );
00067 
00068     load();
00069 
00070     connect(m_confWidget->passwordInput, SIGNAL(textChanged(const QString&)), SLOT(configChanged()) );
00071     connect(m_confWidget->allowUninvitedCB, SIGNAL(clicked()), SLOT(configChanged()) );
00072     connect(m_confWidget->enableSLPCB, SIGNAL(clicked()), SLOT(configChanged()) );
00073     connect(m_confWidget->confirmConnectionsCB, SIGNAL(clicked()), SLOT(configChanged()) );
00074     connect(m_confWidget->allowDesktopControlCB, SIGNAL(clicked()), SLOT(configChanged()) );
00075     connect(m_confWidget->autoPortCB, SIGNAL(clicked()), SLOT(configChanged()) );
00076     connect(m_confWidget->portInput, SIGNAL(valueChanged(int)), SLOT(configChanged()) );
00077     connect((QObject*)m_confWidget->manageInvitations, SIGNAL(clicked()), 
00078         &m_configuration, SLOT(showManageInvitationsDialog()) );
00079     connect(&m_configuration, SIGNAL(invitationNumChanged(int)), 
00080         this, SLOT(setInvitationNum(int)));
00081     setInvitationNum(m_configuration.invitations().size());
00082     connect(m_confWidget->disableBackgroundCB, SIGNAL(clicked()), SLOT(configChanged()) );
00083 }
00084 
00085 void KcmKRfb::configChanged() {
00086     emit changed(true);
00087 }
00088 
00089 void KcmKRfb::setInvitationNum(int num) {
00090     if (num == 0)
00091         m_confWidget->invitationNumLabel->setText(i18n("You have no open invitation."));
00092     else
00093         m_confWidget->invitationNumLabel->setText(i18n("Open invitations: %1", num));
00094 }
00095 
00096 void KcmKRfb::checkKInetd(bool &kinetdAvailable, bool &krfbAvailable) {
00097     kinetdAvailable = false;
00098     krfbAvailable = false;
00099         //TODO verify it when kinetd will port
00100     QDBusInterface kinetd("org.kde.kded", "/modules/kinetd", "org.kde.kinetd");
00101     QDBusReply<bool> reply = kinetd.call("isInstalled","krfb");
00102     if(!reply.isValid())
00103        return;
00104     krfbAvailable = reply;
00105     kinetdAvailable=true;
00106 }
00107 
00108 void KcmKRfb::load() {
00109     bool kinetdAvailable, krfbAvailable;
00110     checkKInetd(kinetdAvailable, krfbAvailable);
00111 
00112     m_confWidget->allowUninvitedCB->setChecked(m_configuration.allowUninvitedConnections());
00113     m_confWidget->enableSLPCB->setChecked(m_configuration.enableSLP());
00114     m_confWidget->confirmConnectionsCB->setChecked(m_configuration.askOnConnect());
00115     m_confWidget->allowDesktopControlCB->setChecked(m_configuration.allowDesktopControl());
00116     m_confWidget->passwordInput->setText(m_configuration.password());
00117     m_confWidget->autoPortCB->setChecked(m_configuration.preferredPort()<0);
00118     m_confWidget->portInput->setValue(m_configuration.preferredPort()> 0 ?
00119         m_configuration.preferredPort() : 5900);
00120     m_confWidget->disableBackgroundCB->setChecked(m_configuration.disableBackground());
00121     emit changed(false);
00122 }
00123 
00124 void KcmKRfb::save() {
00125 
00126         m_configuration.update();
00127     bool allowUninvited = m_confWidget->allowUninvitedCB->isChecked();
00128     m_configuration.setAllowUninvited(allowUninvited);
00129     m_configuration.setEnableSLP(m_confWidget->enableSLPCB->isChecked());
00130     m_configuration.setAskOnConnect(m_confWidget->confirmConnectionsCB->isChecked());
00131     m_configuration.setAllowDesktopControl(m_confWidget->allowDesktopControlCB->isChecked());
00132     m_configuration.setPassword(m_confWidget->passwordInput->text());
00133     if (m_confWidget->autoPortCB->isChecked())
00134         m_configuration.setPreferredPort(-1);
00135     else
00136         m_configuration.setPreferredPort(m_confWidget->portInput->value());
00137     m_configuration.setDisableBackground(m_confWidget->disableBackgroundCB->isChecked());
00138     m_configuration.save();
00139 #if 0
00140     kapp->dcopClient()->emitDCOPSignal("KRFB::ConfigChanged", "KRFB_ConfigChanged()", QByteArray());
00141 #endif
00142     emit changed(false);
00143 }
00144 
00145 void KcmKRfb::defaults() {
00146     bool kinetdAvailable, krfbAvailable;
00147     checkKInetd(kinetdAvailable, krfbAvailable);
00148 
00149     m_confWidget->allowUninvitedCB->setChecked(false);
00150     m_confWidget->enableSLPCB->setChecked(true);
00151     m_confWidget->confirmConnectionsCB->setChecked(false);
00152     m_confWidget->allowDesktopControlCB->setChecked(false);
00153     m_confWidget->passwordInput->setText("");
00154     m_confWidget->autoPortCB->setChecked(true);
00155     m_confWidget->portInput->setValue(5900);
00156     m_confWidget->disableBackgroundCB->setChecked(false);
00157     emit changed(true);
00158 }
00159 
00160 QString KcmKRfb::quickHelp() const
00161 {
00162     return i18n("<h1>Desktop Sharing</h1> This module allows you to configure"
00163                 " the KDE desktop sharing.");
00164 }
00165 
00166 

krfb

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

kdenetwork

Skip menu "kdenetwork"
  • kget
  • kopete
  •   kopete
  •   libkopete
  •       libpapillon
  • krfb
Generated for kdenetwork by doxygen 1.5.4
This website is maintained by Adriaan de Groot and Allen Winter.
KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal