1/* 2 * Copyright 1991-1999, Be Incorporated. 3 * Copyright (c) 1999-2000, Eric Moon. 4 * All rights reserved. 5 * 6 * Redistribution and use in source and binary forms, with or without 7 * modification, are permitted provided that the following conditions 8 * are met: 9 * 10 * 1. Redistributions of source code must retain the above copyright 11 * notice, this list of conditions, and the following disclaimer. 12 * 13 * 2. Redistributions in binary form must reproduce the above copyright 14 * notice, this list of conditions, and the following disclaimer in the 15 * documentation and/or other materials provided with the distribution. 16 * 17 * 3. The name of the author may not be used to endorse or promote products 18 * derived from this software without specific prior written permission. 19 * 20 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR "AS IS" AND ANY EXPRESS OR 21 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 22 * OF TITLE, NON-INFRINGEMENT, MERCHANTABILITY AND FITNESS FOR A PARTICULAR 23 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY 24 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 25 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 26 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED 27 * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR 28 * TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 29 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 30 */ 31 32 33// LoggingConsumerAddOn.cpp 34// e.moon 4jun99 35 36#include "LoggingConsumer.h" 37#include "LoggingConsumerAddOn.h" 38#include <Entry.h> 39#include <Catalog.h> 40#include <Debug.h> 41#include <cstring> 42#include <cstdlib> 43 44// logfile path 45const char* const g_pLogPath = "/tmp/node_log"; 46 47 48#undef B_TRANSLATION_CONTEXT 49#define B_TRANSLATION_CONTEXT "CortexAddOnsLoggingConsumer" 50 51 52// instantiation function 53extern "C" _EXPORT BMediaAddOn* make_media_addon(image_id image) { 54 return new LoggingConsumerAddOn(image); 55} 56 57// -------------------------------------------------------- // 58// ctor/dtor 59// -------------------------------------------------------- // 60 61LoggingConsumerAddOn::~LoggingConsumerAddOn() { 62 PRINT(("~LoggingConsumerAddOn()\n")); 63} 64LoggingConsumerAddOn::LoggingConsumerAddOn(image_id image) : 65 BMediaAddOn(image) {} 66 67// -------------------------------------------------------- // 68// BMediaAddOn impl 69// -------------------------------------------------------- // 70 71status_t LoggingConsumerAddOn::InitCheck( 72 const char** out_failure_text) { 73 return B_OK; 74} 75 76int32 LoggingConsumerAddOn::CountFlavors() { 77 return 1; 78} 79 80status_t LoggingConsumerAddOn::GetFlavorAt( 81 int32 n, 82 const flavor_info** out_info) { 83 if(n) 84 return B_ERROR; 85 86 flavor_info* pInfo = new flavor_info; 87 pInfo->internal_id = n; 88 pInfo->name = B_TRANSLATE("LoggingConsumer"); 89 pInfo->info = B_TRANSLATE("An add-on version of the LoggingConsumer node.\n" 90 "See the Be Developer Newsletter III.18: 5 May, 1999\n" 91 "adapted by Eric Moon (4 June, 1999)"); 92 pInfo->kinds = B_BUFFER_CONSUMER | B_CONTROLLABLE; 93 pInfo->flavor_flags = 0; 94 pInfo->possible_count = 0; 95 96 pInfo->in_format_count = 1; 97 media_format* pFormat = new media_format; 98 pFormat->type = B_MEDIA_UNKNOWN_TYPE; 99 pInfo->in_formats = pFormat; 100 101 pInfo->out_format_count = 0; 102 pInfo->out_formats = 0; 103 104 105 *out_info = pInfo; 106 return B_OK; 107} 108 109BMediaNode* LoggingConsumerAddOn::InstantiateNodeFor( 110 const flavor_info* info, 111 BMessage* config, 112 status_t* out_error) { 113 114 // initialize log file 115 entry_ref ref; 116 get_ref_for_path(g_pLogPath, &ref); 117 LoggingConsumer* pNode = new LoggingConsumer(ref, this); 118 119 // trim down the log's verbosity a touch 120 pNode->SetEnabled(LOG_HANDLE_EVENT, false); 121 122 return pNode; 123} 124 125status_t LoggingConsumerAddOn::GetConfigurationFor( 126 BMediaNode* your_node, 127 BMessage* into_message) { 128 129 // no config yet 130 return B_OK; 131} 132 133// END -- LoggingConsumerAddOn.cpp 134