summaryrefslogtreecommitdiff
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/net/opieftp/opie-ftp.control2
-rw-r--r--noncore/net/opieftp/opieftp.cpp71
2 files changed, 32 insertions, 41 deletions
diff --git a/noncore/net/opieftp/opie-ftp.control b/noncore/net/opieftp/opie-ftp.control
index 32cc7a6..82f774f 100644
--- a/noncore/net/opieftp/opie-ftp.control
+++ b/noncore/net/opieftp/opie-ftp.control
@@ -1,11 +1,11 @@
1Package: opie-ftp 1Package: opie-ftp
2Files: plugins/application/libopieftp.so* bin/opieftp pics/opieftp apps/Applications/opieftp.desktop 2Files: plugins/application/libopieftp.so* bin/opieftp pics/opieftp apps/Applications/opieftp.desktop
3Priority: optional 3Priority: optional
4Section: opie/applications 4Section: opie/applications
5Maintainer: L.J. Potter <ljp@llornkcor.com> 5Maintainer: L.J. Potter <ljp@llornkcor.com>
6Architecture: arm 6Architecture: arm
7Depends: task-opie-minimal, ftplib 7Depends: task-opie-minimal, ftplib, libopiecore2
8Replaces: opieftp 8Replaces: opieftp
9Description: Opie-Ftp 9Description: Opie-Ftp
10 The ftp client for the Opie environment. 10 The ftp client for the Opie environment.
11Version: $QPE_VERSION$EXTRAVERSION 11Version: $QPE_VERSION$EXTRAVERSION
diff --git a/noncore/net/opieftp/opieftp.cpp b/noncore/net/opieftp/opieftp.cpp
index 4f0ca29..14fd859 100644
--- a/noncore/net/opieftp/opieftp.cpp
+++ b/noncore/net/opieftp/opieftp.cpp
@@ -1,197 +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.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//using namespace Opie::Core; 24//using namespace Opie::Core;
25 25
26#include <qpe/qpeapplication.h> 26#include <opie2/oresource.h>
27#include <qpe/resource.h> 27
28#include <qpe/applnk.h>
28#include <qpe/config.h> 29#include <qpe/config.h>
29#include <qpe/mimetype.h> 30#include <qpe/mimetype.h>
31#include <qpe/qpeapplication.h>
32#include <qpe/qpemenubar.h>
30 33
31#include <qtextstream.h> 34#include <qbitmap.h>
32#include <qpushbutton.h>
33#include <qtoolbutton.h>
34#include <qcombobox.h> 35#include <qcombobox.h>
35#include <qlistview.h>
36#include <qlabel.h> 36#include <qlabel.h>
37#include <qlayout.h>
38#include <qlistview.h>
39#include <qmenubar.h>
40#include <qmessagebox.h>
37#include <qprogressbar.h> 41#include <qprogressbar.h>
42#include <qpushbutton.h>
38#include <qspinbox.h> 43#include <qspinbox.h>
39#include <qtabwidget.h> 44#include <qtabwidget.h>
40#include <qlayout.h> 45#include <qtextstream.h>
41#include <qmessagebox.h> 46#include <qtoolbutton.h>
42#include <qmenubar.h>
43#include <qpe/qpemenubar.h>
44 47
45#include <qlineedit.h> 48#include <qlineedit.h>
46#include <qlistbox.h> 49#include <qlistbox.h>
47#include <qvbox.h> 50#include <qvbox.h>
48/* STD */ 51/* STD */
49#include <unistd.h> 52#include <unistd.h>
50#include <stdlib.h> 53#include <stdlib.h>
51 54
52QProgressBar *ProgressBar; 55QProgressBar *ProgressBar;
53static netbuf *conn = NULL; 56static netbuf *conn = NULL;
54 57
55static int log_progress(netbuf *, int xfered, void *) 58static int log_progress(netbuf *, int xfered, void *)
56{ 59{
57// int fsz = *(int *)arg; 60// int fsz = *(int *)arg;
58// int pct = (xfered * 100) / fsz; 61// int pct = (xfered * 100) / fsz;
59// printf("%3d%%\r", pct); 62// printf("%3d%%\r", pct);
60// fflush(stdout); 63// fflush(stdout);
61 ProgressBar->setProgress(xfered); 64 ProgressBar->setProgress(xfered);
62 qApp->processEvents(); 65 qApp->processEvents();
63 return 1; 66 return 1;
64} 67}
65 68
66OpieFtp::OpieFtp( QWidget* , const char*, WFlags) 69OpieFtp::OpieFtp( QWidget* , const char*, WFlags)
67 : QMainWindow( ) 70 : QMainWindow( )
68{ 71{
69 qDebug("OpieFtp constructor"); 72 qDebug("OpieFtp constructor");
70 setCaption( tr( "OpieFtp" ) ); 73 setCaption( tr( "OpieFtp" ) );
71 // initializeGui(); 74 // initializeGui();
72 QTimer::singleShot( 50, this, SLOT(initializeGui() )); 75 QTimer::singleShot( 50, this, SLOT(initializeGui() ));
73} 76}
74 77
75void OpieFtp::initializeGui() { 78void OpieFtp::initializeGui() {
76 fuckeduphack=FALSE; 79 fuckeduphack=FALSE;
77 80
78 QVBox* wrapperBox = new QVBox( this ); 81 QVBox* wrapperBox = new QVBox( this );
79 setCentralWidget( wrapperBox ); 82 setCentralWidget( wrapperBox );
80 83
81 QWidget *view = new QWidget( wrapperBox ); 84 QWidget *view = new QWidget( wrapperBox );
82 85
83 QGridLayout *layout = new QGridLayout( view ); 86 QGridLayout *layout = new QGridLayout( view );
84 layout->setSpacing( 1); 87 layout->setSpacing( 1);
85 layout->setMargin( 1); 88 layout->setMargin( 1);
86 connect( qApp,SIGNAL( aboutToQuit()),SLOT( cleanUp()) ); 89 connect( qApp,SIGNAL( aboutToQuit()),SLOT( cleanUp()) );
87 90
88 QPEMenuBar *menuBar = new QPEMenuBar(view); 91 QPEMenuBar *menuBar = new QPEMenuBar(view);
89// QMenuBar *menuBar = new QMenuBar(this); 92// QMenuBar *menuBar = new QMenuBar(this);
90// QPEToolBar *menuBar = new QPEToolBar(this); 93// QPEToolBar *menuBar = new QPEToolBar(this);
91// menuBar->setHorizontalStretchable( TRUE ); 94// menuBar->setHorizontalStretchable( TRUE );
92 95
93 QWMatrix matrix; 96 unknownXpm = Opie::Core::OResource::loadPixmap( "UnknownDocument", Opie::Core::OResource::SmallIcon );
94 QPixmap pix(Resource::loadPixmap( "UnknownDocument" ));
95 matrix.scale( .4, .4);
96 unknownXpm = pix.xForm(matrix);
97 97
98 connectionMenu = new QPopupMenu( this ); 98 connectionMenu = new QPopupMenu( this );
99 localMenu = new QPopupMenu( this ); 99 localMenu = new QPopupMenu( this );
100 remoteMenu = new QPopupMenu( this ); 100 remoteMenu = new QPopupMenu( this );
101 tabMenu = new QPopupMenu( this ); 101 tabMenu = new QPopupMenu( this );
102 102
103 layout->addMultiCellWidget( menuBar, 0, 0, 0, 2 ); 103 layout->addMultiCellWidget( menuBar, 0, 0, 0, 2 );
104 104
105 menuBar->insertItem( tr( "Connection" ), connectionMenu); 105 menuBar->insertItem( tr( "Connection" ), connectionMenu);
106// menuBar->insertItem( tr( "Local" ), localMenu); 106// menuBar->insertItem( tr( "Local" ), localMenu);
107// menuBar->insertItem( tr( "Remote" ), remoteMenu); 107// menuBar->insertItem( tr( "Remote" ), remoteMenu);
108 menuBar->insertItem( tr( "View" ), tabMenu); 108 menuBar->insertItem( tr( "View" ), tabMenu);
109 109
110 tabMenu->insertItem( tr( "Local" ), localMenu); 110 tabMenu->insertItem( tr( "Local" ), localMenu);
111 tabMenu->insertItem( tr( "Remote" ), remoteMenu); 111 tabMenu->insertItem( tr( "Remote" ), remoteMenu);
112 112
113 connectionMenu->insertItem( tr( "New" ), this, SLOT( newConnection() )); 113 connectionMenu->insertItem( tr( "New" ), this, SLOT( newConnection() ));
114 connectionMenu->insertItem( tr( "Connect" ), this, SLOT( connector() )); 114 connectionMenu->insertItem( tr( "Connect" ), this, SLOT( connector() ));
115 connectionMenu->insertItem( tr( "Disconnect" ), this, SLOT( disConnector() )); 115 connectionMenu->insertItem( tr( "Disconnect" ), this, SLOT( disConnector() ));
116 116
117 localMenu->insertItem( tr( "Show Hidden Files" ), this, SLOT( showHidden() )); 117 localMenu->insertItem( tr( "Show Hidden Files" ), this, SLOT( showHidden() ));
118 localMenu->insertSeparator(); 118 localMenu->insertSeparator();
119 localMenu->insertItem( tr( "Upload" ), this, SLOT( localUpload() )); 119 localMenu->insertItem( tr( "Upload" ), this, SLOT( localUpload() ));
120 localMenu->insertItem( tr( "Make Directory" ), this, SLOT( localMakDir() )); 120 localMenu->insertItem( tr( "Make Directory" ), this, SLOT( localMakDir() ));
121 localMenu->insertItem( tr( "Rename" ), this, SLOT( localRename() )); 121 localMenu->insertItem( tr( "Rename" ), this, SLOT( localRename() ));
122 localMenu->insertSeparator(); 122 localMenu->insertSeparator();
123 localMenu->insertItem( tr( "Delete" ), this, SLOT( localDelete() )); 123 localMenu->insertItem( tr( "Delete" ), this, SLOT( localDelete() ));
124 localMenu->setCheckable(TRUE); 124 localMenu->setCheckable(TRUE);
125 125
126 remoteMenu->insertItem( tr( "Download" ), this, SLOT( remoteDownload() )); 126 remoteMenu->insertItem( tr( "Download" ), this, SLOT( remoteDownload() ));
127 remoteMenu->insertItem( tr( "Make Directory" ), this, SLOT( remoteMakDir() )); 127 remoteMenu->insertItem( tr( "Make Directory" ), this, SLOT( remoteMakDir() ));
128 remoteMenu->insertItem( tr( "Rename" ), this, SLOT( remoteRename() )); 128 remoteMenu->insertItem( tr( "Rename" ), this, SLOT( remoteRename() ));
129 remoteMenu->insertSeparator(); 129 remoteMenu->insertSeparator();
130 remoteMenu->insertItem( tr( "Delete" ), this, SLOT( remoteDelete() )); 130 remoteMenu->insertItem( tr( "Delete" ), this, SLOT( remoteDelete() ));
131 131
132 tabMenu->insertSeparator(); 132 tabMenu->insertSeparator();
133 tabMenu->insertItem( tr( "Switch to Local" ), this, SLOT( switchToLocalTab() )); 133 tabMenu->insertItem( tr( "Switch to Local" ), this, SLOT( switchToLocalTab() ));
134 tabMenu->insertItem( tr( "Switch to Remote" ), this, SLOT( switchToRemoteTab() )); 134 tabMenu->insertItem( tr( "Switch to Remote" ), this, SLOT( switchToRemoteTab() ));
135 tabMenu->insertItem( tr( "Switch to Config" ), this, SLOT( switchToConfigTab() )); 135 tabMenu->insertItem( tr( "Switch to Config" ), this, SLOT( switchToConfigTab() ));
136 tabMenu->insertSeparator();
137// tabMenu->insertItem( tr( "About" ), this, SLOT( doAbout() ));
138 tabMenu->setCheckable(TRUE); 136 tabMenu->setCheckable(TRUE);
139 137
140 138 bool useBigPix = qApp->desktop()->size().width() > 330;
141 cdUpButton = new QToolButton( view,"cdUpButton"); 139 cdUpButton = new QToolButton( view,"cdUpButton");
142 cdUpButton->setPixmap(Resource::loadPixmap("up")); 140 cdUpButton->setUsesBigPixmap( useBigPix );
143 cdUpButton ->setFixedSize( QSize( 20, 20 ) ); 141 cdUpButton->setPixmap( Opie::Core::OResource::loadPixmap( "up", Opie::Core::OResource::SmallIcon ) );
142 cdUpButton->setFixedSize( AppLnk::smallIconSize(), AppLnk::smallIconSize() );
144 connect( cdUpButton ,SIGNAL(released()),this,SLOT( upDir()) ); 143 connect( cdUpButton ,SIGNAL(released()),this,SLOT( upDir()) );
145 layout->addMultiCellWidget( cdUpButton, 0, 0, 4, 4 ); 144 layout->addMultiCellWidget( cdUpButton, 0, 0, 4, 4 );
146 cdUpButton->hide(); 145 cdUpButton->hide();
147 146
148// docButton = new QPushButton(Resource::loadIconSet("DocsIcon"),"",view,"docsButton");
149// docButton->setFixedSize( QSize( 20, 20 ) );
150// connect( docButton,SIGNAL(released()),this,SLOT( docButtonPushed()) );
151// docButton->setFlat(TRUE);
152// layout->addMultiCellWidget( docButton, 0, 0, 6, 6 );
153
154 homeButton = new QToolButton( view,"homeButton"); 147 homeButton = new QToolButton( view,"homeButton");
155 homeButton->setPixmap( Resource::loadPixmap("home")); 148 homeButton->setUsesBigPixmap( useBigPix );
156 homeButton->setFixedSize( QSize( 20, 20 ) ); 149 homeButton->setPixmap( Opie::Core::OResource::loadPixmap( "home", Opie::Core::OResource::SmallIcon ) );
150 homeButton->setFixedSize( AppLnk::smallIconSize(), AppLnk::smallIconSize() );
157 connect(homeButton,SIGNAL(released()),this,SLOT(homeButtonPushed()) ); 151 connect(homeButton,SIGNAL(released()),this,SLOT(homeButtonPushed()) );
158 layout->addMultiCellWidget( homeButton, 0, 0, 3, 3); 152 layout->addMultiCellWidget( homeButton, 0, 0, 3, 3);
159 homeButton->hide(); 153 homeButton->hide();
160 154
161 TabWidget = new QTabWidget( view, "TabWidget" ); 155 TabWidget = new QTabWidget( view, "TabWidget" );
162 layout->addMultiCellWidget( TabWidget, 1, 1, 0, 4 ); 156 layout->addMultiCellWidget( TabWidget, 1, 1, 0, 4 );
163 157
164// TabWidget->setTabShape(QTabWidget::Triangular);
165
166 tab = new QWidget( TabWidget, "tab" ); 158 tab = new QWidget( TabWidget, "tab" );
167 tabLayout = new QGridLayout( tab ); 159 tabLayout = new QGridLayout( tab );
168 tabLayout->setSpacing( 2); 160 tabLayout->setSpacing( 2);
169 tabLayout->setMargin( 2); 161 tabLayout->setMargin( 2);
170 162
171 Local_View = new QListView( tab, "Local_View" ); 163 Local_View = new QListView( tab, "Local_View" );
172// Local_View->setResizePolicy( QListView::AutoOneFit ); 164// Local_View->setResizePolicy( QListView::AutoOneFit );
173 Local_View->addColumn( tr("File"),150); 165 Local_View->addColumn( tr("File"),150);
174 Local_View->addColumn( tr("Date"),-1); 166 Local_View->addColumn( tr("Date"),-1);
175 Local_View->setColumnAlignment(1,QListView::AlignRight); 167 Local_View->setColumnAlignment(1,QListView::AlignRight);
176 Local_View->addColumn( tr("Size"),-1); 168 Local_View->addColumn( tr("Size"),-1);
177 Local_View->setColumnAlignment(2,QListView::AlignRight); 169 Local_View->setColumnAlignment(2,QListView::AlignRight);
178 Local_View->setAllColumnsShowFocus(TRUE); 170 Local_View->setAllColumnsShowFocus(TRUE);
179 171
180 Local_View->setMultiSelection( TRUE); 172 Local_View->setMultiSelection( TRUE);
181 Local_View->setSelectionMode(QListView::Extended); 173 Local_View->setSelectionMode(QListView::Extended);
182 Local_View->setFocusPolicy(QWidget::ClickFocus); 174 Local_View->setFocusPolicy(QWidget::ClickFocus);
183 175
184 QPEApplication::setStylusOperation( Local_View->viewport(),QPEApplication::RightOnHold); 176 QPEApplication::setStylusOperation( Local_View->viewport(),QPEApplication::RightOnHold);
185 177
186 tabLayout->addWidget( Local_View, 0, 0 ); 178 tabLayout->addWidget( Local_View, 0, 0 );
187 179
188 connect( Local_View, SIGNAL( clicked(QListViewItem*)), 180 connect( Local_View, SIGNAL( clicked(QListViewItem*)),
189 this,SLOT( localListClicked(QListViewItem*)) ); 181 this,SLOT( localListClicked(QListViewItem*)) );
190// connect( Local_View, SIGNAL( doubleClicked(QListViewItem*)), 182// connect( Local_View, SIGNAL( doubleClicked(QListViewItem*)),
191// this,SLOT( localListClicked(QListViewItem*)) ); 183// this,SLOT( localListClicked(QListViewItem*)) );
192 connect( Local_View, SIGNAL( mouseButtonPressed(int,QListViewItem*,const QPoint&,int)), 184 connect( Local_View, SIGNAL( mouseButtonPressed(int,QListViewItem*,const QPoint&,int)),
193 this,SLOT( ListPressed(int,QListViewItem*,const QPoint&,int)) ); 185 this,SLOT( ListPressed(int,QListViewItem*,const QPoint&,int)) );
194 186
195 TabWidget->insertTab( tab, tr( "Local" ) ); 187 TabWidget->insertTab( tab, tr( "Local" ) );
196 188
197 tab_2 = new QWidget( TabWidget, "tab_2" ); 189 tab_2 = new QWidget( TabWidget, "tab_2" );
@@ -312,65 +304,65 @@ void OpieFtp::initializeGui() {
312 TabWidget->insertTab( tab_3, tr( "Config" ) ); 304 TabWidget->insertTab( tab_3, tr( "Config" ) );
313 305
314 connect(TabWidget,SIGNAL(currentChanged(QWidget*)), 306 connect(TabWidget,SIGNAL(currentChanged(QWidget*)),
315 this,SLOT(tabChanged(QWidget*))); 307 this,SLOT(tabChanged(QWidget*)));
316 308
317 currentDir.setFilter( QDir::Files | QDir::Dirs/* | QDir::Hidden*/ | QDir::All); 309 currentDir.setFilter( QDir::Files | QDir::Dirs/* | QDir::Hidden*/ | QDir::All);
318 currentDir.setPath( QDir::currentDirPath()); 310 currentDir.setPath( QDir::currentDirPath());
319// currentDir.setSorting(/* QDir::Size*/ /*| QDir::Reversed | */QDir::DirsFirst); 311// currentDir.setSorting(/* QDir::Size*/ /*| QDir::Reversed | */QDir::DirsFirst);
320 312
321 currentPathCombo = new QComboBox( FALSE, view, "currentPathCombo" ); 313 currentPathCombo = new QComboBox( FALSE, view, "currentPathCombo" );
322 layout->addMultiCellWidget( currentPathCombo, 3, 3, 0, 4); 314 layout->addMultiCellWidget( currentPathCombo, 3, 3, 0, 4);
323 315
324 currentPathCombo ->setFixedWidth(220); 316 currentPathCombo ->setFixedWidth(220);
325 currentPathCombo->setEditable(TRUE); 317 currentPathCombo->setEditable(TRUE);
326 currentPathCombo->lineEdit()->setText( currentDir.canonicalPath()); 318 currentPathCombo->lineEdit()->setText( currentDir.canonicalPath());
327 319
328 connect( currentPathCombo, SIGNAL( activated(const QString&) ), 320 connect( currentPathCombo, SIGNAL( activated(const QString&) ),
329 this, SLOT( currentPathComboActivated(const QString&) ) ); 321 this, SLOT( currentPathComboActivated(const QString&) ) );
330 322
331 connect( currentPathCombo->lineEdit(),SIGNAL(returnPressed()), 323 connect( currentPathCombo->lineEdit(),SIGNAL(returnPressed()),
332 this,SLOT(currentPathComboChanged())); 324 this,SLOT(currentPathComboChanged()));
333 ProgressBar = new QProgressBar( view, "ProgressBar" ); 325 ProgressBar = new QProgressBar( view, "ProgressBar" );
334 layout->addMultiCellWidget( ProgressBar, 4, 4, 0, 4); 326 layout->addMultiCellWidget( ProgressBar, 4, 4, 0, 4);
335 ProgressBar->setMaximumHeight(10); 327 ProgressBar->setMaximumHeight(10);
336 filterStr="*"; 328 filterStr="*";
337 b=FALSE; 329 b=FALSE;
338 populateLocalView(); 330 populateLocalView();
339 readConfig(); 331 readConfig();
340 332
341// ServerComboBox->setCurrentItem(currentServerConfig); 333// ServerComboBox->setCurrentItem(currentServerConfig);
342 334
343 TabWidget->setCurrentPage(2); 335 TabWidget->setCurrentPage(2);
344 qDebug("XXXXXXXXXXXX Constructor done"); 336 // qDebug("XXXXXXXXXXXX Constructor done");
345 337
346} 338}
347 339
348OpieFtp::~OpieFtp() 340OpieFtp::~OpieFtp()
349{ 341{
350} 342}
351 343
352void OpieFtp::cleanUp() 344void OpieFtp::cleanUp()
353{ 345{
354 if(conn) 346 if(conn)
355 FtpQuit(conn); 347 FtpQuit(conn);
356 QString sfile=QDir::homeDirPath(); 348 QString sfile=QDir::homeDirPath();
357 if(sfile.right(1) != "/") 349 if(sfile.right(1) != "/")
358 sfile+="/._temp"; 350 sfile+="/._temp";
359 else 351 else
360 sfile+="._temp"; 352 sfile+="._temp";
361 QFile file( sfile); 353 QFile file( sfile);
362 if(file.exists()) 354 if(file.exists())
363 file.remove(); 355 file.remove();
364 Config cfg("opieftp"); 356 Config cfg("opieftp");
365 cfg.setGroup("Server"); 357 cfg.setGroup("Server");
366 cfg.writeEntry("currentServer", currentServerConfig); 358 cfg.writeEntry("currentServer", currentServerConfig);
367 359
368 exit(0); 360 exit(0);
369} 361}
370 362
371void OpieFtp::tabChanged(QWidget *) 363void OpieFtp::tabChanged(QWidget *)
372{ 364{
373 if (TabWidget->currentPageIndex() == 0) { 365 if (TabWidget->currentPageIndex() == 0) {
374 currentPathCombo->lineEdit()->setText( currentDir.canonicalPath()); 366 currentPathCombo->lineEdit()->setText( currentDir.canonicalPath());
375 tabMenu->setItemChecked(tabMenu->idAt(0),TRUE); 367 tabMenu->setItemChecked(tabMenu->idAt(0),TRUE);
376 tabMenu->setItemChecked(tabMenu->idAt(1),FALSE); 368 tabMenu->setItemChecked(tabMenu->idAt(1),FALSE);
@@ -670,143 +662,142 @@ void OpieFtp::populateLocalView()
670 QString fileL, fileS, fileDate; 662 QString fileL, fileS, fileDate;
671 bool isDir=FALSE; 663 bool isDir=FALSE;
672 const QFileInfoList *list = currentDir.entryInfoList( /*QDir::All*/ /*, QDir::SortByMask*/); 664 const QFileInfoList *list = currentDir.entryInfoList( /*QDir::All*/ /*, QDir::SortByMask*/);
673 QFileInfoListIterator it(*list); 665 QFileInfoListIterator it(*list);
674 QFileInfo *fi; 666 QFileInfo *fi;
675 while ( (fi=it.current()) ) { 667 while ( (fi=it.current()) ) {
676 if (fi->isSymLink() ){ 668 if (fi->isSymLink() ){
677 QString symLink=fi->readLink(); 669 QString symLink=fi->readLink();
678// odebug << "Symlink detected "+symLink << oendl; 670// odebug << "Symlink detected "+symLink << oendl;
679 QFileInfo sym( symLink); 671 QFileInfo sym( symLink);
680 fileS.sprintf( "%10i", sym.size() ); 672 fileS.sprintf( "%10i", sym.size() );
681 fileL.sprintf( "%s -> %s", fi->fileName().data(),sym.absFilePath().data() ); 673 fileL.sprintf( "%s -> %s", fi->fileName().data(),sym.absFilePath().data() );
682 fileDate = sym.lastModified().toString(); 674 fileDate = sym.lastModified().toString();
683 } else { 675 } else {
684// odebug << "Not a dir: "+currentDir.canonicalPath()+fileL << oendl; 676// odebug << "Not a dir: "+currentDir.canonicalPath()+fileL << oendl;
685 fileS.sprintf( "%10i", fi->size() ); 677 fileS.sprintf( "%10i", fi->size() );
686 fileL.sprintf( "%s",fi->fileName().data() ); 678 fileL.sprintf( "%s",fi->fileName().data() );
687 fileDate= fi->lastModified().toString(); 679 fileDate= fi->lastModified().toString();
688 if( QDir(QDir::cleanDirPath(currentDir.canonicalPath()+"/"+fileL)).exists() ) { 680 if( QDir(QDir::cleanDirPath(currentDir.canonicalPath()+"/"+fileL)).exists() ) {
689 fileL+="/"; 681 fileL+="/";
690 isDir=TRUE; 682 isDir=TRUE;
691// odebug << fileL << oendl; 683// odebug << fileL << oendl;
692 } 684 }
693 } 685 }
694 686
695 687
696 if(fileL !="./" && fi->exists()) { 688 if(fileL !="./" && fi->exists()) {
697 item = new QListViewItem( Local_View,fileL, fileDate, fileS ); 689 item = new QListViewItem( Local_View,fileL, fileDate, fileS );
698 QPixmap pm; 690 QPixmap pm;
699 691
700 if(isDir || fileL.find("/",0,TRUE) != -1) { 692 if(isDir || fileL.find("/",0,TRUE) != -1) {
701 if( !QDir( fi->filePath() ).isReadable()) 693 if( !QDir( fi->filePath() ).isReadable())
702 pm = Resource::loadPixmap( "lockedfolder" ); 694 pm = Opie::Core::OResource::loadPixmap( "lockedfolder", Opie::Core::OResource::SmallIcon );
703 else 695 else
704 pm= Resource::loadPixmap( "folder" ); 696 pm = Opie::Core::OResource::loadPixmap( "folder", Opie::Core::OResource::SmallIcon );
705 item->setPixmap( 0,pm ); 697 item->setPixmap( 0,pm );
706 } else { 698 } else {
707 if( !fi->isReadable() ) 699 if( !fi->isReadable() )
708 pm = Resource::loadPixmap( "locked" ); 700 pm = Opie::Core::OResource::loadPixmap( "locked", Opie::Core::OResource::SmallIcon );
709 else { 701 else {
710 MimeType mt(fi->filePath()); 702 MimeType mt(fi->filePath());
711 pm=mt.pixmap(); //sets the correct pixmap for mimetype 703 pm=mt.pixmap(); //sets the correct pixmap for mimetype
712 if(pm.isNull()) 704 if(pm.isNull())
713 pm = unknownXpm; 705 pm = unknownXpm;
714 } 706 }
715 } 707 }
716 if( fileL.find("->",0,TRUE) != -1) { 708 if( fileL.find("->",0,TRUE) != -1) {
717 // overlay link image 709 // overlay link image
718 pm= Resource::loadPixmap( "folder" ); 710 pm = Opie::Core::OResource::loadPixmap( "folder", Opie::Core::OResource::SmallIcon );
719 QPixmap lnk = Resource::loadPixmap( "opie/symlink" ); 711 QPixmap lnk = Opie::Core::OResource::loadPixmap( "opie/symlink" );
720 QPainter painter( &pm ); 712 QPainter painter( &pm );
721 painter.drawPixmap( pm.width()-lnk.width(), pm.height()-lnk.height(), lnk ); 713 painter.drawPixmap( pm.width()-lnk.width(), pm.height()-lnk.height(), lnk );
722 pm.setMask( pm.createHeuristicMask( FALSE ) );
723 } 714 }
724 item->setPixmap( 0,pm); 715 item->setPixmap( 0,pm);
725 } 716 }
726 isDir=FALSE; 717 isDir=FALSE;
727 ++it; 718 ++it;
728 } 719 }
729 Local_View->setSorting( 3,FALSE); 720 Local_View->setSorting( 3,FALSE);
730 currentPathCombo->lineEdit()->setText( currentDir.canonicalPath() ); 721 currentPathCombo->lineEdit()->setText( currentDir.canonicalPath() );
731 fillCombo( (const QString &)currentDir.canonicalPath()); 722 fillCombo( (const QString &)currentDir.canonicalPath());
732} 723}
733 724
734bool OpieFtp::populateRemoteView( ) 725bool OpieFtp::populateRemoteView( )
735{ 726{
736// odebug << "populate remoteview" << oendl; 727// odebug << "populate remoteview" << oendl;
737 QString sfile=QDir::homeDirPath(); 728 QString sfile=QDir::homeDirPath();
738 if(sfile.right(1) != "/") 729 if(sfile.right(1) != "/")
739 sfile+="/._temp"; 730 sfile+="/._temp";
740 else 731 else
741 sfile+="._temp"; 732 sfile+="._temp";
742 QFile file( sfile); 733 QFile file( sfile);
743 Remote_View->clear(); 734 Remote_View->clear();
744 QString s, File_Name; 735 QString s, File_Name;
745 QListViewItem *itemDir=NULL, *itemFile=NULL; 736 QListViewItem *itemDir=NULL, *itemFile=NULL;
746 QRegExp monthRe(" [JFMASOND][eapuecoe][brynlgptvc] [ 0-9][0-9] [ 0-9][0-9][:0-9][0-9][0-9] "); 737 QRegExp monthRe(" [JFMASOND][eapuecoe][brynlgptvc] [ 0-9][0-9] [ 0-9][0-9][:0-9][0-9][0-9] ");
747 QString fileL, fileS, fileDate; 738 QString fileL, fileS, fileDate;
748 if ( file.open(IO_ReadOnly)) { 739 if ( file.open(IO_ReadOnly)) {
749 QTextStream t( &file ); // use a text stream 740 QTextStream t( &file ); // use a text stream
750 while ( !t.eof()) { 741 while ( !t.eof()) {
751 s = t.readLine(); 742 s = t.readLine();
752 743
753 if(s.find("total",0,TRUE) == 0) 744 if(s.find("total",0,TRUE) == 0)
754 continue; 745 continue;
755 746
756 int len, month = monthRe.match(s, 0, &len); 747 int len, month = monthRe.match(s, 0, &len);
757 fileDate = s.mid(month + 1, len - 2); // minus spaces 748 fileDate = s.mid(month + 1, len - 2); // minus spaces
758 fileL = s.right(s.length() - month - len); 749 fileL = s.right(s.length() - month - len);
759 if(s.left(1) == "d") 750 if(s.left(1) == "d")
760 fileL = fileL+"/"; 751 fileL = fileL+"/";
761 fileS = s.mid(month - 8, 8); // FIXME 752 fileS = s.mid(month - 8, 8); // FIXME
762 fileS = fileS.stripWhiteSpace(); 753 fileS = fileS.stripWhiteSpace();
763 754
764 if(s.left(1) == "d" || fileL.find("/",0,TRUE) != -1) { 755 if(s.left(1) == "d" || fileL.find("/",0,TRUE) != -1) {
765 QListViewItem * item = new QListViewItem( Remote_View, fileL, fileDate, fileS,"d"); 756 QListViewItem * item = new QListViewItem( Remote_View, fileL, fileDate, fileS,"d");
766 item->setPixmap( 0, Resource::loadPixmap( "folder" )); 757 item->setPixmap( 0, Opie::Core::OResource::loadPixmap( "folder", Opie::Core::OResource::SmallIcon ));
767// if(itemDir) 758// if(itemDir)
768 item->moveItem(itemDir); 759 item->moveItem(itemDir);
769 itemDir=item; 760 itemDir=item;
770 } else { 761 } else {
771 QListViewItem * item = new QListViewItem( Remote_View, fileL, fileDate, fileS,"f"); 762 QListViewItem * item = new QListViewItem( Remote_View, fileL, fileDate, fileS,"f");
772 item->setPixmap( 0, Resource::loadPixmap( "fileopen" )); 763 item->setPixmap( 0, Opie::Core::OResource::loadPixmap( "fileopen", Opie::Core::OResource::SmallIcon ));
773// if(itemFile) 764// if(itemFile)
774 item->moveItem(itemDir); 765 item->moveItem(itemDir);
775 item->moveItem(itemFile); 766 item->moveItem(itemFile);
776 itemFile=item; 767 itemFile=item;
777 } 768 }
778 } 769 }
779 QListViewItem * item1 = new QListViewItem( Remote_View, "../"); 770 QListViewItem * item1 = new QListViewItem( Remote_View, "../");
780 item1->setPixmap( 0, Resource::loadPixmap( "folder" )); 771 item1->setPixmap( 0, Opie::Core::OResource::loadPixmap( "folder", Opie::Core::OResource::SmallIcon ));
781 file.close(); 772 file.close();
782 if( file.exists()) 773 if( file.exists())
783 file. remove(); 774 file. remove();
784 } 775 }
785// odebug << "temp file not opened successfully "+sfile << oendl; 776// odebug << "temp file not opened successfully "+sfile << oendl;
786 Remote_View->setSorting( 4,TRUE); 777 Remote_View->setSorting( 4,TRUE);
787 return true; 778 return true;
788} 779}
789 780
790void OpieFtp::remoteListClicked(QListViewItem *selectedItem) 781void OpieFtp::remoteListClicked(QListViewItem *selectedItem)
791{ 782{
792 if( selectedItem) { 783 if( selectedItem) {
793 // if(selectedItem!= NULL) { 784 // if(selectedItem!= NULL) {
794// QCopEnvelope ( "QPE/System", "busy()" ); 785// QCopEnvelope ( "QPE/System", "busy()" );
795 QString oldRemoteCurrentDir = currentRemoteDir; 786 QString oldRemoteCurrentDir = currentRemoteDir;
796 QString strItem=selectedItem->text(0); 787 QString strItem=selectedItem->text(0);
797 strItem=strItem.simplifyWhiteSpace(); 788 strItem=strItem.simplifyWhiteSpace();
798 if(strItem == "../") { // the user wants to go ^ 789 if(strItem == "../") { // the user wants to go ^
799 if( FtpCDUp( conn) == 0) { 790 if( FtpCDUp( conn) == 0) {
800 QString msg; 791 QString msg;
801 msg.sprintf(tr("Unable to cd up\n")+"%s",FtpLastResponse(conn)); 792 msg.sprintf(tr("Unable to cd up\n")+"%s",FtpLastResponse(conn));
802 msg.replace(QRegExp(":"),"\n"); 793 msg.replace(QRegExp(":"),"\n");
803 QMessageBox::message(tr("Note"),msg); 794 QMessageBox::message(tr("Note"),msg);
804// odebug << msg << oendl; 795// odebug << msg << oendl;
805 } 796 }
806 char path[256]; 797 char path[256];
807 if( FtpPwd( path,sizeof(path),conn) == 0) { //this is easier than fudging the string 798 if( FtpPwd( path,sizeof(path),conn) == 0) { //this is easier than fudging the string
808 QString msg; 799 QString msg;
809 msg.sprintf(tr("Unable to get working dir\n")+"%s",FtpLastResponse(conn)); 800 msg.sprintf(tr("Unable to get working dir\n")+"%s",FtpLastResponse(conn));
810 msg.replace(QRegExp(":"),"\n"); 801 msg.replace(QRegExp(":"),"\n");
811 QMessageBox::message(tr("Note"),msg); 802 QMessageBox::message(tr("Note"),msg);
812// odebug << msg << oendl; 803// odebug << msg << oendl;