From 8cd292013baf44e4afdaff63d0e3f51e6ee39301 Mon Sep 17 00:00:00 2001 From: Ingo Weinhold Date: Sun, 28 Jul 2002 19:30:27 +0000 Subject: [PATCH] Added _send_to_roster_() and _is_valid_roster_mess_(). git-svn-id: file:///srv/svn/repos/haiku/trunk/current@512 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- headers/os/app/Roster.h | 3 + src/kits/app/Roster.cpp | 118 +++++++++++++++++++++++++++++----------- 2 files changed, 89 insertions(+), 32 deletions(-) diff --git a/headers/os/app/Roster.h b/headers/os/app/Roster.h index d978d6d54d..1972d75c58 100644 --- a/headers/os/app/Roster.h +++ b/headers/os/app/Roster.h @@ -39,8 +39,11 @@ class BList; class BMessage; class BNodeInfo; +// TODO: relocate these private prototypes extern "C" int _init_roster_(); extern "C" int _delete_roster_(); +status_t _send_to_roster_(BMessage *message, BMessage *reply, bool mime); +bool _is_valid_roster_mess_(bool mime); /*-------------------------------------------------------------*/ /* --------- app_info Struct and Values ------------------------ */ diff --git a/src/kits/app/Roster.cpp b/src/kits/app/Roster.cpp index 1a5026967f..4ebfd05f04 100644 --- a/src/kits/app/Roster.cpp +++ b/src/kits/app/Roster.cpp @@ -45,38 +45,6 @@ enum { NOT_IMPLEMENTED = B_ERROR, }; -// _init_roster_ -/*! \brief Initializes the global be_roster variable. - - Called before the global constructors are invoked. - - \return Unknown! - - \todo Investigate what the return value means. -*/ -int -_init_roster_() -{ - be_roster = new BRoster; - return 0; -} - -// _delete_roster_ -/*! \brief Deletes the global be_roster. - - Called after the global destructors are invoked. - - \return Unknown! - - \todo Investigate what the return value means. -*/ -int -_delete_roster_() -{ - delete be_roster; - return 0; -} - // helper function prototypes static status_t find_message_app_info(BMessage *message, app_info *info); @@ -998,6 +966,92 @@ DBG(OUT("BRoster::InitMessengers() done\n")); const BRoster *be_roster; +/*-----------------------------------------------------*/ +/*----- Private functions -----------------------------*/ + +// _init_roster_ +/*! \brief Initializes the global be_roster variable. + + Called before the global constructors are invoked. + + \return Unknown! + + \todo Investigate what the return value means. +*/ +int +_init_roster_() +{ + be_roster = new BRoster; + return 0; +} + +// _delete_roster_ +/*! \brief Deletes the global be_roster. + + Called after the global destructors are invoked. + + \return Unknown! + + \todo Investigate what the return value means. +*/ +int +_delete_roster_() +{ + delete be_roster; + return 0; +} + +// _send_to_roster_ +/*! \brief Sends a message to the registrar. + + \a mime specifies whether to send the message to the roster or to the + MIME data base service. + If \a reply is not \c NULL, the function waits for a reply. + + \param message The message to be sent. + \param reply A pointer to a pre-allocated BMessage into which the reply + message will be copied. + \param mime \c true, if the message should be sent to the MIME data base + service, \c false for the roster. + \return + - \c B_OK: Everything went fine. + - \c B_BAD_VALUE: \c NULL \a message. + - \c B_NO_INIT: be_roster is \c NULL. + - another error code +*/ +status_t +_send_to_roster_(BMessage *message, BMessage *reply, bool mime) +{ + status_t error = (message ? B_OK : B_BAD_VALUE); + if (error == B_OK && !be_roster) + error = B_NO_INIT; + if (error == B_OK) { + if (mime) + error = be_roster->fMimeMess.SendMessage(message, reply); + else + error = be_roster->fMess.SendMessage(message, reply); + } + return error; +} + +// _is_valid_roster_mess_ +/*! \brief Returns whether the global be_roster's messengers are valid. + + \a mime specifies whether to check the roster messenger or the one of + the MIME data base service. + + \param mime \c true, if the MIME data base service messenger should be + checked, \c false for the roster messenger. + \return \true, if the selected messenger is valid, \c false otherwise. +*/ +bool +_is_valid_roster_mess_(bool mime) +{ + return (be_roster && (mime ? be_roster->fMimeMess.IsValid() + : be_roster->fMess.IsValid())); +} + + /*-----------------------------------------------------*/ /*----- Helper functions ------------------------------*/