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

dcop

  • dcop
dcopref.cpp
1/*****************************************************************
2
3Copyright (c) 1999 Preston Brown <pbrown@kde.org>
4Copyright (c) 1999 Matthias Ettrich <ettrich@kde.org>
5
6Permission is hereby granted, free of charge, to any person obtaining a copy
7of this software and associated documentation files (the "Software"), to deal
8in the Software without restriction, including without limitation the rights
9to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10copies of the Software, and to permit persons to whom the Software is
11furnished to do so, subject to the following conditions:
12
13The above copyright notice and this permission notice shall be included in
14all copies or substantial portions of the Software.
15
16THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
20AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
21CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
22
23******************************************************************/
24
25#include "dcopref.h"
26#include "dcopclient.h"
27#include "dcopobject.h"
28
29#include <tqdatastream.h>
30
31#define STR( s ) ( s.data() ? s.data() : "" )
32
33bool DCOPReply::typeCheck( const char* t )
34{
35 return typeCheck( t, true );
36}
37
38bool DCOPReply::typeCheck( const char* t, bool warn )
39{
40 if ( type == t )
41 return true;
42 if( warn
43 || strcmp( t, "<unknown>" )) // type not listed in dcoptypes.h
44 tqWarning( "WARNING: DCOPReply<%s>: cast to '%s' error",
45 STR( type ), t );
46 return false;
47}
48
49// this has to stay BC too even if private, because it's called from inlines
50DCOPReply DCOPRef::callInternal( const TQCString& fun, const TQCString& args, const TQByteArray& data )
51{
52 return callInternal( fun, args, data, NoEventLoop, -1 );
53}
54
55DCOPReply DCOPRef::callInternal( const TQCString& fun, const TQCString& args, const TQByteArray& data,
56 EventLoopFlag useEventLoop, int timeout )
57{
58 DCOPReply reply;
59 if ( isNull() ) {
60 tqWarning( "DCOPRef: call '%s' on null reference error",
61 STR( fun ) );
62 return reply;
63 }
64 TQCString sig = fun;
65 if ( fun.find('(') == -1 ) {
66 sig += args;
67 if( args.find( "<unknown" ) != -1 )
68 tqWarning("DCOPRef: unknown type error "
69 "<\"%s\",\"%s\">::call(\"%s\",%s",
70 STR(m_app), STR(m_obj), STR(fun), args.data()+1 );
71 }
72 DCOPClient* dc = dcopClient();
73 if ( !dc || !dc->isAttached() ) {
74 tqWarning( "DCOPRef::call(): no DCOP client or client not attached error" );
75 return reply;
76 }
77 dc->call( m_app, m_obj, sig, data, reply.type, reply.data, useEventLoop == UseEventLoop, timeout );
78 return reply;
79}
80
81bool DCOPRef::sendInternal( const TQCString& fun, const TQCString& args, const TQByteArray& data )
82{
83 if ( isNull() ) {
84 tqWarning( "DCOPRef: send '%s' on null reference error",
85 STR( fun ) );
86 return false;
87 }
88 Q_UNUSED( data );
89 TQCString sig = fun;
90 if ( fun.find('(') == -1 ) {
91 sig += args;
92 if( args.find( "<unknown" ) != -1 )
93 tqWarning("DCOPRef: unknown type error "
94 "<\"%s\",\"%s\">::send(\"%s\",%s",
95 STR(m_app), STR(m_obj), STR(fun), args.data()+1 );
96 }
97 DCOPClient* dc = dcopClient();
98 if ( !dc || !dc->isAttached() ) {
99 tqWarning( "DCOPRef::send(): no DCOP client or client not attached error" );
100 return false;
101 }
102 return dc->send( m_app, m_obj, sig, data );
103}
104
105DCOPRef::DCOPRef()
106 :d(0)
107{
108}
109
110DCOPRef::DCOPRef( const DCOPRef& ref )
111 :d( ref.d )
112{
113 m_app = ref.app();
114 m_obj = ref.obj();
115 m_type = ref.type();
116}
117
118DCOPRef::DCOPRef( DCOPObject *o )
119 : m_app( DCOPClient::mainClient() ? DCOPClient::mainClient()->appId() : TQCString() ),
120 m_obj( o->objId() ), m_type( o->interfaces().last() ), d(0)
121
122{
123}
124
125DCOPRef::DCOPRef( const TQCString& _app, const TQCString& obj )
126 : m_app( _app ), m_obj( obj ), d(0)
127{
128}
129
130DCOPRef::DCOPRef( const TQCString& _app, const TQCString& _obj, const TQCString& _type )
131 : m_app( _app ), m_obj( _obj ), m_type( _type ), d(0)
132{
133}
134
135bool DCOPRef::isNull() const
136{
137 return ( m_app.isNull() || m_obj.isNull() );
138}
139
140TQCString DCOPRef::app() const
141{
142 return m_app;
143}
144
145TQCString DCOPRef::obj() const
146{
147 return m_obj;
148}
149
150TQCString DCOPRef::object() const
151{
152 return m_obj;
153}
154
155
156TQCString DCOPRef::type() const
157{
158 return m_type;
159}
160
161void DCOPRef::setDCOPClient( DCOPClient* dc )
162{
163 d = (DCOPRefPrivate*) dc;
164}
165
166DCOPClient* DCOPRef::dcopClient() const
167{
168 return d ? (DCOPClient*)d : DCOPClient::mainClient();
169}
170
171DCOPRef& DCOPRef::operator=( const DCOPRef& ref )
172{
173 d = ref.d;
174 m_app = ref.app();
175 m_obj = ref.obj();
176 m_type = ref.type();
177 return *this;
178}
179
180void DCOPRef::setRef( const TQCString& _app, const TQCString& _obj )
181{
182 m_app = _app;
183 m_obj = _obj;
184 m_type = 0;
185}
186
187void DCOPRef::setRef( const TQCString& _app, const TQCString& _obj, const TQCString& _type )
188{
189 m_app = _app;
190 m_obj = _obj;
191 m_type = _type;
192}
193
194void DCOPRef::clear()
195{
196 m_app = 0;
197 m_obj = 0;
198 m_type = 0;
199}
200
201TQDataStream& operator<<( TQDataStream& str, const DCOPRef& ref )
202{
203 str << ref.app();
204 str << ref.obj();
205 str << ref.type();
206
207 return str;
208}
209
210TQDataStream& operator>>( TQDataStream& str, DCOPRef& ref )
211{
212 TQCString a, o, t;
213 str >> a >> o >> t;
214
215 ref.setRef( a, o, t );
216
217 return str;
218}
DCOPClient
Inter-process communication and remote procedure calls for KDE applications.
Definition: dcopclient.h:69
DCOPClient::send
bool send(const TQCString &remApp, const TQCString &remObj, const TQCString &remFun, const TQByteArray &data)
Sends a data block to the server.
Definition: dcopclient.cpp:1089
DCOPClient::isAttached
bool isAttached() const
Returns whether or not the client is attached to the server.
Definition: dcopclient.cpp:949
DCOPClient::call
bool call(const TQCString &remApp, const TQCString &remObj, const TQCString &remFun, const TQByteArray &data, TQCString &replyType, TQByteArray &replyData, bool useEventLoop, int timeout, bool forceRemote)
Performs a synchronous send and receive.
Definition: dcopclient.cpp:1786
DCOPClient::mainClient
static DCOPClient * mainClient()
Returns the application's main dcop client.
Definition: dcopclient.cpp:599
DCOPObject
Provides an interface for receiving DCOP messages.
Definition: dcopobject.h:68
DCOPRef
A DCOPRef(erence) encapsulates a remote DCOP object as a triple <app,obj,type> where type is optional...
Definition: dcopref.h:279
DCOPRef::dcopClient
DCOPClient * dcopClient() const
Returns the dcop client the reference operates on.
Definition: dcopref.cpp:166
DCOPRef::operator=
DCOPRef & operator=(const DCOPRef &)
Assignment operator.
Definition: dcopref.cpp:171
DCOPRef::type
TQCString type() const
Type of the referenced object.
Definition: dcopref.cpp:156
DCOPRef::obj
TQCString obj() const
Object ID of the referenced object.
Definition: dcopref.cpp:145
DCOPRef::clear
void clear()
Makes this a null reference.
Definition: dcopref.cpp:194
DCOPRef::object
TQCString object() const
Definition: dcopref.cpp:150
DCOPRef::DCOPRef
DCOPRef()
Creates a null reference.
Definition: dcopref.cpp:105
DCOPRef::setRef
void setRef(const TQCString &app, const TQCString &obj="")
Changes the referenced object.
Definition: dcopref.cpp:180
DCOPRef::app
TQCString app() const
Name of the application in which the object resides.
Definition: dcopref.cpp:140
DCOPRef::setDCOPClient
void setDCOPClient(DCOPClient *client)
Sets a specific dcop client for this reference.
Definition: dcopref.cpp:161
DCOPRef::isNull
bool isNull() const
Tests whether this is a null reference.
Definition: dcopref.cpp:135
DCOPReply
Represents the return value of a DCOPRef:call() or DCOPRef:send() invocation.
Definition: dcopref.h:45
DCOPReply::data
TQByteArray data
The serialized data.
Definition: dcopref.h:102
DCOPReply::type
TQCString type
The name of the type, or 0 if unknown.
Definition: dcopref.h:104
operator<<
kdbgstream & operator<<(const TQValueList< T > &list)

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.