summaryrefslogtreecommitdiffstats
path: root/akregator/src/feedstorage.h
blob: eda8163d39013d6ce68832f888713ceb9d4ecd0b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
/*
    This file is part of Akregator.

    Copyright (C) 2005 Frank Osterfeld <frank.osterfeld@kdemail.net>

    This program is free software; you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation; either version 2 of the License, or
    (at your option) any later version.

    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with this program; if not, write to the Free Software
    Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.

    As a special exception, permission is given to link this program
    with any edition of Qt, and distribute the resulting executable,
    without including the source code for Qt in the source distribution.
*/
#ifndef AKREGATOR_BACKEND_FEEDSTORAGE_H
#define AKREGATOR_BACKEND_FEEDSTORAGE_H

#include <qobject.h>
#include <qstring.h>

#include "akregator_export.h"

class QStringList;


namespace Akregator {
namespace Backend {

/** a convenience class to handle categories in the backend */
class AKREGATOR_EXPORT Category 
{
    public:

    QString term;
    QString scheme;
    QString name;

    /** two categories are equal when scheme and term are equal, name is ignored */

    bool operator==(const Category& other) const
    {
        return term == other.term && scheme == other.scheme;
    }

    bool operator!=(const Category& other) const 
    { 
        return !operator==(other); 
    }
    /** we need this for QMaps */
    bool operator<(const Category& other) const
    {
        return other.scheme < other.scheme || (other.scheme == other.scheme && term < other.term);
    }
};

class Storage;

class AKREGATOR_EXPORT FeedStorage : public QObject
{
    public:
    
        virtual int unread() = 0;
        virtual void setUnread(int unread) = 0;
        virtual int totalCount() = 0;
        virtual int lastFetch() = 0;
        virtual void setLastFetch(int lastFetch) = 0;
        
        /** returns the guids of all articles in this storage. If a tagID is given, only articles with this tag are returned */
        virtual QStringList articles(const QString& tagID=QString::null) = 0;

        /** returns the guid of the articles in a given category */
        virtual QStringList articles(const Category& cat) = 0;

        /** Appends all articles from another storage. If there is already an article in this feed with the same guid, it is replaced by the article from the source
        @param source the archive which articles should be appended
        */
        virtual void add(FeedStorage* source) = 0;

        /** reads an article from another storage and adds it to this storage */
        virtual void copyArticle(const QString& guid, FeedStorage* source) = 0;

        /** deletes all articles from the archive */
        virtual void clear() = 0;

        
        virtual bool contains(const QString& guid) = 0;
        virtual void addEntry(const QString& guid) = 0;
        virtual void deleteArticle(const QString& guid) = 0;
        virtual int comments(const QString& guid) = 0;
        virtual QString commentsLink(const QString& guid) = 0;
        virtual void setCommentsLink(const QString& guid, const QString& commentsLink) = 0;
        virtual void setComments(const QString& guid, int comments) = 0;
        virtual bool guidIsHash(const QString& guid) = 0;
        virtual void setGuidIsHash(const QString& guid, bool isHash) = 0;
        virtual bool guidIsPermaLink(const QString& guid) = 0;
        virtual void setGuidIsPermaLink(const QString& guid, bool isPermaLink) = 0;
        virtual uint hash(const QString& guid) = 0;
        virtual void setHash(const QString& guid, uint hash) = 0;
        virtual void setDeleted(const QString& guid) = 0;
        virtual QString link(const QString& guid) = 0;
        virtual void setLink(const QString& guid, const QString& link) = 0;
        virtual uint pubDate(const QString& guid) = 0;
        virtual void setPubDate(const QString& guid, uint pubdate) = 0;
        virtual int status(const QString& guid) = 0;
        virtual void setStatus(const QString& guid, int status) = 0;
        virtual QString title(const QString& guid) = 0;
        virtual void setTitle(const QString& guid, const QString& title) = 0;
        virtual QString description(const QString& guid) = 0;
        virtual void setDescription(const QString& guid, const QString& description) = 0;

        virtual void addTag(const QString& guid, const QString& tag) = 0;
        virtual void removeTag(const QString& guid, const QString& tag) = 0;

        /** returns the tags of a given article. If @c guid is null, it returns all tags used in this feed */
        virtual QStringList tags(const QString& guid=QString::null) = 0;

        virtual void addCategory(const QString& guid, const Category& category) = 0;
        virtual QValueList<Category> categories(const QString& guid=QString::null) = 0;

        virtual void setEnclosure(const QString& guid, const QString& url, const QString& type, int length) = 0;
        virtual void removeEnclosure(const QString& guid) = 0;
        
        virtual void setAuthor(const QString& /*guid*/, const QString& /*author*/) {}
        virtual QString author(const QString& /*guid*/) { return QString(); }
        
        virtual void enclosure(const QString& guid, bool& hasEnclosure, QString& url, QString& type, int& length) = 0;
        virtual void close() = 0;
        virtual void commit() = 0;
        virtual void rollback() = 0;
    
        virtual void convertOldArchive() = 0;
};

}
}

#endif