summaryrefslogtreecommitdiff
authorllornkcor <llornkcor>2002-05-16 16:29:14 (UTC)
committer llornkcor <llornkcor>2002-05-16 16:29:14 (UTC)
commit62c1424c5421e926173133ab4acd7346c590612e (patch) (unidiff)
treef9df1716b94df11330bb7cb466e26d2e3d1f8add
parentb94bd6003bf7c2024b0f254805f54ff4e52ead6e (diff)
downloadopie-62c1424c5421e926173133ab4acd7346c590612e.zip
opie-62c1424c5421e926173133ab4acd7346c590612e.tar.gz
opie-62c1424c5421e926173133ab4acd7346c590612e.tar.bz2
fixed not loading ftp configs correctly..
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/net/opieftp/opieftp.cpp24
1 files changed, 18 insertions, 6 deletions
diff --git a/noncore/net/opieftp/opieftp.cpp b/noncore/net/opieftp/opieftp.cpp
index 7ca3fff..293c391 100644
--- a/noncore/net/opieftp/opieftp.cpp
+++ b/noncore/net/opieftp/opieftp.cpp
@@ -253,102 +253,104 @@ OpieFtp::OpieFtp( )
253 253
254 TextLabel4 = new QLabel( tab_3, "TextLabel4" ); 254 TextLabel4 = new QLabel( tab_3, "TextLabel4" );
255 TextLabel4->setText( tr( "Port" ) ); 255 TextLabel4->setText( tr( "Port" ) );
256 tabLayout_3->addMultiCellWidget( TextLabel4, 4, 4, 0, 1 ); 256 tabLayout_3->addMultiCellWidget( TextLabel4, 4, 4, 0, 1 );
257 257
258 PortSpinBox = new QSpinBox( tab_3, "PortSpinBox" ); 258 PortSpinBox = new QSpinBox( tab_3, "PortSpinBox" );
259 PortSpinBox->setButtonSymbols( QSpinBox::UpDownArrows ); 259 PortSpinBox->setButtonSymbols( QSpinBox::UpDownArrows );
260 PortSpinBox->setMaxValue(32786); 260 PortSpinBox->setMaxValue(32786);
261 tabLayout_3->addMultiCellWidget( PortSpinBox, 4, 4, 1, 1); 261 tabLayout_3->addMultiCellWidget( PortSpinBox, 4, 4, 1, 1);
262 262
263 QPushButton *deleteServerBtn; 263 QPushButton *deleteServerBtn;
264 deleteServerBtn = new QPushButton( "Delete Server", tab_3 , "OpenButton" ); 264 deleteServerBtn = new QPushButton( "Delete Server", tab_3 , "OpenButton" );
265 tabLayout_3->addMultiCellWidget( deleteServerBtn, 5, 5, 2, 3); 265 tabLayout_3->addMultiCellWidget( deleteServerBtn, 5, 5, 2, 3);
266 266
267 connect(deleteServerBtn,SIGNAL(clicked()),SLOT(deleteServer())); 267 connect(deleteServerBtn,SIGNAL(clicked()),SLOT(deleteServer()));
268 268
269 connectServerBtn = new QPushButton( "Connect", tab_3 , "ConnectButton" ); 269 connectServerBtn = new QPushButton( "Connect", tab_3 , "ConnectButton" );
270 tabLayout_3->addMultiCellWidget( connectServerBtn, 5, 5, 0, 1); 270 tabLayout_3->addMultiCellWidget( connectServerBtn, 5, 5, 0, 1);
271 connectServerBtn->setToggleButton(TRUE); 271 connectServerBtn->setToggleButton(TRUE);
272 connect(connectServerBtn,SIGNAL( toggled( bool)),SLOT( connectorBtnToggled(bool) )); 272 connect(connectServerBtn,SIGNAL( toggled( bool)),SLOT( connectorBtnToggled(bool) ));
273 273
274 QSpacerItem* spacer = new QSpacerItem( 20, 20, QSizePolicy::Minimum, QSizePolicy::Expanding ); 274 QSpacerItem* spacer = new QSpacerItem( 20, 20, QSizePolicy::Minimum, QSizePolicy::Expanding );
275 tabLayout_3->addItem( spacer, 5, 0 ); 275 tabLayout_3->addItem( spacer, 5, 0 );
276 276
277 TabWidget->insertTab( tab_3, tr( "Config" ) ); 277 TabWidget->insertTab( tab_3, tr( "Config" ) );
278 278
279 connect(TabWidget,SIGNAL(currentChanged(QWidget *)), 279 connect(TabWidget,SIGNAL(currentChanged(QWidget *)),
280 this,SLOT(tabChanged(QWidget*))); 280 this,SLOT(tabChanged(QWidget*)));
281 281
282 currentDir.setFilter( QDir::Files | QDir::Dirs/* | QDir::Hidden*/ | QDir::All); 282 currentDir.setFilter( QDir::Files | QDir::Dirs/* | QDir::Hidden*/ | QDir::All);
283 currentDir.setPath( QDir::currentDirPath()); 283 currentDir.setPath( QDir::currentDirPath());
284// currentDir.setSorting(/* QDir::Size*/ /*| QDir::Reversed | */QDir::DirsFirst); 284// currentDir.setSorting(/* QDir::Size*/ /*| QDir::Reversed | */QDir::DirsFirst);
285 285
286 currentPathCombo = new QComboBox( FALSE, this, "currentPathCombo" ); 286 currentPathCombo = new QComboBox( FALSE, this, "currentPathCombo" );
287 layout->addMultiCellWidget( currentPathCombo, 3, 3, 0, 4); 287 layout->addMultiCellWidget( currentPathCombo, 3, 3, 0, 4);
288 288
289 currentPathCombo->setEditable(TRUE); 289 currentPathCombo->setEditable(TRUE);
290 currentPathCombo->lineEdit()->setText( currentDir.canonicalPath()); 290 currentPathCombo->lineEdit()->setText( currentDir.canonicalPath());
291 291
292 connect( currentPathCombo, SIGNAL( activated( const QString & ) ), 292 connect( currentPathCombo, SIGNAL( activated( const QString & ) ),
293 this, SLOT( currentPathComboActivated( const QString & ) ) ); 293 this, SLOT( currentPathComboActivated( const QString & ) ) );
294 294
295 connect( currentPathCombo->lineEdit(),SIGNAL(returnPressed()), 295 connect( currentPathCombo->lineEdit(),SIGNAL(returnPressed()),
296 this,SLOT(currentPathComboChanged())); 296 this,SLOT(currentPathComboChanged()));
297 297
298 ProgressBar = new QProgressBar( this, "ProgressBar" ); 298 ProgressBar = new QProgressBar( this, "ProgressBar" );
299 layout->addMultiCellWidget( ProgressBar, 4, 4, 0, 4); 299 layout->addMultiCellWidget( ProgressBar, 4, 4, 0, 4);
300 300
301// fillCombos(); 301 fillCombos();
302 302
303 filterStr="*"; 303 filterStr="*";
304 b=FALSE; 304 b=FALSE;
305 populateLocalView(); 305 populateLocalView();
306 readConfig(); 306qDebug("read COnfig");
307 readConfig();
308 qDebug("Set current item");
307 ServerComboBox->setCurrentItem(currentServerConfig); 309 ServerComboBox->setCurrentItem(currentServerConfig);
308 310
309 TabWidget->setCurrentPage(2); 311 TabWidget->setCurrentPage(2);
310} 312}
311 313
312OpieFtp::~OpieFtp() 314OpieFtp::~OpieFtp()
313{ 315{
314} 316}
315 317
316void OpieFtp::cleanUp() 318void OpieFtp::cleanUp()
317{ 319{
318 if(conn) 320 if(conn)
319 FtpQuit(conn); 321 FtpQuit(conn);
320 QString sfile=QDir::homeDirPath(); 322 QString sfile=QDir::homeDirPath();
321 if(sfile.right(1) != "/") 323 if(sfile.right(1) != "/")
322 sfile+="/._temp"; 324 sfile+="/._temp";
323 else 325 else
324 sfile+="._temp"; 326 sfile+="._temp";
325 QFile file( sfile); 327 QFile file( sfile);
326 if(file.exists()) 328 if(file.exists())
327 file.remove(); 329 file.remove();
328 exit(0); 330 exit(0);
329} 331}
330 332
331void OpieFtp::tabChanged(QWidget *w) 333void OpieFtp::tabChanged(QWidget *w)
332{ 334{
333 if (TabWidget->currentPageIndex() == 0) { 335 if (TabWidget->currentPageIndex() == 0) {
334 currentPathCombo->lineEdit()->setText( currentDir.canonicalPath()); 336 currentPathCombo->lineEdit()->setText( currentDir.canonicalPath());
335 tabMenu->setItemChecked(tabMenu->idAt(0),TRUE); 337 tabMenu->setItemChecked(tabMenu->idAt(0),TRUE);
336 tabMenu->setItemChecked(tabMenu->idAt(1),FALSE); 338 tabMenu->setItemChecked(tabMenu->idAt(1),FALSE);
337 tabMenu->setItemChecked(tabMenu->idAt(2),FALSE); 339 tabMenu->setItemChecked(tabMenu->idAt(2),FALSE);
338 if(cdUpButton->isHidden()) 340 if(cdUpButton->isHidden())
339 cdUpButton->show(); 341 cdUpButton->show();
340 if(homeButton->isHidden()) 342 if(homeButton->isHidden())
341 homeButton->show(); 343 homeButton->show();
342 344
343 } 345 }
344 if (TabWidget->currentPageIndex() == 1) { 346 if (TabWidget->currentPageIndex() == 1) {
345 currentPathCombo->lineEdit()->setText( currentRemoteDir ); 347 currentPathCombo->lineEdit()->setText( currentRemoteDir );
346 tabMenu->setItemChecked(tabMenu->idAt(1),TRUE); 348 tabMenu->setItemChecked(tabMenu->idAt(1),TRUE);
347 tabMenu->setItemChecked(tabMenu->idAt(0),FALSE); 349 tabMenu->setItemChecked(tabMenu->idAt(0),FALSE);
348 tabMenu->setItemChecked(tabMenu->idAt(2),FALSE); 350 tabMenu->setItemChecked(tabMenu->idAt(2),FALSE);
349 if(cdUpButton->isHidden()) 351 if(cdUpButton->isHidden())
350 cdUpButton->show(); 352 cdUpButton->show();
351 homeButton->hide(); 353 homeButton->hide();
352 354
353 } 355 }
354 if (TabWidget->currentPageIndex() == 2) { 356 if (TabWidget->currentPageIndex() == 2) {
@@ -386,97 +388,98 @@ void OpieFtp::connectorBtnToggled(bool On)
386 disConnector(); 388 disConnector();
387 } 389 }
388 390
389} 391}
390 392
391void OpieFtp::connector() 393void OpieFtp::connector()
392{ 394{
393// QCopEnvelope ( "QPE/System", "busy()" ); 395// QCopEnvelope ( "QPE/System", "busy()" );
394// qApp->processEvents(); 396// qApp->processEvents();
395 currentRemoteDir=remotePath->text(); 397 currentRemoteDir=remotePath->text();
396 if(ServerComboBox->currentText().isEmpty()) { 398 if(ServerComboBox->currentText().isEmpty()) {
397 QMessageBox::warning(this,tr("Ftp"),tr("Please set the server info"),tr("Ok"),0,0); 399 QMessageBox::warning(this,tr("Ftp"),tr("Please set the server info"),tr("Ok"),0,0);
398 TabWidget->setCurrentPage(2); 400 TabWidget->setCurrentPage(2);
399 ServerComboBox->setFocus(); 401 ServerComboBox->setFocus();
400 connectServerBtn->setOn(FALSE); 402 connectServerBtn->setOn(FALSE);
401 connectServerBtn->setText( tr("Connect")); 403 connectServerBtn->setText( tr("Connect"));
402 return; 404 return;
403 } 405 }
404 FtpInit(); 406 FtpInit();
405 TabWidget->setCurrentPage(1); 407 TabWidget->setCurrentPage(1);
406 QString ftp_host = ServerComboBox->currentText(); 408 QString ftp_host = ServerComboBox->currentText();
407 QString ftp_user = UsernameComboBox->currentText(); 409 QString ftp_user = UsernameComboBox->currentText();
408 QString ftp_pass = PasswordEdit->text(); 410 QString ftp_pass = PasswordEdit->text();
409 QString port=PortSpinBox->cleanText(); 411 QString port=PortSpinBox->cleanText();
410 port.stripWhiteSpace(); 412 port.stripWhiteSpace();
411 413
412 if(ftp_host.find("ftp://",0, TRUE) != -1 ) 414 if(ftp_host.find("ftp://",0, TRUE) != -1 )
413 ftp_host=ftp_host.right(ftp_host.length()-6); 415 ftp_host=ftp_host.right(ftp_host.length()-6);
414 ftp_host+=":"+port; 416 ftp_host+=":"+port;
415 if (!FtpConnect( ftp_host.latin1(), &conn)) { 417 if (!FtpConnect( ftp_host.latin1(), &conn)) {
416 QMessageBox::message(tr("Note"),tr("Unable to connect to\n")+ftp_host); 418 QMessageBox::message(tr("Note"),tr("Unable to connect to\n")+ftp_host);
417 connectServerBtn->setOn(FALSE); 419 connectServerBtn->setOn(FALSE);
418 connectServerBtn->setText( tr("Connect")); 420 connectServerBtn->setText( tr("Connect"));
419 return ; 421 return ;
420 } 422 }
421 if (!FtpLogin( ftp_user.latin1(), ftp_pass.latin1(),conn )) { 423 if (!FtpLogin( ftp_user.latin1(), ftp_pass.latin1(),conn )) {
422 QString msg; 424 QString msg;
423 msg.sprintf(tr("Unable to log in\n")+"%s",FtpLastResponse(conn)); 425 msg.sprintf(tr("Unable to log in\n")+"%s",FtpLastResponse(conn));
424 msg.replace(QRegExp(":"),"\n"); 426 msg.replace(QRegExp(":"),"\n");
425 QMessageBox::message(tr("Note"),msg); 427 QMessageBox::message(tr("Note"),msg);
426 if(conn) 428 if(conn)
427 FtpQuit(conn); 429 FtpQuit(conn);
428 connectServerBtn->setOn(FALSE); 430 connectServerBtn->setOn(FALSE);
429 connectServerBtn->setText( tr("Connect")); 431 connectServerBtn->setText( tr("Connect"));
430 return ; 432 return ;
431 } 433 }
432 remoteDirList("/") ; 434 remoteDirList("/") ;
433 setCaption(ftp_host); 435 setCaption(ftp_host);
434 writeConfig(); 436 if( currentServerConfig == -1)
437 writeConfig();
435 connectServerBtn->setText( tr("Disconnect")); 438 connectServerBtn->setText( tr("Disconnect"));
436// QCopEnvelope ( "QPE/System", "notBusy()" ); 439// QCopEnvelope ( "QPE/System", "notBusy()" );
437} 440}
438 441
439void OpieFtp::disConnector() 442void OpieFtp::disConnector()
440{ 443{
441 if(conn) 444 if(conn)
442 FtpQuit(conn); 445 FtpQuit(conn);
443 setCaption("OpieFtp"); 446 setCaption("OpieFtp");
444 currentRemoteDir="/"; 447 currentRemoteDir="/";
445 Remote_View->clear(); 448 Remote_View->clear();
446 connectServerBtn->setText( tr("Connect")); 449 connectServerBtn->setText( tr("Connect"));
447 connectServerBtn->setOn(FALSE); 450 connectServerBtn->setOn(FALSE);
448 setCaption("OpieFtp"); 451 setCaption("OpieFtp");
449} 452}
450 453
451void OpieFtp::localUpload() 454void OpieFtp::localUpload()
452{ 455{
453 int fsz; 456 int fsz;
454// QCopEnvelope ( "QPE/System", "busy()" ); 457// QCopEnvelope ( "QPE/System", "busy()" );
455// qApp->processEvents(); 458// qApp->processEvents();
456 QList<QListViewItem> * getSelectedItems( QListView * Local_View ); 459 QList<QListViewItem> * getSelectedItems( QListView * Local_View );
457 QListViewItemIterator it( Local_View ); 460 QListViewItemIterator it( Local_View );
458 for ( ; it.current(); ++it ) { 461 for ( ; it.current(); ++it ) {
459 if ( it.current()->isSelected() ) { 462 if ( it.current()->isSelected() ) {
460 QString strItem = it.current()->text(0); 463 QString strItem = it.current()->text(0);
461 QString localFile = currentDir.canonicalPath()+"/"+strItem; 464 QString localFile = currentDir.canonicalPath()+"/"+strItem;
462 QString remoteFile= currentRemoteDir+strItem; 465 QString remoteFile= currentRemoteDir+strItem;
463 QFileInfo fi(localFile); 466 QFileInfo fi(localFile);
464 if( !fi.isDir()) { 467 if( !fi.isDir()) {
465 fsz=fi.size(); 468 fsz=fi.size();
466 ProgressBar->setTotalSteps(fsz); 469 ProgressBar->setTotalSteps(fsz);
467 470
468 FtpOptions(FTPLIB_CALLBACK, (long) log_progress, conn); 471 FtpOptions(FTPLIB_CALLBACK, (long) log_progress, conn);
469 FtpOptions(FTPLIB_IDLETIME, (long) 1000, conn); 472 FtpOptions(FTPLIB_IDLETIME, (long) 1000, conn);
470 FtpOptions(FTPLIB_CALLBACKARG, (long) &fsz, conn); 473 FtpOptions(FTPLIB_CALLBACKARG, (long) &fsz, conn);
471 FtpOptions(FTPLIB_CALLBACKBYTES, (long) fsz/10, conn); 474 FtpOptions(FTPLIB_CALLBACKBYTES, (long) fsz/10, conn);
472 qDebug("Put: %s, %s",localFile.latin1(),remoteFile.latin1()); 475 qDebug("Put: %s, %s",localFile.latin1(),remoteFile.latin1());
473 476
474 if( !FtpPut( localFile.latin1(), remoteFile.latin1(),FTPLIB_IMAGE, conn ) ) { 477 if( !FtpPut( localFile.latin1(), remoteFile.latin1(),FTPLIB_IMAGE, conn ) ) {
475 QString msg; 478 QString msg;
476 msg.sprintf(tr("Unable to upload\n")+"%s",FtpLastResponse(conn)); 479 msg.sprintf(tr("Unable to upload\n")+"%s",FtpLastResponse(conn));
477 msg.replace(QRegExp(":"),"\n"); 480 msg.replace(QRegExp(":"),"\n");
478 QMessageBox::message(tr("Note"),msg); 481 QMessageBox::message(tr("Note"),msg);
479 } 482 }
480 } else { 483 } else {
481 QMessageBox::message(tr("Note"),tr("Cannot upload directories")); 484 QMessageBox::message(tr("Note"),tr("Cannot upload directories"));
482 } 485 }
@@ -1100,194 +1103,203 @@ void OpieFtp::fillRemoteCombo(const QString &currentPath) {
1100void OpieFtp::currentPathComboChanged() 1103void OpieFtp::currentPathComboChanged()
1101{ 1104{
1102 QString oldRemoteCurrentDir = currentRemoteDir; 1105 QString oldRemoteCurrentDir = currentRemoteDir;
1103// qDebug("oldRemoteCurrentDir "+oldRemoteCurrentDir); 1106// qDebug("oldRemoteCurrentDir "+oldRemoteCurrentDir);
1104 if (TabWidget->currentPageIndex() == 0) { 1107 if (TabWidget->currentPageIndex() == 0) {
1105 if(QDir( currentPathCombo->lineEdit()->text()).exists()) { 1108 if(QDir( currentPathCombo->lineEdit()->text()).exists()) {
1106 currentDir.setPath( currentPathCombo->lineEdit()->text() ); 1109 currentDir.setPath( currentPathCombo->lineEdit()->text() );
1107 populateLocalView(); 1110 populateLocalView();
1108 } else { 1111 } else {
1109 QMessageBox::message(tr("Note"),tr("That directory does not exist")); 1112 QMessageBox::message(tr("Note"),tr("That directory does not exist"));
1110 } 1113 }
1111 } 1114 }
1112 if (TabWidget->currentPageIndex() == 1) { 1115 if (TabWidget->currentPageIndex() == 1) {
1113 currentRemoteDir = currentPathCombo->lineEdit()->text(); 1116 currentRemoteDir = currentPathCombo->lineEdit()->text();
1114 if(currentRemoteDir.right(1) !="/") { 1117 if(currentRemoteDir.right(1) !="/") {
1115 currentRemoteDir = currentRemoteDir +"/"; 1118 currentRemoteDir = currentRemoteDir +"/";
1116 currentPathCombo->lineEdit()->setText( currentRemoteDir ); 1119 currentPathCombo->lineEdit()->setText( currentRemoteDir );
1117 } 1120 }
1118 if( !remoteChDir( (const QString &)currentRemoteDir) ) { 1121 if( !remoteChDir( (const QString &)currentRemoteDir) ) {
1119 currentRemoteDir = oldRemoteCurrentDir; 1122 currentRemoteDir = oldRemoteCurrentDir;
1120 currentPathCombo->lineEdit()->setText( currentRemoteDir ); 1123 currentPathCombo->lineEdit()->setText( currentRemoteDir );
1121 } 1124 }
1122 1125
1123 remoteDirList( (const QString &)currentRemoteDir); 1126 remoteDirList( (const QString &)currentRemoteDir);
1124 } 1127 }
1125} 1128}
1126 1129
1127void OpieFtp::switchToLocalTab() 1130void OpieFtp::switchToLocalTab()
1128{ 1131{
1129 TabWidget->setCurrentPage(0); 1132 TabWidget->setCurrentPage(0);
1130} 1133}
1131 1134
1132void OpieFtp::switchToRemoteTab() 1135void OpieFtp::switchToRemoteTab()
1133{ 1136{
1134 TabWidget->setCurrentPage(1); 1137 TabWidget->setCurrentPage(1);
1135} 1138}
1136 1139
1137void OpieFtp::switchToConfigTab() 1140void OpieFtp::switchToConfigTab()
1138{ 1141{
1139 TabWidget->setCurrentPage(2); 1142 TabWidget->setCurrentPage(2);
1140} 1143}
1141 1144
1142void OpieFtp::readConfig() 1145void OpieFtp::readConfig()
1143{ 1146{
1144 fillCombos(); 1147 fillCombos();
1145 Config cfg("opieftp"); 1148 Config cfg("opieftp");
1146 cfg.setGroup("Server"); 1149 cfg.setGroup("Server");
1147 currentServerConfig = cfg.readNumEntry("currentServer", -1); 1150 currentServerConfig = cfg.readNumEntry("currentServer", -1);
1151
1148// qDebug("Reading %d", currentServerConfig); 1152// qDebug("Reading %d", currentServerConfig);
1149 serverComboSelected( currentServerConfig); 1153 serverComboSelected( currentServerConfig);
1150} 1154}
1151 1155
1152void OpieFtp::writeConfig() 1156void OpieFtp::writeConfig()
1153{ 1157{
1154 Config cfg("opieftp"); 1158 Config cfg("opieftp");
1155 cfg.setGroup("Server"); 1159 cfg.setGroup("Server");
1156 QString username, remoteServerStr, remotePathStr, password, port, temp; 1160 QString username, remoteServerStr, remotePathStr, password, port, temp;
1157 int numberOfEntries = cfg.readNumEntry("numberOfEntries",0); 1161 int numberOfEntries = cfg.readNumEntry("numberOfEntries",0);
1158 if( currentServerConfig == -1) { 1162 if( currentServerConfig == -1) {
1159 for (int i = 1; i <= numberOfEntries; i++) { 1163 for (int i = 1; i <= numberOfEntries; i++) {
1160 temp.setNum(i); 1164 temp.setNum(i);
1161 cfg.setGroup("Server"); 1165 cfg.setGroup("Server");
1162 QString tempStr = cfg.readEntry( temp,""); 1166 QString tempStr = cfg.readEntry( temp,"");
1163 } 1167 }
1164 temp.setNum( numberOfEntries + 1); 1168 temp.setNum( numberOfEntries + 1);
1165 cfg.setGroup("Server"); 1169 cfg.setGroup("Server");
1166 remoteServerStr = cfg.readEntry( temp,""); 1170 remoteServerStr = cfg.readEntry( temp,"");
1167 int divider = remoteServerStr.length() - remoteServerStr.find(":",0,TRUE); 1171 int divider = remoteServerStr.length() - remoteServerStr.find(":",0,TRUE);
1168 remoteServerStr = remoteServerStr.left(remoteServerStr.length()-divider); 1172 remoteServerStr = remoteServerStr.left(remoteServerStr.length()-divider);
1169 1173
1170 temp.setNum(numberOfEntries+1); 1174 temp.setNum(numberOfEntries+1);
1171 cfg.setGroup("Server"); 1175 cfg.setGroup("Server");
1172 cfg.writeEntry( temp, ServerComboBox->currentText() +":"+PortSpinBox->cleanText() ); 1176 cfg.writeEntry( temp, ServerComboBox->currentText() +":"+PortSpinBox->cleanText() );
1177 cfg.writeEntry("currentServer", numberOfEntries+1);
1173 cfg.setGroup(temp); 1178 cfg.setGroup(temp);
1174 cfg.writeEntry("RemotePath", remotePath->text()); 1179 cfg.writeEntry("RemotePath", remotePath->text());
1175 cfg.writeEntry("Username", UsernameComboBox->currentText()); 1180 cfg.writeEntry("Username", UsernameComboBox->currentText());
1176 cfg.writeEntryCrypt( UsernameComboBox->currentText(), PasswordEdit->text()); 1181 cfg.writeEntryCrypt( UsernameComboBox->currentText(), PasswordEdit->text());
1177 cfg.setGroup("Server"); 1182 cfg.setGroup("Server");
1178 cfg.writeEntry("numberOfEntries", QString::number(numberOfEntries + 1 )); 1183 cfg.writeEntry("numberOfEntries", QString::number(numberOfEntries + 1 ));
1184
1179 } 1185 }
1180} 1186}
1181 1187
1182void OpieFtp::fillCombos() 1188void OpieFtp::fillCombos()
1183{ 1189{
1184 Config cfg("opieftp"); 1190 Config cfg("opieftp");
1185 cfg.setGroup("Server"); 1191 cfg.setGroup("Server");
1186 QString username, remoteServerStr, remotePathStr, password, port, temp; 1192 QString username, remoteServerStr, remotePathStr, password, port, temp;
1187 int numberOfEntries = cfg.readNumEntry("numberOfEntries",0); 1193 int numberOfEntries = cfg.readNumEntry("numberOfEntries",0);
1188 for (int i = 1; i <= numberOfEntries; i++) { 1194 for (int i = 1; i <= numberOfEntries; i++) {
1189 temp.setNum(i); 1195 temp.setNum(i);
1196 qDebug(temp);
1190 cfg.setGroup("Server"); 1197 cfg.setGroup("Server");
1191 remoteServerStr = cfg.readEntry( temp,""); 1198 remoteServerStr = cfg.readEntry( temp,"");
1199 qDebug( remoteServerStr);
1192 int divider = remoteServerStr.length() - remoteServerStr.find(":",0,TRUE); 1200 int divider = remoteServerStr.length() - remoteServerStr.find(":",0,TRUE);
1193 port = remoteServerStr.right( divider - 1); 1201 port = remoteServerStr.right( divider - 1);
1194 bool ok; 1202 bool ok;
1195 PortSpinBox->setValue( port.toInt(&ok,10)); 1203 PortSpinBox->setValue( port.toInt(&ok,10));
1196 1204
1197 remoteServerStr = remoteServerStr.left(remoteServerStr.length()-divider); 1205 remoteServerStr = remoteServerStr.left(remoteServerStr.length()-divider);
1206 qDebug( remoteServerStr);
1198 ServerComboBox->insertItem( remoteServerStr ); 1207 ServerComboBox->insertItem( remoteServerStr );
1199// cfg.setGroup(temp); 1208// cfg.setGroup(temp);
1200 1209
1201// remotePathStr = cfg.readEntry(remoteServer,""); 1210// remotePathStr = cfg.readEntry(remoteServer,"");
1202// int divider = remoteServer.length() - remoteServer.find(":",0,TRUE); 1211// int divider = remoteServer.length() - remoteServer.find(":",0,TRUE);
1203// port = remoteServer.right( divider+1); 1212// port = remoteServer.right( divider+1);
1204// PortSpinBox->setValue( port); 1213// PortSpinBox->setValue( port);
1205 1214
1206// remoteServer = remoteServer.left(divider - 1); 1215// remoteServer = remoteServer.left(divider - 1);
1207// remotePath->setText( remotePathStr); 1216// remotePath->setText( remotePathStr);
1208 1217
1209// username = cfg.readEntry(temp); 1218// username = cfg.readEntry(temp);
1210// UsernameComboBox->insertItem(username); 1219// UsernameComboBox->insertItem(username);
1211// password = cfg.readEntryCrypt(username,""); 1220// password = cfg.readEntryCrypt(username,"");
1212// PasswordEdit->setText(password); 1221// PasswordEdit->setText(password);
1213 } 1222 }
1214} 1223}
1215 1224
1216 1225
1217void OpieFtp::serverComboSelected(int index) 1226void OpieFtp::serverComboSelected(int index)
1218{ 1227{
1219 currentServerConfig = index; 1228 currentServerConfig = index;
1220 QString username, remoteServerStr, remotePathStr, password, port, temp; 1229 QString username, remoteServerStr, remotePathStr, password, port, temp;
1221// remoteServerStr = ServerComboBox->text(index); 1230// remoteServerStr = ServerComboBox->text(index);
1222 Config cfg("opieftp"); 1231 Config cfg("opieftp");
1223 cfg.setGroup("Server"); 1232 cfg.setGroup("Server");
1224 int numberOfEntries = cfg.readNumEntry("numberOfEntries",0); 1233 int numberOfEntries = cfg.readNumEntry("numberOfEntries",0);
1225 1234
1226 temp.setNum(index+1); 1235 temp.setNum(index);
1227 remoteServerStr = cfg.readEntry( temp,""); 1236 remoteServerStr = cfg.readEntry( temp,"");
1237 qDebug("Group" +temp);
1228 cfg.setGroup(temp); 1238 cfg.setGroup(temp);
1229// qDebug(temp); 1239// qDebug(temp);
1230 int divider = remoteServerStr.length() - remoteServerStr.find(":",0,TRUE); 1240 int divider = remoteServerStr.length() - remoteServerStr.find(":",0,TRUE);
1231 port = remoteServerStr.right( divider - 1); 1241 port = remoteServerStr.right( divider - 1);
1232 bool ok; 1242 bool ok;
1233 int portInt = port.toInt(&ok,10); 1243 int portInt = port.toInt(&ok,10);
1234 if( portInt == 0) portInt = 21; 1244 if( portInt == 0) portInt = 21;
1235 1245
1236 PortSpinBox->setValue( portInt); 1246 PortSpinBox->setValue( portInt);
1237 1247
1238 remotePath->setText(cfg.readEntry("RemotePath", "/")); 1248 remotePath->setText(cfg.readEntry("RemotePath", "/"));
1239 1249
1240 username = cfg.readEntry("Username", "anonymous"); 1250 username = cfg.readEntry("Username", "anonymous");
1241 UsernameComboBox->lineEdit()->setText(username); 1251 UsernameComboBox->lineEdit()->setText(username);
1242 1252 qDebug(username);
1243// qDebug("Password is "+cfg.readEntryCrypt(username, "me@opieftp.org")); 1253// qDebug("Password is "+cfg.readEntryCrypt(username, "me@opieftp.org"));
1244 PasswordEdit->setText(cfg.readEntryCrypt(username, "me@opieftp.org")); 1254 PasswordEdit->setText(cfg.readEntryCrypt(username, "me@opieftp.org"));
1245 1255// UsernameComboBox
1256// PasswordEdit
1257
1246 cfg.setGroup("Server"); 1258 cfg.setGroup("Server");
1247 temp.sprintf("%d",currentServerConfig); 1259 temp.sprintf("%d",currentServerConfig);
1248 cfg.writeEntry("currentServer", temp); 1260 cfg.writeEntry("currentServer", temp);
1249 update(); 1261 update();
1250} 1262}
1251// UsernameComboBox->lineEdit()->setText("root"); 1263// UsernameComboBox->lineEdit()->setText("root");
1252// PasswordEdit->setText( tr( "" ) ); 1264// PasswordEdit->setText( tr( "" ) );
1253// ServerComboBox->lineEdit()->setText( tr( "192.168.129.201" ) ); 1265// ServerComboBox->lineEdit()->setText( tr( "192.168.129.201" ) );
1254// remotePath->setText( currentRemoteDir = "/home/llornkcor/"); 1266// remotePath->setText( currentRemoteDir = "/home/llornkcor/");
1255// PortSpinBox->setValue( 4242); 1267// PortSpinBox->setValue( 4242);
1256 1268
1257void OpieFtp::deleteServer() 1269void OpieFtp::deleteServer()
1258{ 1270{
1259 QString username, remoteServerStr, remotePathStr, password, port, temp; 1271 QString username, remoteServerStr, remotePathStr, password, port, temp;
1260 remoteServerStr = ServerComboBox->currentText( ); 1272 remoteServerStr = ServerComboBox->currentText( );
1261 username = UsernameComboBox->currentText(); 1273 username = UsernameComboBox->currentText();
1262 Config cfg("opieftp"); 1274 Config cfg("opieftp");
1263 cfg.setGroup("Server"); 1275 cfg.setGroup("Server");
1264 int numberOfEntries = cfg.readNumEntry("numberOfEntries",0); 1276 int numberOfEntries = cfg.readNumEntry("numberOfEntries",0);
1265 for (int i = 0; i <= numberOfEntries; i++) { 1277 for (int i = 0; i <= numberOfEntries; i++) {
1266 temp.setNum(i+1); 1278 temp.setNum(i+1);
1267 cfg.setGroup("Server"); 1279 cfg.setGroup("Server");
1268 if( cfg.readEntry( temp,"").find( remoteServerStr,0,TRUE) != -1 1280 if( cfg.readEntry( temp,"").find( remoteServerStr,0,TRUE) != -1
1269 && cfg.readEntry(temp).find(username,0,TRUE) != -1 1281 && cfg.readEntry(temp).find(username,0,TRUE) != -1
1270 && !remoteServerStr.isEmpty()) { 1282 && !remoteServerStr.isEmpty()) {
1271 qDebug(temp); 1283 qDebug(temp);
1272 } 1284 }
1273 } 1285 }
1274} 1286}
1275 1287
1276void OpieFtp::upDir() 1288void OpieFtp::upDir()
1277{ 1289{
1278 if (TabWidget->currentPageIndex() == 0) { 1290 if (TabWidget->currentPageIndex() == 0) {
1279 QString current = currentDir.canonicalPath(); 1291 QString current = currentDir.canonicalPath();
1280 QDir dir(current); 1292 QDir dir(current);
1281 dir.cdUp(); 1293 dir.cdUp();
1282 current = dir.canonicalPath(); 1294 current = dir.canonicalPath();
1283 chdir( current.latin1() ); 1295 chdir( current.latin1() );
1284 currentDir.cd( current, TRUE); 1296 currentDir.cd( current, TRUE);
1285 populateLocalView(); 1297 populateLocalView();
1286 update(); 1298 update();
1287 } else { 1299 } else {
1288 if( FtpCDUp( conn) == 0) { 1300 if( FtpCDUp( conn) == 0) {
1289 QString msg; 1301 QString msg;
1290 msg.sprintf(tr("Unable to cd up\n")+"%s",FtpLastResponse(conn)); 1302 msg.sprintf(tr("Unable to cd up\n")+"%s",FtpLastResponse(conn));
1291 msg.replace(QRegExp(":"),"\n"); 1303 msg.replace(QRegExp(":"),"\n");
1292 QMessageBox::message(tr("Note"),msg); 1304 QMessageBox::message(tr("Note"),msg);
1293// qDebug(msg); 1305// qDebug(msg);