author | llornkcor <llornkcor> | 2002-03-17 01:20:09 (UTC) |
---|---|---|
committer | llornkcor <llornkcor> | 2002-03-17 01:20:09 (UTC) |
commit | 2fe80a98551e89b45798369f1bf91f0368382ba6 (patch) (unidiff) | |
tree | a09d8dd51306563faf3496a05cbaca987665b365 | |
parent | 6fa31a92ee5ae6b4e9df2713b0ed7b8fb39fff49 (diff) | |
download | opie-2fe80a98551e89b45798369f1bf91f0368382ba6.zip opie-2fe80a98551e89b45798369f1bf91f0368382ba6.tar.gz opie-2fe80a98551e89b45798369f1bf91f0368382ba6.tar.bz2 |
fixed problem with remote directory not being listed after an upload, and fixed
problem with temp file poop with strewn throughout the local filesystem.
-rw-r--r-- | noncore/net/opieftp/opieftp.cpp | 51 | ||||
-rw-r--r-- | noncore/net/opieftp/opieftp.h | 0 |
2 files changed, 36 insertions, 15 deletions
diff --git a/noncore/net/opieftp/opieftp.cpp b/noncore/net/opieftp/opieftp.cpp index 042ed59..6a3a64d 100644 --- a/noncore/net/opieftp/opieftp.cpp +++ b/noncore/net/opieftp/opieftp.cpp | |||
@@ -243,15 +243,20 @@ OpieFtp::~OpieFtp() | |||
243 | } | 243 | } |
244 | 244 | ||
245 | void OpieFtp::cleanUp() | 245 | void OpieFtp::cleanUp() |
246 | { | 246 | { |
247 | if(conn) | 247 | if(conn) |
248 | FtpQuit(conn); | 248 | FtpQuit(conn); |
249 | QFile f("./._temp"); | 249 | QString sfile=QDir::homeDirPath(); |
250 | if(f.exists()) | 250 | if(sfile.right(1) != "/") |
251 | f. remove(); | 251 | sfile+="/._temp"; |
252 | else | ||
253 | sfile+="._temp"; | ||
254 | QFile file( sfile); | ||
255 | if(file.exists()) | ||
256 | file.remove(); | ||
252 | } | 257 | } |
253 | 258 | ||
254 | void OpieFtp::tabChanged(QWidget *w) | 259 | void OpieFtp::tabChanged(QWidget *w) |
255 | { | 260 | { |
256 | if (TabWidget->currentPageIndex() == 0) { | 261 | if (TabWidget->currentPageIndex() == 0) { |
257 | currentPathEdit->setText( currentDir.canonicalPath()); | 262 | currentPathEdit->setText( currentDir.canonicalPath()); |
@@ -292,13 +297,13 @@ void OpieFtp::localUpload() | |||
292 | ProgressBar->reset(); | 297 | ProgressBar->reset(); |
293 | nullifyCallBack(); | 298 | nullifyCallBack(); |
294 | } else { | 299 | } else { |
295 | QMessageBox::message("Note","Cannot upload directories"); | 300 | QMessageBox::message("Note","Cannot upload directories"); |
296 | } | 301 | } |
297 | TabWidget->setCurrentPage(1); | 302 | TabWidget->setCurrentPage(1); |
298 | populateRemoteView(); | 303 | remoteDirList( (const QString &)currentRemoteDir); //this also calls populate |
299 | QCopEnvelope ( "QPE/System", "notBusy()" ); | 304 | QCopEnvelope ( "QPE/System", "notBusy()" ); |
300 | } | 305 | } |
301 | 306 | ||
302 | void OpieFtp::nullifyCallBack() | 307 | void OpieFtp::nullifyCallBack() |
303 | { | 308 | { |
304 | FtpOptions(FTPLIB_CALLBACK, NULL, conn); | 309 | FtpOptions(FTPLIB_CALLBACK, NULL, conn); |
@@ -394,14 +399,20 @@ void OpieFtp::disConnector() | |||
394 | currentRemoteDir="/"; | 399 | currentRemoteDir="/"; |
395 | Remote_View->clear(); | 400 | Remote_View->clear(); |
396 | } | 401 | } |
397 | 402 | ||
398 | bool OpieFtp::remoteDirList(const QString &dir) | 403 | bool OpieFtp::remoteDirList(const QString &dir) |
399 | { | 404 | { |
405 | QString tmp = QDir::homeDirPath(); | ||
406 | if(tmp.right(1) != "/") | ||
407 | tmp+="/._temp"; | ||
408 | else | ||
409 | tmp+="._temp"; | ||
410 | // qDebug("Listing remote dir "+tmp); | ||
400 | QCopEnvelope ( "QPE/System", "busy()" ); | 411 | QCopEnvelope ( "QPE/System", "busy()" ); |
401 | if (!FtpDir( "./._temp", dir.latin1(), conn) ) { | 412 | if (!FtpDir( tmp.latin1(), dir.latin1(), conn) ) { |
402 | QString msg; | 413 | QString msg; |
403 | msg.sprintf("Unable to list the directory\n"+dir+"\n%s",FtpLastResponse(conn) ); | 414 | msg.sprintf("Unable to list the directory\n"+dir+"\n%s",FtpLastResponse(conn) ); |
404 | msg.replace(QRegExp(":"),"\n"); | 415 | msg.replace(QRegExp(":"),"\n"); |
405 | QMessageBox::message("Note",msg); | 416 | QMessageBox::message("Note",msg); |
406 | // FtpQuit(conn); | 417 | // FtpQuit(conn); |
407 | return false; | 418 | return false; |
@@ -462,19 +473,25 @@ void OpieFtp::populateLocalView() | |||
462 | Local_View->setSorting( 3,FALSE); | 473 | Local_View->setSorting( 3,FALSE); |
463 | currentPathEdit->setText( currentDir.canonicalPath() ); | 474 | currentPathEdit->setText( currentDir.canonicalPath() ); |
464 | } | 475 | } |
465 | 476 | ||
466 | bool OpieFtp::populateRemoteView() | 477 | bool OpieFtp::populateRemoteView() |
467 | { | 478 | { |
479 | // qDebug("populate remoteview"); | ||
480 | QString sfile=QDir::homeDirPath(); | ||
481 | if(sfile.right(1) != "/") | ||
482 | sfile+="/._temp"; | ||
483 | else | ||
484 | sfile+="._temp"; | ||
485 | QFile file( sfile); | ||
468 | Remote_View->clear(); | 486 | Remote_View->clear(); |
469 | QFile tmp("./._temp"); | ||
470 | QString s, File_Name; | 487 | QString s, File_Name; |
471 | QString fileL, fileS, fileDate; | 488 | QString fileL, fileS, fileDate; |
472 | new QListViewItem( Remote_View, "../"); | 489 | new QListViewItem( Remote_View, "../"); |
473 | if (tmp.open(IO_ReadOnly)) { | 490 | if ( file.open(IO_ReadOnly)) { |
474 | QTextStream t( &tmp ); // use a text stream | 491 | QTextStream t( &file ); // use a text stream |
475 | while ( !t.eof()) { | 492 | while ( !t.eof()) { |
476 | s = t.readLine(); | 493 | s = t.readLine(); |
477 | fileL = s.right(s.length()-55); | 494 | fileL = s.right(s.length()-55); |
478 | fileL = fileL.stripWhiteSpace(); | 495 | fileL = fileL.stripWhiteSpace(); |
479 | if(s.left(1) == "d") | 496 | if(s.left(1) == "d") |
480 | fileL = fileL+"/"; | 497 | fileL = fileL+"/"; |
@@ -482,15 +499,18 @@ bool OpieFtp::populateRemoteView() | |||
482 | fileS = fileS.stripWhiteSpace(); | 499 | fileS = fileS.stripWhiteSpace(); |
483 | fileDate = s.mid( 42, 55-42); | 500 | fileDate = s.mid( 42, 55-42); |
484 | fileDate = fileDate.stripWhiteSpace(); | 501 | fileDate = fileDate.stripWhiteSpace(); |
485 | if(fileL.find("total",0,TRUE) == -1) | 502 | if(fileL.find("total",0,TRUE) == -1) |
486 | new QListViewItem( Remote_View, fileL, fileS, fileDate); | 503 | new QListViewItem( Remote_View, fileL, fileS, fileDate); |
487 | } | 504 | } |
488 | tmp.close(); | 505 | file.close(); |
506 | if( file.exists()) | ||
507 | file. remove(); | ||
489 | } else | 508 | } else |
490 | qDebug("temp file not opened successfullly"); | 509 | qDebug("temp file not opened successfullly "+sfile); |
510 | |||
491 | return true; | 511 | return true; |
492 | } | 512 | } |
493 | 513 | ||
494 | void OpieFtp::remoteListClicked(QListViewItem *selectedItem) | 514 | void OpieFtp::remoteListClicked(QListViewItem *selectedItem) |
495 | { | 515 | { |
496 | QCopEnvelope ( "QPE/System", "busy()" ); | 516 | QCopEnvelope ( "QPE/System", "busy()" ); |
@@ -519,34 +539,32 @@ void OpieFtp::remoteListClicked(QListViewItem *selectedItem) | |||
519 | strItem=strItem.right( strItem.length() - strItem.find("->",0,TRUE) - 2 ); | 539 | strItem=strItem.right( strItem.length() - strItem.find("->",0,TRUE) - 2 ); |
520 | strItem = strItem.stripWhiteSpace(); | 540 | strItem = strItem.stripWhiteSpace(); |
521 | currentRemoteDir = strItem; | 541 | currentRemoteDir = strItem; |
522 | if( !remoteChDir( (const QString &)strItem)) { | 542 | if( !remoteChDir( (const QString &)strItem)) { |
523 | currentRemoteDir = oldRemoteCurrentDir; | 543 | currentRemoteDir = oldRemoteCurrentDir; |
524 | strItem=""; | 544 | strItem=""; |
525 | populateRemoteView(); | ||
526 | qDebug("RemoteCurrentDir1 "+oldRemoteCurrentDir); | 545 | qDebug("RemoteCurrentDir1 "+oldRemoteCurrentDir); |
527 | } | 546 | } |
528 | } else if(strItem.find("/",0,TRUE) != -1) { // this is a directory | 547 | } else if(strItem.find("/",0,TRUE) != -1) { // this is a directory |
529 | qDebug("trying directory"); | 548 | qDebug("trying directory"); |
530 | if( !remoteChDir( (const QString &)currentRemoteDir + strItem)) { | 549 | if( !remoteChDir( (const QString &)currentRemoteDir + strItem)) { |
531 | currentRemoteDir = oldRemoteCurrentDir; | 550 | currentRemoteDir = oldRemoteCurrentDir; |
532 | strItem=""; | 551 | strItem=""; |
533 | qDebug("RemoteCurrentDir1 "+oldRemoteCurrentDir); | 552 | qDebug("RemoteCurrentDir1 "+oldRemoteCurrentDir); |
534 | 553 | ||
535 | populateRemoteView(); | ||
536 | } else { | 554 | } else { |
537 | currentRemoteDir = currentRemoteDir+strItem; | 555 | currentRemoteDir = currentRemoteDir+strItem; |
538 | } | 556 | } |
539 | } else { | 557 | } else { |
540 | qDebug("download "+strItem); | 558 | qDebug("download "+strItem); |
541 | } | 559 | } |
542 | } | 560 | } |
561 | remoteDirList( (const QString &)currentRemoteDir); //this also calls populate | ||
543 | if(currentRemoteDir.right(1) !="/") | 562 | if(currentRemoteDir.right(1) !="/") |
544 | currentRemoteDir +="/"; | 563 | currentRemoteDir +="/"; |
545 | currentPathEdit->setText( currentRemoteDir ); | 564 | currentPathEdit->setText( currentRemoteDir ); |
546 | remoteDirList( (const QString &)currentRemoteDir); | ||
547 | QCopEnvelope ( "QPE/System", "notBusy()" ); | 565 | QCopEnvelope ( "QPE/System", "notBusy()" ); |
548 | } | 566 | } |
549 | 567 | ||
550 | void OpieFtp::localListClicked(QListViewItem *selectedItem) | 568 | void OpieFtp::localListClicked(QListViewItem *selectedItem) |
551 | { | 569 | { |
552 | QString strItem=selectedItem->text(0); | 570 | QString strItem=selectedItem->text(0); |
@@ -721,14 +739,14 @@ void OpieFtp::remoteMakDir() | |||
721 | QString msg; | 739 | QString msg; |
722 | msg.sprintf("Unable to make directory\n%s",FtpLastResponse(conn)); | 740 | msg.sprintf("Unable to make directory\n%s",FtpLastResponse(conn)); |
723 | msg.replace(QRegExp(":"),"\n"); | 741 | msg.replace(QRegExp(":"),"\n"); |
724 | QMessageBox::message("Note",msg); | 742 | QMessageBox::message("Note",msg); |
725 | } | 743 | } |
726 | QCopEnvelope ( "QPE/System", "notBusy()" ); | 744 | QCopEnvelope ( "QPE/System", "notBusy()" ); |
745 | remoteDirList( (const QString &)currentRemoteDir); //this also calls populate | ||
727 | } | 746 | } |
728 | populateRemoteView(); | ||
729 | } | 747 | } |
730 | 748 | ||
731 | void OpieFtp::remoteDelete() | 749 | void OpieFtp::remoteDelete() |
732 | { | 750 | { |
733 | QString f = Remote_View->currentItem()->text(0); | 751 | QString f = Remote_View->currentItem()->text(0); |
734 | QCopEnvelope ( "QPE/System", "busy()" ); | 752 | QCopEnvelope ( "QPE/System", "busy()" ); |
@@ -741,12 +759,14 @@ void OpieFtp::remoteDelete() | |||
741 | if(FtpRmdir( path.latin1(), conn) ==0) { | 759 | if(FtpRmdir( path.latin1(), conn) ==0) { |
742 | QString msg; | 760 | QString msg; |
743 | msg.sprintf("Unable to remove directory\n%s",FtpLastResponse(conn)); | 761 | msg.sprintf("Unable to remove directory\n%s",FtpLastResponse(conn)); |
744 | msg.replace(QRegExp(":"),"\n"); | 762 | msg.replace(QRegExp(":"),"\n"); |
745 | QMessageBox::message("Note",msg); | 763 | QMessageBox::message("Note",msg); |
746 | } | 764 | } |
765 | remoteDirList( (const QString &)currentRemoteDir); //this also calls populate | ||
766 | |||
747 | } | 767 | } |
748 | break; | 768 | break; |
749 | }; | 769 | }; |
750 | } else { | 770 | } else { |
751 | switch ( QMessageBox::warning(this,"Delete","Do you really want to delete\n"+f+"?" | 771 | switch ( QMessageBox::warning(this,"Delete","Do you really want to delete\n"+f+"?" |
752 | ,"Yes","No",0,0,1) ) { | 772 | ,"Yes","No",0,0,1) ) { |
@@ -755,12 +775,13 @@ void OpieFtp::remoteDelete() | |||
755 | if(FtpDelete( path.latin1(), conn)==0) { | 775 | if(FtpDelete( path.latin1(), conn)==0) { |
756 | QString msg; | 776 | QString msg; |
757 | msg.sprintf("Unable to delete file\n%s",FtpLastResponse(conn)); | 777 | msg.sprintf("Unable to delete file\n%s",FtpLastResponse(conn)); |
758 | msg.replace(QRegExp(":"),"\n"); | 778 | msg.replace(QRegExp(":"),"\n"); |
759 | QMessageBox::message("Note",msg); | 779 | QMessageBox::message("Note",msg); |
760 | } | 780 | } |
781 | remoteDirList( (const QString &)currentRemoteDir); //this also calls populate | ||
761 | } | 782 | } |
762 | break; | 783 | break; |
763 | }; | 784 | }; |
764 | } | 785 | } |
765 | QCopEnvelope ( "QPE/System", "notBusy()" ); | 786 | QCopEnvelope ( "QPE/System", "notBusy()" ); |
766 | } | 787 | } |
@@ -780,14 +801,14 @@ void OpieFtp::remoteRename() | |||
780 | QString msg; | 801 | QString msg; |
781 | msg.sprintf("Unable to rename file\n%s",FtpLastResponse(conn)); | 802 | msg.sprintf("Unable to rename file\n%s",FtpLastResponse(conn)); |
782 | msg.replace(QRegExp(":"),"\n"); | 803 | msg.replace(QRegExp(":"),"\n"); |
783 | QMessageBox::message("Note",msg); | 804 | QMessageBox::message("Note",msg); |
784 | } | 805 | } |
785 | QCopEnvelope ( "QPE/System", "notBusy()" ); | 806 | QCopEnvelope ( "QPE/System", "notBusy()" ); |
807 | remoteDirList( (const QString &)currentRemoteDir); //this also calls populate | ||
786 | } | 808 | } |
787 | populateRemoteView(); | ||
788 | } | 809 | } |
789 | 810 | ||
790 | void OpieFtp::localRename() | 811 | void OpieFtp::localRename() |
791 | { | 812 | { |
792 | QString curFile = Local_View->currentItem()->text(0); | 813 | QString curFile = Local_View->currentItem()->text(0); |
793 | InputDialog *fileDlg; | 814 | InputDialog *fileDlg; |
diff --git a/noncore/net/opieftp/opieftp.h b/noncore/net/opieftp/opieftp.h index e3ff334..1e5fffa 100644 --- a/noncore/net/opieftp/opieftp.h +++ b/noncore/net/opieftp/opieftp.h | |||