tcp: Fix 64 bit build with debugging features enabled.
[haiku.git] / src / kits / media / FileInterface.cpp
blobc3c8d3d0ac0c1ce886a364f3198d51229716d04b
1 /***********************************************************************
2 * AUTHOR: Marcus Overhagen
3 * FILE: FileInterface.cpp
4 * DESCR:
5 ***********************************************************************/
6 /*
7 * Copyright 2008 Maurice Kalinowski, haiku@kaldience.com
9 * All rights reserved. Distributed under the terms of the MIT License.
13 #include "debug.h"
14 #include "DataExchange.h"
15 #include <string.h>
16 #include <FileInterface.h>
17 #include <MimeType.h>
20 /*************************************************************
21 * protected BFileInterface
22 *************************************************************/
24 BFileInterface::~BFileInterface()
28 /*************************************************************
29 * public BFileInterface
30 *************************************************************/
32 /* nothing */
34 /*************************************************************
35 * protected BFileInterface
36 *************************************************************/
38 BFileInterface::BFileInterface()
39 : BMediaNode("called by FileInterface")
41 CALLED();
43 AddNodeKind(B_FILE_INTERFACE);
47 status_t
48 BFileInterface::HandleMessage(int32 message,
49 const void *data,
50 size_t size)
52 CALLED();
54 status_t rv;
56 switch(message) {
57 case FILEINTERFACE_SET_REF:
59 const fileinterface_set_ref_request *request =
60 (const fileinterface_set_ref_request*) data;
61 fileinterface_set_ref_reply reply;
62 entry_ref ref(request->device, request->directory,
63 request->name);
64 reply.duration = request->duration;
66 rv = SetRef(ref, request->create, &reply.duration);
68 request->SendReply(rv, &reply, sizeof(reply));
69 return B_OK;
71 case FILEINTERFACE_GET_REF:
73 const fileinterface_get_ref_request *request =
74 (const fileinterface_get_ref_request*) data;
75 fileinterface_get_ref_reply reply;
76 entry_ref resultRef;
77 rv = GetRef(&resultRef, reply.mimetype);
78 if (rv == B_OK) {
79 reply.device = resultRef.device;
80 reply.directory = resultRef.directory;
81 strcpy(reply.name, resultRef.name);
83 request->SendReply(rv, &reply, sizeof(reply));
84 return B_OK;
86 case FILEINTERFACE_SNIFF_REF:
88 const fileinterface_sniff_ref_request *request =
89 (const fileinterface_sniff_ref_request*) data;
90 fileinterface_sniff_ref_reply reply;
92 entry_ref ref(request->device, request->directory,
93 request->name);
95 rv = SniffRef(ref, reply.mimetype, &reply.capability);
96 request->SendReply(rv, &reply, sizeof(reply));
98 return B_OK;
100 case FILEINTERFACE_GET_FORMATS:
102 const fileinterface_get_formats_request *request =
103 (const fileinterface_get_formats_request*) data;
104 fileinterface_get_formats_reply reply;
106 media_file_format* formats;
107 area_id area = clone_area("client formats area",
108 (void**)&formats, B_ANY_ADDRESS, B_WRITE_AREA,
109 request->data_area);
111 if (area < 0) {
112 ERROR("BBufferConsumer::FILEINTERFACE_GET_FORMATS:"
113 " can't clone area\n");
114 break;
117 int32 cookie = 0;
118 while (GetNextFileFormat(&cookie, formats) == B_OK) {
119 if (cookie >= request->num_formats)
120 break;
121 formats += sizeof(media_format);
123 reply.filled_slots = cookie;
124 request->SendReply(B_OK, &reply, sizeof(reply));
126 delete_area(area);
127 return B_OK;
129 default:
130 return B_ERROR;
132 return B_ERROR;
135 /*************************************************************
136 * private BFileInterface
137 *************************************************************/
140 private unimplemented
141 BFileInterface::BFileInterface(const BFileInterface &clone)
142 FileInterface & BFileInterface::operator=(const BFileInterface &clone)
145 status_t BFileInterface::_Reserved_FileInterface_0(void *) { return B_ERROR; }
146 status_t BFileInterface::_Reserved_FileInterface_1(void *) { return B_ERROR; }
147 status_t BFileInterface::_Reserved_FileInterface_2(void *) { return B_ERROR; }
148 status_t BFileInterface::_Reserved_FileInterface_3(void *) { return B_ERROR; }
149 status_t BFileInterface::_Reserved_FileInterface_4(void *) { return B_ERROR; }
150 status_t BFileInterface::_Reserved_FileInterface_5(void *) { return B_ERROR; }
151 status_t BFileInterface::_Reserved_FileInterface_6(void *) { return B_ERROR; }
152 status_t BFileInterface::_Reserved_FileInterface_7(void *) { return B_ERROR; }
153 status_t BFileInterface::_Reserved_FileInterface_8(void *) { return B_ERROR; }
154 status_t BFileInterface::_Reserved_FileInterface_9(void *) { return B_ERROR; }
155 status_t BFileInterface::_Reserved_FileInterface_10(void *) { return B_ERROR; }
156 status_t BFileInterface::_Reserved_FileInterface_11(void *) { return B_ERROR; }
157 status_t BFileInterface::_Reserved_FileInterface_12(void *) { return B_ERROR; }
158 status_t BFileInterface::_Reserved_FileInterface_13(void *) { return B_ERROR; }
159 status_t BFileInterface::_Reserved_FileInterface_14(void *) { return B_ERROR; }
160 status_t BFileInterface::_Reserved_FileInterface_15(void *) { return B_ERROR; }