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