- if ( url.isEmpty() ) {
- return NULL;
- }
-
- int i = 0;
- DatInfoList::Iterator it;
- DatInfo* datInfo;
-
- KURL inurl = Kita::ParseMisc::parseURLonly( url );
-
- /* Is this url registered thread ? */
- // if( !Board::boardExists( inurl ) ) return NULL;
- QRegExp threadcheck( "\\d+.(dat|cgi)" );
- if( inurl.filename().find( threadcheck ) == -1 ) return NULL;
-
- /* search */
- if ( m_datInfo.count() ) {
- for ( it = m_datInfo.begin(); it != m_datInfo.end(); ++it, i++ ) {
-
- datInfo = ( *it );
-
- if ( inurl == datInfo->url() ) {
-
- /* LRU */
- if ( i ) {
- m_datInfo.remove( it );
- m_datInfo.prepend( datInfo );
- }
-
- return datInfo;
- }
- }
- }
-
- /* not found */
-
- /*create new DatInfo and insert it into list. */
- KURL daturl;
- if ( url.host().contains( "machi.to" ) ) {
- daturl = url;
- } else {
- daturl = url.protocol() + "://" + url.host() + url.path();
- }
-
- datInfo = new DatInfo( daturl );
- if ( datInfo->getRawDat() == QString::null ) { /* cache does not exist */
- delete( datInfo );
-
- return NULL;
- }
-
- m_datInfo.prepend( datInfo );
-
- /* delete the last items of list */
- if ( m_datInfo.count() > DMANAGER_MAXQUEUE ) {
-
- /* collect unlocked datInfos */
- typedef QValueList<KURL> DELETELIST;
- DELETELIST deleteList;
-
- for ( it = m_datInfo.at( DMANAGER_MAXQUEUE ); it != m_datInfo.end(); ++it )
- if ( ! ( *it ) ->isLocked() ) deleteList += ( *it ) ->url();