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_ABSTRACTLOGGERPLUGIN_H 0021 #define KTP_ABSTRACTLOGGERPLUGIN_H 0022 0023 #include <QtCore/QObject> 0024 0025 #include <KTp/ktpcommoninternals_export.h> 0026 0027 #include <TelepathyQt/Types> 0028 0029 namespace KTp { 0030 0031 class PendingLoggerDates; 0032 class PendingLoggerLogs; 0033 class PendingLoggerEntities; 0034 class PendingLoggerSearch; 0035 class LogEntity; 0036 0037 /** 0038 * @brief An interface for all KTp Logger plugins 0039 * 0040 * @since 0.7 0041 * @author Daniel Vrátil <dvratil@redhat.com> 0042 */ 0043 class KTPCOMMONINTERNALS_EXPORT AbstractLoggerPlugin : public QObject 0044 { 0045 Q_OBJECT 0046 0047 public: 0048 /** 0049 * Constructor. 0050 */ 0051 explicit AbstractLoggerPlugin(QObject *parent = nullptr); 0052 0053 /** 0054 * Destructor. 0055 */ 0056 ~AbstractLoggerPlugin() override; 0057 0058 /** 0059 * Queries all available plugins that handle given @p account for list of dates 0060 * with logs of user's chat with @p entity. 0061 * 0062 * @param account Account to query 0063 * @param entity Entity 0064 * @return Returns KTp::PendingLoggerDates operation that will emit finished() 0065 * signal when all backends are finished. 0066 */ 0067 virtual KTp::PendingLoggerDates* queryDates(const Tp::AccountPtr &account, 0068 const KTp::LogEntity &entity) = 0; 0069 0070 /** 0071 * Queries all available plugins that handle given @p account for list of 0072 * logs of chats with @p entity. 0073 * 0074 * @param account Account to query 0075 * @param entity Entity whose logs should be retrieved 0076 * @param date Specific date for which to retrieve logs 0077 * @return Returns KTp::PendingLoggerLogs operation that will emit finished() 0078 * signal when all backends are finished. 0079 */ 0080 virtual KTp::PendingLoggerLogs* queryLogs(const Tp::AccountPtr &account, 0081 const KTp::LogEntity &entity, 0082 const QDate &date) = 0; 0083 0084 /** 0085 * Queries all available plugins that handle given @p account for list of 0086 * entities for which they have conversation logs. 0087 * 0088 * @param account Account to query 0089 * @return Returns KTp::PendingLoggerEntities operation that will emit finished() 0090 * signal when all backends are finished. 0091 */ 0092 virtual KTp::PendingLoggerEntities* queryEntities(const Tp::AccountPtr &account) = 0; 0093 0094 /** 0095 * Returnes whether plugin handles logs for given @p account. 0096 * 0097 * For example, a dedicated Facebook plugin will handle only accounts that 0098 * represent Facebook accounts, therefore it makes no sense to query it for 0099 * logs from GTalk account for instance. 0100 * 0101 * By default this method returns true, which means that plugin supports any 0102 * kind of account. 0103 */ 0104 virtual bool handlesAccount(const Tp::AccountPtr &account); 0105 0106 /** 0107 * Removes all logs for given @p account from all available plugins that 0108 * handle it. 0109 * 0110 * @param account Account of which to remove logs 0111 */ 0112 virtual void clearAccountLogs(const Tp::AccountPtr &account) = 0; 0113 0114 /** 0115 * Removes all logs for given @p entity from all available plugins that 0116 * handle the @p account. 0117 * 0118 * @param account Account to query 0119 * @param entity Entity whose logs to remove 0120 */ 0121 virtual void clearContactLogs(const Tp::AccountPtr &account, 0122 const KTp::LogEntity &entity) = 0; 0123 0124 /** 0125 * Searches all logs for given @p term. 0126 * 0127 * @param term Term to search 0128 * @return Returns KTp::PendingLoggerSearch operation that will emit finished() 0129 * when all results are available 0130 */ 0131 virtual KTp::PendingLoggerSearch* search(const QString &term) = 0; 0132 0133 /** 0134 * Sets a new Tp::AccountManager to be used by the plugin. 0135 * 0136 * The @p accountManager is expected to be in ready state. 0137 * 0138 * @param accountManager An Tp::AccountManager in the ready state. 0139 */ 0140 virtual void setAccountManager(const Tp::AccountManagerPtr &accountManager); 0141 0142 /** 0143 * Returns the set Tp::AccountManager or an empty pointer if none was set. 0144 */ 0145 virtual Tp::AccountManagerPtr accountManager() const; 0146 0147 /** 0148 * Checks whether there are any logs for given @p account and @p contact. 0149 * 0150 * For easy use this method is synchronous and can block for a while in case 0151 * of a slower plugin. 0152 * 0153 * @param account Account to query 0154 * @param contact Contact to query 0155 * @return Returns whether there are any logs for given person 0156 */ 0157 virtual bool logsExist(const Tp::AccountPtr &account, const KTp::LogEntity &contact) = 0; 0158 0159 private: 0160 class Private; 0161 Private * const d; 0162 }; 0163 0164 } // namespace KTp 0165 0166 #endif // KTP_ABSTRACTLOGGERPLUGIN_H