2023-04-14 18:44:28 +00:00
|
|
|
#ifndef NETWORK_H
|
|
|
|
#define NETWORK_H
|
|
|
|
|
|
|
|
#include <QObject>
|
|
|
|
#include <QNetworkAccessManager>
|
|
|
|
#include <QNetworkReply>
|
2023-05-03 00:31:17 +00:00
|
|
|
#include <QJsonValue>
|
|
|
|
|
|
|
|
struct KeyValue {
|
|
|
|
QString key;
|
|
|
|
QJsonValue value;
|
|
|
|
};
|
2023-04-14 18:44:28 +00:00
|
|
|
|
|
|
|
class Network : public QObject
|
|
|
|
{
|
|
|
|
Q_OBJECT
|
|
|
|
public:
|
|
|
|
static Network *globalInstance();
|
|
|
|
|
|
|
|
Q_INVOKABLE QString generateUniqueId() const;
|
2023-04-24 01:05:38 +00:00
|
|
|
Q_INVOKABLE bool sendConversation(const QString &ingestId, const QString &conversation);
|
2023-04-14 18:44:28 +00:00
|
|
|
|
|
|
|
Q_SIGNALS:
|
2023-04-23 11:35:38 +00:00
|
|
|
void healthCheckFailed(int code);
|
2023-04-14 18:44:28 +00:00
|
|
|
|
2023-04-27 02:05:56 +00:00
|
|
|
public Q_SLOTS:
|
2023-04-28 14:54:05 +00:00
|
|
|
void sendOptOut();
|
2023-04-27 02:05:56 +00:00
|
|
|
void sendModelLoaded();
|
|
|
|
void sendStartup();
|
2023-04-27 11:41:23 +00:00
|
|
|
void sendCheckForUpdates();
|
2023-05-03 00:31:17 +00:00
|
|
|
Q_INVOKABLE void sendModelDownloaderDialog();
|
|
|
|
Q_INVOKABLE void sendResetContext(int conversationLength);
|
2023-05-15 00:12:15 +00:00
|
|
|
void sendInstallModel(const QString &model);
|
2023-05-16 13:32:01 +00:00
|
|
|
void sendRemoveModel(const QString &model);
|
2023-05-03 00:31:17 +00:00
|
|
|
void sendDownloadStarted(const QString &model);
|
|
|
|
void sendDownloadCanceled(const QString &model);
|
|
|
|
void sendDownloadError(const QString &model, int code, const QString &errorString);
|
|
|
|
void sendDownloadFinished(const QString &model, bool success);
|
|
|
|
Q_INVOKABLE void sendSettingsDialog();
|
|
|
|
Q_INVOKABLE void sendNetworkToggled(bool active);
|
2023-05-05 16:30:11 +00:00
|
|
|
Q_INVOKABLE void sendSaveChatsToggled(bool active);
|
2023-05-03 00:31:17 +00:00
|
|
|
Q_INVOKABLE void sendNewChat(int count);
|
|
|
|
Q_INVOKABLE void sendRemoveChat();
|
|
|
|
Q_INVOKABLE void sendRenameChat();
|
2023-05-08 12:31:35 +00:00
|
|
|
Q_INVOKABLE void sendNonCompatHardware();
|
2023-05-03 00:31:17 +00:00
|
|
|
void sendChatStarted();
|
|
|
|
void sendRecalculatingContext(int conversationLength);
|
2023-04-27 02:05:56 +00:00
|
|
|
|
2023-04-14 18:44:28 +00:00
|
|
|
private Q_SLOTS:
|
2023-04-27 02:05:56 +00:00
|
|
|
void handleIpifyFinished();
|
2023-04-23 11:35:38 +00:00
|
|
|
void handleHealthFinished();
|
2023-04-14 18:44:28 +00:00
|
|
|
void handleJsonUploadFinished();
|
2023-04-24 21:52:19 +00:00
|
|
|
void handleSslErrors(QNetworkReply *reply, const QList<QSslError> &errors);
|
2023-04-27 02:05:56 +00:00
|
|
|
void handleMixpanelFinished();
|
2023-06-29 00:42:40 +00:00
|
|
|
void handleIsActiveChanged();
|
|
|
|
void handleUsageStatsActiveChanged();
|
2023-04-14 18:44:28 +00:00
|
|
|
|
|
|
|
private:
|
2023-04-23 11:35:38 +00:00
|
|
|
void sendHealth();
|
2023-04-27 02:05:56 +00:00
|
|
|
void sendIpify();
|
2023-05-03 00:31:17 +00:00
|
|
|
void sendMixpanelEvent(const QString &event, const QVector<KeyValue> &values = QVector<KeyValue>());
|
2023-04-29 15:05:44 +00:00
|
|
|
void sendMixpanel(const QByteArray &json, bool isOptOut = false);
|
2023-04-24 01:05:38 +00:00
|
|
|
bool packageAndSendJson(const QString &ingestId, const QString &json);
|
2023-04-14 18:44:28 +00:00
|
|
|
|
|
|
|
private:
|
2023-04-27 02:05:56 +00:00
|
|
|
bool m_shouldSendStartup;
|
|
|
|
QString m_ipify;
|
2023-04-14 18:44:28 +00:00
|
|
|
QString m_uniqueId;
|
|
|
|
QNetworkAccessManager m_networkManager;
|
|
|
|
QVector<QNetworkReply*> m_activeUploads;
|
|
|
|
|
|
|
|
private:
|
|
|
|
explicit Network();
|
|
|
|
~Network() {}
|
|
|
|
friend class MyNetwork;
|
|
|
|
};
|
|
|
|
|
|
|
|
#endif // LLM_H
|