• Skip to content
  • Skip to link menu
KDE API Reference
  • KDE API Reference
  • kdeedu API Reference
  • KDE Home
  • Contact Us
 

marble

  • sources
  • kde-4.12
  • kdeedu
  • marble
  • src
  • plugins
  • render
  • aprs
AprsTCPIP.cpp
Go to the documentation of this file.
1 //
2 // This file is part of the Marble Virtual Globe.
3 //
4 // This program is free software licensed under the GNU LGPL. You can
5 // find a copy of this license in LICENSE.txt in the top directory of
6 // the source code.
7 //
8 // Copyright 2010 Wes Hardaker <hardaker@users.sourceforge.net>
9 //
10 
11 #include "AprsTCPIP.h"
12 
13 #include <QTcpSocket>
14 
15 #include "MarbleDebug.h"
16 
17 #include "AprsGatherer.h"
18 
19 using namespace Marble;
20 
21 AprsTCPIP::AprsTCPIP( QString hostName, int port )
22  : m_hostName( hostName ),
23  m_port( port ),
24  m_numErrors( 0 )
25 {
26 }
27 
28 AprsTCPIP::~AprsTCPIP()
29 {
30 }
31 
32 QString
33 AprsTCPIP::sourceName() const
34 {
35  return QString( "TCP" );
36 }
37 
38 bool
39 AprsTCPIP::canDoDirect() const
40 {
41  return false;
42 }
43 
44 QIODevice *
45 AprsTCPIP::openSocket()
46 {
47  m_numErrors = 0;
48 
49  QTcpSocket *socket = new QTcpSocket();
50  mDebug() << "Opening TCPIP socket to " <<
51  m_hostName.toLocal8Bit().data() << ":" << m_port;
52  socket->connectToHost( m_hostName, m_port );
53  socket->waitForReadyRead();
54 
55  {
56  // read the initial server statement
57  char buf[4096];
58  socket->readLine( buf, sizeof( buf ) );
59  mDebug() << "Aprs TCPIP server: " << buf;
60  }
61 
62  QString towrite( "user MARBLE pass -1 vers aprs-cgi 1.0 filter r/38/-120/200\n" );
63  socket->write( towrite.toLocal8Bit().data(), towrite.length() );
64 
65  mDebug() << "opened TCPIP socket";
66  return socket;
67 }
68 
69 
70 void
71 AprsTCPIP::checkReadReturn( int length, QIODevice **socket,
72  AprsGatherer *gatherer )
73 {
74  if ( length < 0 || ( length == 0 && m_numErrors > 5 ) ) {
75  // hard error. try reopening
76  mDebug() << "**** restarting TCPIP socket";
77  delete *socket;
78  gatherer->sleepFor( 1 );
79  *socket = openSocket();
80  return;
81  }
82  if ( length == 0 ) {
83  ++m_numErrors;
84  mDebug() << "**** Odd: read zero bytes from TCPIP socket";
85  return;
86  }
87  return;
88 }
89 
Marble::AprsTCPIP::AprsTCPIP
AprsTCPIP(QString hostName, int port)
Definition: AprsTCPIP.cpp:21
Marble::AprsTCPIP::checkReadReturn
void checkReadReturn(int length, QIODevice **socket, AprsGatherer *gatherer)
Definition: AprsTCPIP.cpp:71
MarbleDebug.h
AprsGatherer.h
AprsTCPIP.h
Marble::AprsTCPIP::canDoDirect
bool canDoDirect() const
Definition: AprsTCPIP.cpp:39
Marble::AprsGatherer::sleepFor
void sleepFor(int seconds)
Definition: AprsGatherer.cpp:285
Marble::AprsSource::socket
QIODevice * socket()
Definition: AprsSource.cpp:25
Marble::AprsGatherer
Definition: AprsGatherer.h:26
Marble::AprsTCPIP::sourceName
QString sourceName() const
Definition: AprsTCPIP.cpp:33
Marble::AprsTCPIP::openSocket
QIODevice * openSocket()
Definition: AprsTCPIP.cpp:45
Marble::mDebug
QDebug mDebug()
a function to replace qDebug() in Marble library code
Definition: MarbleDebug.cpp:31
Marble::AprsTCPIP::~AprsTCPIP
~AprsTCPIP()
Definition: AprsTCPIP.cpp:28
This file is part of the KDE documentation.
Documentation copyright © 1996-2014 The KDE developers.
Generated on Tue Oct 14 2014 22:38:49 by doxygen 1.8.7 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

marble

Skip menu "marble"
  • Main Page
  • Namespace List
  • Namespace Members
  • Alphabetical List
  • Class List
  • Class Hierarchy
  • Class Members
  • File List
  • File Members
  • Related Pages

kdeedu API Reference

Skip menu "kdeedu API Reference"
  • Analitza
  •     lib
  • kalgebra
  • kalzium
  •   libscience
  • kanagram
  • kig
  •   lib
  • klettres
  • kstars
  • libkdeedu
  •   keduvocdocument
  • marble
  • parley
  • rocs
  •   App
  •   RocsCore
  •   VisualEditor
  •   stepcore

Search



Report problems with this website to our bug tracking system.
Contact the specific authors with questions and comments about the page contents.

KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal