summaryrefslogtreecommitdiff
path: root/noncore/net/opieftp/opieftp.cpp
Side-by-side diff
Diffstat (limited to 'noncore/net/opieftp/opieftp.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/net/opieftp/opieftp.cpp77
1 files changed, 40 insertions, 37 deletions
diff --git a/noncore/net/opieftp/opieftp.cpp b/noncore/net/opieftp/opieftp.cpp
index 4c39569..fe96103 100644
--- a/noncore/net/opieftp/opieftp.cpp
+++ b/noncore/net/opieftp/opieftp.cpp
@@ -1,88 +1,91 @@
/***************************************************************************
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/ftplib.h"
}
#include "inputDialog.h"
-#include <qmenubar.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 <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 )
{
- qDebug("OpieFtp constructor");
+ 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);
connect( qApp,SIGNAL( aboutToQuit()),SLOT( cleanUp()) );
QMenuBar *menuBar = new QMenuBar(this);
// QToolBar *menuBar = new QToolBar(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 );
@@ -313,49 +316,49 @@ OpieFtp::OpieFtp( QWidget* parent, const char* name, WFlags fl)
currentPathCombo ->setFixedWidth(220);
currentPathCombo->setEditable(TRUE);
currentPathCombo->lineEdit()->setText( currentDir.canonicalPath());
#if 0
connect( currentPathCombo, SIGNAL( activated(const QString&) ),
this, SLOT( currentPathComboActivated(const QString&) ) );
connect( currentPathCombo->lineEdit(),SIGNAL(returnPressed()),
this,SLOT(currentPathComboChanged()));
#endif
ProgressBar = new QProgressBar( view, "ProgressBar" );
layout->addMultiCellWidget( ProgressBar, 4, 4, 0, 4);
ProgressBar->setMaximumHeight(10);
filterStr="*";
b=FALSE;
#if 0
populateLocalView();
#endif
readConfig();
// ServerComboBox->setCurrentItem(currentServerConfig);
TabWidget->setCurrentPage(2);
- qDebug("Constructor done");
+ odebug << "Constructor done" << oendl;
}
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);
}
@@ -384,49 +387,49 @@ void OpieFtp::tabChanged(QWidget *)
}
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 & )
{
// if( ServerComboBox->text(currentServerConfig) != edit /*edit.isEmpty() */) {
-// qDebug("ServerComboEdited");
+// odebug << "ServerComboEdited" << oendl;
// // currentServerConfig = -1;
// }
}
void OpieFtp::UsernameComboBoxEdited(const QString &) {
// currentServerConfig = -1;
}
void OpieFtp::PasswordEditEdited(const QString & ) {
// currentServerConfig = -1;
}
void OpieFtp::connectorBtnToggled(bool On)
{
if(On) {
connector();
} else {
disConnector();
}
}
void OpieFtp::connector()
{
@@ -509,49 +512,49 @@ void OpieFtp::disConnector()
setCaption("OpieFtp");
}
void OpieFtp::localUpload()
{
int fsz;
// QCopEnvelope ( "QPE/System", "busy()" );
// qApp->processEvents();
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);
- qDebug("Put: %s, %s",localFile.latin1(),remoteFile.latin1());
+ 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 ) {
Local_View->clearSelection();
}
Local_View->clearFocus();
TabWidget->setCurrentPage(1);
remoteDirList( (const QString &)currentRemoteDir); //this also calls populate
// QCopEnvelope ( "QPE/System", "notBusy()" );
}
@@ -570,271 +573,271 @@ void OpieFtp::remoteDownload()
// QCopEnvelope ( "QPE/System", "busy()" );
QList<QListViewItem> * getSelectedItems( QListView * Remote_View );
QListViewItemIterator it( Remote_View );
for ( ; it.current(); ++it ) {
if ( it.current()->isSelected() ) {
QString strItem = it.current()->text(0);
// strItem=strItem.right(strItem.length()-1);
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);
- qDebug("Get: %s, %s",localFile.latin1(),remoteFile.latin1());
+ 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();
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";
-// qDebug("Listing remote dir "+tmp);
+// odebug << "Listing remote dir "+tmp << oendl;
// QCopEnvelope ( "QPE/System", "busy()" );
if (!FtpDir( tmp.latin1(), dir.latin1(), conn) ) {
QString msg;
msg.sprintf(tr("Unable to list the directory\n")+dir+"\n%s",FtpLastResponse(conn) );
msg.replace(QRegExp(":"),"\n");
QMessageBox::message(tr("Note"),msg);
return false;
}
populateRemoteView() ;
// QCopEnvelope ( "QPE/System", "notBusy()" );
return true;
}
bool OpieFtp::remoteChDir(const QString &dir)
{
// QCopEnvelope ( "QPE/System", "busy()" );
if (!FtpChdir( dir.latin1(), conn )) {
QString msg;
msg.sprintf(tr("Unable to change directories\n")+dir+"\n%s",FtpLastResponse(conn));
msg.replace(QRegExp(":"),"\n");
QMessageBox::message(tr("Note"),msg);
-// qDebug(msg);
+// odebug << msg << oendl;
// 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);
+ 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 {
- qDebug("Not a dir: "+currentDir.canonicalPath()+fileL);
+ 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;
- qDebug( fileL);
+ 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" );
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
if(pm.isNull())
pm = unknownXpm;
}
}
if( fileL.find("->",0,TRUE) != -1) {
// overlay link image
pm= Resource::loadPixmap( "folder" );
QPixmap lnk = Resource::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);
}
bool OpieFtp::populateRemoteView( )
{
-// qDebug("populate remoteview");
+// 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" ));
// if(itemDir)
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
- qDebug("temp file not opened successfully "+sfile);
+ 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);
-// qDebug(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);
-// qDebug(msg);
+// odebug << msg << oendl;
}
currentRemoteDir=path;
} else {
if(strItem.find("->",0,TRUE) != -1) { //symlink on some servers
strItem=strItem.right( strItem.length() - strItem.find("->",0,TRUE) - 2 );
strItem = strItem.stripWhiteSpace();
currentRemoteDir = strItem;
if( !remoteChDir( (const QString &)strItem)) {
currentRemoteDir = oldRemoteCurrentDir;
strItem="";
-// qDebug("RemoteCurrentDir1 "+oldRemoteCurrentDir);
+// odebug << "RemoteCurrentDir1 "+oldRemoteCurrentDir << oendl;
}
} else if(strItem.find("/",0,TRUE) != -1) { // this is a directory
if( !remoteChDir( (const QString &)currentRemoteDir + strItem)) {
currentRemoteDir = oldRemoteCurrentDir;
strItem="";
-// qDebug("RemoteCurrentDir1 "+oldRemoteCurrentDir);
+// odebug << "RemoteCurrentDir1 "+oldRemoteCurrentDir << oendl;
} 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) {
@@ -845,49 +848,49 @@ void OpieFtp::localListClicked(QListViewItem *selectedItem)
// 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);
+ // odebug << "upload "+strItem << oendl;
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);
@@ -1149,270 +1152,270 @@ void OpieFtp::fillCombo(const QString &currentPath) {
localDirPathStringList.prepend(currentPath );
currentPathCombo->insertStringList( localDirPathStringList,-1);
}
currentPathCombo->lineEdit()->setText(currentPath);
if( remoteDirPathStringList.grep(currentPath,TRUE).isEmpty() ) {
currentPathCombo->clear();
remoteDirPathStringList.prepend(currentPath );
currentPathCombo->insertStringList( remoteDirPathStringList,-1);
}
}
void OpieFtp::fillRemoteCombo(const QString &currentPath) {
currentPathCombo->lineEdit()->setText(currentPath);
if( remoteDirPathStringList.grep(currentPath,TRUE).isEmpty() ) {
currentPathCombo->clear();
remoteDirPathStringList.prepend(currentPath );
currentPathCombo->insertStringList( remoteDirPathStringList,-1);
}
}
void OpieFtp::currentPathComboChanged()
{
QString oldRemoteCurrentDir = currentRemoteDir;
-// qDebug("oldRemoteCurrentDir "+oldRemoteCurrentDir);
+// odebug << "oldRemoteCurrentDir "+oldRemoteCurrentDir << oendl;
if (TabWidget->currentPageIndex() == 0) {
if(QDir( currentPathCombo->lineEdit()->text()).exists()) {
currentDir.setPath( currentPathCombo->lineEdit()->text() );
populateLocalView();
} else {
QMessageBox::message(tr("Note"),tr("That directory does not exist"));
}
}
if (TabWidget->currentPageIndex() == 1) {
currentRemoteDir = currentPathCombo->lineEdit()->text();
if(currentRemoteDir.right(1) !="/") {
currentRemoteDir = currentRemoteDir +"/";
currentPathCombo->lineEdit()->setText( currentRemoteDir );
}
if( !remoteChDir( (const QString &)currentRemoteDir) ) {
currentRemoteDir = oldRemoteCurrentDir;
currentPathCombo->lineEdit()->setText( currentRemoteDir );
}
remoteDirList( (const QString &)currentRemoteDir);
}
}
void OpieFtp::switchToLocalTab()
{
TabWidget->setCurrentPage(0);
}
void OpieFtp::switchToRemoteTab()
{
TabWidget->setCurrentPage(1);
}
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);
+// odebug << "Reading " << currentServerConfig << "" << oendl;
serverComboSelected( currentServerConfig-1);
}
void OpieFtp::writeConfig()
{
- qDebug("write config");
+ 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;
- qDebug("setting currentserverconfig to %d", currentServerConfig);
+ 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() {
- qDebug("clearing");
+ odebug << "clearing" << oendl;
ServerComboBox->clear();
UsernameComboBox->clear();
PasswordEdit->clear();
serverListView->clear();
}
void OpieFtp::fillCombos()
{
clearCombos();
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);
- qDebug(temp);
+ odebug << temp << oendl;
cfg.setGroup("Server");
remoteServerStr = cfg.readEntry( temp,"");
- qDebug( remoteServerStr);
+ 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);
- qDebug( "remote server string "+remoteServerStr);
+ 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)
{
currentServerConfig = index+1;
- qDebug("server combo selected %d", index+1);
+ odebug << "server combo selected " << index+1 << "" << oendl;
QString username, remoteServerStr, remotePathStr, password, port, temp;
// remoteServerStr = ServerComboBox->text(index);
Config cfg("opieftp");
cfg.setGroup("Server");
// int numberOfEntries = cfg.readNumEntry("numberOfEntries",0);
temp.setNum(index+1);
remoteServerStr = cfg.readEntry( temp,"");
- qDebug("Group" +temp);
+ odebug << "Group" +temp << oendl;
cfg.setGroup(temp);
-// qDebug(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");
UsernameComboBox->lineEdit()->setText(username);
- qDebug(username);
-// qDebug("Password is "+cfg.readEntryCrypt(username, "me@opieftp.org"));
+ 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);
fuckeduphack = TRUE;
serverListView->setCurrentItem( index);
fuckeduphack=FALSE;
- qDebug("server list set selected %d",index);
+ odebug << "server list set selected " << index << "" << oendl;
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 &&
// username.find( cfg.readEntry("Username")) != -1) {
serverListView->removeItem(i);
- qDebug("OK DELETE "+tempname);
+ 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);
cfg.writeEntryCrypt( username, password);
}
cfg.setGroup("Server");
cfg.writeEntry("numberOfEntries", QString::number(numberOfEntries - 1 ));
}
}
cfg.setGroup(QString::number(numberOfEntries));
@@ -1425,57 +1428,57 @@ void OpieFtp::deleteServer()
currentServerConfig=currentServerConfig-1;
fillCombos();
update();
}
void OpieFtp::upDir()
{
if (TabWidget->currentPageIndex() == 0) {
QString current = currentDir.canonicalPath();
QDir dir(current);
dir.cdUp();
current = dir.canonicalPath();
chdir( current.latin1() );
currentDir.cd( current, TRUE);
populateLocalView();
update();
} else {
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);
-// qDebug(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);
-// qDebug(msg);
+// odebug << msg << oendl;
}
currentRemoteDir=path;
remoteDirList( (const QString &)currentRemoteDir); //this also calls populate
if(currentRemoteDir.right(1) !="/")
currentRemoteDir +="/";
currentPathCombo->lineEdit()->setText( currentRemoteDir);
fillRemoteCombo( (const QString &)currentRemoteDir);
}
}
void OpieFtp::docButtonPushed() {
QString current = QPEApplication::documentDir();
chdir( current.latin1() );
currentDir.cd( current, TRUE);
populateLocalView();
update();
}
void OpieFtp::homeButtonPushed() {
QString current = QDir::homeDirPath();
chdir( current.latin1() );
currentDir.cd( current, TRUE);
@@ -1494,36 +1497,36 @@ void OpieFtp::doAbout() {
void OpieFtp::NewServer() {
InputDialog *fileDlg;
fileDlg = new InputDialog(this,tr("New Server name"),TRUE, 0);
fileDlg->exec();
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->setCurrentItem( serverListView->count());
}
}
void OpieFtp::serverListClicked( const QString &item) {
if(item.isEmpty()) return;
Config cfg("opieftp");
- qDebug("highltined "+item);
+ 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() {
}