vfs: check userland buffers before reading them.
[haiku.git] / src / tests / kits / app / bmessenger / SMReplyTarget.cpp
blob79591c2066b104e203a475da59e256cb6152a4c5
1 // SMReplyTarget.cpp
3 #include <TestUtils.h>
4 #include <cppunit/TestAssert.h>
6 #include "SMReplyTarget.h"
7 #include "SMLooper.h"
9 // constructor
10 SMReplyTarget::SMReplyTarget(bool preferred)
11 : fHandler(NULL),
12 fLooper(NULL)
14 // create looper and handler
15 fLooper = new SMLooper;
16 fLooper->Run();
17 if (!preferred) {
18 fHandler = new SMHandler;
19 CHK(fLooper->Lock());
20 fLooper->AddHandler(fHandler);
21 fLooper->Unlock();
25 // destructor
26 SMReplyTarget::~SMReplyTarget()
28 if (fLooper) {
29 fLooper->Lock();
30 if (fHandler) {
31 fLooper->RemoveHandler(fHandler);
32 delete fHandler;
34 fLooper->Quit();
38 // Handler
39 BHandler *
40 SMReplyTarget::Handler()
42 return fHandler;
45 // Messenger
46 BMessenger
47 SMReplyTarget::Messenger()
49 return BMessenger(fHandler, fLooper);
52 // ReplySuccess
53 bool
54 SMReplyTarget::ReplySuccess()
56 return fLooper->ReplySuccess();