BRoster: Add launchSuspended option to _LaunchApp().
It allows to launch the app, but keep its main thread suspended instead of automatically resuming it. Also add appThread argument which allows to retrieve the main thread of the launched team.
This commit is contained in:
@@ -183,7 +183,9 @@ private:
|
||||
const BList* messageList, int argc,
|
||||
const char* const* args,
|
||||
const char** environment,
|
||||
team_id* appTeam) const;
|
||||
team_id* appTeam,
|
||||
thread_id* appThread,
|
||||
bool launchSuspended) const;
|
||||
|
||||
status_t _UpdateActiveApp(team_id team) const;
|
||||
|
||||
|
||||
@@ -30,9 +30,10 @@ class BRoster::Private {
|
||||
|
||||
status_t Launch(const char* mimeType, const entry_ref* ref,
|
||||
const BList* messageList, int argc, const char* const* args,
|
||||
const char** environment, team_id* appTeam)
|
||||
const char** environment, team_id* appTeam,
|
||||
thread_id* appThread, bool launchSuspended)
|
||||
{ return fRoster->_LaunchApp(mimeType, ref, messageList, argc,
|
||||
args, environment, appTeam); }
|
||||
args, environment, appTeam, appThread, launchSuspended); }
|
||||
|
||||
status_t ShutDown(bool reboot, bool confirm, bool synchronous)
|
||||
{ return fRoster->_ShutDown(reboot, confirm, synchronous); }
|
||||
|
||||
+22
-9
@@ -923,7 +923,7 @@ BRoster::Launch(const char* mimeType, BMessage* initialMessage,
|
||||
messageList.AddItem(initialMessage);
|
||||
|
||||
return _LaunchApp(mimeType, NULL, &messageList, 0, NULL,
|
||||
(const char**)environ, _appTeam);
|
||||
(const char**)environ, _appTeam, NULL, false);
|
||||
}
|
||||
|
||||
|
||||
@@ -935,7 +935,7 @@ BRoster::Launch(const char* mimeType, BList* messageList,
|
||||
return B_BAD_VALUE;
|
||||
|
||||
return _LaunchApp(mimeType, NULL, messageList, 0, NULL,
|
||||
(const char**)environ, _appTeam);
|
||||
(const char**)environ, _appTeam, NULL, false);
|
||||
}
|
||||
|
||||
|
||||
@@ -947,7 +947,7 @@ BRoster::Launch(const char* mimeType, int argc, const char* const* args,
|
||||
return B_BAD_VALUE;
|
||||
|
||||
return _LaunchApp(mimeType, NULL, NULL, argc, args, (const char**)environ,
|
||||
_appTeam);
|
||||
_appTeam, NULL, false);
|
||||
}
|
||||
|
||||
|
||||
@@ -963,7 +963,7 @@ BRoster::Launch(const entry_ref* ref, const BMessage* initialMessage,
|
||||
messageList.AddItem(const_cast<BMessage*>(initialMessage));
|
||||
|
||||
return _LaunchApp(NULL, ref, &messageList, 0, NULL, (const char**)environ,
|
||||
_appTeam);
|
||||
_appTeam, NULL, false);
|
||||
}
|
||||
|
||||
|
||||
@@ -975,7 +975,7 @@ BRoster::Launch(const entry_ref* ref, const BList* messageList,
|
||||
return B_BAD_VALUE;
|
||||
|
||||
return _LaunchApp(NULL, ref, messageList, 0, NULL, (const char**)environ,
|
||||
appTeam);
|
||||
appTeam, NULL, false);
|
||||
}
|
||||
|
||||
|
||||
@@ -987,7 +987,7 @@ BRoster::Launch(const entry_ref* ref, int argc, const char* const* args,
|
||||
return B_BAD_VALUE;
|
||||
|
||||
return _LaunchApp(NULL, ref, NULL, argc, args, (const char**)environ,
|
||||
appTeam);
|
||||
appTeam, NULL, false);
|
||||
}
|
||||
|
||||
|
||||
@@ -1800,6 +1800,10 @@ BRoster::_UpdateActiveApp(team_id team) const
|
||||
\c B_REFS_RECEIVED message, if no arguments are supplied via \a argc and
|
||||
\args.
|
||||
|
||||
If \a launchSuspended is set to true, the main thread of the loaded app
|
||||
(returned in \a appThread) is kept in the suspended state and not
|
||||
automatically resumed.
|
||||
|
||||
\param mimeType MIME type for which the application shall be launched.
|
||||
May be \c NULL.
|
||||
\param ref entry_ref referring to the file for which an application shall
|
||||
@@ -1811,6 +1815,10 @@ BRoster::_UpdateActiveApp(team_id team) const
|
||||
to the launched application.
|
||||
\param appTeam Pointer to a pre-allocated team_id variable to be set to
|
||||
the team ID of the launched application.
|
||||
\param appThread Pointer to a pre-allocated thread_id variable to
|
||||
be set to the thread ID of the launched main thread.
|
||||
\param launchSuspended Indicates whether to keep the app thread in the
|
||||
suspended state or resume it.
|
||||
|
||||
\return A status code.
|
||||
\retval B_OK Everything went fine.
|
||||
@@ -1828,7 +1836,8 @@ BRoster::_UpdateActiveApp(team_id team) const
|
||||
status_t
|
||||
BRoster::_LaunchApp(const char* mimeType, const entry_ref* ref,
|
||||
const BList* messageList, int argc, const char* const* args,
|
||||
const char** environment, team_id* _appTeam) const
|
||||
const char** environment, team_id* _appTeam,
|
||||
thread_id* _appThread, bool launchSuspended) const
|
||||
{
|
||||
DBG(OUT("BRoster::_LaunchApp()"));
|
||||
|
||||
@@ -1856,6 +1865,7 @@ BRoster::_LaunchApp(const char* mimeType, const entry_ref* ref,
|
||||
status_t error = B_OK;
|
||||
ArgVector argVector;
|
||||
team_id team = -1;
|
||||
thread_id appThread = -1;
|
||||
|
||||
do {
|
||||
// find the app
|
||||
@@ -1900,7 +1910,7 @@ BRoster::_LaunchApp(const char* mimeType, const entry_ref* ref,
|
||||
if (error == B_OK && !alreadyRunning) {
|
||||
DBG(OUT(" token: %lu\n", appToken));
|
||||
// load the app image
|
||||
thread_id appThread = load_image(argVector.Count(),
|
||||
appThread = load_image(argVector.Count(),
|
||||
const_cast<const char**>(argVector.Args()), environment);
|
||||
|
||||
// get the app team
|
||||
@@ -1922,7 +1932,7 @@ BRoster::_LaunchApp(const char* mimeType, const entry_ref* ref,
|
||||
DBG(OUT(" set thread and team: %s (%lx)\n", strerror(error),
|
||||
error));
|
||||
// resume the launched team
|
||||
if (error == B_OK)
|
||||
if (error == B_OK && !launchSuspended)
|
||||
error = resume_thread(appThread);
|
||||
|
||||
DBG(OUT(" resume thread: %s (%lx)\n", strerror(error), error));
|
||||
@@ -1983,6 +1993,9 @@ BRoster::_LaunchApp(const char* mimeType, const entry_ref* ref,
|
||||
error = B_ALREADY_RUNNING;
|
||||
else if (_appTeam)
|
||||
*_appTeam = team;
|
||||
|
||||
if (_appThread != NULL)
|
||||
*_appThread = appThread;
|
||||
}
|
||||
|
||||
DBG(OUT("BRoster::_LaunchApp() done: %s (%lx)\n",
|
||||
|
||||
@@ -352,7 +352,7 @@ Job::Launch()
|
||||
signature << Name();
|
||||
|
||||
status_t status = BRoster::Private().Launch(signature.String(), NULL,
|
||||
NULL, 0, NULL, &environment[0], &fTeam);
|
||||
NULL, 0, NULL, &environment[0], &fTeam, NULL, false);
|
||||
_SetLaunchStatus(status);
|
||||
return status;
|
||||
}
|
||||
@@ -378,7 +378,7 @@ Job::Launch()
|
||||
|
||||
// Launch via entry_ref
|
||||
status = BRoster::Private().Launch(NULL, &ref, NULL, count, &args[0],
|
||||
&environment[0], &fTeam);
|
||||
&environment[0], &fTeam, NULL, false);
|
||||
_SetLaunchStatus(status);
|
||||
return status;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user