dcop
dcopsignals.h
Go to the documentation of this file.00001 /* 00002 Copyright (c) 2000 Waldo Bastian <bastian@kde.org> 00003 00004 Permission is hereby granted, free of charge, to any person obtaining a copy 00005 of this software and associated documentation files (the "Software"), to deal 00006 in the Software without restriction, including without limitation the rights 00007 to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 00008 copies of the Software, and to permit persons to whom the Software is 00009 furnished to do so, subject to the following conditions: 00010 00011 The above copyright notice and this permission notice shall be included in 00012 all copies or substantial portions of the Software. 00013 00014 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 00015 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 00016 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 00017 AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN 00018 AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 00019 CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 00020 */ 00021 00022 #ifndef DCOPSIGNALS_H 00023 #define DCOPSIGNALS_H "$Id: dcopsignals.h 345236 2004-09-09 15:23:55Z dfaure $" 00024 00025 #include <qdict.h> 00026 #include <qasciidict.h> 00027 #include <qptrlist.h> 00028 #include <qstring.h> 00029 #include "kdelibs_export.h" 00030 00031 class DCOPConnection; 00032 00037 class DCOP_EXPORT DCOPSignalConnection 00038 { 00039 public: 00040 QCString sender; // Sender client, empty means any client 00041 DCOPConnection *senderConn; //Sender client. 00042 QCString senderObj; // Object that sends the signal. 00043 QCString signal; // Signal name. Connections are sorted on signal name. 00044 00045 DCOPConnection *recvConn; // Client that wants to receive the signal 00046 QCString recvObj; // Object that wants to receive the signal 00047 QCString slot; // Function to send to in the object. 00048 }; 00049 00051 class DCOP_EXPORT DCOPSignalConnectionList : public QPtrList<DCOPSignalConnection> 00052 { 00053 public: 00054 DCOPSignalConnectionList() { }; 00055 }; 00056 00060 class DCOP_EXPORT DCOPSignals 00061 { 00062 public: 00063 DCOPSignals(); 00064 00073 void emitSignal( DCOPConnection *conn, const QCString &fun, const QByteArray &data, bool excludeSelf); 00074 00089 bool connectSignal( const QCString &sender, const QCString &senderObj, 00090 const QCString &signal, 00091 DCOPConnection *conn, const QCString &receiverObj, 00092 const QCString &slot, bool Volatile); 00093 00103 bool disconnectSignal( const QCString &sender, const QCString &senderObj, 00104 const QCString &signal, 00105 DCOPConnection *conn, const QCString &receiverObj, 00106 const QCString &slot); 00107 00114 void removeConnections(DCOPConnection *conn, const QCString &obj=0); 00115 00116 00117 /* 00118 * The administration. 00119 * 00120 * All connections are sorted by "signal" and then inserted in the 00121 * administration as a list. 00122 * 00123 * connections[signal] gives a list of all connections related to 00124 * a given signal. The connections in this list may specify different 00125 * senders and receiving clients/objects. 00126 */ 00127 QAsciiDict<DCOPSignalConnectionList> connections; 00128 }; 00129 00130 // 00131 // connectSignal: 00132 // 00133 // Check whether signal and slot match wrt arguments. 00134 // A slot may ignore arguments from the signal. 00135 // 00136 // If volatile 00137 // then lookup senderConn... 00138 // If not found? 00139 // then return false 00140 // Create DCOPSignalConnection. 00141 // Add DCOPSignalConnection to "connections". 00142 // Add DCOPSignalConnection to conn->connectionList() 00143 // If volatile 00144 // then Add DCOPSignalConnection to senderConn->connectionList() 00145 // Return true 00146 00147 00148 // removeConnections: 00149 // 00150 // For each DCOPSignalConnection in conn->connectionList 00151 // if DCOPSignalConnection->sender == conn->appId 00152 // then remove DCOPSignalConnection from DCOPSIgnalConnection->conn 00153 // if DCOPSignalConnection->conn == conn 00154 // then.. this is ugly.. remove DCOPSignalConnection from DCOPSignalConnection->sender 00155 // WARNING: Take care when sender and conn are the same client! 00156 // Remove DCOPSignalConnection from connections[DCOPSignalConnection->signal] 00157 00158 #endif