File indexing completed on 2024-04-21 15:42:51
0001 /*************************************************************************** 0002 This is the wallet manager of Smb4K. 0003 ------------------- 0004 begin : Sa Dez 27 2008 0005 copyright : (C) 2008-2019 by Alexander Reinholdt 0006 email : alexander.reinholdt@kdemail.net 0007 ***************************************************************************/ 0008 0009 /*************************************************************************** 0010 * This program is free software; you can redistribute it and/or modify * 0011 * it under the terms of the GNU General Public License as published by * 0012 * the Free Software Foundation; either version 2 of the License, or * 0013 * (at your option) any later version. * 0014 * * 0015 * This program is distributed in the hope that it will be useful, but * 0016 * WITHOUT ANY WARRANTY; without even the implied warranty of * 0017 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * 0018 * General Public License for more details. * 0019 * * 0020 * You should have received a copy of the GNU General Public License * 0021 * along with this program; if not, write to the * 0022 * Free Software Foundation, Inc., 51 Franklin Street, Suite 500, Boston,* 0023 * MA 02110-1335, USA * 0024 ***************************************************************************/ 0025 0026 #ifndef SMB4KWALLETMANAGER_H 0027 #define SMB4KWALLETMANAGER_H 0028 0029 // application specific includes 0030 #include "smb4kglobal.h" 0031 0032 // Qt includes 0033 #include <QList> 0034 #include <QWidget> 0035 0036 // forward declarations 0037 class Smb4KAuthInfo; 0038 class Smb4KWalletManagerPrivate; 0039 0040 /** 0041 * This class manages the access to the digital wallet where the authentication 0042 * information is stored. 0043 * 0044 * If the user chooses to no use the wallet, a password dialog is shown every 0045 * time authentication information is needed. 0046 * 0047 * @author Alexander Reinholdt <alexander.reinholdt@kdemail.net> 0048 */ 0049 0050 class Q_DECL_EXPORT Smb4KWalletManager : public QObject 0051 { 0052 Q_OBJECT 0053 0054 friend class Smb4KWalletManagerPrivate; 0055 0056 public: 0057 /** 0058 * The constructor 0059 */ 0060 explicit Smb4KWalletManager(QObject *parent = 0); 0061 0062 /** 0063 * The destructor 0064 */ 0065 ~Smb4KWalletManager(); 0066 0067 /** 0068 * This is a static pointer to this class. 0069 */ 0070 static Smb4KWalletManager *self(); 0071 0072 /** 0073 * Read the authentication for a certain network item. This functions 0074 * adds the login and password (if present) to the past @p item. A 0075 * pre-defined login name is honored. 0076 * 0077 * If you pass an empty item, the default authentication information will 0078 * be set or none at all, depending on the settings the user chose. 0079 * 0080 * @param networkItem The network item for that the authentication 0081 * information should be acquired 0082 */ 0083 void readAuthInfo(const NetworkItemPtr &networkItem); 0084 0085 /** 0086 * This function reads the default authentication information and enters it 0087 * into @p authInfo. If no default authentication data is present this 0088 * function does nothing. 0089 * 0090 * Please note that this function does not check if the user disabled the use 0091 * of the default login. It is always returned. 0092 * 0093 * @param authInfo The Smb4KAuthInfo object that will be populated 0094 * with the default authentication information. 0095 */ 0096 void readDefaultAuthInfo(Smb4KAuthInfo *authInfo); 0097 0098 /** 0099 * Write the authentication information provided by the network item to 0100 * the wallet or to the internal list if no wallet should be used. 0101 * 0102 * @param networkItem The network item for that the authentication 0103 * information should be saved 0104 */ 0105 void writeAuthInfo(const NetworkItemPtr &networkItem); 0106 0107 /** 0108 * This function writes the default authentication information to the 0109 * wallet. If the wallet is not used, the authentication information is 0110 * not of type Smb4KAuthInfo::Default or empty, this function does nothing. 0111 * 0112 * @param authInfo The Smb4KAuthInfo object 0113 */ 0114 void writeDefaultAuthInfo(Smb4KAuthInfo *authInfo); 0115 0116 /** 0117 * Show the password dialog. This function takes an Smb4KBasicNetworkItem 0118 * object @p item, shows an authentication dialog and saves the data if 0119 * it is new or updated. 0120 * 0121 * @param networkItem The network item for that the authentication 0122 * information should be entered 0123 * 0124 * @returns TRUE if successful and FALSE otherwise 0125 */ 0126 bool showPasswordDialog(const NetworkItemPtr &networkItem); 0127 0128 /** 0129 * This function returns TRUE if the wallet system can be/is used and 0130 * FALSE otherwise. 0131 * 0132 * @returns TRUE if the wallet system can be/is used. 0133 */ 0134 bool useWalletSystem() const; 0135 0136 /** 0137 * Returns the list of authentication information objects stored in the 0138 * wallet or an empty list if the wallet is not open, no entries are 0139 * defined or the wallet system is disabled. 0140 * 0141 * @returns a list of all wallet entries. 0142 */ 0143 QList<Smb4KAuthInfo *> walletEntries(); 0144 0145 /** 0146 * Writes a list of authentication information objects to the wallet. If 0147 * the wallet system is disabled or the wallet is not open, this function 0148 * will do nothing. 0149 * 0150 * @param entries The list of authentication information objects 0151 */ 0152 void writeWalletEntries(const QList<Smb4KAuthInfo *> &entries); 0153 0154 /** 0155 * This function returns TRUE if the wallet is used and open and 0156 * FALSE otherwise. 0157 * 0158 * @returns TRUE if the wallet is used and open. 0159 */ 0160 bool walletIsOpen() const; 0161 0162 Q_SIGNALS: 0163 /** 0164 * This signal is emitted when the wallet manager was initialized 0165 * and is ready to process authentication information. 0166 */ 0167 void initialized(); 0168 0169 private: 0170 /** 0171 * Initialize the wallet manager. 0172 */ 0173 void init(); 0174 0175 /** 0176 * Pointer to the Smb4KWalletManagerPrivate class 0177 */ 0178 const QScopedPointer<Smb4KWalletManagerPrivate> d; 0179 }; 0180 0181 #endif