2 * Copyright 2001-2015, Haiku.
3 * Distributed under the terms of the MIT License.
6 * Ingo Weinhold (bonefish@users.sf.net)
10 //! Access class for BRoster members
13 #include <RosterPrivate.h>
20 /*! \class BRoster::Private
21 \brief Class used to access private BRoster members.
23 This way, the only friend BRoster needs is this class.
27 /*! \brief Initializes the roster.
29 \param mainMessenger A BMessenger targeting the registrar application.
30 \param mimeMessenger A BMessenger targeting the MIME manager.
33 BRoster::Private::SetTo(BMessenger mainMessenger
, BMessenger mimeMessenger
)
35 if (fRoster
!= NULL
) {
36 fRoster
->fMessenger
= mainMessenger
;
37 fRoster
->fMimeMessenger
= mimeMessenger
;
38 fRoster
->fMimeMessengerInitOnce
= INIT_ONCE_INITIALIZED
;
43 /*! \brief Sends a message to the registrar.
45 \a mime specifies whether to send the message to the roster or to the
46 MIME data base service.
47 If \a reply is not \c NULL, the function waits for a reply.
49 \param message The message to be sent.
50 \param reply A pointer to a pre-allocated BMessage into which the reply
51 message will be copied. May be \c NULL.
52 \param mime \c true, if the message should be sent to the MIME data base
53 service, \c false for the roster.
55 - \c B_OK: Everything went fine.
56 - \c B_BAD_VALUE: \c NULL \a message.
57 - \c B_NO_INIT: the roster is \c NULL.
61 BRoster::Private::SendTo(BMessage
*message
, BMessage
*reply
, bool mime
)
68 const BMessenger
& messenger
= mime
69 ? fRoster
->_MimeMessenger() : fRoster
->fMessenger
;
70 if (messenger
.IsTargetLocal())
74 ? messenger
.SendMessage(message
, reply
)
75 : messenger
.SendMessage(message
);
79 /*! \brief Returns whether the roster's messengers are valid.
81 \a mime specifies whether to check the roster messenger or the one of
82 the MIME data base service.
84 \param mime \c true, if the MIME data base service messenger should be
85 checked, \c false for the roster messenger.
86 \return \true, if the selected messenger is valid, \c false otherwise.
89 BRoster::Private::IsMessengerValid(bool mime
) const
91 return fRoster
!= NULL
&& (mime
? fRoster
->_MimeMessenger().IsValid()
92 : fRoster
->fMessenger
.IsValid());
96 /*! \brief Initializes the global be_roster variable.
98 Called before the global constructors are invoked.
101 BRoster::Private::InitBeRoster()
103 be_roster
= new BRoster
;
107 /*! \brief Deletes the global be_roster.
109 Called after the global destructors are invoked.
112 BRoster::Private::DeleteBeRoster()