mirror of
https://github.com/KDE/krfb
synced 2026-07-01 15:31:19 -07:00
- email invitation now working
- determine the peer address when we get a new connection - use the configured port from kconfig insteand of the fixed :5900 value in personal invitation dialog svn path=/trunk/KDE/kdenetwork/krfb/; revision=662656
This commit is contained in:
@@ -32,6 +32,30 @@
|
||||
#include "krfbconfig.h"
|
||||
|
||||
#include <X11/Xutil.h>
|
||||
#include <sys/socket.h>
|
||||
#include <netinet/in.h>
|
||||
#include <arpa/inet.h>
|
||||
|
||||
|
||||
static QString peerAddress(int sock) {
|
||||
|
||||
const int ADDR_SIZE = 50;
|
||||
struct sockaddr sa;
|
||||
socklen_t salen = sizeof(struct sockaddr);
|
||||
if (getpeername(sock, &sa, &salen) == 0) {
|
||||
if (sa.sa_family == AF_INET) {
|
||||
struct sockaddr_in *si = (struct sockaddr_in *)&sa;
|
||||
return QString(inet_ntoa(si->sin_addr));
|
||||
}
|
||||
if (sa.sa_family == AF_INET6) {
|
||||
char inetbuf[ADDR_SIZE];
|
||||
inet_ntop(sa.sa_family, &sa, inetbuf, ADDR_SIZE);
|
||||
return QString(inetbuf);
|
||||
}
|
||||
return QString("not a network address");
|
||||
}
|
||||
return QString("unable to determine...");
|
||||
}
|
||||
|
||||
static void clientGoneHook(rfbClientPtr cl)
|
||||
{
|
||||
@@ -78,14 +102,7 @@ enum rfbNewClientAction ConnectionController::handleNewClient()
|
||||
bool askOnConnect = KrfbConfig::askOnConnect();
|
||||
bool allowUninvited = KrfbConfig::allowUninvitedConnections();
|
||||
|
||||
|
||||
#if 0
|
||||
int socket = cl->sock;
|
||||
// TODO: this drops the connection >.<
|
||||
QTcpSocket t;
|
||||
t.setSocketDescriptor(socket); //, QAbstractSocket::ConnectedState, QIODevice::NotOpen);
|
||||
remoteIp = t.peerAddress().toString();
|
||||
#endif
|
||||
remoteIp = peerAddress(cl->sock);
|
||||
|
||||
if (!allowUninvited && InvitationManager::self()->activeInvitations() == 0) {
|
||||
KNotification::event("ConnectionAttempted",
|
||||
@@ -107,7 +124,6 @@ enum rfbNewClientAction ConnectionController::handleNewClient()
|
||||
i18n("Received connection from %1, on hold (waiting for confirmation)",
|
||||
remoteIp));
|
||||
|
||||
//cl->screen->authPasswdData = (void *)1;
|
||||
cl->clientGoneHook = clientGoneHook;
|
||||
|
||||
ConnectionDialog *dialog = new ConnectionDialog(0);
|
||||
|
||||
@@ -19,6 +19,8 @@
|
||||
#include <QToolTip>
|
||||
#include <QCursor>
|
||||
#include <QDateTime>
|
||||
#include <QNetworkInterface>
|
||||
|
||||
|
||||
#include <KStandardDirs>
|
||||
#include <KStandardGuiItem>
|
||||
@@ -27,6 +29,7 @@
|
||||
#include <KGlobal>
|
||||
#include <KConfigDialog>
|
||||
#include <KMessageBox>
|
||||
#include <KToolInvocation>
|
||||
|
||||
// settings dialog
|
||||
#include "ui_configtcp.h"
|
||||
@@ -111,6 +114,48 @@ void ManageInvitationsDialog::inviteManually()
|
||||
|
||||
void ManageInvitationsDialog::inviteByMail()
|
||||
{
|
||||
int r = KMessageBox::warningContinueCancel(this,
|
||||
i18n("When sending an invitation by email, note that everybody who reads this email "
|
||||
"will be able to connect to your computer for one hour, or until the first "
|
||||
"successful connection took place, whichever comes first. \n"
|
||||
"You should either encrypt the email or at least send it only in a "
|
||||
"secure network, but not over the Internet."),
|
||||
i18n("Send Invitation via Email"),
|
||||
KStandardGuiItem::cont(),
|
||||
KStandardGuiItem::cancel(),
|
||||
"showEmailInvitationWarning");
|
||||
if (r == KMessageBox::Cancel)
|
||||
return;
|
||||
|
||||
QList<QNetworkInterface> ifl = QNetworkInterface::allInterfaces();
|
||||
QString host;
|
||||
int port = KrfbConfig::port();
|
||||
foreach (QNetworkInterface nif, ifl) {
|
||||
if (nif.flags() & QNetworkInterface::IsLoopBack) continue;
|
||||
if (nif.flags() & QNetworkInterface::IsRunning) {
|
||||
host = nif.addressEntries()[0].ip().toString();
|
||||
}
|
||||
}
|
||||
|
||||
Invitation inv = InvitationManager::self()->addInvitation();
|
||||
KToolInvocation::invokeMailer(QString::null, QString::null, QString::null,
|
||||
i18n("Desktop Sharing (VNC) invitation"),
|
||||
ki18n("You have been invited to a VNC session. If you have the KDE Remote "
|
||||
"Desktop Connection installed, just click on the link below.\n\n"
|
||||
"vnc://invitation:%1@%2:%3\n\n"
|
||||
"Otherwise you can use any VNC client with the following parameters:\n\n"
|
||||
"Host: %4:%5\n"
|
||||
"Password: %6\n\n"
|
||||
"For security reasons this invitation will expire at %7.")
|
||||
.subs(inv.password())
|
||||
.subs(host)
|
||||
.subs(port)
|
||||
.subs(host)
|
||||
.subs(port)
|
||||
.subs(inv.password())
|
||||
.subs(KGlobal::locale()->formatDateTime(inv.expirationTime()))
|
||||
.toString());
|
||||
|
||||
}
|
||||
|
||||
void ManageInvitationsDialog::reloadInvitations()
|
||||
|
||||
@@ -22,13 +22,13 @@
|
||||
|
||||
#include <QtGui/QLabel>
|
||||
#include <QtGui/QToolTip>
|
||||
#include <QNetworkInterface>
|
||||
|
||||
#include <kiconloader.h>
|
||||
#include <klocale.h>
|
||||
#include <KStandardDirs>
|
||||
|
||||
|
||||
#include <QNetworkInterface>
|
||||
#include "krfbconfig.h"
|
||||
|
||||
PersonalInviteDialog::PersonalInviteDialog( QWidget *parent )
|
||||
: KDialog( parent )
|
||||
@@ -38,6 +38,8 @@ PersonalInviteDialog::PersonalInviteDialog( QWidget *parent )
|
||||
setDefaultButton(Close);
|
||||
setModal(true);
|
||||
|
||||
int port = KrfbConfig::port();
|
||||
|
||||
m_inviteWidget = new QWidget ( this );
|
||||
setupUi(m_inviteWidget);
|
||||
pixmapLabel->setPixmap(KStandardDirs::locate("data", "krfb/pics/connection-side-image.png"));
|
||||
@@ -47,7 +49,7 @@ PersonalInviteDialog::PersonalInviteDialog( QWidget *parent )
|
||||
foreach (QNetworkInterface nif, ifl) {
|
||||
if (nif.flags() & QNetworkInterface::IsLoopBack) continue;
|
||||
if (nif.flags() & QNetworkInterface::IsRunning) {
|
||||
hostLabel->setText( QString( "%1:5900" ).arg(nif.addressEntries()[0].ip().toString()));
|
||||
hostLabel->setText( QString( "%1:%2" ).arg(nif.addressEntries()[0].ip().toString()).arg(port));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user