PageRenderTime 181ms CodeModel.GetById 61ms app.highlight 44ms RepoModel.GetById 56ms app.codeStats 0ms

/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
 21#ifndef TOMAHAWK_SETTINGS_H
 22#define TOMAHAWK_SETTINGS_H
 23
 24#include "DllMacro.h"
 25#include "Typedefs.h"
 26
 27#include "network/Enums.h"
 28#include "AtticaManager.h"
 29
 30#include <QSettings>
 31#include <QNetworkProxy>
 32#include <QStringList>
 33
 34#define TOMAHAWK_SETTINGS_VERSION 17
 35
 36/**
 37 * Convenience wrapper around QSettings for tomahawk-specific config
 38 */
 39class DLLEXPORT TomahawkSettings : public QSettings
 40{
 41Q_OBJECT
 42
 43public:
 44    static TomahawkSettings* instance();
 45
 46    explicit TomahawkSettings( QObject* parent = 0 );
 47    virtual ~TomahawkSettings();
 48
 49    void applyChanges() { emit changed(); }
 50
 51    /// General settings
 52    QString storageCacheLocation() const;
 53
 54    QStringList scannerPaths() const; /// QDesktopServices::MusicLocation in TomahawkSettingsGui
 55    void setScannerPaths( const QStringList& paths );
 56    bool hasScannerPaths() const;
 57    uint scannerTime() const;
 58    void setScannerTime( uint time );
 59
 60    QString downloadsPreferredFormat() const;
 61    void setDownloadsPreferredFormat( const QString& format );
 62
 63    QString downloadsPath() const;
 64    void setDownloadsPath( const QString& path );
 65
 66    QVariantList downloadStates() const;
 67    void setDownloadStates( const QVariantList& downloads );
 68
 69    uint infoSystemCacheVersion() const;
 70    void setInfoSystemCacheVersion( uint version );
 71    uint genericCacheVersion() const;
 72    void setGenericCacheVersion( uint version );
 73
 74    bool watchForChanges() const;
 75    void setWatchForChanges( bool watch );
 76
 77    bool acceptedLegalWarning() const;
 78    void setAcceptedLegalWarning( bool accept );
 79
 80    /// UI settings
 81    QByteArray mainWindowGeometry() const;
 82    void setMainWindowGeometry( const QByteArray& geom );
 83
 84    QByteArray mainWindowState() const;
 85    void setMainWindowState( const QByteArray& state );
 86
 87    QByteArray mainWindowSplitterState() const;
 88    void setMainWindowSplitterState( const QByteArray& state );
 89
 90    bool verboseNotifications() const;
 91    void setVerboseNotifications( bool notifications );
 92
 93    bool menuBarVisible() const;
 94    void setMenuBarVisible( bool visible );
 95
 96    bool fullscreenEnabled() const;
 97    void setFullscreenEnabled( bool fullscreen );
 98
 99    // Collection Stuff
100    bool showOfflineSources() const;
101    void setShowOfflineSources( bool show );
102
103    bool enableEchonestCatalogs() const;
104    void setEnableEchonestCatalogs( bool enable );
105
106    /// Audio stuff
107    unsigned int volume() const;
108    void setVolume( unsigned int volume );
109
110    bool muted() const;
111    void setMuted( bool muted );
112
113    /// Playlist stuff
114    QByteArray playlistColumnSizes( const QString& playlistid ) const;
115    void setPlaylistColumnSizes( const QString& playlistid, const QByteArray& state );
116
117    QStringList recentlyPlayedPlaylistGuids( unsigned int amount = 0 ) const;
118    void appendRecentlyPlayedPlaylist( const QString& playlistGuid, int sourceId );
119
120    bool shuffleState( const QString& playlistid ) const;
121    void setShuffleState( const QString& playlistid, bool state );
122    Tomahawk::PlaylistModes::RepeatMode repeatMode( const QString& playlistid );
123    void setRepeatMode( const QString& playlistid, Tomahawk::PlaylistModes::RepeatMode mode );
124
125    // remove shuffle state and repeat state
126    void removePlaylistSettings( const QString& playlistid );
127
128    QVariant queueState() const;
129    void setQueueState( const QVariant& state );
130
131    /// SIP plugins
132    // all plugins we know about. loaded, unloaded, enabled, disabled.
133    void setSipPlugins( const QStringList& plugins );
134    QStringList sipPlugins() const;
135
136    // just the enabled sip plugins.
137    void setEnabledSipPlugins( const QStringList& list );
138    QStringList enabledSipPlugins() const;
139    void enableSipPlugin( const QString& pluginId );
140    void disableSipPlugin( const QString& pluginId );
141
142    void addSipPlugin( const QString& pluginId, bool enable = true );
143    void removeSipPlugin( const QString& pluginId );
144
145    void setAccounts( const QStringList& accountIds );
146    QStringList accounts() const;
147    void addAccount( const QString& accountId );
148    void removeAccount( const QString& accountId );
149
150    void setBookmarkPlaylist( const QString& guid );
151    QString bookmarkPlaylist() const;
152
153    /// Network settings
154    Tomahawk::Network::ExternalAddress::Mode externalAddressMode();
155    void setExternalAddressMode( Tomahawk::Network::ExternalAddress::Mode externalAddressMode );
156
157    bool httpEnabled() const; /// true by default
158    void setHttpEnabled( bool enable );
159
160    bool httpBindAll() const; /// false by default
161    void setHttpBindAll( bool bindAll );
162
163    bool crashReporterEnabled() const; /// true by default
164    void setCrashReporterEnabled( bool enable );
165
166    bool songChangeNotificationEnabled() const; /// true by default
167    void setSongChangeNotificationEnabled( bool enable );
168
169    bool autoDetectExternalIp() const;
170    void setAutoDetectExternalIp( bool autoDetect );
171
172    QString externalHostname() const;
173    void setExternalHostname( const QString& externalHostname );
174
175    int defaultPort() const;
176    int externalPort() const;
177    void setExternalPort( int externalPort );
178
179    QString proxyHost() const;
180    void setProxyHost( const QString& host );
181    QString proxyNoProxyHosts() const;
182    void setProxyNoProxyHosts( const QString& hosts );
183    qulonglong proxyPort() const;
184    void setProxyPort( const qulonglong port );
185    QString proxyUsername() const;
186    void setProxyUsername( const QString& username );
187    QString proxyPassword() const;
188    void setProxyPassword( const QString& password );
189    QNetworkProxy::ProxyType proxyType() const;
190    void setProxyType( const QNetworkProxy::ProxyType type );
191    bool proxyDns() const;
192    void setProxyDns( bool lookupViaProxy );
193
194    /// ACL settings
195    QVariantList aclEntries() const;
196    void setAclEntries( const QVariantList& entries );
197
198    bool isSslCertKnown( const QByteArray& sslDigest ) const;
199    bool isSslCertTrusted( const QByteArray& sslDigest ) const;
200    void setSslCertTrusted( const QByteArray& sslDigest, bool trusted );
201
202    /// XMPP Component Settings
203    QString xmppBotServer() const;
204    void setXmppBotServer( const QString& server );
205    QString xmppBotJid() const;
206    void setXmppBotJid( const QString& component );
207    QString xmppBotPassword() const;
208    void setXmppBotPassword( const QString& password );
209    int xmppBotPort() const;
210    void setXmppBotPort( const int port );
211
212    QString scriptDefaultPath() const;
213    void setScriptDefaultPath( const QString& path );
214    QString playlistDefaultPath() const;
215    void setPlaylistDefaultPath( const QString& path );
216
217    // Now-Playing Settings
218    // For now, just Adium. Soon, the world!
219    bool nowPlayingEnabled() const; // false by default
220    void setNowPlayingEnabled( bool enable );
221
222    enum PrivateListeningMode
223    {
224        PublicListening,
225        NoLogPlayback,
226        FullyPrivate
227    };
228    PrivateListeningMode privateListeningMode() const;
229    void setPrivateListeningMode( PrivateListeningMode mode );
230
231    void setImportPlaylistPath( const QString& path );
232    QString importPlaylistPath() const;
233
234    Tomahawk::SerializedUpdaters playlistUpdaters() const;
235    void setPlaylistUpdaters( const Tomahawk::SerializedUpdaters& updaters );
236
237    static void registerCustomSettingsHandlers();
238
239    // Charts
240    void setLastChartIds( const QMap<QString, QVariant>& ids );
241    QMap<QString, QVariant> lastChartIds();
242
243    AtticaManager::StateHash atticaResolverStates() const;
244    void setAtticaResolverStates( const AtticaManager::StateHash states );
245
246    void setAtticaResolverState( const QString& resolver, AtticaManager::ResolverState state );
247    void removeAtticaResolverState( const QString& resolver );
248
249    // Playdar TLS Certificate and Key.
250    // TODO: Store in Keychain
251    QByteArray playdarCertificate() const;
252    void setPlaydarCertificate( const QByteArray& cert );
253    QByteArray playdarKey() const;
254    void setPlaydarKey( const QByteArray& key );
255
256    // VLC Settings
257    QString vlcArguments() const;
258    void setVlcArguments( const QString& arguments );
259
260signals:
261    void changed();
262    void recentlyPlayedPlaylistAdded( const QString& playlistId, int sourceId );
263
264private slots:
265    void updateIndex();
266
267private:
268    void doInitialSetup();
269    void createLastFmAccount();
270    void createSpotifyAccount();
271    void doUpgrade( int oldVersion, int newVersion );
272
273    static TomahawkSettings* s_instance;
274};
275
276Q_DECLARE_METATYPE( TomahawkSettings::PrivateListeningMode )
277Q_DECLARE_METATYPE( AtticaManager::StateHash )
278
279#endif