summaryrefslogtreecommitdiff
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/net/opieftp/opieftp.cpp23
1 files changed, 14 insertions, 9 deletions
diff --git a/noncore/net/opieftp/opieftp.cpp b/noncore/net/opieftp/opieftp.cpp
index 668a03d..269449e 100644
--- a/noncore/net/opieftp/opieftp.cpp
+++ b/noncore/net/opieftp/opieftp.cpp
@@ -717,97 +717,98 @@ bool OpieFtp::populateRemoteView( )
717 QString s, File_Name; 717 QString s, File_Name;
718 QListViewItem *itemDir=NULL, *itemFile=NULL; 718 QListViewItem *itemDir=NULL, *itemFile=NULL;
719 QRegExp monthRe(" [JFMASOND][eapuecoe][brynlgptvc] [ 0-9][0-9] [ 0-9][0-9][:0-9][0-9][0-9] "); 719 QRegExp monthRe(" [JFMASOND][eapuecoe][brynlgptvc] [ 0-9][0-9] [ 0-9][0-9][:0-9][0-9][0-9] ");
720 QString fileL, fileS, fileDate; 720 QString fileL, fileS, fileDate;
721 if ( file.open(IO_ReadOnly)) { 721 if ( file.open(IO_ReadOnly)) {
722 QTextStream t( &file ); // use a text stream 722 QTextStream t( &file ); // use a text stream
723 while ( !t.eof()) { 723 while ( !t.eof()) {
724 s = t.readLine(); 724 s = t.readLine();
725 725
726 if(s.find("total",0,TRUE) == 0) 726 if(s.find("total",0,TRUE) == 0)
727 continue; 727 continue;
728 728
729 int len, month = monthRe.match(s, 0, &len); 729 int len, month = monthRe.match(s, 0, &len);
730 fileDate = s.mid(month + 1, len - 2); // minus spaces 730 fileDate = s.mid(month + 1, len - 2); // minus spaces
731 fileL = s.right(s.length() - month - len); 731 fileL = s.right(s.length() - month - len);
732 if(s.left(1) == "d") 732 if(s.left(1) == "d")
733 fileL = fileL+"/"; 733 fileL = fileL+"/";
734 fileS = s.mid(month - 8, 8); // FIXME 734 fileS = s.mid(month - 8, 8); // FIXME
735 fileS = fileS.stripWhiteSpace(); 735 fileS = fileS.stripWhiteSpace();
736 736
737 if(s.left(1) == "d" || fileL.find("/",0,TRUE) != -1) { 737 if(s.left(1) == "d" || fileL.find("/",0,TRUE) != -1) {
738 QListViewItem * item = new QListViewItem( Remote_View, fileL, fileDate, fileS,"d"); 738 QListViewItem * item = new QListViewItem( Remote_View, fileL, fileDate, fileS,"d");
739 item->setPixmap( 0, Resource::loadPixmap( "folder" )); 739 item->setPixmap( 0, Resource::loadPixmap( "folder" ));
740// if(itemDir) 740// if(itemDir)
741 item->moveItem(itemDir); 741 item->moveItem(itemDir);
742 itemDir=item; 742 itemDir=item;
743 } else { 743 } else {
744 QListViewItem * item = new QListViewItem( Remote_View, fileL, fileDate, fileS,"f"); 744 QListViewItem * item = new QListViewItem( Remote_View, fileL, fileDate, fileS,"f");
745 item->setPixmap( 0, Resource::loadPixmap( "fileopen" )); 745 item->setPixmap( 0, Resource::loadPixmap( "fileopen" ));
746// if(itemFile) 746// if(itemFile)
747 item->moveItem(itemDir); 747 item->moveItem(itemDir);
748 item->moveItem(itemFile); 748 item->moveItem(itemFile);
749 itemFile=item; 749 itemFile=item;
750 } 750 }
751 } 751 }
752 QListViewItem * item1 = new QListViewItem( Remote_View, "../"); 752 QListViewItem * item1 = new QListViewItem( Remote_View, "../");
753 item1->setPixmap( 0, Resource::loadPixmap( "folder" )); 753 item1->setPixmap( 0, Resource::loadPixmap( "folder" ));
754 file.close(); 754 file.close();
755 if( file.exists()) 755 if( file.exists())
756 file. remove(); 756 file. remove();
757 } else 757 } else
758 qDebug("temp file not opened successfullly "+sfile); 758 qDebug("temp file not opened successfullly "+sfile);
759 Remote_View->setSorting( 4,TRUE); 759 Remote_View->setSorting( 4,TRUE);
760 return true; 760 return true;
761} 761}
762 762
763void OpieFtp::remoteListClicked(QListViewItem *selectedItem) 763void OpieFtp::remoteListClicked(QListViewItem *selectedItem)
764{ 764{
765 if( selectedItem) { 765 if( selectedItem) {
766 // if(selectedItem!= NULL) {
766// QCopEnvelope ( "QPE/System", "busy()" ); 767// QCopEnvelope ( "QPE/System", "busy()" );
767 QString oldRemoteCurrentDir = currentRemoteDir; 768 QString oldRemoteCurrentDir = currentRemoteDir;
768 QString strItem=selectedItem->text(0); 769 QString strItem=selectedItem->text(0);
769 strItem=strItem.simplifyWhiteSpace(); 770 strItem=strItem.simplifyWhiteSpace();
770 if(strItem == "../") { // the user wants to go ^ 771 if(strItem == "../") { // the user wants to go ^
771 if( FtpCDUp( conn) == 0) { 772 if( FtpCDUp( conn) == 0) {
772 QString msg; 773 QString msg;
773 msg.sprintf(tr("Unable to cd up\n")+"%s",FtpLastResponse(conn)); 774 msg.sprintf(tr("Unable to cd up\n")+"%s",FtpLastResponse(conn));
774 msg.replace(QRegExp(":"),"\n"); 775 msg.replace(QRegExp(":"),"\n");
775 QMessageBox::message(tr("Note"),msg); 776 QMessageBox::message(tr("Note"),msg);
776// qDebug(msg); 777// qDebug(msg);
777 } 778 }
778 char path[256]; 779 char path[256];
779 if( FtpPwd( path,sizeof(path),conn) == 0) { //this is easier than fudging the string 780 if( FtpPwd( path,sizeof(path),conn) == 0) { //this is easier than fudging the string
780 QString msg; 781 QString msg;
781 msg.sprintf(tr("Unable to get working dir\n")+"%s",FtpLastResponse(conn)); 782 msg.sprintf(tr("Unable to get working dir\n")+"%s",FtpLastResponse(conn));
782 msg.replace(QRegExp(":"),"\n"); 783 msg.replace(QRegExp(":"),"\n");
783 QMessageBox::message(tr("Note"),msg); 784 QMessageBox::message(tr("Note"),msg);
784// qDebug(msg); 785// qDebug(msg);
785 } 786 }
786 currentRemoteDir=path; 787 currentRemoteDir=path;
787 } else { 788 } else {
788 if(strItem.find("->",0,TRUE) != -1) { //symlink on some servers 789 if(strItem.find("->",0,TRUE) != -1) { //symlink on some servers
789 strItem=strItem.right( strItem.length() - strItem.find("->",0,TRUE) - 2 ); 790 strItem=strItem.right( strItem.length() - strItem.find("->",0,TRUE) - 2 );
790 strItem = strItem.stripWhiteSpace(); 791 strItem = strItem.stripWhiteSpace();
791 currentRemoteDir = strItem; 792 currentRemoteDir = strItem;
792 if( !remoteChDir( (const QString &)strItem)) { 793 if( !remoteChDir( (const QString &)strItem)) {
793 currentRemoteDir = oldRemoteCurrentDir; 794 currentRemoteDir = oldRemoteCurrentDir;
794 strItem=""; 795 strItem="";
795// qDebug("RemoteCurrentDir1 "+oldRemoteCurrentDir); 796// qDebug("RemoteCurrentDir1 "+oldRemoteCurrentDir);
796 } 797 }
797 } else if(strItem.find("/",0,TRUE) != -1) { // this is a directory 798 } else if(strItem.find("/",0,TRUE) != -1) { // this is a directory
798 if( !remoteChDir( (const QString &)currentRemoteDir + strItem)) { 799 if( !remoteChDir( (const QString &)currentRemoteDir + strItem)) {
799 currentRemoteDir = oldRemoteCurrentDir; 800 currentRemoteDir = oldRemoteCurrentDir;
800 strItem=""; 801 strItem="";
801// qDebug("RemoteCurrentDir1 "+oldRemoteCurrentDir); 802// qDebug("RemoteCurrentDir1 "+oldRemoteCurrentDir);
802 803
803 } else { 804 } else {
804 currentRemoteDir = currentRemoteDir+strItem; 805 currentRemoteDir = currentRemoteDir+strItem;
805 } 806 }
806 } else { 807 } else {
807// QCopEnvelope ( "QPE/System", "notBusy()" ); 808// QCopEnvelope ( "QPE/System", "notBusy()" );
808 return; 809 return;
809 } 810 }
810 } 811 }
811 remoteDirList( (const QString &)currentRemoteDir); //this also calls populate 812 remoteDirList( (const QString &)currentRemoteDir); //this also calls populate
812 if(currentRemoteDir.right(1) !="/") 813 if(currentRemoteDir.right(1) !="/")
813 currentRemoteDir +="/"; 814 currentRemoteDir +="/";
@@ -863,120 +864,124 @@ void OpieFtp::localListClicked(QListViewItem *selectedItem)
863 864
864void OpieFtp::doLocalCd() 865void OpieFtp::doLocalCd()
865{ 866{
866 localListClicked( Local_View->currentItem()); 867 localListClicked( Local_View->currentItem());
867} 868}
868 869
869void OpieFtp:: doRemoteCd() 870void OpieFtp:: doRemoteCd()
870{ 871{
871 remoteListClicked( Remote_View->currentItem()); 872 remoteListClicked( Remote_View->currentItem());
872 873
873} 874}
874 875
875void OpieFtp::showHidden() 876void OpieFtp::showHidden()
876{ 877{
877 if (!b) { 878 if (!b) {
878 currentDir.setFilter( QDir::Files | QDir::Dirs | QDir::Hidden | QDir::All); 879 currentDir.setFilter( QDir::Files | QDir::Dirs | QDir::Hidden | QDir::All);
879 localMenu->setItemChecked(localMenu->idAt(0),TRUE); 880 localMenu->setItemChecked(localMenu->idAt(0),TRUE);
880// currentDir.setSorting(/* QDir::Size*/ /*| QDir::Reversed | */QDir::DirsFirst); 881// currentDir.setSorting(/* QDir::Size*/ /*| QDir::Reversed | */QDir::DirsFirst);
881 b=TRUE; 882 b=TRUE;
882 883
883 } else { 884 } else {
884 currentDir.setFilter( QDir::Files | QDir::Dirs/* | QDir::Hidden*/ | QDir::All); 885 currentDir.setFilter( QDir::Files | QDir::Dirs/* | QDir::Hidden*/ | QDir::All);
885 localMenu->setItemChecked(localMenu->idAt(0),FALSE); 886 localMenu->setItemChecked(localMenu->idAt(0),FALSE);
886// currentDir.setSorting(/* QDir::Size*/ /*| QDir::Reversed | */QDir::DirsFirst); 887// currentDir.setSorting(/* QDir::Size*/ /*| QDir::Reversed | */QDir::DirsFirst);
887 b=FALSE; 888 b=FALSE;
888 } 889 }
889 populateLocalView(); 890 populateLocalView();
890} 891}
891 892
892void OpieFtp::ListPressed( int mouse, QListViewItem *item, const QPoint &, int) 893void OpieFtp::ListPressed( int mouse, QListViewItem *item, const QPoint &, int)
893{ 894{
894// if(item) 895// if(item)
895 if (mouse == 2) { 896 if (mouse == 2) {
896 showLocalMenu(item); 897 showLocalMenu(item);
897 } 898 }
898} 899}
899 900
900void OpieFtp::RemoteListPressed( int mouse, QListViewItem *item, const QPoint &, int ) 901void OpieFtp::RemoteListPressed( int mouse, QListViewItem *item, const QPoint &, int )
901{ 902{
902 if(mouse == 2) { 903 if(mouse == 2) {
903 showRemoteMenu(item); 904 showRemoteMenu(item);
904 } 905 }
905} 906}
906 907
907void OpieFtp::showRemoteMenu(QListViewItem * item) 908void OpieFtp::showRemoteMenu(QListViewItem * item)
908{ 909{
909 QPopupMenu * m;// = new QPopupMenu( Local_View ); 910 QPopupMenu * m;// = new QPopupMenu( Local_View );
910 m = new QPopupMenu(this); 911 m = new QPopupMenu(this);
911 if( /*item->text(0).right(1) == "/" ||*/ item->text(0).find("/",0,TRUE) != -1) 912 if(item != NULL ) {
912 m->insertItem( tr( "Change Directory" ), this, SLOT( doRemoteCd() )); 913 if( item->text(0).find("/",0,TRUE) != -1)
913 else 914 m->insertItem( tr( "Change Directory" ), this, SLOT( doRemoteCd() ));
914 m->insertItem( tr( "Download" ), this, SLOT( remoteDownload() )); 915 else
916 m->insertItem( tr( "Download" ), this, SLOT( remoteDownload() ));
917 }
915 m->insertItem( tr( "Make Directory" ), this, SLOT( remoteMakDir() )); 918 m->insertItem( tr( "Make Directory" ), this, SLOT( remoteMakDir() ));
916 m->insertItem( tr("Rescan"), this, SLOT( populateLocalView() )); 919 m->insertItem( tr("Rescan"), this, SLOT( populateLocalView() ));
917 m->insertItem( tr( "Rename" ), this, SLOT( remoteRename() )); 920 m->insertItem( tr( "Rename" ), this, SLOT( remoteRename() ));
918 m->insertSeparator(); 921 m->insertSeparator();
919 m->insertItem( tr( "Delete" ), this, SLOT( remoteDelete() )); 922 m->insertItem( tr( "Delete" ), this, SLOT( remoteDelete() ));
920 m->exec( QCursor::pos() ); 923 m->exec( QCursor::pos() );
921 delete m; 924 delete m;
922} 925}
923 926
924void OpieFtp::showLocalMenu(QListViewItem * item) 927void OpieFtp::showLocalMenu(QListViewItem * item)
925{ 928{
926 929
927 QPopupMenu *m; 930 QPopupMenu *m;
928 m = new QPopupMenu( this); 931 m = new QPopupMenu( this);
929 m->insertItem( tr( "Show Hidden Files" ), this, SLOT( showHidden() )); 932 m->insertItem( tr( "Show Hidden Files" ), this, SLOT( showHidden() ));
930 m->insertSeparator(); 933 m->insertSeparator();
931 if( /*item->text(0).right(1) == "/" ||*/ item->text(0).find("/",0,TRUE) !=-1) 934 if(item != NULL ) {
932 m->insertItem( tr( "Change Directory" ), this, SLOT( doLocalCd() )); 935 if( item->text(0).find("/",0,TRUE) !=-1)
933 else 936 m->insertItem( tr( "Change Directory" ), this, SLOT( doLocalCd() ));
934 m->insertItem( tr( "Upload" ), this, SLOT( localUpload() )); 937 else
938 m->insertItem( tr( "Upload" ), this, SLOT( localUpload() ));
939 }
935 m->insertItem( tr( "Make Directory" ), this, SLOT( localMakDir() )); 940 m->insertItem( tr( "Make Directory" ), this, SLOT( localMakDir() ));
936 m->insertItem( tr("Rescan"), this, SLOT( populateRemoteView() )); 941 m->insertItem( tr("Rescan"), this, SLOT( populateRemoteView() ));
937 m->insertItem( tr( "Rename" ), this, SLOT( localRename() )); 942 m->insertItem( tr( "Rename" ), this, SLOT( localRename() ));
938 m->insertSeparator(); 943 m->insertSeparator();
939 m->insertItem( tr( "Delete" ), this, SLOT( localDelete() )); 944 m->insertItem( tr( "Delete" ), this, SLOT( localDelete() ));
940 m->setCheckable(TRUE); 945 m->setCheckable(TRUE);
941 if (b) 946 if (b)
942 m->setItemChecked(m->idAt(0),TRUE); 947 m->setItemChecked(m->idAt(0),TRUE);
943 else 948 else
944 m->setItemChecked(m->idAt(0),FALSE); 949 m->setItemChecked(m->idAt(0),FALSE);
945 950
946 m->exec( QCursor::pos() ); 951 m->exec( QCursor::pos() );
947 delete m; 952 delete m;
948} 953}
949 954
950void OpieFtp::localMakDir() 955void OpieFtp::localMakDir()
951{ 956{
952 InputDialog *fileDlg; 957 InputDialog *fileDlg;
953 fileDlg = new InputDialog(this,tr("Make Directory"),TRUE, 0); 958 fileDlg = new InputDialog(this,tr("Make Directory"),TRUE, 0);
954 fileDlg->exec(); 959 fileDlg->exec();
955 if( fileDlg->result() == 1 ) { 960 if( fileDlg->result() == 1 ) {
956 QString filename = fileDlg->LineEdit1->text(); 961 QString filename = fileDlg->LineEdit1->text();
957 currentDir.mkdir( currentDir.canonicalPath()+"/"+filename); 962 currentDir.mkdir( currentDir.canonicalPath()+"/"+filename);
958 } 963 }
959 populateLocalView(); 964 populateLocalView();
960} 965}
961 966
962void OpieFtp::localDelete() 967void OpieFtp::localDelete()
963{ 968{
964 QList<QListViewItem> * getSelectedItems( QListView * Local_View ); 969 QList<QListViewItem> * getSelectedItems( QListView * Local_View );
965 QListViewItemIterator it( Local_View ); 970 QListViewItemIterator it( Local_View );
966 for ( ; it.current(); ++it ) { 971 for ( ; it.current(); ++it ) {
967 if ( it.current()->isSelected() ) { 972 if ( it.current()->isSelected() ) {
968 QString f = it.current()->text(0); 973 QString f = it.current()->text(0);
969 it.current()->setSelected(FALSE); 974 it.current()->setSelected(FALSE);
970 975
971// QString f = Local_View->currentItem()->text(0); 976// QString f = Local_View->currentItem()->text(0);
972 if(QDir(f).exists() ) { 977 if(QDir(f).exists() ) {
973 switch ( QMessageBox::warning(this,tr("Delete"),tr("Do you really want to delete\n")+f+ 978 switch ( QMessageBox::warning(this,tr("Delete"),tr("Do you really want to delete\n")+f+
974 tr(" ?\nIt must be empty"),tr("Yes"),tr("No"),0,0,1) ) { 979 tr(" ?\nIt must be empty"),tr("Yes"),tr("No"),0,0,1) ) {
975 case 0: { 980 case 0: {
976 f=currentDir.canonicalPath()+"/"+f; 981 f=currentDir.canonicalPath()+"/"+f;
977 QString cmd="rmdir "+f; 982 QString cmd="rmdir "+f;
978 system( cmd.latin1()); 983 system( cmd.latin1());
979 } 984 }
980 break; 985 break;
981 case 1: 986 case 1:
982 // exit 987 // exit