PageRenderTime 58ms CodeModel.GetById 12ms app.highlight 40ms RepoModel.GetById 1ms app.codeStats 0ms

/src/libtomahawk/Typedefs.h

http://github.com/tomahawk-player/tomahawk
C Header | 289 lines | 211 code | 43 blank | 35 comment | 0 complexity | a38c04d2906695799b0019b8ceb69aed MD5 | raw file
  1/* === This file is part of Tomahawk Player - <http://tomahawk-player.org> ===
  2 *
  3 *   Copyright 2010-2011, Christian Muehlhaeuser <muesli@tomahawk-player.org>
  4 *   Copyright 2010-2011, Jeff Mitchell <jeff@tomahawk-player.org>
  5 *
  6 *   Tomahawk is free software: you can redistribute it and/or modify
  7 *   it under the terms of the GNU General Public License as published by
  8 *   the Free Software Foundation, either version 3 of the License, or
  9 *   (at your option) any later version.
 10 *
 11 *   Tomahawk is distributed in the hope that it will be useful,
 12 *   but WITHOUT ANY WARRANTY; without even the implied warranty of
 13 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
 14 *   GNU General Public License for more details.
 15 *
 16 *   You should have received a copy of the GNU General Public License
 17 *   along with Tomahawk. If not, see <http://www.gnu.org/licenses/>.
 18 */
 19
 20#pragma once
 21#ifndef TYPEDEFS_H
 22#define TYPEDEFS_H
 23
 24#include <QSharedPointer>
 25#include <QPointer>
 26#include <QUuid>
 27#include <QPair>
 28#include <QPersistentModelIndex>
 29
 30//template <typename T> class QSharedPointer;
 31
 32#include <QNetworkReply>
 33
 34// TODO: Move into Tomahawk namespace
 35class Msg;
 36
 37typedef QSharedPointer<Msg> msg_ptr;
 38
 39namespace Tomahawk
 40{
 41    class Artist;
 42    class Album;
 43    class Collection;
 44    class Playlist;
 45    class PlaylistEntry;
 46    class PlaylistInterface;
 47    class PlaylistTemplate;
 48    class DynamicPlaylist;
 49    class Query;
 50    class Result;
 51    class Track;
 52    class TrackData;
 53    class Source;
 54    class DynamicControl;
 55    class GeneratorInterface;
 56    class PeerInfo;
 57    class DatabaseCommand;
 58    class ScriptObject;
 59
 60    typedef QSharedPointer<Collection> collection_ptr;
 61    typedef QWeakPointer<Collection> collection_wptr;
 62    typedef QSharedPointer<Playlist> playlist_ptr;
 63    typedef QSharedPointer<PlaylistEntry> plentry_ptr;
 64    typedef QSharedPointer<PlaylistInterface> playlistinterface_ptr;
 65    typedef QSharedPointer<PlaylistTemplate> playlisttemplate_ptr;
 66    typedef QSharedPointer<DynamicPlaylist> dynplaylist_ptr;
 67    typedef QSharedPointer<Query> query_ptr;
 68    typedef QWeakPointer<Query> query_wptr;
 69    typedef QSharedPointer<Result> result_ptr;
 70    typedef QWeakPointer<Result> result_wptr;
 71    typedef QSharedPointer<Track> track_ptr;
 72    typedef QWeakPointer<Track> track_wptr;
 73    typedef QSharedPointer<TrackData> trackdata_ptr;
 74    typedef QWeakPointer<TrackData> trackdata_wptr;
 75    typedef QSharedPointer<Source> source_ptr;
 76    typedef QSharedPointer<Artist> artist_ptr;
 77    typedef QWeakPointer<Artist> artist_wptr;
 78    typedef QSharedPointer<Album> album_ptr;
 79    typedef QWeakPointer<Album> album_wptr;
 80    typedef QSharedPointer<PeerInfo> peerinfo_ptr;
 81    typedef QWeakPointer<PeerInfo> peerinfo_wptr;
 82    typedef QSharedPointer< DatabaseCommand> dbcmd_ptr;
 83
 84    typedef QSharedPointer<DynamicControl> dyncontrol_ptr;
 85    typedef QSharedPointer<GeneratorInterface> geninterface_ptr;
 86
 87
 88    // Scripting
 89    typedef QSharedPointer< ScriptObject > scriptobject_ptr;
 90    typedef QWeakPointer< ScriptObject > scriptobject_wptr;
 91
 92    // let's keep these typesafe, they are different kinds of GUID:
 93    typedef QString QID; //query id
 94    typedef QString RID; //result id
 95
 96    namespace ACLStatus {
 97        enum Type {
 98            NotFound = 0,
 99            Deny = 1,
100            Read = 2,
101            Stream = 3
102        };
103    }
104
105    enum GeneratorMode
106    {
107        OnDemand = 0,
108        Static
109    };
110
111    enum ModelMode
112    {
113        Mixed = 0,
114        DatabaseMode,
115        InfoSystemMode
116    };
117
118    enum ModelTypes
119    {
120        TypeArtist = 0,
121        TypeAlbum,
122        TypeQuery,
123        TypeResult
124    };
125
126    class ExternalResolver;
127
128    namespace PlaylistModes {
129        enum RepeatMode { NoRepeat, RepeatOne, RepeatAll };
130        enum ViewMode { Unknown, Tree, Flat, Album };
131        enum SeekRestrictions { NoSeekRestrictions, NoSeek };
132        enum SkipRestrictions { NoSkipRestrictions, NoSkipForwards, NoSkipBackwards, NoSkip };
133        enum RetryMode { NoRetry, Retry };
134        enum LatchMode { StayOnSong, RealTime };
135    }
136
137
138    struct SerializedUpdater {
139        QString type;
140        QVariantHash customData;
141
142        SerializedUpdater( const QString& t, const QVariantHash cd = QVariantHash() ) : type( t ), customData( cd ) {}
143        SerializedUpdater() {}
144    };
145
146    typedef QMultiHash< QString, SerializedUpdater > SerializedUpdaters;
147    typedef QList< SerializedUpdater > SerializedUpdaterList;
148
149    // Yes/no questions with an associated enum value
150    typedef QPair< QString, int > PlaylistDeleteQuestion;
151    typedef QList< PlaylistDeleteQuestion > PlaylistDeleteQuestions;
152
153    namespace InfoSystem
154    {
155        enum InfoType
156        {
157            // as items are saved in cache, mark them here to not change them
158            InfoNoInfo = 0, //WARNING: *ALWAYS* keep this first!
159            InfoTrackID = 1,
160            InfoTrackArtist = 2,
161            InfoTrackAlbum = 3,
162            InfoTrackGenre = 4,
163            InfoTrackComposer = 5,
164            InfoTrackDate = 6,
165            InfoTrackNumber = 7,
166            InfoTrackDiscNumber = 8,
167            InfoTrackBitRate = 9,
168            InfoTrackLength = 10,
169            InfoTrackSampleRate = 11,
170            InfoTrackFileSize = 12,
171            InfoTrackBPM = 13,
172            InfoTrackReplayGain = 14,
173            InfoTrackReplayPeakGain = 15,
174            InfoTrackLyrics = 16,
175            InfoTrackLocation = 17,
176            InfoTrackProfile = 18,
177            InfoTrackEnergy = 19,
178            InfoTrackDanceability = 20,
179            InfoTrackTempo = 21,
180            InfoTrackLoudness = 22,
181            InfoTrackSimilars = 23, // cached -- do not change
182
183            InfoArtistID = 25,
184            InfoArtistName = 26,
185            InfoArtistBiography = 27,
186            InfoArtistImages = 28, //cached -- do not change
187            InfoArtistBlog = 29,
188            InfoArtistFamiliarity = 30,
189            InfoArtistHotttness = 31,
190            InfoArtistSongs = 32, //cached -- do not change
191            InfoArtistSimilars = 33, //cached -- do not change
192            InfoArtistNews = 34,
193            InfoArtistProfile = 35,
194            InfoArtistReviews = 36,
195            InfoArtistTerms = 37,
196            InfoArtistLinks = 38,
197            InfoArtistVideos = 39,
198            InfoArtistReleases = 40,
199
200            InfoAlbumID = 42,
201            InfoAlbumCoverArt = 43, //cached -- do not change
202            InfoAlbumName = 44,
203            InfoAlbumArtist = 45,
204            InfoAlbumDate = 46,
205            InfoAlbumGenre = 47,
206            InfoAlbumComposer = 48,
207            InfoAlbumSongs = 49,
208            InfoAlbumPurchaseUrl = 50,
209
210            /** \var Tomahawk::InfoSystem::InfoType Tomahawk::InfoSystem::InfoType::InfoChartCapabilities
211            * Documentation for InfoChartCapabilities
212            *
213            * Clients of this InfoType expect a QVariant
214            *
215            */
216            InfoChartCapabilities = 60,
217            /**
218            * Documentation for InfoChartArtists
219            */
220            InfoChart = 61,
221
222            InfoNewReleaseCapabilities = 62,
223            InfoNewRelease = 63,
224
225            InfoMiscTopHotttness = 70,
226            InfoMiscTopTerms = 71,
227
228            InfoSubmitNowPlaying = 80,
229            InfoSubmitScrobble = 81,
230
231            InfoNowPlaying = 90,
232            InfoNowPaused = 91,
233            InfoNowResumed = 92,
234            InfoNowStopped = 93,
235            InfoTrackUnresolved = 94,
236
237            InfoLove = 100,
238            InfoUnLove = 101,
239            InfoShareTrack = 102,
240
241            InfoNotifyUser = 110,
242
243            InfoInboxReceived = 111,
244
245            InfoLastInfo = 112 //WARNING: *ALWAYS* keep this last!
246        };
247
248        class InfoPlugin;
249
250        typedef QSet< InfoType > InfoTypeSet;
251        typedef QMap< InfoType, QVariant > InfoTypeMap;
252        typedef QMap< InfoType, uint > InfoTimeoutMap;
253        typedef QHash< QString, QString > InfoStringHash;
254        typedef QPair< QVariantMap, QVariant > PushInfoPair;
255
256        typedef QSharedPointer< InfoPlugin > InfoPluginPtr;
257    }
258
259    namespace Network
260    {
261        namespace ACL
262        {
263            class AclRequest;
264            typedef QSharedPointer<AclRequest> aclrequest_ptr;
265            typedef QWeakPointer<AclRequest> aclrequest_wptr;
266        }
267    }
268} // ns
269
270typedef int AudioErrorCode;
271typedef int AudioState;
272typedef QList< QPair< QString, QString > > PairList;
273
274// creates 36char ascii guid without {} around it
275inline static QString uuid()
276{
277    // kinda lame, but
278    QString q = QUuid::createUuid().toString();
279    q.remove( 0, 1 );
280    q.chop( 1 );
281    return q;
282}
283
284Q_DECLARE_METATYPE( QModelIndex )
285Q_DECLARE_METATYPE( QPersistentModelIndex )
286Q_DECLARE_METATYPE( QNetworkReply* )
287Q_DECLARE_METATYPE( Tomahawk::ACLStatus::Type )
288
289#endif // TYPEDEFS_H