Ejemplo n.º 1
0
void Nntp::closed()
{
    if ( url() )
	emit connectionStateChanged( ConClosed, tr( "Connection to %1 closed" ).arg( url()->host() ) );
    else
	emit connectionStateChanged( ConClosed, tr( "Connection closed" ) );
}
Ejemplo n.º 2
0
void Robotino::connectionStateChangedEvent( rec::robotino::com::Com::ConnectionState newState, rec::robotino::com::Com::ConnectionState )
{
  if( rec::robotino::com::Com::Connected == newState )
    emit connectionStateChanged( true );
  else if( rec::robotino::com::Com::NotConnected == newState )
    emit connectionStateChanged( false );
}
Ejemplo n.º 3
0
void Nntp::hostFound()
{
    if ( url() )
	emit connectionStateChanged( ConHostFound, tr( "Host %1 found" ).arg( url()->host() ) );
    else
	emit connectionStateChanged( ConHostFound, tr( "Host found" ) );
}
Ejemplo n.º 4
0
void Nntp::connected()
{
    if ( url() )
	emit connectionStateChanged( ConConnected, tr( "Connected to host %1" ).arg( url()->host() ) );
    else
	emit connectionStateChanged( ConConnected, tr( "Connected to host" ) );
}
Ejemplo n.º 5
0
void Http::connected()
{
    if ( url() )
	emit connectionStateChanged( ConConnected, tr( "Connected to host %1" ).arg( url()->host() ) );
    else
	emit connectionStateChanged( ConConnected, tr( "Connected to host" ) );
    connectionReady = TRUE;
}
Ejemplo n.º 6
0
void ConnectionWidget::onReady()
{
    QObject::connect(RTLSDisplayApplication::serialConnection(), SIGNAL(connectionStateChanged(SerialConnection::ConnectionState)),
                     this, SLOT(connectionStateChanged(SerialConnection::ConnectionState)));

    updateDeviceList();

    //connectionStateChanged(SerialConnection::Disconnected);
}
Ejemplo n.º 7
0
void QmvHttp::hostFound()
{
#ifdef QMVHTTP_DEBUG
    qDebug("QmvHttp::hostFound");
#endif
    if ( url() )
	emit connectionStateChanged( ConHostFound, tr( "Host %1 found" ).arg( url()->host() ) );
    else
	emit connectionStateChanged( ConHostFound, tr( "Host found" ) );
}
Ejemplo n.º 8
0
void QmvHttp::connected()
{
#ifdef QMVHTTP_DEBUG
    qDebug("QmvHttp::connected");
#endif
    if ( url() )
	emit connectionStateChanged( ConConnected, tr( "Connected to host %1" ).arg( url()->host() ) );
    else
	emit connectionStateChanged( ConConnected, tr( "Connected to host" ) );
    connectionReady = TRUE;
}
Ejemplo n.º 9
0
void Http::closed()
{
    if ( url() )
	emit connectionStateChanged( ConClosed, tr( "Connection to %1 closed" ).arg( url()->host() ) );
    else
	emit connectionStateChanged( ConClosed, tr( "Connection closed" ) );

    connectionReady = FALSE;
    emit finished( operationInProgress() );

}
Ejemplo n.º 10
0
void QmvHttp::closed()
{
#ifdef QMVHTTP_DEBUG
    qDebug("QmvHttp::closed");
#endif
    if ( url() )
	emit connectionStateChanged( ConClosed, tr( "Connection to %1 closed" ).arg( url()->host() ) );
    else
	emit connectionStateChanged( ConClosed, tr( "Connection closed" ) );

    connectionReady = FALSE;
    emit finished( operationInProgress() );

}
void QApplicationCommand::updateState(QApplicationCommand::State state, QApplicationCommand::ConnectionError error, const QString &errorString)
{
    if (state != m_connectionState)
    {
        m_connectionState = state;
        emit connectionStateChanged(m_connectionState);

        if (m_connectionState == Connected)
        {
            if (m_connected != true) {
                m_connected = true;
                emit connectedChanged(true);
            }
        }
        else
        {
            if (m_connected != false) {
                m_connected = false;
                emit connectedChanged(m_connected);
            }
        }
    }

    updateError(error, errorString);
}
Ejemplo n.º 12
0
void
DiagnosticsDialog::updateLogView()
{
    QString log;

    log.append( QString( "TOMAHAWK DIAGNOSTICS LOG -%1 \n\n" ).arg( QDateTime::currentDateTime().toString() ) );
    log.append( "TOMAHAWK-VERSION: " TOMAHAWK_VERSION "\n" );
    log.append( "PLATFORM: " TOMAHAWK_SYSTEM "\n\n");
    log.append( "NETWORK:\n    General:\n" );

    if ( Servent::instance()->visibleExternally() )
    {
        log.append(
            QString(
                "      visible: true\n"
                "      host: %1\n"
                "      port: %2\n"
                "\n"
            ).arg( Servent::instance()->externalAddress() )
             .arg( Servent::instance()->externalPort() )

        );
    }
    else
    {
        log.append( "      visible: false\n" );
    }

    log.append( "\n\nINFOPLUGINS:\n" );
    QThread* infoSystemWorkerThreadSuperClass = Tomahawk::InfoSystem::InfoSystem::instance()->workerThread();
    Tomahawk::InfoSystem::InfoSystemWorkerThread* infoSystemWorkerThread = qobject_cast< Tomahawk::InfoSystem::InfoSystemWorkerThread* >(infoSystemWorkerThreadSuperClass);

    foreach(const Tomahawk::InfoSystem::InfoPluginPtr& plugin, infoSystemWorkerThread->worker()->plugins())
    {
        log.append("      ");
        log.append( plugin->friendlyName() );
        log.append("\n");
    }

    log.append( "\n\n" );

    log.append( "ACCOUNTS:\n" );

    const QList< Tomahawk::source_ptr > sources = SourceList::instance()->sources( true );
    const QList< Tomahawk::Accounts::Account* > accounts = Tomahawk::Accounts::AccountManager::instance()->accounts( Tomahawk::Accounts::SipType );
    foreach ( Tomahawk::Accounts::Account* account, accounts )
    {
        Q_ASSERT( account && account->sipPlugin() );
        if ( !account || !account->sipPlugin() )
            continue;

        connect( account, SIGNAL( connectionStateChanged( Tomahawk::Accounts::Account::ConnectionState ) ), SLOT( updateLogView() ), Qt::UniqueConnection );
        connect( account, SIGNAL( error( int, QString ) ), SLOT( updateLogView() ), Qt::UniqueConnection );
        connect( account->sipPlugin(), SIGNAL( peerOnline( QString ) ), SLOT( updateLogView() ), Qt::UniqueConnection );
        connect( account->sipPlugin(), SIGNAL( peerOffline( QString ) ), SLOT( updateLogView() ), Qt::UniqueConnection );
        connect( account->sipPlugin(), SIGNAL( sipInfoReceived( QString, SipInfo ) ), SLOT( updateLogView() ), Qt::UniqueConnection );
        connect( account->sipPlugin(), SIGNAL( softwareVersionReceived( QString, QString ) ), SLOT( updateLogView() ), Qt::UniqueConnection );

        log.append( accountLog( account ) + "\n" );
    }
Ejemplo n.º 13
0
    void EtherIPC::handleGetNetVersion() {
        QJsonValue jv;
        if ( !readReply(jv) ) {
            return bail();
        }

        bool ok = false;
        fNetVersion = jv.toString().toInt(&ok);

        if ( !ok ) {
            setError("Unable to parse net version string: " + jv.toString());
            return bail(true);
        }

        emit netVersionChanged(fNetVersion);
        done();

        fTimer.start(); // should happen after filter creation, might need to move into last filter response handler
        // if we connected to external geth, put that info in geth log

        emit startingChanged(fStarting);
        emit connectToServerDone();
        emit connectionStateChanged();
        emit hardForkReadyChanged(getHardForkReady());
    }
Ejemplo n.º 14
0
bool Mole::disconnect() {
    int ret = 0;
    if (this->is_connected) {
        ret =  me_host_unmount(this->descriptor);
        if (ret < 0) {
            qDebug("[Error] Can't me_host_unmount (ret = 0x%.2x)", -ret);
            return false;
        }
        else {
            qDebug() << "[Success] host unmount";
        }

        ret = me_close_mole(this->descriptor);
        if (ret < 0) {
            qDebug("[Error] Can't close mole (ret = 0x%.2x)", -ret);
            return false;
        }
        else {
            qDebug("[Success] connection closed");
            emit connectionStateChanged(false);
            this->is_connected = false;
            return true;
        }
    }
}
Ejemplo n.º 15
0
void QApplicationLauncher::updateState(Service::State state, Service::ConnectionError error, QString errorString)
{
    if (state != m_connectionState)
    {
        if (m_connected) // we are not connected anymore
        {
            stopSubscribeHeartbeat();
            clearSync();
            m_connected = false;
            emit connectedChanged(false);
        }
        else if (state == Service::Connected) {
            m_connected = true;
            emit connectedChanged(true);
        }

        m_connectionState = state;
        emit connectionStateChanged(m_connectionState);

        if ((state == Service::Disconnected) || (state == Service::Error)) {
            initializeObject();
        }
    }

    updateError(error, errorString);
}
Ejemplo n.º 16
0
/*
 * Parse incoming command, e.g:
 *
 * ADD\r\n
 * <StoryId>\r\n
 * <xml><data></data></xml>\r\n\r\n
 *
 * The XML format is standard XML client data
 * and must include a valid story ID.
 *
 * REMOVE\r\n
 * <StoryId>\r\n\r\n
 *
 * Story ID is a unique ID of some sort.
 */
void RepositoryDevice::sendNotification()
{
    switch (RrupDevice::command)
    {
        case RrupDevice::CONNECTIONSTATE:
        {
            emit connectionStateChanged(*this);

            break;
        }
        case RrupDevice::ADD:
        {
            QString storyId = RrupDevice::response.split("\r\n").at(1).trimmed();
            QString data = RrupDevice::response.split("\r\n").at(2).trimmed();

            emit repositoryChanged(RepositoryChangeModel("ADD", storyId, data), *this);

            break;
        }
        case RrupDevice::REMOVE:
        {
            QString storyId = RrupDevice::response.split("\r\n").at(1).trimmed();

            emit repositoryChanged(RepositoryChangeModel("REMOVE", storyId), *this);

            break;
        }
        default:
        {
            break;
        }
    }

    resetDevice();
}
Ejemplo n.º 17
0
bool Client::connectToServer(const QString &serverName)
{
  if (!m_jsonRpcClient) {
    m_jsonRpcClient = new JsonRpcClient(this);
    connect(m_jsonRpcClient, SIGNAL(resultReceived(QJsonObject)),
            SLOT(processResult(QJsonObject)));
    connect(m_jsonRpcClient, SIGNAL(notificationReceived(QJsonObject)),
            SLOT(processNotification(QJsonObject)));
    connect(m_jsonRpcClient, SIGNAL(errorReceived(QJsonObject)),
            SLOT(processError(QJsonObject)));
    connect(m_jsonRpcClient, SIGNAL(connectionStateChanged()),
            SIGNAL(connectionStateChanged()));
  }

  return m_jsonRpcClient->connectToServer(serverName);
}
Ejemplo n.º 18
0
lmcMessaging::lmcMessaging(void) {
	pNetwork = new lmcNetwork();
	connect(pNetwork, SIGNAL(broadcastReceived(DatagramHeader*, QString*)), 
		this, SLOT(receiveBroadcast(DatagramHeader*, QString*)));
	connect(pNetwork, SIGNAL(messageReceived(DatagramHeader*, QString*)), 
		this, SLOT(receiveMessage(DatagramHeader*, QString*)));
	connect(pNetwork, SIGNAL(webMessageReceived(QString*)),
		this, SLOT(receiveWebMessage(QString*)));
	connect(pNetwork, SIGNAL(newConnection(QString*, QString*)), 
		this, SLOT(newConnection(QString*, QString*)));
	connect(pNetwork, SIGNAL(connectionLost(QString*)),
		this, SLOT(connectionLost(QString*)));
	connect(pNetwork, SIGNAL(progressReceived(QString*, QString*)),
		this, SLOT(receiveProgress(QString*, QString*)));
	connect(pNetwork, SIGNAL(connectionStateChanged()), this, SLOT(network_connectionStateChanged()));
    localUser = NULL;
	userList.clear();
	groupList.clear();
	userGroupMap.clear();
	receivedList.clear();
	pendingList.clear();
    fileList.clear();
    folderList.clear();
	loopback = false;
}
Ejemplo n.º 19
0
void QApplicationStatus::updateState(QApplicationStatus::State state, QApplicationStatus::ConnectionError error, const QString &errorString)
{
    if (state != m_connectionState)
    {
        if (m_connected) // we are not connected anymore
        {
            stopStatusHeartbeat();
            clearSync();
            m_connected = false;
            emit connectedChanged(false);
        }
        else if (state == Connected) {
            m_connected = true;
            emit connectedChanged(true);
        }

        m_connectionState = state;
        emit connectionStateChanged(m_connectionState);

        if ((state == Disconnected) || (state == Error)) {
            initializeObject(MotionChannel);
            initializeObject(ConfigChannel);
            initializeObject(IoChannel);
            initializeObject(TaskChannel);
            initializeObject(InterpChannel);
        }
    }

    updateError(error, errorString);
}
Ejemplo n.º 20
0
		void GpsConnection::rememberCoordinates (GgaSentence ggaSentence)
		{
			coordinatesExpireTimer_.stop ();
			coordinates_ = ggaSentence;
			emit connectionStateChanged ();
			isExpired_ = false;
			coordinatesExpireTimer_.start ();
		}
Ejemplo n.º 21
0
IrcConnection::IrcConnection(QObject *parent) :
    QObject(parent), _sock(new QTcpSocket()), _identity(0), _parser(new IrcParser(this))
{
    connect(_sock, SIGNAL(readyRead()), this, SLOT(readyRead()));
    connect(_sock, &QTcpSocket::stateChanged, this, [=](QAbstractSocket::SocketState s) {
        emit(connectionStateChanged(s));
    });
}
Ejemplo n.º 22
0
void GpiDevice::reset(const QString& serialPort, int baudRate)
{
    emit connectionStateChanged(false, this);
    connected = false;
    gpo_triggers.clear();
    device.reset();
    device = gpio::serial_port_device::create(
            serialPort.toStdString(), baudRate, boost::bind(&GpiDevice::onConnected, this, _1));
}
Ejemplo n.º 23
0
    void EtherIPC::connectedToServer() {
        done();

        getClientVersion();
        getBlockNumber(); // initial
        fTimer.start(); // should happen after filter creation, might need to move into last filter response handler

        EtherLog::logMsg("Connected to IPC socket");
        emit connectToServerDone();
        emit connectionStateChanged();
    }
Ejemplo n.º 24
0
void lmcMainWindow::init(User* pLocalUser, QList<Group>* pGroupList, bool connected) {
	setWindowIcon(QIcon(IDR_APPICON));
    setWindowFlags(windowFlags() & Qt::FramelessWindowHint);
    setWindowFlags(windowFlags() & ~Qt::WindowMaximizeButtonHint);
    setMinimumSize(270, 260);
    setMaximumSize(300, 760);

	this->pLocalUser = pLocalUser;

	createMainMenu();
	createToolBar();
	createStatusMenu();
	createAvatarMenu();

	createTrayMenu();
	createTrayIcon();
	connectionStateChanged(connected);

	createGroupMenu();
	createUserMenu();

	ui.lblDividerTop->setBackgroundRole(QPalette::Highlight);
	ui.lblDividerTop->setAutoFillBackground(true);

	ui.tvUserList->setIconSize(QSize(16, 16));
    ui.tvUserList->header()->setSectionsMovable(false);
	ui.tvUserList->header()->setStretchLastSection(false);
    ui.tvUserList->header()->setSectionResizeMode(0, QHeaderView::Stretch);
	btnStatus->setIconSize(QSize(20, 20));
	int index = Helper::statusIndexFromCode(pLocalUser->status);
	//	if status is not recognized, default to available
	index = qMax(index, 0);
	btnStatus->setIcon(QIcon(QPixmap(statusPic[index], "PNG")));
	statusGroup->actions()[index]->setChecked(true);
    QFont font = ui.lblUserName->font();
	int fontSize = ui.lblUserName->fontInfo().pixelSize();
	fontSize += (fontSize * 0.1);
	font.setPixelSize(fontSize);
    font.setBold(true);
    ui.lblUserName->setFont(font);
	ui.lblStatus->setText(statusGroup->checkedAction()->text());
	nAvatar = pLocalUser->avatar;
	ui.txtNote->setText(pLocalUser->note);

	pSoundPlayer = new lmcSoundPlayer();
	pSettings = new lmcSettings();
	restoreGeometry(pSettings->value(IDS_WINDOWMAIN).toByteArray());
	//	get saved settings
	settingsChanged(true);
	setUIText();

	initGroups(pGroupList);
}
Ejemplo n.º 25
0
void MorseConnection::doConnect(Tp::DBusError *error)
{
    Q_UNUSED(error);

    CAppInformation appInfo;
    appInfo.setAppId(14617);
    appInfo.setAppHash(QLatin1String("e17ac360fd072f83d5d08db45ce9a121"));
    appInfo.setAppVersion(QLatin1String("0.1"));
    appInfo.setDeviceInfo(QLatin1String("pc"));
    appInfo.setOsInfo(QLatin1String("GNU/Linux"));
    appInfo.setLanguageCode(QLatin1String("en"));

    m_authReconnectionsCount = 0;
    m_core = new CTelegramCore(0);
    m_core->setPingInterval(m_keepaliveInterval * 1000);
    m_core->setAppInformation(&appInfo);
    m_core->setMessageReceivingFilterFlags(TelegramNamespace::MessageFlagOut|TelegramNamespace::MessageFlagRead);
    m_core->setAcceptableMessageTypes(TelegramNamespace::MessageTypeText);

    setStatus(Tp::ConnectionStatusConnecting, Tp::ConnectionStatusReasonNoneSpecified);

    connect(m_core, SIGNAL(connectionStateChanged(TelegramNamespace::ConnectionState)),
            this, SLOT(whenConnectionStateChanged(TelegramNamespace::ConnectionState)));
    connect(m_core, SIGNAL(authorizationErrorReceived()),
            this, SLOT(whenAuthErrorReceived()));
    connect(m_core, SIGNAL(phoneCodeRequired()),
            this, SLOT(whenPhoneCodeRequired()));
    connect(m_core, SIGNAL(authSignErrorReceived(TelegramNamespace::AuthSignError,QString)),
            this, SLOT(whenAuthSignErrorReceived(TelegramNamespace::AuthSignError,QString)));
    connect(m_core, SIGNAL(avatarReceived(QString,QByteArray,QString,QString)),
            this, SLOT(whenAvatarReceived(QString,QByteArray,QString,QString)));
    connect(m_core, SIGNAL(contactListChanged()),
            this, SLOT(whenContactListChanged()));
    connect(m_core, SIGNAL(messageReceived(QString,QString,TelegramNamespace::MessageType,quint32,quint32,quint32)),
            this, SLOT(whenMessageReceived(QString,QString,TelegramNamespace::MessageType,quint32,quint32,quint32)));
    connect(m_core, SIGNAL(chatMessageReceived(quint32,QString,QString,TelegramNamespace::MessageType,quint32,quint32,quint32)),
            this, SLOT(whenChatMessageReceived(quint32,QString,QString,TelegramNamespace::MessageType,quint32,quint32,quint32)));
    connect(m_core, SIGNAL(chatChanged(quint32)),
            this, SLOT(whenChatChanged(quint32)));
    connect(m_core, SIGNAL(contactStatusChanged(QString,TelegramNamespace::ContactStatus)),
            this, SLOT(updateContactPresence(QString)));

    const QByteArray sessionData = getSessionData(m_selfPhone);

    if (sessionData.isEmpty()) {
        qDebug() << "init connection...";
        m_core->initConnection(QLatin1String("149.154.175.50"), 443);
    } else {
        qDebug() << "restore connection...";
        m_core->restoreConnection(sessionData);
    }
}
Ejemplo n.º 26
0
MaxCube::MaxCube(QObject *parent, QString serialNumber, QHostAddress hostAdress, quint16 port):
    QTcpSocket(parent), m_serialNumber(serialNumber), m_hostAddress(hostAdress), m_port(port)
{

    m_cubeInitialized = false;

    connect(this,SIGNAL(stateChanged(QAbstractSocket::SocketState)),this,SLOT(connectionStateChanged(QAbstractSocket::SocketState)));

    connect(this,SIGNAL(readyRead()),this,SLOT(readData()));
    connect(this,SIGNAL(error(QAbstractSocket::SocketError)),this,SLOT(error(QAbstractSocket::SocketError)));

    connect(this,SIGNAL(cubeDataAvailable(QByteArray)),this,SLOT(processCubeData(QByteArray)));
}
Ejemplo n.º 27
0
void lmcMessaging::network_connectionStateChanged(void) {
    if(isConnected()) {
		localUser->address = pNetwork->ipAddress;
        if(localUser->id.isNull()) {
            QString logonName = Helper::getLogonName();
            QString szAddress = pNetwork->physicalAddress();
            QString userId = createUserId(&szAddress, &logonName);
            localUser->id = userId;
            pNetwork->setLocalId(&userId);
        }
    }
	emit connectionStateChanged();
}
Ejemplo n.º 28
0
lmcCore::lmcCore(void) {
	pMessaging = new lmcMessaging();
	connect(pMessaging, SIGNAL(messageReceived(MessageType, QString*, XmlMessage*)), 
		this, SLOT(receiveMessage(MessageType, QString*, XmlMessage*)));
	connect(pMessaging, SIGNAL(connectionStateChanged()), this, SLOT(connectionStateChanged()));
	pMainWindow = new lmcMainWindow();
	connect(pMainWindow, SIGNAL(appExiting()), this, SLOT(exitApp()));
	connect(pMainWindow, SIGNAL(chatStarting(QString*)), this, SLOT(startChat(QString*)));
	connect(pMainWindow, SIGNAL(chatRoomStarting(QString*)), this, SLOT(startChatRoom(QString*)));
	connect(pMainWindow, SIGNAL(messageSent(MessageType, QString*, XmlMessage*)), 
		this, SLOT(sendMessage(MessageType, QString*, XmlMessage*)));
	connect(pMainWindow, SIGNAL(showTransfers()), this, SLOT(showTransfers()));
	connect(pMainWindow, SIGNAL(showHistory()), this, SLOT(showHistory()));
	connect(pMainWindow, SIGNAL(showSettings()), this, SLOT(showSettings()));
	connect(pMainWindow, SIGNAL(showHelp(QRect*)), this, SLOT(showHelp(QRect*)));
	connect(pMainWindow, SIGNAL(showUpdate(QRect*)), this, SLOT(showUpdate(QRect*)));
	connect(pMainWindow, SIGNAL(showAbout()), this, SLOT(showAbout()));
	connect(pMainWindow, SIGNAL(showBroadcast()), this, SLOT(showBroadcast()));
	connect(pMainWindow, SIGNAL(showPublicChat()), this, SLOT(showPublicChat()));
	connect(pMainWindow, SIGNAL(groupUpdated(GroupOp, QVariant, QVariant)),
			this, SLOT(updateGroup(GroupOp, QVariant, QVariant)));
	pPublicChatWindow = new lmcChatRoomWindow();
	connect(pPublicChatWindow, SIGNAL(messageSent(MessageType, QString*, XmlMessage*)),
		this, SLOT(sendMessage(MessageType, QString*, XmlMessage*)));
	connect(pPublicChatWindow, SIGNAL(chatStarting(QString*)), this, SLOT(startChat(QString*)));
	chatWindows.clear();
	chatRoomWindows.clear();
	pTransferWindow = NULL;
	pHistoryWindow = NULL;
	pSettingsDialog = NULL;
	pUserInfoWindow = NULL;
	pHelpWindow = NULL;
	pUpdateWindow = NULL;
	pUserSelectDialog = NULL;
	pAboutDialog = NULL;
	pBroadcastWindow = NULL;
	pTimer = NULL;
}
Ejemplo n.º 29
0
void Client::setConnection(Connection *connection)
{
    Q_D(Client);
    if (d->connection != connection) {
        if (d->connection) {
            d->connection.data()->deleteLater();
        }

        d->connection = connection;
        connect(connection, SIGNAL(connectionStateChanged(Vreen::Client::State)),
                this, SLOT(_q_connection_state_changed(Vreen::Client::State)));
        connect(connection, SIGNAL(error(Vreen::Client::Error)), this, SIGNAL(error(Vreen::Client::Error)));

        emit connectionChanged(d->connection);
    }
}
Ejemplo n.º 30
0
int ConnectionWidget::updateDeviceList()
{
    int count  = 0;
    qDebug() << "ConnectionWidget::updateDeviceList";

    //remove all items from the combobox
    while(ui->comPort->count())
    {
        ui->comPort->removeItem(0);
    }

    RTLSDisplayApplication::serialConnection()->findSerialDevices();

    ui->comPort->addItems(RTLSDisplayApplication::serialConnection()->portsList());

    count = ui->comPort->count();

    //check if we have found any TREK devices in the COM ports list
    if(count == 0)
    {
        ui->connect_pb->setEnabled(false);
        ui->label->setEnabled(false);
        ui->comPort->setEnabled(false);

        connectionStateChanged(SerialConnection::Disconnected);
        RTLSDisplayApplication::mainWindow()->connectionStateChanged(SerialConnection::Disconnected);
    }
    else
    {
        //connect to the first TREK device
        if(RTLSDisplayApplication::serialConnection()->openConnection(0) != 0)
        {
            return -1;
        }
        //uncommend this to add 2nd anchor
        /*
        if(RTLSDisplayApplication::serialConnection()->openConnection(1) != 0)
        {
            return -1;
        }
        */
    }

    return count;
}