summaryrefslogtreecommitdiff
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/net/opieftp/opieftp.cpp27
1 files changed, 14 insertions, 13 deletions
diff --git a/noncore/net/opieftp/opieftp.cpp b/noncore/net/opieftp/opieftp.cpp
index aa4314a..817943b 100644
--- a/noncore/net/opieftp/opieftp.cpp
+++ b/noncore/net/opieftp/opieftp.cpp
@@ -1,109 +1,108 @@
1/*************************************************************************** 1/***************************************************************************
2 opieftp.cpp 2 opieftp.cpp
3 ------------------- 3 -------------------
4** Created: Sat Mar 9 23:33:09 2002 4** Created: Sat Mar 9 23:33:09 2002
5 copyright : (C) 2002 by ljp 5 copyright : (C) 2002 by ljp
6 email : ljp@llornkcor.com 6 email : ljp@llornkcor.com
7 * This program is free software; you can redistribute it and/or modify * 7 * This program is free software; you can redistribute it and/or modify *
8 * it under the terms of the GNU General Public License as published by * 8 * it under the terms of the GNU General Public License as published by *
9 * the Free Software Foundation; either version 2 of the License, or * 9 * the Free Software Foundation; either version 2 of the License, or *
10 * (at your option) any later version. * 10 * (at your option) any later version. *
11 ***************************************************************************/ 11 ***************************************************************************/
12//#define DEVELOPERS_VERSION 12//#define DEVELOPERS_VERSION
13 13
14#include "opieftp.h" 14#include "opieftp.h"
15 15
16extern "C" { 16extern "C" {
17#include <ftplib.h> 17#include <ftplib.h>
18} 18}
19 19
20#include "inputDialog.h" 20#include "inputDialog.h"
21 21
22/* OPIE */ 22/* OPIE */
23#include <opie2/odebug.h> 23#include <opie2/odebug.h>
24#include <qpe/qpeapplication.h> 24#include <qpe/qpeapplication.h>
25#include <qpe/resource.h> 25#include <qpe/resource.h>
26#include <qpe/config.h> 26#include <qpe/config.h>
27#include <qpe/mimetype.h> 27#include <qpe/mimetype.h>
28using namespace Opie::Core; 28using namespace Opie::Core;
29 29
30#include <qtextstream.h> 30#include <qtextstream.h>
31#include <qpushbutton.h> 31#include <qpushbutton.h>
32#include <qtoolbutton.h> 32#include <qtoolbutton.h>
33#include <qcombobox.h> 33#include <qcombobox.h>
34#include <qlistview.h> 34#include <qlistview.h>
35#include <qlabel.h> 35#include <qlabel.h>
36#include <qprogressbar.h> 36#include <qprogressbar.h>
37#include <qspinbox.h> 37#include <qspinbox.h>
38#include <qtabwidget.h> 38#include <qtabwidget.h>
39#include <qlayout.h> 39#include <qlayout.h>
40#include <qmessagebox.h> 40#include <qmessagebox.h>
41#include <qmenubar.h> 41#include <qmenubar.h>
42#include <qlineedit.h> 42#include <qlineedit.h>
43#include <qlistbox.h> 43#include <qlistbox.h>
44#include <qvbox.h> 44#include <qvbox.h>
45
46/* STD */ 45/* STD */
47#include <unistd.h> 46#include <unistd.h>
48#include <stdlib.h> 47#include <stdlib.h>
49 48
50QProgressBar *ProgressBar; 49QProgressBar *ProgressBar;
51static netbuf *conn=NULL; 50static netbuf *conn=NULL;
52 51
53static int log_progress(netbuf *, int xfered, void *) 52static int log_progress(netbuf *, int xfered, void *)
54{ 53{
55// int fsz = *(int *)arg; 54// int fsz = *(int *)arg;
56// int pct = (xfered * 100) / fsz; 55// int pct = (xfered * 100) / fsz;
57// printf("%3d%%\r", pct); 56// printf("%3d%%\r", pct);
58// fflush(stdout); 57// fflush(stdout);
59 ProgressBar->setProgress(xfered); 58 ProgressBar->setProgress(xfered);
60 qApp->processEvents(); 59 qApp->processEvents();
61 return 1; 60 return 1;
62} 61}
63 62
64OpieFtp::OpieFtp( QWidget* parent, const char* name, WFlags fl) 63OpieFtp::OpieFtp( QWidget* parent, const char* name, WFlags fl)
65 : QMainWindow( parent, name, fl ) 64 : QMainWindow( parent, name, fl )
66{ 65{
67 odebug << "OpieFtp constructor" << oendl; 66 odebug << "OpieFtp constructor" << oendl;
68 setCaption( tr( "OpieFtp" ) ); 67 setCaption( tr( "OpieFtp" ) );
69 fuckeduphack=FALSE; 68 fuckeduphack=FALSE;
70 69
71 QVBox* wrapperBox = new QVBox( this ); 70 QVBox* wrapperBox = new QVBox( this );
72 setCentralWidget( wrapperBox ); 71 setCentralWidget( wrapperBox );
73 72
74 QWidget *view = new QWidget( wrapperBox ); 73 QWidget *view = new QWidget( wrapperBox );
75 74
76 QGridLayout *layout = new QGridLayout( view ); 75 QGridLayout *layout = new QGridLayout( view );
77 layout->setSpacing( 2); 76 layout->setSpacing( 2);
78 layout->setMargin( 2); 77 layout->setMargin( 2);
79 connect( qApp,SIGNAL( aboutToQuit()),SLOT( cleanUp()) ); 78 connect( qApp,SIGNAL( aboutToQuit()),SLOT( cleanUp()) );
80 79
81 QMenuBar *menuBar = new QMenuBar(this); 80 QMenuBar *menuBar = new QMenuBar(this);
82// QToolBar *menuBar = new QToolBar(this); 81// QToolBar *menuBar = new QToolBar(this);
83// menuBar->setHorizontalStretchable( TRUE ); 82// menuBar->setHorizontalStretchable( TRUE );
84 83
85 QWMatrix matrix; 84 QWMatrix matrix;
86 QPixmap pix(Resource::loadPixmap( "UnknownDocument" )); 85 QPixmap pix(Resource::loadPixmap( "UnknownDocument" ));
87 matrix.scale( .4, .4); 86 matrix.scale( .4, .4);
88 unknownXpm = pix.xForm(matrix); 87 unknownXpm = pix.xForm(matrix);
89 88
90 connectionMenu = new QPopupMenu( this ); 89 connectionMenu = new QPopupMenu( this );
91 localMenu = new QPopupMenu( this ); 90 localMenu = new QPopupMenu( this );
92 remoteMenu = new QPopupMenu( this ); 91 remoteMenu = new QPopupMenu( this );
93 tabMenu = new QPopupMenu( this ); 92 tabMenu = new QPopupMenu( this );
94 93
95//#if 0 94//#if 0
96 layout->addMultiCellWidget( menuBar, 0, 0, 0, 2 ); 95 layout->addMultiCellWidget( menuBar, 0, 0, 0, 2 );
97//#endif 96//#endif
98 97
99 menuBar->insertItem( tr( "Connection" ), connectionMenu); 98 menuBar->insertItem( tr( "Connection" ), connectionMenu);
100// menuBar->insertItem( tr( "Local" ), localMenu); 99// menuBar->insertItem( tr( "Local" ), localMenu);
101// menuBar->insertItem( tr( "Remote" ), remoteMenu); 100// menuBar->insertItem( tr( "Remote" ), remoteMenu);
102 menuBar->insertItem( tr( "View" ), tabMenu); 101 menuBar->insertItem( tr( "View" ), tabMenu);
103 102
104 tabMenu->insertItem( tr( "Local" ), localMenu); 103 tabMenu->insertItem( tr( "Local" ), localMenu);
105 tabMenu->insertItem( tr( "Remote" ), remoteMenu); 104 tabMenu->insertItem( tr( "Remote" ), remoteMenu);
106 105
107 connectionMenu->insertItem( tr( "New" ), this, SLOT( newConnection() )); 106 connectionMenu->insertItem( tr( "New" ), this, SLOT( newConnection() ));
108 connectionMenu->insertItem( tr( "Connect" ), this, SLOT( connector() )); 107 connectionMenu->insertItem( tr( "Connect" ), this, SLOT( connector() ));
109 connectionMenu->insertItem( tr( "Disconnect" ), this, SLOT( disConnector() )); 108 connectionMenu->insertItem( tr( "Disconnect" ), this, SLOT( disConnector() ));
@@ -241,158 +240,152 @@ OpieFtp::OpieFtp( QWidget* parent, const char* name, WFlags fl)
241 240
242 PasswordEdit = new QLineEdit( "", tab_3, "PasswordComboBox" ); 241 PasswordEdit = new QLineEdit( "", tab_3, "PasswordComboBox" );
243 PasswordEdit->setEchoMode(QLineEdit::Password); 242 PasswordEdit->setEchoMode(QLineEdit::Password);
244 tabLayout_3->addMultiCellWidget( PasswordEdit, 1, 1, 2, 3 ); 243 tabLayout_3->addMultiCellWidget( PasswordEdit, 1, 1, 2, 3 );
245 244
246 connect( PasswordEdit,SIGNAL(textChanged(const QString&)),this, 245 connect( PasswordEdit,SIGNAL(textChanged(const QString&)),this,
247 SLOT( PasswordEditEdited(const QString&) )); 246 SLOT( PasswordEditEdited(const QString&) ));
248 247
249//PasswordEdit->setFixedWidth(85); 248//PasswordEdit->setFixedWidth(85);
250 TextLabel3 = new QLabel( tab_3, "TextLabel3" ); 249 TextLabel3 = new QLabel( tab_3, "TextLabel3" );
251 TextLabel3->setText( tr( "Remote server" ) ); 250 TextLabel3->setText( tr( "Remote server" ) );
252 tabLayout_3->addMultiCellWidget( TextLabel3, 2, 2, 0, 1 ); 251 tabLayout_3->addMultiCellWidget( TextLabel3, 2, 2, 0, 1 );
253 252
254 ServerComboBox = new QComboBox( FALSE, tab_3, "ServerComboBox" ); 253 ServerComboBox = new QComboBox( FALSE, tab_3, "ServerComboBox" );
255 ServerComboBox->setEditable(TRUE); 254 ServerComboBox->setEditable(TRUE);
256 tabLayout_3->addMultiCellWidget( ServerComboBox, 3, 3, 0, 1 ); 255 tabLayout_3->addMultiCellWidget( ServerComboBox, 3, 3, 0, 1 );
257 256
258 connect(ServerComboBox,SIGNAL(activated(int)),this,SLOT(serverComboSelected(int) )); 257 connect(ServerComboBox,SIGNAL(activated(int)),this,SLOT(serverComboSelected(int) ));
259 connect(ServerComboBox,SIGNAL(textChanged(const QString&)),this, 258 connect(ServerComboBox,SIGNAL(textChanged(const QString&)),this,
260 SLOT(serverComboEdited(const QString&) )); 259 SLOT(serverComboEdited(const QString&) ));
261 260
262 QLabel *TextLabel5 = new QLabel( tab_3, "TextLabel5" ); 261 QLabel *TextLabel5 = new QLabel( tab_3, "TextLabel5" );
263 TextLabel5->setText( tr( "Remote path" ) ); 262 TextLabel5->setText( tr( "Remote path" ) );
264 tabLayout_3->addMultiCellWidget( TextLabel5, 2, 2, 2, 3 ); 263 tabLayout_3->addMultiCellWidget( TextLabel5, 2, 2, 2, 3 );
265 264
266 265
267 remotePath = new QLineEdit( "/", tab_3, "remotePath" ); 266 remotePath = new QLineEdit( "/", tab_3, "remotePath" );
268 tabLayout_3->addMultiCellWidget( remotePath, 3, 3, 2, 3 ); 267 tabLayout_3->addMultiCellWidget( remotePath, 3, 3, 2, 3 );
269 TextLabel4 = new QLabel( tab_3, "TextLabel4" ); 268 TextLabel4 = new QLabel( tab_3, "TextLabel4" );
270 TextLabel4->setText( tr( "Port" ) ); 269 TextLabel4->setText( tr( "Port" ) );
271 tabLayout_3->addMultiCellWidget( TextLabel4, 4, 4, 0, 1 ); 270 tabLayout_3->addMultiCellWidget( TextLabel4, 4, 4, 0, 1 );
272 271
273 PortSpinBox = new QSpinBox( tab_3, "PortSpinBox" ); 272 PortSpinBox = new QSpinBox( tab_3, "PortSpinBox" );
274 PortSpinBox->setButtonSymbols( QSpinBox::UpDownArrows ); 273 PortSpinBox->setButtonSymbols( QSpinBox::UpDownArrows );
275 PortSpinBox->setMaxValue(32786); 274 PortSpinBox->setMaxValue(32786);
276 tabLayout_3->addMultiCellWidget( PortSpinBox, 4, 4, 1, 1); 275 tabLayout_3->addMultiCellWidget( PortSpinBox, 4, 4, 1, 1);
277 276
278 serverListView = new QListBox( tab_3, "ServerListView" ); 277 serverListView = new QListBox( tab_3, "ServerListView" );
279 tabLayout_3->addMultiCellWidget( serverListView , 5, 5, 0, 5); 278 tabLayout_3->addMultiCellWidget( serverListView , 5, 5, 0, 5);
280 279
281 connect( serverListView, SIGNAL( highlighted(const QString&)), 280 connect( serverListView, SIGNAL( highlighted(const QString&)),
282 this,SLOT( serverListClicked(const QString&) ) ); 281 this,SLOT( serverListClicked(const QString&) ) );
283 282
284 connectServerBtn = new QPushButton( tr("Connect"), tab_3 , "ConnectButton" ); 283 connectServerBtn = new QPushButton( tr("Connect"), tab_3 , "ConnectButton" );
285 tabLayout_3->addMultiCellWidget( connectServerBtn, 6, 6, 0, 1); 284 tabLayout_3->addMultiCellWidget( connectServerBtn, 6, 6, 0, 1);
286 connectServerBtn->setToggleButton(TRUE); 285 connectServerBtn->setToggleButton(TRUE);
287 connect(connectServerBtn,SIGNAL( toggled(bool)),SLOT( connectorBtnToggled(bool) )); 286 connect(connectServerBtn,SIGNAL( toggled(bool)),SLOT( connectorBtnToggled(bool) ));
288 287
289 newServerButton= new QPushButton( tr("Add"), tab_3 , "NewServerButton" ); 288 newServerButton= new QPushButton( tr("Add"), tab_3 , "NewServerButton" );
290 tabLayout_3->addMultiCellWidget( newServerButton, 6, 6, 2, 2); 289 tabLayout_3->addMultiCellWidget( newServerButton, 6, 6, 2, 2);
291 connect( newServerButton,SIGNAL( clicked()),SLOT( NewServer() )); 290 connect( newServerButton,SIGNAL( clicked()),SLOT( NewServer() ));
292 291
293 QPushButton *deleteServerBtn; 292 QPushButton *deleteServerBtn;
294 deleteServerBtn = new QPushButton( tr("Delete"), tab_3 , "OpenButton" ); 293 deleteServerBtn = new QPushButton( tr("Delete"), tab_3 , "OpenButton" );
295 tabLayout_3->addMultiCellWidget( deleteServerBtn, 6, 6, 3, 3); 294 tabLayout_3->addMultiCellWidget( deleteServerBtn, 6, 6, 3, 3);
296 295
297 connect(deleteServerBtn,SIGNAL(clicked()),SLOT(deleteServer())); 296 connect(deleteServerBtn,SIGNAL(clicked()),SLOT(deleteServer()));
298 297
299 298
300 QSpacerItem* spacer = new QSpacerItem( 20, 20, QSizePolicy::Minimum, QSizePolicy::Expanding ); 299 QSpacerItem* spacer = new QSpacerItem( 20, 20, QSizePolicy::Minimum, QSizePolicy::Expanding );
301 tabLayout_3->addItem( spacer, 5, 0 ); 300 tabLayout_3->addItem( spacer, 5, 0 );
302 301
303 TabWidget->insertTab( tab_3, tr( "Config" ) ); 302 TabWidget->insertTab( tab_3, tr( "Config" ) );
304 303
305#if 0
306 connect(TabWidget,SIGNAL(currentChanged(QWidget*)), 304 connect(TabWidget,SIGNAL(currentChanged(QWidget*)),
307 this,SLOT(tabChanged(QWidget*))); 305 this,SLOT(tabChanged(QWidget*)));
308#endif
309 306
310 currentDir.setFilter( QDir::Files | QDir::Dirs/* | QDir::Hidden*/ | QDir::All); 307 currentDir.setFilter( QDir::Files | QDir::Dirs/* | QDir::Hidden*/ | QDir::All);
311 currentDir.setPath( QDir::currentDirPath()); 308 currentDir.setPath( QDir::currentDirPath());
312// currentDir.setSorting(/* QDir::Size*/ /*| QDir::Reversed | */QDir::DirsFirst); 309// currentDir.setSorting(/* QDir::Size*/ /*| QDir::Reversed | */QDir::DirsFirst);
313 310
314 currentPathCombo = new QComboBox( FALSE, view, "currentPathCombo" ); 311 currentPathCombo = new QComboBox( FALSE, view, "currentPathCombo" );
315 layout->addMultiCellWidget( currentPathCombo, 3, 3, 0, 4); 312 layout->addMultiCellWidget( currentPathCombo, 3, 3, 0, 4);
316 currentPathCombo ->setFixedWidth(220); 313 currentPathCombo ->setFixedWidth(220);
317 currentPathCombo->setEditable(TRUE); 314 currentPathCombo->setEditable(TRUE);
318 currentPathCombo->lineEdit()->setText( currentDir.canonicalPath()); 315 currentPathCombo->lineEdit()->setText( currentDir.canonicalPath());
319 316
320#if 0
321 connect( currentPathCombo, SIGNAL( activated(const QString&) ), 317 connect( currentPathCombo, SIGNAL( activated(const QString&) ),
322 this, SLOT( currentPathComboActivated(const QString&) ) ); 318 this, SLOT( currentPathComboActivated(const QString&) ) );
323 319
324 connect( currentPathCombo->lineEdit(),SIGNAL(returnPressed()), 320 connect( currentPathCombo->lineEdit(),SIGNAL(returnPressed()),
325 this,SLOT(currentPathComboChanged())); 321 this,SLOT(currentPathComboChanged()));
326#endif
327 ProgressBar = new QProgressBar( view, "ProgressBar" ); 322 ProgressBar = new QProgressBar( view, "ProgressBar" );
328 layout->addMultiCellWidget( ProgressBar, 4, 4, 0, 4); 323 layout->addMultiCellWidget( ProgressBar, 4, 4, 0, 4);
329 ProgressBar->setMaximumHeight(10); 324 ProgressBar->setMaximumHeight(10);
330 filterStr="*"; 325 filterStr="*";
331 b=FALSE; 326 b=FALSE;
332#if 0
333 populateLocalView(); 327 populateLocalView();
334#endif
335 readConfig(); 328 readConfig();
336 329
337// ServerComboBox->setCurrentItem(currentServerConfig); 330// ServerComboBox->setCurrentItem(currentServerConfig);
338 331
339 TabWidget->setCurrentPage(2); 332 TabWidget->setCurrentPage(2);
340 odebug << "Constructor done" << oendl; 333 odebug << "Constructor done" << oendl;
341} 334}
342 335
343OpieFtp::~OpieFtp() 336OpieFtp::~OpieFtp()
344{ 337{
345} 338}
346 339
347void OpieFtp::cleanUp() 340void OpieFtp::cleanUp()
348{ 341{
349 if(conn) 342 if(conn)
350 FtpQuit(conn); 343 FtpQuit(conn);
351 QString sfile=QDir::homeDirPath(); 344 QString sfile=QDir::homeDirPath();
352 if(sfile.right(1) != "/") 345 if(sfile.right(1) != "/")
353 sfile+="/._temp"; 346 sfile+="/._temp";
354 else 347 else
355 sfile+="._temp"; 348 sfile+="._temp";
356 QFile file( sfile); 349 QFile file( sfile);
357 if(file.exists()) 350 if(file.exists())
358 file.remove(); 351 file.remove();
359 Config cfg("opieftp"); 352 Config cfg("opieftp");
360 cfg.setGroup("Server"); 353 cfg.setGroup("Server");
361 cfg.writeEntry("currentServer", currentServerConfig); 354 cfg.writeEntry("currentServer", currentServerConfig);
362 355
363 exit(0); 356 exit(0);
364} 357}
365 358
366void OpieFtp::tabChanged(QWidget *) 359void OpieFtp::tabChanged(QWidget *)
367{ 360{
368 if (TabWidget->currentPageIndex() == 0) { 361 if (TabWidget->currentPageIndex() == 0) {
369 currentPathCombo->lineEdit()->setText( currentDir.canonicalPath()); 362 currentPathCombo->lineEdit()->setText( currentDir.canonicalPath());
370 tabMenu->setItemChecked(tabMenu->idAt(0),TRUE); 363 tabMenu->setItemChecked(tabMenu->idAt(0),TRUE);
371 tabMenu->setItemChecked(tabMenu->idAt(1),FALSE); 364 tabMenu->setItemChecked(tabMenu->idAt(1),FALSE);
372 tabMenu->setItemChecked(tabMenu->idAt(2),FALSE); 365 tabMenu->setItemChecked(tabMenu->idAt(2),FALSE);
373 if(cdUpButton->isHidden()) 366 if(cdUpButton->isHidden())
374 cdUpButton->show(); 367 cdUpButton->show();
375 if(homeButton->isHidden()) 368 if(homeButton->isHidden())
376 homeButton->show(); 369 homeButton->show();
377 370
378 } 371 }
379 if (TabWidget->currentPageIndex() == 1) { 372 if (TabWidget->currentPageIndex() == 1) {
380 currentPathCombo->lineEdit()->setText( currentRemoteDir ); 373 currentPathCombo->lineEdit()->setText( currentRemoteDir );
381 tabMenu->setItemChecked(tabMenu->idAt(1),TRUE); 374 tabMenu->setItemChecked(tabMenu->idAt(1),TRUE);
382 tabMenu->setItemChecked(tabMenu->idAt(0),FALSE); 375 tabMenu->setItemChecked(tabMenu->idAt(0),FALSE);
383 tabMenu->setItemChecked(tabMenu->idAt(2),FALSE); 376 tabMenu->setItemChecked(tabMenu->idAt(2),FALSE);
384 if(cdUpButton->isHidden()) 377 if(cdUpButton->isHidden())
385 cdUpButton->show(); 378 cdUpButton->show();
386 homeButton->hide(); 379 homeButton->hide();
387 380
388 } 381 }
389 if (TabWidget->currentPageIndex() == 2) { 382 if (TabWidget->currentPageIndex() == 2) {
390 tabMenu->setItemChecked(tabMenu->idAt(2),TRUE); 383 tabMenu->setItemChecked(tabMenu->idAt(2),TRUE);
391 tabMenu->setItemChecked(tabMenu->idAt(0),FALSE); 384 tabMenu->setItemChecked(tabMenu->idAt(0),FALSE);
392 tabMenu->setItemChecked(tabMenu->idAt(1),FALSE); 385 tabMenu->setItemChecked(tabMenu->idAt(1),FALSE);
393 cdUpButton->hide(); 386 cdUpButton->hide();
394 homeButton->hide(); 387 homeButton->hide();
395 } 388 }
396} 389}
397 390
398void OpieFtp::newConnection() 391void OpieFtp::newConnection()
@@ -606,180 +599,182 @@ void OpieFtp::remoteDownload()
606 nullifyCallBack(); 599 nullifyCallBack();
607 it.current()->setSelected(FALSE); 600 it.current()->setSelected(FALSE);
608 } 601 }
609 } 602 }
610 for ( ; it.current(); ++it ) { 603 for ( ; it.current(); ++it ) {
611 Remote_View->clearSelection(); 604 Remote_View->clearSelection();
612 } 605 }
613 Remote_View->setFocus(); 606 Remote_View->setFocus();
614 TabWidget->setCurrentPage(0); 607 TabWidget->setCurrentPage(0);
615 populateLocalView(); 608 populateLocalView();
616// QCopEnvelope ( "QPE/System", "notBusy()" ); 609// QCopEnvelope ( "QPE/System", "notBusy()" );
617} 610}
618 611
619bool OpieFtp::remoteDirList(const QString &dir) 612bool OpieFtp::remoteDirList(const QString &dir)
620{ 613{
621 QString tmp = QDir::homeDirPath(); 614 QString tmp = QDir::homeDirPath();
622 if(tmp.right(1) != "/") 615 if(tmp.right(1) != "/")
623 tmp+="/._temp"; 616 tmp+="/._temp";
624 else 617 else
625 tmp+="._temp"; 618 tmp+="._temp";
626// odebug << "Listing remote dir "+tmp << oendl; 619// odebug << "Listing remote dir "+tmp << oendl;
627// QCopEnvelope ( "QPE/System", "busy()" ); 620// QCopEnvelope ( "QPE/System", "busy()" );
628 if (!FtpDir( tmp.latin1(), dir.latin1(), conn) ) { 621 if (!FtpDir( tmp.latin1(), dir.latin1(), conn) ) {
629 QString msg; 622 QString msg;
630 msg.sprintf(tr("Unable to list the directory\n")+dir+"\n%s",FtpLastResponse(conn) ); 623 msg.sprintf(tr("Unable to list the directory\n")+dir+"\n%s",FtpLastResponse(conn) );
631 msg.replace(QRegExp(":"),"\n"); 624 msg.replace(QRegExp(":"),"\n");
632 QMessageBox::message(tr("Note"),msg); 625 QMessageBox::message(tr("Note"),msg);
633 return false; 626 return false;
634 } 627 }
635 populateRemoteView() ; 628 populateRemoteView() ;
636// QCopEnvelope ( "QPE/System", "notBusy()" ); 629// QCopEnvelope ( "QPE/System", "notBusy()" );
637 return true; 630 return true;
638} 631}
639 632
640bool OpieFtp::remoteChDir(const QString &dir) 633bool OpieFtp::remoteChDir(const QString &dir)
641{ 634{
642// QCopEnvelope ( "QPE/System", "busy()" ); 635// QCopEnvelope ( "QPE/System", "busy()" );
643 if (!FtpChdir( dir.latin1(), conn )) { 636 if (!FtpChdir( dir.latin1(), conn )) {
644 QString msg; 637 QString msg;
645 msg.sprintf(tr("Unable to change directories\n")+dir+"\n%s",FtpLastResponse(conn)); 638 msg.sprintf(tr("Unable to change directories\n")+dir+"\n%s",FtpLastResponse(conn));
646 msg.replace(QRegExp(":"),"\n"); 639 msg.replace(QRegExp(":"),"\n");
647 QMessageBox::message(tr("Note"),msg); 640 QMessageBox::message(tr("Note"),msg);
648// odebug << msg << oendl; 641// odebug << msg << oendl;
649// QCopEnvelope ( "QPE/System", "notBusy()" ); 642// QCopEnvelope ( "QPE/System", "notBusy()" );
650 return FALSE; 643 return FALSE;
651 } 644 }
652// QCopEnvelope ( "QPE/System", "notBusy()" ); 645// QCopEnvelope ( "QPE/System", "notBusy()" );
653 return TRUE; 646 return TRUE;
654} 647}
655 648
656void OpieFtp::populateLocalView() 649void OpieFtp::populateLocalView()
657{ 650{
658 Local_View->clear(); 651 Local_View->clear();
659 currentDir.setSorting(/* QDir::Size*/ /*| QDir::Reversed | */QDir::DirsFirst); 652 currentDir.setSorting(/* QDir::Size*/ /*| QDir::Reversed | */QDir::DirsFirst);
660 currentDir.setMatchAllDirs(TRUE); 653 currentDir.setMatchAllDirs(TRUE);
661 currentDir.setNameFilter(filterStr); 654 currentDir.setNameFilter(filterStr);
662 QString fileL, fileS, fileDate; 655 QString fileL, fileS, fileDate;
663 bool isDir=FALSE; 656 bool isDir=FALSE;
664 const QFileInfoList *list = currentDir.entryInfoList( /*QDir::All*/ /*, QDir::SortByMask*/); 657 const QFileInfoList *list = currentDir.entryInfoList( /*QDir::All*/ /*, QDir::SortByMask*/);
665 QFileInfoListIterator it(*list); 658 QFileInfoListIterator it(*list);
666 QFileInfo *fi; 659 QFileInfo *fi;
667 while ( (fi=it.current()) ) { 660 while ( (fi=it.current()) ) {
668 if (fi->isSymLink() ){ 661 if (fi->isSymLink() ){
669 QString symLink=fi->readLink(); 662 QString symLink=fi->readLink();
670 odebug << "Symlink detected "+symLink << oendl; 663// odebug << "Symlink detected "+symLink << oendl;
671 QFileInfo sym( symLink); 664 QFileInfo sym( symLink);
672 fileS.sprintf( "%10i", sym.size() ); 665 fileS.sprintf( "%10i", sym.size() );
673 fileL.sprintf( "%s -> %s", fi->fileName().data(),sym.absFilePath().data() ); 666 fileL.sprintf( "%s -> %s", fi->fileName().data(),sym.absFilePath().data() );
674 fileDate = sym.lastModified().toString(); 667 fileDate = sym.lastModified().toString();
675 } else { 668 } else {
676 odebug << "Not a dir: "+currentDir.canonicalPath()+fileL << oendl; 669// odebug << "Not a dir: "+currentDir.canonicalPath()+fileL << oendl;
677 fileS.sprintf( "%10i", fi->size() ); 670 fileS.sprintf( "%10i", fi->size() );
678 fileL.sprintf( "%s",fi->fileName().data() ); 671 fileL.sprintf( "%s",fi->fileName().data() );
679 fileDate= fi->lastModified().toString(); 672 fileDate= fi->lastModified().toString();
680 if( QDir(QDir::cleanDirPath(currentDir.canonicalPath()+"/"+fileL)).exists() ) { 673 if( QDir(QDir::cleanDirPath(currentDir.canonicalPath()+"/"+fileL)).exists() ) {
681 fileL+="/"; 674 fileL+="/";
682 isDir=TRUE; 675 isDir=TRUE;
683 odebug << fileL << oendl; 676// odebug << fileL << oendl;
684 } 677 }
685 } 678 }
679
680
686 if(fileL !="./" && fi->exists()) { 681 if(fileL !="./" && fi->exists()) {
687 item = new QListViewItem( Local_View,fileL, fileDate, fileS ); 682 item = new QListViewItem( Local_View,fileL, fileDate, fileS );
688 QPixmap pm; 683 QPixmap pm;
689 684
690 if(isDir || fileL.find("/",0,TRUE) != -1) { 685 if(isDir || fileL.find("/",0,TRUE) != -1) {
691 if( !QDir( fi->filePath() ).isReadable()) 686 if( !QDir( fi->filePath() ).isReadable())
692 pm = Resource::loadPixmap( "lockedfolder" ); 687 pm = Resource::loadPixmap( "lockedfolder" );
693 else 688 else
694 pm= Resource::loadPixmap( "folder" ); 689 pm= Resource::loadPixmap( "folder" );
695 item->setPixmap( 0,pm ); 690 item->setPixmap( 0,pm );
696 } else { 691 } else {
697 if( !fi->isReadable() ) 692 if( !fi->isReadable() )
698 pm = Resource::loadPixmap( "locked" ); 693 pm = Resource::loadPixmap( "locked" );
699 else { 694 else {
700 MimeType mt(fi->filePath()); 695 MimeType mt(fi->filePath());
701 pm=mt.pixmap(); //sets the correct pixmap for mimetype 696 pm=mt.pixmap(); //sets the correct pixmap for mimetype
702 if(pm.isNull()) 697 if(pm.isNull())
703 pm = unknownXpm; 698 pm = unknownXpm;
704 } 699 }
705 } 700 }
706 if( fileL.find("->",0,TRUE) != -1) { 701 if( fileL.find("->",0,TRUE) != -1) {
707 // overlay link image 702 // overlay link image
708 pm= Resource::loadPixmap( "folder" ); 703 pm= Resource::loadPixmap( "folder" );
709 QPixmap lnk = Resource::loadPixmap( "opie/symlink" ); 704 QPixmap lnk = Resource::loadPixmap( "opie/symlink" );
710 QPainter painter( &pm ); 705 QPainter painter( &pm );
711 painter.drawPixmap( pm.width()-lnk.width(), pm.height()-lnk.height(), lnk ); 706 painter.drawPixmap( pm.width()-lnk.width(), pm.height()-lnk.height(), lnk );
712 pm.setMask( pm.createHeuristicMask( FALSE ) ); 707 pm.setMask( pm.createHeuristicMask( FALSE ) );
713 } 708 }
714 item->setPixmap( 0,pm); 709 item->setPixmap( 0,pm);
715 } 710 }
716 isDir=FALSE; 711 isDir=FALSE;
717 ++it; 712 ++it;
718 } 713 }
719 Local_View->setSorting( 3,FALSE); 714 Local_View->setSorting( 3,FALSE);
720 currentPathCombo->lineEdit()->setText( currentDir.canonicalPath() ); 715 currentPathCombo->lineEdit()->setText( currentDir.canonicalPath() );
721 fillCombo( (const QString &)currentDir); 716 // fillCombo( (const QString &)currentDir);
722} 717}
723 718
724bool OpieFtp::populateRemoteView( ) 719bool OpieFtp::populateRemoteView( )
725{ 720{
726// odebug << "populate remoteview" << oendl; 721// odebug << "populate remoteview" << oendl;
727 QString sfile=QDir::homeDirPath(); 722 QString sfile=QDir::homeDirPath();
728 if(sfile.right(1) != "/") 723 if(sfile.right(1) != "/")
729 sfile+="/._temp"; 724 sfile+="/._temp";
730 else 725 else
731 sfile+="._temp"; 726 sfile+="._temp";
732 QFile file( sfile); 727 QFile file( sfile);
733 Remote_View->clear(); 728 Remote_View->clear();
734 QString s, File_Name; 729 QString s, File_Name;
735 QListViewItem *itemDir=NULL, *itemFile=NULL; 730 QListViewItem *itemDir=NULL, *itemFile=NULL;
736 QRegExp monthRe(" [JFMASOND][eapuecoe][brynlgptvc] [ 0-9][0-9] [ 0-9][0-9][:0-9][0-9][0-9] "); 731 QRegExp monthRe(" [JFMASOND][eapuecoe][brynlgptvc] [ 0-9][0-9] [ 0-9][0-9][:0-9][0-9][0-9] ");
737 QString fileL, fileS, fileDate; 732 QString fileL, fileS, fileDate;
738 if ( file.open(IO_ReadOnly)) { 733 if ( file.open(IO_ReadOnly)) {
739 QTextStream t( &file ); // use a text stream 734 QTextStream t( &file ); // use a text stream
740 while ( !t.eof()) { 735 while ( !t.eof()) {
741 s = t.readLine(); 736 s = t.readLine();
742 737
743 if(s.find("total",0,TRUE) == 0) 738 if(s.find("total",0,TRUE) == 0)
744 continue; 739 continue;
745 740
746 int len, month = monthRe.match(s, 0, &len); 741 int len, month = monthRe.match(s, 0, &len);
747 fileDate = s.mid(month + 1, len - 2); // minus spaces 742 fileDate = s.mid(month + 1, len - 2); // minus spaces
748 fileL = s.right(s.length() - month - len); 743 fileL = s.right(s.length() - month - len);
749 if(s.left(1) == "d") 744 if(s.left(1) == "d")
750 fileL = fileL+"/"; 745 fileL = fileL+"/";
751 fileS = s.mid(month - 8, 8); // FIXME 746 fileS = s.mid(month - 8, 8); // FIXME
752 fileS = fileS.stripWhiteSpace(); 747 fileS = fileS.stripWhiteSpace();
753 748
754 if(s.left(1) == "d" || fileL.find("/",0,TRUE) != -1) { 749 if(s.left(1) == "d" || fileL.find("/",0,TRUE) != -1) {
755 QListViewItem * item = new QListViewItem( Remote_View, fileL, fileDate, fileS,"d"); 750 QListViewItem * item = new QListViewItem( Remote_View, fileL, fileDate, fileS,"d");
756 item->setPixmap( 0, Resource::loadPixmap( "folder" )); 751 item->setPixmap( 0, Resource::loadPixmap( "folder" ));
757// if(itemDir) 752// if(itemDir)
758 item->moveItem(itemDir); 753 item->moveItem(itemDir);
759 itemDir=item; 754 itemDir=item;
760 } else { 755 } else {
761 QListViewItem * item = new QListViewItem( Remote_View, fileL, fileDate, fileS,"f"); 756 QListViewItem * item = new QListViewItem( Remote_View, fileL, fileDate, fileS,"f");
762 item->setPixmap( 0, Resource::loadPixmap( "fileopen" )); 757 item->setPixmap( 0, Resource::loadPixmap( "fileopen" ));
763// if(itemFile) 758// if(itemFile)
764 item->moveItem(itemDir); 759 item->moveItem(itemDir);
765 item->moveItem(itemFile); 760 item->moveItem(itemFile);
766 itemFile=item; 761 itemFile=item;
767 } 762 }
768 } 763 }
769 QListViewItem * item1 = new QListViewItem( Remote_View, "../"); 764 QListViewItem * item1 = new QListViewItem( Remote_View, "../");
770 item1->setPixmap( 0, Resource::loadPixmap( "folder" )); 765 item1->setPixmap( 0, Resource::loadPixmap( "folder" ));
771 file.close(); 766 file.close();
772 if( file.exists()) 767 if( file.exists())
773 file. remove(); 768 file. remove();
774 } else 769 } else
775 odebug << "temp file not opened successfully "+sfile << oendl; 770 odebug << "temp file not opened successfully "+sfile << oendl;
776 Remote_View->setSorting( 4,TRUE); 771 Remote_View->setSorting( 4,TRUE);
777 return true; 772 return true;
778} 773}
779 774
780void OpieFtp::remoteListClicked(QListViewItem *selectedItem) 775void OpieFtp::remoteListClicked(QListViewItem *selectedItem)
781{ 776{
782 if( selectedItem) { 777 if( selectedItem) {
783 // if(selectedItem!= NULL) { 778 // if(selectedItem!= NULL) {
784// QCopEnvelope ( "QPE/System", "busy()" ); 779// QCopEnvelope ( "QPE/System", "busy()" );
785 QString oldRemoteCurrentDir = currentRemoteDir; 780 QString oldRemoteCurrentDir = currentRemoteDir;
@@ -1084,137 +1079,142 @@ void OpieFtp::remoteDelete()
1084 remoteDirList( (const QString &)currentRemoteDir); //this also calls populate 1079 remoteDirList( (const QString &)currentRemoteDir); //this also calls populate
1085 } 1080 }
1086 break; 1081 break;
1087 }; 1082 };
1088 } 1083 }
1089 } 1084 }
1090 } 1085 }
1091// QCopEnvelope ( "QPE/System", "notBusy()" ); 1086// QCopEnvelope ( "QPE/System", "notBusy()" );
1092} 1087}
1093 1088
1094void OpieFtp::remoteRename() 1089void OpieFtp::remoteRename()
1095{ 1090{
1096 QString curFile = Remote_View->currentItem()->text(0); 1091 QString curFile = Remote_View->currentItem()->text(0);
1097 InputDialog *fileDlg; 1092 InputDialog *fileDlg;
1098 fileDlg = new InputDialog(this,tr("Rename"),TRUE, 0); 1093 fileDlg = new InputDialog(this,tr("Rename"),TRUE, 0);
1099 fileDlg->setTextEdit((const QString &)curFile); 1094 fileDlg->setTextEdit((const QString &)curFile);
1100 fileDlg->exec(); 1095 fileDlg->exec();
1101 if( fileDlg->result() == 1 ) { 1096 if( fileDlg->result() == 1 ) {
1102 QString oldName = currentRemoteDir +"/"+ curFile; 1097 QString oldName = currentRemoteDir +"/"+ curFile;
1103 QString newName = currentRemoteDir +"/"+ fileDlg->LineEdit1->text();//+".playlist"; 1098 QString newName = currentRemoteDir +"/"+ fileDlg->LineEdit1->text();//+".playlist";
1104// QCopEnvelope ( "QPE/System", "busy()" ); 1099// QCopEnvelope ( "QPE/System", "busy()" );
1105 if(FtpRename( oldName.latin1(), newName.latin1(),conn) == 0) { 1100 if(FtpRename( oldName.latin1(), newName.latin1(),conn) == 0) {
1106 QString msg; 1101 QString msg;
1107 msg.sprintf(tr("Unable to rename file\n")+"%s",FtpLastResponse(conn)); 1102 msg.sprintf(tr("Unable to rename file\n")+"%s",FtpLastResponse(conn));
1108 msg.replace(QRegExp(":"),"\n"); 1103 msg.replace(QRegExp(":"),"\n");
1109 QMessageBox::message(tr("Note"),msg); 1104 QMessageBox::message(tr("Note"),msg);
1110 } 1105 }
1111// QCopEnvelope ( "QPE/System", "notBusy()" ); 1106// QCopEnvelope ( "QPE/System", "notBusy()" );
1112 remoteDirList( (const QString &)currentRemoteDir); //this also calls populate 1107 remoteDirList( (const QString &)currentRemoteDir); //this also calls populate
1113 } 1108 }
1114} 1109}
1115 1110
1116void OpieFtp::localRename() 1111void OpieFtp::localRename()
1117{ 1112{
1118 QString curFile = Local_View->currentItem()->text(0); 1113 QString curFile = Local_View->currentItem()->text(0);
1119 InputDialog *fileDlg; 1114 InputDialog *fileDlg;
1120 fileDlg = new InputDialog(this,tr("Rename"),TRUE, 0); 1115 fileDlg = new InputDialog(this,tr("Rename"),TRUE, 0);
1121 fileDlg->setTextEdit((const QString &)curFile); 1116 fileDlg->setTextEdit((const QString &)curFile);
1122 fileDlg->exec(); 1117 fileDlg->exec();
1123 if( fileDlg->result() == 1 ) { 1118 if( fileDlg->result() == 1 ) {
1124 QString oldname = currentDir.canonicalPath() + "/" + curFile; 1119 QString oldname = currentDir.canonicalPath() + "/" + curFile;
1125 QString newName = currentDir.canonicalPath() + "/" + fileDlg->LineEdit1->text();//+".playlist"; 1120 QString newName = currentDir.canonicalPath() + "/" + fileDlg->LineEdit1->text();//+".playlist";
1126 if( rename(oldname.latin1(), newName.latin1())== -1) 1121 if( rename(oldname.latin1(), newName.latin1())== -1)
1127 QMessageBox::message(tr("Note"),tr("Could not rename")); 1122 QMessageBox::message(tr("Note"),tr("Could not rename"));
1128 } 1123 }
1129 populateLocalView(); 1124 populateLocalView();
1130} 1125}
1131 1126
1132void OpieFtp::currentPathComboActivated(const QString & currentPath) { 1127void OpieFtp::currentPathComboActivated(const QString & currentPath) {
1133 if (TabWidget->currentPageIndex() == 0) { 1128 if (TabWidget->currentPageIndex() == 0) {
1134 chdir( currentPath.latin1() ); 1129 chdir( currentPath.latin1() );
1135 currentDir.cd( currentPath, TRUE); 1130 currentDir.cd( currentPath, TRUE);
1136 populateLocalView(); 1131 populateLocalView();
1137 update(); 1132 update();
1138 } else { 1133 } else {
1139// chdir( currentPath.latin1() ); 1134// chdir( currentPath.latin1() );
1140// currentDir.cd( currentPath, TRUE); 1135// currentDir.cd( currentPath, TRUE);
1141// populateList(); 1136// populateList();
1142// update(); 1137// update();
1143 1138
1144 } 1139 }
1145} 1140}
1146 1141
1147void OpieFtp::fillCombo(const QString &currentPath) { 1142void OpieFtp::fillCombo(const QString &currentPath) {
1148 1143 qDebug("Fill Combo "+currentPath);
1149 currentPathCombo->lineEdit()->setText(currentPath); 1144 currentPathCombo->lineEdit()->setText(currentPath);
1145
1150 if( localDirPathStringList.grep(currentPath,TRUE).isEmpty() ) { 1146 if( localDirPathStringList.grep(currentPath,TRUE).isEmpty() ) {
1147 qDebug("Clearing local");
1151 currentPathCombo->clear(); 1148 currentPathCombo->clear();
1152 localDirPathStringList.prepend(currentPath ); 1149 localDirPathStringList.prepend(currentPath );
1153 currentPathCombo->insertStringList( localDirPathStringList,-1); 1150 currentPathCombo->insertStringList( localDirPathStringList,-1);
1154 } 1151 }
1152
1155 currentPathCombo->lineEdit()->setText(currentPath); 1153 currentPathCombo->lineEdit()->setText(currentPath);
1156 if( remoteDirPathStringList.grep(currentPath,TRUE).isEmpty() ) { 1154
1155 if( remoteDirPathStringList.grep(currentPath,TRUE).isEmpty() ) {
1156 qDebug("Clearing remote");
1157 currentPathCombo->clear(); 1157 currentPathCombo->clear();
1158 remoteDirPathStringList.prepend(currentPath ); 1158 remoteDirPathStringList.prepend(currentPath );
1159 currentPathCombo->insertStringList( remoteDirPathStringList,-1); 1159 currentPathCombo->insertStringList( remoteDirPathStringList,-1);
1160 } 1160 }
1161} 1161}
1162 1162
1163void OpieFtp::fillRemoteCombo(const QString &currentPath) { 1163void OpieFtp::fillRemoteCombo(const QString &currentPath) {
1164 1164
1165 currentPathCombo->lineEdit()->setText(currentPath); 1165 currentPathCombo->lineEdit()->setText(currentPath);
1166 if( remoteDirPathStringList.grep(currentPath,TRUE).isEmpty() ) { 1166 if( remoteDirPathStringList.grep(currentPath,TRUE).isEmpty() ) {
1167 currentPathCombo->clear(); 1167 currentPathCombo->clear();
1168 remoteDirPathStringList.prepend(currentPath ); 1168 remoteDirPathStringList.prepend(currentPath );
1169 currentPathCombo->insertStringList( remoteDirPathStringList,-1); 1169 currentPathCombo->insertStringList( remoteDirPathStringList,-1);
1170 } 1170 }
1171} 1171}
1172 1172
1173void OpieFtp::currentPathComboChanged() 1173void OpieFtp::currentPathComboChanged()
1174{ 1174{
1175 QString oldRemoteCurrentDir = currentRemoteDir; 1175 QString oldRemoteCurrentDir = currentRemoteDir;
1176// odebug << "oldRemoteCurrentDir "+oldRemoteCurrentDir << oendl; 1176// odebug << "oldRemoteCurrentDir "+oldRemoteCurrentDir << oendl;
1177 if (TabWidget->currentPageIndex() == 0) { 1177 if (TabWidget->currentPageIndex() == 0) {
1178 if(QDir( currentPathCombo->lineEdit()->text()).exists()) { 1178 if(QDir( currentPathCombo->lineEdit()->text()).exists()) {
1179 currentDir.setPath( currentPathCombo->lineEdit()->text() ); 1179 currentDir.setPath( currentPathCombo->lineEdit()->text() );
1180 populateLocalView(); 1180 populateLocalView();
1181 } else { 1181 } else {
1182 QMessageBox::message(tr("Note"),tr("That directory does not exist")); 1182 QMessageBox::message(tr("Note"),tr("That directory does not exist"));
1183 } 1183 }
1184 } 1184 }
1185 if (TabWidget->currentPageIndex() == 1) { 1185 if (TabWidget->currentPageIndex() == 1) {
1186 currentRemoteDir = currentPathCombo->lineEdit()->text(); 1186 currentRemoteDir = currentPathCombo->lineEdit()->text();
1187 if(currentRemoteDir.right(1) !="/") { 1187 if(currentRemoteDir.right(1) !="/") {
1188 currentRemoteDir = currentRemoteDir +"/"; 1188 currentRemoteDir = currentRemoteDir +"/";
1189 currentPathCombo->lineEdit()->setText( currentRemoteDir ); 1189 currentPathCombo->lineEdit()->setText( currentRemoteDir );
1190 } 1190 }
1191 if( !remoteChDir( (const QString &)currentRemoteDir) ) { 1191 if( !remoteChDir( (const QString &)currentRemoteDir) ) {
1192 currentRemoteDir = oldRemoteCurrentDir; 1192 currentRemoteDir = oldRemoteCurrentDir;
1193 currentPathCombo->lineEdit()->setText( currentRemoteDir ); 1193 currentPathCombo->lineEdit()->setText( currentRemoteDir );
1194 } 1194 }
1195 1195
1196 remoteDirList( (const QString &)currentRemoteDir); 1196 remoteDirList( (const QString &)currentRemoteDir);
1197 } 1197 }
1198} 1198}
1199 1199
1200void OpieFtp::switchToLocalTab() 1200void OpieFtp::switchToLocalTab()
1201{ 1201{
1202 TabWidget->setCurrentPage(0); 1202 TabWidget->setCurrentPage(0);
1203} 1203}
1204 1204
1205void OpieFtp::switchToRemoteTab() 1205void OpieFtp::switchToRemoteTab()
1206{ 1206{
1207 TabWidget->setCurrentPage(1); 1207 TabWidget->setCurrentPage(1);
1208} 1208}
1209 1209
1210void OpieFtp::switchToConfigTab() 1210void OpieFtp::switchToConfigTab()
1211{ 1211{
1212 TabWidget->setCurrentPage(2); 1212 TabWidget->setCurrentPage(2);
1213} 1213}
1214 1214
1215void OpieFtp::readConfig() 1215void OpieFtp::readConfig()
1216{ 1216{
1217 fillCombos(); 1217 fillCombos();
1218 Config cfg("opieftp"); 1218 Config cfg("opieftp");
1219 cfg.setGroup("Server"); 1219 cfg.setGroup("Server");
1220 currentServerConfig = cfg.readNumEntry("currentServer", -1); 1220 currentServerConfig = cfg.readNumEntry("currentServer", -1);
@@ -1226,128 +1226,129 @@ void OpieFtp::readConfig()
1226 1226
1227void OpieFtp::writeConfig() 1227void OpieFtp::writeConfig()
1228{ 1228{
1229 odebug << "write config" << oendl; 1229 odebug << "write config" << oendl;
1230 Config cfg("opieftp"); 1230 Config cfg("opieftp");
1231 cfg.setGroup("Server"); 1231 cfg.setGroup("Server");
1232 1232
1233 QString username, remoteServerStr, remotePathStr, password, port, temp; 1233 QString username, remoteServerStr, remotePathStr, password, port, temp;
1234 1234
1235 int numberOfEntries = cfg.readNumEntry("numberOfEntries",0); 1235 int numberOfEntries = cfg.readNumEntry("numberOfEntries",0);
1236 1236
1237 if( currentServerConfig == -1) { 1237 if( currentServerConfig == -1) {
1238 1238
1239 for (int i = 1; i <= numberOfEntries; i++) { 1239 for (int i = 1; i <= numberOfEntries; i++) {
1240 temp.setNum(i); 1240 temp.setNum(i);
1241 cfg.setGroup("Server"); 1241 cfg.setGroup("Server");
1242 QString tempStr = cfg.readEntry( temp,""); 1242 QString tempStr = cfg.readEntry( temp,"");
1243 } 1243 }
1244 1244
1245 temp.setNum( numberOfEntries + 1); 1245 temp.setNum( numberOfEntries + 1);
1246 cfg.setGroup("Server"); 1246 cfg.setGroup("Server");
1247 1247
1248 remoteServerStr = cfg.readEntry( temp,""); 1248 remoteServerStr = cfg.readEntry( temp,"");
1249 1249
1250 int divider = remoteServerStr.length() - remoteServerStr.find(":",0,TRUE); 1250 int divider = remoteServerStr.length() - remoteServerStr.find(":",0,TRUE);
1251 remoteServerStr = remoteServerStr.left(remoteServerStr.length()-divider); 1251 remoteServerStr = remoteServerStr.left(remoteServerStr.length()-divider);
1252 1252
1253 temp.setNum(numberOfEntries+1); 1253 temp.setNum(numberOfEntries+1);
1254 cfg.setGroup("Server"); 1254 cfg.setGroup("Server");
1255 1255
1256 cfg.writeEntry( temp, ServerComboBox->currentText() +":"+PortSpinBox->cleanText() ); 1256 cfg.writeEntry( temp, ServerComboBox->currentText() +":"+PortSpinBox->cleanText() );
1257 cfg.writeEntry("currentServer", numberOfEntries+1); 1257 cfg.writeEntry("currentServer", numberOfEntries+1);
1258 1258
1259 currentServerConfig = numberOfEntries+1; 1259 currentServerConfig = numberOfEntries+1;
1260 odebug << "setting currentserverconfig to " << currentServerConfig << "" << oendl; 1260 odebug << "setting currentserverconfig to " << currentServerConfig << "" << oendl;
1261 1261
1262 cfg.setGroup(temp); 1262 cfg.setGroup(temp);
1263 if(!newServerName.isEmpty()) 1263 if(!newServerName.isEmpty())
1264 cfg.writeEntry("ServerName", newServerName); 1264 cfg.writeEntry("ServerName", newServerName);
1265 1265
1266 cfg.writeEntry("RemotePath", remotePath->text()); 1266 cfg.writeEntry("RemotePath", remotePath->text());
1267 1267
1268 cfg.writeEntry("Username", UsernameComboBox->currentText()); 1268 cfg.writeEntry("Username", UsernameComboBox->currentText());
1269 1269
1270 cfg.writeEntryCrypt( UsernameComboBox->currentText(), PasswordEdit->text()); 1270 cfg.writeEntryCrypt( UsernameComboBox->currentText(), PasswordEdit->text());
1271 cfg.setGroup("Server"); 1271 cfg.setGroup("Server");
1272 1272
1273 cfg.writeEntry("numberOfEntries", QString::number(numberOfEntries + 1 )); 1273 cfg.writeEntry("numberOfEntries", QString::number(numberOfEntries + 1 ));
1274 1274
1275 } 1275 }
1276} 1276}
1277 1277
1278void OpieFtp::clearCombos() { 1278void OpieFtp::clearCombos() {
1279 odebug << "clearing" << oendl; 1279 odebug << "clearing" << oendl;
1280 ServerComboBox->clear(); 1280 ServerComboBox->clear();
1281 UsernameComboBox->clear(); 1281 UsernameComboBox->clear();
1282 PasswordEdit->clear(); 1282 PasswordEdit->clear();
1283 serverListView->clear(); 1283 serverListView->clear();
1284} 1284}
1285 1285
1286 1286
1287void OpieFtp::fillCombos() 1287void OpieFtp::fillCombos()
1288{ 1288{
1289 clearCombos(); 1289 clearCombos();
1290 qDebug("did we get here yet?");
1290 1291
1291 Config cfg("opieftp"); 1292 Config cfg("opieftp");
1292 cfg.setGroup("Server"); 1293 cfg.setGroup("Server");
1293 QString username, remoteServerStr, remotePathStr, password, port, temp; 1294 QString username, remoteServerStr, remotePathStr, password, port, temp;
1294 int numberOfEntries = cfg.readNumEntry("numberOfEntries",0); 1295 int numberOfEntries = cfg.readNumEntry("numberOfEntries",0);
1295 1296
1296 for (int i = 1; i <= numberOfEntries; i++) { 1297 for (int i = 1; i <= numberOfEntries; i++) {
1297 temp.setNum(i); 1298 temp.setNum(i);
1298 odebug << temp << oendl; 1299 odebug << temp << oendl;
1299 cfg.setGroup("Server"); 1300 cfg.setGroup("Server");
1300 remoteServerStr = cfg.readEntry( temp,""); 1301 remoteServerStr = cfg.readEntry( temp,"");
1301 odebug << remoteServerStr << oendl; 1302 odebug << remoteServerStr << oendl;
1302 1303
1303 int divider = remoteServerStr.length() - remoteServerStr.find(":",0,TRUE); 1304 int divider = remoteServerStr.length() - remoteServerStr.find(":",0,TRUE);
1304 port = remoteServerStr.right( divider - 1); 1305 port = remoteServerStr.right( divider - 1);
1305 bool ok; 1306 bool ok;
1306 PortSpinBox->setValue( port.toInt(&ok,10)); 1307 PortSpinBox->setValue( port.toInt(&ok,10));
1307 1308
1308 remoteServerStr = remoteServerStr.left(remoteServerStr.length()-divider); 1309 remoteServerStr = remoteServerStr.left(remoteServerStr.length()-divider);
1309 odebug << "remote server string "+remoteServerStr << oendl; 1310 odebug << "remote server string "+remoteServerStr << oendl;
1310 ServerComboBox->insertItem( remoteServerStr ); 1311 ServerComboBox->insertItem( remoteServerStr );
1311 1312
1312 cfg.setGroup(temp); 1313 cfg.setGroup(temp);
1313 1314
1314 username = cfg.readEntry(temp); 1315 username = cfg.readEntry(temp);
1315 UsernameComboBox->insertItem(username); 1316 UsernameComboBox->insertItem(username);
1316 password = cfg.readEntryCrypt(username,""); 1317 password = cfg.readEntryCrypt(username,"");
1317 PasswordEdit->setText(password); 1318 PasswordEdit->setText(password);
1318 1319
1319 serverListView->insertItem( cfg.readEntry("ServerName")); 1320 serverListView->insertItem( cfg.readEntry("ServerName"));
1320 } 1321 }
1321} 1322}
1322 1323
1323 1324
1324void OpieFtp::serverComboSelected(int index) 1325void OpieFtp::serverComboSelected(int index)
1325{ 1326{
1326 currentServerConfig = index+1; 1327 currentServerConfig = index+1;
1327 odebug << "server combo selected " << index+1 << "" << oendl; 1328 odebug << "server combo selected " << index+1 << "" << oendl;
1328 QString username, remoteServerStr, remotePathStr, password, port, temp; 1329 QString username, remoteServerStr, remotePathStr, password, port, temp;
1329// remoteServerStr = ServerComboBox->text(index); 1330// remoteServerStr = ServerComboBox->text(index);
1330 1331
1331 Config cfg("opieftp"); 1332 Config cfg("opieftp");
1332 cfg.setGroup("Server"); 1333 cfg.setGroup("Server");
1333// int numberOfEntries = cfg.readNumEntry("numberOfEntries",0); 1334// int numberOfEntries = cfg.readNumEntry("numberOfEntries",0);
1334 1335
1335 temp.setNum(index+1); 1336 temp.setNum(index+1);
1336 remoteServerStr = cfg.readEntry( temp,""); 1337 remoteServerStr = cfg.readEntry( temp,"");
1337 1338
1338 odebug << "Group" +temp << oendl; 1339 odebug << "Group" +temp << oendl;
1339 cfg.setGroup(temp); 1340 cfg.setGroup(temp);
1340// odebug << temp << oendl; 1341// odebug << temp << oendl;
1341 int divider = remoteServerStr.length() - remoteServerStr.find(":",0,TRUE); 1342 int divider = remoteServerStr.length() - remoteServerStr.find(":",0,TRUE);
1342 port = remoteServerStr.right( divider - 1); 1343 port = remoteServerStr.right( divider - 1);
1343 bool ok; 1344 bool ok;
1344 int portInt = port.toInt(&ok,10); 1345 int portInt = port.toInt(&ok,10);
1345 if( portInt == 0) portInt = 21; 1346 if( portInt == 0) portInt = 21;
1346 1347
1347 ServerComboBox->lineEdit()->setText(remoteServerStr.left( remoteServerStr.find(":",0,TRUE))); 1348 ServerComboBox->lineEdit()->setText(remoteServerStr.left( remoteServerStr.find(":",0,TRUE)));
1348 1349
1349 PortSpinBox->setValue( portInt); 1350 PortSpinBox->setValue( portInt);
1350 1351
1351 remotePath->setText(cfg.readEntry("RemotePath", "/")); 1352 remotePath->setText(cfg.readEntry("RemotePath", "/"));
1352 1353
1353 username = cfg.readEntry("Username", "anonymous"); 1354 username = cfg.readEntry("Username", "anonymous");