File indexing completed on 2024-10-06 03:39:32
0001 /* 0002 This file is part of the KDE project 0003 SPDX-FileCopyrightText: 2004 Jan Schaefer <j_schaef@informatik.uni-kl.de> 0004 SPDX-FileCopyrightText: 2010 Rodrigo Belem <rclbelem@gmail.com> 0005 SPDX-FileCopyrightText: 2020 Harald Sitter <sitter@kde.org> 0006 0007 SPDX-License-Identifier: LGPL-2.0-only 0008 */ 0009 0010 #ifndef ksambashare_h 0011 #define ksambashare_h 0012 0013 #include "kiocore_export.h" 0014 #include <QObject> 0015 0016 class KSambaShareData; 0017 class KSambaSharePrivate; 0018 0019 /** 0020 * @class KSambaShare ksambashare.h <KSambaShare> 0021 * 0022 * This class lists Samba user shares and monitors them for addition, update and removal. 0023 * Singleton class, call instance() to get an instance. 0024 */ 0025 class KIOCORE_EXPORT KSambaShare : public QObject 0026 { 0027 Q_OBJECT 0028 0029 public: 0030 /** 0031 * @return the one and only instance of KSambaShare. 0032 */ 0033 static KSambaShare *instance(); 0034 0035 /** 0036 * Whether or not the given path is shared by Samba. 0037 * 0038 * @param path the path to check if it is shared by Samba. 0039 * 0040 * @return whether the given path is shared by Samba. 0041 */ 0042 bool isDirectoryShared(const QString &path) const; 0043 0044 /** 0045 * Returns a list of all directories shared by local users in Samba. 0046 * The resulting list is not sorted. 0047 * 0048 * @return a list of all directories shared by Samba. 0049 */ 0050 QStringList sharedDirectories() const; 0051 0052 /** 0053 * Tests that a share name is valid and does not conflict with system users names or shares. 0054 * 0055 * @param name the share name. 0056 * 0057 * @return whether the given name is already being used or not. 0058 * 0059 */ 0060 bool isShareNameAvailable(const QString &name) const; 0061 0062 /** 0063 * Returns the list of available shares. 0064 * 0065 * @return @c a QStringList containing the user shares names. 0066 * @return @c an empty list if there aren't user shared directories. 0067 * 0068 */ 0069 QStringList shareNames() const; 0070 0071 /** 0072 * Returns the KSambaShareData object of the share name. 0073 * 0074 * @param name the share name. 0075 * 0076 * @return @c the KSambaShareData object that matches the name. 0077 * @return @c an empty KSambaShareData object if there isn't match for the name. 0078 * 0079 */ 0080 KSambaShareData getShareByName(const QString &name) const; 0081 0082 /** 0083 * Returns a list of KSambaShareData matching the path. 0084 * 0085 * @param path the path that wants to get KSambaShareData object. 0086 * 0087 * @return @c the QList of KSambaShareData objects that matches the path. 0088 * @return @c an empty QList if there aren't matches for the given path. 0089 * 0090 */ 0091 QList<KSambaShareData> getSharesByPath(const QString &path) const; 0092 0093 ~KSambaShare() override; 0094 0095 /** 0096 * Used to obtain UserShareSystemError error strings. This is usually the 0097 * verbatim stderr of internal helper commands and may contain newlines. 0098 * Do not use this to obtain error strings for other error types! 0099 * 0100 * @return QString containing the most relevant last stderr 0101 * @since 5.74 0102 */ 0103 QString lastSystemErrorString() const; 0104 0105 /** 0106 * Check whether usershares may enable guests. System-level configuration 0107 * may disable usershare guests and prevent saving KSambaShareData with 0108 * UserGuestPermission set. 0109 * 0110 * @return @c true when usershares may allow guest access 0111 * @since 5.74 0112 */ 0113 bool areGuestsAllowed() const; 0114 0115 Q_SIGNALS: 0116 /** 0117 * Emitted when a share is updated, added or removed 0118 */ 0119 void changed(); 0120 0121 private: 0122 KIOCORE_NO_EXPORT KSambaShare(); 0123 0124 KSambaSharePrivate *const d_ptr; 0125 Q_DECLARE_PRIVATE(KSambaShare) 0126 friend class KSambaShareData; 0127 friend class KSambaShareSingleton; 0128 }; 0129 0130 #endif