summaryrefslogtreecommitdiff
authorllornkcor <llornkcor>2004-07-07 21:00:39 (UTC)
committer llornkcor <llornkcor>2004-07-07 21:00:39 (UTC)
commit30d8a50aba298e26a3d3cc1d5b6a0c69c1d2783d (patch) (unidiff)
tree686ad6e5b4873c5c3046442e106c99cb6f9a0907
parente6a4d3d3e45f1a39aafb3ecfe298611621590d22 (diff)
downloadopie-30d8a50aba298e26a3d3cc1d5b6a0c69c1d2783d.zip
opie-30d8a50aba298e26a3d3cc1d5b6a0c69c1d2783d.tar.gz
opie-30d8a50aba298e26a3d3cc1d5b6a0c69c1d2783d.tar.bz2
bug fix 1267
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/net/opieftp/opieftp.cpp27
1 files changed, 14 insertions, 13 deletions
diff --git a/noncore/net/opieftp/opieftp.cpp b/noncore/net/opieftp/opieftp.cpp
index aa4314a..817943b 100644
--- a/noncore/net/opieftp/opieftp.cpp
+++ b/noncore/net/opieftp/opieftp.cpp
@@ -13,65 +13,64 @@
13 13
14#include "opieftp.h" 14#include "opieftp.h"
15 15
16extern "C" { 16extern "C" {
17#include <ftplib.h> 17#include <ftplib.h>
18} 18}
19 19
20#include "inputDialog.h" 20#include "inputDialog.h"
21 21
22/* OPIE */ 22/* OPIE */
23#include <opie2/odebug.h> 23#include <opie2/odebug.h>
24#include <qpe/qpeapplication.h> 24#include <qpe/qpeapplication.h>
25#include <qpe/resource.h> 25#include <qpe/resource.h>
26#include <qpe/config.h> 26#include <qpe/config.h>
27#include <qpe/mimetype.h> 27#include <qpe/mimetype.h>
28using namespace Opie::Core; 28using namespace Opie::Core;
29 29
30#include <qtextstream.h> 30#include <qtextstream.h>
31#include <qpushbutton.h> 31#include <qpushbutton.h>
32#include <qtoolbutton.h> 32#include <qtoolbutton.h>
33#include <qcombobox.h> 33#include <qcombobox.h>
34#include <qlistview.h> 34#include <qlistview.h>
35#include <qlabel.h> 35#include <qlabel.h>
36#include <qprogressbar.h> 36#include <qprogressbar.h>
37#include <qspinbox.h> 37#include <qspinbox.h>
38#include <qtabwidget.h> 38#include <qtabwidget.h>
39#include <qlayout.h> 39#include <qlayout.h>
40#include <qmessagebox.h> 40#include <qmessagebox.h>
41#include <qmenubar.h> 41#include <qmenubar.h>
42#include <qlineedit.h> 42#include <qlineedit.h>
43#include <qlistbox.h> 43#include <qlistbox.h>
44#include <qvbox.h> 44#include <qvbox.h>
45
46/* STD */ 45/* STD */
47#include <unistd.h> 46#include <unistd.h>
48#include <stdlib.h> 47#include <stdlib.h>
49 48
50QProgressBar *ProgressBar; 49QProgressBar *ProgressBar;
51static netbuf *conn=NULL; 50static netbuf *conn=NULL;
52 51
53static int log_progress(netbuf *, int xfered, void *) 52static int log_progress(netbuf *, int xfered, void *)
54{ 53{
55// int fsz = *(int *)arg; 54// int fsz = *(int *)arg;
56// int pct = (xfered * 100) / fsz; 55// int pct = (xfered * 100) / fsz;
57// printf("%3d%%\r", pct); 56// printf("%3d%%\r", pct);
58// fflush(stdout); 57// fflush(stdout);
59 ProgressBar->setProgress(xfered); 58 ProgressBar->setProgress(xfered);
60 qApp->processEvents(); 59 qApp->processEvents();
61 return 1; 60 return 1;
62} 61}
63 62
64OpieFtp::OpieFtp( QWidget* parent, const char* name, WFlags fl) 63OpieFtp::OpieFtp( QWidget* parent, const char* name, WFlags fl)
65 : QMainWindow( parent, name, fl ) 64 : QMainWindow( parent, name, fl )
66{ 65{
67 odebug << "OpieFtp constructor" << oendl; 66 odebug << "OpieFtp constructor" << oendl;
68 setCaption( tr( "OpieFtp" ) ); 67 setCaption( tr( "OpieFtp" ) );
69 fuckeduphack=FALSE; 68 fuckeduphack=FALSE;
70 69
71 QVBox* wrapperBox = new QVBox( this ); 70 QVBox* wrapperBox = new QVBox( this );
72 setCentralWidget( wrapperBox ); 71 setCentralWidget( wrapperBox );
73 72
74 QWidget *view = new QWidget( wrapperBox ); 73 QWidget *view = new QWidget( wrapperBox );
75 74
76 QGridLayout *layout = new QGridLayout( view ); 75 QGridLayout *layout = new QGridLayout( view );
77 layout->setSpacing( 2); 76 layout->setSpacing( 2);
@@ -273,94 +272,88 @@ OpieFtp::OpieFtp( QWidget* parent, const char* name, WFlags fl)
273 PortSpinBox = new QSpinBox( tab_3, "PortSpinBox" ); 272 PortSpinBox = new QSpinBox( tab_3, "PortSpinBox" );
274 PortSpinBox->setButtonSymbols( QSpinBox::UpDownArrows ); 273 PortSpinBox->setButtonSymbols( QSpinBox::UpDownArrows );
275 PortSpinBox->setMaxValue(32786); 274 PortSpinBox->setMaxValue(32786);
276 tabLayout_3->addMultiCellWidget( PortSpinBox, 4, 4, 1, 1); 275 tabLayout_3->addMultiCellWidget( PortSpinBox, 4, 4, 1, 1);
277 276
278 serverListView = new QListBox( tab_3, "ServerListView" ); 277 serverListView = new QListBox( tab_3, "ServerListView" );
279 tabLayout_3->addMultiCellWidget( serverListView , 5, 5, 0, 5); 278 tabLayout_3->addMultiCellWidget( serverListView , 5, 5, 0, 5);
280 279
281 connect( serverListView, SIGNAL( highlighted(const QString&)), 280 connect( serverListView, SIGNAL( highlighted(const QString&)),
282 this,SLOT( serverListClicked(const QString&) ) ); 281 this,SLOT( serverListClicked(const QString&) ) );
283 282
284 connectServerBtn = new QPushButton( tr("Connect"), tab_3 , "ConnectButton" ); 283 connectServerBtn = new QPushButton( tr("Connect"), tab_3 , "ConnectButton" );
285 tabLayout_3->addMultiCellWidget( connectServerBtn, 6, 6, 0, 1); 284 tabLayout_3->addMultiCellWidget( connectServerBtn, 6, 6, 0, 1);
286 connectServerBtn->setToggleButton(TRUE); 285 connectServerBtn->setToggleButton(TRUE);
287 connect(connectServerBtn,SIGNAL( toggled(bool)),SLOT( connectorBtnToggled(bool) )); 286 connect(connectServerBtn,SIGNAL( toggled(bool)),SLOT( connectorBtnToggled(bool) ));
288 287
289 newServerButton= new QPushButton( tr("Add"), tab_3 , "NewServerButton" ); 288 newServerButton= new QPushButton( tr("Add"), tab_3 , "NewServerButton" );
290 tabLayout_3->addMultiCellWidget( newServerButton, 6, 6, 2, 2); 289 tabLayout_3->addMultiCellWidget( newServerButton, 6, 6, 2, 2);
291 connect( newServerButton,SIGNAL( clicked()),SLOT( NewServer() )); 290 connect( newServerButton,SIGNAL( clicked()),SLOT( NewServer() ));
292 291
293 QPushButton *deleteServerBtn; 292 QPushButton *deleteServerBtn;
294 deleteServerBtn = new QPushButton( tr("Delete"), tab_3 , "OpenButton" ); 293 deleteServerBtn = new QPushButton( tr("Delete"), tab_3 , "OpenButton" );
295 tabLayout_3->addMultiCellWidget( deleteServerBtn, 6, 6, 3, 3); 294 tabLayout_3->addMultiCellWidget( deleteServerBtn, 6, 6, 3, 3);
296 295
297 connect(deleteServerBtn,SIGNAL(clicked()),SLOT(deleteServer())); 296 connect(deleteServerBtn,SIGNAL(clicked()),SLOT(deleteServer()));
298 297
299 298
300 QSpacerItem* spacer = new QSpacerItem( 20, 20, QSizePolicy::Minimum, QSizePolicy::Expanding ); 299 QSpacerItem* spacer = new QSpacerItem( 20, 20, QSizePolicy::Minimum, QSizePolicy::Expanding );
301 tabLayout_3->addItem( spacer, 5, 0 ); 300 tabLayout_3->addItem( spacer, 5, 0 );
302 301
303 TabWidget->insertTab( tab_3, tr( "Config" ) ); 302 TabWidget->insertTab( tab_3, tr( "Config" ) );
304 303
305#if 0
306 connect(TabWidget,SIGNAL(currentChanged(QWidget*)), 304 connect(TabWidget,SIGNAL(currentChanged(QWidget*)),
307 this,SLOT(tabChanged(QWidget*))); 305 this,SLOT(tabChanged(QWidget*)));
308#endif
309 306
310 currentDir.setFilter( QDir::Files | QDir::Dirs/* | QDir::Hidden*/ | QDir::All); 307 currentDir.setFilter( QDir::Files | QDir::Dirs/* | QDir::Hidden*/ | QDir::All);
311 currentDir.setPath( QDir::currentDirPath()); 308 currentDir.setPath( QDir::currentDirPath());
312// currentDir.setSorting(/* QDir::Size*/ /*| QDir::Reversed | */QDir::DirsFirst); 309// currentDir.setSorting(/* QDir::Size*/ /*| QDir::Reversed | */QDir::DirsFirst);
313 310
314 currentPathCombo = new QComboBox( FALSE, view, "currentPathCombo" ); 311 currentPathCombo = new QComboBox( FALSE, view, "currentPathCombo" );
315 layout->addMultiCellWidget( currentPathCombo, 3, 3, 0, 4); 312 layout->addMultiCellWidget( currentPathCombo, 3, 3, 0, 4);
316 currentPathCombo ->setFixedWidth(220); 313 currentPathCombo ->setFixedWidth(220);
317 currentPathCombo->setEditable(TRUE); 314 currentPathCombo->setEditable(TRUE);
318 currentPathCombo->lineEdit()->setText( currentDir.canonicalPath()); 315 currentPathCombo->lineEdit()->setText( currentDir.canonicalPath());
319 316
320#if 0
321 connect( currentPathCombo, SIGNAL( activated(const QString&) ), 317 connect( currentPathCombo, SIGNAL( activated(const QString&) ),
322 this, SLOT( currentPathComboActivated(const QString&) ) ); 318 this, SLOT( currentPathComboActivated(const QString&) ) );
323 319
324 connect( currentPathCombo->lineEdit(),SIGNAL(returnPressed()), 320 connect( currentPathCombo->lineEdit(),SIGNAL(returnPressed()),
325 this,SLOT(currentPathComboChanged())); 321 this,SLOT(currentPathComboChanged()));
326#endif
327 ProgressBar = new QProgressBar( view, "ProgressBar" ); 322 ProgressBar = new QProgressBar( view, "ProgressBar" );
328 layout->addMultiCellWidget( ProgressBar, 4, 4, 0, 4); 323 layout->addMultiCellWidget( ProgressBar, 4, 4, 0, 4);
329 ProgressBar->setMaximumHeight(10); 324 ProgressBar->setMaximumHeight(10);
330 filterStr="*"; 325 filterStr="*";
331 b=FALSE; 326 b=FALSE;
332#if 0
333 populateLocalView(); 327 populateLocalView();
334#endif
335 readConfig(); 328 readConfig();
336 329
337// ServerComboBox->setCurrentItem(currentServerConfig); 330// ServerComboBox->setCurrentItem(currentServerConfig);
338 331
339 TabWidget->setCurrentPage(2); 332 TabWidget->setCurrentPage(2);
340 odebug << "Constructor done" << oendl; 333 odebug << "Constructor done" << oendl;
341} 334}
342 335
343OpieFtp::~OpieFtp() 336OpieFtp::~OpieFtp()
344{ 337{
345} 338}
346 339
347void OpieFtp::cleanUp() 340void OpieFtp::cleanUp()
348{ 341{
349 if(conn) 342 if(conn)
350 FtpQuit(conn); 343 FtpQuit(conn);
351 QString sfile=QDir::homeDirPath(); 344 QString sfile=QDir::homeDirPath();
352 if(sfile.right(1) != "/") 345 if(sfile.right(1) != "/")
353 sfile+="/._temp"; 346 sfile+="/._temp";
354 else 347 else
355 sfile+="._temp"; 348 sfile+="._temp";
356 QFile file( sfile); 349 QFile file( sfile);
357 if(file.exists()) 350 if(file.exists())
358 file.remove(); 351 file.remove();
359 Config cfg("opieftp"); 352 Config cfg("opieftp");
360 cfg.setGroup("Server"); 353 cfg.setGroup("Server");
361 cfg.writeEntry("currentServer", currentServerConfig); 354 cfg.writeEntry("currentServer", currentServerConfig);
362 355
363 exit(0); 356 exit(0);
364} 357}
365 358
366void OpieFtp::tabChanged(QWidget *) 359void OpieFtp::tabChanged(QWidget *)
@@ -638,116 +631,118 @@ bool OpieFtp::remoteDirList(const QString &dir)
638} 631}
639 632
640bool OpieFtp::remoteChDir(const QString &dir) 633bool OpieFtp::remoteChDir(const QString &dir)
641{ 634{
642// QCopEnvelope ( "QPE/System", "busy()" ); 635// QCopEnvelope ( "QPE/System", "busy()" );
643 if (!FtpChdir( dir.latin1(), conn )) { 636 if (!FtpChdir( dir.latin1(), conn )) {
644 QString msg; 637 QString msg;
645 msg.sprintf(tr("Unable to change directories\n")+dir+"\n%s",FtpLastResponse(conn)); 638 msg.sprintf(tr("Unable to change directories\n")+dir+"\n%s",FtpLastResponse(conn));
646 msg.replace(QRegExp(":"),"\n"); 639 msg.replace(QRegExp(":"),"\n");
647 QMessageBox::message(tr("Note"),msg); 640 QMessageBox::message(tr("Note"),msg);
648// odebug << msg << oendl; 641// odebug << msg << oendl;
649// QCopEnvelope ( "QPE/System", "notBusy()" ); 642// QCopEnvelope ( "QPE/System", "notBusy()" );
650 return FALSE; 643 return FALSE;
651 } 644 }
652// QCopEnvelope ( "QPE/System", "notBusy()" ); 645// QCopEnvelope ( "QPE/System", "notBusy()" );
653 return TRUE; 646 return TRUE;
654} 647}
655 648
656void OpieFtp::populateLocalView() 649void OpieFtp::populateLocalView()
657{ 650{
658 Local_View->clear(); 651 Local_View->clear();
659 currentDir.setSorting(/* QDir::Size*/ /*| QDir::Reversed | */QDir::DirsFirst); 652 currentDir.setSorting(/* QDir::Size*/ /*| QDir::Reversed | */QDir::DirsFirst);
660 currentDir.setMatchAllDirs(TRUE); 653 currentDir.setMatchAllDirs(TRUE);
661 currentDir.setNameFilter(filterStr); 654 currentDir.setNameFilter(filterStr);
662 QString fileL, fileS, fileDate; 655 QString fileL, fileS, fileDate;
663 bool isDir=FALSE; 656 bool isDir=FALSE;
664 const QFileInfoList *list = currentDir.entryInfoList( /*QDir::All*/ /*, QDir::SortByMask*/); 657 const QFileInfoList *list = currentDir.entryInfoList( /*QDir::All*/ /*, QDir::SortByMask*/);
665 QFileInfoListIterator it(*list); 658 QFileInfoListIterator it(*list);
666 QFileInfo *fi; 659 QFileInfo *fi;
667 while ( (fi=it.current()) ) { 660 while ( (fi=it.current()) ) {
668 if (fi->isSymLink() ){ 661 if (fi->isSymLink() ){
669 QString symLink=fi->readLink(); 662 QString symLink=fi->readLink();
670 odebug << "Symlink detected "+symLink << oendl; 663// odebug << "Symlink detected "+symLink << oendl;
671 QFileInfo sym( symLink); 664 QFileInfo sym( symLink);
672 fileS.sprintf( "%10i", sym.size() ); 665 fileS.sprintf( "%10i", sym.size() );
673 fileL.sprintf( "%s -> %s", fi->fileName().data(),sym.absFilePath().data() ); 666 fileL.sprintf( "%s -> %s", fi->fileName().data(),sym.absFilePath().data() );
674 fileDate = sym.lastModified().toString(); 667 fileDate = sym.lastModified().toString();
675 } else { 668 } else {
676 odebug << "Not a dir: "+currentDir.canonicalPath()+fileL << oendl; 669// odebug << "Not a dir: "+currentDir.canonicalPath()+fileL << oendl;
677 fileS.sprintf( "%10i", fi->size() ); 670 fileS.sprintf( "%10i", fi->size() );
678 fileL.sprintf( "%s",fi->fileName().data() ); 671 fileL.sprintf( "%s",fi->fileName().data() );
679 fileDate= fi->lastModified().toString(); 672 fileDate= fi->lastModified().toString();
680 if( QDir(QDir::cleanDirPath(currentDir.canonicalPath()+"/"+fileL)).exists() ) { 673 if( QDir(QDir::cleanDirPath(currentDir.canonicalPath()+"/"+fileL)).exists() ) {
681 fileL+="/"; 674 fileL+="/";
682 isDir=TRUE; 675 isDir=TRUE;
683 odebug << fileL << oendl; 676// odebug << fileL << oendl;
684 } 677 }
685 } 678 }
679
680
686 if(fileL !="./" && fi->exists()) { 681 if(fileL !="./" && fi->exists()) {
687 item = new QListViewItem( Local_View,fileL, fileDate, fileS ); 682 item = new QListViewItem( Local_View,fileL, fileDate, fileS );
688 QPixmap pm; 683 QPixmap pm;
689 684
690 if(isDir || fileL.find("/",0,TRUE) != -1) { 685 if(isDir || fileL.find("/",0,TRUE) != -1) {
691 if( !QDir( fi->filePath() ).isReadable()) 686 if( !QDir( fi->filePath() ).isReadable())
692 pm = Resource::loadPixmap( "lockedfolder" ); 687 pm = Resource::loadPixmap( "lockedfolder" );
693 else 688 else
694 pm= Resource::loadPixmap( "folder" ); 689 pm= Resource::loadPixmap( "folder" );
695 item->setPixmap( 0,pm ); 690 item->setPixmap( 0,pm );
696 } else { 691 } else {
697 if( !fi->isReadable() ) 692 if( !fi->isReadable() )
698 pm = Resource::loadPixmap( "locked" ); 693 pm = Resource::loadPixmap( "locked" );
699 else { 694 else {
700 MimeType mt(fi->filePath()); 695 MimeType mt(fi->filePath());
701 pm=mt.pixmap(); //sets the correct pixmap for mimetype 696 pm=mt.pixmap(); //sets the correct pixmap for mimetype
702 if(pm.isNull()) 697 if(pm.isNull())
703 pm = unknownXpm; 698 pm = unknownXpm;
704 } 699 }
705 } 700 }
706 if( fileL.find("->",0,TRUE) != -1) { 701 if( fileL.find("->",0,TRUE) != -1) {
707 // overlay link image 702 // overlay link image
708 pm= Resource::loadPixmap( "folder" ); 703 pm= Resource::loadPixmap( "folder" );
709 QPixmap lnk = Resource::loadPixmap( "opie/symlink" ); 704 QPixmap lnk = Resource::loadPixmap( "opie/symlink" );
710 QPainter painter( &pm ); 705 QPainter painter( &pm );
711 painter.drawPixmap( pm.width()-lnk.width(), pm.height()-lnk.height(), lnk ); 706 painter.drawPixmap( pm.width()-lnk.width(), pm.height()-lnk.height(), lnk );
712 pm.setMask( pm.createHeuristicMask( FALSE ) ); 707 pm.setMask( pm.createHeuristicMask( FALSE ) );
713 } 708 }
714 item->setPixmap( 0,pm); 709 item->setPixmap( 0,pm);
715 } 710 }
716 isDir=FALSE; 711 isDir=FALSE;
717 ++it; 712 ++it;
718 } 713 }
719 Local_View->setSorting( 3,FALSE); 714 Local_View->setSorting( 3,FALSE);
720 currentPathCombo->lineEdit()->setText( currentDir.canonicalPath() ); 715 currentPathCombo->lineEdit()->setText( currentDir.canonicalPath() );
721 fillCombo( (const QString &)currentDir); 716 // fillCombo( (const QString &)currentDir);
722} 717}
723 718
724bool OpieFtp::populateRemoteView( ) 719bool OpieFtp::populateRemoteView( )
725{ 720{
726// odebug << "populate remoteview" << oendl; 721// odebug << "populate remoteview" << oendl;
727 QString sfile=QDir::homeDirPath(); 722 QString sfile=QDir::homeDirPath();
728 if(sfile.right(1) != "/") 723 if(sfile.right(1) != "/")
729 sfile+="/._temp"; 724 sfile+="/._temp";
730 else 725 else
731 sfile+="._temp"; 726 sfile+="._temp";
732 QFile file( sfile); 727 QFile file( sfile);
733 Remote_View->clear(); 728 Remote_View->clear();
734 QString s, File_Name; 729 QString s, File_Name;
735 QListViewItem *itemDir=NULL, *itemFile=NULL; 730 QListViewItem *itemDir=NULL, *itemFile=NULL;
736 QRegExp monthRe(" [JFMASOND][eapuecoe][brynlgptvc] [ 0-9][0-9] [ 0-9][0-9][:0-9][0-9][0-9] "); 731 QRegExp monthRe(" [JFMASOND][eapuecoe][brynlgptvc] [ 0-9][0-9] [ 0-9][0-9][:0-9][0-9][0-9] ");
737 QString fileL, fileS, fileDate; 732 QString fileL, fileS, fileDate;
738 if ( file.open(IO_ReadOnly)) { 733 if ( file.open(IO_ReadOnly)) {
739 QTextStream t( &file ); // use a text stream 734 QTextStream t( &file ); // use a text stream
740 while ( !t.eof()) { 735 while ( !t.eof()) {
741 s = t.readLine(); 736 s = t.readLine();
742 737
743 if(s.find("total",0,TRUE) == 0) 738 if(s.find("total",0,TRUE) == 0)
744 continue; 739 continue;
745 740
746 int len, month = monthRe.match(s, 0, &len); 741 int len, month = monthRe.match(s, 0, &len);
747 fileDate = s.mid(month + 1, len - 2); // minus spaces 742 fileDate = s.mid(month + 1, len - 2); // minus spaces
748 fileL = s.right(s.length() - month - len); 743 fileL = s.right(s.length() - month - len);
749 if(s.left(1) == "d") 744 if(s.left(1) == "d")
750 fileL = fileL+"/"; 745 fileL = fileL+"/";
751 fileS = s.mid(month - 8, 8); // FIXME 746 fileS = s.mid(month - 8, 8); // FIXME
752 fileS = fileS.stripWhiteSpace(); 747 fileS = fileS.stripWhiteSpace();
753 748
@@ -1116,73 +1111,78 @@ void OpieFtp::remoteRename()
1116void OpieFtp::localRename() 1111void OpieFtp::localRename()
1117{ 1112{
1118 QString curFile = Local_View->currentItem()->text(0); 1113 QString curFile = Local_View->currentItem()->text(0);
1119 InputDialog *fileDlg; 1114 InputDialog *fileDlg;
1120 fileDlg = new InputDialog(this,tr("Rename"),TRUE, 0); 1115 fileDlg = new InputDialog(this,tr("Rename"),TRUE, 0);
1121 fileDlg->setTextEdit((const QString &)curFile); 1116 fileDlg->setTextEdit((const QString &)curFile);
1122 fileDlg->exec(); 1117 fileDlg->exec();
1123 if( fileDlg->result() == 1 ) { 1118 if( fileDlg->result() == 1 ) {
1124 QString oldname = currentDir.canonicalPath() + "/" + curFile; 1119 QString oldname = currentDir.canonicalPath() + "/" + curFile;
1125 QString newName = currentDir.canonicalPath() + "/" + fileDlg->LineEdit1->text();//+".playlist"; 1120 QString newName = currentDir.canonicalPath() + "/" + fileDlg->LineEdit1->text();//+".playlist";
1126 if( rename(oldname.latin1(), newName.latin1())== -1) 1121 if( rename(oldname.latin1(), newName.latin1())== -1)
1127 QMessageBox::message(tr("Note"),tr("Could not rename")); 1122 QMessageBox::message(tr("Note"),tr("Could not rename"));
1128 } 1123 }
1129 populateLocalView(); 1124 populateLocalView();
1130} 1125}
1131 1126
1132void OpieFtp::currentPathComboActivated(const QString & currentPath) { 1127void OpieFtp::currentPathComboActivated(const QString & currentPath) {
1133 if (TabWidget->currentPageIndex() == 0) { 1128 if (TabWidget->currentPageIndex() == 0) {
1134 chdir( currentPath.latin1() ); 1129 chdir( currentPath.latin1() );
1135 currentDir.cd( currentPath, TRUE); 1130 currentDir.cd( currentPath, TRUE);
1136 populateLocalView(); 1131 populateLocalView();
1137 update(); 1132 update();
1138 } else { 1133 } else {
1139// chdir( currentPath.latin1() ); 1134// chdir( currentPath.latin1() );
1140// currentDir.cd( currentPath, TRUE); 1135// currentDir.cd( currentPath, TRUE);
1141// populateList(); 1136// populateList();
1142// update(); 1137// update();
1143 1138
1144 } 1139 }
1145} 1140}
1146 1141
1147void OpieFtp::fillCombo(const QString &currentPath) { 1142void OpieFtp::fillCombo(const QString &currentPath) {
1148 1143 qDebug("Fill Combo "+currentPath);
1149 currentPathCombo->lineEdit()->setText(currentPath); 1144 currentPathCombo->lineEdit()->setText(currentPath);
1145
1150 if( localDirPathStringList.grep(currentPath,TRUE).isEmpty() ) { 1146 if( localDirPathStringList.grep(currentPath,TRUE).isEmpty() ) {
1147 qDebug("Clearing local");
1151 currentPathCombo->clear(); 1148 currentPathCombo->clear();
1152 localDirPathStringList.prepend(currentPath ); 1149 localDirPathStringList.prepend(currentPath );
1153 currentPathCombo->insertStringList( localDirPathStringList,-1); 1150 currentPathCombo->insertStringList( localDirPathStringList,-1);
1154 } 1151 }
1152
1155 currentPathCombo->lineEdit()->setText(currentPath); 1153 currentPathCombo->lineEdit()->setText(currentPath);
1156 if( remoteDirPathStringList.grep(currentPath,TRUE).isEmpty() ) { 1154
1155 if( remoteDirPathStringList.grep(currentPath,TRUE).isEmpty() ) {
1156 qDebug("Clearing remote");
1157 currentPathCombo->clear(); 1157 currentPathCombo->clear();
1158 remoteDirPathStringList.prepend(currentPath ); 1158 remoteDirPathStringList.prepend(currentPath );
1159 currentPathCombo->insertStringList( remoteDirPathStringList,-1); 1159 currentPathCombo->insertStringList( remoteDirPathStringList,-1);
1160 } 1160 }
1161} 1161}
1162 1162
1163void OpieFtp::fillRemoteCombo(const QString &currentPath) { 1163void OpieFtp::fillRemoteCombo(const QString &currentPath) {
1164 1164
1165 currentPathCombo->lineEdit()->setText(currentPath); 1165 currentPathCombo->lineEdit()->setText(currentPath);
1166 if( remoteDirPathStringList.grep(currentPath,TRUE).isEmpty() ) { 1166 if( remoteDirPathStringList.grep(currentPath,TRUE).isEmpty() ) {
1167 currentPathCombo->clear(); 1167 currentPathCombo->clear();
1168 remoteDirPathStringList.prepend(currentPath ); 1168 remoteDirPathStringList.prepend(currentPath );
1169 currentPathCombo->insertStringList( remoteDirPathStringList,-1); 1169 currentPathCombo->insertStringList( remoteDirPathStringList,-1);
1170 } 1170 }
1171} 1171}
1172 1172
1173void OpieFtp::currentPathComboChanged() 1173void OpieFtp::currentPathComboChanged()
1174{ 1174{
1175 QString oldRemoteCurrentDir = currentRemoteDir; 1175 QString oldRemoteCurrentDir = currentRemoteDir;
1176// odebug << "oldRemoteCurrentDir "+oldRemoteCurrentDir << oendl; 1176// odebug << "oldRemoteCurrentDir "+oldRemoteCurrentDir << oendl;
1177 if (TabWidget->currentPageIndex() == 0) { 1177 if (TabWidget->currentPageIndex() == 0) {
1178 if(QDir( currentPathCombo->lineEdit()->text()).exists()) { 1178 if(QDir( currentPathCombo->lineEdit()->text()).exists()) {
1179 currentDir.setPath( currentPathCombo->lineEdit()->text() ); 1179 currentDir.setPath( currentPathCombo->lineEdit()->text() );
1180 populateLocalView(); 1180 populateLocalView();
1181 } else { 1181 } else {
1182 QMessageBox::message(tr("Note"),tr("That directory does not exist")); 1182 QMessageBox::message(tr("Note"),tr("That directory does not exist"));
1183 } 1183 }
1184 } 1184 }
1185 if (TabWidget->currentPageIndex() == 1) { 1185 if (TabWidget->currentPageIndex() == 1) {
1186 currentRemoteDir = currentPathCombo->lineEdit()->text(); 1186 currentRemoteDir = currentPathCombo->lineEdit()->text();
1187 if(currentRemoteDir.right(1) !="/") { 1187 if(currentRemoteDir.right(1) !="/") {
1188 currentRemoteDir = currentRemoteDir +"/"; 1188 currentRemoteDir = currentRemoteDir +"/";
@@ -1258,64 +1258,65 @@ void OpieFtp::writeConfig()
1258 1258
1259 currentServerConfig = numberOfEntries+1; 1259 currentServerConfig = numberOfEntries+1;
1260 odebug << "setting currentserverconfig to " << currentServerConfig << "" << oendl; 1260 odebug << "setting currentserverconfig to " << currentServerConfig << "" << oendl;
1261 1261
1262 cfg.setGroup(temp); 1262 cfg.setGroup(temp);
1263 if(!newServerName.isEmpty()) 1263 if(!newServerName.isEmpty())
1264 cfg.writeEntry("ServerName", newServerName); 1264 cfg.writeEntry("ServerName", newServerName);
1265 1265
1266 cfg.writeEntry("RemotePath", remotePath->text()); 1266 cfg.writeEntry("RemotePath", remotePath->text());
1267 1267
1268 cfg.writeEntry("Username", UsernameComboBox->currentText()); 1268 cfg.writeEntry("Username", UsernameComboBox->currentText());
1269 1269
1270 cfg.writeEntryCrypt( UsernameComboBox->currentText(), PasswordEdit->text()); 1270 cfg.writeEntryCrypt( UsernameComboBox->currentText(), PasswordEdit->text());
1271 cfg.setGroup("Server"); 1271 cfg.setGroup("Server");
1272 1272
1273 cfg.writeEntry("numberOfEntries", QString::number(numberOfEntries + 1 )); 1273 cfg.writeEntry("numberOfEntries", QString::number(numberOfEntries + 1 ));
1274 1274
1275 } 1275 }
1276} 1276}
1277 1277
1278void OpieFtp::clearCombos() { 1278void OpieFtp::clearCombos() {
1279 odebug << "clearing" << oendl; 1279 odebug << "clearing" << oendl;
1280 ServerComboBox->clear(); 1280 ServerComboBox->clear();
1281 UsernameComboBox->clear(); 1281 UsernameComboBox->clear();
1282 PasswordEdit->clear(); 1282 PasswordEdit->clear();
1283 serverListView->clear(); 1283 serverListView->clear();
1284} 1284}
1285 1285
1286 1286
1287void OpieFtp::fillCombos() 1287void OpieFtp::fillCombos()
1288{ 1288{
1289 clearCombos(); 1289 clearCombos();
1290 qDebug("did we get here yet?");
1290 1291
1291 Config cfg("opieftp"); 1292 Config cfg("opieftp");
1292 cfg.setGroup("Server"); 1293 cfg.setGroup("Server");
1293 QString username, remoteServerStr, remotePathStr, password, port, temp; 1294 QString username, remoteServerStr, remotePathStr, password, port, temp;
1294 int numberOfEntries = cfg.readNumEntry("numberOfEntries",0); 1295 int numberOfEntries = cfg.readNumEntry("numberOfEntries",0);
1295 1296
1296 for (int i = 1; i <= numberOfEntries; i++) { 1297 for (int i = 1; i <= numberOfEntries; i++) {
1297 temp.setNum(i); 1298 temp.setNum(i);
1298 odebug << temp << oendl; 1299 odebug << temp << oendl;
1299 cfg.setGroup("Server"); 1300 cfg.setGroup("Server");
1300 remoteServerStr = cfg.readEntry( temp,""); 1301 remoteServerStr = cfg.readEntry( temp,"");
1301 odebug << remoteServerStr << oendl; 1302 odebug << remoteServerStr << oendl;
1302 1303
1303 int divider = remoteServerStr.length() - remoteServerStr.find(":",0,TRUE); 1304 int divider = remoteServerStr.length() - remoteServerStr.find(":",0,TRUE);
1304 port = remoteServerStr.right( divider - 1); 1305 port = remoteServerStr.right( divider - 1);
1305 bool ok; 1306 bool ok;
1306 PortSpinBox->setValue( port.toInt(&ok,10)); 1307 PortSpinBox->setValue( port.toInt(&ok,10));
1307 1308
1308 remoteServerStr = remoteServerStr.left(remoteServerStr.length()-divider); 1309 remoteServerStr = remoteServerStr.left(remoteServerStr.length()-divider);
1309 odebug << "remote server string "+remoteServerStr << oendl; 1310 odebug << "remote server string "+remoteServerStr << oendl;
1310 ServerComboBox->insertItem( remoteServerStr ); 1311 ServerComboBox->insertItem( remoteServerStr );
1311 1312
1312 cfg.setGroup(temp); 1313 cfg.setGroup(temp);
1313 1314
1314 username = cfg.readEntry(temp); 1315 username = cfg.readEntry(temp);
1315 UsernameComboBox->insertItem(username); 1316 UsernameComboBox->insertItem(username);
1316 password = cfg.readEntryCrypt(username,""); 1317 password = cfg.readEntryCrypt(username,"");
1317 PasswordEdit->setText(password); 1318 PasswordEdit->setText(password);
1318 1319
1319 serverListView->insertItem( cfg.readEntry("ServerName")); 1320 serverListView->insertItem( cfg.readEntry("ServerName"));
1320 } 1321 }
1321} 1322}