Пример #1
0
ClientConfiguration ClientConfiguration::fromFile(QString const& filename) {
	if (!QFile::exists(filename)) {
		throw IllegalArgumentException() << "Could not open ClientConfiguration file, file does not exist: " << filename.toStdString();
	}
	QFile inputFile(filename);
	if (!inputFile.open(QFile::ReadOnly)) {
		throw IllegalArgumentException() << "Could not open ClientConfiguration file for reading: " << filename.toStdString();
	}
	inputFile.close();

	QSettings clientSettings(filename, QSettings::IniFormat);

	if (!clientSettings.contains("clientIdentityBackupPassword")) {
		throw IllegalArgumentException() << "Invalid ClientConfiguration: Missing clientIdentityBackupPassword in " << filename.toStdString();
	}

	if (!clientSettings.contains("clientIdentityBackupString")) {
		throw IllegalArgumentException() << "Invalid ClientConfiguration: Missing clientIdentityBackupString in " << filename.toStdString();
	}

	QString const backupString(clientSettings.value("clientIdentityBackupString").toString());
	QString const backupPassword(clientSettings.value("clientIdentityBackupPassword").toString());
	BackupData backupData(ClientConfiguration::fromBackup(backupString, backupPassword));

	return ClientConfiguration(backupData.clientIdentity, backupData.clientLongTermKeyPair);
}
Пример #2
0
void autoBackup(menu m)
{
    showMessage("This can take a few minutes depending on how many titles are selected.");


    progressBar autoDump((float)m.getSelectCount(), "Copying saves...");
    //Keep track of what's done
    float dumpCount = 0;
    for(unsigned i = 0; i < m.getSize(); i++)
    {
        //This is for titles with no save archive ex. Fantasy Life
        bool dumped = false;
        FS_Archive saveArch;
        if(m.optSelected(i) && openSaveArch(&saveArch, sdTitle[i], false))//if it's selected and we can open save archive
        {
            createTitleDir(sdTitle[i], MODE_SAVE);
            backupData(sdTitle[i], saveArch, MODE_SAVE, true);
            dumpCount++;
            dumped = true;
        }
        FSUSER_CloseArchive(&saveArch);

        FS_Archive extArch;
        if(m.optSelected(i) && openExtdata(&extArch, sdTitle[i], false))
        {
            createTitleDir(sdTitle[i], MODE_EXTDATA);
            backupData(sdTitle[i], extArch, MODE_EXTDATA, true);

            //check first to make sure we don't count it twice because no save arch
            if(!dumped)
                dumpCount++;
        }
        FSUSER_CloseArchive(&extArch);

        sf2d_start_frame(GFX_BOTTOM, GFX_LEFT);
            autoDump.draw(i);
        sf2d_end_frame();
        sf2d_swapbuffers();
    }

    showMessage("Complete!");
}
Пример #3
0
void sharedBackupMenu(const titleData dat, FS_Archive arch)
{
    menu backupMenu(136, 80, false);
    backupMenu.addItem("Export Data");
    backupMenu.addItem("Import Data");
    backupMenu.addItem("Back");

    std::u32string info = tou32(dat.nameSafe) + U" : Shared Extdata";

    bool loop = true;
    while(loop)
    {
        hidScanInput();

        u32 up = hidKeysUp();

        backupMenu.handleInput(up);

        if(up & KEY_A)
        {
            switch(backupMenu.getSelected())
            {
                case _exp:
                    createTitleDir(dat, MODE_SHARED);
                    backupData(dat, arch, MODE_SHARED, false);
                    break;
                case _imp:
                    restoreData(dat, arch, MODE_SHARED);
                    break;
                case _back:
                    loop = false;
                    break;
            }
        }
        else if(up & KEY_B)
            break;

        sf2d_start_frame(GFX_TOP, GFX_LEFT);
            drawTopBar(info);
            backupMenu.draw();
        sf2d_end_frame();

        sf2d_start_frame(GFX_BOTTOM, GFX_LEFT);
        sf2d_end_frame();

        sf2d_swapbuffers();
    }
}
Пример #4
0
void CLogRequest::SaveToFile()
{
    const char *currentFileName = GetLogFileName();
    m.lock();
    CFile backupData(currentFileName);
    if(backupData.GetSize() < kMaxFileSize)
    {
        if(!mHasDate)
        {
            boost::posix_time::ptime now = boost::posix_time::second_clock::universal_time();
            std::string strDate("&date=");
            std::string date = boost::posix_time::to_simple_string(now);
            CleanString(date);
            strDate += date;
            mData += strDate;
        }            
        backupData.WriteLine(mData);
        
    }
    backupData.Close();
    m.unlock();
}
Пример #5
0
bool OpenTxEepromInterface::loadModelVariant(unsigned int index, ModelData &model, uint8_t *data, unsigned int version, unsigned int variant)
{
  T open9xModel(model, board, version, variant);

  if (!data) {
    // load from EEPROM
    QByteArray eepromData(sizeof(model), 0);  // ModelData should be always bigger than the EEPROM struct
    efile->openRd(FILE_MODEL(index));
    int numbytes = efile->readRlc2((uint8_t *)eepromData.data(), eepromData.size());
    if (numbytes) {
      open9xModel.Import(eepromData);
      // open9xModel.Dump();
      model.used = true;
    }
    else {
      model.clear();
    }
  }
  else {
    // load from SD Backup, size is stored in index
    QByteArray backupData((char *)data, index);
    QByteArray modelData;
    if (IS_SKY9X(board))
      modelData = backupData;
    else
      importRlc(modelData, backupData);
    if (modelData.size()) {
      open9xModel.Import(modelData);
      // open9xModel.Dump();
      model.used = true;
    }
    else {
      model.clear();
    }
  }

  return true;
}