1 /*
2 SPDX-FileCopyrightText: 2012 Jasem Mutlaq <mutlaqja@ikarustech.com>
3
4 SPDX-License-Identifier: GPL-2.0-or-later
5 */
6
7 #include "clientmanager.h"
8
9 #include "deviceinfo.h"
10 #include "drivermanager.h"
11 #include "guimanager.h"
12 #include "indilistener.h"
13 #include "Options.h"
14 #include "servermanager.h"
15
16 #include <indi_debug.h>
17
BlobManager(const QString & host,int port,const QString & device,const QString & prop)18 BlobManager::BlobManager(const QString &host, int port, const QString &device, const QString &prop) : m_Device(device), m_Property(prop)
19 {
20 // Set INDI server params
21 setServer(host.toLatin1().constData(), port);
22
23 // We're only interested in a particular device
24 watchDevice(m_Device.toLatin1().constData());
25
26 // Connect immediately
27 connectServer();
28 }
29
serverDisconnected(int exit_code)30 void BlobManager::serverDisconnected(int exit_code)
31 {
32 qCDebug(KSTARS_INDI) << "INDI server disconnected from BLOB manager for Device:" << m_Device << "Property:" << m_Property << "Exit code:" << exit_code;
33 }
34
newBLOB(IBLOB * bp)35 void BlobManager::newBLOB(IBLOB *bp)
36 {
37 emit newINDIBLOB(bp);
38 }
39
newDevice(INDI::BaseDevice * device)40 void BlobManager::newDevice(INDI::BaseDevice *device)
41 {
42 // Got out target device, let's now set to BLOB ONLY for the particular property we want
43 if (QString(device->getDeviceName()) == m_Device)
44 {
45 setBLOBMode(B_ONLY, m_Device.toLatin1().constData(), m_Property.toLatin1().constData());
46 emit connected();
47 }
48 }
49
setEnabled(bool enabled)50 void BlobManager::setEnabled(bool enabled)
51 {
52 m_Enabled = enabled;
53 setBLOBMode(enabled ? B_ONLY : B_NEVER, m_Device.toLatin1().constData(), m_Property.toLatin1().constData());
54 }
55