1
0
mirror of https://github.com/tomahawk-player/tomahawk.git synced 2025-08-09 07:36:48 +02:00

Remove some ENABLE_HEADLESS

This commit is contained in:
Uwe L. Korn
2014-05-21 12:45:23 +01:00
parent fe5a86bad3
commit d55bec53ad
4 changed files with 10 additions and 60 deletions

View File

@@ -52,12 +52,9 @@
#include <QStringList> #include <QStringList>
#include <QDateTime> #include <QDateTime>
#include <QTimer> #include <QTimer>
#include <QInputDialog>
#ifndef ENABLE_HEADLESS #include <QLineEdit>
#include <QInputDialog> #include <QMessageBox>
#include <QLineEdit>
#include <QMessageBox>
#endif
using namespace Tomahawk; using namespace Tomahawk;
using namespace Accounts; using namespace Accounts;
@@ -95,11 +92,9 @@ JreenMessageHandler( QtMsgType type, const char *msg )
XmppSipPlugin::XmppSipPlugin( Account* account ) XmppSipPlugin::XmppSipPlugin( Account* account )
: SipPlugin( account ) : SipPlugin( account )
, m_state( Account::Disconnected ) , m_state( Account::Disconnected )
#ifndef ENABLE_HEADLESS
, m_menu( 0 ) , m_menu( 0 )
, m_xmlConsole( 0 ) , m_xmlConsole( 0 )
, m_pubSubManager( 0 ) , m_pubSubManager( 0 )
#endif
{ {
#if QT_VERSION <= QT_VERSION_CHECK( 5, 0, 0 ) #if QT_VERSION <= QT_VERSION_CHECK( 5, 0, 0 )
Jreen::Logger::addHandler( JreenMessageHandler ); Jreen::Logger::addHandler( JreenMessageHandler );
@@ -121,14 +116,12 @@ XmppSipPlugin::XmppSipPlugin( Account* account )
m_currentResource = QString( "tomahawk%1" ).arg( QString::number( qrand() % 10000 ) ); m_currentResource = QString( "tomahawk%1" ).arg( QString::number( qrand() % 10000 ) );
m_client->setResource( m_currentResource ); m_client->setResource( m_currentResource );
#ifndef ENABLE_HEADLESS
// instantiate XmlConsole // instantiate XmlConsole
if ( readXmlConsoleEnabled() ) if ( readXmlConsoleEnabled() )
{ {
m_xmlConsole = new XmlConsole( m_client ); m_xmlConsole = new XmlConsole( m_client );
m_xmlConsole->show(); m_xmlConsole->show();
} }
#endif
// add VCardUpdate extension to own presence // add VCardUpdate extension to own presence
m_client->presence().addExtension( new Jreen::VCardUpdate() ); m_client->presence().addExtension( new Jreen::VCardUpdate() );
@@ -136,10 +129,8 @@ XmppSipPlugin::XmppSipPlugin( Account* account )
// initaliaze the roster // initaliaze the roster
m_roster = new Jreen::SimpleRoster( m_client ); m_roster = new Jreen::SimpleRoster( m_client );
#ifndef ENABLE_HEADLESS
// initialize the AvatarManager // initialize the AvatarManager
m_avatarManager = new AvatarManager( m_client ); m_avatarManager = new AvatarManager( m_client );
#endif
// setup disco // setup disco
m_client->disco()->setSoftwareVersion( "Tomahawk Player", TOMAHAWK_VERSION, TOMAHAWK_SYSTEM ); m_client->disco()->setSoftwareVersion( "Tomahawk Player", TOMAHAWK_VERSION, TOMAHAWK_SYSTEM );
@@ -167,9 +158,7 @@ XmppSipPlugin::XmppSipPlugin( Account* account )
connect( m_roster, SIGNAL( subscriptionReceived( Jreen::RosterItem::Ptr, Jreen::Presence ) ), connect( m_roster, SIGNAL( subscriptionReceived( Jreen::RosterItem::Ptr, Jreen::Presence ) ),
SLOT( onSubscriptionReceived( Jreen::RosterItem::Ptr, Jreen::Presence ) ) ); SLOT( onSubscriptionReceived( Jreen::RosterItem::Ptr, Jreen::Presence ) ) );
#ifndef ENABLE_HEADLESS
connect( m_avatarManager, SIGNAL( newAvatar( QString ) ), SLOT( onNewAvatar( QString ) ) ); connect( m_avatarManager, SIGNAL( newAvatar( QString ) ), SLOT( onNewAvatar( QString ) ) );
#endif
m_pubSubManager = new Jreen::PubSub::Manager( m_client ); m_pubSubManager = new Jreen::PubSub::Manager( m_client );
m_pubSubManager->addEntityType< Jreen::Tune >(); m_pubSubManager->addEntityType< Jreen::Tune >();
@@ -189,9 +178,7 @@ XmppSipPlugin::~XmppSipPlugin()
delete m_pubSubManager; delete m_pubSubManager;
delete m_avatarManager; delete m_avatarManager;
delete m_roster; delete m_roster;
#ifndef ENABLE_HEADLESS
delete m_xmlConsole; delete m_xmlConsole;
#endif
delete m_client; delete m_client;
} }
@@ -213,13 +200,11 @@ XmppSipPlugin::infoPlugin()
} }
#ifndef ENABLE_HEADLESS
QMenu* QMenu*
XmppSipPlugin::menu() XmppSipPlugin::menu()
{ {
return m_menu; return m_menu;
} }
#endif
void void
@@ -495,7 +480,6 @@ XmppSipPlugin::addContact( const QString& jid, AddContactOptions options, const
void void
XmppSipPlugin::showAddFriendDialog() XmppSipPlugin::showAddFriendDialog()
{ {
#ifndef ENABLE_HEADLESS
bool ok; bool ok;
QString id = QInputDialog::getText( TomahawkUtils::tomahawkWindow(), tr( "Add Friend" ), QString id = QInputDialog::getText( TomahawkUtils::tomahawkWindow(), tr( "Add Friend" ),
tr( "Enter Xmpp ID:" ), QLineEdit::Normal, "", &ok ).trimmed(); tr( "Enter Xmpp ID:" ), QLineEdit::Normal, "", &ok ).trimmed();
@@ -505,7 +489,6 @@ XmppSipPlugin::showAddFriendDialog()
qDebug() << "Attempting to add xmpp contact to roster:" << id; qDebug() << "Attempting to add xmpp contact to roster:" << id;
addContact( id, SendInvite ); addContact( id, SendInvite );
#endif
} }
@@ -554,9 +537,7 @@ XmppSipPlugin::defaultSuffix() const
void void
XmppSipPlugin::showXmlConsole() XmppSipPlugin::showXmlConsole()
{ {
#ifndef ENABLE_HEADLESS
m_xmlConsole->show(); m_xmlConsole->show();
#endif
} }
@@ -649,7 +630,6 @@ XmppSipPlugin::setupClientHelper()
void void
XmppSipPlugin::addMenuHelper() XmppSipPlugin::addMenuHelper()
{ {
#ifndef ENABLE_HEADLESS
if ( !m_menu ) if ( !m_menu )
{ {
m_menu = new QMenu( QString( "%1 (" ).arg( friendlyName() ).append( readUsername() ).append(")" ) ); m_menu = new QMenu( QString( "%1 (" ).arg( friendlyName() ).append( readUsername() ).append(")" ) );
@@ -665,14 +645,12 @@ XmppSipPlugin::addMenuHelper()
emit addMenu( m_menu ); emit addMenu( m_menu );
} }
#endif
} }
void void
XmppSipPlugin::removeMenuHelper() XmppSipPlugin::removeMenuHelper()
{ {
#ifndef ENABLE_HEADLESS
if ( m_menu ) if ( m_menu )
{ {
emit removeMenu( m_menu ); emit removeMenu( m_menu );
@@ -680,7 +658,6 @@ XmppSipPlugin::removeMenuHelper()
delete m_menu; delete m_menu;
m_menu = 0; m_menu = 0;
} }
#endif
} }
@@ -813,7 +790,6 @@ XmppSipPlugin::onSubscriptionReceived( const Jreen::RosterItem::Ptr& item, const
return; return;
} }
#ifndef ENABLE_HEADLESS
// preparing the confirm box for the user // preparing the confirm box for the user
QMessageBox *confirmBox = new QMessageBox( QMessageBox *confirmBox = new QMessageBox(
QMessageBox::Question, QMessageBox::Question,
@@ -828,14 +804,12 @@ XmppSipPlugin::onSubscriptionReceived( const Jreen::RosterItem::Ptr& item, const
// display the box and wait for the answer // display the box and wait for the answer
confirmBox->open( this, SLOT( onSubscriptionRequestConfirmed( int ) ) ); confirmBox->open( this, SLOT( onSubscriptionRequestConfirmed( int ) ) );
#endif
} }
void void
XmppSipPlugin::onSubscriptionRequestConfirmed( int result ) XmppSipPlugin::onSubscriptionRequestConfirmed( int result )
{ {
#ifndef ENABLE_HEADLESS
qDebug() << Q_FUNC_INFO << result; qDebug() << Q_FUNC_INFO << result;
QList< QMessageBox* > confirmBoxes = m_subscriptionConfirmBoxes.values(); QList< QMessageBox* > confirmBoxes = m_subscriptionConfirmBoxes.values();
@@ -865,7 +839,6 @@ XmppSipPlugin::onSubscriptionRequestConfirmed( int result )
} }
m_roster->allowSubscription( jid, allowSubscription == QMessageBox::Yes ); m_roster->allowSubscription( jid, allowSubscription == QMessageBox::Yes );
#endif
} }
@@ -1046,10 +1019,8 @@ XmppSipPlugin::handlePeerStatus( const Jreen::JID& jid, Jreen::Presence::Type pr
peersWaitingForSip[fulljid] = peerInfo; peersWaitingForSip[fulljid] = peerInfo;
peersWaitingForVersionString[fulljid] = peerInfo; peersWaitingForVersionString[fulljid] = peerInfo;
#ifndef ENABLE_HEADLESS
if ( !m_avatarManager->avatar( jid.bare() ).isNull() ) if ( !m_avatarManager->avatar( jid.bare() ).isNull() )
onNewAvatar( jid.bare() ); onNewAvatar( jid.bare() );
#endif
// request software version // request software version
Jreen::IQ versionIq( Jreen::IQ::Get, jid ); Jreen::IQ versionIq( Jreen::IQ::Get, jid );
@@ -1069,8 +1040,6 @@ XmppSipPlugin::handlePeerStatus( const Jreen::JID& jid, Jreen::Presence::Type pr
void void
XmppSipPlugin::onNewAvatar( const QString& jid ) XmppSipPlugin::onNewAvatar( const QString& jid )
{ {
#ifndef ENABLE_HEADLESS
// qDebug() << Q_FUNC_INFO << jid;
if ( m_state != Account::Connected ) if ( m_state != Account::Connected )
return; return;
@@ -1092,7 +1061,6 @@ XmppSipPlugin::onNewAvatar( const QString& jid )
{ {
PeerInfo::getSelf( this, PeerInfo::AutoCreate )->setAvatar( m_avatarManager->avatar( jid ) ); PeerInfo::getSelf( this, PeerInfo::AutoCreate )->setAvatar( m_avatarManager->avatar( jid ) );
} }
#endif
} }

View File

@@ -27,9 +27,7 @@
#include "AvatarManager.h" #include "AvatarManager.h"
#ifndef ENABLE_HEADLESS #include "XmlConsole.h"
#include "XmlConsole.h"
#endif
#include "accounts/AccountDllMacro.h" #include "accounts/AccountDllMacro.h"
#include "accounts/Account.h" #include "accounts/Account.h"
@@ -50,10 +48,7 @@
#include <jreen/mucroom.h> #include <jreen/mucroom.h>
#include <jreen/pubsubmanager.h> #include <jreen/pubsubmanager.h>
#ifndef ENABLE_HEADLESS #include <QMessageBox>
#include <QMessageBox>
#endif
class ACCOUNTDLLEXPORT XmppSipPlugin : public SipPlugin class ACCOUNTDLLEXPORT XmppSipPlugin : public SipPlugin
{ {
@@ -71,9 +66,7 @@ public:
Tomahawk::InfoSystem::InfoPluginPtr infoPlugin(); Tomahawk::InfoSystem::InfoPluginPtr infoPlugin();
#ifndef ENABLE_HEADLESS
virtual QMenu* menu(); virtual QMenu* menu();
#endif
// used by XmppAccount to expose connection state and controls // used by XmppAccount to expose connection state and controls
Tomahawk::Accounts::Account::ConnectionState connectionState() const; Tomahawk::Accounts::Account::ConnectionState connectionState() const;
@@ -146,11 +139,9 @@ private:
QHash< Jreen::JID, Jreen::Presence::Type > m_peers; QHash< Jreen::JID, Jreen::Presence::Type > m_peers;
QHash< QString, QString > m_jidsNames; QHash< QString, QString > m_jidsNames;
#ifndef ENABLE_HEADLESS
QHash< Jreen::JID, QMessageBox* > m_subscriptionConfirmBoxes; QHash< Jreen::JID, QMessageBox* > m_subscriptionConfirmBoxes;
QMenu* m_menu; QMenu* m_menu;
XmlConsole* m_xmlConsole; XmlConsole* m_xmlConsole;
#endif
enum IqContext { NoContext, RequestDisco, RequestedDisco, SipMessageSent, RequestedVCard, RequestVersion, RequestedVersion }; enum IqContext { NoContext, RequestDisco, RequestedDisco, SipMessageSent, RequestedVCard, RequestVersion, RequestedVersion };
AvatarManager* m_avatarManager; AvatarManager* m_avatarManager;

View File

@@ -29,24 +29,19 @@
#include "database/DatabaseCommand_AddSource.h" #include "database/DatabaseCommand_AddSource.h"
#include "database/DatabaseCommand_CollectionStats.h" #include "database/DatabaseCommand_CollectionStats.h"
#include "database/DatabaseCommand_LoadAllSources.h" #include "database/DatabaseCommand_LoadAllSources.h"
#include "database/DatabaseCommand_SocialAction.h"
#include "database/DatabaseCommand_SourceOffline.h" #include "database/DatabaseCommand_SourceOffline.h"
#include "database/DatabaseCommand_UpdateSearchIndex.h" #include "database/DatabaseCommand_UpdateSearchIndex.h"
#include "database/DatabaseImpl.h" #include "database/DatabaseImpl.h"
#include "database/Database.h" #include "database/Database.h"
#include "utils/Logger.h"
#include "sip/PeerInfo.h"
#include "utils/TomahawkCache.h"
#include "utils/TomahawkUtilsGui.h"
#include <QCoreApplication> #include <QCoreApplication>
#include <QtAlgorithms> #include <QtAlgorithms>
#include "utils/TomahawkCache.h"
#include "database/DatabaseCommand_SocialAction.h"
#ifndef ENABLE_HEADLESS
#include "utils/TomahawkUtilsGui.h"
#endif
#include "utils/Logger.h"
#include "sip/PeerInfo.h"
using namespace Tomahawk; using namespace Tomahawk;
@@ -281,7 +276,6 @@ Source::friendlyNamesLessThan( const QString& first, const QString& second )
} }
#ifndef ENABLE_HEADLESS
QPixmap QPixmap
Source::avatar( TomahawkUtils::ImageMode style, const QSize& size ) Source::avatar( TomahawkUtils::ImageMode style, const QSize& size )
{ {
@@ -320,7 +314,6 @@ Source::avatar( TomahawkUtils::ImageMode style, const QSize& size )
return QPixmap(); return QPixmap();
} }
#endif
void void

View File

@@ -80,9 +80,7 @@ public:
QString dbFriendlyName() const; QString dbFriendlyName() const;
void setDbFriendlyName( const QString& dbFriendlyName ); void setDbFriendlyName( const QString& dbFriendlyName );
#ifndef ENABLE_HEADLESS
QPixmap avatar( TomahawkUtils::ImageMode style = TomahawkUtils::Original, const QSize& size = QSize() ); QPixmap avatar( TomahawkUtils::ImageMode style = TomahawkUtils::Original, const QSize& size = QSize() );
#endif
collection_ptr dbCollection() const; collection_ptr dbCollection() const;
QList< Tomahawk::collection_ptr > collections() const; QList< Tomahawk::collection_ptr > collections() const;