/usr/include/plasma/packagestructure.h is in kdelibs5-dev 4:4.8.4-4+deb7u1.
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 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 | /******************************************************************************
* Copyright 2007 by Aaron Seigo <aseigo@kde.org> *
* *
* This library 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 library 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 *
* Library General Public License for more details. *
* *
* You should have received a copy of the GNU Library General Public License *
* along with this library; see the file COPYING.LIB. If not, write to *
* the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, *
* Boston, MA 02110-1301, USA. *
*******************************************************************************/
#ifndef PLASMA_PACKAGESTRUCTURE_H
#define PLASMA_PACKAGESTRUCTURE_H
#include <QtCore/QStringList>
#include <QtCore/QSharedData>
#include <kgenericfactory.h>
#include <klocale.h>
#include <ksharedptr.h>
#include <plasma/version.h>
#include "packagemetadata.h"
class KConfigBase;
namespace Plasma
{
class PackageStructurePrivate;
/**
* @class PackageStructure plasma/packagestructure.h <Plasma/PackageStructure>
*
* @short A description of the expected file structure of a given package type
*
* PackageStructure defines what is in a package. This information is used
* to create packages and provides a way to programatically refer to contents.
*
* An example usage of this class might be:
*
@code
PackageStructure structure;
structure.addDirectoryDefinition("images", "pics/", i18n("Images"));
QStringList mimetypes;
mimetypes << "image/svg" << "image/png" << "image/jpeg";
structure.setMimetypes("images", mimetypes);
structure.addDirectoryDefinition("scripts", "code/", i18n("Executable Scripts"));
mimetypes.clear();
mimetypes << "text/\*";
structure.setMimetypes("scripts", mimetypes);
structure.addFileDefinition("mainscript", "code/main.js", i18n("Main Script File"));
structure.setRequired("mainscript", true);
@endcode
* One may also choose to create a subclass of PackageStructure and include the setup
* in the constructor.
*
* Either way, PackageStructure creates a sort of "contract" between the packager and
* the application which is also self-documenting.
**/
class PLASMA_EXPORT PackageStructure : public QObject, public QSharedData
{
Q_OBJECT
public:
typedef KSharedPtr<PackageStructure> Ptr;
/**
* Default constructor for a package structure definition
*
* @param type the type of package. This is often application specific.
**/
explicit PackageStructure(QObject *parent = 0,
const QString &type = i18nc("A non-functional package", "Invalid"));
/**
* Destructor
**/
virtual ~PackageStructure();
/**
* Assignment operator
**/
PackageStructure &operator=(const PackageStructure &rhs);
/**
* Loads a package format by name.
*
* @param format If not empty, attempts to locate the given format, either
* from built-ins or via plugins.
* @return a package that matches the format, if available. The caller
* is responsible for deleting the object.
*/
static PackageStructure::Ptr load(const QString &packageFormat);
/**
* Type of package this structure describes
**/
QString type() const;
/**
* The directories defined for this package
**/
QList<const char*> directories() const;
/**
* The required directories defined for this package
**/
QList<const char*> requiredDirectories() const;
/**
* The individual files, by key, that are defined for this package
**/
QList<const char*> files() const;
/**
* The individual required files, by key, that are defined for this package
**/
QList<const char*> requiredFiles() const;
/**
* Adds a directory to the structure of the package. It is added as
* a not-required element with no associated mimetypes.
*
* Starting in 4.6, if an entry with the given key
* already exists, the path is added to it as a search alternative.
*
* @param key used as an internal label for this directory
* @param path the path within the package for this directory
* @param name the user visible (translated) name for the directory
**/
void addDirectoryDefinition(const char *key, const QString &path, const QString &name);
/**
* Adds a file to the structure of the package. It is added as
* a not-required element with no associated mimetypes.
*
* Starting in 4.6, if an entry with the given key
* already exists, the path is added to it as a search alternative.
*
* @param key used as an internal label for this file
* @param path the path within the package for this file
* @param name the user visible (translated) name for the file
**/
void addFileDefinition(const char *key, const QString &path, const QString &name);
/**
* Removes a definition from the structure of the package.
* @since 4.6
* @param key the internal label of the file or directory to remove
*/
void removeDefinition(const char *key);
/**
* @return path relative to the package root for the given entry
* @deprecatd use searchPaths instead
**/
QString path(const char *key) const;
/**
* @return a list of paths relative to the package root for the given entry.
* They are orted by importance: when searching for a file the paths
* will be searched in order
* @since 4.6
**/
QStringList searchPath(const char *key) const;
/**
* Get the list of files of a given type.
*
* @param key the type of file to look for
* @return list of files by name
* @since 4.3
*/
QStringList entryList(const char *key);
/**
* @return user visible name for the given entry
**/
QString name(const char *key) const;
/**
* Sets whether or not a given part of the structure is required or not.
* The path must already have been added using addDirectoryDefinition
* or addFileDefinition.
*
* @param key the entry within the package
* @param required true if this entry is required, false if not
*/
void setRequired(const char *key, bool required);
/**
* @return true if the item at path exists and is required
**/
bool isRequired(const char *key) const;
/**
* Defines the default mimetypes for any definitions that do not have
* associated mimetypes. Handy for packages with only one or predominantly
* one file type.
*
* @param mimetypes a list of mimetypes
**/
void setDefaultMimetypes(QStringList mimetypes);
/**
* Define mimetypes for a given part of the structure
* The path must already have been added using addDirectoryDefinition
* or addFileDefinition.
*
* @param key the entry within the package
* @param mimetypes a list of mimetypes
**/
void setMimetypes(const char *key, QStringList mimetypes);
/**
* @return the mimetypes associated with the path, if any
**/
QStringList mimetypes(const char *key) const;
/**
* Sets the path to the package. Useful for package formats
* which do not have well defined contents prior to installation.
*/
void setPath(const QString &path);
/**
* @return the path to the package, or QString() if none
*/
QString path() const;
/**
* Read a package structure from a config file.
*/
void read(const KConfigBase *config);
/**
* Write this package structure to a config file.
*/
void write(KConfigBase *config) const;
/**
* Installs a package matching this package structure. By default installs a
* native Plasma::Package.
*
* @param archivePath path to the package archive file
* @param packageRoot path to the directory where the package should be
* installed to
* @return true on successful installation, false otherwise
**/
virtual bool installPackage(const QString &archivePath, const QString &packageRoot);
/**
* Uninstalls a package matching this package structure.
*
* @param packageName the name of the package to remove
* @param packageRoot path to the directory where the package should be installed to
* @return true on successful removal of the package, false otherwise
*/
virtual bool uninstallPackage(const QString &packageName, const QString &packageRoot);
/**
* When called, the package plugin should display a window to the user
* that they can use to browser, select and then install widgets supported by
* this package plugin with.
*
* The user interface may be an in-process dialog or an out-of-process application.
*
* When the process is complete, the newWidgetBrowserFinished() signal must be
* emitted.
*
* @param parent the parent widget to use for the widget
*/
virtual void createNewWidgetBrowser(QWidget *parent = 0);
/**
* @return the prefix inserted between the base path and content entries
* @deprecated use contentsPrefixPaths() instead.
*/
KDE_DEPRECATED QString contentsPrefix() const;
/**
* @return the prefix paths inserted between the base path and content entries, in order of priority.
* When searching for a file, all paths will be tried in order.
* @since 4.6
*/
QStringList contentsPrefixPaths() const;
/**
* @return preferred package root. This defaults to plasma/plasmoids/
*/
QString defaultPackageRoot() const;
/**
* @return service prefix used in desktop files. This defaults to plasma-applet-
*/
QString servicePrefix() const;
/**
* Sets service prefix.
*/
void setServicePrefix(const QString &servicePrefix);
/**
* @return the package metadata object.
*/
virtual PackageMetadata metadata();
/**
* @return true if paths/symlinks outside the package itself should be followed.
* By default this is set to false for security reasons.
*/
bool allowExternalPaths() const;
Q_SIGNALS:
/**
* Emitted when the new widget browser process completes.
*/
void newWidgetBrowserFinished();
protected:
/**
* Sets whether or not external paths/symlinks can be followed by a package
* @param allow true if paths/symlinks outside of the package should be followed,
* false if they should be rejected.
*/
void setAllowExternalPaths(bool allow);
/**
* Sets the prefix that all the contents in this package should
* appear under. This defaults to "contents/" and is added automatically
* between the base path and the entries as defined by the package
* structure
*
* @param prefix the directory prefix to use
* @deprecated use setContentsPrefixPaths() instead.
*/
KDE_DEPRECATED void setContentsPrefix(const QString &prefix);
/**
* Sets the prefixes that all the contents in this package should
* appear under. This defaults to "contents/" and is added automatically
* between the base path and the entries as defined by the package
* structure. Multiple entries can be added.
* In this case each file request will be searched in all prefixes in order,
* and the first found will be returned.
*
* @param prefix paths the directory prefix to use
* @since 4.6
*/
void setContentsPrefixPaths(const QStringList &prefixPaths);
/**
* Sets preferred package root.
*/
void setDefaultPackageRoot(const QString &packageRoot);
/**
* Called whenever the path changes so that subclasses may take
* package specific actions.
*/
virtual void pathChanged();
private:
PackageStructurePrivate * const d;
};
/**
* Register an applet when it is contained in a loadable module
*/
#define K_EXPORT_PLASMA_PACKAGESTRUCTURE(libname, classname) \
K_PLUGIN_FACTORY(factory, registerPlugin<classname>();) \
K_EXPORT_PLUGIN(factory("plasma_packagestructure_" #libname)) \
K_EXPORT_PLUGIN_VERSION(PLASMA_VERSION)
} // Plasma namespace
#endif
|