summaryrefslogtreecommitdiff
path: root/noncore/net/opieftp/opieftp.cpp
authorllornkcor <llornkcor>2005-01-03 03:09:51 (UTC)
committer llornkcor <llornkcor>2005-01-03 03:09:51 (UTC)
commit0b3bbec6703c021a188c865e822f536bfa3045fc (patch) (side-by-side diff)
tree3458531d039a111ba39ef2e0bed2e5bbbfedad46 /noncore/net/opieftp/opieftp.cpp
parent8ce8566bf038f0293a0690fce44df2bba9c4eb52 (diff)
downloadopie-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
Diffstat (limited to 'noncore/net/opieftp/opieftp.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/net/opieftp/opieftp.cpp62
1 files changed, 34 insertions, 28 deletions
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
@@ -17,18 +17,19 @@ 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>
@@ -46,30 +47,35 @@ using namespace Opie::Core;
#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 );
@@ -91,15 +97,13 @@ OpieFtp::OpieFtp( QWidget* parent, const char* name, WFlags fl)
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);
@@ -313,33 +317,35 @@ OpieFtp::OpieFtp( QWidget* parent, const char* name, WFlags fl)
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()
{
}
@@ -532,13 +538,13 @@ void OpieFtp::localUpload()
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);
@@ -593,13 +599,13 @@ void OpieFtp::remoteDownload()
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);
@@ -772,14 +778,14 @@ bool OpieFtp::populateRemoteView( )
}
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)
{
@@ -1231,13 +1237,13 @@ void OpieFtp::readConfig()
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);
@@ -1262,13 +1268,13 @@ void OpieFtp::writeConfig()
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());
@@ -1281,13 +1287,13 @@ void OpieFtp::writeConfig()
cfg.writeEntry("numberOfEntries", QString::number(numberOfEntries + 1 ));
}
}
void OpieFtp::clearCombos() {
- odebug << "clearing" << oendl;
+// odebug << "clearing" << oendl;
ServerComboBox->clear();
UsernameComboBox->clear();
PasswordEdit->clear();
serverListView->clear();
}
@@ -1301,24 +1307,24 @@ void OpieFtp::fillCombos()
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);
@@ -1331,13 +1337,13 @@ void OpieFtp::fillCombos()
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");
@@ -1346,13 +1352,13 @@ void OpieFtp::serverComboSelected(int index)
// 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);
@@ -1362,13 +1368,13 @@ void OpieFtp::serverComboSelected(int index)
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");
@@ -1407,13 +1413,13 @@ void OpieFtp::deleteServer()
// 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
@@ -1531,13 +1537,13 @@ void OpieFtp::NewServer() {
}
}
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);
}