summaryrefslogtreecommitdiff
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--core/apps/textedit/textedit.cpp33
-rw-r--r--core/launcher/qprocess_unix.cpp6
-rw-r--r--core/launcher/server.cpp19
-rw-r--r--core/settings/launcher/menusettings.cpp5
-rw-r--r--core/settings/launcher/taskbarsettings.cpp13
-rw-r--r--libopie2/opiecore/oglobal.cpp2
-rw-r--r--libopie2/opiecore/oprocess.cpp2
-rw-r--r--library/global.cpp63
-rw-r--r--noncore/apps/advancedfm/output.cpp5
-rw-r--r--noncore/apps/tinykate/libkate/document/katebuffer.cpp5
-rw-r--r--noncore/settings/usermanager/userdialog.cpp9
11 files changed, 94 insertions, 68 deletions
diff --git a/core/apps/textedit/textedit.cpp b/core/apps/textedit/textedit.cpp
index 759e440..61beac5 100644
--- a/core/apps/textedit/textedit.cpp
+++ b/core/apps/textedit/textedit.cpp
@@ -537,272 +537,273 @@ void TextEdit::setWordWrap(bool y) {
537 edited1=b1; 537 edited1=b1;
538 edited=b2; 538 edited=b2;
539 setCaption(captionStr); 539 setCaption(captionStr);
540} 540}
541 541
542void TextEdit::setSearchBar(bool b) { 542void TextEdit::setSearchBar(bool b) {
543 useSearchBar=b; 543 useSearchBar=b;
544 Config cfg("TextEdit"); 544 Config cfg("TextEdit");
545 cfg.setGroup("View"); 545 cfg.setGroup("View");
546 cfg.writeEntry ( "SearchBar", b ); 546 cfg.writeEntry ( "SearchBar", b );
547 searchBarAction->setOn(b); 547 searchBarAction->setOn(b);
548 if(b) 548 if(b)
549 searchBar->show(); 549 searchBar->show();
550 else 550 else
551 searchBar->hide(); 551 searchBar->hide();
552 editor->setFocus(); 552 editor->setFocus();
553} 553}
554 554
555void TextEdit::fileNew() { 555void TextEdit::fileNew() {
556// if( !bFromDocView ) { 556// if( !bFromDocView ) {
557// saveAs(); 557// saveAs();
558// } 558// }
559 newFile(DocLnk()); 559 newFile(DocLnk());
560} 560}
561 561
562void TextEdit::fileOpen() { 562void TextEdit::fileOpen() {
563 Config cfg("TextEdit"); 563 Config cfg("TextEdit");
564 cfg. setGroup ( "View" ); 564 cfg. setGroup ( "View" );
565 QMap<QString, QStringList> map; 565 QMap<QString, QStringList> map;
566 map.insert(tr("All"), QStringList() ); 566 map.insert(tr("All"), QStringList() );
567 QStringList text; 567 QStringList text;
568 text << "text/*"; 568 text << "text/*";
569 map.insert(tr("Text"), text ); 569 map.insert(tr("Text"), text );
570 text << "*"; 570 text << "*";
571 map.insert(tr("All"), text ); 571 map.insert(tr("All"), text );
572 QString str = OFileDialog::getOpenFileName( 2, 572 QString str = OFileDialog::getOpenFileName( 2,
573 QString::null , 573 QString::null ,
574 QString::null, map); 574 QString::null, map);
575 if( !str.isEmpty() && QFile(str).exists() && !QFileInfo(str).isDir() ) 575 if( !str.isEmpty() && QFile(str).exists() && !QFileInfo(str).isDir() )
576 { 576 {
577 openFile( str ); 577 openFile( str );
578 } 578 }
579 else 579 else
580 updateCaption(); 580 updateCaption();
581} 581}
582 582
583void TextEdit::doSearchBar() { 583void TextEdit::doSearchBar() {
584 if(!useSearchBar) 584 if(!useSearchBar)
585 searchBar->hide(); 585 searchBar->hide();
586 else 586 else
587 searchBar->show(); 587 searchBar->show();
588} 588}
589 589
590#if 0 590#if 0
591void TextEdit::slotFind() { 591void TextEdit::slotFind() {
592 FindDialog frmFind( tr("Text Editor"), this ); 592 FindDialog frmFind( tr("Text Editor"), this );
593 connect( &frmFind, SIGNAL(signalFindClicked(const QString&,bool,bool,int)), 593 connect( &frmFind, SIGNAL(signalFindClicked(const QString&,bool,bool,int)),
594 editor, SLOT(slotDoFind(const QString&,bool,bool))); 594 editor, SLOT(slotDoFind(const QString&,bool,bool)));
595 595
596 //case sensitive, backwards, [category] 596 //case sensitive, backwards, [category]
597 597
598 connect( editor, SIGNAL(notFound()), 598 connect( editor, SIGNAL(notFound()),
599 &frmFind, SLOT(slotNotFound()) ); 599 &frmFind, SLOT(slotNotFound()) );
600 connect( editor, SIGNAL(searchWrapped()), 600 connect( editor, SIGNAL(searchWrapped()),
601 &frmFind, SLOT(slotWrapAround()) ); 601 &frmFind, SLOT(slotWrapAround()) );
602 602
603 frmFind.exec(); 603 frmFind.exec();
604 604
605 605
606} 606}
607#endif 607#endif
608 608
609void TextEdit::fileRevert() { 609void TextEdit::fileRevert() {
610 clear(); 610 clear();
611 fileOpen(); 611 fileOpen();
612} 612}
613 613
614void TextEdit::editCut() { 614void TextEdit::editCut() {
615#ifndef QT_NO_CLIPBOARD 615#ifndef QT_NO_CLIPBOARD
616 editor->cut(); 616 editor->cut();
617#endif 617#endif
618} 618}
619 619
620void TextEdit::editCopy() { 620void TextEdit::editCopy() {
621#ifndef QT_NO_CLIPBOARD 621#ifndef QT_NO_CLIPBOARD
622 editor->copy(); 622 editor->copy();
623#endif 623#endif
624} 624}
625 625
626void TextEdit::editPaste() { 626void TextEdit::editPaste() {
627#ifndef QT_NO_CLIPBOARD 627#ifndef QT_NO_CLIPBOARD
628 editor->paste(); 628 editor->paste();
629#endif 629#endif
630} 630}
631 631
632void TextEdit::editFind() { 632void TextEdit::editFind() {
633 searchBar->show(); 633 searchBar->show();
634 searchEdit->setFocus(); 634 searchEdit->setFocus();
635} 635}
636 636
637void TextEdit::findNext() { 637void TextEdit::findNext() {
638 editor->find( searchEdit->text(), false, false ); 638 editor->find( searchEdit->text(), false, false );
639 639
640} 640}
641 641
642void TextEdit::findClose() { 642void TextEdit::findClose() {
643 searchBar->hide(); 643 searchBar->hide();
644} 644}
645 645
646void TextEdit::search() { 646void TextEdit::search() {
647 editor->find( searchEdit->text(), false, false ); 647 editor->find( searchEdit->text(), false, false );
648} 648}
649 649
650void TextEdit::newFile( const DocLnk &f ) { 650void TextEdit::newFile( const DocLnk &f ) {
651 DocLnk nf = f; 651 DocLnk nf = f;
652 nf.setType("text/plain"); 652 nf.setType("text/plain");
653 clear(); 653 clear();
654 setWState (WState_Reserved1 ); 654 setWState (WState_Reserved1 );
655 editor->setFocus(); 655 editor->setFocus();
656 doc = new DocLnk(nf); 656 doc = new DocLnk(nf);
657 currentFileName = "Unnamed"; 657 currentFileName = "Unnamed";
658 odebug << "newFile "+currentFileName << oendl; 658 odebug << "newFile "+currentFileName << oendl;
659 updateCaption( currentFileName); 659 updateCaption( currentFileName);
660// editor->setEdited( false); 660// editor->setEdited( false);
661} 661}
662 662
663void TextEdit::openDotFile( const QString &f ) { 663void TextEdit::openDotFile( const QString &f ) {
664 if(!currentFileName.isEmpty()) { 664 if(!currentFileName.isEmpty()) {
665 currentFileName=f; 665 currentFileName=f;
666 666
667 odebug << "openFile dotfile " + currentFileName << oendl; 667 odebug << "openFile dotfile " + currentFileName << oendl;
668 QString txt; 668 QString txt;
669 QFile file(f); 669 QFile file(f);
670 file.open(IO_ReadWrite); 670 if (!file.open(IO_ReadWrite))
671 QTextStream t(&file); 671 owarn << "Failed to open file " << file.name() << oendl;
672 while ( !t.atEnd()) { 672 else {
673 txt+=t.readLine()+"\n"; 673 QTextStream t(&file);
674 } 674 while ( !t.atEnd()) {
675 editor->setText(txt); 675 txt+=t.readLine()+"\n";
676 editor->setEdited( false); 676 }
677 edited1=false; 677 editor->setText(txt);
678 edited=false; 678 editor->setEdited( false);
679 679 edited1=false;
680 680 edited=false;
681 }
681 } 682 }
682 updateCaption( currentFileName); 683 updateCaption( currentFileName);
683} 684}
684 685
685void TextEdit::openFile( const QString &f ) { 686void TextEdit::openFile( const QString &f ) {
686 odebug << "filename is "+ f << oendl; 687 odebug << "filename is "+ f << oendl;
687 QString filer; 688 QString filer;
688 QFileInfo fi( f); 689 QFileInfo fi( f);
689// bFromDocView = true; 690// bFromDocView = true;
690 if(f.find(".desktop",0,true) != -1 && !openDesktop ) 691 if(f.find(".desktop",0,true) != -1 && !openDesktop )
691 { 692 {
692 switch ( QMessageBox::warning(this,tr("Text Editor"),tr("Text Editor has detected<BR>you selected a <B>.desktop</B>file.<BR>Open<B>.desktop</B> file or <B>linked</B> file?"),tr(".desktop File"),tr("Linked Document"),0,1,1) ) 693 switch ( QMessageBox::warning(this,tr("Text Editor"),tr("Text Editor has detected<BR>you selected a <B>.desktop</B>file.<BR>Open<B>.desktop</B> file or <B>linked</B> file?"),tr(".desktop File"),tr("Linked Document"),0,1,1) )
693 { 694 {
694 case 0: //desktop 695 case 0: //desktop
695 filer = f; 696 filer = f;
696 break; 697 break;
697 case 1: //linked 698 case 1: //linked
698 DocLnk sf(f); 699 DocLnk sf(f);
699 filer = sf.file(); 700 filer = sf.file();
700 break; 701 break;
701 }; 702 };
702 } 703 }
703 else if(fi.baseName().left(1) == "") 704 else if(fi.baseName().left(1) == "")
704 { 705 {
705 odebug << "opening dotfile" << oendl; 706 odebug << "opening dotfile" << oendl;
706 currentFileName=f; 707 currentFileName=f;
707 openDotFile(currentFileName); 708 openDotFile(currentFileName);
708 return; 709 return;
709 } 710 }
710 /* 711 /*
711 * The problem is a file where Config(f).isValid() and it does not 712 * The problem is a file where Config(f).isValid() and it does not
712 * end with .desktop will be treated as desktop file 713 * end with .desktop will be treated as desktop file
713 */ 714 */
714 else if (f.find(".desktop",0,true) != -1 ) 715 else if (f.find(".desktop",0,true) != -1 )
715 { 716 {
716 DocLnk sf(f); 717 DocLnk sf(f);
717 filer = sf.file(); 718 filer = sf.file();
718 if(filer.right(1) == "/") 719 if(filer.right(1) == "/")
719 filer = f; 720 filer = f;
720 721
721 } 722 }
722 else 723 else
723 filer = f; 724 filer = f;
724 725
725 DocLnk nf; 726 DocLnk nf;
726 nf.setType("text/plain"); 727 nf.setType("text/plain");
727 nf.setFile(filer); 728 nf.setFile(filer);
728 currentFileName=filer; 729 currentFileName=filer;
729 730
730 nf.setName(fi.baseName()); 731 nf.setName(fi.baseName());
731 openFile(nf); 732 openFile(nf);
732 733
733 odebug << "openFile string "+currentFileName << oendl; 734 odebug << "openFile string "+currentFileName << oendl;
734 735
735 showEditTools(); 736 showEditTools();
736 // Show filename in caption 737 // Show filename in caption
737 QString name = filer; 738 QString name = filer;
738 int sep = name.findRev( '/' ); 739 int sep = name.findRev( '/' );
739 if ( sep > 0 ) 740 if ( sep > 0 )
740 name = name.mid( sep+1 ); 741 name = name.mid( sep+1 );
741 updateCaption( name ); 742 updateCaption( name );
742} 743}
743 744
744void TextEdit::openFile( const DocLnk &f ) { 745void TextEdit::openFile( const DocLnk &f ) {
745// clear(); 746// clear();
746// bFromDocView = true; 747// bFromDocView = true;
747 FileManager fm; 748 FileManager fm;
748 QString txt; 749 QString txt;
749 currentFileName=f.file(); 750 currentFileName=f.file();
750 odebug << "openFile doclnk " + currentFileName << oendl; 751 odebug << "openFile doclnk " + currentFileName << oendl;
751 if ( !fm.loadFile( f, txt ) ) { 752 if ( !fm.loadFile( f, txt ) ) {
752 // ####### could be a new file 753 // ####### could be a new file
753 odebug << "Cannot open file" << oendl; 754 odebug << "Cannot open file" << oendl;
754 } 755 }
755// fileNew(); 756// fileNew();
756 if ( doc ) 757 if ( doc )
757 delete doc; 758 delete doc;
758 doc = new DocLnk(f); 759 doc = new DocLnk(f);
759 editor->setText(txt); 760 editor->setText(txt);
760 editor->setEdited( false); 761 editor->setEdited( false);
761 edited1=false; 762 edited1=false;
762 edited=false; 763 edited=false;
763 764
764 doc->setName(currentFileName); 765 doc->setName(currentFileName);
765 updateCaption(); 766 updateCaption();
766 setTimer(); 767 setTimer();
767} 768}
768 769
769void TextEdit::showEditTools() { 770void TextEdit::showEditTools() {
770 menu->show(); 771 menu->show();
771 editBar->show(); 772 editBar->show();
772 if(!useSearchBar) 773 if(!useSearchBar)
773 searchBar->hide(); 774 searchBar->hide();
774 else 775 else
775 searchBar->show(); 776 searchBar->show();
776 setWState (WState_Reserved1 ); 777 setWState (WState_Reserved1 );
777} 778}
778 779
779/*! 780/*!
780 unprompted save */ 781 unprompted save */
781bool TextEdit::save() { 782bool TextEdit::save() {
782 QString name, file; 783 QString name, file;
783 odebug << "saveAsFile " + currentFileName << oendl; 784 odebug << "saveAsFile " + currentFileName << oendl;
784 if(currentFileName.isEmpty()) { 785 if(currentFileName.isEmpty()) {
785 saveAs(); 786 saveAs();
786 return false; 787 return false;
787 } 788 }
788 name = currentFileName; 789 name = currentFileName;
789 if(doc) { 790 if(doc) {
790 file = doc->file(); 791 file = doc->file();
791 odebug << "saver file "+file << oendl; 792 odebug << "saver file "+file << oendl;
792 name = doc->name(); 793 name = doc->name();
793 odebug << "File named "+name << oendl; 794 odebug << "File named "+name << oendl;
794 } else { 795 } else {
795 file = currentFileName; 796 file = currentFileName;
796 name = QFileInfo(currentFileName).baseName(); 797 name = QFileInfo(currentFileName).baseName();
797 } 798 }
798 799
799 QString rt = editor->text(); 800 QString rt = editor->text();
800 if( !rt.isEmpty() ) { 801 if( !rt.isEmpty() ) {
801 if(name.isEmpty()) { 802 if(name.isEmpty()) {
802 saveAs(); 803 saveAs();
803 } else { 804 } else {
804 currentFileName = name; 805 currentFileName = name;
805 odebug << "saveFile "+currentFileName << oendl; 806 odebug << "saveFile "+currentFileName << oendl;
806 807
807 struct stat buf; 808 struct stat buf;
808 mode_t mode; 809 mode_t mode;
diff --git a/core/launcher/qprocess_unix.cpp b/core/launcher/qprocess_unix.cpp
index 97c0460..3125bcc 100644
--- a/core/launcher/qprocess_unix.cpp
+++ b/core/launcher/qprocess_unix.cpp
@@ -188,257 +188,261 @@ public:
188 188
189public slots: 189public slots:
190 void removeMe(); 190 void removeMe();
191 void sigchldHnd( int ); 191 void sigchldHnd( int );
192 192
193public: 193public:
194 struct sigaction oldactChld; 194 struct sigaction oldactChld;
195 struct sigaction oldactPipe; 195 struct sigaction oldactPipe;
196 QList<QProc> *procList; 196 QList<QProc> *procList;
197 int sigchldFd[2]; 197 int sigchldFd[2];
198}; 198};
199 199
200QCleanupHandler<QProcessManager> qprocess_cleanup_procmanager; 200QCleanupHandler<QProcessManager> qprocess_cleanup_procmanager;
201 201
202QProcessManager::QProcessManager() 202QProcessManager::QProcessManager()
203{ 203{
204 procList = new QList<QProc>; 204 procList = new QList<QProc>;
205 procList->setAutoDelete( TRUE ); 205 procList->setAutoDelete( TRUE );
206 206
207 // The SIGCHLD handler writes to a socket to tell the manager that 207 // The SIGCHLD handler writes to a socket to tell the manager that
208 // something happened. This is done to get the processing in sync with the 208 // something happened. This is done to get the processing in sync with the
209 // event reporting. 209 // event reporting.
210 if ( ::socketpair( AF_UNIX, SOCK_STREAM, 0, sigchldFd ) ) { 210 if ( ::socketpair( AF_UNIX, SOCK_STREAM, 0, sigchldFd ) ) {
211 sigchldFd[0] = 0; 211 sigchldFd[0] = 0;
212 sigchldFd[1] = 0; 212 sigchldFd[1] = 0;
213 } else { 213 } else {
214#if defined(QT_QPROCESS_DEBUG) 214#if defined(QT_QPROCESS_DEBUG)
215 odebug << "QProcessManager: install socket notifier (" << sigchldFd[1] << ")" << oendl; 215 odebug << "QProcessManager: install socket notifier (" << sigchldFd[1] << ")" << oendl;
216#endif 216#endif
217 QSocketNotifier *sn = new QSocketNotifier( sigchldFd[1], 217 QSocketNotifier *sn = new QSocketNotifier( sigchldFd[1],
218 QSocketNotifier::Read, this ); 218 QSocketNotifier::Read, this );
219 connect( sn, SIGNAL(activated(int)), 219 connect( sn, SIGNAL(activated(int)),
220 this, SLOT(sigchldHnd(int)) ); 220 this, SLOT(sigchldHnd(int)) );
221 sn->setEnabled( TRUE ); 221 sn->setEnabled( TRUE );
222 } 222 }
223 223
224 // install a SIGCHLD handler and ignore SIGPIPE 224 // install a SIGCHLD handler and ignore SIGPIPE
225 struct sigaction act; 225 struct sigaction act;
226 226
227#if defined(QT_QPROCESS_DEBUG) 227#if defined(QT_QPROCESS_DEBUG)
228 odebug << "QProcessManager: install a SIGCHLD handler" << oendl; 228 odebug << "QProcessManager: install a SIGCHLD handler" << oendl;
229#endif 229#endif
230 act.sa_handler = qt_C_sigchldHnd; 230 act.sa_handler = qt_C_sigchldHnd;
231 sigemptyset( &(act.sa_mask) ); 231 sigemptyset( &(act.sa_mask) );
232 sigaddset( &(act.sa_mask), SIGCHLD ); 232 sigaddset( &(act.sa_mask), SIGCHLD );
233 act.sa_flags = SA_NOCLDSTOP; 233 act.sa_flags = SA_NOCLDSTOP;
234#if defined(SA_RESTART) 234#if defined(SA_RESTART)
235 act.sa_flags |= SA_RESTART; 235 act.sa_flags |= SA_RESTART;
236#endif 236#endif
237 if ( sigaction( SIGCHLD, &act, &oldactChld ) != 0 ) 237 if ( sigaction( SIGCHLD, &act, &oldactChld ) != 0 )
238 owarn << "Error installing SIGCHLD handler" << oendl; 238 owarn << "Error installing SIGCHLD handler" << oendl;
239 239
240#if defined(QT_QPROCESS_DEBUG) 240#if defined(QT_QPROCESS_DEBUG)
241 odebug << "QProcessManager: install a SIGPIPE handler (SIG_IGN)" << oendl; 241 odebug << "QProcessManager: install a SIGPIPE handler (SIG_IGN)" << oendl;
242#endif 242#endif
243 /* 243 /*
244 Using qt_C_sigpipeHnd rather than SIG_IGN is a workaround 244 Using qt_C_sigpipeHnd rather than SIG_IGN is a workaround
245 for a strange problem where GNU tar (called by backuprestore) 245 for a strange problem where GNU tar (called by backuprestore)
246 would hang on filesystem-full. Strangely, the qt_C_sigpipeHnd 246 would hang on filesystem-full. Strangely, the qt_C_sigpipeHnd
247 is never even called, yet this avoids the hang. 247 is never even called, yet this avoids the hang.
248 */ 248 */
249 act.sa_handler = qt_C_sigpipeHnd; 249 act.sa_handler = qt_C_sigpipeHnd;
250 sigemptyset( &(act.sa_mask) ); 250 sigemptyset( &(act.sa_mask) );
251 sigaddset( &(act.sa_mask), SIGPIPE ); 251 sigaddset( &(act.sa_mask), SIGPIPE );
252 act.sa_flags = 0; 252 act.sa_flags = 0;
253 if ( sigaction( SIGPIPE, &act, &oldactPipe ) != 0 ) 253 if ( sigaction( SIGPIPE, &act, &oldactPipe ) != 0 )
254 owarn << "Error installing SIGPIPE handler" << oendl; 254 owarn << "Error installing SIGPIPE handler" << oendl;
255} 255}
256 256
257QProcessManager::~QProcessManager() 257QProcessManager::~QProcessManager()
258{ 258{
259 delete procList; 259 delete procList;
260 260
261 if ( sigchldFd[0] != 0 ) 261 if ( sigchldFd[0] != 0 )
262 ::close( sigchldFd[0] ); 262 ::close( sigchldFd[0] );
263 if ( sigchldFd[1] != 0 ) 263 if ( sigchldFd[1] != 0 )
264 ::close( sigchldFd[1] ); 264 ::close( sigchldFd[1] );
265 265
266 // restore SIGCHLD handler 266 // restore SIGCHLD handler
267#if defined(QT_QPROCESS_DEBUG) 267#if defined(QT_QPROCESS_DEBUG)
268 odebug << "QProcessManager: restore old sigchild handler" << oendl; 268 odebug << "QProcessManager: restore old sigchild handler" << oendl;
269#endif 269#endif
270 if ( sigaction( SIGCHLD, &oldactChld, 0 ) != 0 ) 270 if ( sigaction( SIGCHLD, &oldactChld, 0 ) != 0 )
271 owarn << "Error restoring SIGCHLD handler" << oendl; 271 owarn << "Error restoring SIGCHLD handler" << oendl;
272 272
273#if defined(QT_QPROCESS_DEBUG) 273#if defined(QT_QPROCESS_DEBUG)
274 odebug << "QProcessManager: restore old sigpipe handler" << oendl; 274 odebug << "QProcessManager: restore old sigpipe handler" << oendl;
275#endif 275#endif
276 if ( sigaction( SIGPIPE, &oldactPipe, 0 ) != 0 ) 276 if ( sigaction( SIGPIPE, &oldactPipe, 0 ) != 0 )
277 owarn << "Error restoring SIGPIPE handler" << oendl; 277 owarn << "Error restoring SIGPIPE handler" << oendl;
278} 278}
279 279
280void QProcessManager::append( QProc *p ) 280void QProcessManager::append( QProc *p )
281{ 281{
282 procList->append( p ); 282 procList->append( p );
283#if defined(QT_QPROCESS_DEBUG) 283#if defined(QT_QPROCESS_DEBUG)
284 odebug << "QProcessManager: append process (procList.count(): " << procList->count() << ")" << oendl; 284 odebug << "QProcessManager: append process (procList.count(): " << procList->count() << ")" << oendl;
285#endif 285#endif
286} 286}
287 287
288void QProcessManager::remove( QProc *p ) 288void QProcessManager::remove( QProc *p )
289{ 289{
290 procList->remove( p ); 290 procList->remove( p );
291#if defined(QT_QPROCESS_DEBUG) 291#if defined(QT_QPROCESS_DEBUG)
292 odebug << "QProcessManager: remove process (procList.count(): " << procList->count() << ")" << oendl; 292 odebug << "QProcessManager: remove process (procList.count(): " << procList->count() << ")" << oendl;
293#endif 293#endif
294 cleanup(); 294 cleanup();
295} 295}
296 296
297void QProcessManager::cleanup() 297void QProcessManager::cleanup()
298{ 298{
299 if ( procList->count() == 0 ) { 299 if ( procList->count() == 0 ) {
300 QTimer::singleShot( 0, this, SLOT(removeMe()) ); 300 QTimer::singleShot( 0, this, SLOT(removeMe()) );
301 } 301 }
302} 302}
303 303
304void QProcessManager::removeMe() 304void QProcessManager::removeMe()
305{ 305{
306 if ( procList->count() == 0 ) { 306 if ( procList->count() == 0 ) {
307 qprocess_cleanup_procmanager.remove( &QProcessPrivate::procManager ); 307 qprocess_cleanup_procmanager.remove( &QProcessPrivate::procManager );
308 QProcessPrivate::procManager = 0; 308 QProcessPrivate::procManager = 0;
309 delete this; 309 delete this;
310 } 310 }
311} 311}
312 312
313void QProcessManager::sigchldHnd( int fd ) 313void QProcessManager::sigchldHnd( int fd )
314{ 314{
315 char tmp; 315 char tmp;
316 ::read( fd, &tmp, sizeof(tmp) ); 316 if (::read( fd, &tmp, sizeof(tmp) ) < 0)
317#if defined(QT_QPROCESS_DEBUG)
318 odebug << "QProcessManager::sigchldHnd() failed dummy read of file descriptor" << oendl;
319#endif
320 ;
317#if defined(QT_QPROCESS_DEBUG) 321#if defined(QT_QPROCESS_DEBUG)
318 odebug << "QProcessManager::sigchldHnd()" << oendl; 322 odebug << "QProcessManager::sigchldHnd()" << oendl;
319#endif 323#endif
320 QProc *proc; 324 QProc *proc;
321 QProcess *process; 325 QProcess *process;
322 bool removeProc; 326 bool removeProc;
323 proc = procList->first(); 327 proc = procList->first();
324 while ( proc != 0 ) { 328 while ( proc != 0 ) {
325 removeProc = FALSE; 329 removeProc = FALSE;
326 process = proc->process; 330 process = proc->process;
327 QProcess *process_exit_notify=0; 331 QProcess *process_exit_notify=0;
328 if ( process != 0 ) { 332 if ( process != 0 ) {
329 if ( !process->isRunning() ) { 333 if ( !process->isRunning() ) {
330#if defined(QT_QPROCESS_DEBUG) 334#if defined(QT_QPROCESS_DEBUG)
331 odebug << "QProcessManager::sigchldHnd() (PID: " << proc->pid << "): process exited (QProcess available)" << oendl; 335 odebug << "QProcessManager::sigchldHnd() (PID: " << proc->pid << "): process exited (QProcess available)" << oendl;
332#endif 336#endif
333 // read pending data 337 // read pending data
334 int nbytes = 0; 338 int nbytes = 0;
335 if ( ::ioctl(proc->socketStdout, FIONREAD, (char*)&nbytes)==0 && nbytes>0 ) { 339 if ( ::ioctl(proc->socketStdout, FIONREAD, (char*)&nbytes)==0 && nbytes>0 ) {
336#if defined(QT_QPROCESS_DEBUG) 340#if defined(QT_QPROCESS_DEBUG)
337 odebug << "QProcessManager::sigchldHnd() (PID: " << proc->pid << "): reading " << nbytes << " bytes of pending data on stdout" << oendl; 341 odebug << "QProcessManager::sigchldHnd() (PID: " << proc->pid << "): reading " << nbytes << " bytes of pending data on stdout" << oendl;
338#endif 342#endif
339 process->socketRead( proc->socketStdout ); 343 process->socketRead( proc->socketStdout );
340 } 344 }
341 nbytes = 0; 345 nbytes = 0;
342 if ( ::ioctl(proc->socketStderr, FIONREAD, (char*)&nbytes)==0 && nbytes>0 ) { 346 if ( ::ioctl(proc->socketStderr, FIONREAD, (char*)&nbytes)==0 && nbytes>0 ) {
343#if defined(QT_QPROCESS_DEBUG) 347#if defined(QT_QPROCESS_DEBUG)
344 odebug << "QProcessManager::sigchldHnd() (PID: " << proc->pid << "): reading " << nbytes << " bytes of pending data on stderr" << oendl; 348 odebug << "QProcessManager::sigchldHnd() (PID: " << proc->pid << "): reading " << nbytes << " bytes of pending data on stderr" << oendl;
345#endif 349#endif
346 process->socketRead( proc->socketStderr ); 350 process->socketRead( proc->socketStderr );
347 } 351 }
348 352
349 if ( process->notifyOnExit ) 353 if ( process->notifyOnExit )
350 process_exit_notify = process; 354 process_exit_notify = process;
351 355
352 removeProc = TRUE; 356 removeProc = TRUE;
353 } 357 }
354 } else { 358 } else {
355 int status; 359 int status;
356 if ( ::waitpid( proc->pid, &status, WNOHANG ) == proc->pid ) { 360 if ( ::waitpid( proc->pid, &status, WNOHANG ) == proc->pid ) {
357#if defined(QT_QPROCESS_DEBUG) 361#if defined(QT_QPROCESS_DEBUG)
358 odebug << "QProcessManager::sigchldHnd() (PID: " << proc->pid << "): process exited (QProcess not available)" << oendl; 362 odebug << "QProcessManager::sigchldHnd() (PID: " << proc->pid << "): process exited (QProcess not available)" << oendl;
359#endif 363#endif
360 removeProc = TRUE; 364 removeProc = TRUE;
361 } 365 }
362 } 366 }
363 if ( removeProc ) { 367 if ( removeProc ) {
364 QProc *oldproc = proc; 368 QProc *oldproc = proc;
365 proc = procList->next(); 369 proc = procList->next();
366 remove( oldproc ); 370 remove( oldproc );
367 } else { 371 } else {
368 proc = procList->next(); 372 proc = procList->next();
369 } 373 }
370 if ( process_exit_notify ) 374 if ( process_exit_notify )
371 emit process_exit_notify->processExited(); 375 emit process_exit_notify->processExited();
372 } 376 }
373} 377}
374 378
375#include "qprocess_unix.moc" 379#include "qprocess_unix.moc"
376 380
377 381
378/*********************************************************************** 382/***********************************************************************
379 * 383 *
380 * QProcessPrivate 384 * QProcessPrivate
381 * 385 *
382 **********************************************************************/ 386 **********************************************************************/
383QProcessManager *QProcessPrivate::procManager = 0; 387QProcessManager *QProcessPrivate::procManager = 0;
384 388
385QProcessPrivate::QProcessPrivate() 389QProcessPrivate::QProcessPrivate()
386{ 390{
387#if defined(QT_QPROCESS_DEBUG) 391#if defined(QT_QPROCESS_DEBUG)
388 odebug << "QProcessPrivate: Constructor" << oendl; 392 odebug << "QProcessPrivate: Constructor" << oendl;
389#endif 393#endif
390 stdinBufRead = 0; 394 stdinBufRead = 0;
391 395
392 notifierStdin = 0; 396 notifierStdin = 0;
393 notifierStdout = 0; 397 notifierStdout = 0;
394 notifierStderr = 0; 398 notifierStderr = 0;
395 399
396 exitValuesCalculated = FALSE; 400 exitValuesCalculated = FALSE;
397 socketReadCalled = FALSE; 401 socketReadCalled = FALSE;
398 402
399 proc = 0; 403 proc = 0;
400} 404}
401 405
402QProcessPrivate::~QProcessPrivate() 406QProcessPrivate::~QProcessPrivate()
403{ 407{
404#if defined(QT_QPROCESS_DEBUG) 408#if defined(QT_QPROCESS_DEBUG)
405 odebug << "QProcessPrivate: Destructor" << oendl; 409 odebug << "QProcessPrivate: Destructor" << oendl;
406#endif 410#endif
407 411
408 if ( proc != 0 ) { 412 if ( proc != 0 ) {
409 if ( proc->socketStdin != 0 ) { 413 if ( proc->socketStdin != 0 ) {
410 ::close( proc->socketStdin ); 414 ::close( proc->socketStdin );
411 proc->socketStdin = 0; 415 proc->socketStdin = 0;
412 } 416 }
413 proc->process = 0; 417 proc->process = 0;
414 } 418 }
415 419
416 while ( !stdinBuf.isEmpty() ) { 420 while ( !stdinBuf.isEmpty() ) {
417 delete stdinBuf.dequeue(); 421 delete stdinBuf.dequeue();
418 } 422 }
419 delete notifierStdin; 423 delete notifierStdin;
420 delete notifierStdout; 424 delete notifierStdout;
421 delete notifierStderr; 425 delete notifierStderr;
422} 426}
423 427
424/* 428/*
425 Closes all open sockets in the child process that are not needed by the child 429 Closes all open sockets in the child process that are not needed by the child
426 process. Otherwise one child may have an open socket on standard input, etc. 430 process. Otherwise one child may have an open socket on standard input, etc.
427 of another child. 431 of another child.
428*/ 432*/
429void QProcessPrivate::closeOpenSocketsForChild() 433void QProcessPrivate::closeOpenSocketsForChild()
430{ 434{
431 if ( procManager != 0 ) { 435 if ( procManager != 0 ) {
432 if ( procManager->sigchldFd[0] != 0 ) 436 if ( procManager->sigchldFd[0] != 0 )
433 ::close( procManager->sigchldFd[0] ); 437 ::close( procManager->sigchldFd[0] );
434 if ( procManager->sigchldFd[1] != 0 ) 438 if ( procManager->sigchldFd[1] != 0 )
435 ::close( procManager->sigchldFd[1] ); 439 ::close( procManager->sigchldFd[1] );
436 440
437 // close also the sockets from other QProcess instances 441 // close also the sockets from other QProcess instances
438 QProc *proc; 442 QProc *proc;
439 for ( proc=procManager->procList->first(); proc!=0; proc=procManager->procList->next() ) { 443 for ( proc=procManager->procList->first(); proc!=0; proc=procManager->procList->next() ) {
440 ::close( proc->socketStdin ); 444 ::close( proc->socketStdin );
441 ::close( proc->socketStdout ); 445 ::close( proc->socketStdout );
442 ::close( proc->socketStderr ); 446 ::close( proc->socketStderr );
443 } 447 }
444 } 448 }
diff --git a/core/launcher/server.cpp b/core/launcher/server.cpp
index 921b790..c45265a 100644
--- a/core/launcher/server.cpp
+++ b/core/launcher/server.cpp
@@ -242,266 +242,274 @@ static bool hasVisibleWindow(const QString& clientname, bool partial)
242 242
243void Server::activate(const ODeviceButton* button, bool held) 243void Server::activate(const ODeviceButton* button, bool held)
244{ 244{
245 Global::terminateBuiltin("calibrate"); // No tr 245 Global::terminateBuiltin("calibrate"); // No tr
246 OQCopMessage om; 246 OQCopMessage om;
247 if ( held ) { 247 if ( held ) {
248 om = button->heldAction(); 248 om = button->heldAction();
249 } else { 249 } else {
250 om = button->pressedAction(); 250 om = button->pressedAction();
251 } 251 }
252 252
253 if ( om.channel() != "ignore" ) 253 if ( om.channel() != "ignore" )
254 om.send(); 254 om.send();
255 255
256 // A button with no action defined, will return a null ServiceRequest. Don't attempt 256 // A button with no action defined, will return a null ServiceRequest. Don't attempt
257 // to send/do anything with this as it will crash 257 // to send/do anything with this as it will crash
258 /* ### FIXME */ 258 /* ### FIXME */
259#if 0 259#if 0
260 if ( !sr.isNull() ) { 260 if ( !sr.isNull() ) {
261 QString app = sr.app(); 261 QString app = sr.app();
262 bool vis = hasVisibleWindow(app, app != "qpe"); 262 bool vis = hasVisibleWindow(app, app != "qpe");
263 if ( sr.message() == "raise()" && vis ) { 263 if ( sr.message() == "raise()" && vis ) {
264 sr.setMessage("nextView()"); 264 sr.setMessage("nextView()");
265 } else { 265 } else {
266 // "back door" 266 // "back door"
267 sr << (int)vis; 267 sr << (int)vis;
268 } 268 }
269 269
270 sr.send(); 270 sr.send();
271 } 271 }
272#endif 272#endif
273} 273}
274 274
275 275
276#ifdef Q_WS_QWS 276#ifdef Q_WS_QWS
277 277
278typedef struct KeyOverride { 278typedef struct KeyOverride {
279 ushort scan_code; 279 ushort scan_code;
280 QWSServer::KeyMap map; 280 QWSServer::KeyMap map;
281}; 281};
282 282
283 283
284static const KeyOverride jp109keys[] = { 284static const KeyOverride jp109keys[] = {
285 { 0x03, { Qt::Key_2, '2' , 0x22 , 0xffff } }, 285 { 0x03, { Qt::Key_2, '2' , 0x22 , 0xffff } },
286 { 0x07, { Qt::Key_6, '6' , '&' , 0xffff } }, 286 { 0x07, { Qt::Key_6, '6' , '&' , 0xffff } },
287 { 0x08, { Qt::Key_7, '7' , '\'' , 0xffff } }, 287 { 0x08, { Qt::Key_7, '7' , '\'' , 0xffff } },
288 { 0x09, { Qt::Key_8, '8' , '(' , 0xffff } }, 288 { 0x09, { Qt::Key_8, '8' , '(' , 0xffff } },
289 { 0x0a, { Qt::Key_9, '9' , ')' , 0xffff } }, 289 { 0x0a, { Qt::Key_9, '9' , ')' , 0xffff } },
290 { 0x0b, { Qt::Key_0, '0' , 0xffff, 0xffff } }, 290 { 0x0b, { Qt::Key_0, '0' , 0xffff, 0xffff } },
291 { 0x0c, { Qt::Key_Minus, '-' , '=' , 0xffff } }, 291 { 0x0c, { Qt::Key_Minus, '-' , '=' , 0xffff } },
292 { 0x0d, { Qt::Key_AsciiCircum, '^' , '~' , '^'-64 } }, 292 { 0x0d, { Qt::Key_AsciiCircum, '^' , '~' , '^'-64 } },
293 { 0x1a, { Qt::Key_At, '@' , '`' , 0xffff } }, 293 { 0x1a, { Qt::Key_At, '@' , '`' , 0xffff } },
294 { 0x1b, { Qt::Key_BraceLeft, '[' , '{' , '['-64 } }, 294 { 0x1b, { Qt::Key_BraceLeft, '[' , '{' , '['-64 } },
295 { 0x27, { Qt::Key_Semicolon, ';' , '+' , 0xffff } }, 295 { 0x27, { Qt::Key_Semicolon, ';' , '+' , 0xffff } },
296 { 0x28, { Qt::Key_Colon, ':' , '*' , 0xffff } }, 296 { 0x28, { Qt::Key_Colon, ':' , '*' , 0xffff } },
297 { 0x29, { Qt::Key_Zenkaku_Hankaku, 0xffff, 0xffff, 0xffff } }, 297 { 0x29, { Qt::Key_Zenkaku_Hankaku, 0xffff, 0xffff, 0xffff } },
298 { 0x2b, { Qt::Key_BraceRight, ']' , '}' , ']'-64 } }, 298 { 0x2b, { Qt::Key_BraceRight, ']' , '}' , ']'-64 } },
299 { 0x70, { Qt::Key_Hiragana_Katakana, 0xffff, 0xffff, 0xffff } }, 299 { 0x70, { Qt::Key_Hiragana_Katakana, 0xffff, 0xffff, 0xffff } },
300 { 0x73, { Qt::Key_Backslash, '\\' , '_' , 0xffff } }, 300 { 0x73, { Qt::Key_Backslash, '\\' , '_' , 0xffff } },
301 { 0x79, { Qt::Key_Henkan, 0xffff, 0xffff, 0xffff } }, 301 { 0x79, { Qt::Key_Henkan, 0xffff, 0xffff, 0xffff } },
302 { 0x7b, { Qt::Key_Muhenkan, 0xffff, 0xffff, 0xffff } }, 302 { 0x7b, { Qt::Key_Muhenkan, 0xffff, 0xffff, 0xffff } },
303 { 0x7d, { Qt::Key_yen, 0x00a5, '|' , 0xffff } }, 303 { 0x7d, { Qt::Key_yen, 0x00a5, '|' , 0xffff } },
304 { 0x00, { 0, 0xffff, 0xffff, 0xffff } } 304 { 0x00, { 0, 0xffff, 0xffff, 0xffff } }
305}; 305};
306 306
307bool Server::setKeyboardLayout( const QString &kb ) 307bool Server::setKeyboardLayout( const QString &kb )
308{ 308{
309 //quick demo version that can be extended 309 //quick demo version that can be extended
310 310
311 QIntDict<QWSServer::KeyMap> *om = 0; 311 QIntDict<QWSServer::KeyMap> *om = 0;
312 if ( kb == "us101" ) { // No tr 312 if ( kb == "us101" ) { // No tr
313 om = 0; 313 om = 0;
314 } else if ( kb == "jp109" ) { 314 } else if ( kb == "jp109" ) {
315 om = new QIntDict<QWSServer::KeyMap>(37); 315 om = new QIntDict<QWSServer::KeyMap>(37);
316 const KeyOverride *k = jp109keys; 316 const KeyOverride *k = jp109keys;
317 while ( k->scan_code ) { 317 while ( k->scan_code ) {
318 om->insert( k->scan_code, &k->map ); 318 om->insert( k->scan_code, &k->map );
319 k++; 319 k++;
320 } 320 }
321 } 321 }
322 QWSServer::setOverrideKeys( om ); 322 QWSServer::setOverrideKeys( om );
323 323
324 return TRUE; 324 return TRUE;
325} 325}
326#endif 326#endif
327 327
328void Server::systemMsg(const QCString &msg, const QByteArray &data) 328void Server::systemMsg(const QCString &msg, const QByteArray &data)
329{ 329{
330 QDataStream stream( data, IO_ReadOnly ); 330 QDataStream stream( data, IO_ReadOnly );
331 331
332 if ( msg == "securityChanged()" ) { 332 if ( msg == "securityChanged()" ) {
333 if ( transferServer ) 333 if ( transferServer )
334 transferServer->authorizeConnections(); 334 transferServer->authorizeConnections();
335 335
336 if ( qcopBridge ) 336 if ( qcopBridge )
337 qcopBridge->authorizeConnections(); 337 qcopBridge->authorizeConnections();
338#warning FIXME support TempScreenSaverMode 338#warning FIXME support TempScreenSaverMode
339#if 0 339#if 0
340 } else if ( msg == "setTempScreenSaverMode(int,int)" ) { 340 } else if ( msg == "setTempScreenSaverMode(int,int)" ) {
341 int mode, pid; 341 int mode, pid;
342 stream >> mode >> pid; 342 stream >> mode >> pid;
343 tsmMonitor->setTempMode(mode, pid); 343 tsmMonitor->setTempMode(mode, pid);
344#endif 344#endif
345 } else if ( msg == "linkChanged(QString)" ) { 345 } else if ( msg == "linkChanged(QString)" ) {
346 QString link; 346 QString link;
347 stream >> link; 347 stream >> link;
348 odebug << "desktop.cpp systemMsg -> linkchanged( " << link << " )" << oendl; 348 odebug << "desktop.cpp systemMsg -> linkchanged( " << link << " )" << oendl;
349 docList->linkChanged(link); 349 docList->linkChanged(link);
350 } else if (msg =="reforceDocuments()") { 350 } else if (msg =="reforceDocuments()") {
351 docList->reforceDocuments(); 351 docList->reforceDocuments();
352 } else if ( msg == "serviceChanged(QString)" ) { 352 } else if ( msg == "serviceChanged(QString)" ) {
353 MimeType::updateApplications(); 353 MimeType::updateApplications();
354 } else if ( msg == "mkdir(QString)" ) { 354 } else if ( msg == "mkdir(QString)" ) {
355 QString dir; 355 QString dir;
356 stream >> dir; 356 stream >> dir;
357 if ( !dir.isEmpty() ) 357 if ( !dir.isEmpty() )
358 mkdir( dir ); 358 mkdir( dir );
359 } else if ( msg == "rdiffGenSig(QString,QString)" ) { 359 } else if ( msg == "rdiffGenSig(QString,QString)" ) {
360 QString baseFile, sigFile; 360 QString baseFile, sigFile;
361 stream >> baseFile >> sigFile; 361 stream >> baseFile >> sigFile;
362 QRsync::generateSignature( baseFile, sigFile ); 362 QRsync::generateSignature( baseFile, sigFile );
363 } else if ( msg == "rdiffGenDiff(QString,QString,QString)" ) { 363 } else if ( msg == "rdiffGenDiff(QString,QString,QString)" ) {
364 QString baseFile, sigFile, deltaFile; 364 QString baseFile, sigFile, deltaFile;
365 stream >> baseFile >> sigFile >> deltaFile; 365 stream >> baseFile >> sigFile >> deltaFile;
366 QRsync::generateDiff( baseFile, sigFile, deltaFile ); 366 QRsync::generateDiff( baseFile, sigFile, deltaFile );
367 } else if ( msg == "rdiffApplyPatch(QString,QString)" ) { 367 } else if ( msg == "rdiffApplyPatch(QString,QString)" ) {
368 QString baseFile, deltaFile; 368 QString baseFile, deltaFile;
369 stream >> baseFile >> deltaFile; 369 stream >> baseFile >> deltaFile;
370 bool fileWasCreated = false;
370 if ( !QFile::exists( baseFile ) ) { 371 if ( !QFile::exists( baseFile ) ) {
371 QFile f( baseFile ); 372 QFile f( baseFile );
372 f.open( IO_WriteOnly ); 373 fileWasCreated = f.open( IO_WriteOnly );
373 f.close(); 374 f.close();
374 } 375 }
375 QRsync::applyDiff( baseFile, deltaFile ); 376 if ( fileWasCreated ) {
377 QRsync::applyDiff( baseFile, deltaFile );
376#ifndef QT_NO_COP 378#ifndef QT_NO_COP
377 QCopEnvelope e( "QPE/Desktop", "patchApplied(QString)" ); 379 QCopEnvelope e( "QPE/Desktop", "patchApplied(QString)" );
378 e << baseFile; 380 e << baseFile;
379#endif 381#endif
382 } else {
383#ifndef QT_NO_COP
384 QCopEnvelope e( "QPE/Desktop", "patchUnapplied(QString)" );
385 e << baseFile;
386#endif
387 }
380 } else if ( msg == "rdiffCleanup()" ) { 388 } else if ( msg == "rdiffCleanup()" ) {
381 mkdir( "/tmp/rdiff" ); 389 mkdir( "/tmp/rdiff" );
382 QDir dir; 390 QDir dir;
383 dir.setPath( "/tmp/rdiff" ); 391 dir.setPath( "/tmp/rdiff" );
384 QStringList entries = dir.entryList(); 392 QStringList entries = dir.entryList();
385 for ( QStringList::Iterator it = entries.begin(); it != entries.end(); ++it ) 393 for ( QStringList::Iterator it = entries.begin(); it != entries.end(); ++it )
386 dir.remove( *it ); 394 dir.remove( *it );
387 } else if ( msg == "sendHandshakeInfo()" ) { 395 } else if ( msg == "sendHandshakeInfo()" ) {
388 QString home = getenv( "HOME" ); 396 QString home = getenv( "HOME" );
389#ifndef QT_NO_COP 397#ifndef QT_NO_COP
390 QCopEnvelope e( "QPE/Desktop", "handshakeInfo(QString,bool)" ); 398 QCopEnvelope e( "QPE/Desktop", "handshakeInfo(QString,bool)" );
391 e << home; 399 e << home;
392 int locked = (int) ServerApplication::screenLocked(); 400 int locked = (int) ServerApplication::screenLocked();
393 e << locked; 401 e << locked;
394#endif 402#endif
395 } else if ( msg == "sendVersionInfo()" ) { 403 } else if ( msg == "sendVersionInfo()" ) {
396 /* 404 /*
397 * @&$*! Qtopiadesktop relies on the major number 405 * @&$*! Qtopiadesktop relies on the major number
398 * to start with 1. (or 2 as the case of version 2.1 will be) 406 * to start with 1. (or 2 as the case of version 2.1 will be)
399 * we need to fake 1.7 to be able 407 * we need to fake 1.7 to be able
400 * to sync with Qtopiadesktop 1.7. 408 * to sync with Qtopiadesktop 1.7.
401 * We'll send it Opie's version in the platform string for now, 409 * We'll send it Opie's version in the platform string for now,
402 * until such time when QD gets rewritten correctly. 410 * until such time when QD gets rewritten correctly.
403 */ 411 */
404 QCopEnvelope e( "QPE/Desktop", "versionInfo(QString,QString)" ); 412 QCopEnvelope e( "QPE/Desktop", "versionInfo(QString,QString)" );
405 413
406 QString opiename = "Opie "+QString(QPE_VERSION); 414 QString opiename = "Opie "+QString(QPE_VERSION);
407 QString QDVersion="1.7"; 415 QString QDVersion="1.7";
408 e << QDVersion << opiename; 416 e << QDVersion << opiename;
409 417
410 } else if ( msg == "sendCardInfo()" ) { 418 } else if ( msg == "sendCardInfo()" ) {
411#ifndef QT_NO_COP 419#ifndef QT_NO_COP
412 QCopEnvelope e( "QPE/Desktop", "cardInfo(QString)" ); 420 QCopEnvelope e( "QPE/Desktop", "cardInfo(QString)" );
413#endif 421#endif
414 storage->update(); 422 storage->update();
415 const QList<FileSystem> &fs = storage->fileSystems(); 423 const QList<FileSystem> &fs = storage->fileSystems();
416 QListIterator<FileSystem> it ( fs ); 424 QListIterator<FileSystem> it ( fs );
417 QString s; 425 QString s;
418 QString homeDir = getenv("HOME"); 426 QString homeDir = getenv("HOME");
419 QString homeFs, homeFsPath; 427 QString homeFs, homeFsPath;
420 for ( ; it.current(); ++it ) { 428 for ( ; it.current(); ++it ) {
421 int k4 = (*it)->blockSize()/256; 429 int k4 = (*it)->blockSize()/256;
422 if ( (*it)->isRemovable() ) { 430 if ( (*it)->isRemovable() ) {
423 s += (*it)->name() + "=" + (*it)->path() + "/Documents " // No tr 431 s += (*it)->name() + "=" + (*it)->path() + "/Documents " // No tr
424 + QString::number( (*it)->availBlocks() * k4/4 ) 432 + QString::number( (*it)->availBlocks() * k4/4 )
425 + "K " + (*it)->options() + ";"; 433 + "K " + (*it)->options() + ";";
426 } else if ( homeDir.contains( (*it)->path() ) && 434 } else if ( homeDir.contains( (*it)->path() ) &&
427 (*it)->path().length() > homeFsPath.length() ) { 435 (*it)->path().length() > homeFsPath.length() ) {
428 homeFsPath = (*it)->path(); 436 homeFsPath = (*it)->path();
429 homeFs = 437 homeFs =
430 (*it)->name() + "=" + homeDir + "/Documents " // No tr 438 (*it)->name() + "=" + homeDir + "/Documents " // No tr
431 + QString::number( (*it)->availBlocks() * k4/4 ) 439 + QString::number( (*it)->availBlocks() * k4/4 )
432 + "K " + (*it)->options() + ";"; 440 + "K " + (*it)->options() + ";";
433 } 441 }
434 } 442 }
435 if ( !homeFs.isEmpty() ) 443 if ( !homeFs.isEmpty() )
436 s += homeFs; 444 s += homeFs;
437#ifndef QT_NO_COP 445#ifndef QT_NO_COP
438 e << s; 446 e << s;
439#endif 447#endif
440 } else if ( msg == "sendInstallLocations()" ) { 448 } else if ( msg == "sendInstallLocations()" ) {
441#ifndef QT_NO_COP 449#ifndef QT_NO_COP
442 QCopEnvelope e( "QPE/Desktop", "installLocations(QString)" ); 450 QCopEnvelope e( "QPE/Desktop", "installLocations(QString)" );
443 e << installLocationsString(); 451 e << installLocationsString();
444#endif 452#endif
445 } else if ( msg == "sendSyncDate(QString)" ) { 453 } else if ( msg == "sendSyncDate(QString)" ) {
446 QString app; 454 QString app;
447 stream >> app; 455 stream >> app;
448 Config cfg( "qpe" ); 456 Config cfg( "qpe" );
449 cfg.setGroup("SyncDate"); 457 cfg.setGroup("SyncDate");
450#ifndef QT_NO_COP 458#ifndef QT_NO_COP
451 QCopEnvelope e( "QPE/Desktop", "syncDate(QString,QString)" ); 459 QCopEnvelope e( "QPE/Desktop", "syncDate(QString,QString)" );
452 e << app << cfg.readEntry( app ); 460 e << app << cfg.readEntry( app );
453#endif 461#endif
454 //odebug << "QPE/System sendSyncDate for " << app.latin1() << ": response " 462 //odebug << "QPE/System sendSyncDate for " << app.latin1() << ": response "
455 // << cfg.readEntry( app ).latin1() << oendl; 463 // << cfg.readEntry( app ).latin1() << oendl;
456 } else if ( msg == "setSyncDate(QString,QString)" ) { 464 } else if ( msg == "setSyncDate(QString,QString)" ) {
457 QString app, date; 465 QString app, date;
458 stream >> app >> date; 466 stream >> app >> date;
459 Config cfg( "qpe" ); 467 Config cfg( "qpe" );
460 cfg.setGroup("SyncDate"); 468 cfg.setGroup("SyncDate");
461 cfg.writeEntry( app, date ); 469 cfg.writeEntry( app, date );
462 //odebug << "setSyncDate(QString,QString) " << app << " " << date << "" << oendl; 470 //odebug << "setSyncDate(QString,QString) " << app << " " << date << "" << oendl;
463 } else if ( msg == "startSync(QString)" ) { 471 } else if ( msg == "startSync(QString)" ) {
464 QString what; 472 QString what;
465 stream >> what; 473 stream >> what;
466 delete syncDialog; 474 delete syncDialog;
467 syncDialog = new SyncDialog( this, what ); 475 syncDialog = new SyncDialog( this, what );
468 syncDialog->show(); 476 syncDialog->show();
469 connect( syncDialog, SIGNAL(cancel()), SLOT(cancelSync()) ); 477 connect( syncDialog, SIGNAL(cancel()), SLOT(cancelSync()) );
470 } else if ( msg == "stopSync()") { 478 } else if ( msg == "stopSync()") {
471 delete syncDialog; 479 delete syncDialog;
472 syncDialog = 0; 480 syncDialog = 0;
473 } else if (msg == "restoreDone(QString)") { 481 } else if (msg == "restoreDone(QString)") {
474 docList->restoreDone(); 482 docList->restoreDone();
475 } else if ( msg == "getAllDocLinks()" ) { 483 } else if ( msg == "getAllDocLinks()" ) {
476 docList->sendAllDocLinks(); 484 docList->sendAllDocLinks();
477 } 485 }
478#ifdef QPE_HAVE_DIRECT_ACCESS 486#ifdef QPE_HAVE_DIRECT_ACCESS
479 else if ( msg == "prepareDirectAccess()" ) { 487 else if ( msg == "prepareDirectAccess()" ) {
480 prepareDirectAccess(); 488 prepareDirectAccess();
481 } else if ( msg == "postDirectAccess()" ) { 489 } else if ( msg == "postDirectAccess()" ) {
482 postDirectAccess(); 490 postDirectAccess();
483 } 491 }
484#endif 492#endif
485#ifdef Q_WS_QWS 493#ifdef Q_WS_QWS
486 494
487 else if ( msg == "setMouseProto(QString)" ) { 495 else if ( msg == "setMouseProto(QString)" ) {
488 QString mice; 496 QString mice;
489 stream >> mice; 497 stream >> mice;
490 setenv("QWS_MOUSE_PROTO",mice.latin1(),1); 498 setenv("QWS_MOUSE_PROTO",mice.latin1(),1);
491 qwsServer->openMouse(); 499 qwsServer->openMouse();
492 } else if ( msg == "setKeyboard(QString)" ) { 500 } else if ( msg == "setKeyboard(QString)" ) {
493 QString kb; 501 QString kb;
494 stream >> kb; 502 stream >> kb;
495 setenv("QWS_KEYBOARD",kb.latin1(),1); 503 setenv("QWS_KEYBOARD",kb.latin1(),1);
496 qwsServer->openKeyboard(); 504 qwsServer->openKeyboard();
497 } else if ( msg == "setKeyboardAutoRepeat(int,int)" ) { 505 } else if ( msg == "setKeyboardAutoRepeat(int,int)" ) {
498 int delay, period; 506 int delay, period;
499 stream >> delay >> period; 507 stream >> delay >> period;
500 qwsSetKeyboardAutoRepeat( delay, period ); 508 qwsSetKeyboardAutoRepeat( delay, period );
501 Config cfg( "qpe" ); 509 Config cfg( "qpe" );
502 cfg.setGroup("Keyboard"); 510 cfg.setGroup("Keyboard");
503 cfg.writeEntry( "RepeatDelay", delay ); 511 cfg.writeEntry( "RepeatDelay", delay );
504 cfg.writeEntry( "RepeatPeriod", period ); 512 cfg.writeEntry( "RepeatPeriod", period );
505 } else if ( msg == "setKeyboardLayout(QString)" ) { 513 } else if ( msg == "setKeyboardLayout(QString)" ) {
506 QString kb; 514 QString kb;
507 stream >> kb; 515 stream >> kb;
@@ -873,134 +881,135 @@ void Server::desktopMessage( const QCString &message, const QByteArray &data )
873 runDirectAccess(); 881 runDirectAccess();
874 } 882 }
875 } else if ( message == "installStarted(QString)" ) { 883 } else if ( message == "installStarted(QString)" ) {
876 QString package; 884 QString package;
877 stream >> package; 885 stream >> package;
878 qDebug( "\tInstall Started for package %s", package.latin1() ); 886 qDebug( "\tInstall Started for package %s", package.latin1() );
879 } else if ( message == "installStep(QString)" ) { 887 } else if ( message == "installStep(QString)" ) {
880 QString step; 888 QString step;
881 stream >> step; 889 stream >> step;
882 qDebug( "\tInstall Step %s", step.latin1() ); 890 qDebug( "\tInstall Step %s", step.latin1() );
883 } else if ( message == "installDone(QString)" ) { 891 } else if ( message == "installDone(QString)" ) {
884 QString package; 892 QString package;
885 stream >> package; 893 stream >> package;
886 qDebug( "\tInstall Finished for package %s", package.latin1() ); 894 qDebug( "\tInstall Finished for package %s", package.latin1() );
887 } else if ( message == "installFailed(QString,int,QString)" ) { 895 } else if ( message == "installFailed(QString,int,QString)" ) {
888 QString package, error; 896 QString package, error;
889 int status; 897 int status;
890 stream >> package >> status >> error; 898 stream >> package >> status >> error;
891 qDebug( "\tInstall Failed for package %s with error code %d and error message %s", 899 qDebug( "\tInstall Failed for package %s with error code %d and error message %s",
892 package.latin1(), status, error.latin1() ); 900 package.latin1(), status, error.latin1() );
893 } else if ( message == "removeStarted(QString)" ) { 901 } else if ( message == "removeStarted(QString)" ) {
894 QString package; 902 QString package;
895 stream >> package; 903 stream >> package;
896 qDebug( "\tRemove Started for package %s", package.latin1() ); 904 qDebug( "\tRemove Started for package %s", package.latin1() );
897 } else if ( message == "removeDone(QString)" ) { 905 } else if ( message == "removeDone(QString)" ) {
898 QString package; 906 QString package;
899 stream >> package; 907 stream >> package;
900 qDebug( "\tRemove Finished for package %s", package.latin1() ); 908 qDebug( "\tRemove Finished for package %s", package.latin1() );
901 } else if ( message == "removeFailed(QString)" ) { 909 } else if ( message == "removeFailed(QString)" ) {
902 QString package; 910 QString package;
903 stream >> package; 911 stream >> package;
904 qDebug( "\tRemove Failed for package %s", package.latin1() ); 912 qDebug( "\tRemove Failed for package %s", package.latin1() );
905 } 913 }
906 914
907 if ( qrr && qrr->waitingForMessages ) 915 if ( qrr && qrr->waitingForMessages )
908 qrr->desktopMessage( message, data ); 916 qrr->desktopMessage( message, data );
909} 917}
910 918
911 919
912// This is only connected if QPE_HAVE_DIRECT_ACCESS is defined 920// This is only connected if QPE_HAVE_DIRECT_ACCESS is defined
913void Server::runDirectAccess() 921void Server::runDirectAccess()
914{ 922{
915#ifdef QPE_HAVE_DIRECT_ACCESS 923#ifdef QPE_HAVE_DIRECT_ACCESS
916 // The timer must have fired after all the apps responded 924 // The timer must have fired after all the apps responded
917 // with flushDone(). Just ignore it. 925 // with flushDone(). Just ignore it.
918 if ( directAccessRun ) 926 if ( directAccessRun )
919 return; 927 return;
920 928
921 directAccessRun = TRUE; 929 directAccessRun = TRUE;
922 ::readyDirectAccess(cardInfoString(), installLocationsString()); 930 ::readyDirectAccess(cardInfoString(), installLocationsString());
923#endif 931#endif
924} 932}
925 933
926// This is only called if QPE_HAVE_DIRECT_ACCESS is defined 934// This is only called if QPE_HAVE_DIRECT_ACCESS is defined
927void Server::postDirectAccess() 935void Server::postDirectAccess()
928{ 936{
929#ifdef QPE_HAVE_DIRECT_ACCESS 937#ifdef QPE_HAVE_DIRECT_ACCESS
930 qDebug( "Server::postDirectAccess()" ); 938 qDebug( "Server::postDirectAccess()" );
931 939
932 // Categories may have changed 940 // Categories may have changed
933 QCopEnvelope e1( "QPE/System", "categoriesChanged()" ); 941 QCopEnvelope e1( "QPE/System", "categoriesChanged()" );
934 // Apps need to reload their data 942 // Apps need to reload their data
935 QCopEnvelope e2( "QPE/System", "reload()" ); 943 QCopEnvelope e2( "QPE/System", "reload()" );
936 // Reload DocLinks 944 // Reload DocLinks
937 docList->storageChanged(); 945 docList->storageChanged();
938 // Restart the PDA server stuff 946 // Restart the PDA server stuff
939 startTransferServer(); 947 startTransferServer();
940 948
941 // restart the mtab monitor 949 // restart the mtab monitor
942#ifndef QT_NO_COP 950#ifndef QT_NO_COP
943 { 951 {
944 QCopEnvelope e( "QPE/Stabmon", "restartMonitor()" ); 952 QCopEnvelope e( "QPE/Stabmon", "restartMonitor()" );
945 } 953 }
946#endif 954#endif
947 955
948 // Process queued requests 956 // Process queued requests
949 const char *queueFile = ::directAccessQueueFile(); 957 const char *queueFile = ::directAccessQueueFile();
950 QFile *file = new QFile( queueFile ); 958 QFile *file = new QFile( queueFile );
951 if ( !file->exists() ) { 959 if ( !file->exists() ) {
952 delete file; 960 delete file;
953 // Get rid of the dialog 961 // Get rid of the dialog
954 if ( syncDialog ) { 962 if ( syncDialog ) {
955 delete syncDialog; 963 delete syncDialog;
956 syncDialog = 0; 964 syncDialog = 0;
957 } 965 }
958#warning FIXME support TempScreenSaverMode 966#warning FIXME support TempScreenSaverMode
959#if 0 967#if 0
960 QPEApplication::setTempScreenSaverMode(QPEApplication::Enable); 968 QPEApplication::setTempScreenSaverMode(QPEApplication::Enable);
961#endif 969#endif
962 } else { 970 } else {
963 qrr = new QueuedRequestRunner( file, syncDialog ); 971 qrr = new QueuedRequestRunner( file, syncDialog );
964 connect( qrr, SIGNAL(finished()), 972 connect( qrr, SIGNAL(finished()),
965 this, SLOT(finishedQueuedRequests()) ); 973 this, SLOT(finishedQueuedRequests()) );
966 QTimer::singleShot( 100, qrr, SLOT(process()) ); 974 QTimer::singleShot( 100, qrr, SLOT(process()) );
967 // qrr will remove the sync dialog later 975 // qrr will remove the sync dialog later
968 } 976 }
969#endif 977#endif
970} 978}
971 979
972void Server::finishedQueuedRequests() 980void Server::finishedQueuedRequests()
973{ 981{
974 if ( qrr->readyToDelete ) { 982 if ( qrr->readyToDelete ) {
975 delete qrr; 983 delete qrr;
976 qrr = 0; 984 qrr = 0;
977 // Get rid of the dialog 985 // Get rid of the dialog
978 if ( syncDialog ) { 986 if ( syncDialog ) {
979 delete syncDialog; 987 delete syncDialog;
980 syncDialog = 0; 988 syncDialog = 0;
981 } 989 }
982#warning FIXME support TempScreenSaverMode 990#warning FIXME support TempScreenSaverMode
983#if 0 991#if 0
984 QPEApplication::setTempScreenSaverMode(QPEApplication::Enable); 992 QPEApplication::setTempScreenSaverMode(QPEApplication::Enable);
985#endif 993#endif
986 } else { 994 } else {
987 qrr->readyToDelete = TRUE; 995 qrr->readyToDelete = TRUE;
988 QTimer::singleShot( 0, this, SLOT(finishedQueuedRequests()) ); 996 QTimer::singleShot( 0, this, SLOT(finishedQueuedRequests()) );
989 } 997 }
990} 998}
991 999
992void Server::startSoundServer() { 1000void Server::startSoundServer() {
993 if ( !process ) { 1001 if ( !process ) {
994 process = new Opie::Core::OProcess( this ); 1002 process = new Opie::Core::OProcess( this );
995 connect(process, SIGNAL(processExited(Opie::Core::OProcess*)), 1003 connect(process, SIGNAL(processExited(Opie::Core::OProcess*)),
996 SLOT(soundServerExited())); 1004 SLOT(soundServerExited()));
997 } 1005 }
998 1006
999 process->clearArguments(); 1007 process->clearArguments();
1000 *process << QPEApplication::qpeDir() + "bin/qss"; 1008 *process << QPEApplication::qpeDir() + "bin/qss";
1001 process->start(); 1009 if (!process->start())
1010 owarn << "Sound server process did not start" << oendl;
1002} 1011}
1003 1012
1004void Server::soundServerExited() { 1013void Server::soundServerExited() {
1005 QTimer::singleShot(5000, this, SLOT(startSoundServer())); 1014 QTimer::singleShot(5000, this, SLOT(startSoundServer()));
1006} 1015}
diff --git a/core/settings/launcher/menusettings.cpp b/core/settings/launcher/menusettings.cpp
index 29ce841..d63b203 100644
--- a/core/settings/launcher/menusettings.cpp
+++ b/core/settings/launcher/menusettings.cpp
@@ -1,178 +1,181 @@
1/* 1/*
2 This file is part of the OPIE Project 2 This file is part of the OPIE Project
3 =. Copyright (c) 2002 Trolltech AS <info@trolltech.com> 3 =. Copyright (c) 2002 Trolltech AS <info@trolltech.com>
4 .=l. Copyright (c) 2002 Robert Griebl <sandman@handhelds.org> 4 .=l. Copyright (c) 2002 Robert Griebl <sandman@handhelds.org>
5 .>+-= 5 .>+-=
6_;:, .> :=|. This file is free software; you can 6_;:, .> :=|. This file is free software; you can
7.> <`_, > . <= redistribute it and/or modify it under 7.> <`_, > . <= redistribute it and/or modify it under
8:`=1 )Y*s>-.-- : the terms of the GNU General Public 8:`=1 )Y*s>-.-- : the terms of the GNU General Public
9.="- .-=="i, .._ License as published by the Free Software 9.="- .-=="i, .._ License as published by the Free Software
10- . .-<_> .<> Foundation; either version 2 of the License, 10- . .-<_> .<> Foundation; either version 2 of the License,
11 ._= =} : or (at your option) any later version. 11 ._= =} : or (at your option) any later version.
12 .%`+i> _;_. 12 .%`+i> _;_.
13 .i_,=:_. -<s. This file is distributed in the hope that 13 .i_,=:_. -<s. This file is distributed in the hope that
14 + . -:. = it will be useful, but WITHOUT ANY WARRANTY; 14 + . -:. = it will be useful, but WITHOUT ANY WARRANTY;
15 : .. .:, . . . without even the implied warranty of 15 : .. .:, . . . without even the implied warranty of
16 =_ + =;=|` MERCHANTABILITY or FITNESS FOR A 16 =_ + =;=|` MERCHANTABILITY or FITNESS FOR A
17 _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU General 17 _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU General
18..}^=.= = ; Public License for more details. 18..}^=.= = ; Public License for more details.
19++= -. .` .: 19++= -. .` .:
20: = ...= . :.=- You should have received a copy of the GNU 20: = ...= . :.=- You should have received a copy of the GNU
21-. .:....=;==+<; General Public License along with this file; 21-. .:....=;==+<; General Public License along with this file;
22 -_. . . )=. = see the file COPYING. If not, write to the 22 -_. . . )=. = see the file COPYING. If not, write to the
23 -- :-=` Free Software Foundation, Inc., 23 -- :-=` Free Software Foundation, Inc.,
24 59 Temple Place - Suite 330, 24 59 Temple Place - Suite 330,
25 Boston, MA 02111-1307, USA. 25 Boston, MA 02111-1307, USA.
26 26
27*/ 27*/
28 28
29#include "menusettings.h" 29#include "menusettings.h"
30 30
31#include <qpe/config.h> 31#include <qpe/config.h>
32#include <qpe/qlibrary.h> 32#include <qpe/qlibrary.h>
33#include <qpe/qpeapplication.h> 33#include <qpe/qpeapplication.h>
34#include <qpe/menuappletinterface.h> 34#include <qpe/menuappletinterface.h>
35#include <qpe/qcopenvelope_qws.h> 35#include <qpe/qcopenvelope_qws.h>
36#include <opie2/odebug.h>
36 37
37#include <qdir.h> 38#include <qdir.h>
38#include <qlistview.h> 39#include <qlistview.h>
39#include <qcheckbox.h> 40#include <qcheckbox.h>
40#include <qheader.h> 41#include <qheader.h>
41#include <qlayout.h> 42#include <qlayout.h>
42#include <qlabel.h> 43#include <qlabel.h>
43#include <qwhatsthis.h> 44#include <qwhatsthis.h>
44 45
45#include <stdlib.h> 46#include <stdlib.h>
46 47
47 48
48MenuSettings::MenuSettings ( QWidget *parent, const char *name ) 49MenuSettings::MenuSettings ( QWidget *parent, const char *name )
49 : QWidget ( parent, name ) 50 : QWidget ( parent, name )
50{ 51{
51 m_applets_changed = false; 52 m_applets_changed = false;
52 53
53 QBoxLayout *lay = new QVBoxLayout ( this, 4, 4 ); 54 QBoxLayout *lay = new QVBoxLayout ( this, 4, 4 );
54 55
55 QLabel *l = new QLabel ( tr( "Load applets in O-Menu:" ), this ); 56 QLabel *l = new QLabel ( tr( "Load applets in O-Menu:" ), this );
56 lay-> addWidget ( l ); 57 lay-> addWidget ( l );
57 58
58 m_list = new QListView ( this ); 59 m_list = new QListView ( this );
59 m_list-> addColumn ( "foobar" ); 60 m_list-> addColumn ( "foobar" );
60 m_list-> header ( )-> hide ( ); 61 m_list-> header ( )-> hide ( );
61 62
62 lay-> addWidget ( m_list ); 63 lay-> addWidget ( m_list );
63 64
64 m_menutabs = new QCheckBox ( tr( "Show Launcher tabs in O-Menu" ), this ); 65 m_menutabs = new QCheckBox ( tr( "Show Launcher tabs in O-Menu" ), this );
65 lay-> addWidget ( m_menutabs ); 66 lay-> addWidget ( m_menutabs );
66 67
67 m_menusubpopup = new QCheckBox ( tr( "Show Applications in Subpopups" ), this ); 68 m_menusubpopup = new QCheckBox ( tr( "Show Applications in Subpopups" ), this );
68 lay-> addWidget ( m_menusubpopup ); 69 lay-> addWidget ( m_menusubpopup );
69 70
70 QWhatsThis::add ( m_list, tr( "Check the applets that you want to have included in the O-Menu." )); 71 QWhatsThis::add ( m_list, tr( "Check the applets that you want to have included in the O-Menu." ));
71 QWhatsThis::add ( m_menutabs, tr( "Adds the contents of the Launcher Tabs as menus in the O-Menu." )); 72 QWhatsThis::add ( m_menutabs, tr( "Adds the contents of the Launcher Tabs as menus in the O-Menu." ));
72 73
73 connect ( m_list, SIGNAL( clicked(QListViewItem*)), this, SLOT( appletChanged())); 74 connect ( m_list, SIGNAL( clicked(QListViewItem*)), this, SLOT( appletChanged()));
74 75
75 init ( ); 76 init ( );
76} 77}
77 78
78void MenuSettings::init ( ) 79void MenuSettings::init ( )
79{ 80{
80 Config cfg ( "StartMenu" ); 81 Config cfg ( "StartMenu" );
81 cfg. setGroup ( "Applets" ); 82 cfg. setGroup ( "Applets" );
82 QStringList exclude = cfg. readListEntry ( "ExcludeApplets", ',' ); 83 QStringList exclude = cfg. readListEntry ( "ExcludeApplets", ',' );
83 84
84 QString path = QPEApplication::qpeDir ( ) + "plugins/applets"; 85 QString path = QPEApplication::qpeDir ( ) + "plugins/applets";
85#ifdef Q_OS_MACX 86#ifdef Q_OS_MACX
86 QStringList list = QDir ( path, "lib*.dylib" ). entryList ( ); 87 QStringList list = QDir ( path, "lib*.dylib" ). entryList ( );
87#else 88#else
88 QStringList list = QDir ( path, "lib*.so" ). entryList ( ); 89 QStringList list = QDir ( path, "lib*.so" ). entryList ( );
89#endif /* Q_OS_MACX */ 90#endif /* Q_OS_MACX */
90 91
91 for ( QStringList::Iterator it = list. begin ( ); it != list. end ( ); ++it ) { 92 for ( QStringList::Iterator it = list. begin ( ); it != list. end ( ); ++it ) {
92 QString name; 93 QString name;
93 QPixmap icon; 94 QPixmap icon;
94 MenuAppletInterface *iface = 0; 95 MenuAppletInterface *iface = 0;
95 96
96 QLibrary *lib = new QLibrary ( path + "/" + *it ); 97 QLibrary *lib = new QLibrary ( path + "/" + *it );
97 lib-> queryInterface ( IID_MenuApplet, (QUnknownInterface**) &iface ); 98 QRESULT retVal = QS_OK;
99 if ((retVal = lib-> queryInterface ( IID_MenuApplet, (QUnknownInterface**)(&iface) )) != QS_OK )
100 owarn << "queryInterface failed with " << retVal << oendl;
98 if ( iface ) { 101 if ( iface ) {
99 QString lang = getenv( "LANG" ); 102 QString lang = getenv( "LANG" );
100 QTranslator *trans = new QTranslator ( qApp ); 103 QTranslator *trans = new QTranslator ( qApp );
101 QString type = (*it). left ((*it). find (".")); 104 QString type = (*it). left ((*it). find ("."));
102 QString tfn = QPEApplication::qpeDir ( ) + "i18n/" + lang + "/" + type + ".qm"; 105 QString tfn = QPEApplication::qpeDir ( ) + "i18n/" + lang + "/" + type + ".qm";
103 if ( trans-> load ( tfn )) 106 if ( trans-> load ( tfn ))
104 qApp-> installTranslator ( trans ); 107 qApp-> installTranslator ( trans );
105 else 108 else
106 delete trans; 109 delete trans;
107 name = iface-> name ( ); 110 name = iface-> name ( );
108 icon = iface-> icon ( ). pixmap (); 111 icon = iface-> icon ( ). pixmap ();
109 iface-> release ( ); 112 iface-> release ( );
110 lib-> unload ( ); 113 lib-> unload ( );
111 114
112 QCheckListItem *item; 115 QCheckListItem *item;
113 item = new QCheckListItem ( m_list, name, QCheckListItem::CheckBox ); 116 item = new QCheckListItem ( m_list, name, QCheckListItem::CheckBox );
114 if ( !icon. isNull ( )) 117 if ( !icon. isNull ( ))
115 item-> setPixmap ( 0, icon ); 118 item-> setPixmap ( 0, icon );
116 item-> setOn ( exclude. find ( *it ) == exclude. end ( )); 119 item-> setOn ( exclude. find ( *it ) == exclude. end ( ));
117 m_applets [*it] = item; 120 m_applets [*it] = item;
118 } else { 121 } else {
119 delete lib; 122 delete lib;
120 } 123 }
121 } 124 }
122 125
123 cfg. setGroup ( "Menu" ); 126 cfg. setGroup ( "Menu" );
124 m_menutabs->setChecked( cfg.readBoolEntry( "LauncherTabs", true ) ); 127 m_menutabs->setChecked( cfg.readBoolEntry( "LauncherTabs", true ) );
125 m_menusubpopup->setChecked( cfg.readBoolEntry( "LauncherSubPopup", true ) ); 128 m_menusubpopup->setChecked( cfg.readBoolEntry( "LauncherSubPopup", true ) );
126 m_menusubpopup->setEnabled( m_menutabs->isChecked() ); 129 m_menusubpopup->setEnabled( m_menutabs->isChecked() );
127 connect( m_menutabs, SIGNAL( stateChanged(int) ), m_menusubpopup, SLOT( setEnabled(bool) ) ); 130 connect( m_menutabs, SIGNAL( stateChanged(int) ), m_menusubpopup, SLOT( setEnabled(bool) ) );
128 131
129} 132}
130 133
131void MenuSettings::appletChanged() 134void MenuSettings::appletChanged()
132{ 135{
133 m_applets_changed = true; 136 m_applets_changed = true;
134} 137}
135 138
136void MenuSettings::accept ( ) 139void MenuSettings::accept ( )
137{ 140{
138 bool apps_changed = false; 141 bool apps_changed = false;
139 142
140 Config cfg ( "StartMenu" ); 143 Config cfg ( "StartMenu" );
141 cfg. setGroup ( "Applets" ); 144 cfg. setGroup ( "Applets" );
142 if ( m_applets_changed ) { 145 if ( m_applets_changed ) {
143 QStringList exclude; 146 QStringList exclude;
144 QMap <QString, QCheckListItem *>::Iterator it; 147 QMap <QString, QCheckListItem *>::Iterator it;
145 for ( it = m_applets. begin ( ); it != m_applets. end ( ); ++it ) { 148 for ( it = m_applets. begin ( ); it != m_applets. end ( ); ++it ) {
146 if ( !(*it)-> isOn ( )) 149 if ( !(*it)-> isOn ( ))
147 exclude << it. key ( ); 150 exclude << it. key ( );
148 } 151 }
149 cfg. writeEntry ( "ExcludeApplets", exclude, ',' ); 152 cfg. writeEntry ( "ExcludeApplets", exclude, ',' );
150 } 153 }
151 cfg. writeEntry ( "SafeMode", false ); 154 cfg. writeEntry ( "SafeMode", false );
152 155
153 cfg. setGroup ( "Menu" ); 156 cfg. setGroup ( "Menu" );
154 157
155 if ( m_menutabs-> isChecked ( ) != cfg. readBoolEntry ( "LauncherTabs", true )) { 158 if ( m_menutabs-> isChecked ( ) != cfg. readBoolEntry ( "LauncherTabs", true )) {
156 apps_changed = true; 159 apps_changed = true;
157 cfg. writeEntry ( "LauncherTabs", m_menutabs-> isChecked ( )); 160 cfg. writeEntry ( "LauncherTabs", m_menutabs-> isChecked ( ));
158 } 161 }
159 162
160 if ( m_menusubpopup-> isChecked ( ) != cfg. readBoolEntry ( "LauncherSubPopup", true )) { 163 if ( m_menusubpopup-> isChecked ( ) != cfg. readBoolEntry ( "LauncherSubPopup", true )) {
161 apps_changed = true; 164 apps_changed = true;
162 cfg. writeEntry ( "LauncherSubPopup", m_menusubpopup-> isChecked ( )); 165 cfg. writeEntry ( "LauncherSubPopup", m_menusubpopup-> isChecked ( ));
163 } 166 }
164 167
165 cfg. write ( ); 168 cfg. write ( );
166 169
167 if ( m_applets_changed ) { 170 if ( m_applets_changed ) {
168 QCopEnvelope ( "QPE/TaskBar", "reloadApplets()" ); 171 QCopEnvelope ( "QPE/TaskBar", "reloadApplets()" );
169 m_applets_changed = false; 172 m_applets_changed = false;
170 } 173 }
171 if ( apps_changed ) { 174 if ( apps_changed ) {
172 // currently use reloadApplets() since reloadApps is now used exclusive for server 175 // currently use reloadApplets() since reloadApps is now used exclusive for server
173 // to refresh the tabs. But what we want here is also a refresh of the startmenu entries 176 // to refresh the tabs. But what we want here is also a refresh of the startmenu entries
174 QCopEnvelope ( "QPE/TaskBar", "reloadApps()" ); 177 QCopEnvelope ( "QPE/TaskBar", "reloadApps()" );
175 QCopEnvelope ( "QPE/TaskBar", "reloadApplets()" ); 178 QCopEnvelope ( "QPE/TaskBar", "reloadApplets()" );
176 } 179 }
177} 180}
178 181
diff --git a/core/settings/launcher/taskbarsettings.cpp b/core/settings/launcher/taskbarsettings.cpp
index 861ff3a..c2b82b9 100644
--- a/core/settings/launcher/taskbarsettings.cpp
+++ b/core/settings/launcher/taskbarsettings.cpp
@@ -1,176 +1,179 @@
1/* 1/*
2                This file is part of the OPIE Project 2                This file is part of the OPIE Project
3 =. Copyright (c) 2002 Trolltech AS <info@trolltech.com> 3 =. Copyright (c) 2002 Trolltech AS <info@trolltech.com>
4             .=l. Copyright (c) 2002 Robert Griebl <sandman@handhelds.org> 4             .=l. Copyright (c) 2002 Robert Griebl <sandman@handhelds.org>
5           .>+-= 5           .>+-=
6 _;:,     .>    :=|. This file is free software; you can 6 _;:,     .>    :=|. This file is free software; you can
7.> <`_,   >  .   <= redistribute it and/or modify it under 7.> <`_,   >  .   <= redistribute it and/or modify it under
8:`=1 )Y*s>-.--   : the terms of the GNU General Public 8:`=1 )Y*s>-.--   : the terms of the GNU General Public
9.="- .-=="i,     .._ License as published by the Free Software 9.="- .-=="i,     .._ License as published by the Free Software
10 - .   .-<_>     .<> Foundation; either version 2 of the License, 10 - .   .-<_>     .<> Foundation; either version 2 of the License,
11     ._= =}       : or (at your option) any later version. 11     ._= =}       : or (at your option) any later version.
12    .%`+i>       _;_. 12    .%`+i>       _;_.
13    .i_,=:_.      -<s. This file is distributed in the hope that 13    .i_,=:_.      -<s. This file is distributed in the hope that
14     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY; 14     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY;
15    : ..    .:,     . . . without even the implied warranty of 15    : ..    .:,     . . . without even the implied warranty of
16    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A 16    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A
17  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU General 17  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU General
18..}^=.=       =       ; Public License for more details. 18..}^=.=       =       ; Public License for more details.
19++=   -.     .`     .: 19++=   -.     .`     .:
20 :     =  ...= . :.=- You should have received a copy of the GNU 20 :     =  ...= . :.=- You should have received a copy of the GNU
21 -.   .:....=;==+<; General Public License along with this file; 21 -.   .:....=;==+<; General Public License along with this file;
22  -_. . .   )=.  = see the file COPYING. If not, write to the 22  -_. . .   )=.  = see the file COPYING. If not, write to the
23    --        :-=` Free Software Foundation, Inc., 23    --        :-=` Free Software Foundation, Inc.,
24 59 Temple Place - Suite 330, 24 59 Temple Place - Suite 330,
25 Boston, MA 02111-1307, USA. 25 Boston, MA 02111-1307, USA.
26 26
27*/ 27*/
28 28
29#include "taskbarsettings.h" 29#include "taskbarsettings.h"
30 30
31/* OPIE */ 31/* OPIE */
32#include <qpe/config.h> 32#include <qpe/config.h>
33#include <qpe/qlibrary.h> 33#include <qpe/qlibrary.h>
34#include <qpe/qpeapplication.h> 34#include <qpe/qpeapplication.h>
35#include <qpe/taskbarappletinterface.h> 35#include <qpe/taskbarappletinterface.h>
36#include <qpe/qcopenvelope_qws.h> 36#include <qpe/qcopenvelope_qws.h>
37#include <opie2/odebug.h> 37#include <opie2/odebug.h>
38 38
39/* QT */ 39/* QT */
40#include <qdir.h> 40#include <qdir.h>
41#include <qlistview.h> 41#include <qlistview.h>
42#include <qheader.h> 42#include <qheader.h>
43#include <qlayout.h> 43#include <qlayout.h>
44#include <qlabel.h> 44#include <qlabel.h>
45#include <qwhatsthis.h> 45#include <qwhatsthis.h>
46 46
47/* STD */ 47/* STD */
48#include <stdlib.h> 48#include <stdlib.h>
49 49
50 50
51TaskbarSettings::TaskbarSettings ( QWidget *parent, const char *name ) 51TaskbarSettings::TaskbarSettings ( QWidget *parent, const char *name )
52 : QWidget ( parent, name ) 52 : QWidget ( parent, name )
53{ 53{
54 m_applets_changed = false; 54 m_applets_changed = false;
55 55
56 QBoxLayout *lay = new QVBoxLayout ( this, 4, 4 ); 56 QBoxLayout *lay = new QVBoxLayout ( this, 4, 4 );
57 57
58 QLabel *l = new QLabel ( tr( "Load applets in Taskbar:" ), this ); 58 QLabel *l = new QLabel ( tr( "Load applets in Taskbar:" ), this );
59 lay-> addWidget ( l ); 59 lay-> addWidget ( l );
60 60
61 m_list = new QListView ( this ); 61 m_list = new QListView ( this );
62 m_list-> addColumn ( "foobar" ); 62 m_list-> addColumn ( "foobar" );
63 m_list-> header ( )-> hide ( ); 63 m_list-> header ( )-> hide ( );
64 64
65 lay-> addWidget ( m_list ); 65 lay-> addWidget ( m_list );
66 66
67 QWhatsThis::add ( m_list, tr( "Check the applets that you want displayed in the Taskbar." )); 67 QWhatsThis::add ( m_list, tr( "Check the applets that you want displayed in the Taskbar." ));
68 68
69 connect ( m_list, SIGNAL( clicked(QListViewItem*)), this, SLOT( appletChanged())); 69 connect ( m_list, SIGNAL( clicked(QListViewItem*)), this, SLOT( appletChanged()));
70 70
71 init ( ); 71 init ( );
72} 72}
73 73
74void TaskbarSettings::init ( ) 74void TaskbarSettings::init ( )
75{ 75{
76 Config cfg ( "Taskbar" ); 76 Config cfg ( "Taskbar" );
77 cfg. setGroup ( "Applets" ); 77 cfg. setGroup ( "Applets" );
78 QStringList exclude = cfg. readListEntry ( "ExcludeApplets", ',' ); 78 QStringList exclude = cfg. readListEntry ( "ExcludeApplets", ',' );
79 79
80 QString path = QPEApplication::qpeDir ( ) + "plugins/applets"; 80 QString path = QPEApplication::qpeDir ( ) + "plugins/applets";
81#ifdef Q_OS_MACX 81#ifdef Q_OS_MACX
82 QStringList list = QDir ( path, "lib*.dylib" ). entryList ( ); 82 QStringList list = QDir ( path, "lib*.dylib" ). entryList ( );
83#else 83#else
84 QStringList list = QDir ( path, "lib*.so" ). entryList ( ); 84 QStringList list = QDir ( path, "lib*.so" ). entryList ( );
85#endif /* Q_OS_MACX */ 85#endif /* Q_OS_MACX */
86 86
87 for ( QStringList::Iterator it = list. begin ( ); it != list. end ( ); ++it ) { 87 for ( QStringList::Iterator it = list. begin ( ); it != list. end ( ); ++it ) {
88 QString name; 88 QString name;
89 QPixmap icon; 89 QPixmap icon;
90 TaskbarNamedAppletInterface *iface = 0; 90 TaskbarNamedAppletInterface *iface = 0;
91 91
92 owarn << "Load applet: " << (*it) << "" << oendl; 92 owarn << "Load applet: " << (*it) << "" << oendl;
93 QLibrary *lib = new QLibrary ( path + "/" + *it ); 93 QLibrary *lib = new QLibrary ( path + "/" + *it );
94 lib-> queryInterface ( IID_TaskbarNamedApplet, (QUnknownInterface**) &iface ); 94 QRESULT retVal = QS_OK;
95 if ((retVal = lib-> queryInterface ( IID_TaskbarNamedApplet, (QUnknownInterface**)(&iface) )) != QS_OK)
96 owarn << "<0>" << oendl;
95 owarn << "<1>" << oendl; 97 owarn << "<1>" << oendl;
96 if ( iface ) { 98 if ( iface ) {
97 owarn << "<2>" << oendl; 99 owarn << "<2>" << oendl;
98 QString lang = getenv( "LANG" ); 100 QString lang = getenv( "LANG" );
99 QTranslator *trans = new QTranslator ( qApp ); 101 QTranslator *trans = new QTranslator ( qApp );
100 QString type = (*it). left ((*it). find (".")); 102 QString type = (*it). left ((*it). find ("."));
101 QString tfn = QPEApplication::qpeDir ( ) + "i18n/" + lang + "/" + type + ".qm"; 103 QString tfn = QPEApplication::qpeDir ( ) + "i18n/" + lang + "/" + type + ".qm";
102 if ( trans-> load ( tfn )) 104 if ( trans-> load ( tfn ))
103 qApp-> installTranslator ( trans ); 105 qApp-> installTranslator ( trans );
104 else 106 else
105 delete trans; 107 delete trans;
106 name = iface-> name ( ); 108 name = iface-> name ( );
107 icon = iface-> icon ( ); 109 icon = iface-> icon ( );
108 iface-> release ( ); 110 iface-> release ( );
109 } 111 }
110 owarn << "<3>" << oendl; 112 owarn << "<3>" << oendl;
111 if ( !iface ) { 113 if ( !iface ) {
112 owarn << "<4>" << oendl; 114 owarn << "<4>" << oendl;
113 lib-> queryInterface ( IID_TaskbarApplet, (QUnknownInterface**) &iface ); 115 if ((retVal = lib-> queryInterface ( IID_TaskbarApplet, (QUnknownInterface**)(&iface))) != QS_OK)
116 owarn << "<5>" << oendl;
114 117
115 if ( iface ) { 118 if ( iface ) {
116 owarn << "<5>" << oendl; 119 owarn << "<6>" << oendl;
117 name = (*it). mid ( 3 ); 120 name = (*it). mid ( 3 );
118 owarn << "Found applet: " << name << "" << oendl; 121 owarn << "Found applet: " << name << "" << oendl;
119#ifdef Q_OS_MACX 122#ifdef Q_OS_MACX
120 int sep = name. find( ".dylib" ); 123 int sep = name. find( ".dylib" );
121#else 124#else
122 int sep = name. find( ".so" ); 125 int sep = name. find( ".so" );
123#endif /* Q_OS_MACX */ 126#endif /* Q_OS_MACX */
124 if ( sep > 0 ) 127 if ( sep > 0 )
125 name. truncate ( sep ); 128 name. truncate ( sep );
126 sep = name. find ( "applet" ); 129 sep = name. find ( "applet" );
127 if ( sep == (int) name.length ( ) - 6 ) 130 if ( sep == (int) name.length ( ) - 6 )
128 name. truncate ( sep ); 131 name. truncate ( sep );
129 name[0] = name[0]. upper ( ); 132 name[0] = name[0]. upper ( );
130 iface-> release ( ); 133 iface-> release ( );
131 } 134 }
132 } 135 }
133 owarn << "<6>" << oendl; 136 owarn << "<7>" << oendl;
134 137
135 if ( iface ) { 138 if ( iface ) {
136 owarn << "<7>" << oendl; 139 owarn << "<8>" << oendl;
137 QCheckListItem *item; 140 QCheckListItem *item;
138 item = new QCheckListItem ( m_list, name, QCheckListItem::CheckBox ); 141 item = new QCheckListItem ( m_list, name, QCheckListItem::CheckBox );
139 if ( !icon. isNull ( )) 142 if ( !icon. isNull ( ))
140 item-> setPixmap ( 0, icon ); 143 item-> setPixmap ( 0, icon );
141 item-> setOn ( exclude. find ( *it ) == exclude. end ( )); 144 item-> setOn ( exclude. find ( *it ) == exclude. end ( ));
142 m_applets [*it] = item; 145 m_applets [*it] = item;
143 } 146 }
144 lib-> unload ( ); 147 lib-> unload ( );
145 delete lib; 148 delete lib;
146 } 149 }
147} 150}
148 151
149void TaskbarSettings::appletChanged() 152void TaskbarSettings::appletChanged()
150{ 153{
151 m_applets_changed = true; 154 m_applets_changed = true;
152} 155}
153 156
154void TaskbarSettings::accept ( ) 157void TaskbarSettings::accept ( )
155{ 158{
156 Config cfg ( "Taskbar" ); 159 Config cfg ( "Taskbar" );
157 cfg. setGroup ( "Applets" ); 160 cfg. setGroup ( "Applets" );
158 161
159 if ( m_applets_changed ) { 162 if ( m_applets_changed ) {
160 QStringList exclude; 163 QStringList exclude;
161 QMap <QString, QCheckListItem *>::Iterator it; 164 QMap <QString, QCheckListItem *>::Iterator it;
162 for ( it = m_applets. begin ( ); it != m_applets. end ( ); ++it ) { 165 for ( it = m_applets. begin ( ); it != m_applets. end ( ); ++it ) {
163 if ( !(*it)-> isOn ( )) 166 if ( !(*it)-> isOn ( ))
164 exclude << it. key ( ); 167 exclude << it. key ( );
165 } 168 }
166 cfg. writeEntry ( "ExcludeApplets", exclude, ',' ); 169 cfg. writeEntry ( "ExcludeApplets", exclude, ',' );
167 } 170 }
168 cfg. writeEntry ( "SafeMode", false ); 171 cfg. writeEntry ( "SafeMode", false );
169 cfg. write ( ); 172 cfg. write ( );
170 173
171 if ( m_applets_changed ) { 174 if ( m_applets_changed ) {
172 QCopEnvelope e ( "QPE/TaskBar", "reloadApplets()" ); 175 QCopEnvelope e ( "QPE/TaskBar", "reloadApplets()" );
173 m_applets_changed = false; 176 m_applets_changed = false;
174 } 177 }
175} 178}
176 179
diff --git a/libopie2/opiecore/oglobal.cpp b/libopie2/opiecore/oglobal.cpp
index 706ac6c..b7d59fc 100644
--- a/libopie2/opiecore/oglobal.cpp
+++ b/libopie2/opiecore/oglobal.cpp
@@ -219,204 +219,204 @@ QByteArray OGlobal::encodeBase64(const QByteArray& in, bool insertLFs ) {
219 { 219 {
220 out[didx++] = Base64EncMap[(data[sidx] << 4) & 077]; 220 out[didx++] = Base64EncMap[(data[sidx] << 4) & 077];
221 } 221 }
222 } 222 }
223 223
224 // Add padding 224 // Add padding
225 while (didx < out.size()) 225 while (didx < out.size())
226 { 226 {
227 out[didx] = '='; 227 out[didx] = '=';
228 didx++; 228 didx++;
229 } 229 }
230 230
231 return out; 231 return out;
232} 232}
233 233
234/** 234/**
235 * Decodes the given data that was encoded with the base64 235 * Decodes the given data that was encoded with the base64
236 * algorithm. 236 * algorithm.
237 * 237 *
238 * 238 *
239 * @param in the encoded data to be decoded. 239 * @param in the encoded data to be decoded.
240 * @return the decoded QByteArray or QByteArray() in case of failure 240 * @return the decoded QByteArray or QByteArray() in case of failure
241 * @see OGlobal::encodeBase64 241 * @see OGlobal::encodeBase64
242 */ 242 */
243QByteArray OGlobal::decodeBase64( const QByteArray& in) { 243QByteArray OGlobal::decodeBase64( const QByteArray& in) {
244 if ( in.isEmpty() ) 244 if ( in.isEmpty() )
245 return QByteArray(); 245 return QByteArray();
246 246
247 QByteArray out; 247 QByteArray out;
248 unsigned int count = 0; 248 unsigned int count = 0;
249 unsigned int len = in.size(), tail = len; 249 unsigned int len = in.size(), tail = len;
250 const char* data = in.data(); 250 const char* data = in.data();
251 251
252 // Deal with possible *nix "BEGIN" marker!! 252 // Deal with possible *nix "BEGIN" marker!!
253 while ( count < len && (data[count] == '\n' || data[count] == '\r' || 253 while ( count < len && (data[count] == '\n' || data[count] == '\r' ||
254 data[count] == '\t' || data[count] == ' ') ) 254 data[count] == '\t' || data[count] == ' ') )
255 count++; 255 count++;
256 256
257 if ( strncasecmp(data+count, "begin", 5) == 0 ) 257 if ( strncasecmp(data+count, "begin", 5) == 0 )
258 { 258 {
259 count += 5; 259 count += 5;
260 while ( count < len && data[count] != '\n' && data[count] != '\r' ) 260 while ( count < len && data[count] != '\n' && data[count] != '\r' )
261 count++; 261 count++;
262 262
263 while ( count < len && (data[count] == '\n' || data[count] == '\r') ) 263 while ( count < len && (data[count] == '\n' || data[count] == '\r') )
264 count ++; 264 count ++;
265 265
266 data += count; 266 data += count;
267 tail = (len -= count); 267 tail = (len -= count);
268 } 268 }
269 269
270 // Find the tail end of the actual encoded data even if 270 // Find the tail end of the actual encoded data even if
271 // there is/are trailing CR and/or LF. 271 // there is/are trailing CR and/or LF.
272 while ( data[tail-1] == '=' || data[tail-1] == '\n' || 272 while ( data[tail-1] == '=' || data[tail-1] == '\n' ||
273 data[tail-1] == '\r' ) 273 data[tail-1] == '\r' )
274 if ( data[--tail] != '=' ) len = tail; 274 if ( data[--tail] != '=' ) len = tail;
275 275
276 unsigned int outIdx = 0; 276 unsigned int outIdx = 0;
277 out.resize( (count=len) ); 277 out.resize( (count=len) );
278 for (unsigned int idx = 0; idx < count; idx++) 278 for (unsigned int idx = 0; idx < count; idx++)
279 { 279 {
280 // Adhere to RFC 2045 and ignore characters 280 // Adhere to RFC 2045 and ignore characters
281 // that are not part of the encoding table. 281 // that are not part of the encoding table.
282 unsigned char ch = data[idx]; 282 unsigned char ch = data[idx];
283 if ( (ch > 47 && ch < 58) || (ch > 64 && ch < 91 ) || 283 if ( (ch > 47 && ch < 58) || (ch > 64 && ch < 91 ) ||
284 (ch > 96 && ch < 123)|| ch == '+' || ch == '/' || ch == '=') 284 (ch > 96 && ch < 123)|| ch == '+' || ch == '/' || ch == '=')
285 { 285 {
286 out[outIdx++] = Base64DecMap[ch]; 286 out[outIdx++] = Base64DecMap[ch];
287 } 287 }
288 else 288 else
289 { 289 {
290 len--; 290 len--;
291 tail--; 291 tail--;
292 } 292 }
293 } 293 }
294 294
295 // kdDebug() << "Tail size = " << tail << ", Length size = " << len << endl; 295 // kdDebug() << "Tail size = " << tail << ", Length size = " << len << endl;
296 296
297 // 4-byte to 3-byte conversion 297 // 4-byte to 3-byte conversion
298 len = (tail>(len/4)) ? tail-(len/4) : 0; 298 len = (tail>(len/4)) ? tail-(len/4) : 0;
299 unsigned int sidx = 0, didx = 0; 299 unsigned int sidx = 0, didx = 0;
300 if ( len > 1 ) 300 if ( len > 1 )
301 { 301 {
302 while (didx < len-2) 302 while (didx < len-2)
303 { 303 {
304 out[didx] = (((out[sidx] << 2) & 255) | ((out[sidx+1] >> 4) & 003)); 304 out[didx] = (((out[sidx] << 2) & 255) | ((out[sidx+1] >> 4) & 003));
305 out[didx+1] = (((out[sidx+1] << 4) & 255) | ((out[sidx+2] >> 2) & 017)); 305 out[didx+1] = (((out[sidx+1] << 4) & 255) | ((out[sidx+2] >> 2) & 017));
306 out[didx+2] = (((out[sidx+2] << 6) & 255) | (out[sidx+3] & 077)); 306 out[didx+2] = (((out[sidx+2] << 6) & 255) | (out[sidx+3] & 077));
307 sidx += 4; 307 sidx += 4;
308 didx += 3; 308 didx += 3;
309 } 309 }
310 } 310 }
311 311
312 if (didx < len) 312 if (didx < len)
313 out[didx] = (((out[sidx] << 2) & 255) | ((out[sidx+1] >> 4) & 003)); 313 out[didx] = (((out[sidx] << 2) & 255) | ((out[sidx+1] >> 4) & 003));
314 314
315 if (++didx < len ) 315 if (++didx < len )
316 out[didx] = (((out[sidx+1] << 4) & 255) | ((out[sidx+2] >> 2) & 017)); 316 out[didx] = (((out[sidx+1] << 4) & 255) | ((out[sidx+2] >> 2) & 017));
317 317
318 // Resize the output buffer 318 // Resize the output buffer
319 if ( len == 0 || len < out.size() ) 319 if ( len == 0 || len < out.size() )
320 out.resize(len); 320 out.resize(len);
321 321
322 return out; 322 return out;
323} 323}
324 324
325bool OGlobal::isAppLnkFileName( const QString& str ) 325bool OGlobal::isAppLnkFileName( const QString& str )
326{ 326{
327 if (str.isEmpty()||str.at(str.length()-1)==QDir::separator()) return false; 327 if (str.isEmpty()||str.at(str.length()-1)==QDir::separator()) return false;
328 return str.startsWith(MimeType::appsFolderName()+QDir::separator()); 328 return str.startsWith(MimeType::appsFolderName()+QDir::separator());
329} 329}
330 330
331/* ToDo: 331/* ToDo:
332 * This fun should check the document-path value for the mounted media 332 * This fun should check the document-path value for the mounted media
333 * which has to be implemented later. this moment we just check for a 333 * which has to be implemented later. this moment we just check for a
334 * mounted media name. 334 * mounted media name.
335 */ 335 */
336bool OGlobal::isDocumentFileName( const QString& file ) 336bool OGlobal::isDocumentFileName( const QString& file )
337{ 337{
338 if (file.isEmpty()||file.at(file.length()-1)==QDir::separator()) return false; 338 if (file.isEmpty()||file.at(file.length()-1)==QDir::separator()) return false;
339 if (file.startsWith(QPEApplication::documentDir()+QDir::separator())) return true; 339 if (file.startsWith(QPEApplication::documentDir()+QDir::separator())) return true;
340 StorageInfo si; 340 StorageInfo si;
341 QList< FileSystem > fl = si.fileSystems(); 341 QList< FileSystem > fl = si.fileSystems();
342 FileSystem*fs; 342 FileSystem*fs;
343 for (fs = fl.first();fs!=0;fs=fl.next()) { 343 for (fs = fl.first();fs!=0;fs=fl.next()) {
344 if (fs->isRemovable()&&file.startsWith(fs->name()+QDir::separator())) 344 if (fs->isRemovable()&&file.startsWith(fs->name()+QDir::separator()))
345 return true; 345 return true;
346 } 346 }
347 if (file.startsWith(homeDirPath())+"/Documents/") return true; 347 if (file.startsWith(homeDirPath()+"/Documents/")) return true;
348 return false; 348 return false;
349} 349}
350 350
351QString OGlobal::tempDirPath() 351QString OGlobal::tempDirPath()
352{ 352{
353 static QString defstring="/tmp"; 353 static QString defstring="/tmp";
354 char * tmpp = 0; 354 char * tmpp = 0;
355 if ( (tmpp=getenv("TEMP"))) { 355 if ( (tmpp=getenv("TEMP"))) {
356 return tmpp; 356 return tmpp;
357 } 357 }
358 return defstring; 358 return defstring;
359} 359}
360 360
361QString OGlobal::homeDirPath() 361QString OGlobal::homeDirPath()
362{ 362{
363 char * tmpp = getenv("HOME"); 363 char * tmpp = getenv("HOME");
364 return (tmpp?tmpp:"/"); 364 return (tmpp?tmpp:"/");
365} 365}
366 366
367bool OGlobal::weekStartsOnMonday() 367bool OGlobal::weekStartsOnMonday()
368{ 368{
369 OConfig*conf=OGlobal::qpe_config(); 369 OConfig*conf=OGlobal::qpe_config();
370 if (!conf)return false; 370 if (!conf)return false;
371 conf->setGroup("Time"); 371 conf->setGroup("Time");
372 return conf->readBoolEntry("MONDAY",true); 372 return conf->readBoolEntry("MONDAY",true);
373} 373}
374 374
375void OGlobal::setWeekStartsOnMonday( bool what) 375void OGlobal::setWeekStartsOnMonday( bool what)
376{ 376{
377 OConfig*conf=OGlobal::qpe_config(); 377 OConfig*conf=OGlobal::qpe_config();
378 if (!conf)return; 378 if (!conf)return;
379 conf->setGroup("Time"); 379 conf->setGroup("Time");
380 return conf->writeEntry("MONDAY",what); 380 return conf->writeEntry("MONDAY",what);
381} 381}
382 382
383bool OGlobal::useAMPM() 383bool OGlobal::useAMPM()
384{ 384{
385 OConfig*conf=OGlobal::qpe_config(); 385 OConfig*conf=OGlobal::qpe_config();
386 if (!conf)return false; 386 if (!conf)return false;
387 conf->setGroup("Time"); 387 conf->setGroup("Time");
388 return conf->readBoolEntry("AMPM",false); 388 return conf->readBoolEntry("AMPM",false);
389} 389}
390 390
391void OGlobal::setUseAMPM( bool what) 391void OGlobal::setUseAMPM( bool what)
392{ 392{
393 OConfig*conf=OGlobal::qpe_config(); 393 OConfig*conf=OGlobal::qpe_config();
394 if (!conf)return; 394 if (!conf)return;
395 conf->setGroup("Time"); 395 conf->setGroup("Time");
396 return conf->writeEntry("AMPM",what); 396 return conf->writeEntry("AMPM",what);
397} 397}
398 398
399OConfig* OGlobal::qpe_config() 399OConfig* OGlobal::qpe_config()
400{ 400{
401 if ( !OGlobal::_qpe_config ) { 401 if ( !OGlobal::_qpe_config ) {
402 OGlobal::_qpe_config = new OConfig( "qpe" ); 402 OGlobal::_qpe_config = new OConfig( "qpe" );
403 } 403 }
404 return OGlobal::_qpe_config; 404 return OGlobal::_qpe_config;
405} 405}
406 406
407bool OGlobal::truncateFile( QFile &f, off_t size ) 407bool OGlobal::truncateFile( QFile &f, off_t size )
408{ 408{
409 /* or should we let enlarge Files? then remove this 409 /* or should we let enlarge Files? then remove this
410 f.size()< part! - Alwin 410 f.size()< part! - Alwin
411 */ 411 */
412 if (!f.exists()||f.size()<(unsigned)size) return false; 412 if (!f.exists()||f.size()<(unsigned)size) return false;
413 bool closeit=false; 413 bool closeit=false;
414 if (!f.isOpen()) { 414 if (!f.isOpen()) {
415 closeit=true; 415 closeit=true;
416 f.open(IO_Raw | IO_ReadWrite | IO_Append); 416 f.open(IO_Raw | IO_ReadWrite | IO_Append);
417 } 417 }
418 if (!f.isOpen()) { return false; } 418 if (!f.isOpen()) { return false; }
419 int r = ftruncate(f.handle(),size); 419 int r = ftruncate(f.handle(),size);
420 if (closeit) f.close(); 420 if (closeit) f.close();
421 return r==0; 421 return r==0;
422} 422}
diff --git a/libopie2/opiecore/oprocess.cpp b/libopie2/opiecore/oprocess.cpp
index b3f9724..56f9883 100644
--- a/libopie2/opiecore/oprocess.cpp
+++ b/libopie2/opiecore/oprocess.cpp
@@ -803,149 +803,149 @@ void OProcess::commClose()
803 timeout.tv_usec = 0; 803 timeout.tv_usec = 0;
804 struct timeval *p_timeout = runs ? 0 : &timeout; 804 struct timeval *p_timeout = runs ? 0 : &timeout;
805 805
806 FD_ZERO( &rfds ); 806 FD_ZERO( &rfds );
807 if ( b_out ) 807 if ( b_out )
808 FD_SET( out[ 0 ], &rfds ); 808 FD_SET( out[ 0 ], &rfds );
809 809
810 if ( b_err ) 810 if ( b_err )
811 FD_SET( err[ 0 ], &rfds ); 811 FD_SET( err[ 0 ], &rfds );
812 812
813 fds_ready = select( max_fd + 1, &rfds, 0, 0, p_timeout ); 813 fds_ready = select( max_fd + 1, &rfds, 0, 0, p_timeout );
814 if ( fds_ready <= 0 ) 814 if ( fds_ready <= 0 )
815 break; 815 break;
816 816
817 if ( b_out && FD_ISSET( out[ 0 ], &rfds ) ) 817 if ( b_out && FD_ISSET( out[ 0 ], &rfds ) )
818 { 818 {
819 int ret = 1; 819 int ret = 1;
820 while ( ret > 0 ) 820 while ( ret > 0 )
821 ret = childOutput( out[ 0 ] ); 821 ret = childOutput( out[ 0 ] );
822 if ( ( ret == -1 && errno != EAGAIN ) || ret == 0 ) 822 if ( ( ret == -1 && errno != EAGAIN ) || ret == 0 )
823 b_out = false; 823 b_out = false;
824 } 824 }
825 825
826 if ( b_err && FD_ISSET( err[ 0 ], &rfds ) ) 826 if ( b_err && FD_ISSET( err[ 0 ], &rfds ) )
827 { 827 {
828 int ret = 1; 828 int ret = 1;
829 while ( ret > 0 ) 829 while ( ret > 0 )
830 ret = childError( err[ 0 ] ); 830 ret = childError( err[ 0 ] );
831 if ( ( ret == -1 && errno != EAGAIN ) || ret == 0 ) 831 if ( ( ret == -1 && errno != EAGAIN ) || ret == 0 )
832 b_err = false; 832 b_err = false;
833 } 833 }
834 } 834 }
835 } 835 }
836 836
837 if ( b_in ) 837 if ( b_in )
838 { 838 {
839 communication = ( Communication ) ( communication & ~Stdin ); 839 communication = ( Communication ) ( communication & ~Stdin );
840 close( in[ 1 ] ); 840 close( in[ 1 ] );
841 } 841 }
842 if ( b_out ) 842 if ( b_out )
843 { 843 {
844 communication = ( Communication ) ( communication & ~Stdout ); 844 communication = ( Communication ) ( communication & ~Stdout );
845 close( out[ 0 ] ); 845 close( out[ 0 ] );
846 } 846 }
847 if ( b_err ) 847 if ( b_err )
848 { 848 {
849 communication = ( Communication ) ( communication & ~Stderr ); 849 communication = ( Communication ) ( communication & ~Stderr );
850 close( err[ 0 ] ); 850 close( err[ 0 ] );
851 } 851 }
852 } 852 }
853} 853}
854 854
855void OProcess::setUseShell( bool useShell, const char *shell ) 855void OProcess::setUseShell( bool useShell, const char *shell )
856{ 856{
857 if ( !d ) 857 if ( !d )
858 d = new OProcessPrivate; 858 d = new OProcessPrivate;
859 d->useShell = useShell; 859 d->useShell = useShell;
860 d->shell = shell; 860 d->shell = shell;
861 if ( d->shell.isEmpty() ) 861 if ( d->shell.isEmpty() )
862 d->shell = searchShell(); 862 d->shell = searchShell();
863} 863}
864 864
865QString OProcess::quote( const QString &arg ) 865QString OProcess::quote( const QString &arg )
866{ 866{
867 QString res = arg; 867 QString res = arg;
868 res.replace( QRegExp( QString::fromLatin1( "\'" ) ), 868 res.replace( QRegExp( QString::fromLatin1( "\'" ) ),
869 QString::fromLatin1( "'\"'\"'" ) ); 869 QString::fromLatin1( "'\"'\"'" ) );
870 res.prepend( '\'' ); 870 res.prepend( '\'' );
871 res.append( '\'' ); 871 res.append( '\'' );
872 return res; 872 return res;
873} 873}
874 874
875QCString OProcess::searchShell() 875QCString OProcess::searchShell()
876{ 876{
877 QCString tmpShell = QCString( getenv( "SHELL" ) ).stripWhiteSpace(); 877 QCString tmpShell = QCString( getenv( "SHELL" ) ).stripWhiteSpace();
878 if ( !isExecutable( tmpShell ) ) 878 if ( !isExecutable( tmpShell ) )
879 { 879 {
880 tmpShell = "/bin/sh"; 880 tmpShell = "/bin/sh";
881 } 881 }
882 882
883 return tmpShell; 883 return tmpShell;
884} 884}
885 885
886bool OProcess::isExecutable( const QCString &filename ) 886bool OProcess::isExecutable( const QCString &filename )
887{ 887{
888 struct stat fileinfo; 888 struct stat fileinfo;
889 889
890 if ( filename.isEmpty() ) 890 if ( filename.isEmpty() )
891 return false; 891 return false;
892 892
893 // CC: we've got a valid filename, now let's see whether we can execute that file 893 // CC: we've got a valid filename, now let's see whether we can execute that file
894 894
895 if ( -1 == stat( filename.data(), &fileinfo ) ) 895 if ( -1 == stat( filename.data(), &fileinfo ) )
896 return false; 896 return false;
897 // CC: return false if the file does not exist 897 // CC: return false if the file does not exist
898 898
899 // CC: anyway, we cannot execute directories, block/character devices, fifos or sockets 899 // CC: anyway, we cannot execute directories, block/character devices, fifos or sockets
900 if ( ( S_ISDIR( fileinfo.st_mode ) ) || 900 if ( ( S_ISDIR( fileinfo.st_mode ) ) ||
901 ( S_ISCHR( fileinfo.st_mode ) ) || 901 ( S_ISCHR( fileinfo.st_mode ) ) ||
902 ( S_ISBLK( fileinfo.st_mode ) ) || 902 ( S_ISBLK( fileinfo.st_mode ) ) ||
903#ifdef S_ISSOCK 903#ifdef S_ISSOCK
904 // CC: SYSVR4 systems don't have that macro 904 // CC: SYSVR4 systems don't have that macro
905 ( S_ISSOCK( fileinfo.st_mode ) ) || 905 ( S_ISSOCK( fileinfo.st_mode ) ) ||
906#endif 906#endif
907 ( S_ISFIFO( fileinfo.st_mode ) ) || 907 ( S_ISFIFO( fileinfo.st_mode ) ) ||
908 ( S_ISDIR( fileinfo.st_mode ) ) ) 908 ( S_ISDIR( fileinfo.st_mode ) ) )
909 { 909 {
910 return false; 910 return false;
911 } 911 }
912 912
913 // CC: now check for permission to execute the file 913 // CC: now check for permission to execute the file
914 if ( access( filename.data(), X_OK ) != 0 ) 914 if ( access( filename.data(), X_OK ) != 0 )
915 return false; 915 return false;
916 916
917 // CC: we've passed all the tests... 917 // CC: we've passed all the tests...
918 return true; 918 return true;
919} 919}
920 920
921int OProcess::processPID( const QString& process ) 921int OProcess::processPID( const QString& process )
922{ 922{
923 QString line; 923 QString line;
924 QDir d = QDir( "/proc" ); 924 QDir d = QDir( "/proc" );
925 QStringList dirs = d.entryList( QDir::Dirs ); 925 QStringList dirs = d.entryList( QDir::Dirs );
926 QStringList::Iterator it; 926 QStringList::Iterator it;
927 for ( it = dirs.begin(); it != dirs.end(); ++it ) 927 for ( it = dirs.begin(); it != dirs.end(); ++it )
928 { 928 {
929 //qDebug( "next entry: %s", (const char*) *it ); 929 //qDebug( "next entry: %s", (const char*) *it );
930 QFile file( "/proc/"+*it+"/cmdline" ); 930 QFile file( "/proc/"+*it+"/cmdline" );
931 file.open( IO_ReadOnly ); 931 if ( !file.open( IO_ReadOnly ) ) continue;
932 if ( !file.isOpen() ) continue; 932 if ( !file.isOpen() ) continue;
933 QTextStream t( &file ); 933 QTextStream t( &file );
934 line = t.readLine(); 934 line = t.readLine();
935 //qDebug( "cmdline = %s", (const char*) line ); 935 //qDebug( "cmdline = %s", (const char*) line );
936 if ( line.contains( process ) ) break; //FIXME: That may find also other process, if the name is not long enough ;) 936 if ( line.contains( process ) ) break; //FIXME: That may find also other process, if the name is not long enough ;)
937 } 937 }
938 if ( line.contains( process ) ) 938 if ( line.contains( process ) )
939 { 939 {
940 //qDebug( "found process id #%d", (*it).toInt() ); 940 //qDebug( "found process id #%d", (*it).toInt() );
941 return (*it).toInt(); 941 return (*it).toInt();
942 } 942 }
943 else 943 else
944 { 944 {
945 //qDebug( "process '%s' not found", (const char*) process ); 945 //qDebug( "process '%s' not found", (const char*) process );
946 return 0; 946 return 0;
947 } 947 }
948} 948}
949 949
950} 950}
951} 951}
diff --git a/library/global.cpp b/library/global.cpp
index f7a0767..7bdd0b1 100644
--- a/library/global.cpp
+++ b/library/global.cpp
@@ -91,289 +91,288 @@ StartingAppList::StartingAppList( QObject *parent, const char* name )
91 this, SLOT( handleNewChannel(const QString&)) ); 91 this, SLOT( handleNewChannel(const QString&)) );
92#endif 92#endif
93 dict.setAutoDelete( TRUE ); 93 dict.setAutoDelete( TRUE );
94} 94}
95 95
96void StartingAppList::add( const QString& name ) 96void StartingAppList::add( const QString& name )
97{ 97{
98#if QT_VERSION >= 232 && !defined(QT_NO_COP) 98#if QT_VERSION >= 232 && !defined(QT_NO_COP)
99 if ( !appl ) 99 if ( !appl )
100 appl = new StartingAppList; 100 appl = new StartingAppList;
101 QTime *t = new QTime; 101 QTime *t = new QTime;
102 t->start(); 102 t->start();
103 appl->dict.insert( "QPE/Application/" + name, t ); 103 appl->dict.insert( "QPE/Application/" + name, t );
104#endif 104#endif
105} 105}
106 106
107bool StartingAppList::isStarting( const QString name ) 107bool StartingAppList::isStarting( const QString name )
108{ 108{
109#if QT_VERSION >= 232 && !defined(QT_NO_COP) 109#if QT_VERSION >= 232 && !defined(QT_NO_COP)
110 if ( appl ) { 110 if ( appl ) {
111 QTime *t = appl->dict.find( "QPE/Application/" + name ); 111 QTime *t = appl->dict.find( "QPE/Application/" + name );
112 if ( !t ) 112 if ( !t )
113 return FALSE; 113 return FALSE;
114 if ( t->elapsed() > 10000 ) { 114 if ( t->elapsed() > 10000 ) {
115 // timeout in case of crash or something 115 // timeout in case of crash or something
116 appl->dict.remove( "QPE/Application/" + name ); 116 appl->dict.remove( "QPE/Application/" + name );
117 return FALSE; 117 return FALSE;
118 } 118 }
119 return TRUE; 119 return TRUE;
120 } 120 }
121#endif 121#endif
122 return FALSE; 122 return FALSE;
123} 123}
124 124
125void StartingAppList::handleNewChannel( const QString & name ) 125void StartingAppList::handleNewChannel( const QString & name )
126{ 126{
127#if QT_VERSION >= 232 && !defined(QT_NO_COP) 127#if QT_VERSION >= 232 && !defined(QT_NO_COP)
128 dict.remove( name ); 128 dict.remove( name );
129#endif 129#endif
130} 130}
131 131
132static bool docDirCreated = FALSE; 132static bool docDirCreated = FALSE;
133static QDawg* fixed_dawg = 0; 133static QDawg* fixed_dawg = 0;
134static QDict<QDawg> *named_dawg = 0; 134static QDict<QDawg> *named_dawg = 0;
135 135
136static QString qpeDir() 136static QString qpeDir()
137{ 137{
138 QString dir = getenv("OPIEDIR"); 138 QString dir = getenv("OPIEDIR");
139 if ( dir.isEmpty() ) dir = ".."; 139 if ( dir.isEmpty() ) dir = "..";
140 return dir; 140 return dir;
141} 141}
142 142
143static QString dictDir() 143static QString dictDir()
144{ 144{
145 return qpeDir() + "/etc/dict"; 145 return qpeDir() + "/etc/dict";
146} 146}
147 147
148/*! 148/*!
149 \class Global global.h 149 \class Global global.h
150 \brief The Global class provides application-wide global functions. 150 \brief The Global class provides application-wide global functions.
151 151
152 The Global functions are grouped as follows: 152 The Global functions are grouped as follows:
153 \tableofcontents 153 \tableofcontents
154 154
155 \section1 User Interface 155 \section1 User Interface
156 156
157 The statusMessage() function provides short-duration messages to the 157 The statusMessage() function provides short-duration messages to the
158 user. The showInputMethod() function shows the current input method, 158 user. The showInputMethod() function shows the current input method,
159 and hideInputMethod() hides the input method. 159 and hideInputMethod() hides the input method.
160 160
161 \section1 Document related 161 \section1 Document related
162 162
163 The findDocuments() function creates a set of \link doclnk.html 163 The findDocuments() function creates a set of \link doclnk.html
164 DocLnk\endlink objects in a particular folder. 164 DocLnk\endlink objects in a particular folder.
165 165
166 \section1 Filesystem related 166 \section1 Filesystem related
167 167
168 Global provides an applicationFileName() function that returns the 168 Global provides an applicationFileName() function that returns the
169 full path of an application-specific file. 169 full path of an application-specific file.
170 170
171 The execute() function runs an application. 171 The execute() function runs an application.
172 172
173 \section1 Word list related 173 \section1 Word list related
174 174
175 A list of words relevant to the current locale is maintained by the 175 A list of words relevant to the current locale is maintained by the
176 system. The list is held in a \link qdawg.html DAWG\endlink 176 system. The list is held in a \link qdawg.html DAWG\endlink
177 (implemented by the QDawg class). This list is used, for example, by 177 (implemented by the QDawg class). This list is used, for example, by
178 the pickboard input method. 178 the pickboard input method.
179 179
180 The global QDawg is returned by fixedDawg(); this cannot be updated. 180 The global QDawg is returned by fixedDawg(); this cannot be updated.
181 An updatable copy of the global QDawg is returned by addedDawg(). 181 An updatable copy of the global QDawg is returned by addedDawg().
182 Applications may have their own word lists stored in \l{QDawg}s 182 Applications may have their own word lists stored in \l{QDawg}s
183 which are returned by dawg(). Use addWords() to add words to the 183 which are returned by dawg(). Use addWords() to add words to the
184 updateable copy of the global QDawg or to named application 184 updateable copy of the global QDawg or to named application
185 \l{QDawg}s. 185 \l{QDawg}s.
186 186
187 \section1 Quoting 187 \section1 Quoting
188 188
189 The shellQuote() function quotes a string suitable for passing to a 189 The shellQuote() function quotes a string suitable for passing to a
190 shell. The stringQuote() function backslash escapes '\' and '"' 190 shell. The stringQuote() function backslash escapes '\' and '"'
191 characters. 191 characters.
192 192
193 \section1 Hardware 193 \section1 Hardware
194 194
195 The implementation of the writeHWClock() function depends on the AlarmServer 195 The implementation of the writeHWClock() function depends on the AlarmServer
196 implementation. If the AlarmServer is using atd the clock will be synced to 196 implementation. If the AlarmServer is using atd the clock will be synced to
197 hardware. If opie-alarm is used the hardware clock will be synced before 197 hardware. If opie-alarm is used the hardware clock will be synced before
198 suspending the device. opie-alarm is used by iPAQ and Zaurii implementation 198 suspending the device. opie-alarm is used by iPAQ and Zaurii implementation
199 199
200 \ingroup qtopiaemb 200 \ingroup qtopiaemb
201*/ 201*/
202 202
203/*! 203/*!
204 \internal 204 \internal
205*/ 205*/
206Global::Global() 206Global::Global()
207{ 207{
208} 208}
209 209
210/*! 210/*!
211 Returns the unchangeable QDawg that contains general 211 Returns the unchangeable QDawg that contains general
212 words for the current locale. 212 words for the current locale.
213 213
214 \sa addedDawg() 214 \sa addedDawg()
215*/ 215*/
216const QDawg& Global::fixedDawg() 216const QDawg& Global::fixedDawg()
217{ 217{
218 if ( !fixed_dawg ) { 218 if ( !fixed_dawg ) {
219 if ( !docDirCreated ) 219 if ( !docDirCreated )
220 createDocDir(); 220 createDocDir();
221 221
222 fixed_dawg = new QDawg; 222 fixed_dawg = new QDawg;
223 QString dawgfilename = dictDir() + "/dawg"; 223 QString dawgfilename = dictDir() + "/dawg";
224 QString words_lang; 224 QString words_lang;
225 QStringList langs = Global::languageList(); 225 QStringList langs = Global::languageList();
226 for (QStringList::ConstIterator it = langs.begin(); it!=langs.end(); ++it) { 226 for (QStringList::ConstIterator it = langs.begin(); it!=langs.end(); ++it) {
227 QString lang = *it; 227 QString lang = *it;
228 words_lang = dictDir() + "/words." + lang; 228 words_lang = dictDir() + "/words." + lang;
229 QString dawgfilename_lang = dawgfilename + "." + lang; 229 QString dawgfilename_lang = dawgfilename + "." + lang;
230 if ( QFile::exists(dawgfilename_lang) || 230 if ( QFile::exists(dawgfilename_lang) ||
231 QFile::exists(words_lang) ) { 231 QFile::exists(words_lang) ) {
232 dawgfilename = dawgfilename_lang; 232 dawgfilename = dawgfilename_lang;
233 break; 233 break;
234 } 234 }
235 }
236 QFile dawgfile(dawgfilename);
237
238 if ( !dawgfile.exists() ) {
239 QString fn = dictDir() + "/words";
240 if ( QFile::exists(words_lang) )
241 fn = words_lang;
242 QFile in(fn);
243 if ( in.open(IO_ReadOnly) ) {
244 fixed_dawg->createFromWords(&in);
245 dawgfile.open(IO_WriteOnly);
246 fixed_dawg->write(&dawgfile);
247 dawgfile.close();
248 } 235 }
249 } else { 236 QFile dawgfile(dawgfilename);
250 fixed_dawg->readFile(dawgfilename); 237
251 } 238 if ( !dawgfile.exists() ) {
239 QString fn = dictDir() + "/words";
240 if ( QFile::exists(words_lang) )
241 fn = words_lang;
242 QFile in(fn);
243 if ( in.open(IO_ReadOnly) ) {
244 fixed_dawg->createFromWords(&in);
245 if (dawgfile.open(IO_WriteOnly))
246 fixed_dawg->write(&dawgfile);
247 dawgfile.close();
248 }
249 } else
250 fixed_dawg->readFile(dawgfilename);
252 } 251 }
253 252
254 return *fixed_dawg; 253 return *fixed_dawg;
255} 254}
256 255
257/*! 256/*!
258 Returns the changeable QDawg that contains general 257 Returns the changeable QDawg that contains general
259 words for the current locale. 258 words for the current locale.
260 259
261 \sa fixedDawg() 260 \sa fixedDawg()
262*/ 261*/
263const QDawg& Global::addedDawg() 262const QDawg& Global::addedDawg()
264{ 263{
265 return dawg("local"); 264 return dawg("local");
266} 265}
267 266
268/*! 267/*!
269 Returns the QDawg with the given \a name. 268 Returns the QDawg with the given \a name.
270 This is an application-specific word list. 269 This is an application-specific word list.
271 270
272 \a name should not contain "/". 271 \a name should not contain "/".
273*/ 272*/
274const QDawg& Global::dawg(const QString& name) 273const QDawg& Global::dawg(const QString& name)
275{ 274{
276 createDocDir(); 275 createDocDir();
277 if ( !named_dawg ) 276 if ( !named_dawg )
278 named_dawg = new QDict<QDawg>; 277 named_dawg = new QDict<QDawg>;
279 QDawg* r = named_dawg->find(name); 278 QDawg* r = named_dawg->find(name);
280 if ( !r ) { 279 if ( !r ) {
281 r = new QDawg; 280 r = new QDawg;
282 named_dawg->insert(name,r); 281 named_dawg->insert(name,r);
283 QString dawgfilename = applicationFileName("Dictionary", name ) + ".dawg"; 282 QString dawgfilename = applicationFileName("Dictionary", name ) + ".dawg";
284 QFile dawgfile(dawgfilename); 283 QFile dawgfile(dawgfilename);
285 if ( dawgfile.open(IO_ReadOnly) ) 284 if ( dawgfile.open(IO_ReadOnly) )
286 r->readFile(dawgfilename); 285 r->readFile(dawgfilename);
287 } 286 }
288 return *r; 287 return *r;
289} 288}
290 289
291/*! 290/*!
292 \overload 291 \overload
293 Adds \a wordlist to the addedDawg(). 292 Adds \a wordlist to the addedDawg().
294 293
295 Note that the addition of words persists between program executions 294 Note that the addition of words persists between program executions
296 (they are saved in the dictionary files), so you should confirm the 295 (they are saved in the dictionary files), so you should confirm the
297 words with the user before adding them. 296 words with the user before adding them.
298*/ 297*/
299void Global::addWords(const QStringList& wordlist) 298void Global::addWords(const QStringList& wordlist)
300{ 299{
301 addWords("local",wordlist); 300 addWords("local",wordlist);
302} 301}
303 302
304/*! 303/*!
305 \overload 304 \overload
306 Adds \a wordlist to the addedDawg(). 305 Adds \a wordlist to the addedDawg().
307 306
308 Note that the addition of words persists between program executions 307 Note that the addition of words persists between program executions
309 (they are saved in the dictionary files), so you should confirm the 308 (they are saved in the dictionary files), so you should confirm the
310 words with the user before adding them. 309 words with the user before adding them.
311*/ 310*/
312void Global::addWords(const QString& dictname, const QStringList& wordlist) 311void Global::addWords(const QString& dictname, const QStringList& wordlist)
313{ 312{
314 QDawg& d = (QDawg&)dawg(dictname); 313 QDawg& d = (QDawg&)dawg(dictname);
315 QStringList all = d.allWords() + wordlist; 314 QStringList all = d.allWords() + wordlist;
316 d.createFromWords(all); 315 d.createFromWords(all);
317 316
318 QString dawgfilename = applicationFileName("Dictionary", dictname) + ".dawg"; 317 QString dawgfilename = applicationFileName("Dictionary", dictname) + ".dawg";
319 QFile dawgfile(dawgfilename); 318 QFile dawgfile(dawgfilename);
320 if ( dawgfile.open(IO_WriteOnly) ) { 319 if ( dawgfile.open(IO_WriteOnly) ) {
321 d.write(&dawgfile); 320 d.write(&dawgfile);
322 dawgfile.close(); 321 dawgfile.close();
323 } 322 }
324 323
325 // #### Re-read the dawg here if we use mmap(). 324 // #### Re-read the dawg here if we use mmap().
326 325
327 // #### Signal other processes to re-read. 326 // #### Signal other processes to re-read.
328} 327}
329 328
330 329
331/*! 330/*!
332 Returns the full path for the application called \a appname, with the 331 Returns the full path for the application called \a appname, with the
333 given \a filename. Returns QString::null if there was a problem creating 332 given \a filename. Returns QString::null if there was a problem creating
334 the directory tree for \a appname. 333 the directory tree for \a appname.
335 If \a filename contains "/", it is the caller's responsibility to 334 If \a filename contains "/", it is the caller's responsibility to
336 ensure that those directories exist. 335 ensure that those directories exist.
337*/ 336*/
338QString Global::applicationFileName(const QString& appname, const QString& filename) 337QString Global::applicationFileName(const QString& appname, const QString& filename)
339{ 338{
340 QDir d; 339 QDir d;
341 QString r = getenv("HOME"); 340 QString r = getenv("HOME");
342 r += "/Applications/"; 341 r += "/Applications/";
343 if ( !QFile::exists( r ) ) 342 if ( !QFile::exists( r ) )
344 if ( d.mkdir(r) == false ) 343 if ( d.mkdir(r) == false )
345 return QString::null; 344 return QString::null;
346 r += appname; 345 r += appname;
347 if ( !QFile::exists( r ) ) 346 if ( !QFile::exists( r ) )
348 if ( d.mkdir(r) == false ) 347 if ( d.mkdir(r) == false )
349 return QString::null; 348 return QString::null;
350 r += "/"; r += filename; 349 r += "/"; r += filename;
351 return r; 350 return r;
352} 351}
353 352
354/*! 353/*!
355 \internal 354 \internal
356*/ 355*/
357void Global::createDocDir() 356void Global::createDocDir()
358{ 357{
359 if ( !docDirCreated ) { 358 if ( !docDirCreated ) {
360 docDirCreated = TRUE; 359 docDirCreated = TRUE;
361 mkdir( QPEApplication::documentDir().latin1(), 0755 ); 360 mkdir( QPEApplication::documentDir().latin1(), 0755 );
362 } 361 }
363} 362}
364 363
365 364
366/*! 365/*!
367 Displays a status \a message to the user. This usually appears 366 Displays a status \a message to the user. This usually appears
368 in the taskbar for a short amount of time, then disappears. 367 in the taskbar for a short amount of time, then disappears.
369*/ 368*/
370void Global::statusMessage(const QString& message) 369void Global::statusMessage(const QString& message)
371{ 370{
372#if !defined(QT_NO_COP) 371#if !defined(QT_NO_COP)
373 QCopEnvelope e( "QPE/TaskBar", "message(QString)" ); 372 QCopEnvelope e( "QPE/TaskBar", "message(QString)" );
374 e << message; 373 e << message;
375#endif 374#endif
376} 375}
377 376
378/*! 377/*!
379 \internal 378 \internal
diff --git a/noncore/apps/advancedfm/output.cpp b/noncore/apps/advancedfm/output.cpp
index 8c585f4..8f654d5 100644
--- a/noncore/apps/advancedfm/output.cpp
+++ b/noncore/apps/advancedfm/output.cpp
@@ -67,215 +67,216 @@ static char * filesave_xpm[] = {
67"c c #B8B8B8", 67"c c #B8B8B8",
68"d c #FBFBFB", 68"d c #FBFBFB",
69"e c #F9F9F9", 69"e c #F9F9F9",
70"f c #CCCCCC", 70"f c #CCCCCC",
71"g c #030303", 71"g c #030303",
72"h c #737373", 72"h c #737373",
73"i c #7A7A7A", 73"i c #7A7A7A",
74"j c #7E7E7E", 74"j c #7E7E7E",
75"k c #6A6A6A", 75"k c #6A6A6A",
76"l c #FAFAFA", 76"l c #FAFAFA",
77"m c #505050", 77"m c #505050",
78"n c #9D9D9D", 78"n c #9D9D9D",
79"o c #333333", 79"o c #333333",
80"p c #7B7B7B", 80"p c #7B7B7B",
81"q c #787878", 81"q c #787878",
82"r c #696969", 82"r c #696969",
83"s c #494949", 83"s c #494949",
84"t c #555555", 84"t c #555555",
85"u c #949494", 85"u c #949494",
86"v c #E6E6E6", 86"v c #E6E6E6",
87"w c #424242", 87"w c #424242",
88"x c #515151", 88"x c #515151",
89"y c #535353", 89"y c #535353",
90"z c #3E3E3E", 90"z c #3E3E3E",
91"A c #D4D4D4", 91"A c #D4D4D4",
92"B c #0C0C0C", 92"B c #0C0C0C",
93"C c #353535", 93"C c #353535",
94"D c #474747", 94"D c #474747",
95"E c #ECECEC", 95"E c #ECECEC",
96"F c #919191", 96"F c #919191",
97"G c #7D7D7D", 97"G c #7D7D7D",
98"H c #000000", 98"H c #000000",
99"I c #404040", 99"I c #404040",
100"J c #858585", 100"J c #858585",
101"K c #323232", 101"K c #323232",
102"L c #D0D0D0", 102"L c #D0D0D0",
103"M c #1C1C1C", 103"M c #1C1C1C",
104" ...+ ", 104" ...+ ",
105" @#$%&..+ ", 105" @#$%&..+ ",
106" .*=-;;>,..+ ", 106" .*=-;;>,..+ ",
107" ')!~;;;;;;{]..", 107" ')!~;;;;;;{]..",
108" ^/(-;;;;;;;_:<", 108" ^/(-;;;;;;;_:<",
109" [}|;;;;;;;{12$", 109" [}|;;;;;;;{12$",
110" #34-55;;;;678$+", 110" #34-55;;;;678$+",
111" 90ab=c;dd;e1fg ", 111" 90ab=c;dd;e1fg ",
112" [ahij((kbl0mn$ ", 112" [ahij((kbl0mn$ ",
113" op^q^^7r&]s/$+ ", 113" op^q^^7r&]s/$+ ",
114"@btu;vbwxy]zAB ", 114"@btu;vbwxy]zAB ",
115"CzDEvEv;;DssF$ ", 115"CzDEvEv;;DssF$ ",
116"G.H{E{E{IxsJ$+ ", 116"G.H{E{E{IxsJ$+ ",
117" +...vEKxzLM ", 117" +...vEKxzLM ",
118" +...z]n$ ", 118" +...z]n$ ",
119" +... "}; 119" +... "};
120 120
121Output::Output( const QStringList commands, QWidget* parent, const char* name, bool modal, WFlags fl) 121Output::Output( const QStringList commands, QWidget* parent, const char* name, bool modal, WFlags fl)
122 : QDialog( parent, name, modal, fl ) 122 : QDialog( parent, name, modal, fl )
123{ 123{
124 QStringList cmmds; 124 QStringList cmmds;
125// cmmds=QStringList::split( " ", commands, false); 125// cmmds=QStringList::split( " ", commands, false);
126 cmmds=commands; 126 cmmds=commands;
127// odebug << "count " << cmmds.count() << "" << oendl; 127// odebug << "count " << cmmds.count() << "" << oendl;
128 if ( !name ) 128 if ( !name )
129 setName( tr("Output")); 129 setName( tr("Output"));
130 resize( 196, 269 ); 130 resize( 196, 269 );
131 setCaption( name ); 131 setCaption( name );
132 132
133 OutputLayout = new QGridLayout( this ); 133 OutputLayout = new QGridLayout( this );
134 OutputLayout->setSpacing( 2); 134 OutputLayout->setSpacing( 2);
135 OutputLayout->setMargin( 2); 135 OutputLayout->setMargin( 2);
136 136
137 QPushButton *docButton; 137 QPushButton *docButton;
138 docButton = new QPushButton( QPixmap(( const char** ) filesave_xpm ) ,"",this,"saveButton"); 138 docButton = new QPushButton( QPixmap(( const char** ) filesave_xpm ) ,"",this,"saveButton");
139 docButton->setFixedSize( QSize( 20, 20 ) ); 139 docButton->setFixedSize( QSize( 20, 20 ) );
140 connect( docButton,SIGNAL(released()),this,SLOT( saveOutput() )); 140 connect( docButton,SIGNAL(released()),this,SLOT( saveOutput() ));
141 // docButton->setFlat(TRUE); 141 // docButton->setFlat(TRUE);
142 OutputLayout->addMultiCellWidget( docButton, 0,0,3,3 ); 142 OutputLayout->addMultiCellWidget( docButton, 0,0,3,3 );
143 143
144 OutputEdit = new QMultiLineEdit( this, "OutputEdit" ); 144 OutputEdit = new QMultiLineEdit( this, "OutputEdit" );
145 OutputLayout->addMultiCellWidget( OutputEdit, 1,1,0,3 ); 145 OutputLayout->addMultiCellWidget( OutputEdit, 1,1,0,3 );
146 146
147 proc = new OProcess(); 147 proc = new OProcess();
148 148
149 connect(proc, SIGNAL(processExited(Opie::Core::OProcess*)), 149 connect(proc, SIGNAL(processExited(Opie::Core::OProcess*)),
150 this, SLOT( processFinished())); 150 this, SLOT( processFinished()));
151 151
152 connect(proc, SIGNAL(receivedStdout(Opie::Core::OProcess*,char*,int)), 152 connect(proc, SIGNAL(receivedStdout(Opie::Core::OProcess*,char*,int)),
153 this, SLOT(commandStdout(Opie::Core::OProcess*,char*,int))); 153 this, SLOT(commandStdout(Opie::Core::OProcess*,char*,int)));
154 154
155 connect(proc, SIGNAL(receivedStderr(Opie::Core::OProcess*,char*,int)), 155 connect(proc, SIGNAL(receivedStderr(Opie::Core::OProcess*,char*,int)),
156 this, SLOT(commandStderr(Opie::Core::OProcess*,char*,int))); 156 this, SLOT(commandStderr(Opie::Core::OProcess*,char*,int)));
157 157
158// connect( , SIGNAL(received(const QByteArray&)), 158// connect( , SIGNAL(received(const QByteArray&)),
159// this, SLOT(commandStdin(const QByteArray&))); 159// this, SLOT(commandStdin(const QByteArray&)));
160 160
161// * proc << commands.latin1(); 161// * proc << commands.latin1();
162 for ( QStringList::Iterator it = cmmds.begin(); it != cmmds.end(); ++it ) { 162 for ( QStringList::Iterator it = cmmds.begin(); it != cmmds.end(); ++it ) {
163 odebug << "" << (*it).latin1() << "" << oendl; 163 odebug << "" << (*it).latin1() << "" << oendl;
164 * proc << (*it).latin1(); 164 * proc << (*it).latin1();
165 } 165 }
166 166
167 if(!proc->start(OProcess::NotifyOnExit, OProcess::All)) { 167 if(!proc->start(OProcess::NotifyOnExit, OProcess::All)) {
168 168
169 OutputEdit->append(tr("Process could not start") ); 169 OutputEdit->append(tr("Process could not start") );
170 OutputEdit->setCursorPosition( OutputEdit->numLines() + 1,0,FALSE); 170 OutputEdit->setCursorPosition( OutputEdit->numLines() + 1,0,FALSE);
171 perror("Error: "); 171 perror("Error: ");
172 QString errorMsg=tr("Error\n")+(QString)strerror(errno); 172 QString errorMsg=tr("Error\n")+(QString)strerror(errno);
173 OutputEdit->append( errorMsg); 173 OutputEdit->append( errorMsg);
174 OutputEdit->setCursorPosition( OutputEdit->numLines() + 1,0,FALSE); 174 OutputEdit->setCursorPosition( OutputEdit->numLines() + 1,0,FALSE);
175 } 175 }
176} 176}
177 177
178Output::~Output() { 178Output::~Output() {
179} 179}
180 180
181void Output::saveOutput() { 181void Output::saveOutput() {
182 182
183 InputDialog *fileDlg; 183 InputDialog *fileDlg;
184 fileDlg = new InputDialog(this,tr("Save output to file (name only)"),TRUE, 0); 184 fileDlg = new InputDialog(this,tr("Save output to file (name only)"),TRUE, 0);
185 fileDlg->exec(); 185 fileDlg->exec();
186 if( fileDlg->result() == 1 ) { 186 if( fileDlg->result() == 1 ) {
187 QString filename = QPEApplication::documentDir(); 187 QString filename = QPEApplication::documentDir();
188 if(filename.right(1).find('/') == -1) 188 if(filename.right(1).find('/') == -1)
189 filename+="/"; 189 filename+="/";
190 QString name = fileDlg->LineEdit1->text(); 190 QString name = fileDlg->LineEdit1->text();
191 filename+="text/plain/"+name; 191 filename+="text/plain/"+name;
192 odebug << filename << oendl; 192 odebug << filename << oendl;
193 193
194 QFile f(filename); 194 QFile f(filename);
195 f.open( IO_WriteOnly); 195 if ( !f.open( IO_WriteOnly ) )
196 if( f.writeBlock( OutputEdit->text(), qstrlen( OutputEdit->text()) ) != -1) { 196 owarn << "Could no open file" << oendl;
197 else if( f.writeBlock( OutputEdit->text(), qstrlen( OutputEdit->text()) ) != -1) {
197 DocLnk lnk; 198 DocLnk lnk;
198 lnk.setName(name); //sets file name 199 lnk.setName(name); //sets file name
199 lnk.setFile(filename); //sets File property 200 lnk.setFile(filename); //sets File property
200 lnk.setType("text/plain"); 201 lnk.setType("text/plain");
201 if(!lnk.writeLink()) { 202 if(!lnk.writeLink()) {
202 odebug << "Writing doclink did not work" << oendl; 203 odebug << "Writing doclink did not work" << oendl;
203 } 204 }
204 } else 205 } else
205 owarn << "Could not write file" << oendl; 206 owarn << "Could not write file" << oendl;
206 f.close(); 207 f.close();
207 } 208 }
208} 209}
209 210
210void Output::commandStdout(OProcess*, char *buffer, int buflen) { 211void Output::commandStdout(OProcess*, char *buffer, int buflen) {
211 owarn << "received stdout " << buflen << " bytes" << oendl; 212 owarn << "received stdout " << buflen << " bytes" << oendl;
212 213
213// QByteArray data(buflen); 214// QByteArray data(buflen);
214// data.fill(*buffer, buflen); 215// data.fill(*buffer, buflen);
215// for (uint i = 0; i < data.count(); i++ ) { 216// for (uint i = 0; i < data.count(); i++ ) {
216// printf("%c", buffer[i] ); 217// printf("%c", buffer[i] );
217// } 218// }
218// printf("\n"); 219// printf("\n");
219 220
220 QString lineStr = buffer; 221 QString lineStr = buffer;
221 lineStr=lineStr.left(lineStr.length()-1); 222 lineStr=lineStr.left(lineStr.length()-1);
222 OutputEdit->append(lineStr); 223 OutputEdit->append(lineStr);
223 OutputEdit->setCursorPosition( OutputEdit->numLines() + 1,0,FALSE); 224 OutputEdit->setCursorPosition( OutputEdit->numLines() + 1,0,FALSE);
224} 225}
225 226
226 227
227void Output::commandStdin( const QByteArray &data) { 228void Output::commandStdin( const QByteArray &data) {
228 owarn << "received stdin " << data.size() << " bytes" << oendl; 229 owarn << "received stdin " << data.size() << " bytes" << oendl;
229 // recieved data from the io layer goes to sz 230 // recieved data from the io layer goes to sz
230 proc->writeStdin(data.data(), data.size()); 231 proc->writeStdin(data.data(), data.size());
231} 232}
232 233
233void Output::commandStderr(OProcess*, char *buffer, int buflen) { 234void Output::commandStderr(OProcess*, char *buffer, int buflen) {
234 owarn << "received stderrt " << buflen << " bytes" << oendl; 235 owarn << "received stderrt " << buflen << " bytes" << oendl;
235 236
236 QString lineStr = buffer; 237 QString lineStr = buffer;
237// lineStr=lineStr.left(lineStr.length()-1); 238// lineStr=lineStr.left(lineStr.length()-1);
238 OutputEdit->append(lineStr); 239 OutputEdit->append(lineStr);
239 OutputEdit->setCursorPosition( OutputEdit->numLines() + 1,0,FALSE); 240 OutputEdit->setCursorPosition( OutputEdit->numLines() + 1,0,FALSE);
240} 241}
241 242
242void Output::processFinished() { 243void Output::processFinished() {
243 244
244 delete proc; 245 delete proc;
245 OutputEdit->append( tr("\nFinished\n") ); 246 OutputEdit->append( tr("\nFinished\n") );
246 OutputEdit->setCursorPosition( OutputEdit->numLines() + 1,0,FALSE); 247 OutputEdit->setCursorPosition( OutputEdit->numLines() + 1,0,FALSE);
247// close(); 248// close();
248// disconnect( layer(), SIGNAL(received(const QByteArray&)), 249// disconnect( layer(), SIGNAL(received(const QByteArray&)),
249// this, SLOT(commandStdin(const QByteArray&))); 250// this, SLOT(commandStdin(const QByteArray&)));
250} 251}
251 252
252//============================== 253//==============================
253 254
254InputDialog::InputDialog( QWidget* parent, const char* name, bool modal, WFlags fl ) 255InputDialog::InputDialog( QWidget* parent, const char* name, bool modal, WFlags fl )
255 : QDialog( parent, name, modal, fl ) 256 : QDialog( parent, name, modal, fl )
256{ 257{
257 if ( !name ) 258 if ( !name )
258 setName( "InputDialog" ); 259 setName( "InputDialog" );
259 resize( 234, 50 ); 260 resize( 234, 50 );
260 setMaximumSize( QSize( 240, 50 ) ); 261 setMaximumSize( QSize( 240, 50 ) );
261 setCaption( tr(name ) ); 262 setCaption( tr(name ) );
262 263
263 LineEdit1 = new QLineEdit( this, "LineEdit1" ); 264 LineEdit1 = new QLineEdit( this, "LineEdit1" );
264 LineEdit1->setGeometry( QRect( 10, 10, 216, 22 ) ); 265 LineEdit1->setGeometry( QRect( 10, 10, 216, 22 ) );
265 LineEdit1->setFocus(); 266 LineEdit1->setFocus();
266 LineEdit1->setFocus(); 267 LineEdit1->setFocus();
267 connect(LineEdit1,SIGNAL(returnPressed()),this,SLOT(returned() )); 268 connect(LineEdit1,SIGNAL(returnPressed()),this,SLOT(returned() ));
268} 269}
269 270
270InputDialog::~InputDialog() { 271InputDialog::~InputDialog() {
271 inputText = LineEdit1->text(); 272 inputText = LineEdit1->text();
272} 273}
273 274
274void InputDialog::setInputText(const QString &string) { 275void InputDialog::setInputText(const QString &string) {
275 LineEdit1->setText( string); 276 LineEdit1->setText( string);
276} 277}
277 278
278void InputDialog::returned() { 279void InputDialog::returned() {
279 inputText = LineEdit1->text(); 280 inputText = LineEdit1->text();
280 this->accept(); 281 this->accept();
281} 282}
diff --git a/noncore/apps/tinykate/libkate/document/katebuffer.cpp b/noncore/apps/tinykate/libkate/document/katebuffer.cpp
index 4c15fd0..d89edbd 100644
--- a/noncore/apps/tinykate/libkate/document/katebuffer.cpp
+++ b/noncore/apps/tinykate/libkate/document/katebuffer.cpp
@@ -1,180 +1,183 @@
1/* 1/*
2 This file is part of KWrite 2 This file is part of KWrite
3 Copyright (c) 2000 Waldo Bastian <bastian@kde.org> 3 Copyright (c) 2000 Waldo Bastian <bastian@kde.org>
4 Copyright (c) 2002 Joseph Wenninger <jowenn@kde.org> 4 Copyright (c) 2002 Joseph Wenninger <jowenn@kde.org>
5 5
6 $Id$ 6 $Id$
7 7
8 This library is free software; you can redistribute it and/or 8 This library is free software; you can redistribute it and/or
9 modify it under the terms of the GNU Library General Public 9 modify it under the terms of the GNU Library General Public
10 License version 2 as published by the Free Software Foundation. 10 License version 2 as published by the Free Software Foundation.
11 11
12 This library is distributed in the hope that it will be useful, 12 This library is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of 13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 Library General Public License for more details. 15 Library General Public License for more details.
16 16
17 You should have received a copy of the GNU Library General Public License 17 You should have received a copy of the GNU Library General Public License
18 along with this library; see the file COPYING.LIB. If not, write to 18 along with this library; see the file COPYING.LIB. If not, write to
19 the Free Software Foundation, Inc., 59 Temple Place - Suite 330, 19 the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
20 Boston, MA 02111-1307, USA. 20 Boston, MA 02111-1307, USA.
21*/ 21*/
22 22
23 23
24#include "katebuffer.h" 24#include "katebuffer.h"
25#include "kdebug.h" 25#include "kdebug.h"
26 26
27/* OPIE */ 27/* OPIE */
28#include <opie2/odebug.h> 28#include <opie2/odebug.h>
29 29
30/* QT */ 30/* QT */
31#include <qfile.h> 31#include <qfile.h>
32#include <qtextstream.h> 32#include <qtextstream.h>
33#include <qtimer.h> 33#include <qtimer.h>
34#include <qtextcodec.h> 34#include <qtextcodec.h>
35 35
36/* STD */ 36/* STD */
37// Includes for reading file 37// Includes for reading file
38#include <sys/types.h> 38#include <sys/types.h>
39#include <sys/stat.h> 39#include <sys/stat.h>
40#include <fcntl.h> 40#include <fcntl.h>
41#include <errno.h> 41#include <errno.h>
42#include <unistd.h> 42#include <unistd.h>
43#include <assert.h> 43#include <assert.h>
44 44
45/** 45/**
46 * Create an empty buffer. 46 * Create an empty buffer.
47 */ 47 */
48KWBuffer::KWBuffer() 48KWBuffer::KWBuffer()
49{ 49{
50 clear(); 50 clear();
51} 51}
52 52
53void 53void
54KWBuffer::clear() 54KWBuffer::clear()
55{ 55{
56 m_stringListIt=0; 56 m_stringListIt=0;
57 m_stringListCurrent=0; 57 m_stringListCurrent=0;
58 m_stringList.clear(); 58 m_stringList.clear();
59 m_lineCount=1; 59 m_lineCount=1;
60 m_stringListIt = m_stringList.append(new TextLine()); 60 m_stringListIt = m_stringList.append(new TextLine());
61} 61}
62 62
63/** 63/**
64 * Insert a file at line @p line in the buffer. 64 * Insert a file at line @p line in the buffer.
65 */ 65 */
66void 66void
67KWBuffer::insertFile(int line, const QString &file, QTextCodec *codec) 67KWBuffer::insertFile(int line, const QString &file, QTextCodec *codec)
68{ 68{
69 if (line) { 69 if (line) {
70 odebug << "insert File only supports insertion at line 0 == file opening" << oendl; 70 odebug << "insert File only supports insertion at line 0 == file opening" << oendl;
71 return; 71 return;
72 } 72 }
73 clear(); 73 clear();
74 QFile iofile(file); 74 QFile iofile(file);
75 iofile.open(IO_ReadOnly); 75 if (!iofile.open(IO_ReadOnly)) {
76 owarn << "failed to open file " << iofile.name() << oendl;
77 return;
78 }
76 QTextStream stream(&iofile); 79 QTextStream stream(&iofile);
77 stream.setCodec(codec); 80 stream.setCodec(codec);
78 QString qsl; 81 QString qsl;
79 int count=0; 82 int count=0;
80 for (count=0;((qsl=stream.readLine())!=QString::null); count++) 83 for (count=0;((qsl=stream.readLine())!=QString::null); count++)
81 { 84 {
82 if (count==0) 85 if (count==0)
83 { 86 {
84 (*m_stringListIt)->append(qsl.unicode(),qsl.length()); 87 (*m_stringListIt)->append(qsl.unicode(),qsl.length());
85 } 88 }
86 else 89 else
87 { 90 {
88 TextLine::Ptr tl=new TextLine(); 91 TextLine::Ptr tl=new TextLine();
89 tl ->append(qsl.unicode(),qsl.length()); 92 tl ->append(qsl.unicode(),qsl.length());
90 m_stringListIt=m_stringList.append(tl); 93 m_stringListIt=m_stringList.append(tl);
91 } 94 }
92 } 95 }
93 if (count!=0) 96 if (count!=0)
94 { 97 {
95 m_stringListCurrent=count-1; 98 m_stringListCurrent=count-1;
96 m_lineCount=count; 99 m_lineCount=count;
97 } 100 }
98} 101}
99 102
100void 103void
101KWBuffer::loadFilePart() 104KWBuffer::loadFilePart()
102{ 105{
103} 106}
104 107
105 108
106void 109void
107KWBuffer::insertData(int line, const QByteArray &data, QTextCodec *codec) 110KWBuffer::insertData(int line, const QByteArray &data, QTextCodec *codec)
108{ 111{
109} 112}
110 113
111void 114void
112KWBuffer::slotLoadFile() 115KWBuffer::slotLoadFile()
113{ 116{
114 loadFilePart(); 117 loadFilePart();
115// emit linesChanged(m_totalLines); 118// emit linesChanged(m_totalLines);
116 emit linesChanged(20); 119 emit linesChanged(20);
117} 120}
118 121
119/** 122/**
120 * Return the total number of lines in the buffer. 123 * Return the total number of lines in the buffer.
121 */ 124 */
122int 125int
123KWBuffer::count() 126KWBuffer::count()
124{ 127{
125 odebug << "m_stringList.count " << m_stringList.count() << "" << oendl; 128 odebug << "m_stringList.count " << m_stringList.count() << "" << oendl;
126 return m_lineCount; 129 return m_lineCount;
127// return m_stringList.count(); 130// return m_stringList.count();
128// return m_totalLines; 131// return m_totalLines;
129} 132}
130 133
131 134
132void KWBuffer::seek(int i) 135void KWBuffer::seek(int i)
133{ 136{
134 if (m_stringListCurrent == i) 137 if (m_stringListCurrent == i)
135 return; 138 return;
136 while(m_stringListCurrent < i) 139 while(m_stringListCurrent < i)
137 { 140 {
138 ++m_stringListCurrent; 141 ++m_stringListCurrent;
139 ++m_stringListIt; 142 ++m_stringListIt;
140 } 143 }
141 while(m_stringListCurrent > i) 144 while(m_stringListCurrent > i)
142 { 145 {
143 --m_stringListCurrent; 146 --m_stringListCurrent;
144 --m_stringListIt; 147 --m_stringListIt;
145 } 148 }
146} 149}
147 150
148 151
149TextLine::Ptr 152TextLine::Ptr
150KWBuffer::line(int i) 153KWBuffer::line(int i)
151{ 154{
152 if (i>=m_stringList.count()) return 0; 155 if (i>=m_stringList.count()) return 0;
153 seek(i); 156 seek(i);
154 return *m_stringListIt; 157 return *m_stringListIt;
155} 158}
156 159
157void 160void
158KWBuffer::insertLine(int i, TextLine::Ptr line) 161KWBuffer::insertLine(int i, TextLine::Ptr line)
159{ 162{
160 seek(i); 163 seek(i);
161 m_stringListIt = m_stringList.insert(m_stringListIt, line); 164 m_stringListIt = m_stringList.insert(m_stringListIt, line);
162 m_stringListCurrent = i; 165 m_stringListCurrent = i;
163 m_lineCount++; 166 m_lineCount++;
164} 167}
165 168
166 169
167void 170void
168KWBuffer::removeLine(int i) 171KWBuffer::removeLine(int i)
169{ 172{
170 seek(i); 173 seek(i);
171 m_stringListIt = m_stringList.remove(m_stringListIt); 174 m_stringListIt = m_stringList.remove(m_stringListIt);
172 m_stringListCurrent = i; 175 m_stringListCurrent = i;
173 m_lineCount--; 176 m_lineCount--;
174} 177}
175 178
176void 179void
177KWBuffer::changeLine(int i) 180KWBuffer::changeLine(int i)
178{ 181{
179} 182}
180 183
diff --git a/noncore/settings/usermanager/userdialog.cpp b/noncore/settings/usermanager/userdialog.cpp
index 3654639..75a96a6 100644
--- a/noncore/settings/usermanager/userdialog.cpp
+++ b/noncore/settings/usermanager/userdialog.cpp
@@ -117,259 +117,262 @@ void UserDialog::setupTab1()
117 QLabel *groupLabel=new QLabel(tabpage,"group"); 117 QLabel *groupLabel=new QLabel(tabpage,"group");
118 groupLabel->setText("Primary group: "); 118 groupLabel->setText("Primary group: ");
119 groupComboBox=new QComboBox(tabpage,"PrimaryGroup"); 119 groupComboBox=new QComboBox(tabpage,"PrimaryGroup");
120 120
121 if(vm==VIEWMODE_NEW) 121 if(vm==VIEWMODE_NEW)
122 { 122 {
123 // Copy /etc/skel 123 // Copy /etc/skel
124 skelLabel=new QLabel(tabpage,"skel"); 124 skelLabel=new QLabel(tabpage,"skel");
125 skelLabel->setText("Copy /etc/skel: "); 125 skelLabel->setText("Copy /etc/skel: ");
126 skelCheckBox=new QCheckBox(tabpage); 126 skelCheckBox=new QCheckBox(tabpage);
127 skelCheckBox->setChecked(true); 127 skelCheckBox->setChecked(true);
128 } 128 }
129 129
130 // Widget layout 130 // Widget layout
131 QHBoxLayout *hlayout=new QHBoxLayout(-1,"hlayout"); 131 QHBoxLayout *hlayout=new QHBoxLayout(-1,"hlayout");
132 layout->addWidget(picturePushButton); 132 layout->addWidget(picturePushButton);
133 layout->addSpacing(5); 133 layout->addSpacing(5);
134 layout->addLayout(hlayout); 134 layout->addLayout(hlayout);
135 QVBoxLayout *vlayout1=new QVBoxLayout(-1,"vlayout1"); 135 QVBoxLayout *vlayout1=new QVBoxLayout(-1,"vlayout1");
136 QVBoxLayout *vlayout2=new QVBoxLayout(-1,"vlayout2"); 136 QVBoxLayout *vlayout2=new QVBoxLayout(-1,"vlayout2");
137 // First column, labels 137 // First column, labels
138 vlayout1->addWidget(loginLabel); 138 vlayout1->addWidget(loginLabel);
139 vlayout1->addSpacing(5); 139 vlayout1->addSpacing(5);
140 vlayout1->addWidget(uidLabel); 140 vlayout1->addWidget(uidLabel);
141 vlayout1->addSpacing(5); 141 vlayout1->addSpacing(5);
142 vlayout1->addWidget(gecosLabel); 142 vlayout1->addWidget(gecosLabel);
143 vlayout1->addSpacing(5); 143 vlayout1->addSpacing(5);
144 vlayout1->addWidget(passwordLabel); 144 vlayout1->addWidget(passwordLabel);
145 vlayout1->addSpacing(5); 145 vlayout1->addSpacing(5);
146 vlayout1->addWidget(shellLabel); 146 vlayout1->addWidget(shellLabel);
147 vlayout1->addSpacing(5); 147 vlayout1->addSpacing(5);
148 vlayout1->addWidget(groupLabel); 148 vlayout1->addWidget(groupLabel);
149 if(vm==VIEWMODE_NEW) 149 if(vm==VIEWMODE_NEW)
150 { 150 {
151 vlayout1->addSpacing(5); 151 vlayout1->addSpacing(5);
152 vlayout1->addWidget(skelLabel); 152 vlayout1->addWidget(skelLabel);
153 } 153 }
154 // Second column, data 154 // Second column, data
155 vlayout2->addWidget(loginLineEdit); 155 vlayout2->addWidget(loginLineEdit);
156 vlayout2->addSpacing(5); 156 vlayout2->addSpacing(5);
157 vlayout2->addWidget(uidLineEdit); 157 vlayout2->addWidget(uidLineEdit);
158 vlayout2->addSpacing(5); 158 vlayout2->addSpacing(5);
159 vlayout2->addWidget(gecosLineEdit); 159 vlayout2->addWidget(gecosLineEdit);
160 vlayout2->addSpacing(5); 160 vlayout2->addSpacing(5);
161 vlayout2->addWidget(passwordLineEdit); 161 vlayout2->addWidget(passwordLineEdit);
162 vlayout2->addSpacing(5); 162 vlayout2->addSpacing(5);
163 vlayout2->addWidget(shellComboBox); 163 vlayout2->addWidget(shellComboBox);
164 vlayout2->addSpacing(5); 164 vlayout2->addSpacing(5);
165 vlayout2->addWidget(groupComboBox); 165 vlayout2->addWidget(groupComboBox);
166 if(vm==VIEWMODE_NEW) 166 if(vm==VIEWMODE_NEW)
167 { 167 {
168 vlayout2->addSpacing(5); 168 vlayout2->addSpacing(5);
169 vlayout2->addWidget(skelCheckBox); 169 vlayout2->addWidget(skelCheckBox);
170 } 170 }
171 hlayout->addLayout(vlayout1); 171 hlayout->addLayout(vlayout1);
172 hlayout->addLayout(vlayout2); 172 hlayout->addLayout(vlayout2);
173 173
174 myTabWidget->addTab(tabpage,"User Info"); 174 myTabWidget->addTab(tabpage,"User Info");
175} 175}
176 176
177/** 177/**
178 * Creates the second tab containing additional groups for the user. 178 * Creates the second tab containing additional groups for the user.
179 * 179 *
180 */ 180 */
181void UserDialog::setupTab2() 181void UserDialog::setupTab2()
182{ 182{
183 QWidget *tabpage = new QWidget(myTabWidget,"page2"); 183 QWidget *tabpage = new QWidget(myTabWidget,"page2");
184 QVBoxLayout *layout = new QVBoxLayout(tabpage); 184 QVBoxLayout *layout = new QVBoxLayout(tabpage);
185 layout->setMargin(5); 185 layout->setMargin(5);
186 186
187 // Additional groups 187 // Additional groups
188 groupsListView=new QListView(tabpage,"groups"); 188 groupsListView=new QListView(tabpage,"groups");
189 groupsListView->addColumn("Additional groups"); 189 groupsListView->addColumn("Additional groups");
190 groupsListView->setColumnWidthMode(0,QListView::Maximum); 190 groupsListView->setColumnWidthMode(0,QListView::Maximum);
191 groupsListView->setMultiSelection(false); 191 groupsListView->setMultiSelection(false);
192 groupsListView->setAllColumnsShowFocus(false); 192 groupsListView->setAllColumnsShowFocus(false);
193 193
194 layout->addSpacing(5); 194 layout->addSpacing(5);
195 // Grouplist 195 // Grouplist
196 layout->addWidget(groupsListView); 196 layout->addWidget(groupsListView);
197 197
198 myTabWidget->addTab(tabpage,"User Groups"); 198 myTabWidget->addTab(tabpage,"User Groups");
199} 199}
200 200
201/** 201/**
202 * Static function that creates the userinfo dialog. 202 * Static function that creates the userinfo dialog.
203 * The user will be prompted to add a user. 203 * The user will be prompted to add a user.
204 * 204 *
205 * @param uid This is a suggested available UID. 205 * @param uid This is a suggested available UID.
206 * @param gid This is a suggested available GID. 206 * @param gid This is a suggested available GID.
207 * 207 *
208 * @return <code>true</code> if the user was successfully added, otherwise <code>false</code>. 208 * @return <code>true</code> if the user was successfully added, otherwise <code>false</code>.
209 * 209 *
210 */ 210 */
211bool UserDialog::addUser(int uid, int gid) 211bool UserDialog::addUser(int uid, int gid)
212{ 212{
213 QCheckListItem *temp; 213 QCheckListItem *temp;
214 QFile ozTest; 214 QFile ozTest;
215 int oz=false; 215 int oz=false;
216 if(ODevice::inst()->system()==System_OpenZaurus) oz=true; 216 if(ODevice::inst()->system()==System_OpenZaurus) oz=true;
217 // viewmode is a workaround for a bug in qte-2.3.4 that gives bus error on manipulating adduserDialog's widgets here. 217 // viewmode is a workaround for a bug in qte-2.3.4 that gives bus error on manipulating adduserDialog's widgets here.
218 UserDialog *adduserDialog=new UserDialog(VIEWMODE_NEW); 218 UserDialog *adduserDialog=new UserDialog(VIEWMODE_NEW);
219 adduserDialog->setCaption(tr("Add User")); 219 adduserDialog->setCaption(tr("Add User"));
220 adduserDialog->userID=uid; // Set next available UID as default uid. 220 adduserDialog->userID=uid; // Set next available UID as default uid.
221 adduserDialog->groupID=gid; // Set next available GID as default gid. 221 adduserDialog->groupID=gid; // Set next available GID as default gid.
222 // Insert default group into groupComboBox 222 // Insert default group into groupComboBox
223 adduserDialog->groupComboBox->insertItem("<create new group>",0); 223 adduserDialog->groupComboBox->insertItem("<create new group>",0);
224 adduserDialog->uidLineEdit->setText(QString::number(uid)); 224 adduserDialog->uidLineEdit->setText(QString::number(uid));
225 // If we're running on OZ, add new users to some default groups. 225 // If we're running on OZ, add new users to some default groups.
226 if(oz) 226 if(oz)
227 { 227 {
228 QListViewItemIterator iter( adduserDialog->groupsListView ); 228 QListViewItemIterator iter( adduserDialog->groupsListView );
229 for ( ; iter.current(); ++iter ) 229 for ( ; iter.current(); ++iter )
230 { 230 {
231 temp=(QCheckListItem*)iter.current(); 231 temp=(QCheckListItem*)iter.current();
232 if (temp->text()=="video") temp->setOn(true); 232 if (temp->text()=="video") temp->setOn(true);
233 if (temp->text()=="audio") temp->setOn(true); 233 if (temp->text()=="audio") temp->setOn(true);
234 if (temp->text()=="time") temp->setOn(true); 234 if (temp->text()=="time") temp->setOn(true);
235 if (temp->text()=="power") temp->setOn(true); 235 if (temp->text()=="power") temp->setOn(true);
236 if (temp->text()=="input") temp->setOn(true); 236 if (temp->text()=="input") temp->setOn(true);
237 if (temp->text()=="sharp") temp->setOn(true); 237 if (temp->text()=="sharp") temp->setOn(true);
238 if (temp->text()=="tty") temp->setOn(true); 238 if (temp->text()=="tty") temp->setOn(true);
239 } 239 }
240 } 240 }
241 // Show the dialog! 241 // Show the dialog!
242 if(!(adduserDialog->exec())) return false; 242 if(!(adduserDialog->exec())) return false;
243 if((adduserDialog->groupComboBox->currentItem()!=0)) 243 if((adduserDialog->groupComboBox->currentItem()!=0))
244 { 244 {
245 accounts->findGroup(adduserDialog->groupComboBox->currentText()); 245 // making the call findGroup() puts the group info in the accounts gr_gid
246 adduserDialog->groupID=accounts->gr_gid; 246 if (accounts->findGroup(adduserDialog->groupComboBox->currentText()))
247 owarn << QString::number(accounts->gr_gid) << oendl; 247 {
248 adduserDialog->groupID=accounts->gr_gid;
249 owarn << QString::number(accounts->gr_gid) << oendl;
250 }
248 } 251 }
249 if(!(accounts->addUser(adduserDialog->loginLineEdit->text(), adduserDialog->passwordLineEdit->text(), 252 if(!(accounts->addUser(adduserDialog->loginLineEdit->text(), adduserDialog->passwordLineEdit->text(),
250 adduserDialog->uidLineEdit->text().toInt(), adduserDialog->groupID, adduserDialog->gecosLineEdit->text(), 253 adduserDialog->uidLineEdit->text().toInt(), adduserDialog->groupID, adduserDialog->gecosLineEdit->text(),
251 QString("/home/")+adduserDialog->loginLineEdit->text() , adduserDialog->shellComboBox->currentText()))) 254 QString("/home/")+adduserDialog->loginLineEdit->text() , adduserDialog->shellComboBox->currentText())))
252 { 255 {
253 QMessageBox::information(0,"Ooops!","Something went wrong!\nUnable to add user."); 256 QMessageBox::information(0,"Ooops!","Something went wrong!\nUnable to add user.");
254 return false; 257 return false;
255 } 258 }
256 259
257 // Add User to additional groups. 260 // Add User to additional groups.
258 QListViewItemIterator it( adduserDialog->groupsListView ); 261 QListViewItemIterator it( adduserDialog->groupsListView );
259 for ( ; it.current(); ++it ) 262 for ( ; it.current(); ++it )
260 { 263 {
261 temp=(QCheckListItem*)it.current(); 264 temp=(QCheckListItem*)it.current();
262 if (temp->isOn() ) 265 if (temp->isOn() )
263 accounts->addGroupMember(it.current()->text(0),adduserDialog->loginLineEdit->text()); 266 accounts->addGroupMember(it.current()->text(0),adduserDialog->loginLineEdit->text());
264 } 267 }
265 // Copy image to pics/users/ 268 // Copy image to pics/users/
266 if(!(adduserDialog->userImage.isNull())) 269 if(!(adduserDialog->userImage.isNull()))
267 { 270 {
268 QDir d; 271 QDir d;
269 if(!(d.exists(QPEApplication::qpeDir() + "pics/users"))) 272 if(!(d.exists(QPEApplication::qpeDir() + "pics/users")))
270 { 273 {
271 d.mkdir(QPEApplication::qpeDir() + "pics/users"); 274 d.mkdir(QPEApplication::qpeDir() + "pics/users");
272 } 275 }
273 QString filename= QPEApplication::qpeDir()+"pics/users/"+accounts->pw_name+".png"; 276 QString filename= QPEApplication::qpeDir()+"pics/users/"+accounts->pw_name+".png";
274 // adduserDialog->userImage=adduserDialog->userImage.smoothScale(48,48); 277 // adduserDialog->userImage=adduserDialog->userImage.smoothScale(48,48);
275 adduserDialog->userImage.save(filename,"PNG"); 278 adduserDialog->userImage.save(filename,"PNG");
276 } 279 }
277 280
278 // Should we copy the skeleton homedirectory /etc/skel to the user's homedirectory? 281 // Should we copy the skeleton homedirectory /etc/skel to the user's homedirectory?
279 accounts->findUser(adduserDialog->loginLineEdit->text()); 282 accounts->findUser(adduserDialog->loginLineEdit->text());
280 if(adduserDialog->skelCheckBox->isChecked()) 283 if(adduserDialog->skelCheckBox->isChecked())
281 { 284 {
282 QString command_cp; 285 QString command_cp;
283 QString command_chown; 286 QString command_chown;
284 command_cp.sprintf("cp -a /etc/skel/* %s/",accounts->pw_dir.latin1()); 287 command_cp.sprintf("cp -a /etc/skel/* %s/",accounts->pw_dir.latin1());
285 system(command_cp); 288 system(command_cp);
286 289
287 command_cp.sprintf("cp -a /etc/skel/.[!.]* %s/",accounts->pw_dir.latin1()); // Bug in busybox, ".*" includes parent directory, does this work as a workaround? 290 command_cp.sprintf("cp -a /etc/skel/.[!.]* %s/",accounts->pw_dir.latin1()); // Bug in busybox, ".*" includes parent directory, does this work as a workaround?
288 system(command_cp); 291 system(command_cp);
289 292
290 command_chown.sprintf("chown -R %d:%d %s",accounts->pw_uid,accounts->pw_gid,accounts->pw_dir.latin1()); 293 command_chown.sprintf("chown -R %d:%d %s",accounts->pw_uid,accounts->pw_gid,accounts->pw_dir.latin1());
291 system(command_chown); 294 system(command_chown);
292 } 295 }
293 296
294 return true; 297 return true;
295} 298}
296 299
297/** 300/**
298 * Deletes the user account. 301 * Deletes the user account.
299 * 302 *
300 * @param username User to be deleted. 303 * @param username User to be deleted.
301 * 304 *
302 * @return <code>true</code> if the user was successfully deleted, otherwise <code>false</code>. 305 * @return <code>true</code> if the user was successfully deleted, otherwise <code>false</code>.
303 * 306 *
304 */ 307 */
305bool UserDialog::delUser(const char *username) 308bool UserDialog::delUser(const char *username)
306{ 309{
307 if((accounts->findUser(username))) 310 if((accounts->findUser(username)))
308 { // Does that user exist? 311 { // Does that user exist?
309 if(!(accounts->delUser(username))) 312 if(!(accounts->delUser(username)))
310 { // Delete the user. 313 { // Delete the user.
311 QMessageBox::information(0,"Ooops!","Something went wrong\nUnable to delete user: "+QString(username)+"."); 314 QMessageBox::information(0,"Ooops!","Something went wrong\nUnable to delete user: "+QString(username)+".");
312 } 315 }
313 } 316 }
314 else 317 else
315 { 318 {
316 QMessageBox::information(0,"Invalid Username","That username ("+QString(username)+")does not exist."); 319 QMessageBox::information(0,"Invalid Username","That username ("+QString(username)+")does not exist.");
317 return false; 320 return false;
318 } 321 }
319 return true; 322 return true;
320} 323}
321 324
322/** 325/**
323 * This displays a confirmation dialog wether a user should be deleted or not. 326 * This displays a confirmation dialog wether a user should be deleted or not.
324 * (And also deletes the account) 327 * (And also deletes the account)
325 * 328 *
326 * @param username User to be deleted. 329 * @param username User to be deleted.
327 * 330 *
328 * @return <code>true</code> if the user was successfully deleted, otherwise <code>false</code>. 331 * @return <code>true</code> if the user was successfully deleted, otherwise <code>false</code>.
329 * 332 *
330 */ 333 */
331bool UserDialog::editUser(const char *username) 334bool UserDialog::editUser(const char *username)
332{ 335{
333 int invalid_group=0; 336 int invalid_group=0;
334 // viewmode is a workaround for a bug in qte-2.3.4 that gives bus error on manipulating edituserDialog's widgets here. 337 // viewmode is a workaround for a bug in qte-2.3.4 that gives bus error on manipulating edituserDialog's widgets here.
335 UserDialog *edituserDialog=new UserDialog(VIEWMODE_EDIT); // Create Dialog 338 UserDialog *edituserDialog=new UserDialog(VIEWMODE_EDIT); // Create Dialog
336 edituserDialog->setCaption(tr("Edit User")); 339 edituserDialog->setCaption(tr("Edit User"));
337 accounts->findUser(username); // Locate user in database and fill variables in 'accounts' object. 340 accounts->findUser(username); // Locate user in database and fill variables in 'accounts' object.
338 if(!(accounts->findGroup(accounts->pw_gid))) 341 if(!(accounts->findGroup(accounts->pw_gid)))
339 { // Locate the user's primary group, and fill group variables in 'accounts' object. 342 { // Locate the user's primary group, and fill group variables in 'accounts' object.
340 invalid_group=1; 343 invalid_group=1;
341 } 344 }
342 // Fill widgets with userinfo. 345 // Fill widgets with userinfo.
343 edituserDialog->loginLineEdit->setText(accounts->pw_name); 346 edituserDialog->loginLineEdit->setText(accounts->pw_name);
344 edituserDialog->uidLineEdit->setText(QString::number(accounts->pw_uid)); 347 edituserDialog->uidLineEdit->setText(QString::number(accounts->pw_uid));
345 edituserDialog->gecosLineEdit->setText(accounts->pw_gecos); 348 edituserDialog->gecosLineEdit->setText(accounts->pw_gecos);
346 // Set password to '........', we will later check if this still is the contents, if not, the password has been changed. 349 // Set password to '........', we will later check if this still is the contents, if not, the password has been changed.
347 edituserDialog->passwordLineEdit->setText("........"); 350 edituserDialog->passwordLineEdit->setText("........");
348 // If this user is not using /bin/sh,/bin/ash or /bin/false as shell, add that entry to the shell-combobox. 351 // If this user is not using /bin/sh,/bin/ash or /bin/false as shell, add that entry to the shell-combobox.
349 if(accounts->pw_shell!="/bin/sh" && accounts->pw_shell!="/bin/ash" && accounts->pw_shell!="/bin/false") 352 if(accounts->pw_shell!="/bin/sh" && accounts->pw_shell!="/bin/ash" && accounts->pw_shell!="/bin/false")
350 { 353 {
351 edituserDialog->shellComboBox->insertItem(accounts->pw_shell,0); 354 edituserDialog->shellComboBox->insertItem(accounts->pw_shell,0);
352 edituserDialog->shellComboBox->setCurrentItem(0); 355 edituserDialog->shellComboBox->setCurrentItem(0);
353 } 356 }
354 // Select the primary group for this user. 357 // Select the primary group for this user.
355 for(int i=0;i<edituserDialog->groupComboBox->count();++i) 358 for(int i=0;i<edituserDialog->groupComboBox->count();++i)
356 { 359 {
357 if(accounts->gr_name==edituserDialog->groupComboBox->text(i)) 360 if(accounts->gr_name==edituserDialog->groupComboBox->text(i))
358 { 361 {
359 edituserDialog->groupComboBox->setCurrentItem(i); 362 edituserDialog->groupComboBox->setCurrentItem(i);
360 break; 363 break;
361 } 364 }
362 } 365 }
363 if(invalid_group) 366 if(invalid_group)
364 { 367 {
365 edituserDialog->groupComboBox->insertItem("<Undefined group>",0); 368 edituserDialog->groupComboBox->insertItem("<Undefined group>",0);
366 edituserDialog->groupComboBox->setCurrentItem(0); 369 edituserDialog->groupComboBox->setCurrentItem(0);
367 } 370 }
368 371
369 // Select the groups in the listview, to which the user belongs. 372 // Select the groups in the listview, to which the user belongs.
370 QCheckListItem *temp; 373 QCheckListItem *temp;
371 // BAH!!! QRegExp in qt2 sucks... or maybe I do... can't figure out how to check for EITHER end of input ($) OR a comma, so here we do two different QRegExps instead. 374 // BAH!!! QRegExp in qt2 sucks... or maybe I do... can't figure out how to check for EITHER end of input ($) OR a comma, so here we do two different QRegExps instead.
372 QRegExp userRegExp(QString("[:,]%1$").arg(username)); // The end of line variant. 375 QRegExp userRegExp(QString("[:,]%1$").arg(username)); // The end of line variant.
373 QStringList tempList=accounts->groupStringList.grep(userRegExp); // Find all entries in the group database, that the user is a member of. 376 QStringList tempList=accounts->groupStringList.grep(userRegExp); // Find all entries in the group database, that the user is a member of.
374 for(QStringList::Iterator it=tempList.begin(); it!=tempList.end(); ++it) 377 for(QStringList::Iterator it=tempList.begin(); it!=tempList.end(); ++it)
375 { // Iterate over all of them. 378 { // Iterate over all of them.