summaryrefslogtreecommitdiff
Side-by-side diff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/net/opieftp/opieftp.cpp114
-rw-r--r--noncore/net/opieftp/opieftp.h3
2 files changed, 79 insertions, 38 deletions
diff --git a/noncore/net/opieftp/opieftp.cpp b/noncore/net/opieftp/opieftp.cpp
index e1dd582..0cdac79 100644
--- a/noncore/net/opieftp/opieftp.cpp
+++ b/noncore/net/opieftp/opieftp.cpp
@@ -37,12 +37,13 @@
#include <qwidget.h>
#include <qlayout.h>
#include <qimage.h>
#include <qpixmap.h>
#include <qmessagebox.h>
#include <qlineedit.h>
+#include <qregexp.h>
#include <unistd.h>
#include <stdlib.h>
QProgressBar *ProgressBar;
static netbuf *conn=NULL;
@@ -142,13 +143,13 @@ OpieFtp::OpieFtp( )
TextLabel1 = new QLabel( tab_3, "TextLabel1" );
TextLabel1->setGeometry( QRect( 10, 10, 60, 16 ) );
TextLabel1->setText( tr( "Username" ) );
UsernameComboBox = new QComboBox( FALSE, tab_3, "UsernameComboBox" );
UsernameComboBox->setGeometry( QRect( 10, 25, 196, 21 ) );
UsernameComboBox->setEditable(TRUE);
- UsernameComboBox->lineEdit()->setText("root");
+ UsernameComboBox->lineEdit()->setText("llornkcor");
TextLabel2 = new QLabel( tab_3, "TextLabel2" );
TextLabel2->setGeometry( QRect( 10, 50, 65, 16 ) );
TextLabel2->setText( tr( "Password" ) );
PasswordEdit = new QLineEdit( "", tab_3, "PasswordComboBox" );
PasswordEdit->setGeometry( QRect( 10, 65, 195, 16 ) );
@@ -157,29 +158,30 @@ OpieFtp::OpieFtp( )
TextLabel3 = new QLabel( tab_3, "TextLabel3" );
TextLabel3->setGeometry( QRect( 10, 90, 95, 16 ) );
TextLabel3->setText( tr( "Remote server" ) );
ServerComboBox = new QComboBox( FALSE, tab_3, "ServerComboBox" );
ServerComboBox->setGeometry( QRect( 10, 105, 195, 21 ) );
ServerComboBox->setEditable(TRUE);
- ServerComboBox->lineEdit()->setText( tr( "192.168.129.201" ) );
+ ServerComboBox->lineEdit()->setText( tr( "llornkcor.com" ) );
QLabel *TextLabel5 = new QLabel( tab_3, "TextLabel5" );
TextLabel5->setGeometry( QRect( 10, 130, 95, 16 ) );
TextLabel5->setText( tr( "Remote path" ) );
remotePath = new QLineEdit( "/", tab_3, "remotePath" );
remotePath->setGeometry( QRect( 10, 145, 195, 16 ) );
- remotePath->setText( currentRemoteDir = "/");
+ remotePath->setText( currentRemoteDir = "/home/llornkcor/");
TextLabel4 = new QLabel( tab_3, "TextLabel4" );
TextLabel4->setGeometry( QRect( 10, 170, 30, 21 ) );
TextLabel4->setText( tr( "Port" ) );
PortSpinBox = new QSpinBox( tab_3, "PortSpinBox" );
PortSpinBox->setGeometry( QRect( 40, 175, 75, 20 ) );
PortSpinBox->setButtonSymbols( QSpinBox::UpDownArrows );
PortSpinBox->setMaxValue(32786);
- PortSpinBox->setValue( 4242 );
+ PortSpinBox->setValue( 21);
+
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);
@@ -223,36 +225,46 @@ void OpieFtp::localUpload()
qApp->processEvents();
QString strItem = Local_View->currentItem()->text(0);
QString localFile = currentDir.canonicalPath()+"/"+strItem;
QString remoteFile= currentRemoteDir+strItem;
QFileInfo fi(localFile);
if( !fi.isDir()) {
- fsz=fi.size();
- ProgressBar->setTotalSteps(fsz);
+ fsz=fi.size();
+ ProgressBar->setTotalSteps(fsz);
- FtpOptions(FTPLIB_CALLBACK, (long) log_progress, conn);
- FtpOptions(FTPLIB_IDLETIME, (long) 1000, conn);
- FtpOptions(FTPLIB_CALLBACKARG, (long) &fsz, conn);
- FtpOptions(FTPLIB_CALLBACKBYTES, (long) fsz/10, conn);
- qDebug("Put: %s, %s",localFile.latin1(),remoteFile.latin1());
+ FtpOptions(FTPLIB_CALLBACK, (long) log_progress, conn);
+ FtpOptions(FTPLIB_IDLETIME, (long) 1000, conn);
+ FtpOptions(FTPLIB_CALLBACKARG, (long) &fsz, conn);
+ FtpOptions(FTPLIB_CALLBACKBYTES, (long) fsz/10, conn);
+ qDebug("Put: %s, %s",localFile.latin1(),remoteFile.latin1());
- if( !FtpPut( localFile.latin1(), remoteFile.latin1(),FTPLIB_IMAGE, conn ) ) {
- QString msg;
- msg.sprintf("Unable to upload\n%s",FtpLastResponse(conn));
- QMessageBox::message("Note",msg);
- FtpQuit(conn);
- }
- ProgressBar->reset();
+ if( !FtpPut( localFile.latin1(), remoteFile.latin1(),FTPLIB_IMAGE, conn ) ) {
+ QString msg;
+ msg.sprintf("Unable to upload\n%s",FtpLastResponse(conn));
+ msg.replace(QRegExp(":"),"\n");
+ QMessageBox::message("Note",msg);
+// FtpQuit(conn);
+ }
+ ProgressBar->reset();
+ nullifyCallBack();
} else {
QMessageBox::message("Note","Cannot upload directories");
}
TabWidget->setCurrentPage(1);
populateRemoteView();
QCopEnvelope ( "QPE/System", "notBusy()" );
}
+void OpieFtp::nullifyCallBack() {
+ FtpOptions(FTPLIB_CALLBACK, NULL, conn);
+ FtpOptions(FTPLIB_IDLETIME, NULL, conn);
+ FtpOptions(FTPLIB_CALLBACKARG, NULL, conn);
+ FtpOptions(FTPLIB_CALLBACKBYTES, NULL, conn);
+
+}
+
void OpieFtp::remoteDownload()
{
int fsz;
QCopEnvelope ( "QPE/System", "busy()" );
qApp->processEvents();
QString strItem = Remote_View->currentItem()->text(0);
@@ -270,16 +282,18 @@ void OpieFtp::remoteDownload()
FtpOptions(FTPLIB_CALLBACKBYTES, (long) fsz/10, conn);
qDebug("Get: %s, %s",localFile.latin1(),remoteFile.latin1());
if(!FtpGet( localFile.latin1(), remoteFile.latin1(),FTPLIB_IMAGE, conn ) ) {
QString msg;
msg.sprintf("Unable to download \n%s",FtpLastResponse(conn));
+ msg.replace(QRegExp(":"),"\n");
QMessageBox::message("Note",msg);
- FtpQuit(conn);
+// FtpQuit(conn);
}
ProgressBar->reset();
+ nullifyCallBack();
TabWidget->setCurrentPage(0);
populateLocalView();
QCopEnvelope ( "QPE/System", "notBusy()" );
}
@@ -314,12 +328,13 @@ void OpieFtp::connector()
QMessageBox::message("Note","Unable to connect to\n"+ftp_host);
return ;
}
if (!FtpLogin( ftp_user.latin1(), ftp_pass.latin1(),conn )) {
QString msg;
msg.sprintf("Unable to log in\n%s",FtpLastResponse(conn));
+ msg.replace(QRegExp(":"),"\n");
QMessageBox::message("Note",msg);
FtpQuit(conn);
return ;
}
remoteDirList("/") ;
setCaption(ftp_host);
@@ -337,29 +352,32 @@ void OpieFtp::disConnector()
bool OpieFtp::remoteDirList(const QString &dir)
{
QCopEnvelope ( "QPE/System", "busy()" );
if (!FtpDir( "./._temp", dir.latin1(), conn) ) {
QString msg;
msg.sprintf("Unable to list the directory\n"+dir+"\n%s",FtpLastResponse(conn) );
+ msg.replace(QRegExp(":"),"\n");
QMessageBox::message("Note",msg);
- FtpQuit(conn);
+// FtpQuit(conn);
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("Unable to change directories "+dir+"\n%s",FtpLastResponse(conn));
+ msg.sprintf("Unable to change directories\n"+dir+"\n%s",FtpLastResponse(conn));
+ msg.replace(QRegExp(":"),"\n");
QMessageBox::message("Note",msg);
- FtpQuit(conn);
+ qDebug(msg);
+// FtpQuit(conn);
QCopEnvelope ( "QPE/System", "notBusy()" );
return FALSE;
}
QCopEnvelope ( "QPE/System", "notBusy()" );
return TRUE;
}
@@ -426,44 +444,54 @@ bool OpieFtp::populateRemoteView()
return true;
}
void OpieFtp::remoteListClicked(QListViewItem *selectedItem)
{
QCopEnvelope ( "QPE/System", "busy()" );
+ QString oldRemoteCurrentDir = currentRemoteDir;
QString strItem=selectedItem->text(0);
strItem=strItem.simplifyWhiteSpace();
- if(strItem == "../") {
+ if(strItem == "../") { // the user wants to go ^
if( FtpCDUp( conn) == 0) {
QString msg;
- msg.sprintf("Unable to change directories \n%s",FtpLastResponse(conn));
+ msg.sprintf("Unable to cd up\n%s",FtpLastResponse(conn));
+ msg.replace(QRegExp(":"),"\n");
QMessageBox::message("Note",msg);
+ qDebug(msg);
}
char path[256];
- if( FtpPwd( path,sizeof(path),conn) == 0) {
+ if( FtpPwd( path,sizeof(path),conn) == 0) { //this is easier than fudging the string
QString msg;
msg.sprintf("Unable to get working dir\n%s",FtpLastResponse(conn));
+ msg.replace(QRegExp(":"),"\n");
QMessageBox::message("Note",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)-3 );
+ strItem=strItem.right( strItem.length() - strItem.find("->",0,TRUE) - 2 );
strItem = strItem.stripWhiteSpace();
currentRemoteDir = strItem;
- if( remoteChDir( (const QString &)strItem) ==0) {
- QString msg;
- msg.sprintf("Unable to change directories \n%s",FtpLastResponse(conn));
- QMessageBox::message("Note",msg);
- }
- } else if(strItem.find("/",0,TRUE) != -1) {
- if( remoteChDir( (const QString &)currentRemoteDir+strItem) ==0) {
- QString msg;
- msg.sprintf("Unable to change directories \n%s",FtpLastResponse(conn));
- QMessageBox::message("Note",msg);
+ if( !remoteChDir( (const QString &)strItem)) {
+ currentRemoteDir = oldRemoteCurrentDir;
+ strItem="";
+ populateRemoteView();
+ qDebug("RemoteCurrentDir1 "+oldRemoteCurrentDir);
}
+ } else if(strItem.find("/",0,TRUE) != -1) { // this is a directory
+ qDebug("trying directory");
+ if( !remoteChDir( (const QString &)currentRemoteDir + strItem)) {
+ currentRemoteDir = oldRemoteCurrentDir;
+ strItem="";
+ qDebug("RemoteCurrentDir1 "+oldRemoteCurrentDir);
+
+ populateRemoteView();
+ } else {
currentRemoteDir = currentRemoteDir+strItem;
+ }
} else {
qDebug("download "+strItem);
}
}
if(currentRemoteDir.right(1) !="/")
currentRemoteDir +="/";
@@ -476,13 +504,13 @@ void OpieFtp::remoteListClicked(QListViewItem *selectedItem)
{
QString strItem=selectedItem->text(0);
QString strSize=selectedItem->text(1);
strSize=strSize.stripWhiteSpace();
if(strItem.find("@",0,TRUE) !=-1 || strItem.find("->",0,TRUE) !=-1 ) { //if symlink
// is symlink
- QString strItem2=strItem.right( (strItem.length()-strItem.find("->",0,TRUE)) -4);
+ QString strItem2 = strItem.right( (strItem.length() - strItem.find("->",0,TRUE)) - 4);
if(QDir(strItem2).exists() ) {
currentDir.cd(strItem2, TRUE);
populateLocalView();
}
} else { // not a symlink
if(strItem.find(". .",0,TRUE) && strItem.find("/",0,TRUE)!=-1 ) {
@@ -624,12 +652,13 @@ void OpieFtp::remoteMakDir()
QString filename = fileDlg->LineEdit1->text();//+".playlist";
QString tmp=currentRemoteDir+filename;
QCopEnvelope ( "QPE/System", "busy()" );
if(FtpMkdir( tmp.latin1(), conn) == 0) {
QString msg;
msg.sprintf("Unable to make directory\n%s",FtpLastResponse(conn));
+ msg.replace(QRegExp(":"),"\n");
QMessageBox::message("Note",msg);
}
QCopEnvelope ( "QPE/System", "notBusy()" );
}
populateRemoteView();
}
@@ -644,12 +673,13 @@ void OpieFtp::remoteDelete()
,"Yes","No",0,0,1) ) {
case 0: {
f=currentDir.canonicalPath()+"/"+f;
if(FtpRmdir( path.latin1(), conn) ==0) {
QString msg;
msg.sprintf("Unable to remove directory\n%s",FtpLastResponse(conn));
+ msg.replace(QRegExp(":"),"\n");
QMessageBox::message("Note",msg);
}
}
break;
};
} else {
@@ -657,12 +687,13 @@ void OpieFtp::remoteDelete()
,"Yes","No",0,0,1) ) {
case 0: {
QString path= currentRemoteDir+f;
if(FtpDelete( path.latin1(), conn)==0) {
QString msg;
msg.sprintf("Unable to delete file\n%s",FtpLastResponse(conn));
+ msg.replace(QRegExp(":"),"\n");
QMessageBox::message("Note",msg);
}
}
break;
};
}
@@ -680,12 +711,13 @@ void OpieFtp::remoteRename()
QString oldName = currentRemoteDir +"/"+ curFile;
QString newName = currentRemoteDir +"/"+ fileDlg->LineEdit1->text();//+".playlist";
QCopEnvelope ( "QPE/System", "busy()" );
if(FtpRename( oldName.latin1(), newName.latin1(),conn) == 0) {
QString msg;
msg.sprintf("Unable to rename file\n%s",FtpLastResponse(conn));
+ msg.replace(QRegExp(":"),"\n");
QMessageBox::message("Note",msg);
}
QCopEnvelope ( "QPE/System", "notBusy()" );
}
populateRemoteView();
}
@@ -705,12 +737,14 @@ void OpieFtp::localRename()
}
populateLocalView();
}
void OpieFtp::currentPathEditChanged()
{
+ QString oldRemoteCurrentDir = currentRemoteDir;
+ qDebug("oldRemoteCurrentDir "+oldRemoteCurrentDir);
if (TabWidget->currentPageIndex() == 0) {
if(QDir( currentPathEdit->text()).exists()) {
currentDir.setPath( currentPathEdit->text() );
populateLocalView();
} else {
QMessageBox::message("Note","That directory does not exist");
@@ -719,10 +753,14 @@ void OpieFtp::currentPathEditChanged()
if (TabWidget->currentPageIndex() == 1) {
currentRemoteDir = currentPathEdit->text();
if(currentRemoteDir.right(1) !="/") {
currentRemoteDir = currentRemoteDir +"/";
currentPathEdit->setText( currentRemoteDir );
}
- remoteChDir( (const QString &)currentRemoteDir);
+ if( !remoteChDir( (const QString &)currentRemoteDir) ) {
+ currentRemoteDir = oldRemoteCurrentDir;
+ currentPathEdit->setText( currentRemoteDir );
+ }
+
remoteDirList( (const QString &)currentRemoteDir);
}
}
diff --git a/noncore/net/opieftp/opieftp.h b/noncore/net/opieftp/opieftp.h
index 20dd0d0..e00a398 100644
--- a/noncore/net/opieftp/opieftp.h
+++ b/noncore/net/opieftp/opieftp.h
@@ -84,9 +84,12 @@ protected slots:
bool remoteChDir(const QString &);
void tabChanged(QWidget*);
void cleanUp();
void remoteRename();
void localRename();
void currentPathEditChanged();
+protected:
+ void nullifyCallBack();
+
};
#endif // OPIEFTP_H