xref: /haiku/src/apps/cortex/RouteApp/RouteApp.h (revision d3d8b26997fac34a84981e6d2b649521de2cc45a)
1 // RouteApp.h
2 // e.moon 14may99
3 //
4 // PURPOSE
5 //   Application class for route/1.
6 //
7 // HISTORY
8 //   14may99		e.moon		Created from 'routeApp.cpp'
9 
10 #ifndef __ROUTEAPP_H__
11 #define __ROUTEAPP_H__
12 
13 #include <Application.h>
14 #include <FilePanel.h>
15 #include <Mime.h>
16 #include <Path.h>
17 
18 #include "XML.h"
19 #include "IStateArchivable.h"
20 
21 #include "cortex_defs.h"
22 __BEGIN_CORTEX_NAMESPACE
23 
24 class RouteWindow;
25 class RouteAppNodeManager;
26 
27 class RouteApp :
28 	public		BApplication,
29 	public		IPersistent,
30 	public		IStateArchivable {
31 
32 	typedef		BApplication _inherited;
33 
34 public:															// members
35 	RouteAppNodeManager* const				manager;
36 	RouteWindow* const								routeWindow;
37 
38 	static BMimeType									s_nodeSetType;
39 
40 public:												// messages
41 	enum message_t {
42 		// [e.moon 2dec99]
43 		M_SHOW_OPEN_PANEL					=RouteApp_message_base,
44 		M_SHOW_SAVE_PANEL
45 	};
46 
47 public:												// ctor/dtor
48 	virtual ~RouteApp();
49 	RouteApp();
50 
51 	bool QuitRequested();
52 
53 public:												// *** BHandler
54 	virtual void MessageReceived(
55 		BMessage*									message);
56 
57 public:												// *** BApplication
58 	virtual void RefsReceived(
59 		BMessage*									message);
60 
61 public:												// *** IPersistent
62 
63 	// EXPORT
64 
65 	void xmlExportBegin(
66 		ExportContext&						context) const;
67 
68 	void xmlExportAttributes(
69 		ExportContext&						context) const;
70 
71 	void xmlExportContent(
72 		ExportContext&						context) const;
73 
74 	void xmlExportEnd(
75 		ExportContext&						context) const;
76 
77 	// IMPORT
78 
79 	void xmlImportBegin(
80 		ImportContext&						context);
81 
82 	void xmlImportAttribute(
83 		const char*								key,
84 		const char*								value,
85 		ImportContext&						context);
86 
87 	void xmlImportContent(
88 		const char*								data,
89 		uint32										length,
90 		ImportContext&						context);
91 
92 	void xmlImportChild(
93 		IPersistent*							child,
94 		ImportContext&						context);
95 
96 	void xmlImportComplete(
97 		ImportContext&						context);
98 
99 	void xmlImportChildBegin(
100 		const char*								name,
101 		ImportContext&						context);
102 
103 	void xmlImportChildComplete(
104 		const char*								name,
105 		ImportContext&						context);
106 
107 public:												// *** IStateArchivable
108 
109 	status_t importState(
110 		const BMessage*						archive);
111 
112 	status_t exportState(
113 		BMessage*									archive) const;
114 
115 private:
116 	static const char* const		s_appSignature;
117 
118 	XML::DocumentType*					m_settingsDocType;
119 	XML::DocumentType*					m_nodeSetDocType;
120 
121 	enum {
122 		_READ_ROOT,
123 		_READ_ROUTE_WINDOW,
124 		_READ_MEDIA_ROUTING_VIEW
125 	}														m_readState;
126 
127 	BPath												m_lastIODir;
128 	BFilePanel									m_openPanel;
129 	BFilePanel									m_savePanel;
130 
131 private:
132 	XML::DocumentType* _createSettingsDocType();
133 	XML::DocumentType* _createNodeSetDocType();
134 	status_t _readSettings();
135 	status_t _writeSettings();
136 
137 	status_t _readNodeSet(
138 		entry_ref*								ref);
139 	status_t _writeSelectedNodeSet(
140 		entry_ref*								dir,
141 		const char*								filename);
142 
143 	static status_t _InitMimeTypes();
144 
145 	static const char* const		s_settingsDirectory;
146 	static const char* const		s_settingsFile;
147 
148 	static const char* const		s_rootElement;
149 	static const char* const		s_mediaRoutingViewElement;
150 	static const char* const		s_routeWindowElement;
151 };
152 
153 __END_CORTEX_NAMESPACE
154 #endif /* __ROUTEAPP_H__ */
155