From 9e9f5a1ad34c5bbefe475da7114a7dc53cb26bf3 Mon Sep 17 00:00:00 2001 From: Ingo Weinhold Date: Fri, 9 Aug 2002 23:31:40 +0000 Subject: [PATCH] Improved BMessenger::InitData() a bit: Now only one roster call is done, when a signature but no team ID is given. git-svn-id: file:///srv/svn/repos/haiku/trunk/current@676 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- src/kits/app/Messenger.cpp | 34 +++++++++++++++++----------------- 1 file changed, 17 insertions(+), 17 deletions(-) diff --git a/src/kits/app/Messenger.cpp b/src/kits/app/Messenger.cpp index e0a7ace255..e3466cf17d 100644 --- a/src/kits/app/Messenger.cpp +++ b/src/kits/app/Messenger.cpp @@ -32,6 +32,7 @@ // Standard Includes ----------------------------------------------------------- #include #include +#include // System Includes ------------------------------------------------------------- #include @@ -585,28 +586,27 @@ 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 + // get an app_info + app_info info; if (team < 0) { + // no team ID given if (signature) { - team = be_roster->TeamFor(signature); - if (team < 0) { - error = team; - // B_ERROR means that no application with the given signature - // is running. But we are supposed to return B_BAD_VALUE. - if (error == B_ERROR) - error = B_BAD_VALUE; - } + error = be_roster->GetAppInfo(signature, &info); + team = info.team; + // B_ERROR means that no application with the given signature + // is running. But we are supposed to return B_BAD_VALUE. + if (error == B_ERROR) + error = B_BAD_VALUE; } else error = B_BAD_TYPE; - } - // get the app_info of the team - app_info info; - if (error == B_OK) + } else { + // a team ID is given error = be_roster->GetRunningAppInfo(team, &info); - // check, whether the signature is correct - if (error == B_OK && signature && strcmp(signature, info.signature) != 0) - error = B_MISMATCHED_VALUES; - // check whether it the app flags say B_ARGV_ONLY + // Compare the returned signature with the supplied one. + if (error == B_OK && signature && strcmp(signature, info.signature)) + error = B_MISMATCHED_VALUES; + } + // check whether the app flags say B_ARGV_ONLY if (error == B_OK && (info.flags & B_ARGV_ONLY)) { error = B_BAD_TYPE; // Set the team ID nevertheless -- that's what Be's implementation