void KPasswdServer::removeAuthForWindowId(long windowId) { QStringList *keysChanged = mWindowIdList.find(windowId); if(!keysChanged) return; for(QStringList::ConstIterator it = keysChanged->begin(); it != keysChanged->end(); ++it) { QString key = *it; AuthInfoList *authList = m_authDict.find(key); if(!authList) continue; AuthInfo *current = authList->first(); for(; current;) { if(current->expire == AuthInfo::expWindowClose) { if(current->windowList.remove(windowId) && current->windowList.isEmpty()) { authList->remove(); current = authList->current(); continue; } } current = authList->next(); } } }
const KPasswdServer::AuthInfo *KPasswdServer::findAuthInfoItem(const QString &key, const KIO::AuthInfo &info) { AuthInfoList *authList = m_authDict.find(key); if(!authList) return 0; QString path2 = info.url.directory(false, false); for(AuthInfo *current = authList->first(); current;) { if((current->expire == AuthInfo::expTime) && (difftime(time(0), current->expireTime) > 0)) { authList->remove(); current = authList->current(); continue; } if(info.verifyPath) { QString path1 = current->directory; if(path2.startsWith(path1) && (info.username.isEmpty() || info.username == current->username)) return current; } else { if(current->realmValue == info.realmValue && (info.username.isEmpty() || info.username == current->username)) return current; // TODO: Update directory info, } current = authList->next(); } return 0; }
void KPasswdServer::removeAuthInfoItem(const QString &key, const KIO::AuthInfo &info) { AuthInfoList *authList = m_authDict.find(key); if (!authList) return; for(AuthInfo *current = authList->first(); current; ) { if (current->realmValue == info.realmValue) { authList->remove(); current = authList->current(); } else { current = authList->next(); } } if (authList->isEmpty()) { m_authDict.remove(key); } }
void KPasswdServer::addAuthInfoItem(const QString &key, const KIO::AuthInfo &info, long windowId, long seqNr, bool canceled) { AuthInfoList *authList = m_authDict.find(key); if (!authList) { authList = new AuthInfoList; m_authDict.insert(key, authList); } AuthInfo *current = authList->first(); for(; current; current = authList->next()) { if (current->realmValue == info.realmValue) { authList->take(); break; } } if (!current) { current = new AuthInfo; current->expire = AuthInfo::expTime; kdDebug(130) << "Creating AuthInfo" << endl; } else { kdDebug(130) << "Updating AuthInfo" << endl; } current->url = info.url; current->directory = info.url.directory(false, false); current->username = info.username; current->password = info.password; current->realmValue = info.realmValue; current->digestInfo = info.digestInfo; current->seqNr = seqNr; current->isCanceled = canceled; updateAuthExpire(key, current, windowId, info.keepPassword && !canceled); // Insert into list, keep the list sorted "longest path" first. authList->inSort(current); }