-rw-r--r-- | noncore/apps/opie-console/filetransfer.cpp | 3 | ||||
-rw-r--r-- | noncore/apps/opie-console/mainwindow.cpp | 2 | ||||
-rw-r--r-- | noncore/apps/opie-console/metafactory.cpp | 9 | ||||
-rw-r--r-- | noncore/apps/opie-console/metafactory.h | 1 | ||||
-rw-r--r-- | noncore/apps/opie-console/test/senderui.cpp | 2 | ||||
-rw-r--r-- | noncore/apps/opie-console/transferdialog.cpp | 70 | ||||
-rw-r--r-- | noncore/apps/opie-console/transferdialog.h | 8 |
7 files changed, 60 insertions, 35 deletions
diff --git a/noncore/apps/opie-console/filetransfer.cpp b/noncore/apps/opie-console/filetransfer.cpp index b39dc95..8e86ebb 100644 --- a/noncore/apps/opie-console/filetransfer.cpp +++ b/noncore/apps/opie-console/filetransfer.cpp @@ -2,249 +2,252 @@ #include <stdlib.h> #include <errno.h> #include <fcntl.h> #include <unistd.h> #include <qcstring.h> #include <qsocketnotifier.h> #include <opie/oprocess.h> #include "procctl.h" #include "filetransfer.h" FileTransfer::FileTransfer( Type t, IOLayer* lay ) : FileTransferLayer( lay ), m_type( t ) { signal(SIGPIPE, SIG_IGN ); m_not = 0l; m_proc = 0l; } FileTransfer::~FileTransfer() { } /** * now we will send the file. * * we request an fd. The IOLayer should be closed * then we will setup a pipe for progress communication * then we will dup2 the m_fd in the forked process * to do direct IO from and to the fd */ void FileTransfer::sendFile( const QString& file ) { m_prog =-1; m_fd = layer()->rawIO(); // // m_fd = ::open("/dev/ttyS0", O_RDWR); m_file = file; if ( pipe( m_comm ) < 0 ) m_comm[0] = m_comm[1] = 0; if ( pipe( m_info ) < 0 ) m_info[0] = m_info[1] = 0; m_pid = fork(); switch( m_pid ) { case -1: emit error( StartError, tr("Was not able to fork") ); break; case 0:{ setupChild(); qWarning("output:"+file ); /* exec */ char* verbose = "-vv"; char* binray = "-b"; char* typus; switch(m_type ) { case SZ: typus = ""; break; case SX: typus = "-X"; break; case SY: typus = "--ymodem"; break; } /* we should never return from here */ execlp("sz", "sz", verbose, binray, file.latin1(), typus, NULL ); /* communication for error!*/ char resultByte =1; if (m_info[1] ) write(m_info[1], &resultByte, 1 ); _exit( -1 ); break; } default:{ if ( m_info[1] ) close( m_info[1] ); if ( m_info[0] ) for (;;) { char resultByte; int len; len = read(m_info[0], &resultByte, 1 ); /* len == 1 start up failed */ if ( len == 1 ) { emit error( StartError, tr("Could not start") ); return; } if ( len == -1 ) if ( (errno == ECHILD ) || (errno == EINTR ) ) continue; // len == 0 or something like this break; } if ( m_info[0] ) close( m_info[0] ); /* replace by QSocketNotifier!!! */ m_not = new QSocketNotifier(m_comm[0], QSocketNotifier::Read ); connect(m_not, SIGNAL(activated(int) ), this, SLOT(slotRead() ) ); if ( pipe(m_term) < 0 ) m_term[0] = m_term[1] = 0; ProcCtl::self()->add(m_pid, m_term[1] ); m_proc = new QSocketNotifier(m_term[0], QSocketNotifier::Read ); connect(m_proc, SIGNAL(activated(int) ), this, SLOT(slotExec() ) ); } break; } } /* * let's call the one with the filename */ void FileTransfer::sendFile( const QFile& file ) { sendFile( file.name() ); } /* * setting up communication * between parent child and ioLayer */ void FileTransfer::setupChild() { /* * we do not want to read from our * information channel */ if (m_info[0] ) close(m_info[0] ); /* * FD_CLOEXEC will close the * fd on successfull exec */ if (m_info[1] ) fcntl(m_info[1], F_SETFD, FD_CLOEXEC ); if (m_comm[0] ) close( m_comm[0] ); /* * now set the communication * m_fd STDIN_FILENO * STDOUT_FILENO * STDERR_FILENO */ dup2( m_fd, STDIN_FILENO ); dup2( m_fd, STDOUT_FILENO ); dup2( m_comm[1], STDERR_FILENO ); } /* * read from the stderr of the child * process */ void FileTransfer::slotRead() { QByteArray ar(4096); int len = read(m_comm[0], ar.data(), 4096 ); qWarning("slot read %d", len); for (int i = 0; i < len; i++ ) { // printf("%c", ar[i] ); } ar.resize( len ); QString str( ar ); qWarning(str.simplifyWhiteSpace() ); QStringList lis = QStringList::split(' ', str ); /* * Transfer finished.. either complete or incomplete */ if ( lis[0].simplifyWhiteSpace() == "Transfer" ) { qWarning("sent!!!!"); emit sent(); return; } /* * do progress reading */ slotProgress( lis ); } /* * find the progress */ void FileTransfer::slotProgress( const QStringList& list ) { + if ( m_type != SZ ) + return; bool complete = true; int min, sec; int bps; unsigned long sent, total; min = sec = bps = -1; sent = total = 0; // Data looks like this // 0 1 2 3 4 5 // Bytes Sent 65536/11534336 BPS:7784 ETA 24:33 QStringList progi = QStringList::split('/', list[2].simplifyWhiteSpace() ); sent = progi[0].toULong(&complete ); if (!complete ) return; total = progi[1].toULong(&complete ); if (!complete || total == 0) { return; } qWarning("%s, %d, %d", progi.join("/").latin1(), sent, total ); double pro = (double)sent/total; int prog = pro * 100; // speed progi = QStringList::split(':', list[3].simplifyWhiteSpace() ); bps = progi[1].toInt(); // time progi = QStringList::split(':', list[5].simplifyWhiteSpace() ); min = progi[0].toInt(); sec = progi[1].toInt(); if ( prog > m_prog ) { m_prog = prog; emit progress(m_file, m_prog, bps, -1, min , sec ); } } void FileTransfer::cancel() { ::kill(m_pid,9 ); delete m_not; } void FileTransfer::slotExec() { qWarning("exited!"); char buf[2]; ::read(m_term[0], buf, 1 ); delete m_proc; delete m_not; + m_proc = m_not = 0l; close( m_term[0] ); close( m_term[1] ); close( m_comm[0] ); close( m_comm[1] ); emit sent(); } diff --git a/noncore/apps/opie-console/mainwindow.cpp b/noncore/apps/opie-console/mainwindow.cpp index fbeaa74..88727e4 100644 --- a/noncore/apps/opie-console/mainwindow.cpp +++ b/noncore/apps/opie-console/mainwindow.cpp @@ -37,197 +37,199 @@ void MainWindow::initUI() { m_sessionsPop= new QPopupMenu( this ); m_settings = new QPopupMenu( this ); /* * new Action for new sessions */ QAction* a = new QAction(); a->setText( tr("New Connection") ); a->addTo( m_console ); connect(a, SIGNAL(activated() ), this, SLOT(slotNew() ) ); /* * connect action */ m_connect = new QAction(); m_connect->setText( tr("Connect") ); m_connect->addTo( m_console ); connect(m_connect, SIGNAL(activated() ), this, SLOT(slotConnect() ) ); /* * disconnect action */ m_disconnect = new QAction(); m_disconnect->setText( tr("Disconnect") ); m_disconnect->addTo( m_console ); connect(m_disconnect, SIGNAL(activated() ), this, SLOT(slotDisconnect() ) ); m_transfer = new QAction(); m_transfer->setText( tr("Transfer file...") ); m_transfer->addTo( m_console ); connect(m_transfer, SIGNAL(activated() ), this, SLOT(slotTransfer() ) ); /* * terminate action */ m_terminate = new QAction(); m_terminate->setText( tr("Terminate") ); m_terminate->addTo( m_console ); connect(m_terminate, SIGNAL(activated() ), this, SLOT(slotTerminate() ) ); a = new QAction(); a->setText( tr("Close Window") ); a->addTo( m_console ); connect(a, SIGNAL(activated() ), this, SLOT(slotClose() ) ); /* * the settings action */ m_setProfiles = new QAction(); m_setProfiles->setText( tr("Configure Profiles") ); m_setProfiles->addTo( m_settings ); connect( m_setProfiles, SIGNAL(activated() ), this, SLOT(slotConfigure() ) ); /* insert the submenu */ m_console->insertItem(tr("New from Profile"), m_sessionsPop, -1, 0); /* insert the connection menu */ m_bar->insertItem( tr("Connection"), m_console ); /* the settings menu */ m_bar->insertItem( tr("Settings"), m_settings ); /* * connect to the menu activation */ connect( m_sessionsPop, SIGNAL(activated( int ) ), this, SLOT(slotProfile( int ) ) ); m_consoleWindow = new TabWidget( this, "blah"); setCentralWidget( m_consoleWindow ); } ProfileManager* MainWindow::manager() { return m_manager; } TabWidget* MainWindow::tabWidget() { return m_consoleWindow; } void MainWindow::populateProfiles() { m_sessionsPop->clear(); Profile::ValueList list = manager()->all(); for (Profile::ValueList::Iterator it = list.begin(); it != list.end(); ++it ) { m_sessionsPop->insertItem( (*it).name() ); } } MainWindow::~MainWindow() { delete m_factory; manager()->save(); } MetaFactory* MainWindow::factory() { return m_factory; } Session* MainWindow::currentSession() { return m_curSession; } QList<Session> MainWindow::sessions() { return m_sessions; } void MainWindow::slotNew() { qWarning("New Connection"); ProfileEditorDialog dlg(factory() ); int ret = dlg.exec(); if ( ret == QDialog::Accepted ) { create( dlg.profile() ); } } void MainWindow::slotConnect() { if ( currentSession() ) currentSession()->layer()->open(); } void MainWindow::slotDisconnect() { if ( currentSession() ) currentSession()->layer()->close(); } void MainWindow::slotTerminate() { if ( currentSession() ) currentSession()->layer()->close(); slotClose(); /* FIXME move to the next session */ } void MainWindow::slotConfigure() { qWarning("configure"); ConfigDialog conf( manager()->all(), factory() ); conf.showMaximized(); int ret = conf.exec(); if ( QDialog::Accepted == ret ) { qWarning("conf %d", conf.list().count() ); manager()->setProfiles( conf.list() ); populateProfiles(); } } /* * we will remove * this window from the tabwidget * remove it from the list * delete it * and set the currentSession() */ void MainWindow::slotClose() { qWarning("close"); if (!currentSession() ) return; tabWidget()->remove( currentSession() ); /*it's autodelete */ m_sessions.remove( m_curSession ); m_curSession = m_sessions.first(); tabWidget()->setCurrent( m_curSession ); } /* * We will get the name * Then the profile * and then we will make a profile */ void MainWindow::slotProfile( int id) { Profile prof = manager()->profile( m_sessionsPop->text( id) ); create( prof ); } void MainWindow::create( const Profile& prof ) { Session *ses = manager()->fromProfile( prof, tabWidget() ); m_sessions.append( ses ); tabWidget()->add( ses ); m_curSession = ses; } void MainWindow::slotTransfer() { + if ( currentSession() ) { TransferDialog dlg(this); dlg.showMaximized(); dlg.exec(); + } } diff --git a/noncore/apps/opie-console/metafactory.cpp b/noncore/apps/opie-console/metafactory.cpp index 2b672cf..901f29f 100644 --- a/noncore/apps/opie-console/metafactory.cpp +++ b/noncore/apps/opie-console/metafactory.cpp @@ -1,139 +1,148 @@ #include <qpe/config.h> #include "metafactory.h" MetaFactory::MetaFactory() { } MetaFactory::~MetaFactory() { } void MetaFactory::addConnectionWidgetFactory( const QCString& name, const QString& str, configWidget wid) { m_strings.insert( str, name ); m_conFact.insert( str, wid ); } void MetaFactory::addTerminalWidgetFactory( const QCString& name, const QString& str, configWidget wid ) { m_strings.insert( str, name ); m_termFact.insert( str, wid ); } void MetaFactory::addIOLayerFactory( const QCString& name, const QString& str, iolayer lay) { m_strings.insert( str, name ); m_layerFact.insert( str, lay ); } void MetaFactory::addFileTransferLayer( const QCString& name, const QString& str, filelayer lay) { m_strings.insert(str, name ); m_fileFact.insert( str, lay ); } void MetaFactory::addEmulationLayer( const QCString& name, const QString& str, emulationLayer em) { m_strings.insert(str, name ); m_emu.insert( str, em ); } QStringList MetaFactory::ioLayers()const { QStringList list; QMap<QString, iolayer>::ConstIterator it; for (it = m_layerFact.begin(); it != m_layerFact.end(); ++it ) { list << it.key(); } return list; } QStringList MetaFactory::connectionWidgets()const { QStringList list; QMap<QString, configWidget>::ConstIterator it; for ( it = m_conFact.begin(); it != m_conFact.end(); ++it ) { list << it.key(); } return list; } QStringList MetaFactory::terminalWidgets()const { QStringList list; QMap<QString, configWidget>::ConstIterator it; for ( it = m_termFact.begin(); it != m_termFact.end(); ++it ) { list << it.key(); } return list; } QStringList MetaFactory::fileTransferLayers()const { QStringList list; QMap<QString, filelayer>::ConstIterator it; for ( it = m_fileFact.begin(); it != m_fileFact.end(); ++it ) { list << it.key(); } return list; } QStringList MetaFactory::emulationLayers()const { QStringList list; QMap<QString, emulationLayer>::ConstIterator it; for ( it = m_emu.begin(); it != m_emu.end(); ++it ) { list << it.key(); } return list; } IOLayer* MetaFactory::newIOLayer( const QString& str,const Profile& prof ) { IOLayer* lay = 0l; QMap<QString, iolayer>::Iterator it; it = m_layerFact.find( str ); if ( it != m_layerFact.end() ) { lay = (*(it.data()))(prof); /* iolayer laye = it.data(); lay = (*laye )(conf);*/ } return lay; } ProfileDialogWidget *MetaFactory::newConnectionPlugin ( const QString& str, QWidget *parent) { ProfileDialogWidget* wid = 0l; QMap<QString, configWidget>::Iterator it; it = m_conFact.find( str ); if ( it != m_conFact.end() ) { wid = (*(it.data() ) )(str,parent); } return wid; } ProfileDialogWidget *MetaFactory::newTerminalPlugin( const QString& str, QWidget *parent) { if (str.isEmpty() ) return 0l; ProfileDialogWidget* wid = 0l; qWarning("new terminalPlugin %s %l", str.latin1(), parent ); QMap<QString, configWidget>::Iterator it; it = m_termFact.find( str ); if ( it != m_termFact.end() ) { wid = (*(it.data() ) )(str,parent); } return wid; } EmulationLayer* MetaFactory::newEmulationLayer( const QString& str, WidgetLayer* wid) { EmulationLayer* lay = 0l; QMap<QString, emulationLayer>::Iterator it; it = m_emu.find( str ); if ( it != m_emu.end() ) { lay = (*(it.data() ) )(wid); } return lay; } +FileTransferLayer* MetaFactory::newFileTransfer(const QString& str, IOLayer* lay ) { + FileTransferLayer* file = 0l; + QMap<QString, filelayer>::Iterator it; + it = m_fileFact.find( str ); + if ( it != m_fileFact.end() ) { + file = (*(it.data() ) )(lay); + } + return file; +} QCString MetaFactory::internal( const QString& str )const { return m_strings[str]; } QString MetaFactory::external( const QCString& str )const { QMap<QString, QCString>::ConstIterator it; for ( it = m_strings.begin(); it != m_strings.end(); ++it ) { if ( it.data() == str ) return it.key(); } return QString::null; } diff --git a/noncore/apps/opie-console/metafactory.h b/noncore/apps/opie-console/metafactory.h index d05ece4..7f0699b 100644 --- a/noncore/apps/opie-console/metafactory.h +++ b/noncore/apps/opie-console/metafactory.h @@ -1,106 +1,107 @@ #ifndef OPIE_META_FACTORY_H #define OPIE_META_FACTORY_H /** * The MetaFactory is used to keep track of all IOLayers, FileTransferLayers and ConfigWidgets * and to instantiate these implementations on demand */ #include <qwidget.h> #include <qmap.h> #include <qpe/config.h> #include "io_layer.h" #include "file_layer.h" #include "profile.h" #include "profiledialogwidget.h" #include "emulation_layer.h" class WidgetLayer; class MetaFactory { public: typedef ProfileDialogWidget* (*configWidget)(const QString&, QWidget* parent); typedef IOLayer* (*iolayer)(const Profile& ); typedef FileTransferLayer* (*filelayer)(IOLayer*); typedef EmulationLayer* (*emulationLayer)(WidgetLayer* ); MetaFactory(); ~MetaFactory(); /** * add a ProfileDialogWidget to the factory * name is the name shown to the user */ void addConnectionWidgetFactory( const QCString& internalName, const QString& uiString, configWidget ); void addTerminalWidgetFactory ( const QCString& internalName, const QString& name, configWidget ); /** * adds an IOLayer factory */ void addIOLayerFactory( const QCString&, const QString&, iolayer ); /** * adds a FileTransfer Layer */ void addFileTransferLayer( const QCString& name, const QString&, filelayer ); /** * adds a Factory for Emulation to the Layer.. */ void addEmulationLayer ( const QCString& name, const QString& uiString, emulationLayer ); /* translated UI Strings */ QStringList ioLayers()const; QStringList connectionWidgets()const; /** * Terminal Configuration widgets */ QStringList terminalWidgets()const; QStringList fileTransferLayers()const; QStringList emulationLayers()const; /** * the generation... */ IOLayer* newIOLayer( const QString&,const Profile& ); ProfileDialogWidget *newConnectionPlugin ( const QString&, QWidget* ); ProfileDialogWidget* newTerminalPlugin( const QString&, QWidget* ); EmulationLayer* newEmulationLayer(const QString&, WidgetLayer* ); + FileTransferLayer* newFileTransfer(const QString&, IOLayer* ); /* * internal takes the maybe translated * public QString and maps it to the internal * not translatable QCString */ QCString internal( const QString& )const; /* * external takes the internal name * it returns a translated name */ QString external( const QCString& )const; private: QMap<QString, QCString> m_strings; QMap<QString, configWidget> m_conFact; QMap<QString, configWidget> m_termFact; QMap<QString, iolayer> m_layerFact; QMap<QString, filelayer> m_fileFact; QMap<QString, emulationLayer> m_emu; }; #endif diff --git a/noncore/apps/opie-console/test/senderui.cpp b/noncore/apps/opie-console/test/senderui.cpp index 3e0bd65..8bc1676 100644 --- a/noncore/apps/opie-console/test/senderui.cpp +++ b/noncore/apps/opie-console/test/senderui.cpp @@ -1,68 +1,68 @@ #include <stdlib.h> #include <stdio.h> #include <fcntl.h> #include <sys/termios.h> #include <qmultilineedit.h> #include <qsocketnotifier.h> #include "../profile.h" #include "../io_serial.h" #include "../filetransfer.h" #include <opie/oprocess.h> #include "senderui.h" SenderUI::SenderUI() : Sender() { /* we do that manually */ Profile prof; QString str = "/dev/ttyS0"; prof.writeEntry("Device",str ); prof.writeEntry("Baud", 115200 ); qWarning("prof " + prof.readEntry("Device") + " " + str); ser = new IOSerial(prof); connect(ser, SIGNAL(received(const QByteArray& ) ), this, SLOT(got(const QByteArray&) ) ); if ( ser->open() ) qWarning("opened!!!"); else qWarning("could not open"); } SenderUI::~SenderUI() { } void SenderUI::slotSendFile() { - sz = new FileTransfer(FileTransfer::SZ, ser); + sz = new FileTransfer(FileTransfer::SY, ser); sz->sendFile("/home/ich/bootopie-v06-13.jffs2"); connect (sz, SIGNAL(sent()), this, SLOT(fileTransComplete())); } void SenderUI::slotSend() { QCString str = MultiLineEdit1->text().utf8(); qWarning("sending: %s", str.data() ); ser->send( str ); } void SenderUI::got(const QByteArray& ar) { for ( uint i = 0; i < ar.count(); i++ ) { printf("%c", ar[i] ); } //printf("\n"); } void SenderUI::fileTransComplete() { qWarning("file transfer complete"); } void SenderUI::send() { } diff --git a/noncore/apps/opie-console/transferdialog.cpp b/noncore/apps/opie-console/transferdialog.cpp index d639de6..ba06199 100644 --- a/noncore/apps/opie-console/transferdialog.cpp +++ b/noncore/apps/opie-console/transferdialog.cpp @@ -1,179 +1,187 @@ -#include "transferdialog.h" +#include <qlayout.h> +#include <qcombobox.h> +#include <qlabel.h> +#include <qlineedit.h> +#include <qpushbutton.h> +#include <qmessagebox.h> +#include <qprogressbar.h> + +#include <opie/ofiledialog.h> #include "filetransfer.h" #include "io_serial.h" +#include "metafactory.h" +#include "mainwindow.h" + +#include "transferdialog.h" + -#include "qlayout.h" -#include "qcombobox.h" -#include "qlabel.h" -#include "qlineedit.h" -#include "qpushbutton.h" -#include "qmessagebox.h" -#include "qprogressbar.h" -#include "opie/ofiledialog.h" -TransferDialog::TransferDialog(QWidget *parent, const char *name) -: QDialog(/*parent, name*/NULL, NULL, true) + + + +TransferDialog::TransferDialog(MainWindow *parent, const char *name) +: QDialog(/*parent, name*/0l, 0l, true), m_win(parent) { + m_lay = 0l; QVBoxLayout *vbox; QHBoxLayout *hbox, *hbox2; QLabel *file, *mode, *progress, *status; QPushButton *selector; - transfer = NULL; file = new QLabel(QObject::tr("Send file"), this); mode = new QLabel(QObject::tr("Transfer mode"), this); progress = new QLabel(QObject::tr("Progress"), this); status = new QLabel(QObject::tr("Status"), this); statusbar = new QLabel(QObject::tr("ready"), this); statusbar->setFrameStyle(QFrame::Panel | QFrame::Sunken); protocol = new QComboBox(this); - protocol->insertItem("XModem"); - protocol->insertItem("YModem"); - protocol->insertItem("ZModem"); + /* use the fscking MetaFactory + * because we invented it for that fscking reason + * I'm really getting UPSET!!!! + */ + QStringList list = m_win->factory()->fileTransferLayers(); + for (QStringList::Iterator it =list.begin(); it != list.end(); ++it ) { + protocol->insertItem( (*it) ); + } filename = new QLineEdit(this); progressbar = new QProgressBar(this); progressbar->setProgress(0); selector = new QPushButton("...", this); ok = new QPushButton(QObject::tr("Start transfer"), this); cancel = new QPushButton(QObject::tr("Cancel"), this); vbox = new QVBoxLayout(this, 2); vbox->add(file); hbox = new QHBoxLayout(vbox, 0); hbox->add(filename); hbox->add(selector); vbox->add(mode); vbox->add(protocol); vbox->add(progress); vbox->add(progressbar); vbox->add(status); vbox->add(statusbar); vbox->addStretch(1); hbox2 = new QHBoxLayout(vbox, 2); hbox2->add(ok); hbox2->add(cancel); setCaption(QObject::tr("File transfer")); show(); connect(selector, SIGNAL(clicked()), SLOT(slotFilename())); connect(ok, SIGNAL(clicked()), SLOT(slotTransfer())); connect(cancel, SIGNAL(clicked()), SLOT(slotCancel())); } TransferDialog::~TransferDialog() { } void TransferDialog::slotFilename() { QString f; - + f = OFileDialog::getOpenFileName(0); if(!f.isNull()) filename->setText(f); } void TransferDialog::slotTransfer() { if(filename->text().isEmpty()) { QMessageBox::information(this, QObject::tr("Attention"), QObject::tr("No file has been specified.")); return; } ok->setEnabled(false); statusbar->setText(QObject::tr("Sending...")); - FileTransfer::Type transfermode = FileTransfer::SX; - if(protocol->currentText() == "YModem") transfermode == FileTransfer::SY; - if(protocol->currentText() == "ZModem") transfermode == FileTransfer::SZ; - - // dummy profile - Profile profile("Dummy", "serial", "vt102", Profile::White, Profile::Black, Profile::VT102); + m_lay = m_win->factory()->newFileTransfer( protocol->currentText(), + m_win->currentSession()->layer() ); + m_lay->sendFile(filename->text()); - transfer = new FileTransfer(transfermode, new IOSerial(profile)); - transfer->sendFile(filename->text()); - connect(transfer, SIGNAL(progress(const QString&, int, int, int, int, int)), SLOT(slotProgress(const QString&, int, int, int, int, int))); - connect(transfer, SIGNAL(error(int, const QString&)), SLOT(slotError(int, const QString&))); - connect(transfer, SIGNAL(sent()), SLOT(slotSent())); + connect(m_lay, SIGNAL(progress(const QString&, int, int, int, int, int)), SLOT(slotProgress(const QString&, int, int, int, int, int))); + connect(m_lay, SIGNAL(error(int, const QString&)), SLOT(slotError(int, const QString&))); + connect(m_lay, SIGNAL(sent()), SLOT(slotSent())); } void TransferDialog::slotCancel() { ok->setEnabled(true); - if(transfer) + if(m_lay) { - transfer->cancel(); - delete transfer; - transfer = NULL; + m_lay->cancel(); + delete m_lay; + m_lay = 0l; QMessageBox::information(this, QObject::tr("Cancelled"), QObject::tr("The file transfer has been cancelled.")); } else { close(); } } void TransferDialog::slotProgress(const QString& file, int progress, int speed, int hours, int minutes, int seconds) { progressbar->setProgress(progress); } void TransferDialog::slotError(int error, const QString& message) { switch(error) { case FileTransferLayer::NotSupported: QMessageBox::critical(this, QObject::tr("Error"), QObject::tr("Operation not supported.")); break; case FileTransferLayer::StartError: QMessageBox::critical(this, QObject::tr("Error"), QObject::tr("Operation not supported.")); break; case FileTransferLayer::NoError: QMessageBox::critical(this, QObject::tr("Error"), QObject::tr("Operation not supported.")); break; case FileTransferLayer::Undefined: QMessageBox::critical(this, QObject::tr("Error"), QObject::tr("Operation not supported.")); break; case FileTransferLayer::Incomplete: QMessageBox::critical(this, QObject::tr("Error"), QObject::tr("Operation not supported.")); break; case FileTransferLayer::Unknown: default: QMessageBox::critical(this, QObject::tr("Error"), QObject::tr("Operation not supported.")); break; } } void TransferDialog::slotSent() { QMessageBox::information(this, QObject::tr("Sent"), QObject::tr("File has been sent.")); ok->setEnabled(true); } diff --git a/noncore/apps/opie-console/transferdialog.h b/noncore/apps/opie-console/transferdialog.h index 61f425c..b0c1a76 100644 --- a/noncore/apps/opie-console/transferdialog.h +++ b/noncore/apps/opie-console/transferdialog.h @@ -1,38 +1,40 @@ #ifndef TRANSFER_DIALOG_H #define TRANSFER_DIALOG_H #include "qdialog.h" class QLineEdit; class QComboBox; class QProgressBar; class QLabel; class QPushButton; -class FileTransfer; +class MainWindow; +class FileTransferLayer; class TransferDialog : public QDialog { Q_OBJECT public: - TransferDialog(QWidget *parent = NULL, const char *name = NULL); + TransferDialog(MainWindow *parent = 0l, const char *name = 0l); ~TransferDialog(); public slots: void slotFilename(); void slotTransfer(); void slotCancel(); void slotProgress(const QString&, int, int, int, int, int); void slotError(int error, const QString& message); void slotSent(); private: QLineEdit *filename; QComboBox *protocol; QProgressBar *progressbar; QLabel *statusbar; QPushButton *ok, *cancel; - FileTransfer *transfer; + MainWindow* m_win; + FileTransferLayer* m_lay; }; #endif |