15 #include "ui_configtcp.h"
16 #include "ui_configsecurity.h"
18 #include <KConfigDialog>
20 #include <KIconLoader>
22 #include <KMessageBox>
23 #include <KStandardGuiItem>
24 #include <KSystemTimeZone>
25 #include <KToolInvocation>
26 #include <KStandardAction>
27 #include <KActionCollection>
29 #include <QtGui/QWidget>
30 #include <QtGui/QToolTip>
31 #include <QtGui/QCursor>
32 #include <QtCore/QDateTime>
33 #include <QtNetwork/QNetworkInterface>
35 class TCP:
public QWidget,
public Ui::TCP
43 class Security:
public QWidget,
public Ui::Security
55 setAttribute(Qt::WA_DeleteOnClose,
false);
58 m_ui.setupUi(mainWidget);
59 m_ui.pixmapLabel->setPixmap(KIcon(
"krfb").pixmap(128));
60 setCentralWidget(mainWidget);
62 connect(m_ui.helpLabel, SIGNAL(linkActivated(QString)), SLOT(
showWhatsthis()));
63 connect(m_ui.newPersonalInvitationButton, SIGNAL(clicked()), SLOT(
inviteManually()));
64 connect(m_ui.newEmailInvitationButton, SIGNAL(clicked()), SLOT(
inviteByMail()));
66 connect(m_ui.deleteAllButton, SIGNAL(clicked()), SLOT(
deleteAll()));
67 connect(m_ui.deleteOneButton, SIGNAL(clicked()), SLOT(
deleteCurrent()));
68 connect(m_ui.invitationWidget, SIGNAL(itemSelectionChanged()), SLOT(
selectionChanged()));
70 KStandardAction::quit(QCoreApplication::instance(), SLOT(quit()), actionCollection());
71 KStandardAction::preferences(
this, SLOT(
showConfiguration()), actionCollection());
73 setupGUI(QSize(550, 330));
74 setAutoSaveSettings();
85 QToolTip::showText(QCursor::pos(),
86 i18n(
"An invitation creates a one-time password that allows the receiver to connect to your desktop.\n"
87 "It is valid for only one successful connection and will expire after an hour if it has not been used. \n"
88 "When somebody connects to your computer a dialog will appear and ask you for permission.\n"
89 "The connection will not be established before you accept it. In this dialog you can also\nrestrict "
90 "the other person to view your desktop only, without the ability to move your\nmouse pointer or press "
91 "keys.\nIf you want to create a permanent password for Desktop Sharing, allow 'Uninvited Connections' \n"
92 "in the configuration."));
107 int r = KMessageBox::warningContinueCancel(
this,
108 i18n(
"When sending an invitation by email, note that everybody who reads this email "
109 "will be able to connect to your computer for one hour, or until the first "
110 "successful connection took place, whichever comes first. \n"
111 "You should either encrypt the email or at least send it only in a "
112 "secure network, but not over the Internet."),
113 i18n(
"Send Invitation via Email"),
114 KStandardGuiItem::cont(),
115 KStandardGuiItem::cancel(),
116 "showEmailInvitationWarning");
118 if (r == KMessageBox::Cancel) {
122 QList<QNetworkInterface> ifl = QNetworkInterface::allInterfaces();
125 foreach(
const QNetworkInterface & nif, ifl) {
126 if (nif.flags() & QNetworkInterface::IsLoopBack) {
130 if (nif.flags() & QNetworkInterface::IsRunning) {
131 if (!nif.addressEntries().isEmpty()) {
132 host = nif.addressEntries()[0].ip().toString();
138 KUrl invUrl(QString(
"vnc://invitation:%1@%2:%3").arg(inv.
password()).arg(host).arg(port));
139 KToolInvocation::invokeMailer(QString(), QString(), QString(),
140 i18n(
"Desktop Sharing (VNC) invitation"),
141 ki18n(
"You have been invited to a VNC session. If you have the KDE Remote "
142 "Desktop Connection installed, just click on the link below.\n\n"
144 "Otherwise you can use any VNC client with the following parameters:\n\n"
147 "For security reasons this invitation will expire at %5 (%6).")
150 .subs(QString::number(port))
153 .subs(KSystemTimeZones::local().name())
160 m_ui.invitationWidget->clear();
161 KLocale *loc = KGlobal::locale();
165 QTreeWidgetItem *it =
new QTreeWidgetItem(strs);
166 m_ui.invitationWidget->addTopLevelItem(it);
169 m_ui.invitationWidget->resizeColumnToContents(0);
175 if (KConfigDialog::showDialog(
"settings")) {
179 KConfigDialog *dialog =
new KConfigDialog(
this,
"settings",
KrfbConfig::self());
180 dialog->addPage(
new TCP, i18n(
"Network"),
"network-workgroup");
181 dialog->addPage(
new Security, i18n(
"Security"),
"security-high");
182 dialog->setHelp(QString(),
"krfb");
188 if (KMessageBox::warningContinueCancel(
this,
189 i18n(
"<qt>Are you sure you want to delete all invitations?</qt>"),
190 i18n(
"Confirm delete Invitations"),
191 KStandardGuiItem::ok(),
192 KStandardGuiItem::cancel(),
193 QString(
"krfbdeleteallinv")) !=
194 KMessageBox::Continue) {
203 if (KMessageBox::warningContinueCancel(
this,
204 i18n(
"<qt>Are you sure you want to delete this invitation?</qt>"),
205 i18n(
"Confirm delete Invitations"),
206 KStandardGuiItem::ok(),
207 KStandardGuiItem::cancel(),
208 QString(
"krfbdeleteoneinv")) !=
209 KMessageBox::Continue) {
217 QList<QTreeWidgetItem *> itl = m_ui.invitationWidget->selectedItems();
218 foreach(QTreeWidgetItem * itm, itl) {
220 if (inv.
creationTime() == itm->data(0, Qt::UserRole + 1)) {
235 m_ui.deleteOneButton->setEnabled(m_ui.invitationWidget->selectedItems().size() > 0);
240 if (group.readEntry(
"Visible",
true)) {
243 KMainWindow::readProperties(group);
248 group.writeEntry(
"Visible", isVisible());
249 KMainWindow::saveProperties(group);
252 #include "manageinvitationsdialog.moc"
static InvitationManager * self()
ManageInvitationsDialog(QWidget *parent=0)
virtual void saveProperties(KConfigGroup &group)
virtual void readProperties(const KConfigGroup &group)
~ManageInvitationsDialog()
QDateTime expirationTime() const
void removeInvitation(const Invitation &inv)
static int port()
Get This is the port on which krfb will listen.
void setPassword(const QString &passwd)
Invitation addInvitation()
static KrfbConfig * self()
void removeAllInvitations()
void setExpiration(const QDateTime &expire)
QDateTime creationTime() const