Ejemplo n.º 1
0
void GPDDownloader::onRequestFinished(int /* id */, bool error)
{
    if (error)
        return;
    else if (http->bytesAvailable() < 1)
        return;

    QString tempPath = QDir::tempPath() + "/" + QUuid::createUuid().toString().replace("{", "").replace("}", "").replace("-", "");

    if (!gpdWritten)
    {
        gameGPD = tempPath;

        // create a new temporary file
        QFile v1File(tempPath);
        v1File.open(QFile::Truncate | QFile::WriteOnly);

        // write the gpd to disk
        v1File.write(http->readAll());

        // clean up
        v1File.flush();
        v1File.close();

        gpdWritten = true;
    }
    else
    {
        awardGPD = tempPath;

        // create a new temporary file
        QFile v1File(tempPath);
        v1File.open(QFile::Truncate | QFile::WriteOnly);

        // write the gpd to disk
        v1File.write(http->readAll());

        // clean up
        v1File.flush();
        v1File.close();
    }

    if (hasAwards)
    {
        hasAwards = false;
        http->get(gpdDirectory + "award/" + QString::number(entry.titleID, 16).toUpper() + ".gpd");
    }
}
Ejemplo n.º 2
0
void AvatarAssetDownloader::onRequestFinished(QNetworkReply *aReply)
{
    if (aReply->error() != QNetworkReply::NoError)
    {
        qDebug() << "error: " << aReply->errorString();
        return;
    }

    // verify that the file was downloaded
    DWORD fileSize = aReply->bytesAvailable();

    // all assets have a Ytgr header that's 0x140 bytes
    if (fileSize < 0x140)
    {
        if (!v2Done)
        {
            v1Done = true;
            v2Done = true;
            v1TempPath = "";
            manager->get(QNetworkRequest(QUrl("http://download.xboxlive.com/content/" + titleID +
                    "/avataritems/v2/" + guid + ".bin")));
        }
        else
            v2TempPath = "";
        return;
    }

    // read the crap away, we don't need it
    BYTE temp[0x140];
    aReply->read((char*)temp, 0x140);

    QString tempPath = QDir::tempPath() + "/" + QUuid::createUuid().toString().replace("{",
            "").replace("}", "").replace("-", "");
    if (!v1Done)
        v1TempPath = tempPath;
    else
        v2TempPath = tempPath;

    // create a new temporary file
    QFile v1File(tempPath);
    v1File.open(QFile::Truncate | QFile::WriteOnly);
    // Write the STRB file to the local disk
    v1File.write(aReply->readAll());

    // clean up
    v1File.flush();
    v1File.close();

    v1Done = true;

    // download the v2 file
    if (!v2Done)
    {
        v2Done = true;
        manager->get(QNetworkRequest(QUrl("http://download.xboxlive.com/content/" + titleID +
                "/avataritems/v2/" + guid + ".bin")));
    }
    else
        emit FinishedDownloading();
}