summaryrefslogtreecommitdiff
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--core/apps/textedit/fileBrowser.cpp14
-rw-r--r--noncore/net/opieftp/opieftp.cpp109
-rw-r--r--noncore/net/opieftp/opieftp.h12
3 files changed, 109 insertions, 26 deletions
diff --git a/core/apps/textedit/fileBrowser.cpp b/core/apps/textedit/fileBrowser.cpp
index 41e800c..acd50c2 100644
--- a/core/apps/textedit/fileBrowser.cpp
+++ b/core/apps/textedit/fileBrowser.cpp
@@ -8,388 +8,396 @@
8** packaging of this file. 8** packaging of this file.
9** 9**
10** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE 10** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
11** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 11** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
12** 12**
13****************************************************************************/ 13****************************************************************************/
14#include "fileBrowser.h" 14#include "fileBrowser.h"
15#include "inputDialog.h" 15#include "inputDialog.h"
16 16
17#include <qpe/config.h> 17#include <qpe/config.h>
18#include <qpe/resource.h> 18#include <qpe/resource.h>
19#include <qpe/fileselector.h> 19#include <qpe/fileselector.h>
20#include <qpe/qpeapplication.h> 20#include <qpe/qpeapplication.h>
21#include <qpe/menubutton.h> 21#include <qpe/menubutton.h>
22 22
23#include <qdict.h> 23#include <qdict.h>
24#include <qwidgetstack.h> 24#include <qwidgetstack.h>
25#include <qlistview.h> 25#include <qlistview.h>
26#include <qcombo.h> 26#include <qcombo.h>
27#include <qpushbutton.h> 27#include <qpushbutton.h>
28#include <qfile.h> 28#include <qfile.h>
29#include <qmessagebox.h> 29#include <qmessagebox.h>
30#include <qlayout.h> 30#include <qlayout.h>
31#include <unistd.h> 31#include <unistd.h>
32#include <qpopupmenu.h> 32#include <qpopupmenu.h>
33#include <qlineedit.h> 33#include <qlineedit.h>
34#include <qstringlist.h> 34#include <qstringlist.h>
35 35
36#include <unistd.h> 36#include <unistd.h>
37#include <stdlib.h> 37#include <stdlib.h>
38 38
39static int u_id = 1; 39static int u_id = 1;
40static int get_unique_id() 40static int get_unique_id()
41{ 41{
42 return u_id++; 42 return u_id++;
43} 43}
44 44
45fileBrowser::fileBrowser( QWidget* parent, const char* name, bool modal, WFlags fl , const QString filter ) 45fileBrowser::fileBrowser( QWidget* parent, const char* name, bool modal, WFlags fl , const QString filter )
46 : QDialog( parent, name, modal, fl ) 46 : QDialog( parent, name, modal, fl )
47{ 47{
48 if ( !name ) 48 if ( !name )
49 setName( "fileBrowser" ); 49 setName( "fileBrowser" );
50 setCaption(tr( name ) ); 50 setCaption(tr( name ) );
51 filterStr=filter; 51 filterStr=filter;
52 52
53// channel = new QCopChannel( "QPE/fileDialog", this ); 53// channel = new QCopChannel( "QPE/fileDialog", this );
54// connect( channel, SIGNAL(received(const QCString&, const QByteArray&)), 54// connect( channel, SIGNAL(received(const QCString&, const QByteArray&)),
55// this, SLOT(receive(const QCString&, const QByteArray&)) ); 55// this, SLOT(receive(const QCString&, const QByteArray&)) );
56 56
57 QGridLayout *layout = new QGridLayout( this ); 57 QGridLayout *layout = new QGridLayout( this );
58 layout->setSpacing( 4 ); 58 layout->setSpacing( 4 );
59 layout->setMargin( 4 ); 59 layout->setMargin( 4 );
60 60
61 dirPathCombo = new QComboBox( FALSE, this, "dorPathCombo" ); 61 dirPathCombo = new QComboBox( FALSE, this, "dorPathCombo" );
62 dirPathCombo->setEditable(TRUE); 62 dirPathCombo->setEditable(TRUE);
63 63
64 connect( dirPathCombo, SIGNAL( activated( const QString & ) ), 64 connect( dirPathCombo, SIGNAL( activated( const QString & ) ),
65 this, SLOT( dirPathComboActivated( const QString & ) ) ); 65 this, SLOT( dirPathComboActivated( const QString & ) ) );
66 66
67 connect( dirPathCombo->lineEdit(), SIGNAL( returnPressed( ) ), 67 connect( dirPathCombo->lineEdit(), SIGNAL( returnPressed( ) ),
68 this, SLOT( dirPathEditPressed( ) ) ); 68 this, SLOT( dirPathEditPressed( ) ) );
69 69
70 dirPathStringList << "/"; 70 dirPathStringList << "/";
71// we can get the storage here 71// we can get the storage here
72 72
73 layout->addMultiCellWidget( dirPathCombo, 0, 0, 0, 4 ); 73 layout->addMultiCellWidget( dirPathCombo, 0, 0, 0, 4 );
74 74
75 cdUpButton = new QPushButton(Resource::loadIconSet("up"),"",this,"cdUpButton"); 75 cdUpButton = new QPushButton(Resource::loadIconSet("up"),"",this,"cdUpButton");
76 cdUpButton ->setMinimumSize( QSize( 20, 20 ) ); 76 cdUpButton ->setMinimumSize( QSize( 20, 20 ) );
77 cdUpButton ->setMaximumSize( QSize( 20, 20 ) ); 77 cdUpButton ->setMaximumSize( QSize( 20, 20 ) );
78 connect( cdUpButton ,SIGNAL(released()),this,SLOT( upDir()) ); 78 connect( cdUpButton ,SIGNAL(released()),this,SLOT( upDir()) );
79 cdUpButton ->setFlat(TRUE); 79 cdUpButton ->setFlat(TRUE);
80 layout->addMultiCellWidget( cdUpButton, 0, 0, 5, 5 ); 80 layout->addMultiCellWidget( cdUpButton, 0, 0, 5, 5 );
81 81
82 82
83 docButton = new QPushButton(Resource::loadIconSet("DocsIcon"),"",this,"docsButton"); 83 docButton = new QPushButton(Resource::loadIconSet("DocsIcon"),"",this,"docsButton");
84 docButton->setMinimumSize( QSize( 20, 20 ) ); 84 docButton->setMinimumSize( QSize( 20, 20 ) );
85 docButton->setMaximumSize( QSize( 20, 20 ) ); 85 docButton->setMaximumSize( QSize( 20, 20 ) );
86 connect( docButton,SIGNAL(released()),this,SLOT( docButtonPushed()) ); 86 connect( docButton,SIGNAL(released()),this,SLOT( docButtonPushed()) );
87 docButton->setFlat(TRUE); 87 docButton->setFlat(TRUE);
88 layout->addMultiCellWidget( docButton, 0, 0, 6, 6 ); 88 layout->addMultiCellWidget( docButton, 0, 0, 6, 6 );
89 89
90 homeButton = new QPushButton( Resource::loadIconSet("home"),"",this,"homeButton"); 90 homeButton = new QPushButton( Resource::loadIconSet("home"),"",this,"homeButton");
91 homeButton->setMinimumSize( QSize( 20, 20 ) ); 91 homeButton->setMinimumSize( QSize( 20, 20 ) );
92 homeButton->setMaximumSize( QSize( 20, 20 ) ); 92 homeButton->setMaximumSize( QSize( 20, 20 ) );
93 connect(homeButton,SIGNAL(released()),this,SLOT(homeButtonPushed()) ); 93 connect(homeButton,SIGNAL(released()),this,SLOT(homeButtonPushed()) );
94 homeButton->setFlat(TRUE); 94 homeButton->setFlat(TRUE);
95 layout->addMultiCellWidget( homeButton, 0, 0, 7, 7 ); 95 layout->addMultiCellWidget( homeButton, 0, 0, 7, 7 );
96 96
97 FileStack = new QWidgetStack( this ); 97 FileStack = new QWidgetStack( this );
98 98
99 99
100 ListView = new QListView( this, "ListView" ); 100 ListView = new QListView( this, "ListView" );
101// ListView->setMinimumSize( QSize( 100, 25 ) ); 101// ListView->setMinimumSize( QSize( 100, 25 ) );
102 ListView->addColumn( tr( "Name" ) ); 102 ListView->addColumn( tr( "Name" ) );
103 ListView->setColumnWidth(0,120); 103 ListView->setColumnWidth(0,120);
104 ListView->setSorting( 2, FALSE); 104 ListView->setSorting( 2, FALSE);
105 ListView->addColumn( tr( "Size" ) ); 105 ListView->addColumn( tr( "Size" ) );
106 ListView->setColumnWidth(1,-1); 106 ListView->setColumnWidth(1,-1);
107 ListView->addColumn( "Date",-1); 107 ListView->addColumn( "Date",-1);
108 108
109 ListView->setColumnWidthMode(0,QListView::Manual); 109 ListView->setColumnWidthMode(0,QListView::Manual);
110 ListView->setColumnAlignment(1,QListView::AlignRight); 110 ListView->setColumnAlignment(1,QListView::AlignRight);
111 ListView->setColumnAlignment(2,QListView::AlignRight); 111 ListView->setColumnAlignment(2,QListView::AlignRight);
112 ListView->setAllColumnsShowFocus( TRUE ); 112 ListView->setAllColumnsShowFocus( TRUE );
113 113
114 QPEApplication::setStylusOperation( ListView->viewport(),QPEApplication::RightOnHold); 114 QPEApplication::setStylusOperation( ListView->viewport(),QPEApplication::RightOnHold);
115 connect( ListView, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int)), 115 connect( ListView, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int)),
116 this,SLOT( ListPressed(int, QListViewItem *, const QPoint&, int)) ); 116 this,SLOT( ListPressed(int, QListViewItem *, const QPoint&, int)) );
117 117
118 connect( ListView, SIGNAL( clicked( QListViewItem*)), SLOT(listClicked(QListViewItem *)) ); 118 connect( ListView, SIGNAL( clicked( QListViewItem*)), SLOT(listClicked(QListViewItem *)) );
119 119
120 FileStack->addWidget( ListView, get_unique_id() ); 120 FileStack->addWidget( ListView, get_unique_id() );
121 mimeType="text/*"; 121 mimeType="text/*";
122 fileSelector = new FileSelector( mimeType, FileStack, "fileselector" , FALSE, FALSE); //buggy 122 fileSelector = new FileSelector( mimeType, FileStack, "fileselector" , FALSE, FALSE); //buggy
123// connect( fileSelector, SIGNAL( closeMe() ), this, SLOT( showEditTools() ) ); 123// connect( fileSelector, SIGNAL( closeMe() ), this, SLOT( showEditTools() ) );
124// connect( fileSelector, SIGNAL( newSelected( const DocLnk &) ), this, SLOT( newFile( const DocLnk & ) ) ); 124// connect( fileSelector, SIGNAL( newSelected( const DocLnk &) ), this, SLOT( newFile( const DocLnk & ) ) );
125 connect( fileSelector, SIGNAL( fileSelected( const DocLnk &) ), this, SLOT( docOpen( const DocLnk & ) ) ); 125 connect( fileSelector, SIGNAL( fileSelected( const DocLnk &) ), this, SLOT( docOpen( const DocLnk & ) ) );
126 layout->addMultiCellWidget( FileStack, 1, 1, 0, 7 ); 126 layout->addMultiCellWidget( FileStack, 1, 1, 0, 7 );
127 127
128 SelectionCombo = new QComboBox( FALSE, this, "SelectionCombo" ); 128 SelectionCombo = new QComboBox( FALSE, this, "SelectionCombo" );
129 SelectionCombo->insertItem( tr( "Documents" ) ); 129 SelectionCombo->insertItem( tr( "Documents" ) );
130 SelectionCombo->insertItem( tr( "All files" ) ); 130 SelectionCombo->insertItem( tr( "All files" ) );
131 SelectionCombo->insertItem( tr( "Hidden files" ) ); 131 SelectionCombo->insertItem( tr( "Hidden files" ) );
132// SelectionCombo->setMaximumWidth(120); 132// SelectionCombo->setMaximumWidth(120);
133 layout->addMultiCellWidget( SelectionCombo, 2, 2, 0, 3 ); 133 layout->addMultiCellWidget( SelectionCombo, 2, 2, 0, 3 );
134 134
135 connect( SelectionCombo, SIGNAL( activated( const QString & ) ), 135 connect( SelectionCombo, SIGNAL( activated( const QString & ) ),
136 this, SLOT( selectionChanged( const QString & ) ) ); 136 this, SLOT( selectionChanged( const QString & ) ) );
137 137
138 typemb = new MenuButton(this); 138 typemb = new MenuButton(this);
139 typemb->setLabel(tr("Type: %1")); 139 typemb->setLabel(tr("Type: %1"));
140 typemb->setMinimumWidth(110); 140 typemb->setMinimumWidth(110);
141 typemb->setFixedHeight(22); 141 typemb->setFixedHeight(22);
142 layout->addMultiCellWidget( typemb, 2, 2, 4, 7 ); 142 layout->addMultiCellWidget( typemb, 2, 2, 4, 7 );
143 updateMimeTypeMenu() ; 143 updateMimeTypeMenu() ;
144 144
145 currentDir.setPath(QDir::currentDirPath()); 145 currentDir.setPath(QDir::currentDirPath());
146 currentDir.setFilter( QDir::Files | QDir::Dirs/* | QDir::Hidden */| QDir::All); 146 currentDir.setFilter( QDir::Files | QDir::Dirs/* | QDir::Hidden */| QDir::All);
147 147
148 populateList(); 148 populateList();
149 move(0,15); 149 move(0,15);
150} 150}
151 151
152fileBrowser::~fileBrowser() 152fileBrowser::~fileBrowser()
153{ 153{
154} 154}
155 155
156void fileBrowser::setFileView( int selection ) 156void fileBrowser::setFileView( int selection )
157{ 157{
158 SelectionCombo->setCurrentItem( selection ); 158 SelectionCombo->setCurrentItem( selection );
159 selectionChanged( SelectionCombo->currentText() ); 159 selectionChanged( SelectionCombo->currentText() );
160} 160}
161 161
162void fileBrowser::populateList() 162void fileBrowser::populateList()
163{ 163{
164 ListView->clear(); 164 ListView->clear();
165 bool isDir=FALSE; 165 bool isDir=FALSE;
166//qDebug(currentDir.canonicalPath()); 166//qDebug(currentDir.canonicalPath());
167 currentDir.setSorting(/* QDir::Size*/ /*| QDir::Reversed | */QDir::DirsFirst); 167 currentDir.setSorting(/* QDir::Size*/ /*| QDir::Reversed | */QDir::DirsFirst);
168 currentDir.setMatchAllDirs(TRUE); 168 currentDir.setMatchAllDirs(TRUE);
169 169
170 currentDir.setNameFilter(filterStr); 170 currentDir.setNameFilter(filterStr);
171// currentDir.setNameFilter("*.txt;*.etx"); 171// currentDir.setNameFilter("*.txt;*.etx");
172 QString fileL, fileS, fileDate; 172 QString fileL, fileS, fileDate;
173 const QFileInfoList *list = currentDir.entryInfoList( /*QDir::All*/ /*, QDir::SortByMask*/); 173 const QFileInfoList *list = currentDir.entryInfoList( /*QDir::All*/ /*, QDir::SortByMask*/);
174 QFileInfoListIterator it(*list); 174 QFileInfoListIterator it(*list);
175 QFileInfo *fi; 175 QFileInfo *fi;
176 while ( (fi=it.current()) ) { 176 while ( (fi=it.current()) ) {
177 177
178 if (fi->isSymLink() ){ 178 if (fi->isSymLink() ){
179 QString symLink=fi->readLink(); 179 QString symLink=fi->readLink();
180// qDebug("Symlink detected "+symLink); 180// qDebug("Symlink detected "+symLink);
181 QFileInfo sym( symLink); 181 QFileInfo sym( symLink);
182 fileS.sprintf( "%10li", sym.size() ); 182 fileS.sprintf( "%10li", sym.size() );
183 fileL.sprintf( "%s -> %s", sym.fileName().data(),sym.absFilePath().data() ); 183 fileL.sprintf( "%s -> %s", sym.fileName().data(),sym.absFilePath().data() );
184 fileDate = sym.lastModified().toString(); 184 fileDate = sym.lastModified().toString();
185 } else { 185 } else {
186// qDebug("Not a dir: "+currentDir.canonicalPath()+fileL); 186// qDebug("Not a dir: "+currentDir.canonicalPath()+fileL);
187 fileS.sprintf( "%10li", fi->size() ); 187 fileS.sprintf( "%10li", fi->size() );
188 fileL.sprintf( "%s",fi->fileName().data() ); 188 fileL.sprintf( "%s",fi->fileName().data() );
189 fileDate= fi->lastModified().toString(); 189 fileDate= fi->lastModified().toString();
190 if( QDir(QDir::cleanDirPath(currentDir.canonicalPath()+"/"+fileL)).exists() ) { 190 if( QDir(QDir::cleanDirPath(currentDir.canonicalPath()+"/"+fileL)).exists() ) {
191 fileL+="/"; 191 fileL+="/";
192 isDir=TRUE; 192 isDir=TRUE;
193// qDebug( fileL); 193// qDebug( fileL);
194 } 194 }
195 } 195 }
196 if(fileL !="./") { 196 if(fileL !="./") {
197 item= new QListViewItem( ListView,fileL,fileS , fileDate); 197 item= new QListViewItem( ListView,fileL,fileS , fileDate);
198 QPixmap pm; 198 QPixmap pm;
199 pm= Resource::loadPixmap( "folder" ); 199 pm= Resource::loadPixmap( "folder" );
200 if(isDir || fileL.find("/",0,TRUE) != -1) 200
201 if(isDir || fileL.find("/",0,TRUE) != -1) {
202 if( !QDir( fi->filePath() ).isReadable())
203 pm = Resource::loadPixmap( "lockedfolder" );
201 item->setPixmap( 0,pm ); 204 item->setPixmap( 0,pm );
202 else 205 } else {
203 item->setPixmap( 0, Resource::loadPixmap( "fileopen" )); 206 if( !fi->isReadable() )
207 pm = Resource::loadPixmap( "locked" );
208 else
209 pm = Resource::loadPixmap( "fileopen" );
210 item->setPixmap( 0,pm);
211 }
204 if( fileL.find("->",0,TRUE) != -1) { 212 if( fileL.find("->",0,TRUE) != -1) {
205 // overlay link image 213 // overlay link image
206 QPixmap lnk = Resource::loadPixmap( "symlink" ); 214 QPixmap lnk = Resource::loadPixmap( "symlink" );
207 QPainter painter( &pm ); 215 QPainter painter( &pm );
208 painter.drawPixmap( pm.width()-lnk.width(), pm.height()-lnk.height(), lnk ); 216 painter.drawPixmap( pm.width()-lnk.width(), pm.height()-lnk.height(), lnk );
209 pm.setMask( pm.createHeuristicMask( FALSE ) ); 217 pm.setMask( pm.createHeuristicMask( FALSE ) );
210 item->setPixmap( 0, pm); 218 item->setPixmap( 0, pm);
211 } 219 }
212 } 220 }
213 isDir=FALSE; 221 isDir=FALSE;
214 ++it; 222 ++it;
215 } 223 }
216 ListView->setSorting( 3, FALSE); 224 ListView->setSorting( 3, FALSE);
217 QString currentPath = currentDir.canonicalPath(); 225 QString currentPath = currentDir.canonicalPath();
218 226
219 fillCombo( (const QString &)currentPath); 227 fillCombo( (const QString &)currentPath);
220// dirPathCombo->lineEdit()->setText(currentPath); 228// dirPathCombo->lineEdit()->setText(currentPath);
221 229
222// if( dirPathStringList.grep(currentPath,TRUE).isEmpty() ) { 230// if( dirPathStringList.grep(currentPath,TRUE).isEmpty() ) {
223// dirPathCombo->clear(); 231// dirPathCombo->clear();
224// dirPathStringList.prepend(currentPath ); 232// dirPathStringList.prepend(currentPath );
225// dirPathCombo->insertStringList( dirPathStringList,-1); 233// dirPathCombo->insertStringList( dirPathStringList,-1);
226// } 234// }
227} 235}
228 236
229void fileBrowser::upDir() 237void fileBrowser::upDir()
230{ 238{
231 QString current = currentDir.canonicalPath(); 239 QString current = currentDir.canonicalPath();
232 QDir dir(current); 240 QDir dir(current);
233 dir.cdUp(); 241 dir.cdUp();
234 current = dir.canonicalPath(); 242 current = dir.canonicalPath();
235 chdir( current.latin1() ); 243 chdir( current.latin1() );
236 currentDir.cd( current, TRUE); 244 currentDir.cd( current, TRUE);
237 populateList(); 245 populateList();
238 update(); 246 update();
239} 247}
240 248
241// you may want to switch these 2 functions. I like single clicks 249// you may want to switch these 2 functions. I like single clicks
242void fileBrowser::listClicked(QListViewItem *selectedItem) 250void fileBrowser::listClicked(QListViewItem *selectedItem)
243{ 251{
244 QString strItem=selectedItem->text(0); 252 QString strItem=selectedItem->text(0);
245 QString strSize=selectedItem->text(1); 253 QString strSize=selectedItem->text(1);
246// qDebug("strItem is "+strItem); 254// qDebug("strItem is "+strItem);
247 strSize.stripWhiteSpace(); 255 strSize.stripWhiteSpace();
248// qDebug(strSize); 256// qDebug(strSize);
249 257
250 if(strItem.find("@",0,TRUE) !=-1 || strItem.find("->",0,TRUE) !=-1 ) { //if symlink 258 if(strItem.find("@",0,TRUE) !=-1 || strItem.find("->",0,TRUE) !=-1 ) { //if symlink
251 // is symlink 259 // is symlink
252 QString strItem2=strItem.right( (strItem.length()-strItem.find("->",0,TRUE)) -4); 260 QString strItem2=strItem.right( (strItem.length()-strItem.find("->",0,TRUE)) -4);
253// qDebug("strItem symlink is "+strItem2); 261// qDebug("strItem symlink is "+strItem2);
254 if(QDir(strItem2).exists() ) { 262 if(QDir(strItem2).exists() ) {
255 currentDir.cd(strItem2, TRUE); 263 currentDir.cd(strItem2, TRUE);
256 populateList(); 264 populateList();
257 } 265 }
258 } else { // not a symlink 266 } else { // not a symlink
259 if(strItem.find(". .",0,TRUE) && strItem.find("/",0,TRUE)!=-1 ) { 267 if(strItem.find(". .",0,TRUE) && strItem.find("/",0,TRUE)!=-1 ) {
260 if(QDir(QDir::cleanDirPath(currentDir.canonicalPath()+"/"+strItem)).exists() ) { 268 if(QDir(QDir::cleanDirPath(currentDir.canonicalPath()+"/"+strItem)).exists() ) {
261 strItem=QDir::cleanDirPath(currentDir.canonicalPath()+"/"+strItem); 269 strItem=QDir::cleanDirPath(currentDir.canonicalPath()+"/"+strItem);
262 currentDir.cd(strItem,FALSE); 270 currentDir.cd(strItem,FALSE);
263// qDebug("Path is "+strItem); 271// qDebug("Path is "+strItem);
264 populateList(); 272 populateList();
265 } else { 273 } else {
266 currentDir.cdUp(); 274 currentDir.cdUp();
267 populateList(); 275 populateList();
268 } 276 }
269 if(QDir(strItem).exists()){ 277 if(QDir(strItem).exists()){
270 currentDir.cd(strItem, TRUE); 278 currentDir.cd(strItem, TRUE);
271 populateList(); 279 populateList();
272 } 280 }
273 } else { 281 } else {
274 strItem=QDir::cleanDirPath(currentDir.canonicalPath()+"/"+strItem); 282 strItem=QDir::cleanDirPath(currentDir.canonicalPath()+"/"+strItem);
275 if( QFile::exists(strItem ) ) { 283 if( QFile::exists(strItem ) ) {
276//currentDir.canonicalPath() 284//currentDir.canonicalPath()
277 qDebug("We found our files!!"+strItem); 285 qDebug("We found our files!!"+strItem);
278 OnOK(); 286 OnOK();
279 } 287 }
280 } //end not symlink 288 } //end not symlink
281 chdir(strItem.latin1()); 289 chdir(strItem.latin1());
282 } 290 }
283} 291}
284 292
285void fileBrowser::OnOK() 293void fileBrowser::OnOK()
286{ 294{
287 QListViewItemIterator it1( ListView); 295 QListViewItemIterator it1( ListView);
288 for ( ; it1.current(); ++it1 ) { 296 for ( ; it1.current(); ++it1 ) {
289 if ( it1.current()->isSelected() ) { 297 if ( it1.current()->isSelected() ) {
290 selectedFileName=QDir::cleanDirPath(currentDir.canonicalPath()+"/"+it1.current()->text(0)); 298 selectedFileName=QDir::cleanDirPath(currentDir.canonicalPath()+"/"+it1.current()->text(0));
291 qDebug("selected filename is "+selectedFileName); 299 qDebug("selected filename is "+selectedFileName);
292 fileList.append( selectedFileName ); 300 fileList.append( selectedFileName );
293 } 301 }
294 } 302 }
295 accept(); 303 accept();
296} 304}
297 305
298void fileBrowser::homeButtonPushed() { 306void fileBrowser::homeButtonPushed() {
299 QString current = QDir::homeDirPath(); 307 QString current = QDir::homeDirPath();
300 chdir( current.latin1() ); 308 chdir( current.latin1() );
301 currentDir.cd( current, TRUE); 309 currentDir.cd( current, TRUE);
302 populateList(); 310 populateList();
303 update(); 311 update();
304} 312}
305 313
306void fileBrowser::docButtonPushed() { 314void fileBrowser::docButtonPushed() {
307 QString current = QPEApplication::documentDir(); 315 QString current = QPEApplication::documentDir();
308 chdir( current.latin1() ); 316 chdir( current.latin1() );
309 currentDir.cd( current, TRUE); 317 currentDir.cd( current, TRUE);
310 populateList(); 318 populateList();
311 update(); 319 update();
312 320
313} 321}
314 322
315void fileBrowser::selectionChanged( const QString &select ) 323void fileBrowser::selectionChanged( const QString &select )
316{ 324{
317 if ( select == "Documents") { 325 if ( select == "Documents") {
318 FileStack->raiseWidget( fileSelector ); 326 FileStack->raiseWidget( fileSelector );
319 dirPathCombo->hide(); 327 dirPathCombo->hide();
320 cdUpButton->hide(); 328 cdUpButton->hide();
321 docButton->hide(); 329 docButton->hide();
322 homeButton->hide(); 330 homeButton->hide();
323 } else { 331 } else {
324 if ( select == "All files" ) 332 if ( select == "All files" )
325 currentDir.setFilter( QDir::Files | QDir::Dirs | QDir::All); 333 currentDir.setFilter( QDir::Files | QDir::Dirs | QDir::All);
326 else 334 else
327 currentDir.setFilter( QDir::Files | QDir::Dirs | QDir::Hidden | QDir::All); 335 currentDir.setFilter( QDir::Files | QDir::Dirs | QDir::Hidden | QDir::All);
328 336
329 populateList(); 337 populateList();
330 update(); 338 update();
331 dirPathCombo->show(); 339 dirPathCombo->show();
332 cdUpButton->show(); 340 cdUpButton->show();
333 docButton->show(); 341 docButton->show();
334 homeButton->show(); 342 homeButton->show();
335 FileStack->raiseWidget( ListView ); 343 FileStack->raiseWidget( ListView );
336 } 344 }
337} 345}
338 346
339void fileBrowser::docOpen( const DocLnk &doc ) 347void fileBrowser::docOpen( const DocLnk &doc )
340{ 348{
341 fileList.append( doc.file().latin1() ); 349 fileList.append( doc.file().latin1() );
342 accept(); 350 accept();
343} 351}
344 352
345void fileBrowser::ListPressed( int mouse, QListViewItem *item, const QPoint &point, int i) 353void fileBrowser::ListPressed( int mouse, QListViewItem *item, const QPoint &point, int i)
346{ 354{
347 switch (mouse) { 355 switch (mouse) {
348 case 1: 356 case 1:
349 break; 357 break;
350 case 2: 358 case 2:
351 showListMenu(item); 359 showListMenu(item);
352 break; 360 break;
353 }; 361 };
354} 362}
355 363
356void fileBrowser::showListMenu(QListViewItem *item) { 364void fileBrowser::showListMenu(QListViewItem *item) {
357 365
358 QPopupMenu m;// = new QPopupMenu( Local_View ); 366 QPopupMenu m;// = new QPopupMenu( Local_View );
359 if( item->text(0).find("/",0,TRUE)) 367 if( item->text(0).find("/",0,TRUE))
360 m.insertItem( tr( "Change Directory" ), this, SLOT( doCd() )); 368 m.insertItem( tr( "Change Directory" ), this, SLOT( doCd() ));
361 else 369 else
362 m.insertItem( tr( "Make Directory" ), this, SLOT( makDir() )); 370 m.insertItem( tr( "Make Directory" ), this, SLOT( makDir() ));
363 m.insertItem( tr( "Rescan" ), this, SLOT( populateList()() )); 371 m.insertItem( tr( "Rescan" ), this, SLOT( populateList()() ));
364 m.insertItem( tr( "Rename" ), this, SLOT( localRename() )); 372 m.insertItem( tr( "Rename" ), this, SLOT( localRename() ));
365 m.insertSeparator(); 373 m.insertSeparator();
366 m.insertItem( tr( "Delete" ), this, SLOT( localDelete() )); 374 m.insertItem( tr( "Delete" ), this, SLOT( localDelete() ));
367 m.exec( QCursor::pos() ); 375 m.exec( QCursor::pos() );
368 376
369} 377}
370 378
371void fileBrowser::doCd() { 379void fileBrowser::doCd() {
372 listClicked( ListView->currentItem()); 380 listClicked( ListView->currentItem());
373} 381}
374 382
375void fileBrowser::makDir() { 383void fileBrowser::makDir() {
376 InputDialog *fileDlg; 384 InputDialog *fileDlg;
377 fileDlg = new InputDialog(this,"Make Directory",TRUE, 0); 385 fileDlg = new InputDialog(this,"Make Directory",TRUE, 0);
378 fileDlg->exec(); 386 fileDlg->exec();
379 if( fileDlg->result() == 1 ) { 387 if( fileDlg->result() == 1 ) {
380 QString filename = fileDlg->LineEdit1->text(); 388 QString filename = fileDlg->LineEdit1->text();
381 currentDir.mkdir( currentDir.canonicalPath()+"/"+filename); 389 currentDir.mkdir( currentDir.canonicalPath()+"/"+filename);
382 } 390 }
383 populateList(); 391 populateList();
384} 392}
385 393
386void fileBrowser::localRename() { 394void fileBrowser::localRename() {
387 QString curFile = ListView->currentItem()->text(0); 395 QString curFile = ListView->currentItem()->text(0);
388 InputDialog *fileDlg; 396 InputDialog *fileDlg;
389 fileDlg = new InputDialog(this,"Rename",TRUE, 0); 397 fileDlg = new InputDialog(this,"Rename",TRUE, 0);
390 fileDlg->inputText = curFile; 398 fileDlg->inputText = curFile;
391 fileDlg->exec(); 399 fileDlg->exec();
392 if( fileDlg->result() == 1 ) { 400 if( fileDlg->result() == 1 ) {
393 QString oldname = currentDir.canonicalPath() + "/" + curFile; 401 QString oldname = currentDir.canonicalPath() + "/" + curFile;
394 QString newName = currentDir.canonicalPath() + "/" + fileDlg->LineEdit1->text();//+".playlist"; 402 QString newName = currentDir.canonicalPath() + "/" + fileDlg->LineEdit1->text();//+".playlist";
395 if( rename(oldname.latin1(), newName.latin1())== -1) 403 if( rename(oldname.latin1(), newName.latin1())== -1)
diff --git a/noncore/net/opieftp/opieftp.cpp b/noncore/net/opieftp/opieftp.cpp
index e97a9bf..37e2134 100644
--- a/noncore/net/opieftp/opieftp.cpp
+++ b/noncore/net/opieftp/opieftp.cpp
@@ -1,1104 +1,1173 @@
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#include "ftplib.h" 15#include "ftplib.h"
16#include "inputDialog.h" 16#include "inputDialog.h"
17 17
18#include <qpe/qpemenubar.h> 18#include <qpe/qpemenubar.h>
19#include <qpe/qpetoolbar.h> 19#include <qpe/qpetoolbar.h>
20#include <qpe/qpeapplication.h> 20#include <qpe/qpeapplication.h>
21#include <qpe/resource.h> 21#include <qpe/resource.h>
22#include <qpe/qcopenvelope_qws.h> 22#include <qpe/qcopenvelope_qws.h>
23#include <qpe/config.h> 23#include <qpe/config.h>
24 24
25#include <qstringlist.h>
25#include <qtextstream.h> 26#include <qtextstream.h>
26#include <qpushbutton.h> 27#include <qpushbutton.h>
27#include <qtoolbutton.h> 28#include <qtoolbutton.h>
28#include <qdatetime.h> 29#include <qdatetime.h>
29#include <qdir.h> 30#include <qdir.h>
30#include <qfile.h> 31#include <qfile.h>
31#include <qstring.h> 32#include <qstring.h>
32#include <qcombobox.h> 33#include <qcombobox.h>
33#include <qpopupmenu.h> 34#include <qpopupmenu.h>
34#include <qlistview.h> 35#include <qlistview.h>
35#include <qmainwindow.h> 36#include <qmainwindow.h>
36#include <qlabel.h> 37#include <qlabel.h>
37#include <qprogressbar.h> 38#include <qprogressbar.h>
38#include <qspinbox.h> 39#include <qspinbox.h>
39#include <qtabwidget.h> 40#include <qtabwidget.h>
40#include <qwidget.h> 41#include <qwidget.h>
41#include <qlayout.h> 42#include <qlayout.h>
42#include <qimage.h> 43#include <qimage.h>
43#include <qpixmap.h> 44#include <qpixmap.h>
44#include <qmessagebox.h> 45#include <qmessagebox.h>
45#include <qlineedit.h> 46#include <qlineedit.h>
46#include <qregexp.h> 47#include <qregexp.h>
47 48
48#include <unistd.h> 49#include <unistd.h>
49#include <stdlib.h> 50#include <stdlib.h>
50 51
51 52
52QProgressBar *ProgressBar; 53QProgressBar *ProgressBar;
53static netbuf *conn=NULL; 54static netbuf *conn=NULL;
54 55
55static int log_progress(netbuf *ctl, int xfered, void *arg) 56static int log_progress(netbuf *ctl, int xfered, void *arg)
56{ 57{
57 int fsz = *(int *)arg; 58 int fsz = *(int *)arg;
58 int pct = (xfered * 100) / fsz; 59 int pct = (xfered * 100) / fsz;
59// printf("%3d%%\r", pct); 60// printf("%3d%%\r", pct);
60// fflush(stdout); 61// fflush(stdout);
61 ProgressBar->setProgress(xfered); 62 ProgressBar->setProgress(xfered);
62 qApp->processEvents(); 63 qApp->processEvents();
63 return 1; 64 return 1;
64} 65}
65 66
66OpieFtp::OpieFtp( ) 67OpieFtp::OpieFtp( )
67 : QMainWindow( ) 68 : QMainWindow( )
68{ 69{
69 setCaption( tr( "OpieFtp" ) ); 70 setCaption( tr( "OpieFtp" ) );
70 71
71 QGridLayout *layout = new QGridLayout( this ); 72 QGridLayout *layout = new QGridLayout( this );
72 layout->setSpacing( 2); 73 layout->setSpacing( 2);
73 layout->setMargin( 2); 74 layout->setMargin( 2);
74 75
75 connect( qApp,SIGNAL( aboutToQuit()),SLOT( cleanUp()) ); 76 connect( qApp,SIGNAL( aboutToQuit()),SLOT( cleanUp()) );
76 77
77 QPEMenuBar *menuBar = new QPEMenuBar(this); 78 QPEMenuBar *menuBar = new QPEMenuBar(this);
78 connectionMenu = new QPopupMenu( this ); 79 connectionMenu = new QPopupMenu( this );
79 localMenu = new QPopupMenu( this ); 80 localMenu = new QPopupMenu( this );
80 remoteMenu = new QPopupMenu( this ); 81 remoteMenu = new QPopupMenu( this );
81 tabMenu = new QPopupMenu( this ); 82 tabMenu = new QPopupMenu( this );
82 83
83 layout->addMultiCellWidget( menuBar, 0, 0, 0, 3 ); 84 layout->addMultiCellWidget( menuBar, 0, 0, 0, 3 );
84 85
85 menuBar->insertItem( tr( "Connection" ), connectionMenu); 86 menuBar->insertItem( tr( "Connection" ), connectionMenu);
86 menuBar->insertItem( tr( "Local" ), localMenu); 87 menuBar->insertItem( tr( "Local" ), localMenu);
87 menuBar->insertItem( tr( "Remote" ), remoteMenu); 88 menuBar->insertItem( tr( "Remote" ), remoteMenu);
88 menuBar->insertItem( tr( "View" ), tabMenu); 89 menuBar->insertItem( tr( "View" ), tabMenu);
89 90
90 connectionMenu->insertItem( tr( "New" ), this, SLOT( newConnection() )); 91 connectionMenu->insertItem( tr( "New" ), this, SLOT( newConnection() ));
91 connectionMenu->insertItem( tr( "Connect" ), this, SLOT( connector() )); 92 connectionMenu->insertItem( tr( "Connect" ), this, SLOT( connector() ));
92 connectionMenu->insertItem( tr( "Disconnect" ), this, SLOT( disConnector() )); 93 connectionMenu->insertItem( tr( "Disconnect" ), this, SLOT( disConnector() ));
93 94
94 localMenu->insertItem( tr( "Show Hidden Files" ), this, SLOT( showHidden() )); 95 localMenu->insertItem( tr( "Show Hidden Files" ), this, SLOT( showHidden() ));
95 localMenu->insertSeparator(); 96 localMenu->insertSeparator();
96 localMenu->insertItem( tr( "Upload" ), this, SLOT( localUpload() )); 97 localMenu->insertItem( tr( "Upload" ), this, SLOT( localUpload() ));
97 localMenu->insertItem( tr( "Make Directory" ), this, SLOT( localMakDir() )); 98 localMenu->insertItem( tr( "Make Directory" ), this, SLOT( localMakDir() ));
98 localMenu->insertItem( tr( "Rename" ), this, SLOT( localRename() )); 99 localMenu->insertItem( tr( "Rename" ), this, SLOT( localRename() ));
99 localMenu->insertSeparator(); 100 localMenu->insertSeparator();
100 localMenu->insertItem( tr( "Delete" ), this, SLOT( localDelete() )); 101 localMenu->insertItem( tr( "Delete" ), this, SLOT( localDelete() ));
101 localMenu->setCheckable(TRUE); 102 localMenu->setCheckable(TRUE);
102 103
103 remoteMenu->insertItem( tr( "Download" ), this, SLOT( remoteDownload() )); 104 remoteMenu->insertItem( tr( "Download" ), this, SLOT( remoteDownload() ));
104 remoteMenu->insertItem( tr( "Make Directory" ), this, SLOT( remoteMakDir() )); 105 remoteMenu->insertItem( tr( "Make Directory" ), this, SLOT( remoteMakDir() ));
105 remoteMenu->insertItem( tr( "Rename" ), this, SLOT( remoteRename() )); 106 remoteMenu->insertItem( tr( "Rename" ), this, SLOT( remoteRename() ));
106 remoteMenu->insertSeparator(); 107 remoteMenu->insertSeparator();
107 remoteMenu->insertItem( tr( "Delete" ), this, SLOT( remoteDelete() )); 108 remoteMenu->insertItem( tr( "Delete" ), this, SLOT( remoteDelete() ));
108 109
109 tabMenu->insertItem( tr( "Switch to Local" ), this, SLOT( switchToLocalTab() )); 110 tabMenu->insertItem( tr( "Switch to Local" ), this, SLOT( switchToLocalTab() ));
110 tabMenu->insertItem( tr( "Switch to Remote" ), this, SLOT( switchToRemoteTab() )); 111 tabMenu->insertItem( tr( "Switch to Remote" ), this, SLOT( switchToRemoteTab() ));
111 tabMenu->insertItem( tr( "Switch to Config" ), this, SLOT( switchToConfigTab() )); 112 tabMenu->insertItem( tr( "Switch to Config" ), this, SLOT( switchToConfigTab() ));
112 tabMenu->setCheckable(TRUE); 113 tabMenu->setCheckable(TRUE);
113 114
114 TabWidget = new QTabWidget( this, "TabWidget" ); 115 TabWidget = new QTabWidget( this, "TabWidget" );
115 layout->addMultiCellWidget( TabWidget, 1, 1, 0, 3 ); 116 layout->addMultiCellWidget( TabWidget, 1, 1, 0, 3 );
116 117
117 TabWidget->setTabShape(QTabWidget::Triangular); 118 TabWidget->setTabShape(QTabWidget::Triangular);
118 119
119 tab = new QWidget( TabWidget, "tab" ); 120 tab = new QWidget( TabWidget, "tab" );
120 tabLayout = new QGridLayout( tab ); 121 tabLayout = new QGridLayout( tab );
121 tabLayout->setSpacing( 2); 122 tabLayout->setSpacing( 2);
122 tabLayout->setMargin( 2); 123 tabLayout->setMargin( 2);
123 124
124 Local_View = new QListView( tab, "Local_View" ); 125 Local_View = new QListView( tab, "Local_View" );
125// Local_View->setResizePolicy( QListView::AutoOneFit ); 126// Local_View->setResizePolicy( QListView::AutoOneFit );
126 Local_View->addColumn( tr("File"),120); 127 Local_View->addColumn( tr("File"),120);
127 Local_View->addColumn( tr("Size"),-1); 128 Local_View->addColumn( tr("Size"),-1);
128 Local_View->setColumnAlignment(1,QListView::AlignRight); 129 Local_View->setColumnAlignment(1,QListView::AlignRight);
129 Local_View->addColumn( tr("Date"),-1); 130 Local_View->addColumn( tr("Date"),-1);
130 Local_View->setColumnAlignment(2,QListView::AlignRight); 131 Local_View->setColumnAlignment(2,QListView::AlignRight);
131 Local_View->setAllColumnsShowFocus(TRUE); 132 Local_View->setAllColumnsShowFocus(TRUE);
132 QPEApplication::setStylusOperation( Local_View->viewport(),QPEApplication::RightOnHold); 133 QPEApplication::setStylusOperation( Local_View->viewport(),QPEApplication::RightOnHold);
133 134
134 tabLayout->addWidget( Local_View, 0, 0 ); 135 tabLayout->addWidget( Local_View, 0, 0 );
135 136
136 connect( Local_View, SIGNAL( clicked( QListViewItem*)), 137 connect( Local_View, SIGNAL( clicked( QListViewItem*)),
137 this,SLOT( localListClicked(QListViewItem *)) ); 138 this,SLOT( localListClicked(QListViewItem *)) );
138 connect( Local_View, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int)), 139 connect( Local_View, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int)),
139 this,SLOT( ListPressed(int, QListViewItem *, const QPoint&, int)) ); 140 this,SLOT( ListPressed(int, QListViewItem *, const QPoint&, int)) );
140 141
141 TabWidget->insertTab( tab, tr( "Local" ) ); 142 TabWidget->insertTab( tab, tr( "Local" ) );
142 143
143 tab_2 = new QWidget( TabWidget, "tab_2" ); 144 tab_2 = new QWidget( TabWidget, "tab_2" );
144 tabLayout_2 = new QGridLayout( tab_2 ); 145 tabLayout_2 = new QGridLayout( tab_2 );
145 tabLayout_2->setSpacing( 2); 146 tabLayout_2->setSpacing( 2);
146 tabLayout_2->setMargin( 2); 147 tabLayout_2->setMargin( 2);
147 148
148 Remote_View = new QListView( tab_2, "Remote_View" ); 149 Remote_View = new QListView( tab_2, "Remote_View" );
149 Remote_View->addColumn( tr("File"),120); 150 Remote_View->addColumn( tr("File"),120);
150 Remote_View->addColumn( tr("Size"),-1); 151 Remote_View->addColumn( tr("Size"),-1);
151 Remote_View->setColumnAlignment(1,QListView::AlignRight); 152 Remote_View->setColumnAlignment(1,QListView::AlignRight);
152 Remote_View->addColumn( tr("Date"),-1); 153 Remote_View->addColumn( tr("Date"),-1);
153 Remote_View->setColumnAlignment(2,QListView::AlignRight); 154 Remote_View->setColumnAlignment(2,QListView::AlignRight);
154 Remote_View->addColumn( tr("Dir"),-1); 155 Remote_View->addColumn( tr("Dir"),-1);
155 Remote_View->setColumnAlignment(4,QListView::AlignRight); 156 Remote_View->setColumnAlignment(4,QListView::AlignRight);
156 Remote_View->setAllColumnsShowFocus(TRUE); 157 Remote_View->setAllColumnsShowFocus(TRUE);
157 QPEApplication::setStylusOperation( Remote_View->viewport(),QPEApplication::RightOnHold); 158 QPEApplication::setStylusOperation( Remote_View->viewport(),QPEApplication::RightOnHold);
158 159
159 connect( Remote_View, SIGNAL( clicked( QListViewItem*)), 160 connect( Remote_View, SIGNAL( clicked( QListViewItem*)),
160 this,SLOT( remoteListClicked(QListViewItem *)) ); 161 this,SLOT( remoteListClicked(QListViewItem *)) );
161 connect( Remote_View, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int)), 162 connect( Remote_View, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int)),
162 this,SLOT( RemoteListPressed(int, QListViewItem *, const QPoint&, int)) ); 163 this,SLOT( RemoteListPressed(int, QListViewItem *, const QPoint&, int)) );
163 164
164 tabLayout_2->addWidget( Remote_View, 0, 0 ); 165 tabLayout_2->addWidget( Remote_View, 0, 0 );
165 166
166 TabWidget->insertTab( tab_2, tr( "Remote" ) ); 167 TabWidget->insertTab( tab_2, tr( "Remote" ) );
167 168
168 tab_3 = new QWidget( TabWidget, "tab_3" ); 169 tab_3 = new QWidget( TabWidget, "tab_3" );
169 tabLayout_3 = new QGridLayout( tab_3 ); 170 tabLayout_3 = new QGridLayout( tab_3 );
170 tabLayout_3->setSpacing( 2); 171 tabLayout_3->setSpacing( 2);
171 tabLayout_3->setMargin( 2); 172 tabLayout_3->setMargin( 2);
172 173
173 TextLabel1 = new QLabel( tab_3, "TextLabel1" ); 174 TextLabel1 = new QLabel( tab_3, "TextLabel1" );
174 TextLabel1->setText( tr( "Username" ) ); 175 TextLabel1->setText( tr( "Username" ) );
175 tabLayout_3->addMultiCellWidget( TextLabel1, 0, 0, 0, 1 ); 176 tabLayout_3->addMultiCellWidget( TextLabel1, 0, 0, 0, 1 );
176 177
177 UsernameComboBox = new QComboBox( FALSE, tab_3, "UsernameComboBox" ); 178 UsernameComboBox = new QComboBox( FALSE, tab_3, "UsernameComboBox" );
178 UsernameComboBox->setEditable(TRUE); 179 UsernameComboBox->setEditable(TRUE);
179 tabLayout_3->addMultiCellWidget( UsernameComboBox, 1, 1, 0, 1 ); 180 tabLayout_3->addMultiCellWidget( UsernameComboBox, 1, 1, 0, 1 );
180 181
181 TextLabel2 = new QLabel( tab_3, "TextLabel2" ); 182 TextLabel2 = new QLabel( tab_3, "TextLabel2" );
182 TextLabel2->setText( tr( "Password" ) ); 183 TextLabel2->setText( tr( "Password" ) );
183 tabLayout_3->addMultiCellWidget( TextLabel2, 0, 0, 2, 3 ); 184 tabLayout_3->addMultiCellWidget( TextLabel2, 0, 0, 2, 3 );
184 185
185 PasswordEdit = new QLineEdit( "", tab_3, "PasswordComboBox" ); 186 PasswordEdit = new QLineEdit( "", tab_3, "PasswordComboBox" );
186 PasswordEdit->setEchoMode(QLineEdit::Password); 187 PasswordEdit->setEchoMode(QLineEdit::Password);
187 tabLayout_3->addMultiCellWidget( PasswordEdit, 1, 1, 2, 3 ); 188 tabLayout_3->addMultiCellWidget( PasswordEdit, 1, 1, 2, 3 );
188 189
189 TextLabel3 = new QLabel( tab_3, "TextLabel3" ); 190 TextLabel3 = new QLabel( tab_3, "TextLabel3" );
190 TextLabel3->setText( tr( "Remote server" ) ); 191 TextLabel3->setText( tr( "Remote server" ) );
191 tabLayout_3->addMultiCellWidget( TextLabel3, 2, 2, 0, 1 ); 192 tabLayout_3->addMultiCellWidget( TextLabel3, 2, 2, 0, 1 );
192 193
193 ServerComboBox = new QComboBox( FALSE, tab_3, "ServerComboBox" ); 194 ServerComboBox = new QComboBox( FALSE, tab_3, "ServerComboBox" );
194 ServerComboBox->setEditable(TRUE); 195 ServerComboBox->setEditable(TRUE);
195 tabLayout_3->addMultiCellWidget( ServerComboBox, 3, 3, 0, 1 ); 196 tabLayout_3->addMultiCellWidget( ServerComboBox, 3, 3, 0, 1 );
196 197
197 connect(ServerComboBox,SIGNAL(activated(int)),this,SLOT(serverComboSelected(int ) )); 198 connect(ServerComboBox,SIGNAL(activated(int)),this,SLOT(serverComboSelected(int ) ));
198 connect(ServerComboBox,SIGNAL(textChanged(const QString &)),this,SLOT(serverComboEdited(const QString & ) )); 199 connect(ServerComboBox,SIGNAL(textChanged(const QString &)),this,SLOT(serverComboEdited(const QString & ) ));
199 200
200 QLabel *TextLabel5 = new QLabel( tab_3, "TextLabel5" ); 201 QLabel *TextLabel5 = new QLabel( tab_3, "TextLabel5" );
201 TextLabel5->setText( tr( "Remote path" ) ); 202 TextLabel5->setText( tr( "Remote path" ) );
202 tabLayout_3->addMultiCellWidget( TextLabel5, 2, 2, 2, 3 ); 203 tabLayout_3->addMultiCellWidget( TextLabel5, 2, 2, 2, 3 );
203 204
204 remotePath = new QLineEdit( "/", tab_3, "remotePath" ); 205 remotePath = new QLineEdit( "/", tab_3, "remotePath" );
205 tabLayout_3->addMultiCellWidget( remotePath, 3, 3, 2, 3 ); 206 tabLayout_3->addMultiCellWidget( remotePath, 3, 3, 2, 3 );
206 207
207 TextLabel4 = new QLabel( tab_3, "TextLabel4" ); 208 TextLabel4 = new QLabel( tab_3, "TextLabel4" );
208 TextLabel4->setText( tr( "Port" ) ); 209 TextLabel4->setText( tr( "Port" ) );
209 tabLayout_3->addMultiCellWidget( TextLabel4, 4, 4, 0, 1 ); 210 tabLayout_3->addMultiCellWidget( TextLabel4, 4, 4, 0, 1 );
210 211
211 PortSpinBox = new QSpinBox( tab_3, "PortSpinBox" ); 212 PortSpinBox = new QSpinBox( tab_3, "PortSpinBox" );
212 PortSpinBox->setButtonSymbols( QSpinBox::UpDownArrows ); 213 PortSpinBox->setButtonSymbols( QSpinBox::UpDownArrows );
213 PortSpinBox->setMaxValue(32786); 214 PortSpinBox->setMaxValue(32786);
214 tabLayout_3->addMultiCellWidget( PortSpinBox, 4, 4, 1, 1); 215 tabLayout_3->addMultiCellWidget( PortSpinBox, 4, 4, 1, 1);
215 216
216 QPushButton *deleteServerBtn; 217 QPushButton *deleteServerBtn;
217 deleteServerBtn = new QPushButton( "Delete Server", tab_3 , "OpenButton" ); 218 deleteServerBtn = new QPushButton( "Delete Server", tab_3 , "OpenButton" );
218 tabLayout_3->addMultiCellWidget( deleteServerBtn, 5, 5, 2, 3); 219 tabLayout_3->addMultiCellWidget( deleteServerBtn, 5, 5, 2, 3);
219 220
220 connect(deleteServerBtn,SIGNAL(clicked()),SLOT(deleteServer())); 221 connect(deleteServerBtn,SIGNAL(clicked()),SLOT(deleteServer()));
221 222
222 connectServerBtn = new QPushButton( "Connect", tab_3 , "ConnectButton" ); 223 connectServerBtn = new QPushButton( "Connect", tab_3 , "ConnectButton" );
223 tabLayout_3->addMultiCellWidget( connectServerBtn, 5, 5, 0, 1); 224 tabLayout_3->addMultiCellWidget( connectServerBtn, 5, 5, 0, 1);
224 connectServerBtn->setToggleButton(TRUE); 225 connectServerBtn->setToggleButton(TRUE);
225 connect(connectServerBtn,SIGNAL( toggled( bool)),SLOT( connectorBtnToggled(bool) )); 226 connect(connectServerBtn,SIGNAL( toggled( bool)),SLOT( connectorBtnToggled(bool) ));
226 227
227 228
228 QSpacerItem* spacer = new QSpacerItem( 20, 20, QSizePolicy::Minimum, QSizePolicy::Expanding ); 229 QSpacerItem* spacer = new QSpacerItem( 20, 20, QSizePolicy::Minimum, QSizePolicy::Expanding );
229 tabLayout_3->addItem( spacer, 5, 0 ); 230 tabLayout_3->addItem( spacer, 5, 0 );
230 231
231 TabWidget->insertTab( tab_3, tr( "Config" ) ); 232 TabWidget->insertTab( tab_3, tr( "Config" ) );
232 233
233 connect(TabWidget,SIGNAL(currentChanged(QWidget *)), 234 connect(TabWidget,SIGNAL(currentChanged(QWidget *)),
234 this,SLOT(tabChanged(QWidget*))); 235 this,SLOT(tabChanged(QWidget*)));
235 236
236 currentDir.setFilter( QDir::Files | QDir::Dirs/* | QDir::Hidden*/ | QDir::All); 237 currentDir.setFilter( QDir::Files | QDir::Dirs/* | QDir::Hidden*/ | QDir::All);
237 currentDir.setPath( QDir::currentDirPath()); 238 currentDir.setPath( QDir::currentDirPath());
238// currentDir.setSorting(/* QDir::Size*/ /*| QDir::Reversed | */QDir::DirsFirst); 239// currentDir.setSorting(/* QDir::Size*/ /*| QDir::Reversed | */QDir::DirsFirst);
239 currentPathEdit = new QLineEdit( "/", this, "currentPathEdit" );
240 layout->addMultiCellWidget( currentPathEdit, 3, 3, 0, 3 );
241 240
242 currentPathEdit->setText( currentDir.canonicalPath()); 241 currentPathCombo = new QComboBox( FALSE, this, "currentPathCombo" );
243 connect( currentPathEdit,SIGNAL(returnPressed()),this,SLOT(currentPathEditChanged())); 242 layout->addMultiCellWidget( currentPathCombo, 3, 3, 0, 3 );
243
244 currentPathCombo->lineEdit()->setText( currentDir.canonicalPath());
245
246 connect( currentPathCombo, SIGNAL( activated( const QString & ) ),
247 this, SLOT( currentPathComboChanged()currentPathCombo( const QString & ) ) );
248
249 connect( currentPathCombo->lineEdit(),SIGNAL(returnPressed()),
250 this,SLOT(currentPathComboChanged()));
244 251
245 ProgressBar = new QProgressBar( this, "ProgressBar" ); 252 ProgressBar = new QProgressBar( this, "ProgressBar" );
246 layout->addMultiCellWidget( ProgressBar, 4, 4, 0, 3 ); 253 layout->addMultiCellWidget( ProgressBar, 4, 4, 0, 3 );
247 254
248// fillCombos(); 255// fillCombos();
249 256
250#ifdef DEVELOPERS_VERSION 257#ifdef DEVELOPERS_VERSION
251 ServerComboBox->lineEdit()->setText( tr( "192.168.129.201" ) ); 258 ServerComboBox->lineEdit()->setText( tr( "192.168.129.201" ) );
252 UsernameComboBox->lineEdit()->setText("root"); 259 UsernameComboBox->lineEdit()->setText("root");
253 PortSpinBox->setValue( 4242); 260 PortSpinBox->setValue( 4242);
254 remotePath->setText( currentRemoteDir = "/"); 261 remotePath->setText( currentRemoteDir = "/");
255// ServerComboBox->lineEdit()->setText( tr( "llornkcor.com" ) ); 262// ServerComboBox->lineEdit()->setText( tr( "llornkcor.com" ) );
256// UsernameComboBox->lineEdit()->setText("llornkcor"); 263// UsernameComboBox->lineEdit()->setText("llornkcor");
257// PortSpinBox->setValue( 21); 264// PortSpinBox->setValue( 21);
258// remotePath->setText( currentRemoteDir = "/home/llornkcor"); 265// remotePath->setText( currentRemoteDir = "/home/llornkcor");
259 PasswordEdit->setText( tr( "" ) ); 266 PasswordEdit->setText( tr( "" ) );
260#endif 267#endif
261 filterStr="*"; 268 filterStr="*";
262 b=FALSE; 269 b=FALSE;
263 populateLocalView(); 270 populateLocalView();
264 readConfig(); 271 readConfig();
265 ServerComboBox->setCurrentItem(currentServerConfig); 272 ServerComboBox->setCurrentItem(currentServerConfig);
266 TabWidget->setCurrentPage(2); 273 TabWidget->setCurrentPage(2);
267} 274}
268 275
269OpieFtp::~OpieFtp() 276OpieFtp::~OpieFtp()
270{ 277{
271} 278}
272 279
273void OpieFtp::cleanUp() 280void OpieFtp::cleanUp()
274{ 281{
275 if(conn) 282 if(conn)
276 FtpQuit(conn); 283 FtpQuit(conn);
277 QString sfile=QDir::homeDirPath(); 284 QString sfile=QDir::homeDirPath();
278 if(sfile.right(1) != "/") 285 if(sfile.right(1) != "/")
279 sfile+="/._temp"; 286 sfile+="/._temp";
280 else 287 else
281 sfile+="._temp"; 288 sfile+="._temp";
282 QFile file( sfile); 289 QFile file( sfile);
283 if(file.exists()) 290 if(file.exists())
284 file.remove(); 291 file.remove();
285} 292}
286 293
287void OpieFtp::tabChanged(QWidget *w) 294void OpieFtp::tabChanged(QWidget *w)
288{ 295{
289 if (TabWidget->currentPageIndex() == 0) { 296 if (TabWidget->currentPageIndex() == 0) {
290 currentPathEdit->setText( currentDir.canonicalPath()); 297 currentPathCombo->lineEdit()->setText( currentDir.canonicalPath());
291 tabMenu->setItemChecked(tabMenu->idAt(0),TRUE); 298 tabMenu->setItemChecked(tabMenu->idAt(0),TRUE);
292 tabMenu->setItemChecked(tabMenu->idAt(1),FALSE); 299 tabMenu->setItemChecked(tabMenu->idAt(1),FALSE);
293 tabMenu->setItemChecked(tabMenu->idAt(2),FALSE); 300 tabMenu->setItemChecked(tabMenu->idAt(2),FALSE);
294 } 301 }
295 if (TabWidget->currentPageIndex() == 1) { 302 if (TabWidget->currentPageIndex() == 1) {
296 currentPathEdit->setText( currentRemoteDir ); 303 currentPathCombo->lineEdit()->setText( currentRemoteDir );
297 tabMenu->setItemChecked(tabMenu->idAt(1),TRUE); 304 tabMenu->setItemChecked(tabMenu->idAt(1),TRUE);
298 tabMenu->setItemChecked(tabMenu->idAt(0),FALSE); 305 tabMenu->setItemChecked(tabMenu->idAt(0),FALSE);
299 tabMenu->setItemChecked(tabMenu->idAt(2),FALSE); 306 tabMenu->setItemChecked(tabMenu->idAt(2),FALSE);
300 } 307 }
301 if (TabWidget->currentPageIndex() == 2) { 308 if (TabWidget->currentPageIndex() == 2) {
302 tabMenu->setItemChecked(tabMenu->idAt(2),TRUE); 309 tabMenu->setItemChecked(tabMenu->idAt(2),TRUE);
303 tabMenu->setItemChecked(tabMenu->idAt(0),FALSE); 310 tabMenu->setItemChecked(tabMenu->idAt(0),FALSE);
304 tabMenu->setItemChecked(tabMenu->idAt(1),FALSE); 311 tabMenu->setItemChecked(tabMenu->idAt(1),FALSE);
305 } 312 }
306} 313}
307 314
308void OpieFtp::newConnection() 315void OpieFtp::newConnection()
309{ 316{
310 UsernameComboBox->lineEdit()->setText(""); 317 UsernameComboBox->lineEdit()->setText("");
311 PasswordEdit->setText( "" ); 318 PasswordEdit->setText( "" );
312 ServerComboBox->lineEdit()->setText( ""); 319 ServerComboBox->lineEdit()->setText( "");
313 remotePath->setText( currentRemoteDir = "/"); 320 remotePath->setText( currentRemoteDir = "/");
314 PortSpinBox->setValue( 21); 321 PortSpinBox->setValue( 21);
315 TabWidget->setCurrentPage(2); 322 TabWidget->setCurrentPage(2);
316 currentServerConfig = -1; 323 currentServerConfig = -1;
317} 324}
318 325
319void OpieFtp::serverComboEdited(const QString & edit) { 326void OpieFtp::serverComboEdited(const QString & edit) {
320 if( !edit.isEmpty() ) { 327 if( !edit.isEmpty() ) {
321 currentServerConfig = -1; 328 currentServerConfig = -1;
322 qDebug("comboedited"); 329 qDebug("comboedited");
323 } 330 }
324} 331}
325 332
326void OpieFtp::connectorBtnToggled(bool On) 333void OpieFtp::connectorBtnToggled(bool On)
327{ 334{
328 if(On) { 335 if(On) {
329 connector(); 336 connector();
330 } else { 337 } else {
331 disConnector(); 338 disConnector();
332 } 339 }
333 340
334} 341}
335 342
336void OpieFtp::connector() 343void OpieFtp::connector()
337{ 344{
338 QCopEnvelope ( "QPE/System", "busy()" ); 345 QCopEnvelope ( "QPE/System", "busy()" );
339// qApp->processEvents(); 346// qApp->processEvents();
340 currentRemoteDir=remotePath->text(); 347 currentRemoteDir=remotePath->text();
341 if(ServerComboBox->currentText().isEmpty()) { 348 if(ServerComboBox->currentText().isEmpty()) {
342 QMessageBox::warning(this,tr("Ftp"),tr("Please set the server info"),tr("Ok"),0,0); 349 QMessageBox::warning(this,tr("Ftp"),tr("Please set the server info"),tr("Ok"),0,0);
343 TabWidget->setCurrentPage(2); 350 TabWidget->setCurrentPage(2);
344 ServerComboBox->setFocus(); 351 ServerComboBox->setFocus();
345 connectServerBtn->setOn(FALSE); 352 connectServerBtn->setOn(FALSE);
346 connectServerBtn->setText( tr("Connect")); 353 connectServerBtn->setText( tr("Connect"));
347 return; 354 return;
348 } 355 }
349 FtpInit(); 356 FtpInit();
350 TabWidget->setCurrentPage(1); 357 TabWidget->setCurrentPage(1);
351 QString ftp_host = ServerComboBox->currentText(); 358 QString ftp_host = ServerComboBox->currentText();
352 QString ftp_user = UsernameComboBox->currentText(); 359 QString ftp_user = UsernameComboBox->currentText();
353 QString ftp_pass = PasswordEdit->text(); 360 QString ftp_pass = PasswordEdit->text();
354 QString port=PortSpinBox->cleanText(); 361 QString port=PortSpinBox->cleanText();
355 port.stripWhiteSpace(); 362 port.stripWhiteSpace();
356 363
357 if(ftp_host.find("ftp://",0, TRUE) != -1 ) 364 if(ftp_host.find("ftp://",0, TRUE) != -1 )
358 ftp_host=ftp_host.right(ftp_host.length()-6); 365 ftp_host=ftp_host.right(ftp_host.length()-6);
359 ftp_host+=":"+port; 366 ftp_host+=":"+port;
360 if (!FtpConnect( ftp_host.latin1(), &conn)) { 367 if (!FtpConnect( ftp_host.latin1(), &conn)) {
361 QMessageBox::message(tr("Note"),tr("Unable to connect to\n")+ftp_host); 368 QMessageBox::message(tr("Note"),tr("Unable to connect to\n")+ftp_host);
362 connectServerBtn->setOn(FALSE); 369 connectServerBtn->setOn(FALSE);
363 connectServerBtn->setText( tr("Connect")); 370 connectServerBtn->setText( tr("Connect"));
364 return ; 371 return ;
365 } 372 }
366 if (!FtpLogin( ftp_user.latin1(), ftp_pass.latin1(),conn )) { 373 if (!FtpLogin( ftp_user.latin1(), ftp_pass.latin1(),conn )) {
367 QString msg; 374 QString msg;
368 msg.sprintf(tr("Unable to log in\n")+"%s",FtpLastResponse(conn)); 375 msg.sprintf(tr("Unable to log in\n")+"%s",FtpLastResponse(conn));
369 msg.replace(QRegExp(":"),"\n"); 376 msg.replace(QRegExp(":"),"\n");
370 QMessageBox::message(tr("Note"),msg); 377 QMessageBox::message(tr("Note"),msg);
371 if(conn) 378 if(conn)
372 FtpQuit(conn); 379 FtpQuit(conn);
373 connectServerBtn->setOn(FALSE); 380 connectServerBtn->setOn(FALSE);
374 connectServerBtn->setText( tr("Connect")); 381 connectServerBtn->setText( tr("Connect"));
375 return ; 382 return ;
376 } 383 }
377 remoteDirList("/") ; 384 remoteDirList("/") ;
378 setCaption(ftp_host); 385 setCaption(ftp_host);
379 writeConfig(); 386 writeConfig();
380 connectServerBtn->setText( tr("Disconnect")); 387 connectServerBtn->setText( tr("Disconnect"));
381 QCopEnvelope ( "QPE/System", "notBusy()" ); 388 QCopEnvelope ( "QPE/System", "notBusy()" );
382} 389}
383 390
384void OpieFtp::disConnector() 391void OpieFtp::disConnector()
385{ 392{
386 if(conn) 393 if(conn)
387 FtpQuit(conn); 394 FtpQuit(conn);
388 setCaption("OpieFtp"); 395 setCaption("OpieFtp");
389 currentRemoteDir="/"; 396 currentRemoteDir="/";
390 Remote_View->clear(); 397 Remote_View->clear();
391 connectServerBtn->setText( tr("Connect")); 398 connectServerBtn->setText( tr("Connect"));
392 connectServerBtn->setOn(FALSE); 399 connectServerBtn->setOn(FALSE);
393 400
394} 401}
395 402
396void OpieFtp::localUpload() 403void OpieFtp::localUpload()
397{ 404{
398 int fsz; 405 int fsz;
399 QCopEnvelope ( "QPE/System", "busy()" ); 406 QCopEnvelope ( "QPE/System", "busy()" );
400// qApp->processEvents(); 407// qApp->processEvents();
401 QString strItem = Local_View->currentItem()->text(0); 408 QString strItem = Local_View->currentItem()->text(0);
402 QString localFile = currentDir.canonicalPath()+"/"+strItem; 409 QString localFile = currentDir.canonicalPath()+"/"+strItem;
403 QString remoteFile= currentRemoteDir+strItem; 410 QString remoteFile= currentRemoteDir+strItem;
404 QFileInfo fi(localFile); 411 QFileInfo fi(localFile);
405 if( !fi.isDir()) { 412 if( !fi.isDir()) {
406 fsz=fi.size(); 413 fsz=fi.size();
407 ProgressBar->setTotalSteps(fsz); 414 ProgressBar->setTotalSteps(fsz);
408 415
409 FtpOptions(FTPLIB_CALLBACK, (long) log_progress, conn); 416 FtpOptions(FTPLIB_CALLBACK, (long) log_progress, conn);
410 FtpOptions(FTPLIB_IDLETIME, (long) 1000, conn); 417 FtpOptions(FTPLIB_IDLETIME, (long) 1000, conn);
411 FtpOptions(FTPLIB_CALLBACKARG, (long) &fsz, conn); 418 FtpOptions(FTPLIB_CALLBACKARG, (long) &fsz, conn);
412 FtpOptions(FTPLIB_CALLBACKBYTES, (long) fsz/10, conn); 419 FtpOptions(FTPLIB_CALLBACKBYTES, (long) fsz/10, conn);
413 qDebug("Put: %s, %s",localFile.latin1(),remoteFile.latin1()); 420 qDebug("Put: %s, %s",localFile.latin1(),remoteFile.latin1());
414 421
415 if( !FtpPut( localFile.latin1(), remoteFile.latin1(),FTPLIB_IMAGE, conn ) ) { 422 if( !FtpPut( localFile.latin1(), remoteFile.latin1(),FTPLIB_IMAGE, conn ) ) {
416 QString msg; 423 QString msg;
417 msg.sprintf(tr("Unable to upload\n")+"%s",FtpLastResponse(conn)); 424 msg.sprintf(tr("Unable to upload\n")+"%s",FtpLastResponse(conn));
418 msg.replace(QRegExp(":"),"\n"); 425 msg.replace(QRegExp(":"),"\n");
419 QMessageBox::message(tr("Note"),msg); 426 QMessageBox::message(tr("Note"),msg);
420 } 427 }
421 ProgressBar->reset(); 428 ProgressBar->reset();
422 nullifyCallBack(); 429 nullifyCallBack();
423 } else { 430 } else {
424 QMessageBox::message(tr("Note"),tr("Cannot upload directories")); 431 QMessageBox::message(tr("Note"),tr("Cannot upload directories"));
425 } 432 }
426 TabWidget->setCurrentPage(1); 433 TabWidget->setCurrentPage(1);
427 remoteDirList( (const QString &)currentRemoteDir); //this also calls populate 434 remoteDirList( (const QString &)currentRemoteDir); //this also calls populate
428 QCopEnvelope ( "QPE/System", "notBusy()" ); 435 QCopEnvelope ( "QPE/System", "notBusy()" );
429} 436}
430 437
431void OpieFtp::nullifyCallBack() 438void OpieFtp::nullifyCallBack()
432{ 439{
433 FtpOptions(FTPLIB_CALLBACK, NULL, conn); 440 FtpOptions(FTPLIB_CALLBACK, NULL, conn);
434 FtpOptions(FTPLIB_IDLETIME, NULL, conn); 441 FtpOptions(FTPLIB_IDLETIME, NULL, conn);
435 FtpOptions(FTPLIB_CALLBACKARG, NULL, conn); 442 FtpOptions(FTPLIB_CALLBACKARG, NULL, conn);
436 FtpOptions(FTPLIB_CALLBACKBYTES, NULL, conn); 443 FtpOptions(FTPLIB_CALLBACKBYTES, NULL, conn);
437 444
438} 445}
439 446
440void OpieFtp::remoteDownload() 447void OpieFtp::remoteDownload()
441{ 448{
442// qApp->processEvents(); 449// qApp->processEvents();
443 int fsz; 450 int fsz;
444 QCopEnvelope ( "QPE/System", "busy()" ); 451 QCopEnvelope ( "QPE/System", "busy()" );
445 QString strItem = Remote_View->currentItem()->text(0); 452 QString strItem = Remote_View->currentItem()->text(0);
446// strItem=strItem.right(strItem.length()-1); 453// strItem=strItem.right(strItem.length()-1);
447 454
448 QString localFile = currentDir.canonicalPath(); 455 QString localFile = currentDir.canonicalPath();
449 if(localFile.right(1).find("/",0,TRUE) == -1) 456 if(localFile.right(1).find("/",0,TRUE) == -1)
450 localFile += "/"; 457 localFile += "/";
451 localFile += strItem; 458 localFile += strItem;
452// QString localFile = currentDir.canonicalPath()+"/"+strItem; 459// QString localFile = currentDir.canonicalPath()+"/"+strItem;
453 QString remoteFile= currentRemoteDir+strItem; 460 QString remoteFile= currentRemoteDir+strItem;
454 if (!FtpSize( remoteFile.latin1(), &fsz, FTPLIB_ASCII, conn)) 461 if (!FtpSize( remoteFile.latin1(), &fsz, FTPLIB_ASCII, conn))
455 fsz = 0; 462 fsz = 0;
456 QString temp; 463 QString temp;
457 temp.sprintf( remoteFile+" "+" %dkb", fsz); 464 temp.sprintf( remoteFile+" "+" %dkb", fsz);
458 465
459 ProgressBar->setTotalSteps(fsz); 466 ProgressBar->setTotalSteps(fsz);
460 FtpOptions(FTPLIB_CALLBACK, (long) log_progress, conn); 467 FtpOptions(FTPLIB_CALLBACK, (long) log_progress, conn);
461 FtpOptions(FTPLIB_IDLETIME, (long) 1000, conn); 468 FtpOptions(FTPLIB_IDLETIME, (long) 1000, conn);
462 FtpOptions(FTPLIB_CALLBACKARG, (long) &fsz, conn); 469 FtpOptions(FTPLIB_CALLBACKARG, (long) &fsz, conn);
463 FtpOptions(FTPLIB_CALLBACKBYTES, (long) fsz/10, conn); 470 FtpOptions(FTPLIB_CALLBACKBYTES, (long) fsz/10, conn);
464 qDebug("Get: %s, %s",localFile.latin1(),remoteFile.latin1()); 471 qDebug("Get: %s, %s",localFile.latin1(),remoteFile.latin1());
465 472
466 if(!FtpGet( localFile.latin1(), remoteFile.latin1(),FTPLIB_IMAGE, conn ) ) { 473 if(!FtpGet( localFile.latin1(), remoteFile.latin1(),FTPLIB_IMAGE, conn ) ) {
467 QString msg; 474 QString msg;
468 msg.sprintf(tr("Unable to download \n")+"%s",FtpLastResponse(conn)); 475 msg.sprintf(tr("Unable to download \n")+"%s",FtpLastResponse(conn));
469 msg.replace(QRegExp(":"),"\n"); 476 msg.replace(QRegExp(":"),"\n");
470 QMessageBox::message(tr("Note"),msg); 477 QMessageBox::message(tr("Note"),msg);
471 } 478 }
472 ProgressBar->reset(); 479 ProgressBar->reset();
473 nullifyCallBack(); 480 nullifyCallBack();
474 TabWidget->setCurrentPage(0); 481 TabWidget->setCurrentPage(0);
475 populateLocalView(); 482 populateLocalView();
476 QCopEnvelope ( "QPE/System", "notBusy()" ); 483 QCopEnvelope ( "QPE/System", "notBusy()" );
477} 484}
478 485
479bool OpieFtp::remoteDirList(const QString &dir) 486bool OpieFtp::remoteDirList(const QString &dir)
480{ 487{
481 QString tmp = QDir::homeDirPath(); 488 QString tmp = QDir::homeDirPath();
482 if(tmp.right(1) != "/") 489 if(tmp.right(1) != "/")
483 tmp+="/._temp"; 490 tmp+="/._temp";
484 else 491 else
485 tmp+="._temp"; 492 tmp+="._temp";
486// qDebug("Listing remote dir "+tmp); 493// qDebug("Listing remote dir "+tmp);
487 QCopEnvelope ( "QPE/System", "busy()" ); 494 QCopEnvelope ( "QPE/System", "busy()" );
488 if (!FtpDir( tmp.latin1(), dir.latin1(), conn) ) { 495 if (!FtpDir( tmp.latin1(), dir.latin1(), conn) ) {
489 QString msg; 496 QString msg;
490 msg.sprintf(tr("Unable to list the directory\n")+dir+"\n%s",FtpLastResponse(conn) ); 497 msg.sprintf(tr("Unable to list the directory\n")+dir+"\n%s",FtpLastResponse(conn) );
491 msg.replace(QRegExp(":"),"\n"); 498 msg.replace(QRegExp(":"),"\n");
492 QMessageBox::message(tr("Note"),msg); 499 QMessageBox::message(tr("Note"),msg);
493 return false; 500 return false;
494 } 501 }
495 populateRemoteView() ; 502 populateRemoteView() ;
496 QCopEnvelope ( "QPE/System", "notBusy()" ); 503 QCopEnvelope ( "QPE/System", "notBusy()" );
497 return true; 504 return true;
498} 505}
499 506
500bool OpieFtp::remoteChDir(const QString &dir) 507bool OpieFtp::remoteChDir(const QString &dir)
501{ 508{
502 QCopEnvelope ( "QPE/System", "busy()" ); 509 QCopEnvelope ( "QPE/System", "busy()" );
503 if (!FtpChdir( dir.latin1(), conn )) { 510 if (!FtpChdir( dir.latin1(), conn )) {
504 QString msg; 511 QString msg;
505 msg.sprintf(tr("Unable to change directories\n")+dir+"\n%s",FtpLastResponse(conn)); 512 msg.sprintf(tr("Unable to change directories\n")+dir+"\n%s",FtpLastResponse(conn));
506 msg.replace(QRegExp(":"),"\n"); 513 msg.replace(QRegExp(":"),"\n");
507 QMessageBox::message(tr("Note"),msg); 514 QMessageBox::message(tr("Note"),msg);
508 qDebug(msg); 515 qDebug(msg);
509 QCopEnvelope ( "QPE/System", "notBusy()" ); 516 QCopEnvelope ( "QPE/System", "notBusy()" );
510 return FALSE; 517 return FALSE;
511 } 518 }
512 QCopEnvelope ( "QPE/System", "notBusy()" ); 519 QCopEnvelope ( "QPE/System", "notBusy()" );
513 return TRUE; 520 return TRUE;
514} 521}
515 522
516void OpieFtp::populateLocalView() 523void OpieFtp::populateLocalView()
517{ 524{
518 Local_View->clear(); 525 Local_View->clear();
519 currentDir.setSorting(/* QDir::Size*/ /*| QDir::Reversed | */QDir::DirsFirst); 526 currentDir.setSorting(/* QDir::Size*/ /*| QDir::Reversed | */QDir::DirsFirst);
520 currentDir.setMatchAllDirs(TRUE); 527 currentDir.setMatchAllDirs(TRUE);
521 currentDir.setNameFilter(filterStr); 528 currentDir.setNameFilter(filterStr);
522 QString fileL, fileS, fileDate; 529 QString fileL, fileS, fileDate;
523 bool isDir=FALSE; 530 bool isDir=FALSE;
524 const QFileInfoList *list = currentDir.entryInfoList( /*QDir::All*/ /*, QDir::SortByMask*/); 531 const QFileInfoList *list = currentDir.entryInfoList( /*QDir::All*/ /*, QDir::SortByMask*/);
525 QFileInfoListIterator it(*list); 532 QFileInfoListIterator it(*list);
526 QFileInfo *fi; 533 QFileInfo *fi;
527 while ( (fi=it.current()) ) { 534 while ( (fi=it.current()) ) {
528 if (fi->isSymLink() ){ 535 if (fi->isSymLink() ){
529 QString symLink=fi->readLink(); 536 QString symLink=fi->readLink();
530// qDebug("Symlink detected "+symLink); 537// qDebug("Symlink detected "+symLink);
531 QFileInfo sym( symLink); 538 QFileInfo sym( symLink);
532 fileS.sprintf( "%10li", sym.size() ); 539 fileS.sprintf( "%10li", sym.size() );
533 fileL.sprintf( "%s -> %s", sym.fileName().data(),sym.absFilePath().data() ); 540 fileL.sprintf( "%s -> %s", sym.fileName().data(),sym.absFilePath().data() );
534 fileDate = sym.lastModified().toString(); 541 fileDate = sym.lastModified().toString();
535 } else { 542 } else {
536// qDebug("Not a dir: "+currentDir.canonicalPath()+fileL); 543// qDebug("Not a dir: "+currentDir.canonicalPath()+fileL);
537 fileS.sprintf( "%10li", fi->size() ); 544 fileS.sprintf( "%10li", fi->size() );
538 fileL.sprintf( "%s",fi->fileName().data() ); 545 fileL.sprintf( "%s",fi->fileName().data() );
539 fileDate= fi->lastModified().toString(); 546 fileDate= fi->lastModified().toString();
540 if( QDir(QDir::cleanDirPath(currentDir.canonicalPath()+"/"+fileL)).exists() ) { 547 if( QDir(QDir::cleanDirPath(currentDir.canonicalPath()+"/"+fileL)).exists() ) {
541 fileL+="/"; 548 fileL+="/";
542 isDir=TRUE; 549 isDir=TRUE;
543// qDebug( fileL); 550// qDebug( fileL);
544 } 551 }
545 } 552 }
546 if(fileL !="./") { 553 if(fileL !="./") {
547 item = new QListViewItem( Local_View,fileL,fileS, fileDate); 554 item= new QListViewItem( ListView,fileL,fileS , fileDate);
548 if(isDir || fileL.find("/",0,TRUE) != -1) 555 QPixmap pm;
549 item->setPixmap( 0, Resource::loadPixmap( "folder" )); 556 pm= Resource::loadPixmap( "folder" );
550 else 557
551 item->setPixmap( 0, Resource::loadPixmap( "fileopen" )); 558 if(isDir || fileL.find("/",0,TRUE) != -1) {
559 if( !QDir( fi->filePath() ).isReadable())
560 pm = Resource::loadPixmap( "lockedfolder" );
561 item->setPixmap( 0,pm );
562 } else {
563 if( !fi->isReadable() )
564 pm = Resource::loadPixmap( "locked" );
565 else
566 pm = Resource::loadPixmap( "fileopen" );
567 item->setPixmap( 0,pm);
568 }
569 if( fileL.find("->",0,TRUE) != -1) {
570 // overlay link image
571 QPixmap lnk = Resource::loadPixmap( "symlink" );
572 QPainter painter( &pm );
573 painter.drawPixmap( pm.width()-lnk.width(), pm.height()-lnk.height(), lnk );
574 pm.setMask( pm.createHeuristicMask( FALSE ) );
575 item->setPixmap( 0, pm);
576 }
552 } 577 }
553 isDir=FALSE; 578 isDir=FALSE;
554 ++it; 579 ++it;
555 } 580 }
556 Local_View->setSorting( 3,FALSE); 581 Local_View->setSorting( 3,FALSE);
557 currentPathEdit->setText( currentDir.canonicalPath() ); 582 currentPathCombo->lineEdit()->setText( currentDir.canonicalPath() );
583 fillCombo( (const QString &)currentDir);
584
558} 585}
559 586
560bool OpieFtp::populateRemoteView( ) 587bool OpieFtp::populateRemoteView( )
561{ 588{
562// qDebug("populate remoteview"); 589// qDebug("populate remoteview");
563 QString sfile=QDir::homeDirPath(); 590 QString sfile=QDir::homeDirPath();
564 if(sfile.right(1) != "/") 591 if(sfile.right(1) != "/")
565 sfile+="/._temp"; 592 sfile+="/._temp";
566 else 593 else
567 sfile+="._temp"; 594 sfile+="._temp";
568 QFile file( sfile); 595 QFile file( sfile);
569 Remote_View->clear(); 596 Remote_View->clear();
570 QString s, File_Name; 597 QString s, File_Name;
571 QListViewItem *itemDir=NULL, *itemFile=NULL; 598 QListViewItem *itemDir=NULL, *itemFile=NULL;
572 QString fileL, fileS, fileDate; 599 QString fileL, fileS, fileDate;
573 if ( file.open(IO_ReadOnly)) { 600 if ( file.open(IO_ReadOnly)) {
574 QTextStream t( &file ); // use a text stream 601 QTextStream t( &file ); // use a text stream
575 while ( !t.eof()) { 602 while ( !t.eof()) {
576 s = t.readLine(); 603 s = t.readLine();
577 fileL = s.right(s.length()-55); 604 fileL = s.right(s.length()-55);
578 fileL = fileL.stripWhiteSpace(); 605 fileL = fileL.stripWhiteSpace();
579 if(s.left(1) == "d") 606 if(s.left(1) == "d")
580 fileL = fileL+"/"; 607 fileL = fileL+"/";
581// fileL = "/"+fileL+"/"; 608// fileL = "/"+fileL+"/";
582 fileS = s.mid( 30, 42-30); 609 fileS = s.mid( 30, 42-30);
583 fileS = fileS.stripWhiteSpace(); 610 fileS = fileS.stripWhiteSpace();
584 fileDate = s.mid( 42, 55-42); 611 fileDate = s.mid( 42, 55-42);
585 fileDate = fileDate.stripWhiteSpace(); 612 fileDate = fileDate.stripWhiteSpace();
586 if(fileL.find("total",0,TRUE) == -1) { 613 if(fileL.find("total",0,TRUE) == -1) {
587 if(s.left(1) == "d" || fileL.find("/",0,TRUE) != -1) { 614 if(s.left(1) == "d" || fileL.find("/",0,TRUE) != -1) {
588 QListViewItem * item = new QListViewItem( Remote_View, fileL, fileS, fileDate,"d"); 615 QListViewItem * item = new QListViewItem( Remote_View, fileL, fileS, fileDate,"d");
589 item->setPixmap( 0, Resource::loadPixmap( "folder" )); 616 item->setPixmap( 0, Resource::loadPixmap( "folder" ));
590// if(itemDir) 617// if(itemDir)
591 item->moveItem(itemDir); 618 item->moveItem(itemDir);
592 itemDir=item; 619 itemDir=item;
593 } else { 620 } else {
594 QListViewItem * item = new QListViewItem( Remote_View, fileL, fileS, fileDate,"f"); 621 QListViewItem * item = new QListViewItem( Remote_View, fileL, fileS, fileDate,"f");
595 item->setPixmap( 0, Resource::loadPixmap( "fileopen" )); 622 item->setPixmap( 0, Resource::loadPixmap( "fileopen" ));
596// if(itemFile) 623// if(itemFile)
597 item->moveItem(itemDir); 624 item->moveItem(itemDir);
598 item->moveItem(itemFile); 625 item->moveItem(itemFile);
599 itemFile=item; 626 itemFile=item;
600 } 627 }
601 } 628 }
602 } 629 }
603 QListViewItem * item1 = new QListViewItem( Remote_View, "../"); 630 QListViewItem * item1 = new QListViewItem( Remote_View, "../");
604 item1->setPixmap( 0, Resource::loadPixmap( "folder" )); 631 item1->setPixmap( 0, Resource::loadPixmap( "folder" ));
605 file.close(); 632 file.close();
606 if( file.exists()) 633 if( file.exists())
607 file. remove(); 634 file. remove();
608 } else 635 } else
609 qDebug("temp file not opened successfullly "+sfile); 636 qDebug("temp file not opened successfullly "+sfile);
610 Remote_View->setSorting( 4,TRUE); 637 Remote_View->setSorting( 4,TRUE);
611 return true; 638 return true;
612} 639}
613 640
614void OpieFtp::remoteListClicked(QListViewItem *selectedItem) 641void OpieFtp::remoteListClicked(QListViewItem *selectedItem)
615{ 642{
616 QCopEnvelope ( "QPE/System", "busy()" ); 643 QCopEnvelope ( "QPE/System", "busy()" );
617 QString oldRemoteCurrentDir = currentRemoteDir; 644 QString oldRemoteCurrentDir = currentRemoteDir;
618 QString strItem=selectedItem->text(0); 645 QString strItem=selectedItem->text(0);
619 strItem=strItem.simplifyWhiteSpace(); 646 strItem=strItem.simplifyWhiteSpace();
620 if(strItem == "../") { // the user wants to go ^ 647 if(strItem == "../") { // the user wants to go ^
621 if( FtpCDUp( conn) == 0) { 648 if( FtpCDUp( conn) == 0) {
622 QString msg; 649 QString msg;
623 msg.sprintf(tr("Unable to cd up\n")+"%s",FtpLastResponse(conn)); 650 msg.sprintf(tr("Unable to cd up\n")+"%s",FtpLastResponse(conn));
624 msg.replace(QRegExp(":"),"\n"); 651 msg.replace(QRegExp(":"),"\n");
625 QMessageBox::message(tr("Note"),msg); 652 QMessageBox::message(tr("Note"),msg);
626 qDebug(msg); 653 qDebug(msg);
627 } 654 }
628 char path[256]; 655 char path[256];
629 if( FtpPwd( path,sizeof(path),conn) == 0) { //this is easier than fudging the string 656 if( FtpPwd( path,sizeof(path),conn) == 0) { //this is easier than fudging the string
630 QString msg; 657 QString msg;
631 msg.sprintf(tr("Unable to get working dir\n")+"%s",FtpLastResponse(conn)); 658 msg.sprintf(tr("Unable to get working dir\n")+"%s",FtpLastResponse(conn));
632 msg.replace(QRegExp(":"),"\n"); 659 msg.replace(QRegExp(":"),"\n");
633 QMessageBox::message(tr("Note"),msg); 660 QMessageBox::message(tr("Note"),msg);
634 qDebug(msg); 661 qDebug(msg);
635 } 662 }
636 currentRemoteDir=path; 663 currentRemoteDir=path;
637 } else { 664 } else {
638 if(strItem.find("->",0,TRUE) != -1) { //symlink on some servers 665 if(strItem.find("->",0,TRUE) != -1) { //symlink on some servers
639 strItem=strItem.right( strItem.length() - strItem.find("->",0,TRUE) - 2 ); 666 strItem=strItem.right( strItem.length() - strItem.find("->",0,TRUE) - 2 );
640 strItem = strItem.stripWhiteSpace(); 667 strItem = strItem.stripWhiteSpace();
641 currentRemoteDir = strItem; 668 currentRemoteDir = strItem;
642 if( !remoteChDir( (const QString &)strItem)) { 669 if( !remoteChDir( (const QString &)strItem)) {
643 currentRemoteDir = oldRemoteCurrentDir; 670 currentRemoteDir = oldRemoteCurrentDir;
644 strItem=""; 671 strItem="";
645 qDebug("RemoteCurrentDir1 "+oldRemoteCurrentDir); 672 qDebug("RemoteCurrentDir1 "+oldRemoteCurrentDir);
646 } 673 }
647 } else if(strItem.find("/",0,TRUE) != -1) { // this is a directory 674 } else if(strItem.find("/",0,TRUE) != -1) { // this is a directory
648 qDebug("trying directory"); 675 qDebug("trying directory");
649 if( !remoteChDir( (const QString &)currentRemoteDir + strItem)) { 676 if( !remoteChDir( (const QString &)currentRemoteDir + strItem)) {
650 currentRemoteDir = oldRemoteCurrentDir; 677 currentRemoteDir = oldRemoteCurrentDir;
651 strItem=""; 678 strItem="";
652 qDebug("RemoteCurrentDir1 "+oldRemoteCurrentDir); 679 qDebug("RemoteCurrentDir1 "+oldRemoteCurrentDir);
653 680
654 } else { 681 } else {
655 currentRemoteDir = currentRemoteDir+strItem; 682 currentRemoteDir = currentRemoteDir+strItem;
656 } 683 }
657 } else { 684 } else {
658 qDebug("download "+strItem); 685 qDebug("download "+strItem);
659 } 686 }
660 } 687 }
661 remoteDirList( (const QString &)currentRemoteDir); //this also calls populate 688 remoteDirList( (const QString &)currentRemoteDir); //this also calls populate
662 if(currentRemoteDir.right(1) !="/") 689 if(currentRemoteDir.right(1) !="/")
663 currentRemoteDir +="/"; 690 currentRemoteDir +="/";
664 currentPathEdit->setText( currentRemoteDir ); 691 currentPathCombo->lineEdit()->setText( currentRemoteDir );
692 fillRemoteCombo( (const QString &)currentDir);
665 QCopEnvelope ( "QPE/System", "notBusy()" ); 693 QCopEnvelope ( "QPE/System", "notBusy()" );
666} 694}
667 695
668void OpieFtp::localListClicked(QListViewItem *selectedItem) 696void OpieFtp::localListClicked(QListViewItem *selectedItem)
669{ 697{
670 QString strItem=selectedItem->text(0); 698 QString strItem=selectedItem->text(0);
671 QString strSize=selectedItem->text(1); 699 QString strSize=selectedItem->text(1);
672 strSize=strSize.stripWhiteSpace(); 700 strSize=strSize.stripWhiteSpace();
673 if(strItem.find("@",0,TRUE) !=-1 || strItem.find("->",0,TRUE) !=-1 ) { //if symlink 701 if(strItem.find("@",0,TRUE) !=-1 || strItem.find("->",0,TRUE) !=-1 ) { //if symlink
674 // is symlink 702 // is symlink
675 QString strItem2 = strItem.right( (strItem.length() - strItem.find("->",0,TRUE)) - 4); 703 QString strItem2 = strItem.right( (strItem.length() - strItem.find("->",0,TRUE)) - 4);
676 if(QDir(strItem2).exists() ) { 704 if(QDir(strItem2).exists() ) {
677 currentDir.cd(strItem2, TRUE); 705 currentDir.cd(strItem2, TRUE);
678 populateLocalView(); 706 populateLocalView();
679 } 707 }
680 } else { // not a symlink 708 } else { // not a symlink
681 if(strItem.find(". .",0,TRUE) && strItem.find("/",0,TRUE)!=-1 ) { 709 if(strItem.find(". .",0,TRUE) && strItem.find("/",0,TRUE)!=-1 ) {
682 if(QDir(QDir::cleanDirPath(currentDir.canonicalPath()+"/"+strItem)).exists() ) { 710 if(QDir(QDir::cleanDirPath(currentDir.canonicalPath()+"/"+strItem)).exists() ) {
683 strItem=QDir::cleanDirPath(currentDir.canonicalPath()+"/"+strItem); 711 strItem=QDir::cleanDirPath(currentDir.canonicalPath()+"/"+strItem);
684 currentDir.cd(strItem,FALSE); 712 currentDir.cd(strItem,FALSE);
685 populateLocalView(); 713 populateLocalView();
686 } else { 714 } else {
687 currentDir.cdUp(); 715 currentDir.cdUp();
688 populateLocalView(); 716 populateLocalView();
689 } 717 }
690 if(QDir(strItem).exists()){ 718 if(QDir(strItem).exists()){
691 currentDir.cd(strItem, TRUE); 719 currentDir.cd(strItem, TRUE);
692 populateLocalView(); 720 populateLocalView();
693 } 721 }
694 } else { 722 } else {
695 strItem=QDir::cleanDirPath(currentDir.canonicalPath()+"/"+strItem); 723 strItem=QDir::cleanDirPath(currentDir.canonicalPath()+"/"+strItem);
696 if( QFile::exists(strItem ) ) { 724 if( QFile::exists(strItem ) ) {
697 qDebug("upload "+strItem); 725 qDebug("upload "+strItem);
698 } 726 }
699 } //end not symlink 727 } //end not symlink
700 chdir(strItem.latin1()); 728 chdir(strItem.latin1());
701 } 729 }
702} 730}
703 731
704void OpieFtp::doLocalCd() 732void OpieFtp::doLocalCd()
705{ 733{
706 localListClicked( Local_View->currentItem()); 734 localListClicked( Local_View->currentItem());
707} 735}
708 736
709void OpieFtp:: doRemoteCd() 737void OpieFtp:: doRemoteCd()
710{ 738{
711 remoteListClicked( Remote_View->currentItem()); 739 remoteListClicked( Remote_View->currentItem());
712 740
713} 741}
714 742
715void OpieFtp::showHidden() 743void OpieFtp::showHidden()
716{ 744{
717 if (!b) { 745 if (!b) {
718 currentDir.setFilter( QDir::Files | QDir::Dirs | QDir::Hidden | QDir::All); 746 currentDir.setFilter( QDir::Files | QDir::Dirs | QDir::Hidden | QDir::All);
719 localMenu->setItemChecked(localMenu->idAt(0),TRUE); 747 localMenu->setItemChecked(localMenu->idAt(0),TRUE);
720// currentDir.setSorting(/* QDir::Size*/ /*| QDir::Reversed | */QDir::DirsFirst); 748// currentDir.setSorting(/* QDir::Size*/ /*| QDir::Reversed | */QDir::DirsFirst);
721 b=TRUE; 749 b=TRUE;
722 750
723 } else { 751 } else {
724 currentDir.setFilter( QDir::Files | QDir::Dirs/* | QDir::Hidden*/ | QDir::All); 752 currentDir.setFilter( QDir::Files | QDir::Dirs/* | QDir::Hidden*/ | QDir::All);
725 localMenu->setItemChecked(localMenu->idAt(0),FALSE); 753 localMenu->setItemChecked(localMenu->idAt(0),FALSE);
726// currentDir.setSorting(/* QDir::Size*/ /*| QDir::Reversed | */QDir::DirsFirst); 754// currentDir.setSorting(/* QDir::Size*/ /*| QDir::Reversed | */QDir::DirsFirst);
727 b=FALSE; 755 b=FALSE;
728 } 756 }
729 populateLocalView(); 757 populateLocalView();
730} 758}
731 759
732void OpieFtp::ListPressed( int mouse, QListViewItem *item, const QPoint &point, int i) 760void OpieFtp::ListPressed( int mouse, QListViewItem *item, const QPoint &point, int i)
733{ 761{
734 switch (mouse) { 762 switch (mouse) {
735 case 1: 763 case 1:
736 break; 764 break;
737 case 2: 765 case 2:
738 showLocalMenu(item); 766 showLocalMenu(item);
739 break; 767 break;
740 }; 768 };
741} 769}
742 770
743void OpieFtp::RemoteListPressed( int mouse, QListViewItem *item, const QPoint &point, int i) 771void OpieFtp::RemoteListPressed( int mouse, QListViewItem *item, const QPoint &point, int i)
744{ 772{
745 switch (mouse) { 773 switch (mouse) {
746 case 1: 774 case 1:
747 break; 775 break;
748 case 2: 776 case 2:
749 showRemoteMenu(item); 777 showRemoteMenu(item);
750 break; 778 break;
751 }; 779 };
752} 780}
753 781
754void OpieFtp::showRemoteMenu(QListViewItem * item) 782void OpieFtp::showRemoteMenu(QListViewItem * item)
755{ 783{
756 QPopupMenu m;// = new QPopupMenu( Local_View ); 784 QPopupMenu m;// = new QPopupMenu( Local_View );
757 if( /*item->text(0).right(1) == "/" ||*/ item->text(0).find("/",0,TRUE) != -1) 785 if( /*item->text(0).right(1) == "/" ||*/ item->text(0).find("/",0,TRUE) != -1)
758 m.insertItem( tr( "Change Directory" ), this, SLOT( doRemoteCd() )); 786 m.insertItem( tr( "Change Directory" ), this, SLOT( doRemoteCd() ));
759 else 787 else
760 m.insertItem( tr( "Download" ), this, SLOT( remoteDownload() )); 788 m.insertItem( tr( "Download" ), this, SLOT( remoteDownload() ));
761 m.insertItem( tr( "Make Directory" ), this, SLOT( remoteMakDir() )); 789 m.insertItem( tr( "Make Directory" ), this, SLOT( remoteMakDir() ));
762 m.insertItem( tr( "Rename" ), this, SLOT( remoteRename() )); 790 m.insertItem( tr( "Rename" ), this, SLOT( remoteRename() ));
763 m.insertSeparator(); 791 m.insertSeparator();
764 m.insertItem( tr( "Delete" ), this, SLOT( remoteDelete() )); 792 m.insertItem( tr( "Delete" ), this, SLOT( remoteDelete() ));
765 m.exec( QCursor::pos() ); 793 m.exec( QCursor::pos() );
766} 794}
767 795
768void OpieFtp::showLocalMenu(QListViewItem * item) 796void OpieFtp::showLocalMenu(QListViewItem * item)
769{ 797{
770 QPopupMenu m; 798 QPopupMenu m;
771 m.insertItem( tr( "Show Hidden Files" ), this, SLOT( showHidden() )); 799 m.insertItem( tr( "Show Hidden Files" ), this, SLOT( showHidden() ));
772 m.insertSeparator(); 800 m.insertSeparator();
773 if( /*item->text(0).right(1) == "/" ||*/ item->text(0).find("/",0,TRUE) !=-1) 801 if( /*item->text(0).right(1) == "/" ||*/ item->text(0).find("/",0,TRUE) !=-1)
774 m.insertItem( tr( "Change Directory" ), this, SLOT( doLocalCd() )); 802 m.insertItem( tr( "Change Directory" ), this, SLOT( doLocalCd() ));
775 else 803 else
776 m.insertItem( tr( "Upload" ), this, SLOT( localUpload() )); 804 m.insertItem( tr( "Upload" ), this, SLOT( localUpload() ));
777 m.insertItem( tr( "Make Directory" ), this, SLOT( localMakDir() )); 805 m.insertItem( tr( "Make Directory" ), this, SLOT( localMakDir() ));
778 m.insertItem( tr( "Rename" ), this, SLOT( localRename() )); 806 m.insertItem( tr( "Rename" ), this, SLOT( localRename() ));
779 m.insertSeparator(); 807 m.insertSeparator();
780 m.insertItem( tr( "Delete" ), this, SLOT( localDelete() )); 808 m.insertItem( tr( "Delete" ), this, SLOT( localDelete() ));
781 m.setCheckable(TRUE); 809 m.setCheckable(TRUE);
782 if (b) 810 if (b)
783 m.setItemChecked(m.idAt(0),TRUE); 811 m.setItemChecked(m.idAt(0),TRUE);
784 else 812 else
785 m.setItemChecked(m.idAt(0),FALSE); 813 m.setItemChecked(m.idAt(0),FALSE);
786 814
787 m.exec( QCursor::pos() ); 815 m.exec( QCursor::pos() );
788} 816}
789 817
790void OpieFtp::localMakDir() 818void OpieFtp::localMakDir()
791{ 819{
792 InputDialog *fileDlg; 820 InputDialog *fileDlg;
793 fileDlg = new InputDialog(this,tr("Make Directory"),TRUE, 0); 821 fileDlg = new InputDialog(this,tr("Make Directory"),TRUE, 0);
794 fileDlg->exec(); 822 fileDlg->exec();
795 if( fileDlg->result() == 1 ) { 823 if( fileDlg->result() == 1 ) {
796 QString filename = fileDlg->LineEdit1->text(); 824 QString filename = fileDlg->LineEdit1->text();
797 currentDir.mkdir( currentDir.canonicalPath()+"/"+filename); 825 currentDir.mkdir( currentDir.canonicalPath()+"/"+filename);
798 } 826 }
799 populateLocalView(); 827 populateLocalView();
800} 828}
801 829
802void OpieFtp::localDelete() 830void OpieFtp::localDelete()
803{ 831{
804 QString f = Local_View->currentItem()->text(0); 832 QString f = Local_View->currentItem()->text(0);
805 if(QDir(f).exists() ) { 833 if(QDir(f).exists() ) {
806 switch ( QMessageBox::warning(this,tr("Delete"),tr("Do you really want to delete\n")+f+ 834 switch ( QMessageBox::warning(this,tr("Delete"),tr("Do you really want to delete\n")+f+
807 tr(" ?\nIt must be empty"),tr("Yes"),tr("No"),0,0,1) ) { 835 tr(" ?\nIt must be empty"),tr("Yes"),tr("No"),0,0,1) ) {
808 case 0: { 836 case 0: {
809 f=currentDir.canonicalPath()+"/"+f; 837 f=currentDir.canonicalPath()+"/"+f;
810 QString cmd="rmdir "+f; 838 QString cmd="rmdir "+f;
811 system( cmd.latin1()); 839 system( cmd.latin1());
812 populateLocalView(); 840 populateLocalView();
813 } 841 }
814 break; 842 break;
815 case 1: 843 case 1:
816 // exit 844 // exit
817 break; 845 break;
818 }; 846 };
819 847
820 } else { 848 } else {
821 switch ( QMessageBox::warning(this,tr("Delete"),tr("Do you really want to delete\n")+f 849 switch ( QMessageBox::warning(this,tr("Delete"),tr("Do you really want to delete\n")+f
822 +" ?",tr("Yes"),tr("No"),0,0,1) ) { 850 +" ?",tr("Yes"),tr("No"),0,0,1) ) {
823 case 0: { 851 case 0: {
824 f=currentDir.canonicalPath()+"/"+f; 852 f=currentDir.canonicalPath()+"/"+f;
825 QString cmd="rm "+f; 853 QString cmd="rm "+f;
826 system( cmd.latin1()); 854 system( cmd.latin1());
827 populateLocalView(); 855 populateLocalView();
828 } 856 }
829 break; 857 break;
830 case 1: 858 case 1:
831 // exit 859 // exit
832 break; 860 break;
833 }; 861 };
834 } 862 }
835} 863}
836 864
837void OpieFtp::remoteMakDir() 865void OpieFtp::remoteMakDir()
838{ 866{
839 InputDialog *fileDlg; 867 InputDialog *fileDlg;
840 fileDlg = new InputDialog(this,tr("Make Directory"),TRUE, 0); 868 fileDlg = new InputDialog(this,tr("Make Directory"),TRUE, 0);
841 fileDlg->exec(); 869 fileDlg->exec();
842 if( fileDlg->result() == 1 ) { 870 if( fileDlg->result() == 1 ) {
843 QString filename = fileDlg->LineEdit1->text();//+".playlist"; 871 QString filename = fileDlg->LineEdit1->text();//+".playlist";
844 QString tmp=currentRemoteDir+filename; 872 QString tmp=currentRemoteDir+filename;
845 QCopEnvelope ( "QPE/System", "busy()" ); 873 QCopEnvelope ( "QPE/System", "busy()" );
846 if(FtpMkdir( tmp.latin1(), conn) == 0) { 874 if(FtpMkdir( tmp.latin1(), conn) == 0) {
847 QString msg; 875 QString msg;
848 msg.sprintf(tr("Unable to make directory\n")+"%s",FtpLastResponse(conn)); 876 msg.sprintf(tr("Unable to make directory\n")+"%s",FtpLastResponse(conn));
849 msg.replace(QRegExp(":"),"\n"); 877 msg.replace(QRegExp(":"),"\n");
850 QMessageBox::message(tr("Note"),msg); 878 QMessageBox::message(tr("Note"),msg);
851 } 879 }
852 QCopEnvelope ( "QPE/System", "notBusy()" ); 880 QCopEnvelope ( "QPE/System", "notBusy()" );
853 remoteDirList( (const QString &)currentRemoteDir); //this also calls populate 881 remoteDirList( (const QString &)currentRemoteDir); //this also calls populate
854 } 882 }
855} 883}
856 884
857void OpieFtp::remoteDelete() 885void OpieFtp::remoteDelete()
858{ 886{
859 QString f = Remote_View->currentItem()->text(0); 887 QString f = Remote_View->currentItem()->text(0);
860 QCopEnvelope ( "QPE/System", "busy()" ); 888 QCopEnvelope ( "QPE/System", "busy()" );
861 if( f.right(1) =="/") { 889 if( f.right(1) =="/") {
862 QString path= currentRemoteDir+f; 890 QString path= currentRemoteDir+f;
863 switch ( QMessageBox::warning(this,tr("Delete"),tr("Do you really want to delete\n")+f+"?" 891 switch ( QMessageBox::warning(this,tr("Delete"),tr("Do you really want to delete\n")+f+"?"
864 ,tr("Yes"),tr("No"),0,0,1) ) { 892 ,tr("Yes"),tr("No"),0,0,1) ) {
865 case 0: { 893 case 0: {
866 f=currentDir.canonicalPath()+"/"+f; 894 f=currentDir.canonicalPath()+"/"+f;
867 if(FtpRmdir( path.latin1(), conn) ==0) { 895 if(FtpRmdir( path.latin1(), conn) ==0) {
868 QString msg; 896 QString msg;
869 msg.sprintf(tr("Unable to remove directory\n")+"%s",FtpLastResponse(conn)); 897 msg.sprintf(tr("Unable to remove directory\n")+"%s",FtpLastResponse(conn));
870 msg.replace(QRegExp(":"),"\n"); 898 msg.replace(QRegExp(":"),"\n");
871 QMessageBox::message(tr("Note"),msg); 899 QMessageBox::message(tr("Note"),msg);
872 } 900 }
873 remoteDirList( (const QString &)currentRemoteDir); //this also calls populate 901 remoteDirList( (const QString &)currentRemoteDir); //this also calls populate
874 902
875 } 903 }
876 break; 904 break;
877 }; 905 };
878 } else { 906 } else {
879 switch ( QMessageBox::warning(this,tr("Delete"),tr("Do you really want to delete\n")+f+"?" 907 switch ( QMessageBox::warning(this,tr("Delete"),tr("Do you really want to delete\n")+f+"?"
880 ,tr("Yes"),tr("No"),0,0,1) ) { 908 ,tr("Yes"),tr("No"),0,0,1) ) {
881 case 0: { 909 case 0: {
882 QString path= currentRemoteDir+f; 910 QString path= currentRemoteDir+f;
883 if(FtpDelete( path.latin1(), conn)==0) { 911 if(FtpDelete( path.latin1(), conn)==0) {
884 QString msg; 912 QString msg;
885 msg.sprintf(tr("Unable to delete file\n")+"%s",FtpLastResponse(conn)); 913 msg.sprintf(tr("Unable to delete file\n")+"%s",FtpLastResponse(conn));
886 msg.replace(QRegExp(":"),"\n"); 914 msg.replace(QRegExp(":"),"\n");
887 QMessageBox::message(tr("Note"),msg); 915 QMessageBox::message(tr("Note"),msg);
888 } 916 }
889 remoteDirList( (const QString &)currentRemoteDir); //this also calls populate 917 remoteDirList( (const QString &)currentRemoteDir); //this also calls populate
890 } 918 }
891 break; 919 break;
892 }; 920 };
893 } 921 }
894 QCopEnvelope ( "QPE/System", "notBusy()" ); 922 QCopEnvelope ( "QPE/System", "notBusy()" );
895} 923}
896 924
897void OpieFtp::remoteRename() 925void OpieFtp::remoteRename()
898{ 926{
899 QString curFile = Remote_View->currentItem()->text(0); 927 QString curFile = Remote_View->currentItem()->text(0);
900 InputDialog *fileDlg; 928 InputDialog *fileDlg;
901 fileDlg = new InputDialog(this,tr("Rename"),TRUE, 0); 929 fileDlg = new InputDialog(this,tr("Rename"),TRUE, 0);
902 fileDlg->inputText = curFile; 930 fileDlg->inputText = curFile;
903 fileDlg->exec(); 931 fileDlg->exec();
904 if( fileDlg->result() == 1 ) { 932 if( fileDlg->result() == 1 ) {
905 QString oldName = currentRemoteDir +"/"+ curFile; 933 QString oldName = currentRemoteDir +"/"+ curFile;
906 QString newName = currentRemoteDir +"/"+ fileDlg->LineEdit1->text();//+".playlist"; 934 QString newName = currentRemoteDir +"/"+ fileDlg->LineEdit1->text();//+".playlist";
907 QCopEnvelope ( "QPE/System", "busy()" ); 935 QCopEnvelope ( "QPE/System", "busy()" );
908 if(FtpRename( oldName.latin1(), newName.latin1(),conn) == 0) { 936 if(FtpRename( oldName.latin1(), newName.latin1(),conn) == 0) {
909 QString msg; 937 QString msg;
910 msg.sprintf(tr("Unable to rename file\n")+"%s",FtpLastResponse(conn)); 938 msg.sprintf(tr("Unable to rename file\n")+"%s",FtpLastResponse(conn));
911 msg.replace(QRegExp(":"),"\n"); 939 msg.replace(QRegExp(":"),"\n");
912 QMessageBox::message(tr("Note"),msg); 940 QMessageBox::message(tr("Note"),msg);
913 } 941 }
914 QCopEnvelope ( "QPE/System", "notBusy()" ); 942 QCopEnvelope ( "QPE/System", "notBusy()" );
915 remoteDirList( (const QString &)currentRemoteDir); //this also calls populate 943 remoteDirList( (const QString &)currentRemoteDir); //this also calls populate
916 } 944 }
917} 945}
918 946
919void OpieFtp::localRename() 947void OpieFtp::localRename()
920{ 948{
921 QString curFile = Local_View->currentItem()->text(0); 949 QString curFile = Local_View->currentItem()->text(0);
922 InputDialog *fileDlg; 950 InputDialog *fileDlg;
923 fileDlg = new InputDialog(this,tr("Rename"),TRUE, 0); 951 fileDlg = new InputDialog(this,tr("Rename"),TRUE, 0);
924 fileDlg->inputText = curFile; 952 fileDlg->inputText = curFile;
925 fileDlg->exec(); 953 fileDlg->exec();
926 if( fileDlg->result() == 1 ) { 954 if( fileDlg->result() == 1 ) {
927 QString oldname = currentDir.canonicalPath() + "/" + curFile; 955 QString oldname = currentDir.canonicalPath() + "/" + curFile;
928 QString newName = currentDir.canonicalPath() + "/" + fileDlg->LineEdit1->text();//+".playlist"; 956 QString newName = currentDir.canonicalPath() + "/" + fileDlg->LineEdit1->text();//+".playlist";
929 if( rename(oldname.latin1(), newName.latin1())== -1) 957 if( rename(oldname.latin1(), newName.latin1())== -1)
930 QMessageBox::message(tr("Note"),tr("Could not rename")); 958 QMessageBox::message(tr("Note"),tr("Could not rename"));
931 } 959 }
932 populateLocalView(); 960 populateLocalView();
933} 961}
934 962
935void OpieFtp::currentPathEditChanged() 963void OpieFtp::currentPathComboActivated(const QString & currentPath) {
964 if (TabWidget->currentPageIndex() == 0) {
965 chdir( currentPath.latin1() );
966 currentDir.cd( currentPath, TRUE);
967 populateLocalList();
968 update();
969 } else {
970// chdir( currentPath.latin1() );
971// currentDir.cd( currentPath, TRUE);
972// populateList();
973// update();
974
975 }
976}
977
978void OpieFtp::fillCombo(const QString &currentPath) {
979
980 currentPathComboBox->lineEdit()->setText(currentPath);
981 if( localDirPathStringList.grep(currentPath,TRUE).isEmpty() ) {
982 currentPathComboBox->clear();
983 localDirPathStringList.prepend(currentPath );
984 currentPathComboBox->insertStringList( localDirPathStringList,-1);
985 }
986 currentPathComboBox->lineEdit()->setText(currentPath);
987 if( remoteDirPathStringList.grep(currentPath,TRUE).isEmpty() ) {
988 currentPathComboBox->clear();
989 remoteDirPathStringList.prepend(currentPath );
990 currentPathComboBox->insertStringList( remoteDirPathStringList,-1);
991 }
992}
993
994void OpieFtp::fillRemoteCombo(const QString &currentPath) {
995
996 dirPathCombo->lineEdit()->setText(currentPath);
997 if( remoteDirPathStringList.grep(currentPath,TRUE).isEmpty() ) {
998 dirPathCombo->clear();
999 remoteDirPathStringList.prepend(currentPath );
1000 dirPathCombo->insertStringList( remoteDirPathStringList,-1);
1001 }
1002}
1003
1004void OpieFtp::currentPathComboChanged()
936{ 1005{
937 QString oldRemoteCurrentDir = currentRemoteDir; 1006 QString oldRemoteCurrentDir = currentRemoteDir;
938// qDebug("oldRemoteCurrentDir "+oldRemoteCurrentDir); 1007// qDebug("oldRemoteCurrentDir "+oldRemoteCurrentDir);
939 if (TabWidget->currentPageIndex() == 0) { 1008 if (TabWidget->currentPageIndex() == 0) {
940 if(QDir( currentPathEdit->text()).exists()) { 1009 if(QDir( currentPathCombo->lineEdit()->text()).exists()) {
941 currentDir.setPath( currentPathEdit->text() ); 1010 currentDir.setPath( currentPathCombo->lineEdit()->text() );
942 populateLocalView(); 1011 populateLocalView();
943 } else { 1012 } else {
944 QMessageBox::message(tr("Note"),tr("That directory does not exist")); 1013 QMessageBox::message(tr("Note"),tr("That directory does not exist"));
945 } 1014 }
946 } 1015 }
947 if (TabWidget->currentPageIndex() == 1) { 1016 if (TabWidget->currentPageIndex() == 1) {
948 currentRemoteDir = currentPathEdit->text(); 1017 currentRemoteDir = currentPathCombo->lineEdit()->text();
949 if(currentRemoteDir.right(1) !="/") { 1018 if(currentRemoteDir.right(1) !="/") {
950 currentRemoteDir = currentRemoteDir +"/"; 1019 currentRemoteDir = currentRemoteDir +"/";
951 currentPathEdit->setText( currentRemoteDir ); 1020 currentPathCombo->lineEdit()->setText( currentRemoteDir );
952 } 1021 }
953 if( !remoteChDir( (const QString &)currentRemoteDir) ) { 1022 if( !remoteChDir( (const QString &)currentRemoteDir) ) {
954 currentRemoteDir = oldRemoteCurrentDir; 1023 currentRemoteDir = oldRemoteCurrentDir;
955 currentPathEdit->setText( currentRemoteDir ); 1024 currentPathCombo->lineEdit()->setText( currentRemoteDir );
956 } 1025 }
957 1026
958 remoteDirList( (const QString &)currentRemoteDir); 1027 remoteDirList( (const QString &)currentRemoteDir);
959 } 1028 }
960} 1029}
961 1030
962void OpieFtp::switchToLocalTab() 1031void OpieFtp::switchToLocalTab()
963{ 1032{
964 TabWidget->setCurrentPage(0); 1033 TabWidget->setCurrentPage(0);
965} 1034}
966 1035
967void OpieFtp::switchToRemoteTab() 1036void OpieFtp::switchToRemoteTab()
968{ 1037{
969 TabWidget->setCurrentPage(1); 1038 TabWidget->setCurrentPage(1);
970} 1039}
971 1040
972void OpieFtp::switchToConfigTab() 1041void OpieFtp::switchToConfigTab()
973{ 1042{
974 TabWidget->setCurrentPage(2); 1043 TabWidget->setCurrentPage(2);
975} 1044}
976 1045
977void OpieFtp::readConfig() 1046void OpieFtp::readConfig()
978{ 1047{
979 fillCombos(); 1048 fillCombos();
980 Config cfg("opieftp"); 1049 Config cfg("opieftp");
981 cfg.setGroup("Server"); 1050 cfg.setGroup("Server");
982 currentServerConfig = cfg.readNumEntry("currentServer", -1); 1051 currentServerConfig = cfg.readNumEntry("currentServer", -1);
983 serverComboSelected( currentServerConfig); 1052 serverComboSelected( currentServerConfig);
984} 1053}
985 1054
986void OpieFtp::writeConfig() 1055void OpieFtp::writeConfig()
987{ 1056{
988 1057
989 Config cfg("opieftp"); 1058 Config cfg("opieftp");
990 cfg.setGroup("Server"); 1059 cfg.setGroup("Server");
991 QString username, remoteServerStr, remotePathStr, password, port, temp; 1060 QString username, remoteServerStr, remotePathStr, password, port, temp;
992 int numberOfEntries = cfg.readNumEntry("numberOfEntries",0); 1061 int numberOfEntries = cfg.readNumEntry("numberOfEntries",0);
993 if( currentServerConfig == -1) { 1062 if( currentServerConfig == -1) {
994 1063
995 temp.setNum( numberOfEntries + 1); 1064 temp.setNum( numberOfEntries + 1);
996 cfg.setGroup("Server"); 1065 cfg.setGroup("Server");
997 remoteServerStr = cfg.readEntry( temp,""); 1066 remoteServerStr = cfg.readEntry( temp,"");
998 int divider = remoteServerStr.length() - remoteServerStr.find(":",0,TRUE); 1067 int divider = remoteServerStr.length() - remoteServerStr.find(":",0,TRUE);
999 remoteServerStr = remoteServerStr.left(remoteServerStr.length()-divider); 1068 remoteServerStr = remoteServerStr.left(remoteServerStr.length()-divider);
1000 1069
1001 temp.setNum(numberOfEntries+1); 1070 temp.setNum(numberOfEntries+1);
1002 cfg.setGroup("Server"); 1071 cfg.setGroup("Server");
1003 cfg.writeEntry( temp, ServerComboBox->currentText() +":"+PortSpinBox->cleanText() ); 1072 cfg.writeEntry( temp, ServerComboBox->currentText() +":"+PortSpinBox->cleanText() );
1004 cfg.setGroup(temp); 1073 cfg.setGroup(temp);
1005 cfg.writeEntry("RemotePath", remotePath->text()); 1074 cfg.writeEntry("RemotePath", remotePath->text());
1006 cfg.writeEntry("Username", UsernameComboBox->currentText()); 1075 cfg.writeEntry("Username", UsernameComboBox->currentText());
1007 cfg.writeEntryCrypt( UsernameComboBox->currentText(), PasswordEdit->text()); 1076 cfg.writeEntryCrypt( UsernameComboBox->currentText(), PasswordEdit->text());
1008 cfg.setGroup("Server"); 1077 cfg.setGroup("Server");
1009 cfg.writeEntry("numberOfEntries", QString::number(numberOfEntries + 1 )); 1078 cfg.writeEntry("numberOfEntries", QString::number(numberOfEntries + 1 ));
1010 1079
1011 } 1080 }
1012} 1081}
1013 1082
1014void OpieFtp::fillCombos() 1083void OpieFtp::fillCombos()
1015{ 1084{
1016 Config cfg("opieftp"); 1085 Config cfg("opieftp");
1017 cfg.setGroup("Server"); 1086 cfg.setGroup("Server");
1018 QString username, remoteServerStr, remotePathStr, password, port, temp; 1087 QString username, remoteServerStr, remotePathStr, password, port, temp;
1019 int numberOfEntries = cfg.readNumEntry("numberOfEntries",0); 1088 int numberOfEntries = cfg.readNumEntry("numberOfEntries",0);
1020 for (int i = 1; i <= numberOfEntries; i++) { 1089 for (int i = 1; i <= numberOfEntries; i++) {
1021 temp.setNum(i); 1090 temp.setNum(i);
1022 cfg.setGroup("Server"); 1091 cfg.setGroup("Server");
1023 remoteServerStr = cfg.readEntry( temp,""); 1092 remoteServerStr = cfg.readEntry( temp,"");
1024 int divider = remoteServerStr.length() - remoteServerStr.find(":",0,TRUE); 1093 int divider = remoteServerStr.length() - remoteServerStr.find(":",0,TRUE);
1025 port = remoteServerStr.right( divider - 1); 1094 port = remoteServerStr.right( divider - 1);
1026 bool ok; 1095 bool ok;
1027 PortSpinBox->setValue( port.toInt(&ok,10)); 1096 PortSpinBox->setValue( port.toInt(&ok,10));
1028 1097
1029 remoteServerStr = remoteServerStr.left(remoteServerStr.length()-divider); 1098 remoteServerStr = remoteServerStr.left(remoteServerStr.length()-divider);
1030 ServerComboBox->insertItem( remoteServerStr ); 1099 ServerComboBox->insertItem( remoteServerStr );
1031// cfg.setGroup(temp); 1100// cfg.setGroup(temp);
1032 1101
1033// remotePathStr = cfg.readEntry(remoteServer,""); 1102// remotePathStr = cfg.readEntry(remoteServer,"");
1034// int divider = remoteServer.length() - remoteServer.find(":",0,TRUE); 1103// int divider = remoteServer.length() - remoteServer.find(":",0,TRUE);
1035// port = remoteServer.right( divider+1); 1104// port = remoteServer.right( divider+1);
1036// PortSpinBox->setValue( port); 1105// PortSpinBox->setValue( port);
1037 1106
1038// remoteServer = remoteServer.left(divider - 1); 1107// remoteServer = remoteServer.left(divider - 1);
1039// remotePath->setText( remotePathStr); 1108// remotePath->setText( remotePathStr);
1040 1109
1041// username = cfg.readEntry(temp); 1110// username = cfg.readEntry(temp);
1042// UsernameComboBox->insertItem(username); 1111// UsernameComboBox->insertItem(username);
1043// password = cfg.readEntryCrypt(username,""); 1112// password = cfg.readEntryCrypt(username,"");
1044// PasswordEdit->setText(password); 1113// PasswordEdit->setText(password);
1045 } 1114 }
1046} 1115}
1047 1116
1048 1117
1049void OpieFtp::serverComboSelected(int index) 1118void OpieFtp::serverComboSelected(int index)
1050{ 1119{
1051 currentServerConfig = index; 1120 currentServerConfig = index;
1052 QString username, remoteServerStr, remotePathStr, password, port, temp; 1121 QString username, remoteServerStr, remotePathStr, password, port, temp;
1053// remoteServerStr = ServerComboBox->text(index); 1122// remoteServerStr = ServerComboBox->text(index);
1054 Config cfg("opieftp"); 1123 Config cfg("opieftp");
1055 cfg.setGroup("Server"); 1124 cfg.setGroup("Server");
1056 int numberOfEntries = cfg.readNumEntry("numberOfEntries",0); 1125 int numberOfEntries = cfg.readNumEntry("numberOfEntries",0);
1057 1126
1058 temp.setNum(index+1); 1127 temp.setNum(index+1);
1059 remoteServerStr = cfg.readEntry( temp,""); 1128 remoteServerStr = cfg.readEntry( temp,"");
1060 cfg.setGroup(temp); 1129 cfg.setGroup(temp);
1061 qDebug(temp); 1130 qDebug(temp);
1062 int divider = remoteServerStr.length() - remoteServerStr.find(":",0,TRUE); 1131 int divider = remoteServerStr.length() - remoteServerStr.find(":",0,TRUE);
1063 port = remoteServerStr.right( divider - 1); 1132 port = remoteServerStr.right( divider - 1);
1064 bool ok; 1133 bool ok;
1065 int portInt = port.toInt(&ok,10); 1134 int portInt = port.toInt(&ok,10);
1066 if( portInt == 0) portInt = 21; 1135 if( portInt == 0) portInt = 21;
1067 1136
1068 PortSpinBox->setValue( portInt); 1137 PortSpinBox->setValue( portInt);
1069 1138
1070 remotePath->setText(cfg.readEntry("RemotePath", "/")); 1139 remotePath->setText(cfg.readEntry("RemotePath", "/"));
1071 1140
1072 username = cfg.readEntry("Username", "anonymous"); 1141 username = cfg.readEntry("Username", "anonymous");
1073 UsernameComboBox->lineEdit()->setText(username); 1142 UsernameComboBox->lineEdit()->setText(username);
1074 PasswordEdit->setText(cfg.readEntryCrypt(username, "me@opieftp.org")); 1143 PasswordEdit->setText(cfg.readEntryCrypt(username, "me@opieftp.org"));
1075 1144
1076 cfg.setGroup("Server"); 1145 cfg.setGroup("Server");
1077 temp.sprintf("%d",currentServerConfig); 1146 temp.sprintf("%d",currentServerConfig);
1078 cfg.writeEntry("currentServer", temp); 1147 cfg.writeEntry("currentServer", temp);
1079 update(); 1148 update();
1080} 1149}
1081// UsernameComboBox->lineEdit()->setText("root"); 1150// UsernameComboBox->lineEdit()->setText("root");
1082// PasswordEdit->setText( tr( "" ) ); 1151// PasswordEdit->setText( tr( "" ) );
1083// ServerComboBox->lineEdit()->setText( tr( "192.168.129.201" ) ); 1152// ServerComboBox->lineEdit()->setText( tr( "192.168.129.201" ) );
1084// remotePath->setText( currentRemoteDir = "/home/llornkcor/"); 1153// remotePath->setText( currentRemoteDir = "/home/llornkcor/");
1085// PortSpinBox->setValue( 4242); 1154// PortSpinBox->setValue( 4242);
1086 1155
1087void OpieFtp::deleteServer() 1156void OpieFtp::deleteServer()
1088{ 1157{
1089 QString username, remoteServerStr, remotePathStr, password, port, temp; 1158 QString username, remoteServerStr, remotePathStr, password, port, temp;
1090 remoteServerStr = ServerComboBox->currentText( ); 1159 remoteServerStr = ServerComboBox->currentText( );
1091 username = UsernameComboBox->currentText(); 1160 username = UsernameComboBox->currentText();
1092 Config cfg("opieftp"); 1161 Config cfg("opieftp");
1093 cfg.setGroup("Server"); 1162 cfg.setGroup("Server");
1094 int numberOfEntries = cfg.readNumEntry("numberOfEntries",0); 1163 int numberOfEntries = cfg.readNumEntry("numberOfEntries",0);
1095 for (int i = 0; i <= numberOfEntries; i++) { 1164 for (int i = 0; i <= numberOfEntries; i++) {
1096 temp.setNum(i+1); 1165 temp.setNum(i+1);
1097 cfg.setGroup("Server"); 1166 cfg.setGroup("Server");
1098 if( cfg.readEntry( temp,"").find( remoteServerStr,0,TRUE) != -1 1167 if( cfg.readEntry( temp,"").find( remoteServerStr,0,TRUE) != -1
1099 && cfg.readEntry(temp).find(username,0,TRUE) != -1 1168 && cfg.readEntry(temp).find(username,0,TRUE) != -1
1100 && !remoteServerStr.isEmpty()) { 1169 && !remoteServerStr.isEmpty()) {
1101 qDebug(temp); 1170 qDebug(temp);
1102 } 1171 }
1103 } 1172 }
1104} 1173}
diff --git a/noncore/net/opieftp/opieftp.h b/noncore/net/opieftp/opieftp.h
index 52ed885..57599b7 100644
--- a/noncore/net/opieftp/opieftp.h
+++ b/noncore/net/opieftp/opieftp.h
@@ -1,111 +1,117 @@
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 21
22class QVBoxLayout; 22class QVBoxLayout;
23class QHBoxLayout; 23class QHBoxLayout;
24class QGridLayout; 24class QGridLayout;
25class QComboBox; 25class QComboBox;
26class QListView; 26class QListView;
27class QListviewItem; 27class QListviewItem;
28class QLabel; 28class QLabel;
29class QProgressBar; 29class QProgressBar;
30class QSpinBox; 30class QSpinBox;
31class QTabWidget; 31class QTabWidget;
32class QWidget; 32class QWidget;
33class QPEToolBar; 33class QPEToolBar;
34class QPEMenuBar; 34class QPEMenuBar;
35class QPopupMenu; 35class QPopupMenu;
36class QFile; 36class QFile;
37class QListViewItem; 37class QListViewItem;
38class QLineEdit; 38class QLineEdit;
39class QPushButton; 39class QPushButton;
40class QStringList;
40 41
41class OpieFtp : public QMainWindow 42class OpieFtp : public QMainWindow
42{ 43{
43 Q_OBJECT 44 Q_OBJECT
44 45
45public: 46public:
46 OpieFtp( ); 47 OpieFtp( );
47 ~OpieFtp(); 48 ~OpieFtp();
48 49
49 QTabWidget *TabWidget; 50 QTabWidget *TabWidget;
50 QWidget *tab, *tab_2, *tab_3; 51 QWidget *tab, *tab_2, *tab_3;
51 QListView *Local_View, *Remote_View; 52 QListView *Local_View, *Remote_View;
52 53
53 QComboBox *UsernameComboBox, *ServerComboBox; 54 QComboBox *UsernameComboBox, *ServerComboBox, *currentPathCombo;
54 QLineEdit *PasswordEdit, *remotePath, *currentPathEdit; 55 QLineEdit *PasswordEdit, *remotePath, *currentPathEdit;
55 QLabel *TextLabel2, *TextLabel1, *TextLabel3, *TextLabel4;; 56 QLabel *TextLabel2, *TextLabel1, *TextLabel3, *TextLabel4;;
56 QSpinBox* PortSpinBox; 57 QSpinBox* PortSpinBox;
57 QPopupMenu *connectionMenu, *localMenu, *remoteMenu, *tabMenu; 58 QPopupMenu *connectionMenu, *localMenu, *remoteMenu, *tabMenu;
58 QDir currentDir; 59 QDir currentDir;
59 QString currentRemoteDir; 60 QString currentRemoteDir;
60 QString filterStr; 61 QString filterStr;
61 QListViewItem * item; 62 QListViewItem * item;
62 QPushButton *connectServerBtn; 63 QPushButton *connectServerBtn;
63 bool b; 64 bool b;
64 int currentServerConfig; 65 int currentServerConfig;
65protected slots: 66protected slots:
66 void serverComboEdited(const QString & ); 67 void serverComboEdited(const QString & );
67 void showLocalMenu( QListViewItem *); 68 void showLocalMenu( QListViewItem *);
68 void showRemoteMenu( QListViewItem *); 69 void showRemoteMenu( QListViewItem *);
69 void doLocalCd(); 70 void doLocalCd();
70 void doRemoteCd(); 71 void doRemoteCd();
71 void localUpload(); 72 void localUpload();
72 void remoteDownload(); 73 void remoteDownload();
73 void newConnection(); 74 void newConnection();
74 void connector(); 75 void connector();
75 void disConnector(); 76 void disConnector();
76 void populateLocalView(); 77 void populateLocalView();
77 bool populateRemoteView(); 78 bool populateRemoteView();
78 void showHidden(); 79 void showHidden();
79 void writeConfig(); 80 void writeConfig();
80 void readConfig(); 81 void readConfig();
81 void localListClicked(QListViewItem *); 82 void localListClicked(QListViewItem *);
82 void remoteListClicked(QListViewItem *); 83 void remoteListClicked(QListViewItem *);
83 void ListPressed( int, QListViewItem *, const QPoint&, int); 84 void ListPressed( int, QListViewItem *, const QPoint&, int);
84 void RemoteListPressed( int, QListViewItem *, const QPoint&, int); 85 void RemoteListPressed( int, QListViewItem *, const QPoint&, int);
85 void localMakDir(); 86 void localMakDir();
86 void localDelete(); 87 void localDelete();
87 void remoteMakDir(); 88 void remoteMakDir();
88 void remoteDelete(); 89 void remoteDelete();
89 bool remoteDirList(const QString &); 90 bool remoteDirList(const QString &);
90 bool remoteChDir(const QString &); 91 bool remoteChDir(const QString &);
91 void tabChanged(QWidget*); 92 void tabChanged(QWidget*);
92 void cleanUp(); 93 void cleanUp();
93 void remoteRename(); 94 void remoteRename();
94 void localRename(); 95 void localRename();
95 void currentPathEditChanged(); 96 void currentPathComboChanged();
97 void fillCombos();
98 void fillCombo(const QString &);
99 void currentPathComboActivated(const QString &);
96 void switchToLocalTab(); 100 void switchToLocalTab();
97 void switchToRemoteTab(); 101 void switchToRemoteTab();
98 void switchToConfigTab(); 102 void switchToConfigTab();
99 void fillCombos(); 103 void fillCombo();
104 void fillRemoteCombo();
100 void serverComboSelected(int); 105 void serverComboSelected(int);
101 void deleteServer(); 106 void deleteServer();
102 void connectorBtnToggled(bool); 107 void connectorBtnToggled(bool);
103protected: 108protected:
109 QStringList remoteDirPathStringList, localDirPathStringList;
104 void nullifyCallBack(); 110 void nullifyCallBack();
105 QGridLayout* tabLayout; 111 QGridLayout* tabLayout;
106 QGridLayout* tabLayout_2; 112 QGridLayout* tabLayout_2;
107 QGridLayout* tabLayout_3; 113 QGridLayout* tabLayout_3;
108 114
109}; 115};
110 116
111#endif // OPIEFTP_H 117#endif // OPIEFTP_H