Style fixes to BMessageRunner, no functional changes intended
This commit is contained in:
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2001-2010, Haiku, Inc.
|
* Copyright 2001-2010 Haiku, Inc. All rights reserved.
|
||||||
* Distributed under the terms of the MIT License.
|
* Distributed under the terms of the MIT License.
|
||||||
*/
|
*/
|
||||||
#ifndef _MESSAGE_RUNNER_H
|
#ifndef _MESSAGE_RUNNER_H
|
||||||
@@ -41,8 +41,7 @@ public:
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
BMessageRunner(const BMessageRunner &);
|
BMessageRunner(const BMessageRunner &);
|
||||||
BMessageRunner &operator=(
|
BMessageRunner& operator=(const BMessageRunner&);
|
||||||
const BMessageRunner &);
|
|
||||||
|
|
||||||
static int32 _RegisterRunner(BMessenger target,
|
static int32 _RegisterRunner(BMessenger target,
|
||||||
const BMessage* message, bigtime_t interval,
|
const BMessage* message, bigtime_t interval,
|
||||||
|
|||||||
+87
-225
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2001-2010, Haiku, Inc.
|
* Copyright 2001-2010 Haiku, Inc. All rights reserved.
|
||||||
* Distributed under the terms of the MIT License.
|
* Distributed under the terms of the MIT License.
|
||||||
*
|
*
|
||||||
* Authors:
|
* Authors:
|
||||||
@@ -19,25 +19,6 @@
|
|||||||
using namespace BPrivate;
|
using namespace BPrivate;
|
||||||
|
|
||||||
|
|
||||||
/*! \brief Creates and initializes a new BMessageRunner.
|
|
||||||
|
|
||||||
The target for replies to the delivered message(s) is \c be_app_messenger.
|
|
||||||
|
|
||||||
The success of the initialization can (and should) be asked for via
|
|
||||||
InitCheck(). This object will not take ownership of the \a message, you
|
|
||||||
may freely change or delete it after creation.
|
|
||||||
|
|
||||||
\note As soon as the last message has been sent, the message runner
|
|
||||||
becomes unusable. InitCheck() will still return \c B_OK, but
|
|
||||||
SetInterval(), SetCount() and GetInfo() will fail.
|
|
||||||
|
|
||||||
\param target Target of the message(s).
|
|
||||||
\param message The message to be sent to the target.
|
|
||||||
\param interval Period of time before the first message is sent and
|
|
||||||
between messages (if more than one shall be sent) in microseconds.
|
|
||||||
\param count Specifies how many times the message shall be sent.
|
|
||||||
A value less than \c 0 for an unlimited number of repetitions.
|
|
||||||
*/
|
|
||||||
BMessageRunner::BMessageRunner(BMessenger target, const BMessage* message,
|
BMessageRunner::BMessageRunner(BMessenger target, const BMessage* message,
|
||||||
bigtime_t interval, int32 count)
|
bigtime_t interval, int32 count)
|
||||||
:
|
:
|
||||||
@@ -47,25 +28,6 @@ BMessageRunner::BMessageRunner(BMessenger target, const BMessage* message,
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*! \brief Creates and initializes a new BMessageRunner.
|
|
||||||
|
|
||||||
The target for replies to the delivered message(s) is \c be_app_messenger.
|
|
||||||
|
|
||||||
The success of the initialization can (and should) be asked for via
|
|
||||||
InitCheck(). This object will not take ownership of the \a message, you
|
|
||||||
may freely change or delete it after creation.
|
|
||||||
|
|
||||||
\note As soon as the last message has been sent, the message runner
|
|
||||||
becomes unusable. InitCheck() will still return \c B_OK, but
|
|
||||||
SetInterval(), SetCount() and GetInfo() will fail.
|
|
||||||
|
|
||||||
\param target Target of the message(s).
|
|
||||||
\param message The message to be sent to the target.
|
|
||||||
\param interval Period of time before the first message is sent and
|
|
||||||
between messages (if more than one shall be sent) in microseconds.
|
|
||||||
\param count Specifies how many times the message shall be sent.
|
|
||||||
A value less than \c 0 for an unlimited number of repetitions.
|
|
||||||
*/
|
|
||||||
BMessageRunner::BMessageRunner(BMessenger target, const BMessage& message,
|
BMessageRunner::BMessageRunner(BMessenger target, const BMessage& message,
|
||||||
bigtime_t interval, int32 count)
|
bigtime_t interval, int32 count)
|
||||||
:
|
:
|
||||||
@@ -75,27 +37,6 @@ BMessageRunner::BMessageRunner(BMessenger target, const BMessage& message,
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*! \brief Creates and initializes a new BMessageRunner.
|
|
||||||
|
|
||||||
This constructor version additionally allows to specify the target for
|
|
||||||
replies to the delivered message(s).
|
|
||||||
|
|
||||||
The success of the initialization can (and should) be asked for via
|
|
||||||
InitCheck(). This object will not take ownership of the \a message, you
|
|
||||||
may freely change or delete it after creation.
|
|
||||||
|
|
||||||
\note As soon as the last message has been sent, the message runner
|
|
||||||
becomes unusable. InitCheck() will still return \c B_OK, but
|
|
||||||
SetInterval(), SetCount() and GetInfo() will fail.
|
|
||||||
|
|
||||||
\param target Target of the message(s).
|
|
||||||
\param message The message to be sent to the target.
|
|
||||||
\param interval Period of time before the first message is sent and
|
|
||||||
between messages (if more than one shall be sent) in microseconds.
|
|
||||||
\param count Specifies how many times the message shall be sent.
|
|
||||||
A value less than \c 0 for an unlimited number of repetitions.
|
|
||||||
\param replyTo Target replies to the delivered message(s) shall be sent to.
|
|
||||||
*/
|
|
||||||
BMessageRunner::BMessageRunner(BMessenger target, const BMessage* message,
|
BMessageRunner::BMessageRunner(BMessenger target, const BMessage* message,
|
||||||
bigtime_t interval, int32 count, BMessenger replyTo)
|
bigtime_t interval, int32 count, BMessenger replyTo)
|
||||||
:
|
:
|
||||||
@@ -105,27 +46,6 @@ BMessageRunner::BMessageRunner(BMessenger target, const BMessage* message,
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*! \brief Creates and initializes a new BMessageRunner.
|
|
||||||
|
|
||||||
This constructor version additionally allows to specify the target for
|
|
||||||
replies to the delivered message(s).
|
|
||||||
|
|
||||||
The success of the initialization can (and should) be asked for via
|
|
||||||
InitCheck(). This object will not take ownership of the \a message, you
|
|
||||||
may freely change or delete it after creation.
|
|
||||||
|
|
||||||
\note As soon as the last message has been sent, the message runner
|
|
||||||
becomes unusable. InitCheck() will still return \c B_OK, but
|
|
||||||
SetInterval(), SetCount() and GetInfo() will fail.
|
|
||||||
|
|
||||||
\param target Target of the message(s).
|
|
||||||
\param message The message to be sent to the target.
|
|
||||||
\param interval Period of time before the first message is sent and
|
|
||||||
between messages (if more than one shall be sent) in microseconds.
|
|
||||||
\param count Specifies how many times the message shall be sent.
|
|
||||||
A value less than \c 0 for an unlimited number of repetitions.
|
|
||||||
\param replyTo Target replies to the delivered message(s) shall be sent to.
|
|
||||||
*/
|
|
||||||
BMessageRunner::BMessageRunner(BMessenger target, const BMessage& message,
|
BMessageRunner::BMessageRunner(BMessenger target, const BMessage& message,
|
||||||
bigtime_t interval, int32 count, BMessenger replyTo)
|
bigtime_t interval, int32 count, BMessenger replyTo)
|
||||||
:
|
:
|
||||||
@@ -135,8 +55,6 @@ BMessageRunner::BMessageRunner(BMessenger target, const BMessage& message,
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*! \brief Frees all resources associated with the object.
|
|
||||||
*/
|
|
||||||
BMessageRunner::~BMessageRunner()
|
BMessageRunner::~BMessageRunner()
|
||||||
{
|
{
|
||||||
if (fToken < B_OK)
|
if (fToken < B_OK)
|
||||||
@@ -144,26 +62,17 @@ BMessageRunner::~BMessageRunner()
|
|||||||
|
|
||||||
// compose the request message
|
// compose the request message
|
||||||
BMessage request(B_REG_UNREGISTER_MESSAGE_RUNNER);
|
BMessage request(B_REG_UNREGISTER_MESSAGE_RUNNER);
|
||||||
status_t error = request.AddInt32("token", fToken);
|
status_t result = request.AddInt32("token", fToken);
|
||||||
|
|
||||||
// send the request
|
// send the request
|
||||||
BMessage reply;
|
BMessage reply;
|
||||||
if (error == B_OK)
|
if (result == B_OK)
|
||||||
error = BRoster::Private().SendTo(&request, &reply, false);
|
result = BRoster::Private().SendTo(&request, &reply, false);
|
||||||
|
|
||||||
// ignore the reply, we can't do anything anyway
|
// ignore the reply, we can't do anything anyway
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*! \brief Returns the status of the initialization.
|
|
||||||
|
|
||||||
\note As soon as the last message has been sent, the message runner
|
|
||||||
becomes unusable. InitCheck() will still return \c B_OK, but
|
|
||||||
SetInterval(), SetCount() and GetInfo() will fail.
|
|
||||||
|
|
||||||
\return \c B_OK, if the object is properly initialized, an error code
|
|
||||||
otherwise.
|
|
||||||
*/
|
|
||||||
status_t
|
status_t
|
||||||
BMessageRunner::InitCheck() const
|
BMessageRunner::InitCheck() const
|
||||||
{
|
{
|
||||||
@@ -171,14 +80,6 @@ BMessageRunner::InitCheck() const
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*! \brief Sets the interval of time between messages.
|
|
||||||
\param interval The new interval in microseconds.
|
|
||||||
\return
|
|
||||||
- \c B_OK: Everything went fine.
|
|
||||||
- \c B_NO_INIT: The message runner is not properly initialized.
|
|
||||||
- \c B_BAD_VALUE: \a interval is \c 0 or negative, or the message runner
|
|
||||||
has already sent all messages to be sent and has become unusable.
|
|
||||||
*/
|
|
||||||
status_t
|
status_t
|
||||||
BMessageRunner::SetInterval(bigtime_t interval)
|
BMessageRunner::SetInterval(bigtime_t interval)
|
||||||
{
|
{
|
||||||
@@ -186,15 +87,6 @@ BMessageRunner::SetInterval(bigtime_t interval)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*! \brief Sets the number of times message shall be sent.
|
|
||||||
\param count Specifies how many times the message shall be sent.
|
|
||||||
A value less than \c 0 for an unlimited number of repetitions.
|
|
||||||
- \c B_BAD_VALUE: The message runner has already sent all messages to be
|
|
||||||
sent and has become unusable.
|
|
||||||
\return
|
|
||||||
- \c B_OK: Everything went fine.
|
|
||||||
- \c B_NO_INIT: The message runner is not properly initialized.
|
|
||||||
*/
|
|
||||||
status_t
|
status_t
|
||||||
BMessageRunner::SetCount(int32 count)
|
BMessageRunner::SetCount(int32 count)
|
||||||
{
|
{
|
||||||
@@ -202,104 +94,67 @@ BMessageRunner::SetCount(int32 count)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*! \brief Returns the time interval between two messages and the number of
|
|
||||||
times the message has still to be sent.
|
|
||||||
|
|
||||||
Both parameters (\a interval and \a count) may be \c NULL.
|
|
||||||
|
|
||||||
\param interval Pointer to a pre-allocated bigtime_t variable to be set
|
|
||||||
to the time interval. May be \c NULL.
|
|
||||||
\param count Pointer to a pre-allocated int32 variable to be set
|
|
||||||
to the number of times the message has still to be sent.
|
|
||||||
May be \c NULL.
|
|
||||||
\return
|
|
||||||
- \c B_OK: Everything went fine.
|
|
||||||
- \c B_BAD_VALUE: The message runner is not longer valid. All the
|
|
||||||
messages that had to be sent have already been sent.
|
|
||||||
*/
|
|
||||||
status_t
|
status_t
|
||||||
BMessageRunner::GetInfo(bigtime_t* interval, int32* count) const
|
BMessageRunner::GetInfo(bigtime_t* interval, int32* count) const
|
||||||
{
|
{
|
||||||
status_t error = (fToken >= 0 ? B_OK : B_BAD_VALUE);
|
status_t result = fToken >= 0 ? B_OK : B_BAD_VALUE;
|
||||||
|
|
||||||
// compose the request message
|
// compose the request message
|
||||||
BMessage request(B_REG_GET_MESSAGE_RUNNER_INFO);
|
BMessage request(B_REG_GET_MESSAGE_RUNNER_INFO);
|
||||||
if (error == B_OK)
|
if (result == B_OK)
|
||||||
error = request.AddInt32("token", fToken);
|
result = request.AddInt32("token", fToken);
|
||||||
|
|
||||||
// send the request
|
// send the request
|
||||||
BMessage reply;
|
BMessage reply;
|
||||||
if (error == B_OK)
|
if (result == B_OK)
|
||||||
error = BRoster::Private().SendTo(&request, &reply, false);
|
result = BRoster::Private().SendTo(&request, &reply, false);
|
||||||
|
|
||||||
// evaluate the reply
|
// evaluate the reply
|
||||||
if (error == B_OK) {
|
if (result == B_OK) {
|
||||||
if (reply.what == B_REG_SUCCESS) {
|
if (reply.what == B_REG_SUCCESS) {
|
||||||
// count
|
// count
|
||||||
int32 _count;
|
int32 _count;
|
||||||
if (reply.FindInt32("count", &_count) == B_OK) {
|
if (reply.FindInt32("count", &_count) == B_OK) {
|
||||||
if (count)
|
if (count != 0)
|
||||||
*count = _count;
|
*count = _count;
|
||||||
} else
|
} else
|
||||||
error = B_ERROR;
|
result = B_ERROR;
|
||||||
|
|
||||||
// interval
|
// interval
|
||||||
bigtime_t _interval;
|
bigtime_t _interval;
|
||||||
if (reply.FindInt64("interval", &_interval) == B_OK) {
|
if (reply.FindInt64("interval", &_interval) == B_OK) {
|
||||||
if (interval)
|
if (interval != 0)
|
||||||
*interval = _interval;
|
*interval = _interval;
|
||||||
} else
|
} else
|
||||||
error = B_ERROR;
|
result = B_ERROR;
|
||||||
} else {
|
} else {
|
||||||
if (reply.FindInt32("error", &error) != B_OK)
|
if (reply.FindInt32("error", &result) != B_OK)
|
||||||
error = B_ERROR;
|
result = B_ERROR;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return error;
|
|
||||||
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*! \brief Creates and initializes a detached BMessageRunner.
|
|
||||||
|
|
||||||
You cannot alter the runner after the creation, and it will be deleted
|
|
||||||
automatically once it is done.
|
|
||||||
The target for replies to the delivered message(s) is \c be_app_messenger.
|
|
||||||
|
|
||||||
\param target Target of the message(s).
|
|
||||||
\param message The message to be sent to the target.
|
|
||||||
\param interval Period of time before the first message is sent and
|
|
||||||
between messages (if more than one shall be sent) in microseconds.
|
|
||||||
\param count Specifies how many times the message shall be sent.
|
|
||||||
A value less than \c 0 for an unlimited number of repetitions.
|
|
||||||
*/
|
|
||||||
/*static*/ status_t
|
/*static*/ status_t
|
||||||
BMessageRunner::StartSending(BMessenger target, const BMessage* message,
|
BMessageRunner::StartSending(BMessenger target, const BMessage* message,
|
||||||
bigtime_t interval, int32 count)
|
bigtime_t interval, int32 count)
|
||||||
{
|
{
|
||||||
int32 token = _RegisterRunner(target, message, interval, count, true,
|
int32 token = _RegisterRunner(target, message, interval, count, true,
|
||||||
be_app_messenger);
|
be_app_messenger);
|
||||||
|
|
||||||
return token >= B_OK ? B_OK : token;
|
return token >= B_OK ? B_OK : token;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*! \brief Creates and initializes a detached BMessageRunner.
|
|
||||||
|
|
||||||
You cannot alter the runner after the creation, and it will be deleted
|
|
||||||
automatically once it is done.
|
|
||||||
|
|
||||||
\param target Target of the message(s).
|
|
||||||
\param message The message to be sent to the target.
|
|
||||||
\param interval Period of time before the first message is sent and
|
|
||||||
between messages (if more than one shall be sent) in microseconds.
|
|
||||||
\param count Specifies how many times the message shall be sent.
|
|
||||||
A value less than \c 0 for an unlimited number of repetitions.
|
|
||||||
\param replyTo Target replies to the delivered message(s) shall be sent to.
|
|
||||||
*/
|
|
||||||
/*static*/ status_t
|
/*static*/ status_t
|
||||||
BMessageRunner::StartSending(BMessenger target, const BMessage* message,
|
BMessageRunner::StartSending(BMessenger target, const BMessage* message,
|
||||||
bigtime_t interval, int32 count, BMessenger replyTo)
|
bigtime_t interval, int32 count, BMessenger replyTo)
|
||||||
{
|
{
|
||||||
int32 token = _RegisterRunner(target, message, interval, count, true, replyTo);
|
int32 token = _RegisterRunner(target, message, interval, count, true,
|
||||||
|
replyTo);
|
||||||
|
|
||||||
return token >= B_OK ? B_OK : token;
|
return token >= B_OK ? B_OK : token;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -313,38 +168,37 @@ void BMessageRunner::_ReservedMessageRunner5() {}
|
|||||||
void BMessageRunner::_ReservedMessageRunner6() {}
|
void BMessageRunner::_ReservedMessageRunner6() {}
|
||||||
|
|
||||||
|
|
||||||
/*! \brief Privatized copy constructor to prevent usage.
|
//! Privatized copy constructor to prevent usage.
|
||||||
*/
|
|
||||||
BMessageRunner::BMessageRunner(const BMessageRunner &)
|
BMessageRunner::BMessageRunner(const BMessageRunner &)
|
||||||
: fToken(-1)
|
:
|
||||||
|
fToken(-1)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*! \brief Privatized assignment operator to prevent usage.
|
//! Privatized assignment operator to prevent usage.
|
||||||
*/
|
BMessageRunner&
|
||||||
BMessageRunner &
|
BMessageRunner::operator=(const BMessageRunner&)
|
||||||
BMessageRunner::operator=(const BMessageRunner &)
|
|
||||||
{
|
{
|
||||||
return* this;
|
return* this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*! \brief Initializes the BMessageRunner.
|
/*! Initializes the BMessageRunner.
|
||||||
|
|
||||||
The success of the initialization can (and should) be asked for via
|
The success of the initialization can (and should) be asked for via
|
||||||
InitCheck().
|
InitCheck().
|
||||||
|
|
||||||
\note As soon as the last message has been sent, the message runner
|
\note As soon as the last message has been sent, the message runner
|
||||||
becomes unusable. InitCheck() will still return \c B_OK, but
|
becomes unusable. InitCheck() will still return \c B_OK, but
|
||||||
SetInterval(), SetCount() and GetInfo() will fail.
|
SetInterval(), SetCount() and GetInfo() will fail.
|
||||||
|
|
||||||
\param target Target of the message(s).
|
\param target Target of the message(s).
|
||||||
\param message The message to be sent to the target.
|
\param message The message to be sent to the target.
|
||||||
\param interval Period of time before the first message is sent and
|
\param interval Period of time before the first message is sent and
|
||||||
between messages (if more than one shall be sent) in microseconds.
|
between messages (if more than one shall be sent) in microseconds.
|
||||||
\param count Specifies how many times the message shall be sent.
|
\param count Specifies how many times the message shall be sent.
|
||||||
A value less than \c 0 for an unlimited number of repetitions.
|
A value less than \c 0 for an unlimited number of repetitions.
|
||||||
\param replyTo Target replies to the delivered message(s) shall be sent to.
|
\param replyTo Target replies to the delivered message(s) shall be sent to.
|
||||||
*/
|
*/
|
||||||
void
|
void
|
||||||
@@ -355,68 +209,73 @@ BMessageRunner::_InitData(BMessenger target, const BMessage* message,
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*! \brief Registers the BMessageRunner in the registrar.
|
/*! Registers the BMessageRunner in the registrar.
|
||||||
|
|
||||||
\param target Target of the message(s).
|
\param target Target of the message(s).
|
||||||
\param message The message to be sent to the target.
|
\param message The message to be sent to the target.
|
||||||
\param interval Period of time before the first message is sent and
|
\param interval Period of time before the first message is sent and
|
||||||
between messages (if more than one shall be sent) in microseconds.
|
between messages (if more than one shall be sent) in microseconds.
|
||||||
\param count Specifies how many times the message shall be sent.
|
\param count Specifies how many times the message shall be sent.
|
||||||
A value less than \c 0 for an unlimited number of repetitions.
|
A value less than \c 0 for an unlimited number of repetitions.
|
||||||
\param replyTo Target replies to the delivered message(s) shall be sent to.
|
\param replyTo Target replies to the delivered message(s) shall be sent to.
|
||||||
|
|
||||||
\return The token the message runner is registered with, or the error code
|
\return The token the message runner is registered with, or the error code
|
||||||
while trying to register it.
|
while trying to register it.
|
||||||
*/
|
*/
|
||||||
/*static*/ int32
|
/*static*/ int32
|
||||||
BMessageRunner::_RegisterRunner(BMessenger target, const BMessage* message,
|
BMessageRunner::_RegisterRunner(BMessenger target, const BMessage* message,
|
||||||
bigtime_t interval, int32 count, bool detach, BMessenger replyTo)
|
bigtime_t interval, int32 count, bool detach, BMessenger replyTo)
|
||||||
{
|
{
|
||||||
status_t error = B_OK;
|
status_t result = B_OK;
|
||||||
if (message == NULL || count == 0 || (count < 0 && detach))
|
if (message == NULL || count == 0 || (count < 0 && detach))
|
||||||
error = B_BAD_VALUE;
|
result = B_BAD_VALUE;
|
||||||
|
|
||||||
// compose the request message
|
// compose the request message
|
||||||
BMessage request(B_REG_REGISTER_MESSAGE_RUNNER);
|
BMessage request(B_REG_REGISTER_MESSAGE_RUNNER);
|
||||||
if (error == B_OK)
|
if (result == B_OK)
|
||||||
error = request.AddInt32("team", BPrivate::current_team());
|
result = request.AddInt32("team", BPrivate::current_team());
|
||||||
if (error == B_OK)
|
|
||||||
error = request.AddMessenger("target", target);
|
if (result == B_OK)
|
||||||
if (error == B_OK)
|
result = request.AddMessenger("target", target);
|
||||||
error = request.AddMessage("message", message);
|
|
||||||
if (error == B_OK)
|
if (result == B_OK)
|
||||||
error = request.AddInt64("interval", interval);
|
result = request.AddMessage("message", message);
|
||||||
if (error == B_OK)
|
|
||||||
error = request.AddInt32("count", count);
|
if (result == B_OK)
|
||||||
if (error == B_OK)
|
result = request.AddInt64("interval", interval);
|
||||||
error = request.AddMessenger("reply_target", replyTo);
|
|
||||||
|
if (result == B_OK)
|
||||||
|
result = request.AddInt32("count", count);
|
||||||
|
|
||||||
|
if (result == B_OK)
|
||||||
|
result = request.AddMessenger("reply_target", replyTo);
|
||||||
|
|
||||||
// send the request
|
// send the request
|
||||||
BMessage reply;
|
BMessage reply;
|
||||||
if (error == B_OK)
|
if (result == B_OK)
|
||||||
error = BRoster::Private().SendTo(&request, &reply, false);
|
result = BRoster::Private().SendTo(&request, &reply, false);
|
||||||
|
|
||||||
int32 token;
|
int32 token;
|
||||||
|
|
||||||
// evaluate the reply
|
// evaluate the reply
|
||||||
if (error == B_OK) {
|
if (result == B_OK) {
|
||||||
if (reply.what == B_REG_SUCCESS) {
|
if (reply.what == B_REG_SUCCESS) {
|
||||||
if (reply.FindInt32("token", &token) != B_OK)
|
if (reply.FindInt32("token", &token) != B_OK)
|
||||||
error = B_ERROR;
|
result = B_ERROR;
|
||||||
} else {
|
} else {
|
||||||
if (reply.FindInt32("error", &error) != B_OK)
|
if (reply.FindInt32("error", &result) != B_OK)
|
||||||
error = B_ERROR;
|
result = B_ERROR;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (error == B_OK)
|
if (result == B_OK)
|
||||||
return token;
|
return token;
|
||||||
|
|
||||||
return error;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*! \brief Sets the message runner's interval and count parameters.
|
/*! Sets the message runner's interval and count parameters.
|
||||||
|
|
||||||
The parameters \a resetInterval and \a resetCount specify whether
|
The parameters \a resetInterval and \a resetCount specify whether
|
||||||
the interval or the count parameter respectively shall be reset.
|
the interval or the count parameter respectively shall be reset.
|
||||||
@@ -425,17 +284,18 @@ BMessageRunner::_RegisterRunner(BMessenger target, const BMessage* message,
|
|||||||
\c B_BAD_VALUE.
|
\c B_BAD_VALUE.
|
||||||
|
|
||||||
\param resetInterval \c true, if the interval shall be reset, \c false
|
\param resetInterval \c true, if the interval shall be reset, \c false
|
||||||
otherwise -- then \a interval is ignored.
|
otherwise -- then \a interval is ignored.
|
||||||
\param interval The new interval in microseconds.
|
\param interval The new interval in microseconds.
|
||||||
\param resetCount \c true, if the count shall be reset, \c false
|
\param resetCount \c true, if the count shall be reset, \c false
|
||||||
otherwise -- then \a count is ignored.
|
otherwise -- then \a count is ignored.
|
||||||
\param count Specifies how many times the message shall be sent.
|
\param count Specifies how many times the message shall be sent.
|
||||||
A value less than \c 0 for an unlimited number of repetitions.
|
A value less than \c 0 for an unlimited number of repetitions.
|
||||||
\return
|
|
||||||
- \c B_OK: Everything went fine.
|
\return A status code.
|
||||||
- \c B_BAD_VALUE: The message runner is not longer valid. All the
|
\retval B_OK Everything went fine.
|
||||||
messages that had to be sent have already been sent. Or both
|
\retval B_BAD_VALUE The message runner is not longer valid. All the
|
||||||
\a resetInterval and \a resetCount are \c false.
|
messages that had to be sent have already been sent. Or both
|
||||||
|
\a resetInterval and \a resetCount are \c false.
|
||||||
*/
|
*/
|
||||||
status_t
|
status_t
|
||||||
BMessageRunner::_SetParams(bool resetInterval, bigtime_t interval,
|
BMessageRunner::_SetParams(bool resetInterval, bigtime_t interval,
|
||||||
@@ -446,23 +306,25 @@ BMessageRunner::_SetParams(bool resetInterval, bigtime_t interval,
|
|||||||
|
|
||||||
// compose the request message
|
// compose the request message
|
||||||
BMessage request(B_REG_SET_MESSAGE_RUNNER_PARAMS);
|
BMessage request(B_REG_SET_MESSAGE_RUNNER_PARAMS);
|
||||||
status_t error = request.AddInt32("token", fToken);
|
status_t result = request.AddInt32("token", fToken);
|
||||||
if (error == B_OK && resetInterval)
|
if (result == B_OK && resetInterval)
|
||||||
error = request.AddInt64("interval", interval);
|
result = request.AddInt64("interval", interval);
|
||||||
if (error == B_OK && resetCount)
|
|
||||||
error = request.AddInt32("count", count);
|
if (result == B_OK && resetCount)
|
||||||
|
result = request.AddInt32("count", count);
|
||||||
|
|
||||||
// send the request
|
// send the request
|
||||||
BMessage reply;
|
BMessage reply;
|
||||||
if (error == B_OK)
|
if (result == B_OK)
|
||||||
error = BRoster::Private().SendTo(&request, &reply, false);
|
result = BRoster::Private().SendTo(&request, &reply, false);
|
||||||
|
|
||||||
// evaluate the reply
|
// evaluate the reply
|
||||||
if (error == B_OK) {
|
if (result == B_OK) {
|
||||||
if (reply.what != B_REG_SUCCESS) {
|
if (reply.what != B_REG_SUCCESS) {
|
||||||
if (reply.FindInt32("error", &error) != B_OK)
|
if (reply.FindInt32("error", &result) != B_OK)
|
||||||
error = B_ERROR;
|
result = B_ERROR;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return error;
|
|
||||||
|
return result;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user