BTRFS: Implement BTree::Path and change _Find.
[haiku.git] / src / add-ons / media / media-add-ons / AbstractFileInterfaceAddOn.cpp
blob8ff2725e58bfba1e7f96da40a7e6eab6a6347441
1 // AbstractFileInterfaceAddOn.cpp
2 //
3 // Andrew Bachmann, 2002
4 //
5 // AbstractFileInterfaceAddOn is an add-on
6 // that can make instances of AbstractFileInterfaceNode
7 //
8 // AbstractFileInterfaceNode handles a file and a multistream
11 #include "AbstractFileInterfaceNode.h"
12 #include "AbstractFileInterfaceAddOn.h"
13 #include "debug.h"
15 #include <Errors.h>
16 #include <MediaDefs.h>
17 #include <MediaAddOn.h>
18 #include <Mime.h>
19 #include <Node.h>
20 #include <StorageDefs.h>
23 #include <limits.h>
24 #include <stdio.h>
25 #include <string.h>
28 AbstractFileInterfaceAddOn::~AbstractFileInterfaceAddOn()
33 AbstractFileInterfaceAddOn::AbstractFileInterfaceAddOn(image_id image) :
34 BMediaAddOn(image)
36 CALLED();
37 refCount = 0;
41 // -------------------------------------------------------- //
42 // BMediaAddOn impl
43 // -------------------------------------------------------- //
44 status_t AbstractFileInterfaceAddOn::InitCheck(
45 const char ** out_failure_text)
47 CALLED();
48 return B_OK;
51 int32 AbstractFileInterfaceAddOn::CountFlavors()
53 CALLED();
54 return 1;
57 status_t AbstractFileInterfaceAddOn::GetFlavorAt(
58 int32 n,
59 const flavor_info ** out_info)
61 CALLED();
63 if (n != 0) {
64 PRINT("\t<- B_BAD_INDEX\n");
65 return B_BAD_INDEX;
68 flavor_info * infos = new flavor_info[1];
69 AbstractFileInterfaceNode::GetFlavor(&infos[0],n);
70 (*out_info) = infos;
71 return B_OK;
75 status_t AbstractFileInterfaceAddOn::GetConfigurationFor(
76 BMediaNode * your_node,
77 BMessage * into_message)
79 CALLED();
80 AbstractFileInterfaceNode * node
81 = dynamic_cast<AbstractFileInterfaceNode*>(your_node);
82 if (node == 0) {
83 PRINT("\t<- B_BAD_TYPE\n");
84 return B_BAD_TYPE;
86 return node->GetConfigurationFor(into_message);
90 bool AbstractFileInterfaceAddOn::WantsAutoStart()
92 CALLED();
93 return false;
97 status_t AbstractFileInterfaceAddOn::AutoStart(
98 int in_count,
99 BMediaNode ** out_node,
100 int32 * out_internal_id,
101 bool * out_has_more)
103 CALLED();
104 return B_OK;
108 // -------------------------------------------------------- //
109 // BMediaAddOn impl for B_FILE_INTERFACE nodes
110 // -------------------------------------------------------- //
111 status_t AbstractFileInterfaceAddOn::SniffRef(
112 const entry_ref & file,
113 BMimeType * io_mime_type,
114 float * out_quality,
115 int32 * out_internal_id)
117 CALLED();
119 *out_internal_id = 0; // only one flavor
120 char mime_string[B_MIME_TYPE_LENGTH+1];
121 status_t status = AbstractFileInterfaceNode::StaticSniffRef(file,mime_string,out_quality);
122 io_mime_type->SetTo(mime_string);
123 return status;
127 // even though I implemented SniffTypeKind below and this shouldn't get called,
128 // I am going to implement it anyway. I'll use it later anyhow.
129 status_t AbstractFileInterfaceAddOn::SniffType(
130 const BMimeType & type,
131 float * out_quality,
132 int32 * out_internal_id)
134 CALLED();
136 *out_quality = 1.0;
137 *out_internal_id = 0;
138 return B_OK;
142 status_t AbstractFileInterfaceAddOn::GetFileFormatList(
143 int32 flavor_id,
144 media_file_format * out_writable_formats,
145 int32 in_write_items,
146 int32 * out_write_items,
147 media_file_format * out_readable_formats,
148 int32 in_read_items,
149 int32 * out_read_items,
150 void * _reserved)
152 CALLED();
154 if (flavor_id != 0) {
155 // this is a sanity check for now
156 PRINT("\t<- B_BAD_INDEX\n");
157 return B_BAD_INDEX;
160 *out_write_items = 0;
161 *out_read_items = 0;
163 return B_OK;
167 status_t AbstractFileInterfaceAddOn::SniffTypeKind(
168 const BMimeType & type,
169 uint64 in_kinds,
170 uint64 io_kind,
171 float * out_quality,
172 int32 * out_internal_id,
173 void * _reserved)
175 CALLED();
177 if (in_kinds & (io_kind | B_FILE_INTERFACE | B_CONTROLLABLE)) {
178 return SniffType(type,out_quality,out_internal_id);
179 } else {
180 // They asked for some kind we don't supply. We set the output
181 // just in case they try to do something with it anyway (!)
182 *out_quality = 0;
183 *out_internal_id = -1;
184 PRINT("\t<- B_BAD_TYPE\n");
185 return B_BAD_TYPE;
190 // -------------------------------------------------------- //
191 // main
192 // -------------------------------------------------------- //
194 // int main(int argc, char *argv[])
198 // -------------------------------------------------------- //
199 // stuffing
200 // -------------------------------------------------------- //
202 status_t AbstractFileInterfaceAddOn::_Reserved_AbstractFileInterfaceAddOn_0(void *) {return B_ERROR;};
203 status_t AbstractFileInterfaceAddOn::_Reserved_AbstractFileInterfaceAddOn_1(void *) {return B_ERROR;};
204 status_t AbstractFileInterfaceAddOn::_Reserved_AbstractFileInterfaceAddOn_2(void *) {return B_ERROR;};
205 status_t AbstractFileInterfaceAddOn::_Reserved_AbstractFileInterfaceAddOn_3(void *) {return B_ERROR;};
206 status_t AbstractFileInterfaceAddOn::_Reserved_AbstractFileInterfaceAddOn_4(void *) {return B_ERROR;};
207 status_t AbstractFileInterfaceAddOn::_Reserved_AbstractFileInterfaceAddOn_5(void *) {return B_ERROR;};
208 status_t AbstractFileInterfaceAddOn::_Reserved_AbstractFileInterfaceAddOn_6(void *) {return B_ERROR;};
209 status_t AbstractFileInterfaceAddOn::_Reserved_AbstractFileInterfaceAddOn_7(void *) {return B_ERROR;};
210 status_t AbstractFileInterfaceAddOn::_Reserved_AbstractFileInterfaceAddOn_8(void *) {return B_ERROR;};
211 status_t AbstractFileInterfaceAddOn::_Reserved_AbstractFileInterfaceAddOn_9(void *) {return B_ERROR;};
212 status_t AbstractFileInterfaceAddOn::_Reserved_AbstractFileInterfaceAddOn_10(void *) {return B_ERROR;};
213 status_t AbstractFileInterfaceAddOn::_Reserved_AbstractFileInterfaceAddOn_11(void *) {return B_ERROR;};
214 status_t AbstractFileInterfaceAddOn::_Reserved_AbstractFileInterfaceAddOn_12(void *) {return B_ERROR;};
215 status_t AbstractFileInterfaceAddOn::_Reserved_AbstractFileInterfaceAddOn_13(void *) {return B_ERROR;};
216 status_t AbstractFileInterfaceAddOn::_Reserved_AbstractFileInterfaceAddOn_14(void *) {return B_ERROR;};
217 status_t AbstractFileInterfaceAddOn::_Reserved_AbstractFileInterfaceAddOn_15(void *) {return B_ERROR;};