-rw-r--r-- | noncore/apps/opie-console/dialer.cpp | 6 | ||||
-rw-r--r-- | noncore/apps/opie-console/dialer.h | 1 | ||||
-rw-r--r-- | noncore/apps/opie-console/io_modem.cpp | 5 | ||||
-rw-r--r-- | noncore/apps/opie-console/mainwindow.cpp | 3 | ||||
-rw-r--r-- | noncore/apps/opie-console/transferdialog.cpp | 4 | ||||
-rw-r--r-- | noncore/apps/opie-console/transferdialog.h | 2 |
6 files changed, 16 insertions, 5 deletions
diff --git a/noncore/apps/opie-console/dialer.cpp b/noncore/apps/opie-console/dialer.cpp index bd6b50f..7bf9352 100644 --- a/noncore/apps/opie-console/dialer.cpp +++ b/noncore/apps/opie-console/dialer.cpp @@ -39,96 +39,102 @@ //dialPref3Line->setText( config.readEntry("DialPrefix3", MODEM_DEFAULT_DIAL_PREFIX1 ) ); //dialSuf3Line->setText( config.readEntry("DialSuffix3", MODEM_DEFAULT_DIAL_SUFFIX1 ) ); //connectLine->setText( config.readEntry("DefaultConnect" MODEM_DEFAULT_CONNECT_STRING ) ); //hangupLine->setText( config.readEntry("HangupString", MODEM_DEFAULT_HANGUP_STRING ) ); // from modemconfigwidget //int rad_flow = prof.readNumEntry("Flow"); //int rad_parity = prof.readNumEntry("Parity"); //int speed = prof.readNumEntry("Speed"); //QString number = prof.readEntry("Number"); Dialer::Dialer(const Profile& profile, int fd, QWidget *parent, const char *name) : QDialog(parent, name, true), m_fd(fd), m_profile(profile) { QVBoxLayout *vbox; QLabel *desc; //m_profile.writeEntry("InitString", "ATZ"); //m_profile.writeEntry("DialPrefix1", "ATDT"); //m_profile.writeEntry("Termination", "\n"); usercancel = 0; fcntl(m_fd, F_SETFL, O_NONBLOCK); desc = new QLabel(QObject::tr("Dialing number: %1").arg(m_profile.readEntry("Number")), this); progress = new QProgressBar(this); status = new QLabel("", this); status->setFrameStyle(QFrame::Panel | QFrame::Sunken); cancel = new QPushButton(QObject::tr("Cancel"), this); vbox = new QVBoxLayout(this, 2); vbox->add(desc); vbox->add(progress); vbox->add(status); vbox->add(cancel); connect(cancel, SIGNAL(clicked()), SLOT(slotCancel())); show(); QTimer::singleShot(500, this, SLOT(slotAutostart())); } Dialer::~Dialer() { } +void Dialer::setHangupOnly() +{ + state = state_cancel; + usercancel = 1; +} + void Dialer::slotCancel() { if(state != state_online) { usercancel = 1; reset(); } else accept(); } void Dialer::reset() { switchState(state_cancel); } void Dialer::slotAutostart() { //state = state_preinit; dial(m_profile.readEntry("Number")); } void Dialer::dial(const QString& number) { while(state != state_online) { if(!usercancel) { state = state_preinit; trydial(number); } else break; } if(usercancel) { // modem hangup trydial(QString::null); reject(); } } void Dialer::trydial(const QString& number) { //if(state != state_cancel) //{ if(state != state_cancel) switchState(state_preinit); send("+++ATH"); send(""); diff --git a/noncore/apps/opie-console/dialer.h b/noncore/apps/opie-console/dialer.h index 4011880..84444b9 100644 --- a/noncore/apps/opie-console/dialer.h +++ b/noncore/apps/opie-console/dialer.h @@ -1,52 +1,53 @@ #ifndef DIALER_H #define DIALER_H #include <qdialog.h> #include "profile.h" class QLabel; class QProgressBar; class Dialer : public QDialog { Q_OBJECT public: Dialer(const Profile& profile, int fd, QWidget *parent = NULL, const char *name = NULL); ~Dialer(); + void setHangupOnly(); public slots: void slotCancel(); void slotAutostart(); private: void switchState(int newstate); void reset(); void dial(const QString& number); void trydial(const QString& number); void send(const QString& msg); QString receive(); enum States { state_cancel, state_preinit, state_init, state_options, state_dialtone, state_dialing, state_online }; QLabel *status; QProgressBar *progress; QPushButton *cancel; int state; int usercancel; const Profile& m_profile; int m_fd; }; #endif diff --git a/noncore/apps/opie-console/io_modem.cpp b/noncore/apps/opie-console/io_modem.cpp index c04aad1..2f0c04e 100644 --- a/noncore/apps/opie-console/io_modem.cpp +++ b/noncore/apps/opie-console/io_modem.cpp @@ -1,66 +1,69 @@ #include "io_modem.h" #include "dialer.h" IOModem::IOModem( const Profile &profile ) : IOSerial( profile ) { m_profile = profile; } IOModem::~IOModem() { } void IOModem::close() { - // maybe do a hangup here just in case...? + // Hangup, discarding result + Dialer d(m_profile, rawIO()); + d.setHangupOnly(); + d.exec(); IOSerial::close(); } bool IOModem::open() { bool ret = IOSerial::open(); if(!ret) return false; Dialer d(m_profile, rawIO()); int result = d.exec(); if(result == QDialog::Accepted) { return true; } else { close(); return false; } } void IOModem::reload( const Profile &config ) { m_device = config.readEntry("Device", MODEM_DEFAULT_DEVICE); m_baud = config.readNumEntry("Baud", MODEM_DEFAULT_BAUD); m_parity = config.readNumEntry("Parity", MODEM_DEFAULT_PARITY); m_dbits = config.readNumEntry("DataBits", MODEM_DEFAULT_DBITS); m_sbits = config.readNumEntry("StopBits", MODEM_DEFAULT_SBITS); m_flow = config.readNumEntry("Flow", MODEM_DEFAULT_FLOW); m_initString = config.readEntry("InitString", MODEM_DEFAULT_INIT_STRING ); m_resetString = config.readEntry("ResetString", MODEM_DEFAULT_RESET_STRING ); m_dialPref1 = config.readEntry("DialPrefix1", MODEM_DEFAULT_DIAL_PREFIX1 ); m_dialSuf1 = config.readEntry("DialSuffix1", MODEM_DEFAULT_DIAL_SUFFIX1 ); m_dialPref2 = config.readEntry("DialPrefix2", MODEM_DEFAULT_DIAL_PREFIX1 ); m_dialSuf2 = config.readEntry("DialSuffix2", MODEM_DEFAULT_DIAL_SUFFIX1 ); m_dialPref3 = config.readEntry("DialPrefix3", MODEM_DEFAULT_DIAL_PREFIX1 ); m_dialSuf3 = config.readEntry("DialSuffix3", MODEM_DEFAULT_DIAL_SUFFIX1 ); m_connect = config.readEntry("DefaultConnect" MODEM_DEFAULT_CONNECT_STRING ); m_hangup = config.readEntry("HangupString", MODEM_DEFAULT_HANGUP_STRING ); m_cancel = config.readEntry("CancelString", MODEM_DEFAULT_CANCEL_STRING ); m_dialTime = config.readNumEntry("DialTime", MODEM_DEFAULT_DIAL_TIME ); m_delayRedial = config.readNumEntry("DelayRedial", MODEM_DEFAULT_DELAY_REDIAL ); m_numberTries = config.readNumEntry("NumberTries", MODEM_DEFAULT_NUMBER_TRIES ); m_dtrDropTime = config.readNumEntry("DTRDRopTime", MODEM_DEFAULT_DTR_DROP_TIME ); m_bpsDetect = config.readBoolEntry("BPSDetect", MODEM_DEFAULT_BPS_DETECT ); m_dcdLines = config.readBoolEntry("DCDLines", MODEM_DEFAULT_DCD_LINES ); diff --git a/noncore/apps/opie-console/mainwindow.cpp b/noncore/apps/opie-console/mainwindow.cpp index 9a226bb..55e9836 100644 --- a/noncore/apps/opie-console/mainwindow.cpp +++ b/noncore/apps/opie-console/mainwindow.cpp @@ -397,98 +397,99 @@ void MainWindow::slotClose() { } /* * 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() ); if((!ses) || (!ses->layer()) || (!ses->widgetStack())) { QMessageBox::warning(this, QObject::tr("Session failed"), QObject::tr("<qt>Cannot open session: Not all components were found.</qt>")); //if(ses) delete ses; return; } m_sessions.append( ses ); tabWidget()->add( ses ); m_curSession = ses; // dicide if its a local term ( then no connction and no tranfer), maybe make a wrapper method out of it m_connect->setEnabled( true ); m_disconnect->setEnabled( false ); m_terminate->setEnabled( true ); m_transfer->setEnabled( true ); m_recordScript->setEnabled( true ); m_saveScript->setEnabled( true ); m_runScript->setEnabled( true ); m_fullscreen->setEnabled( true ); m_closewindow->setEnabled( true ); // is io_layer wants direct connection, then autoconnect if ( ( m_curSession->layer() )->supports()[0] = 1 ) { slotConnect(); } } void MainWindow::slotTransfer() { if ( currentSession() ) { - TransferDialog dlg(this); + TransferDialog dlg(currentSession()->widgetStack(), this); dlg.showMaximized(); + //currentSession()->widgetStack()->add(dlg); dlg.exec(); } } void MainWindow::slotOpenKeb(bool state) { if (state) m_keyBar->show(); else m_keyBar->hide(); } void MainWindow::slotOpenButtons( bool state ) { if ( state ) { m_buttonBar->show(); } else { m_buttonBar->hide(); } } void MainWindow::slotSessionChanged( Session* ses ) { qWarning("changed!"); if ( ses ) { m_curSession = ses; qDebug(QString("is connected : %1").arg( m_curSession->layer()->isConnected() ) ); if ( m_curSession->layer()->isConnected() ) { m_connect->setEnabled( false ); m_disconnect->setEnabled( true ); } else { m_connect->setEnabled( true ); m_disconnect->setEnabled( false ); } } } void MainWindow::slotFullscreen() { if ( m_isFullscreen ) { ( m_curSession->widgetStack() )->reparent( m_consoleWindow, 0, QPoint(0,0), false ); ( m_curSession->widgetStack() )->setFrameStyle( QFrame::Panel | QFrame::Sunken ); setCentralWidget( m_consoleWindow ); ( m_curSession->widgetStack() )->show(); ( m_curSession->emulationHandler() )->cornerButton()->hide(); disconnect( ( m_curSession->emulationHandler() )->cornerButton(), SIGNAL( pressed() ), this, SLOT( slotFullscreen() ) ); diff --git a/noncore/apps/opie-console/transferdialog.cpp b/noncore/apps/opie-console/transferdialog.cpp index f9a0b87..ac5b1d0 100644 --- a/noncore/apps/opie-console/transferdialog.cpp +++ b/noncore/apps/opie-console/transferdialog.cpp @@ -1,69 +1,69 @@ #include <qlayout.h> #include <qcombobox.h> #include <qlabel.h> #include <qlineedit.h> #include <qpushbutton.h> #include <qmessagebox.h> #include <qprogressbar.h> #include <qradiobutton.h> #include <qbuttongroup.h> #include <opie/ofiledialog.h> #include "file_layer.h" #include "receive_layer.h" #include "metafactory.h" #include "mainwindow.h" #include "transferdialog.h" -TransferDialog::TransferDialog(MainWindow *parent, const char *name) -: QDialog(0l, 0l, true), m_win(parent) +TransferDialog::TransferDialog(QWidget *parent, MainWindow *mainwindow, const char *name) +: QDialog(parent, 0l, true), m_win(mainwindow) { m_lay = 0l; m_recvlay = 0l; QVBoxLayout *vbox, *vbox2; QHBoxLayout *hbox, *hbox2, *hbox3; QLabel *file, *mode, *progress, *status; QButtonGroup *group; QRadioButton *mode_send, *mode_receive; m_autocleanup = 0; group = new QButtonGroup(QObject::tr("Transfer mode"), this); mode_send = new QRadioButton(QObject::tr("Send"), group); mode_receive = new QRadioButton(QObject::tr("Receive"), group); group->insert(mode_send, id_send); group->insert(mode_receive, id_receive); vbox2 = new QVBoxLayout(group, 2); vbox2->addSpacing(10); hbox3 = new QHBoxLayout(vbox2, 2); hbox3->add(mode_send); hbox3->add(mode_receive); mode_send->setChecked(true); m_transfermode = id_send; file = new QLabel(QObject::tr("Send file"), this); mode = new QLabel(QObject::tr("Transfer protocol"), 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); 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(group); diff --git a/noncore/apps/opie-console/transferdialog.h b/noncore/apps/opie-console/transferdialog.h index 1b27f16..d87be6a 100644 --- a/noncore/apps/opie-console/transferdialog.h +++ b/noncore/apps/opie-console/transferdialog.h @@ -1,54 +1,54 @@ #ifndef TRANSFER_DIALOG_H #define TRANSFER_DIALOG_H #include "qdialog.h" class QLineEdit; class QComboBox; class QProgressBar; class QLabel; class QPushButton; class MainWindow; class FileTransferLayer; class ReceiveLayer; class TransferDialog : public QDialog { Q_OBJECT public: - TransferDialog(MainWindow *parent = 0l, const char *name = 0l); + TransferDialog(QWidget *parent = 0l, MainWindow *mainwindow = 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(); void slotReceived(const QString& file); void slotMode(int id); private: enum Modes { id_send, id_receive }; void cleanup(); QLineEdit *filename; QComboBox *protocol; QProgressBar *progressbar; QLabel *statusbar; QPushButton *ok, *cancel, *selector; MainWindow* m_win; FileTransferLayer* m_lay; ReceiveLayer *m_recvlay; int m_transfermode; int m_autocleanup; }; #endif |