summaryrefslogtreecommitdiff
authorllornkcor <llornkcor>2002-03-31 02:00:57 (UTC)
committer llornkcor <llornkcor>2002-03-31 02:00:57 (UTC)
commit13da5064c21e124f2202310ac4c54cb3ddc8c0b1 (patch) (unidiff)
treed95a8c039a1240aace32be1751382ea43b8c77cc
parent04158decf6fa76d966be178d07e1895336a47bd9 (diff)
downloadopie-13da5064c21e124f2202310ac4c54cb3ddc8c0b1.zip
opie-13da5064c21e124f2202310ac4c54cb3ddc8c0b1.tar.gz
opie-13da5064c21e124f2202310ac4c54cb3ddc8c0b1.tar.bz2
fixed some goofy crap I thought I fixed earlier with server combo and multiple entries. oh well. Also fixed single click going into a repopulate(bad when remote)
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/net/opieftp/opieftp.cpp33
1 files changed, 19 insertions, 14 deletions
diff --git a/noncore/net/opieftp/opieftp.cpp b/noncore/net/opieftp/opieftp.cpp
index 3dda17e..e64fd73 100644
--- a/noncore/net/opieftp/opieftp.cpp
+++ b/noncore/net/opieftp/opieftp.cpp
@@ -104,65 +104,66 @@ OpieFtp::OpieFtp( )
104 104
105 remoteMenu->insertItem( tr( "Download" ), this, SLOT( remoteDownload() )); 105 remoteMenu->insertItem( tr( "Download" ), this, SLOT( remoteDownload() ));
106 remoteMenu->insertItem( tr( "Make Directory" ), this, SLOT( remoteMakDir() )); 106 remoteMenu->insertItem( tr( "Make Directory" ), this, SLOT( remoteMakDir() ));
107 remoteMenu->insertItem( tr( "Rename" ), this, SLOT( remoteRename() )); 107 remoteMenu->insertItem( tr( "Rename" ), this, SLOT( remoteRename() ));
108 remoteMenu->insertSeparator(); 108 remoteMenu->insertSeparator();
109 remoteMenu->insertItem( tr( "Delete" ), this, SLOT( remoteDelete() )); 109 remoteMenu->insertItem( tr( "Delete" ), this, SLOT( remoteDelete() ));
110 110
111 tabMenu->insertItem( tr( "Switch to Local" ), this, SLOT( switchToLocalTab() )); 111 tabMenu->insertItem( tr( "Switch to Local" ), this, SLOT( switchToLocalTab() ));
112 tabMenu->insertItem( tr( "Switch to Remote" ), this, SLOT( switchToRemoteTab() )); 112 tabMenu->insertItem( tr( "Switch to Remote" ), this, SLOT( switchToRemoteTab() ));
113 tabMenu->insertItem( tr( "Switch to Config" ), this, SLOT( switchToConfigTab() )); 113 tabMenu->insertItem( tr( "Switch to Config" ), this, SLOT( switchToConfigTab() ));
114 tabMenu->setCheckable(TRUE); 114 tabMenu->setCheckable(TRUE);
115 115
116 TabWidget = new QTabWidget( this, "TabWidget" ); 116 TabWidget = new QTabWidget( this, "TabWidget" );
117 layout->addMultiCellWidget( TabWidget, 1, 1, 0, 3 ); 117 layout->addMultiCellWidget( TabWidget, 1, 1, 0, 3 );
118 118
119 TabWidget->setTabShape(QTabWidget::Triangular); 119 TabWidget->setTabShape(QTabWidget::Triangular);
120 120
121 tab = new QWidget( TabWidget, "tab" ); 121 tab = new QWidget( TabWidget, "tab" );
122 tabLayout = new QGridLayout( tab ); 122 tabLayout = new QGridLayout( tab );
123 tabLayout->setSpacing( 2); 123 tabLayout->setSpacing( 2);
124 tabLayout->setMargin( 2); 124 tabLayout->setMargin( 2);
125 125
126 Local_View = new QListView( tab, "Local_View" ); 126 Local_View = new QListView( tab, "Local_View" );
127// Local_View->setResizePolicy( QListView::AutoOneFit ); 127// Local_View->setResizePolicy( QListView::AutoOneFit );
128 Local_View->addColumn( tr("File"),150); 128 Local_View->addColumn( tr("File"),150);
129 Local_View->addColumn( tr("Size"),-1); 129 Local_View->addColumn( tr("Size"),-1);
130 Local_View->setColumnAlignment(1,QListView::AlignRight); 130 Local_View->setColumnAlignment(1,QListView::AlignRight);
131 Local_View->addColumn( tr("Date"),-1); 131 Local_View->addColumn( tr("Date"),-1);
132 Local_View->setColumnAlignment(2,QListView::AlignRight); 132 Local_View->setColumnAlignment(2,QListView::AlignRight);
133 Local_View->setAllColumnsShowFocus(TRUE); 133 Local_View->setAllColumnsShowFocus(TRUE);
134 Local_View->setMultiSelection( TRUE ); 134 Local_View->setMultiSelection( TRUE );
135 Local_View->setSelectionMode(QListView::Extended); 135 Local_View->setSelectionMode(QListView::Extended);
136 QPEApplication::setStylusOperation( Local_View->viewport(),QPEApplication::RightOnHold); 136
137 QPEApplication::setStylusOperation( Local_View->viewport(),QPEApplication::RightOnHold);
137 138
138 tabLayout->addWidget( Local_View, 0, 0 ); 139 tabLayout->addWidget( Local_View, 0, 0 );
139 140
140 connect( Local_View, SIGNAL( clicked( QListViewItem*)), 141 connect( Local_View, SIGNAL( clicked( QListViewItem*)),
141 this,SLOT( localListClicked(QListViewItem *)) ); 142 this,SLOT( localListClicked(QListViewItem *)) );
142// connect( Local_View, SIGNAL( doubleClicked( QListViewItem*)), 143// connect( Local_View, SIGNAL( doubleClicked( QListViewItem*)),
143// this,SLOT( localListClicked(QListViewItem *)) ); 144// this,SLOT( localListClicked(QListViewItem *)) );
144 connect( Local_View, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int)), 145 connect( Local_View, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int)),
145 this,SLOT( ListPressed(int, QListViewItem *, const QPoint&, int)) ); 146 this,SLOT( ListPressed(int, QListViewItem *, const QPoint&, int)) );
146 147
147 TabWidget->insertTab( tab, tr( "Local" ) ); 148 TabWidget->insertTab( tab, tr( "Local" ) );
148 149
149 tab_2 = new QWidget( TabWidget, "tab_2" ); 150 tab_2 = new QWidget( TabWidget, "tab_2" );
150 tabLayout_2 = new QGridLayout( tab_2 ); 151 tabLayout_2 = new QGridLayout( tab_2 );
151 tabLayout_2->setSpacing( 2); 152 tabLayout_2->setSpacing( 2);
152 tabLayout_2->setMargin( 2); 153 tabLayout_2->setMargin( 2);
153 154
154 Remote_View = new QListView( tab_2, "Remote_View" ); 155 Remote_View = new QListView( tab_2, "Remote_View" );
155 Remote_View->addColumn( tr("File"),150); 156 Remote_View->addColumn( tr("File"),150);
156 Remote_View->addColumn( tr("Size"),-1); 157 Remote_View->addColumn( tr("Size"),-1);
157 Remote_View->setColumnAlignment(1,QListView::AlignRight); 158 Remote_View->setColumnAlignment(1,QListView::AlignRight);
158 Remote_View->addColumn( tr("Date"),-1); 159 Remote_View->addColumn( tr("Date"),-1);
159 Remote_View->setColumnAlignment(2,QListView::AlignRight); 160 Remote_View->setColumnAlignment(2,QListView::AlignRight);
160 Remote_View->addColumn( tr("Dir"),-1); 161 Remote_View->addColumn( tr("Dir"),-1);
161 Remote_View->setColumnAlignment(4,QListView::AlignRight); 162 Remote_View->setColumnAlignment(4,QListView::AlignRight);
162 Remote_View->setAllColumnsShowFocus(TRUE); 163 Remote_View->setAllColumnsShowFocus(TRUE);
163 Remote_View->setMultiSelection( TRUE ); 164 Remote_View->setMultiSelection( TRUE );
164 Remote_View->setSelectionMode(QListView::Extended); 165 Remote_View->setSelectionMode(QListView::Extended);
165 166
166 QPEApplication::setStylusOperation( Remote_View->viewport(),QPEApplication::RightOnHold); 167 QPEApplication::setStylusOperation( Remote_View->viewport(),QPEApplication::RightOnHold);
167 168
168 connect( Remote_View, SIGNAL( clicked( QListViewItem*)), 169 connect( Remote_View, SIGNAL( clicked( QListViewItem*)),
@@ -289,65 +290,64 @@ void OpieFtp::cleanUp()
289 exit(0); 290 exit(0);
290} 291}
291 292
292void OpieFtp::tabChanged(QWidget *w) 293void OpieFtp::tabChanged(QWidget *w)
293{ 294{
294 if (TabWidget->currentPageIndex() == 0) { 295 if (TabWidget->currentPageIndex() == 0) {
295 currentPathCombo->lineEdit()->setText( currentDir.canonicalPath()); 296 currentPathCombo->lineEdit()->setText( currentDir.canonicalPath());
296 tabMenu->setItemChecked(tabMenu->idAt(0),TRUE); 297 tabMenu->setItemChecked(tabMenu->idAt(0),TRUE);
297 tabMenu->setItemChecked(tabMenu->idAt(1),FALSE); 298 tabMenu->setItemChecked(tabMenu->idAt(1),FALSE);
298 tabMenu->setItemChecked(tabMenu->idAt(2),FALSE); 299 tabMenu->setItemChecked(tabMenu->idAt(2),FALSE);
299 } 300 }
300 if (TabWidget->currentPageIndex() == 1) { 301 if (TabWidget->currentPageIndex() == 1) {
301 currentPathCombo->lineEdit()->setText( currentRemoteDir ); 302 currentPathCombo->lineEdit()->setText( currentRemoteDir );
302 tabMenu->setItemChecked(tabMenu->idAt(1),TRUE); 303 tabMenu->setItemChecked(tabMenu->idAt(1),TRUE);
303 tabMenu->setItemChecked(tabMenu->idAt(0),FALSE); 304 tabMenu->setItemChecked(tabMenu->idAt(0),FALSE);
304 tabMenu->setItemChecked(tabMenu->idAt(2),FALSE); 305 tabMenu->setItemChecked(tabMenu->idAt(2),FALSE);
305 } 306 }
306 if (TabWidget->currentPageIndex() == 2) { 307 if (TabWidget->currentPageIndex() == 2) {
307 tabMenu->setItemChecked(tabMenu->idAt(2),TRUE); 308 tabMenu->setItemChecked(tabMenu->idAt(2),TRUE);
308 tabMenu->setItemChecked(tabMenu->idAt(0),FALSE); 309 tabMenu->setItemChecked(tabMenu->idAt(0),FALSE);
309 tabMenu->setItemChecked(tabMenu->idAt(1),FALSE); 310 tabMenu->setItemChecked(tabMenu->idAt(1),FALSE);
310 } 311 }
311} 312}
312 313
313void OpieFtp::newConnection() 314void OpieFtp::newConnection()
314{ 315{
315 UsernameComboBox->lineEdit()->setText(""); 316 UsernameComboBox->lineEdit()->setText("");
316 PasswordEdit->setText( "" ); 317 PasswordEdit->setText( "" );
317 ServerComboBox->lineEdit()->setText( ""); 318 ServerComboBox->lineEdit()->setText( "");
318 remotePath->setText( currentRemoteDir = "/"); 319 remotePath->setText( currentRemoteDir = "/");
319 PortSpinBox->setValue( 21); 320 PortSpinBox->setValue( 21);
320 TabWidget->setCurrentPage(2); 321 TabWidget->setCurrentPage(2);
321 currentServerConfig = -1;
322} 322}
323 323
324void OpieFtp::serverComboEdited(const QString & edit) 324void OpieFtp::serverComboEdited(const QString & edit)
325{ 325{
326 if( !edit.isEmpty() ) { 326 if( !edit.isEmpty() ) {
327 currentServerConfig = -1; 327 currentServerConfig = -1;
328// qDebug("comboedited"); 328// qDebug("comboedited");
329 } 329 }
330} 330}
331 331
332void OpieFtp::connectorBtnToggled(bool On) 332void OpieFtp::connectorBtnToggled(bool On)
333{ 333{
334 if(On) { 334 if(On) {
335 connector(); 335 connector();
336 } else { 336 } else {
337 disConnector(); 337 disConnector();
338 } 338 }
339 339
340} 340}
341 341
342void OpieFtp::connector() 342void OpieFtp::connector()
343{ 343{
344 QCopEnvelope ( "QPE/System", "busy()" ); 344 QCopEnvelope ( "QPE/System", "busy()" );
345// qApp->processEvents(); 345// qApp->processEvents();
346 currentRemoteDir=remotePath->text(); 346 currentRemoteDir=remotePath->text();
347 if(ServerComboBox->currentText().isEmpty()) { 347 if(ServerComboBox->currentText().isEmpty()) {
348 QMessageBox::warning(this,tr("Ftp"),tr("Please set the server info"),tr("Ok"),0,0); 348 QMessageBox::warning(this,tr("Ftp"),tr("Please set the server info"),tr("Ok"),0,0);
349 TabWidget->setCurrentPage(2); 349 TabWidget->setCurrentPage(2);
350 ServerComboBox->setFocus(); 350 ServerComboBox->setFocus();
351 connectServerBtn->setOn(FALSE); 351 connectServerBtn->setOn(FALSE);
352 connectServerBtn->setText( tr("Connect")); 352 connectServerBtn->setText( tr("Connect"));
353 return; 353 return;
@@ -403,120 +403,120 @@ void OpieFtp::localUpload()
403 int fsz; 403 int fsz;
404 QCopEnvelope ( "QPE/System", "busy()" ); 404 QCopEnvelope ( "QPE/System", "busy()" );
405// qApp->processEvents(); 405// qApp->processEvents();
406 QList<QListViewItem> * getSelectedItems( QListView * Local_View ); 406 QList<QListViewItem> * getSelectedItems( QListView * Local_View );
407 QListViewItemIterator it( Local_View ); 407 QListViewItemIterator it( Local_View );
408 for ( ; it.current(); ++it ) { 408 for ( ; it.current(); ++it ) {
409 if ( it.current()->isSelected() ) { 409 if ( it.current()->isSelected() ) {
410 QString strItem = it.current()->text(0); 410 QString strItem = it.current()->text(0);
411 QString localFile = currentDir.canonicalPath()+"/"+strItem; 411 QString localFile = currentDir.canonicalPath()+"/"+strItem;
412 QString remoteFile= currentRemoteDir+strItem; 412 QString remoteFile= currentRemoteDir+strItem;
413 QFileInfo fi(localFile); 413 QFileInfo fi(localFile);
414 if( !fi.isDir()) { 414 if( !fi.isDir()) {
415 fsz=fi.size(); 415 fsz=fi.size();
416 ProgressBar->setTotalSteps(fsz); 416 ProgressBar->setTotalSteps(fsz);
417 417
418 FtpOptions(FTPLIB_CALLBACK, (long) log_progress, conn); 418 FtpOptions(FTPLIB_CALLBACK, (long) log_progress, conn);
419 FtpOptions(FTPLIB_IDLETIME, (long) 1000, conn); 419 FtpOptions(FTPLIB_IDLETIME, (long) 1000, conn);
420 FtpOptions(FTPLIB_CALLBACKARG, (long) &fsz, conn); 420 FtpOptions(FTPLIB_CALLBACKARG, (long) &fsz, conn);
421 FtpOptions(FTPLIB_CALLBACKBYTES, (long) fsz/10, conn); 421 FtpOptions(FTPLIB_CALLBACKBYTES, (long) fsz/10, conn);
422 qDebug("Put: %s, %s",localFile.latin1(),remoteFile.latin1()); 422 qDebug("Put: %s, %s",localFile.latin1(),remoteFile.latin1());
423 423
424 if( !FtpPut( localFile.latin1(), remoteFile.latin1(),FTPLIB_IMAGE, conn ) ) { 424 if( !FtpPut( localFile.latin1(), remoteFile.latin1(),FTPLIB_IMAGE, conn ) ) {
425 QString msg; 425 QString msg;
426 msg.sprintf(tr("Unable to upload\n")+"%s",FtpLastResponse(conn)); 426 msg.sprintf(tr("Unable to upload\n")+"%s",FtpLastResponse(conn));
427 msg.replace(QRegExp(":"),"\n"); 427 msg.replace(QRegExp(":"),"\n");
428 QMessageBox::message(tr("Note"),msg); 428 QMessageBox::message(tr("Note"),msg);
429 } 429 }
430 } else { 430 } else {
431 QMessageBox::message(tr("Note"),tr("Cannot upload directories")); 431 QMessageBox::message(tr("Note"),tr("Cannot upload directories"));
432 } 432 }
433 ProgressBar->reset(); 433 ProgressBar->reset();
434 nullifyCallBack(); 434 nullifyCallBack();
435 it.current()->setSelected(FALSE);
436 } //end currentSelected 435 } //end currentSelected
436 it.current()->setSelected(FALSE);
437 } 437 }
438 TabWidget->setCurrentPage(1); 438 TabWidget->setCurrentPage(1);
439 remoteDirList( (const QString &)currentRemoteDir); //this also calls populate 439 remoteDirList( (const QString &)currentRemoteDir); //this also calls populate
440 QCopEnvelope ( "QPE/System", "notBusy()" ); 440 QCopEnvelope ( "QPE/System", "notBusy()" );
441} 441}
442 442
443void OpieFtp::nullifyCallBack() 443void OpieFtp::nullifyCallBack()
444{ 444{
445 FtpOptions(FTPLIB_CALLBACK, NULL, conn); 445 FtpOptions(FTPLIB_CALLBACK, NULL, conn);
446 FtpOptions(FTPLIB_IDLETIME, NULL, conn); 446 FtpOptions(FTPLIB_IDLETIME, NULL, conn);
447 FtpOptions(FTPLIB_CALLBACKARG, NULL, conn); 447 FtpOptions(FTPLIB_CALLBACKARG, NULL, conn);
448 FtpOptions(FTPLIB_CALLBACKBYTES, NULL, conn); 448 FtpOptions(FTPLIB_CALLBACKBYTES, NULL, conn);
449} 449}
450 450
451void OpieFtp::remoteDownload() 451void OpieFtp::remoteDownload()
452{ 452{
453// qApp->processEvents(); 453// qApp->processEvents();
454 int fsz; 454 int fsz;
455 QCopEnvelope ( "QPE/System", "busy()" ); 455 QCopEnvelope ( "QPE/System", "busy()" );
456 456
457 QList<QListViewItem> * getSelectedItems( QListView * Remote_View ); 457 QList<QListViewItem> * getSelectedItems( QListView * Remote_View );
458 QListViewItemIterator it( Remote_View ); 458 QListViewItemIterator it( Remote_View );
459 for ( ; it.current(); ++it ) { 459 for ( ; it.current(); ++it ) {
460 if ( it.current()->isSelected() ) { 460 if ( it.current()->isSelected() ) {
461 QString strItem = it.current()->text(0); 461 QString strItem = it.current()->text(0);
462// strItem=strItem.right(strItem.length()-1); 462// strItem=strItem.right(strItem.length()-1);
463 QString localFile = currentDir.canonicalPath(); 463 QString localFile = currentDir.canonicalPath();
464 if(localFile.right(1).find("/",0,TRUE) == -1) 464 if(localFile.right(1).find("/",0,TRUE) == -1)
465 localFile += "/"; 465 localFile += "/";
466 localFile += strItem; 466 localFile += strItem;
467// QString localFile = currentDir.canonicalPath()+"/"+strItem; 467// QString localFile = currentDir.canonicalPath()+"/"+strItem;
468 QString remoteFile= currentRemoteDir+strItem; 468 QString remoteFile= currentRemoteDir+strItem;
469 if (!FtpSize( remoteFile.latin1(), &fsz, FTPLIB_ASCII, conn)) 469 if (!FtpSize( remoteFile.latin1(), &fsz, FTPLIB_ASCII, conn))
470 fsz = 0; 470 fsz = 0;
471 QString temp; 471 QString temp;
472 temp.sprintf( remoteFile+" "+" %dkb", fsz); 472 temp.sprintf( remoteFile+" "+" %dkb", fsz);
473 473
474 ProgressBar->setTotalSteps(fsz); 474 ProgressBar->setTotalSteps(fsz);
475 FtpOptions(FTPLIB_CALLBACK, (long) log_progress, conn); 475 FtpOptions(FTPLIB_CALLBACK, (long) log_progress, conn);
476 FtpOptions(FTPLIB_IDLETIME, (long) 1000, conn); 476 FtpOptions(FTPLIB_IDLETIME, (long) 1000, conn);
477 FtpOptions(FTPLIB_CALLBACKARG, (long) &fsz, conn); 477 FtpOptions(FTPLIB_CALLBACKARG, (long) &fsz, conn);
478 FtpOptions(FTPLIB_CALLBACKBYTES, (long) fsz/10, conn); 478 FtpOptions(FTPLIB_CALLBACKBYTES, (long) fsz/10, conn);
479 qDebug("Get: %s, %s",localFile.latin1(),remoteFile.latin1()); 479 qDebug("Get: %s, %s",localFile.latin1(),remoteFile.latin1());
480 480
481 if(!FtpGet( localFile.latin1(), remoteFile.latin1(),FTPLIB_IMAGE, conn ) ) { 481 if(!FtpGet( localFile.latin1(), remoteFile.latin1(),FTPLIB_IMAGE, conn ) ) {
482 QString msg; 482 QString msg;
483 msg.sprintf(tr("Unable to download \n")+"%s",FtpLastResponse(conn)); 483 msg.sprintf(tr("Unable to download \n")+"%s",FtpLastResponse(conn));
484 msg.replace(QRegExp(":"),"\n"); 484 msg.replace(QRegExp(":"),"\n");
485 QMessageBox::message(tr("Note"),msg); 485 QMessageBox::message(tr("Note"),msg);
486 } 486 }
487 ProgressBar->reset(); 487 ProgressBar->reset();
488 nullifyCallBack(); 488 nullifyCallBack();
489 it.current()->setSelected(FALSE);
490 } 489 }
490 it.current()->setSelected(FALSE);
491 } 491 }
492 TabWidget->setCurrentPage(0); 492 TabWidget->setCurrentPage(0);
493 populateLocalView(); 493 populateLocalView();
494 QCopEnvelope ( "QPE/System", "notBusy()" ); 494 QCopEnvelope ( "QPE/System", "notBusy()" );
495} 495}
496 496
497bool OpieFtp::remoteDirList(const QString &dir) 497bool OpieFtp::remoteDirList(const QString &dir)
498{ 498{
499 QString tmp = QDir::homeDirPath(); 499 QString tmp = QDir::homeDirPath();
500 if(tmp.right(1) != "/") 500 if(tmp.right(1) != "/")
501 tmp+="/._temp"; 501 tmp+="/._temp";
502 else 502 else
503 tmp+="._temp"; 503 tmp+="._temp";
504// qDebug("Listing remote dir "+tmp); 504// qDebug("Listing remote dir "+tmp);
505 QCopEnvelope ( "QPE/System", "busy()" ); 505 QCopEnvelope ( "QPE/System", "busy()" );
506 if (!FtpDir( tmp.latin1(), dir.latin1(), conn) ) { 506 if (!FtpDir( tmp.latin1(), dir.latin1(), conn) ) {
507 QString msg; 507 QString msg;
508 msg.sprintf(tr("Unable to list the directory\n")+dir+"\n%s",FtpLastResponse(conn) ); 508 msg.sprintf(tr("Unable to list the directory\n")+dir+"\n%s",FtpLastResponse(conn) );
509 msg.replace(QRegExp(":"),"\n"); 509 msg.replace(QRegExp(":"),"\n");
510 QMessageBox::message(tr("Note"),msg); 510 QMessageBox::message(tr("Note"),msg);
511 return false; 511 return false;
512 } 512 }
513 populateRemoteView() ; 513 populateRemoteView() ;
514 QCopEnvelope ( "QPE/System", "notBusy()" ); 514 QCopEnvelope ( "QPE/System", "notBusy()" );
515 return true; 515 return true;
516} 516}
517 517
518bool OpieFtp::remoteChDir(const QString &dir) 518bool OpieFtp::remoteChDir(const QString &dir)
519{ 519{
520 QCopEnvelope ( "QPE/System", "busy()" ); 520 QCopEnvelope ( "QPE/System", "busy()" );
521 if (!FtpChdir( dir.latin1(), conn )) { 521 if (!FtpChdir( dir.latin1(), conn )) {
522 QString msg; 522 QString msg;
@@ -628,150 +628,152 @@ bool OpieFtp::populateRemoteView( )
628 fileDate = fileDate.stripWhiteSpace(); 628 fileDate = fileDate.stripWhiteSpace();
629 if(fileL.find("total",0,TRUE) == -1) { 629 if(fileL.find("total",0,TRUE) == -1) {
630 if(s.left(1) == "d" || fileL.find("/",0,TRUE) != -1) { 630 if(s.left(1) == "d" || fileL.find("/",0,TRUE) != -1) {
631 QListViewItem * item = new QListViewItem( Remote_View, fileL, fileS, fileDate,"d"); 631 QListViewItem * item = new QListViewItem( Remote_View, fileL, fileS, fileDate,"d");
632 item->setPixmap( 0, Resource::loadPixmap( "folder" )); 632 item->setPixmap( 0, Resource::loadPixmap( "folder" ));
633// if(itemDir) 633// if(itemDir)
634 item->moveItem(itemDir); 634 item->moveItem(itemDir);
635 itemDir=item; 635 itemDir=item;
636 } else { 636 } else {
637 QListViewItem * item = new QListViewItem( Remote_View, fileL, fileS, fileDate,"f"); 637 QListViewItem * item = new QListViewItem( Remote_View, fileL, fileS, fileDate,"f");
638 item->setPixmap( 0, Resource::loadPixmap( "fileopen" )); 638 item->setPixmap( 0, Resource::loadPixmap( "fileopen" ));
639// if(itemFile) 639// if(itemFile)
640 item->moveItem(itemDir); 640 item->moveItem(itemDir);
641 item->moveItem(itemFile); 641 item->moveItem(itemFile);
642 itemFile=item; 642 itemFile=item;
643 } 643 }
644 } 644 }
645 } 645 }
646 QListViewItem * item1 = new QListViewItem( Remote_View, "../"); 646 QListViewItem * item1 = new QListViewItem( Remote_View, "../");
647 item1->setPixmap( 0, Resource::loadPixmap( "folder" )); 647 item1->setPixmap( 0, Resource::loadPixmap( "folder" ));
648 file.close(); 648 file.close();
649 if( file.exists()) 649 if( file.exists())
650 file. remove(); 650 file. remove();
651 } else 651 } else
652 qDebug("temp file not opened successfullly "+sfile); 652 qDebug("temp file not opened successfullly "+sfile);
653 Remote_View->setSorting( 4,TRUE); 653 Remote_View->setSorting( 4,TRUE);
654 return true; 654 return true;
655} 655}
656 656
657void OpieFtp::remoteListClicked(QListViewItem *selectedItem) 657void OpieFtp::remoteListClicked(QListViewItem *selectedItem)
658{ 658{
659 if( selectedItem) { 659 if( selectedItem) {
660 QCopEnvelope ( "QPE/System", "busy()" ); 660// QCopEnvelope ( "QPE/System", "busy()" );
661 QString oldRemoteCurrentDir = currentRemoteDir; 661 QString oldRemoteCurrentDir = currentRemoteDir;
662 QString strItem=selectedItem->text(0); 662 QString strItem=selectedItem->text(0);
663 strItem=strItem.simplifyWhiteSpace(); 663 strItem=strItem.simplifyWhiteSpace();
664 if(strItem == "../") { // the user wants to go ^ 664 if(strItem == "../") { // the user wants to go ^
665 if( FtpCDUp( conn) == 0) { 665 if( FtpCDUp( conn) == 0) {
666 QString msg; 666 QString msg;
667 msg.sprintf(tr("Unable to cd up\n")+"%s",FtpLastResponse(conn)); 667 msg.sprintf(tr("Unable to cd up\n")+"%s",FtpLastResponse(conn));
668 msg.replace(QRegExp(":"),"\n"); 668 msg.replace(QRegExp(":"),"\n");
669 QMessageBox::message(tr("Note"),msg); 669 QMessageBox::message(tr("Note"),msg);
670 qDebug(msg); 670 qDebug(msg);
671 } 671 }
672 char path[256]; 672 char path[256];
673 if( FtpPwd( path,sizeof(path),conn) == 0) { //this is easier than fudging the string 673 if( FtpPwd( path,sizeof(path),conn) == 0) { //this is easier than fudging the string
674 QString msg; 674 QString msg;
675 msg.sprintf(tr("Unable to get working dir\n")+"%s",FtpLastResponse(conn)); 675 msg.sprintf(tr("Unable to get working dir\n")+"%s",FtpLastResponse(conn));
676 msg.replace(QRegExp(":"),"\n"); 676 msg.replace(QRegExp(":"),"\n");
677 QMessageBox::message(tr("Note"),msg); 677 QMessageBox::message(tr("Note"),msg);
678 qDebug(msg); 678 qDebug(msg);
679 } 679 }
680 currentRemoteDir=path; 680 currentRemoteDir=path;
681 } else { 681 } else {
682 if(strItem.find("->",0,TRUE) != -1) { //symlink on some servers 682 if(strItem.find("->",0,TRUE) != -1) { //symlink on some servers
683 strItem=strItem.right( strItem.length() - strItem.find("->",0,TRUE) - 2 ); 683 strItem=strItem.right( strItem.length() - strItem.find("->",0,TRUE) - 2 );
684 strItem = strItem.stripWhiteSpace(); 684 strItem = strItem.stripWhiteSpace();
685 currentRemoteDir = strItem; 685 currentRemoteDir = strItem;
686 if( !remoteChDir( (const QString &)strItem)) { 686 if( !remoteChDir( (const QString &)strItem)) {
687 currentRemoteDir = oldRemoteCurrentDir; 687 currentRemoteDir = oldRemoteCurrentDir;
688 strItem=""; 688 strItem="";
689 qDebug("RemoteCurrentDir1 "+oldRemoteCurrentDir); 689// qDebug("RemoteCurrentDir1 "+oldRemoteCurrentDir);
690 } 690 }
691 } else if(strItem.find("/",0,TRUE) != -1) { // this is a directory 691 } else if(strItem.find("/",0,TRUE) != -1) { // this is a directory
692 qDebug("trying directory");
693 if( !remoteChDir( (const QString &)currentRemoteDir + strItem)) { 692 if( !remoteChDir( (const QString &)currentRemoteDir + strItem)) {
694 currentRemoteDir = oldRemoteCurrentDir; 693 currentRemoteDir = oldRemoteCurrentDir;
695 strItem=""; 694 strItem="";
696 qDebug("RemoteCurrentDir1 "+oldRemoteCurrentDir); 695// qDebug("RemoteCurrentDir1 "+oldRemoteCurrentDir);
697 696
698 } else { 697 } else {
699 currentRemoteDir = currentRemoteDir+strItem; 698 currentRemoteDir = currentRemoteDir+strItem;
700 } 699 }
701 } else { 700 } else {
702 qDebug("download "+strItem); 701 QCopEnvelope ( "QPE/System", "notBusy()" );
702 return;
703 } 703 }
704 } 704 }
705 remoteDirList( (const QString &)currentRemoteDir); //this also calls populate 705 remoteDirList( (const QString &)currentRemoteDir); //this also calls populate
706 if(currentRemoteDir.right(1) !="/") 706 if(currentRemoteDir.right(1) !="/")
707 currentRemoteDir +="/"; 707 currentRemoteDir +="/";
708 currentPathCombo->lineEdit()->setText( currentRemoteDir ); 708 currentPathCombo->lineEdit()->setText( currentRemoteDir);
709 fillRemoteCombo( (const QString &)currentDir); 709 fillRemoteCombo( (const QString &)currentRemoteDir);
710 QCopEnvelope ( "QPE/System", "notBusy()" ); 710// QCopEnvelope ( "QPE/System", "notBusy()" );
711 } 711 }
712} 712}
713 713
714void OpieFtp::localListClicked(QListViewItem *selectedItem) 714void OpieFtp::localListClicked(QListViewItem *selectedItem)
715{ 715{
716 if(selectedItem!= NULL) { 716 if(selectedItem!= NULL) {
717 717
718 QString strItem=selectedItem->text(0); 718 QString strItem=selectedItem->text(0);
719 QString strSize=selectedItem->text(1); 719 QString strSize=selectedItem->text(1);
720 strSize=strSize.stripWhiteSpace(); 720 strSize=strSize.stripWhiteSpace();
721 if(strItem.find("@",0,TRUE) !=-1 || strItem.find("->",0,TRUE) !=-1 ) { //if symlink 721 if(strItem.find("@",0,TRUE) !=-1 || strItem.find("->",0,TRUE) !=-1 ) { //if symlink
722 // is symlink 722 // is symlink
723 QString strItem2 = strItem.right( (strItem.length() - strItem.find("->",0,TRUE)) - 4); 723 QString strItem2 = strItem.right( (strItem.length() - strItem.find("->",0,TRUE)) - 4);
724 if(QDir(strItem2).exists() ) { 724 if(QDir(strItem2).exists() ) {
725 currentDir.cd(strItem2, TRUE); 725 currentDir.cd(strItem2, TRUE);
726 populateLocalView(); 726 populateLocalView();
727 } 727 }
728 } else { // not a symlink 728 } else { // not a symlink
729 if(strItem.find(". .",0,TRUE) && strItem.find("/",0,TRUE)!=-1 ) { 729 if(strItem.find(". .",0,TRUE) && strItem.find("/",0,TRUE)!=-1 ) {
730
730 if(QDir(QDir::cleanDirPath(currentDir.canonicalPath()+"/"+strItem)).exists() ) { 731 if(QDir(QDir::cleanDirPath(currentDir.canonicalPath()+"/"+strItem)).exists() ) {
731 strItem=QDir::cleanDirPath(currentDir.canonicalPath()+"/"+strItem); 732 strItem=QDir::cleanDirPath(currentDir.canonicalPath()+"/"+strItem);
732 currentDir.cd(strItem,FALSE); 733 currentDir.cd(strItem,FALSE);
733 populateLocalView(); 734 populateLocalView();
734 } else { 735 } else {
735 currentDir.cdUp(); 736 currentDir.cdUp();
736 populateLocalView(); 737 populateLocalView();
737 } 738 }
738 if(QDir(strItem).exists()){ 739 if(QDir(strItem).exists()){
739 currentDir.cd(strItem, TRUE); 740 currentDir.cd(strItem, TRUE);
740 populateLocalView(); 741 populateLocalView();
741 } 742 }
742 } else { 743 } else {
743 strItem=QDir::cleanDirPath(currentDir.canonicalPath()+"/"+strItem); 744 strItem=QDir::cleanDirPath(currentDir.canonicalPath()+"/"+strItem);
744 if( QFile::exists(strItem ) ) { 745 if( QFile::exists(strItem ) ) {
745 // qDebug("upload "+strItem); 746 // qDebug("upload "+strItem);
747 return;
746 } 748 }
747 } //end not symlink 749 } //end not symlink
748 chdir(strItem.latin1()); 750 chdir(strItem.latin1());
749 } 751 }
750 } 752 }
751} 753}
752 754
753void OpieFtp::doLocalCd() 755void OpieFtp::doLocalCd()
754{ 756{
755 localListClicked( Local_View->currentItem()); 757 localListClicked( Local_View->currentItem());
756} 758}
757 759
758void OpieFtp:: doRemoteCd() 760void OpieFtp:: doRemoteCd()
759{ 761{
760 remoteListClicked( Remote_View->currentItem()); 762 remoteListClicked( Remote_View->currentItem());
761 763
762} 764}
763 765
764void OpieFtp::showHidden() 766void OpieFtp::showHidden()
765{ 767{
766 if (!b) { 768 if (!b) {
767 currentDir.setFilter( QDir::Files | QDir::Dirs | QDir::Hidden | QDir::All); 769 currentDir.setFilter( QDir::Files | QDir::Dirs | QDir::Hidden | QDir::All);
768 localMenu->setItemChecked(localMenu->idAt(0),TRUE); 770 localMenu->setItemChecked(localMenu->idAt(0),TRUE);
769// currentDir.setSorting(/* QDir::Size*/ /*| QDir::Reversed | */QDir::DirsFirst); 771// currentDir.setSorting(/* QDir::Size*/ /*| QDir::Reversed | */QDir::DirsFirst);
770 b=TRUE; 772 b=TRUE;
771 773
772 } else { 774 } else {
773 currentDir.setFilter( QDir::Files | QDir::Dirs/* | QDir::Hidden*/ | QDir::All); 775 currentDir.setFilter( QDir::Files | QDir::Dirs/* | QDir::Hidden*/ | QDir::All);
774 localMenu->setItemChecked(localMenu->idAt(0),FALSE); 776 localMenu->setItemChecked(localMenu->idAt(0),FALSE);
775// currentDir.setSorting(/* QDir::Size*/ /*| QDir::Reversed | */QDir::DirsFirst); 777// currentDir.setSorting(/* QDir::Size*/ /*| QDir::Reversed | */QDir::DirsFirst);
776 b=FALSE; 778 b=FALSE;
777 } 779 }
@@ -1039,87 +1041,90 @@ void OpieFtp::currentPathComboChanged()
1039 } 1041 }
1040 1042
1041 remoteDirList( (const QString &)currentRemoteDir); 1043 remoteDirList( (const QString &)currentRemoteDir);
1042 } 1044 }
1043} 1045}
1044 1046
1045void OpieFtp::switchToLocalTab() 1047void OpieFtp::switchToLocalTab()
1046{ 1048{
1047 TabWidget->setCurrentPage(0); 1049 TabWidget->setCurrentPage(0);
1048} 1050}
1049 1051
1050void OpieFtp::switchToRemoteTab() 1052void OpieFtp::switchToRemoteTab()
1051{ 1053{
1052 TabWidget->setCurrentPage(1); 1054 TabWidget->setCurrentPage(1);
1053} 1055}
1054 1056
1055void OpieFtp::switchToConfigTab() 1057void OpieFtp::switchToConfigTab()
1056{ 1058{
1057 TabWidget->setCurrentPage(2); 1059 TabWidget->setCurrentPage(2);
1058} 1060}
1059 1061
1060void OpieFtp::readConfig() 1062void OpieFtp::readConfig()
1061{ 1063{
1062 fillCombos(); 1064 fillCombos();
1063 Config cfg("opieftp"); 1065 Config cfg("opieftp");
1064 cfg.setGroup("Server"); 1066 cfg.setGroup("Server");
1065 currentServerConfig = cfg.readNumEntry("currentServer", -1); 1067 currentServerConfig = cfg.readNumEntry("currentServer", -1);
1066 serverComboSelected( currentServerConfig); 1068 serverComboSelected( currentServerConfig);
1067} 1069}
1068 1070
1069void OpieFtp::writeConfig() 1071void OpieFtp::writeConfig()
1070{ 1072{
1071
1072 Config cfg("opieftp"); 1073 Config cfg("opieftp");
1073 cfg.setGroup("Server"); 1074 cfg.setGroup("Server");
1074 QString username, remoteServerStr, remotePathStr, password, port, temp; 1075 QString username, remoteServerStr, remotePathStr, password, port, temp;
1075 int numberOfEntries = cfg.readNumEntry("numberOfEntries",0); 1076 int numberOfEntries = cfg.readNumEntry("numberOfEntries",0);
1076 if( currentServerConfig == -1) { 1077 if( currentServerConfig == -1) {
1078 for (int i = 1; i <= numberOfEntries; i++) {
1079 temp.setNum(i);
1080 cfg.setGroup("Server");
1081 QString tempStr = cfg.readEntry( temp,"");
1082 }
1077 1083
1078 temp.setNum( numberOfEntries + 1); 1084 temp.setNum( numberOfEntries + 1);
1079 cfg.setGroup("Server"); 1085 cfg.setGroup("Server");
1080 remoteServerStr = cfg.readEntry( temp,""); 1086 remoteServerStr = cfg.readEntry( temp,"");
1081 int divider = remoteServerStr.length() - remoteServerStr.find(":",0,TRUE); 1087 int divider = remoteServerStr.length() - remoteServerStr.find(":",0,TRUE);
1082 remoteServerStr = remoteServerStr.left(remoteServerStr.length()-divider); 1088 remoteServerStr = remoteServerStr.left(remoteServerStr.length()-divider);
1083 1089
1084 temp.setNum(numberOfEntries+1); 1090 temp.setNum(numberOfEntries+1);
1085 cfg.setGroup("Server"); 1091 cfg.setGroup("Server");
1086 cfg.writeEntry( temp, ServerComboBox->currentText() +":"+PortSpinBox->cleanText() ); 1092 cfg.writeEntry( temp, ServerComboBox->currentText() +":"+PortSpinBox->cleanText() );
1087 cfg.setGroup(temp); 1093 cfg.setGroup(temp);
1088 cfg.writeEntry("RemotePath", remotePath->text()); 1094 cfg.writeEntry("RemotePath", remotePath->text());
1089 cfg.writeEntry("Username", UsernameComboBox->currentText()); 1095 cfg.writeEntry("Username", UsernameComboBox->currentText());
1090 cfg.writeEntryCrypt( UsernameComboBox->currentText(), PasswordEdit->text()); 1096 cfg.writeEntryCrypt( UsernameComboBox->currentText(), PasswordEdit->text());
1091 cfg.setGroup("Server"); 1097 cfg.setGroup("Server");
1092 cfg.writeEntry("numberOfEntries", QString::number(numberOfEntries + 1 )); 1098 cfg.writeEntry("numberOfEntries", QString::number(numberOfEntries + 1 ));
1093
1094 } 1099 }
1095} 1100}
1096 1101
1097void OpieFtp::fillCombos() 1102void OpieFtp::fillCombos()
1098{ 1103{
1099 Config cfg("opieftp"); 1104 Config cfg("opieftp");
1100 cfg.setGroup("Server"); 1105 cfg.setGroup("Server");
1101 QString username, remoteServerStr, remotePathStr, password, port, temp; 1106 QString username, remoteServerStr, remotePathStr, password, port, temp;
1102 int numberOfEntries = cfg.readNumEntry("numberOfEntries",0); 1107 int numberOfEntries = cfg.readNumEntry("numberOfEntries",0);
1103 for (int i = 1; i <= numberOfEntries; i++) { 1108 for (int i = 1; i <= numberOfEntries; i++) {
1104 temp.setNum(i); 1109 temp.setNum(i);
1105 cfg.setGroup("Server"); 1110 cfg.setGroup("Server");
1106 remoteServerStr = cfg.readEntry( temp,""); 1111 remoteServerStr = cfg.readEntry( temp,"");
1107 int divider = remoteServerStr.length() - remoteServerStr.find(":",0,TRUE); 1112 int divider = remoteServerStr.length() - remoteServerStr.find(":",0,TRUE);
1108 port = remoteServerStr.right( divider - 1); 1113 port = remoteServerStr.right( divider - 1);
1109 bool ok; 1114 bool ok;
1110 PortSpinBox->setValue( port.toInt(&ok,10)); 1115 PortSpinBox->setValue( port.toInt(&ok,10));
1111 1116
1112 remoteServerStr = remoteServerStr.left(remoteServerStr.length()-divider); 1117 remoteServerStr = remoteServerStr.left(remoteServerStr.length()-divider);
1113 ServerComboBox->insertItem( remoteServerStr ); 1118 ServerComboBox->insertItem( remoteServerStr );
1114// cfg.setGroup(temp); 1119// cfg.setGroup(temp);
1115 1120
1116// remotePathStr = cfg.readEntry(remoteServer,""); 1121// remotePathStr = cfg.readEntry(remoteServer,"");
1117// int divider = remoteServer.length() - remoteServer.find(":",0,TRUE); 1122// int divider = remoteServer.length() - remoteServer.find(":",0,TRUE);
1118// port = remoteServer.right( divider+1); 1123// port = remoteServer.right( divider+1);
1119// PortSpinBox->setValue( port); 1124// PortSpinBox->setValue( port);
1120 1125
1121// remoteServer = remoteServer.left(divider - 1); 1126// remoteServer = remoteServer.left(divider - 1);
1122// remotePath->setText( remotePathStr); 1127// remotePath->setText( remotePathStr);
1123 1128
1124// username = cfg.readEntry(temp); 1129// username = cfg.readEntry(temp);
1125// UsernameComboBox->insertItem(username); 1130// UsernameComboBox->insertItem(username);