示例#1
0
void LoginDialog::readyRead()
{
    qDebug()<<"readyRead";
//    QDataStream in(socket);
//    if (socket->bytesAvailable()<(int)sizeof(quint16)){
//        qDebug()<<"bytes available < quint16";
//        return;
//    }
//    quint16 blockSize;
//    in>>blockSize;
//    qDebug()<<"Block size"<<blockSize;
//    quint8 command;
//    in>>command;
//    qDebug()<<"Command"<< command;
    QString result;
    switch(Connection::readMessage(socket, result)){
    case Connection::AUTH_SECCESSFULL:
        UserWindow *userswindow = new UserWindow(socket);
        this->hide();
        disconnect(socket, SIGNAL(readyRead()),this, SLOT(readyRead()));
        disconnect(socket, SIGNAL(connected()), this, SLOT(connected()));
        disconnect(socket, SIGNAL(error(QAbstractSocket::SocketError)),
                this, SLOT(onConnectionError(QAbstractSocket::SocketError)));
        disconnect(socket, SIGNAL(stateChanged(QAbstractSocket::SocketState)),
                this , SLOT(onStateChanged(QAbstractSocket::SocketState)));
        userswindow->show();
        break;
    }

}
示例#2
0
void SecureFileUploader::upload(const QString &localFile, const QString &dest, const QString &host,
                                const QString &username, const QString &passwd)
{
    QFileInfo info(localFile);

    m_localFilename = info.canonicalFilePath();
    m_remoteFilename = dest + "/" + info.fileName();

    QSsh::SshConnectionParameters params;
    params.host = host;
    params.userName = username;
    params.password = passwd;
    params.authenticationType = QSsh::SshConnectionParameters::AuthenticationTypePassword;
    params.timeout = 30;
    params.port = 22;

    m_connection = new QSsh::SshConnection(params, this); // TODO free this pointer!

    connect(m_connection, SIGNAL(connected()), SLOT(onConnected()));
    connect(m_connection, SIGNAL(error(QSsh::SshError)), SLOT(onConnectionError(QSsh::SshError)));

    qDebug() << "SecureUploader: Connecting to host" << host;

    m_connection->connectToHost();
}
示例#3
0
LoginDialog::LoginDialog(QWidget *parent) :
    QDialog(parent),
    ui(new Ui::LoginDialog)
{
    ui->setupUi(this);
    ui->groupMore->hide();
    layout()->setSizeConstraint(QLayout::SetFixedSize);
    socket = new QTcpSocket(this);
    connect(socket, SIGNAL(readyRead()),this, SLOT(readyRead()));
    connect(socket, SIGNAL(connected()), this, SLOT(connected()));
    connect(socket, SIGNAL(error(QAbstractSocket::SocketError)),
            this, SLOT(onConnectionError(QAbstractSocket::SocketError)));
    connect(socket, SIGNAL(stateChanged(QAbstractSocket::SocketState)),
            this , SLOT(onStateChanged(QAbstractSocket::SocketState)));
}
示例#4
0
ClientServer::ClientServer(QObject *parent_) :
  Avogadro::QtGui::ExtensionPlugin(parent_),
  m_openAction(new QAction(this)), m_settingsAction(new QAction(this)),
  m_molecule(NULL), m_controller(NULL), m_communicator(NULL), m_channel(NULL)
{
  m_openAction->setEnabled(true);
  m_openAction->setText("Open Molecule");
  m_actions.append(m_openAction);

  m_settingsAction->setEnabled(true);
  m_settingsAction->setText("Settings");
  m_actions.append(m_settingsAction);

  connect(m_openAction, SIGNAL(triggered()), SLOT(openFile()));
  connect(m_settingsAction, SIGNAL(triggered()), SLOT(openSettings()));
  connect(this, SIGNAL(connectionError()), SLOT(onConnectionError()));
}
void Component::handleConnectionError(const ComponentError &error) {
	onConnectionError(error);
// 	if (m_reconnectCount == 2)
// 		Component::instance()->userManager()->removeAllUsers();
	std::string str = "Unknown error";
	switch (error.getType()) {
		case ComponentError::UnknownError: str = "Unknown error"; break;
		case ComponentError::ConnectionError: str = "Connection error"; break;
		case ComponentError::ConnectionReadError: str = "Connection read error"; break;
		case ComponentError::ConnectionWriteError: str = "Connection write error"; break;
		case ComponentError::XMLError: str = "XML Error"; break;
		case ComponentError::AuthenticationFailedError: str = "Authentication failed error"; break;
		case ComponentError::UnexpectedElementError: str = "Unexpected element error"; break;
	}
	LOG4CXX_INFO(logger, "Disconnected from XMPP server. Error: " << str);

	m_reconnectTimer->start();
}
示例#6
0
ConnectWindow::ConnectWindow(QMenu *settingsMenu, QWidget *parent)
    : QWidget(parent),
      state_(STATE_DISCONNECTED),
      pbCancelCon(0),
      pbRestoreGateway(0),
      killSwitch_(NULL),
      getMyVpnIp_(NULL),
      mode_(MODE_OPEN_VPN),
      logDialog_(NULL)
{
    ui.setupUi(this);

#if defined Q_OS_WIN
    QString strUpdatedStyleSheet;
    QString strStyleSheet = ui.tabWidget->styleSheet();
    QString matchStr = "QTabWidget:tab-bar{}";
    int ind = strStyleSheet.indexOf(matchStr);
    Q_ASSERT(ind != -1);
    strUpdatedStyleSheet = strStyleSheet.left(ind);
    strUpdatedStyleSheet += "QTabWidget:tab-bar{left: 100px; top: 10px;}";
    strUpdatedStyleSheet += strStyleSheet.right(strStyleSheet.length() - (ind + matchStr.length()));
    ui.tabWidget->setStyleSheet(strUpdatedStyleSheet);
#endif

    ui.btnSettings->setMenu( settingsMenu );

    showStatistics( false );

    mainWindow_ = (MainWindow *)parent;

    killSwitch_ = new KillSwitch(this);

    QSettings settings;
    ui.cbEnableSmartDNS->setChecked(settings.value("openVpnDNSEnabled", true).toBool());

    /*if (!connection_.initialize())
	{
		QMessageBox::information(this, QApplication::applicationName(), tr("OpenVPN initialize error"));
		QTimer::singleShot(1, parent, SLOT(close()));
		return;
	}

    if (!connection_.tapInstalled())
	{
		QMessageBox::question(this, QApplication::applicationName(), tr("TAP drivers not installed."));
		QTimer::singleShot(1, this, SLOT(close()));
		return;
    }   */

    ui.cbServer->installEventFilter(this);

    logDialog_ = new ShowLog(this);
    connect(g_openVPNConnection, SIGNAL(log(QString)), logDialog_, SLOT(onUpdateLog(QString)));

    updateIP();

    qRegisterMetaType<OPENVPN_ERROR>("OPENVPN_ERROR");

	connect(ui.btnConnect, SIGNAL(clicked()), SLOT(onClickConnect()));
    connect(ui.cbEnableSmartDNS, SIGNAL(stateChanged(int)), SLOT(onDNSEnabledStateChanged(int)));
    connect(ui.pbSmartDnsHelp, SIGNAL(clicked()), SLOT(onSmartDnsHelp()));
    connect(ui.pbSmartDns, SIGNAL(clicked()), SLOT(onClickSmartDns()));
    connect(g_openVPNConnection, SIGNAL(connected()), SLOT(onConnected()));
    connect(g_openVPNConnection, SIGNAL(disconnected()), SLOT(onDisconnected()));
    connect(g_openVPNConnection, SIGNAL(error(OPENVPN_ERROR)), SLOT(onConnectionError(OPENVPN_ERROR)));
    connect(g_openVPNConnection, SIGNAL(disconnected()), SLOT(onDisconnected()));
    connect(g_openVPNConnection, SIGNAL(statisticsUpdated(long, long)), SLOT(onStatisticsChanged(long, long)));
}
bool QGeoSatelliteInfoSourceNpeBackend::init()
{
    m_locationdConn = new LocationDaemonConnection(this);
    //check for Error: Could not connect to socket (locationd not started?)
    if (!m_locationdConn->connected())
        return(false);
    connect(m_locationdConn, SIGNAL(satelliteUpdate(QList<SatelliteData>)), this, SLOT(onSatelliteUpdate(QList<SatelliteData>)));
    connect(m_locationdConn, SIGNAL(connectionError(LocationDaemonConnection::SocketError)), this, SLOT(onConnectionError(LocationDaemonConnection::SocketError)));
    return(true);
}