summaryrefslogtreecommitdiff
path: root/noncore
authorllornkcor <llornkcor>2002-09-30 01:32:04 (UTC)
committer llornkcor <llornkcor>2002-09-30 01:32:04 (UTC)
commit251458a2dd6d75c59440dc006060db2544de5d0e (patch) (side-by-side diff)
treee367bffa02a6e20caafa7f9917f1222fcaae0ab6 /noncore
parentf6e9cebd79044b1ca54648ecdadd13db8c4673dc (diff)
downloadopie-251458a2dd6d75c59440dc006060db2544de5d0e.zip
opie-251458a2dd6d75c59440dc006060db2544de5d0e.tar.gz
opie-251458a2dd6d75c59440dc006060db2544de5d0e.tar.bz2
fixed scroll, and cleanedup non used variables
Diffstat (limited to 'noncore') (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/net/opieftp/opieftp.cpp38
1 files changed, 22 insertions, 16 deletions
diff --git a/noncore/net/opieftp/opieftp.cpp b/noncore/net/opieftp/opieftp.cpp
index 9beac94..4e14946 100644
--- a/noncore/net/opieftp/opieftp.cpp
+++ b/noncore/net/opieftp/opieftp.cpp
@@ -39,52 +39,52 @@ extern "C" {
#include <qcombobox.h>
#include <qpopupmenu.h>
#include <qlistview.h>
#include <qmainwindow.h>
#include <qlabel.h>
#include <qprogressbar.h>
#include <qspinbox.h>
#include <qtabwidget.h>
#include <qwidget.h>
#include <qlayout.h>
#include <qimage.h>
#include <qpixmap.h>
#include <qmessagebox.h>
#include <qlineedit.h>
#include <qregexp.h>
#include <qlistbox.h>
#include <unistd.h>
#include <stdlib.h>
QProgressBar *ProgressBar;
static netbuf *conn=NULL;
-static int log_progress(netbuf *ctl, int xfered, void *arg)
+static int log_progress(netbuf *, int xfered, void *)
{
- int fsz = *(int *)arg;
- int pct = (xfered * 100) / fsz;
+// 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( )
{
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 );
connectionMenu = new QPopupMenu( this );
localMenu = new QPopupMenu( this );
@@ -204,71 +204,74 @@ OpieFtp::OpieFtp( )
QPEApplication::setStylusOperation( Remote_View->viewport(),QPEApplication::RightOnHold);
connect( Remote_View, SIGNAL( clicked( QListViewItem*)),
this,SLOT( remoteListClicked(QListViewItem *)) );
connect( Remote_View, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int)),
this,SLOT( RemoteListPressed(int, QListViewItem *, const QPoint&, int)) );
tabLayout_2->addWidget( Remote_View, 0, 0 );
TabWidget->insertTab( tab_2, tr( "Remote" ) );
tab_3 = new QWidget( TabWidget, "tab_3" );
tabLayout_3 = new QGridLayout( tab_3 );
tabLayout_3->setSpacing( 2);
tabLayout_3->setMargin( 2);
TextLabel1 = new QLabel( tab_3, "TextLabel1" );
TextLabel1->setText( tr( "Username" ) );
tabLayout_3->addMultiCellWidget( TextLabel1, 0, 0, 0, 1 );
UsernameComboBox = new QComboBox( FALSE, tab_3, "UsernameComboBox" );
UsernameComboBox->setEditable(TRUE);
tabLayout_3->addMultiCellWidget( UsernameComboBox, 1, 1, 0, 1 );
- connect( UsernameComboBox,SIGNAL(textChanged(const QString &)),this,SLOT( UsernameComboBoxEdited(const QString & ) ));
+ connect( UsernameComboBox,SIGNAL(textChanged(const QString &)),this,
+ SLOT( UsernameComboBoxEdited(const QString & ) ));
TextLabel2 = new QLabel( tab_3, "TextLabel2" );
TextLabel2->setText( tr( "Password" ) );
tabLayout_3->addMultiCellWidget( TextLabel2, 0, 0, 2, 3 );
PasswordEdit = new QLineEdit( "", tab_3, "PasswordComboBox" );
PasswordEdit->setEchoMode(QLineEdit::Password);
tabLayout_3->addMultiCellWidget( PasswordEdit, 1, 1, 2, 3 );
- connect( PasswordEdit,SIGNAL(textChanged(const QString &)),this,SLOT( PasswordEditEdited(const QString & ) ));
+ connect( PasswordEdit,SIGNAL(textChanged(const QString &)),this,
+ SLOT( PasswordEditEdited(const QString & ) ));
//PasswordEdit->setFixedWidth(85);
TextLabel3 = new QLabel( tab_3, "TextLabel3" );
TextLabel3->setText( tr( "Remote server" ) );
tabLayout_3->addMultiCellWidget( TextLabel3, 2, 2, 0, 1 );
ServerComboBox = new QComboBox( FALSE, tab_3, "ServerComboBox" );
ServerComboBox->setEditable(TRUE);
tabLayout_3->addMultiCellWidget( ServerComboBox, 3, 3, 0, 1 );
connect(ServerComboBox,SIGNAL(activated(int)),this,SLOT(serverComboSelected(int ) ));
- connect(ServerComboBox,SIGNAL(textChanged(const QString &)),this,SLOT(serverComboEdited(const QString & ) ));
+ connect(ServerComboBox,SIGNAL(textChanged(const QString &)),this,
+ SLOT(serverComboEdited(const QString & ) ));
QLabel *TextLabel5 = new QLabel( tab_3, "TextLabel5" );
TextLabel5->setText( tr( "Remote path" ) );
tabLayout_3->addMultiCellWidget( TextLabel5, 2, 2, 2, 3 );
remotePath = new QLineEdit( "/", tab_3, "remotePath" );
tabLayout_3->addMultiCellWidget( remotePath, 3, 3, 2, 3 );
TextLabel4 = new QLabel( tab_3, "TextLabel4" );
TextLabel4->setText( tr( "Port" ) );
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" );
@@ -326,144 +329,144 @@ OpieFtp::OpieFtp( )
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();
Config cfg("opieftp");
cfg.setGroup("Server");
cfg.writeEntry("currentServer", currentServerConfig);
exit(0);
}
-void OpieFtp::tabChanged(QWidget *w)
+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) {
tabMenu->setItemChecked(tabMenu->idAt(2),TRUE);
tabMenu->setItemChecked(tabMenu->idAt(0),FALSE);
tabMenu->setItemChecked(tabMenu->idAt(1),FALSE);
cdUpButton->hide();
homeButton->hide();
}
}
void OpieFtp::newConnection()
{
UsernameComboBox->lineEdit()->setText("");
PasswordEdit->setText( "" );
ServerComboBox->lineEdit()->setText( "");
remotePath->setText( currentRemoteDir = "/");
PortSpinBox->setValue( 21);
TabWidget->setCurrentPage(2);
}
-void OpieFtp::serverComboEdited(const QString & edit)
+void OpieFtp::serverComboEdited(const QString & )
{
// if( ServerComboBox->text(currentServerConfig) != edit /*edit.isEmpty() */) {
// qDebug("ServerComboEdited");
// // currentServerConfig = -1;
// }
}
-void OpieFtp::UsernameComboBoxEdited(const QString & use) {
+void OpieFtp::UsernameComboBoxEdited(const QString &) {
// currentServerConfig = -1;
}
-void OpieFtp::PasswordEditEdited(const QString & pass) {
+void OpieFtp::PasswordEditEdited(const QString & ) {
// currentServerConfig = -1;
}
void OpieFtp::connectorBtnToggled(bool On)
{
if(On) {
connector();
} else {
disConnector();
}
}
void OpieFtp::connector()
{
// QCopEnvelope ( "QPE/System", "busy()" );
// qApp->processEvents();
currentRemoteDir=remotePath->text();
if( ServerComboBox->currentText().isEmpty()) {
QMessageBox::warning(this,tr("Ftp"),tr("Please set the server info"),tr("Ok"),0,0);
TabWidget->setCurrentPage(2);
ServerComboBox->setFocus();
connectServerBtn->setOn(FALSE);
connectServerBtn->setText( tr("Connect"));
return;
}
FtpInit();
TabWidget->setCurrentPage(1);
QString ftp_host = ServerComboBox->currentText();
QString ftp_user = UsernameComboBox->currentText();
QString ftp_pass = PasswordEdit->text();
QString port=PortSpinBox->cleanText();
port.stripWhiteSpace();
Config cfg("opieftp");
cfg.setGroup("Server");
- int current=cfg.readNumEntry("currentServer", 1);
+// 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;
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 ;
}
if (!FtpLogin( ftp_user.latin1(), ftp_pass.latin1(),conn )) {
QString msg;
msg.sprintf(tr("Unable to log in\n")+"%s",FtpLastResponse(conn));
@@ -632,54 +635,54 @@ bool OpieFtp::remoteChDir(const QString &dir)
// qDebug(msg);
// 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();
// qDebug("Symlink detected "+symLink);
QFileInfo sym( symLink);
- fileS.sprintf( "%10li", sym.size() );
+ fileS.sprintf( "%10i", sym.size() );
fileL.sprintf( "%s -> %s", fi->fileName().data(),sym.absFilePath().data() );
fileDate = sym.lastModified().toString();
} else {
// qDebug("Not a dir: "+currentDir.canonicalPath()+fileL);
- fileS.sprintf( "%10li", fi->size() );
+ 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
@@ -793,129 +796,132 @@ void OpieFtp::remoteListClicked(QListViewItem *selectedItem)
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 +="/";
currentPathCombo->lineEdit()->setText( currentRemoteDir);
fillRemoteCombo( (const QString &)currentRemoteDir);
// QCopEnvelope ( "QPE/System", "notBusy()" );
+ 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());
}
}
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 &point, int i)
+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 &point, int i)
+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() ));
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)
@@ -1284,49 +1290,49 @@ void OpieFtp::fillCombos()
qDebug( "remote server string "+remoteServerStr);
ServerComboBox->insertItem( remoteServerStr );
cfg.setGroup(temp);
username = cfg.readEntry(temp);
UsernameComboBox->insertItem(username);
password = cfg.readEntryCrypt(username,"");
PasswordEdit->setText(password);
serverListView->insertItem( cfg.readEntry("ServerName"));
}
}
void OpieFtp::serverComboSelected(int index)
{
currentServerConfig = index+1;
qDebug("server combo selected %d", index+1);
QString username, remoteServerStr, remotePathStr, password, port, temp;
// remoteServerStr = ServerComboBox->text(index);
Config cfg("opieftp");
cfg.setGroup("Server");
- int numberOfEntries = cfg.readNumEntry("numberOfEntries",0);
+// int numberOfEntries = cfg.readNumEntry("numberOfEntries",0);
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"));