mirror of
https://github.com/tomahawk-player/tomahawk.git
synced 2025-07-31 03:10:12 +02:00
* Merged stable changes to master.
This commit is contained in:
@@ -7,9 +7,15 @@ Version 0.1.0:
|
|||||||
music collection.
|
music collection.
|
||||||
|
|
||||||
Version 0.0.3:
|
Version 0.0.3:
|
||||||
* Fix crashes in Twitter authentication. For reals now.
|
* Fix crashes in Twitter authentication.
|
||||||
* Properly honor the chosen port number if a static host and port are
|
* Properly honor the chosen port number if a static host and port are
|
||||||
marked as preferred.
|
marked as preferred.
|
||||||
|
* Don't automatically try to resolve all incoming playback logs. This
|
||||||
|
speeds up importing sources a lot.
|
||||||
|
* Faster painting of playlists with lots of unresolved tracks.
|
||||||
|
* The tomahawk:// protocol handler works on Windows now.
|
||||||
|
* Fixed launching Tomahawk from Installer with administrative permissions.
|
||||||
|
* Prefer local results when results' score is equal.
|
||||||
|
|
||||||
Version 0.0.2:
|
Version 0.0.2:
|
||||||
* Don't reconnect to Jabber if the settings dialog is closed successfully
|
* Don't reconnect to Jabber if the settings dialog is closed successfully
|
||||||
|
@@ -4,12 +4,12 @@
|
|||||||
; Some installer script options (comment-out options not required)
|
; Some installer script options (comment-out options not required)
|
||||||
;-----------------------------------------------------------------------------
|
;-----------------------------------------------------------------------------
|
||||||
;!define OPTION_LICENSE_AGREEMENT
|
;!define OPTION_LICENSE_AGREEMENT
|
||||||
;!define OPTION_UAC_PLUGIN_ENHANCED
|
!define OPTION_UAC_PLUGIN_ENHANCED
|
||||||
!define OPTION_SECTION_SC_START_MENU
|
!define OPTION_SECTION_SC_START_MENU
|
||||||
!define OPTION_SECTION_SC_DESKTOP
|
!define OPTION_SECTION_SC_DESKTOP
|
||||||
!define OPTION_SECTION_SC_QUICK_LAUNCH
|
!define OPTION_SECTION_SC_QUICK_LAUNCH
|
||||||
!define OPTION_FINISHPAGE
|
!define OPTION_FINISHPAGE
|
||||||
!define OPTION_FINISHPAGE_LAUNCHER
|
;!define OPTION_FINISHPAGE_LAUNCHER
|
||||||
!define OPTION_FINISHPAGE_RELEASE_NOTES
|
!define OPTION_FINISHPAGE_RELEASE_NOTES
|
||||||
|
|
||||||
;-----------------------------------------------------------------------------
|
;-----------------------------------------------------------------------------
|
||||||
@@ -58,17 +58,10 @@ InstType Full
|
|||||||
InstType Minimal
|
InstType Minimal
|
||||||
CRCCheck On
|
CRCCheck On
|
||||||
SetCompressor /SOLID lzma
|
SetCompressor /SOLID lzma
|
||||||
|
RequestExecutionLevel user ;Now using the UAC plugin.
|
||||||
ReserveFile tomahawk.ini
|
ReserveFile tomahawk.ini
|
||||||
ReserveFile "${NSISDIR}\Plugins\InstallOptions.dll"
|
ReserveFile "${NSISDIR}\Plugins\InstallOptions.dll"
|
||||||
|
|
||||||
;The UAC plugin provides an elevated user.
|
|
||||||
;Otherwise request admin level here.
|
|
||||||
!ifdef OPTION_UAC_PLUGIN_ENHANCED
|
|
||||||
RequestExecutionLevel user
|
|
||||||
!else
|
|
||||||
RequestExecutionLevel admin
|
|
||||||
!endif
|
|
||||||
|
|
||||||
;-----------------------------------------------------------------------------
|
;-----------------------------------------------------------------------------
|
||||||
; Include some required header files.
|
; Include some required header files.
|
||||||
;-----------------------------------------------------------------------------
|
;-----------------------------------------------------------------------------
|
||||||
@@ -79,9 +72,7 @@ ReserveFile "${NSISDIR}\Plugins\InstallOptions.dll"
|
|||||||
!include Memento.nsh ;Remember user selections.
|
!include Memento.nsh ;Remember user selections.
|
||||||
!include WinVer.nsh ;Windows version detection.
|
!include WinVer.nsh ;Windows version detection.
|
||||||
!include WordFunc.nsh ;Used by VersionCompare macro function.
|
!include WordFunc.nsh ;Used by VersionCompare macro function.
|
||||||
!ifdef OPTION_UAC_PLUGIN_ENHANCED
|
!include UAC.nsh ;Used by the UAC elevation to install as user or admin.
|
||||||
!include UAC.nsh ;Used by the UAC elevation to install as user or admin.
|
|
||||||
!endif
|
|
||||||
|
|
||||||
;-----------------------------------------------------------------------------
|
;-----------------------------------------------------------------------------
|
||||||
; Memento selections stored in registry.
|
; Memento selections stored in registry.
|
||||||
@@ -146,18 +137,12 @@ UninstPage custom un.UnPageUserAppData un.UnPageUserAppDataLeave
|
|||||||
##############################################################################
|
##############################################################################
|
||||||
|
|
||||||
Function LaunchTomahawk
|
Function LaunchTomahawk
|
||||||
!ifdef OPTION_UAC_PLUGIN_ENHANCED
|
${UAC.CallFunctionAsUser} LaunchTomahawkAsUser
|
||||||
${UAC.CallFunctionAsUser} LaunchTomahawkAsUser
|
|
||||||
!else
|
|
||||||
Exec "$INSTDIR\tomahawk.exe"
|
|
||||||
!endif
|
|
||||||
FunctionEnd
|
FunctionEnd
|
||||||
|
|
||||||
!ifdef OPTION_UAC_PLUGIN_ENHANCED
|
|
||||||
Function LaunchTomahawkAsUser
|
Function LaunchTomahawkAsUser
|
||||||
Exec "$INSTDIR\tomahawk.exe"
|
Exec "$INSTDIR\tomahawk.exe"
|
||||||
FunctionEnd
|
FunctionEnd
|
||||||
!endif
|
|
||||||
|
|
||||||
##############################################################################
|
##############################################################################
|
||||||
# #
|
# #
|
||||||
@@ -189,14 +174,9 @@ FunctionEnd
|
|||||||
no_process_${processName}_to_end:
|
no_process_${processName}_to_end:
|
||||||
!macroend
|
!macroend
|
||||||
|
|
||||||
!macro EnsureTomahawkShutdown un
|
Function EnsureTomahawkShutdown
|
||||||
Function ${un}EnsureTomahawkShutdown
|
!insertmacro CheckAndConfirmEndProcess "tomahawk.exe"
|
||||||
!insertmacro CheckAndConfirmEndProcess "tomahawk.exe"
|
FunctionEnd
|
||||||
FunctionEnd
|
|
||||||
!macroend
|
|
||||||
|
|
||||||
!insertmacro EnsureTomahawkShutdown ""
|
|
||||||
!insertmacro EnsureTomahawkShutdown "un."
|
|
||||||
|
|
||||||
##############################################################################
|
##############################################################################
|
||||||
# #
|
# #
|
||||||
@@ -265,12 +245,10 @@ Function PageLeaveReinstall
|
|||||||
Delete $R1
|
Delete $R1
|
||||||
RMDir $INSTDIR
|
RMDir $INSTDIR
|
||||||
no_remove_uninstaller:
|
no_remove_uninstaller:
|
||||||
StrCmp $R0 "2" +2 0
|
StrCmp $R0 "2" 0 +3
|
||||||
|
UAC::Unload
|
||||||
|
Quit
|
||||||
BringToFront
|
BringToFront
|
||||||
!ifdef OPTION_UAC_PLUGIN_ENHANCED
|
|
||||||
UAC::Unload
|
|
||||||
Quit
|
|
||||||
!endif
|
|
||||||
reinst_done:
|
reinst_done:
|
||||||
FunctionEnd
|
FunctionEnd
|
||||||
|
|
||||||
@@ -385,7 +363,7 @@ SectionGroup "Shortcuts"
|
|||||||
CreateShortCut "$SMPROGRAMS\Tomahawk\LICENSE.lnk" "$INSTDIR\LICENSE.txt"
|
CreateShortCut "$SMPROGRAMS\Tomahawk\LICENSE.lnk" "$INSTDIR\LICENSE.txt"
|
||||||
CreateShortCut "$SMPROGRAMS\Tomahawk\Tomahawk.lnk" "$INSTDIR\tomahawk.exe"
|
CreateShortCut "$SMPROGRAMS\Tomahawk\Tomahawk.lnk" "$INSTDIR\tomahawk.exe"
|
||||||
CreateShortCut "$SMPROGRAMS\Tomahawk\Release notes.lnk" "$INSTDIR\NOTES.txt"
|
CreateShortCut "$SMPROGRAMS\Tomahawk\Release notes.lnk" "$INSTDIR\NOTES.txt"
|
||||||
CreateShortCut "$SMPROGRAMS\Tomahawk\Uninstall.lnk" "$INSTDIR\Uninstall.exe"
|
CreateShortCut "$SMPROGRAMS\Tomahawk\Uninstall.lnk" "$INSTDIR\uninstall.exe"
|
||||||
SetShellVarContext current
|
SetShellVarContext current
|
||||||
${MementoSectionEnd}
|
${MementoSectionEnd}
|
||||||
!endif
|
!endif
|
||||||
@@ -429,7 +407,7 @@ Section -post
|
|||||||
SetDetailsPrint textonly
|
SetDetailsPrint textonly
|
||||||
DetailPrint "Writing Uninstaller"
|
DetailPrint "Writing Uninstaller"
|
||||||
SetDetailsPrint listonly
|
SetDetailsPrint listonly
|
||||||
WriteUninstaller $INSTDIR\Uninstall.exe
|
WriteUninstaller $INSTDIR\uninstall.exe
|
||||||
|
|
||||||
;Registry keys required for installer version handling and uninstaller.
|
;Registry keys required for installer version handling and uninstaller.
|
||||||
SetDetailsPrint textonly
|
SetDetailsPrint textonly
|
||||||
@@ -573,27 +551,25 @@ Function .onInit
|
|||||||
|
|
||||||
${MementoSectionRestore}
|
${MementoSectionRestore}
|
||||||
|
|
||||||
!ifdef OPTION_UAC_PLUGIN_ENHANCED
|
UAC_Elevate:
|
||||||
UAC_Elevate:
|
UAC::RunElevated
|
||||||
UAC::RunElevated
|
StrCmp 1223 $0 UAC_ElevationAborted ; UAC dialog aborted by user?
|
||||||
StrCmp 1223 $0 UAC_ElevationAborted ; UAC dialog aborted by user?
|
StrCmp 0 $0 0 UAC_Err ; Error?
|
||||||
StrCmp 0 $0 0 UAC_Err ; Error?
|
StrCmp 1 $1 0 UAC_Success ;Are we the real deal or just the wrapper?
|
||||||
StrCmp 1 $1 0 UAC_Success ;Are we the real deal or just the wrapper?
|
Quit
|
||||||
Quit
|
|
||||||
|
|
||||||
UAC_Err:
|
UAC_Err:
|
||||||
MessageBox MB_ICONSTOP "Unable to elevate, error $0"
|
MessageBox MB_ICONSTOP "Unable to elevate, error $0"
|
||||||
Abort
|
Abort
|
||||||
|
|
||||||
UAC_ElevationAborted:
|
UAC_ElevationAborted:
|
||||||
Abort
|
Abort
|
||||||
|
|
||||||
UAC_Success:
|
UAC_Success:
|
||||||
StrCmp 1 $3 +4 ;Admin?
|
StrCmp 1 $3 +4 ;Admin?
|
||||||
StrCmp 3 $1 0 UAC_ElevationAborted ;Try again?
|
StrCmp 3 $1 0 UAC_ElevationAborted ;Try again?
|
||||||
MessageBox MB_ICONSTOP "This installer requires admin access, try again"
|
MessageBox MB_ICONSTOP "This installer requires admin access, try again"
|
||||||
goto UAC_Elevate
|
goto UAC_Elevate
|
||||||
!endif
|
|
||||||
|
|
||||||
;Prevent multiple instances.
|
;Prevent multiple instances.
|
||||||
System::Call 'kernel32::CreateMutexA(i 0, i 0, t "tomahawkInstaller") i .r1 ?e'
|
System::Call 'kernel32::CreateMutexA(i 0, i 0, t "tomahawkInstaller") i .r1 ?e'
|
||||||
@@ -615,15 +591,11 @@ FunctionEnd
|
|||||||
|
|
||||||
Function .onInstSuccess
|
Function .onInstSuccess
|
||||||
${MementoSectionSave}
|
${MementoSectionSave}
|
||||||
!ifdef OPTION_UAC_PLUGIN_ENHANCED
|
UAC::Unload ;Must call unload!
|
||||||
UAC::Unload ;Must call unload!
|
|
||||||
!endif
|
|
||||||
FunctionEnd
|
FunctionEnd
|
||||||
|
|
||||||
Function .onInstFailed
|
Function .onInstFailed
|
||||||
!ifdef OPTION_UAC_PLUGIN_ENHANCED
|
UAC::Unload ;Must call unload!
|
||||||
UAC::Unload ;Must call unload!
|
|
||||||
!endif
|
|
||||||
FunctionEnd
|
FunctionEnd
|
||||||
|
|
||||||
##############################################################################
|
##############################################################################
|
||||||
@@ -633,27 +605,25 @@ FunctionEnd
|
|||||||
##############################################################################
|
##############################################################################
|
||||||
|
|
||||||
Function un.onInit
|
Function un.onInit
|
||||||
!ifdef OPTION_UAC_PLUGIN_ENHANCED
|
UAC_Elevate:
|
||||||
UAC_Elevate:
|
UAC::RunElevated
|
||||||
UAC::RunElevated
|
StrCmp 1223 $0 UAC_ElevationAborted ; UAC dialog aborted by user?
|
||||||
StrCmp 1223 $0 UAC_ElevationAborted ; UAC dialog aborted by user?
|
StrCmp 0 $0 0 UAC_Err ; Error?
|
||||||
StrCmp 0 $0 0 UAC_Err ; Error?
|
StrCmp 1 $1 0 UAC_Success ;Are we the real deal or just the wrapper?
|
||||||
StrCmp 1 $1 0 UAC_Success ;Are we the real deal or just the wrapper?
|
Quit
|
||||||
Quit
|
|
||||||
|
|
||||||
UAC_Err:
|
UAC_Err:
|
||||||
MessageBox MB_ICONSTOP "Unable to elevate, error $0"
|
MessageBox MB_ICONSTOP "Unable to elevate, error $0"
|
||||||
Abort
|
Abort
|
||||||
|
|
||||||
UAC_ElevationAborted:
|
UAC_ElevationAborted:
|
||||||
Abort
|
Abort
|
||||||
|
|
||||||
UAC_Success:
|
UAC_Success:
|
||||||
StrCmp 1 $3 +4 ;Admin?
|
StrCmp 1 $3 +4 ;Admin?
|
||||||
StrCmp 3 $1 0 UAC_ElevationAborted ;Try again?
|
StrCmp 3 $1 0 UAC_ElevationAborted ;Try again?
|
||||||
MessageBox MB_ICONSTOP "This uninstaller requires admin access, try again"
|
MessageBox MB_ICONSTOP "This uninstaller requires admin access, try again"
|
||||||
goto UAC_Elevate
|
goto UAC_Elevate
|
||||||
!endif
|
|
||||||
|
|
||||||
;Prevent multiple instances.
|
;Prevent multiple instances.
|
||||||
System::Call 'kernel32::CreateMutexA(i 0, i 0, t "tomahawkUninstaller") i .r1 ?e'
|
System::Call 'kernel32::CreateMutexA(i 0, i 0, t "tomahawkUninstaller") i .r1 ?e'
|
||||||
@@ -664,13 +634,9 @@ Function un.onInit
|
|||||||
FunctionEnd
|
FunctionEnd
|
||||||
|
|
||||||
Function un.onUnInstSuccess
|
Function un.onUnInstSuccess
|
||||||
!ifdef OPTION_UAC_PLUGIN_ENHANCED
|
UAC::Unload ;Must call unload!
|
||||||
UAC::Unload ;Must call unload!
|
|
||||||
!endif
|
|
||||||
FunctionEnd
|
FunctionEnd
|
||||||
|
|
||||||
Function un.onUnInstFailed
|
Function un.onUnInstFailed
|
||||||
!ifdef OPTION_UAC_PLUGIN_ENHANCED
|
UAC::Unload ;Must call unload!
|
||||||
UAC::Unload ;Must call unload!
|
|
||||||
!endif
|
|
||||||
FunctionEnd
|
FunctionEnd
|
||||||
|
@@ -52,9 +52,9 @@ DatabaseCommand_LoadDynamicPlaylist::exec( DatabaseImpl* dbi )
|
|||||||
QList< QVariantMap > controls;
|
QList< QVariantMap > controls;
|
||||||
QString playlist_guid;
|
QString playlist_guid;
|
||||||
qDebug() << "Loading controls..." << revisionGuid();
|
qDebug() << "Loading controls..." << revisionGuid();
|
||||||
qDebug() << "SELECT playlist_revision.playlist, controls, plmode, pltype "
|
// qDebug() << "SELECT playlist_revision.playlist, controls, plmode, pltype "
|
||||||
"FROM dynamic_playlist_revision, playlist_revision "
|
// "FROM dynamic_playlist_revision, playlist_revision "
|
||||||
"WHERE dynamic_playlist_revision.guid = "<< revisionGuid() << " AND playlist_revision.guid = dynamic_playlist_revision.guid";
|
// "WHERE dynamic_playlist_revision.guid = "<< revisionGuid() << " AND playlist_revision.guid = dynamic_playlist_revision.guid";
|
||||||
if( controlsQuery.first() )
|
if( controlsQuery.first() )
|
||||||
{
|
{
|
||||||
playlist_guid = controlsQuery.value( 0 ).toString();
|
playlist_guid = controlsQuery.value( 0 ).toString();
|
||||||
|
@@ -45,7 +45,7 @@ DatabaseCommand_LoadPlaylistEntries::generateEntries( DatabaseImpl* dbi )
|
|||||||
query_entries.bindValue( ":guid", m_revguid );
|
query_entries.bindValue( ":guid", m_revguid );
|
||||||
query_entries.exec();
|
query_entries.exec();
|
||||||
|
|
||||||
qDebug() << "trying to load entries:" << m_revguid;
|
// qDebug() << "trying to load entries:" << m_revguid;
|
||||||
QString prevrev;
|
QString prevrev;
|
||||||
QJson::Parser parser; bool ok;
|
QJson::Parser parser; bool ok;
|
||||||
|
|
||||||
@@ -55,7 +55,6 @@ DatabaseCommand_LoadPlaylistEntries::generateEntries( DatabaseImpl* dbi )
|
|||||||
QVariant v = parser.parse( query_entries.value(0).toByteArray(), &ok );
|
QVariant v = parser.parse( query_entries.value(0).toByteArray(), &ok );
|
||||||
Q_ASSERT( ok && v.type() == QVariant::List ); //TODO
|
Q_ASSERT( ok && v.type() == QVariant::List ); //TODO
|
||||||
m_guids = v.toStringList();
|
m_guids = v.toStringList();
|
||||||
// qDebug() << "Entries:" << guids;
|
|
||||||
|
|
||||||
QString inclause = QString("('%1')").arg(m_guids.join("', '"));
|
QString inclause = QString("('%1')").arg(m_guids.join("', '"));
|
||||||
|
|
||||||
@@ -115,5 +114,5 @@ DatabaseCommand_LoadPlaylistEntries::generateEntries( DatabaseImpl* dbi )
|
|||||||
m_islatest = query_entries_old.value( 1 ).toBool();
|
m_islatest = query_entries_old.value( 1 ).toBool();
|
||||||
}
|
}
|
||||||
|
|
||||||
qDebug() << Q_FUNC_INFO << "entrymap:" << m_entrymap;
|
// qDebug() << Q_FUNC_INFO << "entrymap:" << m_entrymap;
|
||||||
}
|
}
|
||||||
|
@@ -62,16 +62,12 @@ Connection::Connection( Servent* parent )
|
|||||||
|
|
||||||
Connection::~Connection()
|
Connection::~Connection()
|
||||||
{
|
{
|
||||||
qDebug() << "DTOR connection (super)" << id() << thread();
|
qDebug() << "DTOR connection (super)" << id() << thread() << m_sock.isNull();
|
||||||
if( !m_sock.isNull() )
|
if( !m_sock.isNull() )
|
||||||
{
|
{
|
||||||
qDebug() << "deleteLatering sock" << m_sock;
|
// qDebug() << "deleteLatering sock" << m_sock;
|
||||||
m_sock->deleteLater();
|
m_sock->deleteLater();
|
||||||
}
|
}
|
||||||
else
|
|
||||||
{
|
|
||||||
qDebug() << "no valid sock to delete";
|
|
||||||
}
|
|
||||||
|
|
||||||
delete m_statstimer;
|
delete m_statstimer;
|
||||||
}
|
}
|
||||||
@@ -118,7 +114,7 @@ Connection::setFirstMessage( msg_ptr m )
|
|||||||
void
|
void
|
||||||
Connection::shutdown( bool waitUntilSentAll )
|
Connection::shutdown( bool waitUntilSentAll )
|
||||||
{
|
{
|
||||||
qDebug() << Q_FUNC_INFO << waitUntilSentAll;
|
qDebug() << Q_FUNC_INFO << waitUntilSentAll << id();
|
||||||
if ( m_do_shutdown )
|
if ( m_do_shutdown )
|
||||||
{
|
{
|
||||||
//qDebug() << id() << " already shutting down";
|
//qDebug() << id() << " already shutting down";
|
||||||
@@ -128,7 +124,7 @@ Connection::shutdown( bool waitUntilSentAll )
|
|||||||
m_do_shutdown = true;
|
m_do_shutdown = true;
|
||||||
if ( !waitUntilSentAll )
|
if ( !waitUntilSentAll )
|
||||||
{
|
{
|
||||||
qDebug() << "Shutting down immediately " << id();
|
// qDebug() << "Shutting down immediately " << id();
|
||||||
actualShutdown();
|
actualShutdown();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@@ -146,10 +142,9 @@ Connection::shutdown( bool waitUntilSentAll )
|
|||||||
void
|
void
|
||||||
Connection::actualShutdown()
|
Connection::actualShutdown()
|
||||||
{
|
{
|
||||||
qDebug() << Q_FUNC_INFO;
|
qDebug() << Q_FUNC_INFO << m_actually_shutting_down << id();
|
||||||
if( m_actually_shutting_down )
|
if( m_actually_shutting_down )
|
||||||
{
|
{
|
||||||
qDebug() << "(already actually shutting down)";
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
m_actually_shutting_down = true;
|
m_actually_shutting_down = true;
|
||||||
@@ -159,7 +154,7 @@ Connection::actualShutdown()
|
|||||||
m_sock->disconnectFromHost();
|
m_sock->disconnectFromHost();
|
||||||
}
|
}
|
||||||
|
|
||||||
qDebug() << "EMITTING finished()";
|
// qDebug() << "EMITTING finished()";
|
||||||
emit finished();
|
emit finished();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -75,6 +75,13 @@ ControlConnection::setup()
|
|||||||
{
|
{
|
||||||
qDebug() << Q_FUNC_INFO << id() << name();
|
qDebug() << Q_FUNC_INFO << id() << name();
|
||||||
|
|
||||||
|
if ( !m_source.isNull() )
|
||||||
|
{
|
||||||
|
qDebug() << "This source seems to be online already.";
|
||||||
|
Q_ASSERT( false );
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
QString friendlyName;
|
QString friendlyName;
|
||||||
if ( Servent::isIPWhitelisted( m_sock->peerAddress() ) )
|
if ( Servent::isIPWhitelisted( m_sock->peerAddress() ) )
|
||||||
{
|
{
|
||||||
@@ -85,7 +92,7 @@ ControlConnection::setup()
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
friendlyName = name();
|
friendlyName = name();
|
||||||
|
|
||||||
// setup source and remote collection for this peer
|
// setup source and remote collection for this peer
|
||||||
m_source = SourceList::instance()->get( id(), friendlyName );
|
m_source = SourceList::instance()->get( id(), friendlyName );
|
||||||
m_source->setControlConnection( this );
|
m_source->setControlConnection( this );
|
||||||
|
@@ -75,7 +75,7 @@ DBSyncConnection::~DBSyncConnection()
|
|||||||
void
|
void
|
||||||
DBSyncConnection::idleTimeout()
|
DBSyncConnection::idleTimeout()
|
||||||
{
|
{
|
||||||
qDebug() << Q_FUNC_INFO << "*************";
|
qDebug() << Q_FUNC_INFO;
|
||||||
shutdown( true );
|
shutdown( true );
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -87,11 +87,6 @@ DBSyncConnection::changeState( State newstate )
|
|||||||
m_state = newstate;
|
m_state = newstate;
|
||||||
qDebug() << "DBSYNC State changed from" << s << "to" << newstate;
|
qDebug() << "DBSYNC State changed from" << s << "to" << newstate;
|
||||||
emit stateChanged( newstate, s, "" );
|
emit stateChanged( newstate, s, "" );
|
||||||
|
|
||||||
if ( newstate == SYNCED )
|
|
||||||
{
|
|
||||||
qDebug() << "Synced :)";
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -197,7 +192,7 @@ DBSyncConnection::handleMsg( msg_ptr msg )
|
|||||||
msg->is( Msg::DBOP ) &&
|
msg->is( Msg::DBOP ) &&
|
||||||
msg->payload() == "ok" )
|
msg->payload() == "ok" )
|
||||||
{
|
{
|
||||||
qDebug() << "No ops to apply, we are synced.";
|
// qDebug() << "No ops to apply, we are synced.";
|
||||||
changeState( SYNCED );
|
changeState( SYNCED );
|
||||||
// calc the collection stats, to updates the "X tracks" in the sidebar etc
|
// calc the collection stats, to updates the "X tracks" in the sidebar etc
|
||||||
// this is done automatically if you run a dbcmd to add files.
|
// this is done automatically if you run a dbcmd to add files.
|
||||||
|
@@ -102,7 +102,7 @@ Pipeline::resolve( const QList<query_ptr>& qlist, bool prioritized )
|
|||||||
int i = 0;
|
int i = 0;
|
||||||
foreach( const query_ptr& q, qlist )
|
foreach( const query_ptr& q, qlist )
|
||||||
{
|
{
|
||||||
qDebug() << Q_FUNC_INFO << (qlonglong)q.data() << q->toString();
|
// qDebug() << Q_FUNC_INFO << (qlonglong)q.data() << q->toString();
|
||||||
if ( !m_qids.contains( q->id() ) )
|
if ( !m_qids.contains( q->id() ) )
|
||||||
{
|
{
|
||||||
m_qids.insert( q->id(), q );
|
m_qids.insert( q->id(), q );
|
||||||
@@ -189,7 +189,7 @@ Pipeline::reportResults( QID qid, const QList< result_ptr >& results )
|
|||||||
if ( decQIDState( q ) == 0 )
|
if ( decQIDState( q ) == 0 )
|
||||||
{
|
{
|
||||||
// All resolvers have reported back their results for this query now
|
// All resolvers have reported back their results for this query now
|
||||||
qDebug() << "Finished resolving:" << q->toString();
|
qDebug() << "Finished resolving:" << q->toString() << q->numResults();
|
||||||
|
|
||||||
if ( !q->solved() )
|
if ( !q->solved() )
|
||||||
q->onResolvingFinished();
|
q->onResolvingFinished();
|
||||||
@@ -216,7 +216,7 @@ Pipeline::shuntNext()
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
qDebug() << Q_FUNC_INFO << m_qidsState.count();
|
// qDebug() << Q_FUNC_INFO << m_qidsState.count();
|
||||||
// Check if we are ready to dispatch more queries
|
// Check if we are ready to dispatch more queries
|
||||||
if ( m_qidsState.count() >= CONCURRENT_QUERIES )
|
if ( m_qidsState.count() >= CONCURRENT_QUERIES )
|
||||||
return;
|
return;
|
||||||
@@ -246,8 +246,8 @@ Pipeline::shunt( const query_ptr& q )
|
|||||||
|
|
||||||
if ( q->solved() )
|
if ( q->solved() )
|
||||||
{
|
{
|
||||||
qDebug() << "Query solved, pipeline aborted:" << q->toString()
|
// qDebug() << "Query solved, pipeline aborted:" << q->toString()
|
||||||
<< "numresults:" << q->results().length();
|
// << "numresults:" << q->results().length();
|
||||||
|
|
||||||
QList< result_ptr > rl;
|
QList< result_ptr > rl;
|
||||||
reportResults( q->id(), rl );
|
reportResults( q->id(), rl );
|
||||||
@@ -275,7 +275,7 @@ Pipeline::shunt( const query_ptr& q )
|
|||||||
lasttimeout = r->timeout();
|
lasttimeout = r->timeout();
|
||||||
|
|
||||||
// resolvers aren't allowed to block in this call:
|
// resolvers aren't allowed to block in this call:
|
||||||
qDebug() << "Dispatching to resolver" << r->name();
|
qDebug() << "Dispatching to resolver" << r->name() << q->toString();
|
||||||
|
|
||||||
thisResolver = i;
|
thisResolver = i;
|
||||||
r->resolve( q );
|
r->resolve( q );
|
||||||
@@ -291,7 +291,7 @@ Pipeline::shunt( const query_ptr& q )
|
|||||||
if ( thisResolver < m_resolvers.count() )
|
if ( thisResolver < m_resolvers.count() )
|
||||||
{
|
{
|
||||||
incQIDState( q );
|
incQIDState( q );
|
||||||
qDebug() << "Shunting in" << lasttimeout << "ms, q:" << q->toString();
|
// qDebug() << "Shunting in" << lasttimeout << "ms, q:" << q->toString();
|
||||||
new FuncTimeout( lasttimeout, boost::bind( &Pipeline::shunt, this, q ) );
|
new FuncTimeout( lasttimeout, boost::bind( &Pipeline::shunt, this, q ) );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -329,7 +329,7 @@ Pipeline::incQIDState( const Tomahawk::query_ptr& query )
|
|||||||
state = m_qidsState.value( query->id() ) + 1;
|
state = m_qidsState.value( query->id() ) + 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
qDebug() << Q_FUNC_INFO << "inserting to qidsstate:" << query->id() << state;
|
// qDebug() << Q_FUNC_INFO << "inserting to qidsstate:" << query->id() << state;
|
||||||
m_qidsState.insert( query->id(), state );
|
m_qidsState.insert( query->id(), state );
|
||||||
|
|
||||||
return state;
|
return state;
|
||||||
@@ -344,12 +344,12 @@ Pipeline::decQIDState( const Tomahawk::query_ptr& query )
|
|||||||
int state = m_qidsState.value( query->id() ) - 1;
|
int state = m_qidsState.value( query->id() ) - 1;
|
||||||
if ( state )
|
if ( state )
|
||||||
{
|
{
|
||||||
qDebug() << Q_FUNC_INFO << "replacing" << query->id() << state;
|
// qDebug() << Q_FUNC_INFO << "replacing" << query->id() << state;
|
||||||
m_qidsState.insert( query->id(), state );
|
m_qidsState.insert( query->id(), state );
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
qDebug() << Q_FUNC_INFO << "removing" << query->id() << state;
|
// qDebug() << Q_FUNC_INFO << "removing" << query->id() << state;
|
||||||
m_qidsState.remove( query->id() );
|
m_qidsState.remove( query->id() );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -112,7 +112,7 @@ Playlist::Playlist( const source_ptr& src,
|
|||||||
, m_lastmodified( lastmod )
|
, m_lastmodified( lastmod )
|
||||||
, m_shared( shared )
|
, m_shared( shared )
|
||||||
{
|
{
|
||||||
qDebug() << Q_FUNC_INFO << "1";
|
// qDebug() << Q_FUNC_INFO << "1";
|
||||||
init();
|
init();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -253,8 +253,8 @@ DynamicPlaylist::reportCreated( const Tomahawk::dynplaylist_ptr& self )
|
|||||||
Q_ASSERT( !author().isNull() );
|
Q_ASSERT( !author().isNull() );
|
||||||
Q_ASSERT( !author()->collection().isNull() );
|
Q_ASSERT( !author()->collection().isNull() );
|
||||||
// will emit Collection::playlistCreated(...)
|
// will emit Collection::playlistCreated(...)
|
||||||
qDebug() << "Creating dynplaylist belonging to:" << author().data() << author().isNull();
|
// qDebug() << "Creating dynplaylist belonging to:" << author().data() << author().isNull();
|
||||||
qDebug() << "REPORTING DYNAMIC PLAYLIST CREATED:" << this << author()->friendlyName();
|
// qDebug() << "REPORTING DYNAMIC PLAYLIST CREATED:" << this << author()->friendlyName();
|
||||||
author()->collection()->addDynamicPlaylist( self );
|
author()->collection()->addDynamicPlaylist( self );
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -431,7 +431,7 @@ QList< dyncontrol_ptr > DynamicPlaylist::variantsToControl( const QList< QVarian
|
|||||||
QList<dyncontrol_ptr> realControls;
|
QList<dyncontrol_ptr> realControls;
|
||||||
foreach( QVariantMap controlV, controlsV ) {
|
foreach( QVariantMap controlV, controlsV ) {
|
||||||
dyncontrol_ptr control = GeneratorFactory::createControl( controlV.value( "type" ).toString(), controlV.value( "selectedType" ).toString() );
|
dyncontrol_ptr control = GeneratorFactory::createControl( controlV.value( "type" ).toString(), controlV.value( "selectedType" ).toString() );
|
||||||
qDebug() << "CReating control with data:" << controlV;
|
qDebug() << "Creating control with data:" << controlV;
|
||||||
QJson::QObjectHelper::qvariant2qobject( controlV, control.data() );
|
QJson::QObjectHelper::qvariant2qobject( controlV, control.data() );
|
||||||
realControls << control;
|
realControls << control;
|
||||||
}
|
}
|
||||||
|
@@ -72,14 +72,21 @@ PlaylistItemDelegate::paint( QPainter* painter, const QStyleOptionViewItem& opti
|
|||||||
if ( !item || item->query().isNull() )
|
if ( !item || item->query().isNull() )
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
float opacity = 0.0;
|
||||||
painter->save();
|
painter->save();
|
||||||
if ( item->query()->results().count() )
|
if ( item->query()->results().count() )
|
||||||
painter->setOpacity( item->query()->results().at( 0 )->score() );
|
opacity = item->query()->results().first()->score();
|
||||||
else
|
|
||||||
painter->setOpacity( 0.0 );
|
|
||||||
|
|
||||||
if ( painter->opacity() < 0.3 )
|
QColor textcol, bgcol;
|
||||||
painter->setOpacity( 0.3 );
|
textcol = option.palette.color( QPalette::Foreground );
|
||||||
|
bgcol = option.palette.color( QPalette::Background );
|
||||||
|
|
||||||
|
opacity = qMax( (float)0.3, opacity );
|
||||||
|
int r = textcol.red(), g = textcol.green(), b = textcol.blue();
|
||||||
|
r = opacity * r + ( 1 - opacity ) * bgcol.red();
|
||||||
|
g = opacity * g + ( 1 - opacity ) * bgcol.green();
|
||||||
|
b = opacity * b + ( 1 - opacity ) * bgcol.blue();
|
||||||
|
textcol = QColor( r, g, b );
|
||||||
|
|
||||||
if ( item->isPlaying() )
|
if ( item->isPlaying() )
|
||||||
{
|
{
|
||||||
@@ -113,7 +120,14 @@ PlaylistItemDelegate::paint( QPainter* painter, const QStyleOptionViewItem& opti
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
QStyledItemDelegate::paint( painter, option, index );
|
if ( const QStyleOptionViewItem *vioption = qstyleoption_cast<const QStyleOptionViewItem *>(&option))
|
||||||
|
{
|
||||||
|
QStyleOptionViewItemV4 o( *vioption );
|
||||||
|
o.palette.setColor( QPalette::Text, textcol );
|
||||||
|
QStyledItemDelegate::paint( painter, o, index );
|
||||||
|
}
|
||||||
|
else
|
||||||
|
QStyledItemDelegate::paint( painter, option, index );
|
||||||
}
|
}
|
||||||
|
|
||||||
painter->restore();
|
painter->restore();
|
||||||
|
@@ -63,7 +63,7 @@ Query::addResults( const QList< Tomahawk::result_ptr >& newresults )
|
|||||||
{
|
{
|
||||||
bool becameSolved = false;
|
bool becameSolved = false;
|
||||||
{
|
{
|
||||||
// QMutexLocker lock( &m_mut );
|
QMutexLocker lock( &m_mutex );
|
||||||
m_results.append( newresults );
|
m_results.append( newresults );
|
||||||
qStableSort( m_results.begin(), m_results.end(), Query::resultSorter );
|
qStableSort( m_results.begin(), m_results.end(), Query::resultSorter );
|
||||||
|
|
||||||
@@ -101,7 +101,7 @@ void
|
|||||||
Query::removeResult( const Tomahawk::result_ptr& result )
|
Query::removeResult( const Tomahawk::result_ptr& result )
|
||||||
{
|
{
|
||||||
{
|
{
|
||||||
// QMutexLocker lock( &m_mut );
|
QMutexLocker lock( &m_mutex );
|
||||||
m_results.removeAll( result );
|
m_results.removeAll( result );
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -121,7 +121,7 @@ Query::onResolvingFinished()
|
|||||||
QList< result_ptr >
|
QList< result_ptr >
|
||||||
Query::results() const
|
Query::results() const
|
||||||
{
|
{
|
||||||
// QMutexLocker lock( &m_mut );
|
QMutexLocker lock( &m_mutex );
|
||||||
return m_results;
|
return m_results;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -129,7 +129,7 @@ Query::results() const
|
|||||||
unsigned int
|
unsigned int
|
||||||
Query::numResults() const
|
Query::numResults() const
|
||||||
{
|
{
|
||||||
// QMutexLocker lock( &m_mut );
|
QMutexLocker lock( &m_mutex );
|
||||||
return m_results.length();
|
return m_results.length();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -149,7 +149,18 @@ Query::id() const
|
|||||||
bool
|
bool
|
||||||
Query::resultSorter( const result_ptr& left, const result_ptr& right )
|
Query::resultSorter( const result_ptr& left, const result_ptr& right )
|
||||||
{
|
{
|
||||||
return left->score() > right->score();
|
const float ls = left->score();
|
||||||
|
const float rs = right->score();
|
||||||
|
|
||||||
|
if ( ls == rs )
|
||||||
|
{
|
||||||
|
if ( !left->collection().isNull() && left->collection()->source()->isLocal() )
|
||||||
|
return true;
|
||||||
|
else
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return ls > rs;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@@ -116,6 +116,8 @@ private:
|
|||||||
QString m_track;
|
QString m_track;
|
||||||
int m_duration;
|
int m_duration;
|
||||||
QString m_resultHint;
|
QString m_resultHint;
|
||||||
|
|
||||||
|
mutable QMutex m_mutex;
|
||||||
};
|
};
|
||||||
|
|
||||||
}; //ns
|
}; //ns
|
||||||
|
@@ -30,7 +30,7 @@
|
|||||||
using namespace Tomahawk;
|
using namespace Tomahawk;
|
||||||
|
|
||||||
|
|
||||||
Source::Source( int id, const QString &username )
|
Source::Source( int id, const QString& username )
|
||||||
: QObject()
|
: QObject()
|
||||||
, m_isLocal( false )
|
, m_isLocal( false )
|
||||||
, m_online( false )
|
, m_online( false )
|
||||||
@@ -38,7 +38,7 @@ Source::Source( int id, const QString &username )
|
|||||||
, m_id( id )
|
, m_id( id )
|
||||||
, m_cc( 0 )
|
, m_cc( 0 )
|
||||||
{
|
{
|
||||||
qDebug() << Q_FUNC_INFO;
|
qDebug() << Q_FUNC_INFO << id << username;
|
||||||
|
|
||||||
if ( id == 0 )
|
if ( id == 0 )
|
||||||
{
|
{
|
||||||
@@ -146,6 +146,7 @@ Source::setOnline()
|
|||||||
{
|
{
|
||||||
if ( m_online )
|
if ( m_online )
|
||||||
return;
|
return;
|
||||||
|
m_online = true;
|
||||||
|
|
||||||
// ensure username is in the database
|
// ensure username is in the database
|
||||||
DatabaseCommand_addSource* cmd = new DatabaseCommand_addSource( m_username, m_friendlyname );
|
DatabaseCommand_addSource* cmd = new DatabaseCommand_addSource( m_username, m_friendlyname );
|
||||||
@@ -153,7 +154,6 @@ Source::setOnline()
|
|||||||
SLOT( dbLoaded( unsigned int, const QString& ) ) );
|
SLOT( dbLoaded( unsigned int, const QString& ) ) );
|
||||||
Database::instance()->enqueue( QSharedPointer<DatabaseCommand>(cmd) );
|
Database::instance()->enqueue( QSharedPointer<DatabaseCommand>(cmd) );
|
||||||
|
|
||||||
m_online = true;
|
|
||||||
emit online();
|
emit online();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -83,7 +83,7 @@ AnimatedSplitter::hide( int index, bool animate )
|
|||||||
|
|
||||||
emit hidden( w );
|
emit hidden( w );
|
||||||
w->setMinimumHeight( minHeight );
|
w->setMinimumHeight( minHeight );
|
||||||
qDebug() << "animating to:" << w->height() << "from" << minHeight;
|
// qDebug() << "animating to:" << w->height() << "from" << minHeight;
|
||||||
|
|
||||||
m_animateForward = false;
|
m_animateForward = false;
|
||||||
if ( animate )
|
if ( animate )
|
||||||
|
@@ -17,6 +17,8 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#include "tomahawk/tomahawkapp.h"
|
#include "tomahawk/tomahawkapp.h"
|
||||||
|
|
||||||
|
#include "kdsingleapplicationguard/kdsingleapplicationguard.h"
|
||||||
#include <QTranslator>
|
#include <QTranslator>
|
||||||
|
|
||||||
#ifdef Q_WS_MAC
|
#ifdef Q_WS_MAC
|
||||||
@@ -25,9 +27,7 @@
|
|||||||
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[] )
|
||||||
{
|
{
|
||||||
@@ -39,7 +39,6 @@ main( int argc, char *argv[] )
|
|||||||
// used for url handler
|
// used for url handler
|
||||||
AEEventHandlerUPP h = AEEventHandlerUPP( appleEventHandler );
|
AEEventHandlerUPP h = AEEventHandlerUPP( appleEventHandler );
|
||||||
AEInstallEventHandler( 'GURL', 'GURL', h, 0, false );
|
AEInstallEventHandler( 'GURL', 'GURL', h, 0, false );
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
TomahawkApp a( argc, argv );
|
TomahawkApp a( argc, argv );
|
||||||
@@ -52,9 +51,9 @@ main( int argc, char *argv[] )
|
|||||||
translator.load( QString( ":/lang/tomahawk_" ) + locale );
|
translator.load( QString( ":/lang/tomahawk_" ) + locale );
|
||||||
a.installTranslator( &translator );
|
a.installTranslator( &translator );
|
||||||
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 )
|
||||||
|
@@ -163,8 +163,6 @@ MusicScanner::startScan()
|
|||||||
DatabaseCommand_DirMtimes* cmd = new DatabaseCommand_DirMtimes( TomahawkSettings::instance()->scannerPaths() );
|
DatabaseCommand_DirMtimes* cmd = new DatabaseCommand_DirMtimes( TomahawkSettings::instance()->scannerPaths() );
|
||||||
connect( cmd, SIGNAL( done( QMap<QString, unsigned int> ) ),
|
connect( cmd, SIGNAL( done( QMap<QString, unsigned int> ) ),
|
||||||
SLOT( setMtimes( QMap<QString, unsigned int> ) ) );
|
SLOT( setMtimes( QMap<QString, unsigned int> ) ) );
|
||||||
connect( cmd, SIGNAL( done( QMap<QString, unsigned int> ) ),
|
|
||||||
SLOT( scan() ) );
|
|
||||||
|
|
||||||
Database::instance()->enqueue( QSharedPointer<DatabaseCommand>(cmd) );
|
Database::instance()->enqueue( QSharedPointer<DatabaseCommand>(cmd) );
|
||||||
}
|
}
|
||||||
@@ -173,7 +171,9 @@ MusicScanner::startScan()
|
|||||||
void
|
void
|
||||||
MusicScanner::setMtimes( const QMap<QString, unsigned int>& m )
|
MusicScanner::setMtimes( const QMap<QString, unsigned int>& m )
|
||||||
{
|
{
|
||||||
|
qDebug() << Q_FUNC_INFO << m.count();
|
||||||
m_dirmtimes = m;
|
m_dirmtimes = m;
|
||||||
|
scan();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@@ -32,81 +32,11 @@ QtScriptResolver::QtScriptResolver( const QString& scriptPath )
|
|||||||
{
|
{
|
||||||
qDebug() << Q_FUNC_INFO << scriptPath;
|
qDebug() << Q_FUNC_INFO << scriptPath;
|
||||||
|
|
||||||
m_thread = new ScriptThread( scriptPath, this );
|
m_engine = new ScriptEngine( this );
|
||||||
connect( m_thread, SIGNAL( engineFound( QString, unsigned int, unsigned int, unsigned int ) ),
|
QFile scriptFile( scriptPath );
|
||||||
SLOT( onEngineFound( QString, unsigned int, unsigned int, unsigned int ) ) );
|
|
||||||
|
|
||||||
m_thread->start();
|
|
||||||
|
|
||||||
connect( this, SIGNAL( destroyed( QObject* ) ), m_thread, SLOT( deleteLater() ) );
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
QtScriptResolver::~QtScriptResolver()
|
|
||||||
{
|
|
||||||
Tomahawk::Pipeline::instance()->removeResolver( this );
|
|
||||||
delete m_thread;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void
|
|
||||||
QtScriptResolver::resolve( const Tomahawk::query_ptr& query )
|
|
||||||
{
|
|
||||||
m_thread->resolve( query );
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void
|
|
||||||
QtScriptResolver::onEngineFound( const QString& name, unsigned int weight, unsigned int timeout, unsigned int preference )
|
|
||||||
{
|
|
||||||
m_name = name;
|
|
||||||
m_weight = weight;
|
|
||||||
m_timeout = timeout;
|
|
||||||
m_preference = preference;
|
|
||||||
|
|
||||||
qDebug() << "QTSCRIPT" << filePath() << "READY," << endl
|
|
||||||
<< "name" << m_name << endl
|
|
||||||
<< "weight" << m_weight << endl
|
|
||||||
<< "timeout" << m_timeout << endl
|
|
||||||
<< "preference" << m_preference;
|
|
||||||
|
|
||||||
m_ready = true;
|
|
||||||
Tomahawk::Pipeline::instance()->addResolver( this );
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
ScriptThread::ScriptThread( const QString& scriptPath, QtScriptResolver* parent )
|
|
||||||
: QThread()
|
|
||||||
, m_parent( parent )
|
|
||||||
, m_scriptPath( scriptPath )
|
|
||||||
{
|
|
||||||
moveToThread( this );
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void
|
|
||||||
ScriptThread::resolve( const Tomahawk::query_ptr& query )
|
|
||||||
{
|
|
||||||
m_engine->resolve( query );
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void
|
|
||||||
ScriptThread::run()
|
|
||||||
{
|
|
||||||
QTimer::singleShot( 0, this, SLOT( initEngine() ) );
|
|
||||||
exec();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void
|
|
||||||
ScriptThread::initEngine()
|
|
||||||
{
|
|
||||||
m_engine = new ScriptEngine( m_parent, this );
|
|
||||||
QFile scriptFile( m_scriptPath );
|
|
||||||
if ( !scriptFile.open( QIODevice::ReadOnly ) )
|
if ( !scriptFile.open( QIODevice::ReadOnly ) )
|
||||||
{
|
{
|
||||||
qDebug() << Q_FUNC_INFO << "Failed loading JavaScript resolver:" << m_scriptPath;
|
qDebug() << Q_FUNC_INFO << "Failed loading JavaScript resolver:" << scriptPath;
|
||||||
deleteLater();
|
deleteLater();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -115,42 +45,39 @@ ScriptThread::initEngine()
|
|||||||
m_engine->mainFrame()->evaluateJavaScript( scriptFile.readAll() );
|
m_engine->mainFrame()->evaluateJavaScript( scriptFile.readAll() );
|
||||||
scriptFile.close();
|
scriptFile.close();
|
||||||
|
|
||||||
QString name;
|
|
||||||
unsigned int weight, preference, timeout;
|
|
||||||
QVariantMap m = m_engine->mainFrame()->evaluateJavaScript( "getSettings();" ).toMap();
|
QVariantMap m = m_engine->mainFrame()->evaluateJavaScript( "getSettings();" ).toMap();
|
||||||
name = m.value( "name" ).toString();
|
m_name = m.value( "name" ).toString();
|
||||||
weight = m.value( "weight", 0 ).toUInt();
|
m_weight = m.value( "weight", 0 ).toUInt();
|
||||||
timeout = m.value( "timeout", 25 ).toUInt() * 1000;
|
m_timeout = m.value( "timeout", 25 ).toUInt() * 1000;
|
||||||
preference = m.value( "preference", 0 ).toUInt();
|
m_preference = m.value( "preference", 0 ).toUInt();
|
||||||
|
|
||||||
qDebug() << Q_FUNC_INFO << name << weight << timeout << preference;
|
qDebug() << Q_FUNC_INFO << m_name << m_weight << m_timeout << m_preference;
|
||||||
emit engineFound( name, weight, timeout, preference );
|
|
||||||
|
m_ready = true;
|
||||||
|
Tomahawk::Pipeline::instance()->addResolver( this );
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
QtScriptResolver::~QtScriptResolver()
|
||||||
|
{
|
||||||
|
Tomahawk::Pipeline::instance()->removeResolver( this );
|
||||||
|
delete m_engine;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
ScriptEngine::resolve( const Tomahawk::query_ptr& query )
|
QtScriptResolver::resolve( const Tomahawk::query_ptr& query )
|
||||||
{
|
{
|
||||||
if ( QThread::currentThread() != thread() )
|
|
||||||
{
|
|
||||||
// qDebug() << "Reinvoking in correct thread:" << Q_FUNC_INFO;
|
|
||||||
QMetaObject::invokeMethod( this, "resolve",
|
|
||||||
Qt::QueuedConnection,
|
|
||||||
Q_ARG(Tomahawk::query_ptr, query)
|
|
||||||
);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
qDebug() << Q_FUNC_INFO << query->toString();
|
qDebug() << Q_FUNC_INFO << query->toString();
|
||||||
QString eval = QString( "resolve( '%1', '%2', '%3', '%4' );" )
|
QString eval = QString( "resolve( '%1', '%2', '%3', '%4' );" )
|
||||||
.arg( query->id().replace( "'", "\\'" ) )
|
.arg( query->id().replace( "'", "\\'" ) )
|
||||||
.arg( query->artist().replace( "'", "\\'" ) )
|
.arg( query->artist().replace( "'", "\\'" ) )
|
||||||
.arg( query->album().replace( "'", "\\'" ) )
|
.arg( query->album().replace( "'", "\\'" ) )
|
||||||
.arg( query->track().replace( "'", "\\'" ) );
|
.arg( query->track().replace( "'", "\\'" ) );
|
||||||
|
|
||||||
QList< Tomahawk::result_ptr > results;
|
QList< Tomahawk::result_ptr > results;
|
||||||
|
|
||||||
QVariantMap m = mainFrame()->evaluateJavaScript( eval ).toMap();
|
QVariantMap m = m_engine->mainFrame()->evaluateJavaScript( eval ).toMap();
|
||||||
qDebug() << "JavaScript Result:" << m;
|
qDebug() << "JavaScript Result:" << m;
|
||||||
|
|
||||||
const QString qid = query->id();
|
const QString qid = query->id();
|
||||||
@@ -169,9 +96,9 @@ ScriptEngine::resolve( const Tomahawk::query_ptr& query )
|
|||||||
rp->setBitrate( m.value( "bitrate" ).toUInt() );
|
rp->setBitrate( m.value( "bitrate" ).toUInt() );
|
||||||
rp->setUrl( m.value( "url" ).toString() );
|
rp->setUrl( m.value( "url" ).toString() );
|
||||||
rp->setSize( m.value( "size" ).toUInt() );
|
rp->setSize( m.value( "size" ).toUInt() );
|
||||||
rp->setScore( m.value( "score" ).toFloat() * ( (float)m_resolver->weight() / 100.0 ) );
|
rp->setScore( m.value( "score" ).toFloat() * ( (float)weight() / 100.0 ) );
|
||||||
rp->setRID( uuid() );
|
rp->setRID( uuid() );
|
||||||
rp->setFriendlySource( m_resolver->name() );
|
rp->setFriendlySource( name() );
|
||||||
|
|
||||||
if ( m.contains( "year" ) )
|
if ( m.contains( "year" ) )
|
||||||
{
|
{
|
||||||
|
@@ -30,7 +30,6 @@
|
|||||||
#include <QtWebKit/QWebPage>
|
#include <QtWebKit/QWebPage>
|
||||||
#include <QtWebKit/QWebFrame>
|
#include <QtWebKit/QWebFrame>
|
||||||
|
|
||||||
class ScriptThread;
|
|
||||||
class QtScriptResolver;
|
class QtScriptResolver;
|
||||||
|
|
||||||
class ScriptEngine : public QWebPage
|
class ScriptEngine : public QWebPage
|
||||||
@@ -38,18 +37,16 @@ class ScriptEngine : public QWebPage
|
|||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
explicit ScriptEngine( QtScriptResolver* resolver, ScriptThread* parent )
|
explicit ScriptEngine( QtScriptResolver* parent )
|
||||||
: QWebPage( (QObject*)parent )
|
: QWebPage( (QObject*) parent )
|
||||||
, m_parent( parent )
|
, m_parent( parent )
|
||||||
, m_resolver( resolver )
|
{
|
||||||
{}
|
}
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
void resolve( const Tomahawk::query_ptr& query );
|
|
||||||
|
|
||||||
bool shouldInterruptJavaScript()
|
bool shouldInterruptJavaScript()
|
||||||
{
|
{
|
||||||
return false;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
@@ -57,32 +54,7 @@ protected:
|
|||||||
{ qDebug() << "JAVASCRIPT ERROR:" << message << lineNumber << sourceID; }
|
{ qDebug() << "JAVASCRIPT ERROR:" << message << lineNumber << sourceID; }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
ScriptThread* m_parent;
|
|
||||||
QtScriptResolver* m_resolver;
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
class ScriptThread : public QThread
|
|
||||||
{
|
|
||||||
Q_OBJECT
|
|
||||||
|
|
||||||
public:
|
|
||||||
ScriptThread( const QString& scriptPath, QtScriptResolver* parent );
|
|
||||||
|
|
||||||
void run();
|
|
||||||
|
|
||||||
virtual void resolve( const Tomahawk::query_ptr& query );
|
|
||||||
|
|
||||||
signals:
|
|
||||||
void engineFound( const QString& name, unsigned int weight, unsigned int timeout, unsigned int preference );
|
|
||||||
|
|
||||||
private slots:
|
|
||||||
void initEngine();
|
|
||||||
|
|
||||||
private:
|
|
||||||
ScriptEngine* m_engine;
|
|
||||||
QtScriptResolver* m_parent;
|
QtScriptResolver* m_parent;
|
||||||
QString m_scriptPath;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
@@ -106,11 +78,8 @@ public slots:
|
|||||||
signals:
|
signals:
|
||||||
void finished();
|
void finished();
|
||||||
|
|
||||||
private slots:
|
|
||||||
void onEngineFound( const QString& name, unsigned int weight, unsigned int timeout, unsigned int preference );
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
ScriptThread* m_thread;
|
ScriptEngine* m_engine;
|
||||||
|
|
||||||
QString m_name;
|
QString m_name;
|
||||||
unsigned int m_weight, m_preference, m_timeout;
|
unsigned int m_weight, m_preference, m_timeout;
|
||||||
|
@@ -54,7 +54,7 @@ Jabber_p::Jabber_p( const QString& jid, const QString& password, const QString&
|
|||||||
|
|
||||||
if( m_jid.resource().find( "tomahawk" ) == std::string::npos )
|
if( m_jid.resource().find( "tomahawk" ) == std::string::npos )
|
||||||
{
|
{
|
||||||
qDebug() << "!!! Setting your resource to 'tomahawk' prior to logging in to jabber";
|
// qDebug() << "!!! Setting your resource to 'tomahawk' prior to logging in to jabber";
|
||||||
m_jid.setResource( QString( "tomahawk%1" ).arg( qrand() ).toStdString() );
|
m_jid.setResource( QString( "tomahawk%1" ).arg( qrand() ).toStdString() );
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -230,8 +230,8 @@ Jabber_p::sendMsg( const QString& to, const QString& msg )
|
|||||||
{
|
{
|
||||||
if ( QThread::currentThread() != thread() )
|
if ( QThread::currentThread() != thread() )
|
||||||
{
|
{
|
||||||
qDebug() << Q_FUNC_INFO << "invoking in correct thread, not"
|
// qDebug() << Q_FUNC_INFO << "invoking in correct thread, not"
|
||||||
<< QThread::currentThread();
|
// << QThread::currentThread();
|
||||||
|
|
||||||
QMetaObject::invokeMethod( this, "sendMsg",
|
QMetaObject::invokeMethod( this, "sendMsg",
|
||||||
Qt::QueuedConnection,
|
Qt::QueuedConnection,
|
||||||
@@ -297,7 +297,7 @@ Jabber_p::addContact( const QString& jid, const QString& msg )
|
|||||||
void
|
void
|
||||||
Jabber_p::onConnect()
|
Jabber_p::onConnect()
|
||||||
{
|
{
|
||||||
qDebug() << "Connected to the XMPP server";
|
qDebug() << "Connected to the XMPP server" << m_jid.full().c_str();
|
||||||
// update jid resource, servers like gtalk use resource binding and may
|
// update jid resource, servers like gtalk use resource binding and may
|
||||||
// have changed our requested /resource
|
// have changed our requested /resource
|
||||||
if ( m_client->resource() != m_jid.resource() )
|
if ( m_client->resource() != m_jid.resource() )
|
||||||
@@ -307,7 +307,6 @@ Jabber_p::onConnect()
|
|||||||
emit jidChanged( jidstr );
|
emit jidChanged( jidstr );
|
||||||
}
|
}
|
||||||
|
|
||||||
qDebug() << "Connected as:" << m_jid.full().c_str();
|
|
||||||
emit connected();
|
emit connected();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -536,7 +535,7 @@ gloox::Roster::const_iterator it = roster.begin();
|
|||||||
for ( ; it != roster.end(); ++it )
|
for ( ; it != roster.end(); ++it )
|
||||||
{
|
{
|
||||||
if ( (*it).second->subscription() != gloox::S10nBoth ) continue;
|
if ( (*it).second->subscription() != gloox::S10nBoth ) continue;
|
||||||
qDebug() << (*it).second->jid().c_str() << (*it).second->name().c_str();
|
// qDebug() << (*it).second->jid().c_str() << (*it).second->name().c_str();
|
||||||
//printf("JID: %s\n", (*it).second->jid().c_str());
|
//printf("JID: %s\n", (*it).second->jid().c_str());
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -559,8 +558,6 @@ Jabber_p::handlePresence( const gloox::Presence& presence )
|
|||||||
gloox::JID jid = presence.from();
|
gloox::JID jid = presence.from();
|
||||||
QString fulljid( jid.full().c_str() );
|
QString fulljid( jid.full().c_str() );
|
||||||
|
|
||||||
qDebug() << "* handleRosterPresence" << fulljid << presence.subtype();
|
|
||||||
|
|
||||||
if( jid == m_jid )
|
if( jid == m_jid )
|
||||||
return;
|
return;
|
||||||
|
|
||||||
@@ -582,6 +579,7 @@ Jabber_p::handlePresence( const gloox::Presence& presence )
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
qDebug() << "* handleRosterPresence" << fulljid << presence.subtype();
|
||||||
//qDebug() << "handling presence for resource of" << res;
|
//qDebug() << "handling presence for resource of" << res;
|
||||||
|
|
||||||
//qDebug() << Q_FUNC_INFO << "jid:" << QString::fromStdString(item.jid())
|
//qDebug() << Q_FUNC_INFO << "jid:" << QString::fromStdString(item.jid())
|
||||||
|
@@ -81,6 +81,9 @@ ofstream logfile;
|
|||||||
|
|
||||||
void TomahawkLogHandler( QtMsgType type, const char *msg )
|
void TomahawkLogHandler( QtMsgType type, const char *msg )
|
||||||
{
|
{
|
||||||
|
static QMutex s_mutex;
|
||||||
|
|
||||||
|
QMutexLocker locker( &s_mutex );
|
||||||
switch( type )
|
switch( type )
|
||||||
{
|
{
|
||||||
case QtDebugMsg:
|
case QtDebugMsg:
|
||||||
|
Reference in New Issue
Block a user