Exemple #1
0
    void
  AsyncHTTPLookup::slotQueryReady()
  {
    kDebug(60010) << "Matches Found: " <<  matchList_.count();

    if ( Success != result_ )
    {
      emit finished( result_ );
      return;
    }

    requestCDInfoForMatch();
  }
Exemple #2
0
    Result
  AsyncHTTPLookup::lookup
  (
    const QString         & hostName,
    uint                    port,
    const TrackOffsetList & trackOffsetList
  )
  {
    trackOffsetList_ = trackOffsetList;

    connect( this, SIGNAL(queryReady()), SLOT(slotQueryReady()) );
    connect( this, SIGNAL(readReady()), SLOT(requestCDInfoForMatch()) );

    initURL( hostName, port );

    // Run a query.
    result_ = runQuery();

    return result_;
  }
Exemple #3
0
void
AsyncCDDBPLookup::read()
{
    switch ( state_ )
    {
    case WaitingForGreeting:

        if ( !parseGreeting( readLine() ) )
        {
            result_ = ServerError;
            doQuit();
            return;
        }

        doHandshake();

        break;

    case WaitingForHandshake:

        if ( !parseHandshake( readLine() ) )
        {
            result_ = ServerError;
            doQuit();
            return;
        }

        doProto();

        break;

    case WaitingForProtoResponse:

        // Ignore the response for now
        readLine();

        doQuery();

        break;

    case WaitingForQueryResponse:
        result_ = parseQuery( readLine() );

        switch ( result_ )
        {
        case Success:
            requestCDInfoForMatch();
            break;

        case MultipleRecordFound:
            state_ = WaitingForMoreMatches;
            break;

        default: // Error :(
            doQuit();
            return;
        }

        break;

    case WaitingForMoreMatches:
    {
        QString line = readLine();

        if (line.startsWith(QLatin1String( "." )))
            requestCDInfoForMatch();
        else
            parseExtraMatch( line );
    }

    break;

    case WaitingForCDInfoResponse:
    {
        Result result = parseRead( readLine() );

        if ( Success != result )
        {
            result_ = result;
            doQuit();
            return;
        }

        state_ = WaitingForCDInfoData;
    }

    break;

    case WaitingForCDInfoData:
    {
        QString line = readLine();

        if (line.startsWith(QLatin1String( "." )))
        {
            parseCDInfoData();
            requestCDInfoForMatch();
        }
        else
            cdInfoBuffer_ << line;
    }

    break;

    case WaitingForQuitResponse:

        state_ = Idle;

        char c;
        while ( socket_->bytesAvailable() )
            socket_->getChar(&c);

        close();

        emit finished( result_ );

        break;

    default:

        break;
    }
}