From 5559d51db7a1ac4f2f87531a6efd213eadcb5831 Mon Sep 17 00:00:00 2001 From: Augustin Cavalier Date: Sat, 7 May 2016 21:09:00 -0400 Subject: [PATCH] bluetooth_server: Nuke the weird logging system, just use macros... ... just like everything else on Haiku does. Permanently enabled for the time being. At least I can tell what's going on now. --- headers/private/bluetooth/bluetoothserver_p.h | 5 +- src/preferences/bluetooth/BluetoothWindow.cpp | 13 +- src/servers/bluetooth/BluetoothServer.cpp | 118 ++++------- src/servers/bluetooth/Debug.h | 18 ++ src/servers/bluetooth/DeviceManager.cpp | 25 ++- .../bluetooth/HCITransportAccessor.cpp | 4 +- src/servers/bluetooth/Jamfile | 1 - src/servers/bluetooth/LocalDeviceImpl.cpp | 155 ++++++--------- src/servers/bluetooth/Output.cpp | 187 ------------------ src/servers/bluetooth/Output.h | 73 ------- 10 files changed, 125 insertions(+), 474 deletions(-) create mode 100644 src/servers/bluetooth/Debug.h delete mode 100644 src/servers/bluetooth/Output.cpp delete mode 100644 src/servers/bluetooth/Output.h diff --git a/headers/private/bluetooth/bluetoothserver_p.h b/headers/private/bluetooth/bluetoothserver_p.h index aa735664d5..70dac2ecc4 100644 --- a/headers/private/bluetooth/bluetoothserver_p.h +++ b/headers/private/bluetooth/bluetoothserver_p.h @@ -7,7 +7,7 @@ /* Kit Comunication */ -// LocalDevice +// LocalDevice #define BT_MSG_COUNT_LOCAL_DEVICES 'btCd' #define BT_MSG_ACQUIRE_LOCAL_DEVICE 'btAd' #define BT_MSG_HANDLE_SIMPLE_REQUEST 'btsR' @@ -22,7 +22,4 @@ #define BT_MSG_INQUIRY_ERROR 'IqER' #define BT_MSG_INQUIRY_DEVICE 'IqDE' -// Server -#define BT_MSG_SERVER_SHOW_CONSOLE 'btsc' - #endif diff --git a/src/preferences/bluetooth/BluetoothWindow.cpp b/src/preferences/bluetooth/BluetoothWindow.cpp index 9c186db38c..c39cb157c8 100644 --- a/src/preferences/bluetooth/BluetoothWindow.cpp +++ b/src/preferences/bluetooth/BluetoothWindow.cpp @@ -30,7 +30,6 @@ static const uint32 kMsgRevert = 'rvrt'; static const uint32 kMsgStartServices = 'SrSR'; static const uint32 kMsgStopServices = 'StST'; -static const uint32 kMsgShowDebug = 'ShDG'; LocalDevice* ActiveLocalDevice = NULL; @@ -59,10 +58,7 @@ BluetoothWindow::BluetoothWindow(BRect frame) new BMessage(kMsgStopServices), 0)); menu->AddSeparatorItem(); menu->AddItem(new BMenuItem( - B_TRANSLATE("Show bluetooth console" B_UTF8_ELLIPSIS), - new BMessage(kMsgShowDebug), 0)); - menu->AddItem(new BMenuItem( - B_TRANSLATE("Refresh LocalDevices" B_UTF8_ELLIPSIS), + B_TRANSLATE("Refresh local devices" B_UTF8_ELLIPSIS), new BMessage(kMsgRefresh), 0)); fMenubar->AddItem(menu); @@ -134,13 +130,6 @@ BluetoothWindow::MessageReceived(BMessage* message) printf("kMsgStopServices: %s\n", strerror(error)); } break; - case kMsgShowDebug: - if (be_roster->IsRunning(BLUETOOTH_SIGNATURE)) { - status_t error = BMessenger(BLUETOOTH_SIGNATURE).SendMessage( - BT_MSG_SERVER_SHOW_CONSOLE); - printf("kMsgShowDebug: %s\n", strerror(error)); - } - break; case kMsgAddToRemoteList: PostMessage(message, fRemoteDevices); diff --git a/src/servers/bluetooth/BluetoothServer.cpp b/src/servers/bluetooth/BluetoothServer.cpp index 1abf460c8a..b6865b1413 100644 --- a/src/servers/bluetooth/BluetoothServer.cpp +++ b/src/servers/bluetooth/BluetoothServer.cpp @@ -16,6 +16,7 @@ #include #include #include +#include #include #include @@ -28,7 +29,7 @@ #include "BluetoothServer.h" #include "DeskbarReplicant.h" #include "LocalDeviceImpl.h" -#include "Output.h" +#include "Debug.h" status_t @@ -36,7 +37,7 @@ DispatchEvent(struct hci_event_header* header, int32 code, size_t size) { // we only handle events if (GET_PORTCODE_TYPE(code)!= BT_EVENT) { - Output::Instance()->Post("Wrong type frame code", BLACKBOARD_KIT); + TRACE_BT("BluetoothServer: Wrong type frame code\n"); return B_OK; } @@ -45,7 +46,7 @@ DispatchEvent(struct hci_event_header* header, int32 code, size_t size) LocateLocalDeviceImpl(GET_PORTCODE_HID(code)); if (lDeviceImplementation == NULL) { - Output::Instance()->Post("LocalDevice could not be fetched", BLACKBOARD_KIT); + TRACE_BT("BluetoothServer: LocalDevice could not be fetched\n"); return B_OK; } @@ -61,14 +62,6 @@ BluetoothServer::BluetoothServer() fSDPThreadID(-1), fIsShuttingDown(false) { - Output::Instance()->Run(); - Output::Instance()->SetTitle("Bluetooth message gathering"); - - Output::Instance()->AddTab("General", BLACKBOARD_GENERAL); - Output::Instance()->AddTab("Device Manager", BLACKBOARD_DEVICEMANAGER); - Output::Instance()->AddTab("Kit", BLACKBOARD_KIT); - Output::Instance()->AddTab("SDP", BLACKBOARD_SDP); - fDeviceManager = new DeviceManager(); fLocalDevicesList.MakeEmpty(); @@ -91,14 +84,11 @@ bool BluetoothServer::QuitRequested(void) status_t threadReturnStatus; wait_for_thread(fSDPThreadID, &threadReturnStatus); - printf("SDP server thread exited with: %s\n", strerror(threadReturnStatus)); - - // Finish quitting - Output::Instance()->Lock(); - Output::Instance()->Quit(); + TRACE_BT("BluetoothServer server thread exited with: %s\n", + strerror(threadReturnStatus)); delete fEventListener2; - printf("Shutting down bluetooth_server.\n"); + TRACE_BT("Shutting down bluetooth_server.\n"); return BApplication::QuitRequested(); } @@ -110,7 +100,6 @@ void BluetoothServer::ArgvReceived(int32 argc, char **argv) if (strcmp(argv[1], "--finish") == 0) PostMessage(B_QUIT_REQUESTED); } - } @@ -122,11 +111,9 @@ void BluetoothServer::ReadyToRun(void) fDeviceManager->StartMonitoringDevice("bluetooth/h5"); if (fEventListener2->Launch() != B_OK) - Output::Instance()->Post("Bluetooth event listener failed\n", - BLACKBOARD_GENERAL); + TRACE_BT("General: Bluetooth event listener failed\n"); else - Output::Instance()->Post("Bluetooth event listener Ready\n", - BLACKBOARD_GENERAL); + TRACE_BT("General: Bluetooth event listener Ready\n"); _InstallDeskbarIcon(); @@ -137,8 +124,8 @@ void BluetoothServer::ReadyToRun(void) #define _USE_FAKE_SDP_SERVER #ifdef _USE_FAKE_SDP_SERVER if (fSDPThreadID <= 0 || resume_thread(fSDPThreadID) != B_OK) { - Output::Instance()->Postf(BLACKBOARD_SDP, - "Failed launching the SDP server thread: %x\n", fSDPThreadID); + TRACE_BT("BluetoothServer: Failed launching the SDP server thread: %lx\n", + fSDPThreadID); } #endif } @@ -160,11 +147,9 @@ void BluetoothServer::MessageReceived(BMessage* message) case BT_MSG_ADD_DEVICE: { BString str; - message->FindString("name", &str); - Output::Instance()->Postf(BLACKBOARD_GENERAL, - "Requested LocalDevice %s\n", str.String()); + TRACE_BT("BluetoothServer: Requested LocalDevice %s\n", str.String()); BPath path(str.String()); @@ -174,15 +159,10 @@ void BluetoothServer::MessageReceived(BMessage* message) if (lDeviceImpl->GetID() >= 0) { fLocalDevicesList.AddItem(lDeviceImpl); - Output::Instance()->AddTab("Local Device", - BLACKBOARD_LD(lDeviceImpl->GetID())); - Output::Instance()->Postf(BLACKBOARD_LD(lDeviceImpl->GetID()), - "LocalDevice %s id=%x added\n", str.String(), + TRACE_BT("LocalDevice %s id=%lx added\n", str.String(), lDeviceImpl->GetID()); - } else { - Output::Instance()->Post("Adding LocalDevice hci id invalid\n", - BLACKBOARD_GENERAL); + TRACE_BT("BluetoothServer: Adding LocalDevice hci id invalid\n"); } status = B_WOULD_BLOCK; @@ -231,10 +211,6 @@ void BluetoothServer::MessageReceived(BMessage* message) return; } - case BT_MSG_SERVER_SHOW_CONSOLE: - ShowWindow(Output::Instance()); - break; - default: BApplication::MessageReceived(message); break; @@ -299,7 +275,7 @@ BluetoothServer::LocateLocalDeviceImpl(hci_id hid) status_t BluetoothServer::HandleLocalDevicesCount(BMessage* message, BMessage* reply) { - Output::Instance()->Post("Count Requested\n", BLACKBOARD_KIT); + TRACE_BT("BluetoothServer: count requested\n"); return reply->AddInt32("count", fLocalDevicesList.CountItems()); } @@ -315,16 +291,14 @@ BluetoothServer::HandleAcquireLocalDevice(BMessage* message, BMessage* reply) static int32 lastIndex = 0; if (message->FindInt32("hci_id", &hid) == B_OK) { - Output::Instance()->Post("GetLocalDevice requested with id\n", - BLACKBOARD_KIT); + TRACE_BT("BluetoothServer: GetLocalDevice requested with id\n"); lDeviceImpl = LocateDelegateFromMessage(message); } else if (message->FindData("bdaddr", B_ANY_TYPE, (const void**)&bdaddr, &size) == B_OK) { // Try to find out when the user specified the address - Output::Instance()->Post("GetLocalDevice requested with bdaddr\n", - BLACKBOARD_KIT); + TRACE_BT("BluetoothServer: GetLocalDevice requested with bdaddr\n"); for (lastIndex = 0; lastIndex < fLocalDevicesList.CountItems(); lastIndex ++) { // TODO: Only possible if the property is available @@ -338,7 +312,7 @@ BluetoothServer::HandleAcquireLocalDevice(BMessage* message, BMessage* reply) } else { // Careless, any device not performing operations will be fine - Output::Instance()->Post("GetLocalDevice plain request\n", BLACKBOARD_KIT); + TRACE_BT("BluetoothServer: GetLocalDevice plain request\n"); // from last assigned till end for (int index = lastIndex + 1; index < fLocalDevicesList.CountItems(); index++) { @@ -346,8 +320,7 @@ BluetoothServer::HandleAcquireLocalDevice(BMessage* message, BMessage* reply) if (lDeviceImpl != NULL && lDeviceImpl->Available()) { printf("Requested local device %" B_PRId32 "\n", lDeviceImpl->GetID()); - Output::Instance()->Postf(BLACKBOARD_KIT, - "Device available: %lx\n", lDeviceImpl->GetID()); + TRACE_BT("BluetoothServer: Device available: %lx\n", lDeviceImpl->GetID()); lastIndex = index; break; } @@ -360,8 +333,7 @@ BluetoothServer::HandleAcquireLocalDevice(BMessage* message, BMessage* reply) if (lDeviceImpl != NULL && lDeviceImpl->Available()) { printf("Requested local device %" B_PRId32 "\n", lDeviceImpl->GetID()); - Output::Instance()->Postf(BLACKBOARD_KIT, - "Device available: %lx\n", lDeviceImpl->GetID()); + TRACE_BT("BluetoothServer: Device available: %lx\n", lDeviceImpl->GetID()); lastIndex = index; break; } @@ -375,7 +347,7 @@ BluetoothServer::HandleAcquireLocalDevice(BMessage* message, BMessage* reply) hid = lDeviceImpl->GetID(); lDeviceImpl->Acquire(); - Output::Instance()->Postf(BLACKBOARD_KIT, "Device acquired %lx\n", hid); + TRACE_BT("BluetoothServer: Device acquired %lx\n", hid); return reply->AddInt32("hci_id", hid); } @@ -431,8 +403,7 @@ BluetoothServer::HandleGetProperty(BMessage* message, BMessage* reply) // Find out if there is a property being requested, if (message->FindString("property", &propertyRequested) == B_OK) { - Output::Instance()->Postf(BLACKBOARD_LD(lDeviceImpl->GetID()), - "Searching %s property...\n", propertyRequested); + TRACE_BT("BluetoothServer: Searching %s property...\n", propertyRequested); // Check if the property has been already retrieved if (lDeviceImpl->IsPropertyAvailable(propertyRequested)) { @@ -471,8 +442,7 @@ BluetoothServer::HandleGetProperty(BMessage* message, BMessage* reply) } else { - Output::Instance()->Postf(BLACKBOARD_LD(lDeviceImpl->GetID()), - "Property %s could not be satisfied\n", propertyRequested); + TRACE_BT("BluetoothServer: Property %s could not be satisfied\n", propertyRequested); } } } @@ -497,13 +467,12 @@ BluetoothServer::SDPServerThread(void* data) status_t status; char buffer[512] = ""; - Output::Instance()->Postf(BLACKBOARD_SDP, "SDP server thread up...\n"); + TRACE_BT("SDP: SDP server thread up...\n"); socketServer = socket(PF_BLUETOOTH, SOCK_STREAM, BLUETOOTH_PROTO_L2CAP); if (socketServer < 0) { - Output::Instance()->Post("Could not create server socket ...\n", - BLACKBOARD_SDP); + TRACE_BT("SDP: Could not create server socket ...\n"); return B_ERROR; } @@ -518,8 +487,7 @@ BluetoothServer::SDPServerThread(void* data) sizeof(struct sockaddr_l2cap)); if (status < 0) { - Output::Instance()->Postf(BLACKBOARD_SDP, - "Could not bind server socket %d ...\n", status); + TRACE_BT("SDP: Could not bind server socket (%s)...\n", strerror(status)); return status; } @@ -530,42 +498,36 @@ BluetoothServer::SDPServerThread(void* data) status = listen(socketServer, 10); if (status != B_OK) { - Output::Instance()->Postf(BLACKBOARD_SDP, - "Could not listen server socket %d ...\n", status); + TRACE_BT("SDP: Could not listen server socket (%s)...\n", strerror(status)); return status; } while (!server->fIsShuttingDown) { - Output::Instance()->Postf(BLACKBOARD_SDP, - "Waiting connection for socket %d ...\n", socketServer); + TRACE_BT("SDP: Waiting connection for socket (%s)...\n", strerror(status)); uint len = sizeof(struct sockaddr_l2cap); client = accept(socketServer, (struct sockaddr*)&loc_addr, &len); - Output::Instance()->Postf(BLACKBOARD_SDP, - "Incomming connection... %ld\n", client); + TRACE_BT("SDP: Incomming connection... %d\n", client); ssize_t receivedSize; do { receivedSize = recv(client, buffer, 29 , 0); if (receivedSize < 0) - Output::Instance()->Post("Error reading client socket\n", - BLACKBOARD_SDP); + TRACE_BT("SDP: Error reading client socket\n"); else { - Output::Instance()->Postf(BLACKBOARD_SDP, - "Received from SDP client: %ld:\n", receivedSize); + TRACE_BT("SDP: Received from SDP client: %ld:\n", receivedSize); for (int i = 0; i < receivedSize ; i++) - Output::Instance()->Postf(BLACKBOARD_SDP, "%x:", buffer[i]); + TRACE_BT("SDP: %x:", buffer[i]); - Output::Instance()->Post("\n", BLACKBOARD_SDP); + TRACE_BT("\n"); } } while (receivedSize >= 0); snooze(5000000); - Output::Instance()->Post("\nWaiting for next connection...\n", - BLACKBOARD_SDP); + TRACE_BT("SDP: Waiting for next connection...\n"); } // Close the socket @@ -600,9 +562,8 @@ BluetoothServer::_InstallDeskbarIcon() } status_t res = deskbar.AddItem(&appInfo.ref); - if (res != B_OK) { - printf("Failed adding deskbar icon: %" B_PRId32 "\n", res); - } + if (res != B_OK) + TRACE_BT("Failed adding deskbar icon: %" B_PRId32 "\n", res); } @@ -611,9 +572,8 @@ BluetoothServer::_RemoveDeskbarIcon() { BDeskbar deskbar; status_t res = deskbar.RemoveItem(kDeskbarItemName); - if (res != B_OK) { - printf("Failed removing Deskbar icon: %" B_PRId32 ": \n", res); - } + if (res != B_OK) + TRACE_BT("Failed removing Deskbar icon: %" B_PRId32 ": \n", res); } @@ -624,8 +584,6 @@ BluetoothServer::_RemoveDeskbarIcon() int main(int /*argc*/, char** /*argv*/) { - setbuf(stdout, NULL); - BluetoothServer* bluetoothServer = new BluetoothServer; bluetoothServer->Run(); diff --git a/src/servers/bluetooth/Debug.h b/src/servers/bluetooth/Debug.h new file mode 100644 index 0000000000..5d6ccc5cc5 --- /dev/null +++ b/src/servers/bluetooth/Debug.h @@ -0,0 +1,18 @@ +/* + * Copyright 2016, Haiku, Inc. All Rights Reserved. + * Distributed under the terms of the MIT License. + * + * Authors: + * Augustin Cavalier, + */ +#ifndef _BLUETOOTH_SERVER_DEBUG_H +#define _BLUETOOTH_SERVER_DEBUG_H + +//#ifdef TRACE_BLUETOOTH_SERVER +#if 1 +# define TRACE_BT(x...) printf(x) +#else +# define TRACE_BT(x) +#endif + +#endif diff --git a/src/servers/bluetooth/DeviceManager.cpp b/src/servers/bluetooth/DeviceManager.cpp index 8f0eaa254a..4470ecd36f 100644 --- a/src/servers/bluetooth/DeviceManager.cpp +++ b/src/servers/bluetooth/DeviceManager.cpp @@ -16,7 +16,7 @@ #include "DeviceManager.h" #include "LocalDeviceImpl.h" -#include "Output.h" +#include "Debug.h" #include "BluetoothServer.h" #include @@ -36,14 +36,14 @@ DeviceManager::MessageReceived(BMessage* msg) const char *name; BDirectory dir; - Output::Instance()->Post("Something new in the bus ... ", BLACKBOARD_DEVICEMANAGER); + TRACE_BT("Something new in the bus ... "); if ((msg->FindInt32("device", &ref.device)!=B_OK) || (msg->FindInt64("directory", &ref.directory)!=B_OK) || (msg->FindString("name", &name) != B_OK)) return; - Output::Instance()->Postf(BLACKBOARD_DEVICEMANAGER, " -> %s\n", name); + TRACE_BT("DeviceManager: -> %s\n", name); ref.set_name(name); @@ -62,8 +62,7 @@ DeviceManager::MessageReceived(BMessage* msg) break; case B_ENTRY_REMOVED: { - Output::Instance()->Post("Something removed from the bus ...\n", - BLACKBOARD_DEVICEMANAGER); + TRACE_BT("Something removed from the bus ...\n"); } break; @@ -86,21 +85,20 @@ DeviceManager::AddDirectory(node_ref *nref) BDirectory directory(nref); status_t status = directory.InitCheck(); if (status != B_OK) { - Output::Instance()->Post("AddDirectory::Initcheck Failed\n", BLACKBOARD_DEVICEMANAGER); + TRACE_BT("AddDirectory::Initcheck Failed\n"); return status; } status = watch_node(nref, B_WATCH_DIRECTORY, this); if (status != B_OK) { - Output::Instance()->Post("AddDirectory::watch_node Failed\n", BLACKBOARD_DEVICEMANAGER); + TRACE_BT("AddDirectory::watch_node Failed\n"); return status; } // BPath path(*nref); // BString str(path.Path()); // -// Output::Instance()->Postf(BLACKBOARD_DEVICEMANAGER, -// "Exploring entries in %s\n", str.String()); +// TRACE_BT("DeviceManager: Exploring entries in %s\n", str.String()); entry_ref ref; status_t error; @@ -109,8 +107,7 @@ DeviceManager::AddDirectory(node_ref *nref) AddDevice(&ref); } - Output::Instance()->Postf(BLACKBOARD_DEVICEMANAGER, - "Finished exploring entries(%s)\n", strerror(error)); + TRACE_BT("DeviceManager: Finished exploring entries(%s)\n", strerror(error)); return (error == B_OK || error == B_ENTRY_NOT_FOUND)?B_OK:error; } @@ -157,7 +154,7 @@ DeviceManager::AddDevice(entry_ref* ref) msg->AddString("name", *str ); - Output::Instance()->Postf(BLACKBOARD_DEVICEMANAGER, "Device %s registered\n", path.Path()); + TRACE_BT("DeviceManager: Device %s registered\n", path.Path()); return be_app_messenger.SendMessage(msg); } @@ -233,7 +230,7 @@ DeviceManager::StartMonitoringDevice(const char *device) if (error != B_OK) return error; - Output::Instance()->Postf(BLACKBOARD_DEVICEMANAGER, "%s path being monitored\n", path.Path()); + TRACE_BT("DeviceManager: %s path being monitored\n", path.Path()); // We are monitoring the root we may have already directories inside // to be monitored @@ -247,7 +244,7 @@ DeviceManager::StartMonitoringDevice(const char *device) AddDirectory(&driverNRef); } - Output::Instance()->Postf(BLACKBOARD_DEVICEMANAGER, "Finished exploring entries(%s)\n", strerror(error)); + TRACE_BT("DeviceManager: Finished exploring entries(%s)\n", strerror(error)); #if 0 HCIDelegate *tmphd = NULL; diff --git a/src/servers/bluetooth/HCITransportAccessor.cpp b/src/servers/bluetooth/HCITransportAccessor.cpp index 8e64949323..2353d4e346 100644 --- a/src/servers/bluetooth/HCITransportAccessor.cpp +++ b/src/servers/bluetooth/HCITransportAccessor.cpp @@ -1,8 +1,6 @@ /* * Copyright 2007-2008 Oliver Ruiz Dorantes, oliver.ruiz.dorantes_at_gmail.com - * * All rights reserved. Distributed under the terms of the MIT License. - * */ @@ -10,7 +8,7 @@ #include "BluetoothServer.h" #include "HCITransportAccessor.h" -#include "Output.h" + HCITransportAccessor::HCITransportAccessor(BPath* path) : HCIDelegate(path) { diff --git a/src/servers/bluetooth/Jamfile b/src/servers/bluetooth/Jamfile index 1ae2edbce3..5270a1ae2f 100644 --- a/src/servers/bluetooth/Jamfile +++ b/src/servers/bluetooth/Jamfile @@ -15,7 +15,6 @@ Server bluetooth_server HCITransportAccessor.cpp LocalDeviceHandler.cpp LocalDeviceImpl.cpp - Output.cpp : be network libbluetooth.so [ TargetLibstdc++ ] ; diff --git a/src/servers/bluetooth/LocalDeviceImpl.cpp b/src/servers/bluetooth/LocalDeviceImpl.cpp index 264efc783f..f8ec8f71cf 100644 --- a/src/servers/bluetooth/LocalDeviceImpl.cpp +++ b/src/servers/bluetooth/LocalDeviceImpl.cpp @@ -9,7 +9,7 @@ #include "LocalDeviceImpl.h" #include "CommandManager.h" -#include "Output.h" +#include "Debug.h" #include #include @@ -84,7 +84,7 @@ LocalDeviceImpl::Unregister() msg->AddInt32("hci_id", fHCIDelegate->Id()); - Output::Instance()->Postf(BLACKBOARD_DEVICEMANAGER, "Unregistering %x\n", + TRACE_BT("LocalDeviceImpl: Unregistering %lx\n", fHCIDelegate->Id()); be_app_messenger.SendMessage(msg); @@ -287,8 +287,7 @@ LocalDeviceImpl::HandleEvent(struct hci_event_header* event) struct hci_ev_cmd_complete* commandComplete = JumpEventHeader(event); - Output::Instance()->Postf(BLACKBOARD_LD(GetID()), - "Incomming CommandComplete(%d) for %s\n", commandComplete->ncmd, + TRACE_BT("LocalDeviceImpl: Incoming CommandComplete(%d) for %s\n", commandComplete->ncmd, BluetoothCommandOpcode(commandComplete->opcode)); request = FindPetition(event->ecode, commandComplete->opcode, @@ -304,8 +303,7 @@ LocalDeviceImpl::HandleEvent(struct hci_event_header* event) struct hci_ev_cmd_status* commandStatus = JumpEventHeader(event); - Output::Instance()->Postf(BLACKBOARD_LD(GetID()), - "Incomming CommandStatus(%d)(%s) for %s\n", commandStatus->ncmd, + TRACE_BT("LocalDeviceImpl: Incoming CommandStatus(%d)(%s) for %s\n", commandStatus->ncmd, BluetoothError(commandStatus->status), BluetoothCommandOpcode(commandStatus->opcode)); @@ -317,8 +315,7 @@ LocalDeviceImpl::HandleEvent(struct hci_event_header* event) break; } default: - Output::Instance()->Postf(BLACKBOARD_LD(GetID()), - "Incomming %s event\n", BluetoothEvent(event->ecode)); + TRACE_BT("LocalDeviceImpl: Incoming %s event\n", BluetoothEvent(event->ecode)); request = FindPetition(event->ecode); if (request != NULL) @@ -328,8 +325,7 @@ LocalDeviceImpl::HandleEvent(struct hci_event_header* event) } if (request == NULL) { - Output::Instance()->Postf(BLACKBOARD_LD(GetID()), - "Event %s could not be understood or delivered\n", + TRACE_BT("LocalDeviceImpl: Event %s could not be understood or delivered\n", BluetoothEvent(event->ecode)); HandleUnexpectedEvent(event); } @@ -343,9 +339,8 @@ LocalDeviceImpl::HandleEvent(struct hci_event_header* event) void LocalDeviceImpl::CommandComplete(struct hci_ev_cmd_complete* event, - BMessage* request, - int32 index) { - + BMessage* request, int32 index) +{ int16 opcodeExpected; BMessage reply; status_t status; @@ -354,8 +349,7 @@ LocalDeviceImpl::CommandComplete(struct hci_ev_cmd_complete* event, request->FindInt16("opcodeExpected", index, &opcodeExpected); if (request->IsSourceWaiting() == false) { - Output::Instance()->Post("Nobody waiting for the event\n", - BLACKBOARD_KIT); + TRACE_BT("LocalDeviceImpl: Nobody waiting for the event\n"); } switch ((uint16)opcodeExpected) { @@ -391,8 +385,7 @@ LocalDeviceImpl::CommandComplete(struct hci_ev_cmd_complete* event, } } - Output::Instance()->Postf(BLACKBOARD_LD(GetID()), - "Reply for Local Version %x\n", version->status); + TRACE_BT("LocalDeviceImpl: Reply for Local Version %x\n", version->status); reply.AddInt8("status", version->status); status = request->SendReply(&reply); @@ -414,8 +407,7 @@ LocalDeviceImpl::CommandComplete(struct hci_ev_cmd_complete* event, fProperties->AddInt16("page_timeout", pageTimeout->page_timeout); - Output::Instance()->Postf(BLACKBOARD_LD(GetID()), - "Page Timeout=%x\n", pageTimeout->page_timeout); + TRACE_BT("LocalDeviceImpl: Page Timeout=%x\n", pageTimeout->page_timeout); } reply.AddInt8("status", pageTimeout->status); @@ -464,15 +456,13 @@ LocalDeviceImpl::CommandComplete(struct hci_ev_cmd_complete* event, fProperties->AddBool("role_switch_capable", roleSwitch); fProperties->AddBool("encrypt_capable", encryptCapable); - Output::Instance()->Postf(BLACKBOARD_KIT, - "Packet type %x role switch %d encrypt %d\n", + TRACE_BT("LocalDeviceImpl: Packet type %x role switch %d encrypt %d\n", packetType, roleSwitch, encryptCapable); } } - Output::Instance()->Postf(BLACKBOARD_KIT, - "Reply for Local Features %x\n", features->status); + TRACE_BT("LocalDeviceImpl: Reply for Local Features %x\n", features->status); reply.AddInt8("status", features->status); status = request->SendReply(&reply); @@ -506,8 +496,7 @@ LocalDeviceImpl::CommandComplete(struct hci_ev_cmd_complete* event, } - Output::Instance()->Postf(BLACKBOARD_KIT, - "Reply for Read Buffer Size %x\n", buffer->status); + TRACE_BT("LocalDeviceImpl: Reply for Read Buffer Size %x\n", buffer->status); reply.AddInt8("status", buffer->status); @@ -531,8 +520,7 @@ LocalDeviceImpl::CommandComplete(struct hci_ev_cmd_complete* event, sizeof(bdaddr_t)); } - Output::Instance()->Postf(BLACKBOARD_KIT, - "Read bdaddr status = %x\n", readbdaddr->status); + TRACE_BT("LocalDeviceImpl: Read bdaddr status = %x\n", readbdaddr->status); reply.AddInt8("status", readbdaddr->status); status = request->SendReply(&reply); @@ -556,8 +544,7 @@ LocalDeviceImpl::CommandComplete(struct hci_ev_cmd_complete* event, sizeof(classDev->dev_class)); } - Output::Instance()->Postf(BLACKBOARD_KIT, - "Read DeviceClass status = %x DeviceClass = [%x][%x][%x]\n", + TRACE_BT("LocalDeviceImpl: Read DeviceClass status = %x DeviceClass = [%x][%x][%x]\n", classDev->status, classDev->dev_class[0], classDev->dev_class[1], classDev->dev_class[2]); @@ -584,8 +571,7 @@ LocalDeviceImpl::CommandComplete(struct hci_ev_cmd_complete* event, (const char*)readLocalName->local_name); } - Output::Instance()->Postf(BLACKBOARD_KIT, - "Friendly name status %x\n", readLocalName->status); + TRACE_BT("LocalDeviceImpl: Friendly name status %x\n", readLocalName->status); reply.AddInt8("status", readLocalName->status); status = request->SendReply(&reply); @@ -602,8 +588,7 @@ LocalDeviceImpl::CommandComplete(struct hci_ev_cmd_complete* event, uint8* statusReply = (uint8*)(event + 1); // TODO: This reply has to match the BDADDR of the outgoing message - Output::Instance()->Postf(BLACKBOARD_KIT, - "pincode accept status %x\n", *statusReply); + TRACE_BT("LocalDeviceImpl: pincode accept status %x\n", *statusReply); reply.AddInt8("status", *statusReply); status = request->SendReply(&reply); @@ -622,8 +607,7 @@ LocalDeviceImpl::CommandComplete(struct hci_ev_cmd_complete* event, // TODO: This reply might match the BDADDR of the outgoing message // => FindPetition should be expanded.... - Output::Instance()->Postf(BLACKBOARD_KIT, - "pincode reject status %x\n", *statusReply); + TRACE_BT("LocalDeviceImpl: pincode reject status %x\n", *statusReply); reply.AddInt8("status", *statusReply); status = request->SendReply(&reply); @@ -641,8 +625,7 @@ LocalDeviceImpl::CommandComplete(struct hci_ev_cmd_complete* event, = JumpEventHeader(event); - Output::Instance()->Postf(BLACKBOARD_LD(GetID()), - "Status %s MaxKeys=%d, KeysRead=%d\n", + TRACE_BT("LocalDeviceImpl: Status %s MaxKeys=%d, KeysRead=%d\n", BluetoothError(linkKeyRetrieval->status), linkKeyRetrieval->max_num_keys, linkKeyRetrieval->num_keys_read); @@ -663,8 +646,7 @@ LocalDeviceImpl::CommandComplete(struct hci_ev_cmd_complete* event, = JumpEventHeader(event); - Output::Instance()->Postf(BLACKBOARD_LD(GetID()), - "Status %s addresss=%s\n", BluetoothError(linkKeyReply->status), + TRACE_BT("LocalDeviceImpl: Status %s addresss=%s\n", BluetoothError(linkKeyReply->status), bdaddrUtils::ToString(linkKeyReply->bdaddr).String()); ClearWantedEvent(request, HCI_EVENT_CMD_COMPLETE, opcodeExpected); @@ -680,8 +662,7 @@ LocalDeviceImpl::CommandComplete(struct hci_ev_cmd_complete* event, if (scanEnable->status == BT_OK) { fProperties->AddInt8("scan_enable", scanEnable->enable); - Output::Instance()->Postf(BLACKBOARD_LD(GetID()), - "enable = %x\n", scanEnable->enable); + TRACE_BT("LocalDeviceImpl: enable = %x\n", scanEnable->enable); } reply.AddInt8("status", scanEnable->status); @@ -707,8 +688,7 @@ LocalDeviceImpl::CommandComplete(struct hci_ev_cmd_complete* event, { reply.AddInt8("status", *(uint8*)(event + 1)); - Output::Instance()->Postf(BLACKBOARD_LD(GetID()), - "%s for %s status %x\n", __FUNCTION__, + TRACE_BT("LocalDeviceImpl: %s for %s status %x\n", __FUNCTION__, BluetoothCommandOpcode(opcodeExpected), *(uint8*)(event + 1)); status = request->SendReply(&reply); @@ -721,8 +701,7 @@ LocalDeviceImpl::CommandComplete(struct hci_ev_cmd_complete* event, } default: - Output::Instance()->Post("Command Complete not handled\n", - BLACKBOARD_KIT); + TRACE_BT("LocalDeviceImpl: Command Complete not handled\n"); break; } @@ -742,8 +721,7 @@ LocalDeviceImpl::CommandStatus(struct hci_ev_cmd_status* event, request->FindInt16("opcodeExpected", index, &opcodeExpected); if (request->IsSourceWaiting() == false) { - Output::Instance()->Post("Nobody waiting for the event\n", - BLACKBOARD_KIT); + TRACE_BT("LocalDeviceImpl: Nobody waiting for the event\n"); } switch (opcodeExpected) { @@ -752,8 +730,7 @@ LocalDeviceImpl::CommandStatus(struct hci_ev_cmd_status* event, { reply.what = BT_MSG_INQUIRY_STARTED; - Output::Instance()->Postf(BLACKBOARD_KIT, - "Inquiry status %x\n", event->status); + TRACE_BT("LocalDeviceImpl: Inquiry status %x\n", event->status); reply.AddInt8("status", event->status); status = request->SendReply(&reply); @@ -771,8 +748,7 @@ LocalDeviceImpl::CommandStatus(struct hci_ev_cmd_status* event, if (event->status == BT_OK) { ClearWantedEvent(request, HCI_EVENT_CMD_STATUS, opcodeExpected); } else { - Output::Instance()->Postf(BLACKBOARD_KIT, - "Command Status for remote friendly name %x\n", + TRACE_BT("LocalDeviceImpl: Command Status for remote friendly name %x\n", event->status); reply.AddInt8("status", event->status); @@ -800,8 +776,7 @@ LocalDeviceImpl::CommandStatus(struct hci_ev_cmd_status* event, break;*/ default: - Output::Instance()->Post("Command Status not handled\n", - BLACKBOARD_KIT); + TRACE_BT("LocalDeviceImpl: Command Status not handled\n"); break; } @@ -821,16 +796,16 @@ LocalDeviceImpl::InquiryResult(uint8* numberOfResponses, BMessage* request) reply.AddInt8("count", *numberOfResponses); - Output::Instance()->Postf(BLACKBOARD_LD(GetID()), "%s #responses=%d\n", + TRACE_BT("LocalDeviceImpl: %s #responses=%d\n", __FUNCTION__, *numberOfResponses); struct inquiry_info* info = JumpEventHeader (numberOfResponses); while (responses > 0) { - Output::Instance()->Postf(BLACKBOARD_LD(GetID()), - "page_rep=%d scan_period=%d, scan=%d clock=%d\n", info->pscan_rep_mode, - info->pscan_period_mode, info->pscan_mode, info->clock_offset); + TRACE_BT("LocalDeviceImpl: page_rep=%d scan_period=%d, scan=%d clock=%d\n", + info->pscan_rep_mode, info->pscan_period_mode, info->pscan_mode, + info->clock_offset); responses--; info++; } @@ -871,17 +846,15 @@ LocalDeviceImpl::RemoteNameRequestComplete( reply.AddInt8("status", remotename->status); - Output::Instance()->Postf(BLACKBOARD_LD(GetID()), - "%s for %s with status %s\n", + TRACE_BT("LocalDeviceImpl: %s for %s with status %s\n", BluetoothEvent(HCI_EVENT_REMOTE_NAME_REQUEST_COMPLETE), bdaddrUtils::ToString(remotename->bdaddr).String(), BluetoothError(remotename->status)); - printf("%s: Sending reply...\n", __func__); status_t status = request->SendReply(&reply); if (status < B_OK) - printf("%s: Error sending reply!\n", __func__); - // debug reply.PrintToStream(); + printf("%s: Error sending reply to BMessage request: %s!\n", + __func__, strerror(status)); // This request is not gonna be used anymore ClearWantedEvent(request); @@ -895,8 +868,7 @@ LocalDeviceImpl::ConnectionRequest(struct hci_ev_conn_request* event, size_t size; void* command; - Output::Instance()->Postf(BLACKBOARD_LD(GetID()), - "Connection Incoming type %x from %s...\n", + TRACE_BT("LocalDeviceImpl: Connection Incoming type %x from %s...\n", event->link_type, bdaddrUtils::ToString(event->bdaddr).String()); // TODO: add a possible request in the queue @@ -925,12 +897,10 @@ LocalDeviceImpl::ConnectionRequest(struct hci_ev_conn_request* event, AddWantedEvent(newrequest); if ((fHCIDelegate)->IssueCommand(command, size) == B_ERROR) { - Output::Instance()->Postf(BLACKBOARD_LD(GetID()), - "Command issued error for Accepting connection\n"); + TRACE_BT("LocalDeviceImpl: Command issued error for Accepting connection\n"); // remove the request? } else { - Output::Instance()->Postf(BLACKBOARD_LD(GetID()), - "Command issued for Accepting connection\n"); + TRACE_BT("LocalDeviceImpl: Command issued for Accepting connection\n"); } } } @@ -949,14 +919,12 @@ LocalDeviceImpl::ConnectionComplete(struct hci_ev_conn_complete* event, new RemoteDevice(event->bdaddr, cod)); iConnection->Show(); - Output::Instance()->Postf(BLACKBOARD_LD(GetID()), - "%s: Address %s handle=%#x type=%d encrypt=%d\n", __FUNCTION__, + TRACE_BT("LocalDeviceImpl: %s: Address %s handle=%#x type=%d encrypt=%d\n", __FUNCTION__, bdaddrUtils::ToString(event->bdaddr).String(), event->handle, event->link_type, event->encrypt_mode); } else { - Output::Instance()->Postf(BLACKBOARD_LD(GetID()), - "%s: failed with error %s\n", __FUNCTION__, + TRACE_BT("LocalDeviceImpl: %s: failed with error %s\n", __FUNCTION__, BluetoothError(event->status)); } @@ -985,8 +953,7 @@ void LocalDeviceImpl::DisconnectionComplete( struct hci_ev_disconnection_complete_reply* event, BMessage* request) { - Output::Instance()->Postf(BLACKBOARD_LD(GetID()), - "%s: Handle=%#x, reason=%s status=%x\n", __FUNCTION__, event->handle, + TRACE_BT("LocalDeviceImpl: %s: Handle=%#x, reason=%s status=%x\n", __FUNCTION__, event->handle, BluetoothError(event->reason), event->status); if (request != NULL) { @@ -1016,8 +983,7 @@ LocalDeviceImpl::PinCodeRequest(struct hci_ev_pin_code_req* event, void LocalDeviceImpl::RoleChange(hci_ev_role_change* event, BMessage* request) { - Output::Instance()->Postf(BLACKBOARD_LD(GetID()), - "%s: Address %s role=%d status=%d\n", __FUNCTION__, + TRACE_BT("LocalDeviceImpl: %s: Address %s role=%d status=%d\n", __FUNCTION__, bdaddrUtils::ToString(event->bdaddr).String(), event->role, event->status); } @@ -1026,8 +992,7 @@ void LocalDeviceImpl::PageScanRepetitionModeChange( struct hci_ev_page_scan_rep_mode_change* event, BMessage* request) { - Output::Instance()->Postf(BLACKBOARD_LD(GetID()), - "%s: Address %s type=%d\n", __FUNCTION__, + TRACE_BT("LocalDeviceImpl: %s: Address %s type=%d\n", __FUNCTION__, bdaddrUtils::ToString(event->bdaddr).String(), event->page_scan_rep_mode); } @@ -1036,8 +1001,7 @@ void LocalDeviceImpl::LinkKeyNotify(hci_ev_link_key_notify* event, BMessage* request) { - Output::Instance()->Postf(BLACKBOARD_LD(GetID()), - "%s: Address %s, key=%s, type=%d\n", __FUNCTION__, + TRACE_BT("LocalDeviceImpl: %s: Address %s, key=%s, type=%d\n", __FUNCTION__, bdaddrUtils::ToString(event->bdaddr).String(), LinkKeyUtils::ToString(event->link_key).String(), event->key_type); } @@ -1047,8 +1011,7 @@ void LocalDeviceImpl::LinkKeyRequested(struct hci_ev_link_key_req* keyRequested, BMessage* request) { - Output::Instance()->Postf(BLACKBOARD_LD(GetID()), - "%s: Address %s\n", __FUNCTION__, + TRACE_BT("LocalDeviceImpl: %s: Address %s\n", __FUNCTION__, bdaddrUtils::ToString(keyRequested->bdaddr).String()); // TODO: @@ -1065,11 +1028,9 @@ LocalDeviceImpl::LinkKeyRequested(struct hci_ev_link_key_req* keyRequested, if ((fHCIDelegate)->IssueCommand(linkKeyNegativeReply.Data(), linkKeyNegativeReply.Size()) == B_ERROR) { - Output::Instance()->Postf(BLACKBOARD_LD(GetID()), - "Command issued error for reply %s\n", __FUNCTION__); + TRACE_BT("LocalDeviceImpl: Command issued error for reply %s\n", __FUNCTION__); } else { - Output::Instance()->Postf(BLACKBOARD_LD(GetID()), - "Command issued in reply of %s\n", __FUNCTION__); + TRACE_BT("LocalDeviceImpl: Command issued in reply of %s\n", __FUNCTION__); } if (request != NULL) @@ -1081,7 +1042,7 @@ LocalDeviceImpl::LinkKeyRequested(struct hci_ev_link_key_req* keyRequested, void LocalDeviceImpl::ReturnLinkKeys(struct hci_ev_return_link_keys* returnedKeys) { - Output::Instance()->Postf(BLACKBOARD_LD(GetID()), "%s: #keys=%d %s\n", + TRACE_BT("LocalDeviceImpl: %s: #keys=%d\n", __FUNCTION__, returnedKeys->num_keys); uint8 numKeys = returnedKeys->num_keys; @@ -1090,7 +1051,7 @@ LocalDeviceImpl::ReturnLinkKeys(struct hci_ev_return_link_keys* returnedKeys) while (numKeys > 0) { - Output::Instance()->Postf(BLACKBOARD_LD(GetID()), "Address=%s key=%s\n", + TRACE_BT("LocalDeviceImpl: Address=%s key=%s\n", bdaddrUtils::ToString(linkKeys->bdaddr).String(), LinkKeyUtils::ToString(linkKeys->link_key).String()); @@ -1103,8 +1064,7 @@ void LocalDeviceImpl::MaxSlotChange(struct hci_ev_max_slot_change* event, BMessage* request) { - Output::Instance()->Postf(BLACKBOARD_LD(GetID()), - "%s: Handle=%#x, max slots=%d\n", __FUNCTION__, + TRACE_BT("LocalDeviceImpl: %s: Handle=%#x, max slots=%d\n", __FUNCTION__, event->handle, event->lmp_max_slots); } @@ -1112,24 +1072,21 @@ LocalDeviceImpl::MaxSlotChange(struct hci_ev_max_slot_change* event, void LocalDeviceImpl::HardwareError(struct hci_ev_hardware_error* event) { - Output::Instance()->Postf(BLACKBOARD_LD(GetID()), - "%s: hardware code=%#x\n", __FUNCTION__, event->hardware_code); + TRACE_BT("LocalDeviceImpl: %s: hardware code=%#x\n", __FUNCTION__, event->hardware_code); } void LocalDeviceImpl::NumberOfCompletedPackets(struct hci_ev_num_comp_pkts* event) { - Output::Instance()->Postf(BLACKBOARD_LD(GetID()), - "%s: #Handles=%d\n", __FUNCTION__, event->num_hndl); + TRACE_BT("LocalDeviceImpl: %s: #Handles=%d\n", __FUNCTION__, event->num_hndl); struct handle_and_number* numberPackets = JumpEventHeader(event); for (uint8 i = 0; i < event->num_hndl; i++) { - Output::Instance()->Postf(BLACKBOARD_LD(GetID()), - "%s: Handle=%d #packets=%d\n", __FUNCTION__, numberPackets->handle, + TRACE_BT("LocalDeviceImpl: %s: Handle=%d #packets=%d\n", __FUNCTION__, numberPackets->handle, numberPackets->num_completed); numberPackets++; @@ -1160,16 +1117,14 @@ LocalDeviceImpl::ProcessSimpleRequest(BMessage* request) // TODO: // Reply the request with error! // Remove the just added request - (Output::Instance()->Post("## ERROR Command issue, REMOVING!\n", - BLACKBOARD_KIT)); + TRACE_BT("LocalDeviceImpl: ## ERROR Command issue, REMOVING!\n"); ClearWantedEvent(request); } else { return B_OK; } } else { - (Output::Instance()->Post("No command specified for simple request\n", - BLACKBOARD_KIT)); + TRACE_BT("LocalDeviceImpl: No command specified for simple request\n"); } return B_ERROR; diff --git a/src/servers/bluetooth/Output.cpp b/src/servers/bluetooth/Output.cpp deleted file mode 100644 index e1f99548af..0000000000 --- a/src/servers/bluetooth/Output.cpp +++ /dev/null @@ -1,187 +0,0 @@ -/* - * Copyright 2011 Hamish Morrison, hamish@lavabit.com - * Copyright 2010 Oliver Ruiz Dorantes, oliver.ruiz.dorantes_at_gmail.com - * Copyright 2010 Dan-Matei Epure, mateiepure@gmail.com - * Copyright BeNet Team (Original Project) - * All rights reserved. Distributed under the terms of the MIT License. - */ -#ifndef _Output_h -#include "Output.h" -#endif - -#include -#include - -#include - -/* -#ifndef _Preferences_h -#include "Preferences.h" -#endif -*/ - - -OutputView::OutputView(const char* name) - : - BGroupView(name, B_VERTICAL, B_WILL_DRAW) -{ - rgb_color textColor = {255, 255, 255}; - fTextView = new BTextView("Output", NULL, &textColor, B_WILL_DRAW); - fTextView->SetViewColor(0, 0, 100); - fTextView->MakeEditable(false); - BScrollView* scrollView = new BScrollView("ScrollView", fTextView, - 0, false, true); - - BLayoutBuilder::Group<>(this).Add(scrollView); -} - - -// Singleton implementation -Output* Output::sInstance = 0; - - -Output::Output() - : - BWindow(BRect(200, 200, 800, 800), "Output", - B_TITLED_WINDOW, B_NOT_ZOOMABLE) -{ - fOutputViewsList = new BList(); - - fReset = new BButton("reset all", "Clear", - new BMessage(kMsgOutputReset), B_WILL_DRAW); - fResetAll = new BButton("reset", "Clear all", - new BMessage(kMsgOutputResetAll), B_WILL_DRAW); - - fTabView = new BTabView("tab_view", B_WIDTH_FROM_LABEL, - B_FULL_UPDATE_ON_RESIZE | B_WILL_DRAW | B_NAVIGABLE_JUMP); - - fTabView->AddTab(fAll = new OutputView("All")); - - BLayoutBuilder::Group<>(this, B_VERTICAL, 5) - .Add(fTabView) - .AddGroup(B_HORIZONTAL, 0) - .Add(fReset) - .AddGlue() - .Add(fResetAll) - .End() - .SetInsets(5, 5, 5, 5); - - /* - MoveTo( Preferences::Instance()->OutputX(), - Preferences::Instance()->OutputY()); - */ -} - - -void -Output::AddTab(const char* text, uint32 index) -{ - OutputView* customOutput; - - Lock(); - fTabView->AddTab(customOutput = new OutputView(text)); - fTabView->Invalidate(); - Unlock(); - - fOutputViewsList->AddItem(customOutput, index); -} - - -Output::~Output() -{ -/* BWindow::~BWindow();*/ - delete fOutputViewsList; -} - - -Output* -Output::Instance() -{ - if (!sInstance) - sInstance = new Output; - return sInstance; -} - - -bool -Output::QuitRequested() -{ - Hide(); - return false; -} - - -OutputView* -Output::_OutputViewForTab(int32 index) -{ - return (OutputView*)fTabView->TabAt(index)->View(); -} - - -void -Output::MessageReceived(BMessage* msg) -{ - switch(msg->what) { - case kMsgOutputReset: - _OutputViewForTab(fTabView->Selection())->Clear(); - break; - case kMsgOutputResetAll: - for (int32 index = 0; index < fTabView->CountTabs(); ++index) - _OutputViewForTab(index)->Clear(); - break; - default: - BWindow::MessageReceived(msg); - break; - } -} - - -void -Output::FrameMoved(BPoint point) -{ -/* Preferences::Instance()->OutputX(point.x); - Preferences::Instance()->OutputY(point.y); -*/ -} - - -int -Output::Postf(uint32 index, const char* format, ...) -{ - char string[200]; - va_list arg; - int done; - - va_start (arg, format); - done = vsnprintf(string, 200, format, arg); - va_end (arg); - - Post(string, index); - - return done; -} - - -void -Output::Post(const char* text, uint32 index) -{ - Lock(); - OutputView* view = (OutputView*)fOutputViewsList->ItemAt(index); - - if (view != NULL) - _Add(text, view); - else - // Note that the view should be added before this! - // Dropping twice to the main - _Add(text, fAll); - - Unlock(); -} - - -void -Output::_Add(const char* text, OutputView* view) -{ - view->Add(text); - fAll->Add(text); -} diff --git a/src/servers/bluetooth/Output.h b/src/servers/bluetooth/Output.h deleted file mode 100644 index 8b8fb957a3..0000000000 --- a/src/servers/bluetooth/Output.h +++ /dev/null @@ -1,73 +0,0 @@ -/* - * Copyright 2011 Hamish Morrison, hamish@lavabit.com - * Copyright 2010 Oliver Ruiz Dorantes - * Copyright 2010 Dan-Matei Epure, mateiepure@gmail.com - * Copyright BeNet Team (Original Project) - * All rights reserved. Distributed under the terms of the MIT License. - */ -#ifndef _Output_h -#define _Output_h - -#include -#include -#include -#include -#include -#include - -const uint32 kMsgOutputReset = 'outr'; -const uint32 kMsgOutputResetAll = 'opra'; - - -class OutputView : public BGroupView -{ -public: - OutputView(const char* name); - - void Add(const char* text) {fTextView->Insert(text);} - void Clear() {fTextView->Delete(0, fTextView->TextLength());} - -private: - BTextView* fTextView; -}; - - -class Output : public BWindow -{ -public: - static Output* Instance(); - - ~Output(); - - virtual bool QuitRequested(); - virtual void MessageReceived(BMessage* msg); - virtual void FrameMoved(BPoint point); - - void AddTab(const char* text, uint32 index); - - void Post(const char* text, uint32 index); - int Postf(uint32 index, const char* format, ...); - -private: - // functions - Output(); - void _Add(const char* text, OutputView* view); - OutputView* _OutputViewForTab(int32 index); - -private: - // data - static Output* sInstance; - BTab* fAllTab; - - OutputView* fAll; - - BButton* fReset; - BButton* fResetAll; - - BTabView* fTabView; - - BList* fOutputViewsList; -}; - - -#endif // _Output_h