Пример #1
0
void BookCopy::Update()
{
    if (status_ == BookStatus::LENT)
    {
        NotifyOverdueIfNeeded();
    }
    else if (status_ == BookStatus::AT_LOAN_DESK)
    {
        bool need_nodify = false;
        std::time_t today = Today();

        while (std::difftime(today, due_date_) > 0.0)
        {
            // another one missed the book
            request_queue_.erase(request_queue_.begin());
            if (request_queue_.empty())
            {
                // all the people missed the book
                status_ = BookStatus::ON_SHELF;
                return;
            }
            else  // move to next person
            {
                need_nodify = true;
                due_date_ = nDaysLater(due_date_, kReserveDays);
            }
        }
        // nodify the new person
        NotifyRequest();
    }
}
void NfcSettingsPrivate::InitializeNfcFeatureSupport()
    {
    TBool nfcAvailable = EFalse;
    TRAPD(error, nfcAvailable = CFeatureDiscovery::IsFeatureSupportedL(KFeatureIdNfc));

    if ( nfcAvailable )
        {
        iNfcFeature = NfcSettings::NfcFeatureSupported;

        if ( !iRepository )
            {
            TRAP( error, iRepository = CRepository::NewL(KNfcCentralRepositoryUid) );
            }

        if ( error == KErrNone )
            {
            Cancel();
            NotifyRequest();
            }
        else
            {
            ReportError( NfcSettings::NfcErrorModeRetrieval, error );
            }
        }
    else if ( ProductSupportsNfcViaFirmwareUpdate() )
        {
        iNfcFeature = NfcSettings::NfcFeatureSupportedViaFirmwareUpdate;
        }
    }
void NfcSettingsPrivate::RunL()
    {
    const TInt status( iStatus.Int() );

    User::LeaveIfError( status );

    // A successfully completed CRepository::NotifyRequest() will set the key
    // of the modified repository value as the TRequestStatus value. As the
    // repository key is a TUint32, it is explicitly converted to a TInt
    // to compare it to the TInt status value. This supresses a GCCE compilation
    // warning. The value of KNfcModeSetting is 0x01, so it can be safely
    // converted to a TInt without any loss of information.
    if ( status == TInt(KNfcModeSetting) )
        {
        NotifyRequest();
        }
    }
Пример #4
0
bool BookCopy::Return(User *user)
{
    if (status_ != BookStatus::LENT)
    {
        std::cout << "只能还回被借出的馆藏\n";
        return false;
    }

    if (!(user->Return(id_)))  // error info will be printed inside
        return false;

    // returned
    if (request_queue_.empty())  // no one is waiting
    {
        status_ = BookStatus::ON_SHELF;
    }
    else  // sb. has requested
    {
        status_ = BookStatus::AT_LOAN_DESK;
        due_date_ = nDaysLater(kReserveDays);
        NotifyRequest();
    }
    return true;
}