/src/libtomahawk/TomahawkSettings.h

http://github.com/tomahawk-player/tomahawk · C Header · 279 lines · 173 code · 66 blank · 40 comment · 0 complexity · 5cf526b092c6796b186853d1afa44c80 MD5 · raw file

  1. /* === This file is part of Tomahawk Player - <http://tomahawk-player.org> ===
  2. *
  3. * Copyright 2010-2015, Christian Muehlhaeuser <muesli@tomahawk-player.org>
  4. * Copyright 2010-2012 Leo Franchi <lfranchi@kde.org>
  5. * Copyright 2010-2012, Jeff Mitchell <jeff@tomahawk-player.org>
  6. *
  7. * Tomahawk is free software: you can redistribute it and/or modify
  8. * it under the terms of the GNU General Public License as published by
  9. * the Free Software Foundation, either version 3 of the License, or
  10. * (at your option) any later version.
  11. *
  12. * Tomahawk is distributed in the hope that it will be useful,
  13. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  15. * GNU General Public License for more details.
  16. *
  17. * You should have received a copy of the GNU General Public License
  18. * along with Tomahawk. If not, see <http://www.gnu.org/licenses/>.
  19. */
  20. #ifndef TOMAHAWK_SETTINGS_H
  21. #define TOMAHAWK_SETTINGS_H
  22. #include "DllMacro.h"
  23. #include "Typedefs.h"
  24. #include "network/Enums.h"
  25. #include "AtticaManager.h"
  26. #include <QSettings>
  27. #include <QNetworkProxy>
  28. #include <QStringList>
  29. #define TOMAHAWK_SETTINGS_VERSION 17
  30. /**
  31. * Convenience wrapper around QSettings for tomahawk-specific config
  32. */
  33. class DLLEXPORT TomahawkSettings : public QSettings
  34. {
  35. Q_OBJECT
  36. public:
  37. static TomahawkSettings* instance();
  38. explicit TomahawkSettings( QObject* parent = 0 );
  39. virtual ~TomahawkSettings();
  40. void applyChanges() { emit changed(); }
  41. /// General settings
  42. QString storageCacheLocation() const;
  43. QStringList scannerPaths() const; /// QDesktopServices::MusicLocation in TomahawkSettingsGui
  44. void setScannerPaths( const QStringList& paths );
  45. bool hasScannerPaths() const;
  46. uint scannerTime() const;
  47. void setScannerTime( uint time );
  48. QString downloadsPreferredFormat() const;
  49. void setDownloadsPreferredFormat( const QString& format );
  50. QString downloadsPath() const;
  51. void setDownloadsPath( const QString& path );
  52. QVariantList downloadStates() const;
  53. void setDownloadStates( const QVariantList& downloads );
  54. uint infoSystemCacheVersion() const;
  55. void setInfoSystemCacheVersion( uint version );
  56. uint genericCacheVersion() const;
  57. void setGenericCacheVersion( uint version );
  58. bool watchForChanges() const;
  59. void setWatchForChanges( bool watch );
  60. bool acceptedLegalWarning() const;
  61. void setAcceptedLegalWarning( bool accept );
  62. /// UI settings
  63. QByteArray mainWindowGeometry() const;
  64. void setMainWindowGeometry( const QByteArray& geom );
  65. QByteArray mainWindowState() const;
  66. void setMainWindowState( const QByteArray& state );
  67. QByteArray mainWindowSplitterState() const;
  68. void setMainWindowSplitterState( const QByteArray& state );
  69. bool verboseNotifications() const;
  70. void setVerboseNotifications( bool notifications );
  71. bool menuBarVisible() const;
  72. void setMenuBarVisible( bool visible );
  73. bool fullscreenEnabled() const;
  74. void setFullscreenEnabled( bool fullscreen );
  75. // Collection Stuff
  76. bool showOfflineSources() const;
  77. void setShowOfflineSources( bool show );
  78. bool enableEchonestCatalogs() const;
  79. void setEnableEchonestCatalogs( bool enable );
  80. /// Audio stuff
  81. unsigned int volume() const;
  82. void setVolume( unsigned int volume );
  83. bool muted() const;
  84. void setMuted( bool muted );
  85. /// Playlist stuff
  86. QByteArray playlistColumnSizes( const QString& playlistid ) const;
  87. void setPlaylistColumnSizes( const QString& playlistid, const QByteArray& state );
  88. QStringList recentlyPlayedPlaylistGuids( unsigned int amount = 0 ) const;
  89. void appendRecentlyPlayedPlaylist( const QString& playlistGuid, int sourceId );
  90. bool shuffleState( const QString& playlistid ) const;
  91. void setShuffleState( const QString& playlistid, bool state );
  92. Tomahawk::PlaylistModes::RepeatMode repeatMode( const QString& playlistid );
  93. void setRepeatMode( const QString& playlistid, Tomahawk::PlaylistModes::RepeatMode mode );
  94. // remove shuffle state and repeat state
  95. void removePlaylistSettings( const QString& playlistid );
  96. QVariant queueState() const;
  97. void setQueueState( const QVariant& state );
  98. /// SIP plugins
  99. // all plugins we know about. loaded, unloaded, enabled, disabled.
  100. void setSipPlugins( const QStringList& plugins );
  101. QStringList sipPlugins() const;
  102. // just the enabled sip plugins.
  103. void setEnabledSipPlugins( const QStringList& list );
  104. QStringList enabledSipPlugins() const;
  105. void enableSipPlugin( const QString& pluginId );
  106. void disableSipPlugin( const QString& pluginId );
  107. void addSipPlugin( const QString& pluginId, bool enable = true );
  108. void removeSipPlugin( const QString& pluginId );
  109. void setAccounts( const QStringList& accountIds );
  110. QStringList accounts() const;
  111. void addAccount( const QString& accountId );
  112. void removeAccount( const QString& accountId );
  113. void setBookmarkPlaylist( const QString& guid );
  114. QString bookmarkPlaylist() const;
  115. /// Network settings
  116. Tomahawk::Network::ExternalAddress::Mode externalAddressMode();
  117. void setExternalAddressMode( Tomahawk::Network::ExternalAddress::Mode externalAddressMode );
  118. bool httpEnabled() const; /// true by default
  119. void setHttpEnabled( bool enable );
  120. bool httpBindAll() const; /// false by default
  121. void setHttpBindAll( bool bindAll );
  122. bool crashReporterEnabled() const; /// true by default
  123. void setCrashReporterEnabled( bool enable );
  124. bool songChangeNotificationEnabled() const; /// true by default
  125. void setSongChangeNotificationEnabled( bool enable );
  126. bool autoDetectExternalIp() const;
  127. void setAutoDetectExternalIp( bool autoDetect );
  128. QString externalHostname() const;
  129. void setExternalHostname( const QString& externalHostname );
  130. int defaultPort() const;
  131. int externalPort() const;
  132. void setExternalPort( int externalPort );
  133. QString proxyHost() const;
  134. void setProxyHost( const QString& host );
  135. QString proxyNoProxyHosts() const;
  136. void setProxyNoProxyHosts( const QString& hosts );
  137. qulonglong proxyPort() const;
  138. void setProxyPort( const qulonglong port );
  139. QString proxyUsername() const;
  140. void setProxyUsername( const QString& username );
  141. QString proxyPassword() const;
  142. void setProxyPassword( const QString& password );
  143. QNetworkProxy::ProxyType proxyType() const;
  144. void setProxyType( const QNetworkProxy::ProxyType type );
  145. bool proxyDns() const;
  146. void setProxyDns( bool lookupViaProxy );
  147. /// ACL settings
  148. QVariantList aclEntries() const;
  149. void setAclEntries( const QVariantList& entries );
  150. bool isSslCertKnown( const QByteArray& sslDigest ) const;
  151. bool isSslCertTrusted( const QByteArray& sslDigest ) const;
  152. void setSslCertTrusted( const QByteArray& sslDigest, bool trusted );
  153. /// XMPP Component Settings
  154. QString xmppBotServer() const;
  155. void setXmppBotServer( const QString& server );
  156. QString xmppBotJid() const;
  157. void setXmppBotJid( const QString& component );
  158. QString xmppBotPassword() const;
  159. void setXmppBotPassword( const QString& password );
  160. int xmppBotPort() const;
  161. void setXmppBotPort( const int port );
  162. QString scriptDefaultPath() const;
  163. void setScriptDefaultPath( const QString& path );
  164. QString playlistDefaultPath() const;
  165. void setPlaylistDefaultPath( const QString& path );
  166. // Now-Playing Settings
  167. // For now, just Adium. Soon, the world!
  168. bool nowPlayingEnabled() const; // false by default
  169. void setNowPlayingEnabled( bool enable );
  170. enum PrivateListeningMode
  171. {
  172. PublicListening,
  173. NoLogPlayback,
  174. FullyPrivate
  175. };
  176. PrivateListeningMode privateListeningMode() const;
  177. void setPrivateListeningMode( PrivateListeningMode mode );
  178. void setImportPlaylistPath( const QString& path );
  179. QString importPlaylistPath() const;
  180. Tomahawk::SerializedUpdaters playlistUpdaters() const;
  181. void setPlaylistUpdaters( const Tomahawk::SerializedUpdaters& updaters );
  182. static void registerCustomSettingsHandlers();
  183. // Charts
  184. void setLastChartIds( const QMap<QString, QVariant>& ids );
  185. QMap<QString, QVariant> lastChartIds();
  186. AtticaManager::StateHash atticaResolverStates() const;
  187. void setAtticaResolverStates( const AtticaManager::StateHash states );
  188. void setAtticaResolverState( const QString& resolver, AtticaManager::ResolverState state );
  189. void removeAtticaResolverState( const QString& resolver );
  190. // Playdar TLS Certificate and Key.
  191. // TODO: Store in Keychain
  192. QByteArray playdarCertificate() const;
  193. void setPlaydarCertificate( const QByteArray& cert );
  194. QByteArray playdarKey() const;
  195. void setPlaydarKey( const QByteArray& key );
  196. // VLC Settings
  197. QString vlcArguments() const;
  198. void setVlcArguments( const QString& arguments );
  199. signals:
  200. void changed();
  201. void recentlyPlayedPlaylistAdded( const QString& playlistId, int sourceId );
  202. private slots:
  203. void updateIndex();
  204. private:
  205. void doInitialSetup();
  206. void createLastFmAccount();
  207. void createSpotifyAccount();
  208. void doUpgrade( int oldVersion, int newVersion );
  209. static TomahawkSettings* s_instance;
  210. };
  211. Q_DECLARE_METATYPE( TomahawkSettings::PrivateListeningMode )
  212. Q_DECLARE_METATYPE( AtticaManager::StateHash )
  213. #endif