kpasswdserver.h00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025 #ifndef KPASSWDSERVER_H
00026 #define KPASSWDSERVER_H
00027
00028 #include <qdict.h>
00029 #include <qintdict.h>
00030
00031 #include <dcopclient.h>
00032 #include <kio/authinfo.h>
00033 #include <kded/kdedmodule.h>
00034
00035 namespace KWallet {
00036 class Wallet;
00037 }
00038
00039 class KPasswdServer : public KDEDModule
00040 {
00041 Q_OBJECT
00042 K_DCOP
00043 public:
00044 KPasswdServer(const QCString &);
00045 ~KPasswdServer();
00046
00047 k_dcop:
00048
00049 KIO::AuthInfo checkAuthInfo(KIO::AuthInfo, long, unsigned long);
00050 KIO::AuthInfo checkAuthInfo(KIO::AuthInfo, long);
00051 KIO::AuthInfo queryAuthInfo(KIO::AuthInfo, QString, long, long, unsigned long);
00052 KIO::AuthInfo queryAuthInfo(KIO::AuthInfo, QString, long, long);
00053 void addAuthInfo(KIO::AuthInfo, long);
00054
00055 public slots:
00056 void processRequest();
00057
00058 void removeAuthForWindowId(long windowId);
00059
00060 protected:
00061 struct AuthInfo;
00062
00063 QString createCacheKey( const KIO::AuthInfo &info );
00064 const AuthInfo *findAuthInfoItem(const QString &key, const KIO::AuthInfo &info);
00065 void removeAuthInfoItem(const QString &key, const KIO::AuthInfo &info);
00066 void addAuthInfoItem(const QString &key, const KIO::AuthInfo &info, long windowId, long seqNr, bool canceled);
00067 KIO::AuthInfo copyAuthInfo(const AuthInfo *);
00068 void updateAuthExpire(const QString &key, const AuthInfo *, long windowId, bool keep);
00069 int findWalletEntry( const QMap<QString,QString>& map, const QString& username );
00070 bool openWallet( WId windowId );
00071
00072 struct AuthInfo {
00073 AuthInfo() { expire = expNever; isCanceled = false; seqNr = 0; }
00074
00075 KURL url;
00076 QString directory;
00077 QString username;
00078 QString password;
00079 QString realmValue;
00080 QString digestInfo;
00081
00082 enum { expNever, expWindowClose, expTime } expire;
00083 QValueList<long> windowList;
00084 unsigned long expireTime;
00085 long seqNr;
00086
00087 bool isCanceled;
00088 };
00089
00090 class AuthInfoList : public QPtrList<AuthInfo>
00091 {
00092 public:
00093 AuthInfoList() { setAutoDelete(true); }
00094 int compareItems(QPtrCollection::Item n1, QPtrCollection::Item n2);
00095 };
00096
00097 QDict< AuthInfoList > m_authDict;
00098
00099 struct Request {
00100 DCOPClient *client;
00101 DCOPClientTransaction *transaction;
00102 QString key;
00103 KIO::AuthInfo info;
00104 QString errorMsg;
00105 long windowId;
00106 long seqNr;
00107 bool prompt;
00108 };
00109
00110 QPtrList< Request > m_authPending;
00111 QPtrList< Request > m_authWait;
00112 QIntDict<QStringList> mWindowIdList;
00113 DCOPClient *m_dcopClient;
00114 KWallet::Wallet* m_wallet;
00115 long m_seqNr;
00116 };
00117
00118 #endif
|