• Skip to content
  • Skip to link menu
Trinity API Reference
  • Trinity API Reference
  • dcop
 

dcop

  • dcop
dcop_deadlock_test.cpp
1/*****************************************************************
2
3Copyright (c) 2004 Waldo Bastian <bastian@kde.org>
4
5Permission is hereby granted, free of charge, to any person obtaining a copy
6of this software and associated documentation files (the "Software"), to deal
7in the Software without restriction, including without limitation the rights
8to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9copies of the Software, and to permit persons to whom the Software is
10furnished to do so, subject to the following conditions:
11
12The above copyright notice and this permission notice shall be included in
13all copies or substantial portions of the Software.
14
15THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
19AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
20CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
21
22******************************************************************
23*/
24
25#include <dcop_deadlock_test.h>
26#include <dcopref.h>
27#include <tqtimer.h>
28#include <sys/time.h>
29#include <sys/types.h>
30#include <unistd.h>
31#include <stdlib.h>
32
33MyDCOPObject::MyDCOPObject(const TQCString &name, const TQCString &remoteName)
34: TQObject(0, name), DCOPObject(name), m_remoteName(remoteName)
35{
36 connect(&m_timer, TQ_SIGNAL(timeout()), this, TQ_SLOT(slotTimeout()));
37}
38
39bool MyDCOPObject::process(const TQCString &fun, const TQByteArray &data,
40TQCString& replyType, TQByteArray &replyData)
41{
42 if (fun == "function(TQCString)") {
43 TQDataStream args( data, IO_ReadOnly );
44 args >> m_remoteName;
45
46 struct timeval tv;
47 gettimeofday(&tv, 0);
48tqWarning("%s: function('%s') %d:%06d", name(), m_remoteName.data(), tv.tv_sec % 100, tv.tv_usec);
49
50 replyType = "TQString";
51 TQDataStream reply( replyData, IO_WriteOnly );
52 reply << TQString("Hey");
53 m_timer.start(1000, true);
54 return true;
55 }
56 return DCOPObject::process(fun, data, replyType, replyData);
57}
58
59void MyDCOPObject::slotTimeout()
60{
61 struct timeval tv;
62 gettimeofday(&tv, 0);
63tqWarning("%s: slotTimeout() %d:%06d", name(), tv.tv_sec % 100, tv.tv_usec);
64
65 m_timer.start(1000, true);
66 TQString result;
67 DCOPRef(m_remoteName, m_remoteName).call("function", TQCString(name())).get(result);
68 gettimeofday(&tv, 0);
69tqWarning("%s: Got result '%s' %d:%06d", name(), result.latin1(), tv.tv_sec % 100, tv.tv_usec);
70}
71
72int main(int argc, char **argv)
73{
74 TQCString myName = TDEApplication::dcopClient()->registerAs("testdcop", false);
75 TDEApplication app(argc, argv, "testdcop");
76
77 tqWarning("%d:I am '%s'", getpid(), app.dcopClient()->appId().data());
78
79 if (myName == "testdcop")
80 {
81 system("./dcop_deadlock_test testdcop&");
82 }
83
84 TQCString remoteApp;
85 if (argc == 2)
86 {
87 remoteApp = argv[1];
88 }
89 MyDCOPObject myObject(app.dcopClient()->appId(), remoteApp);
90
91 if (!remoteApp.isEmpty())
92 myObject.slotTimeout();
93 app.exec();
94}
95
96#include "dcop_deadlock_test.moc"
DCOPClient::registerAs
TQCString registerAs(const TQCString &appId, bool addPID=true)
Registers at the DCOP server.
Definition: dcopclient.cpp:983
DCOPObject
Provides an interface for receiving DCOP messages.
Definition: dcopobject.h:68
DCOPObject::process
virtual bool process(const TQCString &fun, const TQByteArray &data, TQCString &replyType, TQByteArray &replyData)
Dispatches a message.
Definition: dcopobject.cpp:166
DCOPRef
A DCOPRef(erence) encapsulates a remote DCOP object as a triple <app,obj,type> where type is optional...
Definition: dcopref.h:279
DCOPRef::call
DCOPReply call(const TQCString &fun)
Calls the function fun on the object referenced by this reference.
Definition: dcopref.h:417
DCOPReply::get
bool get(T &t, const char *tname)
Retrieves the value from the type T.
Definition: dcopref.h:70
TDEApplication
TDEApplication::dcopClient
static DCOPClient * dcopClient()
TDEStdAccel::name
TQString name(StdAccel id)

dcop

Skip menu "dcop"
  • Main Page
  • Modules
  • Class Hierarchy
  • Alphabetical List
  • Class List
  • File List
  • Class Members
  • Related Pages

dcop

Skip menu "dcop"
  • arts
  • dcop
  • dnssd
  • interfaces
  •   kspeech
  •     interface
  •     library
  •   tdetexteditor
  • kate
  • kded
  • kdoctools
  • kimgio
  • kjs
  • libtdemid
  • libtdescreensaver
  • tdeabc
  • tdecmshell
  • tdecore
  • tdefx
  • tdehtml
  • tdeinit
  • tdeio
  •   bookmarks
  •   httpfilter
  •   kpasswdserver
  •   kssl
  •   tdefile
  •   tdeio
  •   tdeioexec
  • tdeioslave
  •   http
  • tdemdi
  •   tdemdi
  • tdenewstuff
  • tdeparts
  • tdeprint
  • tderandr
  • tderesources
  • tdespell2
  • tdesu
  • tdeui
  • tdeunittest
  • tdeutils
  • tdewallet
Generated for dcop by doxygen 1.9.4
This website is maintained by Timothy Pearson.