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

tdeui

kdcopactionproxy.cpp

00001 /* This file is part of the KDE project
00002    Copyright (C) 1999 Simon Hausmann <hausmann@kde.org>
00003 
00004    This library is free software; you can redistribute it and/or
00005    modify it under the terms of the GNU Library General Public
00006    License as published by the Free Software Foundation; either
00007    version 2 of the License, or (at your option) any later version.
00008 
00009    This library is distributed in the hope that it will be useful,
00010    but WITHOUT ANY WARRANTY; without even the implied warranty of
00011    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00012    Library General Public License for more details.
00013 
00014    You should have received a copy of the GNU Library General Public License
00015    along with this library; see the file COPYING.LIB.  If not, write to
00016    the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
00017    Boston, MA 02110-1301, USA.
00018 */
00019 
00020 #include "kdcopactionproxy.h"
00021 
00022 #include <dcopclient.h>
00023 #include <tdeapplication.h>
00024 #include <tdeaction.h>
00025 #include <kdebug.h>
00026 #include <kdcoppropertyproxy.h>
00027 
00028 #include <ctype.h>
00029 
00030 class KDCOPActionProxy::KDCOPActionProxyPrivate
00031 {
00032 public:
00033   KDCOPActionProxyPrivate()
00034   {
00035   }
00036   ~KDCOPActionProxyPrivate()
00037   {
00038   }
00039 
00040   TDEActionCollection *m_actionCollection;
00041   DCOPObject *m_parent;
00042   TQCString m_prefix;
00043   int m_pos;
00044 };
00045 
00046 KDCOPActionProxy::KDCOPActionProxy( TDEActionCollection *actionCollection, DCOPObject *parent )
00047 {
00048   init( actionCollection, parent );
00049 }
00050 
00051 KDCOPActionProxy::KDCOPActionProxy( DCOPObject *parent )
00052 {
00053   init( 0, parent );
00054 }
00055 
00056 void KDCOPActionProxy::init( TDEActionCollection *collection, DCOPObject *parent )
00057 {
00058   d = new KDCOPActionProxyPrivate;
00059   d->m_actionCollection = collection;
00060   d->m_parent = parent;
00061   d->m_prefix = parent->objId() + "/action/";
00062   d->m_pos = d->m_prefix.length();
00063 }
00064 
00065 KDCOPActionProxy::~KDCOPActionProxy()
00066 {
00067   delete d;
00068 }
00069 
00070 TQValueList<TDEAction *>KDCOPActionProxy::actions() const
00071 {
00072   if ( !d->m_actionCollection )
00073     return TQValueList<TDEAction *>();
00074 
00075   return d->m_actionCollection->actions();
00076 }
00077 
00078 TDEAction *KDCOPActionProxy::action( const char *name ) const
00079 {
00080   if ( !d->m_actionCollection )
00081     return 0;
00082 
00083   return d->m_actionCollection->action( name );
00084 }
00085 
00086 TQCString KDCOPActionProxy::actionObjectId( const TQCString &name ) const
00087 {
00088   return d->m_prefix + name;
00089 }
00090 
00091 TQMap<TQCString,DCOPRef> KDCOPActionProxy::actionMap( const TQCString &appId ) const
00092 {
00093   TQMap<TQCString,DCOPRef> res;
00094 
00095   TQCString id = appId;
00096   if ( id.isEmpty() )
00097     id = kapp->dcopClient()->appId();
00098 
00099   TQValueList<TDEAction *> lst = actions();
00100   TQValueList<TDEAction *>::ConstIterator it = lst.begin();
00101   TQValueList<TDEAction *>::ConstIterator end = lst.end();
00102   for (; it != end; ++it )
00103     res.insert( (*it)->name(), DCOPRef( id, actionObjectId( (*it)->name() ) ) );
00104 
00105   return res;
00106 }
00107 
00108 bool KDCOPActionProxy::process( const TQCString &obj, const TQCString &fun, const TQByteArray &data,
00109                                 TQCString &replyType, TQByteArray &replyData )
00110 {
00111   if ( obj.left( d->m_pos ) != d->m_prefix )
00112     return false;
00113 
00114   TDEAction *act = action( obj.mid( d->m_pos ) );
00115   if ( !act )
00116     return false;
00117 
00118   return processAction( obj, fun, data, replyType, replyData, act );
00119 }
00120 
00121 bool KDCOPActionProxy::processAction( const TQCString &, const TQCString &fun, const TQByteArray &data,
00122                                       TQCString &replyType, TQByteArray &replyData, TDEAction *action )
00123 {
00124   if ( fun == "activate()" )
00125   {
00126     replyType = "void";
00127     action->activate();
00128     return true;
00129   }
00130 
00131   if ( fun == "isPlugged()" )
00132   {
00133     replyType = "bool";
00134     TQDataStream reply( replyData, IO_WriteOnly );
00135     reply << (TQ_INT8)action->isPlugged();
00136     return true;
00137   }
00138 
00139   if ( fun == "functions()" )
00140   {
00141     TQValueList<TQCString> res;
00142     res << "QCStringList functions()";
00143     res << "void activate()";
00144     res << "bool isPlugged()";
00145 
00146     res += KDCOPPropertyProxy::functions( action );
00147 
00148     replyType = "QCStringList";
00149     TQDataStream reply( replyData, IO_WriteOnly );
00150     reply << res;
00151     return true;
00152   }
00153 
00154   return KDCOPPropertyProxy::processPropertyRequest( fun, data, replyType, replyData, action );
00155 }
00156 
00157 void KDCOPActionProxy::virtual_hook( int id, void* data )
00158 { DCOPObjectProxy::virtual_hook( id, data ); }
00159 

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.6.3
This website is maintained by Timothy Pearson.