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 9 10 11 #include "AbstractFileInterfaceNode.h" 12 #include "AbstractFileInterfaceAddOn.h" 13 #include "debug.h" 14 15 #include <Errors.h> 16 #include <MediaDefs.h> 17 #include <MediaAddOn.h> 18 #include <Mime.h> 19 #include <Node.h> 20 #include <StorageDefs.h> 21 22 23 #include <limits.h> 24 #include <stdio.h> 25 #include <string.h> 26 27 28 AbstractFileInterfaceAddOn::~AbstractFileInterfaceAddOn() 29 { 30 } 31 32 33 AbstractFileInterfaceAddOn::AbstractFileInterfaceAddOn(image_id image) : 34 BMediaAddOn(image) 35 { 36 CALLED(); 37 refCount = 0; 38 } 39 40 41 // -------------------------------------------------------- // 42 // BMediaAddOn impl 43 // -------------------------------------------------------- // 44 status_t AbstractFileInterfaceAddOn::InitCheck( 45 const char ** out_failure_text) 46 { 47 CALLED(); 48 return B_OK; 49 } 50 51 int32 AbstractFileInterfaceAddOn::CountFlavors() 52 { 53 CALLED(); 54 return 1; 55 } 56 57 status_t AbstractFileInterfaceAddOn::GetFlavorAt( 58 int32 n, 59 const flavor_info ** out_info) 60 { 61 CALLED(); 62 63 if (n != 0) { 64 PRINT("\t<- B_BAD_INDEX\n"); 65 return B_BAD_INDEX; 66 } 67 68 flavor_info * infos = new flavor_info[1]; 69 AbstractFileInterfaceNode::GetFlavor(&infos[0],n); 70 (*out_info) = infos; 71 return B_OK; 72 } 73 74 75 status_t AbstractFileInterfaceAddOn::GetConfigurationFor( 76 BMediaNode * your_node, 77 BMessage * into_message) 78 { 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; 85 } 86 return node->GetConfigurationFor(into_message); 87 } 88 89 90 bool AbstractFileInterfaceAddOn::WantsAutoStart() 91 { 92 CALLED(); 93 return false; 94 } 95 96 97 status_t AbstractFileInterfaceAddOn::AutoStart( 98 int in_count, 99 BMediaNode ** out_node, 100 int32 * out_internal_id, 101 bool * out_has_more) 102 { 103 CALLED(); 104 return B_OK; 105 } 106 107 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) 116 { 117 CALLED(); 118 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; 124 } 125 126 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) 133 { 134 CALLED(); 135 136 *out_quality = 1.0; 137 *out_internal_id = 0; 138 return B_OK; 139 } 140 141 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) 151 { 152 CALLED(); 153 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; 158 } 159 160 *out_write_items = 0; 161 *out_read_items = 0; 162 163 return B_OK; 164 } 165 166 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) 174 { 175 CALLED(); 176 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; 186 } 187 } 188 189 190 // -------------------------------------------------------- // 191 // main 192 // -------------------------------------------------------- // 193 194 // int main(int argc, char *argv[]) 195 //{ 196 //} 197 198 // -------------------------------------------------------- // 199 // stuffing 200 // -------------------------------------------------------- // 201 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;}; 218