~ubuntu-branches/ubuntu/warty/kdebase/warty

« back to all changes in this revision

Viewing changes to kcontrol/info/info_osx.cpp

  • Committer: Bazaar Package Importer
  • Author(s): LaMont Jones
  • Date: 2004-09-16 04:51:45 UTC
  • Revision ID: james.westby@ubuntu.com-20040916045145-9vr63kith3k1cpza
Tags: upstream-3.2.2
ImportĀ upstreamĀ versionĀ 3.2.2

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 *  $Id: info_osx.cpp,v 1.2 2003/06/29 20:16:54 reed Exp $
 
3
 *
 
4
 *  Copyright (c) 2003 Benjamin Reed <ranger@befunk.com>
 
5
 *
 
6
 *  info_osx.cpp is part of the KDE program kcminfo.  Copied wholesale
 
7
 *  from info_fbsd.cpp =)
 
8
 *
 
9
 *  This program is free software; you can redistribute it and/or modify
 
10
 *  it under the terms of the GNU General Public License as published by
 
11
 *  the Free Software Foundation; either version 2 of the License, or
 
12
 *  (at your option) any later version.
 
13
 *
 
14
 *  This program is distributed in the hope that it will be useful,
 
15
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 
16
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
17
 *  GNU General Public License for more details.
 
18
 *
 
19
 *  You should have received a copy of the GNU General Public License
 
20
 *  along with this program; if not, write to the Free Software
 
21
 *  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
 
22
 */
 
23
 
 
24
#define INFO_CPU_AVAILABLE
 
25
//#define INFO_IRQ_AVAILABLE
 
26
//#define INFO_DMA_AVAILABLE
 
27
//#define INFO_PCI_AVAILABLE
 
28
//#define INFO_IOPORTS_AVAILABLE
 
29
#define INFO_SOUND_AVAILABLE
 
30
#define INFO_DEVICES_AVAILABLE
 
31
#define INFO_SCSI_AVAILABLE
 
32
#define INFO_PARTITIONS_AVAILABLE
 
33
#define INFO_XSERVER_AVAILABLE
 
34
 
 
35
/*
 
36
 * all following functions should return TRUE, when the Information
 
37
 * was filled into the lBox-Widget. Returning FALSE indicates that
 
38
 * information was not available.
 
39
 */
 
40
 
 
41
#include <sys/types.h>
 
42
#include <sys/sysctl.h>
 
43
 
 
44
#include <fstab.h>
 
45
#include <stdio.h>
 
46
#include <stdlib.h>
 
47
 
 
48
#include <iostream.h>
 
49
 
 
50
#include <qdict.h>
 
51
#include <qfile.h>
 
52
#include <qfontmetrics.h>
 
53
#include <qptrlist.h>
 
54
#include <qstring.h>
 
55
#include <qtextstream.h>
 
56
 
 
57
#include <kdebug.h>
 
58
 
 
59
#include <mach/mach.h>
 
60
#include <mach-o/arch.h>
 
61
 
 
62
#ifdef HAVE_COREAUDIO
 
63
#include <CoreAudio/CoreAudio.h>
 
64
#endif
 
65
 
 
66
#include <machine/limits.h>
 
67
 
 
68
bool GetInfo_CPU (QListView *lBox)
 
69
{
 
70
 
 
71
        QString cpustring;
 
72
 
 
73
        kern_return_t ret;
 
74
        struct host_basic_info basic_info;
 
75
        unsigned int count=HOST_BASIC_INFO_COUNT;
 
76
 
 
77
        ret=host_info(mach_host_self(), HOST_BASIC_INFO, 
 
78
                (host_info_t)&basic_info, &count);
 
79
        if (ret != KERN_SUCCESS) {
 
80
                kdDebug() << "unable to get host information from mach" << endl;
 
81
                return false;
 
82
        } else {
 
83
                kdDebug() << "got Host Info: (" << basic_info.avail_cpus << ") CPUs available" << endl;
 
84
                const NXArchInfo *archinfo;
 
85
                archinfo=NXGetArchInfoFromCpuType(basic_info.cpu_type, basic_info.cpu_subtype);
 
86
                new QListViewItem(lBox, i18n("Kernel is configured for %1 CPUs").arg(basic_info.max_cpus));
 
87
                for (int i = 1; i <= basic_info.avail_cpus; i++) {
 
88
                        cpustring = i18n("CPU %1: %2").arg(i).arg(archinfo->description);
 
89
                        new QListViewItem(lBox, cpustring);
 
90
                }
 
91
                return true;
 
92
        }
 
93
        return false;
 
94
}
 
95
 
 
96
bool GetInfo_IRQ (QListView *)
 
97
{
 
98
        return false;
 
99
}
 
100
 
 
101
bool GetInfo_DMA (QListView *)
 
102
{
 
103
        return false;
 
104
}
 
105
 
 
106
bool GetInfo_PCI (QListView *)
 
107
{
 
108
        return false;
 
109
}
 
110
 
 
111
bool GetInfo_IO_Ports (QListView *)
 
112
{
 
113
        return false;
 
114
}
 
115
 
 
116
bool GetInfo_Sound (QListView *lBox)
 
117
{
 
118
#ifdef HAVE_COREAUDIO
 
119
#define kMaxStringSize 1024
 
120
        OSStatus status;
 
121
        AudioDeviceID gOutputDeviceID;
 
122
        unsigned long propertySize;
 
123
        char deviceName[kMaxStringSize];
 
124
        char manufacturer[kMaxStringSize];
 
125
        propertySize = sizeof(gOutputDeviceID);
 
126
        status = AudioHardwareGetProperty(kAudioHardwarePropertyDefaultOutputDevice, &propertySize, &gOutputDeviceID);
 
127
        if (status) {
 
128
                kdDebug() << "get default output device failed, status = " << (int)status << endl;
 
129
                return false;
 
130
        }
 
131
 
 
132
        if (gOutputDeviceID != kAudioDeviceUnknown) {
 
133
 
 
134
                propertySize = kMaxStringSize;
 
135
 
 
136
                /* Device Name */
 
137
                status = AudioDeviceGetProperty(gOutputDeviceID, 1, 0, kAudioDevicePropertyDeviceName, &propertySize, deviceName);
 
138
                if (status) {
 
139
                        kdDebug() << "get device name failed, status = " << (int)status << endl;
 
140
                        return false;
 
141
                }
 
142
                new QListViewItem(lBox, i18n("Device Name: %1").arg(deviceName));
 
143
 
 
144
                /* Manufacturer */
 
145
                status = AudioDeviceGetProperty(gOutputDeviceID, 1, 0, kAudioDevicePropertyDeviceManufacturer, &propertySize, manufacturer);
 
146
                if (status) {
 
147
                        kdDebug() << "get manufacturer failed, status = " << (int)status << endl;
 
148
                        return false;
 
149
                }
 
150
                new QListViewItem(lBox, i18n("Manufacturer: %1").arg(manufacturer));
 
151
                return true;
 
152
        } else {
 
153
                return false;
 
154
        }
 
155
#else
 
156
        return false;
 
157
#endif
 
158
}
 
159
 
 
160
bool GetInfo_SCSI (QListView *lbox)
 
161
{
 
162
        return false;
 
163
}
 
164
 
 
165
bool GetInfo_Partitions (QListView *lbox)
 
166
{
 
167
        return false;
 
168
}
 
169
 
 
170
bool GetInfo_XServer_and_Video (QListView *lBox)
 
171
{
 
172
        return GetInfo_XServer_Generic( lBox );
 
173
}
 
174
 
 
175
bool GetInfo_Devices (QListView *lbox)
 
176
{
 
177
        return false;
 
178
}