24 #include <dynamicrequest.h>
27 #include <tqdatastream.h>
31 #include "mcopdcoptools.h"
32 #include "mcopdcopobject.h"
34 class MCOPDCOPObjectPrivate
37 TQMap<TQCString, MCOPEntryInfo *> dynamicFunctions;
40 MCOPDCOPObject::MCOPDCOPObject(TQCString name) : DCOPObject(
name)
42 d =
new MCOPDCOPObjectPrivate();
45 MCOPDCOPObject::~MCOPDCOPObject()
50 QCStringList MCOPDCOPObject::functionsDynamic()
52 QCStringList returnList;
54 TQMap<TQCString, MCOPEntryInfo *>::iterator it;
55 for(it = d->dynamicFunctions.begin(); it != d->dynamicFunctions.end(); ++it)
56 returnList.append(it.key());
61 Arts::Buffer *MCOPDCOPObject::callFunction(MCOPEntryInfo *entry, TQCString ifaceName,
const TQByteArray &data)
63 Arts::Object workingObject = Arts::SubClass(
string(ifaceName));
64 Arts::DynamicRequest request(workingObject);
65 request.method(
string(entry->functionName()));
67 if(entry->signatureList().size() > 0)
69 QCStringList list = entry->signatureList();
71 QCStringList::iterator it;
72 for(it = list.begin(); it != list.end(); ++it)
74 TQCString param = *it;
78 TQDataStream argStream(data, IO_ReadOnly);
81 request.param(MCOPDCOPTools::getLong(argStream));
82 else if(param ==
"string")
83 request.param(MCOPDCOPTools::getString(argStream));
88 if(!request.invoke(result))
91 Arts::Buffer *newBuffer =
new Arts::Buffer();
92 result.write(newBuffer);
97 bool MCOPDCOPObject::processDynamic(
const TQCString &fun,
const TQByteArray &data, TQCString &replyType, TQByteArray &replyData)
99 TQMap<TQCString, MCOPEntryInfo *>::iterator it;
100 for(it = d->dynamicFunctions.begin(); it != d->dynamicFunctions.end(); ++it)
102 MCOPEntryInfo *entry = it.data();
104 if((entry->functionName() + entry->signature()) == fun)
106 TQCString type = entry->functionType();
112 Arts::Buffer *result = callFunction(entry, objId(), data);
117 else if(type ==
"string")
119 replyType =
"TQCString";
121 TQDataStream reply(replyData, IO_WriteOnly);
124 else if(type ==
"long")
128 long returnCode = -1;
130 Arts::Buffer *result = callFunction(entry, objId(), data);
134 returnCode = result->readLong();
138 TQDataStream reply(replyData, IO_WriteOnly);
149 void MCOPDCOPObject::addDynamicFunction(TQCString value, MCOPEntryInfo *entry)
151 d->dynamicFunctions.insert(value, entry);
kndbgstream & endl(kndbgstream &s)
kdbgstream kdDebug(int area=0)
TQString name(StdAccel id)