xref: /haiku/src/apps/midiplayer/MidiPlayerApp.cpp (revision 93aeb8c3bc3f13cb1f282e3e749258a23790d947)
1 /*
2  * Copyright (c) 2004 Matthijs Hollemans
3  *
4  * Permission is hereby granted, free of charge, to any person obtaining a
5  * copy of this software and associated documentation files (the "Software"),
6  * to deal in the Software without restriction, including without limitation
7  * the rights to use, copy, modify, merge, publish, distribute, sublicense,
8  * and/or sell copies of the Software, and to permit persons to whom the
9  * Software is furnished to do so, subject to the following conditions:
10  *
11  * The above copyright notice and this permission notice shall be included in
12  * all copies or substantial portions of the Software.
13  *
14  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17  * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
19  * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
20  * DEALINGS IN THE SOFTWARE.
21  */
22 
23 #include <Alert.h>
24 #include <StorageKit.h>
25 
26 #include "MidiPlayerApp.h"
27 #include "MidiPlayerWindow.h"
28 
29 //------------------------------------------------------------------------------
30 
31 MidiPlayerApp::MidiPlayerApp()
32 	: BApplication(MIDI_PLAYER_SIGNATURE)
33 {
34 	window = new MidiPlayerWindow;
35 }
36 
37 //------------------------------------------------------------------------------
38 
39 void MidiPlayerApp::ReadyToRun()
40 {
41 	window->Show();
42 }
43 
44 //------------------------------------------------------------------------------
45 
46 void MidiPlayerApp::AboutRequested()
47 {
48 	(new BAlert(
49 		NULL,
50 		"Haiku MIDI Player 1.0.0 beta\n\n"
51 		"This tiny program\n"
52 		"Knows how to play thousands of\n"
53 		"Cheesy sounding songs",
54 		"Okay", NULL, NULL,
55 		B_WIDTH_AS_USUAL, B_INFO_ALERT))->Go();
56 }
57 
58 //------------------------------------------------------------------------------
59 
60 void MidiPlayerApp::RefsReceived(BMessage* msg)
61 {
62 	msg->what = B_SIMPLE_DATA;
63 	window->PostMessage(msg);
64 }
65 
66 //------------------------------------------------------------------------------
67 
68 void MidiPlayerApp::ArgvReceived(int32 argc, char** argv)
69 {
70 	// Note: we only load the first file, even if more than one is specified.
71 	// For some reason, BeOS R5 MidiPlayer loads them all but will only play
72 	// the last one. That's not very useful.
73 
74 	if (argc > 1)
75 	{
76 		BMessage msg;
77 		msg.what = B_SIMPLE_DATA;
78 
79 		BEntry entry(argv[1]);
80 		entry_ref ref;
81 		entry.GetRef(&ref);
82 		msg.AddRef("refs", &ref);
83 
84 		window->PostMessage(&msg);
85 	}
86 }
87 
88 //------------------------------------------------------------------------------
89 
90 int main()
91 {
92 	MidiPlayerApp app;
93 	app.Run();
94 	return 0;
95 }
96 
97 //------------------------------------------------------------------------------
98