Make BufferInfo qDebug()able as per EgS' request.
[quassel.git] / src / common / signalproxy.cpp
index b7ac968..c30fe4f 100644 (file)
@@ -5,7 +5,7 @@
  *   This program is free software; you can redistribute it and/or modify  *
  *   it under the terms of the GNU General Public License as published by  *
  *   the Free Software Foundation; either version 2 of the License, or     *
- *   (at your option) any later version.                                   *
+ *   (at your option) version 3.                                           *
  *                                                                         *
  *   This program is distributed in the hope that it will be useful,       *
  *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
  *   along with this program; if not, write to the                         *
  *   Free Software Foundation, Inc.,                                       *
  *   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
- ***************************************************************************
- *   SignalProxy has been inspired by QxtRPCPeer, part of libqxt,          *
- *   the Qt eXTension Library <http://www.libqxt.org>. We would like to    *
- *   thank Arvid "aep" Picciani and Adam "ahigerd" Higerd for providing    *
- *   QxtRPCPeer, valuable input and the genius idea to (ab)use Qt's        *
- *   Meta Object System for transmitting signals over the network.         *
- *                                                                         *
- *   To make contribution back into libqxt possible, redistribution and    *
- *   modification of this file is additionally allowed under the terms of  *
- *   the Common Public License, version 1.0, as published by IBM.          *
  ***************************************************************************/
 
 #include "signalproxy.h"
@@ -337,7 +327,6 @@ const QByteArray &SignalProxy::methodName(QObject *obj, int methodId) {
 
 void SignalProxy::setSyncMap(QObject *obj) {
   const QMetaObject *meta = obj->metaObject();
-
   QHash<int, int> syncMap;
   
   QList<int> slotIndexes;
@@ -577,8 +566,17 @@ void SignalProxy::handleSync(QVariantList params) {
 
   QObject *receiver = _syncSlave[className][objectName];
   if(!syncMap(receiver).contains(signalId)) {
-    qWarning() << "received Sync Call with invalid SignalId" << className << objectName << signalId;
-  }
+    const QMetaObject *meta = receiver->metaObject();
+    QString signalName;
+    if(signalId < meta->methodCount())
+      signalName = QString(meta->method(signalId).signature());
+    else
+      signalName = QString::number(signalId);
+    
+    qWarning() << "received Sync Call for Object" << receiver
+              << "- no matching Slot for Signal:" << signalName;
+    return;
+   }
   int slotId = syncMap(receiver)[signalId];
   if(!invokeSlot(receiver, slotId, params))
     qWarning("SignalProxy::handleSync(): invokeMethod for \"%s\" failed ", methodName(receiver, slotId).constData());
@@ -593,7 +591,7 @@ void SignalProxy::handleInitRequest(QIODevice *sender, const QVariantList &param
   
   QByteArray className(params[0].toByteArray());
   QString objectName(params[1].toString());
-
+  
   if(!_syncSlave.contains(className)) {
     qWarning() << "SignalProxy::handleInitRequest() received initRequest for unregistered Class:"
               << className;
@@ -605,7 +603,7 @@ void SignalProxy::handleInitRequest(QIODevice *sender, const QVariantList &param
               << className << objectName;
     return;
   }
-
+  
   QObject *obj = _syncSlave[className][objectName];
 
   QVariantList params_;
@@ -821,4 +819,14 @@ void SignalProxy::dumpProxyStats() {
   qDebug() << "number of Classes cached:" << _classInfo.count();
 }
 
+void SignalProxy::dumpSyncMap(QObject *object) {
+  const QMetaObject *meta = object->metaObject();
+  qDebug() << "SignalProxy: SyncMap for Class" << meta->className();
 
+  QHash<int, int> syncMap_ = syncMap(object);
+  QHash<int, int>::const_iterator iter = syncMap_.constBegin();
+  while(iter != syncMap_.constEnd()) {
+    qDebug() << iter.key() << meta->method(iter.key()).signature() << "-->" << iter.value() << meta->method(iter.value()).signature();    
+    iter++;
+  }
+}