1 /* 2 * Copyright 2001-2005, Haiku. 3 * Distributed under the terms of the MIT License. 4 * 5 * Authors: 6 * Erik Jaesler (erik@cgsoftware.com) 7 */ 8 9 10 #include <MessageFilter.h> 11 12 13 BMessageFilter::BMessageFilter(uint32 inWhat, filter_hook func) 14 : 15 fFiltersAny(false), 16 fWhat(inWhat), 17 fDelivery(B_ANY_DELIVERY), 18 fSource(B_ANY_SOURCE), 19 fLooper(NULL), 20 fFilterFunction(func) 21 { 22 } 23 24 25 BMessageFilter::BMessageFilter(message_delivery delivery, 26 message_source source, filter_hook func) 27 : 28 fFiltersAny(true), 29 fWhat(0), 30 fDelivery(delivery), 31 fSource(source), 32 fLooper(NULL), 33 fFilterFunction(func) 34 { 35 } 36 37 38 BMessageFilter::BMessageFilter(message_delivery delivery, 39 message_source source, uint32 inWhat, filter_hook func) 40 : 41 fFiltersAny(false), 42 fWhat(inWhat), 43 fDelivery(delivery), 44 fSource(source), 45 fLooper(NULL), 46 fFilterFunction(func) 47 { 48 } 49 50 51 BMessageFilter::BMessageFilter(const BMessageFilter& filter) 52 { 53 *this = filter; 54 } 55 56 57 BMessageFilter::BMessageFilter(const BMessageFilter* filter) 58 { 59 *this = *filter; 60 } 61 62 63 BMessageFilter::~BMessageFilter() 64 { 65 } 66 67 68 BMessageFilter & 69 BMessageFilter::operator=(const BMessageFilter& from) 70 { 71 fFiltersAny = from.FiltersAnyCommand(); 72 fWhat = from.Command(); 73 fDelivery = from.MessageDelivery(); 74 fSource = from.MessageSource(); 75 fFilterFunction = from.FilterFunction(); 76 77 SetLooper(from.Looper()); 78 79 return *this; 80 } 81 82 83 filter_result 84 BMessageFilter::Filter(BMessage* message, BHandler** target) 85 { 86 return B_DISPATCH_MESSAGE; 87 } 88 89 90 message_delivery 91 BMessageFilter::MessageDelivery() const 92 { 93 return fDelivery; 94 } 95 96 97 message_source 98 BMessageFilter::MessageSource() const 99 { 100 return fSource; 101 } 102 103 104 uint32 105 BMessageFilter::Command() const 106 { 107 return fWhat; 108 } 109 110 111 bool 112 BMessageFilter::FiltersAnyCommand() const 113 { 114 return fFiltersAny; 115 } 116 117 118 BLooper * 119 BMessageFilter::Looper() const 120 { 121 return fLooper; 122 } 123 124 125 void BMessageFilter::_ReservedMessageFilter1() {} 126 void BMessageFilter::_ReservedMessageFilter2() {} 127 128 129 void 130 BMessageFilter::SetLooper(BLooper* owner) 131 { 132 fLooper = owner; 133 } 134 135 136 filter_hook 137 BMessageFilter::FilterFunction() const 138 { 139 return fFilterFunction; 140 } 141