diff --git a/headers/os/app/Roster.h b/headers/os/app/Roster.h index c63a068bb3..04a78163b4 100644 --- a/headers/os/app/Roster.h +++ b/headers/os/app/Roster.h @@ -39,17 +39,6 @@ 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); - -namespace BPrivate { - void init_registrar_roster(BMessenger mainMessenger, - BMessenger mimeMessenger); -} - /*-------------------------------------------------------------*/ /* --------- app_info Struct and Values ------------------------ */ @@ -149,15 +138,10 @@ public: const char *appSig = NULL) const; /*----- Private or reserved ------------------------------*/ + class Private; + private: - friend class BApplication; - friend class BWindow; - friend class _BAppCleanup_; - friend int _init_roster_(); - friend status_t _send_to_roster_(BMessage *, BMessage *, bool); - friend bool _is_valid_roster_mess_(bool); - friend void BPrivate::init_registrar_roster(BMessenger, BMessenger); - friend class GetRecentTester; + friend class Private; class ArgVector; diff --git a/headers/private/app/RosterPrivate.h b/headers/private/app/RosterPrivate.h new file mode 100644 index 0000000000..031b5aca32 --- /dev/null +++ b/headers/private/app/RosterPrivate.h @@ -0,0 +1,73 @@ +//---------------------------------------------------------------------- +// This software is part of the OpenBeOS distribution and is covered +// by the OpenBeOS license. +//--------------------------------------------------------------------- + +#ifndef _ROSTER_PRIVATE_H +#define _ROSTER_PRIVATE_H + +#include +#include + +class BRoster::Private { +public: + Private() : fRoster(const_cast(be_roster)) {} + Private(BRoster &roster) : fRoster(&roster) {} + Private(BRoster *roster) : fRoster(roster) {} + + void SetTo(BMessenger mainMessenger, BMessenger mimeMessenger); + + status_t SendTo(BMessage *message, BMessage *reply, bool mime); + bool IsMessengerValid(bool mime) const; + + // needed by BApplication + + status_t AddApplication(const char *mimeSig, const entry_ref *ref, + uint32 flags, team_id team, thread_id thread, + port_id port, bool fullReg, uint32 *token, + team_id *otherTeam) const + { return fRoster->AddApplication(mimeSig, ref, flags, team, thread, + port, fullReg, token, otherTeam); } + + status_t SetSignature(team_id team, const char *mimeSig) const + { return fRoster->SetSignature(team, mimeSig); } + + status_t CompleteRegistration(team_id team, thread_id thread, + port_id port) const + { return fRoster->CompleteRegistration(team, thread, port); } + + bool IsAppPreRegistered(const entry_ref *ref, team_id team, + app_info *info) const + { return fRoster->IsAppPreRegistered(ref, team, info); } + + status_t RemoveApp(team_id team) const + { return fRoster->RemoveApp(team); } + + // needed by GetRecentTester + + void AddToRecentApps(const char *appSig) const + { fRoster->AddToRecentApps(appSig); } + + void ClearRecentDocuments() const + { fRoster->ClearRecentDocuments(); } + + void ClearRecentFolders() const + { fRoster->ClearRecentFolders(); } + + void ClearRecentApps() const + { fRoster->ClearRecentApps(); } + + void LoadRecentLists(const char *file) const + { fRoster->LoadRecentLists(file); } + + void SaveRecentLists(const char *file) const + { fRoster->SaveRecentLists(file); } + +private: + BRoster *fRoster; +}; + +extern "C" int _init_roster_(); +extern "C" int _delete_roster_(); + +#endif // _ROSTER_PRIVATE_H diff --git a/src/kits/app/Application.cpp b/src/kits/app/Application.cpp index 4b1022466d..78acf84a40 100644 --- a/src/kits/app/Application.cpp +++ b/src/kits/app/Application.cpp @@ -44,6 +44,7 @@ #include #include #include +#include #include // Project Includes ------------------------------------------------------------ @@ -216,7 +217,7 @@ BApplication::BApplication(const char* signature, status_t* error) BApplication::~BApplication() { // unregister from the roster - be_roster->RemoveApp(Team()); + BRoster::Private().RemoveApp(Team()); // uninitialize be_app and be_app_messenger be_app = NULL; // R5 doesn't uninitialize be_app_messenger. @@ -659,15 +660,18 @@ void BApplication::InitData(const char* signature, status_t* error) } } // check whether be_roster is valid - if (fInitError == B_OK && !isRegistrar && !_is_valid_roster_mess_(false)) { + if (fInitError == B_OK && !isRegistrar + && !BRoster::Private().IsMessengerValid(false)) { printf("FATAL: be_roster is not valid. Is the registrar running?\n"); fInitError = B_NO_INIT; } // check whether or not we are pre-registered bool preRegistered = false; app_info appInfo; - if (fInitError == B_OK && !isRegistrar) - preRegistered = be_roster->IsAppPreRegistered(&ref, team, &appInfo); + if (fInitError == B_OK && !isRegistrar) { + preRegistered = BRoster::Private().IsAppPreRegistered(&ref, team, + &appInfo); + } if (preRegistered) { // we are pre-registered => the app info has been filled in // Check whether we need to replace the looper port with a port @@ -679,17 +683,17 @@ void BApplication::InitData(const char* signature, status_t* error) appInfo.port = fMsgPort; // check the signature and correct it, if necessary if (strcmp(appInfo.signature, fAppName)) - be_roster->SetSignature(team, fAppName); + BRoster::Private().SetSignature(team, fAppName); // complete the registration - fInitError = be_roster->CompleteRegistration(team, thread, - appInfo.port); + fInitError = BRoster::Private().CompleteRegistration(team, thread, + appInfo.port); } else if (fInitError == B_OK) { // not pre-registered -- try to register the application team_id otherTeam = -1; // the registrar must not register if (!isRegistrar) { - fInitError = be_roster->AddApplication(signature, &ref, appFlags, - team, thread, fMsgPort, true, NULL, &otherTeam); + fInitError = BRoster::Private().AddApplication(signature, &ref, + appFlags, team, thread, fMsgPort, true, NULL, &otherTeam); } if (fInitError == B_ALREADY_RUNNING) { // An instance is already running and we asked for diff --git a/src/kits/app/Clipboard.cpp b/src/kits/app/Clipboard.cpp index cf0ba391e7..0a1b6cdf6f 100644 --- a/src/kits/app/Clipboard.cpp +++ b/src/kits/app/Clipboard.cpp @@ -32,8 +32,9 @@ // System Includes ------------------------------------------------------------- #include -#include #include +#include +#include // Project Includes ------------------------------------------------------------ @@ -56,7 +57,7 @@ BClipboard::BClipboard(const char *name, bool transient = false) fSystemCount = 0; BMessage message(B_REG_GET_CLIPBOARD_MESSENGER), reply; - if ( (_send_to_roster_(&message, &reply, false) == B_OK) && + if ( (BRoster::Private().SendTo(&message, &reply, false) == B_OK) && (reply.what == B_REG_SUCCESS) && (reply.FindMessenger("messenger",&fClipHandler) == B_OK) ) { diff --git a/src/kits/app/InitTerminateLibBe.cpp b/src/kits/app/InitTerminateLibBe.cpp index 15c4779a4d..31b0324802 100644 --- a/src/kits/app/InitTerminateLibBe.cpp +++ b/src/kits/app/InitTerminateLibBe.cpp @@ -25,7 +25,7 @@ //------------------------------------------------------------------------------ #include -#include +#include // debugging //#define DBG(x) x diff --git a/src/kits/app/MessageRunner.cpp b/src/kits/app/MessageRunner.cpp index ced25729c4..bebe6b361d 100644 --- a/src/kits/app/MessageRunner.cpp +++ b/src/kits/app/MessageRunner.cpp @@ -29,6 +29,7 @@ #include #include #include +#include // constructor /*! \brief Creates and initializes a new BMessageRunner. @@ -98,7 +99,7 @@ BMessageRunner::~BMessageRunner() // send the request BMessage reply; if (error == B_OK) - error = _send_to_roster_(&request, &reply, false); + error = BRoster::Private().SendTo(&request, &reply, false); // ignore the reply, we can't do anything anyway } @@ -176,7 +177,7 @@ BMessageRunner::GetInfo(bigtime_t *interval, int32 *count) const // send the request BMessage reply; if (error == B_OK) - error = _send_to_roster_(&request, &reply, false); + error = BRoster::Private().SendTo(&request, &reply, false); // evaluate the reply if (error == B_OK) { if (reply.what == B_REG_SUCCESS) { @@ -267,7 +268,7 @@ BMessageRunner::InitData(BMessenger target, const BMessage *message, // send the request BMessage reply; if (error == B_OK) - error = _send_to_roster_(&request, &reply, false); + error = BRoster::Private().SendTo(&request, &reply, false); // evaluate the reply if (error == B_OK) { if (reply.what == B_REG_SUCCESS) { @@ -319,7 +320,7 @@ BMessageRunner::SetParams(bool resetInterval, bigtime_t interval, // send the request BMessage reply; if (error == B_OK) - error = _send_to_roster_(&request, &reply, false); + error = BRoster::Private().SendTo(&request, &reply, false); // evaluate the reply if (error == B_OK) { if (reply.what != B_REG_SUCCESS) diff --git a/src/kits/app/Roster.cpp b/src/kits/app/Roster.cpp index 2aa121983f..00aa8545bf 100644 --- a/src/kits/app/Roster.cpp +++ b/src/kits/app/Roster.cpp @@ -48,6 +48,7 @@ #include #include #include +#include #include // debugging @@ -2304,92 +2305,6 @@ BRoster::SaveRecentLists(const char *filename) const 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 ------------------------------*/ diff --git a/src/kits/app/RosterPrivate.cpp b/src/kits/app/RosterPrivate.cpp new file mode 100644 index 0000000000..37d5e79da1 --- /dev/null +++ b/src/kits/app/RosterPrivate.cpp @@ -0,0 +1,112 @@ +//---------------------------------------------------------------------- +// This software is part of the OpenBeOS distribution and is covered +// by the OpenBeOS license. +//--------------------------------------------------------------------- + +#include +#include + +/*! \class BRoster::Private + \brief Class used to access private BRoster members. + + This way, the only friend BRoster needs is this class. +*/ + +// SetTo +/*! \brief Initializes the roster. + + \param mainMessenger A BMessenger targeting the registrar application. + \param mimeMessenger A BMessenger targeting the MIME manager. +*/ +void +BRoster::Private::SetTo(BMessenger mainMessenger, BMessenger mimeMessenger) +{ + if (fRoster) { + fRoster->fMess = mainMessenger; + fRoster->fMimeMess = mimeMessenger; + } +} + +// SendTo +/*! \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: the roster is \c NULL. + - another error code +*/ +status_t +BRoster::Private::SendTo(BMessage *message, BMessage *reply, bool mime) +{ + status_t error = (message ? B_OK : B_BAD_VALUE); + if (error == B_OK && !fRoster) + error = B_NO_INIT; + if (error == B_OK) { + if (mime) + error = fRoster->fMimeMess.SendMessage(message, reply); + else + error = fRoster->fMess.SendMessage(message, reply); + } + return error; +} + +// IsMessengerValid +/*! \brief Returns whether the 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 +BRoster::Private::IsMessengerValid(bool mime) const +{ + return (fRoster && (mime ? fRoster->fMimeMess.IsValid() + : fRoster->fMess.IsValid())); +} + + +// _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; +} + diff --git a/src/kits/app/app.src b/src/kits/app/app.src index b8f4d33baf..ff47716e5e 100644 --- a/src/kits/app/app.src +++ b/src/kits/app/app.src @@ -18,5 +18,6 @@ APP_KIT_SOURCE = RegistrarThread.cpp RegistrarThreadManager.cpp Roster.cpp + RosterPrivate.cpp TokenSpace.cpp ; diff --git a/src/kits/storage/Mime.cpp b/src/kits/storage/Mime.cpp index acf0d44d89..2036ab5504 100644 --- a/src/kits/storage/Mime.cpp +++ b/src/kits/storage/Mime.cpp @@ -18,6 +18,7 @@ #include #include #include +#include #include @@ -51,7 +52,7 @@ status_t do_mime_update(int32 what, const char *path, int recursive, if (!err) err = msg.AddBool("force", force); if (!err) - err = _send_to_roster_(&msg, &reply, true); + err = BRoster::Private().SendTo(&msg, &reply, true); if (!err) err = reply.what == B_REG_RESULT ? B_OK : B_BAD_VALUE; if (!err) diff --git a/src/kits/storage/MimeType.cpp b/src/kits/storage/MimeType.cpp index c260b76a88..22e436012b 100644 --- a/src/kits/storage/MimeType.cpp +++ b/src/kits/storage/MimeType.cpp @@ -18,7 +18,7 @@ #include // For printf() #include // For strncpy() #include -#include // For _send_to_roster_() +#include // For SendTo() // Private helper functions bool isValidMimeChar(const char ch); @@ -320,7 +320,7 @@ BMimeType::Install() if (!err) err = msg.AddString("type", Type()); if (!err) - err = _send_to_roster_(&msg, &reply, true); + err = BRoster::Private().SendTo(&msg, &reply, true); if (!err) err = reply.what == B_REG_RESULT ? B_OK : B_BAD_REPLY; if (!err) @@ -356,7 +356,7 @@ BMimeType::Delete() if (!err) err = msg.AddString("type", Type()); if (!err) - err = _send_to_roster_(&msg, &reply, true); + err = BRoster::Private().SendTo(&msg, &reply, true); if (!err) err = reply.what == B_REG_RESULT ? B_OK : B_BAD_REPLY; if (!err) @@ -629,7 +629,7 @@ BMimeType::GetSupportingApps(BMessage *signatures) const if (!err) err = msg.AddString("type", Type()); if (!err) - err = _send_to_roster_(&msg, &reply, true); + err = BRoster::Private().SendTo(&msg, &reply, true); if (!err) err = reply.what == B_REG_RESULT ? B_OK : B_BAD_REPLY; if (!err) @@ -703,7 +703,7 @@ BMimeType::SetPreferredApp(const char *signature, app_verb verb) if (!err) err = msg.AddInt32("app verb", verb); if (!err) - err = _send_to_roster_(&msg, &reply, true); + err = BRoster::Private().SendTo(&msg, &reply, true); if (!err) err = reply.what == B_REG_RESULT ? B_OK : B_BAD_REPLY; if (!err) @@ -779,7 +779,7 @@ BMimeType::SetAttrInfo(const BMessage *info) if (!err && info) err = msg.AddMessage("attr info", info); if (!err) - err = _send_to_roster_(&msg, &reply, true); + err = BRoster::Private().SendTo(&msg, &reply, true); if (!err) err = reply.what == B_REG_RESULT ? B_OK : B_BAD_REPLY; if (!err) @@ -836,7 +836,7 @@ BMimeType::SetFileExtensions(const BMessage *extensions) if (!err && extensions) err = msg.AddMessage("extensions", extensions); if (!err) - err = _send_to_roster_(&msg, &reply, true); + err = BRoster::Private().SendTo(&msg, &reply, true); if (!err) err = reply.what == B_REG_RESULT ? B_OK : B_BAD_REPLY; if (!err) @@ -878,7 +878,7 @@ BMimeType::SetShortDescription(const char *description) if (!err) err = msg.AddBool("long", false); if (!err) - err = _send_to_roster_(&msg, &reply, true); + err = BRoster::Private().SendTo(&msg, &reply, true); if (!err) err = reply.what == B_REG_RESULT ? B_OK : B_BAD_REPLY; if (!err) @@ -920,7 +920,7 @@ BMimeType::SetLongDescription(const char *description) if (!err) err = msg.AddBool("long", true); if (!err) - err = _send_to_roster_(&msg, &reply, true); + err = BRoster::Private().SendTo(&msg, &reply, true); if (!err) err = reply.what == B_REG_RESULT ? B_OK : B_BAD_REPLY; if (!err) @@ -956,7 +956,7 @@ BMimeType::GetInstalledSupertypes(BMessage *supertypes) if (!err) msg.what = B_REG_MIME_GET_INSTALLED_SUPERTYPES; if (!err) - err = _send_to_roster_(&msg, &reply, true); + err = BRoster::Private().SendTo(&msg, &reply, true); if (!err) err = reply.what == B_REG_RESULT ? B_OK : B_BAD_REPLY; if (!err) @@ -1015,7 +1015,7 @@ BMimeType::GetInstalledTypes(const char *supertype, BMessage *types) if (!err && supertype) err = msg.AddString("supertype", supertype); if (!err) - err = _send_to_roster_(&msg, &reply, true); + err = BRoster::Private().SendTo(&msg, &reply, true); if (!err) err = reply.what == B_REG_RESULT ? B_OK : B_BAD_REPLY; if (!err) @@ -1163,7 +1163,7 @@ BMimeType::SetAppHint(const entry_ref *ref) if (!err && ref) err = msg.AddRef("app hint", ref); if (!err) - err = _send_to_roster_(&msg, &reply, true); + err = BRoster::Private().SendTo(&msg, &reply, true); if (!err) err = reply.what == B_REG_RESULT ? B_OK : B_BAD_REPLY; if (!err) @@ -1279,7 +1279,7 @@ BMimeType::SetIconForType(const char *type, const BBitmap *icon, icon_size which err = msg.AddString("file type", type); } if (!err) - err = _send_to_roster_(&msg, &reply, true); + err = BRoster::Private().SendTo(&msg, &reply, true); if (!err) err = reply.what == B_REG_RESULT ? B_OK : B_BAD_REPLY; if (!err) @@ -1345,7 +1345,7 @@ BMimeType::SetSnifferRule(const char *rule) if (!err && rule) err = msg.AddString("sniffer rule", rule); if (!err) - err = _send_to_roster_(&msg, &reply, true); + err = BRoster::Private().SendTo(&msg, &reply, true); if (!err) err = reply.what == B_REG_RESULT ? B_OK : B_BAD_REPLY; if (!err) @@ -1474,7 +1474,7 @@ BMimeType::GuessMimeType(const entry_ref *file, BMimeType *type) if (!err) err = msg.AddRef("file ref", file); if (!err) - err = _send_to_roster_(&msg, &reply, true); + err = BRoster::Private().SendTo(&msg, &reply, true); if (!err) err = reply.what == B_REG_RESULT ? B_OK : B_BAD_REPLY; if (!err) @@ -1512,7 +1512,7 @@ BMimeType::GuessMimeType(const void *buffer, int32 length, BMimeType *type) if (!err) err = msg.AddData("data", B_RAW_TYPE, buffer, length); if (!err) - err = _send_to_roster_(&msg, &reply, true); + err = BRoster::Private().SendTo(&msg, &reply, true); if (!err) err = reply.what == B_REG_RESULT ? B_OK : B_BAD_REPLY; if (!err) @@ -1553,7 +1553,7 @@ BMimeType::GuessMimeType(const char *filename, BMimeType *type) if (!err) err = msg.AddString("filename", filename); if (!err) - err = _send_to_roster_(&msg, &reply, true); + err = BRoster::Private().SendTo(&msg, &reply, true); if (!err) err = reply.what == B_REG_RESULT ? B_OK : B_BAD_REPLY; if (!err) @@ -1587,7 +1587,7 @@ BMimeType::StartWatching(BMessenger target) // Build and send the message, read the reply err = msg.AddMessenger("target", target); if (!err) - err = _send_to_roster_(&msg, &reply, true); + err = BRoster::Private().SendTo(&msg, &reply, true); if (!err) err = reply.what == B_REG_RESULT ? B_OK : B_BAD_REPLY; if (!err) @@ -1616,7 +1616,7 @@ BMimeType::StopWatching(BMessenger target) // Build and send the message, read the reply err = msg.AddMessenger("target", target); if (!err) - err = _send_to_roster_(&msg, &reply, true); + err = BRoster::Private().SendTo(&msg, &reply, true); if (!err) err = reply.what == B_REG_RESULT ? B_OK : B_BAD_REPLY; if (!err) @@ -1796,7 +1796,7 @@ BMimeType::SetSupportedTypes(const BMessage *types, bool fullSync) if (!err) err = msg.AddBool("full sync", fullSync); if (!err) - err = _send_to_roster_(&msg, &reply, true); + err = BRoster::Private().SendTo(&msg, &reply, true); if (!err) err = reply.what == B_REG_RESULT ? B_OK : B_BAD_REPLY; if (!err) @@ -1834,7 +1834,7 @@ BMimeType::GetAssociatedTypes(const char *extension, BMessage *types) if (!err) err = msg.AddString("extension", extension); if (!err) - err = _send_to_roster_(&msg, &reply, true); + err = BRoster::Private().SendTo(&msg, &reply, true); if (!err) err = reply.what == B_REG_RESULT ? B_OK : B_BAD_REPLY; if (!err) diff --git a/src/servers/registrar/Registrar.cpp b/src/servers/registrar/Registrar.cpp index 5d85d1b460..bbfe05e854 100644 --- a/src/servers/registrar/Registrar.cpp +++ b/src/servers/registrar/Registrar.cpp @@ -6,6 +6,7 @@ #include #include #include +#include #include "ClipboardHandler.h" #include "DiskDeviceManager.h" @@ -68,7 +69,7 @@ Registrar::~Registrar() delete fRoster; // Invalidate the global be_roster, so that the BApplication destructor // won't dead-lock when sending a message to itself. - BPrivate::init_registrar_roster(BMessenger(), BMessenger()); + BRoster::Private().SetTo(BMessenger(), BMessenger()); FUNCTION_END(); } @@ -233,8 +234,7 @@ Registrar::ReadyToRun() fEventQueue = new EventQueue(kEventQueueName); fMessageRunnerManager = new MessageRunnerManager(fEventQueue); // init the global be_roster - BPrivate::init_registrar_roster(be_app_messenger, - BMessenger(NULL, fMIMEManager)); + BRoster::Private().SetTo(be_app_messenger, BMessenger(NULL, fMIMEManager)); // create and schedule the sanity message event fSanityEvent = new MessageEvent(system_time() + kRosterSanityEventInterval, this, B_REG_ROSTER_SANITY_EVENT); @@ -276,25 +276,6 @@ Registrar::App() } -// init_registrar_roster -/*! \brief Initializes the global \a be_roster. - - While this is done automagically for all other applications while libbe - initialization, the registrar needs to help out a bit. - - \param mainMessenger A BMessenger targeting the registrar application. - \param mimeMessenger A BMessenger targeting the MIME manager. -*/ -void -BPrivate::init_registrar_roster(BMessenger mainMessenger, - BMessenger mimeMessenger) -{ - BRoster *roster = const_cast(be_roster); - roster->fMess = mainMessenger; - roster->fMimeMess = mimeMessenger; -} - - // main /*! \brief Creates and runs the registrar application. diff --git a/src/tests/kits/app/broster/GetRecentTester.cpp b/src/tests/kits/app/broster/GetRecentTester.cpp index fe4907b324..fbe39fa750 100644 --- a/src/tests/kits/app/broster/GetRecentTester.cpp +++ b/src/tests/kits/app/broster/GetRecentTester.cpp @@ -14,6 +14,7 @@ #include #include #include +#include // Project Includes ------------------------------------------------------------ #include @@ -1270,8 +1271,8 @@ GetRecentTester::RecentListsLoadSaveClearTest() roster.AddToRecentDocuments(&doc2, test_sigs[1]); roster.AddToRecentFolders(&folder1, test_sigs[0]); roster.AddToRecentFolders(&folder2, test_sigs[1]); - roster.AddToRecentApps(appSig1); - roster.AddToRecentApps(appSig2); + BRoster::Private(roster).AddToRecentApps(appSig1); + BRoster::Private(roster).AddToRecentApps(appSig2); // Check #1 NextSubTest(); @@ -1300,10 +1301,10 @@ GetRecentTester::RecentListsLoadSaveClearTest() // Save to disk and clear NextSubTest(); - roster.SaveRecentLists(kTempSaveFile); - roster.ClearRecentDocuments(); - roster.ClearRecentFolders(); - roster.ClearRecentApps(); + BRoster::Private(roster).SaveRecentLists(kTempSaveFile); + BRoster::Private(roster).ClearRecentDocuments(); + BRoster::Private(roster).ClearRecentFolders(); + BRoster::Private(roster).ClearRecentApps(); // Check #2 NextSubTest(); @@ -1323,7 +1324,7 @@ GetRecentTester::RecentListsLoadSaveClearTest() // Load back from disk NextSubTest(); - roster.LoadRecentLists(kTempSaveFile); + BRoster::Private(roster).LoadRecentLists(kTempSaveFile); // Check #3 NextSubTest();