Ejemplo n.º 1
0
bool QtQuick2ApplicationViewer::event(QEvent *ev)
{
    if (ev->type() == QEvent::Close) {
        qDebug() << "Main window has just started to closing";
        if (!m_readyToExit) {
            m_readyToExit = true;
            ev->accept();
            emit aboutToClose();
            return true;
        }
    }
    return QQuickView::event(ev);
}
Ejemplo n.º 2
0
void LocalDiskRepo::putFileComplete(QIODevice* device, QString file_path)
{
    qDebug() << "saving file";
    disconnect(device, SIGNAL(aboutToClose()), this, SLOT(putFileFailed()));
    QFile* f = (QFile*) device;
    if (!QFile::exists(absoluteFilePath(file_path))) {
        qDebug() << "renaming writebuffer and closing";
        f->rename(absoluteFilePath(file_path));
    } else {
        // keeping as temporary
        qCritical() << "file with file_path:" << file_path << " already exists";
        f->close();
    }
}
Ejemplo n.º 3
0
void MLTTYDevice::close()
{
  if(tty_open) {
    emit aboutToClose();
    tty_write_timer->stop();
    delete tty_notifier;
    tty_notifier=NULL;
    ::close(tty_fd);
    if((tty_mode&QIODevice::ReadOnly)!=0) {
      emit readChannelFinished();
    }
  }
  tty_open=false;
}
Ejemplo n.º 4
0
void Console::attachIODevice(QIODevice *iod)
{
    if(_ioDevice)
        _ioDevice->disconnect(this);

    _ioDevice = iod;

    if(_ioDevice){
        connect(_ioDevice, SIGNAL(readyRead()),this, SLOT(printData()));
        connect(_ioDevice, SIGNAL(readChannelFinished()),this, SLOT(enableOutput()));
        connect(_ioDevice, SIGNAL(closeDevice()),this, SLOT(aboutToClose()));

    }
}
Ejemplo n.º 5
0
WebSocket::WebSocket(QWebSocket *sock, QString ID, AuthorizationManager *auth){
  SockID = ID;
  SockAuthToken.clear(); //nothing set initially
  SOCKET = sock;
  SendAppCafeEvents = false;
  AUTHSYSTEM = auth;
  idletimer = new QTimer(this);
    idletimer->setInterval(600000); //10-minute timeout
    idletimer->setSingleShot(true);
  connect(idletimer, SIGNAL(timeout()), this, SLOT(checkIdle()) );
  connect(SOCKET, SIGNAL(textMessageReceived(const QString&)), this, SLOT(EvaluateMessage(const QString&)) );
  connect(SOCKET, SIGNAL(binaryMessageReceived(const QByteArray&)), this, SLOT(EvaluateMessage(const QByteArray&)) );
  connect(SOCKET, SIGNAL(aboutToClose()), this, SLOT(SocketClosing()) );
  idletimer->start();
}
PersistentConnection::PersistentConnection(QWidget *parent) :
    QDialog(parent),
    ui(new Ui::PersistentConnection)
{
    ui->setupUi(this);

    setWindowFlags(this->windowFlags() & ~Qt::WindowContextHelpButtonHint);

    suppressSlot = true;

    QDEBUG();
    sendPacket.clear();
    QDEBUG() << ": refreshTimer Connection attempt " <<
             connect ( &refreshTimer , SIGNAL ( timeout() ) , this, SLOT ( refreshTimerTimeout (  ) ) )
             << connect ( this , SIGNAL ( rejected() ) , this, SLOT ( aboutToClose (  ) ) )
             << connect ( this , SIGNAL ( accepted() ) , this, SLOT ( aboutToClose (  ) ) )
             << connect ( this , SIGNAL ( dialogIsClosing() ) , this, SLOT ( aboutToClose (  ) ) );
    QDEBUG() << "Setup timer";
    refreshTimer.setInterval(200);
    refreshTimer.start();
    trafficList.clear();
    startTime = QDateTime::currentDateTime();
    wasConnected = false;
    stopTimer = false;

    ui->searchEdit->setText("");

    loadComboBox();

    useraw = true;

    ui->asciiLineEdit->setFocus();
    suppressSlot = false;


}
Ejemplo n.º 7
0
// New Connection Signals
void WebServer::NewSocketConnection(){
  if(!this->hasPendingConnections()){ return; }
  qDebug() << "New Socket Connection";	
  if(csock!=0){ qDebug() << " - Placed in queue"; return;}
  if(idletimer->isActive()){ idletimer->stop(); }
  csock = this->nextPendingConnection();
  connect(csock, SIGNAL(textMessageReceived(const QString&)), this, SLOT(EvaluateMessage(const QString&)) );
  connect(csock, SIGNAL(binaryMessageReceived(const QByteArray&)), this, SLOT(EvaluateMessage(const QByteArray&)) );
  connect(csock, SIGNAL(aboutToClose()), this, SLOT(SocketClosing()) );
  connect(csock, SIGNAL(disconnected()), this, SLOT(NewSocketConnection()) );
  if(csock == 0){ qWarning() << " - new connection invalid, skipping..."; QTimer::singleShot(10, this, SLOT(NewSocketConnection())); return; }
  qDebug() <<  " - Accepting connection:" << csock->origin();
  idletimer->start();
  //QTimer::singleShot(0,this, SLOT(EvaluateConnection()));
}
FileBrowserDialog *FileBrowserManager::openOrActivateDialog(const Account &account, const ServerRepo &repo)
{
    FileBrowserDialog *dialog = getDialog(account, repo.id);
    if (dialog == NULL) {
        dialog = new FileBrowserDialog(account, repo, seafApplet->mainWindow());
        QRect screen = QApplication::desktop()->screenGeometry();
        dialog->setAttribute(Qt::WA_DeleteOnClose, true);
        dialog->show();
        dialog->move(screen.center() - dialog->rect().center());
        dialogs_.push_back(dialog);
        connect(dialog, SIGNAL(aboutToClose()), this, SLOT(onAboutToClose()));
    }
    dialog->raise();
    dialog->activateWindow();
    return dialog;
}
Ejemplo n.º 9
0
Worker::Worker(QIODevice* peer, QObject* parent)
	: QObject(parent),
	  m_peer(peer), m_target(0), m_connector(0),
	  m_buf(), m_expected_length(-1), m_state(Worker::ConnectedState),
	  m_noauth_allowed(false)
{
	QObject::connect(this->m_peer, SIGNAL(readyRead()), this, SLOT(peerReadyReadHandler()));

	if (qobject_cast<QAbstractSocket*>(this->m_peer)) {
		QObject::connect(this->m_peer, SIGNAL(disconnected()), this, SLOT(disconnectHandler()));
		QObject::connect(this->m_peer, SIGNAL(error(QAbstractSocket::SocketError)), this, SLOT(peerErrorHandler(QAbstractSocket::SocketError)));
	}
	else {
		QObject::connect(this->m_peer, SIGNAL(aboutToClose()), this, SLOT(disconnectHandler()));
	}
}
Ejemplo n.º 10
0
WebSocket::WebSocket(QWebSocket *sock, QString ID, AuthorizationManager *auth){
  SockID = ID;
  SockAuthToken.clear(); //nothing set initially
  SOCKET = sock;
  TSOCKET = 0;
  AUTHSYSTEM = auth;
  SockPeerIP = SOCKET->peerAddress().toString();
  LogManager::log(LogManager::HOST,"New Connection: "+SockPeerIP);
  idletimer = new QTimer(this);
    idletimer->setInterval(IDLETIMEOUTMINS*60000); //connection timout for idle sockets
    idletimer->setSingleShot(true);
  connect(idletimer, SIGNAL(timeout()), this, SLOT(checkIdle()) );
  connect(SOCKET, SIGNAL(textMessageReceived(const QString&)), this, SLOT(EvaluateMessage(const QString&)) );
  connect(SOCKET, SIGNAL(binaryMessageReceived(const QByteArray&)), this, SLOT(EvaluateMessage(const QByteArray&)) );
  connect(SOCKET, SIGNAL(aboutToClose()), this, SLOT(SocketClosing()) );
  idletimer->start();
}
Ejemplo n.º 11
0
//-----------------------------------------------------------------------------
// SatAppToneProvider::playUserSelectedTone
//-----------------------------------------------------------------------------
void SatAppToneProvider::playUserSelectedTone(
    const QString& text,
    int tone,
    int duration)
{
    qDebug("SatAppToneProvider::playUserSelectedTone >");

    // If several messages/calls arrive during a small amount of time and if the
    // message received or incoming call tone is already being played we do not 
    // restart it.
    if (mAudioPlayer) {
        qDebug( "SatAppToneProvider::\
            PlayUserSelectedToneL Error - already played" );
        mCurrentAction->complete(ESatFailure);
        mCurrentAction = 0;
        mState = Idle;
        return;
    }

    if (text.length() > 0) {
        mPermanentNote = new HbMessageBox(HbMessageBox::MessageTypeInformation);
        mPermanentNote->setText(text);
        mPermanentNote->setStandardButtons(HbMessageBox::Cancel);
        if (duration) {
            mPermanentNote->setTimeout(duration);
        }
        mPermanentNote->setDismissPolicy(HbPopup::TapAnywhere);
        qDebug("SatAppToneProvider::PlayUserSelectedToneL show before");
        mPermanentNote->show();
        qDebug("SatAppToneProvider::PlayUserSelectedToneL show after");
    }

    QT_TRAP_THROWING(SymbianPrepareAudioPlayerL(tone,duration));
    
    if (duration > 0) {
        qDebug( "SATAPP: SatAppToneProvider::PlayUserSelectedToneL\
            duration not 0" );
        mTimer = new QTimer(this);
        mTimer->start(duration);
        SAT_ASSERT(connect(mTimer, SIGNAL(timeout()), this, SLOT(stopPlayTone())));

        if (mPermanentNote) {
            SAT_ASSERT(connect(mPermanentNote, SIGNAL(aboutToClose()),
                    this, SLOT(stopPlayTone())));
        }
    }
Socks5ConnectedState::Socks5ConnectedState(QIODevice *remoteSocket, SocksConnection *parent) :
    SocksState(parent), _socket(remoteSocket)
{
    if (_socket.isNull())
        return;

    _socket->setParent(this);

    connect(_socket.data(),
             SIGNAL(readyRead()),
             this,
             SLOT(handleRemoteReadyRead()));
    connect(_socket.data(),
             SIGNAL(aboutToClose()),
             this,
             SLOT(handleRemoteDisconnect()));
}
Ejemplo n.º 13
0
bool QNmeaPositionInfoSourcePrivate::openSourceDevice()
{
    if (!m_device) {
        qWarning("QNmeaPositionInfoSource: no QIODevice data source, call setDevice() first");
        return false;
    }

    if (!m_device->isOpen() && !m_device->open(QIODevice::ReadOnly)) {
        qWarning("QNmeaPositionInfoSource: cannot open QIODevice data source");
        return false;
    }

    connect(m_device, SIGNAL(aboutToClose()), SLOT(sourceDataClosed()));
    connect(m_device, SIGNAL(readChannelFinished()), SLOT(sourceDataClosed()));
    connect(m_device, SIGNAL(destroyed()), SLOT(sourceDataClosed()));

    return true;
}
Ejemplo n.º 14
0
void
MainWindow::closeEvent(QCloseEvent *event) {
  emit aboutToClose();

  auto ok =       mergeTool()->closeAllTabs();
  ok      = ok && headerEditorTool()->closeAllTabs();
  ok      = ok && chapterEditorTool()->closeAllTabs();
  ok      = ok && beforeCloseCheckRunningJobs();

  if (!ok) {
    event->ignore();
    return;
  }

  Util::saveWidgetGeometry(this);

  event->accept();
}
Ejemplo n.º 15
0
void AudioPlayback::startPlaying(QIODevice * stream)
{
    qDebug() << "AudioPlayback::startPlaying";

    m_audioOutput = new QAudioOutput(m_format);
    connect(m_audioOutput,SIGNAL(stateChanged(QAudio::State)),SLOT(printState(QAudio::State)));

    m_stream = stream;
    connect(m_stream, SIGNAL(aboutToClose()), this, SLOT(stopPlaying()));
//    connect(stream, SIGNAL(readyRead()), this, SLOT(processIncomingData()), Qt::DirectConnection);

    // Open IODevice if not open already
    if(!stream->isOpen())
    {
        stream->open(QIODevice::ReadOnly);
    }

    m_audioOutput->start(m_stream);
}
Ejemplo n.º 16
0
void MeanwhileSession::handleRedirect(const char *host)
{
    /* if configured manually, force the login */
    if (account->getForceLogin()) {
        mwSession_forceLogin(session);
        return;
    }

    /* if we're connecting to the same host, force */
    if (!host || account->getServerName() == host) {
        mwSession_forceLogin(session);
        return;
    }

    QTcpSocket *sock = new QTcpSocket(this);

    Kopete::SocketTimeoutWatcher* timeoutWatcher = Kopete::SocketTimeoutWatcher::watch(sock);
    if (timeoutWatcher)
        QObject::connect(timeoutWatcher, SIGNAL(error(QAbstractSocket::SocketError)), this, SLOT(slotSocketAboutToClose()));

    sock->connectToHost(host, quint16(account->getServerPort()));

    if (!sock->waitForConnected()) {
        KMessageBox::queuedMessageBox(0, KMessageBox::Error,
                i18n( "Could not connect to redirected server"),
                        i18n("Meanwhile Plugin"),
                KMessageBox::Notify);
        delete sock;
        mwSession_forceLogin(session);
        return;
    }

    /* we've redirected, so swap the sockets */
    delete this->socket;
    this->socket = sock;

    /* we want to receive signals when there is data to read */
    QObject::connect(sock, SIGNAL(readyRead()), this,
                     SLOT(slotSocketDataAvailable()));
    QObject::connect(sock, SIGNAL(aboutToClose()), this,
                     SLOT(slotSocketAboutToClose()));
}
/*!
  LifeTimerKeySequenceHandler::launchLifeTimerDialog().
 */
void LifeTimerKeySequenceHandler::launchLifeTimerDialog()
{
    DPRINT_METHODENTRYEXIT;

    destroyMessageBox();

    QString lifeTimerData = constructLifeTimerData();
    QString lifeTimerNoteText =
        hbTrId("txt_phone_info_life_timer").arg(lifeTimerData);
    m_messageBox = new HbDeviceMessageBox(
        lifeTimerNoteText,
        HbMessageBox::MessageTypeInformation);
    m_messageBox->setTimeout(HbPopup::NoTimeout);

    QObject::connect(
        m_messageBox, SIGNAL(aboutToClose()),
        this, SLOT(destroyMessageBox()));

    m_messageBox->show();
}
/*!
 * The construction of the dialog
 */ 
void EapMschapv2PwdExpNoteDialog::createDialog()
{
    OstTraceFunctionEntry0( EAPMSCHAPV2PWDEXPNOTEDIALOG_CREATEDIALOG_ENTRY );
    qDebug("EapMschapv2PwdExpNoteDialog::createDialog ENTER");
     
    QString text(hbTrId("txt_occ_info_eapmschapv2_password_has_expired_yo"));
        
    //Set the dialog to be on the screen until user reacts
    //by pressing the Action button
    this->setModal(true);
    this->setTimeout(HbPopup::NoTimeout);
    this->setDismissPolicy(HbPopup::NoDismiss);
                   
    this->setText(text);    
    this->setIconVisible(true);
    
    //Remove all default actions from the dialog          
    QList<QAction*> action_list = this->actions();
    for ( int i = 0; i < action_list.count(); i++ ) {
        this->removeAction(action_list.at(i));
        }
    
    //Add a new Ok button action 
    HbAction* actionOk = new HbAction(hbTrId("txt_common_button_ok_single_dialog"),this); 
    this->addAction(actionOk);
    
    //Connect to a SLOT owned by this class  
    bool connected = connect(actionOk, SIGNAL(triggered()), this, SLOT(okPressed()));
    Q_ASSERT(connected == true);
        
    //Connect the about to close and hide signals, so that we are able to inform 
    //the caller that the dialog was closed    
    connected = connect(this, SIGNAL(aboutToClose()), this, SLOT(closingDialog()));
    Q_ASSERT(connected == true);
    connected = connect(this, SIGNAL(aboutToHide()), this, SLOT(closingDialog()));
    Q_ASSERT(connected == true);
   
    OstTraceFunctionExit0( DUP1_EAPMSCHAPV2PWDEXPNOTEDIALOG_CREATEDIALOG_EXIT );
    qDebug("EapMschapv2PwdExpNoteDialog::createDialog EXIT");
}
/*!
 * The construction of the dialog
 *
 * @param [in] parameters Parameters for the Construction of the dialog.
 */ 
void EapFastProvWaitNoteDialog::createDialog(const QVariantMap &parameters )
{
    OstTraceFunctionEntry0( EAPFASTPROVWAITNOTEDIALOG_CREATEDIALOG_ENTRY );
    qDebug("EapFastProvWaitNoteDialog::createDialog ENTER");
    
    QString mainText;    
    QString key("notificationtxt");
    
    bool authProvWaitNote = false;
    
    //Get the needed information from parameters that indicates to type of the dialog
    //which is either a authenticated or a unauthenticated 
    if ( parameters.empty() == false ) {
        if ( parameters.contains(key) ) {
            QVariant variant = parameters.value(key);
            authProvWaitNote = variant.toBool();
            }
        }      
    
    if ( authProvWaitNote ) {
        mainText = QString(hbTrId("txt_occ_dpopinfo_authenticated_provisioning_in_pro"));       
    } else {
        mainText = QString(hbTrId("txt_occ_dpopinfo_unauthenticated_provisioning_in_p"));
    }
       
    // Set the dialog to be on the screen for 4 seconds.
    this->setTimeout(4000);
    this->setTitle(mainText);  
   
    // Connect the about to close and hide signals, so that we are able to inform 
    // the caller that the dialog was closed        
    bool connected = connect(this, SIGNAL(aboutToClose()), this, SLOT(closingDialog()));
    Q_ASSERT(connected == true);
    connected = connect(this, SIGNAL(aboutToHide()), this, SLOT(closingDialog()));
    Q_ASSERT(connected == true);
   
    OstTraceFunctionExit0( DUP1_EAPFASTPROVWAITNOTEDIALOG_CREATEDIALOG_EXIT );
    qDebug("EapFastProvWaitNoteDialog::createDialog EXIT");
}
Ejemplo n.º 20
0
WebSocket::WebSocket(QSslSocket *sock, QString ID, AuthorizationManager *auth){
  SockID = ID;
  SockAuthToken.clear(); //nothing set initially
  TSOCKET = sock;
  SOCKET = 0;
  SockPeerIP = TSOCKET->peerAddress().toString();
  LogManager::log(LogManager::HOST,"New Connection: "+SockPeerIP);
  AUTHSYSTEM = auth;
  idletimer = new QTimer(this);
    idletimer->setInterval(IDLETIMEOUTMINS*60000); //connection timout for idle sockets
    idletimer->setSingleShot(true);
  connect(idletimer, SIGNAL(timeout()), this, SLOT(checkIdle()) );
  connect(TSOCKET, SIGNAL(readyRead()), this, SLOT(EvaluateTcpMessage()) );
  connect(TSOCKET, SIGNAL(aboutToClose()), this, SLOT(SocketClosing()) );
  connect(TSOCKET, SIGNAL(encrypted()), this, SLOT(nowEncrypted()) );
  connect(TSOCKET, SIGNAL(peerVerifyError(const QSslError &)), this, SLOT(peerError(const QSslError &)) );
  connect(TSOCKET, SIGNAL(sslErrors(const QList<QSslError> &)), this, SLOT(SslError(const QList<QSslError> &)) );
  //qDebug() << " - Starting Server Encryption Handshake";
   TSOCKET->startServerEncryption();
  //qDebug() << " - Socket Encrypted:" << TSOCKET->isEncrypted();
  idletimer->start();
}
Ejemplo n.º 21
0
FullScreenVideoQt::FullScreenVideoQt(ChromeClientQt* chromeClient)
    : m_chromeClient(chromeClient)
    , m_videoElement(0)
{
    Q_ASSERT(m_chromeClient);

#if USE(QT_MULTIMEDIA)
    m_FullScreenVideoHandler = m_chromeClient->m_platformPlugin.createFullScreenVideoHandler();
    if (!m_FullScreenVideoHandler)
        m_FullScreenVideoHandler = new DefaultFullScreenVideoHandler;

    if (m_FullScreenVideoHandler)
        connect(m_FullScreenVideoHandler, SIGNAL(fullScreenClosed()), this, SLOT(aboutToClose()));
#endif

#if USE(GSTREAMER)
    m_FullScreenVideoHandlerGStreamer = new GStreamerFullScreenVideoHandler;
#endif

#if USE(QTKIT)
    m_FullScreenVideoHandlerQTKit = new QTKitFullScreenVideoHandler;
#endif
}
/*!
 * The construction of the dialog
 *
 * @param [in] parameters Parameters for the Construction of the dialog.
 */ 
void EapMschapv2NewPwdDialog::createDialog(const QVariantMap &parameters )
{
    OstTraceFunctionEntry0( EAPMSCHAPV2NEWPWDDIALOG_CREATEDIALOG_ENTRY );
    qDebug("EapMschapv2NewPwdDialog::createDialog ENTER");
    
    Q_UNUSED(parameters)
    
    QString labelText1(hbTrId("txt_occ_dialog_new_eapmschapv2_password"));
    QString labelText2(hbTrId("txt_occ_dialog_verify_password"));
        
    //Set the dialog to be on the screen until user reacts
    //by pressing any of the Action buttons
    this->setModal(true);
    this->setTimeout(HbPopup::NoTimeout);
    this->setDismissPolicy(HbPopup::NoDismiss);
    this->setDismissOnAction(false);        
    this->setAdditionalRowVisible(true);
    
    //Set the first Line Edit to be on the screen
    this->setPromptText(labelText1, 0);   
    mEdit1 = this->lineEdit(0);
    mEdit1->setEchoMode(HbLineEdit::Password);
    
    //Set the second Line Edit to be on the screen also
    this->setPromptText(labelText2, 1);   
    mEdit2 = this->lineEdit(1);        
    mEdit2->setEchoMode(HbLineEdit::Password);
    
    EapQtConfigInterface eapConfigIf;
    
    mPwdValidator.reset( eapConfigIf.validatorEap(EapQtExpandedEapType::TypeEapMschapv2,
                EapQtConfig::Password ) );  
    Q_ASSERT( mPwdValidator.isNull() == false );                
                   
    mPwdValidator->updateEditor(mEdit1);
    
    //Remove all default actions from the dialog     
    QList<QAction*> action_list = this->actions();        
    for ( int i = 0; i < action_list.count(); i++ ) {
        this->removeAction(action_list.at(i));
        } 
    
    //Add a new Ok button action 
    HbAction* actionOk = new HbAction(hbTrId("txt_common_button_ok"),this); 
    this->addAction(actionOk);
    
    //Add a new Cancel button action 
    HbAction* actionCancel = new HbAction(hbTrId("txt_common_button_cancel"),this);
    this->addAction(actionCancel);    
    
    //Connect to a SLOT owned by this class
    bool connected = connect(actionOk, SIGNAL(triggered()), this, SLOT(okPressed()));
    Q_ASSERT(connected == true);
    
    //Connect to a SLOT owned by this class
    connected = connect(actionCancel, SIGNAL(triggered()), this, SLOT(cancelPressed()));
    Q_ASSERT(connected == true);
    
    //Connect the about to close and hide signals, so that we are able to inform 
    //the caller that the dialog was closed   
    connected = connect(this, SIGNAL(aboutToClose()), this, SLOT(closingDialog()));
    Q_ASSERT(connected == true);
    connected = connect(this, SIGNAL(aboutToHide()), this, SLOT(closingDialog()));
    Q_ASSERT(connected == true);
   
    OstTraceFunctionExit0( DUP1_EAPMSCHAPV2NEWPWDDIALOG_CREATEDIALOG_EXIT );
    qDebug("EapMschapv2NewPwdDialog::createDialog EXIT");
}
Ejemplo n.º 23
0
void
OutputWindow::closeEvent(QCloseEvent * e)
{
  emit aboutToClose();
  e->accept();
}
Ejemplo n.º 24
0
MythSocket::MythSocket(
    qt_socket_fd_t socket, MythSocketCBs *cb, bool use_shared_thread) :
    ReferenceCounter(QString("MythSocket(%1)").arg(socket)),
    m_tcpSocket(new QTcpSocket()),
    m_thread(NULL),
    m_socketDescriptor(-1),
    m_peerPort(-1),
    m_callback(cb),
    m_useSharedThread(use_shared_thread),
    m_disableReadyReadCallback(false),
    m_connected(false),
    m_dataAvailable(0),
    m_isValidated(false),
    m_isAnnounced(false)
{
    LOG(VB_SOCKET, LOG_INFO, LOC + QString("MythSocket(%1, 0x%2) ctor")
        .arg(socket).arg((intptr_t)(cb),0,16));

    // Use direct connections so m_tcpSocket can be used
    // in the handlers safely since they will be running
    // in the same thread as all other m_tcpSocket users.

    connect(m_tcpSocket,  SIGNAL(connected()),
            this, SLOT(ConnectHandler()),
            Qt::DirectConnection);
    connect(m_tcpSocket,  SIGNAL(error(QAbstractSocket::SocketError)),
            this, SLOT(ErrorHandler(QAbstractSocket::SocketError)),
            Qt::DirectConnection);
    connect(m_tcpSocket,  SIGNAL(aboutToClose()),
            this, SLOT(AboutToCloseHandler()));
    connect(m_tcpSocket,  SIGNAL(disconnected()),
            this, SLOT(DisconnectHandler()),
            Qt::DirectConnection);
    connect(m_tcpSocket,  SIGNAL(readyRead()),
            this, SLOT(ReadyReadHandler()),
            Qt::DirectConnection);

    connect(this, SIGNAL(CallReadyRead()),
            this, SLOT(CallReadyReadHandler()),
            Qt::QueuedConnection);

    if (socket != -1)
    {
        m_tcpSocket->setSocketDescriptor(
            socket, QAbstractSocket::ConnectedState,
            QAbstractSocket::ReadWrite);

        ConnectHandler(); // already called implicitly above?
    }

    if (!use_shared_thread)
    {
        m_thread = new MThread(QString("MythSocketThread(%1)").arg(socket));
        m_thread->start();
    }
    else
    {
        QMutexLocker locker(&s_thread_lock);
        if (!s_thread)
        {
            s_thread = new MThread("SharedMythSocketThread");
            s_thread->start();
        }
        m_thread = s_thread;
        s_thread_cnt++;
    }

    m_tcpSocket->moveToThread(m_thread->qthread());
    moveToThread(m_thread->qthread());
}
Ejemplo n.º 25
0
Composer::Composer(QWidget *parent) :
    QWidget(parent),
    ui(new Ui::Composer){
    ui->setupUi(this);
    socket = new QTcpSocket();
    //socket->setProxy(QNetworkProxy(QNetworkProxy::HttpProxy,"127.0.0.1",8999));
    connect(socket,SIGNAL(connected()),SLOT(onConnected()));
    connect(socket,SIGNAL(error(QAbstractSocket::SocketError)),SLOT(onError(QAbstractSocket::SocketError)));
    connect(socket,SIGNAL(aboutToClose()),SLOT(onClose()));
    connect(socket,SIGNAL(readyRead()),SLOT(onData()));

    connect(ui->connectbtn,SIGNAL(clicked()),SLOT(onConnectBtnClick()));
    connect(ui->sendbtn,SIGNAL(clicked()),SLOT(onSendBtnClick()));
    connect(ui->disconnectbtn,SIGNAL(clicked()),SLOT(onDisConnectBtnClick()));

    setAcceptDrops(true);

    ui->requestsComboBox->clear();

    QStringList requestStr;
    requestStr<<"w.l.qq.com"<<"80"<<
        "GET /lview?type=text&callback=auto_gen_1&loc=QQ_FC_RX_text1,QQ_FC_RX_text2,QQ_FC_RX_text3,QQ_FC_RX_text4,QQ_FC_RX_text5,QQ_FC_DZ_text1,QQ_FC_DZ_text2,QQ_FC_DZ_text3,QQ_FC_DZ_text4,QQ_FC_DZ_text5,QQ_FC_XP_text1,QQ_FC_XP_text2,QQ_FC_XP_text3,QQ_FC_XP_text4,QQ_FC_XP_text5,QQ_FC_ESF_text1,QQ_FC_ESF_text2,QQ_FC_ESF_text3,QQ_FC_ESF_text4,QQ_FC_ESF_text5,QQ_SX_ZS_Test1,QQ_SX_ZS_Test2,QQ_SX_ZS_Test3,QQ_SX_ZS_Test4,QQ_SX_ZS_Test5,QQ_SX_ZS_Test6,QQ_SX_ZS_Test7,QQ_SX_ZS_Test8,QQ_SX_ZS_Test9,QQ_SX_ZS_Test10,QQ_SX_LX_Test1,QQ_SX_LX_Test2,QQ_SX_LX_Test3,QQ_SX_LX_Test4,QQ_SX_LX_Test5,QQ_SX_LX_Test6,QQ_SX_LX_Test7,QQ_SX_LX_Test8,QQ_SX_LX_Test9,QQ_SX_LX_Test10&k=&t=%E8%85%BE%E8%AE%AF%E9%A6%96%E9%A1%B5&r=&s= HTTP/1.1"
        "\nHost: w.l.qq.com"
        "\nConnection: keep-alive"
        "\nAccept-Encoding: identity;q=1, *;q=0"
        "\nUser-Agent: Mozilla/5.0 (Windows NT 6.1) AppleWebKit/535.11 (KHTML, like Gecko) Chrome/17.0.963.46 Safari/535.11"
        "\nAccept: */*"
        "\nReferer: http://im.qq.com/macqq/index.shtml"
        "\nAccept-Language: zh-CN,zh;q=0.8"
        "\nAccept-Charset: gb18030,utf-8;q=0.7,*;q=0.3"
        "\nCookie: pgv_r_cookie=116156043288; sd_machines=-1|-1|-1|-1; comment_uin=164473028 %u0069%u0070%u0074%u0074%u006f%u006e; comment_skey=e7eadd2dda7ad02007b2aa2da36d34a7+iptton; old_friend=true; lv_irt_id=fe103783d2a200ef99be838e606bae5d; pvid=8739289251; mbCardUserNotLoginTips=1; pt2gguin=o0164473028; ptisp=ctc; show_id=; o_cookie=164473028; verifysession=h005f594834a73e2d5de281414f85629403925acc6e89b25a779dcb0a60d2147ed189c5a866140b5cc7; pgv_pvid=o_cookie=164473028; pgv_info=ssid=s9100271653&pgvReferrer="
        "\nRange: bytes=48-6116217"
        "\n\n";
    _requests.append(requestStr);
    ui->requestsComboBox->addItem(requestStr.at(0));
    requestStr.clear();

    requestStr<<"w.qq.com"<<"80"<<
                "GET /css/webmini_main.css HTTP/1.1"
                "\nHost: w.qq.com"
                "\n\n";
    _requests.append(requestStr);
    ui->requestsComboBox->addItem(requestStr.at(0));
    requestStr.clear();

    requestStr<<"www.anjiala.com"<<"80"<<
                "GET /design/showview/2012-01-30/21393.html HTTP/1.1"
                "\nHost: www.anjiala.com"
                "\n\n";
    _requests.append(requestStr);
    ui->requestsComboBox->addItem(requestStr.at(0));
    requestStr.clear();



    requestStr<<"trace.qq.com"<<"80"<<
                "GET /collect?pj=1990&dm=w.qq.com&url=/&arg=&rdm=&rurl=&rarg=&icache=-&uv=&nu=&ol=&loc=http%3A//w.qq.com/&column=&subject=&nrnd=164473028&rnd=852 HTTP/1.1"
                "\nHost: trace.qq.com"
                "\nProxy-Connection: keep-alive"
                "\nCache-Control: no-cache"
                "\nPragma: no-cache"
                "\nUser-Agent: Mozilla/5.0 (Windows NT 6.1) AppleWebKit/535.11 (KHTML, like Gecko) Chrome/17.0.963.46 Safari/535.11"
                "\nAccept: */*"
                "\nReferer: http://w.qq.com/"
                "\nAccept-Encoding: gzip,deflate,sdch"
                "\nAccept-Language: zh-CN,zh;q=0.8"
                "\nAccept-Charset: gb18030,utf-8;q=0.7,*;q=0.3"
                "\nCookie: pgv_r_cookie=116156043288; sd_machines=-1|-1|-1|-1; comment_uin=164473028 %u0069%u0070%u0074%u0074%u006f%u006e; comment_skey=e7eadd2dda7ad02007b2aa2da36d34a7+iptton; old_friend=true; lv_irt_id=fe103783d2a200ef99be838e606bae5d; pvid=8739289251; pt2gguin=o0164473028; qv_swfrfh=news.qq.com; qv_swfrfc=v2; verifysession=h008080f4865e1b20be8cba15fcb6b9a12b76209b5fe0c5e0355f92fe120c004d13ec81fb98ec036d86; pgv_pvid=o_cookie=164473028; pgv_info=ssid=s9694936942&pgvReferrer=; o_cookie=164473028"
                "\n\n";
    _requests.append(requestStr);
    ui->requestsComboBox->addItem(requestStr.at(0));
    requestStr.clear();

    requestStr<<"qt.gtimg.cn"<<"80"<<
                "GET /0.7963608948048204&q=s_sh000001 HTTP/1.1"
                "\nHost: qt.gtimg.cn"
                "\nProxy-Connection: keep-alive"
                "\nUser-Agent: Mozilla/5.0 (Windows NT 5.1) AppleWebKit/535.7 (KHTML, like Gecko) Chrome/16.0.912.63 Safari/535.7"
                "\nAccept: */*"
                "\nReferer: http://www.qq.com/"
                "\nAccept-Encoding: gzip,deflate,sdch"
                "\nAccept-Language: zh-CN,zh;q=0.8"
                "\nAccept-Charset: gb18030,utf-8;q=0.7,*;q=0.3"
                "\n\n";
    _requests.append(requestStr);
    ui->requestsComboBox->addItem(requestStr.at(0));
    requestStr.clear();


    requestStr<<"bbs.anjiala.com"<<"80"<<
                "GET /member.php?mod=loginstatus HTTP/1.1"
                "\nHost: bbs.anjiala.com"
                "\nConnection: keep-alive"
                "\nUser-Agent: Mozilla/5.0 (Windows NT 5.1) AppleWebKit/535.7 (KHTML, like Gecko) Chrome/16.0.912.63 Safari/535.7"
                "\nAccept: */*"
                "\nReferer: http://www.anjiala.com/design/showview/2012-01-30/21393.html"
                "\nAccept-Encoding: gzip,deflate,sdch"
                "\nAccept-Language: zh-CN,zh;q=0.8"
                "\nAccept-Charset: gb18030,utf-8;q=0.7,*;q=0.3"
                "\nCookie: gQHG_a52f_lastvisit=1329015447; gQHG_a52f_sid=G80s6O; gQHG_a52f_lastact=1329024158%09member.php%09loginstatus"
                "\n\n";
    _requests.append(requestStr);
    ui->requestsComboBox->addItem(requestStr.at(0));
    requestStr.clear();




    connect(ui->requestsComboBox,SIGNAL(currentIndexChanged(int)),SLOT(onRequestChanged(int)));


    ui->connectbtn->setDisabled(false);
    ui->sendbtn->setDisabled(true);
    ui->disconnectbtn->setDisabled(true);

    //connectToHost();
}
Ejemplo n.º 26
0
LayeredStream::LayeredStream(QIODevice* baseDevice)
    : QIODevice(baseDevice)
    , m_baseDevice(baseDevice)
{
    connect(baseDevice, SIGNAL(aboutToClose()), SLOT(closeStream()));
}
Ejemplo n.º 27
0
Void PlaYUVerMdiSubWindow::closeEvent( QCloseEvent *event )
{
  emit aboutToClose( this );
  event->accept();
}
Ejemplo n.º 28
0
NotificationDialog::NotificationDialog(Notification *notification, QWidget *parent) : QDialog(parent),
	m_notification(notification),
	m_closeLabel(NULL)
{
	QFrame *notificationFrame = new QFrame(this);
	notificationFrame->setObjectName(QLatin1String("notificationFrame"));
	notificationFrame->setStyleSheet(QLatin1String("#notificationFrame {padding:5px;border:1px solid #CCC;border-radius:10px;background:#F0F0f0;}"));
	notificationFrame->setCursor(QCursor(Qt::PointingHandCursor));
	notificationFrame->installEventFilter(this);

	QBoxLayout *mainLayout = new QBoxLayout(QBoxLayout::LeftToRight);
	mainLayout->setContentsMargins(0, 0, 0, 0);
	mainLayout->setSpacing(0);
	mainLayout->setSizeConstraint(QLayout::SetMinimumSize);
	mainLayout->addWidget(notificationFrame);

	QLabel *iconLabel = new QLabel(this);
	iconLabel->setPixmap(Utils::getIcon(QLatin1String("otter-browser-32")).pixmap(32, 32));
	iconLabel->setStyleSheet(QLatin1String("padding:5px;"));

	QLabel *messageLabel = new QLabel(this);
	messageLabel->setText(m_notification->getMessage());
	messageLabel->setStyleSheet(QLatin1String("padding:5px;font-size:13px;"));
	messageLabel->setWordWrap(true);

	QStyleOption option;
	option.rect = QRect(0, 0, 16, 16);

	QPixmap pixmap(16, 16);
	pixmap.fill(Qt::transparent);

	QPainter painter(&pixmap);

	style()->drawPrimitive(QStyle::PE_IndicatorTabClose, &option, &painter, this);

	m_closeLabel = new QLabel(notificationFrame);
	m_closeLabel->setToolTip(tr("Close"));
	m_closeLabel->setPixmap(pixmap);
	m_closeLabel->setAlignment(Qt::AlignTop);
	m_closeLabel->setMargin(5);
	m_closeLabel->installEventFilter(this);

	QBoxLayout *notificationLayout = new QBoxLayout(QBoxLayout::LeftToRight);
	notificationLayout->setContentsMargins(0, 0, 0, 0);
	notificationLayout->setSpacing(0);
	notificationLayout->setSizeConstraint(QLayout::SetMinimumSize);
	notificationLayout->addWidget(iconLabel);
	notificationLayout->addWidget(messageLabel);
	notificationLayout->addWidget(m_closeLabel);

	notificationFrame->setLayout(notificationLayout);

	setLayout(mainLayout);
	setFixedWidth(400);
	setMinimumHeight(50);
	setMaximumHeight(150);
	setWindowOpacity(0);
	setWindowFlags(Qt::WindowStaysOnTopHint | Qt::Tool | Qt::FramelessWindowHint);
	setFocusPolicy(Qt::NoFocus);
	setAttribute(Qt::WA_ShowWithoutActivating);
	setAttribute(Qt::WA_TranslucentBackground);
	adjustSize();

	m_animation = new QPropertyAnimation(this, QStringLiteral("windowOpacity").toLatin1());
	m_animation->setDuration(500);
	m_animation->setStartValue(0.0);
	m_animation->setEndValue(1.0);
	m_animation->start();

	const int visibilityDuration = SettingsManager::getValue(QLatin1String("Interface/NotificationVisibilityDuration")).toInt();

	if (visibilityDuration > 0)
	{
		QTimer::singleShot((visibilityDuration * 1000), this, SLOT(aboutToClose()));
	}
}
Ejemplo n.º 29
0
void Window::close()
{
	emit aboutToClose();

	QTimer::singleShot(50, this, SLOT(notifyRequestedCloseWindow()));
}
Ejemplo n.º 30
0
void Nuria::ReferenceDevice::close () {
	setOpenMode (NotOpen);
	emit aboutToClose ();
}