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_NEW_PLAYER = 'nwpl', 33 M_PLAYER_QUIT = 'plqt', 34 M_SETTINGS = 'stng', 35 36 M_SHOW_OPEN_PANEL = 'swop', 37 M_SHOW_SAVE_PANEL = 'swsp', 38 // "target" - This BMessenger will be sent the result message. 39 // "message" - This message will be sent back to the target, with 40 // the additional fields that a BFilePanel provides. 41 // If no result message is specified, the constants below 42 // will be used. 43 // "title" - String that will be used to name the panel window. 44 // "label" - String that will be used to name the Default button. 45 46 M_OPEN_PANEL_RESULT = 'oprs', 47 M_SAVE_PANEL_RESULT = 'sprs', 48 49 M_MEDIA_SERVER_STARTED = 'msst', 50 M_MEDIA_SERVER_QUIT = 'msqt', 51 52 M_OPEN_PREVIOUS_PLAYLIST = 'oppp' 53 }; 54 55 56 #define NAME "MediaPlayer" 57 58 59 class BFilePanel; 60 class SettingsWindow; 61 62 63 class MainApp : public BApplication { 64 public: 65 MainApp(); 66 virtual ~MainApp(); 67 68 MainWin* NewWindow(BMessage* message = NULL); 69 int32 PlayerCount() const; 70 71 private: 72 virtual bool QuitRequested(); 73 virtual void ReadyToRun(); 74 virtual void RefsReceived(BMessage* message); 75 virtual void ArgvReceived(int32 argc, char** argv); 76 virtual void MessageReceived(BMessage* message); 77 virtual void AboutRequested(); 78 79 private: 80 void _ShowSettingsWindow(); 81 void _BroadcastMessage(const BMessage& message); 82 83 void _ShowOpenFilePanel(const BMessage* message); 84 void _ShowSaveFilePanel(const BMessage* message); 85 void _ShowFilePanel(BFilePanel* panel, 86 uint32 command, const BMessage* message, 87 const char* defaultTitle, 88 const char* defaultLabel); 89 90 void _HandleOpenPanelResult( 91 const BMessage* message); 92 void _HandleSavePanelResult( 93 const BMessage* message); 94 void _HandleFilePanelResult(BFilePanel* panel, 95 const BMessage* message); 96 97 void _StoreCurrentPlaylist( 98 const BMessage* message) const; 99 status_t _RestoreCurrentPlaylist( 100 BMessage* message) const; 101 102 void _InstallPlaylistMimeType(); 103 104 private: 105 int32 fPlayerCount; 106 SettingsWindow* fSettingsWindow; 107 108 BFilePanel* fOpenFilePanel; 109 BFilePanel* fSaveFilePanel; 110 entry_ref fLastFilePanelFolder; 111 112 bool fMediaServerRunning; 113 bool fMediaAddOnServerRunning; 114 115 bool fAudioWindowFrameSaved; 116 bigtime_t fLastSavedAudioWindowCreationTime; 117 }; 118 119 extern MainApp* gMainApp; 120 extern const char* kAppSig; 121 122 #endif // __MAIN_APP_H 123