xref: /haiku/src/apps/mediaplayer/MainApp.h (revision 22440f4105cafc95cc1d49f9bc65bb395c527d86)
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 
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