Exemplo n.º 1
0
void QgsCollapsibleGroupBox::loadState()
{
  if ( !isEnabled() || ( !mSaveCollapsedState && !mSaveCheckedState ) )
    return;

  setUpdatesEnabled( false );

  QSettings settings;
  QString key = saveKey();
  QVariant val;
  if ( mSaveCheckedState )
  {
    val = settings.value( key + "/checked" );
    if ( ! val.isNull() )
      setChecked( val.toBool() );
  }
  if ( mSaveCollapsedState )
  {
    val = settings.value( key + "/collapsed" );
    if ( ! val.isNull() )
      setCollapsed( val.toBool() );
  }

  setUpdatesEnabled( true );
}
bool CCDictionarySaver::saveDictionary(CCDictionary* pDict, xmlNodePtr node)
{
    do
    {
        xmlNodePtr dict_node = xmlNewNode(NULL, DICT_NODE_DICT);
        CC_BREAK_IF(!dict_node);
        
        CC_BREAK_IF(!xmlAddChild(node, dict_node));
        
        CCDictElement* pElem;
        CCDICT_FOREACH(pDict, pElem)
        {
            saveKey(pElem->getStrKey(), dict_node);
            
            CCObject* obj = pElem->getObject();

            if (dynamic_cast<CCString*>(obj))
            {
                CCString* s = dynamic_cast<CCString*>(obj);
                CC_BREAK_IF(!saveString(s->getCString(), dict_node));
            }
            else if (dynamic_cast<CCDictionary*>(obj))
            {
                CC_BREAK_IF(!saveDictionary(dynamic_cast<CCDictionary*>(obj), dict_node));
            }
            else if (dynamic_cast<CCArray*>(obj))
            {
                CC_BREAK_IF(!saveArray(dynamic_cast<CCArray*>(obj), dict_node));
            }
        }
        return true;
    } while (false);
Exemplo n.º 3
0
void SmartMote::config(){
    AString conf;
    AStringList * param = NULL;
    bool flag;
    /*  se il bottone non è premuto                                             */
    if(!checkButton()){
        /*  ritorno                                                             */
        return;
    }
    /*  accendo l'uart                                                          */
    openUART();
    /*  inizializzo il modulo come AP                                           */
    if(!m_net.initialize(AESP07::APMode)){
        /*  se fallisce notifico l'errore                                       */
        error();
    }
    /*  setto il nome come SmartMote e password admin                           */
    if(!m_net.configureAP("SmartMote", "smartmote")){
        /*  se fallisce notifico l'errore                                       */
        error();        
    }
    /*  imposto l'ip a 192.168.1.1                                              */
    if(!m_net.setIp(AESP07::APMode, "192.168.1.1")){
        /*  se fallisce notifico l'errore                                       */
        error();        
    }
    /*  disabilito le connessioni multiple                                      */
    if(!m_net.setMultipleConnections(false)){
        /*  se fallisce notifico l'errore                                       */
        error();                
    }
    /*  apro il server sulla porta 8000                                         */
    if(!m_net.listen(8000)){
        /*  se fallisce notifico l'errore                                       */
        error();
    }
    /*  aspetto di ricevere la stringa                                          */
    while(conf.isEmpty()){
        
        m_net.waitForData(conf);
    }
    /*  prendo i parametri                                                      */
    param = conf.split(' ');
    /*  se la stringlist è allocata correttamente                               */
    if(param){
        saveSSID(param->at(0));
        saveKey(param->at(1));
        saveHost(param->at(2));
        RTCC.setHours(static_cast<uint32>(param->at(3).toInt32(flag)));
        RTCC.setMinutes(static_cast<uint32>(param->at(3).toInt32(flag)));
        RTCC.setSeconds(static_cast<uint32>(param->at(3).toInt32(flag)));
    }else{
        /*  altrimenti notifico l'errore                                        */
        error();
    }
    /*  spengo i led                                                            */
    turnOffRed();
    turnOffGreen();
}
void QgsCollapsibleGroupBox::saveState()
{
  if ( ! mSaveState )
    return;
  QSettings settings;
  QString key = saveKey();
  settings.setValue( key + "/checked", isChecked() );
  settings.setValue( key + "/collapsed", isCollapsed() );
}
Exemplo n.º 5
0
void
BackEndFile::doImportKey(const Name& keyName, const uint8_t* buf, size_t size, const char* pw, size_t pwLen)
{
  try {
    auto key = make_shared<PrivateKey>();
    key->loadPkcs8(buf, size, pw, pwLen);
    saveKey(keyName, key);
  }
  catch (const PrivateKey::Error&) {
    BOOST_THROW_EXCEPTION(Error("Cannot import private key"));
  }
}
Exemplo n.º 6
0
void QgsCollapsibleGroupBox::saveState()
{
  if ( !isEnabled() || ( !mSaveCollapsedState && !mSaveCheckedState ) )
    return;

  QSettings settings;
  QString key = saveKey();

  if ( mSaveCheckedState )
    settings.setValue( key + "/checked", isChecked() );
  if ( mSaveCollapsedState )
    settings.setValue( key + "/collapsed", isCollapsed() );
}
Exemplo n.º 7
0
		dht::Key loadKey(const QString & key_file)
		{
			bt::File fptr;
			if (!fptr.open(key_file, "rb"))
			{
				Out(SYS_DHT | LOG_IMPORTANT) << "DHT: Cannot open file " << key_file << " : " << fptr.errorString() << endl;
				dht::Key r = dht::Key::random();
				saveKey(r, key_file);
				new_key = true;
				return r;
			}
			
			Uint8 data[20];
			if (fptr.read(data, 20) != 20)
			{
				dht::Key r = dht::Key::random();
				saveKey(r, key_file);
				new_key = true;
				return r;
			}
			
			new_key = false;
			return dht::Key(data);
		}
Exemplo n.º 8
0
unique_ptr<KeyHandle>
BackEndFile::doCreateKey(const Name& identityName, const KeyParams& params)
{
  shared_ptr<PrivateKey> key(transform::generatePrivateKey(params).release());
  unique_ptr<KeyHandle> keyHandle = make_unique<KeyHandleMem>(key);

  setKeyName(*keyHandle, identityName, params);

  try {
    saveKey(keyHandle->getKeyName(), key);
    return keyHandle;
  }
  catch (const std::runtime_error& e) {
    BOOST_THROW_EXCEPTION(Error(std::string("Cannot write key to disk: ") + e.what()));
  }
}