summaryrefslogtreecommitdiff
authorkergoth <kergoth>2002-09-05 18:56:37 (UTC)
committer kergoth <kergoth>2002-09-05 18:56:37 (UTC)
commit3b604a204719a4b45360a9d8685d4bb51a32b9dd (patch) (unidiff)
treebb47316b888c038a0c07373df93e8b2cc853777a
parent45c33b69ae0eec4868a312dc7eb9f496e10588bd (diff)
downloadopie-3b604a204719a4b45360a9d8685d4bb51a32b9dd.zip
opie-3b604a204719a4b45360a9d8685d4bb51a32b9dd.tar.gz
opie-3b604a204719a4b45360a9d8685d4bb51a32b9dd.tar.bz2
Use SIG_IGN rather than an empty handler to ignore SIG_TSTP.
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--libopie/odevice.cpp8
-rw-r--r--libopie/odevice.h2
2 files changed, 1 insertions, 9 deletions
diff --git a/libopie/odevice.cpp b/libopie/odevice.cpp
index 6572fb6..1da8862 100644
--- a/libopie/odevice.cpp
+++ b/libopie/odevice.cpp
@@ -86,115 +86,109 @@ protected:
86 86
87 87
88 88
89ODevice *ODevice::inst ( ) 89ODevice *ODevice::inst ( )
90{ 90{
91 static ODevice *dev = 0; 91 static ODevice *dev = 0;
92 92
93 if ( !dev ) { 93 if ( !dev ) {
94 if ( QFile::exists ( "/proc/hal/model" )) 94 if ( QFile::exists ( "/proc/hal/model" ))
95 dev = new ODeviceIPAQ ( ); 95 dev = new ODeviceIPAQ ( );
96 else if ( QFile::exists ( "/dev/sharp_buz" ) || QFile::exists ( "/dev/sharp_led" )) 96 else if ( QFile::exists ( "/dev/sharp_buz" ) || QFile::exists ( "/dev/sharp_led" ))
97 dev = new ODeviceZaurus ( ); 97 dev = new ODeviceZaurus ( );
98 else 98 else
99 dev = new ODevice ( ); 99 dev = new ODevice ( );
100 100
101 dev-> init ( ); 101 dev-> init ( );
102 } 102 }
103 return dev; 103 return dev;
104} 104}
105 105
106ODevice::ODevice ( ) 106ODevice::ODevice ( )
107{ 107{
108 d = new ODeviceData; 108 d = new ODeviceData;
109 109
110 d-> m_modelstr = "Unknown"; 110 d-> m_modelstr = "Unknown";
111 d-> m_model = OMODEL_Unknown; 111 d-> m_model = OMODEL_Unknown;
112 d-> m_vendorstr = "Unkown"; 112 d-> m_vendorstr = "Unkown";
113 d-> m_vendor = OVENDOR_Unknown; 113 d-> m_vendor = OVENDOR_Unknown;
114 d-> m_systemstr = "Unkown"; 114 d-> m_systemstr = "Unkown";
115 d-> m_system = OSYSTEM_Unknown; 115 d-> m_system = OSYSTEM_Unknown;
116 d-> m_sysverstr = "0.0"; 116 d-> m_sysverstr = "0.0";
117} 117}
118 118
119void ODevice::init ( ) 119void ODevice::init ( )
120{ 120{
121} 121}
122 122
123ODevice::~ODevice ( ) 123ODevice::~ODevice ( )
124{ 124{
125 delete d; 125 delete d;
126} 126}
127 127
128//#include <linux/apm_bios.h> 128//#include <linux/apm_bios.h>
129 129
130//#define APM_IOC_SUSPEND _IO('A',2) 130//#define APM_IOC_SUSPEND _IO('A',2)
131 131
132#define APM_IOC_SUSPEND (( 0<<30 ) | ( 'A'<<8 ) | ( 2 ) | ( 0<<16 )) 132#define APM_IOC_SUSPEND (( 0<<30 ) | ( 'A'<<8 ) | ( 2 ) | ( 0<<16 ))
133 133
134
135void ODevice::tstp_sighandler ( int )
136{
137}
138
139
140bool ODevice::suspend ( ) 134bool ODevice::suspend ( )
141{ 135{
142 if ( d-> m_model == OMODEL_Unknown ) // better don't suspend in qvfb / on unkown devices 136 if ( d-> m_model == OMODEL_Unknown ) // better don't suspend in qvfb / on unkown devices
143 return false; 137 return false;
144 138
145 int fd; 139 int fd;
146 bool res = false; 140 bool res = false;
147 141
148 if ((( fd = ::open ( "/dev/apm_bios", O_RDWR )) >= 0 ) || 142 if ((( fd = ::open ( "/dev/apm_bios", O_RDWR )) >= 0 ) ||
149 (( fd = ::open ( "/dev/misc/apm_bios",O_RDWR )) >= 0 )) { 143 (( fd = ::open ( "/dev/misc/apm_bios",O_RDWR )) >= 0 )) {
150 struct timeval tvs, tvn; 144 struct timeval tvs, tvn;
151 145
152 ::signal ( SIGTSTP, tstp_sighandler );// we don't want to be stopped 146 ::signal ( SIGTSTP, SIG_IGN );// we don't want to be stopped
153 ::gettimeofday ( &tvs, 0 ); 147 ::gettimeofday ( &tvs, 0 );
154 148
155 res = ( ::ioctl ( fd, APM_IOC_SUSPEND ) == 0 ); // tell the kernel to "start" suspending 149 res = ( ::ioctl ( fd, APM_IOC_SUSPEND ) == 0 ); // tell the kernel to "start" suspending
156 ::close ( fd ); 150 ::close ( fd );
157 151
158 if ( res ) { 152 if ( res ) {
159 ::kill ( -::getpid ( ), SIGTSTP ); // stop everthing in out process group 153 ::kill ( -::getpid ( ), SIGTSTP ); // stop everthing in out process group
160 154
161 do { // wait at most 1.5 sec: either suspend didn't work or the device resumed 155 do { // wait at most 1.5 sec: either suspend didn't work or the device resumed
162 ::usleep ( 200 * 1000 ); 156 ::usleep ( 200 * 1000 );
163 ::gettimeofday ( &tvn, 0 ); 157 ::gettimeofday ( &tvn, 0 );
164 } while ((( tvn. tv_sec - tvs. tv_sec ) * 1000 + ( tvn. tv_usec - tvs. tv_usec ) / 1000 ) < 1500 ); 158 } while ((( tvn. tv_sec - tvs. tv_sec ) * 1000 + ( tvn. tv_usec - tvs. tv_usec ) / 1000 ) < 1500 );
165 159
166 ::kill ( -::getpid ( ), SIGCONT ); // continue everything in our process group 160 ::kill ( -::getpid ( ), SIGCONT ); // continue everything in our process group
167 } 161 }
168 162
169 ::signal ( SIGTSTP, SIG_DFL ); 163 ::signal ( SIGTSTP, SIG_DFL );
170 } 164 }
171 165
172 return res; 166 return res;
173} 167}
174 168
175 169
176QString ODevice::vendorString ( ) 170QString ODevice::vendorString ( )
177{ 171{
178 return d-> m_vendorstr; 172 return d-> m_vendorstr;
179} 173}
180 174
181OVendor ODevice::vendor ( ) 175OVendor ODevice::vendor ( )
182{ 176{
183 return d-> m_vendor; 177 return d-> m_vendor;
184} 178}
185 179
186QString ODevice::modelString ( ) 180QString ODevice::modelString ( )
187{ 181{
188 return d-> m_modelstr; 182 return d-> m_modelstr;
189} 183}
190 184
191OModel ODevice::model ( ) 185OModel ODevice::model ( )
192{ 186{
193 return d-> m_model; 187 return d-> m_model;
194} 188}
195 189
196QString ODevice::systemString ( ) 190QString ODevice::systemString ( )
197{ 191{
198 return d-> m_systemstr; 192 return d-> m_systemstr;
199} 193}
200 194
diff --git a/libopie/odevice.h b/libopie/odevice.h
index cda504a..5009b91 100644
--- a/libopie/odevice.h
+++ b/libopie/odevice.h
@@ -57,55 +57,53 @@ enum OLedState {
57 OLED_BlinkSlow, 57 OLED_BlinkSlow,
58 OLED_BlinkFast 58 OLED_BlinkFast
59}; 59};
60 60
61 61
62class ODevice 62class ODevice
63{ 63{
64public: 64public:
65 65
66public: 66public:
67 static ODevice *inst ( ); 67 static ODevice *inst ( );
68 68
69 // system 69 // system
70 virtual bool suspend ( ); 70 virtual bool suspend ( );
71 71
72// information 72// information
73 73
74 QString modelString ( ); 74 QString modelString ( );
75 OModel model ( ); 75 OModel model ( );
76 76
77 QString vendorString ( ); 77 QString vendorString ( );
78 OVendor vendor ( ); 78 OVendor vendor ( );
79 79
80 QString systemString ( ); 80 QString systemString ( );
81 OSystem system ( ); 81 OSystem system ( );
82 82
83 QString systemVersionString ( ); 83 QString systemVersionString ( );
84 84
85// input / output 85// input / output
86 86
87 virtual void alarmSound ( ); 87 virtual void alarmSound ( );
88 virtual void keySound ( ); 88 virtual void keySound ( );
89 virtual void touchSound ( ); 89 virtual void touchSound ( );
90 90
91 virtual uint hasLeds ( ) const; 91 virtual uint hasLeds ( ) const;
92 virtual OLedState led ( uint which ) const; 92 virtual OLedState led ( uint which ) const;
93 virtual bool setLed ( uint which, OLedState st ); 93 virtual bool setLed ( uint which, OLedState st );
94 94
95 virtual ~ODevice ( ); 95 virtual ~ODevice ( );
96 96
97protected: 97protected:
98 ODevice ( ); 98 ODevice ( );
99 virtual void init ( ); 99 virtual void init ( );
100 100
101 ODeviceData *d; 101 ODeviceData *d;
102 102
103private: 103private:
104 ODevice ( const ODevice & ); 104 ODevice ( const ODevice & );
105
106 static void tstp_sighandler ( int );
107}; 105};
108 106
109#endif 107#endif
110 108
111 109