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

kdeui

  • kdeui
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 <kapplication.h>
24 #include <kaction.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  KActionCollection *m_actionCollection;
41  DCOPObject *m_parent;
42  TQCString m_prefix;
43  int m_pos;
44 };
45 
46 KDCOPActionProxy::KDCOPActionProxy( KActionCollection *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( KActionCollection *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<KAction *>KDCOPActionProxy::actions() const
71 {
72  if ( !d->m_actionCollection )
73  return TQValueList<KAction *>();
74 
75  return d->m_actionCollection->actions();
76 }
77 
78 KAction *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<KAction *> lst = actions();
100  TQValueList<KAction *>::ConstIterator it = lst.begin();
101  TQValueList<KAction *>::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  KAction *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, KAction *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 
KActionCollection
A managed set of KAction objects.
Definition: kactioncollection.h:78
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
DCOPRef
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::KDCOPActionProxy
KDCOPActionProxy(KActionCollection *actionCollection, DCOPObject *parent)
Constructs a dcop action proxy, being able to export the actions of the provided KActionCollection th...
Definition: kdcopactionproxy.cpp:46
KDCOPActionProxy::processAction
virtual bool processAction(const TQCString &obj, const TQCString &fun, const TQByteArray &data, TQCString &replyType, TQByteArray &replyData, KAction *action)
Called by the process method and takes care of processing the object request for an action object...
Definition: kdcopactionproxy.cpp:121
KAction::isPlugged
virtual bool isPlugged() const
returns whether the action is plugged into any container widget or not.
Definition: kaction.cpp:273
DCOPObject::objId
TQCString objId() const
KAction::activate
virtual void activate()
Emulate user's interaction programmatically, by activating the action.
Definition: kaction.cpp:1104
KDCOPPropertyProxy::functions
TQValueList< TQCString > functions()
KDCOPPropertyProxy::processPropertyRequest
bool processPropertyRequest(const TQCString &fun, const TQByteArray &data, TQCString &replyType, TQByteArray &replyData)
KDCOPActionProxy::action
virtual KAction * action(const char *name) const
Returns an action object with the given name.
Definition: kdcopactionproxy.cpp:78
KDCOPActionProxy::~KDCOPActionProxy
~KDCOPActionProxy()
Destructor.
Definition: kdcopactionproxy.cpp:65
KAction
Class to encapsulate user-driven action or event.
Definition: kaction.h:202
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::actions
virtual TQValueList< KAction * > actions() const
Returns a list of exportable actions.
Definition: kdcopactionproxy.cpp:70
DCOPObject

kdeui

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

kdeui

Skip menu "kdeui"
  • 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 kdeui by doxygen 1.8.8
This website is maintained by Timothy Pearson.
KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. |