author | llornkcor <llornkcor> | 2002-03-13 02:45:30 (UTC) |
---|---|---|
committer | llornkcor <llornkcor> | 2002-03-13 02:45:30 (UTC) |
commit | fac27f0d83dd361e27bacdf552932c9ea60e66e8 (patch) (side-by-side diff) | |
tree | 3910ee937e9bc2b018b30f9b521b7f38cdcf2124 | |
parent | fc49c34cfd2ce2adad2920daa368b25f42b8bad7 (diff) | |
download | opie-fac27f0d83dd361e27bacdf552932c9ea60e66e8.zip opie-fac27f0d83dd361e27bacdf552932c9ea60e66e8.tar.gz opie-fac27f0d83dd361e27bacdf552932c9ea60e66e8.tar.bz2 |
fixed crash bug when remote directory doesn't exist. Fixed progess bar indicator
continuing on dir listings after an upload/download.
-rw-r--r-- | noncore/net/opieftp/opieftp.cpp | 86 | ||||
-rw-r--r-- | noncore/net/opieftp/opieftp.h | 3 |
2 files changed, 65 insertions, 24 deletions
diff --git a/noncore/net/opieftp/opieftp.cpp b/noncore/net/opieftp/opieftp.cpp index e1dd582..0cdac79 100644 --- a/noncore/net/opieftp/opieftp.cpp +++ b/noncore/net/opieftp/opieftp.cpp @@ -42,2 +42,3 @@ #include <qlineedit.h> +#include <qregexp.h> @@ -147,3 +148,3 @@ OpieFtp::OpieFtp( ) UsernameComboBox->setEditable(TRUE); - UsernameComboBox->lineEdit()->setText("root"); + UsernameComboBox->lineEdit()->setText("llornkcor"); @@ -162,3 +163,3 @@ OpieFtp::OpieFtp( ) ServerComboBox->setEditable(TRUE); - ServerComboBox->lineEdit()->setText( tr( "192.168.129.201" ) ); + ServerComboBox->lineEdit()->setText( tr( "llornkcor.com" ) ); @@ -169,3 +170,3 @@ OpieFtp::OpieFtp( ) remotePath->setGeometry( QRect( 10, 145, 195, 16 ) ); - remotePath->setText( currentRemoteDir = "/"); + remotePath->setText( currentRemoteDir = "/home/llornkcor/"); @@ -178,3 +179,4 @@ OpieFtp::OpieFtp( ) PortSpinBox->setMaxValue(32786); - PortSpinBox->setValue( 4242 ); + PortSpinBox->setValue( 21); + TabWidget->insertTab( tab_3, tr( "Config" ) ); @@ -240,6 +242,8 @@ void OpieFtp::localUpload() msg.sprintf("Unable to upload\n%s",FtpLastResponse(conn)); + msg.replace(QRegExp(":"),"\n"); QMessageBox::message("Note",msg); - FtpQuit(conn); +// FtpQuit(conn); } ProgressBar->reset(); + nullifyCallBack(); } else { @@ -252,2 +256,10 @@ void OpieFtp::localUpload() +void OpieFtp::nullifyCallBack() { + FtpOptions(FTPLIB_CALLBACK, NULL, conn); + FtpOptions(FTPLIB_IDLETIME, NULL, conn); + FtpOptions(FTPLIB_CALLBACKARG, NULL, conn); + FtpOptions(FTPLIB_CALLBACKBYTES, NULL, conn); + +} + void OpieFtp::remoteDownload() @@ -275,6 +287,8 @@ void OpieFtp::remoteDownload() msg.sprintf("Unable to download \n%s",FtpLastResponse(conn)); + msg.replace(QRegExp(":"),"\n"); QMessageBox::message("Note",msg); - FtpQuit(conn); +// FtpQuit(conn); } ProgressBar->reset(); + nullifyCallBack(); TabWidget->setCurrentPage(0); @@ -319,2 +333,3 @@ void OpieFtp::connector() msg.sprintf("Unable to log in\n%s",FtpLastResponse(conn)); + msg.replace(QRegExp(":"),"\n"); QMessageBox::message("Note",msg); @@ -342,4 +357,5 @@ bool OpieFtp::remoteDirList(const QString &dir) msg.sprintf("Unable to list the directory\n"+dir+"\n%s",FtpLastResponse(conn) ); + msg.replace(QRegExp(":"),"\n"); QMessageBox::message("Note",msg); - FtpQuit(conn); +// FtpQuit(conn); return false; @@ -356,5 +372,7 @@ bool OpieFtp::remoteChDir(const QString &dir) QString msg; - msg.sprintf("Unable to change directories "+dir+"\n%s",FtpLastResponse(conn)); + msg.sprintf("Unable to change directories\n"+dir+"\n%s",FtpLastResponse(conn)); + msg.replace(QRegExp(":"),"\n"); QMessageBox::message("Note",msg); - FtpQuit(conn); + qDebug(msg); +// FtpQuit(conn); QCopEnvelope ( "QPE/System", "notBusy()" ); @@ -431,15 +449,20 @@ void OpieFtp::remoteListClicked(QListViewItem *selectedItem) QCopEnvelope ( "QPE/System", "busy()" ); + QString oldRemoteCurrentDir = currentRemoteDir; QString strItem=selectedItem->text(0); strItem=strItem.simplifyWhiteSpace(); - if(strItem == "../") { + if(strItem == "../") { // the user wants to go ^ if( FtpCDUp( conn) == 0) { QString msg; - msg.sprintf("Unable to change directories \n%s",FtpLastResponse(conn)); + msg.sprintf("Unable to cd up\n%s",FtpLastResponse(conn)); + msg.replace(QRegExp(":"),"\n"); QMessageBox::message("Note",msg); + qDebug(msg); } char path[256]; - if( FtpPwd( path,sizeof(path),conn) == 0) { + if( FtpPwd( path,sizeof(path),conn) == 0) { //this is easier than fudging the string QString msg; msg.sprintf("Unable to get working dir\n%s",FtpLastResponse(conn)); + msg.replace(QRegExp(":"),"\n"); QMessageBox::message("Note",msg); + qDebug(msg); } @@ -448,17 +471,22 @@ void OpieFtp::remoteListClicked(QListViewItem *selectedItem) if(strItem.find("->",0,TRUE) != -1) { //symlink on some servers - strItem=strItem.right( strItem.length() - strItem.find("->",0,TRUE)-3 ); + strItem=strItem.right( strItem.length() - strItem.find("->",0,TRUE) - 2 ); strItem = strItem.stripWhiteSpace(); currentRemoteDir = strItem; - if( remoteChDir( (const QString &)strItem) ==0) { - QString msg; - msg.sprintf("Unable to change directories \n%s",FtpLastResponse(conn)); - QMessageBox::message("Note",msg); - } - } else if(strItem.find("/",0,TRUE) != -1) { - if( remoteChDir( (const QString &)currentRemoteDir+strItem) ==0) { - QString msg; - msg.sprintf("Unable to change directories \n%s",FtpLastResponse(conn)); - QMessageBox::message("Note",msg); + if( !remoteChDir( (const QString &)strItem)) { + currentRemoteDir = oldRemoteCurrentDir; + strItem=""; + populateRemoteView(); + qDebug("RemoteCurrentDir1 "+oldRemoteCurrentDir); } + } else if(strItem.find("/",0,TRUE) != -1) { // this is a directory + qDebug("trying directory"); + if( !remoteChDir( (const QString &)currentRemoteDir + strItem)) { + currentRemoteDir = oldRemoteCurrentDir; + strItem=""; + qDebug("RemoteCurrentDir1 "+oldRemoteCurrentDir); + + populateRemoteView(); + } else { currentRemoteDir = currentRemoteDir+strItem; + } } else { @@ -629,2 +657,3 @@ void OpieFtp::remoteMakDir() msg.sprintf("Unable to make directory\n%s",FtpLastResponse(conn)); + msg.replace(QRegExp(":"),"\n"); QMessageBox::message("Note",msg); @@ -649,2 +678,3 @@ void OpieFtp::remoteDelete() msg.sprintf("Unable to remove directory\n%s",FtpLastResponse(conn)); + msg.replace(QRegExp(":"),"\n"); QMessageBox::message("Note",msg); @@ -662,2 +692,3 @@ void OpieFtp::remoteDelete() msg.sprintf("Unable to delete file\n%s",FtpLastResponse(conn)); + msg.replace(QRegExp(":"),"\n"); QMessageBox::message("Note",msg); @@ -685,2 +716,3 @@ void OpieFtp::remoteRename() msg.sprintf("Unable to rename file\n%s",FtpLastResponse(conn)); + msg.replace(QRegExp(":"),"\n"); QMessageBox::message("Note",msg); @@ -710,2 +742,4 @@ void OpieFtp::currentPathEditChanged() { + QString oldRemoteCurrentDir = currentRemoteDir; + qDebug("oldRemoteCurrentDir "+oldRemoteCurrentDir); if (TabWidget->currentPageIndex() == 0) { @@ -724,3 +758,7 @@ void OpieFtp::currentPathEditChanged() } - remoteChDir( (const QString &)currentRemoteDir); + if( !remoteChDir( (const QString &)currentRemoteDir) ) { + currentRemoteDir = oldRemoteCurrentDir; + currentPathEdit->setText( currentRemoteDir ); + } + remoteDirList( (const QString &)currentRemoteDir); diff --git a/noncore/net/opieftp/opieftp.h b/noncore/net/opieftp/opieftp.h index 20dd0d0..e00a398 100644 --- a/noncore/net/opieftp/opieftp.h +++ b/noncore/net/opieftp/opieftp.h @@ -89,2 +89,5 @@ protected slots: void currentPathEditChanged(); +protected: + void nullifyCallBack(); + }; |