summaryrefslogtreecommitdiff
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/net/opieftp/opieftp.cpp5
1 files changed, 4 insertions, 1 deletions
diff --git a/noncore/net/opieftp/opieftp.cpp b/noncore/net/opieftp/opieftp.cpp
index f1b159c..6e9dc67 100644
--- a/noncore/net/opieftp/opieftp.cpp
+++ b/noncore/net/opieftp/opieftp.cpp
@@ -209,257 +209,260 @@ OpieFtp::OpieFtp( )
209 TextLabel4 = new QLabel( tab_3, "TextLabel4" ); 209 TextLabel4 = new QLabel( tab_3, "TextLabel4" );
210 TextLabel4->setText( tr( "Port" ) ); 210 TextLabel4->setText( tr( "Port" ) );
211 tabLayout_3->addMultiCellWidget( TextLabel4, 4, 4, 0, 1 ); 211 tabLayout_3->addMultiCellWidget( TextLabel4, 4, 4, 0, 1 );
212 212
213 PortSpinBox = new QSpinBox( tab_3, "PortSpinBox" ); 213 PortSpinBox = new QSpinBox( tab_3, "PortSpinBox" );
214 PortSpinBox->setButtonSymbols( QSpinBox::UpDownArrows ); 214 PortSpinBox->setButtonSymbols( QSpinBox::UpDownArrows );
215 PortSpinBox->setMaxValue(32786); 215 PortSpinBox->setMaxValue(32786);
216 PortSpinBox->setValue( 4242); 216 PortSpinBox->setValue( 4242);
217// PortSpinBox->setValue( 21); 217// PortSpinBox->setValue( 21);
218 tabLayout_3->addMultiCellWidget( PortSpinBox, 4, 4, 1, 1); 218 tabLayout_3->addMultiCellWidget( PortSpinBox, 4, 4, 1, 1);
219 219
220 QSpacerItem* spacer = new QSpacerItem( 20, 20, QSizePolicy::Minimum, QSizePolicy::Expanding ); 220 QSpacerItem* spacer = new QSpacerItem( 20, 20, QSizePolicy::Minimum, QSizePolicy::Expanding );
221 tabLayout_3->addItem( spacer, 5, 0 ); 221 tabLayout_3->addItem( spacer, 5, 0 );
222 222
223 TabWidget->insertTab( tab_3, tr( "Config" ) ); 223 TabWidget->insertTab( tab_3, tr( "Config" ) );
224 224
225 connect(TabWidget,SIGNAL(currentChanged(QWidget *)), 225 connect(TabWidget,SIGNAL(currentChanged(QWidget *)),
226 this,SLOT(tabChanged(QWidget*))); 226 this,SLOT(tabChanged(QWidget*)));
227 227
228 currentDir.setFilter( QDir::Files | QDir::Dirs/* | QDir::Hidden*/ | QDir::All); 228 currentDir.setFilter( QDir::Files | QDir::Dirs/* | QDir::Hidden*/ | QDir::All);
229 currentDir.setPath( QDir::currentDirPath()); 229 currentDir.setPath( QDir::currentDirPath());
230// currentDir.setSorting(/* QDir::Size*/ /*| QDir::Reversed | */QDir::DirsFirst); 230// currentDir.setSorting(/* QDir::Size*/ /*| QDir::Reversed | */QDir::DirsFirst);
231 currentPathEdit = new QLineEdit( "/", this, "currentPathEdit" ); 231 currentPathEdit = new QLineEdit( "/", this, "currentPathEdit" );
232 layout->addMultiCellWidget( currentPathEdit, 3, 3, 0, 3 ); 232 layout->addMultiCellWidget( currentPathEdit, 3, 3, 0, 3 );
233 233
234 currentPathEdit->setText( currentDir.canonicalPath()); 234 currentPathEdit->setText( currentDir.canonicalPath());
235 connect( currentPathEdit,SIGNAL(returnPressed()),this,SLOT(currentPathEditChanged())); 235 connect( currentPathEdit,SIGNAL(returnPressed()),this,SLOT(currentPathEditChanged()));
236 236
237 ProgressBar = new QProgressBar( this, "ProgressBar" ); 237 ProgressBar = new QProgressBar( this, "ProgressBar" );
238 layout->addMultiCellWidget( ProgressBar, 4, 4, 0, 3 ); 238 layout->addMultiCellWidget( ProgressBar, 4, 4, 0, 3 );
239 239
240 filterStr="*"; 240 filterStr="*";
241 b=FALSE; 241 b=FALSE;
242 populateLocalView(); 242 populateLocalView();
243} 243}
244 244
245OpieFtp::~OpieFtp() 245OpieFtp::~OpieFtp()
246{ 246{
247} 247}
248 248
249void OpieFtp::cleanUp() 249void OpieFtp::cleanUp()
250{ 250{
251 if(conn) 251 if(conn)
252 FtpQuit(conn); 252 FtpQuit(conn);
253 QString sfile=QDir::homeDirPath(); 253 QString sfile=QDir::homeDirPath();
254 if(sfile.right(1) != "/") 254 if(sfile.right(1) != "/")
255 sfile+="/._temp"; 255 sfile+="/._temp";
256 else 256 else
257 sfile+="._temp"; 257 sfile+="._temp";
258 QFile file( sfile); 258 QFile file( sfile);
259 if(file.exists()) 259 if(file.exists())
260 file.remove(); 260 file.remove();
261} 261}
262 262
263void OpieFtp::tabChanged(QWidget *w) 263void OpieFtp::tabChanged(QWidget *w)
264{ 264{
265 if (TabWidget->currentPageIndex() == 0) { 265 if (TabWidget->currentPageIndex() == 0) {
266 currentPathEdit->setText( currentDir.canonicalPath()); 266 currentPathEdit->setText( currentDir.canonicalPath());
267 tabMenu->setItemChecked(tabMenu->idAt(0),TRUE); 267 tabMenu->setItemChecked(tabMenu->idAt(0),TRUE);
268 tabMenu->setItemChecked(tabMenu->idAt(1),FALSE); 268 tabMenu->setItemChecked(tabMenu->idAt(1),FALSE);
269 tabMenu->setItemChecked(tabMenu->idAt(2),FALSE); 269 tabMenu->setItemChecked(tabMenu->idAt(2),FALSE);
270 } 270 }
271 if (TabWidget->currentPageIndex() == 1) { 271 if (TabWidget->currentPageIndex() == 1) {
272 currentPathEdit->setText( currentRemoteDir ); 272 currentPathEdit->setText( currentRemoteDir );
273 tabMenu->setItemChecked(tabMenu->idAt(1),TRUE); 273 tabMenu->setItemChecked(tabMenu->idAt(1),TRUE);
274 tabMenu->setItemChecked(tabMenu->idAt(0),FALSE); 274 tabMenu->setItemChecked(tabMenu->idAt(0),FALSE);
275 tabMenu->setItemChecked(tabMenu->idAt(2),FALSE); 275 tabMenu->setItemChecked(tabMenu->idAt(2),FALSE);
276 } 276 }
277 if (TabWidget->currentPageIndex() == 2) { 277 if (TabWidget->currentPageIndex() == 2) {
278 tabMenu->setItemChecked(tabMenu->idAt(2),TRUE); 278 tabMenu->setItemChecked(tabMenu->idAt(2),TRUE);
279 tabMenu->setItemChecked(tabMenu->idAt(0),FALSE); 279 tabMenu->setItemChecked(tabMenu->idAt(0),FALSE);
280 tabMenu->setItemChecked(tabMenu->idAt(1),FALSE); 280 tabMenu->setItemChecked(tabMenu->idAt(1),FALSE);
281 } 281 }
282} 282}
283 283
284void OpieFtp::localUpload() 284void OpieFtp::localUpload()
285{ 285{
286 int fsz; 286 int fsz;
287 QCopEnvelope ( "QPE/System", "busy()" ); 287 QCopEnvelope ( "QPE/System", "busy()" );
288 qApp->processEvents(); 288 qApp->processEvents();
289 QString strItem = Local_View->currentItem()->text(0); 289 QString strItem = Local_View->currentItem()->text(0);
290 QString localFile = currentDir.canonicalPath()+"/"+strItem; 290 QString localFile = currentDir.canonicalPath()+"/"+strItem;
291 QString remoteFile= currentRemoteDir+strItem; 291 QString remoteFile= currentRemoteDir+strItem;
292 QFileInfo fi(localFile); 292 QFileInfo fi(localFile);
293 if( !fi.isDir()) { 293 if( !fi.isDir()) {
294 fsz=fi.size(); 294 fsz=fi.size();
295 ProgressBar->setTotalSteps(fsz); 295 ProgressBar->setTotalSteps(fsz);
296 296
297 FtpOptions(FTPLIB_CALLBACK, (long) log_progress, conn); 297 FtpOptions(FTPLIB_CALLBACK, (long) log_progress, conn);
298 FtpOptions(FTPLIB_IDLETIME, (long) 1000, conn); 298 FtpOptions(FTPLIB_IDLETIME, (long) 1000, conn);
299 FtpOptions(FTPLIB_CALLBACKARG, (long) &fsz, conn); 299 FtpOptions(FTPLIB_CALLBACKARG, (long) &fsz, conn);
300 FtpOptions(FTPLIB_CALLBACKBYTES, (long) fsz/10, conn); 300 FtpOptions(FTPLIB_CALLBACKBYTES, (long) fsz/10, conn);
301 qDebug("Put: %s, %s",localFile.latin1(),remoteFile.latin1()); 301 qDebug("Put: %s, %s",localFile.latin1(),remoteFile.latin1());
302 302
303 if( !FtpPut( localFile.latin1(), remoteFile.latin1(),FTPLIB_IMAGE, conn ) ) { 303 if( !FtpPut( localFile.latin1(), remoteFile.latin1(),FTPLIB_IMAGE, conn ) ) {
304 QString msg; 304 QString msg;
305 msg.sprintf(tr("Unable to upload\n")+"%s",FtpLastResponse(conn)); 305 msg.sprintf(tr("Unable to upload\n")+"%s",FtpLastResponse(conn));
306 msg.replace(QRegExp(":"),"\n"); 306 msg.replace(QRegExp(":"),"\n");
307 QMessageBox::message(tr("Note"),msg); 307 QMessageBox::message(tr("Note"),msg);
308// FtpQuit(conn); 308// FtpQuit(conn);
309 } 309 }
310 ProgressBar->reset(); 310 ProgressBar->reset();
311 nullifyCallBack(); 311 nullifyCallBack();
312 } else { 312 } else {
313 QMessageBox::message(tr("Note"),tr("Cannot upload directories")); 313 QMessageBox::message(tr("Note"),tr("Cannot upload directories"));
314 } 314 }
315 TabWidget->setCurrentPage(1); 315 TabWidget->setCurrentPage(1);
316 remoteDirList( (const QString &)currentRemoteDir); //this also calls populate 316 remoteDirList( (const QString &)currentRemoteDir); //this also calls populate
317 QCopEnvelope ( "QPE/System", "notBusy()" ); 317 QCopEnvelope ( "QPE/System", "notBusy()" );
318} 318}
319 319
320void OpieFtp::nullifyCallBack() 320void OpieFtp::nullifyCallBack()
321{ 321{
322 FtpOptions(FTPLIB_CALLBACK, NULL, conn); 322 FtpOptions(FTPLIB_CALLBACK, NULL, conn);
323 FtpOptions(FTPLIB_IDLETIME, NULL, conn); 323 FtpOptions(FTPLIB_IDLETIME, NULL, conn);
324 FtpOptions(FTPLIB_CALLBACKARG, NULL, conn); 324 FtpOptions(FTPLIB_CALLBACKARG, NULL, conn);
325 FtpOptions(FTPLIB_CALLBACKBYTES, NULL, conn); 325 FtpOptions(FTPLIB_CALLBACKBYTES, NULL, conn);
326 326
327} 327}
328 328
329void OpieFtp::remoteDownload() 329void OpieFtp::remoteDownload()
330{ 330{
331 int fsz; 331 int fsz;
332 QCopEnvelope ( "QPE/System", "busy()" ); 332 QCopEnvelope ( "QPE/System", "busy()" );
333 qApp->processEvents(); 333 qApp->processEvents();
334 QString strItem = Remote_View->currentItem()->text(0); 334 QString strItem = Remote_View->currentItem()->text(0);
335// strItem=strItem.right(strItem.length()-1); 335// strItem=strItem.right(strItem.length()-1);
336 336
337 QString localFile = currentDir.canonicalPath()+strItem; 337 QString localFile = currentDir.canonicalPath();
338 if(localFile.right(1).find("/",0,TRUE) == -1)
339 localFile += "/";
340 localFile += strItem;
338// QString localFile = currentDir.canonicalPath()+"/"+strItem; 341// QString localFile = currentDir.canonicalPath()+"/"+strItem;
339 QString remoteFile= currentRemoteDir+strItem; 342 QString remoteFile= currentRemoteDir+strItem;
340 if (!FtpSize( remoteFile.latin1(), &fsz, FTPLIB_ASCII, conn)) 343 if (!FtpSize( remoteFile.latin1(), &fsz, FTPLIB_ASCII, conn))
341 fsz = 0; 344 fsz = 0;
342 QString temp; 345 QString temp;
343 temp.sprintf( remoteFile+" "+" %dkb", fsz); 346 temp.sprintf( remoteFile+" "+" %dkb", fsz);
344 347
345 ProgressBar->setTotalSteps(fsz); 348 ProgressBar->setTotalSteps(fsz);
346 FtpOptions(FTPLIB_CALLBACK, (long) log_progress, conn); 349 FtpOptions(FTPLIB_CALLBACK, (long) log_progress, conn);
347 FtpOptions(FTPLIB_IDLETIME, (long) 1000, conn); 350 FtpOptions(FTPLIB_IDLETIME, (long) 1000, conn);
348 FtpOptions(FTPLIB_CALLBACKARG, (long) &fsz, conn); 351 FtpOptions(FTPLIB_CALLBACKARG, (long) &fsz, conn);
349 FtpOptions(FTPLIB_CALLBACKBYTES, (long) fsz/10, conn); 352 FtpOptions(FTPLIB_CALLBACKBYTES, (long) fsz/10, conn);
350 qDebug("Get: %s, %s",localFile.latin1(),remoteFile.latin1()); 353 qDebug("Get: %s, %s",localFile.latin1(),remoteFile.latin1());
351 354
352 if(!FtpGet( localFile.latin1(), remoteFile.latin1(),FTPLIB_IMAGE, conn ) ) { 355 if(!FtpGet( localFile.latin1(), remoteFile.latin1(),FTPLIB_IMAGE, conn ) ) {
353 QString msg; 356 QString msg;
354 msg.sprintf(tr("Unable to download \n")+"%s",FtpLastResponse(conn)); 357 msg.sprintf(tr("Unable to download \n")+"%s",FtpLastResponse(conn));
355 msg.replace(QRegExp(":"),"\n"); 358 msg.replace(QRegExp(":"),"\n");
356 QMessageBox::message(tr("Note"),msg); 359 QMessageBox::message(tr("Note"),msg);
357// FtpQuit(conn); 360// FtpQuit(conn);
358 } 361 }
359 ProgressBar->reset(); 362 ProgressBar->reset();
360 nullifyCallBack(); 363 nullifyCallBack();
361 TabWidget->setCurrentPage(0); 364 TabWidget->setCurrentPage(0);
362 populateLocalView(); 365 populateLocalView();
363 QCopEnvelope ( "QPE/System", "notBusy()" ); 366 QCopEnvelope ( "QPE/System", "notBusy()" );
364} 367}
365 368
366 369
367void OpieFtp::newConnection() 370void OpieFtp::newConnection()
368{ 371{
369 TabWidget->setCurrentPage(2); 372 TabWidget->setCurrentPage(2);
370} 373}
371 374
372void OpieFtp::connector() 375void OpieFtp::connector()
373{ 376{
374 QCopEnvelope ( "QPE/System", "busy()" ); 377 QCopEnvelope ( "QPE/System", "busy()" );
375 qApp->processEvents(); 378 qApp->processEvents();
376 currentRemoteDir=remotePath->text(); 379 currentRemoteDir=remotePath->text();
377 if(ServerComboBox->currentText().isEmpty()) { 380 if(ServerComboBox->currentText().isEmpty()) {
378 QMessageBox::warning(this,tr("Ftp"),tr("Please set the server info"),tr("Ok"),0,0); 381 QMessageBox::warning(this,tr("Ftp"),tr("Please set the server info"),tr("Ok"),0,0);
379 TabWidget->setCurrentPage(2); 382 TabWidget->setCurrentPage(2);
380 ServerComboBox->setFocus(); 383 ServerComboBox->setFocus();
381 return; 384 return;
382 } 385 }
383 FtpInit(); 386 FtpInit();
384 TabWidget->setCurrentPage(1); 387 TabWidget->setCurrentPage(1);
385 QString ftp_host = ServerComboBox->currentText(); 388 QString ftp_host = ServerComboBox->currentText();
386 QString ftp_user = UsernameComboBox->currentText(); 389 QString ftp_user = UsernameComboBox->currentText();
387 QString ftp_pass = PasswordEdit->text(); 390 QString ftp_pass = PasswordEdit->text();
388 QString port=PortSpinBox->cleanText(); 391 QString port=PortSpinBox->cleanText();
389 port.stripWhiteSpace(); 392 port.stripWhiteSpace();
390 393
391 if(ftp_host.find("ftp://",0, TRUE) != -1 ) 394 if(ftp_host.find("ftp://",0, TRUE) != -1 )
392 ftp_host=ftp_host.right(ftp_host.length()-6); 395 ftp_host=ftp_host.right(ftp_host.length()-6);
393 ftp_host+=":"+port; 396 ftp_host+=":"+port;
394 if (!FtpConnect( ftp_host.latin1(), &conn)) { 397 if (!FtpConnect( ftp_host.latin1(), &conn)) {
395 QMessageBox::message(tr("Note"),tr("Unable to connect to\n")+ftp_host); 398 QMessageBox::message(tr("Note"),tr("Unable to connect to\n")+ftp_host);
396 return ; 399 return ;
397 } 400 }
398 if (!FtpLogin( ftp_user.latin1(), ftp_pass.latin1(),conn )) { 401 if (!FtpLogin( ftp_user.latin1(), ftp_pass.latin1(),conn )) {
399 QString msg; 402 QString msg;
400 msg.sprintf(tr("Unable to log in\n")+"%s",FtpLastResponse(conn)); 403 msg.sprintf(tr("Unable to log in\n")+"%s",FtpLastResponse(conn));
401 msg.replace(QRegExp(":"),"\n"); 404 msg.replace(QRegExp(":"),"\n");
402 QMessageBox::message(tr("Note"),msg); 405 QMessageBox::message(tr("Note"),msg);
403 FtpQuit(conn); 406 FtpQuit(conn);
404 return ; 407 return ;
405 } 408 }
406 remoteDirList("/") ; 409 remoteDirList("/") ;
407 setCaption(ftp_host); 410 setCaption(ftp_host);
408 QCopEnvelope ( "QPE/System", "notBusy()" ); 411 QCopEnvelope ( "QPE/System", "notBusy()" );
409} 412}
410 413
411void OpieFtp::disConnector() 414void OpieFtp::disConnector()
412{ 415{
413 FtpQuit(conn); 416 FtpQuit(conn);
414 setCaption("OpieFtp"); 417 setCaption("OpieFtp");
415 currentRemoteDir="/"; 418 currentRemoteDir="/";
416 Remote_View->clear(); 419 Remote_View->clear();
417} 420}
418 421
419bool OpieFtp::remoteDirList(const QString &dir) 422bool OpieFtp::remoteDirList(const QString &dir)
420{ 423{
421 QString tmp = QDir::homeDirPath(); 424 QString tmp = QDir::homeDirPath();
422 if(tmp.right(1) != "/") 425 if(tmp.right(1) != "/")
423 tmp+="/._temp"; 426 tmp+="/._temp";
424 else 427 else
425 tmp+="._temp"; 428 tmp+="._temp";
426// qDebug("Listing remote dir "+tmp); 429// qDebug("Listing remote dir "+tmp);
427 QCopEnvelope ( "QPE/System", "busy()" ); 430 QCopEnvelope ( "QPE/System", "busy()" );
428 if (!FtpDir( tmp.latin1(), dir.latin1(), conn) ) { 431 if (!FtpDir( tmp.latin1(), dir.latin1(), conn) ) {
429 QString msg; 432 QString msg;
430 msg.sprintf(tr("Unable to list the directory\n")+dir+"\n%s",FtpLastResponse(conn) ); 433 msg.sprintf(tr("Unable to list the directory\n")+dir+"\n%s",FtpLastResponse(conn) );
431 msg.replace(QRegExp(":"),"\n"); 434 msg.replace(QRegExp(":"),"\n");
432 QMessageBox::message(tr("Note"),msg); 435 QMessageBox::message(tr("Note"),msg);
433// FtpQuit(conn); 436// FtpQuit(conn);
434 return false; 437 return false;
435 } 438 }
436 populateRemoteView() ; 439 populateRemoteView() ;
437 QCopEnvelope ( "QPE/System", "notBusy()" ); 440 QCopEnvelope ( "QPE/System", "notBusy()" );
438 return true; 441 return true;
439} 442}
440 443
441bool OpieFtp::remoteChDir(const QString &dir) 444bool OpieFtp::remoteChDir(const QString &dir)
442{ 445{
443 QCopEnvelope ( "QPE/System", "busy()" ); 446 QCopEnvelope ( "QPE/System", "busy()" );
444 if (!FtpChdir( dir.latin1(), conn )) { 447 if (!FtpChdir( dir.latin1(), conn )) {
445 QString msg; 448 QString msg;
446 msg.sprintf(tr("Unable to change directories\n")+dir+"\n%s",FtpLastResponse(conn)); 449 msg.sprintf(tr("Unable to change directories\n")+dir+"\n%s",FtpLastResponse(conn));
447 msg.replace(QRegExp(":"),"\n"); 450 msg.replace(QRegExp(":"),"\n");
448 QMessageBox::message(tr("Note"),msg); 451 QMessageBox::message(tr("Note"),msg);
449 qDebug(msg); 452 qDebug(msg);
450// FtpQuit(conn); 453// FtpQuit(conn);
451 QCopEnvelope ( "QPE/System", "notBusy()" ); 454 QCopEnvelope ( "QPE/System", "notBusy()" );
452 return FALSE; 455 return FALSE;
453 } 456 }
454 QCopEnvelope ( "QPE/System", "notBusy()" ); 457 QCopEnvelope ( "QPE/System", "notBusy()" );
455 return TRUE; 458 return TRUE;
456} 459}
457 460
458void OpieFtp::populateLocalView() 461void OpieFtp::populateLocalView()
459{ 462{
460 Local_View->clear(); 463 Local_View->clear();
461 currentDir.setSorting(/* QDir::Size*/ /*| QDir::Reversed | */QDir::DirsFirst); 464 currentDir.setSorting(/* QDir::Size*/ /*| QDir::Reversed | */QDir::DirsFirst);
462 currentDir.setMatchAllDirs(TRUE); 465 currentDir.setMatchAllDirs(TRUE);
463 currentDir.setNameFilter(filterStr); 466 currentDir.setNameFilter(filterStr);
464 QString fileL, fileS, fileDate; 467 QString fileL, fileS, fileDate;
465 bool isDir=FALSE; 468 bool isDir=FALSE;