-rw-r--r-- | noncore/net/opieftp/opieftp.cpp | 57 |
1 files changed, 48 insertions, 9 deletions
diff --git a/noncore/net/opieftp/opieftp.cpp b/noncore/net/opieftp/opieftp.cpp index 118275b..a3b29a1 100644 --- a/noncore/net/opieftp/opieftp.cpp +++ b/noncore/net/opieftp/opieftp.cpp | |||
@@ -32,32 +32,33 @@ | |||
32 | #include <qmainwindow.h> | 32 | #include <qmainwindow.h> |
33 | #include <qlabel.h> | 33 | #include <qlabel.h> |
34 | #include <qprogressbar.h> | 34 | #include <qprogressbar.h> |
35 | #include <qspinbox.h> | 35 | #include <qspinbox.h> |
36 | #include <qtabwidget.h> | 36 | #include <qtabwidget.h> |
37 | #include <qwidget.h> | 37 | #include <qwidget.h> |
38 | #include <qlayout.h> | 38 | #include <qlayout.h> |
39 | #include <qimage.h> | 39 | #include <qimage.h> |
40 | #include <qpixmap.h> | 40 | #include <qpixmap.h> |
41 | #include <qmessagebox.h> | 41 | #include <qmessagebox.h> |
42 | #include <qlineedit.h> | 42 | #include <qlineedit.h> |
43 | #include <qregexp.h> | 43 | #include <qregexp.h> |
44 | 44 | ||
45 | #include <unistd.h> | 45 | #include <unistd.h> |
46 | #include <stdlib.h> | 46 | #include <stdlib.h> |
47 | 47 | ||
48 | |||
48 | QProgressBar *ProgressBar; | 49 | QProgressBar *ProgressBar; |
49 | static netbuf *conn=NULL; | 50 | static netbuf *conn=NULL; |
50 | 51 | ||
51 | static int log_progress(netbuf *ctl, int xfered, void *arg) | 52 | static int log_progress(netbuf *ctl, int xfered, void *arg) |
52 | { | 53 | { |
53 | int fsz = *(int *)arg; | 54 | int fsz = *(int *)arg; |
54 | int pct = (xfered * 100) / fsz; | 55 | int pct = (xfered * 100) / fsz; |
55 | // printf("%3d%%\r", pct); | 56 | // printf("%3d%%\r", pct); |
56 | // fflush(stdout); | 57 | // fflush(stdout); |
57 | ProgressBar->setProgress(xfered); | 58 | ProgressBar->setProgress(xfered); |
58 | qApp->processEvents(); | 59 | qApp->processEvents(); |
59 | return 1; | 60 | return 1; |
60 | } | 61 | } |
61 | 62 | ||
62 | OpieFtp::OpieFtp( ) | 63 | OpieFtp::OpieFtp( ) |
63 | : QMainWindow( ) | 64 | : QMainWindow( ) |
@@ -81,33 +82,34 @@ OpieFtp::OpieFtp( ) | |||
81 | menuBar->insertItem( tr( "Connection" ), connectionMenu); | 82 | menuBar->insertItem( tr( "Connection" ), connectionMenu); |
82 | menuBar->insertItem( tr( "Local" ), localMenu); | 83 | menuBar->insertItem( tr( "Local" ), localMenu); |
83 | menuBar->insertItem( tr( "Remote" ), remoteMenu); | 84 | menuBar->insertItem( tr( "Remote" ), remoteMenu); |
84 | menuBar->insertItem( tr( "View" ), tabMenu); | 85 | menuBar->insertItem( tr( "View" ), tabMenu); |
85 | 86 | ||
86 | connectionMenu->insertItem( tr( "New" ), this, SLOT( newConnection() )); | 87 | connectionMenu->insertItem( tr( "New" ), this, SLOT( newConnection() )); |
87 | connectionMenu->insertItem( tr( "Connect" ), this, SLOT( connector() )); | 88 | connectionMenu->insertItem( tr( "Connect" ), this, SLOT( connector() )); |
88 | connectionMenu->insertItem( tr( "Disconnect" ), this, SLOT( disConnector() )); | 89 | connectionMenu->insertItem( tr( "Disconnect" ), this, SLOT( disConnector() )); |
89 | 90 | ||
90 | localMenu->insertItem( tr( "Show Hidden Files" ), this, SLOT( showHidden() )); | 91 | localMenu->insertItem( tr( "Show Hidden Files" ), this, SLOT( showHidden() )); |
91 | localMenu->insertSeparator(); | 92 | localMenu->insertSeparator(); |
92 | localMenu->insertItem( tr( "Upload" ), this, SLOT( localUpload() )); | 93 | localMenu->insertItem( tr( "Upload" ), this, SLOT( localUpload() )); |
93 | localMenu->insertItem( tr( "Make Directory" ), this, SLOT( localMakDir() )); | 94 | localMenu->insertItem( tr( "Make Directory" ), this, SLOT( localMakDir() )); |
94 | localMenu->insertItem( tr( "Rename" ), this, SLOT( localRename() )); | 95 | localMenu->insertItem( tr( "Rename" ), this, SLOT( localRename() )); |
95 | localMenu->insertSeparator(); | 96 | localMenu->insertSeparator(); |
96 | localMenu->insertItem( tr( "Delete" ), this, SLOT( localDelete() )); | 97 | localMenu->insertItem( tr( "Delete" ), this, SLOT( localDelete() )); |
97 | 98 | localMenu->setCheckable(TRUE); | |
99 | |||
98 | remoteMenu->insertItem( tr( "Download" ), this, SLOT( remoteDownload() )); | 100 | remoteMenu->insertItem( tr( "Download" ), this, SLOT( remoteDownload() )); |
99 | remoteMenu->insertItem( tr( "Make Directory" ), this, SLOT( remoteMakDir() )); | 101 | remoteMenu->insertItem( tr( "Make Directory" ), this, SLOT( remoteMakDir() )); |
100 | remoteMenu->insertItem( tr( "Rename" ), this, SLOT( remoteRename() )); | 102 | remoteMenu->insertItem( tr( "Rename" ), this, SLOT( remoteRename() )); |
101 | remoteMenu->insertSeparator(); | 103 | remoteMenu->insertSeparator(); |
102 | remoteMenu->insertItem( tr( "Delete" ), this, SLOT( remoteDelete() )); | 104 | remoteMenu->insertItem( tr( "Delete" ), this, SLOT( remoteDelete() )); |
103 | 105 | ||
104 | tabMenu->insertItem( tr( "Switch to Local" ), this, SLOT( switchToLocalTab() )); | 106 | tabMenu->insertItem( tr( "Switch to Local" ), this, SLOT( switchToLocalTab() )); |
105 | tabMenu->insertItem( tr( "Switch to Remote" ), this, SLOT( switchToRemoteTab() )); | 107 | tabMenu->insertItem( tr( "Switch to Remote" ), this, SLOT( switchToRemoteTab() )); |
106 | tabMenu->insertItem( tr( "Switch to Config" ), this, SLOT( switchToConfigTab() )); | 108 | tabMenu->insertItem( tr( "Switch to Config" ), this, SLOT( switchToConfigTab() )); |
107 | tabMenu->setCheckable(TRUE); | 109 | tabMenu->setCheckable(TRUE); |
108 | 110 | ||
109 | TabWidget = new QTabWidget( this, "TabWidget" ); | 111 | TabWidget = new QTabWidget( this, "TabWidget" ); |
110 | layout->addMultiCellWidget( TabWidget, 1, 1, 0, 3 ); | 112 | layout->addMultiCellWidget( TabWidget, 1, 1, 0, 3 ); |
111 | 113 | ||
112 | TabWidget->setTabShape(QTabWidget::Triangular); | 114 | TabWidget->setTabShape(QTabWidget::Triangular); |
113 | 115 | ||
@@ -188,34 +190,34 @@ OpieFtp::OpieFtp( ) | |||
188 | TextLabel3->setText( tr( "Remote server" ) ); | 190 | TextLabel3->setText( tr( "Remote server" ) ); |
189 | tabLayout_3->addMultiCellWidget( TextLabel3, 2, 2, 0, 1 ); | 191 | tabLayout_3->addMultiCellWidget( TextLabel3, 2, 2, 0, 1 ); |
190 | 192 | ||
191 | ServerComboBox = new QComboBox( FALSE, tab_3, "ServerComboBox" ); | 193 | ServerComboBox = new QComboBox( FALSE, tab_3, "ServerComboBox" ); |
192 | ServerComboBox->setEditable(TRUE); | 194 | ServerComboBox->setEditable(TRUE); |
193 | ServerComboBox->lineEdit()->setText( tr( "" ) ); | 195 | ServerComboBox->lineEdit()->setText( tr( "" ) ); |
194 | tabLayout_3->addMultiCellWidget( ServerComboBox, 3, 3, 0, 1 ); | 196 | tabLayout_3->addMultiCellWidget( ServerComboBox, 3, 3, 0, 1 ); |
195 | // ServerComboBox->lineEdit()->setText( tr( "llornkcor.com" ) ); | 197 | // ServerComboBox->lineEdit()->setText( tr( "llornkcor.com" ) ); |
196 | ServerComboBox->lineEdit()->setText( tr( "192.168.129.201" ) ); | 198 | ServerComboBox->lineEdit()->setText( tr( "192.168.129.201" ) ); |
197 | 199 | ||
198 | QLabel *TextLabel5 = new QLabel( tab_3, "TextLabel5" ); | 200 | QLabel *TextLabel5 = new QLabel( tab_3, "TextLabel5" ); |
199 | TextLabel5->setText( tr( "Remote path" ) ); | 201 | TextLabel5->setText( tr( "Remote path" ) ); |
200 | tabLayout_3->addMultiCellWidget( TextLabel5, 2, 2, 2, 3 ); | 202 | tabLayout_3->addMultiCellWidget( TextLabel5, 2, 2, 2, 3 ); |
201 | 203 | ||
202 | remotePath = new QLineEdit( "/", tab_3, "remotePath" ); | 204 | remotePath = new QLineEdit( "/", tab_3, "remotePath" ); |
203 | remotePath->setText( currentRemoteDir = "/"); | 205 | remotePath->setText( currentRemoteDir = "/"); |
204 | tabLayout_3->addMultiCellWidget( remotePath, 3, 3, 2, 3 ); | ||
205 | // remotePath->setText( currentRemoteDir = "/home/llornkcor/"); | 206 | // remotePath->setText( currentRemoteDir = "/home/llornkcor/"); |
207 | tabLayout_3->addMultiCellWidget( remotePath, 3, 3, 2, 3 ); | ||
206 | 208 | ||
207 | TextLabel4 = new QLabel( tab_3, "TextLabel4" ); | 209 | TextLabel4 = new QLabel( tab_3, "TextLabel4" ); |
208 | TextLabel4->setText( tr( "Port" ) ); | 210 | TextLabel4->setText( tr( "Port" ) ); |
209 | tabLayout_3->addMultiCellWidget( TextLabel4, 4, 4, 0, 1 ); | 211 | tabLayout_3->addMultiCellWidget( TextLabel4, 4, 4, 0, 1 ); |
210 | 212 | ||
211 | PortSpinBox = new QSpinBox( tab_3, "PortSpinBox" ); | 213 | PortSpinBox = new QSpinBox( tab_3, "PortSpinBox" ); |
212 | PortSpinBox->setButtonSymbols( QSpinBox::UpDownArrows ); | 214 | PortSpinBox->setButtonSymbols( QSpinBox::UpDownArrows ); |
213 | PortSpinBox->setMaxValue(32786); | 215 | PortSpinBox->setMaxValue(32786); |
214 | PortSpinBox->setValue( 4242); | 216 | PortSpinBox->setValue( 4242); |
215 | // PortSpinBox->setValue( 21); | 217 | // PortSpinBox->setValue( 21); |
216 | tabLayout_3->addMultiCellWidget( PortSpinBox, 4, 4, 1, 1); | 218 | tabLayout_3->addMultiCellWidget( PortSpinBox, 4, 4, 1, 1); |
217 | 219 | ||
218 | QSpacerItem* spacer = new QSpacerItem( 20, 20, QSizePolicy::Minimum, QSizePolicy::Expanding ); | 220 | QSpacerItem* spacer = new QSpacerItem( 20, 20, QSizePolicy::Minimum, QSizePolicy::Expanding ); |
219 | tabLayout_3->addItem( spacer, 5, 0 ); | 221 | tabLayout_3->addItem( spacer, 5, 0 ); |
220 | 222 | ||
221 | TabWidget->insertTab( tab_3, tr( "Config" ) ); | 223 | TabWidget->insertTab( tab_3, tr( "Config" ) ); |
@@ -223,32 +225,33 @@ OpieFtp::OpieFtp( ) | |||
223 | connect(TabWidget,SIGNAL(currentChanged(QWidget *)), | 225 | connect(TabWidget,SIGNAL(currentChanged(QWidget *)), |
224 | this,SLOT(tabChanged(QWidget*))); | 226 | this,SLOT(tabChanged(QWidget*))); |
225 | 227 | ||
226 | currentDir.setFilter( QDir::Files | QDir::Dirs/* | QDir::Hidden*/ | QDir::All); | 228 | currentDir.setFilter( QDir::Files | QDir::Dirs/* | QDir::Hidden*/ | QDir::All); |
227 | currentDir.setPath( QDir::currentDirPath()); | 229 | currentDir.setPath( QDir::currentDirPath()); |
228 | // currentDir.setSorting(/* QDir::Size*/ /*| QDir::Reversed | */QDir::DirsFirst); | 230 | // currentDir.setSorting(/* QDir::Size*/ /*| QDir::Reversed | */QDir::DirsFirst); |
229 | currentPathEdit = new QLineEdit( "/", this, "currentPathEdit" ); | 231 | currentPathEdit = new QLineEdit( "/", this, "currentPathEdit" ); |
230 | layout->addMultiCellWidget( currentPathEdit, 3, 3, 0, 3 ); | 232 | layout->addMultiCellWidget( currentPathEdit, 3, 3, 0, 3 ); |
231 | 233 | ||
232 | currentPathEdit->setText( currentDir.canonicalPath()); | 234 | currentPathEdit->setText( currentDir.canonicalPath()); |
233 | connect( currentPathEdit,SIGNAL(returnPressed()),this,SLOT(currentPathEditChanged())); | 235 | connect( currentPathEdit,SIGNAL(returnPressed()),this,SLOT(currentPathEditChanged())); |
234 | 236 | ||
235 | ProgressBar = new QProgressBar( this, "ProgressBar" ); | 237 | ProgressBar = new QProgressBar( this, "ProgressBar" ); |
236 | layout->addMultiCellWidget( ProgressBar, 4, 4, 0, 3 ); | 238 | layout->addMultiCellWidget( ProgressBar, 4, 4, 0, 3 ); |
237 | 239 | ||
238 | filterStr="*"; | 240 | filterStr="*"; |
241 | b=FALSE; | ||
239 | populateLocalView(); | 242 | populateLocalView(); |
240 | } | 243 | } |
241 | 244 | ||
242 | OpieFtp::~OpieFtp() | 245 | OpieFtp::~OpieFtp() |
243 | { | 246 | { |
244 | } | 247 | } |
245 | 248 | ||
246 | void OpieFtp::cleanUp() | 249 | void OpieFtp::cleanUp() |
247 | { | 250 | { |
248 | if(conn) | 251 | if(conn) |
249 | FtpQuit(conn); | 252 | FtpQuit(conn); |
250 | QString sfile=QDir::homeDirPath(); | 253 | QString sfile=QDir::homeDirPath(); |
251 | if(sfile.right(1) != "/") | 254 | if(sfile.right(1) != "/") |
252 | sfile+="/._temp"; | 255 | sfile+="/._temp"; |
253 | else | 256 | else |
254 | sfile+="._temp"; | 257 | sfile+="._temp"; |
@@ -316,33 +319,36 @@ void OpieFtp::localUpload() | |||
316 | 319 | ||
317 | void OpieFtp::nullifyCallBack() | 320 | void OpieFtp::nullifyCallBack() |
318 | { | 321 | { |
319 | FtpOptions(FTPLIB_CALLBACK, NULL, conn); | 322 | FtpOptions(FTPLIB_CALLBACK, NULL, conn); |
320 | FtpOptions(FTPLIB_IDLETIME, NULL, conn); | 323 | FtpOptions(FTPLIB_IDLETIME, NULL, conn); |
321 | FtpOptions(FTPLIB_CALLBACKARG, NULL, conn); | 324 | FtpOptions(FTPLIB_CALLBACKARG, NULL, conn); |
322 | FtpOptions(FTPLIB_CALLBACKBYTES, NULL, conn); | 325 | FtpOptions(FTPLIB_CALLBACKBYTES, NULL, conn); |
323 | 326 | ||
324 | } | 327 | } |
325 | 328 | ||
326 | void OpieFtp::remoteDownload() | 329 | void OpieFtp::remoteDownload() |
327 | { | 330 | { |
328 | int fsz; | 331 | int fsz; |
329 | QCopEnvelope ( "QPE/System", "busy()" ); | 332 | QCopEnvelope ( "QPE/System", "busy()" ); |
330 | qApp->processEvents(); | 333 | qApp->processEvents(); |
331 | QString strItem = Remote_View->currentItem()->text(0); | 334 | QString strItem = Remote_View->currentItem()->text(0); |
332 | QString localFile = currentDir.canonicalPath()+"/"+strItem; | 335 | // strItem=strItem.right(strItem.length()-1); |
336 | |||
337 | QString localFile = currentDir.canonicalPath()+strItem; | ||
338 | // QString localFile = currentDir.canonicalPath()+"/"+strItem; | ||
333 | QString remoteFile= currentRemoteDir+strItem; | 339 | QString remoteFile= currentRemoteDir+strItem; |
334 | if (!FtpSize( remoteFile.latin1(), &fsz, FTPLIB_ASCII, conn)) | 340 | if (!FtpSize( remoteFile.latin1(), &fsz, FTPLIB_ASCII, conn)) |
335 | fsz = 0; | 341 | fsz = 0; |
336 | QString temp; | 342 | QString temp; |
337 | temp.sprintf( remoteFile+" "+" %dkb", fsz); | 343 | temp.sprintf( remoteFile+" "+" %dkb", fsz); |
338 | 344 | ||
339 | ProgressBar->setTotalSteps(fsz); | 345 | ProgressBar->setTotalSteps(fsz); |
340 | FtpOptions(FTPLIB_CALLBACK, (long) log_progress, conn); | 346 | FtpOptions(FTPLIB_CALLBACK, (long) log_progress, conn); |
341 | FtpOptions(FTPLIB_IDLETIME, (long) 1000, conn); | 347 | FtpOptions(FTPLIB_IDLETIME, (long) 1000, conn); |
342 | FtpOptions(FTPLIB_CALLBACKARG, (long) &fsz, conn); | 348 | FtpOptions(FTPLIB_CALLBACKARG, (long) &fsz, conn); |
343 | FtpOptions(FTPLIB_CALLBACKBYTES, (long) fsz/10, conn); | 349 | FtpOptions(FTPLIB_CALLBACKBYTES, (long) fsz/10, conn); |
344 | qDebug("Get: %s, %s",localFile.latin1(),remoteFile.latin1()); | 350 | qDebug("Get: %s, %s",localFile.latin1(),remoteFile.latin1()); |
345 | 351 | ||
346 | if(!FtpGet( localFile.latin1(), remoteFile.latin1(),FTPLIB_IMAGE, conn ) ) { | 352 | if(!FtpGet( localFile.latin1(), remoteFile.latin1(),FTPLIB_IMAGE, conn ) ) { |
347 | QString msg; | 353 | QString msg; |
348 | msg.sprintf("Unable to download \n%s",FtpLastResponse(conn)); | 354 | msg.sprintf("Unable to download \n%s",FtpLastResponse(conn)); |
@@ -443,93 +449,118 @@ bool OpieFtp::remoteChDir(const QString &dir) | |||
443 | qDebug(msg); | 449 | qDebug(msg); |
444 | // FtpQuit(conn); | 450 | // FtpQuit(conn); |
445 | QCopEnvelope ( "QPE/System", "notBusy()" ); | 451 | QCopEnvelope ( "QPE/System", "notBusy()" ); |
446 | return FALSE; | 452 | return FALSE; |
447 | } | 453 | } |
448 | QCopEnvelope ( "QPE/System", "notBusy()" ); | 454 | QCopEnvelope ( "QPE/System", "notBusy()" ); |
449 | return TRUE; | 455 | return TRUE; |
450 | } | 456 | } |
451 | 457 | ||
452 | void OpieFtp::populateLocalView() | 458 | void OpieFtp::populateLocalView() |
453 | { | 459 | { |
454 | Local_View->clear(); | 460 | Local_View->clear(); |
455 | currentDir.setSorting(/* QDir::Size*/ /*| QDir::Reversed | */QDir::DirsFirst); | 461 | currentDir.setSorting(/* QDir::Size*/ /*| QDir::Reversed | */QDir::DirsFirst); |
456 | currentDir.setMatchAllDirs(TRUE); | 462 | currentDir.setMatchAllDirs(TRUE); |
457 | currentDir.setNameFilter(filterStr); | 463 | currentDir.setNameFilter(filterStr); |
458 | QString fileL, fileS, fileDate; | 464 | QString fileL, fileS, fileDate; |
465 | bool isDir=FALSE; | ||
459 | const QFileInfoList *list = currentDir.entryInfoList( /*QDir::All*/ /*, QDir::SortByMask*/); | 466 | const QFileInfoList *list = currentDir.entryInfoList( /*QDir::All*/ /*, QDir::SortByMask*/); |
460 | QFileInfoListIterator it(*list); | 467 | QFileInfoListIterator it(*list); |
461 | QFileInfo *fi; | 468 | QFileInfo *fi; |
462 | while ( (fi=it.current()) ) { | 469 | while ( (fi=it.current()) ) { |
463 | if (fi->isSymLink() ){ | 470 | if (fi->isSymLink() ){ |
464 | QString symLink=fi->readLink(); | 471 | QString symLink=fi->readLink(); |
465 | // qDebug("Symlink detected "+symLink); | 472 | // qDebug("Symlink detected "+symLink); |
466 | QFileInfo sym( symLink); | 473 | QFileInfo sym( symLink); |
467 | fileS.sprintf( "%10li", sym.size() ); | 474 | fileS.sprintf( "%10li", sym.size() ); |
468 | fileL.sprintf( "%s -> %s", sym.fileName().data(),sym.absFilePath().data() ); | 475 | fileL.sprintf( "%s -> %s", sym.fileName().data(),sym.absFilePath().data() ); |
469 | fileDate = sym.lastModified().toString(); | 476 | fileDate = sym.lastModified().toString(); |
470 | } else { | 477 | } else { |
471 | // qDebug("Not a dir: "+currentDir.canonicalPath()+fileL); | 478 | // qDebug("Not a dir: "+currentDir.canonicalPath()+fileL); |
472 | fileS.sprintf( "%10li", fi->size() ); | 479 | fileS.sprintf( "%10li", fi->size() ); |
473 | fileL.sprintf( "%s",fi->fileName().data() ); | 480 | fileL.sprintf( "%s",fi->fileName().data() ); |
474 | fileDate= fi->lastModified().toString(); | 481 | fileDate= fi->lastModified().toString(); |
475 | if( QDir(QDir::cleanDirPath(currentDir.canonicalPath()+"/"+fileL)).exists() ) { | 482 | if( QDir(QDir::cleanDirPath(currentDir.canonicalPath()+"/"+fileL)).exists() ) { |
476 | fileL+="/"; | 483 | fileL+="/"; |
484 | isDir=TRUE; | ||
477 | // qDebug( fileL); | 485 | // qDebug( fileL); |
478 | } | 486 | } |
479 | } | 487 | } |
480 | item= new QListViewItem( Local_View,fileL,fileS, fileDate); | 488 | if(fileL !="./") { |
489 | item = new QListViewItem( Local_View,fileL,fileS, fileDate); | ||
490 | if(isDir) | ||
491 | item->setPixmap( 0, Resource::loadPixmap( "folder" )); | ||
492 | else | ||
493 | item->setPixmap( 0, Resource::loadPixmap( "fileopen" )); | ||
494 | } | ||
495 | isDir=FALSE; | ||
481 | ++it; | 496 | ++it; |
482 | } | 497 | } |
483 | Local_View->setSorting( 3,FALSE); | 498 | Local_View->setSorting( 3,FALSE); |
484 | currentPathEdit->setText( currentDir.canonicalPath() ); | 499 | currentPathEdit->setText( currentDir.canonicalPath() ); |
485 | } | 500 | } |
486 | 501 | ||
487 | bool OpieFtp::populateRemoteView( ) | 502 | bool OpieFtp::populateRemoteView( ) |
488 | { | 503 | { |
489 | // qDebug("populate remoteview"); | 504 | // qDebug("populate remoteview"); |
490 | QString sfile=QDir::homeDirPath(); | 505 | QString sfile=QDir::homeDirPath(); |
491 | if(sfile.right(1) != "/") | 506 | if(sfile.right(1) != "/") |
492 | sfile+="/._temp"; | 507 | sfile+="/._temp"; |
493 | else | 508 | else |
494 | sfile+="._temp"; | 509 | sfile+="._temp"; |
495 | QFile file( sfile); | 510 | QFile file( sfile); |
496 | Remote_View->clear(); | 511 | Remote_View->clear(); |
497 | QString s, File_Name; | 512 | QString s, File_Name; |
513 | QListViewItem *itemDir=NULL, *itemFile=NULL; | ||
498 | QString fileL, fileS, fileDate; | 514 | QString fileL, fileS, fileDate; |
499 | new QListViewItem( Remote_View, "../"); | ||
500 | if ( file.open(IO_ReadOnly)) { | 515 | if ( file.open(IO_ReadOnly)) { |
501 | QTextStream t( &file ); // use a text stream | 516 | QTextStream t( &file ); // use a text stream |
502 | while ( !t.eof()) { | 517 | while ( !t.eof()) { |
503 | s = t.readLine(); | 518 | s = t.readLine(); |
504 | fileL = s.right(s.length()-55); | 519 | fileL = s.right(s.length()-55); |
505 | fileL = fileL.stripWhiteSpace(); | 520 | fileL = fileL.stripWhiteSpace(); |
506 | if(s.left(1) == "d") | 521 | if(s.left(1) == "d") |
507 | fileL = fileL+"/"; | 522 | fileL = fileL+"/"; |
523 | // fileL = "/"+fileL+"/"; | ||
508 | fileS = s.mid( 30, 42-30); | 524 | fileS = s.mid( 30, 42-30); |
509 | fileS = fileS.stripWhiteSpace(); | 525 | fileS = fileS.stripWhiteSpace(); |
510 | fileDate = s.mid( 42, 55-42); | 526 | fileDate = s.mid( 42, 55-42); |
511 | fileDate = fileDate.stripWhiteSpace(); | 527 | fileDate = fileDate.stripWhiteSpace(); |
512 | if(fileL.find("total",0,TRUE) == -1) | 528 | if(fileL.find("total",0,TRUE) == -1) { |
513 | new QListViewItem( Remote_View, fileL, fileS, fileDate); | 529 | QListViewItem * item = new QListViewItem( Remote_View, fileL, fileS, fileDate); |
530 | if(s.left(1) == "d") { | ||
531 | item->setPixmap( 0, Resource::loadPixmap( "folder" )); | ||
532 | if(itemDir) | ||
533 | item->moveItem(itemDir); | ||
534 | itemDir=item; | ||
535 | } else { | ||
536 | item->setPixmap( 0, Resource::loadPixmap( "fileopen" )); | ||
537 | if(itemFile) | ||
538 | item->moveItem(itemFile); | ||
539 | itemFile=item; | ||
540 | } | ||
541 | } | ||
514 | } | 542 | } |
543 | QListViewItem * item1 = new QListViewItem( Remote_View, "../"); | ||
544 | item1->setPixmap( 0, Resource::loadPixmap( "folder" )); | ||
515 | file.close(); | 545 | file.close(); |
516 | if( file.exists()) | 546 | if( file.exists()) |
517 | file. remove(); | 547 | file. remove(); |
518 | } else | 548 | } else |
519 | qDebug("temp file not opened successfullly "+sfile); | 549 | qDebug("temp file not opened successfullly "+sfile); |
550 | Remote_View->setSorting( 4,TRUE); | ||
520 | 551 | ||
521 | return true; | 552 | return true; |
522 | } | 553 | } |
523 | 554 | ||
524 | void OpieFtp::remoteListClicked(QListViewItem *selectedItem) | 555 | void OpieFtp::remoteListClicked(QListViewItem *selectedItem) |
525 | { | 556 | { |
526 | QCopEnvelope ( "QPE/System", "busy()" ); | 557 | QCopEnvelope ( "QPE/System", "busy()" ); |
527 | QString oldRemoteCurrentDir = currentRemoteDir; | 558 | QString oldRemoteCurrentDir = currentRemoteDir; |
528 | QString strItem=selectedItem->text(0); | 559 | QString strItem=selectedItem->text(0); |
529 | strItem=strItem.simplifyWhiteSpace(); | 560 | strItem=strItem.simplifyWhiteSpace(); |
530 | if(strItem == "../") { // the user wants to go ^ | 561 | if(strItem == "../") { // the user wants to go ^ |
531 | if( FtpCDUp( conn) == 0) { | 562 | if( FtpCDUp( conn) == 0) { |
532 | QString msg; | 563 | QString msg; |
533 | msg.sprintf("Unable to cd up\n%s",FtpLastResponse(conn)); | 564 | msg.sprintf("Unable to cd up\n%s",FtpLastResponse(conn)); |
534 | msg.replace(QRegExp(":"),"\n"); | 565 | msg.replace(QRegExp(":"),"\n"); |
535 | QMessageBox::message("Note",msg); | 566 | QMessageBox::message("Note",msg); |
@@ -613,37 +644,39 @@ void OpieFtp::localListClicked(QListViewItem *selectedItem) | |||
613 | 644 | ||
614 | void OpieFtp::doLocalCd() | 645 | void OpieFtp::doLocalCd() |
615 | { | 646 | { |
616 | localListClicked( Local_View->currentItem()); | 647 | localListClicked( Local_View->currentItem()); |
617 | } | 648 | } |
618 | 649 | ||
619 | void OpieFtp:: doRemoteCd() | 650 | void OpieFtp:: doRemoteCd() |
620 | { | 651 | { |
621 | remoteListClicked( Remote_View->currentItem()); | 652 | remoteListClicked( Remote_View->currentItem()); |
622 | 653 | ||
623 | } | 654 | } |
624 | 655 | ||
625 | void OpieFtp::showHidden() | 656 | void OpieFtp::showHidden() |
626 | { | 657 | { |
627 | if (!b) { | 658 | if (!b) { |
628 | currentDir.setFilter( QDir::Files | QDir::Dirs | QDir::Hidden | QDir::All); | 659 | currentDir.setFilter( QDir::Files | QDir::Dirs | QDir::Hidden | QDir::All); |
660 | localMenu->setItemChecked(localMenu->idAt(0),TRUE); | ||
629 | // currentDir.setSorting(/* QDir::Size*/ /*| QDir::Reversed | */QDir::DirsFirst); | 661 | // currentDir.setSorting(/* QDir::Size*/ /*| QDir::Reversed | */QDir::DirsFirst); |
630 | b=TRUE; | 662 | b=TRUE; |
631 | 663 | ||
632 | } else { | 664 | } else { |
633 | currentDir.setFilter( QDir::Files | QDir::Dirs/* | QDir::Hidden*/ | QDir::All); | 665 | currentDir.setFilter( QDir::Files | QDir::Dirs/* | QDir::Hidden*/ | QDir::All); |
666 | localMenu->setItemChecked(localMenu->idAt(0),FALSE); | ||
634 | // currentDir.setSorting(/* QDir::Size*/ /*| QDir::Reversed | */QDir::DirsFirst); | 667 | // currentDir.setSorting(/* QDir::Size*/ /*| QDir::Reversed | */QDir::DirsFirst); |
635 | b=FALSE; | 668 | b=FALSE; |
636 | } | 669 | } |
637 | populateLocalView(); | 670 | populateLocalView(); |
638 | } | 671 | } |
639 | 672 | ||
640 | void OpieFtp::ListPressed( int mouse, QListViewItem *item, const QPoint &point, int i) | 673 | void OpieFtp::ListPressed( int mouse, QListViewItem *item, const QPoint &point, int i) |
641 | { | 674 | { |
642 | switch (mouse) { | 675 | switch (mouse) { |
643 | case 1: | 676 | case 1: |
644 | break; | 677 | break; |
645 | case 2: | 678 | case 2: |
646 | showLocalMenu(item); | 679 | showLocalMenu(item); |
647 | break; | 680 | break; |
648 | }; | 681 | }; |
649 | } | 682 | } |
@@ -673,32 +706,38 @@ void OpieFtp::showRemoteMenu(QListViewItem * item) | |||
673 | m.exec( QCursor::pos() ); | 706 | m.exec( QCursor::pos() ); |
674 | } | 707 | } |
675 | 708 | ||
676 | void OpieFtp::showLocalMenu(QListViewItem * item) | 709 | void OpieFtp::showLocalMenu(QListViewItem * item) |
677 | { | 710 | { |
678 | QPopupMenu m; | 711 | QPopupMenu m; |
679 | m.insertItem( tr( "Show Hidden Files" ), this, SLOT( showHidden() )); | 712 | m.insertItem( tr( "Show Hidden Files" ), this, SLOT( showHidden() )); |
680 | m.insertSeparator(); | 713 | m.insertSeparator(); |
681 | if(item->text(0).right(1) == "/") | 714 | if(item->text(0).right(1) == "/") |
682 | m.insertItem( tr( "Change Directory" ), this, SLOT( doLocalCd() )); | 715 | m.insertItem( tr( "Change Directory" ), this, SLOT( doLocalCd() )); |
683 | else | 716 | else |
684 | m.insertItem( tr( "Upload" ), this, SLOT( localUpload() )); | 717 | m.insertItem( tr( "Upload" ), this, SLOT( localUpload() )); |
685 | m.insertItem( tr( "Make Directory" ), this, SLOT( localMakDir() )); | 718 | m.insertItem( tr( "Make Directory" ), this, SLOT( localMakDir() )); |
686 | m.insertItem( tr( "Rename" ), this, SLOT( localRename() )); | 719 | m.insertItem( tr( "Rename" ), this, SLOT( localRename() )); |
687 | m.insertSeparator(); | 720 | m.insertSeparator(); |
688 | m.insertItem( tr( "Delete" ), this, SLOT( localDelete() )); | 721 | m.insertItem( tr( "Delete" ), this, SLOT( localDelete() )); |
722 | m.setCheckable(TRUE); | ||
723 | if (b) | ||
724 | m.setItemChecked(m.idAt(0),TRUE); | ||
725 | else | ||
726 | m.setItemChecked(m.idAt(0),FALSE); | ||
727 | |||
689 | m.exec( QCursor::pos() ); | 728 | m.exec( QCursor::pos() ); |
690 | } | 729 | } |
691 | 730 | ||
692 | void OpieFtp::localMakDir() | 731 | void OpieFtp::localMakDir() |
693 | { | 732 | { |
694 | InputDialog *fileDlg; | 733 | InputDialog *fileDlg; |
695 | fileDlg = new InputDialog(this,"Make Directory",TRUE, 0); | 734 | fileDlg = new InputDialog(this,"Make Directory",TRUE, 0); |
696 | fileDlg->exec(); | 735 | fileDlg->exec(); |
697 | if( fileDlg->result() == 1 ) { | 736 | if( fileDlg->result() == 1 ) { |
698 | QString filename = fileDlg->LineEdit1->text(); | 737 | QString filename = fileDlg->LineEdit1->text(); |
699 | currentDir.mkdir( currentDir.canonicalPath()+"/"+filename); | 738 | currentDir.mkdir( currentDir.canonicalPath()+"/"+filename); |
700 | } | 739 | } |
701 | populateLocalView(); | 740 | populateLocalView(); |
702 | } | 741 | } |
703 | 742 | ||
704 | void OpieFtp::localDelete() | 743 | void OpieFtp::localDelete() |
@@ -824,33 +863,33 @@ void OpieFtp::localRename() | |||
824 | InputDialog *fileDlg; | 863 | InputDialog *fileDlg; |
825 | fileDlg = new InputDialog(this,"Rename",TRUE, 0); | 864 | fileDlg = new InputDialog(this,"Rename",TRUE, 0); |
826 | fileDlg->inputText = curFile; | 865 | fileDlg->inputText = curFile; |
827 | fileDlg->exec(); | 866 | fileDlg->exec(); |
828 | if( fileDlg->result() == 1 ) { | 867 | if( fileDlg->result() == 1 ) { |
829 | QString oldname = currentDir.canonicalPath() + "/" + curFile; | 868 | QString oldname = currentDir.canonicalPath() + "/" + curFile; |
830 | QString newName = currentDir.canonicalPath() + "/" + fileDlg->LineEdit1->text();//+".playlist"; | 869 | QString newName = currentDir.canonicalPath() + "/" + fileDlg->LineEdit1->text();//+".playlist"; |
831 | if( rename(oldname.latin1(), newName.latin1())== -1) | 870 | if( rename(oldname.latin1(), newName.latin1())== -1) |
832 | QMessageBox::message("Note","Could not rename"); | 871 | QMessageBox::message("Note","Could not rename"); |
833 | } | 872 | } |
834 | populateLocalView(); | 873 | populateLocalView(); |
835 | } | 874 | } |
836 | 875 | ||
837 | void OpieFtp::currentPathEditChanged() | 876 | void OpieFtp::currentPathEditChanged() |
838 | { | 877 | { |
839 | QString oldRemoteCurrentDir = currentRemoteDir; | 878 | QString oldRemoteCurrentDir = currentRemoteDir; |
840 | qDebug("oldRemoteCurrentDir "+oldRemoteCurrentDir); | 879 | // qDebug("oldRemoteCurrentDir "+oldRemoteCurrentDir); |
841 | if (TabWidget->currentPageIndex() == 0) { | 880 | if (TabWidget->currentPageIndex() == 0) { |
842 | if(QDir( currentPathEdit->text()).exists()) { | 881 | if(QDir( currentPathEdit->text()).exists()) { |
843 | currentDir.setPath( currentPathEdit->text() ); | 882 | currentDir.setPath( currentPathEdit->text() ); |
844 | populateLocalView(); | 883 | populateLocalView(); |
845 | } else { | 884 | } else { |
846 | QMessageBox::message("Note","That directory does not exist"); | 885 | QMessageBox::message("Note","That directory does not exist"); |
847 | } | 886 | } |
848 | } | 887 | } |
849 | if (TabWidget->currentPageIndex() == 1) { | 888 | if (TabWidget->currentPageIndex() == 1) { |
850 | currentRemoteDir = currentPathEdit->text(); | 889 | currentRemoteDir = currentPathEdit->text(); |
851 | if(currentRemoteDir.right(1) !="/") { | 890 | if(currentRemoteDir.right(1) !="/") { |
852 | currentRemoteDir = currentRemoteDir +"/"; | 891 | currentRemoteDir = currentRemoteDir +"/"; |
853 | currentPathEdit->setText( currentRemoteDir ); | 892 | currentPathEdit->setText( currentRemoteDir ); |
854 | } | 893 | } |
855 | if( !remoteChDir( (const QString &)currentRemoteDir) ) { | 894 | if( !remoteChDir( (const QString &)currentRemoteDir) ) { |
856 | currentRemoteDir = oldRemoteCurrentDir; | 895 | currentRemoteDir = oldRemoteCurrentDir; |