summaryrefslogtreecommitdiff
Side-by-side diff
Diffstat (more/less context) (show whitespace changes)
-rw-r--r--noncore/net/opieftp/opieftp.cpp51
-rw-r--r--noncore/net/opieftp/opieftp.h0
2 files changed, 36 insertions, 15 deletions
diff --git a/noncore/net/opieftp/opieftp.cpp b/noncore/net/opieftp/opieftp.cpp
index 042ed59..6a3a64d 100644
--- a/noncore/net/opieftp/opieftp.cpp
+++ b/noncore/net/opieftp/opieftp.cpp
@@ -233,35 +233,40 @@ OpieFtp::OpieFtp( )
ProgressBar = new QProgressBar( this, "ProgressBar" );
layout->addMultiCellWidget( ProgressBar, 4, 4, 0, 3 );
filterStr="*";
populateLocalView();
}
OpieFtp::~OpieFtp()
{
}
void OpieFtp::cleanUp()
{
if(conn)
FtpQuit(conn);
- QFile f("./._temp");
- if(f.exists())
- f. remove();
+ QString sfile=QDir::homeDirPath();
+ if(sfile.right(1) != "/")
+ sfile+="/._temp";
+ else
+ sfile+="._temp";
+ QFile file( sfile);
+ if(file.exists())
+ file.remove();
}
void OpieFtp::tabChanged(QWidget *w)
{
if (TabWidget->currentPageIndex() == 0) {
currentPathEdit->setText( currentDir.canonicalPath());
}
if (TabWidget->currentPageIndex() == 1) {
currentPathEdit->setText( currentRemoteDir );
}
if (TabWidget->currentPageIndex() == 2) {
}
}
void OpieFtp::localUpload()
{
@@ -282,33 +287,33 @@ void OpieFtp::localUpload()
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));
msg.replace(QRegExp(":"),"\n");
QMessageBox::message("Note",msg);
// FtpQuit(conn);
}
ProgressBar->reset();
nullifyCallBack();
} else {
QMessageBox::message("Note","Cannot upload directories");
}
TabWidget->setCurrentPage(1);
- populateRemoteView();
+ remoteDirList( (const QString &)currentRemoteDir); //this also calls populate
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()" );
@@ -384,34 +389,40 @@ void OpieFtp::connector()
}
remoteDirList("/") ;
setCaption(ftp_host);
QCopEnvelope ( "QPE/System", "notBusy()" );
}
void OpieFtp::disConnector()
{
FtpQuit(conn);
setCaption("OpieFtp");
currentRemoteDir="/";
Remote_View->clear();
}
bool OpieFtp::remoteDirList(const QString &dir)
{
+ QString tmp = QDir::homeDirPath();
+ if(tmp.right(1) != "/")
+ tmp+="/._temp";
+ else
+ tmp+="._temp";
+// qDebug("Listing remote dir "+tmp);
QCopEnvelope ( "QPE/System", "busy()" );
- if (!FtpDir( "./._temp", dir.latin1(), conn) ) {
+ if (!FtpDir( tmp.latin1(), 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);
return false;
}
populateRemoteView();
QCopEnvelope ( "QPE/System", "notBusy()" );
return true;
}
bool OpieFtp::remoteChDir(const QString &dir)
{
QCopEnvelope ( "QPE/System", "busy()" );
if (!FtpChdir( dir.latin1(), conn )) {
@@ -452,55 +463,64 @@ void OpieFtp::populateLocalView()
fileL.sprintf( "%s",fi->fileName().data() );
fileDate= fi->lastModified().toString();
if( QDir(QDir::cleanDirPath(currentDir.canonicalPath()+"/"+fileL)).exists() ) {
fileL+="/";
// qDebug( fileL);
}
}
item= new QListViewItem( Local_View,fileL,fileS, fileDate);
++it;
}
Local_View->setSorting( 3,FALSE);
currentPathEdit->setText( currentDir.canonicalPath() );
}
bool OpieFtp::populateRemoteView()
{
+// qDebug("populate remoteview");
+ QString sfile=QDir::homeDirPath();
+ if(sfile.right(1) != "/")
+ sfile+="/._temp";
+ else
+ sfile+="._temp";
+ QFile file( sfile);
Remote_View->clear();
- QFile tmp("./._temp");
QString s, File_Name;
QString fileL, fileS, fileDate;
new QListViewItem( Remote_View, "../");
- if (tmp.open(IO_ReadOnly)) {
- QTextStream t( &tmp ); // use a text stream
+ if ( file.open(IO_ReadOnly)) {
+ QTextStream t( &file ); // use a text stream
while ( !t.eof()) {
s = t.readLine();
fileL = s.right(s.length()-55);
fileL = fileL.stripWhiteSpace();
if(s.left(1) == "d")
fileL = fileL+"/";
fileS = s.mid( 30, 42-30);
fileS = fileS.stripWhiteSpace();
fileDate = s.mid( 42, 55-42);
fileDate = fileDate.stripWhiteSpace();
if(fileL.find("total",0,TRUE) == -1)
new QListViewItem( Remote_View, fileL, fileS, fileDate);
}
- tmp.close();
+ file.close();
+ if( file.exists())
+ file. remove();
} else
- qDebug("temp file not opened successfullly");
+ qDebug("temp file not opened successfullly "+sfile);
+
return true;
}
void OpieFtp::remoteListClicked(QListViewItem *selectedItem)
{
QCopEnvelope ( "QPE/System", "busy()" );
QString oldRemoteCurrentDir = currentRemoteDir;
QString strItem=selectedItem->text(0);
strItem=strItem.simplifyWhiteSpace();
if(strItem == "../") { // the user wants to go ^
if( FtpCDUp( conn) == 0) {
QString msg;
msg.sprintf("Unable to cd up\n%s",FtpLastResponse(conn));
msg.replace(QRegExp(":"),"\n");
QMessageBox::message("Note",msg);
qDebug(msg);
@@ -509,54 +529,52 @@ void OpieFtp::remoteListClicked(QListViewItem *selectedItem)
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) - 2 );
strItem = strItem.stripWhiteSpace();
currentRemoteDir = strItem;
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);
}
}
+ remoteDirList( (const QString &)currentRemoteDir); //this also calls populate
if(currentRemoteDir.right(1) !="/")
currentRemoteDir +="/";
currentPathEdit->setText( currentRemoteDir );
- remoteDirList( (const QString &)currentRemoteDir);
QCopEnvelope ( "QPE/System", "notBusy()" );
}
void OpieFtp::localListClicked(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);
if(QDir(strItem2).exists() ) {
currentDir.cd(strItem2, TRUE);
populateLocalView();
}
} else { // not a symlink
@@ -711,93 +729,96 @@ void OpieFtp::localDelete()
void OpieFtp::remoteMakDir()
{
InputDialog *fileDlg;
fileDlg = new InputDialog(this,"Make Directory",TRUE, 0);
fileDlg->exec();
if( fileDlg->result() == 1 ) {
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()" );
+ remoteDirList( (const QString &)currentRemoteDir); //this also calls populate
}
- populateRemoteView();
}
void OpieFtp::remoteDelete()
{
QString f = Remote_View->currentItem()->text(0);
QCopEnvelope ( "QPE/System", "busy()" );
if( f.right(1) =="/") {
QString path= currentRemoteDir+f;
switch ( QMessageBox::warning(this,"Delete","Do you really want to delete\n"+f+"?"
,"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);
}
+ remoteDirList( (const QString &)currentRemoteDir); //this also calls populate
+
}
break;
};
} else {
switch ( QMessageBox::warning(this,"Delete","Do you really want to delete\n"+f+"?"
,"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);
}
+ remoteDirList( (const QString &)currentRemoteDir); //this also calls populate
}
break;
};
}
QCopEnvelope ( "QPE/System", "notBusy()" );
}
void OpieFtp::remoteRename()
{
QString curFile = Remote_View->currentItem()->text(0);
InputDialog *fileDlg;
fileDlg = new InputDialog(this,"Rename",TRUE, 0);
fileDlg->inputText = curFile;
fileDlg->exec();
if( fileDlg->result() == 1 ) {
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()" );
+ remoteDirList( (const QString &)currentRemoteDir); //this also calls populate
}
- populateRemoteView();
}
void OpieFtp::localRename()
{
QString curFile = Local_View->currentItem()->text(0);
InputDialog *fileDlg;
fileDlg = new InputDialog(this,"Rename",TRUE, 0);
fileDlg->inputText = curFile;
fileDlg->exec();
if( fileDlg->result() == 1 ) {
QString oldname = currentDir.canonicalPath() + "/" + curFile;
QString newName = currentDir.canonicalPath() + "/" + fileDlg->LineEdit1->text();//+".playlist";
if( rename(oldname.latin1(), newName.latin1())== -1)
QMessageBox::message("Note","Could not rename");
}
populateLocalView();
diff --git a/noncore/net/opieftp/opieftp.h b/noncore/net/opieftp/opieftp.h
index e3ff334..1e5fffa 100644
--- a/noncore/net/opieftp/opieftp.h
+++ b/noncore/net/opieftp/opieftp.h