File indexing completed on 2023-12-03 08:28:33
0001 /* 0002 * Copyright (C) 2013 Daniel Vrátil <dvratil@redhat.com> 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 St, Fifth Floor, Boston, MA 02110-1301 USA 0017 * 0018 */ 0019 0020 #ifndef KTP_LOGMANAGER_H 0021 #define KTP_LOGMANAGER_H 0022 0023 #include <KTp/Logger/abstract-logger-plugin.h> 0024 #include <KTp/ktpcommoninternals_export.h> 0025 0026 #include <TelepathyQt/Types> 0027 0028 namespace KTp { 0029 0030 class LogEntity; 0031 0032 class PendingLoggerOperation; 0033 class PendingLoggerDates; 0034 class PendingLoggerLogs; 0035 class PendingLoggerEntities; 0036 0037 /** 0038 * Log manager is a singleton that user can use to query the logs. 0039 * 0040 * @since 0.7 0041 * @author Daniel Vrátil <dvratil@redhat.com> 0042 */ 0043 class KTPCOMMONINTERNALS_EXPORT LogManager : public AbstractLoggerPlugin 0044 { 0045 Q_OBJECT 0046 0047 public: 0048 /** 0049 * Returns global instance of the LogManager. 0050 */ 0051 static KTp::LogManager* instance(); 0052 0053 /** 0054 * Sets a new Tp::AccountManager to be used by the LogManager. 0055 * 0056 * The @p accountManager is expected to be in ready state. 0057 * 0058 * @param accountManager An Tp::AccountManager in the ready state. 0059 */ 0060 void setAccountManager(const Tp::AccountManagerPtr &accountManager) override; 0061 0062 /** 0063 * Returns the set Tp::AccountManager or an empty pointer if none was set. 0064 */ 0065 Tp::AccountManagerPtr accountManager() const override; 0066 0067 /** 0068 * Queries all available plugins for list of dates with logs of user's chat 0069 * with @p entity. 0070 * 0071 * @param account Account to query 0072 * @param entity Entity 0073 * @return Returns KTp::PendingLoggerDates operation that will emit finished() 0074 * signal when all backends are finished. 0075 */ 0076 KTp::PendingLoggerDates* queryDates(const Tp::AccountPtr &account, 0077 const KTp::LogEntity &entity) override; 0078 0079 /** 0080 * Queries all available plugins for list of logs of chats with @p entity. 0081 * 0082 * @param account Account to query 0083 * @param entity Entity whose logs should be retrieved 0084 * @param date Specific date for which to retrieve logs 0085 * @return Returns KTp::PendingLoggerLogs operation that will emit finished() 0086 * signal when all backends are finished. 0087 */ 0088 KTp::PendingLoggerLogs* queryLogs(const Tp::AccountPtr &account, 0089 const KTp::LogEntity &entity, 0090 const QDate &date) override; 0091 0092 /** 0093 * Queries all available plugins for list of entities for which they have 0094 * conversation logs. 0095 * 0096 * @param account Account to query 0097 * @return Returns KTp::PendingLoggerEntities operation that will emit finished() 0098 * signal when all backends are finished. 0099 */ 0100 KTp::PendingLoggerEntities* queryEntities(const Tp::AccountPtr &account) override; 0101 0102 /** 0103 * Removes all logs for given @p account from all available plugins that 0104 * handle it. 0105 * 0106 * @param account Account of which to remove logs 0107 */ 0108 void clearAccountLogs(const Tp::AccountPtr &account) override; 0109 0110 /** 0111 * Removes all logs for given @p entity from all available plugins that 0112 * handle the @p account. 0113 * 0114 * @param account Account to query 0115 * @param entity Entity whose logs to remove 0116 */ 0117 void clearContactLogs(const Tp::AccountPtr &account, 0118 const KTp::LogEntity &entity) override; 0119 0120 /** 0121 * Searches all logs for given @p term. 0122 * 0123 * @param term Term to search 0124 * @return Returns KTp::PendingLoggerSearch operation that will emit finished() 0125 * signal when search is finished. 0126 */ 0127 KTp::PendingLoggerSearch* search(const QString &term) override; 0128 0129 /** 0130 * Checks whether there are any logs for given @p account and @p contact. 0131 * 0132 * For easy use this method is synchronous and can block in case of a slower 0133 * plugin. 0134 * 0135 * @param account Account to query 0136 * @param contact Contact to query 0137 * @return Returns whether there are any logs for given person 0138 */ 0139 bool logsExist(const Tp::AccountPtr &account, const KTp::LogEntity &contact) override; 0140 0141 /** 0142 * Destructor. 0143 */ 0144 ~LogManager() override; 0145 0146 private: 0147 explicit LogManager(); 0148 0149 class Private; 0150 Private * const d; 0151 0152 friend class PendingLoggerOperation; 0153 0154 }; 0155 0156 } // namespace KTp 0157 0158 #endif // KTP_LOGMANAGER_H