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