Commit 6d5e2bc3 authored by Jeremy Whiting's avatar Jeremy Whiting
Browse files

Remove telepathy tubes and contact list support.

parent 10176b9e
......@@ -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
[D-BUS Service]
Name=org.freedesktop.Telepathy.Client.krfb_rfb_handler
Exec=@CMAKE_INSTALL_PREFIX@/bin/krfb --nodialog
/*
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"
/*
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
/*
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,