author | llornkcor <llornkcor> | 2005-01-03 03:09:51 (UTC) |
---|---|---|
committer | llornkcor <llornkcor> | 2005-01-03 03:09:51 (UTC) |
commit | 0b3bbec6703c021a188c865e822f536bfa3045fc (patch) (side-by-side diff) | |
tree | 3458531d039a111ba39ef2e0bed2e5bbbfedad46 | |
parent | 8ce8566bf038f0293a0690fce44df2bba9c4eb52 (diff) | |
download | opie-0b3bbec6703c021a188c865e822f536bfa3045fc.zip opie-0b3bbec6703c021a188c865e822f536bfa3045fc.tar.gz opie-0b3bbec6703c021a188c865e822f536bfa3045fc.tar.bz2 |
mess with things so this runs from launcher. not sure what was going on, but this seems to fix #1507
-rw-r--r-- | noncore/net/opieftp/main.cpp | 6 | ||||
-rw-r--r-- | noncore/net/opieftp/opieftp.cpp | 62 | ||||
-rw-r--r-- | noncore/net/opieftp/opieftp.h | 6 | ||||
-rw-r--r-- | noncore/net/opieftp/opieftp.pro | 3 |
4 files changed, 44 insertions, 33 deletions
diff --git a/noncore/net/opieftp/main.cpp b/noncore/net/opieftp/main.cpp index 330ca52..763ffb4 100644 --- a/noncore/net/opieftp/main.cpp +++ b/noncore/net/opieftp/main.cpp @@ -1,18 +1,20 @@ /*************************************************************************** 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 <opie2/oapplicationfactory.h> #include "opieftp.h" - +#include <opie2/oapplicationfactory.h> +//#include <qtopia/qpeapplication.h> using namespace Opie::Core; OPIE_EXPORT_APP( OApplicationFactory<OpieFtp> ) + + diff --git a/noncore/net/opieftp/opieftp.cpp b/noncore/net/opieftp/opieftp.cpp index 64146cb..4f0ca29 100644 --- a/noncore/net/opieftp/opieftp.cpp +++ b/noncore/net/opieftp/opieftp.cpp @@ -7,109 +7,113 @@ * 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. * ***************************************************************************/ //#define DEVELOPERS_VERSION #include "opieftp.h" extern "C" { #include <ftplib.h> } #include "inputDialog.h" /* OPIE */ -#include <opie2/odebug.h> +//#include <opie2/odebug.h> +//using namespace Opie::Core; + #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 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 ) +OpieFtp::OpieFtp( QWidget* , const char*, WFlags) + : QMainWindow( ) { - odebug << "OpieFtp constructor" << oendl; + qDebug("OpieFtp constructor"); setCaption( tr( "OpieFtp" ) ); +// initializeGui(); + QTimer::singleShot( 50, this, SLOT(initializeGui() )); +} + +void OpieFtp::initializeGui() { fuckeduphack=FALSE; QVBox* wrapperBox = new QVBox( this ); setCentralWidget( wrapperBox ); QWidget *view = new QWidget( wrapperBox ); QGridLayout *layout = new QGridLayout( view ); layout->setSpacing( 1); layout->setMargin( 1); connect( qApp,SIGNAL( aboutToQuit()),SLOT( cleanUp()) ); 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); connectionMenu->insertItem( tr( "New" ), this, SLOT( newConnection() )); connectionMenu->insertItem( tr( "Connect" ), this, SLOT( connector() )); connectionMenu->insertItem( tr( "Disconnect" ), this, SLOT( disConnector() )); localMenu->insertItem( tr( "Show Hidden Files" ), this, SLOT( showHidden() )); localMenu->insertSeparator(); localMenu->insertItem( tr( "Upload" ), this, SLOT( localUpload() )); @@ -303,53 +307,55 @@ OpieFtp::OpieFtp( QWidget* parent, const char* name, WFlags fl) 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*))); 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 ->setFixedWidth(220); currentPathCombo->setEditable(TRUE); currentPathCombo->lineEdit()->setText( currentDir.canonicalPath()); connect( currentPathCombo, SIGNAL( activated(const QString&) ), this, SLOT( currentPathComboActivated(const QString&) ) ); connect( currentPathCombo->lineEdit(),SIGNAL(returnPressed()), this,SLOT(currentPathComboChanged())); - ProgressBar = new QProgressBar( view, "ProgressBar" ); - layout->addMultiCellWidget( ProgressBar, 4, 4, 0, 4); - ProgressBar->setMaximumHeight(10); + ProgressBar = new QProgressBar( view, "ProgressBar" ); + layout->addMultiCellWidget( ProgressBar, 4, 4, 0, 4); + ProgressBar->setMaximumHeight(10); filterStr="*"; b=FALSE; populateLocalView(); readConfig(); // ServerComboBox->setCurrentItem(currentServerConfig); TabWidget->setCurrentPage(2); - odebug << "Constructor done" << oendl; + qDebug("XXXXXXXXXXXX Constructor done"); + } 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); @@ -522,33 +528,33 @@ void OpieFtp::localUpload() QList<QListViewItem> * getSelectedItems( QListView * Local_View ); QListViewItemIterator it( Local_View ); for ( ; it.current(); ++it ) { if ( it.current()->isSelected() ) { QString strItem = it.current()->text(0); QString localFile = currentDir.canonicalPath()+"/"+strItem; QString remoteFile= currentRemoteDir+strItem; QFileInfo fi(localFile); if( !fi.isDir()) { fsz=fi.size(); ProgressBar->setTotalSteps(fsz); FtpOptions(FTPLIB_CALLBACK, (long) log_progress, conn); FtpOptions(FTPLIB_IDLETIME, (long) 1000, conn); FtpOptions(FTPLIB_CALLBACKARG, (long) &fsz, conn); FtpOptions(FTPLIB_CALLBACKBYTES, (long) fsz/10, conn); - odebug << "Put: " << localFile.latin1() << ", " << remoteFile.latin1() << "" << oendl; +// odebug << "Put: " << localFile.latin1() << ", " << remoteFile.latin1() << "" << oendl; if( !FtpPut( localFile.latin1(), remoteFile.latin1(),FTPLIB_IMAGE, conn ) ) { QString msg; msg.sprintf(tr("Unable to upload\n")+"%s",FtpLastResponse(conn)); msg.replace(QRegExp(":"),"\n"); QMessageBox::message(tr("Note"),msg); } } else { QMessageBox::message(tr("Note"),tr("Cannot upload directories")); } ProgressBar->reset(); nullifyCallBack(); it.current()->setSelected(FALSE); } //end currentSelected } for ( ; it.current(); ++it ) { @@ -583,33 +589,33 @@ void OpieFtp::remoteDownload() QString localFile = currentDir.canonicalPath(); if(localFile.right(1).find("/",0,TRUE) == -1) localFile += "/"; localFile += strItem; // QString localFile = currentDir.canonicalPath()+"/"+strItem; QString remoteFile= currentRemoteDir+strItem; if (!FtpSize( remoteFile.latin1(), &fsz, FTPLIB_ASCII, conn)) fsz = 0; QString temp; temp.sprintf( remoteFile+" "+" %dkb", fsz); ProgressBar->setTotalSteps(fsz); FtpOptions(FTPLIB_CALLBACK, (long) log_progress, conn); FtpOptions(FTPLIB_IDLETIME, (long) 1000, conn); FtpOptions(FTPLIB_CALLBACKARG, (long) &fsz, conn); FtpOptions(FTPLIB_CALLBACKBYTES, (long) fsz/10, conn); - odebug << "Get: " << localFile.latin1() << ", " << remoteFile.latin1() << "" << oendl; +// odebug << "Get: " << localFile.latin1() << ", " << remoteFile.latin1() << "" << oendl; if(!FtpGet( localFile.latin1(), remoteFile.latin1(),FTPLIB_IMAGE, conn ) ) { QString msg; 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(); @@ -762,34 +768,34 @@ bool OpieFtp::populateRemoteView( ) 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 - odebug << "temp file not opened successfully "+sfile << oendl; + } +// odebug << "temp file not opened successfully "+sfile << oendl; Remote_View->setSorting( 4,TRUE); return true; } void OpieFtp::remoteListClicked(QListViewItem *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)); @@ -1221,164 +1227,164 @@ void OpieFtp::switchToConfigTab() } void OpieFtp::readConfig() { fillCombos(); Config cfg("opieftp"); cfg.setGroup("Server"); currentServerConfig = cfg.readNumEntry("currentServer", -1); // odebug << "Reading " << currentServerConfig << "" << oendl; serverComboSelected( currentServerConfig-1); } void OpieFtp::writeConfig() { - odebug << "write config" << oendl; +// odebug << "write config" << oendl; Config cfg("opieftp"); cfg.setGroup("Server"); QString username, remoteServerStr, remotePathStr, password, port, temp; int numberOfEntries = cfg.readNumEntry("numberOfEntries",0); if( currentServerConfig == -1) { for (int i = 1; i <= numberOfEntries; i++) { temp.setNum(i); cfg.setGroup("Server"); QString tempStr = cfg.readEntry( temp,""); } temp.setNum( numberOfEntries + 1); cfg.setGroup("Server"); remoteServerStr = cfg.readEntry( temp,""); int divider = remoteServerStr.length() - remoteServerStr.find(":",0,TRUE); remoteServerStr = remoteServerStr.left(remoteServerStr.length()-divider); temp.setNum(numberOfEntries+1); cfg.setGroup("Server"); cfg.writeEntry( temp, ServerComboBox->currentText() +":"+PortSpinBox->cleanText() ); cfg.writeEntry("currentServer", numberOfEntries+1); currentServerConfig = numberOfEntries+1; - odebug << "setting currentserverconfig to " << currentServerConfig << "" << oendl; +// odebug << "setting currentserverconfig to " << currentServerConfig << "" << oendl; 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() { - odebug << "clearing" << oendl; +// 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; +// odebug << temp << oendl; cfg.setGroup("Server"); remoteServerStr = cfg.readEntry( temp,""); - odebug << remoteServerStr << oendl; +// 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; +// 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; servername = remoteServerStr = ServerComboBox->text(index); qDebug("server text " + remoteServerStr); Config cfg("opieftp"); cfg.setGroup("Server"); // int numberOfEntries = cfg.readNumEntry("numberOfEntries",0); // 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); 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); - odebug << username << oendl; +// 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); cfg.writeEntry("currentServer", temp); cfg.writeEntry(temp,servername); fuckeduphack = TRUE; serverListView->setCurrentItem( index); fuckeduphack = FALSE; qDebug( "server list set selected %d "+temp, index); ServerComboBox->lineEdit()->setText(servername); @@ -1397,33 +1403,33 @@ void OpieFtp::deleteServer() 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 && // username.find( cfg.readEntry("Username")) != -1) { serverListView->removeItem(i); - odebug << "OK DELETE "+tempname << oendl; +// odebug << "OK DELETE "+tempname << oendl; cfg.removeEntry(QString::number(i)); for ( ; i <= numberOfEntries; i++) { cfg.setGroup("Server"); cfg.writeEntry("Server", QString::number(numberOfEntries + 1 )); cfg.setGroup(QString::number(i+1)); //get next server config servername=cfg.readEntry("ServerName"); remoteServerStr=cfg.readEntry("RemotePath"); username=cfg.readEntry("Username"); password=cfg.readEntryCrypt( username); cfg.setGroup(QString::number(i)); cfg.writeEntry("RemotePath", remoteServerStr); cfg.writeEntry("ServerName", servername); cfg.writeEntry("Username", username); @@ -1521,28 +1527,28 @@ void OpieFtp::NewServer() { 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->setCurrentItem( serverListView->count()); } } void OpieFtp::serverListClicked( const QString &item) { if(item.isEmpty()) return; Config cfg("opieftp"); - odebug << "highltined "+item << oendl; +// odebug << "highltined "+item << oendl; 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) serverComboSelected(i-1); } } void OpieFtp::timerOut() { } diff --git a/noncore/net/opieftp/opieftp.h b/noncore/net/opieftp/opieftp.h index 076a906..ba2ddf9 100644 --- a/noncore/net/opieftp/opieftp.h +++ b/noncore/net/opieftp/opieftp.h @@ -34,55 +34,57 @@ class QWidget; class QToolBar; class QMenuBar; class QPopupMenu; class QFile; class QLineEdit; class QPushButton; class QToolButton; class QStringList; class QListBox; class QTimer; class OpieFtp : public QMainWindow { Q_OBJECT public: + static QString appName() { return QString::fromLatin1("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; QString filterStr; QListViewItem * item; - QPushButton *connectServerBtn, *newServerButton;// + QPushButton *connectServerBtn, *newServerButton; QToolButton *cdUpButton, *homeButton, *docButton; bool b; + int currentServerConfig; protected slots: + void initializeGui(); void timerOut(); void upDir(); void homeButtonPushed(); void docButtonPushed(); void doAbout(); void serverComboEdited(const QString & ); void UsernameComboBoxEdited(const QString & ); void PasswordEditEdited(const QString & ); void showLocalMenu( QListViewItem *); void showRemoteMenu( QListViewItem *); void doLocalCd(); void doRemoteCd(); void localUpload(); void remoteDownload(); diff --git a/noncore/net/opieftp/opieftp.pro b/noncore/net/opieftp/opieftp.pro index fe69e15..835b6e0 100644 --- a/noncore/net/opieftp/opieftp.pro +++ b/noncore/net/opieftp/opieftp.pro @@ -1,9 +1,10 @@ -CONFIG += qt quick-app +TEMPLATE = app +CONFIG += qte quick-app warn_on HEADERS = opieftp.h inputDialog.h SOURCES = opieftp.cpp inputDialog.cpp main.cpp TARGET = opieftp INCLUDEPATH += $(OPIEDIR)/include DEPENDPATH += $(OPIEDIR)/include LIBS += -lqpe -lopiecore2 -lftplib include( $(OPIEDIR)/include.pro ) |