2015-02-08 00:18:25 +08:00
|
|
|
/*
|
|
|
|
This file is part of qTox, a Qt-based graphical interface for Tox.
|
|
|
|
|
|
|
|
This program is libre software: you can redistribute it and/or modify
|
|
|
|
it under the terms of the GNU General Public License as published by
|
|
|
|
the Free Software Foundation, either version 3 of the License, or
|
|
|
|
(at your option) any later version.
|
|
|
|
This program is distributed in the hope that it will be useful,
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
|
|
|
|
|
|
|
See the COPYING file for more details.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef OFFLINEMSGENGINE_H
|
|
|
|
#define OFFLINEMSGENGINE_H
|
|
|
|
|
|
|
|
#include <QObject>
|
|
|
|
#include <QSet>
|
|
|
|
#include <QMutex>
|
|
|
|
#include <QDateTime>
|
2015-02-08 01:49:38 +08:00
|
|
|
#include <QMap>
|
|
|
|
#include "src/chatlog/chatmessage.h"
|
2015-02-08 00:18:25 +08:00
|
|
|
|
2015-04-20 05:12:44 +08:00
|
|
|
class Friend;
|
2015-02-08 00:18:25 +08:00
|
|
|
class QTimer;
|
|
|
|
|
|
|
|
class OfflineMsgEngine : public QObject
|
|
|
|
{
|
|
|
|
Q_OBJECT
|
|
|
|
public:
|
|
|
|
OfflineMsgEngine(Friend *);
|
|
|
|
virtual ~OfflineMsgEngine();
|
2015-02-13 13:27:49 +08:00
|
|
|
static QMutex globalMutex;
|
2015-02-08 00:18:25 +08:00
|
|
|
|
|
|
|
void dischargeReceipt(int receipt);
|
2015-02-08 01:49:38 +08:00
|
|
|
void registerReceipt(int receipt, int messageID, ChatMessage::Ptr msg, const QDateTime ×tamp = QDateTime::currentDateTime());
|
2015-02-08 00:18:25 +08:00
|
|
|
|
|
|
|
public slots:
|
|
|
|
void deliverOfflineMsgs();
|
|
|
|
void removeAllReciepts();
|
|
|
|
|
|
|
|
private:
|
|
|
|
struct MsgPtr {
|
2015-02-08 01:49:38 +08:00
|
|
|
ChatMessage::Ptr msg;
|
2015-02-08 00:18:25 +08:00
|
|
|
QDateTime timestamp;
|
|
|
|
int receipt;
|
|
|
|
};
|
|
|
|
|
|
|
|
QMutex mutex;
|
|
|
|
Friend* f;
|
|
|
|
QHash<int, int> receipts;
|
|
|
|
QMap<int, MsgPtr> undeliveredMsgs;
|
|
|
|
|
|
|
|
static const int offlineTimeout;
|
|
|
|
};
|
|
|
|
|
|
|
|
#endif // OFFLINEMSGENGINE_H
|