From 5e949b7dfcb1beacd57377e0d887abc6058587bf Mon Sep 17 00:00:00 2001 From: Ingo Weinhold Date: Sun, 28 Jul 2002 19:37:24 +0000 Subject: [PATCH] Added method Init(), which adds the registrar to the roster. git-svn-id: file:///srv/svn/repos/haiku/trunk/current@517 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- src/servers/registrar/TRoster.cpp | 38 +++++++++++++++++++++++++++++++ src/servers/registrar/TRoster.h | 2 ++ 2 files changed, 40 insertions(+) diff --git a/src/servers/registrar/TRoster.cpp b/src/servers/registrar/TRoster.cpp index 68706e9781..50b78a9b00 100644 --- a/src/servers/registrar/TRoster.cpp +++ b/src/servers/registrar/TRoster.cpp @@ -28,6 +28,7 @@ #include #include +#include #include "Debug.h" #include "RegistrarDefs.h" @@ -585,6 +586,43 @@ TRoster::HandleActivateApp(BMessage *request) FUNCTION_END(); } +// Init +/*! \brief Initializes the roster. + + Currently only adds the registrar to the roster. + The application must already be running, more precisly Run() must have + been called. + + \return + - \c B_OK: Everything went fine. + - an error code +*/ +status_t +TRoster::Init() +{ + status_t error = B_OK; + // create the info + RosterAppInfo *info = new(nothrow) RosterAppInfo; + if (!info) + error = B_NO_MEMORY; + // get the app's ref + entry_ref ref; + if (error == B_OK) + error = get_app_ref(&ref); + // init and add the info + if (error == B_OK) { + info->Init(be_app->Thread(), be_app->Team(), be_app_messenger.fPort, + B_EXCLUSIVE_LAUNCH, &ref, kRegistrarSignature); + info->state = APP_STATE_REGISTERED; + info->registration_time = system_time(); + error = AddApp(info); + } + // cleanup on error + if (error != B_OK && info) + delete info; + return error; +} + // AddApp /*! \brief Add the supplied app info to the list of (pre-)registered apps. diff --git a/src/servers/registrar/TRoster.h b/src/servers/registrar/TRoster.h index 167445c6b0..9cd8743e9a 100644 --- a/src/servers/registrar/TRoster.h +++ b/src/servers/registrar/TRoster.h @@ -62,6 +62,8 @@ public: void HandleGetAppList(BMessage *request); void HandleActivateApp(BMessage *request); + status_t Init(); + status_t AddApp(RosterAppInfo *info); void RemoveApp(RosterAppInfo *info); void ActivateApp(RosterAppInfo *info);