mirror of
https://github.com/tomahawk-player/tomahawk.git
synced 2025-08-09 23:57:34 +02:00
* Fixed TomahawkApp CTOR for secondary instances.
This commit is contained in:
@@ -1,5 +1,5 @@
|
|||||||
/* === This file is part of Tomahawk Player - <http://tomahawk-player.org> ===
|
/* === This file is part of Tomahawk Player - <http://tomahawk-player.org> ===
|
||||||
*
|
*
|
||||||
* Copyright 2010-2011, Christian Muehlhaeuser <muesli@tomahawk-player.org>
|
* Copyright 2010-2011, Christian Muehlhaeuser <muesli@tomahawk-player.org>
|
||||||
*
|
*
|
||||||
* Tomahawk is free software: you can redistribute it and/or modify
|
* Tomahawk is free software: you can redistribute it and/or modify
|
||||||
@@ -78,6 +78,7 @@ public:
|
|||||||
TomahawkApp( int& argc, char *argv[] );
|
TomahawkApp( int& argc, char *argv[] );
|
||||||
virtual ~TomahawkApp();
|
virtual ~TomahawkApp();
|
||||||
|
|
||||||
|
void init();
|
||||||
static TomahawkApp* instance();
|
static TomahawkApp* instance();
|
||||||
|
|
||||||
SipHandler* sipHandler() { return m_sipHandler; }
|
SipHandler* sipHandler() { return m_sipHandler; }
|
||||||
@@ -98,10 +99,10 @@ public:
|
|||||||
|
|
||||||
// because QApplication::arguments() is expensive
|
// because QApplication::arguments() is expensive
|
||||||
bool scrubFriendlyName() const { return m_scrubFriendlyName; }
|
bool scrubFriendlyName() const { return m_scrubFriendlyName; }
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
void instanceStarted( KDSingleApplicationGuard::Instance );
|
void instanceStarted( KDSingleApplicationGuard::Instance );
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
void setupSIP();
|
void setupSIP();
|
||||||
|
|
||||||
@@ -124,14 +125,14 @@ private:
|
|||||||
XMPPBot* m_xmppBot;
|
XMPPBot* m_xmppBot;
|
||||||
Tomahawk::ShortcutHandler* m_shortcutHandler;
|
Tomahawk::ShortcutHandler* m_shortcutHandler;
|
||||||
bool m_scrubFriendlyName;
|
bool m_scrubFriendlyName;
|
||||||
|
|
||||||
#ifdef LIBLASTFM_FOUND
|
#ifdef LIBLASTFM_FOUND
|
||||||
Scrobbler* m_scrobbler;
|
Scrobbler* m_scrobbler;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef TOMAHAWK_HEADLESS
|
#ifndef TOMAHAWK_HEADLESS
|
||||||
TomahawkWindow* m_mainwindow;
|
TomahawkWindow* m_mainwindow;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
bool m_headless;
|
bool m_headless;
|
||||||
|
|
||||||
|
16
src/main.cpp
16
src/main.cpp
@@ -1,5 +1,5 @@
|
|||||||
/* === This file is part of Tomahawk Player - <http://tomahawk-player.org> ===
|
/* === This file is part of Tomahawk Player - <http://tomahawk-player.org> ===
|
||||||
*
|
*
|
||||||
* Copyright 2010-2011, Christian Muehlhaeuser <muesli@tomahawk-player.org>
|
* Copyright 2010-2011, Christian Muehlhaeuser <muesli@tomahawk-player.org>
|
||||||
*
|
*
|
||||||
* Tomahawk is free software: you can redistribute it and/or modify
|
* Tomahawk is free software: you can redistribute it and/or modify
|
||||||
@@ -18,15 +18,15 @@
|
|||||||
|
|
||||||
#include "tomahawk/tomahawkapp.h"
|
#include "tomahawk/tomahawkapp.h"
|
||||||
|
|
||||||
|
#include "kdsingleapplicationguard/kdsingleapplicationguard.h"
|
||||||
|
|
||||||
#ifdef Q_WS_MAC
|
#ifdef Q_WS_MAC
|
||||||
#include "tomahawkapp_mac.h"
|
#include "tomahawkapp_mac.h"
|
||||||
#include </System/Library/Frameworks/CoreServices.framework/Versions/A/Frameworks/AE.framework/Versions/A/Headers/AppleEvents.h>
|
#include </System/Library/Frameworks/CoreServices.framework/Versions/A/Frameworks/AE.framework/Versions/A/Headers/AppleEvents.h>
|
||||||
static pascal OSErr appleEventHandler( const AppleEvent*, AppleEvent*, long );
|
static pascal OSErr appleEventHandler( const AppleEvent*, AppleEvent*, long );
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include <exception>
|
|
||||||
|
|
||||||
#include "kdsingleapplicationguard/kdsingleapplicationguard.h"
|
|
||||||
int
|
int
|
||||||
main( int argc, char *argv[] )
|
main( int argc, char *argv[] )
|
||||||
{
|
{
|
||||||
@@ -42,11 +42,15 @@ main( int argc, char *argv[] )
|
|||||||
|
|
||||||
TomahawkApp a( argc, argv );
|
TomahawkApp a( argc, argv );
|
||||||
KDSingleApplicationGuard guard( &a, KDSingleApplicationGuard::AutoKillOtherInstances );
|
KDSingleApplicationGuard guard( &a, KDSingleApplicationGuard::AutoKillOtherInstances );
|
||||||
QObject::connect( &guard, SIGNAL( instanceStarted( KDSingleApplicationGuard::Instance ) ), &a, SLOT( instanceStarted( KDSingleApplicationGuard::Instance ) ) );
|
QObject::connect( &guard, SIGNAL( instanceStarted( KDSingleApplicationGuard::Instance ) ), &a, SLOT( instanceStarted( KDSingleApplicationGuard::Instance ) ) );
|
||||||
|
|
||||||
|
if ( guard.isPrimaryInstance() )
|
||||||
|
a.init();
|
||||||
|
|
||||||
return a.exec();
|
return a.exec();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
#ifdef Q_WS_MAC
|
#ifdef Q_WS_MAC
|
||||||
static pascal OSErr
|
static pascal OSErr
|
||||||
appleEventHandler( const AppleEvent* e, AppleEvent*, long )
|
appleEventHandler( const AppleEvent* e, AppleEvent*, long )
|
||||||
|
@@ -152,31 +152,53 @@ TomahawkApp::TomahawkApp( int& argc, char *argv[] )
|
|||||||
, m_mainwindow( 0 )
|
, m_mainwindow( 0 )
|
||||||
, m_infoSystem( 0 )
|
, m_infoSystem( 0 )
|
||||||
{
|
{
|
||||||
qsrand( QTime( 0, 0, 0 ).secsTo( QTime::currentTime() ) );
|
|
||||||
|
|
||||||
#ifdef TOMAHAWK_HEADLESS
|
|
||||||
m_headless = true;
|
|
||||||
#else
|
|
||||||
m_mainwindow = 0;
|
|
||||||
m_headless = arguments().contains( "--headless" );
|
|
||||||
setWindowIcon( QIcon( RESPATH "icons/tomahawk-icon-128x128.png" ) );
|
|
||||||
#endif
|
|
||||||
|
|
||||||
qDebug() << "TomahawkApp thread:" << this->thread();
|
qDebug() << "TomahawkApp thread:" << this->thread();
|
||||||
setOrganizationName( QLatin1String( ORGANIZATION_NAME ) );
|
setOrganizationName( QLatin1String( ORGANIZATION_NAME ) );
|
||||||
setOrganizationDomain( QLatin1String( ORGANIZATION_DOMAIN ) );
|
setOrganizationDomain( QLatin1String( ORGANIZATION_DOMAIN ) );
|
||||||
setApplicationName( QLatin1String( APPLICATION_NAME ) );
|
setApplicationName( QLatin1String( APPLICATION_NAME ) );
|
||||||
setApplicationVersion( QLatin1String( VERSION ) );
|
setApplicationVersion( QLatin1String( VERSION ) );
|
||||||
registerMetaTypes();
|
|
||||||
setupLogfile();
|
setupLogfile();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
TomahawkApp::~TomahawkApp()
|
||||||
|
{
|
||||||
|
qDebug() << Q_FUNC_INFO;
|
||||||
|
|
||||||
|
delete m_sipHandler;
|
||||||
|
delete m_servent;
|
||||||
|
|
||||||
|
#ifndef TOMAHAWK_HEADLESS
|
||||||
|
delete m_mainwindow;
|
||||||
|
delete m_audioEngine;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
delete m_database;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void
|
||||||
|
TomahawkApp::init()
|
||||||
|
{
|
||||||
|
qsrand( QTime( 0, 0, 0 ).secsTo( QTime::currentTime() ) );
|
||||||
|
|
||||||
|
#ifdef TOMAHAWK_HEADLESS
|
||||||
|
m_headless = true;
|
||||||
|
#else
|
||||||
|
m_mainwindow = 0;
|
||||||
|
m_headless = arguments().contains( "--headless" );
|
||||||
|
setWindowIcon( QIcon( RESPATH "icons/tomahawk-icon-128x128.png" ) );
|
||||||
|
#endif
|
||||||
|
|
||||||
|
registerMetaTypes();
|
||||||
|
|
||||||
Echonest::Config::instance()->setAPIKey( "JRIHWEP6GPOER2QQ6" );
|
Echonest::Config::instance()->setAPIKey( "JRIHWEP6GPOER2QQ6" );
|
||||||
|
|
||||||
new TomahawkSettings( this );
|
new TomahawkSettings( this );
|
||||||
m_audioEngine = new AudioEngine;
|
m_audioEngine = new AudioEngine;
|
||||||
new ScanManager( this );
|
new ScanManager( this );
|
||||||
new Pipeline( this );
|
new Pipeline( this );
|
||||||
|
|
||||||
m_servent = new Servent( this );
|
m_servent = new Servent( this );
|
||||||
connect( m_servent, SIGNAL( ready() ), SLOT( setupSIP() ) );
|
connect( m_servent, SIGNAL( ready() ), SLOT( setupSIP() ) );
|
||||||
|
|
||||||
@@ -185,15 +207,15 @@ TomahawkApp::TomahawkApp( int& argc, char *argv[] )
|
|||||||
|
|
||||||
qDebug() << "Init Echonest Factory.";
|
qDebug() << "Init Echonest Factory.";
|
||||||
GeneratorFactory::registerFactory( "echonest", new EchonestFactory );
|
GeneratorFactory::registerFactory( "echonest", new EchonestFactory );
|
||||||
|
|
||||||
m_scrubFriendlyName = arguments().contains( "--demo" );
|
m_scrubFriendlyName = arguments().contains( "--demo" );
|
||||||
// Register shortcut handler for this platform
|
// Register shortcut handler for this platform
|
||||||
#ifdef Q_WS_MAC
|
#ifdef Q_WS_MAC
|
||||||
m_shortcutHandler = new MacShortcutHandler( this );
|
m_shortcutHandler = new MacShortcutHandler( this );
|
||||||
Tomahawk::setShortcutHandler( static_cast<MacShortcutHandler*>( m_shortcutHandler) );
|
Tomahawk::setShortcutHandler( static_cast<MacShortcutHandler*>( m_shortcutHandler) );
|
||||||
|
|
||||||
Tomahawk::setApplicationHandler( this );
|
Tomahawk::setApplicationHandler( this );
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// Connect up shortcuts
|
// Connect up shortcuts
|
||||||
if ( m_shortcutHandler )
|
if ( m_shortcutHandler )
|
||||||
@@ -208,7 +230,7 @@ TomahawkApp::TomahawkApp( int& argc, char *argv[] )
|
|||||||
connect( m_shortcutHandler, SIGNAL( mute() ), m_audioEngine, SLOT( mute() ) );
|
connect( m_shortcutHandler, SIGNAL( mute() ), m_audioEngine, SLOT( mute() ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef LIBLASTFM_FOUND
|
#ifdef LIBLASTFM_FOUND
|
||||||
qDebug() << "Init Scrobbler.";
|
qDebug() << "Init Scrobbler.";
|
||||||
m_scrobbler = new Scrobbler( this );
|
m_scrobbler = new Scrobbler( this );
|
||||||
qDebug() << "Setting NAM.";
|
qDebug() << "Setting NAM.";
|
||||||
@@ -225,10 +247,10 @@ TomahawkApp::TomahawkApp( int& argc, char *argv[] )
|
|||||||
|
|
||||||
connect( m_audioEngine, SIGNAL( stopped() ),
|
connect( m_audioEngine, SIGNAL( stopped() ),
|
||||||
m_scrobbler, SLOT( trackStopped() ), Qt::QueuedConnection );
|
m_scrobbler, SLOT( trackStopped() ), Qt::QueuedConnection );
|
||||||
#else
|
#else
|
||||||
qDebug() << "Setting NAM.";
|
qDebug() << "Setting NAM.";
|
||||||
TomahawkUtils::setNam( new QNetworkAccessManager );
|
TomahawkUtils::setNam( new QNetworkAccessManager );
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// Set up proxy
|
// Set up proxy
|
||||||
if( TomahawkSettings::instance()->proxyType() != QNetworkProxy::NoProxy &&
|
if( TomahawkSettings::instance()->proxyType() != QNetworkProxy::NoProxy &&
|
||||||
@@ -258,7 +280,7 @@ TomahawkApp::TomahawkApp( int& argc, char *argv[] )
|
|||||||
m_mainwindow->setWindowTitle( "Tomahawk" );
|
m_mainwindow->setWindowTitle( "Tomahawk" );
|
||||||
m_mainwindow->show();
|
m_mainwindow->show();
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
qDebug() << "Init Local Collection.";
|
qDebug() << "Init Local Collection.";
|
||||||
initLocalCollection();
|
initLocalCollection();
|
||||||
@@ -273,28 +295,12 @@ TomahawkApp::TomahawkApp( int& argc, char *argv[] )
|
|||||||
startHTTP();
|
startHTTP();
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifndef TOMAHAWK_HEADLESS
|
#ifndef TOMAHAWK_HEADLESS
|
||||||
if ( !TomahawkSettings::instance()->hasScannerPath() )
|
if ( !TomahawkSettings::instance()->hasScannerPath() )
|
||||||
{
|
{
|
||||||
m_mainwindow->showSettingsDialog();
|
m_mainwindow->showSettingsDialog();
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
TomahawkApp::~TomahawkApp()
|
|
||||||
{
|
|
||||||
qDebug() << Q_FUNC_INFO;
|
|
||||||
|
|
||||||
delete m_sipHandler;
|
|
||||||
delete m_servent;
|
|
||||||
|
|
||||||
#ifndef TOMAHAWK_HEADLESS
|
|
||||||
delete m_mainwindow;
|
|
||||||
delete m_audioEngine;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
delete m_database;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -332,7 +338,7 @@ TomahawkApp::registerMetaTypes()
|
|||||||
qRegisterMetaType< QMap<QString, unsigned int> >("QMap<QString, unsigned int>");
|
qRegisterMetaType< QMap<QString, unsigned int> >("QMap<QString, unsigned int>");
|
||||||
qRegisterMetaType< QMap< QString, plentry_ptr > >("QMap< QString, plentry_ptr >");
|
qRegisterMetaType< QMap< QString, plentry_ptr > >("QMap< QString, plentry_ptr >");
|
||||||
qRegisterMetaType< QHash< QString, QMap<quint32, quint16> > >("QHash< QString, QMap<quint32, quint16> >");
|
qRegisterMetaType< QHash< QString, QMap<quint32, quint16> > >("QHash< QString, QMap<quint32, quint16> >");
|
||||||
|
|
||||||
qRegisterMetaType< GeneratorMode>("GeneratorMode");
|
qRegisterMetaType< GeneratorMode>("GeneratorMode");
|
||||||
qRegisterMetaType<Tomahawk::GeneratorMode>("Tomahawk::GeneratorMode");
|
qRegisterMetaType<Tomahawk::GeneratorMode>("Tomahawk::GeneratorMode");
|
||||||
// Extra definition for namespaced-versions of signals/slots required
|
// Extra definition for namespaced-versions of signals/slots required
|
||||||
@@ -525,16 +531,16 @@ TomahawkApp::loadUrl( const QString& url )
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
TomahawkApp::instanceStarted( KDSingleApplicationGuard::Instance instance )
|
TomahawkApp::instanceStarted( KDSingleApplicationGuard::Instance instance )
|
||||||
{
|
{
|
||||||
qDebug() << "INSTANCE STARTED!" << instance.pid << instance.arguments;
|
qDebug() << "INSTANCE STARTED!" << instance.pid << instance.arguments;
|
||||||
|
|
||||||
if( instance.arguments.size() < 2 )
|
if( instance.arguments.size() < 2 )
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
loadUrl( instance.arguments.at( 1 ) );
|
loadUrl( instance.arguments.at( 1 ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user