-rw-r--r-- | noncore/net/opieftp/opieftp.cpp | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/noncore/net/opieftp/opieftp.cpp b/noncore/net/opieftp/opieftp.cpp index 151be84..e1dd582 100644 --- a/noncore/net/opieftp/opieftp.cpp +++ b/noncore/net/opieftp/opieftp.cpp | |||
@@ -320,257 +320,266 @@ void OpieFtp::connector() | |||
320 | QMessageBox::message("Note",msg); | 320 | QMessageBox::message("Note",msg); |
321 | FtpQuit(conn); | 321 | FtpQuit(conn); |
322 | return ; | 322 | return ; |
323 | } | 323 | } |
324 | remoteDirList("/") ; | 324 | remoteDirList("/") ; |
325 | setCaption(ftp_host); | 325 | setCaption(ftp_host); |
326 | QCopEnvelope ( "QPE/System", "notBusy()" ); | 326 | QCopEnvelope ( "QPE/System", "notBusy()" ); |
327 | } | 327 | } |
328 | 328 | ||
329 | void OpieFtp::disConnector() | 329 | void OpieFtp::disConnector() |
330 | { | 330 | { |
331 | FtpQuit(conn); | 331 | FtpQuit(conn); |
332 | setCaption("OpieFtp"); | 332 | setCaption("OpieFtp"); |
333 | currentRemoteDir="/"; | 333 | currentRemoteDir="/"; |
334 | Remote_View->clear(); | 334 | Remote_View->clear(); |
335 | } | 335 | } |
336 | 336 | ||
337 | bool OpieFtp::remoteDirList(const QString &dir) | 337 | bool OpieFtp::remoteDirList(const QString &dir) |
338 | { | 338 | { |
339 | QCopEnvelope ( "QPE/System", "busy()" ); | 339 | QCopEnvelope ( "QPE/System", "busy()" ); |
340 | if (!FtpDir( "./._temp", dir.latin1(), conn) ) { | 340 | if (!FtpDir( "./._temp", dir.latin1(), conn) ) { |
341 | QString msg; | 341 | QString msg; |
342 | msg.sprintf("Unable to list the directory\n"+dir+"\n%s",FtpLastResponse(conn) ); | 342 | msg.sprintf("Unable to list the directory\n"+dir+"\n%s",FtpLastResponse(conn) ); |
343 | QMessageBox::message("Note",msg); | 343 | QMessageBox::message("Note",msg); |
344 | FtpQuit(conn); | 344 | FtpQuit(conn); |
345 | return false; | 345 | return false; |
346 | } | 346 | } |
347 | populateRemoteView(); | 347 | populateRemoteView(); |
348 | QCopEnvelope ( "QPE/System", "notBusy()" ); | 348 | QCopEnvelope ( "QPE/System", "notBusy()" ); |
349 | return true; | 349 | return true; |
350 | } | 350 | } |
351 | 351 | ||
352 | bool OpieFtp::remoteChDir(const QString &dir) | 352 | bool OpieFtp::remoteChDir(const QString &dir) |
353 | { | 353 | { |
354 | QCopEnvelope ( "QPE/System", "busy()" ); | 354 | QCopEnvelope ( "QPE/System", "busy()" ); |
355 | if (!FtpChdir( dir.latin1(), conn )) { | 355 | if (!FtpChdir( dir.latin1(), conn )) { |
356 | QString msg; | 356 | QString msg; |
357 | msg.sprintf("Unable to change directories "+dir+"\n%s",FtpLastResponse(conn)); | 357 | msg.sprintf("Unable to change directories "+dir+"\n%s",FtpLastResponse(conn)); |
358 | QMessageBox::message("Note",msg); | 358 | QMessageBox::message("Note",msg); |
359 | FtpQuit(conn); | 359 | FtpQuit(conn); |
360 | QCopEnvelope ( "QPE/System", "notBusy()" ); | 360 | QCopEnvelope ( "QPE/System", "notBusy()" ); |
361 | return FALSE; | 361 | return FALSE; |
362 | } | 362 | } |
363 | QCopEnvelope ( "QPE/System", "notBusy()" ); | 363 | QCopEnvelope ( "QPE/System", "notBusy()" ); |
364 | return TRUE; | 364 | return TRUE; |
365 | } | 365 | } |
366 | 366 | ||
367 | void OpieFtp::populateLocalView() | 367 | void OpieFtp::populateLocalView() |
368 | { | 368 | { |
369 | Local_View->clear(); | 369 | Local_View->clear(); |
370 | currentDir.setSorting(/* QDir::Size*/ /*| QDir::Reversed | */QDir::DirsFirst); | 370 | currentDir.setSorting(/* QDir::Size*/ /*| QDir::Reversed | */QDir::DirsFirst); |
371 | currentDir.setMatchAllDirs(TRUE); | 371 | currentDir.setMatchAllDirs(TRUE); |
372 | currentDir.setNameFilter(filterStr); | 372 | currentDir.setNameFilter(filterStr); |
373 | QString fileL, fileS, fileDate; | 373 | QString fileL, fileS, fileDate; |
374 | const QFileInfoList *list = currentDir.entryInfoList( /*QDir::All*/ /*, QDir::SortByMask*/); | 374 | const QFileInfoList *list = currentDir.entryInfoList( /*QDir::All*/ /*, QDir::SortByMask*/); |
375 | QFileInfoListIterator it(*list); | 375 | QFileInfoListIterator it(*list); |
376 | QFileInfo *fi; | 376 | QFileInfo *fi; |
377 | while ( (fi=it.current()) ) { | 377 | while ( (fi=it.current()) ) { |
378 | if (fi->isSymLink() ){ | 378 | if (fi->isSymLink() ){ |
379 | QString symLink=fi->readLink(); | 379 | QString symLink=fi->readLink(); |
380 | // qDebug("Symlink detected "+symLink); | 380 | // qDebug("Symlink detected "+symLink); |
381 | QFileInfo sym( symLink); | 381 | QFileInfo sym( symLink); |
382 | fileS.sprintf( "%10li", sym.size() ); | 382 | fileS.sprintf( "%10li", sym.size() ); |
383 | fileL.sprintf( "%s -> %s", sym.fileName().data(),sym.absFilePath().data() ); | 383 | fileL.sprintf( "%s -> %s", sym.fileName().data(),sym.absFilePath().data() ); |
384 | fileDate = sym.lastModified().toString(); | 384 | fileDate = sym.lastModified().toString(); |
385 | } else { | 385 | } else { |
386 | // qDebug("Not a dir: "+currentDir.canonicalPath()+fileL); | 386 | // qDebug("Not a dir: "+currentDir.canonicalPath()+fileL); |
387 | fileS.sprintf( "%10li", fi->size() ); | 387 | fileS.sprintf( "%10li", fi->size() ); |
388 | fileL.sprintf( "%s",fi->fileName().data() ); | 388 | fileL.sprintf( "%s",fi->fileName().data() ); |
389 | fileDate= fi->lastModified().toString(); | 389 | fileDate= fi->lastModified().toString(); |
390 | if( QDir(QDir::cleanDirPath(currentDir.canonicalPath()+"/"+fileL)).exists() ) { | 390 | if( QDir(QDir::cleanDirPath(currentDir.canonicalPath()+"/"+fileL)).exists() ) { |
391 | fileL+="/"; | 391 | fileL+="/"; |
392 | // qDebug( fileL); | 392 | // qDebug( fileL); |
393 | } | 393 | } |
394 | } | 394 | } |
395 | item= new QListViewItem( Local_View,fileL,fileS, fileDate); | 395 | item= new QListViewItem( Local_View,fileL,fileS, fileDate); |
396 | ++it; | 396 | ++it; |
397 | } | 397 | } |
398 | Local_View->setSorting( 3,FALSE); | 398 | Local_View->setSorting( 3,FALSE); |
399 | currentPathEdit->setText( currentDir.canonicalPath() ); | 399 | currentPathEdit->setText( currentDir.canonicalPath() ); |
400 | } | 400 | } |
401 | 401 | ||
402 | bool OpieFtp::populateRemoteView() | 402 | bool OpieFtp::populateRemoteView() |
403 | { | 403 | { |
404 | Remote_View->clear(); | 404 | Remote_View->clear(); |
405 | QFile tmp("./._temp"); | 405 | QFile tmp("./._temp"); |
406 | QString s, File_Name; | 406 | QString s, File_Name; |
407 | QString fileL, fileS, fileDate; | 407 | QString fileL, fileS, fileDate; |
408 | new QListViewItem( Remote_View, "../"); | 408 | new QListViewItem( Remote_View, "../"); |
409 | if (tmp.open(IO_ReadOnly)) { | 409 | if (tmp.open(IO_ReadOnly)) { |
410 | QTextStream t( &tmp ); // use a text stream | 410 | QTextStream t( &tmp ); // use a text stream |
411 | while ( !t.eof()) { | 411 | while ( !t.eof()) { |
412 | s = t.readLine(); | 412 | s = t.readLine(); |
413 | fileL = s.right(s.length()-55); | 413 | fileL = s.right(s.length()-55); |
414 | fileL = fileL.stripWhiteSpace(); | 414 | fileL = fileL.stripWhiteSpace(); |
415 | if(s.left(1) == "d") | 415 | if(s.left(1) == "d") |
416 | fileL = fileL+"/"; | 416 | fileL = fileL+"/"; |
417 | fileS = s.mid( 30, 42-30); | 417 | fileS = s.mid( 30, 42-30); |
418 | fileS = fileS.stripWhiteSpace(); | 418 | fileS = fileS.stripWhiteSpace(); |
419 | fileDate = s.mid( 42, 55-42); | 419 | fileDate = s.mid( 42, 55-42); |
420 | fileDate = fileDate.stripWhiteSpace(); | 420 | fileDate = fileDate.stripWhiteSpace(); |
421 | if(fileL.find("total",0,TRUE) == -1) | 421 | if(fileL.find("total",0,TRUE) == -1) |
422 | new QListViewItem( Remote_View, fileL, fileS, fileDate); | 422 | new QListViewItem( Remote_View, fileL, fileS, fileDate); |
423 | } | 423 | } |
424 | tmp.close(); | 424 | tmp.close(); |
425 | } | 425 | } |
426 | return true; | 426 | return true; |
427 | } | 427 | } |
428 | 428 | ||
429 | void OpieFtp::remoteListClicked(QListViewItem *selectedItem) | 429 | void OpieFtp::remoteListClicked(QListViewItem *selectedItem) |
430 | { | 430 | { |
431 | QCopEnvelope ( "QPE/System", "busy()" ); | 431 | QCopEnvelope ( "QPE/System", "busy()" ); |
432 | QString strItem=selectedItem->text(0); | 432 | QString strItem=selectedItem->text(0); |
433 | strItem=strItem.simplifyWhiteSpace(); | 433 | strItem=strItem.simplifyWhiteSpace(); |
434 | if(strItem == "../") { | 434 | if(strItem == "../") { |
435 | if( FtpCDUp( conn) == 0) { | 435 | if( FtpCDUp( conn) == 0) { |
436 | QString msg; | 436 | QString msg; |
437 | msg.sprintf("Unable to change directories \n%s",FtpLastResponse(conn)); | 437 | msg.sprintf("Unable to change directories \n%s",FtpLastResponse(conn)); |
438 | QMessageBox::message("Note",msg); | 438 | QMessageBox::message("Note",msg); |
439 | } | 439 | } |
440 | char path[256]; | 440 | char path[256]; |
441 | if( FtpPwd( path,sizeof(path),conn) == 0) { | 441 | if( FtpPwd( path,sizeof(path),conn) == 0) { |
442 | QString msg; | 442 | QString msg; |
443 | msg.sprintf("Unable to get working dir\n%s",FtpLastResponse(conn)); | 443 | msg.sprintf("Unable to get working dir\n%s",FtpLastResponse(conn)); |
444 | QMessageBox::message("Note",msg); | 444 | QMessageBox::message("Note",msg); |
445 | } | 445 | } |
446 | currentRemoteDir=path; | 446 | currentRemoteDir=path; |
447 | } else { | 447 | } else { |
448 | if(strItem.find("/",0,TRUE) != -1) { | 448 | if(strItem.find("->",0,TRUE) != -1) { //symlink on some servers |
449 | strItem=strItem.right( strItem.length() - strItem.find("->",0,TRUE)-3 ); | ||
450 | strItem = strItem.stripWhiteSpace(); | ||
451 | currentRemoteDir = strItem; | ||
452 | if( remoteChDir( (const QString &)strItem) ==0) { | ||
453 | QString msg; | ||
454 | msg.sprintf("Unable to change directories \n%s",FtpLastResponse(conn)); | ||
455 | QMessageBox::message("Note",msg); | ||
456 | } | ||
457 | } else if(strItem.find("/",0,TRUE) != -1) { | ||
449 | if( remoteChDir( (const QString &)currentRemoteDir+strItem) ==0) { | 458 | if( remoteChDir( (const QString &)currentRemoteDir+strItem) ==0) { |
450 | QString msg; | 459 | QString msg; |
451 | msg.sprintf("Unable to change directories \n%s",FtpLastResponse(conn)); | 460 | msg.sprintf("Unable to change directories \n%s",FtpLastResponse(conn)); |
452 | QMessageBox::message("Note",msg); | 461 | QMessageBox::message("Note",msg); |
453 | } | 462 | } |
454 | currentRemoteDir = currentRemoteDir+strItem; | 463 | currentRemoteDir = currentRemoteDir+strItem; |
455 | } else { | 464 | } else { |
456 | qDebug("download "+strItem); | 465 | qDebug("download "+strItem); |
457 | } | 466 | } |
458 | } | 467 | } |
459 | if(currentRemoteDir.right(1) !="/") | 468 | if(currentRemoteDir.right(1) !="/") |
460 | currentRemoteDir +="/"; | 469 | currentRemoteDir +="/"; |
461 | currentPathEdit->setText( currentRemoteDir ); | 470 | currentPathEdit->setText( currentRemoteDir ); |
462 | remoteDirList( (const QString &)currentRemoteDir); | 471 | remoteDirList( (const QString &)currentRemoteDir); |
463 | QCopEnvelope ( "QPE/System", "notBusy()" ); | 472 | QCopEnvelope ( "QPE/System", "notBusy()" ); |
464 | } | 473 | } |
465 | 474 | ||
466 | void OpieFtp::localListClicked(QListViewItem *selectedItem) | 475 | void OpieFtp::localListClicked(QListViewItem *selectedItem) |
467 | { | 476 | { |
468 | QString strItem=selectedItem->text(0); | 477 | QString strItem=selectedItem->text(0); |
469 | QString strSize=selectedItem->text(1); | 478 | QString strSize=selectedItem->text(1); |
470 | strSize=strSize.stripWhiteSpace(); | 479 | strSize=strSize.stripWhiteSpace(); |
471 | if(strItem.find("@",0,TRUE) !=-1 || strItem.find("->",0,TRUE) !=-1 ) { //if symlink | 480 | if(strItem.find("@",0,TRUE) !=-1 || strItem.find("->",0,TRUE) !=-1 ) { //if symlink |
472 | // is symlink | 481 | // is symlink |
473 | QString strItem2=strItem.right( (strItem.length()-strItem.find("->",0,TRUE)) -4); | 482 | QString strItem2=strItem.right( (strItem.length()-strItem.find("->",0,TRUE)) -4); |
474 | if(QDir(strItem2).exists() ) { | 483 | if(QDir(strItem2).exists() ) { |
475 | currentDir.cd(strItem2, TRUE); | 484 | currentDir.cd(strItem2, TRUE); |
476 | populateLocalView(); | 485 | populateLocalView(); |
477 | } | 486 | } |
478 | } else { // not a symlink | 487 | } else { // not a symlink |
479 | if(strItem.find(". .",0,TRUE) && strItem.find("/",0,TRUE)!=-1 ) { | 488 | if(strItem.find(". .",0,TRUE) && strItem.find("/",0,TRUE)!=-1 ) { |
480 | if(QDir(QDir::cleanDirPath(currentDir.canonicalPath()+"/"+strItem)).exists() ) { | 489 | if(QDir(QDir::cleanDirPath(currentDir.canonicalPath()+"/"+strItem)).exists() ) { |
481 | strItem=QDir::cleanDirPath(currentDir.canonicalPath()+"/"+strItem); | 490 | strItem=QDir::cleanDirPath(currentDir.canonicalPath()+"/"+strItem); |
482 | currentDir.cd(strItem,FALSE); | 491 | currentDir.cd(strItem,FALSE); |
483 | populateLocalView(); | 492 | populateLocalView(); |
484 | } else { | 493 | } else { |
485 | currentDir.cdUp(); | 494 | currentDir.cdUp(); |
486 | populateLocalView(); | 495 | populateLocalView(); |
487 | } | 496 | } |
488 | if(QDir(strItem).exists()){ | 497 | if(QDir(strItem).exists()){ |
489 | currentDir.cd(strItem, TRUE); | 498 | currentDir.cd(strItem, TRUE); |
490 | populateLocalView(); | 499 | populateLocalView(); |
491 | } | 500 | } |
492 | } else { | 501 | } else { |
493 | strItem=QDir::cleanDirPath(currentDir.canonicalPath()+"/"+strItem); | 502 | strItem=QDir::cleanDirPath(currentDir.canonicalPath()+"/"+strItem); |
494 | if( QFile::exists(strItem ) ) { | 503 | if( QFile::exists(strItem ) ) { |
495 | qDebug("upload "+strItem); | 504 | qDebug("upload "+strItem); |
496 | } | 505 | } |
497 | } //end not symlink | 506 | } //end not symlink |
498 | chdir(strItem.latin1()); | 507 | chdir(strItem.latin1()); |
499 | } | 508 | } |
500 | } | 509 | } |
501 | 510 | ||
502 | void OpieFtp::showHidden() | 511 | void OpieFtp::showHidden() |
503 | { | 512 | { |
504 | if (!b) { | 513 | if (!b) { |
505 | currentDir.setFilter( QDir::Files | QDir::Dirs | QDir::Hidden | QDir::All); | 514 | currentDir.setFilter( QDir::Files | QDir::Dirs | QDir::Hidden | QDir::All); |
506 | // currentDir.setSorting(/* QDir::Size*/ /*| QDir::Reversed | */QDir::DirsFirst); | 515 | // currentDir.setSorting(/* QDir::Size*/ /*| QDir::Reversed | */QDir::DirsFirst); |
507 | b=TRUE; | 516 | b=TRUE; |
508 | 517 | ||
509 | } else { | 518 | } else { |
510 | currentDir.setFilter( QDir::Files | QDir::Dirs/* | QDir::Hidden*/ | QDir::All); | 519 | currentDir.setFilter( QDir::Files | QDir::Dirs/* | QDir::Hidden*/ | QDir::All); |
511 | // currentDir.setSorting(/* QDir::Size*/ /*| QDir::Reversed | */QDir::DirsFirst); | 520 | // currentDir.setSorting(/* QDir::Size*/ /*| QDir::Reversed | */QDir::DirsFirst); |
512 | b=FALSE; | 521 | b=FALSE; |
513 | } | 522 | } |
514 | populateLocalView(); | 523 | populateLocalView(); |
515 | } | 524 | } |
516 | 525 | ||
517 | void OpieFtp::ListPressed( int mouse, QListViewItem *item, const QPoint &point, int i) | 526 | void OpieFtp::ListPressed( int mouse, QListViewItem *item, const QPoint &point, int i) |
518 | { | 527 | { |
519 | switch (mouse) { | 528 | switch (mouse) { |
520 | case 1: | 529 | case 1: |
521 | break; | 530 | break; |
522 | case 2: | 531 | case 2: |
523 | showLocalMenu(); | 532 | showLocalMenu(); |
524 | break; | 533 | break; |
525 | }; | 534 | }; |
526 | } | 535 | } |
527 | 536 | ||
528 | void OpieFtp::RemoteListPressed( int mouse, QListViewItem *item, const QPoint &point, int i) | 537 | void OpieFtp::RemoteListPressed( int mouse, QListViewItem *item, const QPoint &point, int i) |
529 | { | 538 | { |
530 | switch (mouse) { | 539 | switch (mouse) { |
531 | case 1: | 540 | case 1: |
532 | break; | 541 | break; |
533 | case 2: | 542 | case 2: |
534 | showRemoteMenu(); | 543 | showRemoteMenu(); |
535 | break; | 544 | break; |
536 | }; | 545 | }; |
537 | } | 546 | } |
538 | 547 | ||
539 | void OpieFtp::showRemoteMenu() | 548 | void OpieFtp::showRemoteMenu() |
540 | { | 549 | { |
541 | QPopupMenu m;// = new QPopupMenu( Local_View ); | 550 | QPopupMenu m;// = new QPopupMenu( Local_View ); |
542 | m.insertItem( tr( "Download" ), this, SLOT( remoteDownload() )); | 551 | m.insertItem( tr( "Download" ), this, SLOT( remoteDownload() )); |
543 | m.insertItem( tr( "Make Directory" ), this, SLOT( remoteMakDir() )); | 552 | m.insertItem( tr( "Make Directory" ), this, SLOT( remoteMakDir() )); |
544 | m.insertItem( tr( "Rename" ), this, SLOT( remoteRename() )); | 553 | m.insertItem( tr( "Rename" ), this, SLOT( remoteRename() )); |
545 | m.insertSeparator(); | 554 | m.insertSeparator(); |
546 | m.insertItem( tr( "Delete" ), this, SLOT( remoteDelete() )); | 555 | m.insertItem( tr( "Delete" ), this, SLOT( remoteDelete() )); |
547 | m.exec( QCursor::pos() ); | 556 | m.exec( QCursor::pos() ); |
548 | } | 557 | } |
549 | 558 | ||
550 | void OpieFtp::showLocalMenu() | 559 | void OpieFtp::showLocalMenu() |
551 | { | 560 | { |
552 | QPopupMenu m; | 561 | QPopupMenu m; |
553 | m.insertItem( tr( "Show Hidden Files" ), this, SLOT( showHidden() )); | 562 | m.insertItem( tr( "Show Hidden Files" ), this, SLOT( showHidden() )); |
554 | m.insertItem( tr( "Upload" ), this, SLOT( localUpload() )); | 563 | m.insertItem( tr( "Upload" ), this, SLOT( localUpload() )); |
555 | m.insertItem( tr( "Make Directory" ), this, SLOT( localMakDir() )); | 564 | m.insertItem( tr( "Make Directory" ), this, SLOT( localMakDir() )); |
556 | m.insertItem( tr( "Rename" ), this, SLOT( localRename() )); | 565 | m.insertItem( tr( "Rename" ), this, SLOT( localRename() )); |
557 | m.insertSeparator(); | 566 | m.insertSeparator(); |
558 | m.insertItem( tr( "Delete" ), this, SLOT( localDelete() )); | 567 | m.insertItem( tr( "Delete" ), this, SLOT( localDelete() )); |
559 | m.exec( QCursor::pos() ); | 568 | m.exec( QCursor::pos() ); |
560 | } | 569 | } |
561 | 570 | ||
562 | void OpieFtp::localMakDir() | 571 | void OpieFtp::localMakDir() |
563 | { | 572 | { |
564 | InputDialog *fileDlg; | 573 | InputDialog *fileDlg; |
565 | fileDlg = new InputDialog(this,"Make Directory",TRUE, 0); | 574 | fileDlg = new InputDialog(this,"Make Directory",TRUE, 0); |
566 | fileDlg->exec(); | 575 | fileDlg->exec(); |
567 | if( fileDlg->result() == 1 ) { | 576 | if( fileDlg->result() == 1 ) { |
568 | QString filename = fileDlg->LineEdit1->text(); | 577 | QString filename = fileDlg->LineEdit1->text(); |
569 | currentDir.mkdir( currentDir.canonicalPath()+"/"+filename); | 578 | currentDir.mkdir( currentDir.canonicalPath()+"/"+filename); |
570 | } | 579 | } |
571 | populateLocalView(); | 580 | populateLocalView(); |
572 | } | 581 | } |
573 | 582 | ||
574 | void OpieFtp::localDelete() | 583 | void OpieFtp::localDelete() |
575 | { | 584 | { |
576 | QString f = Local_View->currentItem()->text(0); | 585 | QString f = Local_View->currentItem()->text(0); |