2 * Copyright (c) 1999-2000, Eric Moon.
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
9 * 1. Redistributions of source code must retain the above copyright
10 * notice, this list of conditions, and the following disclaimer.
12 * 2. Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions, and the following disclaimer in the
14 * documentation and/or other materials provided with the distribution.
16 * 3. The name of the author may not be used to endorse or promote products
17 * derived from this software without specific prior written permission.
19 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR "AS IS" AND ANY EXPRESS OR
20 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
21 * OF TITLE, NON-INFRINGEMENT, MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
23 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
24 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
25 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
26 * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
27 * TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
32 // MediaNodeControlApp.cpp
35 #include "MediaNodeControlApp.h"
38 #include <MediaRoster.h>
39 #include <MediaTheme.h>
40 #include <ParameterWeb.h>
48 // -------------------------------------------------------- //
50 // -------------------------------------------------------- //
54 typedef BWindow _inherited
;
57 BWindow(BRect(50, 50, 100, 100), "MediaNodeControlApp",
59 B_ASYNCHRONOUS_CONTROLS
|
60 B_WILL_ACCEPT_FIRST_CLICK
) {}
62 bool QuitRequested() {
63 be_app
->PostMessage(B_QUIT_REQUESTED
);
68 MediaNodeControlApp::~MediaNodeControlApp() {
69 BMediaRoster
* r
= BMediaRoster::Roster();
70 r
->ReleaseNode(m_node
);
73 MediaNodeControlApp::MediaNodeControlApp(
74 const char* pAppSignature
,
75 media_node_id nodeID
) :
76 BApplication(pAppSignature
) {
78 BMediaRoster
* r
= BMediaRoster::Roster();
81 status_t err
= r
->GetNodeFor(nodeID
, &m_node
);
85 "MediaNodeControlApp: couldn't find node (%" B_PRId32
"):\n%s\n",
86 nodeID
, strerror(err
));
87 BAlert
* alert
= new BAlert("error", buffer
, "OK");
88 alert
->SetFlags(alert
->Flags() | B_CLOSE_ON_ESCAPE
);
95 err
= r
->GetLiveNodeInfo(m_node
, &nInfo
);
99 "MediaNodeControlApp: couldn't get node info (%" B_PRId32
100 "):\n%s\n", nodeID
, strerror(err
));
101 BAlert
* alert
= new BAlert("error", buffer
, "OK");
102 alert
->SetFlags(alert
->Flags() | B_CLOSE_ON_ESCAPE
);
108 windowTitle
<< nInfo
.name
<< '(' << nodeID
<< ") controls";
112 err
= r
->GetParameterWebFor(m_node
, &pWeb
);
116 "MediaNodeControlApp: no parameters for node (%" B_PRId32
117 "):\n%s\n", nodeID
, strerror(err
));
118 BAlert
* alert
= new BAlert("error", buffer
, "OK");
119 alert
->SetFlags(alert
->Flags() | B_CLOSE_ON_ESCAPE
);
124 // build & show control window
125 BView
* pView
= BMediaTheme::ViewFor(pWeb
);
126 BWindow
* pWnd
= new PanelWindow();
127 pWnd
->AddChild(pView
);
128 pWnd
->ResizeTo(pView
->Bounds().Width(), pView
->Bounds().Height());
129 pWnd
->SetTitle(windowTitle
.String());
133 //r->ReleaseNode(m_node);
136 // END -- MediaNodeControlApp.cpp --