From 3b044715729e97f74e9438b342aae8626a05cf7d Mon Sep 17 00:00:00 2001 From: Ingo Weinhold Date: Fri, 26 Jul 2002 19:48:49 +0000 Subject: [PATCH] Implemented InitData(). BMessenger is complete. git-svn-id: file:///srv/svn/repos/haiku/trunk/current@455 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- src/kits/app/Messenger.cpp | 30 +++++++++++++++++++++++++++--- 1 file changed, 27 insertions(+), 3 deletions(-) diff --git a/src/kits/app/Messenger.cpp b/src/kits/app/Messenger.cpp index 255be3c642..dbe214a757 100644 --- a/src/kits/app/Messenger.cpp +++ b/src/kits/app/Messenger.cpp @@ -41,6 +41,7 @@ #include #include #include +#include // Project Includes ------------------------------------------------------------ #include "TokenSpace.h" @@ -574,14 +575,37 @@ BMessenger::BMessenger(team_id team, port_id port, int32 token, bool preferred) \param team The target application's team ID. May be < 0. \param result An optional pointer to a pre-allocated status_t into which the result of the initialization is written. - - \todo Implement! */ void BMessenger::InitData(const char *signature, team_id team, status_t *result) { + status_t error = B_OK; + // if no team ID is given, get one using the signature + if (team < 0) { + if (signature) { + team = be_roster->TeamFor(signature); + if (team < 0) + error = team; + } else + error = B_BAD_VALUE; + } + // get the app_info of the team + app_info info; + if (error == B_OK) + error = be_roster->GetRunningAppInfo(team, &info); + // check, whether the signature is correct + if (error == B_OK && signature && strcmp(signature, info.signature) != 0) + error = B_BAD_VALUE; + // init our members + if (error == B_OK) { + fTeam = team; + fPort = info.port; + fHandlerToken = 0; + fPreferredTarget = true; + } + // return the error if (result) - *result = NOT_IMPLEMENTED; + *result = error; } // <