comunicmessages/helpers/conversationslisthelper.h

80 lines
1.8 KiB
C
Raw Normal View History

2018-12-02 20:26:49 +00:00
/**
* Conversations list helper
*
* Does all the tasks related with conversations managment
*
* @author Pierre HUBERT
*/
#ifndef CONVERSATIONSLISTHELPER_H
#define CONVERSATIONSLISTHELPER_H
#include <QObject>
#include "../data/conversation.h"
2018-12-07 10:31:42 +00:00
#include "../data/userslist.h"
2018-12-02 20:26:49 +00:00
class QJsonObject;
class APIHelper;
class ConversationsList;
2018-12-02 20:26:49 +00:00
class ConversationsListHelper : public QObject
{
Q_OBJECT
public:
explicit ConversationsListHelper(QObject *parent = nullptr);
/**
* Get the list of conversations
*/
void getList();
2018-12-07 10:31:42 +00:00
/**
* Get and return the display name of a conversation
*
* @param conv Information about the target conversation
* @param usersInfo Information about related users
* @return The name of the conversation
*/
static QString getConversationDisplayName(const Conversation &conv, const UsersList &usersInfo);
2018-12-02 20:26:49 +00:00
signals:
/**
* This signal is emitted once we have a got a new list of conversation
*
* @param success TRUE for a success / FALSE else
* @param list The list of conversations
*/
void onGotList(bool success, const ConversationsList &list);
2018-12-02 20:26:49 +00:00
public slots:
private slots:
/**
* This slot is triggered once the request to the server was
* completed
*
* @param code Response code from the server
* @param document Response document
*/
void getConvListCallback(int code, const QJsonDocument &document);
private:
/**
* Turn a QJsonObject into a Conversation one
*
* @param obj The object to convert
* @return Generated conversation object
*/
static Conversation GetConversationFromJson(const QJsonObject &obj);
//Private fields
APIHelper *mAPIHelper;
};
#endif // CONVERSATIONSLISTHELPER_H