summaryrefslogtreecommitdiff
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/net/opieftp/opieftp.cpp10
-rw-r--r--noncore/net/opieftp/opieftp.h2
2 files changed, 9 insertions, 3 deletions
diff --git a/noncore/net/opieftp/opieftp.cpp b/noncore/net/opieftp/opieftp.cpp
index 7c83223..db365ca 100644
--- a/noncore/net/opieftp/opieftp.cpp
+++ b/noncore/net/opieftp/opieftp.cpp
@@ -1,184 +1,189 @@
1/*************************************************************************** 1/***************************************************************************
2 opieftp.cpp 2 opieftp.cpp
3 ------------------- 3 -------------------
4** Created: Sat Mar 9 23:33:09 2002 4** Created: Sat Mar 9 23:33:09 2002
5 copyright : (C) 2002 by ljp 5 copyright : (C) 2002 by ljp
6 email : ljp@llornkcor.com 6 email : ljp@llornkcor.com
7 * This program is free software; you can redistribute it and/or modify * 7 * This program is free software; you can redistribute it and/or modify *
8 * it under the terms of the GNU General Public License as published by * 8 * it under the terms of the GNU General Public License as published by *
9 * the Free Software Foundation; either version 2 of the License, or * 9 * the Free Software Foundation; either version 2 of the License, or *
10 * (at your option) any later version. * 10 * (at your option) any later version. *
11 ***************************************************************************/ 11 ***************************************************************************/
12//#define DEVELOPERS_VERSION 12//#define DEVELOPERS_VERSION
13 13
14#include "opieftp.h" 14#include "opieftp.h"
15 15
16extern "C" { 16extern "C" {
17#include "../ftplib/ftplib.h" 17#include "../ftplib/ftplib.h"
18} 18}
19 19
20#include "inputDialog.h" 20#include "inputDialog.h"
21 21
22#include <qpe/qpemenubar.h> 22#include <qpe/qpemenubar.h>
23#include <qpe/qpetoolbar.h> 23#include <qpe/qpetoolbar.h>
24#include <qpe/qpeapplication.h> 24#include <qpe/qpeapplication.h>
25#include <qpe/resource.h> 25#include <qpe/resource.h>
26#include <qpe/qcopenvelope_qws.h> 26#include <qpe/qcopenvelope_qws.h>
27#include <qpe/config.h> 27#include <qpe/config.h>
28#include <qpe/mimetype.h> 28#include <qpe/mimetype.h>
29#include <qpe/qpemessagebox.h> 29#include <qpe/qpemessagebox.h>
30 30
31#include <qstringlist.h> 31#include <qstringlist.h>
32#include <qtextstream.h> 32#include <qtextstream.h>
33#include <qpushbutton.h> 33#include <qpushbutton.h>
34#include <qtoolbutton.h> 34#include <qtoolbutton.h>
35#include <qdatetime.h> 35#include <qdatetime.h>
36#include <qdir.h> 36#include <qdir.h>
37#include <qfile.h> 37#include <qfile.h>
38#include <qstring.h> 38#include <qstring.h>
39#include <qcombobox.h> 39#include <qcombobox.h>
40#include <qpopupmenu.h> 40#include <qpopupmenu.h>
41#include <qlistview.h> 41#include <qlistview.h>
42#include <qmainwindow.h> 42#include <qmainwindow.h>
43#include <qlabel.h> 43#include <qlabel.h>
44#include <qprogressbar.h> 44#include <qprogressbar.h>
45#include <qspinbox.h> 45#include <qspinbox.h>
46#include <qtabwidget.h> 46#include <qtabwidget.h>
47#include <qwidget.h> 47#include <qwidget.h>
48#include <qlayout.h> 48#include <qlayout.h>
49#include <qimage.h> 49#include <qimage.h>
50#include <qpixmap.h> 50#include <qpixmap.h>
51#include <qmessagebox.h> 51#include <qmessagebox.h>
52#include <qlineedit.h> 52#include <qlineedit.h>
53#include <qregexp.h> 53#include <qregexp.h>
54#include <qlistbox.h> 54#include <qlistbox.h>
55 55
56#include <unistd.h> 56#include <unistd.h>
57#include <stdlib.h> 57#include <stdlib.h>
58 58
59 59
60QProgressBar *ProgressBar; 60QProgressBar *ProgressBar;
61static netbuf *conn=NULL; 61static netbuf *conn=NULL;
62 62
63static int log_progress(netbuf *, int xfered, void *) 63static int log_progress(netbuf *, int xfered, void *)
64{ 64{
65// int fsz = *(int *)arg; 65// int fsz = *(int *)arg;
66// int pct = (xfered * 100) / fsz; 66// int pct = (xfered * 100) / fsz;
67// printf("%3d%%\r", pct); 67// printf("%3d%%\r", pct);
68// fflush(stdout); 68// fflush(stdout);
69 ProgressBar->setProgress(xfered); 69 ProgressBar->setProgress(xfered);
70 qApp->processEvents(); 70 qApp->processEvents();
71 return 1; 71 return 1;
72} 72}
73 73
74OpieFtp::OpieFtp( ) 74OpieFtp::OpieFtp( )
75 : QMainWindow( ) 75 : QMainWindow( )
76{ 76{
77 setCaption( tr( "OpieFtp" ) ); 77 setCaption( tr( "OpieFtp" ) );
78 fuckeduphack=FALSE; 78 fuckeduphack=FALSE;
79 QGridLayout *layout = new QGridLayout( this ); 79 QGridLayout *layout = new QGridLayout( this );
80 layout->setSpacing( 2); 80 layout->setSpacing( 2);
81 layout->setMargin( 2); 81 layout->setMargin( 2);
82 82
83 connect( qApp,SIGNAL( aboutToQuit()),SLOT( cleanUp()) ); 83 connect( qApp,SIGNAL( aboutToQuit()),SLOT( cleanUp()) );
84 84
85 QPEMenuBar *menuBar = new QPEMenuBar(this); 85 QPEMenuBar *menuBar = new QPEMenuBar(this);
86// QPEToolBar *menuBar = new QPEToolBar(this); 86// QPEToolBar *menuBar = new QPEToolBar(this);
87// menuBar->setHorizontalStretchable( TRUE ); 87// menuBar->setHorizontalStretchable( TRUE );
88 88
89 QWMatrix matrix;
90 QPixmap pix(Resource::loadPixmap( "UnknownDocument" ));
91 matrix.scale( .4, .4);
92 unknownXpm = pix.xForm(matrix);
93
89 connectionMenu = new QPopupMenu( this ); 94 connectionMenu = new QPopupMenu( this );
90 localMenu = new QPopupMenu( this ); 95 localMenu = new QPopupMenu( this );
91 remoteMenu = new QPopupMenu( this ); 96 remoteMenu = new QPopupMenu( this );
92 tabMenu = new QPopupMenu( this ); 97 tabMenu = new QPopupMenu( this );
93 98
94 layout->addMultiCellWidget( menuBar, 0, 0, 0, 2 ); 99 layout->addMultiCellWidget( menuBar, 0, 0, 0, 2 );
95 100
96 menuBar->insertItem( tr( "Connection" ), connectionMenu); 101 menuBar->insertItem( tr( "Connection" ), connectionMenu);
97 menuBar->insertItem( tr( "Local" ), localMenu); 102 menuBar->insertItem( tr( "Local" ), localMenu);
98 menuBar->insertItem( tr( "Remote" ), remoteMenu); 103 menuBar->insertItem( tr( "Remote" ), remoteMenu);
99 menuBar->insertItem( tr( "View" ), tabMenu); 104 menuBar->insertItem( tr( "View" ), tabMenu);
100 105
101 connectionMenu->insertItem( tr( "New" ), this, SLOT( newConnection() )); 106 connectionMenu->insertItem( tr( "New" ), this, SLOT( newConnection() ));
102 connectionMenu->insertItem( tr( "Connect" ), this, SLOT( connector() )); 107 connectionMenu->insertItem( tr( "Connect" ), this, SLOT( connector() ));
103 connectionMenu->insertItem( tr( "Disconnect" ), this, SLOT( disConnector() )); 108 connectionMenu->insertItem( tr( "Disconnect" ), this, SLOT( disConnector() ));
104 109
105 localMenu->insertItem( tr( "Show Hidden Files" ), this, SLOT( showHidden() )); 110 localMenu->insertItem( tr( "Show Hidden Files" ), this, SLOT( showHidden() ));
106 localMenu->insertSeparator(); 111 localMenu->insertSeparator();
107 localMenu->insertItem( tr( "Upload" ), this, SLOT( localUpload() )); 112 localMenu->insertItem( tr( "Upload" ), this, SLOT( localUpload() ));
108 localMenu->insertItem( tr( "Make Directory" ), this, SLOT( localMakDir() )); 113 localMenu->insertItem( tr( "Make Directory" ), this, SLOT( localMakDir() ));
109 localMenu->insertItem( tr( "Rename" ), this, SLOT( localRename() )); 114 localMenu->insertItem( tr( "Rename" ), this, SLOT( localRename() ));
110 localMenu->insertSeparator(); 115 localMenu->insertSeparator();
111 localMenu->insertItem( tr( "Delete" ), this, SLOT( localDelete() )); 116 localMenu->insertItem( tr( "Delete" ), this, SLOT( localDelete() ));
112 localMenu->setCheckable(TRUE); 117 localMenu->setCheckable(TRUE);
113 118
114 remoteMenu->insertItem( tr( "Download" ), this, SLOT( remoteDownload() )); 119 remoteMenu->insertItem( tr( "Download" ), this, SLOT( remoteDownload() ));
115 remoteMenu->insertItem( tr( "Make Directory" ), this, SLOT( remoteMakDir() )); 120 remoteMenu->insertItem( tr( "Make Directory" ), this, SLOT( remoteMakDir() ));
116 remoteMenu->insertItem( tr( "Rename" ), this, SLOT( remoteRename() )); 121 remoteMenu->insertItem( tr( "Rename" ), this, SLOT( remoteRename() ));
117 remoteMenu->insertSeparator(); 122 remoteMenu->insertSeparator();
118 remoteMenu->insertItem( tr( "Delete" ), this, SLOT( remoteDelete() )); 123 remoteMenu->insertItem( tr( "Delete" ), this, SLOT( remoteDelete() ));
119 124
120 tabMenu->insertItem( tr( "Switch to Local" ), this, SLOT( switchToLocalTab() )); 125 tabMenu->insertItem( tr( "Switch to Local" ), this, SLOT( switchToLocalTab() ));
121 tabMenu->insertItem( tr( "Switch to Remote" ), this, SLOT( switchToRemoteTab() )); 126 tabMenu->insertItem( tr( "Switch to Remote" ), this, SLOT( switchToRemoteTab() ));
122 tabMenu->insertItem( tr( "Switch to Config" ), this, SLOT( switchToConfigTab() )); 127 tabMenu->insertItem( tr( "Switch to Config" ), this, SLOT( switchToConfigTab() ));
123 tabMenu->insertSeparator(); 128 tabMenu->insertSeparator();
124 tabMenu->insertItem( tr( "About" ), this, SLOT( doAbout() )); 129 tabMenu->insertItem( tr( "About" ), this, SLOT( doAbout() ));
125 tabMenu->setCheckable(TRUE); 130 tabMenu->setCheckable(TRUE);
126 131
127 132
128 133
129 cdUpButton = new QToolButton( this,"cdUpButton"); 134 cdUpButton = new QToolButton( this,"cdUpButton");
130 cdUpButton->setPixmap(Resource::loadPixmap("up")); 135 cdUpButton->setPixmap(Resource::loadPixmap("up"));
131 cdUpButton ->setFixedSize( QSize( 20, 20 ) ); 136 cdUpButton ->setFixedSize( QSize( 20, 20 ) );
132 connect( cdUpButton ,SIGNAL(released()),this,SLOT( upDir()) ); 137 connect( cdUpButton ,SIGNAL(released()),this,SLOT( upDir()) );
133 layout->addMultiCellWidget( cdUpButton, 0, 0, 3, 3 ); 138 layout->addMultiCellWidget( cdUpButton, 0, 0, 3, 3 );
134 cdUpButton->hide(); 139 cdUpButton->hide();
135 140
136// docButton = new QPushButton(Resource::loadIconSet("DocsIcon"),"",this,"docsButton"); 141// docButton = new QPushButton(Resource::loadIconSet("DocsIcon"),"",this,"docsButton");
137// docButton->setFixedSize( QSize( 20, 20 ) ); 142// docButton->setFixedSize( QSize( 20, 20 ) );
138// connect( docButton,SIGNAL(released()),this,SLOT( docButtonPushed()) ); 143// connect( docButton,SIGNAL(released()),this,SLOT( docButtonPushed()) );
139// docButton->setFlat(TRUE); 144// docButton->setFlat(TRUE);
140// layout->addMultiCellWidget( docButton, 0, 0, 6, 6 ); 145// layout->addMultiCellWidget( docButton, 0, 0, 6, 6 );
141 146
142 homeButton = new QToolButton(this,"homeButton"); 147 homeButton = new QToolButton(this,"homeButton");
143 homeButton->setPixmap( Resource::loadPixmap("home")); 148 homeButton->setPixmap( Resource::loadPixmap("home"));
144 homeButton->setFixedSize( QSize( 20, 20 ) ); 149 homeButton->setFixedSize( QSize( 20, 20 ) );
145 connect(homeButton,SIGNAL(released()),this,SLOT(homeButtonPushed()) ); 150 connect(homeButton,SIGNAL(released()),this,SLOT(homeButtonPushed()) );
146 layout->addMultiCellWidget( homeButton, 0, 0, 4, 4); 151 layout->addMultiCellWidget( homeButton, 0, 0, 4, 4);
147 homeButton->hide(); 152 homeButton->hide();
148 153
149 TabWidget = new QTabWidget( this, "TabWidget" ); 154 TabWidget = new QTabWidget( this, "TabWidget" );
150 layout->addMultiCellWidget( TabWidget, 1, 1, 0, 4 ); 155 layout->addMultiCellWidget( TabWidget, 1, 1, 0, 4 );
151 156
152// TabWidget->setTabShape(QTabWidget::Triangular); 157// TabWidget->setTabShape(QTabWidget::Triangular);
153 158
154 tab = new QWidget( TabWidget, "tab" ); 159 tab = new QWidget( TabWidget, "tab" );
155 tabLayout = new QGridLayout( tab ); 160 tabLayout = new QGridLayout( tab );
156 tabLayout->setSpacing( 2); 161 tabLayout->setSpacing( 2);
157 tabLayout->setMargin( 2); 162 tabLayout->setMargin( 2);
158 163
159 Local_View = new QListView( tab, "Local_View" ); 164 Local_View = new QListView( tab, "Local_View" );
160// Local_View->setResizePolicy( QListView::AutoOneFit ); 165// Local_View->setResizePolicy( QListView::AutoOneFit );
161 Local_View->addColumn( tr("File"),150); 166 Local_View->addColumn( tr("File"),150);
162 Local_View->addColumn( tr("Date"),-1); 167 Local_View->addColumn( tr("Date"),-1);
163 Local_View->setColumnAlignment(1,QListView::AlignRight); 168 Local_View->setColumnAlignment(1,QListView::AlignRight);
164 Local_View->addColumn( tr("Size"),-1); 169 Local_View->addColumn( tr("Size"),-1);
165 Local_View->setColumnAlignment(2,QListView::AlignRight); 170 Local_View->setColumnAlignment(2,QListView::AlignRight);
166 Local_View->setAllColumnsShowFocus(TRUE); 171 Local_View->setAllColumnsShowFocus(TRUE);
167 172
168 Local_View->setMultiSelection( TRUE); 173 Local_View->setMultiSelection( TRUE);
169 Local_View->setSelectionMode(QListView::Extended); 174 Local_View->setSelectionMode(QListView::Extended);
170 Local_View->setFocusPolicy(QWidget::ClickFocus); 175 Local_View->setFocusPolicy(QWidget::ClickFocus);
171 176
172 QPEApplication::setStylusOperation( Local_View->viewport(),QPEApplication::RightOnHold); 177 QPEApplication::setStylusOperation( Local_View->viewport(),QPEApplication::RightOnHold);
173 178
174 tabLayout->addWidget( Local_View, 0, 0 ); 179 tabLayout->addWidget( Local_View, 0, 0 );
175 180
176 connect( Local_View, SIGNAL( clicked( QListViewItem*)), 181 connect( Local_View, SIGNAL( clicked( QListViewItem*)),
177 this,SLOT( localListClicked(QListViewItem *)) ); 182 this,SLOT( localListClicked(QListViewItem *)) );
178// connect( Local_View, SIGNAL( doubleClicked( QListViewItem*)), 183// connect( Local_View, SIGNAL( doubleClicked( QListViewItem*)),
179// this,SLOT( localListClicked(QListViewItem *)) ); 184// this,SLOT( localListClicked(QListViewItem *)) );
180 connect( Local_View, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int)), 185 connect( Local_View, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int)),
181 this,SLOT( ListPressed(int, QListViewItem *, const QPoint&, int)) ); 186 this,SLOT( ListPressed(int, QListViewItem *, const QPoint&, int)) );
182 187
183 TabWidget->insertTab( tab, tr( "Local" ) ); 188 TabWidget->insertTab( tab, tr( "Local" ) );
184 189
@@ -595,205 +600,204 @@ void OpieFtp::remoteDownload()
595 it.current()->setSelected(FALSE); 600 it.current()->setSelected(FALSE);
596 } 601 }
597 } 602 }
598 for ( ; it.current(); ++it ) { 603 for ( ; it.current(); ++it ) {
599 Remote_View->clearSelection(); 604 Remote_View->clearSelection();
600 } 605 }
601 Remote_View->setFocus(); 606 Remote_View->setFocus();
602 TabWidget->setCurrentPage(0); 607 TabWidget->setCurrentPage(0);
603 populateLocalView(); 608 populateLocalView();
604// QCopEnvelope ( "QPE/System", "notBusy()" ); 609// QCopEnvelope ( "QPE/System", "notBusy()" );
605} 610}
606 611
607bool OpieFtp::remoteDirList(const QString &dir) 612bool OpieFtp::remoteDirList(const QString &dir)
608{ 613{
609 QString tmp = QDir::homeDirPath(); 614 QString tmp = QDir::homeDirPath();
610 if(tmp.right(1) != "/") 615 if(tmp.right(1) != "/")
611 tmp+="/._temp"; 616 tmp+="/._temp";
612 else 617 else
613 tmp+="._temp"; 618 tmp+="._temp";
614// qDebug("Listing remote dir "+tmp); 619// qDebug("Listing remote dir "+tmp);
615// QCopEnvelope ( "QPE/System", "busy()" ); 620// QCopEnvelope ( "QPE/System", "busy()" );
616 if (!FtpDir( tmp.latin1(), dir.latin1(), conn) ) { 621 if (!FtpDir( tmp.latin1(), dir.latin1(), conn) ) {
617 QString msg; 622 QString msg;
618 msg.sprintf(tr("Unable to list the directory\n")+dir+"\n%s",FtpLastResponse(conn) ); 623 msg.sprintf(tr("Unable to list the directory\n")+dir+"\n%s",FtpLastResponse(conn) );
619 msg.replace(QRegExp(":"),"\n"); 624 msg.replace(QRegExp(":"),"\n");
620 QMessageBox::message(tr("Note"),msg); 625 QMessageBox::message(tr("Note"),msg);
621 return false; 626 return false;
622 } 627 }
623 populateRemoteView() ; 628 populateRemoteView() ;
624// QCopEnvelope ( "QPE/System", "notBusy()" ); 629// QCopEnvelope ( "QPE/System", "notBusy()" );
625 return true; 630 return true;
626} 631}
627 632
628bool OpieFtp::remoteChDir(const QString &dir) 633bool OpieFtp::remoteChDir(const QString &dir)
629{ 634{
630// QCopEnvelope ( "QPE/System", "busy()" ); 635// QCopEnvelope ( "QPE/System", "busy()" );
631 if (!FtpChdir( dir.latin1(), conn )) { 636 if (!FtpChdir( dir.latin1(), conn )) {
632 QString msg; 637 QString msg;
633 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));
634 msg.replace(QRegExp(":"),"\n"); 639 msg.replace(QRegExp(":"),"\n");
635 QMessageBox::message(tr("Note"),msg); 640 QMessageBox::message(tr("Note"),msg);
636// qDebug(msg); 641// qDebug(msg);
637// QCopEnvelope ( "QPE/System", "notBusy()" ); 642// QCopEnvelope ( "QPE/System", "notBusy()" );
638 return FALSE; 643 return FALSE;
639 } 644 }
640// QCopEnvelope ( "QPE/System", "notBusy()" ); 645// QCopEnvelope ( "QPE/System", "notBusy()" );
641 return TRUE; 646 return TRUE;
642} 647}
643 648
644void OpieFtp::populateLocalView() 649void OpieFtp::populateLocalView()
645{ 650{
646 Local_View->clear(); 651 Local_View->clear();
647 currentDir.setSorting(/* QDir::Size*/ /*| QDir::Reversed | */QDir::DirsFirst); 652 currentDir.setSorting(/* QDir::Size*/ /*| QDir::Reversed | */QDir::DirsFirst);
648 currentDir.setMatchAllDirs(TRUE); 653 currentDir.setMatchAllDirs(TRUE);
649 currentDir.setNameFilter(filterStr); 654 currentDir.setNameFilter(filterStr);
650 QString fileL, fileS, fileDate; 655 QString fileL, fileS, fileDate;
651 bool isDir=FALSE; 656 bool isDir=FALSE;
652 const QFileInfoList *list = currentDir.entryInfoList( /*QDir::All*/ /*, QDir::SortByMask*/); 657 const QFileInfoList *list = currentDir.entryInfoList( /*QDir::All*/ /*, QDir::SortByMask*/);
653 QFileInfoListIterator it(*list); 658 QFileInfoListIterator it(*list);
654 QFileInfo *fi; 659 QFileInfo *fi;
655 while ( (fi=it.current()) ) { 660 while ( (fi=it.current()) ) {
656 if (fi->isSymLink() ){ 661 if (fi->isSymLink() ){
657 QString symLink=fi->readLink(); 662 QString symLink=fi->readLink();
658// qDebug("Symlink detected "+symLink); 663// qDebug("Symlink detected "+symLink);
659 QFileInfo sym( symLink); 664 QFileInfo sym( symLink);
660 fileS.sprintf( "%10i", sym.size() ); 665 fileS.sprintf( "%10i", sym.size() );
661 fileL.sprintf( "%s -> %s", fi->fileName().data(),sym.absFilePath().data() ); 666 fileL.sprintf( "%s -> %s", fi->fileName().data(),sym.absFilePath().data() );
662 fileDate = sym.lastModified().toString(); 667 fileDate = sym.lastModified().toString();
663 } else { 668 } else {
664// qDebug("Not a dir: "+currentDir.canonicalPath()+fileL); 669// qDebug("Not a dir: "+currentDir.canonicalPath()+fileL);
665 fileS.sprintf( "%10i", fi->size() ); 670 fileS.sprintf( "%10i", fi->size() );
666 fileL.sprintf( "%s",fi->fileName().data() ); 671 fileL.sprintf( "%s",fi->fileName().data() );
667 fileDate= fi->lastModified().toString(); 672 fileDate= fi->lastModified().toString();
668 if( QDir(QDir::cleanDirPath(currentDir.canonicalPath()+"/"+fileL)).exists() ) { 673 if( QDir(QDir::cleanDirPath(currentDir.canonicalPath()+"/"+fileL)).exists() ) {
669 fileL+="/"; 674 fileL+="/";
670 isDir=TRUE; 675 isDir=TRUE;
671// qDebug( fileL); 676// qDebug( fileL);
672 } 677 }
673 } 678 }
674 if(fileL !="./" && fi->exists()) { 679 if(fileL !="./" && fi->exists()) {
675 item = new QListViewItem( Local_View,fileL, fileDate, fileS ); 680 item = new QListViewItem( Local_View,fileL, fileDate, fileS );
676 QPixmap pm; 681 QPixmap pm;
677 682
678 if(isDir || fileL.find("/",0,TRUE) != -1) { 683 if(isDir || fileL.find("/",0,TRUE) != -1) {
679 if( !QDir( fi->filePath() ).isReadable()) 684 if( !QDir( fi->filePath() ).isReadable())
680 pm = Resource::loadPixmap( "lockedfolder" ); 685 pm = Resource::loadPixmap( "lockedfolder" );
681 else 686 else
682 pm= Resource::loadPixmap( "folder" ); 687 pm= Resource::loadPixmap( "folder" );
683 item->setPixmap( 0,pm ); 688 item->setPixmap( 0,pm );
684 } else { 689 } else {
685 if( !fi->isReadable() ) 690 if( !fi->isReadable() )
686 pm = Resource::loadPixmap( "locked" ); 691 pm = Resource::loadPixmap( "locked" );
687 else { 692 else {
688 MimeType mt(fi->filePath()); 693 MimeType mt(fi->filePath());
689 pm=mt.pixmap(); //sets the correct pixmap for mimetype 694 pm=mt.pixmap(); //sets the correct pixmap for mimetype
690 if(pm.isNull()) 695 if(pm.isNull())
691 pm = Resource::loadPixmap( "UnknownDocument-14" ); 696 pm = unknownXpm;
692 item->setPixmap( 0,pm);
693 } 697 }
694 } 698 }
695 if( fileL.find("->",0,TRUE) != -1) { 699 if( fileL.find("->",0,TRUE) != -1) {
696 // overlay link image 700 // overlay link image
697 pm= Resource::loadPixmap( "folder" ); 701 pm= Resource::loadPixmap( "folder" );
698 QPixmap lnk = Resource::loadPixmap( "opie/symlink" ); 702 QPixmap lnk = Resource::loadPixmap( "opie/symlink" );
699 QPainter painter( &pm ); 703 QPainter painter( &pm );
700 painter.drawPixmap( pm.width()-lnk.width(), pm.height()-lnk.height(), lnk ); 704 painter.drawPixmap( pm.width()-lnk.width(), pm.height()-lnk.height(), lnk );
701 pm.setMask( pm.createHeuristicMask( FALSE ) ); 705 pm.setMask( pm.createHeuristicMask( FALSE ) );
702 item->setPixmap( 0, pm);
703 } 706 }
707 item->setPixmap( 0,pm);
704 } 708 }
705 isDir=FALSE; 709 isDir=FALSE;
706 ++it; 710 ++it;
707 } 711 }
708 Local_View->setSorting( 3,FALSE); 712 Local_View->setSorting( 3,FALSE);
709 currentPathCombo->lineEdit()->setText( currentDir.canonicalPath() ); 713 currentPathCombo->lineEdit()->setText( currentDir.canonicalPath() );
710 fillCombo( (const QString &)currentDir); 714 fillCombo( (const QString &)currentDir);
711} 715}
712 716
713bool OpieFtp::populateRemoteView( ) 717bool OpieFtp::populateRemoteView( )
714{ 718{
715// qDebug("populate remoteview"); 719// qDebug("populate remoteview");
716 QString sfile=QDir::homeDirPath(); 720 QString sfile=QDir::homeDirPath();
717 if(sfile.right(1) != "/") 721 if(sfile.right(1) != "/")
718 sfile+="/._temp"; 722 sfile+="/._temp";
719 else 723 else
720 sfile+="._temp"; 724 sfile+="._temp";
721 QFile file( sfile); 725 QFile file( sfile);
722 Remote_View->clear(); 726 Remote_View->clear();
723 QString s, File_Name; 727 QString s, File_Name;
724 QListViewItem *itemDir=NULL, *itemFile=NULL; 728 QListViewItem *itemDir=NULL, *itemFile=NULL;
725 QRegExp monthRe(" [JFMASOND][eapuecoe][brynlgptvc] [ 0-9][0-9] [ 0-9][0-9][:0-9][0-9][0-9] "); 729 QRegExp monthRe(" [JFMASOND][eapuecoe][brynlgptvc] [ 0-9][0-9] [ 0-9][0-9][:0-9][0-9][0-9] ");
726 QString fileL, fileS, fileDate; 730 QString fileL, fileS, fileDate;
727 if ( file.open(IO_ReadOnly)) { 731 if ( file.open(IO_ReadOnly)) {
728 QTextStream t( &file ); // use a text stream 732 QTextStream t( &file ); // use a text stream
729 while ( !t.eof()) { 733 while ( !t.eof()) {
730 s = t.readLine(); 734 s = t.readLine();
731 735
732 if(s.find("total",0,TRUE) == 0) 736 if(s.find("total",0,TRUE) == 0)
733 continue; 737 continue;
734 738
735 int len, month = monthRe.match(s, 0, &len); 739 int len, month = monthRe.match(s, 0, &len);
736 fileDate = s.mid(month + 1, len - 2); // minus spaces 740 fileDate = s.mid(month + 1, len - 2); // minus spaces
737 fileL = s.right(s.length() - month - len); 741 fileL = s.right(s.length() - month - len);
738 if(s.left(1) == "d") 742 if(s.left(1) == "d")
739 fileL = fileL+"/"; 743 fileL = fileL+"/";
740 fileS = s.mid(month - 8, 8); // FIXME 744 fileS = s.mid(month - 8, 8); // FIXME
741 fileS = fileS.stripWhiteSpace(); 745 fileS = fileS.stripWhiteSpace();
742 746
743 if(s.left(1) == "d" || fileL.find("/",0,TRUE) != -1) { 747 if(s.left(1) == "d" || fileL.find("/",0,TRUE) != -1) {
744 QListViewItem * item = new QListViewItem( Remote_View, fileL, fileDate, fileS,"d"); 748 QListViewItem * item = new QListViewItem( Remote_View, fileL, fileDate, fileS,"d");
745 item->setPixmap( 0, Resource::loadPixmap( "folder" )); 749 item->setPixmap( 0, Resource::loadPixmap( "folder" ));
746// if(itemDir) 750// if(itemDir)
747 item->moveItem(itemDir); 751 item->moveItem(itemDir);
748 itemDir=item; 752 itemDir=item;
749 } else { 753 } else {
750 QListViewItem * item = new QListViewItem( Remote_View, fileL, fileDate, fileS,"f"); 754 QListViewItem * item = new QListViewItem( Remote_View, fileL, fileDate, fileS,"f");
751 item->setPixmap( 0, Resource::loadPixmap( "fileopen" )); 755 item->setPixmap( 0, Resource::loadPixmap( "fileopen" ));
752// if(itemFile) 756// if(itemFile)
753 item->moveItem(itemDir); 757 item->moveItem(itemDir);
754 item->moveItem(itemFile); 758 item->moveItem(itemFile);
755 itemFile=item; 759 itemFile=item;
756 } 760 }
757 } 761 }
758 QListViewItem * item1 = new QListViewItem( Remote_View, "../"); 762 QListViewItem * item1 = new QListViewItem( Remote_View, "../");
759 item1->setPixmap( 0, Resource::loadPixmap( "folder" )); 763 item1->setPixmap( 0, Resource::loadPixmap( "folder" ));
760 file.close(); 764 file.close();
761 if( file.exists()) 765 if( file.exists())
762 file. remove(); 766 file. remove();
763 } else 767 } else
764 qDebug("temp file not opened successfullly "+sfile); 768 qDebug("temp file not opened successfullly "+sfile);
765 Remote_View->setSorting( 4,TRUE); 769 Remote_View->setSorting( 4,TRUE);
766 return true; 770 return true;
767} 771}
768 772
769void OpieFtp::remoteListClicked(QListViewItem *selectedItem) 773void OpieFtp::remoteListClicked(QListViewItem *selectedItem)
770{ 774{
771 if( selectedItem) { 775 if( selectedItem) {
772// QCopEnvelope ( "QPE/System", "busy()" ); 776// QCopEnvelope ( "QPE/System", "busy()" );
773 QString oldRemoteCurrentDir = currentRemoteDir; 777 QString oldRemoteCurrentDir = currentRemoteDir;
774 QString strItem=selectedItem->text(0); 778 QString strItem=selectedItem->text(0);
775 strItem=strItem.simplifyWhiteSpace(); 779 strItem=strItem.simplifyWhiteSpace();
776 if(strItem == "../") { // the user wants to go ^ 780 if(strItem == "../") { // the user wants to go ^
777 if( FtpCDUp( conn) == 0) { 781 if( FtpCDUp( conn) == 0) {
778 QString msg; 782 QString msg;
779 msg.sprintf(tr("Unable to cd up\n")+"%s",FtpLastResponse(conn)); 783 msg.sprintf(tr("Unable to cd up\n")+"%s",FtpLastResponse(conn));
780 msg.replace(QRegExp(":"),"\n"); 784 msg.replace(QRegExp(":"),"\n");
781 QMessageBox::message(tr("Note"),msg); 785 QMessageBox::message(tr("Note"),msg);
782// qDebug(msg); 786// qDebug(msg);
783 } 787 }
784 char path[256]; 788 char path[256];
785 if( FtpPwd( path,sizeof(path),conn) == 0) { //this is easier than fudging the string 789 if( FtpPwd( path,sizeof(path),conn) == 0) { //this is easier than fudging the string
786 QString msg; 790 QString msg;
787 msg.sprintf(tr("Unable to get working dir\n")+"%s",FtpLastResponse(conn)); 791 msg.sprintf(tr("Unable to get working dir\n")+"%s",FtpLastResponse(conn));
788 msg.replace(QRegExp(":"),"\n"); 792 msg.replace(QRegExp(":"),"\n");
789 QMessageBox::message(tr("Note"),msg); 793 QMessageBox::message(tr("Note"),msg);
790// qDebug(msg); 794// qDebug(msg);
791 } 795 }
792 currentRemoteDir=path; 796 currentRemoteDir=path;
793 } else { 797 } else {
794 if(strItem.find("->",0,TRUE) != -1) { //symlink on some servers 798 if(strItem.find("->",0,TRUE) != -1) { //symlink on some servers
795 strItem=strItem.right( strItem.length() - strItem.find("->",0,TRUE) - 2 ); 799 strItem=strItem.right( strItem.length() - strItem.find("->",0,TRUE) - 2 );
796 strItem = strItem.stripWhiteSpace(); 800 strItem = strItem.stripWhiteSpace();
797 currentRemoteDir = strItem; 801 currentRemoteDir = strItem;
798 if( !remoteChDir( (const QString &)strItem)) { 802 if( !remoteChDir( (const QString &)strItem)) {
799 currentRemoteDir = oldRemoteCurrentDir; 803 currentRemoteDir = oldRemoteCurrentDir;
diff --git a/noncore/net/opieftp/opieftp.h b/noncore/net/opieftp/opieftp.h
index 109b5f8..9d5d211 100644
--- a/noncore/net/opieftp/opieftp.h
+++ b/noncore/net/opieftp/opieftp.h
@@ -1,140 +1,142 @@
1/*************************************************************************** 1/***************************************************************************
2 opieftp.h 2 opieftp.h
3 ------------------- 3 -------------------
4** Created: Sat Mar 9 23:33:09 2002 4** Created: Sat Mar 9 23:33:09 2002
5 copyright : (C) 2002 by ljp 5 copyright : (C) 2002 by ljp
6 email : ljp@llornkcor.com 6 email : ljp@llornkcor.com
7 * This program is free software; you can redistribute it and/or modify * 7 * This program is free software; you can redistribute it and/or modify *
8 * it under the terms of the GNU General Public License as published by * 8 * it under the terms of the GNU General Public License as published by *
9 * the Free Software Foundation; either version 2 of the License, or * 9 * the Free Software Foundation; either version 2 of the License, or *
10 * (at your option) any later version. * 10 * (at your option) any later version. *
11 ***************************************************************************/ 11 ***************************************************************************/
12#ifndef OPIEFTP_H 12#ifndef OPIEFTP_H
13#define OPIEFTP_H 13#define OPIEFTP_H
14 14
15#include <qvariant.h> 15#include <qvariant.h>
16#include <qdialog.h> 16#include <qdialog.h>
17#include <qmainwindow.h> 17#include <qmainwindow.h>
18#include <qdir.h> 18#include <qdir.h>
19#include <qstring.h> 19#include <qstring.h>
20#include <qpoint.h> 20#include <qpoint.h>
21#include <qpixmap.h>
21 22
22class QVBoxLayout; 23class QVBoxLayout;
23class QHBoxLayout; 24class QHBoxLayout;
24class QGridLayout; 25class QGridLayout;
25class QComboBox; 26class QComboBox;
26class QListView; 27class QListView;
27class QListViewItem; 28class QListViewItem;
28class QLabel; 29class QLabel;
29class QProgressBar; 30class QProgressBar;
30class QSpinBox; 31class QSpinBox;
31class QTabWidget; 32class QTabWidget;
32class QWidget; 33class QWidget;
33class QPEToolBar; 34class QPEToolBar;
34class QPEMenuBar; 35class QPEMenuBar;
35class QPopupMenu; 36class QPopupMenu;
36class QFile; 37class QFile;
37class QLineEdit; 38class QLineEdit;
38class QPushButton; 39class QPushButton;
39class QToolButton; 40class QToolButton;
40class QStringList; 41class QStringList;
41class QListBox; 42class QListBox;
42class QTimer; 43class QTimer;
43 44
44class OpieFtp : public QMainWindow 45class OpieFtp : public QMainWindow
45{ 46{
46 Q_OBJECT 47 Q_OBJECT
47 48
48public: 49public:
49 OpieFtp( ); 50 OpieFtp( );
50 ~OpieFtp(); 51 ~OpieFtp();
51 52
52 QTabWidget *TabWidget; 53 QTabWidget *TabWidget;
53 QWidget *tab, *tab_2, *tab_3; 54 QWidget *tab, *tab_2, *tab_3;
54 QListView *Local_View, *Remote_View; 55 QListView *Local_View, *Remote_View;
55 QListBox *serverListView; 56 QListBox *serverListView;
56 57
57 QComboBox *UsernameComboBox, *ServerComboBox, *currentPathCombo; 58 QComboBox *UsernameComboBox, *ServerComboBox, *currentPathCombo;
58 QLineEdit *PasswordEdit, *remotePath; 59 QLineEdit *PasswordEdit, *remotePath;
59 QLabel *TextLabel2, *TextLabel1, *TextLabel3, *TextLabel4;; 60 QLabel *TextLabel2, *TextLabel1, *TextLabel3, *TextLabel4;;
60 QSpinBox* PortSpinBox; 61 QSpinBox* PortSpinBox;
61 QPopupMenu *connectionMenu, *localMenu, *remoteMenu, *tabMenu, *aboutMenu; 62 QPopupMenu *connectionMenu, *localMenu, *remoteMenu, *tabMenu, *aboutMenu;
62 QDir currentDir; 63 QDir currentDir;
63 QString currentRemoteDir; 64 QString currentRemoteDir;
64 QString filterStr; 65 QString filterStr;
65 QListViewItem * item; 66 QListViewItem * item;
66 QPushButton *connectServerBtn, *newServerButton;// 67 QPushButton *connectServerBtn, *newServerButton;//
67 QToolButton *cdUpButton, *homeButton, *docButton; 68 QToolButton *cdUpButton, *homeButton, *docButton;
68 bool b; 69 bool b;
69 int currentServerConfig; 70 int currentServerConfig;
70protected slots: 71protected slots:
71 void timerOut(); 72 void timerOut();
72 void upDir(); 73 void upDir();
73 void homeButtonPushed(); 74 void homeButtonPushed();
74 void docButtonPushed(); 75 void docButtonPushed();
75 void doAbout(); 76 void doAbout();
76 77
77 void serverComboEdited(const QString & ); 78 void serverComboEdited(const QString & );
78 void UsernameComboBoxEdited(const QString & ); 79 void UsernameComboBoxEdited(const QString & );
79 void PasswordEditEdited(const QString & ); 80 void PasswordEditEdited(const QString & );
80 81
81 void showLocalMenu( QListViewItem *); 82 void showLocalMenu( QListViewItem *);
82 void showRemoteMenu( QListViewItem *); 83 void showRemoteMenu( QListViewItem *);
83 void doLocalCd(); 84 void doLocalCd();
84 void doRemoteCd(); 85 void doRemoteCd();
85 void localUpload(); 86 void localUpload();
86 void remoteDownload(); 87 void remoteDownload();
87 void newConnection(); 88 void newConnection();
88 void connector(); 89 void connector();
89 void disConnector(); 90 void disConnector();
90 void populateLocalView(); 91 void populateLocalView();
91 bool populateRemoteView(); 92 bool populateRemoteView();
92 void showHidden(); 93 void showHidden();
93 void writeConfig(); 94 void writeConfig();
94 void readConfig(); 95 void readConfig();
95 void localListClicked(QListViewItem *); 96 void localListClicked(QListViewItem *);
96 void remoteListClicked(QListViewItem *); 97 void remoteListClicked(QListViewItem *);
97 void ListPressed( int, QListViewItem *, const QPoint&, int); 98 void ListPressed( int, QListViewItem *, const QPoint&, int);
98 void RemoteListPressed( int, QListViewItem *, const QPoint&, int); 99 void RemoteListPressed( int, QListViewItem *, const QPoint&, int);
99 void localMakDir(); 100 void localMakDir();
100 void localDelete(); 101 void localDelete();
101 void remoteMakDir(); 102 void remoteMakDir();
102 void remoteDelete(); 103 void remoteDelete();
103 104
104 bool remoteDirList(const QString &); 105 bool remoteDirList(const QString &);
105 bool remoteChDir(const QString &); 106 bool remoteChDir(const QString &);
106 107
107 void tabChanged(QWidget*); 108 void tabChanged(QWidget*);
108 void cleanUp(); 109 void cleanUp();
109 110
110 void remoteRename(); 111 void remoteRename();
111 void localRename(); 112 void localRename();
112 113
113 void currentPathComboChanged(); 114 void currentPathComboChanged();
114 void currentPathComboActivated(const QString &); 115 void currentPathComboActivated(const QString &);
115 void switchToLocalTab(); 116 void switchToLocalTab();
116 void switchToRemoteTab(); 117 void switchToRemoteTab();
117 void switchToConfigTab(); 118 void switchToConfigTab();
118 119
119 void fillCombos(); 120 void fillCombos();
120 void clearCombos(); 121 void clearCombos();
121 void fillRemoteCombo(const QString&); 122 void fillRemoteCombo(const QString&);
122 void fillCombo(const QString &); 123 void fillCombo(const QString &);
123 void serverComboSelected(int); 124 void serverComboSelected(int);
124 void deleteServer(); 125 void deleteServer();
125 void connectorBtnToggled(bool); 126 void connectorBtnToggled(bool);
126 void NewServer(); 127 void NewServer();
127 void serverListClicked( const QString &); 128 void serverListClicked( const QString &);
128 129
129protected: 130protected:
131 QPixmap unknownXpm;
130 bool fuckeduphack; 132 bool fuckeduphack;
131 QStringList remoteDirPathStringList, localDirPathStringList; 133 QStringList remoteDirPathStringList, localDirPathStringList;
132 QString newServerName; 134 QString newServerName;
133 void nullifyCallBack(); 135 void nullifyCallBack();
134 QGridLayout* tabLayout; 136 QGridLayout* tabLayout;
135 QGridLayout* tabLayout_2; 137 QGridLayout* tabLayout_2;
136 QGridLayout* tabLayout_3; 138 QGridLayout* tabLayout_3;
137 139
138}; 140};
139 141
140#endif // OPIEFTP_H 142#endif // OPIEFTP_H