[SCM] ktp-text-ui packaging branch, master, updated. debian/15.12.1-1-1918-gdf4b0ec
Maximiliano Curia
maxy at moszumanska.debian.org
Sat May 28 00:23:07 UTC 2016
Gitweb-URL: http://git.debian.org/?p=pkg-kde/applications/ktp-text-ui.git;a=commitdiff;h=dca55b1
The following commit has been merged in the master branch:
commit dca55b1099d0066a363b907c7d53bfd0b8831221
Author: Dan Vrátil <dvratil at redhat.com>
Date: Fri Jan 4 14:54:07 2013 +0100
Move message-processing classes to common-internals
---
CMakeLists.txt | 1 -
lib/CMakeLists.txt | 7 --
lib/abstract-message-filter.cpp | 53 ---------------
lib/abstract-message-filter.h | 51 ---------------
lib/escape-filter.cpp | 41 ------------
lib/filters.h | 40 ------------
lib/message-processor.cpp | 135 --------------------------------------
lib/message-processor.h | 65 -------------------
lib/message.cpp | 116 ---------------------------------
lib/message.h | 140 ----------------------------------------
lib/plugin-config-manager.cpp | 94 ---------------------------
lib/plugin-config-manager.h | 46 -------------
lib/url-filter.cpp | 60 -----------------
version.h.in | 1 -
14 files changed, 850 deletions(-)
diff --git a/CMakeLists.txt b/CMakeLists.txt
index f9d44be..97d72cf 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -1,7 +1,6 @@
project(ktp-text-ui)
set(KTP_TEXT_UI_VERSION "0.5.2")
-set(KTP_TEXT_UI_PLUGIN_FRAMEWORK_VERSION "2")
set(IS_KTP_INTERNAL_MODULE TRUE)
# Include our extra FindFoo.cmake files.
diff --git a/lib/CMakeLists.txt b/lib/CMakeLists.txt
index c0d70ee..5c4741d 100644
--- a/lib/CMakeLists.txt
+++ b/lib/CMakeLists.txt
@@ -14,16 +14,9 @@ set(ktpchat_SRCS
chat-text-edit.cpp
chat-search-bar.cpp
logmanager.cpp
- message.cpp
- abstract-message-filter.cpp
- message-processor.cpp
- url-filter.cpp
- escape-filter.cpp
- plugin-config-manager.cpp
)
set(ktpchat_HDRS
- abstract-message-filter.h
adium-theme-content-info.h
adium-theme-header-info.h
adium-theme-message-info.h
diff --git a/lib/abstract-message-filter.cpp b/lib/abstract-message-filter.cpp
deleted file mode 100644
index 44b81c3..0000000
--- a/lib/abstract-message-filter.cpp
+++ /dev/null
@@ -1,53 +0,0 @@
-/*
- Copyright (C) 2012 Lasath Fernando <kde at lasath.org>
-
- 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 Street, Fifth Floor, Boston, MA 02110-1301 USA
-*/
-
-#include "abstract-message-filter.h"
-
-AbstractMessageFilter::AbstractMessageFilter(QObject* parent)
- : QObject(parent)
-{
-}
-
-AbstractMessageFilter::~AbstractMessageFilter()
-{
-}
-
-void AbstractMessageFilter::filterIncomingMessage(Message &message)
-{
- filterMessage(message);
-}
-
-void AbstractMessageFilter::filterOutgoingMessage(Message &message)
-{
- filterMessage(message);
-}
-
-void AbstractMessageFilter::filterMessage(Message &message)
-{
- Q_UNUSED(message)
-}
-
-QStringList AbstractMessageFilter::requiredScripts()
-{
- return QStringList();
-}
-
-QStringList AbstractMessageFilter::requiredStylesheets()
-{
- return QStringList();
-}
diff --git a/lib/abstract-message-filter.h b/lib/abstract-message-filter.h
deleted file mode 100644
index 2b159de..0000000
--- a/lib/abstract-message-filter.h
+++ /dev/null
@@ -1,51 +0,0 @@
-/*
- Copyright (C) 2012 Lasath Fernando <kde at lasath.org>
-
- 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 Street, Fifth Floor, Boston, MA 02110-1301 USA
-*/
-
-#ifndef ABSTRACTPLUGIN_H
-#define ABSTRACTPLUGIN_H
-
-#include "message.h"
-#include "ktpchat_export.h"
-
-class KDE_TELEPATHY_CHAT_EXPORT AbstractMessageFilter : public QObject
-{
-Q_OBJECT
-public:
- AbstractMessageFilter(QObject* parent = 0);
- virtual ~AbstractMessageFilter();
-
- /** Filter messages to show on the UI recieved by another contact*/
- virtual void filterIncomingMessage(Message &message);
-
- /** Filter messages to show in the UI that you have sent
- This does _not_ affect the actual message sent, only the visual representation on your screen.
- */
- virtual void filterOutgoingMessage(Message &message);
-
- /** Filter messages in either direction. Base implementation calls this for messages sent/recived in either direction.*/
- virtual void filterMessage(Message &message);
-
- /** Scripts that must be included in the <head> section of the html required by this message filter.*/
- virtual QStringList requiredScripts();
-
- /** Scripts that must be included in the <head> section of the html required by this message filter.*/
- virtual QStringList requiredStylesheets();
-};
-
-#endif // ABSTRACTPLUGIN_H
-
diff --git a/lib/escape-filter.cpp b/lib/escape-filter.cpp
deleted file mode 100644
index 7a43151..0000000
--- a/lib/escape-filter.cpp
+++ /dev/null
@@ -1,41 +0,0 @@
-/*
- Copyright (C) 2012 Lasath Fernando <kde at lasath.org>
-
- 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 Street, Fifth Floor, Boston, MA 02110-1301 USA
-*/
-
-#include "filters.h"
-
-#include <QtGui/QTextDocument> //needed for Qt::escape
-
-EscapeFilter::EscapeFilter(QObject *parent)
- : AbstractMessageFilter(parent)
-{
-}
-
-void EscapeFilter::filterMessage(Message& message)
-{
- QString escapedMessage = Qt::escape(message.mainMessagePart());
-
- escapedMessage.replace(QLatin1String("
"), QLatin1String("<br/> ")); //keep leading whitespaces
- escapedMessage.replace(QLatin1Char('
'), QLatin1String("<br/>"));
- escapedMessage.replace(QLatin1Char('
'), QLatin1String("<br/>"));
- escapedMessage.replace(QLatin1Char(' '), QLatin1String(" ")); // replace tabs by 4 spaces
- escapedMessage.replace(QLatin1String(" "), QLatin1String(" ")); // keep multiple whitespaces
- escapedMessage.replace(QLatin1Char('\'), QLatin1String("\\")); //replace a single backslash with two backslashes.
-
- message.setMainMessagePart(escapedMessage);
-}
-
diff --git a/lib/filters.h b/lib/filters.h
deleted file mode 100644
index 4e96ae0..0000000
--- a/lib/filters.h
+++ /dev/null
@@ -1,40 +0,0 @@
-/*
- Copyright (C) 2012 Lasath Fernando <kde at lasath.org>
-
- 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 Street, Fifth Floor, Boston, MA 02110-1301 USA
-*/
-
-#ifndef FILTERS_H
-#define FILTERS_H
-
-#include "abstract-message-filter.h"
-
-#include <QObject>
-
-class UrlFilter : public AbstractMessageFilter
-{
-public:
- explicit UrlFilter(QObject *parent = 0);
- void filterMessage(Message &message);
-};
-
-class EscapeFilter : public AbstractMessageFilter
-{
-public:
- explicit EscapeFilter(QObject *parent = 0);
- virtual void filterMessage(Message& message);
-};
-
-#endif
diff --git a/lib/message-processor.cpp b/lib/message-processor.cpp
deleted file mode 100644
index 44dc765..0000000
--- a/lib/message-processor.cpp
+++ /dev/null
@@ -1,135 +0,0 @@
-/*
- Copyright (C) 2012 Lasath Fernando <kde at lasath.org>
-
- 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 Street, Fifth Floor, Boston, MA 02110-1301 USA
-*/
-
-
-#include "message-processor.h"
-#include "filters.h"
-#include "plugin-config-manager.h"
-
-#include <QMutex>
-#include <QStringBuilder>
-
-#include <KDebug>
-#include <KService>
-#include <KServiceTypeTrader>
-#include <KPluginFactory>
-#include <KDE/KStandardDirs>
-
-MessageProcessor* MessageProcessor::s_instance = 0;
-
-MessageProcessor* MessageProcessor::instance()
-{
- kDebug();
-
- static QMutex mutex;
- mutex.lock();
- if (!s_instance) {
- s_instance = new MessageProcessor;
- }
- mutex.unlock();
-
- return s_instance;
-}
-
-
-MessageProcessor::MessageProcessor()
-{
- m_filters.append(new EscapeFilter(this));
- m_filters.append(new UrlFilter(this));
-
- loadFilters();
-}
-
-
-MessageProcessor::~MessageProcessor()
-{
-}
-
-QString MessageProcessor::header()
-{
- QStringList scripts;
- QStringList stylesheets;
- Q_FOREACH (AbstractMessageFilter *filter, MessageProcessor::m_filters) {
- Q_FOREACH (const QString &script, filter->requiredScripts()) {
- // Avoid duplicates
- if (!scripts.contains(script)) {
- scripts << script;
- }
- }
- Q_FOREACH (const QString &stylesheet, filter->requiredStylesheets()) {
- // Avoid duplicates
- if (!stylesheets.contains(stylesheet)) {
- stylesheets << stylesheet;
- }
- }
- }
-
- QString out(QLatin1String("
<!-- The following scripts and stylesheets are injected here by the plugins -->
"));
- Q_FOREACH(const QString &script, scripts) {
- out = out % QLatin1String(" <script type=\"text/javascript\" src=\"")
- % KGlobal::dirs()->findResource("data", script)
- % QLatin1String("\"></script>
");
- }
- Q_FOREACH(const QString &stylesheet, stylesheets) {
- out = out % QLatin1String(" <link rel=\"stylesheet\" type=\"text/css\" href=\"")
- % KGlobal::dirs()->findResource("data", stylesheet)
- % QLatin1String("\" />
");
- }
-
- kDebug() << out;
-
- return out;
-}
-
-Message MessageProcessor::processIncomingMessage(Message receivedMessage)
-{
- Q_FOREACH (AbstractMessageFilter *filter, MessageProcessor::m_filters) {
- kDebug() << "running filter :" << filter->metaObject()->className();
- filter->filterIncomingMessage(receivedMessage);
- }
- return receivedMessage;
-}
-
-Message MessageProcessor::processOutgoingMessage(Message sentMessage)
-{
- Q_FOREACH (AbstractMessageFilter *filter, MessageProcessor::m_filters) {
- filter->filterOutgoingMessage(sentMessage);
- }
- return sentMessage;
-}
-
-void MessageProcessor::loadFilters() {
- kDebug() << "Starting loading filters...";
-
- Q_FOREACH (const KPluginInfo &plugin, PluginConfigManager::self()->enabledPlugins()) {
- KService::Ptr service = plugin.service();
-
- KPluginFactory *factory = KPluginLoader(service->library()).factory();
- if(factory) {
- kDebug() << "loaded factory :" << factory;
- AbstractMessageFilter *filter = factory->create<AbstractMessageFilter>(this);
-
- if(filter) {
- kDebug() << "loaded message filter : " << filter;
- m_filters.append(filter);
- }
- } else {
- kError() << "error loading plugin :" << service->library();
- }
- }
-}
diff --git a/lib/message-processor.h b/lib/message-processor.h
deleted file mode 100644
index c6183f6..0000000
--- a/lib/message-processor.h
+++ /dev/null
@@ -1,65 +0,0 @@
-/*
- Copyright (C) 2012 Lasath Fernando <kde at lasath.org>
-
- 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 Street, Fifth Floor, Boston, MA 02110-1301 USA
-*/
-
-
-#ifndef MESSAGE_PROCESSOR_H
-#define MESSAGE_PROCESSOR_H
-
-#include <QObject>
-#include <QList>
-#include <KPluginInfo>
-
-#include "message.h"
-
-#include <ktpchat_export.h>
-
-namespace Tp
-{
-class ReceivedMessage;
-class Message;
-}
-
-class AbstractMessageFilter;
-
-//each thing that displays message will have an instance of this
-class KDE_TELEPATHY_CHAT_EXPORT MessageProcessor : public QObject
-{
-Q_OBJECT
-
-public:
- static MessageProcessor* instance();
- ~MessageProcessor();
-
- //text-ui will call this somewhere when creating the template
- QString header();
-
- //text-ui will call this somewhere in handleIncommingMessage just before displaying it
- Message processIncomingMessage(Message message);
- Message processOutgoingMessage(Message message);
-
-protected:
- explicit MessageProcessor();
-
-private:
- // TODO Move in a private class
- void loadFilters();
- static MessageProcessor* s_instance;
- QList<AbstractMessageFilter*> m_filters;
-};
-
-#endif // MESSAGE_PROCESSOR_H
diff --git a/lib/message.cpp b/lib/message.cpp
deleted file mode 100644
index aa7de9d..0000000
--- a/lib/message.cpp
+++ /dev/null
@@ -1,116 +0,0 @@
-/*
- Copyright (C) 2012 Lasath Fernando <kde at lasath.org>
-
- 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 Street, Fifth Floor, Boston, MA 02110-1301 USA
-*/
-
-
-#include "message.h"
-#include <KDebug>
-
-Message::Message(const Tp::Message &original) :
- m_sentTime(original.sent()),
- m_token(original.messageToken()),
- m_messageType(original.messageType())
-{
- setMainMessagePart(original.text());
-}
-
-Message::Message(const Tpl::TextEventPtr &original) :
- m_sentTime(original->timestamp()),
- m_token(original->messageToken()),
- m_messageType(original->messageType())
-{
- setMainMessagePart(original->message());
-}
-
-QString Message::mainMessagePart() const
-{
- return m_mainPart;
-}
-
-void Message::setMainMessagePart(const QString& message)
-{
- m_mainPart = message;
-}
-
-void Message::appendMessagePart(const QString& part)
-{
- m_parts << part;
-}
-
-void Message::appendScript(const QString& script)
-{
- // Append the script only if it is not already appended to avoid multiple
- // execution of the scripts.
- if (!m_scripts.contains(script)) {
- m_scripts << script;
- }
-}
-
-QString Message::finalizedMessage() const
-{
- QString msg = m_mainPart + QLatin1String("
") +
- m_parts.join(QLatin1String("
"));
-
-// kDebug() << msg;
- return msg;
-}
-
-QString Message::finalizedScript() const
-{
- if (m_scripts.empty()) {
- return QString();
- }
-
- QString finalScript = m_scripts.join(QLatin1String(""));
-
- if (!finalScript.isEmpty()) {
- finalScript.append(QLatin1String("false;"));
- }
-
-// kDebug() << finalScript;
- return finalScript;
-}
-
-QVariant Message::property(const char *name) const
-{
- return m_properties[QLatin1String(name)];
-}
-
-void Message::setProperty(const char *name, const QVariant& value)
-{
- m_properties[QLatin1String(name)] = value;
-}
-
-QDateTime Message::time() const
-{
- return m_sentTime;
-}
-
-QString Message::token() const
-{
- return m_token;
-}
-
-Tp::ChannelTextMessageType Message::type() const
-{
- return m_messageType;
-}
-
-int Message::partsSize() const
-{
- return m_parts.size();
-}
diff --git a/lib/message.h b/lib/message.h
deleted file mode 100644
index 1928fcd..0000000
--- a/lib/message.h
+++ /dev/null
@@ -1,140 +0,0 @@
-/*
- Copyright (C) 2012 Lasath Fernando <kde at lasath.org>
-
- 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 Street, Fifth Floor, Boston, MA 02110-1301 USA
-*/
-
-
-#ifndef MESSAGE_H
-#define MESSAGE_H
-
-#include <TelepathyQt/Message>
-
-#include <TelepathyLoggerQt4/Types>
-#include <TelepathyLoggerQt4/TextEvent>
-
-#include <ktpchat_export.h>
-
-/*!
- * \par
- * An encapsualtion of a Tp::Message that can be procesesd
- * by many MessageFilters concurrently.
- *
- * \par
- * Contains multiple parts created by plugins, to be displayed by user
- * interfaces. Also contains internal metadata for use by other plugins.
- *
- *
ote
- * Methods in this class are currently *not* thread safe. They will be in a
- * later version. Setting properties concurrently is undefined.
- *
- * uthor Lasath Fernando <kde at lasath.org>
- */
-class KDE_TELEPATHY_CHAT_EXPORT Message {
-
-public:
- Message(const Tp::Message& original);
- Message(const Tpl::TextEventPtr &original);
-
- /*! rief The body of the message
- *
eturn the contents of the body of the message, as HTML
- */
- QString mainMessagePart() const;
-
- /*! rief Edit the main component of the message
- *
- * \param message the string to replace the body with. Must be correct HTML
- */
- void setMainMessagePart(const QString& message);
-
- /*! rief Add new visual content to the end of the message
- *
- * \par
- * Each plugin that adds visual components should call this once thier
- * processing is complete. Once a message part is added, it cannot be
- * changed!
- *
- * \param part the content to be added, in valid HTML
- */
- void appendMessagePart(const QString &part);
-
- /*! rief Append a script
- *
- * \par
- * Each plugin that requires to run a script after the page is updated can
- * use this method to add a script will be run after the message is appended
- */
- void appendScript(const QString &script);
-
- /*! rief Construct the final procesesd content
- *
- * \par
- * This will concatenate all the visual 'parts' of the message into one
- * (Qt supported) HTML string.
- *
- *
ote
- * All user interfaces need only care about this
- *
- */
- QString finalizedMessage() const;
-
- /*! rief Construct the final script
- *
- * \par
- * This will concatenate all the scripts parts of the message into one
- * script that must be executed after the finalized message is appended.
- */
- QString finalizedScript() const;
-
- /*! rief Sets the contents of a property
- * \par
- * These messages contain meta-data for plugins in the form of 'properties'.
- * A property can be set to any QMetaType (i.e type that can stuck in a
- * QVariant) and is identified by a string (name).
- *
- * \par
- * These are set by plugins for use in other plugins, creating implicit
- * dependencies between plugins. Since these plugins are (or will be)
- * run concurrently, calling this method on a property that hasn't been set
- * yet will block until it has been set by some plugin. If it isn't set when
- * all plugins are finished, this plugin will be cancelled.
- *
- * \param name the identifier of the property
- */
- QVariant property(const char *name) const;
- void setProperty(const char *name, const QVariant &value);
-
- /*!
eturn the time the message was sent*/
- QDateTime time() const;
- /*!
eturn the unique token from the message*/
- QString token() const;
- /*!
eturn the type of the message*/
- Tp::ChannelTextMessageType type() const;
-
- /*!
eturn the number of appended parts */
- int partsSize() const;
-
-private:
- QDateTime m_sentTime;
- QString m_token;
- Tp::ChannelTextMessageType m_messageType;
- QVariantMap m_properties;
- QString m_mainPart;
- QStringList m_parts;
- QStringList m_scripts;
-};
-
-
-#endif // MESSAGE_H
diff --git a/lib/plugin-config-manager.cpp b/lib/plugin-config-manager.cpp
deleted file mode 100644
index 601d74b..0000000
--- a/lib/plugin-config-manager.cpp
+++ /dev/null
@@ -1,94 +0,0 @@
-/*
- * Copyright (C) 2012 Lasath Fernando <kde at lasath.org>
- *
- * 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 Street, Fifth Floor, Boston, MA 02110-1301 USA
-*/
-
-#include "plugin-config-manager.h"
-#include "version.h"
-
-#include <QMutex>
-#include <QSet>
-
-#include <KGlobal>
-#include <KDebug>
-#include <KServiceTypeTrader>
-
-typedef QSet<KPluginInfo> PluginSet;
-
-class PluginConfigManager::Private {
-public:
- PluginSet all;
- PluginSet enabled;
-};
-
-PluginConfigManager *PluginConfigManager::self()
-{
- static PluginConfigManager *pcm_instance;
- static QMutex mutex;
- mutex.lock();
- if (!pcm_instance) {
- pcm_instance = new PluginConfigManager;
- }
- mutex.unlock();
-
- return pcm_instance;
-}
-
-PluginConfigManager::PluginConfigManager() :
- d(new Private)
-{
- generateCache();
-}
-
-KService::List offers() {
- return KServiceTypeTrader::self()->query(QLatin1String("KTpTextUi/MessageFilter"),
- QLatin1String("[X-KTp-PluginInfo-Version] == " KTP_TEXT_UI_PLUGIN_FRAMEWORK_VERSION));
-}
-
-void PluginConfigManager::generateCache()
-{
- KPluginInfo::List all = KPluginInfo::fromServices(offers(), configGroup());
- for (KPluginInfo::List::Iterator i = all.begin(); i != all.end(); i++) {
- KPluginInfo &plugin = *i;
-
- d->all.insert(plugin);
-
- plugin.load();
- if (plugin.isPluginEnabled()) {
- d->enabled.insert(plugin);
- }
- }
-}
-
-KPluginInfo::List PluginConfigManager::allPlugins() const
-{
- return d->all.toList();
-}
-
-KPluginInfo::List PluginConfigManager::enabledPlugins() const
-{
- return d->enabled.toList();
-}
-
-KConfigGroup PluginConfigManager::configGroup() const
-{
- return sharedConfig()->group("Plugins");
-}
-
-KSharedConfig::Ptr PluginConfigManager::sharedConfig() const
-{
- return KSharedConfig::openConfig(QLatin1String("ktelepathyrc"));
-}
diff --git a/lib/plugin-config-manager.h b/lib/plugin-config-manager.h
deleted file mode 100644
index 4307b55..0000000
--- a/lib/plugin-config-manager.h
+++ /dev/null
@@ -1,46 +0,0 @@
-/*
- * Copyright (C) 2012 Lasath Fernando <kde at lasath.org>
- *
- * 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 Street, Fifth Floor, Boston, MA 02110-1301 USA
-*/
-
-#ifndef PLUGIN_CONFIG_MANAGER_H
-#define PLUGIN_CONFIG_MANAGER_H
-
-#include <KPluginInfo>
-#include <ktpchat_export.h>
-
-class KDE_TELEPATHY_CHAT_EXPORT PluginConfigManager
-{
-public:
- static PluginConfigManager* self();
-
- KPluginInfo::List allPlugins() const;
- KPluginInfo::List enabledPlugins() const;
-
- KConfigGroup configGroup() const;
- KSharedConfig::Ptr sharedConfig() const;
-
-protected:
- PluginConfigManager();
-
-private:
- class Private;
- Private *d;
-
- void generateCache();
-};
-
-#endif // PLUGIN_CONFIG_MANAGER_H
diff --git a/lib/url-filter.cpp b/lib/url-filter.cpp
deleted file mode 100644
index 162f992..0000000
--- a/lib/url-filter.cpp
+++ /dev/null
@@ -1,60 +0,0 @@
-/*
- Copyright (C) 2012 Lasath Fernando <kde at lasath.org>
- Copyright (C) 2012 David Edmundson <kde at davidedmundson.co.uk>
- Copyright (C) 2012 Rohan Garg <rohangarg at kubuntu.org>
-
- 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 Street, Fifth Floor, Boston, MA 02110-1301 USA
-*/
-
-#include "filters.h"
-
-#include <QImageReader>
-
-#include <KUrl>
-#include <KProtocolInfo>
-#include <KDebug>
-#include <KTp/text-parser.h>
-
-UrlFilter::UrlFilter(QObject *parent)
- : AbstractMessageFilter(parent)
-{
-}
-
-void UrlFilter::filterMessage(Message &info) {
- QString message = info.mainMessagePart();
- //FIXME: make "Urls" into a constant
- QVariantList urls = info.property("Urls").toList();
-
- // link detection
- KTp::TextUrlData parsedUrl = KTp::TextParser::instance()->extractUrlData(message);
-
- int offset = 0;
- for (int i = 0; i < parsedUrl.fixedUrls.size(); i++) {
- KUrl url(parsedUrl.fixedUrls.at(i));
- QString originalText = message.mid(parsedUrl.urlRanges.at(i).first + offset, parsedUrl.urlRanges.at(i).second);
- QString link = QString::fromLatin1("<a href=\"%1\">%2</a>").arg(QString::fromAscii(url.toEncoded()), originalText);
- message.replace(parsedUrl.urlRanges.at(i).first + offset, parsedUrl.urlRanges.at(i).second, link);
-
- urls.append(url);
-
- //after the first replacement is made, the original position values are not valid anymore, this adjusts them
- offset += link.length() - originalText.length();
- }
-
- info.setProperty("Urls", urls);
- info.setMainMessagePart(message);
-}
-
-
diff --git a/version.h.in b/version.h.in
index 914f26e..a4e11bf 100644
--- a/version.h.in
+++ b/version.h.in
@@ -1,2 +1 @@
#define KTP_TEXT_UI_VERSION "@KTP_TEXT_UI_VERSION@"
-#define KTP_TEXT_UI_PLUGIN_FRAMEWORK_VERSION "@KTP_TEXT_UI_PLUGIN_FRAMEWORK_VERSION@"
--
ktp-text-ui packaging
More information about the pkg-kde-commits
mailing list