summaryrefslogtreecommitdiff
path: root/core/apps/qcop/main.cpp
Unidiff
Diffstat (limited to 'core/apps/qcop/main.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--core/apps/qcop/main.cpp84
1 files changed, 16 insertions, 68 deletions
diff --git a/core/apps/qcop/main.cpp b/core/apps/qcop/main.cpp
index 9306cbf..0f5cb2c 100644
--- a/core/apps/qcop/main.cpp
+++ b/core/apps/qcop/main.cpp
@@ -1,83 +1,31 @@
1/********************************************************************** 1/**********************************************************************
2** Copyright (C) 2000 Trolltech AS. All rights reserved. 2** Copyright (C) 2000-2004 Trolltech AS. All rights reserved.
3** 3**
4** This file is part of Qtopia Environment. 4** This file is part of the Qtopia Environment.
5**
6** This program is free software; you can redistribute it and/or modify it
7** under the terms of the GNU General Public License as published by the
8** Free Software Foundation; either version 2 of the License, or (at your
9** option) any later version.
10**
11** A copy of the GNU GPL license version 2 is included in this package as
12** LICENSE.GPL.
5** 13**
6** This file may be distributed and/or modified under the terms of the 14** This program is distributed in the hope that it will be useful, but
7** GNU General Public License version 2 as published by the Free Software 15** WITHOUT ANY WARRANTY; without even the implied warranty of
8** Foundation and appearing in the file LICENSE.GPL included in the 16** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
9** packaging of this file. 17** See the GNU General Public License for more details.
10**
11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
13** 18**
14** See http://www.trolltech.com/gpl/ for GPL licensing information. 19** See http://www.trolltech.com/gpl/ for GPL licensing information.
15** 20**
16** Contact info@trolltech.com if any conditions of this licensing are 21** Contact info@trolltech.com if any conditions of this licensing are
17** not clear to you. 22** not clear to you.
18** 23**
19**********************************************************************/ 24**********************************************************************/
20 25
21#include <qpe/qcopenvelope_qws.h> 26#include "qcopimpl.h"
22
23#include <qapplication.h>
24#include <qtimer.h>
25
26#include <stdlib.h>
27#include <stdio.h>
28
29static void usage()
30{
31 fprintf( stderr, "Usage: qcop channel command [parameters]\n" );
32}
33
34static void syntax( const QString &where, const QString &what )
35{
36 fprintf( stderr, "Syntax error in %s: %s\n", where.latin1(), what.latin1() );
37 exit(1);
38}
39 27
40int main( int argc, char *argv[] ) 28int main( int argc, char *argv[] )
41{ 29{
42 QApplication app( argc, argv ); 30 return doqcopimpl(argc,argv);
43
44 if ( argc < 3 ) {
45 usage();
46 exit(1);
47 }
48
49 QString channel = argv[1];
50 QString command = argv[2];
51 command.stripWhiteSpace();
52
53 int paren = command.find( "(" );
54 if ( paren <= 0 )
55 syntax( "command", command );
56
57 QString params = command.mid( paren + 1 );
58 if ( params[params.length()-1] != ')' )
59 syntax( "command", command );
60
61 params.truncate( params.length()-1 );
62 QCopEnvelope env(channel.latin1(), command.latin1());
63
64 int argIdx = 3;
65
66 QStringList paramList = QStringList::split( ",", params );
67 QStringList::Iterator it;
68 for ( it = paramList.begin(); it != paramList.end(); ++it ) {
69 QString arg = argv[argIdx];
70 if ( *it == "QString" ) {
71 env << arg;
72 } else if ( *it == "int" ) {
73 env << arg.toInt();
74 } else {
75 syntax( "paramter type", *it );
76 }
77 argIdx++;
78 }
79
80 QTimer::singleShot( 0, &app, SLOT(quit()) );
81 return app.exec();
82} 31}
83