Kstars

ekosliveclient.h
1 /*
2  SPDX-FileCopyrightText: 2018 Jasem Mutlaq <[email protected]>
3 
4  SPDX-License-Identifier: GPL-2.0-or-later
5 */
6 
7 #pragma once
8 
9 #include <QDialog>
10 #include <QtWebSockets/QWebSocket>
11 #include <memory>
12 
13 #include "ekos/ekos.h"
14 #include "ekos/manager.h"
15 #include "ekos/align/align.h"
16 #include "indi/indicommon.h"
17 #include "ksnotification.h"
18 
19 // Ekos Live Communication Channels
20 #include "message.h"
21 #include "media.h"
22 #include "cloud.h"
23 
24 #include "ui_ekoslivedialog.h"
25 
26 class QProgressIndicator;
28 class QNetworkReply;
29 
30 namespace EkosLive
31 {
32 class Client : public QDialog, public Ui::EkosLiveDialog
33 {
34  Q_OBJECT
35  public:
36  explicit Client(Ekos::Manager *manager);
37  ~Client();
38 
39  bool isConnected() const
40  {
41  return m_isConnected;
42  }
43 
44  const QPointer<Message> &message()
45  {
46  return m_Message;
47  }
48  const QPointer<Media> &media()
49  {
50  return m_Media;
51  }
52  const QPointer<Cloud> &cloud()
53  {
54  return m_Cloud;
55  }
56 
57  void setConnected(bool enabled);
58  void setConfig(bool onlineService, bool rememberCredentials, bool autoConnect);
59  void setUser(const QString &user, const QString &pass);
60 
61  signals:
62  void connected();
63  void disconnected();
64 
65  protected slots:
66  void authenticate();
67  void onResult(QNetworkReply *reply);
68 
69  private slots:
70  // Auth Server
71  void connectAuthServer();
72  void disconnectAuthServer();
73 
74  void onConnected();
75  void onDisconnected();
76 
77  private:
78  QJsonObject authResponse;
79  QWebSocket m_mediaWebSocket;
80  bool m_isConnected { false };
81  Ekos::Manager *m_Manager { nullptr };
82  QNetworkAccessManager *networkManager { nullptr };
83 
84  QProgressIndicator *pi { nullptr };
85 
86  QString token;
87  QUrl m_serviceURL;
88  QUrl m_wsURL;
89 
90  uint16_t m_AuthReconnectTries {0};
91 
92  QPointer<Message> m_Message;
93  QPointer<Media> m_Media;
94  QPointer<Cloud> m_Cloud;
95 
96  // Retry every 3 seconds if connection is refused.
97  static const uint16_t RECONNECT_INTERVAL = 3000;
98  // Retry for 3 times before giving up
99  static const uint16_t RECONNECT_MAX_TRIES = 3;
100 };
101 }
Q_OBJECTQ_OBJECT
The QProgressIndicator class lets an application display a progress indicator to show that a long tas...
Generic record interfaces and implementations.
Definition: cloud.cpp:23
QString message
This file is part of the KDE documentation.
Documentation copyright © 1996-2022 The KDE developers.
Generated on Thu Aug 11 2022 03:59:58 by doxygen 1.8.17 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.