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

/src/tomahawkapp.h

http://github.com/tomahawk-player/tomahawk
C++ Header | 153 lines | 95 code | 33 blank | 25 comment | 0 complexity | 33ff5d4c8ab25bab37d03c4afb0652dc 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, Leo Franchi <lfranchi@kde.org>
  5 *   Copyright 2010-2011, 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 TOMAHAWKAPP_H
 22#define TOMAHAWKAPP_H
 23
 24#define APP TomahawkApp::instance()
 25
 26#include "mac/TomahawkApp_Mac.h" // for PlatforInterface
 27#include "Typedefs.h"
 28#include "utils/TomahawkUtils.h"
 29#include "thirdparty/kdsingleapplicationguard/kdsingleapplicationguard.h"
 30
 31#include "HeadlessCheck.h"
 32#include "config.h"
 33
 34#include "QxtHttpServerConnector"
 35#include "QxtHttpSessionManager"
 36
 37#include <QRegExp>
 38#include <QFile>
 39#include <QSettings>
 40#include <QDir>
 41#include <QPersistentModelIndex>
 42
 43class AudioEngine;
 44class Database;
 45class ScanManager;
 46class Servent;
 47class SipHandler;
 48class TomahawkSettings;
 49class AudioControls;
 50
 51namespace Tomahawk
 52{
 53    class ShortcutHandler;
 54    namespace InfoSystem
 55    {
 56        class InfoSystem;
 57    }
 58
 59    namespace Accounts
 60    {
 61        class AccountManager;
 62    }
 63}
 64
 65#ifdef LIBLASTFM_FOUND
 66#include <lastfm/NetworkAccessManager.h>
 67#include "Scrobbler.h"
 68#endif
 69
 70#ifndef TOMAHAWK_HEADLESS
 71class TomahawkWindow;
 72#endif
 73
 74
 75// this also acts as a a container for important top-level objects
 76// that other parts of the app need to find
 77// (eg, library, pipeline, friends list)
 78class TomahawkApp : public TOMAHAWK_APPLICATION, public Tomahawk::PlatformInterface
 79{
 80Q_OBJECT
 81
 82public:
 83    TomahawkApp( int& argc, char *argv[] );
 84    virtual ~TomahawkApp();
 85
 86    void init();
 87    static TomahawkApp* instance();
 88
 89#ifndef ENABLE_HEADLESS
 90    AudioControls* audioControls();
 91    TomahawkWindow* mainWindow() const;
 92#endif
 93
 94    // PlatformInterface
 95    virtual bool loadUrl( const QString& url );
 96
 97    bool isTomahawkLoaded() const;
 98
 99    // reimplemented from QApplication/QCoreApplication
100    virtual bool notify( QObject* receiver, QEvent* e );
101
102signals:
103    void tomahawkLoaded();
104
105public slots:
106    virtual void activate();
107    void instanceStarted( KDSingleApplicationGuard::Instance );
108
109private slots:
110    void initServent();
111    void initSIP();
112    void initHTTP();
113
114    void spotifyApiCheckFinished();
115    void accountManagerReady();
116
117private:
118    void installTranslator();
119    void registerMetaTypes();
120
121    void printHelp();
122
123    // Start-up order: database, collection, pipeline, servent, http
124    void initDatabase();
125    void initLocalCollection();
126    void initPipeline();
127
128    QWeakPointer<Database> m_database;
129    QWeakPointer<ScanManager> m_scanManager;
130    QWeakPointer<AudioEngine> m_audioEngine;
131    QWeakPointer<Servent> m_servent;
132    QWeakPointer<Tomahawk::InfoSystem::InfoSystem> m_infoSystem;
133    QWeakPointer<Tomahawk::ShortcutHandler> m_shortcutHandler;
134    QWeakPointer< Tomahawk::Accounts::AccountManager > m_accountManager;
135    bool m_scrubFriendlyName;
136
137#ifdef LIBLASTFM_FOUND
138    Scrobbler* m_scrobbler;
139#endif
140
141#ifndef TOMAHAWK_HEADLESS
142    TomahawkWindow* m_mainwindow;
143#endif
144
145    bool m_headless, m_loaded;
146
147    QWeakPointer< QxtHttpServerConnector > m_connector;
148    QWeakPointer< QxtHttpSessionManager > m_session;
149};
150
151Q_DECLARE_METATYPE( PairList )
152
153#endif // TOMAHAWKAPP_H