-rw-r--r-- | core/applets/vmemo/vmemo.cpp | 10 | ||||
-rw-r--r-- | core/applets/vtapplet/vt.cpp | 8 | ||||
-rw-r--r-- | libopie/odevice.cpp | 4 | ||||
-rw-r--r-- | libopie2/opiemm/osoundsystem.cpp | 5 | ||||
-rw-r--r-- | library/qpeapplication.cpp | 16 |
5 files changed, 40 insertions, 3 deletions
diff --git a/core/applets/vmemo/vmemo.cpp b/core/applets/vmemo/vmemo.cpp index e747a19..07ef15c 100644 --- a/core/applets/vmemo/vmemo.cpp +++ b/core/applets/vmemo/vmemo.cpp | |||
@@ -158,508 +158,512 @@ static char * vmemo_xpm[] = { | |||
158 | "N c #8F8F98", | 158 | "N c #8F8F98", |
159 | "O c #000407", | 159 | "O c #000407", |
160 | "P c #2D3137", | 160 | "P c #2D3137", |
161 | "Q c #B0B1BC", | 161 | "Q c #B0B1BC", |
162 | "R c #3B3C40", | 162 | "R c #3B3C40", |
163 | "S c #6E6E74", | 163 | "S c #6E6E74", |
164 | "T c #95959C", | 164 | "T c #95959C", |
165 | "U c #74747A", | 165 | "U c #74747A", |
166 | "V c #1D1D1E", | 166 | "V c #1D1D1E", |
167 | "W c #91929A", | 167 | "W c #91929A", |
168 | "X c #42444A", | 168 | "X c #42444A", |
169 | "Y c #22282E", | 169 | "Y c #22282E", |
170 | "Z c #B0B2BC", | 170 | "Z c #B0B2BC", |
171 | "` c #898A90", | 171 | "` c #898A90", |
172 | " . c #65656A", | 172 | " . c #65656A", |
173 | ".. c #999AA2", | 173 | ".. c #999AA2", |
174 | "+. c #52535A", | 174 | "+. c #52535A", |
175 | "@. c #151B21", | 175 | "@. c #151B21", |
176 | "#. c #515257", | 176 | "#. c #515257", |
177 | "$. c #B5B5BE", | 177 | "$. c #B5B5BE", |
178 | "%. c #616167", | 178 | "%. c #616167", |
179 | "&. c #1A1D22", | 179 | "&. c #1A1D22", |
180 | "*. c #000713", | 180 | "*. c #000713", |
181 | "=. c #1F1F21", | 181 | "=. c #1F1F21", |
182 | " ", | 182 | " ", |
183 | " . + @ # ", | 183 | " . + @ # ", |
184 | " $ % & * = - ", | 184 | " $ % & * = - ", |
185 | " ; > , ' ) ! ~ ", | 185 | " ; > , ' ) ! ~ ", |
186 | " { ] ^ / ( _ : ", | 186 | " { ] ^ / ( _ : ", |
187 | " < [ } | 1 2 3 ", | 187 | " < [ } | 1 2 3 ", |
188 | " 4 5 6 7 8 9 0 a b c ", | 188 | " 4 5 6 7 8 9 0 a b c ", |
189 | " d e f g h i j 3 k l m n ", | 189 | " d e f g h i j 3 k l m n ", |
190 | " o p q r s t u v w n ", | 190 | " o p q r s t u v w n ", |
191 | " o x y z A B C D E n ", | 191 | " o x y z A B C D E n ", |
192 | " F G H I J K L M N O ", | 192 | " F G H I J K L M N O ", |
193 | " P Q R S T U V W X ", | 193 | " P Q R S T U V W X ", |
194 | " Y Z ` b ...+. ", | 194 | " Y Z ` b ...+. ", |
195 | " @.#.$.%.&. ", | 195 | " @.#.$.%.&. ", |
196 | " *.B =. ", | 196 | " *.B =. ", |
197 | " n n n n n n n n n "}; | 197 | " n n n n n n n n n "}; |
198 | 198 | ||
199 | 199 | ||
200 | using namespace Opie::Ui; | 200 | using namespace Opie::Ui; |
201 | VMemo::VMemo( QWidget *parent, const char *_name ) | 201 | VMemo::VMemo( QWidget *parent, const char *_name ) |
202 | : QWidget( parent, _name ) { | 202 | : QWidget( parent, _name ) { |
203 | setFixedHeight( 18 ); | 203 | setFixedHeight( 18 ); |
204 | setFixedWidth( 14 ); | 204 | setFixedWidth( 14 ); |
205 | 205 | ||
206 | t_timer = new QTimer( this ); | 206 | t_timer = new QTimer( this ); |
207 | connect( t_timer, SIGNAL( timeout() ), SLOT( timerBreak() ) ); | 207 | connect( t_timer, SIGNAL( timeout() ), SLOT( timerBreak() ) ); |
208 | 208 | ||
209 | Config vmCfg("Vmemo"); | 209 | Config vmCfg("Vmemo"); |
210 | vmCfg.setGroup("Defaults"); | 210 | vmCfg.setGroup("Defaults"); |
211 | int toggleKey = setToggleButton(vmCfg.readNumEntry("toggleKey", -1)); | 211 | int toggleKey = setToggleButton(vmCfg.readNumEntry("toggleKey", -1)); |
212 | useADPCM = vmCfg.readBoolEntry("use_ADPCM", 0); | 212 | useADPCM = vmCfg.readBoolEntry("use_ADPCM", 0); |
213 | 213 | ||
214 | odebug << "toggleKey " << toggleKey << "" << oendl; | 214 | odebug << "toggleKey " << toggleKey << "" << oendl; |
215 | 215 | ||
216 | // if ( QFile::exists ( "/dev/sharp_buz" ) || QFile::exists ( "/dev/sharp_led" )) | 216 | // if ( QFile::exists ( "/dev/sharp_buz" ) || QFile::exists ( "/dev/sharp_led" )) |
217 | // systemZaurus=TRUE; | 217 | // systemZaurus=TRUE; |
218 | // else | 218 | // else |
219 | systemZaurus = FALSE; | 219 | systemZaurus = FALSE; |
220 | 220 | ||
221 | myChannel = new QCopChannel( "QPE/VMemo", this ); | 221 | myChannel = new QCopChannel( "QPE/VMemo", this ); |
222 | connect( myChannel, SIGNAL(received(const QCString&,const QByteArray&)), | 222 | connect( myChannel, SIGNAL(received(const QCString&,const QByteArray&)), |
223 | this, SLOT(receive(const QCString&,const QByteArray&)) ); | 223 | this, SLOT(receive(const QCString&,const QByteArray&)) ); |
224 | 224 | ||
225 | if( toggleKey != -1 ) { | 225 | if( toggleKey != -1 ) { |
226 | odebug << "Register key " << toggleKey << "" << oendl; | 226 | odebug << "Register key " << toggleKey << "" << oendl; |
227 | QCopEnvelope e("QPE/Launcher", "keyRegister(int,QCString,QCString)"); | 227 | QCopEnvelope e("QPE/Launcher", "keyRegister(int,QCString,QCString)"); |
228 | // e << 4096; // Key_Escape | 228 | // e << 4096; // Key_Escape |
229 | // e << Key_F5; //4148 | 229 | // e << Key_F5; //4148 |
230 | e << toggleKey; | 230 | e << toggleKey; |
231 | e << QString("QPE/VMemo"); | 231 | e << QString("QPE/VMemo"); |
232 | e << QString("toggleRecord()"); | 232 | e << QString("toggleRecord()"); |
233 | } | 233 | } |
234 | if(toggleKey == 1) | 234 | if(toggleKey == 1) |
235 | usingIcon = TRUE; | 235 | usingIcon = TRUE; |
236 | else | 236 | else |
237 | usingIcon = FALSE; | 237 | usingIcon = FALSE; |
238 | // if( vmCfg.readNumEntry("hideIcon",0) == 1) | 238 | // if( vmCfg.readNumEntry("hideIcon",0) == 1) |
239 | if (!usingIcon) | 239 | if (!usingIcon) |
240 | hide(); | 240 | hide(); |
241 | recording = FALSE; | 241 | recording = FALSE; |
242 | // } | 242 | // } |
243 | } | 243 | } |
244 | 244 | ||
245 | VMemo::~VMemo() { | 245 | VMemo::~VMemo() { |
246 | } | 246 | } |
247 | 247 | ||
248 | int VMemo::position() | 248 | int VMemo::position() |
249 | { | 249 | { |
250 | return 6; | 250 | return 6; |
251 | } | 251 | } |
252 | 252 | ||
253 | void VMemo::receive( const QCString &msg, const QByteArray &data ) { | 253 | void VMemo::receive( const QCString &msg, const QByteArray &data ) { |
254 | odebug << "Vmemo receive" << oendl; | 254 | odebug << "Vmemo receive" << oendl; |
255 | QDataStream stream( data, IO_ReadOnly ); | 255 | QDataStream stream( data, IO_ReadOnly ); |
256 | 256 | ||
257 | if (msg == "toggleRecord()") { | 257 | if (msg == "toggleRecord()") { |
258 | if (recording) { | 258 | if (recording) { |
259 | fromToggle = TRUE; | 259 | fromToggle = TRUE; |
260 | stopRecording(); | 260 | stopRecording(); |
261 | } else { | 261 | } else { |
262 | fromToggle = TRUE; | 262 | fromToggle = TRUE; |
263 | startRecording(); | 263 | startRecording(); |
264 | } | 264 | } |
265 | } | 265 | } |
266 | } | 266 | } |
267 | 267 | ||
268 | void VMemo::paintEvent( QPaintEvent* ) { | 268 | void VMemo::paintEvent( QPaintEvent* ) { |
269 | QPainter p(this); | 269 | QPainter p(this); |
270 | p.drawPixmap( 0, 1,( const char** ) vmemo_xpm ); | 270 | p.drawPixmap( 0, 1,( const char** ) vmemo_xpm ); |
271 | } | 271 | } |
272 | 272 | ||
273 | void VMemo::mousePressEvent( QMouseEvent * /*me*/) { | 273 | void VMemo::mousePressEvent( QMouseEvent * /*me*/) { |
274 | /* No mousePress/mouseRelease recording on the iPAQ. The REC button on the iPAQ calls these functions | 274 | /* No mousePress/mouseRelease recording on the iPAQ. The REC button on the iPAQ calls these functions |
275 | mousePressEvent and mouseReleaseEvent with a NULL parameter. */ | 275 | mousePressEvent and mouseReleaseEvent with a NULL parameter. */ |
276 | 276 | ||
277 | // if (!systemZaurus && me != NULL) | 277 | // if (!systemZaurus && me != NULL) |
278 | // return; | 278 | // return; |
279 | // } | 279 | // } |
280 | 280 | ||
281 | if(!recording) | 281 | if(!recording) |
282 | startRecording(); | 282 | startRecording(); |
283 | else | 283 | else |
284 | stopRecording(); | 284 | stopRecording(); |
285 | } | 285 | } |
286 | 286 | ||
287 | void VMemo::mouseReleaseEvent( QMouseEvent * ) { | 287 | void VMemo::mouseReleaseEvent( QMouseEvent * ) { |
288 | } | 288 | } |
289 | 289 | ||
290 | bool VMemo::startRecording() { | 290 | bool VMemo::startRecording() { |
291 | Config config( "Vmemo" ); | 291 | Config config( "Vmemo" ); |
292 | config.setGroup( "System" ); | 292 | config.setGroup( "System" ); |
293 | 293 | ||
294 | useAlerts = config.readBoolEntry("Alert",1); | 294 | useAlerts = config.readBoolEntry("Alert",1); |
295 | if(useAlerts) { | 295 | if(useAlerts) { |
296 | 296 | ||
297 | msgLabel = new QLabel( 0, "alertLabel" ); | 297 | msgLabel = new QLabel( 0, "alertLabel" ); |
298 | msgLabel->setText("<B><P><font size=+2>VMemo-Recording</font></B>"); | 298 | msgLabel->setText("<B><P><font size=+2>VMemo-Recording</font></B>"); |
299 | msgLabel->show(); | 299 | msgLabel->show(); |
300 | } | 300 | } |
301 | 301 | ||
302 | odebug << "Start recording engines" << oendl; | 302 | odebug << "Start recording engines" << oendl; |
303 | recording = TRUE; | 303 | recording = TRUE; |
304 | 304 | ||
305 | if (openDSP() == -1) { | 305 | if (openDSP() == -1) { |
306 | recording = FALSE; | 306 | recording = FALSE; |
307 | return FALSE; | 307 | return FALSE; |
308 | } | 308 | } |
309 | 309 | ||
310 | config.setGroup("Defaults"); | 310 | config.setGroup("Defaults"); |
311 | 311 | ||
312 | date = TimeString::dateString( QDateTime::currentDateTime(),false,true); | 312 | date = TimeString::dateString( QDateTime::currentDateTime(),false,true); |
313 | date.replace(QRegExp("'"),""); | 313 | date.replace(QRegExp("'"),""); |
314 | date.replace(QRegExp(" "),"_"); | 314 | date.replace(QRegExp(" "),"_"); |
315 | date.replace(QRegExp(":"),"-"); | 315 | date.replace(QRegExp(":"),"-"); |
316 | date.replace(QRegExp(","),""); | 316 | date.replace(QRegExp(","),""); |
317 | 317 | ||
318 | QString fName; | 318 | QString fName; |
319 | config.setGroup( "System" ); | 319 | config.setGroup( "System" ); |
320 | fName = QPEApplication::documentDir() ; | 320 | fName = QPEApplication::documentDir() ; |
321 | fileName = config.readEntry("RecLocation", fName); | 321 | fileName = config.readEntry("RecLocation", fName); |
322 | 322 | ||
323 | int s; | 323 | int s; |
324 | s=fileName.find(':'); | 324 | s=fileName.find(':'); |
325 | if(s) | 325 | if(s) |
326 | fileName=fileName.right(fileName.length()-s-2); | 326 | fileName=fileName.right(fileName.length()-s-2); |
327 | odebug << "pathname will be "+fileName << oendl; | 327 | odebug << "pathname will be "+fileName << oendl; |
328 | 328 | ||
329 | if( fileName.left(1).find('/') == -1) | 329 | if( fileName.left(1).find('/') == -1) |
330 | fileName="/"+fileName; | 330 | fileName="/"+fileName; |
331 | if( fileName.right(1).find('/') == -1) | 331 | if( fileName.right(1).find('/') == -1) |
332 | fileName+="/"; | 332 | fileName+="/"; |
333 | fName = "vm_"+ date + ".wav"; | 333 | fName = "vm_"+ date + ".wav"; |
334 | 334 | ||
335 | fileName+=fName; | 335 | fileName+=fName; |
336 | odebug << "filename is " + fileName << oendl; | 336 | odebug << "filename is " + fileName << oendl; |
337 | // open tmp file here | 337 | // open tmp file here |
338 | char *pointer; | 338 | char *pointer; |
339 | pointer=tmpnam(NULL); | 339 | pointer=tmpnam(NULL); |
340 | odebug << "Opening tmp file " << pointer << "" << oendl; | 340 | odebug << "Opening tmp file " << pointer << "" << oendl; |
341 | 341 | ||
342 | if(openWAV(pointer ) == -1) { | 342 | if(openWAV(pointer ) == -1) { |
343 | 343 | ||
344 | QString err("Could not open the temp file\n"); | 344 | QString err("Could not open the temp file\n"); |
345 | err += fileName; | 345 | err += fileName; |
346 | QMessageBox::critical(0, "vmemo", err, "Abort"); | 346 | QMessageBox::critical(0, "vmemo", err, "Abort"); |
347 | ::close(dsp); | 347 | ::close(dsp); |
348 | return FALSE; | 348 | return FALSE; |
349 | } | 349 | } |
350 | if( record() ) { | 350 | if( record() ) { |
351 | 351 | ||
352 | QString cmd; | 352 | QString cmd; |
353 | if( fileName.find(".wav",0,TRUE) == -1) | 353 | if( fileName.find(".wav",0,TRUE) == -1) |
354 | fileName += ".wav"; | 354 | fileName += ".wav"; |
355 | 355 | ||
356 | cmd.sprintf("mv %s "+fileName, pointer); | 356 | cmd.sprintf("mv %s "+fileName, pointer); |
357 | // move tmp file to regular file here | 357 | // move tmp file to regular file here |
358 | 358 | ||
359 | system(cmd.latin1()); | 359 | system(cmd.latin1()); |
360 | 360 | ||
361 | QArray<int> cats(1); | 361 | QArray<int> cats(1); |
362 | cats[0] = config.readNumEntry("Category", 0); | 362 | cats[0] = config.readNumEntry("Category", 0); |
363 | 363 | ||
364 | QString dlName("vm_"); | 364 | QString dlName("vm_"); |
365 | dlName += date; | 365 | dlName += date; |
366 | DocLnk l; | 366 | DocLnk l; |
367 | l.setFile(fileName); | 367 | l.setFile(fileName); |
368 | l.setName(dlName); | 368 | l.setName(dlName); |
369 | l.setType("audio/x-wav"); | 369 | l.setType("audio/x-wav"); |
370 | l.setCategories(cats); | 370 | l.setCategories(cats); |
371 | l.writeLink(); | 371 | l.writeLink(); |
372 | return TRUE; | 372 | return TRUE; |
373 | } else | 373 | } else |
374 | return FALSE; | 374 | return FALSE; |
375 | 375 | ||
376 | } | 376 | } |
377 | 377 | ||
378 | void VMemo::stopRecording() { | 378 | void VMemo::stopRecording() { |
379 | // show(); | 379 | // show(); |
380 | odebug << "Stopped recording" << oendl; | 380 | odebug << "Stopped recording" << oendl; |
381 | recording = FALSE; | 381 | recording = FALSE; |
382 | if(useAlerts) { | 382 | if(useAlerts) { |
383 | msgLabel->close(); | 383 | msgLabel->close(); |
384 | msgLabel=0; | 384 | msgLabel=0; |
385 | delete msgLabel; | 385 | delete msgLabel; |
386 | } | 386 | } |
387 | t_timer->stop(); | 387 | t_timer->stop(); |
388 | Config cfg("Vmemo"); | 388 | Config cfg("Vmemo"); |
389 | cfg.setGroup("Defaults"); | 389 | cfg.setGroup("Defaults"); |
390 | // if( cfg.readNumEntry("hideIcon",0) == 1 ) | 390 | // if( cfg.readNumEntry("hideIcon",0) == 1 ) |
391 | // hide(); | 391 | // hide(); |
392 | } | 392 | } |
393 | 393 | ||
394 | int VMemo::openDSP() { | 394 | int VMemo::openDSP() { |
395 | Config cfg("Vmemo"); | 395 | Config cfg("Vmemo"); |
396 | cfg.setGroup("Record"); | 396 | cfg.setGroup("Record"); |
397 | 397 | ||
398 | speed = cfg.readNumEntry("SampleRate", 22050); | 398 | speed = cfg.readNumEntry("SampleRate", 22050); |
399 | channels = cfg.readNumEntry("Stereo", 1) ? 2 : 1; // 1 = stereo(2), 0 = mono(1) | 399 | channels = cfg.readNumEntry("Stereo", 1) ? 2 : 1; // 1 = stereo(2), 0 = mono(1) |
400 | if (cfg.readNumEntry("SixteenBit", 1)==1) { | 400 | if (cfg.readNumEntry("SixteenBit", 1)==1) { |
401 | format = AFMT_S16_LE; | 401 | format = AFMT_S16_LE; |
402 | resolution = 16; | 402 | resolution = 16; |
403 | } else { | 403 | } else { |
404 | format = AFMT_U8; | 404 | format = AFMT_U8; |
405 | resolution = 8; | 405 | resolution = 8; |
406 | } | 406 | } |
407 | 407 | ||
408 | odebug << "samplerate: " << speed << ", channels " << channels << ", resolution " << resolution << "" << oendl; | 408 | odebug << "samplerate: " << speed << ", channels " << channels << ", resolution " << resolution << "" << oendl; |
409 | 409 | ||
410 | if(systemZaurus) { | 410 | if(systemZaurus) { |
411 | dsp = open("/dev/dsp1", O_RDONLY); //Zaurus needs /dev/dsp1 | 411 | dsp = open("/dev/dsp1", O_RDONLY); //Zaurus needs /dev/dsp1 |
412 | channels=1; //zaurus has one input channel | 412 | channels=1; //zaurus has one input channel |
413 | } else { | 413 | } else { |
414 | #ifdef QT_QWS_DEVFS | ||
415 | dsp = open("/dev/sound/dsp", O_RDONLY); | ||
416 | #else | ||
414 | dsp = open("/dev/dsp", O_RDONLY); | 417 | dsp = open("/dev/dsp", O_RDONLY); |
418 | #endif | ||
415 | } | 419 | } |
416 | 420 | ||
417 | if(dsp == -1) { | 421 | if (dsp == -1) { |
418 | msgLabel->close(); | 422 | msgLabel->close(); |
419 | msgLabel=0; | 423 | msgLabel=0; |
420 | delete msgLabel; | 424 | delete msgLabel; |
421 | 425 | ||
422 | perror("open(\"/dev/dsp\")"); | 426 | perror("open(\"/dev/dsp\")"); |
423 | errorMsg="open(\"/dev/dsp\")\n "+(QString)strerror(errno); | 427 | errorMsg="open(\"/dev/dsp\")\n "+(QString)strerror(errno); |
424 | QMessageBox::critical(0, "vmemo", errorMsg, "Abort"); | 428 | QMessageBox::critical(0, "vmemo", errorMsg, "Abort"); |
425 | return -1; | 429 | return -1; |
426 | } | 430 | } |
427 | 431 | ||
428 | if(ioctl(dsp, SNDCTL_DSP_SETFMT , &format)==-1) { | 432 | if(ioctl(dsp, SNDCTL_DSP_SETFMT , &format)==-1) { |
429 | perror("ioctl(\"SNDCTL_DSP_SETFMT\")"); | 433 | perror("ioctl(\"SNDCTL_DSP_SETFMT\")"); |
430 | return -1; | 434 | return -1; |
431 | } | 435 | } |
432 | if(ioctl(dsp, SNDCTL_DSP_CHANNELS , &channels)==-1) { | 436 | if(ioctl(dsp, SNDCTL_DSP_CHANNELS , &channels)==-1) { |
433 | perror("ioctl(\"SNDCTL_DSP_CHANNELS\")"); | 437 | perror("ioctl(\"SNDCTL_DSP_CHANNELS\")"); |
434 | return -1; | 438 | return -1; |
435 | } | 439 | } |
436 | if(ioctl(dsp, SNDCTL_DSP_SPEED , &speed)==-1) { | 440 | if(ioctl(dsp, SNDCTL_DSP_SPEED , &speed)==-1) { |
437 | perror("ioctl(\"SNDCTL_DSP_SPEED\")"); | 441 | perror("ioctl(\"SNDCTL_DSP_SPEED\")"); |
438 | return -1; | 442 | return -1; |
439 | } | 443 | } |
440 | if(ioctl(dsp, SOUND_PCM_READ_RATE , &rate)==-1) { | 444 | if(ioctl(dsp, SOUND_PCM_READ_RATE , &rate)==-1) { |
441 | perror("ioctl(\"SOUND_PCM_READ_RATE\")"); | 445 | perror("ioctl(\"SOUND_PCM_READ_RATE\")"); |
442 | return -1; | 446 | return -1; |
443 | } | 447 | } |
444 | 448 | ||
445 | QCopEnvelope( "QPE/System", "volumeChange(bool)" ) << FALSE; //mute | 449 | QCopEnvelope( "QPE/System", "volumeChange(bool)" ) << FALSE; //mute |
446 | 450 | ||
447 | return 1; | 451 | return 1; |
448 | } | 452 | } |
449 | 453 | ||
450 | int VMemo::openWAV(const char *filename) { | 454 | int VMemo::openWAV(const char *filename) { |
451 | track.setName(filename); | 455 | track.setName(filename); |
452 | if(!track.open(IO_WriteOnly|IO_Truncate|IO_Raw)) { | 456 | if(!track.open(IO_WriteOnly|IO_Truncate|IO_Raw)) { |
453 | errorMsg=filename; | 457 | errorMsg=filename; |
454 | return -1; | 458 | return -1; |
455 | } | 459 | } |
456 | 460 | ||
457 | wav=track.handle(); | 461 | wav=track.handle(); |
458 | Config vmCfg("Vmemo"); | 462 | Config vmCfg("Vmemo"); |
459 | vmCfg.setGroup("Defaults"); | 463 | vmCfg.setGroup("Defaults"); |
460 | useADPCM = vmCfg.readBoolEntry("use_ADPCM", 0); | 464 | useADPCM = vmCfg.readBoolEntry("use_ADPCM", 0); |
461 | 465 | ||
462 | WaveHeader wh; | 466 | WaveHeader wh; |
463 | 467 | ||
464 | wh.main_chunk = RIFF; | 468 | wh.main_chunk = RIFF; |
465 | wh.length=0; | 469 | wh.length=0; |
466 | wh.chunk_type = WAVE; | 470 | wh.chunk_type = WAVE; |
467 | wh.sub_chunk = FMT; | 471 | wh.sub_chunk = FMT; |
468 | wh.sc_len = 16; | 472 | wh.sc_len = 16; |
469 | if(useADPCM) | 473 | if(useADPCM) |
470 | wh.format = WAVE_FORMAT_DVI_ADPCM;//PCM_CODE; | 474 | wh.format = WAVE_FORMAT_DVI_ADPCM;//PCM_CODE; |
471 | else | 475 | else |
472 | wh.format = PCM_CODE; | 476 | wh.format = PCM_CODE; |
473 | wh.modus = channels; | 477 | wh.modus = channels; |
474 | wh.sample_fq = speed; | 478 | wh.sample_fq = speed; |
475 | wh.byte_p_sec = speed * channels * resolution/8; | 479 | wh.byte_p_sec = speed * channels * resolution/8; |
476 | wh.byte_p_spl = channels * (resolution / 8); | 480 | wh.byte_p_spl = channels * (resolution / 8); |
477 | wh.bit_p_spl = resolution; | 481 | wh.bit_p_spl = resolution; |
478 | wh.data_chunk = DATA; | 482 | wh.data_chunk = DATA; |
479 | wh.data_length= 0; | 483 | wh.data_length= 0; |
480 | // odebug << "Write header channels " << wh.modus << ", speed " << wh.sample_fq << ", b/s " | 484 | // odebug << "Write header channels " << wh.modus << ", speed " << wh.sample_fq << ", b/s " |
481 | // << wh.byte_p_sec << ", blockalign " << wh.byte_p_spl << ", bitrate " << wh.bit_p_spl << oendl; | 485 | // << wh.byte_p_sec << ", blockalign " << wh.byte_p_spl << ", bitrate " << wh.bit_p_spl << oendl; |
482 | write (wav, &wh, sizeof(WaveHeader)); | 486 | write (wav, &wh, sizeof(WaveHeader)); |
483 | 487 | ||
484 | return 1; | 488 | return 1; |
485 | } | 489 | } |
486 | 490 | ||
487 | bool VMemo::record() { | 491 | bool VMemo::record() { |
488 | length = 0; | 492 | length = 0; |
489 | int bytesWritten = 0; | 493 | int bytesWritten = 0; |
490 | int result = 0; | 494 | int result = 0; |
491 | int value = 0; | 495 | int value = 0; |
492 | 496 | ||
493 | QString msg; | 497 | QString msg; |
494 | msg.sprintf("Recording format %d", format); | 498 | msg.sprintf("Recording format %d", format); |
495 | odebug << msg << oendl; | 499 | odebug << msg << oendl; |
496 | 500 | ||
497 | Config config("Vmemo"); | 501 | Config config("Vmemo"); |
498 | config.setGroup("Record"); | 502 | config.setGroup("Record"); |
499 | int sRate = config.readNumEntry("SizeLimit", 30); | 503 | int sRate = config.readNumEntry("SizeLimit", 30); |
500 | odebug << "VMEMO rate" << sRate << oendl; | 504 | odebug << "VMEMO rate" << sRate << oendl; |
501 | 505 | ||
502 | if(sRate > 0) { | 506 | if(sRate > 0) { |
503 | t_timer->start( sRate * 1000+1000, TRUE); | 507 | t_timer->start( sRate * 1000+1000, TRUE); |
504 | } | 508 | } |
505 | 509 | ||
506 | msg.sprintf("Recording format other"); | 510 | msg.sprintf("Recording format other"); |
507 | odebug << msg << oendl; | 511 | odebug << msg << oendl; |
508 | 512 | ||
509 | config.setGroup("Defaults"); | 513 | config.setGroup("Defaults"); |
510 | useADPCM = config.readBoolEntry("use_ADPCM", 0); | 514 | useADPCM = config.readBoolEntry("use_ADPCM", 0); |
511 | 515 | ||
512 | int bufsize = config.readNumEntry("BufferSize",1024); | 516 | int bufsize = config.readNumEntry("BufferSize",1024); |
513 | unsigned short sound[bufsize]; //, monoBuffer[bufsize]; | 517 | unsigned short sound[bufsize]; //, monoBuffer[bufsize]; |
514 | char abuf[bufsize / 2]; | 518 | char abuf[bufsize / 2]; |
515 | short sbuf[bufsize]; | 519 | short sbuf[bufsize]; |
516 | odebug << "ready to record"<< oendl; | 520 | odebug << "ready to record"<< oendl; |
517 | if(useADPCM) { | 521 | if(useADPCM) { |
518 | odebug << "usr ADPCM" << oendl; | 522 | odebug << "usr ADPCM" << oendl; |
519 | 523 | ||
520 | while(recording) { | 524 | while(recording) { |
521 | result = ::read(dsp, sbuf, bufsize); // adpcm read | 525 | result = ::read(dsp, sbuf, bufsize); // adpcm read |
522 | if( result <= 0) { | 526 | if( result <= 0) { |
523 | perror("recording error "); | 527 | perror("recording error "); |
524 | QMessageBox::message(tr("Note"),tr("error recording")); | 528 | QMessageBox::message(tr("Note"),tr("error recording")); |
525 | recording = FALSE; | 529 | recording = FALSE; |
526 | break; | 530 | break; |
527 | return FALSE; | 531 | return FALSE; |
528 | } | 532 | } |
529 | adpcm_coder( sbuf, abuf, result/2, &encoder_state); | 533 | adpcm_coder( sbuf, abuf, result/2, &encoder_state); |
530 | bytesWritten = ::write(wav, abuf, result/4); // adpcm write | 534 | bytesWritten = ::write(wav, abuf, result/4); // adpcm write |
531 | length += bytesWritten; | 535 | length += bytesWritten; |
532 | 536 | ||
533 | if(length < 0) { | 537 | if(length < 0) { |
534 | recording = false; | 538 | recording = false; |
535 | perror("dev/dsp's is a lookin' messy"); | 539 | perror("dev/dsp's is a lookin' messy"); |
536 | QMessageBox::message("Vmemo","Error writing to file\n"+ fileName); | 540 | QMessageBox::message("Vmemo","Error writing to file\n"+ fileName); |
537 | break; | 541 | break; |
538 | return FALSE; | 542 | return FALSE; |
539 | } | 543 | } |
540 | printf("%d\r", length); | 544 | printf("%d\r", length); |
541 | fflush(stdout); | 545 | fflush(stdout); |
542 | qApp->processEvents(); | 546 | qApp->processEvents(); |
543 | } | 547 | } |
544 | } else { | 548 | } else { |
545 | odebug << "use regular wav" << oendl; | 549 | odebug << "use regular wav" << oendl; |
546 | while(recording) { | 550 | while(recording) { |
547 | result = ::read(dsp, sound, bufsize); // read | 551 | result = ::read(dsp, sound, bufsize); // read |
548 | if( result <= 0) { | 552 | if( result <= 0) { |
549 | perror("recording error "); | 553 | perror("recording error "); |
550 | QMessageBox::message(tr("Note"),tr("error recording")); | 554 | QMessageBox::message(tr("Note"),tr("error recording")); |
551 | recording = FALSE; | 555 | recording = FALSE; |
552 | break; | 556 | break; |
553 | return FALSE; | 557 | return FALSE; |
554 | } | 558 | } |
555 | 559 | ||
556 | bytesWritten = ::write(wav, sound, result); // write | 560 | bytesWritten = ::write(wav, sound, result); // write |
557 | length += bytesWritten; | 561 | length += bytesWritten; |
558 | 562 | ||
559 | if(length < 0) { | 563 | if(length < 0) { |
560 | recording = false; | 564 | recording = false; |
561 | perror("dev/dsp's is a lookin' messy"); | 565 | perror("dev/dsp's is a lookin' messy"); |
562 | QMessageBox::message("Vmemo","Error writing to file\n"+ fileName); | 566 | QMessageBox::message("Vmemo","Error writing to file\n"+ fileName); |
563 | break; | 567 | break; |
564 | return FALSE; | 568 | return FALSE; |
565 | } | 569 | } |
566 | // printf("%d\r", length); | 570 | // printf("%d\r", length); |
567 | // fflush(stdout); | 571 | // fflush(stdout); |
568 | qApp->processEvents(); | 572 | qApp->processEvents(); |
569 | } | 573 | } |
570 | // odebug << "result is " << result << oendl; | 574 | // odebug << "result is " << result << oendl; |
571 | } | 575 | } |
572 | odebug << "file has length of " << length << " lasting " << (( length / speed) / channels) / 2 << " seconds" << oendl; | 576 | odebug << "file has length of " << length << " lasting " << (( length / speed) / channels) / 2 << " seconds" << oendl; |
573 | 577 | ||
574 | value = length + 36; | 578 | value = length + 36; |
575 | 579 | ||
576 | lseek(wav, 4, SEEK_SET); | 580 | lseek(wav, 4, SEEK_SET); |
577 | write(wav, &value, 4); | 581 | write(wav, &value, 4); |
578 | lseek(wav, 40, SEEK_SET); | 582 | lseek(wav, 40, SEEK_SET); |
579 | 583 | ||
580 | write(wav, &length, 4); | 584 | write(wav, &length, 4); |
581 | 585 | ||
582 | track.close(); | 586 | track.close(); |
583 | odebug << "Track closed" << oendl; | 587 | odebug << "Track closed" << oendl; |
584 | 588 | ||
585 | if( ioctl( dsp, SNDCTL_DSP_RESET,0) == -1) | 589 | if( ioctl( dsp, SNDCTL_DSP_RESET,0) == -1) |
586 | perror("ioctl(\"SNDCTL_DSP_RESET\")"); | 590 | perror("ioctl(\"SNDCTL_DSP_RESET\")"); |
587 | 591 | ||
588 | ::close(dsp); | 592 | ::close(dsp); |
589 | 593 | ||
590 | Config cfgO("OpieRec"); | 594 | Config cfgO("OpieRec"); |
591 | cfgO.setGroup("Sounds"); | 595 | cfgO.setGroup("Sounds"); |
592 | 596 | ||
593 | int nFiles = cfgO.readNumEntry( "NumberofFiles",0); | 597 | int nFiles = cfgO.readNumEntry( "NumberofFiles",0); |
594 | 598 | ||
595 | QString currentFileName = fileName; | 599 | QString currentFileName = fileName; |
596 | QString currentFile = "vm_"+ date; | 600 | QString currentFile = "vm_"+ date; |
597 | 601 | ||
598 | float numberOfRecordedSeconds = (float) length / (float)speed * (float)2; | 602 | float numberOfRecordedSeconds = (float) length / (float)speed * (float)2; |
599 | 603 | ||
600 | cfgO.writeEntry( "NumberofFiles", nFiles + 1); | 604 | cfgO.writeEntry( "NumberofFiles", nFiles + 1); |
601 | cfgO.writeEntry( QString::number( nFiles + 1), currentFile); | 605 | cfgO.writeEntry( QString::number( nFiles + 1), currentFile); |
602 | cfgO.writeEntry( currentFile, currentFileName); | 606 | cfgO.writeEntry( currentFile, currentFileName); |
603 | 607 | ||
604 | QString time; | 608 | QString time; |
605 | time.sprintf("%.2f", numberOfRecordedSeconds); | 609 | time.sprintf("%.2f", numberOfRecordedSeconds); |
606 | cfgO.writeEntry( currentFileName, time ); | 610 | cfgO.writeEntry( currentFileName, time ); |
607 | // odebug << "writing config numberOfRecordedSeconds "+time << oendl; | 611 | // odebug << "writing config numberOfRecordedSeconds "+time << oendl; |
608 | 612 | ||
609 | cfgO.write(); | 613 | cfgO.write(); |
610 | 614 | ||
611 | odebug << "done recording "+fileName << oendl; | 615 | odebug << "done recording "+fileName << oendl; |
612 | 616 | ||
613 | Config cfg("qpe"); | 617 | Config cfg("qpe"); |
614 | cfg.setGroup("Volume"); | 618 | cfg.setGroup("Volume"); |
615 | QString foo = cfg.readEntry("Mute","TRUE"); | 619 | QString foo = cfg.readEntry("Mute","TRUE"); |
616 | if(foo.find("TRUE",0,TRUE) != -1) | 620 | if(foo.find("TRUE",0,TRUE) != -1) |
617 | QCopEnvelope( "QPE/System", "volumeChange(bool)" ) << TRUE; //mute | 621 | QCopEnvelope( "QPE/System", "volumeChange(bool)" ) << TRUE; //mute |
618 | return TRUE; | 622 | return TRUE; |
619 | } | 623 | } |
620 | 624 | ||
621 | int VMemo::setToggleButton(int tog) { | 625 | int VMemo::setToggleButton(int tog) { |
622 | 626 | ||
623 | for( int i=0; i < 10;i++) { | 627 | for( int i=0; i < 10;i++) { |
624 | switch (tog) { | 628 | switch (tog) { |
625 | case 0: | 629 | case 0: |
626 | return -1; | 630 | return -1; |
627 | break; | 631 | break; |
628 | case 1: | 632 | case 1: |
629 | return 0; | 633 | return 0; |
630 | break; | 634 | break; |
631 | case 2: | 635 | case 2: |
632 | return Key_F24; //was Escape | 636 | return Key_F24; //was Escape |
633 | break; | 637 | break; |
634 | case 3: | 638 | case 3: |
635 | return Key_Space; | 639 | return Key_Space; |
636 | break; | 640 | break; |
637 | case 4: | 641 | case 4: |
638 | return Key_F12; | 642 | return Key_F12; |
639 | break; | 643 | break; |
640 | case 5: | 644 | case 5: |
641 | return Key_F9; | 645 | return Key_F9; |
642 | break; | 646 | break; |
643 | case 6: | 647 | case 6: |
644 | return Key_F10; | 648 | return Key_F10; |
645 | break; | 649 | break; |
646 | case 7: | 650 | case 7: |
647 | return Key_F11; | 651 | return Key_F11; |
648 | break; | 652 | break; |
649 | case 8: | 653 | case 8: |
650 | return Key_F13; | 654 | return Key_F13; |
651 | break; | 655 | break; |
652 | }; | 656 | }; |
653 | } | 657 | } |
654 | return -1; | 658 | return -1; |
655 | } | 659 | } |
656 | 660 | ||
657 | void VMemo::timerBreak() { | 661 | void VMemo::timerBreak() { |
658 | //stop | 662 | //stop |
659 | stopRecording(); | 663 | stopRecording(); |
660 | QMessageBox::message("Vmemo","Vmemo recording has ended"); | 664 | QMessageBox::message("Vmemo","Vmemo recording has ended"); |
661 | } | 665 | } |
662 | 666 | ||
663 | 667 | ||
664 | EXPORT_OPIE_APPLET_v1( VMemo ) | 668 | EXPORT_OPIE_APPLET_v1( VMemo ) |
665 | 669 | ||
diff --git a/core/applets/vtapplet/vt.cpp b/core/applets/vtapplet/vt.cpp index aec63c3..7832ee0 100644 --- a/core/applets/vtapplet/vt.cpp +++ b/core/applets/vtapplet/vt.cpp | |||
@@ -1,164 +1,172 @@ | |||
1 | /********************************************************************** | 1 | /********************************************************************** |
2 | ** Copyright (C) 2003-2004 Michael 'Mickey' Lauer <mickey@Vanille.de> | 2 | ** Copyright (C) 2003-2004 Michael 'Mickey' Lauer <mickey@Vanille.de> |
3 | ** | 3 | ** |
4 | ** This file may be distributed and/or modified under the terms of the | 4 | ** This file may be distributed and/or modified under the terms of the |
5 | ** GNU General Public License version 2 as published by the Free Software | 5 | ** GNU General Public License version 2 as published by the Free Software |
6 | ** Foundation and appearing in the file LICENSE.GPL included in the | 6 | ** Foundation and appearing in the file LICENSE.GPL included in the |
7 | ** packaging of this file. | 7 | ** packaging of this file. |
8 | ** | 8 | ** |
9 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE | 9 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE |
10 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. | 10 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. |
11 | ** | 11 | ** |
12 | **********************************************************************/ | 12 | **********************************************************************/ |
13 | 13 | ||
14 | #include "vt.h" | 14 | #include "vt.h" |
15 | 15 | ||
16 | /* OPIE */ | 16 | /* OPIE */ |
17 | #include <opie2/odebug.h> | 17 | #include <opie2/odebug.h> |
18 | #include <qpe/resource.h> | 18 | #include <qpe/resource.h> |
19 | using namespace Opie::Core; | 19 | using namespace Opie::Core; |
20 | 20 | ||
21 | /* QT */ | 21 | /* QT */ |
22 | #include <qpopupmenu.h> | 22 | #include <qpopupmenu.h> |
23 | 23 | ||
24 | /* STD */ | 24 | /* STD */ |
25 | #include <fcntl.h> | 25 | #include <fcntl.h> |
26 | #include <unistd.h> | 26 | #include <unistd.h> |
27 | #include <sys/types.h> | 27 | #include <sys/types.h> |
28 | #include <sys/stat.h> | 28 | #include <sys/stat.h> |
29 | #include <sys/ioctl.h> | 29 | #include <sys/ioctl.h> |
30 | #include <linux/vt.h> | 30 | #include <linux/vt.h> |
31 | 31 | ||
32 | VTApplet::VTApplet ( ) | 32 | VTApplet::VTApplet ( ) |
33 | : QObject ( 0, "VTApplet" ) | 33 | : QObject ( 0, "VTApplet" ) |
34 | { | 34 | { |
35 | } | 35 | } |
36 | 36 | ||
37 | VTApplet::~VTApplet ( ) | 37 | VTApplet::~VTApplet ( ) |
38 | { | 38 | { |
39 | } | 39 | } |
40 | 40 | ||
41 | int VTApplet::position ( ) const | 41 | int VTApplet::position ( ) const |
42 | { | 42 | { |
43 | return 2; | 43 | return 2; |
44 | } | 44 | } |
45 | 45 | ||
46 | QString VTApplet::name ( ) const | 46 | QString VTApplet::name ( ) const |
47 | { | 47 | { |
48 | return tr( "VT shortcut" ); | 48 | return tr( "VT shortcut" ); |
49 | } | 49 | } |
50 | 50 | ||
51 | QString VTApplet::text ( ) const | 51 | QString VTApplet::text ( ) const |
52 | { | 52 | { |
53 | return tr( "Terminal" ); | 53 | return tr( "Terminal" ); |
54 | } | 54 | } |
55 | 55 | ||
56 | /* | 56 | /* |
57 | QString VTApplet::tr( const char* s ) const | 57 | QString VTApplet::tr( const char* s ) const |
58 | { | 58 | { |
59 | return qApp->translate( "VTApplet", s, 0 ); | 59 | return qApp->translate( "VTApplet", s, 0 ); |
60 | } | 60 | } |
61 | 61 | ||
62 | QString VTApplet::tr( const char* s, const char* p ) const | 62 | QString VTApplet::tr( const char* s, const char* p ) const |
63 | { | 63 | { |
64 | return qApp->translate( "VTApplet", s, p ); | 64 | return qApp->translate( "VTApplet", s, p ); |
65 | } | 65 | } |
66 | */ | 66 | */ |
67 | 67 | ||
68 | QIconSet VTApplet::icon ( ) const | 68 | QIconSet VTApplet::icon ( ) const |
69 | { | 69 | { |
70 | QPixmap pix; | 70 | QPixmap pix; |
71 | QImage img = Resource::loadImage ( "terminal" ); | 71 | QImage img = Resource::loadImage ( "terminal" ); |
72 | 72 | ||
73 | if ( !img. isNull ( )) | 73 | if ( !img. isNull ( )) |
74 | pix. convertFromImage ( img. smoothScale ( 14, 14 )); | 74 | pix. convertFromImage ( img. smoothScale ( 14, 14 )); |
75 | return pix; | 75 | return pix; |
76 | } | 76 | } |
77 | 77 | ||
78 | QPopupMenu *VTApplet::popup ( QWidget* parent ) const | 78 | QPopupMenu *VTApplet::popup ( QWidget* parent ) const |
79 | { | 79 | { |
80 | odebug << "VTApplet::popup" << oendl; | 80 | odebug << "VTApplet::popup" << oendl; |
81 | 81 | ||
82 | struct vt_stat vtstat; | 82 | struct vt_stat vtstat; |
83 | #ifdef QT_QWS_DEVFS | ||
84 | int fd = ::open( "/dev/vc/0", O_RDWR ); | ||
85 | #else | ||
83 | int fd = ::open( "/dev/tty0", O_RDWR ); | 86 | int fd = ::open( "/dev/tty0", O_RDWR ); |
87 | #endif | ||
84 | if ( fd == -1 ) return 0; | 88 | if ( fd == -1 ) return 0; |
85 | if ( ioctl( fd, VT_GETSTATE, &vtstat ) == -1 ) return 0; | 89 | if ( ioctl( fd, VT_GETSTATE, &vtstat ) == -1 ) return 0; |
86 | 90 | ||
87 | m_subMenu = new QPopupMenu( parent ); | 91 | m_subMenu = new QPopupMenu( parent ); |
88 | m_subMenu->setCheckable( true ); | 92 | m_subMenu->setCheckable( true ); |
89 | for ( int i = 1; i < 10; ++i ) | 93 | for ( int i = 1; i < 10; ++i ) |
90 | { | 94 | { |
91 | int id = m_subMenu->insertItem( QString::number( i ), 500+i ); | 95 | int id = m_subMenu->insertItem( QString::number( i ), 500+i ); |
92 | m_subMenu->setItemChecked( id, id-500 == vtstat.v_active ); | 96 | m_subMenu->setItemChecked( id, id-500 == vtstat.v_active ); |
93 | } | 97 | } |
94 | ::close( fd ); | 98 | ::close( fd ); |
95 | 99 | ||
96 | connect( m_subMenu, SIGNAL( activated(int) ), this, SLOT( changeVT(int) ) ); | 100 | connect( m_subMenu, SIGNAL( activated(int) ), this, SLOT( changeVT(int) ) ); |
97 | connect( m_subMenu, SIGNAL( aboutToShow() ), this, SLOT( updateMenu() ) ); | 101 | connect( m_subMenu, SIGNAL( aboutToShow() ), this, SLOT( updateMenu() ) ); |
98 | 102 | ||
99 | return m_subMenu; | 103 | return m_subMenu; |
100 | } | 104 | } |
101 | 105 | ||
102 | 106 | ||
103 | void VTApplet::changeVT( int index ) | 107 | void VTApplet::changeVT( int index ) |
104 | { | 108 | { |
105 | //odebug << "VTApplet::changeVT( " << index-500 << " )" << oendl; | 109 | //odebug << "VTApplet::changeVT( " << index-500 << " )" << oendl; |
106 | 110 | ||
111 | #ifdef QT_QWS_DEVFS | ||
112 | int fd = ::open("/dev/vc/0", O_RDWR); | ||
113 | #else | ||
107 | int fd = ::open("/dev/tty0", O_RDWR); | 114 | int fd = ::open("/dev/tty0", O_RDWR); |
115 | #endif | ||
108 | if ( fd == -1 ) return; | 116 | if ( fd == -1 ) return; |
109 | ioctl( fd, VT_ACTIVATE, index-500 ); | 117 | ioctl( fd, VT_ACTIVATE, index-500 ); |
110 | } | 118 | } |
111 | 119 | ||
112 | 120 | ||
113 | void VTApplet::updateMenu() | 121 | void VTApplet::updateMenu() |
114 | { | 122 | { |
115 | //odebug << "VTApplet::updateMenu()" << oendl; | 123 | //odebug << "VTApplet::updateMenu()" << oendl; |
116 | 124 | ||
117 | int fd = ::open( "/dev/console", O_RDONLY ); | 125 | int fd = ::open( "/dev/console", O_RDONLY ); |
118 | if ( fd == -1 ) return; | 126 | if ( fd == -1 ) return; |
119 | 127 | ||
120 | for ( int i = 1; i < 10; ++i ) | 128 | for ( int i = 1; i < 10; ++i ) |
121 | { | 129 | { |
122 | int result = ioctl( fd, VT_DISALLOCATE, i ); | 130 | int result = ioctl( fd, VT_DISALLOCATE, i ); |
123 | 131 | ||
124 | /* | 132 | /* |
125 | if ( result == -1 ) | 133 | if ( result == -1 ) |
126 | odebug << "VT " << i << " disallocated == free" << oendl; | 134 | odebug << "VT " << i << " disallocated == free" << oendl; |
127 | else | 135 | else |
128 | odebug << "VT " << i << " _not_ disallocated == busy" << oendl; | 136 | odebug << "VT " << i << " _not_ disallocated == busy" << oendl; |
129 | */ | 137 | */ |
130 | 138 | ||
131 | m_subMenu->setItemEnabled( 500+i, result == -1 ); | 139 | m_subMenu->setItemEnabled( 500+i, result == -1 ); |
132 | } | 140 | } |
133 | 141 | ||
134 | ::close( fd ); | 142 | ::close( fd ); |
135 | } | 143 | } |
136 | 144 | ||
137 | 145 | ||
138 | void VTApplet::activated() | 146 | void VTApplet::activated() |
139 | { | 147 | { |
140 | odebug << "VTApplet::activated()" << oendl; | 148 | odebug << "VTApplet::activated()" << oendl; |
141 | } | 149 | } |
142 | 150 | ||
143 | 151 | ||
144 | QRESULT VTApplet::queryInterface ( const QUuid &uuid, QUnknownInterface **iface ) | 152 | QRESULT VTApplet::queryInterface ( const QUuid &uuid, QUnknownInterface **iface ) |
145 | { | 153 | { |
146 | *iface = 0; | 154 | *iface = 0; |
147 | if ( uuid == IID_QUnknown ) | 155 | if ( uuid == IID_QUnknown ) |
148 | *iface = this; | 156 | *iface = this; |
149 | else if ( uuid == IID_MenuApplet ) | 157 | else if ( uuid == IID_MenuApplet ) |
150 | *iface = this; | 158 | *iface = this; |
151 | else | 159 | else |
152 | return QS_FALSE; | 160 | return QS_FALSE; |
153 | 161 | ||
154 | if ( *iface ) | 162 | if ( *iface ) |
155 | (*iface)-> addRef ( ); | 163 | (*iface)-> addRef ( ); |
156 | return QS_OK; | 164 | return QS_OK; |
157 | } | 165 | } |
158 | 166 | ||
159 | Q_EXPORT_INTERFACE( ) | 167 | Q_EXPORT_INTERFACE( ) |
160 | { | 168 | { |
161 | Q_CREATE_INSTANCE( VTApplet ) | 169 | Q_CREATE_INSTANCE( VTApplet ) |
162 | } | 170 | } |
163 | 171 | ||
164 | 172 | ||
diff --git a/libopie/odevice.cpp b/libopie/odevice.cpp index 21070bf..9d0bbbf 100644 --- a/libopie/odevice.cpp +++ b/libopie/odevice.cpp | |||
@@ -342,513 +342,517 @@ struct s_button { | |||
342 | "buttonsettings", "raise()" }, | 342 | "buttonsettings", "raise()" }, |
343 | { Model_SIMpad_CL4 | Model_SIMpad_SL4 | Model_SIMpad_SLC | Model_SIMpad_TSinus, | 343 | { Model_SIMpad_CL4 | Model_SIMpad_SL4 | Model_SIMpad_SLC | Model_SIMpad_TSinus, |
344 | Qt::Key_F6, QT_TRANSLATE_NOOP("Button", "Upper+Down"), | 344 | Qt::Key_F6, QT_TRANSLATE_NOOP("Button", "Upper+Down"), |
345 | "devicebuttons/simpad_upper_down", | 345 | "devicebuttons/simpad_upper_down", |
346 | "addressbook", "raise()", | 346 | "addressbook", "raise()", |
347 | "addressbook", "beamBusinessCard()" }, | 347 | "addressbook", "beamBusinessCard()" }, |
348 | { Model_SIMpad_CL4 | Model_SIMpad_SL4 | Model_SIMpad_SLC | Model_SIMpad_TSinus, | 348 | { Model_SIMpad_CL4 | Model_SIMpad_SL4 | Model_SIMpad_SLC | Model_SIMpad_TSinus, |
349 | Qt::Key_F7, QT_TRANSLATE_NOOP("Button", "Upper+Right"), | 349 | Qt::Key_F7, QT_TRANSLATE_NOOP("Button", "Upper+Right"), |
350 | "devicebuttons/simpad_upper_right", | 350 | "devicebuttons/simpad_upper_right", |
351 | "QPE/TaskBar", "toggleMenu()", | 351 | "QPE/TaskBar", "toggleMenu()", |
352 | "QPE/TaskBar", "toggleStartMenu()" }, | 352 | "QPE/TaskBar", "toggleStartMenu()" }, |
353 | { Model_SIMpad_CL4 | Model_SIMpad_SL4 | Model_SIMpad_SLC | Model_SIMpad_TSinus, | 353 | { Model_SIMpad_CL4 | Model_SIMpad_SL4 | Model_SIMpad_SLC | Model_SIMpad_TSinus, |
354 | Qt::Key_F13, QT_TRANSLATE_NOOP("Button", "Upper+Left"), | 354 | Qt::Key_F13, QT_TRANSLATE_NOOP("Button", "Upper+Left"), |
355 | "devicebuttons/simpad_upper_left", | 355 | "devicebuttons/simpad_upper_left", |
356 | "QPE/Rotation", "flip()", | 356 | "QPE/Rotation", "flip()", |
357 | "QPE/Rotation", "flip()" }, | 357 | "QPE/Rotation", "flip()" }, |
358 | /* | 358 | /* |
359 | { Model_SIMpad_CL4 | Model_SIMpad_SL4 | Model_SIMpad_SLC | Model_SIMpad_TSinus, | 359 | { Model_SIMpad_CL4 | Model_SIMpad_SL4 | Model_SIMpad_SLC | Model_SIMpad_TSinus, |
360 | Qt::Key_F12, QT_TRANSLATE_NOOP("Button", "Lower+Upper"), | 360 | Qt::Key_F12, QT_TRANSLATE_NOOP("Button", "Lower+Upper"), |
361 | "devicebuttons/simpad_lower_upper", | 361 | "devicebuttons/simpad_lower_upper", |
362 | "QPE/Launcher", "home()", | 362 | "QPE/Launcher", "home()", |
363 | "buttonsettings", "raise()" }, | 363 | "buttonsettings", "raise()" }, |
364 | { Model_SIMpad_CL4 | Model_SIMpad_SL4 | Model_SIMpad_SLC | Model_SIMpad_TSinus, | 364 | { Model_SIMpad_CL4 | Model_SIMpad_SL4 | Model_SIMpad_SLC | Model_SIMpad_TSinus, |
365 | Qt::Key_F12, QT_TRANSLATE_NOOP("Button", "Lower+Upper"), | 365 | Qt::Key_F12, QT_TRANSLATE_NOOP("Button", "Lower+Upper"), |
366 | "devicebuttons/simpad_upper_lower", | 366 | "devicebuttons/simpad_upper_lower", |
367 | "QPE/Launcher", "home()", | 367 | "QPE/Launcher", "home()", |
368 | "buttonsettings", "raise()" }, | 368 | "buttonsettings", "raise()" }, |
369 | */ | 369 | */ |
370 | }; | 370 | }; |
371 | 371 | ||
372 | class Yopy : public ODevice { | 372 | class Yopy : public ODevice { |
373 | protected: | 373 | protected: |
374 | virtual void init ( ); | 374 | virtual void init ( ); |
375 | virtual void initButtons ( ); | 375 | virtual void initButtons ( ); |
376 | 376 | ||
377 | public: | 377 | public: |
378 | virtual bool suspend ( ); | 378 | virtual bool suspend ( ); |
379 | 379 | ||
380 | virtual bool setDisplayBrightness ( int b ); | 380 | virtual bool setDisplayBrightness ( int b ); |
381 | virtual int displayBrightnessResolution ( ) const; | 381 | virtual int displayBrightnessResolution ( ) const; |
382 | 382 | ||
383 | static bool isYopy ( ); | 383 | static bool isYopy ( ); |
384 | }; | 384 | }; |
385 | 385 | ||
386 | struct yopy_button { | 386 | struct yopy_button { |
387 | Qt::Key code; | 387 | Qt::Key code; |
388 | char *utext; | 388 | char *utext; |
389 | char *pix; | 389 | char *pix; |
390 | char *fpressedservice; | 390 | char *fpressedservice; |
391 | char *fpressedaction; | 391 | char *fpressedaction; |
392 | char *fheldservice; | 392 | char *fheldservice; |
393 | char *fheldaction; | 393 | char *fheldaction; |
394 | } yopy_buttons [] = { | 394 | } yopy_buttons [] = { |
395 | { Qt::Key_F10, QT_TRANSLATE_NOOP("Button", "Action Button"), | 395 | { Qt::Key_F10, QT_TRANSLATE_NOOP("Button", "Action Button"), |
396 | "devicebuttons/yopy_action", | 396 | "devicebuttons/yopy_action", |
397 | "datebook", "nextView()", | 397 | "datebook", "nextView()", |
398 | "today", "raise()" }, | 398 | "today", "raise()" }, |
399 | { Qt::Key_F11, QT_TRANSLATE_NOOP("Button", "OK Button"), | 399 | { Qt::Key_F11, QT_TRANSLATE_NOOP("Button", "OK Button"), |
400 | "devicebuttons/yopy_ok", | 400 | "devicebuttons/yopy_ok", |
401 | "addressbook", "raise()", | 401 | "addressbook", "raise()", |
402 | "addressbook", "beamBusinessCard()" }, | 402 | "addressbook", "beamBusinessCard()" }, |
403 | { Qt::Key_F12, QT_TRANSLATE_NOOP("Button", "End Button"), | 403 | { Qt::Key_F12, QT_TRANSLATE_NOOP("Button", "End Button"), |
404 | "devicebuttons/yopy_end", | 404 | "devicebuttons/yopy_end", |
405 | "QPE/Launcher", "home()", | 405 | "QPE/Launcher", "home()", |
406 | "buttonsettings", "raise()" }, | 406 | "buttonsettings", "raise()" }, |
407 | }; | 407 | }; |
408 | 408 | ||
409 | static QCString makeChannel ( const char *str ) | 409 | static QCString makeChannel ( const char *str ) |
410 | { | 410 | { |
411 | if ( str && !::strchr ( str, '/' )) | 411 | if ( str && !::strchr ( str, '/' )) |
412 | return QCString ( "QPE/Application/" ) + str; | 412 | return QCString ( "QPE/Application/" ) + str; |
413 | else | 413 | else |
414 | return str; | 414 | return str; |
415 | } | 415 | } |
416 | 416 | ||
417 | static inline bool isQWS() | 417 | static inline bool isQWS() |
418 | { | 418 | { |
419 | return qApp ? ( qApp-> type ( ) == QApplication::GuiServer ) : false; | 419 | return qApp ? ( qApp-> type ( ) == QApplication::GuiServer ) : false; |
420 | } | 420 | } |
421 | 421 | ||
422 | ODevice *ODevice::inst ( ) | 422 | ODevice *ODevice::inst ( ) |
423 | { | 423 | { |
424 | static ODevice *dev = 0; | 424 | static ODevice *dev = 0; |
425 | 425 | ||
426 | if ( !dev ) { | 426 | if ( !dev ) { |
427 | if ( QFile::exists ( "/proc/hal/model" )) | 427 | if ( QFile::exists ( "/proc/hal/model" )) |
428 | dev = new iPAQ ( ); | 428 | dev = new iPAQ ( ); |
429 | else if ( Zaurus::isZaurus() ) | 429 | else if ( Zaurus::isZaurus() ) |
430 | dev = new Zaurus ( ); | 430 | dev = new Zaurus ( ); |
431 | else if ( QFile::exists ( "/proc/ucb1x00" ) && QFile::exists ( "/proc/cs3" )) | 431 | else if ( QFile::exists ( "/proc/ucb1x00" ) && QFile::exists ( "/proc/cs3" )) |
432 | dev = new SIMpad ( ); | 432 | dev = new SIMpad ( ); |
433 | else if ( Yopy::isYopy() ) | 433 | else if ( Yopy::isYopy() ) |
434 | dev = new Yopy ( ); | 434 | dev = new Yopy ( ); |
435 | else if ( Jornada::isJornada() ) | 435 | else if ( Jornada::isJornada() ) |
436 | dev = new Jornada ( ); | 436 | dev = new Jornada ( ); |
437 | else if ( QFile::exists ( "/proc/sys/board/sys_name" )) | 437 | else if ( QFile::exists ( "/proc/sys/board/sys_name" )) |
438 | dev = new Ramses ( ); | 438 | dev = new Ramses ( ); |
439 | else | 439 | else |
440 | dev = new ODevice ( ); | 440 | dev = new ODevice ( ); |
441 | dev-> init ( ); | 441 | dev-> init ( ); |
442 | } | 442 | } |
443 | return dev; | 443 | return dev; |
444 | } | 444 | } |
445 | 445 | ||
446 | 446 | ||
447 | /************************************************** | 447 | /************************************************** |
448 | * | 448 | * |
449 | * common | 449 | * common |
450 | * | 450 | * |
451 | **************************************************/ | 451 | **************************************************/ |
452 | 452 | ||
453 | 453 | ||
454 | ODevice::ODevice ( ) | 454 | ODevice::ODevice ( ) |
455 | { | 455 | { |
456 | d = new ODeviceData; | 456 | d = new ODeviceData; |
457 | 457 | ||
458 | d-> m_modelstr = "Unknown"; | 458 | d-> m_modelstr = "Unknown"; |
459 | d-> m_model = Model_Unknown; | 459 | d-> m_model = Model_Unknown; |
460 | d-> m_vendorstr = "Unknown"; | 460 | d-> m_vendorstr = "Unknown"; |
461 | d-> m_vendor = Vendor_Unknown; | 461 | d-> m_vendor = Vendor_Unknown; |
462 | d-> m_systemstr = "Unknown"; | 462 | d-> m_systemstr = "Unknown"; |
463 | d-> m_system = System_Unknown; | 463 | d-> m_system = System_Unknown; |
464 | d-> m_sysverstr = "0.0"; | 464 | d-> m_sysverstr = "0.0"; |
465 | d-> m_rotation = Rot0; | 465 | d-> m_rotation = Rot0; |
466 | d-> m_direction = CW; | 466 | d-> m_direction = CW; |
467 | 467 | ||
468 | d-> m_holdtime = 1000; // 1000ms | 468 | d-> m_holdtime = 1000; // 1000ms |
469 | d-> m_buttons = 0; | 469 | d-> m_buttons = 0; |
470 | d-> m_cpu_frequencies = new QStrList; | 470 | d-> m_cpu_frequencies = new QStrList; |
471 | } | 471 | } |
472 | 472 | ||
473 | void ODevice::systemMessage ( const QCString &msg, const QByteArray & ) | 473 | void ODevice::systemMessage ( const QCString &msg, const QByteArray & ) |
474 | { | 474 | { |
475 | if ( msg == "deviceButtonMappingChanged()" ) { | 475 | if ( msg == "deviceButtonMappingChanged()" ) { |
476 | reloadButtonMapping ( ); | 476 | reloadButtonMapping ( ); |
477 | } | 477 | } |
478 | } | 478 | } |
479 | 479 | ||
480 | void ODevice::init ( ) | 480 | void ODevice::init ( ) |
481 | { | 481 | { |
482 | } | 482 | } |
483 | 483 | ||
484 | /** | 484 | /** |
485 | * This method initialises the button mapping | 485 | * This method initialises the button mapping |
486 | */ | 486 | */ |
487 | void ODevice::initButtons ( ) | 487 | void ODevice::initButtons ( ) |
488 | { | 488 | { |
489 | if ( d-> m_buttons ) | 489 | if ( d-> m_buttons ) |
490 | return; | 490 | return; |
491 | 491 | ||
492 | // Simulation uses iPAQ 3660 device buttons | 492 | // Simulation uses iPAQ 3660 device buttons |
493 | 493 | ||
494 | qDebug ( "init Buttons" ); | 494 | qDebug ( "init Buttons" ); |
495 | d-> m_buttons = new QValueList <ODeviceButton>; | 495 | d-> m_buttons = new QValueList <ODeviceButton>; |
496 | 496 | ||
497 | for ( uint i = 0; i < ( sizeof( ipaq_buttons ) / sizeof( i_button )); i++ ) { | 497 | for ( uint i = 0; i < ( sizeof( ipaq_buttons ) / sizeof( i_button )); i++ ) { |
498 | i_button *ib = ipaq_buttons + i; | 498 | i_button *ib = ipaq_buttons + i; |
499 | ODeviceButton b; | 499 | ODeviceButton b; |
500 | 500 | ||
501 | if (( ib-> model & Model_iPAQ_H36xx ) == Model_iPAQ_H36xx ) { | 501 | if (( ib-> model & Model_iPAQ_H36xx ) == Model_iPAQ_H36xx ) { |
502 | b. setKeycode ( ib-> code ); | 502 | b. setKeycode ( ib-> code ); |
503 | b. setUserText ( QObject::tr ( "Button", ib-> utext )); | 503 | b. setUserText ( QObject::tr ( "Button", ib-> utext )); |
504 | b. setPixmap ( Resource::loadPixmap ( ib-> pix )); | 504 | b. setPixmap ( Resource::loadPixmap ( ib-> pix )); |
505 | b. setFactoryPresetPressedAction ( OQCopMessage ( makeChannel ( ib-> fpressedservice ), ib-> fpressedaction )); | 505 | b. setFactoryPresetPressedAction ( OQCopMessage ( makeChannel ( ib-> fpressedservice ), ib-> fpressedaction )); |
506 | b. setFactoryPresetHeldAction ( OQCopMessage ( makeChannel ( ib-> fheldservice ), ib-> fheldaction )); | 506 | b. setFactoryPresetHeldAction ( OQCopMessage ( makeChannel ( ib-> fheldservice ), ib-> fheldaction )); |
507 | d-> m_buttons-> append ( b ); | 507 | d-> m_buttons-> append ( b ); |
508 | } | 508 | } |
509 | } | 509 | } |
510 | reloadButtonMapping ( ); | 510 | reloadButtonMapping ( ); |
511 | 511 | ||
512 | QCopChannel *sysch = new QCopChannel ( "QPE/System", this ); | 512 | QCopChannel *sysch = new QCopChannel ( "QPE/System", this ); |
513 | connect ( sysch, SIGNAL( received(const QCString&,const QByteArray&)), this, SLOT( systemMessage(const QCString&,const QByteArray&))); | 513 | connect ( sysch, SIGNAL( received(const QCString&,const QByteArray&)), this, SLOT( systemMessage(const QCString&,const QByteArray&))); |
514 | } | 514 | } |
515 | 515 | ||
516 | ODevice::~ODevice ( ) | 516 | ODevice::~ODevice ( ) |
517 | { | 517 | { |
518 | // we leak m_devicebuttons and m_cpu_frequency | 518 | // we leak m_devicebuttons and m_cpu_frequency |
519 | // but it's a singleton and it is not so importantant | 519 | // but it's a singleton and it is not so importantant |
520 | // -zecke | 520 | // -zecke |
521 | delete d; | 521 | delete d; |
522 | } | 522 | } |
523 | 523 | ||
524 | bool ODevice::setSoftSuspend ( bool /*soft*/ ) | 524 | bool ODevice::setSoftSuspend ( bool /*soft*/ ) |
525 | { | 525 | { |
526 | return false; | 526 | return false; |
527 | } | 527 | } |
528 | 528 | ||
529 | //#include <linux/apm_bios.h> | 529 | //#include <linux/apm_bios.h> |
530 | 530 | ||
531 | #define APM_IOC_SUSPEND OD_IO( 'A', 2 ) | 531 | #define APM_IOC_SUSPEND OD_IO( 'A', 2 ) |
532 | 532 | ||
533 | /** | 533 | /** |
534 | * This method will try to suspend the device | 534 | * This method will try to suspend the device |
535 | * It only works if the user is the QWS Server and the apm application | 535 | * It only works if the user is the QWS Server and the apm application |
536 | * is installed. | 536 | * is installed. |
537 | * It tries to suspend and then waits some time cause some distributions | 537 | * It tries to suspend and then waits some time cause some distributions |
538 | * do have asynchronus apm implementations. | 538 | * do have asynchronus apm implementations. |
539 | * This method will either fail and return false or it'll suspend the | 539 | * This method will either fail and return false or it'll suspend the |
540 | * device and return once the device got woken up | 540 | * device and return once the device got woken up |
541 | * | 541 | * |
542 | * @return if the device got suspended | 542 | * @return if the device got suspended |
543 | */ | 543 | */ |
544 | bool ODevice::suspend ( ) | 544 | bool ODevice::suspend ( ) |
545 | { | 545 | { |
546 | qDebug("ODevice::suspend"); | 546 | qDebug("ODevice::suspend"); |
547 | if ( !isQWS( ) ) // only qwsserver is allowed to suspend | 547 | if ( !isQWS( ) ) // only qwsserver is allowed to suspend |
548 | return false; | 548 | return false; |
549 | 549 | ||
550 | if ( d-> m_model == Model_Unknown ) // better don't suspend in qvfb / on unkown devices | 550 | if ( d-> m_model == Model_Unknown ) // better don't suspend in qvfb / on unkown devices |
551 | return false; | 551 | return false; |
552 | 552 | ||
553 | bool res = false; | 553 | bool res = false; |
554 | 554 | ||
555 | struct timeval tvs, tvn; | 555 | struct timeval tvs, tvn; |
556 | ::gettimeofday ( &tvs, 0 ); | 556 | ::gettimeofday ( &tvs, 0 ); |
557 | 557 | ||
558 | ::sync ( ); // flush fs caches | 558 | ::sync ( ); // flush fs caches |
559 | res = ( ::system ( "apm --suspend" ) == 0 ); | 559 | res = ( ::system ( "apm --suspend" ) == 0 ); |
560 | 560 | ||
561 | // This is needed because the iPAQ apm implementation is asynchronous and we | 561 | // This is needed because the iPAQ apm implementation is asynchronous and we |
562 | // can not be sure when exactly the device is really suspended | 562 | // can not be sure when exactly the device is really suspended |
563 | // This can be deleted as soon as a stable familiar with a synchronous apm implementation exists. | 563 | // This can be deleted as soon as a stable familiar with a synchronous apm implementation exists. |
564 | 564 | ||
565 | if ( res ) { | 565 | if ( res ) { |
566 | do { // wait at most 1.5 sec: either suspend didn't work or the device resumed | 566 | do { // wait at most 1.5 sec: either suspend didn't work or the device resumed |
567 | ::usleep ( 200 * 1000 ); | 567 | ::usleep ( 200 * 1000 ); |
568 | ::gettimeofday ( &tvn, 0 ); | 568 | ::gettimeofday ( &tvn, 0 ); |
569 | } while ((( tvn. tv_sec - tvs. tv_sec ) * 1000 + ( tvn. tv_usec - tvs. tv_usec ) / 1000 ) < 1500 ); | 569 | } while ((( tvn. tv_sec - tvs. tv_sec ) * 1000 + ( tvn. tv_usec - tvs. tv_usec ) / 1000 ) < 1500 ); |
570 | } | 570 | } |
571 | 571 | ||
572 | return res; | 572 | return res; |
573 | } | 573 | } |
574 | 574 | ||
575 | //#include <linux/fb.h> better not rely on kernel headers in userspace ... | 575 | //#include <linux/fb.h> better not rely on kernel headers in userspace ... |
576 | 576 | ||
577 | #define FBIOBLANK OD_IO( 'F', 0x11 ) // 0x4611 | 577 | #define FBIOBLANK OD_IO( 'F', 0x11 ) // 0x4611 |
578 | 578 | ||
579 | /* VESA Blanking Levels */ | 579 | /* VESA Blanking Levels */ |
580 | #define VESA_NO_BLANKING 0 | 580 | #define VESA_NO_BLANKING 0 |
581 | #define VESA_VSYNC_SUSPEND 1 | 581 | #define VESA_VSYNC_SUSPEND 1 |
582 | #define VESA_HSYNC_SUSPEND 2 | 582 | #define VESA_HSYNC_SUSPEND 2 |
583 | #define VESA_POWERDOWN 3 | 583 | #define VESA_POWERDOWN 3 |
584 | 584 | ||
585 | /** | 585 | /** |
586 | * This sets the display on or off | 586 | * This sets the display on or off |
587 | */ | 587 | */ |
588 | bool ODevice::setDisplayStatus ( bool on ) | 588 | bool ODevice::setDisplayStatus ( bool on ) |
589 | { | 589 | { |
590 | qDebug("ODevice::setDisplayStatus(%d)", on); | 590 | qDebug("ODevice::setDisplayStatus(%d)", on); |
591 | 591 | ||
592 | if ( d-> m_model == Model_Unknown ) | 592 | if ( d-> m_model == Model_Unknown ) |
593 | return false; | 593 | return false; |
594 | 594 | ||
595 | bool res = false; | 595 | bool res = false; |
596 | int fd; | 596 | int fd; |
597 | 597 | ||
598 | #ifdef QT_QWS_DEVFS | ||
599 | if (( fd = ::open ( "/dev/fb/0", O_RDWR )) >= 0 ) { | ||
600 | #else | ||
598 | if (( fd = ::open ( "/dev/fb0", O_RDWR )) >= 0 ) { | 601 | if (( fd = ::open ( "/dev/fb0", O_RDWR )) >= 0 ) { |
602 | #endif | ||
599 | res = ( ::ioctl ( fd, FBIOBLANK, on ? VESA_NO_BLANKING : VESA_POWERDOWN ) == 0 ); | 603 | res = ( ::ioctl ( fd, FBIOBLANK, on ? VESA_NO_BLANKING : VESA_POWERDOWN ) == 0 ); |
600 | ::close ( fd ); | 604 | ::close ( fd ); |
601 | } | 605 | } |
602 | return res; | 606 | return res; |
603 | } | 607 | } |
604 | 608 | ||
605 | /** | 609 | /** |
606 | * This sets the display brightness | 610 | * This sets the display brightness |
607 | * | 611 | * |
608 | * @param p The brightness to be set on a scale from 0 to 255 | 612 | * @param p The brightness to be set on a scale from 0 to 255 |
609 | * @return success or failure | 613 | * @return success or failure |
610 | */ | 614 | */ |
611 | bool ODevice::setDisplayBrightness ( int p) | 615 | bool ODevice::setDisplayBrightness ( int p) |
612 | { | 616 | { |
613 | Q_UNUSED( p ) | 617 | Q_UNUSED( p ) |
614 | return false; | 618 | return false; |
615 | } | 619 | } |
616 | 620 | ||
617 | /** | 621 | /** |
618 | * @return returns the number of steppings on the brightness slider | 622 | * @return returns the number of steppings on the brightness slider |
619 | * in the Light-'n-Power settings. | 623 | * in the Light-'n-Power settings. |
620 | */ | 624 | */ |
621 | int ODevice::displayBrightnessResolution ( ) const | 625 | int ODevice::displayBrightnessResolution ( ) const |
622 | { | 626 | { |
623 | return 16; | 627 | return 16; |
624 | } | 628 | } |
625 | 629 | ||
626 | /** | 630 | /** |
627 | * This sets the display contrast | 631 | * This sets the display contrast |
628 | * @param p The contrast to be set on a scale from 0 to 255 | 632 | * @param p The contrast to be set on a scale from 0 to 255 |
629 | * @return success or failure | 633 | * @return success or failure |
630 | */ | 634 | */ |
631 | bool ODevice::setDisplayContrast ( int p) | 635 | bool ODevice::setDisplayContrast ( int p) |
632 | { | 636 | { |
633 | Q_UNUSED( p ) | 637 | Q_UNUSED( p ) |
634 | return false; | 638 | return false; |
635 | } | 639 | } |
636 | 640 | ||
637 | /** | 641 | /** |
638 | * @return return the max value for the brightness settings slider | 642 | * @return return the max value for the brightness settings slider |
639 | * or 0 if the device doesn't support setting of a contrast | 643 | * or 0 if the device doesn't support setting of a contrast |
640 | */ | 644 | */ |
641 | int ODevice::displayContrastResolution ( ) const | 645 | int ODevice::displayContrastResolution ( ) const |
642 | { | 646 | { |
643 | return 0; | 647 | return 0; |
644 | } | 648 | } |
645 | 649 | ||
646 | /** | 650 | /** |
647 | * This returns the vendor as string | 651 | * This returns the vendor as string |
648 | * @return Vendor as QString | 652 | * @return Vendor as QString |
649 | */ | 653 | */ |
650 | QString ODevice::vendorString ( ) const | 654 | QString ODevice::vendorString ( ) const |
651 | { | 655 | { |
652 | return d-> m_vendorstr; | 656 | return d-> m_vendorstr; |
653 | } | 657 | } |
654 | 658 | ||
655 | /** | 659 | /** |
656 | * This returns the vendor as one of the values of OVendor | 660 | * This returns the vendor as one of the values of OVendor |
657 | * @return OVendor | 661 | * @return OVendor |
658 | */ | 662 | */ |
659 | OVendor ODevice::vendor ( ) const | 663 | OVendor ODevice::vendor ( ) const |
660 | { | 664 | { |
661 | return d-> m_vendor; | 665 | return d-> m_vendor; |
662 | } | 666 | } |
663 | 667 | ||
664 | /** | 668 | /** |
665 | * This returns the model as a string | 669 | * This returns the model as a string |
666 | * @return A string representing the model | 670 | * @return A string representing the model |
667 | */ | 671 | */ |
668 | QString ODevice::modelString ( ) const | 672 | QString ODevice::modelString ( ) const |
669 | { | 673 | { |
670 | return d-> m_modelstr; | 674 | return d-> m_modelstr; |
671 | } | 675 | } |
672 | 676 | ||
673 | /** | 677 | /** |
674 | * This does return the OModel used | 678 | * This does return the OModel used |
675 | */ | 679 | */ |
676 | OModel ODevice::model ( ) const | 680 | OModel ODevice::model ( ) const |
677 | { | 681 | { |
678 | return d-> m_model; | 682 | return d-> m_model; |
679 | } | 683 | } |
680 | 684 | ||
681 | /** | 685 | /** |
682 | * This does return the systen name | 686 | * This does return the systen name |
683 | */ | 687 | */ |
684 | QString ODevice::systemString ( ) const | 688 | QString ODevice::systemString ( ) const |
685 | { | 689 | { |
686 | return d-> m_systemstr; | 690 | return d-> m_systemstr; |
687 | } | 691 | } |
688 | 692 | ||
689 | /** | 693 | /** |
690 | * Return System as OSystem value | 694 | * Return System as OSystem value |
691 | */ | 695 | */ |
692 | OSystem ODevice::system ( ) const | 696 | OSystem ODevice::system ( ) const |
693 | { | 697 | { |
694 | return d-> m_system; | 698 | return d-> m_system; |
695 | } | 699 | } |
696 | 700 | ||
697 | /** | 701 | /** |
698 | * @return the version string of the base system | 702 | * @return the version string of the base system |
699 | */ | 703 | */ |
700 | QString ODevice::systemVersionString ( ) const | 704 | QString ODevice::systemVersionString ( ) const |
701 | { | 705 | { |
702 | return d-> m_sysverstr; | 706 | return d-> m_sysverstr; |
703 | } | 707 | } |
704 | 708 | ||
705 | /** | 709 | /** |
706 | * @return the current Transformation | 710 | * @return the current Transformation |
707 | */ | 711 | */ |
708 | Transformation ODevice::rotation ( ) const | 712 | Transformation ODevice::rotation ( ) const |
709 | { | 713 | { |
710 | VirtRotation rot; | 714 | VirtRotation rot; |
711 | ODevice* that =(ODevice* )this; | 715 | ODevice* that =(ODevice* )this; |
712 | that->virtual_hook( VIRTUAL_ROTATION, &rot ); | 716 | that->virtual_hook( VIRTUAL_ROTATION, &rot ); |
713 | return rot.trans; | 717 | return rot.trans; |
714 | } | 718 | } |
715 | 719 | ||
716 | /** | 720 | /** |
717 | * @return the current rotation direction | 721 | * @return the current rotation direction |
718 | */ | 722 | */ |
719 | ODirection ODevice::direction ( ) const | 723 | ODirection ODevice::direction ( ) const |
720 | { | 724 | { |
721 | VirtDirection dir; | 725 | VirtDirection dir; |
722 | ODevice* that =(ODevice* )this; | 726 | ODevice* that =(ODevice* )this; |
723 | that->virtual_hook( VIRTUAL_DIRECTION, &dir ); | 727 | that->virtual_hook( VIRTUAL_DIRECTION, &dir ); |
724 | return dir.direct; | 728 | return dir.direct; |
725 | } | 729 | } |
726 | 730 | ||
727 | /** | 731 | /** |
728 | * This plays an alarmSound | 732 | * This plays an alarmSound |
729 | */ | 733 | */ |
730 | void ODevice::alarmSound ( ) | 734 | void ODevice::alarmSound ( ) |
731 | { | 735 | { |
732 | #ifndef QT_NO_SOUND | 736 | #ifndef QT_NO_SOUND |
733 | static Sound snd ( "alarm" ); | 737 | static Sound snd ( "alarm" ); |
734 | 738 | ||
735 | if ( snd. isFinished ( )) | 739 | if ( snd. isFinished ( )) |
736 | snd. play ( ); | 740 | snd. play ( ); |
737 | #endif | 741 | #endif |
738 | } | 742 | } |
739 | 743 | ||
740 | /** | 744 | /** |
741 | * This plays a key sound | 745 | * This plays a key sound |
742 | */ | 746 | */ |
743 | void ODevice::keySound ( ) | 747 | void ODevice::keySound ( ) |
744 | { | 748 | { |
745 | #ifndef QT_NO_SOUND | 749 | #ifndef QT_NO_SOUND |
746 | static Sound snd ( "keysound" ); | 750 | static Sound snd ( "keysound" ); |
747 | 751 | ||
748 | if ( snd. isFinished ( )) | 752 | if ( snd. isFinished ( )) |
749 | snd. play ( ); | 753 | snd. play ( ); |
750 | #endif | 754 | #endif |
751 | } | 755 | } |
752 | 756 | ||
753 | /** | 757 | /** |
754 | * This plays a touch sound | 758 | * This plays a touch sound |
755 | */ | 759 | */ |
756 | void ODevice::touchSound ( ) | 760 | void ODevice::touchSound ( ) |
757 | { | 761 | { |
758 | #ifndef QT_NO_SOUND | 762 | #ifndef QT_NO_SOUND |
759 | static Sound snd ( "touchsound" ); | 763 | static Sound snd ( "touchsound" ); |
760 | 764 | ||
761 | if ( snd. isFinished ( )) | 765 | if ( snd. isFinished ( )) |
762 | snd. play ( ); | 766 | snd. play ( ); |
763 | #endif | 767 | #endif |
764 | } | 768 | } |
765 | 769 | ||
766 | /** | 770 | /** |
767 | * This method will return a list of leds | 771 | * This method will return a list of leds |
768 | * available on this device | 772 | * available on this device |
769 | * @return a list of LEDs. | 773 | * @return a list of LEDs. |
770 | */ | 774 | */ |
771 | QValueList <OLed> ODevice::ledList ( ) const | 775 | QValueList <OLed> ODevice::ledList ( ) const |
772 | { | 776 | { |
773 | return QValueList <OLed> ( ); | 777 | return QValueList <OLed> ( ); |
774 | } | 778 | } |
775 | 779 | ||
776 | /** | 780 | /** |
777 | * This does return the state of the LEDs | 781 | * This does return the state of the LEDs |
778 | */ | 782 | */ |
779 | QValueList <OLedState> ODevice::ledStateList ( OLed /*which*/ ) const | 783 | QValueList <OLedState> ODevice::ledStateList ( OLed /*which*/ ) const |
780 | { | 784 | { |
781 | return QValueList <OLedState> ( ); | 785 | return QValueList <OLedState> ( ); |
782 | } | 786 | } |
783 | 787 | ||
784 | /** | 788 | /** |
785 | * @return the state for a given OLed | 789 | * @return the state for a given OLed |
786 | */ | 790 | */ |
787 | OLedState ODevice::ledState ( OLed /*which*/ ) const | 791 | OLedState ODevice::ledState ( OLed /*which*/ ) const |
788 | { | 792 | { |
789 | return Led_Off; | 793 | return Led_Off; |
790 | } | 794 | } |
791 | 795 | ||
792 | /** | 796 | /** |
793 | * Set the state for a LED | 797 | * Set the state for a LED |
794 | * @param which Which OLed to use | 798 | * @param which Which OLed to use |
795 | * @param st The state to set | 799 | * @param st The state to set |
796 | * @return success or failure | 800 | * @return success or failure |
797 | */ | 801 | */ |
798 | bool ODevice::setLedState ( OLed which, OLedState st ) | 802 | bool ODevice::setLedState ( OLed which, OLedState st ) |
799 | { | 803 | { |
800 | Q_UNUSED( which ) | 804 | Q_UNUSED( which ) |
801 | Q_UNUSED( st ) | 805 | Q_UNUSED( st ) |
802 | return false; | 806 | return false; |
803 | } | 807 | } |
804 | 808 | ||
805 | /** | 809 | /** |
806 | * @return if the device has a light sensor | 810 | * @return if the device has a light sensor |
807 | */ | 811 | */ |
808 | bool ODevice::hasLightSensor ( ) const | 812 | bool ODevice::hasLightSensor ( ) const |
809 | { | 813 | { |
810 | return false; | 814 | return false; |
811 | } | 815 | } |
812 | 816 | ||
813 | /** | 817 | /** |
814 | * @return a value from the light sensor | 818 | * @return a value from the light sensor |
815 | */ | 819 | */ |
816 | int ODevice::readLightSensor ( ) | 820 | int ODevice::readLightSensor ( ) |
817 | { | 821 | { |
818 | return -1; | 822 | return -1; |
819 | } | 823 | } |
820 | 824 | ||
821 | /** | 825 | /** |
822 | * @return the light sensor resolution | 826 | * @return the light sensor resolution |
823 | */ | 827 | */ |
824 | int ODevice::lightSensorResolution ( ) const | 828 | int ODevice::lightSensorResolution ( ) const |
825 | { | 829 | { |
826 | return 0; | 830 | return 0; |
827 | } | 831 | } |
828 | 832 | ||
829 | /** | 833 | /** |
830 | * @return if the device has a hinge sensor | 834 | * @return if the device has a hinge sensor |
831 | */ | 835 | */ |
832 | bool ODevice::hasHingeSensor ( ) const | 836 | bool ODevice::hasHingeSensor ( ) const |
833 | { | 837 | { |
834 | VirtHasHinge hing; | 838 | VirtHasHinge hing; |
835 | ODevice* that =(ODevice* )this; | 839 | ODevice* that =(ODevice* )this; |
836 | that->virtual_hook( VIRTUAL_HAS_HINGE, &hing ); | 840 | that->virtual_hook( VIRTUAL_HAS_HINGE, &hing ); |
837 | return hing.hasHinge; | 841 | return hing.hasHinge; |
838 | } | 842 | } |
839 | 843 | ||
840 | /** | 844 | /** |
841 | * @return a value from the hinge sensor | 845 | * @return a value from the hinge sensor |
842 | */ | 846 | */ |
843 | OHingeStatus ODevice::readHingeSensor ( ) | 847 | OHingeStatus ODevice::readHingeSensor ( ) |
844 | { | 848 | { |
845 | VirtHingeStatus hing; | 849 | VirtHingeStatus hing; |
846 | virtual_hook( VIRTUAL_HINGE, &hing ); | 850 | virtual_hook( VIRTUAL_HINGE, &hing ); |
847 | return hing.hingeStat; | 851 | return hing.hingeStat; |
848 | } | 852 | } |
849 | 853 | ||
850 | /** | 854 | /** |
851 | * @return a list with CPU frequencies supported by the hardware | 855 | * @return a list with CPU frequencies supported by the hardware |
852 | */ | 856 | */ |
853 | const QStrList &ODevice::allowedCpuFrequencies ( ) const | 857 | const QStrList &ODevice::allowedCpuFrequencies ( ) const |
854 | { | 858 | { |
diff --git a/libopie2/opiemm/osoundsystem.cpp b/libopie2/opiemm/osoundsystem.cpp index 763ff65..17e5cb0 100644 --- a/libopie2/opiemm/osoundsystem.cpp +++ b/libopie2/opiemm/osoundsystem.cpp | |||
@@ -1,317 +1,322 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of the Opie Project | 2 | This file is part of the Opie Project |
3 | 3 | ||
4 | (C) 2003 Michael 'Mickey' Lauer <mickey@tm.informatik.uni-frankfurt.de> | 4 | (C) 2003 Michael 'Mickey' Lauer <mickey@tm.informatik.uni-frankfurt.de> |
5 | =. | 5 | =. |
6 | .=l. | 6 | .=l. |
7 | .>+-= | 7 | .>+-= |
8 | _;:, .> :=|. This program is free software; you can | 8 | _;:, .> :=|. This program is free software; you can |
9 | .> <`_, > . <= redistribute it and/or modify it under | 9 | .> <`_, > . <= redistribute it and/or modify it under |
10 | :`=1 )Y*s>-.-- : the terms of the GNU Library General Public | 10 | :`=1 )Y*s>-.-- : the terms of the GNU Library General Public |
11 | .="- .-=="i, .._ License as published by the Free Software | 11 | .="- .-=="i, .._ License as published by the Free Software |
12 | - . .-<_> .<> Foundation; either version 2 of the License, | 12 | - . .-<_> .<> Foundation; either version 2 of the License, |
13 | ._= =} : or (at your option) any later version. | 13 | ._= =} : or (at your option) any later version. |
14 | .%`+i> _;_. | 14 | .%`+i> _;_. |
15 | .i_,=:_. -<s. This program is distributed in the hope that | 15 | .i_,=:_. -<s. This program is distributed in the hope that |
16 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; | 16 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; |
17 | : .. .:, . . . without even the implied warranty of | 17 | : .. .:, . . . without even the implied warranty of |
18 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A | 18 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A |
19 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU | 19 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU |
20 | ..}^=.= = ; Library General Public License for more | 20 | ..}^=.= = ; Library General Public License for more |
21 | ++= -. .` .: details. | 21 | ++= -. .` .: details. |
22 | : = ...= . :.=- | 22 | : = ...= . :.=- |
23 | -. .:....=;==+<; You should have received a copy of the GNU | 23 | -. .:....=;==+<; You should have received a copy of the GNU |
24 | -_. . . )=. = Library General Public License along with | 24 | -_. . . )=. = Library General Public License along with |
25 | -- :-=` this library; see the file COPYING.LIB. | 25 | -- :-=` this library; see the file COPYING.LIB. |
26 | If not, write to the Free Software Foundation, | 26 | If not, write to the Free Software Foundation, |
27 | Inc., 59 Temple Place - Suite 330, | 27 | Inc., 59 Temple Place - Suite 330, |
28 | Boston, MA 02111-1307, USA. | 28 | Boston, MA 02111-1307, USA. |
29 | 29 | ||
30 | */ | 30 | */ |
31 | 31 | ||
32 | #include <opie2/osoundsystem.h> | 32 | #include <opie2/osoundsystem.h> |
33 | #include <opie2/odebug.h> | 33 | #include <opie2/odebug.h> |
34 | 34 | ||
35 | #include <errno.h> | 35 | #include <errno.h> |
36 | #include <fcntl.h> | 36 | #include <fcntl.h> |
37 | #include <string.h> | 37 | #include <string.h> |
38 | #include <sys/ioctl.h> | 38 | #include <sys/ioctl.h> |
39 | #include <sys/types.h> | 39 | #include <sys/types.h> |
40 | #include <sys/soundcard.h> | 40 | #include <sys/soundcard.h> |
41 | #include <sys/stat.h> | 41 | #include <sys/stat.h> |
42 | 42 | ||
43 | 43 | ||
44 | using namespace Opie::Core; | 44 | using namespace Opie::Core; |
45 | using namespace Opie::MM; | 45 | using namespace Opie::MM; |
46 | /*====================================================================================== | 46 | /*====================================================================================== |
47 | * OSoundSystem | 47 | * OSoundSystem |
48 | *======================================================================================*/ | 48 | *======================================================================================*/ |
49 | 49 | ||
50 | OSoundSystem* OSoundSystem::_instance = 0; | 50 | OSoundSystem* OSoundSystem::_instance = 0; |
51 | 51 | ||
52 | OSoundSystem::OSoundSystem() | 52 | OSoundSystem::OSoundSystem() |
53 | { | 53 | { |
54 | odebug << "OSoundSystem::OSoundSystem()" << oendl; | 54 | odebug << "OSoundSystem::OSoundSystem()" << oendl; |
55 | synchronize(); | 55 | synchronize(); |
56 | } | 56 | } |
57 | 57 | ||
58 | void OSoundSystem::synchronize() | 58 | void OSoundSystem::synchronize() |
59 | { | 59 | { |
60 | // gather available interfaces by inspecting /dev | 60 | // gather available interfaces by inspecting /dev |
61 | //FIXME: we could use SIOCGIFCONF here, but we aren't interested in virtual (e.g. eth0:0) devices | 61 | //FIXME: we could use SIOCGIFCONF here, but we aren't interested in virtual (e.g. eth0:0) devices |
62 | //FIXME: Use SIOCGIFCONF anway, because we can disable listing of aliased devices | 62 | //FIXME: Use SIOCGIFCONF anway, because we can disable listing of aliased devices |
63 | 63 | ||
64 | _interfaces.clear(); | 64 | _interfaces.clear(); |
65 | _interfaces.insert( "soundcard", new OSoundCard( this, "soundcard" ) ); | 65 | _interfaces.insert( "soundcard", new OSoundCard( this, "soundcard" ) ); |
66 | 66 | ||
67 | 67 | ||
68 | /* | 68 | /* |
69 | 69 | ||
70 | QString str; | 70 | QString str; |
71 | QFile f( "/dev/sound" ); | 71 | QFile f( "/dev/sound" ); |
72 | bool hasFile = f.open( IO_ReadOnly ); | 72 | bool hasFile = f.open( IO_ReadOnly ); |
73 | if ( !hasFile ) | 73 | if ( !hasFile ) |
74 | { | 74 | { |
75 | odebug << "OSoundSystem: /dev/sound not existing. No sound devices available" << oendl; | 75 | odebug << "OSoundSystem: /dev/sound not existing. No sound devices available" << oendl; |
76 | return; | 76 | return; |
77 | } | 77 | } |
78 | QTextStream s( &f ); | 78 | QTextStream s( &f ); |
79 | s.readLine(); | 79 | s.readLine(); |
80 | s.readLine(); | 80 | s.readLine(); |
81 | while ( !s.atEnd() ) | 81 | while ( !s.atEnd() ) |
82 | { | 82 | { |
83 | s >> str; | 83 | s >> str; |
84 | str.truncate( str.find( ':' ) ); | 84 | str.truncate( str.find( ':' ) ); |
85 | odebug << "OSoundSystem: found interface '" << str << "'" << oendl; | 85 | odebug << "OSoundSystem: found interface '" << str << "'" << oendl; |
86 | OAudioInterface* iface; | 86 | OAudioInterface* iface; |
87 | iface = new OAudioInterface( this, (const char*) str ); | 87 | iface = new OAudioInterface( this, (const char*) str ); |
88 | 88 | ||
89 | _interfaces.insert( str, iface ); | 89 | _interfaces.insert( str, iface ); |
90 | s.readLine(); | 90 | s.readLine(); |
91 | } | 91 | } |
92 | */ | 92 | */ |
93 | } | 93 | } |
94 | 94 | ||
95 | 95 | ||
96 | int OSoundSystem::count() const | 96 | int OSoundSystem::count() const |
97 | { | 97 | { |
98 | return _interfaces.count(); | 98 | return _interfaces.count(); |
99 | } | 99 | } |
100 | 100 | ||
101 | 101 | ||
102 | OSoundCard* OSoundSystem::card( const QString& iface ) const | 102 | OSoundCard* OSoundSystem::card( const QString& iface ) const |
103 | { | 103 | { |
104 | return _interfaces[iface]; | 104 | return _interfaces[iface]; |
105 | } | 105 | } |
106 | 106 | ||
107 | 107 | ||
108 | OSoundSystem* OSoundSystem::instance() | 108 | OSoundSystem* OSoundSystem::instance() |
109 | { | 109 | { |
110 | if ( !_instance ) _instance = new OSoundSystem(); | 110 | if ( !_instance ) _instance = new OSoundSystem(); |
111 | return _instance; | 111 | return _instance; |
112 | } | 112 | } |
113 | 113 | ||
114 | 114 | ||
115 | OSoundSystem::CardIterator OSoundSystem::iterator() const | 115 | OSoundSystem::CardIterator OSoundSystem::iterator() const |
116 | { | 116 | { |
117 | return OSoundSystem::CardIterator( _interfaces ); | 117 | return OSoundSystem::CardIterator( _interfaces ); |
118 | } | 118 | } |
119 | 119 | ||
120 | 120 | ||
121 | /*====================================================================================== | 121 | /*====================================================================================== |
122 | * OSoundCard | 122 | * OSoundCard |
123 | *======================================================================================*/ | 123 | *======================================================================================*/ |
124 | 124 | ||
125 | OSoundCard::OSoundCard( QObject* parent, const char* name ) | 125 | OSoundCard::OSoundCard( QObject* parent, const char* name ) |
126 | :QObject( parent, name ), _audio( 0 ), _mixer( 0 ) | 126 | :QObject( parent, name ), _audio( 0 ), _mixer( 0 ) |
127 | { | 127 | { |
128 | odebug << "OSoundCard::OSoundCard()" << oendl; | 128 | odebug << "OSoundCard::OSoundCard()" << oendl; |
129 | init(); | 129 | init(); |
130 | } | 130 | } |
131 | 131 | ||
132 | 132 | ||
133 | OSoundCard::~OSoundCard() | 133 | OSoundCard::~OSoundCard() |
134 | { | 134 | { |
135 | } | 135 | } |
136 | 136 | ||
137 | 137 | ||
138 | void OSoundCard::init() | 138 | void OSoundCard::init() |
139 | { | 139 | { |
140 | #ifdef QT_QWS_DEVFS | ||
141 | _audio = new OAudioInterface( this, "/dev/sound/dsp" ); | ||
142 | _mixer = new OMixerInterface( this, "/dev/sound/mixer" ); | ||
143 | #else | ||
140 | _audio = new OAudioInterface( this, "/dev/dsp" ); | 144 | _audio = new OAudioInterface( this, "/dev/dsp" ); |
141 | _mixer = new OMixerInterface( this, "/dev/mixer" ); | 145 | _mixer = new OMixerInterface( this, "/dev/mixer" ); |
146 | #endif | ||
142 | } | 147 | } |
143 | 148 | ||
144 | 149 | ||
145 | /*====================================================================================== | 150 | /*====================================================================================== |
146 | * OAudioInterface | 151 | * OAudioInterface |
147 | *======================================================================================*/ | 152 | *======================================================================================*/ |
148 | 153 | ||
149 | OAudioInterface::OAudioInterface( QObject* parent, const char* name ) | 154 | OAudioInterface::OAudioInterface( QObject* parent, const char* name ) |
150 | :QObject( parent, name ), _sfd(0) | 155 | :QObject( parent, name ), _sfd(0) |
151 | { | 156 | { |
152 | odebug << "OAudioInterface::OAudioInterface()" << oendl; | 157 | odebug << "OAudioInterface::OAudioInterface()" << oendl; |
153 | init(); | 158 | init(); |
154 | } | 159 | } |
155 | 160 | ||
156 | 161 | ||
157 | OAudioInterface::~OAudioInterface() | 162 | OAudioInterface::~OAudioInterface() |
158 | { | 163 | { |
159 | } | 164 | } |
160 | 165 | ||
161 | 166 | ||
162 | void OAudioInterface::init() | 167 | void OAudioInterface::init() |
163 | { | 168 | { |
164 | 169 | ||
165 | 170 | ||
166 | } | 171 | } |
167 | 172 | ||
168 | 173 | ||
169 | /*====================================================================================== | 174 | /*====================================================================================== |
170 | * OMixerInterface | 175 | * OMixerInterface |
171 | *======================================================================================*/ | 176 | *======================================================================================*/ |
172 | 177 | ||
173 | OMixerInterface::OMixerInterface( QObject* parent, const char* name ) | 178 | OMixerInterface::OMixerInterface( QObject* parent, const char* name ) |
174 | :QObject( parent, name ) | 179 | :QObject( parent, name ) |
175 | { | 180 | { |
176 | odebug << "OMixerInterface::OMixerInterface()" << oendl; | 181 | odebug << "OMixerInterface::OMixerInterface()" << oendl; |
177 | init(); | 182 | init(); |
178 | } | 183 | } |
179 | 184 | ||
180 | 185 | ||
181 | OMixerInterface::~OMixerInterface() | 186 | OMixerInterface::~OMixerInterface() |
182 | { | 187 | { |
183 | } | 188 | } |
184 | 189 | ||
185 | 190 | ||
186 | void OMixerInterface::init() | 191 | void OMixerInterface::init() |
187 | { | 192 | { |
188 | // open the device | 193 | // open the device |
189 | _fd = ::open( name(), O_RDWR ); | 194 | _fd = ::open( name(), O_RDWR ); |
190 | if ( _fd == -1 ) | 195 | if ( _fd == -1 ) |
191 | { | 196 | { |
192 | owarn << "OMixerInterface::init(): Can't open mixer." << oendl; | 197 | owarn << "OMixerInterface::init(): Can't open mixer." << oendl; |
193 | return; | 198 | return; |
194 | } | 199 | } |
195 | 200 | ||
196 | // construct the device capabilities | 201 | // construct the device capabilities |
197 | int devmask = 0; | 202 | int devmask = 0; |
198 | if ( ioctl( _fd, SOUND_MIXER_READ_DEVMASK, &devmask ) != -1 ) | 203 | if ( ioctl( _fd, SOUND_MIXER_READ_DEVMASK, &devmask ) != -1 ) |
199 | { | 204 | { |
200 | if ( devmask & ( 1 << SOUND_MIXER_VOLUME ) ) _channels.insert( "PlayVolume", SOUND_MIXER_VOLUME ); | 205 | if ( devmask & ( 1 << SOUND_MIXER_VOLUME ) ) _channels.insert( "PlayVolume", SOUND_MIXER_VOLUME ); |
201 | if ( devmask & ( 1 << SOUND_MIXER_BASS ) ) _channels.insert( "PlayBass", SOUND_MIXER_BASS ); | 206 | if ( devmask & ( 1 << SOUND_MIXER_BASS ) ) _channels.insert( "PlayBass", SOUND_MIXER_BASS ); |
202 | if ( devmask & ( 1 << SOUND_MIXER_TREBLE ) ) _channels.insert( "PlayTreble", SOUND_MIXER_TREBLE ); | 207 | if ( devmask & ( 1 << SOUND_MIXER_TREBLE ) ) _channels.insert( "PlayTreble", SOUND_MIXER_TREBLE ); |
203 | if ( devmask & ( 1 << SOUND_MIXER_SYNTH ) ) _channels.insert( "PlaySynth", SOUND_MIXER_SYNTH ); | 208 | if ( devmask & ( 1 << SOUND_MIXER_SYNTH ) ) _channels.insert( "PlaySynth", SOUND_MIXER_SYNTH ); |
204 | if ( devmask & ( 1 << SOUND_MIXER_PCM ) ) _channels.insert( "PlayPCM", SOUND_MIXER_PCM ); | 209 | if ( devmask & ( 1 << SOUND_MIXER_PCM ) ) _channels.insert( "PlayPCM", SOUND_MIXER_PCM ); |
205 | if ( devmask & ( 1 << SOUND_MIXER_SPEAKER ) ) _channels.insert( "PlaySpeaker", SOUND_MIXER_SPEAKER ); | 210 | if ( devmask & ( 1 << SOUND_MIXER_SPEAKER ) ) _channels.insert( "PlaySpeaker", SOUND_MIXER_SPEAKER ); |
206 | if ( devmask & ( 1 << SOUND_MIXER_LINE ) ) _channels.insert( "PlayLine", SOUND_MIXER_LINE ); | 211 | if ( devmask & ( 1 << SOUND_MIXER_LINE ) ) _channels.insert( "PlayLine", SOUND_MIXER_LINE ); |
207 | if ( devmask & ( 1 << SOUND_MIXER_MIC ) ) _channels.insert( "PlayMic", SOUND_MIXER_MIC ); | 212 | if ( devmask & ( 1 << SOUND_MIXER_MIC ) ) _channels.insert( "PlayMic", SOUND_MIXER_MIC ); |
208 | if ( devmask & ( 1 << SOUND_MIXER_CD ) ) _channels.insert( "PlayCD", SOUND_MIXER_CD ); | 213 | if ( devmask & ( 1 << SOUND_MIXER_CD ) ) _channels.insert( "PlayCD", SOUND_MIXER_CD ); |
209 | if ( devmask & ( 1 << SOUND_MIXER_IMIX ) ) _channels.insert( "PlayInputMix", SOUND_MIXER_IMIX ); | 214 | if ( devmask & ( 1 << SOUND_MIXER_IMIX ) ) _channels.insert( "PlayInputMix", SOUND_MIXER_IMIX ); |
210 | if ( devmask & ( 1 << SOUND_MIXER_ALTPCM ) ) _channels.insert( "PlayAltPCM", SOUND_MIXER_ALTPCM ); | 215 | if ( devmask & ( 1 << SOUND_MIXER_ALTPCM ) ) _channels.insert( "PlayAltPCM", SOUND_MIXER_ALTPCM ); |
211 | if ( devmask & ( 1 << SOUND_MIXER_RECLEV ) ) _channels.insert( "PlayRecord", SOUND_MIXER_RECLEV ); | 216 | if ( devmask & ( 1 << SOUND_MIXER_RECLEV ) ) _channels.insert( "PlayRecord", SOUND_MIXER_RECLEV ); |
212 | if ( devmask & ( 1 << SOUND_MIXER_IGAIN ) ) _channels.insert( "PlayInputGain", SOUND_MIXER_IGAIN ); | 217 | if ( devmask & ( 1 << SOUND_MIXER_IGAIN ) ) _channels.insert( "PlayInputGain", SOUND_MIXER_IGAIN ); |
213 | if ( devmask & ( 1 << SOUND_MIXER_OGAIN ) ) _channels.insert( "PlayOutputGain", SOUND_MIXER_OGAIN ); | 218 | if ( devmask & ( 1 << SOUND_MIXER_OGAIN ) ) _channels.insert( "PlayOutputGain", SOUND_MIXER_OGAIN ); |
214 | //odebug << "devmask available and constructed." << oendl; | 219 | //odebug << "devmask available and constructed." << oendl; |
215 | } | 220 | } |
216 | 221 | ||
217 | devmask = 0; | 222 | devmask = 0; |
218 | if ( ioctl( _fd, SOUND_MIXER_READ_RECMASK, &devmask ) != -1 ) | 223 | if ( ioctl( _fd, SOUND_MIXER_READ_RECMASK, &devmask ) != -1 ) |
219 | { | 224 | { |
220 | if ( devmask & ( 1 << SOUND_MIXER_VOLUME ) ) _channels.insert( "RecVolume", SOUND_MIXER_VOLUME ); | 225 | if ( devmask & ( 1 << SOUND_MIXER_VOLUME ) ) _channels.insert( "RecVolume", SOUND_MIXER_VOLUME ); |
221 | if ( devmask & ( 1 << SOUND_MIXER_BASS ) ) _channels.insert( "RecBass", SOUND_MIXER_BASS ); | 226 | if ( devmask & ( 1 << SOUND_MIXER_BASS ) ) _channels.insert( "RecBass", SOUND_MIXER_BASS ); |
222 | if ( devmask & ( 1 << SOUND_MIXER_TREBLE ) ) _channels.insert( "RecTreble", SOUND_MIXER_TREBLE ); | 227 | if ( devmask & ( 1 << SOUND_MIXER_TREBLE ) ) _channels.insert( "RecTreble", SOUND_MIXER_TREBLE ); |
223 | if ( devmask & ( 1 << SOUND_MIXER_SYNTH ) ) _channels.insert( "RecSynth", SOUND_MIXER_SYNTH ); | 228 | if ( devmask & ( 1 << SOUND_MIXER_SYNTH ) ) _channels.insert( "RecSynth", SOUND_MIXER_SYNTH ); |
224 | if ( devmask & ( 1 << SOUND_MIXER_PCM ) ) _channels.insert( "RecPCM", SOUND_MIXER_PCM ); | 229 | if ( devmask & ( 1 << SOUND_MIXER_PCM ) ) _channels.insert( "RecPCM", SOUND_MIXER_PCM ); |
225 | if ( devmask & ( 1 << SOUND_MIXER_SPEAKER ) ) _channels.insert( "RecSpeaker", SOUND_MIXER_SPEAKER ); | 230 | if ( devmask & ( 1 << SOUND_MIXER_SPEAKER ) ) _channels.insert( "RecSpeaker", SOUND_MIXER_SPEAKER ); |
226 | if ( devmask & ( 1 << SOUND_MIXER_LINE ) ) _channels.insert( "RecLine", SOUND_MIXER_LINE ); | 231 | if ( devmask & ( 1 << SOUND_MIXER_LINE ) ) _channels.insert( "RecLine", SOUND_MIXER_LINE ); |
227 | if ( devmask & ( 1 << SOUND_MIXER_MIC ) ) _channels.insert( "RecMic", SOUND_MIXER_MIC ); | 232 | if ( devmask & ( 1 << SOUND_MIXER_MIC ) ) _channels.insert( "RecMic", SOUND_MIXER_MIC ); |
228 | if ( devmask & ( 1 << SOUND_MIXER_CD ) ) _channels.insert( "RecCD", SOUND_MIXER_CD ); | 233 | if ( devmask & ( 1 << SOUND_MIXER_CD ) ) _channels.insert( "RecCD", SOUND_MIXER_CD ); |
229 | if ( devmask & ( 1 << SOUND_MIXER_IMIX ) ) _channels.insert( "RecInputMix", SOUND_MIXER_IMIX ); | 234 | if ( devmask & ( 1 << SOUND_MIXER_IMIX ) ) _channels.insert( "RecInputMix", SOUND_MIXER_IMIX ); |
230 | if ( devmask & ( 1 << SOUND_MIXER_ALTPCM ) ) _channels.insert( "RecAltPCM", SOUND_MIXER_ALTPCM ); | 235 | if ( devmask & ( 1 << SOUND_MIXER_ALTPCM ) ) _channels.insert( "RecAltPCM", SOUND_MIXER_ALTPCM ); |
231 | if ( devmask & ( 1 << SOUND_MIXER_RECLEV ) ) _channels.insert( "RecRecord", SOUND_MIXER_RECLEV ); | 236 | if ( devmask & ( 1 << SOUND_MIXER_RECLEV ) ) _channels.insert( "RecRecord", SOUND_MIXER_RECLEV ); |
232 | if ( devmask & ( 1 << SOUND_MIXER_IGAIN ) ) _channels.insert( "RecInputGain", SOUND_MIXER_IGAIN ); | 237 | if ( devmask & ( 1 << SOUND_MIXER_IGAIN ) ) _channels.insert( "RecInputGain", SOUND_MIXER_IGAIN ); |
233 | if ( devmask & ( 1 << SOUND_MIXER_OGAIN ) ) _channels.insert( "RecOutputGain", SOUND_MIXER_OGAIN ); | 238 | if ( devmask & ( 1 << SOUND_MIXER_OGAIN ) ) _channels.insert( "RecOutputGain", SOUND_MIXER_OGAIN ); |
234 | //odebug << "recmask available and constructed." << oendl; | 239 | //odebug << "recmask available and constructed." << oendl; |
235 | } | 240 | } |
236 | 241 | ||
237 | /* ChannelIterator it; | 242 | /* ChannelIterator it; |
238 | for ( it = _channels.begin(); it != _channels.end(); ++it ) | 243 | for ( it = _channels.begin(); it != _channels.end(); ++it ) |
239 | { | 244 | { |
240 | odebug << "Channel " << it.key() << " available (bit " << it.data() << ")" << oendl; | 245 | odebug << "Channel " << it.key() << " available (bit " << it.data() << ")" << oendl; |
241 | odebug << " +--- Volume: " << volume( it.key() ) & 0xff << " | " << volume( it.key() ) >> 8 << "" << oendl; | 246 | odebug << " +--- Volume: " << volume( it.key() ) & 0xff << " | " << volume( it.key() ) >> 8 << "" << oendl; |
242 | } | 247 | } |
243 | */ | 248 | */ |
244 | } | 249 | } |
245 | 250 | ||
246 | QStringList OMixerInterface::allChannels() const | 251 | QStringList OMixerInterface::allChannels() const |
247 | { | 252 | { |
248 | ChannelIterator it = _channels.begin(); | 253 | ChannelIterator it = _channels.begin(); |
249 | QStringList channels; | 254 | QStringList channels; |
250 | while ( it != _channels.end() ) | 255 | while ( it != _channels.end() ) |
251 | { | 256 | { |
252 | channels += it.key(); | 257 | channels += it.key(); |
253 | it++; | 258 | it++; |
254 | } | 259 | } |
255 | return channels; | 260 | return channels; |
256 | } | 261 | } |
257 | 262 | ||
258 | 263 | ||
259 | QStringList OMixerInterface::recChannels() const | 264 | QStringList OMixerInterface::recChannels() const |
260 | { | 265 | { |
261 | owarn << "NYI" << oendl; | 266 | owarn << "NYI" << oendl; |
262 | return QStringList(); | 267 | return QStringList(); |
263 | } | 268 | } |
264 | 269 | ||
265 | 270 | ||
266 | QStringList OMixerInterface::playChannels() const | 271 | QStringList OMixerInterface::playChannels() const |
267 | { | 272 | { |
268 | owarn << "NYI" << oendl; | 273 | owarn << "NYI" << oendl; |
269 | return QStringList(); | 274 | return QStringList(); |
270 | } | 275 | } |
271 | 276 | ||
272 | 277 | ||
273 | bool OMixerInterface::hasChannel( const QString& channel ) | 278 | bool OMixerInterface::hasChannel( const QString& channel ) |
274 | { | 279 | { |
275 | return _channels.contains( channel ); | 280 | return _channels.contains( channel ); |
276 | } | 281 | } |
277 | 282 | ||
278 | 283 | ||
279 | void OMixerInterface::setVolume( const QString& channel, int left, int right ) | 284 | void OMixerInterface::setVolume( const QString& channel, int left, int right ) |
280 | { | 285 | { |
281 | int volume = left; | 286 | int volume = left; |
282 | volume |= ( right == -1 ) ? left << 8 : right << 8; | 287 | volume |= ( right == -1 ) ? left << 8 : right << 8; |
283 | 288 | ||
284 | if ( _channels.contains( channel ) ) | 289 | if ( _channels.contains( channel ) ) |
285 | { | 290 | { |
286 | int result = ioctl( _fd, MIXER_WRITE( _channels[channel] ), &volume ); | 291 | int result = ioctl( _fd, MIXER_WRITE( _channels[channel] ), &volume ); |
287 | if ( result == -1 ) | 292 | if ( result == -1 ) |
288 | { | 293 | { |
289 | owarn << "Can't set volume: " << strerror( errno ) << oendl; | 294 | owarn << "Can't set volume: " << strerror( errno ) << oendl; |
290 | } | 295 | } |
291 | else | 296 | else |
292 | { | 297 | { |
293 | if ( result & 0xff != left ) | 298 | if ( result & 0xff != left ) |
294 | { | 299 | { |
295 | owarn << "Device adjusted volume from " << left << " to " << (result & 0xff) << oendl; | 300 | owarn << "Device adjusted volume from " << left << " to " << (result & 0xff) << oendl; |
296 | } | 301 | } |
297 | } | 302 | } |
298 | } | 303 | } |
299 | } | 304 | } |
300 | 305 | ||
301 | 306 | ||
302 | int OMixerInterface::volume( const QString& channel ) const | 307 | int OMixerInterface::volume( const QString& channel ) const |
303 | { | 308 | { |
304 | int volume; | 309 | int volume; |
305 | 310 | ||
306 | if ( _channels.contains( channel ) ) | 311 | if ( _channels.contains( channel ) ) |
307 | { | 312 | { |
308 | if ( ioctl( _fd, MIXER_READ( _channels[channel] ), &volume ) == -1 ) | 313 | if ( ioctl( _fd, MIXER_READ( _channels[channel] ), &volume ) == -1 ) |
309 | { | 314 | { |
310 | owarn << "Can't get volume: " << strerror( errno ) << oendl; | 315 | owarn << "Can't get volume: " << strerror( errno ) << oendl; |
311 | } | 316 | } |
312 | else return volume; | 317 | else return volume; |
313 | } | 318 | } |
314 | return -1; | 319 | return -1; |
315 | } | 320 | } |
316 | 321 | ||
317 | 322 | ||
diff --git a/library/qpeapplication.cpp b/library/qpeapplication.cpp index c6d9cfd..ca90427 100644 --- a/library/qpeapplication.cpp +++ b/library/qpeapplication.cpp | |||
@@ -312,584 +312,600 @@ static void qpe_show_dialog( QDialog* d, bool nomax ) | |||
312 | maximized = TRUE; | 312 | maximized = TRUE; |
313 | // 350 is the trigger in qwsdefaultdecoration for providing a resize button | 313 | // 350 is the trigger in qwsdefaultdecoration for providing a resize button |
314 | if ( qApp->desktop()->width() <= 350 ) | 314 | if ( qApp->desktop()->width() <= 350 ) |
315 | return FALSE; | 315 | return FALSE; |
316 | 316 | ||
317 | Config cfg( "qpe" ); | 317 | Config cfg( "qpe" ); |
318 | cfg.setGroup("ApplicationPositions"); | 318 | cfg.setGroup("ApplicationPositions"); |
319 | QString str = cfg.readEntry( app, QString::null ); | 319 | QString str = cfg.readEntry( app, QString::null ); |
320 | QStringList l = QStringList::split(",", str); | 320 | QStringList l = QStringList::split(",", str); |
321 | 321 | ||
322 | if ( l.count() == 5) { | 322 | if ( l.count() == 5) { |
323 | p.setX( l[0].toInt() ); | 323 | p.setX( l[0].toInt() ); |
324 | p.setY( l[1].toInt() ); | 324 | p.setY( l[1].toInt() ); |
325 | 325 | ||
326 | s.setWidth( l[2].toInt() ); | 326 | s.setWidth( l[2].toInt() ); |
327 | s.setHeight( l[3].toInt() ); | 327 | s.setHeight( l[3].toInt() ); |
328 | 328 | ||
329 | maximized = l[4].toInt(); | 329 | maximized = l[4].toInt(); |
330 | 330 | ||
331 | return TRUE; | 331 | return TRUE; |
332 | } | 332 | } |
333 | 333 | ||
334 | return FALSE; | 334 | return FALSE; |
335 | } | 335 | } |
336 | 336 | ||
337 | 337 | ||
338 | static bool validate_widget_size(const QWidget *w, QPoint &p, QSize &s) | 338 | static bool validate_widget_size(const QWidget *w, QPoint &p, QSize &s) |
339 | { | 339 | { |
340 | #ifndef Q_WS_QWS | 340 | #ifndef Q_WS_QWS |
341 | QRect qt_maxWindowRect = qApp->desktop()->geometry(); | 341 | QRect qt_maxWindowRect = qApp->desktop()->geometry(); |
342 | #endif | 342 | #endif |
343 | int maxX = qt_maxWindowRect.width(); | 343 | int maxX = qt_maxWindowRect.width(); |
344 | int maxY = qt_maxWindowRect.height(); | 344 | int maxY = qt_maxWindowRect.height(); |
345 | int wWidth = s.width() + ( w->frameGeometry().width() - w->geometry().width() ); | 345 | int wWidth = s.width() + ( w->frameGeometry().width() - w->geometry().width() ); |
346 | int wHeight = s.height() + ( w->frameGeometry().height() - w->geometry().height() ); | 346 | int wHeight = s.height() + ( w->frameGeometry().height() - w->geometry().height() ); |
347 | 347 | ||
348 | // total window size is not allowed to be larger than desktop window size | 348 | // total window size is not allowed to be larger than desktop window size |
349 | if ( ( wWidth >= maxX ) && ( wHeight >= maxY ) ) | 349 | if ( ( wWidth >= maxX ) && ( wHeight >= maxY ) ) |
350 | return FALSE; | 350 | return FALSE; |
351 | 351 | ||
352 | if ( wWidth > maxX ) { | 352 | if ( wWidth > maxX ) { |
353 | s.setWidth( maxX - (w->frameGeometry().width() - w->geometry().width() ) ); | 353 | s.setWidth( maxX - (w->frameGeometry().width() - w->geometry().width() ) ); |
354 | wWidth = maxX; | 354 | wWidth = maxX; |
355 | } | 355 | } |
356 | 356 | ||
357 | if ( wHeight > maxY ) { | 357 | if ( wHeight > maxY ) { |
358 | s.setHeight( maxY - (w->frameGeometry().height() - w->geometry().height() ) ); | 358 | s.setHeight( maxY - (w->frameGeometry().height() - w->geometry().height() ) ); |
359 | wHeight = maxY; | 359 | wHeight = maxY; |
360 | } | 360 | } |
361 | 361 | ||
362 | // any smaller than this and the maximize/close/help buttons will be overlapping | 362 | // any smaller than this and the maximize/close/help buttons will be overlapping |
363 | if ( wWidth < 80 || wHeight < 60 ) | 363 | if ( wWidth < 80 || wHeight < 60 ) |
364 | return FALSE; | 364 | return FALSE; |
365 | 365 | ||
366 | if ( p.x() < 0 ) | 366 | if ( p.x() < 0 ) |
367 | p.setX(0); | 367 | p.setX(0); |
368 | if ( p.y() < 0 ) | 368 | if ( p.y() < 0 ) |
369 | p.setY(0); | 369 | p.setY(0); |
370 | 370 | ||
371 | if ( p.x() + wWidth > maxX ) | 371 | if ( p.x() + wWidth > maxX ) |
372 | p.setX( maxX - wWidth ); | 372 | p.setX( maxX - wWidth ); |
373 | if ( p.y() + wHeight > maxY ) | 373 | if ( p.y() + wHeight > maxY ) |
374 | p.setY( maxY - wHeight ); | 374 | p.setY( maxY - wHeight ); |
375 | 375 | ||
376 | return TRUE; | 376 | return TRUE; |
377 | } | 377 | } |
378 | 378 | ||
379 | static void store_widget_rect(QWidget *w, QString &app) | 379 | static void store_widget_rect(QWidget *w, QString &app) |
380 | { | 380 | { |
381 | // 350 is the trigger in qwsdefaultdecoration for providing a resize button | 381 | // 350 is the trigger in qwsdefaultdecoration for providing a resize button |
382 | if ( qApp->desktop()->width() <= 350 ) | 382 | if ( qApp->desktop()->width() <= 350 ) |
383 | return; | 383 | return; |
384 | // we use these to map the offset of geometry and pos. ( we can only use normalGeometry to | 384 | // we use these to map the offset of geometry and pos. ( we can only use normalGeometry to |
385 | // get the non-maximized version, so we have to do it the hard way ) | 385 | // get the non-maximized version, so we have to do it the hard way ) |
386 | int offsetX = w->x() - w->geometry().left(); | 386 | int offsetX = w->x() - w->geometry().left(); |
387 | int offsetY = w->y() - w->geometry().top(); | 387 | int offsetY = w->y() - w->geometry().top(); |
388 | 388 | ||
389 | QRect r; | 389 | QRect r; |
390 | if ( w->isMaximized() ) | 390 | if ( w->isMaximized() ) |
391 | r = ( (HackWidget *) w)->normalGeometry(); | 391 | r = ( (HackWidget *) w)->normalGeometry(); |
392 | else | 392 | else |
393 | r = w->geometry(); | 393 | r = w->geometry(); |
394 | 394 | ||
395 | // Stores the window placement as pos(), size() (due to the offset mapping) | 395 | // Stores the window placement as pos(), size() (due to the offset mapping) |
396 | Config cfg( "qpe" ); | 396 | Config cfg( "qpe" ); |
397 | cfg.setGroup("ApplicationPositions"); | 397 | cfg.setGroup("ApplicationPositions"); |
398 | QString s; | 398 | QString s; |
399 | s.sprintf("%d,%d,%d,%d,%d", r.left() + offsetX, r.top() + offsetY, r.width(), r.height(), w->isMaximized() ); | 399 | s.sprintf("%d,%d,%d,%d,%d", r.left() + offsetX, r.top() + offsetY, r.width(), r.height(), w->isMaximized() ); |
400 | cfg.writeEntry( app, s ); | 400 | cfg.writeEntry( app, s ); |
401 | } | 401 | } |
402 | 402 | ||
403 | static bool setWidgetCaptionFromAppName( QWidget* /*mw*/, const QString& /*appName*/, const QString& /*appsPath*/ ) | 403 | static bool setWidgetCaptionFromAppName( QWidget* /*mw*/, const QString& /*appName*/, const QString& /*appsPath*/ ) |
404 | { | 404 | { |
405 | /* | 405 | /* |
406 | // This works but disable it for now until it is safe to apply | 406 | // This works but disable it for now until it is safe to apply |
407 | // What is does is scan the .desktop files of all the apps for | 407 | // What is does is scan the .desktop files of all the apps for |
408 | // the applnk that has the corresponding argv[0] as this program | 408 | // the applnk that has the corresponding argv[0] as this program |
409 | // then it uses the name stored in the .desktop file as the caption | 409 | // then it uses the name stored in the .desktop file as the caption |
410 | // for the main widget. This saves duplicating translations for | 410 | // for the main widget. This saves duplicating translations for |
411 | // the app name in the program and in the .desktop files. | 411 | // the app name in the program and in the .desktop files. |
412 | 412 | ||
413 | AppLnkSet apps( appsPath ); | 413 | AppLnkSet apps( appsPath ); |
414 | 414 | ||
415 | QList<AppLnk> appsList = apps.children(); | 415 | QList<AppLnk> appsList = apps.children(); |
416 | for ( QListIterator<AppLnk> it(appsList); it.current(); ++it ) { | 416 | for ( QListIterator<AppLnk> it(appsList); it.current(); ++it ) { |
417 | if ( (*it)->exec() == appName ) { | 417 | if ( (*it)->exec() == appName ) { |
418 | mw->setCaption( (*it)->name() ); | 418 | mw->setCaption( (*it)->name() ); |
419 | return TRUE; | 419 | return TRUE; |
420 | } | 420 | } |
421 | } | 421 | } |
422 | */ | 422 | */ |
423 | return FALSE; | 423 | return FALSE; |
424 | } | 424 | } |
425 | 425 | ||
426 | 426 | ||
427 | void show(QWidget* mw, bool nomax) | 427 | void show(QWidget* mw, bool nomax) |
428 | { | 428 | { |
429 | setWidgetCaptionFromAppName( mw, appName, QPEApplication::qpeDir() + "apps" ); | 429 | setWidgetCaptionFromAppName( mw, appName, QPEApplication::qpeDir() + "apps" ); |
430 | nomaximize = nomax; | 430 | nomaximize = nomax; |
431 | qpe_main_widget = mw; | 431 | qpe_main_widget = mw; |
432 | qcopQok = TRUE; | 432 | qcopQok = TRUE; |
433 | #ifndef QT_NO_COP | 433 | #ifndef QT_NO_COP |
434 | 434 | ||
435 | sendQCopQ(); | 435 | sendQCopQ(); |
436 | #endif | 436 | #endif |
437 | 437 | ||
438 | if ( preloaded ) { | 438 | if ( preloaded ) { |
439 | if (forceshow) | 439 | if (forceshow) |
440 | show_mx(mw, nomax, appName); | 440 | show_mx(mw, nomax, appName); |
441 | } | 441 | } |
442 | else if ( keep_running ) { | 442 | else if ( keep_running ) { |
443 | show_mx(mw, nomax, appName); | 443 | show_mx(mw, nomax, appName); |
444 | } | 444 | } |
445 | } | 445 | } |
446 | 446 | ||
447 | void loadTextCodecs() | 447 | void loadTextCodecs() |
448 | { | 448 | { |
449 | QString path = QPEApplication::qpeDir() + "/plugins/textcodecs"; | 449 | QString path = QPEApplication::qpeDir() + "/plugins/textcodecs"; |
450 | #ifdef Q_OS_MACX | 450 | #ifdef Q_OS_MACX |
451 | QDir dir( path, "lib*.dylib" ); | 451 | QDir dir( path, "lib*.dylib" ); |
452 | #else | 452 | #else |
453 | QDir dir( path, "lib*.so" ); | 453 | QDir dir( path, "lib*.so" ); |
454 | #endif | 454 | #endif |
455 | QStringList list; | 455 | QStringList list; |
456 | if ( dir. exists ( )) | 456 | if ( dir. exists ( )) |
457 | list = dir.entryList(); | 457 | list = dir.entryList(); |
458 | QStringList::Iterator it; | 458 | QStringList::Iterator it; |
459 | for ( it = list.begin(); it != list.end(); ++it ) { | 459 | for ( it = list.begin(); it != list.end(); ++it ) { |
460 | TextCodecInterface *iface = 0; | 460 | TextCodecInterface *iface = 0; |
461 | QLibrary *lib = new QLibrary( path + "/" + *it ); | 461 | QLibrary *lib = new QLibrary( path + "/" + *it ); |
462 | if ( lib->queryInterface( IID_QtopiaTextCodec, (QUnknownInterface**)&iface ) == QS_OK && iface ) { | 462 | if ( lib->queryInterface( IID_QtopiaTextCodec, (QUnknownInterface**)&iface ) == QS_OK && iface ) { |
463 | QValueList<int> mibs = iface->mibEnums(); | 463 | QValueList<int> mibs = iface->mibEnums(); |
464 | for (QValueList<int>::ConstIterator i = mibs.begin(); i != mibs.end(); ++i) { | 464 | for (QValueList<int>::ConstIterator i = mibs.begin(); i != mibs.end(); ++i) { |
465 | (void)iface->createForMib(*i); | 465 | (void)iface->createForMib(*i); |
466 | // ### it exists now; need to remember if we can delete it | 466 | // ### it exists now; need to remember if we can delete it |
467 | } | 467 | } |
468 | } | 468 | } |
469 | else { | 469 | else { |
470 | lib->unload(); | 470 | lib->unload(); |
471 | delete lib; | 471 | delete lib; |
472 | } | 472 | } |
473 | } | 473 | } |
474 | } | 474 | } |
475 | 475 | ||
476 | void loadImageCodecs() | 476 | void loadImageCodecs() |
477 | { | 477 | { |
478 | QString path = QPEApplication::qpeDir() + "/plugins/imagecodecs"; | 478 | QString path = QPEApplication::qpeDir() + "/plugins/imagecodecs"; |
479 | #ifdef Q_OS_MACX | 479 | #ifdef Q_OS_MACX |
480 | QDir dir( path, "lib*.dylib" ); | 480 | QDir dir( path, "lib*.dylib" ); |
481 | #else | 481 | #else |
482 | QDir dir( path, "lib*.so" ); | 482 | QDir dir( path, "lib*.so" ); |
483 | #endif | 483 | #endif |
484 | QStringList list; | 484 | QStringList list; |
485 | if ( dir. exists ( )) | 485 | if ( dir. exists ( )) |
486 | list = dir.entryList(); | 486 | list = dir.entryList(); |
487 | QStringList::Iterator it; | 487 | QStringList::Iterator it; |
488 | for ( it = list.begin(); it != list.end(); ++it ) { | 488 | for ( it = list.begin(); it != list.end(); ++it ) { |
489 | ImageCodecInterface *iface = 0; | 489 | ImageCodecInterface *iface = 0; |
490 | QLibrary *lib = new QLibrary( path + "/" + *it ); | 490 | QLibrary *lib = new QLibrary( path + "/" + *it ); |
491 | if ( lib->queryInterface( IID_QtopiaImageCodec, (QUnknownInterface**)&iface ) == QS_OK && iface ) { | 491 | if ( lib->queryInterface( IID_QtopiaImageCodec, (QUnknownInterface**)&iface ) == QS_OK && iface ) { |
492 | QStringList formats = iface->keys(); | 492 | QStringList formats = iface->keys(); |
493 | for (QStringList::ConstIterator i = formats.begin(); i != formats.end(); ++i) { | 493 | for (QStringList::ConstIterator i = formats.begin(); i != formats.end(); ++i) { |
494 | (void)iface->installIOHandler(*i); | 494 | (void)iface->installIOHandler(*i); |
495 | // ### it exists now; need to remember if we can delete it | 495 | // ### it exists now; need to remember if we can delete it |
496 | } | 496 | } |
497 | } | 497 | } |
498 | else { | 498 | else { |
499 | lib->unload(); | 499 | lib->unload(); |
500 | delete lib; | 500 | delete lib; |
501 | } | 501 | } |
502 | } | 502 | } |
503 | } | 503 | } |
504 | 504 | ||
505 | }; | 505 | }; |
506 | 506 | ||
507 | class ResourceMimeFactory : public QMimeSourceFactory | 507 | class ResourceMimeFactory : public QMimeSourceFactory |
508 | { | 508 | { |
509 | public: | 509 | public: |
510 | ResourceMimeFactory() : resImage( 0 ) | 510 | ResourceMimeFactory() : resImage( 0 ) |
511 | { | 511 | { |
512 | setFilePath( Global::helpPath() ); | 512 | setFilePath( Global::helpPath() ); |
513 | setExtensionType( "html", "text/html;charset=UTF-8" ); | 513 | setExtensionType( "html", "text/html;charset=UTF-8" ); |
514 | } | 514 | } |
515 | ~ResourceMimeFactory() { | 515 | ~ResourceMimeFactory() { |
516 | delete resImage; | 516 | delete resImage; |
517 | } | 517 | } |
518 | 518 | ||
519 | const QMimeSource* data( const QString& abs_name ) const | 519 | const QMimeSource* data( const QString& abs_name ) const |
520 | { | 520 | { |
521 | const QMimeSource * r = QMimeSourceFactory::data( abs_name ); | 521 | const QMimeSource * r = QMimeSourceFactory::data( abs_name ); |
522 | if ( !r ) { | 522 | if ( !r ) { |
523 | int sl = abs_name.length(); | 523 | int sl = abs_name.length(); |
524 | do { | 524 | do { |
525 | sl = abs_name.findRev( '/', sl - 1 ); | 525 | sl = abs_name.findRev( '/', sl - 1 ); |
526 | QString name = sl >= 0 ? abs_name.mid( sl + 1 ) : abs_name; | 526 | QString name = sl >= 0 ? abs_name.mid( sl + 1 ) : abs_name; |
527 | int dot = name.findRev( '.' ); | 527 | int dot = name.findRev( '.' ); |
528 | if ( dot >= 0 ) | 528 | if ( dot >= 0 ) |
529 | name = name.left( dot ); | 529 | name = name.left( dot ); |
530 | QImage img = Resource::loadImage( name ); | 530 | QImage img = Resource::loadImage( name ); |
531 | if ( !img.isNull() ) { | 531 | if ( !img.isNull() ) { |
532 | delete resImage; | 532 | delete resImage; |
533 | resImage = new QImageDrag( img ); | 533 | resImage = new QImageDrag( img ); |
534 | r = resImage; | 534 | r = resImage; |
535 | } | 535 | } |
536 | } | 536 | } |
537 | while ( !r && sl > 0 ); | 537 | while ( !r && sl > 0 ); |
538 | } | 538 | } |
539 | return r; | 539 | return r; |
540 | } | 540 | } |
541 | private: | 541 | private: |
542 | mutable QImageDrag *resImage; | 542 | mutable QImageDrag *resImage; |
543 | }; | 543 | }; |
544 | 544 | ||
545 | static int& hack(int& i) | 545 | static int& hack(int& i) |
546 | { | 546 | { |
547 | #if QT_VERSION <= 230 && defined(QT_NO_CODECS) | 547 | #if QT_VERSION <= 230 && defined(QT_NO_CODECS) |
548 | // These should be created, but aren't in Qt 2.3.0 | 548 | // These should be created, but aren't in Qt 2.3.0 |
549 | (void)new QUtf8Codec; | 549 | (void)new QUtf8Codec; |
550 | (void)new QUtf16Codec; | 550 | (void)new QUtf16Codec; |
551 | #endif | 551 | #endif |
552 | return i; | 552 | return i; |
553 | } | 553 | } |
554 | 554 | ||
555 | static int muted = 0; | 555 | static int muted = 0; |
556 | static int micMuted = 0; | 556 | static int micMuted = 0; |
557 | 557 | ||
558 | static void setVolume( int t = 0, int percent = -1 ) | 558 | static void setVolume( int t = 0, int percent = -1 ) |
559 | { | 559 | { |
560 | switch ( t ) { | 560 | switch ( t ) { |
561 | case 0: { | 561 | case 0: { |
562 | Config cfg( "qpe" ); | 562 | Config cfg( "qpe" ); |
563 | cfg.setGroup( "Volume" ); | 563 | cfg.setGroup( "Volume" ); |
564 | if ( percent < 0 ) | 564 | if ( percent < 0 ) |
565 | percent = cfg.readNumEntry( "VolumePercent", 50 ); | 565 | percent = cfg.readNumEntry( "VolumePercent", 50 ); |
566 | #ifndef QT_NO_SOUND | 566 | #ifndef QT_NO_SOUND |
567 | int fd = 0; | 567 | int fd = 0; |
568 | #ifdef QT_QWS_DEVFS | ||
569 | if ( ( fd = open( "/dev/sound/mixer", O_RDWR ) ) >= 0 ) { | ||
570 | #else | ||
568 | if ( ( fd = open( "/dev/mixer", O_RDWR ) ) >= 0 ) { | 571 | if ( ( fd = open( "/dev/mixer", O_RDWR ) ) >= 0 ) { |
572 | #endif | ||
569 | int vol = muted ? 0 : percent; | 573 | int vol = muted ? 0 : percent; |
570 | // set both channels to same volume | 574 | // set both channels to same volume |
571 | vol |= vol << 8; | 575 | vol |= vol << 8; |
572 | ioctl( fd, MIXER_WRITE( SOUND_MIXER_VOLUME ), &vol ); | 576 | ioctl( fd, MIXER_WRITE( SOUND_MIXER_VOLUME ), &vol ); |
573 | ::close( fd ); | 577 | ::close( fd ); |
574 | } | 578 | } |
575 | #endif | 579 | #endif |
576 | } | 580 | } |
577 | break; | 581 | break; |
578 | } | 582 | } |
579 | } | 583 | } |
580 | 584 | ||
581 | static void setMic( int t = 0, int percent = -1 ) | 585 | static void setMic( int t = 0, int percent = -1 ) |
582 | { | 586 | { |
583 | switch ( t ) { | 587 | switch ( t ) { |
584 | case 0: { | 588 | case 0: { |
585 | Config cfg( "qpe" ); | 589 | Config cfg( "qpe" ); |
586 | cfg.setGroup( "Volume" ); | 590 | cfg.setGroup( "Volume" ); |
587 | if ( percent < 0 ) | 591 | if ( percent < 0 ) |
588 | percent = cfg.readNumEntry( "Mic", 50 ); | 592 | percent = cfg.readNumEntry( "Mic", 50 ); |
589 | 593 | ||
590 | #ifndef QT_NO_SOUND | 594 | #ifndef QT_NO_SOUND |
591 | int fd = 0; | 595 | int fd = 0; |
592 | int mic = micMuted ? 0 : percent; | 596 | int mic = micMuted ? 0 : percent; |
597 | #ifdef QT_QWS_DEVFS | ||
598 | if ( ( fd = open( "/dev/sound/mixer", O_RDWR ) ) >= 0 ) { | ||
599 | #else | ||
593 | if ( ( fd = open( "/dev/mixer", O_RDWR ) ) >= 0 ) { | 600 | if ( ( fd = open( "/dev/mixer", O_RDWR ) ) >= 0 ) { |
601 | #endif | ||
594 | ioctl( fd, MIXER_WRITE( SOUND_MIXER_MIC ), &mic ); | 602 | ioctl( fd, MIXER_WRITE( SOUND_MIXER_MIC ), &mic ); |
595 | ::close( fd ); | 603 | ::close( fd ); |
596 | } | 604 | } |
597 | #endif | 605 | #endif |
598 | } | 606 | } |
599 | break; | 607 | break; |
600 | } | 608 | } |
601 | } | 609 | } |
602 | 610 | ||
603 | 611 | ||
604 | static void setBass( int t = 0, int percent = -1 ) | 612 | static void setBass( int t = 0, int percent = -1 ) |
605 | { | 613 | { |
606 | switch ( t ) { | 614 | switch ( t ) { |
607 | case 0: { | 615 | case 0: { |
608 | Config cfg( "qpe" ); | 616 | Config cfg( "qpe" ); |
609 | cfg.setGroup( "Volume" ); | 617 | cfg.setGroup( "Volume" ); |
610 | if ( percent < 0 ) | 618 | if ( percent < 0 ) |
611 | percent = cfg.readNumEntry( "BassPercent", 50 ); | 619 | percent = cfg.readNumEntry( "BassPercent", 50 ); |
612 | 620 | ||
613 | #ifndef QT_NO_SOUND | 621 | #ifndef QT_NO_SOUND |
614 | int fd = 0; | 622 | int fd = 0; |
615 | int bass = percent; | 623 | int bass = percent; |
624 | #ifdef QT_QWS_DEVFS | ||
625 | if ( ( fd = open( "/dev/sound/mixer", O_RDWR ) ) >= 0 ) { | ||
626 | #else | ||
616 | if ( ( fd = open( "/dev/mixer", O_RDWR ) ) >= 0 ) { | 627 | if ( ( fd = open( "/dev/mixer", O_RDWR ) ) >= 0 ) { |
628 | #endif | ||
617 | ioctl( fd, MIXER_WRITE( SOUND_MIXER_BASS ), &bass ); | 629 | ioctl( fd, MIXER_WRITE( SOUND_MIXER_BASS ), &bass ); |
618 | ::close( fd ); | 630 | ::close( fd ); |
619 | } | 631 | } |
620 | #endif | 632 | #endif |
621 | } | 633 | } |
622 | break; | 634 | break; |
623 | } | 635 | } |
624 | } | 636 | } |
625 | 637 | ||
626 | 638 | ||
627 | static void setTreble( int t = 0, int percent = -1 ) | 639 | static void setTreble( int t = 0, int percent = -1 ) |
628 | { | 640 | { |
629 | switch ( t ) { | 641 | switch ( t ) { |
630 | case 0: { | 642 | case 0: { |
631 | Config cfg( "qpe" ); | 643 | Config cfg( "qpe" ); |
632 | cfg.setGroup( "Volume" ); | 644 | cfg.setGroup( "Volume" ); |
633 | if ( percent < 0 ) | 645 | if ( percent < 0 ) |
634 | percent = cfg.readNumEntry( "TreblePercent", 50 ); | 646 | percent = cfg.readNumEntry( "TreblePercent", 50 ); |
635 | 647 | ||
636 | #ifndef QT_NO_SOUND | 648 | #ifndef QT_NO_SOUND |
637 | int fd = 0; | 649 | int fd = 0; |
638 | int treble = percent; | 650 | int treble = percent; |
651 | #ifdef QT_QWS_DEVFS | ||
652 | if ( ( fd = open( "/dev/sound/mixer", O_RDWR ) ) >= 0 ) { | ||
653 | #else | ||
639 | if ( ( fd = open( "/dev/mixer", O_RDWR ) ) >= 0 ) { | 654 | if ( ( fd = open( "/dev/mixer", O_RDWR ) ) >= 0 ) { |
655 | #endif | ||
640 | ioctl( fd, MIXER_WRITE( SOUND_MIXER_TREBLE ), &treble ); | 656 | ioctl( fd, MIXER_WRITE( SOUND_MIXER_TREBLE ), &treble ); |
641 | ::close( fd ); | 657 | ::close( fd ); |
642 | } | 658 | } |
643 | #endif | 659 | #endif |
644 | } | 660 | } |
645 | break; | 661 | break; |
646 | } | 662 | } |
647 | } | 663 | } |
648 | 664 | ||
649 | 665 | ||
650 | /** | 666 | /** |
651 | \class QPEApplication | 667 | \class QPEApplication |
652 | \brief The QPEApplication class implements various system services | 668 | \brief The QPEApplication class implements various system services |
653 | that are available to all Qtopia applications. | 669 | that are available to all Qtopia applications. |
654 | 670 | ||
655 | Simply by using QPEApplication instead of QApplication, a standard Qt | 671 | Simply by using QPEApplication instead of QApplication, a standard Qt |
656 | application becomes a Qtopia application. It automatically follows | 672 | application becomes a Qtopia application. It automatically follows |
657 | style changes, quits and raises, and in the | 673 | style changes, quits and raises, and in the |
658 | case of \link docwidget.html document-oriented\endlink applications, | 674 | case of \link docwidget.html document-oriented\endlink applications, |
659 | changes the currently displayed document in response to the environment. | 675 | changes the currently displayed document in response to the environment. |
660 | 676 | ||
661 | To create a \link docwidget.html document-oriented\endlink | 677 | To create a \link docwidget.html document-oriented\endlink |
662 | application use showMainDocumentWidget(); to create a | 678 | application use showMainDocumentWidget(); to create a |
663 | non-document-oriented application use showMainWidget(). The | 679 | non-document-oriented application use showMainWidget(). The |
664 | keepRunning() function indicates whether the application will | 680 | keepRunning() function indicates whether the application will |
665 | continue running after it's processed the last \link qcop.html | 681 | continue running after it's processed the last \link qcop.html |
666 | QCop\endlink message. This can be changed using setKeepRunning(). | 682 | QCop\endlink message. This can be changed using setKeepRunning(). |
667 | 683 | ||
668 | A variety of signals are emitted when certain events occur, for | 684 | A variety of signals are emitted when certain events occur, for |
669 | example, timeChanged(), clockChanged(), weekChanged(), | 685 | example, timeChanged(), clockChanged(), weekChanged(), |
670 | dateFormatChanged() and volumeChanged(). If the application receives | 686 | dateFormatChanged() and volumeChanged(). If the application receives |
671 | a \link qcop.html QCop\endlink message on the application's | 687 | a \link qcop.html QCop\endlink message on the application's |
672 | QPE/Application/\e{appname} channel, the appMessage() signal is | 688 | QPE/Application/\e{appname} channel, the appMessage() signal is |
673 | emitted. There are also flush() and reload() signals, which | 689 | emitted. There are also flush() and reload() signals, which |
674 | are emitted when synching begins and ends respectively - upon these | 690 | are emitted when synching begins and ends respectively - upon these |
675 | signals, the application should save and reload any data | 691 | signals, the application should save and reload any data |
676 | files that are involved in synching. Most of these signals will initially | 692 | files that are involved in synching. Most of these signals will initially |
677 | be received and unfiltered through the appMessage() signal. | 693 | be received and unfiltered through the appMessage() signal. |
678 | 694 | ||
679 | This class also provides a set of useful static functions. The | 695 | This class also provides a set of useful static functions. The |
680 | qpeDir() and documentDir() functions return the respective paths. | 696 | qpeDir() and documentDir() functions return the respective paths. |
681 | The grabKeyboard() and ungrabKeyboard() functions are used to | 697 | The grabKeyboard() and ungrabKeyboard() functions are used to |
682 | control whether the application takes control of the device's | 698 | control whether the application takes control of the device's |
683 | physical buttons (e.g. application launch keys). The stylus' mode of | 699 | physical buttons (e.g. application launch keys). The stylus' mode of |
684 | operation is set with setStylusOperation() and retrieved with | 700 | operation is set with setStylusOperation() and retrieved with |
685 | stylusOperation(). There are also setInputMethodHint() and | 701 | stylusOperation(). There are also setInputMethodHint() and |
686 | inputMethodHint() functions. | 702 | inputMethodHint() functions. |
687 | 703 | ||
688 | \ingroup qtopiaemb | 704 | \ingroup qtopiaemb |
689 | */ | 705 | */ |
690 | 706 | ||
691 | /*! | 707 | /*! |
692 | \fn void QPEApplication::clientMoused() | 708 | \fn void QPEApplication::clientMoused() |
693 | 709 | ||
694 | \internal | 710 | \internal |
695 | */ | 711 | */ |
696 | 712 | ||
697 | /*! | 713 | /*! |
698 | \fn void QPEApplication::timeChanged(); | 714 | \fn void QPEApplication::timeChanged(); |
699 | This signal is emitted when the time changes outside the normal | 715 | This signal is emitted when the time changes outside the normal |
700 | passage of time, i.e. if the time is set backwards or forwards. | 716 | passage of time, i.e. if the time is set backwards or forwards. |
701 | */ | 717 | */ |
702 | 718 | ||
703 | /*! | 719 | /*! |
704 | \fn void QPEApplication::clockChanged( bool ampm ); | 720 | \fn void QPEApplication::clockChanged( bool ampm ); |
705 | 721 | ||
706 | This signal is emitted when the user changes the clock's style. If | 722 | This signal is emitted when the user changes the clock's style. If |
707 | \a ampm is TRUE, the user wants a 12-hour AM/PM clock, otherwise, | 723 | \a ampm is TRUE, the user wants a 12-hour AM/PM clock, otherwise, |
708 | they want a 24-hour clock. | 724 | they want a 24-hour clock. |
709 | */ | 725 | */ |
710 | 726 | ||
711 | /*! | 727 | /*! |
712 | \fn void QPEApplication::volumeChanged( bool muted ) | 728 | \fn void QPEApplication::volumeChanged( bool muted ) |
713 | 729 | ||
714 | This signal is emitted whenever the mute state is changed. If \a | 730 | This signal is emitted whenever the mute state is changed. If \a |
715 | muted is TRUE, then sound output has been muted. | 731 | muted is TRUE, then sound output has been muted. |
716 | */ | 732 | */ |
717 | 733 | ||
718 | /*! | 734 | /*! |
719 | \fn void QPEApplication::weekChanged( bool startOnMonday ) | 735 | \fn void QPEApplication::weekChanged( bool startOnMonday ) |
720 | 736 | ||
721 | This signal is emitted if the week start day is changed. If \a | 737 | This signal is emitted if the week start day is changed. If \a |
722 | startOnMonday is TRUE then the first day of the week is Monday; if | 738 | startOnMonday is TRUE then the first day of the week is Monday; if |
723 | \a startOnMonday is FALSE then the first day of the week is | 739 | \a startOnMonday is FALSE then the first day of the week is |
724 | Sunday. | 740 | Sunday. |
725 | */ | 741 | */ |
726 | 742 | ||
727 | /*! | 743 | /*! |
728 | \fn void QPEApplication::dateFormatChanged(DateFormat) | 744 | \fn void QPEApplication::dateFormatChanged(DateFormat) |
729 | 745 | ||
730 | This signal is emitted whenever the date format is changed. | 746 | This signal is emitted whenever the date format is changed. |
731 | */ | 747 | */ |
732 | 748 | ||
733 | /*! | 749 | /*! |
734 | \fn void QPEApplication::flush() | 750 | \fn void QPEApplication::flush() |
735 | 751 | ||
736 | ### | 752 | ### |
737 | */ | 753 | */ |
738 | 754 | ||
739 | /*! | 755 | /*! |
740 | \fn void QPEApplication::reload() | 756 | \fn void QPEApplication::reload() |
741 | 757 | ||
742 | */ | 758 | */ |
743 | 759 | ||
744 | 760 | ||
745 | 761 | ||
746 | void QPEApplication::processQCopFile() | 762 | void QPEApplication::processQCopFile() |
747 | { | 763 | { |
748 | QString qcopfn("/tmp/qcop-msg-"); | 764 | QString qcopfn("/tmp/qcop-msg-"); |
749 | qcopfn += d->appName; // append command name | 765 | qcopfn += d->appName; // append command name |
750 | 766 | ||
751 | QFile f(qcopfn); | 767 | QFile f(qcopfn); |
752 | if ( f.open(IO_ReadWrite) ) { | 768 | if ( f.open(IO_ReadWrite) ) { |
753 | #ifndef Q_OS_WIN32 | 769 | #ifndef Q_OS_WIN32 |
754 | flock(f.handle(), LOCK_EX); | 770 | flock(f.handle(), LOCK_EX); |
755 | #endif | 771 | #endif |
756 | QDataStream ds(&f); | 772 | QDataStream ds(&f); |
757 | QCString channel, message; | 773 | QCString channel, message; |
758 | QByteArray data; | 774 | QByteArray data; |
759 | while(!ds.atEnd()) { | 775 | while(!ds.atEnd()) { |
760 | ds >> channel >> message >> data; | 776 | ds >> channel >> message >> data; |
761 | d->enqueueQCop(channel,message,data); | 777 | d->enqueueQCop(channel,message,data); |
762 | } | 778 | } |
763 | ::ftruncate(f.handle(), 0); | 779 | ::ftruncate(f.handle(), 0); |
764 | #ifndef Q_OS_WIN32 | 780 | #ifndef Q_OS_WIN32 |
765 | f.flush(); | 781 | f.flush(); |
766 | flock(f.handle(), LOCK_UN); | 782 | flock(f.handle(), LOCK_UN); |
767 | #endif | 783 | #endif |
768 | } | 784 | } |
769 | #endif | 785 | #endif |
770 | } | 786 | } |
771 | 787 | ||
772 | 788 | ||
773 | /*! | 789 | /*! |
774 | \fn void QPEApplication::appMessage( const QCString& msg, const QByteArray& data ) | 790 | \fn void QPEApplication::appMessage( const QCString& msg, const QByteArray& data ) |
775 | 791 | ||
776 | This signal is emitted when a message is received on this | 792 | This signal is emitted when a message is received on this |
777 | application's QPE/Application/<i>appname</i> \link qcop.html | 793 | application's QPE/Application/<i>appname</i> \link qcop.html |
778 | QCop\endlink channel. | 794 | QCop\endlink channel. |
779 | 795 | ||
780 | The slot to which you connect this signal uses \a msg and \a data | 796 | The slot to which you connect this signal uses \a msg and \a data |
781 | in the following way: | 797 | in the following way: |
782 | 798 | ||
783 | \code | 799 | \code |
784 | void MyWidget::receive( const QCString& msg, const QByteArray& data ) | 800 | void MyWidget::receive( const QCString& msg, const QByteArray& data ) |
785 | { | 801 | { |
786 | QDataStream stream( data, IO_ReadOnly ); | 802 | QDataStream stream( data, IO_ReadOnly ); |
787 | if ( msg == "someMessage(int,int,int)" ) { | 803 | if ( msg == "someMessage(int,int,int)" ) { |
788 | int a,b,c; | 804 | int a,b,c; |
789 | stream >> a >> b >> c; | 805 | stream >> a >> b >> c; |
790 | ... | 806 | ... |
791 | } else if ( msg == "otherMessage(QString)" ) { | 807 | } else if ( msg == "otherMessage(QString)" ) { |
792 | ... | 808 | ... |
793 | } | 809 | } |
794 | } | 810 | } |
795 | \endcode | 811 | \endcode |
796 | 812 | ||
797 | \sa qcop.html | 813 | \sa qcop.html |
798 | Note that messages received here may be processed by qpe application | 814 | Note that messages received here may be processed by qpe application |
799 | and emitted as signals, such as flush() and reload(). | 815 | and emitted as signals, such as flush() and reload(). |
800 | */ | 816 | */ |
801 | 817 | ||
802 | /*! | 818 | /*! |
803 | Constructs a QPEApplication just as you would construct | 819 | Constructs a QPEApplication just as you would construct |
804 | a QApplication, passing \a argc, \a argv, and \a t. | 820 | a QApplication, passing \a argc, \a argv, and \a t. |
805 | 821 | ||
806 | For applications, \a t should be the default, GuiClient. Only | 822 | For applications, \a t should be the default, GuiClient. Only |
807 | the Qtopia server passes GuiServer. | 823 | the Qtopia server passes GuiServer. |
808 | */ | 824 | */ |
809 | QPEApplication::QPEApplication( int & argc, char **argv, Type t ) | 825 | QPEApplication::QPEApplication( int & argc, char **argv, Type t ) |
810 | : QApplication( hack(argc), argv, t ), pidChannel( 0 ) | 826 | : QApplication( hack(argc), argv, t ), pidChannel( 0 ) |
811 | { | 827 | { |
812 | QPixmapCache::setCacheLimit(256); // sensible default for smaller devices. | 828 | QPixmapCache::setCacheLimit(256); // sensible default for smaller devices. |
813 | 829 | ||
814 | d = new QPEApplicationData; | 830 | d = new QPEApplicationData; |
815 | d->loadTextCodecs(); | 831 | d->loadTextCodecs(); |
816 | d->loadImageCodecs(); | 832 | d->loadImageCodecs(); |
817 | 833 | ||
818 | setFont( QFont( d->fontFamily, d->fontSize ) ); | 834 | setFont( QFont( d->fontFamily, d->fontSize ) ); |
819 | AppLnk::setSmallIconSize( d->smallIconSize ); | 835 | AppLnk::setSmallIconSize( d->smallIconSize ); |
820 | AppLnk::setBigIconSize( d->bigIconSize ); | 836 | AppLnk::setBigIconSize( d->bigIconSize ); |
821 | 837 | ||
822 | QMimeSourceFactory::setDefaultFactory( new ResourceMimeFactory ); | 838 | QMimeSourceFactory::setDefaultFactory( new ResourceMimeFactory ); |
823 | 839 | ||
824 | connect( this, SIGNAL( lastWindowClosed() ), this, SLOT( hideOrQuit() ) ); | 840 | connect( this, SIGNAL( lastWindowClosed() ), this, SLOT( hideOrQuit() ) ); |
825 | 841 | ||
826 | 842 | ||
827 | sysChannel = new QCopChannel( "QPE/System", this ); | 843 | sysChannel = new QCopChannel( "QPE/System", this ); |
828 | connect( sysChannel, SIGNAL( received(const QCString&,const QByteArray&) ), | 844 | connect( sysChannel, SIGNAL( received(const QCString&,const QByteArray&) ), |
829 | this, SLOT( systemMessage(const QCString&,const QByteArray&) ) ); | 845 | this, SLOT( systemMessage(const QCString&,const QByteArray&) ) ); |
830 | 846 | ||
831 | /* COde now in initapp */ | 847 | /* COde now in initapp */ |
832 | #if 0 | 848 | #if 0 |
833 | #if defined(Q_WS_QWS) && !defined(QT_NO_COP) | 849 | #if defined(Q_WS_QWS) && !defined(QT_NO_COP) |
834 | 850 | ||
835 | QString qcopfn( "/tmp/qcop-msg-" ); | 851 | QString qcopfn( "/tmp/qcop-msg-" ); |
836 | qcopfn += QString( argv[ 0 ] ); // append command name | 852 | qcopfn += QString( argv[ 0 ] ); // append command name |
837 | 853 | ||
838 | QFile f( qcopfn ); | 854 | QFile f( qcopfn ); |
839 | if ( f.open( IO_ReadOnly ) ) { | 855 | if ( f.open( IO_ReadOnly ) ) { |
840 | flock( f.handle(), LOCK_EX ); | 856 | flock( f.handle(), LOCK_EX ); |
841 | } | 857 | } |
842 | 858 | ||
843 | 859 | ||
844 | 860 | ||
845 | QCString channel = QCString( argv[ 0 ] ); | 861 | QCString channel = QCString( argv[ 0 ] ); |
846 | channel.replace( QRegExp( ".*/" ), "" ); | 862 | channel.replace( QRegExp( ".*/" ), "" ); |
847 | d->appName = channel; | 863 | d->appName = channel; |
848 | channel = "QPE/Application/" + channel; | 864 | channel = "QPE/Application/" + channel; |
849 | pidChannel = new QCopChannel( channel, this ); | 865 | pidChannel = new QCopChannel( channel, this ); |
850 | connect( pidChannel, SIGNAL( received(const QCString&,const QByteArray&) ), | 866 | connect( pidChannel, SIGNAL( received(const QCString&,const QByteArray&) ), |
851 | this, SLOT( pidMessage(const QCString&,const QByteArray&) ) ); | 867 | this, SLOT( pidMessage(const QCString&,const QByteArray&) ) ); |
852 | 868 | ||
853 | if ( f.isOpen() ) { | 869 | if ( f.isOpen() ) { |
854 | d->keep_running = FALSE; | 870 | d->keep_running = FALSE; |
855 | QDataStream ds( &f ); | 871 | QDataStream ds( &f ); |
856 | QCString channel, message; | 872 | QCString channel, message; |
857 | QByteArray data; | 873 | QByteArray data; |
858 | while ( !ds.atEnd() ) { | 874 | while ( !ds.atEnd() ) { |
859 | ds >> channel >> message >> data; | 875 | ds >> channel >> message >> data; |
860 | d->enqueueQCop( channel, message, data ); | 876 | d->enqueueQCop( channel, message, data ); |
861 | } | 877 | } |
862 | 878 | ||
863 | flock( f.handle(), LOCK_UN ); | 879 | flock( f.handle(), LOCK_UN ); |
864 | f.close(); | 880 | f.close(); |
865 | f.remove(); | 881 | f.remove(); |
866 | } | 882 | } |
867 | 883 | ||
868 | for ( int a = 0; a < argc; a++ ) { | 884 | for ( int a = 0; a < argc; a++ ) { |
869 | if ( qstrcmp( argv[ a ], "-preload" ) == 0 ) { | 885 | if ( qstrcmp( argv[ a ], "-preload" ) == 0 ) { |
870 | argv[ a ] = argv[ a + 1 ]; | 886 | argv[ a ] = argv[ a + 1 ]; |
871 | a++; | 887 | a++; |
872 | d->preloaded = TRUE; | 888 | d->preloaded = TRUE; |
873 | argc -= 1; | 889 | argc -= 1; |
874 | } | 890 | } |
875 | else if ( qstrcmp( argv[ a ], "-preload-show" ) == 0 ) { | 891 | else if ( qstrcmp( argv[ a ], "-preload-show" ) == 0 ) { |
876 | argv[ a ] = argv[ a + 1 ]; | 892 | argv[ a ] = argv[ a + 1 ]; |
877 | a++; | 893 | a++; |
878 | d->preloaded = TRUE; | 894 | d->preloaded = TRUE; |
879 | d->forceshow = TRUE; | 895 | d->forceshow = TRUE; |
880 | argc -= 1; | 896 | argc -= 1; |
881 | } | 897 | } |
882 | } | 898 | } |
883 | 899 | ||
884 | /* overide stored arguments */ | 900 | /* overide stored arguments */ |
885 | setArgs( argc, argv ); | 901 | setArgs( argc, argv ); |
886 | 902 | ||
887 | #endif | 903 | #endif |
888 | #else | 904 | #else |
889 | initApp( argc, argv ); | 905 | initApp( argc, argv ); |
890 | #endif | 906 | #endif |
891 | #ifdef Q_WS_QWS | 907 | #ifdef Q_WS_QWS |
892 | /* load the font renderer factories */ | 908 | /* load the font renderer factories */ |
893 | FontDatabase::loadRenderers(); | 909 | FontDatabase::loadRenderers(); |
894 | #endif | 910 | #endif |
895 | #ifndef QT_NO_TRANSLATION | 911 | #ifndef QT_NO_TRANSLATION |