Removed broken autoconnect (for networks) -- how are we gonna do that anyways?
authorManuel Nickschas <sputnick@quassel-irc.org>
Tue, 7 Aug 2007 20:15:36 +0000 (20:15 +0000)
committerManuel Nickschas <sputnick@quassel-irc.org>
Tue, 7 Aug 2007 20:15:36 +0000 (20:15 +0000)
We should not wait for a client to connect...
Also I added Storage::renameUser() and a few signals.

src/client/client.cpp
src/core/coresession.cpp
src/core/sqlitestorage.cpp
src/core/sqlitestorage.h
src/core/storage.h
src/qtgui/serverlist.cpp

index 4170760..938d107 100644 (file)
@@ -176,7 +176,7 @@ void Client::coreSocketDisconnected() {
 }
 
 void Client::recvCoreState(const QVariant &state) {
 }
 
 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);
 
 }
   syncToCore(state);
 
 }
index 4c50221..ccfa2a1 100644 (file)
@@ -48,6 +48,17 @@ CoreSession::CoreSession(UserId uid, Storage *_storage) : user(uid), storage(_st
   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 &)));
   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() {
 }
 
 CoreSession::~CoreSession() {
index 7ee2e56..dda91b4 100644 (file)
@@ -201,13 +201,15 @@ UserId SqliteStorage::addUser(QString user, QString password) {
   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.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();
 
   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) {
 }
 
 void SqliteStorage::updateUser(UserId user, QString password) {
@@ -221,6 +223,15 @@ void SqliteStorage::updateUser(UserId user, QString password) {
   query.exec();
 }
 
   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();
 UserId SqliteStorage::validateUser(QString user, QString password) {
   QByteArray cryptopass = QCryptographicHash::hash(password.toUtf8(), QCryptographicHash::Sha1);
   cryptopass = cryptopass.toHex();
@@ -257,6 +268,7 @@ void SqliteStorage::delUser(UserId user) {
   query.bindValue(":userid", user);
   query.exec();
   // I hate the lack of foreign keys and on delete cascade... :(
   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) {
 }
 
 void SqliteStorage::createBuffer(UserId user, QString network, QString buffer) {
index 393050b..2d72b59 100644 (file)
@@ -48,6 +48,7 @@ class SqliteStorage : public Storage {
 
     virtual UserId addUser(QString user, QString password);
     virtual void updateUser(UserId user, QString password);
 
     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 UserId validateUser(QString user, QString password);
     virtual void delUser(UserId user);
 
index d143443..e66563b 100644 (file)
@@ -74,6 +74,12 @@ class Storage : public QObject {
      */
     virtual void updateUser(UserId user, QString password) = 0;
 
      */
     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
     //! Validate a username with a given password.
     /** \param user     The username to validate
      *  \param password The user's alleged password
@@ -147,8 +153,14 @@ class Storage : public QObject {
     virtual void importOldBacklog() = 0;
 
   signals:
     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);
     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 */
 
   public:
     /* Exceptions */
index b1b68ba..a374daf 100644 (file)
@@ -40,11 +40,11 @@ ServerListDlg::ServerListDlg(QWidget *parent) : QDialog(parent) {
   connect(Client::instance(), SIGNAL(sessionDataChanged(const QString &)), this, SLOT(updateNetworkTree()));
 
   settings.endGroup();
   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
   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()) {
   QStringList list;
   VarMap networks = Client::retrieveSessionData("Networks").toMap();
   foreach(QString net, networks.keys()) {
@@ -53,6 +53,7 @@ ServerListDlg::ServerListDlg(QWidget *parent) : QDialog(parent) {
     }
   }
   if(!list.isEmpty()) emit requestConnect(list);
     }
   }
   if(!list.isEmpty()) emit requestConnect(list);
+  */
 }
 
 ServerListDlg::~ServerListDlg() {
 }
 
 ServerListDlg::~ServerListDlg() {