• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

ossia / score / 32671464175

23 Aug 2026 10:43PM UTC coverage: 23.21% (+1.6%) from 21.606%
32671464175

push

github

jcelerier
scenario: export NodalIntervalView

test_integration_nodal_viewport and test_integration_cable_drag_view_scroll
call into the class from outside the plug-in, so a shared-plugin build could
not link either of them: the library held 136 NodalIntervalView symbols and
exported none. A static-plugin build never sees it, which is why CI does not.

51875 of 223502 relevant lines covered (23.21%)

63063.32 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

0.0
/src/plugins/score-plugin-protocols/Protocols/OSCQuery/OSCQueryDevice.cpp
1
// This is an open source non-commercial project. Dear PVS-Studio, please check
2
// it. PVS-Studio Static Code Analyzer for C, C++ and C#: http://www.viva64.com
3
#include "OSCQueryDevice.hpp"
4

5
#include <Device/Protocol/DeviceSettings.hpp>
6

7
#include <Explorer/DeviceList.hpp>
8
#include <Explorer/DeviceLogging.hpp>
9

10
#include <Protocols/OSCQuery/OSCQuerySpecificSettings.hpp>
11

12
#include <ossia/network/context.hpp>
13
#include <ossia/network/generic/generic_device.hpp>
14
#include <ossia/network/generic/generic_parameter.hpp>
15
#include <ossia/network/local/local.hpp>
16
#include <ossia/network/oscquery/oscquery_mirror.hpp>
17
#include <ossia/network/rate_limiting_protocol.hpp>
18
#include <ossia/network/resolve.hpp>
19
#include <ossia/protocols/oscquery/oscquery_mirror_asio.hpp>
20
#include <ossia/protocols/oscquery/oscquery_mirror_asio_dense.hpp>
21

22
#include <boost/algorithm/string.hpp>
23
#include <boost/asio/io_context.hpp>
24
#include <boost/asio/ip/basic_resolver.hpp>
25
#include <boost/asio/ip/tcp.hpp>
26

27
#include <QCoreApplication>
28
#include <QDebug>
29
#include <QMetaMethod>
30

31
#include <wobjectimpl.h>
32

33
#include <memory>
34
W_OBJECT_IMPL(Protocols::OSCQueryDevice)
×
35
namespace Protocols
36
{
37

38
OSCQueryDevice::OSCQueryDevice(
×
39
    const Device::DeviceSettings& settings, const ossia::net::network_context_ptr& ctx)
40
    : OwningDeviceInterface{settings}
×
41
    , m_ctx{ctx}
42
{
×
43
  m_capas.canRefreshTree = true;
×
44
  m_capas.asyncConnect = true;
×
45
  m_capas.canRenameNode = false;
×
46
  m_capas.canSetProperties = false;
×
47

48
  connect(
×
49
      this, &OSCQueryDevice::sig_command, this, &OSCQueryDevice::slot_command,
50
      Qt::QueuedConnection);
51
  connect(
×
52
      this, &OSCQueryDevice::sig_createDevice, this, &OSCQueryDevice::slot_createDevice,
53
      Qt::QueuedConnection);
54
  connect(
×
55
      this, &OSCQueryDevice::sig_disconnect, this,
56
      [this] {
×
57
    // TODO how to notify the GUI ?
58
    m_connected = false;
×
59
  },
×
60
      Qt::QueuedConnection);
61
}
×
62

63
OSCQueryDevice::~OSCQueryDevice()
×
64
{
×
65
  auto old = std::move(m_dev);
×
66
  deviceChanged(old.get(), nullptr);
×
67
  Device::releaseDevice(*m_ctx, std::move(old));
×
68
}
×
69

70
bool OSCQueryDevice::connected() const
×
71
{
72
  return m_dev && m_connected;
×
73
}
74

75
void OSCQueryDevice::disconnect()
×
76
{
77
  if(m_mirror)
×
78
  {
79
    m_mirror->on_connection_closed.disconnect<&OSCQueryDevice::sig_disconnect>(*this);
×
80
    m_mirror->on_connection_failure.disconnect<&OSCQueryDevice::sig_disconnect>(*this);
×
81
    m_mirror = nullptr;
×
82
  }
×
83

84
  // Taken from OwningDeviceInterface::disconnect
85
  if(m_owned)
×
86
  {
87
    DeviceInterface::disconnect();
×
88
    // TODO why not auto dev = m_dev; ... like in MIDIDevice ?
89
    auto old = std::move(m_dev);
×
90
    deviceChanged(old.get(), nullptr);
×
91

92
    Device::releaseDevice(*m_ctx, std::move(old));
×
93
    m_dev.reset();
×
94
  }
×
95
}
×
96

97
bool OSCQueryDevice::reconnect()
×
98
{
99
  const auto& cur_settings = settings();
×
100
  const auto& stgs
×
101
      = cur_settings.deviceSpecificSettings.value<OSCQuerySpecificSettings>();
×
102

103
  if(m_dev && m_mirror && m_oldSettings == cur_settings)
×
104
  {
105
    // TODO update settings
106
    try
107
    {
108
      m_mirror->connect();
×
109
      m_connected = true;
×
110
    }
×
111
    catch(std::exception& e)
112
    {
113
      qDebug() << "Could not connect: " << e.what();
×
114
      m_connected = false;
×
115
    }
×
116
    catch(...)
117
    {
118
      // TODO save the reason of the non-connection.
119
      m_connected = false;
×
120
    }
×
121

122
    connectionChanged(m_connected);
×
123
    return connected();
×
124
  }
125

126
  disconnect();
×
127

128
  // TODO put this in the io_context thread instead
129
  std::thread resolver([self = QPointer{this}, url = stgs.host.toStdString()] {
×
130
    auto [host, port] = ossia::url_to_host_and_port(url);
×
131
    bool ok = bool(ossia::resolve_sync_v4<boost::asio::ip::tcp>(host, port));
×
132
    QMetaObject::invokeMethod(qApp, [self, ok] {
×
133
      if(!self)
×
134
        return;
×
135

136
      // We are on the main thread here: create the device right away.
137
      // connectionChanged() is emitted by slot_createDevice() once the device
138
      // exists (or failed to be created): whoever waits on it to explore the
139
      // namespace - DeviceDocumentPlugin::asyncConnect followed by refresh() -
140
      // must find the device in place. Emitting connectionChanged(false) before
141
      // a queued device creation is what left freshly added OSCQuery devices
142
      // with an empty tree.
143
      if(ok)
×
144
      {
145
        self->slot_createDevice();
×
146
      }
×
147
      else
148
      {
149
        self->m_connected = false;
×
150
        self->connectionChanged(self->m_connected);
×
151
      }
152
    });
×
153
  });
×
154

155
  resolver.detach();
×
156

157
  return connected();
×
158
}
×
159

160
void OSCQueryDevice::recreate(const Device::Node& n)
×
161
{
162
  for(auto& child : n)
×
163
  {
164
    addNode(child);
×
165
  }
166
}
×
167

168
void OSCQueryDevice::slot_command()
×
169
{
170
  /*
171
  if (m_mirror)
172
  {
173
    m_mirror->run_commands();
174
  }
175
  */
176
}
×
177

178
void OSCQueryDevice::slot_createDevice()
×
179
{
180
  const auto& cur_settings = settings();
×
181
  const auto& stgs
×
182
      = cur_settings.deviceSpecificSettings.value<OSCQuerySpecificSettings>();
×
183

184
  try
185
  {
186
    std::unique_ptr<ossia::net::protocol_base> ossia_settings;
×
187
    if(stgs.dense)
×
188
    {
189
      ossia_settings
×
190
          = std::make_unique<ossia::oscquery_asio::oscquery_mirror_asio_protocol_dense>(
×
191
              m_ctx, stgs.host.toStdString(), stgs.localPort);
×
192
    }
×
193
    else
194
    {
195
      ossia_settings
×
196
          = std::make_unique<ossia::oscquery_asio::oscquery_mirror_asio_protocol>(
×
197
              m_ctx, stgs.host.toStdString(), stgs.localPort);
×
198
    }
199

200
    m_mirror = ossia_settings.get();
×
201

202
    if(stgs.rate)
×
203
    {
204
      ossia_settings = std::make_unique<ossia::net::rate_limiting_protocol>(
×
205
          std::chrono::milliseconds{*stgs.rate}, std::move(ossia_settings));
×
206
    }
×
207

208
    // run the commands in the Qt event loop
209
    // FIXME they should be disabled upon manual disconnection
210

211
    auto old = std::move(m_dev);
×
212
    auto old_ptr = old.get();
×
213
    Device::releaseDevice(*m_ctx, std::move(old));
×
214
    m_dev = std::make_unique<ossia::net::generic_device>(
×
215
        std::move(ossia_settings), settings().name.toStdString());
×
216

217
    deviceChanged(old_ptr, m_dev.get());
×
218

219
    //m_mirror->set_command_callback([this] { sig_command(); });
220
    m_mirror->on_connection_closed.connect<&OSCQueryDevice::sig_disconnect>(*this);
×
221
    m_mirror->on_connection_failure.connect<&OSCQueryDevice::sig_disconnect>(*this);
×
222

223
    setLogging_impl(Device::get_cur_logging(isLogging()));
×
224

225
    enableCallbacks();
×
226
    m_connected = true;
×
227
  }
×
228
  catch(std::exception& e)
229
  {
230
    qDebug() << "Could not connect: " << e.what();
×
231
    m_connected = false;
×
232
    if(!m_dev)
×
233
      m_mirror = nullptr;
×
234
  }
×
235
  catch(...)
236
  {
237
    // TODO save the reason of the non-connection.
238
    m_connected = false;
×
239
    if(!m_dev)
×
240
      m_mirror = nullptr;
×
241
  }
×
242

243
  connectionChanged(m_connected);
×
244
}
×
245
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE TRIAL · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc