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

arts

  • arts
  • kde
  • mcop-dcop
kmcop.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 #include <kuniqueapplication.h>
21 #include <kaboutdata.h>
22 #include <kcmdlineargs.h>
23 #include <klocale.h>
24 #include <dcopclient.h>
25 
26 #include <tqvaluelist.h>
27 #include <tqcstring.h>
28 
29 #include <kartsdispatcher.h>
30 #include <soundserver.h>
31 #include <dispatcher.h>
32 #include <object.h>
33 #include <core.h>
34 
35 #include "mcopdcopobject.h"
36 
37 #include "kmcop.moc"
38 
39 using namespace Arts;
40 using namespace std;
41 
42 class KMCOPPrivate
43 {
44 public:
45  MCOPInfo mcopInfo;
46  TQPtrList<MCOPDCOPObject> list;
47 };
48 
49 int main(int argc, char **argv)
50 {
51  KAboutData aboutdata("kmcop", I18N_NOOP("KMCOP"),
52  "0.1", I18N_NOOP("KDE MCOP-DCOP Bridge"),
53  KAboutData::License_GPL, "(C) 2001, Nikolas Zimmermann");
54  aboutdata.addAuthor("Nikolas Zimmermann", I18N_NOOP("Author"), "wildfox@kde.org");
55 
56  KCmdLineArgs::init(argc, argv, &aboutdata);
57  KUniqueApplication::addCmdLineOptions();
58 
59  if(!KUniqueApplication::start())
60  {
61  kdDebug() << "Running kmcop found" << endl;
62  return 0;
63  }
64 
65  KUniqueApplication app;
66  app.disableSessionManagement();
67 
68  KArtsDispatcher dispatcher;
69 
70  KMCOP notify;
71  app.dcopClient()->setDefaultObject("arts");
72  app.dcopClient()->setDaemonMode(true);
73 
74  return app.exec();
75 }
76 
77 KMCOP::KMCOP() : TQObject(), DCOPObject("arts")
78 {
79  d = new KMCOPPrivate();
80  d->mcopInfo = Reference("global:Arts_MCOPInfo");
81  d->list.setAutoDelete(true);
82 }
83 
84 KMCOP::~KMCOP()
85 {
86  delete d;
87 }
88 
89 int KMCOP::objectCount()
90 {
91  return d->mcopInfo.objectCount();
92 }
93 
94 TQCString KMCOP::correctType(const TQCString &str)
95 {
96  if(str == "string")
97  return "TQCString";
98  return str;
99 }
100 
101 void KMCOP::addInterfacesHackHackHack()
102 {
103  for(int i = 0; i <= objectCount(); i++)
104  {
105  Arts::Object obj = d->mcopInfo.objectForNumber(i);
106 
107  if(!obj.isNull())
108  {
109  TQCString interfaceName = obj._interfaceName().c_str();
110 
111  if(interfaceName != "Arts::TraderOffer")
112  {
113  Arts::InterfaceRepo ifaceRepo = Dispatcher::the()->interfaceRepo();
114 
115  MCOPDCOPObject *interface = new MCOPDCOPObject(interfaceName);
116  d->list.append(interface);
117 
118  InterfaceDef ifaceDef = ifaceRepo.queryInterface(string(interfaceName));
119  vector<MethodDef> ifaceMethods = ifaceDef.methods;
120 
121  vector<MethodDef>::iterator ifaceMethodsIterator;
122  for(ifaceMethodsIterator = ifaceMethods.begin(); ifaceMethodsIterator != ifaceMethods.end(); ifaceMethodsIterator++)
123  {
124  TQCString function, signature;
125 
126  MCOPEntryInfo *entry = new MCOPEntryInfo();
127 
128  MethodDef currentMethod = *ifaceMethodsIterator;
129  vector<ParamDef> currentParameters = currentMethod.signature;
130 
131  TQCString newType = correctType(TQCString(currentMethod.type.c_str()));
132 
133  entry->setFunctionType(newType);
134  entry->setFunctionName(TQCString(currentMethod.name.c_str()));
135 
136  function = entry->functionType() + TQCString(" ") + entry->functionName() + TQCString("(");
137 
138  signature = TQCString("(");
139 
140  QCStringList signatureList;
141 
142  vector<ParamDef>::iterator methodParametersIterator;
143  for(methodParametersIterator = currentParameters.begin(); methodParametersIterator != currentParameters.end(); methodParametersIterator++)
144  {
145  ParamDef parameter = *methodParametersIterator;
146  if(methodParametersIterator != currentParameters.begin())
147  {
148  function += TQCString(", ");
149  signature += TQCString(",");
150  }
151 
152  TQCString correctParameter = correctType(TQCString(parameter.type.c_str()));
153 
154  function += correctParameter;
155  signature += correctParameter;
156 
157  signatureList.append(TQCString(parameter.type.c_str()));
158  }
159 
160  function += TQCString(")");
161  signature += TQCString(")");
162 
163  entry->setSignature(signature);
164  entry->setSignatureList(signatureList);
165 
166  interface->addDynamicFunction(function, entry);
167  }
168  }
169  }
170  }
171 }
KUniqueApplication::start
static bool start()
KArtsDispatcher
KArtsDispatcher ensures that an instance of Arts::Dispatcher using an Arts::QIOManager exists...
Definition: kartsdispatcher.h:64
std
kdDebug
kdbgstream kdDebug(int area=0)
KApplication::disableSessionManagement
void disableSessionManagement()
klocale.h
I18N_NOOP
#define I18N_NOOP(x)
Arts
Definition: kartsdispatcher.h:29
KAboutData
KUniqueApplication::addCmdLineOptions
static void addCmdLineOptions()
KCmdLineArgs::init
static void init(int _argc, char **_argv, const char *_appname, const char *programName, const char *_description, const char *_version, bool noKApp=false)
KApplication::dcopClient
static DCOPClient * dcopClient()
KUniqueApplication
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
  •     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 arts by doxygen 1.8.11
This website is maintained by Timothy Pearson.
KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. |