Warning, /sdk/kompare/tests/diff/unifiedm.diff is written in an unsupported language. File is not indexed.
0001 diff -aur dcop/client/dcop.cpp dcop2/client/dcop.cpp 0002 --- dcop/client/dcop.cpp Wed Jan 30 22:38:07 2002 0003 +++ dcop2/client/dcop.cpp Wed Jan 30 22:37:04 2002 0004 @@ -20,19 +20,47 @@ 0005 0006 ******************************************************************/ 0007 0008 -#include <qvariant.h> 0009 +#include <ctype.h> 0010 +#include <stdio.h> 0011 +#include <stdlib.h> 0012 + 0013 #include <qcolor.h> 0014 -#include "../kdatastream.h" 0015 +#include <qdir.h> 0016 +#include <qfile.h> 0017 +#include <qfileinfo.h> 0018 +#include <qmap.h> 0019 +#include <qstringlist.h> 0020 +#include <qtextstream.h> 0021 +#include <qvariant.h> 0022 + 0023 +// putenv() is not available on all platforms, so make sure the emulation 0024 +// wrapper is available in those cases by loading config.h! 0025 +#include <config.h> 0026 + 0027 #include "../dcopclient.h" 0028 #include "../dcopref.h" 0029 -#include <stdlib.h> 0030 -#include <stdio.h> 0031 -#include <ctype.h> 0032 +#include "../kdatastream.h" 0033 0034 #include "marshall.cpp" 0035 0036 +typedef QMap<QString, QString> UserList; 0037 + 0038 static DCOPClient* dcop = 0; 0039 0040 +static QTextStream cout( stdout, IO_WriteOnly ); 0041 +static QTextStream cerr( stderr, IO_WriteOnly ); 0042 + 0043 +/** 0044 + * Session to send call to 0045 + * DefaultSession - current session. Current KDE session when called without 0046 + * --user or --all-users option. Otherwise this value ignores 0047 + * all users with more than one active session. 0048 + * AllSessions - Send to all sessions found. requires --user or --all-users. 0049 + * QuerySessions - Don't call DCOP, return a list of available sessions. 0050 + * CustomSession - Use the specified session 0051 + */ 0052 +enum Session { DefaultSession = 0, AllSessions, QuerySessions, CustomSession }; 0053 + 0054 bool startsWith(const QCString &id, const char *str, int n) 0055 { 0056 return !n || (strncmp(id.data(), str, n) == 0); 0057 @@ -118,9 +146,8 @@ 0058 } 0059 } 0060 0061 -void callFunction( const char* app, const char* obj, const char* func, int argc, char** args ) 0062 +void callFunction( const char* app, const char* obj, const char* func, const QCStringList args ) 0063 { 0064 - 0065 QString f = func; // Qt is better with unicode strings, so use one. 0066 int left = f.find( '(' ); 0067 int right = f.find( ')' ); 0068 @@ -136,7 +163,7 @@ 0069 bool ok = false; 0070 QCStringList funcs = dcop->remoteFunctions( app, obj, &ok ); 0071 QCString realfunc; 0072 - if ( !ok && argc == 0 ) 0073 + if ( !ok && args.isEmpty() ) 0074 goto doit; 0075 if ( !ok ) 0076 { 0077 @@ -153,15 +180,16 @@ 0078 0079 if ( l > 0 && (*it).mid( s, l - s ) == func ) { 0080 realfunc = (*it).mid( s ); 0081 - int a = (*it).contains(','); 0082 - if ( ( a == 0 && argc == 0) || ( a > 0 && a + 1 == argc ) ) 0083 + uint a = (*it).contains(','); 0084 + if ( ( a == 0 && args.isEmpty() ) || ( a > 0 && a + 1 == args.count() ) ) 0085 break; 0086 } 0087 } 0088 if ( realfunc.isEmpty() ) 0089 { 0090 qWarning("no such function"); 0091 - exit(1); 0092 +// exit(1); 0093 + return; 0094 } 0095 f = realfunc; 0096 left = f.find( '(' ); 0097 @@ -243,11 +271,12 @@ 0098 QCString replyType; 0099 QDataStream arg(data, IO_WriteOnly); 0100 0101 - int i = 0; 0102 - for ( QStringList::Iterator it = types.begin(); it != types.end(); ++it ) { 0103 - marshall(arg, argc, args, i, *it); 0104 - } 0105 - if ( i != argc ) { 0106 + uint i = 0; 0107 + for( QStringList::Iterator it = types.begin(); it != types.end(); ++it ) 0108 + marshall( arg, args, i, *it ); 0109 + 0110 + if ( i != args.count() ) 0111 + { 0112 qWarning( "arguments do not match" ); 0113 exit(1); 0114 } 0115 @@ -266,78 +295,479 @@ 0116 } 0117 } 0118 0119 +/** 0120 + * Show command-line help and exit 0121 + */ 0122 +void showHelp( int exitCode = 0 ) 0123 +{ 0124 + cout << "Usage: dcop [options] [application [object [function [arg1] [arg2] ... ] ] ]" << endl 0125 + << "" << endl 0126 + << "Console DCOP client" << endl 0127 + << "" << endl 0128 + << "Generic options:" << endl 0129 + << " --help Show help about options" << endl 0130 + << "" << endl 0131 + << "Options:" << endl 0132 + << " --pipe Call DCOP for each line read from stdin" << endl 0133 + << " --user <user> Connect to the given user's DCOP server. This option will" << endl 0134 + << " ignore the values of the environment vars $DCOPSERVER and" << endl 0135 + << " $ICEAUTHORITY, even if they are set." << endl 0136 + << " If the user has more than one open session, you must also" << endl 0137 + << " use one of the --list-sessions, --session or --als-sessions" << endl 0138 + << " command-line options." << endl 0139 + << " --all-users Send the same DCOP call to all users with a running DCOP" << endl 0140 + << " server. Only failed calls to existing DCOP servers will" 0141 + << " generate an error message. If no DCOP server is available" << endl 0142 + << " at all, no error will be generated." << endl; 0143 + 0144 + exit( exitCode ); 0145 +} 0146 0147 - 0148 -int main( int argc, char** argv ) 0149 +/** 0150 + * Return a list of all users and their home directories. 0151 + * Returns an empty list if /etc/passwd cannot be read for some reason. 0152 + */ 0153 +static UserList userList() 0154 { 0155 + UserList result; 0156 + 0157 + QFile f( "/etc/passwd" ); 0158 + 0159 + if( !f.open( IO_ReadOnly ) ) 0160 + { 0161 + cerr << "Can't open /etc/passwd for reading!" << endl; 0162 + return result; 0163 + } 0164 0165 - if ( argc > 1 && argv[1][0] == '-' ) { 0166 - fprintf( stderr, "Usage: dcop [ application [object [function [arg1] [arg2] [arg3] ... ] ] ] \n" ); 0167 - exit(0); 0168 + QStringList l( QStringList::split( '\n', f.readAll() ) ); 0169 + 0170 + for( QStringList::ConstIterator it( l.begin() ); it != l.end(); ++it ) 0171 + { 0172 + QStringList userInfo( QStringList::split( ':', *it, true ) ); 0173 + result[ userInfo[ 0 ] ] = userInfo[ 5 ]; 0174 } 0175 0176 - DCOPClient client; 0177 - client.attach(); 0178 - dcop = &client; 0179 + return result; 0180 +} 0181 + 0182 +/** 0183 + * Return a list of available DCOP sessions for the specified user 0184 + * An empty list means no sessions are available, or an error occurred. 0185 + */ 0186 +QStringList dcopSessionList( const QString &user, const QString &home ) 0187 +{ 0188 + if( home.isEmpty() ) 0189 + { 0190 + cerr << "WARNING: Cannot determine home directory for user " 0191 + << user << "!" << endl 0192 + << "Please check permissions or set the $DCOPSERVER variable manually before" << endl 0193 + << "calling dcop." << endl; 0194 + return QStringList(); 0195 + } 0196 + 0197 + QStringList result; 0198 + QFileInfo dirInfo( home ); 0199 + if( !dirInfo.exists() || !dirInfo.isReadable() ) 0200 + return result; 0201 + 0202 + QDir d( home ); 0203 + d.setFilter( QDir::Files | QDir::Hidden | QDir::NoSymLinks ); 0204 + d.setNameFilter( ".DCOPserver*" ); 0205 + 0206 + const QFileInfoList *list = d.entryInfoList(); 0207 + if( !list ) 0208 + return result; 0209 + 0210 + QFileInfoListIterator it( *list ); 0211 + QFileInfo *fi; 0212 + 0213 + while ( ( fi = it.current() ) != 0 ) 0214 + { 0215 + if( fi->isReadable() ) 0216 + result.append( fi->fileName() ); 0217 + ++it; 0218 + } 0219 + return result; 0220 +} 0221 0222 +/** 0223 + * Do the actual DCOP call 0224 + */ 0225 +void runDCOP( QCStringList args, UserList users, Session session, 0226 + const QString sessionName, bool readStdin ) 0227 +{ 0228 QCString app; 0229 QCString objid; 0230 QCString function; 0231 - char **args = 0; 0232 - if ((argc > 1) && (strncmp(argv[1], "DCOPRef(", 8)) == 0) 0233 + QCStringList params; 0234 + DCOPClient *client = 0L; 0235 + if ( !args.isEmpty() && args[ 0 ].find( "DCOPRef(" ) == 0 ) 0236 { 0237 - char *delim = strchr(argv[1], ','); 0238 - if (!delim) 0239 - { 0240 - fprintf(stderr, "Error: '%s' is not a valid DCOP reference.\n", argv[1]); 0241 - return 1; 0242 - } 0243 - *delim = 0; 0244 - app = argv[1] + 8; 0245 - delim++; 0246 - delim[strlen(delim)-1] = 0; 0247 - objid = delim; 0248 - if (argc > 2) 0249 - function = argv[2]; 0250 - if (argc > 3) 0251 - args = &argv[3]; 0252 - argc++; 0253 + // WARNING: This part (until the closing '}') could very 0254 + // well be broken now. As I don't know how to trigger and test 0255 + // dcoprefs this code is *not* tested. It compiles and it looks 0256 + // ok to me, but that's all I can say - Martijn (2001/12/24) 0257 + int delimPos = args[ 0 ].findRev( ',' ); 0258 + if( delimPos == -1 ) 0259 + { 0260 + cerr << "Error: '" << args[ 0 ] 0261 + << "' is not a valid DCOP reference." << endl; 0262 + exit( -1 ); 0263 + } 0264 + args[ 0 ][ delimPos ] = 0; 0265 + app = args[ 0 ].mid( 8 ); 0266 + delimPos++; 0267 + args[ 0 ][ args[ 0 ].length() - 1 ] = 0; 0268 + objid = args[ 0 ].mid( delimPos ); 0269 + if( args.count() > 1 ) 0270 + function = args[ 1 ]; 0271 + if( args.count() > 2 ) 0272 + { 0273 + params = args; 0274 + params.remove( params.begin() ); 0275 + params.remove( params.begin() ); 0276 + } 0277 } 0278 else 0279 { 0280 - if (argc > 1) 0281 - app = argv[1]; 0282 - if (argc > 2) 0283 - objid = argv[2]; 0284 - if (argc > 3) 0285 - function = argv[3]; 0286 - if (argc > 4) 0287 - args = &argv[4]; 0288 - } 0289 - 0290 - switch ( argc ) { 0291 - case 0: 0292 - case 1: 0293 - queryApplications(""); 0294 - break; 0295 - case 2: 0296 - if (endsWith(app, '*')) 0297 - queryApplications(app); 0298 - else 0299 - queryObjects( app, "" ); 0300 - break; 0301 - case 3: 0302 - if (endsWith(objid, '*')) 0303 - queryObjects(app, objid); 0304 - else 0305 - queryFunctions( app, objid ); 0306 - break; 0307 - case 4: 0308 - default: 0309 - callFunction( app, objid, function, argc - 4, args ); 0310 - break; 0311 + if( !args.isEmpty() ) 0312 + app = args[ 0 ]; 0313 + if( args.count() > 1 ) 0314 + objid = args[ 1 ]; 0315 + if( args.count() > 2 ) 0316 + function = args[ 2 ]; 0317 + if( args.count() > 3) 0318 + { 0319 + params = args; 0320 + params.remove( params.begin() ); 0321 + params.remove( params.begin() ); 0322 + params.remove( params.begin() ); 0323 + } 0324 + } 0325 + 0326 + bool firstRun = true; 0327 + UserList::Iterator it; 0328 + QStringList sessions; 0329 + bool presetDCOPServer = false; 0330 +// char *dcopStr = 0L; 0331 + QString dcopServer; 0332 + 0333 + for( it = users.begin(); it != users.end() || firstRun; it++ ) 0334 + { 0335 + firstRun = false; 0336 + 0337 + //cout << "Iterating '" << it.key() << "'" << endl; 0338 + 0339 + if( session == QuerySessions ) 0340 + { 0341 + QStringList sessions = dcopSessionList( it.key(), it.data() ); 0342 + if( sessions.isEmpty() ) 0343 + { 0344 + cout << "No active sessions"; 0345 + if( !( *it ).isEmpty() ) 0346 + cout << " for user " << *it; 0347 + cout << endl; 0348 + } 0349 + else 0350 + { 0351 + cout << "Active sessions "; 0352 + if( !( *it ).isEmpty() ) 0353 + cout << "for user " << *it << " "; 0354 + cout << ":" << endl; 0355 + 0356 + QStringList::Iterator sIt; 0357 + for( sIt = sessions.begin(); sIt != sessions.end(); sIt++ ) 0358 + cout << " " << *sIt << endl; 0359 + 0360 + cout << endl; 0361 + } 0362 + continue; 0363 + } 0364 + 0365 + if( getenv( "DCOPSERVER" ) ) 0366 + { 0367 + sessions.append( getenv( "DCOPSERVER" ) ); 0368 + presetDCOPServer = true; 0369 + } 0370 + 0371 + if( users.count() > 1 || ( users.count() == 1 && 0372 + ( getenv( "DCOPSERVER" ) == 0 /*&& getenv( "DISPLAY" ) == 0*/ ) ) ) 0373 + { 0374 + sessions = dcopSessionList( it.key(), it.data() ); 0375 + if( sessions.isEmpty() ) 0376 + { 0377 + if( users.count() > 1 ) 0378 + continue; 0379 + else 0380 + { 0381 + cerr << "ERROR: No active KDE sessions!" << endl 0382 + << "If you are sure there is one, please set the $DCOPSERVER variable manually" << endl 0383 + << "before calling dcop." << endl; 0384 + exit( -1 ); 0385 + } 0386 + } 0387 + else if( sessions.count() > 1 && session != AllSessions ) 0388 + { 0389 + cerr << "ERROR: Multiple available KDE sessions!" << endl 0390 + << "Please specify the correct session to use with --session or use the" << endl 0391 + << "--all-sessions option to broadcast to all sessions." << endl; 0392 + exit( -1 ); 0393 + } 0394 + } 0395 0396 + if( users.count() > 1 || ( users.count() == 1 && 0397 + ( getenv( "ICEAUTHORITY" ) == 0 || getenv( "DISPLAY" ) == 0 ) ) ) 0398 + { 0399 + // Check for ICE authority file and if the file can be read by us 0400 + QString home = it.data(); 0401 + QString iceFile = it.data() + "/.ICEauthority"; 0402 + QFileInfo fi( iceFile ); 0403 + if( iceFile.isEmpty() ) 0404 + { 0405 + cerr << "WARNING: Cannot determine home directory for user " 0406 + << it.key() << "!" << endl 0407 + << "Please check permissions or set the $ICEAUTHORITY variable manually before" << endl 0408 + << "calling dcop." << endl; 0409 + } 0410 + else if( fi.exists() ) 0411 + { 0412 + if( fi.isReadable() ) 0413 + { 0414 + char *envStr = strdup( ( "ICEAUTHORITY=" + iceFile ).ascii() ); 0415 + putenv( envStr ); 0416 + //cerr << "ice: " << envStr << endl; 0417 + } 0418 + else 0419 + { 0420 + cerr << "WARNING: ICE authority file " << iceFile 0421 + << "is not readable by you!" << endl 0422 + << "Please check permissions or set the $ICEAUTHORITY variable manually before" << endl 0423 + << "calling dcop." << endl; 0424 + } 0425 + } 0426 + else 0427 + { 0428 + if( users.count() > 1 ) 0429 + continue; 0430 + else 0431 + { 0432 + cerr << "WARNING: Cannot find ICE authority file " 0433 + << iceFile << "!" << endl 0434 + << "Please check permissions or set the $ICEAUTHORITY" 0435 + << " variable manually before" << endl 0436 + << "calling dcop." << endl; 0437 + } 0438 + } 0439 + } 0440 + 0441 + // Main loop 0442 + // If users is an empty list we're calling for the currently logged 0443 + // in user. In this case we don't have a session, but still want 0444 + // to iterate the loop once. 0445 + QStringList::Iterator sIt = sessions.begin(); 0446 + for( ; sIt != sessions.end() || users.isEmpty(); sIt++ ) 0447 + { 0448 + if( !presetDCOPServer && !users.isEmpty() ) 0449 + { 0450 + QString dcopFile = it.data() + "/" + *sIt; 0451 + QFile f( dcopFile ); 0452 + if( !f.open( IO_ReadOnly ) ) 0453 + { 0454 + cerr << "Can't open " << dcopFile << " for reading!" << endl; 0455 + exit( -1 ); 0456 + } 0457 + 0458 + QStringList l( QStringList::split( '\n', f.readAll() ) ); 0459 + dcopServer = l.first(); 0460 + 0461 + if( dcopServer.isEmpty() ) 0462 + { 0463 + cerr << "WARNING: Unable to determine DCOP server for session " 0464 + << *sIt << "!" << endl 0465 + << "Please check permissions or set the $DCOPSERVER variable manually before" << endl 0466 + << "calling dcop." << endl; 0467 + exit( -1 ); 0468 + } 0469 + } 0470 + 0471 + delete client; 0472 + client = new DCOPClient; 0473 + if( !dcopServer.isEmpty() ) 0474 + client->setServerAddress( dcopServer.ascii() ); 0475 + bool success = client->attach(); 0476 + if( !success ) 0477 + { 0478 + cerr << "ERROR: Couldn't attach to DCOP server!" << endl; 0479 + continue; 0480 + } 0481 + dcop = client; 0482 + 0483 + switch ( args.count() ) 0484 + { 0485 + case 0: 0486 + queryApplications(""); 0487 + break; 0488 + case 1: 0489 + if (endsWith(app, '*')) 0490 + queryApplications(app); 0491 + else 0492 + queryObjects( app, "" ); 0493 + break; 0494 + case 2: 0495 + if (endsWith(objid, '*')) 0496 + queryObjects(app, objid); 0497 + else 0498 + queryFunctions( app, objid ); 0499 + break; 0500 + case 3: 0501 + default: 0502 + if( readStdin ) 0503 + { 0504 + QCStringList::Iterator replaceArg = args.end(); 0505 + 0506 + QCStringList::Iterator it; 0507 + for( it = args.begin(); it != args.end(); it++ ) 0508 + if( *it == "%1" ) 0509 + replaceArg = it; 0510 + 0511 + // Read from stdin until EOF and call function for each line read 0512 + char *buf = new char[ 1000 ]; 0513 + while ( !feof( stdin ) ) 0514 + { 0515 + fgets( buf, 1000, stdin ); 0516 + 0517 + if( replaceArg != args.end() ) 0518 + *replaceArg = buf; 0519 + 0520 + callFunction( app, objid, function, params ); 0521 + } 0522 + } 0523 + else 0524 + { 0525 + // Just call function 0526 +// cout << "call " << app << ", " << objid << ", " << function << ", (params)" << endl; 0527 + callFunction( app, objid, function, params ); 0528 + } 0529 + break; 0530 + } 0531 + // Another sIt++ would make the loop infinite... 0532 + if( users.isEmpty() ) 0533 + break; 0534 + } 0535 + 0536 + // Another it++ would make the loop infinite... 0537 + if( it == users.end() ) 0538 + break; 0539 } 0540 +} 0541 + 0542 + 0543 +int main( int argc, char** argv ) 0544 +{ 0545 + bool readStdin = false; 0546 + int numOptions = 0; 0547 + QString user; 0548 + Session session = DefaultSession; 0549 + QString sessionName; 0550 + 0551 + // Scan for command-line options first 0552 + for( int pos = 1 ; pos <= argc - 1 ; pos++ ) 0553 + { 0554 + if( strcmp( argv[ pos ], "--help" ) == 0 ) 0555 + showHelp( 0 ); 0556 + else if( strcmp( argv[ pos ], "--pipe" ) == 0 ) 0557 + { 0558 + readStdin = true; 0559 + numOptions++; 0560 + } 0561 + else if( strcmp( argv[ pos ], "--user" ) == 0 ) 0562 + { 0563 + if( pos <= argc - 2 ) 0564 + { 0565 + user = QString::fromLocal8Bit( argv[ pos + 1] ); 0566 + numOptions +=2; 0567 + pos++; 0568 + } 0569 + else 0570 + { 0571 + cerr << "Missing username for '--user' option!" << endl << endl; 0572 + showHelp( -1 ); 0573 + } 0574 + } 0575 + else if( strcmp( argv[ pos ], "--all-users" ) == 0 ) 0576 + { 0577 + user = "*"; 0578 + numOptions ++; 0579 + } 0580 + else if( strcmp( argv[ pos ], "--list-sessions" ) == 0 ) 0581 + { 0582 + session = QuerySessions; 0583 + numOptions ++; 0584 + } 0585 + else if( strcmp( argv[ pos ], "--all-sessions" ) == 0 ) 0586 + { 0587 + session = AllSessions; 0588 + numOptions ++; 0589 + } 0590 + else if( argv[ pos ][ 0 ] == '-' ) 0591 + { 0592 + cerr << "Unknown command-line option '" << argv[ pos ] 0593 + << "'." << endl << endl; 0594 + showHelp( -1 ); 0595 + } 0596 + else 0597 + break; // End of options 0598 + } 0599 + 0600 + argc -= numOptions; 0601 + 0602 + QCStringList args; 0603 + for( int i = numOptions; i < argc + numOptions - 1; i++ ) 0604 + args.append( argv[ i + 1 ] ); 0605 + 0606 + if( readStdin && args.count() < 3 ) 0607 + { 0608 + cerr << "--pipe option only supported for function calls!" << endl << endl; 0609 + showHelp( -1 ); 0610 + } 0611 + 0612 + if( user == "*" && args.count() < 3 && session != QuerySessions ) 0613 + { 0614 + cerr << "ERROR: The --all-users option is only supported for function calls!" << endl << endl; 0615 + showHelp( -1 ); 0616 + } 0617 + 0618 + if( session == QuerySessions && !args.isEmpty() ) 0619 + { 0620 + cerr << "ERROR: The --list-sessions option cannot be used for actual DCOP calls!" << endl << endl; 0621 + showHelp( -1 ); 0622 + } 0623 + 0624 + if( session == QuerySessions && user.isEmpty() ) 0625 + { 0626 + cerr << "ERROR: The --list-sessions option can only be used with the --user or" << endl 0627 + << "--all-users options!" << endl << endl; 0628 + showHelp( -1 ); 0629 + } 0630 + 0631 + if( session != DefaultSession && session != QuerySessions && 0632 + args.count() < 3 ) 0633 + { 0634 + cerr << "ERROR: The --session and --all-sessions options are only supported for function" << endl 0635 + << "calls!" << endl << endl; 0636 + showHelp( -1 ); 0637 + } 0638 + 0639 + UserList users; 0640 + if( user == "*" ) 0641 + users = userList(); 0642 + else if( !user.isEmpty() ) 0643 + users[ user ] = userList()[ user ]; 0644 + 0645 + runDCOP( args, users, session, sessionName, readStdin ); 0646 0647 return 0; 0648 } 0649 + 0650 +// vim: set ts=8 sts=4 sw=4 noet: 0651 + 0652 diff -aur dcop/client/dcopfind.cpp dcop2/client/dcopfind.cpp 0653 --- dcop/client/dcopfind.cpp Wed Jan 30 22:38:07 2002 0654 +++ dcop2/client/dcopfind.cpp Wed Jan 30 22:37:04 2002 0655 @@ -36,7 +36,7 @@ 0656 static bool bAppIdOnly = 0; 0657 static bool bLaunchApp = 0; 0658 0659 -bool findObject( const char* app, const char* obj, const char* func, int argc, char** args ) 0660 +bool findObject( const char* app, const char* obj, const char* func, QCStringList args ) 0661 { 0662 QString f = func; // Qt is better with unicode strings, so use one. 0663 int left = f.find( '(' ); 0664 @@ -118,7 +118,7 @@ 0665 f = fc; 0666 } 0667 0668 - if ( (int) types.count() != argc ) { 0669 + if ( types.count() != args.count() ) { 0670 qWarning( "arguments do not match" ); 0671 exit(1); 0672 } 0673 @@ -128,9 +128,9 @@ 0674 0675 int i = 0; 0676 for ( QStringList::Iterator it = types.begin(); it != types.end(); ++it ) { 0677 - marshall(arg, argc, args, i, *it); 0678 + marshall(arg, args, i, *it); 0679 } 0680 - if ( (int) i != argc ) { 0681 + if ( (uint) i != args.count() ) { 0682 qWarning( "arguments do not match" ); 0683 exit(1); 0684 } 0685 @@ -221,7 +221,11 @@ 0686 argc = 0; 0687 } 0688 0689 - findObject( app, objid, function, argc, args ); 0690 + QCStringList params; 0691 + for( int i = 0; i < argc; i++ ) 0692 + params.append( args[ i ] ); 0693 + 0694 + findObject( app, objid, function, params ); 0695 0696 return 0; 0697 } 0698 diff -aur dcop/client/marshall.cpp dcop2/client/marshall.cpp 0699 --- dcop/client/marshall.cpp Wed Jan 30 22:38:07 2002 0700 +++ dcop2/client/marshall.cpp Wed Jan 30 22:37:04 2002 0701 @@ -242,108 +242,110 @@ 0702 0703 } 0704 0705 -void marshall(QDataStream &arg, int argc, char **argv, int &i, QString type) 0706 +void marshall( QDataStream &arg, QCStringList args, uint &i, QString type ) 0707 { 0708 - if (type == "QStringList") 0709 - type = "QValueList<QString>"; 0710 - if (type == "QCStringList") 0711 - type = "QValueList<QCString>"; 0712 - if (i >= argc) 0713 - { 0714 - qWarning("Not enough arguments."); 0715 - exit(1); 0716 - } 0717 - QString s = QString::fromLocal8Bit(argv[i]); 0718 - 0719 - if ( type == "int" ) 0720 - arg << s.toInt(); 0721 - else if ( type == "uint" ) 0722 - arg << s.toUInt(); 0723 - else if ( type == "unsigned" ) 0724 - arg << s.toUInt(); 0725 - else if ( type == "unsigned int" ) 0726 - arg << s.toUInt(); 0727 - else if ( type == "long" ) 0728 - arg << s.toLong(); 0729 - else if ( type == "long int" ) 0730 - arg << s.toLong(); 0731 - else if ( type == "unsigned long" ) 0732 - arg << s.toULong(); 0733 - else if ( type == "unsigned long int" ) 0734 - arg << s.toULong(); 0735 - else if ( type == "float" ) 0736 - arg << s.toFloat(); 0737 - else if ( type == "double" ) 0738 - arg << s.toDouble(); 0739 - else if ( type == "bool" ) 0740 - arg << mkBool( s ); 0741 - else if ( type == "QString" ) 0742 - arg << s; 0743 - else if ( type == "QCString" ) 0744 - arg << QCString( argv[i] ); 0745 - else if ( type == "QColor" ) 0746 - arg << mkColor( s ); 0747 - else if ( type == "QPoint" ) 0748 - arg << mkPoint( s ); 0749 - else if ( type == "QSize" ) 0750 - arg << mkSize( s ); 0751 - else if ( type == "QRect" ) 0752 - arg << mkRect( s ); 0753 - else if ( type == "QVariant" ) { 0754 - if ( s == "true" || s == "false" ) 0755 - arg << QVariant( mkBool( s ), 42 ); 0756 - else if ( s.left( 4 ) == "int(" ) 0757 - arg << QVariant( s.mid(4, s.length()-5).toInt() ); 0758 - else if ( s.left( 7 ) == "QPoint(" ) 0759 - arg << QVariant( mkPoint( s.mid(7, s.length()-8) ) ); 0760 - else if ( s.left( 6 ) == "QSize(" ) 0761 - arg << QVariant( mkSize( s.mid(6, s.length()-7) ) ); 0762 - else if ( s.left( 6 ) == "QRect(" ) 0763 - arg << QVariant( mkRect( s.mid(6, s.length()-7) ) ); 0764 - else if ( s.left( 7 ) == "QColor(" ) 0765 - arg << QVariant( mkColor( s.mid(7, s.length()-8) ) ); 0766 - else 0767 - arg << QVariant( s ); 0768 - } else if ( type.startsWith("QValueList<")) { 0769 - type = type.mid(11, type.length() - 12); 0770 - QStringList list; 0771 - QString delim = s; 0772 - if (delim == "[") 0773 - delim = "]"; 0774 - if (delim == "(") 0775 - delim = ")"; 0776 - i++; 0777 - QByteArray dummy_data; 0778 - QDataStream dummy_arg(dummy_data, IO_WriteOnly); 0779 + if (type == "QStringList") 0780 + type = "QValueList<QString>"; 0781 + if (type == "QCStringList") 0782 + type = "QValueList<QCString>"; 0783 + if( i > args.count() ) 0784 + { 0785 + qWarning("Not enough arguments."); 0786 + exit(1); 0787 + } 0788 + QString s = QString::fromLocal8Bit( args[ i ] ); 0789 0790 - int j = i; 0791 - int count = 0; 0792 - // Parse list to get the count 0793 - while (true) { 0794 - if (j >= argc) 0795 - { 0796 - qWarning("List end-delimiter '%s' not found.", delim.latin1()); 0797 - exit(1); 0798 - } 0799 - if (argv[j] == delim) break; 0800 - marshall(dummy_arg, argc, argv, j, type); 0801 - count++; 0802 - } 0803 - arg << (Q_UINT32) count; 0804 - // Parse the list for real 0805 - while (true) { 0806 - if (i >= argc) 0807 - { 0808 - qWarning("List end-delimiter '%s' not found.", delim.latin1()); 0809 - exit(1); 0810 - } 0811 - if (argv[i] == delim) break; 0812 - marshall(arg, argc, argv, i, type); 0813 - } 0814 - } else { 0815 - qWarning( "cannot handle datatype '%s'", type.latin1() ); 0816 - exit(1); 0817 - } 0818 + if ( type == "int" ) 0819 + arg << s.toInt(); 0820 + else if ( type == "uint" ) 0821 + arg << s.toUInt(); 0822 + else if ( type == "unsigned" ) 0823 + arg << s.toUInt(); 0824 + else if ( type == "unsigned int" ) 0825 + arg << s.toUInt(); 0826 + else if ( type == "long" ) 0827 + arg << s.toLong(); 0828 + else if ( type == "long int" ) 0829 + arg << s.toLong(); 0830 + else if ( type == "unsigned long" ) 0831 + arg << s.toULong(); 0832 + else if ( type == "unsigned long int" ) 0833 + arg << s.toULong(); 0834 + else if ( type == "float" ) 0835 + arg << s.toFloat(); 0836 + else if ( type == "double" ) 0837 + arg << s.toDouble(); 0838 + else if ( type == "bool" ) 0839 + arg << mkBool( s ); 0840 + else if ( type == "QString" ) 0841 + arg << s; 0842 + else if ( type == "QCString" ) 0843 + arg << QCString( args[ i ] ); 0844 + else if ( type == "QColor" ) 0845 + arg << mkColor( s ); 0846 + else if ( type == "QPoint" ) 0847 + arg << mkPoint( s ); 0848 + else if ( type == "QSize" ) 0849 + arg << mkSize( s ); 0850 + else if ( type == "QRect" ) 0851 + arg << mkRect( s ); 0852 + else if ( type == "QVariant" ) { 0853 + if ( s == "true" || s == "false" ) 0854 + arg << QVariant( mkBool( s ), 42 ); 0855 + else if ( s.left( 4 ) == "int(" ) 0856 + arg << QVariant( s.mid(4, s.length()-5).toInt() ); 0857 + else if ( s.left( 7 ) == "QPoint(" ) 0858 + arg << QVariant( mkPoint( s.mid(7, s.length()-8) ) ); 0859 + else if ( s.left( 6 ) == "QSize(" ) 0860 + arg << QVariant( mkSize( s.mid(6, s.length()-7) ) ); 0861 + else if ( s.left( 6 ) == "QRect(" ) 0862 + arg << QVariant( mkRect( s.mid(6, s.length()-7) ) ); 0863 + else if ( s.left( 7 ) == "QColor(" ) 0864 + arg << QVariant( mkColor( s.mid(7, s.length()-8) ) ); 0865 + else 0866 + arg << QVariant( s ); 0867 + } else if ( type.startsWith("QValueList<")) { 0868 + type = type.mid(11, type.length() - 12); 0869 + QStringList list; 0870 + QString delim = s; 0871 + if (delim == "[") 0872 + delim = "]"; 0873 + if (delim == "(") 0874 + delim = ")"; 0875 i++; 0876 + QByteArray dummy_data; 0877 + QDataStream dummy_arg(dummy_data, IO_WriteOnly); 0878 + 0879 + uint j = i; 0880 + uint count = 0; 0881 + // Parse list to get the count 0882 + while (true) { 0883 + if( j > args.count() ) 0884 + { 0885 + qWarning("List end-delimiter '%s' not found.", delim.latin1()); 0886 + exit(1); 0887 + } 0888 + if( QString::fromLocal8Bit( args[ j ] ) == delim ) 0889 + break; 0890 + marshall( dummy_arg, args, j, type ); 0891 + count++; 0892 + } 0893 + arg << (Q_UINT32) count; 0894 + // Parse the list for real 0895 + while (true) { 0896 + if( i > args.count() ) 0897 + { 0898 + qWarning("List end-delimiter '%s' not found.", delim.latin1()); 0899 + exit(1); 0900 + } 0901 + if( QString::fromLocal8Bit( args[ i ] ) == delim ) 0902 + break; 0903 + marshall( arg, args, i, type ); 0904 + } 0905 + } else { 0906 + qWarning( "cannot handle datatype '%s'", type.latin1() ); 0907 + exit(1); 0908 + } 0909 + i++; 0910 } 0911