LCOV - code coverage report
Current view: top level - core/gps - qgsgpsdconnection.cpp (source / functions) Hit Total Coverage
Test: coverage.info.cleaned Lines: 0 16 0.0 %
Date: 2021-03-26 12:19:53 Functions: 0 0 -
Branches: 0 0 -

           Branch data     Line data    Source code
       1                 :            : /***************************************************************************
       2                 :            :                           qgsgpsdconnection.cpp  -  description
       3                 :            :                           ---------------------
       4                 :            :     begin                : October 4th, 2010
       5                 :            :     copyright            : (C) 2010 by Jürgen E. Fischer, norBIT GmbH
       6                 :            :     email                : jef at norbit dot de
       7                 :            :  ***************************************************************************/
       8                 :            : 
       9                 :            : /***************************************************************************
      10                 :            :  *                                                                         *
      11                 :            :  *   This program is free software; you can redistribute it and/or modify  *
      12                 :            :  *   it under the terms of the GNU General Public License as published by  *
      13                 :            :  *   the Free Software Foundation; either version 2 of the License, or     *
      14                 :            :  *   (at your option) any later version.                                   *
      15                 :            :  *                                                                         *
      16                 :            :  ***************************************************************************/
      17                 :            : 
      18                 :            : #include "qgsgpsdconnection.h"
      19                 :            : #include "qgslogger.h"
      20                 :            : 
      21                 :            : #include <QTcpSocket>
      22                 :            : 
      23                 :          0 : QgsGpsdConnection::QgsGpsdConnection( const QString &host, qint16 port, const QString &device )
      24                 :          0 :   : QgsNmeaConnection( new QTcpSocket() )
      25                 :          0 :   , mDevice( device )
      26                 :          0 : {
      27                 :          0 :   QTcpSocket *socket = qobject_cast< QTcpSocket * >( mSource.get() );
      28                 :            : 
      29                 :          0 :   QObject::connect( socket, SIGNAL( connected() ), this, SLOT( connected() ) );
      30                 :          0 :   QObject::connect( socket, SIGNAL( error( QAbstractSocket::SocketError ) ), this, SLOT( error( QAbstractSocket::SocketError ) ) );
      31                 :          0 :   socket->connectToHost( host, port );
      32                 :          0 : }
      33                 :            : 
      34                 :          0 : void QgsGpsdConnection::connected()
      35                 :            : {
      36                 :          0 :   QgsDebugMsgLevel( QStringLiteral( "connected!" ), 2 );
      37                 :          0 :   QTcpSocket *socket = qobject_cast< QTcpSocket * >( mSource.get() );
      38                 :          0 :   socket->write( QStringLiteral( "?WATCH={\"enable\":true,\"nmea\":true,\"raw\":true%1};" ).arg( mDevice.isEmpty() ? mDevice : QStringLiteral( ",\"device\":%1" ).arg( mDevice ) ).toUtf8() );
      39                 :          0 : }
      40                 :            : 
      41                 :          0 : void QgsGpsdConnection::error( QAbstractSocket::SocketError socketError )
      42                 :            : {
      43                 :            : #ifdef QGISDEBUG
      44                 :            :   QTcpSocket *socket = qobject_cast< QTcpSocket * >( mSource.get() );
      45                 :            :   QgsDebugMsg( QStringLiteral( "error: %1 %2" ).arg( socketError ).arg( socket->errorString() ) );
      46                 :            : #else
      47                 :            :   Q_UNUSED( socketError )
      48                 :            : #endif
      49                 :          0 : }

Generated by: LCOV version 1.14