* Changed return type of some private methods from void to status_t.
AddApplication() returns the token via reference parameter and additionally returns the team ID of the already running app (if any). * Implemented AddApplication(), SetThreadAndTeam(), CompleteRegistration(), IsAppPreRegistered(), RemovePreRegApp(), RemoveApp(), or to to say it briefly the complete set of app registration helper functions. * Implemented GetRunningAppInfo() and GetActiveAppInfo(). git-svn-id: file:///srv/svn/repos/haiku/trunk/current@454 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
+11
-9
@@ -164,18 +164,20 @@ private:
|
|||||||
uint32 event_mask) const;
|
uint32 event_mask) const;
|
||||||
status_t _StopWatching(mtarget target, BMessenger *rosterMess, uint32 what,
|
status_t _StopWatching(mtarget target, BMessenger *rosterMess, uint32 what,
|
||||||
BMessenger notify) const;
|
BMessenger notify) const;
|
||||||
uint32 AddApplication(const char *mimeSig, entry_ref *ref, uint32 flags,
|
status_t AddApplication(const char *mimeSig, const entry_ref *ref,
|
||||||
team_id team, thread_id thread, port_id port,
|
uint32 flags, team_id team, thread_id thread,
|
||||||
bool fullReg) const;
|
port_id port, bool fullReg, uint32 *token,
|
||||||
|
team_id *otherTeam) const;
|
||||||
void SetSignature(team_id team, const char *mimeSig) const;
|
void SetSignature(team_id team, const char *mimeSig) const;
|
||||||
void SetThread(team_id team, thread_id thread) const;
|
void SetThread(team_id team, thread_id thread) const;
|
||||||
void SetThreadAndTeam(uint32 entry_token, thread_id thread,
|
status_t SetThreadAndTeam(uint32 entryToken, thread_id thread,
|
||||||
team_id team) const;
|
team_id team) const;
|
||||||
void CompleteRegistration(team_id team, thread_id, port_id port) const;
|
status_t CompleteRegistration(team_id team, thread_id thread,
|
||||||
bool IsAppPreRegistered(entry_ref *ref, team_id team,
|
port_id port) const;
|
||||||
|
bool IsAppPreRegistered(const entry_ref *ref, team_id team,
|
||||||
app_info *info) const;
|
app_info *info) const;
|
||||||
void RemovePreRegApp(uint32 entryToken) const;
|
status_t RemovePreRegApp(uint32 entryToken) const;
|
||||||
void RemoveApp(team_id team) const;
|
status_t RemoveApp(team_id team) const;
|
||||||
|
|
||||||
status_t xLaunchAppPrivate(const char *mimeSig, const entry_ref *ref,
|
status_t xLaunchAppPrivate(const char *mimeSig, const entry_ref *ref,
|
||||||
BList* msgList, int cargs, char **args,
|
BList* msgList, int cargs, char **args,
|
||||||
|
|||||||
+190
-16
@@ -60,6 +60,28 @@ _delete_roster_()
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// find_message_app_info
|
||||||
|
static
|
||||||
|
status_t
|
||||||
|
find_message_app_info(BMessage *message, app_info *info)
|
||||||
|
{
|
||||||
|
status_t error = B_OK;
|
||||||
|
const flat_app_info *flatInfo = NULL;
|
||||||
|
ssize_t size = 0;
|
||||||
|
error = message->FindData("app_info", B_REG_APP_INFO_TYPE,
|
||||||
|
(const void**)&flatInfo, &size);
|
||||||
|
if (error == B_OK) {
|
||||||
|
if (size == sizeof(flat_app_info)) {
|
||||||
|
memcpy(info, &flatInfo->info, sizeof(app_info));
|
||||||
|
info->ref.name = NULL;
|
||||||
|
if (strlen(flatInfo->ref_name) > 0)
|
||||||
|
info->ref.set_name(flatInfo->ref_name);
|
||||||
|
} else
|
||||||
|
error = B_ERROR;
|
||||||
|
}
|
||||||
|
return error;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/*-------------------------------------------------------------*/
|
/*-------------------------------------------------------------*/
|
||||||
/* --------- app_info Struct and Values ------------------------ */
|
/* --------- app_info Struct and Values ------------------------ */
|
||||||
@@ -69,7 +91,7 @@ app_info::app_info()
|
|||||||
: thread(-1),
|
: thread(-1),
|
||||||
team(-1),
|
team(-1),
|
||||||
port(-1),
|
port(-1),
|
||||||
flags(B_MULTIPLE_LAUNCH | B_ARGV_ONLY | _B_APP_INFO_RESERVED1_),
|
flags(B_REG_DEFAULT_APP_FLAGS),
|
||||||
ref()
|
ref()
|
||||||
{
|
{
|
||||||
signature[0] = '\0';
|
signature[0] = '\0';
|
||||||
@@ -158,14 +180,44 @@ BRoster::GetAppInfo(entry_ref *ref, app_info *info) const
|
|||||||
status_t
|
status_t
|
||||||
BRoster::GetRunningAppInfo(team_id team, app_info *info) const
|
BRoster::GetRunningAppInfo(team_id team, app_info *info) const
|
||||||
{
|
{
|
||||||
return NOT_IMPLEMENTED; // not implemented
|
status_t error = (team >= 0 && info ? B_OK : B_BAD_VALUE);
|
||||||
|
// compose the request message
|
||||||
|
BMessage request(B_REG_GET_RUNNING_APP_INFO);
|
||||||
|
if (error == B_OK)
|
||||||
|
error = request.AddInt32("team", team);
|
||||||
|
// send the request
|
||||||
|
BMessage reply;
|
||||||
|
if (error == B_OK)
|
||||||
|
error = fMess.SendMessage(&request, &reply);
|
||||||
|
// evaluate the reply
|
||||||
|
if (error == B_OK) {
|
||||||
|
if (reply.what == B_REG_SUCCESS)
|
||||||
|
error = find_message_app_info(&reply, info);
|
||||||
|
else
|
||||||
|
reply.FindInt32("error", &error);
|
||||||
|
}
|
||||||
|
return error;
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetActiveAppInfo
|
// GetActiveAppInfo
|
||||||
status_t
|
status_t
|
||||||
BRoster::GetActiveAppInfo(app_info *info) const
|
BRoster::GetActiveAppInfo(app_info *info) const
|
||||||
{
|
{
|
||||||
return NOT_IMPLEMENTED; // not implemented
|
status_t error = (info ? B_OK : B_BAD_VALUE);
|
||||||
|
// compose the request message
|
||||||
|
BMessage request(B_REG_GET_RUNNING_APP_INFO);
|
||||||
|
// send the request
|
||||||
|
BMessage reply;
|
||||||
|
if (error == B_OK)
|
||||||
|
error = fMess.SendMessage(&request, &reply);
|
||||||
|
// evaluate the reply
|
||||||
|
if (error == B_OK) {
|
||||||
|
if (reply.what == B_REG_SUCCESS)
|
||||||
|
error = find_message_app_info(&reply, info);
|
||||||
|
else
|
||||||
|
reply.FindInt32("error", &error);
|
||||||
|
}
|
||||||
|
return error;
|
||||||
}
|
}
|
||||||
|
|
||||||
// FindApp
|
// FindApp
|
||||||
@@ -331,12 +383,50 @@ BRoster::_StopWatching(mtarget target, BMessenger *rosterMess, uint32 what,
|
|||||||
}
|
}
|
||||||
|
|
||||||
// AddApplication
|
// AddApplication
|
||||||
uint32
|
status_t
|
||||||
BRoster::AddApplication(const char *mimeSig, entry_ref *ref, uint32 flags,
|
BRoster::AddApplication(const char *mimeSig, const entry_ref *ref,
|
||||||
team_id team, thread_id thread, port_id port,
|
uint32 flags, team_id team, thread_id thread,
|
||||||
bool fullReg) const
|
port_id port, bool fullReg, uint32 *_token,
|
||||||
|
team_id *otherTeam) const
|
||||||
{
|
{
|
||||||
return 0; // not implemented
|
status_t error = B_OK;
|
||||||
|
// compose the request message
|
||||||
|
BMessage request(B_REG_ADD_APP);
|
||||||
|
if (error == B_OK && mimeSig)
|
||||||
|
error = request.AddString("signature", mimeSig);
|
||||||
|
if (error == B_OK && ref)
|
||||||
|
error = request.AddRef("ref", ref);
|
||||||
|
if (error == B_OK)
|
||||||
|
error = request.AddInt32("flags", (int32)flags);
|
||||||
|
if (error == B_OK && team >= 0)
|
||||||
|
error = request.AddInt32("team", team);
|
||||||
|
if (error == B_OK && thread >= 0)
|
||||||
|
error = request.AddInt32("thread", thread);
|
||||||
|
if (error == B_OK && port >= 0)
|
||||||
|
error = request.AddInt32("port", port);
|
||||||
|
if (error == B_OK)
|
||||||
|
error = request.AddBool("full_registration", fullReg);
|
||||||
|
// send the request
|
||||||
|
BMessage reply;
|
||||||
|
if (error == B_OK)
|
||||||
|
error = fMess.SendMessage(&request, &reply);
|
||||||
|
// evaluate the reply
|
||||||
|
if (error == B_OK) {
|
||||||
|
if (reply.what == B_REG_SUCCESS) {
|
||||||
|
if (!fullReg && team < 0) {
|
||||||
|
uint32 token;
|
||||||
|
if (request.FindInt32("token", (int32)&token) == B_OK)
|
||||||
|
*_token = token;
|
||||||
|
else
|
||||||
|
error = B_ERROR;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
reply.FindInt32("error", &error);
|
||||||
|
if (otherTeam)
|
||||||
|
reply.FindInt32("other_team", otherTeam);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return error;
|
||||||
}
|
}
|
||||||
|
|
||||||
// SetSignature
|
// SetSignature
|
||||||
@@ -352,35 +442,119 @@ BRoster::SetThread(team_id team, thread_id thread) const
|
|||||||
}
|
}
|
||||||
|
|
||||||
// SetThreadAndTeam
|
// SetThreadAndTeam
|
||||||
void
|
status_t
|
||||||
BRoster::SetThreadAndTeam(uint32 entry_token, thread_id thread,
|
BRoster::SetThreadAndTeam(uint32 entryToken, thread_id thread,
|
||||||
team_id team) const
|
team_id team) const
|
||||||
{
|
{
|
||||||
|
status_t error = B_OK;
|
||||||
|
// compose the request message
|
||||||
|
BMessage request(B_REG_SET_THREAD_AND_TEAM);
|
||||||
|
if (error == B_OK)
|
||||||
|
error = request.AddInt32("token", (int32)entryToken);
|
||||||
|
if (error == B_OK && team >= 0)
|
||||||
|
error = request.AddInt32("team", team);
|
||||||
|
if (error == B_OK && thread >= 0)
|
||||||
|
error = request.AddInt32("thread", thread);
|
||||||
|
// send the request
|
||||||
|
BMessage reply;
|
||||||
|
if (error == B_OK)
|
||||||
|
error = fMess.SendMessage(&request, &reply);
|
||||||
|
// evaluate the reply
|
||||||
|
if (error == B_OK && reply.what != B_REG_SUCCESS)
|
||||||
|
reply.FindInt32("error", &error);
|
||||||
|
return error;
|
||||||
}
|
}
|
||||||
|
|
||||||
// CompleteRegistration
|
// CompleteRegistration
|
||||||
void
|
status_t
|
||||||
BRoster::CompleteRegistration(team_id team, thread_id, port_id port) const
|
BRoster::CompleteRegistration(team_id team, thread_id thread,
|
||||||
|
port_id port) const
|
||||||
{
|
{
|
||||||
|
status_t error = B_OK;
|
||||||
|
// compose the request message
|
||||||
|
BMessage request(B_REG_COMPLETE_REGISTRATION);
|
||||||
|
if (error == B_OK && team >= 0)
|
||||||
|
error = request.AddInt32("team", team);
|
||||||
|
if (error == B_OK && thread >= 0)
|
||||||
|
error = request.AddInt32("thread", thread);
|
||||||
|
if (error == B_OK && port >= 0)
|
||||||
|
error = request.AddInt32("port", port);
|
||||||
|
// send the request
|
||||||
|
BMessage reply;
|
||||||
|
if (error == B_OK)
|
||||||
|
error = fMess.SendMessage(&request, &reply);
|
||||||
|
// evaluate the reply
|
||||||
|
if (error == B_OK && reply.what != B_REG_SUCCESS)
|
||||||
|
reply.FindInt32("error", &error);
|
||||||
|
return error;
|
||||||
}
|
}
|
||||||
|
|
||||||
// IsAppPreRegistered
|
// IsAppPreRegistered
|
||||||
bool
|
bool
|
||||||
BRoster::IsAppPreRegistered(entry_ref *ref, team_id team, app_info *info) const
|
BRoster::IsAppPreRegistered(const entry_ref *ref, team_id team,
|
||||||
|
app_info *info) const
|
||||||
{
|
{
|
||||||
return false; // not implemented
|
status_t error = B_OK;
|
||||||
|
// compose the request message
|
||||||
|
BMessage request(B_REG_IS_PRE_REGISTERED);
|
||||||
|
if (error == B_OK && ref)
|
||||||
|
error = request.AddRef("ref", ref);
|
||||||
|
if (error == B_OK && team >= 0)
|
||||||
|
error = request.AddInt32("team", team);
|
||||||
|
// send the request
|
||||||
|
BMessage reply;
|
||||||
|
if (error == B_OK)
|
||||||
|
error = fMess.SendMessage(&request, &reply);
|
||||||
|
// evaluate the reply
|
||||||
|
bool isPreRegistered = false;
|
||||||
|
if (error == B_OK) {
|
||||||
|
if (reply.what == B_REG_SUCCESS) {
|
||||||
|
if (request.FindBool("pre-registered", isPreRegistered) != B_OK)
|
||||||
|
error = B_ERROR;
|
||||||
|
if (error == B_OK && isPreRegistered && info)
|
||||||
|
error = find_message_app_info(&reply, info);
|
||||||
|
} else
|
||||||
|
reply.FindInt32("error", &error);
|
||||||
|
}
|
||||||
|
return (error == B_OK && isPreRegistered);
|
||||||
}
|
}
|
||||||
|
|
||||||
// RemovePreRegApp
|
// RemovePreRegApp
|
||||||
void
|
status_t
|
||||||
BRoster::RemovePreRegApp(uint32 entryToken) const
|
BRoster::RemovePreRegApp(uint32 entryToken) const
|
||||||
{
|
{
|
||||||
|
status_t error = B_OK;
|
||||||
|
// compose the request message
|
||||||
|
BMessage request(B_REG_REMOVE_PRE_REGISTERED_APP);
|
||||||
|
if (error == B_OK)
|
||||||
|
error = request.AddInt32("token", (int32)entryToken);
|
||||||
|
// send the request
|
||||||
|
BMessage reply;
|
||||||
|
if (error == B_OK)
|
||||||
|
error = fMess.SendMessage(&request, &reply);
|
||||||
|
// evaluate the reply
|
||||||
|
if (error == B_OK && reply.what != B_REG_SUCCESS)
|
||||||
|
reply.FindInt32("error", &error);
|
||||||
|
return error;
|
||||||
}
|
}
|
||||||
|
|
||||||
// RemoveApp
|
// RemoveApp
|
||||||
void
|
status_t
|
||||||
BRoster::RemoveApp(team_id team) const
|
BRoster::RemoveApp(team_id team) const
|
||||||
{
|
{
|
||||||
|
status_t error = B_OK;
|
||||||
|
// compose the request message
|
||||||
|
BMessage request(B_REG_REMOVE_APP);
|
||||||
|
if (error == B_OK && team >= 0)
|
||||||
|
error = request.AddInt32("team", team);
|
||||||
|
// send the request
|
||||||
|
BMessage reply;
|
||||||
|
if (error == B_OK)
|
||||||
|
error = fMess.SendMessage(&request, &reply);
|
||||||
|
// evaluate the reply
|
||||||
|
if (error == B_OK && reply.what != B_REG_SUCCESS)
|
||||||
|
reply.FindInt32("error", &error);
|
||||||
|
return error;
|
||||||
}
|
}
|
||||||
|
|
||||||
// xLaunchAppPrivate
|
// xLaunchAppPrivate
|
||||||
|
|||||||
Reference in New Issue
Block a user