diff --git a/CMakeLists.txt b/CMakeLists.txt
index aa450babc..37b65eef0 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -369,43 +369,45 @@ if (TAGLIB_FOUND)
SET(CANTATA_SRCS ${CANTATA_SRCS} replaygain/ebur128.c replaygain/scanner.cpp replaygain/rgdialog.cpp replaygain/tagreader.cpp replaygain/jobcontroller.cpp )
SET(CANTATA_MOC_HDRS ${CANTATA_MOC_HDRS} replaygain/scanner.h replaygain/rgdialog.h replaygain/tagreader.h replaygain/jobcontroller.h )
endif(FFMPEG_FOUND AND MPG123_FOUND)
-endif (TAGLIB_FOUND)
-add_subdirectory(po)
-
-IF( ENABLE_KDE_SUPPORT )
- if (TAGLIB_FOUND)
- set (ENABLE_TAG_EDITOR_SUPPORT 1)
+ if (NOT WIN32)
set (ENABLE_DEVICES_SUPPORT 1)
+ if (NOT ENABLE_KDE_SUPPORT)
+ add_subdirectory(solid-lite)
+ endif (NOT ENABLE_KDE_SUPPORT)
if (ENABLE_MTP)
find_package(Mtp)
endif (ENABLE_MTP)
+ if (MTP_FOUND)
+ SET( CANTATA_SRCS ${CANTATA_SRCS} devices/mtpdevice.cpp )
+ SET( CANTATA_MOC_HDRS ${CANTATA_MOC_HDRS} devices/mtpdevice.h )
+ endif (MTP_FOUND)
- SET( CANTATA_SRCS ${CANTATA_SRCS} devices/mediadevicecache.cpp devices/devicespage.cpp
+ SET( CANTATA_SRCS ${CANTATA_SRCS} devices/mediadevicecache.cpp devices/devicespage.cpp devices/filejob.cpp
devices/device.cpp devices/fsdevice.cpp devices/umsdevice.cpp
models/devicesmodel.cpp devices/filetyperesolver.cpp devices/actiondialog.cpp devices/devicepropertieswidget.cpp
- devices/devicepropertiesdialog.cpp devices/encoders.cpp
+ devices/devicepropertiesdialog.cpp devices/encoders.cpp devices/freespaceinfo.cpp
devices/transcodingjob.cpp devices/valueslider.cpp devices/syncdialog.cpp devices/synccollectionwidget.cpp)
- SET( CANTATA_MOC_HDRS ${CANTATA_MOC_HDRS} devices/mediadevicecache.h devices/devicespage.h
+ SET( CANTATA_MOC_HDRS ${CANTATA_MOC_HDRS} devices/mediadevicecache.h devices/devicespage.h devices/filejob.h
devices/device.h devices/fsdevice.h devices/umsdevice.h models/devicesmodel.h
devices/actiondialog.h devices/devicepropertieswidget.h devices/devicepropertiesdialog.h
devices/transcodingjob.h devices/valueslider.h devices/syncdialog.h devices/synccollectionwidget.h)
SET( CANTATA_UIS ${CANTATA_UIS} devices/devicespage.ui devices/actiondialog.ui devices/devicepropertieswidget.ui
devices/synccollectionwidget.ui)
- if (ENABLE_REMOTE_DEVICES)
+ if (NOT WIN32 AND ENABLE_REMOTE_DEVICES)
SET(CANTATA_SRCS ${CANTATA_SRCS} devices/remotefsdevice.cpp devices/remotedevicepropertiesdialog.cpp
devices/remotedevicepropertieswidget.cpp)
SET(CANTATA_MOC_HDRS ${CANTATA_MOC_HDRS} devices/remotefsdevice.h devices/remotedevicepropertiesdialog.h
devices/remotedevicepropertieswidget.h)
SET(CANTATA_UIS ${CANTATA_UIS} devices/remotedevicepropertieswidget.ui)
- endif (ENABLE_REMOTE_DEVICES)
- if (MTP_FOUND)
- SET( CANTATA_SRCS ${CANTATA_SRCS} devices/mtpdevice.cpp )
- SET( CANTATA_MOC_HDRS ${CANTATA_MOC_HDRS} devices/mtpdevice.h )
- endif (MTP_FOUND)
- endif (TAGLIB_FOUND)
+ endif (NOT WIN32 AND ENABLE_REMOTE_DEVICES)
+ endif (NOT WIN32)
+endif (TAGLIB_FOUND)
+add_subdirectory(po)
+
+IF( ENABLE_KDE_SUPPORT )
macro_ensure_version("4.7.0" ${KDE_VERSION} KDE_VERSION_47)
if (NOT KDE_VERSION_47)
@@ -418,14 +420,10 @@ IF( ENABLE_KDE_SUPPORT )
QT4_ADD_RESOURCES( CANTATA_RC_SRCS ${CANTATA_RCS} )
KDE4_ADD_UI_FILES( CANTATA_UI_HDRS ${CANTATA_UIS} )
KDE4_ADD_EXECUTABLE( cantata ${CANTATA_SRCS} ${CANTATA_MOC_SRCS} ${CANTATA_RC_SRCS} ${CANTATA_UI_HDRS} )
- TARGET_LINK_LIBRARIES( cantata ${KDE4_KDEWEBKIT_LIBRARY} ${KDE4_KDECORE_LIBS} ${KDE4_KDEUI_LIBS} ${KDE4_KIO_LIBS} ${KDE4_SOLID_LIBS} )
- if (MTP_FOUND)
- TARGET_LINK_LIBRARIES(cantata ${MTP_LIBRARIES})
- include_directories( ${MTP_INCLUDE_DIR})
- endif (MTP_FOUND)
- if (ENABLE_REMOTE_DEVICES)
+ TARGET_LINK_LIBRARIES( cantata ${KDE4_KDEWEBKIT_LIBRARY} ${KDE4_KDECORE_LIBS} ${KDE4_KDEUI_LIBS} ${KDE4_SOLID_LIBS} )
+ if (NOT WIN32 AND TAGLIB_FOUND AND ENABLE_REMOTE_DEVICES)
TARGET_LINK_LIBRARIES(cantata ${KDE4_KFILE_LIBS})
- endif (ENABLE_REMOTE_DEVICES)
+ endif (NOT WIN32 AND TAGLIB_FOUND AND ENABLE_REMOTE_DEVICES)
install( TARGETS cantata ${INSTALL_TARGETS_DEFAULT_ARGS} )
install( PROGRAMS dynamic/cantata-dynamic DESTINATION bin)
install( FILES cantataui.rc DESTINATION ${DATA_INSTALL_DIR}/cantata )
@@ -467,6 +465,11 @@ ELSE( ENABLE_KDE_SUPPORT )
include_directories(${CMAKE_BINARY_DIR}/qtsingleapplication)
ENDIF( ENABLE_KDE_SUPPORT )
+if (MTP_FOUND AND NOT WIN32)
+ TARGET_LINK_LIBRARIES(cantata ${MTP_LIBRARIES})
+ include_directories( ${MTP_INCLUDE_DIR})
+endif (MTP_FOUND AND NOT WIN32)
+
ADD_SUBDIRECTORY( icons )
TARGET_LINK_LIBRARIES(cantata ${QT_QTXML_LIBRARY} ${QT_QTCORE_LIBRARY} ${QT_QTGUI_LIBRARY} ${QT_QTNETWORK_LIBRARY} ${QT_QTDBUS_LIBRARY})
@@ -488,6 +491,9 @@ if (TAGLIB_FOUND)
include_directories( ${SPEEXDSP_INCLUDE_DIRS})
endif(SPEEXDSP_FOUND)
endif(FFMPEG_FOUND AND MPG123_FOUND)
+ if (NOT ENABLE_KDE_SUPPORT)
+ TARGET_LINK_LIBRARIES(cantata solidlite)
+ endif (NOT ENABLE_KDE_SUPPORT)
endif (TAGLIB_FOUND)
if (PHONON_FOUND)
@@ -515,48 +521,38 @@ configure_file(config.h.cmake ${CMAKE_BINARY_DIR}/config.h)
message("")
IF( ENABLE_KDE_SUPPORT )
message("INFO: Building with KDE support")
- if (TAGLIB_FOUND)
- message(" Extra enabled features:")
- message(" - UMS device sync")
- if (MTP_FOUND)
- message(" - MTP device sync")
- endif (MTP_FOUND)
- if (ENABLE_REMOTE_DEVICES)
- message(" - Remote device sync (EXPERIMENTAL)")
- endif (ENABLE_REMOTE_DEVICES)
- if( NOT TAGLIB_FOUND OR NOT MTP_FOUND OR NOT FFMPEG_FOUND OR NOT MPG123_FOUND )
- message(" Disabled features:")
- if (NOT TAGLIB_FOUND)
- message(" - Tag Editor (taglib required)")
- message(" - Track Organizer (taglib required)")
- message(" - Commandline support (taglib required)")
- message(" - HTTP server support (taglib required)")
- endif (NOT TAGLIB_FOUND)
- if (NOT MTP_FOUND)
- message(" - MTP device sync (taglib and libmtp required)")
- endif (NOT MTP_FOUND)
- #if (NOT ENABLE_REMOTE_DEVICES)
- # message(" - Remote device sync (EXPERIMENTAL)")
- #endif (NOT ENABLE_REMOTE_DEVICES)
- if(NOT FFMPEG_FOUND OR NOT MPG123_FOUND)
- message(" - ReplayGain calculation (taglib, ffmpeg, and mpg123 required)")
- endif(NOT FFMPEG_FOUND OR NOT MPG123_FOUND)
- endif( NOT TAGLIB_FOUND OR NOT MTP_FOUND OR NOT FFMPEG_FOUND OR NOT MPG123_FOUND )
- endif (TAGLIB_FOUND)
-ELSE( ENABLE_KDE_SUPPORT )
+else ( ENABLE_KDE_SUPPORT )
if (NOT WIN32)
- message("INFO: Building WITHOUT KDE support - Device sync support DISABLED")
- if( NOT TAGLIB_FOUND OR NOT FFMPEG_FOUND OR NOT MPG123_FOUND )
- message(" Disabled features:")
- if (NOT TAGLIB_FOUND)
- message(" - Tag Editor (taglib required)")
- message(" - Track Organizer (taglib required)")
- message(" - Commandline support (taglib required)")
- message(" - HTTP server support (taglib required)")
- endif (NOT TAGLIB_FOUND)
- message(" - ReplayGain calculation (taglib, ffmpeg, and mpg123 required)")
- endif( NOT TAGLIB_FOUND OR NOT FFMPEG_FOUND OR NOT MPG123_FOUND )
+ message("INFO: Building WITHOUT KDE support")
endif (NOT WIN32)
+endif ( ENABLE_KDE_SUPPORT )
+
+if (TAGLIB_FOUND)
+ if (ENABLE_REMOTE_DEVICES)
+ message(" Extra enabled features:")
+ message(" - Remote device sync (EXPERIMENTAL)")
+ endif (ENABLE_REMOTE_DEVICES)
+ if( NOT TAGLIB_FOUND OR NOT MTP_FOUND OR NOT FFMPEG_FOUND OR NOT MPG123_FOUND )
+ message(" Disabled features:")
+ if (NOT TAGLIB_FOUND)
+ message(" - Tag Editor (taglib required)")
+ message(" - Track Organizer (taglib required)")
+ message(" - Commandline support (taglib required)")
+ message(" - HTTP server support (taglib required)")
+ if (NOT WIN32)
+ message(" - UMS device sync (taglib required)")
+ endif (NOT WIN32)
+ endif (NOT TAGLIB_FOUND)
+ if (NOT MTP_FOUND AND NOT WIN32)
+ message(" - MTP device sync (taglib and libmtp required)")
+ endif (NOT MTP_FOUND AND NOT WIN32)
+ if(NOT FFMPEG_FOUND OR NOT MPG123_FOUND)
+ message(" - ReplayGain calculation (taglib, ffmpeg, and mpg123 required)")
+ endif(NOT FFMPEG_FOUND OR NOT MPG123_FOUND)
+ endif( NOT TAGLIB_FOUND OR NOT MTP_FOUND OR NOT FFMPEG_FOUND OR NOT MPG123_FOUND )
+endif (TAGLIB_FOUND)
+
+IF ( NOT ENABLE_KDE_SUPPORT )
message("")
message("*************************************************************")
message("*************************************************************")
@@ -565,5 +561,5 @@ ELSE( ENABLE_KDE_SUPPORT )
message("*************************************************************")
message("*************************************************************")
message("")
-ENDIF( ENABLE_KDE_SUPPORT )
+ENDIF( NOT ENABLE_KDE_SUPPORT )
message("")
diff --git a/ChangeLog b/ChangeLog
index 109bd4835..ce8e4eb99 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -20,6 +20,8 @@
languages that have more than 1 plural form, it is suggested that BOTH
strings are translatated to the format "Items: %1" - e.g. "1 Track" becomes
"Tracks: 1", and "%1 Tracks" becomes "Tracks: %1"
+11. Device sync support for Qt-only builds. To support this, a cut-down version
+ of Solid is included.
0.8.3.1
-------
diff --git a/cmake/FindUDev.cmake b/cmake/FindUDev.cmake
new file mode 100644
index 000000000..4c8390db6
--- /dev/null
+++ b/cmake/FindUDev.cmake
@@ -0,0 +1,19 @@
+# - Try to find UDev
+# Once done this will define
+#
+# UDEV_FOUND - system has UDev
+# UDEV_INCLUDE_DIR - the libudev include directory
+# UDEV_LIBS - The libudev libraries
+
+# Copyright (c) 2010, Rafael Fernández López,
+#
+# Redistribution and use is allowed according to the terms of the BSD license.
+# For details see the accompanying COPYING-CMAKE-SCRIPTS file.
+
+find_path(UDEV_INCLUDE_DIR libudev.h)
+find_library(UDEV_LIBS udev)
+
+include(FindPackageHandleStandardArgs)
+find_package_handle_standard_args(UDev DEFAULT_MSG UDEV_INCLUDE_DIR UDEV_LIBS)
+
+mark_as_advanced(UDEV_INCLUDE_DIR UDEV_LIBS)
diff --git a/cmake/MacroLogFeature.cmake b/cmake/MacroLogFeature.cmake
new file mode 100644
index 000000000..45e27b6df
--- /dev/null
+++ b/cmake/MacroLogFeature.cmake
@@ -0,0 +1,157 @@
+# This file defines the Feature Logging macros.
+#
+# MACRO_LOG_FEATURE(VAR FEATURE DESCRIPTION URL [REQUIRED [MIN_VERSION [COMMENTS]]])
+# Logs the information so that it can be displayed at the end
+# of the configure run
+# VAR : TRUE or FALSE, indicating whether the feature is supported
+# FEATURE: name of the feature, e.g. "libjpeg"
+# DESCRIPTION: description what this feature provides
+# URL: home page
+# REQUIRED: TRUE or FALSE, indicating whether the featue is required
+# MIN_VERSION: minimum version number. empty string if unneeded
+# COMMENTS: More info you may want to provide. empty string if unnecessary
+#
+# MACRO_DISPLAY_FEATURE_LOG()
+# Call this to display the collected results.
+# Exits CMake with a FATAL error message if a required feature is missing
+#
+# Example:
+#
+# INCLUDE(MacroLogFeature)
+#
+# FIND_PACKAGE(JPEG)
+# MACRO_LOG_FEATURE(JPEG_FOUND "libjpeg" "Support JPEG images" "http://www.ijg.org" TRUE "3.2a" "")
+# ...
+# MACRO_DISPLAY_FEATURE_LOG()
+
+# Copyright (c) 2006, Alexander Neundorf,
+# Copyright (c) 2006, Allen Winter,
+# Copyright (c) 2009, Sebastian Trueg,
+#
+# Redistribution and use is allowed according to the terms of the BSD license.
+# For details see the accompanying COPYING-CMAKE-SCRIPTS file.
+
+IF (NOT _macroLogFeatureAlreadyIncluded)
+ SET(_file ${CMAKE_BINARY_DIR}/MissingRequirements.txt)
+ IF (EXISTS ${_file})
+ FILE(REMOVE ${_file})
+ ENDIF (EXISTS ${_file})
+
+ SET(_file ${CMAKE_BINARY_DIR}/EnabledFeatures.txt)
+ IF (EXISTS ${_file})
+ FILE(REMOVE ${_file})
+ ENDIF (EXISTS ${_file})
+
+ SET(_file ${CMAKE_BINARY_DIR}/DisabledFeatures.txt)
+ IF (EXISTS ${_file})
+ FILE(REMOVE ${_file})
+ ENDIF (EXISTS ${_file})
+
+ SET(_macroLogFeatureAlreadyIncluded TRUE)
+
+ INCLUDE(FeatureSummary)
+
+ENDIF (NOT _macroLogFeatureAlreadyIncluded)
+
+
+MACRO(MACRO_LOG_FEATURE _var _package _description _url ) # _required _minvers _comments)
+
+ STRING(TOUPPER "${ARGV4}" _required)
+ SET(_minvers "${ARGV5}")
+ SET(_comments "${ARGV6}")
+
+ IF (${_var})
+ SET(_LOGFILENAME ${CMAKE_BINARY_DIR}/EnabledFeatures.txt)
+ ELSE (${_var})
+ IF ("${_required}" STREQUAL "TRUE")
+ SET(_LOGFILENAME ${CMAKE_BINARY_DIR}/MissingRequirements.txt)
+ ELSE ("${_required}" STREQUAL "TRUE")
+ SET(_LOGFILENAME ${CMAKE_BINARY_DIR}/DisabledFeatures.txt)
+ ENDIF ("${_required}" STREQUAL "TRUE")
+ ENDIF (${_var})
+
+ SET(_logtext " * ${_package}")
+
+ IF (NOT ${_var})
+ IF (${_minvers} MATCHES ".*")
+ SET(_logtext "${_logtext} (${_minvers} or higher)")
+ ENDIF (${_minvers} MATCHES ".*")
+ SET(_logtext "${_logtext} <${_url}>\n ")
+ ELSE (NOT ${_var})
+ SET(_logtext "${_logtext} - ")
+ ENDIF (NOT ${_var})
+
+ SET(_logtext "${_logtext}${_description}")
+
+ IF (NOT ${_var})
+ IF (${_comments} MATCHES ".*")
+ SET(_logtext "${_logtext}\n ${_comments}")
+ ENDIF (${_comments} MATCHES ".*")
+# SET(_logtext "${_logtext}\n") #double-space missing features?
+ ENDIF (NOT ${_var})
+
+ FILE(APPEND "${_LOGFILENAME}" "${_logtext}\n")
+
+ IF(COMMAND SET_PACKAGE_INFO) # in FeatureSummary.cmake since CMake 2.8.3
+ SET_PACKAGE_INFO("${_package}" "\"${_description}\"" "${_url}" "\"${_comments}\"")
+ ENDIF(COMMAND SET_PACKAGE_INFO)
+
+ENDMACRO(MACRO_LOG_FEATURE)
+
+
+MACRO(MACRO_DISPLAY_FEATURE_LOG)
+ IF(COMMAND FEATURE_SUMMARY) # in FeatureSummary.cmake since CMake 2.8.3
+ FEATURE_SUMMARY(FILENAME ${CMAKE_CURRENT_BINARY_DIR}/FindPackageLog.txt
+ WHAT ALL)
+ ENDIF(COMMAND FEATURE_SUMMARY)
+
+ SET(_missingFile ${CMAKE_BINARY_DIR}/MissingRequirements.txt)
+ SET(_enabledFile ${CMAKE_BINARY_DIR}/EnabledFeatures.txt)
+ SET(_disabledFile ${CMAKE_BINARY_DIR}/DisabledFeatures.txt)
+
+ IF (EXISTS ${_missingFile} OR EXISTS ${_enabledFile} OR EXISTS ${_disabledFile})
+ SET(_printSummary TRUE)
+ ENDIF (EXISTS ${_missingFile} OR EXISTS ${_enabledFile} OR EXISTS ${_disabledFile})
+
+ IF(_printSummary)
+ SET(_missingDeps 0)
+ IF (EXISTS ${_enabledFile})
+ FILE(READ ${_enabledFile} _enabled)
+ FILE(REMOVE ${_enabledFile})
+ SET(_summary "${_summary}\n-----------------------------------------------------------------------------\n-- The following external packages were located on your system.\n-- This installation will have the extra features provided by these packages.\n-----------------------------------------------------------------------------\n${_enabled}")
+ ENDIF (EXISTS ${_enabledFile})
+
+
+ IF (EXISTS ${_disabledFile})
+ SET(_missingDeps 1)
+ FILE(READ ${_disabledFile} _disabled)
+ FILE(REMOVE ${_disabledFile})
+ SET(_summary "${_summary}\n-----------------------------------------------------------------------------\n-- The following OPTIONAL packages could NOT be located on your system.\n-- Consider installing them to enable more features from this software.\n-----------------------------------------------------------------------------\n${_disabled}")
+ ENDIF (EXISTS ${_disabledFile})
+
+
+ IF (EXISTS ${_missingFile})
+ SET(_missingDeps 1)
+ FILE(READ ${_missingFile} _requirements)
+ SET(_summary "${_summary}\n-----------------------------------------------------------------------------\n-- The following REQUIRED packages could NOT be located on your system.\n-- You must install these packages before continuing.\n-----------------------------------------------------------------------------\n${_requirements}")
+ FILE(REMOVE ${_missingFile})
+ SET(_haveMissingReq 1)
+ ENDIF (EXISTS ${_missingFile})
+
+
+ IF (NOT ${_missingDeps})
+ SET(_summary "${_summary}\n-----------------------------------------------------------------------------\n-- Congratulations! All external packages have been found.")
+ ENDIF (NOT ${_missingDeps})
+
+
+ MESSAGE(${_summary})
+ MESSAGE("-----------------------------------------------------------------------------\n")
+
+
+ IF(_haveMissingReq)
+ MESSAGE(FATAL_ERROR "Exiting: Missing Requirements")
+ ENDIF(_haveMissingReq)
+
+ ENDIF(_printSummary)
+
+ENDMACRO(MACRO_DISPLAY_FEATURE_LOG)
diff --git a/cmake/MacroOptionalFindPackage.cmake b/cmake/MacroOptionalFindPackage.cmake
new file mode 100644
index 000000000..d4ed48e33
--- /dev/null
+++ b/cmake/MacroOptionalFindPackage.cmake
@@ -0,0 +1,48 @@
+# - MACRO_OPTIONAL_FIND_PACKAGE() combines FIND_PACKAGE() with an OPTION()
+# MACRO_OPTIONAL_FIND_PACKAGE( [QUIT] )
+# This macro is a combination of OPTION() and FIND_PACKAGE(), it
+# works like FIND_PACKAGE(), but additionally it automatically creates
+# an option name WITH_, which can be disabled via the cmake GUI.
+# or via -DWITH_=OFF
+# The standard _FOUND variables can be used in the same way
+# as when using the normal FIND_PACKAGE()
+
+# Copyright (c) 2006-2010 Alexander Neundorf,
+#
+# Redistribution and use is allowed according to the terms of the BSD license.
+# For details see the accompanying COPYING-CMAKE-SCRIPTS file.
+
+# This is just a helper macro to set a bunch of variables empty.
+# We don't know whether the package uses UPPERCASENAME or CamelCaseName, so we try both:
+macro(_MOFP_SET_EMPTY_IF_DEFINED _name _var)
+ if(DEFINED ${_name}_${_var})
+ set(${_name}_${_var} "")
+ endif(DEFINED ${_name}_${_var})
+
+ string(TOUPPER ${_name} _nameUpper)
+ if(DEFINED ${_nameUpper}_${_var})
+ set(${_nameUpper}_${_var} "")
+ endif(DEFINED ${_nameUpper}_${_var})
+endmacro(_MOFP_SET_EMPTY_IF_DEFINED _package _var)
+
+
+macro (MACRO_OPTIONAL_FIND_PACKAGE _name )
+ option(WITH_${_name} "Search for ${_name} package" ON)
+ if (WITH_${_name})
+ find_package(${_name} ${ARGN})
+ else (WITH_${_name})
+ string(TOUPPER ${_name} _nameUpper)
+ set(${_name}_FOUND FALSE)
+ set(${_nameUpper}_FOUND FALSE)
+
+ _mofp_set_empty_if_defined(${_name} INCLUDE_DIRS)
+ _mofp_set_empty_if_defined(${_name} INCLUDE_DIR)
+ _mofp_set_empty_if_defined(${_name} INCLUDES)
+ _mofp_set_empty_if_defined(${_name} LIBRARY)
+ _mofp_set_empty_if_defined(${_name} LIBRARIES)
+ _mofp_set_empty_if_defined(${_name} LIBS)
+ _mofp_set_empty_if_defined(${_name} FLAGS)
+ _mofp_set_empty_if_defined(${_name} DEFINITIONS)
+ endif (WITH_${_name})
+endmacro (MACRO_OPTIONAL_FIND_PACKAGE)
+
diff --git a/devices/actiondialog.cpp b/devices/actiondialog.cpp
index 3b565702e..bfc957d6d 100644
--- a/devices/actiondialog.cpp
+++ b/devices/actiondialog.cpp
@@ -35,12 +35,10 @@
#include "mpdconnection.h"
#include "encoders.h"
#include "localize.h"
-#include
-#include
-#include
-#include
-#include
-#include
+#include "messagebox.h"
+#include "filejob.h"
+#include "freespaceinfo.h"
+#include
static int iCount=0;
@@ -113,10 +111,10 @@ void ActionDialog::copy(const QString &srcUdi, const QString &dstUdi, const QLis
capacityString=dev->capacityString();
usedCapacity=dev->usedCapacity();
} else {
- KDiskFreeSpaceInfo inf=KDiskFreeSpaceInfo::freeSpaceInfo(MPDConnection::self()->getDetails().dir);
+ FreeSpaceInfo inf=FreeSpaceInfo(MPDConnection::self()->getDetails().dir);
spaceAvailable=inf.size()-inf.used();
usedCapacity=(inf.used()*1.0)/(inf.size()*1.0);
- capacityString=i18n("%1 free", KGlobal::locale()->formatByteSize(inf.size()-inf.used()), 1);
+ capacityString=i18n("%1 free").arg(Utils::formatByteSize(inf.size()-inf.used()));
}
bool enoughSpace=spaceAvailable>spaceRequired;
@@ -133,9 +131,8 @@ void ActionDialog::copy(const QString &srcUdi, const QString &dstUdi, const QLis
namingOptions.load(mpdCfgName, true);
setPage(PAGE_START);
mode=Copy;
- capacity->setText(capacityString);
- capacity->setValue((usedCapacity*100)+0.5);
- capacity->setDrawTextMode(KCapacityBar::DrawTextInline);
+
+ capacity->update(capacityString, (usedCapacity*100)+0.5);
bool destIsDev=sourceUdi.isEmpty();
mpdConfigured=DeviceOptions::isConfigured(mpdCfgName, true);
@@ -143,17 +140,17 @@ void ActionDialog::copy(const QString &srcUdi, const QString &dstUdi, const QLis
configureSourceLabel->setVisible((!destIsDev && !dev->isConfigured()) || (destIsDev && !mpdConfigured));
show();
if (!enoughSpace) {
- KMessageBox::information(this, i18n("There is insufficient space left on the destination device.\n"
- "The selected songs consume %1, but there is only %2 left.\n"
- "The songs will need to be transcoded to a smaller filesize in order to be successfully copied.",
- KGlobal::locale()->formatByteSize(spaceRequired),
- KGlobal::locale()->formatByteSize(spaceAvailable)));
+ MessageBox::information(this, i18n("There is insufficient space left on the destination device.\n"
+ "The selected songs consume %1, but there is only %2 left.\n"
+ "The songs will need to be transcoded to a smaller filesize in order to be successfully copied.")
+ .arg(Utils::formatByteSize(spaceRequired))
+ .arg(Utils::formatByteSize(spaceAvailable)));
}
} else {
- KMessageBox::error(parentWidget(), i18n("There is insufficient space left on the destination.\n"
- "The selected songs consume %1, but there is only %2 left.",
- KGlobal::locale()->formatByteSize(spaceRequired),
- KGlobal::locale()->formatByteSize(spaceAvailable)));
+ MessageBox::error(parentWidget(), i18n("There is insufficient space left on the destination.\n"
+ "The selected songs consume %1, but there is only %2 left.")
+ .arg(Utils::formatByteSize(spaceRequired))
+ .arg(Utils::formatByteSize(spaceAvailable)));
deleteLater();
}
}
@@ -212,11 +209,11 @@ void ActionDialog::slotButtonClicked(int button)
case Ok:
if (haveVariousArtists &&
((configureDestLabel->isVisible() &&
- KMessageBox::No==KMessageBox::warningYesNo(this, i18n("You have not configured the destination device.
"
- "Continue with the default settings?
"))) ||
+ MessageBox::No==MessageBox::warningYesNo(this, i18n("You have not configured the destination device.
"
+ "Continue with the default settings?
"))) ||
(configureSourceLabel->isVisible() &&
- KMessageBox::No==KMessageBox::warningYesNo(this, i18n("You have not configured the source device.
"
- "Continue with the default settings?
"))))) {
+ MessageBox::No==MessageBox::warningYesNo(this, i18n("You have not configured the source device.
"
+ "Continue with the default settings?
"))))) {
return;
}
Settings::self()->saveOverwriteSongs(overwrite->isChecked());
@@ -264,7 +261,7 @@ void ActionDialog::slotButtonClicked(int button)
break;
case PAGE_PROGRESS:
paused=true;
- if (KMessageBox::Yes==KMessageBox::questionYesNo(this, i18n("Are you sure you wish to cancel?"))) {
+ if (MessageBox::Yes==MessageBox::questionYesNo(this, i18n("Are you sure you wish to cancel?"))) {
refreshLibrary();
reject();
// Need to call this - if not, when dialog is closed by window X control, it is not deleted!!!!
@@ -298,7 +295,7 @@ Device * ActionDialog::getDevice(const QString &udi)
if (isVisible()) {
setPage(PAGE_ERROR, error);
} else {
- KMessageBox::error(parentWidget(), error);
+ MessageBox::error(parentWidget(), error);
}
return 0;
@@ -396,35 +393,35 @@ void ActionDialog::actionStatus(int status)
}
break;
case Device::FileExists:
- setPage(PAGE_SKIP, i18n("The destination filename already exists!
%1", formatSong(currentSong, true)));
+ setPage(PAGE_SKIP, i18n("The destination filename already exists!
%1").arg(formatSong(currentSong, true)));
break;
case Device::SongExists:
- setPage(PAGE_SKIP, i18n("Song already exists!
%1", formatSong(currentSong)));
+ setPage(PAGE_SKIP, i18n("Song already exists!
%1").arg(formatSong(currentSong)));
break;
case Device::SongDoesNotExist:
- setPage(PAGE_SKIP, i18n("Song does not exist!
%1", formatSong(currentSong)));
+ setPage(PAGE_SKIP, i18n("Song does not exist!
%1").arg(formatSong(currentSong)));
break;
case Device::DirCreationFaild:
- setPage(PAGE_SKIP, i18n("Failed to create destination folder!
Please check you have sufficient permissions.
%1", formatSong(currentSong, true)));
+ setPage(PAGE_SKIP, i18n("Failed to create destination folder!
Please check you have sufficient permissions.
%1").arg(formatSong(currentSong, true)));
break;
case Device::SourceFileDoesNotExist:
- setPage(PAGE_SKIP, i18n("Source file no longer exists?
%1", formatSong(currentSong, true)));
+ setPage(PAGE_SKIP, i18n("Source file no longer exists?
%1").arg(formatSong(currentSong, true)));
break;
case Device::Failed:
- setPage(PAGE_SKIP, Copy==mode ? i18n("Failed to copy.
%1", formatSong(currentSong))
- : i18n("Failed to delete.
%1", formatSong(currentSong)));
+ setPage(PAGE_SKIP, Copy==mode ? i18n("Failed to copy.
%1").arg(formatSong(currentSong))
+ : i18n("Failed to delete.
%1").arg(formatSong(currentSong)));
break;
case Device::NotConnected:
- setPage(PAGE_ERROR, i18n("Not connected to device.
%1", formatSong(currentSong)));
+ setPage(PAGE_ERROR, i18n("Not connected to device.
%1").arg(formatSong(currentSong)));
break;
case Device::CodecNotAvailable:
- setPage(PAGE_ERROR, i18n("Selected codec is not available.
%1", formatSong(currentSong)));
+ setPage(PAGE_ERROR, i18n("Selected codec is not available.
%1").arg(formatSong(currentSong)));
break;
case Device::TranscodeFailed:
- setPage(PAGE_SKIP, i18n("Transcoding failed.
%1", formatSong(currentSong)));
+ setPage(PAGE_SKIP, i18n("Transcoding failed.
%1").arg(formatSong(currentSong)));
break;
case Device::FailedToCreateTempFile:
- setPage(PAGE_ERROR, i18n("Failed to create temporary file.
(Required for transcoding to MTP devices.)
%1", formatSong(currentSong)));
+ setPage(PAGE_ERROR, i18n("Failed to create temporary file.
(Required for transcoding to MTP devices.)
%1").arg(formatSong(currentSong)));
break;
default:
break;
@@ -523,21 +520,21 @@ QString ActionDialog::formatSong(const Song &s, bool showFiles)
"| Track: | %3 |
"
"| Source file: | %4 |
"
"| Destination file: | %5 |
"
- "", s.albumArtist(), s.album,
- s.trackAndTitleStr(Song::isVariousArtists(s.albumArtist()) && !Song::isVariousArtists(s.artist)), s.file, destFile)
+ "").arg(s.albumArtist()).arg(s.album)
+ .arg(s.trackAndTitleStr(Song::isVariousArtists(s.albumArtist()) && !Song::isVariousArtists(s.artist))).arg(s.file).arg(destFile)
: i18n(""
"| Artist: | %1 |
"
"| Album: | %2 |
"
"| Track: | %3 |
"
"| File: | %4 |
"
- "
", s.albumArtist(), s.album,
- s.trackAndTitleStr(Song::isVariousArtists(s.albumArtist()) && !Song::isVariousArtists(s.artist)), s.file)
+ "").arg(s.albumArtist()).arg(s.album)
+ .arg(s.trackAndTitleStr(Song::isVariousArtists(s.albumArtist()) && !Song::isVariousArtists(s.artist))).arg(s.file)
: i18n(""
"| Artist: | %1 |
"
"| Album: | %2 |
"
"| Track: | %3 |
"
- "
", s.albumArtist(), s.album,
- s.trackAndTitleStr(Song::isVariousArtists(s.albumArtist()) && !Song::isVariousArtists(s.artist)));
+ "").arg(s.albumArtist()).arg(s.album)
+ .arg(s.trackAndTitleStr(Song::isVariousArtists(s.albumArtist()) && !Song::isVariousArtists(s.artist)));
}
void ActionDialog::refreshLibrary()
@@ -566,13 +563,13 @@ void ActionDialog::removeSong(const Song &s)
return;
}
- KIO::SimpleJob *job=KIO::file_delete(KUrl(s.file), KIO::HideProgressInfo);
- connect(job, SIGNAL(result(KJob *)), SLOT(removeSongResult(KJob *)));
+ DeleteJob *job=new DeleteJob(s.file);
+ connect(job, SIGNAL(result(int)), SLOT(removeSongResult(int)));
}
-void ActionDialog::removeSongResult(KJob *job)
+void ActionDialog::removeSongResult(int status)
{
- if (job->error()) {
+ if (FileJob::StatusOk!=status) {
actionStatus(Device::Failed);
} else {
MusicLibraryModel::self()->removeSongFromList(currentSong);
@@ -595,4 +592,3 @@ void ActionDialog::incProgress()
progressBar->setValue(progressBar->value()+1);
}
}
-
diff --git a/devices/actiondialog.h b/devices/actiondialog.h
index 88e5ba59a..7c50cbb84 100644
--- a/devices/actiondialog.h
+++ b/devices/actiondialog.h
@@ -29,8 +29,6 @@
#include "device.h"
#include "ui_actiondialog.h"
-class KJob;
-
class ActionDialog : public Dialog, Ui::ActionDialog
{
Q_OBJECT
@@ -63,7 +61,7 @@ private Q_SLOTS:
void saveProperties();
void actionStatus(int status);
void doNext();
- void removeSongResult(KJob *job);
+ void removeSongResult(int status);
void copyPercent(unsigned long percent);
private:
diff --git a/devices/device.cpp b/devices/device.cpp
index 9d183912f..7de477499 100644
--- a/devices/device.cpp
+++ b/devices/device.cpp
@@ -35,9 +35,15 @@
#include "musiclibraryitemalbum.h"
#include "musiclibraryitemsong.h"
#include "localize.h"
+#ifdef ENABLE_KDE_SUPPORT
#include
#include
#include
+#else
+#include "solid-lite/portablemediaplayer.h"
+#include "solid-lite/storageaccess.h"
+#include "solid-lite/storagedrive.h"
+#endif
#include
#include
@@ -313,5 +319,5 @@ void Device::setStatusMessage(const QString &msg)
void Device::songCount(int c)
{
- setStatusMessage(i18n("Updating (%1)...", c));
+ setStatusMessage(i18n("Updating (%1)...").arg(c));
}
diff --git a/devices/device.h b/devices/device.h
index a229d6d82..435a5dec8 100644
--- a/devices/device.h
+++ b/devices/device.h
@@ -29,7 +29,11 @@
#include "encoders.h"
#include "deviceoptions.h"
#include
+#ifdef ENABLE_KDE_SUPPORT
#include
+#else
+#include "solid-lite/device.h"
+#endif
class QWidget;
class DevicesModel;
diff --git a/devices/deviceoptions.cpp b/devices/deviceoptions.cpp
index cf20cc216..1ab2a61a8 100644
--- a/devices/deviceoptions.cpp
+++ b/devices/deviceoptions.cpp
@@ -24,14 +24,7 @@
#include "deviceoptions.h"
#include "song.h"
#include "localize.h"
-#ifdef ENABLE_KDE_SUPPORT
-#include
-#include
-#include
-#include
-#else
-#include
-#endif
+#include "settings.h"
#include
#include
@@ -193,7 +186,7 @@ DeviceOptions::DeviceOptions()
, asciiOnly(false)
, ignoreThe(false)
, replaceSpaces(false)
- #ifdef ENABLE_KDE_SUPPORT
+ #ifdef ENABLE_DEVICES_SUPPORT
, fixVariousArtists(false)
, transcoderValue(0)
, transcoderWhenDifferent(false)
@@ -220,65 +213,56 @@ bool DeviceOptions::isConfigured(const QString &group, bool isMpd)
void DeviceOptions::load(const QString &group, bool isMpd)
{
#ifdef ENABLE_KDE_SUPPORT
- KConfigGroup grp(KGlobal::config(), !isMpd || group.isEmpty() || KGlobal::config()->hasGroup(group) ? group : constMpdGroup);
- scheme=grp.readEntry("scheme", scheme);
- vfatSafe=grp.readEntry("vfatSafe", vfatSafe);
- asciiOnly=grp.readEntry("asciiOnly", asciiOnly);
- ignoreThe=grp.readEntry("ignoreThe", ignoreThe);
- replaceSpaces=grp.readEntry("replaceSpaces", replaceSpaces);
- if (!isMpd) {
- fixVariousArtists=grp.readEntry("fixVariousArtists", fixVariousArtists);
- transcoderCodec=grp.readEntry("transcoderCodec", transcoderCodec);
- transcoderValue=grp.readEntry("transcoderValue", transcoderValue);
- transcoderWhenDifferent=grp.readEntry("transcoderWhenDifferent", transcoderWhenDifferent);
- }
+ KConfigGroup cfg(KGlobal::config(), !isMpd || group.isEmpty() || KGlobal::config()->hasGroup(group) ? group : constMpdGroup);
#else
- #define GET_STRING(KEY, DEF) (cfg.contains(KEY) ? cfg.value(KEY).toString() : QString(DEF))
- #define GET_BOOL(KEY, DEF) (cfg.contains(KEY) ? cfg.value(KEY).toBool() : DEF)
-
QSettings cfg;
- QString sep=group.isEmpty() ? QString() : ((-1==cfg.childGroups().indexOf(group) && isMpd ? constMpdGroup : group)+"/");
- scheme=GET_STRING(sep+"scheme", scheme);
- vfatSafe=GET_BOOL(sep+"vfatSafe", vfatSafe);
- asciiOnly=GET_BOOL(sep+"asciiOnly", asciiOnly);
- ignoreThe=GET_BOOL(sep+"ignoreThe", ignoreThe);
- replaceSpaces=GET_BOOL(sep+"replaceSpaces", replaceSpaces);
+ cfg.beginGroup(!isMpd || group.isEmpty() || HAS_GROUP(group) ? group : constMpdGroup);
+ #endif
+ scheme=GET_STRING("scheme", scheme);
+ vfatSafe=GET_BOOL("vfatSafe", vfatSafe);
+ asciiOnly=GET_BOOL("asciiOnly", asciiOnly);
+ ignoreThe=GET_BOOL("ignoreThe", ignoreThe);
+ replaceSpaces=GET_BOOL("replaceSpaces", replaceSpaces);
+ #ifdef ENABLE_DEVICES_SUPPORT
+ if (!isMpd) {
+ fixVariousArtists=GET_BOOL("fixVariousArtists", fixVariousArtists);
+ transcoderCodec=GET_STRING("transcoderCodec", transcoderCodec);
+ transcoderValue=GET_INT("transcoderValue", transcoderValue);
+ transcoderWhenDifferent=GET_BOOL("transcoderWhenDifferent", transcoderWhenDifferent);
+ }
#endif
}
void DeviceOptions::save(const QString &group, bool isMpd)
{
#ifdef ENABLE_KDE_SUPPORT
- KConfigGroup grp(KGlobal::config(), group);
- grp.writeEntry("scheme", scheme);
- grp.writeEntry("vfatSafe", vfatSafe);
- grp.writeEntry("asciiOnly", asciiOnly);
- grp.writeEntry("ignoreThe", ignoreThe);
- grp.writeEntry("replaceSpaces", replaceSpaces);
- if (!isMpd) {
- grp.writeEntry("fixVariousArtists", fixVariousArtists);
- grp.writeEntry("transcoderCodec", transcoderCodec);
- grp.writeEntry("transcoderValue", transcoderValue);
- grp.writeEntry("transcoderWhenDifferent", transcoderWhenDifferent);
- }
- grp.sync();
-
- if (isMpd && KGlobal::config()->hasGroup(constMpdGroup)) {
- KGlobal::config()->deleteGroup(constMpdGroup);
- }
+ KConfigGroup cfg(KGlobal::config(), !isMpd || group.isEmpty() || KGlobal::config()->hasGroup(group) ? group : constMpdGroup);
#else
QSettings cfg;
- QString sep=group.isEmpty() ? QString() : (group+"/");
- cfg.setValue(sep+"scheme", scheme);
- cfg.setValue(sep+"vfatSafe", vfatSafe);
- cfg.setValue(sep+"asciiOnly", asciiOnly);
- cfg.setValue(sep+"ignoreThe", ignoreThe);
- cfg.setValue(sep+"replaceSpaces", replaceSpaces);
+ cfg.beginGroup(!isMpd || group.isEmpty() || HAS_GROUP(group) ? group : constMpdGroup);
+ #endif
- if (isMpd && -1!=cfg.childGroups().indexOf(constMpdGroup)) {
- cfg.remove(constMpdGroup);
+ SET_VALUE("scheme", scheme);
+ SET_VALUE("vfatSafe", vfatSafe);
+ SET_VALUE("asciiOnly", asciiOnly);
+ SET_VALUE("ignoreThe", ignoreThe);
+ SET_VALUE("replaceSpaces", replaceSpaces);
+ #ifdef ENABLE_DEVICES_SUPPORT
+ if (!isMpd) {
+ SET_VALUE("fixVariousArtists", fixVariousArtists);
+ SET_VALUE("transcoderCodec", transcoderCodec);
+ SET_VALUE("transcoderValue", transcoderValue);
+ SET_VALUE("transcoderWhenDifferent", transcoderWhenDifferent);
}
#endif
+ CFG_SYNC;
+
+ #ifndef ENABLE_KDE_SUPPORT
+ cfg.endGroup();
+ #endif
+ if (isMpd && HAS_GROUP(constMpdGroup)) {
+ REMOVE_GROUP(constMpdGroup);
+ }
}
QString DeviceOptions::clean(const QString &str) const
diff --git a/devices/deviceoptions.h b/devices/deviceoptions.h
index 298695952..077dad136 100644
--- a/devices/deviceoptions.h
+++ b/devices/deviceoptions.h
@@ -25,7 +25,8 @@
#define DEVICE_OPTIONS_H
#include
-#ifdef ENABLE_KDE_SUPPORT
+#include "config.h"
+#ifdef ENABLE_DEVICES_SUPPORT
#include "encoders.h"
#endif
@@ -51,7 +52,7 @@ struct DeviceOptions {
bool operator==(const DeviceOptions &o) const {
return vfatSafe==o.vfatSafe && asciiOnly==o.asciiOnly && ignoreThe==o.ignoreThe &&
replaceSpaces==o.replaceSpaces && scheme==o.scheme
- #ifdef ENABLE_KDE_SUPPORT
+ #ifdef ENABLE_DEVICES_SUPPORT
&& fixVariousArtists==o.fixVariousArtists && useCache==o.useCache &&
transcoderCodec==o.transcoderCodec && autoScan==o.autoScan &&
(transcoderCodec.isEmpty() || (transcoderValue==o.transcoderValue && transcoderWhenDifferent==o.transcoderWhenDifferent))
@@ -70,7 +71,7 @@ struct DeviceOptions {
bool asciiOnly;
bool ignoreThe;
bool replaceSpaces;
- #ifdef ENABLE_KDE_SUPPORT
+ #ifdef ENABLE_DEVICES_SUPPORT
bool fixVariousArtists;
QString transcoderCodec;
int transcoderValue;
diff --git a/devices/devicepropertieswidget.cpp b/devices/devicepropertieswidget.cpp
index ede204298..740e4340c 100644
--- a/devices/devicepropertieswidget.cpp
+++ b/devices/devicepropertieswidget.cpp
@@ -25,8 +25,6 @@
#include "filenameschemedialog.h"
#include "covers.h"
#include "localize.h"
-#include
-#include
#include
#include
@@ -145,7 +143,7 @@ void DevicePropertiesWidget::update(const QString &path, const QString &coverNam
transcoderFrame->setVisible(false);
} else {
foreach (const Encoders::Encoder &e, encs) {
- transcoderName->addItem(i18n("Transcode to \"%1\"", e.name), e.codec);
+ transcoderName->addItem(i18n("Transcode to \"%1\"").arg(e.name), e.codec);
}
if (opts.transcoderCodec.isEmpty()) {
diff --git a/devices/devicespage.cpp b/devices/devicespage.cpp
index b22507f08..c42da8634 100644
--- a/devices/devicespage.cpp
+++ b/devices/devicespage.cpp
@@ -33,9 +33,8 @@
#include
#include
#ifdef ENABLE_KDE_SUPPORT
-#include
-#include
#include
+#include
#else
#include
#endif
@@ -57,27 +56,15 @@ DevicesPage::DevicesPage(MainWindow *p)
{
setupUi(this);
- configureAction = p->actionCollection()->addAction("configuredevice");
- configureAction->setText(i18n("Configure Device"));
- configureAction->setIcon(QIcon::fromTheme("configure"));
- refreshAction = p->actionCollection()->addAction("refreshdevice");
- refreshAction->setText(i18n("Refresh Device"));
- refreshAction->setIcon(QIcon::fromTheme("view-refresh"));
- copyAction = p->actionCollection()->addAction("copytolibrary");
- copyAction->setText(i18n("Copy To Library"));
- copyAction->setIcon(QIcon::fromTheme("document-import"));
+ configureAction = p->createAction("configuredevice", i18n("Configure Device"), "configure");
+ refreshAction = p->createAction("refreshdevice", i18n("Refresh Device"), "view-refresh");
+ copyAction = p->createAction("copytolibrary", i18n("Copy To Library"), "document-import");
copyToLibraryButton->setDefaultAction(copyAction);
- syncAction = p->actionCollection()->addAction("syncdevice");
- syncAction->setText(i18n("Sync"));
- syncAction->setIcon(QIcon::fromTheme("folder-sync"));
+ syncAction = p->createAction("syncdevice", i18n("Sync"), "folder-sync");
connect(syncAction, SIGNAL(triggered()), this, SLOT(sync()));
#ifdef ENABLE_REMOTE_DEVICES
- forgetDeviceAction=p->actionCollection()->addAction("forgetdevice");
- forgetDeviceAction->setText(i18n("Forget Device"));
- forgetDeviceAction->setIcon(QIcon::fromTheme("list-remove"));
- toggleDeviceAction=p->actionCollection()->addAction("toggledevice");
- toggleDeviceAction->setText(i18n("Toggle Device"));
- toggleDeviceAction->setIcon(QIcon::fromTheme("network-connect"));
+ forgetDeviceAction=p->createAction("forgetdevice", i18n("Forget Device"), "list-remove");
+ toggleDeviceAction=p->createAction("toggledevice", i18n("Toggle Device"), "network-connect");
connect(forgetDeviceAction, SIGNAL(triggered()), this, SLOT(forgetRemoteDevice()));
connect(toggleDeviceAction, SIGNAL(triggered()), this, SLOT(toggleDevice()));
#endif
@@ -117,9 +104,7 @@ DevicesPage::DevicesPage(MainWindow *p)
menu->addAction(refreshAction);
menu->addSeparator();
#ifdef ENABLE_REMOTE_DEVICES
- KAction *addRemote=p->actionCollection()->addAction("adddevice");
- addRemote->setText(i18n("Add Device"));
- addRemote->setIcon(QIcon::fromTheme("network-server"));
+ Action *addRemote=p->createAction("adddevice", i18n("Add Device"), "network-server");
connect(addRemote, SIGNAL(triggered()), this, SLOT(addRemoteDevice()));
menu->addAction(addRemote);
menu->addAction(forgetDeviceAction);
@@ -368,13 +353,13 @@ void DevicesPage::refreshDevice()
bool full=true;
if (dev->childCount() && Device::Mtp!=dev->devType()) {
QString udi=dev->udi();
- switch (KMessageBox::questionYesNoCancel(this, i18n("Which type of refresh do you wish to perform?
"
- "- Partial - Only new songs are scanned (quick)
"
- "- Full - All songs are rescanned (slow)
"),
- i18n("Refresh"), KGuiItem(i18n("Partial")), KGuiItem(i18n("Full")))) {
- case KMessageBox::Yes:
+ switch (MessageBox::questionYesNoCancel(this, i18n("Which type of refresh do you wish to perform?
"
+ "- Partial - Only new songs are scanned (quick)
"
+ "- Full - All songs are rescanned (slow)
"),
+ i18n("Refresh"), KGuiItem(i18n("Partial")), KGuiItem(i18n("Full")))) {
+ case MessageBox::Yes:
full=false;
- case KMessageBox::No:
+ case MessageBox::No:
break;
default:
return;
diff --git a/devices/devicespage.h b/devices/devicespage.h
index 184e7a0ff..c64657fe7 100644
--- a/devices/devicespage.h
+++ b/devices/devicespage.h
@@ -33,8 +33,6 @@
#include "remotefsdevice.h"
#endif
-class KAction;
-
class DevicesPage : public QWidget, public Ui::DevicesPage
{
Q_OBJECT
@@ -73,14 +71,14 @@ Q_SIGNALS:
private:
MainWindow *mw;
MusicLibraryProxyModel proxy;
- KAction *configureAction;
- KAction *refreshAction;
- KAction *copyAction;
+ Action *configureAction;
+ Action *refreshAction;
+ Action *copyAction;
#ifdef ENABLE_REMOTE_DEVICES
- KAction *forgetDeviceAction;
- KAction *toggleDeviceAction;
+ Action *forgetDeviceAction;
+ Action *toggleDeviceAction;
#endif
- KAction *syncAction;
+ Action *syncAction;
QSet genres;
};
diff --git a/devices/encoders.cpp b/devices/encoders.cpp
index 66a4f58c6..e58b09713 100644
--- a/devices/encoders.cpp
+++ b/devices/encoders.cpp
@@ -25,7 +25,6 @@
#include "encoders.h"
#include "utils.h"
#include "localize.h"
-#include
#include
#include
@@ -42,9 +41,9 @@ static void init()
if (!initialised) {
initialised=true;
- ffmpeg=KStandardDirs::findExe("ffmpeg");
+ ffmpeg=Utils::findExe("ffmpeg");
if (ffmpeg.isEmpty()) {
- ffmpeg=KStandardDirs::findExe("avconv");
+ ffmpeg=Utils::findExe("avconv");
usingAvconv=true;
}
if (ffmpeg.isEmpty()) {
@@ -81,17 +80,17 @@ static void init()
QLatin1String("libfaac"),
QLatin1String("-aq"),
i18n("Expected average bitrate for variable bitrate encoding"),
- QList() << Setting(i18n(vbr, 25), 30)
- << Setting(i18n(vbr, 50), 55)
- << Setting(i18n(vbr, 70), 80)
- << Setting(i18n(vbr, 90), 105)
- << Setting(i18n(vbr, 120), 125)
- << Setting(i18n(vbr, 150), 155)
- << Setting(i18n(vbr, 170), 180)
- << Setting(i18n(vbr, 180), 205)
- << Setting(i18n(vbr, 190), 230)
- << Setting(i18n(vbr, 200), 255)
- << Setting(i18n(vbr, 210), 280),
+ QList() << Setting(i18n(vbr).arg(25), 30)
+ << Setting(i18n(vbr).arg(50), 55)
+ << Setting(i18n(vbr).arg(70), 80)
+ << Setting(i18n(vbr).arg(90), 105)
+ << Setting(i18n(vbr).arg(120), 125)
+ << Setting(i18n(vbr).arg(150), 155)
+ << Setting(i18n(vbr).arg(170), 180)
+ << Setting(i18n(vbr).arg(180), 205)
+ << Setting(i18n(vbr).arg(190), 230)
+ << Setting(i18n(vbr).arg(200), 255)
+ << Setting(i18n(vbr).arg(210), 280),
i18n("Smaller file"),
i18n("Better sound quality"),
5));
@@ -172,16 +171,16 @@ static void init()
QLatin1String("libmp3lame"),
QLatin1String("-aq"),
i18n("Expected average bitrate for variable bitrate encoding"),
- QList() << Setting(i18n(vbr, 80), 9)
- << Setting(i18n(vbr, 100), 8)
- << Setting(i18n(vbr, 120), 7)
- << Setting(i18n(vbr, 140), 6)
- << Setting(i18n(vbr, 160), 5)
- << Setting(i18n(vbr, 175), 4)
- << Setting(i18n(vbr, 190), 3)
- << Setting(i18n(vbr, 205), 2)
- << Setting(i18n(vbr, 220), 1)
- << Setting(i18n(vbr, 240), 0),
+ QList() << Setting(i18n(vbr).arg(80), 9)
+ << Setting(i18n(vbr).arg(100), 8)
+ << Setting(i18n(vbr).arg(120), 7)
+ << Setting(i18n(vbr).arg(140), 6)
+ << Setting(i18n(vbr).arg(160), 5)
+ << Setting(i18n(vbr).arg(175), 4)
+ << Setting(i18n(vbr).arg(190), 3)
+ << Setting(i18n(vbr).arg(205), 2)
+ << Setting(i18n(vbr).arg(220), 1)
+ << Setting(i18n(vbr).arg(240), 0),
i18n("Smaller file"),
i18n("Better sound quality"),
4));
@@ -214,18 +213,18 @@ static void init()
QLatin1String("libvorbis"),
QLatin1String("-aq"),
i18n("Quality rating"),
- QList() << Setting(i18n(quality, -1, 45), -1)
- << Setting(i18n(quality, 0, 64), 0)
- << Setting(i18n(quality, 1, 80), 1)
- << Setting(i18n(quality, 2, 96), 2)
- << Setting(i18n(quality, 3, 112), 3)
- << Setting(i18n(quality, 4, 128), 4)
- << Setting(i18n(quality, 5, 160), 5)
- << Setting(i18n(quality, 6, 192), 6)
- << Setting(i18n(quality, 7, 224), 7)
- << Setting(i18n(quality, 8, 256), 8)
- << Setting(i18n(quality, 9, 320), 9)
- << Setting(i18n(quality, 10, 500), 10),
+ QList() << Setting(i18n(quality).arg(-1).arg(45), -1)
+ << Setting(i18n(quality).arg(0).arg(64), 0)
+ << Setting(i18n(quality).arg(1).arg(80), 1)
+ << Setting(i18n(quality).arg(2).arg(96), 2)
+ << Setting(i18n(quality).arg(3).arg(112), 3)
+ << Setting(i18n(quality).arg(4).arg(128), 4)
+ << Setting(i18n(quality).arg(5).arg(160), 5)
+ << Setting(i18n(quality).arg(6).arg(192), 6)
+ << Setting(i18n(quality).arg(7).arg(224), 7)
+ << Setting(i18n(quality).arg(8).arg(256), 8)
+ << Setting(i18n(quality).arg(9).arg(320), 9)
+ << Setting(i18n(quality).arg(10).arg(500), 10),
i18n("Smaller file"),
i18n("Better sound quality"),
6));
@@ -251,14 +250,14 @@ static void init()
QLatin1String("wmav2"),
QLatin1String("-ab"),
i18n("Bitrate"),
- QList() << Setting(i18n(cbr, 64), 65*1000)
- << Setting(i18n(cbr, 80), 75*1000)
- << Setting(i18n(cbr, 96), 88*1000)
- << Setting(i18n(cbr, 112), 106*1000)
- << Setting(i18n(cbr, 136), 133*1000)
- << Setting(i18n(cbr, 182), 180*1000)
- << Setting(i18n(cbr, 275), 271*1000)
- << Setting(i18n(cbr, 550), 545*1000),
+ QList() << Setting(i18n(cbr).arg(64), 65*1000)
+ << Setting(i18n(cbr).arg(80), 75*1000)
+ << Setting(i18n(cbr).arg(96), 88*1000)
+ << Setting(i18n(cbr).arg(112), 106*1000)
+ << Setting(i18n(cbr).arg(136), 133*1000)
+ << Setting(i18n(cbr).arg(182), 180*1000)
+ << Setting(i18n(cbr).arg(275), 271*1000)
+ << Setting(i18n(cbr).arg(550), 545*1000),
i18n("Smaller file"),
i18n("Better sound quality"),
4));
diff --git a/devices/filejob.cpp b/devices/filejob.cpp
new file mode 100644
index 000000000..621788a70
--- /dev/null
+++ b/devices/filejob.cpp
@@ -0,0 +1,147 @@
+/*
+ * Cantata
+ *
+ * Copyright (c) 2011-2012 Craig Drummond
+ *
+ * ----
+ *
+ * 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 2 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; see the file COPYING. If not, write to
+ * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ */
+
+#include "filejob.h"
+#include "utils.h"
+#include
+#include
+#include
+
+#ifdef ENABLE_KDE_SUPPORT
+#include
+K_GLOBAL_STATIC(FileScheduler, instance)
+#endif
+
+FileScheduler * FileScheduler::self()
+{
+ #ifdef ENABLE_KDE_SUPPORT
+ return instance;
+ #else
+ static FileScheduler *instance=0;
+ if(!instance) {
+ instance=new FileScheduler;
+ }
+ return instance;
+ #endif
+}
+
+FileScheduler::FileScheduler()
+ : thread(0)
+{
+}
+
+void FileScheduler::addJob(FileJob *job)
+{
+ if (!thread) {
+ thread=new QThread();
+ moveToThread(thread);
+ thread->start();
+ }
+ job->moveToThread(thread);
+ QTimer::singleShot(0, job, SLOT(start()));
+}
+
+void FileScheduler::stop()
+{
+ if (thread) {
+ Utils::stopThread(thread);
+ thread=0;
+ }
+}
+
+void FileJob::setPercent(int pc)
+{
+ if (pc!=progressPercent) {
+ progressPercent=pc;
+ emit percent(progressPercent);
+ }
+}
+
+static const int constChunkSize=32*1024;
+
+void CopyJob::start()
+{
+ QFile src(srcFile);
+
+ if (!src.open(QIODevice::ReadOnly)) {
+ emit result(StatusFailed);
+ return;
+ }
+
+ QFile dest(destFile);
+ if (!dest.open(QIODevice::WriteOnly)) {
+ emit result(StatusFailed);
+ return;
+ }
+
+ char buffer[constChunkSize];
+ qint64 totalBytes = src.size();
+ qint64 readPos = 0;
+ qint64 bytesRead = 0;
+
+ do {
+ if (stopRequested) {
+ emit result(StatusCancelled);
+ return;
+ }
+ bytesRead = src.read(buffer, constChunkSize);
+ readPos+=bytesRead;
+ if (bytesRead<0) {
+ emit result(StatusFailed);
+ return;
+ }
+
+ if (stopRequested) {
+ emit result(StatusCancelled);
+ return;
+ }
+
+ qint64 writePos=0;
+ do {
+ qint64 bytesWritten = dest.write(&buffer[writePos], bytesRead - writePos);
+ if (stopRequested) {
+ emit result(StatusCancelled);
+ return;
+ }
+ if (-1==bytesWritten) {
+ emit result(StatusFailed);
+ return;
+ }
+ writePos+=bytesWritten;
+ } while (writePos
+ *
+ * ----
+ *
+ * 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 2 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; see the file COPYING. If not, write to
+ * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ */
+
+#ifndef FILE_JOB_H
+#define FILE_JOB_H
+
+#include
+
+class QThread;
+class FileJob;
+
+class FileScheduler : public QObject
+{
+ Q_OBJECT
+public:
+ static FileScheduler * self();
+
+ FileScheduler();
+ void addJob(FileJob *job);
+ void stop();
+private:
+ QThread *thread;
+};
+
+class FileJob : public QObject
+{
+ Q_OBJECT
+
+public:
+ enum Status {
+ StatusOk,
+ StatusFailed,
+ StatusCancelled
+ };
+
+ FileJob()
+ : stopRequested(false)
+ , progressPercent(0) {
+ FileScheduler::self()->addJob(this);
+ }
+ virtual ~FileJob() { }
+
+ void setPercent(int pc);
+ bool wasStarted() const { return 0!=progressPercent && 100!=progressPercent; }
+
+Q_SIGNALS:
+ void percent(int pc);
+ void result(int status);
+
+public:
+ virtual void stop() { stopRequested=true; }
+
+protected Q_SLOTS:
+ virtual void start()=0;
+
+protected:
+ bool stopRequested;
+ int progressPercent;
+};
+
+class CopyJob : public FileJob
+{
+public:
+ CopyJob(const QString &src, const QString &dest)
+ : srcFile(src)
+ , destFile(dest) {
+ }
+private:
+ void start();
+private:
+ QString srcFile;
+ QString destFile;
+};
+
+class DeleteJob : public FileJob
+{
+public:
+ DeleteJob(const QString &file)
+ : fileName(file) {
+ }
+private:
+ void start();
+private:
+ QString fileName;
+};
+
+#endif
diff --git a/devices/filetyperesolver.cpp b/devices/filetyperesolver.cpp
index dcc0124ef..21305175d 100644
--- a/devices/filetyperesolver.cpp
+++ b/devices/filetyperesolver.cpp
@@ -25,9 +25,9 @@
#include
#include
-// #include
+#ifdef ENABLE_KDE_SUPPORT
#include
-
+#endif
#ifdef TAGLIB_EXTRAS_FOUND
#include
#include
@@ -52,101 +52,90 @@ TagLib::File *Meta::Tag::FileTypeResolver::createFile(TagLib::FileName fileName,
{
TagLib::File* result = 0;
- QString fn = QFile::decodeName( fileName );
- QString suffix = QFileInfo( fn ).suffix();
- KMimeType::Ptr mimetype = KMimeType::findByPath( fn );
+ QString fn = QFile::decodeName(fileName);
+ QString suffix = QFileInfo(fn).suffix();
+
+ #ifdef ENABLE_KDE_SUPPORT
+ KMimeType::Ptr mimetype = KMimeType::findByPath(fn);
// -- check by mime type
- if( mimetype->is( QLatin1String("audio/mpeg") )
- || mimetype->is( QLatin1String("audio/x-mpegurl") )
- || mimetype->is( QLatin1String("audio/mpeg") ))
- {
+ if (mimetype->is(QLatin1String("audio/mpeg")) || mimetype->is(QLatin1String("audio/x-mpegurl"))
+ || mimetype->is(QLatin1String("audio/mpeg"))) {
result = new TagLib::MPEG::File(fileName, readProperties, propertiesStyle);
}
- else if( mimetype->is( QLatin1String("audio/mp4") )
- || mimetype->is( QLatin1String("video/mp4") ) )
- {
+ else if (mimetype->is(QLatin1String("audio/mp4")) || mimetype->is(QLatin1String("video/mp4"))) {
result = new TagLib::MP4::File(fileName, readProperties, propertiesStyle);
}
- else if( mimetype->is( QLatin1String("audio/x-ms-wma") )
- /*|| mimetype->is( QLatin1String("video/x-ms-asf") )
- || mimetype->is( QLatin1String("video/x-msvideo") )
- || mimetype->is( QLatin1String("video/x-ms-wmv") )*/ )
- {
+ else if (mimetype->is(QLatin1String("audio/x-ms-wma")) /*|| mimetype->is(QLatin1String("video/x-ms-asf"))
+ || mimetype->is(QLatin1String("video/x-msvideo")) || mimetype->is(QLatin1String("video/x-ms-wmv"))*/) {
result = new TagLib::ASF::File(fileName, readProperties, propertiesStyle);
}
-#ifdef TAGLIB_EXTRAS_FOUND
- else if( mimetype->is( QLatin1String("audio/vnd.rn-realaudio") )
- || mimetype->is( QLatin1String("audio/x-pn-realaudioplugin") )
- /*|| mimetype->is( QLatin1String("audio/vnd.rn-realvideo") )*/ )
- {
+ #ifdef TAGLIB_EXTRAS_FOUND
+ else if (mimetype->is(QLatin1String("audio/vnd.rn-realaudio")) || mimetype->is(QLatin1String("audio/x-pn-realaudioplugin"))
+ /*|| mimetype->is(QLatin1String("audio/vnd.rn-realvideo"))*/) {
result = new TagLibExtras::RealMedia::File(fileName, readProperties, propertiesStyle);
}
-#endif
- else if( mimetype->is( QLatin1String("audio/x-vorbis+ogg") ) )
- {
+ #endif
+ else if (mimetype->is(QLatin1String("audio/x-vorbis+ogg"))) {
result = new TagLib::Ogg::Vorbis::File(fileName, readProperties, propertiesStyle);
}
- else if( mimetype->is( QLatin1String("audio/x-flac+ogg") ) )
- {
+ else if (mimetype->is(QLatin1String("audio/x-flac+ogg"))) {
result = new TagLib::Ogg::FLAC::File(fileName, readProperties, propertiesStyle);
}
- else if( mimetype->is( QLatin1String("audio/x-aiff") ) )
- {
+ else if (mimetype->is(QLatin1String("audio/x-aiff"))) {
result = new TagLib::RIFF::AIFF::File(fileName, readProperties, propertiesStyle);
}
- else if( mimetype->is( QLatin1String("audio/x-flac") ) )
- {
+ else if (mimetype->is(QLatin1String("audio/x-flac"))) {
result = new TagLib::FLAC::File(fileName, readProperties, propertiesStyle);
}
- else if( mimetype->is( QLatin1String("audio/x-musepack") ) )
- {
+ else if (mimetype->is(QLatin1String("audio/x-musepack"))) {
result = new TagLib::MPC::File(fileName, readProperties, propertiesStyle);
}
- else if( mimetype->is( QLatin1String("audio/x-wav") ) )
- {
+ else if (mimetype->is(QLatin1String("audio/x-wav"))) {
result = new TagLib::RIFF::WAV::File(fileName, readProperties, propertiesStyle);
}
- else if( mimetype->is( QLatin1String("audio/x-wavpack") ) )
- {
+ else if (mimetype->is(QLatin1String("audio/x-wavpack"))) {
result = new TagLib::WavPack::File(fileName, readProperties, propertiesStyle);
}
- else if( mimetype->is( QLatin1String("audio/x-tta") ) )
- {
+ else if (mimetype->is(QLatin1String("audio/x-tta"))) {
result = new TagLib::TrueAudio::File(fileName, readProperties, propertiesStyle);
}
- else if( mimetype->is( QLatin1String("audio/x-speex") )
- || mimetype->is( QLatin1String("audio/x-speex+ogg") ) )
- {
+ else if (mimetype->is(QLatin1String("audio/x-speex")) || mimetype->is(QLatin1String("audio/x-speex+ogg"))) {
result = new TagLib::TrueAudio::File(fileName, readProperties, propertiesStyle);
}
// -- check by extension
- else if( suffix == QLatin1String("m4a")
- || suffix == QLatin1String("m4b")
- || suffix == QLatin1String("m4p")
- || suffix == QLatin1String("mp4")
- /*|| suffix == QLatin1String("m4v")
- || suffix == QLatin1String("mp4v") */)
- {
+ #else // ENABLE_KDE_SUPPORT
+ if (suffix == QLatin1String("mp3")) {
+ result = new TagLib::MPEG::File(fileName, readProperties, propertiesStyle);
+ } else if (suffix == QLatin1String("ogg") || suffix == QLatin1String("flac")) {
+ result = new TagLib::Ogg::Vorbis::File(fileName, readProperties, propertiesStyle);
+ if (!result->isValid()) {
+ delete result;
+ result = new TagLib::Ogg::FLAC::File(fileName, readProperties, propertiesStyle);
+ }
+ } else if (suffix == QLatin1String("wma")) {
+ result = new TagLib::ASF::File(fileName, readProperties, propertiesStyle);
+ }
+ #endif //
+ else if (suffix == QLatin1String("m4a") || suffix == QLatin1String("m4b")
+ || suffix == QLatin1String("m4p") || suffix == QLatin1String("mp4")
+ /*|| suffix == QLatin1String("m4v") || suffix == QLatin1String("mp4v") */) {
result = new TagLib::MP4::File(fileName, readProperties, propertiesStyle);
}
- else if( suffix == QLatin1String("wav") )
- {
+ else if (suffix == QLatin1String("wav")) {
result = new TagLib::RIFF::WAV::File(fileName, readProperties, propertiesStyle);
}
- else if( suffix == QLatin1String("wma")
- /*|| suffix == QLatin1String("asf")*/ )
- {
+ else if (suffix == QLatin1String("wma") /*|| suffix == QLatin1String("asf")*/) {
result = new TagLib::ASF::File(fileName, readProperties, propertiesStyle);
}
// #ifndef Q_OS_WIN
-// if( !result )
+// if (!result)
// qDebug() << "kmimetype filetype guessing failed for" << fileName;
// #endif
- if( result && !result->isValid() ) {
+ if (result && !result->isValid()) {
delete result;
result = 0;
}
diff --git a/devices/freespaceinfo.cpp b/devices/freespaceinfo.cpp
new file mode 100644
index 000000000..1bc83eed9
--- /dev/null
+++ b/devices/freespaceinfo.cpp
@@ -0,0 +1,87 @@
+/*
+ * Cantata
+ *
+ * Copyright (c) 2011-2012 Craig Drummond
+ *
+ * ----
+ *
+ * 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 2 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; see the file COPYING. If not, write to
+ * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ */
+
+#include "freespaceinfo.h"
+#ifdef ENABLE_KDE_SUPPORT
+#include
+#elif defined(Q_OS_UNIX)
+#include
+#elif defined Q_OS_WIN
+#include "windows.h"
+#endif
+
+FreeSpaceInfo::FreeSpaceInfo(const QString &path)
+ : location(path)
+ , isDirty(true)
+ , totalSize(0)
+ , usedSpace(0)
+{
+}
+
+void FreeSpaceInfo::setPath(const QString &path)
+{
+ if (location!=path) {
+ location=path;
+ isDirty=true;
+ }
+}
+
+qulonglong FreeSpaceInfo::size()
+{
+ if (isDirty) {
+ update();
+ }
+ return totalSize;
+}
+
+qulonglong FreeSpaceInfo::used()
+{
+ if (isDirty) {
+ update();
+ }
+ return usedSpace;
+}
+
+void FreeSpaceInfo::update()
+{
+ #ifdef ENABLE_KDE_SUPPORT
+ KDiskFreeSpaceInfo inf=KDiskFreeSpaceInfo::freeSpaceInfo(location);
+ totalSize=inf.size();
+ usedSpace=inf.used();
+ #elif defined(Q_OS_UNIX)
+ struct statvfs fs_info;
+ if (0==statvfs(location.toLocal8Bit().constData(), &fs_info)) {
+ totalSize=quint64(fs_info.f_blocks) * quint64(fs_info.f_bsize);
+ usedSpace=totalSize-(quint64(fs_info.f_bavail) * quint64(fs_info.f_bsize));
+ }
+ #elif defined(Q_OS_WIN32)
+ _ULARGE_INTEGER totalRet;
+ _ULARGE_INTEGER freeRet;
+ if (0!=GetDiskFreeSpaceEx(QDir::toNativeSeparators(location).toLocal8Bit().constData(), &freeRet, &totalRet, NULL)) {
+ totalSize=totalRet.QuadPart;
+ usedSpace=totalRet.QuadPart-freeRet.QuadPart;
+ }
+ #endif
+ isDirty=false;
+}
+
diff --git a/devices/freespaceinfo.h b/devices/freespaceinfo.h
new file mode 100644
index 000000000..bf8f7b650
--- /dev/null
+++ b/devices/freespaceinfo.h
@@ -0,0 +1,49 @@
+/*
+ * Cantata
+ *
+ * Copyright (c) 2011-2012 Craig Drummond
+ *
+ * ----
+ *
+ * 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 2 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; see the file COPYING. If not, write to
+ * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ */
+
+#ifndef FREESPACEINFO_H
+#define FREESPACEINFO_H
+
+#include
+
+class FreeSpaceInfo
+{
+public:
+ FreeSpaceInfo(const QString &path=QString());
+
+ void setPath(const QString &path);
+ void setDirty() { isDirty=true; }
+ quint64 size();
+ quint64 used();
+
+private:
+ void update();
+
+private:
+ QString location;
+ bool isDirty;
+ quint64 totalSize;
+ quint64 usedSpace;
+};
+
+#endif
diff --git a/devices/fsdevice.cpp b/devices/fsdevice.cpp
index d5aa4f73f..d3693c3e2 100644
--- a/devices/fsdevice.cpp
+++ b/devices/fsdevice.cpp
@@ -42,11 +42,6 @@
#include
#include
#include
-#include
-#include
-#include
-#include
-#include
static const QLatin1String constCantataCacheFile("/.cache.xml");
@@ -231,8 +226,7 @@ void FsDevice::addSong(const Song &s, bool overwrite)
return;
}
- KUrl dest(destFile);
- QDir dir(dest.directory());
+ QDir dir(Utils::getDir(destFile));
if(!dir.exists() && !Utils::createDir(dir.absolutePath(), QString())) {
emit actionStatus(DirCreationFaild);
}
@@ -240,15 +234,14 @@ void FsDevice::addSong(const Song &s, bool overwrite)
currentSong=s;
if (encoder.codec.isEmpty() || (opts.transcoderWhenDifferent && !encoder.isDifferent(s.file))) {
transcoding=false;
- KIO::FileCopyJob *job=KIO::file_copy(KUrl(s.file), dest, -1, KIO::HideProgressInfo|(overwrite ? KIO::Overwrite : KIO::DefaultFlags));
- connect(job, SIGNAL(result(KJob *)), SLOT(addSongResult(KJob *)));
- connect(job, SIGNAL(percent(KJob *, unsigned long)), SLOT(percent(KJob *, unsigned long)));
+ CopyJob *job=new CopyJob(s.file, destFile);
+ connect(job, SIGNAL(result(int)), SLOT(addSongResult(int)));
+ connect(job, SIGNAL(percent(int)), SLOT(percent(int)));
} else {
transcoding=true;
TranscodingJob *job=new TranscodingJob(encoder.params(opts.transcoderValue, s.file, destFile));
- connect(job, SIGNAL(result(KJob *)), SLOT(addSongResult(KJob *)));
- connect(job, SIGNAL(percent(KJob *, unsigned long)), SLOT(percent(KJob *, unsigned long)));
- job->start();
+ connect(job, SIGNAL(result(int)), SLOT(addSongResult(int)));
+ connect(job, SIGNAL(percent(int)), SLOT(percent(int)));
}
}
@@ -288,17 +281,17 @@ void FsDevice::copySongTo(const Song &s, const QString &baseDir, const QString &
currentBaseDir=baseDir;
currentMusicPath=musicPath;
- KUrl dest(currentBaseDir+currentMusicPath);
- QDir dir(dest.directory());
+ QString dest(currentBaseDir+currentMusicPath);
+ QDir dir(Utils::getDir(dest));
if (!dir.exists() && !Utils::createDir(dir.absolutePath(), baseDir)) {
emit actionStatus(DirCreationFaild);
return;
}
currentSong=s;
- KIO::FileCopyJob *job=KIO::file_copy(KUrl(source), dest, -1, KIO::HideProgressInfo|(overwrite ? KIO::Overwrite : KIO::DefaultFlags));
- connect(job, SIGNAL(result(KJob *)), SLOT(copySongToResult(KJob *)));
- connect(job, SIGNAL(percent(KJob *, unsigned long)), SLOT(percent(KJob *, unsigned long)));
+ CopyJob *job=new CopyJob(source, dest);
+ connect(job, SIGNAL(result(int)), SLOT(copySongToResult(int)));
+ connect(job, SIGNAL(percent(int)), SLOT(percent(int)));
}
void FsDevice::removeSong(const Song &s)
@@ -317,8 +310,8 @@ void FsDevice::removeSong(const Song &s)
}
currentSong=s;
- KIO::SimpleJob *job=KIO::file_delete(KUrl(audioFolder+s.file), KIO::HideProgressInfo);
- connect(job, SIGNAL(result(KJob *)), SLOT(removeSongResult(KJob *)));
+ DeleteJob *job=new DeleteJob(audioFolder+s.file);
+ connect(job, SIGNAL(result(int)), SLOT(removeSongResult(int)));
}
void FsDevice::cleanDirs(const QSet &dirs)
@@ -328,28 +321,33 @@ void FsDevice::cleanDirs(const QSet &dirs)
}
}
-void FsDevice::percent(KJob *job, unsigned long percent)
+void FsDevice::percent(int percent)
{
if (jobAbortRequested && 100!=percent) {
- job->kill(KJob::EmitResult);
+ FileJob *job=qobject_cast(sender());
+ if (job) {
+ job->stop();
+ }
return;
}
emit progress(percent);
}
-void FsDevice::addSongResult(KJob *job)
+void FsDevice::addSongResult(int status)
{
+ spaceInfo.setDirty();
QString destFileName=opts.createFilename(currentSong);
if (transcoding) {
destFileName=encoder.changeExtension(destFileName);
}
if (jobAbortRequested) {
- if (0!=job->percent() && 100!=job->percent() && QFile::exists(audioFolder+destFileName)) {
+ FileJob *job=qobject_cast(sender());
+ if (job && job->wasStarted() && QFile::exists(audioFolder+destFileName)) {
QFile::remove(audioFolder+destFileName);
}
return;
}
- if (job->error()) {
+ if (FileJob::StatusOk!=status) {
emit actionStatus(transcoding ? TranscodeFailed : Failed);
} else {
QString sourceDir=MPDParseUtils::getDir(currentSong.file);
@@ -367,15 +365,17 @@ void FsDevice::addSongResult(KJob *job)
}
}
-void FsDevice::copySongToResult(KJob *job)
+void FsDevice::copySongToResult(int status)
{
+ spaceInfo.setDirty();
if (jobAbortRequested) {
- if (0!=job->percent() && 100!=job->percent() && QFile::exists(currentBaseDir+currentMusicPath)) {
+ FileJob *job=qobject_cast(sender());
+ if (job && job->wasStarted() && QFile::exists(currentBaseDir+currentMusicPath)) {
QFile::remove(currentBaseDir+currentMusicPath);
}
return;
}
- if (job->error()) {
+ if (FileJob::StatusOk!=status) {
emit actionStatus(Failed);
} else {
QString sourceDir=MPDParseUtils::getDir(currentSong.file);
@@ -391,12 +391,13 @@ void FsDevice::copySongToResult(KJob *job)
}
}
-void FsDevice::removeSongResult(KJob *job)
+void FsDevice::removeSongResult(int status)
{
+ spaceInfo.setDirty();
if (jobAbortRequested) {
return;
}
- if (job->error()) {
+ if (FileJob::StatusOk!=status) {
emit actionStatus(Failed);
} else {
removeSongFromList(currentSong);
diff --git a/devices/fsdevice.h b/devices/fsdevice.h
index 80bb313ee..25b604f45 100644
--- a/devices/fsdevice.h
+++ b/devices/fsdevice.h
@@ -27,7 +27,7 @@
#include "device.h"
#include "song.h"
#include "utils.h"
-#include
+#include "freespaceinfo.h"
#include
#include
@@ -97,16 +97,17 @@ protected:
protected Q_SLOTS:
void cacheRead();
void libraryUpdated();
- void percent(KJob *job, unsigned long percent);
- void addSongResult(KJob *job);
- void copySongToResult(KJob *job);
- void removeSongResult(KJob *job);
+ void percent(int percent);
+ void addSongResult(int status);
+ void copySongToResult(int status);
+ void removeSongResult(int status);
protected:
bool scanned;
MusicScanner *scanner;
QString audioFolder;
QString coverFileName;
+ FreeSpaceInfo spaceInfo;
};
#endif
diff --git a/devices/mediadevicecache.cpp b/devices/mediadevicecache.cpp
index 12caae9cb..a27cf593d 100644
--- a/devices/mediadevicecache.cpp
+++ b/devices/mediadevicecache.cpp
@@ -22,6 +22,7 @@
#include "mediadevicecache.h"
+#ifdef ENABLE_KDE_SUPPORT
#include
#include
#include
@@ -35,10 +36,21 @@
#include
#include
#include
-
#include
-
#include
+#else
+#include "solid-lite/device.h"
+#include "solid-lite/deviceinterface.h"
+#include "solid-lite/devicenotifier.h"
+#include "solid-lite/genericinterface.h"
+#include "solid-lite/opticaldisc.h"
+#include "solid-lite/portablemediaplayer.h"
+#include "solid-lite/storageaccess.h"
+#include "solid-lite/storagedrive.h"
+#include "solid-lite/block.h"
+#include "solid-lite/storagevolume.h"
+#include
+#endif
#include
#include
@@ -57,14 +69,10 @@ MediaDeviceCache::MediaDeviceCache() : QObject()
{
DEBUG_BLOCK
s_instance = this;
- connect( Solid::DeviceNotifier::instance(), SIGNAL( deviceAdded( const QString & ) ),
- this, SLOT( slotAddSolidDevice( const QString & ) ) );
- connect( Solid::DeviceNotifier::instance(), SIGNAL( deviceRemoved( const QString & ) ),
- this, SLOT( slotRemoveSolidDevice( const QString & ) ) );
-// connect(&m_timer, SIGNAL(timeout()), this, SLOT(slotTimeout()));
-
-// m_timer.setSingleShot(true);
-// m_timer.start(1000);
+ connect(Solid::DeviceNotifier::instance(), SIGNAL(deviceAdded(const QString &)),
+ this, SLOT(slotAddDevice(const QString &)));
+ connect(Solid::DeviceNotifier::instance(), SIGNAL(deviceRemoved(const QString &)),
+ this, SLOT(slotRemoveDevice(const QString &)));
}
MediaDeviceCache::~MediaDeviceCache()
@@ -72,176 +80,144 @@ MediaDeviceCache::~MediaDeviceCache()
s_instance = 0;
}
-void
-MediaDeviceCache::refreshCache()
+void MediaDeviceCache::refreshCache()
{
DEBUG_BLOCK
m_type.clear();
m_name.clear();
- QList deviceList = Solid::Device::listFromType( Solid::DeviceInterface::PortableMediaPlayer );
- foreach( const Solid::Device &device, deviceList )
- {
- if( device.as() )
- {
+ QList deviceList = Solid::Device::listFromType(Solid::DeviceInterface::PortableMediaPlayer);
+ foreach (const Solid::Device &device, deviceList) {
+ if (device.as()) {
debug() << "Found Solid PMP that is also a StorageDrive, skipping";
continue;
}
debug() << "Found Solid::DeviceInterface::PortableMediaPlayer with udi = " << device.udi();
debug() << "Device name is = " << device.product() << " and was made by " << device.vendor();
- m_type[device.udi()] = MediaDeviceCache::SolidPMPType;
+ m_type[device.udi()] = MediaDeviceCache::PMPType;
m_name[device.udi()] = device.vendor() + " - " + device.product();
}
- deviceList = Solid::Device::listFromType( Solid::DeviceInterface::StorageAccess );
- foreach( const Solid::Device &device, deviceList )
+ deviceList = Solid::Device::listFromType(Solid::DeviceInterface::StorageAccess);
+ foreach (const Solid::Device &device, deviceList)
{
debug() << "Found Solid::DeviceInterface::StorageAccess with udi = " << device.udi();
debug() << "Device name is = " << device.product() << " and was made by " << device.vendor();
const Solid::StorageAccess* ssa = device.as();
- if( ssa )
- {
+ if (ssa) {
// Commented out - as we want a signal when any storage device is added/removed - so we can check for MPD dir accessibility.
// device.cpp contains the check to ensure the device is a USB bevice before adding it to the list...
-// if( (!device.parent().as() || Solid::StorageDrive::Usb!=device.parent().as()->bus()) &&
-// (!device.as() || Solid::StorageDrive::Usb!=device.as()->bus()) )
-// {
+// if ((!device.parent().as() || Solid::StorageDrive::Usb!=device.parent().as()->bus()) &&
+// (!device.as() || Solid::StorageDrive::Usb!=device.as()->bus())) {
// debug() << "Found Solid::DeviceInterface::StorageAccess that is not usb, skipping";
// continue;
// }
- if( !m_volumes.contains( device.udi() ) )
- {
- connect( ssa, SIGNAL( accessibilityChanged(bool, const QString&) ),
- this, SLOT( slotAccessibilityChanged(bool, const QString&) ) );
- m_volumes.append( device.udi() );
+ if (!m_volumes.contains(device.udi())) {
+ connect(ssa, SIGNAL(accessibilityChanged(bool, const QString&)),
+ this, SLOT(slotAccessibilityChanged(bool, const QString&)));
+ m_volumes.append(device.udi());
}
- if( ssa->isAccessible() )
- {
- m_type[device.udi()] = MediaDeviceCache::SolidVolumeType;
+ if (ssa->isAccessible()) {
+ m_type[device.udi()] = MediaDeviceCache::VolumeType;
m_name[device.udi()] = ssa->filePath();
m_accessibility[ device.udi() ] = true;
- }
- else
- {
+ } else {
m_accessibility[ device.udi() ] = false;
debug() << "Solid device is not accessible, will wait until it is to consider it added.";
}
}
}
-// deviceList = Solid::Device::listFromType( Solid::DeviceInterface::StorageDrive );
-// foreach( const Solid::Device &device, deviceList )
-// {
+// deviceList = Solid::Device::listFromType(Solid::DeviceInterface::StorageDrive);
+// foreach (const Solid::Device &device, deviceList) {
// debug() << "Found Solid::DeviceInterface::StorageDrive with udi = " << device.udi();
// debug() << "Device name is = " << device.product() << " and was made by " << device.vendor();
//
-// if( device.as() )
-// {
-// m_type[device.udi()] = MediaDeviceCache::SolidGenericType;
+// if (device.as()) {
+// m_type[device.udi()] = MediaDeviceCache::GenericType;
// m_name[device.udi()] = device.vendor() + " - " + device.product();
// }
// }
-// deviceList = Solid::Device::listFromType( Solid::DeviceInterface::OpticalDisc );
-// foreach( const Solid::Device &device, deviceList )
-// {
+// deviceList = Solid::Device::listFromType(Solid::DeviceInterface::OpticalDisc);
+// foreach (const Solid::Device &device, deviceList) {
// debug() << "Found Solid::DeviceInterface::OpticalDisc with udi = " << device.udi();
// debug() << "Device name is = " << device.product() << " and was made by " << device.vendor();
//
// const Solid::OpticalDisc * opt = device.as();
//
-// if ( opt && opt->availableContent() & Solid::OpticalDisc::Audio )
-// {
+// if (opt && opt->availableContent() & Solid::OpticalDisc::Audio) {
// debug() << "device is an Audio CD";
-// m_type[device.udi()] = MediaDeviceCache::SolidAudioCdType;
+// m_type[device.udi()] = MediaDeviceCache::AudioCdType;
// m_name[device.udi()] = device.vendor() + " - " + device.product();
// }
// }
// deviceList = Solid::Device::allDevices();
-// foreach( const Solid::Device &device, deviceList )
-// {
-// if( const Solid::GenericInterface *generic = device.as() )
-// {
-// if( m_type.contains( device.udi() ) )
+// foreach (const Solid::Device &device, deviceList) {
+// if (const Solid::GenericInterface *generic = device.as()) {
+// if (m_type.contains(device.udi()))
// continue;
//
// const QMap properties = generic->allProperties();
-// if( !properties.contains("info.capabilities") )
+// if (!properties.contains("info.capabilities"))
// continue;
//
// const QStringList capabilities = properties["info.capabilities"].toStringList();
-// if( !capabilities.contains("afc") )
+// if (!capabilities.contains("afc"))
// continue;
//
// debug() << "Found AFC capable Solid::DeviceInterface::GenericInterface with udi = " << device.udi();
// debug() << "Device name is = " << device.product() << " and was made by " << device.vendor();
//
-// m_type[device.udi()] = MediaDeviceCache::SolidGenericType;
+// m_type[device.udi()] = MediaDeviceCache::GenericType;
// m_name[device.udi()] = device.vendor() + " - " + device.product();
// }
// }
-// KConfigGroup config(KGlobal::config(), "PortableDevices" );
+// KConfigGroup config(KGlobal::config(), "PortableDevices");
// const QStringList manualDeviceKeys = config.entryMap().keys();
-// foreach( const QString &udi, manualDeviceKeys )
-// {
-// if( udi.startsWith( "manual" ) )
-// {
+// foreach (const QString &udi, manualDeviceKeys) {
+// if (udi.startsWith("manual")) {
// debug() << "Found manual device with udi = " << udi;
// m_type[udi] = MediaDeviceCache::ManualType;
-// m_name[udi] = udi.split( '|' )[1];
+// m_name[udi] = udi.split('|')[1];
// }
// }
}
-void
-MediaDeviceCache::slotAddSolidDevice( const QString &udi )
+void MediaDeviceCache::slotAddDevice(const QString &udi)
{
DEBUG_BLOCK
- Solid::Device device( udi );
+ Solid::Device device(udi);
debug() << "Found new Solid device with udi = " << device.udi();
debug() << "Device name is = " << device.product() << " and was made by " << device.vendor();
Solid::StorageAccess *ssa = device.as();
-
Solid::OpticalDisc * opt = device.as();
- if ( opt && opt->availableContent() & Solid::OpticalDisc::Audio )
- {
+ if (opt && opt->availableContent() & Solid::OpticalDisc::Audio) {
debug() << "device is an Audio CD";
- m_type[udi] = MediaDeviceCache::SolidAudioCdType;
+ m_type[udi] = MediaDeviceCache::AudioCdType;
m_name[udi] = device.vendor() + " - " + device.product();
- }
- else if( ssa )
- {
+ } else if (ssa) {
debug() << "volume is generic storage";
- if( !m_volumes.contains( device.udi() ) )
- {
- connect( ssa, SIGNAL( accessibilityChanged(bool, const QString&) ),
- this, SLOT( slotAccessibilityChanged(bool, const QString&) ) );
- m_volumes.append( device.udi() );
+ if (!m_volumes.contains(device.udi())) {
+ connect(ssa, SIGNAL(accessibilityChanged(bool, const QString&)),
+ this, SLOT(slotAccessibilityChanged(bool, const QString&)));
+ m_volumes.append(device.udi());
}
- if( ssa->isAccessible() )
- {
- m_type[udi] = MediaDeviceCache::SolidVolumeType;
+ if (ssa->isAccessible()) {
+ m_type[udi] = MediaDeviceCache::VolumeType;
m_name[udi] = ssa->filePath();
- }
- else
- {
+ } else {
debug() << "storage volume is not accessible right now, not adding.";
return;
}
- }
- else if( device.is() )
- {
+ } else if (device.is()) {
debug() << "device is a Storage drive, still need a volume";
- m_type[udi] = MediaDeviceCache::SolidGenericType;
+ m_type[udi] = MediaDeviceCache::GenericType;
m_name[udi] = device.vendor() + " - " + device.product();
- }
- else if( device.is() )
- {
+ } else if (device.is()) {
debug() << "device is a PMP";
- m_type[udi] = MediaDeviceCache::SolidPMPType;
+ m_type[udi] = MediaDeviceCache::PMPType;
m_name[udi] = device.vendor() + " - " + device.product();
- }
- else if( const Solid::GenericInterface *generic = device.as() )
- {
+ } else if (const Solid::GenericInterface *generic = device.as()) {
const QMap properties = generic->allProperties();
/* At least iPod touch 3G and iPhone 3G do not advertise AFC (Apple File
* Connection) capabilities. Therefore we have to white-list them so that they are
@@ -250,207 +226,88 @@ MediaDeviceCache::slotAddSolidDevice( const QString &udi )
* @see IpodConnectionAssistant::identify() for a quirk that is currently also
* needed for proper identification of iPhone-like devices.
*/
- if ( !device.product().contains("iPod") && !device.product().contains("iPhone"))
- {
- if( !properties.contains("info.capabilities") )
- {
+ if (!device.product().contains("iPod") && !device.product().contains("iPhone")) {
+ if (!properties.contains("info.capabilities")) {
debug() << "udi " << udi << " does not describe a portable media player or storage volume";
return;
}
const QStringList capabilities = properties["info.capabilities"].toStringList();
- if( !capabilities.contains("afc") )
- {
+ if (!capabilities.contains("afc")) {
debug() << "udi " << udi << " does not describe a portable media player or storage volume";
return;
}
}
debug() << "udi" << udi << "is AFC cabable (Apple mobile device)";
- m_type[udi] = MediaDeviceCache::SolidGenericType;
+ m_type[udi] = MediaDeviceCache::GenericType;
m_name[udi] = device.vendor() + " - " + device.product();
- }
- else
- {
+ } else {
debug() << "udi " << udi << " does not describe a portable media player or storage volume";
return;
}
- emit deviceAdded( udi );
+ emit deviceAdded(udi);
}
-void
-MediaDeviceCache::slotRemoveSolidDevice( const QString &udi )
+void MediaDeviceCache::slotRemoveDevice(const QString &udi)
{
DEBUG_BLOCK
debug() << "udi is: " << udi;
- Solid::Device device( udi );
- if( m_volumes.contains( udi ) )
- {
- disconnect( device.as(), SIGNAL( accessibilityChanged(bool, const QString&) ),
- this, SLOT( slotAccessibilityChanged(bool, const QString&) ) );
- m_volumes.removeAll( udi );
- emit deviceRemoved( udi );
+ Solid::Device device(udi);
+ if (m_volumes.contains(udi)) {
+ disconnect(device.as(), SIGNAL(accessibilityChanged(bool, const QString&)),
+ this, SLOT(slotAccessibilityChanged(bool, const QString&)));
+ m_volumes.removeAll(udi);
+// emit deviceRemoved(udi);
}
- if( m_type.contains( udi ) )
- {
- m_type.remove( udi );
- m_name.remove( udi );
- emit deviceRemoved( udi );
- return;
+ if (m_type.contains(udi)) {
+ m_type.remove(udi);
+ m_name.remove(udi);
+// emit deviceRemoved(udi);
}
debug() << "Odd, got a deviceRemoved at udi " << udi << " but it did not seem to exist in the first place...";
- emit deviceRemoved( udi );
+ emit deviceRemoved(udi);
}
-// void MediaDeviceCache::slotTimeout()
-// {
-// KMountPoint::List possibleMountList = KMountPoint::possibleMountPoints();
-// KMountPoint::List currentMountList = KMountPoint::currentMountPoints();
-// QList deviceList = Solid::Device::listFromType( Solid::DeviceInterface::StorageAccess );
-//
-// for (KMountPoint::List::iterator it = possibleMountList.begin(); it != possibleMountList.end(); ++it) {
-// if ((*it)->mountType() == "nfs" || (*it)->mountType() == "nfs4" ||
-// (*it)->mountType() == "smb" || (*it)->mountType() == "cifs") {
-// QString path = (*it)->mountPoint();
-// bool mounted = false;
-// QString udi = QString();
-//
-// foreach( const Solid::Device &device, deviceList )
-// {
-// const Solid::StorageAccess* ssa = device.as();
-// if( ssa && path == ssa->filePath())
-// udi = device.udi();
-// }
-//
-// for (KMountPoint::List::iterator it2 = currentMountList.begin(); it2 != currentMountList.end(); ++it2) {
-// if ( (*it)->mountType() == (*it2)->mountType() &&
-// (*it)->mountPoint() == (*it2)->mountPoint() ) {
-// mounted = true;
-// break;
-// }
-// }
-//
-// if ( m_accessibility[udi] != mounted ) {
-// m_accessibility[udi] = mounted;
-// slotAccessibilityChanged( mounted, udi);
-// }
-// }
-// }
-//
-// m_timer.setSingleShot(true);
-// m_timer.start(1000);
-// }
-
-void
-MediaDeviceCache::slotAccessibilityChanged( bool accessible, const QString &udi )
+void MediaDeviceCache::slotAccessibilityChanged(bool accessible, const QString &udi)
{
debug() << "accessibility of device " << udi << " has changed to accessible = " << (accessible ? "true":"false");
- if( accessible )
- {
- Solid::Device device( udi );
- m_type[udi] = MediaDeviceCache::SolidVolumeType;
+ if (accessible) {
+ Solid::Device device(udi);
+ m_type[udi] = MediaDeviceCache::VolumeType;
Solid::StorageAccess *ssa = device.as();
- if( ssa )
+ if (ssa) {
m_name[udi] = ssa->filePath();
- emit deviceAdded( udi );
+ }
+ emit deviceAdded(udi);
return;
- }
- else
- {
- if( m_type.contains( udi ) )
- {
- m_type.remove( udi );
- m_name.remove( udi );
- emit deviceRemoved( udi );
+ } else {
+ if (m_type.contains(udi)) {
+ m_type.remove(udi);
+ m_name.remove(udi);
+ emit deviceRemoved(udi);
return;
}
debug() << "Got accessibility changed to false but was not there in the first place...";
}
- emit accessibilityChanged( accessible, udi );
+ emit accessibilityChanged(accessible, udi);
}
-MediaDeviceCache::DeviceType
-MediaDeviceCache::deviceType( const QString &udi ) const
+MediaDeviceCache::DeviceType MediaDeviceCache::deviceType(const QString &udi) const
{
- if( m_type.contains( udi ) )
- {
+ if (m_type.contains(udi)) {
return m_type[udi];
}
return MediaDeviceCache::InvalidType;
}
-const QString
-MediaDeviceCache::deviceName( const QString &udi ) const
+const QString MediaDeviceCache::deviceName(const QString &udi) const
{
- if( m_name.contains( udi ) )
- {
+ if (m_name.contains(udi)) {
return m_name[udi];
}
return "ERR_NO_NAME"; //Should never happen!
}
-const QString
-MediaDeviceCache::device( const QString &udi ) const
-{
- DEBUG_BLOCK
- Solid::Device device( udi );
- Solid::Device parent( device.parent() );
- if( !parent.isValid() )
- {
- debug() << udi << "has no parent, returning null string.";
- return QString();
- }
-
- Solid::Block* sb = parent.as();
- if( !sb )
- {
- debug() << parent.udi() << "failed to convert to Block, returning null string.";
- return QString();
- }
-
- return sb->device();
-}
-
-bool
-MediaDeviceCache::isGenericEnabled( const QString &udi ) const
-{
- DEBUG_BLOCK
- if( m_type[udi] != MediaDeviceCache::SolidVolumeType )
- {
- debug() << "Not SolidVolumeType, returning false";
- return false;
- }
- Solid::Device device( udi );
- Solid::StorageAccess* ssa = device.as();
- if( !ssa || !ssa->isAccessible() )
- {
- debug() << "Not able to convert to StorageAccess or not accessible, returning false";
- return false;
- }
- if( device.parent().as() )
- {
- debug() << "Could convert parent to PortableMediaPlayer, returning true";
- return true;
- }
- if( QFile::exists( ssa->filePath() + QDir::separator() + ".is_audio_player" ) )
- {
- return true;
- }
- return false;
-}
-
-const QString
-MediaDeviceCache::volumeMountPoint( const QString &udi ) const
-{
- DEBUG_BLOCK
- Solid::Device device( udi );
- Solid::StorageAccess* ssa = device.as();
- if( !ssa || !ssa->isAccessible() )
- {
- debug() << "Not able to convert to StorageAccess or not accessible, returning empty";
- return QString();
- }
- return ssa->filePath();
-}
diff --git a/devices/mediadevicecache.h b/devices/mediadevicecache.h
index 5f4cd8604..bc3a60897 100644
--- a/devices/mediadevicecache.h
+++ b/devices/mediadevicecache.h
@@ -27,55 +27,45 @@
#include
#include
#include
-// #include
-
-namespace Solid {
- class Device;
-}
class MediaDeviceCache : public QObject
{
Q_OBJECT
- public:
+public:
- enum DeviceType { SolidPMPType, SolidVolumeType, ManualType, SolidAudioCdType, SolidGenericType, InvalidType };
+ enum DeviceType { PMPType, VolumeType, ManualType, AudioCdType, GenericType, InvalidType };
- static MediaDeviceCache* self() { return s_instance ? s_instance : new MediaDeviceCache(); }
+ static MediaDeviceCache* self() { return s_instance ? s_instance : new MediaDeviceCache(); }
- /**
- * Creates a new MediaDeviceCache.
- *
- */
- MediaDeviceCache();
- ~MediaDeviceCache();
+ /**
+ * Creates a new MediaDeviceCache.
+ *
+ */
+ MediaDeviceCache();
+ ~MediaDeviceCache();
- void refreshCache();
- const QStringList getAll() const { return m_type.keys(); }
- MediaDeviceCache::DeviceType deviceType( const QString &udi ) const;
- const QString deviceName( const QString &udi ) const;
- const QString device( const QString & udi ) const;
- bool isGenericEnabled( const QString &udi ) const;
- const QString volumeMountPoint( const QString &udi ) const;
+ void refreshCache();
+ const QStringList getAll() const { return m_type.keys(); }
+ MediaDeviceCache::DeviceType deviceType( const QString &udi ) const;
+ const QString deviceName( const QString &udi ) const;
- Q_SIGNALS:
- void deviceAdded( const QString &udi );
- void deviceRemoved( const QString &udi );
- void accessibilityChanged( bool accessible, const QString &udi );
+Q_SIGNALS:
+ void deviceAdded( const QString &udi );
+ void deviceRemoved( const QString &udi );
+ void accessibilityChanged( bool accessible, const QString &udi );
- public Q_SLOTS:
- void slotAddSolidDevice( const QString &udi );
- void slotRemoveSolidDevice( const QString &udi );
- void slotAccessibilityChanged( bool accessible, const QString &udi );
-// void slotTimeout();
+public Q_SLOTS:
+ void slotAddDevice( const QString &udi );
+ void slotRemoveDevice( const QString &udi );
+ void slotAccessibilityChanged( bool accessible, const QString &udi );
- private:
- QMap m_type;
- QMap m_name;
- QMap m_accessibility;
- QStringList m_volumes;
- static MediaDeviceCache* s_instance;
-// QTimer m_timer;
+private:
+ QMap m_type;
+ QMap m_name;
+ QMap m_accessibility;
+ QStringList m_volumes;
+ static MediaDeviceCache* s_instance;
};
#endif /* AMAROK_MEDIADEVICECACHE_H */
diff --git a/devices/mtpdevice.cpp b/devices/mtpdevice.cpp
index f0dac21ac..e72149a3b 100644
--- a/devices/mtpdevice.cpp
+++ b/devices/mtpdevice.cpp
@@ -37,14 +37,15 @@
#include "utils.h"
#include "mpdparseutils.h"
#include "localize.h"
+#include "filejob.h"
+#include "settings.h"
#include
#include
#include
-#include
-#include
-#include
+#include
+#ifdef ENABLE_KDE_SUPPORT
#include
-#include
+#endif
#include
#include
#include
@@ -353,6 +354,7 @@ static char * createString(const QString &str)
static LIBMTP_filetype_t mtpFileType(const Song &s)
{
+ #ifdef ENABLE_KDE_SUPPORT
KMimeType::Ptr mime=KMimeType::findByPath(s.file);
if (mime->is("audio/mpeg")) {
@@ -376,6 +378,29 @@ static LIBMTP_filetype_t mtpFileType(const Song &s)
if (mime->is("audio/x-wav")) {
return LIBMTP_FILETYPE_WAV;
}
+ #else
+ if (s.file.endsWith(".mp3", Qt::CaseInsensitive)) {
+ return LIBMTP_FILETYPE_MP3;
+ }
+ if (s.file.endsWith(".ogg", Qt::CaseInsensitive)) {
+ return LIBMTP_FILETYPE_OGG;
+ }
+ if (s.file.endsWith(".wma", Qt::CaseInsensitive)) {
+ return LIBMTP_FILETYPE_WMA;
+ }
+ if (s.file.endsWith(".m4a", Qt::CaseInsensitive)) {
+ return LIBMTP_FILETYPE_M4A; // LIBMTP_FILETYPE_MP4
+ }
+ if (s.file.endsWith(".aac", Qt::CaseInsensitive)) {
+ return LIBMTP_FILETYPE_AAC;
+ }
+ if (s.file.endsWith(".flac", Qt::CaseInsensitive)) {
+ return LIBMTP_FILETYPE_FLAC;
+ }
+ if (s.file.endsWith(".wav", Qt::CaseInsensitive)) {
+ return LIBMTP_FILETYPE_WAV;
+ }
+ #endif
return LIBMTP_FILETYPE_UNDEF_AUDIO;
}
@@ -398,14 +423,15 @@ void MtpConnection::putSong(const Song &s, bool fixVa)
}
meta->item_id=0;
QString fileName=song.file;
- KTemporaryFile *temp=0;
+ QTemporaryFile *temp=0;
if (fixVa) {
// Need to 'workaround' broken various artists handling, so write to a temporary file first...
- temp=new KTemporaryFile();
int index=song.file.lastIndexOf('.');
if (index>0) {
- temp->setSuffix(song.file.mid(index));
+ temp=new QTemporaryFile("cantata_XXXX"+song.file.mid(index));
+ } else {
+ temp=new QTemporaryFile("cantata_XXXX");
}
temp->setAutoRemove(false);
if (temp->open()) {
@@ -536,7 +562,10 @@ void MtpDevice::deviceDetails(const QString &s)
serial=s;
QString configKey=cfgKey(solidDev, serial);
opts.load(configKey);
- configured=KGlobal::config()->hasGroup(configKey);
+ #ifndef ENABLE_KDE_SUPPORT
+ QSettings cfg;
+ #endif
+ configured=HAS_GROUP(configKey);
}
}
@@ -608,8 +637,7 @@ void MtpDevice::addSong(const Song &s, bool overwrite)
if (!opts.transcoderWhenDifferent || encoder.isDifferent(s.file)) {
deleteTemp();
- tempFile=new KTemporaryFile();
- tempFile->setSuffix("."+encoder.extension);
+ tempFile=new QTemporaryFile("cantata_XXXX"+encoder.extension);
tempFile->setAutoRemove(false);
if (!tempFile->open()) {
@@ -624,8 +652,8 @@ void MtpDevice::addSong(const Song &s, bool overwrite)
}
transcoding=true;
TranscodingJob *job=new TranscodingJob(encoder.params(opts.transcoderValue, s.file, destFile));
- connect(job, SIGNAL(result(KJob *)), SLOT(transcodeSongResult(KJob *)));
- connect(job, SIGNAL(percent(KJob *, unsigned long)), SLOT(transcodePercent(KJob *, unsigned long)));
+ connect(job, SIGNAL(result(int)), SLOT(transcodeSongResult(int)));
+ connect(job, SIGNAL(percent(int)), SLOT(transcodePercent(int)));
job->start();
currentSong.file=destFile;
return;
@@ -665,8 +693,8 @@ void MtpDevice::copySongTo(const Song &s, const QString &baseDir, const QString
currentBaseDir=baseDir;
currentMusicPath=musicPath;
- KUrl dest(currentBaseDir+currentMusicPath);
- QDir dir(dest.directory());
+ QString dest(currentBaseDir+currentMusicPath);
+ QDir dir(Utils::getDir(dest));
if (!dir.exists() && !Utils::createDir(dir.absolutePath(), baseDir)) {
emit actionStatus(DirCreationFaild);
return;
@@ -721,26 +749,28 @@ void MtpDevice::putSongStatus(bool ok, int id, const QString &file, bool fixedVa
}
}
-void MtpDevice::transcodeSongResult(KJob *job)
+void MtpDevice::transcodeSongResult(int status)
{
if (jobAbortRequested) {
deleteTemp();
return;
}
- if (job->error()) {
+ if (FileJob::StatusOk!=status) {
emit actionStatus(TranscodeFailed);
} else {
emit putSong(currentSong, needToFixVa);
}
}
-void MtpDevice::transcodePercent(KJob *job, unsigned long percent)
+void MtpDevice::transcodePercent(int percent)
{
if (jobAbortRequested) {
- job->kill(KJob::EmitResult); // emit result so that temp file can be removed!
+ FileJob *job=qobject_cast(sender());
+ if (job) {
+ job->stop();
+ }
return;
}
- Q_UNUSED(job)
emit progress(percent/2);
}
@@ -802,7 +832,7 @@ QString MtpDevice::capacityString()
return i18n("Not Connected");
}
- return i18n("%1 free", KGlobal::locale()->formatByteSize(connection->capacity()-connection->usedSpace()), 1);
+ return i18n("%1 free").arg(Utils::formatByteSize(connection->capacity()-connection->usedSpace()));
}
qint64 MtpDevice::freeSpace()
diff --git a/devices/mtpdevice.h b/devices/mtpdevice.h
index e570be8cf..5910b260c 100644
--- a/devices/mtpdevice.h
+++ b/devices/mtpdevice.h
@@ -26,14 +26,17 @@
#include "device.h"
#include "song.h"
+#ifdef ENABLE_KDE_SUPPORT
#include
+#else
+#include "solid-lite/portablemediaplayer.h"
+#endif
#include
class MusicLibraryItemRoot;
class QThread;
class MtpDevice;
-class KJob;
-class KTemporaryFile;
+class QTemporaryFile;
class MtpConnection : public QObject
{
@@ -134,8 +137,8 @@ private Q_SLOTS:
void libraryUpdated();
void rescan(bool full=true);
void putSongStatus(bool ok, int id, const QString &file, bool fixedVa);
- void transcodeSongResult(KJob *job);
- void transcodePercent(KJob *job, unsigned long percent);
+ void transcodeSongResult(int status);
+ void transcodePercent(int percent);
void emitProgress(unsigned long);
void getSongStatus(bool ok);
void delSongStatus(bool ok);
@@ -149,7 +152,7 @@ private:
Solid::PortableMediaPlayer *pmp;
QThread *thread;
MtpConnection *connection;
- KTemporaryFile *tempFile;
+ QTemporaryFile *tempFile;
Song currentSong;
bool mtpUpdating;
QString serial;
diff --git a/devices/remotedevicepropertiesdialog.cpp b/devices/remotedevicepropertiesdialog.cpp
index a964259a0..0055e79ef 100644
--- a/devices/remotedevicepropertiesdialog.cpp
+++ b/devices/remotedevicepropertiesdialog.cpp
@@ -27,9 +27,9 @@
#include "devicesmodel.h"
#include "localize.h"
#include "messagebox.h"
+#include "icon.h"
#include
#include
-#include
RemoteDevicePropertiesDialog::RemoteDevicePropertiesDialog(QWidget *parent)
: Dialog(parent)
@@ -43,7 +43,7 @@ RemoteDevicePropertiesDialog::RemoteDevicePropertiesDialog(QWidget *parent)
remoteProp=new RemoteDevicePropertiesWidget(tab);
devProp=new DevicePropertiesWidget(tab);
tab->addTab(remoteProp, QIcon::fromTheme("network-server"), i18n("Connection"));
- tab->addTab(devProp, KIcon("cantata-view-media-library"), i18n("Music Library"));
+ tab->addTab(devProp, Icon("cantata-view-media-library"), i18n("Music Library"));
setMainWidget(tab);
}
@@ -73,7 +73,7 @@ void RemoteDevicePropertiesDialog::slotButtonClicked(int button)
case Ok: {
RemoteFsDevice::Details d=remoteProp->details();
if (d.name!=remoteProp->origDetails().name && DevicesModel::self()->device(RemoteFsDevice::createUdi(d.name))) {
- MessageBox::error(this, i18n("A remote device named \"%1\" already exists!\nPlease choose a different name", d.name));
+ MessageBox::error(this, i18n("A remote device named \"%1\" already exists!\nPlease choose a different name").arg(d.name));
} else {
emit updatedSettings(devProp->cover(), devProp->settings(), remoteProp->details());
accept();
diff --git a/devices/remotedevicepropertieswidget.cpp b/devices/remotedevicepropertieswidget.cpp
index e47d781e4..ab63a9641 100644
--- a/devices/remotedevicepropertieswidget.cpp
+++ b/devices/remotedevicepropertieswidget.cpp
@@ -25,11 +25,12 @@
#include "filenameschemedialog.h"
#include "covers.h"
#include "localize.h"
-#include
-#include
+#ifdef ENABLE_KDE_SUPPORT
#include
+#endif
#include
#include
+#include
#include "lineedit.h"
#include "config.h"
@@ -49,15 +50,19 @@ RemoteDevicePropertiesWidget::RemoteDevicePropertiesWidget(QWidget *parent)
}
type->addItem(i18n("Secure Shell (sshfs)"), (int)Type_SshFs);
type->addItem(i18n("Locally Mounted Folder"), (int)Type_File);
+ #ifdef ENABLE_KDE_SUPPORT
sshFolderButton->setIcon(QIcon::fromTheme("document-open"));
fileFolder->setMode(KFile::Directory|KFile::ExistingOnly|KFile::LocalOnly);
kioUrl->setMode(KFile::Directory|KFile::ExistingOnly);
+ #else
+ sshFolderButton->setVisible(false);
+ #endif
}
void RemoteDevicePropertiesWidget::update(const RemoteFsDevice::Details &d, bool create, bool isConnected)
{
- int t=d.url.isLocalFile() ? Type_File : Type_SshFs;
- setEnabled(d.url.isLocalFile() || !isConnected);
+ int t=d.isLocalFile() ? Type_File : Type_SshFs;
+ setEnabled(d.isLocalFile() || !isConnected);
infoLabel->setVisible(create);
orig=d;
name->setText(d.name);
@@ -66,20 +71,26 @@ void RemoteDevicePropertiesWidget::update(const RemoteFsDevice::Details &d, bool
sshHost->setText(QString());
sshUser->setText(QString());
fileFolder->setText(QString());
+ #ifdef ENABLE_KDE_SUPPORT
kioUrl->setUrl(KUrl());
+ #else
+ kioUrl->setText(QString());
+ #endif
switch (t) {
- case Type_SshFs:
- sshFolder->setText(d.url.path());
- sshPort->setValue(d.url.port());
- sshHost->setText(d.url.host());
- sshUser->setText(d.url.user());
+ case Type_SshFs: {
+ QUrl url(d.url);
+ sshFolder->setText(url.path());
+ sshPort->setValue(url.port());
+ sshHost->setText(url.host());
+ sshUser->setText(url.userName());
break;
+ }
case Type_File:
- fileFolder->setText(d.url.path());
+ fileFolder->setText(d.url);
break;
}
- name->setEnabled(d.url.isLocalFile() || !isConnected);
+ name->setEnabled(d.isLocalFile() || !isConnected);
connect(type, SIGNAL(currentIndexChanged(int)), this, SLOT(setType()));
for (int i=1; icount(); ++i) {
@@ -111,6 +122,7 @@ void RemoteDevicePropertiesWidget::setType()
}
}
+#ifdef ENABLE_KDE_SUPPORT
void RemoteDevicePropertiesWidget::browseSftpFolder()
{
RemoteFsDevice::Details det=details();
@@ -125,13 +137,16 @@ void RemoteDevicePropertiesWidget::browseSftpFolder()
sshFolder->setText(url.path());
}
}
+#endif
void RemoteDevicePropertiesWidget::checkSaveable()
{
RemoteFsDevice::Details det=details();
modified=det!=orig;
saveable=!det.isEmpty();
- sshFolderButton->setEnabled(!det.url.host().isEmpty() && det.url.port()>0);
+ #ifdef ENABLE_KDE_SUPPORT
+ sshFolderButton->setEnabled(!det.url.isEmpty());
+ #endif
emit updated();
}
@@ -147,14 +162,14 @@ RemoteFsDevice::Details RemoteDevicePropertiesWidget::details()
QString u=sshUser->text().trimmed();
QString f=sshFolder->text().trimmed();
int p=sshPort->value();
- det.url=KUrl(RemoteFsDevice::constSshfsProtocol+QLatin1String("://")+ (u.isEmpty() ? QString() : (u+QChar('@')))
+ det.url=QString(RemoteFsDevice::constSshfsProtocol+QLatin1String("://")+ (u.isEmpty() ? QString() : (u+QChar('@')))
+ h + (p<=0 ? QString() : QString(QChar(':')+QString::number(p)))
+ (f.startsWith("/") ? f : (f.isEmpty() ? QString("/") : f)));
break;
}
case Type_File: {
QString f=fileFolder->text().trimmed();
- det.url=KUrl(QLatin1String("file://")+(f.startsWith("/") ? f : (f.isEmpty() ? QString("/") : f)));
+ det.url=QString(f.startsWith("/") ? f : (f.isEmpty() ? QString("/") : f));
break;
}
}
diff --git a/devices/remotedevicepropertieswidget.h b/devices/remotedevicepropertieswidget.h
index daeee1f3a..b786fa6a0 100644
--- a/devices/remotedevicepropertieswidget.h
+++ b/devices/remotedevicepropertieswidget.h
@@ -47,7 +47,9 @@ Q_SIGNALS:
private Q_SLOTS:
void checkSaveable();
void setType();
+ #ifdef ENABLE_KDE_SUPPORT
void browseSftpFolder();
+ #endif
private:
RemoteFsDevice::Details orig;
diff --git a/devices/remotedevicepropertieswidget.ui b/devices/remotedevicepropertieswidget.ui
index 8623d1e7c..450ad9d98 100644
--- a/devices/remotedevicepropertieswidget.ui
+++ b/devices/remotedevicepropertieswidget.ui
@@ -142,7 +142,7 @@
-
-
+
@@ -159,7 +159,7 @@
-
-
+
@@ -207,9 +207,9 @@
- KUrlRequester
- QFrame
-
+ DirRequester
+ QLineEdit
+
LineEdit
diff --git a/devices/remotefsdevice.cpp b/devices/remotefsdevice.cpp
index 1f1118e8a..cf8ff053c 100644
--- a/devices/remotefsdevice.cpp
+++ b/devices/remotefsdevice.cpp
@@ -30,15 +30,15 @@
#include "network.h"
#include "httpserver.h"
#include "localize.h"
+#include "settings.h"
#include
#include
-#include
-#include
-#include
-#include
-#include
+#include
+#include
+#ifdef ENABLE_KDE_SUPPORT
#include
#include
+#endif
#include
#include
@@ -46,70 +46,90 @@ const QLatin1String RemoteFsDevice::constSshfsProtocol("cantata-sshfs");
static QString mountPoint(const RemoteFsDevice::Details &details, bool create)
{
- if (details.url.isLocalFile()) {
- return details.url.path();
+ if (details.isLocalFile()) {
+ return details.url;
}
return Network::cacheDir(QLatin1String("mount/")+details.name, create);
}
void RemoteFsDevice::Details::load(const QString &group)
{
- KConfigGroup grp(KGlobal::config(), group);
- name=grp.readEntry("name", name);
- url=grp.readEntry("url", url);
+ #ifdef ENABLE_KDE_SUPPORT
+ KConfigGroup cfg(KGlobal::config(), group);
+ #else
+ QSettings cfg;
+ cfg.beginGroup(group);
+ #endif
+ name=GET_STRING("name", name);
+ url=GET_STRING("url", url);
+ #ifdef ENABLE_KDE_SUPPORT
if (url.isEmpty()) {
// Old, pre 0.7.0 remote device...
- QString folder=grp.readEntry("folder", QString());
+ QString folder=GET_STRING("folder", QString());
if (!folder.isEmpty()) {
- if (1==grp.readEntry("protocol", 0)) {
- QString host=grp.readEntry("host", QString());
- QString user=grp.readEntry("user", QString());
- int port=grp.readEntry("port", 0);
+ if (1==GET_INT("protocol", 0)) {
+ QString host=GET_STRING("host", QString());
+ QString user=GET_STRING("user", QString());
+ int port=GET_INT("port", 0);
- url=KUrl(RemoteFsDevice::constSshfsProtocol+QLatin1String("://")+ (user.isEmpty() ? QString() : (user+QChar('@')))
+ url=RemoteFsDevice::constSshfsProtocol+QLatin1String("://")+ (user.isEmpty() ? QString() : (user+QChar('@')))
+ host + (port<=0 ? QString() : QString(QChar(':')+QString::number(port)))
- + (folder.startsWith("/") ? folder : (folder.isEmpty() ? QString("/") : folder)));
+ + (folder.startsWith("/") ? folder : (folder.isEmpty() ? QString("/") : folder));
} else {
- url=KUrl(QLatin1String("file://")+(folder.startsWith("/") ? folder : (folder.isEmpty() ? QString("/") : folder)));
+ url=(folder.startsWith("/") ? folder : (folder.isEmpty() ? QString("/") : folder));
}
}
- grp.deleteEntry("protocol");
- grp.deleteEntry("folder");
- grp.deleteEntry("host");
- grp.deleteEntry("user");
- grp.deleteEntry("port");
- grp.writeEntry("url", url);
+ // These are in case of old (KDE-only) entries...
+ REMOVE_ENTRY("protocol");
+ REMOVE_ENTRY("folder");
+ REMOVE_ENTRY("host");
+ REMOVE_ENTRY("user");
+ REMOVE_ENTRY("port");
+ SET_VALUE("url", url);
}
+ if (url.startsWith("file://")) {
+ url=url.mid(7);
+ }
+ #endif
}
void RemoteFsDevice::Details::save(const QString &group) const
{
- KConfigGroup grp(KGlobal::config(), group);
- grp.writeEntry("name", name);
- grp.writeEntry("url", url);
- grp.sync();
+ #ifdef ENABLE_KDE_SUPPORT
+ KConfigGroup cfg(KGlobal::config(), group);
+ #else
+ QSettings cfg;
+ cfg.beginGroup(group);
+ #endif
+ SET_VALUE("name", name);
+ SET_VALUE("url", url);
+ CFG_SYNC;
}
-
static const QLatin1String constCfgPrefix("RemoteDevice-");
static const QLatin1String constCfgKey("remoteDevices");
QList RemoteFsDevice::loadAll(DevicesModel *m)
{
QList devices;
- KConfigGroup grp(KGlobal::config(), "General");
- QStringList names=grp.readEntry(constCfgKey, QStringList());
+ #ifdef ENABLE_KDE_SUPPORT
+ KConfigGroup cfg(KGlobal::config(), "General");
+ #else
+ QSettings cfg;
+ cfg.beginGroup("General");
+ #endif
+ QStringList names=GET_STRINGLIST(constCfgKey, QStringList());
foreach (const QString &n, names) {
Details d;
d.load(constCfgPrefix+n);
if (d.isEmpty() || d.name!=n) {
- KGlobal::config()->deleteGroup(constCfgPrefix+n);
- } else if (d.url.isLocalFile() || constSshfsProtocol==d.url.protocol()) {
+ REMOVE_GROUP(constCfgPrefix+n);
+ } else if (d.isLocalFile() || d.url.startsWith(constSshfsProtocol)) {
devices.append(new RemoteFsDevice(m, d));
}
}
if (devices.count()!=names.count()) {
- KGlobal::config()->sync();
+ CFG_SYNC;
}
return devices;
}
@@ -119,15 +139,20 @@ Device * RemoteFsDevice::create(DevicesModel *m, const QString &cover, const Dev
if (d.isEmpty()) {
return false;
}
- KConfigGroup grp(KGlobal::config(), "General");
- QStringList names=grp.readEntry(constCfgKey, QStringList());
+ #ifdef ENABLE_KDE_SUPPORT
+ KConfigGroup cfg(KGlobal::config(), "General");
+ #else
+ QSettings cfg;
+ cfg.beginGroup("General");
+ #endif
+ QStringList names=GET_STRINGLIST(constCfgKey, QStringList());
if (names.contains(d.name)) {
return false;
}
names.append(d.name);
- grp.writeEntry(constCfgKey, names);
+ SET_VALUE(constCfgKey, names);
d.save(constCfgPrefix+d.name);
- if (d.url.isLocalFile() || constSshfsProtocol==d.url.protocol()) {
+ if (d.isLocalFile() || d.url.startsWith(constSshfsProtocol)) {
return new RemoteFsDevice(m, cover, options, d);
}
return 0;
@@ -138,15 +163,20 @@ void RemoteFsDevice::remove(Device *dev)
if (!dev || RemoteFs!=dev->devType()) {
return;
}
- KConfigGroup grp(KGlobal::config(), "General");
- QStringList names=grp.readEntry(constCfgKey, QStringList());
+ #ifdef ENABLE_KDE_SUPPORT
+ KConfigGroup cfg(KGlobal::config(), "General");
+ #else
+ QSettings cfg;
+ cfg.beginGroup("General");
+ #endif
+ QStringList names=GET_STRINGLIST(constCfgKey, QStringList());
RemoteFsDevice *rfs=qobject_cast(dev);
QString name=rfs ? rfs->details.name : QString();
if (names.contains(name)) {
names.removeAll(name);
- KGlobal::config()->deleteGroup(dev->udi());
- grp.writeEntry(constCfgKey, names);
- KGlobal::config()->sync();
+ REMOVE_GROUP(dev->udi());
+ SET_VALUE(constCfgKey, names);
+ CFG_SYNC;
}
if (rfs) {
rfs->stopScanner(false);
@@ -164,17 +194,22 @@ QString RemoteFsDevice::createUdi(const QString &n)
void RemoteFsDevice::renamed(const QString &oldName, const QString &newName)
{
- KConfigGroup grp(KGlobal::config(), "General");
- QStringList names=grp.readEntry(constCfgKey, QStringList());
+ #ifdef ENABLE_KDE_SUPPORT
+ KConfigGroup cfg(KGlobal::config(), "General");
+ #else
+ QSettings cfg;
+ cfg.beginGroup("General");
+ #endif
+ QStringList names=GET_STRINGLIST(constCfgKey, QStringList());
if (names.contains(oldName)) {
names.removeAll(oldName);
- KGlobal::config()->deleteGroup(createUdi(oldName));
+ REMOVE_GROUP(createUdi(oldName));
}
if (!names.contains(newName)) {
names.append(newName);
}
- grp.writeEntry(constCfgKey, names);
- KGlobal::config()->sync();
+ SET_VALUE(constCfgKey, names);
+ CFG_SYNC;
}
RemoteFsDevice::RemoteFsDevice(DevicesModel *m, const QString &cover, const DeviceOptions &options, const Details &d)
@@ -185,7 +220,7 @@ RemoteFsDevice::RemoteFsDevice(DevicesModel *m, const QString &cover, const Devi
{
coverFileName=cover;
opts=options;
- details.url.setPath(MPDParseUtils::fixPath(details.url.path()));
+ details.url=MPDParseUtils::fixPath(details.url);
load();
mount();
}
@@ -196,7 +231,7 @@ RemoteFsDevice::RemoteFsDevice(DevicesModel *m, const Details &d)
, details(d)
, proc(0)
{
- details.url.setPath(MPDParseUtils::fixPath(details.url.path()));
+ details.url=MPDParseUtils::fixPath(details.url);
setup();
}
@@ -229,18 +264,36 @@ void RemoteFsDevice::mount()
emit error(i18n("Password prompting does not work when cantata is started from the commandline."));
return;
}
- if (KStandardDirs::findExe("ksshaskpass").isEmpty()) {
- emit error(i18n("\"ksshaskpass\" is not installed! This is required for entering passwords"));
+ QStringList askPassList;
+ const char *env=qgetenv("KDE_FULL_SESSION");
+ QString dm=env && 0==strcmp(env, "true") ? QLatin1String("KDE") : QString(qgetenv("XDG_CURRENT_DESKTOP"));
+ if (dm.isEmpty() || QLatin1String("KDE")==dm) {
+ askPassList << QLatin1String("ksshaskpass") << QLatin1String("ssh-askpass") << QLatin1String("ssh-askpass-gnome");
+ } else {
+ askPassList << QLatin1String("ssh-askpass-gnome") << QLatin1String("ssh-askpass") << QLatin1String("ksshaskpass");
+ }
+
+ QString askPass;
+ foreach (const QString &ap, askPassList) {
+ askPass=Utils::findExe(ap);
+ if (!askPass.isEmpty()) {
+ break;
+ }
+ }
+
+ if (askPass.isEmpty()) {
+ emit error(i18n("No suitable ssh-askpass applicaiton installed! This is required for entering passwords."));
return;
}
- cmd=KStandardDirs::findExe("sshfs");
+ cmd=Utils::findExe("sshfs");
if (!cmd.isEmpty()) {
if (!QDir(mountPoint(details, true)).entryList(QDir::NoDot|QDir::NoDotDot|QDir::AllEntries|QDir::Hidden).isEmpty()) {
- emit error(i18n("Mount point (\"%1\") is not empty!", mountPoint(details, true)));
+ emit error(i18n("Mount point (\"%1\") is not empty!").arg(mountPoint(details, true)));
return;
}
- args << details.url.user()+QChar('@')+details.url.host()+QChar(':')+details.url.path() << QLatin1String("-p")
- << QString::number(details.url.port()) << mountPoint(details, true)
+ QUrl url(details.url);
+ args << url.userName()+QChar('@')+url.host()+QChar(':')+url.path() << QLatin1String("-p")
+ << QString::number(url.port()) << mountPoint(details, true)
<< QLatin1String("-o") << QLatin1String("ServerAliveInterval=15");
//<< QLatin1String("-o") << QLatin1String("Ciphers=arcfour");
} else {
@@ -272,7 +325,7 @@ void RemoteFsDevice::unmount()
if (!details.isLocalFile()) {
QString mp=mountPoint(details, false);
if (!mp.isEmpty()) {
- cmd=KStandardDirs::findExe("fusermount");
+ cmd=Utils::findExe("fusermount");
if (!cmd.isEmpty()) {
args << QLatin1String("-u") << QLatin1String("-z") << mp;
} else {
@@ -297,8 +350,8 @@ void RemoteFsDevice::procFinished(int exitCode)
proc=0;
if (0!=exitCode) {
- emit error(wasMount ? i18n("Failed to connect to \"%1\"", details.name)
- : i18n("Failed to disconnect from \"%1\"", details.name));
+ emit error(wasMount ? i18n("Failed to connect to \"%1\"").arg(details.name)
+ : i18n("Failed to disconnect from \"%1\"").arg(details.name));
setStatusMessage(QString());
} else if (wasMount) {
setStatusMessage(i18n("Updating tracks..."));
@@ -313,7 +366,7 @@ void RemoteFsDevice::procFinished(int exitCode)
bool RemoteFsDevice::isConnected() const
{
if (details.isLocalFile()) {
- return QDir(details.url.path()).exists();
+ return QDir(details.url).exists();
}
QString mp=mountPoint(details, false);
@@ -328,12 +381,24 @@ bool RemoteFsDevice::isConnected() const
if (mp.endsWith('/')) {
mp=mp.left(mp.length()-1);
}
+ #ifdef ENABLE_KDE_SUPPORT
KMountPoint::List list=KMountPoint::currentMountPoints();
foreach (KMountPoint::Ptr p, list) {
if (p->mountPoint()==mp) {
return true;
}
}
+ #else
+ QFile mtab("/proc/mounts");
+ if (mtab.open(QIODevice::ReadOnly)) {
+ while (!mtab.atEnd()) {
+ QStringList parts = QString(mtab.readLine()).split(' ');
+ if (parts.size()>=2 && parts.at(1)==mp) {
+ return true;
+ }
+ }
+ }
+ #endif
return false;
}
@@ -343,8 +408,8 @@ double RemoteFsDevice::usedCapacity()
return -1.0;
}
- KDiskFreeSpaceInfo inf=KDiskFreeSpaceInfo::freeSpaceInfo(mountPoint(details, false));
- return inf.size()>0 ? (inf.used()*1.0)/(inf.size()*1.0) : -1.0;
+ spaceInfo.setPath(mountPoint(details, false));
+ return spaceInfo.size()>0 ? (spaceInfo.used()*1.0)/(spaceInfo.size()*1.0) : -1.0;
}
QString RemoteFsDevice::capacityString()
@@ -356,8 +421,9 @@ QString RemoteFsDevice::capacityString()
if (!details.isLocalFile()) {
return i18n("Capacity Unknown");
}
- KDiskFreeSpaceInfo inf=KDiskFreeSpaceInfo::freeSpaceInfo(mountPoint(details, false));
- return i18n("%1 free", KGlobal::locale()->formatByteSize(inf.size()-inf.used()), 1);
+
+ spaceInfo.setPath(mountPoint(details, false));
+ return i18n("%1 free").arg(Utils::formatByteSize(spaceInfo.size()-spaceInfo.used()));
}
qint64 RemoteFsDevice::freeSpace()
@@ -366,8 +432,8 @@ qint64 RemoteFsDevice::freeSpace()
return 0;
}
- KDiskFreeSpaceInfo inf=KDiskFreeSpaceInfo::freeSpaceInfo(mountPoint(details, false));
- return inf.size()-inf.used();
+ spaceInfo.setPath(mountPoint(details, false));
+ return spaceInfo.size()-spaceInfo.used();
}
void RemoteFsDevice::load()
@@ -385,11 +451,24 @@ void RemoteFsDevice::setup()
QString key=udi();
opts.load(key);
details.load(key);
- details.url.setPath(MPDParseUtils::fixPath(details.url.path()));
- KConfigGroup grp(KGlobal::config(), key);
- opts.useCache=grp.readEntry("useCache", true);
- coverFileName=grp.readEntry("coverFileName", "cover.jpg");
- configured=KGlobal::config()->hasGroup(key);
+ details.url=MPDParseUtils::fixPath(details.url);
+ #ifndef ENABLE_KDE_SUPPORT
+ QSettings cfg;
+ #endif
+ if (HAS_GROUP(key)) {
+ #ifdef ENABLE_KDE_SUPPORT
+ KConfigGroup cfg(KGlobal::config(), key);
+ #else
+ cfg.beginGroup(key);
+ #endif
+ opts.useCache=GET_BOOL("useCache", true);
+ coverFileName=GET_STRING("coverFileName", "cover.jpg");
+ configured=true;
+ } else {
+ opts.useCache=true;
+ coverFileName=QLatin1String("cover.jpg");
+ configured=false;
+ }
load();
}
@@ -446,7 +525,7 @@ void RemoteFsDevice::saveProperties(const QString &newCoverFileName, const Devic
configured=true;
Details oldDetails=details;
- newDetails.url.setPath(MPDParseUtils::fixPath(newDetails.url.path()));
+ newDetails.url=MPDParseUtils::fixPath(newDetails.url);
if (opts.useCache!=newOpts.useCache || newDetails.url!=oldDetails.url) { // Cache/url settings changed
if (opts.useCache && newDetails.url==oldDetails.url) {
@@ -468,9 +547,14 @@ void RemoteFsDevice::saveProperties(const QString &newCoverFileName, const Devic
QString key=udi();
details.save(key);
opts.save(key);
- KConfigGroup grp(KGlobal::config(), key);
- grp.writeEntry("useCache", opts.useCache);
- grp.writeEntry("coverFileName", coverFileName);
+ #ifdef ENABLE_KDE_SUPPORT
+ KConfigGroup cfg(KGlobal::config(), key);
+ #else
+ QSettings cfg;
+ cfg.beginGroup(key);
+ #endif
+ SET_VALUE("useCache", opts.useCache);
+ SET_VALUE("coverFileName", coverFileName);
if (newName) {
QString oldMount=mountPoint(oldDetails, false);
diff --git a/devices/remotefsdevice.h b/devices/remotefsdevice.h
index f2d383a4c..bae200d71 100644
--- a/devices/remotefsdevice.h
+++ b/devices/remotefsdevice.h
@@ -26,7 +26,6 @@
#include "fsdevice.h"
#include
-#include
class QProcess;
class RemoteFsDevice : public FsDevice
@@ -49,10 +48,10 @@ public:
return name.isEmpty() || url.isEmpty();
}
bool isLocalFile() const {
- return url.isLocalFile();
+ return !url.startsWith(constSshfsProtocol);
}
QString name;
- KUrl url;
+ QString url;
};
static const QLatin1String constSshfsProtocol;
@@ -70,7 +69,7 @@ public:
void toggle();
void mount();
void unmount();
- bool supportsDisconnect() const { return !details.url.isLocalFile(); }
+ bool supportsDisconnect() const { return !details.isLocalFile(); }
bool isConnected() const;
double usedCapacity();
QString capacityString();
@@ -80,7 +79,7 @@ public:
DevType devType() const { return RemoteFs; }
QString udi() const { return createUdi(details.name); }
QString icon() const {
- return QLatin1String(details.url.isLocalFile() ? "inode-directory" : "network-server");
+ return QLatin1String(details.isLocalFile() ? "inode-directory" : "network-server");
}
bool canPlaySongs() const;
diff --git a/devices/synccollectionwidget.cpp b/devices/synccollectionwidget.cpp
index dd3f2eb2b..a92ff9c5c 100644
--- a/devices/synccollectionwidget.cpp
+++ b/devices/synccollectionwidget.cpp
@@ -25,9 +25,8 @@
#include "treeview.h"
#include "musiclibrarymodel.h"
#include "musiclibraryproxymodel.h"
-#include
-#include
-#include
+#include "icon.h"
+#include
SyncCollectionWidget::SyncCollectionWidget(QWidget *parent, const QString &title, const QString &action)
: QWidget(parent)
@@ -45,7 +44,7 @@ SyncCollectionWidget::SyncCollectionWidget(QWidget *parent, const QString &title
connect(tree, SIGNAL(itemsSelected(bool)), button, SLOT(setEnabled(bool)));
connect(button, SIGNAL(clicked()), SLOT(copySongs()));
- KAction *act=new KAction(action, this);
+ QAction *act=new QAction(action, this);
connect(act, SIGNAL(triggered(bool)), SLOT(copySongs()));
tree->addAction(act);
tree->setAlternatingRowColors(false); // Otherwise background gets corrrupted.
@@ -57,7 +56,7 @@ SyncCollectionWidget::~SyncCollectionWidget()
void SyncCollectionWidget::setIcon(const QString &iconName)
{
- tree->setPixmap(KIcon(iconName).pixmap(128, 128));
+ tree->setPixmap(QIcon::fromTheme(iconName).pixmap(128, 128));
}
void SyncCollectionWidget::update(const QSet &songs)
diff --git a/devices/synccollectionwidget.ui b/devices/synccollectionwidget.ui
index f1390125e..f4bcd9af0 100644
--- a/devices/synccollectionwidget.ui
+++ b/devices/synccollectionwidget.ui
@@ -34,7 +34,7 @@
-
-
+
@@ -42,11 +42,6 @@
-
- KPushButton
- QPushButton
-
-
TreeView
QTreeView
diff --git a/devices/syncdialog.cpp b/devices/syncdialog.cpp
index b94d7dffb..e3127e532 100644
--- a/devices/syncdialog.cpp
+++ b/devices/syncdialog.cpp
@@ -157,7 +157,7 @@ bool SyncDialog::updateSongs(bool showMessage)
if (0==inDev.count() && 0==inLib.count()) {
if (showMessage) {
- KMessageBox::information(isVisible() ? this : parentWidget(), i18n("Device and library are in sync."));
+ MessageBox::information(isVisible() ? this : parentWidget(), i18n("Device and library are in sync."));
}
deleteLater();
hide();
diff --git a/devices/transcodingjob.cpp b/devices/transcodingjob.cpp
index 9cb50b6c0..db71fa431 100644
--- a/devices/transcodingjob.cpp
+++ b/devices/transcodingjob.cpp
@@ -2,55 +2,76 @@
* Cantata
*
* Copyright (c) 2011-2012 Craig Drummond
+ *
+ * ----
+ *
+ * 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 2 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; see the file COPYING. If not, write to
+ * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
*/
-/****************************************************************************************
- * Copyright (c) 2010 Téo Mrnjavac *
- * *
- * 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 2 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 . *
- ****************************************************************************************/
#include "transcodingjob.h"
-TranscodingJob::TranscodingJob(const QStringList ¶ms, QObject *parent)
- : KJob(parent)
+TranscodingJob::TranscodingJob(const QStringList ¶ms)
+ : parameters(params)
+ , process(0)
, duration(-1)
{
- QStringList p(params);
- QString cmd=p.takeFirst();
+}
- process = new KProcess(this);
- process->setOutputChannelMode(KProcess::MergedChannels);
- process->setProgram(cmd);
- *process << p;
-
- connect(process, SIGNAL(readyRead()), this, SLOT(processOutput()));
- connect(process, SIGNAL(finished(int, QProcess::ExitStatus)), this, SLOT(finished(int, QProcess::ExitStatus)));
+TranscodingJob::~TranscodingJob()
+{
+ delete process;
}
void TranscodingJob::start()
{
- process->start();
+ process = new QProcess;
+ connect(process, SIGNAL(readyReadStandardError()), this, SLOT(processOutput()));
+ connect(process, SIGNAL(readyReadStandardOutput()), this, SLOT(processOutput()));
+ connect(process, SIGNAL(finished(int, QProcess::ExitStatus)), this, SLOT(finished(int, QProcess::ExitStatus)));
+ QString cmd=parameters.takeFirst();
+ process->start(cmd, parameters);
+}
+
+void TranscodingJob::stop()
+{
+ if (process) {
+ process->close();
+ process->deleteLater();
+ process=0;
+ emit result(StatusCancelled);
+ }
}
void TranscodingJob::finished(int exitCode, QProcess::ExitStatus exitStatus)
{
- Q_UNUSED(exitCode);
Q_UNUSED(exitStatus);
- emitResult();
+ if (!process) {
+ return;
+ }
+ if (stopRequested) {
+ emit result(StatusCancelled);
+ return;
+ }
+ emit result(0==exitCode ? StatusOk : StatusFailed);
}
void TranscodingJob::processOutput()
{
+ if (stopRequested) {
+ return;
+ }
QString output = process->readAllStandardOutput().data();
if(output.simplified().isEmpty()) {
return;
@@ -58,14 +79,13 @@ void TranscodingJob::processOutput()
if (-1==duration) {
duration = computeDuration(output);
- if(duration >= 0) {
- setTotalAmount(KJob::Bytes, duration);
- }
}
- qint64 progress = computeProgress(output);
- if(progress > -1) {
- setProcessedAmount(KJob::Bytes, progress);
+ if (duration>0) {
+ qint64 prog = computeProgress(output);
+ if (prog>-1) {
+ setPercent(prog/duration);
+ }
}
}
diff --git a/devices/transcodingjob.h b/devices/transcodingjob.h
index f1d21e95c..080dd487d 100644
--- a/devices/transcodingjob.h
+++ b/devices/transcodingjob.h
@@ -22,17 +22,19 @@
#ifndef TRANSCODING_JOB_H
#define TRANSCODING_JOB_H
+#include "filejob.h"
#include
-#include
-#include
+#include
-class TranscodingJob : public KJob
+class TranscodingJob : public FileJob
{
Q_OBJECT
public:
- explicit TranscodingJob(const QStringList ¶ms, QObject *parent = 0);
+ explicit TranscodingJob(const QStringList ¶ms);
+ ~TranscodingJob();
void start();
+ void stop();
private Q_SLOTS:
void processOutput();
@@ -43,7 +45,8 @@ private:
inline qint64 computeProgress(const QString &output);
private:
- KProcess *process;
+ QStringList parameters;
+ QProcess *process;
qint64 duration; //in csec
};
diff --git a/devices/umsdevice.cpp b/devices/umsdevice.cpp
index b28a30eb4..8b002e1b7 100644
--- a/devices/umsdevice.cpp
+++ b/devices/umsdevice.cpp
@@ -32,10 +32,11 @@
#include
#include
#include
+#ifdef ENABLE_KDE_SUPPORT
#include
-#include
#include
#include
+#endif
static const QLatin1String constSettingsFile("/.is_audio_player");
static const QLatin1String constMusicFolderKey("audio_folder");
@@ -59,6 +60,7 @@ UmsDevice::UmsDevice(DevicesModel *m, Solid::Device &dev)
: FsDevice(m, dev)
, access(dev.as())
{
+ spaceInfo.setPath(access->filePath());
setup();
}
@@ -76,8 +78,7 @@ double UmsDevice::usedCapacity()
return -1.0;
}
- KDiskFreeSpaceInfo inf=KDiskFreeSpaceInfo::freeSpaceInfo(access->filePath());
- return inf.size()>0 ? (inf.used()*1.0)/(inf.size()*1.0) : -1.0;
+ return spaceInfo.size()>0 ? (spaceInfo.used()*1.0)/(spaceInfo.size()*1.0) : -1.0;
}
QString UmsDevice::capacityString()
@@ -86,8 +87,7 @@ QString UmsDevice::capacityString()
return i18n("Not Connected");
}
- KDiskFreeSpaceInfo inf=KDiskFreeSpaceInfo::freeSpaceInfo(access->filePath());
- return i18n("%1 free", KGlobal::locale()->formatByteSize(inf.size()-inf.used()), 1);
+ return i18n("%1 free").arg(Utils::formatByteSize(spaceInfo.size()-spaceInfo.used()));
}
qint64 UmsDevice::freeSpace()
@@ -96,8 +96,7 @@ qint64 UmsDevice::freeSpace()
return 0;
}
- KDiskFreeSpaceInfo inf=KDiskFreeSpaceInfo::freeSpaceInfo(access->filePath());
- return inf.size()-inf.used();
+ return spaceInfo.size()-spaceInfo.used();
}
void UmsDevice::setup()
@@ -119,10 +118,14 @@ void UmsDevice::setup()
while (!in.atEnd()) {
QString line = in.readLine();
if (line.startsWith(constMusicFolderKey+"=")) {
+ #ifdef ENABLE_KDE_SUPPORT
KUrl url = KUrl(path);
url.addPath(line.section('=', 1, 1));
url.cleanPath();
audioFolderSetting=audioFolder=url.toLocalFile();
+ #else
+ audioFolderSetting=Utils::cleanPath(path+'/'+line.section('=', 1, 1));
+ #endif
if (!QDir(audioFolder).exists()) {
audioFolder = path;
}
diff --git a/devices/umsdevice.h b/devices/umsdevice.h
index cfdbd162b..5e4164d9a 100644
--- a/devices/umsdevice.h
+++ b/devices/umsdevice.h
@@ -25,6 +25,11 @@
#define UMSDEVICE_H
#include "fsdevice.h"
+#ifdef ENABLE_KDE_SUPPORT
+#include
+#else
+#include "solid-lite/storageaccess.h"
+#endif
class UmsDevice : public FsDevice
{
diff --git a/devices/utils.cpp b/devices/utils.cpp
index 204198a53..d63377cc8 100644
--- a/devices/utils.cpp
+++ b/devices/utils.cpp
@@ -25,6 +25,7 @@
#include "config.h"
#include "mpdparseutils.h"
#include "covers.h"
+#include "localize.h"
#include
#include
#include
@@ -304,3 +305,216 @@ void Utils::stopThread(QThread *thread)
}
}
+#ifndef ENABLE_KDE_SUPPORT
+// Copied from KDE... START
+#include
+
+QString Utils::formatByteSize(double size)
+{
+ static QLocale locale;
+
+ int unit = 0;
+ double multiplier = 1024.0;
+
+ while (qAbs(size) >= multiplier && unit < 3) {
+ size /= multiplier;
+ unit++;
+ }
+
+ switch(unit) {
+ case 0: return i18n("%1 B").arg(size);
+ case 1: return i18n("%1 KiB").arg(locale.toString(size, 'f', 1));
+ case 2: return i18n("%1 MiB").arg(locale.toString(size, 'f', 1));
+ default:
+ case 3: return i18n("%1 GiB").arg(locale.toString(size, 'f', 1));
+ }
+}
+
+#if defined Q_OS_WIN
+#define KPATH_SEPARATOR ';'
+// #define KDIR_SEPARATOR '\\' /* faster than QDir::separator() */
+#else
+#define KPATH_SEPARATOR ':'
+// #define KDIR_SEPARATOR '/' /* faster than QDir::separator() */
+#endif
+
+static inline QString equalizePath(QString &str)
+{
+ #ifdef Q_WS_WIN
+ // filter pathes through QFileInfo to have always
+ // the same case for drive letters
+ QFileInfo f(str);
+ if (f.isAbsolute())
+ return f.absoluteFilePath();
+ else
+ #endif
+ return str;
+}
+
+static void tokenize(QStringList &tokens, const QString &str, const QString &delim)
+{
+ const int len = str.length();
+ QString token;
+
+ for(int index = 0; index < len; index++) {
+ if (delim.contains(str[index])) {
+ tokens.append(equalizePath(token));
+ token.clear();
+ } else {
+ token += str[index];
+ }
+ }
+ if (!token.isEmpty()) {
+ tokens.append(equalizePath(token));
+ }
+}
+
+#ifdef Q_OS_WIN
+static QStringList executableExtensions()
+{
+ QStringList ret = QString::fromLocal8Bit(qgetenv("PATHEXT")).split(QLatin1Char(';'));
+ if (!ret.contains(QLatin1String(".exe"), Qt::CaseInsensitive)) {
+ // If %PATHEXT% does not contain .exe, it is either empty, malformed, or distorted in ways that we cannot support, anyway.
+ ret.clear();
+ ret << QLatin1String(".exe")
+ << QLatin1String(".com")
+ << QLatin1String(".bat")
+ << QLatin1String(".cmd");
+ }
+ return ret;
+}
+#endif
+
+static QStringList systemPaths(const QString &pstr)
+{
+ QStringList tokens;
+ QString p = pstr;
+
+ if( p.isEmpty() ) {
+ p = QString::fromLocal8Bit( qgetenv( "PATH" ) );
+ }
+
+ QString delimiters(QLatin1Char(KPATH_SEPARATOR));
+ delimiters += QLatin1Char('\b');
+ tokenize( tokens, p, delimiters );
+
+ QStringList exePaths;
+
+ // split path using : or \b as delimiters
+ for( int i = 0; i < tokens.count(); i++ ) {
+ exePaths << /*KShell::tildeExpand(*/ tokens[ i ] /*)*/; // TODO
+ }
+
+ return exePaths;
+}
+
+#ifdef Q_WS_MAC
+static QString getBundle(const QString &path)
+{
+ //kDebug(180) << "getBundle(" << path << ", " << ignore << ") called";
+ QFileInfo info;
+ QString bundle = path;
+ bundle += QLatin1String(".app/Contents/MacOS/") + bundle.section(QLatin1Char('/'), -1);
+ info.setFile( bundle );
+ FILE *file;
+ if (file = fopen(info.absoluteFilePath().toUtf8().constData(), "r")) {
+ fclose(file);
+ struct stat _stat;
+ if ((stat(info.absoluteFilePath().toUtf8().constData(), &_stat)) < 0) {
+ return QString();
+ }
+ if ( _stat.st_mode & S_IXUSR ) {
+ if ( ((_stat.st_mode & S_IFMT) == S_IFREG) || ((_stat.st_mode & S_IFMT) == S_IFLNK) ) {
+ //kDebug(180) << "getBundle(): returning " << bundle;
+ return bundle;
+ }
+ }
+ }
+ return QString();
+}
+#endif
+
+static QString checkExecutable( const QString& path )
+{
+ #ifdef Q_WS_MAC
+ QString bundle = getBundle( path );
+ if ( !bundle.isEmpty() ) {
+ //kDebug(180) << "findExe(): returning " << bundle;
+ return bundle;
+ }
+ #endif
+ QFileInfo info( path );
+ QFileInfo orig = info;
+ #if defined(Q_OS_DARWIN) || defined(Q_OS_MAC)
+ FILE *file;
+ if (file = fopen(orig.absoluteFilePath().toUtf8().constData(), "r")) {
+ fclose(file);
+ struct stat _stat;
+ if ((stat(orig.absoluteFilePath().toUtf8().constData(), &_stat)) < 0) {
+ return QString();
+ }
+ if ( _stat.st_mode & S_IXUSR ) {
+ if ( ((_stat.st_mode & S_IFMT) == S_IFREG) || ((_stat.st_mode & S_IFMT) == S_IFLNK) ) {
+ orig.makeAbsolute();
+ return orig.filePath();
+ }
+ }
+ }
+ return QString();
+ #else
+ if( info.exists() && info.isSymLink() )
+ info = QFileInfo( info.canonicalFilePath() );
+ if( info.exists() && info.isExecutable() && info.isFile() ) {
+ // return absolute path, but without symlinks resolved in order to prevent
+ // problems with executables that work differently depending on name they are
+ // run as (for example gunzip)
+ orig.makeAbsolute();
+ return orig.filePath();
+ }
+ //kDebug(180) << "checkExecutable(): failed, returning empty string";
+ return QString();
+ #endif
+}
+
+QString Utils::findExe(const QString &appname, const QString &pstr)
+{
+ #ifdef Q_OS_WIN
+ QStringList executable_extensions = executableExtensions();
+ if (!executable_extensions.contains(appname.section(QLatin1Char('.'), -1, -1, QString::SectionIncludeLeadingSep), Qt::CaseInsensitive)) {
+ QString found_exe;
+ foreach (const QString& extension, executable_extensions) {
+ found_exe = findExe(appname + extension, pstr);
+ if (!found_exe.isEmpty()) {
+ return found_exe;
+ }
+ }
+ return QString();
+ }
+ #endif
+
+ const QStringList exePaths = systemPaths( pstr );
+ for (QStringList::ConstIterator it = exePaths.begin(); it != exePaths.end(); ++it) {
+ QString p = (*it) + QLatin1Char('/');
+ p += appname;
+
+ QString result = checkExecutable(p);
+ if (!result.isEmpty()) {
+ return result;
+ }
+ }
+
+ return QString();
+}
+// Copied from KDE... END
+
+QString Utils::cleanPath(const QString &p)
+{
+ QString path(p);
+ while(path.contains("//")) {
+ path.replace("//", "/");
+ }
+ return dirSyntax(path);
+}
+
+#endif
+
diff --git a/devices/utils.h b/devices/utils.h
index 8b5ceac95..0f10d021d 100644
--- a/devices/utils.h
+++ b/devices/utils.h
@@ -27,6 +27,12 @@
#include
#include
#include
+#include
+#ifdef ENABLE_KDE_SUPPORT
+#include
+#include
+#include
+#endif
class QString;
class QThread;
@@ -53,6 +59,15 @@ namespace Utils
extern void msleep(int msecs);
inline void sleep() { msleep(100); }
extern void stopThread(QThread *thread);
+
+ #ifdef ENABLE_KDE_SUPPORT
+ inline QString findExe(const QString &appname, const QString &pathstr=QString()) { return KStandardDirs::findExe(appname, pathstr); }
+ inline QString formatByteSize(double size) { return KGlobal::locale()->formatByteSize(size, 1); }
+ #else
+ extern QString findExe(const QString &appname, const QString &pathstr=QString());
+ extern QString formatByteSize(double size);
+ extern QString cleanPath(const QString &p);
+ #endif
};
#endif
diff --git a/gui/mainwindow.cpp b/gui/mainwindow.cpp
index c8c2fae52..12fa24dc0 100644
--- a/gui/mainwindow.cpp
+++ b/gui/mainwindow.cpp
@@ -78,7 +78,8 @@
#include "lyricspage.h"
#include "infopage.h"
#include "serverinfopage.h"
-#if defined ENABLE_DEVICES_SUPPORT && defined TAGLIB_FOUND
+#if defined ENABLE_DEVICES_SUPPORT
+#include "filejob.h"
#include "devicespage.h"
#include "devicesmodel.h"
#include "actiondialog.h"
@@ -915,6 +916,9 @@ MainWindow::~MainWindow()
}
Utils::stopThread(mpdThread);
Covers::self()->stop();
+ #if defined ENABLE_DEVICES_SUPPORT
+ FileScheduler::self()->stop();
+ #endif
}
void MainWindow::initSizes()
diff --git a/gui/mainwindow.h b/gui/mainwindow.h
index c0a4ecf96..d95ad22e3 100644
--- a/gui/mainwindow.h
+++ b/gui/mainwindow.h
@@ -71,7 +71,7 @@ class LyricsPage;
class StreamsPage;
class InfoPage;
class ServerInfoPage;
-#if defined ENABLE_KDE_SUPPORT && defined TAGLIB_FOUND
+#ifdef ENABLE_DEVICES_SUPPORT
class DevicesPage;
#endif
class QThread;
@@ -165,7 +165,7 @@ public:
PAGE_INFO,
#endif
PAGE_SERVER_INFO
- #ifdef ENABLE_KDE_SUPPORT
+ #ifdef ENABLE_DEVICES_SUPPORT
, PAGE_DEVICES
#endif
};
diff --git a/gui/settings.cpp b/gui/settings.cpp
index e4dd7e2e7..d3c3501e5 100644
--- a/gui/settings.cpp
+++ b/gui/settings.cpp
@@ -111,39 +111,6 @@ struct MpdDefaults
static MpdDefaults mpdDefaults;
-#ifdef ENABLE_KDE_SUPPORT
-#define CFG_GET_STRING(CFG, KEY, DEF) (CFG.readEntry(KEY, QString(DEF)))
-#define CFG_GET_STRINGLIST(CFG, KEY, DEF) (CFG.readEntry(KEY, DEF))
-#define CFG_GET_BOOL(CFG, KEY, DEF) (CFG.readEntry(KEY, DEF))
-#define CFG_GET_INT(CFG, KEY, DEF) (CFG.readEntry(KEY, DEF))
-#define CFG_GET_BYTE_ARRAY(CFG, KEY) (CFG.readEntry(KEY, QByteArray()))
-#define CFG_GET_SIZE(CFG, KEY) (CFG.readEntry(KEY, QSize()))
-#define CFG_SET_VALUE(CFG, KEY, V) (CFG.writeEntry(KEY, V))
-#define HAS_GROUP(GRP) (KGlobal::config()->hasGroup(GRP))
-#define REMOVE_GROUP(GRP) (KGlobal::config()->deleteGroup(GRP))
-#define REMOVE_ENTRY(KEY) (cfg.deleteEntry(KEY))
-#define GET_STRING(KEY, DEF) CFG_GET_STRING(cfg, KEY, DEF)
-#define GET_STRINGLIST(KEY, DEF) CFG_GET_STRINGLIST(cfg, KEY, DEF)
-#define GET_BOOL(KEY, DEF) CFG_GET_BOOL(cfg, KEY, DEF)
-#define GET_INT(KEY, DEF) CFG_GET_INT(cfg, KEY, DEF)
-#define GET_BYTE_ARRAY(KEY) CFG_GET_BYTE_ARRAY(cfg, KEY)
-#define GET_SIZE(KEY) CFG_GET_SIZE(cfg, KEY)
-#define SET_VALUE(KEY, V) CFG_SET_VALUE(cfg, KEY, V)
-#define HAS_ENTRY(KEY) (cfg.hasKey(KEY))
-#else
-#define GET_STRING(KEY, DEF) (cfg.contains(KEY) ? cfg.value(KEY).toString() : QString(DEF))
-#define GET_STRINGLIST(KEY, DEF) (cfg.contains(KEY) ? cfg.value(KEY).toStringList() : DEF)
-#define GET_BOOL(KEY, DEF) (cfg.contains(KEY) ? cfg.value(KEY).toBool() : DEF)
-#define GET_INT(KEY, DEF) (cfg.contains(KEY) ? cfg.value(KEY).toInt() : DEF)
-#define GET_BYTE_ARRAY(KEY) (cfg.value(KEY).toByteArray())
-#define GET_SIZE(KEY) (cfg.contains(KEY) ? cfg.value(KEY).toSize() : QSize())
-#define SET_VALUE(KEY, V) (cfg.setValue(KEY, V))
-#define HAS_GROUP(GRP) (-1!=cfg.childGroups().indexOf(GRP))
-#define REMOVE_GROUP(GRP) (cfg.remove(GRP))
-#define REMOVE_ENTRY(KEY) (cfg.remove(KEY))
-#define HAS_ENTRY(KEY) (cfg.contains(KEY))
-#endif
-
Settings::Settings()
: isFirstRun(false)
, timer(0)
@@ -904,11 +871,7 @@ void Settings::save(bool force)
{
if (force) {
SET_VALUE("version", PACKAGE_VERSION);
- #ifdef ENABLE_KDE_SUPPORT
- KGlobal::config()->sync();
- #else
- cfg.sync();
- #endif
+ CFG_SYNC;
if (timer) {
timer->stop();
}
diff --git a/gui/settings.h b/gui/settings.h
index f4a0ca623..af7c46f43 100644
--- a/gui/settings.h
+++ b/gui/settings.h
@@ -25,6 +25,8 @@
#define SETTINGS_H
#ifdef ENABLE_KDE_SUPPORT
+#include
+#include
#include
namespace KWallet {
class Wallet;
@@ -37,6 +39,41 @@ class Wallet;
#define CANTATA_MAKE_VERSION(a, b, c) (((a) << 16) | ((b) << 8) | (c))
+#ifdef ENABLE_KDE_SUPPORT
+#define CFG_GET_STRING(CFG, KEY, DEF) (CFG.readEntry(KEY, QString(DEF)))
+#define CFG_GET_STRINGLIST(CFG, KEY, DEF) (CFG.readEntry(KEY, DEF))
+#define CFG_GET_BOOL(CFG, KEY, DEF) (CFG.readEntry(KEY, DEF))
+#define CFG_GET_INT(CFG, KEY, DEF) (CFG.readEntry(KEY, DEF))
+#define CFG_GET_BYTE_ARRAY(CFG, KEY) (CFG.readEntry(KEY, QByteArray()))
+#define CFG_GET_SIZE(CFG, KEY) (CFG.readEntry(KEY, QSize()))
+#define CFG_SET_VALUE(CFG, KEY, V) (CFG.writeEntry(KEY, V))
+#define HAS_GROUP(GRP) (KGlobal::config()->hasGroup(GRP))
+#define REMOVE_GROUP(GRP) (KGlobal::config()->deleteGroup(GRP))
+#define REMOVE_ENTRY(KEY) (cfg.deleteEntry(KEY))
+#define GET_STRING(KEY, DEF) CFG_GET_STRING(cfg, KEY, DEF)
+#define GET_STRINGLIST(KEY, DEF) CFG_GET_STRINGLIST(cfg, KEY, DEF)
+#define GET_BOOL(KEY, DEF) CFG_GET_BOOL(cfg, KEY, DEF)
+#define GET_INT(KEY, DEF) CFG_GET_INT(cfg, KEY, DEF)
+#define GET_BYTE_ARRAY(KEY) CFG_GET_BYTE_ARRAY(cfg, KEY)
+#define GET_SIZE(KEY) CFG_GET_SIZE(cfg, KEY)
+#define SET_VALUE(KEY, V) CFG_SET_VALUE(cfg, KEY, V)
+#define HAS_ENTRY(KEY) (cfg.hasKey(KEY))
+#define CFG_SYNC KGlobal::config()->sync()
+#else
+#define GET_STRING(KEY, DEF) (cfg.contains(KEY) ? cfg.value(KEY).toString() : QString(DEF))
+#define GET_STRINGLIST(KEY, DEF) (cfg.contains(KEY) ? cfg.value(KEY).toStringList() : DEF)
+#define GET_BOOL(KEY, DEF) (cfg.contains(KEY) ? cfg.value(KEY).toBool() : DEF)
+#define GET_INT(KEY, DEF) (cfg.contains(KEY) ? cfg.value(KEY).toInt() : DEF)
+#define GET_BYTE_ARRAY(KEY) (cfg.value(KEY).toByteArray())
+#define GET_SIZE(KEY) (cfg.contains(KEY) ? cfg.value(KEY).toSize() : QSize())
+#define SET_VALUE(KEY, V) (cfg.setValue(KEY, V))
+#define HAS_GROUP(GRP) (-1!=cfg.childGroups().indexOf(GRP))
+#define REMOVE_GROUP(GRP) (cfg.remove(GRP))
+#define REMOVE_ENTRY(KEY) (cfg.remove(KEY))
+#define HAS_ENTRY(KEY) (cfg.contains(KEY))
+#define CFG_SYNC cfg.sync()
+#endif
+
class QTimer;
class Settings : public QObject
diff --git a/gui/tageditor.cpp b/gui/tageditor.cpp
index e812a8a64..3870f4028 100644
--- a/gui/tageditor.cpp
+++ b/gui/tageditor.cpp
@@ -745,17 +745,17 @@ Device * TagEditor::getDevice(const QString &udi, QWidget *p)
{
Device *dev=DevicesModel::self()->device(udi);
if (!dev) {
- KMessageBox::error(p ? p : this, i18n("Device has been removed!"));
+ MessageBox::error(p ? p : this, i18n("Device has been removed!"));
reject();
return 0;
}
if (!dev->isConnected()) {
- KMessageBox::error(p ? p : this, i18n("Device is not connected."));
+ MessageBox::error(p ? p : this, i18n("Device is not connected."));
reject();
return 0;
}
if (!dev->isIdle()) {
- KMessageBox::error(p ? p : this, i18n("Device is busy?"));
+ MessageBox::error(p ? p : this, i18n("Device is busy?"));
reject();
return 0;
}
diff --git a/models/musiclibraryitemalbum.cpp b/models/musiclibraryitemalbum.cpp
index 7a685b037..1fce5372d 100644
--- a/models/musiclibraryitemalbum.cpp
+++ b/models/musiclibraryitemalbum.cpp
@@ -32,7 +32,7 @@
#include "covers.h"
#include "config.h"
#include "icon.h"
-#if defined ENABLE_KDE_SUPPORT && defined TAGLIB_FOUND
+#ifdef ENABLE_DEVICES_SUPPORT
#include "device.h"
#include "utils.h"
#endif
@@ -204,7 +204,7 @@ const QPixmap & MusicLibraryItemAlbum::cover()
song.album=m_itemData;
song.year=m_year;
song.file=firstSong->file();
- #if defined ENABLE_KDE_SUPPORT && defined TAGLIB_FOUND
+ #ifdef ENABLE_DEVICES_SUPPORT
if (!song.file.startsWith("/") && parent() && parent()->parent() && qobject_cast(parent()->parent())) {
QString root=static_cast(parent()->parent())->path();
if (!root.isEmpty()) {
diff --git a/models/musiclibraryitemartist.cpp b/models/musiclibraryitemartist.cpp
index 3c2d0e457..e474c62fe 100644
--- a/models/musiclibraryitemartist.cpp
+++ b/models/musiclibraryitemartist.cpp
@@ -34,7 +34,7 @@
#include "localize.h"
#include "covers.h"
#include "icon.h"
-#if defined ENABLE_KDE_SUPPORT && defined TAGLIB_FOUND
+#ifdef ENABLE_DEVICES_SUPPORT
#include "device.h"
#include "utils.h"
#endif
@@ -121,7 +121,7 @@ const QPixmap & MusicLibraryItemArtist::cover()
if (firstSong) {
song.file=firstSong->file();
- #if defined ENABLE_KDE_SUPPORT && defined TAGLIB_FOUND
+ #ifdef ENABLE_DEVICES_SUPPORT
if (!song.file.startsWith("/") && parent() && qobject_cast(parent())) {
QString root=static_cast(parent())->path();
if (!root.isEmpty()) {
diff --git a/po/generate.sh b/po/generate.sh
index 46758c935..7bfd1b4a5 100755
--- a/po/generate.sh
+++ b/po/generate.sh
@@ -26,7 +26,7 @@ echo "Done preparing rc files"
echo "Extracting messages"
cd ${BASEDIR}
# see above on sorting
-find . -name '*.cpp' -o -name '*.h' -o -name '*.c' | sort > ${WDIR}/infiles.list
+find . -name '*.cpp' -o -name '*.h' -o -name '*.c' | grep -v "solid-lite" | sort > ${WDIR}/infiles.list
echo "rc.cpp" >> ${WDIR}/infiles.list
cd ${WDIR}
@@ -35,7 +35,7 @@ xgettext --from-code=UTF-8 -C -kde -ci18n -ki18n:1 -ki18nc:1c,2 -ki18np:1,2 -ki1
--msgid-bugs-address="${BUGADDR}" \
--files-from=infiles.list -D ${BASEDIR} -D ${WDIR} -o ${PROJECT}_kde.pot || { echo "error while calling xgettext. aborting."; exit 1; }
-find .. -name '*.cpp' | xargs grep -l 'QObject::tr(' | sort > ${WDIR}/infiles.qt.list
+find .. -name '*.cpp' | xargs grep -l 'QObject::tr(' | grep -v "solid-lite" | sort > ${WDIR}/infiles.qt.list
echo "../qtplural.h" >> ${WDIR}/infiles.qt.list
lupdate @infiles.qt.list -ts ${PROJECT}.ts && lconvert -i ${PROJECT}.ts -o ${PROJECT}_qt.po && msguniq -o ${PROJECT}_qt.pot ${PROJECT}_qt.po && rm ${PROJECT}.ts ${PROJECT}_qt.po
diff --git a/replaygain/rgdialog.cpp b/replaygain/rgdialog.cpp
index 5b70057e2..0b0c21066 100644
--- a/replaygain/rgdialog.cpp
+++ b/replaygain/rgdialog.cpp
@@ -45,7 +45,7 @@
#include
#endif
-#ifdef ENABLE_DEVICES_SUPPORT
+#ifdef ENABLE_KDE_SUPPORT
static QString formatNumber(double number, int precision)
{
return KGlobal::locale()->formatNumber(number, precision);
@@ -121,7 +121,7 @@ RgDialog::RgDialog(QWidget *parent)
layout->addWidget(statusLabel);
layout->addWidget(progress);
setMainWidget(mainWidet);
- #ifdef ENABLE_DEVICES_SUPPORT
+ #ifdef ENABLE_KDE_SUPPORT
setButtonGuiItem(Ok, KStandardGuiItem::save());
setButtonGuiItem(Cancel, KStandardGuiItem::close());
#else
@@ -236,7 +236,7 @@ void RgDialog::startScanning()
if (!all && origTags.count()==origSongs.count()) {
return;
}
- #ifdef ENABLE_DEVICES_SUPPORT
+ #ifdef ENABLE_KDE_SUPPORT
setButtonGuiItem(Cancel, KStandardGuiItem::cancel());
#else
setButtonGuiItem(Cancel, KGuiItem(i18n("Cancel"), "dialog-cancel"));
@@ -271,7 +271,7 @@ void RgDialog::stopScanning()
JobController::self()->cancel();
clearScanners();
- #ifdef ENABLE_DEVICES_SUPPORT
+ #ifdef ENABLE_KDE_SUPPORT
setButtonGuiItem(Cancel, KStandardGuiItem::cancel());
#else
setButtonGuiItem(Cancel, KGuiItem(i18n("Close"), "dialog-close"));
@@ -312,7 +312,7 @@ void RgDialog::startReadingTags()
if (tagReader) {
return;
}
- #ifdef ENABLE_DEVICES_SUPPORT
+ #ifdef ENABLE_KDE_SUPPORT
setButtonGuiItem(Cancel, KStandardGuiItem::cancel());
#else
setButtonGuiItem(Cancel, KGuiItem(i18n("Cancel"), "dialog-cancel"));
@@ -418,7 +418,7 @@ void RgDialog::updateView()
progress->setVisible(false);
statusLabel->setVisible(false);
state=State_Idle;
- #ifdef ENABLE_DEVICES_SUPPORT
+ #ifdef ENABLE_KDE_SUPPORT
setButtonGuiItem(Cancel, KStandardGuiItem::close());
#else
setButtonGuiItem(Cancel, KGuiItem(i18n("Close"), "dialog-close"));
@@ -435,17 +435,17 @@ Device * RgDialog::getDevice(const QString &udi, QWidget *p)
{
Device *dev=DevicesModel::self()->device(udi);
if (!dev) {
- KMessageBox::error(p ? p : this, i18n("Device has been removed!"));
+ MessageBox::error(p ? p : this, i18n("Device has been removed!"));
reject();
return 0;
}
if (!dev->isConnected()) {
- KMessageBox::error(p ? p : this, i18n("Device is not connected."));
+ MessageBox::error(p ? p : this, i18n("Device is not connected."));
reject();
return 0;
}
if (!dev->isIdle()) {
- KMessageBox::error(p ? p : this, i18n("Device is busy?"));
+ MessageBox::error(p ? p : this, i18n("Device is busy?"));
reject();
return 0;
}
diff --git a/solid-lite/CMakeLists.txt b/solid-lite/CMakeLists.txt
new file mode 100644
index 000000000..16457fde7
--- /dev/null
+++ b/solid-lite/CMakeLists.txt
@@ -0,0 +1,310 @@
+INCLUDE(MacroOptionalFindPackage)
+INCLUDE(MacroLogFeature)
+
+add_subdirectory( ifaces )
+include_directories( ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_BINARY_DIR} ${QT_INCLUDES})
+
+file(MAKE_DIRECTORY
+ ${CMAKE_CURRENT_BINARY_DIR}/backends/hal
+ ${CMAKE_CURRENT_BINARY_DIR}/backends/udev
+ ${CMAKE_CURRENT_BINARY_DIR}/backends/wmi
+)
+
+set(solidlite_LIB_SRCS
+ solidnamespace.cpp
+ managerbase.cpp
+ device.cpp
+ devicemanager.cpp
+ deviceinterface.cpp
+ genericinterface.cpp
+ block.cpp
+ storagedrive.cpp
+ opticaldrive.cpp
+ storagevolume.cpp
+ opticaldisc.cpp
+ storageaccess.cpp
+ portablemediaplayer.cpp
+ predicate.cpp
+ predicateparse.cpp
+ predicate_lexer.c
+ predicate_parser.c
+ xdgbasedirs.cpp
+
+ ifaces/block.cpp
+ ifaces/opticaldrive.cpp
+ ifaces/device.cpp
+ ifaces/deviceinterface.cpp
+ ifaces/devicemanager.cpp
+ ifaces/genericinterface.cpp
+ ifaces/opticaldisc.cpp
+ ifaces/portablemediaplayer.cpp
+ ifaces/storagedrive.cpp
+ ifaces/storagevolume.cpp
+ ifaces/storageaccess.cpp
+
+ backends/shared/rootdevice.cpp
+)
+
+set(solidlite_LIB_MOC_HDRS
+ block.h
+ deviceinterface.h
+ devicemanager_p.h
+ devicenotifier.h
+ device_p.h
+ genericinterface.h
+ opticaldisc.h
+ opticaldrive.h
+ portablemediaplayer.h
+ storageaccess.h
+ storagedrive.h
+ storagevolume.h
+ ifaces/device.h
+ ifaces/devicemanager.h
+ backends/shared/rootdevice.h
+)
+ macro_optional_find_package( UDev )
+ macro_log_feature( UDEV_FOUND "UDev" "UDev support for Solid" "http://www.kernel.org/pub/linux/utils/kernel/hotplug/udev.html" FALSE "" "Allows Solid to use UDev to provide information about devices on Linux" )
+ configure_file( config-solid.h.cmake ${CMAKE_CURRENT_BINARY_DIR}/config-solid.h )
+
+
+ if ( UDEV_FOUND )
+ message(STATUS "Building Solid UDev backend." )
+ set(solidlite_LIB_SRCS ${solidlite_LIB_SRCS}
+ backends/udev/udevdevice.cpp
+ backends/udev/udevmanager.cpp
+ backends/udev/udevdeviceinterface.cpp
+ backends/udev/udevgenericinterface.cpp
+ backends/udev/udevportablemediaplayer.cpp
+ backends/udev/udevblock.cpp
+ backends/shared/udevqtclient.cpp
+ backends/shared/udevqtdevice.cpp
+ )
+
+ set(solidlite_LIB_MOC_HDRS ${solidlite_LIB_MOC_HDRS}
+ backends/udev/udevblock.h
+ backends/udev/udevdevice.h
+ backends/udev/udevdeviceinterface.h
+ backends/udev/udevgenericinterface.h
+ backends/udev/udevmanager.h
+ backends/udev/udevportablemediaplayer.h
+ backends/shared/udevqt.h
+ )
+ # check for media-player-info (runtime-only optional dependency)
+ set(XDG_DATA_DIRS_ENV $ENV{XDG_DATA_DIRS}) # if(ENV{..}) does not work for me
+ if(XDG_DATA_DIRS_ENV)
+ find_path(MEDIAPLAYERINFO_PATH sony_psp.mpi
+ PATHS ENV XDG_DATA_DIRS
+ PATH_SUFFIXES "media-player-info" NO_DEFAULT_PATH
+ )
+ else(XDG_DATA_DIRS_ENV)
+ set(XDG_DATA_DIRS "/usr/share")
+ message(STATUS "Warning: environment variable XDG_DATA_DIRS not set, falling back to ${XDG_DATA_DIRS}")
+ find_path(MEDIAPLAYERINFO_PATH sony_psp.mpi
+ PATHS "${XDG_DATA_DIRS}"
+ PATH_SUFFIXES "media-player-info" NO_DEFAULT_PATH
+ )
+ endif(XDG_DATA_DIRS_ENV)
+
+ macro_log_feature(MEDIAPLAYERINFO_PATH
+ "media-player-info"
+ "Enables identification and querying of portable media players"
+ "http://www.freedesktop.org/wiki/Software/media-player-info"
+ FALSE
+ ""
+ "Runtime-only dependency of the udev solid backend. Support for m-p-i is included even if not found during build"
+ )
+ endif( UDEV_FOUND )
+
+
+ message(STATUS "Building Solid HAL backend." )
+ set(solidlite_LIB_SRCS ${solidlite_LIB_SRCS}
+ backends/hal/halblock.cpp
+ backends/hal/halcdrom.cpp
+ backends/hal/haldeviceinterface.cpp
+ backends/hal/halfstabhandling.cpp
+ backends/hal/halgenericinterface.cpp
+ backends/hal/haldevice.cpp
+ backends/hal/halmanager.cpp
+ backends/hal/halopticaldisc.cpp
+ backends/hal/halportablemediaplayer.cpp
+ backends/hal/halstorageaccess.cpp
+ backends/hal/halstorage.cpp
+ backends/hal/halvolume.cpp
+ )
+ set(solidlite_LIB_MOC_HDRS ${solidlite_LIB_MOC_HDRS}
+ backends/hal/halblock.h
+ backends/hal/halcdrom.h
+ backends/hal/haldevice.h
+ backends/hal/haldeviceinterface.h
+ backends/hal/halgenericinterface.h
+ backends/hal/halmanager.h
+ backends/hal/halopticaldisc.h
+ backends/hal/halportablemediaplayer.h
+ backends/hal/halstorageaccess.h
+ backends/hal/halstorage.h
+ backends/hal/halvolume.h
+ )
+
+ # FIXME: this should work on more Unix systems
+ if (CMAKE_SYSTEM_NAME MATCHES Linux)
+ message(STATUS "Building Solid UDisks backend." )
+ set(solidlite_LIB_SRCS ${solidlite_LIB_SRCS}
+ backends/udisks/udisksmanager.cpp
+ backends/udisks/udisksdevice.cpp
+ backends/udisks/udisksblock.cpp
+ backends/udisks/udisksstoragevolume.cpp
+ backends/udisks/udisksdeviceinterface.cpp
+ backends/udisks/udisksopticaldisc.cpp
+ backends/udisks/udisksopticaldrive.cpp
+ backends/udisks/udisksstoragedrive.cpp
+ backends/udisks/udisksstorageaccess.cpp
+ backends/udisks/udisksgenericinterface.cpp
+ )
+ set(solidlite_LIB_MOC_HDRS ${solidlite_LIB_MOC_HDRS}
+ backends/udisks/udisksblock.h
+ backends/udisks/udisksdevice.h
+ backends/udisks/udisksdeviceinterface.h
+ backends/udisks/udisksgenericinterface.h
+ backends/udisks/udisksmanager.h
+ backends/udisks/udisksopticaldisc.h
+ backends/udisks/udisksopticaldrive.h
+ backends/udisks/udisksstorageaccess.h
+ backends/udisks/udisksstoragedrive.h
+ backends/udisks/udisksstoragevolume.h
+ )
+ endif (CMAKE_SYSTEM_NAME MATCHES Linux)
+
+if(APPLE)
+ find_package(IOKit REQUIRED)
+
+ message(STATUS "-- Building Solid IOKit backend." )
+ set(solidlite_LIB_SRCS ${solidlite_LIB_SRCS}
+ backends/iokit/iokitmanager.cpp
+ backends/iokit/iokitdevice.cpp
+ backends/iokit/cfhelper.cpp
+ backends/iokit/iokitdeviceinterface.cpp
+ backends/iokit/iokitgenericinterface.cpp
+ )
+ set(solidlite_LIB_MOC_HDRS ${solidlite_LIB_MOC_HDRS}
+ backends/iokit/iokitdevice.h
+ backends/iokit/iokitdeviceinterface.h
+ backends/iokit/iokitgenericinterface.h
+ backends/iokit/iokitmanager.h
+ )
+endif(APPLE)
+
+if(WIN32)
+ include(CheckIncludeFileCXX)
+ check_include_file_cxx(wbemidl.h HAVE_WBEM)
+ FIND_LIBRARY(WBEM_LIBRARIES NAMES wbemuuid wbemuuidd)
+ if(HAVE_WBEM AND WBEM_LIBRARIES)
+ set(HAVE_WBEM True)
+ message(STATUS "Found wbemuuid library: ${WBEM_LIBRARIES}")
+ else(HAVE_WBEM AND WBEM_LIBRARIES)
+ set(HAVE_WBEM False)
+ endif(HAVE_WBEM AND WBEM_LIBRARIES)
+ if(HAVE_WBEM AND NOT WINCE)
+ set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DHAVE_WBEM")
+ message(STATUS "-- Building Solid WMI backend." )
+
+ set(solidlite_LIB_SRCS ${solidlite_LIB_SRCS}
+ backends/wmi/wmiblock.cpp
+ backends/wmi/wmicdrom.cpp
+ backends/wmi/wmideviceinterface.cpp
+ backends/wmi/wmigenericinterface.cpp
+ backends/wmi/wmidevice.cpp
+ backends/wmi/wmimanager.cpp
+ backends/wmi/wmiopticaldisc.cpp
+ backends/wmi/wmiportablemediaplayer.cpp
+ backends/wmi/wmiquery.cpp
+ backends/wmi/wmistorageaccess.cpp
+ backends/wmi/wmistorage.cpp
+ backends/wmi/wmivolume.cpp
+
+ )
+ set(solidlite_LIB_MOC_HDRS ${solidlite_LIB_MOC_HDRS}
+ backends/wmi/wmiblock.h
+ backends/wmi/wmicdrom.h
+ backends/wmi/wmidevice.h
+ backends/wmi/wmideviceinterface.h
+ backends/wmi/wmigenericinterface.h
+ backends/wmi/wmimanager.h
+ backends/wmi/wmiopticaldisc.h
+ backends/wmi/wmiportablemediaplayer.h
+ backends/wmi/wmistorageaccess.h
+ backends/wmi/wmistorage.h
+ backends/wmi/wmivolume.h
+ )
+ endif(HAVE_WBEM AND NOT WINCE)
+endif(WIN32)
+
+set(solidlite_OPTIONAL_LIBS)
+
+if(WIN32)
+ set(solidlite_OPTIONAL_LIBS ${solidlite_OPTIONAL_LIBS} ${KDEWIN_LIBRARY})
+ if(HAVE_WBEM)
+ set(solidlite_OPTIONAL_LIBS ${solidlite_OPTIONAL_LIBS} ${WBEM_LIBRARIES})
+ endif(HAVE_WBEM)
+endif(WIN32)
+
+if(APPLE)
+ set(solidlite_OPTIONAL_LIBS ${IOKIT_LIBRARY})
+endif(APPLE)
+
+QT4_WRAP_CPP(solidlite_LIB_MOC_SRCS ${solidlite_LIB_MOC_HDRS} )
+add_library(solidlite ${solidlite_LIB_SRCS} ${solidlite_LIB_MOC_SRCS})
+# set_target_properties(solidlite PROPERTIES AUTOMOC TRUE)
+
+if ( UDEV_FOUND )
+ set(solidlite_OPTIONAL_LIBS ${solidlite_OPTIONAL_LIBS} ${UDEV_LIBS})
+endif ( UDEV_FOUND )
+
+target_link_libraries(solidlite ${QT_QTCORE_LIBRARY} ${QT_QTDBUS_LIBRARY} ${QT_QTXML_LIBRARY} ${QT_QTGUI_LIBRARY} ${solidlite_OPTIONAL_LIBS} )
+target_link_libraries(solidlite LINK_INTERFACE_LIBRARIES ${QT_CORE_LIBRARY} )
+
+if (WINCE)
+ target_link_libraries(solidlite ${WCECOMPAT_LIBRARIES})
+endif(WINCE)
+
+# set_target_properties(solidlite PROPERTIES
+# VERSION ${GENERIC_LIB_VERSION}
+# SOVERSION ${GENERIC_LIB_SOVERSION}
+# )
+
+#set(lexer_FILE predicate_lexer)
+#set(parser_FILE predicate_parser)
+
+#find_package(Flex)
+#macro_log_feature(FLEX_FOUND
+# "Flex"
+# "Allows the Solid predicate parser to be updated"
+# "http://flex.sourceforge.net"
+# FALSE
+# ""
+# "Required by the UpdateSolidPredicateParser target (mainly useful for developers)")
+
+#find_program(BISON_EXECUTABLE bison)
+#macro_log_feature(BISON_EXECUTABLE
+# "Bison"
+# "Allows the Solid predicate parser to be updated"
+# "http://www.gnu.org/software/bison"
+# FALSE
+# ""
+# "Required by the UpdateSolidPredicateParser target (mainly useful for developers)")
+#mark_as_advanced(BISON_EXECUTABLE) # don't show it in the simple view in cmake-gui/ccmake
+
+# if (FLEX_EXECUTABLE AND BISON_EXECUTABLE)
+#
+# add_custom_target(UpdateSolidPredicateParser
+# COMMAND ${FLEX_EXECUTABLE} -P Solid -o${lexer_FILE}.c ${lexer_FILE}.l
+# COMMAND ${BISON_EXECUTABLE} -p Solid -d -b ${parser_FILE} ${parser_FILE}.y
+# COMMAND ${CMAKE_COMMAND} -E copy ${parser_FILE}.tab.c ${CMAKE_CURRENT_SOURCE_DIR}/${parser_FILE}.c
+# COMMAND ${CMAKE_COMMAND} -E copy ${parser_FILE}.tab.h ${CMAKE_CURRENT_SOURCE_DIR}/${parser_FILE}.h
+# COMMAND ${CMAKE_COMMAND} -E remove ${parser_FILE}.tab.c ${parser_FILE}.tab.h
+# WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR})
+#
+# else (FLEX_EXECUTABLE AND BISON_EXECUTABLE)
+# add_custom_target(UpdateSolidPredicateParser
+# COMMAND echo "flex and/or bison not found, so target UpdateSolidPredicateParser inactive")
+# endif (FLEX_EXECUTABLE AND BISON_EXECUTABLE)
+
diff --git a/solid-lite/README b/solid-lite/README
new file mode 100644
index 000000000..26a872b53
--- /dev/null
+++ b/solid-lite/README
@@ -0,0 +1,3 @@
+This is a (cut down) copy of Solid for KDE4.9.1
+
+Only disk/medisplayer detection is remaining - as this is all Cantata needs.
diff --git a/solid-lite/backends/hal/halblock.cpp b/solid-lite/backends/hal/halblock.cpp
new file mode 100644
index 000000000..f5f5f09f8
--- /dev/null
+++ b/solid-lite/backends/hal/halblock.cpp
@@ -0,0 +1,53 @@
+/*
+ Copyright 2006 Kevin Ottens
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) version 3, or any
+ later version accepted by the membership of KDE e.V. (or its
+ successor approved by the membership of KDE e.V.), which shall
+ act as a proxy defined in Section 6 of version 3 of the license.
+
+ This library 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
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with this library. If not, see .
+*/
+
+#include "halblock.h"
+
+#include "haldevice.h"
+
+using namespace Solid::Backends::Hal;
+
+Block::Block(HalDevice *device)
+ : DeviceInterface(device)
+{
+
+}
+
+Block::~Block()
+{
+
+}
+
+int Block::deviceMajor() const
+{
+ return m_device->prop("block.major").toInt();
+}
+
+int Block::deviceMinor() const
+{
+ return m_device->prop("block.minor").toInt();
+}
+
+QString Block::device() const
+{
+ return m_device->prop("block.device").toString();
+}
+
+//#include "backends/hal/halblock.moc"
diff --git a/solid-lite/backends/hal/halblock.h b/solid-lite/backends/hal/halblock.h
new file mode 100644
index 000000000..edf4a9415
--- /dev/null
+++ b/solid-lite/backends/hal/halblock.h
@@ -0,0 +1,50 @@
+/*
+ Copyright 2006 Kevin Ottens
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) version 3, or any
+ later version accepted by the membership of KDE e.V. (or its
+ successor approved by the membership of KDE e.V.), which shall
+ act as a proxy defined in Section 6 of version 3 of the license.
+
+ This library 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
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with this library. If not, see .
+*/
+
+#ifndef SOLID_BACKENDS_HAL_BLOCK_H
+#define SOLID_BACKENDS_HAL_BLOCK_H
+
+#include
+#include "haldeviceinterface.h"
+
+namespace Solid
+{
+namespace Backends
+{
+namespace Hal
+{
+class Block : public DeviceInterface, virtual public Solid::Ifaces::Block
+{
+ Q_OBJECT
+ Q_INTERFACES(Solid::Ifaces::Block)
+
+public:
+ Block(HalDevice *device);
+ virtual ~Block();
+
+ virtual int deviceMajor() const;
+ virtual int deviceMinor() const;
+ virtual QString device() const;
+};
+}
+}
+}
+
+#endif // SOLID_BACKENDS_HAL_BLOCK_H
diff --git a/solid-lite/backends/hal/halcdrom.cpp b/solid-lite/backends/hal/halcdrom.cpp
new file mode 100644
index 000000000..1216641db
--- /dev/null
+++ b/solid-lite/backends/hal/halcdrom.cpp
@@ -0,0 +1,218 @@
+/*
+ Copyright 2006 Kevin Ottens
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) version 3, or any
+ later version accepted by the membership of KDE e.V. (or its
+ successor approved by the membership of KDE e.V.), which shall
+ act as a proxy defined in Section 6 of version 3 of the license.
+
+ This library 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
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with this library. If not, see .
+*/
+
+#include "halcdrom.h"
+
+#include
+#include
+#include
+#include
+#include
+
+#include "halfstabhandling.h"
+
+using namespace Solid::Backends::Hal;
+
+Cdrom::Cdrom(HalDevice *device)
+ : Storage(device), m_ejectInProgress(false)
+{
+ connect(device, SIGNAL(conditionRaised(QString,QString)),
+ this, SLOT(slotCondition(QString,QString)));
+ m_device->registerAction("eject", this,
+ SLOT(slotEjectRequested()),
+ SLOT(slotEjectDone(int,QString)));
+}
+
+Cdrom::~Cdrom()
+{
+
+}
+
+
+Solid::OpticalDrive::MediumTypes Cdrom::supportedMedia() const
+{
+ Solid::OpticalDrive::MediumTypes supported;
+
+ QMap map;
+ map[Solid::OpticalDrive::Cdr] = "storage.cdrom.cdr";
+ map[Solid::OpticalDrive::Cdrw] = "storage.cdrom.cdrw";
+ map[Solid::OpticalDrive::Dvd] = "storage.cdrom.dvd";
+ map[Solid::OpticalDrive::Dvdr] = "storage.cdrom.dvdr";
+ map[Solid::OpticalDrive::Dvdrw] ="storage.cdrom.dvdrw";
+ map[Solid::OpticalDrive::Dvdram] ="storage.cdrom.dvdram";
+ map[Solid::OpticalDrive::Dvdplusr] ="storage.cdrom.dvdplusr";
+ map[Solid::OpticalDrive::Dvdplusrw] ="storage.cdrom.dvdplusrw";
+ map[Solid::OpticalDrive::Dvdplusdl] ="storage.cdrom.dvdplusrdl";
+ map[Solid::OpticalDrive::Dvdplusdlrw] ="storage.cdrom.dvdplusrwdl";
+ map[Solid::OpticalDrive::Bd] ="storage.cdrom.bd";
+ map[Solid::OpticalDrive::Bdr] ="storage.cdrom.bdr";
+ map[Solid::OpticalDrive::Bdre] ="storage.cdrom.bdre";
+ map[Solid::OpticalDrive::HdDvd] ="storage.cdrom.hddvd";
+ map[Solid::OpticalDrive::HdDvdr] ="storage.cdrom.hddvdr";
+ map[Solid::OpticalDrive::HdDvdrw] ="storage.cdrom.hddvdrw";
+
+ foreach (const Solid::OpticalDrive::MediumType type, map.keys())
+ {
+ if (m_device->prop(map[type]).toBool())
+ {
+ supported|= type;
+ }
+ }
+
+ return supported;
+}
+
+int Cdrom::readSpeed() const
+{
+ return m_device->prop("storage.cdrom.read_speed").toInt();
+}
+
+int Cdrom::writeSpeed() const
+{
+ return m_device->prop("storage.cdrom.write_speed").toInt();
+}
+
+QList Cdrom::writeSpeeds() const
+{
+ QList speeds;
+ QStringList speed_strlist = m_device->prop("storage.cdrom.write_speeds").toStringList();
+
+ foreach (const QString &speed_str, speed_strlist)
+ {
+ speeds << speed_str.toInt();
+ }
+
+ return speeds;
+}
+
+void Cdrom::slotCondition(const QString &name, const QString &/*reason */)
+{
+ if (name == "EjectPressed")
+ {
+ emit ejectPressed(m_device->udi());
+ }
+}
+
+bool Cdrom::eject()
+{
+ if (m_ejectInProgress) {
+ return false;
+ }
+ m_ejectInProgress = true;
+ m_device->broadcastActionRequested("eject");
+
+ if (FstabHandling::isInFstab(m_device->prop("block.device").toString())) {
+ return callSystemEject();
+ } else {
+ return callHalDriveEject();
+ }
+}
+
+void Cdrom::slotEjectRequested()
+{
+ m_ejectInProgress = true;
+ emit ejectRequested(m_device->udi());
+}
+
+bool Cdrom::callHalDriveEject()
+{
+ QString udi = m_device->udi();
+ QString interface = "org.freedesktop.Hal.Device.Storage";
+
+ // HACK: Eject doesn't work on cdrom drives when there's a mounted disc,
+ // let's try to workaround this by calling a child volume...
+ if (m_device->prop("storage.removable.media_available").toBool()) {
+ QDBusInterface manager("org.freedesktop.Hal",
+ "/org/freedesktop/Hal/Manager",
+ "org.freedesktop.Hal.Manager",
+ QDBusConnection::systemBus());
+
+ QDBusReply reply = manager.call("FindDeviceStringMatch", "info.parent", udi);
+
+ if (reply.isValid())
+ {
+ const QStringList udis = reply;
+ if (!udis.isEmpty()) {
+ udi = udis[0];
+ interface = "org.freedesktop.Hal.Device.Volume";
+ }
+ }
+ }
+
+ QDBusConnection c = QDBusConnection::systemBus();
+ QDBusMessage msg = QDBusMessage::createMethodCall("org.freedesktop.Hal", udi,
+ interface, "Eject");
+
+ msg << QStringList();
+
+
+ return c.callWithCallback(msg, this,
+ SLOT(slotDBusReply(QDBusMessage)),
+ SLOT(slotDBusError(QDBusError)));
+}
+
+bool Solid::Backends::Hal::Cdrom::callSystemEject()
+{
+ const QString device = m_device->prop("block.device").toString();
+ m_process = FstabHandling::callSystemCommand("eject", device,
+ this, SLOT(slotProcessFinished(int,QProcess::ExitStatus)));
+
+ return m_process!=0;
+}
+
+void Cdrom::slotDBusReply(const QDBusMessage &/*reply*/)
+{
+ m_ejectInProgress = false;
+ m_device->broadcastActionDone("eject");
+}
+
+void Cdrom::slotDBusError(const QDBusError &error)
+{
+ m_ejectInProgress = false;
+
+ // TODO: Better error reporting here
+ m_device->broadcastActionDone("eject", Solid::UnauthorizedOperation,
+ QString(error.name()+": "+error.message()));
+}
+
+void Solid::Backends::Hal::Cdrom::slotProcessFinished(int exitCode, QProcess::ExitStatus exitStatus)
+{
+ Q_UNUSED(exitStatus);
+ if (m_ejectInProgress) {
+ m_ejectInProgress = false;
+
+ if (exitCode==0) {
+ m_device->broadcastActionDone("eject");
+ } else {
+ m_device->broadcastActionDone("eject", Solid::UnauthorizedOperation,
+ m_process->readAllStandardError());
+ }
+ }
+
+ delete m_process;
+}
+
+void Cdrom::slotEjectDone(int error, const QString &errorString)
+{
+ m_ejectInProgress = false;
+ emit ejectDone(static_cast(error), errorString, m_device->udi());
+}
+
+//#include "backends/hal/halcdrom.moc"
diff --git a/solid-lite/backends/hal/halcdrom.h b/solid-lite/backends/hal/halcdrom.h
new file mode 100644
index 000000000..7f0d3e771
--- /dev/null
+++ b/solid-lite/backends/hal/halcdrom.h
@@ -0,0 +1,77 @@
+/*
+ Copyright 2006 Kevin Ottens
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) version 3, or any
+ later version accepted by the membership of KDE e.V. (or its
+ successor approved by the membership of KDE e.V.), which shall
+ act as a proxy defined in Section 6 of version 3 of the license.
+
+ This library 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
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with this library. If not, see .
+*/
+
+#ifndef SOLID_BACKENDS_HAL_CDROM_H
+#define SOLID_BACKENDS_HAL_CDROM_H
+
+#include
+#include "halstorage.h"
+
+#include
+#include
+#include
+#include
+
+namespace Solid
+{
+namespace Backends
+{
+namespace Hal
+{
+class Cdrom : public Storage, virtual public Solid::Ifaces::OpticalDrive
+{
+ Q_OBJECT
+ Q_INTERFACES(Solid::Ifaces::OpticalDrive)
+
+public:
+ Cdrom(HalDevice *device);
+ virtual ~Cdrom();
+
+ virtual Solid::OpticalDrive::MediumTypes supportedMedia() const;
+ virtual int readSpeed() const;
+ virtual int writeSpeed() const;
+ virtual QList writeSpeeds() const;
+ virtual bool eject();
+
+Q_SIGNALS:
+ void ejectPressed(const QString &udi);
+ void ejectDone(Solid::ErrorType error, QVariant errorData, const QString &udi);
+ void ejectRequested(const QString &udi);
+
+private Q_SLOTS:
+ void slotCondition(const QString &name, const QString &reason);
+ void slotDBusReply(const QDBusMessage &reply);
+ void slotDBusError(const QDBusError &error);
+ void slotProcessFinished(int exitCode, QProcess::ExitStatus exitStatus);
+ void slotEjectRequested();
+ void slotEjectDone(int error, const QString &errorString);
+
+private:
+ bool callHalDriveEject();
+ bool callSystemEject();
+
+ bool m_ejectInProgress;
+ QProcess *m_process;
+};
+}
+}
+}
+
+#endif // SOLID_BACKENDS_HAL_CDROM_H
diff --git a/solid-lite/backends/hal/haldevice.cpp b/solid-lite/backends/hal/haldevice.cpp
new file mode 100644
index 000000000..d66a28201
--- /dev/null
+++ b/solid-lite/backends/hal/haldevice.cpp
@@ -0,0 +1,851 @@
+/*
+ Copyright 2005-2007 Kevin Ottens
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) version 3, or any
+ later version accepted by the membership of KDE e.V. (or its
+ successor approved by the membership of KDE e.V.), which shall
+ act as a proxy defined in Section 6 of version 3 of the license.
+
+ This library 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
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with this library. If not, see .
+*/
+
+#include "haldevice.h"
+
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+
+#include
+
+#include "haldeviceinterface.h"
+#include "halgenericinterface.h"
+//#include "halprocessor.h"
+#include "halblock.h"
+#include "halstorageaccess.h"
+#include "halstorage.h"
+#include "halcdrom.h"
+//#include "halvolume.h"
+#include "halopticaldisc.h"
+//#include "halcamera.h"
+#include "halportablemediaplayer.h"
+//#include "halnetworkinterface.h"
+//#include "halacadapter.h"
+//#include "halbattery.h"
+//#include "halbutton.h"
+//#include "halaudiointerface.h"
+//#include "haldvbinterface.h"
+//#include "halvideo.h"
+//#include "halserialinterface.h"
+//#include "halsmartcardreader.h"
+
+using namespace Solid::Backends::Hal;
+
+// Adapted from KLocale as Solid needs to be Qt-only
+static QString formatByteSize(double size)
+{
+ // Per IEC 60027-2
+
+ // Binary prefixes
+ //Tebi-byte TiB 2^40 1,099,511,627,776 bytes
+ //Gibi-byte GiB 2^30 1,073,741,824 bytes
+ //Mebi-byte MiB 2^20 1,048,576 bytes
+ //Kibi-byte KiB 2^10 1,024 bytes
+
+ QString s;
+ // Gibi-byte
+ if ( size >= 1073741824.0 )
+ {
+ size /= 1073741824.0;
+ if ( size > 1024 ) // Tebi-byte
+ s = QObject::tr("%1 TiB").arg(QLocale().toString(size / 1024.0, 'f', 1));
+ else
+ s = QObject::tr("%1 GiB").arg(QLocale().toString(size, 'f', 1));
+ }
+ // Mebi-byte
+ else if ( size >= 1048576.0 )
+ {
+ size /= 1048576.0;
+ s = QObject::tr("%1 MiB").arg(QLocale().toString(size, 'f', 1));
+ }
+ // Kibi-byte
+ else if ( size >= 1024.0 )
+ {
+ size /= 1024.0;
+ s = QObject::tr("%1 KiB").arg(QLocale().toString(size, 'f', 1));
+ }
+ // Just byte
+ else if ( size > 0 )
+ {
+ s = QObject::tr("%1 B").arg(QLocale().toString(size, 'f', 1));
+ }
+ // Nothing
+ else
+ {
+ s = QObject::tr("0 B");
+ }
+ return s;
+}
+
+class Solid::Backends::Hal::HalDevicePrivate
+{
+public:
+ HalDevicePrivate(const QString &udi)
+ : device("org.freedesktop.Hal",
+ udi,
+ "org.freedesktop.Hal.Device",
+ QDBusConnection::systemBus()),
+ cacheSynced(false), parent(0) { }
+ void checkCache(const QString &key = QString());
+
+ QDBusInterface device;
+ QMap cache;
+ QMap capListCache;
+ QSet invalidKeys;
+
+ bool cacheSynced;
+ HalDevice *parent;
+};
+
+Q_DECLARE_METATYPE(ChangeDescription)
+Q_DECLARE_METATYPE(QList)
+
+const QDBusArgument &operator<<(QDBusArgument &arg, const ChangeDescription &change)
+{
+ arg.beginStructure();
+ arg << change.key << change.added << change.removed;
+ arg.endStructure();
+ return arg;
+}
+
+const QDBusArgument &operator>>(const QDBusArgument &arg, ChangeDescription &change)
+{
+ arg.beginStructure();
+ arg >> change.key >> change.added >> change.removed;
+ arg.endStructure();
+ return arg;
+}
+
+HalDevice::HalDevice(const QString &udi)
+ : Device(), d(new HalDevicePrivate(udi))
+{
+ qDBusRegisterMetaType();
+ qDBusRegisterMetaType< QList >();
+
+ d->device.connection().connect("org.freedesktop.Hal",
+ udi, "org.freedesktop.Hal.Device",
+ "PropertyModified",
+ this, SLOT(slotPropertyModified(int,QList)));
+ d->device.connection().connect("org.freedesktop.Hal",
+ udi, "org.freedesktop.Hal.Device",
+ "Condition",
+ this, SLOT(slotCondition(QString,QString)));
+}
+
+HalDevice::~HalDevice()
+{
+ delete d->parent;
+ delete d;
+}
+
+QString HalDevice::udi() const
+{
+ return prop("info.udi").toString();
+}
+
+QString HalDevice::parentUdi() const
+{
+ return prop("info.parent").toString();
+}
+
+QString HalDevice::vendor() const
+{
+ const QString category = prop("info.category").toString();
+
+ if (category == QLatin1String("battery")) {
+ return prop("battery.vendor").toString();
+ } else {
+ return prop("info.vendor").toString();
+ }
+}
+
+QString HalDevice::product() const
+{
+ return prop("info.product").toString();
+}
+
+QString HalDevice::icon() const
+{
+ QString category = prop("info.category").toString();
+
+ if(parentUdi().isEmpty()) {
+
+ QString formfactor = prop("system.formfactor").toString();
+ if (formfactor=="laptop") {
+ return "computer-laptop";
+ } else {
+ return "computer";
+ }
+
+ } else if (category=="storage" || category=="storage.cdrom") {
+
+ if (prop("storage.drive_type").toString()=="floppy") {
+ return "media-floppy";
+ } else if (prop("storage.drive_type").toString()=="cdrom") {
+ return "drive-optical";
+ } else if (prop("storage.drive_type").toString()=="sd_mmc") {
+ return "media-flash-sd-mmc";
+ } else if (prop("storage.hotpluggable").toBool()) {
+ if (prop("storage.bus").toString()=="usb") {
+ if (prop("storage.no_partitions_hint").toBool()
+ || prop("storage.removable.media_size").toLongLong()<4000000000LL) {
+ return "drive-removable-media-usb-pendrive";
+ } else {
+ return "drive-removable-media-usb";
+ }
+ }
+
+ return "drive-removable-media";
+ }
+
+ return "drive-harddisk";
+
+ } else if (category=="volume" || category=="volume.disc") {
+
+ QStringList capabilities = prop("info.capabilities").toStringList();
+
+ if (capabilities.contains("volume.disc")) {
+ bool has_video = prop("volume.disc.is_vcd").toBool()
+ || prop("volume.disc.is_svcd").toBool()
+ || prop("volume.disc.is_videodvd").toBool();
+ bool has_audio = prop("volume.disc.has_audio").toBool();
+ bool recordable = prop("volume.disc.is_blank").toBool()
+ || prop("volume.disc.is_appendable").toBool()
+ || prop("volume.disc.is_rewritable").toBool();
+
+ if (has_video) {
+ return "media-optical-video";
+ } else if (has_audio) {
+ return "media-optical-audio";
+ } else if (recordable) {
+ return "media-optical-recordable";
+ } else {
+ return "media-optical";
+ }
+
+ } else {
+ if (!d->parent) {
+ d->parent = new HalDevice(parentUdi());
+ }
+ QString iconName = d->parent->icon();
+
+ if (!iconName.isEmpty()) {
+ return iconName;
+ }
+
+ return "drive-harddisk";
+ }
+
+ } /*else if (category=="camera") {
+ return "camera-photo";
+
+ } else if (category=="input") {
+ QStringList capabilities = prop("info.capabilities").toStringList();
+
+ if (capabilities.contains("input.mouse")) {
+ return "input-mouse";
+ } else if (capabilities.contains("input.keyboard")) {
+ return "input-keyboard";
+ } else if (capabilities.contains("input.joystick")) {
+ return "input-gaming";
+ } else if (capabilities.contains("input.tablet")) {
+ return "input-tablet";
+ }
+
+ } */ else if (category=="portable_audio_player") {
+ QStringList protocols = prop("portable_audio_player.access_method.protocols").toStringList();
+
+ if (protocols.contains("ipod")) {
+ return "multimedia-player-apple-ipod";
+ } else {
+ return "multimedia-player";
+ }
+ } /* else if (category=="battery") {
+ return "battery";
+ } else if (category=="processor") {
+ return "cpu"; // FIXME: Doesn't follow icon spec
+ } else if (category=="video4linux") {
+ return "camera-web";
+ } else if (category == "alsa" || category == "oss") {
+ // Sorry about this const_cast, but it's the best way to not copy the code from
+ // AudioInterface.
+ const Hal::AudioInterface audioIface(const_cast(this));
+ switch (audioIface.soundcardType()) {
+ case Solid::AudioInterface::InternalSoundcard:
+ return QLatin1String("audio-card");
+ case Solid::AudioInterface::UsbSoundcard:
+ return QLatin1String("audio-card-usb");
+ case Solid::AudioInterface::FirewireSoundcard:
+ return QLatin1String("audio-card-firewire");
+ case Solid::AudioInterface::Headset:
+ if (udi().contains("usb", Qt::CaseInsensitive) ||
+ audioIface.name().contains("usb", Qt::CaseInsensitive)) {
+ return QLatin1String("audio-headset-usb");
+ } else {
+ return QLatin1String("audio-headset");
+ }
+ case Solid::AudioInterface::Modem:
+ return QLatin1String("modem");
+ }
+ } else if (category == "serial") {
+ // TODO - a serial device can be a modem, or just
+ // a COM port - need a new icon?
+ return QLatin1String("modem");
+ } else if (category == "smart_card_reader") {
+ return QLatin1String("smart-card-reader");
+ } */
+
+ return QString();
+}
+
+QStringList HalDevice::emblems() const
+{
+ QStringList res;
+
+ if (queryDeviceInterface(Solid::DeviceInterface::StorageAccess)) {
+ bool isEncrypted = prop("volume.fsusage").toString()=="crypto";
+
+ const Hal::StorageAccess accessIface(const_cast(this));
+ if (accessIface.isAccessible()) {
+ if (isEncrypted) {
+ res << "emblem-encrypted-unlocked";
+ } else {
+ res << "emblem-mounted";
+ }
+ } else {
+ if (isEncrypted) {
+ res << "emblem-encrypted-locked";
+ } else {
+ res << "emblem-unmounted";
+ }
+ }
+ }
+
+ return res;
+}
+
+QString HalDevice::description() const
+{
+ QString category = prop("info.category").toString();
+
+ if (category=="storage" || category=="storage.cdrom") {
+ return storageDescription();
+ } else if (category=="volume" || category=="volume.disc") {
+ return volumeDescription();
+ } /*else if (category=="net.80211") {
+ return QObject::tr("WLAN Interface");
+ } else if (category=="net.80203") {
+ return QObject::tr("Networking Interface");
+ } */ else {
+ return product();
+ }
+}
+
+QVariant HalDevice::prop(const QString &key) const
+{
+ d->checkCache(key);
+ return d->cache.value(key);
+}
+
+void HalDevicePrivate::checkCache(const QString &key)
+{
+ if (cacheSynced) {
+ if (key.isEmpty()) {
+ if (invalidKeys.isEmpty()) {
+ return;
+ }
+ } else if (!invalidKeys.contains(key)) {
+ return;
+ }
+ }
+
+ QDBusReply reply = device.call("GetAllProperties");
+
+ if (reply.isValid()) {
+ cache = reply;
+ } else {
+ qWarning() << Q_FUNC_INFO << " error: " << reply.error().name()
+ << ", " << reply.error().message() << endl;
+ cache = QVariantMap();
+ }
+
+ invalidKeys.clear();
+ cacheSynced = true;
+ //qDebug( )<< q << udi() << "failure";
+}
+
+QMap HalDevice::allProperties() const
+{
+ d->checkCache();
+ return d->cache;
+}
+
+bool HalDevice::propertyExists(const QString &key) const
+{
+ d->checkCache(key);
+ return d->cache.value(key).isValid();
+}
+
+bool HalDevice::queryDeviceInterface(const Solid::DeviceInterface::Type &type) const
+{
+ // Special cases not matching with HAL capabilities
+ if (type==Solid::DeviceInterface::GenericInterface) {
+ return true;
+ } else if (type==Solid::DeviceInterface::StorageAccess) {
+ return prop("org.freedesktop.Hal.Device.Volume.method_names").toStringList().contains("Mount")
+ || prop("info.interfaces").toStringList().contains("org.freedesktop.Hal.Device.Volume.Crypto");
+ }
+ /*else if (type==Solid::DeviceInterface::Video) {
+ if (!prop("video4linux.device").toString().contains("video" ) )
+ return false;
+ } */else if (d->capListCache.contains(type)) {
+ return d->capListCache.value(type);
+ }
+
+ QStringList cap_list = DeviceInterface::toStringList(type);
+
+ foreach (const QString &cap, cap_list) {
+ QDBusReply reply = d->device.call("QueryCapability", cap);
+
+ if (!reply.isValid()) {
+ qWarning() << Q_FUNC_INFO << " error: " << reply.error().name() << endl;
+ return false;
+ }
+
+ if (reply) {
+ d->capListCache.insert(type, true);
+ return true;
+ }
+ }
+
+ d->capListCache.insert(type, false);
+ return false;
+}
+
+QObject *HalDevice::createDeviceInterface(const Solid::DeviceInterface::Type &type)
+{
+ if (!queryDeviceInterface(type)) {
+ return 0;
+ }
+
+ DeviceInterface *iface = 0;
+
+ switch (type)
+ {
+ case Solid::DeviceInterface::GenericInterface:
+ iface = new GenericInterface(this);
+ break;
+ //case Solid::DeviceInterface::Processor:
+ // iface = new Processor(this);
+ // break;
+ case Solid::DeviceInterface::Block:
+ iface = new Block(this);
+ break;
+ case Solid::DeviceInterface::StorageAccess:
+ iface = new StorageAccess(this);
+ break;
+ case Solid::DeviceInterface::StorageDrive:
+ iface = new Storage(this);
+ break;
+ case Solid::DeviceInterface::OpticalDrive:
+ iface = new Cdrom(this);
+ break;
+ case Solid::DeviceInterface::StorageVolume:
+ iface = new Volume(this);
+ break;
+ case Solid::DeviceInterface::OpticalDisc:
+ iface = new OpticalDisc(this);
+ break;
+ //case Solid::DeviceInterface::Camera:
+ // iface = new Camera(this);
+ // break;
+ case Solid::DeviceInterface::PortableMediaPlayer:
+ iface = new PortableMediaPlayer(this);
+ break;
+ /*case Solid::DeviceInterface::NetworkInterface:
+ iface = new NetworkInterface(this);
+ break;
+ case Solid::DeviceInterface::AcAdapter:
+ iface = new AcAdapter(this);
+ break;
+ case Solid::DeviceInterface::Battery:
+ iface = new Battery(this);
+ break;
+ case Solid::DeviceInterface::Button:
+ iface = new Button(this);
+ break;
+ case Solid::DeviceInterface::AudioInterface:
+ iface = new AudioInterface(this);
+ break;
+ case Solid::DeviceInterface::DvbInterface:
+ iface = new DvbInterface(this);
+ break;
+ case Solid::DeviceInterface::Video:
+ iface = new Video(this);
+ break;
+ case Solid::DeviceInterface::SerialInterface:
+ iface = new SerialInterface(this);
+ break;
+ case Solid::DeviceInterface::SmartCardReader:
+ iface = new SmartCardReader(this);
+ break;
+ case Solid::DeviceInterface::InternetGateway:
+ break;
+ case Solid::DeviceInterface::NetworkShare:
+ break;
+ */
+ case Solid::DeviceInterface::Unknown:
+ case Solid::DeviceInterface::Last:
+ break;
+ }
+
+ return iface;
+}
+
+void HalDevice::slotPropertyModified(int /*count */, const QList &changes)
+{
+ QMap result;
+
+ foreach (const ChangeDescription &change, changes) {
+ QString key = change.key;
+ bool added = change.added;
+ bool removed = change.removed;
+
+ Solid::GenericInterface::PropertyChange type = Solid::GenericInterface::PropertyModified;
+
+ if (added) {
+ type = Solid::GenericInterface::PropertyAdded;
+ } else if (removed) {
+ type = Solid::GenericInterface::PropertyRemoved;
+ }
+
+ result[key] = type;
+ d->cache.remove(key);
+
+ if (d->cache.isEmpty()) {
+ d->cacheSynced = false;
+ d->invalidKeys.clear();
+ } else {
+ d->invalidKeys.insert(key);
+ }
+ }
+
+ //qDebug() << this << "unsyncing the cache";
+ emit propertyChanged(result);
+}
+
+void HalDevice::slotCondition(const QString &condition, const QString &reason)
+{
+ emit conditionRaised(condition, reason);
+}
+
+QString HalDevice::storageDescription() const
+{
+ QString description;
+ const Storage storageDrive(const_cast(this));
+ Solid::StorageDrive::DriveType drive_type = storageDrive.driveType();
+ bool drive_is_hotpluggable = storageDrive.isHotpluggable();
+
+ if (drive_type == Solid::StorageDrive::CdromDrive) {
+ const Cdrom opticalDrive(const_cast(this));
+ Solid::OpticalDrive::MediumTypes mediumTypes = opticalDrive.supportedMedia();
+ QString first;
+ QString second;
+
+ first = QObject::tr("CD-ROM", "First item of %1%2 Drive sentence");
+ if (mediumTypes & Solid::OpticalDrive::Cdr)
+ first = QObject::tr("CD-R", "First item of %1%2 Drive sentence");
+ if (mediumTypes & Solid::OpticalDrive::Cdrw)
+ first = QObject::tr("CD-RW", "First item of %1%2 Drive sentence");
+
+ if (mediumTypes & Solid::OpticalDrive::Dvd)
+ second = QObject::tr("/DVD-ROM", "Second item of %1%2 Drive sentence");
+ if (mediumTypes & Solid::OpticalDrive::Dvdplusr)
+ second = QObject::tr("/DVD+R", "Second item of %1%2 Drive sentence");
+ if (mediumTypes & Solid::OpticalDrive::Dvdplusrw)
+ second = QObject::tr("/DVD+RW", "Second item of %1%2 Drive sentence");
+ if (mediumTypes & Solid::OpticalDrive::Dvdr)
+ second = QObject::tr("/DVD-R", "Second item of %1%2 Drive sentence");
+ if (mediumTypes & Solid::OpticalDrive::Dvdrw)
+ second = QObject::tr("/DVD-RW", "Second item of %1%2 Drive sentence");
+ if (mediumTypes & Solid::OpticalDrive::Dvdram)
+ second = QObject::tr("/DVD-RAM", "Second item of %1%2 Drive sentence");
+ if ((mediumTypes & Solid::OpticalDrive::Dvdr) && (mediumTypes & Solid::OpticalDrive::Dvdplusr)) {
+ if(mediumTypes & Solid::OpticalDrive::Dvdplusdl)
+ second = QObject::tr("/DVD±R DL", "Second item of %1%2 Drive sentence");
+ else
+ second = QObject::tr("/DVD±R", "Second item of %1%2 Drive sentence");
+ }
+ if ((mediumTypes & Solid::OpticalDrive::Dvdrw) && (mediumTypes & Solid::OpticalDrive::Dvdplusrw)) {
+ if((mediumTypes & Solid::OpticalDrive::Dvdplusdl) || (mediumTypes & Solid::OpticalDrive::Dvdplusdlrw))
+ second = QObject::tr("/DVD±RW DL", "Second item of %1%2 Drive sentence");
+ else
+ second = QObject::tr("/DVD±RW", "Second item of %1%2 Drive sentence");
+ }
+ if (mediumTypes & Solid::OpticalDrive::Bd)
+ second = QObject::tr("/BD-ROM", "Second item of %1%2 Drive sentence");
+ if (mediumTypes & Solid::OpticalDrive::Bdr)
+ second = QObject::tr("/BD-R", "Second item of %1%2 Drive sentence");
+ if (mediumTypes & Solid::OpticalDrive::Bdre)
+ second = QObject::tr("/BD-RE", "Second item of %1%2 Drive sentence");
+ if (mediumTypes & Solid::OpticalDrive::HdDvd)
+ second = QObject::tr("/HD DVD-ROM", "Second item of %1%2 Drive sentence");
+ if (mediumTypes & Solid::OpticalDrive::HdDvdr)
+ second = QObject::tr("/HD DVD-R", "Second item of %1%2 Drive sentence");
+ if (mediumTypes & Solid::OpticalDrive::HdDvdrw)
+ second = QObject::tr("/HD DVD-RW", "Second item of %1%2 Drive sentence");
+
+ if (drive_is_hotpluggable) {
+ description = QObject::tr("External %1%2 Drive", "%1 is CD-ROM/CD-R/etc; %2 is '/DVD-ROM'/'/DVD-R'/etc (with leading slash)").arg(first).arg(second);
+ } else {
+ description = QObject::tr("%1%2 Drive", "%1 is CD-ROM/CD-R/etc; %2 is '/DVD-ROM'/'/DVD-R'/etc (with leading slash)").arg(first).arg(second);
+ }
+
+ return description;
+ }
+
+ if (drive_type == Solid::StorageDrive::Floppy) {
+ if (drive_is_hotpluggable)
+ description = QObject::tr("External Floppy Drive");
+ else
+ description = QObject::tr("Floppy Drive");
+
+ return description;
+ }
+
+ bool drive_is_removable = storageDrive.isRemovable();
+
+ if (drive_type == Solid::StorageDrive::HardDisk && !drive_is_removable) {
+ QString size_str = formatByteSize(prop("storage.size").toInt());
+ if (!size_str.isEmpty()) {
+ if (drive_is_hotpluggable) {
+ description = QObject::tr("%1 External Hard Drive", "%1 is the size").arg(size_str);
+ } else {
+ description = QObject::tr("%1 Hard Drive", "%1 is the size").arg(size_str);
+ }
+ } else {
+ if (drive_is_hotpluggable)
+ description = QObject::tr("External Hard Drive");
+ else
+ description = QObject::tr("Hard Drive");
+ }
+
+ return description;
+ }
+
+ QString vendormodel_str;
+ QString model = prop("storage.model").toString();
+ QString vendor = prop("storage.vendor").toString();
+
+ if (vendor.isEmpty()) {
+ if (!model.isEmpty())
+ vendormodel_str = model;
+ } else {
+ if (model.isEmpty())
+ vendormodel_str = vendor;
+ else
+ vendormodel_str = QObject::tr("%1 %2", "%1 is the vendor, %2 is the model of the device").arg(vendor).arg(model);
+ }
+
+ if (vendormodel_str.isEmpty())
+ description = QObject::tr("Drive");
+ else
+ description = vendormodel_str;
+
+ return description;
+}
+
+QString HalDevice::volumeDescription() const
+{
+ QString description;
+ QString volume_label = prop("volume.label").toString();
+
+ if (!volume_label.isEmpty()) {
+ return volume_label;
+ }
+
+ if (!d->parent) {
+ d->parent = new HalDevice(parentUdi());
+ }
+ const Storage storageDrive(const_cast(d->parent));
+ Solid::StorageDrive::DriveType drive_type = storageDrive.driveType();
+
+ /* Handle media in optical drives */
+ if (drive_type == Solid::StorageDrive::CdromDrive) {
+ const OpticalDisc disc(const_cast(this));
+ switch (disc.discType()) {
+ case Solid::OpticalDisc::UnknownDiscType:
+ case Solid::OpticalDisc::CdRom:
+ description = QObject::tr("CD-ROM");
+ break;
+
+ case Solid::OpticalDisc::CdRecordable:
+ if (disc.isBlank())
+ description = QObject::tr("Blank CD-R");
+ else
+ description = QObject::tr("CD-R");
+ break;
+
+ case Solid::OpticalDisc::CdRewritable:
+ if (disc.isBlank())
+ description = QObject::tr("Blank CD-RW");
+ else
+ description = QObject::tr("CD-RW");
+ break;
+
+ case Solid::OpticalDisc::DvdRom:
+ description = QObject::tr("DVD-ROM");
+ break;
+
+ case Solid::OpticalDisc::DvdRam:
+ if (disc.isBlank())
+ description = QObject::tr("Blank DVD-RAM");
+ else
+ description = QObject::tr("DVD-RAM");
+ break;
+
+ case Solid::OpticalDisc::DvdRecordable:
+ if (disc.isBlank())
+ description = QObject::tr("Blank DVD-R");
+ else
+ description = QObject::tr("DVD-R");
+ break;
+
+ case Solid::OpticalDisc::DvdPlusRecordableDuallayer:
+ if (disc.isBlank())
+ description = QObject::tr("Blank DVD+R Dual-Layer");
+ else
+ description = QObject::tr("DVD+R Dual-Layer");
+ break;
+
+ case Solid::OpticalDisc::DvdRewritable:
+ if (disc.isBlank())
+ description = QObject::tr("Blank DVD-RW");
+ else
+ description = QObject::tr("DVD-RW");
+ break;
+
+ case Solid::OpticalDisc::DvdPlusRecordable:
+ if (disc.isBlank())
+ description = QObject::tr("Blank DVD+R");
+ else
+ description = QObject::tr("DVD+R");
+ break;
+
+ case Solid::OpticalDisc::DvdPlusRewritable:
+ if (disc.isBlank())
+ description = QObject::tr("Blank DVD+RW");
+ else
+ description = QObject::tr("DVD+RW");
+ break;
+
+ case Solid::OpticalDisc::DvdPlusRewritableDuallayer:
+ if (disc.isBlank())
+ description = QObject::tr("Blank DVD+RW Dual-Layer");
+ else
+ description = QObject::tr("DVD+RW Dual-Layer");
+ break;
+
+ case Solid::OpticalDisc::BluRayRom:
+ description = QObject::tr("BD-ROM");
+ break;
+
+ case Solid::OpticalDisc::BluRayRecordable:
+ if (disc.isBlank())
+ description = QObject::tr("Blank BD-R");
+ else
+ description = QObject::tr("BD-R");
+ break;
+
+ case Solid::OpticalDisc::BluRayRewritable:
+ if (disc.isBlank())
+ description = QObject::tr("Blank BD-RE");
+ else
+ description = QObject::tr("BD-RE");
+ break;
+
+ case Solid::OpticalDisc::HdDvdRom:
+ description = QObject::tr("HD DVD-ROM");
+ break;
+
+ case Solid::OpticalDisc::HdDvdRecordable:
+ if (disc.isBlank())
+ description = QObject::tr("Blank HD DVD-R");
+ else
+ description = QObject::tr("HD DVD-R");
+ break;
+
+ case Solid::OpticalDisc::HdDvdRewritable:
+ if (disc.isBlank())
+ description = QObject::tr("Blank HD DVD-RW");
+ else
+ description = QObject::tr("HD DVD-RW");
+ break;
+ }
+
+ /* Special case for pure audio disc */
+ if (disc.availableContent() == Solid::OpticalDisc::Audio) {
+ description = QObject::tr("Audio CD");
+ }
+
+ return description;
+ }
+
+ bool drive_is_removable = storageDrive.isRemovable();
+ bool drive_is_hotpluggable = storageDrive.isHotpluggable();
+ bool drive_is_encrypted_container = prop("volume.fsusage").toString()=="crypto";
+
+ QString size_str = formatByteSize(prop("volume.size").toULongLong());
+ if (drive_is_encrypted_container) {
+ if (!size_str.isEmpty()) {
+ description = QObject::tr("%1 Encrypted Container", "%1 is the size").arg(size_str);
+ } else {
+ description = QObject::tr("Encrypted Container");
+ }
+ } else if (drive_type == Solid::StorageDrive::HardDisk && !drive_is_removable) {
+ if (!size_str.isEmpty()) {
+ if (drive_is_hotpluggable) {
+ description = QObject::tr("%1 External Hard Drive", "%1 is the size").arg(size_str);
+ } else {
+ description = QObject::tr("%1 Hard Drive", "%1 is the size").arg(size_str);
+ }
+ } else {
+ if (drive_is_hotpluggable)
+ description = QObject::tr("External Hard Drive");
+ else
+ description = QObject::tr("Hard Drive");
+ }
+ } else {
+ if (drive_is_removable) {
+ description = QObject::tr("%1 Removable Media", "%1 is the size").arg(size_str);
+ } else {
+ description = QObject::tr("%1 Media", "%1 is the size").arg(size_str);
+ }
+ }
+
+ return description;
+}
+
+//#include "backends/hal/haldevice.moc"
diff --git a/solid-lite/backends/hal/haldevice.h b/solid-lite/backends/hal/haldevice.h
new file mode 100644
index 000000000..136258261
--- /dev/null
+++ b/solid-lite/backends/hal/haldevice.h
@@ -0,0 +1,87 @@
+/*
+ Copyright 2005,2006 Kevin Ottens
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) version 3, or any
+ later version accepted by the membership of KDE e.V. (or its
+ successor approved by the membership of KDE e.V.), which shall
+ act as a proxy defined in Section 6 of version 3 of the license.
+
+ This library 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
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with this library. If not, see .
+*/
+
+#ifndef SOLID_BACKENDS_HAL_HALDEVICE_H
+#define SOLID_BACKENDS_HAL_HALDEVICE_H
+
+#include
+
+class QDBusVariant;
+
+namespace Solid
+{
+namespace Backends
+{
+namespace Hal
+{
+class HalManager;
+class HalDevicePrivate;
+
+struct ChangeDescription
+{
+ QString key;
+ bool added;
+ bool removed;
+};
+
+class HalDevice : public Solid::Ifaces::Device
+{
+ Q_OBJECT
+
+public:
+ HalDevice(const QString &udi);
+ virtual ~HalDevice();
+
+ virtual QString udi() const;
+ virtual QString parentUdi() const;
+
+ virtual QString vendor() const;
+ virtual QString product() const;
+ virtual QString icon() const;
+ virtual QStringList emblems() const;
+ virtual QString description() const;
+
+ virtual bool queryDeviceInterface(const Solid::DeviceInterface::Type &type) const;
+ virtual QObject *createDeviceInterface(const Solid::DeviceInterface::Type &type);
+
+public:
+ QVariant prop(const QString &key) const;
+ QMap allProperties() const;
+ bool propertyExists(const QString &key) const;
+
+Q_SIGNALS:
+ void propertyChanged(const QMap &changes);
+ void conditionRaised(const QString &condition, const QString &reason);
+
+private Q_SLOTS:
+ void slotPropertyModified(int count, const QList &changes);
+ void slotCondition(const QString &condition, const QString &reason);
+
+private:
+ QString storageDescription() const;
+ QString volumeDescription() const;
+
+ HalDevicePrivate *d;
+};
+}
+}
+}
+
+#endif // SOLID_BACKENDS_HAL_HALDEVICE_H
diff --git a/solid-lite/backends/hal/haldeviceinterface.cpp b/solid-lite/backends/hal/haldeviceinterface.cpp
new file mode 100644
index 000000000..d479a14ea
--- /dev/null
+++ b/solid-lite/backends/hal/haldeviceinterface.cpp
@@ -0,0 +1,34 @@
+/*
+ Copyright 2006 Kevin Ottens
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) version 3, or any
+ later version accepted by the membership of KDE e.V. (or its
+ successor approved by the membership of KDE e.V.), which shall
+ act as a proxy defined in Section 6 of version 3 of the license.
+
+ This library 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
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with this library. If not, see .
+*/
+
+#include "haldeviceinterface.h"
+
+using namespace Solid::Backends::Hal;
+
+DeviceInterface::DeviceInterface(HalDevice *device)
+ : QObject(device), m_device(device)
+{
+}
+
+DeviceInterface::~DeviceInterface()
+{
+}
+
+//#include "backends/hal/haldeviceinterface.moc"
diff --git a/solid-lite/backends/hal/haldeviceinterface.h b/solid-lite/backends/hal/haldeviceinterface.h
new file mode 100644
index 000000000..1853c5a92
--- /dev/null
+++ b/solid-lite/backends/hal/haldeviceinterface.h
@@ -0,0 +1,172 @@
+/*
+ Copyright 2006 Kevin Ottens
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) version 3, or any
+ later version accepted by the membership of KDE e.V. (or its
+ successor approved by the membership of KDE e.V.), which shall
+ act as a proxy defined in Section 6 of version 3 of the license.
+
+ This library 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
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with this library. If not, see .
+*/
+
+#ifndef SOLID_BACKENDS_HAL_DEVICEINTERFACE_H
+#define SOLID_BACKENDS_HAL_DEVICEINTERFACE_H
+
+#include
+#include "haldevice.h"
+
+#include
+#include
+
+namespace Solid
+{
+namespace Backends
+{
+namespace Hal
+{
+class DeviceInterface : public QObject, virtual public Solid::Ifaces::DeviceInterface
+{
+ Q_OBJECT
+ Q_INTERFACES(Solid::Ifaces::DeviceInterface)
+public:
+ DeviceInterface(HalDevice *device);
+ virtual ~DeviceInterface();
+
+protected:
+ HalDevice *m_device;
+
+public:
+ inline static QStringList toStringList(Solid::DeviceInterface::Type type)
+ {
+ QStringList list;
+
+ switch(type)
+ {
+ case Solid::DeviceInterface::GenericInterface:
+ // Doesn't exist with HAL
+ break;
+ //case Solid::DeviceInterface::Processor:
+ // list << "processor";
+ // break;
+ case Solid::DeviceInterface::Block:
+ list << "block";
+ break;
+ case Solid::DeviceInterface::StorageAccess:
+ // Doesn't exist with HAL, but let's assume volume always cover this type
+ list << "volume";
+ break;
+ case Solid::DeviceInterface::StorageDrive:
+ list << "storage";
+ break;
+ case Solid::DeviceInterface::OpticalDrive:
+ list << "storage.cdrom";
+ break;
+ case Solid::DeviceInterface::StorageVolume:
+ list << "volume";
+ break;
+ case Solid::DeviceInterface::OpticalDisc:
+ list << "volume.disc";
+ break;
+ //case Solid::DeviceInterface::Camera:
+ // list << "camera";
+ // break;
+ case Solid::DeviceInterface::PortableMediaPlayer:
+ list << "portable_audio_player";
+ break;
+ /*case Solid::DeviceInterface::NetworkInterface:
+ list << "net";
+ break;
+ case Solid::DeviceInterface::AcAdapter:
+ list << "ac_adapter";
+ break;
+ case Solid::DeviceInterface::Battery:
+ list << "battery";
+ break;
+ case Solid::DeviceInterface::Button:
+ list << "button";
+ break;
+ case Solid::DeviceInterface::AudioInterface:
+ list << "alsa" << "oss";
+ break;
+ case Solid::DeviceInterface::DvbInterface:
+ list << "dvb";
+ break;
+ case Solid::DeviceInterface::Video:
+ list << "video4linux";
+ break;
+ case Solid::DeviceInterface::SerialInterface:
+ list << "serial";
+ break;
+ case Solid::DeviceInterface::SmartCardReader:
+ list << "smart_card_reader";
+ case Solid::DeviceInterface::InternetGateway:
+ list << "internet_gateway";
+ case Solid::DeviceInterface::NetworkShare:
+ list << "networkshare";
+ break;
+ */
+ case Solid::DeviceInterface::Unknown:
+ break;
+ case Solid::DeviceInterface::Last:
+ break;
+ }
+
+ return list;
+ }
+
+ inline static Solid::DeviceInterface::Type fromString(const QString &capability)
+ {
+ /*if (capability == "processor")
+ return Solid::DeviceInterface::Processor;
+ else */if (capability == "block")
+ return Solid::DeviceInterface::Block;
+ else if (capability == "storage")
+ return Solid::DeviceInterface::StorageDrive;
+ else if (capability == "storage.cdrom")
+ return Solid::DeviceInterface::OpticalDrive;
+ else if (capability == "volume")
+ return Solid::DeviceInterface::StorageVolume;
+ else if (capability == "volume.disc")
+ return Solid::DeviceInterface::OpticalDisc;
+ /*else if (capability == "camera")
+ return Solid::DeviceInterface::Camera; */
+ else if (capability == "portable_audio_player")
+ return Solid::DeviceInterface::PortableMediaPlayer;
+ /*else if (capability == "net")
+ return Solid::DeviceInterface::NetworkInterface;
+ else if (capability == "ac_adapter")
+ return Solid::DeviceInterface::AcAdapter;
+ else if (capability == "battery")
+ return Solid::DeviceInterface::Battery;
+ else if (capability == "button")
+ return Solid::DeviceInterface::Button;
+ else if (capability == "alsa" || capability == "oss")
+ return Solid::DeviceInterface::AudioInterface;
+ else if (capability == "dvb")
+ return Solid::DeviceInterface::DvbInterface;
+ else if (capability == "video4linux")
+ return Solid::DeviceInterface::Video;
+ else if (capability == "serial")
+ return Solid::DeviceInterface::SerialInterface;
+ else if (capability == "smart_card_reader")
+ return Solid::DeviceInterface::SmartCardReader;
+ else if (capability == "networkshare")
+ return Solid::DeviceInterface::NetworkShare;*/
+ else
+ return Solid::DeviceInterface::Unknown;
+ }
+};
+}
+}
+}
+
+#endif // SOLID_BACKENDS_HAL_DEVICEINTERFACE_H
diff --git a/solid-lite/backends/hal/halfstabhandling.cpp b/solid-lite/backends/hal/halfstabhandling.cpp
new file mode 100644
index 000000000..1774e11e9
--- /dev/null
+++ b/solid-lite/backends/hal/halfstabhandling.cpp
@@ -0,0 +1,194 @@
+/*
+ Copyright 2007 Kevin Ottens
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) version 3, or any
+ later version accepted by the membership of KDE e.V. (or its
+ successor approved by the membership of KDE e.V.), which shall
+ act as a proxy defined in Section 6 of version 3 of the license.
+
+ This library 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
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with this library. If not, see .
+*/
+
+#include "halfstabhandling.h"
+
+#include
+#include
+#include
+#include
+#include