mirror of
https://github.com/KDE/krfb
synced 2026-07-01 07:31:16 -07:00
Remove telepathy tubes and contact list support.
This commit is contained in:
@@ -46,16 +46,6 @@ set(CMAKE_MODULE_PATH
|
||||
|
||||
find_package(LibVNCServer REQUIRED)
|
||||
|
||||
find_package(TelepathyQt5 0.9.3)
|
||||
set_package_properties(TelepathyQt5 PROPERTIES
|
||||
PURPOSE "Needed to build Telepathy Tubes support."
|
||||
URL "http://telepathy.freedesktop.org")
|
||||
|
||||
find_package(KTp)
|
||||
set_package_properties(KTp PROPERTIES
|
||||
PURPOSE "Needed to build KDE IM Contacts Display in KRFB."
|
||||
URL "https://projects.kde.org/projects/extragear/network/telepathy")
|
||||
|
||||
if (HAVE_XDAMAGE)
|
||||
set(X11_Xdamage_FOUND 1)
|
||||
else()
|
||||
|
||||
@@ -46,16 +46,6 @@ install (FILES
|
||||
# Second target: krfb - the app
|
||||
# itself.
|
||||
|
||||
if(TelepathyQt4_FOUND)
|
||||
add_definitions(-DKRFB_WITH_TELEPATHY_TUBES)
|
||||
include_directories(${TELEPATHY_QT4_INCLUDE_DIR})
|
||||
endif()
|
||||
|
||||
if(KTP_FOUND)
|
||||
add_definitions(-DKRFB_WITH_KDE_TELEPATHY)
|
||||
include_directories(${KTP_INCLUDE_DIR})
|
||||
endif()
|
||||
|
||||
set (krfb_SRCS
|
||||
connectiondialog.cpp
|
||||
events.cpp
|
||||
@@ -71,14 +61,6 @@ set (krfb_SRCS
|
||||
invitationsrfbclient.cpp
|
||||
)
|
||||
|
||||
if(TelepathyQt4_FOUND)
|
||||
set (krfb_SRCS
|
||||
${krfb_SRCS}
|
||||
tubesrfbserver.cpp
|
||||
tubesrfbclient.cpp
|
||||
)
|
||||
endif()
|
||||
|
||||
kconfig_add_kcfg_files (krfb_SRCS
|
||||
krfbconfig.kcfgc
|
||||
)
|
||||
@@ -90,10 +72,6 @@ ki18n_wrap_ui (krfb_SRCS
|
||||
ui/mainwidget.ui
|
||||
)
|
||||
|
||||
if(TelepathyQt4_FOUND)
|
||||
ki18n_wrap_ui(krfb_SRCS ui/tubesconnectionwidget.ui)
|
||||
endif()
|
||||
|
||||
add_executable (krfb
|
||||
${krfb_SRCS}
|
||||
)
|
||||
@@ -118,20 +96,6 @@ target_link_libraries (krfb
|
||||
${LIBVNCSERVER_LIBRARIES}
|
||||
)
|
||||
|
||||
if(TelepathyQt4_FOUND)
|
||||
target_link_libraries(krfb
|
||||
${TELEPATHY_QT4_LIBRARIES}
|
||||
)
|
||||
endif()
|
||||
|
||||
if(KTP_FOUND)
|
||||
target_link_libraries(krfb
|
||||
${KTP_LIBRARIES}
|
||||
${KTP_MODELS_LIBRARIES}
|
||||
${KTP_WIDGETS_LIBRARIES}
|
||||
)
|
||||
endif()
|
||||
|
||||
if (X11_XTest_FOUND)
|
||||
target_link_libraries (krfb
|
||||
${X11_XTest_LIB}
|
||||
@@ -142,15 +106,6 @@ install (TARGETS krfb
|
||||
${INSTALL_TARGETS_DEFAULT_ARGS}
|
||||
)
|
||||
|
||||
if(TelepathyQt4_FOUND)
|
||||
configure_file(org.freedesktop.Telepathy.Client.krfb_rfb_handler.service.in
|
||||
org.freedesktop.Telepathy.Client.krfb_rfb_handler.service)
|
||||
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/org.freedesktop.Telepathy.Client.krfb_rfb_handler.service
|
||||
DESTINATION ${DBUS_SERVICES_INSTALL_DIR})
|
||||
|
||||
install(FILES krfb_rfb_handler.client DESTINATION ${CMAKE_INSTALL_PREFIX}/share/telepathy/clients/)
|
||||
endif()
|
||||
|
||||
########### install files ###############
|
||||
|
||||
install (PROGRAMS org.kde.krfb.desktop
|
||||
|
||||
@@ -83,20 +83,4 @@ void InvitationsConnectionDialog::setRemoteHost(const QString &host)
|
||||
|
||||
//**********
|
||||
|
||||
#ifdef KRFB_WITH_TELEPATHY_TUBES
|
||||
|
||||
TubesConnectionDialog::TubesConnectionDialog(QWidget *parent)
|
||||
: ConnectionDialog<Ui::TubesConnectionWidget>(parent)
|
||||
{
|
||||
}
|
||||
|
||||
void TubesConnectionDialog::setContactName(const QString & name)
|
||||
{
|
||||
QString txt = i18n("You have requested to share your desktop with %1. If you proceed, "
|
||||
"you will allow the remote user to watch your desktop.", name);
|
||||
m_ui.mainTextLabel->setText(txt);
|
||||
}
|
||||
|
||||
#endif // KRFB_WITH_TELEPATHY_TUBES
|
||||
|
||||
#include "connectiondialog.moc"
|
||||
|
||||
@@ -65,18 +65,5 @@ public:
|
||||
|
||||
//*********
|
||||
|
||||
#ifdef KRFB_WITH_TELEPATHY_TUBES
|
||||
# include "ui_tubesconnectionwidget.h"
|
||||
|
||||
class TubesConnectionDialog : public ConnectionDialog<Ui::TubesConnectionWidget>
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
TubesConnectionDialog(QWidget *parent);
|
||||
void setContactName(const QString & name);
|
||||
};
|
||||
|
||||
#endif // KRFB_WITH_TELEPATHY_TUBES
|
||||
|
||||
#endif // CONNECTIONDIALOG_H
|
||||
|
||||
|
||||
@@ -29,10 +29,6 @@
|
||||
#include <qwindowdefs.h>
|
||||
#include <QX11Info>
|
||||
|
||||
#ifdef KRFB_WITH_TELEPATHY_TUBES
|
||||
# include "tubesrfbserver.h"
|
||||
#endif
|
||||
|
||||
#include <signal.h>
|
||||
#include <X11/extensions/XTest.h>
|
||||
#include <QCommandLineParser>
|
||||
@@ -112,10 +108,6 @@ int main(int argc, char *argv[])
|
||||
//init the core
|
||||
InvitationsRfbServer::init();
|
||||
|
||||
#ifdef KRFB_WITH_TELEPATHY_TUBES
|
||||
TubesRfbServer::init();
|
||||
#endif
|
||||
|
||||
//init the GUI
|
||||
MainWindow mainWindow;
|
||||
TrayIcon trayicon(&mainWindow);
|
||||
|
||||
@@ -27,16 +27,6 @@
|
||||
#include <QSizePolicy>
|
||||
#include <QtNetwork/QNetworkInterface>
|
||||
|
||||
#ifdef KRFB_WITH_KDE_TELEPATHY
|
||||
#include "tubesrfbserver.h"
|
||||
#include <TelepathyQt/PendingReady>
|
||||
#include <TelepathyQt/PendingChannelRequest>
|
||||
#include <KTp/actions.h>
|
||||
#include <KTp/Widgets/contact-view-widget.h>
|
||||
#include <KTp/Models/contacts-list-model.h>
|
||||
#include <KTp/Models/contacts-filter-model.h>
|
||||
#endif
|
||||
|
||||
class TCP: public QWidget, public Ui::TCP
|
||||
{
|
||||
public:
|
||||
@@ -105,31 +95,6 @@ MainWindow::MainWindow(QWidget *parent)
|
||||
m_ui.passwordDisplayLabel->setText(
|
||||
InvitationsRfbServer::instance->desktopPassword());
|
||||
|
||||
|
||||
#ifdef KRFB_WITH_KDE_TELEPATHY
|
||||
|
||||
m_contactViewWidget = new KTp::ContactViewWidget(
|
||||
TubesRfbServer::instance->contactsListModel(), this);
|
||||
|
||||
m_contactViewWidget->setEnabled(false);
|
||||
connect(m_ui.enableSharingCheckBox, SIGNAL(toggled(bool)),
|
||||
m_contactViewWidget, SLOT(setEnabled(bool)));
|
||||
m_contactViewWidget->setIconSize(QSize(32,32));
|
||||
m_contactViewWidget->setMinimumWidth(120);
|
||||
m_contactViewWidget->setMaximumWidth(360);
|
||||
m_contactViewWidget->setMinimumHeight(300);
|
||||
m_contactViewWidget->contactFilterLineEdit()->setClickMessage(i18n("Search in Contacts..."));
|
||||
m_contactViewWidget->filter()->setPresenceTypeFilterFlags(KTp::ContactsFilterModel::ShowOnlyConnected);
|
||||
m_contactViewWidget->filter()->setTubesFilterStrings(QStringList("rfb"));
|
||||
m_contactViewWidget->filter()->setCapabilityFilterFlags(KTp::ContactsFilterModel::FilterByTubes);
|
||||
|
||||
m_contactViewWidget->setSizePolicy(QSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::MinimumExpanding));
|
||||
m_ui.tpContactsLayout->addWidget(m_contactViewWidget);
|
||||
connect(m_contactViewWidget, SIGNAL(contactDoubleClicked(const Tp::AccountPtr &, const KTp::ContactPtr &)),
|
||||
this, SLOT(onContactDoubleClicked(const Tp::AccountPtr &, const KTp::ContactPtr &)));
|
||||
#endif
|
||||
|
||||
|
||||
KStandardAction::quit(QCoreApplication::instance(), SLOT(quit()), actionCollection());
|
||||
KStandardAction::preferences(this, SLOT(showConfiguration()), actionCollection());
|
||||
|
||||
@@ -212,25 +177,6 @@ void MainWindow::aboutUnattendedMode()
|
||||
i18n("KDE Desktop Sharing"));
|
||||
}
|
||||
|
||||
#ifdef KRFB_WITH_KDE_TELEPATHY
|
||||
|
||||
void MainWindow::onContactDoubleClicked(const Tp::AccountPtr &account, const KTp::ContactPtr &contact)
|
||||
{
|
||||
Tp::PendingOperation *op = KTp::Actions::startDesktopSharing(account, contact);
|
||||
connect(op, SIGNAL(finished(Tp::PendingOperation*)),
|
||||
this, SLOT(pendingDesktopShareFinished(Tp::PendingOperation*)));
|
||||
}
|
||||
|
||||
void MainWindow::pendingDesktopShareFinished(Tp::PendingOperation *operation)
|
||||
{
|
||||
if(operation->isError()) {
|
||||
KMessageBox::error(this,
|
||||
operation->errorName() + ": " + operation->errorMessage());
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
void MainWindow::showConfiguration()
|
||||
{
|
||||
if (KConfigDialog::showDialog("settings")) {
|
||||
|
||||
@@ -15,17 +15,6 @@
|
||||
|
||||
#include <KXmlGuiWindow>
|
||||
|
||||
#ifdef KRFB_WITH_KDE_TELEPATHY
|
||||
#include <KTp/contact.h>
|
||||
#include <TelepathyQt/PendingReady>
|
||||
namespace KTp {
|
||||
class ContactViewWidget;
|
||||
}
|
||||
namespace Tp {
|
||||
class PendingOperation;
|
||||
}
|
||||
#endif
|
||||
|
||||
class KLineEdit;
|
||||
|
||||
class MainWindow : public KXmlGuiWindow
|
||||
@@ -50,19 +39,11 @@ class MainWindow : public KXmlGuiWindow
|
||||
void passwordChanged(const QString&);
|
||||
void aboutConnectionAddress();
|
||||
void aboutUnattendedMode();
|
||||
#ifdef KRFB_WITH_KDE_TELEPATHY
|
||||
void onContactDoubleClicked(const Tp::AccountPtr &, const KTp::ContactPtr &);
|
||||
void pendingDesktopShareFinished(Tp::PendingOperation*);
|
||||
#endif
|
||||
|
||||
private:
|
||||
Ui::MainWidget m_ui;
|
||||
bool m_passwordEditable;
|
||||
KLineEdit *m_passwordLineEdit;
|
||||
#ifdef KRFB_WITH_KDE_TELEPATHY
|
||||
KTp::ContactViewWidget *m_contactViewWidget;
|
||||
#endif
|
||||
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
@@ -1,3 +0,0 @@
|
||||
[D-BUS Service]
|
||||
Name=org.freedesktop.Telepathy.Client.krfb_rfb_handler
|
||||
Exec=@CMAKE_INSTALL_PREFIX@/bin/krfb --nodialog
|
||||
@@ -1,88 +0,0 @@
|
||||
/*
|
||||
Copyright (C) 2009-2010 Collabora Ltd. <info@collabora.co.uk>
|
||||
@author George Goldberg <george.goldberg@collabora.co.uk>
|
||||
@author George Kiagiadakis <george.kiagiadakis@collabora.co.uk>
|
||||
|
||||
This program is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2 of the License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
#include "tubesrfbclient.h"
|
||||
#include "krfbconfig.h"
|
||||
#include "connectiondialog.h"
|
||||
#include <KNotification>
|
||||
#include <KLocalizedString>
|
||||
#include <KConfigGroup>
|
||||
|
||||
QString TubesRfbClient::name() const
|
||||
{
|
||||
return m_contact->alias();
|
||||
}
|
||||
|
||||
//********
|
||||
|
||||
PendingTubesRfbClient::PendingTubesRfbClient(rfbClientPtr client, QObject* parent) :
|
||||
PendingRfbClient(client, parent),
|
||||
m_processNewClientCalled(false)
|
||||
{
|
||||
processNewClient();
|
||||
}
|
||||
|
||||
void PendingTubesRfbClient::setContact(const Tp::ContactPtr & contact)
|
||||
{
|
||||
m_contact = contact;
|
||||
if (m_processNewClientCalled) {
|
||||
//processNewClient has already been called, so we need to act here
|
||||
showConfirmationDialog();
|
||||
}
|
||||
}
|
||||
|
||||
void PendingTubesRfbClient::processNewClient()
|
||||
{
|
||||
if (!m_contact) {
|
||||
//no associated contact yet, hold.
|
||||
m_processNewClientCalled = true; //act when a contact is set
|
||||
} else {
|
||||
//we have a contact, begin handling
|
||||
showConfirmationDialog();
|
||||
}
|
||||
}
|
||||
|
||||
void PendingTubesRfbClient::showConfirmationDialog()
|
||||
{
|
||||
QString name = m_contact->alias();
|
||||
|
||||
KNotification::event("NewConnectionOnHold",
|
||||
i18n("Received connection from %1, on hold (waiting for confirmation)",
|
||||
name));
|
||||
|
||||
TubesConnectionDialog *dialog = new TubesConnectionDialog(0);
|
||||
dialog->setContactName(name);
|
||||
dialog->setAllowRemoteControl(KrfbConfig::allowDesktopControl());
|
||||
|
||||
connect(dialog, SIGNAL(clicked()), SLOT(dialogAccepted()));
|
||||
connect(dialog, SIGNAL(clicked()), SLOT(reject()));
|
||||
|
||||
dialog->show();
|
||||
}
|
||||
|
||||
void PendingTubesRfbClient::dialogAccepted()
|
||||
{
|
||||
TubesConnectionDialog *dialog = qobject_cast<TubesConnectionDialog *>(sender());
|
||||
Q_ASSERT(dialog);
|
||||
|
||||
TubesRfbClient *client = new TubesRfbClient(m_rfbClient, m_contact, parent());
|
||||
client->setControlEnabled(dialog->allowRemoteControl());
|
||||
accept(client);
|
||||
}
|
||||
|
||||
#include "tubesrfbclient.moc"
|
||||
@@ -1,60 +0,0 @@
|
||||
/*
|
||||
Copyright (C) 2010 Collabora Ltd. <info@collabora.co.uk>
|
||||
@author George Kiagiadakis <george.kiagiadakis@collabora.co.uk>
|
||||
|
||||
This program is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2 of the License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
#ifndef TUBESRFBCLIENT_H
|
||||
#define TUBESRFBCLIENT_H
|
||||
|
||||
#include "rfbclient.h"
|
||||
#include <TelepathyQt/Contact>
|
||||
|
||||
class TubesRfbClient : public RfbClient
|
||||
{
|
||||
public:
|
||||
TubesRfbClient(rfbClientPtr client,
|
||||
const Tp::ContactPtr &contact, QObject *parent=0)
|
||||
: RfbClient(client, parent), m_contact(contact)
|
||||
{}
|
||||
|
||||
virtual QString name() const;
|
||||
|
||||
private:
|
||||
Tp::ContactPtr m_contact;
|
||||
};
|
||||
|
||||
//*********
|
||||
|
||||
class PendingTubesRfbClient : public PendingRfbClient
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
PendingTubesRfbClient(rfbClientPtr client, QObject* parent = 0);
|
||||
|
||||
void setContact(const Tp::ContactPtr & contact);
|
||||
|
||||
protected Q_SLOTS:
|
||||
virtual void processNewClient();
|
||||
|
||||
private Q_SLOTS:
|
||||
void showConfirmationDialog();
|
||||
void dialogAccepted();
|
||||
|
||||
private:
|
||||
Tp::ContactPtr m_contact;
|
||||
bool m_processNewClientCalled;
|
||||
};
|
||||
|
||||
#endif // TUBESRFBCLIENT_H
|
||||
@@ -1,262 +0,0 @@
|
||||
/*
|
||||
Copyright (C) 2009-2011 Collabora Ltd. <info@collabora.co.uk>
|
||||
@author George Goldberg <george.goldberg@collabora.co.uk>
|
||||
@author George Kiagiadakis <george.kiagiadakis@collabora.co.uk>
|
||||
|
||||
This program is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2 of the License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
#include "tubesrfbserver.h"
|
||||
#include "tubesrfbclient.h"
|
||||
#include "sockethelpers.h"
|
||||
|
||||
#include <QDebug>
|
||||
#include <KRandom>
|
||||
|
||||
#include <TelepathyQt/Debug>
|
||||
#include <TelepathyQt/Contact>
|
||||
#include <TelepathyQt/AccountFactory>
|
||||
#include <TelepathyQt/ConnectionFactory>
|
||||
#include <TelepathyQt/ContactFactory>
|
||||
#include <TelepathyQt/ChannelFactory>
|
||||
#include <TelepathyQt/OutgoingStreamTubeChannel>
|
||||
#include <TelepathyQt/StreamTubeServer>
|
||||
|
||||
#ifdef KRFB_WITH_KDE_TELEPATHY
|
||||
#include <TelepathyQt/AccountSet>
|
||||
#include <TelepathyQt/AccountManager>
|
||||
#include <TelepathyQt/PendingReady>
|
||||
#include <KTp/Models/contacts-list-model.h>
|
||||
#include <KTp/contact-factory.h>
|
||||
#endif
|
||||
|
||||
struct TubesRfbServer::Private
|
||||
{
|
||||
Tp::StreamTubeServerPtr stubeServer;
|
||||
QHash<quint16, Tp::ContactPtr> contactsPerPort;
|
||||
QHash<quint16, PendingTubesRfbClient*> clientsPerPort;
|
||||
};
|
||||
|
||||
//static
|
||||
TubesRfbServer *TubesRfbServer::instance;
|
||||
|
||||
//static
|
||||
void TubesRfbServer::init()
|
||||
{
|
||||
instance = new TubesRfbServer;
|
||||
//RfbServerManager takes care of deletion
|
||||
|
||||
instance->startAndCheck();
|
||||
}
|
||||
|
||||
TubesRfbServer::TubesRfbServer(QObject *parent)
|
||||
: RfbServer(parent), d(new Private)
|
||||
{
|
||||
//qDebug() << "starting";
|
||||
|
||||
Tp::enableDebug(true);
|
||||
Tp::enableWarnings(true);
|
||||
Tp::registerTypes();
|
||||
|
||||
Tp::AccountFactoryPtr accountFactory = Tp::AccountFactory::create(
|
||||
QDBusConnection::sessionBus(),
|
||||
Tp::Features() << Tp::Account::FeatureCore
|
||||
<< Tp::Account::FeatureAvatar
|
||||
<< Tp::Account::FeatureCapabilities
|
||||
<< Tp::Account::FeatureProtocolInfo
|
||||
<< Tp::Account::FeatureProfile);
|
||||
|
||||
Tp::ConnectionFactoryPtr connectionFactory = Tp::ConnectionFactory::create(
|
||||
QDBusConnection::sessionBus(),
|
||||
Tp::Features() << Tp::Connection::FeatureCore
|
||||
<< Tp::Connection::FeatureSelfContact);
|
||||
|
||||
Tp::ChannelFactoryPtr channelFactory = Tp::ChannelFactory::create(
|
||||
QDBusConnection::sessionBus());
|
||||
|
||||
#ifdef KRFB_WITH_KDE_TELEPATHY
|
||||
Tp::ContactFactoryPtr contactFactory = KTp::ContactFactory::create(
|
||||
Tp::Features() << Tp::Contact::FeatureAlias
|
||||
<<Tp::Contact::FeatureAvatarToken
|
||||
<<Tp::Contact::FeatureAvatarData
|
||||
<<Tp::Contact::FeatureSimplePresence
|
||||
<<Tp::Contact::FeatureCapabilities
|
||||
<<Tp::Contact::FeatureClientTypes);
|
||||
|
||||
m_accountManager = Tp::AccountManager::create(
|
||||
QDBusConnection::sessionBus(),
|
||||
accountFactory,
|
||||
connectionFactory,
|
||||
channelFactory,
|
||||
contactFactory);
|
||||
|
||||
d->stubeServer = Tp::StreamTubeServer::create(
|
||||
m_accountManager,
|
||||
QStringList() << QLatin1String("rfb"),
|
||||
QStringList(),
|
||||
QLatin1String("krfb_rfb_handler"),
|
||||
true);
|
||||
|
||||
connect(m_accountManager->becomeReady(),
|
||||
SIGNAL(finished(Tp::PendingOperation*)),
|
||||
this,
|
||||
SLOT(onAccountManagerReady()));
|
||||
|
||||
m_contactsListModel = new KTp::ContactsListModel(this);
|
||||
#else
|
||||
Tp::ContactFactoryPtr contactFactory = Tp::ContactFactory::create(
|
||||
Tp::Contact::FeatureAlias);
|
||||
|
||||
d->stubeServer = Tp::StreamTubeServer::create(
|
||||
QStringList() << QLatin1String("rfb"),
|
||||
QStringList(),
|
||||
QLatin1String("krfb_rfb_handler"),
|
||||
true,
|
||||
accountFactory,
|
||||
connectionFactory,
|
||||
channelFactory,
|
||||
contactFactory);
|
||||
#endif //KRFB_WITH_KDE_TELEPATHY
|
||||
|
||||
connect(d->stubeServer.data(),
|
||||
SIGNAL(tubeRequested(Tp::AccountPtr,Tp::OutgoingStreamTubeChannelPtr,
|
||||
QDateTime,Tp::ChannelRequestHints)),
|
||||
SLOT(onTubeRequested()));
|
||||
connect(d->stubeServer.data(),
|
||||
SIGNAL(tubeClosed(Tp::AccountPtr,Tp::OutgoingStreamTubeChannelPtr,QString,QString)),
|
||||
SLOT(onTubeClosed()));
|
||||
|
||||
connect(d->stubeServer.data(),
|
||||
SIGNAL(newTcpConnection(QHostAddress,quint16,Tp::AccountPtr,
|
||||
Tp::ContactPtr,Tp::OutgoingStreamTubeChannelPtr)),
|
||||
SLOT(onNewTcpConnection(QHostAddress,quint16,Tp::AccountPtr,
|
||||
Tp::ContactPtr,Tp::OutgoingStreamTubeChannelPtr)));
|
||||
connect(d->stubeServer.data(),
|
||||
SIGNAL(tcpConnectionClosed(QHostAddress,quint16,Tp::AccountPtr,Tp::ContactPtr,
|
||||
QString,QString,Tp::OutgoingStreamTubeChannelPtr)),
|
||||
SLOT(onTcpConnectionClosed(QHostAddress,quint16,Tp::AccountPtr,Tp::ContactPtr,
|
||||
QString,QString,Tp::OutgoingStreamTubeChannelPtr)));
|
||||
|
||||
// Pick a random port in the private range (49152–65535)
|
||||
setListeningPort((KRandom::random() % 16383) + 49152);
|
||||
// Listen only on the loopback network interface
|
||||
setListeningAddress("127.0.0.1");
|
||||
setPasswordRequired(false);
|
||||
}
|
||||
|
||||
TubesRfbServer::~TubesRfbServer()
|
||||
{
|
||||
//qDebug();
|
||||
stop();
|
||||
delete d;
|
||||
}
|
||||
|
||||
#ifdef KRFB_WITH_KDE_TELEPATHY
|
||||
KTp::ContactsListModel *TubesRfbServer::contactsListModel()
|
||||
{
|
||||
return m_contactsListModel;
|
||||
}
|
||||
#endif
|
||||
|
||||
void TubesRfbServer::startAndCheck()
|
||||
{
|
||||
if (!start()) {
|
||||
//try a few times with different ports
|
||||
bool ok = false;
|
||||
for (int i=0; !ok && i<5; i++) {
|
||||
setListeningPort((KRandom::random() % 16383) + 49152);
|
||||
ok = start();
|
||||
}
|
||||
|
||||
if (!ok) {
|
||||
qCritical() << "Failed to start tubes rfb server";
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
//TODO listeningAddress() should be a QHostAddress
|
||||
d->stubeServer->exportTcpSocket(QHostAddress(QString::fromAscii(listeningAddress())),
|
||||
listeningPort());
|
||||
}
|
||||
|
||||
void TubesRfbServer::onTubeRequested()
|
||||
{
|
||||
//qDebug() << "Got a tube";
|
||||
}
|
||||
|
||||
void TubesRfbServer::onTubeClosed()
|
||||
{
|
||||
//qDebug() << "tube closed";
|
||||
}
|
||||
|
||||
void TubesRfbServer::onNewTcpConnection(const QHostAddress & sourceAddress,
|
||||
quint16 sourcePort,
|
||||
const Tp::AccountPtr & account,
|
||||
const Tp::ContactPtr & contact,
|
||||
const Tp::OutgoingStreamTubeChannelPtr & tube)
|
||||
{
|
||||
Q_UNUSED(account);
|
||||
Q_UNUSED(tube);
|
||||
|
||||
//qDebug() << "CM signaled tube connection from" << sourceAddress << ":" << sourcePort;
|
||||
|
||||
d->contactsPerPort[sourcePort] = contact;
|
||||
if (d->clientsPerPort.contains(sourcePort)) {
|
||||
//qDebug() << "client already exists";
|
||||
d->clientsPerPort[sourcePort]->setContact(contact);
|
||||
}
|
||||
}
|
||||
|
||||
void TubesRfbServer::onTcpConnectionClosed(const QHostAddress& sourceAddress,
|
||||
quint16 sourcePort,
|
||||
const Tp::AccountPtr& account,
|
||||
const Tp::ContactPtr& contact,
|
||||
const QString& error,
|
||||
const QString& message,
|
||||
const Tp::OutgoingStreamTubeChannelPtr& tube)
|
||||
{
|
||||
Q_UNUSED(account);
|
||||
Q_UNUSED(contact);
|
||||
Q_UNUSED(tube);
|
||||
|
||||
//qDebug() << "Connection from" << sourceAddress << ":" << sourcePort << "closed."
|
||||
<< error << message;
|
||||
|
||||
d->clientsPerPort.remove(sourcePort);
|
||||
d->contactsPerPort.remove(sourcePort);
|
||||
}
|
||||
|
||||
PendingRfbClient* TubesRfbServer::newClient(rfbClientPtr client)
|
||||
{
|
||||
PendingTubesRfbClient *c = new PendingTubesRfbClient(client, this);
|
||||
quint16 port = peerPort(client->sock);
|
||||
|
||||
//qDebug() << "new tube client on port" << port;
|
||||
|
||||
d->clientsPerPort[port] = c;
|
||||
if (d->contactsPerPort.contains(port)) {
|
||||
//qDebug() << "already have a contact";
|
||||
c->setContact(d->contactsPerPort[port]);
|
||||
}
|
||||
|
||||
return c;
|
||||
}
|
||||
|
||||
#ifdef KRFB_WITH_KDE_TELEPATHY
|
||||
void TubesRfbServer::onAccountManagerReady()
|
||||
{
|
||||
m_contactsListModel->setAccountManager(m_accountManager);
|
||||
}
|
||||
#endif
|
||||
|
||||
#include "tubesrfbserver.moc"
|
||||
@@ -1,86 +0,0 @@
|
||||
/*
|
||||
Copyright (C) 2009-2011 Collabora Ltd. <info@collabora.co.uk>
|
||||
@author George Goldberg <george.goldberg@collabora.co.uk>
|
||||
@author George Kiagiadakis <george.kiagiadakis@collabora.co.uk>
|
||||
|
||||
This program is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2 of the License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
#ifndef TUBESRFBSERVER_H
|
||||
#define TUBESRFBSERVER_H
|
||||
|
||||
#include "rfbserver.h"
|
||||
#include <QtNetwork/QHostAddress>
|
||||
#include <TelepathyQt/Types>
|
||||
|
||||
#ifdef KRFB_WITH_KDE_TELEPATHY
|
||||
namespace KTp {
|
||||
class ContactsListModel;
|
||||
}
|
||||
#endif
|
||||
|
||||
class TubesRfbServer : public RfbServer
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
static TubesRfbServer *instance;
|
||||
static void init();
|
||||
|
||||
virtual ~TubesRfbServer();
|
||||
#ifdef KRFB_WITH_KDE_TELEPATHY
|
||||
KTp::ContactsListModel *contactsListModel();
|
||||
#endif
|
||||
|
||||
protected:
|
||||
TubesRfbServer(QObject *parent = 0);
|
||||
|
||||
virtual PendingRfbClient* newClient(rfbClientPtr client);
|
||||
|
||||
private Q_SLOTS:
|
||||
void startAndCheck();
|
||||
|
||||
void onTubeRequested();
|
||||
void onTubeClosed();
|
||||
|
||||
void onNewTcpConnection(
|
||||
const QHostAddress &sourceAddress,
|
||||
quint16 sourcePort,
|
||||
const Tp::AccountPtr &account,
|
||||
const Tp::ContactPtr &contact,
|
||||
const Tp::OutgoingStreamTubeChannelPtr &tube);
|
||||
|
||||
void onTcpConnectionClosed(
|
||||
const QHostAddress &sourceAddress,
|
||||
quint16 sourcePort,
|
||||
const Tp::AccountPtr &account,
|
||||
const Tp::ContactPtr &contact,
|
||||
const QString &error,
|
||||
const QString &message,
|
||||
const Tp::OutgoingStreamTubeChannelPtr &tube);
|
||||
|
||||
#ifdef KRFB_WITH_KDE_TELEPATHY
|
||||
void onAccountManagerReady();
|
||||
#endif
|
||||
|
||||
private:
|
||||
struct Private;
|
||||
Private *const d;
|
||||
|
||||
#ifdef KRFB_WITH_KDE_TELEPATHY
|
||||
KTp::ContactsListModel *m_contactsListModel;
|
||||
Tp::AccountManagerPtr m_accountManager;
|
||||
#endif
|
||||
|
||||
};
|
||||
|
||||
#endif // TUBESRFBSERVER_H
|
||||
@@ -1,114 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>TubesConnectionWidget</class>
|
||||
<widget class="QWidget" name="TubesConnectionWidget">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>500</width>
|
||||
<height>162</height>
|
||||
</rect>
|
||||
</property>
|
||||
<layout class="QHBoxLayout">
|
||||
<item>
|
||||
<widget class="QLabel" name="pixmapLabel">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>128</width>
|
||||
<height>128</height>
|
||||
</size>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QVBoxLayout">
|
||||
<item>
|
||||
<widget class="QLabel" name="TextLabel5">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Minimum" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="font">
|
||||
<font>
|
||||
<pointsize>13</pointsize>
|
||||
<weight>75</weight>
|
||||
<bold>true</bold>
|
||||
</font>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Confirmation</string>
|
||||
</property>
|
||||
<property name="wordWrap">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="indent">
|
||||
<number>0</number>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLabel" name="mainTextLabel">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="lineWidth">
|
||||
<number>-1</number>
|
||||
</property>
|
||||
<property name="midLineWidth">
|
||||
<number>5</number>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string/>
|
||||
</property>
|
||||
<property name="textFormat">
|
||||
<enum>Qt::AutoText</enum>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter</set>
|
||||
</property>
|
||||
<property name="wordWrap">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="margin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="indent">
|
||||
<number>0</number>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QCheckBox" name="cbAllowRemoteControl">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Minimum" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="whatsThis">
|
||||
<string>If you turn this option on, the remote user can enter keystrokes and use your mouse pointer. This gives them full control over your computer, so be careful. When the option is disabled the remote user can only watch your screen.</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Allow remote user to &control keyboard and mouse</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<resources/>
|
||||
<connections/>
|
||||
</ui>
|
||||
Reference in New Issue
Block a user