示例#1
0
void check(JobInfoPtr info)
{
  if(info->isSuccess())
    cout << "SUCCESS: " << info->getMessage() << " prog=" << info->getCurrent()
         << "/" << info->getTotal() << endl;
  else
    cout << "FAILURE: " << info->getMessage() << endl;
}
示例#2
0
void testStatus(Job &j)
{
  JobInfoPtr info = j.getInfo();

  if(info->isBusy()) cout << "Busy!";
  else if(!info->hasStarted()) cout << "Not started yet!";
  else if(info->isSuccess()) cout << "Success!";
  else if(info->isError()) cout << "Failure: " << info->getMessage();
  else if(info->isAbort()) cout << "Abort!";
  cout << "  - progress " << info->getCurrent() << "/" << info->getTotal() << endl;
}
示例#3
0
void StatusNotifier::tick()
{
    // If the data pointer hasn't been set yet, we aren't ready to do
    // anything. So just exit.
    if(!data) return;

    // Check if we're updating the entire dataset first
    if(updateJob && updateJob->isFinished())
    {
        if(updateJob->isSuccess())
        {
            PRINT("Update job successful");
            data->updateReady();
        }
        else
        {
            /* TODO: If the job failed, but the base Spread update
               succeeded, then the update will not be attempted again
               until the next release. This means we might be sitting on
               a partially updated repo and it won't be fixed.
             */

            PRINT("Update job FAILED: " << updateJob->getMessage());
        }

        updateJob.reset();
    }

    // How much do we need to update
    bool soft = false;
    bool hard = false;

    WatchList::iterator it, itold;
    for(it = watchList.begin(); it != watchList.end();)
    {
        // If there are any elements being installed at all, always
        // update the displays.
        soft = true;

        // Increase the iterator, since we might erase it from the
        // list below, invalidating the current position.
        itold = it++;

        // Get the GameInf pointer
        GameInf* inf = getFromId(data->repo, itold->first);
        if(!inf) continue;

        // Get the stored job
        JobInfoPtr job = itold->second;

        // Check that we have the right job attached
        assert(job == inf->info.getStatus());

        // If we are no longer working, update main status and remove
        // ourselves from the list
        if(job->isFinished())
        {
            watchList.erase(itold);
            hard = true;

            // Report errors to the user
            if(job->isError())
                Boxes::error(job->getMessage());
        }

        // Update the object status
        inf->updateStatus();
    }

    /* A 'hard' update means totally refresh the 'installed' list, and
       tell all tabs to update game data - screenshot, button
       information etc - in case the currently selected game has changed
       status.
    */
    if(hard)
        statusChanged();

    /* A 'soft' update just refreshes the list views. It's only meant to
       update the percentages when downloading/installing.
     */
    else if(soft)
        data->updateDisplayStatus();
}