Exemplo n.º 1
0
void ProfileManager::updateCurrentProfile()
{
    QDir profileDir(DataPaths::currentProfilePath());

    if (!profileDir.exists()) {
        QDir newDir(profileDir.path().remove(profileDir.dirName()));
        newDir.mkdir(profileDir.dirName());
    }

    QFile versionFile(profileDir.filePath(QLatin1String("version")));

    // If file exists, just update the profile to current version
    if (versionFile.exists()) {
        versionFile.open(QFile::ReadOnly);
        QString profileVersion = versionFile.readAll();
        versionFile.close();

        updateProfile(Qz::VERSION, profileVersion.trimmed());
    }
    else {
        copyDataToProfile();
    }

    versionFile.open(QFile::WriteOnly);
    versionFile.write(Qz::VERSION);
    versionFile.close();
}
Exemplo n.º 2
0
bts::application_config load_config( const std::string& profile_name )
  {
  try 
    {
    auto strDataDir = QStandardPaths::writableLocation(QStandardPaths::DataLocation).toStdWString();
    boost::filesystem::path dataDir(strDataDir);
    boost::filesystem::path profileDataDir(dataDir/profile_name);
    fc::path profileDir(profileDataDir);
    fc::create_directories(profileDir);
    auto config_file  = profileDir / "config.json";
    ilog( "config_file: ${file}", ("file",config_file) );
    if(fc::exists(config_file) == false)
      {
      bts::application_config default_cfg;
      default_cfg.data_dir = profileDir / "data";

      fc::ofstream out( config_file );
      out << fc::json::to_pretty_string( default_cfg );
      }

    auto app_config = fc::json::from_file( config_file ).as<bts::application_config>();
    fc::ofstream out( config_file );
    out << fc::json::to_pretty_string( app_config );
    return app_config;
    }
  FC_RETHROW_EXCEPTIONS( warn, "")
  }
Exemplo n.º 3
0
void ProfileUpdater::copyDataToProfile()
{
    QDir profileDir(m_profilePath);
    profileDir.mkdir("certificates");

    QFile(m_profilePath + "browsedata.db").remove();
    QFile(":data/browsedata.db").copy(m_profilePath + "browsedata.db");
    QFile(m_profilePath + "browsedata.db").setPermissions(QFile::ReadUser | QFile::WriteUser);
}
OtrInternal::OtrInternal(psiotr::OtrCallback* callback,
                         psiotr::OtrPolicy& policy)
    : m_userstate(),
      m_uiOps(),
      m_callback(callback),
      m_otrPolicy(policy),
      is_generating(false)
{
    QDir profileDir(callback->dataDir());

    m_keysFile        = profileDir.filePath(OTR_KEYS_FILE);
    m_instagsFile     = profileDir.filePath(OTR_INSTAGS_FILE);
    m_fingerprintFile = profileDir.filePath(OTR_FINGERPRINTS_FILE);

    OTRL_INIT;
    m_userstate                 = otrl_userstate_create();
    m_uiOps.policy              = (*OtrInternal::cb_policy);
    m_uiOps.create_privkey      = (*OtrInternal::cb_create_privkey);
    m_uiOps.is_logged_in        = (*OtrInternal::cb_is_logged_in);
    m_uiOps.inject_message      = (*OtrInternal::cb_inject_message);
    m_uiOps.update_context_list = (*OtrInternal::cb_update_context_list);
    m_uiOps.new_fingerprint     = (*OtrInternal::cb_new_fingerprint);
    m_uiOps.write_fingerprints  = (*OtrInternal::cb_write_fingerprints);
    m_uiOps.gone_secure         = (*OtrInternal::cb_gone_secure);
    m_uiOps.gone_insecure       = (*OtrInternal::cb_gone_insecure);
    m_uiOps.still_secure        = (*OtrInternal::cb_still_secure);

#if (OTRL_VERSION_MAJOR > 3 || (OTRL_VERSION_MAJOR == 3 && OTRL_VERSION_MINOR >= 2))
    m_uiOps.max_message_size    = NULL;
    m_uiOps.account_name        = (*OtrInternal::cb_account_name);
    m_uiOps.account_name_free   = (*OtrInternal::cb_account_name_free);
#endif

#if (OTRL_VERSION_MAJOR >= 4)
    m_uiOps.handle_msg_event    = (*OtrInternal::cb_handle_msg_event);
    m_uiOps.handle_smp_event    = (*OtrInternal::cb_handle_smp_event);
    m_uiOps.create_instag       = (*OtrInternal::cb_create_instag);
#else
    m_uiOps.log_message         = (*OtrInternal::cb_log_message);

    m_uiOps.notify              = (*OtrInternal::cb_notify);
    m_uiOps.display_otr_message = (*OtrInternal::cb_display_otr_message);

    m_uiOps.protocol_name       = (*OtrInternal::cb_protocol_name);
    m_uiOps.protocol_name_free  = (*OtrInternal::cb_protocol_name_free);
#endif

    otrl_privkey_read(m_userstate, QFile::encodeName(m_keysFile).constData());
    otrl_privkey_read_fingerprints(m_userstate,
                                   QFile::encodeName(m_fingerprintFile).constData(),
                                   NULL, NULL);
#if (OTRL_VERSION_MAJOR >= 4)
    otrl_instag_read(m_userstate, QFile::encodeName(m_instagsFile).constData());
#endif
}
Exemplo n.º 5
0
void SettingsManager::setProfileDirectory(const String& profileDirStr)
{
	_propertiesFile->setValue("profile_directory", profileDirStr);
	_propertiesFile->saveIfNeeded();

	if (m_profileManager)
	{
		File profileDir(profileDirStr);
		m_profileManager->setProfileDirectory(profileDir);
	}
}
Exemplo n.º 6
0
void MainWindow::setupProfileActions()
{
    QDir profileDir( KStandardDirs::locateLocal( "appdata", "profiles/" ) );
    QStringList profileNames = profileDir.entryList( QDir::Files | QDir::Readable );
    QStringList::ConstIterator it = profileNames.constBegin();
    QStringList::ConstIterator end = profileNames.constEnd();
    while ( it != end ) {
        m_profiles << new Profile( *it );
        ++it;
    }
    updateProfileActions();
}
Exemplo n.º 7
0
void SettingsManager::Init(LR_IPC_OUT *lr_IPC_OUT, ProfileManager *profileManager)
{
	m_lr_IPC_OUT = lr_IPC_OUT;

	if (m_lr_IPC_OUT)
	{
		// add ourselves as a listener to LR_IPC_OUT so that we can send plugin settings on connection
		m_lr_IPC_OUT->addListener(this);
	}

	m_profileManager = profileManager;

	if (m_profileManager)
	{
		// set the profile directory
		File profileDir(getProfileDirectory());
		profileManager->setProfileDirectory(profileDir);
	}

}
Exemplo n.º 8
0
void ProfileUpdater::copyDataToProfile()
{
    QDir profileDir(m_profilePath);
    profileDir.mkdir("certificates");

    QFile browseData(m_profilePath + "browsedata.db");
    if (browseData.exists()) {
        const QString &browseDataBackup = qz_ensureUniqueFilename(m_profilePath + "browsedata-backup.db");
        const QString &settingsBackup = qz_ensureUniqueFilename(m_profilePath + "settings-backup.ini");
        browseData.copy(browseDataBackup);
        QFile(m_profilePath + "settings.ini").copy(settingsBackup);
        const QString &text = "Incompatible profile version has been detected. To avoid losing your profile data, they were "
                              "backed up in following directories:<br/><br/><b>" + browseDataBackup + "<br/>" + settingsBackup + "<br/></b>";
        QMessageBox::warning(0, "QupZilla: Incompatible profile version", text);
    }

    browseData.remove();
    QFile(":data/browsedata.db").copy(m_profilePath + "browsedata.db");
    QFile(m_profilePath + "browsedata.db").setPermissions(QFile::ReadUser | QFile::WriteUser);
}
Exemplo n.º 9
0
void ProfileManager::copyDataToProfile()
{
    QDir profileDir(DataPaths::currentProfilePath());

    QFile browseData(profileDir.filePath(QLatin1String("browsedata.db")));

    if (browseData.exists()) {
        const QString browseDataBackup = QzTools::ensureUniqueFilename(profileDir.filePath(QLatin1String("browsedata-backup.db")));
        browseData.copy(browseDataBackup);

        const QString text = "Incompatible profile version has been detected. To avoid losing your profile data, they were "
                             "backed up in following file:<br/><br/><b>" + browseDataBackup + "<br/></b>";
        QMessageBox::warning(0, "QupZilla: Incompatible profile version", text);
    }

    browseData.remove();

    QFile(QLatin1String(":data/browsedata.db")).copy(profileDir.filePath(QLatin1String("browsedata.db")));
    QFile(profileDir.filePath(QLatin1String("browsedata.db"))).setPermissions(QFile::ReadUser | QFile::WriteUser);

    // Reconnect database
    connectDatabase();
}
Exemplo n.º 10
0
bool Settings::save(QString profile) {
  QString fileName = profileDir(profile.isEmpty() ? profileName_ : profile) % "/settings.conf";
  return saveFile(fileName);
}
Exemplo n.º 11
0
bool Settings::load(QString profile) {
  profileName_ = profile;
  QString fileName = profileDir(profile, true) % "/settings.conf";
  return loadFile(fileName);
}
void InstallProcessPage::prepareInstallation() {

    progressBarInstallation->setValue( 5 );
    listWidgetDosBoxProcessStatus->addItem( tr( "dboxfe: prepare installation ..." ) );

    // Make a application thread
    qApp->processEvents();

    // Get the wizard next-button
    QAbstractButton *buttonNext = GameWizard::instance()->button( QWizard::NextButton );

    if ( buttonNext ) {

        buttonNext->setEnabled( false );
    }

    progressBarInstallation->setValue( 10 );
    listWidgetDosBoxProcessStatus->addItem( tr( "        get required fields" ) );

    // Get dosbox binary and setup settings
    dosBoxBinary = field( "dosBoxBinary" ).toString();
    installSetupFile = field( "installSetupFile" ).toString();
    installFolder = field( "installFolder" ).toString();

    progressBarInstallation->setValue( 15 );
    listWidgetDosBoxProcessStatus->addItem( tr( "        open installation.conf" ) );

    // Get installation config
    QString m_installConf = ":/install_conf";

    QFile installConf( m_installConf );

    // Open installation config
    if ( !installConf.open( QFile::ReadOnly | QFile::Text ) ) {
        QMessageBox::information( 0, tr( "Game Wizard" ), tr( "Can not read " ) + installConf.fileName() );
        return;
    }

    // Read installation config
    QTextStream installTextStream( &installConf );
    QString m_conf = installTextStream.readAll();

    QString keyboardLayout = QLocale::languageToString( QLocale::system().language() );
    if( keyboardLayout == "German" ) {
        keyboardLayout = "GR";

    } else {
        keyboardLayout = "none";
    }

    progressBarInstallation->setValue( 20 );
    listWidgetDosBoxProcessStatus->addItem( tr( "        replace installation.conf variables" ) );

    QFileInfo dvdDirectory( installSetupFile );

    m_conf.replace( "$(KEYBOARD_LAYOUT)", keyboardLayout );
    m_conf.replace( "$(DVD_CD_DIRECTORY)", dvdDirectory.absolutePath() );
    m_conf.replace( "$(INSTALLATION_DIRECTORY)", installFolder );
    m_conf.replace( "$(SETUP_EXECUTABLE)", dvdDirectory.fileName() );

    progressBarInstallation->setValue( 25 );
    listWidgetDosBoxProcessStatus->addItem( tr( "        close installation.conf" ) );
    // Close install config
    installConf.flush();
    installConf.close();

    progressBarInstallation->setValue( 30 );
    listWidgetDosBoxProcessStatus->addItem( tr( "        create required directories" ) );

    // Set real installation config for save on hard disc
    m_installConf = "";
    m_installConf = QDir::homePath();
    m_installConf.append( "/.dboxfe" );

    // create profile directory if this not exists
    QDir profileDir( m_installConf );

    if ( !profileDir.exists() ) {
        profileDir.mkpath( m_installConf );
    }

    progressBarInstallation->setValue( 40 );
    listWidgetDosBoxProcessStatus->addItem( tr( "        open installation.conf again" ) );

    // Append the installation config file
    m_installConf.append( "/installation.conf" );

    QFile realInstallConf( m_installConf );

    // Open real installation config
    if ( !realInstallConf.open( QFile::WriteOnly | QFile::Text ) ) {
        QMessageBox::information( 0, tr( "Game Wizard" ), tr( "Can not read " ) + realInstallConf.fileName() );
        progressBarInstallation->setValue( 0 );
        listWidgetDosBoxProcessStatus->addItem( tr( "       ERROR - Can not read %1" ).arg( realInstallConf.fileName() ) );
        return;
    }

    // Read real installation config
    QTextStream realInstallTextStream( &realInstallConf );

    realInstallTextStream << m_conf;

    progressBarInstallation->setValue( 45 );
    listWidgetDosBoxProcessStatus->addItem( tr( "        save installation.conf" ) );

    // Close and write real install config
    realInstallTextStream.flush();
    installConf.flush();
    installConf.close();

    progressBarInstallation->setValue( 50 );
    listWidgetDosBoxProcessStatus->addItem( tr( "        finish" ) );
    listWidgetDosBoxProcessStatus->addItem( tr( "" ) );

    progressBarInstallation->setValue( 55 );
    listWidgetDosBoxProcessStatus->addItem( tr( "dboxfe: begin installation ..." ) );

    install( dosBoxBinary, "-conf", """" + realInstallConf.fileName() + """", buttonNext );
}