summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGeorge Goldberg <george.goldberg@collabora.co.uk>2009-09-21 15:39:06 (GMT)
committerGeorge Goldberg <george.goldberg@collabora.co.uk>2009-09-21 15:39:06 (GMT)
commit613e8249fb3748cc8439cedbe281c68d59905b7d (patch)
treef9ede391fd691a7511b3ad625b36bb5518ab5eda
downloadpackage-kopete-plugin-sharemydesktop-613e8249fb3748cc8439cedbe281c68d59905b7d.tar.gz
package-kopete-plugin-sharemydesktop-613e8249fb3748cc8439cedbe281c68d59905b7d.tar.xz
Initial debian packaging for svn snapshot r1026361.debian
-rw-r--r--CMakeLists.txt33
-rw-r--r--cmake/modules/FindKCMTelepathyAccounts.cmake26
-rw-r--r--cmake/modules/FindTelepathyQt4.cmake39
-rw-r--r--debian/changelog6
-rw-r--r--debian/compat1
-rw-r--r--debian/control16
-rw-r--r--debian/copyright67
-rwxr-xr-xdebian/rules4
-rw-r--r--plugins/CMakeLists.txt14
-rw-r--r--plugins/sharemydesktop/CMakeLists.txt41
-rw-r--r--plugins/sharemydesktop/kopete_sharemydesktop.desktop26
-rw-r--r--plugins/sharemydesktop/share-my-desktop-chat-ui.rc6
-rw-r--r--plugins/sharemydesktop/share-my-desktop-gui-client.cpp209
-rw-r--r--plugins/sharemydesktop/share-my-desktop-gui-client.h59
-rw-r--r--plugins/sharemydesktop/share-my-desktop-plugin.cpp87
-rw-r--r--plugins/sharemydesktop/share-my-desktop-plugin.h45
16 files changed, 679 insertions, 0 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
new file mode 100644
index 0000000..23d68d2
--- /dev/null
+++ b/CMakeLists.txt
@@ -0,0 +1,33 @@
+project(playground-kopete)
+
+set(CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake/modules" ${CMAKE_MODULE_PATH})
+
+# search packages used by KDE
+find_package(KDE4 REQUIRED)
+find_package(Kopete REQUIRED)
+find_package(TelepathyQt4)
+find_package(KCMTelepathyAccounts)
+
+include (KDE4Defaults)
+include (MacroLibrary)
+include(MacroOptionalAddSubdirectory)
+
+add_definitions (${QT_DEFINITIONS} ${KDE4_DEFINITIONS})
+include_directories (${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_BINARY_DIR} ${KDE4_INCLUDES} ${KOPETE_INCLUDE_DIR}/kopete )
+
+# needed for the share-my-desktop plugin to link against the KopeteTelepathy library.
+include_directories (${CMAKE_CURRENT_SOURCE_DIR}/protocols/telepathy)
+
+macro_optional_find_package(TelepathyQt4)
+macro_log_feature(TELEPATHY_QT4_FOUND "telepathy-qt4" "Telepathy Qt Bindings" "https://telepathy.freedesktop.org" FALSE "0.18" "Needed to build Telepathy protocol plugin.")
+
+macro_optional_find_package(TelepathyQt4)
+macro_log_feature(KCMTELEPATHYACCOUNTS_FOUND "libkcmtelepathyaccounts" "Library for writing plugins for the Telepathy Accounts KCM" "http://websvn.kde.org/trunk/playground/network/telepathy-accounts-kcm" FALSE "0.0.1" "Needed to build Telepathy protocol plugin.")
+
+macro_optional_add_subdirectory(plugins)
+#macro_optional_add_subdirectory(protocols)
+
+if(CMAKE_SOURCE_DIR STREQUAL "${CMAKE_CURRENT_SOURCE_DIR}")
+ macro_display_feature_log()
+endif(CMAKE_SOURCE_DIR STREQUAL "${CMAKE_CURRENT_SOURCE_DIR}")
+
diff --git a/cmake/modules/FindKCMTelepathyAccounts.cmake b/cmake/modules/FindKCMTelepathyAccounts.cmake
new file mode 100644
index 0000000..4624957
--- /dev/null
+++ b/cmake/modules/FindKCMTelepathyAccounts.cmake
@@ -0,0 +1,26 @@
+# Try to find the KCM Telepathy Accounts library
+# KCMTELEPATHYACCOUNTS_FOUND - system has libkcmtelepathyaccounts
+# KCMTELEPATHYACCOUNTS_INCLUDE_DIR - the kcmtelepathyaccounts include directory
+# KCMTELEPATHYACCOUNTS_LIBRARIES - Link these to use libkcmtelepathyaccounts
+
+# Copyright (c) 2008, Allen Winter <winter@kde.org>
+#
+# Redistribution and use is allowed according to the terms of the BSD license.
+# For details see the accompanying COPYING-CMAKE-SCRIPTS file.
+
+SET (KCMTELEPATHYACCOUNTS_FIND_REQUIRED ${KCMTelepathyAccounts_FIND_REQUIRED})
+if (KCMTELEPATHYACCOUNTS_INCLUDE_DIR AND KCMTELEPATHYACCOUNTS_LIBRARIES)
+ # Already in cache, be silent
+ set(KCMTELEPATHYACCOUNTS_FIND_QUIETLY TRUE)
+endif (KCMTELEPATHYACCOUNTS_INCLUDE_DIR AND KCMTELEPATHYACCOUNTS_LIBRARIES)
+
+find_path(KCMTELEPATHYACCOUNTS_INCLUDE_DIR
+ NAMES KCMTelepathyAccounts/AbstractAccountUi KCMTelepathyAccounts/abstract-account-parameters-widget.h)
+find_library(KCMTELEPATHYACCOUNTS_LIBRARIES NAMES kcmtelepathyaccounts )
+
+include(FindPackageHandleStandardArgs)
+FIND_PACKAGE_HANDLE_STANDARD_ARGS(KCMTELEPATHYACCOUNTS DEFAULT_MSG
+ KCMTELEPATHYACCOUNTS_LIBRARIES KCMTELEPATHYACCOUNTS_INCLUDE_DIR)
+
+
+mark_as_advanced(KCMTELEPATHYACCOUNTS_INCLUDE_DIR KCMTELEPATHYACCOUNTS_LIBRARIES)
diff --git a/cmake/modules/FindTelepathyQt4.cmake b/cmake/modules/FindTelepathyQt4.cmake
new file mode 100644
index 0000000..33381a9
--- /dev/null
+++ b/cmake/modules/FindTelepathyQt4.cmake
@@ -0,0 +1,39 @@
+# Try to find the Qt4 binding of the Telepathy library
+# TELEPATHY_QT4_FOUND - system has TelepathyQt4
+# TELEPATHY_QT4_INCLUDE_DIR - the TelepathyQt4 include directory
+# TELEPATHY_QT4_LIBRARIES - Link these to use TelepathyQt4
+
+# Copyright (c) 2008, Allen Winter <winter@kde.org>
+# Copyright (c) 2009, Andre Moreira Magalhaes <andrunko@gmail.com>
+#
+# Redistribution and use is allowed according to the terms of the BSD license.
+# For details see the accompanying COPYING-CMAKE-SCRIPTS file.
+
+set(TELEPATHY_QT4_FIND_REQUIRED ${TelepathyQt4_FIND_REQUIRED})
+if(TELEPATHY_QT4_INCLUDE_DIR AND TELEPATHY_QT4_LIBRARIES)
+ # Already in cache, be silent
+ set(TELEPATHY_QT4_FIND_QUIETLY TRUE)
+endif(TELEPATHY_QT4_INCLUDE_DIR AND TELEPATHY_QT4_LIBRARIES)
+
+find_package(PkgConfig)
+if(PKG_CONFIG_FOUND)
+ pkg_check_modules(PC_TELEPATHY_QT4 QUIET TelepathyQt4>=0.1.8)
+endif(PKG_CONFIG_FOUND)
+
+find_path(TELEPATHY_QT4_INCLUDE_DIR
+ NAMES TelepathyQt4/Types
+ HINTS
+ ${PC_TELEPATHY_QT4_INCLUDEDIR}
+ ${PC_TELEPATHY_QT4_INCLUDE_DIRS}
+)
+
+find_library(TELEPATHY_QT4_LIBRARIES
+ NAMES telepathy-qt4
+ HINTS
+ ${PC_TELEPATHY_QT4_LIBDIR}
+ ${PC_TELEPATHY_QT4_LIBRARY_DIRS}
+)
+
+include(FindPackageHandleStandardArgs)
+find_package_handle_standard_args(TELEPATHY_QT4 DEFAULT_MSG
+ TELEPATHY_QT4_LIBRARIES TELEPATHY_QT4_INCLUDE_DIR)
diff --git a/debian/changelog b/debian/changelog
new file mode 100644
index 0000000..fc58930
--- /dev/null
+++ b/debian/changelog
@@ -0,0 +1,6 @@
+kopete-plugin-sharemydesktop (0:0.1.0.1026361-1) experimental; urgency=low
+
+ * Initial release based on upstream svn snapshot r1026361
+
+ -- George Goldberg <george.goldberg@collabora.co.uk> Mon, 21 Sep 2009 16:33:53 +0100
+
diff --git a/debian/compat b/debian/compat
new file mode 100644
index 0000000..7f8f011
--- /dev/null
+++ b/debian/compat
@@ -0,0 +1 @@
+7
diff --git a/debian/control b/debian/control
new file mode 100644
index 0000000..4305fa2
--- /dev/null
+++ b/debian/control
@@ -0,0 +1,16 @@
+Source: kopete-plugin-sharemydesktop
+Section: net
+Priority: optional
+Maintainer: George Goldberg <george.goldberg@collabora.co.uk>
+Uploaders: George Goldberg <george.goldberg@collabora.co.uk>
+Build-Depends: cdbs (>= 0.4.51), debhelper (>= 7), pkg-kde-tools (>= 0.4.2),
+ libkopete-dev (>=4.2.96), libkopetetelepathy-dev (= 0.1.0.1026277-1)
+Standards-Version: 3.8.2
+Homepage: http://www.kde.org/
+
+Package: kopete-plugin-sharemydesktop
+Section: net
+Architecture: any
+Depends: ${shlibs:Depends}, ${misc:Depends}, libkopete4 (>= 4.2.96),
+ libkopetetelepathy4 (=0.1.0.1026277-1)
+Description: Kopete plugin to allow sharing your desktop over Telepathy \ No newline at end of file
diff --git a/debian/copyright b/debian/copyright
new file mode 100644
index 0000000..c8e2095
--- /dev/null
+++ b/debian/copyright
@@ -0,0 +1,67 @@
+This package was debianized by George Goldberg <george.goldberg@collabora.co.uk> on
+Mon, 21 Sep 2009 16:37:29 +0100.
+
+It was downloaded from http://www.kde.org/download
+
+Upstream Author: The KDE development team <kde-core-devel@kde.org>
+Numerous people, too many to count, have contributed to KDE as a
+whole. The KDE project tries to make an extensive list of people who contributed
+to KDE at http://www.kde.org/people/credits/
+
+Copyright:
+Unless something else is mentioned, copyright is
+© 2009 Collabora Ltd. <http://www.collabora.co.uk/>
+
+License:
+Unless something else is mentioned, the code files in this package are under
+the GNU Lesser General Public License:
+
+ | This program is free software; you can redistribute it and/or modify
+ | it under the terms of the GNU Lesser General Public License as published
+ | by the Free Software Foundation; either version 2.1 of the License, or
+ | (at your option) any later version.
+ |
+ | This package 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 Lesser 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, write to the Free Software Foundation,
+ | Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+
+ The full text of the GNU Lesser General Public License version 2.1 is available on
+ Debian systems in /usr/share/common-licenses/LGPL-2.1.
+
+ Files under cmake/
+ Copyright: © 2008, Allen Winter <winter@kde.org>
+ Copyright: © 2009, Andre Moreira Magalhaes <andrunko@gmail.com>
+
+ These files are under this license:
+
+ | Redistribution and use in source and binary forms, with or without
+ | modification, are permitted provided that the following conditions
+ | are met:
+ |
+ | 1. Redistributions of source code must retain the copyright
+ | notice, this list of conditions and the following disclaimer.
+ | 2. Redistributions in binary form must reproduce the copyright
+ | notice, this list of conditions and the following disclaimer in the
+ | documentation and/or other materials provided with the distribution.
+ | 3. The name of the author may not be used to endorse or promote products
+ | derived from this software without specific prior written permission.
+ |
+ | THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ | IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ | OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ | IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ | INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ | NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ | DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ | THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ | THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+The Debian packaging is (C) 2009, Collabora Ltd and
+is licensed under the LGPL v2.1 or later, see `/usr/share/common-licenses/LGPL-2.1'.
+
diff --git a/debian/rules b/debian/rules
new file mode 100755
index 0000000..22a8107
--- /dev/null
+++ b/debian/rules
@@ -0,0 +1,4 @@
+#!/usr/bin/make -f
+
+include /usr/share/pkg-kde-tools/makefiles/1/debhelper/kde.mk
+
diff --git a/plugins/CMakeLists.txt b/plugins/CMakeLists.txt
new file mode 100644
index 0000000..9efa6db
--- /dev/null
+++ b/plugins/CMakeLists.txt
@@ -0,0 +1,14 @@
+include(MacroOptionalAddSubdirectory)
+
+#macro_optional_add_subdirectory(javascript)
+#macro_optional_add_subdirectory(motionautoaway)
+#macro_optional_add_subdirectory(smpppdcs)
+
+# the above do not compile
+
+# macro_optional_add_subdirectory(thinklight-kde4)
+
+if(TELEPATHY_QT4_FOUND)
+ macro_optional_add_subdirectory(sharemydesktop)
+endif(TELEPATHY_QT4_FOUND)
+
diff --git a/plugins/sharemydesktop/CMakeLists.txt b/plugins/sharemydesktop/CMakeLists.txt
new file mode 100644
index 0000000..ab88795
--- /dev/null
+++ b/plugins/sharemydesktop/CMakeLists.txt
@@ -0,0 +1,41 @@
+project (kopete-plugin-sharemydesktop)
+
+include_directories (${CMAKE_CURRENT_SOURCE_DIR}
+ ${CMAKE_CURRENT_BINARY_DIR}
+ ${TELEPATHY_QT4_INCLUDE_DIR}
+)
+
+set (kopete_plugin_sharemydesktop_SRCS
+ share-my-desktop-plugin.cpp
+ share-my-desktop-gui-client.cpp
+)
+
+kde4_add_plugin (kopete_sharemydesktop
+ ${kopete_plugin_sharemydesktop_SRCS}
+)
+
+target_link_libraries (kopete_sharemydesktop
+ kopetetelepathy
+ ${TELEPATHY_QT4_LIBRARIES}
+ ${KDE4_KDEUI_LIBS}
+ ${KOPETE_LIBRARIES}
+)
+
+install (TARGETS
+ kopete_sharemydesktop
+ DESTINATION
+ ${PLUGIN_INSTALL_DIR}
+)
+
+install (FILES
+ kopete_sharemydesktop.desktop
+ DESTINATION
+ ${SERVICES_INSTALL_DIR}
+)
+
+install (FILES
+ share-my-desktop-chat-ui.rc
+ DESTINATION
+ ${DATA_INSTALL_DIR}/kopete_sharemydesktop
+)
+
diff --git a/plugins/sharemydesktop/kopete_sharemydesktop.desktop b/plugins/sharemydesktop/kopete_sharemydesktop.desktop
new file mode 100644
index 0000000..dabdcca
--- /dev/null
+++ b/plugins/sharemydesktop/kopete_sharemydesktop.desktop
@@ -0,0 +1,26 @@
+[Desktop Entry]
+Type=Service
+X-Kopete-Version=1000900
+Icon=krfb
+X-KDE-ServiceTypes=Kopete/Plugin
+X-KDE-Library=kopete_sharemydesktop
+X-KDE-PluginInfo-Author=George Goldberg
+X-KDE-PluginInfo-Email=grundleborg@googlemail.com
+X-KDE-PluginInfo-Name=kopete_sharemydesktop
+X-KDE-PluginInfo-Version=0.1.0
+X-KDE-PluginInfo-Website=http://kopete.kde.org
+X-KDE-PluginInfo-Category=Plugins
+X-KDE-PluginInfo-Depends=
+X-KDE-PluginInfo-License=LGPL
+X-KDE-PluginInfo-EnabledByDefault=true
+Name=Share My Desktop
+Name[pt]=Partilhar o Meu Ecrã
+Name[sv]=Dela mitt skrivbord
+Name[tr]=Masaüstümü Paylaş
+Name[uk]=Відкрити мою стільницю
+Name[x-test]=xxShare My Desktopxx
+Comment=Share your desktop with your instant messaging buddies
+Comment[pt]=Partilhe o seu ambiente de trabalho com os seus amigos das mensagens instantâneas
+Comment[sv]=Dela ditt skrivbord med direktmeddelandekompisar
+Comment[uk]=Відкрити вашу стільницю для ваших співрозмовників у службі обміну повідомленнями
+Comment[x-test]=xxShare your desktop with your instant messaging buddiesxx
diff --git a/plugins/sharemydesktop/share-my-desktop-chat-ui.rc b/plugins/sharemydesktop/share-my-desktop-chat-ui.rc
new file mode 100644
index 0000000..fb17a36
--- /dev/null
+++ b/plugins/sharemydesktop/share-my-desktop-chat-ui.rc
@@ -0,0 +1,6 @@
+<!DOCTYPE kpartgui>
+<kpartgui name="kopete_sharemydesktop" version="1">
+ <ToolBar name="chatToolBar" fullWidth="true">
+ <Action name="shareMyDesktop" />
+ </ToolBar>
+</kpartgui>
diff --git a/plugins/sharemydesktop/share-my-desktop-gui-client.cpp b/plugins/sharemydesktop/share-my-desktop-gui-client.cpp
new file mode 100644
index 0000000..aec0eb9
--- /dev/null
+++ b/plugins/sharemydesktop/share-my-desktop-gui-client.cpp
@@ -0,0 +1,209 @@
+/*
+ * This file is part of Kopete
+ *
+ * Copyright (C) 2009 Collabora Ltd. <info@collabora.co.uk>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library 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
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#include "share-my-desktop-gui-client.h"
+
+#include "share-my-desktop-plugin.h"
+
+#include <KopeteTelepathy/telepathychatsession.h>
+#include <KopeteTelepathy/telepathycontact.h>
+
+#include <kopeteaccount.h>
+#include <kopetechatsession.h>
+#include <ui/kopeteview.h>
+
+#include <KAction>
+#include <KActionCollection>
+#include <KDebug>
+#include <KGenericFactory>
+#include <KMessageBox>
+#include <KShortcut>
+
+#include <TelepathyQt4/PendingChannelRequest>
+#include <TelepathyQt4/PendingOperation>
+#include <TelepathyQt4/PendingReady>
+#include <TelepathyQt4/ReferencedHandles>
+
+ShareMyDesktopGuiClient::ShareMyDesktopGuiClient(const KComponentData &componentData,
+ Kopete::ChatSession *parent)
+ : QObject(parent),
+ KXMLGUIClient(parent),
+ m_chatSession(parent)
+{
+ kDebug();
+
+ // Set the component data so KXMLGui can find the correct RC file
+ setComponentData(componentData);
+
+ // If the chat session is invalid or empty, this instance should never have happened, but best
+ // to be safe and check again anyway.
+ if (!m_chatSession || m_chatSession->members().isEmpty()) {
+ kWarning() << "Invalid Chat Session.";
+ deleteLater();
+ }
+
+ // Same for if it is a telepathy chat.
+ TelepathyChatSession *tpChatSession = qobject_cast<TelepathyChatSession*>(m_chatSession);
+
+ if (!tpChatSession) {
+ kWarning() << "Not a Telepathy Chat Session.";
+ deleteLater();
+ }
+
+ // Add a KAction for Share My Desktop.
+ // FIXME: Are the label and accelerator and shortcut here OK?
+ KAction *shareMyDesktop = new KAction(KIcon("krfb"), i18n("S&hare My Desktop"), this);
+ actionCollection()->addAction( "shareMyDesktop", shareMyDesktop );
+ shareMyDesktop->setShortcut(KShortcut (Qt::CTRL + Qt::Key_D));
+ connect(shareMyDesktop, SIGNAL(triggered(bool)), this, SLOT(onShareMyDesktopTriggered()));
+
+ // Set the RC file to use to be the one with our toolbar button in it.
+ setXMLFile("share-my-desktop-chat-ui.rc");
+}
+
+ShareMyDesktopGuiClient::~ShareMyDesktopGuiClient()
+{
+ kDebug();
+}
+
+void ShareMyDesktopGuiClient::onShareMyDesktopTriggered()
+{
+ kDebug();
+
+ // When the share-my-desktop button is pressed this slot is called.
+
+ // First check that the Chat Session is valid.
+ if (!m_chatSession) {
+ kWarning() << "Chat session is no longer valid.";
+ return;
+ }
+
+ // Get the remote contacts we are chatting with. Sharing a desktop to more than one contact
+ // in the same chat is not currently supported.
+ // FIXME: Support sharing desktop to everyone in a Multi-User-Chat
+ Kopete::ContactPtrList members = m_chatSession->members();
+
+ if (members.size() <= 0) {
+ kWarning() << "Invalid number of people in the chat. Aborting share-my-desktop.";
+ return;
+ }
+
+ if (members.size() > 1) {
+ kWarning() << "Share-My-Desktop only supports 1-1 chats at the moment.";
+ return;
+ }
+
+ // Cast the only member of the chat to a TelepathyContact.
+ TelepathyContact *tpContact = qobject_cast<TelepathyContact*>(members.at(0));
+
+ // Check the member really is a telepathy contact.
+ if (!tpContact) {
+ kWarning() << "Chat member is not a telepathy contact. Aborting share-my-desktop.";
+ return;
+ }
+
+ // Get the internal Tp::Contact and save it as a member variable.
+ m_contact = tpContact->internalContact();
+
+ if (!m_contact) {
+ kWarning() << "Internal Contact is null. Aborting share-my-desktop.";
+ return;
+ }
+
+ // Get the Account on which we are requesting a channel.
+ Kopete::Account *kAccount = tpContact->account();
+
+ // Check the account is not null
+ if (!kAccount) {
+ kWarning() << "Contact's account is not valid. Aborting share-my-desktop.";
+ return;
+ }
+
+ // Cast to a telepathy account
+ TelepathyAccount *tpAccount = qobject_cast<TelepathyAccount*>(kAccount);
+
+ // Check the TelepathyAccount is valid.
+ if (!tpAccount) {
+ kWarning() << "Account is not a a TelepathyAccount. Aborting share-my-desktop.";
+ return;
+ }
+
+ // The account is valid. Get its telepathy account and save it as a member variable.
+ m_account = tpAccount->account();
+
+ // Check that the internal telepathy account is valid.
+ if (!m_account) {
+ kWarning() << "Tp::Account is not valid. Aborting share-my-desktop.";
+ return;
+ }
+
+ // Now we get the Tp::Account ready with the core feature.
+ connect(m_account->becomeReady(Tp::Account::FeatureCore),
+ SIGNAL(finished(Tp::PendingOperation*)),
+ SLOT(onAccountReady(Tp::PendingOperation*)));
+}
+
+void ShareMyDesktopGuiClient::onAccountReady(Tp::PendingOperation *op)
+{
+ kDebug();
+
+ if (op->isError()) {
+ kWarning() << "Making the Account ready failed:" << op->errorName() << op->errorMessage();
+ return;
+ }
+
+ // Ensure a rfb stream tube channel to this contact.
+ QVariantMap parameters;
+ parameters.insert(QLatin1String(TELEPATHY_INTERFACE_CHANNEL ".ChannelType"),
+ TELEPATHY_INTERFACE_CHANNEL_TYPE_STREAM_TUBE);
+ parameters.insert(QLatin1String(TELEPATHY_INTERFACE_CHANNEL ".TargetHandleType"),
+ Tp::HandleTypeContact);
+ parameters.insert(QLatin1String(TELEPATHY_INTERFACE_CHANNEL ".TargetHandle"),
+ m_contact->handle().at(0));
+ parameters.insert(QLatin1String(TELEPATHY_INTERFACE_CHANNEL_TYPE_STREAM_TUBE ".Service"),
+ "rfb");
+
+ connect(m_account->ensureChannel(parameters),
+ SIGNAL(finished(Tp::PendingOperation*)),
+ SLOT(onEnsureChannelFinished(Tp::PendingOperation*)));
+}
+
+void ShareMyDesktopGuiClient::onEnsureChannelFinished(Tp::PendingOperation *op)
+{
+ if (op->isError()) {
+ kWarning() << "Ensuring channel failed:" << op->errorName() << op->errorMessage();
+
+ if (op->errorName() == TELEPATHY_ERROR_DISCONNECTED) {
+ KMessageBox::error(m_chatSession->view()->mainWidget(),
+ i18n("An error occurred sharing your desktop. Please ensure that you have krfb installed."),
+ i18n("Error - Share My Desktop"));
+ } else {
+ KMessageBox::error(m_chatSession->view()->mainWidget(),
+ i18n("An unknown error occurred sharing your desktop."),
+ i18n("Error - Share My Desktop"));
+ }
+
+ return;
+ }
+}
+
+
+#include "share-my-desktop-gui-client.moc"
+
diff --git a/plugins/sharemydesktop/share-my-desktop-gui-client.h b/plugins/sharemydesktop/share-my-desktop-gui-client.h
new file mode 100644
index 0000000..d05e697
--- /dev/null
+++ b/plugins/sharemydesktop/share-my-desktop-gui-client.h
@@ -0,0 +1,59 @@
+/*
+ * This file is part of Kopete
+ *
+ * Copyright (C) 2009 Collabora Ltd. <info@collabora.co.uk>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library 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
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#ifndef KOPETE_PLUGIN_SHAREMYDESKTOP_SHARE_MY_DESKTOP_GUI_CLIENT_H
+#define KOPETE_PLUGIN_SHAREMYDESKTOP_SHARE_MY_DESKTOP_GUI_CLIENT_H
+
+#include <KXMLGUIClient>
+
+#include <TelepathyQt4/Account>
+#include <TelepathyQt4/Contact>
+
+namespace Kopete {
+ class ChatSession;
+}
+
+namespace Tp {
+ class PendingOperation;
+}
+
+class ShareMyDesktopGuiClient : public QObject, public KXMLGUIClient
+{
+ Q_OBJECT
+
+public:
+ ShareMyDesktopGuiClient(const KComponentData &componentData, Kopete::ChatSession *parent = 0);
+ ~ShareMyDesktopGuiClient();
+
+private Q_SLOTS:
+ void onShareMyDesktopTriggered();
+ void onAccountReady(Tp::PendingOperation *op);
+ void onEnsureChannelFinished(Tp::PendingOperation *op);
+
+private:
+ Kopete::ChatSession *m_chatSession;
+
+ Tp::AccountPtr m_account;
+ Tp::ContactPtr m_contact;
+};
+
+
+#endif // Header guard
+
diff --git a/plugins/sharemydesktop/share-my-desktop-plugin.cpp b/plugins/sharemydesktop/share-my-desktop-plugin.cpp
new file mode 100644
index 0000000..4782645
--- /dev/null
+++ b/plugins/sharemydesktop/share-my-desktop-plugin.cpp
@@ -0,0 +1,87 @@
+/*
+ * This file is part of Kopete
+ *
+ * Copyright (C) 2009 Collabora Ltd. <info@collabora.co.uk>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library 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
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#include "share-my-desktop-plugin.h"
+
+#include "share-my-desktop-gui-client.h"
+
+#include <KAboutData>
+#include <KComponentData>
+#include <KDebug>
+#include <KPluginFactory>
+#include <KPluginInfo>
+
+#include <kopetechatsessionmanager.h>
+#include <kopetechatsession.h>
+#include <kopeteprotocol.h>
+#include <ui/kopeteview.h>
+#include <ui/kopeteviewplugin.h>
+
+K_PLUGIN_FACTORY(ShareMyDesktopPluginFactory, registerPlugin<ShareMyDesktopPlugin>(); )
+K_EXPORT_PLUGIN(ShareMyDesktopPluginFactory("kopete_sharemydesktop"))
+
+ShareMyDesktopPlugin::ShareMyDesktopPlugin(QObject *parent, const QVariantList &args)
+ : Kopete::Plugin(ShareMyDesktopPluginFactory::componentData(), parent)
+{
+ kDebug();
+
+ Q_UNUSED(args);
+
+ // Connect to the signal emitted when a new Chat Session is started.
+ connect(Kopete::ChatSessionManager::self(),
+ SIGNAL(viewCreated(KopeteView*)),
+ SLOT(onViewCreated(KopeteView*)));
+}
+
+ShareMyDesktopPlugin::~ShareMyDesktopPlugin()
+{
+ kDebug();
+}
+
+void ShareMyDesktopPlugin::onViewCreated(KopeteView *view)
+{
+ if (view->plugin()->pluginInfo().pluginName() != QString::fromLatin1("kopete_chatwindow")) {
+ // Only conventional text chat windows are supported by this plugin (e.g. not email ones).
+ return;
+ }
+
+ // Get the chat session
+ Kopete::ChatSession *session = view->msgManager();
+
+ if (!session) {
+ kWarning() << "Null chat session. Aborting.";
+ return;
+ }
+
+ // Check that this chat session is using the Telepathy protocol (since this plugin only works
+ // with the Telepathy protocol.
+ if (session->protocol()->componentData().componentName() != "kopete_telepathy") {
+ kDebug() << "Chat is not using Telepathy protocol. Do not use this plugin.";
+ return;
+ }
+
+ kDebug() << "Chat is using Telepathy protocol :):):)";
+
+ new ShareMyDesktopGuiClient(ShareMyDesktopPluginFactory::componentData(), session);
+}
+
+
+#include "share-my-desktop-plugin.moc"
+
diff --git a/plugins/sharemydesktop/share-my-desktop-plugin.h b/plugins/sharemydesktop/share-my-desktop-plugin.h
new file mode 100644
index 0000000..604301e
--- /dev/null
+++ b/plugins/sharemydesktop/share-my-desktop-plugin.h
@@ -0,0 +1,45 @@
+/*
+ * This file is part of Kopete
+ *
+ * Copyright (C) 2009 Collabora Ltd. <info@collabora.co.uk>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library 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
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#ifndef KOPETE_PLUGIN_SHAREMYDESKTOP_SHARE_MY_DESKTOP_PLUGIN_H
+#define KOPETE_PLUGIN_SHAREMYDESKTOP_SHARE_MY_DESKTOP_PLUGIN_H
+
+#include "kopeteplugin.h"
+
+#include <QtCore/QVariantList>
+
+class KopeteView;
+
+class ShareMyDesktopPlugin : public Kopete::Plugin
+{
+ Q_OBJECT
+
+public:
+ ShareMyDesktopPlugin(QObject *parent, const QVariantList &args);
+ ~ShareMyDesktopPlugin();
+
+private Q_SLOTS:
+ void onViewCreated(KopeteView *view);
+
+};
+
+
+#endif // Header guard
+