author | llornkcor <llornkcor> | 2002-05-16 16:29:14 (UTC) |
---|---|---|
committer | llornkcor <llornkcor> | 2002-05-16 16:29:14 (UTC) |
commit | 62c1424c5421e926173133ab4acd7346c590612e (patch) (side-by-side diff) | |
tree | f9df1716b94df11330bb7cb466e26d2e3d1f8add | |
parent | b94bd6003bf7c2024b0f254805f54ff4e52ead6e (diff) | |
download | opie-62c1424c5421e926173133ab4acd7346c590612e.zip opie-62c1424c5421e926173133ab4acd7346c590612e.tar.gz opie-62c1424c5421e926173133ab4acd7346c590612e.tar.bz2 |
fixed not loading ftp configs correctly..
-rw-r--r-- | noncore/net/opieftp/opieftp.cpp | 24 |
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 @@ -277,54 +277,56 @@ OpieFtp::OpieFtp( ) TabWidget->insertTab( tab_3, tr( "Config" ) ); connect(TabWidget,SIGNAL(currentChanged(QWidget *)), this,SLOT(tabChanged(QWidget*))); currentDir.setFilter( QDir::Files | QDir::Dirs/* | QDir::Hidden*/ | QDir::All); currentDir.setPath( QDir::currentDirPath()); // currentDir.setSorting(/* QDir::Size*/ /*| QDir::Reversed | */QDir::DirsFirst); currentPathCombo = new QComboBox( FALSE, this, "currentPathCombo" ); layout->addMultiCellWidget( currentPathCombo, 3, 3, 0, 4); currentPathCombo->setEditable(TRUE); currentPathCombo->lineEdit()->setText( currentDir.canonicalPath()); connect( currentPathCombo, SIGNAL( activated( const QString & ) ), this, SLOT( currentPathComboActivated( const QString & ) ) ); connect( currentPathCombo->lineEdit(),SIGNAL(returnPressed()), this,SLOT(currentPathComboChanged())); ProgressBar = new QProgressBar( this, "ProgressBar" ); layout->addMultiCellWidget( ProgressBar, 4, 4, 0, 4); -// fillCombos(); + fillCombos(); filterStr="*"; b=FALSE; populateLocalView(); - readConfig(); +qDebug("read COnfig"); + readConfig(); + qDebug("Set current item"); ServerComboBox->setCurrentItem(currentServerConfig); TabWidget->setCurrentPage(2); } OpieFtp::~OpieFtp() { } void OpieFtp::cleanUp() { if(conn) FtpQuit(conn); QString sfile=QDir::homeDirPath(); if(sfile.right(1) != "/") sfile+="/._temp"; else sfile+="._temp"; QFile file( sfile); if(file.exists()) file.remove(); exit(0); } @@ -410,49 +412,50 @@ void OpieFtp::connector() port.stripWhiteSpace(); if(ftp_host.find("ftp://",0, TRUE) != -1 ) ftp_host=ftp_host.right(ftp_host.length()-6); ftp_host+=":"+port; if (!FtpConnect( ftp_host.latin1(), &conn)) { QMessageBox::message(tr("Note"),tr("Unable to connect to\n")+ftp_host); connectServerBtn->setOn(FALSE); connectServerBtn->setText( tr("Connect")); return ; } if (!FtpLogin( ftp_user.latin1(), ftp_pass.latin1(),conn )) { QString msg; msg.sprintf(tr("Unable to log in\n")+"%s",FtpLastResponse(conn)); msg.replace(QRegExp(":"),"\n"); QMessageBox::message(tr("Note"),msg); if(conn) FtpQuit(conn); connectServerBtn->setOn(FALSE); connectServerBtn->setText( tr("Connect")); return ; } remoteDirList("/") ; setCaption(ftp_host); - writeConfig(); + if( currentServerConfig == -1) + writeConfig(); connectServerBtn->setText( tr("Disconnect")); // QCopEnvelope ( "QPE/System", "notBusy()" ); } void OpieFtp::disConnector() { if(conn) FtpQuit(conn); setCaption("OpieFtp"); currentRemoteDir="/"; Remote_View->clear(); connectServerBtn->setText( tr("Connect")); connectServerBtn->setOn(FALSE); setCaption("OpieFtp"); } void OpieFtp::localUpload() { int fsz; // QCopEnvelope ( "QPE/System", "busy()" ); // qApp->processEvents(); QList<QListViewItem> * getSelectedItems( QListView * Local_View ); QListViewItemIterator it( Local_View ); for ( ; it.current(); ++it ) { @@ -1124,146 +1127,155 @@ void OpieFtp::currentPathComboChanged() } } void OpieFtp::switchToLocalTab() { TabWidget->setCurrentPage(0); } void OpieFtp::switchToRemoteTab() { TabWidget->setCurrentPage(1); } void OpieFtp::switchToConfigTab() { TabWidget->setCurrentPage(2); } void OpieFtp::readConfig() { fillCombos(); Config cfg("opieftp"); cfg.setGroup("Server"); currentServerConfig = cfg.readNumEntry("currentServer", -1); + // qDebug("Reading %d", currentServerConfig); serverComboSelected( currentServerConfig); } void OpieFtp::writeConfig() { Config cfg("opieftp"); cfg.setGroup("Server"); QString username, remoteServerStr, remotePathStr, password, port, temp; int numberOfEntries = cfg.readNumEntry("numberOfEntries",0); if( currentServerConfig == -1) { for (int i = 1; i <= numberOfEntries; i++) { temp.setNum(i); cfg.setGroup("Server"); QString tempStr = cfg.readEntry( temp,""); } temp.setNum( numberOfEntries + 1); cfg.setGroup("Server"); remoteServerStr = cfg.readEntry( temp,""); int divider = remoteServerStr.length() - remoteServerStr.find(":",0,TRUE); remoteServerStr = remoteServerStr.left(remoteServerStr.length()-divider); temp.setNum(numberOfEntries+1); cfg.setGroup("Server"); cfg.writeEntry( temp, ServerComboBox->currentText() +":"+PortSpinBox->cleanText() ); + cfg.writeEntry("currentServer", numberOfEntries+1); cfg.setGroup(temp); cfg.writeEntry("RemotePath", remotePath->text()); cfg.writeEntry("Username", UsernameComboBox->currentText()); cfg.writeEntryCrypt( UsernameComboBox->currentText(), PasswordEdit->text()); cfg.setGroup("Server"); cfg.writeEntry("numberOfEntries", QString::number(numberOfEntries + 1 )); + } } void OpieFtp::fillCombos() { Config cfg("opieftp"); cfg.setGroup("Server"); QString username, remoteServerStr, remotePathStr, password, port, temp; int numberOfEntries = cfg.readNumEntry("numberOfEntries",0); for (int i = 1; i <= numberOfEntries; i++) { temp.setNum(i); + qDebug(temp); cfg.setGroup("Server"); remoteServerStr = cfg.readEntry( temp,""); + qDebug( remoteServerStr); int divider = remoteServerStr.length() - remoteServerStr.find(":",0,TRUE); port = remoteServerStr.right( divider - 1); bool ok; PortSpinBox->setValue( port.toInt(&ok,10)); remoteServerStr = remoteServerStr.left(remoteServerStr.length()-divider); + qDebug( remoteServerStr); ServerComboBox->insertItem( remoteServerStr ); // cfg.setGroup(temp); // remotePathStr = cfg.readEntry(remoteServer,""); // int divider = remoteServer.length() - remoteServer.find(":",0,TRUE); // port = remoteServer.right( divider+1); // PortSpinBox->setValue( port); // remoteServer = remoteServer.left(divider - 1); // remotePath->setText( remotePathStr); // username = cfg.readEntry(temp); // UsernameComboBox->insertItem(username); // password = cfg.readEntryCrypt(username,""); // PasswordEdit->setText(password); } } void OpieFtp::serverComboSelected(int index) { currentServerConfig = index; QString username, remoteServerStr, remotePathStr, password, port, temp; // remoteServerStr = ServerComboBox->text(index); Config cfg("opieftp"); cfg.setGroup("Server"); int numberOfEntries = cfg.readNumEntry("numberOfEntries",0); - temp.setNum(index+1); + temp.setNum(index); remoteServerStr = cfg.readEntry( temp,""); + qDebug("Group" +temp); cfg.setGroup(temp); // qDebug(temp); int divider = remoteServerStr.length() - remoteServerStr.find(":",0,TRUE); port = remoteServerStr.right( divider - 1); bool ok; int portInt = port.toInt(&ok,10); if( portInt == 0) portInt = 21; PortSpinBox->setValue( portInt); remotePath->setText(cfg.readEntry("RemotePath", "/")); username = cfg.readEntry("Username", "anonymous"); UsernameComboBox->lineEdit()->setText(username); - + qDebug(username); // qDebug("Password is "+cfg.readEntryCrypt(username, "me@opieftp.org")); PasswordEdit->setText(cfg.readEntryCrypt(username, "me@opieftp.org")); - +// UsernameComboBox +// PasswordEdit + cfg.setGroup("Server"); temp.sprintf("%d",currentServerConfig); cfg.writeEntry("currentServer", temp); update(); } // UsernameComboBox->lineEdit()->setText("root"); // PasswordEdit->setText( tr( "" ) ); // ServerComboBox->lineEdit()->setText( tr( "192.168.129.201" ) ); // remotePath->setText( currentRemoteDir = "/home/llornkcor/"); // PortSpinBox->setValue( 4242); void OpieFtp::deleteServer() { QString username, remoteServerStr, remotePathStr, password, port, temp; remoteServerStr = ServerComboBox->currentText( ); username = UsernameComboBox->currentText(); Config cfg("opieftp"); cfg.setGroup("Server"); int numberOfEntries = cfg.readNumEntry("numberOfEntries",0); for (int i = 0; i <= numberOfEntries; i++) { temp.setNum(i+1); cfg.setGroup("Server"); if( cfg.readEntry( temp,"").find( remoteServerStr,0,TRUE) != -1 && cfg.readEntry(temp).find(username,0,TRUE) != -1 |