File indexing completed on 2024-09-15 04:36:26
0001 /* 0002 SPDX-FileCopyrightText: 2011 Volker Krause <vkrause@kde.org> 0003 0004 SPDX-License-Identifier: LGPL-2.0-or-later 0005 */ 0006 0007 #pragma once 0008 0009 #include "akonadiprivate_export.h" 0010 0011 #include <QString> 0012 0013 namespace Akonadi 0014 { 0015 /** 0016 * Convenience wrappers on top of QStandardPaths that are instance namespace aware. 0017 * @since 1.7 0018 */ 0019 namespace StandardDirs 0020 { 0021 /** 0022 * @brief Open mode flags for resource files 0023 * 0024 * FileAccessMode is a typedef for QFlags<FileAccessFlag>. It stores 0025 * a OR combination of FileAccessFlag values 0026 */ 0027 enum FileAccessMode { 0028 ReadOnly = 0x1, 0029 WriteOnly = 0x2, 0030 ReadWrite = ReadOnly | WriteOnly, 0031 }; 0032 0033 /** 0034 * Returns path to the config file @p configFile. 0035 */ 0036 AKONADIPRIVATE_EXPORT QString configFile(const QString &configFile, FileAccessMode openMode = ReadOnly); 0037 0038 /** 0039 * Returns the full path to the server config file (akonadiserverrc). 0040 */ 0041 AKONADIPRIVATE_EXPORT QString serverConfigFile(FileAccessMode openMode = ReadOnly); 0042 0043 /** 0044 * Returns the full path to the connection config file (akonadiconnectionrc). 0045 */ 0046 AKONADIPRIVATE_EXPORT QString connectionConfigFile(FileAccessMode openMode = ReadOnly); 0047 0048 /** 0049 * Returns the full path to the agentsrc config file 0050 */ 0051 AKONADIPRIVATE_EXPORT QString agentsConfigFile(FileAccessMode openMode = ReadOnly); 0052 0053 /** 0054 * Returns the full path to config file of agent @p identifier. 0055 * 0056 * Never returns empty string. 0057 * 0058 * @param identifier identifier of the agent (akonadi_foo_resource_0) 0059 */ 0060 AKONADIPRIVATE_EXPORT QString agentConfigFile(const QString &identifier, FileAccessMode openMode = ReadOnly); 0061 0062 /** 0063 * Instance-aware wrapper for QStandardPaths 0064 * @note @p relPath does not need to include the "akonadi/" folder. 0065 */ 0066 AKONADIPRIVATE_EXPORT QString saveDir(const char *resource, const QString &relPath = QString()); 0067 0068 /** 0069 * @brief Searches the resource specific directories for a given file 0070 * 0071 * Convenience method for finding a given file (with optional relative path) 0072 * in any of the configured base directories for a given resource type. 0073 * 0074 * Will check the user local directory first and then process the system 0075 * wide path list according to the inherent priority. 0076 * 0077 * @param resource a named resource type, e.g. "config" 0078 * @param relPath relative path of a file to look for, e.g."akonadi/akonadiserverrc" 0079 * 0080 * @returns the file path of the first match, or @c QString() if no such relative path 0081 * exists in any of the base directories or if a match is not a file 0082 */ 0083 AKONADIPRIVATE_EXPORT QString locateResourceFile(const char *resource, const QString &relPath); 0084 0085 /** 0086 * Equivalent to QStandardPaths::locateAll() but always includes at least the 0087 * default Akonadi compile prefix. 0088 */ 0089 AKONADIPRIVATE_EXPORT QStringList locateAllResourceDirs(const QString &relPath); 0090 0091 /** 0092 * Equivalent to QStandardPaths::findExecutable() but it looks in 0093 * qApp->applicationDirPath() first. 0094 */ 0095 0096 AKONADIPRIVATE_EXPORT QString findExecutable(const QString &relPath); 0097 0098 } 0099 }