summaryrefslogtreecommitdiffstats
path: root/amarok/src/podcastbundle.h
blob: f1e4fbe140d78a78b412a1e467b369bf0cb76783 (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
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
// (c) 2006 Seb Ruiz <me@sebruiz.net>
// See COPYING file for licensing information

#ifndef AMAROK_PODCASTBUNDLE_H
#define AMAROK_PODCASTBUNDLE_H

#include "podcastsettings.h"
#include <kurl.h>
#include <krfcdate.h>
#include <tqdatetime.h>

class PodcastChannelBundle
{
    public:
        PodcastChannelBundle()
            : m_parentId( -1 )
            , m_autoscan( false )
            , m_fetchType( -1 )
            , m_autotransfer( false )
            , m_purge( false )
            , m_purgeCount( -1 ) { }

        PodcastChannelBundle( const KURL &url, const TQString &title, const TQString &author, const KURL &link,
                              const TQString &desc,  const TQString &copy, PodcastSettings *settings )
        {   m_url = url;
            m_title = title;
            m_author = author;
            m_link = link;
            m_description = desc;
            m_copyright = copy;
            m_parentId = -1;
            setSettings( settings );
        }

        void setSettings( PodcastSettings *settings )
        {
            m_saveLocation = settings->saveLocation();
            m_autoscan     = settings->autoscan();
            m_fetchType    = settings->fetchType();
            m_autotransfer = settings->autoTransfer();
            m_purge        = settings->hasPurge();
            m_purgeCount   = settings->purgeCount();
        }

        PodcastSettings * getSettings()
        {
            return new PodcastSettings( m_title, m_saveLocation, m_autoscan, m_fetchType,
                                        m_autotransfer, m_purge, m_purgeCount );
        }

        /// Return the url of the podcast feed
        const KURL    &url()         const;
        /// The title of the Podcast channel
        const TQString &title()       const;
        /// The author of the Podcast channel
        const TQString &author()      const;
        /// A url to the webpage of the podcast
        const KURL    &link()        const;
        /// A url to the image of the podcast
        const KURL    &imageURL()    const;
        const TQString &description() const;
        const TQString &copyright()   const;
        /// The id which the parent folder has in the database
        int     parentId()    const;

        void    setURL( const KURL &u );
        void    setTitle( const TQString &t );
        void    setAuthor( const TQString &a );
        void    setLink( const KURL &l );
        void    setImageURL( const KURL &i );
        void    setDescription( const TQString &d );
        void    setCopyright( const TQString &c );
        void    setParentId( const int p );

        void    setSaveLocation( const TQString &s );
        void    setAutoScan( const bool b );
        void    setFetchType( const int i );
        void    setAutoTransfer( const bool b );
        void    setPurge( const bool b );
        void    setPurgeCount( const int i );

        //settings
        const TQString& saveLocation() const;
        bool autoscan()     const;
        int  fetchType()    const;
        bool autotransfer() const;
        bool hasPurge()     const;
        int  purgeCount()   const;

    private:
        KURL    m_url;
        TQString m_title;
        TQString m_author;
        KURL    m_link;
        KURL    m_imageUrl;
        TQString m_description;
        TQString m_copyright;
        int     m_parentId;

        TQString m_saveLocation;
        bool    m_autoscan;
        int     m_fetchType;
        bool    m_autotransfer;
        bool    m_purge;
        int     m_purgeCount;
};

inline const KURL    &PodcastChannelBundle::url()         const { return m_url; }
inline const TQString &PodcastChannelBundle::title()       const { return m_title; }
inline const TQString &PodcastChannelBundle::author()      const { return m_author; }
inline const KURL    &PodcastChannelBundle::link()        const { return m_link; }
inline const KURL    &PodcastChannelBundle::imageURL()    const { return m_imageUrl; }
inline const TQString &PodcastChannelBundle::description() const { return m_description; }
inline const TQString &PodcastChannelBundle::copyright()   const { return m_copyright; }
inline int     PodcastChannelBundle::parentId()    const { return m_parentId; }

inline void    PodcastChannelBundle::setURL         ( const KURL &u )    { m_url = u; }
inline void    PodcastChannelBundle::setTitle       ( const TQString &t ) { m_title = t; }
inline void    PodcastChannelBundle::setAuthor      ( const TQString &a ) { m_author = a; }
inline void    PodcastChannelBundle::setLink        ( const KURL &l )    { m_link = l; }
inline void    PodcastChannelBundle::setImageURL    ( const KURL &i )    { m_imageUrl = i; }
inline void    PodcastChannelBundle::setDescription ( const TQString &d ) { m_description = d; }
inline void    PodcastChannelBundle::setCopyright   ( const TQString &c ) { m_copyright = c; }
inline void    PodcastChannelBundle::setParentId    ( const int p )      { m_parentId = p; }

inline void    PodcastChannelBundle::setSaveLocation( const TQString &s ) { m_saveLocation = s; }
inline void    PodcastChannelBundle::setAutoScan( const bool b )         { m_autoscan = b; }
inline void    PodcastChannelBundle::setFetchType( const int i )         { m_fetchType = i; }
inline void    PodcastChannelBundle::setAutoTransfer( const bool b )     { m_autotransfer = b; }
inline void    PodcastChannelBundle::setPurge( const bool b )            { m_purge = b; }
inline void    PodcastChannelBundle::setPurgeCount( const int i )        { m_purgeCount = i; }

inline const TQString &PodcastChannelBundle::saveLocation() const { return m_saveLocation; }
inline bool    PodcastChannelBundle::autoscan()     const { return m_autoscan; }
inline int     PodcastChannelBundle::fetchType()    const { return m_fetchType; }
inline bool    PodcastChannelBundle::autotransfer() const { return m_autotransfer; }
inline bool    PodcastChannelBundle::hasPurge()     const { return m_purge; }
inline int     PodcastChannelBundle::purgeCount()   const { return m_purgeCount; }



class PodcastEpisodeBundle
{
    public:
        PodcastEpisodeBundle()
            : m_id( 0 )
            , m_duration( 0 )
            , m_size( 0 )
            , m_isNew( false )
        {
        }
        PodcastEpisodeBundle( const KURL &url,       const KURL &parent,  const TQString &title,
                              const TQString &author, const TQString &desc, const TQString &date,
                              const TQString &type,   const int duration,  const TQString &guid,
                              const bool isNew  )
            : m_id( 0 )
            , m_size( 0 )
        {
            m_url = url;
            m_parent = parent;
            m_author = author;
            m_title = title;
            m_description = desc;
            m_type = type;
            m_date = date;
            m_duration = duration < 0 ? 0 : duration;
            m_guid = guid;
            m_isNew = isNew;

            if( !date.isEmpty() )
                m_dateTime.setTime_t( KRFCDate::parseDate( date ) );
        }

        /// The row id which this podcast episode has in the database
        int     dBId()        const;
        /// The remote url to the podcast episode
        const KURL    &url()         const;
        /// The local url of the podcast episode (if it has been downloaded, an invalid url otherwise)
        const KURL    &localUrl()    const;
        /// The url of the podcast channel
        const KURL    &parent()      const;
        const TQString &author()      const;
        const TQString &title()       const;
        const TQString &subtitle()    const;
        const TQString &description() const;
        const TQString &date()        const;
        TQDateTime dateTime()  const;
        /// File type of the podcast episode, eg ogg, mp3 etc
        const TQString &type()        const;
        int     duration()    const; // duration in seconds
        uint    size()        const; // file/stream size in bytes
        /// unique identifier that should be available in the feed (RSS 2.0: guid ATOM: id)
        const TQString &guid()        const;
        /// Has this particular podcast episode been listened to?
        bool    isNew()       const;

        void    setDBId( const int i );
        void    setURL( const KURL &u );
        void    setLocalURL( const KURL &u );
        void    setParent( const KURL &u );
        void    setAuthor( const TQString &a );
        void    setTitle( const TQString &t );
        void    setSubtitle( const TQString &s );
        void    setDescription( const TQString &d );
        void    setDate( const TQString &d );
        void    setType( const TQString &t );
        void    setDuration( const int i );
        void    setSize( const uint i );
        void    setGuid( const TQString &g );
        void    setNew( const bool &b );

        void detach(); // for being able to apply TQDeepCopy<>

    private:
        int     m_id;
        KURL    m_url;
        KURL    m_localUrl;
        KURL    m_parent;
        TQString m_author;
        TQString m_title;
        TQString m_subtitle;
        TQString m_description;
        TQString m_date;
        TQDateTime m_dateTime;
        TQString m_type;
        int     m_duration;
        uint    m_size;
        TQString m_guid;
        bool    m_isNew;
};

inline int            PodcastEpisodeBundle::dBId()        const { return m_id; }
inline const KURL    &PodcastEpisodeBundle::url()         const { return m_url; }
inline const KURL    &PodcastEpisodeBundle::localUrl()    const { return m_localUrl; }
inline const KURL    &PodcastEpisodeBundle::parent()      const { return m_parent; }
inline const TQString &PodcastEpisodeBundle::author()      const { return m_author; }
inline const TQString &PodcastEpisodeBundle::title()       const { return m_title; }
inline const TQString &PodcastEpisodeBundle::subtitle()    const { return m_subtitle; }
inline const TQString &PodcastEpisodeBundle::description() const { return m_description; }
inline const TQString &PodcastEpisodeBundle::date()        const { return m_date; }
inline TQDateTime      PodcastEpisodeBundle::dateTime()    const { return m_dateTime; }
inline const TQString &PodcastEpisodeBundle::type()        const { return m_type; }
inline int            PodcastEpisodeBundle::duration()    const { return m_duration; }
inline uint           PodcastEpisodeBundle::size()        const { return m_size; }
inline const TQString &PodcastEpisodeBundle::guid()        const { return m_guid; }
inline bool           PodcastEpisodeBundle::isNew()       const { return m_isNew; }

inline void    PodcastEpisodeBundle::setDBId( const int i )             { m_id = i; }
inline void    PodcastEpisodeBundle::setURL( const KURL &u )            { m_url = u; }
inline void    PodcastEpisodeBundle::setLocalURL( const KURL &u )       { m_localUrl = u; }
inline void    PodcastEpisodeBundle::setParent( const KURL &u )         { m_parent = u; }
inline void    PodcastEpisodeBundle::setAuthor( const TQString &a )      { m_author = a; }
inline void    PodcastEpisodeBundle::setTitle( const TQString &t )       { m_title = t; }
inline void    PodcastEpisodeBundle::setSubtitle( const TQString &t )    { m_subtitle = t; }
inline void    PodcastEpisodeBundle::setDescription( const TQString &d ) { m_description = d; }
inline void    PodcastEpisodeBundle::setDate( const TQString &d )
               { m_date = d; if( !d.isEmpty() ) m_dateTime.setTime_t( KRFCDate::parseDate( d ) );}
inline void    PodcastEpisodeBundle::setType( const TQString &t )        { m_type = t; }
inline void    PodcastEpisodeBundle::setDuration( const int i )         { m_duration = i; }
inline void    PodcastEpisodeBundle::setSize( const uint i )            { m_size = i; }
inline void    PodcastEpisodeBundle::setGuid( const TQString &g )        { m_guid = g; }
inline void    PodcastEpisodeBundle::setNew( const bool &b )            { m_isNew = b; }

#endif /* AMAROK_PODCASTBUNDLE_H */