From: Marcus Eggenberger Date: Sun, 4 Nov 2007 16:04:37 +0000 (+0000) Subject: This Update is like 90% bugfixes. X-Git-Tag: 0.1.0~84 X-Git-Url: https://git.quassel-irc.org/?p=quassel.git;a=commitdiff_plain;h=0ff076706c3d353ec9b098b1eca270195288774e;ds=sidebyside This Update is like 90% bugfixes. - IMPORTANT! - this version uses a new version of the SqlLite Schema (though only slitely different). The change to the schema _canno_ be done via an ALTER statement. Thus it is recommanded that you delete the current quassel-storage.sqlite DB-File, so it gets created again. - SignalProxy got a new method which is basically just for debuging/info purposes. use SignalProxy::dumpProxyStat() to see some infos of the current proxy situation on STDERR. - fixed a bug causing Segfaults - fixed a minor bug where Quassel treated channelnames not casesensitive and thus created a second buffer for them --- diff --git a/src/client/client.cpp b/src/client/client.cpp index 1d44fd60..2500b273 100644 --- a/src/client/client.cpp +++ b/src/client/client.cpp @@ -354,7 +354,6 @@ void Client::updateCoreConnectionProgress() { if(! channel->initialized()) numChannelsWaiting++; } - } if(numNetsWaiting > 0) { @@ -377,6 +376,12 @@ void Client::updateCoreConnectionProgress() { emit coreConnectionProgress(1,1); emit connected(); + + foreach(NetworkInfo *net, networkInfos()) { + disconnect(net, 0, this, SLOT(updateCoreConnectionProgress())); + } + + // signalProxy()->dumpProxyStats(); } void Client::recvSessionData(const QString &key, const QVariant &data) { diff --git a/src/common/ircchannel.cpp b/src/common/ircchannel.cpp index b9caebd0..29b618f4 100644 --- a/src/common/ircchannel.cpp +++ b/src/common/ircchannel.cpp @@ -107,6 +107,7 @@ void IrcChannel::join(IrcUser *ircuser) { if(!_userModes.contains(ircuser) && ircuser) { _userModes[ircuser] = QString(); ircuser->joinChannel(name()); + connect(ircuser, SIGNAL(destroyed()), this, SLOT(ircUserDestroyed())); // no emit here since the join is propagated by IrcUser } } @@ -175,10 +176,10 @@ void IrcChannel::removeUserMode(const QString &nick, const QString &mode) { // INIT SET USER MODES QVariantMap IrcChannel::initUserModes() const { QVariantMap usermodes; - QHashIterator iter(_userModes); - while(iter.hasNext()) { - iter.next(); + QHash::const_iterator iter = _userModes.constBegin(); + while(iter != _userModes.constEnd()) { usermodes[iter.key()->nick()] = iter.value(); + iter++; } return usermodes; } @@ -194,7 +195,7 @@ void IrcChannel::initSetUserModes(const QVariantMap &usermodes) { void IrcChannel::ircUserDestroyed() { IrcUser *ircUser = static_cast(sender()); Q_ASSERT(ircUser); - part(ircUser); + _userModes.remove(ircUser); } void IrcChannel::setInitialized() { diff --git a/src/common/ircchannel.h b/src/common/ircchannel.h index 2b438761..40ed3fbf 100644 --- a/src/common/ircchannel.h +++ b/src/common/ircchannel.h @@ -77,8 +77,6 @@ public slots: // init seters void initSetUserModes(const QVariantMap &usermodes); - void ircUserDestroyed(); - void setInitialized(); signals: @@ -88,7 +86,10 @@ signals: void userModeRemoved(QString nick, QString mode); void initDone(); - + +private slots: + void ircUserDestroyed(); + private: bool _initialized; QString _name; diff --git a/src/common/ircuser.cpp b/src/common/ircuser.cpp index 665b10ff..bc341437 100644 --- a/src/common/ircuser.cpp +++ b/src/common/ircuser.cpp @@ -38,6 +38,9 @@ IrcUser::IrcUser(const QString &hostmask, NetworkInfo *networkinfo) setObjectName(QString::number(networkInfo->networkId()) + "/" + IrcUser::hostmask()); } +IrcUser::~IrcUser() { +} + // ==================== // PUBLIC: // ==================== diff --git a/src/common/ircuser.h b/src/common/ircuser.h index 4fe3f37a..93ec9ebd 100644 --- a/src/common/ircuser.h +++ b/src/common/ircuser.h @@ -43,6 +43,7 @@ class IrcUser : public QObject { public: IrcUser(const QString &hostmask, NetworkInfo *networkInfo); + virtual ~IrcUser(); bool initialized() const; diff --git a/src/common/signalproxy.cpp b/src/common/signalproxy.cpp index 290e517f..c8f753da 100644 --- a/src/common/signalproxy.cpp +++ b/src/common/signalproxy.cpp @@ -50,6 +50,8 @@ public: int qt_metacall(QMetaObject::Call _c, int _id, void **_a); void attachSignal(int methodId, const QByteArray &func); + + int sigCount() const; private: SignalProxy* proxy; @@ -87,6 +89,11 @@ int SignalRelay::qt_metacall(QMetaObject::Call _c, int _id, void **_a) { return _id; } +int SignalRelay::sigCount() const { + // only for debuging purpose + return sigNames.count(); +} + void SignalRelay::attachSignal(int methodId, const QByteArray &func) { // we ride without safetybelts here... all checking for valid method etc pp has to be done by the caller // all connected methodIds are offset by the standard methodCount of QObject @@ -111,22 +118,19 @@ void SignalRelay::attachSignal(int methodId, const QByteArray &func) { // ==================== SignalProxy::SignalProxy(QObject* parent) : QObject(parent), - _proxyMode(Client), - _maxClients(-1) + _proxyMode(Client) { } SignalProxy::SignalProxy(ProxyMode mode, QObject* parent) : QObject(parent), - _proxyMode(mode), - _maxClients(-1) + _proxyMode(mode) { } SignalProxy::SignalProxy(ProxyMode mode, QIODevice* device, QObject* parent) : QObject(parent), - _proxyMode(mode), - _maxClients(-1) + _proxyMode(mode) { addPeer(device); } @@ -152,17 +156,6 @@ SignalProxy::ProxyMode SignalProxy::proxyMode() const { return _proxyMode; } -bool SignalProxy::maxPeersReached() { - if(_peerByteCount.empty()) - return false; - if(proxyMode() != Server) - return true; - if(_maxClients == -1) - return false; - - return (_maxClients <= _peerByteCount.count()); -} - bool SignalProxy::addPeer(QIODevice* iodev) { if(!iodev) return false; @@ -170,8 +163,8 @@ bool SignalProxy::addPeer(QIODevice* iodev) { if(_peerByteCount.contains(iodev)) return true; - if(maxPeersReached()) { - qWarning("SignalProxy: max peer count reached"); + if(proxyMode() == Client && !_peerByteCount.isEmpty()) { + qWarning("SignalProxy: only one peer allowed in client mode!"); return false; } @@ -330,6 +323,7 @@ bool SignalProxy::attachSlot(const QByteArray& sigName, QObject* recv, const cha void SignalProxy::detachSender() { // this is a slot so we can bypass the QueuedConnection + // and if someone is forcing direct connection in a multithreaded environment he's just nuts... _detachSignals(sender()); _detachSlots(sender()); } @@ -348,18 +342,18 @@ void SignalProxy::detachSignals(QObject* sender) { Q_ARG(QObject*, sender)); } -void SignalProxy::_detachSignals(QObject* sender) { - if(!_relayHash.contains(sender)) - return; - _relayHash.take(sender)->deleteLater(); -} - void SignalProxy::detachSlots(QObject* receiver) { QMetaObject::invokeMethod(this, "_detachSlots", Qt::QueuedConnection, Q_ARG(QObject*, receiver)); } +void SignalProxy::_detachSignals(QObject* sender) { + if(!_relayHash.contains(sender)) + return; + _relayHash.take(sender)->deleteLater(); +} + void SignalProxy::_detachSlots(QObject* receiver) { SlotHash::iterator slotIter = _attachedSlots.begin(); while(slotIter != _attachedSlots.end()) { @@ -370,7 +364,6 @@ void SignalProxy::_detachSlots(QObject* receiver) { } } - void SignalProxy::call(const char* signal, QVariant p1, QVariant p2, QVariant p3, QVariant p4, QVariant p5, QVariant p6, QVariant p7, QVariant p8, QVariant p9) { QByteArray func = QMetaObject::normalizedSignature(signal); QVariantList params; @@ -409,16 +402,11 @@ void SignalProxy::receivePeerSignal(const QVariant &packedFunc) { } void SignalProxy::dataAvailable() { + // yet again. it's a private slot. no need for checks. QIODevice* ioDev = qobject_cast(sender()); - Q_ASSERT(ioDev); - if(!_peerByteCount.contains(ioDev)) { - qWarning() << "SignalProxy: Unrecognized client object connected to dataAvailable"; - return; - } else { - QVariant var; - while(readDataFromDevice(ioDev, _peerByteCount[ioDev], var)) - receivePeerSignal(var); - } + QVariant var; + while(readDataFromDevice(ioDev, _peerByteCount[ioDev], var)) + receivePeerSignal(var); } void SignalProxy::writeDataToDevice(QIODevice *dev, const QVariant &item) { @@ -451,3 +439,22 @@ bool SignalProxy::readDataFromDevice(QIODevice *dev, quint32 &blockSize, QVarian blockSize = 0; return true; } + +void SignalProxy::dumpProxyStats() { + QString mode; + if(proxyMode() == Server) + mode = "Server"; + else + mode = "Client"; + + int sigCount = 0; + foreach(SignalRelay *relay, _relayHash.values()) + sigCount += relay->sigCount(); + + qDebug() << this; + qDebug() << " Proxy Mode:" << mode; + qDebug() << "attached sending Objects:" << _relayHash.count(); + qDebug() << " Number of Signals:" << sigCount; + qDebug() << " attached Slots:" << _attachedSlots.count(); + qDebug() << "number of Classes cached:" << _classInfo.count(); +} diff --git a/src/common/signalproxy.h b/src/common/signalproxy.h index 0b51125e..ebc4ae76 100644 --- a/src/common/signalproxy.h +++ b/src/common/signalproxy.h @@ -57,8 +57,6 @@ public: void setProxyMode(ProxyMode mode); ProxyMode proxyMode() const; - bool maxPeersReached(); - bool addPeer(QIODevice *iodev); void removePeer(QIODevice *iodev = 0); @@ -86,6 +84,8 @@ public: MethodNameHash methodNames; // QHash syncMap }; + + void dumpProxyStats(); private slots: void dataAvailable(); @@ -123,7 +123,6 @@ private: QHash _peerByteCount; ProxyMode _proxyMode; - int _maxClients; }; diff --git a/src/core/sqlitestorage.cpp b/src/core/sqlitestorage.cpp index 21d67cd1..d8dc9bad 100644 --- a/src/core/sqlitestorage.cpp +++ b/src/core/sqlitestorage.cpp @@ -56,7 +56,7 @@ SqliteStorage::SqliteStorage() { getBufferInfoQuery = new QSqlQuery(logDb); getBufferInfoQuery->prepare("SELECT bufferid FROM buffer " "JOIN network ON buffer.networkid = network.networkid " - "WHERE network.networkname = :networkname AND buffer.userid = :userid AND buffer.buffername = :buffername "); + "WHERE network.networkname = :networkname AND buffer.userid = :userid AND lower(buffer.buffername) = lower(:buffername)"); logMessageQuery = new QSqlQuery(logDb); logMessageQuery->prepare("INSERT INTO backlog (time, bufferid, type, flags, senderid, message) " @@ -163,7 +163,7 @@ void SqliteStorage::initDb() { "type INTEGER NOT NULL," "flags INTEGER NOT NULL," "senderid INTEGER NOT NULL," - "message TEXT NOT NULL)"); + "message TEXT)"); logDb.exec("CREATE TABLE coreinfo (" "updateid INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT," @@ -311,6 +311,7 @@ uint SqliteStorage::getNetworkId(UserId user, const QString &network) { BufferInfo SqliteStorage::getBufferInfo(UserId user, const QString &network, const QString &buffer) { BufferInfo bufferid; + // TODO: get rid of this hackaround uint networkId = getNetworkId(user, network); getBufferInfoQuery->bindValue(":networkname", network); getBufferInfoQuery->bindValue(":userid", user); @@ -319,6 +320,8 @@ BufferInfo SqliteStorage::getBufferInfo(UserId user, const QString &network, con if(!getBufferInfoQuery->first()) { createBuffer(user, network, buffer); + // TODO: get rid of this hackaround + networkId = getNetworkId(user, network); getBufferInfoQuery->exec(); if(getBufferInfoQuery->first()) { bufferid = BufferInfo(getBufferInfoQuery->value(0).toUInt(), networkId, 0, network, buffer);