1 /* 2 * Copyright 2006, Haiku. 3 * Distributed under the terms of the MIT License. 4 * 5 * Authors: 6 * Ingo Weinhold <bonefish@cs.tu-berlin.de> 7 */ 8 9 #include "AbstractLOAdapter.h" 10 11 #include <Handler.h> 12 #include <Looper.h> 13 #include <Messenger.h> 14 15 // constructor 16 AbstractLOAdapter::AbstractLOAdapter(BHandler* handler) 17 : fHandler(handler), 18 fMessenger(NULL) 19 { 20 } 21 22 // constructor 23 AbstractLOAdapter::AbstractLOAdapter(const BMessenger& messenger) 24 : fHandler(NULL), 25 fMessenger(new BMessenger(messenger)) 26 { 27 } 28 29 // destructor 30 AbstractLOAdapter::~AbstractLOAdapter() 31 { 32 delete fMessenger; 33 } 34 35 // DeliverMessage 36 void 37 AbstractLOAdapter::DeliverMessage(BMessage* message) 38 { 39 if (fHandler) { 40 if (BLooper* looper = fHandler->Looper()) 41 looper->PostMessage(message, fHandler); 42 } else if (fMessenger) 43 fMessenger->SendMessage(message); 44 } 45 46 // DeliverMessage 47 void 48 AbstractLOAdapter::DeliverMessage(BMessage& message) 49 { 50 DeliverMessage(&message); 51 } 52 53 // DeliverMessage 54 void 55 AbstractLOAdapter::DeliverMessage(uint32 command) 56 { 57 BMessage message(command); 58 DeliverMessage(&message); 59 } 60 61