author | simon <simon> | 2002-11-08 15:16:56 (UTC) |
---|---|---|
committer | simon <simon> | 2002-11-08 15:16:56 (UTC) |
commit | c2d39953b626147400114dbde85d87bdf5081576 (patch) (unidiff) | |
tree | 137fdab93cbf9786d35a8060d0c1aebdfa552570 | |
parent | 0850f627522ed8765ffd37dfa47dc3c40fd543be (diff) | |
download | opie-c2d39953b626147400114dbde85d87bdf5081576.zip opie-c2d39953b626147400114dbde85d87bdf5081576.tar.gz opie-c2d39953b626147400114dbde85d87bdf5081576.tar.bz2 |
- for ( i; i <= numberOfEntries; i++) {
+ for ( ; i <= numberOfEntries; i++) {
-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 3d97ecb..292cc9d 100644 --- a/noncore/net/opieftp/opieftp.cpp +++ b/noncore/net/opieftp/opieftp.cpp | |||
@@ -871,642 +871,642 @@ void OpieFtp::doLocalCd() | |||
871 | { | 871 | { |
872 | localListClicked( Local_View->currentItem()); | 872 | localListClicked( Local_View->currentItem()); |
873 | } | 873 | } |
874 | 874 | ||
875 | void OpieFtp:: doRemoteCd() | 875 | void OpieFtp:: doRemoteCd() |
876 | { | 876 | { |
877 | remoteListClicked( Remote_View->currentItem()); | 877 | remoteListClicked( Remote_View->currentItem()); |
878 | 878 | ||
879 | } | 879 | } |
880 | 880 | ||
881 | void OpieFtp::showHidden() | 881 | void OpieFtp::showHidden() |
882 | { | 882 | { |
883 | if (!b) { | 883 | if (!b) { |
884 | currentDir.setFilter( QDir::Files | QDir::Dirs | QDir::Hidden | QDir::All); | 884 | currentDir.setFilter( QDir::Files | QDir::Dirs | QDir::Hidden | QDir::All); |
885 | localMenu->setItemChecked(localMenu->idAt(0),TRUE); | 885 | localMenu->setItemChecked(localMenu->idAt(0),TRUE); |
886 | // currentDir.setSorting(/* QDir::Size*/ /*| QDir::Reversed | */QDir::DirsFirst); | 886 | // currentDir.setSorting(/* QDir::Size*/ /*| QDir::Reversed | */QDir::DirsFirst); |
887 | b=TRUE; | 887 | b=TRUE; |
888 | 888 | ||
889 | } else { | 889 | } else { |
890 | currentDir.setFilter( QDir::Files | QDir::Dirs/* | QDir::Hidden*/ | QDir::All); | 890 | currentDir.setFilter( QDir::Files | QDir::Dirs/* | QDir::Hidden*/ | QDir::All); |
891 | localMenu->setItemChecked(localMenu->idAt(0),FALSE); | 891 | localMenu->setItemChecked(localMenu->idAt(0),FALSE); |
892 | // currentDir.setSorting(/* QDir::Size*/ /*| QDir::Reversed | */QDir::DirsFirst); | 892 | // currentDir.setSorting(/* QDir::Size*/ /*| QDir::Reversed | */QDir::DirsFirst); |
893 | b=FALSE; | 893 | b=FALSE; |
894 | } | 894 | } |
895 | populateLocalView(); | 895 | populateLocalView(); |
896 | } | 896 | } |
897 | 897 | ||
898 | void OpieFtp::ListPressed( int mouse, QListViewItem *item, const QPoint &, int) | 898 | void OpieFtp::ListPressed( int mouse, QListViewItem *item, const QPoint &, int) |
899 | { | 899 | { |
900 | // if(item) | 900 | // if(item) |
901 | if (mouse == 2) { | 901 | if (mouse == 2) { |
902 | showLocalMenu(item); | 902 | showLocalMenu(item); |
903 | } | 903 | } |
904 | } | 904 | } |
905 | 905 | ||
906 | void OpieFtp::RemoteListPressed( int mouse, QListViewItem *item, const QPoint &, int ) | 906 | void OpieFtp::RemoteListPressed( int mouse, QListViewItem *item, const QPoint &, int ) |
907 | { | 907 | { |
908 | if(mouse == 2) { | 908 | if(mouse == 2) { |
909 | showRemoteMenu(item); | 909 | showRemoteMenu(item); |
910 | } | 910 | } |
911 | } | 911 | } |
912 | 912 | ||
913 | void OpieFtp::showRemoteMenu(QListViewItem * item) | 913 | void OpieFtp::showRemoteMenu(QListViewItem * item) |
914 | { | 914 | { |
915 | QPopupMenu * m;// = new QPopupMenu( Local_View ); | 915 | QPopupMenu * m;// = new QPopupMenu( Local_View ); |
916 | m = new QPopupMenu(this); | 916 | m = new QPopupMenu(this); |
917 | if( /*item->text(0).right(1) == "/" ||*/ item->text(0).find("/",0,TRUE) != -1) | 917 | if( /*item->text(0).right(1) == "/" ||*/ item->text(0).find("/",0,TRUE) != -1) |
918 | m->insertItem( tr( "Change Directory" ), this, SLOT( doRemoteCd() )); | 918 | m->insertItem( tr( "Change Directory" ), this, SLOT( doRemoteCd() )); |
919 | else | 919 | else |
920 | m->insertItem( tr( "Download" ), this, SLOT( remoteDownload() )); | 920 | m->insertItem( tr( "Download" ), this, SLOT( remoteDownload() )); |
921 | m->insertItem( tr( "Make Directory" ), this, SLOT( remoteMakDir() )); | 921 | m->insertItem( tr( "Make Directory" ), this, SLOT( remoteMakDir() )); |
922 | m->insertItem( tr("Rescan"), this, SLOT( populateLocalView() )); | 922 | m->insertItem( tr("Rescan"), this, SLOT( populateLocalView() )); |
923 | m->insertItem( tr( "Rename" ), this, SLOT( remoteRename() )); | 923 | m->insertItem( tr( "Rename" ), this, SLOT( remoteRename() )); |
924 | m->insertSeparator(); | 924 | m->insertSeparator(); |
925 | m->insertItem( tr( "Delete" ), this, SLOT( remoteDelete() )); | 925 | m->insertItem( tr( "Delete" ), this, SLOT( remoteDelete() )); |
926 | m->exec( QCursor::pos() ); | 926 | m->exec( QCursor::pos() ); |
927 | delete m; | 927 | delete m; |
928 | } | 928 | } |
929 | 929 | ||
930 | void OpieFtp::showLocalMenu(QListViewItem * item) | 930 | void OpieFtp::showLocalMenu(QListViewItem * item) |
931 | { | 931 | { |
932 | 932 | ||
933 | QPopupMenu *m; | 933 | QPopupMenu *m; |
934 | m = new QPopupMenu( this); | 934 | m = new QPopupMenu( this); |
935 | m->insertItem( tr( "Show Hidden Files" ), this, SLOT( showHidden() )); | 935 | m->insertItem( tr( "Show Hidden Files" ), this, SLOT( showHidden() )); |
936 | m->insertSeparator(); | 936 | m->insertSeparator(); |
937 | if( /*item->text(0).right(1) == "/" ||*/ item->text(0).find("/",0,TRUE) !=-1) | 937 | if( /*item->text(0).right(1) == "/" ||*/ item->text(0).find("/",0,TRUE) !=-1) |
938 | m->insertItem( tr( "Change Directory" ), this, SLOT( doLocalCd() )); | 938 | m->insertItem( tr( "Change Directory" ), this, SLOT( doLocalCd() )); |
939 | else | 939 | else |
940 | m->insertItem( tr( "Upload" ), this, SLOT( localUpload() )); | 940 | m->insertItem( tr( "Upload" ), this, SLOT( localUpload() )); |
941 | m->insertItem( tr( "Make Directory" ), this, SLOT( localMakDir() )); | 941 | m->insertItem( tr( "Make Directory" ), this, SLOT( localMakDir() )); |
942 | m->insertItem( tr("Rescan"), this, SLOT( populateRemoteView() )); | 942 | m->insertItem( tr("Rescan"), this, SLOT( populateRemoteView() )); |
943 | m->insertItem( tr( "Rename" ), this, SLOT( localRename() )); | 943 | m->insertItem( tr( "Rename" ), this, SLOT( localRename() )); |
944 | m->insertSeparator(); | 944 | m->insertSeparator(); |
945 | m->insertItem( tr( "Delete" ), this, SLOT( localDelete() )); | 945 | m->insertItem( tr( "Delete" ), this, SLOT( localDelete() )); |
946 | m->setCheckable(TRUE); | 946 | m->setCheckable(TRUE); |
947 | if (b) | 947 | if (b) |
948 | m->setItemChecked(m->idAt(0),TRUE); | 948 | m->setItemChecked(m->idAt(0),TRUE); |
949 | else | 949 | else |
950 | m->setItemChecked(m->idAt(0),FALSE); | 950 | m->setItemChecked(m->idAt(0),FALSE); |
951 | 951 | ||
952 | m->exec( QCursor::pos() ); | 952 | m->exec( QCursor::pos() ); |
953 | delete m; | 953 | delete m; |
954 | } | 954 | } |
955 | 955 | ||
956 | void OpieFtp::localMakDir() | 956 | void OpieFtp::localMakDir() |
957 | { | 957 | { |
958 | InputDialog *fileDlg; | 958 | InputDialog *fileDlg; |
959 | fileDlg = new InputDialog(this,tr("Make Directory"),TRUE, 0); | 959 | fileDlg = new InputDialog(this,tr("Make Directory"),TRUE, 0); |
960 | fileDlg->exec(); | 960 | fileDlg->exec(); |
961 | if( fileDlg->result() == 1 ) { | 961 | if( fileDlg->result() == 1 ) { |
962 | QString filename = fileDlg->LineEdit1->text(); | 962 | QString filename = fileDlg->LineEdit1->text(); |
963 | currentDir.mkdir( currentDir.canonicalPath()+"/"+filename); | 963 | currentDir.mkdir( currentDir.canonicalPath()+"/"+filename); |
964 | } | 964 | } |
965 | populateLocalView(); | 965 | populateLocalView(); |
966 | } | 966 | } |
967 | 967 | ||
968 | void OpieFtp::localDelete() | 968 | void OpieFtp::localDelete() |
969 | { | 969 | { |
970 | QList<QListViewItem> * getSelectedItems( QListView * Local_View ); | 970 | QList<QListViewItem> * getSelectedItems( QListView * Local_View ); |
971 | QListViewItemIterator it( Local_View ); | 971 | QListViewItemIterator it( Local_View ); |
972 | for ( ; it.current(); ++it ) { | 972 | for ( ; it.current(); ++it ) { |
973 | if ( it.current()->isSelected() ) { | 973 | if ( it.current()->isSelected() ) { |
974 | QString f = it.current()->text(0); | 974 | QString f = it.current()->text(0); |
975 | it.current()->setSelected(FALSE); | 975 | it.current()->setSelected(FALSE); |
976 | 976 | ||
977 | // QString f = Local_View->currentItem()->text(0); | 977 | // QString f = Local_View->currentItem()->text(0); |
978 | if(QDir(f).exists() ) { | 978 | if(QDir(f).exists() ) { |
979 | switch ( QMessageBox::warning(this,tr("Delete"),tr("Do you really want to delete\n")+f+ | 979 | switch ( QMessageBox::warning(this,tr("Delete"),tr("Do you really want to delete\n")+f+ |
980 | tr(" ?\nIt must be empty"),tr("Yes"),tr("No"),0,0,1) ) { | 980 | tr(" ?\nIt must be empty"),tr("Yes"),tr("No"),0,0,1) ) { |
981 | case 0: { | 981 | case 0: { |
982 | f=currentDir.canonicalPath()+"/"+f; | 982 | f=currentDir.canonicalPath()+"/"+f; |
983 | QString cmd="rmdir "+f; | 983 | QString cmd="rmdir "+f; |
984 | system( cmd.latin1()); | 984 | system( cmd.latin1()); |
985 | } | 985 | } |
986 | break; | 986 | break; |
987 | case 1: | 987 | case 1: |
988 | // exit | 988 | // exit |
989 | break; | 989 | break; |
990 | }; | 990 | }; |
991 | 991 | ||
992 | } else { | 992 | } else { |
993 | switch ( QMessageBox::warning(this,tr("Delete"),tr("Do you really want to delete\n")+f | 993 | switch ( QMessageBox::warning(this,tr("Delete"),tr("Do you really want to delete\n")+f |
994 | +" ?",tr("Yes"),tr("No"),0,0,1) ) { | 994 | +" ?",tr("Yes"),tr("No"),0,0,1) ) { |
995 | case 0: { | 995 | case 0: { |
996 | f=currentDir.canonicalPath()+"/"+f; | 996 | f=currentDir.canonicalPath()+"/"+f; |
997 | QString cmd="rm "+f; | 997 | QString cmd="rm "+f; |
998 | system( cmd.latin1()); | 998 | system( cmd.latin1()); |
999 | } | 999 | } |
1000 | break; | 1000 | break; |
1001 | case 1: | 1001 | case 1: |
1002 | // exit | 1002 | // exit |
1003 | break; | 1003 | break; |
1004 | }; | 1004 | }; |
1005 | } | 1005 | } |
1006 | } | 1006 | } |
1007 | } | 1007 | } |
1008 | populateLocalView(); | 1008 | populateLocalView(); |
1009 | 1009 | ||
1010 | } | 1010 | } |
1011 | 1011 | ||
1012 | void OpieFtp::remoteMakDir() | 1012 | void OpieFtp::remoteMakDir() |
1013 | { | 1013 | { |
1014 | InputDialog *fileDlg; | 1014 | InputDialog *fileDlg; |
1015 | fileDlg = new InputDialog(this,tr("Make Directory"),TRUE, 0); | 1015 | fileDlg = new InputDialog(this,tr("Make Directory"),TRUE, 0); |
1016 | fileDlg->exec(); | 1016 | fileDlg->exec(); |
1017 | if( fileDlg->result() == 1 ) { | 1017 | if( fileDlg->result() == 1 ) { |
1018 | QString filename = fileDlg->LineEdit1->text();//+".playlist"; | 1018 | QString filename = fileDlg->LineEdit1->text();//+".playlist"; |
1019 | QString tmp=currentRemoteDir+filename; | 1019 | QString tmp=currentRemoteDir+filename; |
1020 | // QCopEnvelope ( "QPE/System", "busy()" ); | 1020 | // QCopEnvelope ( "QPE/System", "busy()" ); |
1021 | if(FtpMkdir( tmp.latin1(), conn) == 0) { | 1021 | if(FtpMkdir( tmp.latin1(), conn) == 0) { |
1022 | QString msg; | 1022 | QString msg; |
1023 | msg.sprintf(tr("Unable to make directory\n")+"%s",FtpLastResponse(conn)); | 1023 | msg.sprintf(tr("Unable to make directory\n")+"%s",FtpLastResponse(conn)); |
1024 | msg.replace(QRegExp(":"),"\n"); | 1024 | msg.replace(QRegExp(":"),"\n"); |
1025 | QMessageBox::message(tr("Note"),msg); | 1025 | QMessageBox::message(tr("Note"),msg); |
1026 | } | 1026 | } |
1027 | // QCopEnvelope ( "QPE/System", "notBusy()" ); | 1027 | // QCopEnvelope ( "QPE/System", "notBusy()" ); |
1028 | remoteDirList( (const QString &)currentRemoteDir); //this also calls populate | 1028 | remoteDirList( (const QString &)currentRemoteDir); //this also calls populate |
1029 | } | 1029 | } |
1030 | } | 1030 | } |
1031 | 1031 | ||
1032 | void OpieFtp::remoteDelete() | 1032 | void OpieFtp::remoteDelete() |
1033 | { | 1033 | { |
1034 | QList<QListViewItem> * getSelectedItems( QListView * Remote_View ); | 1034 | QList<QListViewItem> * getSelectedItems( QListView * Remote_View ); |
1035 | QListViewItemIterator it( Remote_View ); | 1035 | QListViewItemIterator it( Remote_View ); |
1036 | for ( ; it.current(); ++it ) { | 1036 | for ( ; it.current(); ++it ) { |
1037 | if ( it.current()->isSelected() ) { | 1037 | if ( it.current()->isSelected() ) { |
1038 | QString f = it.current()->text(0); | 1038 | QString f = it.current()->text(0); |
1039 | // QString f = Remote_View->currentItem()->text(0); | 1039 | // QString f = Remote_View->currentItem()->text(0); |
1040 | // QCopEnvelope ( "QPE/System", "busy()" ); | 1040 | // QCopEnvelope ( "QPE/System", "busy()" ); |
1041 | if( f.right(1) =="/") { | 1041 | if( f.right(1) =="/") { |
1042 | QString path= currentRemoteDir+f; | 1042 | QString path= currentRemoteDir+f; |
1043 | switch ( QMessageBox::warning(this,tr("Delete"),tr("Do you really want to delete\n")+f+"?" | 1043 | switch ( QMessageBox::warning(this,tr("Delete"),tr("Do you really want to delete\n")+f+"?" |
1044 | ,tr("Yes"),tr("No"),0,0,1) ) { | 1044 | ,tr("Yes"),tr("No"),0,0,1) ) { |
1045 | case 0: { | 1045 | case 0: { |
1046 | f=currentDir.canonicalPath()+"/"+f; | 1046 | f=currentDir.canonicalPath()+"/"+f; |
1047 | if(FtpRmdir( path.latin1(), conn) ==0) { | 1047 | if(FtpRmdir( path.latin1(), conn) ==0) { |
1048 | QString msg; | 1048 | QString msg; |
1049 | msg.sprintf(tr("Unable to remove directory\n")+"%s",FtpLastResponse(conn)); | 1049 | msg.sprintf(tr("Unable to remove directory\n")+"%s",FtpLastResponse(conn)); |
1050 | msg.replace(QRegExp(":"),"\n"); | 1050 | msg.replace(QRegExp(":"),"\n"); |
1051 | QMessageBox::message(tr("Note"),msg); | 1051 | QMessageBox::message(tr("Note"),msg); |
1052 | } | 1052 | } |
1053 | remoteDirList( (const QString &)currentRemoteDir); //this also calls populate | 1053 | remoteDirList( (const QString &)currentRemoteDir); //this also calls populate |
1054 | } | 1054 | } |
1055 | break; | 1055 | break; |
1056 | }; | 1056 | }; |
1057 | } else { | 1057 | } else { |
1058 | switch ( QMessageBox::warning(this,tr("Delete"),tr("Do you really want to delete\n")+f+"?" | 1058 | switch ( QMessageBox::warning(this,tr("Delete"),tr("Do you really want to delete\n")+f+"?" |
1059 | ,tr("Yes"),tr("No"),0,0,1) ) { | 1059 | ,tr("Yes"),tr("No"),0,0,1) ) { |
1060 | case 0: { | 1060 | case 0: { |
1061 | QString path= currentRemoteDir+f; | 1061 | QString path= currentRemoteDir+f; |
1062 | if(FtpDelete( path.latin1(), conn)==0) { | 1062 | if(FtpDelete( path.latin1(), conn)==0) { |
1063 | QString msg; | 1063 | QString msg; |
1064 | msg.sprintf(tr("Unable to delete file\n")+"%s",FtpLastResponse(conn)); | 1064 | msg.sprintf(tr("Unable to delete file\n")+"%s",FtpLastResponse(conn)); |
1065 | msg.replace(QRegExp(":"),"\n"); | 1065 | msg.replace(QRegExp(":"),"\n"); |
1066 | QMessageBox::message(tr("Note"),msg); | 1066 | QMessageBox::message(tr("Note"),msg); |
1067 | } | 1067 | } |
1068 | remoteDirList( (const QString &)currentRemoteDir); //this also calls populate | 1068 | remoteDirList( (const QString &)currentRemoteDir); //this also calls populate |
1069 | } | 1069 | } |
1070 | break; | 1070 | break; |
1071 | }; | 1071 | }; |
1072 | } | 1072 | } |
1073 | } | 1073 | } |
1074 | } | 1074 | } |
1075 | // QCopEnvelope ( "QPE/System", "notBusy()" ); | 1075 | // QCopEnvelope ( "QPE/System", "notBusy()" ); |
1076 | } | 1076 | } |
1077 | 1077 | ||
1078 | void OpieFtp::remoteRename() | 1078 | void OpieFtp::remoteRename() |
1079 | { | 1079 | { |
1080 | QString curFile = Remote_View->currentItem()->text(0); | 1080 | QString curFile = Remote_View->currentItem()->text(0); |
1081 | InputDialog *fileDlg; | 1081 | InputDialog *fileDlg; |
1082 | fileDlg = new InputDialog(this,tr("Rename"),TRUE, 0); | 1082 | fileDlg = new InputDialog(this,tr("Rename"),TRUE, 0); |
1083 | fileDlg->setTextEdit((const QString &)curFile); | 1083 | fileDlg->setTextEdit((const QString &)curFile); |
1084 | fileDlg->exec(); | 1084 | fileDlg->exec(); |
1085 | if( fileDlg->result() == 1 ) { | 1085 | if( fileDlg->result() == 1 ) { |
1086 | QString oldName = currentRemoteDir +"/"+ curFile; | 1086 | QString oldName = currentRemoteDir +"/"+ curFile; |
1087 | QString newName = currentRemoteDir +"/"+ fileDlg->LineEdit1->text();//+".playlist"; | 1087 | QString newName = currentRemoteDir +"/"+ fileDlg->LineEdit1->text();//+".playlist"; |
1088 | // QCopEnvelope ( "QPE/System", "busy()" ); | 1088 | // QCopEnvelope ( "QPE/System", "busy()" ); |
1089 | if(FtpRename( oldName.latin1(), newName.latin1(),conn) == 0) { | 1089 | if(FtpRename( oldName.latin1(), newName.latin1(),conn) == 0) { |
1090 | QString msg; | 1090 | QString msg; |
1091 | msg.sprintf(tr("Unable to rename file\n")+"%s",FtpLastResponse(conn)); | 1091 | msg.sprintf(tr("Unable to rename file\n")+"%s",FtpLastResponse(conn)); |
1092 | msg.replace(QRegExp(":"),"\n"); | 1092 | msg.replace(QRegExp(":"),"\n"); |
1093 | QMessageBox::message(tr("Note"),msg); | 1093 | QMessageBox::message(tr("Note"),msg); |
1094 | } | 1094 | } |
1095 | // QCopEnvelope ( "QPE/System", "notBusy()" ); | 1095 | // QCopEnvelope ( "QPE/System", "notBusy()" ); |
1096 | remoteDirList( (const QString &)currentRemoteDir); //this also calls populate | 1096 | remoteDirList( (const QString &)currentRemoteDir); //this also calls populate |
1097 | } | 1097 | } |
1098 | } | 1098 | } |
1099 | 1099 | ||
1100 | void OpieFtp::localRename() | 1100 | void OpieFtp::localRename() |
1101 | { | 1101 | { |
1102 | QString curFile = Local_View->currentItem()->text(0); | 1102 | QString curFile = Local_View->currentItem()->text(0); |
1103 | InputDialog *fileDlg; | 1103 | InputDialog *fileDlg; |
1104 | fileDlg = new InputDialog(this,tr("Rename"),TRUE, 0); | 1104 | fileDlg = new InputDialog(this,tr("Rename"),TRUE, 0); |
1105 | fileDlg->setTextEdit((const QString &)curFile); | 1105 | fileDlg->setTextEdit((const QString &)curFile); |
1106 | fileDlg->exec(); | 1106 | fileDlg->exec(); |
1107 | if( fileDlg->result() == 1 ) { | 1107 | if( fileDlg->result() == 1 ) { |
1108 | QString oldname = currentDir.canonicalPath() + "/" + curFile; | 1108 | QString oldname = currentDir.canonicalPath() + "/" + curFile; |
1109 | QString newName = currentDir.canonicalPath() + "/" + fileDlg->LineEdit1->text();//+".playlist"; | 1109 | QString newName = currentDir.canonicalPath() + "/" + fileDlg->LineEdit1->text();//+".playlist"; |
1110 | if( rename(oldname.latin1(), newName.latin1())== -1) | 1110 | if( rename(oldname.latin1(), newName.latin1())== -1) |
1111 | QMessageBox::message(tr("Note"),tr("Could not rename")); | 1111 | QMessageBox::message(tr("Note"),tr("Could not rename")); |
1112 | } | 1112 | } |
1113 | populateLocalView(); | 1113 | populateLocalView(); |
1114 | } | 1114 | } |
1115 | 1115 | ||
1116 | void OpieFtp::currentPathComboActivated(const QString & currentPath) { | 1116 | void OpieFtp::currentPathComboActivated(const QString & currentPath) { |
1117 | if (TabWidget->currentPageIndex() == 0) { | 1117 | if (TabWidget->currentPageIndex() == 0) { |
1118 | chdir( currentPath.latin1() ); | 1118 | chdir( currentPath.latin1() ); |
1119 | currentDir.cd( currentPath, TRUE); | 1119 | currentDir.cd( currentPath, TRUE); |
1120 | populateLocalView(); | 1120 | populateLocalView(); |
1121 | update(); | 1121 | update(); |
1122 | } else { | 1122 | } else { |
1123 | // chdir( currentPath.latin1() ); | 1123 | // chdir( currentPath.latin1() ); |
1124 | // currentDir.cd( currentPath, TRUE); | 1124 | // currentDir.cd( currentPath, TRUE); |
1125 | // populateList(); | 1125 | // populateList(); |
1126 | // update(); | 1126 | // update(); |
1127 | 1127 | ||
1128 | } | 1128 | } |
1129 | } | 1129 | } |
1130 | 1130 | ||
1131 | void OpieFtp::fillCombo(const QString ¤tPath) { | 1131 | void OpieFtp::fillCombo(const QString ¤tPath) { |
1132 | 1132 | ||
1133 | currentPathCombo->lineEdit()->setText(currentPath); | 1133 | currentPathCombo->lineEdit()->setText(currentPath); |
1134 | if( localDirPathStringList.grep(currentPath,TRUE).isEmpty() ) { | 1134 | if( localDirPathStringList.grep(currentPath,TRUE).isEmpty() ) { |
1135 | currentPathCombo->clear(); | 1135 | currentPathCombo->clear(); |
1136 | localDirPathStringList.prepend(currentPath ); | 1136 | localDirPathStringList.prepend(currentPath ); |
1137 | currentPathCombo->insertStringList( localDirPathStringList,-1); | 1137 | currentPathCombo->insertStringList( localDirPathStringList,-1); |
1138 | } | 1138 | } |
1139 | currentPathCombo->lineEdit()->setText(currentPath); | 1139 | currentPathCombo->lineEdit()->setText(currentPath); |
1140 | if( remoteDirPathStringList.grep(currentPath,TRUE).isEmpty() ) { | 1140 | if( remoteDirPathStringList.grep(currentPath,TRUE).isEmpty() ) { |
1141 | currentPathCombo->clear(); | 1141 | currentPathCombo->clear(); |
1142 | remoteDirPathStringList.prepend(currentPath ); | 1142 | remoteDirPathStringList.prepend(currentPath ); |
1143 | currentPathCombo->insertStringList( remoteDirPathStringList,-1); | 1143 | currentPathCombo->insertStringList( remoteDirPathStringList,-1); |
1144 | } | 1144 | } |
1145 | } | 1145 | } |
1146 | 1146 | ||
1147 | void OpieFtp::fillRemoteCombo(const QString ¤tPath) { | 1147 | void OpieFtp::fillRemoteCombo(const QString ¤tPath) { |
1148 | 1148 | ||
1149 | currentPathCombo->lineEdit()->setText(currentPath); | 1149 | currentPathCombo->lineEdit()->setText(currentPath); |
1150 | if( remoteDirPathStringList.grep(currentPath,TRUE).isEmpty() ) { | 1150 | if( remoteDirPathStringList.grep(currentPath,TRUE).isEmpty() ) { |
1151 | currentPathCombo->clear(); | 1151 | currentPathCombo->clear(); |
1152 | remoteDirPathStringList.prepend(currentPath ); | 1152 | remoteDirPathStringList.prepend(currentPath ); |
1153 | currentPathCombo->insertStringList( remoteDirPathStringList,-1); | 1153 | currentPathCombo->insertStringList( remoteDirPathStringList,-1); |
1154 | } | 1154 | } |
1155 | } | 1155 | } |
1156 | 1156 | ||
1157 | void OpieFtp::currentPathComboChanged() | 1157 | void OpieFtp::currentPathComboChanged() |
1158 | { | 1158 | { |
1159 | QString oldRemoteCurrentDir = currentRemoteDir; | 1159 | QString oldRemoteCurrentDir = currentRemoteDir; |
1160 | // qDebug("oldRemoteCurrentDir "+oldRemoteCurrentDir); | 1160 | // qDebug("oldRemoteCurrentDir "+oldRemoteCurrentDir); |
1161 | if (TabWidget->currentPageIndex() == 0) { | 1161 | if (TabWidget->currentPageIndex() == 0) { |
1162 | if(QDir( currentPathCombo->lineEdit()->text()).exists()) { | 1162 | if(QDir( currentPathCombo->lineEdit()->text()).exists()) { |
1163 | currentDir.setPath( currentPathCombo->lineEdit()->text() ); | 1163 | currentDir.setPath( currentPathCombo->lineEdit()->text() ); |
1164 | populateLocalView(); | 1164 | populateLocalView(); |
1165 | } else { | 1165 | } else { |
1166 | QMessageBox::message(tr("Note"),tr("That directory does not exist")); | 1166 | QMessageBox::message(tr("Note"),tr("That directory does not exist")); |
1167 | } | 1167 | } |
1168 | } | 1168 | } |
1169 | if (TabWidget->currentPageIndex() == 1) { | 1169 | if (TabWidget->currentPageIndex() == 1) { |
1170 | currentRemoteDir = currentPathCombo->lineEdit()->text(); | 1170 | currentRemoteDir = currentPathCombo->lineEdit()->text(); |
1171 | if(currentRemoteDir.right(1) !="/") { | 1171 | if(currentRemoteDir.right(1) !="/") { |
1172 | currentRemoteDir = currentRemoteDir +"/"; | 1172 | currentRemoteDir = currentRemoteDir +"/"; |
1173 | currentPathCombo->lineEdit()->setText( currentRemoteDir ); | 1173 | currentPathCombo->lineEdit()->setText( currentRemoteDir ); |
1174 | } | 1174 | } |
1175 | if( !remoteChDir( (const QString &)currentRemoteDir) ) { | 1175 | if( !remoteChDir( (const QString &)currentRemoteDir) ) { |
1176 | currentRemoteDir = oldRemoteCurrentDir; | 1176 | currentRemoteDir = oldRemoteCurrentDir; |
1177 | currentPathCombo->lineEdit()->setText( currentRemoteDir ); | 1177 | currentPathCombo->lineEdit()->setText( currentRemoteDir ); |
1178 | } | 1178 | } |
1179 | 1179 | ||
1180 | remoteDirList( (const QString &)currentRemoteDir); | 1180 | remoteDirList( (const QString &)currentRemoteDir); |
1181 | } | 1181 | } |
1182 | } | 1182 | } |
1183 | 1183 | ||
1184 | void OpieFtp::switchToLocalTab() | 1184 | void OpieFtp::switchToLocalTab() |
1185 | { | 1185 | { |
1186 | TabWidget->setCurrentPage(0); | 1186 | TabWidget->setCurrentPage(0); |
1187 | } | 1187 | } |
1188 | 1188 | ||
1189 | void OpieFtp::switchToRemoteTab() | 1189 | void OpieFtp::switchToRemoteTab() |
1190 | { | 1190 | { |
1191 | TabWidget->setCurrentPage(1); | 1191 | TabWidget->setCurrentPage(1); |
1192 | } | 1192 | } |
1193 | 1193 | ||
1194 | void OpieFtp::switchToConfigTab() | 1194 | void OpieFtp::switchToConfigTab() |
1195 | { | 1195 | { |
1196 | TabWidget->setCurrentPage(2); | 1196 | TabWidget->setCurrentPage(2); |
1197 | } | 1197 | } |
1198 | 1198 | ||
1199 | void OpieFtp::readConfig() | 1199 | void OpieFtp::readConfig() |
1200 | { | 1200 | { |
1201 | fillCombos(); | 1201 | fillCombos(); |
1202 | Config cfg("opieftp"); | 1202 | Config cfg("opieftp"); |
1203 | cfg.setGroup("Server"); | 1203 | cfg.setGroup("Server"); |
1204 | currentServerConfig = cfg.readNumEntry("currentServer", -1); | 1204 | currentServerConfig = cfg.readNumEntry("currentServer", -1); |
1205 | 1205 | ||
1206 | // qDebug("Reading %d", currentServerConfig); | 1206 | // qDebug("Reading %d", currentServerConfig); |
1207 | serverComboSelected( currentServerConfig-1); | 1207 | serverComboSelected( currentServerConfig-1); |
1208 | 1208 | ||
1209 | } | 1209 | } |
1210 | 1210 | ||
1211 | void OpieFtp::writeConfig() | 1211 | void OpieFtp::writeConfig() |
1212 | { | 1212 | { |
1213 | qDebug("write config"); | 1213 | qDebug("write config"); |
1214 | Config cfg("opieftp"); | 1214 | Config cfg("opieftp"); |
1215 | cfg.setGroup("Server"); | 1215 | cfg.setGroup("Server"); |
1216 | 1216 | ||
1217 | QString username, remoteServerStr, remotePathStr, password, port, temp; | 1217 | QString username, remoteServerStr, remotePathStr, password, port, temp; |
1218 | 1218 | ||
1219 | int numberOfEntries = cfg.readNumEntry("numberOfEntries",0); | 1219 | int numberOfEntries = cfg.readNumEntry("numberOfEntries",0); |
1220 | 1220 | ||
1221 | if( currentServerConfig == -1) { | 1221 | if( currentServerConfig == -1) { |
1222 | 1222 | ||
1223 | for (int i = 1; i <= numberOfEntries; i++) { | 1223 | for (int i = 1; i <= numberOfEntries; i++) { |
1224 | temp.setNum(i); | 1224 | temp.setNum(i); |
1225 | cfg.setGroup("Server"); | 1225 | cfg.setGroup("Server"); |
1226 | QString tempStr = cfg.readEntry( temp,""); | 1226 | QString tempStr = cfg.readEntry( temp,""); |
1227 | } | 1227 | } |
1228 | 1228 | ||
1229 | temp.setNum( numberOfEntries + 1); | 1229 | temp.setNum( numberOfEntries + 1); |
1230 | cfg.setGroup("Server"); | 1230 | cfg.setGroup("Server"); |
1231 | 1231 | ||
1232 | remoteServerStr = cfg.readEntry( temp,""); | 1232 | remoteServerStr = cfg.readEntry( temp,""); |
1233 | 1233 | ||
1234 | int divider = remoteServerStr.length() - remoteServerStr.find(":",0,TRUE); | 1234 | int divider = remoteServerStr.length() - remoteServerStr.find(":",0,TRUE); |
1235 | remoteServerStr = remoteServerStr.left(remoteServerStr.length()-divider); | 1235 | remoteServerStr = remoteServerStr.left(remoteServerStr.length()-divider); |
1236 | 1236 | ||
1237 | temp.setNum(numberOfEntries+1); | 1237 | temp.setNum(numberOfEntries+1); |
1238 | cfg.setGroup("Server"); | 1238 | cfg.setGroup("Server"); |
1239 | 1239 | ||
1240 | cfg.writeEntry( temp, ServerComboBox->currentText() +":"+PortSpinBox->cleanText() ); | 1240 | cfg.writeEntry( temp, ServerComboBox->currentText() +":"+PortSpinBox->cleanText() ); |
1241 | cfg.writeEntry("currentServer", numberOfEntries+1); | 1241 | cfg.writeEntry("currentServer", numberOfEntries+1); |
1242 | 1242 | ||
1243 | currentServerConfig = numberOfEntries+1; | 1243 | currentServerConfig = numberOfEntries+1; |
1244 | qDebug("setting currentserverconfig to %d", currentServerConfig); | 1244 | qDebug("setting currentserverconfig to %d", currentServerConfig); |
1245 | 1245 | ||
1246 | cfg.setGroup(temp); | 1246 | cfg.setGroup(temp); |
1247 | if(!newServerName.isEmpty()) | 1247 | if(!newServerName.isEmpty()) |
1248 | cfg.writeEntry("ServerName", newServerName); | 1248 | cfg.writeEntry("ServerName", newServerName); |
1249 | 1249 | ||
1250 | cfg.writeEntry("RemotePath", remotePath->text()); | 1250 | cfg.writeEntry("RemotePath", remotePath->text()); |
1251 | 1251 | ||
1252 | cfg.writeEntry("Username", UsernameComboBox->currentText()); | 1252 | cfg.writeEntry("Username", UsernameComboBox->currentText()); |
1253 | 1253 | ||
1254 | cfg.writeEntryCrypt( UsernameComboBox->currentText(), PasswordEdit->text()); | 1254 | cfg.writeEntryCrypt( UsernameComboBox->currentText(), PasswordEdit->text()); |
1255 | cfg.setGroup("Server"); | 1255 | cfg.setGroup("Server"); |
1256 | 1256 | ||
1257 | cfg.writeEntry("numberOfEntries", QString::number(numberOfEntries + 1 )); | 1257 | cfg.writeEntry("numberOfEntries", QString::number(numberOfEntries + 1 )); |
1258 | 1258 | ||
1259 | } | 1259 | } |
1260 | } | 1260 | } |
1261 | 1261 | ||
1262 | void OpieFtp::clearCombos() { | 1262 | void OpieFtp::clearCombos() { |
1263 | qDebug("clearing"); | 1263 | qDebug("clearing"); |
1264 | ServerComboBox->clear(); | 1264 | ServerComboBox->clear(); |
1265 | UsernameComboBox->clear(); | 1265 | UsernameComboBox->clear(); |
1266 | PasswordEdit->clear(); | 1266 | PasswordEdit->clear(); |
1267 | serverListView->clear(); | 1267 | serverListView->clear(); |
1268 | } | 1268 | } |
1269 | 1269 | ||
1270 | 1270 | ||
1271 | void OpieFtp::fillCombos() | 1271 | void OpieFtp::fillCombos() |
1272 | { | 1272 | { |
1273 | clearCombos(); | 1273 | clearCombos(); |
1274 | 1274 | ||
1275 | Config cfg("opieftp"); | 1275 | Config cfg("opieftp"); |
1276 | cfg.setGroup("Server"); | 1276 | cfg.setGroup("Server"); |
1277 | QString username, remoteServerStr, remotePathStr, password, port, temp; | 1277 | QString username, remoteServerStr, remotePathStr, password, port, temp; |
1278 | int numberOfEntries = cfg.readNumEntry("numberOfEntries",0); | 1278 | int numberOfEntries = cfg.readNumEntry("numberOfEntries",0); |
1279 | 1279 | ||
1280 | for (int i = 1; i <= numberOfEntries; i++) { | 1280 | for (int i = 1; i <= numberOfEntries; i++) { |
1281 | temp.setNum(i); | 1281 | temp.setNum(i); |
1282 | qDebug(temp); | 1282 | qDebug(temp); |
1283 | cfg.setGroup("Server"); | 1283 | cfg.setGroup("Server"); |
1284 | remoteServerStr = cfg.readEntry( temp,""); | 1284 | remoteServerStr = cfg.readEntry( temp,""); |
1285 | qDebug( remoteServerStr); | 1285 | qDebug( remoteServerStr); |
1286 | 1286 | ||
1287 | int divider = remoteServerStr.length() - remoteServerStr.find(":",0,TRUE); | 1287 | int divider = remoteServerStr.length() - remoteServerStr.find(":",0,TRUE); |
1288 | port = remoteServerStr.right( divider - 1); | 1288 | port = remoteServerStr.right( divider - 1); |
1289 | bool ok; | 1289 | bool ok; |
1290 | PortSpinBox->setValue( port.toInt(&ok,10)); | 1290 | PortSpinBox->setValue( port.toInt(&ok,10)); |
1291 | 1291 | ||
1292 | remoteServerStr = remoteServerStr.left(remoteServerStr.length()-divider); | 1292 | remoteServerStr = remoteServerStr.left(remoteServerStr.length()-divider); |
1293 | qDebug( "remote server string "+remoteServerStr); | 1293 | qDebug( "remote server string "+remoteServerStr); |
1294 | ServerComboBox->insertItem( remoteServerStr ); | 1294 | ServerComboBox->insertItem( remoteServerStr ); |
1295 | 1295 | ||
1296 | cfg.setGroup(temp); | 1296 | cfg.setGroup(temp); |
1297 | 1297 | ||
1298 | username = cfg.readEntry(temp); | 1298 | username = cfg.readEntry(temp); |
1299 | UsernameComboBox->insertItem(username); | 1299 | UsernameComboBox->insertItem(username); |
1300 | password = cfg.readEntryCrypt(username,""); | 1300 | password = cfg.readEntryCrypt(username,""); |
1301 | PasswordEdit->setText(password); | 1301 | PasswordEdit->setText(password); |
1302 | 1302 | ||
1303 | serverListView->insertItem( cfg.readEntry("ServerName")); | 1303 | serverListView->insertItem( cfg.readEntry("ServerName")); |
1304 | } | 1304 | } |
1305 | } | 1305 | } |
1306 | 1306 | ||
1307 | 1307 | ||
1308 | void OpieFtp::serverComboSelected(int index) | 1308 | void OpieFtp::serverComboSelected(int index) |
1309 | { | 1309 | { |
1310 | currentServerConfig = index+1; | 1310 | currentServerConfig = index+1; |
1311 | qDebug("server combo selected %d", index+1); | 1311 | qDebug("server combo selected %d", index+1); |
1312 | QString username, remoteServerStr, remotePathStr, password, port, temp; | 1312 | QString username, remoteServerStr, remotePathStr, password, port, temp; |
1313 | // remoteServerStr = ServerComboBox->text(index); | 1313 | // remoteServerStr = ServerComboBox->text(index); |
1314 | 1314 | ||
1315 | Config cfg("opieftp"); | 1315 | Config cfg("opieftp"); |
1316 | cfg.setGroup("Server"); | 1316 | cfg.setGroup("Server"); |
1317 | // int numberOfEntries = cfg.readNumEntry("numberOfEntries",0); | 1317 | // int numberOfEntries = cfg.readNumEntry("numberOfEntries",0); |
1318 | 1318 | ||
1319 | temp.setNum(index+1); | 1319 | temp.setNum(index+1); |
1320 | remoteServerStr = cfg.readEntry( temp,""); | 1320 | remoteServerStr = cfg.readEntry( temp,""); |
1321 | 1321 | ||
1322 | qDebug("Group" +temp); | 1322 | qDebug("Group" +temp); |
1323 | cfg.setGroup(temp); | 1323 | cfg.setGroup(temp); |
1324 | // qDebug(temp); | 1324 | // qDebug(temp); |
1325 | int divider = remoteServerStr.length() - remoteServerStr.find(":",0,TRUE); | 1325 | int divider = remoteServerStr.length() - remoteServerStr.find(":",0,TRUE); |
1326 | port = remoteServerStr.right( divider - 1); | 1326 | port = remoteServerStr.right( divider - 1); |
1327 | bool ok; | 1327 | bool ok; |
1328 | int portInt = port.toInt(&ok,10); | 1328 | int portInt = port.toInt(&ok,10); |
1329 | if( portInt == 0) portInt = 21; | 1329 | if( portInt == 0) portInt = 21; |
1330 | 1330 | ||
1331 | ServerComboBox->lineEdit()->setText(remoteServerStr.left( remoteServerStr.find(":",0,TRUE))); | 1331 | ServerComboBox->lineEdit()->setText(remoteServerStr.left( remoteServerStr.find(":",0,TRUE))); |
1332 | 1332 | ||
1333 | PortSpinBox->setValue( portInt); | 1333 | PortSpinBox->setValue( portInt); |
1334 | 1334 | ||
1335 | remotePath->setText(cfg.readEntry("RemotePath", "/")); | 1335 | remotePath->setText(cfg.readEntry("RemotePath", "/")); |
1336 | 1336 | ||
1337 | username = cfg.readEntry("Username", "anonymous"); | 1337 | username = cfg.readEntry("Username", "anonymous"); |
1338 | UsernameComboBox->lineEdit()->setText(username); | 1338 | UsernameComboBox->lineEdit()->setText(username); |
1339 | qDebug(username); | 1339 | qDebug(username); |
1340 | // qDebug("Password is "+cfg.readEntryCrypt(username, "me@opieftp.org")); | 1340 | // qDebug("Password is "+cfg.readEntryCrypt(username, "me@opieftp.org")); |
1341 | PasswordEdit->setText(cfg.readEntryCrypt(username, "me@opieftp.org")); | 1341 | PasswordEdit->setText(cfg.readEntryCrypt(username, "me@opieftp.org")); |
1342 | // UsernameComboBox | 1342 | // UsernameComboBox |
1343 | // PasswordEdit | 1343 | // PasswordEdit |
1344 | 1344 | ||
1345 | cfg.setGroup("Server"); | 1345 | cfg.setGroup("Server"); |
1346 | temp.sprintf("%d",currentServerConfig); | 1346 | temp.sprintf("%d",currentServerConfig); |
1347 | cfg.writeEntry("currentServer", temp); | 1347 | cfg.writeEntry("currentServer", temp); |
1348 | 1348 | ||
1349 | fuckeduphack = TRUE; | 1349 | fuckeduphack = TRUE; |
1350 | serverListView->setCurrentItem( index); | 1350 | serverListView->setCurrentItem( index); |
1351 | fuckeduphack=FALSE; | 1351 | fuckeduphack=FALSE; |
1352 | qDebug("server list set selected %d",index); | 1352 | qDebug("server list set selected %d",index); |
1353 | update(); | 1353 | update(); |
1354 | } | 1354 | } |
1355 | 1355 | ||
1356 | void OpieFtp::deleteServer() | 1356 | void OpieFtp::deleteServer() |
1357 | { | 1357 | { |
1358 | QString username, remoteServerStr, remotePathStr, password, port, temp, servername; | 1358 | QString username, remoteServerStr, remotePathStr, password, port, temp, servername; |
1359 | remoteServerStr = ServerComboBox->currentText( ); | 1359 | remoteServerStr = ServerComboBox->currentText( ); |
1360 | username = UsernameComboBox->currentText(); | 1360 | username = UsernameComboBox->currentText(); |
1361 | servername=serverListView->currentText(); | 1361 | servername=serverListView->currentText(); |
1362 | 1362 | ||
1363 | Config cfg("opieftp"); | 1363 | Config cfg("opieftp"); |
1364 | cfg.setGroup("Server"); | 1364 | cfg.setGroup("Server"); |
1365 | QString tempname; | 1365 | QString tempname; |
1366 | int numberOfEntries = cfg.readNumEntry("numberOfEntries",0); | 1366 | int numberOfEntries = cfg.readNumEntry("numberOfEntries",0); |
1367 | 1367 | ||
1368 | for (int i = 1; i <= numberOfEntries; i++) { | 1368 | for (int i = 1; i <= numberOfEntries; i++) { |
1369 | temp.setNum(i); | 1369 | temp.setNum(i); |
1370 | // cfg.setGroup("Server"); | 1370 | // cfg.setGroup("Server"); |
1371 | cfg.setGroup(QString::number(i)); | 1371 | cfg.setGroup(QString::number(i)); |
1372 | tempname=cfg.readEntry( "ServerName",""); | 1372 | tempname=cfg.readEntry( "ServerName",""); |
1373 | 1373 | ||
1374 | if( tempname.find( servername,0,TRUE) != -1 ) { | 1374 | if( tempname.find( servername,0,TRUE) != -1 ) { |
1375 | // servername.find( cfg.readEntry("ServerName")) != -1 && | 1375 | // servername.find( cfg.readEntry("ServerName")) != -1 && |
1376 | // remoteServerStr.find( cfg.readEntry("RemotePath")) != -1 && | 1376 | // remoteServerStr.find( cfg.readEntry("RemotePath")) != -1 && |
1377 | // username.find( cfg.readEntry("Username")) != -1) { | 1377 | // username.find( cfg.readEntry("Username")) != -1) { |
1378 | 1378 | ||
1379 | serverListView->removeItem(i); | 1379 | serverListView->removeItem(i); |
1380 | 1380 | ||
1381 | qDebug("OK DELETE "+tempname); | 1381 | qDebug("OK DELETE "+tempname); |
1382 | cfg.removeEntry(QString::number(i)); | 1382 | cfg.removeEntry(QString::number(i)); |
1383 | for ( i; i <= numberOfEntries; i++) { | 1383 | for ( ; i <= numberOfEntries; i++) { |
1384 | cfg.setGroup("Server"); | 1384 | cfg.setGroup("Server"); |
1385 | cfg.writeEntry("Server", QString::number(numberOfEntries + 1 )); | 1385 | cfg.writeEntry("Server", QString::number(numberOfEntries + 1 )); |
1386 | 1386 | ||
1387 | cfg.setGroup(QString::number(i+1)); //get next server config | 1387 | cfg.setGroup(QString::number(i+1)); //get next server config |
1388 | servername=cfg.readEntry("ServerName"); | 1388 | servername=cfg.readEntry("ServerName"); |
1389 | remoteServerStr=cfg.readEntry("RemotePath"); | 1389 | remoteServerStr=cfg.readEntry("RemotePath"); |
1390 | username=cfg.readEntry("Username"); | 1390 | username=cfg.readEntry("Username"); |
1391 | password=cfg.readEntryCrypt( username); | 1391 | password=cfg.readEntryCrypt( username); |
1392 | 1392 | ||
1393 | cfg.setGroup(QString::number(i)); | 1393 | cfg.setGroup(QString::number(i)); |
1394 | 1394 | ||
1395 | cfg.writeEntry("RemotePath", remoteServerStr); | 1395 | cfg.writeEntry("RemotePath", remoteServerStr); |
1396 | cfg.writeEntry("ServerName", servername); | 1396 | cfg.writeEntry("ServerName", servername); |
1397 | cfg.writeEntry("Username", username); | 1397 | cfg.writeEntry("Username", username); |
1398 | cfg.writeEntryCrypt( username, password); | 1398 | cfg.writeEntryCrypt( username, password); |
1399 | 1399 | ||
1400 | } | 1400 | } |
1401 | cfg.setGroup("Server"); | 1401 | cfg.setGroup("Server"); |
1402 | cfg.writeEntry("numberOfEntries", QString::number(numberOfEntries - 1 )); | 1402 | cfg.writeEntry("numberOfEntries", QString::number(numberOfEntries - 1 )); |
1403 | } | 1403 | } |
1404 | } | 1404 | } |
1405 | cfg.setGroup(QString::number(numberOfEntries)); | 1405 | cfg.setGroup(QString::number(numberOfEntries)); |
1406 | cfg.removeEntry("Server"); | 1406 | cfg.removeEntry("Server"); |
1407 | cfg.removeEntry("RemotePath"); | 1407 | cfg.removeEntry("RemotePath"); |
1408 | cfg.removeEntry("ServerName"); | 1408 | cfg.removeEntry("ServerName"); |
1409 | username=cfg.readEntry("Username"); | 1409 | username=cfg.readEntry("Username"); |
1410 | cfg.removeEntry("Username"); | 1410 | cfg.removeEntry("Username"); |
1411 | cfg.removeEntry(username); | 1411 | cfg.removeEntry(username); |
1412 | 1412 | ||
1413 | currentServerConfig=currentServerConfig-1; | 1413 | currentServerConfig=currentServerConfig-1; |
1414 | 1414 | ||
1415 | fillCombos(); | 1415 | fillCombos(); |
1416 | update(); | 1416 | update(); |
1417 | } | 1417 | } |
1418 | 1418 | ||
1419 | void OpieFtp::upDir() | 1419 | void OpieFtp::upDir() |
1420 | { | 1420 | { |
1421 | if (TabWidget->currentPageIndex() == 0) { | 1421 | if (TabWidget->currentPageIndex() == 0) { |
1422 | QString current = currentDir.canonicalPath(); | 1422 | QString current = currentDir.canonicalPath(); |
1423 | QDir dir(current); | 1423 | QDir dir(current); |
1424 | dir.cdUp(); | 1424 | dir.cdUp(); |
1425 | current = dir.canonicalPath(); | 1425 | current = dir.canonicalPath(); |
1426 | chdir( current.latin1() ); | 1426 | chdir( current.latin1() ); |
1427 | currentDir.cd( current, TRUE); | 1427 | currentDir.cd( current, TRUE); |
1428 | populateLocalView(); | 1428 | populateLocalView(); |
1429 | update(); | 1429 | update(); |
1430 | } else { | 1430 | } else { |
1431 | if( FtpCDUp( conn) == 0) { | 1431 | if( FtpCDUp( conn) == 0) { |
1432 | QString msg; | 1432 | QString msg; |
1433 | msg.sprintf(tr("Unable to cd up\n")+"%s",FtpLastResponse(conn)); | 1433 | msg.sprintf(tr("Unable to cd up\n")+"%s",FtpLastResponse(conn)); |
1434 | msg.replace(QRegExp(":"),"\n"); | 1434 | msg.replace(QRegExp(":"),"\n"); |
1435 | QMessageBox::message(tr("Note"),msg); | 1435 | QMessageBox::message(tr("Note"),msg); |
1436 | // qDebug(msg); | 1436 | // qDebug(msg); |
1437 | } | 1437 | } |
1438 | char path[256]; | 1438 | char path[256]; |
1439 | if( FtpPwd( path,sizeof(path),conn) == 0) { //this is easier than fudging the string | 1439 | if( FtpPwd( path,sizeof(path),conn) == 0) { //this is easier than fudging the string |
1440 | QString msg; | 1440 | QString msg; |
1441 | msg.sprintf(tr("Unable to get working dir\n")+"%s",FtpLastResponse(conn)); | 1441 | msg.sprintf(tr("Unable to get working dir\n")+"%s",FtpLastResponse(conn)); |
1442 | msg.replace(QRegExp(":"),"\n"); | 1442 | msg.replace(QRegExp(":"),"\n"); |
1443 | QMessageBox::message(tr("Note"),msg); | 1443 | QMessageBox::message(tr("Note"),msg); |
1444 | // qDebug(msg); | 1444 | // qDebug(msg); |
1445 | } | 1445 | } |
1446 | currentRemoteDir=path; | 1446 | currentRemoteDir=path; |
1447 | remoteDirList( (const QString &)currentRemoteDir); //this also calls populate | 1447 | remoteDirList( (const QString &)currentRemoteDir); //this also calls populate |
1448 | if(currentRemoteDir.right(1) !="/") | 1448 | if(currentRemoteDir.right(1) !="/") |
1449 | currentRemoteDir +="/"; | 1449 | currentRemoteDir +="/"; |
1450 | currentPathCombo->lineEdit()->setText( currentRemoteDir); | 1450 | currentPathCombo->lineEdit()->setText( currentRemoteDir); |
1451 | fillRemoteCombo( (const QString &)currentRemoteDir); | 1451 | fillRemoteCombo( (const QString &)currentRemoteDir); |
1452 | 1452 | ||
1453 | } | 1453 | } |
1454 | } | 1454 | } |
1455 | 1455 | ||
1456 | void OpieFtp::docButtonPushed() { | 1456 | void OpieFtp::docButtonPushed() { |
1457 | QString current = QPEApplication::documentDir(); | 1457 | QString current = QPEApplication::documentDir(); |
1458 | chdir( current.latin1() ); | 1458 | chdir( current.latin1() ); |
1459 | currentDir.cd( current, TRUE); | 1459 | currentDir.cd( current, TRUE); |
1460 | populateLocalView(); | 1460 | populateLocalView(); |
1461 | update(); | 1461 | update(); |
1462 | 1462 | ||
1463 | } | 1463 | } |
1464 | 1464 | ||
1465 | void OpieFtp::homeButtonPushed() { | 1465 | void OpieFtp::homeButtonPushed() { |
1466 | QString current = QDir::homeDirPath(); | 1466 | QString current = QDir::homeDirPath(); |
1467 | chdir( current.latin1() ); | 1467 | chdir( current.latin1() ); |
1468 | currentDir.cd( current, TRUE); | 1468 | currentDir.cd( current, TRUE); |
1469 | populateLocalView(); | 1469 | populateLocalView(); |
1470 | update(); | 1470 | update(); |
1471 | } | 1471 | } |
1472 | 1472 | ||
1473 | void OpieFtp::doAbout() { | 1473 | void OpieFtp::doAbout() { |
1474 | QMessageBox::message("OpieFtp","Opie ftp client is copyright 2002 by\n" | 1474 | QMessageBox::message("OpieFtp","Opie ftp client is copyright 2002 by\n" |
1475 | "L.J.Potter<llornkcor@handhelds.org>\n" | 1475 | "L.J.Potter<llornkcor@handhelds.org>\n" |
1476 | "and uses ftplib copyright 1996-2000\n" | 1476 | "and uses ftplib copyright 1996-2000\n" |
1477 | "by Thomas Pfau, pfau@cnj.digex.net\n\n" | 1477 | "by Thomas Pfau, pfau@cnj.digex.net\n\n" |
1478 | "and is licensed by the GPL"); | 1478 | "and is licensed by the GPL"); |
1479 | } | 1479 | } |
1480 | 1480 | ||
1481 | void OpieFtp::NewServer() { | 1481 | void OpieFtp::NewServer() { |
1482 | InputDialog *fileDlg; | 1482 | InputDialog *fileDlg; |
1483 | fileDlg = new InputDialog(this,tr("New Server name"),TRUE, 0); | 1483 | fileDlg = new InputDialog(this,tr("New Server name"),TRUE, 0); |
1484 | fileDlg->exec(); | 1484 | fileDlg->exec(); |
1485 | Config cfg("opieftp"); | 1485 | Config cfg("opieftp"); |
1486 | if( fileDlg->result() == 1 ) { | 1486 | if( fileDlg->result() == 1 ) { |
1487 | newServerName = fileDlg->LineEdit1->text(); | 1487 | newServerName = fileDlg->LineEdit1->text(); |
1488 | for(int i=1;i<serverListView->count();i++) { | 1488 | for(int i=1;i<serverListView->count();i++) { |
1489 | cfg.setGroup( QString::number(i)); | 1489 | cfg.setGroup( QString::number(i)); |
1490 | if(cfg.readEntry("ServerName").find(newServerName,0,TRUE) != -1) { | 1490 | if(cfg.readEntry("ServerName").find(newServerName,0,TRUE) != -1) { |
1491 | QMessageBox::message(tr("OpieFtp"),tr("Sorry name already taken")); | 1491 | QMessageBox::message(tr("OpieFtp"),tr("Sorry name already taken")); |
1492 | return; | 1492 | return; |
1493 | } | 1493 | } |
1494 | } | 1494 | } |
1495 | currentServerConfig =-1; | 1495 | currentServerConfig =-1; |
1496 | writeConfig(); | 1496 | writeConfig(); |
1497 | serverListView->insertItem( newServerName ); | 1497 | serverListView->insertItem( newServerName ); |
1498 | serverListView->setCurrentItem( serverListView->count()); | 1498 | serverListView->setCurrentItem( serverListView->count()); |
1499 | } | 1499 | } |
1500 | } | 1500 | } |
1501 | 1501 | ||
1502 | void OpieFtp::serverListClicked( const QString &item) { | 1502 | void OpieFtp::serverListClicked( const QString &item) { |
1503 | if(item.isEmpty()) return; | 1503 | if(item.isEmpty()) return; |
1504 | Config cfg("opieftp"); | 1504 | Config cfg("opieftp"); |
1505 | qDebug("highltined "+item); | 1505 | qDebug("highltined "+item); |
1506 | int numberOfEntries = cfg.readNumEntry("numberOfEntries",0); | 1506 | int numberOfEntries = cfg.readNumEntry("numberOfEntries",0); |
1507 | for (int i = 1; i <= numberOfEntries; i++) { | 1507 | for (int i = 1; i <= numberOfEntries; i++) { |
1508 | cfg.setGroup(QString::number(i)); | 1508 | cfg.setGroup(QString::number(i)); |
1509 | if(cfg.readEntry( "ServerName").find(item) != -1 && !fuckeduphack) | 1509 | if(cfg.readEntry( "ServerName").find(item) != -1 && !fuckeduphack) |
1510 | serverComboSelected(i-1); | 1510 | serverComboSelected(i-1); |
1511 | } | 1511 | } |
1512 | } | 1512 | } |