summaryrefslogtreecommitdiff
path: root/noncore
Unidiff
Diffstat (limited to 'noncore') (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/net/opieftp/ftplib.c2
-rw-r--r--noncore/net/opieftp/opieftp.cpp278
-rw-r--r--noncore/net/opieftp/opieftp.h9
3 files changed, 168 insertions, 121 deletions
diff --git a/noncore/net/opieftp/ftplib.c b/noncore/net/opieftp/ftplib.c
index b9ca746..5116170 100644
--- a/noncore/net/opieftp/ftplib.c
+++ b/noncore/net/opieftp/ftplib.c
@@ -49,25 +49,25 @@
49#endif 49#endif
50 50
51#define BUILDING_LIBRARY 51#define BUILDING_LIBRARY
52#include "ftplib.h" 52#include "ftplib.h"
53 53
54#if defined(_WIN32) 54#if defined(_WIN32)
55#define SETSOCKOPT_OPTVAL_TYPE (const char *) 55#define SETSOCKOPT_OPTVAL_TYPE (const char *)
56#else 56#else
57#define SETSOCKOPT_OPTVAL_TYPE (void *) 57#define SETSOCKOPT_OPTVAL_TYPE (void *)
58#endif 58#endif
59 59
60#define FTPLIB_BUFSIZ 8192 60#define FTPLIB_BUFSIZ 8192
61#define ACCEPT_TIMEOUT 30 61#define ACCEPT_TIMEOUT 15
62 62
63#define FTPLIB_CONTROL 0 63#define FTPLIB_CONTROL 0
64#define FTPLIB_READ 1 64#define FTPLIB_READ 1
65#define FTPLIB_WRITE 2 65#define FTPLIB_WRITE 2
66 66
67#if !defined FTPLIB_DEFMODE 67#if !defined FTPLIB_DEFMODE
68#define FTPLIB_DEFMODE FTPLIB_PASSIVE 68#define FTPLIB_DEFMODE FTPLIB_PASSIVE
69#endif 69#endif
70 70
71struct NetBuf { 71struct NetBuf {
72 char *cput,*cget; 72 char *cput,*cget;
73 int handle; 73 int handle;
diff --git a/noncore/net/opieftp/opieftp.cpp b/noncore/net/opieftp/opieftp.cpp
index eed133e..d74c55b 100644
--- a/noncore/net/opieftp/opieftp.cpp
+++ b/noncore/net/opieftp/opieftp.cpp
@@ -1,24 +1,24 @@
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 DEVELOPER_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
@@ -124,150 +124,148 @@ OpieFtp::OpieFtp( )
124 Local_View = new QListView( tab, "Local_View" ); 124 Local_View = new QListView( tab, "Local_View" );
125// Local_View->setResizePolicy( QListView::AutoOneFit ); 125// Local_View->setResizePolicy( QListView::AutoOneFit );
126 Local_View->addColumn( tr("File"),120); 126 Local_View->addColumn( tr("File"),120);
127 Local_View->addColumn( tr("Size"),-1); 127 Local_View->addColumn( tr("Size"),-1);
128 Local_View->setColumnAlignment(1,QListView::AlignRight); 128 Local_View->setColumnAlignment(1,QListView::AlignRight);
129 Local_View->addColumn( tr("Date"),-1); 129 Local_View->addColumn( tr("Date"),-1);
130 Local_View->setColumnAlignment(2,QListView::AlignRight); 130 Local_View->setColumnAlignment(2,QListView::AlignRight);
131 Local_View->setAllColumnsShowFocus(TRUE); 131 Local_View->setAllColumnsShowFocus(TRUE);
132 QPEApplication::setStylusOperation( Local_View->viewport(),QPEApplication::RightOnHold); 132 QPEApplication::setStylusOperation( Local_View->viewport(),QPEApplication::RightOnHold);
133 133
134 tabLayout->addWidget( Local_View, 0, 0 ); 134 tabLayout->addWidget( Local_View, 0, 0 );
135 135
136 connect( Local_View, SIGNAL( doubleClicked( QListViewItem*)), 136 connect( Local_View, SIGNAL( clicked( QListViewItem*)),
137 this,SLOT( localListClicked(QListViewItem *)) ); 137 this,SLOT( localListClicked(QListViewItem *)) );
138 connect( Local_View, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int)), 138 connect( Local_View, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int)),
139 this,SLOT( ListPressed(int, QListViewItem *, const QPoint&, int)) ); 139 this,SLOT( ListPressed(int, QListViewItem *, const QPoint&, int)) );
140 140
141 TabWidget->insertTab( tab, tr( "Local" ) ); 141 TabWidget->insertTab( tab, tr( "Local" ) );
142 142
143 tab_2 = new QWidget( TabWidget, "tab_2" ); 143 tab_2 = new QWidget( TabWidget, "tab_2" );
144 tabLayout_2 = new QGridLayout( tab_2 ); 144 tabLayout_2 = new QGridLayout( tab_2 );
145 tabLayout_2->setSpacing( 2); 145 tabLayout_2->setSpacing( 2);
146 tabLayout_2->setMargin( 2); 146 tabLayout_2->setMargin( 2);
147 147
148 Remote_View = new QListView( tab_2, "Remote_View" ); 148 Remote_View = new QListView( tab_2, "Remote_View" );
149 Remote_View->addColumn( tr("File"),120); 149 Remote_View->addColumn( tr("File"),120);
150 Remote_View->addColumn( tr("Size"),-1); 150 Remote_View->addColumn( tr("Size"),-1);
151 Remote_View->setColumnAlignment(1,QListView::AlignRight); 151 Remote_View->setColumnAlignment(1,QListView::AlignRight);
152 Remote_View->addColumn( tr("Date"),-1); 152 Remote_View->addColumn( tr("Date"),-1);
153 Remote_View->setColumnAlignment(2,QListView::AlignRight); 153 Remote_View->setColumnAlignment(2,QListView::AlignRight);
154 Remote_View->setAllColumnsShowFocus(TRUE); 154 Remote_View->setAllColumnsShowFocus(TRUE);
155 QPEApplication::setStylusOperation( Remote_View->viewport(),QPEApplication::RightOnHold); 155 QPEApplication::setStylusOperation( Remote_View->viewport(),QPEApplication::RightOnHold);
156 156
157 connect( Remote_View, SIGNAL( doubleClicked( QListViewItem*)), 157 connect( Remote_View, SIGNAL( clicked( QListViewItem*)),
158 this,SLOT( remoteListClicked(QListViewItem *)) ); 158 this,SLOT( remoteListClicked(QListViewItem *)) );
159 connect( Remote_View, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int)), 159 connect( Remote_View, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int)),
160 this,SLOT( RemoteListPressed(int, QListViewItem *, const QPoint&, int)) ); 160 this,SLOT( RemoteListPressed(int, QListViewItem *, const QPoint&, int)) );
161 161
162 tabLayout_2->addWidget( Remote_View, 0, 0 ); 162 tabLayout_2->addWidget( Remote_View, 0, 0 );
163 163
164 TabWidget->insertTab( tab_2, tr( "Remote" ) ); 164 TabWidget->insertTab( tab_2, tr( "Remote" ) );
165 165
166 tab_3 = new QWidget( TabWidget, "tab_3" ); 166 tab_3 = new QWidget( TabWidget, "tab_3" );
167 tabLayout_3 = new QGridLayout( tab_3 ); 167 tabLayout_3 = new QGridLayout( tab_3 );
168 tabLayout_3->setSpacing( 2); 168 tabLayout_3->setSpacing( 2);
169 tabLayout_3->setMargin( 2); 169 tabLayout_3->setMargin( 2);
170 170
171 TextLabel1 = new QLabel( tab_3, "TextLabel1" ); 171 TextLabel1 = new QLabel( tab_3, "TextLabel1" );
172 TextLabel1->setText( tr( "Username" ) ); 172 TextLabel1->setText( tr( "Username" ) );
173 tabLayout_3->addMultiCellWidget( TextLabel1, 0, 0, 0, 1 ); 173 tabLayout_3->addMultiCellWidget( TextLabel1, 0, 0, 0, 1 );
174 174
175 UsernameComboBox = new QComboBox( FALSE, tab_3, "UsernameComboBox" ); 175 UsernameComboBox = new QComboBox( FALSE, tab_3, "UsernameComboBox" );
176 UsernameComboBox->setEditable(TRUE); 176 UsernameComboBox->setEditable(TRUE);
177// UsernameComboBox->lineEdit()->setText("anonymous");
178 tabLayout_3->addMultiCellWidget( UsernameComboBox, 1, 1, 0, 1 ); 177 tabLayout_3->addMultiCellWidget( UsernameComboBox, 1, 1, 0, 1 );
179 178
180 TextLabel2 = new QLabel( tab_3, "TextLabel2" ); 179 TextLabel2 = new QLabel( tab_3, "TextLabel2" );
181 TextLabel2->setText( tr( "Password" ) ); 180 TextLabel2->setText( tr( "Password" ) );
182 tabLayout_3->addMultiCellWidget( TextLabel2, 0, 0, 2, 3 ); 181 tabLayout_3->addMultiCellWidget( TextLabel2, 0, 0, 2, 3 );
183 182
184 PasswordEdit = new QLineEdit( "", tab_3, "PasswordComboBox" ); 183 PasswordEdit = new QLineEdit( "", tab_3, "PasswordComboBox" );
185 PasswordEdit->setEchoMode(QLineEdit::Password); 184 PasswordEdit->setEchoMode(QLineEdit::Password);
186// PasswordEdit->setText( tr( "me@opieftp.org" ) );
187 tabLayout_3->addMultiCellWidget( PasswordEdit, 1, 1, 2, 3 ); 185 tabLayout_3->addMultiCellWidget( PasswordEdit, 1, 1, 2, 3 );
188 186
189 TextLabel3 = new QLabel( tab_3, "TextLabel3" ); 187 TextLabel3 = new QLabel( tab_3, "TextLabel3" );
190 TextLabel3->setText( tr( "Remote server" ) ); 188 TextLabel3->setText( tr( "Remote server" ) );
191 tabLayout_3->addMultiCellWidget( TextLabel3, 2, 2, 0, 1 ); 189 tabLayout_3->addMultiCellWidget( TextLabel3, 2, 2, 0, 1 );
192 190
193 ServerComboBox = new QComboBox( FALSE, tab_3, "ServerComboBox" ); 191 ServerComboBox = new QComboBox( FALSE, tab_3, "ServerComboBox" );
194 ServerComboBox->setEditable(TRUE); 192 ServerComboBox->setEditable(TRUE);
195// ServerComboBox->lineEdit()->setText( tr( "" ) );
196 tabLayout_3->addMultiCellWidget( ServerComboBox, 3, 3, 0, 1 ); 193 tabLayout_3->addMultiCellWidget( ServerComboBox, 3, 3, 0, 1 );
197 194
198 connect(ServerComboBox,SIGNAL(activated(int)),this,SLOT(serverComboSelected(int ) )); 195 connect(ServerComboBox,SIGNAL(activated(int)),this,SLOT(serverComboSelected(int ) ));
196 connect(ServerComboBox,SIGNAL(textChanged(const QString &)),this,SLOT(serverComboEdited(const QString & ) ));
199 197
200 QLabel *TextLabel5 = new QLabel( tab_3, "TextLabel5" ); 198 QLabel *TextLabel5 = new QLabel( tab_3, "TextLabel5" );
201 TextLabel5->setText( tr( "Remote path" ) ); 199 TextLabel5->setText( tr( "Remote path" ) );
202 tabLayout_3->addMultiCellWidget( TextLabel5, 2, 2, 2, 3 ); 200 tabLayout_3->addMultiCellWidget( TextLabel5, 2, 2, 2, 3 );
203 201
204 remotePath = new QLineEdit( "/", tab_3, "remotePath" ); 202 remotePath = new QLineEdit( "/", tab_3, "remotePath" );
205 remotePath->setText( currentRemoteDir = "/");
206 tabLayout_3->addMultiCellWidget( remotePath, 3, 3, 2, 3 ); 203 tabLayout_3->addMultiCellWidget( remotePath, 3, 3, 2, 3 );
207 204
208 TextLabel4 = new QLabel( tab_3, "TextLabel4" ); 205 TextLabel4 = new QLabel( tab_3, "TextLabel4" );
209 TextLabel4->setText( tr( "Port" ) ); 206 TextLabel4->setText( tr( "Port" ) );
210 tabLayout_3->addMultiCellWidget( TextLabel4, 4, 4, 0, 1 ); 207 tabLayout_3->addMultiCellWidget( TextLabel4, 4, 4, 0, 1 );
211 208
212 PortSpinBox = new QSpinBox( tab_3, "PortSpinBox" ); 209 PortSpinBox = new QSpinBox( tab_3, "PortSpinBox" );
213 PortSpinBox->setButtonSymbols( QSpinBox::UpDownArrows ); 210 PortSpinBox->setButtonSymbols( QSpinBox::UpDownArrows );
214 PortSpinBox->setMaxValue(32786); 211 PortSpinBox->setMaxValue(32786);
215 PortSpinBox->setValue( 21);
216 tabLayout_3->addMultiCellWidget( PortSpinBox, 4, 4, 1, 1); 212 tabLayout_3->addMultiCellWidget( PortSpinBox, 4, 4, 1, 1);
217 213
218 QPushButton *deleteServerBtn; 214 QPushButton *deleteServerBtn;
219 deleteServerBtn = new QPushButton( "Delete Server",this, "OpenButton" ); 215 deleteServerBtn = new QPushButton( "Delete Server", tab_3 , "OpenButton" );
220 tabLayout_3->addMultiCellWidget( deleteServerBtn, 5, 5, 2, 3); 216 tabLayout_3->addMultiCellWidget( deleteServerBtn, 5, 5, 2, 3);
221 217
222 connect(deleteServerBtn,SIGNAL(clicked()),SLOT(deleteServer())); 218 connect(deleteServerBtn,SIGNAL(clicked()),SLOT(deleteServer()));
223 219
224 QPushButton *connectServerBtn; 220 connectServerBtn = new QPushButton( "Connect", tab_3 , "ConnectButton" );
225 connectServerBtn = new QPushButton( "Connect",this, "ConnectButton" );
226 tabLayout_3->addMultiCellWidget( connectServerBtn, 5, 5, 0, 1); 221 tabLayout_3->addMultiCellWidget( connectServerBtn, 5, 5, 0, 1);
227 connect(connectServerBtn,SIGNAL( clicked()),SLOT( connector() )); 222 connectServerBtn->setToggleButton(TRUE);
223 connect(connectServerBtn,SIGNAL( toggled( bool)),SLOT( connectorBtnToggled(bool) ));
228 224
229 225
230 QSpacerItem* spacer = new QSpacerItem( 20, 20, QSizePolicy::Minimum, QSizePolicy::Expanding ); 226 QSpacerItem* spacer = new QSpacerItem( 20, 20, QSizePolicy::Minimum, QSizePolicy::Expanding );
231 tabLayout_3->addItem( spacer, 5, 0 ); 227 tabLayout_3->addItem( spacer, 5, 0 );
232 228
233 TabWidget->insertTab( tab_3, tr( "Config" ) ); 229 TabWidget->insertTab( tab_3, tr( "Config" ) );
234 230
235 connect(TabWidget,SIGNAL(currentChanged(QWidget *)), 231 connect(TabWidget,SIGNAL(currentChanged(QWidget *)),
236 this,SLOT(tabChanged(QWidget*))); 232 this,SLOT(tabChanged(QWidget*)));
237 233
238 currentDir.setFilter( QDir::Files | QDir::Dirs/* | QDir::Hidden*/ | QDir::All); 234 currentDir.setFilter( QDir::Files | QDir::Dirs/* | QDir::Hidden*/ | QDir::All);
239 currentDir.setPath( QDir::currentDirPath()); 235 currentDir.setPath( QDir::currentDirPath());
240// currentDir.setSorting(/* QDir::Size*/ /*| QDir::Reversed | */QDir::DirsFirst); 236// currentDir.setSorting(/* QDir::Size*/ /*| QDir::Reversed | */QDir::DirsFirst);
241 currentPathEdit = new QLineEdit( "/", this, "currentPathEdit" ); 237 currentPathEdit = new QLineEdit( "/", this, "currentPathEdit" );
242 layout->addMultiCellWidget( currentPathEdit, 3, 3, 0, 3 ); 238 layout->addMultiCellWidget( currentPathEdit, 3, 3, 0, 3 );
243 239
244 currentPathEdit->setText( currentDir.canonicalPath()); 240 currentPathEdit->setText( currentDir.canonicalPath());
245 connect( currentPathEdit,SIGNAL(returnPressed()),this,SLOT(currentPathEditChanged())); 241 connect( currentPathEdit,SIGNAL(returnPressed()),this,SLOT(currentPathEditChanged()));
246 242
247 ProgressBar = new QProgressBar( this, "ProgressBar" ); 243 ProgressBar = new QProgressBar( this, "ProgressBar" );
248 layout->addMultiCellWidget( ProgressBar, 4, 4, 0, 3 ); 244 layout->addMultiCellWidget( ProgressBar, 4, 4, 0, 3 );
249 245
250 serverComboSelected(0); 246 serverComboSelected(0);
251#ifdef DEVELOPER_VERSION 247 fillCombos();
252// ServerComboBox->lineEdit()->setText( tr( "llornkcor.com" ) ); 248
249#ifdef DEVELOPERS_VERSION
253 ServerComboBox->lineEdit()->setText( tr( "192.168.129.201" ) ); 250 ServerComboBox->lineEdit()->setText( tr( "192.168.129.201" ) );
254 UsernameComboBox->lineEdit()->setText("root"); 251 UsernameComboBox->lineEdit()->setText("root");
255// UsernameComboBox->lineEdit()->setText("llornkcor");
256 PortSpinBox->setValue( 4242); 252 PortSpinBox->setValue( 4242);
257 remotePath->setText( currentRemoteDir = "/"); 253 remotePath->setText( currentRemoteDir = "/");
254// ServerComboBox->lineEdit()->setText( tr( "llornkcor.com" ) );
255// UsernameComboBox->lineEdit()->setText("llornkcor");
256// PortSpinBox->setValue( 21);
257// remotePath->setText( currentRemoteDir = "/home/llornkcor");
258 PasswordEdit->setText( tr( "" ) ); 258 PasswordEdit->setText( tr( "" ) );
259 259#endif
260#endif
261 fillCombos();
262 filterStr="*"; 260 filterStr="*";
263 b=FALSE; 261 b=FALSE;
264 populateLocalView(); 262 populateLocalView();
265 TabWidget->setCurrentPage(2); 263 TabWidget->setCurrentPage(2);
266} 264}
267 265
268OpieFtp::~OpieFtp() 266OpieFtp::~OpieFtp()
269{ 267{
270} 268}
271 269
272void OpieFtp::cleanUp() 270void OpieFtp::cleanUp()
273{ 271{
@@ -295,49 +293,136 @@ void OpieFtp::tabChanged(QWidget *w)
295 currentPathEdit->setText( currentRemoteDir ); 293 currentPathEdit->setText( currentRemoteDir );
296 tabMenu->setItemChecked(tabMenu->idAt(1),TRUE); 294 tabMenu->setItemChecked(tabMenu->idAt(1),TRUE);
297 tabMenu->setItemChecked(tabMenu->idAt(0),FALSE); 295 tabMenu->setItemChecked(tabMenu->idAt(0),FALSE);
298 tabMenu->setItemChecked(tabMenu->idAt(2),FALSE); 296 tabMenu->setItemChecked(tabMenu->idAt(2),FALSE);
299 } 297 }
300 if (TabWidget->currentPageIndex() == 2) { 298 if (TabWidget->currentPageIndex() == 2) {
301 tabMenu->setItemChecked(tabMenu->idAt(2),TRUE); 299 tabMenu->setItemChecked(tabMenu->idAt(2),TRUE);
302 tabMenu->setItemChecked(tabMenu->idAt(0),FALSE); 300 tabMenu->setItemChecked(tabMenu->idAt(0),FALSE);
303 tabMenu->setItemChecked(tabMenu->idAt(1),FALSE); 301 tabMenu->setItemChecked(tabMenu->idAt(1),FALSE);
304 } 302 }
305} 303}
306 304
305void OpieFtp::newConnection()
306{
307 UsernameComboBox->lineEdit()->setText("");
308 PasswordEdit->setText( "" );
309 ServerComboBox->lineEdit()->setText( "");
310 remotePath->setText( currentRemoteDir = "/");
311 PortSpinBox->setValue( 21);
312 TabWidget->setCurrentPage(2);
313 currentServerConfig = -1;
314}
315
316void OpieFtp::serverComboEdited(const QString & edit) {
317 if( !edit.isEmpty() ) {
318 currentServerConfig = -1;
319 qDebug("comboedited");
320 }
321}
322
323void OpieFtp::connectorBtnToggled(bool On)
324{
325 if(On) {
326 connector();
327 } else {
328 disConnector();
329 }
330
331}
332
333void OpieFtp::connector()
334{
335 QCopEnvelope ( "QPE/System", "busy()" );
336 qApp->processEvents();
337 currentRemoteDir=remotePath->text();
338 if(ServerComboBox->currentText().isEmpty()) {
339 QMessageBox::warning(this,tr("Ftp"),tr("Please set the server info"),tr("Ok"),0,0);
340 TabWidget->setCurrentPage(2);
341 ServerComboBox->setFocus();
342 connectServerBtn->setOn(FALSE);
343 connectServerBtn->setText( tr("Connect"));
344 return;
345 }
346 FtpInit();
347 TabWidget->setCurrentPage(1);
348 QString ftp_host = ServerComboBox->currentText();
349 QString ftp_user = UsernameComboBox->currentText();
350 QString ftp_pass = PasswordEdit->text();
351 QString port=PortSpinBox->cleanText();
352 port.stripWhiteSpace();
353
354 if(ftp_host.find("ftp://",0, TRUE) != -1 )
355 ftp_host=ftp_host.right(ftp_host.length()-6);
356 ftp_host+=":"+port;
357 if (!FtpConnect( ftp_host.latin1(), &conn)) {
358 QMessageBox::message(tr("Note"),tr("Unable to connect to\n")+ftp_host);
359 connectServerBtn->setOn(FALSE);
360 connectServerBtn->setText( tr("Connect"));
361 return ;
362 }
363 if (!FtpLogin( ftp_user.latin1(), ftp_pass.latin1(),conn )) {
364 QString msg;
365 msg.sprintf(tr("Unable to log in\n")+"%s",FtpLastResponse(conn));
366 msg.replace(QRegExp(":"),"\n");
367 QMessageBox::message(tr("Note"),msg);
368 if(conn)
369 FtpQuit(conn);
370 connectServerBtn->setOn(FALSE);
371 connectServerBtn->setText( tr("Connect"));
372 return ;
373 }
374 remoteDirList("/") ;
375 setCaption(ftp_host);
376 writeConfig();
377 connectServerBtn->setText( tr("Disconnect"));
378 QCopEnvelope ( "QPE/System", "notBusy()" );
379}
380
381void OpieFtp::disConnector()
382{
383 if(conn)
384 FtpQuit(conn);
385 setCaption("OpieFtp");
386 currentRemoteDir="/";
387 Remote_View->clear();
388 connectServerBtn->setText( tr("Connect"));
389 connectServerBtn->setOn(FALSE);
390
391}
392
307void OpieFtp::localUpload() 393void OpieFtp::localUpload()
308{ 394{
309 int fsz; 395 int fsz;
310 QCopEnvelope ( "QPE/System", "busy()" ); 396 QCopEnvelope ( "QPE/System", "busy()" );
311 qApp->processEvents(); 397 qApp->processEvents();
312 QString strItem = Local_View->currentItem()->text(0); 398 QString strItem = Local_View->currentItem()->text(0);
313 QString localFile = currentDir.canonicalPath()+"/"+strItem; 399 QString localFile = currentDir.canonicalPath()+"/"+strItem;
314 QString remoteFile= currentRemoteDir+strItem; 400 QString remoteFile= currentRemoteDir+strItem;
315 QFileInfo fi(localFile); 401 QFileInfo fi(localFile);
316 if( !fi.isDir()) { 402 if( !fi.isDir()) {
317 fsz=fi.size(); 403 fsz=fi.size();
318 ProgressBar->setTotalSteps(fsz); 404 ProgressBar->setTotalSteps(fsz);
319 405
320 FtpOptions(FTPLIB_CALLBACK, (long) log_progress, conn); 406 FtpOptions(FTPLIB_CALLBACK, (long) log_progress, conn);
321 FtpOptions(FTPLIB_IDLETIME, (long) 1000, conn); 407 FtpOptions(FTPLIB_IDLETIME, (long) 1000, conn);
322 FtpOptions(FTPLIB_CALLBACKARG, (long) &fsz, conn); 408 FtpOptions(FTPLIB_CALLBACKARG, (long) &fsz, conn);
323 FtpOptions(FTPLIB_CALLBACKBYTES, (long) fsz/10, conn); 409 FtpOptions(FTPLIB_CALLBACKBYTES, (long) fsz/10, conn);
324 qDebug("Put: %s, %s",localFile.latin1(),remoteFile.latin1()); 410 qDebug("Put: %s, %s",localFile.latin1(),remoteFile.latin1());
325 411
326 if( !FtpPut( localFile.latin1(), remoteFile.latin1(),FTPLIB_IMAGE, conn ) ) { 412 if( !FtpPut( localFile.latin1(), remoteFile.latin1(),FTPLIB_IMAGE, conn ) ) {
327 QString msg; 413 QString msg;
328 msg.sprintf(tr("Unable to upload\n")+"%s",FtpLastResponse(conn)); 414 msg.sprintf(tr("Unable to upload\n")+"%s",FtpLastResponse(conn));
329 msg.replace(QRegExp(":"),"\n"); 415 msg.replace(QRegExp(":"),"\n");
330 QMessageBox::message(tr("Note"),msg); 416 QMessageBox::message(tr("Note"),msg);
331// FtpQuit(conn);
332 } 417 }
333 ProgressBar->reset(); 418 ProgressBar->reset();
334 nullifyCallBack(); 419 nullifyCallBack();
335 } else { 420 } else {
336 QMessageBox::message(tr("Note"),tr("Cannot upload directories")); 421 QMessageBox::message(tr("Note"),tr("Cannot upload directories"));
337 } 422 }
338 TabWidget->setCurrentPage(1); 423 TabWidget->setCurrentPage(1);
339 remoteDirList( (const QString &)currentRemoteDir); //this also calls populate 424 remoteDirList( (const QString &)currentRemoteDir); //this also calls populate
340 QCopEnvelope ( "QPE/System", "notBusy()" ); 425 QCopEnvelope ( "QPE/System", "notBusy()" );
341} 426}
342 427
343void OpieFtp::nullifyCallBack() 428void OpieFtp::nullifyCallBack()
@@ -371,125 +456,62 @@ void OpieFtp::remoteDownload()
371 ProgressBar->setTotalSteps(fsz); 456 ProgressBar->setTotalSteps(fsz);
372 FtpOptions(FTPLIB_CALLBACK, (long) log_progress, conn); 457 FtpOptions(FTPLIB_CALLBACK, (long) log_progress, conn);
373 FtpOptions(FTPLIB_IDLETIME, (long) 1000, conn); 458 FtpOptions(FTPLIB_IDLETIME, (long) 1000, conn);
374 FtpOptions(FTPLIB_CALLBACKARG, (long) &fsz, conn); 459 FtpOptions(FTPLIB_CALLBACKARG, (long) &fsz, conn);
375 FtpOptions(FTPLIB_CALLBACKBYTES, (long) fsz/10, conn); 460 FtpOptions(FTPLIB_CALLBACKBYTES, (long) fsz/10, conn);
376 qDebug("Get: %s, %s",localFile.latin1(),remoteFile.latin1()); 461 qDebug("Get: %s, %s",localFile.latin1(),remoteFile.latin1());
377 462
378 if(!FtpGet( localFile.latin1(), remoteFile.latin1(),FTPLIB_IMAGE, conn ) ) { 463 if(!FtpGet( localFile.latin1(), remoteFile.latin1(),FTPLIB_IMAGE, conn ) ) {
379 QString msg; 464 QString msg;
380 msg.sprintf(tr("Unable to download \n")+"%s",FtpLastResponse(conn)); 465 msg.sprintf(tr("Unable to download \n")+"%s",FtpLastResponse(conn));
381 msg.replace(QRegExp(":"),"\n"); 466 msg.replace(QRegExp(":"),"\n");
382 QMessageBox::message(tr("Note"),msg); 467 QMessageBox::message(tr("Note"),msg);
383// FtpQuit(conn);
384 } 468 }
385 ProgressBar->reset(); 469 ProgressBar->reset();
386 nullifyCallBack(); 470 nullifyCallBack();
387 TabWidget->setCurrentPage(0); 471 TabWidget->setCurrentPage(0);
388 populateLocalView(); 472 populateLocalView();
389 QCopEnvelope ( "QPE/System", "notBusy()" ); 473 QCopEnvelope ( "QPE/System", "notBusy()" );
390} 474}
391 475
392
393void OpieFtp::newConnection()
394{
395 UsernameComboBox->lineEdit()->setText("");
396 PasswordEdit->setText( "" );
397 ServerComboBox->lineEdit()->setText( "");
398 remotePath->setText( currentRemoteDir = "/");
399 PortSpinBox->setValue( 21);
400 TabWidget->setCurrentPage(2);
401
402}
403
404void OpieFtp::connector()
405{
406 QCopEnvelope ( "QPE/System", "busy()" );
407 qApp->processEvents();
408 currentRemoteDir=remotePath->text();
409 if(ServerComboBox->currentText().isEmpty()) {
410 QMessageBox::warning(this,tr("Ftp"),tr("Please set the server info"),tr("Ok"),0,0);
411 TabWidget->setCurrentPage(2);
412 ServerComboBox->setFocus();
413 return;
414 }
415 FtpInit();
416 TabWidget->setCurrentPage(1);
417 QString ftp_host = ServerComboBox->currentText();
418 QString ftp_user = UsernameComboBox->currentText();
419 QString ftp_pass = PasswordEdit->text();
420 QString port=PortSpinBox->cleanText();
421 port.stripWhiteSpace();
422
423 if(ftp_host.find("ftp://",0, TRUE) != -1 )
424 ftp_host=ftp_host.right(ftp_host.length()-6);
425 ftp_host+=":"+port;
426 if (!FtpConnect( ftp_host.latin1(), &conn)) {
427 QMessageBox::message(tr("Note"),tr("Unable to connect to\n")+ftp_host);
428 return ;
429 }
430 if (!FtpLogin( ftp_user.latin1(), ftp_pass.latin1(),conn )) {
431 QString msg;
432 msg.sprintf(tr("Unable to log in\n")+"%s",FtpLastResponse(conn));
433 msg.replace(QRegExp(":"),"\n");
434 QMessageBox::message(tr("Note"),msg);
435 FtpQuit(conn);
436 return ;
437 }
438 remoteDirList("/") ;
439 setCaption(ftp_host);
440 writeConfig();
441 QCopEnvelope ( "QPE/System", "notBusy()" );
442}
443
444void OpieFtp::disConnector()
445{
446 FtpQuit(conn);
447 setCaption("OpieFtp");
448 currentRemoteDir="/";
449 Remote_View->clear();
450}
451
452bool OpieFtp::remoteDirList(const QString &dir) 476bool OpieFtp::remoteDirList(const QString &dir)
453{ 477{
454 QString tmp = QDir::homeDirPath(); 478 QString tmp = QDir::homeDirPath();
455 if(tmp.right(1) != "/") 479 if(tmp.right(1) != "/")
456 tmp+="/._temp"; 480 tmp+="/._temp";
457 else 481 else
458 tmp+="._temp"; 482 tmp+="._temp";
459// qDebug("Listing remote dir "+tmp); 483// qDebug("Listing remote dir "+tmp);
460 QCopEnvelope ( "QPE/System", "busy()" ); 484 QCopEnvelope ( "QPE/System", "busy()" );
461 if (!FtpDir( tmp.latin1(), dir.latin1(), conn) ) { 485 if (!FtpDir( tmp.latin1(), dir.latin1(), conn) ) {
462 QString msg; 486 QString msg;
463 msg.sprintf(tr("Unable to list the directory\n")+dir+"\n%s",FtpLastResponse(conn) ); 487 msg.sprintf(tr("Unable to list the directory\n")+dir+"\n%s",FtpLastResponse(conn) );
464 msg.replace(QRegExp(":"),"\n"); 488 msg.replace(QRegExp(":"),"\n");
465 QMessageBox::message(tr("Note"),msg); 489 QMessageBox::message(tr("Note"),msg);
466// FtpQuit(conn);
467 return false; 490 return false;
468 } 491 }
469 populateRemoteView() ; 492 populateRemoteView() ;
470 QCopEnvelope ( "QPE/System", "notBusy()" ); 493 QCopEnvelope ( "QPE/System", "notBusy()" );
471 return true; 494 return true;
472} 495}
473 496
474bool OpieFtp::remoteChDir(const QString &dir) 497bool OpieFtp::remoteChDir(const QString &dir)
475{ 498{
476 QCopEnvelope ( "QPE/System", "busy()" ); 499 QCopEnvelope ( "QPE/System", "busy()" );
477 if (!FtpChdir( dir.latin1(), conn )) { 500 if (!FtpChdir( dir.latin1(), conn )) {
478 QString msg; 501 QString msg;
479 msg.sprintf(tr("Unable to change directories\n")+dir+"\n%s",FtpLastResponse(conn)); 502 msg.sprintf(tr("Unable to change directories\n")+dir+"\n%s",FtpLastResponse(conn));
480 msg.replace(QRegExp(":"),"\n"); 503 msg.replace(QRegExp(":"),"\n");
481 QMessageBox::message(tr("Note"),msg); 504 QMessageBox::message(tr("Note"),msg);
482 qDebug(msg); 505 qDebug(msg);
483// FtpQuit(conn);
484 QCopEnvelope ( "QPE/System", "notBusy()" ); 506 QCopEnvelope ( "QPE/System", "notBusy()" );
485 return FALSE; 507 return FALSE;
486 } 508 }
487 QCopEnvelope ( "QPE/System", "notBusy()" ); 509 QCopEnvelope ( "QPE/System", "notBusy()" );
488 return TRUE; 510 return TRUE;
489} 511}
490 512
491void OpieFtp::populateLocalView() 513void OpieFtp::populateLocalView()
492{ 514{
493 Local_View->clear(); 515 Local_View->clear();
494 currentDir.setSorting(/* QDir::Size*/ /*| QDir::Reversed | */QDir::DirsFirst); 516 currentDir.setSorting(/* QDir::Size*/ /*| QDir::Reversed | */QDir::DirsFirst);
495 currentDir.setMatchAllDirs(TRUE); 517 currentDir.setMatchAllDirs(TRUE);
@@ -572,25 +594,25 @@ bool OpieFtp::populateRemoteView( )
572 itemFile=item; 594 itemFile=item;
573 } 595 }
574 } 596 }
575 } 597 }
576 QListViewItem * item1 = new QListViewItem( Remote_View, "../"); 598 QListViewItem * item1 = new QListViewItem( Remote_View, "../");
577 item1->setPixmap( 0, Resource::loadPixmap( "folder" )); 599 item1->setPixmap( 0, Resource::loadPixmap( "folder" ));
578 file.close(); 600 file.close();
579 if( file.exists()) 601 if( file.exists())
580 file. remove(); 602 file. remove();
581 } else 603 } else
582 qDebug("temp file not opened successfullly "+sfile); 604 qDebug("temp file not opened successfullly "+sfile);
583 Remote_View->setSorting( 4,TRUE); 605 Remote_View->setSorting( 4,TRUE);
584 606
585 return true; 607 return true;
586} 608}
587 609
588void OpieFtp::remoteListClicked(QListViewItem *selectedItem) 610void OpieFtp::remoteListClicked(QListViewItem *selectedItem)
589{ 611{
590 QCopEnvelope ( "QPE/System", "busy()" ); 612 QCopEnvelope ( "QPE/System", "busy()" );
591 QString oldRemoteCurrentDir = currentRemoteDir; 613 QString oldRemoteCurrentDir = currentRemoteDir;
592 QString strItem=selectedItem->text(0); 614 QString strItem=selectedItem->text(0);
593 strItem=strItem.simplifyWhiteSpace(); 615 strItem=strItem.simplifyWhiteSpace();
594 if(strItem == "../") { // the user wants to go ^ 616 if(strItem == "../") { // the user wants to go ^
595 if( FtpCDUp( conn) == 0) { 617 if( FtpCDUp( conn) == 0) {
596 QString msg; 618 QString msg;
@@ -777,25 +799,25 @@ void OpieFtp::localDelete()
777{ 799{
778 QString f = Local_View->currentItem()->text(0); 800 QString f = Local_View->currentItem()->text(0);
779 if(QDir(f).exists() ) { 801 if(QDir(f).exists() ) {
780 switch ( QMessageBox::warning(this,tr("Delete"),tr("Do you really want to delete\n")+f+ 802 switch ( QMessageBox::warning(this,tr("Delete"),tr("Do you really want to delete\n")+f+
781 tr(" ?\nIt must be empty"),tr("Yes"),tr("No"),0,0,1) ) { 803 tr(" ?\nIt must be empty"),tr("Yes"),tr("No"),0,0,1) ) {
782 case 0: { 804 case 0: {
783 f=currentDir.canonicalPath()+"/"+f; 805 f=currentDir.canonicalPath()+"/"+f;
784 QString cmd="rmdir "+f; 806 QString cmd="rmdir "+f;
785 system( cmd.latin1()); 807 system( cmd.latin1());
786 populateLocalView(); 808 populateLocalView();
787 } 809 }
788 break; 810 break;
789 case 1: 811 case 1:
790 // exit 812 // exit
791 break; 813 break;
792 }; 814 };
793 815
794 } else { 816 } else {
795 switch ( QMessageBox::warning(this,tr("Delete"),tr("Do you really want to delete\n")+f 817 switch ( QMessageBox::warning(this,tr("Delete"),tr("Do you really want to delete\n")+f
796 +" ?",tr("Yes"),tr("No"),0,0,1) ) { 818 +" ?",tr("Yes"),tr("No"),0,0,1) ) {
797 case 0: { 819 case 0: {
798 f=currentDir.canonicalPath()+"/"+f; 820 f=currentDir.canonicalPath()+"/"+f;
799 QString cmd="rm "+f; 821 QString cmd="rm "+f;
800 system( cmd.latin1()); 822 system( cmd.latin1());
801 populateLocalView(); 823 populateLocalView();
@@ -836,25 +858,25 @@ void OpieFtp::remoteDelete()
836 QString path= currentRemoteDir+f; 858 QString path= currentRemoteDir+f;
837 switch ( QMessageBox::warning(this,tr("Delete"),tr("Do you really want to delete\n")+f+"?" 859 switch ( QMessageBox::warning(this,tr("Delete"),tr("Do you really want to delete\n")+f+"?"
838 ,tr("Yes"),tr("No"),0,0,1) ) { 860 ,tr("Yes"),tr("No"),0,0,1) ) {
839 case 0: { 861 case 0: {
840 f=currentDir.canonicalPath()+"/"+f; 862 f=currentDir.canonicalPath()+"/"+f;
841 if(FtpRmdir( path.latin1(), conn) ==0) { 863 if(FtpRmdir( path.latin1(), conn) ==0) {
842 QString msg; 864 QString msg;
843 msg.sprintf(tr("Unable to remove directory\n")+"%s",FtpLastResponse(conn)); 865 msg.sprintf(tr("Unable to remove directory\n")+"%s",FtpLastResponse(conn));
844 msg.replace(QRegExp(":"),"\n"); 866 msg.replace(QRegExp(":"),"\n");
845 QMessageBox::message(tr("Note"),msg); 867 QMessageBox::message(tr("Note"),msg);
846 } 868 }
847 remoteDirList( (const QString &)currentRemoteDir); //this also calls populate 869 remoteDirList( (const QString &)currentRemoteDir); //this also calls populate
848 870
849 } 871 }
850 break; 872 break;
851 }; 873 };
852 } else { 874 } else {
853 switch ( QMessageBox::warning(this,tr("Delete"),tr("Do you really want to delete\n")+f+"?" 875 switch ( QMessageBox::warning(this,tr("Delete"),tr("Do you really want to delete\n")+f+"?"
854 ,tr("Yes"),tr("No"),0,0,1) ) { 876 ,tr("Yes"),tr("No"),0,0,1) ) {
855 case 0: { 877 case 0: {
856 QString path= currentRemoteDir+f; 878 QString path= currentRemoteDir+f;
857 if(FtpDelete( path.latin1(), conn)==0) { 879 if(FtpDelete( path.latin1(), conn)==0) {
858 QString msg; 880 QString msg;
859 msg.sprintf(tr("Unable to delete file\n")+"%s",FtpLastResponse(conn)); 881 msg.sprintf(tr("Unable to delete file\n")+"%s",FtpLastResponse(conn));
860 msg.replace(QRegExp(":"),"\n"); 882 msg.replace(QRegExp(":"),"\n");
@@ -939,74 +961,84 @@ void OpieFtp::switchToLocalTab()
939} 961}
940 962
941void OpieFtp::switchToRemoteTab() 963void OpieFtp::switchToRemoteTab()
942{ 964{
943 TabWidget->setCurrentPage(1); 965 TabWidget->setCurrentPage(1);
944} 966}
945 967
946void OpieFtp::switchToConfigTab() 968void OpieFtp::switchToConfigTab()
947{ 969{
948 TabWidget->setCurrentPage(2); 970 TabWidget->setCurrentPage(2);
949} 971}
950 972
951void OpieFtp::readConfig() { 973void OpieFtp::readConfig()
974{
952 975
953 Config cfg("opieftp"); 976 Config cfg("opieftp");
954 cfg.setGroup("Server"); 977 cfg.setGroup("Server");
955 QString username, remoteServer, remotePathStr, password, port, temp; 978 QString username, remoteServer, remotePathStr, password, port, temp;
956 int numberOfEntries = cfg.readNumEntry("numberOfEntries",0); 979 int numberOfEntries = cfg.readNumEntry("numberOfEntries",0);
957 for (int i = 0; i <= numberOfEntries; i++) { 980 for (int i = 0; i <= numberOfEntries; i++) {
958 temp.setNum(i+1); 981 temp.setNum(i+1);
959 cfg.setGroup("Server"); 982 cfg.setGroup("Server");
960 remoteServer = cfg.readEntry( temp,""); 983 remoteServer = cfg.readEntry( temp,"");
961 ServerComboBox->insertItem( remoteServer ); 984 ServerComboBox->insertItem( remoteServer );
962 cfg.setGroup(temp); 985 cfg.setGroup(temp);
963 986
964 remotePathStr = cfg.readEntry(remoteServer,""); 987 remotePathStr = cfg.readEntry(remoteServer,"");
965 int divider = remoteServer.length() - remoteServer.find(":",0,TRUE); 988 int divider = remoteServer.length() - remoteServer.find(":",0,TRUE);
966 port = remoteServer.right( divider+1); 989 port = remoteServer.right( divider+1);
967 bool ok; 990 bool ok;
968 PortSpinBox->setValue( port.toInt(&ok,10)); 991 PortSpinBox->setValue( port.toInt(&ok,10));
969 992
970 remoteServer = remoteServer.left(divider - 1); 993 remoteServer = remoteServer.left(divider - 1);
971 remotePath->setText( remotePathStr); 994 remotePath->setText( remotePathStr);
972 username = cfg.readEntry(temp); 995 username = cfg.readEntry(temp);
973 UsernameComboBox->insertItem(username); 996 UsernameComboBox->insertItem(username);
974 password = cfg.readEntryCrypt(username,""); 997 password = cfg.readEntryCrypt(username,"");
975 PasswordEdit->setText(password); 998 PasswordEdit->setText(password);
976
977 } 999 }
978
979} 1000}
980 1001
981void OpieFtp::writeConfig() { 1002void OpieFtp::writeConfig()
1003{
982 1004
983 Config cfg("opieftp"); 1005 Config cfg("opieftp");
984 cfg.setGroup("Server"); 1006 cfg.setGroup("Server");
985 QString temp; 1007 QString username, remoteServerStr, remotePathStr, password, port, temp;
986 int numberOfEntries = cfg.readNumEntry("numberOfEntries",0); 1008 int numberOfEntries = cfg.readNumEntry("numberOfEntries",0);
1009 if( currentServerConfig == -1) {
1010
1011 temp.setNum( numberOfEntries + 1);
1012 cfg.setGroup("Server");
1013 remoteServerStr = cfg.readEntry( temp,"");
1014 int divider = remoteServerStr.length() - remoteServerStr.find(":",0,TRUE);
1015 remoteServerStr = remoteServerStr.left(remoteServerStr.length()-divider);
1016
987 temp.setNum(numberOfEntries+1); 1017 temp.setNum(numberOfEntries+1);
988 cfg.setGroup("Server"); 1018 cfg.setGroup("Server");
989 cfg.writeEntry( temp, ServerComboBox->currentText() +":"+PortSpinBox->cleanText() ); 1019 cfg.writeEntry( temp, ServerComboBox->currentText() +":"+PortSpinBox->cleanText() );
990 cfg.setGroup(temp); 1020 cfg.setGroup(temp);
991 cfg.writeEntry("RemotePath", remotePath->text()); 1021 cfg.writeEntry("RemotePath", remotePath->text());
992 cfg.writeEntry("Username", UsernameComboBox->currentText()); 1022 cfg.writeEntry("Username", UsernameComboBox->currentText());
993 cfg.writeEntryCrypt( UsernameComboBox->currentText(), PasswordEdit->text()); 1023 cfg.writeEntryCrypt( UsernameComboBox->currentText(), PasswordEdit->text());
994 cfg.setGroup("Server"); 1024 cfg.setGroup("Server");
995 cfg.writeEntry("numberOfEntries", QString::number(numberOfEntries + 1 )); 1025 cfg.writeEntry("numberOfEntries", QString::number(numberOfEntries + 1 ));
996 1026
1027 }
997} 1028}
998 1029
999void OpieFtp::fillCombos() { 1030void OpieFtp::fillCombos()
1000 Config cfg("opieftp"); 1031{
1032 Config cfg("opieftp");
1001 cfg.setGroup("Server"); 1033 cfg.setGroup("Server");
1002 QString username, remoteServerStr, remotePathStr, password, port, temp; 1034 QString username, remoteServerStr, remotePathStr, password, port, temp;
1003 int numberOfEntries = cfg.readNumEntry("numberOfEntries",0); 1035 int numberOfEntries = cfg.readNumEntry("numberOfEntries",0);
1004 for (int i = 1; i <= numberOfEntries; i++) { 1036 for (int i = 1; i <= numberOfEntries; i++) {
1005 temp.setNum(i); 1037 temp.setNum(i);
1006 cfg.setGroup("Server"); 1038 cfg.setGroup("Server");
1007 remoteServerStr = cfg.readEntry( temp,""); 1039 remoteServerStr = cfg.readEntry( temp,"");
1008 int divider = remoteServerStr.length() - remoteServerStr.find(":",0,TRUE); 1040 int divider = remoteServerStr.length() - remoteServerStr.find(":",0,TRUE);
1009 port = remoteServerStr.right( divider - 1); 1041 port = remoteServerStr.right( divider - 1);
1010 bool ok; 1042 bool ok;
1011 PortSpinBox->setValue( port.toInt(&ok,10)); 1043 PortSpinBox->setValue( port.toInt(&ok,10));
1012 1044
@@ -1017,56 +1049,68 @@ void OpieFtp::fillCombos() {
1017// remotePathStr = cfg.readEntry(remoteServer,""); 1049// remotePathStr = cfg.readEntry(remoteServer,"");
1018// int divider = remoteServer.length() - remoteServer.find(":",0,TRUE); 1050// int divider = remoteServer.length() - remoteServer.find(":",0,TRUE);
1019// port = remoteServer.right( divider+1); 1051// port = remoteServer.right( divider+1);
1020// PortSpinBox->setValue( port); 1052// PortSpinBox->setValue( port);
1021 1053
1022// remoteServer = remoteServer.left(divider - 1); 1054// remoteServer = remoteServer.left(divider - 1);
1023// remotePath->setText( remotePathStr); 1055// remotePath->setText( remotePathStr);
1024 1056
1025// username = cfg.readEntry(temp); 1057// username = cfg.readEntry(temp);
1026// UsernameComboBox->insertItem(username); 1058// UsernameComboBox->insertItem(username);
1027// password = cfg.readEntryCrypt(username,""); 1059// password = cfg.readEntryCrypt(username,"");
1028// PasswordEdit->setText(password); 1060// PasswordEdit->setText(password);
1029
1030 } 1061 }
1031
1032} 1062}
1033 1063
1034 1064
1035void OpieFtp::serverComboSelected(int index) { 1065void OpieFtp::serverComboSelected(int index)
1036 1066{
1067 currentServerConfig = index;
1037 QString username, remoteServerStr, remotePathStr, password, port, temp; 1068 QString username, remoteServerStr, remotePathStr, password, port, temp;
1038// remoteServerStr = ServerComboBox->text(index); 1069// remoteServerStr = ServerComboBox->text(index);
1039 Config cfg("opieftp"); 1070 Config cfg("opieftp");
1040 cfg.setGroup("Server"); 1071 cfg.setGroup("Server");
1041 int numberOfEntries = cfg.readNumEntry("numberOfEntries",0); 1072 int numberOfEntries = cfg.readNumEntry("numberOfEntries",0);
1042 1073
1043// for (int i = 0; i <= numberOfEntries; i++) { 1074 temp.setNum(index+1);
1044 temp.setNum(index+1); 1075 remoteServerStr = cfg.readEntry( temp,"");
1045 remoteServerStr = cfg.readEntry( temp,""); 1076 cfg.setGroup(temp);
1046 // if( remoteServerStr.find( ServerComboBox->text(index),0,TRUE) != -1 ) { 1077 qDebug(temp);
1047 cfg.setGroup(temp); 1078 int divider = remoteServerStr.length() - remoteServerStr.find(":",0,TRUE);
1048 qDebug(temp); 1079 port = remoteServerStr.right( divider - 1);
1049 int divider = remoteServerStr.length() - remoteServerStr.find(":",0,TRUE); 1080 bool ok;
1050 port = remoteServerStr.right( divider - 1); 1081 int portInt = port.toInt(&ok,10);
1051 bool ok; 1082 if( portInt == 0) portInt = 21;
1052 PortSpinBox->setValue( port.toInt(&ok,10));
1053 1083
1054 remotePath->setText(cfg.readEntry("RemotePath", "")); 1084 PortSpinBox->setValue( portInt);
1055 username = cfg.readEntry("Username", "");
1056 UsernameComboBox->lineEdit()->setText(username);
1057 PasswordEdit->setText(cfg.readEntryCrypt(username, ""));
1058 1085
1059// } 1086 remotePath->setText(cfg.readEntry("RemotePath", "/"));
1060 1087
1061 // } 1088 username = cfg.readEntry("Username", "anonymous");
1062 update(); 1089 UsernameComboBox->lineEdit()->setText(username);
1090 PasswordEdit->setText(cfg.readEntryCrypt(username, "me@opieftp.org"));
1091 update();
1063} 1092}
1064// UsernameComboBox->lineEdit()->setText("root"); 1093// UsernameComboBox->lineEdit()->setText("root");
1065// PasswordEdit->setText( tr( "" ) ); 1094// PasswordEdit->setText( tr( "" ) );
1066// ServerComboBox->lineEdit()->setText( tr( "192.168.129.201" ) ); 1095// ServerComboBox->lineEdit()->setText( tr( "192.168.129.201" ) );
1067// remotePath->setText( currentRemoteDir = "/home/llornkcor/"); 1096// remotePath->setText( currentRemoteDir = "/home/llornkcor/");
1068// PortSpinBox->setValue( 4242); 1097// PortSpinBox->setValue( 4242);
1069 1098
1070void OpieFtp::deleteServer() { 1099void OpieFtp::deleteServer()
1071 1100{
1101 QString username, remoteServerStr, remotePathStr, password, port, temp;
1102 remoteServerStr = ServerComboBox->currentText( );
1103 username = UsernameComboBox->currentText();
1104 Config cfg("opieftp");
1105 cfg.setGroup("Server");
1106 int numberOfEntries = cfg.readNumEntry("numberOfEntries",0);
1107 for (int i = 0; i <= numberOfEntries; i++) {
1108 temp.setNum(i+1);
1109 cfg.setGroup("Server");
1110 if( cfg.readEntry( temp,"").find( remoteServerStr,0,TRUE) != -1
1111 && cfg.readEntry(temp).find(username,0,TRUE) != -1
1112 && !remoteServerStr.isEmpty()) {
1113 qDebug(temp);
1114 }
1115 }
1072} 1116}
diff --git a/noncore/net/opieftp/opieftp.h b/noncore/net/opieftp/opieftp.h
index c88a15b..52ed885 100644
--- a/noncore/net/opieftp/opieftp.h
+++ b/noncore/net/opieftp/opieftp.h
@@ -27,49 +27,52 @@ class 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;
39 40
40class OpieFtp : public QMainWindow 41class OpieFtp : public QMainWindow
41{ 42{
42 Q_OBJECT 43 Q_OBJECT
43 44
44public: 45public:
45 OpieFtp( ); 46 OpieFtp( );
46 ~OpieFtp(); 47 ~OpieFtp();
47 48
48 QTabWidget *TabWidget; 49 QTabWidget *TabWidget;
49 QWidget *tab, *tab_2, *tab_3; 50 QWidget *tab, *tab_2, *tab_3;
50 QListView *Local_View, *Remote_View; 51 QListView *Local_View, *Remote_View;
51 52
52 QComboBox *UsernameComboBox, *ServerComboBox; 53 QComboBox *UsernameComboBox, *ServerComboBox;
53 QLineEdit *PasswordEdit, *remotePath, *currentPathEdit; 54 QLineEdit *PasswordEdit, *remotePath, *currentPathEdit;
54 QLabel *TextLabel2, *TextLabel1, *TextLabel3, *TextLabel4;; 55 QLabel *TextLabel2, *TextLabel1, *TextLabel3, *TextLabel4;;
55 QSpinBox* PortSpinBox; 56 QSpinBox* PortSpinBox;
56 QPopupMenu *connectionMenu, *localMenu, *remoteMenu, *tabMenu; 57 QPopupMenu *connectionMenu, *localMenu, *remoteMenu, *tabMenu;
57 QDir currentDir; 58 QDir currentDir;
58 QString currentRemoteDir; 59 QString currentRemoteDir;
59 QString filterStr; 60 QString filterStr;
60 QListViewItem * item; 61 QListViewItem * item;
62 QPushButton *connectServerBtn;
61 bool b; 63 bool b;
62 64 int currentServerConfig;
63protected slots: 65protected slots:
66 void serverComboEdited(const QString & );
64 void showLocalMenu( QListViewItem *); 67 void showLocalMenu( QListViewItem *);
65 void showRemoteMenu( QListViewItem *); 68 void showRemoteMenu( QListViewItem *);
66 void doLocalCd(); 69 void doLocalCd();
67 void doRemoteCd(); 70 void doRemoteCd();
68 void localUpload(); 71 void localUpload();
69 void remoteDownload(); 72 void remoteDownload();
70 void newConnection(); 73 void newConnection();
71 void connector(); 74 void connector();
72 void disConnector(); 75 void disConnector();
73 void populateLocalView(); 76 void populateLocalView();
74 bool populateRemoteView(); 77 bool populateRemoteView();
75 void showHidden(); 78 void showHidden();
@@ -87,22 +90,22 @@ protected slots:
87 bool remoteChDir(const QString &); 90 bool remoteChDir(const QString &);
88 void tabChanged(QWidget*); 91 void tabChanged(QWidget*);
89 void cleanUp(); 92 void cleanUp();
90 void remoteRename(); 93 void remoteRename();
91 void localRename(); 94 void localRename();
92 void currentPathEditChanged(); 95 void currentPathEditChanged();
93 void switchToLocalTab(); 96 void switchToLocalTab();
94 void switchToRemoteTab(); 97 void switchToRemoteTab();
95 void switchToConfigTab(); 98 void switchToConfigTab();
96 void fillCombos(); 99 void fillCombos();
97 void serverComboSelected(int); 100 void serverComboSelected(int);
98 void deleteServer(); 101 void deleteServer();
99 102 void connectorBtnToggled(bool);
100protected: 103protected:
101 void nullifyCallBack(); 104 void nullifyCallBack();
102 QGridLayout* tabLayout; 105 QGridLayout* tabLayout;
103 QGridLayout* tabLayout_2; 106 QGridLayout* tabLayout_2;
104 QGridLayout* tabLayout_3; 107 QGridLayout* tabLayout_3;
105 108
106}; 109};
107 110
108#endif // OPIEFTP_H 111#endif // OPIEFTP_H