Ejemplo n.º 1
0
void KNNntpClient::doFetchArticle()
{
    KNRemoteArticle *target = static_cast<KNRemoteArticle *>(job->data());
    QCString cmd;

    sendSignal(TSdownloadArticle);
    errorPrefix = i18n("Article could not be retrieved.\nThe following error occurred:\n");

    progressValue = 100;
    predictedLines = target->lines()->numberOfLines() + 10;

    if(target->collection())
    {
        QString groupName = static_cast<KNGroup *>(target->collection())->groupname();
        if(currentGroup != groupName)
        {
            cmd = "GROUP ";
            cmd += groupName.utf8();
            if(!sendCommandWCheck(cmd, 211))       // 211 n f l s group selected
                return;
            currentGroup = groupName;
        }
    }

    if(target->articleNumber() != -1)
    {
        cmd.setNum(target->articleNumber());
        cmd.prepend("ARTICLE ");
    }
    else
    {
        cmd = "ARTICLE " + target->messageID()->as7BitString(false);
    }

    if(!sendCommandWCheck(cmd, 220))        // 220 n <a> article retrieved - head and body follow
    {
        int code = atoi(getCurrentLine());
        if(code == 430 || code == 423)      // 430 no such article found || 423 no such article number in this group
        {
            QString msgId = target->messageID()->as7BitString(false);
            // strip of '<' and '>'
            msgId = msgId.mid(1, msgId.length() - 2);
            job->setErrorString(errorPrefix + getCurrentLine() +
                                i18n("<br><br>The article you requested is not available on your news server."
                                     "<br>You could try to get it from <a href=\"http://groups.google.com/groups?selm=%1\">groups.google.com</a>.")
                                .arg(msgId));
        }
        return;
    }

    QStrList msg;
    if(!getMsg(msg))
        return;

    progressValue = 1000;
    sendSignal(TSprogressUpdate);

    target->setContent(&msg);
    target->parse();
}
void KNArticleManager::processJob(KNJobData *j)
{
  if(j->type()==KNJobData::JTfetchArticle && !j->canceled()) {
    KNRemoteArticle *a = static_cast<KNRemoteArticle*>( j->data() );
    if(j->success()) {
      ArticleWidget::articleChanged( a );
      if(!a->isOrphant()) //orphant articles are deleted by the displaying widget
        knGlobals.memoryManager()->updateCacheEntry(a);
      if(a->listItem())
        a->updateListItem();
    } else {
      if ( j->error() == KIO::ERR_DOES_NOT_EXIST ) {
        // article is not available at the server anymore
        QString msgId = a->messageID()->as7BitString( false );
        // strip of '<' and '>'
        msgId = msgId.mid( 1, msgId.length() - 2 );
        ArticleWidget::articleLoadError( a,
            i18n("The article you requested is not available on your news server."
            "<br />You could try to get it from <a href=\"http://groups.google.com/groups?selm=%1\">groups.google.com</a>.",
              msgId ) );
        // mark article as read
        if ( knGlobals.settings()->autoMark() && !a->isOrphant() ) {
          KNRemoteArticle::List l;
          l.append( a );
          setRead( l, true );
        }
      } else
        ArticleWidget::articleLoadError( a, j->errorString() );
    }
  }

  delete j;
}
Ejemplo n.º 3
0
void KNNntpClient::doFetchSource()
{
    KNRemoteArticle *target = static_cast<KNRemoteArticle *>(job->data());

    sendSignal(TSdownloadArticle);
    errorPrefix = i18n("Article could not be retrieved.\nThe following error occurred:\n");

    progressValue = 100;
    predictedLines = target->lines()->numberOfLines() + 10;

    QCString cmd = "ARTICLE " + target->messageID()->as7BitString(false);
    if(!sendCommandWCheck(cmd, 220))      // 220 n <a> article retrieved - head and body follow
        return;

    QStrList msg;
    if(!getMsg(msg))
        return;

    progressValue = 1000;
    sendSignal(TSprogressUpdate);

    target->setContent(&msg);
}