* implemented BMediaRoster::StartControlPanel(). It queries a BControllable node with CONTROLLABE_START_CONTROL_PANEL message and returns the result to the caller (thx for help/suggestions from Marcus here). Needed to add appropiate structs and message value to DataExchange.h

* implemented BControllable::StartControlPanel(). The behaviour is supposed to be the one documented in the BeBook, meaning that it first checks if the BControllable node has been instantiated over an BMediaAddOn. If so, we investigate where the addon is located and try to launch it. Thus media_addons which have a control panel need to be compiled as an Application, not as an Addon. See r24664 as an example.
* inside BControllable::HandleMessage() call StartControlPanel for the message.
* MediaNodes having such a ControlPanel are rarely used as parameterwebs should provide you everything. But for instance the vst MediaAddOn uses it and some others do as well.



git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@24665 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Maurice Kalinowski 2008-03-29 20:53:01 +00:00
parent 81fa5e8026
commit 999cd0acee
3 changed files with 82 additions and 5 deletions

View File

@ -177,6 +177,7 @@ enum {
CONTROLLABLE_GET_PARAMETER_DATA,
CONTROLLABLE_SET_PARAMETER_DATA,
CONTROLLABLE_MESSAGE_END,
CONTROLLABLE_START_CONTROL_PANEL,
TIMESOURCE_MESSAGE_START = 0x700,
TIMESOURCE_OP, // datablock is a struct time_source_op_info
@ -1019,4 +1020,14 @@ struct controllable_set_parameter_data_reply : public reply_data
{
};
struct controllable_start_control_panel_request : public request_data
{
media_node node;
};
struct controllable_start_control_panel_reply : public reply_data
{
team_id team;
};
#endif // _DATA_EXCHANGE_H

View File

@ -30,6 +30,7 @@
#include <OS.h>
#include <Controllable.h>
#include <ParameterWeb.h>
#include <Roster.h>
#include "debug.h"
#include "DataExchange.h"
#include "Notifications.h"
@ -226,7 +227,21 @@ BControllable::HandleMessage(int32 message, const void *data, size_t size)
request->SendReply(rv, &reply, sizeof(reply));
return B_OK;
}
case CONTROLLABLE_START_CONTROL_PANEL:
{
const controllable_start_control_panel_request *request = static_cast<const controllable_start_control_panel_request*>(data);
controllable_start_control_panel_reply reply;
BMessenger targetMessenger;
rv = StartControlPanel(&targetMessenger);
if (rv != B_OK) {
ERROR("BControllable::HandleMessage CONTROLLABLE_START_CONTROL_PANEL failed\n");
}
reply.result = rv;
reply.team = targetMessenger.Team();
request->SendReply(rv, &reply, sizeof(reply));
return B_OK;
}
}
return B_ERROR;
}
@ -254,9 +269,46 @@ BControllable::BroadcastNewParameterValue(bigtime_t when,
status_t
BControllable::StartControlPanel(BMessenger *out_messenger)
{
UNIMPLEMENTED();
CALLED();
return B_ERROR;
int32 internalId;
BMediaAddOn* addon = AddOn(&internalId);
if (!addon) {
ERROR("BControllable::StartControlPanel not instantiated per AddOn\n");
return B_ERROR;
}
image_id imageId = addon->ImageID();
image_info info;
if ((imageId <= 0) || (get_image_info(imageId, &info) != B_OK)) {
ERROR("BControllable::StartControlPanel Error accessing image\n");
return B_BAD_VALUE;
}
team_id id;
entry_ref ref;
if (BEntry(info.name).GetRef(&ref) != B_OK) {
ERROR("BControllable::StartControlPanel Error getting ref\n");
return B_BAD_VALUE;
}
// The first argument is "node=id" with id meaning the media_node_id
char *arg = (char*) malloc(10);
sprintf(arg, "node=%d" , (int) ID());
if (be_roster->Launch(&ref, 1, &arg, &id) != B_OK) {
free(arg);
ERROR("BControllable::StartControlPanel Error launching application\n");
return B_BAD_VALUE;
}
printf("BControllable::StartContolPanel done wiht id: %d\n" , id);
free(arg);
if (out_messenger)
*out_messenger = BMessenger(0, id);
return B_OK;
}

View File

@ -2101,8 +2101,22 @@ status_t
BMediaRoster::StartControlPanel(const media_node & node,
BMessenger * out_messenger)
{
UNIMPLEMENTED();
return B_ERROR;
CALLED();
controllable_start_control_panel_request request;
controllable_start_control_panel_reply reply;
request.node = node;
status_t rv;
rv = QueryPort(node.port, CONTROLLABLE_START_CONTROL_PANEL, &request, sizeof(request), &reply, sizeof(reply));
if (rv != B_OK)
return rv;
if (reply.team != -1 && out_messenger)
*out_messenger = BMessenger(0, reply.team);
return B_OK;
}