vfs: check userland buffers before reading them.
[haiku.git] / src / apps / midiplayer / MidiPlayerApp.cpp
blob74dda5ccc3daa6dec8b5b94f8f2cd536e2b0f11b
1 /*
2 * Copyright (c) 2004 Matthijs Hollemans
3 * Copyright (c) 2008-2014 Haiku, Inc. All rights reserved.
5 * Permission is hereby granted, free of charge, to any person obtaining a
6 * copy of this software and associated documentation files (the "Software"),
7 * to deal in the Software without restriction, including without limitation
8 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
9 * and/or sell copies of the Software, and to permit persons to whom the
10 * Software is furnished to do so, subject to the following conditions:
12 * The above copyright notice and this permission notice shall be included in
13 * all copies or substantial portions of the Software.
15 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
20 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
21 * DEALINGS IN THE SOFTWARE.
25 #include "MidiPlayerApp.h"
27 #include <AboutWindow.h>
28 #include <Alert.h>
29 #include <Catalog.h>
30 #include <Locale.h>
31 #include <StorageKit.h>
33 #include "MidiPlayerWindow.h"
36 #undef B_TRANSLATION_CONTEXT
37 #define B_TRANSLATION_CONTEXT "Main Application"
40 // #pragma mark - MidiPlayerApp
43 MidiPlayerApp::MidiPlayerApp()
45 BApplication(MIDI_PLAYER_SIGNATURE)
47 window = new MidiPlayerWindow();
51 void
52 MidiPlayerApp::ReadyToRun()
54 window->Show();
58 void
59 MidiPlayerApp::AboutRequested()
61 BAboutWindow* window = new BAboutWindow("MidiPlayer",
62 MIDI_PLAYER_SIGNATURE);
64 const char* extraCopyrights[] = {
65 "2008-2014 Haiku, Inc.",
66 NULL
68 window->AddCopyright(2004, "Matthijs Hollemans", extraCopyrights);
70 const char* authors[] = {
71 "Adrien Destugues",
72 "Axel Dörfler",
73 "Matthijs Hollemans",
74 "Humdinger",
75 "Ryan Leavengood",
76 "Matt Madia",
77 "John Scipione",
78 "Jonas Sundström",
79 "Oliver Tappe",
80 NULL
82 window->AddAuthors(authors);
84 window->AddDescription(B_TRANSLATE_COMMENT(
85 "This tiny program\n"
86 "Knows how to play thousands of\n"
87 "Cheesy sounding songs",
88 "This is a haiku. First line has five syllables, "
89 "second has seven and last has five again. "
90 "Create your own."));
92 window->Show();
96 void
97 MidiPlayerApp::RefsReceived(BMessage* message)
99 message->what = B_SIMPLE_DATA;
100 window->PostMessage(message);
104 void
105 MidiPlayerApp::ArgvReceived(int32 argc, char** argv)
107 // Note: we only load the first file, even if more than one is specified.
108 // For some reason, BeOS R5 MidiPlayer loads them all but will only play
109 // the last one. That's not very useful.
111 if (argc > 1) {
112 BMessage msg;
113 msg.what = B_SIMPLE_DATA;
115 BEntry entry(argv[1]);
116 entry_ref ref;
117 entry.GetRef(&ref);
118 msg.AddRef("refs", &ref);
120 window->PostMessage(&msg);
125 // #pragma mark - main method
129 main()
131 MidiPlayerApp app;
132 app.Run();
133 return 0;