-rw-r--r-- | noncore/net/opieftp/opieftp.cpp | 175 | ||||
-rw-r--r-- | noncore/net/opieftp/opieftp.h | 7 |
2 files changed, 170 insertions, 12 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 @@ -11,2 +11,3 @@ ***************************************************************************/ +//#define DEVELOPER_VERSION @@ -21,4 +22,6 @@ #include <qpe/qcopenvelope_qws.h> +#include <qpe/config.h> #include <qtextstream.h> +#include <qpushbutton.h> #include <qtoolbutton.h> @@ -173,5 +176,3 @@ OpieFtp::OpieFtp( ) 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 ); @@ -184,4 +185,3 @@ OpieFtp::OpieFtp( ) 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 ); @@ -194,6 +194,6 @@ OpieFtp::OpieFtp( ) 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 ) )); @@ -205,3 +205,2 @@ OpieFtp::OpieFtp( ) remotePath->setText( currentRemoteDir = "/"); -// remotePath->setText( currentRemoteDir = "/home/llornkcor/"); tabLayout_3->addMultiCellWidget( remotePath, 3, 3, 2, 3 ); @@ -215,3 +214,2 @@ OpieFtp::OpieFtp( ) PortSpinBox->setMaxValue(32786); -// PortSpinBox->setValue( 4242); PortSpinBox->setValue( 21); @@ -219,2 +217,14 @@ OpieFtp::OpieFtp( ) + 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 ); @@ -239,2 +249,14 @@ OpieFtp::OpieFtp( ) + 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="*"; @@ -242,2 +264,3 @@ OpieFtp::OpieFtp( ) populateLocalView(); + TabWidget->setCurrentPage(2); } @@ -371,3 +394,9 @@ void OpieFtp::newConnection() { - TabWidget->setCurrentPage(2); + UsernameComboBox->lineEdit()->setText(""); + PasswordEdit->setText( "" ); + ServerComboBox->lineEdit()->setText( ""); + remotePath->setText( currentRemoteDir = "/"); + PortSpinBox->setValue( 21); + TabWidget->setCurrentPage(2); + } @@ -410,2 +439,3 @@ void OpieFtp::connector() setCaption(ftp_host); + writeConfig(); QCopEnvelope ( "QPE/System", "notBusy()" ); @@ -919 +949,124 @@ void OpieFtp::switchToConfigTab() } + +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 @@ -75,3 +75,4 @@ protected slots: void showHidden(); - + void writeConfig(); + void readConfig(); void localListClicked(QListViewItem *); @@ -94,2 +95,6 @@ protected slots: void switchToConfigTab(); + void fillCombos(); + void serverComboSelected(int); + void deleteServer(); + protected: |