xref: /haiku/src/apps/mediaplayer/MainApp.h (revision 97dfeb96704e5dbc5bec32ad7b21379d0125e031)
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_OPEN_PREVIOUS_PLAYLIST	= 'oppp'
50 };
51 
52 
53 #define NAME "MediaPlayer"
54 
55 
56 class BFilePanel;
57 class SettingsWindow;
58 
59 
60 class MainApp : public BApplication {
61 public:
62 								MainApp();
63 	virtual						~MainApp();
64 
65 			MainWin*			NewWindow(BMessage* message = NULL);
66 			int32				PlayerCount() const;
67 
68 private:
69 	virtual	bool				QuitRequested();
70 	virtual	void				ReadyToRun();
71 	virtual	void				RefsReceived(BMessage* message);
72 	virtual	void				ArgvReceived(int32 argc, char** argv);
73 	virtual	void				MessageReceived(BMessage* message);
74 
75 private:
76 			void				_ShowSettingsWindow();
77 			void				_BroadcastMessage(const BMessage& message);
78 
79 			void				_ShowOpenFilePanel(const BMessage* message);
80 			void				_ShowSaveFilePanel(const BMessage* message);
81 			void				_ShowFilePanel(BFilePanel* panel,
82 									uint32 command, const BMessage* message,
83 									const char* defaultTitle,
84 									const char* defaultLabel);
85 
86 			void				_HandleOpenPanelResult(
87 									const BMessage* message);
88 			void				_HandleSavePanelResult(
89 									const BMessage* message);
90 			void				_HandleFilePanelResult(BFilePanel* panel,
91 									const BMessage* message);
92 
93 			void				_StoreCurrentPlaylist(
94 									const BMessage* message) const;
95 			status_t			_RestoreCurrentPlaylist(
96 									BMessage* message) const;
97 
98 			void				_InstallPlaylistMimeType();
99 
100 private:
101 			int32				fPlayerCount;
102 			SettingsWindow*		fSettingsWindow;
103 
104 			BFilePanel*			fOpenFilePanel;
105 			BFilePanel*			fSaveFilePanel;
106 			entry_ref			fLastFilePanelFolder;
107 
108 			bool				fAudioWindowFrameSaved;
109 			bigtime_t			fLastSavedAudioWindowCreationTime;
110 };
111 
112 extern MainApp* gMainApp;
113 extern const char* kAppSig;
114 
115 #endif	// __MAIN_APP_H
116