1// -*- c++ -*-
2/*
3 This file is part of the KDE libraries
4 SPDX-FileCopyrightText: 2001 Waldo Bastian <bastian@kde.org>
5
6 SPDX-License-Identifier: LGPL-2.0-only
7*/
8
9#ifndef KIO_WORKER_CONFIG_H
10#define KIO_WORKER_CONFIG_H
11
12#include "metadata.h"
13#include <QObject>
14
15#include <memory>
16
17namespace KIO
18{
19class WorkerConfigPrivate;
20/*!
21 * \class KIO::WorkerConfig
22 * \inheaderfile KIO/WorkerConfig
23 * \inmodule KIOCore
24 *
25 * \brief This class manages the configuration for KIO workers based on protocol
26 * and host.
27 *
28 * The Scheduler makes use of this class to configure the worker
29 * whenever it has to connect to a new host.
30 *
31 * You only need to use this class if you want to override specific
32 * configuration items of an KIO worker when the worker is used by
33 * your application.
34 *
35 * Normally KIO workers are being configured by "kio_<protocol>rc"
36 * configuration files. Groups defined in such files are treated as host
37 * or domain specification. Configuration items defined in a group are
38 * only applied when the worker is connecting with a host that matches with
39 * the host and/or domain specified by the group.
40 */
41class WorkerConfig : public QObject
42{
43 Q_OBJECT
44
45public:
46 static WorkerConfig *self();
47 ~WorkerConfig() override;
48 /*!
49 * Configure workers of type \a protocol by setting \a key to \a value.
50 * If \a host is specified the configuration only applies when dealing
51 * with \a host.
52 *
53 * Changes made to the worker configuration only apply to workers
54 * used by the current process.
55 */
56 void setConfigData(const QString &protocol, const QString &host, const QString &key, const QString &value);
57
58 /*!
59 * Configure workers of type \a protocol with \a config.
60 * If \a host is specified the configuration only applies when dealing
61 * with \a host.
62 *
63 * Changes made to the worker configuration only apply to workers
64 * used by the current process.
65 */
66 void setConfigData(const QString &protocol, const QString &host, const MetaData &config);
67
68 /*!
69 * Query worker configuration for workers of type \a protocol when
70 * dealing with \a host.
71 */
72 MetaData configData(const QString &protocol, const QString &host);
73
74 /*!
75 * Query a specific configuration key for workers of type \a protocol when
76 * dealing with \a host.
77 */
78 QString configData(const QString &protocol, const QString &host, const QString &key);
79
80 /*!
81 * Undo any changes made by calls to setConfigData.
82 */
83 void reset();
84
85Q_SIGNALS:
86 /*!
87 * This signal is raised when a worker of type \a protocol deals
88 * with \a host for the first time.
89 *
90 * Your application can use this signal to make some last minute
91 * configuration changes with setConfigData based on the
92 * host.
93 */
94 void configNeeded(const QString &protocol, const QString &host);
95
96protected:
97 WorkerConfig();
98
99private:
100 std::unique_ptr<WorkerConfigPrivate> const d;
101 friend class WorkerConfigSingleton;
102};
103}
104
105#endif
106

source code of kio/src/core/workerconfig.h