author | llornkcor <llornkcor> | 2002-04-05 01:34:24 (UTC) |
---|---|---|
committer | llornkcor <llornkcor> | 2002-04-05 01:34:24 (UTC) |
commit | dd5bc1f9d61cdd8cfde4c7a7fbba3b53b77b2670 (patch) (side-by-side diff) | |
tree | e8ebf3f926e3ac7e4d612964a05bce834fe6fc2e | |
parent | 8674b15e0768d5108d9a225ff2631538283e1019 (diff) | |
download | opie-dd5bc1f9d61cdd8cfde4c7a7fbba3b53b77b2670.zip opie-dd5bc1f9d61cdd8cfde4c7a7fbba3b53b77b2670.tar.gz opie-dd5bc1f9d61cdd8cfde4c7a7fbba3b53b77b2670.tar.bz2 |
fixed bug where same server was being saved multiple times
-rw-r--r-- | noncore/net/opieftp/opieftp.cpp | 17 |
1 files changed, 9 insertions, 8 deletions
diff --git a/noncore/net/opieftp/opieftp.cpp b/noncore/net/opieftp/opieftp.cpp index b451925..919649e 100644 --- a/noncore/net/opieftp/opieftp.cpp +++ b/noncore/net/opieftp/opieftp.cpp @@ -103,33 +103,33 @@ OpieFtp::OpieFtp( ) localMenu->setCheckable(TRUE); remoteMenu->insertItem( tr( "Download" ), this, SLOT( remoteDownload() )); remoteMenu->insertItem( tr( "Make Directory" ), this, SLOT( remoteMakDir() )); remoteMenu->insertItem( tr( "Rename" ), this, SLOT( remoteRename() )); remoteMenu->insertSeparator(); remoteMenu->insertItem( tr( "Delete" ), this, SLOT( remoteDelete() )); tabMenu->insertItem( tr( "Switch to Local" ), this, SLOT( switchToLocalTab() )); tabMenu->insertItem( tr( "Switch to Remote" ), this, SLOT( switchToRemoteTab() )); tabMenu->insertItem( tr( "Switch to Config" ), this, SLOT( switchToConfigTab() )); tabMenu->setCheckable(TRUE); TabWidget = new QTabWidget( this, "TabWidget" ); layout->addMultiCellWidget( TabWidget, 1, 1, 0, 3 ); - TabWidget->setTabShape(QTabWidget::Triangular); +// TabWidget->setTabShape(QTabWidget::Triangular); tab = new QWidget( TabWidget, "tab" ); tabLayout = new QGridLayout( tab ); tabLayout->setSpacing( 2); tabLayout->setMargin( 2); Local_View = new QListView( tab, "Local_View" ); // Local_View->setResizePolicy( QListView::AutoOneFit ); Local_View->addColumn( tr("File"),150); Local_View->addColumn( tr("Size"),-1); Local_View->setColumnAlignment(1,QListView::AlignRight); Local_View->addColumn( tr("Date"),-1); Local_View->setColumnAlignment(2,QListView::AlignRight); Local_View->setAllColumnsShowFocus(TRUE); Local_View->setMultiSelection( TRUE ); Local_View->setSelectionMode(QListView::Extended); @@ -254,33 +254,34 @@ OpieFtp::OpieFtp( ) 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, 3 ); // fillCombos(); filterStr="*"; b=FALSE; populateLocalView(); readConfig(); - ServerComboBox->setCurrentItem(currentServerConfig); + 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"; @@ -310,35 +311,35 @@ void OpieFtp::tabChanged(QWidget *w) tabMenu->setItemChecked(tabMenu->idAt(1),FALSE); } } void OpieFtp::newConnection() { UsernameComboBox->lineEdit()->setText(""); PasswordEdit->setText( "" ); ServerComboBox->lineEdit()->setText( ""); remotePath->setText( currentRemoteDir = "/"); PortSpinBox->setValue( 21); TabWidget->setCurrentPage(2); } void OpieFtp::serverComboEdited(const QString & edit) { - if( !edit.isEmpty() ) { + if( ServerComboBox->text(currentServerConfig) != edit /*edit.isEmpty() */) { + qDebug("ServerComboEdited"); currentServerConfig = -1; -// qDebug("comboedited"); } } void OpieFtp::connectorBtnToggled(bool On) { if(On) { connector(); } else { disConnector(); } } void OpieFtp::connector() { QCopEnvelope ( "QPE/System", "busy()" ); @@ -510,33 +511,33 @@ bool OpieFtp::remoteDirList(const QString &dir) QMessageBox::message(tr("Note"),msg); return false; } populateRemoteView() ; QCopEnvelope ( "QPE/System", "notBusy()" ); return true; } bool OpieFtp::remoteChDir(const QString &dir) { QCopEnvelope ( "QPE/System", "busy()" ); if (!FtpChdir( dir.latin1(), conn )) { QString msg; msg.sprintf(tr("Unable to change directories\n")+dir+"\n%s",FtpLastResponse(conn)); msg.replace(QRegExp(":"),"\n"); QMessageBox::message(tr("Note"),msg); - qDebug(msg); +// qDebug(msg); QCopEnvelope ( "QPE/System", "notBusy()" ); return FALSE; } QCopEnvelope ( "QPE/System", "notBusy()" ); return TRUE; } void OpieFtp::populateLocalView() { Local_View->clear(); currentDir.setSorting(/* QDir::Size*/ /*| QDir::Reversed | */QDir::DirsFirst); currentDir.setMatchAllDirs(TRUE); currentDir.setNameFilter(filterStr); QString fileL, fileS, fileDate; bool isDir=FALSE; const QFileInfoList *list = currentDir.entryInfoList( /*QDir::All*/ /*, QDir::SortByMask*/); @@ -654,41 +655,41 @@ bool OpieFtp::populateRemoteView( ) return true; } void OpieFtp::remoteListClicked(QListViewItem *selectedItem) { if( selectedItem) { // QCopEnvelope ( "QPE/System", "busy()" ); QString oldRemoteCurrentDir = currentRemoteDir; QString strItem=selectedItem->text(0); strItem=strItem.simplifyWhiteSpace(); if(strItem == "../") { // the user wants to go ^ if( FtpCDUp( conn) == 0) { QString msg; msg.sprintf(tr("Unable to cd up\n")+"%s",FtpLastResponse(conn)); msg.replace(QRegExp(":"),"\n"); QMessageBox::message(tr("Note"),msg); - qDebug(msg); +// qDebug(msg); } char path[256]; if( FtpPwd( path,sizeof(path),conn) == 0) { //this is easier than fudging the string QString msg; msg.sprintf(tr("Unable to get working dir\n")+"%s",FtpLastResponse(conn)); msg.replace(QRegExp(":"),"\n"); QMessageBox::message(tr("Note"),msg); - qDebug(msg); +// qDebug(msg); } currentRemoteDir=path; } else { if(strItem.find("->",0,TRUE) != -1) { //symlink on some servers strItem=strItem.right( strItem.length() - strItem.find("->",0,TRUE) - 2 ); strItem = strItem.stripWhiteSpace(); currentRemoteDir = strItem; if( !remoteChDir( (const QString &)strItem)) { currentRemoteDir = oldRemoteCurrentDir; strItem=""; // qDebug("RemoteCurrentDir1 "+oldRemoteCurrentDir); } } else if(strItem.find("/",0,TRUE) != -1) { // this is a directory if( !remoteChDir( (const QString &)currentRemoteDir + strItem)) { currentRemoteDir = oldRemoteCurrentDir; strItem=""; @@ -1052,48 +1053,48 @@ void OpieFtp::switchToLocalTab() 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.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 )); } |