1 /* 2 * MainApp.h - Media Player for the Haiku Operating System 3 * 4 * Copyright (C) 2006 Marcus Overhagen <marcus@overhagen.de> 5 * Copyright (C) 2008 Stephan Aßmus <superstippi@gmx.de> 6 * 7 * This program is free software; you can redistribute it and/or 8 * modify it under the terms of the GNU General Public License 9 * version 2 as published by the Free Software Foundation. 10 * 11 * This program is distributed in the hope that it will be useful, 12 * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 * GNU General Public License for more details. 15 * 16 * You should have received a copy of the GNU General Public License 17 * along with this program; if not, write to the Free Software 18 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 19 * 20 */ 21 #ifndef __MAIN_APP_H 22 #define __MAIN_APP_H 23 24 25 #include <Application.h> 26 #include <Entry.h> 27 28 #include "MainWin.h" 29 30 31 enum { 32 M_PLAYER_QUIT = 'plqt', 33 M_SETTINGS = 'stng', 34 35 M_SHOW_OPEN_PANEL = 'swop', 36 M_SHOW_SAVE_PANEL = 'swsp', 37 // "target" - This BMessenger will be sent the result message. 38 // "message" - This message will be sent back to the target, with 39 // the additional fields that a BFilePanel provides. 40 // If no result message is specified, the constants below 41 // will be used. 42 // "title" - String that will be used to name the panel window. 43 // "label" - String that will be used to name the Default button. 44 45 M_OPEN_PANEL_RESULT = 'oprs', 46 M_SAVE_PANEL_RESULT = 'sprs', 47 48 M_MEDIA_SERVER_STARTED = 'msst', 49 M_MEDIA_SERVER_QUIT = 'msqt', 50 51 M_OPEN_PREVIOUS_PLAYLIST = 'oppp' 52 }; 53 54 55 #define NAME "MediaPlayer" 56 57 58 class BFilePanel; 59 class SettingsWindow; 60 61 62 class MainApp : public BApplication { 63 public: 64 MainApp(); 65 virtual ~MainApp(); 66 67 MainWin* NewWindow(BMessage* message = NULL); 68 int32 PlayerCount() const; 69 70 private: 71 virtual bool QuitRequested(); 72 virtual void ReadyToRun(); 73 virtual void RefsReceived(BMessage* message); 74 virtual void ArgvReceived(int32 argc, char** argv); 75 virtual void MessageReceived(BMessage* message); 76 virtual void AboutRequested(); 77 78 private: 79 void _ShowSettingsWindow(); 80 void _BroadcastMessage(const BMessage& message); 81 82 void _ShowOpenFilePanel(const BMessage* message); 83 void _ShowSaveFilePanel(const BMessage* message); 84 void _ShowFilePanel(BFilePanel* panel, 85 uint32 command, const BMessage* message, 86 const char* defaultTitle, 87 const char* defaultLabel); 88 89 void _HandleOpenPanelResult( 90 const BMessage* message); 91 void _HandleSavePanelResult( 92 const BMessage* message); 93 void _HandleFilePanelResult(BFilePanel* panel, 94 const BMessage* message); 95 96 void _StoreCurrentPlaylist( 97 const BMessage* message) const; 98 status_t _RestoreCurrentPlaylist( 99 BMessage* message) const; 100 101 void _InstallPlaylistMimeType(); 102 103 private: 104 int32 fPlayerCount; 105 SettingsWindow* fSettingsWindow; 106 107 BFilePanel* fOpenFilePanel; 108 BFilePanel* fSaveFilePanel; 109 entry_ref fLastFilePanelFolder; 110 111 bool fMediaServerRunning; 112 bool fMediaAddOnServerRunning; 113 114 bool fAudioWindowFrameSaved; 115 bigtime_t fLastSavedAudioWindowCreationTime; 116 }; 117 118 extern MainApp* gMainApp; 119 extern const char* kAppSig; 120 121 #endif // __MAIN_APP_H 122