summaryrefslogtreecommitdiff
path: root/noncore/net
Side-by-side diff
Diffstat (limited to 'noncore/net') (more/less context) (show whitespace changes)
-rw-r--r--noncore/net/opieftp/opieftp.cpp25
1 files changed, 13 insertions, 12 deletions
diff --git a/noncore/net/opieftp/opieftp.cpp b/noncore/net/opieftp/opieftp.cpp
index aa4314a..817943b 100644
--- a/noncore/net/opieftp/opieftp.cpp
+++ b/noncore/net/opieftp/opieftp.cpp
@@ -21,49 +21,48 @@ extern "C" {
/* OPIE */
#include <opie2/odebug.h>
#include <qpe/qpeapplication.h>
#include <qpe/resource.h>
#include <qpe/config.h>
#include <qpe/mimetype.h>
using namespace Opie::Core;
#include <qtextstream.h>
#include <qpushbutton.h>
#include <qtoolbutton.h>
#include <qcombobox.h>
#include <qlistview.h>
#include <qlabel.h>
#include <qprogressbar.h>
#include <qspinbox.h>
#include <qtabwidget.h>
#include <qlayout.h>
#include <qmessagebox.h>
#include <qmenubar.h>
#include <qlineedit.h>
#include <qlistbox.h>
#include <qvbox.h>
-
/* STD */
#include <unistd.h>
#include <stdlib.h>
QProgressBar *ProgressBar;
static netbuf *conn=NULL;
static int log_progress(netbuf *, int xfered, void *)
{
// int fsz = *(int *)arg;
// int pct = (xfered * 100) / fsz;
// printf("%3d%%\r", pct);
// fflush(stdout);
ProgressBar->setProgress(xfered);
qApp->processEvents();
return 1;
}
OpieFtp::OpieFtp( QWidget* parent, const char* name, WFlags fl)
: QMainWindow( parent, name, fl )
{
odebug << "OpieFtp constructor" << oendl;
setCaption( tr( "OpieFtp" ) );
fuckeduphack=FALSE;
@@ -281,78 +280,72 @@ OpieFtp::OpieFtp( QWidget* parent, const char* name, WFlags fl)
connect( serverListView, SIGNAL( highlighted(const QString&)),
this,SLOT( serverListClicked(const QString&) ) );
connectServerBtn = new QPushButton( tr("Connect"), tab_3 , "ConnectButton" );
tabLayout_3->addMultiCellWidget( connectServerBtn, 6, 6, 0, 1);
connectServerBtn->setToggleButton(TRUE);
connect(connectServerBtn,SIGNAL( toggled(bool)),SLOT( connectorBtnToggled(bool) ));
newServerButton= new QPushButton( tr("Add"), tab_3 , "NewServerButton" );
tabLayout_3->addMultiCellWidget( newServerButton, 6, 6, 2, 2);
connect( newServerButton,SIGNAL( clicked()),SLOT( NewServer() ));
QPushButton *deleteServerBtn;
deleteServerBtn = new QPushButton( tr("Delete"), tab_3 , "OpenButton" );
tabLayout_3->addMultiCellWidget( deleteServerBtn, 6, 6, 3, 3);
connect(deleteServerBtn,SIGNAL(clicked()),SLOT(deleteServer()));
QSpacerItem* spacer = new QSpacerItem( 20, 20, QSizePolicy::Minimum, QSizePolicy::Expanding );
tabLayout_3->addItem( spacer, 5, 0 );
TabWidget->insertTab( tab_3, tr( "Config" ) );
-#if 0
connect(TabWidget,SIGNAL(currentChanged(QWidget*)),
this,SLOT(tabChanged(QWidget*)));
-#endif
currentDir.setFilter( QDir::Files | QDir::Dirs/* | QDir::Hidden*/ | QDir::All);
currentDir.setPath( QDir::currentDirPath());
// currentDir.setSorting(/* QDir::Size*/ /*| QDir::Reversed | */QDir::DirsFirst);
currentPathCombo = new QComboBox( FALSE, view, "currentPathCombo" );
layout->addMultiCellWidget( currentPathCombo, 3, 3, 0, 4);
currentPathCombo ->setFixedWidth(220);
currentPathCombo->setEditable(TRUE);
currentPathCombo->lineEdit()->setText( currentDir.canonicalPath());
-#if 0
connect( currentPathCombo, SIGNAL( activated(const QString&) ),
this, SLOT( currentPathComboActivated(const QString&) ) );
connect( currentPathCombo->lineEdit(),SIGNAL(returnPressed()),
this,SLOT(currentPathComboChanged()));
-#endif
ProgressBar = new QProgressBar( view, "ProgressBar" );
layout->addMultiCellWidget( ProgressBar, 4, 4, 0, 4);
ProgressBar->setMaximumHeight(10);
filterStr="*";
b=FALSE;
-#if 0
populateLocalView();
-#endif
readConfig();
// ServerComboBox->setCurrentItem(currentServerConfig);
TabWidget->setCurrentPage(2);
odebug << "Constructor done" << oendl;
}
OpieFtp::~OpieFtp()
{
}
void OpieFtp::cleanUp()
{
if(conn)
FtpQuit(conn);
QString sfile=QDir::homeDirPath();
if(sfile.right(1) != "/")
sfile+="/._temp";
else
sfile+="._temp";
QFile file( sfile);
if(file.exists())
file.remove();
@@ -646,100 +639,102 @@ bool OpieFtp::remoteChDir(const QString &dir)
msg.replace(QRegExp(":"),"\n");
QMessageBox::message(tr("Note"),msg);
// odebug << msg << oendl;
// QCopEnvelope ( "QPE/System", "notBusy()" );
return FALSE;
}
// QCopEnvelope ( "QPE/System", "notBusy()" );
return TRUE;
}
void OpieFtp::populateLocalView()
{
Local_View->clear();
currentDir.setSorting(/* QDir::Size*/ /*| QDir::Reversed | */QDir::DirsFirst);
currentDir.setMatchAllDirs(TRUE);
currentDir.setNameFilter(filterStr);
QString fileL, fileS, fileDate;
bool isDir=FALSE;
const QFileInfoList *list = currentDir.entryInfoList( /*QDir::All*/ /*, QDir::SortByMask*/);
QFileInfoListIterator it(*list);
QFileInfo *fi;
while ( (fi=it.current()) ) {
if (fi->isSymLink() ){
QString symLink=fi->readLink();
- odebug << "Symlink detected "+symLink << oendl;
+// odebug << "Symlink detected "+symLink << oendl;
QFileInfo sym( symLink);
fileS.sprintf( "%10i", sym.size() );
fileL.sprintf( "%s -> %s", fi->fileName().data(),sym.absFilePath().data() );
fileDate = sym.lastModified().toString();
} else {
- odebug << "Not a dir: "+currentDir.canonicalPath()+fileL << oendl;
+// odebug << "Not a dir: "+currentDir.canonicalPath()+fileL << oendl;
fileS.sprintf( "%10i", fi->size() );
fileL.sprintf( "%s",fi->fileName().data() );
fileDate= fi->lastModified().toString();
if( QDir(QDir::cleanDirPath(currentDir.canonicalPath()+"/"+fileL)).exists() ) {
fileL+="/";
isDir=TRUE;
- odebug << fileL << oendl;
+// odebug << fileL << oendl;
}
}
+
+
if(fileL !="./" && fi->exists()) {
item = new QListViewItem( Local_View,fileL, fileDate, fileS );
QPixmap pm;
if(isDir || fileL.find("/",0,TRUE) != -1) {
if( !QDir( fi->filePath() ).isReadable())
pm = Resource::loadPixmap( "lockedfolder" );
else
pm= Resource::loadPixmap( "folder" );
item->setPixmap( 0,pm );
} else {
if( !fi->isReadable() )
pm = Resource::loadPixmap( "locked" );
else {
MimeType mt(fi->filePath());
pm=mt.pixmap(); //sets the correct pixmap for mimetype
if(pm.isNull())
pm = unknownXpm;
}
}
if( fileL.find("->",0,TRUE) != -1) {
// overlay link image
pm= Resource::loadPixmap( "folder" );
QPixmap lnk = Resource::loadPixmap( "opie/symlink" );
QPainter painter( &pm );
painter.drawPixmap( pm.width()-lnk.width(), pm.height()-lnk.height(), lnk );
pm.setMask( pm.createHeuristicMask( FALSE ) );
}
item->setPixmap( 0,pm);
}
isDir=FALSE;
++it;
}
Local_View->setSorting( 3,FALSE);
currentPathCombo->lineEdit()->setText( currentDir.canonicalPath() );
- fillCombo( (const QString &)currentDir);
+ // fillCombo( (const QString &)currentDir);
}
bool OpieFtp::populateRemoteView( )
{
// odebug << "populate remoteview" << oendl;
QString sfile=QDir::homeDirPath();
if(sfile.right(1) != "/")
sfile+="/._temp";
else
sfile+="._temp";
QFile file( sfile);
Remote_View->clear();
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;
@@ -1124,57 +1119,62 @@ void OpieFtp::localRename()
QString oldname = currentDir.canonicalPath() + "/" + curFile;
QString newName = currentDir.canonicalPath() + "/" + fileDlg->LineEdit1->text();//+".playlist";
if( rename(oldname.latin1(), newName.latin1())== -1)
QMessageBox::message(tr("Note"),tr("Could not rename"));
}
populateLocalView();
}
void OpieFtp::currentPathComboActivated(const QString & currentPath) {
if (TabWidget->currentPageIndex() == 0) {
chdir( currentPath.latin1() );
currentDir.cd( currentPath, TRUE);
populateLocalView();
update();
} else {
// chdir( currentPath.latin1() );
// currentDir.cd( currentPath, TRUE);
// populateList();
// update();
}
}
void OpieFtp::fillCombo(const QString &currentPath) {
-
+ qDebug("Fill Combo "+currentPath);
currentPathCombo->lineEdit()->setText(currentPath);
+
if( localDirPathStringList.grep(currentPath,TRUE).isEmpty() ) {
+ qDebug("Clearing local");
currentPathCombo->clear();
localDirPathStringList.prepend(currentPath );
currentPathCombo->insertStringList( localDirPathStringList,-1);
}
+
currentPathCombo->lineEdit()->setText(currentPath);
+
if( remoteDirPathStringList.grep(currentPath,TRUE).isEmpty() ) {
+ qDebug("Clearing remote");
currentPathCombo->clear();
remoteDirPathStringList.prepend(currentPath );
currentPathCombo->insertStringList( remoteDirPathStringList,-1);
}
}
void OpieFtp::fillRemoteCombo(const QString &currentPath) {
currentPathCombo->lineEdit()->setText(currentPath);
if( remoteDirPathStringList.grep(currentPath,TRUE).isEmpty() ) {
currentPathCombo->clear();
remoteDirPathStringList.prepend(currentPath );
currentPathCombo->insertStringList( remoteDirPathStringList,-1);
}
}
void OpieFtp::currentPathComboChanged()
{
QString oldRemoteCurrentDir = currentRemoteDir;
// odebug << "oldRemoteCurrentDir "+oldRemoteCurrentDir << oendl;
if (TabWidget->currentPageIndex() == 0) {
if(QDir( currentPathCombo->lineEdit()->text()).exists()) {
currentDir.setPath( currentPathCombo->lineEdit()->text() );
populateLocalView();
@@ -1266,48 +1266,49 @@ void OpieFtp::writeConfig()
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::clearCombos() {
odebug << "clearing" << oendl;
ServerComboBox->clear();
UsernameComboBox->clear();
PasswordEdit->clear();
serverListView->clear();
}
void OpieFtp::fillCombos()
{
clearCombos();
+ qDebug("did we get here yet?");
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);
odebug << temp << oendl;
cfg.setGroup("Server");
remoteServerStr = cfg.readEntry( temp,"");
odebug << remoteServerStr << oendl;
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);
odebug << "remote server string "+remoteServerStr << oendl;
ServerComboBox->insertItem( remoteServerStr );
cfg.setGroup(temp);