xref: /haiku/src/servers/registrar/RosterAppInfo.cpp (revision df6cc9b5c923e79d19c96e84eaf755676691e4ed)
1 /*
2  * Copyright 2001-2007, Ingo Weinhold, bonefish@users.sf.net.
3  * Distributed under the terms of the MIT License.
4  */
5 
6 //!	An extended app_info.
7 
8 #include "RosterAppInfo.h"
9 
10 #include <new>
11 #include <string.h>
12 
13 #include <Entry.h>
14 #include <SupportDefs.h>
15 
16 
17 using std::nothrow;
18 
19 
20 // constructor
RosterAppInfo()21 RosterAppInfo::RosterAppInfo()
22 	: app_info(),
23 	state(APP_STATE_UNREGISTERED),
24 	token(0),
25 	registration_time(0)
26 {
27 }
28 
29 
30 // Init
31 void
Init(thread_id thread,team_id team,port_id port,uint32 flags,const entry_ref * ref,const char * signature)32 RosterAppInfo::Init(thread_id thread, team_id team, port_id port, uint32 flags,
33 	const entry_ref *ref, const char *signature)
34 {
35 	this->thread = thread;
36 	this->team = team;
37 	this->port = port;
38 	this->flags = flags;
39 	BEntry entry(ref, true);
40 	if (entry.GetRef(&this->ref) != B_OK)
41 		this->ref = *ref;
42 	if (signature)
43 		strlcpy(this->signature, signature, B_MIME_TYPE_LENGTH);
44 	else
45 		this->signature[0] = '\0';
46 }
47 
48 
49 // Clone
50 RosterAppInfo *
Clone() const51 RosterAppInfo::Clone() const
52 {
53 	RosterAppInfo *clone = new(nothrow) RosterAppInfo;
54 	if (!clone)
55 		return NULL;
56 
57 	clone->Init(thread, team, port, flags, &ref, signature);
58 	clone->registration_time = registration_time;
59 	return clone;
60 }
61 
62 
63 // IsRunning
64 bool
IsRunning() const65 RosterAppInfo::IsRunning() const
66 {
67 	team_info teamInfo;
68 	return get_team_info(team, &teamInfo) == B_OK;
69 }
70 
71