File indexing completed on 2024-04-21 05:01:36
0001 /* 0002 This class provides the interface to the libsmbclient library. 0003 0004 SPDX-FileCopyrightText: 2018-2023 Alexander Reinholdt <alexander.reinholdt@kdemail.net> 0005 SPDX-License-Identifier: GPL-2.0-or-later 0006 */ 0007 0008 #ifndef SMB4KCLIENT_H 0009 #define SMB4KCLIENT_H 0010 0011 // application specific includes 0012 #include "smb4kglobal.h" 0013 0014 // Qt includes 0015 #include <QScopedPointer> 0016 0017 // KDE includes 0018 #include <KCompositeJob> 0019 #include <KFileItem> 0020 0021 // forward declarations 0022 class Smb4KClientPrivate; 0023 class Smb4KBasicNetworkItem; 0024 class Smb4KClientBaseJob; 0025 class Smb4KPreviewDialog; 0026 0027 class Q_DECL_EXPORT Smb4KClient : public KCompositeJob 0028 { 0029 Q_OBJECT 0030 0031 public: 0032 /** 0033 * The constructor 0034 */ 0035 explicit Smb4KClient(QObject *parent = nullptr); 0036 0037 /** 0038 * The destructor 0039 */ 0040 ~Smb4KClient(); 0041 0042 /** 0043 * This function returns a static pointer to this class. 0044 * 0045 * @returns a static pointer to the Smb4KClient class. 0046 */ 0047 static Smb4KClient *self(); 0048 0049 /** 0050 * This function starts the composite job 0051 */ 0052 void start() override; 0053 0054 /** 0055 * Returns TRUE, if jobs are running and FALSE otherwise 0056 * 0057 * @returns TRUE if jobs are running 0058 */ 0059 bool isRunning(); 0060 0061 /** 0062 * Aborts all subjobs 0063 */ 0064 void abort(); 0065 0066 /** 0067 * This function starts the scan for all available workgroups and domains 0068 * on the network neighborhood. 0069 */ 0070 void lookupDomains(); 0071 0072 /** 0073 * This function looks up all hosts in a certain domain or workgroup. 0074 * 0075 * @param workgroup The workgroup object 0076 */ 0077 void lookupDomainMembers(const WorkgroupPtr &workgroup); 0078 0079 /** 0080 * This function looks up all shared resources a certain @p host provides. 0081 * 0082 * @param host The host object 0083 */ 0084 void lookupShares(const HostPtr &host); 0085 0086 /** 0087 * This function looks up all files and directories present at the location 0088 * @p item points to. The network item must be of type Smb4KGlobal::Share or 0089 * Smb4KGlobal::Directory. 0090 * 0091 * @param item The network item object 0092 */ 0093 void lookupFiles(const NetworkItemPtr &item); 0094 0095 /** 0096 * This function starts the printing of a file @p file to the printer share 0097 * @p printer. 0098 * 0099 * @param share The printer share 0100 * 0101 * @param fileItem The file item 0102 * 0103 * @param copies Number of copies 0104 */ 0105 void printFile(const SharePtr &share, const KFileItem &fileItem, int copies); 0106 0107 /** 0108 * Perform a search on the entire network neighborhood 0109 * 0110 * @param item The search item 0111 */ 0112 void search(const QString &item); 0113 0114 Q_SIGNALS: 0115 /** 0116 * This signal is emitted when the client starts its work. 0117 * 0118 * @param item The network item 0119 * @param type The type of work 0120 */ 0121 void aboutToStart(const NetworkItemPtr &item, int type); 0122 0123 /** 0124 * This signal is emitted when the client finished its work. 0125 * 0126 * @param item The network item 0127 * @param type The type of work 0128 */ 0129 void finished(const NetworkItemPtr &item, int type); 0130 0131 /** 0132 * Emitted when the requested list of workgroups was acquired 0133 */ 0134 void workgroups(); 0135 0136 /** 0137 * Emitted when the requested list of workgroup members was acquired 0138 * 0139 * @param workgroup The workgroup that was queried 0140 */ 0141 void hosts(const WorkgroupPtr &workgroup); 0142 0143 /** 0144 * Emitted when the requested list of shares was acquired 0145 * 0146 * @param host The host that was queried 0147 */ 0148 void shares(const HostPtr &host); 0149 0150 /** 0151 * Emitted when the requested list of files and directories was acquired 0152 * 0153 * @param list The list of files and directories 0154 */ 0155 void files(const QList<FilePtr> &list); 0156 0157 /** 0158 * Emitted when a search was done 0159 * 0160 * @param list The list of search results 0161 */ 0162 void searchResults(const QList<SharePtr> &list); 0163 0164 /** 0165 * Emitted when credentials are requested from elsewhere 0166 * 0167 * @param networkItem The network item for which the credentials 0168 * are requested 0169 */ 0170 void requestCredentials(const NetworkItemPtr &networkItem); 0171 0172 protected Q_SLOTS: 0173 /** 0174 * Start the composite job 0175 */ 0176 void slotStartJobs(); 0177 0178 /** 0179 * React on changes of the online state 0180 */ 0181 void slotOnlineStateChanged(bool online); 0182 0183 /** 0184 * Called when a job finished. Reimplemented from KCompositeJob. 0185 */ 0186 void slotResult(KJob *job) override; 0187 0188 /** 0189 * Called when the application is about to be closed 0190 */ 0191 void slotAboutToQuit(); 0192 0193 /** 0194 * Called when a process should be aborted 0195 */ 0196 void slotAbort(); 0197 0198 /** 0199 * Called when the credentials were updated 0200 */ 0201 void slotCredentialsUpdated(const QUrl &url); 0202 0203 private: 0204 /** 0205 * Process errors 0206 */ 0207 void processErrors(Smb4KClientBaseJob *job); 0208 0209 /** 0210 * Process the domains/workgroups retrieved from the network 0211 * 0212 * @param job The client base job 0213 */ 0214 void processWorkgroups(Smb4KClientBaseJob *job); 0215 0216 /** 0217 * Process the domain/workgroup members 0218 * 0219 * @param job The client job 0220 */ 0221 void processHosts(Smb4KClientBaseJob *job); 0222 0223 /** 0224 * Process the shares 0225 * 0226 * @param job The client job 0227 */ 0228 void processShares(Smb4KClientBaseJob *job); 0229 0230 /** 0231 * Process the files and directories 0232 * 0233 * @param job The client job 0234 */ 0235 void processFiles(Smb4KClientBaseJob *job); 0236 0237 /** 0238 * Pointer to the Smb4KClientPrivate class 0239 */ 0240 QScopedPointer<Smb4KClientPrivate> d; 0241 }; 0242 0243 #endif