2009-07-29 19:22:49 +02:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								#include "launcher.h"
							 | 
						
					
						
							
								
									
										
										
										
											2009-10-26 12:18:14 +01:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								#include "communicationstarter.h"
							 | 
						
					
						
							
								
									
										
										
										
											2009-07-29 19:22:49 +02:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							
								
									
										
										
										
											2009-08-17 11:47:17 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								#include <QtCore/QCoreApplication>
							 | 
						
					
						
							
								
									
										
										
										
											2009-10-23 18:00:20 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								#include <QtCore/QSharedPointer>
							 | 
						
					
						
							
								
									
										
										
										
											2009-08-17 11:47:17 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								#include <QtCore/QDebug>
							 | 
						
					
						
							
								
									
										
										
										
											2009-08-18 13:48:03 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								#include <QtCore/QStringList>
							 | 
						
					
						
							
								
									
										
										
										
											2009-07-29 19:22:49 +02:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							
								
									
										
										
										
											2009-08-18 13:48:03 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								static const char *usageC =
							 | 
						
					
						
							
								
									
										
										
										
											2009-10-23 18:00:20 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								"\n"
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								"Usage: %1 [options] <trk_port_name>\n"
							 | 
						
					
						
							
								
									
										
										
										
											2010-01-21 12:35:09 +01:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								"       %1 [options] <trk_port_name> <remote_executable_name> [-- args]\n"
							 | 
						
					
						
							
								
									
										
										
										
											2009-10-23 18:00:20 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								"       %1 [options] -i <trk_port_name> remote_sis_file\n"
							 | 
						
					
						
							
								
									
										
										
										
											2010-01-21 12:35:09 +01:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								"       %1 [options] -I local_sis_file remote_sis_file] [<remote_executable_name>] [-- args]\n"
							 | 
						
					
						
							
								
									
										
										
										
											2009-08-20 11:30:10 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								"\nOptions:\n    -v verbose\n"
							 | 
						
					
						
							
								
									
										
										
										
											2009-10-23 18:00:20 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								            "    -b Prompt for Bluetooth connect (Linux only)\n"
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								            "    -f turn serial message frame off (Bluetooth)\n"
							 | 
						
					
						
							
								
									
										
										
										
											2009-08-18 13:48:03 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								"\nPing:\n"
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								"%1 COM5\n"
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								"\nRemote launch:\n"
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								"%1 COM5 C:\\sys\\bin\\test.exe\n"
							 | 
						
					
						
							
								
									
										
										
										
											2009-09-28 17:17:11 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								"\nInstallation:\n"
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								"%1 -i COM5 C:\\Data\\test_gcce_udeb.sisx\n"
							 | 
						
					
						
							
								
									
										
										
										
											2009-08-18 13:48:03 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								"\nInstallation and remote launch:\n"
							 | 
						
					
						
							
								
									
										
										
										
											2009-09-22 17:19:56 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								"%1 -i COM5 C:\\Data\\test_gcce_udeb.sisx C:\\sys\\bin\\test.exe\n"
							 | 
						
					
						
							
								
									
										
										
										
											2009-09-28 17:17:11 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								"\nCopy from local file, installation:\n"
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								"%1 -I COM5 C:\\Projects\\test\\test_gcce_udeb.sisx C:\\Data\\test_gcce_udeb.sisx\n"
							 | 
						
					
						
							
								
									
										
										
										
											2009-08-18 13:48:03 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								"\nCopy from local file, installation and remote launch:\n"
							 | 
						
					
						
							
								
									
										
										
										
											2009-09-22 17:19:56 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								"%1 -I COM5 C:\\Projects\\test\\test_gcce_udeb.sisx C:\\Data\\test_gcce_udeb.sisx C:\\sys\\bin\\test.exe\n";
							 | 
						
					
						
							
								
									
										
										
										
											2009-08-18 13:48:03 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								static void usage()
							 | 
						
					
						
							
								
									
										
										
										
											2009-07-29 19:22:49 +02:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								{
							 | 
						
					
						
							
								
									
										
										
										
											2009-08-18 13:48:03 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    const QString msg = QString::fromLatin1(usageC).arg(QCoreApplication::applicationName());
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    qWarning("%s", qPrintable(msg));
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								}
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							
								
									
										
										
										
											2009-10-23 18:00:20 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								typedef QSharedPointer<trk::Launcher> TrkLauncherPtr;
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								// Parse arguments, return pointer or a null none.
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								static inline TrkLauncherPtr createLauncher(trk::Launcher::Actions actions,
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								                                            const QString &serverName,
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								                                            bool serialFrame,
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								                                            int verbosity)
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								{
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    TrkLauncherPtr launcher(new trk::Launcher(actions));
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    launcher->setTrkServerName(serverName);
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    launcher->setSerialFrame(serialFrame);
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    launcher->setVerbose(verbosity);
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    return launcher;
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								}
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								static TrkLauncherPtr parseArguments(const QStringList &arguments, bool *bluetooth)
							 | 
						
					
						
							
								
									
										
										
										
											2009-08-18 13:48:03 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								{
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    // Parse away options
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    bool install = false;
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    bool customInstall = false;
							 | 
						
					
						
							
								
									
										
										
										
											2009-10-23 18:00:20 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    bool serialFrame = true;
							 | 
						
					
						
							
								
									
										
										
										
											2009-08-18 13:48:03 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    const int argCount = arguments.size();
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    int verbosity = 0;
							 | 
						
					
						
							
								
									
										
										
										
											2009-10-23 18:00:20 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    *bluetooth = false;
							 | 
						
					
						
							
								
									
										
										
										
											2010-01-21 12:35:09 +01:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    QStringList remoteArguments;
							 | 
						
					
						
							
								
									
										
										
										
											2009-10-23 18:00:20 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    trk::Launcher::Actions actions = trk::Launcher::ActionPingOnly;
							 | 
						
					
						
							
								
									
										
										
										
											2009-08-18 13:48:03 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    int a = 1;
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    for ( ; a < argCount; a++) {
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								        const QString option = arguments.at(a);
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								        if (!option.startsWith(QLatin1Char('-')))
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								            break;
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								        if (option.size() != 2)
							 | 
						
					
						
							
								
									
										
										
										
											2009-10-23 18:00:20 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								            return TrkLauncherPtr();        
							 | 
						
					
						
							
								
									
										
										
										
											2009-08-18 13:48:03 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								        switch (option.at(1).toAscii()) {
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								        case 'v':
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								            verbosity++;
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								            break;
							 | 
						
					
						
							
								
									
										
										
										
											2009-08-20 11:30:10 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								        case 'f':
							 | 
						
					
						
							
								
									
										
										
										
											2009-10-23 18:00:20 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								            serialFrame = false;
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								            break;
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								        case 'b':
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								            *bluetooth = true;
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								            break;
							 | 
						
					
						
							
								
									
										
										
										
											2009-08-18 13:48:03 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								        case 'i':
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								            install = true;
							 | 
						
					
						
							
								
									
										
										
										
											2009-10-23 18:00:20 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								            actions = trk::Launcher::ActionInstall;
							 | 
						
					
						
							
								
									
										
										
										
											2009-08-18 13:48:03 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								            break;
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								        case 'I':
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								            customInstall = true;
							 | 
						
					
						
							
								
									
										
										
										
											2009-10-23 18:00:20 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								            actions = trk::Launcher::ActionCopyInstall;
							 | 
						
					
						
							
								
									
										
										
										
											2009-08-18 13:48:03 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								            break;
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								        default:
							 | 
						
					
						
							
								
									
										
										
										
											2009-10-23 18:00:20 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								            return TrkLauncherPtr();
							 | 
						
					
						
							
								
									
										
										
										
											2009-08-18 13:48:03 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								        }
							 | 
						
					
						
							
								
									
										
										
										
											2009-07-29 19:22:49 +02:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    }
							 | 
						
					
						
							
								
									
										
										
										
											2010-01-21 12:35:09 +01:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    // Parse for '--' delimiter for remote executable argunment
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    int pastArguments = a;
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    for ( ; pastArguments < argCount && arguments.at(pastArguments) != QLatin1String("--"); pastArguments++) ;
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    if (pastArguments != argCount)
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								        for (int ra = pastArguments + 1; ra < argCount; ra++)
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								            remoteArguments.push_back(arguments.at(ra));
							 | 
						
					
						
							
								
									
										
										
										
											2009-08-18 13:48:03 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    // Evaluate arguments
							 | 
						
					
						
							
								
									
										
										
										
											2010-01-21 12:35:09 +01:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    const int remainingArgsCount = pastArguments -a ;
							 | 
						
					
						
							
								
									
										
										
										
											2009-10-23 18:00:20 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    if (remainingArgsCount == 1 && !install && !customInstall) { // Ping
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								        return createLauncher(actions, arguments.at(a), serialFrame, verbosity);
							 | 
						
					
						
							
								
									
										
										
										
											2009-08-18 13:48:03 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    }
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    if (remainingArgsCount == 2 && !install && !customInstall) {
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								        // remote exec
							 | 
						
					
						
							
								
									
										
										
										
											2009-10-23 18:00:20 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								        TrkLauncherPtr launcher = createLauncher(actions, arguments.at(a), serialFrame, verbosity);
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								        launcher->addStartupActions(trk::Launcher::ActionRun);
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								        launcher->setFileName(arguments.at(a + 1));
							 | 
						
					
						
							
								
									
										
										
										
											2010-01-21 12:35:09 +01:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								        launcher->setCommandLineArgs(remoteArguments);
							 | 
						
					
						
							
								
									
										
										
										
											2009-10-23 18:00:20 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								        return launcher;
							 | 
						
					
						
							
								
									
										
										
										
											2009-08-18 13:48:03 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    }
							 | 
						
					
						
							
								
									
										
										
										
											2009-09-28 17:17:11 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    if ((remainingArgsCount == 3 || remainingArgsCount == 2) && install && !customInstall) {
							 | 
						
					
						
							
								
									
										
										
										
											2009-10-23 18:00:20 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								        TrkLauncherPtr launcher = createLauncher(actions, arguments.at(a), serialFrame, verbosity);
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								        launcher->setInstallFileName(arguments.at(a + 1));
							 | 
						
					
						
							
								
									
										
										
										
											2009-10-05 18:48:53 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								        if (remainingArgsCount == 3) {
							 | 
						
					
						
							
								
									
										
										
										
											2009-10-23 18:00:20 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								            launcher->addStartupActions(trk::Launcher::ActionRun);
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								            launcher->setFileName(arguments.at(a + 2));
							 | 
						
					
						
							
								
									
										
										
										
											2010-01-21 12:35:09 +01:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								            launcher->setCommandLineArgs(remoteArguments);
							 | 
						
					
						
							
								
									
										
										
										
											2009-10-05 18:48:53 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								        }
							 | 
						
					
						
							
								
									
										
										
										
											2009-10-23 18:00:20 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								        return launcher;
							 | 
						
					
						
							
								
									
										
										
										
											2009-08-18 13:48:03 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    }
							 | 
						
					
						
							
								
									
										
										
										
											2009-09-28 17:17:11 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    if ((remainingArgsCount == 4 || remainingArgsCount == 3) && !install && customInstall) {
							 | 
						
					
						
							
								
									
										
										
										
											2009-10-23 18:00:20 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								        TrkLauncherPtr launcher = createLauncher(actions, arguments.at(a), serialFrame, verbosity);
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								        launcher->setTrkServerName(arguments.at(a)); // ping
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								        launcher->setCopyFileName(arguments.at(a + 1), arguments.at(a + 2));
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								        launcher->setInstallFileName(arguments.at(a + 2));
							 | 
						
					
						
							
								
									
										
										
										
											2009-10-05 18:48:53 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								        if (remainingArgsCount == 4) {
							 | 
						
					
						
							
								
									
										
										
										
											2009-10-23 18:00:20 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								            launcher->addStartupActions(trk::Launcher::ActionRun);
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								            launcher->setFileName(arguments.at(a + 3));
							 | 
						
					
						
							
								
									
										
										
										
											2010-01-21 12:35:09 +01:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								            launcher->setCommandLineArgs(remoteArguments);
							 | 
						
					
						
							
								
									
										
										
										
											2009-10-05 18:48:53 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								        }
							 | 
						
					
						
							
								
									
										
										
										
											2009-10-23 18:00:20 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								        return launcher;
							 | 
						
					
						
							
								
									
										
										
										
											2009-08-18 13:48:03 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    }
							 | 
						
					
						
							
								
									
										
										
										
											2009-10-23 18:00:20 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    return TrkLauncherPtr();
							 | 
						
					
						
							
								
									
										
										
										
											2009-08-18 13:48:03 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								}
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								int main(int argc, char *argv[])
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								{
							 | 
						
					
						
							
								
									
										
										
										
											2009-07-29 19:22:49 +02:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    QCoreApplication app(argc, argv);
							 | 
						
					
						
							
								
									
										
										
										
											2009-10-29 14:18:49 +01:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    QCoreApplication::setApplicationName(QLatin1String("TRKlauncher"));
							 | 
						
					
						
							
								
									
										
										
										
											2009-08-18 13:48:03 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    QCoreApplication::setOrganizationName(QLatin1String("Nokia"));
							 | 
						
					
						
							
								
									
										
										
										
											2009-07-29 19:22:49 +02:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							
								
									
										
										
										
											2009-10-23 18:00:20 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    bool bluetooth;
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    const TrkLauncherPtr launcher = parseArguments(app.arguments(), &bluetooth);
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    if (launcher.isNull()) {
							 | 
						
					
						
							
								
									
										
										
										
											2009-08-18 13:48:03 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								        usage();
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								        return 1;
							 | 
						
					
						
							
								
									
										
										
										
											2009-07-29 19:22:49 +02:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    }
							 | 
						
					
						
							
								
									
										
										
										
											2009-10-23 18:00:20 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    QObject::connect(launcher.data(), SIGNAL(finished()), &app, SLOT(quit()));
							 | 
						
					
						
							
								
									
										
										
										
											2010-01-21 15:46:33 +01:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    QObject::connect(launcher.data(), SIGNAL(processStopped(uint,uint,uint,QString)),
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								                     launcher.data(), SLOT(terminate()));
							 | 
						
					
						
							
								
									
										
										
										
											2009-10-23 18:00:20 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    // BLuetooth: Open with prompt
							 | 
						
					
						
							
								
									
										
										
										
											2009-08-14 14:29:19 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    QString errorMessage;
							 | 
						
					
						
							
								
									
										
										
										
											2009-10-23 18:00:20 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    if (bluetooth && !trk::ConsoleBluetoothStarter::startBluetooth(launcher->trkDevice(),
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								                                                     launcher.data(),
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								                                                     launcher->trkServerName(),
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								                                                     30, &errorMessage)) {
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								        qWarning("%s\n", qPrintable(errorMessage));
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								        return -1;
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    }
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    if (launcher->startServer(&errorMessage))
							 | 
						
					
						
							
								
									
										
										
										
											2009-07-29 19:22:49 +02:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								        return app.exec();
							 | 
						
					
						
							
								
									
										
										
										
											2009-08-14 14:29:19 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    qWarning("%s\n", qPrintable(errorMessage));
							 | 
						
					
						
							
								
									
										
										
										
											2009-07-29 19:22:49 +02:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    return 4;
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								}
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 |