Beispiel #1
0
/**
 * get quota data for a single ID
 *
 * @param id the user or group ID to check
 * @param type the type of the ID user or group, enum QuotaDataType
 * @param blockDevices the QuotaBlockDevice to check
 * @param outQuotaDataList the return list with the quota data
 * @param session a session for all required lib handles if zfs is used, it can be an uninitialized
 *        session, the initialization can be done by this function
 *
 * @return false on error (in which case outData is empty)
 */
bool QuotaTk::requestQuotaForID(unsigned id, QuotaDataType type, QuotaBlockDeviceMap* blockDevices,
   QuotaDataList* outQuotaDataList, ZfsSession* session)
{
   QuotaData data(id, type);
   bool retVal = checkQuota(blockDevices, &data, session);

   if(retVal && (data.getSize() != 0 || data.getInodes() != 0) )
      outQuotaDataList->push_back(data);

   return retVal;
}
void NetworkUpdater::update()
{
    auto dateTime = QDateTime::currentDateTimeUtc();

    if (firstUpdate)
    {
        emptyCurrentData();
    }

    if (!firstUpdate && dateTime != lastUpdate)
    {
        InterfaceData::iterator i;
        for (i = currentData.begin(); i != currentData.end(); ++i)
        {
            TransferTypeData::iterator j;
            for (j = i.value().begin(); j != i.value().end(); ++j)
            {
                storage->addData(dateTime, j.key(), j.value(), i.key());
            }
        }
        snapshots.push_front(DataSnapshot(dateTime, currentData));

        auto old = engine->rootContext()->contextProperty("hourlyModel");
        engine->rootContext()->setContextProperty("hourlyModel", 0);
        engine->rootContext()->setContextProperty("hourlyModel", old);

        if (!firstUpdate)
        {
            auto quota = checkQuota();
            if (quota != lastQuota)
            {
                auto quotaStatus = parent()->findChild<QQuickItem*>("quotaStatus");
                QString text;
                if (quota)
                {
                    text = "Status: Quota exceeded!";
                }
                else
                {
                    text = "Status: Ok";
                }
                quotaStatus->setProperty("text", text);
            }
            if (quota != lastQuota && quota)
            {
                qDebug() << "Quota exceeded!";

                QMessageBox::critical(0, "Quota", "Quota exceeded!", QMessageBox::Ok);
            }
            lastQuota = quota;
        }

        refreshUI();

        emptyCurrentData();
    }

    currentRawData = getCurrentRawData();

    if (!firstUpdate)
    {
        addDifferenceToCurrentData();
    }

    lastRawData = currentRawData;

    firstUpdate = false;
    lastUpdate = dateTime;
}