2 * Copyright (c) 2003 Benjamin Reed <ranger@befunk.com>
4 * info_osx.cpp is part of the KDE program kcminfo. Copied wholesale
5 * from info_fbsd.cpp =)
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2 of the License, or
10 * (at your option) any later version.
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
22 #define INFO_CPU_AVAILABLE
23 //#define INFO_IRQ_AVAILABLE
24 //#define INFO_DMA_AVAILABLE
25 //#define INFO_PCI_AVAILABLE
26 //#define INFO_IOPORTS_AVAILABLE
27 #define INFO_SOUND_AVAILABLE
28 #define INFO_DEVICES_AVAILABLE
29 #define INFO_SCSI_AVAILABLE
30 #define INFO_PARTITIONS_AVAILABLE
31 #define INFO_XSERVER_AVAILABLE
34 * all following functions should return true, when the Information
35 * was filled into the lBox-Widget. Returning false indicates that
36 * information was not available.
39 #include <sys/types.h>
40 #include <sys/sysctl.h>
50 #include <QFontMetrics>
53 #include <QTextStream>
57 #include <mach/mach.h>
58 #include <mach-o/arch.h>
61 #include <CoreAudio/CoreAudio.h>
64 #include <machine/limits.h>
66 bool GetInfo_CPU (QListView
*lBox
)
72 struct host_basic_info basic_info
;
73 unsigned int count
=HOST_BASIC_INFO_COUNT
;
75 ret
=host_info(mach_host_self(), HOST_BASIC_INFO
,
76 (host_info_t
)&basic_info
, &count
);
77 if (ret
!= KERN_SUCCESS
) {
78 kDebug() << "unable to get host information from mach";
81 kDebug() << "got Host Info: (" << basic_info
.avail_cpus
<< ") CPUs available";
82 const NXArchInfo
*archinfo
;
83 archinfo
=NXGetArchInfoFromCpuType(basic_info
.cpu_type
, basic_info
.cpu_subtype
);
84 new QListViewItem(lBox
, i18n("Kernel is configured for %1 CPUs", basic_info
.max_cpus
));
85 for (int i
= 1; i
<= basic_info
.avail_cpus
; i
++) {
86 cpustring
= i18n("CPU %1: %2", i
, archinfo
->description
);
87 new QListViewItem(lBox
, cpustring
);
94 bool GetInfo_IRQ (QListView
*)
99 bool GetInfo_DMA (QListView
*)
104 bool GetInfo_PCI (QListView
*)
109 bool GetInfo_IO_Ports (QListView
*)
114 bool GetInfo_Sound (QListView
*lBox
)
116 #ifdef HAVE_COREAUDIO
117 #define qMaxStringSize 1024
119 AudioDeviceID gOutputDeviceID
;
120 unsigned long propertySize
;
121 char deviceName
[qMaxStringSize
];
122 char manufacturer
[qMaxStringSize
];
123 propertySize
= sizeof(gOutputDeviceID
);
124 status
= AudioHardwareGetProperty(kAudioHardwarePropertyDefaultOutputDevice
, &propertySize
, &gOutputDeviceID
);
126 kDebug() << "get default output device failed, status = " << (int)status
;
130 if (gOutputDeviceID
!= kAudioDeviceUnknown
) {
132 propertySize
= qMaxStringSize
;
135 status
= AudioDeviceGetProperty(gOutputDeviceID
, 1, 0, kAudioDevicePropertyDeviceName
, &propertySize
, deviceName
);
137 kDebug() << "get device name failed, status = " << (int)status
;
140 new QListViewItem(lBox
, i18n("Device Name: %1", deviceName
));
143 status
= AudioDeviceGetProperty(gOutputDeviceID
, 1, 0, kAudioDevicePropertyDeviceManufacturer
, &propertySize
, manufacturer
);
145 kDebug() << "get manufacturer failed, status = " << (int)status
;
148 new QListViewItem(lBox
, i18n("Manufacturer: %1", manufacturer
));
158 bool GetInfo_SCSI (QListView
*lbox
)
163 bool GetInfo_Partitions (QListView
*lbox
)
168 bool GetInfo_XServer_and_Video (QListView
*lBox
)
170 return GetInfo_XServer_Generic( lBox
);
173 bool GetInfo_Devices (QListView
*lbox
)