mirror of
https://bitbucket.org/smil3y/kdelibs.git
synced 2025-02-23 18:32:49 +00:00
kdecore: drop socket resource type and use QStandardPaths:writableLocation() for base resource directories
Signed-off-by: Ivailo Monev <xakepa10@gmail.com>
This commit is contained in:
parent
e83a89249c
commit
41db76b92c
4 changed files with 21 additions and 22 deletions
|
@ -141,8 +141,7 @@ int main(int argc, char **argv)
|
|||
"xdgdata-mime", I18N_NOOP("XDG Mime Types"),
|
||||
"xdgconf-menu", I18N_NOOP("XDG Menu layout (.menu files)"),
|
||||
"xdgconf-autostart", I18N_NOOP("XDG autostart directory"),
|
||||
"tmp", I18N_NOOP("Temporary files (specific for both current host and current user)"),
|
||||
"socket", I18N_NOOP("UNIX Sockets (specific for both current host and current user)"),
|
||||
"tmp", I18N_NOOP("Temporary files (specific for current user)"),
|
||||
0, 0
|
||||
};
|
||||
Q_FOREACH(const QString &type, types)
|
||||
|
|
|
@ -59,6 +59,7 @@
|
|||
#include <QtCore/QCache>
|
||||
#include <QtCore/QFileInfo>
|
||||
#include <QtCore/QSettings>
|
||||
#include <QtCore/QStandardPaths>
|
||||
#include <QtNetwork/QHostInfo>
|
||||
|
||||
#include <mutex>
|
||||
|
@ -263,7 +264,6 @@ QStringList KStandardDirs::allTypes() const
|
|||
//list.append(QString::fromLatin1("home")); // undocumented on purpose, said Waldo in r113855.
|
||||
|
||||
// Those are handled by resourceDirs() itself
|
||||
list.append(QString::fromLatin1("socket"));
|
||||
list.append(QString::fromLatin1("tmp"));
|
||||
list.append(QString::fromLatin1("cache"));
|
||||
// Those are handled by installPath()
|
||||
|
@ -854,12 +854,20 @@ KStandardDirs::realFilePath(const QString &filename)
|
|||
|
||||
void KStandardDirs::KStandardDirsPrivate::createSpecialResource(const char *type)
|
||||
{
|
||||
QString resourceDir = QDir::tempPath();
|
||||
resourceDir.append(QDir::separator());
|
||||
resourceDir.append(QLatin1String("kde-"));
|
||||
resourceDir.append(QString::fromLatin1(type));
|
||||
resourceDir.append(QLatin1Char('-'));
|
||||
resourceDir.append(QString::number(::getuid()));
|
||||
QString resourceDir;
|
||||
if (qstrcmp(type, "cache") == 0) {
|
||||
resourceDir = QStandardPaths::writableLocation(QStandardPaths::CacheLocation);
|
||||
resourceDir.append(QDir::separator());
|
||||
resourceDir.append(QLatin1String("katana"));
|
||||
} else if (qstrcmp(type, "tmp") == 0) {
|
||||
resourceDir = QStandardPaths::writableLocation(QStandardPaths::RuntimeLocation);
|
||||
// if the base directory is /tmp not /run/user/<uid> make sure it is user specific
|
||||
resourceDir.append(QDir::separator());
|
||||
resourceDir.append(QLatin1String("katana-"));
|
||||
resourceDir.append(QString::number(::getuid()));
|
||||
} else {
|
||||
Q_ASSERT(false);
|
||||
}
|
||||
q->addResourceDir(type, QDir::cleanPath(resourceDir) + QLatin1Char('/'), false);
|
||||
}
|
||||
|
||||
|
@ -886,11 +894,7 @@ QStringList KStandardDirs::KStandardDirsPrivate::resourceDirs(const char* type,
|
|||
else // filling cache
|
||||
{
|
||||
//qDebug() << this << "resourceDirs(" << type << "), not in cache";
|
||||
if (strcmp(type, "socket") == 0)
|
||||
createSpecialResource(type);
|
||||
else if (strcmp(type, "tmp") == 0)
|
||||
createSpecialResource(type);
|
||||
else if (strcmp(type, "cache") == 0)
|
||||
if (strcmp(type, "tmp") == 0 || strcmp(type, "cache") == 0)
|
||||
createSpecialResource(type);
|
||||
|
||||
QDir testdir;
|
||||
|
@ -1184,12 +1188,9 @@ QString KStandardDirs::saveLocation(const char *type,
|
|||
if (path.isEmpty())
|
||||
{
|
||||
QStringList dirs = d->m_relatives.value(type);
|
||||
if (dirs.isEmpty() && (
|
||||
(strcmp(type, "socket") == 0) ||
|
||||
(strcmp(type, "tmp") == 0) ||
|
||||
(strcmp(type, "cache") == 0) ))
|
||||
if (dirs.isEmpty() && (strcmp(type, "tmp") == 0 || strcmp(type, "cache") == 0))
|
||||
{
|
||||
(void) resourceDirs(type); // Generate socket|tmp|cache resource.
|
||||
(void) resourceDirs(type); // Generate tmp|cache resource.
|
||||
dirs = d->m_relatives.value(type); // Search again.
|
||||
}
|
||||
if (!dirs.isEmpty())
|
||||
|
|
|
@ -78,8 +78,7 @@ class KConfig;
|
|||
* @li @c sound - Application sounds.
|
||||
* @li @c templates - Templates for the "Create new file" functionality.
|
||||
* @li @c wallpaper - Wallpapers.
|
||||
* @li @c tmp - Temporary files (specific for both current host and current user)
|
||||
* @li @c socket - UNIX Sockets (specific for both current host and current user)
|
||||
* @li @c tmp - Temporary files (specific for current user)
|
||||
* @li @c xdgconf-menu - Freedesktop.org standard location for menu layout (.menu) files.
|
||||
* @li @c xdgdata-apps - Freedesktop.org standard location for application desktop files.
|
||||
* @li @c xdgdata-dirs - Freedesktop.org standard location for menu descriptions (.directory files).
|
||||
|
|
|
@ -1305,7 +1305,7 @@ static void kdeinit_library_path()
|
|||
display.replace(':','_');
|
||||
// WARNING, if you change the socket name, adjust kwrapper too
|
||||
const QString socketFileName = QString::fromLatin1("kdeinit4_%1").arg(QLatin1String(display));
|
||||
QByteArray socketName = QFile::encodeName(KStandardDirs::locateLocal("socket", socketFileName, *s_instance));
|
||||
QByteArray socketName = QFile::encodeName(KStandardDirs::locateLocal("tmp", socketFileName, *s_instance));
|
||||
if (socketName.length() >= MAX_SOCK_FILE)
|
||||
{
|
||||
fprintf(stderr, "kdeinit4: Aborting. Socket name will be too long:\n");
|
||||
|
|
Loading…
Add table
Reference in a new issue