- qDebug() << qPrintable(QString("Migrating Storage backend %1 to %2...").arg(_storage->displayName(), storage->displayName()));
- delete _storage;
- _storage = 0;
- delete storage;
- storage = 0;
- if(reader->migrateTo(writer)) {
- qDebug() << "Migration finished!";
- saveBackendSettings(backend, settings);
- return true;
+ // inform the user why we cannot merge
+ if(!_storage) {
+ qWarning() << "No currently active backend. Skipping migration.";
+ } else if(!reader) {
+ qWarning() << "Currently active backend does not support migration:" << qPrintable(_storage->displayName());
+ }
+ if(writer) {
+ qWarning() << "New backend does not support migration:" << qPrintable(backend);
+ }
+
+ // so we were unable to merge, but let's create a user \o/
+ _storage = storage;
+ createUser();
+ return true;
+}
+
+void Core::createUser() {
+ QTextStream out(stdout);
+ QTextStream in(stdin);
+ out << "Add a new user:" << endl;
+ out << "Username: ";
+ out.flush();
+ QString username = in.readLine().trimmed();
+
+ disableStdInEcho();
+ out << "Password: ";
+ out.flush();
+ QString password = in.readLine().trimmed();
+ out << endl;
+ out << "Repeat Password: ";
+ out.flush();
+ QString password2 = in.readLine().trimmed();
+ out << endl;
+ enableStdInEcho();
+
+ if(password != password2) {
+ qWarning() << "Passwords don't match!";
+ return;
+ }
+ if(password.isEmpty()) {
+ qWarning() << "Password is empty!";
+ return;
+ }
+
+ if(_storage->addUser(username, password).isValid()) {
+ out << "Added user " << username << " successfully!" << endl;
+ } else {
+ qWarning() << "Unable to add user:" << qPrintable(username);