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