libroot: added ability to communicate with the launch_daemon.
* These methods don't really work yet, as BMessage doesn't support replying with a KMessage; the request is received, but the reply never gets to the target.
This commit is contained in:
@@ -0,0 +1,29 @@
|
||||
/*
|
||||
* Copyright 2015, Axel Dörfler, [email protected].
|
||||
* Distributed under the terms of the MIT License.
|
||||
*/
|
||||
#ifndef _LIBROOT_LAUNCH_H
|
||||
#define _LIBROOT_LAUNCH_H
|
||||
|
||||
|
||||
#include <LaunchDaemonDefs.h>
|
||||
#include <OS.h>
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
namespace BPrivate {
|
||||
|
||||
|
||||
class KMessage;
|
||||
|
||||
|
||||
port_id get_launch_daemon_port();
|
||||
status_t send_request_to_launch_daemon(KMessage& request, KMessage& reply);
|
||||
status_t get_launch_data(const char* signature, KMessage& data);
|
||||
|
||||
|
||||
} // namespace BPrivate
|
||||
#endif // __cplusplus
|
||||
|
||||
|
||||
#endif // _LIBROOT_LAUNCH_H
|
||||
@@ -18,7 +18,7 @@ if $(RUN_WITHOUT_APP_SERVER) != 0 {
|
||||
}
|
||||
|
||||
UseLibraryHeaders icon ;
|
||||
UsePrivateHeaders shared app interface kernel locale notification ;
|
||||
UsePrivateHeaders shared app interface kernel libroot locale notification ;
|
||||
|
||||
SetSubDirSupportedPlatforms haiku libbe_test ;
|
||||
|
||||
|
||||
@@ -12,6 +12,7 @@
|
||||
#include <Application.h>
|
||||
#include <String.h>
|
||||
|
||||
#include <launch.h>
|
||||
#include <LaunchDaemonDefs.h>
|
||||
#include <MessengerPrivate.h>
|
||||
|
||||
@@ -107,7 +108,7 @@ void
|
||||
BLaunchRoster::_InitMessenger()
|
||||
{
|
||||
// find the launch_daemon port
|
||||
port_id daemonPort = find_port(B_LAUNCH_DAEMON_PORT_NAME);
|
||||
port_id daemonPort = BPrivate::get_launch_daemon_port();
|
||||
port_info info;
|
||||
if (daemonPort >= 0 && get_port_info(daemonPort, &info) == B_OK) {
|
||||
BMessenger::Private(fMessenger).SetTo(info.team, daemonPort,
|
||||
|
||||
@@ -2,7 +2,7 @@ SubDir HAIKU_TOP src system libroot os ;
|
||||
|
||||
UsePrivateHeaders kernel ;
|
||||
# for util/KMessage.h
|
||||
UsePrivateHeaders libroot runtime_loader shared ;
|
||||
UsePrivateHeaders app libroot runtime_loader shared ;
|
||||
|
||||
local architectureObject ;
|
||||
for architectureObject in [ MultiArchSubDirSetup ] {
|
||||
@@ -28,6 +28,7 @@ for architectureObject in [ MultiArchSubDirSetup ] {
|
||||
fs_query.cpp
|
||||
fs_volume.c
|
||||
image.cpp
|
||||
launch.cpp
|
||||
memory.cpp
|
||||
parsedate.cpp
|
||||
port.c
|
||||
|
||||
@@ -0,0 +1,45 @@
|
||||
/*
|
||||
* Copyright 2015, Axel Dörfler, [email protected].
|
||||
* Distributed under the terms of the MIT License.
|
||||
*/
|
||||
|
||||
|
||||
#include <launch.h>
|
||||
|
||||
#include <TokenSpace.h>
|
||||
#include <util/KMessage.h>
|
||||
|
||||
|
||||
static port_id sLaunchDaemonPort = -1;
|
||||
|
||||
|
||||
port_id
|
||||
BPrivate::get_launch_daemon_port()
|
||||
{
|
||||
if (sLaunchDaemonPort < 0)
|
||||
sLaunchDaemonPort = find_port(B_LAUNCH_DAEMON_PORT_NAME);
|
||||
|
||||
return sLaunchDaemonPort;
|
||||
}
|
||||
|
||||
|
||||
status_t
|
||||
BPrivate::send_request_to_launch_daemon(KMessage& request, KMessage& reply)
|
||||
{
|
||||
status_t status = request.SendTo(get_launch_daemon_port(),
|
||||
B_PREFERRED_TOKEN, &reply);
|
||||
if (status != B_OK)
|
||||
return status;
|
||||
|
||||
return (status_t)reply.What();
|
||||
}
|
||||
|
||||
|
||||
status_t
|
||||
BPrivate::get_launch_data(const char* signature, KMessage& data)
|
||||
{
|
||||
BPrivate::KMessage request(B_GET_LAUNCH_DATA);
|
||||
request.AddString("name", signature);
|
||||
|
||||
return BPrivate::send_request_to_launch_daemon(request, data);
|
||||
}
|
||||
Reference in New Issue
Block a user