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 | 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 @@ -1,35 +1,38 @@ /*************************************************************************** opieftp.cpp ------------------- ** Created: Sat Mar 9 23:33:09 2002 copyright : (C) 2002 by ljp email : ljp@llornkcor.com * This program is free software; you can redistribute it and/or modify * * it under the terms of the GNU General Public License as published by * * the Free Software Foundation; either version 2 of the License, or * * (at your option) any later version. * ***************************************************************************/ +//#define DEVELOPER_VERSION #include "opieftp.h" #include "ftplib.h" #include "inputDialog.h" #include <qpe/qpemenubar.h> #include <qpe/qpetoolbar.h> #include <qpe/qpeapplication.h> #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> #include <qdir.h> #include <qfile.h> #include <qstring.h> #include <qcombobox.h> #include <qpopupmenu.h> #include <qlistview.h> #include <qmainwindow.h> #include <qlabel.h> #include <qprogressbar.h> #include <qspinbox.h> @@ -162,93 +165,113 @@ OpieFtp::OpieFtp( ) tab_3 = new QWidget( TabWidget, "tab_3" ); tabLayout_3 = new QGridLayout( tab_3 ); tabLayout_3->setSpacing( 2); tabLayout_3->setMargin( 2); TextLabel1 = new QLabel( tab_3, "TextLabel1" ); TextLabel1->setText( tr( "Username" ) ); tabLayout_3->addMultiCellWidget( TextLabel1, 0, 0, 0, 1 ); 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 ); TextLabel2 = new QLabel( tab_3, "TextLabel2" ); TextLabel2->setText( tr( "Password" ) ); tabLayout_3->addMultiCellWidget( TextLabel2, 0, 0, 2, 3 ); 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 ); TextLabel3 = new QLabel( tab_3, "TextLabel3" ); TextLabel3->setText( tr( "Remote server" ) ); tabLayout_3->addMultiCellWidget( TextLabel3, 2, 2, 0, 1 ); 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" ); TextLabel5->setText( tr( "Remote path" ) ); tabLayout_3->addMultiCellWidget( TextLabel5, 2, 2, 2, 3 ); remotePath = new QLineEdit( "/", tab_3, "remotePath" ); remotePath->setText( currentRemoteDir = "/"); -// remotePath->setText( currentRemoteDir = "/home/llornkcor/"); tabLayout_3->addMultiCellWidget( remotePath, 3, 3, 2, 3 ); TextLabel4 = new QLabel( tab_3, "TextLabel4" ); TextLabel4->setText( tr( "Port" ) ); tabLayout_3->addMultiCellWidget( TextLabel4, 4, 4, 0, 1 ); PortSpinBox = new QSpinBox( tab_3, "PortSpinBox" ); 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 ); 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); currentPathEdit = new QLineEdit( "/", this, "currentPathEdit" ); layout->addMultiCellWidget( currentPathEdit, 3, 3, 0, 3 ); currentPathEdit->setText( currentDir.canonicalPath()); connect( currentPathEdit,SIGNAL(returnPressed()),this,SLOT(currentPathEditChanged())); ProgressBar = new QProgressBar( this, "ProgressBar" ); 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); } OpieFtp::~OpieFtp() { } void OpieFtp::cleanUp() { if(conn) FtpQuit(conn); QString sfile=QDir::homeDirPath(); if(sfile.right(1) != "/") @@ -360,25 +383,31 @@ void OpieFtp::remoteDownload() // FtpQuit(conn); } ProgressBar->reset(); nullifyCallBack(); TabWidget->setCurrentPage(0); populateLocalView(); QCopEnvelope ( "QPE/System", "notBusy()" ); } void OpieFtp::newConnection() { - TabWidget->setCurrentPage(2); + UsernameComboBox->lineEdit()->setText(""); + PasswordEdit->setText( "" ); + ServerComboBox->lineEdit()->setText( ""); + remotePath->setText( currentRemoteDir = "/"); + PortSpinBox->setValue( 21); + TabWidget->setCurrentPage(2); + } void OpieFtp::connector() { QCopEnvelope ( "QPE/System", "busy()" ); qApp->processEvents(); currentRemoteDir=remotePath->text(); if(ServerComboBox->currentText().isEmpty()) { QMessageBox::warning(this,tr("Ftp"),tr("Please set the server info"),tr("Ok"),0,0); TabWidget->setCurrentPage(2); ServerComboBox->setFocus(); return; @@ -399,24 +428,25 @@ void OpieFtp::connector() 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); FtpQuit(conn); return ; } remoteDirList("/") ; setCaption(ftp_host); + writeConfig(); QCopEnvelope ( "QPE/System", "notBusy()" ); } void OpieFtp::disConnector() { FtpQuit(conn); setCaption("OpieFtp"); currentRemoteDir="/"; Remote_View->clear(); } bool OpieFtp::remoteDirList(const QString &dir) @@ -908,12 +938,135 @@ void OpieFtp::switchToLocalTab() TabWidget->setCurrentPage(0); } void OpieFtp::switchToRemoteTab() { TabWidget->setCurrentPage(1); } 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 @@ -64,40 +64,45 @@ protected slots: void showLocalMenu( QListViewItem *); void showRemoteMenu( QListViewItem *); void doLocalCd(); void doRemoteCd(); void localUpload(); void remoteDownload(); void newConnection(); void connector(); void disConnector(); void populateLocalView(); bool populateRemoteView(); void showHidden(); - + void writeConfig(); + void readConfig(); void localListClicked(QListViewItem *); void remoteListClicked(QListViewItem *); void ListPressed( int, QListViewItem *, const QPoint&, int); void RemoteListPressed( int, QListViewItem *, const QPoint&, int); void localMakDir(); void localDelete(); void remoteMakDir(); void remoteDelete(); bool remoteDirList(const QString &); bool remoteChDir(const QString &); void tabChanged(QWidget*); void cleanUp(); void remoteRename(); void localRename(); void currentPathEditChanged(); void switchToLocalTab(); void switchToRemoteTab(); void switchToConfigTab(); + void fillCombos(); + void serverComboSelected(int); + void deleteServer(); + protected: void nullifyCallBack(); QGridLayout* tabLayout; QGridLayout* tabLayout_2; QGridLayout* tabLayout_3; }; #endif // OPIEFTP_H |