We should not wait for a client to connect...
Also I added Storage::renameUser() and a few signals.
}
void Client::recvCoreState(const QVariant &state) {
- disconnect(this, SIGNAL(recvPartialItem(quint32, quint32)), this, SIGNAL(coreConnectionProgress(uint, uint)));
+ disconnect(this, SIGNAL(recvPartialItem(uint, uint)), this, SIGNAL(coreConnectionProgress(uint, uint)));
syncToCore(state);
}
connect(storage, SIGNAL(bufferIdUpdated(BufferId)), coreProxy, SLOT(csUpdateBufferId(BufferId)));
connect(this, SIGNAL(sessionDataChanged(const QString &, const QVariant &)), coreProxy, SLOT(csSessionDataChanged(const QString &, const QVariant &)));
connect(coreProxy, SIGNAL(gsSessionDataChanged(const QString &, const QVariant &)), this, SLOT(storeSessionData(const QString &, const QVariant &)));
+
+ /* Autoconnect. (When) do we actually do this?
+ QStringList list;
+ VarMap networks = retrieveSessionData("Networks").toMap();
+ foreach(QString net, networks.keys()) {
+ if(networks[net].toMap()["AutoConnect"].toBool()) {
+ list << net;
+ }
+ } qDebug() << list;
+ if(list.count()) connectToIrc(list);
+ */
}
CoreSession::~CoreSession() {
query.exec();
if(query.lastError().isValid() && query.lastError().number() == 19) { // user already exists - sadly 19 seems to be the general constraint violation error...
return 0;
- }
+ }
query.prepare("SELECT userid FROM quasseluser WHERE username = :username");
query.bindValue(":username", user);
query.exec();
query.first();
- return query.value(0).toUInt();
+ UserId uid = query.value(0).toUInt();
+ emit userAdded(uid, user);
+ return uid;
}
void SqliteStorage::updateUser(UserId user, QString password) {
query.exec();
}
+void SqliteStorage::renameUser(UserId user, QString newName) {
+ QSqlQuery query(logDb);
+ query.prepare("UPDATE quasseluser SET username = :username WHERE userid = :userid");
+ query.bindValue(":userid", user);
+ query.bindValue(":username", newName);
+ query.exec();
+ emit userRenamed(user, newName);
+}
+
UserId SqliteStorage::validateUser(QString user, QString password) {
QByteArray cryptopass = QCryptographicHash::hash(password.toUtf8(), QCryptographicHash::Sha1);
cryptopass = cryptopass.toHex();
query.bindValue(":userid", user);
query.exec();
// I hate the lack of foreign keys and on delete cascade... :(
+ emit userRemoved(user);
}
void SqliteStorage::createBuffer(UserId user, QString network, QString buffer) {
virtual UserId addUser(QString user, QString password);
virtual void updateUser(UserId user, QString password);
+ virtual void renameUser(UserId user, QString newName);
virtual UserId validateUser(QString user, QString password);
virtual void delUser(UserId user);
*/
virtual void updateUser(UserId user, QString password) = 0;
+ //! Rename a user
+ /** \param user The user's id
+ * \param newName The user's new name
+ */
+ virtual void renameUser(UserId user, QString newName) = 0;
+
//! Validate a username with a given password.
/** \param user The username to validate
* \param password The user's alleged password
virtual void importOldBacklog() = 0;
signals:
- //! Sent if a new BufferId is created, or an existing one changed somehow.
+ //! Sent when a new BufferId is created, or an existing one changed somehow.
void bufferIdUpdated(BufferId);
+ //! Sent when a new user has been added
+ void userAdded(UserId, const QString &username);
+ //! Sent when a user has been renamed
+ void userRenamed(UserId, const QString &newname);
+ //! Sent when a user has been removed
+ void userRemoved(UserId);
public:
/* Exceptions */
connect(Client::instance(), SIGNAL(sessionDataChanged(const QString &)), this, SLOT(updateNetworkTree()));
settings.endGroup();
- // check if we already have a valid identity
- //if(!Global::data("Identities", VarMap()).toMap().contains("Default")) editIdentities(true); // FIXME
+
connect(this, SIGNAL(requestConnect(QStringList)), ClientProxy::instance(), SLOT(gsRequestConnect(QStringList)));
// Autoconnect
+ /* Should not be the client's task... :-P
QStringList list;
VarMap networks = Client::retrieveSessionData("Networks").toMap();
foreach(QString net, networks.keys()) {
}
}
if(!list.isEmpty()) emit requestConnect(list);
+ */
}
ServerListDlg::~ServerListDlg() {