xref: /haiku/src/apps/cortex/RouteApp/RouteApp.h (revision 21258e2674226d6aa732321b6f8494841895af5f)
1 /*
2  * Copyright (c) 1999-2000, Eric Moon.
3  * All rights reserved.
4  *
5  * Redistribution and use in source and binary forms, with or without
6  * modification, are permitted provided that the following conditions
7  * are met:
8  *
9  * 1. Redistributions of source code must retain the above copyright
10  *    notice, this list of conditions, and the following disclaimer.
11  *
12  * 2. Redistributions in binary form must reproduce the above copyright
13  *    notice, this list of conditions, and the following disclaimer in the
14  *    documentation and/or other materials provided with the distribution.
15  *
16  * 3. The name of the author may not be used to endorse or promote products
17  *    derived from this software without specific prior written permission.
18  *
19  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR "AS IS" AND ANY EXPRESS OR
20  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
21  * OF TITLE, NON-INFRINGEMENT, MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
23  * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
24  * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
25  * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
26  * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
27  * TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
28  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29  */
30 
31 
32 // RouteApp.h
33 // e.moon 14may99
34 //
35 // PURPOSE
36 //   Application class for route/1.
37 //
38 // HISTORY
39 //   14may99		e.moon		Created from 'routeApp.cpp'
40 
41 #ifndef __ROUTEAPP_H__
42 #define __ROUTEAPP_H__
43 
44 #include <Application.h>
45 #include <FilePanel.h>
46 #include <Mime.h>
47 #include <Path.h>
48 
49 #include "XML.h"
50 #include "IStateArchivable.h"
51 
52 #include "cortex_defs.h"
53 __BEGIN_CORTEX_NAMESPACE
54 
55 class RouteWindow;
56 class RouteAppNodeManager;
57 
58 class RouteApp :
59 	public		BApplication,
60 	public		IPersistent,
61 	public		IStateArchivable {
62 
63 	typedef		BApplication _inherited;
64 
65 public:															// members
66 	RouteAppNodeManager* const				manager;
67 	RouteWindow* const								routeWindow;
68 
69 	static BMimeType									s_nodeSetType;
70 
71 public:												// messages
72 	enum message_t {
73 		// [e.moon 2dec99]
74 		M_SHOW_OPEN_PANEL					=RouteApp_message_base,
75 		M_SHOW_SAVE_PANEL
76 	};
77 
78 public:												// ctor/dtor
79 	virtual ~RouteApp();
80 	RouteApp();
81 
82 	bool QuitRequested();
83 
84 public:												// *** BHandler
85 	virtual void MessageReceived(
86 		BMessage*									message);
87 
88 public:												// *** BApplication
89 	virtual void RefsReceived(
90 		BMessage*									message);
91 
92 public:												// *** IPersistent
93 
94 	// EXPORT
95 
96 	void xmlExportBegin(
97 		ExportContext&						context) const;
98 
99 	void xmlExportAttributes(
100 		ExportContext&						context) const;
101 
102 	void xmlExportContent(
103 		ExportContext&						context) const;
104 
105 	void xmlExportEnd(
106 		ExportContext&						context) const;
107 
108 	// IMPORT
109 
110 	void xmlImportBegin(
111 		ImportContext&						context);
112 
113 	void xmlImportAttribute(
114 		const char*								key,
115 		const char*								value,
116 		ImportContext&						context);
117 
118 	void xmlImportContent(
119 		const char*								data,
120 		uint32										length,
121 		ImportContext&						context);
122 
123 	void xmlImportChild(
124 		IPersistent*							child,
125 		ImportContext&						context);
126 
127 	void xmlImportComplete(
128 		ImportContext&						context);
129 
130 	void xmlImportChildBegin(
131 		const char*								name,
132 		ImportContext&						context);
133 
134 	void xmlImportChildComplete(
135 		const char*								name,
136 		ImportContext&						context);
137 
138 public:												// *** IStateArchivable
139 
140 	status_t importState(
141 		const BMessage*						archive);
142 
143 	status_t exportState(
144 		BMessage*									archive) const;
145 
146 private:
147 	static const char* const		s_appSignature;
148 
149 	XML::DocumentType*					m_settingsDocType;
150 	XML::DocumentType*					m_nodeSetDocType;
151 
152 	enum {
153 		_READ_ROOT,
154 		_READ_ROUTE_WINDOW,
155 		_READ_MEDIA_ROUTING_VIEW
156 	}														m_readState;
157 
158 	BPath												m_lastIODir;
159 	BFilePanel									m_openPanel;
160 	BFilePanel									m_savePanel;
161 
162 private:
163 	XML::DocumentType* _createSettingsDocType();
164 	XML::DocumentType* _createNodeSetDocType();
165 	status_t _readSettings();
166 	status_t _writeSettings();
167 
168 	status_t _readNodeSet(
169 		entry_ref*								ref);
170 	status_t _writeSelectedNodeSet(
171 		entry_ref*								dir,
172 		const char*								filename);
173 
174 	static status_t _InitMimeTypes();
175 
176 	static const char* const		s_settingsDirectory;
177 	static const char* const		s_settingsFile;
178 
179 	static const char* const		s_rootElement;
180 	static const char* const		s_mediaRoutingViewElement;
181 	static const char* const		s_routeWindowElement;
182 };
183 
184 __END_CORTEX_NAMESPACE
185 #endif /* __ROUTEAPP_H__ */
186