[SCM] ktp-common-internals packaging branch, master, updated. debian/15.12.1-2-1839-gf0635e9

Maximiliano Curia maxy at moszumanska.debian.org
Mon May 9 09:06:36 UTC 2016


Gitweb-URL: http://git.debian.org/?p=pkg-kde/applications/ktp-common-internals.git;a=commitdiff;h=71c92b3

The following commit has been merged in the master branch:
commit 71c92b36407a1d66c19e066b0f0c7b7fef89615c
Author: David Edmundson <kde at davidedmundson.co.uk>
Date:   Mon Mar 11 00:59:32 2013 +0000

    Add a new class for processing outgoing messages
    
    Currently we re-use KTp::Message, this exposes a lot of setters and getters that have no use before we send a message.
    It also mixes HTML and plain text which has already led to one bug, and would probably lead to more.
    
    This keeps the API cleaner and simpler
    
    REVIEW: 109403
---
 CMakeLists.txt                  |  2 +-
 KTp/CMakeLists.txt              |  2 ++
 KTp/abstract-message-filter.cpp |  2 +-
 KTp/abstract-message-filter.h   |  4 ++-
 KTp/message-processor.cpp       |  4 +--
 KTp/message-processor.h         |  4 ++-
 KTp/outgoing-message.cpp        | 80 +++++++++++++++++++++++++++++++++++++++++
 KTp/outgoing-message.h          | 71 ++++++++++++++++++++++++++++++++++++
 8 files changed, 163 insertions(+), 6 deletions(-)

diff --git a/CMakeLists.txt b/CMakeLists.txt
index 323afb3..0bb010a 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -10,7 +10,7 @@ set (CMAKE_MODULE_PATH
 set (KTP_VERSION "0.5.80")
 # Bump for every 0.x release, or whenever BC changes
 set (KTP_SONUMBER 5)
-set (KTP_MESSAGE_FILTER_FRAMEWORK_VERSION "3")
+set (KTP_MESSAGE_FILTER_FRAMEWORK_VERSION "4")
 
 find_package (KDE4 REQUIRED)
 find_package (TelepathyQt4 0.9.2.1 REQUIRED)
diff --git a/KTp/CMakeLists.txt b/KTp/CMakeLists.txt
index 4484255..def690d 100644
--- a/KTp/CMakeLists.txt
+++ b/KTp/CMakeLists.txt
@@ -22,6 +22,7 @@ set (ktp_common_internals_private_SRCS
      message-filter-config-manager.cpp
      message-processor.cpp
      message-url-filter.cpp
+     outgoing-message.cpp
      persistent-contact.cpp
      presence.cpp
      service-availability-checker.cpp
@@ -48,6 +49,7 @@ set (ktp_common_internals_private_HDRS
      message.h
      message-context.h
      message-processor.h
+     outgoing-message.h
      persistent-contact.h
      presence.h
      service-availability-checker.h
diff --git a/KTp/abstract-message-filter.cpp b/KTp/abstract-message-filter.cpp
index 06d805d..29323bb 100644
--- a/KTp/abstract-message-filter.cpp
+++ b/KTp/abstract-message-filter.cpp
@@ -46,7 +46,7 @@ QStringList AbstractMessageFilter::requiredStylesheets()
     return QStringList();
 }
 
-void AbstractMessageFilter::filterOutgoingMessage(Message &message, const MessageContext &context)
+void AbstractMessageFilter::filterOutgoingMessage(KTp::OutgoingMessage &message, const MessageContext &context)
 {
     Q_UNUSED(message)
     Q_UNUSED(context)
diff --git a/KTp/abstract-message-filter.h b/KTp/abstract-message-filter.h
index cf26907..4749616 100644
--- a/KTp/abstract-message-filter.h
+++ b/KTp/abstract-message-filter.h
@@ -20,6 +20,8 @@
 #define KTP_ABSTRACT_MESSAGE_FILTER_H
 
 #include <KTp/message.h>
+#include <KTp/outgoing-message.h>
+
 #include <KTp/message-context.h>
 #include <KTp/ktp-export.h>
 
@@ -47,7 +49,7 @@ class KTP_EXPORT AbstractMessageFilter : public QObject
     virtual QStringList requiredStylesheets();
 
     /** Filter composed messages about to be sent to telepathy backend */
-    virtual void filterOutgoingMessage(KTp::Message &message, const KTp::MessageContext &context);
+    virtual void filterOutgoingMessage(KTp::OutgoingMessage &message, const KTp::MessageContext &context);
 };
 
 }
diff --git a/KTp/message-processor.cpp b/KTp/message-processor.cpp
index 2e252f9..d4d1e8c 100644
--- a/KTp/message-processor.cpp
+++ b/KTp/message-processor.cpp
@@ -186,10 +186,10 @@ KTp::Message MessageProcessor::processIncomingMessage(KTp::Message message, cons
     return message;
 }
 
-KTp::Message MessageProcessor::processOutgoingMessage(const QString &messageText, const Tp::AccountPtr &account, const Tp::TextChannelPtr &channel)
+KTp::OutgoingMessage MessageProcessor::processOutgoingMessage(const QString &messageText, const Tp::AccountPtr &account, const Tp::TextChannelPtr &channel)
 {
     KTp::MessageContext context(account, channel);
-    KTp::Message message(messageText, context);
+    KTp::OutgoingMessage message(messageText);
 
     Q_FOREACH (AbstractMessageFilter *filter, d->filters) {
         kDebug() << "running outgoing filter : " << filter->metaObject()->className();
diff --git a/KTp/message-processor.h b/KTp/message-processor.h
index a22fc70..acbcd20 100644
--- a/KTp/message-processor.h
+++ b/KTp/message-processor.h
@@ -25,6 +25,8 @@
 #include <KPluginInfo>
 
 #include <KTp/message.h>
+#include <KTp/outgoing-message.h>
+
 #include <KTp/ktp-export.h>
 #include <KTp/abstract-message-filter.h>
 #include <TelepathyLoggerQt4/Types>
@@ -58,7 +60,7 @@ class KTP_EXPORT MessageProcessor : public QObject
     KTp::Message processIncomingMessage(const Tp::ReceivedMessage &message, const Tp::AccountPtr &account, const Tp::TextChannelPtr &channel);
     KTp::Message processIncomingMessage(const Tpl::TextEventPtr &message, const Tp::AccountPtr &account, const Tp::TextChannelPtr &channel);
 
-    KTp::Message processOutgoingMessage(const QString &messageText, const Tp::AccountPtr &account, const Tp::TextChannelPtr &channel);
+    KTp::OutgoingMessage processOutgoingMessage(const QString &messageText, const Tp::AccountPtr &account, const Tp::TextChannelPtr &channel);
 
   protected:
     KTp::Message processIncomingMessage(KTp::Message message, const KTp::MessageContext &context);
diff --git a/KTp/outgoing-message.cpp b/KTp/outgoing-message.cpp
new file mode 100644
index 0000000..055017e
--- /dev/null
+++ b/KTp/outgoing-message.cpp
@@ -0,0 +1,80 @@
+/*
+    Copyright (C) 2013 David Edmundson <kde at davidedmundson.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 Street, Fifth Floor, Boston, MA  02110-1301  USA
+*/
+
+
+#include "outgoing-message.h"
+
+#include <KDebug>
+#include <QSharedData>
+
+#include <TelepathyQt/ContactManager>
+#include <TelepathyQt/Connection>
+
+#include <TelepathyLoggerQt4/Entity>
+
+using namespace KTp;
+
+class OutgoingMessage::Private : public QSharedData {
+
+  public:
+    Private() {
+        messageType = Tp::ChannelTextMessageTypeNormal;
+    }
+    QString text;
+    Tp::ChannelTextMessageType messageType;
+};
+
+OutgoingMessage::OutgoingMessage(const OutgoingMessage &other):
+    d(other.d)
+{
+}
+
+OutgoingMessage& OutgoingMessage::operator=(const OutgoingMessage &other) {
+    d = other.d;
+    return *this;
+}
+
+OutgoingMessage::OutgoingMessage(const QString &messageText) :
+    d(new Private)
+{
+    setText(messageText);
+}
+
+OutgoingMessage::~OutgoingMessage()
+{
+}
+
+QString OutgoingMessage::text() const
+{
+    return d->text;
+}
+
+void OutgoingMessage::setText(const QString &text)
+{
+    d->text = text;
+}
+
+Tp::ChannelTextMessageType OutgoingMessage::type() const
+{
+    return d->messageType;
+}
+
+void OutgoingMessage::setType(Tp::ChannelTextMessageType type)
+{
+    d->messageType = type;
+}
diff --git a/KTp/outgoing-message.h b/KTp/outgoing-message.h
new file mode 100644
index 0000000..8ffa2cf
--- /dev/null
+++ b/KTp/outgoing-message.h
@@ -0,0 +1,71 @@
+/*
+    Copyright (C) 2013  David Edmundson <kde at davidedmundson.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 Street, Fifth Floor, Boston, MA  02110-1301  USA
+*/
+
+
+#ifndef KTP_OUTGOING_MESSAGE_H
+#define KTP_OUTGOING_MESSAGE_H
+
+#include <KTp/ktp-export.h>
+#include <KTp/message-context.h>
+
+#include <TelepathyQt/Types>
+
+#include <QSharedData>
+#include <QSharedDataPointer>
+
+namespace KTp
+{
+
+/*!
+ * \par
+ * An encapsualtion of a message that is to be sent out
+ *
+ * uthor David Edmundson <kde at davidedmundson.co.uk>
+ */
+class KTP_EXPORT OutgoingMessage
+{
+  public:
+    OutgoingMessage(const KTp::OutgoingMessage &other);
+    KTp::OutgoingMessage& operator=(const KTp::OutgoingMessage &other);
+    virtual ~OutgoingMessage();
+
+    /*! rief The body of the message
+     * 
eturn the contents of the message as a plain string
+     */
+    QString text() const;
+
+    void setText(const QString &text);
+
+    void setType(Tp::ChannelTextMessageType type);
+
+    Tp::ChannelTextMessageType type() const;
+
+
+protected:
+    explicit OutgoingMessage(const QString &messageText);
+
+private:
+    class Private;
+    QSharedDataPointer<Private> d;
+    friend class MessageProcessor;
+};
+
+}
+
+
+#endif // KTP_PENDING_SEND_MESSAGE_H

-- 
ktp-common-internals packaging



More information about the pkg-kde-commits mailing list