author | llornkcor <llornkcor> | 2004-07-07 21:00:39 (UTC) |
---|---|---|
committer | llornkcor <llornkcor> | 2004-07-07 21:00:39 (UTC) |
commit | 30d8a50aba298e26a3d3cc1d5b6a0c69c1d2783d (patch) (unidiff) | |
tree | 686ad6e5b4873c5c3046442e106c99cb6f9a0907 /noncore/net | |
parent | e6a4d3d3e45f1a39aafb3ecfe298611621590d22 (diff) | |
download | opie-30d8a50aba298e26a3d3cc1d5b6a0c69c1d2783d.zip opie-30d8a50aba298e26a3d3cc1d5b6a0c69c1d2783d.tar.gz opie-30d8a50aba298e26a3d3cc1d5b6a0c69c1d2783d.tar.bz2 |
bug fix 1267
-rw-r--r-- | noncore/net/opieftp/opieftp.cpp | 27 |
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 | |||
@@ -33,25 +33,24 @@ using namespace Opie::Core; | |||
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 | ||
50 | QProgressBar *ProgressBar; | 49 | QProgressBar *ProgressBar; |
51 | static netbuf *conn=NULL; | 50 | static netbuf *conn=NULL; |
52 | 51 | ||
53 | static int log_progress(netbuf *, int xfered, void *) | 52 | static 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); |
@@ -293,54 +292,48 @@ OpieFtp::OpieFtp( QWidget* parent, const char* name, WFlags fl) | |||
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 | ||
343 | OpieFtp::~OpieFtp() | 336 | OpieFtp::~OpieFtp() |
344 | { | 337 | { |
345 | } | 338 | } |
346 | 339 | ||
@@ -658,40 +651,42 @@ void OpieFtp::populateLocalView() | |||
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() ) |
@@ -709,25 +704,25 @@ void OpieFtp::populateLocalView() | |||
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 | ||
724 | bool OpieFtp::populateRemoteView( ) | 719 | bool 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(); |
@@ -1136,33 +1131,38 @@ void OpieFtp::currentPathComboActivated(const QString & currentPath) { | |||
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 | ||
1147 | void OpieFtp::fillCombo(const QString ¤tPath) { | 1142 | void OpieFtp::fillCombo(const QString ¤tPath) { |
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 | ||
1163 | void OpieFtp::fillRemoteCombo(const QString ¤tPath) { | 1163 | void OpieFtp::fillRemoteCombo(const QString ¤tPath) { |
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 ); |
@@ -1278,24 +1278,25 @@ void OpieFtp::writeConfig() | |||
1278 | void OpieFtp::clearCombos() { | 1278 | void 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 | ||
1287 | void OpieFtp::fillCombos() | 1287 | void 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; |