1 /****************************************************************************************
2  * Copyright (c) 2010-2012 Leo Franchi <lfranchi@kde.org>                               *
3  *                                                                                      *
4  * This program is free software; you can redistribute it and/or modify it under        *
5  * the terms of the GNU General Public License as published by the Free Software        *
6  * Foundation; either version 2 of the License, or (at your option) any later           *
7  * version.                                                                             *
8  *                                                                                      *
9  * This program is distributed in the hope that it will be useful, but WITHOUT ANY      *
10  * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A      *
11  * PARTICULAR PURPOSE. See the GNU General Public License for more details.             *
12  *                                                                                      *
13  * You should have received a copy of the GNU General Public License along with         *
14  * this program.  If not, see <http://www.gnu.org/licenses/>.                           *
15  ****************************************************************************************/
16 #ifndef ECHONEST_CATALOG_ENTRY_H
17 #define ECHONEST_CATALOG_ENTRY_H
18 
19 #include "echonest_export.h"
20 #include "Util.h"
21 
22 #include <QByteArray>
23 #include <QSharedDataPointer>
24 #include <QString>
25 #include <QVector>
26 
27 class CatalogUpdateEntryData;
28 
29 namespace Echonest {
30 
31 /**
32  * This rather simple struct collects information about a status update
33  */
34 typedef QVector< QPair< QByteArray, QString > > CatalogStatusItem;
35 typedef struct CatalogStatusStruct {
36     CatalogTypes::TicketStatus status;
37     QString details;
38 
39     int items_updated;
40     CatalogStatusItem items; // List of [ item_id, info ]
41 
42 //     int percent_complete;
CatalogStatusStructCatalogStatusStruct43     CatalogStatusStruct() : status( CatalogTypes::Unknown ), items_updated( -1 ) {}
44 } CatalogStatus;
45 
46 /**
47  * This class described a catalog entry for use in the Catalog update() call.
48  *  All data fields are optional except Action, and only the ones specified will be sent.
49  */
50 class ECHONEST_EXPORT CatalogUpdateEntry
51 {
52 public:
53     CatalogUpdateEntry();
54     CatalogUpdateEntry( CatalogTypes::Action action );
55     virtual ~CatalogUpdateEntry();
56     CatalogUpdateEntry( const CatalogUpdateEntry& other );
57     CatalogUpdateEntry& operator=( const CatalogUpdateEntry& );
58 
59     /**
60      * Optional, the item id for the catalog entry. hash( catalog_id + item_id )
61      *  MUST be unique. If this is not set, a unique id will be generated internally.
62      */
63     QByteArray itemId() const;
64     void setItemId( const QByteArray& id );
65 
66     /**
67      * The type of action that this item represents, required.
68      */
69     CatalogTypes::Action action() const;
70     void setAction( CatalogTypes::Action action );
71 
72     /**
73      * The Echo Nest fingerprint.
74      */
75     QByteArray fingerprint() const;
76     void setFingerprint( const QByteArray& id );
77 
78     // deprecated
79     void setFingerpring( const QByteArray& id );
80     /**
81      * The song id. Rosetta id or Echo Nest ID.
82      */
83     QByteArray songId() const;
84     void setSongId( const QByteArray& id );
85 
86     /**
87      * The song name. Mutually exclusive with song id.
88      */
89     QString songName() const;
90     void setSongName( const QString& name );
91 
92     /**
93      * The artist id, either a rosetta stone ID or an Echo Nest ID.
94      */
95     QByteArray artistId() const;
96     void setArtistId( const QByteArray& id );
97 
98     /**
99      * The artist name, mutually exclusive with artist id.
100      */
101     QString artistName() const;
102     void setArtistName( const QString& name );
103 
104     /**
105      * The release, or album, name.
106      */
107     QString release() const;
108     void setRelease( const QString& release );
109 
110     /**
111      * The genre of the item.
112      */
113     QString genre() const;
114     void setGenre( const QString& genre );
115 
116     /**
117      * The track number.
118      */
119     int trackNumber() const;
120     void setTrackNumber( int trackNum );
121 
122     /**
123      * The disc number of this item.
124      */
125     int discNumber() const;
126     void setDiscNumber( int disc );
127 
128     /**
129      * The url or the local filename or remote url.
130      */
131     QString url() const;
132     void setUrl( const QString& url );
133 
134     /**
135      * If this song was marked as a favorite or not
136      */
137     bool favorite() const;
138     void setFavorite( bool fav );
139 
140     /**
141      * If this song was banned.
142      */
143     bool banned() const;
144     void setBanned( bool banned );
145 
146     /**
147      * The play count of this item.
148      */
149     int playCount() const;
150     void setPlayCount( int playCount );
151 
152     /**
153      * The skip count of this item.
154      */
155     int skipCount() const;
156     void setSkipCount( int skipCount );
157 
158     /**
159      * The rating of this item, from 1 to 10.
160      */
161     int rating() const;
162     void setRating( int rating );
163 
164     bool favoriteSet() const;
165     bool bannedSet() const;
166 private:
167     QSharedDataPointer<CatalogUpdateEntryData> d;
168 };
169 
170 typedef QVector<CatalogUpdateEntry> CatalogUpdateEntries;
171 
172 }
173 
174 #endif
175