summaryrefslogtreecommitdiff
authorllornkcor <llornkcor>2002-04-30 12:13:14 (UTC)
committer llornkcor <llornkcor>2002-04-30 12:13:14 (UTC)
commit99ae08c3e872fb9dcbba8057ee98f9f1687d0af1 (patch) (unidiff)
tree48546f25bfd565839687cde043e5ab1079098ae6
parent713aa4385e859c9300ee2a5b0086fbaabf3b3a33 (diff)
downloadopie-99ae08c3e872fb9dcbba8057ee98f9f1687d0af1.zip
opie-99ae08c3e872fb9dcbba8057ee98f9f1687d0af1.tar.gz
opie-99ae08c3e872fb9dcbba8057ee98f9f1687d0af1.tar.bz2
took out QCop busy() because its too slow to respond, fixed titlebar after disconnect still showing ftp server info
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/net/opieftp/opieftp.cpp35
1 files changed, 18 insertions, 17 deletions
diff --git a/noncore/net/opieftp/opieftp.cpp b/noncore/net/opieftp/opieftp.cpp
index 6684abb..6d0be57 100644
--- a/noncore/net/opieftp/opieftp.cpp
+++ b/noncore/net/opieftp/opieftp.cpp
@@ -345,291 +345,292 @@ void OpieFtp::tabChanged(QWidget *w)
345 currentPathCombo->lineEdit()->setText( currentRemoteDir ); 345 currentPathCombo->lineEdit()->setText( currentRemoteDir );
346 tabMenu->setItemChecked(tabMenu->idAt(1),TRUE); 346 tabMenu->setItemChecked(tabMenu->idAt(1),TRUE);
347 tabMenu->setItemChecked(tabMenu->idAt(0),FALSE); 347 tabMenu->setItemChecked(tabMenu->idAt(0),FALSE);
348 tabMenu->setItemChecked(tabMenu->idAt(2),FALSE); 348 tabMenu->setItemChecked(tabMenu->idAt(2),FALSE);
349 if(cdUpButton->isHidden()) 349 if(cdUpButton->isHidden())
350 cdUpButton->show(); 350 cdUpButton->show();
351 homeButton->hide(); 351 homeButton->hide();
352 352
353 } 353 }
354 if (TabWidget->currentPageIndex() == 2) { 354 if (TabWidget->currentPageIndex() == 2) {
355 tabMenu->setItemChecked(tabMenu->idAt(2),TRUE); 355 tabMenu->setItemChecked(tabMenu->idAt(2),TRUE);
356 tabMenu->setItemChecked(tabMenu->idAt(0),FALSE); 356 tabMenu->setItemChecked(tabMenu->idAt(0),FALSE);
357 tabMenu->setItemChecked(tabMenu->idAt(1),FALSE); 357 tabMenu->setItemChecked(tabMenu->idAt(1),FALSE);
358 cdUpButton->hide(); 358 cdUpButton->hide();
359 homeButton->hide(); 359 homeButton->hide();
360 } 360 }
361} 361}
362 362
363void OpieFtp::newConnection() 363void OpieFtp::newConnection()
364{ 364{
365 UsernameComboBox->lineEdit()->setText(""); 365 UsernameComboBox->lineEdit()->setText("");
366 PasswordEdit->setText( "" ); 366 PasswordEdit->setText( "" );
367 ServerComboBox->lineEdit()->setText( ""); 367 ServerComboBox->lineEdit()->setText( "");
368 remotePath->setText( currentRemoteDir = "/"); 368 remotePath->setText( currentRemoteDir = "/");
369 PortSpinBox->setValue( 21); 369 PortSpinBox->setValue( 21);
370 TabWidget->setCurrentPage(2); 370 TabWidget->setCurrentPage(2);
371} 371}
372 372
373void OpieFtp::serverComboEdited(const QString & edit) 373void OpieFtp::serverComboEdited(const QString & edit)
374{ 374{
375 if( ServerComboBox->text(currentServerConfig) != edit /*edit.isEmpty() */) { 375 if( ServerComboBox->text(currentServerConfig) != edit /*edit.isEmpty() */) {
376 qDebug("ServerComboEdited"); 376 qDebug("ServerComboEdited");
377 currentServerConfig = -1; 377 currentServerConfig = -1;
378 } 378 }
379} 379}
380 380
381void OpieFtp::connectorBtnToggled(bool On) 381void OpieFtp::connectorBtnToggled(bool On)
382{ 382{
383 if(On) { 383 if(On) {
384 connector(); 384 connector();
385 } else { 385 } else {
386 disConnector(); 386 disConnector();
387 } 387 }
388 388
389} 389}
390 390
391void OpieFtp::connector() 391void OpieFtp::connector()
392{ 392{
393 QCopEnvelope ( "QPE/System", "busy()" ); 393// QCopEnvelope ( "QPE/System", "busy()" );
394// qApp->processEvents(); 394// qApp->processEvents();
395 currentRemoteDir=remotePath->text(); 395 currentRemoteDir=remotePath->text();
396 if(ServerComboBox->currentText().isEmpty()) { 396 if(ServerComboBox->currentText().isEmpty()) {
397 QMessageBox::warning(this,tr("Ftp"),tr("Please set the server info"),tr("Ok"),0,0); 397 QMessageBox::warning(this,tr("Ftp"),tr("Please set the server info"),tr("Ok"),0,0);
398 TabWidget->setCurrentPage(2); 398 TabWidget->setCurrentPage(2);
399 ServerComboBox->setFocus(); 399 ServerComboBox->setFocus();
400 connectServerBtn->setOn(FALSE); 400 connectServerBtn->setOn(FALSE);
401 connectServerBtn->setText( tr("Connect")); 401 connectServerBtn->setText( tr("Connect"));
402 return; 402 return;
403 } 403 }
404 FtpInit(); 404 FtpInit();
405 TabWidget->setCurrentPage(1); 405 TabWidget->setCurrentPage(1);
406 QString ftp_host = ServerComboBox->currentText(); 406 QString ftp_host = ServerComboBox->currentText();
407 QString ftp_user = UsernameComboBox->currentText(); 407 QString ftp_user = UsernameComboBox->currentText();
408 QString ftp_pass = PasswordEdit->text(); 408 QString ftp_pass = PasswordEdit->text();
409 QString port=PortSpinBox->cleanText(); 409 QString port=PortSpinBox->cleanText();
410 port.stripWhiteSpace(); 410 port.stripWhiteSpace();
411 411
412 if(ftp_host.find("ftp://",0, TRUE) != -1 ) 412 if(ftp_host.find("ftp://",0, TRUE) != -1 )
413 ftp_host=ftp_host.right(ftp_host.length()-6); 413 ftp_host=ftp_host.right(ftp_host.length()-6);
414 ftp_host+=":"+port; 414 ftp_host+=":"+port;
415 if (!FtpConnect( ftp_host.latin1(), &conn)) { 415 if (!FtpConnect( ftp_host.latin1(), &conn)) {
416 QMessageBox::message(tr("Note"),tr("Unable to connect to\n")+ftp_host); 416 QMessageBox::message(tr("Note"),tr("Unable to connect to\n")+ftp_host);
417 connectServerBtn->setOn(FALSE); 417 connectServerBtn->setOn(FALSE);
418 connectServerBtn->setText( tr("Connect")); 418 connectServerBtn->setText( tr("Connect"));
419 return ; 419 return ;
420 } 420 }
421 if (!FtpLogin( ftp_user.latin1(), ftp_pass.latin1(),conn )) { 421 if (!FtpLogin( ftp_user.latin1(), ftp_pass.latin1(),conn )) {
422 QString msg; 422 QString msg;
423 msg.sprintf(tr("Unable to log in\n")+"%s",FtpLastResponse(conn)); 423 msg.sprintf(tr("Unable to log in\n")+"%s",FtpLastResponse(conn));
424 msg.replace(QRegExp(":"),"\n"); 424 msg.replace(QRegExp(":"),"\n");
425 QMessageBox::message(tr("Note"),msg); 425 QMessageBox::message(tr("Note"),msg);
426 if(conn) 426 if(conn)
427 FtpQuit(conn); 427 FtpQuit(conn);
428 connectServerBtn->setOn(FALSE); 428 connectServerBtn->setOn(FALSE);
429 connectServerBtn->setText( tr("Connect")); 429 connectServerBtn->setText( tr("Connect"));
430 return ; 430 return ;
431 } 431 }
432 remoteDirList("/") ; 432 remoteDirList("/") ;
433 setCaption(ftp_host); 433 setCaption(ftp_host);
434 writeConfig(); 434 writeConfig();
435 connectServerBtn->setText( tr("Disconnect")); 435 connectServerBtn->setText( tr("Disconnect"));
436 QCopEnvelope ( "QPE/System", "notBusy()" ); 436// QCopEnvelope ( "QPE/System", "notBusy()" );
437} 437}
438 438
439void OpieFtp::disConnector() 439void OpieFtp::disConnector()
440{ 440{
441 if(conn) 441 if(conn)
442 FtpQuit(conn); 442 FtpQuit(conn);
443 setCaption("OpieFtp"); 443 setCaption("OpieFtp");
444 currentRemoteDir="/"; 444 currentRemoteDir="/";
445 Remote_View->clear(); 445 Remote_View->clear();
446 connectServerBtn->setText( tr("Connect")); 446 connectServerBtn->setText( tr("Connect"));
447 connectServerBtn->setOn(FALSE); 447 connectServerBtn->setOn(FALSE);
448 setCaption("OpieFtp");
448} 449}
449 450
450void OpieFtp::localUpload() 451void OpieFtp::localUpload()
451{ 452{
452 int fsz; 453 int fsz;
453// QCopEnvelope ( "QPE/System", "busy()" ); 454// QCopEnvelope ( "QPE/System", "busy()" );
454// qApp->processEvents(); 455// qApp->processEvents();
455 QList<QListViewItem> * getSelectedItems( QListView * Local_View ); 456 QList<QListViewItem> * getSelectedItems( QListView * Local_View );
456 QListViewItemIterator it( Local_View ); 457 QListViewItemIterator it( Local_View );
457 for ( ; it.current(); ++it ) { 458 for ( ; it.current(); ++it ) {
458 if ( it.current()->isSelected() ) { 459 if ( it.current()->isSelected() ) {
459 QString strItem = it.current()->text(0); 460 QString strItem = it.current()->text(0);
460 QString localFile = currentDir.canonicalPath()+"/"+strItem; 461 QString localFile = currentDir.canonicalPath()+"/"+strItem;
461 QString remoteFile= currentRemoteDir+strItem; 462 QString remoteFile= currentRemoteDir+strItem;
462 QFileInfo fi(localFile); 463 QFileInfo fi(localFile);
463 if( !fi.isDir()) { 464 if( !fi.isDir()) {
464 fsz=fi.size(); 465 fsz=fi.size();
465 ProgressBar->setTotalSteps(fsz); 466 ProgressBar->setTotalSteps(fsz);
466 467
467 FtpOptions(FTPLIB_CALLBACK, (long) log_progress, conn); 468 FtpOptions(FTPLIB_CALLBACK, (long) log_progress, conn);
468 FtpOptions(FTPLIB_IDLETIME, (long) 1000, conn); 469 FtpOptions(FTPLIB_IDLETIME, (long) 1000, conn);
469 FtpOptions(FTPLIB_CALLBACKARG, (long) &fsz, conn); 470 FtpOptions(FTPLIB_CALLBACKARG, (long) &fsz, conn);
470 FtpOptions(FTPLIB_CALLBACKBYTES, (long) fsz/10, conn); 471 FtpOptions(FTPLIB_CALLBACKBYTES, (long) fsz/10, conn);
471 qDebug("Put: %s, %s",localFile.latin1(),remoteFile.latin1()); 472 qDebug("Put: %s, %s",localFile.latin1(),remoteFile.latin1());
472 473
473 if( !FtpPut( localFile.latin1(), remoteFile.latin1(),FTPLIB_IMAGE, conn ) ) { 474 if( !FtpPut( localFile.latin1(), remoteFile.latin1(),FTPLIB_IMAGE, conn ) ) {
474 QString msg; 475 QString msg;
475 msg.sprintf(tr("Unable to upload\n")+"%s",FtpLastResponse(conn)); 476 msg.sprintf(tr("Unable to upload\n")+"%s",FtpLastResponse(conn));
476 msg.replace(QRegExp(":"),"\n"); 477 msg.replace(QRegExp(":"),"\n");
477 QMessageBox::message(tr("Note"),msg); 478 QMessageBox::message(tr("Note"),msg);
478 } 479 }
479 } else { 480 } else {
480 QMessageBox::message(tr("Note"),tr("Cannot upload directories")); 481 QMessageBox::message(tr("Note"),tr("Cannot upload directories"));
481 } 482 }
482 ProgressBar->reset(); 483 ProgressBar->reset();
483 nullifyCallBack(); 484 nullifyCallBack();
484 it.current()->setSelected(FALSE); 485 it.current()->setSelected(FALSE);
485 } //end currentSelected 486 } //end currentSelected
486 } 487 }
487 for ( ; it.current(); ++it ) { 488 for ( ; it.current(); ++it ) {
488 Local_View->clearSelection(); 489 Local_View->clearSelection();
489 } 490 }
490 Local_View->clearFocus(); 491 Local_View->clearFocus();
491 TabWidget->setCurrentPage(1); 492 TabWidget->setCurrentPage(1);
492 remoteDirList( (const QString &)currentRemoteDir); //this also calls populate 493 remoteDirList( (const QString &)currentRemoteDir); //this also calls populate
493 QCopEnvelope ( "QPE/System", "notBusy()" ); 494// QCopEnvelope ( "QPE/System", "notBusy()" );
494} 495}
495 496
496void OpieFtp::nullifyCallBack() 497void OpieFtp::nullifyCallBack()
497{ 498{
498 FtpOptions(FTPLIB_CALLBACK, NULL, conn); 499 FtpOptions(FTPLIB_CALLBACK, NULL, conn);
499 FtpOptions(FTPLIB_IDLETIME, NULL, conn); 500 FtpOptions(FTPLIB_IDLETIME, NULL, conn);
500 FtpOptions(FTPLIB_CALLBACKARG, NULL, conn); 501 FtpOptions(FTPLIB_CALLBACKARG, NULL, conn);
501 FtpOptions(FTPLIB_CALLBACKBYTES, NULL, conn); 502 FtpOptions(FTPLIB_CALLBACKBYTES, NULL, conn);
502} 503}
503 504
504void OpieFtp::remoteDownload() 505void OpieFtp::remoteDownload()
505{ 506{
506// qApp->processEvents(); 507// qApp->processEvents();
507 int fsz; 508 int fsz;
508 QCopEnvelope ( "QPE/System", "busy()" ); 509// QCopEnvelope ( "QPE/System", "busy()" );
509 510
510 QList<QListViewItem> * getSelectedItems( QListView * Remote_View ); 511 QList<QListViewItem> * getSelectedItems( QListView * Remote_View );
511 QListViewItemIterator it( Remote_View ); 512 QListViewItemIterator it( Remote_View );
512 for ( ; it.current(); ++it ) { 513 for ( ; it.current(); ++it ) {
513 if ( it.current()->isSelected() ) { 514 if ( it.current()->isSelected() ) {
514 QString strItem = it.current()->text(0); 515 QString strItem = it.current()->text(0);
515// strItem=strItem.right(strItem.length()-1); 516// strItem=strItem.right(strItem.length()-1);
516 QString localFile = currentDir.canonicalPath(); 517 QString localFile = currentDir.canonicalPath();
517 if(localFile.right(1).find("/",0,TRUE) == -1) 518 if(localFile.right(1).find("/",0,TRUE) == -1)
518 localFile += "/"; 519 localFile += "/";
519 localFile += strItem; 520 localFile += strItem;
520// QString localFile = currentDir.canonicalPath()+"/"+strItem; 521// QString localFile = currentDir.canonicalPath()+"/"+strItem;
521 QString remoteFile= currentRemoteDir+strItem; 522 QString remoteFile= currentRemoteDir+strItem;
522 if (!FtpSize( remoteFile.latin1(), &fsz, FTPLIB_ASCII, conn)) 523 if (!FtpSize( remoteFile.latin1(), &fsz, FTPLIB_ASCII, conn))
523 fsz = 0; 524 fsz = 0;
524 QString temp; 525 QString temp;
525 temp.sprintf( remoteFile+" "+" %dkb", fsz); 526 temp.sprintf( remoteFile+" "+" %dkb", fsz);
526 527
527 ProgressBar->setTotalSteps(fsz); 528 ProgressBar->setTotalSteps(fsz);
528 FtpOptions(FTPLIB_CALLBACK, (long) log_progress, conn); 529 FtpOptions(FTPLIB_CALLBACK, (long) log_progress, conn);
529 FtpOptions(FTPLIB_IDLETIME, (long) 1000, conn); 530 FtpOptions(FTPLIB_IDLETIME, (long) 1000, conn);
530 FtpOptions(FTPLIB_CALLBACKARG, (long) &fsz, conn); 531 FtpOptions(FTPLIB_CALLBACKARG, (long) &fsz, conn);
531 FtpOptions(FTPLIB_CALLBACKBYTES, (long) fsz/10, conn); 532 FtpOptions(FTPLIB_CALLBACKBYTES, (long) fsz/10, conn);
532 qDebug("Get: %s, %s",localFile.latin1(),remoteFile.latin1()); 533 qDebug("Get: %s, %s",localFile.latin1(),remoteFile.latin1());
533 534
534 if(!FtpGet( localFile.latin1(), remoteFile.latin1(),FTPLIB_IMAGE, conn ) ) { 535 if(!FtpGet( localFile.latin1(), remoteFile.latin1(),FTPLIB_IMAGE, conn ) ) {
535 QString msg; 536 QString msg;
536 msg.sprintf(tr("Unable to download \n")+"%s",FtpLastResponse(conn)); 537 msg.sprintf(tr("Unable to download \n")+"%s",FtpLastResponse(conn));
537 msg.replace(QRegExp(":"),"\n"); 538 msg.replace(QRegExp(":"),"\n");
538 QMessageBox::message(tr("Note"),msg); 539 QMessageBox::message(tr("Note"),msg);
539 } 540 }
540 ProgressBar->reset(); 541 ProgressBar->reset();
541 nullifyCallBack(); 542 nullifyCallBack();
542 it.current()->setSelected(FALSE); 543 it.current()->setSelected(FALSE);
543 } 544 }
544 } 545 }
545 for ( ; it.current(); ++it ) { 546 for ( ; it.current(); ++it ) {
546 Remote_View->clearSelection(); 547 Remote_View->clearSelection();
547 } 548 }
548 Remote_View->setFocus(); 549 Remote_View->setFocus();
549 TabWidget->setCurrentPage(0); 550 TabWidget->setCurrentPage(0);
550 populateLocalView(); 551 populateLocalView();
551 QCopEnvelope ( "QPE/System", "notBusy()" ); 552// QCopEnvelope ( "QPE/System", "notBusy()" );
552} 553}
553 554
554bool OpieFtp::remoteDirList(const QString &dir) 555bool OpieFtp::remoteDirList(const QString &dir)
555{ 556{
556 QString tmp = QDir::homeDirPath(); 557 QString tmp = QDir::homeDirPath();
557 if(tmp.right(1) != "/") 558 if(tmp.right(1) != "/")
558 tmp+="/._temp"; 559 tmp+="/._temp";
559 else 560 else
560 tmp+="._temp"; 561 tmp+="._temp";
561// qDebug("Listing remote dir "+tmp); 562// qDebug("Listing remote dir "+tmp);
562 QCopEnvelope ( "QPE/System", "busy()" ); 563// QCopEnvelope ( "QPE/System", "busy()" );
563 if (!FtpDir( tmp.latin1(), dir.latin1(), conn) ) { 564 if (!FtpDir( tmp.latin1(), dir.latin1(), conn) ) {
564 QString msg; 565 QString msg;
565 msg.sprintf(tr("Unable to list the directory\n")+dir+"\n%s",FtpLastResponse(conn) ); 566 msg.sprintf(tr("Unable to list the directory\n")+dir+"\n%s",FtpLastResponse(conn) );
566 msg.replace(QRegExp(":"),"\n"); 567 msg.replace(QRegExp(":"),"\n");
567 QMessageBox::message(tr("Note"),msg); 568 QMessageBox::message(tr("Note"),msg);
568 return false; 569 return false;
569 } 570 }
570 populateRemoteView() ; 571 populateRemoteView() ;
571 QCopEnvelope ( "QPE/System", "notBusy()" ); 572// QCopEnvelope ( "QPE/System", "notBusy()" );
572 return true; 573 return true;
573} 574}
574 575
575bool OpieFtp::remoteChDir(const QString &dir) 576bool OpieFtp::remoteChDir(const QString &dir)
576{ 577{
577 QCopEnvelope ( "QPE/System", "busy()" ); 578// QCopEnvelope ( "QPE/System", "busy()" );
578 if (!FtpChdir( dir.latin1(), conn )) { 579 if (!FtpChdir( dir.latin1(), conn )) {
579 QString msg; 580 QString msg;
580 msg.sprintf(tr("Unable to change directories\n")+dir+"\n%s",FtpLastResponse(conn)); 581 msg.sprintf(tr("Unable to change directories\n")+dir+"\n%s",FtpLastResponse(conn));
581 msg.replace(QRegExp(":"),"\n"); 582 msg.replace(QRegExp(":"),"\n");
582 QMessageBox::message(tr("Note"),msg); 583 QMessageBox::message(tr("Note"),msg);
583// qDebug(msg); 584// qDebug(msg);
584 QCopEnvelope ( "QPE/System", "notBusy()" ); 585// QCopEnvelope ( "QPE/System", "notBusy()" );
585 return FALSE; 586 return FALSE;
586 } 587 }
587 QCopEnvelope ( "QPE/System", "notBusy()" ); 588// QCopEnvelope ( "QPE/System", "notBusy()" );
588 return TRUE; 589 return TRUE;
589} 590}
590 591
591void OpieFtp::populateLocalView() 592void OpieFtp::populateLocalView()
592{ 593{
593 Local_View->clear(); 594 Local_View->clear();
594 currentDir.setSorting(/* QDir::Size*/ /*| QDir::Reversed | */QDir::DirsFirst); 595 currentDir.setSorting(/* QDir::Size*/ /*| QDir::Reversed | */QDir::DirsFirst);
595 currentDir.setMatchAllDirs(TRUE); 596 currentDir.setMatchAllDirs(TRUE);
596 currentDir.setNameFilter(filterStr); 597 currentDir.setNameFilter(filterStr);
597 QString fileL, fileS, fileDate; 598 QString fileL, fileS, fileDate;
598 bool isDir=FALSE; 599 bool isDir=FALSE;
599 const QFileInfoList *list = currentDir.entryInfoList( /*QDir::All*/ /*, QDir::SortByMask*/); 600 const QFileInfoList *list = currentDir.entryInfoList( /*QDir::All*/ /*, QDir::SortByMask*/);
600 QFileInfoListIterator it(*list); 601 QFileInfoListIterator it(*list);
601 QFileInfo *fi; 602 QFileInfo *fi;
602 while ( (fi=it.current()) ) { 603 while ( (fi=it.current()) ) {
603 if (fi->isSymLink() ){ 604 if (fi->isSymLink() ){
604 QString symLink=fi->readLink(); 605 QString symLink=fi->readLink();
605// qDebug("Symlink detected "+symLink); 606// qDebug("Symlink detected "+symLink);
606 QFileInfo sym( symLink); 607 QFileInfo sym( symLink);
607 fileS.sprintf( "%10li", sym.size() ); 608 fileS.sprintf( "%10li", sym.size() );
608 fileL.sprintf( "%s -> %s", sym.fileName().data(),sym.absFilePath().data() ); 609 fileL.sprintf( "%s -> %s", sym.fileName().data(),sym.absFilePath().data() );
609 fileDate = sym.lastModified().toString(); 610 fileDate = sym.lastModified().toString();
610 } else { 611 } else {
611// qDebug("Not a dir: "+currentDir.canonicalPath()+fileL); 612// qDebug("Not a dir: "+currentDir.canonicalPath()+fileL);
612 fileS.sprintf( "%10li", fi->size() ); 613 fileS.sprintf( "%10li", fi->size() );
613 fileL.sprintf( "%s",fi->fileName().data() ); 614 fileL.sprintf( "%s",fi->fileName().data() );
614 fileDate= fi->lastModified().toString(); 615 fileDate= fi->lastModified().toString();
615 if( QDir(QDir::cleanDirPath(currentDir.canonicalPath()+"/"+fileL)).exists() ) { 616 if( QDir(QDir::cleanDirPath(currentDir.canonicalPath()+"/"+fileL)).exists() ) {
616 fileL+="/"; 617 fileL+="/";
617 isDir=TRUE; 618 isDir=TRUE;
618// qDebug( fileL); 619// qDebug( fileL);
619 } 620 }
620 } 621 }
621 if(fileL !="./" && fi->exists()) { 622 if(fileL !="./" && fi->exists()) {
622 item= new QListViewItem( Local_View,fileL, fileDate, fileS ); 623 item= new QListViewItem( Local_View,fileL, fileDate, fileS );
623 QPixmap pm; 624 QPixmap pm;
624 625
625 if(isDir || fileL.find("/",0,TRUE) != -1) { 626 if(isDir || fileL.find("/",0,TRUE) != -1) {
626 if( !QDir( fi->filePath() ).isReadable()) 627 if( !QDir( fi->filePath() ).isReadable())
627 pm = Resource::loadPixmap( "lockedfolder" ); 628 pm = Resource::loadPixmap( "lockedfolder" );
628 else 629 else
629 pm= Resource::loadPixmap( "folder" ); 630 pm= Resource::loadPixmap( "folder" );
630 item->setPixmap( 0,pm ); 631 item->setPixmap( 0,pm );
631 } else { 632 } else {
632 if( !fi->isReadable() ) 633 if( !fi->isReadable() )
633 pm = Resource::loadPixmap( "locked" ); 634 pm = Resource::loadPixmap( "locked" );
634 else { 635 else {
635 MimeType mt(fi->filePath()); 636 MimeType mt(fi->filePath());
@@ -710,97 +711,97 @@ bool OpieFtp::populateRemoteView( )
710 Remote_View->setSorting( 4,TRUE); 711 Remote_View->setSorting( 4,TRUE);
711 return true; 712 return true;
712} 713}
713 714
714void OpieFtp::remoteListClicked(QListViewItem *selectedItem) 715void OpieFtp::remoteListClicked(QListViewItem *selectedItem)
715{ 716{
716 if( selectedItem) { 717 if( selectedItem) {
717// QCopEnvelope ( "QPE/System", "busy()" ); 718// QCopEnvelope ( "QPE/System", "busy()" );
718 QString oldRemoteCurrentDir = currentRemoteDir; 719 QString oldRemoteCurrentDir = currentRemoteDir;
719 QString strItem=selectedItem->text(0); 720 QString strItem=selectedItem->text(0);
720 strItem=strItem.simplifyWhiteSpace(); 721 strItem=strItem.simplifyWhiteSpace();
721 if(strItem == "../") { // the user wants to go ^ 722 if(strItem == "../") { // the user wants to go ^
722 if( FtpCDUp( conn) == 0) { 723 if( FtpCDUp( conn) == 0) {
723 QString msg; 724 QString msg;
724 msg.sprintf(tr("Unable to cd up\n")+"%s",FtpLastResponse(conn)); 725 msg.sprintf(tr("Unable to cd up\n")+"%s",FtpLastResponse(conn));
725 msg.replace(QRegExp(":"),"\n"); 726 msg.replace(QRegExp(":"),"\n");
726 QMessageBox::message(tr("Note"),msg); 727 QMessageBox::message(tr("Note"),msg);
727// qDebug(msg); 728// qDebug(msg);
728 } 729 }
729 char path[256]; 730 char path[256];
730 if( FtpPwd( path,sizeof(path),conn) == 0) { //this is easier than fudging the string 731 if( FtpPwd( path,sizeof(path),conn) == 0) { //this is easier than fudging the string
731 QString msg; 732 QString msg;
732 msg.sprintf(tr("Unable to get working dir\n")+"%s",FtpLastResponse(conn)); 733 msg.sprintf(tr("Unable to get working dir\n")+"%s",FtpLastResponse(conn));
733 msg.replace(QRegExp(":"),"\n"); 734 msg.replace(QRegExp(":"),"\n");
734 QMessageBox::message(tr("Note"),msg); 735 QMessageBox::message(tr("Note"),msg);
735// qDebug(msg); 736// qDebug(msg);
736 } 737 }
737 currentRemoteDir=path; 738 currentRemoteDir=path;
738 } else { 739 } else {
739 if(strItem.find("->",0,TRUE) != -1) { //symlink on some servers 740 if(strItem.find("->",0,TRUE) != -1) { //symlink on some servers
740 strItem=strItem.right( strItem.length() - strItem.find("->",0,TRUE) - 2 ); 741 strItem=strItem.right( strItem.length() - strItem.find("->",0,TRUE) - 2 );
741 strItem = strItem.stripWhiteSpace(); 742 strItem = strItem.stripWhiteSpace();
742 currentRemoteDir = strItem; 743 currentRemoteDir = strItem;
743 if( !remoteChDir( (const QString &)strItem)) { 744 if( !remoteChDir( (const QString &)strItem)) {
744 currentRemoteDir = oldRemoteCurrentDir; 745 currentRemoteDir = oldRemoteCurrentDir;
745 strItem=""; 746 strItem="";
746// qDebug("RemoteCurrentDir1 "+oldRemoteCurrentDir); 747// qDebug("RemoteCurrentDir1 "+oldRemoteCurrentDir);
747 } 748 }
748 } else if(strItem.find("/",0,TRUE) != -1) { // this is a directory 749 } else if(strItem.find("/",0,TRUE) != -1) { // this is a directory
749 if( !remoteChDir( (const QString &)currentRemoteDir + strItem)) { 750 if( !remoteChDir( (const QString &)currentRemoteDir + strItem)) {
750 currentRemoteDir = oldRemoteCurrentDir; 751 currentRemoteDir = oldRemoteCurrentDir;
751 strItem=""; 752 strItem="";
752// qDebug("RemoteCurrentDir1 "+oldRemoteCurrentDir); 753// qDebug("RemoteCurrentDir1 "+oldRemoteCurrentDir);
753 754
754 } else { 755 } else {
755 currentRemoteDir = currentRemoteDir+strItem; 756 currentRemoteDir = currentRemoteDir+strItem;
756 } 757 }
757 } else { 758 } else {
758 QCopEnvelope ( "QPE/System", "notBusy()" ); 759// QCopEnvelope ( "QPE/System", "notBusy()" );
759 return; 760 return;
760 } 761 }
761 } 762 }
762 remoteDirList( (const QString &)currentRemoteDir); //this also calls populate 763 remoteDirList( (const QString &)currentRemoteDir); //this also calls populate
763 if(currentRemoteDir.right(1) !="/") 764 if(currentRemoteDir.right(1) !="/")
764 currentRemoteDir +="/"; 765 currentRemoteDir +="/";
765 currentPathCombo->lineEdit()->setText( currentRemoteDir); 766 currentPathCombo->lineEdit()->setText( currentRemoteDir);
766 fillRemoteCombo( (const QString &)currentRemoteDir); 767 fillRemoteCombo( (const QString &)currentRemoteDir);
767// QCopEnvelope ( "QPE/System", "notBusy()" ); 768// QCopEnvelope ( "QPE/System", "notBusy()" );
768 } 769 }
769} 770}
770 771
771void OpieFtp::localListClicked(QListViewItem *selectedItem) 772void OpieFtp::localListClicked(QListViewItem *selectedItem)
772{ 773{
773 if(selectedItem!= NULL) { 774 if(selectedItem!= NULL) {
774 775
775 QString strItem=selectedItem->text(0); 776 QString strItem=selectedItem->text(0);
776 QString strSize=selectedItem->text(1); 777 QString strSize=selectedItem->text(1);
777 strSize=strSize.stripWhiteSpace(); 778 strSize=strSize.stripWhiteSpace();
778 if(strItem.find("@",0,TRUE) !=-1 || strItem.find("->",0,TRUE) !=-1 ) { //if symlink 779 if(strItem.find("@",0,TRUE) !=-1 || strItem.find("->",0,TRUE) !=-1 ) { //if symlink
779 // is symlink 780 // is symlink
780 QString strItem2 = strItem.right( (strItem.length() - strItem.find("->",0,TRUE)) - 4); 781 QString strItem2 = strItem.right( (strItem.length() - strItem.find("->",0,TRUE)) - 4);
781 if(QDir(strItem2).exists() ) { 782 if(QDir(strItem2).exists() ) {
782 currentDir.cd(strItem2, TRUE); 783 currentDir.cd(strItem2, TRUE);
783 populateLocalView(); 784 populateLocalView();
784 } 785 }
785 } else { // not a symlink 786 } else { // not a symlink
786 if(strItem.find(". .",0,TRUE) && strItem.find("/",0,TRUE)!=-1 ) { 787 if(strItem.find(". .",0,TRUE) && strItem.find("/",0,TRUE)!=-1 ) {
787 788
788 if(QDir(QDir::cleanDirPath(currentDir.canonicalPath()+"/"+strItem)).exists() ) { 789 if(QDir(QDir::cleanDirPath(currentDir.canonicalPath()+"/"+strItem)).exists() ) {
789 strItem=QDir::cleanDirPath(currentDir.canonicalPath()+"/"+strItem); 790 strItem=QDir::cleanDirPath(currentDir.canonicalPath()+"/"+strItem);
790 currentDir.cd(strItem,FALSE); 791 currentDir.cd(strItem,FALSE);
791 populateLocalView(); 792 populateLocalView();
792 } else { 793 } else {
793 currentDir.cdUp(); 794 currentDir.cdUp();
794 populateLocalView(); 795 populateLocalView();
795 } 796 }
796 if(QDir(strItem).exists()){ 797 if(QDir(strItem).exists()){
797 currentDir.cd(strItem, TRUE); 798 currentDir.cd(strItem, TRUE);
798 populateLocalView(); 799 populateLocalView();
799 } 800 }
800 } else { 801 } else {
801 strItem=QDir::cleanDirPath(currentDir.canonicalPath()+"/"+strItem); 802 strItem=QDir::cleanDirPath(currentDir.canonicalPath()+"/"+strItem);
802 if( QFile::exists(strItem ) ) { 803 if( QFile::exists(strItem ) ) {
803 // qDebug("upload "+strItem); 804 // qDebug("upload "+strItem);
804 return; 805 return;
805 } 806 }
806 } //end not symlink 807 } //end not symlink
@@ -912,172 +913,172 @@ void OpieFtp::localDelete()
912 for ( ; it.current(); ++it ) { 913 for ( ; it.current(); ++it ) {
913 if ( it.current()->isSelected() ) { 914 if ( it.current()->isSelected() ) {
914 QString f = it.current()->text(0); 915 QString f = it.current()->text(0);
915 it.current()->setSelected(FALSE); 916 it.current()->setSelected(FALSE);
916 917
917// QString f = Local_View->currentItem()->text(0); 918// QString f = Local_View->currentItem()->text(0);
918 if(QDir(f).exists() ) { 919 if(QDir(f).exists() ) {
919 switch ( QMessageBox::warning(this,tr("Delete"),tr("Do you really want to delete\n")+f+ 920 switch ( QMessageBox::warning(this,tr("Delete"),tr("Do you really want to delete\n")+f+
920 tr(" ?\nIt must be empty"),tr("Yes"),tr("No"),0,0,1) ) { 921 tr(" ?\nIt must be empty"),tr("Yes"),tr("No"),0,0,1) ) {
921 case 0: { 922 case 0: {
922 f=currentDir.canonicalPath()+"/"+f; 923 f=currentDir.canonicalPath()+"/"+f;
923 QString cmd="rmdir "+f; 924 QString cmd="rmdir "+f;
924 system( cmd.latin1()); 925 system( cmd.latin1());
925 } 926 }
926 break; 927 break;
927 case 1: 928 case 1:
928 // exit 929 // exit
929 break; 930 break;
930 }; 931 };
931 932
932 } else { 933 } else {
933 switch ( QMessageBox::warning(this,tr("Delete"),tr("Do you really want to delete\n")+f 934 switch ( QMessageBox::warning(this,tr("Delete"),tr("Do you really want to delete\n")+f
934 +" ?",tr("Yes"),tr("No"),0,0,1) ) { 935 +" ?",tr("Yes"),tr("No"),0,0,1) ) {
935 case 0: { 936 case 0: {
936 f=currentDir.canonicalPath()+"/"+f; 937 f=currentDir.canonicalPath()+"/"+f;
937 QString cmd="rm "+f; 938 QString cmd="rm "+f;
938 system( cmd.latin1()); 939 system( cmd.latin1());
939 } 940 }
940 break; 941 break;
941 case 1: 942 case 1:
942 // exit 943 // exit
943 break; 944 break;
944 }; 945 };
945 } 946 }
946 } 947 }
947 } 948 }
948 populateLocalView(); 949 populateLocalView();
949 950
950} 951}
951 952
952void OpieFtp::remoteMakDir() 953void OpieFtp::remoteMakDir()
953{ 954{
954 InputDialog *fileDlg; 955 InputDialog *fileDlg;
955 fileDlg = new InputDialog(this,tr("Make Directory"),TRUE, 0); 956 fileDlg = new InputDialog(this,tr("Make Directory"),TRUE, 0);
956 fileDlg->exec(); 957 fileDlg->exec();
957 if( fileDlg->result() == 1 ) { 958 if( fileDlg->result() == 1 ) {
958 QString filename = fileDlg->LineEdit1->text();//+".playlist"; 959 QString filename = fileDlg->LineEdit1->text();//+".playlist";
959 QString tmp=currentRemoteDir+filename; 960 QString tmp=currentRemoteDir+filename;
960 QCopEnvelope ( "QPE/System", "busy()" ); 961// QCopEnvelope ( "QPE/System", "busy()" );
961 if(FtpMkdir( tmp.latin1(), conn) == 0) { 962 if(FtpMkdir( tmp.latin1(), conn) == 0) {
962 QString msg; 963 QString msg;
963 msg.sprintf(tr("Unable to make directory\n")+"%s",FtpLastResponse(conn)); 964 msg.sprintf(tr("Unable to make directory\n")+"%s",FtpLastResponse(conn));
964 msg.replace(QRegExp(":"),"\n"); 965 msg.replace(QRegExp(":"),"\n");
965 QMessageBox::message(tr("Note"),msg); 966 QMessageBox::message(tr("Note"),msg);
966 } 967 }
967 QCopEnvelope ( "QPE/System", "notBusy()" ); 968// QCopEnvelope ( "QPE/System", "notBusy()" );
968 remoteDirList( (const QString &)currentRemoteDir); //this also calls populate 969 remoteDirList( (const QString &)currentRemoteDir); //this also calls populate
969 } 970 }
970} 971}
971 972
972void OpieFtp::remoteDelete() 973void OpieFtp::remoteDelete()
973{ 974{
974 QList<QListViewItem> * getSelectedItems( QListView * Remote_View ); 975 QList<QListViewItem> * getSelectedItems( QListView * Remote_View );
975 QListViewItemIterator it( Remote_View ); 976 QListViewItemIterator it( Remote_View );
976 for ( ; it.current(); ++it ) { 977 for ( ; it.current(); ++it ) {
977 if ( it.current()->isSelected() ) { 978 if ( it.current()->isSelected() ) {
978 QString f = it.current()->text(0); 979 QString f = it.current()->text(0);
979// QString f = Remote_View->currentItem()->text(0); 980// QString f = Remote_View->currentItem()->text(0);
980 QCopEnvelope ( "QPE/System", "busy()" ); 981// QCopEnvelope ( "QPE/System", "busy()" );
981 if( f.right(1) =="/") { 982 if( f.right(1) =="/") {
982 QString path= currentRemoteDir+f; 983 QString path= currentRemoteDir+f;
983 switch ( QMessageBox::warning(this,tr("Delete"),tr("Do you really want to delete\n")+f+"?" 984 switch ( QMessageBox::warning(this,tr("Delete"),tr("Do you really want to delete\n")+f+"?"
984 ,tr("Yes"),tr("No"),0,0,1) ) { 985 ,tr("Yes"),tr("No"),0,0,1) ) {
985 case 0: { 986 case 0: {
986 f=currentDir.canonicalPath()+"/"+f; 987 f=currentDir.canonicalPath()+"/"+f;
987 if(FtpRmdir( path.latin1(), conn) ==0) { 988 if(FtpRmdir( path.latin1(), conn) ==0) {
988 QString msg; 989 QString msg;
989 msg.sprintf(tr("Unable to remove directory\n")+"%s",FtpLastResponse(conn)); 990 msg.sprintf(tr("Unable to remove directory\n")+"%s",FtpLastResponse(conn));
990 msg.replace(QRegExp(":"),"\n"); 991 msg.replace(QRegExp(":"),"\n");
991 QMessageBox::message(tr("Note"),msg); 992 QMessageBox::message(tr("Note"),msg);
992 } 993 }
993 remoteDirList( (const QString &)currentRemoteDir); //this also calls populate 994 remoteDirList( (const QString &)currentRemoteDir); //this also calls populate
994 } 995 }
995 break; 996 break;
996 }; 997 };
997 } else { 998 } else {
998 switch ( QMessageBox::warning(this,tr("Delete"),tr("Do you really want to delete\n")+f+"?" 999 switch ( QMessageBox::warning(this,tr("Delete"),tr("Do you really want to delete\n")+f+"?"
999 ,tr("Yes"),tr("No"),0,0,1) ) { 1000 ,tr("Yes"),tr("No"),0,0,1) ) {
1000 case 0: { 1001 case 0: {
1001 QString path= currentRemoteDir+f; 1002 QString path= currentRemoteDir+f;
1002 if(FtpDelete( path.latin1(), conn)==0) { 1003 if(FtpDelete( path.latin1(), conn)==0) {
1003 QString msg; 1004 QString msg;
1004 msg.sprintf(tr("Unable to delete file\n")+"%s",FtpLastResponse(conn)); 1005 msg.sprintf(tr("Unable to delete file\n")+"%s",FtpLastResponse(conn));
1005 msg.replace(QRegExp(":"),"\n"); 1006 msg.replace(QRegExp(":"),"\n");
1006 QMessageBox::message(tr("Note"),msg); 1007 QMessageBox::message(tr("Note"),msg);
1007 } 1008 }
1008 remoteDirList( (const QString &)currentRemoteDir); //this also calls populate 1009 remoteDirList( (const QString &)currentRemoteDir); //this also calls populate
1009 } 1010 }
1010 break; 1011 break;
1011 }; 1012 };
1012 } 1013 }
1013 } 1014 }
1014 } 1015 }
1015 QCopEnvelope ( "QPE/System", "notBusy()" ); 1016// QCopEnvelope ( "QPE/System", "notBusy()" );
1016} 1017}
1017 1018
1018void OpieFtp::remoteRename() 1019void OpieFtp::remoteRename()
1019{ 1020{
1020 QString curFile = Remote_View->currentItem()->text(0); 1021 QString curFile = Remote_View->currentItem()->text(0);
1021 InputDialog *fileDlg; 1022 InputDialog *fileDlg;
1022 fileDlg = new InputDialog(this,tr("Rename"),TRUE, 0); 1023 fileDlg = new InputDialog(this,tr("Rename"),TRUE, 0);
1023 fileDlg->setTextEdit((const QString &)curFile); 1024 fileDlg->setTextEdit((const QString &)curFile);
1024 fileDlg->exec(); 1025 fileDlg->exec();
1025 if( fileDlg->result() == 1 ) { 1026 if( fileDlg->result() == 1 ) {
1026 QString oldName = currentRemoteDir +"/"+ curFile; 1027 QString oldName = currentRemoteDir +"/"+ curFile;
1027 QString newName = currentRemoteDir +"/"+ fileDlg->LineEdit1->text();//+".playlist"; 1028 QString newName = currentRemoteDir +"/"+ fileDlg->LineEdit1->text();//+".playlist";
1028 QCopEnvelope ( "QPE/System", "busy()" ); 1029// QCopEnvelope ( "QPE/System", "busy()" );
1029 if(FtpRename( oldName.latin1(), newName.latin1(),conn) == 0) { 1030 if(FtpRename( oldName.latin1(), newName.latin1(),conn) == 0) {
1030 QString msg; 1031 QString msg;
1031 msg.sprintf(tr("Unable to rename file\n")+"%s",FtpLastResponse(conn)); 1032 msg.sprintf(tr("Unable to rename file\n")+"%s",FtpLastResponse(conn));
1032 msg.replace(QRegExp(":"),"\n"); 1033 msg.replace(QRegExp(":"),"\n");
1033 QMessageBox::message(tr("Note"),msg); 1034 QMessageBox::message(tr("Note"),msg);
1034 } 1035 }
1035 QCopEnvelope ( "QPE/System", "notBusy()" ); 1036// QCopEnvelope ( "QPE/System", "notBusy()" );
1036 remoteDirList( (const QString &)currentRemoteDir); //this also calls populate 1037 remoteDirList( (const QString &)currentRemoteDir); //this also calls populate
1037 } 1038 }
1038} 1039}
1039 1040
1040void OpieFtp::localRename() 1041void OpieFtp::localRename()
1041{ 1042{
1042 QString curFile = Local_View->currentItem()->text(0); 1043 QString curFile = Local_View->currentItem()->text(0);
1043 InputDialog *fileDlg; 1044 InputDialog *fileDlg;
1044 fileDlg = new InputDialog(this,tr("Rename"),TRUE, 0); 1045 fileDlg = new InputDialog(this,tr("Rename"),TRUE, 0);
1045 fileDlg->setTextEdit((const QString &)curFile); 1046 fileDlg->setTextEdit((const QString &)curFile);
1046 fileDlg->exec(); 1047 fileDlg->exec();
1047 if( fileDlg->result() == 1 ) { 1048 if( fileDlg->result() == 1 ) {
1048 QString oldname = currentDir.canonicalPath() + "/" + curFile; 1049 QString oldname = currentDir.canonicalPath() + "/" + curFile;
1049 QString newName = currentDir.canonicalPath() + "/" + fileDlg->LineEdit1->text();//+".playlist"; 1050 QString newName = currentDir.canonicalPath() + "/" + fileDlg->LineEdit1->text();//+".playlist";
1050 if( rename(oldname.latin1(), newName.latin1())== -1) 1051 if( rename(oldname.latin1(), newName.latin1())== -1)
1051 QMessageBox::message(tr("Note"),tr("Could not rename")); 1052 QMessageBox::message(tr("Note"),tr("Could not rename"));
1052 } 1053 }
1053 populateLocalView(); 1054 populateLocalView();
1054} 1055}
1055 1056
1056void OpieFtp::currentPathComboActivated(const QString & currentPath) { 1057void OpieFtp::currentPathComboActivated(const QString & currentPath) {
1057 if (TabWidget->currentPageIndex() == 0) { 1058 if (TabWidget->currentPageIndex() == 0) {
1058 chdir( currentPath.latin1() ); 1059 chdir( currentPath.latin1() );
1059 currentDir.cd( currentPath, TRUE); 1060 currentDir.cd( currentPath, TRUE);
1060 populateLocalView(); 1061 populateLocalView();
1061 update(); 1062 update();
1062 } else { 1063 } else {
1063// chdir( currentPath.latin1() ); 1064// chdir( currentPath.latin1() );
1064// currentDir.cd( currentPath, TRUE); 1065// currentDir.cd( currentPath, TRUE);
1065// populateList(); 1066// populateList();
1066// update(); 1067// update();
1067 1068
1068 } 1069 }
1069} 1070}
1070 1071
1071void OpieFtp::fillCombo(const QString &currentPath) { 1072void OpieFtp::fillCombo(const QString &currentPath) {
1072 1073
1073 currentPathCombo->lineEdit()->setText(currentPath); 1074 currentPathCombo->lineEdit()->setText(currentPath);
1074 if( localDirPathStringList.grep(currentPath,TRUE).isEmpty() ) { 1075 if( localDirPathStringList.grep(currentPath,TRUE).isEmpty() ) {
1075 currentPathCombo->clear(); 1076 currentPathCombo->clear();
1076 localDirPathStringList.prepend(currentPath ); 1077 localDirPathStringList.prepend(currentPath );
1077 currentPathCombo->insertStringList( localDirPathStringList,-1); 1078 currentPathCombo->insertStringList( localDirPathStringList,-1);
1078 } 1079 }
1079 currentPathCombo->lineEdit()->setText(currentPath); 1080 currentPathCombo->lineEdit()->setText(currentPath);
1080 if( remoteDirPathStringList.grep(currentPath,TRUE).isEmpty() ) { 1081 if( remoteDirPathStringList.grep(currentPath,TRUE).isEmpty() ) {
1081 currentPathCombo->clear(); 1082 currentPathCombo->clear();
1082 remoteDirPathStringList.prepend(currentPath ); 1083 remoteDirPathStringList.prepend(currentPath );
1083 currentPathCombo->insertStringList( remoteDirPathStringList,-1); 1084 currentPathCombo->insertStringList( remoteDirPathStringList,-1);