kio Library API Documentation

kpasswdserver.h

00001 /*
00002     This file is part of the KDE Password Server
00003 
00004     Copyright (C) 2002 Waldo Bastian (bastian@kde.org)
00005 
00006     This library is free software; you can redistribute it and/or
00007     modify it under the terms of the GNU General Public License
00008     version 2 as published by the Free Software Foundation.
00009 
00010     This software is distributed in the hope that it will be useful,
00011     but WITHOUT ANY WARRANTY; without even the implied warranty of
00012     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00013     General Public License for more details.
00014 
00015     You should have received a copy of the GNU General Public License
00016     along with this library; see the file COPYING. If not, write to
00017     the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
00018     Boston, MA 02111-1307, USA.
00019 */
00020 //----------------------------------------------------------------------------
00021 //
00022 // KDE Password Server
00023 // $Id: kpasswdserver.h 426310 2005-06-16 23:37:01Z dfaure $
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   KIO::AuthInfo checkAuthInfo(KIO::AuthInfo, long);
00049   KIO::AuthInfo queryAuthInfo(KIO::AuthInfo, QString, long, long);
00050   void addAuthInfo(KIO::AuthInfo, long);
00051 
00052 public slots:
00053   void processRequest();
00054   // Remove all authentication info associated with windowId
00055   void removeAuthForWindowId(long windowId);
00056 
00057 protected:
00058   struct AuthInfo;
00059 
00060   QString createCacheKey( const KIO::AuthInfo &info );
00061   const AuthInfo *findAuthInfoItem(const QString &key, const KIO::AuthInfo &info);
00062   void removeAuthInfoItem(const QString &key, const KIO::AuthInfo &info);
00063   void addAuthInfoItem(const QString &key, const KIO::AuthInfo &info, long windowId, long seqNr, bool canceled);
00064   KIO::AuthInfo copyAuthInfo(const AuthInfo *);
00065   void updateAuthExpire(const QString &key, const AuthInfo *, long windowId, bool keep);
00066   static bool storeInWallet( KWallet::Wallet* wallet, const QString& key, const KIO::AuthInfo &info );
00067   static bool readFromWallet( KWallet::Wallet* wallet, const QString& key, QString& username, QString& password, bool userReadOnly, QMap<QString,QString>& knownLogins );
00068   int findWalletEntry( const QMap<QString,QString>& map, const QString& username );
00069   bool openWallet( WId windowId );
00070 
00071   struct AuthInfo {
00072     AuthInfo() { expire = expNever; isCanceled = false; seqNr = 0; }
00073 
00074     KURL url;
00075     QString directory;
00076     QString username;
00077     QString password;
00078     QString realmValue;
00079     QString digestInfo;
00080 
00081     enum { expNever, expWindowClose, expTime } expire;
00082     QValueList<long> windowList;
00083     unsigned long expireTime;
00084     long seqNr;
00085 
00086     bool isCanceled;
00087   };
00088 
00089   class AuthInfoList : public QPtrList<AuthInfo>
00090   {
00091     public:
00092       AuthInfoList() { setAutoDelete(true); }
00093       int compareItems(QPtrCollection::Item n1, QPtrCollection::Item n2);
00094   };
00095 
00096   QDict< AuthInfoList > m_authDict;
00097 
00098   struct Request {
00099      DCOPClient *client;
00100      DCOPClientTransaction *transaction;
00101      QString key;
00102      KIO::AuthInfo info;
00103      QString errorMsg;
00104      long windowId;
00105      long seqNr;
00106      bool prompt;
00107   };
00108 
00109   QPtrList< Request > m_authPending;
00110   QPtrList< Request > m_authWait;
00111   QIntDict<QStringList> mWindowIdList;
00112   DCOPClient *m_dcopClient;
00113   KWallet::Wallet* m_wallet;
00114   long m_seqNr;
00115 };
00116 
00117 #endif
KDE Logo
This file is part of the documentation for kio Library Version 3.4.2.
Documentation copyright © 1996-2004 the KDE developers.
Generated on Tue Aug 2 12:05:07 2005 by doxygen 1.3.9.1 written by Dimitri van Heesch, © 1997-2003