}
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()));
}
-void Core::createUser()
+bool Core::createUser()
{
QTextStream out(stdout);
QTextStream in(stdin);
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;
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;
}
}
void socketError(QAbstractSocket::SocketError err, const QString &errorString);
void setupClientSession(RemotePeer *, UserId);
- void changeUserPass(const QString &username);
+ bool changeUserPass(const QString &username);
private:
Core();
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);
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)));
}
}
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<IrcUser*> users = network()->ircChannel(bufferInfo.bufferName())->ircUsers();
foreach(IrcUser *user, users) {
if ((addOrRemove == '+' && !network()->ircChannel(bufferInfo.bufferName())->userModes(user).contains(mode))
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);
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);
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);
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);
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. *
***************************************************************************/
+#include <QPushButton>
#include <QImage>
+#include <QLabel>
+#include <QLayout>
#include <QPainter>
#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);
+ }
}
#include <QWidget>
+class QPushButton;
+
class MainPage : public QWidget
{
Q_OBJECT
public:
MainPage(QWidget *parent = 0);
-protected:
- void paintEvent(QPaintEvent *event);
+private slots:
+ void showCoreConnectionDlg();
+ void coreConnectionStateChanged();
+
+private:
+ QPushButton *_connectButton;
};
// attach the NickListWidget to the BufferModel and the default selection
_nickListWidget->setModel(Client::bufferModel());
_nickListWidget->setSelectionModel(Client::bufferModel()->standardSelectionModel());
+
+ _nickListWidget->setVisible(false);
}
_layoutLoaded = true;
return;
}
-
+ _nickListWidget->setVisible(true);
restoreState(state, accountId);
int bufferViewId = s.value(QString("ActiveBufferView-%1").arg(accountId), -1).toInt();
if (bufferViewId >= 0)
_msgProcessorStatusWidget->setProgress(0, 0);
updateIcon();
systemTray()->setState(SystemTray::Passive);
+ _nickListWidget->setVisible(false);
}
}
}
+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)
{
public slots:
void showWidget(bool visible);
+ void setVisible(bool visible) override;
signals:
void nickSelectionChanged(const QModelIndexList &);
ui.validity->setText(tr("%1 to %2").arg(cert.effectiveDate().date().toString(Qt::ISODate), cert.expiryDate().date().toString(Qt::ISODate)));
ui.md5Digest->setText(prettyDigest(cert.digest(QCryptographicHash::Md5)));
ui.sha1Digest->setText(prettyDigest(cert.digest(QCryptographicHash::Sha1)));
+#if QT_VERSION < 0x050000
+ // Qt 4 doesn't include SHA-2 hashes, so hide the row
+ ui.sha256Label->hide();
+ ui.sha256Digest->hide();
+#else
+ ui.sha256Digest->setText(prettyDigest(cert.digest(QCryptographicHash::Sha256)));
+#endif
}
// in Qt5, subjectInfo returns a QStringList(); turn this into a comma-separated string instead
</property>
</widget>
</item>
+ <item row="10" column="0">
+ <widget class="QLabel" name="sha256Label">
+ <property name="text">
+ <string><b>SHA256 digest:</b></string>
+ </property>
+ <property name="alignment">
+ <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
+ </property>
+ </widget>
+ </item>
+ <item row="10" column="1">
+ <widget class="QLabel" name="sha256Digest">
+ <property name="text">
+ <string notr="true">n/a</string>
+ </property>
+ </widget>
+ </item>
<item row="4" column="2" colspan="2">
<spacer name="horizontalSpacer_2">
<property name="orientation">
</property>
</spacer>
</item>
- <item row="10" column="0">
+ <item row="11" column="0">
<widget class="QLabel" name="label_19">
<property name="text">
<string><b>Trusted:</b></string>
</property>
</widget>
</item>
- <item row="10" column="1">
+ <item row="11" column="1">
<widget class="QLabel" name="trusted">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Maximum">