projects
/
quassel.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Add support for self messages
[quassel.git]
/
src
/
core
/
core.cpp
diff --git
a/src/core/core.cpp
b/src/core/core.cpp
index
e7b5639
..
3eb31e4
100644
(file)
--- a/
src/core/core.cpp
+++ b/
src/core/core.cpp
@@
-1,5
+1,5
@@
/***************************************************************************
/***************************************************************************
- * Copyright (C) 2005-201
5
by the Quassel Project *
+ * Copyright (C) 2005-201
6
by the Quassel Project *
* devel@quassel-irc.org *
* *
* This program is free software; you can redistribute it and/or modify *
* devel@quassel-irc.org *
* *
* This program is free software; you can redistribute it and/or modify *
@@
-198,13
+198,13
@@
void Core::init()
}
if (Quassel::isOptionSet("add-user")) {
}
if (Quassel::isOptionSet("add-user")) {
-
createUser(
);
- exit(0);
+
exit(createUser() ? EXIT_SUCCESS : EXIT_FAILURE
);
+
}
if (Quassel::isOptionSet("change-userpass")) {
}
if (Quassel::isOptionSet("change-userpass")) {
- changeUserPass(Quassel::optionValue("change-userpass"));
-
exit(0
);
+ exit(changeUserPass(Quassel::optionValue("change-userpass")) ?
+
EXIT_SUCCESS : EXIT_FAILURE
);
}
connect(&_server, SIGNAL(newConnection()), this, SLOT(incomingConnection()));
}
connect(&_server, SIGNAL(newConnection()), this, SLOT(incomingConnection()));
@@
-739,7
+739,7
@@
bool Core::selectBackend(const QString &backend)
}
}
-
void
Core::createUser()
+
bool
Core::createUser()
{
QTextStream out(stdout);
QTextStream in(stdin);
{
QTextStream out(stdout);
QTextStream in(stdin);
@@
-761,30
+761,32
@@
void Core::createUser()
if (password != password2) {
qWarning() << "Passwords don't match!";
if (password != password2) {
qWarning() << "Passwords don't match!";
- return;
+ return
false
;
}
if (password.isEmpty()) {
qWarning() << "Password is empty!";
}
if (password.isEmpty()) {
qWarning() << "Password is empty!";
- return;
+ return
false
;
}
if (_configured && _storage->addUser(username, password).isValid()) {
out << "Added user " << username << " successfully!" << endl;
}
if (_configured && _storage->addUser(username, password).isValid()) {
out << "Added user " << username << " successfully!" << endl;
+ return true;
}
else {
qWarning() << "Unable to add user:" << qPrintable(username);
}
else {
qWarning() << "Unable to add user:" << qPrintable(username);
+ return false;
}
}
}
}
-
void
Core::changeUserPass(const QString &username)
+
bool
Core::changeUserPass(const QString &username)
{
QTextStream out(stdout);
QTextStream in(stdin);
UserId userId = _storage->getUserId(username);
if (!userId.isValid()) {
out << "User " << username << " does not exist." << endl;
{
QTextStream out(stdout);
QTextStream in(stdin);
UserId userId = _storage->getUserId(username);
if (!userId.isValid()) {
out << "User " << username << " does not exist." << endl;
- return;
+ return
false
;
}
out << "Change password for user: " << username << endl;
}
out << "Change password for user: " << username << endl;
@@
-802,22
+804,33
@@
void Core::changeUserPass(const QString &username)
if (password != password2) {
qWarning() << "Passwords don't match!";
if (password != password2) {
qWarning() << "Passwords don't match!";
- return;
+ return
false
;
}
if (password.isEmpty()) {
qWarning() << "Password is empty!";
}
if (password.isEmpty()) {
qWarning() << "Password is empty!";
- return;
+ return
false
;
}
if (_configured && _storage->updateUser(userId, password)) {
out << "Password changed successfully!" << endl;
}
if (_configured && _storage->updateUser(userId, password)) {
out << "Password changed successfully!" << endl;
+ return true;
}
else {
qWarning() << "Failed to change password!";
}
else {
qWarning() << "Failed to change password!";
+ return false;
}
}
}
}
+bool Core::changeUserPassword(UserId userId, const QString &password)
+{
+ if (!isConfigured() || !userId.isValid())
+ return false;
+
+ return instance()->_storage->updateUser(userId, password);
+}
+
+
AbstractSqlMigrationReader *Core::getMigrationReader(Storage *storage)
{
if (!storage)
AbstractSqlMigrationReader *Core::getMigrationReader(Storage *storage)
{
if (!storage)