aboutsummaryrefslogtreecommitdiffstats
path: root/src/plugins/nim/suggest/server.h
blob: 9eb2bac141d0a85d8d68902109ff8133d9c7d137 (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
39
40
41
42
43
44
45
46
// Copyright (C) Filippo Cucchetto <filippocucchetto@gmail.com>
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0

#pragma once

#include <QDebug>
#include <QFile>
#include <QObject>

#include <utils/process.h>

namespace Nim {
namespace Suggest {

class NimSuggestServer : public QObject
{
    Q_OBJECT

public:
    NimSuggestServer(QObject *parent = nullptr);

    bool start(const QString &executablePath, const QString &projectFilePath);
    void stop();

    quint16 port() const;
    QString executablePath() const;
    QString projectFilePath() const;

signals:
    void started();
    void done();

private:
    void onStandardOutputAvailable();
    void onDone();
    void clearState();

    bool m_portAvailable = false;
    Utils::Process m_process;
    quint16 m_port = 0;
    QString m_projectFilePath;
    QString m_executablePath;
};

} // namespace Suggest
} // namespace Nim