xref: /haiku/src/apps/cortex/InfoView/AppNodeInfoView.cpp (revision 1294543de9ac0eff000eaea1b18368c36435d08e)
1 // AppNodeInfoView.cpp
2 
3 #include "AppNodeInfoView.h"
4 // NodeManager
5 #include "NodeRef.h"
6 // Support
7 #include "MediaIcon.h"
8 #include "MediaString.h"
9 
10 // Application Kit
11 #include <Roster.h>
12 // Media Kit
13 #include <MediaNode.h>
14 #include <MediaRoster.h>
15 // Storage Kit
16 #include <AppFileInfo.h>
17 #include <Entry.h>
18 #include <File.h>
19 #include <Path.h>
20 
21 __USE_CORTEX_NAMESPACE
22 
23 #include <Debug.h>
24 #define D_METHOD(x) //PRINT (x)
25 
26 // -------------------------------------------------------- //
27 // *** ctor/dtor (public)
28 // -------------------------------------------------------- //
29 
30 AppNodeInfoView::AppNodeInfoView(
31 	const NodeRef *ref)
32 	: LiveNodeInfoView(ref)
33 {
34 	D_METHOD(("AppNodeInfoView::AppNodeInfoView()\n"));
35 
36 	// adjust view properties
37 	setSideBarWidth(be_plain_font->StringWidth(" File Format ") + 2 * InfoView::M_H_MARGIN);
38 	setSubTitle("Application-Owned Node");
39 
40 	// add separator
41 	addField("", "");
42 
43 	port_info portInfo;
44 	app_info appInfo;
45 
46 	if ((get_port_info(ref->node().port, &portInfo) == B_OK)
47 	 && (be_roster->GetRunningAppInfo(portInfo.team, &appInfo) == B_OK))
48 	{
49 		BEntry appEntry(&appInfo.ref);
50 		char appName[B_FILE_NAME_LENGTH];
51 		if ((appEntry.InitCheck() == B_OK)
52 		 && (appEntry.GetName(appName) == B_OK))
53 		{
54 			addField("Application", appName);
55 		}
56 		BFile appFile(&appInfo.ref, B_READ_ONLY);
57 		if (appFile.InitCheck() == B_OK)
58 		{
59 			BAppFileInfo appFileInfo(&appFile);
60 			if (appFileInfo.InitCheck() == B_OK)
61 			{
62 				version_info appVersion;
63 				if (appFileInfo.GetVersionInfo(&appVersion, B_APP_VERSION_KIND) == B_OK)
64 				{
65 					addField("Version", appVersion.long_info);
66 				}
67 			}
68 		}
69 		addField("Signature", appInfo.signature);
70 	}
71 }
72 
73 AppNodeInfoView::~AppNodeInfoView()
74 {
75 	D_METHOD(("AppNodeInfoView::~AppNodeInfoView()\n"));
76 }
77 
78 // END -- AppNodeInfoView.cpp --
79