This file is indexed.

/usr/include/akonadi/private/xdgbasedirs_p.h is in libakonadi-dev 1.13.0-8ubuntu2.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
/***************************************************************************
 *   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.         *
 ***************************************************************************/

#ifndef XDGBASEDIRS_H
#define XDGBASEDIRS_H

// Qt includes
#include <QtCore/QFlags>
#include <QtCore/QStringList>

#include "akonadiprotocolinternals_export.h"

// forward declarations
class QString;

namespace Akonadi {

class XdgBaseDirsPrivate;

/**
 @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"

 Example: getting the Akonadi server config file "akonadiserverrc", assuming
 that Akonadi stores its config in an additional subdirectoy called "akonadi"
 @code
 QString relativeFileName = QLatin1String( "akonadi/akonadiserverrc" );

 // look for the file "akonadiserverrc" with additional subdirectory "akonadi"
 // in any directory associated with resource type "config"
 QString configFile = XdgBaseDirs::findResourceFile( "config", relativeFileName );

 if ( configFile.isEmpty() ) {
  // No config file yet, get the suitable user specific directory for storing
  // a new one
  configFile  = XdgBaseDirs::saveDir( "config", QLatin1String( "akonadi" ) );
  configFile += QLatin1String( "akonadiserverrc" );
 }

 QSettings serverConfig( configFile );
 @endcode

 @author Kevin Krammer, <kevin.krammer@gmx.at>

 @see http://www.freedesktop.org/wiki/Specifications/basedir-spec
 */
class AKONADIPROTOCOLINTERNALS_EXPORT XdgBaseDirs
{
  public:
    /**
     @brief Creates the instance
     */
    XdgBaseDirs();

    /**
     @brief Destroys the instance
     */
    ~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()
     @see saveDir()
     */
    static 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()
     */
    static 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

     @see findResourceDir()
     @see saveDir
     */
    static QString findResourceFile( const char *resource, const QString &relPath );

    /**
     @brief Searches the executable specific directories for a given file

     Convenience method for finding a given executable (with optional relative path)
     in any of the configured directories for a this special type.

     @note This is not based on the XDG base dir spec, since it does not cover
           executable

     @param relPath relative path of a file to look for,
            e.g."akonadiserver"
     @param searchPath additional paths to search for the executable,
            only used if the file was not found in PATH and the install prefix

     @returns the file path of the first match, or @c QString() if no such
              relative path exists in any of the base directories

     @see findResourceFile()
     */
    static QString findExecutableFile( const QString &relPath, const QStringList &searchPath = QStringList() );

    /**
     @brief Searches the plugin specific directories for a given file

     Convenience method for finding a given plugin (with optional relative path)
     in any of the configured directories for a this special type.

     @note This is not based on the XDG base dir spec, since it does not cover
           plugins

     @param relPath relative path of a file to look for,
            e.g."akonadi_knut_resource"
     @param searchPath additional paths to search for the plugin,
            only used if the file was not found in QT_PLUGIN_PATH and the install prefix

     @returns the file path of the first match, or @c QString() if no such
              relative path exists in any of the base directories

     @see findResourceFile()
     */
    static QString findPluginFile( const QString &relPath, const QStringList &searchPath = QStringList() );

    /**
     @brief Returns plugin specific directories

     Convenience method for listing directories that can be scanned for available
     plugins.

     @note This is not based on the XDG base dir spec, since it does not cover
           plugins.

    @return directories where application should look for plugins
    */
    static QStringList findPluginDirs();

    /**
     @brief Searches the resource specific directories for a given subdirectory

     Convenience method for finding a given relative subdirectory 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.

     Use findAllResourceDirs() if looking for all directories with the given
     subdirectory.

     @param resource a named resource type, e.g. "config"
     @param relPath relative path of a subdirectory to look for,
            e.g."akonadi/agents"

     @returns the directory 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 directory

     @see findResourceFile()
     @see saveDir()
     */
    static QString findResourceDir( const char *resource, const QString &relPath );

    /**
     @brief Searches the resource specific directories for a given subdirectory

     Convenience method for getting a list of directoreis with a given relative
     subdirectory 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.

     Similar to findResourceDir() but does not just find the first best match
     but all matching resource directories. The resuling list will be sorted
     according to the same proprity criteria.

     @param resource a named resource type, e.g. "config"
     @param relPath relative path of a subdirectory to look for,
            e.g."akonadi/agents"

     @returns a list of directory paths, or @c QString() if no such
              relative path exists in any of the base directories or if
              non of the matches is a directory

     @see findResourceDir()
     */
    static QStringList findAllResourceDirs( const char *resource, const QString &relPath );

    /**
     @brief Finds or creates the "save to" directory for a given resource

     Convenience method for creating subdirectores relative to a given
     resource type's user directory, i.e. homePath() + relPath

     If the target directory does not exists, it an all necessary parent
     directories will be created, unless denied by the filesystem.

     @param resource a named resource type, e.g. "config"
     @param relPath relative path of a directory to be used for file writing

     @return the directory path of the "save to" directory or @c QString()
             if the directory or one of its parents could not be created

     @see findResourceDir()
     */
    static QString saveDir( const char *resource, const QString &relPath );

    /**
    * @brief Open mode flags for resource files
    *
    * FileAccessMode is a typedef for QFlags<FileAccessFlag>. It stores
    * a OR combination of FileAccessFlag values
    */
    enum FileAccessFlag {
        ReadOnly  = 0x1,
        WriteOnly = 0x2,
        ReadWrite = ReadOnly | WriteOnly
    };

    typedef QFlags<FileAccessFlag> FileAccessMode;

    /**
    * @brief Returns the path of the Akonadi server config file
    *
    * Convenience method for getting the server config file "akonadiserverrc"
    * since this is an often needed procedure in several parts of the code.
    *
    * @param openMode how the application wants to use the config file
    *
    * @return the path of the server config file, suitable for \p openMode
    */
    static QString akonadiServerConfigFile( FileAccessMode openMode = ReadOnly );

    /**
    * @brief Returns the path of the Akonadi data connection config file
    *
    * Convenience method for getting the server config file "akonadiconnectionrc"
    * since this is an often needed procedure in several parts of the code.
    *
    * @param openMode how the application wants to use the config file
    *
    * @return the path of the data connection config file, suitable for \p openMode
    */
    static QString akonadiConnectionConfigFile( FileAccessMode openMode = ReadOnly );

  private:
    XdgBaseDirsPrivate *const d;

  private:
    static QString akonadiConfigFile( const QString &file, FileAccessMode openMode );

  private:
    XdgBaseDirs( const XdgBaseDirs & );
    XdgBaseDirs &operator=( const XdgBaseDirs & );
};

}

#endif