-rw-r--r-- | noncore/net/opieftp/opieftp.cpp | 49 |
1 files changed, 31 insertions, 18 deletions
diff --git a/noncore/net/opieftp/opieftp.cpp b/noncore/net/opieftp/opieftp.cpp index b703217..64146cb 100644 --- a/noncore/net/opieftp/opieftp.cpp +++ b/noncore/net/opieftp/opieftp.cpp @@ -18,88 +18,91 @@ extern "C" { } #include "inputDialog.h" /* 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 <qpe/qpemenubar.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; QVBox* wrapperBox = new QVBox( this ); setCentralWidget( wrapperBox ); QWidget *view = new QWidget( wrapperBox ); QGridLayout *layout = new QGridLayout( view ); - layout->setSpacing( 2); - layout->setMargin( 2); + layout->setSpacing( 1); + layout->setMargin( 1); connect( qApp,SIGNAL( aboutToQuit()),SLOT( cleanUp()) ); - QMenuBar *menuBar = new QMenuBar(this); -// QToolBar *menuBar = new QToolBar(this); + QPEMenuBar *menuBar = new QPEMenuBar(view); +// QMenuBar *menuBar = new QMenuBar(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 ); //#if 0 layout->addMultiCellWidget( menuBar, 0, 0, 0, 2 ); //#endif 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); @@ -114,63 +117,63 @@ OpieFtp::OpieFtp( QWidget* parent, const char* name, WFlags fl) localMenu->insertItem( tr( "Rename" ), this, SLOT( localRename() )); localMenu->insertSeparator(); localMenu->insertItem( tr( "Delete" ), this, SLOT( localDelete() )); localMenu->setCheckable(TRUE); remoteMenu->insertItem( tr( "Download" ), this, SLOT( remoteDownload() )); remoteMenu->insertItem( tr( "Make Directory" ), this, SLOT( remoteMakDir() )); remoteMenu->insertItem( tr( "Rename" ), this, SLOT( remoteRename() )); remoteMenu->insertSeparator(); remoteMenu->insertItem( tr( "Delete" ), this, SLOT( remoteDelete() )); tabMenu->insertSeparator(); tabMenu->insertItem( tr( "Switch to Local" ), this, SLOT( switchToLocalTab() )); tabMenu->insertItem( tr( "Switch to Remote" ), this, SLOT( switchToRemoteTab() )); tabMenu->insertItem( tr( "Switch to Config" ), this, SLOT( switchToConfigTab() )); tabMenu->insertSeparator(); // tabMenu->insertItem( tr( "About" ), this, SLOT( doAbout() )); tabMenu->setCheckable(TRUE); cdUpButton = new QToolButton( view,"cdUpButton"); cdUpButton->setPixmap(Resource::loadPixmap("up")); cdUpButton ->setFixedSize( QSize( 20, 20 ) ); connect( cdUpButton ,SIGNAL(released()),this,SLOT( upDir()) ); - layout->addMultiCellWidget( cdUpButton, 0, 0, 3, 3 ); + layout->addMultiCellWidget( cdUpButton, 0, 0, 4, 4 ); cdUpButton->hide(); // docButton = new QPushButton(Resource::loadIconSet("DocsIcon"),"",view,"docsButton"); // docButton->setFixedSize( QSize( 20, 20 ) ); // connect( docButton,SIGNAL(released()),this,SLOT( docButtonPushed()) ); // docButton->setFlat(TRUE); // layout->addMultiCellWidget( docButton, 0, 0, 6, 6 ); - homeButton = new QToolButton(view,"homeButton"); + homeButton = new QToolButton( view,"homeButton"); homeButton->setPixmap( Resource::loadPixmap("home")); homeButton->setFixedSize( QSize( 20, 20 ) ); connect(homeButton,SIGNAL(released()),this,SLOT(homeButtonPushed()) ); - layout->addMultiCellWidget( homeButton, 0, 0, 4, 4); - homeButton->hide(); + layout->addMultiCellWidget( homeButton, 0, 0, 3, 3); + homeButton->hide(); TabWidget = new QTabWidget( view, "TabWidget" ); layout->addMultiCellWidget( TabWidget, 1, 1, 0, 4 ); // TabWidget->setTabShape(QTabWidget::Triangular); tab = new QWidget( TabWidget, "tab" ); tabLayout = new QGridLayout( tab ); tabLayout->setSpacing( 2); tabLayout->setMargin( 2); Local_View = new QListView( tab, "Local_View" ); // Local_View->setResizePolicy( QListView::AutoOneFit ); Local_View->addColumn( tr("File"),150); Local_View->addColumn( tr("Date"),-1); Local_View->setColumnAlignment(1,QListView::AlignRight); Local_View->addColumn( tr("Size"),-1); Local_View->setColumnAlignment(2,QListView::AlignRight); Local_View->setAllColumnsShowFocus(TRUE); Local_View->setMultiSelection( TRUE); Local_View->setSelectionMode(QListView::Extended); Local_View->setFocusPolicy(QWidget::ClickFocus); @@ -231,48 +234,51 @@ OpieFtp::OpieFtp( QWidget* parent, const char* name, WFlags fl) UsernameComboBox->setEditable(TRUE); tabLayout_3->addMultiCellWidget( UsernameComboBox, 1, 1, 0, 1 ); 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&) )); //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); + ServerComboBox->setAutoCompletion(true); +// ServerComboBox->blockSignals(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&) )); 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); @@ -1305,91 +1311,98 @@ void OpieFtp::fillCombos() 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); username = cfg.readEntry(temp); UsernameComboBox->insertItem(username); password = cfg.readEntryCrypt(username,""); PasswordEdit->setText(password); serverListView->insertItem( cfg.readEntry("ServerName")); } } void OpieFtp::serverComboSelected(int index) { + QString servername; currentServerConfig = index+1; - odebug << "server combo selected " << index+1 << "" << oendl; + odebug << "server combo selected " << index + 1 << "" << oendl; QString username, remoteServerStr, remotePathStr, password, port, temp; -// remoteServerStr = ServerComboBox->text(index); + servername = remoteServerStr = ServerComboBox->text(index); + qDebug("server text " + remoteServerStr); Config cfg("opieftp"); cfg.setGroup("Server"); // int numberOfEntries = cfg.readNumEntry("numberOfEntries",0); - temp.setNum(index+1); + // for (int i = 1; i <= numberOfEntries; i++) { +// int numberOfEntries = cfg.readNumEntry("numberOfEntries",0); + + temp.setNum(index + 1); remoteServerStr = cfg.readEntry( temp,""); - odebug << "Group" +temp << oendl; + odebug << "Group " +temp << oendl; cfg.setGroup(temp); -// odebug << temp << oendl; + 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"); + username = cfg.readEntry("Username", "anonymous"); UsernameComboBox->lineEdit()->setText(username); odebug << username << oendl; // odebug << "Password is "+cfg.readEntryCrypt(username << oendl; PasswordEdit->setText(cfg.readEntryCrypt(username, "me@opieftp.org")); // UsernameComboBox // PasswordEdit cfg.setGroup("Server"); - temp.sprintf("%d",currentServerConfig); + temp.sprintf("%d", currentServerConfig); cfg.writeEntry("currentServer", temp); + cfg.writeEntry(temp,servername); + fuckeduphack = TRUE; serverListView->setCurrentItem( index); - fuckeduphack=FALSE; - odebug << "server list set selected " << index << "" << oendl; + fuckeduphack = FALSE; + qDebug( "server list set selected %d "+temp, index); + ServerComboBox->lineEdit()->setText(servername); 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 ) { // servername.find( cfg.readEntry("ServerName")) != -1 && // remoteServerStr.find( cfg.readEntry("RemotePath")) != -1 && |