Exemplo n.º 1
0
void MainWindow::startServer()
{
    if(!db || !db->isOpen()) {
        QMessageBox::information(this, tr("No database"),
                                 tr("you need to configure database for server at first..."));
        return;
    }
    if(server) {
        server->close();
        delete server;
    }

    server = new FSEServer(this);
    server->setDatabase(db);

    connect(server, SIGNAL(acceptError(QAbstractSocket::SocketError)),
            this, SLOT(socketError(QAbstractSocket::SocketError)));
    connect(server, SIGNAL(errorString(QString)),
            this, SLOT(logCollect(QString)));
    connect(server, SIGNAL(debugString(QString)),
            this, SLOT(logCollect(QString)));

    if(server->listen(QHostAddress(IPv4), serverPort)) {
        logCollect(tr("start to listen ") + IPv4 + ":" +QString::number(serverPort));
        stateChange(ServerWorking);
    }
    else {
        qDebug() << "start failed" << server->serverError();
        stopServer();
    }
}
bool CTcpServer::SetTcpServerIP_Port(const QHostAddress &TcpServer_HostAddress_, const quint16 nTcpServer_Port_)
{
    m_TcpServer_HostAddress = TcpServer_HostAddress_;
    m_nTcpServer_Port = nTcpServer_Port_;
    if (NULL == m_pTcpServer)
    {
        m_pTcpServer = new QTcpServer(this);
        connect(m_pTcpServer,SIGNAL(acceptError(QAbstractSocket::SocketError)),this,SLOT(Slot_TcpServer_acceptError(QAbstractSocket::SocketError)));
        connect(m_pTcpServer,SIGNAL(newConnection()),this,SLOT(Slot_TcpServer_newConnection()));
    }else
    {

    }

    if (m_bTcpServer_IsListening)
    {

    }else
    {
        m_bTcpServer_IsListening = m_pTcpServer->listen(m_TcpServer_HostAddress,m_nTcpServer_Port);
        //    int nListen2 = m_pTcpServer->waitForNewConnection();
        qDebug()<<__func__<<"m_bTcpServer_IsListening ="<<m_bTcpServer_IsListening;
        if (m_bTcpServer_IsListening)
        {

        }else
        {
            QTimer::singleShot(10000,this,SLOT(Slot_TcpServer_Listen()));
        }
    }
    return m_bTcpServer_IsListening;
}
Exemplo n.º 3
0
bool WebServer::setupTcp(quint16 port){
  TCPServer = new SslServer(this);
  //Setup Connections
  connect(TCPServer, SIGNAL(newConnection()), this, SLOT(NewSocketConnection()) );
  connect(TCPServer, SIGNAL(acceptError(QAbstractSocket::SocketError)), this, SLOT(NewConnectError(QAbstractSocket::SocketError)) );
  //Now start the server
  return TCPServer->listen(QHostAddress::Any, port);	
}
Exemplo n.º 4
0
void QListenerThread::InitializeSubThread( )
{
    pTcpServer = new QMyTcpServer( );
    pSocketDispatcher = QSocketDispatcherThread::CreateThread( );

    connect( pTcpServer, SIGNAL( acceptError( QAbstractSocket::SocketError ) ),
             this, SLOT( HandleAcceptError( QAbstractSocket::SocketError ) ) );
    connect( pSocketDispatcher, SIGNAL( Log( QString, bool ) ),
             this, SLOT( HandleLog( QString, bool ) ) );
}
Exemplo n.º 5
0
GTcpServer::GTcpServer(QObject *parent,VM *pVM)  : QTcpServer(parent)
{
	this->pVM = pVM;
	this->pParaList = ring_list_new(0);
	strcpy(this->cacceptErrorEvent,"");
	strcpy(this->cnewConnectionEvent,"");

	QObject::connect(this, SIGNAL(acceptError(QAbstractSocket::SocketError)),this, SLOT(acceptErrorSlot()));
	QObject::connect(this, SIGNAL(newConnection()),this, SLOT(newConnectionSlot()));

}
Exemplo n.º 6
0
HostedCall::HostedCall(ClientWorker &worker, QObject *parent) :
    QObject(parent),
    _worker(worker)
{
    this->_stopping = false;
    this->_stopMutex = new myMutex();
    connect(&this->_tcpServer, SIGNAL(newConnection()), this, SLOT(receiveNewTcpConnection()));
    connect(&this->_tcpServer, SIGNAL(acceptError(QAbstractSocket::SocketError)), this, SLOT(onAcceptError(QAbstractSocket::SocketError)));

    connect(&this->_udpServer, SIGNAL(readyRead()), this, SLOT(receiveUdp()));
    this->_sManager = new PortAudioSoundManager(this->_container, this);
}
Exemplo n.º 7
0
//===================
//     PRIVATE
//===================
bool WebServer::setupWebSocket(quint16 port){
  WSServer = new QWebSocketServer("sysadm-server", QWebSocketServer::SecureMode, this);
  //SSL Configuration
  QSslConfiguration config = QSslConfiguration::defaultConfiguration();
	QFile CF( QStringLiteral(SSLCERTFILE) ); 
	  if(CF.open(QIODevice::ReadOnly) ){
	    QSslCertificate CERT(&CF,QSsl::Pem);
	    config.setLocalCertificate( CERT );
	    CF.close();   
	  }else{
	    qWarning() << "Could not read WS certificate file:" << CF.fileName();
	  }
	QFile KF( QStringLiteral(SSLKEYFILE));
	  if(KF.open(QIODevice::ReadOnly) ){
	    QSslKey KEY(&KF, QSsl::Rsa, QSsl::Pem);
	    config.setPrivateKey( KEY );
	    KF.close();	
	  }else{
	    qWarning() << "Could not read WS key file:" << KF.fileName();
	  }
	config.setPeerVerifyMode(QSslSocket::VerifyNone);
	config.setProtocol(SSLVERSION);
  WSServer->setSslConfiguration(config);
  //Setup Connections
  connect(WSServer, SIGNAL(newConnection()), this, SLOT(NewSocketConnection()) );
  connect(WSServer, SIGNAL(acceptError(QAbstractSocket::SocketError)), this, SLOT(NewConnectError(QAbstractSocket::SocketError)) );
  //  -- websocket specific signals
  connect(WSServer, SIGNAL(closed()), this, SLOT(ServerClosed()) );
  connect(WSServer, SIGNAL(serverError(QWebSocketProtocol::CloseCode)), this, SLOT(ServerError(QWebSocketProtocol::CloseCode)) );
  connect(WSServer, SIGNAL(originAuthenticationRequired(QWebSocketCorsAuthenticator*)), this, SLOT(OriginAuthRequired(QWebSocketCorsAuthenticator*)) );
  connect(WSServer, SIGNAL(peerVerifyError(const QSslError&)), this, SLOT(PeerVerifyError(const QSslError&)) );
  connect(WSServer, SIGNAL(sslErrors(const QList<QSslError>&)), this, SLOT(SslErrors(const QList<QSslError>&)) );
  connect(WSServer, SIGNAL(acceptError(QAbstractSocket::SocketError)), this, SLOT(ConnectError(QAbstractSocket::SocketError)) );
  //Now start the server
  return WSServer->listen(QHostAddress::Any, port);
}
Exemplo n.º 8
0
void MyServer::incomingConnection(qintptr socketDescriptor)
{
    qDebug("incoming ... ");
    socket = new QTcpSocket(this);
    socket->setSocketDescriptor(socketDescriptor);
    connect(socket, SIGNAL(readyRead()), this, SLOT(solveReadBuf()));
    connect(socket, SIGNAL(disconnected()), socket, SLOT(deleteLater()));

    connect(this, SIGNAL(acceptError(QAbstractSocket::SocketError)), this, SLOT(solveError(QAbstractSocket::SocketError)));

    connect(myTimer, SIGNAL(timeout()), this, SLOT(sendHeartBeat()));
    connect(timeOut, SIGNAL(timeout()), this, SLOT(heartBeatTimeOut()));
    myTimer->start(1000 * 15);
    qDebug("start Timer ... ");
}
Exemplo n.º 9
0
//=======================
//              PUBLIC
//=======================
WebServer::WebServer() : QWebSocketServer("pc-restserver", QWebSocketServer::NonSecureMode){
  csock = 0; //no current socket connected
  //Setup all the various settings
  idletimer = new QTimer(this);
    idletimer->setInterval(5000); //every 5 seconds
    idletimer->setSingleShot(true);
  //Any SSL changes
    /*QSslConfiguration ssl = this->sslConfiguration();
      ssl.setProtocol(QSsl::SecureProtocols);
    this->setSslConfiguration(ssl);*/

  //Setup Connections
  connect(idletimer, SIGNAL(timeout()), this, SLOT(checkIdle()) );
  connect(this, SIGNAL(closed()), this, SLOT(ServerClosed()) );
  connect(this, SIGNAL(serverError(QWebSocketProtocol::CloseCode)), this, SLOT(ServerError(QWebSocketProtocol::CloseCode)) );
  connect(this, SIGNAL(newConnection()), this, SLOT(NewSocketConnection()) );
  connect(this, SIGNAL(acceptError(QAbstractSocket::SocketError)), this, SLOT(NewConnectError(QAbstractSocket::SocketError)) );
  connect(this, SIGNAL(originAuthenticationRequired(QWebSocketCorsAuthenticator*)), this, SLOT(OriginAuthRequired(QWebSocketCorsAuthenticator*)) );
  connect(this, SIGNAL(peerVerifyError(const QSslError&)), this, SLOT(PeerVerifyError(const QSslError&)) );
  connect(this, SIGNAL(sslErrors(const QList<QSslError>&)), this, SLOT(SslErrors(const QList<QSslError>&)) );
}
Exemplo n.º 10
0
void Server::listen() {
    if (server->listen()) {
        // change network interface
        QString ipAddress;
        QList<QHostAddress> ipAddressesList = QNetworkInterface::allAddresses();
        for (int i = 0; i < ipAddressesList.size(); ++i) {
            if (ipAddressesList.at(i) != QHostAddress::LocalHost &&
                    ipAddressesList.at(i).toIPv4Address()) {
                ipAddress = ipAddressesList.at(i).toString();
                break;
            }
        }
        if (ipAddress.isEmpty())
            ipAddress = QHostAddress(QHostAddress::LocalHost).toString();

        connect(server, SIGNAL(newConnection()), this, SLOT(onNewConnection()));
        connect(server, SIGNAL(acceptError(QAbstractSocket::SocketError)), this, SLOT(onServerError(QAbstractSocket::SocketError)));

        printReport(tr("The server is running on IP: %1 port: %2").arg(ipAddress).arg(server->serverPort()));
    }
    else
        printReport(tr("Unable to start the server: %1").arg(server->errorString()));

}
Exemplo n.º 11
0
Xaman::Xaman(QWidget *parent) :
    QMainWindow(parent),
    ui(new Ui::Xaman)
{
    ui->setupUi(this);

    Q_INIT_RESOURCE(resource);
    init();

    this->server = new QTcpServer(this);
    connect(this->server, SIGNAL(acceptError(QAbstractSocket::SocketError)), this, SLOT(server_Error()));
    connect(this->server, SIGNAL(newConnection()), this, SLOT(server_Connected()));

    //if(server->listen(QHostAddress::LocalHost, 6000)){
    if(server->listen(QHostAddress::Any, 6000)){
        qDebug() << "Escuchando";
    }

    //BOTONES DE LA INTERFAZ
    connect(ui->widget->controls, SIGNAL(changeVolume(int)), this, SLOT(test(int)));
    connect(ui->widget->controls, SIGNAL(play()), this, SLOT(remotePlay()));
    connect(ui->widget->controls, SIGNAL(stop()), this, SLOT(remoteStop()));
    connect(ui->widget->controls, SIGNAL(pause()), this, SLOT(remotePause()));
    connect(ui->widget->controls, SIGNAL(next()), this, SLOT(remoteNext()));
    connect(ui->widget->controls, SIGNAL(previous()), this, SLOT(remotePrevious())); 
    
    
    //CREACION DE EL ESTILO DE LA INTERFAZ
    ui->tabWidget->setStyleSheet("QTabWidget::pane { border: transparent;}"
                                 "QTabWidget::tab-bar {left: 0px;"
                                 "}"
                                 "QTabBar::tab {"
                                     "background: #000000;"
                                     "border: transparent;"
                                     "border-top: 5px solid #D8FF00;"
                                     "color: white;"
                                     "min-width: 8ex;"
                                     "padding: 2px;"
                                     "width: 495px;"
                                     "height: 23px"
                                     "}"
                                     "QTabBar::tab:selected, QTabBar::tab:hover {"

                                      "color: black;"
                                      "background: url(':/images/Iconos/pestania_principal.png') #000000 ;}"
                                      "QTabBar::tab:!selected {margin-top: 0px;}");

    ui->Contenido->setStyleSheet(  "QTabWidget::tab-bar {left: 14px;"
                                   "}"
                                   "QTabBar::tab {"
                                   "background: #000000;"
                                   "border: transparent;"
                                   "border-top: 1px solid #D8FF00;"
                                   "color: white;"
                                   "min-width: 8ex;"
                                   "padding: 2px;"
                                   "width: 320px;"
                                   "height: 29px"
                                   "}"
                                   "QTabBar::tab:selected, QTabBar::tab:hover {"

                                    "color: black;"
                                    "background: url(':/images/Iconos/pestania_libreria.png') no-repeat #000000 ;}"
                                    "QTabBar::tab:!selected {margin-top: 0px;}" );


    ui->Content_Shows->setStyleSheet("QHeaderView::section {background-color: qlineargradient(x1:0, y1:0, x2:0, y2:1, stop:0 #505050, stop: 0.2 #404040, stop: 0.4 #303030 , stop: 0.6 #202020 , stop: 0.8 #101010, stop: 1 #080808 );border: transparent; "
                                     "height: 38px;"
                                     "text-align: center;"
                                     "}"
                                     "QTreeWidget{border: transparent;}"

                                     "QTreeView::item {"
                                         "border-bottom: 1px solid  #686868;"
                                         "height: 23px"
                                     "}"
                                     "QTreeView::item:hover {"
                                         "background: transparent;"
                                         "border: 1px solid #ffffff;"
                                         "border-left: 0px solid #25282A;"
                                         "border-right: 0px solid #25282A;"
                                         "color: #d8ff00;"
                                     "}"
                                     "QTreeView::item:selected:active{"
                                        "background: transparent;"
                                        "border: 1px solid #ffffff;"
                                        "border-left: 0px"
                                        "border-right: 0px"
                                        "color: #ffffff;"

                                     "}"
                                     "QTreeView  {"
                                         "show-decoration-selected: 1;"
                                         "color: #d8ff00;"

                                     "}"
                                     );
    ui->Content_Musica->setStyleSheet("QHeaderView::section {background-color: qlineargradient(x1:0, y1:0, x2:0, y2:1, stop:0 #505050, stop: 0.2 #404040, stop: 0.4 #303030 , stop: 0.6 #202020 , stop: 0.8 #101010, stop: 1 #080808 );border: transparent; "
                                     "height: 38px;"
                                     "text-align: center;"
                                     "}"
                                     "QTreeWidget{border: transparent;}"

                                     "QTreeView::item {"
                                         "border-bottom: 1px solid  #686868;"
                                         "height: 23px"
                                     "}"
                                     "QTreeView::item:hover {"
                                         "background: transparent;"
                                         "border: 1px solid #ffffff;"
                                         "border-left: 0px solid #25282A;"
                                         "border-right: 0px solid #25282A;"
                                         "color: #d8ff00;"
                                     "}"
                                     "QTreeView::item:selected:active{"
                                        "background: transparent;"
                                        "border: 1px solid #ffffff;"
                                        "border-left: 0px"
                                        "border-right: 0px"
                                        "color: #ffffff;"

                                     "}"
                                     "QTreeView  {"
                                         "show-decoration-selected: 1;"
                                         "color: #d8ff00;"

                                     "}"


                                     );
    ui->Content_Imagenes->setStyleSheet("QHeaderView::section {background-color: qlineargradient(x1:0, y1:0, x2:0, y2:1, stop:0 #505050, stop: 0.2 #404040, stop: 0.4 #303030 , stop: 0.6 #202020 , stop: 0.8 #101010, stop: 1 #080808 );border: transparent; "
                                        "height: 38px;"
                                        "text-align: center;"
                                        "}"
                                        "QTreeWidget{border: transparent;}"

                                        "QTreeView::item {"
                                            "border-bottom: 1px solid  #686868;"
                                            "height: 23px"
                                        "}"
                                        "QTreeView::item:hover {"
                                            "background: transparent;"
                                            "border: 1px solid #ffffff;"
                                            "border-left: 0px solid #25282A;"
                                            "border-right: 0px solid #25282A;"
                                            "color: #d8ff00;"
                                        "}"
                                        "QTreeView::item:selected:active{"
                                           "background: transparent;"
                                           "border: 1px solid #ffffff;"
                                           "border-left: 0px"
                                           "border-right: 0px"
                                           "color: #ffffff;"

                                        "}"
                                        "QTreeView  {"
                                            "show-decoration-selected: 1;"
                                            "color: #d8ff00;"

                                        "}"

                                     );

    ui->Content_Shows->header()->setDefaultAlignment(Qt::AlignCenter);

    ui->Content_Imagenes->header()->setDefaultAlignment(Qt::AlignCenter);

    ui->Content_Musica->header()->setDefaultAlignment(Qt::AlignCenter);

    ui->treeWidget->setStyleSheet("QHeaderView::section {background-color: qlineargradient(x1:0, y1:0, x2:0, y2:1, stop:0 #505050, stop: 0.2 #404040, stop: 0.4 #303030 , stop: 0.6 #202020 , stop: 0.8 #101010, stop: 1 #080808 );border: transparent; "
                                  "height: 45px;"
                                  "text-align: center;"
                                  "}"
                                  "QTreeWidget{border: transparent;}"

                                  "QTreeView::item {"

                                      "border-bottom: 1px solid  #686868;"
                                      "height: 30px"
                                  "}"
                                  "QTreeView::item:hover {"
                                      "background: transparent;"
                                      "border-top: 1px solid #ffffff;"
                                      "border-bottom: 1px solid  #ffffff;"

                                      "color: #d8ff00;"
                                  "}"

                                  );
    ui->treeWidget->header()->setDefaultAlignment(Qt::AlignCenter);
    ui->treeWidget->setFocusPolicy(Qt::NoFocus);
    ui->btn_addPlaylist->setIcon(QIcon(":/images/Iconos/listanueva_icon.png"));
    ui->btn_addPlaylist->setIconSize(QSize(30,30));
    ui->btn_addPlaylist->setStyleSheet("QToolButton{ background: rgba(0,0,0,0%);  border: transparent;}");

    ui->verticalSlider->setStyleSheet("QSlider::groove:vertical {"
                                      "border: 0px solid #d0eb46;"
                                      "background: white;"
                                      "border-radius: 4px;"
                                      "}"

                                      "QSlider::sub-page:vertical {"
                                      "background: qlineargradient(x1: 0, y1: 0,    x2: 0, y2: 1,"
                                          "stop: 0 #d0eb46;, stop: 1 #d0eb46;);"
                                      "background: qlineargradient(x1: 0, y1: 0.2, x2: 1, y2: 1,"
                                          "stop: 0 #d0eb46 , stop: 1 #000000;);"
                                      "border: 1px solid #d0eb46;"
                                      "border-radius: 4px;"
                                      "}"

                                      "QSlider::add-page:vertical {"
                                      "background: #d0eb46;"
                                      "border: 1px solid #777;"

                                      "border-radius: 4px;"
                                      "}"

                                      "QSlider::handle:vertical {"
                                      "background: qlineargradient(x1:0, y1:0, x2:1, y2:1,"
                                          "stop:0 #eee, stop:1 #ccc);"
                                      "border: 1px solid #777;"
                                      "width: 3px;"
                                      "margin-top: 5px;"
                                      "margin-bottom: 5px;"
                                      "border-radius: 4px;"
                                      "}"

                                      "QSlider::handle:vertical:hover {"
                                      "background: qlineargradient(x1:0, y1:0, x2:1, y2:1,"
                                      "stop:0 #fff, stop:1 #ddd);"
                                      "border: 1px solid #444;"
                                      "border-radius: 4px;"
                                      "}"

                                      "QSlider::sub-page:vertical:disabled {"
                                      "background: #d0eb46;"
                                      "border-color: #999;"
                                      "}"

                                      "QSlider::add-page:vertical:disabled {"
                                      "background: #eee;"
                                      "border-color: #999;"
                                      "}"

                                      "QSlider::handle:vertical:disabled {"
                                      "background: #eee;"
                                      "border: 1px solid #aaa;"
                                      "border-radius: 4px;"
                                      "}");
    ui->playlist->setStyleSheet("QScrollArea { border: transparent; background-color: rgba(0,0,0,0%); }");
    
    //DECLARACION DE LOS BOTONES DE ACCESO DIRECTO
    QAction *shortcut = new QAction(this);
    shortcut->setShortcut(Qt::CTRL | Qt::ALT | Qt::Key_H);;

    connect(shortcut, SIGNAL(triggered(bool)), this, SLOT(addXaman()));
    this->addAction(shortcut);
}