summaryrefslogtreecommitdiffstats
path: root/arts/kde/mcop-dcop
diff options
context:
space:
mode:
Diffstat (limited to 'arts/kde/mcop-dcop')
-rw-r--r--arts/kde/mcop-dcop/Makefile.am20
-rw-r--r--arts/kde/mcop-dcop/kmcop.cpp171
-rw-r--r--arts/kde/mcop-dcop/kmcop.desktop90
-rw-r--r--arts/kde/mcop-dcop/kmcop.h50
-rw-r--r--arts/kde/mcop-dcop/mcopdcopobject.cpp152
-rw-r--r--arts/kde/mcop-dcop/mcopdcopobject.h89
-rw-r--r--arts/kde/mcop-dcop/mcopdcoptools.h47
7 files changed, 619 insertions, 0 deletions
diff --git a/arts/kde/mcop-dcop/Makefile.am b/arts/kde/mcop-dcop/Makefile.am
new file mode 100644
index 000000000..6e2b90eac
--- /dev/null
+++ b/arts/kde/mcop-dcop/Makefile.am
@@ -0,0 +1,20 @@
+
+INCLUDES= -I$(includedir)/arts -I$(top_srcdir)/arts/kde $(all_includes)
+
+bin_PROGRAMS=
+lib_LTLIBRARIES =
+kdeinit_LTLIBRARIES = kmcop.la
+
+kmcop_la_SOURCES = mcopdcopobject.cpp kmcop.cpp kmcop.skel
+kmcop_la_LIBADD = ../libartskde.la
+kmcop_la_LDFLAGS = $(all_libraries) -module -avoid-version
+kmcop_la_METASOURCES = AUTO
+
+noinst_HEADERS = kmcop.h
+
+kdelnkdir = $(kde_servicesdir)
+kdelnk_DATA = kmcop.desktop
+
+messages:
+ $(XGETTEXT) kmcop.cpp -o $(podir)/kmcop.pot
+
diff --git a/arts/kde/mcop-dcop/kmcop.cpp b/arts/kde/mcop-dcop/kmcop.cpp
new file mode 100644
index 000000000..22e19dc9d
--- /dev/null
+++ b/arts/kde/mcop-dcop/kmcop.cpp
@@ -0,0 +1,171 @@
+/*
+ Copyright (c) 2001 Nikolas Zimmermann <wildfox@kde.org>
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2, or (at your option)
+ any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+*/
+
+#include <kdebug.h>
+#include <kuniqueapplication.h>
+#include <kaboutdata.h>
+#include <kcmdlineargs.h>
+#include <klocale.h>
+#include <dcopclient.h>
+
+#include <qvaluelist.h>
+#include <qcstring.h>
+
+#include <kartsdispatcher.h>
+#include <soundserver.h>
+#include <dispatcher.h>
+#include <object.h>
+#include <core.h>
+
+#include "mcopdcopobject.h"
+
+#include "kmcop.moc"
+
+using namespace Arts;
+using namespace std;
+
+class KMCOPPrivate
+{
+public:
+ MCOPInfo mcopInfo;
+ QPtrList<MCOPDCOPObject> list;
+};
+
+int main(int argc, char **argv)
+{
+ KAboutData aboutdata("kmcop", I18N_NOOP("KMCOP"),
+ "0.1", I18N_NOOP("KDE MCOP-DCOP Bridge"),
+ KAboutData::License_GPL, "(C) 2001, Nikolas Zimmermann");
+ aboutdata.addAuthor("Nikolas Zimmermann", I18N_NOOP("Author"), "wildfox@kde.org");
+
+ KCmdLineArgs::init(argc, argv, &aboutdata);
+ KUniqueApplication::addCmdLineOptions();
+
+ if(!KUniqueApplication::start())
+ {
+ kdDebug() << "Running kmcop found" << endl;
+ return 0;
+ }
+
+ KUniqueApplication app;
+ app.disableSessionManagement();
+
+ KArtsDispatcher dispatcher;
+
+ KMCOP notify;
+ app.dcopClient()->setDefaultObject("arts");
+ app.dcopClient()->setDaemonMode(true);
+
+ return app.exec();
+}
+
+KMCOP::KMCOP() : QObject(), DCOPObject("arts")
+{
+ d = new KMCOPPrivate();
+ d->mcopInfo = Reference("global:Arts_MCOPInfo");
+ d->list.setAutoDelete(true);
+}
+
+KMCOP::~KMCOP()
+{
+ delete d;
+}
+
+int KMCOP::objectCount()
+{
+ return d->mcopInfo.objectCount();
+}
+
+QCString KMCOP::correctType(const QCString &str)
+{
+ if(str == "string")
+ return "QCString";
+ return str;
+}
+
+void KMCOP::addInterfacesHackHackHack()
+{
+ for(int i = 0; i <= objectCount(); i++)
+ {
+ Arts::Object obj = d->mcopInfo.objectForNumber(i);
+
+ if(!obj.isNull())
+ {
+ QCString interfaceName = obj._interfaceName().c_str();
+
+ if(interfaceName != "Arts::TraderOffer")
+ {
+ Arts::InterfaceRepo ifaceRepo = Dispatcher::the()->interfaceRepo();
+
+ MCOPDCOPObject *interface = new MCOPDCOPObject(interfaceName);
+ d->list.append(interface);
+
+ InterfaceDef ifaceDef = ifaceRepo.queryInterface(string(interfaceName));
+ vector<MethodDef> ifaceMethods = ifaceDef.methods;
+
+ vector<MethodDef>::iterator ifaceMethodsIterator;
+ for(ifaceMethodsIterator = ifaceMethods.begin(); ifaceMethodsIterator != ifaceMethods.end(); ifaceMethodsIterator++)
+ {
+ QCString function, signature;
+
+ MCOPEntryInfo *entry = new MCOPEntryInfo();
+
+ MethodDef currentMethod = *ifaceMethodsIterator;
+ vector<ParamDef> currentParameters = currentMethod.signature;
+
+ QCString newType = correctType(QCString(currentMethod.type.c_str()));
+
+ entry->setFunctionType(newType);
+ entry->setFunctionName(QCString(currentMethod.name.c_str()));
+
+ function = entry->functionType() + QCString(" ") + entry->functionName() + QCString("(");
+
+ signature = QCString("(");
+
+ QCStringList signatureList;
+
+ vector<ParamDef>::iterator methodParametersIterator;
+ for(methodParametersIterator = currentParameters.begin(); methodParametersIterator != currentParameters.end(); methodParametersIterator++)
+ {
+ ParamDef parameter = *methodParametersIterator;
+ if(methodParametersIterator != currentParameters.begin())
+ {
+ function += QCString(", ");
+ signature += QCString(",");
+ }
+
+ QCString correctParameter = correctType(QCString(parameter.type.c_str()));
+
+ function += correctParameter;
+ signature += correctParameter;
+
+ signatureList.append(QCString(parameter.type.c_str()));
+ }
+
+ function += QCString(")");
+ signature += QCString(")");
+
+ entry->setSignature(signature);
+ entry->setSignatureList(signatureList);
+
+ interface->addDynamicFunction(function, entry);
+ }
+ }
+ }
+ }
+}
diff --git a/arts/kde/mcop-dcop/kmcop.desktop b/arts/kde/mcop-dcop/kmcop.desktop
new file mode 100644
index 000000000..4e6400ef1
--- /dev/null
+++ b/arts/kde/mcop-dcop/kmcop.desktop
@@ -0,0 +1,90 @@
+[Desktop Entry]
+Type=Service
+Name=KMCOP
+Name[hi]=के-एमकॉप
+Name[te]=కెఎంకాప్
+Exec=kmcop
+Comment=KDE MCOP-DCOP Bridge
+Comment[af]=KDE MCOP-DCOP Brug
+Comment[ar]=جسر KDE MCOP-DCOP
+Comment[az]=KDE MCOP-DCOP Körpüsü
+Comment[be]=Сувязь MCOP/DCOP
+Comment[bn]=কে.ডি.ই MCOP-DCOP ব্রিজ
+Comment[br]=Pont KDE MCOP-DCOP
+Comment[bs]=KDE MCOP-DCOP prelaz
+Comment[ca]=Connector MCOP-DCOP per al KDE
+Comment[cs]=KDE MCOP-DCOP můstek
+Comment[csb]=Mostk KDE MCOP-DCOP
+Comment[cy]=Pont MCOP-DCOP KDE
+Comment[da]=KDE MCOP-DCOP-bro
+Comment[de]=Verbindung zwischen MCOP und DCOP
+Comment[el]=Γέφυρα MCOP-DCOP του KDE
+Comment[eo]=KDE-ponto inter MCOP-DCOP
+Comment[es]=Puente KDE MCOP-DCOP
+Comment[et]=KDE MCOP-DCOP sild
+Comment[eu]=KDEren MCOP-DCOP zubia
+Comment[fa]=پل KDE MCOP-DCOP
+Comment[fi]=MCOP-DCOP -silta
+Comment[fo]=KDE MCOP-DCOP-brúgv
+Comment[fr]=Passerelle MCOP-DCOP pour KDE
+Comment[ga]=Droichead KDE idir MCOP agus DCOP
+Comment[gl]=Ponte MCOP-DCOP de KDE
+Comment[he]=גשר MCOP-DCOP ל־KDE
+Comment[hi]=केडीई MCOP-डीकॉप ब्रिज
+Comment[hr]=KDE most MCOP-DCOP
+Comment[hsb]=KDE MCOP-DCOP-móst
+Comment[hu]=KDE MCOP-DCOP összekötőprogram
+Comment[id]=Jembatan KDE MCOP-DCOP
+Comment[is]=KDE MCOP-DCOP brú
+Comment[it]=Ponte MCOP-DCOP per KDE
+Comment[ja]=KDE MCOP-DCOP ブリッジ
+Comment[ka]=KDE MCOP-DCOP ხიდი
+Comment[kk]=KDE MCOP-DCOP көпірі
+Comment[ko]=KDE MCOP-DCOP 브릿지
+Comment[lb]=KDE-MCOP-DCOP-Bréck
+Comment[lt]=KDE MCOP-DCOP tiltas
+Comment[lv]=KDE MCOP-DCOP Tilts
+Comment[mk]=KDE MCOP-DCOP Мост
+Comment[mn]=KDE-н MCOP ба DCOP хоорондын гүүр
+Comment[ms]=Jambatan KDE MCOP-DCOP
+Comment[mt]=Pont bejn MCOP u DCOP
+Comment[nb]=KDE MCOP-DCOP Bro
+Comment[nds]=KDE-Brüch twischen MCOP un DCOP
+Comment[ne]=KDE MCOP-DCOP ब्रिज
+Comment[nn]=MCOP-DCOP-bru for KDE
+Comment[nso]=Leporogo la KDE MCOP-DCOP
+Comment[pa]=KDE MCOP-DCOP ਪੁੱਲ
+Comment[pl]=Mostek MCOP-DCOP
+Comment[pt]=Ponte MCOP-DCOP para o KDE
+Comment[pt_BR]=Ligação KDE MCOP-DCOP
+Comment[ro]=Punte MCOP-DCOP KDE
+Comment[ru]=Мост MCOP-DCOP
+Comment[rw]=Iteme MCOP-DCOP KDE
+Comment[se]=KDE MCOP-DCOP šaldi
+Comment[sk]=Most KDE MCOP-DCOP
+Comment[sl]=Premostitelj MCOP-DCOP za KDE
+Comment[sq]=Ura e KDE MCOP-DCOP-it
+Comment[sr]=KDED MCOP-DCOP мост
+Comment[sr@Latn]=KDED MCOP-DCOP most
+Comment[ss]=Libhuloho le MCOP-DCOP ku KDE
+Comment[sv]=KDE MCOP-DCOP-brygga
+Comment[ta]=கேடிஇ MCOP-DCOP பாலம்
+Comment[te]=కెడిఈ ఎంసిఓపి-డిసిఓపి వారధి
+Comment[tg]=Пайвасти KDE MCOP-DCOP
+Comment[th]=ตัวเชื่อม KDE MCOP-DCOP
+Comment[tr]=KDE MCOP-DCOP Köprüsü
+Comment[tt]=KDE MCOP-DCOP Küpere
+Comment[uk]=Міст KDE MCOP-DCOP
+Comment[uz]=KDE MCOP-DCOP koʻprigi
+Comment[uz@cyrillic]=KDE MCOP-DCOP кўприги
+Comment[ven]=KDE MCOP-DCOP Buroho
+Comment[vi]=Cầu MCOP-DCOP của KDE
+Comment[xh]=KDE MCOP-DCOP Ibhulorho
+Comment[zh_CN]=KDE MCOP-DCOP 桥
+Comment[zh_HK]=KDE MCOP-DCOP 橋樑
+Comment[zh_TW]=KDE MCOP-DCOP 橋樑
+Comment[zu]=Ibhulogo le-KDE MCOP-DCOP
+Icon=kmcop
+ServiceTypes=KMCOP
+X-DCOP-ServiceType=Unique
+X-KDE-StartupNotify=false
diff --git a/arts/kde/mcop-dcop/kmcop.h b/arts/kde/mcop-dcop/kmcop.h
new file mode 100644
index 000000000..c81e385ff
--- /dev/null
+++ b/arts/kde/mcop-dcop/kmcop.h
@@ -0,0 +1,50 @@
+/*
+ Copyright (c) 2001 Nikolas Zimmermann <wildfox@kde.org>
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2, or (at your option)
+ any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+
+*/
+
+#ifndef KMCOP_H
+#define KMCOP_H
+
+#include <qobject.h>
+
+#include <dcopobject.h>
+
+class KMCOPPrivate;
+
+class KMCOP : public QObject,
+ public DCOPObject
+{
+Q_OBJECT
+K_DCOP
+
+public:
+ KMCOP();
+ ~KMCOP();
+
+k_dcop:
+ int objectCount();
+ void addInterfacesHackHackHack();
+
+private:
+ QCString correctType(const QCString &str);
+ KMCOPPrivate *d;
+};
+
+
+#endif
+
diff --git a/arts/kde/mcop-dcop/mcopdcopobject.cpp b/arts/kde/mcop-dcop/mcopdcopobject.cpp
new file mode 100644
index 000000000..f1d1acad5
--- /dev/null
+++ b/arts/kde/mcop-dcop/mcopdcopobject.cpp
@@ -0,0 +1,152 @@
+/*
+ Copyright (c) 2001 Nikolas Zimmermann <wildfox@kde.org>
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2, or (at your option)
+ any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+*/
+
+#include <kdebug.h>
+
+#include <core.h>
+//#include <object.h>
+//#include <reference.h>
+#include <dynamicrequest.h>
+
+#include <qmap.h>
+#include <qdatastream.h>
+
+using namespace std;
+
+#include "mcopdcoptools.h"
+#include "mcopdcopobject.h"
+
+class MCOPDCOPObjectPrivate
+{
+public:
+ QMap<QCString, MCOPEntryInfo *> dynamicFunctions;
+};
+
+MCOPDCOPObject::MCOPDCOPObject(QCString name) : DCOPObject(name)
+{
+ d = new MCOPDCOPObjectPrivate();
+}
+
+MCOPDCOPObject::~MCOPDCOPObject()
+{
+ delete d;
+}
+
+QCStringList MCOPDCOPObject::functionsDynamic()
+{
+ QCStringList returnList;
+
+ QMap<QCString, MCOPEntryInfo *>::iterator it;
+ for(it = d->dynamicFunctions.begin(); it != d->dynamicFunctions.end(); ++it)
+ returnList.append(it.key());
+
+ return returnList;
+}
+
+Arts::Buffer *MCOPDCOPObject::callFunction(MCOPEntryInfo *entry, QCString ifaceName, const QByteArray &data)
+{
+ Arts::Object workingObject = Arts::SubClass(string(ifaceName));
+ Arts::DynamicRequest request(workingObject);
+ request.method(string(entry->functionName()));
+
+ if(entry->signatureList().size() > 0)
+ {
+ QCStringList list = entry->signatureList();
+
+ QCStringList::iterator it;
+ for(it = list.begin(); it != list.end(); ++it)
+ {
+ QCString param = *it;
+
+ kdDebug() << "PARAM: " << param << endl;
+
+ QDataStream argStream(data, IO_ReadOnly);
+
+ if(param == "long")
+ request.param(MCOPDCOPTools::getLong(argStream));
+ else if(param == "string")
+ request.param(MCOPDCOPTools::getString(argStream));
+ }
+ }
+
+ Arts::AnyRef result;
+ if(!request.invoke(result))
+ return 0;
+
+ Arts::Buffer *newBuffer = new Arts::Buffer();
+ result.write(newBuffer);
+
+ return newBuffer;
+}
+
+bool MCOPDCOPObject::processDynamic(const QCString &fun, const QByteArray &data, QCString &replyType, QByteArray &replyData)
+{
+ QMap<QCString, MCOPEntryInfo *>::iterator it;
+ for(it = d->dynamicFunctions.begin(); it != d->dynamicFunctions.end(); ++it)
+ {
+ MCOPEntryInfo *entry = it.data();
+
+ if((entry->functionName() + entry->signature()) == fun)
+ {
+ QCString type = entry->functionType();
+
+ if(type == "void")
+ {
+ replyType = type;
+
+ Arts::Buffer *result = callFunction(entry, objId(), data);
+
+ if(result != 0)
+ delete result;
+ }
+ else if(type == "string")
+ {
+ replyType = "QCString";
+
+ QDataStream reply(replyData, IO_WriteOnly);
+ reply << "fooo!";
+ }
+ else if(type == "long")
+ {
+ replyType = type;
+
+ long returnCode = -1;
+
+ Arts::Buffer *result = callFunction(entry, objId(), data);
+
+ if(result != 0)
+ {
+ returnCode = result->readLong();
+ delete result;
+ }
+
+ QDataStream reply(replyData, IO_WriteOnly);
+ reply << returnCode;
+ }
+
+ return true;
+ }
+ }
+
+ return false;
+}
+
+void MCOPDCOPObject::addDynamicFunction(QCString value, MCOPEntryInfo *entry)
+{
+ d->dynamicFunctions.insert(value, entry);
+}
diff --git a/arts/kde/mcop-dcop/mcopdcopobject.h b/arts/kde/mcop-dcop/mcopdcopobject.h
new file mode 100644
index 000000000..4c7e70cf5
--- /dev/null
+++ b/arts/kde/mcop-dcop/mcopdcopobject.h
@@ -0,0 +1,89 @@
+/*
+ Copyright (c) 2001 Nikolas Zimmermann <wildfox@kde.org>
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2, or (at your option)
+ any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+
+*/
+
+#ifndef MCOPDCOPOBJECT_H
+#define MCOPDCOPOBJECT_H
+
+#include <dcopobject.h>
+
+#include <qvaluelist.h>
+#include <qcstring.h>
+
+typedef QValueList<QCString> QCStringList;
+
+class MCOPDCOPObjectPrivate;
+
+class MCOPEntryInfo
+{
+public:
+ MCOPEntryInfo()
+ { }
+
+ ~MCOPEntryInfo()
+ { }
+
+ QCString functionType()
+ { return m_functionType; }
+
+ QCString functionName()
+ { return m_functionName; }
+
+ QCString signature()
+ { return m_signature; }
+
+ QCStringList signatureList()
+ { return m_signatureList; }
+
+ void setFunctionType(QCString s)
+ { m_functionType = s; }
+
+ void setFunctionName(QCString s)
+ { m_functionName = s; }
+
+ void setSignature(QCString s)
+ { m_signature = s; }
+
+ void setSignatureList(QCStringList s)
+ { m_signatureList = s; }
+
+private:
+ QCString m_functionType, m_functionName, m_signature;
+ QCStringList m_signatureList;
+};
+
+class MCOPDCOPObject : public DCOPObject
+{
+public:
+ MCOPDCOPObject(QCString name);
+ ~MCOPDCOPObject();
+
+ virtual bool processDynamic(const QCString &fun, const QByteArray &data, QCString &replyType, QByteArray &replyData);
+ virtual QCStringList functionsDynamic();
+
+ void addDynamicFunction(QCString value, MCOPEntryInfo *entry);
+
+ Arts::Buffer *callFunction(MCOPEntryInfo *entry, QCString ifaceName, const QByteArray &data);
+
+private:
+ MCOPDCOPObjectPrivate *d;
+};
+
+
+#endif
+
diff --git a/arts/kde/mcop-dcop/mcopdcoptools.h b/arts/kde/mcop-dcop/mcopdcoptools.h
new file mode 100644
index 000000000..f1279111c
--- /dev/null
+++ b/arts/kde/mcop-dcop/mcopdcoptools.h
@@ -0,0 +1,47 @@
+/*
+ Copyright (c) 2001 Nikolas Zimmermann <wildfox@kde.org>
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2, or (at your option)
+ any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+
+*/
+
+#ifndef MCOPDCOPTOOLS_H
+#define MCOPDCOPTOOLS_H
+
+#include <string>
+
+#include <qdatastream.h>
+
+class MCOPDCOPTools
+{
+public:
+ static long getLong(QDataStream &stream)
+ {
+ long l;
+ stream << l;
+
+ return l;
+ }
+
+ static std::string getString(QDataStream &stream)
+ {
+ QCString s;
+ stream << s;
+
+ return std::string(s);
+ }
+};
+
+#endif