author | llornkcor <llornkcor> | 2002-04-23 23:55:30 (UTC) |
---|---|---|
committer | llornkcor <llornkcor> | 2002-04-23 23:55:30 (UTC) |
commit | 23f73a3a483a4daf3a26d0e83fd947d4f4118013 (patch) (unidiff) | |
tree | 863595f54ae6ac8a9865da9912dfeec7cda561ca | |
parent | f90935204b16126b40d4c562b26e37148ca03536 (diff) | |
download | opie-23f73a3a483a4daf3a26d0e83fd947d4f4118013.zip opie-23f73a3a483a4daf3a26d0e83fd947d4f4118013.tar.gz opie-23f73a3a483a4daf3a26d0e83fd947d4f4118013.tar.bz2 |
symlink icon fix
-rw-r--r-- | noncore/net/opieftp/opieftp.cpp | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/noncore/net/opieftp/opieftp.cpp b/noncore/net/opieftp/opieftp.cpp index d78b7d1..6684abb 100644 --- a/noncore/net/opieftp/opieftp.cpp +++ b/noncore/net/opieftp/opieftp.cpp | |||
@@ -453,385 +453,385 @@ void OpieFtp::localUpload() | |||
453 | // QCopEnvelope ( "QPE/System", "busy()" ); | 453 | // QCopEnvelope ( "QPE/System", "busy()" ); |
454 | // qApp->processEvents(); | 454 | // qApp->processEvents(); |
455 | QList<QListViewItem> * getSelectedItems( QListView * Local_View ); | 455 | QList<QListViewItem> * getSelectedItems( QListView * Local_View ); |
456 | QListViewItemIterator it( Local_View ); | 456 | QListViewItemIterator it( Local_View ); |
457 | for ( ; it.current(); ++it ) { | 457 | for ( ; it.current(); ++it ) { |
458 | if ( it.current()->isSelected() ) { | 458 | if ( it.current()->isSelected() ) { |
459 | QString strItem = it.current()->text(0); | 459 | QString strItem = it.current()->text(0); |
460 | QString localFile = currentDir.canonicalPath()+"/"+strItem; | 460 | QString localFile = currentDir.canonicalPath()+"/"+strItem; |
461 | QString remoteFile= currentRemoteDir+strItem; | 461 | QString remoteFile= currentRemoteDir+strItem; |
462 | QFileInfo fi(localFile); | 462 | QFileInfo fi(localFile); |
463 | if( !fi.isDir()) { | 463 | if( !fi.isDir()) { |
464 | fsz=fi.size(); | 464 | fsz=fi.size(); |
465 | ProgressBar->setTotalSteps(fsz); | 465 | ProgressBar->setTotalSteps(fsz); |
466 | 466 | ||
467 | FtpOptions(FTPLIB_CALLBACK, (long) log_progress, conn); | 467 | FtpOptions(FTPLIB_CALLBACK, (long) log_progress, conn); |
468 | FtpOptions(FTPLIB_IDLETIME, (long) 1000, conn); | 468 | FtpOptions(FTPLIB_IDLETIME, (long) 1000, conn); |
469 | FtpOptions(FTPLIB_CALLBACKARG, (long) &fsz, conn); | 469 | FtpOptions(FTPLIB_CALLBACKARG, (long) &fsz, conn); |
470 | FtpOptions(FTPLIB_CALLBACKBYTES, (long) fsz/10, conn); | 470 | FtpOptions(FTPLIB_CALLBACKBYTES, (long) fsz/10, conn); |
471 | qDebug("Put: %s, %s",localFile.latin1(),remoteFile.latin1()); | 471 | qDebug("Put: %s, %s",localFile.latin1(),remoteFile.latin1()); |
472 | 472 | ||
473 | if( !FtpPut( localFile.latin1(), remoteFile.latin1(),FTPLIB_IMAGE, conn ) ) { | 473 | if( !FtpPut( localFile.latin1(), remoteFile.latin1(),FTPLIB_IMAGE, conn ) ) { |
474 | QString msg; | 474 | QString msg; |
475 | msg.sprintf(tr("Unable to upload\n")+"%s",FtpLastResponse(conn)); | 475 | msg.sprintf(tr("Unable to upload\n")+"%s",FtpLastResponse(conn)); |
476 | msg.replace(QRegExp(":"),"\n"); | 476 | msg.replace(QRegExp(":"),"\n"); |
477 | QMessageBox::message(tr("Note"),msg); | 477 | QMessageBox::message(tr("Note"),msg); |
478 | } | 478 | } |
479 | } else { | 479 | } else { |
480 | QMessageBox::message(tr("Note"),tr("Cannot upload directories")); | 480 | QMessageBox::message(tr("Note"),tr("Cannot upload directories")); |
481 | } | 481 | } |
482 | ProgressBar->reset(); | 482 | ProgressBar->reset(); |
483 | nullifyCallBack(); | 483 | nullifyCallBack(); |
484 | it.current()->setSelected(FALSE); | 484 | it.current()->setSelected(FALSE); |
485 | } //end currentSelected | 485 | } //end currentSelected |
486 | } | 486 | } |
487 | for ( ; it.current(); ++it ) { | 487 | for ( ; it.current(); ++it ) { |
488 | Local_View->clearSelection(); | 488 | Local_View->clearSelection(); |
489 | } | 489 | } |
490 | Local_View->clearFocus(); | 490 | Local_View->clearFocus(); |
491 | TabWidget->setCurrentPage(1); | 491 | TabWidget->setCurrentPage(1); |
492 | remoteDirList( (const QString &)currentRemoteDir); //this also calls populate | 492 | remoteDirList( (const QString &)currentRemoteDir); //this also calls populate |
493 | QCopEnvelope ( "QPE/System", "notBusy()" ); | 493 | QCopEnvelope ( "QPE/System", "notBusy()" ); |
494 | } | 494 | } |
495 | 495 | ||
496 | void OpieFtp::nullifyCallBack() | 496 | void OpieFtp::nullifyCallBack() |
497 | { | 497 | { |
498 | FtpOptions(FTPLIB_CALLBACK, NULL, conn); | 498 | FtpOptions(FTPLIB_CALLBACK, NULL, conn); |
499 | FtpOptions(FTPLIB_IDLETIME, NULL, conn); | 499 | FtpOptions(FTPLIB_IDLETIME, NULL, conn); |
500 | FtpOptions(FTPLIB_CALLBACKARG, NULL, conn); | 500 | FtpOptions(FTPLIB_CALLBACKARG, NULL, conn); |
501 | FtpOptions(FTPLIB_CALLBACKBYTES, NULL, conn); | 501 | FtpOptions(FTPLIB_CALLBACKBYTES, NULL, conn); |
502 | } | 502 | } |
503 | 503 | ||
504 | void OpieFtp::remoteDownload() | 504 | void OpieFtp::remoteDownload() |
505 | { | 505 | { |
506 | // qApp->processEvents(); | 506 | // qApp->processEvents(); |
507 | int fsz; | 507 | int fsz; |
508 | QCopEnvelope ( "QPE/System", "busy()" ); | 508 | QCopEnvelope ( "QPE/System", "busy()" ); |
509 | 509 | ||
510 | QList<QListViewItem> * getSelectedItems( QListView * Remote_View ); | 510 | QList<QListViewItem> * getSelectedItems( QListView * Remote_View ); |
511 | QListViewItemIterator it( Remote_View ); | 511 | QListViewItemIterator it( Remote_View ); |
512 | for ( ; it.current(); ++it ) { | 512 | for ( ; it.current(); ++it ) { |
513 | if ( it.current()->isSelected() ) { | 513 | if ( it.current()->isSelected() ) { |
514 | QString strItem = it.current()->text(0); | 514 | QString strItem = it.current()->text(0); |
515 | // strItem=strItem.right(strItem.length()-1); | 515 | // strItem=strItem.right(strItem.length()-1); |
516 | QString localFile = currentDir.canonicalPath(); | 516 | QString localFile = currentDir.canonicalPath(); |
517 | if(localFile.right(1).find("/",0,TRUE) == -1) | 517 | if(localFile.right(1).find("/",0,TRUE) == -1) |
518 | localFile += "/"; | 518 | localFile += "/"; |
519 | localFile += strItem; | 519 | localFile += strItem; |
520 | // QString localFile = currentDir.canonicalPath()+"/"+strItem; | 520 | // QString localFile = currentDir.canonicalPath()+"/"+strItem; |
521 | QString remoteFile= currentRemoteDir+strItem; | 521 | QString remoteFile= currentRemoteDir+strItem; |
522 | if (!FtpSize( remoteFile.latin1(), &fsz, FTPLIB_ASCII, conn)) | 522 | if (!FtpSize( remoteFile.latin1(), &fsz, FTPLIB_ASCII, conn)) |
523 | fsz = 0; | 523 | fsz = 0; |
524 | QString temp; | 524 | QString temp; |
525 | temp.sprintf( remoteFile+" "+" %dkb", fsz); | 525 | temp.sprintf( remoteFile+" "+" %dkb", fsz); |
526 | 526 | ||
527 | ProgressBar->setTotalSteps(fsz); | 527 | ProgressBar->setTotalSteps(fsz); |
528 | FtpOptions(FTPLIB_CALLBACK, (long) log_progress, conn); | 528 | FtpOptions(FTPLIB_CALLBACK, (long) log_progress, conn); |
529 | FtpOptions(FTPLIB_IDLETIME, (long) 1000, conn); | 529 | FtpOptions(FTPLIB_IDLETIME, (long) 1000, conn); |
530 | FtpOptions(FTPLIB_CALLBACKARG, (long) &fsz, conn); | 530 | FtpOptions(FTPLIB_CALLBACKARG, (long) &fsz, conn); |
531 | FtpOptions(FTPLIB_CALLBACKBYTES, (long) fsz/10, conn); | 531 | FtpOptions(FTPLIB_CALLBACKBYTES, (long) fsz/10, conn); |
532 | qDebug("Get: %s, %s",localFile.latin1(),remoteFile.latin1()); | 532 | qDebug("Get: %s, %s",localFile.latin1(),remoteFile.latin1()); |
533 | 533 | ||
534 | if(!FtpGet( localFile.latin1(), remoteFile.latin1(),FTPLIB_IMAGE, conn ) ) { | 534 | if(!FtpGet( localFile.latin1(), remoteFile.latin1(),FTPLIB_IMAGE, conn ) ) { |
535 | QString msg; | 535 | QString msg; |
536 | msg.sprintf(tr("Unable to download \n")+"%s",FtpLastResponse(conn)); | 536 | msg.sprintf(tr("Unable to download \n")+"%s",FtpLastResponse(conn)); |
537 | msg.replace(QRegExp(":"),"\n"); | 537 | msg.replace(QRegExp(":"),"\n"); |
538 | QMessageBox::message(tr("Note"),msg); | 538 | QMessageBox::message(tr("Note"),msg); |
539 | } | 539 | } |
540 | ProgressBar->reset(); | 540 | ProgressBar->reset(); |
541 | nullifyCallBack(); | 541 | nullifyCallBack(); |
542 | it.current()->setSelected(FALSE); | 542 | it.current()->setSelected(FALSE); |
543 | } | 543 | } |
544 | } | 544 | } |
545 | for ( ; it.current(); ++it ) { | 545 | for ( ; it.current(); ++it ) { |
546 | Remote_View->clearSelection(); | 546 | Remote_View->clearSelection(); |
547 | } | 547 | } |
548 | Remote_View->setFocus(); | 548 | Remote_View->setFocus(); |
549 | TabWidget->setCurrentPage(0); | 549 | TabWidget->setCurrentPage(0); |
550 | populateLocalView(); | 550 | populateLocalView(); |
551 | QCopEnvelope ( "QPE/System", "notBusy()" ); | 551 | QCopEnvelope ( "QPE/System", "notBusy()" ); |
552 | } | 552 | } |
553 | 553 | ||
554 | bool OpieFtp::remoteDirList(const QString &dir) | 554 | bool OpieFtp::remoteDirList(const QString &dir) |
555 | { | 555 | { |
556 | QString tmp = QDir::homeDirPath(); | 556 | QString tmp = QDir::homeDirPath(); |
557 | if(tmp.right(1) != "/") | 557 | if(tmp.right(1) != "/") |
558 | tmp+="/._temp"; | 558 | tmp+="/._temp"; |
559 | else | 559 | else |
560 | tmp+="._temp"; | 560 | tmp+="._temp"; |
561 | // qDebug("Listing remote dir "+tmp); | 561 | // qDebug("Listing remote dir "+tmp); |
562 | QCopEnvelope ( "QPE/System", "busy()" ); | 562 | QCopEnvelope ( "QPE/System", "busy()" ); |
563 | if (!FtpDir( tmp.latin1(), dir.latin1(), conn) ) { | 563 | if (!FtpDir( tmp.latin1(), dir.latin1(), conn) ) { |
564 | QString msg; | 564 | QString msg; |
565 | msg.sprintf(tr("Unable to list the directory\n")+dir+"\n%s",FtpLastResponse(conn) ); | 565 | msg.sprintf(tr("Unable to list the directory\n")+dir+"\n%s",FtpLastResponse(conn) ); |
566 | msg.replace(QRegExp(":"),"\n"); | 566 | msg.replace(QRegExp(":"),"\n"); |
567 | QMessageBox::message(tr("Note"),msg); | 567 | QMessageBox::message(tr("Note"),msg); |
568 | return false; | 568 | return false; |
569 | } | 569 | } |
570 | populateRemoteView() ; | 570 | populateRemoteView() ; |
571 | QCopEnvelope ( "QPE/System", "notBusy()" ); | 571 | QCopEnvelope ( "QPE/System", "notBusy()" ); |
572 | return true; | 572 | return true; |
573 | } | 573 | } |
574 | 574 | ||
575 | bool OpieFtp::remoteChDir(const QString &dir) | 575 | bool OpieFtp::remoteChDir(const QString &dir) |
576 | { | 576 | { |
577 | QCopEnvelope ( "QPE/System", "busy()" ); | 577 | QCopEnvelope ( "QPE/System", "busy()" ); |
578 | if (!FtpChdir( dir.latin1(), conn )) { | 578 | if (!FtpChdir( dir.latin1(), conn )) { |
579 | QString msg; | 579 | QString msg; |
580 | msg.sprintf(tr("Unable to change directories\n")+dir+"\n%s",FtpLastResponse(conn)); | 580 | msg.sprintf(tr("Unable to change directories\n")+dir+"\n%s",FtpLastResponse(conn)); |
581 | msg.replace(QRegExp(":"),"\n"); | 581 | msg.replace(QRegExp(":"),"\n"); |
582 | QMessageBox::message(tr("Note"),msg); | 582 | QMessageBox::message(tr("Note"),msg); |
583 | // qDebug(msg); | 583 | // qDebug(msg); |
584 | QCopEnvelope ( "QPE/System", "notBusy()" ); | 584 | QCopEnvelope ( "QPE/System", "notBusy()" ); |
585 | return FALSE; | 585 | return FALSE; |
586 | } | 586 | } |
587 | QCopEnvelope ( "QPE/System", "notBusy()" ); | 587 | QCopEnvelope ( "QPE/System", "notBusy()" ); |
588 | return TRUE; | 588 | return TRUE; |
589 | } | 589 | } |
590 | 590 | ||
591 | void OpieFtp::populateLocalView() | 591 | void OpieFtp::populateLocalView() |
592 | { | 592 | { |
593 | Local_View->clear(); | 593 | Local_View->clear(); |
594 | currentDir.setSorting(/* QDir::Size*/ /*| QDir::Reversed | */QDir::DirsFirst); | 594 | currentDir.setSorting(/* QDir::Size*/ /*| QDir::Reversed | */QDir::DirsFirst); |
595 | currentDir.setMatchAllDirs(TRUE); | 595 | currentDir.setMatchAllDirs(TRUE); |
596 | currentDir.setNameFilter(filterStr); | 596 | currentDir.setNameFilter(filterStr); |
597 | QString fileL, fileS, fileDate; | 597 | QString fileL, fileS, fileDate; |
598 | bool isDir=FALSE; | 598 | bool isDir=FALSE; |
599 | const QFileInfoList *list = currentDir.entryInfoList( /*QDir::All*/ /*, QDir::SortByMask*/); | 599 | const QFileInfoList *list = currentDir.entryInfoList( /*QDir::All*/ /*, QDir::SortByMask*/); |
600 | QFileInfoListIterator it(*list); | 600 | QFileInfoListIterator it(*list); |
601 | QFileInfo *fi; | 601 | QFileInfo *fi; |
602 | while ( (fi=it.current()) ) { | 602 | while ( (fi=it.current()) ) { |
603 | if (fi->isSymLink() ){ | 603 | if (fi->isSymLink() ){ |
604 | QString symLink=fi->readLink(); | 604 | QString symLink=fi->readLink(); |
605 | // qDebug("Symlink detected "+symLink); | 605 | // qDebug("Symlink detected "+symLink); |
606 | QFileInfo sym( symLink); | 606 | QFileInfo sym( symLink); |
607 | fileS.sprintf( "%10li", sym.size() ); | 607 | fileS.sprintf( "%10li", sym.size() ); |
608 | fileL.sprintf( "%s -> %s", sym.fileName().data(),sym.absFilePath().data() ); | 608 | fileL.sprintf( "%s -> %s", sym.fileName().data(),sym.absFilePath().data() ); |
609 | fileDate = sym.lastModified().toString(); | 609 | fileDate = sym.lastModified().toString(); |
610 | } else { | 610 | } else { |
611 | // qDebug("Not a dir: "+currentDir.canonicalPath()+fileL); | 611 | // qDebug("Not a dir: "+currentDir.canonicalPath()+fileL); |
612 | fileS.sprintf( "%10li", fi->size() ); | 612 | fileS.sprintf( "%10li", fi->size() ); |
613 | fileL.sprintf( "%s",fi->fileName().data() ); | 613 | fileL.sprintf( "%s",fi->fileName().data() ); |
614 | fileDate= fi->lastModified().toString(); | 614 | fileDate= fi->lastModified().toString(); |
615 | if( QDir(QDir::cleanDirPath(currentDir.canonicalPath()+"/"+fileL)).exists() ) { | 615 | if( QDir(QDir::cleanDirPath(currentDir.canonicalPath()+"/"+fileL)).exists() ) { |
616 | fileL+="/"; | 616 | fileL+="/"; |
617 | isDir=TRUE; | 617 | isDir=TRUE; |
618 | // qDebug( fileL); | 618 | // qDebug( fileL); |
619 | } | 619 | } |
620 | } | 620 | } |
621 | if(fileL !="./" && fi->exists()) { | 621 | if(fileL !="./" && fi->exists()) { |
622 | item= new QListViewItem( Local_View,fileL, fileDate, fileS ); | 622 | item= new QListViewItem( Local_View,fileL, fileDate, fileS ); |
623 | QPixmap pm; | 623 | QPixmap pm; |
624 | 624 | ||
625 | if(isDir || fileL.find("/",0,TRUE) != -1) { | 625 | if(isDir || fileL.find("/",0,TRUE) != -1) { |
626 | if( !QDir( fi->filePath() ).isReadable()) | 626 | if( !QDir( fi->filePath() ).isReadable()) |
627 | pm = Resource::loadPixmap( "lockedfolder" ); | 627 | pm = Resource::loadPixmap( "lockedfolder" ); |
628 | else | 628 | else |
629 | pm= Resource::loadPixmap( "folder" ); | 629 | pm= Resource::loadPixmap( "folder" ); |
630 | item->setPixmap( 0,pm ); | 630 | item->setPixmap( 0,pm ); |
631 | } else { | 631 | } else { |
632 | if( !fi->isReadable() ) | 632 | if( !fi->isReadable() ) |
633 | pm = Resource::loadPixmap( "locked" ); | 633 | pm = Resource::loadPixmap( "locked" ); |
634 | else { | 634 | else { |
635 | MimeType mt(fi->filePath()); | 635 | MimeType mt(fi->filePath()); |
636 | pm=mt.pixmap(); //sets the correct pixmap for mimetype | 636 | pm=mt.pixmap(); //sets the correct pixmap for mimetype |
637 | if(pm.isNull()) | 637 | if(pm.isNull()) |
638 | pm = Resource::loadPixmap( "UnknownDocument-14" ); | 638 | pm = Resource::loadPixmap( "UnknownDocument-14" ); |
639 | item->setPixmap( 0,pm); | 639 | item->setPixmap( 0,pm); |
640 | } | 640 | } |
641 | } | 641 | } |
642 | if( fileL.find("->",0,TRUE) != -1) { | 642 | if( fileL.find("->",0,TRUE) != -1) { |
643 | // overlay link image | 643 | // overlay link image |
644 | pm= Resource::loadPixmap( "folder" ); | 644 | pm= Resource::loadPixmap( "folder" ); |
645 | QPixmap lnk = Resource::loadPixmap( "symlink" ); | 645 | QPixmap lnk = Resource::loadPixmap( "opie/symlink" ); |
646 | QPainter painter( &pm ); | 646 | QPainter painter( &pm ); |
647 | painter.drawPixmap( pm.width()-lnk.width(), pm.height()-lnk.height(), lnk ); | 647 | painter.drawPixmap( pm.width()-lnk.width(), pm.height()-lnk.height(), lnk ); |
648 | pm.setMask( pm.createHeuristicMask( FALSE ) ); | 648 | pm.setMask( pm.createHeuristicMask( FALSE ) ); |
649 | item->setPixmap( 0, pm); | 649 | item->setPixmap( 0, pm); |
650 | } | 650 | } |
651 | } | 651 | } |
652 | isDir=FALSE; | 652 | isDir=FALSE; |
653 | ++it; | 653 | ++it; |
654 | } | 654 | } |
655 | Local_View->setSorting( 3,FALSE); | 655 | Local_View->setSorting( 3,FALSE); |
656 | currentPathCombo->lineEdit()->setText( currentDir.canonicalPath() ); | 656 | currentPathCombo->lineEdit()->setText( currentDir.canonicalPath() ); |
657 | fillCombo( (const QString &)currentDir); | 657 | fillCombo( (const QString &)currentDir); |
658 | } | 658 | } |
659 | 659 | ||
660 | bool OpieFtp::populateRemoteView( ) | 660 | bool OpieFtp::populateRemoteView( ) |
661 | { | 661 | { |
662 | // qDebug("populate remoteview"); | 662 | // qDebug("populate remoteview"); |
663 | QString sfile=QDir::homeDirPath(); | 663 | QString sfile=QDir::homeDirPath(); |
664 | if(sfile.right(1) != "/") | 664 | if(sfile.right(1) != "/") |
665 | sfile+="/._temp"; | 665 | sfile+="/._temp"; |
666 | else | 666 | else |
667 | sfile+="._temp"; | 667 | sfile+="._temp"; |
668 | QFile file( sfile); | 668 | QFile file( sfile); |
669 | Remote_View->clear(); | 669 | Remote_View->clear(); |
670 | QString s, File_Name; | 670 | QString s, File_Name; |
671 | QListViewItem *itemDir=NULL, *itemFile=NULL; | 671 | QListViewItem *itemDir=NULL, *itemFile=NULL; |
672 | QString fileL, fileS, fileDate; | 672 | QString fileL, fileS, fileDate; |
673 | if ( file.open(IO_ReadOnly)) { | 673 | if ( file.open(IO_ReadOnly)) { |
674 | QTextStream t( &file ); // use a text stream | 674 | QTextStream t( &file ); // use a text stream |
675 | while ( !t.eof()) { | 675 | while ( !t.eof()) { |
676 | s = t.readLine(); | 676 | s = t.readLine(); |
677 | fileL = s.right(s.length()-55); | 677 | fileL = s.right(s.length()-55); |
678 | fileL = fileL.stripWhiteSpace(); | 678 | fileL = fileL.stripWhiteSpace(); |
679 | if(s.left(1) == "d") | 679 | if(s.left(1) == "d") |
680 | fileL = fileL+"/"; | 680 | fileL = fileL+"/"; |
681 | // fileL = "/"+fileL+"/"; | 681 | // fileL = "/"+fileL+"/"; |
682 | fileS = s.mid( 30, 42-30); | 682 | fileS = s.mid( 30, 42-30); |
683 | fileS = fileS.stripWhiteSpace(); | 683 | fileS = fileS.stripWhiteSpace(); |
684 | fileDate = s.mid( 42, 55-42); | 684 | fileDate = s.mid( 42, 55-42); |
685 | fileDate = fileDate.stripWhiteSpace(); | 685 | fileDate = fileDate.stripWhiteSpace(); |
686 | if(fileL.find("total",0,TRUE) == -1) { | 686 | if(fileL.find("total",0,TRUE) == -1) { |
687 | if(s.left(1) == "d" || fileL.find("/",0,TRUE) != -1) { | 687 | if(s.left(1) == "d" || fileL.find("/",0,TRUE) != -1) { |
688 | QListViewItem * item = new QListViewItem( Remote_View, fileL, fileDate, fileS,"d"); | 688 | QListViewItem * item = new QListViewItem( Remote_View, fileL, fileDate, fileS,"d"); |
689 | item->setPixmap( 0, Resource::loadPixmap( "folder" )); | 689 | item->setPixmap( 0, Resource::loadPixmap( "folder" )); |
690 | // if(itemDir) | 690 | // if(itemDir) |
691 | item->moveItem(itemDir); | 691 | item->moveItem(itemDir); |
692 | itemDir=item; | 692 | itemDir=item; |
693 | } else { | 693 | } else { |
694 | QListViewItem * item = new QListViewItem( Remote_View, fileL, fileDate, fileS,"f"); | 694 | QListViewItem * item = new QListViewItem( Remote_View, fileL, fileDate, fileS,"f"); |
695 | item->setPixmap( 0, Resource::loadPixmap( "fileopen" )); | 695 | item->setPixmap( 0, Resource::loadPixmap( "fileopen" )); |
696 | // if(itemFile) | 696 | // if(itemFile) |
697 | item->moveItem(itemDir); | 697 | item->moveItem(itemDir); |
698 | item->moveItem(itemFile); | 698 | item->moveItem(itemFile); |
699 | itemFile=item; | 699 | itemFile=item; |
700 | } | 700 | } |
701 | } | 701 | } |
702 | } | 702 | } |
703 | QListViewItem * item1 = new QListViewItem( Remote_View, "../"); | 703 | QListViewItem * item1 = new QListViewItem( Remote_View, "../"); |
704 | item1->setPixmap( 0, Resource::loadPixmap( "folder" )); | 704 | item1->setPixmap( 0, Resource::loadPixmap( "folder" )); |
705 | file.close(); | 705 | file.close(); |
706 | if( file.exists()) | 706 | if( file.exists()) |
707 | file. remove(); | 707 | file. remove(); |
708 | } else | 708 | } else |
709 | qDebug("temp file not opened successfullly "+sfile); | 709 | qDebug("temp file not opened successfullly "+sfile); |
710 | Remote_View->setSorting( 4,TRUE); | 710 | Remote_View->setSorting( 4,TRUE); |
711 | return true; | 711 | return true; |
712 | } | 712 | } |
713 | 713 | ||
714 | void OpieFtp::remoteListClicked(QListViewItem *selectedItem) | 714 | void OpieFtp::remoteListClicked(QListViewItem *selectedItem) |
715 | { | 715 | { |
716 | if( selectedItem) { | 716 | if( selectedItem) { |
717 | // QCopEnvelope ( "QPE/System", "busy()" ); | 717 | // QCopEnvelope ( "QPE/System", "busy()" ); |
718 | QString oldRemoteCurrentDir = currentRemoteDir; | 718 | QString oldRemoteCurrentDir = currentRemoteDir; |
719 | QString strItem=selectedItem->text(0); | 719 | QString strItem=selectedItem->text(0); |
720 | strItem=strItem.simplifyWhiteSpace(); | 720 | strItem=strItem.simplifyWhiteSpace(); |
721 | if(strItem == "../") { // the user wants to go ^ | 721 | if(strItem == "../") { // the user wants to go ^ |
722 | if( FtpCDUp( conn) == 0) { | 722 | if( FtpCDUp( conn) == 0) { |
723 | QString msg; | 723 | QString msg; |
724 | msg.sprintf(tr("Unable to cd up\n")+"%s",FtpLastResponse(conn)); | 724 | msg.sprintf(tr("Unable to cd up\n")+"%s",FtpLastResponse(conn)); |
725 | msg.replace(QRegExp(":"),"\n"); | 725 | msg.replace(QRegExp(":"),"\n"); |
726 | QMessageBox::message(tr("Note"),msg); | 726 | QMessageBox::message(tr("Note"),msg); |
727 | // qDebug(msg); | 727 | // qDebug(msg); |
728 | } | 728 | } |
729 | char path[256]; | 729 | char path[256]; |
730 | if( FtpPwd( path,sizeof(path),conn) == 0) { //this is easier than fudging the string | 730 | if( FtpPwd( path,sizeof(path),conn) == 0) { //this is easier than fudging the string |
731 | QString msg; | 731 | QString msg; |
732 | msg.sprintf(tr("Unable to get working dir\n")+"%s",FtpLastResponse(conn)); | 732 | msg.sprintf(tr("Unable to get working dir\n")+"%s",FtpLastResponse(conn)); |
733 | msg.replace(QRegExp(":"),"\n"); | 733 | msg.replace(QRegExp(":"),"\n"); |
734 | QMessageBox::message(tr("Note"),msg); | 734 | QMessageBox::message(tr("Note"),msg); |
735 | // qDebug(msg); | 735 | // qDebug(msg); |
736 | } | 736 | } |
737 | currentRemoteDir=path; | 737 | currentRemoteDir=path; |
738 | } else { | 738 | } else { |
739 | if(strItem.find("->",0,TRUE) != -1) { //symlink on some servers | 739 | if(strItem.find("->",0,TRUE) != -1) { //symlink on some servers |
740 | strItem=strItem.right( strItem.length() - strItem.find("->",0,TRUE) - 2 ); | 740 | strItem=strItem.right( strItem.length() - strItem.find("->",0,TRUE) - 2 ); |
741 | strItem = strItem.stripWhiteSpace(); | 741 | strItem = strItem.stripWhiteSpace(); |
742 | currentRemoteDir = strItem; | 742 | currentRemoteDir = strItem; |
743 | if( !remoteChDir( (const QString &)strItem)) { | 743 | if( !remoteChDir( (const QString &)strItem)) { |
744 | currentRemoteDir = oldRemoteCurrentDir; | 744 | currentRemoteDir = oldRemoteCurrentDir; |
745 | strItem=""; | 745 | strItem=""; |
746 | // qDebug("RemoteCurrentDir1 "+oldRemoteCurrentDir); | 746 | // qDebug("RemoteCurrentDir1 "+oldRemoteCurrentDir); |
747 | } | 747 | } |
748 | } else if(strItem.find("/",0,TRUE) != -1) { // this is a directory | 748 | } else if(strItem.find("/",0,TRUE) != -1) { // this is a directory |
749 | if( !remoteChDir( (const QString &)currentRemoteDir + strItem)) { | 749 | if( !remoteChDir( (const QString &)currentRemoteDir + strItem)) { |
750 | currentRemoteDir = oldRemoteCurrentDir; | 750 | currentRemoteDir = oldRemoteCurrentDir; |
751 | strItem=""; | 751 | strItem=""; |
752 | // qDebug("RemoteCurrentDir1 "+oldRemoteCurrentDir); | 752 | // qDebug("RemoteCurrentDir1 "+oldRemoteCurrentDir); |
753 | 753 | ||
754 | } else { | 754 | } else { |
755 | currentRemoteDir = currentRemoteDir+strItem; | 755 | currentRemoteDir = currentRemoteDir+strItem; |
756 | } | 756 | } |
757 | } else { | 757 | } else { |
758 | QCopEnvelope ( "QPE/System", "notBusy()" ); | 758 | QCopEnvelope ( "QPE/System", "notBusy()" ); |
759 | return; | 759 | return; |
760 | } | 760 | } |
761 | } | 761 | } |
762 | remoteDirList( (const QString &)currentRemoteDir); //this also calls populate | 762 | remoteDirList( (const QString &)currentRemoteDir); //this also calls populate |
763 | if(currentRemoteDir.right(1) !="/") | 763 | if(currentRemoteDir.right(1) !="/") |
764 | currentRemoteDir +="/"; | 764 | currentRemoteDir +="/"; |
765 | currentPathCombo->lineEdit()->setText( currentRemoteDir); | 765 | currentPathCombo->lineEdit()->setText( currentRemoteDir); |
766 | fillRemoteCombo( (const QString &)currentRemoteDir); | 766 | fillRemoteCombo( (const QString &)currentRemoteDir); |
767 | // QCopEnvelope ( "QPE/System", "notBusy()" ); | 767 | // QCopEnvelope ( "QPE/System", "notBusy()" ); |
768 | } | 768 | } |
769 | } | 769 | } |
770 | 770 | ||
771 | void OpieFtp::localListClicked(QListViewItem *selectedItem) | 771 | void OpieFtp::localListClicked(QListViewItem *selectedItem) |
772 | { | 772 | { |
773 | if(selectedItem!= NULL) { | 773 | if(selectedItem!= NULL) { |
774 | 774 | ||
775 | QString strItem=selectedItem->text(0); | 775 | QString strItem=selectedItem->text(0); |
776 | QString strSize=selectedItem->text(1); | 776 | QString strSize=selectedItem->text(1); |
777 | strSize=strSize.stripWhiteSpace(); | 777 | strSize=strSize.stripWhiteSpace(); |
778 | if(strItem.find("@",0,TRUE) !=-1 || strItem.find("->",0,TRUE) !=-1 ) { //if symlink | 778 | if(strItem.find("@",0,TRUE) !=-1 || strItem.find("->",0,TRUE) !=-1 ) { //if symlink |
779 | // is symlink | 779 | // is symlink |
780 | QString strItem2 = strItem.right( (strItem.length() - strItem.find("->",0,TRUE)) - 4); | 780 | QString strItem2 = strItem.right( (strItem.length() - strItem.find("->",0,TRUE)) - 4); |
781 | if(QDir(strItem2).exists() ) { | 781 | if(QDir(strItem2).exists() ) { |
782 | currentDir.cd(strItem2, TRUE); | 782 | currentDir.cd(strItem2, TRUE); |
783 | populateLocalView(); | 783 | populateLocalView(); |
784 | } | 784 | } |
785 | } else { // not a symlink | 785 | } else { // not a symlink |
786 | if(strItem.find(". .",0,TRUE) && strItem.find("/",0,TRUE)!=-1 ) { | 786 | if(strItem.find(". .",0,TRUE) && strItem.find("/",0,TRUE)!=-1 ) { |
787 | 787 | ||
788 | if(QDir(QDir::cleanDirPath(currentDir.canonicalPath()+"/"+strItem)).exists() ) { | 788 | if(QDir(QDir::cleanDirPath(currentDir.canonicalPath()+"/"+strItem)).exists() ) { |
789 | strItem=QDir::cleanDirPath(currentDir.canonicalPath()+"/"+strItem); | 789 | strItem=QDir::cleanDirPath(currentDir.canonicalPath()+"/"+strItem); |
790 | currentDir.cd(strItem,FALSE); | 790 | currentDir.cd(strItem,FALSE); |
791 | populateLocalView(); | 791 | populateLocalView(); |
792 | } else { | 792 | } else { |
793 | currentDir.cdUp(); | 793 | currentDir.cdUp(); |
794 | populateLocalView(); | 794 | populateLocalView(); |
795 | } | 795 | } |
796 | if(QDir(strItem).exists()){ | 796 | if(QDir(strItem).exists()){ |
797 | currentDir.cd(strItem, TRUE); | 797 | currentDir.cd(strItem, TRUE); |
798 | populateLocalView(); | 798 | populateLocalView(); |
799 | } | 799 | } |
800 | } else { | 800 | } else { |
801 | strItem=QDir::cleanDirPath(currentDir.canonicalPath()+"/"+strItem); | 801 | strItem=QDir::cleanDirPath(currentDir.canonicalPath()+"/"+strItem); |
802 | if( QFile::exists(strItem ) ) { | 802 | if( QFile::exists(strItem ) ) { |
803 | // qDebug("upload "+strItem); | 803 | // qDebug("upload "+strItem); |
804 | return; | 804 | return; |
805 | } | 805 | } |
806 | } //end not symlink | 806 | } //end not symlink |
807 | chdir(strItem.latin1()); | 807 | chdir(strItem.latin1()); |
808 | } | 808 | } |
809 | } | 809 | } |
810 | } | 810 | } |
811 | 811 | ||
812 | void OpieFtp::doLocalCd() | 812 | void OpieFtp::doLocalCd() |
813 | { | 813 | { |
814 | localListClicked( Local_View->currentItem()); | 814 | localListClicked( Local_View->currentItem()); |
815 | } | 815 | } |
816 | 816 | ||
817 | void OpieFtp:: doRemoteCd() | 817 | void OpieFtp:: doRemoteCd() |
818 | { | 818 | { |
819 | remoteListClicked( Remote_View->currentItem()); | 819 | remoteListClicked( Remote_View->currentItem()); |
820 | 820 | ||
821 | } | 821 | } |
822 | 822 | ||
823 | void OpieFtp::showHidden() | 823 | void OpieFtp::showHidden() |
824 | { | 824 | { |
825 | if (!b) { | 825 | if (!b) { |
826 | currentDir.setFilter( QDir::Files | QDir::Dirs | QDir::Hidden | QDir::All); | 826 | currentDir.setFilter( QDir::Files | QDir::Dirs | QDir::Hidden | QDir::All); |
827 | localMenu->setItemChecked(localMenu->idAt(0),TRUE); | 827 | localMenu->setItemChecked(localMenu->idAt(0),TRUE); |
828 | // currentDir.setSorting(/* QDir::Size*/ /*| QDir::Reversed | */QDir::DirsFirst); | 828 | // currentDir.setSorting(/* QDir::Size*/ /*| QDir::Reversed | */QDir::DirsFirst); |
829 | b=TRUE; | 829 | b=TRUE; |
830 | 830 | ||
831 | } else { | 831 | } else { |
832 | currentDir.setFilter( QDir::Files | QDir::Dirs/* | QDir::Hidden*/ | QDir::All); | 832 | currentDir.setFilter( QDir::Files | QDir::Dirs/* | QDir::Hidden*/ | QDir::All); |
833 | localMenu->setItemChecked(localMenu->idAt(0),FALSE); | 833 | localMenu->setItemChecked(localMenu->idAt(0),FALSE); |
834 | // currentDir.setSorting(/* QDir::Size*/ /*| QDir::Reversed | */QDir::DirsFirst); | 834 | // currentDir.setSorting(/* QDir::Size*/ /*| QDir::Reversed | */QDir::DirsFirst); |
835 | b=FALSE; | 835 | b=FALSE; |
836 | } | 836 | } |
837 | populateLocalView(); | 837 | populateLocalView(); |