author | drw <drw> | 2005-05-04 23:07:10 (UTC) |
---|---|---|
committer | drw <drw> | 2005-05-04 23:07:10 (UTC) |
commit | d89cbf4ba511beaf228ce87d4e21a2a6a49767f2 (patch) (side-by-side diff) | |
tree | d7c1518bfa0550b99d73fe85630cebe351155a37 | |
parent | 5db2256e7e342f290e17096cf70b8b318bfcd987 (diff) | |
download | opie-d89cbf4ba511beaf228ce87d4e21a2a6a49767f2.zip opie-d89cbf4ba511beaf228ce87d4e21a2a6a49767f2.tar.gz opie-d89cbf4ba511beaf228ce87d4e21a2a6a49767f2.tar.bz2 |
Resource -> OResource
-rw-r--r-- | noncore/net/opieftp/opie-ftp.control | 2 | ||||
-rw-r--r-- | noncore/net/opieftp/opieftp.cpp | 69 |
2 files changed, 31 insertions, 40 deletions
diff --git a/noncore/net/opieftp/opie-ftp.control b/noncore/net/opieftp/opie-ftp.control index 32cc7a6..82f774f 100644 --- a/noncore/net/opieftp/opie-ftp.control +++ b/noncore/net/opieftp/opie-ftp.control @@ -1,11 +1,11 @@ Package: opie-ftp Files: plugins/application/libopieftp.so* bin/opieftp pics/opieftp apps/Applications/opieftp.desktop Priority: optional Section: opie/applications Maintainer: L.J. Potter <ljp@llornkcor.com> Architecture: arm -Depends: task-opie-minimal, ftplib +Depends: task-opie-minimal, ftplib, libopiecore2 Replaces: opieftp Description: Opie-Ftp The ftp client for the Opie environment. Version: $QPE_VERSION$EXTRAVERSION diff --git a/noncore/net/opieftp/opieftp.cpp b/noncore/net/opieftp/opieftp.cpp index 4f0ca29..14fd859 100644 --- a/noncore/net/opieftp/opieftp.cpp +++ b/noncore/net/opieftp/opieftp.cpp @@ -1,197 +1,189 @@ /*************************************************************************** opieftp.cpp ------------------- ** Created: Sat Mar 9 23:33:09 2002 copyright : (C) 2002 by ljp 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. * ***************************************************************************/ //#define DEVELOPERS_VERSION #include "opieftp.h" extern "C" { #include <ftplib.h> } #include "inputDialog.h" /* OPIE */ //#include <opie2/odebug.h> //using namespace Opie::Core; -#include <qpe/qpeapplication.h> -#include <qpe/resource.h> +#include <opie2/oresource.h> + +#include <qpe/applnk.h> #include <qpe/config.h> #include <qpe/mimetype.h> +#include <qpe/qpeapplication.h> +#include <qpe/qpemenubar.h> -#include <qtextstream.h> -#include <qpushbutton.h> -#include <qtoolbutton.h> +#include <qbitmap.h> #include <qcombobox.h> -#include <qlistview.h> #include <qlabel.h> +#include <qlayout.h> +#include <qlistview.h> +#include <qmenubar.h> +#include <qmessagebox.h> #include <qprogressbar.h> +#include <qpushbutton.h> #include <qspinbox.h> #include <qtabwidget.h> -#include <qlayout.h> -#include <qmessagebox.h> -#include <qmenubar.h> -#include <qpe/qpemenubar.h> +#include <qtextstream.h> +#include <qtoolbutton.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* , const char*, WFlags) : QMainWindow( ) { 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); + unknownXpm = Opie::Core::OResource::loadPixmap( "UnknownDocument", Opie::Core::OResource::SmallIcon ); 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() )); 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() )); localMenu->insertItem( tr( "Make Directory" ), this, SLOT( localMakDir() )); 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); - + bool useBigPix = qApp->desktop()->size().width() > 330; cdUpButton = new QToolButton( view,"cdUpButton"); - cdUpButton->setPixmap(Resource::loadPixmap("up")); - cdUpButton ->setFixedSize( QSize( 20, 20 ) ); + cdUpButton->setUsesBigPixmap( useBigPix ); + cdUpButton->setPixmap( Opie::Core::OResource::loadPixmap( "up", Opie::Core::OResource::SmallIcon ) ); + cdUpButton->setFixedSize( AppLnk::smallIconSize(), AppLnk::smallIconSize() ); connect( cdUpButton ,SIGNAL(released()),this,SLOT( upDir()) ); 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->setPixmap( Resource::loadPixmap("home")); - homeButton->setFixedSize( QSize( 20, 20 ) ); + homeButton->setUsesBigPixmap( useBigPix ); + homeButton->setPixmap( Opie::Core::OResource::loadPixmap( "home", Opie::Core::OResource::SmallIcon ) ); + homeButton->setFixedSize( AppLnk::smallIconSize(), AppLnk::smallIconSize() ); connect(homeButton,SIGNAL(released()),this,SLOT(homeButtonPushed()) ); 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); QPEApplication::setStylusOperation( Local_View->viewport(),QPEApplication::RightOnHold); tabLayout->addWidget( Local_View, 0, 0 ); connect( Local_View, SIGNAL( clicked(QListViewItem*)), this,SLOT( localListClicked(QListViewItem*)) ); // connect( Local_View, SIGNAL( doubleClicked(QListViewItem*)), // this,SLOT( localListClicked(QListViewItem*)) ); connect( Local_View, SIGNAL( mouseButtonPressed(int,QListViewItem*,const QPoint&,int)), this,SLOT( ListPressed(int,QListViewItem*,const QPoint&,int)) ); TabWidget->insertTab( tab, tr( "Local" ) ); tab_2 = new QWidget( TabWidget, "tab_2" ); @@ -312,65 +304,65 @@ void OpieFtp::initializeGui() { 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->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); filterStr="*"; b=FALSE; populateLocalView(); readConfig(); // ServerComboBox->setCurrentItem(currentServerConfig); TabWidget->setCurrentPage(2); - qDebug("XXXXXXXXXXXX Constructor done"); +// 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); if(file.exists()) file.remove(); Config cfg("opieftp"); cfg.setGroup("Server"); cfg.writeEntry("currentServer", currentServerConfig); exit(0); } 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); @@ -670,143 +662,142 @@ void OpieFtp::populateLocalView() 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; 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; 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; } } 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" ); + pm = Opie::Core::OResource::loadPixmap( "lockedfolder", Opie::Core::OResource::SmallIcon ); else - pm= Resource::loadPixmap( "folder" ); + pm = Opie::Core::OResource::loadPixmap( "folder", Opie::Core::OResource::SmallIcon ); item->setPixmap( 0,pm ); } else { if( !fi->isReadable() ) - pm = Resource::loadPixmap( "locked" ); + pm = Opie::Core::OResource::loadPixmap( "locked", Opie::Core::OResource::SmallIcon ); 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" ); + pm = Opie::Core::OResource::loadPixmap( "folder", Opie::Core::OResource::SmallIcon ); + QPixmap lnk = Opie::Core::OResource::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.canonicalPath()); } 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; 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") 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" )); + item->setPixmap( 0, Opie::Core::OResource::loadPixmap( "folder", Opie::Core::OResource::SmallIcon )); // if(itemDir) item->moveItem(itemDir); itemDir=item; } else { QListViewItem * item = new QListViewItem( Remote_View, fileL, fileDate, fileS,"f"); - item->setPixmap( 0, Resource::loadPixmap( "fileopen" )); + item->setPixmap( 0, Opie::Core::OResource::loadPixmap( "fileopen", Opie::Core::OResource::SmallIcon )); // if(itemFile) item->moveItem(itemDir); item->moveItem(itemFile); itemFile=item; } } QListViewItem * item1 = new QListViewItem( Remote_View, "../"); - item1->setPixmap( 0, Resource::loadPixmap( "folder" )); + item1->setPixmap( 0, Opie::Core::OResource::loadPixmap( "folder", Opie::Core::OResource::SmallIcon )); file.close(); if( file.exists()) file. remove(); } // 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)); msg.replace(QRegExp(":"),"\n"); QMessageBox::message(tr("Note"),msg); // odebug << msg << oendl; } char path[256]; if( FtpPwd( path,sizeof(path),conn) == 0) { //this is easier than fudging the string QString msg; msg.sprintf(tr("Unable to get working dir\n")+"%s",FtpLastResponse(conn)); msg.replace(QRegExp(":"),"\n"); QMessageBox::message(tr("Note"),msg); // odebug << msg << oendl; |