xref: /haiku/src/apps/cortex/InfoView/AppNodeInfoView.cpp (revision 99d1318ec02694fc520a0dc38ae38565db7e8c3c)
1 /*
2  * Copyright (c) 1999-2000, Eric Moon.
3  * All rights reserved.
4  *
5  * Redistribution and use in source and binary forms, with or without
6  * modification, are permitted provided that the following conditions
7  * are met:
8  *
9  * 1. Redistributions of source code must retain the above copyright
10  *    notice, this list of conditions, and the following disclaimer.
11  *
12  * 2. Redistributions in binary form must reproduce the above copyright
13  *    notice, this list of conditions, and the following disclaimer in the
14  *    documentation and/or other materials provided with the distribution.
15  *
16  * 3. The name of the author may not be used to endorse or promote products
17  *    derived from this software without specific prior written permission.
18  *
19  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR "AS IS" AND ANY EXPRESS OR
20  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
21  * OF TITLE, NON-INFRINGEMENT, MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
23  * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
24  * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
25  * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
26  * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
27  * TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
28  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29  */
30 
31 
32 // AppNodeInfoView.cpp
33 
34 #include "AppNodeInfoView.h"
35 // NodeManager
36 #include "NodeRef.h"
37 // Support
38 #include "MediaIcon.h"
39 #include "MediaString.h"
40 
41 // Application Kit
42 #include <Roster.h>
43 // Locale Kit
44 #undef B_CATALOG
45 #define B_CATALOG (&sCatalog)
46 #include <Catalog.h>
47 // Media Kit
48 #include <MediaNode.h>
49 #include <MediaRoster.h>
50 // Storage Kit
51 #include <AppFileInfo.h>
52 #include <Entry.h>
53 #include <File.h>
54 #include <Path.h>
55 
56 #undef B_TRANSLATION_CONTEXT
57 #define B_TRANSLATION_CONTEXT "AppNodeInfoView"
58 
59 __USE_CORTEX_NAMESPACE
60 
61 #include <Debug.h>
62 #define D_METHOD(x) //PRINT (x)
63 
64 static BCatalog sCatalog("x-vnd.Cortex.InfoView");
65 
66 // -------------------------------------------------------- //
67 // *** ctor/dtor (public)
68 // -------------------------------------------------------- //
69 
70 AppNodeInfoView::AppNodeInfoView(
71 	const NodeRef *ref)
72 	: LiveNodeInfoView(ref)
73 {
74 	D_METHOD(("AppNodeInfoView::AppNodeInfoView()\n"));
75 
76 	// adjust view properties
77 	setSideBarWidth(be_plain_font->StringWidth(B_TRANSLATE("File format"))
78 		+ 2 * InfoView::M_H_MARGIN);
79 	setSubTitle(B_TRANSLATE("Application-owned node"));
80 
81 	// add separator
82 	addField("", "");
83 
84 	port_info portInfo;
85 	app_info appInfo;
86 
87 	if ((get_port_info(ref->node().port, &portInfo) == B_OK)
88 	 && (be_roster->GetRunningAppInfo(portInfo.team, &appInfo) == B_OK))
89 	{
90 		BEntry appEntry(&appInfo.ref);
91 		char appName[B_FILE_NAME_LENGTH];
92 		if ((appEntry.InitCheck() == B_OK)
93 		 && (appEntry.GetName(appName) == B_OK))
94 		{
95 			addField(B_TRANSLATE("Application"), appName);
96 		}
97 		BFile appFile(&appInfo.ref, B_READ_ONLY);
98 		if (appFile.InitCheck() == B_OK)
99 		{
100 			BAppFileInfo appFileInfo(&appFile);
101 			if (appFileInfo.InitCheck() == B_OK)
102 			{
103 				version_info appVersion;
104 				if (appFileInfo.GetVersionInfo(&appVersion, B_APP_VERSION_KIND) == B_OK)
105 				{
106 					addField(B_TRANSLATE("Version"), appVersion.long_info);
107 				}
108 			}
109 		}
110 		addField(B_TRANSLATE("Signature"), appInfo.signature);
111 	}
112 }
113 
114 AppNodeInfoView::~AppNodeInfoView()
115 {
116 	D_METHOD(("AppNodeInfoView::~AppNodeInfoView()\n"));
117 }
118 
119 // END -- AppNodeInfoView.cpp --
120