bool LLMediaEntry::checkCandidateUrl(const std::string& url) const
{
    if (getWhiteListEnable()) 
    {
        return checkUrlAgainstWhitelist(url, getWhiteList());
    }
    else 
	{
        return true;
    }
}
void CCardFilterParameters::updateSettings(QSettings &settings) const
{
    settings.beginGroup("filterOptions");

    settings.setValue("allowAssaultsLegendary", mIsAssaultAllowed[0]);
    settings.setValue("allowAssaultsRare", mIsAssaultAllowed[1]);
    settings.setValue("allowAssaultsUncommon", mIsAssaultAllowed[2]);
    settings.setValue("allowAssaultsCommon", mIsAssaultAllowed[3]);

    settings.setValue("allowStructuresLegendary", mIsStructureAllowed[0]);
    settings.setValue("allowStructuresRare", mIsStructureAllowed[1]);
    settings.setValue("allowStructuresUncommon", mIsStructureAllowed[2]);
    settings.setValue("allowStructuresCommon", mIsStructureAllowed[3]);

    settings.setValue("allowCommandersLegendary", mIsCommanderAllowed[0]);
    settings.setValue("allowCommandersRare", mIsCommanderAllowed[1]);
    settings.setValue("allowCommandersUncommon", mIsCommanderAllowed[2]);
    settings.setValue("allowCommandersCommon", mIsCommanderAllowed[3]);

    settings.setValue("allowActionsLegendary", mIsActionAllowed[0]);
    settings.setValue("allowActionsRare", mIsActionAllowed[1]);
    settings.setValue("allowActionsUncommon", mIsActionAllowed[2]);
    settings.setValue("allowActionsCommon", mIsActionAllowed[3]);

    settings.setValue("allowHealth1", mIsHealthAllowed[0]);
    settings.setValue("allowHealth2", mIsHealthAllowed[1]);
    settings.setValue("allowHealth3", mIsHealthAllowed[2]);
    settings.setValue("allowHealth4", mIsHealthAllowed[3]);
    settings.setValue("allowHealth5", mIsHealthAllowed[4]);

    settings.setValue("allowAttack0", mIsAttackAllowed[0]);
    settings.setValue("allowAttack1", mIsAttackAllowed[1]);
    settings.setValue("allowAttack2", mIsAttackAllowed[2]);
    settings.setValue("allowAttack3", mIsAttackAllowed[3]);
    settings.setValue("allowAttack4", mIsAttackAllowed[4]);

    settings.setValue("allowDelay0", mIsDelayAllowed[0]);
    settings.setValue("allowDelay1", mIsDelayAllowed[1]);
    settings.setValue("allowDelay2", mIsDelayAllowed[2]);
    settings.setValue("allowDelay3", mIsDelayAllowed[3]);
    settings.setValue("allowDelay4", mIsDelayAllowed[4]);

    settings.setValue("allowFactionBloodthirsty", mIsFactionAllowed[0]);
    settings.setValue("allowFactionImperial", mIsFactionAllowed[1]);
    settings.setValue("allowFactionRaider", mIsFactionAllowed[2]);
    settings.setValue("allowFactionRighteous", mIsFactionAllowed[3]);
    settings.setValue("allowFactionXeno", mIsFactionAllowed[4]);


    QStringList whiteList;
    getWhiteList(whiteList);
    settings.setValue("whiteList", whiteList);

    QStringList blackList;
    getBlackList(blackList);
    settings.setValue("blackList", blackList);

    settings.setValue("standardSetComplement", mComplement[0]);
    settings.setValue("enclaveSetComplement", mComplement[1]);
    settings.setValue("nexusSetComplement", mComplement[2]);
    settings.setValue("blightSetComplement", mComplement[3]);
    settings.setValue("puritySetComplement", mComplement[4]);
    settings.setValue("homeworldSetComplement", mComplement[5]);
    settings.setValue("phobosSetComplement", mComplement[6]);
    settings.setValue("phobosAfermathSetComplement", mComplement[7]);
    settings.setValue("awakeningSetComplement", mComplement[8]);
    settings.setValue("terminusSetComplement", mComplement[9]);
    settings.setValue("occupationSetComplement", mComplement[10]);
    settings.setValue("worldshipSetComplement", mComplement[11]);
    settings.setValue("flashpointSetComplement", mComplement[12]);
    settings.setValue("rewardSetComplement", mComplement[13]);
    settings.setValue("promotionalSetComplement", mComplement[14]);
    settings.setValue("upgradedSetComplement", mComplement[15]);

    settings.setValue("isFilterOptionEnabled", mIsFilterOptionEnabled);
    settings.setValue("isAssaultOptionEnabled", mIsAssaultOptionEnabled);
    settings.setValue("isWhiteListEnabled", mIsWhiteListEnabled);
    settings.setValue("isBlackListEnabled", mIsBlackListEnabled);
    settings.setValue("isBlockListEnabled", mIsBlockListEnabled);
    settings.setValue("isCompletionEnabled", mIsCompletionEnabled);

    settings.endGroup();
}
void CCardFilterParameters::updateUi(Ui::CardFilterWidget &ui) const
{
    ui.assaultLegendaryBox->setChecked(mIsAssaultAllowed[0]);
    ui.assaultRareBox->setChecked(mIsAssaultAllowed[1]);
    ui.assaultUncommonBox->setChecked(mIsAssaultAllowed[2]);
    ui.assaultCommonBox->setChecked(mIsAssaultAllowed[3]);

    ui.structureLegendaryBox->setChecked(mIsStructureAllowed[0]);
    ui.structureRareBox->setChecked(mIsStructureAllowed[1]);
    ui.structureUncommonBox->setChecked(mIsStructureAllowed[2]);
    ui.structureCommonBox->setChecked(mIsStructureAllowed[3]);

    ui.commanderLegendaryBox->setChecked(mIsCommanderAllowed[0]);
    ui.commanderRareBox->setChecked(mIsCommanderAllowed[1]);
    ui.commanderUncommonBox->setChecked(mIsCommanderAllowed[2]);
    ui.commanderCommonBox->setChecked(mIsCommanderAllowed[3]);

    ui.actionLegendaryBox->setChecked(mIsActionAllowed[0]);
    ui.actionRareBox->setChecked(mIsActionAllowed[1]);
    ui.actionUncommonBox->setChecked(mIsActionAllowed[2]);
    ui.actionCommonBox->setChecked(mIsActionAllowed[3]);

    ui.health1Box->setChecked(mIsHealthAllowed[0]);
    ui.health2Box->setChecked(mIsHealthAllowed[1]);
    ui.health3Box->setChecked(mIsHealthAllowed[2]);
    ui.health4Box->setChecked(mIsHealthAllowed[3]);
    ui.health5Box->setChecked(mIsHealthAllowed[4]);

    ui.attack0Box->setChecked(mIsAttackAllowed[0]);
    ui.attack1Box->setChecked(mIsAttackAllowed[1]);
    ui.attack2Box->setChecked(mIsAttackAllowed[2]);
    ui.attack3Box->setChecked(mIsAttackAllowed[3]);
    ui.attack4Box->setChecked(mIsAttackAllowed[4]);

    ui.delay0Box->setChecked(mIsDelayAllowed[0]);
    ui.delay1Box->setChecked(mIsDelayAllowed[1]);
    ui.delay2Box->setChecked(mIsDelayAllowed[2]);
    ui.delay3Box->setChecked(mIsDelayAllowed[3]);
    ui.delay4Box->setChecked(mIsDelayAllowed[4]);

    ui.factionBloodthirstyBox->setChecked(mIsFactionAllowed[0]);
    ui.factionImperialBox->setChecked(mIsFactionAllowed[1]);
    ui.factionRaiderBox->setChecked(mIsFactionAllowed[2]);
    ui.factionRighteousBox->setChecked(mIsFactionAllowed[3]);
    ui.factionXenoBox->setChecked(mIsFactionAllowed[4]);

    QStringList whiteList;
    getWhiteList(whiteList);
    whiteList.sort();
    ui.whiteListEdit->setPlainText(whiteList.join("\n"));

    QStringList blackList;
    getBlackList(blackList);
    blackList.sort();
    ui.blackListEdit->setPlainText(blackList.join("\n"));

    QStringList blockList;
    for(QHash<QString, int>::const_iterator i = mBlockList.begin(); i != mBlockList.end(); ++i)
    {
        QString curCard = listedCardToStr(TListedCard(i.key(), i.value()));
        if (!curCard.isEmpty())
        {
            blockList.push_back(curCard);
        }
    }
    blockList.sort();
    ui.blockListEdit->setPlainText(blockList.join("\n"));

    ui.standardSpinBox->setValue(mComplement[0]);
    ui.enclaveSpinBox->setValue(mComplement[1]);
    ui.nexusSpinBox->setValue(mComplement[2]);
    ui.blightSpinBox->setValue(mComplement[3]);
    ui.puritySpinBox->setValue(mComplement[4]);
    ui.homeWorldSpinBox->setValue(mComplement[5]);
    ui.phobosSpinBox->setValue(mComplement[6]);
    ui.phobosAfterMathSpinBox->setValue(mComplement[7]);
    ui.awakeningSpinBox->setValue(mComplement[8]);
    ui.terminusSpinBox->setValue(mComplement[9]);
    ui.occupationSpinBox->setValue(mComplement[10]);
    ui.worldShipSpinBox->setValue(mComplement[11]);
    ui.flashPointSpinBox->setValue(mComplement[12]);
    ui.rewardSpinBox->setValue(mComplement[13]);
    ui.promotionalSpinBox->setValue(mComplement[14]);
    ui.upgradedSpinBox->setValue(mComplement[15]);

    ui.filterOptionsBox->setChecked(mIsFilterOptionEnabled);
    ui.assaultOptionsBox->setChecked(mIsAssaultOptionEnabled);
    ui.whiteListBox->setChecked(mIsWhiteListEnabled);
    ui.blackListBox->setChecked(mIsBlackListEnabled);
    ui.blockListBox->setChecked(mIsBlockListEnabled);
    ui.complementsBox->setChecked(mIsCompletionEnabled);
}
Beispiel #4
0
  int
  CCollector::Reclamation ()
  {
    ObjectList lstDestructed;                                           // destructed object list

    // step 401 - determine unreachable objects
    do for (ObjectList::Iterator iter (getWhiteList ()); iter;)
        {
          CPouch *pPouch = iter;
          iter.next ();

          if (pPouch->isDestructed ())
            {
              getWhiteList ().remove (pPouch);
              lstDestructed.pushTail (pPouch);
            }
          else
            {
              pPouch->getFlags ()->bitwiseOR (F_UNREACHABLE);
            }
        }
    while (0);

    // step 402 - invoke OnReclaim routine of all unreachable objects
    bool bResurr = false;
    do for (ObjectList::Iterator iter (getWhiteList ()); iter; iter.next ())
        {
          CPouch *pPouch = iter;
          CDeclarator dcl (&bResurr, pPouch, pPouch);

          pPouch->onreclaim (&dcl);                             // call OnReclaim routine for
          // each unreachable object to give them a chance to resurrect.
        }
    while (0);

    if (bResurr)
      {
        // 1. clear the D-List
        CDependence *pRec;
        while ((pRec = m_lstDependences.popNode ()) != 0)
          {
            delete pRec;
          }

        // 2. unmark unreachabe objects
        do for (ObjectList::Iterator iter (getWhiteList ()); iter; iter.next ())
            {
              CPouch *pPouch = iter;
              pPouch->getFlags ()->bitwiseAND (~F_UNREACHABLE);
            }
        while (0);

        // 3. move back destructed objecs
        getWhiteList ().pushTail (lstDestructed);

        // return back and continue traversal again.
        return 1;
      }

    // note - From now, unreachable objects can be dropped to ZRC or/and
    // be explicitly destructed.

    ObjectList lstStandby;                                              // objects that is depended by others
    ObjectList *pDestructing = &getWhiteList ();
    ObjectList *pStandby = &lstStandby;
    uint_flags nColorDestructing = 0;                           // identify Q-Destructing or Q-Standby
    for (;;)
      {
        // note - Q-Standby is empty at beginning for every loop

        // step 403 - scan D-List
        do for (DRecList::Iterator iter (m_lstDependences); iter;)
            {
              CPouch *pDepender = iter->m_pDepender;
              // note - D-List records have been limited to among unreachable
              // objects, others are discarded in CCollector::OnReclaimDeclare.

              if (pDepender->isDestructed ())
                {
                  CDependence *pRec = iter;
                  iter.remove ();
                  delete pRec;
                  continue;
                }

              // move dependee from Q-Destructing to Q-Standby
              CPouch *pDependee = iter->m_pDependee;
              if (pDependee->getFlags ()->bitwiseCompareExchange (
                    F_DEPENDENCE, nColorDestructing,
                    F_DEPENDENCE & (~nColorDestructing)
                    ) == nColorDestructing)
                {
                  // this ensures a dependee would only move once from
                  // Q-Destructing to Q-Standby
                  pDestructing->remove (pDependee);
                  pStandby->pushTail (pDependee);
                }

              iter.next ();
            }
        while (0);

        // step 404 - check Q-Destructing
        if (pDestructing->isEmpty ())
          {
            // No destruction can be taken, no depender will vanish
            break;
          }

        // step 405 - destructing objects in Q-Destructing
        CPouch *pPouch;
        while ((pPouch = pDestructing->popHead ()) != 0)
          {
            // previous nesting HandleZRC function may have destructed the object
            DestructObject (pPouch);
            lstDestructed.pushTail (pPouch);
          }

        // step 407 - remove records in D-List that the depender of the
        // record has been destructed. (emerged into step 403)

        // step 408 - switch Q-Destructing and Q-Standby
        ObjectList *pTemp = pDestructing;
        pDestructing = pStandby;
        pStandby = pTemp;
        nColorDestructing = F_DEPENDENCE & ~nColorDestructing;
      }           // loop back D-List scanning

    //
    // Destructions of objects have done
    //
    if (!pStandby->isEmpty ())
      {
        // circular-depended relationship found! all objects are moved
        // from Q-Destructing to Q-Standby.

        // 1. clear D-List
        do for (DRecList::Iterator iter (m_lstDependences); iter;)
            {
              CDependence *pRec = iter;
              iter.remove ();
              delete pRec;
            }
        while (0);

        // 2. TODO: log these circular-depended objects

        // 3. skip app-level reclamation of Q-Standby objects.
        lstDestructed.pushTail (*pStandby);
      }

    // step 406 - System-level reclamation
    //	all unreachable objects are destructed (or skipped for the reason of
    //	circular depending relationship), there is neither live objects nor
    //  any destructor refering them.
    CPouch *pPouch;
    while ((pPouch = lstDestructed.popHead ()) != 0)
      {
        // RC should be zero, but cannot guaranteed for some bad-behavor
        // application does not drop reference at destruction, or existing
        // some circular-depended objects.

        // ASSERT(pPouch->getLECount()->isZero());

        pPouch->destroy ();
      }

    // By now, Q-Destructed, Q-Destructing, D-List, Q-Standby should be empty
    ASSERT (pDestructing->isEmpty ());
    ASSERT (pStandby->isEmpty ());
    ASSERT (lstDestructed.isEmpty ());
    ASSERT (m_lstDependences.isEmpty ());
    return 0;
  }