1 /***************************************************************************
2 * Copyright (C) 2005-07 by The Quassel IRC Development Team *
3 * devel@quassel-irc.org *
5 * This program is free software; you can redistribute it and/or modify *
6 * it under the terms of the GNU General Public License as published by *
7 * the Free Software Foundation; either version 2 of the License, or *
8 * (at your option) any later version. *
10 * This program is distributed in the hope that it will be useful, *
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
13 * GNU General Public License for more details. *
15 * You should have received a copy of the GNU General Public License *
16 * along with this program; if not, write to the *
17 * Free Software Foundation, Inc., *
18 * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
19 ***************************************************************************/
21 #include "signalproxy.h"
23 SignalProxy::SignalProxy(ProxyType _type, QIODevice *dev, QObject *parent) : QObject(parent), type(_type) {
26 qWarning() << tr("Device given for ProxyType == Server, ignoring...").toAscii();
33 SignalProxy::~SignalProxy() {
34 foreach(Connection conn, peers) {
35 conn.peer->deleteLater(); conn.device->deleteLater();
39 void SignalProxy::addPeer(QIODevice *dev) {
40 if(type == Client && peers.count()) {
41 qWarning() << tr("Cannot add more than one peer to a SignalProxy in client mode!").toAscii();
46 conn.peer = new QxtRPCPeer(dev, QxtRPCPeer::Peer, this);
48 foreach(SlotDesc slot, attachedSlots) {
49 conn.peer->attachSlot(slot.rpcFunction, slot.recv, slot.slot);
51 foreach(SignalDesc sig, attachedSignals) {
52 conn.peer->attachSignal(sig.sender, sig.signal, sig.rpcFunction);
58 void SignalProxy::attachSignal(QObject* sender, const char* signal, const QByteArray& rpcFunction) {
59 foreach(Connection conn, peers) {
60 conn.peer->attachSignal(sender, signal, rpcFunction);
62 attachedSignals.append(SignalDesc(sender, signal, rpcFunction));
66 void SignalProxy::attachSlot(const QByteArray& rpcFunction, QObject* recv, const char* slot) {
67 foreach(Connection conn, peers) {
68 conn.peer->attachSlot(rpcFunction, recv, slot);
70 attachedSlots.append(SlotDesc(rpcFunction, recv, slot));
73 void SignalProxy::detachObject(QObject* obj) {
74 Q_ASSERT(false); // not done yet
75 foreach(Connection conn, peers) {
76 conn.peer->detachObject(obj);
78 // FIXME: delete attached signal/slot info