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