[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:21:03 UTC 2016
Gitweb-URL: http://git.debian.org/?p=pkg-kde/applications/ktp-text-ui.git;a=commitdiff;h=ccee120
The following commit has been merged in the master branch:
commit ccee120019543309e4758a4a97ddc35a95b36d4d
Author: Lasath Fernando <kde at lasath.org>
Date: Tue Jan 31 10:04:53 2012 +1100
Fix issues in Message and MessageProcessor. Move replaceMessageKeywords() into a filter.
---
lib/adium-theme-message-info.cpp | 16 +++----
lib/adium-theme-view.cpp | 96 ++++++++++++++++++++--------------------
lib/chat-widget.cpp | 7 ++-
lib/message-processor.cpp | 10 ++++-
lib/message-processor.h | 6 +--
lib/message.cpp | 5 ++-
6 files changed, 78 insertions(+), 62 deletions(-)
diff --git a/lib/adium-theme-message-info.cpp b/lib/adium-theme-message-info.cpp
index c5e0dfc..0c65268 100644
--- a/lib/adium-theme-message-info.cpp
+++ b/lib/adium-theme-message-info.cpp
@@ -71,14 +71,14 @@ AdiumThemeMessageInfo::MessageType AdiumThemeMessageInfo::type() const
QString AdiumThemeMessageInfo::message() const
{
- QString htmlMessage= Qt::escape(d->message);
- htmlMessage.replace(QLatin1String("
"), QLatin1String("<br/> ")); //keep leading whitespaces
- htmlMessage.replace(QLatin1Char('
'), QLatin1String("<br/>"));
- htmlMessage.replace(QLatin1Char(' '), QLatin1String(" ")); // replace tabs by 4 spaces
- htmlMessage.replace(QLatin1String(" "), QLatin1String(" ")); // keep multiple whitespaces
- htmlMessage.replace(QLatin1Char('\'), QLatin1String("\\")); //replace a single backslash with two backslashes.
-
- return htmlMessage;
+// QString htmlMessage= Qt::escape(d->message);
+// htmlMessage.replace(QLatin1String("
"), QLatin1String("<br/> ")); //keep leading whitespaces
+// htmlMessage.replace(QLatin1Char('
'), QLatin1String("<br/>"));
+// htmlMessage.replace(QLatin1Char(' '), QLatin1String(" ")); // replace tabs by 4 spaces
+// htmlMessage.replace(QLatin1String(" "), QLatin1String(" ")); // keep multiple whitespaces
+// htmlMessage.replace(QLatin1Char('\'), QLatin1String("\\")); //replace a single backslash with two backslashes.
+
+ return d->message;
}
void AdiumThemeMessageInfo::setMessage(const QString& message)
diff --git a/lib/adium-theme-view.cpp b/lib/adium-theme-view.cpp
index a0e7ac1..ef51945 100644
--- a/lib/adium-theme-view.cpp
+++ b/lib/adium-theme-view.cpp
@@ -415,54 +415,54 @@ QString AdiumThemeView::replaceMessageKeywords(QString &htmlTemplate, const Adiu
//message
QString message = info.message();
- // link detection
- QRegExp linkRegExp(QLatin1String("\b(?:(\w+)://|(www\.))([^\s]+)"));
- int index = 0;
-
- while ((index = linkRegExp.indexIn(message, index)) != -1) {
- QString realUrl = linkRegExp.cap(0);
- QString protocol = linkRegExp.cap(1);
-
- //if cap(1) is empty cap(2) was matched -> starts with www.
- const bool startsWithWWW = linkRegExp.cap(1).isEmpty();
-
- kDebug() << "Found URL " << realUrl << "with protocol : " << (startsWithWWW ? QLatin1String("http") : protocol);
-
-
- // if url has a supported protocol
- if (startsWithWWW || KProtocolInfo::protocols().contains(protocol, Qt::CaseInsensitive)) {
-
- // text not wanted in a link ( <,> )
- QRegExp unwanted(QLatin1String("(<|>)"));
-
- if (!realUrl.contains(unwanted)) {
- // string to show to user
- QString shownUrl = realUrl;
-
- // check for newline and cut link when found
- if (realUrl.contains(QLatin1String(("<br/>")))) {
- int findIndex = realUrl.indexOf(QLatin1String("<br/>"));
- realUrl.truncate(findIndex);
- shownUrl.truncate(findIndex);
- }
-
- // check prefix
- if (startsWithWWW) {
- realUrl.prepend(QLatin1String("http://"));
- }
-
- // if the url is changed, show in chat what the user typed in
- QString link = QLatin1String("<a href='") + realUrl + QLatin1String("'>") + shownUrl + QLatin1String("</a>");
- message.replace(index, shownUrl.length(), link);
- // advance position otherwise I end up parsing the same link
- index += link.length();
- } else {
- index += realUrl.length();
- }
- } else {
- index += linkRegExp.matchedLength();
- }
- }
+// // link detection
+// QRegExp linkRegExp(QLatin1String("\b(?:(\w+)://|(www\.))([^\s]+)"));
+// int index = 0;
+//
+// while ((index = linkRegExp.indexIn(message, index)) != -1) {
+// QString realUrl = linkRegExp.cap(0);
+// QString protocol = linkRegExp.cap(1);
+//
+// //if cap(1) is empty cap(2) was matched -> starts with www.
+// const bool startsWithWWW = linkRegExp.cap(1).isEmpty();
+//
+// kDebug() << "Found URL " << realUrl << "with protocol : " << (startsWithWWW ? QLatin1String("http") : protocol);
+//
+//
+// // if url has a supported protocol
+// if (startsWithWWW || KProtocolInfo::protocols().contains(protocol, Qt::CaseInsensitive)) {
+//
+// // text not wanted in a link ( <,> )
+// QRegExp unwanted(QLatin1String("(<|>)"));
+//
+// if (!realUrl.contains(unwanted)) {
+// // string to show to user
+// QString shownUrl = realUrl;
+//
+// // check for newline and cut link when found
+// if (realUrl.contains(QLatin1String(("<br/>")))) {
+// int findIndex = realUrl.indexOf(QLatin1String("<br/>"));
+// realUrl.truncate(findIndex);
+// shownUrl.truncate(findIndex);
+// }
+//
+// // check prefix
+// if (startsWithWWW) {
+// realUrl.prepend(QLatin1String("http://"));
+// }
+//
+// // if the url is changed, show in chat what the user typed in
+// QString link = QLatin1String("<a href='") + realUrl + QLatin1String("'>") + shownUrl + QLatin1String("</a>");
+// message.replace(index, shownUrl.length(), link);
+// // advance position otherwise I end up parsing the same link
+// index += link.length();
+// } else {
+// index += realUrl.length();
+// }
+// } else {
+// index += linkRegExp.matchedLength();
+// }
+// }
message = m_emoticons.theme().parseEmoticons(message);
htmlTemplate.replace(QLatin1String("%message%"), message);
diff --git a/lib/chat-widget.cpp b/lib/chat-widget.cpp
index 75acef0..b860ff7 100644
--- a/lib/chat-widget.cpp
+++ b/lib/chat-widget.cpp
@@ -46,6 +46,7 @@
#include <TelepathyQt/Presence>
#include <KTp/presence.h>
+#include "message-processor.h"
class ChatWidgetPrivate
{
@@ -68,6 +69,7 @@ public:
Ui::ChatWidget ui;
ChannelContactModel *contactModel;
LogManager *logManager;
+ MessageProcessor *messageProcessor;
KComponentData telepathyComponentData();
};
@@ -193,6 +195,9 @@ ChatWidget::ChatWidget(const Tp::TextChannelPtr & channel, const Tp::AccountPtr
d->logManager->setFetchAmount(3);
d->logManager->setTextChannel(d->account, d->channel);
}
+
+ //initialise message processor
+ d->messageProcessor = new MessageProcessor(this);
}
ChatWidget::~ChatWidget()
@@ -538,7 +543,7 @@ void ChatWidget::handleIncomingMessage(const Tp::ReceivedMessage &message)
} else {
AdiumThemeContentInfo messageInfo(AdiumThemeMessageInfo::RemoteToLocal);
- messageInfo.setMessage(message.text());
+ messageInfo.setMessage(d->messageProcessor->processIncommingMessage(message).finalizedMessage());
QDateTime time = message.sent();
if (!time.isValid()) {
diff --git a/lib/message-processor.cpp b/lib/message-processor.cpp
index e6a140c..3bb0353 100644
--- a/lib/message-processor.cpp
+++ b/lib/message-processor.cpp
@@ -18,11 +18,19 @@
#include "message-processor.h"
+#include "filters.h"
QList<AbstractMessageFilter*> MessageProcessor::m_filters;
-MessageProcessor::MessageProcessor()
+AbstractMessageFilter::~AbstractMessageFilter()
{
+
+}
+
+
+MessageProcessor::MessageProcessor(QObject* parent): QObject(parent)
+{
+ m_filters << new UrlFilter();
}
KTp::Message MessageProcessor::processIncommingMessage(Tp::ReceivedMessage receivedMessage)
diff --git a/lib/message-processor.h b/lib/message-processor.h
index c2bcfb0..50cacec 100644
--- a/lib/message-processor.h
+++ b/lib/message-processor.h
@@ -25,16 +25,16 @@
class AbstractMessageFilter {
public:
- virtual void filterMessage(KTp::Message) = 0;
+ virtual void filterMessage(KTp::Message&) = 0;
virtual ~AbstractMessageFilter();
};
//each thing that displays message will have an instance of this
-class MessageProcessor
+class MessageProcessor : public QObject
{
public:
- MessageProcessor();
+ explicit MessageProcessor(QObject* parent = 0);
~MessageProcessor();
//text-ui will call this somewhere in handleIncommingMessage just before displaying it
diff --git a/lib/message.cpp b/lib/message.cpp
index 9fff9c0..a227cba 100644
--- a/lib/message.cpp
+++ b/lib/message.cpp
@@ -18,6 +18,7 @@
#include "message.h"
+#include <KDebug>
using namespace KTp;
@@ -44,7 +45,9 @@ void Message::appendMessagePart(const QString& part)
QString Message::finalizedMessage() const
{
- return content.join(QLatin1String("
"));
+ QString msg = content.join(QLatin1String("
"));
+ kDebug() << msg;
+ return msg;
}
QVariantMap& Message::miscData()
--
ktp-text-ui packaging
More information about the pkg-kde-commits
mailing list