22 #include <dcopserver.h>
23 #include <dcopsignals.h>
25 template class TQPtrList<DCOPSignalConnection>;
27 DCOPSignals::DCOPSignals()
29 connections.setAutoDelete(
true);
38 DCOPSignals::emitSignal( DCOPConnection *conn,
const TQCString &_fun,
const TQByteArray &data,
bool excludeSelf)
42 int i = fun.find(
'#');
45 senderObj = fun.left(i);
49 DCOPSignalConnectionList *list = connections.find(fun);
51 for(DCOPSignalConnection *current = list->first(); current; current = list->next())
54 if (current->senderConn)
56 if (current->senderConn == conn)
59 else if (!current->sender.isEmpty())
61 if ((conn && current->sender == conn->appId) || (current->sender ==
"DCOPServer"))
69 if (!current->senderObj.isEmpty() &&
70 (current->senderObj != senderObj))
75 if (excludeSelf && (conn == current->recvConn))
79 the_server->sendMessage(current->recvConn, conn ? conn->appId : TQCString(
"DCOPServer"),
80 current->recvConn->appId, current->recvObj,
97 DCOPSignals::connectSignal(
const TQCString &sender,
const TQCString &senderObj,
98 const TQCString &signal,
99 DCOPConnection *conn,
const TQCString &receiverObj,
100 const TQCString &slot,
bool Volatile)
103 TQCString signalArgs, slotArgs;
105 i = signal.find(
'(');
106 if (i < 0)
return false;
107 signalArgs = signal.mid(i+1);
108 j = signalArgs.find(
')');
109 if (j < 0)
return false;
110 signalArgs.truncate(j);
112 if (i < 0)
return false;
113 slotArgs = slot.mid(i+1);
114 j = slotArgs.find(
')');
115 if (j < 0)
return false;
116 slotArgs.truncate(j);
118 if(signalArgs != slotArgs)
121 if (signalArgs.length() <= slotArgs.length())
123 if ((slotArgs.length() > 0) && (signalArgs[slotArgs.length()] !=
','))
125 if (signalArgs.left(slotArgs.length()) != slotArgs)
129 DCOPConnection *senderConn = 0;
132 senderConn = the_server->findApp(sender);
136 DCOPSignalConnection *current =
new DCOPSignalConnection;
137 current->sender = sender;
138 current->senderObj = senderObj;
139 current->senderConn = senderConn;
140 current->signal = signal;
141 current->recvConn = conn;
142 current->recvObj = receiverObj;
143 current->slot = slot;
145 DCOPSignalConnectionList *list = connections.find(signal);
148 list =
new DCOPSignalConnectionList;
149 connections.insert(signal, list);
152 list->append( current );
153 conn->signalConnectionList()->append(current);
154 if (senderConn && senderConn != conn)
155 senderConn->signalConnectionList()->append(current);
169 DCOPSignals::disconnectSignal(
const TQCString &sender,
const TQCString &senderObj,
170 const TQCString &signal,
171 DCOPConnection *conn,
const TQCString &receiverObj,
172 const TQCString &slot)
174 if (sender.isEmpty() && signal.isEmpty())
176 removeConnections(conn, receiverObj);
180 DCOPSignalConnectionList *list = connections.find(signal);
184 DCOPSignalConnection *
next = 0;
187 for(DCOPSignalConnection *current = list->first(); current; current = next)
191 if (current->recvConn != conn)
194 if (current->senderConn)
196 if (current->senderConn->appId != sender)
199 else if (current->sender != sender)
202 if (!senderObj.isEmpty() &&
203 (current->senderObj != senderObj))
206 if (!receiverObj.isEmpty() &&
207 (current->recvObj != receiverObj))
210 if (!slot.isEmpty() &&
211 (current->slot != slot))
215 list->removeRef(current);
216 conn->signalConnectionList()->removeRef(current);
217 if (current->senderConn)
218 current->senderConn->signalConnectionList()->removeRef(current);
231 DCOPSignals::removeConnections(DCOPConnection *conn,
const TQCString &obj)
233 DCOPSignalConnectionList *list = conn->_signalConnectionList;
237 DCOPSignalConnection *
next = 0;
239 for(DCOPSignalConnection *current = list->first(); current; current = next)
245 if ((current->senderConn == conn) && (current->senderObj != obj))
248 if ((current->recvConn == conn) && (current->recvObj != obj))
252 if (current->senderConn && (current->senderConn != conn))
253 current->senderConn->signalConnectionList()->removeRef(current);
255 if (current->recvConn != conn)
256 current->recvConn->signalConnectionList()->removeRef(current);
258 DCOPSignalConnectionList *signalList = connections.find(current->signal);
261 signalList->removeRef(current);
262 if (signalList->isEmpty())
263 connections.
remove(current->signal);
267 tqDebug(
"Error: Signal Connection was not in signalList!\n");
269 list->removeRef(current);
void remove(const KKeySequence &keySeq)
const TDEShortcut & next()