1// -*- c++ -*-
2/*
3 * This file is part of the KDE libraries
4 * Copyright (c) 2001 Waldo Bastian <bastian@kde.org>
5 *
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Library General Public
8 * License version 2 as published by the Free Software Foundation.
9 *
10 * This library is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * Library General Public License for more details.
14 *
15 * You should have received a copy of the GNU Library General Public License
16 * along with this library; see the file COPYING.LIB. If not, write to
17 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
18 * Boston, MA 02110-1301, USA.
19 **/
20
21#ifndef KIO_SLAVE_CONFIG_H
22#define KIO_SLAVE_CONFIG_H
23
24#include <QtCore/QObject>
25#include <kio/global.h>
26
27namespace KIO {
28
29 class SlaveConfigPrivate;
30 /**
31 * SlaveConfig
32 *
33 * This class manages the configuration for io-slaves based on protocol
34 * and host. The Scheduler makes use of this class to configure the slave
35 * whenever it has to connect to a new host.
36 *
37 * You only need to use this class if you want to override specific
38 * configuration items of an io-slave when the io-slave is used by
39 * your application.
40 *
41 * Normally io-slaves are being configured by "kio_<protocol>rc"
42 * configuration files. Groups defined in such files are treated as host
43 * or domain specification. Configuration items defined in a group are
44 * only applied when the slave is connecting with a host that matches with
45 * the host and/or domain specified by the group.
46 */
47 class KIO_EXPORT SlaveConfig : public QObject
48 {
49 Q_OBJECT
50 public:
51 static SlaveConfig *self();
52 ~SlaveConfig();
53 /**
54 * Configure slaves of type @p protocol by setting @p key to @p value.
55 * If @p host is specified the configuration only applies when dealing
56 * with @p host.
57 *
58 * Changes made to the slave configuration only apply to slaves
59 * used by the current process.
60 */
61 void setConfigData(const QString &protocol, const QString &host, const QString &key, const QString &value );
62
63 /**
64 * Configure slaves of type @p protocol with @p config.
65 * If @p host is specified the configuration only applies when dealing
66 * with @p host.
67 *
68 * Changes made to the slave configuration only apply to slaves
69 * used by the current process.
70 */
71 void setConfigData(const QString &protocol, const QString &host, const MetaData &config );
72
73 /**
74 * Query slave configuration for slaves of type @p protocol when
75 * dealing with @p host.
76 */
77 MetaData configData(const QString &protocol, const QString &host);
78
79 /**
80 * Query a specific configuration key for slaves of type @p protocol when
81 * dealing with @p host.
82 */
83 QString configData(const QString &protocol, const QString &host, const QString &key);
84
85 /**
86 * Undo any changes made by calls to setConfigData.
87 */
88 void reset();
89 Q_SIGNALS:
90 /**
91 * This signal is raised when a slave of type @p protocol deals
92 * with @p host for the first time.
93 *
94 * Your application can use this signal to make some last minute
95 * configuration changes with setConfigData based on the
96 * host.
97 */
98 void configNeeded(const QString &protocol, const QString &host);
99 protected:
100 SlaveConfig();
101 private:
102 SlaveConfigPrivate* const d;
103 };
104}
105
106#endif
107