BPicture: Fix archive constructor.
[haiku.git] / src / kits / app / Invoker.cpp
blob087bb917b0ffe68ac969710a93c45bcf80a86fb1
1 /*
2 * Copyright 2001-2005, Haiku.
3 * Distributed under the terms of the MIT License.
5 * Authors:
6 * Marc Flerackers (mflerackers@androme.be)
7 */
10 #include <Invoker.h>
13 BInvoker::BInvoker(BMessage* message, BMessenger messenger)
15 fMessage(message),
16 fMessenger(messenger),
17 fReplyTo(NULL),
18 fTimeout(B_INFINITE_TIMEOUT),
19 fNotifyKind(0)
24 BInvoker::BInvoker(BMessage* message, const BHandler* handler,
25 const BLooper* looper)
27 fMessage(message),
28 fMessenger(BMessenger(handler, looper)),
29 fReplyTo(NULL),
30 fTimeout(B_INFINITE_TIMEOUT),
31 fNotifyKind(0)
36 BInvoker::BInvoker()
38 fMessage(NULL),
39 fReplyTo(NULL),
40 fTimeout(B_INFINITE_TIMEOUT),
41 fNotifyKind(0)
46 BInvoker::~BInvoker()
48 delete fMessage;
52 status_t
53 BInvoker::SetMessage(BMessage* message)
55 if (fMessage == message)
56 return B_OK;
58 delete fMessage;
59 fMessage = message;
61 return B_OK;
65 BMessage*
66 BInvoker::Message() const
68 return fMessage;
72 uint32
73 BInvoker::Command() const
75 if (fMessage)
76 return fMessage->what;
78 return 0;
82 status_t
83 BInvoker::SetTarget(BMessenger messenger)
85 fMessenger = messenger;
86 return B_OK;
90 status_t
91 BInvoker::SetTarget(const BHandler* handler, const BLooper* looper)
93 fMessenger = BMessenger(handler, looper);
94 return B_OK;
98 bool
99 BInvoker::IsTargetLocal() const
101 return fMessenger.IsTargetLocal();
105 BHandler*
106 BInvoker::Target(BLooper** _looper) const
108 return fMessenger.Target(_looper);
112 BMessenger
113 BInvoker::Messenger() const
115 return fMessenger;
119 status_t
120 BInvoker::SetHandlerForReply(BHandler* replyHandler)
122 fReplyTo = replyHandler;
123 return B_OK;
127 BHandler*
128 BInvoker::HandlerForReply() const
130 return fReplyTo;
134 status_t
135 BInvoker::Invoke(BMessage* message)
137 if (!message)
138 message = Message();
140 if (!message)
141 return B_BAD_VALUE;
143 return fMessenger.SendMessage(message, fReplyTo, fTimeout);
147 status_t
148 BInvoker::InvokeNotify(BMessage* message, uint32 kind)
150 if (fNotifyKind != 0)
151 return B_WOULD_BLOCK;
153 BeginInvokeNotify(kind);
154 status_t err = Invoke(message);
155 EndInvokeNotify();
157 return err;
161 status_t
162 BInvoker::SetTimeout(bigtime_t timeout)
164 fTimeout = timeout;
165 return B_OK;
169 bigtime_t
170 BInvoker::Timeout() const
172 return fTimeout;
176 uint32
177 BInvoker::InvokeKind(bool* _notify)
179 if (_notify)
180 *_notify = fNotifyKind != 0;
182 if (fNotifyKind != 0)
183 return fNotifyKind;
185 return B_CONTROL_INVOKED;
189 void
190 BInvoker::BeginInvokeNotify(uint32 kind)
192 fNotifyKind = kind;
196 void
197 BInvoker::EndInvokeNotify()
199 fNotifyKind = 0;
203 void BInvoker::_ReservedInvoker1() {}
204 void BInvoker::_ReservedInvoker2() {}
205 void BInvoker::_ReservedInvoker3() {}
208 BInvoker::BInvoker(const BInvoker &)
213 BInvoker &
214 BInvoker::operator=(const BInvoker &)
216 return *this;