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

dcop

  • dcop
dcopref.cpp
1 /*****************************************************************
2 
3 Copyright (c) 1999 Preston Brown <pbrown@kde.org>
4 Copyright (c) 1999 Matthias Ettrich <ettrich@kde.org>
5 
6 Permission is hereby granted, free of charge, to any person obtaining a copy
7 of this software and associated documentation files (the "Software"), to deal
8 in the Software without restriction, including without limitation the rights
9 to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 copies of the Software, and to permit persons to whom the Software is
11 furnished to do so, subject to the following conditions:
12 
13 The above copyright notice and this permission notice shall be included in
14 all copies or substantial portions of the Software.
15 
16 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
20 AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
21 CONNECTION 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 
33 bool DCOPReply::typeCheck( const char* t )
34 {
35  return typeCheck( t, true );
36 }
37 
38 bool 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  qWarning( "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
50 DCOPReply DCOPRef::callInternal( const TQCString& fun, const TQCString& args, const TQByteArray& data )
51 {
52  return callInternal( fun, args, data, NoEventLoop, -1 );
53 }
54 
55 DCOPReply DCOPRef::callInternal( const TQCString& fun, const TQCString& args, const TQByteArray& data,
56  EventLoopFlag useEventLoop, int timeout )
57 {
58  DCOPReply reply;
59  if ( isNull() ) {
60  qWarning( "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  qWarning("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  qWarning( "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 
81 bool DCOPRef::sendInternal( const TQCString& fun, const TQCString& args, const TQByteArray& data )
82 {
83  if ( isNull() ) {
84  qWarning( "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  qWarning("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  qWarning( "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 
105 DCOPRef::DCOPRef()
106  :d(0)
107 {
108 }
109 
110 DCOPRef::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 
118 DCOPRef::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 
125 DCOPRef::DCOPRef( const TQCString& _app, const TQCString& obj )
126  : m_app( _app ), m_obj( obj ), d(0)
127 {
128 }
129 
130 DCOPRef::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 
135 bool DCOPRef::isNull() const
136 {
137  return ( m_app.isNull() || m_obj.isNull() );
138 }
139 
140 TQCString DCOPRef::app() const
141 {
142  return m_app;
143 }
144 
145 TQCString DCOPRef::obj() const
146 {
147  return m_obj;
148 }
149 
150 TQCString DCOPRef::object() const
151 {
152  return m_obj;
153 }
154 
155 
156 TQCString DCOPRef::type() const
157 {
158  return m_type;
159 }
160 
161 void DCOPRef::setDCOPClient( DCOPClient* dc )
162 {
163  d = (DCOPRefPrivate*) dc;
164 }
165 
166 DCOPClient* DCOPRef::dcopClient() const
167 {
168  return d ? (DCOPClient*)d : DCOPClient::mainClient();
169 }
170 
171 DCOPRef& 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 
180 void DCOPRef::setRef( const TQCString& _app, const TQCString& _obj )
181 {
182  m_app = _app;
183  m_obj = _obj;
184  m_type = 0;
185 }
186 
187 void 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 
194 void DCOPRef::clear()
195 {
196  m_app = 0;
197  m_obj = 0;
198  m_type = 0;
199 }
200 
201 TQDataStream& 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 
210 TQDataStream& 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 }

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
  •     interface
  •     library
  •   kspeech
  •   ktexteditor
  • kabc
  • kate
  • kcmshell
  • kdecore
  • kded
  • kdefx
  • kdeprint
  • kdesu
  • kdeui
  • kdoctools
  • khtml
  • kimgio
  • kinit
  • kio
  •   bookmarks
  •   httpfilter
  •   kfile
  •   kio
  •   kioexec
  •   kpasswdserver
  •   kssl
  • kioslave
  •   http
  • kjs
  • kmdi
  •   kmdi
  • knewstuff
  • kparts
  • krandr
  • kresources
  • kspell2
  • kunittest
  • kutils
  • kwallet
  • libkmid
  • libkscreensaver
Generated for dcop by doxygen 1.8.1.2
This website is maintained by Timothy Pearson.
KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. |