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

dcop

  • dcop
  • client
dcopstart.cpp
1 /*****************************************************************
2 Copyright (c) 2001 Waldo Bastian <bastian@kde.org>
3 
4 Permission is hereby granted, free of charge, to any person obtaining a copy
5 of this software and associated documentation files (the "Software"), to deal
6 in the Software without restriction, including without limitation the rights
7 to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8 copies of the Software, and to permit persons to whom the Software is
9 furnished to do so, subject to the following conditions:
10 
11 The above copyright notice and this permission notice shall be included in
12 all copies or substantial portions of the Software.
13 
14 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17 AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
18 AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
19 CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
20 
21 ******************************************************************/
22 
23 #include "../kdatastream.h"
24 #include "../dcopclient.h"
25 #include <stdlib.h>
26 #include <stdio.h>
27 #include <ctype.h>
28 
29 #include <tqstringlist.h>
30 
31 static DCOPClient* dcop = 0;
32 
33 void startApp(const char *_app, int argc, const char **args)
34 {
35  const char *function = 0;
36  TQString app = TQString::fromLatin1(_app);
37  if (app.endsWith(".desktop"))
38  function = "start_service_by_desktop_path(TQString,TQStringList)";
39  else
40  function = "start_service_by_desktop_name(TQString,TQStringList)";
41  TQStringList URLs;
42  for(int i = 0; i < argc; i++)
43  {
44  URLs.append(TQString::fromLocal8Bit(args[i]));
45  }
46 
47  TQByteArray data, replyData;
48  TQCString replyType;
49  TQDataStream arg(data, IO_WriteOnly);
50  arg << app << URLs;
51 
52  if ( !dcop->call( "tdelauncher", "tdelauncher", function, data, replyType, replyData) ) {
53  tqWarning( "call failed");
54  exit(1);
55  } else {
56  TQDataStream reply(replyData, IO_ReadOnly);
57 
58  if ( replyType != "serviceResult" )
59  {
60  tqWarning( "unexpected result '%s'", replyType.data());
61  exit(1);
62  }
63  int result;
64  TQCString dcopName;
65  TQString error;
66  reply >> result >> dcopName >> error;
67  if (result != 0)
68  {
69  tqWarning("Error: %s", error.local8Bit().data());
70  exit(1);
71  }
72  if (!dcopName.isEmpty())
73  puts(dcopName.data());
74  }
75 }
76 
77 #ifdef Q_OS_WIN
78 # define main kdemain
79 #endif
80 
81 int main( int argc, char** argv )
82 {
83  if (( argc < 2) || (argv[1][0] == '-' )) {
84  fprintf( stderr, "Usage: dcopstart <application> [url1] [url2] ...\n" );
85  exit(0);
86  }
87 
88  DCOPClient client;
89  client.attach();
90  dcop = &client;
91 
92  TQCString app;
93  TQCString objid;
94  TQCString function;
95  /*char **args = 0;*/
96  startApp( argv[1], argc - 2, (const char**)&argv[2] );
97 
98  return 0;
99 }
DCOPClient
Inter-process communication and remote procedure calls for KDE applications.
Definition: dcopclient.h:69
DCOPClient::attach
bool attach()
Attaches to the DCOP server.
Definition: dcopclient.cpp:679
DCOPClient::call
bool call(const TQCString &remApp, const TQCString &remObj, const TQCString &remFun, const TQByteArray &data, TQCString &replyType, TQByteArray &replyData, bool useEventLoop, int timeout, bool forceRemote)
Performs a synchronous send and receive.
Definition: dcopclient.cpp:1786

dcop

Skip menu "dcop"
  • Main Page
  • Modules
  • Class Hierarchy
  • Alphabetical List
  • Class List
  • File List
  • Class Members
  • Related Pages

dcop

Skip menu "dcop"
  • 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 dcop by doxygen 1.9.1
This website is maintained by Timothy Pearson.