[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:28 UTC 2016
Gitweb-URL: http://git.debian.org/?p=pkg-kde/applications/ktp-text-ui.git;a=commitdiff;h=8e17628
The following commit has been merged in the master branch:
commit 8e176284f8c15b451a92f7026b03d566d5d89780
Author: Lasath Fernando <kde at lasath.org>
Date: Sun Feb 10 01:54:12 2013 +0000
Add a new filter that turns messages containg bugzilla bug URL's into displaying the full title + status
---
filters/bugzilla/CMakeLists.txt | 25 +++++
filters/bugzilla/bugzilla-filter.cpp | 115 +++++++++++++++++++++
.../bugzilla-filter.h} | 18 ++--
.../ktptextui_message_filter_bugzilla.desktop | 13 +++
4 files changed, 163 insertions(+), 8 deletions(-)
diff --git a/filters/bugzilla/CMakeLists.txt b/filters/bugzilla/CMakeLists.txt
new file mode 100644
index 0000000..aeb6cd9
--- /dev/null
+++ b/filters/bugzilla/CMakeLists.txt
@@ -0,0 +1,25 @@
+find_package(QJSON REQUIRED)
+
+set (ktptextui_message_filter_bugzilla_SRCS
+ bugzilla-filter.cpp
+)
+
+kde4_add_plugin (ktptextui_message_filter_bugzilla
+ ${ktptextui_message_filter_bugzilla_SRCS}
+)
+
+target_link_libraries (ktptextui_message_filter_bugzilla
+ ktpchat
+ ${QT_LIBRARIES}
+ ${QJSON_LIBRARIES}
+ ${KDE4_KIO_LIBS}
+)
+
+# Install:
+install (TARGETS ktptextui_message_filter_bugzilla
+ DESTINATION ${PLUGIN_INSTALL_DIR}
+)
+
+install (FILES ktptextui_message_filter_bugzilla.desktop
+ DESTINATION ${SERVICES_INSTALL_DIR}
+)
diff --git a/filters/bugzilla/bugzilla-filter.cpp b/filters/bugzilla/bugzilla-filter.cpp
new file mode 100644
index 0000000..d7f8dfe
--- /dev/null
+++ b/filters/bugzilla/bugzilla-filter.cpp
@@ -0,0 +1,115 @@
+/*
+ * 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 "bugzilla-filter.h"
+
+#include <qjson/parser.h>
+
+#include <KPluginFactory>
+#include <KDebug>
+#include <KUrl>
+#include <KUriFilter>
+#include <KIO/Job>
+#include <QTextDocument>
+
+class BugzillaFilter::Private
+{
+public:
+ QRegExp bugText;
+ QString sectionTemplate;
+};
+
+BugzillaFilter::BugzillaFilter(QObject *parent, const QVariantList &) :
+ AbstractMessageFilter(parent), d(new Private)
+{
+ d->bugText = QRegExp(QLatin1String("BUG:[ ]*(\d+)"));
+ d->sectionTemplate = QLatin1String("[BUG <a href='%1'>%2</a>] %3");
+}
+
+BugzillaFilter::~BugzillaFilter()
+{
+ delete d;
+}
+
+void BugzillaFilter::addBugDescription(Message &msg, KUrl &baseUrl) {
+ KUrl request;
+ request.setHost(baseUrl.host());
+ request.setProtocol(baseUrl.protocol());
+ request.setDirectory(baseUrl.directory());
+ request.setFileName(QLatin1String("jsonrpc.cgi"));
+
+ request.addQueryItem(QLatin1String("method"), QLatin1String("Bug.get"));
+ request.addQueryItem(QLatin1String("params"),
+ QString(QLatin1String("[{\"ids\":[%1]}]")).
+ arg(baseUrl.queryItemValue(QLatin1String("id"))));
+
+ kDebug() << request;
+ KIO::StoredTransferJob *job = KIO::storedGet(request);
+ job->exec();
+
+ QVariantMap response = QJson::Parser().parse(job->data()).toMap();
+ if (response.contains(QLatin1String("result"))) {
+ QVariantMap result = response.value(QLatin1String("result")).toMap();
+ if (result.contains(QLatin1String("bugs"))) {
+ QVariantList bugs = result.value(QLatin1String("bugs")).toList();
+ if (!bugs.isEmpty()) {
+ QVariantMap bug = bugs.first().toMap();
+ if (bug.contains(QLatin1String("summary"))) {
+ QString summary = bug.value(QLatin1String("summary")).toString();
+ kDebug() << summary;
+
+ msg.appendMessagePart(d->sectionTemplate
+ .arg(baseUrl.url())
+ .arg(Qt::escape(baseUrl.queryItemValue(QLatin1String("id"))))
+ .arg(Qt::escape(summary)));
+ }
+ }
+ }
+ }
+
+}
+
+void BugzillaFilter::filterMessage(Message &message)
+{
+ QString msg = message.mainMessagePart();
+ int index = msg.indexOf(d->bugText);
+ while (index >= 0) {
+ KUrl baseUrl;
+ baseUrl.setProtocol(QLatin1String("https"));
+ baseUrl.setHost(QLatin1String("bugs.kde.org"));
+ baseUrl.setFileName(QLatin1String("show_bug.cgi"));
+ baseUrl.addQueryItem(QLatin1String("id"), d->bugText.cap(1));
+
+ addBugDescription(message, baseUrl);
+ index = msg.indexOf(d->bugText, index + 1);
+ }
+
+ Q_FOREACH (QVariant var, message.property("Urls").toList()) {
+ KUrl url = qvariant_cast<KUrl>(var);
+
+ if (url.fileName() == QLatin1String("show_bug.cgi")) { //a bugzilla of some sort
+ kDebug() << "link is to a bugzilla:" << url.host();
+
+ //by using the host from the link, it will work with *any* bugzilla installation
+ addBugDescription(message, url);
+ }
+ }
+}
+
+K_PLUGIN_FACTORY(MessageFilterFactory, registerPlugin<BugzillaFilter>();)
+K_EXPORT_PLUGIN(MessageFilterFactory("ktptextui_message_filter_bugzilla"))
diff --git a/filters/highlight/highlight-filter.h b/filters/bugzilla/bugzilla-filter.h
similarity index 71%
copy from filters/highlight/highlight-filter.h
copy to filters/bugzilla/bugzilla-filter.h
index 0725e06..edc3fa8 100644
--- a/filters/highlight/highlight-filter.h
+++ b/filters/bugzilla/bugzilla-filter.h
@@ -16,23 +16,25 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
-#ifndef HIGHLIGHT_FILTER_H
-#define HIGHLIGHT_FILTER_H
+#ifndef BUGZILLA_FILTER_H
+#define BUGZILLA_FILTER_H
-#include <KTp/abstract-message-filter.h>
+#include <KTp/AbstractMessageFilter>
-class HighlightFilter : public KTp::AbstractMessageFilter
+class BugzillaFilter : public AbstractMessageFilter
{
Q_OBJECT
public:
- HighlightFilter(QObject *parent, const QVariantList &args);
- virtual ~HighlightFilter();
- virtual void filterMessage(KTp::Message &message, const KTp::MessageContext &context);
+ BugzillaFilter(QObject *parent, const QVariantList &);
+ virtual ~BugzillaFilter();
+
+ virtual void filterMessage(Message &message);
+ void addBugDescription(Message &msg, KUrl &baseUrl);
private:
class Private;
Private *d;
};
-#endif // HIGHLIGHT_FILTER_H
+#endif // BUGZILLA_FILTER_H
diff --git a/filters/bugzilla/ktptextui_message_filter_bugzilla.desktop b/filters/bugzilla/ktptextui_message_filter_bugzilla.desktop
new file mode 100644
index 0000000..75dcd9a
--- /dev/null
+++ b/filters/bugzilla/ktptextui_message_filter_bugzilla.desktop
@@ -0,0 +1,13 @@
+[Desktop Entry]
+Encoding=UTF-8
+Type=Service
+ServiceTypes=KTpTextUi/MessageFilter
+
+X-KDE-Library=ktptextui_message_filter_bugzilla
+X-KDE-PluginInfo-Author=Lasath Fernando
+X-KDE-PluginInfo-Email=kde at lasath.org
+X-KDE-PluginInfo-Name=bugzilla
+X-KDE-PluginInfo-Version=0.4
+X-KDE-PluginInfo-Website=http://community.kde.org/Real-Time_Communication_and_Collaboration
+X-KDE-PluginInfo-License=GPL
+X-KDE-PluginInfo-EnabledByDefault=true
--
ktp-text-ui packaging
More information about the pkg-kde-commits
mailing list