2 This file is part of the KDE Password Server
4 Copyright (C) 2002 Waldo Bastian (bastian@kde.org)
6 This library is free software; you can redistribute it and/or
7 modify it under the terms of the GNU General Public License
8 version 2 as published by the Free Software Foundation.
10 This software is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 General Public License for more details.
15 You should have received a copy of the GNU General Public License
16 along with this library; see the file COPYING. If not, write to
17 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
18 Boston, MA 02110-1301, USA.
20 //----------------------------------------------------------------------------
22 // KDE Password Server
24 #ifndef KPASSWDSERVER_H
25 #define KPASSWDSERVER_H
27 #include <QtCore/QHash>
28 #include <Qt3Support/Q3PtrList>
29 #include <QtDBus/QtDBus>
31 #include <kio/authinfo.h>
32 #include <kdedmodule.h>
38 class KPasswdServer
: public KDEDModule
41 Q_CLASSINFO("D-Bus Interface", "org.kde.KPasswdServer")
43 KPasswdServer(QObject
* parent
, const QList
<QVariant
>&);
47 Q_SCRIPTABLE QByteArray
checkAuthInfo(const QByteArray
&, qlonglong
, qlonglong
, const QDBusMessage
&);
48 Q_SCRIPTABLE QByteArray
queryAuthInfo(const QByteArray
&, const QString
&, qlonglong
, qlonglong
, qlonglong
, const QDBusMessage
&);
49 Q_SCRIPTABLE
void addAuthInfo(const QByteArray
&, qlonglong
);
50 Q_SCRIPTABLE
void removeAuthInfo(const QString
& host
, const QString
& protocol
, const QString
& user
);
52 void processRequest();
53 // Remove all authentication info associated with windowId
54 void removeAuthForWindowId(qlonglong windowId
);
57 struct AuthInfoContainer
;
59 QString
createCacheKey( const KIO::AuthInfo
&info
);
60 const AuthInfoContainer
*findAuthInfoItem(const QString
&key
, const KIO::AuthInfo
&info
);
61 void removeAuthInfoItem(const QString
&key
, const KIO::AuthInfo
&info
);
62 void addAuthInfoItem(const QString
&key
, const KIO::AuthInfo
&info
, qlonglong windowId
, qlonglong seqNr
, bool canceled
);
63 KIO::AuthInfo
copyAuthInfo(const AuthInfoContainer
*);
64 void updateAuthExpire(const QString
&key
, const AuthInfoContainer
*, qlonglong windowId
, bool keep
);
65 int findWalletEntry( const QMap
<QString
,QString
>& map
, const QString
& username
);
66 bool openWallet( int windowId
);
68 struct AuthInfoContainer
{
69 AuthInfoContainer() { expire
= expNever
; isCanceled
= false; seqNr
= 0; }
74 enum { expNever
, expWindowClose
, expTime
} expire
;
75 QList
<qlonglong
> windowList
;
76 qulonglong expireTime
;
82 class AuthInfoContainerList
: public Q3PtrList
<AuthInfoContainer
>
85 AuthInfoContainerList() { setAutoDelete(true); }
86 int compareItems(Q3PtrCollection::Item n1
, Q3PtrCollection::Item n2
);
89 QHash
< QString
, AuthInfoContainerList
* > m_authDict
;
92 QDBusMessage transaction
;
101 Q3PtrList
< Request
> m_authPending
;
102 Q3PtrList
< Request
> m_authWait
;
103 QHash
<int, QStringList
*> mWindowIdList
;
104 KWallet::Wallet
* m_wallet
;