summaryrefslogtreecommitdiff
path: root/noncore/net/opieftp/opieftp.cpp
Unidiff
Diffstat (limited to 'noncore/net/opieftp/opieftp.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/net/opieftp/opieftp.cpp256
1 files changed, 141 insertions, 115 deletions
diff --git a/noncore/net/opieftp/opieftp.cpp b/noncore/net/opieftp/opieftp.cpp
index fb57193..7f5d71c 100644
--- a/noncore/net/opieftp/opieftp.cpp
+++ b/noncore/net/opieftp/opieftp.cpp
@@ -134,80 +134,84 @@ OpieFtp::OpieFtp( )
134 homeButton->setFixedSize( QSize( 20, 20 ) ); 134 homeButton->setFixedSize( QSize( 20, 20 ) );
135 connect(homeButton,SIGNAL(released()),this,SLOT(homeButtonPushed()) ); 135 connect(homeButton,SIGNAL(released()),this,SLOT(homeButtonPushed()) );
136 homeButton->setFlat(TRUE); 136 homeButton->setFlat(TRUE);
137 layout->addMultiCellWidget( homeButton, 0, 0, 4, 4); 137 layout->addMultiCellWidget( homeButton, 0, 0, 4, 4);
138 homeButton->hide(); 138 homeButton->hide();
139 139
140 TabWidget = new QTabWidget( this, "TabWidget" ); 140 TabWidget = new QTabWidget( this, "TabWidget" );
141 layout->addMultiCellWidget( TabWidget, 1, 1, 0, 4 ); 141 layout->addMultiCellWidget( TabWidget, 1, 1, 0, 4 );
142 142
143// TabWidget->setTabShape(QTabWidget::Triangular); 143// TabWidget->setTabShape(QTabWidget::Triangular);
144 144
145 tab = new QWidget( TabWidget, "tab" ); 145 tab = new QWidget( TabWidget, "tab" );
146 tabLayout = new QGridLayout( tab ); 146 tabLayout = new QGridLayout( tab );
147 tabLayout->setSpacing( 2); 147 tabLayout->setSpacing( 2);
148 tabLayout->setMargin( 2); 148 tabLayout->setMargin( 2);
149 149
150 Local_View = new QListView( tab, "Local_View" ); 150 Local_View = new QListView( tab, "Local_View" );
151// Local_View->setResizePolicy( QListView::AutoOneFit ); 151// Local_View->setResizePolicy( QListView::AutoOneFit );
152 Local_View->addColumn( tr("File"),150); 152 Local_View->addColumn( tr("File"),150);
153 Local_View->addColumn( tr("Size"),-1); 153 Local_View->addColumn( tr("Size"),-1);
154 Local_View->setColumnAlignment(1,QListView::AlignRight); 154 Local_View->setColumnAlignment(1,QListView::AlignRight);
155 Local_View->addColumn( tr("Date"),-1); 155 Local_View->addColumn( tr("Date"),-1);
156 Local_View->setColumnAlignment(2,QListView::AlignRight); 156 Local_View->setColumnAlignment(2,QListView::AlignRight);
157 Local_View->setAllColumnsShowFocus(TRUE); 157 Local_View->setAllColumnsShowFocus(TRUE);
158 Local_View->setMultiSelection( TRUE ); 158
159 Local_View->setMultiSelection( TRUE);
159 Local_View->setSelectionMode(QListView::Extended); 160 Local_View->setSelectionMode(QListView::Extended);
161 Local_View->setFocusPolicy(QWidget::ClickFocus);
160 162
161 QPEApplication::setStylusOperation( Local_View->viewport(),QPEApplication::RightOnHold); 163 QPEApplication::setStylusOperation( Local_View->viewport(),QPEApplication::RightOnHold);
162 164
163 tabLayout->addWidget( Local_View, 0, 0 ); 165 tabLayout->addWidget( Local_View, 0, 0 );
164 166
165 connect( Local_View, SIGNAL( clicked( QListViewItem*)), 167 connect( Local_View, SIGNAL( clicked( QListViewItem*)),
166 this,SLOT( localListClicked(QListViewItem *)) ); 168 this,SLOT( localListClicked(QListViewItem *)) );
167// connect( Local_View, SIGNAL( doubleClicked( QListViewItem*)), 169// connect( Local_View, SIGNAL( doubleClicked( QListViewItem*)),
168// this,SLOT( localListClicked(QListViewItem *)) ); 170// this,SLOT( localListClicked(QListViewItem *)) );
169 connect( Local_View, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int)), 171 connect( Local_View, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int)),
170 this,SLOT( ListPressed(int, QListViewItem *, const QPoint&, int)) ); 172 this,SLOT( ListPressed(int, QListViewItem *, const QPoint&, int)) );
171 173
172 TabWidget->insertTab( tab, tr( "Local" ) ); 174 TabWidget->insertTab( tab, tr( "Local" ) );
173 175
174 tab_2 = new QWidget( TabWidget, "tab_2" ); 176 tab_2 = new QWidget( TabWidget, "tab_2" );
175 tabLayout_2 = new QGridLayout( tab_2 ); 177 tabLayout_2 = new QGridLayout( tab_2 );
176 tabLayout_2->setSpacing( 2); 178 tabLayout_2->setSpacing( 2);
177 tabLayout_2->setMargin( 2); 179 tabLayout_2->setMargin( 2);
178 180
179 Remote_View = new QListView( tab_2, "Remote_View" ); 181 Remote_View = new QListView( tab_2, "Remote_View" );
180 Remote_View->addColumn( tr("File"),150); 182 Remote_View->addColumn( tr("File"),150);
181 Remote_View->addColumn( tr("Size"),-1); 183 Remote_View->addColumn( tr("Size"),-1);
182 Remote_View->setColumnAlignment(1,QListView::AlignRight); 184 Remote_View->setColumnAlignment(1,QListView::AlignRight);
183 Remote_View->addColumn( tr("Date"),-1); 185 Remote_View->addColumn( tr("Date"),-1);
184 Remote_View->setColumnAlignment(2,QListView::AlignRight); 186 Remote_View->setColumnAlignment(2,QListView::AlignRight);
185 Remote_View->addColumn( tr("Dir"),-1); 187 Remote_View->addColumn( tr("Dir"),-1);
186 Remote_View->setColumnAlignment(4,QListView::AlignRight); 188 Remote_View->setColumnAlignment(4,QListView::AlignRight);
187 Remote_View->setAllColumnsShowFocus(TRUE); 189 Remote_View->setAllColumnsShowFocus(TRUE);
188 Remote_View->setMultiSelection( TRUE ); 190
191 Remote_View->setMultiSelection( FALSE);
189 Remote_View->setSelectionMode(QListView::Extended); 192 Remote_View->setSelectionMode(QListView::Extended);
193 Remote_View->setFocusPolicy(QWidget::ClickFocus);
190 194
191 QPEApplication::setStylusOperation( Remote_View->viewport(),QPEApplication::RightOnHold); 195 QPEApplication::setStylusOperation( Remote_View->viewport(),QPEApplication::RightOnHold);
192 196
193 connect( Remote_View, SIGNAL( clicked( QListViewItem*)), 197 connect( Remote_View, SIGNAL( clicked( QListViewItem*)),
194 this,SLOT( remoteListClicked(QListViewItem *)) ); 198 this,SLOT( remoteListClicked(QListViewItem *)) );
195 connect( Remote_View, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int)), 199 connect( Remote_View, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int)),
196 this,SLOT( RemoteListPressed(int, QListViewItem *, const QPoint&, int)) ); 200 this,SLOT( RemoteListPressed(int, QListViewItem *, const QPoint&, int)) );
197 201
198 tabLayout_2->addWidget( Remote_View, 0, 0 ); 202 tabLayout_2->addWidget( Remote_View, 0, 0 );
199 203
200 TabWidget->insertTab( tab_2, tr( "Remote" ) ); 204 TabWidget->insertTab( tab_2, tr( "Remote" ) );
201 205
202 tab_3 = new QWidget( TabWidget, "tab_3" ); 206 tab_3 = new QWidget( TabWidget, "tab_3" );
203 tabLayout_3 = new QGridLayout( tab_3 ); 207 tabLayout_3 = new QGridLayout( tab_3 );
204 tabLayout_3->setSpacing( 2); 208 tabLayout_3->setSpacing( 2);
205 tabLayout_3->setMargin( 2); 209 tabLayout_3->setMargin( 2);
206 210
207 TextLabel1 = new QLabel( tab_3, "TextLabel1" ); 211 TextLabel1 = new QLabel( tab_3, "TextLabel1" );
208 TextLabel1->setText( tr( "Username" ) ); 212 TextLabel1->setText( tr( "Username" ) );
209 tabLayout_3->addMultiCellWidget( TextLabel1, 0, 0, 0, 1 ); 213 tabLayout_3->addMultiCellWidget( TextLabel1, 0, 0, 0, 1 );
210 214
211 UsernameComboBox = new QComboBox( FALSE, tab_3, "UsernameComboBox" ); 215 UsernameComboBox = new QComboBox( FALSE, tab_3, "UsernameComboBox" );
212 UsernameComboBox->setEditable(TRUE); 216 UsernameComboBox->setEditable(TRUE);
213 tabLayout_3->addMultiCellWidget( UsernameComboBox, 1, 1, 0, 1 ); 217 tabLayout_3->addMultiCellWidget( UsernameComboBox, 1, 1, 0, 1 );
@@ -357,237 +361,243 @@ void OpieFtp::newConnection()
357 PortSpinBox->setValue( 21); 361 PortSpinBox->setValue( 21);
358 TabWidget->setCurrentPage(2); 362 TabWidget->setCurrentPage(2);
359} 363}
360 364
361void OpieFtp::serverComboEdited(const QString & edit) 365void OpieFtp::serverComboEdited(const QString & edit)
362{ 366{
363 if( ServerComboBox->text(currentServerConfig) != edit /*edit.isEmpty() */) { 367 if( ServerComboBox->text(currentServerConfig) != edit /*edit.isEmpty() */) {
364 qDebug("ServerComboEdited"); 368 qDebug("ServerComboEdited");
365 currentServerConfig = -1; 369 currentServerConfig = -1;
366 } 370 }
367} 371}
368 372
369void OpieFtp::connectorBtnToggled(bool On) 373void OpieFtp::connectorBtnToggled(bool On)
370{ 374{
371 if(On) { 375 if(On) {
372 connector(); 376 connector();
373 } else { 377 } else {
374 disConnector(); 378 disConnector();
375 } 379 }
376 380
377} 381}
378 382
379void OpieFtp::connector() 383void OpieFtp::connector()
380{ 384{
381// QCopEnvelope ( "QPE/System", "busy()" ); 385 QCopEnvelope ( "QPE/System", "busy()" );
382// qApp->processEvents(); 386// qApp->processEvents();
383 currentRemoteDir=remotePath->text(); 387 currentRemoteDir=remotePath->text();
384 if(ServerComboBox->currentText().isEmpty()) { 388 if(ServerComboBox->currentText().isEmpty()) {
385 QMessageBox::warning(this,tr("Ftp"),tr("Please set the server info"),tr("Ok"),0,0); 389 QMessageBox::warning(this,tr("Ftp"),tr("Please set the server info"),tr("Ok"),0,0);
386 TabWidget->setCurrentPage(2); 390 TabWidget->setCurrentPage(2);
387 ServerComboBox->setFocus(); 391 ServerComboBox->setFocus();
388 connectServerBtn->setOn(FALSE); 392 connectServerBtn->setOn(FALSE);
389 connectServerBtn->setText( tr("Connect")); 393 connectServerBtn->setText( tr("Connect"));
390 return; 394 return;
391 } 395 }
392 FtpInit(); 396 FtpInit();
393 TabWidget->setCurrentPage(1); 397 TabWidget->setCurrentPage(1);
394 QString ftp_host = ServerComboBox->currentText(); 398 QString ftp_host = ServerComboBox->currentText();
395 QString ftp_user = UsernameComboBox->currentText(); 399 QString ftp_user = UsernameComboBox->currentText();
396 QString ftp_pass = PasswordEdit->text(); 400 QString ftp_pass = PasswordEdit->text();
397 QString port=PortSpinBox->cleanText(); 401 QString port=PortSpinBox->cleanText();
398 port.stripWhiteSpace(); 402 port.stripWhiteSpace();
399 403
400 if(ftp_host.find("ftp://",0, TRUE) != -1 ) 404 if(ftp_host.find("ftp://",0, TRUE) != -1 )
401 ftp_host=ftp_host.right(ftp_host.length()-6); 405 ftp_host=ftp_host.right(ftp_host.length()-6);
402 ftp_host+=":"+port; 406 ftp_host+=":"+port;
403 if (!FtpConnect( ftp_host.latin1(), &conn)) { 407 if (!FtpConnect( ftp_host.latin1(), &conn)) {
404 QMessageBox::message(tr("Note"),tr("Unable to connect to\n")+ftp_host); 408 QMessageBox::message(tr("Note"),tr("Unable to connect to\n")+ftp_host);
405 connectServerBtn->setOn(FALSE); 409 connectServerBtn->setOn(FALSE);
406 connectServerBtn->setText( tr("Connect")); 410 connectServerBtn->setText( tr("Connect"));
407 return ; 411 return ;
408 } 412 }
409 if (!FtpLogin( ftp_user.latin1(), ftp_pass.latin1(),conn )) { 413 if (!FtpLogin( ftp_user.latin1(), ftp_pass.latin1(),conn )) {
410 QString msg; 414 QString msg;
411 msg.sprintf(tr("Unable to log in\n")+"%s",FtpLastResponse(conn)); 415 msg.sprintf(tr("Unable to log in\n")+"%s",FtpLastResponse(conn));
412 msg.replace(QRegExp(":"),"\n"); 416 msg.replace(QRegExp(":"),"\n");
413 QMessageBox::message(tr("Note"),msg); 417 QMessageBox::message(tr("Note"),msg);
414 if(conn) 418 if(conn)
415 FtpQuit(conn); 419 FtpQuit(conn);
416 connectServerBtn->setOn(FALSE); 420 connectServerBtn->setOn(FALSE);
417 connectServerBtn->setText( tr("Connect")); 421 connectServerBtn->setText( tr("Connect"));
418 return ; 422 return ;
419 } 423 }
420 remoteDirList("/") ; 424 remoteDirList("/") ;
421 setCaption(ftp_host); 425 setCaption(ftp_host);
422 writeConfig(); 426 writeConfig();
423 connectServerBtn->setText( tr("Disconnect")); 427 connectServerBtn->setText( tr("Disconnect"));
424// QCopEnvelope ( "QPE/System", "notBusy()" ); 428 QCopEnvelope ( "QPE/System", "notBusy()" );
425} 429}
426 430
427void OpieFtp::disConnector() 431void OpieFtp::disConnector()
428{ 432{
429 if(conn) 433 if(conn)
430 FtpQuit(conn); 434 FtpQuit(conn);
431 setCaption("OpieFtp"); 435 setCaption("OpieFtp");
432 currentRemoteDir="/"; 436 currentRemoteDir="/";
433 Remote_View->clear(); 437 Remote_View->clear();
434 connectServerBtn->setText( tr("Connect")); 438 connectServerBtn->setText( tr("Connect"));
435 connectServerBtn->setOn(FALSE); 439 connectServerBtn->setOn(FALSE);
436} 440}
437 441
438void OpieFtp::localUpload() 442void OpieFtp::localUpload()
439{ 443{
440 int fsz; 444 int fsz;
441// QCopEnvelope ( "QPE/System", "busy()" ); 445// QCopEnvelope ( "QPE/System", "busy()" );
442// qApp->processEvents(); 446// qApp->processEvents();
443 QList<QListViewItem> * getSelectedItems( QListView * Local_View ); 447 QList<QListViewItem> * getSelectedItems( QListView * Local_View );
444 QListViewItemIterator it( Local_View ); 448 QListViewItemIterator it( Local_View );
445 for ( ; it.current(); ++it ) { 449 for ( ; it.current(); ++it ) {
446 if ( it.current()->isSelected() ) { 450 if ( it.current()->isSelected() ) {
447 QString strItem = it.current()->text(0); 451 QString strItem = it.current()->text(0);
448 QString localFile = currentDir.canonicalPath()+"/"+strItem; 452 QString localFile = currentDir.canonicalPath()+"/"+strItem;
449 QString remoteFile= currentRemoteDir+strItem; 453 QString remoteFile= currentRemoteDir+strItem;
450 QFileInfo fi(localFile); 454 QFileInfo fi(localFile);
451 if( !fi.isDir()) { 455 if( !fi.isDir()) {
452 fsz=fi.size(); 456 fsz=fi.size();
453 ProgressBar->setTotalSteps(fsz); 457 ProgressBar->setTotalSteps(fsz);
454 458
455 FtpOptions(FTPLIB_CALLBACK, (long) log_progress, conn); 459 FtpOptions(FTPLIB_CALLBACK, (long) log_progress, conn);
456 FtpOptions(FTPLIB_IDLETIME, (long) 1000, conn); 460 FtpOptions(FTPLIB_IDLETIME, (long) 1000, conn);
457 FtpOptions(FTPLIB_CALLBACKARG, (long) &fsz, conn); 461 FtpOptions(FTPLIB_CALLBACKARG, (long) &fsz, conn);
458 FtpOptions(FTPLIB_CALLBACKBYTES, (long) fsz/10, conn); 462 FtpOptions(FTPLIB_CALLBACKBYTES, (long) fsz/10, conn);
459 qDebug("Put: %s, %s",localFile.latin1(),remoteFile.latin1()); 463 qDebug("Put: %s, %s",localFile.latin1(),remoteFile.latin1());
460 464
461 if( !FtpPut( localFile.latin1(), remoteFile.latin1(),FTPLIB_IMAGE, conn ) ) { 465 if( !FtpPut( localFile.latin1(), remoteFile.latin1(),FTPLIB_IMAGE, conn ) ) {
462 QString msg; 466 QString msg;
463 msg.sprintf(tr("Unable to upload\n")+"%s",FtpLastResponse(conn)); 467 msg.sprintf(tr("Unable to upload\n")+"%s",FtpLastResponse(conn));
464 msg.replace(QRegExp(":"),"\n"); 468 msg.replace(QRegExp(":"),"\n");
465 QMessageBox::message(tr("Note"),msg); 469 QMessageBox::message(tr("Note"),msg);
466 } 470 }
467 } else { 471 } else {
468 QMessageBox::message(tr("Note"),tr("Cannot upload directories")); 472 QMessageBox::message(tr("Note"),tr("Cannot upload directories"));
469 } 473 }
470 ProgressBar->reset(); 474 ProgressBar->reset();
471 nullifyCallBack(); 475 nullifyCallBack();
472 } //end currentSelected
473 it.current()->setSelected(FALSE); 476 it.current()->setSelected(FALSE);
477 } //end currentSelected
478 }
479 for ( ; it.current(); ++it ) {
480 Local_View->clearSelection();
474 } 481 }
482 Local_View->clearFocus();
475 TabWidget->setCurrentPage(1); 483 TabWidget->setCurrentPage(1);
476 remoteDirList( (const QString &)currentRemoteDir); //this also calls populate 484 remoteDirList( (const QString &)currentRemoteDir); //this also calls populate
477// QCopEnvelope ( "QPE/System", "notBusy()" ); 485 QCopEnvelope ( "QPE/System", "notBusy()" );
478
479} 486}
480 487
481void OpieFtp::nullifyCallBack() 488void OpieFtp::nullifyCallBack()
482{ 489{
483 FtpOptions(FTPLIB_CALLBACK, NULL, conn); 490 FtpOptions(FTPLIB_CALLBACK, NULL, conn);
484 FtpOptions(FTPLIB_IDLETIME, NULL, conn); 491 FtpOptions(FTPLIB_IDLETIME, NULL, conn);
485 FtpOptions(FTPLIB_CALLBACKARG, NULL, conn); 492 FtpOptions(FTPLIB_CALLBACKARG, NULL, conn);
486 FtpOptions(FTPLIB_CALLBACKBYTES, NULL, conn); 493 FtpOptions(FTPLIB_CALLBACKBYTES, NULL, conn);
487} 494}
488 495
489void OpieFtp::remoteDownload() 496void OpieFtp::remoteDownload()
490{ 497{
491// qApp->processEvents(); 498// qApp->processEvents();
492 int fsz; 499 int fsz;
493// QCopEnvelope ( "QPE/System", "busy()" ); 500 QCopEnvelope ( "QPE/System", "busy()" );
494 501
495 QList<QListViewItem> * getSelectedItems( QListView * Remote_View ); 502 QList<QListViewItem> * getSelectedItems( QListView * Remote_View );
496 QListViewItemIterator it( Remote_View ); 503 QListViewItemIterator it( Remote_View );
497 for ( ; it.current(); ++it ) { 504 for ( ; it.current(); ++it ) {
498 if ( it.current()->isSelected() ) { 505 if ( it.current()->isSelected() ) {
499 QString strItem = it.current()->text(0); 506 QString strItem = it.current()->text(0);
500// strItem=strItem.right(strItem.length()-1); 507// strItem=strItem.right(strItem.length()-1);
501 QString localFile = currentDir.canonicalPath(); 508 QString localFile = currentDir.canonicalPath();
502 if(localFile.right(1).find("/",0,TRUE) == -1) 509 if(localFile.right(1).find("/",0,TRUE) == -1)
503 localFile += "/"; 510 localFile += "/";
504 localFile += strItem; 511 localFile += strItem;
505// QString localFile = currentDir.canonicalPath()+"/"+strItem; 512// QString localFile = currentDir.canonicalPath()+"/"+strItem;
506 QString remoteFile= currentRemoteDir+strItem; 513 QString remoteFile= currentRemoteDir+strItem;
507 if (!FtpSize( remoteFile.latin1(), &fsz, FTPLIB_ASCII, conn)) 514 if (!FtpSize( remoteFile.latin1(), &fsz, FTPLIB_ASCII, conn))
508 fsz = 0; 515 fsz = 0;
509 QString temp; 516 QString temp;
510 temp.sprintf( remoteFile+" "+" %dkb", fsz); 517 temp.sprintf( remoteFile+" "+" %dkb", fsz);
511 518
512 ProgressBar->setTotalSteps(fsz); 519 ProgressBar->setTotalSteps(fsz);
513 FtpOptions(FTPLIB_CALLBACK, (long) log_progress, conn); 520 FtpOptions(FTPLIB_CALLBACK, (long) log_progress, conn);
514 FtpOptions(FTPLIB_IDLETIME, (long) 1000, conn); 521 FtpOptions(FTPLIB_IDLETIME, (long) 1000, conn);
515 FtpOptions(FTPLIB_CALLBACKARG, (long) &fsz, conn); 522 FtpOptions(FTPLIB_CALLBACKARG, (long) &fsz, conn);
516 FtpOptions(FTPLIB_CALLBACKBYTES, (long) fsz/10, conn); 523 FtpOptions(FTPLIB_CALLBACKBYTES, (long) fsz/10, conn);
517 qDebug("Get: %s, %s",localFile.latin1(),remoteFile.latin1()); 524 qDebug("Get: %s, %s",localFile.latin1(),remoteFile.latin1());
518 525
519 if(!FtpGet( localFile.latin1(), remoteFile.latin1(),FTPLIB_IMAGE, conn ) ) { 526 if(!FtpGet( localFile.latin1(), remoteFile.latin1(),FTPLIB_IMAGE, conn ) ) {
520 QString msg; 527 QString msg;
521 msg.sprintf(tr("Unable to download \n")+"%s",FtpLastResponse(conn)); 528 msg.sprintf(tr("Unable to download \n")+"%s",FtpLastResponse(conn));
522 msg.replace(QRegExp(":"),"\n"); 529 msg.replace(QRegExp(":"),"\n");
523 QMessageBox::message(tr("Note"),msg); 530 QMessageBox::message(tr("Note"),msg);
524 } 531 }
525 ProgressBar->reset(); 532 ProgressBar->reset();
526 nullifyCallBack(); 533 nullifyCallBack();
527 }
528 it.current()->setSelected(FALSE); 534 it.current()->setSelected(FALSE);
535 }
536 }
537 for ( ; it.current(); ++it ) {
538 Remote_View->clearSelection();
529 } 539 }
540 Remote_View->setFocus();
530 TabWidget->setCurrentPage(0); 541 TabWidget->setCurrentPage(0);
531 populateLocalView(); 542 populateLocalView();
532// QCopEnvelope ( "QPE/System", "notBusy()" ); 543 QCopEnvelope ( "QPE/System", "notBusy()" );
533
534} 544}
535 545
536bool OpieFtp::remoteDirList(const QString &dir) 546bool OpieFtp::remoteDirList(const QString &dir)
537{ 547{
538 QString tmp = QDir::homeDirPath(); 548 QString tmp = QDir::homeDirPath();
539 if(tmp.right(1) != "/") 549 if(tmp.right(1) != "/")
540 tmp+="/._temp"; 550 tmp+="/._temp";
541 else 551 else
542 tmp+="._temp"; 552 tmp+="._temp";
543// qDebug("Listing remote dir "+tmp); 553// qDebug("Listing remote dir "+tmp);
544// QCopEnvelope ( "QPE/System", "busy()" ); 554 QCopEnvelope ( "QPE/System", "busy()" );
545 if (!FtpDir( tmp.latin1(), dir.latin1(), conn) ) { 555 if (!FtpDir( tmp.latin1(), dir.latin1(), conn) ) {
546 QString msg; 556 QString msg;
547 msg.sprintf(tr("Unable to list the directory\n")+dir+"\n%s",FtpLastResponse(conn) ); 557 msg.sprintf(tr("Unable to list the directory\n")+dir+"\n%s",FtpLastResponse(conn) );
548 msg.replace(QRegExp(":"),"\n"); 558 msg.replace(QRegExp(":"),"\n");
549 QMessageBox::message(tr("Note"),msg); 559 QMessageBox::message(tr("Note"),msg);
550 return false; 560 return false;
551 } 561 }
552 populateRemoteView() ; 562 populateRemoteView() ;
553// QCopEnvelope ( "QPE/System", "notBusy()" ); 563 QCopEnvelope ( "QPE/System", "notBusy()" );
554 return true; 564 return true;
555} 565}
556 566
557bool OpieFtp::remoteChDir(const QString &dir) 567bool OpieFtp::remoteChDir(const QString &dir)
558{ 568{
559// QCopEnvelope ( "QPE/System", "busy()" ); 569 QCopEnvelope ( "QPE/System", "busy()" );
560 if (!FtpChdir( dir.latin1(), conn )) { 570 if (!FtpChdir( dir.latin1(), conn )) {
561 QString msg; 571 QString msg;
562 msg.sprintf(tr("Unable to change directories\n")+dir+"\n%s",FtpLastResponse(conn)); 572 msg.sprintf(tr("Unable to change directories\n")+dir+"\n%s",FtpLastResponse(conn));
563 msg.replace(QRegExp(":"),"\n"); 573 msg.replace(QRegExp(":"),"\n");
564 QMessageBox::message(tr("Note"),msg); 574 QMessageBox::message(tr("Note"),msg);
565// qDebug(msg); 575// qDebug(msg);
566// QCopEnvelope ( "QPE/System", "notBusy()" ); 576 QCopEnvelope ( "QPE/System", "notBusy()" );
567 return FALSE; 577 return FALSE;
568 } 578 }
569// QCopEnvelope ( "QPE/System", "notBusy()" ); 579 QCopEnvelope ( "QPE/System", "notBusy()" );
570 return TRUE; 580 return TRUE;
571} 581}
572 582
573void OpieFtp::populateLocalView() 583void OpieFtp::populateLocalView()
574{ 584{
575 Local_View->clear(); 585 Local_View->clear();
576 currentDir.setSorting(/* QDir::Size*/ /*| QDir::Reversed | */QDir::DirsFirst); 586 currentDir.setSorting(/* QDir::Size*/ /*| QDir::Reversed | */QDir::DirsFirst);
577 currentDir.setMatchAllDirs(TRUE); 587 currentDir.setMatchAllDirs(TRUE);
578 currentDir.setNameFilter(filterStr); 588 currentDir.setNameFilter(filterStr);
579 QString fileL, fileS, fileDate; 589 QString fileL, fileS, fileDate;
580 bool isDir=FALSE; 590 bool isDir=FALSE;
581 const QFileInfoList *list = currentDir.entryInfoList( /*QDir::All*/ /*, QDir::SortByMask*/); 591 const QFileInfoList *list = currentDir.entryInfoList( /*QDir::All*/ /*, QDir::SortByMask*/);
582 QFileInfoListIterator it(*list); 592 QFileInfoListIterator it(*list);
583 QFileInfo *fi; 593 QFileInfo *fi;
584 while ( (fi=it.current()) ) { 594 while ( (fi=it.current()) ) {
585 if (fi->isSymLink() ){ 595 if (fi->isSymLink() ){
586 QString symLink=fi->readLink(); 596 QString symLink=fi->readLink();
587// qDebug("Symlink detected "+symLink); 597// qDebug("Symlink detected "+symLink);
588 QFileInfo sym( symLink); 598 QFileInfo sym( symLink);
589 fileS.sprintf( "%10li", sym.size() ); 599 fileS.sprintf( "%10li", sym.size() );
590 fileL.sprintf( "%s -> %s", sym.fileName().data(),sym.absFilePath().data() ); 600 fileL.sprintf( "%s -> %s", sym.fileName().data(),sym.absFilePath().data() );
591 fileDate = sym.lastModified().toString(); 601 fileDate = sym.lastModified().toString();
592 } else { 602 } else {
593// qDebug("Not a dir: "+currentDir.canonicalPath()+fileL); 603// qDebug("Not a dir: "+currentDir.canonicalPath()+fileL);
@@ -616,49 +626,48 @@ void OpieFtp::populateLocalView()
616 else { 626 else {
617 MimeType mt(fi->filePath()); 627 MimeType mt(fi->filePath());
618 pm=mt.pixmap(); //sets the correct pixmap for mimetype 628 pm=mt.pixmap(); //sets the correct pixmap for mimetype
619 if(pm.isNull()) 629 if(pm.isNull())
620 pm = Resource::loadPixmap( "UnknownDocument-14" ); 630 pm = Resource::loadPixmap( "UnknownDocument-14" );
621 item->setPixmap( 0,pm); 631 item->setPixmap( 0,pm);
622 } 632 }
623 } 633 }
624 if( fileL.find("->",0,TRUE) != -1) { 634 if( fileL.find("->",0,TRUE) != -1) {
625 // overlay link image 635 // overlay link image
626 pm= Resource::loadPixmap( "folder" ); 636 pm= Resource::loadPixmap( "folder" );
627 QPixmap lnk = Resource::loadPixmap( "symlink" ); 637 QPixmap lnk = Resource::loadPixmap( "symlink" );
628 QPainter painter( &pm ); 638 QPainter painter( &pm );
629 painter.drawPixmap( pm.width()-lnk.width(), pm.height()-lnk.height(), lnk ); 639 painter.drawPixmap( pm.width()-lnk.width(), pm.height()-lnk.height(), lnk );
630 pm.setMask( pm.createHeuristicMask( FALSE ) ); 640 pm.setMask( pm.createHeuristicMask( FALSE ) );
631 item->setPixmap( 0, pm); 641 item->setPixmap( 0, pm);
632 } 642 }
633 } 643 }
634 isDir=FALSE; 644 isDir=FALSE;
635 ++it; 645 ++it;
636 } 646 }
637 Local_View->setSorting( 3,FALSE); 647 Local_View->setSorting( 3,FALSE);
638 currentPathCombo->lineEdit()->setText( currentDir.canonicalPath() ); 648 currentPathCombo->lineEdit()->setText( currentDir.canonicalPath() );
639 fillCombo( (const QString &)currentDir); 649 fillCombo( (const QString &)currentDir);
640
641} 650}
642 651
643bool OpieFtp::populateRemoteView( ) 652bool OpieFtp::populateRemoteView( )
644{ 653{
645// qDebug("populate remoteview"); 654// qDebug("populate remoteview");
646 QString sfile=QDir::homeDirPath(); 655 QString sfile=QDir::homeDirPath();
647 if(sfile.right(1) != "/") 656 if(sfile.right(1) != "/")
648 sfile+="/._temp"; 657 sfile+="/._temp";
649 else 658 else
650 sfile+="._temp"; 659 sfile+="._temp";
651 QFile file( sfile); 660 QFile file( sfile);
652 Remote_View->clear(); 661 Remote_View->clear();
653 QString s, File_Name; 662 QString s, File_Name;
654 QListViewItem *itemDir=NULL, *itemFile=NULL; 663 QListViewItem *itemDir=NULL, *itemFile=NULL;
655 QString fileL, fileS, fileDate; 664 QString fileL, fileS, fileDate;
656 if ( file.open(IO_ReadOnly)) { 665 if ( file.open(IO_ReadOnly)) {
657 QTextStream t( &file ); // use a text stream 666 QTextStream t( &file ); // use a text stream
658 while ( !t.eof()) { 667 while ( !t.eof()) {
659 s = t.readLine(); 668 s = t.readLine();
660 fileL = s.right(s.length()-55); 669 fileL = s.right(s.length()-55);
661 fileL = fileL.stripWhiteSpace(); 670 fileL = fileL.stripWhiteSpace();
662 if(s.left(1) == "d") 671 if(s.left(1) == "d")
663 fileL = fileL+"/"; 672 fileL = fileL+"/";
664// fileL = "/"+fileL+"/"; 673// fileL = "/"+fileL+"/";
@@ -717,49 +726,49 @@ void OpieFtp::remoteListClicked(QListViewItem *selectedItem)
717 QMessageBox::message(tr("Note"),msg); 726 QMessageBox::message(tr("Note"),msg);
718// qDebug(msg); 727// qDebug(msg);
719 } 728 }
720 currentRemoteDir=path; 729 currentRemoteDir=path;
721 } else { 730 } else {
722 if(strItem.find("->",0,TRUE) != -1) { //symlink on some servers 731 if(strItem.find("->",0,TRUE) != -1) { //symlink on some servers
723 strItem=strItem.right( strItem.length() - strItem.find("->",0,TRUE) - 2 ); 732 strItem=strItem.right( strItem.length() - strItem.find("->",0,TRUE) - 2 );
724 strItem = strItem.stripWhiteSpace(); 733 strItem = strItem.stripWhiteSpace();
725 currentRemoteDir = strItem; 734 currentRemoteDir = strItem;
726 if( !remoteChDir( (const QString &)strItem)) { 735 if( !remoteChDir( (const QString &)strItem)) {
727 currentRemoteDir = oldRemoteCurrentDir; 736 currentRemoteDir = oldRemoteCurrentDir;
728 strItem=""; 737 strItem="";
729// qDebug("RemoteCurrentDir1 "+oldRemoteCurrentDir); 738// qDebug("RemoteCurrentDir1 "+oldRemoteCurrentDir);
730 } 739 }
731 } else if(strItem.find("/",0,TRUE) != -1) { // this is a directory 740 } else if(strItem.find("/",0,TRUE) != -1) { // this is a directory
732 if( !remoteChDir( (const QString &)currentRemoteDir + strItem)) { 741 if( !remoteChDir( (const QString &)currentRemoteDir + strItem)) {
733 currentRemoteDir = oldRemoteCurrentDir; 742 currentRemoteDir = oldRemoteCurrentDir;
734 strItem=""; 743 strItem="";
735// qDebug("RemoteCurrentDir1 "+oldRemoteCurrentDir); 744// qDebug("RemoteCurrentDir1 "+oldRemoteCurrentDir);
736 745
737 } else { 746 } else {
738 currentRemoteDir = currentRemoteDir+strItem; 747 currentRemoteDir = currentRemoteDir+strItem;
739 } 748 }
740 } else { 749 } else {
741// QCopEnvelope ( "QPE/System", "notBusy()" ); 750 QCopEnvelope ( "QPE/System", "notBusy()" );
742 return; 751 return;
743 } 752 }
744 } 753 }
745 remoteDirList( (const QString &)currentRemoteDir); //this also calls populate 754 remoteDirList( (const QString &)currentRemoteDir); //this also calls populate
746 if(currentRemoteDir.right(1) !="/") 755 if(currentRemoteDir.right(1) !="/")
747 currentRemoteDir +="/"; 756 currentRemoteDir +="/";
748 currentPathCombo->lineEdit()->setText( currentRemoteDir); 757 currentPathCombo->lineEdit()->setText( currentRemoteDir);
749 fillRemoteCombo( (const QString &)currentRemoteDir); 758 fillRemoteCombo( (const QString &)currentRemoteDir);
750// QCopEnvelope ( "QPE/System", "notBusy()" ); 759// QCopEnvelope ( "QPE/System", "notBusy()" );
751 } 760 }
752} 761}
753 762
754void OpieFtp::localListClicked(QListViewItem *selectedItem) 763void OpieFtp::localListClicked(QListViewItem *selectedItem)
755{ 764{
756 if(selectedItem!= NULL) { 765 if(selectedItem!= NULL) {
757 766
758 QString strItem=selectedItem->text(0); 767 QString strItem=selectedItem->text(0);
759 QString strSize=selectedItem->text(1); 768 QString strSize=selectedItem->text(1);
760 strSize=strSize.stripWhiteSpace(); 769 strSize=strSize.stripWhiteSpace();
761 if(strItem.find("@",0,TRUE) !=-1 || strItem.find("->",0,TRUE) !=-1 ) { //if symlink 770 if(strItem.find("@",0,TRUE) !=-1 || strItem.find("->",0,TRUE) !=-1 ) { //if symlink
762 // is symlink 771 // is symlink
763 QString strItem2 = strItem.right( (strItem.length() - strItem.find("->",0,TRUE)) - 4); 772 QString strItem2 = strItem.right( (strItem.length() - strItem.find("->",0,TRUE)) - 4);
764 if(QDir(strItem2).exists() ) { 773 if(QDir(strItem2).exists() ) {
765 currentDir.cd(strItem2, TRUE); 774 currentDir.cd(strItem2, TRUE);
@@ -769,255 +778,274 @@ void OpieFtp::localListClicked(QListViewItem *selectedItem)
769 if(strItem.find(". .",0,TRUE) && strItem.find("/",0,TRUE)!=-1 ) { 778 if(strItem.find(". .",0,TRUE) && strItem.find("/",0,TRUE)!=-1 ) {
770 779
771 if(QDir(QDir::cleanDirPath(currentDir.canonicalPath()+"/"+strItem)).exists() ) { 780 if(QDir(QDir::cleanDirPath(currentDir.canonicalPath()+"/"+strItem)).exists() ) {
772 strItem=QDir::cleanDirPath(currentDir.canonicalPath()+"/"+strItem); 781 strItem=QDir::cleanDirPath(currentDir.canonicalPath()+"/"+strItem);
773 currentDir.cd(strItem,FALSE); 782 currentDir.cd(strItem,FALSE);
774 populateLocalView(); 783 populateLocalView();
775 } else { 784 } else {
776 currentDir.cdUp(); 785 currentDir.cdUp();
777 populateLocalView(); 786 populateLocalView();
778 } 787 }
779 if(QDir(strItem).exists()){ 788 if(QDir(strItem).exists()){
780 currentDir.cd(strItem, TRUE); 789 currentDir.cd(strItem, TRUE);
781 populateLocalView(); 790 populateLocalView();
782 } 791 }
783 } else { 792 } else {
784 strItem=QDir::cleanDirPath(currentDir.canonicalPath()+"/"+strItem); 793 strItem=QDir::cleanDirPath(currentDir.canonicalPath()+"/"+strItem);
785 if( QFile::exists(strItem ) ) { 794 if( QFile::exists(strItem ) ) {
786 // qDebug("upload "+strItem); 795 // qDebug("upload "+strItem);
787 return; 796 return;
788 } 797 }
789 } //end not symlink 798 } //end not symlink
790 chdir(strItem.latin1()); 799 chdir(strItem.latin1());
791 } 800 }
792 } 801 }
793
794} 802}
795 803
796void OpieFtp::doLocalCd() 804void OpieFtp::doLocalCd()
797{ 805{
798 localListClicked( Local_View->currentItem()); 806 localListClicked( Local_View->currentItem());
799} 807}
800 808
801void OpieFtp:: doRemoteCd() 809void OpieFtp:: doRemoteCd()
802{ 810{
803 remoteListClicked( Remote_View->currentItem()); 811 remoteListClicked( Remote_View->currentItem());
804 812
805} 813}
806 814
807void OpieFtp::showHidden() 815void OpieFtp::showHidden()
808{ 816{
809 if (!b) { 817 if (!b) {
810 currentDir.setFilter( QDir::Files | QDir::Dirs | QDir::Hidden | QDir::All); 818 currentDir.setFilter( QDir::Files | QDir::Dirs | QDir::Hidden | QDir::All);
811 localMenu->setItemChecked(localMenu->idAt(0),TRUE); 819 localMenu->setItemChecked(localMenu->idAt(0),TRUE);
812// currentDir.setSorting(/* QDir::Size*/ /*| QDir::Reversed | */QDir::DirsFirst); 820// currentDir.setSorting(/* QDir::Size*/ /*| QDir::Reversed | */QDir::DirsFirst);
813 b=TRUE; 821 b=TRUE;
814 822
815 } else { 823 } else {
816 currentDir.setFilter( QDir::Files | QDir::Dirs/* | QDir::Hidden*/ | QDir::All); 824 currentDir.setFilter( QDir::Files | QDir::Dirs/* | QDir::Hidden*/ | QDir::All);
817 localMenu->setItemChecked(localMenu->idAt(0),FALSE); 825 localMenu->setItemChecked(localMenu->idAt(0),FALSE);
818// currentDir.setSorting(/* QDir::Size*/ /*| QDir::Reversed | */QDir::DirsFirst); 826// currentDir.setSorting(/* QDir::Size*/ /*| QDir::Reversed | */QDir::DirsFirst);
819 b=FALSE; 827 b=FALSE;
820 } 828 }
821 populateLocalView(); 829 populateLocalView();
822} 830}
823 831
824void OpieFtp::ListPressed( int mouse, QListViewItem *item, const QPoint &point, int i) 832void OpieFtp::ListPressed( int mouse, QListViewItem *item, const QPoint &point, int i)
825{ 833{
826// if(item) 834// if(item)
827 if (mouse == 2) { 835 if (mouse == 2) {
828 showLocalMenu(item); 836 showLocalMenu(item);
829 } 837 }
830} 838}
831 839
832void OpieFtp::RemoteListPressed( int mouse, QListViewItem *item, const QPoint &point, int i) 840void OpieFtp::RemoteListPressed( int mouse, QListViewItem *item, const QPoint &point, int i)
833{ 841{
834 if(mouse == 2) { 842 if(mouse == 2) {
835 showRemoteMenu(item); 843 showRemoteMenu(item);
836 } 844 }
837} 845}
838 846
839void OpieFtp::showRemoteMenu(QListViewItem * item) 847void OpieFtp::showRemoteMenu(QListViewItem * item)
840{ 848{
841 QPopupMenu m;// = new QPopupMenu( Local_View ); 849 QPopupMenu * m;// = new QPopupMenu( Local_View );
850 m = new QPopupMenu(this);
842 if( /*item->text(0).right(1) == "/" ||*/ item->text(0).find("/",0,TRUE) != -1) 851 if( /*item->text(0).right(1) == "/" ||*/ item->text(0).find("/",0,TRUE) != -1)
843 m.insertItem( tr( "Change Directory" ), this, SLOT( doRemoteCd() )); 852 m->insertItem( tr( "Change Directory" ), this, SLOT( doRemoteCd() ));
844 else 853 else
845 m.insertItem( tr( "Download" ), this, SLOT( remoteDownload() )); 854 m->insertItem( tr( "Download" ), this, SLOT( remoteDownload() ));
846 m.insertItem( tr( "Make Directory" ), this, SLOT( remoteMakDir() )); 855 m->insertItem( tr( "Make Directory" ), this, SLOT( remoteMakDir() ));
847 m.insertItem( tr( "Rename" ), this, SLOT( remoteRename() )); 856 m->insertItem( tr( "Rename" ), this, SLOT( remoteRename() ));
848 m.insertSeparator(); 857 m->insertSeparator();
849 m.insertItem( tr( "Delete" ), this, SLOT( remoteDelete() )); 858 m->insertItem( tr( "Delete" ), this, SLOT( remoteDelete() ));
850 m.exec( QCursor::pos() ); 859 m->exec( QCursor::pos() );
860 delete m;
851} 861}
852 862
853void OpieFtp::showLocalMenu(QListViewItem * item) 863void OpieFtp::showLocalMenu(QListViewItem * item)
854{ 864{
855 865
856 QPopupMenu m; 866 QPopupMenu *m;
857 m.insertItem( tr( "Show Hidden Files" ), this, SLOT( showHidden() )); 867 m = new QPopupMenu( this);
858 m.insertSeparator(); 868 m->insertItem( tr( "Show Hidden Files" ), this, SLOT( showHidden() ));
869 m->insertSeparator();
859 if( /*item->text(0).right(1) == "/" ||*/ item->text(0).find("/",0,TRUE) !=-1) 870 if( /*item->text(0).right(1) == "/" ||*/ item->text(0).find("/",0,TRUE) !=-1)
860 m.insertItem( tr( "Change Directory" ), this, SLOT( doLocalCd() )); 871 m->insertItem( tr( "Change Directory" ), this, SLOT( doLocalCd() ));
861 else 872 else
862 m.insertItem( tr( "Upload" ), this, SLOT( localUpload() )); 873 m->insertItem( tr( "Upload" ), this, SLOT( localUpload() ));
863 m.insertItem( tr( "Make Directory" ), this, SLOT( localMakDir() )); 874 m->insertItem( tr( "Make Directory" ), this, SLOT( localMakDir() ));
864 m.insertItem( tr( "Rename" ), this, SLOT( localRename() )); 875 m->insertItem( tr( "Rename" ), this, SLOT( localRename() ));
865 m.insertSeparator(); 876 m->insertSeparator();
866 m.insertItem( tr( "Delete" ), this, SLOT( localDelete() )); 877 m->insertItem( tr( "Delete" ), this, SLOT( localDelete() ));
867 m.setCheckable(TRUE); 878 m->setCheckable(TRUE);
868 if (b) 879 if (b)
869 m.setItemChecked(m.idAt(0),TRUE); 880 m->setItemChecked(m->idAt(0),TRUE);
870 else 881 else
871 m.setItemChecked(m.idAt(0),FALSE); 882 m->setItemChecked(m->idAt(0),FALSE);
872 883
873 m.exec( QCursor::pos() ); 884 m->exec( QCursor::pos() );
885 delete m;
874} 886}
875 887
876void OpieFtp::localMakDir() 888void OpieFtp::localMakDir()
877{ 889{
878 InputDialog *fileDlg; 890 InputDialog *fileDlg;
879 fileDlg = new InputDialog(this,tr("Make Directory"),TRUE, 0); 891 fileDlg = new InputDialog(this,tr("Make Directory"),TRUE, 0);
880 fileDlg->exec(); 892 fileDlg->exec();
881 if( fileDlg->result() == 1 ) { 893 if( fileDlg->result() == 1 ) {
882 QString filename = fileDlg->LineEdit1->text(); 894 QString filename = fileDlg->LineEdit1->text();
883 currentDir.mkdir( currentDir.canonicalPath()+"/"+filename); 895 currentDir.mkdir( currentDir.canonicalPath()+"/"+filename);
884 } 896 }
885 populateLocalView(); 897 populateLocalView();
886} 898}
887 899
888void OpieFtp::localDelete() 900void OpieFtp::localDelete()
889{ 901{
890 QString f = Local_View->currentItem()->text(0); 902 QList<QListViewItem> * getSelectedItems( QListView * Local_View );
891 if(QDir(f).exists() ) { 903 QListViewItemIterator it( Local_View );
892 switch ( QMessageBox::warning(this,tr("Delete"),tr("Do you really want to delete\n")+f+ 904 for ( ; it.current(); ++it ) {
893 tr(" ?\nIt must be empty"),tr("Yes"),tr("No"),0,0,1) ) { 905 if ( it.current()->isSelected() ) {
894 case 0: { 906 QString f = it.current()->text(0);
895 f=currentDir.canonicalPath()+"/"+f; 907 it.current()->setSelected(FALSE);
896 QString cmd="rmdir "+f; 908
897 system( cmd.latin1()); 909// QString f = Local_View->currentItem()->text(0);
898 populateLocalView(); 910 if(QDir(f).exists() ) {
899 } 911 switch ( QMessageBox::warning(this,tr("Delete"),tr("Do you really want to delete\n")+f+
900 break; 912 tr(" ?\nIt must be empty"),tr("Yes"),tr("No"),0,0,1) ) {
901 case 1: 913 case 0: {
902 // exit 914 f=currentDir.canonicalPath()+"/"+f;
903 break; 915 QString cmd="rmdir "+f;
904 }; 916 system( cmd.latin1());
917 }
918 break;
919 case 1:
920 // exit
921 break;
922 };
905 923
906 } else { 924 } else {
907 switch ( QMessageBox::warning(this,tr("Delete"),tr("Do you really want to delete\n")+f 925 switch ( QMessageBox::warning(this,tr("Delete"),tr("Do you really want to delete\n")+f
908 +" ?",tr("Yes"),tr("No"),0,0,1) ) { 926 +" ?",tr("Yes"),tr("No"),0,0,1) ) {
909 case 0: { 927 case 0: {
910 f=currentDir.canonicalPath()+"/"+f; 928 f=currentDir.canonicalPath()+"/"+f;
911 QString cmd="rm "+f; 929 QString cmd="rm "+f;
912 system( cmd.latin1()); 930 system( cmd.latin1());
913 populateLocalView(); 931 }
914 } 932 break;
915 break; 933 case 1:
916 case 1: 934 // exit
917 // exit 935 break;
918 break; 936 };
919 }; 937 }
938 }
920 } 939 }
940 populateLocalView();
941
921} 942}
922 943
923void OpieFtp::remoteMakDir() 944void OpieFtp::remoteMakDir()
924{ 945{
925 InputDialog *fileDlg; 946 InputDialog *fileDlg;
926 fileDlg = new InputDialog(this,tr("Make Directory"),TRUE, 0); 947 fileDlg = new InputDialog(this,tr("Make Directory"),TRUE, 0);
927 fileDlg->exec(); 948 fileDlg->exec();
928 if( fileDlg->result() == 1 ) { 949 if( fileDlg->result() == 1 ) {
929 QString filename = fileDlg->LineEdit1->text();//+".playlist"; 950 QString filename = fileDlg->LineEdit1->text();//+".playlist";
930 QString tmp=currentRemoteDir+filename; 951 QString tmp=currentRemoteDir+filename;
931// QCopEnvelope ( "QPE/System", "busy()" ); 952 QCopEnvelope ( "QPE/System", "busy()" );
932 if(FtpMkdir( tmp.latin1(), conn) == 0) { 953 if(FtpMkdir( tmp.latin1(), conn) == 0) {
933 QString msg; 954 QString msg;
934 msg.sprintf(tr("Unable to make directory\n")+"%s",FtpLastResponse(conn)); 955 msg.sprintf(tr("Unable to make directory\n")+"%s",FtpLastResponse(conn));
935 msg.replace(QRegExp(":"),"\n"); 956 msg.replace(QRegExp(":"),"\n");
936 QMessageBox::message(tr("Note"),msg); 957 QMessageBox::message(tr("Note"),msg);
937 } 958 }
938// QCopEnvelope ( "QPE/System", "notBusy()" ); 959 QCopEnvelope ( "QPE/System", "notBusy()" );
939 remoteDirList( (const QString &)currentRemoteDir); //this also calls populate 960 remoteDirList( (const QString &)currentRemoteDir); //this also calls populate
940 } 961 }
941} 962}
942 963
943void OpieFtp::remoteDelete() 964void OpieFtp::remoteDelete()
944{ 965{
945 QString f = Remote_View->currentItem()->text(0); 966 QList<QListViewItem> * getSelectedItems( QListView * Remote_View );
946// QCopEnvelope ( "QPE/System", "busy()" ); 967 QListViewItemIterator it( Remote_View );
947 if( f.right(1) =="/") { 968 for ( ; it.current(); ++it ) {
948 QString path= currentRemoteDir+f; 969 if ( it.current()->isSelected() ) {
949 switch ( QMessageBox::warning(this,tr("Delete"),tr("Do you really want to delete\n")+f+"?" 970 QString f = it.current()->text(0);
950 ,tr("Yes"),tr("No"),0,0,1) ) { 971// QString f = Remote_View->currentItem()->text(0);
951 case 0: { 972 QCopEnvelope ( "QPE/System", "busy()" );
952 f=currentDir.canonicalPath()+"/"+f; 973 if( f.right(1) =="/") {
953 if(FtpRmdir( path.latin1(), conn) ==0) { 974 QString path= currentRemoteDir+f;
954 QString msg; 975 switch ( QMessageBox::warning(this,tr("Delete"),tr("Do you really want to delete\n")+f+"?"
955 msg.sprintf(tr("Unable to remove directory\n")+"%s",FtpLastResponse(conn)); 976 ,tr("Yes"),tr("No"),0,0,1) ) {
956 msg.replace(QRegExp(":"),"\n"); 977 case 0: {
957 QMessageBox::message(tr("Note"),msg); 978 f=currentDir.canonicalPath()+"/"+f;
958 } 979 if(FtpRmdir( path.latin1(), conn) ==0) {
959 remoteDirList( (const QString &)currentRemoteDir); //this also calls populate 980 QString msg;
960 } 981 msg.sprintf(tr("Unable to remove directory\n")+"%s",FtpLastResponse(conn));
961 break; 982 msg.replace(QRegExp(":"),"\n");
962 }; 983 QMessageBox::message(tr("Note"),msg);
963 } else { 984 }
964 switch ( QMessageBox::warning(this,tr("Delete"),tr("Do you really want to delete\n")+f+"?" 985 remoteDirList( (const QString &)currentRemoteDir); //this also calls populate
965 ,tr("Yes"),tr("No"),0,0,1) ) { 986 }
966 case 0: { 987 break;
967 QString path= currentRemoteDir+f; 988 };
968 if(FtpDelete( path.latin1(), conn)==0) { 989 } else {
969 QString msg; 990 switch ( QMessageBox::warning(this,tr("Delete"),tr("Do you really want to delete\n")+f+"?"
970 msg.sprintf(tr("Unable to delete file\n")+"%s",FtpLastResponse(conn)); 991 ,tr("Yes"),tr("No"),0,0,1) ) {
971 msg.replace(QRegExp(":"),"\n"); 992 case 0: {
972 QMessageBox::message(tr("Note"),msg); 993 QString path= currentRemoteDir+f;
973 } 994 if(FtpDelete( path.latin1(), conn)==0) {
974 remoteDirList( (const QString &)currentRemoteDir); //this also calls populate 995 QString msg;
975 } 996 msg.sprintf(tr("Unable to delete file\n")+"%s",FtpLastResponse(conn));
976 break; 997 msg.replace(QRegExp(":"),"\n");
977 }; 998 QMessageBox::message(tr("Note"),msg);
999 }
1000 remoteDirList( (const QString &)currentRemoteDir); //this also calls populate
1001 }
1002 break;
1003 };
1004 }
1005 }
978 } 1006 }
979// QCopEnvelope ( "QPE/System", "notBusy()" ); 1007 QCopEnvelope ( "QPE/System", "notBusy()" );
980} 1008}
981 1009
982void OpieFtp::remoteRename() 1010void OpieFtp::remoteRename()
983{ 1011{
984 QString curFile = Remote_View->currentItem()->text(0); 1012 QString curFile = Remote_View->currentItem()->text(0);
985 InputDialog *fileDlg; 1013 InputDialog *fileDlg;
986 fileDlg = new InputDialog(this,tr("Rename"),TRUE, 0); 1014 fileDlg = new InputDialog(this,tr("Rename"),TRUE, 0);
987 fileDlg->setTextEdit((const QString &)curFile); 1015 fileDlg->setTextEdit((const QString &)curFile);
988 fileDlg->exec(); 1016 fileDlg->exec();
989 if( fileDlg->result() == 1 ) { 1017 if( fileDlg->result() == 1 ) {
990 QString oldName = currentRemoteDir +"/"+ curFile; 1018 QString oldName = currentRemoteDir +"/"+ curFile;
991 QString newName = currentRemoteDir +"/"+ fileDlg->LineEdit1->text();//+".playlist"; 1019 QString newName = currentRemoteDir +"/"+ fileDlg->LineEdit1->text();//+".playlist";
992// QCopEnvelope ( "QPE/System", "busy()" ); 1020 QCopEnvelope ( "QPE/System", "busy()" );
993 if(FtpRename( oldName.latin1(), newName.latin1(),conn) == 0) { 1021 if(FtpRename( oldName.latin1(), newName.latin1(),conn) == 0) {
994 QString msg; 1022 QString msg;
995 msg.sprintf(tr("Unable to rename file\n")+"%s",FtpLastResponse(conn)); 1023 msg.sprintf(tr("Unable to rename file\n")+"%s",FtpLastResponse(conn));
996 msg.replace(QRegExp(":"),"\n"); 1024 msg.replace(QRegExp(":"),"\n");
997 QMessageBox::message(tr("Note"),msg); 1025 QMessageBox::message(tr("Note"),msg);
998 } 1026 }
999// QCopEnvelope ( "QPE/System", "notBusy()" ); 1027 QCopEnvelope ( "QPE/System", "notBusy()" );
1000 remoteDirList( (const QString &)currentRemoteDir); //this also calls populate 1028 remoteDirList( (const QString &)currentRemoteDir); //this also calls populate
1001 } 1029 }
1002} 1030}
1003 1031
1004void OpieFtp::localRename() 1032void OpieFtp::localRename()
1005{ 1033{
1006 QString curFile = Local_View->currentItem()->text(0); 1034 QString curFile = Local_View->currentItem()->text(0);
1007 InputDialog *fileDlg; 1035 InputDialog *fileDlg;
1008 fileDlg = new InputDialog(this,tr("Rename"),TRUE, 0); 1036 fileDlg = new InputDialog(this,tr("Rename"),TRUE, 0);
1009 fileDlg->setTextEdit((const QString &)curFile); 1037 fileDlg->setTextEdit((const QString &)curFile);
1010 fileDlg->exec(); 1038 fileDlg->exec();
1011 if( fileDlg->result() == 1 ) { 1039 if( fileDlg->result() == 1 ) {
1012 QString oldname = currentDir.canonicalPath() + "/" + curFile; 1040 QString oldname = currentDir.canonicalPath() + "/" + curFile;
1013 QString newName = currentDir.canonicalPath() + "/" + fileDlg->LineEdit1->text();//+".playlist"; 1041 QString newName = currentDir.canonicalPath() + "/" + fileDlg->LineEdit1->text();//+".playlist";
1014 if( rename(oldname.latin1(), newName.latin1())== -1) 1042 if( rename(oldname.latin1(), newName.latin1())== -1)
1015 QMessageBox::message(tr("Note"),tr("Could not rename")); 1043 QMessageBox::message(tr("Note"),tr("Could not rename"));
1016 } 1044 }
1017 populateLocalView(); 1045 populateLocalView();
1018} 1046}
1019 1047
1020void OpieFtp::currentPathComboActivated(const QString & currentPath) { 1048void OpieFtp::currentPathComboActivated(const QString & currentPath) {
1021 if (TabWidget->currentPageIndex() == 0) { 1049 if (TabWidget->currentPageIndex() == 0) {
1022 chdir( currentPath.latin1() ); 1050 chdir( currentPath.latin1() );
1023 currentDir.cd( currentPath, TRUE); 1051 currentDir.cd( currentPath, TRUE);
@@ -1244,46 +1272,44 @@ void OpieFtp::upDir()
1244 populateLocalView(); 1272 populateLocalView();
1245 update(); 1273 update();
1246 } else { 1274 } else {
1247 if( FtpCDUp( conn) == 0) { 1275 if( FtpCDUp( conn) == 0) {
1248 QString msg; 1276 QString msg;
1249 msg.sprintf(tr("Unable to cd up\n")+"%s",FtpLastResponse(conn)); 1277 msg.sprintf(tr("Unable to cd up\n")+"%s",FtpLastResponse(conn));
1250 msg.replace(QRegExp(":"),"\n"); 1278 msg.replace(QRegExp(":"),"\n");
1251 QMessageBox::message(tr("Note"),msg); 1279 QMessageBox::message(tr("Note"),msg);
1252// qDebug(msg); 1280// qDebug(msg);
1253 } 1281 }
1254 char path[256]; 1282 char path[256];
1255 if( FtpPwd( path,sizeof(path),conn) == 0) { //this is easier than fudging the string 1283 if( FtpPwd( path,sizeof(path),conn) == 0) { //this is easier than fudging the string
1256 QString msg; 1284 QString msg;
1257 msg.sprintf(tr("Unable to get working dir\n")+"%s",FtpLastResponse(conn)); 1285 msg.sprintf(tr("Unable to get working dir\n")+"%s",FtpLastResponse(conn));
1258 msg.replace(QRegExp(":"),"\n"); 1286 msg.replace(QRegExp(":"),"\n");
1259 QMessageBox::message(tr("Note"),msg); 1287 QMessageBox::message(tr("Note"),msg);
1260// qDebug(msg); 1288// qDebug(msg);
1261 } 1289 }
1262 currentRemoteDir=path; 1290 currentRemoteDir=path;
1263 remoteDirList( (const QString &)currentRemoteDir); //this also calls populate 1291 remoteDirList( (const QString &)currentRemoteDir); //this also calls populate
1264 if(currentRemoteDir.right(1) !="/") 1292 if(currentRemoteDir.right(1) !="/")
1265 currentRemoteDir +="/"; 1293 currentRemoteDir +="/";
1266 currentPathCombo->lineEdit()->setText( currentRemoteDir); 1294 currentPathCombo->lineEdit()->setText( currentRemoteDir);
1267 fillRemoteCombo( (const QString &)currentRemoteDir); 1295 fillRemoteCombo( (const QString &)currentRemoteDir);
1268 populateRemoteView( ); 1296
1269 } 1297 }
1270} 1298}
1271 1299
1272void OpieFtp::docButtonPushed() { 1300void OpieFtp::docButtonPushed() {
1273 QString current = QPEApplication::documentDir(); 1301 QString current = QPEApplication::documentDir();
1274 chdir( current.latin1() ); 1302 chdir( current.latin1() );
1275 currentDir.cd( current, TRUE); 1303 currentDir.cd( current, TRUE);
1276 populateLocalView(); 1304 populateLocalView();
1277 update(); 1305 update();
1278 1306
1279} 1307}
1280 1308
1281void OpieFtp::homeButtonPushed() { 1309void OpieFtp::homeButtonPushed() {
1282 if (TabWidget->currentPageIndex() == 0) { 1310 QString current = QDir::homeDirPath();
1283 QString current = QDir::homeDirPath(); 1311 chdir( current.latin1() );
1284 chdir( current.latin1() ); 1312 currentDir.cd( current, TRUE);
1285 currentDir.cd( current, TRUE); 1313 populateLocalView();
1286 populateLocalView(); 1314 update();
1287 update();
1288 }
1289} 1315}