xref: /haiku/src/servers/registrar/RosterAppInfo.cpp (revision 1214ef1b2100f2b3299fc9d8d6142e46f70a4c3f)
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 
14 using std::nothrow;
15 
16 
17 // constructor
18 RosterAppInfo::RosterAppInfo()
19 	: app_info(),
20 	state(APP_STATE_UNREGISTERED),
21 	token(0),
22 	registration_time(0)
23 {
24 }
25 
26 
27 // Init
28 void
29 RosterAppInfo::Init(thread_id thread, team_id team, port_id port, uint32 flags,
30 	const entry_ref *ref, const char *signature)
31 {
32 	this->thread = thread;
33 	this->team = team;
34 	this->port = port;
35 	this->flags = flags;
36 	this->ref = *ref;
37 	if (signature)
38 		strlcpy(this->signature, signature, B_MIME_TYPE_LENGTH);
39 	else
40 		this->signature[0] = '\0';
41 }
42 
43 
44 // Clone
45 RosterAppInfo *
46 RosterAppInfo::Clone() const
47 {
48 	RosterAppInfo *clone = new(nothrow) RosterAppInfo;
49 	if (!clone)
50 		return NULL;
51 
52 	clone->Init(thread, team, port, flags, &ref, signature);
53 	clone->registration_time = registration_time;
54 	return clone;
55 }
56 
57 
58 // IsRunning
59 bool
60 RosterAppInfo::IsRunning() const
61 {
62 	team_info teamInfo;
63 	return get_team_info(team, &teamInfo) == B_OK;
64 }
65 
66