void KNArticleManager::rescoreArticles(KNRemoteArticle::List &l) { if ( l.isEmpty() ) return; KNGroup *g = static_cast<KNGroup*>( l.first()->collection() ); KScoringManager *sm = knGlobals.scoringManager(); sm->initCache(g->groupname()); for ( KNRemoteArticle::List::Iterator it = l.begin(); it != l.end(); ++it ) { int defScore = 0; if ( (*it)->isIgnored()) defScore = knGlobals.settings()->ignoredThreshold(); else if ( (*it)->isWatched() ) defScore = knGlobals.settings()->watchedThreshold(); (*it)->setScore(defScore); bool read = (*it)->isRead(); KNScorableArticle sa( (*it) ); sm->applyRules(sa); (*it)->updateListItem(); (*it)->setChanged( true ); if ( !read && (*it)->isRead() != read ) g_roup->incReadCount(); } }
void KNNntpClient::doFetchNewHeaders() { KNGroup *target = static_cast<KNGroup *>(job->data()); char *s; int first = 0, last = 0, oldlast = 0, toFetch = 0, rep = 0; QCString cmd; target->setLastFetchCount(0); sendSignal(TSdownloadNew); errorPrefix = i18n("No new articles could be retrieved for\n%1/%2.\nThe following error occurred:\n") .arg(account.server()).arg(target->groupname()); cmd = "GROUP "; cmd += target->groupname().utf8(); if(!sendCommandWCheck(cmd, 211)) // 211 n f l s group selected { return; } currentGroup = target->groupname(); progressValue = 90; s = strchr(getCurrentLine(), ' '); if(s) { s++; s = strchr(s, ' '); } if(s) { s++; first = atoi(s); target->setFirstNr(first); s = strchr(s, ' '); } if(s) { last = atoi(s); } else { QString tmp = i18n("No new articles could be retrieved.\nThe server sent a malformatted response:\n"); tmp += getCurrentLine(); job->setErrorString(tmp); closeConnection(); return; } if(target->lastNr() == 0) //first fetch { if(first > 0) oldlast = first - 1; else oldlast = first; } else oldlast = target->lastNr(); toFetch = last - oldlast; //qDebug("knode: last %d oldlast %d toFetch %d\n",last,oldlast,toFetch); if(toFetch <= 0) { //qDebug("knode: No new Articles in group\n"); target->setLastNr(last); // don't get stuck when the article numbers wrap return; } if(toFetch > target->maxFetch()) { toFetch = target->maxFetch(); //qDebug("knode: Fetching only %d articles\n",toFetch); } progressValue = 100; predictedLines = toFetch; // get list of additional headers provided by the XOVER command // see RFC 2980 section 2.1.7 QStrList headerformat; cmd = "LIST OVERVIEW.FMT"; if(sendCommand(cmd, rep) && rep == 215) { QStrList tmp; if(getMsg(tmp)) { for(QCString s = tmp.first(); s; s = tmp.next()) { s = s.stripWhiteSpace(); // remove the mandatory xover header if(s == "Subject:" || s == "From:" || s == "Date:" || s == "Message-ID:" || s == "References:" || s == "Bytes:" || s == "Lines:") continue; else headerformat.append(s); } } } //qDebug("knode: KNNntpClient::doFetchNewHeaders() : xover %d-%d", last-toFetch+1, last); cmd.sprintf("xover %d-%d", last - toFetch + 1, last); if(!sendCommand(cmd, rep)) return; // no articles in selected range... if(rep == 420) // 420 No article(s) selected { target->setLastNr(last); return; } else if(rep != 224) // 224 success { handleErrors(); return; } QStrList headers; if(!getMsg(headers)) { return; } progressValue = 1000; sendSignal(TSprogressUpdate); sendSignal(TSsortNew); mutex.lock(); target->insortNewHeaders(&headers, &headerformat, this); target->setLastNr(last); mutex.unlock(); }