summaryrefslogtreecommitdiff
Side-by-side diff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/net/opieftp/opieftp.cpp23
1 files changed, 14 insertions, 9 deletions
diff --git a/noncore/net/opieftp/opieftp.cpp b/noncore/net/opieftp/opieftp.cpp
index 668a03d..269449e 100644
--- a/noncore/net/opieftp/opieftp.cpp
+++ b/noncore/net/opieftp/opieftp.cpp
@@ -717,97 +717,98 @@ bool OpieFtp::populateRemoteView( )
QString s, File_Name;
QListViewItem *itemDir=NULL, *itemFile=NULL;
QRegExp monthRe(" [JFMASOND][eapuecoe][brynlgptvc] [ 0-9][0-9] [ 0-9][0-9][:0-9][0-9][0-9] ");
QString fileL, fileS, fileDate;
if ( file.open(IO_ReadOnly)) {
QTextStream t( &file ); // use a text stream
while ( !t.eof()) {
s = t.readLine();
if(s.find("total",0,TRUE) == 0)
continue;
int len, month = monthRe.match(s, 0, &len);
fileDate = s.mid(month + 1, len - 2); // minus spaces
fileL = s.right(s.length() - month - len);
if(s.left(1) == "d")
fileL = fileL+"/";
fileS = s.mid(month - 8, 8); // FIXME
fileS = fileS.stripWhiteSpace();
if(s.left(1) == "d" || fileL.find("/",0,TRUE) != -1) {
QListViewItem * item = new QListViewItem( Remote_View, fileL, fileDate, fileS,"d");
item->setPixmap( 0, Resource::loadPixmap( "folder" ));
// if(itemDir)
item->moveItem(itemDir);
itemDir=item;
} else {
QListViewItem * item = new QListViewItem( Remote_View, fileL, fileDate, fileS,"f");
item->setPixmap( 0, Resource::loadPixmap( "fileopen" ));
// if(itemFile)
item->moveItem(itemDir);
item->moveItem(itemFile);
itemFile=item;
}
}
QListViewItem * item1 = new QListViewItem( Remote_View, "../");
item1->setPixmap( 0, Resource::loadPixmap( "folder" ));
file.close();
if( file.exists())
file. remove();
} else
qDebug("temp file not opened successfullly "+sfile);
Remote_View->setSorting( 4,TRUE);
return true;
}
void OpieFtp::remoteListClicked(QListViewItem *selectedItem)
{
- if( selectedItem) {
+ if( selectedItem) {
+ // if(selectedItem!= NULL) {
// 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(tr("Unable to cd up\n")+"%s",FtpLastResponse(conn));
msg.replace(QRegExp(":"),"\n");
QMessageBox::message(tr("Note"),msg);
// qDebug(msg);
}
char path[256];
if( FtpPwd( path,sizeof(path),conn) == 0) { //this is easier than fudging the string
QString msg;
msg.sprintf(tr("Unable to get working dir\n")+"%s",FtpLastResponse(conn));
msg.replace(QRegExp(":"),"\n");
QMessageBox::message(tr("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="";
// qDebug("RemoteCurrentDir1 "+oldRemoteCurrentDir);
}
} else if(strItem.find("/",0,TRUE) != -1) { // this is a directory
if( !remoteChDir( (const QString &)currentRemoteDir + strItem)) {
currentRemoteDir = oldRemoteCurrentDir;
strItem="";
// qDebug("RemoteCurrentDir1 "+oldRemoteCurrentDir);
} else {
currentRemoteDir = currentRemoteDir+strItem;
}
} else {
// QCopEnvelope ( "QPE/System", "notBusy()" );
return;
}
}
remoteDirList( (const QString &)currentRemoteDir); //this also calls populate
if(currentRemoteDir.right(1) !="/")
currentRemoteDir +="/";
@@ -863,120 +864,124 @@ void OpieFtp::localListClicked(QListViewItem *selectedItem)
void OpieFtp::doLocalCd()
{
localListClicked( Local_View->currentItem());
}
void OpieFtp:: doRemoteCd()
{
remoteListClicked( Remote_View->currentItem());
}
void OpieFtp::showHidden()
{
if (!b) {
currentDir.setFilter( QDir::Files | QDir::Dirs | QDir::Hidden | QDir::All);
localMenu->setItemChecked(localMenu->idAt(0),TRUE);
// currentDir.setSorting(/* QDir::Size*/ /*| QDir::Reversed | */QDir::DirsFirst);
b=TRUE;
} else {
currentDir.setFilter( QDir::Files | QDir::Dirs/* | QDir::Hidden*/ | QDir::All);
localMenu->setItemChecked(localMenu->idAt(0),FALSE);
// currentDir.setSorting(/* QDir::Size*/ /*| QDir::Reversed | */QDir::DirsFirst);
b=FALSE;
}
populateLocalView();
}
void OpieFtp::ListPressed( int mouse, QListViewItem *item, const QPoint &, int)
{
// if(item)
if (mouse == 2) {
showLocalMenu(item);
}
}
void OpieFtp::RemoteListPressed( int mouse, QListViewItem *item, const QPoint &, int )
{
if(mouse == 2) {
showRemoteMenu(item);
}
}
void OpieFtp::showRemoteMenu(QListViewItem * item)
{
QPopupMenu * m;// = new QPopupMenu( Local_View );
m = new QPopupMenu(this);
- if( /*item->text(0).right(1) == "/" ||*/ item->text(0).find("/",0,TRUE) != -1)
- m->insertItem( tr( "Change Directory" ), this, SLOT( doRemoteCd() ));
- else
- m->insertItem( tr( "Download" ), this, SLOT( remoteDownload() ));
+ if(item != NULL ) {
+ if( item->text(0).find("/",0,TRUE) != -1)
+ m->insertItem( tr( "Change Directory" ), this, SLOT( doRemoteCd() ));
+ else
+ m->insertItem( tr( "Download" ), this, SLOT( remoteDownload() ));
+ }
m->insertItem( tr( "Make Directory" ), this, SLOT( remoteMakDir() ));
m->insertItem( tr("Rescan"), this, SLOT( populateLocalView() ));
m->insertItem( tr( "Rename" ), this, SLOT( remoteRename() ));
m->insertSeparator();
m->insertItem( tr( "Delete" ), this, SLOT( remoteDelete() ));
m->exec( QCursor::pos() );
delete m;
}
void OpieFtp::showLocalMenu(QListViewItem * item)
{
QPopupMenu *m;
m = new QPopupMenu( this);
m->insertItem( tr( "Show Hidden Files" ), this, SLOT( showHidden() ));
m->insertSeparator();
- if( /*item->text(0).right(1) == "/" ||*/ item->text(0).find("/",0,TRUE) !=-1)
- m->insertItem( tr( "Change Directory" ), this, SLOT( doLocalCd() ));
- else
- m->insertItem( tr( "Upload" ), this, SLOT( localUpload() ));
+ if(item != NULL ) {
+ if( item->text(0).find("/",0,TRUE) !=-1)
+ m->insertItem( tr( "Change Directory" ), this, SLOT( doLocalCd() ));
+ else
+ m->insertItem( tr( "Upload" ), this, SLOT( localUpload() ));
+ }
m->insertItem( tr( "Make Directory" ), this, SLOT( localMakDir() ));
m->insertItem( tr("Rescan"), this, SLOT( populateRemoteView() ));
m->insertItem( tr( "Rename" ), this, SLOT( localRename() ));
m->insertSeparator();
m->insertItem( tr( "Delete" ), this, SLOT( localDelete() ));
m->setCheckable(TRUE);
if (b)
m->setItemChecked(m->idAt(0),TRUE);
else
m->setItemChecked(m->idAt(0),FALSE);
m->exec( QCursor::pos() );
delete m;
}
void OpieFtp::localMakDir()
{
InputDialog *fileDlg;
fileDlg = new InputDialog(this,tr("Make Directory"),TRUE, 0);
fileDlg->exec();
if( fileDlg->result() == 1 ) {
QString filename = fileDlg->LineEdit1->text();
currentDir.mkdir( currentDir.canonicalPath()+"/"+filename);
}
populateLocalView();
}
void OpieFtp::localDelete()
{
QList<QListViewItem> * getSelectedItems( QListView * Local_View );
QListViewItemIterator it( Local_View );
for ( ; it.current(); ++it ) {
if ( it.current()->isSelected() ) {
QString f = it.current()->text(0);
it.current()->setSelected(FALSE);
// QString f = Local_View->currentItem()->text(0);
if(QDir(f).exists() ) {
switch ( QMessageBox::warning(this,tr("Delete"),tr("Do you really want to delete\n")+f+
tr(" ?\nIt must be empty"),tr("Yes"),tr("No"),0,0,1) ) {
case 0: {
f=currentDir.canonicalPath()+"/"+f;
QString cmd="rmdir "+f;
system( cmd.latin1());
}
break;
case 1:
// exit