1 /* 2 SPDX-FileCopyrightText: 2011 Volker Krause <vkrause@kde.org> 3 4 SPDX-License-Identifier: LGPL-2.0-or-later 5 */ 6 7 #pragma once 8 9 #include "akonadiprivate_export.h" 10 11 #include <QString> 12 13 namespace Akonadi 14 { 15 /** 16 * Convenience wrappers on top of QStandardPaths that are instance namespace aware. 17 * @since 1.7 18 */ 19 namespace StandardDirs 20 { 21 /** 22 * @brief Open mode flags for resource files 23 * 24 * FileAccessMode is a typedef for QFlags<FileAccessFlag>. It stores 25 * a OR combination of FileAccessFlag values 26 */ 27 enum FileAccessMode { 28 ReadOnly = 0x1, 29 WriteOnly = 0x2, 30 ReadWrite = ReadOnly | WriteOnly, 31 }; 32 33 /** 34 * Returns path to the config file @p configFile. 35 */ 36 AKONADIPRIVATE_EXPORT QString configFile(const QString &configFile, FileAccessMode openMode = ReadOnly); 37 38 /** 39 * Returns the full path to the server config file (akonadiserverrc). 40 */ 41 AKONADIPRIVATE_EXPORT QString serverConfigFile(FileAccessMode openMode = ReadOnly); 42 43 /** 44 * Returns the full path to the connection config file (akonadiconnectionrc). 45 */ 46 AKONADIPRIVATE_EXPORT QString connectionConfigFile(FileAccessMode openMode = ReadOnly); 47 48 /** 49 * Returns the full path to the agentsrc config file 50 */ 51 AKONADIPRIVATE_EXPORT QString agentsConfigFile(FileAccessMode openMode = ReadOnly); 52 53 /** 54 * Returns the full path to config file of agent @p identifier. 55 * 56 * Never returns empty string. 57 * 58 * @param identifier identifier of the agent (akonadi_foo_resource_0) 59 */ 60 AKONADIPRIVATE_EXPORT QString agentConfigFile(const QString &identifier, FileAccessMode openMode = ReadOnly); 61 62 /** 63 * Instance-aware wrapper for QStandardPaths 64 * @note @p relPath does not need to include the "akonadi/" folder. 65 */ 66 AKONADIPRIVATE_EXPORT QString saveDir(const char *resource, const QString &relPath = QString()); 67 68 /** 69 * @brief Searches the resource specific directories for a given file 70 * 71 * Convenience method for finding a given file (with optional relative path) 72 * in any of the configured base directories for a given resource type. 73 * 74 * Will check the user local directory first and then process the system 75 * wide path list according to the inherent priority. 76 * 77 * @param resource a named resource type, e.g. "config" 78 * @param relPath relative path of a file to look for, e.g."akonadi/akonadiserverrc" 79 * 80 * @returns the file path of the first match, or @c QString() if no such relative path 81 * exists in any of the base directories or if a match is not a file 82 */ 83 AKONADIPRIVATE_EXPORT QString locateResourceFile(const char *resource, const QString &relPath); 84 85 /** 86 * Equivalent to QStandardPaths::locateAll() but always includes at least the 87 * default Akonadi compile prefix. 88 */ 89 AKONADIPRIVATE_EXPORT QStringList locateAllResourceDirs(const QString &relPath); 90 91 /** 92 * Equivalent to QStandardPaths::findExecutable() but it looks in 93 * qApp->applicationDirPath() first. 94 */ 95 96 AKONADIPRIVATE_EXPORT QString findExecutable(const QString &relPath); 97 98 } 99 } 100 101