1
0
mirror of https://github.com/tomahawk-player/tomahawk.git synced 2025-09-08 21:20:45 +02:00

Compare commits

..

1 Commits
gfw ... win7

Author SHA1 Message Date
Leo Franchi
9a58b9072d test win7 translucency 2011-06-01 19:22:26 -04:00
320 changed files with 3396 additions and 11072 deletions

3
.gitignore vendored
View File

@@ -12,6 +12,3 @@ moc_*
thirdparty/qtweetlib/WARNING-twitter-api-keys
.kdev4
tomahawk.kdev4
clang/
win/
gcc/

View File

@@ -1,6 +1,5 @@
PROJECT( tomahawk )
CMAKE_MINIMUM_REQUIRED( VERSION 2.8 )
SET( CMAKE_MODULE_PATH "${CMAKE_MODULE_PATH}" "${CMAKE_SOURCE_DIR}/CMakeModules" )
IF( ${CMAKE_VERSION} VERSION_GREATER 2.8.3 )
CMAKE_POLICY(SET CMP0017 NEW)
@@ -12,43 +11,15 @@ ENDIF( ${CMAKE_VERSION} VERSION_GREATER 2.8.3 )
SET( TOMAHAWK_ORGANIZATION_NAME "Tomahawk" )
SET( TOMAHAWK_ORGANIZATION_DOMAIN "tomahawk-player.org" )
SET( TOMAHAWK_APPLICATION_NAME "Tomahawk" )
SET( TOMAHAWK_DESCRIPTION_SUMMARY "The social media player" )
SET( TOMAHAWK_VERSION_MAJOR 0 )
SET( TOMAHAWK_VERSION_MINOR 1 )
SET( TOMAHAWK_VERSION_PATCH 0 )
# SET( TOMAHAWK_VERSION_RC 0 )
IF( NOT CMAKE_BUILD_TYPE STREQUAL "Release" )
# Use the date as the tweak level.
INCLUDE( ${CMAKE_MODULE_PATH}/kwsysDateStamp.cmake )
SET( TOMAHAWK_VERSION_TWEAK "${KWSYS_DATE_STAMP_YEAR}${KWSYS_DATE_STAMP_MONTH}${KWSYS_DATE_STAMP_DAY}" )
INCLUDE( ${CMAKE_MODULE_PATH}/CMakeVersionSource.cmake )
ENDIF()
SET( TOMAHAWK_VERSION ${TOMAHAWK_VERSION_MAJOR}.${TOMAHAWK_VERSION_MINOR}.${TOMAHAWK_VERSION_PATCH} )
IF( ${TOMAHAWK_VERSION_TWEAK} GREATER 0)
SET( TOMAHAWK_VERSION ${TOMAHAWK_VERSION}.${TOMAHAWK_VERSION_TWEAK} )
ENDIF()
IF( TOMAHAWK_VERSION_RC )
SET( CMake_VERSION ${TOMAHAWK_VERSION}-rc${TOMAHAWK_VERSION_RC} )
ENDIF()
IF( CMAKE_VERSION_SOURCE )
SET( TOMAHAWK_VERSION ${TOMAHAWK_VERSION}-${CMAKE_VERSION_SOURCE} )
ENDIF()
SET( TOMAHAWK_VERSION "0.1.0" )
# set paths
SET( CMAKE_MODULE_PATH "${CMAKE_MODULE_PATH}" "${CMAKE_SOURCE_DIR}/CMakeModules" )
SET( THIRDPARTY_DIR ${CMAKE_SOURCE_DIR}/thirdparty )
SET( CMAKE_RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}" )
SET( CMAKE_LIBRARY_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}" )
SET( CMAKE_ARCHIVE_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}" )
# installer creation
INCLUDE( CPack.cmake )
SET(CMAKE_RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}")
SET(CMAKE_LIBRARY_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}")
SET(CMAKE_ARCHIVE_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}")
# Check if we need qtgui:
IF( "${gui}" STREQUAL "no" )

View File

@@ -1,37 +0,0 @@
# Try to identify the current development source version.
set(CMAKE_VERSION_SOURCE "")
if(EXISTS ${CMAKE_SOURCE_DIR}/.git/HEAD)
find_program(GIT_EXECUTABLE NAMES git git.cmd)
mark_as_advanced(GIT_EXECUTABLE)
if(GIT_EXECUTABLE)
execute_process(
COMMAND ${GIT_EXECUTABLE} rev-parse --verify -q --short=4 HEAD
OUTPUT_VARIABLE head
OUTPUT_STRIP_TRAILING_WHITESPACE
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
)
if(head)
set(CMAKE_VERSION_SOURCE "g${head}")
execute_process(
COMMAND ${GIT_EXECUTABLE} update-index -q --refresh
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
)
execute_process(
COMMAND ${GIT_EXECUTABLE} diff-index --name-only HEAD --
OUTPUT_VARIABLE dirty
OUTPUT_STRIP_TRAILING_WHITESPACE
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
)
if(dirty)
set(CMAKE_VERSION_SOURCE "${CMAKE_VERSION_SOURCE}-dirty")
endif()
endif()
endif()
elseif(EXISTS ${CMAKE_SOURCE_DIR}/CVS/Repository)
file(READ ${CMAKE_SOURCE_DIR}/CVS/Repository repo)
set(branch "")
if("${repo}" MATCHES "\\.git/")
string(REGEX REPLACE ".*\\.git/([^\r\n]*).*" "-\\1" branch "${repo}")
endif()
set(CMAKE_VERSION_SOURCE "cvs${branch}")
endif()

View File

@@ -1,24 +0,0 @@
[Settings]
NumFields=3
[Field 1]
Type=Label
Left=0
Right=-1
Top=0
Bottom=24
[Field 2]
Type=RadioButton
Left=30
Right=-1
Top=50
Bottom=58
State=1
[Field 3]
Type=RadioButton
Left=30
Right=-1
Top=70
Bottom=78

View File

@@ -1,665 +0,0 @@
;Tomahawk installer script.
;-----------------------------------------------------------------------------
; Some installer script options (comment-out options not required)
;-----------------------------------------------------------------------------
;!define OPTION_LICENSE_AGREEMENT
!define OPTION_UAC_PLUGIN_ENHANCED
!define OPTION_SECTION_SC_START_MENU
!define OPTION_SECTION_SC_DESKTOP
!define OPTION_SECTION_SC_QUICK_LAUNCH
!define OPTION_FINISHPAGE
!define OPTION_FINISHPAGE_LAUNCHER
!define OPTION_FINISHPAGE_RELEASE_NOTES
;-----------------------------------------------------------------------------
; Some paths.
;-----------------------------------------------------------------------------
!ifndef MING_PATH
!define MING_PATH "/usr/i686-w64-mingw32/sys-root/mingw"
!endif
!define MING_BIN "${MING_PATH}/bin"
!define MING_LIB "${MING_PATH}/lib"
!define BUILD_PATH "@CMAKE_BINARY_DIR@"
!define QT_DLL_PATH "${MING_BIN}"
!define SQLITE_DLL_PATH "${MING_LIB}/qt4/plugins/sqldrivers"
!define IMAGEFORMATS_DLL_PATH "${MING_LIB}/qt4/plugins/imageformats"
!define VLC_PLUGIN_PATH "${MING_LIB}\vlc\plugins"
!define NSI_PATH "@CMAKE_SOURCE_DIR@/admin/win/nsi"
;-----------------------------------------------------------------------------
; Increment installer revision number as part of this script.
;-----------------------------------------------------------------------------
!define /file REVISION_LAST ${NSI_PATH}/revision.txt
!define /math REVISION ${REVISION_LAST} + 1
!delfile revision.txt
!appendfile revision.txt ${REVISION}
!define VER_MAJOR "@CPACK_PACKAGE_VERSION_MAJOR@"
!define VER_MINOR "@CPACK_PACKAGE_VERSION_MINOR@"
!define VER_BUILD "@CPACK_PACKAGE_VERSION_PATCH@"
!define VERSION "@CPACK_PACKAGE_VERSION@"
;-----------------------------------------------------------------------------
; Installer build timestamp.
;-----------------------------------------------------------------------------
!define /date BUILD_TIME "built on %Y/%m/%d at %I:%M %p (rev. ${REVISION})"
;-----------------------------------------------------------------------------
; Initial installer setup and definitions.
;-----------------------------------------------------------------------------
Name "@CPACK_NSIS_PACKAGE_NAME@"
Caption "Tomahawk Installer"
BrandingText "Tomahawk ${VERSION} -- ${BUILD_TIME}"
OutFile "@CPACK_TOPLEVEL_DIRECTORY@/@CPACK_OUTPUT_FILE_NAME@"
InstallDir "$PROGRAMFILES\@CPACK_PACKAGE_INSTALL_DIRECTORY@"
InstallDirRegKey HKCU "Software\Tomahawk" ""
InstType Standard
InstType Full
InstType Minimal
CRCCheck On
SetCompressor @CPACK_NSIS_COMPRESSOR@
RequestExecutionLevel user ;Now using the UAC plugin.
ReserveFile NSIS.InstallOptions.ini
ReserveFile "${NSISDIR}\Plugins\InstallOptions.dll"
@CPACK_NSIS_SECTION_SELECTED_VARS@
;-----------------------------------------------------------------------------
; Include some required header files.
;-----------------------------------------------------------------------------
!include LogicLib.nsh ;Used by APPDATA uninstaller.
!include nsDialogs.nsh ;Used by APPDATA uninstaller.
!include MUI2.nsh ;Used by APPDATA uninstaller.
!include InstallOptions.nsh ;Required by MUI2 to support old MUI_INSTALLOPTIONS.
!include Memento.nsh ;Remember user selections.
!include WinVer.nsh ;Windows version detection.
!include WordFunc.nsh ;Used by VersionCompare macro function.
!include UAC.nsh ;Used by the UAC elevation to install as user or admin.
;-----------------------------------------------------------------------------
; Memento selections stored in registry.
;-----------------------------------------------------------------------------
!define MEMENTO_REGISTRY_ROOT HKLM
!define MEMENTO_REGISTRY_KEY Software\Microsoft\Windows\CurrentVersion\Uninstall\Tomahawk
;-----------------------------------------------------------------------------
; Modern User Interface (MUI) defintions and setup.
;-----------------------------------------------------------------------------
!define MUI_ABORTWARNING
!define MUI_ICON ${NSI_PATH}\installer.ico
!define MUI_UNICON ${NSI_PATH}\installer.ico
!define MUI_WELCOMEFINISHPAGE_BITMAP ${NSI_PATH}\welcome.bmp
!define MUI_WELCOMEPAGE_TITLE "@CPACK_PACKAGE_NAME@ ${VERSION} Setup$\r$\nInstaller Build Revision ${REVISION}"
!define MUI_WELCOMEPAGE_TEXT "This wizard will guide you through the installation.$\r$\n$\r$\n$_CLICK"
!define MUI_HEADERIMAGE
!define MUI_HEADERIMAGE_BITMAP ${NSI_PATH}\page_header.bmp
!define MUI_COMPONENTSPAGE_SMALLDESC
!define MUI_FINISHPAGE_TITLE "@CPACK_PACKAGE_NAME@ Install Completed"
!define MUI_FINISHPAGE_LINK "Click here to visit the @CPACK_PACKAGE_NAME@ website."
!define MUI_FINISHPAGE_LINK_LOCATION "http://@TOMAHAWK_ORGANIZATION_DOMAIN@"
!define MUI_FINISHPAGE_NOREBOOTSUPPORT
!ifdef OPTION_FINISHPAGE_RELEASE_NOTES
!define MUI_FINISHPAGE_SHOWREADME_NOTCHECKED
!define MUI_FINISHPAGE_SHOWREADME "$INSTDIR\NOTES.txt"
!define MUI_FINISHPAGE_SHOWREADME_TEXT "Show release notes"
!endif
!ifdef OPTION_FINISHPAGE_LAUNCHER
!define MUI_FINISHPAGE_NOAUTOCLOSE
!define MUI_FINISHPAGE_RUN
!define MUI_FINISHPAGE_RUN_FUNCTION "LaunchTomahawk"
!endif
;-----------------------------------------------------------------------------
; Page macros.
;-----------------------------------------------------------------------------
!insertmacro MUI_PAGE_WELCOME
!ifdef OPTION_LICENSE_AGREEMENT
!insertmacro MUI_PAGE_LICENSE "LICENSE.txt"
!endif
Page custom PageReinstall PageLeaveReinstall
!insertmacro MUI_PAGE_COMPONENTS
!insertmacro MUI_PAGE_DIRECTORY
!insertmacro MUI_PAGE_INSTFILES
!ifdef OPTION_FINISHPAGE
!insertmacro MUI_PAGE_FINISH
!endif
!insertmacro MUI_UNPAGE_CONFIRM
UninstPage custom un.UnPageUserAppData un.UnPageUserAppDataLeave
!insertmacro MUI_UNPAGE_INSTFILES
;-----------------------------------------------------------------------------
; Other MUI macros.
;-----------------------------------------------------------------------------
!insertmacro MUI_LANGUAGE "English"
##############################################################################
# #
# FINISH PAGE LAUNCHER FUNCTIONS #
# #
##############################################################################
Function LaunchTomahawk
${UAC.CallFunctionAsUser} LaunchTomahawkAsUser
FunctionEnd
Function LaunchTomahawkAsUser
Exec "$INSTDIR\tomahawk.exe"
FunctionEnd
##############################################################################
# #
# PROCESS HANDLING FUNCTIONS AND MACROS #
# #
##############################################################################
!macro CheckForProcess processName gotoWhenFound gotoWhenNotFound
Processes::FindProcess ${processName}
StrCmp $R0 "0" ${gotoWhenNotFound} ${gotoWhenFound}
!macroend
!macro ConfirmEndProcess processName
MessageBox MB_YESNO|MB_ICONEXCLAMATION \
"Found ${processName} process(s) which need to be stopped.$\nDo you want the installer to stop these for you?" \
IDYES process_${processName}_kill IDNO process_${processName}_ended
process_${processName}_kill:
DetailPrint "Killing ${processName} processes."
Processes::KillProcess ${processName}
Sleep 1500
StrCmp $R0 "1" process_${processName}_ended
DetailPrint "Process to kill not found!"
process_${processName}_ended:
!macroend
!macro CheckAndConfirmEndProcess processName
!insertmacro CheckForProcess ${processName} 0 no_process_${processName}_to_end
!insertmacro ConfirmEndProcess ${processName}
no_process_${processName}_to_end:
!macroend
Function EnsureTomahawkShutdown
!insertmacro CheckAndConfirmEndProcess "tomahawk.exe"
FunctionEnd
##############################################################################
# #
# RE-INSTALLER FUNCTIONS #
# #
##############################################################################
Function PageReinstall
ReadRegStr $R0 HKLM "Software\Tomahawk" ""
StrCmp $R0 "" 0 +2
Abort
;Detect version
ReadRegDWORD $R0 HKLM "Software\Tomahawk" "VersionMajor"
IntCmp $R0 ${VER_MAJOR} minor_check new_version older_version
minor_check:
ReadRegDWORD $R0 HKLM "Software\Tomahawk" "VersionMinor"
IntCmp $R0 ${VER_MINOR} build_check new_version older_version
build_check:
ReadRegDWORD $R0 HKLM "Software\Tomahawk" "VersionBuild"
IntCmp $R0 ${VER_BUILD} revision_check new_version older_version
revision_check:
ReadRegDWORD $R0 HKLM "Software\Tomahawk" "VersionRevision"
IntCmp $R0 ${REVISION} same_version new_version older_version
new_version:
!insertmacro INSTALLOPTIONS_WRITE "NSIS.InstallOptions.ini" "Field 1" "Text" "An older version of Tomahawk is installed on your system. It is recommended that you uninstall the current version before installing. Select the operation you want to perform and click Next to continue."
!insertmacro INSTALLOPTIONS_WRITE "NSIS.InstallOptions.ini" "Field 2" "Text" "Uninstall before installing"
!insertmacro INSTALLOPTIONS_WRITE "NSIS.InstallOptions.ini" "Field 3" "Text" "Do not uninstall"
!insertmacro MUI_HEADER_TEXT "Already Installed" "Choose how you want to install Tomahawk."
StrCpy $R0 "1"
Goto reinst_start
older_version:
!insertmacro INSTALLOPTIONS_WRITE "NSIS.InstallOptions.ini" "Field 1" "Text" "A newer version of Tomahawk is already installed! It is not recommended that you install an older version. If you really want to install this older version, it is better to uninstall the current version first. Select the operation you want to perform and click Next to continue."
!insertmacro INSTALLOPTIONS_WRITE "NSIS.InstallOptions.ini" "Field 2" "Text" "Uninstall before installing"
!insertmacro INSTALLOPTIONS_WRITE "NSIS.InstallOptions.ini" "Field 3" "Text" "Do not uninstall"
!insertmacro MUI_HEADER_TEXT "Already Installed" "Choose how you want to install Tomahawk."
StrCpy $R0 "1"
Goto reinst_start
same_version:
!insertmacro INSTALLOPTIONS_WRITE "NSIS.InstallOptions.ini" "Field 1" "Text" "Tomahawk ${VERSION} is already installed.\r\nSelect the operation you want to perform and click Next to continue."
!insertmacro INSTALLOPTIONS_WRITE "NSIS.InstallOptions.ini" "Field 2" "Text" "Add/Reinstall components"
!insertmacro INSTALLOPTIONS_WRITE "NSIS.InstallOptions.ini" "Field 3" "Text" "Uninstall Tomahawk"
!insertmacro MUI_HEADER_TEXT "Already Installed" "Choose the maintenance option to perform."
StrCpy $R0 "2"
reinst_start:
!insertmacro INSTALLOPTIONS_DISPLAY "NSIS.InstallOptions.ini"
FunctionEnd
Function PageLeaveReinstall
!insertmacro INSTALLOPTIONS_READ $R1 "NSIS.InstallOptions.ini" "Field 2" "State"
StrCmp $R0 "1" 0 +2
StrCmp $R1 "1" reinst_uninstall reinst_done
StrCmp $R0 "2" 0 +3
StrCmp $R1 "1" reinst_done reinst_uninstall
reinst_uninstall:
ReadRegStr $R1 HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\Tomahawk" "UninstallString"
HideWindow
ClearErrors
ExecWait '$R1 _?=$INSTDIR'
IfErrors no_remove_uninstaller
IfFileExists "$INSTDIR\tomahawk.exe" no_remove_uninstaller
Delete $R1
RMDir $INSTDIR
no_remove_uninstaller:
StrCmp $R0 "2" 0 +3
UAC::Unload
Quit
BringToFront
reinst_done:
FunctionEnd
##############################################################################
# #
# INSTALLER SECTIONS #
# #
##############################################################################
Section "Tomahawk Player" SEC_TOMAHAWK_PLAYER
SectionIn 1 2 3 RO
SetDetailsPrint listonly
SetDetailsPrint textonly
DetailPrint "Installing Tomahawk Player essentials."
SetDetailsPrint listonly
SetOutPath "$INSTDIR"
!ifdef INSTALL_PATH
;Main executable.
File "${INSTALL_PATH}\bin\tomahawk.exe"
File "${INSTALL_PATH}\bin\libqxtweb-standalone.dll"
File "${INSTALL_PATH}\bin\libtomahawk_portfwd.dll"
File "${INSTALL_PATH}\bin\libtomahawk_lastfm2.dll"
File "${INSTALL_PATH}\bin\libtomahawklib.dll"
File "${INSTALL_PATH}\lib\libtomahawk_sip*.dll"
!endif
!ifndef INSTALL_PATH
;Main executable.
File "${BUILD_PATH}\tomahawk.exe"
File "${BUILD_PATH}\libtomahawklib.dll"
File "${BUILD_PATH}\libqxtweb-standalone.dll"
File "${BUILD_PATH}\libtomahawk_portfwd.dll"
File "${BUILD_PATH}\libtomahawk_lastfm2.dll"
File "${BUILD_PATH}\libtomahawk_sip*.dll"
!endif
;License & release notes.
File "@CPACK_RESOURCE_FILE_LICENSE@"
File /oname=NOTES.txt ${NSI_PATH}\RELEASE_NOTES.txt
;QT stuff:
File "${QT_DLL_PATH}\QtCore4.dll"
File "${QT_DLL_PATH}\QtGui4.dll"
File "${QT_DLL_PATH}\QtNetwork4.dll"
File "${QT_DLL_PATH}\QtSql4.dll"
File "${QT_DLL_PATH}\QtXml4.dll"
File "${QT_DLL_PATH}\QtWebKit4.dll"
;SQLite driver
SetOutPath "$INSTDIR\sqldrivers"
File "${SQLITE_DLL_PATH}\qsqlite4.dll"
SetOutPath "$INSTDIR"
;Image plugins
SetOutPath "$INSTDIR\imageformats"
File "${IMAGEFORMATS_DLL_PATH}\qgif4.dll"
File "${IMAGEFORMATS_DLL_PATH}\qjpeg4.dll"
SetOutPath "$INSTDIR"
;Cygwin/c++ stuff
;File "${MING_BIN}\cygmad-0.dll"
;File "${MING_BIN}\libgcc_s_dw2-1.dll"
;File "${MING_BIN}\mingwm10.dll"
File "${MING_BIN}\libgcc_s_sjlj-1.dll"
File "${MING_BIN}\libstdc++-6.dll"
;Phonon stuff
;Fix the phonon build to not use Dbus
File "${QT_DLL_PATH}\QtDbus4.dll"
File "${MING_BIN}\libdbus-1-3.dll"
File "${MING_BIN}\dbus-daemon.exe"
File "${MING_BIN}\libphonon.dll"
SetOutPath "$INSTDIR\phonon_backend"
File "${MING_BIN}\phonon_backend\phonon_vlc.dll"
SetOutPath "$INSTDIR"
;VLC
;SetOutPath "$INSTDIR\phonon_backend"
File "${MING_BIN}\libvlc.dll"
File "${MING_BIN}\libvlccore.dll"
SetOutPath "$INSTDIR\plugins"
File /r "${VLC_PLUGIN_PATH}\*.dll"
SetOutPath "$INSTDIR"
File "${MING_BIN}\libmad-0.dll" ; MP3
File "${MING_BIN}\libFLAC-8.dll" ; FLAC
File "${MING_BIN}\libogg-0.dll" ; OGG, FLAC
File "${MING_BIN}\libvorbis-0.dll" ; OGG
File "${MING_BIN}\libvorbisenc-2.dll" ; OGG
; Other
File "${MING_BIN}\libqjson.dll"
File "${MING_BIN}\libtag.dll"
File "${MING_BIN}\libpng15-15.dll"
File "${MING_BIN}\libjpeg-8.dll"
File "${MING_BIN}\zlib1.dll"
File "${MING_BIN}\libechonest.dll"
File "${MING_BIN}\libQTweetLib.dll"
; Jabber
File "${MING_BIN}\libjreen.dll"
File "${MING_BIN}\libqca.dll"
SetOutPath "$INSTDIR\crypto"
File "${MING_LIB}\qt4\plugins\crypto\libqca-ossl.dll"
SetOutPath "$INSTDIR"
File "${MING_BIN}\libssl-8.dll"
File "${MING_BIN}\libcrypto-8.dll"
File "${MING_LIB}\libclucene-core.dll"
File "${MING_LIB}\libclucene-shared.dll"
File "${MING_BIN}\libqtsparkle.dll"
SectionEnd
SectionGroup "Shortcuts"
!ifdef OPTION_SECTION_SC_START_MENU
${MementoSection} "Start Menu Program Group" SEC_START_MENU
SectionIn 1 2
SetDetailsPrint textonly
DetailPrint "Adding shortcuts for the Tomahawk program group to the Start Menu."
SetDetailsPrint listonly
SetShellVarContext all
RMDir /r "$SMPROGRAMS\Tomahawk"
CreateDirectory "$SMPROGRAMS\Tomahawk"
CreateShortCut "$SMPROGRAMS\Tomahawk\LICENSE.lnk" "$INSTDIR\LICENSE.txt"
CreateShortCut "$SMPROGRAMS\Tomahawk\Tomahawk.lnk" "$INSTDIR\tomahawk.exe"
CreateShortCut "$SMPROGRAMS\Tomahawk\Release notes.lnk" "$INSTDIR\NOTES.txt"
CreateShortCut "$SMPROGRAMS\Tomahawk\Uninstall.lnk" "$INSTDIR\uninstall.exe"
SetShellVarContext current
${MementoSectionEnd}
!endif
!ifdef OPTION_SECTION_SC_DESKTOP
${MementoSection} "Desktop Shortcut" SEC_DESKTOP
SectionIn 1 2
SetDetailsPrint textonly
DetailPrint "Creating Desktop Shortcuts"
SetDetailsPrint listonly
CreateShortCut "$DESKTOP\Tomahawk.lnk" "$INSTDIR\tomahawk.exe"
${MementoSectionEnd}
!endif
!ifdef OPTION_SECTION_SC_QUICK_LAUNCH
${MementoSection} "Quick Launch Shortcut" SEC_QUICK_LAUNCH
SectionIn 1 2
SetDetailsPrint textonly
DetailPrint "Creating Quick Launch Shortcut"
SetDetailsPrint listonly
CreateShortCut "$QUICKLAUNCH\Tomahawk.lnk" "$INSTDIR\tomahawk.exe"
${MementoSectionEnd}
!endif
SectionGroupEnd
${MementoSectionDone}
; Installer section descriptions
;--------------------------------
!insertmacro MUI_FUNCTION_DESCRIPTION_BEGIN
!insertmacro MUI_DESCRIPTION_TEXT ${SEC_TOMAHAWK_PLAYER} "Tomahawk player essentials."
!insertmacro MUI_DESCRIPTION_TEXT ${SEC_START_MENU} "Tomahawk program group."
!insertmacro MUI_DESCRIPTION_TEXT ${SEC_DESKTOP} "Desktop shortcut for Tomahawk."
!insertmacro MUI_DESCRIPTION_TEXT ${SEC_QUICK_LAUNCH} "Quick Launch shortcut for Tomahawk."
!insertmacro MUI_FUNCTION_DESCRIPTION_END
Section -post
;Uninstaller file.
SetDetailsPrint textonly
DetailPrint "Writing Uninstaller"
SetDetailsPrint listonly
WriteUninstaller $INSTDIR\uninstall.exe
;Registry keys required for installer version handling and uninstaller.
SetDetailsPrint textonly
DetailPrint "Writing Installer Registry Keys"
SetDetailsPrint listonly
;Version numbers used to detect existing installation version for comparisson.
WriteRegStr HKLM "Software\Tomahawk" "" $INSTDIR
WriteRegDWORD HKLM "Software\Tomahawk" "VersionMajor" "${VER_MAJOR}"
WriteRegDWORD HKLM "Software\Tomahawk" "VersionMinor" "${VER_MINOR}"
WriteRegDWORD HKLM "Software\Tomahawk" "VersionRevision" "${REVISION}"
WriteRegDWORD HKLM "Software\Tomahawk" "VersionBuild" "${VER_BUILD}"
;Add or Remove Programs entry.
WriteRegExpandStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\Tomahawk" "UninstallString" '"$INSTDIR\Uninstall.exe"'
WriteRegExpandStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\Tomahawk" "InstallLocation" "$INSTDIR"
WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\Tomahawk" "DisplayName" "Tomahawk"
WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\Tomahawk" "Publisher" "Tomahawk-player.org"
WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\Tomahawk" "DisplayIcon" "$INSTDIR\Uninstall.exe,0"
WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\Tomahawk" "DisplayVersion" "${VERSION}"
WriteRegDWORD HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\Tomahawk" "VersionMajor" "${VER_MAJOR}"
WriteRegDWORD HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\Tomahawk" "VersionMinor" "${VER_MINOR}.${REVISION}"
WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\Tomahawk" "URLInfoAbout" "http://tomahawk-player.org/"
WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\Tomahawk" "HelpLink" "http://tomahawk-player.org/"
WriteRegDWORD HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\Tomahawk" "NoModify" "1"
WriteRegDWORD HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\Tomahawk" "NoRepair" "1"
; Register tomahawk:// protocol handler
WriteRegStr HKCR "tomahawk" "" "URL: Tomahawk Protocol"
WriteRegStr HKCR "tomahawk\DefaultIcon" "" $INSTDIR\tomahawk.exe,1
WriteRegStr HKCR "tomahawk\shell" "" "open"
WriteRegStr HKCR "tomahawk\shell\open\command" "" '"$INSTDIR\tomahawk.exe" "%1"'
SetDetailsPrint textonly
DetailPrint "Finsihed."
SectionEnd
##############################################################################
# #
# UNINSTALLER SECTION #
# #
##############################################################################
Var UnPageUserAppDataDialog
Var UnPageUserAppDataCheckbox
Var UnPageUserAppDataCheckbox_State
Var UnPageUserAppDataEditBox
Function un.UnPageUserAppData
!insertmacro MUI_HEADER_TEXT "Uninstall Tomahawk" "Remove Tomahawk's data folder from your computer."
nsDialogs::Create /NOUNLOAD 1018
Pop $UnPageUserAppDataDialog
${If} $UnPageUserAppDataDialog == error
Abort
${EndIf}
${NSD_CreateLabel} 0 0 100% 12u "Do you want to delete Tomahawk's data folder?"
Pop $0
${NSD_CreateText} 0 13u 100% 12u "$LOCALAPPDATA\Tomahawk"
Pop $UnPageUserAppDataEditBox
SendMessage $UnPageUserAppDataEditBox ${EM_SETREADONLY} 1 0
${NSD_CreateLabel} 0 46u 100% 24u "Leave unchecked to keep the data folder for later use or check to delete the data folder."
Pop $0
${NSD_CreateCheckbox} 0 71u 100% 8u "Yes, delete this data folder."
Pop $UnPageUserAppDataCheckbox
nsDialogs::Show
FunctionEnd
Function un.UnPageUserAppDataLeave
${NSD_GetState} $UnPageUserAppDataCheckbox $UnPageUserAppDataCheckbox_State
FunctionEnd
Section Uninstall
IfFileExists "$INSTDIR\tomahawk.exe" tomahawk_installed
MessageBox MB_YESNO "It does not appear that Tomahawk is installed in the directory '$INSTDIR'.$\r$\nContinue anyway (not recommended)?" IDYES tomahawk_installed
Abort "Uninstall aborted by user"
tomahawk_installed:
;Delete registry keys.
DeleteRegKey HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\Tomahawk"
DeleteRegValue HKLM "Software\Tomahawk" "VersionBuild"
DeleteRegValue HKLM "Software\Tomahawk" "VersionMajor"
DeleteRegValue HKLM "Software\Tomahawk" "VersionMinor"
DeleteRegValue HKLM "Software\Tomahawk" "VersionRevision"
DeleteRegValue HKLM "Software\Tomahawk" ""
DeleteRegKey HKLM "Software\Tomahawk"
DeleteRegKey HKCR "tomahawk"
;Start menu shortcuts.
!ifdef OPTION_SECTION_SC_START_MENU
SetShellVarContext all
RMDir /r "$SMPROGRAMS\Tomahawk"
SetShellVarContext current
!endif
;Desktop shortcut.
!ifdef OPTION_SECTION_SC_DESKTOP
IfFileExists "$DESKTOP\Tomahawk.lnk" 0 +2
Delete "$DESKTOP\Tomahawk.lnk"
!endif
;Quick Launch shortcut.
!ifdef OPTION_SECTION_SC_QUICK_LAUNCH
IfFileExists "$QUICKLAUNCH\Tomahawk.lnk" 0 +2
Delete "$QUICKLAUNCH\Tomahawk.lnk"
!endif
;Remove all the Program Files.
RMDir /r $INSTDIR
;Uninstall User Data if option is checked, otherwise skip.
${If} $UnPageUserAppDataCheckbox_State == ${BST_CHECKED}
RMDir /r "$LOCALAPPDATA\Tomahawk"
${EndIf}
SetDetailsPrint textonly
DetailPrint "Finsihed."
SectionEnd
##############################################################################
# #
# NSIS Installer Event Handler Functions #
# #
##############################################################################
Function .onInit
!insertmacro INSTALLOPTIONS_EXTRACT "NSIS.InstallOptions.ini"
;Remove Quick Launch option from Windows 7, as no longer applicable - usually.
${IfNot} ${AtMostWinVista}
SectionSetText ${SEC_QUICK_LAUNCH} "Quick Launch Shortcut (N/A)"
SectionSetFlags ${SEC_QUICK_LAUNCH} ${SF_RO}
SectionSetInstTypes ${SEC_QUICK_LAUNCH} 0
${EndIf}
${MementoSectionRestore}
UAC_Elevate:
UAC::RunElevated
StrCmp 1223 $0 UAC_ElevationAborted ; UAC dialog aborted by user?
StrCmp 0 $0 0 UAC_Err ; Error?
StrCmp 1 $1 0 UAC_Success ;Are we the real deal or just the wrapper?
Quit
UAC_Err:
MessageBox MB_ICONSTOP "Unable to elevate, error $0"
Abort
UAC_ElevationAborted:
Abort
UAC_Success:
StrCmp 1 $3 +4 ;Admin?
StrCmp 3 $1 0 UAC_ElevationAborted ;Try again?
MessageBox MB_ICONSTOP "This installer requires admin access, try again"
goto UAC_Elevate
;Prevent multiple instances.
System::Call 'kernel32::CreateMutexA(i 0, i 0, t "tomahawkInstaller") i .r1 ?e'
Pop $R0
StrCmp $R0 0 +3
MessageBox MB_OK|MB_ICONEXCLAMATION "The installer is already running."
Abort
;Use available InstallLocation when possible. This is useful in the uninstaller
;via re-install, which would otherwise use a default location - a bug.
ReadRegStr $R0 HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\Tomahawk" "InstallLocation"
StrCmp $R0 "" SkipSetInstDir
StrCpy $INSTDIR $R0
SkipSetInstDir:
;Shutdown Tomahawk in case Add/Remove re-installer option used.
Call EnsureTomahawkShutdown
FunctionEnd
Function .onInstSuccess
${MementoSectionSave}
UAC::Unload ;Must call unload!
FunctionEnd
Function .onInstFailed
UAC::Unload ;Must call unload!
FunctionEnd
##############################################################################
# #
# NSIS Uninstaller Event Handler Functions #
# #
##############################################################################
Function un.onInit
UAC_Elevate:
UAC::RunElevated
StrCmp 1223 $0 UAC_ElevationAborted ; UAC dialog aborted by user?
StrCmp 0 $0 0 UAC_Err ; Error?
StrCmp 1 $1 0 UAC_Success ;Are we the real deal or just the wrapper?
Quit
UAC_Err:
MessageBox MB_ICONSTOP "Unable to elevate, error $0"
Abort
UAC_ElevationAborted:
Abort
UAC_Success:
StrCmp 1 $3 +4 ;Admin?
StrCmp 3 $1 0 UAC_ElevationAborted ;Try again?
MessageBox MB_ICONSTOP "This uninstaller requires admin access, try again"
goto UAC_Elevate
;Prevent multiple instances.
System::Call 'kernel32::CreateMutexA(i 0, i 0, t "tomahawkUninstaller") i .r1 ?e'
Pop $R0
StrCmp $R0 0 +3
MessageBox MB_OK|MB_ICONEXCLAMATION "This uninstaller is already running."
Abort
FunctionEnd
Function un.onUnInstSuccess
UAC::Unload ;Must call unload!
FunctionEnd
Function un.onUnInstFailed
UAC::Unload ;Must call unload!
FunctionEnd

View File

@@ -1,21 +0,0 @@
# Do not edit! Generated by kwsysDateStamp.py
#=============================================================================
# KWSys - Kitware System Library
# Copyright 2000-2009 Kitware, Inc., Insight Software Consortium
#
# Distributed under the OSI-approved BSD License (the "License");
# see accompanying file Copyright.txt for details.
#
# This software is distributed WITHOUT ANY WARRANTY; without even the
# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
# See the License for more information.
#=============================================================================
# KWSys version date year component. Format is CCYY.
SET(KWSYS_DATE_STAMP_YEAR 2011)
# KWSys version date month component. Format is MM.
SET(KWSYS_DATE_STAMP_MONTH 07)
# KWSys version date day component. Format is DD.
SET(KWSYS_DATE_STAMP_DAY 06)

View File

@@ -1,53 +0,0 @@
INCLUDE( InstallRequiredSystemLibraries )
SET( CPACK_PACKAGE_CONTACT "Dominik Schmidt <domme@tomahawk-player.org>" )
SET( CPACK_PACKAGE_FILE_NAME tomahawk-${TOMAHAWK_VERSION} ) # Package file name without extension. Also a directory of installer cmake-2.5.0-Linux-i686
# CPACK_GENERATOR CPack generator to be used STGZ;TGZ;TZ
# CPACK_INCLUDE_TOPLEVEL_DIRECTORY Controls whether CPack adds a top-level directory, usually of the form ProjectName-Version-OS, to the top of package tree. 0 to disable, 1 to enable
# CPACK_INSTALL_CMAKE_PROJECTS List of four values: Build directory, Project Name, Project Component, Directory in the package /home/andy/vtk/CMake-bin;CMake;ALL;/
SET( CPACK_PACKAGE_DESCRIPTION_FILE "${CMAKE_SOURCE_DIR}/README" ) # File used as a description of a project /path/to/project/ReadMe.txt
SET( CPACK_PACKAGE_DESCRIPTION_SUMMARY ${TOMAHAWK_DESCRIPTION_SUMMARY} ) # Description summary of a project
# CPACK_PACKAGE_EXECUTABLES List of pairs of executables and labels. Used by the NSIS generator to create Start Menu shortcuts. ccmake;CMake
SET( CPACK_PACKAGE_INSTALL_DIRECTORY ${TOMAHAWK_APPLICATION_NAME} ) # Installation directory on the target system -> C:\Program Files\fellody
SET( CPACK_PACKAGE_INSTALL_REGISTRY_KEY ${TOMAHAWK_APPLICATION_NAME} ) # Registry key used when installing this project CMake 2.5.0
SET( CPACK_PACKAGE_NAME ${TOMAHAWK_APPLICATION_NAME} ) # Package name, defaults to the project name
SET( CPACK_PACKAGE_VENDOR ${TOMAHAWK_ORGANIZATION_NAME} ) # Package vendor name
SET( CPACK_PACKAGE_VERSION_MAJOR ${TOMAHAWK_VERSION_MAJOR} )
SET( CPACK_PACKAGE_VERSION_MINOR ${TOMAHAWK_VERSION_MINOR} )
SET( CPACK_PACKAGE_VERSION_PATCH ${TOMAHAWK_VERSION_PATCH} )
# CPACK_SOURCE_GENERATOR List of generators used for the source package TGZ;TZ
SET( CPACK_SOURCE_GENERATOR TGZ )
SET( CPACK_SOURCE_IGNORE_FILES "/\\\\.git/" ".*~$" ".kate-swp$" "/build_dir/" "/clang/" "/gcc/" "/build/" "/win/" ) # Pattern of files in the source tree that won't be packaged
SET( CPACK_SOURCE_PACKAGE_FILE_NAME tomahawk-${TOMAHAWK_VERSION} ) # Name of the source package
# CPACK_SOURCE_STRIP_FILES List of files in the source tree that will be stripped. Starting with CMake 2.6.0 CPACK_SOURCE_STRIP_FILES will be a boolean variable which enables stripping of all files (a list of files evaluates to TRUE in CMake, so this change is compatible).
# CPACK_STRIP_FILES List of files to be stripped. Starting with CMake 2.6.0 CPACK_STRIP_FILES will be a boolean variable which enables stripping of all files (a list of files evaluates to TRUE in CMake, so this change is compatible). bin/ccmake;bin/cmake;bin/cpack;bin/ctest
# CPACK_SYSTEM_NAME System name, defaults to the value of ${CMAKE_SYSTEM_NAME}. Linux-i686
# Advanced settings
# CPACK_CMAKE_GENERATOR What CMake generator should be used if the project is CMake project. Defaults to the value of CMAKE_GENERATOR. Unix Makefiles
SET( CPACK_RESOURCE_FILE_LICENSE "${CMAKE_SOURCE_DIR}/LICENSE.txt" ) # License file for the project, used by the STGZ, NSIS, and PackageMaker generators. /home/andy/vtk/CMake/Copyright.txt
# CPACK_RESOURCE_FILE_README ReadMe file for the project, used by PackageMaker generator. /home/andy/vtk/CMake/Templates/CPack.GenericDescription.txt
# CPACK_RESOURCE_FILE_WELCOME Welcome file for the project, used by PackageMaker generator. /home/andy/vtk/CMake/Templates/CPack.GenericWelcome.txt
SET( CPACK_PACKAGE_VERSION ${TOMAHAWK_VERSION} )
SET( CPACK_TOPLEVEL_TAG "narf" ) # Directory for the installed files. - needed to provide anything to avoid an error# CPACK_INSTALL_COMMANDS Extra commands to install components.
# CPACK_INSTALL_DIRECTORIES Extra directories to install.
# CPACK_MONOLITHIC_INSTALL When set disables the component-based installer.
# CPACK_PACKAGING_INSTALL_PREFIX Sets the default root that the generated package installs into, '/usr' is the default for the debian and redhat generators /usr/local
##
# INSTALL DEPS
##
# Set the options file that needs to be included inside CMakeCPackOptions.cmake
#SET(QT_DIALOG_CPACK_OPTIONS_FILE ${CMake_BINARY_DIR}/Source/QtDialog/QtDialogCPack.cmake)
configure_file("${CMAKE_SOURCE_DIR}/CPackOptions.cmake.in"
"${CMAKE_BINARY_DIR}/CPackOptions.cmake" @ONLY)
set(CPACK_PROJECT_CONFIG_FILE "${CMAKE_BINARY_DIR}/CPackOptions.cmake") # File included at cpack time, once per generator after setting CPACK_GENERATOR to the actual generator being used; allows per-generator setting of CPACK_* variables at cpack time. ${PROJECT_BINARY_DIR}/CPackOptions.cmake
include(CPack)

View File

@@ -1,73 +0,0 @@
# This file is configured at cmake time, and loaded at cpack time.
# To pass variables to cpack from cmake, they must be configured
# in this file.
if(CPACK_GENERATOR MATCHES "NSIS")
#SET(CPACK_NSIS_INSTALL_ROOT "@CPACK_NSIS_INSTALL_ROOT@")
# set the install/unistall icon used for the installer itself
# There is a bug in NSI that does not handle full unix paths properly.
#SET(CPACK_NSIS_MUI_ICON "@CMake_SOURCE_DIR@/Utilities/Release\\CMakeLogo.ico")
#SET(CPACK_NSIS_MUI_UNIICON "@CMake_SOURCE_DIR@/Utilities/Release\\CMakeLogo.ico")
# set the package header icon for MUI
#SET(CPACK_PACKAGE_ICON "@CMake_SOURCE_DIR@/Utilities/Release\\CMakeInstall.bmp")
# tell cpack to create links to the doc files
#SET(CPACK_NSIS_MENU_LINKS
# "doc/cmake-@CMake_VERSION_MAJOR@.@CMake_VERSION_MINOR@/cmake-gui.html" "cmake-gui Help"
# "doc/cmake-@CMake_VERSION_MAJOR@.@CMake_VERSION_MINOR@/cmake.html" "CMake Help"
# "doc/cmake-@CMake_VERSION_MAJOR@.@CMake_VERSION_MINOR@/cmake-properties.html"
# "CMake Properties and Variables Help"
# "doc/cmake-@CMake_VERSION_MAJOR@.@CMake_VERSION_MINOR@/ctest.html" "CTest Help"
# "doc/cmake-@CMake_VERSION_MAJOR@.@CMake_VERSION_MINOR@/cmake-modules.html" "CMake Modules Help"
# "doc/cmake-@CMake_VERSION_MAJOR@.@CMake_VERSION_MINOR@/cmake-commands.html" "CMake Commands Help"
# "doc/cmake-@CMake_VERSION_MAJOR@.@CMake_VERSION_MINOR@/cpack.html" "CPack Help"
# "http://www.cmake.org" "CMake Web Site"
# )
# Use the icon from cmake-gui for add-remove programs
#SET(CPACK_NSIS_INSTALLED_ICON_NAME "bin\\cmake-gui.exe")
#
#SET(CPACK_NSIS_PACKAGE_NAME "@CPACK_NSIS_PACKAGE_NAME@")
#SET(CPACK_NSIS_DISPLAY_NAME "@CPACK_NSIS_PACKAGE_NAME@, a cross-platform, open-source build system")
#SET(CPACK_NSIS_HELP_LINK "http://www.cmake.org")
#SET(CPACK_NSIS_URL_INFO_ABOUT "http://www.kitware.com")
#SET(CPACK_NSIS_CONTACT @CPACK_PACKAGE_CONTACT@)
#SET(CPACK_NSIS_MODIFY_PATH ON)
##### all options
#CPACK_NSIS_MUI_ICON The icon file (.ico) for the generated install program. Both this and CPACK_NSIS_MUI_UNIICON need to set for this to have any effect. installer.ico
#CPACK_NSIS_MUI_UNIICON The icon file (.ico) for the generated uninstall program. Both this and CPACK_NSIS_MUI_ICON need to set for this to have any effect. uninstaller.ico
SET( CPACK_PACKAGE_ICON @CMAKE_SOURCE_DIR@/admin/win/nsi/installer.ico ) # A branding image that will be displayed on the top bar inside the installer. installer.bmp
#CPACK_NSIS_EXTRA_INSTALL_COMMANDS Extra NSIS commands that will be added to the install Section. ExecWait '\\\"$INSTDIR\\\\vcredist_x86.exe\\\" /q:a'
#CPACK_NSIS_EXTRA_UNINSTALL_COMMANDS Extra NSIS commands that will be added to the uninstall Section.
SET( CPACK_NSIS_COMPRESSOR "/SOLID lzma" ) # The arguments that will be passed to the NSIS SetCompressor command. /SOLID lzma
#CPACK_NSIS_MODIFY_PATH If this is set to "ON", then an extra page will appear in the installer that will allow the user to choose whether the program directory should be added to the system PATH variable. ON
#CPACK_NSIS_DISPLAY_NAME Undocumented. "${CPACK_PACKAGE_INSTALL_DIRECTORY} My Famous Project"
#CPACK_NSIS_INSTALLED_ICON_NAME Set the icon used for the Windows "Add or Remove Programs" tool. "bin\\\\MyExecutable.exe"
#CPACK_NSIS_HELP_LINK Adds link to registry. URI. "http:\\\\\\\\www.my-project-home-page.org"
#CPACK_NSIS_URL_INFO_ABOUT Adds link to registry and the vendor in add/remove programs' "Click here for support information" in program entry links here. "http:\\\\\\\\www.my-personal-home-page.com"
#CPACK_NSIS_CONTACT Adds link to add/remove programs' "Click here for support information" in program entry. "me@my-personal-home-page.com"
#CPACK_NSIS_CREATE_ICONS_EXTRA Additional NSIS commands for creating start menu shortcuts. set(CPACK_NSIS_CREATE_ICONS "CreateShortCut '\$SMPROGRAMS\\\\$STARTMENU_FOLDER\\\\${PROJECT_NAME}.lnk' '\$INSTDIR\\\\${PROJECT_NAME}.exe'")
#CPACK_NSIS_DELETE_ICONS_EXTRA Undocumented. Possibly: Additional NSIS commands to uninstall start menu shortcuts.
#CPACK_NSIS_MENU_LINKS Used to override the Start Menu links. "doc/cmake-@CMake_VERSION_MAJOR@.@CMake_VERSION_MINOR@/CMakeSetup.html" "CMakeSetup Help"
#CPACK_NSIS_MUI_FINISHPAGE_RUN If used, will make it possible for user to choose (on an additional page, displayed at the end of the installation) to run intalled program. Should point to program name to run, seemingly without any sub-directories of the installation directory in case program installed in such sub-directories (but please check generated NSIS script if you can't make it work). "MyExecutable.exe"
endif(CPACK_GENERATOR MATCHES "NSIS")
## include the cpack options for qt dialog if they exisit
## they might not if qt was not enabled for the build
#INCLUDE("@QT_DIALOG_CPACK_OPTIONS_FILE@" OPTIONAL)
#if("${CPACK_GENERATOR}" STREQUAL "PackageMaker")
# if(CMAKE_PACKAGE_QTGUI)
# set(CPACK_PACKAGE_DEFAULT_LOCATION "/Applications")
# else(CMAKE_PACKAGE_QTGUI)
# set(CPACK_PACKAGE_DEFAULT_LOCATION "/usr")
# endif(CMAKE_PACKAGE_QTGUI)
#endif("${CPACK_GENERATOR}" STREQUAL "PackageMaker")
SET( CMAKE_SOURCE_DIR @CMAKE_SOURCE_DIR@ )
SET( CMAKE_BINARY_DIR @CMAKE_BINARY_DIR@ )

4
README
View File

@@ -19,10 +19,6 @@ Detailed building instructions for OS X
---------------------------------------
See: http://wiki.tomahawk-player.org/mediawiki/index.php/Building_OS_X_Application_Bundle_on_Snow_Leopard_(10.6)
Doxygen Documentation
---------------------
See: http://dev.tomahawk-player.org/api/classes.html
Dependencies
------------

View File

@@ -54,8 +54,8 @@ cp -R $QT_PLUGINS_DIR/imageformats/libqgif.dylib Contents/MacOS/imageformats/
cp -R $QT_PLUGINS_DIR/imageformats/libqjpeg.dylib Contents/MacOS/imageformats/
cp -R $QT_PLUGINS_DIR/imageformats/libqico.dylib Contents/MacOS/imageformats/
cp -R $QT_PLUGINS_DIR/imageformats/libqmng.dylib Contents/MacOS/imageformats/
#cp -R $QT_PLUGINS_DIR/imageformats/libqsvg.dylib Contents/MacOS/imageformats/
#cp -R $QT_PLUGINS_DIR/imageformats/libqtiff.dylib Contents/MacOS/imageformats/
cp -R $QT_PLUGINS_DIR/imageformats/libqsvg.dylib Contents/MacOS/imageformats/
cp -R $QT_PLUGINS_DIR/imageformats/libqtiff.dylib Contents/MacOS/imageformats/
cp -R $QT_PLUGINS_DIR/crypto/libqca-ossl.dylib Contents/MacOS/crypto/
cp -R $QT_PLUGINS_DIR/phonon_backend/phonon_vlc.so Contents/MacOS/phonon_backend/

View File

@@ -50,11 +50,7 @@ function deposx_change
install_name_tool -change /usr/local/Cellar/qt/$QTVERSION/lib/$y.framework/Versions/4/$y \
@executable_path/../Frameworks/$y.framework/Versions/4/$y \
"$1"
install_name_tool -change /usr/X11/lib/libpng12.0.dylib \
@executable_path/libpng12.0.dylib \
"$1"
"$1"
done
for y in $LIBS
@@ -130,7 +126,6 @@ import_lib /usr/local/Cellar/kde-phonon/4.5.0/lib/libphonon.4.dylib
import_lib /usr/local/Cellar/vlc-git/HEAD/lib/libvlc.5.dylib
import_lib /usr/local/Cellar/vlc-git/HEAD/lib/libvlccore.4.dylib
import_lib /usr/local/Cellar/gettext/0.18.1.1/lib/libintl.8.dylib
import_lib /usr/X11/lib/libpng12.0.dylib
import_lib $ORIGROOT/libjreen.dylib
import_lib $ORIGROOT/libtomahawklib.dylib

View File

@@ -2,8 +2,8 @@
SET(CMAKE_SYSTEM_NAME Windows)
# specify the cross compiler
SET(CMAKE_C_COMPILER ccache i686-w64-mingw32-gcc)
SET(CMAKE_CXX_COMPILER ccache i686-w64-mingw32-g++)
SET(CMAKE_C_COMPILER i686-w64-mingw32-gcc)
SET(CMAKE_CXX_COMPILER i686-w64-mingw32-g++)
# where is the target environment containing libraries
SET(CMAKE_FIND_ROOT_PATH /usr/i686-w64-mingw32/sys-root/mingw)

View File

@@ -1 +1 @@
127
105

View File

@@ -25,7 +25,8 @@
!define QT_DLL_PATH "${MING_BIN}"
!define SQLITE_DLL_PATH "${MING_LIB}/qt4/plugins/sqldrivers"
!define IMAGEFORMATS_DLL_PATH "${MING_LIB}/qt4/plugins/imageformats"
!define VLC_PLUGIN_PATH "${MING_LIB}\vlc\plugins"
!define VLC_PATH "${ROOT_PATH}\..\vlc"
!define VLC_PLUGIN_PATH "${VLC_PATH}\plugins"
;-----------------------------------------------------------------------------
; Increment installer revision number as part of this script.
@@ -37,8 +38,8 @@
!ifndef VER_MAJOR && VER_MINOR && VER_BUILD
!define VER_MAJOR "0"
!define VER_MINOR "2"
!define VER_BUILD "0prealpha"
!define VER_MINOR "1"
!define VER_BUILD "0rc2"
!endif
!define VERSION "${VER_MAJOR}.${VER_MINOR}.${VER_BUILD}"
@@ -54,7 +55,7 @@
Name "Tomahawk"
Caption "Tomahawk Installer"
BrandingText "Tomahawk ${VERSION} -- ${BUILD_TIME}"
OutFile "${ROOT_PATH}\build\tomahawk-${VERSION}.exe"
OutFile "tomahawk-${VERSION}.exe"
InstallDir "$PROGRAMFILES\Tomahawk"
InstallDirRegKey HKCU "Software\Tomahawk" ""
InstType Standard
@@ -292,10 +293,9 @@ Section "Tomahawk Player" SEC_TOMAHAWK_PLAYER
File "${BUILD_PATH}\libtomahawk_sip*.dll"
!endif
;License & release notes & icon (for Growl).
;License & release notes.
File "${ROOT_PATH}\LICENSE.txt"
File /oname=NOTES.txt RELEASE_NOTES.txt
File "${ROOT_PATH}\data\icons\tomahawk-icon-128x128.png"
;QT stuff:
File "${QT_DLL_PATH}\QtCore4.dll"
@@ -337,8 +337,8 @@ Section "Tomahawk Player" SEC_TOMAHAWK_PLAYER
;VLC
;SetOutPath "$INSTDIR\phonon_backend"
File "${MING_BIN}\libvlc.dll"
File "${MING_BIN}\libvlccore.dll"
File "${VLC_PATH}\libvlc.dll"
File "${VLC_PATH}\libvlccore.dll"
SetOutPath "$INSTDIR\plugins"
File /r "${VLC_PLUGIN_PATH}\*.dll"
SetOutPath "$INSTDIR"

Binary file not shown.

Before

Width:  |  Height:  |  Size: 7.3 KiB

After

Width:  |  Height:  |  Size: 4.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.0 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.9 MiB

After

Width:  |  Height:  |  Size: 1.7 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 7.3 KiB

After

Width:  |  Height:  |  Size: 4.1 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.9 KiB

After

Width:  |  Height:  |  Size: 691 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.0 KiB

After

Width:  |  Height:  |  Size: 666 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.9 KiB

After

Width:  |  Height:  |  Size: 650 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 8.3 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 260 KiB

After

Width:  |  Height:  |  Size: 14 KiB

BIN
data/images/configure.png Executable file → Normal file

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.8 KiB

After

Width:  |  Height:  |  Size: 717 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 6.4 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 260 KiB

After

Width:  |  Height:  |  Size: 14 KiB

BIN
data/images/home.png Executable file → Normal file

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.7 KiB

After

Width:  |  Height:  |  Size: 5.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 7.3 KiB

After

Width:  |  Height:  |  Size: 4.6 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 13 KiB

After

Width:  |  Height:  |  Size: 564 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 13 KiB

After

Width:  |  Height:  |  Size: 332 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 352 B

BIN
data/images/music-icon.png Executable file → Normal file

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.8 KiB

After

Width:  |  Height:  |  Size: 5.7 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 7.3 KiB

After

Width:  |  Height:  |  Size: 3.9 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 6.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.8 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.2 KiB

After

Width:  |  Height:  |  Size: 500 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 5.2 KiB

After

Width:  |  Height:  |  Size: 4.8 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.8 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.2 MiB

After

Width:  |  Height:  |  Size: 2.4 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 7.3 KiB

After

Width:  |  Height:  |  Size: 5.9 KiB

BIN
data/images/search-box.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 13 KiB

After

Width:  |  Height:  |  Size: 771 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 13 KiB

After

Width:  |  Height:  |  Size: 325 B

BIN
data/images/source-info.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 844 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 858 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 563 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 589 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 301 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 530 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.5 KiB

After

Width:  |  Height:  |  Size: 8.7 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.4 KiB

After

Width:  |  Height:  |  Size: 3.6 KiB

BIN
data/images/view-refresh.png Executable file → Normal file

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.0 KiB

After

Width:  |  Height:  |  Size: 931 B

View File

@@ -1,300 +0,0 @@
// if run in phantomjs add fake Tomahawk environment
if(window.Tomahawk === undefined)
{
alert("PHANTOMJS ENVIRONMENT");
var Tomahawk = {
fakeEnv: function()
{
return true;
},
resolverData: function()
{
return {
scriptPath: function()
{
return "/home/tomahawk/resolver.js";
}
};
},
log: function( message )
{
console.log( message );
}
};
}
Tomahawk.resolver = {
scriptPath: Tomahawk.resolverData().scriptPath
};
Tomahawk.timestamp = function() {
return Math.round( new Date()/1000 );
}
Tomahawk.dumpResult = function( result ) {
var results = result.results;
Tomahawk.log("Dumping " + results.length + " results for query " + result.qid + "...");
for(var i=0; i<results.length;i++)
{
var result = results[i];
Tomahawk.log( result.artist + " - " + result.track + " | " + result.url );
}
Tomahawk.log("Done.");
}
// javascript part of Tomahawk-Object API
Tomahawk.extend = function(object, members) {
var F = function() {};
F.prototype = object;
var newObject = new F;
for(var key in members)
{
newObject[key] = members[key];
}
return newObject;
}
// Resolver BaseObject, inherit it to implement your own resolver
var TomahawkResolver = {
init: function()
{
},
scriptPath: function()
{
return Tomahawk.resolverData().scriptPath;
},
getConfigUi: function()
{
return {};
},
getUserConfig: function()
{
var configJson = window.localStorage[ this.scriptPath() ];
if( configJson === undefined )
configJson = "{}";
var config = JSON.parse( configJson );
return config;
},
saveUserConfig: function()
{
var config = Tomahawk.resolverData().config;
var configJson = JSON.stringify( config );
window.localStorage[ this.scriptPath() ] = configJson;
},
resolve: function( qid, artist, album, title )
{
return {
qid: qid
};
},
search: function( qid, searchString )
{
return this.resolve( qid, "", "", searchString );
}
};
/**** begin example implementation of a resolver ****/
// implement the resolver
/*
* var DemoResolver = Tomahawk.extend(TomahawkResolver,
* {
* getSettings: function()
* {
* return {
* name: "Demo Resolver",
* weigth: 95,
* timeout: 5,
* limit: 10
};
},
resolve: function( qid, artist, album, track )
{
return {
qid: qid,
results: [
{
artist: "Mokele",
album: "You Yourself are Me Myself and I am in Love",
track: "Hiding In Your Insides (php)",
source: "Mokele.co.uk",
url: "http://play.mokele.co.uk/music/Hiding%20In%20Your%20Insides.mp3",
bitrate: 160,
duration: 248,
size: 4971780,
score: 1.0,
extension: "mp3",
mimetype: "audio/mpeg"
}
]
};
}
}
);
// register the resolver
Tomahawk.resolver.instance = DemoResolver;*/
/**** end example implementation of a resolver ****/
// help functions
Tomahawk.valueForSubNode = function(node, tag)
{
if(node === undefined)
throw new Error("Tomahawk.valueForSubnode: node is undefined!");
var element = node.getElementsByTagName(tag)[0];
if( element === undefined )
return undefined;
return element.textContent;
};
Tomahawk.syncRequest = function(url)
{
var xmlHttpRequest = new XMLHttpRequest();
xmlHttpRequest.open('GET', url, false);
xmlHttpRequest.send(null);
return xmlHttpRequest.responseText;
}
/**
*
* Secure Hash Algorithm (SHA256)
* http://www.webtoolkit.info/
*
* Original code by Angel Marin, Paul Johnston.
*
**/
Tomahawk.sha256=function(s){
var chrsz = 8;
var hexcase = 0;
function safe_add (x, y) {
var lsw = (x & 0xFFFF) + (y & 0xFFFF);
var msw = (x >> 16) + (y >> 16) + (lsw >> 16);
return (msw << 16) | (lsw & 0xFFFF);
}
function S (X, n) { return ( X >>> n ) | (X << (32 - n)); }
function R (X, n) { return ( X >>> n ); }
function Ch(x, y, z) { return ((x & y) ^ ((~x) & z)); }
function Maj(x, y, z) { return ((x & y) ^ (x & z) ^ (y & z)); }
function Sigma0256(x) { return (S(x, 2) ^ S(x, 13) ^ S(x, 22)); }
function Sigma1256(x) { return (S(x, 6) ^ S(x, 11) ^ S(x, 25)); }
function Gamma0256(x) { return (S(x, 7) ^ S(x, 18) ^ R(x, 3)); }
function Gamma1256(x) { return (S(x, 17) ^ S(x, 19) ^ R(x, 10)); }
function core_sha256 (m, l) {
var K = new Array(0x428A2F98, 0x71374491, 0xB5C0FBCF, 0xE9B5DBA5, 0x3956C25B, 0x59F111F1, 0x923F82A4, 0xAB1C5ED5, 0xD807AA98, 0x12835B01, 0x243185BE, 0x550C7DC3, 0x72BE5D74, 0x80DEB1FE, 0x9BDC06A7, 0xC19BF174, 0xE49B69C1, 0xEFBE4786, 0xFC19DC6, 0x240CA1CC, 0x2DE92C6F, 0x4A7484AA, 0x5CB0A9DC, 0x76F988DA, 0x983E5152, 0xA831C66D, 0xB00327C8, 0xBF597FC7, 0xC6E00BF3, 0xD5A79147, 0x6CA6351, 0x14292967, 0x27B70A85, 0x2E1B2138, 0x4D2C6DFC, 0x53380D13, 0x650A7354, 0x766A0ABB, 0x81C2C92E, 0x92722C85, 0xA2BFE8A1, 0xA81A664B, 0xC24B8B70, 0xC76C51A3, 0xD192E819, 0xD6990624, 0xF40E3585, 0x106AA070, 0x19A4C116, 0x1E376C08, 0x2748774C, 0x34B0BCB5, 0x391C0CB3, 0x4ED8AA4A, 0x5B9CCA4F, 0x682E6FF3, 0x748F82EE, 0x78A5636F, 0x84C87814, 0x8CC70208, 0x90BEFFFA, 0xA4506CEB, 0xBEF9A3F7, 0xC67178F2);
var HASH = new Array(0x6A09E667, 0xBB67AE85, 0x3C6EF372, 0xA54FF53A, 0x510E527F, 0x9B05688C, 0x1F83D9AB, 0x5BE0CD19);
var W = new Array(64);
var a, b, c, d, e, f, g, h, i, j;
var T1, T2;
m[l >> 5] |= 0x80 << (24 - l % 32);
m[((l + 64 >> 9) << 4) + 15] = l;
for ( var i = 0; i<m.length; i+=16 ) {
a = HASH[0];
b = HASH[1];
c = HASH[2];
d = HASH[3];
e = HASH[4];
f = HASH[5];
g = HASH[6];
h = HASH[7];
for ( var j = 0; j<64; j++) {
if (j < 16) W[j] = m[j + i];
else W[j] = safe_add(safe_add(safe_add(Gamma1256(W[j - 2]), W[j - 7]), Gamma0256(W[j - 15])), W[j - 16]);
T1 = safe_add(safe_add(safe_add(safe_add(h, Sigma1256(e)), Ch(e, f, g)), K[j]), W[j]);
T2 = safe_add(Sigma0256(a), Maj(a, b, c));
h = g;
g = f;
f = e;
e = safe_add(d, T1);
d = c;
c = b;
b = a;
a = safe_add(T1, T2);
}
HASH[0] = safe_add(a, HASH[0]);
HASH[1] = safe_add(b, HASH[1]);
HASH[2] = safe_add(c, HASH[2]);
HASH[3] = safe_add(d, HASH[3]);
HASH[4] = safe_add(e, HASH[4]);
HASH[5] = safe_add(f, HASH[5]);
HASH[6] = safe_add(g, HASH[6]);
HASH[7] = safe_add(h, HASH[7]);
}
return HASH;
}
function str2binb (str) {
var bin = Array();
var mask = (1 << chrsz) - 1;
for(var i = 0; i < str.length * chrsz; i += chrsz) {
bin[i>>5] |= (str.charCodeAt(i / chrsz) & mask) << (24 - i%32);
}
return bin;
}
function Utf8Encode(string) {
string = string.replace(/\r\n/g,"\n");
var utftext = "";
for (var n = 0; n < string.length; n++) {
var c = string.charCodeAt(n);
if (c < 128) {
utftext += String.fromCharCode(c);
}
else if((c > 127) && (c < 2048)) {
utftext += String.fromCharCode((c >> 6) | 192);
utftext += String.fromCharCode((c & 63) | 128);
}
else {
utftext += String.fromCharCode((c >> 12) | 224);
utftext += String.fromCharCode(((c >> 6) & 63) | 128);
utftext += String.fromCharCode((c & 63) | 128);
}
}
return utftext;
}
function binb2hex (binarray) {
var hex_tab = hexcase ? "0123456789ABCDEF" : "0123456789abcdef";
var str = "";
for(var i = 0; i < binarray.length * 4; i++) {
str += hex_tab.charAt((binarray[i>>2] >> ((3 - i%4)*8+4)) & 0xF) +
hex_tab.charAt((binarray[i>>2] >> ((3 - i%4)*8 )) & 0xF);
}
return str;
}
s = Utf8Encode(s);
return binb2hex(core_sha256(str2binb(s), s.length * chrsz));
}

View File

@@ -1,22 +0,0 @@
-- Script to migate from db version 23 to 24.
-- Added the social_attributes table.
--
-- Separate each command with %%
CREATE TABLE IF NOT EXISTS social_attributes (
id INTEGER REFERENCES track(id) ON DELETE CASCADE ON UPDATE CASCADE DEFERRABLE INITIALLY DEFERRED, -- track id
source INTEGER REFERENCES source(id) ON DELETE CASCADE ON UPDATE CASCADE, -- DEFERRABLE INITIALLY DEFERRED,
k TEXT NOT NULL,
v TEXT NOT NULL,
timestamp INTEGER NOT NULL DEFAULT 0
);
CREATE INDEX social_attrib_id ON social_attributes(id);
CREATE INDEX social_attrib_source ON social_attributes(source);
CREATE INDEX social_attrib_k ON social_attributes(k);
CREATE INDEX social_attrib_timestamp ON social_attributes(timestamp);
UPDATE settings SET v = '24' WHERE k == 'schema_version';

View File

@@ -1,18 +0,0 @@
-- Script to migate from db version 24 to 25.
-- Added the social_attributes table.
--
-- Separate each command with %%
ALTER TABLE dynamic_playlist RENAME TO tmp_dynamic_playlist;
CREATE TABLE IF NOT EXISTS dynamic_playlist (
guid TEXT NOT NULL REFERENCES playlist(guid) ON DELETE CASCADE ON UPDATE CASCADE DEFERRABLE INITIALLY DEFERRED,
pltype TEXT, -- the generator type
plmode INTEGER -- the mode of this playlist
);
INSERT INTO dynamic_playlist( guid, pltype, plmode ) SELECT guid, pltype, plmode FROM tmp_dynamic_playlist;
DROP TABLE tmp_dynamic_playlist;
UPDATE settings SET v = '25' WHERE k == 'schema_version';

View File

View File

View File

@@ -1,12 +1,13 @@
<RCC>
<qresource>
<file>./data/images/add-friend-button-pressed.png</file>
<file>./data/images/add-friend-button-rest.png</file>
<file>./data/images/avatar-dude-plus.png</file>
<file>./data/images/avatar-dude.png</file>
<file>./data/images/back-pressed.png</file>
<file>./data/images/back-rest.png</file>
<file>./data/images/cover-shadow.png</file>
<file>./data/images/loved.png</file>
<file>./data/images/not-loved.png</file>
<file>./data/images/magnifying-glass.png</file>
<file>./data/images/no-album-art-placeholder.png</file>
<file>./data/images/now-playing-panel.png</file>
<file>./data/images/now-playing-speaker.png</file>
@@ -24,6 +25,7 @@
<file>./data/images/repeat-off-pressed.png</file>
<file>./data/images/repeat-off-rest.png</file>
<file>./data/images/search-box-dismiss-x.png</file>
<file>./data/images/search-box.png</file>
<file>./data/images/seek-and-volume-knob-pressed.png</file>
<file>./data/images/seek-and-volume-knob-rest.png</file>
<file>./data/images/seek-slider-bkg.png</file>
@@ -34,6 +36,14 @@
<file>./data/images/shuffle-on-rest.png</file>
<file>./data/images/skip-pressed.png</file>
<file>./data/images/skip-rest.png</file>
<file>./data/images/source-info.png</file>
<file>./data/images/source-off-pressed.png</file>
<file>./data/images/source-off-rest.png</file>
<file>./data/images/source-on-pressed.png</file>
<file>./data/images/source-on-rest.png</file>
<file>./data/images/status-alert-icon.png</file>
<file>./data/images/status-bar-bkg.png</file>
<file>./data/images/status-dismiss-x.png</file>
<file>./data/images/user-avatar.png</file>
<file>./data/images/view-toggle-active-centre.png</file>
<file>./data/images/view-toggle-active-left.png</file>
@@ -78,9 +88,6 @@
<file>./data/images/music-settings.png</file>
<file>./data/images/resolvers-settings.png</file>
<file>./data/images/lastfm-settings.png</file>
<file>./data/images/automatic-playlist.png</file>
<file>./data/images/station.png</file>
<file>./data/images/new-additions.png</file>
<file>./data/stylesheets/topbar-radiobuttons.css</file>
<file>./data/icons/tomahawk-icon-16x16.png</file>
<file>./data/icons/tomahawk-icon-32x32.png</file>
@@ -95,8 +102,5 @@
<file>./data/www/auth.na.html</file>
<file>./data/www/tomahawk_banner_small.png</file>
<file>./data/sql/dbmigrate-22_to_23.sql</file>
<file>./data/sql/dbmigrate-23_to_24.sql</file>
<file>./data/sql/dbmigrate-24_to_25.sql</file>
<file>./data/js/tomahawk.js</file>
</qresource>
</RCC>

View File

@@ -4,10 +4,6 @@ CMAKE_MINIMUM_REQUIRED( VERSION 2.8 )
IF( "${gui}" STREQUAL "no" )
SET( QT_DONT_USE_QTGUI TRUE )
ENDIF()
IF( UNIX AND NOT APPLE )
SET( QT_USE_QTDBUS TRUE )
ENDIF( UNIX AND NOT APPLE )
SET( QT_USE_QTSQL TRUE )
SET( QT_USE_QTNETWORK TRUE )
SET( QT_USE_QTXML TRUE )
@@ -74,6 +70,8 @@ SET( tomahawkSourcesGui ${tomahawkSourcesGui}
resolverconfigdelegate.cpp
resolversmodel.cpp
tomahawkwindow.cpp
win/qtwin.cpp
)
SET( tomahawkHeaders ${tomahawkHeaders}
@@ -118,14 +116,17 @@ SET( tomahawkHeadersGui ${tomahawkHeadersGui}
resolversmodel.h
delegateconfigwrapper.h
tomahawkwindow.h
win/qtwin.h
)
SET( tomahawkUI ${tomahawkUI}
tomahawkwindow.ui
settingsdialog.ui
diagnosticsdialog.ui
stackedsettingsdialog.ui
proxydialog.ui
searchbox.ui
audiocontrols.ui
)
@@ -264,5 +265,4 @@ IF( UNIX AND NOT APPLE AND KDE4_INSTALLED ) #install protocol file
ENDIF()
INSTALL( FILES ${CMAKE_BINARY_DIR}/tomahawk.protocol DESTINATION ${PROTOCOL_INSTALL_DIR} )
ENDIF()
#INCLUDE( "CPack.txt" )

View File

@@ -25,13 +25,9 @@
#include "viewmanager.h"
#include "utils/imagebutton.h"
#include "utils/tomahawkutils.h"
#include "database/database.h"
#include "database/databasecommand_socialaction.h"
#include "album.h"
using namespace Tomahawk;
static QString s_acInfoIdentifier = QString( "AUDIOCONTROLS" );
@@ -49,7 +45,7 @@ AudioControls::AudioControls( QWidget* parent )
font.setPixelSize( 12 );
#ifdef Q_WS_MAC
font.setPixelSize( font.pixelSize() - 2 );
font.setPointSize( font.pointSize() - 2 );
#endif
ui->artistTrackLabel->setFont( font );
@@ -79,8 +75,6 @@ AudioControls::AudioControls( QWidget* parent )
ui->repeatButton->setPixmap( RESPATH "images/repeat-off-pressed.png", QIcon::Off, QIcon::Active );
ui->volumeLowButton->setPixmap( RESPATH "images/volume-icon-muted.png" );
ui->volumeHighButton->setPixmap( RESPATH "images/volume-icon-full.png" );
ui->loveButton->setPixmap( RESPATH "images/not-loved.png" );
ui->loveButton->setCheckable( true );
ui->ownerLabel->setForegroundRole( QPalette::Dark );
ui->metaDataArea->setStyleSheet( "QWidget#metaDataArea {\nborder-width: 4px;\nborder-image: url(" RESPATH "images/now-playing-panel.png) 4 4 4 4 stretch stretch; }" );
@@ -143,6 +137,7 @@ AudioControls::AudioControls( QWidget* parent )
connect( ui->volumeLowButton, SIGNAL( clicked() ), AudioEngine::instance(), SLOT( lowerVolume() ) );
connect( ui->volumeHighButton, SIGNAL( clicked() ), AudioEngine::instance(), SLOT( raiseVolume() ) );
connect( ui->playPauseButton, SIGNAL( clicked() ), this, SIGNAL( playPressed() ) );
connect( ui->pauseButton, SIGNAL( clicked() ), this, SIGNAL( pausePressed() ) );
@@ -152,7 +147,6 @@ AudioControls::AudioControls( QWidget* parent )
connect( ui->artistTrackLabel, SIGNAL( clickedArtist() ), SLOT( onArtistClicked() ) );
connect( ui->artistTrackLabel, SIGNAL( clickedTrack() ), SLOT( onTrackClicked() ) );
connect( ui->albumLabel, SIGNAL( clickedAlbum() ), SLOT( onAlbumClicked() ) );
connect( ui->loveButton, SIGNAL( clicked( bool ) ), SLOT( onLoveButtonClicked( bool ) ) );
// <From AudioEngine>
connect( AudioEngine::instance(), SIGNAL( loading( Tomahawk::result_ptr ) ), SLOT( onPlaybackLoading( Tomahawk::result_ptr ) ) );
@@ -167,8 +161,8 @@ AudioControls::AudioControls( QWidget* parent )
.scaled( ui->coverImage->size(), Qt::IgnoreAspectRatio, Qt::SmoothTransformation );
connect( Tomahawk::InfoSystem::InfoSystem::instance(),
SIGNAL( info( Tomahawk::InfoSystem::InfoRequestData, QVariant ) ),
SLOT( infoSystemInfo( Tomahawk::InfoSystem::InfoRequestData, QVariant ) ) );
SIGNAL( info( QString, Tomahawk::InfoSystem::InfoType, QVariant, QVariant, Tomahawk::InfoSystem::InfoCustomData ) ),
SLOT( infoSystemInfo( QString, Tomahawk::InfoSystem::InfoType, QVariant, QVariant, Tomahawk::InfoSystem::InfoCustomData ) ) );
connect( Tomahawk::InfoSystem::InfoSystem::instance(), SIGNAL( finished( QString ) ), SLOT( infoSystemFinished( QString ) ) );
@@ -218,21 +212,20 @@ AudioControls::onPlaybackStarted( const Tomahawk::result_ptr& result )
trackInfo["artist"] = result->artist()->name();
trackInfo["album"] = result->album()->name();
Tomahawk::InfoSystem::InfoRequestData requestData;
requestData.caller = s_acInfoIdentifier;
requestData.type = Tomahawk::InfoSystem::InfoAlbumCoverArt;
requestData.input = QVariant::fromValue< Tomahawk::InfoSystem::InfoCriteriaHash >( trackInfo );
requestData.customData = QVariantMap();
Tomahawk::InfoSystem::InfoSystem::instance()->getInfo( requestData );
Tomahawk::InfoSystem::InfoSystem::instance()->getInfo(
s_acInfoIdentifier, Tomahawk::InfoSystem::InfoAlbumCoverArt,
QVariant::fromValue< Tomahawk::InfoSystem::InfoCriteriaHash >( trackInfo ), Tomahawk::InfoSystem::InfoCustomData() );
}
void
AudioControls::infoSystemInfo( Tomahawk::InfoSystem::InfoRequestData requestData, QVariant output )
AudioControls::infoSystemInfo( QString caller, Tomahawk::InfoSystem::InfoType type, QVariant input, QVariant output, Tomahawk::InfoSystem::InfoCustomData customData )
{
qDebug() << Q_FUNC_INFO << requestData.caller << requestData.type << s_acInfoIdentifier << Tomahawk::InfoSystem::InfoAlbumCoverArt;
if ( requestData.caller != s_acInfoIdentifier || requestData.type != Tomahawk::InfoSystem::InfoAlbumCoverArt )
Q_UNUSED( input );
Q_UNUSED( customData );
qDebug() << Q_FUNC_INFO << caller << type << s_acInfoIdentifier << Tomahawk::InfoSystem::InfoAlbumCoverArt;
if ( caller != s_acInfoIdentifier || type != Tomahawk::InfoSystem::InfoAlbumCoverArt )
{
qDebug() << "Info of wrong type or not with our identifier";
return;
@@ -244,13 +237,13 @@ AudioControls::infoSystemInfo( Tomahawk::InfoSystem::InfoRequestData requestData
return;
}
if ( !output.canConvert< QVariantMap >() )
if ( !output.canConvert< Tomahawk::InfoSystem::InfoCustomData >() )
{
qDebug() << "Cannot convert fetched art from a QByteArray";
return;
}
QVariantMap returnedData = output.value< QVariantMap >();
Tomahawk::InfoSystem::InfoCustomData returnedData = output.value< Tomahawk::InfoSystem::InfoCustomData >();
const QByteArray ba = returnedData["imgbytes"].toByteArray();
if ( ba.length() )
{
@@ -299,21 +292,6 @@ AudioControls::onPlaybackLoading( const Tomahawk::result_ptr& result )
ui->pauseButton->setVisible( true );
ui->playPauseButton->setVisible( false );
ui->playPauseButton->setEnabled( false );
ui->loveButton->setEnabled( true );
ui->loveButton->setVisible( true );
result->loadSocialActions();
if ( result->loved() )
{
ui->loveButton->setPixmap( RESPATH "images/loved.png" );
ui->loveButton->setChecked( true );
}
else
{
ui->loveButton->setPixmap( RESPATH "images/not-loved.png" );
ui->loveButton->setChecked( false );
}
}
@@ -336,11 +314,10 @@ AudioControls::onPlaybackResumed()
/* m_playAction->setEnabled( false );
m_pauseAction->setEnabled( true ); */
ui->playPauseButton->setVisible( false );
ui->playPauseButton->setEnabled( false );
ui->pauseButton->setVisible( true );
ui->pauseButton->setEnabled( true );
ui->loveButton->setVisible( true );
ui->playPauseButton->setVisible( false );
ui->playPauseButton->setEnabled( false );
}
@@ -361,8 +338,6 @@ AudioControls::onPlaybackStopped()
ui->pauseButton->setEnabled( false );
ui->playPauseButton->setEnabled( true );
ui->playPauseButton->setVisible( true );
ui->loveButton->setEnabled( false );
ui->loveButton->setVisible( false );
/* m_pauseAction->setEnabled( false );
m_playAction->setEnabled( true ); */
@@ -503,35 +478,3 @@ AudioControls::onTrackClicked()
{
ViewManager::instance()->showCurrentTrack();
}
void
AudioControls::onLoveButtonClicked( bool checked )
{
Tomahawk::InfoSystem::InfoCriteriaHash trackInfo;
trackInfo["title"] = m_currentTrack->track();
trackInfo["artist"] = m_currentTrack->artist()->name();
trackInfo["album"] = m_currentTrack->album()->name();
if ( checked )
{
Tomahawk::InfoSystem::InfoSystem::instance()->pushInfo(
s_acInfoIdentifier, Tomahawk::InfoSystem::InfoLove,
QVariant::fromValue< Tomahawk::InfoSystem::InfoCriteriaHash >( trackInfo ) );
DatabaseCommand_SocialAction* cmd = new DatabaseCommand_SocialAction( m_currentTrack, QString( "Love" ), QString( "true") );
Database::instance()->enqueue( QSharedPointer<DatabaseCommand>(cmd) );
ui->loveButton->setPixmap( RESPATH "images/loved.png" );
}
else
{
Tomahawk::InfoSystem::InfoSystem::instance()->pushInfo(
s_acInfoIdentifier, Tomahawk::InfoSystem::InfoUnLove,
QVariant::fromValue< Tomahawk::InfoSystem::InfoCriteriaHash >( trackInfo ) );
DatabaseCommand_SocialAction* cmd = new DatabaseCommand_SocialAction( m_currentTrack, QString( "Love" ), QString( "false" ) );
Database::instance()->enqueue( QSharedPointer<DatabaseCommand>(cmd) );
ui->loveButton->setPixmap( RESPATH "images/not-loved.png" );
}
}

View File

@@ -43,7 +43,7 @@ signals:
void pausePressed();
public slots:
void onRepeatModeChanged( Tomahawk::PlaylistInterface::RepeatMode mode );
void onRepeatModeChanged( PlaylistInterface::RepeatMode mode );
void onShuffleModeChanged( bool enabled );
protected:
@@ -65,9 +65,8 @@ private slots:
void onArtistClicked();
void onAlbumClicked();
void onTrackClicked();
void onLoveButtonClicked( bool );
void infoSystemInfo( Tomahawk::InfoSystem::InfoRequestData requestData, QVariant output );
void infoSystemInfo( QString caller, Tomahawk::InfoSystem::InfoType type, QVariant input, QVariant output, Tomahawk::InfoSystem::InfoCustomData customData );
void infoSystemFinished( QString target );
private:
@@ -81,7 +80,7 @@ private:
QPixmap m_defaultCover;
Tomahawk::result_ptr m_currentTrack;
Tomahawk::PlaylistInterface::RepeatMode m_repeatMode;
PlaylistInterface::RepeatMode m_repeatMode;
bool m_shuffled;
};

View File

@@ -251,39 +251,6 @@
</property>
</spacer>
</item>
<item>
<layout class="QVBoxLayout" name="verticalLayout_2">
<item>
<widget class="ImageButton" name="loveButton">
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="Minimum">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="cursor">
<cursorShape>PointingHandCursor</cursorShape>
</property>
<property name="text">
<string>love</string>
</property>
</widget>
</item>
<item>
<spacer name="verticalSpacer_2">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>13</height>
</size>
</property>
</spacer>
</item>
</layout>
</item>
<item>
<widget class="QLabel" name="ownerLabel">
<property name="font">

View File

@@ -21,7 +21,6 @@
#include <QDialog>
#include <QDialogButtonBox>
#include <QVBoxLayout>
#include <QPushButton>
class DelegateConfigWrapper : public QDialog
{
@@ -29,10 +28,8 @@ class DelegateConfigWrapper : public QDialog
public:
DelegateConfigWrapper( QWidget* conf, const QString& title, QWidget* parent, Qt::WindowFlags flags = 0 ) : QDialog( parent, flags ), m_widget( conf )
{
m_widget->setWindowFlags( Qt::Sheet );
#ifdef Q_OS_MAC
m_widget->setVisible( true );
#endif
m_widget->setWindowFlags( Qt::Sheet );
setWindowTitle( title );
QVBoxLayout* v = new QVBoxLayout( this );
@@ -40,7 +37,6 @@ public:
v->addWidget( m_widget );
QDialogButtonBox* buttons = new QDialogButtonBox( QDialogButtonBox::Ok | QDialogButtonBox::Cancel, Qt::Horizontal, this );
m_okButton = buttons->button( QDialogButtonBox::Ok );
connect( buttons, SIGNAL( clicked( QAbstractButton*) ), this, SLOT( closed( QAbstractButton* ) ) );
connect( this, SIGNAL( rejected() ), this, SLOT( rejected() ) );
v->addWidget( buttons );
@@ -51,19 +47,9 @@ public:
setSizeGripEnabled( false );
setMinimumSize( sizeHint() );
setMaximumSize( sizeHint() ); // to remove the resize grip on osx this is the only way
connect( conf, SIGNAL( sizeHintChanged() ), this, SLOT( updateSizeHint() ) );
#else
m_widget->setVisible( true );
#endif
}
public slots:
void toggleOkButton( bool dataError )
{
// if dataError is True we want to set the button enabled to false
m_okButton->setEnabled( !dataError );
}
void closed( QAbstractButton* b )
{
// let the config widget live to see another day
@@ -86,18 +72,8 @@ public slots:
m_widget->setVisible( false );
}
void updateSizeHint() {
hide();
setSizeGripEnabled( false );
setMinimumSize( sizeHint() );
setMaximumSize( sizeHint() );
show();
}
private:
QWidget* m_widget;
QPushButton* m_okButton;
};
#endif

View File

@@ -22,7 +22,8 @@
#ifdef ENABLE_HEADLESS
#define TOMAHAWK_APPLICATION QCoreApplication
#include <QApplication>
#define TOMAHAWK_HEADLESS
#include <QApplication>>
#else

View File

@@ -27,11 +27,9 @@ set( libSources
query.cpp
result.cpp
source.cpp
sourceplaylistinterface.cpp
viewpage.cpp
viewmanager.cpp
globalactionmanager.cpp
contextMenu.cpp
sip/SipPlugin.cpp
sip/SipHandler.cpp
@@ -56,7 +54,6 @@ set( libSources
database/databasecommand_addfiles.cpp
database/databasecommand_deletefiles.cpp
database/databasecommand_dirmtimes.cpp
database/databasecommand_filemtimes.cpp
database/databasecommand_loadfile.cpp
database/databasecommand_logplayback.cpp
database/databasecommand_addsource.cpp
@@ -81,16 +78,14 @@ set( libSources
database/databasecommand_deletedynamicplaylist.cpp
database/databasecommand_addclientauth.cpp
database/databasecommand_clientauthvalid.cpp
database/databasecommand_socialaction.cpp
database/databasecommand_loadsocialactions.cpp
database/database.cpp
infosystem/infosystemcache.cpp
infosystem/infosystem.cpp
infosystem/infosystemworker.cpp
infosystem/infoplugins/generic/echonestplugin.cpp
infosystem/infoplugins/generic/lastfmplugin.cpp
infosystem/infoplugins/generic/musixmatchplugin.cpp
infosystem/infoplugins/echonestplugin.cpp
infosystem/infoplugins/lastfmplugin.cpp
infosystem/infoplugins/musixmatchplugin.cpp
playlist/treemodel.cpp
playlist/treeproxymodel.cpp
@@ -166,14 +161,11 @@ set( libSources
utils/xspfgenerator.cpp
widgets/newplaylistwidget.cpp
widgets/searchwidget.cpp
widgets/playlisttypeselectordlg.cpp
widgets/welcomewidget.cpp
widgets/welcomeplaylistmodel.cpp
widgets/overlaywidget.cpp
widgets/HeaderLabel.cpp
widgets/infowidgets/sourceinfowidget.cpp
widgets/infowidgets/ArtistInfoWidget.cpp
kdsingleapplicationguard/kdsingleapplicationguard.cpp
kdsingleapplicationguard/kdsharedmemorylocker.cpp
@@ -194,10 +186,9 @@ set( libHeaders
resolver.h
result.h
source.h
sourceplaylistinterface.h
viewpage.h
viewmanager.h
globalactionmanager.h
contextMenu.h
artist.h
album.h
@@ -225,7 +216,6 @@ set( libHeaders
database/databasecommand_addfiles.h
database/databasecommand_deletefiles.h
database/databasecommand_dirmtimes.h
database/databasecommand_filemtimes.h
database/databasecommand_loadfile.h
database/databasecommand_logplayback.h
database/databasecommand_addsource.h
@@ -252,15 +242,13 @@ set( libHeaders
database/databasecommand_loadallstations.h
database/databasecommand_addclientauth.h
database/databasecommand_clientauthvalid.h
database/databasecommand_socialaction.h
database/databasecommand_loadsocialactions.h
infosystem/infosystem.h
infosystem/infosystemworker.h
infosystem/infosystemcache.h
infosystem/infoplugins/generic/echonestplugin.h
infosystem/infoplugins/generic/lastfmplugin.h
infosystem/infoplugins/generic/musixmatchplugin.h
infosystem/infoplugins/echonestplugin.h
infosystem/infoplugins/lastfmplugin.h
infosystem/infoplugins/musixmatchplugin.h
network/bufferiodevice.h
network/msgprocessor.h
@@ -309,6 +297,7 @@ set( libHeaders
playlist/dynamic/DynamicPlaylist.h
playlist/dynamic/DynamicControl.h
playlist/dynamic/GeneratorFactory.h
playlist/dynamic/GeneratorInterface.h
playlist/dynamic/DynamicView.h
playlist/dynamic/DynamicModel.h
@@ -324,6 +313,7 @@ set( libHeaders
playlist/dynamic/widgets/DynamicSetupWidget.h
playlist/dynamic/widgets/LoadingSpinner.h
utils/tomahawkutils.h
utils/querylabel.h
utils/elidedlabel.h
utils/animatedcounterlabel.h
@@ -335,36 +325,26 @@ set( libHeaders
utils/xspfgenerator.h
widgets/newplaylistwidget.h
widgets/searchwidget.h
widgets/playlisttypeselectordlg.h
widgets/welcomewidget.h
widgets/welcomeplaylistmodel.h
widgets/overlaywidget.h
widgets/HeaderLabel.h
widgets/infowidgets/sourceinfowidget.h
widgets/infowidgets/ArtistInfoWidget.h
kdsingleapplicationguard/kdsingleapplicationguard.h
kdsingleapplicationguard/kdsharedmemorylocker.h
kdsingleapplicationguard/kdtoolsglobal.h
kdsingleapplicationguard/kdlockedsharedmemorypointer.h
)
set( libHeaders_NoMOC
viewpage.h
infosystem/infoplugins/unix/imageconverter.h
playlist/dynamic/GeneratorInterface.h
playlist/dynamic/GeneratorFactory.h
utils/tomahawkutils.h
playlist/dynamic/GeneratorInterface.h
)
set( libUI ${libUI}
widgets/playlisttypeselectordlg.ui
widgets/newplaylistwidget.ui
widgets/searchwidget.ui
widgets/welcomewidget.ui
widgets/infowidgets/sourceinfowidget.ui
widgets/infowidgets/ArtistInfoWidget.ui
playlist/topbar/topbar.ui
playlist/infobar/infobar.ui
)
@@ -384,27 +364,11 @@ include_directories( . ${CMAKE_CURRENT_BINARY_DIR} ${CMAKE_CURRENT_BINARY_DIR}/.
${LIBPORTFWD_INCLUDE_DIR}
${THIRDPARTY_DIR}/qxt/qxtweb-standalone/qxtweb
${THIRDPARTY_DIR}/gntp-send/gntp-send/headers
${CMAKE_BINARY_DIR}/thirdparty/liblastfm2/src
)
IF( UNIX AND NOT APPLE )
SET( libSources ${libSources}
infosystem/infoplugins/unix/fdonotifyplugin.cpp
infosystem/infoplugins/unix/imageconverter.cpp )
SET( libHeaders ${libHeaders}
infosystem/infoplugins/unix/fdonotifyplugin.h
infosystem/infoplugins/unix/imageconverter.h )
ENDIF( UNIX AND NOT APPLE )
IF( WIN32 )
SET( libSources ${libSources}
infosystem/infoplugins/win/gfwnotifyplugin.cpp )
SET( libHeaders ${libHeaders}
infosystem/infoplugins/win/gfwnotifyplugin.h )
SET( OS_SPECIFIC_LINK_LIBRARIES
${OS_SPECIFIC_LINK_LIBRARIES}
# System
@@ -420,25 +384,13 @@ ENDIF( WIN32 )
IF( APPLE )
FIND_LIBRARY( COREAUDIO_LIBRARY CoreAudio )
FIND_LIBRARY( COREFOUNDATION_LIBRARY CoreFoundation )
FIND_LIBRARY( FOUNDATION_LIBRARY Foundation )
FIND_LIBRARY( SCRIPTINGBRIDGE_LIBRARY ScriptingBridge )
MARK_AS_ADVANCED( COREAUDIO_LIBRARY COREFOUNDATION_LIBRARY FOUNDATION_LIBRARY SCRIPTINGBRIDGE_LIBRARY )
SET( libSources ${libSources}
infosystem/infoplugins/mac/adium.mm
infosystem/infoplugins/mac/adiumplugin.cpp )
SET( libHeaders ${libHeaders}
infosystem/infoplugins/mac/adium.h
infosystem/infoplugins/mac/adiumplugin.h )
MARK_AS_ADVANCED( COREAUDIO_LIBRARY COREFOUNDATION_LIBRARY )
SET( OS_SPECIFIC_LINK_LIBRARIES
${OS_SPECIFIC_LINK_LIBRARIES}
# System
${COREAUDIO_LIBRARY}
${COREFOUNDATION_LIBRARY}
${FOUNDATION_LIBRARY}
${SCRIPTINGBRIDGE_LIBRARY}
)
ENDIF( APPLE )
@@ -457,8 +409,6 @@ target_link_libraries( tomahawklib
# Thirdparty shipped with tomahawk
${LIBPORTFWD_LIBRARIES}
tomahawk_growl
# External deps
${QJSON_LIBRARIES}
${PHONON_LIBS}

View File

@@ -52,7 +52,6 @@ Album::Album( unsigned int id, const QString& name, const Tomahawk::artist_ptr&
, m_id( id )
, m_name( name )
, m_artist( artist )
, m_currentItem( 0 )
, m_currentTrack( 0 )
{
}
@@ -81,20 +80,7 @@ Album::siblingItem( int itemsAway )
return Tomahawk::result_ptr();
m_currentTrack = p;
m_currentItem = m_queries.at( p )->results().first();
return m_currentItem;
}
bool
Album::hasNextItem()
{
int p = m_currentTrack;
p++;
if ( p < 0 || p >= m_queries.count() )
return false;
return true;
return m_queries.at( p )->results().first();
}

View File

@@ -52,9 +52,6 @@ public:
virtual Tomahawk::result_ptr siblingItem( int itemsAway );
virtual bool hasNextItem();
virtual Tomahawk::result_ptr currentItem() const { return m_currentItem; }
virtual PlaylistInterface::RepeatMode repeatMode() const { return PlaylistInterface::NoRepeat; }
virtual bool shuffled() const { return false; }
@@ -70,8 +67,6 @@ signals:
void tracksAdded( const QList<Tomahawk::query_ptr>& tracks );
void trackCountChanged( unsigned int tracks );
void sourceTrackCountChanged( unsigned int tracks );
void nextTrackReady();
private slots:
void onTracksAdded( const QList<Tomahawk::query_ptr>& tracks );
@@ -82,7 +77,7 @@ private:
artist_ptr m_artist;
QList<Tomahawk::query_ptr> m_queries;
result_ptr m_currentItem;
unsigned int m_currentTrack;
};

View File

@@ -26,27 +26,9 @@
using namespace Tomahawk;
Artist::Artist() {}
Artist::Artist()
{
}
Artist::~Artist()
{
}
artist_ptr
Artist::get( const QString& name, bool autoCreate )
{
int artid = Database::instance()->impl()->artistId( name, autoCreate );
if ( artid < 1 )
return artist_ptr();
return Artist::get( artid, name );
}
Artist::~Artist() {}
artist_ptr
Artist::get( unsigned int id, const QString& name )
@@ -72,7 +54,6 @@ Artist::Artist( unsigned int id, const QString& name )
: PlaylistInterface( this )
, m_id( id )
, m_name( name )
, m_currentItem( 0 )
, m_currentTrack( 0 )
{
}
@@ -101,20 +82,7 @@ Artist::siblingItem( int itemsAway )
return Tomahawk::result_ptr();
m_currentTrack = p;
m_currentItem = m_queries.at( p )->results().first();
return m_currentItem;
}
bool
Artist::hasNextItem()
{
int p = m_currentTrack;
p++;
if ( p < 0 || p >= m_queries.count() )
return false;
return true;
return m_queries.at( p )->results().first();
}

View File

@@ -1,5 +1,5 @@
/* === This file is part of Tomahawk Player - <http://tomahawk-player.org> ===
*
*
* Copyright 2010-2011, Christian Muehlhaeuser <muesli@tomahawk-player.org>
*
* Tomahawk is free software: you can redistribute it and/or modify
@@ -36,7 +36,6 @@ class DLLEXPORT Artist : public QObject, public PlaylistInterface
Q_OBJECT
public:
static artist_ptr get( const QString& name, bool autoCreate = false );
static artist_ptr get( unsigned int id, const QString& name );
Artist( unsigned int id, const QString& name );
@@ -53,9 +52,6 @@ public:
virtual Tomahawk::result_ptr siblingItem( int itemsAway );
virtual bool hasNextItem();
virtual Tomahawk::result_ptr currentItem() const { return m_currentItem; }
virtual PlaylistInterface::RepeatMode repeatMode() const { return PlaylistInterface::NoRepeat; }
virtual bool shuffled() const { return false; }
@@ -72,8 +68,6 @@ signals:
void trackCountChanged( unsigned int tracks );
void sourceTrackCountChanged( unsigned int tracks );
void nextTrackReady();
private slots:
void onTracksAdded( const QList<Tomahawk::query_ptr>& tracks );
@@ -82,7 +76,6 @@ private:
QString m_name;
QList<Tomahawk::query_ptr> m_queries;
result_ptr m_currentItem;
unsigned int m_currentTrack;
};

View File

@@ -21,20 +21,13 @@
#include <QUrl>
#include "playlistinterface.h"
#include "sourceplaylistinterface.h"
#include "tomahawksettings.h"
#include "database/database.h"
#include "database/databasecommand_logplayback.h"
#include "network/servent.h"
#include "album.h"
using namespace Tomahawk;
AudioEngine* AudioEngine::s_instance = 0;
static QString s_aeInfoIdentifier = QString( "AUDIOENGINE" );
AudioEngine*
AudioEngine::instance()
@@ -51,8 +44,6 @@ AudioEngine::AudioEngine()
, m_queue( 0 )
, m_timeElapsed( 0 )
, m_expectStop( false )
, m_waitingOnNewTrack( false )
, m_infoSystemConnected( false )
{
s_instance = this;
qDebug() << "Init AudioEngine";
@@ -66,22 +57,13 @@ AudioEngine::AudioEngine()
m_mediaObject->setTickInterval( 150 );
connect( m_mediaObject, SIGNAL( stateChanged( Phonon::State, Phonon::State ) ), SLOT( onStateChanged( Phonon::State, Phonon::State ) ) );
connect( m_mediaObject, SIGNAL( tick( qint64 ) ), SLOT( timerTriggered( qint64 ) ) );
connect( m_mediaObject, SIGNAL( aboutToFinish() ), SLOT( onAboutToFinish() ) );
connect( m_audioOutput, SIGNAL( volumeChanged( qreal ) ), this, SLOT( onVolumeChanged( qreal ) ) );
onVolumeChanged( m_audioOutput->volume() );
#ifdef Q_OS_MAC
// On mac, phonon volume is independent from system volume, so the onVolumeChanged call above just sets our volume to 100%.
// Since it's indendent, we'll set it to 75% since that's nicer
setVolume( 75 );
#endif
}
AudioEngine::~AudioEngine()
{
qDebug() << Q_FUNC_INFO;
m_mediaObject->stop();
// stop();
@@ -109,14 +91,6 @@ AudioEngine::play()
{
m_mediaObject->play();
emit resumed();
Tomahawk::InfoSystem::InfoCriteriaHash trackInfo;
trackInfo["title"] = m_currentTrack->track();
trackInfo["artist"] = m_currentTrack->artist()->name();
trackInfo["album"] = m_currentTrack->album()->name();
Tomahawk::InfoSystem::InfoSystem::instance()->pushInfo(
s_aeInfoIdentifier, Tomahawk::InfoSystem::InfoNowResumed,
QVariant::fromValue< Tomahawk::InfoSystem::InfoCriteriaHash >( trackInfo ) );
}
else
loadNextTrack();
@@ -130,7 +104,6 @@ AudioEngine::pause()
m_mediaObject->pause();
emit paused();
Tomahawk::InfoSystem::InfoSystem::instance()->pushInfo( s_aeInfoIdentifier, Tomahawk::InfoSystem::InfoNowPaused, QVariant() );
}
@@ -139,27 +112,11 @@ AudioEngine::stop()
{
qDebug() << Q_FUNC_INFO;
m_expectStop = true;
m_mediaObject->stop();
if ( m_playlist )
m_playlist->reset();
setCurrentTrack( Tomahawk::result_ptr() );
emit stopped();
Tomahawk::InfoSystem::InfoTypeMap map;
map[ Tomahawk::InfoSystem::InfoNowStopped ] = QVariant();
if ( m_waitingOnNewTrack )
sendWaitingNotification();
else if ( TomahawkSettings::instance()->verboseNotifications() )
{
QVariantMap stopInfo;
stopInfo["message"] = QString( "Tomahawk is stopped." );
map[ Tomahawk::InfoSystem::InfoNotifyUser ] = QVariant::fromValue< QVariantMap >( stopInfo );
}
Tomahawk::InfoSystem::InfoSystem::instance()->pushInfo( s_aeInfoIdentifier, map );
}
@@ -167,14 +124,6 @@ void
AudioEngine::previous()
{
qDebug() << Q_FUNC_INFO;
if ( !m_playlist )
return;
if ( m_playlist->skipRestrictions() == PlaylistInterface::NoSkip ||
m_playlist->skipRestrictions() == PlaylistInterface::NoSkipBackwards )
return;
loadPreviousTrack();
}
@@ -183,22 +132,6 @@ void
AudioEngine::next()
{
qDebug() << Q_FUNC_INFO;
if ( !m_playlist )
return;
if ( m_playlist->skipRestrictions() == PlaylistInterface::NoSkip ||
m_playlist->skipRestrictions() == PlaylistInterface::NoSkipForwards )
return;
if ( !m_currentTrack.isNull() && !m_playlist->hasNextItem() &&
m_currentTrack->id() == m_playlist->currentItem()->id() )
{
//For instance, when doing a catch-up while listening along, but the person
//you're following hasn't started a new track yet...don't do anything
return;
}
loadNextTrack();
}
@@ -206,12 +139,6 @@ AudioEngine::next()
void
AudioEngine::seek( int ms )
{
if ( !m_playlist )
return;
if ( m_playlist->seekRestrictions() == PlaylistInterface::NoSeek )
return;
if ( isPlaying() || isPaused() )
{
qDebug() << Q_FUNC_INFO << ms;
@@ -230,6 +157,7 @@ AudioEngine::setVolume( int percentage )
emit volumeChanged( percentage );
}
void
AudioEngine::mute()
{
@@ -237,92 +165,6 @@ AudioEngine::mute()
}
void
AudioEngine::sendWaitingNotification() const
{
QVariantMap retryInfo;
retryInfo["message"] = QString( "The current track could not be resolved. Tomahawk will pick back up with the next resolvable track from this source." );
Tomahawk::InfoSystem::InfoSystem::instance()->pushInfo(
s_aeInfoIdentifier, Tomahawk::InfoSystem::InfoNotifyUser,
QVariant::fromValue< QVariantMap >( retryInfo ) );
}
void
AudioEngine::sendNowPlayingNotification()
{
qDebug() << Q_FUNC_INFO;
if ( ! m_infoSystemConnected )
{
connect( Tomahawk::InfoSystem::InfoSystem::instance(),
SIGNAL( info( Tomahawk::InfoSystem::InfoRequestData, QVariant ) ),
SLOT( infoSystemInfo( Tomahawk::InfoSystem::InfoRequestData, QVariant ) ) );
connect( Tomahawk::InfoSystem::InfoSystem::instance(), SIGNAL( finished( QString ) ), SLOT( infoSystemFinished( QString ) ) );
m_infoSystemConnected = true;
}
Tomahawk::InfoSystem::InfoCriteriaHash trackInfo;
trackInfo["artist"] = m_currentTrack->album()->artist()->name();
trackInfo["album"] = m_currentTrack->album()->name();
Tomahawk::InfoSystem::InfoRequestData requestData;
requestData.caller = s_aeInfoIdentifier;
requestData.type = Tomahawk::InfoSystem::InfoAlbumCoverArt;
requestData.input = QVariant::fromValue< Tomahawk::InfoSystem::InfoCriteriaHash >( trackInfo );
requestData.customData = QVariantMap();
Tomahawk::InfoSystem::InfoSystem::instance()->getInfo( requestData );
}
void
AudioEngine::infoSystemInfo( Tomahawk::InfoSystem::InfoRequestData requestData, QVariant output )
{
qDebug() << Q_FUNC_INFO;
if ( requestData.caller != s_aeInfoIdentifier ||
requestData.type != Tomahawk::InfoSystem::InfoAlbumCoverArt )
{
qDebug() << Q_FUNC_INFO << " not destined for us or wrong type, caller is " << requestData.caller << " and type is " << requestData.type;
return;
}
QVariantMap playInfo;
playInfo["message"] = QString( "Tomahawk is playing \"%1\" by %2 on album %3." )
.arg( m_currentTrack->track() )
.arg( m_currentTrack->artist()->name() )
.arg( m_currentTrack->album()->name() );
if ( !output.isNull() && output.isValid() )
{
qDebug() << Q_FUNC_INFO << " output is valid";
QVariantMap returnedData = output.value< QVariantMap >();
const QByteArray ba = returnedData["imgbytes"].toByteArray();
qDebug() << "ba.length = " << ba.length();
if ( ba.length() )
{
QPixmap pm;
pm.loadFromData( ba );
playInfo["image"] = QVariant( pm.toImage() );
}
}
Tomahawk::InfoSystem::InfoSystem::instance()->pushInfo(
s_aeInfoIdentifier, Tomahawk::InfoSystem::InfoNotifyUser,
QVariant::fromValue< QVariantMap >( playInfo ) );
}
void
AudioEngine::infoSystemFinished( QString caller )
{
Q_UNUSED( caller );
qDebug() << Q_FUNC_INFO;
}
void
AudioEngine::onTrackAboutToFinish()
{
@@ -334,7 +176,6 @@ bool
AudioEngine::loadTrack( const Tomahawk::result_ptr& result )
{
qDebug() << Q_FUNC_INFO << thread() << result;
bool err = false;
{
@@ -363,6 +204,17 @@ AudioEngine::loadTrack( const Tomahawk::result_ptr& result )
qDebug() << "Starting new song from url:" << m_currentTrack->url();
emit loading( m_currentTrack );
if ( !m_input.isNull() || m_isPlayingHttp )
{
if ( !m_input.isNull() )
{
m_input->close();
m_input.clear();
}
m_expectStop = true;
}
if ( !isHttpResult( m_currentTrack->url() ) && !isLocalResult( m_currentTrack->url() ) )
{
m_mediaObject->setCurrentSource( io.data() );
@@ -382,30 +234,12 @@ AudioEngine::loadTrack( const Tomahawk::result_ptr& result )
m_isPlayingHttp = true;
}
if ( !m_input.isNull() )
{
m_input->close();
m_input.clear();
}
m_input = io;
m_mediaObject->play();
emit started( m_currentTrack );
DatabaseCommand_LogPlayback* cmd = new DatabaseCommand_LogPlayback( m_currentTrack, DatabaseCommand_LogPlayback::Started );
Database::instance()->enqueue( QSharedPointer<DatabaseCommand>(cmd) );
Tomahawk::InfoSystem::InfoCriteriaHash trackInfo;
trackInfo["title"] = m_currentTrack->track();
trackInfo["artist"] = m_currentTrack->artist()->name();
trackInfo["album"] = m_currentTrack->album()->name();
if ( TomahawkSettings::instance()->verboseNotifications() )
sendNowPlayingNotification();
Tomahawk::InfoSystem::InfoSystem::instance()->pushInfo(
s_aeInfoIdentifier,
Tomahawk::InfoSystem::InfoNowPlaying,
QVariant::fromValue< Tomahawk::InfoSystem::InfoCriteriaHash >( trackInfo ) );
}
}
@@ -415,7 +249,6 @@ AudioEngine::loadTrack( const Tomahawk::result_ptr& result )
return false;
}
m_waitingOnNewTrack = false;
return true;
}
@@ -458,77 +291,53 @@ AudioEngine::loadNextTrack()
if ( !result.isNull() )
loadTrack( result );
else
{
if ( m_playlist && m_playlist->retryMode() == Tomahawk::PlaylistInterface::Retry )
m_waitingOnNewTrack = true;
stop();
}
}
void
AudioEngine::playItem( Tomahawk::PlaylistInterface* playlist, const Tomahawk::result_ptr& result )
AudioEngine::playItem( PlaylistInterface* playlist, const Tomahawk::result_ptr& result )
{
qDebug() << Q_FUNC_INFO;
if ( m_playlist )
m_playlist->reset();
setPlaylist( playlist );
m_currentTrackPlaylist = playlist;
if ( !result.isNull() )
loadTrack( result );
else if ( m_playlist && m_playlist->retryMode() == PlaylistInterface::Retry )
{
m_waitingOnNewTrack = true;
stop();
}
}
void
AudioEngine::playlistNextTrackReady()
{
if ( !m_waitingOnNewTrack )
return;
m_waitingOnNewTrack = false;
next();
}
void
AudioEngine::onAboutToFinish()
{
qDebug() << Q_FUNC_INFO;
m_expectStop = true;
loadTrack( result );
}
void
AudioEngine::onStateChanged( Phonon::State newState, Phonon::State oldState )
{
qDebug() << Q_FUNC_INFO << oldState << newState << m_expectStop;
qDebug() << Q_FUNC_INFO << oldState << newState;
if ( newState == Phonon::ErrorState )
{
qDebug() << "Phonon Error:" << m_mediaObject->errorString() << m_mediaObject->errorType();
return;
}
if ( !m_expectStop )
return;
m_expectStop = false;
if ( oldState == Phonon::PlayingState )
if ( oldState == Phonon::PlayingState && newState == Phonon::StoppedState )
{
if ( newState == Phonon::PausedState || newState == Phonon::StoppedState )
qDebug() << "Expecting stop?" << m_expectStop;
if ( !m_expectStop )
{
qDebug() << "Loading next track.";
m_expectStop = false;
loadNextTrack();
}
}
else if ( oldState == Phonon::PlayingState && newState == Phonon::PausedState )
{
qDebug() << m_mediaObject->currentTime() << m_mediaObject->totalTime();
if ( m_mediaObject->currentTime() == m_mediaObject->totalTime() )
{
qDebug() << "Loading next track.";
m_expectStop = false;
loadNextTrack();
}
}
m_expectStop = false;
}
@@ -557,14 +366,7 @@ AudioEngine::timerTriggered( qint64 time )
void
AudioEngine::setPlaylist( PlaylistInterface* playlist )
{
if ( m_playlist )
m_playlist->reset();
m_playlist = playlist;
if ( m_playlist && m_playlist->object() && m_playlist->retryMode() == PlaylistInterface::Retry )
connect( m_playlist->object(), SIGNAL( nextTrackReady() ), SLOT( playlistNextTrackReady() ) );
emit playlistChanged( playlist );
}
@@ -588,7 +390,7 @@ AudioEngine::setCurrentTrack( const Tomahawk::result_ptr& result )
bool
AudioEngine::isHttpResult( const QString& url ) const
{
return url.startsWith( "http://" ) || url.startsWith( "https://" );
return url.startsWith( "http://" );
}

View File

@@ -20,13 +20,10 @@
#define AUDIOENGINE_H
#include <QObject>
#include <QTimer>
#include <phonon/MediaObject>
#include <phonon/AudioOutput>
#include "infosystem/infosystem.h"
#include "result.h"
#include "typedefs.h"
@@ -34,10 +31,7 @@
#define AUDIO_VOLUME_STEP 5
namespace Tomahawk
{
class PlaylistInterface;
}
class PlaylistInterface;
class DLLEXPORT AudioEngine : public QObject
{
@@ -56,13 +50,11 @@ public:
bool isPaused() const { return m_mediaObject->state() == Phonon::PausedState; }
/* Returns the PlaylistInterface of the currently playing track. Note: This might be different to the current playlist! */
Tomahawk::PlaylistInterface* currentTrackPlaylist() const { return m_currentTrackPlaylist; }
PlaylistInterface* currentTrackPlaylist() const { return m_currentTrackPlaylist; }
/* Returns the PlaylistInterface of the current playlist. Note: The currently playing track might still be from a different playlist! */
Tomahawk::PlaylistInterface* playlist() const { return m_playlist; }
PlaylistInterface* playlist() const { return m_playlist; }
Tomahawk::result_ptr currentTrack() const { return m_currentTrack; }
public slots:
void playPause();
void play();
@@ -76,20 +68,15 @@ public slots:
void setVolume( int percentage );
void lowerVolume() { setVolume( volume() - AUDIO_VOLUME_STEP ); }
void raiseVolume() { setVolume( volume() + AUDIO_VOLUME_STEP ); }
void onVolumeChanged( qreal volume ) { emit volumeChanged( volume * 100 ); }
void onVolumeChanged( float volume ) { emit volumeChanged( volume * 100 ); }
void mute();
void playItem( Tomahawk::PlaylistInterface* playlist, const Tomahawk::result_ptr& result );
void setPlaylist( Tomahawk::PlaylistInterface* playlist );
void setQueue( Tomahawk::PlaylistInterface* queue ) { m_queue = queue; }
void playItem( PlaylistInterface* playlist, const Tomahawk::result_ptr& result );
void setPlaylist( PlaylistInterface* playlist );
void setQueue( PlaylistInterface* queue ) { m_queue = queue; }
void onTrackAboutToFinish();
void playlistNextTrackReady();
void infoSystemInfo( Tomahawk::InfoSystem::InfoRequestData requestData, QVariant output );
void infoSystemFinished( QString caller );
signals:
void loading( const Tomahawk::result_ptr& track );
void started( const Tomahawk::result_ptr& track );
@@ -104,7 +91,7 @@ signals:
void timerSeconds( unsigned int secondsElapsed );
void timerPercentage( unsigned int percentage );
void playlistChanged( Tomahawk::PlaylistInterface* playlist );
void playlistChanged( PlaylistInterface* playlist );
void error( AudioErrorCode errorCode );
@@ -113,7 +100,6 @@ private slots:
void loadPreviousTrack();
void loadNextTrack();
void onAboutToFinish();
void onStateChanged( Phonon::State newState, Phonon::State oldState );
void timerTriggered( qint64 time );
@@ -122,25 +108,21 @@ private slots:
private:
bool isHttpResult( const QString& ) const;
bool isLocalResult( const QString& ) const;
void sendWaitingNotification() const;
void sendNowPlayingNotification();
bool m_isPlayingHttp;
QSharedPointer<QIODevice> m_input;
Tomahawk::result_ptr m_currentTrack;
Tomahawk::result_ptr m_lastTrack;
Tomahawk::PlaylistInterface* m_playlist;
Tomahawk::PlaylistInterface* m_currentTrackPlaylist;
Tomahawk::PlaylistInterface* m_queue;
PlaylistInterface* m_playlist;
PlaylistInterface* m_currentTrackPlaylist;
PlaylistInterface* m_queue;
Phonon::MediaObject* m_mediaObject;
Phonon::AudioOutput* m_audioOutput;
unsigned int m_timeElapsed;
bool m_expectStop;
bool m_waitingOnNewTrack;
bool m_infoSystemConnected;
static AudioEngine* s_instance;
};

View File

@@ -16,32 +16,49 @@
* along with Tomahawk. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef HEADERLABEL_H
#define HEADERLABEL_H
#include "dummytranscode.h"
#include <QLabel>
#include <QDebug>
#include "dllmacro.h"
class DLLEXPORT HeaderLabel : public QLabel
DummyTranscode::DummyTranscode()
: m_init( false )
{
Q_OBJECT
qDebug() << Q_FUNC_INFO;
}
public:
HeaderLabel( QWidget* parent );
~HeaderLabel();
QSize minimumSizeHint() const { return sizeHint(); }
QSize sizeHint() const;
DummyTranscode::~DummyTranscode()
{
qDebug() << Q_FUNC_INFO;
}
public slots:
protected:
// void changeEvent( QEvent* e );
void paintEvent( QPaintEvent* event );
void
DummyTranscode::processData( const QByteArray &buffer, bool finish )
{
Q_UNUSED( finish );
m_buffer.append( buffer );
// qDebug() << "DUMMYTRANSCODING:" << buffer.size();
private:
QWidget* m_parent;
};
if( !m_init && m_buffer.size() >= 16364 ) {
m_init = true;
emit streamInitialized( 44100, 2 );
}
}
void
DummyTranscode::onSeek( int seconds )
{
Q_UNUSED( seconds );
m_buffer.clear();
}
void
DummyTranscode::clearBuffers()
{
m_buffer.clear();
m_init = false;
}
#endif // HEADERLABEL_H

View File

@@ -0,0 +1,63 @@
/*
<one line to give the program's name and a brief idea of what it does.>
Copyright (C) 2011 Leo Franchi <leo@kdab.com>
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef DUMMYTRANSCODE_H
#define DUMMYTRANSCODE_H
#include "audio/transcodeinterface.h"
#include "dllmacro.h"
#define _BUFFER_PREFERRED 32768
class DLLEXPORT DummyTranscode : public TranscodeInterface
{
Q_OBJECT
public:
DummyTranscode();
virtual ~DummyTranscode();
const QStringList supportedTypes() const { QStringList l; l << "audio/basic"; return l; }
int needData() { return true; } // always eats data
bool haveData() { return !m_buffer.isEmpty(); }
unsigned int preferredDataSize() { return _BUFFER_PREFERRED; }
QByteArray data() { QByteArray b = m_buffer; m_buffer.clear(); return b; }
virtual void setBufferCapacity( int bytes ) { m_bufferCapacity = bytes; }
int bufferSize() { return m_buffer.size(); }
public slots:
virtual void clearBuffers();
virtual void onSeek( int seconds );
virtual void processData( const QByteArray& data, bool finish );
signals:
void streamInitialized( long sampleRate, int channels );
void timeChanged( int seconds );
private:
QByteArray m_buffer;
int m_bufferCapacity;
bool m_init;
};
#endif // DUMMYTRANSCODE_H

View File

@@ -242,9 +242,8 @@ Collection::delTracks( const QStringList& files )
int i = 0;
foreach ( const query_ptr& query, m_tracks )
{
foreach ( const QString& file, files )
foreach ( QString file, files )
{
bool found = false;
foreach ( const result_ptr& result, query->results() )
{
if ( file == result->url() )
@@ -252,13 +251,8 @@ Collection::delTracks( const QStringList& files )
// qDebug() << Q_FUNC_INFO << "Found deleted result:" << file;
tracks << query;
m_tracks.removeAt( i );
i--;
found = true;
break;
}
}
if ( found )
break;
}
i++;

View File

@@ -1,218 +0,0 @@
/* === This file is part of Tomahawk Player - <http://tomahawk-player.org> ===
*
* Copyright 2010-2011, Christian Muehlhaeuser <muesli@tomahawk-player.org>
*
* Tomahawk is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Tomahawk is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Tomahawk. If not, see <http://www.gnu.org/licenses/>.
*/
#include "contextMenu.h"
#include <QDebug>
#include "globalactionmanager.h"
#include "playlistview.h"
#include "viewmanager.h"
using namespace Tomahawk;
ContextMenu::ContextMenu( QWidget* parent )
: QMenu( parent )
{
m_sigmap = new QSignalMapper( this );
connect( m_sigmap, SIGNAL( mapped( int ) ), SLOT( onTriggered( int ) ) );
m_supportedActions = ActionPlay | ActionQueue | ActionCopyLink;
}
void
ContextMenu::clear()
{
QMenu::clear();
m_queries.clear();
m_albums.clear();
m_artists.clear();
}
void
ContextMenu::setQueries( const QList<Tomahawk::query_ptr>& queries )
{
if ( queries.isEmpty() )
return;
QMenu::clear();
m_queries.clear();
m_queries << queries;
if ( m_supportedActions & ActionPlay && itemCount() == 1 )
m_sigmap->setMapping( addAction( tr( "&Play" ) ), ActionPlay );
if ( m_supportedActions & ActionQueue )
m_sigmap->setMapping( addAction( tr( "Add to &Queue" ) ), ActionQueue );
//m_sigmap->setMapping( addAction( tr( "&Add to Playlist" ) ), ActionAddToPlaylist );
addSeparator();
if ( m_supportedActions & ActionCopyLink && itemCount() == 1 )
m_sigmap->setMapping( addAction( tr( "Copy Track &Link" ) ), ActionCopyLink );
addSeparator();
if ( m_supportedActions & ActionDelete )
m_sigmap->setMapping( addAction( queries.count() > 1 ? tr( "&Delete Items" ) : tr( "&Delete Item" ) ), ActionDelete );
foreach ( QAction* action, actions() )
{
connect( action, SIGNAL( triggered() ), m_sigmap, SLOT( map() ) );
}
}
void
ContextMenu::setQuery( const Tomahawk::query_ptr& query )
{
QList<query_ptr> queries;
queries << query;
setQueries( queries );
}
void
ContextMenu::setAlbums( const QList<Tomahawk::album_ptr>& albums )
{
if ( albums.isEmpty() )
return;
QMenu::clear();
m_albums.clear();
m_albums << albums;
if ( m_supportedActions & ActionPlay && itemCount() == 1 )
m_sigmap->setMapping( addAction( tr( "&Play" ) ), ActionPlay );
if ( m_supportedActions & ActionQueue )
m_sigmap->setMapping( addAction( tr( "Add to &Queue" ) ), ActionQueue );
//m_sigmap->setMapping( addAction( tr( "&Add to Playlist" ) ), ActionAddToPlaylist );
addSeparator();
/* if ( m_supportedActions & ActionCopyLink && itemCount() == 1 )
m_sigmap->setMapping( addAction( tr( "Copy Album &Link" ) ), ActionCopyLink ); */
foreach ( QAction* action, actions() )
{
connect( action, SIGNAL( triggered() ), m_sigmap, SLOT( map() ) );
}
}
void
ContextMenu::setAlbum( const Tomahawk::album_ptr& album )
{
QList<album_ptr> albums;
albums << album;
setAlbums( albums );
}
void
ContextMenu::setArtists( const QList<Tomahawk::artist_ptr>& artists )
{
if ( artists.isEmpty() )
return;
QMenu::clear();
m_artists.clear();
m_artists << artists;
if ( m_supportedActions & ActionPlay && itemCount() == 1 )
m_sigmap->setMapping( addAction( tr( "&Play" ) ), ActionPlay );
if ( m_supportedActions & ActionQueue )
m_sigmap->setMapping( addAction( tr( "Add to &Queue" ) ), ActionQueue );
//m_sigmap->setMapping( addAction( tr( "&Add to Playlist" ) ), ActionAddToPlaylist );
addSeparator();
/* if ( m_supportedActions & ActionCopyLink && itemCount() == 1 )
m_sigmap->setMapping( addAction( tr( "Copy Artist &Link" ) ), ActionCopyLink ); */
foreach ( QAction* action, actions() )
{
connect( action, SIGNAL( triggered() ), m_sigmap, SLOT( map() ) );
}
}
void
ContextMenu::setArtist( const Tomahawk::artist_ptr& artist )
{
QList<artist_ptr> artists;
artists << artist;
setArtists( artists );
}
void
ContextMenu::onTriggered( int action )
{
switch ( action )
{
case ActionQueue:
addToQueue();
break;
case ActionCopyLink:
copyLink();
break;
default:
emit triggered( action );
}
}
void ContextMenu::addToQueue()
{
foreach ( const query_ptr& query, m_queries )
{
ViewManager::instance()->queue()->model()->append( query );
}
foreach ( const artist_ptr& artist, m_artists )
{
ViewManager::instance()->queue()->model()->append( artist );
}
foreach ( const album_ptr& album, m_albums )
{
ViewManager::instance()->queue()->model()->append( album );
}
ViewManager::instance()->showQueue();
}
void
ContextMenu::copyLink()
{
if ( m_queries.count() )
{
GlobalActionManager::instance()->copyToClipboard( m_queries.first() );
}
}

View File

@@ -1,78 +0,0 @@
/* === This file is part of Tomahawk Player - <http://tomahawk-player.org> ===
*
* Copyright 2010-2011, Christian Muehlhaeuser <muesli@tomahawk-player.org>
*
* Tomahawk is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Tomahawk is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Tomahawk. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef CONTEXTMENU_H
#define CONTEXTMENU_H
#include <QSignalMapper>
#include <QMenu>
#include "typedefs.h"
#include "dllmacro.h"
namespace Tomahawk
{
class DLLEXPORT ContextMenu : public QMenu
{
Q_OBJECT
public:
enum MenuActions
{ ActionPlay = 1, ActionQueue = 2, ActionDelete = 4, ActionCopyLink = 8 };
explicit ContextMenu( QWidget* parent = 0 );
int supportedActions() const { return m_supportedActions; }
void setSupportedActions( int actions ) { m_supportedActions = actions; }
void setQuery( const Tomahawk::query_ptr& query );
void setQueries( const QList<Tomahawk::query_ptr>& queries );
void setArtist( const Tomahawk::artist_ptr& artist );
void setArtists( const QList<Tomahawk::artist_ptr>& artists );
void setAlbum( const Tomahawk::album_ptr& album );
void setAlbums( const QList<Tomahawk::album_ptr>& albums );
void clear();
unsigned int itemCount() const { return m_queries.count() + m_artists.count() + m_albums.count(); }
signals:
void triggered( int action );
private slots:
void onTriggered( int action );
void copyLink();
void addToQueue();
private:
QSignalMapper* m_sigmap;
int m_supportedActions;
QList<Tomahawk::query_ptr> m_queries;
QList<Tomahawk::artist_ptr> m_artists;
QList<Tomahawk::album_ptr> m_albums;
};
}; // ns
#endif

View File

@@ -1,5 +1,5 @@
/* === This file is part of Tomahawk Player - <http://tomahawk-player.org> ===
*
*
* Copyright 2010-2011, Christian Muehlhaeuser <muesli@tomahawk-player.org>
*
* Tomahawk is free software: you can redistribute it and/or modify
@@ -18,8 +18,7 @@
#include "database.h"
#define DEFAULT_WORKER_THREADS 4
#define MAX_WORKER_THREADS 16
#define WORKER_THREADS 5
Database* Database::s_instance = 0;
@@ -39,9 +38,6 @@ Database::Database( const QString& dbname, QObject* parent )
{
s_instance = this;
m_maxConcurrentThreads = qBound( DEFAULT_WORKER_THREADS, QThread::idealThreadCount(), MAX_WORKER_THREADS );
qDebug() << Q_FUNC_INFO << "Using" << m_maxConcurrentThreads << "threads";
connect( m_impl, SIGNAL( indexReady() ), SIGNAL( indexReady() ) );
connect( m_impl, SIGNAL( indexReady() ), SIGNAL( ready() ) );
connect( m_impl, SIGNAL( indexReady() ), SLOT( setIsReadyTrue() ) );
@@ -70,8 +66,9 @@ Database::loadIndex()
void
Database::enqueue( QSharedPointer<DatabaseCommand> lc )
{
if ( lc->doesMutates() )
if( lc->doesMutates() )
{
//qDebug() << Q_FUNC_INFO << "RW" << lc->commandname();
qDebug() << "Enqueueing command to rw thread:" << lc->commandname();
m_workerRW->enqueue( lc );
}
@@ -79,20 +76,21 @@ Database::enqueue( QSharedPointer<DatabaseCommand> lc )
{
// find existing amount of worker threads for commandname
// create new thread if < WORKER_THREADS
if ( m_workers.count() < m_maxConcurrentThreads )
if ( m_workers.count( lc->commandname() ) < WORKER_THREADS )
{
DatabaseWorker* worker = new DatabaseWorker( m_impl, this, false );
worker->start();
m_workers << worker;
m_workers.insertMulti( lc->commandname(), worker );
}
// find thread for commandname with lowest amount of outstanding jobs and enqueue job
int busyThreads = 0;
DatabaseWorker* happyThread = 0;
for ( int i = 0; i < m_workers.count(); i++ )
QList< DatabaseWorker* > workers = m_workers.values( lc->commandname() );
for ( int i = 0; i < workers.count(); i++ )
{
DatabaseWorker* worker = m_workers.at( i );
DatabaseWorker* worker = workers.at( i );
if ( !worker->busy() )
{

View File

@@ -1,5 +1,5 @@
/* === This file is part of Tomahawk Player - <http://tomahawk-player.org> ===
*
*
* Copyright 2010-2011, Christian Muehlhaeuser <muesli@tomahawk-player.org>
*
* Tomahawk is free software: you can redistribute it and/or modify
@@ -52,7 +52,7 @@ public:
bool indexReady() const { return m_indexReady; }
void loadIndex();
bool isReady() const { return m_ready; }
signals:
@@ -67,20 +67,15 @@ public slots:
private slots:
void setIsReadyTrue() { m_ready = true; }
private:
DatabaseImpl* impl() const { return m_impl; }
bool m_ready;
DatabaseImpl* m_impl;
DatabaseWorker* m_workerRW;
QList<DatabaseWorker*> m_workers;
QHash< QString, DatabaseWorker* > m_workers;
bool m_indexReady;
int m_maxConcurrentThreads;
static Database* s_instance;
friend class Tomahawk::Artist;
};
#endif // DATABASE_H

View File

@@ -1,5 +1,5 @@
/* === This file is part of Tomahawk Player - <http://tomahawk-player.org> ===
*
*
* Copyright 2010-2011, Christian Muehlhaeuser <muesli@tomahawk-player.org>
*
* Tomahawk is free software: you can redistribute it and/or modify
@@ -30,8 +30,6 @@
#include "databasecommand_createdynamicplaylist.h"
#include "databasecommand_deletedynamicplaylist.h"
#include "databasecommand_setdynamicplaylistrevision.h"
#include "databasecommand_socialaction.h"
#include "databasecommand_loadsocialactions.h"
DatabaseCommand::DatabaseCommand( QObject* parent )
@@ -53,7 +51,7 @@ DatabaseCommand::DatabaseCommand( const source_ptr& src, QObject* parent )
DatabaseCommand::~DatabaseCommand()
{
// qDebug() << Q_FUNC_INFO;
//qDebug() << Q_FUNC_INFO;
}
@@ -128,7 +126,7 @@ DatabaseCommand::factory( const QVariant& op, const source_ptr& source )
cmd->setSource( source );
QJson::QObjectHelper::qvariant2qobject( op.toMap(), cmd );
return cmd;
}
}
else if( name == "deletedynamicplaylist" )
{
DatabaseCommand_DeleteDynamicPlaylist * cmd = new DatabaseCommand_DeleteDynamicPlaylist;
@@ -144,13 +142,6 @@ DatabaseCommand::factory( const QVariant& op, const source_ptr& source )
QJson::QObjectHelper::qvariant2qobject( op.toMap(), cmd );
return cmd;
}
else if( name == "socialaction" )
{
DatabaseCommand_SocialAction * cmd = new DatabaseCommand_SocialAction;
cmd->setSource( source );
QJson::QObjectHelper::qvariant2qobject( op.toMap(), cmd );
return cmd;
}
qDebug() << "ERROR in" << Q_FUNC_INFO << name;
// Q_ASSERT( false );

View File

@@ -1,5 +1,5 @@
/* === This file is part of Tomahawk Player - <http://tomahawk-player.org> ===
*
*
* Copyright 2010-2011, Christian Muehlhaeuser <muesli@tomahawk-player.org>
*
* Tomahawk is free software: you can redistribute it and/or modify
@@ -69,6 +69,12 @@ DatabaseCommand_AddFiles::postCommitHook()
emit notify( m_queries );
// also re-calc the collection stats, to updates the "X tracks" in the sidebar etc:
DatabaseCommand_CollectionStats* cmd = new DatabaseCommand_CollectionStats( source() );
connect( cmd, SIGNAL( done( QVariantMap ) ),
source().data(), SLOT( setStats( QVariantMap ) ), Qt::QueuedConnection );
Database::instance()->enqueue( QSharedPointer<DatabaseCommand>( cmd ) );
if( source()->isLocal() )
Servent::instance()->triggerDBSync();
}
@@ -148,16 +154,14 @@ DatabaseCommand_AddFiles::exec( DatabaseImpl* dbi )
if( !source()->isLocal() )
url = QString( "servent://%1\t%2" ).arg( source()->userName() ).arg( url );
bool autoCreate = true;
artistid = dbi->artistId( artist, autoCreate );
bool isnew;
artistid = dbi->artistId( artist, isnew );
if ( artistid < 1 )
continue;
autoCreate = true; // artistId overwrites autoCreate (reference)
trackid = dbi->trackId( artistid, track, autoCreate );
trackid = dbi->trackId( artistid, track, isnew );
if ( trackid < 1 )
continue;
autoCreate = true; // trackId overwrites autoCreate (reference)
albumid = dbi->albumId( artistid, album, autoCreate );
albumid = dbi->albumId( artistid, album, isnew );
// Now add the association
query_filejoin.bindValue( 0, fileid );

View File

@@ -84,7 +84,7 @@ DatabaseCommand_AllAlbums::execForCollection( DatabaseImpl* dbi )
{
TomahawkSqlQuery query = dbi->newquery();
QList<Tomahawk::album_ptr> al;
QString orderToken, sourceToken;
QString orderToken;
switch ( m_sortOrder )
{
@@ -95,9 +95,6 @@ DatabaseCommand_AllAlbums::execForCollection( DatabaseImpl* dbi )
orderToken = "file.mtime";
}
if ( !m_collection.isNull() )
sourceToken = QString( "AND file.source %1 " ).arg( m_collection->source()->isLocal() ? "IS NULL" : QString( "= %1" ).arg( m_collection->source()->id() ) );
QString sql = QString(
"SELECT DISTINCT album.id, album.name, album.artist, artist.name "
"FROM album, file, file_join "
@@ -105,9 +102,9 @@ DatabaseCommand_AllAlbums::execForCollection( DatabaseImpl* dbi )
"ON album.artist = artist.id "
"WHERE file.id = file_join.file "
"AND file_join.album = album.id "
"%1 "
"AND file.source %1 "
"%2 %3 %4"
).arg( sourceToken )
).arg( m_collection->source()->isLocal() ? "IS NULL" : QString( "= %1" ).arg( m_collection->source()->id() ) )
.arg( m_sortOrder > 0 ? QString( "ORDER BY %1" ).arg( orderToken ) : QString() )
.arg( m_sortDescending ? "DESC" : QString() )
.arg( m_amount > 0 ? QString( "LIMIT 0, %1" ).arg( m_amount ) : QString() );

View File

@@ -35,7 +35,7 @@ using namespace Tomahawk;
void
DatabaseCommand_DeleteFiles::postCommitHook()
{
// qDebug() << Q_FUNC_INFO;
qDebug() << Q_FUNC_INFO;
if ( !m_files.count() )
return;
@@ -49,6 +49,12 @@ DatabaseCommand_DeleteFiles::postCommitHook()
emit notify( m_files );
// also re-calc the collection stats, to updates the "X tracks" in the sidebar etc:
DatabaseCommand_CollectionStats* cmd = new DatabaseCommand_CollectionStats( source() );
connect( cmd, SIGNAL( done( QVariantMap ) ),
source().data(), SLOT( setStats( QVariantMap ) ), Qt::QueuedConnection );
Database::instance()->enqueue( QSharedPointer<DatabaseCommand>( cmd ) );
if( source()->isLocal() )
Servent::instance()->triggerDBSync();
}
@@ -57,7 +63,7 @@ DatabaseCommand_DeleteFiles::postCommitHook()
void
DatabaseCommand_DeleteFiles::exec( DatabaseImpl* dbi )
{
// qDebug() << Q_FUNC_INFO;
qDebug() << Q_FUNC_INFO;
Q_ASSERT( !source().isNull() );
int deleted = 0;
@@ -116,7 +122,7 @@ DatabaseCommand_DeleteFiles::exec( DatabaseImpl* dbi )
foreach( const QVariant& id, m_ids )
{
// qDebug() << "Deleting" << id.toUInt() << "from db for source" << srcid;
qDebug() << "Deleting" << id.toUInt() << "from db for source" << srcid;
const QString url = QString( "servent://%1\t%2" ).arg( source()->userName() ).arg( id.toString() );
m_files << url;
@@ -135,7 +141,7 @@ DatabaseCommand_DeleteFiles::exec( DatabaseImpl* dbi )
}
}
// qDebug() << "Deleted" << deleted << m_ids << m_files;
qDebug() << "Deleted" << deleted << m_ids << m_files;
emit done( m_files, source()->collection() );
}

View File

@@ -39,11 +39,7 @@ DatabaseCommand_DirMtimes::execSelect( DatabaseImpl* dbi )
QMap<QString,unsigned int> mtimes;
TomahawkSqlQuery query = dbi->newquery();
if( m_prefix.isEmpty() && m_prefixes.isEmpty() )
{
query.exec( "SELECT name, mtime FROM dirs_scanned" );
while( query.next() )
mtimes.insert( query.value( 0 ).toString(), query.value( 1 ).toUInt() );
}
else if( m_prefixes.isEmpty() )
execSelectPath( dbi, m_prefix, mtimes );
else
@@ -68,7 +64,9 @@ DatabaseCommand_DirMtimes::execSelectPath( DatabaseImpl *dbi, const QDir& path,
query.exec();
while( query.next() )
{
mtimes.insert( query.value( 0 ).toString(), query.value( 1 ).toUInt() );
}
}

View File

@@ -38,7 +38,7 @@ public:
: DatabaseCommand( parent ), m_prefix( prefix ), m_update( false )
{}
explicit DatabaseCommand_DirMtimes( const QStringList& prefixes, QObject* parent = 0 )
explicit DatabaseCommand_DirMtimes( const QStringList& prefixes = QStringList(), QObject* parent = 0 )
: DatabaseCommand( parent ), m_prefixes( prefixes ), m_update( false )
{}

View File

@@ -1,80 +0,0 @@
/* === This file is part of Tomahawk Player - <http://tomahawk-player.org> ===
*
* Copyright 2010-2011, Christian Muehlhaeuser <muesli@tomahawk-player.org>
*
* Tomahawk is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Tomahawk is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Tomahawk. If not, see <http://www.gnu.org/licenses/>.
*/
#include "databasecommand_filemtimes.h"
#include <QSqlQuery>
#include "databaseimpl.h"
void
DatabaseCommand_FileMtimes::exec( DatabaseImpl* dbi )
{
execSelect( dbi );
}
void
DatabaseCommand_FileMtimes::execSelect( DatabaseImpl* dbi )
{
qDebug() << Q_FUNC_INFO;
//FIXME: If ever needed for a non-local source this will have to be fixed/updated
QMap< QString, QMap< unsigned int, unsigned int > > mtimes;
TomahawkSqlQuery query = dbi->newquery();
if( m_prefix.isEmpty() && m_prefixes.isEmpty() )
{
query.exec( "SELECT url, id, mtime FROM file WHERE source IS NULL" );
while( query.next() )
{
QMap< unsigned int, unsigned int > map;
map.insert( query.value( 1 ).toUInt(), query.value( 2 ).toUInt() );
mtimes.insert( query.value( 0 ).toString(), map );
}
}
else if( m_prefixes.isEmpty() )
execSelectPath( dbi, m_prefix, mtimes );
else
{
if( !m_prefix.isEmpty() )
execSelectPath( dbi, m_prefix, mtimes );
foreach( QString path, m_prefixes )
execSelectPath( dbi, path, mtimes );
}
emit done( mtimes );
}
void
DatabaseCommand_FileMtimes::execSelectPath( DatabaseImpl *dbi, const QDir& path, QMap<QString, QMap< unsigned int, unsigned int > > &mtimes )
{
TomahawkSqlQuery query = dbi->newquery();
query.prepare( QString( "SELECT url, id, mtime "
"FROM file "
"WHERE source IS NULL "
"AND url LIKE :prefix" ) );
query.bindValue( ":prefix", "file://" + path.canonicalPath() + "%" );
query.exec();
while( query.next() )
{
QMap< unsigned int, unsigned int > map;
map.insert( query.value( 1 ).toUInt(), query.value( 2 ).toUInt() );
mtimes.insert( query.value( 0 ).toString(), map );
}
}

View File

@@ -1,61 +0,0 @@
/* === This file is part of Tomahawk Player - <http://tomahawk-player.org> ===
*
* Copyright 2010-2011, Christian Muehlhaeuser <muesli@tomahawk-player.org>
*
* Tomahawk is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Tomahawk is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Tomahawk. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef DATABASECOMMAND_FILEMTIMES_H
#define DATABASECOMMAND_FILEMTIMES_H
#include <QObject>
#include <QVariantMap>
#include <QMap>
#include "databasecommand.h"
#include "dllmacro.h"
// Not loggable, mtimes only used to speed up our local scanner.
class DLLEXPORT DatabaseCommand_FileMtimes : public DatabaseCommand
{
Q_OBJECT
public:
explicit DatabaseCommand_FileMtimes( const QString& prefix = QString(), QObject* parent = 0 )
: DatabaseCommand( parent ), m_prefix( prefix )
{}
explicit DatabaseCommand_FileMtimes( const QStringList& prefixes, QObject* parent = 0 )
: DatabaseCommand( parent ), m_prefixes( prefixes )
{}
virtual void exec( DatabaseImpl* );
virtual bool doesMutates() const { return false; }
virtual QString commandname() const { return "filemtimes"; }
signals:
void done( const QMap< QString, QMap< unsigned int, unsigned int > >& );
public slots:
private:
void execSelectPath( DatabaseImpl *dbi, const QDir& path, QMap< QString, QMap< unsigned int, unsigned int > > &mtimes );
void execSelect( DatabaseImpl* dbi );
QString m_prefix;
QStringList m_prefixes;
};
#endif // DATABASECOMMAND_FILEMTIMES_H

View File

@@ -1,75 +0,0 @@
/* === This file is part of Tomahawk Player - <http://tomahawk-player.org> ===
*
* Copyright 2010-2011, Christopher Reichert <creichert07@gmail.com>
*
* Tomahawk is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Tomahawk is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Tomahawk. If not, see <http://www.gnu.org/licenses/>.
*/
#include "databasecommand_loadsocialactions.h"
#include <QSqlQuery>
#include "database/database.h"
#include "databaseimpl.h"
#include "network/servent.h"
#include "result.h"
using namespace Tomahawk;
void
DatabaseCommand_LoadSocialActions::exec( DatabaseImpl* dbi )
{
qDebug() << Q_FUNC_INFO;
Q_ASSERT( !source().isNull() );
TomahawkSqlQuery query = dbi->newquery();
QVariant srcid = source()->isLocal() ? QVariant( QVariant::Int ) : source()->id();
bool autoCreate = true;
int artid = dbi->artistId( m_artist, autoCreate );
if( artid < 1 )
return;
autoCreate = true; // artistId overwrites autoCreate (reference)
int trkid = dbi->trackId( artid, m_track, autoCreate );
if( trkid < 1 )
return;
QString whereToken;
whereToken = QString( "WHERE id IS %1" ).arg( trkid );
QString sql = QString(
"SELECT k, v, timestamp, source "
"FROM social_attributes %1 "
"ORDER BY timestamp ASC" ).arg( whereToken );
query.prepare( sql );
query.exec();
QList< Tomahawk::SocialAction > allSocialActions;
while ( query.next() ) {
Tomahawk::SocialAction action;
action.action = query.value( 0 ); // action
action.value = query.value( 1 ); // comment
action.timestamp = query.value( 2 ); // timestamp
action.source = query.value( 3 ); // source
allSocialActions.append( action );
}
m_result->setAllSocialActions( allSocialActions );
}

View File

@@ -1,73 +0,0 @@
/* === This file is part of Tomahawk Player - <http://tomahawk-player.org> ===
*
* Copyright 2011, Christopher Reichert <creichert07@gmail.com>
*
* Tomahawk is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Tomahawk is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Tomahawk. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef DATABASECOMMAND_LOADSOCIALACTIONS_H
#define DATABASECOMMAND_LOADSOCIALACTIONS_H
#include <QDateTime>
#include <QList>
#include "database/databasecommand.h"
#include "sourcelist.h"
#include "typedefs.h"
#include "artist.h"
#include "result.h"
#include "dllmacro.h"
class DLLEXPORT DatabaseCommand_LoadSocialActions : public DatabaseCommand
{
Q_OBJECT
public:
explicit DatabaseCommand_LoadSocialActions( QObject* parent = 0 )
: DatabaseCommand( parent )
{}
explicit DatabaseCommand_LoadSocialActions( Tomahawk::Result* result, QObject* parent = 0 )
: DatabaseCommand( parent ), m_result( result )
{
setSource( SourceList::instance()->getLocal() );
setArtist( result->artist()->name() );
setTrack( result->track() );
}
virtual QString commandname() const { return "loadsocialactions"; }
virtual void exec( DatabaseImpl* );
QString artist() const { return m_artist; }
void setArtist( const QString& s ) { m_artist = s; }
QString track() const { return m_track; }
void setTrack( const QString& s ) { m_track = s; }
signals:
void done( QList< Tomahawk::SocialAction >& allSocialActions );
private:
Tomahawk::Result* m_result;
QString m_artist;
QString m_track;
};
#endif // DATABASECOMMAND_LOADSOCIALACTIONS_H

View File

@@ -40,14 +40,12 @@ DatabaseCommand_LogPlayback::postCommitHook()
// do not auto resolve this track
Tomahawk::query_ptr q = Tomahawk::Query::get( m_artist, m_track, QString() );
q->setPlayedBy( source(), m_playtime );
if ( m_action == Finished )
{
emit trackPlayed( q );
}
// if the play time is more than 10 minutes in the past, ignore
else if ( m_action == Started && QDateTime::fromTime_t( playtime() ).secsTo( QDateTime::currentDateTime() ) < 600 )
else if ( m_action == Started && QDateTime::fromTime_t( playtime() ).secsTo( QDateTime::currentDateTime() ) < 600 ) // if the play time is more than 10 minutes in the past, ignore
{
emit trackPlaying( q );
}
@@ -80,13 +78,12 @@ DatabaseCommand_LogPlayback::exec( DatabaseImpl* dbi )
query.bindValue( 0, srcid );
bool autoCreate = true;
int artid = dbi->artistId( m_artist, autoCreate );
bool isnew;
int artid = dbi->artistId( m_artist, isnew );
if( artid < 1 )
return;
autoCreate = true; // artistId overwrites autoCreate (reference)
int trkid = dbi->trackId( artid, m_track, autoCreate );
int trkid = dbi->trackId( artid, m_track, isnew );
if( trkid < 1 )
return;

View File

@@ -1,5 +1,5 @@
/* === This file is part of Tomahawk Player - <http://tomahawk-player.org> ===
*
*
* Copyright 2010-2011, Christian Muehlhaeuser <muesli@tomahawk-player.org>
*
* Tomahawk is free software: you can redistribute it and/or modify
@@ -21,7 +21,6 @@
#include <QSqlQuery>
#include "databaseimpl.h"
#include "sourcelist.h"
void
@@ -37,7 +36,7 @@ DatabaseCommand_PlaybackHistory::exec( DatabaseImpl* dbi )
}
QString sql = QString(
"SELECT track, playtime, secs_played, source "
"SELECT track, playtime, secs_played "
"FROM playback_log "
"%1 "
"ORDER BY playtime DESC "
@@ -64,16 +63,6 @@ DatabaseCommand_PlaybackHistory::exec( DatabaseImpl* dbi )
if ( query_track.next() )
{
Tomahawk::query_ptr q = Tomahawk::Query::get( query_track.value( 1 ).toString(), query_track.value( 0 ).toString(), QString(), uuid() );
if ( query.value( 3 ).toUInt() == 0 )
{
q->setPlayedBy( SourceList::instance()->getLocal(), query.value( 1 ).toUInt() );
}
else
{
q->setPlayedBy( SourceList::instance()->get( query.value( 3 ).toUInt() ), query.value( 1 ).toUInt() );
}
ql << q;
}
}

View File

@@ -36,49 +36,38 @@ DatabaseCommand_Resolve::DatabaseCommand_Resolve( const query_ptr& query )
void
DatabaseCommand_Resolve::exec( DatabaseImpl* lib )
{
/*
* Resolving is a 2 stage process.
* 1) find list of trk/art/alb IDs that are reasonable matches to the metadata given
* 2) find files in database by permitted sources and calculate score, ignoring
* results that are less than MINSCORE
*/
QList<Tomahawk::result_ptr> res;
if ( !m_query->resultHint().isEmpty() )
{
qDebug() << "Using result-hint to speed up resolving:" << m_query->resultHint();
Tomahawk::result_ptr result = lib->resultFromHint( m_query );
/* qDebug() << "Result null:" << result.isNull();
* qDebug() << "Collection null:" << result->collection().isNull();
* qDebug() << "Source null:" << result->collection()->source().isNull();*/
/* qDebug() << "Result null:" << result.isNull();
qDebug() << "Collection null:" << result->collection().isNull();
qDebug() << "Source null:" << result->collection()->source().isNull();*/
if ( !result.isNull() && !result->collection().isNull() && result->collection()->source()->isOnline() )
{
QList<Tomahawk::result_ptr> res;
res << result;
emit results( m_query->id(), res );
return;
}
}
if ( m_query->isFullTextQuery() )
fullTextResolve( lib );
else
resolve( lib );
}
/*
Resolving is a 2 stage process.
1) find list of trk/art/alb IDs that are reasonable matches to the metadata given
2) find files in database by permitted sources and calculate score, ignoring
results that are less than MINSCORE
*/
void
DatabaseCommand_Resolve::resolve( DatabaseImpl* lib )
{
QList<Tomahawk::result_ptr> res;
typedef QPair<int, float> scorepair_t;
// STEP 1
QList< QPair<int, float> > artists = lib->searchTable( "artist", m_query->artist(), 10 );
QList< QPair<int, float> > tracks = lib->searchTable( "track", m_query->track(), 10 );
QList< QPair<int, float> > albums = lib->searchTable( "album", m_query->album(), 10 );
QList< int > artists = lib->searchTable( "artist", m_query->artist(), 10 );
QList< int > tracks = lib->searchTable( "track", m_query->track(), 10 );
QList< int > albums = lib->searchTable( "album", m_query->album(), 10 );
if ( artists.length() == 0 || tracks.length() == 0 )
if( artists.length() == 0 || tracks.length() == 0 )
{
qDebug() << "No candidates found in first pass, aborting resolve" << m_query->artist() << m_query->track();
emit results( m_query->id(), res );
@@ -89,13 +78,10 @@ DatabaseCommand_Resolve::resolve( DatabaseImpl* lib )
TomahawkSqlQuery files_query = lib->newquery();
QStringList artsl, trksl;
for ( int k = 0; k < artists.count(); k++ )
artsl.append( QString::number( artists.at( k ).first ) );
for ( int k = 0; k < tracks.count(); k++ )
trksl.append( QString::number( tracks.at( k ).first ) );
QString artsToken = QString( "file_join.artist IN (%1)" ).arg( artsl.join( "," ) );
QString trksToken = QString( "file_join.track IN (%1)" ).arg( trksl.join( "," ) );
foreach( int i, artists )
artsl.append( QString::number( i ) );
foreach( int i, tracks )
trksl.append( QString::number( i ) );
QString sql = QString( "SELECT "
"url, mtime, size, md5, mimetype, duration, bitrate, file_join.artist, file_join.album, file_join.track, "
@@ -112,9 +98,10 @@ DatabaseCommand_Resolve::resolve( DatabaseImpl* lib )
"artist.id = file_join.artist AND "
"track.id = file_join.track AND "
"file.id = file_join.file AND "
"(%1 AND %2)" )
.arg( artsToken )
.arg( trksToken );
"file_join.artist IN (%1) AND "
"file_join.track IN (%2)" )
.arg( artsl.join( "," ) )
.arg( trksl.join( "," ) );
files_query.prepare( sql );
files_query.exec();
@@ -173,7 +160,7 @@ DatabaseCommand_Resolve::resolve( DatabaseImpl* lib )
float score = how_similar( m_query, result );
result->setScore( score );
if ( score < MINSCORE )
if( score < MINSCORE )
continue;
result->setCollection( s->collection() );
@@ -184,129 +171,6 @@ DatabaseCommand_Resolve::resolve( DatabaseImpl* lib )
}
void
DatabaseCommand_Resolve::fullTextResolve( DatabaseImpl* lib )
{
QList<Tomahawk::result_ptr> res;
typedef QPair<int, float> scorepair_t;
// STEP 1
QList< QPair<int, float> > artists = lib->searchTable( "artist", m_query->fullTextQuery(), 10 );
QList< QPair<int, float> > tracks = lib->searchTable( "track", m_query->fullTextQuery(), 10 );
QList< QPair<int, float> > albums = lib->searchTable( "album", m_query->fullTextQuery(), 10 );
if ( artists.length() == 0 && tracks.length() == 0 && albums.length() == 0 )
{
qDebug() << "No candidates found in first pass, aborting resolve" << m_query->artist() << m_query->track();
emit results( m_query->id(), res );
return;
}
// STEP 2
TomahawkSqlQuery files_query = lib->newquery();
QStringList artsl, trksl, albsl;
for ( int k = 0; k < artists.count(); k++ )
artsl.append( QString::number( artists.at( k ).first ) );
for ( int k = 0; k < tracks.count(); k++ )
trksl.append( QString::number( tracks.at( k ).first ) );
for ( int k = 0; k < albums.count(); k++ )
albsl.append( QString::number( albums.at( k ).first ) );
QString artsToken = QString( "file_join.artist IN (%1)" ).arg( artsl.join( "," ) );
QString trksToken = QString( "file_join.track IN (%1)" ).arg( trksl.join( "," ) );
QString albsToken = QString( "file_join.album IN (%1)" ).arg( albsl.join( "," ) );
QString sql = QString( "SELECT "
"url, mtime, size, md5, mimetype, duration, bitrate, file_join.artist, file_join.album, file_join.track, "
"artist.name as artname, "
"album.name as albname, "
"track.name as trkname, "
"file.source, "
"file_join.albumpos, "
"artist.id as artid, "
"album.id as albid "
"FROM file, file_join, artist, track "
"LEFT JOIN album ON album.id = file_join.album "
"WHERE "
"artist.id = file_join.artist AND "
"track.id = file_join.track AND "
"file.id = file_join.file AND "
"%1" )
.arg( tracks.length() > 0 ? trksToken : QString( "0" ) );
files_query.prepare( sql );
files_query.exec();
while( files_query.next() )
{
Tomahawk::result_ptr result( new Tomahawk::Result() );
source_ptr s;
const QString url_str = files_query.value( 0 ).toString();
if( files_query.value( 13 ).toUInt() == 0 )
{
s = SourceList::instance()->getLocal();
result->setUrl( url_str );
}
else
{
s = SourceList::instance()->get( files_query.value( 13 ).toUInt() );
if( s.isNull() )
{
qDebug() << "WTF: Could not find source" << files_query.value( 13 ).toUInt();
continue;
}
result->setUrl( QString( "servent://%1\t%2" ).arg( s->userName() ).arg( url_str ) );
}
Tomahawk::artist_ptr artist = Tomahawk::Artist::get( files_query.value( 15 ).toUInt(), files_query.value( 10 ).toString() );
Tomahawk::album_ptr album = Tomahawk::Album::get( files_query.value( 16 ).toUInt(), files_query.value( 11 ).toString(), artist );
result->setModificationTime( files_query.value( 1 ).toUInt() );
result->setSize( files_query.value( 2 ).toUInt() );
result->setMimetype( files_query.value( 4 ).toString() );
result->setDuration( files_query.value( 5 ).toUInt() );
result->setBitrate( files_query.value( 6 ).toUInt() );
result->setArtist( artist );
result->setAlbum( album );
result->setTrack( files_query.value( 12 ).toString() );
result->setRID( uuid() );
result->setAlbumPos( files_query.value( 14 ).toUInt() );
result->setId( files_query.value( 9 ).toUInt() );
result->setYear( files_query.value( 17 ).toUInt() );
for ( int k = 0; k < tracks.count(); k++ )
{
if ( tracks.at( k ).first == (int)result->dbid() )
{
result->setScore( tracks.at( k ).second );
break;
}
}
TomahawkSqlQuery attrQuery = lib->newquery();
QVariantMap attr;
attrQuery.prepare( "SELECT k, v FROM track_attributes WHERE id = ?" );
attrQuery.bindValue( 0, result->dbid() );
attrQuery.exec();
while ( attrQuery.next() )
{
attr[ attrQuery.value( 0 ).toString() ] = attrQuery.value( 1 ).toString();
}
result->setAttributes( attr );
result->setCollection( s->collection() );
res << result;
}
emit results( m_query->id(), res );
}
// TODO make clever (ft. featuring live (stuff) etc)
float
DatabaseCommand_Resolve::how_similar( const Tomahawk::query_ptr& q, const Tomahawk::result_ptr& r )

View File

@@ -1,5 +1,5 @@
/* === This file is part of Tomahawk Player - <http://tomahawk-player.org> ===
*
*
* Copyright 2010-2011, Christian Muehlhaeuser <muesli@tomahawk-player.org>
*
* Tomahawk is free software: you can redistribute it and/or modify
@@ -44,9 +44,6 @@ signals:
public slots:
private:
void fullTextResolve( DatabaseImpl* lib );
void resolve( DatabaseImpl* lib );
Tomahawk::query_ptr m_query;
float how_similar( const Tomahawk::query_ptr& q, const Tomahawk::result_ptr& r );

View File

@@ -1,72 +0,0 @@
/* === This file is part of Tomahawk Player - <http://tomahawk-player.org> ===
*
* Copyright 2010-2011, Christopher Reichert <creichert07@gmail.com>
*
* Tomahawk is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Tomahawk is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Tomahawk. If not, see <http://www.gnu.org/licenses/>.
*/
#include "databasecommand_socialaction.h"
#include <QSqlQuery>
#include "database/database.h"
#include "databaseimpl.h"
#include "network/servent.h"
using namespace Tomahawk;
void
DatabaseCommand_SocialAction::postCommitHook()
{
qDebug() << Q_FUNC_INFO;
if ( source()->isLocal() )
{
Servent::instance()->triggerDBSync();
}
}
void
DatabaseCommand_SocialAction::exec( DatabaseImpl* dbi )
{
qDebug() << Q_FUNC_INFO;
Q_ASSERT( !source().isNull() );
TomahawkSqlQuery query = dbi->newquery();
query.prepare( "INSERT INTO social_attributes(id, source, k, v, timestamp) "
"VALUES (?, ?, ?, ?, ?)" );
QVariant srcid = source()->isLocal() ? QVariant( QVariant::Int ) : source()->id();
bool autoCreate = true;
int artid = dbi->artistId( m_artist, autoCreate );
if( artid < 1 )
return;
autoCreate = true; // artistId overwrites autoCreate (reference)
int trkid = dbi->trackId( artid, m_track, autoCreate );
if( trkid < 1 )
return;
query.bindValue( 0, trkid );
query.bindValue( 1, srcid );
query.bindValue( 2, m_action );
query.bindValue( 3, m_comment );
query.bindValue( 4, m_timestamp );
query.exec();
}

View File

@@ -1,180 +0,0 @@
/* === This file is part of Tomahawk Player - <http://tomahawk-player.org> ===
*
* Copyright 2011, Christopher Reichert <creichert07@gmail.com>
*
* Tomahawk is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Tomahawk is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Tomahawk. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef DATABASECOMMAND_SOCIALACTION_H
#define DATABASECOMMAND_SOCIALACTION_H
#include <QDateTime>
#include "database/databasecommand.h"
#include "sourcelist.h"
#include "typedefs.h"
#include "artist.h"
#include "dllmacro.h"
/**
* \class DatabaseCommand_SocialAction
* \brief Database command used to write social actions to database.
*
* This Database command allows Tomahawk to write social actions to
* the local database. These social actions can be interfaced with social
* networking API's such as LastFm, Facebook, or Twitter to allow the user
* to sync these actions with their accounts on these sites.
*
* \see DatabaseCommand_LoadSocialAction
*/
class DLLEXPORT DatabaseCommand_SocialAction : public DatabaseCommand
{
Q_OBJECT
Q_PROPERTY( QString action READ action WRITE setAction )
Q_PROPERTY( QString comment READ comment WRITE setComment )
Q_PROPERTY( int timestamp READ timestamp WRITE setTimestamp )
public:
/**
* \brief Default constructor for DatabaseCommand_SocialAction.
*
* Constructs an empty database command for a social action.
*/
explicit DatabaseCommand_SocialAction( QObject* parent = 0 )
: DatabaseCommand( parent )
{}
/**
* \brief Overloaded constructor for DatabaseCommand_SocialAction.
* \param result Pointer to a Tomahawk::Result.
* \param action Name of the social action to be written to the database.
* \param comment Comment associated with this social action.
* \param parent Parent class.
*
* Constructor which creates a new database command for the specified social action.
*/
explicit DatabaseCommand_SocialAction( const Tomahawk::result_ptr& result, QString action, QString comment="", QObject* parent = 0 )
: DatabaseCommand( parent ), m_result( result ), m_action( action )
{
setSource( SourceList::instance()->getLocal() );
setArtist( result->artist()->name() );
setTrack( result->track() );
setComment( comment );
setTimestamp( QDateTime::currentDateTime().toTime_t() );
}
/**
* \brief Returns the name of this database command.
* \return QString containing the database command name 'socialaction'.
*/
virtual QString commandname() const { return "socialaction"; }
/**
* \brief Executes the database command.
* \param dbi Database instance.
*
* This method prepares an sql query to write this social action
* into the local database.
*/
virtual void exec( DatabaseImpl* dbi );
/**
* \brief Triggers a Database Sync.
*/
virtual void postCommitHook();
/**
* \brief Returns the artist associated with this database command.
* \return Name of the artist.
* \see setArtist()
*/
QString artist() const { return m_artist; }
/**
* \brief Sets the artist name for this database command.
* \param s QString containing the artist name.
* \see artist()
*/
void setArtist( const QString& s ) { m_artist = s; }
/**
* \brief Returns the track name associated with this social action.
* \return QString containing the track name.
* \see setTrack()
*/
QString track() const { return m_track; }
/**
* \brief Sets the track name associated with this database command.
* \param track QString containing the track name.
* \see track()
*/
void setTrack( const QString& track ) { m_track = track; }
/**
* \brief Returns the social action for this database command instance.
* \return QString containing the action name.
* \see setAction()
*/
QString action() const { return m_action; }
/**
* \brief Sets the social actions
* \param a QString containing action to be set in this class.
* \see action()
*/
void setAction( QString a ) { m_action = a; }
/**
* \brief Returns comment associated with this social action.
* \return QString containing comment associated with this social action.
* \see setComment()
*/
QString comment() const { return m_comment; }
/**
* \brief Sets the comment associated with this social action.
* \param com Comment associated with this social action.
* \see comment()
*/
void setComment( const QString& com ) { m_comment = com; }
/**
* \brief Returns the timestamp associated with this social action.
* \return unsigned integer containing timestamp
* \see setTimesetamp()
*/
int timestamp() const { return m_timestamp; }
/**
* \brief Sets the timestamp associated with this social action.
* \param ts unsigned integer associated with this social action.
* \see timestamp()
*/
void setTimestamp( const int ts ) { m_timestamp = ts; }
private:
Tomahawk::result_ptr m_result;
QString m_artist;
QString m_track;
int m_timestamp;
QString m_comment;
QString m_action;
};
#endif // DATABASECOMMAND_SOCIALACTION_H

View File

@@ -38,7 +38,7 @@
*/
#include "schema.sql.h"
#define CURRENT_SCHEMA_VERSION 25
#define CURRENT_SCHEMA_VERSION 23
DatabaseImpl::DatabaseImpl( const QString& dbname, Database* parent )
@@ -47,48 +47,67 @@ DatabaseImpl::DatabaseImpl( const QString& dbname, Database* parent )
, m_lastalbid( 0 )
, m_lasttrkid( 0 )
{
bool schemaUpdated = false;
int version = getDatabaseVersion( dbname );
if ( version > 0 && version != CURRENT_SCHEMA_VERSION )
db = QSqlDatabase::addDatabase( "QSQLITE", "tomahawk" );
db.setDatabaseName( dbname );
if ( !db.open() )
{
QString newname = QString( "%1.v%2" ).arg( dbname ).arg( version );
qDebug() << endl << "****************************" << endl;
qDebug() << "Schema version too old: " << version << ". Current version is:" << CURRENT_SCHEMA_VERSION;
qDebug() << "Moving" << dbname << newname;
qDebug() << "If the migration fails, you can recover your DB by copying" << newname << "back to" << dbname;
qDebug() << endl << "****************************" << endl;
qDebug() << "FAILED TO OPEN DB";
throw "failed to open db"; // TODO
}
QFile::copy( dbname, newname );
QSqlQuery qry = QSqlQuery( db );
bool schemaUpdated = false;
qry.exec( "SELECT v FROM settings WHERE k='schema_version'" );
if ( qry.next() )
{
int v = qry.value( 0 ).toInt();
qDebug() << "Current schema is" << v << this->thread();
if ( v != CURRENT_SCHEMA_VERSION )
{
db = QSqlDatabase::addDatabase( "QSQLITE", "tomahawk" );
db.setDatabaseName( dbname );
if( !db.open() )
throw "db moving failed";
TomahawkSqlQuery query = newquery();
query.exec( "PRAGMA auto_vacuum = FULL" );
QString newname = QString("%1.v%2").arg(dbname).arg(v);
qDebug() << endl << "****************************" << endl;
qDebug() << "Schema version too old: " << v << ". Current version is:" << CURRENT_SCHEMA_VERSION;
qDebug() << "Moving" << dbname << newname;
qDebug() << "If the migration fails, you can recover your DB by copying" << newname << "back to" << dbname;
qDebug() << endl << "****************************" << endl;
schemaUpdated = updateSchema( version );
if ( !schemaUpdated )
qry.clear();
qry.finish();
db.close();
db.removeDatabase( "tomahawk" );
if( QFile::copy( dbname, newname ) )
{
db = QSqlDatabase::addDatabase( "QSQLITE", "tomahawk" );
db.setDatabaseName( dbname );
if( !db.open() )
throw "db moving failed";
TomahawkSqlQuery query = newquery();
query.exec( "PRAGMA auto_vacuum = FULL" );
schemaUpdated = updateSchema( v );
if( !schemaUpdated )
{
Q_ASSERT( false );
QTimer::singleShot( 0, qApp, SLOT( quit() ) );
}
}
else
{
Q_ASSERT( false );
QTimer::singleShot( 0, qApp, SLOT( quit() ) );
return;
}
}
}
else
{
db = QSqlDatabase::addDatabase( "QSQLITE", "tomahawk" );
db.setDatabaseName( dbname );
if ( !db.open() )
{
qDebug() << "Failed to open database" << dbname;
throw "failed to open db"; // TODO
}
if ( version < 0 )
schemaUpdated = updateSchema( 0 );
schemaUpdated = updateSchema( 0 );
}
TomahawkSqlQuery query = newquery();
@@ -149,10 +168,10 @@ DatabaseImpl::updateSchema( int oldVersion )
QStringList statements = sql.split( ";", QString::SkipEmptyParts );
db.transaction();
foreach ( const QString& sl, statements )
foreach( const QString& sl, statements )
{
QString s( sl.trimmed() );
if ( s.length() == 0 )
if( s.length() == 0 )
continue;
qDebug() << "Executing:" << s;
@@ -173,18 +192,18 @@ DatabaseImpl::updateSchema( int oldVersion )
QString path = QString( RESPATH "sql/dbmigrate-%1_to_%2.sql" ).arg( cur - 1 ).arg( cur );
QFile script( path );
if ( !script.exists() || !script.open( QIODevice::ReadOnly ) )
if( !script.exists() || !script.open( QIODevice::ReadOnly ) )
{
qWarning() << "Failed to find or open upgrade script from" << (cur-1) << "to" << cur << " (" << path << ")! Aborting upgrade...";
qWarning() << "Failed to find or open upgrade script from" << (cur-1) << "to" << cur << " (" << path << ")! Aborting upgrade..";
return false;
}
QString sql = QString::fromUtf8( script.readAll() ).trimmed();
QStringList statements = sql.split( ";", QString::SkipEmptyParts );
foreach ( const QString& sql, statements )
foreach( const QString& sql, statements )
{
QString clean = cleanSql( sql ).trimmed();
if ( clean.isEmpty() )
if( clean.isEmpty() )
continue;
qDebug() << "Executing upgrade statement:" << clean;
@@ -224,7 +243,7 @@ DatabaseImpl::file( int fid )
"WHERE file.id = file_join.file AND file.id = %1" )
.arg( fid ) );
if ( query.next() )
if( query.next() )
{
Tomahawk::source_ptr s;
@@ -266,10 +285,10 @@ DatabaseImpl::file( int fid )
int
DatabaseImpl::artistId( const QString& name_orig, bool& autoCreate )
DatabaseImpl::artistId( const QString& name_orig, bool& isnew )
{
bool isnew = false;
if ( m_lastart == name_orig )
isnew = false;
if( m_lastart == name_orig )
return m_lastartid;
int id = 0;
@@ -279,36 +298,31 @@ DatabaseImpl::artistId( const QString& name_orig, bool& autoCreate )
query.prepare( "SELECT id FROM artist WHERE sortname = ?" );
query.addBindValue( sortname );
query.exec();
if ( query.next() )
if( query.next() )
{
id = query.value( 0 ).toInt();
}
if ( id )
if( id )
{
m_lastart = name_orig;
m_lastartid = id;
return id;
}
if ( autoCreate )
// not found, insert it.
query.prepare( "INSERT INTO artist(id,name,sortname) VALUES(NULL,?,?)" );
query.addBindValue( name_orig );
query.addBindValue( sortname );
if( !query.exec() )
{
// not found, insert it.
query.prepare( "INSERT INTO artist(id,name,sortname) VALUES(NULL,?,?)" );
query.addBindValue( name_orig );
query.addBindValue( sortname );
if ( !query.exec() )
{
qDebug() << "Failed to insert artist:" << name_orig;
return 0;
}
id = query.lastInsertId().toInt();
isnew = true;
m_lastart = name_orig;
m_lastartid = id;
qDebug() << "Failed to insert artist:" << name_orig;
return 0;
}
autoCreate = isnew;
id = query.lastInsertId().toInt();
isnew = true;
m_lastart = name_orig;
m_lastartid = id;
return id;
}
@@ -408,23 +422,30 @@ DatabaseImpl::albumId( int artistid, const QString& name_orig, bool& isnew )
}
QList< QPair<int, float> >
QList< int >
DatabaseImpl::searchTable( const QString& table, const QString& name, uint limit )
{
Q_UNUSED( limit );
QList< QPair<int, float> > resultslist;
QList< int > results;
if( table != "artist" && table != "track" && table != "album" )
return resultslist;
return results;
QMap< int, float > resultsmap = m_fuzzyIndex->search( table, name );
QList< QPair<int, float> > resultslist;
foreach( int i, resultsmap.keys() )
{
resultslist << QPair<int, float>( i, (float)resultsmap.value( i ) );
}
qSort( resultslist.begin(), resultslist.end(), DatabaseImpl::scorepairSorter );
return resultslist;
for( int k = 0; k < resultslist.count(); k++ )
{
results << resultslist.at( k ).first;
}
// qDebug() << "Returning" << results.count() << "results";
return results;
}
@@ -618,31 +639,3 @@ DatabaseImpl::resultFromHint( const Tomahawk::query_ptr& origquery )
return res;
}
int
DatabaseImpl::getDatabaseVersion( const QString& dbname )
{
int version = -1;
{
QSqlDatabase db = QSqlDatabase::addDatabase( "QSQLITE", "tomahawk" );
db.setDatabaseName( dbname );
if ( !db.open() )
{
qDebug() << "Failed to open database" << dbname;
throw "failed to open db"; // TODO
}
QSqlQuery qry = QSqlQuery( db );
qry.exec( "SELECT v FROM settings WHERE k='schema_version'" );
if ( qry.next() )
{
version = qry.value( 0 ).toInt();
qDebug() << "Database schema of" << dbname << "is" << version;
}
}
QSqlDatabase::removeDatabase( "tomahawk" );
return version;
}

Some files were not shown because too many files have changed in this diff Show More