-rw-r--r-- | noncore/net/opieftp/opieftp.cpp | 33 |
1 files changed, 19 insertions, 14 deletions
diff --git a/noncore/net/opieftp/opieftp.cpp b/noncore/net/opieftp/opieftp.cpp index 3dda17e..e64fd73 100644 --- a/noncore/net/opieftp/opieftp.cpp +++ b/noncore/net/opieftp/opieftp.cpp | |||
@@ -128,17 +128,18 @@ OpieFtp::OpieFtp( ) | |||
128 | Local_View->addColumn( tr("File"),150); | 128 | Local_View->addColumn( tr("File"),150); |
129 | Local_View->addColumn( tr("Size"),-1); | 129 | Local_View->addColumn( tr("Size"),-1); |
130 | Local_View->setColumnAlignment(1,QListView::AlignRight); | 130 | Local_View->setColumnAlignment(1,QListView::AlignRight); |
131 | Local_View->addColumn( tr("Date"),-1); | 131 | Local_View->addColumn( tr("Date"),-1); |
132 | Local_View->setColumnAlignment(2,QListView::AlignRight); | 132 | Local_View->setColumnAlignment(2,QListView::AlignRight); |
133 | Local_View->setAllColumnsShowFocus(TRUE); | 133 | Local_View->setAllColumnsShowFocus(TRUE); |
134 | Local_View->setMultiSelection( TRUE ); | 134 | Local_View->setMultiSelection( TRUE ); |
135 | Local_View->setSelectionMode(QListView::Extended); | 135 | Local_View->setSelectionMode(QListView::Extended); |
136 | QPEApplication::setStylusOperation( Local_View->viewport(),QPEApplication::RightOnHold); | 136 | |
137 | QPEApplication::setStylusOperation( Local_View->viewport(),QPEApplication::RightOnHold); | ||
137 | 138 | ||
138 | tabLayout->addWidget( Local_View, 0, 0 ); | 139 | tabLayout->addWidget( Local_View, 0, 0 ); |
139 | 140 | ||
140 | connect( Local_View, SIGNAL( clicked( QListViewItem*)), | 141 | connect( Local_View, SIGNAL( clicked( QListViewItem*)), |
141 | this,SLOT( localListClicked(QListViewItem *)) ); | 142 | this,SLOT( localListClicked(QListViewItem *)) ); |
142 | // connect( Local_View, SIGNAL( doubleClicked( QListViewItem*)), | 143 | // connect( Local_View, SIGNAL( doubleClicked( QListViewItem*)), |
143 | // this,SLOT( localListClicked(QListViewItem *)) ); | 144 | // this,SLOT( localListClicked(QListViewItem *)) ); |
144 | connect( Local_View, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int)), | 145 | connect( Local_View, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int)), |
@@ -313,17 +314,16 @@ void OpieFtp::tabChanged(QWidget *w) | |||
313 | void OpieFtp::newConnection() | 314 | void OpieFtp::newConnection() |
314 | { | 315 | { |
315 | UsernameComboBox->lineEdit()->setText(""); | 316 | UsernameComboBox->lineEdit()->setText(""); |
316 | PasswordEdit->setText( "" ); | 317 | PasswordEdit->setText( "" ); |
317 | ServerComboBox->lineEdit()->setText( ""); | 318 | ServerComboBox->lineEdit()->setText( ""); |
318 | remotePath->setText( currentRemoteDir = "/"); | 319 | remotePath->setText( currentRemoteDir = "/"); |
319 | PortSpinBox->setValue( 21); | 320 | PortSpinBox->setValue( 21); |
320 | TabWidget->setCurrentPage(2); | 321 | TabWidget->setCurrentPage(2); |
321 | currentServerConfig = -1; | ||
322 | } | 322 | } |
323 | 323 | ||
324 | void OpieFtp::serverComboEdited(const QString & edit) | 324 | void OpieFtp::serverComboEdited(const QString & edit) |
325 | { | 325 | { |
326 | if( !edit.isEmpty() ) { | 326 | if( !edit.isEmpty() ) { |
327 | currentServerConfig = -1; | 327 | currentServerConfig = -1; |
328 | // qDebug("comboedited"); | 328 | // qDebug("comboedited"); |
329 | } | 329 | } |
@@ -427,18 +427,18 @@ void OpieFtp::localUpload() | |||
427 | msg.replace(QRegExp(":"),"\n"); | 427 | msg.replace(QRegExp(":"),"\n"); |
428 | QMessageBox::message(tr("Note"),msg); | 428 | QMessageBox::message(tr("Note"),msg); |
429 | } | 429 | } |
430 | } else { | 430 | } else { |
431 | QMessageBox::message(tr("Note"),tr("Cannot upload directories")); | 431 | QMessageBox::message(tr("Note"),tr("Cannot upload directories")); |
432 | } | 432 | } |
433 | ProgressBar->reset(); | 433 | ProgressBar->reset(); |
434 | nullifyCallBack(); | 434 | nullifyCallBack(); |
435 | it.current()->setSelected(FALSE); | ||
436 | } //end currentSelected | 435 | } //end currentSelected |
436 | it.current()->setSelected(FALSE); | ||
437 | } | 437 | } |
438 | TabWidget->setCurrentPage(1); | 438 | TabWidget->setCurrentPage(1); |
439 | remoteDirList( (const QString &)currentRemoteDir); //this also calls populate | 439 | remoteDirList( (const QString &)currentRemoteDir); //this also calls populate |
440 | QCopEnvelope ( "QPE/System", "notBusy()" ); | 440 | QCopEnvelope ( "QPE/System", "notBusy()" ); |
441 | } | 441 | } |
442 | 442 | ||
443 | void OpieFtp::nullifyCallBack() | 443 | void OpieFtp::nullifyCallBack() |
444 | { | 444 | { |
@@ -481,18 +481,18 @@ void OpieFtp::remoteDownload() | |||
481 | if(!FtpGet( localFile.latin1(), remoteFile.latin1(),FTPLIB_IMAGE, conn ) ) { | 481 | if(!FtpGet( localFile.latin1(), remoteFile.latin1(),FTPLIB_IMAGE, conn ) ) { |
482 | QString msg; | 482 | QString msg; |
483 | msg.sprintf(tr("Unable to download \n")+"%s",FtpLastResponse(conn)); | 483 | msg.sprintf(tr("Unable to download \n")+"%s",FtpLastResponse(conn)); |
484 | msg.replace(QRegExp(":"),"\n"); | 484 | msg.replace(QRegExp(":"),"\n"); |
485 | QMessageBox::message(tr("Note"),msg); | 485 | QMessageBox::message(tr("Note"),msg); |
486 | } | 486 | } |
487 | ProgressBar->reset(); | 487 | ProgressBar->reset(); |
488 | nullifyCallBack(); | 488 | nullifyCallBack(); |
489 | it.current()->setSelected(FALSE); | ||
490 | } | 489 | } |
490 | it.current()->setSelected(FALSE); | ||
491 | } | 491 | } |
492 | TabWidget->setCurrentPage(0); | 492 | TabWidget->setCurrentPage(0); |
493 | populateLocalView(); | 493 | populateLocalView(); |
494 | QCopEnvelope ( "QPE/System", "notBusy()" ); | 494 | QCopEnvelope ( "QPE/System", "notBusy()" ); |
495 | } | 495 | } |
496 | 496 | ||
497 | bool OpieFtp::remoteDirList(const QString &dir) | 497 | bool OpieFtp::remoteDirList(const QString &dir) |
498 | { | 498 | { |
@@ -652,17 +652,17 @@ bool OpieFtp::populateRemoteView( ) | |||
652 | qDebug("temp file not opened successfullly "+sfile); | 652 | qDebug("temp file not opened successfullly "+sfile); |
653 | Remote_View->setSorting( 4,TRUE); | 653 | Remote_View->setSorting( 4,TRUE); |
654 | return true; | 654 | return true; |
655 | } | 655 | } |
656 | 656 | ||
657 | void OpieFtp::remoteListClicked(QListViewItem *selectedItem) | 657 | void OpieFtp::remoteListClicked(QListViewItem *selectedItem) |
658 | { | 658 | { |
659 | if( selectedItem) { | 659 | if( selectedItem) { |
660 | QCopEnvelope ( "QPE/System", "busy()" ); | 660 | // QCopEnvelope ( "QPE/System", "busy()" ); |
661 | QString oldRemoteCurrentDir = currentRemoteDir; | 661 | QString oldRemoteCurrentDir = currentRemoteDir; |
662 | QString strItem=selectedItem->text(0); | 662 | QString strItem=selectedItem->text(0); |
663 | strItem=strItem.simplifyWhiteSpace(); | 663 | strItem=strItem.simplifyWhiteSpace(); |
664 | if(strItem == "../") { // the user wants to go ^ | 664 | if(strItem == "../") { // the user wants to go ^ |
665 | if( FtpCDUp( conn) == 0) { | 665 | if( FtpCDUp( conn) == 0) { |
666 | QString msg; | 666 | QString msg; |
667 | msg.sprintf(tr("Unable to cd up\n")+"%s",FtpLastResponse(conn)); | 667 | msg.sprintf(tr("Unable to cd up\n")+"%s",FtpLastResponse(conn)); |
668 | msg.replace(QRegExp(":"),"\n"); | 668 | msg.replace(QRegExp(":"),"\n"); |
@@ -681,38 +681,38 @@ void OpieFtp::remoteListClicked(QListViewItem *selectedItem) | |||
681 | } else { | 681 | } else { |
682 | if(strItem.find("->",0,TRUE) != -1) { //symlink on some servers | 682 | if(strItem.find("->",0,TRUE) != -1) { //symlink on some servers |
683 | strItem=strItem.right( strItem.length() - strItem.find("->",0,TRUE) - 2 ); | 683 | strItem=strItem.right( strItem.length() - strItem.find("->",0,TRUE) - 2 ); |
684 | strItem = strItem.stripWhiteSpace(); | 684 | strItem = strItem.stripWhiteSpace(); |
685 | currentRemoteDir = strItem; | 685 | currentRemoteDir = strItem; |
686 | if( !remoteChDir( (const QString &)strItem)) { | 686 | if( !remoteChDir( (const QString &)strItem)) { |
687 | currentRemoteDir = oldRemoteCurrentDir; | 687 | currentRemoteDir = oldRemoteCurrentDir; |
688 | strItem=""; | 688 | strItem=""; |
689 | qDebug("RemoteCurrentDir1 "+oldRemoteCurrentDir); | 689 | // qDebug("RemoteCurrentDir1 "+oldRemoteCurrentDir); |
690 | } | 690 | } |
691 | } else if(strItem.find("/",0,TRUE) != -1) { // this is a directory | 691 | } else if(strItem.find("/",0,TRUE) != -1) { // this is a directory |
692 | qDebug("trying directory"); | ||
693 | if( !remoteChDir( (const QString &)currentRemoteDir + strItem)) { | 692 | if( !remoteChDir( (const QString &)currentRemoteDir + strItem)) { |
694 | currentRemoteDir = oldRemoteCurrentDir; | 693 | currentRemoteDir = oldRemoteCurrentDir; |
695 | strItem=""; | 694 | strItem=""; |
696 | qDebug("RemoteCurrentDir1 "+oldRemoteCurrentDir); | 695 | // qDebug("RemoteCurrentDir1 "+oldRemoteCurrentDir); |
697 | 696 | ||
698 | } else { | 697 | } else { |
699 | currentRemoteDir = currentRemoteDir+strItem; | 698 | currentRemoteDir = currentRemoteDir+strItem; |
700 | } | 699 | } |
701 | } else { | 700 | } else { |
702 | qDebug("download "+strItem); | 701 | QCopEnvelope ( "QPE/System", "notBusy()" ); |
702 | return; | ||
703 | } | 703 | } |
704 | } | 704 | } |
705 | remoteDirList( (const QString &)currentRemoteDir); //this also calls populate | 705 | remoteDirList( (const QString &)currentRemoteDir); //this also calls populate |
706 | if(currentRemoteDir.right(1) !="/") | 706 | if(currentRemoteDir.right(1) !="/") |
707 | currentRemoteDir +="/"; | 707 | currentRemoteDir +="/"; |
708 | currentPathCombo->lineEdit()->setText( currentRemoteDir ); | 708 | currentPathCombo->lineEdit()->setText( currentRemoteDir); |
709 | fillRemoteCombo( (const QString &)currentDir); | 709 | fillRemoteCombo( (const QString &)currentRemoteDir); |
710 | QCopEnvelope ( "QPE/System", "notBusy()" ); | 710 | // QCopEnvelope ( "QPE/System", "notBusy()" ); |
711 | } | 711 | } |
712 | } | 712 | } |
713 | 713 | ||
714 | void OpieFtp::localListClicked(QListViewItem *selectedItem) | 714 | void OpieFtp::localListClicked(QListViewItem *selectedItem) |
715 | { | 715 | { |
716 | if(selectedItem!= NULL) { | 716 | if(selectedItem!= NULL) { |
717 | 717 | ||
718 | QString strItem=selectedItem->text(0); | 718 | QString strItem=selectedItem->text(0); |
@@ -722,32 +722,34 @@ void OpieFtp::localListClicked(QListViewItem *selectedItem) | |||
722 | // is symlink | 722 | // is symlink |
723 | QString strItem2 = strItem.right( (strItem.length() - strItem.find("->",0,TRUE)) - 4); | 723 | QString strItem2 = strItem.right( (strItem.length() - strItem.find("->",0,TRUE)) - 4); |
724 | if(QDir(strItem2).exists() ) { | 724 | if(QDir(strItem2).exists() ) { |
725 | currentDir.cd(strItem2, TRUE); | 725 | currentDir.cd(strItem2, TRUE); |
726 | populateLocalView(); | 726 | populateLocalView(); |
727 | } | 727 | } |
728 | } else { // not a symlink | 728 | } else { // not a symlink |
729 | if(strItem.find(". .",0,TRUE) && strItem.find("/",0,TRUE)!=-1 ) { | 729 | if(strItem.find(". .",0,TRUE) && strItem.find("/",0,TRUE)!=-1 ) { |
730 | |||
730 | if(QDir(QDir::cleanDirPath(currentDir.canonicalPath()+"/"+strItem)).exists() ) { | 731 | if(QDir(QDir::cleanDirPath(currentDir.canonicalPath()+"/"+strItem)).exists() ) { |
731 | strItem=QDir::cleanDirPath(currentDir.canonicalPath()+"/"+strItem); | 732 | strItem=QDir::cleanDirPath(currentDir.canonicalPath()+"/"+strItem); |
732 | currentDir.cd(strItem,FALSE); | 733 | currentDir.cd(strItem,FALSE); |
733 | populateLocalView(); | 734 | populateLocalView(); |
734 | } else { | 735 | } else { |
735 | currentDir.cdUp(); | 736 | currentDir.cdUp(); |
736 | populateLocalView(); | 737 | populateLocalView(); |
737 | } | 738 | } |
738 | if(QDir(strItem).exists()){ | 739 | if(QDir(strItem).exists()){ |
739 | currentDir.cd(strItem, TRUE); | 740 | currentDir.cd(strItem, TRUE); |
740 | populateLocalView(); | 741 | populateLocalView(); |
741 | } | 742 | } |
742 | } else { | 743 | } else { |
743 | strItem=QDir::cleanDirPath(currentDir.canonicalPath()+"/"+strItem); | 744 | strItem=QDir::cleanDirPath(currentDir.canonicalPath()+"/"+strItem); |
744 | if( QFile::exists(strItem ) ) { | 745 | if( QFile::exists(strItem ) ) { |
745 | // qDebug("upload "+strItem); | 746 | // qDebug("upload "+strItem); |
747 | return; | ||
746 | } | 748 | } |
747 | } //end not symlink | 749 | } //end not symlink |
748 | chdir(strItem.latin1()); | 750 | chdir(strItem.latin1()); |
749 | } | 751 | } |
750 | } | 752 | } |
751 | } | 753 | } |
752 | 754 | ||
753 | void OpieFtp::doLocalCd() | 755 | void OpieFtp::doLocalCd() |
@@ -1063,39 +1065,42 @@ void OpieFtp::readConfig() | |||
1063 | Config cfg("opieftp"); | 1065 | Config cfg("opieftp"); |
1064 | cfg.setGroup("Server"); | 1066 | cfg.setGroup("Server"); |
1065 | currentServerConfig = cfg.readNumEntry("currentServer", -1); | 1067 | currentServerConfig = cfg.readNumEntry("currentServer", -1); |
1066 | serverComboSelected( currentServerConfig); | 1068 | serverComboSelected( currentServerConfig); |
1067 | } | 1069 | } |
1068 | 1070 | ||
1069 | void OpieFtp::writeConfig() | 1071 | void OpieFtp::writeConfig() |
1070 | { | 1072 | { |
1071 | |||
1072 | Config cfg("opieftp"); | 1073 | Config cfg("opieftp"); |
1073 | cfg.setGroup("Server"); | 1074 | cfg.setGroup("Server"); |
1074 | QString username, remoteServerStr, remotePathStr, password, port, temp; | 1075 | QString username, remoteServerStr, remotePathStr, password, port, temp; |
1075 | int numberOfEntries = cfg.readNumEntry("numberOfEntries",0); | 1076 | int numberOfEntries = cfg.readNumEntry("numberOfEntries",0); |
1076 | if( currentServerConfig == -1) { | 1077 | if( currentServerConfig == -1) { |
1078 | for (int i = 1; i <= numberOfEntries; i++) { | ||
1079 | temp.setNum(i); | ||
1080 | cfg.setGroup("Server"); | ||
1081 | QString tempStr = cfg.readEntry( temp,""); | ||
1082 | } | ||
1077 | 1083 | ||
1078 | temp.setNum( numberOfEntries + 1); | 1084 | temp.setNum( numberOfEntries + 1); |
1079 | cfg.setGroup("Server"); | 1085 | cfg.setGroup("Server"); |
1080 | remoteServerStr = cfg.readEntry( temp,""); | 1086 | remoteServerStr = cfg.readEntry( temp,""); |
1081 | int divider = remoteServerStr.length() - remoteServerStr.find(":",0,TRUE); | 1087 | int divider = remoteServerStr.length() - remoteServerStr.find(":",0,TRUE); |
1082 | remoteServerStr = remoteServerStr.left(remoteServerStr.length()-divider); | 1088 | remoteServerStr = remoteServerStr.left(remoteServerStr.length()-divider); |
1083 | 1089 | ||
1084 | temp.setNum(numberOfEntries+1); | 1090 | temp.setNum(numberOfEntries+1); |
1085 | cfg.setGroup("Server"); | 1091 | cfg.setGroup("Server"); |
1086 | cfg.writeEntry( temp, ServerComboBox->currentText() +":"+PortSpinBox->cleanText() ); | 1092 | cfg.writeEntry( temp, ServerComboBox->currentText() +":"+PortSpinBox->cleanText() ); |
1087 | cfg.setGroup(temp); | 1093 | cfg.setGroup(temp); |
1088 | cfg.writeEntry("RemotePath", remotePath->text()); | 1094 | cfg.writeEntry("RemotePath", remotePath->text()); |
1089 | cfg.writeEntry("Username", UsernameComboBox->currentText()); | 1095 | cfg.writeEntry("Username", UsernameComboBox->currentText()); |
1090 | cfg.writeEntryCrypt( UsernameComboBox->currentText(), PasswordEdit->text()); | 1096 | cfg.writeEntryCrypt( UsernameComboBox->currentText(), PasswordEdit->text()); |
1091 | cfg.setGroup("Server"); | 1097 | cfg.setGroup("Server"); |
1092 | cfg.writeEntry("numberOfEntries", QString::number(numberOfEntries + 1 )); | 1098 | cfg.writeEntry("numberOfEntries", QString::number(numberOfEntries + 1 )); |
1093 | |||
1094 | } | 1099 | } |
1095 | } | 1100 | } |
1096 | 1101 | ||
1097 | void OpieFtp::fillCombos() | 1102 | void OpieFtp::fillCombos() |
1098 | { | 1103 | { |
1099 | Config cfg("opieftp"); | 1104 | Config cfg("opieftp"); |
1100 | cfg.setGroup("Server"); | 1105 | cfg.setGroup("Server"); |
1101 | QString username, remoteServerStr, remotePathStr, password, port, temp; | 1106 | QString username, remoteServerStr, remotePathStr, password, port, temp; |