completely removed TokenQueue from GxsGroupDialog and GxsGroupFrameDialog

This commit is contained in:
csoler 2020-03-22 21:47:14 +01:00
parent 7ba83272cf
commit 6c1f09a53b
No known key found for this signature in database
GPG Key ID: 7BCA522266C0804C
26 changed files with 423 additions and 217 deletions

View File

@ -398,6 +398,15 @@ public:
virtual bool subscribeToChannel( const RsGxsGroupId& channelId,
bool subscribe ) = 0;
/**
* \brief Retrieve statistics about the given channel
* @jsonapi{development}
* \param[in] channelId Id of the channel group
* \param[out] stat Statistics structure
* \return
*/
virtual bool getChannelStatistics(const RsGxsGroupId& channelId,GxsGroupStatistic& stat) =0;
/**
* @brief Request remote channels search
* @jsonapi{development}

View File

@ -219,6 +219,15 @@ public:
*/
virtual bool getForumsSummaries(std::list<RsGroupMetaData>& forums) = 0;
/**
* @brief returns statistics about a particular forum
* @jsonapi{development}
* @param[in] forumId Id of the forum
* @param[out] stat statistics struct
* @return false when the object doesn't exist or when the timeout is reached requesting the data
*/
virtual bool getForumStatistics(const RsGxsGroupId& forumId,GxsGroupStatistic& stat)=0;
/**
* @brief Get forums information (description, thumbnail...).
* Blocking API.
@ -361,5 +370,5 @@ public:
RS_DEPRECATED_FOR(createMessage)
virtual bool createMsg(uint32_t &token, RsGxsForumMsg &msg) = 0;
RS_DEPRECATED_FOR(editForum)
virtual bool updateGroup(uint32_t &token, RsGxsForumGroup &group) = 0;
virtual bool updateGroup(uint32_t &token, const RsGxsForumGroup &group) = 0;
};

View File

@ -340,13 +340,14 @@ public:
}
/// @see RsTokenService::requestGroupStatistic
void requestGroupStatistic(uint32_t& token, const RsGxsGroupId& grpId)
bool requestGroupStatistic(uint32_t& token, const RsGxsGroupId& grpId)
{
mTokenService.requestGroupStatistic(token, grpId);
RS_STACK_MUTEX(mMtx);
mActiveTokens[token]=TokenRequestType::GROUP_STATISTICS;
locked_dumpTokens();
return true;
}
bool cancelActiveRequestTokens(TokenRequestType type)

View File

@ -157,6 +157,12 @@ public:
std::vector<RsPostedPost>& posts,
std::vector<RsGxsComment>& comments ) = 0;
virtual bool editBoard(RsPostedGroup& board) =0;
virtual bool createBoard(RsPostedGroup& board) =0;
virtual bool getBoardStatistics(const RsGxsGroupId& boardId,GxsGroupStatistic& stat) =0;
enum RS_DEPRECATED RankType {TopRankType, HotRankType, NewRankType };
RS_DEPRECATED_FOR(getBoardsInfo)

View File

@ -1053,6 +1053,15 @@ bool p3GxsChannels::getChannelsInfo( const std::list<RsGxsGroupId>& chanIds, std
return getGroupData(token, channelsInfo) && !channelsInfo.empty();
}
bool p3GxsChannels::getChannelStatistics(const RsGxsGroupId& channelId,GxsGroupStatistic& stat)
{
uint32_t token;
if(!RsGxsIfaceHelper::requestGroupStatistic(token, channelId) || waitToken(token) != RsTokenService::COMPLETE)
return false;
return RsGenExchange::getGroupStatistic(token,stat);
}
bool p3GxsChannels::getContentSummaries(
const RsGxsGroupId& channelId, std::vector<RsMsgMetaData>& summaries )
{

View File

@ -196,6 +196,9 @@ virtual bool ExtraFileRemove(const RsFileHash &hash);
const RsGxsGroupId& channelId,
std::vector<RsMsgMetaData>& summaries ) override;
/// Implementation of @see RsGxsChannels::getChannelStatistics
bool getChannelStatistics(const RsGxsGroupId& channelId,GxsGroupStatistic& stat) override;
/// Implementation of @see RsGxsChannels::createChannelV2
bool createChannelV2(
const std::string& name, const std::string& description,

View File

@ -819,7 +819,16 @@ bool p3GxsForums::createGroup(uint32_t &token, RsGxsForumGroup &group)
return true;
}
bool p3GxsForums::updateGroup(uint32_t &token, RsGxsForumGroup &group)
bool p3GxsForums::getForumStatistics(const RsGxsGroupId& ForumId,GxsGroupStatistic& stat)
{
uint32_t token;
if(!RsGxsIfaceHelper::requestGroupStatistic(token, ForumId) || waitToken(token) != RsTokenService::COMPLETE)
return false;
return RsGenExchange::getGroupStatistic(token,stat);
}
bool p3GxsForums::updateGroup(uint32_t &token, const RsGxsForumGroup &group)
{
std::cerr << "p3GxsForums::updateGroup()" << std::endl;

View File

@ -94,6 +94,9 @@ public:
const std::list<RsGxsGroupId>& forumIds,
std::vector<RsGxsForumGroup>& forumsInfo );
/// Implementation of @see RsGxsForums::getForumStatistics
bool getForumStatistics(const RsGxsGroupId& ForumId,GxsGroupStatistic& stat) override;
/// @see RsGxsForums::getForumMsgMetaData
virtual bool getForumMsgMetaData(const RsGxsGroupId& forumId, std::vector<RsMsgMetaData>& msg_metas) ;
@ -125,13 +128,16 @@ public:
std::string& errMsg = RS_DEFAULT_STORAGE_PARAM(std::string)
) override;
virtual bool getGroupData(const uint32_t &token, std::vector<RsGxsForumGroup> &groups);
virtual bool getMsgData(const uint32_t &token, std::vector<RsGxsForumMsg> &msgs);
virtual bool getMsgMetaData(const uint32_t &token, GxsMsgMetaMap& msg_metas);
virtual void setMessageReadStatus(uint32_t& token, const RsGxsGrpMsgIdPair& msgId, bool read);
virtual bool createGroup(uint32_t &token, RsGxsForumGroup &group);
virtual bool createMsg(uint32_t &token, RsGxsForumMsg &msg);
virtual bool updateGroup(uint32_t &token, RsGxsForumGroup &group);
/// implementation of rsGxsGorums
///
bool getGroupData(const uint32_t &token, std::vector<RsGxsForumGroup> &groups) override;
bool getMsgData(const uint32_t &token, std::vector<RsGxsForumMsg> &msgs) override;
void setMessageReadStatus(uint32_t& token, const RsGxsGrpMsgIdPair& msgId, bool read) override;
bool createGroup(uint32_t &token, RsGxsForumGroup &group) override;
bool createMsg(uint32_t &token, RsGxsForumMsg &msg) override;
bool updateGroup(uint32_t &token, const RsGxsForumGroup &group) override;
bool getMsgMetaData(const uint32_t &token, GxsMsgMetaMap& msg_metas) ;
private:

View File

@ -350,5 +350,62 @@ bool p3Posted::getBoardsSummaries(std::list<RsGroupMetaData>& boards )
return getGroupSummary(token, boards);
}
bool p3Posted::getBoardStatistics(const RsGxsGroupId& boardId,GxsGroupStatistic& stat)
{
uint32_t token;
if(!RsGxsIfaceHelper::requestGroupStatistic(token, boardId) || waitToken(token) != RsTokenService::COMPLETE)
return false;
return RsGenExchange::getGroupStatistic(token,stat);
}
bool p3Posted::createBoard(RsPostedGroup& board)
{
uint32_t token;
if(!createGroup(token, board))
{
std::cerr << __PRETTY_FUNCTION__ << "Error! Failed creating group." << std::endl;
return false;
}
if(waitToken(token,std::chrono::milliseconds(5000)) != RsTokenService::COMPLETE)
{
std::cerr << __PRETTY_FUNCTION__ << "Error! GXS operation failed." << std::endl;
return false;
}
if(!RsGenExchange::getPublishedGroupMeta(token, board.mMeta))
{
std::cerr << __PRETTY_FUNCTION__ << "Error! Failure getting updated " << " group data." << std::endl;
return false;
}
return true;
}
bool p3Posted::editBoard(RsPostedGroup& board)
{
uint32_t token;
if(!updateGroup(token, board))
{
std::cerr << __PRETTY_FUNCTION__ << " Error! Failed updating group." << std::endl;
return false;
}
if(waitToken(token) != RsTokenService::COMPLETE)
{
std::cerr << __PRETTY_FUNCTION__ << " Error! GXS operation failed." << std::endl;
return false;
}
if(!RsGenExchange::getPublishedGroupMeta(token, board.mMeta))
{
std::cerr << __PRETTY_FUNCTION__ << " Error! Failure getting updated " << " group data." << std::endl;
return false;
}
return true;
}
RsPosted::~RsPosted() = default;
RsGxsPostedEvent::~RsGxsPostedEvent() = default;

View File

@ -68,6 +68,12 @@ virtual void receiveHelperChanges(std::vector<RsGxsNotify*>& changes)
bool getBoardsSummaries(std::list<RsGroupMetaData>& groupInfo) override;
bool getBoardStatistics(const RsGxsGroupId& boardId,GxsGroupStatistic& stat) override;
bool editBoard(RsPostedGroup& board) override;
bool createBoard(RsPostedGroup& board) override;
virtual bool getGroupData(const uint32_t &token, std::vector<RsPostedGroup> &groups);
virtual bool getPostData(const uint32_t &token, std::vector<RsPostedPost> &posts, std::vector<RsGxsComment> &cmts);
virtual bool getPostData(const uint32_t &token, std::vector<RsPostedPost> &posts) { std::vector<RsGxsComment> cmts; return getPostData( token, posts, cmts);}

View File

@ -167,14 +167,19 @@ bool PostedDialog::getGroupData(std::list<RsGxsGenericGroupData*>& groupInfo)
return true;
}
GxsGroupDialog *PostedDialog::createNewGroupDialog(TokenQueue *tokenQueue)
bool PostedDialog::getGroupStatistics(const RsGxsGroupId& groupId,GxsGroupStatistic& stat)
{
return new PostedGroupDialog(tokenQueue, this);
return rsPosted->getBoardStatistics(groupId,stat);
}
GxsGroupDialog *PostedDialog::createGroupDialog(TokenQueue *tokenQueue, RsTokenService *tokenService, GxsGroupDialog::Mode mode, RsGxsGroupId groupId)
GxsGroupDialog *PostedDialog::createNewGroupDialog()
{
return new PostedGroupDialog(tokenQueue, tokenService, mode, groupId, this);
return new PostedGroupDialog(this);
}
GxsGroupDialog *PostedDialog::createGroupDialog(GxsGroupDialog::Mode mode, RsGxsGroupId groupId)
{
return new PostedGroupDialog(mode, groupId, this);
}
int PostedDialog::shareKeyType()

View File

@ -48,14 +48,15 @@ protected:
void groupInfoToGroupItemInfo(const RsGxsGenericGroupData *groupData, GroupItemInfo &groupItemInfo) override;
bool getGroupData(std::list<RsGxsGenericGroupData*>& groupInfo) override;
bool getGroupStatistics(const RsGxsGroupId& groupId,GxsGroupStatistic& stat) override;
private:
/* GxsGroupFrameDialog */
virtual QString text(TextType type);
virtual QString icon(IconType type);
virtual QString settingsGroupName() { return "PostedDialog"; }
virtual GxsGroupDialog *createNewGroupDialog(TokenQueue *tokenQueue);
virtual GxsGroupDialog *createGroupDialog(TokenQueue *tokenQueue, RsTokenService *tokenService, GxsGroupDialog::Mode mode, RsGxsGroupId groupId);
virtual GxsGroupDialog *createNewGroupDialog();
virtual GxsGroupDialog *createGroupDialog(GxsGroupDialog::Mode mode, RsGxsGroupId groupId);
virtual int shareKeyType();
virtual GxsMessageFrameWidget *createMessageFrameWidget(const RsGxsGroupId &groupId);
virtual RsGxsCommentService *getCommentService();

View File

@ -56,13 +56,13 @@ uint32_t PostedCreateDefaultsFlags = ( GXS_GROUP_DEFAULTS_DISTRIB_PUBLIC |
uint32_t PostedEditEnabledFlags = PostedCreateEnabledFlags;
uint32_t PostedEditDefaultsFlags = PostedCreateDefaultsFlags;
PostedGroupDialog::PostedGroupDialog(TokenQueue *tokenQueue, QWidget *parent)
: GxsGroupDialog(tokenQueue, PostedCreateEnabledFlags, PostedCreateDefaultsFlags, parent)
PostedGroupDialog::PostedGroupDialog(QWidget *parent)
: GxsGroupDialog(PostedCreateEnabledFlags, PostedCreateDefaultsFlags, parent)
{
}
PostedGroupDialog::PostedGroupDialog(TokenQueue *tokenExternalQueue, RsTokenService *tokenService, Mode mode, RsGxsGroupId groupId, QWidget *parent)
: GxsGroupDialog(tokenExternalQueue, tokenService, mode, groupId, PostedEditEnabledFlags, PostedEditDefaultsFlags, parent)
PostedGroupDialog::PostedGroupDialog(Mode mode, RsGxsGroupId groupId, QWidget *parent)
: GxsGroupDialog(mode, groupId, PostedEditEnabledFlags, PostedEditDefaultsFlags, parent)
{
}
@ -112,18 +112,19 @@ void PostedGroupDialog::preparePostedGroup(RsPostedGroup &group, const RsGroupMe
}
}
bool PostedGroupDialog::service_CreateGroup(uint32_t &token, const RsGroupMetaData &meta)
bool PostedGroupDialog::service_createGroup(RsGroupMetaData& meta)
{
// Specific Function.
RsPostedGroup grp;
preparePostedGroup(grp, meta);
rsPosted->createGroup(token, grp);
if(rsPosted->createBoard(grp))
meta = grp.mMeta;
return true;
}
bool PostedGroupDialog::service_EditGroup(uint32_t &token, RsGroupMetaData &editedMeta)
bool PostedGroupDialog::service_updateGroup(const RsGroupMetaData& editedMeta)
{
RsPostedGroup grp;
preparePostedGroup(grp, editedMeta);
@ -131,45 +132,48 @@ bool PostedGroupDialog::service_EditGroup(uint32_t &token, RsGroupMetaData &edit
std::cerr << "PostedGroupDialog::service_EditGroup() submitting changes";
std::cerr << std::endl;
rsPosted->updateGroup(token, grp);
return true;
return rsPosted->editBoard(grp);
}
bool PostedGroupDialog::service_loadGroup(uint32_t token, Mode /*mode*/, RsGroupMetaData& groupMetaData, QString &description)
bool PostedGroupDialog::service_loadGroup(const RsGxsGenericGroupData *data, Mode mode, QString& description)
{
std::cerr << "PostedGroupDialog::service_loadGroup(" << token << ")";
std::cerr << std::endl;
const RsPostedGroup *pgroup = dynamic_cast<const RsPostedGroup*>(data);
std::vector<RsPostedGroup> groups;
if (!rsPosted->getGroupData(token, groups))
if(pgroup == nullptr)
{
std::cerr << "PostedGroupDialog::service_loadGroup() Error getting GroupData";
std::cerr << std::endl;
return false;
}
if (groups.size() != 1)
{
std::cerr << "PostedGroupDialog::service_loadGroup() Error Group.size() != 1";
std::cerr << std::endl;
std::cerr << "PostedGroupDialog::service_loadGroup() Error not a RsPostedGroup" << std::endl;
return false;
}
std::cerr << "PostedGroupDialog::service_loadGroup() Unfinished Loading";
std::cerr << std::endl;
const RsPostedGroup &group = groups[0];
groupMetaData = group.mMeta;
const RsPostedGroup& group = *pgroup;
description = QString::fromUtf8(group.mDescription.c_str());
if (group.mGroupImage.mData) {
if (group.mGroupImage.mData)
{
QPixmap pixmap;
if (GxsIdDetails::loadPixmapFromData(group.mGroupImage.mData, group.mGroupImage.mSize, pixmap,GxsIdDetails::ORIGINAL))
setLogo(pixmap);
} else {
setLogo(QPixmap(":/icons/png/posted.png"));
}
else
setLogo(QPixmap(":/icons/png/posted.png"));
return true;
}
bool PostedGroupDialog::service_getGroupData(const RsGxsGroupId& grpId,RsGxsGenericGroupData *& data)
{
std::vector<RsPostedGroup> boardsInfo ;
if( rsPosted->getBoardsInfo(std::list<RsGxsGroupId>({grpId}),boardsInfo) && boardsInfo.size() == 1)
{
data = new RsPostedGroup(boardsInfo[0]);
return true;
}
else
return false;
}

View File

@ -30,15 +30,16 @@ class PostedGroupDialog : public GxsGroupDialog
Q_OBJECT
public:
PostedGroupDialog(TokenQueue *tokenQueue, QWidget *parent);
PostedGroupDialog(TokenQueue *tokenExternalQueue, RsTokenService *tokenService, Mode mode, RsGxsGroupId groupId, QWidget *parent);
PostedGroupDialog(QWidget *parent);
PostedGroupDialog(Mode mode, RsGxsGroupId groupId, QWidget *parent);
protected:
virtual void initUi();
virtual QPixmap serviceImage();
virtual bool service_CreateGroup(uint32_t &token, const RsGroupMetaData &meta);
virtual bool service_loadGroup(uint32_t token, Mode mode, RsGroupMetaData& groupMetaData, QString &description);
virtual bool service_EditGroup(uint32_t &token, RsGroupMetaData &editedMeta);
void initUi() override;
QPixmap serviceImage() override;
bool service_createGroup(RsGroupMetaData& meta) override;
bool service_loadGroup(const RsGxsGenericGroupData *data,Mode mode, QString &description) override;
bool service_updateGroup(const RsGroupMetaData& editedMeta) override;
bool service_getGroupData(const RsGxsGroupId& grpId,RsGxsGenericGroupData *& data) override;
private:
void preparePostedGroup(RsPostedGroup &group, const RsGroupMetaData &meta);

View File

@ -23,6 +23,7 @@
#include "util/misc.h"
#include "util/DateTime.h"
#include "util/qtthreadsutils.h"
#include "GxsGroupDialog.h"
#include "gui/common/PeerDefs.h"
#include "gui/RetroShareLink.h"
@ -63,25 +64,21 @@
#define GXSGROUP_INTERNAL_LOADGROUP 3
/** Constructor */
GxsGroupDialog::GxsGroupDialog(TokenQueue *tokenExternalQueue, uint32_t enableFlags, uint32_t defaultFlags, QWidget *parent)
: QDialog(parent, Qt::WindowSystemMenuHint | Qt::WindowTitleHint | Qt::WindowCloseButtonHint), mTokenService(NULL), mExternalTokenQueue(tokenExternalQueue), mInternalTokenQueue(NULL), mGrpMeta(), mMode(MODE_CREATE), mEnabledFlags(enableFlags), mReadonlyFlags(0), mDefaultsFlags(defaultFlags)
GxsGroupDialog::GxsGroupDialog(uint32_t enableFlags, uint32_t defaultFlags, QWidget *parent)
: QDialog(parent, Qt::WindowSystemMenuHint | Qt::WindowTitleHint | Qt::WindowCloseButtonHint), mGrpMeta(), mMode(MODE_CREATE), mEnabledFlags(enableFlags), mReadonlyFlags(0), mDefaultsFlags(defaultFlags)
{
/* Invoke the Qt Designer generated object setup routine */
ui.setupUi(this);
mInternalTokenQueue = NULL;
init();
}
GxsGroupDialog::GxsGroupDialog(TokenQueue *tokenExternalQueue, RsTokenService *tokenService, Mode mode, RsGxsGroupId groupId, uint32_t enableFlags, uint32_t defaultFlags, QWidget *parent)
: QDialog(parent, Qt::WindowSystemMenuHint | Qt::WindowTitleHint | Qt::WindowCloseButtonHint), mTokenService(NULL), mExternalTokenQueue(tokenExternalQueue), mInternalTokenQueue(NULL), mGrpMeta(), mMode(mode), mEnabledFlags(enableFlags), mReadonlyFlags(0), mDefaultsFlags(defaultFlags)
GxsGroupDialog::GxsGroupDialog(Mode mode, RsGxsGroupId groupId, uint32_t enableFlags, uint32_t defaultFlags, QWidget *parent)
: QDialog(parent, Qt::WindowSystemMenuHint | Qt::WindowTitleHint | Qt::WindowCloseButtonHint), mGrpMeta(), mMode(mode), mEnabledFlags(enableFlags), mReadonlyFlags(0), mDefaultsFlags(defaultFlags)
{
/* Invoke the Qt Designer generated object setup routine */
ui.setupUi(this);
mTokenService = tokenService;
mInternalTokenQueue = new TokenQueue(tokenService, this);
mGrpMeta.mGroupId = groupId;
init();
@ -90,9 +87,6 @@ GxsGroupDialog::GxsGroupDialog(TokenQueue *tokenExternalQueue, RsTokenService *t
GxsGroupDialog::~GxsGroupDialog()
{
Settings->saveWidgetInformation(this);
if (mInternalTokenQueue) {
delete(mInternalTokenQueue);
}
}
void GxsGroupDialog::init()
@ -179,6 +173,9 @@ void GxsGroupDialog::showEvent(QShowEvent*)
setWindowIcon(serviceWindowIcon());
initUi();
if(!mGrpMeta.mGroupId.isNull() && mGrpMeta.mPublishTs == 0) // group not actually loaded yet
loadGroup(mGrpMeta.mGroupId);
}
void GxsGroupDialog::setUiText(UiType uiType, const QString &text)
@ -237,7 +234,6 @@ void GxsGroupDialog::initMode()
ui.stackedWidget->setCurrentIndex(1);
mReadonlyFlags = 0xffffffff; // Force all to readonly.
ui.buttonBox->setStandardButtons(QDialogButtonBox::Close);
requestGroup(mGrpMeta.mGroupId);
}
break;
@ -246,7 +242,6 @@ void GxsGroupDialog::initMode()
ui.stackedWidget->setCurrentIndex(0);
ui.buttonBox->setStandardButtons(QDialogButtonBox::Ok | QDialogButtonBox::Cancel);
ui.buttonBox->button(QDialogButtonBox::Ok)->setText(tr("Submit Group Changes"));
requestGroup(mGrpMeta.mGroupId);
}
break;
}
@ -596,14 +591,7 @@ void GxsGroupDialog::editGroup()
std::cerr << "GxsGroupDialog::editGroup() calling service_EditGroup";
std::cerr << std::endl;
uint32_t token;
if (service_EditGroup(token, newMeta))
{
// get the Queue to handle response.
if(mExternalTokenQueue != NULL)
mExternalTokenQueue->queueRequest(token, TOKENREQ_GROUPINFO, RS_TOKREQ_ANSTYPE_ACK, GXSGROUP_NEWGROUPID);
}
else
if (!service_updateGroup(newMeta))
{
std::cerr << "GxsGroupDialog::editGroup() ERROR";
std::cerr << std::endl;
@ -676,7 +664,6 @@ void GxsGroupDialog::createGroup()
return; //Don't add a empty name!!
}
uint32_t token;
RsGroupMetaData meta;
QString reason;
if (!prepareGroupMetaData(meta, reason))
@ -686,11 +673,16 @@ void GxsGroupDialog::createGroup()
return; //Don't add with invalid circle.
}
if (service_CreateGroup(token, meta))
if (service_createGroup(meta))
{
// get the Queue to handle response.
// now update the UI
#warning Missing code here!
#ifdef TODO
//
// get the Queue to handle response. What is this for?
if(mExternalTokenQueue != NULL)
mExternalTokenQueue->queueRequest(token, TOKENREQ_GROUPINFO, RS_TOKREQ_ANSTYPE_ACK, GXSGROUP_NEWGROUPID);
#endif
}
close();
@ -984,6 +976,40 @@ void GxsGroupDialog::filterComboBoxChanged(int i)
Loading Group.
***********************************************************************************/
void GxsGroupDialog::loadGroup(const RsGxsGroupId& grpId)
{
RsThread::async([this,grpId]()
{
RsGxsGenericGroupData *groupData;
if(!service_getGroupData(grpId,groupData))
{
std::cerr << __PRETTY_FUNCTION__ << " failed to collect group info " << std::endl;
return;
}
RsQThreadUtils::postToObject( [this,groupData]()
{
/* Here it goes any code you want to be executed on the Qt Gui
* thread, for example to update the data model with new information
* after a blocking call to RetroShare API complete, note that
* Qt::QueuedConnection is important!
*/
mGrpMeta = groupData->mMeta;
QString description;
if (service_loadGroup(groupData, mMode, description))
updateFromExistingMeta(description);
delete groupData;
}, this );
});
}
#ifdef TO_REMOVE
void GxsGroupDialog::requestGroup(const RsGxsGroupId &groupId)
{
RsTokReqOptions opts;
@ -1032,3 +1058,4 @@ void GxsGroupDialog::loadRequest(const TokenQueue *queue, const TokenRequest &re
}
}
}
#endif

View File

@ -108,7 +108,7 @@ public:
* The long term plan is perhap logic structure (i.e. code) will be moved into each GXS \n
* service for better customisation of group creation, or perhaps not!
*/
class GxsGroupDialog : public QDialog, public TokenResponse
class GxsGroupDialog : public QDialog
{
Q_OBJECT
@ -131,15 +131,12 @@ public:
/*!
* Constructs a GxsGroupDialog for creating group
* @param tokenQueue This should be the TokenQueue of the (parent) service
* in order to receive acknowledgement of group creation, if set to NULL with create mode \n
* creation will not happen
* @param enableFlags This determines what options are enabled such as Icon, Description, publish type and key sharing
* @param defaultFlags This deter
* @param parent The parent dialog
* @param mode
*/
GxsGroupDialog(TokenQueue* tokenQueue, uint32_t enableFlags, uint32_t defaultFlags, QWidget *parent = NULL);
GxsGroupDialog(uint32_t enableFlags, uint32_t defaultFlags, QWidget *parent = NULL);
/*!
* Contructs a GxsGroupDialog for display a group or editing
@ -147,15 +144,12 @@ public:
* @param mode This determines whether the dialog starts in show or edit mode (Edit not supported yet)
* @param parent
*/
GxsGroupDialog(TokenQueue *tokenExternalQueue, RsTokenService *tokenService, Mode mode, RsGxsGroupId groupId, uint32_t enableFlags, uint32_t defaultFlags, QWidget *parent = NULL);
GxsGroupDialog(Mode mode, RsGxsGroupId groupId, uint32_t enableFlags, uint32_t defaultFlags, QWidget *parent = NULL);
~GxsGroupDialog();
uint32_t mode() { return mMode; }
// overloaded from TokenResponse
virtual void loadRequest(const TokenQueue *queue, const TokenRequest &req);
private:
void newGroup();
void init();
@ -191,24 +185,37 @@ protected:
void setUiToolTip(UiType uiType, const QString &text);
void setUiText (UiType uiType, const QString &text);
/*!
* It is up to the service to retrieve its own group data, which derives from RsGxsGenericGroupData. That data will be passed down
* to the service itself for specific tasks.
* \param grpId Id of the group to retrieve
* \param data Generic group data for this group. /!\ The pointer should be deleted by the client when released.
* \return True if everything does fine.
*/
virtual bool service_getGroupData(const RsGxsGroupId& grpId,RsGxsGenericGroupData *& data) = 0;
/*!
* It is up to the service to do the actual group creation
* Service can also modify initial meta going into group
* @param token This should be set to the token retrieved
* @param meta The deriving GXS service should set their grp meta to this value
*/
virtual bool service_CreateGroup(uint32_t &token, const RsGroupMetaData &meta) = 0;
virtual bool service_createGroup(RsGroupMetaData& meta) = 0;
/*!
* It is up to the service to do the actual group editing
* @param token This should be set to the token retrieved
* @param meta The deriving GXS service should set their grp meta to this value
*/
virtual bool service_EditGroup(uint32_t &token, RsGroupMetaData &editedMeta) = 0;
virtual bool service_updateGroup(const RsGroupMetaData& editedMeta) = 0;
// To be overloaded by users.
// use Token to retrieve from service, fill in metaData.
virtual bool service_loadGroup(uint32_t token, Mode mode, RsGroupMetaData& groupMetaData, QString &description) = 0;
/*!
* Should be overloaded by the service in order to extract meaningful information from the group data (that is usually group-specific).
* One of them however, common to all groups is the description. So it is returned by this method so that the GxsGroupDialog updates it.
* \param data Generic group data, to be dynamic_cast by the client to specific service-level group data
* \param mode Editing mode (?)
* \param description Description string for the group. Common to all services, but still present in the service-specific data part.
* \return
*/
virtual bool service_loadGroup(const RsGxsGenericGroupData *data, Mode mode, QString &description) = 0;
/*!
* This returns a group logo from the ui \n
@ -270,8 +277,7 @@ private:
void loadNewGroupId(const uint32_t &token);
// loading existing Groups.
void requestGroup(const RsGxsGroupId &groupId);
void loadGroup(uint32_t token);
void loadGroup(const RsGxsGroupId &groupId);
void updateFromExistingMeta(const QString &description);
bool prepareGroupMetaData(RsGroupMetaData &meta, QString &reason);

View File

@ -88,8 +88,6 @@ GxsGroupFrameDialog::GxsGroupFrameDialog(RsGxsIfaceHelper *ifaceImpl, QWidget *p
/* Setup Queue */
mInterface = ifaceImpl;
mTokenService = mInterface->getTokenService();
mTokenQueue = new TokenQueue(mInterface->getTokenService(), this);
/* Setup UI helper */
mStateHelper = new UIStateHelper(this);
@ -127,7 +125,6 @@ GxsGroupFrameDialog::~GxsGroupFrameDialog()
// save settings
processSettings(false);
delete(mTokenQueue);
delete(ui);
}
@ -548,7 +545,8 @@ void GxsGroupFrameDialog::restoreGroupKeys(void)
void GxsGroupFrameDialog::newGroup()
{
GxsGroupDialog *dialog = createNewGroupDialog(mTokenQueue);
GxsGroupDialog *dialog = createNewGroupDialog();
if (!dialog) {
return;
}
@ -575,8 +573,6 @@ void GxsGroupFrameDialog::groupSubscribe(bool subscribe)
uint32_t token;
mInterface->subscribeToGroup(token, mGroupId, subscribe);
// Replaced by meta data changed
// mTokenQueue->queueRequest(token, 0, RS_TOKREQ_ANSTYPE_ACK, TOKEN_TYPE_SUBSCRIBE_CHANGE);
}
void GxsGroupFrameDialog::showGroupDetails()
@ -585,7 +581,7 @@ void GxsGroupFrameDialog::showGroupDetails()
return;
}
GxsGroupDialog *dialog = createGroupDialog(mTokenQueue, mInterface->getTokenService(), GxsGroupDialog::MODE_SHOW, mGroupId);
GxsGroupDialog *dialog = createGroupDialog(GxsGroupDialog::MODE_SHOW, mGroupId);
if (!dialog) {
return;
}
@ -600,7 +596,7 @@ void GxsGroupFrameDialog::editGroupDetails()
return;
}
GxsGroupDialog *dialog = createGroupDialog(mTokenQueue, mInterface->getTokenService(), GxsGroupDialog::MODE_EDIT, mGroupId);
GxsGroupDialog *dialog = createGroupDialog(GxsGroupDialog::MODE_EDIT, mGroupId);
if (!dialog) {
return;
}
@ -995,7 +991,8 @@ void GxsGroupFrameDialog::updateMessageSummaryList(RsGxsGroupId groupId)
return;
}
if (groupId.isNull()) {
if (groupId.isNull())
{
QTreeWidgetItem *items[2] = { mYourGroups, mSubscribedGroups };
for (int item = 0; item < 2; ++item) {
int child;
@ -1003,16 +1000,15 @@ void GxsGroupFrameDialog::updateMessageSummaryList(RsGxsGroupId groupId)
for (child = 0; child < childCount; ++child) {
QTreeWidgetItem *childItem = items[item]->child(child);
QString childId = ui->groupTreeWidget->itemId(childItem);
if (childId.isEmpty()) {
if (childId.isEmpty())
continue;
}
requestGroupStatistics(RsGxsGroupId(childId.toLatin1().constData()));
updateGroupStatistics(RsGxsGroupId(childId.toLatin1().constData()));
}
}
} else {
requestGroupStatistics(groupId);
}
else
updateGroupStatistics(groupId);
}
/*********************** **** **** **** ***********************/
@ -1163,13 +1159,39 @@ void GxsGroupFrameDialog::loadGroupSummary(const std::list<RsGxsGenericGroupData
/*********************** **** **** **** ***********************/
/*********************** **** **** **** ***********************/
void GxsGroupFrameDialog::requestGroupStatistics(const RsGxsGroupId &groupId)
void GxsGroupFrameDialog::updateGroupStatistics(const RsGxsGroupId &groupId)
{
uint32_t token;
mTokenService->requestGroupStatistic(token, groupId);
mTokenQueue->queueRequest(token, 0, RS_TOKREQ_ANSTYPE_ACK, TOKEN_TYPE_STATISTICS);
RsThread::async([this,groupId]()
{
GxsGroupStatistic stats;
if(! getGroupStatistics(groupId, stats))
{
std::cerr << __PRETTY_FUNCTION__ << " failed to collect group statistics for group " << groupId << std::endl;
return;
}
RsQThreadUtils::postToObject( [this,stats]()
{
/* Here it goes any code you want to be executed on the Qt Gui
* thread, for example to update the data model with new information
* after a blocking call to RetroShare API complete, note that
* Qt::QueuedConnection is important!
*/
QTreeWidgetItem *item = ui->groupTreeWidget->getItemFromId(QString::fromStdString(stats.mGrpId.toStdString()));
if (!item)
return;
ui->groupTreeWidget->setUnreadCount(item, mCountChildMsgs ? (stats.mNumThreadMsgsUnread + stats.mNumChildMsgsUnread) : stats.mNumThreadMsgsUnread);
getUserNotify()->updateIcon();
}, this );
});
}
#ifdef TO_REMOVE
void GxsGroupFrameDialog::loadGroupStatistics(const uint32_t &token)
{
GxsGroupStatistic stats;
@ -1222,6 +1244,7 @@ void GxsGroupFrameDialog::loadRequest(const TokenQueue *queue, const TokenReques
}
}
}
#endif
TurtleRequestId GxsGroupFrameDialog::distantSearch(const QString& search_string) // this should be overloaded in the child class
{

View File

@ -44,7 +44,7 @@ class UIStateHelper;
struct RsGxsCommentService;
class GxsCommentDialog;
class GxsGroupFrameDialog : public MainPage, public TokenResponse
class GxsGroupFrameDialog : public MainPage
{
Q_OBJECT
@ -76,9 +76,6 @@ public:
bool navigate(const RsGxsGroupId &groupId, const RsGxsMessageId& msgId);
// Callback for all Loads.
virtual void loadRequest(const TokenQueue *queue, const TokenRequest &req);
virtual QString getHelpString() const =0;
virtual void getGroupList(std::map<RsGxsGroupId,RsGroupMetaData> &groups) ;
@ -97,10 +94,14 @@ protected:
virtual void checkRequestGroup(const RsGxsGroupId& /* grpId */) {} // overload this one in order to retrieve full group data when the group is browsed
void updateMessageSummaryList(RsGxsGroupId groupId);
void updateGroupStatistics(const RsGxsGroupId &groupId);
virtual const std::set<TurtleRequestId> getSearchRequests() const { return std::set<TurtleRequestId>(); } // overload this for subclasses that provide distant search
// These two need to be overloaded by subsclasses, possibly calling the blocking API, since they are used asynchroneously.
virtual bool getGroupData(std::list<RsGxsGenericGroupData*>& groupInfo) =0;
virtual bool getGroupStatistics(const RsGxsGroupId& groupId,GxsGroupStatistic& stat) =0;
private slots:
void todo();
@ -147,8 +148,8 @@ private:
virtual QString settingsGroupName() = 0;
virtual TurtleRequestId distantSearch(const QString& search_string) ;
virtual GxsGroupDialog *createNewGroupDialog(TokenQueue *tokenQueue) = 0;
virtual GxsGroupDialog *createGroupDialog(TokenQueue *tokenQueue, RsTokenService *tokenService, GxsGroupDialog::Mode mode, RsGxsGroupId groupId) = 0;
virtual GxsGroupDialog *createNewGroupDialog() = 0;
virtual GxsGroupDialog *createGroupDialog(GxsGroupDialog::Mode mode, RsGxsGroupId groupId) = 0;
virtual int shareKeyType() = 0;
virtual GxsMessageFrameWidget *createMessageFrameWidget(const RsGxsGroupId &groupId) = 0;
virtual void groupTreeCustomActions(RsGxsGroupId /*grpId*/, int /*subscribeFlags*/, QList<QAction*> &/*actions*/) {}
@ -198,8 +199,6 @@ private:
QString mSettingsName;
RsGxsGroupId mGroupId;
RsGxsIfaceHelper *mInterface;
RsTokenService *mTokenService;
TokenQueue *mTokenQueue;
GxsMessageFrameWidget *mMessageWidget;
QTreeWidgetItem *mYourGroups;

View File

@ -181,14 +181,14 @@ QString GxsChannelDialog::icon(IconType type)
return "";
}
GxsGroupDialog *GxsChannelDialog::createNewGroupDialog(TokenQueue *tokenQueue)
GxsGroupDialog *GxsChannelDialog::createNewGroupDialog()
{
return new GxsChannelGroupDialog(tokenQueue, this);
return new GxsChannelGroupDialog(this);
}
GxsGroupDialog *GxsChannelDialog::createGroupDialog(TokenQueue *tokenQueue, RsTokenService *tokenService, GxsGroupDialog::Mode mode, RsGxsGroupId groupId)
GxsGroupDialog *GxsChannelDialog::createGroupDialog(GxsGroupDialog::Mode mode, RsGxsGroupId groupId)
{
return new GxsChannelGroupDialog(tokenQueue, tokenService, mode, groupId, this);
return new GxsChannelGroupDialog(mode, groupId, this);
}
int GxsChannelDialog::shareKeyType()
@ -344,6 +344,11 @@ void GxsChannelDialog::toggleAutoDownload()
});
}
bool GxsChannelDialog::getGroupStatistics(const RsGxsGroupId& groupId,GxsGroupStatistic& stat)
{
return rsGxsChannels->getChannelStatistics(groupId,stat);
}
bool GxsChannelDialog::getGroupData(std::list<RsGxsGenericGroupData*>& groupInfo)
{
std::vector<RsGxsChannelGroup> groups;

View File

@ -43,18 +43,21 @@ public:
protected:
/* GxsGroupFrameDialog */
virtual RetroShareLink::enumType getLinkType() { return RetroShareLink::TYPE_CHANNEL; }
virtual GroupFrameSettings::Type groupFrameSettingsType() { return GroupFrameSettings::Channel; }
virtual QString getHelpString() const ;
virtual bool getDistantSearchResults(TurtleRequestId id, std::map<RsGxsGroupId,RsGxsGroupSummary>& group_infos);
virtual TurtleRequestId distantSearch(const QString& search_string) ;
virtual void checkRequestGroup(const RsGxsGroupId& grpId) ;
// Implementation of some abstract methods in GxsGroupFrameDialog
virtual QString getHelpString() const override;
GroupFrameSettings::Type groupFrameSettingsType() override { return GroupFrameSettings::Channel; }
RetroShareLink::enumType getLinkType() override { return RetroShareLink::TYPE_CHANNEL; }
void groupInfoToGroupItemInfo(const RsGxsGenericGroupData *groupData, GroupItemInfo &groupItemInfo) override;
const std::set<TurtleRequestId> getSearchRequests() const override { return mSearchResults ; }
UserNotify *createUserNotify(QObject *parent) override;
bool getGroupData(std::list<RsGxsGenericGroupData*>& groupInfo) override;
void groupInfoToGroupItemInfo(const RsGxsGenericGroupData *groupData, GroupItemInfo &groupItemInfo) override;
bool getGroupStatistics(const RsGxsGroupId& groupId,GxsGroupStatistic& stat) override;
private slots:
void toggleAutoDownload();
@ -67,8 +70,8 @@ private:
virtual QString text(TextType type);
virtual QString icon(IconType type);
virtual QString settingsGroupName() { return "ChannelDialog"; }
virtual GxsGroupDialog *createNewGroupDialog(TokenQueue *tokenQueue);
virtual GxsGroupDialog *createGroupDialog(TokenQueue *tokenQueue, RsTokenService *tokenService, GxsGroupDialog::Mode mode, RsGxsGroupId groupId);
virtual GxsGroupDialog *createNewGroupDialog();
virtual GxsGroupDialog *createGroupDialog(GxsGroupDialog::Mode mode, RsGxsGroupId groupId);
virtual int shareKeyType();
virtual GxsMessageFrameWidget *createMessageFrameWidget(const RsGxsGroupId &groupId);
virtual void groupTreeCustomActions(RsGxsGroupId grpId, int subscribeFlags, QList<QAction*> &actions);

View File

@ -59,15 +59,15 @@ const uint32_t ChannelCreateDefaultsFlags = ( GXS_GROUP_DEFAULTS_DISTRIB_PUBLIC
const uint32_t ChannelEditEnabledFlags = ChannelCreateEnabledFlags;
const uint32_t ChannelEditDefaultsFlags = ChannelCreateDefaultsFlags;
GxsChannelGroupDialog::GxsChannelGroupDialog(TokenQueue *tokenQueue, QWidget *parent)
: GxsGroupDialog(tokenQueue, ChannelCreateEnabledFlags, ChannelCreateDefaultsFlags, parent)
GxsChannelGroupDialog::GxsChannelGroupDialog(QWidget *parent)
: GxsGroupDialog(ChannelCreateEnabledFlags, ChannelCreateDefaultsFlags, parent)
{
ui.commentGroupBox->setEnabled(false); // These are here because comments_allowed are actually not used yet, so the group will not be changed by the setting and when
ui.comments_allowed->setChecked(true); // the group info is displayed it will therefore be set to "disabled" in all cases although it is enabled.
}
GxsChannelGroupDialog::GxsChannelGroupDialog(TokenQueue *tokenExternalQueue, RsTokenService *tokenService, Mode mode, RsGxsGroupId groupId, QWidget *parent)
: GxsGroupDialog(tokenExternalQueue, tokenService, mode, groupId, ChannelEditEnabledFlags, ChannelEditDefaultsFlags, parent)
GxsChannelGroupDialog::GxsChannelGroupDialog(Mode mode, RsGxsGroupId groupId, QWidget *parent)
: GxsGroupDialog(mode, groupId, ChannelEditEnabledFlags, ChannelEditDefaultsFlags, parent)
{
ui.commentGroupBox->setEnabled(false); // These are here because comments_allowed are actually not used yet, so the group will not be changed by the setting and when
ui.comments_allowed->setChecked(true); // the group info is displayed it will therefore be set to "disabled" in all cases although it is enabled.
@ -129,17 +129,19 @@ void GxsChannelGroupDialog::prepareChannelGroup(RsGxsChannelGroup &group, const
}
}
bool GxsChannelGroupDialog::service_CreateGroup(uint32_t &token, const RsGroupMetaData &meta)
bool GxsChannelGroupDialog::service_createGroup(RsGroupMetaData& meta)
{
// Specific Function.
RsGxsChannelGroup grp;
prepareChannelGroup(grp, meta);
rsGxsChannels->createGroup(token, grp);
rsGxsChannels->createChannel(grp);
meta = grp.mMeta;
return true;
}
bool GxsChannelGroupDialog::service_EditGroup(uint32_t &token, RsGroupMetaData &editedMeta)
bool GxsChannelGroupDialog::service_updateGroup(const RsGroupMetaData& editedMeta)
{
RsGxsChannelGroup grp;
prepareChannelGroup(grp, editedMeta);
@ -147,44 +149,42 @@ bool GxsChannelGroupDialog::service_EditGroup(uint32_t &token, RsGroupMetaData &
std::cerr << "GxsChannelGroupDialog::service_EditGroup() submitting changes";
std::cerr << std::endl;
rsGxsChannels->updateGroup(token, grp);
return true;
return rsGxsChannels->editChannel(grp);
}
bool GxsChannelGroupDialog::service_loadGroup(uint32_t token, Mode /*mode*/, RsGroupMetaData& groupMetaData, QString &description)
bool GxsChannelGroupDialog::service_loadGroup(const RsGxsGenericGroupData *data, Mode /*mode*/, QString& description)
{
std::cerr << "GxsChannelGroupDialog::service_loadGroup(" << token << ")";
std::cerr << std::endl;
const RsGxsChannelGroup *pgroup = dynamic_cast<const RsGxsChannelGroup*>(data);
std::vector<RsGxsChannelGroup> groups;
if (!rsGxsChannels->getGroupData(token, groups))
if (!pgroup)
{
std::cerr << "GxsChannelGroupDialog::service_loadGroup() Error getting GroupData";
std::cerr << std::endl;
std::cerr << "GxsChannelGroupDialog::service_loadGroup() Error supplied generic group data is not a RsGxsChannelGroup" << std::endl;
return false;
}
if (groups.size() != 1)
{
std::cerr << "GxsChannelGroupDialog::service_loadGroup() Error Group.size() != 1";
std::cerr << std::endl;
return false;
}
std::cerr << "GxsChannelsGroupDialog::service_loadGroup() Unfinished Loading";
std::cerr << std::endl;
const RsGxsChannelGroup &group = groups[0];
groupMetaData = group.mMeta;
const RsGxsChannelGroup& group = *pgroup;
description = QString::fromUtf8(group.mDescription.c_str());
if (group.mImage.mData) {
QPixmap pixmap;
if (GxsIdDetails::loadPixmapFromData(group.mImage.mData, group.mImage.mSize,pixmap,GxsIdDetails::ORIGINAL)) {
if (GxsIdDetails::loadPixmapFromData(group.mImage.mData, group.mImage.mSize,pixmap,GxsIdDetails::ORIGINAL))
setLogo(pixmap);
}
}
return true;
}
bool GxsChannelGroupDialog::service_getGroupData(const RsGxsGroupId& grpId,RsGxsGenericGroupData *& data)
{
std::vector<RsGxsChannelGroup> forumsInfo ;
if( rsGxsChannels->getChannelsInfo(std::list<RsGxsGroupId>({grpId}),forumsInfo) && forumsInfo.size() == 1)
{
data = new RsGxsChannelGroup(forumsInfo[0]);
return true;
}
else
return false;
}

View File

@ -29,15 +29,16 @@ class GxsChannelGroupDialog : public GxsGroupDialog
Q_OBJECT
public:
GxsChannelGroupDialog(TokenQueue *tokenQueue, QWidget *parent);
GxsChannelGroupDialog(TokenQueue *tokenExternalQueue, RsTokenService *tokenService, Mode mode, RsGxsGroupId groupId, QWidget *parent = NULL);
GxsChannelGroupDialog(QWidget *parent);
GxsChannelGroupDialog(Mode mode, RsGxsGroupId groupId, QWidget *parent = NULL);
protected:
virtual void initUi();
virtual QPixmap serviceImage();
virtual bool service_CreateGroup(uint32_t &token, const RsGroupMetaData &meta);
virtual bool service_loadGroup(uint32_t token, Mode mode, RsGroupMetaData& groupMetaData, QString &description);
virtual bool service_EditGroup(uint32_t &token, RsGroupMetaData &editedMeta);
void initUi() override;
QPixmap serviceImage() override;
bool service_createGroup(RsGroupMetaData &meta) override;
bool service_loadGroup(const RsGxsGenericGroupData *data,Mode mode, QString& description) override;
bool service_updateGroup(const RsGroupMetaData& editedMeta) override;
bool service_getGroupData(const RsGxsGroupId& grpId,RsGxsGenericGroupData *& data) override;
private:
void prepareChannelGroup(RsGxsChannelGroup &group, const RsGroupMetaData &meta);

View File

@ -58,15 +58,15 @@ const uint32_t ForumCreateDefaultsFlags = ( GXS_GROUP_DEFAULTS_DISTRIB_PUBLIC
const uint32_t ForumEditEnabledFlags = ForumCreateEnabledFlags;
const uint32_t ForumEditDefaultsFlags = ForumCreateDefaultsFlags;
GxsForumGroupDialog::GxsForumGroupDialog(TokenQueue *tokenQueue, QWidget *parent)
: GxsGroupDialog(tokenQueue, ForumCreateEnabledFlags, ForumCreateDefaultsFlags, parent)
GxsForumGroupDialog::GxsForumGroupDialog(QWidget *parent)
: GxsGroupDialog(ForumCreateEnabledFlags, ForumCreateDefaultsFlags, parent)
{
ui.pubKeyShare_cb->setEnabled(true) ;
ui.label_2->setToolTip(tr("<p>Put one of your identities here to allow others to send feedback and also have moderator rights on the forum. You may as well leave that field blank and keep the forum anonymously administrated.</p>"));
}
GxsForumGroupDialog::GxsForumGroupDialog(TokenQueue *tokenExternalQueue, RsTokenService *tokenService, Mode mode, RsGxsGroupId groupId, QWidget *parent)
: GxsGroupDialog(tokenExternalQueue, tokenService, mode, groupId, ForumEditEnabledFlags, ForumEditDefaultsFlags, parent)
GxsForumGroupDialog::GxsForumGroupDialog(Mode mode, RsGxsGroupId groupId, QWidget *parent)
: GxsGroupDialog(mode, groupId, ForumEditEnabledFlags, ForumEditDefaultsFlags, parent)
{
ui.pubKeyShare_cb->setEnabled(true) ;
}
@ -99,7 +99,7 @@ QPixmap GxsForumGroupDialog::serviceImage()
return QPixmap(":/icons/png/forums.png");
}
bool GxsForumGroupDialog::service_CreateGroup(uint32_t &token, const RsGroupMetaData &meta)
bool GxsForumGroupDialog::service_createGroup(RsGroupMetaData& meta)
{
// Specific Function.
RsGxsForumGroup grp;
@ -107,11 +107,16 @@ bool GxsForumGroupDialog::service_CreateGroup(uint32_t &token, const RsGroupMeta
grp.mDescription = getDescription().toUtf8().constData();
getSelectedModerators(grp.mAdminList.ids);
rsGxsForums->createGroup(token, grp);
return true;
if(rsGxsForums->createForum(grp))
{
meta = grp.mMeta;
return true;
}
else
return false;
}
bool GxsForumGroupDialog::service_EditGroup(uint32_t &token, RsGroupMetaData &editedMeta)
bool GxsForumGroupDialog::service_updateGroup(const RsGroupMetaData& editedMeta)
{
RsGxsForumGroup grp(mGroupData); // start again from cached information. That allows to keep the pinned posts for instance.
@ -125,44 +130,45 @@ bool GxsForumGroupDialog::service_EditGroup(uint32_t &token, RsGroupMetaData &ed
std::cerr << "GxsForumGroupDialog::service_EditGroup() submitting changes";
std::cerr << std::endl;
rsGxsForums->updateGroup(token, grp);
return true;
return rsGxsForums->editForum(grp);
}
bool GxsForumGroupDialog::service_loadGroup(uint32_t token, Mode /*mode*/, RsGroupMetaData& groupMetaData, QString &description)
bool GxsForumGroupDialog::service_loadGroup(const RsGxsGenericGroupData *data, Mode /*mode*/, QString &description)
{
std::cerr << "GxsForumGroupDialog::service_loadGroup(" << token << ")";
std::cerr << std::endl;
const RsGxsForumGroup *pgroup = dynamic_cast<const RsGxsForumGroup*>(data);
std::vector<RsGxsForumGroup> groups;
if (!rsGxsForums->getGroupData(token, groups))
if (!pgroup)
{
std::cerr << "GxsForumGroupDialog::service_loadGroup() Error getting GroupData";
std::cerr << std::endl;
RsErr() << "GxsForumGroupDialog::service_loadGroup() supplied generic group is not a RsGxsForumGroup"<< std::endl;
return false;
}
if (groups.size() != 1)
{
std::cerr << "GxsForumGroupDialog::service_loadGroup() Error Group.size() != 1";
std::cerr << std::endl;
return false;
}
std::cerr << "GxsForumsGroupDialog::service_loadGroup() Unfinished Loading";
std::cerr << std::endl;
// Information handled by GxsGroupDialog. description should rather be handled here in the service part!
groupMetaData = groups[0].mMeta;
description = QString::fromUtf8(groups[0].mDescription.c_str());
description = QString::fromUtf8(pgroup->mDescription.c_str());
// Local information. Description should be handled here.
setSelectedModerators(groups[0].mAdminList.ids);
setSelectedModerators(pgroup->mAdminList.ids);
mGroupData = groups[0]; // keeps the private information
mGroupData = *pgroup; // keeps the private information
return true;
}
bool GxsForumGroupDialog::service_getGroupData(const RsGxsGroupId& grpId,RsGxsGenericGroupData *& data)
{
std::vector<RsGxsForumGroup> forumsInfo ;
if( rsGxsForums->getForumsInfo(std::list<RsGxsGroupId>({grpId}),forumsInfo) && forumsInfo.size() == 1)
{
data = new RsGxsForumGroup(forumsInfo[0]);
return true;
}
else
return false;
}

View File

@ -29,15 +29,16 @@ class GxsForumGroupDialog : public GxsGroupDialog
Q_OBJECT
public:
GxsForumGroupDialog(TokenQueue *tokenQueue, QWidget *parent);
GxsForumGroupDialog(TokenQueue *tokenExternalQueue, RsTokenService *tokenService, Mode mode, RsGxsGroupId groupId, QWidget *parent);
GxsForumGroupDialog(QWidget *parent);
GxsForumGroupDialog(Mode mode, RsGxsGroupId groupId, QWidget *parent);
protected:
virtual void initUi();
virtual QPixmap serviceImage();
virtual bool service_CreateGroup(uint32_t &token, const RsGroupMetaData &meta);
virtual bool service_loadGroup(uint32_t token, Mode mode, RsGroupMetaData& groupMetaData, QString &description);
virtual bool service_EditGroup(uint32_t &token, RsGroupMetaData &editedMeta);
void initUi() override;
QPixmap serviceImage() override;
bool service_createGroup(RsGroupMetaData& meta) override;
bool service_loadGroup(const RsGxsGenericGroupData *data,Mode mode, QString &description) override;
bool service_updateGroup(const RsGroupMetaData& editedMeta) override;
bool service_getGroupData(const RsGxsGroupId& grpId,RsGxsGenericGroupData *& data) override;
private:
RsGxsForumGroup mGroupData;

View File

@ -93,6 +93,12 @@ bool GxsForumsDialog::getGroupData(std::list<RsGxsGenericGroupData*>& groupInfo)
return true;
}
bool GxsForumsDialog::getGroupStatistics(const RsGxsGroupId& groupId,GxsGroupStatistic& stat)
{
return rsGxsForums->getForumStatistics(groupId,stat);
}
QString GxsForumsDialog::getHelpString() const
{
@ -181,14 +187,14 @@ QString GxsForumsDialog::icon(IconType type)
return "";
}
GxsGroupDialog *GxsForumsDialog::createNewGroupDialog(TokenQueue *tokenQueue)
GxsGroupDialog *GxsForumsDialog::createNewGroupDialog()
{
return new GxsForumGroupDialog(tokenQueue, this);
return new GxsForumGroupDialog(this);
}
GxsGroupDialog *GxsForumsDialog::createGroupDialog(TokenQueue *tokenQueue, RsTokenService *tokenService, GxsGroupDialog::Mode mode, RsGxsGroupId groupId)
GxsGroupDialog *GxsForumsDialog::createGroupDialog(GxsGroupDialog::Mode mode, RsGxsGroupId groupId)
{
return new GxsForumGroupDialog(tokenQueue, tokenService, mode, groupId, this);
return new GxsForumGroupDialog(mode, groupId, this);
}
int GxsForumsDialog::shareKeyType()

View File

@ -46,18 +46,21 @@ protected:
UserNotify *createUserNotify(QObject *parent) override;
bool getGroupData(std::list<RsGxsGenericGroupData*>& groupInfo) override;
bool getGroupStatistics(const RsGxsGroupId& groupId,GxsGroupStatistic& stat) override;
void groupInfoToGroupItemInfo(const RsGxsGenericGroupData *groupData, GroupItemInfo &groupItemInfo) override;
private:
/* GxsGroupFrameDialog */
virtual QString text(TextType type);
virtual QString icon(IconType type);
virtual QString settingsGroupName() { return "ForumsDialog"; }
virtual GxsGroupDialog *createNewGroupDialog(TokenQueue *tokenQueue);
virtual GxsGroupDialog *createGroupDialog(TokenQueue *tokenQueue, RsTokenService *tokenService, GxsGroupDialog::Mode mode, RsGxsGroupId groupId);
virtual int shareKeyType();
virtual GxsMessageFrameWidget *createMessageFrameWidget(const RsGxsGroupId &groupId);
virtual uint32_t requestGroupSummaryType() { return GXS_REQUEST_TYPE_GROUP_DATA; } // request complete group data
QString text(TextType type)override ;
QString icon(IconType type)override ;
QString settingsGroupName() override { return "ForumsDialog"; }
GxsGroupDialog *createNewGroupDialog() override;
GxsGroupDialog *createGroupDialog(GxsGroupDialog::Mode mode, RsGxsGroupId groupId) override;
int shareKeyType() override;
GxsMessageFrameWidget *createMessageFrameWidget(const RsGxsGroupId &groupId) override;
uint32_t requestGroupSummaryType() override { return GXS_REQUEST_TYPE_GROUP_DATA; } // request complete group data
void handleEvent_main_thread(std::shared_ptr<const RsEvent> event);