1 //---------------------------------------------------------------------- 2 // This software is part of the OpenBeOS distribution and is covered 3 // by the OpenBeOS license. 4 //--------------------------------------------------------------------- 5 6 #include <RosterPrivate.h> 7 #include <Roster.h> 8 9 /*! \class BRoster::Private 10 \brief Class used to access private BRoster members. 11 12 This way, the only friend BRoster needs is this class. 13 */ 14 15 // SetTo 16 /*! \brief Initializes the roster. 17 18 \param mainMessenger A BMessenger targeting the registrar application. 19 \param mimeMessenger A BMessenger targeting the MIME manager. 20 */ 21 void 22 BRoster::Private::SetTo(BMessenger mainMessenger, BMessenger mimeMessenger) 23 { 24 if (fRoster) { 25 fRoster->fMess = mainMessenger; 26 fRoster->fMimeMess = mimeMessenger; 27 } 28 } 29 30 // SendTo 31 /*! \brief Sends a message to the registrar. 32 33 \a mime specifies whether to send the message to the roster or to the 34 MIME data base service. 35 If \a reply is not \c NULL, the function waits for a reply. 36 37 \param message The message to be sent. 38 \param reply A pointer to a pre-allocated BMessage into which the reply 39 message will be copied. 40 \param mime \c true, if the message should be sent to the MIME data base 41 service, \c false for the roster. 42 \return 43 - \c B_OK: Everything went fine. 44 - \c B_BAD_VALUE: \c NULL \a message. 45 - \c B_NO_INIT: the roster is \c NULL. 46 - another error code 47 */ 48 status_t 49 BRoster::Private::SendTo(BMessage *message, BMessage *reply, bool mime) 50 { 51 status_t error = (message ? B_OK : B_BAD_VALUE); 52 if (error == B_OK && !fRoster) 53 error = B_NO_INIT; 54 if (error == B_OK) { 55 if (mime) 56 error = fRoster->fMimeMess.SendMessage(message, reply); 57 else 58 error = fRoster->fMess.SendMessage(message, reply); 59 } 60 return error; 61 } 62 63 // IsMessengerValid 64 /*! \brief Returns whether the roster's messengers are valid. 65 66 \a mime specifies whether to check the roster messenger or the one of 67 the MIME data base service. 68 69 \param mime \c true, if the MIME data base service messenger should be 70 checked, \c false for the roster messenger. 71 \return \true, if the selected messenger is valid, \c false otherwise. 72 */ 73 bool 74 BRoster::Private::IsMessengerValid(bool mime) const 75 { 76 return (fRoster && (mime ? fRoster->fMimeMess.IsValid() 77 : fRoster->fMess.IsValid())); 78 } 79 80 81 // _init_roster_ 82 /*! \brief Initializes the global be_roster variable. 83 84 Called before the global constructors are invoked. 85 86 \return Unknown! 87 88 \todo Investigate what the return value means. 89 */ 90 int 91 _init_roster_() 92 { 93 be_roster = new BRoster; 94 return 0; 95 } 96 97 // _delete_roster_ 98 /*! \brief Deletes the global be_roster. 99 100 Called after the global destructors are invoked. 101 102 \return Unknown! 103 104 \todo Investigate what the return value means. 105 */ 106 int 107 _delete_roster_() 108 { 109 delete be_roster; 110 return 0; 111 } 112 113