2014-07-23 14:51:56 -04:00
|
|
|
/****************************************************************
|
|
|
|
* RetroShare is distributed under the following license:
|
|
|
|
*
|
|
|
|
* Copyright (C) 2014 RetroShare Team
|
|
|
|
*
|
|
|
|
* This program is free 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 2
|
|
|
|
* 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
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
|
|
|
* Boston, MA 02110-1301, USA.
|
|
|
|
****************************************************************/
|
|
|
|
|
|
|
|
#ifndef GXSMESSAGEFRAMEPOSTWIDGET_H
|
|
|
|
#define GXSMESSAGEFRAMEPOSTWIDGET_H
|
|
|
|
|
2014-08-01 14:54:55 -04:00
|
|
|
#include <QThread>
|
|
|
|
|
2014-07-23 14:51:56 -04:00
|
|
|
#include "GxsMessageFrameWidget.h"
|
|
|
|
|
2014-08-01 14:54:55 -04:00
|
|
|
class GxsMessageFramePostThread;
|
2014-07-23 14:51:56 -04:00
|
|
|
|
2015-03-13 15:33:37 -04:00
|
|
|
class GxsMessageFramePostWidget : public GxsMessageFrameWidget
|
2014-07-23 14:51:56 -04:00
|
|
|
{
|
|
|
|
Q_OBJECT
|
|
|
|
|
2014-08-01 14:54:55 -04:00
|
|
|
friend class GxsMessageFramePostThread;
|
|
|
|
|
2014-07-23 14:51:56 -04:00
|
|
|
public:
|
|
|
|
explicit GxsMessageFramePostWidget(RsGxsIfaceHelper *ifaceImpl, QWidget *parent = NULL);
|
2014-08-01 14:54:55 -04:00
|
|
|
virtual ~GxsMessageFramePostWidget();
|
2014-07-23 14:51:56 -04:00
|
|
|
|
|
|
|
/* GxsMessageFrameWidget */
|
2015-03-13 15:33:37 -04:00
|
|
|
virtual void groupIdChanged();
|
2014-07-23 14:51:56 -04:00
|
|
|
virtual QString groupName(bool withUnreadCount);
|
|
|
|
// virtual QIcon groupIcon() = 0;
|
2014-10-25 19:52:33 -04:00
|
|
|
virtual bool navigate(const RsGxsMessageId& msgId);
|
2015-03-14 17:13:28 -04:00
|
|
|
virtual bool isLoading();
|
2014-07-23 14:51:56 -04:00
|
|
|
|
|
|
|
/* GXS functions */
|
|
|
|
virtual void loadRequest(const TokenQueue *queue, const TokenRequest &req);
|
|
|
|
|
|
|
|
int subscribeFlags() { return mSubscribeFlags; }
|
|
|
|
|
|
|
|
protected:
|
2015-03-14 17:13:28 -04:00
|
|
|
/* RsGxsUpdateBroadcastWidget */
|
2014-07-23 14:51:56 -04:00
|
|
|
virtual void updateDisplay(bool complete);
|
2015-03-14 17:13:28 -04:00
|
|
|
|
2014-07-23 14:51:56 -04:00
|
|
|
virtual void groupNameChanged(const QString &/*name*/) {}
|
|
|
|
|
2014-08-01 10:49:58 -04:00
|
|
|
virtual void clearPosts() = 0;
|
2014-10-25 19:52:33 -04:00
|
|
|
virtual bool navigatePostItem(const RsGxsMessageId& msgId) = 0;
|
2014-07-23 14:51:56 -04:00
|
|
|
|
2014-08-01 14:54:55 -04:00
|
|
|
/* Thread functions */
|
|
|
|
virtual bool useThread() { return false; }
|
|
|
|
virtual void fillThreadCreatePost(const QVariant &/*post*/, bool /*related*/, int /*current*/, int /*count*/) {}
|
|
|
|
|
2014-07-23 14:51:56 -04:00
|
|
|
/* GXS functions */
|
|
|
|
void requestGroupData();
|
|
|
|
void loadGroupData(const uint32_t &token);
|
|
|
|
virtual bool insertGroupData(const uint32_t &token, RsGroupMetaData &metaData) = 0;
|
|
|
|
|
2015-08-13 09:22:48 -04:00
|
|
|
void requestAllPosts();
|
|
|
|
void loadAllPosts(const uint32_t &token);
|
|
|
|
virtual void insertAllPosts(const uint32_t &token, GxsMessageFramePostThread *thread) = 0;
|
2014-07-23 14:51:56 -04:00
|
|
|
|
2015-08-13 09:22:48 -04:00
|
|
|
void requestPosts(const std::vector<RsGxsMessageId> &msgIds);
|
|
|
|
void loadPosts(const uint32_t &token);
|
|
|
|
virtual void insertPosts(const uint32_t &token) = 0;
|
2014-07-23 14:51:56 -04:00
|
|
|
|
2014-08-01 14:54:55 -04:00
|
|
|
private slots:
|
|
|
|
void fillThreadFinished();
|
|
|
|
void fillThreadAddPost(const QVariant &post, bool related, int current, int count);
|
|
|
|
|
2014-07-23 14:51:56 -04:00
|
|
|
protected:
|
|
|
|
uint32_t mTokenTypeGroupData;
|
2015-08-13 09:22:48 -04:00
|
|
|
uint32_t mTokenTypeAllPosts;
|
2014-07-23 14:51:56 -04:00
|
|
|
uint32_t mTokenTypePosts;
|
2014-10-25 19:52:33 -04:00
|
|
|
RsGxsMessageId mNavigatePendingMsgId;
|
2014-07-23 14:51:56 -04:00
|
|
|
|
|
|
|
private:
|
|
|
|
QString mGroupName;
|
|
|
|
int mSubscribeFlags;
|
2014-08-01 14:54:55 -04:00
|
|
|
GxsMessageFramePostThread *mFillThread;
|
|
|
|
};
|
|
|
|
|
|
|
|
class GxsMessageFramePostThread : public QThread
|
|
|
|
{
|
|
|
|
Q_OBJECT
|
|
|
|
|
|
|
|
public:
|
|
|
|
GxsMessageFramePostThread(uint32_t token, GxsMessageFramePostWidget *parent);
|
|
|
|
~GxsMessageFramePostThread();
|
|
|
|
|
|
|
|
void run();
|
|
|
|
void stop(bool waitForStop);
|
|
|
|
bool stopped() { return mStopped; }
|
|
|
|
|
|
|
|
void emitAddPost(const QVariant &post, bool related, int current, int count);
|
|
|
|
|
|
|
|
signals:
|
|
|
|
void addPost(const QVariant &post, bool related, int current, int count);
|
|
|
|
|
|
|
|
private:
|
|
|
|
uint32_t mToken;
|
|
|
|
GxsMessageFramePostWidget *mParent;
|
|
|
|
volatile bool mStopped;
|
2014-07-23 14:51:56 -04:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif // GXSMESSAGEFRAMEPOSTWIDGET_H
|