vfs: check userland buffers before reading them.
[haiku.git] / src / apps / cortex / RouteApp / RouteApp.h
blobfa3c8caf0abb768562861eb258df599397eb96a2
1 /*
2 * Copyright (c) 1999-2000, Eric Moon.
3 * All rights reserved.
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
9 * 1. Redistributions of source code must retain the above copyright
10 * notice, this list of conditions, and the following disclaimer.
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.
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.
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.
32 // RouteApp.h
33 // e.moon 14may99
35 // PURPOSE
36 // Application class for route/1.
38 // HISTORY
39 // 14may99 e.moon Created from 'routeApp.cpp'
41 #ifndef __ROUTEAPP_H__
42 #define __ROUTEAPP_H__
44 #include <Application.h>
45 #include <FilePanel.h>
46 #include <Mime.h>
47 #include <Path.h>
49 #include "XML.h"
50 #include "IStateArchivable.h"
52 #include "cortex_defs.h"
53 __BEGIN_CORTEX_NAMESPACE
55 class RouteWindow;
56 class RouteAppNodeManager;
58 class RouteApp :
59 public BApplication,
60 public IPersistent,
61 public IStateArchivable {
63 typedef BApplication _inherited;
65 public: // members
66 RouteAppNodeManager* const manager;
67 RouteWindow* const routeWindow;
69 static BMimeType s_nodeSetType;
71 public: // messages
72 enum message_t {
73 // [e.moon 2dec99]
74 M_SHOW_OPEN_PANEL =RouteApp_message_base,
75 M_SHOW_SAVE_PANEL
78 public: // ctor/dtor
79 virtual ~RouteApp();
80 RouteApp();
82 bool QuitRequested();
84 public: // *** BHandler
85 virtual void MessageReceived(
86 BMessage* message);
88 public: // *** BApplication
89 virtual void RefsReceived(
90 BMessage* message);
92 public: // *** IPersistent
94 // EXPORT
96 void xmlExportBegin(
97 ExportContext& context) const;
99 void xmlExportAttributes(
100 ExportContext& context) const;
102 void xmlExportContent(
103 ExportContext& context) const;
105 void xmlExportEnd(
106 ExportContext& context) const;
108 // IMPORT
110 void xmlImportBegin(
111 ImportContext& context);
113 void xmlImportAttribute(
114 const char* key,
115 const char* value,
116 ImportContext& context);
118 void xmlImportContent(
119 const char* data,
120 uint32 length,
121 ImportContext& context);
123 void xmlImportChild(
124 IPersistent* child,
125 ImportContext& context);
127 void xmlImportComplete(
128 ImportContext& context);
130 void xmlImportChildBegin(
131 const char* name,
132 ImportContext& context);
134 void xmlImportChildComplete(
135 const char* name,
136 ImportContext& context);
138 public: // *** IStateArchivable
140 status_t importState(
141 const BMessage* archive);
143 status_t exportState(
144 BMessage* archive) const;
146 private:
147 static const char* const s_appSignature;
149 XML::DocumentType* m_settingsDocType;
150 XML::DocumentType* m_nodeSetDocType;
152 enum {
153 _READ_ROOT,
154 _READ_ROUTE_WINDOW,
155 _READ_MEDIA_ROUTING_VIEW
156 } m_readState;
158 BPath m_lastIODir;
159 BFilePanel m_openPanel;
160 BFilePanel m_savePanel;
162 private:
163 XML::DocumentType* _createSettingsDocType();
164 XML::DocumentType* _createNodeSetDocType();
165 status_t _readSettings();
166 status_t _writeSettings();
168 status_t _readNodeSet(
169 entry_ref* ref);
170 status_t _writeSelectedNodeSet(
171 entry_ref* dir,
172 const char* filename);
174 static status_t _InitMimeTypes();
176 static const char* const s_settingsDirectory;
177 static const char* const s_settingsFile;
179 static const char* const s_rootElement;
180 static const char* const s_mediaRoutingViewElement;
181 static const char* const s_routeWindowElement;
184 __END_CORTEX_NAMESPACE
185 #endif /* __ROUTEAPP_H__ */