aboutsummaryrefslogtreecommitdiffstats
path: root/src/plugins/boot2qt/device-detection/devicedetector.h
blob: f5ff76dbcdd187366f84f25d01524c0c555c7564 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
// Copyright (C) 2019 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0+ OR GPL-3.0 WITH Qt-GPL-exception-1.0

#pragma once

#include "../qdbdevice.h"
#include "qdbdevicetracker.h"
#include "qdbmessagetracker.h"

namespace Qdb {
namespace Internal {

class DeviceDetector : public QObject
{
    Q_OBJECT

public:
    DeviceDetector();
    ~DeviceDetector();

    void start();
    void stop();

private:
    void handleDeviceEvent(QdbDeviceTracker::DeviceEventType eventType,
                           const QMap<QString, QString> &info);
    void handleTrackerError(const QString &errorMessage);
    void resetDevices();

    enum State { Inactive, WaitingForDeviceUpdates };

    State m_state = Inactive;
    QdbDeviceTracker m_deviceTracker;
    QdbMessageTracker m_messageTracker;
};

} // namespace Internal
} // namespace Qdb