1014ff001SIngo Weinhold// SMInvoker.cpp
2014ff001SIngo Weinhold
3014ff001SIngo Weinhold#include "SMInvoker.h"
4014ff001SIngo Weinhold#include "SMMessages.h"
5014ff001SIngo Weinhold
6014ff001SIngo Weinhold// SMInvoker
7014ff001SIngo Weinhold
8014ff001SIngo Weinhold// constructor
9014ff001SIngo WeinholdSMInvoker::SMInvoker()
10014ff001SIngo Weinhold		 : fReplyMessage(NULL)
11014ff001SIngo Weinhold{
12014ff001SIngo Weinhold}
13014ff001SIngo Weinhold
14014ff001SIngo Weinhold// destructor
15014ff001SIngo WeinholdSMInvoker::~SMInvoker()
16014ff001SIngo Weinhold{
17014ff001SIngo Weinhold	delete fReplyMessage;
18014ff001SIngo Weinhold}
19014ff001SIngo Weinhold
20014ff001SIngo Weinhold// ReplySuccess
21014ff001SIngo Weinholdbool
22014ff001SIngo WeinholdSMInvoker::ReplySuccess()
23014ff001SIngo Weinhold{
24014ff001SIngo Weinhold	return (fReplyMessage && fReplyMessage->what == MSG_REPLY);
25014ff001SIngo Weinhold}
26014ff001SIngo Weinhold
27014ff001SIngo Weinhold// DirectReply
28014ff001SIngo Weinholdbool
29014ff001SIngo WeinholdSMInvoker::DirectReply()
30014ff001SIngo Weinhold{
31014ff001SIngo Weinhold	return fReplyMessage;
32014ff001SIngo Weinhold}
33014ff001SIngo Weinhold
34014ff001SIngo Weinhold
35014ff001SIngo Weinhold// SMInvoker1
36014ff001SIngo Weinhold
37014ff001SIngo Weinhold// constructor
38014ff001SIngo WeinholdSMInvoker1::SMInvoker1(bool useReplyTo)
39014ff001SIngo Weinhold		  : SMInvoker(),
40014ff001SIngo Weinhold			fUseReplyTo(useReplyTo)
41014ff001SIngo Weinhold{
42014ff001SIngo Weinhold}
43014ff001SIngo Weinhold
44014ff001SIngo Weinhold// Invoke
45014ff001SIngo Weinholdstatus_t
46014ff001SIngo WeinholdSMInvoker1::Invoke(BMessenger &target, BHandler *replyHandler,
47014ff001SIngo Weinhold				   BMessenger &replyMessenger)
48014ff001SIngo Weinhold{
49014ff001SIngo Weinhold	BHandler *replyTo = (fUseReplyTo ? replyHandler : NULL);
50014ff001SIngo Weinhold	status_t result = target.SendMessage(MSG_TEST, replyTo);
51014ff001SIngo Weinhold	return result;
52014ff001SIngo Weinhold}
53014ff001SIngo Weinhold
54014ff001SIngo Weinhold
55014ff001SIngo Weinhold// SMInvoker2
56014ff001SIngo Weinhold
57014ff001SIngo Weinhold// constructor
58014ff001SIngo WeinholdSMInvoker2::SMInvoker2(bool useMessage, bool useReplyTo, bigtime_t timeout)
59014ff001SIngo Weinhold		  : SMInvoker(),
60014ff001SIngo Weinhold			fUseMessage(useMessage),
61014ff001SIngo Weinhold			fUseReplyTo(useReplyTo),
62014ff001SIngo Weinhold			fTimeout(timeout)
63014ff001SIngo Weinhold{
64014ff001SIngo Weinhold}
65014ff001SIngo Weinhold
66014ff001SIngo Weinhold// Invoke
67014ff001SIngo Weinholdstatus_t
68014ff001SIngo WeinholdSMInvoker2::Invoke(BMessenger &target, BHandler *replyHandler,
69014ff001SIngo Weinhold				   BMessenger &replyMessenger)
70014ff001SIngo Weinhold{
71014ff001SIngo Weinhold	BHandler *replyTo = (fUseReplyTo ? replyHandler : NULL);
72014ff001SIngo Weinhold	BMessage _message(MSG_TEST);
73014ff001SIngo Weinhold	BMessage *message = (fUseMessage ? &_message : NULL);
74014ff001SIngo Weinhold	status_t result = target.SendMessage(message, replyTo, fTimeout);
75014ff001SIngo Weinhold	return result;
76014ff001SIngo Weinhold}
77014ff001SIngo Weinhold
78014ff001SIngo Weinhold
79014ff001SIngo Weinhold// SMInvoker3
80014ff001SIngo Weinhold
81014ff001SIngo Weinhold// constructor
82014ff001SIngo WeinholdSMInvoker3::SMInvoker3(bool useMessage, bool useReplyTo, bigtime_t timeout)
83014ff001SIngo Weinhold		  : SMInvoker(),
84014ff001SIngo Weinhold			fUseMessage(useMessage),
85014ff001SIngo Weinhold			fUseReplyTo(useReplyTo),
86014ff001SIngo Weinhold			fTimeout(timeout)
87014ff001SIngo Weinhold{
88014ff001SIngo Weinhold}
89014ff001SIngo Weinhold
90014ff001SIngo Weinhold// Invoke
91014ff001SIngo Weinholdstatus_t
92014ff001SIngo WeinholdSMInvoker3::Invoke(BMessenger &target, BHandler *replyHandler,
93014ff001SIngo Weinhold				   BMessenger &replyMessenger)
94014ff001SIngo Weinhold{
95014ff001SIngo Weinhold	BMessenger badMessenger;
96014ff001SIngo Weinhold	BMessenger &replyTo = (fUseReplyTo ? replyMessenger : badMessenger);
97014ff001SIngo Weinhold	BMessage _message(MSG_TEST);
98014ff001SIngo Weinhold	BMessage *message = (fUseMessage ? &_message : NULL);
99014ff001SIngo Weinhold	status_t result = target.SendMessage(message, replyTo, fTimeout);
100014ff001SIngo Weinhold	return result;
101014ff001SIngo Weinhold}
102014ff001SIngo Weinhold
103014ff001SIngo Weinhold
104014ff001SIngo Weinhold// SMInvoker4
105014ff001SIngo Weinhold
106014ff001SIngo Weinhold// constructor
107014ff001SIngo WeinholdSMInvoker4::SMInvoker4(bool useReply)
108014ff001SIngo Weinhold		  : SMInvoker(),
109014ff001SIngo Weinhold			fUseReply(useReply)
110014ff001SIngo Weinhold{
111014ff001SIngo Weinhold}
112014ff001SIngo Weinhold
113014ff001SIngo Weinhold// Invoke
114014ff001SIngo Weinholdstatus_t
115014ff001SIngo WeinholdSMInvoker4::Invoke(BMessenger &target, BHandler *replyHandler,
116014ff001SIngo Weinhold				   BMessenger &replyMessenger)
117014ff001SIngo Weinhold{
118014ff001SIngo Weinhold	if (fUseReply)
1199aec6561SOliver Tappe		fReplyMessage = new BMessage(uint32(0));
120014ff001SIngo Weinhold	status_t result = target.SendMessage(MSG_TEST, fReplyMessage);
121014ff001SIngo Weinhold	return result;
122014ff001SIngo Weinhold}
123014ff001SIngo Weinhold
124037c2e46SIngo Weinhold
125037c2e46SIngo Weinhold// SMInvoker5
126037c2e46SIngo Weinhold
127037c2e46SIngo Weinhold// constructor
128037c2e46SIngo WeinholdSMInvoker5::SMInvoker5(bool useMessage, bool useReply,
129037c2e46SIngo Weinhold					   bigtime_t deliveryTimeout, bigtime_t replyTimeout)
130037c2e46SIngo Weinhold		  : SMInvoker(),
131037c2e46SIngo Weinhold			fUseMessage(useMessage),
132037c2e46SIngo Weinhold			fUseReply(useReply),
133037c2e46SIngo Weinhold			fDeliveryTimeout(deliveryTimeout),
134037c2e46SIngo Weinhold			fReplyTimeout(replyTimeout)
135037c2e46SIngo Weinhold{
136037c2e46SIngo Weinhold}
137037c2e46SIngo Weinhold
138037c2e46SIngo Weinhold// Invoke
139037c2e46SIngo Weinholdstatus_t
140037c2e46SIngo WeinholdSMInvoker5::Invoke(BMessenger &target, BHandler *replyHandler,
141037c2e46SIngo Weinhold				   BMessenger &replyMessenger)
142037c2e46SIngo Weinhold{
143037c2e46SIngo Weinhold	if (fUseReply)
1449aec6561SOliver Tappe		fReplyMessage = new BMessage(uint32(0));
145037c2e46SIngo Weinhold	BMessage _message(MSG_TEST);
146037c2e46SIngo Weinhold	BMessage *message = (fUseMessage ? &_message : NULL);
147037c2e46SIngo Weinhold	status_t result = target.SendMessage(message, fReplyMessage,
148037c2e46SIngo Weinhold										 fDeliveryTimeout, fReplyTimeout);
149037c2e46SIngo Weinhold	return result;
150037c2e46SIngo Weinhold}
151037c2e46SIngo Weinhold
152be2939caSTyler Dauwalder
153