Make a branch to make krunner Good Enough For Aaron™.
[kdebase/uwolfer.git] / apps / kinfocenter / info / info_osx.cpp
blob0d3d6e288501c7d7d0cfc1e17b224ac6ae530460
1 /*
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>
42 #include <fstab.h>
43 #include <stdio.h>
44 #include <stdlib.h>
46 #include <iostream.h>
48 #include <qdict.h>
49 #include <QFile>
50 #include <QFontMetrics>
51 #include <Q3PtrList>
53 #include <QTextStream>
55 #include <kdebug.h>
57 #include <mach/mach.h>
58 #include <mach-o/arch.h>
60 #ifdef HAVE_COREAUDIO
61 #include <CoreAudio/CoreAudio.h>
62 #endif
64 #include <machine/limits.h>
66 bool GetInfo_CPU (QListView *lBox)
69 QString cpustring;
71 kern_return_t ret;
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";
79 return false;
80 } else {
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);
89 return true;
91 return false;
94 bool GetInfo_IRQ (QListView *)
96 return false;
99 bool GetInfo_DMA (QListView *)
101 return false;
104 bool GetInfo_PCI (QListView *)
106 return false;
109 bool GetInfo_IO_Ports (QListView *)
111 return false;
114 bool GetInfo_Sound (QListView *lBox)
116 #ifdef HAVE_COREAUDIO
117 #define qMaxStringSize 1024
118 OSStatus status;
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);
125 if (status) {
126 kDebug() << "get default output device failed, status = " << (int)status;
127 return false;
130 if (gOutputDeviceID != kAudioDeviceUnknown) {
132 propertySize = qMaxStringSize;
134 /* Device Name */
135 status = AudioDeviceGetProperty(gOutputDeviceID, 1, 0, kAudioDevicePropertyDeviceName, &propertySize, deviceName);
136 if (status) {
137 kDebug() << "get device name failed, status = " << (int)status;
138 return false;
140 new QListViewItem(lBox, i18n("Device Name: %1", deviceName));
142 /* Manufacturer */
143 status = AudioDeviceGetProperty(gOutputDeviceID, 1, 0, kAudioDevicePropertyDeviceManufacturer, &propertySize, manufacturer);
144 if (status) {
145 kDebug() << "get manufacturer failed, status = " << (int)status;
146 return false;
148 new QListViewItem(lBox, i18n("Manufacturer: %1", manufacturer));
149 return true;
150 } else {
151 return false;
153 #else
154 return false;
155 #endif
158 bool GetInfo_SCSI (QListView *lbox)
160 return false;
163 bool GetInfo_Partitions (QListView *lbox)
165 return false;
168 bool GetInfo_XServer_and_Video (QListView *lBox)
170 return GetInfo_XServer_Generic( lBox );
173 bool GetInfo_Devices (QListView *lbox)
175 return false;