summaryrefslogtreecommitdiff
path: root/noncore/net/opieftp
authormickeyl <mickeyl>2003-10-29 18:18:19 (UTC)
committer mickeyl <mickeyl>2003-10-29 18:18:19 (UTC)
commit1af1f1d9f398d38a2bc666cd2edff5725da7a770 (patch) (side-by-side diff)
treeb3bb0d90cafc1e933b5b9297a7b2669ce3b184ea /noncore/net/opieftp
parent35615947e11575a61456c8483e7f6d67fe59d5ed (diff)
downloadopie-1af1f1d9f398d38a2bc666cd2edff5725da7a770.zip
opie-1af1f1d9f398d38a2bc666cd2edff5725da7a770.tar.gz
opie-1af1f1d9f398d38a2bc666cd2edff5725da7a770.tar.bz2
mrege noncore/net/*
Diffstat (limited to 'noncore/net/opieftp') (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/net/opieftp/main.cpp15
-rw-r--r--noncore/net/opieftp/opieftp.cpp58
-rw-r--r--noncore/net/opieftp/opieftp.h3
-rw-r--r--noncore/net/opieftp/opieftp.pro6
4 files changed, 35 insertions, 47 deletions
diff --git a/noncore/net/opieftp/main.cpp b/noncore/net/opieftp/main.cpp
index 4f5a7d4..0217e41 100644
--- a/noncore/net/opieftp/main.cpp
+++ b/noncore/net/opieftp/main.cpp
@@ -1,27 +1,16 @@
/***************************************************************************
main.cpp - description
-------------------
begin : March 10, 2002
copyright : (C) 2002 by llornkcor
email : ljp@llornkcor.com
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
***************************************************************************/
-#include <qpe/qpeapplication.h>
-
-
-
+#include <opie/oapplicationfactory.h>
#include "opieftp.h"
-int main(int argc, char *argv[])
-{
- QPEApplication a(argc, argv);
-
- OpieFtp opieftp;
- a.showMainWidget( &opieftp);
- return a.exec();
-}
-
+OPIE_EXPORT_APP( OApplicationFactory<OpieFtp> )
diff --git a/noncore/net/opieftp/opieftp.cpp b/noncore/net/opieftp/opieftp.cpp
index 269449e..ee7d32f 100644
--- a/noncore/net/opieftp/opieftp.cpp
+++ b/noncore/net/opieftp/opieftp.cpp
@@ -48,49 +48,49 @@ 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( )
- : QMainWindow( )
+OpieFtp::OpieFtp( QWidget* parent, const char* name, WFlags fl)
+ : QMainWindow( parent, name, fl )
{
setCaption( tr( "OpieFtp" ) );
fuckeduphack=FALSE;
QGridLayout *layout = new QGridLayout( this );
layout->setSpacing( 2);
layout->setMargin( 2);
connect( qApp,SIGNAL( aboutToQuit()),SLOT( cleanUp()) );
QPEMenuBar *menuBar = new QPEMenuBar(this);
// QPEToolBar *menuBar = new QPEToolBar(this);
// menuBar->setHorizontalStretchable( TRUE );
QWMatrix matrix;
QPixmap pix(Resource::loadPixmap( "UnknownDocument" ));
matrix.scale( .4, .4);
unknownXpm = pix.xForm(matrix);
connectionMenu = new QPopupMenu( this );
localMenu = new QPopupMenu( this );
remoteMenu = new QPopupMenu( this );
tabMenu = new QPopupMenu( this );
-
+
layout->addMultiCellWidget( menuBar, 0, 0, 0, 2 );
menuBar->insertItem( tr( "Connection" ), connectionMenu);
// menuBar->insertItem( tr( "Local" ), localMenu);
// menuBar->insertItem( tr( "Remote" ), remoteMenu);
menuBar->insertItem( tr( "View" ), tabMenu);
tabMenu->insertItem( tr( "Local" ), localMenu);
tabMenu->insertItem( tr( "Remote" ), remoteMenu);
connectionMenu->insertItem( tr( "New" ), this, SLOT( newConnection() ));
connectionMenu->insertItem( tr( "Connect" ), this, SLOT( connector() ));
@@ -260,36 +260,36 @@ OpieFtp::OpieFtp( )
tabLayout_3->addMultiCellWidget( TextLabel4, 4, 4, 0, 1 );
PortSpinBox = new QSpinBox( tab_3, "PortSpinBox" );
PortSpinBox->setButtonSymbols( QSpinBox::UpDownArrows );
PortSpinBox->setMaxValue(32786);
tabLayout_3->addMultiCellWidget( PortSpinBox, 4, 4, 1, 1);
serverListView = new QListBox( tab_3, "ServerListView" );
tabLayout_3->addMultiCellWidget( serverListView , 5, 5, 0, 5);
connect( serverListView, SIGNAL( highlighted( const QString &)),
this,SLOT( serverListClicked( const QString &) ) );
-
- connectServerBtn = new QPushButton( "Connect", tab_3 , "ConnectButton" );
+
+ 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( "Add", tab_3 , "NewServerButton" );
+ 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( "Delete", tab_3 , "OpenButton" );
+ 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" ) );
connect(TabWidget,SIGNAL(currentChanged(QWidget *)),
this,SLOT(tabChanged(QWidget*)));
@@ -310,25 +310,25 @@ OpieFtp::OpieFtp( )
connect( currentPathCombo->lineEdit(),SIGNAL(returnPressed()),
this,SLOT(currentPathComboChanged()));
ProgressBar = new QProgressBar( this, "ProgressBar" );
layout->addMultiCellWidget( ProgressBar, 4, 4, 0, 4);
ProgressBar->setMaximumHeight(10);
filterStr="*";
b=FALSE;
populateLocalView();
readConfig();
// ServerComboBox->setCurrentItem(currentServerConfig);
-
+
TabWidget->setCurrentPage(2);
}
OpieFtp::~OpieFtp()
{
}
void OpieFtp::cleanUp()
{
if(conn)
FtpQuit(conn);
QString sfile=QDir::homeDirPath();
@@ -348,25 +348,25 @@ void OpieFtp::cleanUp()
void OpieFtp::tabChanged(QWidget *)
{
if (TabWidget->currentPageIndex() == 0) {
currentPathCombo->lineEdit()->setText( currentDir.canonicalPath());
tabMenu->setItemChecked(tabMenu->idAt(0),TRUE);
tabMenu->setItemChecked(tabMenu->idAt(1),FALSE);
tabMenu->setItemChecked(tabMenu->idAt(2),FALSE);
if(cdUpButton->isHidden())
cdUpButton->show();
if(homeButton->isHidden())
homeButton->show();
-
+
}
if (TabWidget->currentPageIndex() == 1) {
currentPathCombo->lineEdit()->setText( currentRemoteDir );
tabMenu->setItemChecked(tabMenu->idAt(1),TRUE);
tabMenu->setItemChecked(tabMenu->idAt(0),FALSE);
tabMenu->setItemChecked(tabMenu->idAt(2),FALSE);
if(cdUpButton->isHidden())
cdUpButton->show();
homeButton->hide();
}
if (TabWidget->currentPageIndex() == 2) {
@@ -440,25 +440,25 @@ void OpieFtp::connector()
port.stripWhiteSpace();
Config cfg("opieftp");
cfg.setGroup("Server");
// int current=cfg.readNumEntry("currentServer", 1);
// if(ftp_host!= cfg.readEntry(QString::number( current)))
// currentServerConfig=-1;
// cfg.setGroup(QString::number(current));
// if( ftp_user != cfg.readEntry("Username"))
// currentServerConfig=-1;
// if(ftp_pass != cfg.readEntry(cfg.readEntry("Username")))
-// currentServerConfig=-1;
+// currentServerConfig=-1;
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 ;
}
@@ -584,25 +584,25 @@ void OpieFtp::remoteDownload()
msg.sprintf(tr("Unable to download \n")+"%s",FtpLastResponse(conn));
msg.replace(QRegExp(":"),"\n");
QMessageBox::message(tr("Note"),msg);
}
ProgressBar->reset();
nullifyCallBack();
it.current()->setSelected(FALSE);
}
}
for ( ; it.current(); ++it ) {
Remote_View->clearSelection();
}
- Remote_View->setFocus();
+ Remote_View->setFocus();
TabWidget->setCurrentPage(0);
populateLocalView();
// QCopEnvelope ( "QPE/System", "notBusy()" );
}
bool OpieFtp::remoteDirList(const QString &dir)
{
QString tmp = QDir::homeDirPath();
if(tmp.right(1) != "/")
tmp+="/._temp";
else
tmp+="._temp";
@@ -660,25 +660,25 @@ void OpieFtp::populateLocalView()
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;
// qDebug( fileL);
}
}
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
@@ -720,25 +720,25 @@ bool OpieFtp::populateRemoteView( )
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")
+ 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");
@@ -806,68 +806,68 @@ void OpieFtp::remoteListClicked(QListViewItem *selectedItem)
}
} else {
// QCopEnvelope ( "QPE/System", "notBusy()" );
return;
}
}
remoteDirList( (const QString &)currentRemoteDir); //this also calls populate
if(currentRemoteDir.right(1) !="/")
currentRemoteDir +="/";
currentPathCombo->lineEdit()->setText( currentRemoteDir);
fillRemoteCombo( (const QString &)currentRemoteDir);
// QCopEnvelope ( "QPE/System", "notBusy()" );
- Remote_View->ensureItemVisible(Remote_View->firstChild());
-
+ Remote_View->ensureItemVisible(Remote_View->firstChild());
+
}
}
void OpieFtp::localListClicked(QListViewItem *selectedItem)
{
if(selectedItem!= NULL) {
-
+
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
if(strItem.find(". .",0,TRUE) && strItem.find("/",0,TRUE)!=-1 ) {
-
+
if(QDir(QDir::cleanDirPath(currentDir.canonicalPath()+"/"+strItem)).exists() ) {
strItem=QDir::cleanDirPath(currentDir.canonicalPath()+"/"+strItem);
currentDir.cd(strItem,FALSE);
populateLocalView();
} else {
currentDir.cdUp();
populateLocalView();
}
if(QDir(strItem).exists()){
currentDir.cd(strItem, TRUE);
populateLocalView();
}
} else {
strItem=QDir::cleanDirPath(currentDir.canonicalPath()+"/"+strItem);
if( QFile::exists(strItem ) ) {
// qDebug("upload "+strItem);
return;
}
} //end not symlink
chdir(strItem.latin1());
}
- Local_View->ensureItemVisible(Local_View->firstChild());
+ Local_View->ensureItemVisible(Local_View->firstChild());
}
}
void OpieFtp::doLocalCd()
{
localListClicked( Local_View->currentItem());
}
void OpieFtp:: doRemoteCd()
{
remoteListClicked( Remote_View->currentItem());
@@ -963,58 +963,58 @@ void OpieFtp::localMakDir()
}
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
break;
};
} else {
switch ( QMessageBox::warning(this,tr("Delete"),tr("Do you really want to delete\n")+f
+" ?",tr("Yes"),tr("No"),0,0,1) ) {
case 0: {
f=currentDir.canonicalPath()+"/"+f;
QString cmd="rm "+f;
system( cmd.latin1());
}
break;
- case 1:
+ case 1:
// exit
break;
};
}
}
}
populateLocalView();
-
+
}
void OpieFtp::remoteMakDir()
{
InputDialog *fileDlg;
fileDlg = new InputDialog(this,tr("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) {
@@ -1192,28 +1192,28 @@ void OpieFtp::switchToRemoteTab()
void OpieFtp::switchToConfigTab()
{
TabWidget->setCurrentPage(2);
}
void OpieFtp::readConfig()
{
fillCombos();
Config cfg("opieftp");
cfg.setGroup("Server");
currentServerConfig = cfg.readNumEntry("currentServer", -1);
-
+
// qDebug("Reading %d", currentServerConfig);
serverComboSelected( currentServerConfig-1);
-
+
}
void OpieFtp::writeConfig()
{
qDebug("write config");
Config cfg("opieftp");
cfg.setGroup("Server");
QString username, remoteServerStr, remotePathStr, password, port, temp;
int numberOfEntries = cfg.readNumEntry("numberOfEntries",0);
@@ -1245,25 +1245,25 @@ void OpieFtp::writeConfig()
cfg.setGroup(temp);
if(!newServerName.isEmpty())
cfg.writeEntry("ServerName", newServerName);
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() {
qDebug("clearing");
ServerComboBox->clear();
UsernameComboBox->clear();
PasswordEdit->clear();
serverListView->clear();
}
@@ -1317,57 +1317,57 @@ void OpieFtp::serverComboSelected(int index)
temp.setNum(index+1);
remoteServerStr = cfg.readEntry( temp,"");
qDebug("Group" +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;
-
+
ServerComboBox->lineEdit()->setText(remoteServerStr.left( remoteServerStr.find(":",0,TRUE)));
-
+
PortSpinBox->setValue( portInt);
remotePath->setText(cfg.readEntry("RemotePath", "/"));
username = cfg.readEntry("Username", "anonymous");
UsernameComboBox->lineEdit()->setText(username);
qDebug(username);
// qDebug("Password is "+cfg.readEntryCrypt(username, "me@opieftp.org"));
PasswordEdit->setText(cfg.readEntryCrypt(username, "me@opieftp.org"));
// UsernameComboBox
// PasswordEdit
-
+
cfg.setGroup("Server");
temp.sprintf("%d",currentServerConfig);
cfg.writeEntry("currentServer", temp);
fuckeduphack = TRUE;
serverListView->setCurrentItem( index);
fuckeduphack=FALSE;
qDebug("server list set selected %d",index);
update();
}
void OpieFtp::deleteServer()
{
QString username, remoteServerStr, remotePathStr, password, port, temp, servername;
remoteServerStr = ServerComboBox->currentText( );
username = UsernameComboBox->currentText();
servername=serverListView->currentText();
-
+
Config cfg("opieftp");
cfg.setGroup("Server");
QString tempname;
int numberOfEntries = cfg.readNumEntry("numberOfEntries",0);
for (int i = 1; i <= numberOfEntries; i++) {
temp.setNum(i);
// cfg.setGroup("Server");
cfg.setGroup(QString::number(i));
tempname=cfg.readEntry( "ServerName","");
if( tempname.find( servername,0,TRUE) != -1 ) {
@@ -1484,25 +1484,25 @@ void OpieFtp::NewServer() {
Config cfg("opieftp");
if( fileDlg->result() == 1 ) {
newServerName = fileDlg->LineEdit1->text();
for(int i=1;i<serverListView->count();i++) {
cfg.setGroup( QString::number(i));
if(cfg.readEntry("ServerName").find(newServerName,0,TRUE) != -1) {
QMessageBox::message(tr("OpieFtp"),tr("Sorry name already taken"));
return;
}
}
currentServerConfig =-1;
writeConfig();
- serverListView->insertItem( newServerName );
+ serverListView->insertItem( newServerName );
serverListView->setCurrentItem( serverListView->count());
}
}
void OpieFtp::serverListClicked( const QString &item) {
if(item.isEmpty()) return;
Config cfg("opieftp");
qDebug("highltined "+item);
int numberOfEntries = cfg.readNumEntry("numberOfEntries",0);
for (int i = 1; i <= numberOfEntries; i++) {
cfg.setGroup(QString::number(i));
if(cfg.readEntry( "ServerName").find(item) != -1 && !fuckeduphack)
diff --git a/noncore/net/opieftp/opieftp.h b/noncore/net/opieftp/opieftp.h
index 9d5d211..7bd615a 100644
--- a/noncore/net/opieftp/opieftp.h
+++ b/noncore/net/opieftp/opieftp.h
@@ -38,27 +38,28 @@ class QFile;
class QLineEdit;
class QPushButton;
class QToolButton;
class QStringList;
class QListBox;
class QTimer;
class OpieFtp : public QMainWindow
{
Q_OBJECT
public:
- OpieFtp( );
+ OpieFtp( QWidget* parent = 0, const char* name = 0, WFlags fl = 0 );
~OpieFtp();
+ static QString appName() { return QString::fromLatin1("opieftp"); }
QTabWidget *TabWidget;
QWidget *tab, *tab_2, *tab_3;
QListView *Local_View, *Remote_View;
QListBox *serverListView;
QComboBox *UsernameComboBox, *ServerComboBox, *currentPathCombo;
QLineEdit *PasswordEdit, *remotePath;
QLabel *TextLabel2, *TextLabel1, *TextLabel3, *TextLabel4;;
QSpinBox* PortSpinBox;
QPopupMenu *connectionMenu, *localMenu, *remoteMenu, *tabMenu, *aboutMenu;
QDir currentDir;
QString currentRemoteDir;
diff --git a/noncore/net/opieftp/opieftp.pro b/noncore/net/opieftp/opieftp.pro
index ac16819..185c341 100644
--- a/noncore/net/opieftp/opieftp.pro
+++ b/noncore/net/opieftp/opieftp.pro
@@ -1,18 +1,16 @@
-TEMPLATE = app
-CONFIG += qt warn_on release
-HEADERS = opieftp.h inputDialog.h
+CONFIG += qt warn_on release quick-app
+HEADERS = opieftp.h inputDialog.h
SOURCES = opieftp.cpp inputDialog.cpp main.cpp
TARGET = opieftp
-DESTDIR = $(OPIEDIR)/bin
INCLUDEPATH += $(OPIEDIR)/include
DEPENDPATH += $(OPIEDIR)/include
LIBS += -lqpe -lftplib
TRANSLATIONS = ../../../i18n/de/opieftp.ts \
../../../i18n/nl/opieftp.ts \
../../../i18n/da/opieftp.ts \
../../../i18n/xx/opieftp.ts \
../../../i18n/en/opieftp.ts \
../../../i18n/es/opieftp.ts \
../../../i18n/fr/opieftp.ts \
../../../i18n/hu/opieftp.ts \