Fix crash if key bindings specified in profile cannot be found. Improve
[personal-kdebase.git] / apps / kinfocenter / base / info_osx.cpp
blob337db83ae418c063be0f009b9d1d21ff708fc9e1
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.
23 * all following functions should return true, when the Information
24 * was filled into the lBox-Widget. Returning false indicates that
25 * information was not available.
28 #include <sys/types.h>
29 #include <sys/sysctl.h>
31 #include <fstab.h>
32 #include <stdio.h>
33 #include <stdlib.h>
35 #include <iostream.h>
37 #include <qdict.h>
38 #include <QFile>
39 #include <QFontMetrics>
41 #include <QTextStream>
43 #include <kdebug.h>
45 #include <mach/mach.h>
46 #include <mach-o/arch.h>
48 #ifdef HAVE_COREAUDIO
49 #include <CoreAudio/CoreAudio.h>
50 #endif
52 #include <machine/limits.h>
54 bool GetInfo_CPU(QListView *lBox) {
56 QString cpustring;
58 kern_return_t ret;
59 struct host_basic_info basic_info;
60 unsigned int count=HOST_BASIC_INFO_COUNT;
62 ret=host_info(mach_host_self(), HOST_BASIC_INFO, (host_info_t)&basic_info, &count);
63 if (ret != KERN_SUCCESS) {
64 kDebug() << "unable to get host information from mach";
65 return false;
66 } else {
67 kDebug() << "got Host Info: (" << basic_info.avail_cpus << ") CPUs available";
68 const NXArchInfo *archinfo;
69 archinfo=NXGetArchInfoFromCpuType(basic_info.cpu_type, basic_info.cpu_subtype);
70 new QListViewItem(lBox, i18n("Kernel is configured for %1 CPUs", basic_info.max_cpus));
71 for (int i = 1; i <= basic_info.avail_cpus; i++) {
72 cpustring = i18n("CPU %1: %2", i, archinfo->description);
73 new QListViewItem(lBox, cpustring);
75 return true;
77 return false;
80 bool GetInfo_IRQ(QListView *) {
81 return false;
84 bool GetInfo_DMA(QListView *) {
85 return false;
88 bool GetInfo_PCI(QTreeWidget*) {
89 return false;
92 bool GetInfo_IO_Ports(QListView *) {
93 return false;
96 bool GetInfo_Sound(QListView *lBox) {
97 #ifdef HAVE_COREAUDIO
98 #define qMaxStringSize 1024
99 OSStatus status;
100 AudioDeviceID gOutputDeviceID;
101 unsigned long propertySize;
102 char deviceName[qMaxStringSize];
103 char manufacturer[qMaxStringSize];
104 propertySize = sizeof(gOutputDeviceID);
105 status = AudioHardwareGetProperty(kAudioHardwarePropertyDefaultOutputDevice, &propertySize, &gOutputDeviceID);
106 if (status) {
107 kDebug() << "get default output device failed, status = " << (int)status;
108 return false;
111 if (gOutputDeviceID != kAudioDeviceUnknown) {
113 propertySize = qMaxStringSize;
115 /* Device Name */
116 status = AudioDeviceGetProperty(gOutputDeviceID, 1, 0, kAudioDevicePropertyDeviceName, &propertySize, deviceName);
117 if (status) {
118 kDebug() << "get device name failed, status = " << (int)status;
119 return false;
121 new QListViewItem(lBox, i18n("Device Name: %1", deviceName));
123 /* Manufacturer */
124 status = AudioDeviceGetProperty(gOutputDeviceID, 1, 0, kAudioDevicePropertyDeviceManufacturer, &propertySize, manufacturer);
125 if (status) {
126 kDebug() << "get manufacturer failed, status = " << (int)status;
127 return false;
129 new QListViewItem(lBox, i18n("Manufacturer: %1", manufacturer));
130 return true;
131 } else {
132 return false;
134 #else
135 return false;
136 #endif
139 bool GetInfo_SCSI(QListView *lbox) {
140 return false;
143 bool GetInfo_Partitions(QListView *lbox) {
144 return false;
147 bool GetInfo_XServer_and_Video(QListView *lBox) {
148 return GetInfo_XServer_Generic(lBox);
151 bool GetInfo_Devices(QListView *lbox) {
152 return false;