repository_infos: Enable automatic updates on the main Haiku repostiory.
[haiku.git] / src / apps / cortex / addons / LoggingConsumer / LoggingConsumerAddOn.cpp
blobeba50ae223296f51a40fcef0d49276ea4e51d6d4
1 /*
2 * Copyright 1991-1999, Be Incorporated.
3 * Copyright (c) 1999-2000, Eric Moon.
4 * All rights reserved.
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions
8 * are met:
10 * 1. Redistributions of source code must retain the above copyright
11 * notice, this list of conditions, and the following disclaimer.
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.
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.
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.
33 // LoggingConsumerAddOn.cpp
34 // e.moon 4jun99
36 #include "LoggingConsumer.h"
37 #include "LoggingConsumerAddOn.h"
38 #include <Entry.h>
39 #include <Debug.h>
40 #include <cstring>
41 #include <cstdlib>
43 // logfile path
44 const char* const g_pLogPath = "/tmp/node_log";
47 // instantiation function
48 extern "C" _EXPORT BMediaAddOn* make_media_addon(image_id image) {
49 return new LoggingConsumerAddOn(image);
52 // -------------------------------------------------------- //
53 // ctor/dtor
54 // -------------------------------------------------------- //
56 LoggingConsumerAddOn::~LoggingConsumerAddOn() {
57 PRINT(("~LoggingConsumerAddOn()\n"));
59 LoggingConsumerAddOn::LoggingConsumerAddOn(image_id image) :
60 BMediaAddOn(image) {}
62 // -------------------------------------------------------- //
63 // BMediaAddOn impl
64 // -------------------------------------------------------- //
66 status_t LoggingConsumerAddOn::InitCheck(
67 const char** out_failure_text) {
68 return B_OK;
71 int32 LoggingConsumerAddOn::CountFlavors() {
72 return 1;
75 status_t LoggingConsumerAddOn::GetFlavorAt(
76 int32 n,
77 const flavor_info** out_info) {
78 if(n)
79 return B_ERROR;
81 flavor_info* pInfo = new flavor_info;
82 pInfo->internal_id = n;
83 pInfo->name = (char*)"LoggingConsumer";
84 pInfo->info = (char*)"An add-on version of the LoggingConsumer node.\n"
85 "See the Be Developer Newsletter III.18: 5 May, 1999\n"
86 "adapted by Eric Moon (4 June, 1999)";
87 pInfo->kinds = B_BUFFER_CONSUMER | B_CONTROLLABLE;
88 pInfo->flavor_flags = 0;
89 pInfo->possible_count = 0;
91 pInfo->in_format_count = 1;
92 media_format* pFormat = new media_format;
93 pFormat->type = B_MEDIA_UNKNOWN_TYPE;
94 pInfo->in_formats = pFormat;
96 pInfo->out_format_count = 0;
97 pInfo->out_formats = 0;
100 *out_info = pInfo;
101 return B_OK;
104 BMediaNode* LoggingConsumerAddOn::InstantiateNodeFor(
105 const flavor_info* info,
106 BMessage* config,
107 status_t* out_error) {
109 // initialize log file
110 entry_ref ref;
111 get_ref_for_path(g_pLogPath, &ref);
112 LoggingConsumer* pNode = new LoggingConsumer(ref, this);
114 // trim down the log's verbosity a touch
115 pNode->SetEnabled(LOG_HANDLE_EVENT, false);
117 return pNode;
120 status_t LoggingConsumerAddOn::GetConfigurationFor(
121 BMediaNode* your_node,
122 BMessage* into_message) {
124 // no config yet
125 return B_OK;
128 // END -- LoggingConsumerAddOn.cpp