From adc44678a3c91ce63304a69486fa3b3d1b319c30 Mon Sep 17 00:00:00 2001 From: Ingo Weinhold Date: Tue, 30 Jan 2007 13:04:26 +0000 Subject: [PATCH] Added simple "launch" command to the roster shell. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@20017 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- src/tests/servers/registrar/RosterShell.cpp | 34 +++++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/src/tests/servers/registrar/RosterShell.cpp b/src/tests/servers/registrar/RosterShell.cpp index 18199804a3..4238ba03c5 100644 --- a/src/tests/servers/registrar/RosterShell.cpp +++ b/src/tests/servers/registrar/RosterShell.cpp @@ -16,6 +16,7 @@ const char kShellUsage[] = "activate, a [ ] activates the application specified by \n" "exit, e exits the roster shell\n" "help, h prints this help\n" +"launch [ ] Executes via BRoster::Launch()\n" "list, l [ ] lists the applications specified by \n" " or all registered applications\n" "list-long, ll [ ] lists the applications specified by \n" @@ -43,6 +44,8 @@ public: CmdExit(cmdLine); else if (command == "help" || command == "h") Usage(); + else if (command == "launch") + CmdLaunch(cmdLine); else if (command == "list" || command == "l") CmdList(cmdLine); else if (command == "list-long" || command == "ll") @@ -90,6 +93,37 @@ public: fTerminating = true; } + void CmdLaunch(vector &args) + { + // check args + if (args.size() != 2) { + printf("launch: requires exactly one argument\n"); + return; + } + + string program = args[1]; + + // get an app ref + entry_ref ref; + status_t error = get_ref_for_path(program.c_str(), &ref); + if (error != B_OK) { + printf("launch: Failed to get entry ref for \"%s\": %s\n", + program.c_str(), strerror(error)); + return; + } + + // launch the app + BRoster roster; + team_id teamID; + error = roster.Launch(&ref, (const BMessage*)NULL, &teamID); + if (error == B_OK) { + printf("launched \"%s\", team id: %ld\n", program.c_str(), teamID); + } else { + printf("launch: Failed to launch \"%s\": %s\n", + program.c_str(), strerror(error)); + } + } + static void ParseTeamList(vector &args, BList *teamList) { for (int32 i = 1; i < (int32)args.size(); i++) {