diff --git a/headers/private/media/DataExchange.h b/headers/private/media/DataExchange.h index b5c9e53796..db2e266a73 100644 --- a/headers/private/media/DataExchange.h +++ b/headers/private/media/DataExchange.h @@ -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 diff --git a/src/kits/media/Controllable.cpp b/src/kits/media/Controllable.cpp index c8f6a21c1e..e9663f1e87 100644 --- a/src/kits/media/Controllable.cpp +++ b/src/kits/media/Controllable.cpp @@ -30,6 +30,7 @@ #include #include #include +#include #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(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; } diff --git a/src/kits/media/MediaRoster.cpp b/src/kits/media/MediaRoster.cpp index ceda725bf4..e1f30aa1be 100644 --- a/src/kits/media/MediaRoster.cpp +++ b/src/kits/media/MediaRoster.cpp @@ -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; }