|
|
1.1 root 1: //
2: // nono
3: // Copyright (C) 2020 nono project
4: // Licensed under nono-license.txt
5: //
6:
1.1.1.4 root 7: //
1.1 root 8: // バージョンダイアログ
1.1.1.4 root 9: //
1.1 root 10:
11: #include "wxversion.h"
1.1.1.11 root 12: #include "hostnet.h"
1.1.1.9 root 13: #include "monitor.h"
1.1.1.2 root 14: #include <sys/utsname.h>
15:
1.1.1.4 root 16: // グローバル参照用
17: HostInfoMonitor *gHostInfo;
1.1 root 18:
19: // コンストラクタ
20: WXVersionDlg::WXVersionDlg(wxWindow *parent)
21: : inherited(parent, wxID_ANY, _("About nono"))
22: {
23: wxBoxSizer *vbox = new wxBoxSizer(wxVERTICAL);
24:
25: wxString title = wxString::Format("nono %d.%d.%d (%s)",
26: NONO_MAJOR_VER, NONO_MINOR_VER, NONO_PATCH_VER, NONO_DATE);
27:
28: // タイトルだけ少し大きく
29: // XXX ..したいのだが wxOSX だと色々おかしいのでただのテキストにする。
30: auto titlectrl = new wxStaticText(this, wxID_ANY, title);
31: #if !defined(__WXOSX__)
32: titlectrl->SetLabelMarkup("<span size=\"x-large\">" + title + "</span>");
33: #endif
34: vbox->Add(titlectrl, 0, wxALIGN_CENTER);
35:
36: // 空行
37: vbox->Add(new wxStaticText(this, wxID_ANY, ""));
38:
39: // Copyright
40: vbox->Add(new wxStaticText(this, wxID_ANY,
1.1.1.12! root 41: "Copyright (C) 2020-2026 nono project"));
1.1 root 42:
43: // 空行
44: vbox->Add(new wxStaticText(this, wxID_ANY, ""));
45:
46: // OK
47: vbox->Add(CreateButtonSizer(wxOK), 0, wxALIGN_CENTER);
48:
49: // 周囲に 12px の余白をつける
50: wxBoxSizer *topsizer = new wxBoxSizer(wxVERTICAL);
51: topsizer->Add(vbox, 0, wxALL, 12);
52: SetSizer(topsizer);
53: topsizer->SetSizeHints(this);
54: }
55:
56: // デストラクタ
57: WXVersionDlg::~WXVersionDlg()
58: {
59: }
1.1.1.2 root 60:
61:
62: //
63: // ホスト情報モニタ
64: //
65:
66: // コンストラクタ
67: HostInfoMonitor::HostInfoMonitor()
1.1.1.5 root 68: : inherited(OBJ_HOSTINFO)
1.1.1.2 root 69: {
1.1.1.4 root 70: // ログは不要
71: ClearAlias();
72:
1.1.1.2 root 73: // この時点で必要な情報は全部集めておく
1.1.1.3 root 74: int width = 0;
1.1.1.11 root 75: int height = 4;
1.1.1.2 root 76:
77: // OS 名
78: const auto info = wxPlatformInfo::Get();
79: #if defined(__WXOSX__)
80: // "Apple Mac OS X 10.14" みたいに表示される
81: osname = info.GetOperatingSystemIdName();
82: osname += wxString::Format(" %d.%d",
83: info.GetOSMajorVersion(),
84: info.GetOSMinorVersion());
85: #else
86: // Linux ならディストリビューション
87: if (info.GetOperatingSystemId() == wxOS_UNIX_LINUX) {
88: auto distro = info.GetLinuxDistributionInfo();
89: osname = distro.Description;
90: }
91: // そうでなければ
92: if (osname.IsEmpty()) {
93: // GetOperatingSystemDescription() はほぼ uname -srm のようなので
94: // 前の2つだけにして uname -sr 相当で表示。
95: osname = info.GetOperatingSystemDescription();
96: auto pos = osname.rfind(' ');
97: if (pos != std::string::npos) {
98: osname = osname.substr(0, pos);
99: }
100: }
101: #endif
102: width = std::max(width, (int)osname.Length());
103:
104: // Machine (アーキテクチャと Endian を表示したい)
105: struct utsname ut;
106: if (uname(&ut) == 0) {
107: machinename = ut.machine;
108: machinename += " ";
109: }
110: // GetEndiannessName() は endian が小文字なので大文字にしたい
111: switch (info.GetEndianness()) {
112: case wxENDIAN_BIG:
113: machinename += "(Big Endian)";
114: break;
115: case wxENDIAN_LITTLE:
116: machinename += "(Little Endian)";
117: break;
118: case wxENDIAN_PDP:
119: machinename += "(PDP Endian)";
120: break;
121: default:
122: break;
123: }
124: width = std::max(width, (int)machinename.Length());
125:
1.1.1.7 root 126: // CPU Features
127: #if defined(__x86_64__)
1.1.1.8 root 128: height++;
1.1.1.7 root 129: # if defined(HAVE_AVX2)
130: if (gMainApp.detect_avx2) {
131: if (gMainApp.enable_avx2) {
132: avx2str = "enabled";
133: } else {
134: avx2str = "disabled";
135: }
136: } else {
137: avx2str = "not detected";
138: }
139: # else
140: avx2str = "not compiled";
141: # endif
142: #endif
1.1.1.8 root 143:
144: #if defined(__aarch64__)
145: height++;
146: # if defined(HAVE_NEON)
147: if (gMainApp.detect_neon) {
148: if (gMainApp.enable_neon) {
149: neonstr = "enabled";
150: } else {
151: neonstr = "disabled";
152: }
153: } else {
154: neonstr = "not detected";
155: }
156: # else
157: neonstr = "not compiled";
158: # endif
159: #endif
1.1.1.7 root 160: width = std::max(width, (int)avx2str.Length());
1.1.1.8 root 161: width = std::max(width, (int)neonstr.Length());
1.1.1.7 root 162:
1.1.1.2 root 163: // wxWidgets バージョン
164: wxname = wxVERSION_NUM_DOT_STRING_T;
165: // wxWidgets ポート名
166: // wxGTK なら wxGTK{2,3} の区別をしておきたい
1.1.1.3 root 167: auto wxport = info.GetPortIdName();
1.1.1.2 root 168: if (info.GetPortId() == wxPORT_GTK) {
169: wxport += wxString::Format("%d", info.GetToolkitMajorVersion());
170: }
171: wxname = wxname + " (" + wxport + ")";
172: width = std::max(width, (int)wxname.Length());
1.1.1.7 root 173:
1.1.1.11 root 174: // libslirp バージョン
175: slirpver = HostNetDevice::GetSlirpVersion();
176: if (slirpver == NULL) {
177: slirpver = "not compiled";
178: }
179: width = std::max(width, (int)strlen(slirpver));
180:
1.1.1.9 root 181: monitor = gMonitorManager->Regist(ID_MONITOR_WXHOSTINFO, this);
1.1.1.12! root 182: monitor->SetCallback(&HostInfoMonitor::MonitorScreen);
1.1.1.9 root 183: monitor->SetSize(11 + width, height);
1.1.1.2 root 184: }
185:
186: // デストラクタ
187: HostInfoMonitor::~HostInfoMonitor()
188: {
1.1.1.4 root 189: gHostInfo = NULL;
1.1.1.2 root 190: }
191:
192: // モニタを更新
193: void
1.1.1.12! root 194: HostInfoMonitor::MonitorScreen(Monitor *, TextScreen& screen)
1.1.1.2 root 195: {
196: int x = 11;
197: int y;
198:
1.1.1.3 root 199: screen.Clear();
1.1.1.2 root 200: y = 0;
201:
1.1.1.3 root 202: screen.Puts(0, y, "OS:");
203: screen.Puts(x, y, (const char *)osname.mb_str());
1.1.1.2 root 204: y++;
205:
1.1.1.3 root 206: screen.Puts(0, y, "Machine:");
207: screen.Puts(x, y, (const char *)machinename.mb_str());
1.1.1.2 root 208: y++;
209:
1.1.1.7 root 210: #if defined(__x86_64__)
211: screen.Puts(0, y, "AVX2:");
212: screen.Puts(x, y, (const char *)avx2str.mb_str());
213: y++;
214: #endif
1.1.1.8 root 215: #if defined(__aarch64__)
216: screen.Puts(0, y, "NEON:");
217: screen.Puts(x, y, (const char *)neonstr.mb_str());
218: y++;
219: #endif
1.1.1.7 root 220:
1.1.1.3 root 221: screen.Puts(0, y, "wxWidgets:");
222: screen.Puts(x, y, (const char *)wxname.mb_str());
1.1.1.2 root 223: y++;
1.1.1.11 root 224:
225: screen.Puts(0, y, "libslirp:");
226: screen.Puts(x, y, slirpver);
227: y++;
1.1.1.2 root 228: }
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.