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

tdeui

  • tdeui
kdcopactionproxy.cpp
1 /* This file is part of the KDE project
2  Copyright (C) 1999 Simon Hausmann <hausmann@kde.org>
3 
4  This library is free software; you can redistribute it and/or
5  modify it under the terms of the GNU Library General Public
6  License as published by the Free Software Foundation; either
7  version 2 of the License, or (at your option) any later version.
8 
9  This library is distributed in the hope that it will be useful,
10  but WITHOUT ANY WARRANTY; without even the implied warranty of
11  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12  Library General Public License for more details.
13 
14  You should have received a copy of the GNU Library General Public License
15  along with this library; see the file COPYING.LIB. If not, write to
16  the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
17  Boston, MA 02110-1301, USA.
18 */
19 
20 #include "kdcopactionproxy.h"
21 
22 #include <dcopclient.h>
23 #include <tdeapplication.h>
24 #include <tdeaction.h>
25 #include <kdebug.h>
26 #include <kdcoppropertyproxy.h>
27 
28 #include <ctype.h>
29 
30 class KDCOPActionProxy::KDCOPActionProxyPrivate
31 {
32 public:
33  KDCOPActionProxyPrivate()
34  {
35  }
36  ~KDCOPActionProxyPrivate()
37  {
38  }
39 
40  TDEActionCollection *m_actionCollection;
41  DCOPObject *m_parent;
42  TQCString m_prefix;
43  int m_pos;
44 };
45 
46 KDCOPActionProxy::KDCOPActionProxy( TDEActionCollection *actionCollection, DCOPObject *parent )
47 {
48  init( actionCollection, parent );
49 }
50 
51 KDCOPActionProxy::KDCOPActionProxy( DCOPObject *parent )
52 {
53  init( 0, parent );
54 }
55 
56 void KDCOPActionProxy::init( TDEActionCollection *collection, DCOPObject *parent )
57 {
58  d = new KDCOPActionProxyPrivate;
59  d->m_actionCollection = collection;
60  d->m_parent = parent;
61  d->m_prefix = parent->objId() + "/action/";
62  d->m_pos = d->m_prefix.length();
63 }
64 
65 KDCOPActionProxy::~KDCOPActionProxy()
66 {
67  delete d;
68 }
69 
70 TQValueList<TDEAction *>KDCOPActionProxy::actions() const
71 {
72  if ( !d->m_actionCollection )
73  return TQValueList<TDEAction *>();
74 
75  return d->m_actionCollection->actions();
76 }
77 
78 TDEAction *KDCOPActionProxy::action( const char *name ) const
79 {
80  if ( !d->m_actionCollection )
81  return 0;
82 
83  return d->m_actionCollection->action( name );
84 }
85 
86 TQCString KDCOPActionProxy::actionObjectId( const TQCString &name ) const
87 {
88  return d->m_prefix + name;
89 }
90 
91 TQMap<TQCString,DCOPRef> KDCOPActionProxy::actionMap( const TQCString &appId ) const
92 {
93  TQMap<TQCString,DCOPRef> res;
94 
95  TQCString id = appId;
96  if ( id.isEmpty() )
97  id = kapp->dcopClient()->appId();
98 
99  TQValueList<TDEAction *> lst = actions();
100  TQValueList<TDEAction *>::ConstIterator it = lst.begin();
101  TQValueList<TDEAction *>::ConstIterator end = lst.end();
102  for (; it != end; ++it )
103  res.insert( (*it)->name(), DCOPRef( id, actionObjectId( (*it)->name() ) ) );
104 
105  return res;
106 }
107 
108 bool KDCOPActionProxy::process( const TQCString &obj, const TQCString &fun, const TQByteArray &data,
109  TQCString &replyType, TQByteArray &replyData )
110 {
111  if ( obj.left( d->m_pos ) != d->m_prefix )
112  return false;
113 
114  TDEAction *act = action( obj.mid( d->m_pos ) );
115  if ( !act )
116  return false;
117 
118  return processAction( obj, fun, data, replyType, replyData, act );
119 }
120 
121 bool KDCOPActionProxy::processAction( const TQCString &, const TQCString &fun, const TQByteArray &data,
122  TQCString &replyType, TQByteArray &replyData, TDEAction *action )
123 {
124  if ( fun == "activate()" )
125  {
126  replyType = "void";
127  action->activate();
128  return true;
129  }
130 
131  if ( fun == "isPlugged()" )
132  {
133  replyType = "bool";
134  TQDataStream reply( replyData, IO_WriteOnly );
135  reply << (TQ_INT8)action->isPlugged();
136  return true;
137  }
138 
139  if ( fun == "functions()" )
140  {
141  TQValueList<TQCString> res;
142  res << "QCStringList functions()";
143  res << "void activate()";
144  res << "bool isPlugged()";
145 
146  res += KDCOPPropertyProxy::functions( action );
147 
148  replyType = "QCStringList";
149  TQDataStream reply( replyData, IO_WriteOnly );
150  reply << res;
151  return true;
152  }
153 
154  return KDCOPPropertyProxy::processPropertyRequest( fun, data, replyType, replyData, action );
155 }
156 
157 void KDCOPActionProxy::virtual_hook( int id, void* data )
158 { DCOPObjectProxy::virtual_hook( id, data ); }
159 
DCOPObject
DCOPObject::objId
TQCString objId() const
DCOPRef
KDCOPActionProxy::~KDCOPActionProxy
~KDCOPActionProxy()
Destructor.
Definition: kdcopactionproxy.cpp:65
KDCOPActionProxy::actionObjectId
virtual TQCString actionObjectId(const TQCString &name) const
Use this method to retrieve a DCOP object id for an action with the given name.
Definition: kdcopactionproxy.cpp:86
KDCOPActionProxy::actionMap
virtual TQMap< TQCString, DCOPRef > actionMap(const TQCString &appId=TQCString()) const
Returns a map of all exported actions, with the action name as keys and a global DCOP reference as da...
Definition: kdcopactionproxy.cpp:91
KDCOPActionProxy::processAction
virtual bool processAction(const TQCString &obj, const TQCString &fun, const TQByteArray &data, TQCString &replyType, TQByteArray &replyData, TDEAction *action)
Called by the process method and takes care of processing the object request for an action object.
Definition: kdcopactionproxy.cpp:121
KDCOPActionProxy::action
virtual TDEAction * action(const char *name) const
Returns an action object with the given name.
Definition: kdcopactionproxy.cpp:78
KDCOPActionProxy::actions
virtual TQValueList< TDEAction * > actions() const
Returns a list of exportable actions.
Definition: kdcopactionproxy.cpp:70
KDCOPActionProxy::KDCOPActionProxy
KDCOPActionProxy(TDEActionCollection *actionCollection, DCOPObject *parent)
Constructs a dcop action proxy, being able to export the actions of the provided TDEActionCollection ...
Definition: kdcopactionproxy.cpp:46
KDCOPActionProxy::process
virtual bool process(const TQCString &obj, const TQCString &fun, const TQByteArray &data, TQCString &replyType, TQByteArray &replyData)
Internal reimplementation of DCOPObjectProxy::process .
Definition: kdcopactionproxy.cpp:108
KDCOPPropertyProxy::functions
TQValueList< TQCString > functions()
KDCOPPropertyProxy::processPropertyRequest
bool processPropertyRequest(const TQCString &fun, const TQByteArray &data, TQCString &replyType, TQByteArray &replyData)
TDEActionCollection
A managed set of TDEAction objects.
Definition: tdeactioncollection.h:79
TDEAction
Class to encapsulate user-driven action or event.
Definition: tdeaction.h:203
TDEAction::activate
virtual void activate()
Emulate user's interaction programmatically, by activating the action.
Definition: tdeaction.cpp:1104
TDEAction::isPlugged
virtual bool isPlugged() const
returns whether the action is plugged into any container widget or not.
Definition: tdeaction.cpp:273

tdeui

Skip menu "tdeui"
  • Main Page
  • Namespace List
  • Class Hierarchy
  • Alphabetical List
  • Class List
  • File List
  • Namespace Members
  • Class Members
  • Related Pages

tdeui

Skip menu "tdeui"
  • 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 tdeui by doxygen 1.9.1
This website is maintained by Timothy Pearson.