From: Manuel Nickschas Date: Sun, 22 Nov 2015 22:26:28 +0000 (+0100) Subject: Merge pull request #156 from veeti/sha256-certificate X-Git-Tag: travis-deploy-test~541 X-Git-Url: https://git.quassel-irc.org/?p=quassel.git;a=commitdiff_plain;h=7df097437df5c77a1fd772ff1a5b63d40d09ac4f;hp=5d13848aa7c9e25d1eb541a2a53704254e13a930 Merge pull request #156 from veeti/sha256-certificate Display SHA256 fingerprint for SSL certificates --- diff --git a/src/core/core.cpp b/src/core/core.cpp index 2049b63b..e57a764b 100644 --- a/src/core/core.cpp +++ b/src/core/core.cpp @@ -198,13 +198,13 @@ void Core::init() } if (Quassel::isOptionSet("add-user")) { - createUser(); - exit(0); + exit(createUser() ? EXIT_SUCCESS : EXIT_FAILURE); + } 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())); @@ -739,7 +739,7 @@ bool Core::selectBackend(const QString &backend) } -void Core::createUser() +bool Core::createUser() { QTextStream out(stdout); QTextStream in(stdin); @@ -761,30 +761,32 @@ void Core::createUser() if (password != password2) { qWarning() << "Passwords don't match!"; - return; + return false; } if (password.isEmpty()) { qWarning() << "Password is empty!"; - return; + return false; } if (_configured && _storage->addUser(username, password).isValid()) { out << "Added user " << username << " successfully!" << endl; + return true; } 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; - return; + return false; } out << "Change password for user: " << username << endl; @@ -802,18 +804,20 @@ void Core::changeUserPass(const QString &username) if (password != password2) { qWarning() << "Passwords don't match!"; - return; + return false; } if (password.isEmpty()) { qWarning() << "Password is empty!"; - return; + return false; } if (_configured && _storage->updateUser(userId, password)) { out << "Password changed successfully!" << endl; + return true; } else { qWarning() << "Failed to change password!"; + return false; } } diff --git a/src/core/core.h b/src/core/core.h index e356a0fb..aab2b84b 100644 --- a/src/core/core.h +++ b/src/core/core.h @@ -533,7 +533,7 @@ private slots: void socketError(QAbstractSocket::SocketError err, const QString &errorString); void setupClientSession(RemotePeer *, UserId); - void changeUserPass(const QString &username); + bool changeUserPass(const QString &username); private: Core(); @@ -551,7 +551,7 @@ private: void unregisterStorageBackends(); void unregisterStorageBackend(Storage *); bool selectBackend(const QString &backend); - void createUser(); + bool createUser(); void saveBackendSettings(const QString &backend, const QVariantMap &settings); QVariantMap promptForSettings(const Storage *storage); diff --git a/src/core/corenetwork.cpp b/src/core/corenetwork.cpp index 942e32f6..c42325f9 100644 --- a/src/core/corenetwork.cpp +++ b/src/core/corenetwork.cpp @@ -81,7 +81,7 @@ CoreNetwork::CoreNetwork(const NetworkId &networkid, CoreSession *session) connect(this, SIGNAL(newEvent(Event *)), coreSession()->eventManager(), SLOT(postEvent(Event *))); if (Quassel::isOptionSet("oidentd")) { - connect(this, SIGNAL(socketOpen(const CoreIdentity*, QHostAddress, quint16, QHostAddress, quint16)), Core::instance()->oidentdConfigGenerator(), SLOT(addSocket(const CoreIdentity*, QHostAddress, quint16, QHostAddress, quint16)), Qt::BlockingQueuedConnection); + connect(this, SIGNAL(socketInitialized(const CoreIdentity*, QHostAddress, quint16, QHostAddress, quint16)), Core::instance()->oidentdConfigGenerator(), SLOT(addSocket(const CoreIdentity*, QHostAddress, quint16, QHostAddress, quint16)), Qt::BlockingQueuedConnection); connect(this, SIGNAL(socketDisconnected(const CoreIdentity*, QHostAddress, quint16, QHostAddress, quint16)), Core::instance()->oidentdConfigGenerator(), SLOT(removeSocket(const CoreIdentity*, QHostAddress, quint16, QHostAddress, quint16))); } } diff --git a/src/core/coreuserinputhandler.cpp b/src/core/coreuserinputhandler.cpp index 7887a929..73aac48a 100644 --- a/src/core/coreuserinputhandler.cpp +++ b/src/core/coreuserinputhandler.cpp @@ -228,7 +228,7 @@ void CoreUserInputHandler::doMode(const BufferInfo &bufferInfo, const QChar& add if (!isNumber || maxModes == 0) maxModes = 1; QStringList nickList; - if (nicks == "*") { // All users in channel + if (nicks == "*" && bufferInfo.type() == BufferInfo::ChannelBuffer) { // All users in channel const QList users = network()->ircChannel(bufferInfo.bufferName())->ircUsers(); foreach(IrcUser *user, users) { if ((addOrRemove == '+' && !network()->ircChannel(bufferInfo.bufferName())->userModes(user).contains(mode)) diff --git a/src/core/postgresqlstorage.cpp b/src/core/postgresqlstorage.cpp index b16f4b0a..65460dff 100644 --- a/src/core/postgresqlstorage.cpp +++ b/src/core/postgresqlstorage.cpp @@ -944,7 +944,7 @@ void PostgreSqlStorage::setChannelPersistent(UserId user, const NetworkId &netwo QSqlQuery query(logDb()); query.prepare(queryString("update_buffer_persistent_channel")); query.bindValue(":userid", user.toInt()); - query.bindValue(":networkId", networkId.toInt()); + query.bindValue(":networkid", networkId.toInt()); query.bindValue(":buffercname", channel.toLower()); query.bindValue(":joined", isJoined); safeExec(query); @@ -957,7 +957,7 @@ void PostgreSqlStorage::setPersistentChannelKey(UserId user, const NetworkId &ne QSqlQuery query(logDb()); query.prepare(queryString("update_buffer_set_channel_key")); query.bindValue(":userid", user.toInt()); - query.bindValue(":networkId", networkId.toInt()); + query.bindValue(":networkid", networkId.toInt()); query.bindValue(":buffercname", channel.toLower()); query.bindValue(":key", key); safeExec(query); diff --git a/src/core/sqlitestorage.cpp b/src/core/sqlitestorage.cpp index 46e2c70e..354b340a 100644 --- a/src/core/sqlitestorage.cpp +++ b/src/core/sqlitestorage.cpp @@ -968,7 +968,7 @@ void SqliteStorage::setChannelPersistent(UserId user, const NetworkId &networkId QSqlQuery query(db); query.prepare(queryString("update_buffer_persistent_channel")); query.bindValue(":userid", user.toInt()); - query.bindValue(":networkId", networkId.toInt()); + query.bindValue(":networkid", networkId.toInt()); query.bindValue(":buffercname", channel.toLower()); query.bindValue(":joined", isJoined ? 1 : 0); @@ -990,7 +990,7 @@ void SqliteStorage::setPersistentChannelKey(UserId user, const NetworkId &networ QSqlQuery query(db); query.prepare(queryString("update_buffer_set_channel_key")); query.bindValue(":userid", user.toInt()); - query.bindValue(":networkId", networkId.toInt()); + query.bindValue(":networkid", networkId.toInt()); query.bindValue(":buffercname", channel.toLower()); query.bindValue(":key", key); diff --git a/src/qtui/mainpage.cpp b/src/qtui/mainpage.cpp index 82387ab6..4838e251 100644 --- a/src/qtui/mainpage.cpp +++ b/src/qtui/mainpage.cpp @@ -18,28 +18,49 @@ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * ***************************************************************************/ +#include #include +#include +#include #include #include "mainpage.h" +#include "coreconnectdlg.h" +#include "client.h" MainPage::MainPage(QWidget *parent) : QWidget(parent) { -} - - -void MainPage::paintEvent(QPaintEvent *event) -{ - Q_UNUSED(event); + QVBoxLayout *layout = new QVBoxLayout(this); + layout->setAlignment(Qt::AlignCenter); + QLabel *label = new QLabel(this); + label->setPixmap(QPixmap(":/pics/quassel-logo.png")); + layout->addWidget(label); - QPainter painter(this); - QImage img(":/pics/quassel-logo.png"); // FIXME load externally + if (Quassel::runMode() != Quassel::Monolithic) { + _connectButton = new QPushButton(QIcon::fromTheme("network-connect"), tr("Connect to Core...")); + _connectButton->setEnabled(Client::coreConnection()->state() == CoreConnection::Disconnected); - if (img.height() > height() || img.width() > width()) - img = img.scaled(width(), height(), Qt::KeepAspectRatio, Qt::SmoothTransformation); + connect(Client::coreConnection(), SIGNAL(stateChanged(CoreConnection::ConnectionState)), this, SLOT(coreConnectionStateChanged())); + connect(_connectButton, SIGNAL(clicked(bool)), this, SLOT(showCoreConnectionDlg())); + layout->addWidget(_connectButton); + } +} - int xmargin = (width() - img.width()) / 2; - int ymargin = (height() - img.height()) / 2; +void MainPage::showCoreConnectionDlg() +{ + CoreConnectDlg dlg(this); + if (dlg.exec() == QDialog::Accepted) { + AccountId accId = dlg.selectedAccount(); + if (accId.isValid()) + Client::coreConnection()->connectToCore(accId); + } +} - painter.drawImage(xmargin, ymargin, img); +void MainPage::coreConnectionStateChanged() +{ + if (Client::coreConnection()->state() == CoreConnection::Disconnected) { + _connectButton->setEnabled(true); + } else { + _connectButton->setDisabled(true); + } } diff --git a/src/qtui/mainpage.h b/src/qtui/mainpage.h index 0557f8e3..6ac80394 100644 --- a/src/qtui/mainpage.h +++ b/src/qtui/mainpage.h @@ -23,6 +23,8 @@ #include +class QPushButton; + class MainPage : public QWidget { Q_OBJECT @@ -30,8 +32,12 @@ class MainPage : public QWidget public: MainPage(QWidget *parent = 0); -protected: - void paintEvent(QPaintEvent *event); +private slots: + void showCoreConnectionDlg(); + void coreConnectionStateChanged(); + +private: + QPushButton *_connectButton; }; diff --git a/src/qtui/mainwin.cpp b/src/qtui/mainwin.cpp index bd8727ac..95d2e6f6 100644 --- a/src/qtui/mainwin.cpp +++ b/src/qtui/mainwin.cpp @@ -879,6 +879,8 @@ void MainWin::setupNickWidget() // attach the NickListWidget to the BufferModel and the default selection _nickListWidget->setModel(Client::bufferModel()); _nickListWidget->setSelectionModel(Client::bufferModel()->standardSelectionModel()); + + _nickListWidget->setVisible(false); } @@ -1131,7 +1133,7 @@ void MainWin::loadLayout() _layoutLoaded = true; return; } - + _nickListWidget->setVisible(true); restoreState(state, accountId); int bufferViewId = s.value(QString("ActiveBufferView-%1").arg(accountId), -1).toInt(); if (bufferViewId >= 0) @@ -1201,6 +1203,7 @@ void MainWin::setDisconnectedState() _msgProcessorStatusWidget->setProgress(0, 0); updateIcon(); systemTray()->setState(SystemTray::Passive); + _nickListWidget->setVisible(false); } diff --git a/src/qtui/nicklistwidget.cpp b/src/qtui/nicklistwidget.cpp index d5af971b..a47cc6e4 100644 --- a/src/qtui/nicklistwidget.cpp +++ b/src/qtui/nicklistwidget.cpp @@ -84,6 +84,19 @@ void NickListWidget::showWidget(bool visible) } } +void NickListWidget::setVisible(bool visible) +{ + QWidget::setVisible(visible); + QDockWidget *dock_ = dock(); + if (!dock_) + return; + + if (visible) + dock_->show(); + else + dock_->close(); +} + void NickListWidget::currentChanged(const QModelIndex ¤t, const QModelIndex &previous) { diff --git a/src/qtui/nicklistwidget.h b/src/qtui/nicklistwidget.h index 1b7253f7..84fc4325 100644 --- a/src/qtui/nicklistwidget.h +++ b/src/qtui/nicklistwidget.h @@ -43,6 +43,7 @@ public: public slots: void showWidget(bool visible); + void setVisible(bool visible) override; signals: void nickSelectionChanged(const QModelIndexList &);