SDRAngel  4.11.5
Developer docs for <a href="https://github.com/f4exb/sdrangel">SDRangel<\a>, an Open Source Qt5 / OpenGL 3.0+ SDR and signal analyzer frontend to various hardware.
localsinksettings.cpp
Go to the documentation of this file.
1 // Copyright (C) 2019 Edouard Griffiths, F4EXB. //
3 // //
4 // This program is free software; you can redistribute it and/or modify //
5 // it under the terms of the GNU General Public License as published by //
6 // the Free Software Foundation as version 3 of the License, or //
7 // (at your option) any later version. //
8 // //
9 // This program is distributed in the hope that it will be useful, //
10 // but WITHOUT ANY WARRANTY; without even the implied warranty of //
11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the //
12 // GNU General Public License V3 for more details. //
13 // //
14 // You should have received a copy of the GNU General Public License //
15 // along with this program. If not, see <http://www.gnu.org/licenses/>. //
17 
18 #include "localsinksettings.h"
19 
20 #include <QColor>
21 
22 #include "util/simpleserializer.h"
23 #include "settings/serializable.h"
24 
25 
27 {
29 }
30 
32 {
34  m_rgbColor = QColor(140, 4, 4).rgb();
35  m_title = "Local sink";
36  m_log2Decim = 0;
38  m_channelMarker = nullptr;
39  m_useReverseAPI = false;
40  m_reverseAPIAddress = "127.0.0.1";
41  m_reverseAPIPort = 8888;
44 }
45 
46 QByteArray LocalSinkSettings::serialize() const
47 {
48  SimpleSerializer s(1);
50  s.writeU32(5, m_rgbColor);
51  s.writeString(6, m_title);
57  s.writeU32(12, m_log2Decim);
59 
60  return s.final();
61 }
62 
63 bool LocalSinkSettings::deserialize(const QByteArray& data)
64 {
65  SimpleDeserializer d(data);
66 
67  if(!d.isValid())
68  {
70  return false;
71  }
72 
73  if(d.getVersion() == 1)
74  {
75  uint32_t tmp;
76  QString strtmp;
77 
78  d.readU32(1, &m_localDeviceIndex, 0);
79  d.readU32(5, &m_rgbColor, QColor(0, 255, 255).rgb());
80  d.readString(6, &m_title, "Local sink");
81  d.readBool(7, &m_useReverseAPI, false);
82  d.readString(8, &m_reverseAPIAddress, "127.0.0.1");
83  d.readU32(9, &tmp, 0);
84 
85  if ((tmp > 1023) && (tmp < 65535)) {
86  m_reverseAPIPort = tmp;
87  } else {
88  m_reverseAPIPort = 8888;
89  }
90 
91  d.readU32(10, &tmp, 0);
92  m_reverseAPIDeviceIndex = tmp > 99 ? 99 : tmp;
93  d.readU32(11, &tmp, 0);
94  m_reverseAPIChannelIndex = tmp > 99 ? 99 : tmp;
95  d.readU32(12, &tmp, 0);
96  m_log2Decim = tmp > 6 ? 6 : tmp;
97  d.readU32(13, &m_filterChainHash, 0);
98 
99  return true;
100  }
101  else
102  {
103  resetToDefaults();
104  return false;
105  }
106 }
107 
108 
109 
110 
111 
QByteArray serialize() const
bool readU32(quint32 id, quint32 *result, quint32 def=0) const
bool readString(quint32 id, QString *result, const QString &def=QString::null) const
bool readBool(quint32 id, bool *result, bool def=false) const
bool isValid() const
unsigned int uint32_t
Definition: rtptypes_win.h:46
uint16_t m_reverseAPIChannelIndex
bool deserialize(const QByteArray &data)
quint32 getVersion() const
uint16_t m_reverseAPIDeviceIndex
Serializable * m_channelMarker
void writeU32(quint32 id, quint32 value)
void writeBool(quint32 id, bool value)
void writeString(quint32 id, const QString &value)
const QByteArray & final()