File indexing completed on 2023-12-03 08:28:34
0001 /* 0002 Copyright (C) 2011 Dominik Schmidt <kde@dominik-schmidt.de> 0003 Copyright (C) 2013 Daniel Vrátil <dvratil@redhat.com> 0004 0005 This library is free software; you can redistribute it and/or 0006 modify it under the terms of the GNU Lesser General Public 0007 License as published by the Free Software Foundation; either 0008 version 2.1 of the License, or (at your option) any later version. 0009 0010 This library is distributed in the hope that it will be useful, 0011 but WITHOUT ANY WARRANTY; without even the implied warranty of 0012 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 0013 Lesser General Public License for more details. 0014 0015 You should have received a copy of the GNU Lesser General Public 0016 License along with this library; if not, write to the Free Software 0017 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 0018 */ 0019 0020 0021 #ifndef SCROLLBACKMANAGER_H 0022 #define SCROLLBACKMANAGER_H 0023 0024 #include <KTp/message.h> 0025 0026 namespace KTp { 0027 class PendingLoggerOperation; 0028 } 0029 0030 class KTPCOMMONINTERNALS_EXPORT ScrollbackManager : public QObject 0031 { 0032 Q_OBJECT 0033 0034 public: 0035 explicit ScrollbackManager(QObject *parent = nullptr); 0036 ~ScrollbackManager() override; 0037 0038 bool exists() const; 0039 0040 void setTextChannel(const Tp::AccountPtr &account, const Tp::TextChannelPtr &textChannel); 0041 0042 /** 0043 * This is an alternative for setTextChannel() to allow for offline scrollback 0044 * 0045 * @param account The account of the contact 0046 * @param contactId id of the contact for which the screollback is requested 0047 */ 0048 void setAccountAndContact(const Tp::AccountPtr &account, const QString &contactId, const QString &contactAlias = QString()); 0049 0050 /** 0051 * Sets amount of messages to be fetched via @p fetchScrollback() 0052 */ 0053 void setScrollbackLength(int n); 0054 0055 int scrollbackLength() const; 0056 0057 /** 0058 * Fetches last N message,s as set via setFetchAmount() 0059 */ 0060 void fetchScrollback(); 0061 0062 /** 0063 * Fetches last @p n messages 0064 * If @p fromMessageToken is specified, it fetches last @p n messages 0065 * from the message with the given token 0066 */ 0067 void fetchHistory(int n, const QString &fromMessageToken = QString()); 0068 0069 Q_SIGNALS: 0070 void fetched(const QList<KTp::Message> &messages); 0071 0072 private Q_SLOTS: 0073 void onDatesFinished(KTp::PendingLoggerOperation *po); 0074 void onEventsFinished(KTp::PendingLoggerOperation *po); 0075 0076 private: 0077 class Private; 0078 Private * const d; 0079 }; 0080 0081 #endif // SCROLLBACKMANAGER_H