#ifdef Q_OS_WIN32
# include <windows.h>
#else
+# include <unistd.h>
# include <termios.h>
#endif /* Q_OS_WIN32 */
+#ifdef HAVE_UMASK
+# include <sys/types.h>
+# include <sys/stat.h>
+#endif /* HAVE_UMASK */
+
// ==============================
// Custom Events
// ==============================
Core::Core()
: _storage(0)
{
+#ifdef HAVE_UMASK
+ umask(S_IRWXG | S_IRWXO);
+#endif
_startTime = QDateTime::currentDateTime().toUTC(); // for uptime :)
Quassel::loadTranslation(QLocale::system());
connect(&_server, SIGNAL(newConnection()), this, SLOT(incomingConnection()));
connect(&_v6server, SIGNAL(newConnection()), this, SLOT(incomingConnection()));
if(!startListening()) exit(1); // TODO make this less brutal
+
+ if(Quassel::isOptionSet("oidentd"))
+ _oidentdConfigGenerator = new OidentdConfigGenerator(this);
}
Core::~Core() {
return;
}
*/
+
QVariantList activeSessions = s.coreState().toMap()["ActiveSessions"].toList();
if(activeSessions.count() > 0) {
quInfo() << "Restoring previous core state...";
}
setupData["AdminUser"] = "AdminUser";
setupData["AdminPasswd"] = QString::number(pass);
- setupData["Backend"] = _storageBackends[_storageBackends.keys().first()]->displayName();
+ setupData["Backend"] = QString("SQLite"); // mono client currently needs sqlite
return setupCore(setupData);
}
if(user.isEmpty() || password.isEmpty()) {
return tr("Admin user or password not set.");
}
- _configured = initStorage(setupData, true);
- if(!_configured) {
+ if(_configured || !(_configured = initStorage(setupData, true))) {
return tr("Could not setup storage!");
}
CoreSettings s;
);
} else {
switch(addr.protocol()) {
- case QAbstractSocket::IPv4Protocol:
- if(_server.listen(addr, port)) {
+ case QAbstractSocket::IPv6Protocol:
+ if(_v6server.listen(addr, port)) {
quInfo() << qPrintable(
- tr("Listening for GUI clients on IPv4 %1 port %2 using protocol version %3")
+ tr("Listening for GUI clients on IPv6 %1 port %2 using protocol version %3")
.arg(addr.toString())
- .arg(_server.serverPort())
+ .arg(_v6server.serverPort())
.arg(Quassel::buildInfo().protocolVersion)
);
success = true;
} else
quWarning() << qPrintable(
- tr("Could not open IPv4 interface %1:%2: %3")
+ tr("Could not open IPv6 interface %1:%2: %3")
.arg(addr.toString())
.arg(port)
- .arg(_server.errorString()));
+ .arg(_v6server.errorString()));
break;
- case QAbstractSocket::IPv6Protocol:
- if(_v6server.listen(addr, port)) {
+ case QAbstractSocket::IPv4Protocol:
+ if(_server.listen(addr, port)) {
quInfo() << qPrintable(
- tr("Listening for GUI clients on IPv6 %1 port %2 using protocol version %3")
+ tr("Listening for GUI clients on IPv4 %1 port %2 using protocol version %3")
.arg(addr.toString())
- .arg(_v6server.serverPort())
+ .arg(_server.serverPort())
.arg(Quassel::buildInfo().protocolVersion)
);
success = true;
} else {
- // if v4 succeeded on Any, the port will be already in use - don't display the error then
- // FIXME: handle this more sanely, make sure we can listen to both v4 and v6 by default!
- if(!success || _v6server.serverError() != QAbstractSocket::AddressInUseError)
+ // if v6 succeeded on Any, the port will be already in use - don't display the error then
+ if(!success || _server.serverError() != QAbstractSocket::AddressInUseError)
quWarning() << qPrintable(
- tr("Could not open IPv6 interface %1:%2: %3")
+ tr("Could not open IPv4 interface %1:%2: %3")
.arg(addr.toString())
.arg(port)
- .arg(_v6server.errorString()));
+ .arg(_server.errorString()));
}
break;
default:
.arg(Quassel::buildInfo().buildDate)
.arg(updays).arg(uphours,2,10,QChar('0')).arg(upmins,2,10,QChar('0')).arg(startTime().toString(Qt::TextDate));
+ reply["CoreFeatures"] = (int)Quassel::features();
+
#ifdef HAVE_SSL
SslServer *sslServer = qobject_cast<SslServer *>(&_server);
QSslSocket *sslSocket = qobject_cast<QSslSocket *>(socket);
return;
}
- if(_storage->addUser(username, password).isValid()) {
+ if(_configured && _storage->addUser(username, password).isValid()) {
out << "Added user " << username << " successfully!" << endl;
} else {
qWarning() << "Unable to add user:" << qPrintable(username);
return;
}
- if(_storage->updateUser(userId, password)) {
- out << "Password changed successfuly!" << endl;
+ if(_configured && _storage->updateUser(userId, password)) {
+ out << "Password changed successfully!" << endl;
} else {
qWarning() << "Failed to change password!";
}