25 #include <dcop_deadlock_test.h>
29 #include <sys/types.h>
33 MyDCOPObject::MyDCOPObject(
const TQCString &name,
const TQCString &remoteName)
34 : TQObject(0, name),
DCOPObject(name), m_remoteName(remoteName)
36 connect(&m_timer, TQT_SIGNAL(timeout()),
this, TQT_SLOT(slotTimeout()));
39 bool MyDCOPObject::process(
const TQCString &fun,
const TQByteArray &data,
40 TQCString& replyType, TQByteArray &replyData)
42 if (fun ==
"function(TQCString)") {
43 TQDataStream args( data, IO_ReadOnly );
48 tqWarning(
"%s: function('%s') %d:%06d", name(), m_remoteName.data(), tv.tv_sec % 100, tv.tv_usec);
50 replyType = TQSTRING_OBJECT_NAME_STRING;
51 TQDataStream reply( replyData, IO_WriteOnly );
52 reply << TQString(
"Hey");
53 m_timer.start(1000,
true);
59 void MyDCOPObject::slotTimeout()
63 tqWarning(
"%s: slotTimeout() %d:%06d", name(), tv.tv_sec % 100, tv.tv_usec);
65 m_timer.start(1000,
true);
67 DCOPRef(m_remoteName, m_remoteName).
call(
"function", TQCString(name())).
get(result);
69 tqWarning(
"%s: Got result '%s' %d:%06d", name(), result.latin1(), tv.tv_sec % 100, tv.tv_usec);
72 int main(
int argc,
char **argv)
74 TQCString myName = TDEApplication::dcopClient()->registerAs(
"testdcop",
false);
77 tqWarning(
"%d:I am '%s'", getpid(), app.dcopClient()->appId().data());
79 if (myName ==
"testdcop")
81 system(
"./dcop_deadlock_test testdcop&");
89 MyDCOPObject myObject(app.dcopClient()->appId(), remoteApp);
91 if (!remoteApp.isEmpty())
92 myObject.slotTimeout();
96 #include "dcop_deadlock_test.moc"
A DCOPRef(erence) encapsulates a remote DCOP object as a triple
where type is optional...
virtual bool process(const TQCString &fun, const TQByteArray &data, TQCString &replyType, TQByteArray &replyData)
Dispatches a message.
DCOPReply call(const TQCString &fun)
Calls the function fun on the object referenced by this reference.
bool get(T &t, const char *tname)
Retrieves the value from the type T.
Provides an interface for receiving DCOP messages.