summaryrefslogtreecommitdiff
Side-by-side diff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/net/opieftp/ftplib.c2
-rw-r--r--noncore/net/opieftp/opieftp.cpp278
-rw-r--r--noncore/net/opieftp/opieftp.h9
3 files changed, 168 insertions, 121 deletions
diff --git a/noncore/net/opieftp/ftplib.c b/noncore/net/opieftp/ftplib.c
index b9ca746..5116170 100644
--- a/noncore/net/opieftp/ftplib.c
+++ b/noncore/net/opieftp/ftplib.c
@@ -59,5 +59,5 @@
#define FTPLIB_BUFSIZ 8192
-#define ACCEPT_TIMEOUT 30
+#define ACCEPT_TIMEOUT 15
#define FTPLIB_CONTROL 0
diff --git a/noncore/net/opieftp/opieftp.cpp b/noncore/net/opieftp/opieftp.cpp
index eed133e..d74c55b 100644
--- a/noncore/net/opieftp/opieftp.cpp
+++ b/noncore/net/opieftp/opieftp.cpp
@@ -1,4 +1,4 @@
/***************************************************************************
- opieftp.cpp
+ opieftp.cpp
-------------------
** Created: Sat Mar 9 23:33:09 2002
@@ -10,5 +10,5 @@
* (at your option) any later version. *
***************************************************************************/
-//#define DEVELOPER_VERSION
+#define DEVELOPERS_VERSION
#include "opieftp.h"
@@ -134,5 +134,5 @@ OpieFtp::OpieFtp( )
tabLayout->addWidget( Local_View, 0, 0 );
- connect( Local_View, SIGNAL( doubleClicked( QListViewItem*)),
+ connect( Local_View, SIGNAL( clicked( QListViewItem*)),
this,SLOT( localListClicked(QListViewItem *)) );
connect( Local_View, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int)),
@@ -155,5 +155,5 @@ OpieFtp::OpieFtp( )
QPEApplication::setStylusOperation( Remote_View->viewport(),QPEApplication::RightOnHold);
- connect( Remote_View, SIGNAL( doubleClicked( QListViewItem*)),
+ connect( Remote_View, SIGNAL( clicked( QListViewItem*)),
this,SLOT( remoteListClicked(QListViewItem *)) );
connect( Remote_View, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int)),
@@ -175,5 +175,4 @@ OpieFtp::OpieFtp( )
UsernameComboBox = new QComboBox( FALSE, tab_3, "UsernameComboBox" );
UsernameComboBox->setEditable(TRUE);
-// UsernameComboBox->lineEdit()->setText("anonymous");
tabLayout_3->addMultiCellWidget( UsernameComboBox, 1, 1, 0, 1 );
@@ -184,5 +183,4 @@ OpieFtp::OpieFtp( )
PasswordEdit = new QLineEdit( "", tab_3, "PasswordComboBox" );
PasswordEdit->setEchoMode(QLineEdit::Password);
-// PasswordEdit->setText( tr( "me@opieftp.org" ) );
tabLayout_3->addMultiCellWidget( PasswordEdit, 1, 1, 2, 3 );
@@ -193,8 +191,8 @@ OpieFtp::OpieFtp( )
ServerComboBox = new QComboBox( FALSE, tab_3, "ServerComboBox" );
ServerComboBox->setEditable(TRUE);
-// ServerComboBox->lineEdit()->setText( tr( "" ) );
tabLayout_3->addMultiCellWidget( ServerComboBox, 3, 3, 0, 1 );
connect(ServerComboBox,SIGNAL(activated(int)),this,SLOT(serverComboSelected(int ) ));
+ connect(ServerComboBox,SIGNAL(textChanged(const QString &)),this,SLOT(serverComboEdited(const QString & ) ));
QLabel *TextLabel5 = new QLabel( tab_3, "TextLabel5" );
@@ -203,5 +201,4 @@ OpieFtp::OpieFtp( )
remotePath = new QLineEdit( "/", tab_3, "remotePath" );
- remotePath->setText( currentRemoteDir = "/");
tabLayout_3->addMultiCellWidget( remotePath, 3, 3, 2, 3 );
@@ -213,17 +210,16 @@ OpieFtp::OpieFtp( )
PortSpinBox->setButtonSymbols( QSpinBox::UpDownArrows );
PortSpinBox->setMaxValue(32786);
- PortSpinBox->setValue( 21);
tabLayout_3->addMultiCellWidget( PortSpinBox, 4, 4, 1, 1);
QPushButton *deleteServerBtn;
- deleteServerBtn = new QPushButton( "Delete Server",this, "OpenButton" );
+ deleteServerBtn = new QPushButton( "Delete Server", tab_3 , "OpenButton" );
tabLayout_3->addMultiCellWidget( deleteServerBtn, 5, 5, 2, 3);
connect(deleteServerBtn,SIGNAL(clicked()),SLOT(deleteServer()));
- QPushButton *connectServerBtn;
- connectServerBtn = new QPushButton( "Connect",this, "ConnectButton" );
+ connectServerBtn = new QPushButton( "Connect", tab_3 , "ConnectButton" );
tabLayout_3->addMultiCellWidget( connectServerBtn, 5, 5, 0, 1);
- connect(connectServerBtn,SIGNAL( clicked()),SLOT( connector() ));
+ connectServerBtn->setToggleButton(TRUE);
+ connect(connectServerBtn,SIGNAL( toggled( bool)),SLOT( connectorBtnToggled(bool) ));
@@ -249,15 +245,17 @@ OpieFtp::OpieFtp( )
serverComboSelected(0);
-#ifdef DEVELOPER_VERSION
-// ServerComboBox->lineEdit()->setText( tr( "llornkcor.com" ) );
+ fillCombos();
+
+#ifdef DEVELOPERS_VERSION
ServerComboBox->lineEdit()->setText( tr( "192.168.129.201" ) );
UsernameComboBox->lineEdit()->setText("root");
-// UsernameComboBox->lineEdit()->setText("llornkcor");
PortSpinBox->setValue( 4242);
remotePath->setText( currentRemoteDir = "/");
+// ServerComboBox->lineEdit()->setText( tr( "llornkcor.com" ) );
+// UsernameComboBox->lineEdit()->setText("llornkcor");
+// PortSpinBox->setValue( 21);
+// remotePath->setText( currentRemoteDir = "/home/llornkcor");
PasswordEdit->setText( tr( "" ) );
-
-#endif
- fillCombos();
+#endif
filterStr="*";
b=FALSE;
@@ -305,4 +303,92 @@ void OpieFtp::tabChanged(QWidget *w)
}
+void OpieFtp::newConnection()
+{
+ UsernameComboBox->lineEdit()->setText("");
+ PasswordEdit->setText( "" );
+ ServerComboBox->lineEdit()->setText( "");
+ remotePath->setText( currentRemoteDir = "/");
+ PortSpinBox->setValue( 21);
+ TabWidget->setCurrentPage(2);
+ currentServerConfig = -1;
+}
+
+void OpieFtp::serverComboEdited(const QString & edit) {
+ if( !edit.isEmpty() ) {
+ currentServerConfig = -1;
+ qDebug("comboedited");
+ }
+}
+
+void OpieFtp::connectorBtnToggled(bool On)
+{
+ if(On) {
+ connector();
+ } else {
+ disConnector();
+ }
+
+}
+
+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();
+ connectServerBtn->setOn(FALSE);
+ connectServerBtn->setText( tr("Connect"));
+ return;
+ }
+ FtpInit();
+ TabWidget->setCurrentPage(1);
+ QString ftp_host = ServerComboBox->currentText();
+ QString ftp_user = UsernameComboBox->currentText();
+ QString ftp_pass = PasswordEdit->text();
+ QString port=PortSpinBox->cleanText();
+ 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();
+ 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);
+
+}
+
void OpieFtp::localUpload()
{
@@ -329,5 +415,4 @@ void OpieFtp::localUpload()
msg.replace(QRegExp(":"),"\n");
QMessageBox::message(tr("Note"),msg);
-// FtpQuit(conn);
}
ProgressBar->reset();
@@ -381,5 +466,4 @@ void OpieFtp::remoteDownload()
msg.replace(QRegExp(":"),"\n");
QMessageBox::message(tr("Note"),msg);
-// FtpQuit(conn);
}
ProgressBar->reset();
@@ -390,64 +474,4 @@ void OpieFtp::remoteDownload()
}
-
-void OpieFtp::newConnection()
-{
- 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;
- }
- FtpInit();
- TabWidget->setCurrentPage(1);
- QString ftp_host = ServerComboBox->currentText();
- QString ftp_user = UsernameComboBox->currentText();
- QString ftp_pass = PasswordEdit->text();
- QString port=PortSpinBox->cleanText();
- 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);
- 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)
{
@@ -464,5 +488,4 @@ bool OpieFtp::remoteDirList(const QString &dir)
msg.replace(QRegExp(":"),"\n");
QMessageBox::message(tr("Note"),msg);
-// FtpQuit(conn);
return false;
}
@@ -481,5 +504,4 @@ bool OpieFtp::remoteChDir(const QString &dir)
QMessageBox::message(tr("Note"),msg);
qDebug(msg);
-// FtpQuit(conn);
QCopEnvelope ( "QPE/System", "notBusy()" );
return FALSE;
@@ -582,5 +604,5 @@ bool OpieFtp::populateRemoteView( )
qDebug("temp file not opened successfullly "+sfile);
Remote_View->setSorting( 4,TRUE);
-
+
return true;
}
@@ -787,5 +809,5 @@ void OpieFtp::localDelete()
}
break;
- case 1:
+ case 1:
// exit
break;
@@ -846,5 +868,5 @@ void OpieFtp::remoteDelete()
}
remoteDirList( (const QString &)currentRemoteDir); //this also calls populate
-
+
}
break;
@@ -949,5 +971,6 @@ void OpieFtp::switchToConfigTab()
}
-void OpieFtp::readConfig() {
+void OpieFtp::readConfig()
+{
Config cfg("opieftp");
@@ -974,15 +997,22 @@ void OpieFtp::readConfig() {
password = cfg.readEntryCrypt(username,"");
PasswordEdit->setText(password);
-
}
-
}
-void OpieFtp::writeConfig() {
+void OpieFtp::writeConfig()
+{
Config cfg("opieftp");
cfg.setGroup("Server");
- QString temp;
+ QString username, remoteServerStr, remotePathStr, password, port, temp;
int numberOfEntries = cfg.readNumEntry("numberOfEntries",0);
+ if( currentServerConfig == -1) {
+
+ 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");
@@ -994,9 +1024,11 @@ void OpieFtp::writeConfig() {
cfg.setGroup("Server");
cfg.writeEntry("numberOfEntries", QString::number(numberOfEntries + 1 ));
-
+
+ }
}
-void OpieFtp::fillCombos() {
- Config cfg("opieftp");
+void OpieFtp::fillCombos()
+{
+ Config cfg("opieftp");
cfg.setGroup("Server");
QString username, remoteServerStr, remotePathStr, password, port, temp;
@@ -1027,12 +1059,11 @@ void OpieFtp::fillCombos() {
// password = cfg.readEntryCrypt(username,"");
// PasswordEdit->setText(password);
-
}
-
}
-void OpieFtp::serverComboSelected(int index) {
-
+void OpieFtp::serverComboSelected(int index)
+{
+ currentServerConfig = index;
QString username, remoteServerStr, remotePathStr, password, port, temp;
// remoteServerStr = ServerComboBox->text(index);
@@ -1041,24 +1072,22 @@ void OpieFtp::serverComboSelected(int index) {
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));
+ temp.setNum(index+1);
+ remoteServerStr = cfg.readEntry( 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;
- remotePath->setText(cfg.readEntry("RemotePath", ""));
- username = cfg.readEntry("Username", "");
- UsernameComboBox->lineEdit()->setText(username);
- PasswordEdit->setText(cfg.readEntryCrypt(username, ""));
+ PortSpinBox->setValue( portInt);
-// }
+ remotePath->setText(cfg.readEntry("RemotePath", "/"));
- // }
- update();
+ username = cfg.readEntry("Username", "anonymous");
+ UsernameComboBox->lineEdit()->setText(username);
+ PasswordEdit->setText(cfg.readEntryCrypt(username, "me@opieftp.org"));
+ update();
}
// UsernameComboBox->lineEdit()->setText("root");
@@ -1068,5 +1097,20 @@ void OpieFtp::serverComboSelected(int index) {
// PortSpinBox->setValue( 4242);
-void OpieFtp::deleteServer() {
-
+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
+ && !remoteServerStr.isEmpty()) {
+ qDebug(temp);
+ }
+ }
}
diff --git a/noncore/net/opieftp/opieftp.h b/noncore/net/opieftp/opieftp.h
index c88a15b..52ed885 100644
--- a/noncore/net/opieftp/opieftp.h
+++ b/noncore/net/opieftp/opieftp.h
@@ -37,7 +37,8 @@ class QFile;
class QListViewItem;
class QLineEdit;
+class QPushButton;
class OpieFtp : public QMainWindow
-{
+{
Q_OBJECT
@@ -59,7 +60,9 @@ public:
QString filterStr;
QListViewItem * item;
+ QPushButton *connectServerBtn;
bool b;
-
+ int currentServerConfig;
protected slots:
+ void serverComboEdited(const QString & );
void showLocalMenu( QListViewItem *);
void showRemoteMenu( QListViewItem *);
@@ -97,5 +100,5 @@ protected slots:
void serverComboSelected(int);
void deleteServer();
-
+ void connectorBtnToggled(bool);
protected:
void nullifyCallBack();