summaryrefslogtreecommitdiffstats
path: root/applauncher/AppLauncherGrpcClient.h
blob: f9e1d0f7ad0e50d51b100dfb5f26ca02cc4cd55d (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
47
48
49
50
51
52
53
54
55
// SPDX-License-Identifier: Apache-2.0
/*
 * Copyright (C) 2022 Konsulko Group
 */

#ifndef APPLAUNCHER_GRPC_CLIENT_H
#define APPLAUNCHER_GRPC_CLIENT_H

#include <QObject>
#include <QList>
#include <QMap>
#include <QThread>
#include <grpcpp/grpcpp.h>

#include "applauncher.grpc.pb.h"

using grpc::Channel;

class AppStatusEventReader : public QObject
{
	Q_OBJECT
public:
	AppStatusEventReader(std::shared_ptr<automotivegradelinux::AppLauncher::Stub> &stub,
			     QObject *parent = Q_NULLPTR) : QObject(parent), stub_(stub) {}

public slots:
	void GetStatusEvents();

signals:
	void statusUpdate(const QString &id, const QString &status);
	void finished();

private:
	std::shared_ptr<automotivegradelinux::AppLauncher::Stub> stub_;
};

class AppLauncherGrpcClient : public QObject
{
	Q_OBJECT

public:
	AppLauncherGrpcClient(QObject *parent = Q_NULLPTR);

	bool StartApplication(const QString &id);

	bool ListApplications(QList<QMap<QString, QString>> &list);

private:
	std::shared_ptr<automotivegradelinux::AppLauncher::Stub> stub_;

	QThread m_event_thread;

};

#endif // APPLAUNCHER_GRPC_CLIENT_H