File indexing completed on 2024-05-05 05:13:10
0001 /* 0002 This file is part of Akregator. 0003 0004 SPDX-FileCopyrightText: 2005 Stanislav Karchebny <Stanislav.Karchebny@kdemail.net> 0005 SPDX-FileCopyrightText: 2005 Frank Osterfeld <osterfeld@kde.org> 0006 0007 SPDX-License-Identifier: GPL-2.0-or-later WITH Qt-Commercial-exception-1.0 0008 */ 0009 0010 #pragma once 0011 0012 #include "akregator_export.h" 0013 0014 #include <QObject> 0015 #include <memory> 0016 0017 #include "feedstorage.h" 0018 0019 namespace Akregator 0020 { 0021 namespace Backend 0022 { 0023 class AKREGATOR_EXPORT Storage : public QObject 0024 { 0025 Q_OBJECT 0026 public: 0027 Storage(); 0028 virtual ~Storage(); 0029 0030 /** KGlobal::dirs()->saveLocation("data", "akregator")+"/Archive" */ 0031 static QString defaultArchivePath(); 0032 0033 /** sets the directory where the metakit files will be stored. 0034 0035 @param archivePath the path to the archive, or QString() to reset it to the default. 0036 */ 0037 void setArchivePath(const QString &archivePath); 0038 0039 /** returns the path to the metakit archives */ 0040 QString archivePath() const; 0041 0042 /** 0043 * Open storage and prepare it for work. 0044 * @return true on success. 0045 */ 0046 bool open(bool autoCommit = false); 0047 0048 /** 0049 * Commit changes made in feeds and articles, making them persistent. 0050 * @return true on success. 0051 */ 0052 bool commit(); 0053 0054 /** 0055 * Rollback changes made in feeds and articles, reverting to last committed values. 0056 * @returns true on success. 0057 */ 0058 bool rollback(); 0059 0060 /** 0061 * Closes storage, freeing all allocated resources. Called from destructor, so you don't need to call it directly. 0062 * @return true on success. 0063 */ 0064 void close(); 0065 0066 /** 0067 * @return Article archive for feed at given url. 0068 */ 0069 FeedStorage *archiveFor(const QString &url); 0070 const FeedStorage *archiveFor(const QString &url) const; 0071 0072 bool autoCommit() const; 0073 0074 // API for FeedStorage to alter the feed index 'view' 0075 int unreadFor(const QString &url) const; 0076 void setUnreadFor(const QString &url, int unread); 0077 int totalCountFor(const QString &url) const; 0078 void setTotalCountFor(const QString &url, int total); 0079 QDateTime lastFetchFor(const QString &url) const; 0080 void setLastFetchFor(const QString &url, const QDateTime &lastFetch); 0081 0082 QStringList feeds() const; 0083 0084 void storeFeedList(const QString &opmlStr); 0085 QString restoreFeedList() const; 0086 0087 void markDirty(); 0088 0089 protected Q_SLOTS: 0090 void slotCommit(); 0091 0092 private: 0093 class StoragePrivate; 0094 std::unique_ptr<StoragePrivate> const d; 0095 }; 0096 } // namespace Backend 0097 } // namespace Akregator