SoDaRadio-5.0.3-master:8901fb5
soda_hamlib_server.hpp
Go to the documentation of this file.
1 /*
2 Copyright (c) 2017 Matthew H. Reilly (kb1vc)
3 All rights reserved.
4 
5 Redistribution and use in source and binary forms, with or without
6 modification, are permitted provided that the following conditions are
7 met:
8 
9  Redistributions of source code must retain the above copyright
10  notice, this list of conditions and the following disclaimer.
11  Redistributions in binary form must reproduce the above copyright
12  notice, this list of conditions and the following disclaimer in
13  the documentation and/or other materials provided with the
14  distribution.
15 
16 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
17 "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
18 LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
19 A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
20 HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
21 SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
22 LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23 DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24 THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25 (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
26 OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27 */
28 
29 #ifndef SODA_HAMLIB_SERVER_HEADER
30 #define SODA_HAMLIB_SERVER_HEADER
31 #include <QObject>
32 #include <QString>
33 #include <QtNetwork/QtNetwork>
34 #include <iostream>
35 #include <boost/format.hpp>
36 #include <errno.h>
37 #include "soda_hamlib_listener.hpp"
38 #include "soda_hamlib_handler.hpp"
39 #include "../src/Command.hxx"
40 
41  // This, and soda_hamlib_listener are taken
42  // from a pattern at https://gist.github.com/lamprosg/4587087
43  // nicely done and documented.
44  //
45 
46 namespace GUISoDa {
47  class HamlibServer : public QTcpServer {
48  Q_OBJECT
49 
50  public:
51  HamlibServer(QObject * parent = 0, int _port_num = 4575);
52 
53  ~HamlibServer();
54 
56 
57  signals:
58  void stopListeners();
59 
60  public slots:
61  // start listening for the first incoming connection.
62  bool start();
63 
64 
65  protected:
66  void incomingConnection(qintptr desc);
67  int port_num;
68 
70 
71  std::list<HamlibListener *> listener_list;
72  };
73 }
74 #endif
HamlibHandler * getHandler()
HamlibServer(QObject *parent=0, int _port_num=4575)
void incomingConnection(qintptr desc)
std::list< HamlibListener * > listener_list