summaryrefslogtreecommitdiff
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/net/opieftp/opieftp.cpp8
1 files changed, 4 insertions, 4 deletions
diff --git a/noncore/net/opieftp/opieftp.cpp b/noncore/net/opieftp/opieftp.cpp
index 36de842..6be28d6 100644
--- a/noncore/net/opieftp/opieftp.cpp
+++ b/noncore/net/opieftp/opieftp.cpp
@@ -226,193 +226,194 @@ OpieFtp::OpieFtp( )
226 deleteServerBtn = new QPushButton( "Delete Server", tab_3 , "OpenButton" ); 226 deleteServerBtn = new QPushButton( "Delete Server", tab_3 , "OpenButton" );
227 tabLayout_3->addMultiCellWidget( deleteServerBtn, 5, 5, 2, 3); 227 tabLayout_3->addMultiCellWidget( deleteServerBtn, 5, 5, 2, 3);
228 228
229 connect(deleteServerBtn,SIGNAL(clicked()),SLOT(deleteServer())); 229 connect(deleteServerBtn,SIGNAL(clicked()),SLOT(deleteServer()));
230 230
231 connectServerBtn = new QPushButton( "Connect", tab_3 , "ConnectButton" ); 231 connectServerBtn = new QPushButton( "Connect", tab_3 , "ConnectButton" );
232 tabLayout_3->addMultiCellWidget( connectServerBtn, 5, 5, 0, 1); 232 tabLayout_3->addMultiCellWidget( connectServerBtn, 5, 5, 0, 1);
233 connectServerBtn->setToggleButton(TRUE); 233 connectServerBtn->setToggleButton(TRUE);
234 connect(connectServerBtn,SIGNAL( toggled( bool)),SLOT( connectorBtnToggled(bool) )); 234 connect(connectServerBtn,SIGNAL( toggled( bool)),SLOT( connectorBtnToggled(bool) ));
235 235
236 QSpacerItem* spacer = new QSpacerItem( 20, 20, QSizePolicy::Minimum, QSizePolicy::Expanding ); 236 QSpacerItem* spacer = new QSpacerItem( 20, 20, QSizePolicy::Minimum, QSizePolicy::Expanding );
237 tabLayout_3->addItem( spacer, 5, 0 ); 237 tabLayout_3->addItem( spacer, 5, 0 );
238 238
239 TabWidget->insertTab( tab_3, tr( "Config" ) ); 239 TabWidget->insertTab( tab_3, tr( "Config" ) );
240 240
241 connect(TabWidget,SIGNAL(currentChanged(QWidget *)), 241 connect(TabWidget,SIGNAL(currentChanged(QWidget *)),
242 this,SLOT(tabChanged(QWidget*))); 242 this,SLOT(tabChanged(QWidget*)));
243 243
244 currentDir.setFilter( QDir::Files | QDir::Dirs/* | QDir::Hidden*/ | QDir::All); 244 currentDir.setFilter( QDir::Files | QDir::Dirs/* | QDir::Hidden*/ | QDir::All);
245 currentDir.setPath( QDir::currentDirPath()); 245 currentDir.setPath( QDir::currentDirPath());
246// currentDir.setSorting(/* QDir::Size*/ /*| QDir::Reversed | */QDir::DirsFirst); 246// currentDir.setSorting(/* QDir::Size*/ /*| QDir::Reversed | */QDir::DirsFirst);
247 247
248 currentPathCombo = new QComboBox( FALSE, this, "currentPathCombo" ); 248 currentPathCombo = new QComboBox( FALSE, this, "currentPathCombo" );
249 layout->addMultiCellWidget( currentPathCombo, 3, 3, 0, 3 ); 249 layout->addMultiCellWidget( currentPathCombo, 3, 3, 0, 3 );
250 currentPathCombo->setEditable(TRUE); 250 currentPathCombo->setEditable(TRUE);
251 currentPathCombo->lineEdit()->setText( currentDir.canonicalPath()); 251 currentPathCombo->lineEdit()->setText( currentDir.canonicalPath());
252 252
253 connect( currentPathCombo, SIGNAL( activated( const QString & ) ), 253 connect( currentPathCombo, SIGNAL( activated( const QString & ) ),
254 this, SLOT( currentPathComboActivated( const QString & ) ) ); 254 this, SLOT( currentPathComboActivated( const QString & ) ) );
255 255
256 connect( currentPathCombo->lineEdit(),SIGNAL(returnPressed()), 256 connect( currentPathCombo->lineEdit(),SIGNAL(returnPressed()),
257 this,SLOT(currentPathComboChanged())); 257 this,SLOT(currentPathComboChanged()));
258 258
259 ProgressBar = new QProgressBar( this, "ProgressBar" ); 259 ProgressBar = new QProgressBar( this, "ProgressBar" );
260 layout->addMultiCellWidget( ProgressBar, 4, 4, 0, 3 ); 260 layout->addMultiCellWidget( ProgressBar, 4, 4, 0, 3 );
261 261
262// fillCombos(); 262// fillCombos();
263 263
264 filterStr="*"; 264 filterStr="*";
265 b=FALSE; 265 b=FALSE;
266 populateLocalView(); 266 populateLocalView();
267 readConfig(); 267 readConfig();
268 ServerComboBox->setCurrentItem(currentServerConfig); 268 ServerComboBox->setCurrentItem(currentServerConfig);
269 TabWidget->setCurrentPage(2); 269 TabWidget->setCurrentPage(2);
270} 270}
271 271
272OpieFtp::~OpieFtp() 272OpieFtp::~OpieFtp()
273{ 273{
274} 274}
275 275
276void OpieFtp::cleanUp() 276void OpieFtp::cleanUp()
277{ 277{
278 if(conn) 278 if(conn)
279 FtpQuit(conn); 279 FtpQuit(conn);
280 QString sfile=QDir::homeDirPath(); 280 QString sfile=QDir::homeDirPath();
281 if(sfile.right(1) != "/") 281 if(sfile.right(1) != "/")
282 sfile+="/._temp"; 282 sfile+="/._temp";
283 else 283 else
284 sfile+="._temp"; 284 sfile+="._temp";
285 QFile file( sfile); 285 QFile file( sfile);
286 if(file.exists()) 286 if(file.exists())
287 file.remove(); 287 file.remove();
288} 288}
289 289
290void OpieFtp::tabChanged(QWidget *w) 290void OpieFtp::tabChanged(QWidget *w)
291{ 291{
292 if (TabWidget->currentPageIndex() == 0) { 292 if (TabWidget->currentPageIndex() == 0) {
293 currentPathCombo->lineEdit()->setText( currentDir.canonicalPath()); 293 currentPathCombo->lineEdit()->setText( currentDir.canonicalPath());
294 tabMenu->setItemChecked(tabMenu->idAt(0),TRUE); 294 tabMenu->setItemChecked(tabMenu->idAt(0),TRUE);
295 tabMenu->setItemChecked(tabMenu->idAt(1),FALSE); 295 tabMenu->setItemChecked(tabMenu->idAt(1),FALSE);
296 tabMenu->setItemChecked(tabMenu->idAt(2),FALSE); 296 tabMenu->setItemChecked(tabMenu->idAt(2),FALSE);
297 } 297 }
298 if (TabWidget->currentPageIndex() == 1) { 298 if (TabWidget->currentPageIndex() == 1) {
299 currentPathCombo->lineEdit()->setText( currentRemoteDir ); 299 currentPathCombo->lineEdit()->setText( currentRemoteDir );
300 tabMenu->setItemChecked(tabMenu->idAt(1),TRUE); 300 tabMenu->setItemChecked(tabMenu->idAt(1),TRUE);
301 tabMenu->setItemChecked(tabMenu->idAt(0),FALSE); 301 tabMenu->setItemChecked(tabMenu->idAt(0),FALSE);
302 tabMenu->setItemChecked(tabMenu->idAt(2),FALSE); 302 tabMenu->setItemChecked(tabMenu->idAt(2),FALSE);
303 } 303 }
304 if (TabWidget->currentPageIndex() == 2) { 304 if (TabWidget->currentPageIndex() == 2) {
305 tabMenu->setItemChecked(tabMenu->idAt(2),TRUE); 305 tabMenu->setItemChecked(tabMenu->idAt(2),TRUE);
306 tabMenu->setItemChecked(tabMenu->idAt(0),FALSE); 306 tabMenu->setItemChecked(tabMenu->idAt(0),FALSE);
307 tabMenu->setItemChecked(tabMenu->idAt(1),FALSE); 307 tabMenu->setItemChecked(tabMenu->idAt(1),FALSE);
308 } 308 }
309} 309}
310 310
311void OpieFtp::newConnection() 311void OpieFtp::newConnection()
312{ 312{
313 UsernameComboBox->lineEdit()->setText(""); 313 UsernameComboBox->lineEdit()->setText("");
314 PasswordEdit->setText( "" ); 314 PasswordEdit->setText( "" );
315 ServerComboBox->lineEdit()->setText( ""); 315 ServerComboBox->lineEdit()->setText( "");
316 remotePath->setText( currentRemoteDir = "/"); 316 remotePath->setText( currentRemoteDir = "/");
317 PortSpinBox->setValue( 21); 317 PortSpinBox->setValue( 21);
318 TabWidget->setCurrentPage(2); 318 TabWidget->setCurrentPage(2);
319 currentServerConfig = -1; 319 currentServerConfig = -1;
320} 320}
321 321
322void OpieFtp::serverComboEdited(const QString & edit) { 322void OpieFtp::serverComboEdited(const QString & edit)
323{
323 if( !edit.isEmpty() ) { 324 if( !edit.isEmpty() ) {
324 currentServerConfig = -1; 325 currentServerConfig = -1;
325// qDebug("comboedited"); 326// qDebug("comboedited");
326 } 327 }
327} 328}
328 329
329void OpieFtp::connectorBtnToggled(bool On) 330void OpieFtp::connectorBtnToggled(bool On)
330{ 331{
331 if(On) { 332 if(On) {
332 connector(); 333 connector();
333 } else { 334 } else {
334 disConnector(); 335 disConnector();
335 } 336 }
336 337
337} 338}
338 339
339void OpieFtp::connector() 340void OpieFtp::connector()
340{ 341{
341 QCopEnvelope ( "QPE/System", "busy()" ); 342 QCopEnvelope ( "QPE/System", "busy()" );
342// qApp->processEvents(); 343// qApp->processEvents();
343 currentRemoteDir=remotePath->text(); 344 currentRemoteDir=remotePath->text();
344 if(ServerComboBox->currentText().isEmpty()) { 345 if(ServerComboBox->currentText().isEmpty()) {
345 QMessageBox::warning(this,tr("Ftp"),tr("Please set the server info"),tr("Ok"),0,0); 346 QMessageBox::warning(this,tr("Ftp"),tr("Please set the server info"),tr("Ok"),0,0);
346 TabWidget->setCurrentPage(2); 347 TabWidget->setCurrentPage(2);
347 ServerComboBox->setFocus(); 348 ServerComboBox->setFocus();
348 connectServerBtn->setOn(FALSE); 349 connectServerBtn->setOn(FALSE);
349 connectServerBtn->setText( tr("Connect")); 350 connectServerBtn->setText( tr("Connect"));
350 return; 351 return;
351 } 352 }
352 FtpInit(); 353 FtpInit();
353 TabWidget->setCurrentPage(1); 354 TabWidget->setCurrentPage(1);
354 QString ftp_host = ServerComboBox->currentText(); 355 QString ftp_host = ServerComboBox->currentText();
355 QString ftp_user = UsernameComboBox->currentText(); 356 QString ftp_user = UsernameComboBox->currentText();
356 QString ftp_pass = PasswordEdit->text(); 357 QString ftp_pass = PasswordEdit->text();
357 QString port=PortSpinBox->cleanText(); 358 QString port=PortSpinBox->cleanText();
358 port.stripWhiteSpace(); 359 port.stripWhiteSpace();
359 360
360 if(ftp_host.find("ftp://",0, TRUE) != -1 ) 361 if(ftp_host.find("ftp://",0, TRUE) != -1 )
361 ftp_host=ftp_host.right(ftp_host.length()-6); 362 ftp_host=ftp_host.right(ftp_host.length()-6);
362 ftp_host+=":"+port; 363 ftp_host+=":"+port;
363 if (!FtpConnect( ftp_host.latin1(), &conn)) { 364 if (!FtpConnect( ftp_host.latin1(), &conn)) {
364 QMessageBox::message(tr("Note"),tr("Unable to connect to\n")+ftp_host); 365 QMessageBox::message(tr("Note"),tr("Unable to connect to\n")+ftp_host);
365 connectServerBtn->setOn(FALSE); 366 connectServerBtn->setOn(FALSE);
366 connectServerBtn->setText( tr("Connect")); 367 connectServerBtn->setText( tr("Connect"));
367 return ; 368 return ;
368 } 369 }
369 if (!FtpLogin( ftp_user.latin1(), ftp_pass.latin1(),conn )) { 370 if (!FtpLogin( ftp_user.latin1(), ftp_pass.latin1(),conn )) {
370 QString msg; 371 QString msg;
371 msg.sprintf(tr("Unable to log in\n")+"%s",FtpLastResponse(conn)); 372 msg.sprintf(tr("Unable to log in\n")+"%s",FtpLastResponse(conn));
372 msg.replace(QRegExp(":"),"\n"); 373 msg.replace(QRegExp(":"),"\n");
373 QMessageBox::message(tr("Note"),msg); 374 QMessageBox::message(tr("Note"),msg);
374 if(conn) 375 if(conn)
375 FtpQuit(conn); 376 FtpQuit(conn);
376 connectServerBtn->setOn(FALSE); 377 connectServerBtn->setOn(FALSE);
377 connectServerBtn->setText( tr("Connect")); 378 connectServerBtn->setText( tr("Connect"));
378 return ; 379 return ;
379 } 380 }
380 remoteDirList("/") ; 381 remoteDirList("/") ;
381 setCaption(ftp_host); 382 setCaption(ftp_host);
382 writeConfig(); 383 writeConfig();
383 connectServerBtn->setText( tr("Disconnect")); 384 connectServerBtn->setText( tr("Disconnect"));
384 QCopEnvelope ( "QPE/System", "notBusy()" ); 385 QCopEnvelope ( "QPE/System", "notBusy()" );
385} 386}
386 387
387void OpieFtp::disConnector() 388void OpieFtp::disConnector()
388{ 389{
389 if(conn) 390 if(conn)
390 FtpQuit(conn); 391 FtpQuit(conn);
391 setCaption("OpieFtp"); 392 setCaption("OpieFtp");
392 currentRemoteDir="/"; 393 currentRemoteDir="/";
393 Remote_View->clear(); 394 Remote_View->clear();
394 connectServerBtn->setText( tr("Connect")); 395 connectServerBtn->setText( tr("Connect"));
395 connectServerBtn->setOn(FALSE); 396 connectServerBtn->setOn(FALSE);
396 397
397} 398}
398 399
399void OpieFtp::localUpload() 400void OpieFtp::localUpload()
400{ 401{
401 int fsz; 402 int fsz;
402 QCopEnvelope ( "QPE/System", "busy()" ); 403 QCopEnvelope ( "QPE/System", "busy()" );
403// qApp->processEvents(); 404// qApp->processEvents();
404 QList<QListViewItem> * getSelectedItems( QListView * Local_View ); 405 QList<QListViewItem> * getSelectedItems( QListView * Local_View );
405 QListViewItemIterator it( Local_View ); 406 QListViewItemIterator it( Local_View );
406 for ( ; it.current(); ++it ) { 407 for ( ; it.current(); ++it ) {
407 if ( it.current()->isSelected() ) { 408 if ( it.current()->isSelected() ) {
408 QString strItem = it.current()->text(0); 409 QString strItem = it.current()->text(0);
409 QString localFile = currentDir.canonicalPath()+"/"+strItem; 410 QString localFile = currentDir.canonicalPath()+"/"+strItem;
410 QString remoteFile= currentRemoteDir+strItem; 411 QString remoteFile= currentRemoteDir+strItem;
411 QFileInfo fi(localFile); 412 QFileInfo fi(localFile);
412 if( !fi.isDir()) { 413 if( !fi.isDir()) {
413 fsz=fi.size(); 414 fsz=fi.size();
414 ProgressBar->setTotalSteps(fsz); 415 ProgressBar->setTotalSteps(fsz);
415 416
416 FtpOptions(FTPLIB_CALLBACK, (long) log_progress, conn); 417 FtpOptions(FTPLIB_CALLBACK, (long) log_progress, conn);
417 FtpOptions(FTPLIB_IDLETIME, (long) 1000, conn); 418 FtpOptions(FTPLIB_IDLETIME, (long) 1000, conn);
418 FtpOptions(FTPLIB_CALLBACKARG, (long) &fsz, conn); 419 FtpOptions(FTPLIB_CALLBACKARG, (long) &fsz, conn);
@@ -561,251 +562,250 @@ void OpieFtp::populateLocalView()
561 } 562 }
562 if(fileL !="./" && fi->exists()) { 563 if(fileL !="./" && fi->exists()) {
563 item= new QListViewItem( Local_View,fileL,fileS , fileDate); 564 item= new QListViewItem( Local_View,fileL,fileS , fileDate);
564 QPixmap pm; 565 QPixmap pm;
565 566
566 if(isDir || fileL.find("/",0,TRUE) != -1) { 567 if(isDir || fileL.find("/",0,TRUE) != -1) {
567 if( !QDir( fi->filePath() ).isReadable()) 568 if( !QDir( fi->filePath() ).isReadable())
568 pm = Resource::loadPixmap( "lockedfolder" ); 569 pm = Resource::loadPixmap( "lockedfolder" );
569 else 570 else
570 pm= Resource::loadPixmap( "folder" ); 571 pm= Resource::loadPixmap( "folder" );
571 item->setPixmap( 0,pm ); 572 item->setPixmap( 0,pm );
572 } else { 573 } else {
573 if( !fi->isReadable() ) 574 if( !fi->isReadable() )
574 pm = Resource::loadPixmap( "locked" ); 575 pm = Resource::loadPixmap( "locked" );
575 else { 576 else {
576 MimeType mt(fi->filePath()); 577 MimeType mt(fi->filePath());
577 pm=mt.pixmap(); //sets the correct pixmap for mimetype 578 pm=mt.pixmap(); //sets the correct pixmap for mimetype
578 if(pm.isNull()) 579 if(pm.isNull())
579 pm = Resource::loadPixmap( "UnknownDocument-14" ); 580 pm = Resource::loadPixmap( "UnknownDocument-14" );
580 item->setPixmap( 0,pm); 581 item->setPixmap( 0,pm);
581 } 582 }
582 } 583 }
583 if( fileL.find("->",0,TRUE) != -1) { 584 if( fileL.find("->",0,TRUE) != -1) {
584 // overlay link image 585 // overlay link image
585 pm= Resource::loadPixmap( "folder" ); 586 pm= Resource::loadPixmap( "folder" );
586 QPixmap lnk = Resource::loadPixmap( "symlink" ); 587 QPixmap lnk = Resource::loadPixmap( "symlink" );
587 QPainter painter( &pm ); 588 QPainter painter( &pm );
588 painter.drawPixmap( pm.width()-lnk.width(), pm.height()-lnk.height(), lnk ); 589 painter.drawPixmap( pm.width()-lnk.width(), pm.height()-lnk.height(), lnk );
589 pm.setMask( pm.createHeuristicMask( FALSE ) ); 590 pm.setMask( pm.createHeuristicMask( FALSE ) );
590 item->setPixmap( 0, pm); 591 item->setPixmap( 0, pm);
591 } 592 }
592 } 593 }
593 isDir=FALSE; 594 isDir=FALSE;
594 ++it; 595 ++it;
595 } 596 }
596 Local_View->setSorting( 3,FALSE); 597 Local_View->setSorting( 3,FALSE);
597 currentPathCombo->lineEdit()->setText( currentDir.canonicalPath() ); 598 currentPathCombo->lineEdit()->setText( currentDir.canonicalPath() );
598 fillCombo( (const QString &)currentDir); 599 fillCombo( (const QString &)currentDir);
599} 600}
600 601
601bool OpieFtp::populateRemoteView( ) 602bool OpieFtp::populateRemoteView( )
602{ 603{
603// qDebug("populate remoteview"); 604// qDebug("populate remoteview");
604 QString sfile=QDir::homeDirPath(); 605 QString sfile=QDir::homeDirPath();
605 if(sfile.right(1) != "/") 606 if(sfile.right(1) != "/")
606 sfile+="/._temp"; 607 sfile+="/._temp";
607 else 608 else
608 sfile+="._temp"; 609 sfile+="._temp";
609 QFile file( sfile); 610 QFile file( sfile);
610 Remote_View->clear(); 611 Remote_View->clear();
611 QString s, File_Name; 612 QString s, File_Name;
612 QListViewItem *itemDir=NULL, *itemFile=NULL; 613 QListViewItem *itemDir=NULL, *itemFile=NULL;
613 QString fileL, fileS, fileDate; 614 QString fileL, fileS, fileDate;
614 if ( file.open(IO_ReadOnly)) { 615 if ( file.open(IO_ReadOnly)) {
615 QTextStream t( &file ); // use a text stream 616 QTextStream t( &file ); // use a text stream
616 while ( !t.eof()) { 617 while ( !t.eof()) {
617 s = t.readLine(); 618 s = t.readLine();
618 fileL = s.right(s.length()-55); 619 fileL = s.right(s.length()-55);
619 fileL = fileL.stripWhiteSpace(); 620 fileL = fileL.stripWhiteSpace();
620 if(s.left(1) == "d") 621 if(s.left(1) == "d")
621 fileL = fileL+"/"; 622 fileL = fileL+"/";
622// fileL = "/"+fileL+"/"; 623// fileL = "/"+fileL+"/";
623 fileS = s.mid( 30, 42-30); 624 fileS = s.mid( 30, 42-30);
624 fileS = fileS.stripWhiteSpace(); 625 fileS = fileS.stripWhiteSpace();
625 fileDate = s.mid( 42, 55-42); 626 fileDate = s.mid( 42, 55-42);
626 fileDate = fileDate.stripWhiteSpace(); 627 fileDate = fileDate.stripWhiteSpace();
627 if(fileL.find("total",0,TRUE) == -1) { 628 if(fileL.find("total",0,TRUE) == -1) {
628 if(s.left(1) == "d" || fileL.find("/",0,TRUE) != -1) { 629 if(s.left(1) == "d" || fileL.find("/",0,TRUE) != -1) {
629 QListViewItem * item = new QListViewItem( Remote_View, fileL, fileS, fileDate,"d"); 630 QListViewItem * item = new QListViewItem( Remote_View, fileL, fileS, fileDate,"d");
630 item->setPixmap( 0, Resource::loadPixmap( "folder" )); 631 item->setPixmap( 0, Resource::loadPixmap( "folder" ));
631// if(itemDir) 632// if(itemDir)
632 item->moveItem(itemDir); 633 item->moveItem(itemDir);
633 itemDir=item; 634 itemDir=item;
634 } else { 635 } else {
635 QListViewItem * item = new QListViewItem( Remote_View, fileL, fileS, fileDate,"f"); 636 QListViewItem * item = new QListViewItem( Remote_View, fileL, fileS, fileDate,"f");
636 item->setPixmap( 0, Resource::loadPixmap( "fileopen" )); 637 item->setPixmap( 0, Resource::loadPixmap( "fileopen" ));
637// if(itemFile) 638// if(itemFile)
638 item->moveItem(itemDir); 639 item->moveItem(itemDir);
639 item->moveItem(itemFile); 640 item->moveItem(itemFile);
640 itemFile=item; 641 itemFile=item;
641 } 642 }
642 } 643 }
643 } 644 }
644 QListViewItem * item1 = new QListViewItem( Remote_View, "../"); 645 QListViewItem * item1 = new QListViewItem( Remote_View, "../");
645 item1->setPixmap( 0, Resource::loadPixmap( "folder" )); 646 item1->setPixmap( 0, Resource::loadPixmap( "folder" ));
646 file.close(); 647 file.close();
647 if( file.exists()) 648 if( file.exists())
648 file. remove(); 649 file. remove();
649 } else 650 } else
650 qDebug("temp file not opened successfullly "+sfile); 651 qDebug("temp file not opened successfullly "+sfile);
651 Remote_View->setSorting( 4,TRUE); 652 Remote_View->setSorting( 4,TRUE);
652 return true; 653 return true;
653} 654}
654 655
655void OpieFtp::remoteListClicked(QListViewItem *selectedItem) 656void OpieFtp::remoteListClicked(QListViewItem *selectedItem)
656{ 657{
657 if(item) { 658 if( selectedItem) {
658 QCopEnvelope ( "QPE/System", "busy()" ); 659 QCopEnvelope ( "QPE/System", "busy()" );
659 QString oldRemoteCurrentDir = currentRemoteDir; 660 QString oldRemoteCurrentDir = currentRemoteDir;
660 QString strItem=selectedItem->text(0); 661 QString strItem=selectedItem->text(0);
661 strItem=strItem.simplifyWhiteSpace(); 662 strItem=strItem.simplifyWhiteSpace();
662 if(strItem == "../") { // the user wants to go ^ 663 if(strItem == "../") { // the user wants to go ^
663 if( FtpCDUp( conn) == 0) { 664 if( FtpCDUp( conn) == 0) {
664 QString msg; 665 QString msg;
665 msg.sprintf(tr("Unable to cd up\n")+"%s",FtpLastResponse(conn)); 666 msg.sprintf(tr("Unable to cd up\n")+"%s",FtpLastResponse(conn));
666 msg.replace(QRegExp(":"),"\n"); 667 msg.replace(QRegExp(":"),"\n");
667 QMessageBox::message(tr("Note"),msg); 668 QMessageBox::message(tr("Note"),msg);
668 qDebug(msg); 669 qDebug(msg);
669 } 670 }
670 char path[256]; 671 char path[256];
671 if( FtpPwd( path,sizeof(path),conn) == 0) { //this is easier than fudging the string 672 if( FtpPwd( path,sizeof(path),conn) == 0) { //this is easier than fudging the string
672 QString msg; 673 QString msg;
673 msg.sprintf(tr("Unable to get working dir\n")+"%s",FtpLastResponse(conn)); 674 msg.sprintf(tr("Unable to get working dir\n")+"%s",FtpLastResponse(conn));
674 msg.replace(QRegExp(":"),"\n"); 675 msg.replace(QRegExp(":"),"\n");
675 QMessageBox::message(tr("Note"),msg); 676 QMessageBox::message(tr("Note"),msg);
676 qDebug(msg); 677 qDebug(msg);
677 } 678 }
678 currentRemoteDir=path; 679 currentRemoteDir=path;
679 } else { 680 } else {
680 if(strItem.find("->",0,TRUE) != -1) { //symlink on some servers 681 if(strItem.find("->",0,TRUE) != -1) { //symlink on some servers
681 strItem=strItem.right( strItem.length() - strItem.find("->",0,TRUE) - 2 ); 682 strItem=strItem.right( strItem.length() - strItem.find("->",0,TRUE) - 2 );
682 strItem = strItem.stripWhiteSpace(); 683 strItem = strItem.stripWhiteSpace();
683 currentRemoteDir = strItem; 684 currentRemoteDir = strItem;
684 if( !remoteChDir( (const QString &)strItem)) { 685 if( !remoteChDir( (const QString &)strItem)) {
685 currentRemoteDir = oldRemoteCurrentDir; 686 currentRemoteDir = oldRemoteCurrentDir;
686 strItem=""; 687 strItem="";
687 qDebug("RemoteCurrentDir1 "+oldRemoteCurrentDir); 688 qDebug("RemoteCurrentDir1 "+oldRemoteCurrentDir);
688 } 689 }
689 } else if(strItem.find("/",0,TRUE) != -1) { // this is a directory 690 } else if(strItem.find("/",0,TRUE) != -1) { // this is a directory
690 qDebug("trying directory"); 691 qDebug("trying directory");
691 if( !remoteChDir( (const QString &)currentRemoteDir + strItem)) { 692 if( !remoteChDir( (const QString &)currentRemoteDir + strItem)) {
692 currentRemoteDir = oldRemoteCurrentDir; 693 currentRemoteDir = oldRemoteCurrentDir;
693 strItem=""; 694 strItem="";
694 qDebug("RemoteCurrentDir1 "+oldRemoteCurrentDir); 695 qDebug("RemoteCurrentDir1 "+oldRemoteCurrentDir);
695 696
696 } else { 697 } else {
697 currentRemoteDir = currentRemoteDir+strItem; 698 currentRemoteDir = currentRemoteDir+strItem;
698 } 699 }
699 } else { 700 } else {
700 qDebug("download "+strItem); 701 qDebug("download "+strItem);
701 } 702 }
702 } 703 }
703 remoteDirList( (const QString &)currentRemoteDir); //this also calls populate 704 remoteDirList( (const QString &)currentRemoteDir); //this also calls populate
704 if(currentRemoteDir.right(1) !="/") 705 if(currentRemoteDir.right(1) !="/")
705 currentRemoteDir +="/"; 706 currentRemoteDir +="/";
706 currentPathCombo->lineEdit()->setText( currentRemoteDir ); 707 currentPathCombo->lineEdit()->setText( currentRemoteDir );
707 fillRemoteCombo( (const QString &)currentDir); 708 fillRemoteCombo( (const QString &)currentDir);
708 QCopEnvelope ( "QPE/System", "notBusy()" ); 709 QCopEnvelope ( "QPE/System", "notBusy()" );
709 } 710 }
710} 711}
711 712
712void OpieFtp::localListClicked(QListViewItem *selectedItem) 713void OpieFtp::localListClicked(QListViewItem *selectedItem)
713{ 714{
714// qDebug(selectedItem->text(0)); 715 if(selectedItem!= NULL) {
715 if(item!= NULL) {
716 716
717 QString strItem=selectedItem->text(0); 717 QString strItem=selectedItem->text(0);
718 QString strSize=selectedItem->text(1); 718 QString strSize=selectedItem->text(1);
719 strSize=strSize.stripWhiteSpace(); 719 strSize=strSize.stripWhiteSpace();
720 if(strItem.find("@",0,TRUE) !=-1 || strItem.find("->",0,TRUE) !=-1 ) { //if symlink 720 if(strItem.find("@",0,TRUE) !=-1 || strItem.find("->",0,TRUE) !=-1 ) { //if symlink
721 // is symlink 721 // is symlink
722 QString strItem2 = strItem.right( (strItem.length() - strItem.find("->",0,TRUE)) - 4); 722 QString strItem2 = strItem.right( (strItem.length() - strItem.find("->",0,TRUE)) - 4);
723 if(QDir(strItem2).exists() ) { 723 if(QDir(strItem2).exists() ) {
724 currentDir.cd(strItem2, TRUE); 724 currentDir.cd(strItem2, TRUE);
725 populateLocalView(); 725 populateLocalView();
726 } 726 }
727 } else { // not a symlink 727 } else { // not a symlink
728 if(strItem.find(". .",0,TRUE) && strItem.find("/",0,TRUE)!=-1 ) { 728 if(strItem.find(". .",0,TRUE) && strItem.find("/",0,TRUE)!=-1 ) {
729 if(QDir(QDir::cleanDirPath(currentDir.canonicalPath()+"/"+strItem)).exists() ) { 729 if(QDir(QDir::cleanDirPath(currentDir.canonicalPath()+"/"+strItem)).exists() ) {
730 strItem=QDir::cleanDirPath(currentDir.canonicalPath()+"/"+strItem); 730 strItem=QDir::cleanDirPath(currentDir.canonicalPath()+"/"+strItem);
731 currentDir.cd(strItem,FALSE); 731 currentDir.cd(strItem,FALSE);
732 populateLocalView(); 732 populateLocalView();
733 } else { 733 } else {
734 currentDir.cdUp(); 734 currentDir.cdUp();
735 populateLocalView(); 735 populateLocalView();
736 } 736 }
737 if(QDir(strItem).exists()){ 737 if(QDir(strItem).exists()){
738 currentDir.cd(strItem, TRUE); 738 currentDir.cd(strItem, TRUE);
739 populateLocalView(); 739 populateLocalView();
740 } 740 }
741 } else { 741 } else {
742 strItem=QDir::cleanDirPath(currentDir.canonicalPath()+"/"+strItem); 742 strItem=QDir::cleanDirPath(currentDir.canonicalPath()+"/"+strItem);
743 if( QFile::exists(strItem ) ) { 743 if( QFile::exists(strItem ) ) {
744 // qDebug("upload "+strItem); 744 // qDebug("upload "+strItem);
745 } 745 }
746 } //end not symlink 746 } //end not symlink
747 chdir(strItem.latin1()); 747 chdir(strItem.latin1());
748 } 748 }
749 } 749 }
750} 750}
751 751
752void OpieFtp::doLocalCd() 752void OpieFtp::doLocalCd()
753{ 753{
754 localListClicked( Local_View->currentItem()); 754 localListClicked( Local_View->currentItem());
755} 755}
756 756
757void OpieFtp:: doRemoteCd() 757void OpieFtp:: doRemoteCd()
758{ 758{
759 remoteListClicked( Remote_View->currentItem()); 759 remoteListClicked( Remote_View->currentItem());
760 760
761} 761}
762 762
763void OpieFtp::showHidden() 763void OpieFtp::showHidden()
764{ 764{
765 if (!b) { 765 if (!b) {
766 currentDir.setFilter( QDir::Files | QDir::Dirs | QDir::Hidden | QDir::All); 766 currentDir.setFilter( QDir::Files | QDir::Dirs | QDir::Hidden | QDir::All);
767 localMenu->setItemChecked(localMenu->idAt(0),TRUE); 767 localMenu->setItemChecked(localMenu->idAt(0),TRUE);
768// currentDir.setSorting(/* QDir::Size*/ /*| QDir::Reversed | */QDir::DirsFirst); 768// currentDir.setSorting(/* QDir::Size*/ /*| QDir::Reversed | */QDir::DirsFirst);
769 b=TRUE; 769 b=TRUE;
770 770
771 } else { 771 } else {
772 currentDir.setFilter( QDir::Files | QDir::Dirs/* | QDir::Hidden*/ | QDir::All); 772 currentDir.setFilter( QDir::Files | QDir::Dirs/* | QDir::Hidden*/ | QDir::All);
773 localMenu->setItemChecked(localMenu->idAt(0),FALSE); 773 localMenu->setItemChecked(localMenu->idAt(0),FALSE);
774// currentDir.setSorting(/* QDir::Size*/ /*| QDir::Reversed | */QDir::DirsFirst); 774// currentDir.setSorting(/* QDir::Size*/ /*| QDir::Reversed | */QDir::DirsFirst);
775 b=FALSE; 775 b=FALSE;
776 } 776 }
777 populateLocalView(); 777 populateLocalView();
778} 778}
779 779
780void OpieFtp::ListPressed( int mouse, QListViewItem *item, const QPoint &point, int i) 780void OpieFtp::ListPressed( int mouse, QListViewItem *item, const QPoint &point, int i)
781{ 781{
782// if(item) 782// if(item)
783if (mouse == 2) { 783if (mouse == 2) {
784 showLocalMenu(item); 784 showLocalMenu(item);
785 } 785 }
786} 786}
787 787
788void OpieFtp::RemoteListPressed( int mouse, QListViewItem *item, const QPoint &point, int i) 788void OpieFtp::RemoteListPressed( int mouse, QListViewItem *item, const QPoint &point, int i)
789{ 789{
790 switch (mouse) { 790 switch (mouse) {
791 case 1: 791 case 1:
792 break; 792 break;
793 case 2: 793 case 2:
794 showRemoteMenu(item); 794 showRemoteMenu(item);
795 break; 795 break;
796 }; 796 };
797} 797}
798 798
799void OpieFtp::showRemoteMenu(QListViewItem * item) 799void OpieFtp::showRemoteMenu(QListViewItem * item)
800{ 800{
801 QPopupMenu m;// = new QPopupMenu( Local_View ); 801 QPopupMenu m;// = new QPopupMenu( Local_View );
802 if( /*item->text(0).right(1) == "/" ||*/ item->text(0).find("/",0,TRUE) != -1) 802 if( /*item->text(0).right(1) == "/" ||*/ item->text(0).find("/",0,TRUE) != -1)
803 m.insertItem( tr( "Change Directory" ), this, SLOT( doRemoteCd() )); 803 m.insertItem( tr( "Change Directory" ), this, SLOT( doRemoteCd() ));
804 else 804 else
805 m.insertItem( tr( "Download" ), this, SLOT( remoteDownload() )); 805 m.insertItem( tr( "Download" ), this, SLOT( remoteDownload() ));
806 m.insertItem( tr( "Make Directory" ), this, SLOT( remoteMakDir() )); 806 m.insertItem( tr( "Make Directory" ), this, SLOT( remoteMakDir() ));
807 m.insertItem( tr( "Rename" ), this, SLOT( remoteRename() )); 807 m.insertItem( tr( "Rename" ), this, SLOT( remoteRename() ));
808 m.insertSeparator(); 808 m.insertSeparator();
809 m.insertItem( tr( "Delete" ), this, SLOT( remoteDelete() )); 809 m.insertItem( tr( "Delete" ), this, SLOT( remoteDelete() ));
810 m.exec( QCursor::pos() ); 810 m.exec( QCursor::pos() );
811} 811}