-rw-r--r-- | noncore/net/opieftp/opieftp.cpp | 114 | ||||
-rw-r--r-- | noncore/net/opieftp/opieftp.h | 3 |
2 files changed, 79 insertions, 38 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 | |||
@@ -41,4 +41,5 @@ | |||
41 | #include <qmessagebox.h> | 41 | #include <qmessagebox.h> |
42 | #include <qlineedit.h> | 42 | #include <qlineedit.h> |
43 | #include <qregexp.h> | ||
43 | 44 | ||
44 | #include <unistd.h> | 45 | #include <unistd.h> |
@@ -146,5 +147,5 @@ OpieFtp::OpieFtp( ) | |||
146 | UsernameComboBox->setGeometry( QRect( 10, 25, 196, 21 ) ); | 147 | UsernameComboBox->setGeometry( QRect( 10, 25, 196, 21 ) ); |
147 | UsernameComboBox->setEditable(TRUE); | 148 | UsernameComboBox->setEditable(TRUE); |
148 | UsernameComboBox->lineEdit()->setText("root"); | 149 | UsernameComboBox->lineEdit()->setText("llornkcor"); |
149 | 150 | ||
150 | TextLabel2 = new QLabel( tab_3, "TextLabel2" ); | 151 | TextLabel2 = new QLabel( tab_3, "TextLabel2" ); |
@@ -161,5 +162,5 @@ OpieFtp::OpieFtp( ) | |||
161 | ServerComboBox->setGeometry( QRect( 10, 105, 195, 21 ) ); | 162 | ServerComboBox->setGeometry( QRect( 10, 105, 195, 21 ) ); |
162 | ServerComboBox->setEditable(TRUE); | 163 | ServerComboBox->setEditable(TRUE); |
163 | ServerComboBox->lineEdit()->setText( tr( "192.168.129.201" ) ); | 164 | ServerComboBox->lineEdit()->setText( tr( "llornkcor.com" ) ); |
164 | 165 | ||
165 | QLabel *TextLabel5 = new QLabel( tab_3, "TextLabel5" ); | 166 | QLabel *TextLabel5 = new QLabel( tab_3, "TextLabel5" ); |
@@ -168,5 +169,5 @@ OpieFtp::OpieFtp( ) | |||
168 | remotePath = new QLineEdit( "/", tab_3, "remotePath" ); | 169 | remotePath = new QLineEdit( "/", tab_3, "remotePath" ); |
169 | remotePath->setGeometry( QRect( 10, 145, 195, 16 ) ); | 170 | remotePath->setGeometry( QRect( 10, 145, 195, 16 ) ); |
170 | remotePath->setText( currentRemoteDir = "/"); | 171 | remotePath->setText( currentRemoteDir = "/home/llornkcor/"); |
171 | 172 | ||
172 | TextLabel4 = new QLabel( tab_3, "TextLabel4" ); | 173 | TextLabel4 = new QLabel( tab_3, "TextLabel4" ); |
@@ -177,5 +178,6 @@ OpieFtp::OpieFtp( ) | |||
177 | PortSpinBox->setButtonSymbols( QSpinBox::UpDownArrows ); | 178 | PortSpinBox->setButtonSymbols( QSpinBox::UpDownArrows ); |
178 | PortSpinBox->setMaxValue(32786); | 179 | PortSpinBox->setMaxValue(32786); |
179 | PortSpinBox->setValue( 4242 ); | 180 | PortSpinBox->setValue( 21); |
181 | |||
180 | TabWidget->insertTab( tab_3, tr( "Config" ) ); | 182 | TabWidget->insertTab( tab_3, tr( "Config" ) ); |
181 | 183 | ||
@@ -227,20 +229,22 @@ void OpieFtp::localUpload() | |||
227 | QFileInfo fi(localFile); | 229 | QFileInfo fi(localFile); |
228 | if( !fi.isDir()) { | 230 | if( !fi.isDir()) { |
229 | fsz=fi.size(); | 231 | fsz=fi.size(); |
230 | ProgressBar->setTotalSteps(fsz); | 232 | ProgressBar->setTotalSteps(fsz); |
231 | 233 | ||
232 | FtpOptions(FTPLIB_CALLBACK, (long) log_progress, conn); | 234 | FtpOptions(FTPLIB_CALLBACK, (long) log_progress, conn); |
233 | FtpOptions(FTPLIB_IDLETIME, (long) 1000, conn); | 235 | FtpOptions(FTPLIB_IDLETIME, (long) 1000, conn); |
234 | FtpOptions(FTPLIB_CALLBACKARG, (long) &fsz, conn); | 236 | FtpOptions(FTPLIB_CALLBACKARG, (long) &fsz, conn); |
235 | FtpOptions(FTPLIB_CALLBACKBYTES, (long) fsz/10, conn); | 237 | FtpOptions(FTPLIB_CALLBACKBYTES, (long) fsz/10, conn); |
236 | qDebug("Put: %s, %s",localFile.latin1(),remoteFile.latin1()); | 238 | qDebug("Put: %s, %s",localFile.latin1(),remoteFile.latin1()); |
237 | 239 | ||
238 | if( !FtpPut( localFile.latin1(), remoteFile.latin1(),FTPLIB_IMAGE, conn ) ) { | 240 | if( !FtpPut( localFile.latin1(), remoteFile.latin1(),FTPLIB_IMAGE, conn ) ) { |
239 | QString msg; | 241 | QString msg; |
240 | msg.sprintf("Unable to upload\n%s",FtpLastResponse(conn)); | 242 | msg.sprintf("Unable to upload\n%s",FtpLastResponse(conn)); |
241 | QMessageBox::message("Note",msg); | 243 | msg.replace(QRegExp(":"),"\n"); |
242 | FtpQuit(conn); | 244 | QMessageBox::message("Note",msg); |
243 | } | 245 | // FtpQuit(conn); |
244 | ProgressBar->reset(); | 246 | } |
247 | ProgressBar->reset(); | ||
248 | nullifyCallBack(); | ||
245 | } else { | 249 | } else { |
246 | QMessageBox::message("Note","Cannot upload directories"); | 250 | QMessageBox::message("Note","Cannot upload directories"); |
@@ -251,4 +255,12 @@ void OpieFtp::localUpload() | |||
251 | } | 255 | } |
252 | 256 | ||
257 | void OpieFtp::nullifyCallBack() { | ||
258 | FtpOptions(FTPLIB_CALLBACK, NULL, conn); | ||
259 | FtpOptions(FTPLIB_IDLETIME, NULL, conn); | ||
260 | FtpOptions(FTPLIB_CALLBACKARG, NULL, conn); | ||
261 | FtpOptions(FTPLIB_CALLBACKBYTES, NULL, conn); | ||
262 | |||
263 | } | ||
264 | |||
253 | void OpieFtp::remoteDownload() | 265 | void OpieFtp::remoteDownload() |
254 | { | 266 | { |
@@ -274,8 +286,10 @@ void OpieFtp::remoteDownload() | |||
274 | QString msg; | 286 | QString msg; |
275 | msg.sprintf("Unable to download \n%s",FtpLastResponse(conn)); | 287 | msg.sprintf("Unable to download \n%s",FtpLastResponse(conn)); |
288 | msg.replace(QRegExp(":"),"\n"); | ||
276 | QMessageBox::message("Note",msg); | 289 | QMessageBox::message("Note",msg); |
277 | FtpQuit(conn); | 290 | // FtpQuit(conn); |
278 | } | 291 | } |
279 | ProgressBar->reset(); | 292 | ProgressBar->reset(); |
293 | nullifyCallBack(); | ||
280 | TabWidget->setCurrentPage(0); | 294 | TabWidget->setCurrentPage(0); |
281 | populateLocalView(); | 295 | populateLocalView(); |
@@ -318,4 +332,5 @@ void OpieFtp::connector() | |||
318 | QString msg; | 332 | QString msg; |
319 | msg.sprintf("Unable to log in\n%s",FtpLastResponse(conn)); | 333 | msg.sprintf("Unable to log in\n%s",FtpLastResponse(conn)); |
334 | msg.replace(QRegExp(":"),"\n"); | ||
320 | QMessageBox::message("Note",msg); | 335 | QMessageBox::message("Note",msg); |
321 | FtpQuit(conn); | 336 | FtpQuit(conn); |
@@ -341,6 +356,7 @@ bool OpieFtp::remoteDirList(const QString &dir) | |||
341 | QString msg; | 356 | QString msg; |
342 | msg.sprintf("Unable to list the directory\n"+dir+"\n%s",FtpLastResponse(conn) ); | 357 | msg.sprintf("Unable to list the directory\n"+dir+"\n%s",FtpLastResponse(conn) ); |
358 | msg.replace(QRegExp(":"),"\n"); | ||
343 | QMessageBox::message("Note",msg); | 359 | QMessageBox::message("Note",msg); |
344 | FtpQuit(conn); | 360 | // FtpQuit(conn); |
345 | return false; | 361 | return false; |
346 | } | 362 | } |
@@ -355,7 +371,9 @@ bool OpieFtp::remoteChDir(const QString &dir) | |||
355 | if (!FtpChdir( dir.latin1(), conn )) { | 371 | if (!FtpChdir( dir.latin1(), conn )) { |
356 | QString msg; | 372 | QString msg; |
357 | msg.sprintf("Unable to change directories "+dir+"\n%s",FtpLastResponse(conn)); | 373 | msg.sprintf("Unable to change directories\n"+dir+"\n%s",FtpLastResponse(conn)); |
374 | msg.replace(QRegExp(":"),"\n"); | ||
358 | QMessageBox::message("Note",msg); | 375 | QMessageBox::message("Note",msg); |
359 | FtpQuit(conn); | 376 | qDebug(msg); |
377 | // FtpQuit(conn); | ||
360 | QCopEnvelope ( "QPE/System", "notBusy()" ); | 378 | QCopEnvelope ( "QPE/System", "notBusy()" ); |
361 | return FALSE; | 379 | return FALSE; |
@@ -430,36 +448,46 @@ void OpieFtp::remoteListClicked(QListViewItem *selectedItem) | |||
430 | { | 448 | { |
431 | QCopEnvelope ( "QPE/System", "busy()" ); | 449 | QCopEnvelope ( "QPE/System", "busy()" ); |
450 | QString oldRemoteCurrentDir = currentRemoteDir; | ||
432 | QString strItem=selectedItem->text(0); | 451 | QString strItem=selectedItem->text(0); |
433 | strItem=strItem.simplifyWhiteSpace(); | 452 | strItem=strItem.simplifyWhiteSpace(); |
434 | if(strItem == "../") { | 453 | if(strItem == "../") { // the user wants to go ^ |
435 | if( FtpCDUp( conn) == 0) { | 454 | if( FtpCDUp( conn) == 0) { |
436 | QString msg; | 455 | QString msg; |
437 | msg.sprintf("Unable to change directories \n%s",FtpLastResponse(conn)); | 456 | msg.sprintf("Unable to cd up\n%s",FtpLastResponse(conn)); |
457 | msg.replace(QRegExp(":"),"\n"); | ||
438 | QMessageBox::message("Note",msg); | 458 | QMessageBox::message("Note",msg); |
459 | qDebug(msg); | ||
439 | } | 460 | } |
440 | char path[256]; | 461 | char path[256]; |
441 | if( FtpPwd( path,sizeof(path),conn) == 0) { | 462 | if( FtpPwd( path,sizeof(path),conn) == 0) { //this is easier than fudging the string |
442 | QString msg; | 463 | QString msg; |
443 | msg.sprintf("Unable to get working dir\n%s",FtpLastResponse(conn)); | 464 | msg.sprintf("Unable to get working dir\n%s",FtpLastResponse(conn)); |
465 | msg.replace(QRegExp(":"),"\n"); | ||
444 | QMessageBox::message("Note",msg); | 466 | QMessageBox::message("Note",msg); |
467 | qDebug(msg); | ||
445 | } | 468 | } |
446 | currentRemoteDir=path; | 469 | currentRemoteDir=path; |
447 | } else { | 470 | } else { |
448 | if(strItem.find("->",0,TRUE) != -1) { //symlink on some servers | 471 | if(strItem.find("->",0,TRUE) != -1) { //symlink on some servers |
449 | strItem=strItem.right( strItem.length() - strItem.find("->",0,TRUE)-3 ); | 472 | strItem=strItem.right( strItem.length() - strItem.find("->",0,TRUE) - 2 ); |
450 | strItem = strItem.stripWhiteSpace(); | 473 | strItem = strItem.stripWhiteSpace(); |
451 | currentRemoteDir = strItem; | 474 | currentRemoteDir = strItem; |
452 | if( remoteChDir( (const QString &)strItem) ==0) { | 475 | if( !remoteChDir( (const QString &)strItem)) { |
453 | QString msg; | 476 | currentRemoteDir = oldRemoteCurrentDir; |
454 | msg.sprintf("Unable to change directories \n%s",FtpLastResponse(conn)); | 477 | strItem=""; |
455 | QMessageBox::message("Note",msg); | 478 | populateRemoteView(); |
456 | } | 479 | qDebug("RemoteCurrentDir1 "+oldRemoteCurrentDir); |
457 | } else if(strItem.find("/",0,TRUE) != -1) { | ||
458 | if( remoteChDir( (const QString &)currentRemoteDir+strItem) ==0) { | ||
459 | QString msg; | ||
460 | msg.sprintf("Unable to change directories \n%s",FtpLastResponse(conn)); | ||
461 | QMessageBox::message("Note",msg); | ||
462 | } | 480 | } |
481 | } else if(strItem.find("/",0,TRUE) != -1) { // this is a directory | ||
482 | qDebug("trying directory"); | ||
483 | if( !remoteChDir( (const QString &)currentRemoteDir + strItem)) { | ||
484 | currentRemoteDir = oldRemoteCurrentDir; | ||
485 | strItem=""; | ||
486 | qDebug("RemoteCurrentDir1 "+oldRemoteCurrentDir); | ||
487 | |||
488 | populateRemoteView(); | ||
489 | } else { | ||
463 | currentRemoteDir = currentRemoteDir+strItem; | 490 | currentRemoteDir = currentRemoteDir+strItem; |
491 | } | ||
464 | } else { | 492 | } else { |
465 | qDebug("download "+strItem); | 493 | qDebug("download "+strItem); |
@@ -480,5 +508,5 @@ void OpieFtp::remoteListClicked(QListViewItem *selectedItem) | |||
480 | if(strItem.find("@",0,TRUE) !=-1 || strItem.find("->",0,TRUE) !=-1 ) { //if symlink | 508 | if(strItem.find("@",0,TRUE) !=-1 || strItem.find("->",0,TRUE) !=-1 ) { //if symlink |
481 | // is symlink | 509 | // is symlink |
482 | QString strItem2=strItem.right( (strItem.length()-strItem.find("->",0,TRUE)) -4); | 510 | QString strItem2 = strItem.right( (strItem.length() - strItem.find("->",0,TRUE)) - 4); |
483 | if(QDir(strItem2).exists() ) { | 511 | if(QDir(strItem2).exists() ) { |
484 | currentDir.cd(strItem2, TRUE); | 512 | currentDir.cd(strItem2, TRUE); |
@@ -628,4 +656,5 @@ void OpieFtp::remoteMakDir() | |||
628 | QString msg; | 656 | QString msg; |
629 | msg.sprintf("Unable to make directory\n%s",FtpLastResponse(conn)); | 657 | msg.sprintf("Unable to make directory\n%s",FtpLastResponse(conn)); |
658 | msg.replace(QRegExp(":"),"\n"); | ||
630 | QMessageBox::message("Note",msg); | 659 | QMessageBox::message("Note",msg); |
631 | } | 660 | } |
@@ -648,4 +677,5 @@ void OpieFtp::remoteDelete() | |||
648 | QString msg; | 677 | QString msg; |
649 | msg.sprintf("Unable to remove directory\n%s",FtpLastResponse(conn)); | 678 | msg.sprintf("Unable to remove directory\n%s",FtpLastResponse(conn)); |
679 | msg.replace(QRegExp(":"),"\n"); | ||
650 | QMessageBox::message("Note",msg); | 680 | QMessageBox::message("Note",msg); |
651 | } | 681 | } |
@@ -661,4 +691,5 @@ void OpieFtp::remoteDelete() | |||
661 | QString msg; | 691 | QString msg; |
662 | msg.sprintf("Unable to delete file\n%s",FtpLastResponse(conn)); | 692 | msg.sprintf("Unable to delete file\n%s",FtpLastResponse(conn)); |
693 | msg.replace(QRegExp(":"),"\n"); | ||
663 | QMessageBox::message("Note",msg); | 694 | QMessageBox::message("Note",msg); |
664 | } | 695 | } |
@@ -684,4 +715,5 @@ void OpieFtp::remoteRename() | |||
684 | QString msg; | 715 | QString msg; |
685 | msg.sprintf("Unable to rename file\n%s",FtpLastResponse(conn)); | 716 | msg.sprintf("Unable to rename file\n%s",FtpLastResponse(conn)); |
717 | msg.replace(QRegExp(":"),"\n"); | ||
686 | QMessageBox::message("Note",msg); | 718 | QMessageBox::message("Note",msg); |
687 | } | 719 | } |
@@ -709,4 +741,6 @@ void OpieFtp::localRename() | |||
709 | void OpieFtp::currentPathEditChanged() | 741 | void OpieFtp::currentPathEditChanged() |
710 | { | 742 | { |
743 | QString oldRemoteCurrentDir = currentRemoteDir; | ||
744 | qDebug("oldRemoteCurrentDir "+oldRemoteCurrentDir); | ||
711 | if (TabWidget->currentPageIndex() == 0) { | 745 | if (TabWidget->currentPageIndex() == 0) { |
712 | if(QDir( currentPathEdit->text()).exists()) { | 746 | if(QDir( currentPathEdit->text()).exists()) { |
@@ -723,5 +757,9 @@ void OpieFtp::currentPathEditChanged() | |||
723 | currentPathEdit->setText( currentRemoteDir ); | 757 | currentPathEdit->setText( currentRemoteDir ); |
724 | } | 758 | } |
725 | remoteChDir( (const QString &)currentRemoteDir); | 759 | if( !remoteChDir( (const QString &)currentRemoteDir) ) { |
760 | currentRemoteDir = oldRemoteCurrentDir; | ||
761 | currentPathEdit->setText( currentRemoteDir ); | ||
762 | } | ||
763 | |||
726 | remoteDirList( (const QString &)currentRemoteDir); | 764 | remoteDirList( (const QString &)currentRemoteDir); |
727 | } | 765 | } |
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 | |||
@@ -88,4 +88,7 @@ protected slots: | |||
88 | void localRename(); | 88 | void localRename(); |
89 | void currentPathEditChanged(); | 89 | void currentPathEditChanged(); |
90 | protected: | ||
91 | void nullifyCallBack(); | ||
92 | |||
90 | }; | 93 | }; |
91 | 94 | ||