You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
81 lines
2.3 KiB
81 lines
2.3 KiB
#ifndef CONV_CONTEXT_H
|
|
#define CONV_CONTEXT_H
|
|
|
|
#include <QObject>
|
|
#include <QProcess>
|
|
#include <QNetworkAccessManager>
|
|
#include <QTimer>
|
|
|
|
#include <rtcom-eventlogger/eventlogger.h>
|
|
#include <glib.h>
|
|
#include <glib/gstdio.h>
|
|
|
|
#include "lib/http.h"
|
|
#include "lib/countries.h"
|
|
#include "models/ChatModel.h"
|
|
#include "models/ChatOverviewModel.h"
|
|
#include "wsclient.h"
|
|
|
|
struct rtcom_query {
|
|
RTComElQuery *query;
|
|
RTComElIter *it;
|
|
RTComEl *el = NULL;
|
|
};
|
|
|
|
class Conversations : public QObject {
|
|
Q_OBJECT
|
|
Q_PROPERTY(QString configRootconfigDirectory MEMBER configDirectory);
|
|
Q_PROPERTY(QString configRoot MEMBER configRoot);
|
|
Q_PROPERTY(QString pathGenericData MEMBER pathGenericData);
|
|
Q_PROPERTY(QString homeDir MEMBER homeDir);
|
|
Q_PROPERTY(QString accountName MEMBER accountName);
|
|
|
|
public:
|
|
explicit Conversations(QCommandLineParser *cmdargs);
|
|
~Conversations() override;
|
|
bool isDebug = false;
|
|
|
|
QCommandLineParser *cmdargs;
|
|
|
|
QString configDirectory;
|
|
QString configRoot;
|
|
QString pathGenericData;
|
|
QString homeDir;
|
|
QString accountName;
|
|
QHash<QString, CountryISO> countries_iso_3166_1;
|
|
QString applicationPath;
|
|
|
|
static void createConfigDirectory(const QString &dir) ;
|
|
|
|
WSClient *ws;
|
|
Countries *countries;
|
|
ChatModel *chatModel;
|
|
ChatOverviewModel *chatOverviewModel;
|
|
|
|
void setWindowTitle(const QString &title);
|
|
|
|
static rtcom_query* rtcomStartQuery(int limit, int offset, RTComElQueryGroupBy group_by = RTCOM_EL_QUERY_GROUP_BY_NONE);
|
|
static QList<ChatMessage*> rtcomIterateResults(rtcom_query *query_struct);
|
|
|
|
void getMessages(const QString &remote_uid, int limit, int offset) const;
|
|
void getOverviewMessages(int limit = 20, int offset = 0) const;
|
|
|
|
signals:
|
|
void clockSkewDetected();
|
|
void setTitle(const QString &title); // set window title
|
|
void showChat();
|
|
|
|
|
|
public slots:
|
|
void onSendMessage(const QString &message);
|
|
void requestChat(const QString &group_uid, const QString &local_uid, const QString &remote_uid);
|
|
|
|
private:
|
|
QTimer m_hibernateTimer;
|
|
std::chrono::seconds m_hibernateDetectInterval{300};
|
|
std::chrono::time_point<std::chrono::steady_clock> m_hibernatePreviousTime;
|
|
gint m_rtcom_sms_service_id = 3; // rtcom_el_get_service_id(el, "RTCOM_EL_SERVICE_SMS");
|
|
};
|
|
|
|
#endif // CONV_CONTEXT_H
|