author | llornkcor <llornkcor> | 2002-03-21 13:59:50 (UTC) |
---|---|---|
committer | llornkcor <llornkcor> | 2002-03-21 13:59:50 (UTC) |
commit | 60c9126183ea72c08ad5cb77b8939812627aae17 (patch) (side-by-side diff) | |
tree | 60852886d3352fbca6a52bc5c0fb88e521d08145 | |
parent | 9030459d54a67bd2e6201e0c1641c1f23d9af0ec (diff) | |
download | opie-60c9126183ea72c08ad5cb77b8939812627aae17.zip opie-60c9126183ea72c08ad5cb77b8939812627aae17.tar.gz opie-60c9126183ea72c08ad5cb77b8939812627aae17.tar.bz2 |
added some combo stuff
-rw-r--r-- | noncore/net/opieftp/opieftp.cpp | 173 | ||||
-rw-r--r-- | noncore/net/opieftp/opieftp.h | 7 |
2 files changed, 169 insertions, 11 deletions
diff --git a/noncore/net/opieftp/opieftp.cpp b/noncore/net/opieftp/opieftp.cpp index 82776d0..eed133e 100644 --- a/noncore/net/opieftp/opieftp.cpp +++ b/noncore/net/opieftp/opieftp.cpp @@ -10,4 +10,5 @@ * (at your option) any later version. * ***************************************************************************/ +//#define DEVELOPER_VERSION #include "opieftp.h" @@ -20,6 +21,8 @@ #include <qpe/resource.h> #include <qpe/qcopenvelope_qws.h> +#include <qpe/config.h> #include <qtextstream.h> +#include <qpushbutton.h> #include <qtoolbutton.h> #include <qdatetime.h> @@ -172,7 +175,5 @@ OpieFtp::OpieFtp( ) UsernameComboBox = new QComboBox( FALSE, tab_3, "UsernameComboBox" ); UsernameComboBox->setEditable(TRUE); - UsernameComboBox->lineEdit()->setText("anonymous"); -// UsernameComboBox->lineEdit()->setText("root"); -// UsernameComboBox->lineEdit()->setText("llornkcor"); +// UsernameComboBox->lineEdit()->setText("anonymous"); tabLayout_3->addMultiCellWidget( UsernameComboBox, 1, 1, 0, 1 ); @@ -183,6 +184,5 @@ OpieFtp::OpieFtp( ) PasswordEdit = new QLineEdit( "", tab_3, "PasswordComboBox" ); PasswordEdit->setEchoMode(QLineEdit::Password); - PasswordEdit->setText( tr( "me@opieftp.org" ) ); -// PasswordEdit->setText( tr( "" ) ); +// PasswordEdit->setText( tr( "me@opieftp.org" ) ); tabLayout_3->addMultiCellWidget( PasswordEdit, 1, 1, 2, 3 ); @@ -193,8 +193,8 @@ OpieFtp::OpieFtp( ) ServerComboBox = new QComboBox( FALSE, tab_3, "ServerComboBox" ); ServerComboBox->setEditable(TRUE); - ServerComboBox->lineEdit()->setText( tr( "" ) ); +// ServerComboBox->lineEdit()->setText( tr( "" ) ); tabLayout_3->addMultiCellWidget( ServerComboBox, 3, 3, 0, 1 ); -// ServerComboBox->lineEdit()->setText( tr( "llornkcor.com" ) ); -// ServerComboBox->lineEdit()->setText( tr( "192.168.129.201" ) ); + + connect(ServerComboBox,SIGNAL(activated(int)),this,SLOT(serverComboSelected(int ) )); QLabel *TextLabel5 = new QLabel( tab_3, "TextLabel5" ); @@ -204,5 +204,4 @@ OpieFtp::OpieFtp( ) remotePath = new QLineEdit( "/", tab_3, "remotePath" ); remotePath->setText( currentRemoteDir = "/"); -// remotePath->setText( currentRemoteDir = "/home/llornkcor/"); tabLayout_3->addMultiCellWidget( remotePath, 3, 3, 2, 3 ); @@ -214,8 +213,19 @@ OpieFtp::OpieFtp( ) PortSpinBox->setButtonSymbols( QSpinBox::UpDownArrows ); PortSpinBox->setMaxValue(32786); -// PortSpinBox->setValue( 4242); PortSpinBox->setValue( 21); tabLayout_3->addMultiCellWidget( PortSpinBox, 4, 4, 1, 1); + QPushButton *deleteServerBtn; + deleteServerBtn = new QPushButton( "Delete Server",this, "OpenButton" ); + tabLayout_3->addMultiCellWidget( deleteServerBtn, 5, 5, 2, 3); + + connect(deleteServerBtn,SIGNAL(clicked()),SLOT(deleteServer())); + + QPushButton *connectServerBtn; + connectServerBtn = new QPushButton( "Connect",this, "ConnectButton" ); + tabLayout_3->addMultiCellWidget( connectServerBtn, 5, 5, 0, 1); + connect(connectServerBtn,SIGNAL( clicked()),SLOT( connector() )); + + QSpacerItem* spacer = new QSpacerItem( 20, 20, QSizePolicy::Minimum, QSizePolicy::Expanding ); tabLayout_3->addItem( spacer, 5, 0 ); @@ -238,7 +248,20 @@ OpieFtp::OpieFtp( ) layout->addMultiCellWidget( ProgressBar, 4, 4, 0, 3 ); + serverComboSelected(0); +#ifdef DEVELOPER_VERSION +// ServerComboBox->lineEdit()->setText( tr( "llornkcor.com" ) ); + ServerComboBox->lineEdit()->setText( tr( "192.168.129.201" ) ); + UsernameComboBox->lineEdit()->setText("root"); +// UsernameComboBox->lineEdit()->setText("llornkcor"); + PortSpinBox->setValue( 4242); + remotePath->setText( currentRemoteDir = "/"); + PasswordEdit->setText( tr( "" ) ); + +#endif + fillCombos(); filterStr="*"; b=FALSE; populateLocalView(); + TabWidget->setCurrentPage(2); } @@ -370,5 +393,11 @@ void OpieFtp::remoteDownload() void OpieFtp::newConnection() { + UsernameComboBox->lineEdit()->setText(""); + PasswordEdit->setText( "" ); + ServerComboBox->lineEdit()->setText( ""); + remotePath->setText( currentRemoteDir = "/"); + PortSpinBox->setValue( 21); TabWidget->setCurrentPage(2); + } @@ -409,4 +438,5 @@ void OpieFtp::connector() remoteDirList("/") ; setCaption(ftp_host); + writeConfig(); QCopEnvelope ( "QPE/System", "notBusy()" ); } @@ -918,2 +948,125 @@ void OpieFtp::switchToConfigTab() TabWidget->setCurrentPage(2); } + +void OpieFtp::readConfig() { + + Config cfg("opieftp"); + cfg.setGroup("Server"); + QString username, remoteServer, remotePathStr, password, port, temp; + int numberOfEntries = cfg.readNumEntry("numberOfEntries",0); + for (int i = 0; i <= numberOfEntries; i++) { + temp.setNum(i+1); + cfg.setGroup("Server"); + remoteServer = cfg.readEntry( temp,""); + ServerComboBox->insertItem( remoteServer ); + cfg.setGroup(temp); + + remotePathStr = cfg.readEntry(remoteServer,""); + int divider = remoteServer.length() - remoteServer.find(":",0,TRUE); + port = remoteServer.right( divider+1); + bool ok; + PortSpinBox->setValue( port.toInt(&ok,10)); + + remoteServer = remoteServer.left(divider - 1); + remotePath->setText( remotePathStr); + username = cfg.readEntry(temp); + UsernameComboBox->insertItem(username); + password = cfg.readEntryCrypt(username,""); + PasswordEdit->setText(password); + + } + +} + +void OpieFtp::writeConfig() { + + Config cfg("opieftp"); + cfg.setGroup("Server"); + QString temp; + int numberOfEntries = cfg.readNumEntry("numberOfEntries",0); + 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 )); + +} + +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); + cfg.setGroup("Server"); + remoteServerStr = cfg.readEntry( temp,""); + 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); + 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) { + + QString username, remoteServerStr, remotePathStr, password, port, temp; +// remoteServerStr = ServerComboBox->text(index); + Config cfg("opieftp"); + cfg.setGroup("Server"); + int numberOfEntries = cfg.readNumEntry("numberOfEntries",0); + +// for (int i = 0; i <= numberOfEntries; i++) { + temp.setNum(index+1); + remoteServerStr = cfg.readEntry( temp,""); + // if( remoteServerStr.find( ServerComboBox->text(index),0,TRUE) != -1 ) { + cfg.setGroup(temp); + qDebug(temp); + int divider = remoteServerStr.length() - remoteServerStr.find(":",0,TRUE); + port = remoteServerStr.right( divider - 1); + bool ok; + PortSpinBox->setValue( port.toInt(&ok,10)); + + remotePath->setText(cfg.readEntry("RemotePath", "")); + username = cfg.readEntry("Username", ""); + UsernameComboBox->lineEdit()->setText(username); + PasswordEdit->setText(cfg.readEntryCrypt(username, "")); + +// } + + // } + 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() { + +} diff --git a/noncore/net/opieftp/opieftp.h b/noncore/net/opieftp/opieftp.h index 1e5fffa..c88a15b 100644 --- a/noncore/net/opieftp/opieftp.h +++ b/noncore/net/opieftp/opieftp.h @@ -74,5 +74,6 @@ protected slots: bool populateRemoteView(); void showHidden(); - + void writeConfig(); + void readConfig(); void localListClicked(QListViewItem *); void remoteListClicked(QListViewItem *); @@ -93,4 +94,8 @@ protected slots: void switchToRemoteTab(); void switchToConfigTab(); + void fillCombos(); + void serverComboSelected(int); + void deleteServer(); + protected: void nullifyCallBack(); |