[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-commits
Subject: [kdelibs/frameworks] tier1/solid/src/solid: Remove xdgbasedirs copy, replace with a call to QStanda
From: David Faure <faure () kde ! org>
Date: 2012-08-21 22:42:02
Message-ID: 20120821224202.554C7A6096 () git ! kde ! org
[Download RAW message or body]
Git commit ccdef3930f90d1f605b88115bdd7baade62f987f by David Faure.
Committed on 20/08/2012 at 21:55.
Pushed by dfaure into branch 'frameworks'.
Remove xdgbasedirs copy, replace with a call to QStandardPaths.
Cool, huh? :-)
CCMAIL: kevin.krammer@gmx.at
M +5 -2 tier1/solid/src/solid/CMakeLists.txt
M +2 -3 tier1/solid/src/solid/backends/udev/udevportablemediaplayer.cpp
D +0 -135 tier1/solid/src/solid/xdgbasedirs.cpp
D +0 -112 tier1/solid/src/solid/xdgbasedirs_p.h
http://commits.kde.org/kdelibs/ccdef3930f90d1f605b88115bdd7baade62f987f
diff --git a/tier1/solid/src/solid/CMakeLists.txt \
b/tier1/solid/src/solid/CMakeLists.txt index 71a6c97..129d0e4 100644
--- a/tier1/solid/src/solid/CMakeLists.txt
+++ b/tier1/solid/src/solid/CMakeLists.txt
@@ -71,7 +71,6 @@ set(solid_LIB_SRCS
video.cpp
smartcardreader.cpp
internetgateway.cpp
- xdgbasedirs.cpp
ifaces/acadapter.cpp
ifaces/audiointerface.cpp
@@ -398,7 +397,11 @@ add_library(solid ${solid_LIB_SRCS})
generate_export_header(solid)
target_link_libraries(solid LINK_PUBLIC ${QT_QTCORE_LIBRARY}
- LINK_PRIVATE ${QT_QTDBUS_LIBRARY} ${QT_QTXML_LIBRARY} \
${QT_QTGUI_LIBRARY} ${solid_OPTIONAL_LIBS} ) + \
LINK_PRIVATE ${QT_QTDBUS_LIBRARY} + \
${QT_QTXML_LIBRARY} + ${QT_QTGUI_LIBRARY}
+ ${solid_OPTIONAL_LIBS}
+ ${inqt5_LIBRARY} )
set_target_properties(solid PROPERTIES VERSION ${ECM_VERSION_STRING}
SOVERSION ${ECM_SOVERSION} )
diff --git a/tier1/solid/src/solid/backends/udev/udevportablemediaplayer.cpp \
b/tier1/solid/src/solid/backends/udev/udevportablemediaplayer.cpp index \
b35f473..5bb84ac 100644
--- a/tier1/solid/src/solid/backends/udev/udevportablemediaplayer.cpp
+++ b/tier1/solid/src/solid/backends/udev/udevportablemediaplayer.cpp
@@ -22,12 +22,11 @@
#include "udevportablemediaplayer.h"
-#include "solid/xdgbasedirs_p.h"
-
#include <QtCore/QChar>
#include <QtCore/QDebug>
#include <QtCore/QFile>
#include <QtCore/QTextStream>
+#include <qstandardpaths.h>
using namespace Solid::Backends::UDev;
@@ -141,7 +140,7 @@ QString PortableMediaPlayer::mediaPlayerInfoFilePath() const
}
relativeFilename.prepend("media-player-info/");
relativeFilename.append(".mpi");
- QString filename = Solid::XdgBaseDirs::findResourceFile("data", \
relativeFilename); + QString filename = \
QStandardPaths::locate(QStandardPaths::GenericDataLocation, relativeFilename); if \
(filename.isEmpty()) {
qWarning() << "media player info file" << relativeFilename << "not found \
under user and"
<< "system XDG data directories. Do you have media-player-info \
installed?";
diff --git a/tier1/solid/src/solid/xdgbasedirs.cpp \
b/tier1/solid/src/solid/xdgbasedirs.cpp deleted file mode 100644
index e5cafdf..0000000
--- a/tier1/solid/src/solid/xdgbasedirs.cpp
+++ /dev/null
@@ -1,135 +0,0 @@
-/***************************************************************************
- * Copyright (C) 2007 by Kevin Krammer <kevin.krammer@gmx.at> *
- * *
- * This program is free software; you can redistribute it and/or modify *
- * it under the terms of the GNU Library 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 Library General Public *
- * License along with this program; if not, write to the *
- * Free Software Foundation, Inc., *
- * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. *
- ***************************************************************************/
-
-/*
- * This file was copied to solid from [akonadi]/libs/xdgbasedirs.cpp and slimmed \
down.
- * See xdgbasedirs_p.h for notes about slimming down.
- */
-
-#include "xdgbasedirs_p.h"
-
-#include <QtCore/QDir>
-#include <QtCore/QFileInfo>
-
-static QStringList splitPathList( const QString &pathList )
-{
- return pathList.split( QLatin1Char( ':' ) );
-}
-
-class XdgBaseDirsSingleton
-{
- public:
- QString homePath( const char *variable, const char *defaultSubDir );
-
- QStringList systemPathList( const char *variable, const char *defaultDirList );
-
- public:
- QString mConfigHome;
- QString mDataHome;
-
- QStringList mConfigDirs;
- QStringList mDataDirs;
-};
-
-Q_GLOBAL_STATIC( XdgBaseDirsSingleton, instance )
-
-QString Solid::XdgBaseDirs::homePath( const char *resource )
-{
- if ( qstrncmp( "data", resource, 4 ) == 0 ) {
- if ( instance()->mDataHome.isEmpty() ) {
- instance()->mDataHome = instance()->homePath( "XDG_DATA_HOME", ".local/share" \
);
- }
- return instance()->mDataHome;
- } else if ( qstrncmp( "config", resource, 6 ) == 0 ) {
- if ( instance()->mConfigHome.isEmpty() ) {
- instance()->mConfigHome = instance()->homePath( "XDG_CONFIG_HOME", ".config" \
);
- }
- return instance()->mConfigHome;
- }
-
- return QString();
-}
-
-QStringList Solid::XdgBaseDirs::systemPathList( const char *resource )
-{
- if ( qstrncmp( "data", resource, 4 ) == 0 ) {
- if ( instance()->mDataDirs.isEmpty() ) {
- instance()->mDataDirs = instance()->systemPathList( "XDG_DATA_DIRS", \
"/usr/local/share:/usr/share" );
- }
- return instance()->mDataDirs;
- } else if ( qstrncmp( "config", resource, 6 ) == 0 ) {
- if ( instance()->mConfigDirs.isEmpty() ) {
- instance()->mConfigDirs = instance()->systemPathList( "XDG_CONFIG_DIRS", \
"/etc/xdg" );
- }
- return instance()->mConfigDirs;
- }
-
- return QStringList();
-}
-
-QString Solid::XdgBaseDirs::findResourceFile( const char *resource, const QString \
&relPath )
-{
- const QString fullPath = homePath( resource ) + QLatin1Char( '/' ) + relPath;
-
- QFileInfo fileInfo( fullPath );
- if ( fileInfo.exists() && fileInfo.isFile() && fileInfo.isReadable() ) {
- return fullPath;
- }
-
- const QStringList pathList = systemPathList( resource );
-
- Q_FOREACH ( const QString &path, pathList ) {
- fileInfo = QFileInfo( path + QLatin1Char('/' ) + relPath );
- if ( fileInfo.exists() && fileInfo.isFile() && fileInfo.isReadable() ) {
- return fileInfo.absoluteFilePath();
- }
- }
-
- return QString();
-}
-
-QString XdgBaseDirsSingleton::homePath( const char *variable, const char \
*defaultSubDir )
-{
- const QByteArray env = qgetenv( variable );
-
- QString xdgPath;
- if ( env.isEmpty() ) {
- xdgPath = QDir::homePath() + QLatin1Char( '/' ) + QLatin1String( defaultSubDir \
);
- } else if ( env.startsWith( '/' ) ) {
- xdgPath = QString::fromLocal8Bit( env );
- } else {
- xdgPath = QDir::homePath() + QLatin1Char( '/' ) + QString::fromLocal8Bit( env );
- }
-
- return xdgPath;
-}
-
-QStringList XdgBaseDirsSingleton::systemPathList( const char *variable, const char \
*defaultDirList )
-{
- const QByteArray env = qgetenv( variable );
-
- QString xdgDirList;
- if ( env.isEmpty() ) {
- xdgDirList = QLatin1String( defaultDirList );
- } else {
- xdgDirList = QString::fromLocal8Bit( env );
- }
-
- return splitPathList( xdgDirList );
-}
diff --git a/tier1/solid/src/solid/xdgbasedirs_p.h \
b/tier1/solid/src/solid/xdgbasedirs_p.h deleted file mode 100644
index 369d12f..0000000
--- a/tier1/solid/src/solid/xdgbasedirs_p.h
+++ /dev/null
@@ -1,112 +0,0 @@
-/***************************************************************************
- * Copyright (C) 2007 by Kevin Krammer <kevin.krammer@gmx.at> *
- * *
- * This program is free software; you can redistribute it and/or modify *
- * it under the terms of the GNU Library 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 Library General Public *
- * License along with this program; if not, write to the *
- * Free Software Foundation, Inc., *
- * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. *
- ***************************************************************************/
-
-/*
- * This file was copied to solid from [akonadi]/libs/xdgbasedirs_p.h and slimmed \
down.
- * UDev::PortableMediaPlayer uses findResourceFile() which in turn uses homePath() \
and
- * systemPathList() so these are exported here too
- */
-
-#ifndef SOLID_XDGBASEDIRS_H
-#define SOLID_XDGBASEDIRS_H
-
-class QString;
-class QStringList;
-
-namespace Solid
-{
- /**
- @brief Resource type based handling of standard directories
-
- Developers of several Free Software desktop projects have created
- a specification for handling so-called "base directories", i.e.
- lists of system wide directories and directories within each user's
- home directory for installing and later finding certain files.
-
- This class handles the respective behaviour, i.e. environment variables
- and their defaults, for the following type of resources:
- - "config"
- - "data"
-
- @author Kevin Krammer, <kevin.krammer@gmx.at>
-
- @see http://www.freedesktop.org/wiki/Specifications/basedir-spec
- */
- namespace XdgBaseDirs
- {
- /**
- @brief Returns the user specific directory for the given resource type
-
- Unless the user's environment has a specific path set as an override
- this will be the default as defined in the freedesktop.org base-dir-spec
-
- @note Caches the value of the first call
-
- @param resource a named resource type, e.g. "config"
-
- @return a directory path
-
- @see systemPathList()
- */
- QString homePath( const char *resource );
-
- /**
- @brief Returns the list of system wide directories for a given resource \
type
-
- The returned list can contain one or more directory paths. If there are \
more
- than one, the list is sorted by falling priority, i.e. if an entry is valid
- for the respective use case (e.g. contains a file the application looks \
for)
- the list should not be processed further.
-
- @note The user's resource path should, to be compliant with the spec,
- always be treated as having higher priority than any path in the
- list of system wide paths
-
- @note Caches the value of the first call
-
- @param resource a named resource type, e.g. "config"
-
- @return a priority sorted list of directory paths
-
- @see homePath()
- */
- QStringList systemPathList( const char *resource );
-
- /**
- @brief Searches the resource specific directories for a given file
-
- Convenience method for finding a given file (with optional relative path)
- in any of the configured base directories for a given resource type.
-
- Will check the user local directory first and then process the system
- wide path list according to the inherent priority.
-
- @param resource a named resource type, e.g. "config"
- @param relPath relative path of a file to look for,
- e.g."akonadi/akonadiserverrc"
-
- @returns the file path of the first match, or @c QString() if no such
- relative path exists in any of the base directories or if
- a match is not a file
- */
- QString findResourceFile( const char *resource, const QString &relPath );
- }
-}
-
-#endif
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic