~ubuntu-branches/ubuntu/gutsy/kdebase-workspace/gutsy-backports

« back to all changes in this revision

Viewing changes to kcontrol/infocenter/info/info_svr4.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Jonathan Riddell
  • Date: 2007-09-05 20:45:14 UTC
  • Revision ID: james.westby@ubuntu.com-20070905204514-632hhspl0nvrc84i
Tags: upstream-3.93.0
ImportĀ upstreamĀ versionĀ 3.93.0

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*      
 
2
    info_svr4.cpp
 
3
 
 
4
    UNIX System V Release 4 specific Information about the Hardware.
 
5
    Appropriate for SCO OpenServer and UnixWare.
 
6
    Written 20-Feb-99 by Ronald Joe Record (rr@sco.com)
 
7
    Initially based on info_sgi.cpp
 
8
*/
 
9
 
 
10
#define INFO_CPU_AVAILABLE
 
11
#define INFO_IRQ_AVAILABLE
 
12
#define INFO_DMA_AVAILABLE
 
13
#define INFO_PCI_AVAILABLE
 
14
#define INFO_IOPORTS_AVAILABLE
 
15
#define INFO_SOUND_AVAILABLE
 
16
#define INFO_DEVICES_AVAILABLE
 
17
#define INFO_SCSI_AVAILABLE
 
18
#define INFO_PARTITIONS_AVAILABLE
 
19
#define INFO_XSERVER_AVAILABLE
 
20
 
 
21
#define INFO_DEV_SNDSTAT "/dev/sndstat"
 
22
 
 
23
#include <sys/systeminfo.h>
 
24
 
 
25
/*  all following functions should return true, when the Information 
 
26
    was filled into the lBox-Widget.
 
27
    returning false indicates, that information was not available.
 
28
*/
 
29
 
 
30
bool GetInfo_ReadfromFile( QListView *lBox, char *Name, char splitchar  )
 
31
{
 
32
  QString str;
 
33
  char buf[512];
 
34
 
 
35
  QFile *file = new QFile(Name);
 
36
  QListViewItem* olditem = 0;
 
37
 
 
38
  if(!file->open(QIODevice::ReadOnly)) {
 
39
    delete file; 
 
40
    return false;
 
41
  }
 
42
  
 
43
  while (file->readLine(buf,sizeof(buf)-1) > 0) {
 
44
      if (strlen(buf)) {
 
45
          char *p=buf;
 
46
          if (splitchar!=0)    /* remove leading spaces between ':' and the following text */
 
47
              while (*p) {
 
48
                  if (*p==splitchar) {
 
49
                      *p++ = ' ';
 
50
                      while (*p==' ') ++p;
 
51
                      *(--p) = splitchar;
 
52
                      ++p;
 
53
                  }
 
54
                  else ++p;
 
55
              }
 
56
          
 
57
          QString s1 = QString::fromLocal8Bit(buf);
 
58
          QString s2 = s1.mid(s1.find(splitchar)+1);
 
59
          
 
60
          s1.truncate(s1.find(splitchar));
 
61
          if(!(s1.isEmpty() || s2.isEmpty()))
 
62
              olditem = new QListViewItem(lBox, olditem, s1, s2);
 
63
      }
 
64
  }
 
65
  file->close();
 
66
  
 
67
  delete file;
 
68
  return true;
 
69
}
 
70
 
 
71
bool GetInfo_CPU( QListView *lBox )
 
72
{
 
73
      char buf[256];
 
74
 
 
75
      sysinfo(SI_ARCHITECTURE, buf, sizeof(buf));
 
76
      new QListViewItem(lBox, QString::fromLocal8Bit(buf));
 
77
      return true;
 
78
}
 
79
 
 
80
 
 
81
bool GetInfo_IRQ( QListView * )
 
82
{
 
83
        return false;
 
84
}
 
85
 
 
86
bool GetInfo_DMA( QListView * )
 
87
{
 
88
        return false;
 
89
}
 
90
 
 
91
bool GetInfo_PCI( QListView *lBox )
 
92
{
 
93
      char buf[256];
 
94
 
 
95
      sysinfo(SI_BUSTYPES, buf, sizeof(buf));
 
96
      new QListViewItem(lBox, QString::fromLocal8Bit(buf));
 
97
      return true;
 
98
}
 
99
 
 
100
bool GetInfo_IO_Ports( QListView * )
 
101
{
 
102
        return false;
 
103
}
 
104
 
 
105
bool GetInfo_Sound( QListView *lBox )
 
106
{
 
107
  if ( GetInfo_ReadfromFile( lBox, INFO_DEV_SNDSTAT, 0 ))
 
108
    return true;
 
109
  else
 
110
    return false;
 
111
}
 
112
 
 
113
bool GetInfo_Devices( QListView * )
 
114
{
 
115
    return false;
 
116
}
 
117
 
 
118
bool GetInfo_SCSI( QListView * )
 
119
{
 
120
    return false;
 
121
}
 
122
 
 
123
bool GetInfo_Partitions( QListView * )
 
124
{
 
125
        return false;
 
126
}
 
127
 
 
128
bool GetInfo_XServer_and_Video( QListView *lBox )
 
129
{
 
130
        return GetInfo_XServer_Generic( lBox );
 
131
}
 
132