bool MobileUiApplication::init() {
  if(Quassel::init()) {

    // FIXME: MIGRATION 0.3 -> 0.4: Move database and core config to new location
    // Move settings, note this does not delete the old files
#ifdef Q_WS_MAC
    QSettings newSettings("quassel-irc.org", "quassel2go");
#else

# ifdef Q_WS_WIN
    QSettings::Format format = QSettings::IniFormat;
# else
    QSettings::Format format = QSettings::NativeFormat;
# endif

    QString newFilePath = Quassel::configDirPath() + "quassel2go"
    + ((format == QSettings::NativeFormat) ? QLatin1String(".conf") : QLatin1String(".ini"));
    QSettings newSettings(newFilePath, format);
#endif /* Q_WS_MAC */

    if(newSettings.value("Config/Version").toUInt() == 0) {
#     ifdef Q_WS_MAC
        QString org = "quassel-irc.org";
#     else
        QString org = "Quassel Project";
#     endif
      QSettings oldSettings(org, "Quassel Client");
      if(oldSettings.allKeys().count()) {
        qWarning() << "\n\n*** IMPORTANT: Config and data file locations have changed. Attempting to auto-migrate your client settings...";
        foreach(QString key, oldSettings.allKeys())
          newSettings.setValue(key, oldSettings.value(key));
        newSettings.setValue("Config/Version", 1);
        qWarning() << "*   Your client settings have been migrated to" << newSettings.fileName();
        qWarning() << "*** Migration completed.\n\n";
      }
    }

    // MIGRATION end

    // check settings version
    // so far, we only have 1
    QtUiSettings s;
    if(s.version() != 1) {
      qCritical() << "Invalid client settings version, terminating!";
      return false;
    }

    // session resume
    QtUi *gui = new QtUi();
    Client::init(gui);
    // init gui only after the event loop has started
    // QTimer::singleShot(0, gui, SLOT(init()));
    gui->init();
    resumeSessionIfPossible();
    return true;
  }
  return false;
}
void ConfigDialogImpl::slotOk()
{
    applyConfig();
    writeConfig();
    emit(newSettings());
    delete ui;
}
void VLCSetingsDialog::loadNewSettings()
{
    QString settings = textEdit->toPlainText();
    QString settingsToEmit;
    for(int i = 0; i < settings.size(); i++)
    {
        if(settings.at(i) == '\n')
            settingsToEmit.append(" ");
        else
            settingsToEmit.append(settings.at(i));
    }
    emit newSettings(settingsToEmit);
    accept();
}
void Debugger::loadSettings() {
	FILE* pFile = fopen(DebugPrefs, "r");
	int size = 1024, pos;
	int c;
	char *buffer = (char*)malloc(sizeof(char)*size);

	int confSizeA = 128;
	int confSizeB = 128;
	//finish dynamic memory allocation for debugruntimeconfig method
	char** conf = (char**)malloc(sizeof(char*)*2);

	conf[0] = (char*)malloc(sizeof(char)*confSizeA);
	conf[1] = (char*)malloc(sizeof(char)*confSizeB);
	
	if(pFile == NULL) {
		Log(WARNING, "Failed to open Debugger Preferences.");
		Log(INFO, "Checking if Debugger Preferences exist.");
		if(settingsExist()) {
			Log(_ERROR_, "Cannot access Debugger Preferences but file does exist.");
			Log(WARNING, "Is another application using this file? (Shouldn't be!)");
		} else {
			Log(INFO, "Debugger Preferences file does not exist, generating.");
			newSettings();
		}
	} else {
		do {
			pos = 0;
			do {
				c = fgetc(pFile);
				if(c!=EOF) buffer[pos++] = (char)c;
				if(pos >= size - 1) {
					size *= 2;
					buffer = (char*)realloc(buffer, size);
				}
			} while (c != EOF && c != '\n');
			buffer[pos]=0;
			//Log(buffer);
			//Each line from the file gets handled here.
			conf = handleConfiguration(buffer);
			setDebuggerRuntimeConfig(conf);
		} while (c != EOF);
		fclose(pFile);
	}
	free(buffer);
}
Exemple #5
0
Core::Core()
    : QObject(),
      _storage(0)
{
#ifdef HAVE_UMASK
    umask(S_IRWXG | S_IRWXO);
#endif
    _startTime = QDateTime::currentDateTime().toUTC(); // for uptime :)

    Quassel::loadTranslation(QLocale::system());

    // FIXME: MIGRATION 0.3 -> 0.4: Move database and core config to new location
    // Move settings, note this does not delete the old files
#ifdef Q_WS_MAC
    QSettings newSettings("quassel-irc.org", "quasselcore");
#else

# ifdef Q_WS_WIN
    QSettings::Format format = QSettings::IniFormat;
# else
    QSettings::Format format = QSettings::NativeFormat;
# endif
    QString newFilePath = Quassel::configDirPath() + "quasselcore"
                          + ((format == QSettings::NativeFormat) ? QLatin1String(".conf") : QLatin1String(".ini"));
    QSettings newSettings(newFilePath, format);
#endif /* Q_WS_MAC */

    if (newSettings.value("Config/Version").toUInt() == 0) {
#   ifdef Q_WS_MAC
        QString org = "quassel-irc.org";
#   else
        QString org = "Quassel Project";
#   endif
        QSettings oldSettings(org, "Quassel Core");
        if (oldSettings.allKeys().count()) {
            qWarning() << "\n\n*** IMPORTANT: Config and data file locations have changed. Attempting to auto-migrate your core settings...";
            foreach(QString key, oldSettings.allKeys())
            newSettings.setValue(key, oldSettings.value(key));
            newSettings.setValue("Config/Version", 1);
            qWarning() << "*   Your core settings have been migrated to" << newSettings.fileName();

#ifndef Q_WS_MAC /* we don't need to move the db and cert for mac */
#ifdef Q_OS_WIN32
            QString quasselDir = qgetenv("APPDATA") + "/quassel/";
#elif defined Q_WS_MAC
            QString quasselDir = QDir::homePath() + "/Library/Application Support/Quassel/";
#else
            QString quasselDir = QDir::homePath() + "/.quassel/";
#endif

            QFileInfo info(Quassel::configDirPath() + "quassel-storage.sqlite");
            if (!info.exists()) {
                // move database, if we found it
                QFile oldDb(quasselDir + "quassel-storage.sqlite");
                if (oldDb.exists()) {
                    bool success = oldDb.rename(Quassel::configDirPath() + "quassel-storage.sqlite");
                    if (success)
                        qWarning() << "*   Your database has been moved to" << Quassel::configDirPath() + "quassel-storage.sqlite";
                    else
                        qWarning() << "!!! Moving your database has failed. Please move it manually into" << Quassel::configDirPath();
                }
            }
            // move certificate
            QFileInfo certInfo(quasselDir + "quasselCert.pem");
            if (certInfo.exists()) {
                QFile cert(quasselDir + "quasselCert.pem");
                bool success = cert.rename(Quassel::configDirPath() + "quasselCert.pem");
                if (success)
                    qWarning() << "*   Your certificate has been moved to" << Quassel::configDirPath() + "quasselCert.pem";
                else
                    qWarning() << "!!! Moving your certificate has failed. Please move it manually into" << Quassel::configDirPath();
            }
#endif /* !Q_WS_MAC */
            qWarning() << "*** Migration completed.\n\n";
        }
    }
    // MIGRATION end

    // check settings version
    // so far, we only have 1
    CoreSettings s;
    if (s.version() != 1) {
        qCritical() << "Invalid core settings version, terminating!";
        exit(EXIT_FAILURE);
    }

    registerStorageBackends();

    connect(&_storageSyncTimer, SIGNAL(timeout()), this, SLOT(syncStorage()));
    _storageSyncTimer.start(10 * 60 * 1000); // 10 minutes
}