1/*
2 This file is part of the KDE project
3 SPDX-FileCopyrightText: 2004 Jan Schaefer <j_schaef@informatik.uni-kl.de>
4 SPDX-FileCopyrightText: 2010 Rodrigo Belem <rclbelem@gmail.com>
5 SPDX-FileCopyrightText: 2020 Harald Sitter <sitter@kde.org>
6
7 SPDX-License-Identifier: LGPL-2.0-only
8*/
9
10#ifndef ksambashare_h
11#define ksambashare_h
12
13#include "kiocore_export.h"
14#include <QObject>
15
16class KSambaShareData;
17class KSambaSharePrivate;
18
19/*!
20 * \class KSambaShare
21 * \inmodule KIOCore
22 *
23 * \brief This class lists Samba user shares and monitors them for addition, update and removal.
24 *
25 * Singleton class, call instance() to get an instance.
26 */
27class KIOCORE_EXPORT KSambaShare : public QObject
28{
29 Q_OBJECT
30
31public:
32 /*!
33 * Returns the one and only instance of KSambaShare.
34 */
35 static KSambaShare *instance();
36
37 /*!
38 * Whether or not the given path is shared by Samba.
39 *
40 * \a path the path to check if it is shared by Samba.
41 */
42 bool isDirectoryShared(const QString &path) const;
43
44 /*!
45 * Returns a list of all directories shared by local users in Samba.
46 * The resulting list is not sorted.
47 */
48 QStringList sharedDirectories() const;
49
50 /*!
51 * Tests that a share name is valid and does not conflict with system users names or shares.
52 *
53 * \a name the share name.
54 *
55 * Returns whether the given name is already being used or not.
56 *
57 */
58 bool isShareNameAvailable(const QString &name) const;
59
60 /*!
61 * Returns the list of available shares.
62 *
63 * Returns a QStringList containing the user shares names or empty list if there aren't user shared directories.
64 *
65 */
66 QStringList shareNames() const;
67
68 /*!
69 * Returns the KSambaShareData object of the share name.
70 *
71 * \a name the share name.
72 *
73 * Returns the KSambaShareData object that matches the name or an empty KSambaShareData object if there is no match for the name.
74 *
75 */
76 KSambaShareData getShareByName(const QString &name) const;
77
78 /*!
79 * Returns a list of KSambaShareData matching the path.
80 *
81 * \a path the path that wants to get KSambaShareData object.
82 *
83 * Returns the QList of KSambaShareData objects that matches the path or an empty QList if there aren't matches for the given path.
84 */
85 QList<KSambaShareData> getSharesByPath(const QString &path) const;
86
87 ~KSambaShare() override;
88
89 /*!
90 * Used to obtain UserShareSystemError error strings. This is usually the
91 * verbatim stderr of internal helper commands and may contain newlines.
92 * Do not use this to obtain error strings for other error types!
93 *
94 * Returns QString containing the most relevant last stderr
95 * \since 5.74
96 */
97 QString lastSystemErrorString() const;
98
99 /*!
100 * Check whether usershares may enable guests. System-level configuration
101 * may disable usershare guests and prevent saving KSambaShareData with
102 * UserGuestPermission set.
103 *
104 * Returns \c true when usershares may allow guest access
105 * \since 5.74
106 */
107 bool areGuestsAllowed() const;
108
109Q_SIGNALS:
110 /*!
111 * Emitted when a share is updated, added or removed
112 */
113 void changed();
114
115private:
116 KIOCORE_NO_EXPORT KSambaShare();
117
118 KSambaSharePrivate *const d_ptr;
119 Q_DECLARE_PRIVATE(KSambaShare)
120 friend class KSambaShareData;
121 friend class KSambaShareSingleton;
122};
123
124#endif
125

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