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

arts

  • arts
  • kde
  • mcop-dcop
mcopdcopobject.cpp
1 /*
2  Copyright (c) 2001 Nikolas Zimmermann <wildfox@kde.org>
3 
4  This program is free software; you can redistribute it and/or modify
5  it under the terms of the GNU General Public License as published by
6  the Free Software Foundation; either version 2, or (at your option)
7  any later version.
8 
9  This program 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
12  GNU General Public License for more details.
13 
14  You should have received a copy of the GNU General Public License
15  along with this program; if not, write to the Free Software
16  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
17 */
18 
19 #include <kdebug.h>
20 
21 #include <core.h>
22 //#include <object.h>
23 //#include <reference.h>
24 #include <dynamicrequest.h>
25 
26 #include <tqmap.h>
27 #include <tqdatastream.h>
28 
29 using namespace std;
30 
31 #include "mcopdcoptools.h"
32 #include "mcopdcopobject.h"
33 
34 class MCOPDCOPObjectPrivate
35 {
36 public:
37  TQMap<TQCString, MCOPEntryInfo *> dynamicFunctions;
38 };
39 
40 MCOPDCOPObject::MCOPDCOPObject(TQCString name) : DCOPObject(name)
41 {
42  d = new MCOPDCOPObjectPrivate();
43 }
44 
45 MCOPDCOPObject::~MCOPDCOPObject()
46 {
47  delete d;
48 }
49 
50 QCStringList MCOPDCOPObject::functionsDynamic()
51 {
52  QCStringList returnList;
53 
54  TQMap<TQCString, MCOPEntryInfo *>::iterator it;
55  for(it = d->dynamicFunctions.begin(); it != d->dynamicFunctions.end(); ++it)
56  returnList.append(it.key());
57 
58  return returnList;
59 }
60 
61 Arts::Buffer *MCOPDCOPObject::callFunction(MCOPEntryInfo *entry, TQCString ifaceName, const TQByteArray &data)
62 {
63  Arts::Object workingObject = Arts::SubClass(string(ifaceName));
64  Arts::DynamicRequest request(workingObject);
65  request.method(string(entry->functionName()));
66 
67  if(entry->signatureList().size() > 0)
68  {
69  QCStringList list = entry->signatureList();
70 
71  QCStringList::iterator it;
72  for(it = list.begin(); it != list.end(); ++it)
73  {
74  TQCString param = *it;
75 
76  kdDebug() << "PARAM: " << param << endl;
77 
78  TQDataStream argStream(data, IO_ReadOnly);
79 
80  if(param == "long")
81  request.param(MCOPDCOPTools::getLong(argStream));
82  else if(param == "string")
83  request.param(MCOPDCOPTools::getString(argStream));
84  }
85  }
86 
87  Arts::AnyRef result;
88  if(!request.invoke(result))
89  return 0;
90 
91  Arts::Buffer *newBuffer = new Arts::Buffer();
92  result.write(newBuffer);
93 
94  return newBuffer;
95 }
96 
97 bool MCOPDCOPObject::processDynamic(const TQCString &fun, const TQByteArray &data, TQCString &replyType, TQByteArray &replyData)
98 {
99  TQMap<TQCString, MCOPEntryInfo *>::iterator it;
100  for(it = d->dynamicFunctions.begin(); it != d->dynamicFunctions.end(); ++it)
101  {
102  MCOPEntryInfo *entry = it.data();
103 
104  if((entry->functionName() + entry->signature()) == fun)
105  {
106  TQCString type = entry->functionType();
107 
108  if(type == "void")
109  {
110  replyType = type;
111 
112  Arts::Buffer *result = callFunction(entry, objId(), data);
113 
114  if(result != 0)
115  delete result;
116  }
117  else if(type == "string")
118  {
119  replyType = "TQCString";
120 
121  TQDataStream reply(replyData, IO_WriteOnly);
122  reply << "fooo!";
123  }
124  else if(type == "long")
125  {
126  replyType = type;
127 
128  long returnCode = -1;
129 
130  Arts::Buffer *result = callFunction(entry, objId(), data);
131 
132  if(result != 0)
133  {
134  returnCode = result->readLong();
135  delete result;
136  }
137 
138  TQDataStream reply(replyData, IO_WriteOnly);
139  reply << returnCode;
140  }
141 
142  return true;
143  }
144  }
145 
146  return false;
147 }
148 
149 void MCOPDCOPObject::addDynamicFunction(TQCString value, MCOPEntryInfo *entry)
150 {
151  d->dynamicFunctions.insert(value, entry);
152 }
std
kdDebug
kdbgstream kdDebug(int area=0)
endl
kndbgstream & endl(kndbgstream &s)

arts

Skip menu "arts"
  • Main Page
  • Alphabetical List
  • Class List
  • File List
  • Class Members
  • Related Pages

arts

Skip menu "arts"
  • arts
  • dcop
  • dnssd
  • interfaces
  •   kspeech
  •     interface
  •     library
  •   tdetexteditor
  • kate
  • kded
  • kdoctools
  • kimgio
  • kjs
  • libtdemid
  • libtdescreensaver
  •     tdecore
  • tdeabc
  • tdecmshell
  • tdecore
  • tdefx
  • tdehtml
  • tdeinit
  • tdeio
  •   bookmarks
  •   httpfilter
  •   kpasswdserver
  •   kssl
  • tdeioslave
  •   http
  •   tdefile
  •   tdeio
  •   tdeioexec
  • tdemdi
  •   tdemdi
  • tdenewstuff
  • tdeparts
  • tdeprint
  • tderandr
  • tderesources
  • tdespell2
  • tdesu
  • tdeui
  • tdeunittest
  • tdeutils
  • tdewallet
Generated for arts by doxygen 1.8.8
This website is maintained by Timothy Pearson.