File indexing completed on 2023-10-01 08:41:45
0001 /* 0002 Copyright (C) 2012 Lasath Fernando <kde@lasath.org> 0003 0004 This library is free software; you can redistribute it and/or 0005 modify it under the terms of the GNU Lesser General Public 0006 License as published by the Free Software Foundation; either 0007 version 2.1 of the License, or (at your option) any later version. 0008 0009 This library is distributed in the hope that it will be useful, 0010 but WITHOUT ANY WARRANTY; without even the implied warranty of 0011 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 0012 Lesser General Public License for more details. 0013 0014 You should have received a copy of the GNU Lesser General Public 0015 License along with this library; if not, write to the Free Software 0016 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 0017 */ 0018 0019 0020 #ifndef MESSAGE_PROCESSOR_H 0021 #define MESSAGE_PROCESSOR_H 0022 0023 #include <QObject> 0024 #include <QList> 0025 #include <QLoggingCategory> 0026 #include <KPluginInfo> 0027 0028 #include <KTp/message.h> 0029 #include <KTp/outgoing-message.h> 0030 0031 #include <KTp/ktpcommoninternals_export.h> 0032 #include <KTp/abstract-message-filter.h> 0033 0034 Q_DECLARE_LOGGING_CATEGORY(KTP_MESSAGEPROCESSOR) 0035 0036 namespace Tp 0037 { 0038 class ReceivedMessage; 0039 class Message; 0040 } 0041 0042 0043 namespace KTp 0044 { 0045 0046 class AbstractMessageFilter; 0047 0048 //each thing that displays message will have an instance of this 0049 class KTPCOMMONINTERNALS_EXPORT MessageProcessor : public QObject 0050 { 0051 Q_OBJECT 0052 0053 public: 0054 static MessageProcessor* instance(); 0055 ~MessageProcessor() override; 0056 0057 //text-ui will call this somewhere when creating the template 0058 QString header(); 0059 0060 //text-ui will call this somewhere in handleIncommingMessage just before displaying it 0061 KTp::Message processIncomingMessage(const Tp::Message &message, const Tp::AccountPtr &account, const Tp::TextChannelPtr &channel); 0062 KTp::Message processIncomingMessage(const Tp::ReceivedMessage &message, const Tp::AccountPtr &account, const Tp::TextChannelPtr &channel); 0063 0064 KTp::OutgoingMessage processOutgoingMessage(const QString &messageText, const Tp::AccountPtr &account, const Tp::TextChannelPtr &channel); 0065 0066 KTp::Message processIncomingMessage(KTp::Message message, const KTp::MessageContext &context); 0067 protected: 0068 explicit MessageProcessor(); 0069 0070 private: 0071 class Private; 0072 Private * const d; 0073 0074 friend class MessageFilterConfigManager; 0075 }; 0076 0077 } 0078 0079 #endif // MESSAGE_PROCESSOR_H