[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-core-devel
Subject: Re: PATCH for review: KIO::AuthInfo, KPasswordDialog and KPasswdServer
From: nf2 <nf2 () scheinwelt ! at>
Date: 2008-05-18 17:14:00
Message-ID: 483063D8.90808 () scheinwelt ! at
[Download RAW message or body]
nf2 wrote:
> This patch extends KIO::AuthInfo and KPasswordDialog:
>
> KIO::AuthInfo:
>
> * Extra fields (like "domain"), stored as a map of QVariants
> * Anonymous login flag
> * Flag to suppress password caching in KPasswdServer
>
> KPasswordDialog:
>
> * Optional domain field
> * Optional "anonymous login" checkbox
>
> Additionally i did some refactoring of KPasswdServer
>
> * Renamed struct AuthInfo into struct AuthInfoContainer, for better
> readability.
> * KIO::AuthInfo inside this struct, instead of cloning all the fields
> one by one.
>
> Regards,
> Norbert
>
Here is an updated set of the patches for kdelibs and kdebase.
I have streamlined the extensions of the KIO::AuthInfo API:
* The flag to enable the anonymous login checkbox is stored as
KIO::AuthInfo Extra-Field as well.
* The flag to bypass KPasswdServers caching and Kwallet is a "hidden
feature" for now (just set the extra-field "bypass-cache-and-kwallet" to
true), because i'm not sure yet, where this flag should be set: An
additional method in AuthInfo - or by overloading
SlaveBase::openPasswordDialog()?
Could someone please have a quick look at it - particularly the
KIO::AuthInfo API changes? Because of the feature-freeze i'm afraid i
have to commit it tonight. :-)
Regards,
Norbert
["kdelibs_authinfo_2.patch" (text/x-diff)]
Index: kio/kio/authinfo.cpp
===================================================================
--- kio/kio/authinfo.cpp (revision 809180)
+++ kio/kio/authinfo.cpp (working copy)
@@ -41,19 +41,67 @@
using namespace KIO;
-AuthInfo::AuthInfo()
+//////
+
+class ExtraField
{
+public:
+ QString customTitle; // reserved for future use
+ AuthInfo::FieldFlags flags;
+ QVariant value;
+
+ ExtraField() : flags(AuthInfo::ExtraFieldNoFlags) {}
+};
+
+QDataStream& operator<< (QDataStream& s, const ExtraField& extraField)
+{
+ s << extraField.customTitle;
+ s << (int)extraField.flags;
+ s << extraField.value;
+ return s;
+}
+
+QDataStream& operator>> (QDataStream& s, ExtraField& extraField)
+{
+ s >> extraField.customTitle ;
+ int i;
+ s >> i;
+ extraField.flags = (AuthInfo::FieldFlags)i;
+ s >> extraField.value ;
+ return s;
+}
+
+
+class AuthInfoPrivate
+{
+public:
+ AuthInfoPrivate()
+ {}
+
+ QMap<QString, ExtraField> extraFields;
+};
+
+
+//////
+
+AuthInfo::AuthInfo() : d(new AuthInfoPrivate())
+{
modified = false;
readOnly = false;
verifyPath = false;
keepPassword = false;
}
-AuthInfo::AuthInfo( const AuthInfo& info )
+AuthInfo::AuthInfo( const AuthInfo& info ) : d(new AuthInfoPrivate())
{
(*this) = info;
}
+AuthInfo::~AuthInfo()
+{
+ delete d;
+}
+
AuthInfo& AuthInfo::operator= ( const AuthInfo& info )
{
url = info.url;
@@ -69,6 +117,7 @@
readOnly = info.readOnly;
keepPassword = info.keepPassword;
modified = info.modified;
+ d->extraFields = info.d->extraFields;
return *this;
}
@@ -82,19 +131,50 @@
modified = flag;
}
+/////
+
+void AuthInfo::setExtraField(const QString &fieldName, const QVariant & value)
+{
+ d->extraFields[fieldName].value = value;
+}
+
+void AuthInfo::setExtraFieldFlags(const QString &fieldName, const FieldFlags flags)
+{
+ d->extraFields[fieldName].flags = flags;
+}
+
+QVariant AuthInfo::getExtraField(const QString &fieldName) const
+{
+ if (!d->extraFields.contains(fieldName)) return QVariant();
+ return d->extraFields[fieldName].value;
+}
+
+AuthInfo::FieldFlags AuthInfo::getExtraFieldFlags(const QString &fieldName) const
+{
+ if (!d->extraFields.contains(fieldName)) return AuthInfo::ExtraFieldNoFlags;
+ return d->extraFields[fieldName].flags;
+}
+
+/////
+
QDataStream& KIO::operator<< (QDataStream& s, const AuthInfo& a)
{
- s << a.url << a.username << a.password << a.prompt << a.caption
+ s << (quint8)1
+ << a.url << a.username << a.password << a.prompt << a.caption
<< a.comment << a.commentLabel << a.realmValue << a.digestInfo
- << a.verifyPath << a.readOnly << a.keepPassword << a.modified;
+ << a.verifyPath << a.readOnly << a.keepPassword << a.modified
+ << a.d->extraFields;
return s;
}
QDataStream& KIO::operator>> (QDataStream& s, AuthInfo& a)
{
- s >> a.url >> a.username >> a.password >> a.prompt >> a.caption
+ quint8 version;
+ s >> version
+ >> a.url >> a.username >> a.password >> a.prompt >> a.caption
>> a.comment >> a.commentLabel >> a.realmValue >> a.digestInfo
- >> a.verifyPath >> a.readOnly >> a.keepPassword >> a.modified;
+ >> a.verifyPath >> a.readOnly >> a.keepPassword >> a.modified
+ >> a.d->extraFields;
return s;
}
Index: kio/kio/authinfo.h
===================================================================
--- kio/kio/authinfo.h (revision 809180)
+++ kio/kio/authinfo.h (working copy)
@@ -28,6 +28,8 @@
#include <QtCore/QStringList>
#include <kurl.h>
+class AuthInfoPrivate;
+
namespace KIO {
/**
@@ -56,6 +58,7 @@
KIO_EXPORT friend QDataStream& operator>> (QDataStream& s, AuthInfo& a);
public:
+
/**
* Default constructor.
*/
@@ -65,8 +68,14 @@
* Copy constructor.
*/
AuthInfo( const AuthInfo& info );
-
+
/**
+ * Destructor
+ * @since 4.1
+ */
+ ~AuthInfo();
+
+ /**
* Overloaded equal to operator.
*/
AuthInfo& operator=( const AuthInfo& info );
@@ -219,12 +228,54 @@
* cached password is deleted right after the application using
* it has been closed.
*/
- bool keepPassword;
-
+ bool keepPassword;
+
+ /**
+ * Flags for extra fields
+ * @since 4.1
+ */
+ enum FieldFlags
+ {
+ ExtraFieldNoFlags = 0,
+ ExtraFieldReadOnly = 1<<1,
+ ExtraFieldMandatory = 1<<2
+ };
+
+ /**
+ * Set Extra Field Value.
+ * Currently supported extra-fields:
+ * "domain" (QString),
+ * "anonymous" (bool)
+ * Setting it to an invalid QVariant() will disable the field.
+ * Extra Fields are disabled by default.
+ * @since 4.1
+ */
+ void setExtraField(const QString &fieldName, const QVariant & value);
+
+ /**
+ * Set Extra Field Flags
+ * @since 4.1
+ */
+ void setExtraFieldFlags(const QString &fieldName, const FieldFlags flags);
+
+ /**
+ * Get Extra Field Value
+ * Check QVariant::isValid() to find out if the field exists.
+ * @since 4.1
+ */
+ QVariant getExtraField(const QString &fieldName) const;
+
+ /**
+ * Get Extra Field Flags
+ * @since 4.1
+ */
+ AuthInfo::FieldFlags getExtraFieldFlags(const QString &fieldName) const;
+
protected:
bool modified;
private:
- class AuthInfoPrivate* d;
+ friend class AuthInfoPrivate;
+ AuthInfoPrivate * const d;
};
KIO_EXPORT QDataStream& operator<< (QDataStream& s, const AuthInfo& a);
Index: kdeui/dialogs/kpassworddialog.h
===================================================================
--- kdeui/dialogs/kpassworddialog.h (revision 809180)
+++ kdeui/dialogs/kpassworddialog.h (working copy)
@@ -73,7 +73,22 @@
/**
* If this flag is set, the login lineedit will be in read only mode.
*/
- UsernameReadOnly = 0x04
+ UsernameReadOnly = 0x04,
+ /**
+ * If this flag is set, the Anonymous Login checkbox will be displayed
+ * @since 4.1
+ */
+ ShowAnonymousLoginCheckBox = 0x08,
+ /**
+ * If this flag is set, there will be an additional line to let the user enter the domain.
+ * @since 4.1
+ */
+ ShowDomainLine = 0x10,
+ /**
+ * If this flag is set, the domain lineedit will be in read only mode.
+ * @since 4.1
+ */
+ DomainReadOnly = 0x20
};
Q_DECLARE_FLAGS(KPasswordDialogFlags, KPasswordDialogFlag)
@@ -85,7 +100,7 @@
* A problem with the user name as entered
**/
UsernameError,
-
+
/**
* Incorrect password
*/
@@ -94,7 +109,13 @@
/**
* Error preventing further attempts, will result in disabling most of the interface
*/
- FatalError
+ FatalError,
+
+ /**
+ * A problem with the domain as entered
+ * @since 4.1
+ **/
+ DomainError
};
/**
@@ -172,6 +193,31 @@
QString username() const;
/**
+ * set the default domain.
+ * @since 4.1
+ */
+ void setDomain(const QString&);
+
+ /**
+ * Returns the domain entered by the user.
+ * @return the domain name
+ * @since 4.1
+ */
+ QString domain() const;
+
+ /**
+ * set anonymous mode (all other fields will be greyed out)
+ * @since 4.1
+ */
+ void setAnonymousMode(bool anonymous);
+
+ /**
+ * @return anonymous mode has been selected.
+ * @since 4.1
+ */
+ bool anonymousMode() const;
+
+ /**
* Determines whether supplied authorization should
* persist even after the application has been closed.
*
@@ -250,6 +296,7 @@
private:
Q_PRIVATE_SLOT(d, void actuallyAccept())
Q_PRIVATE_SLOT(d, void activated( const QString& userName ))
+ Q_PRIVATE_SLOT(d, void updateFields())
private:
class KPasswordDialogPrivate;
Index: kdeui/dialogs/kpassworddialog.ui
===================================================================
--- kdeui/dialogs/kpassworddialog.ui (revision 809180)
+++ kdeui/dialogs/kpassworddialog.ui (working copy)
@@ -116,6 +116,23 @@
</widget>
</item>
<item row="1" column="0" >
+ <widget class="QCheckBox" name="anonymousCheckBox" >
+ <property name="text" >
+ <string>Anonymous</string>
+ </property>
+ </widget>
+ </item>
+ <item row="2" column="0" >
+ <widget class="QLabel" name="domainLabel" >
+ <property name="text" >
+ <string>Domain:</string>
+ </property>
+ <property name="buddy" >
+ <cstring>domainEdit</cstring>
+ </property>
+ </widget>
+ </item>
+ <item row="3" column="0" >
<widget class="QLabel" name="passwordLabel" >
<property name="text" >
<string>Password:</string>
@@ -125,14 +142,14 @@
</property>
</widget>
</item>
- <item row="1" column="1" >
+ <item row="3" column="1" >
<widget class="KLineEdit" name="passEdit" >
<property name="passwordMode" stdset="0" >
<bool>true</bool>
</property>
</widget>
</item>
- <item row="2" column="1" >
+ <item row="4" column="1" >
<widget class="QCheckBox" name="keepCheckBox" >
<property name="text" >
<string>Remember password</string>
@@ -142,6 +159,9 @@
<item row="0" column="1" >
<widget class="QLineEdit" name="userEdit" />
</item>
+ <item row="2" column="1" >
+ <widget class="QLineEdit" name="domainEdit" />
+ </item>
</layout>
</item>
<item>
@@ -171,6 +191,8 @@
</customwidgets>
<tabstops>
<tabstop>userEdit</tabstop>
+ <tabstop>anonymousCheckBox</tabstop>
+ <tabstop>domainEdit</tabstop>
<tabstop>passEdit</tabstop>
<tabstop>keepCheckBox</tabstop>
</tabstops>
Index: kdeui/dialogs/kpassworddialog.cpp
===================================================================
--- kdeui/dialogs/kpassworddialog.cpp (revision 809180)
+++ kdeui/dialogs/kpassworddialog.cpp (working copy)
@@ -50,9 +50,11 @@
void actuallyAccept();
void activated( const QString& userName );
- void init( const KPasswordDialogFlags& flags );
+ void updateFields();
+ void init();
KPasswordDialog *q;
+ KPasswordDialogFlags m_flags;
Ui_KPasswordDialog ui;
QMap<QString,QString> knownLogins;
KComboBox* userEditCombo;
@@ -69,7 +71,8 @@
setButtons( Ok | Cancel | otherButtons );
showButtonSeparator( true );
setDefaultButton( Ok );
- d->init ( flags );
+ d->m_flags = flags;
+ d->init ();
}
KPasswordDialog::~KPasswordDialog()
@@ -77,26 +80,61 @@
delete d;
}
-void KPasswordDialog::KPasswordDialogPrivate::init( const KPasswordDialogFlags& flags )
+void KPasswordDialog::KPasswordDialogPrivate::updateFields()
{
+ if (q->anonymousMode())
+ {
+ ui.userEdit->setEnabled( false );
+ ui.domainEdit->setEnabled( false );
+ ui.passEdit->setEnabled( false );
+ }
+ else
+ {
+ ui.userEdit->setEnabled(!( m_flags & KPasswordDialog::UsernameReadOnly ));
+ ui.domainEdit->setEnabled(!( m_flags & KPasswordDialog::DomainReadOnly ));
+ ui.passEdit->setEnabled( true );
+ }
+}
+
+void KPasswordDialog::KPasswordDialogPrivate::init()
+{
ui.setupUi( q->mainWidget() );
ui.errorMessage->setHidden(true);
// Row 4: Username field
- if ( flags & KPasswordDialog::ShowUsernameLine ) {
+ if ( m_flags & KPasswordDialog::ShowUsernameLine ) {
ui.userEdit->setFocus();
QObject::connect( ui.userEdit, SIGNAL(returnPressed()), ui.passEdit, SLOT(setFocus()) );
} else {
ui.userNameLabel->hide();
ui.userEdit->hide();
+ ui.domainLabel->hide();
+ ui.domainEdit->hide();
ui.passEdit->setFocus();
}
- if ( !( flags & KPasswordDialog::ShowKeepPassword ) )
+ if ( !( m_flags & KPasswordDialog::ShowAnonymousLoginCheckBox ) )
{
+ ui.anonymousCheckBox->hide();
+ }
+ else
+ {
+ QObject::connect( ui.anonymousCheckBox, SIGNAL(stateChanged (int)), q, SLOT(updateFields()) );
+ }
+
+ if ( !( m_flags & KPasswordDialog::ShowDomainLine ) )
+ {
+ ui.domainLabel->hide();
+ ui.domainEdit->hide();
+ }
+
+ if ( !( m_flags & KPasswordDialog::ShowKeepPassword ) )
+ {
ui.keepCheckBox->hide();
}
+ updateFields();
+
QRect desktop = KGlobalSettings::desktopGeometry(q->topLevelWidget());
q->setFixedWidth(qMin(1000, qMax(400, desktop.width() / 4)));
q->setPixmap(KIcon("dialog-password").pixmap(KIconLoader::SizeHuge));
@@ -148,6 +186,27 @@
return d->ui.passEdit->text();
}
+void KPasswordDialog::setDomain(const QString& domain)
+{
+ d->ui.domainEdit->setText(domain);
+}
+
+QString KPasswordDialog::domain() const
+{
+ return d->ui.domainEdit->text();
+}
+
+void KPasswordDialog::setAnonymousMode(bool anonymous)
+{
+ d->ui.anonymousCheckBox->setChecked( anonymous );
+}
+
+bool KPasswordDialog::anonymousMode() const
+{
+ return d->ui.anonymousCheckBox->isChecked();
+}
+
+
void KPasswordDialog::setKeepPassword( bool b )
{
d->ui.keepCheckBox->setChecked( b );
@@ -173,9 +232,12 @@
++d->commentRow;
d->ui.gridLayout->addWidget(d->ui.userNameLabel, d->commentRow, 0);
d->ui.gridLayout->addWidget(d->ui.userEdit, d->commentRow, 1);
- d->ui.gridLayout->addWidget(d->ui.passwordLabel, d->commentRow + 1, 0);
- d->ui.gridLayout->addWidget(d->ui.passEdit, d->commentRow + 1, 1);
- d->ui.gridLayout->addWidget(d->ui.keepCheckBox, d->commentRow + 2, 1);
+ d->ui.gridLayout->addWidget(d->ui.anonymousCheckBox, d->commentRow + 1, 1);
+ d->ui.gridLayout->addWidget(d->ui.domainLabel, d->commentRow + 2, 0);
+ d->ui.gridLayout->addWidget(d->ui.domainEdit, d->commentRow + 2, 1);
+ d->ui.gridLayout->addWidget(d->ui.passwordLabel, d->commentRow + 3, 0);
+ d->ui.gridLayout->addWidget(d->ui.passEdit, d->commentRow + 3, 1);
+ d->ui.gridLayout->addWidget(d->ui.keepCheckBox, d->commentRow + 4, 1);
// cycle through column 0 widgets and see the max width so we can set the minimum height of
// column 2 wordwrapable labels
@@ -213,8 +275,15 @@
{
d->ui.userNameLabel->setFont( bold );
d->ui.userEdit->setFocus();
- break;
}
+ break;
+ case DomainError:
+ if ( d->ui.domainEdit->isVisibleTo( this ) )
+ {
+ d->ui.domainLabel->setFont( bold );
+ d->ui.domainEdit->setFocus();
+ }
+ break;
case FatalError:
d->ui.userNameLabel->setEnabled( false );
d->ui.userEdit->setEnabled( false );
["kdebase_kpasswdserver2.patch" (text/x-diff)]
Index: runtime/kpasswdserver/kpasswdserver.cpp
===================================================================
--- runtime/kpasswdserver/kpasswdserver.cpp (revision 809205)
+++ runtime/kpasswdserver/kpasswdserver.cpp (working copy)
@@ -49,14 +49,18 @@
)
K_EXPORT_PLUGIN(KPasswdServerFactory("kpasswdserver"))
+#define AUTHINFO_EXTRAFIELD_DOMAIN "domain"
+#define AUTHINFO_EXTRAFIELD_ANONYMOUS "anonymous"
+#define AUTHINFO_EXTRAFIELD_BYPASS_CACHE_AND_KWALLET "bypass-cache-and-kwallet"
+
int
-KPasswdServer::AuthInfoList::compareItems(Q3PtrCollection::Item n1, \
Q3PtrCollection::Item n2) \
+KPasswdServer::AuthInfoContainerList::compareItems(Q3PtrCollection::Item n1, \
Q3PtrCollection::Item n2) {
if (!n1 || !n2)
return 0;
- AuthInfo *i1 = (AuthInfo *) n1;
- AuthInfo *i2 = (AuthInfo *) n2;
+ AuthInfoContainer *i1 = (AuthInfoContainer *) n1;
+ AuthInfoContainer *i2 = (AuthInfoContainer *) n2;
int l1 = i1->directory.length();
int l2 = i2->directory.length();
@@ -214,7 +218,7 @@
return data; // return value will be ignored
}
- const AuthInfo *result = findAuthInfoItem(key, info);
+ const AuthInfoContainer *result = findAuthInfoItem(key, info);
if (!result || result->isCanceled)
{
if (!result &&
@@ -332,12 +336,13 @@
return;
KIO::AuthInfo &info = request->info;
-
+ bool bypassCacheAndKWallet = \
info.getExtraField(AUTHINFO_EXTRAFIELD_BYPASS_CACHE_AND_KWALLET).toBool() == true; + \
kDebug(130) << "KPasswdServer::processRequest: User= " << info.username
<< ", Message= " << info.prompt << endl;
- const AuthInfo *result = findAuthInfoItem(request->key, request->info);
+ const AuthInfoContainer *result = findAuthInfoItem(request->key, request->info);
- if (result && (request->seqNr < result->seqNr))
+ if (!bypassCacheAndKWallet && result && (request->seqNr < result->seqNr))
{
kDebug(130) << "KPasswdServer::processRequest: auto retry!";
if (result->isCanceled)
@@ -373,7 +378,8 @@
bool hasWalletData = false;
QMap<QString, QString> knownLogins;
- if ( ( username.isEmpty() || password.isEmpty() )
+ if ( !bypassCacheAndKWallet
+ && ( username.isEmpty() || password.isEmpty() )
&& !KWallet::Wallet::keyDoesNotExist(KWallet::Wallet::NetworkWallet(), \
KWallet::Wallet::PasswordFolder(), makeWalletKey( request->key, info.realmValue )) ) \
{ // no login+pass provided, check if kwallet has one
@@ -381,7 +387,28 @@
hasWalletData = readFromWallet( m_wallet, request->key, \
info.realmValue, username, password, info.readOnly, knownLogins ); }
- KPasswordDialog dlg( 0l, info.keepPassword ? ( \
KPasswordDialog::ShowUsernameLine | KPasswordDialog::ShowKeepPassword) : \
KPasswordDialog::ShowUsernameLine ) ; + // assemble dialog-flags
+ KPasswordDialog::KPasswordDialogFlags dialogFlags;
+
+ if (info.getExtraField(AUTHINFO_EXTRAFIELD_DOMAIN).isValid())
+ {
+ dialogFlags |= KPasswordDialog::ShowDomainLine;
+ if (info.getExtraFieldFlags(AUTHINFO_EXTRAFIELD_DOMAIN) & \
KIO::AuthInfo::ExtraFieldReadOnly) + {
+ dialogFlags |= KPasswordDialog::DomainReadOnly;
+ }
+ }
+
+ if (info.getExtraField(AUTHINFO_EXTRAFIELD_ANONYMOUS).isValid())
+ {
+ dialogFlags |= KPasswordDialog::ShowAnonymousLoginCheckBox;
+ }
+
+ dialogFlags |= (info.keepPassword ? ( KPasswordDialog::ShowUsernameLine
+ | KPasswordDialog::ShowKeepPassword) : \
KPasswordDialog::ShowUsernameLine ); +
+ // instantiate dialog
+ KPasswordDialog dlg( 0l, dialogFlags) ;
dlg.setPrompt(info.prompt);
dlg.setUsername(username);
if (info.caption.isEmpty())
@@ -403,6 +430,12 @@
if (hasWalletData)
dlg.setKeepPassword( true );
+ if (info.getExtraField(AUTHINFO_EXTRAFIELD_DOMAIN).isValid ())
+ dlg.setDomain(info.getExtraField(AUTHINFO_EXTRAFIELD_DOMAIN).toString());
+
+ if (info.getExtraField(AUTHINFO_EXTRAFIELD_ANONYMOUS).isValid ())
+ dlg.setAnonymousMode(info.getExtraField(AUTHINFO_EXTRAFIELD_ANONYMOUS).toBool());
+
#ifdef Q_WS_X11
XSetTransientForHint( QX11Info::display(), dlg.winId(), \
request->windowId); #endif
@@ -414,6 +447,11 @@
info.username = dlg.username();
info.password = dlg.password();
info.keepPassword = dlg.keepPassword();
+
+ if (info.getExtraField(AUTHINFO_EXTRAFIELD_DOMAIN).isValid ())
+ info.setExtraField(AUTHINFO_EXTRAFIELD_DOMAIN, dlg.domain());
+ if (info.getExtraField(AUTHINFO_EXTRAFIELD_ANONYMOUS).isValid ())
+ info.setExtraField(AUTHINFO_EXTRAFIELD_ANONYMOUS, \
dlg.anonymousMode());
// When the user checks "keep password", that means:
// * if the wallet is enabled, store it there for long-term, and in \
kpasswdserver @@ -430,12 +468,18 @@
}
if ( dlgResult != QDialog::Accepted )
{
- addAuthInfoItem(request->key, info, 0, m_seqNr, true);
+ if (!bypassCacheAndKWallet)
+ {
+ addAuthInfoItem(request->key, info, 0, m_seqNr, true);
+ }
info.setModified( false );
}
else
{
- addAuthInfoItem(request->key, info, request->windowId, m_seqNr, false);
+ if (!bypassCacheAndKWallet)
+ {
+ addAuthInfoItem(request->key, info, request->windowId, m_seqNr, \
false); + }
info.setModified( true );
}
}
@@ -478,7 +522,7 @@
}
else
{
- const AuthInfo *result = findAuthInfoItem(waitRequest->key, \
waitRequest->info); + const AuthInfoContainer *result = \
findAuthInfoItem(waitRequest->key, waitRequest->info); QByteArray replyData;
QDataStream stream2(&replyData, QIODevice::WriteOnly);
@@ -535,31 +579,26 @@
}
KIO::AuthInfo
-KPasswdServer::copyAuthInfo(const AuthInfo *i)
+KPasswdServer::copyAuthInfo(const AuthInfoContainer *i)
{
- KIO::AuthInfo result;
- result.url = i->url;
- result.username = i->username;
- result.password = i->password;
- result.realmValue = i->realmValue;
- result.digestInfo = i->digestInfo;
+ KIO::AuthInfo result = i->info;
result.setModified(true);
return result;
}
-const KPasswdServer::AuthInfo *
+const KPasswdServer::AuthInfoContainer *
KPasswdServer::findAuthInfoItem(const QString &key, const KIO::AuthInfo &info)
{
- AuthInfoList *authList = m_authDict.value(key);
+ AuthInfoContainerList *authList = m_authDict.value(key);
if (!authList)
return 0;
QString path2 = info.url.directory(KUrl::AppendTrailingSlash|KUrl::ObeyTrailingSlash);
- for(AuthInfo *current = authList->first();
+ for(AuthInfoContainer *current = authList->first();
current; )
{
- if ((current->expire == AuthInfo::expTime) &&
+ if ((current->expire == AuthInfoContainer::expTime) &&
(difftime(time(0), current->expireTime) > 0))
{
authList->remove();
@@ -571,13 +610,13 @@
{
QString path1 = current->directory;
if (path2.startsWith(path1) &&
- (info.username.isEmpty() || info.username == current->username))
+ (info.username.isEmpty() || info.username == current->info.username))
return current;
}
else
{
- if (current->realmValue == info.realmValue &&
- (info.username.isEmpty() || info.username == current->username))
+ if (current->info.realmValue == info.realmValue &&
+ (info.username.isEmpty() || info.username == current->info.username))
return current; // TODO: Update directory info,
}
@@ -589,14 +628,14 @@
void
KPasswdServer::removeAuthInfoItem(const QString &key, const KIO::AuthInfo &info)
{
- AuthInfoList *authList = m_authDict.value(key);
+ AuthInfoContainerList *authList = m_authDict.value(key);
if (!authList)
return;
- for(AuthInfo *current = authList->first();
+ for(AuthInfoContainer *current = authList->first();
current; )
{
- if (current->realmValue == info.realmValue)
+ if (current->info.realmValue == info.realmValue)
{
authList->remove();
current = authList->current();
@@ -616,16 +655,16 @@
void
KPasswdServer::addAuthInfoItem(const QString &key, const KIO::AuthInfo &info, \
qlonglong windowId, qlonglong seqNr, bool canceled) {
- AuthInfoList *authList = m_authDict.value(key);
+ AuthInfoContainerList *authList = m_authDict.value(key);
if (!authList)
{
- authList = new AuthInfoList;
+ authList = new AuthInfoContainerList;
m_authDict.insert(key, authList);
}
- AuthInfo *current = authList->first();
+ AuthInfoContainer *current = authList->first();
for(; current; current = authList->next())
{
- if (current->realmValue == info.realmValue)
+ if (current->info.realmValue == info.realmValue)
{
authList->take();
break;
@@ -634,21 +673,17 @@
if (!current)
{
- current = new AuthInfo;
- current->expire = AuthInfo::expTime;
- kDebug(130) << "Creating AuthInfo";
+ current = new AuthInfoContainer;
+ current->expire = AuthInfoContainer::expTime;
+ kDebug(130) << "Creating AuthInfoContainer";
}
else
{
- kDebug(130) << "Updating AuthInfo";
+ kDebug(130) << "Updating AuthInfoContainer";
}
- current->url = info.url;
+ current->info = info;
current->directory = \
info.url.directory(KUrl::AppendTrailingSlash|KUrl::ObeyTrailingSlash);
- current->username = info.username;
- current->password = info.password;
- current->realmValue = info.realmValue;
- current->digestInfo = info.digestInfo;
current->seqNr = seqNr;
current->isCanceled = canceled;
@@ -659,20 +694,20 @@
}
void
-KPasswdServer::updateAuthExpire(const QString &key, const AuthInfo *auth, qlonglong \
windowId, bool keep) +KPasswdServer::updateAuthExpire(const QString &key, const \
AuthInfoContainer *auth, qlonglong windowId, bool keep) {
- AuthInfo *current = const_cast<AuthInfo *>(auth);
+ AuthInfoContainer *current = const_cast<AuthInfoContainer *>(auth);
if (keep)
{
- current->expire = AuthInfo::expNever;
+ current->expire = AuthInfoContainer::expNever;
}
- else if (windowId && (current->expire != AuthInfo::expNever))
+ else if (windowId && (current->expire != AuthInfoContainer::expNever))
{
- current->expire = AuthInfo::expWindowClose;
+ current->expire = AuthInfoContainer::expWindowClose;
if (!current->windowList.contains(windowId))
current->windowList.append(windowId);
}
- else if (current->expire == AuthInfo::expTime)
+ else if (current->expire == AuthInfoContainer::expTime)
{
current->expireTime = time(0)+10;
}
@@ -701,14 +736,14 @@
it != keysChanged->end(); ++it)
{
QString key = *it;
- AuthInfoList *authList = m_authDict.value(key);
+ AuthInfoContainerList *authList = m_authDict.value(key);
if (!authList)
continue;
- AuthInfo *current = authList->first();
+ AuthInfoContainer *current = authList->first();
for(; current; )
{
- if (current->expire == AuthInfo::expWindowClose)
+ if (current->expire == AuthInfoContainer::expWindowClose)
{
if (current->windowList.removeAll(windowId) && \
current->windowList.isEmpty()) {
Index: runtime/kpasswdserver/kpasswdserver.h
===================================================================
--- runtime/kpasswdserver/kpasswdserver.h (revision 809205)
+++ runtime/kpasswdserver/kpasswdserver.h (working copy)
@@ -53,27 +53,23 @@
void removeAuthForWindowId(qlonglong windowId);
protected:
- struct AuthInfo;
+ struct AuthInfoContainer;
QString createCacheKey( const KIO::AuthInfo &info );
- const AuthInfo *findAuthInfoItem(const QString &key, const KIO::AuthInfo &info);
+ const AuthInfoContainer *findAuthInfoItem(const QString &key, const KIO::AuthInfo \
&info); void removeAuthInfoItem(const QString &key, const KIO::AuthInfo &info);
void addAuthInfoItem(const QString &key, const KIO::AuthInfo &info, qlonglong \
windowId, qlonglong seqNr, bool canceled);
- KIO::AuthInfo copyAuthInfo(const AuthInfo *);
- void updateAuthExpire(const QString &key, const AuthInfo *, qlonglong windowId, \
bool keep); + KIO::AuthInfo copyAuthInfo(const AuthInfoContainer *);
+ void updateAuthExpire(const QString &key, const AuthInfoContainer *, qlonglong \
windowId, bool keep); int findWalletEntry( const QMap<QString,QString>& map, const \
QString& username ); bool openWallet( int windowId );
- struct AuthInfo {
- AuthInfo() { expire = expNever; isCanceled = false; seqNr = 0; }
+ struct AuthInfoContainer {
+ AuthInfoContainer() { expire = expNever; isCanceled = false; seqNr = 0; }
- KUrl url;
+ KIO::AuthInfo info;
QString directory;
- QString username;
- QString password;
- QString realmValue;
- QString digestInfo;
-
+
enum { expNever, expWindowClose, expTime } expire;
QList<qlonglong> windowList;
qulonglong expireTime;
@@ -82,14 +78,14 @@
bool isCanceled;
};
- class AuthInfoList : public Q3PtrList<AuthInfo>
+ class AuthInfoContainerList : public Q3PtrList<AuthInfoContainer>
{
public:
- AuthInfoList() { setAutoDelete(true); }
+ AuthInfoContainerList() { setAutoDelete(true); }
int compareItems(Q3PtrCollection::Item n1, Q3PtrCollection::Item n2);
};
- QHash< QString, AuthInfoList* > m_authDict;
+ QHash< QString, AuthInfoContainerList* > m_authDict;
struct Request {
QDBusMessage transaction;
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic