mirror of
https://github.com/RetroShare/RetroShare.git
synced 2024-12-31 18:36:24 -05:00
Added update capability to forums ui
Added timestamp check for group update in nxs decided to add control variable to allow meta changes in updates rather than none git-svn-id: http://svn.code.sf.net/p/retroshare/code/branches/v0.5-gxs_finale@6803 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
parent
2a841d7ab3
commit
9470e5562a
@ -1370,11 +1370,11 @@ void RsGenExchange::publishGroup(uint32_t& token, RsGxsGrpItem *grpItem)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void RsGenExchange::updateGroup(uint32_t& token, RsGxsGrpItem* grpItem)
|
void RsGenExchange::updateGroup(uint32_t& token, RsGxsGroupUpdateMeta& updateMeta, RsGxsGrpItem* grpItem)
|
||||||
{
|
{
|
||||||
RsStackMutex stack(mGenMtx);
|
RsStackMutex stack(mGenMtx);
|
||||||
token = mDataAccess->generatePublicToken();
|
token = mDataAccess->generatePublicToken();
|
||||||
mGroupUpdatePublish.push_back(GroupUpdatePublish(grpItem, token));
|
mGroupUpdatePublish.push_back(GroupUpdatePublish(grpItem, updateMeta, token));
|
||||||
|
|
||||||
#ifdef GEN_EXCH_DEBUG
|
#ifdef GEN_EXCH_DEBUG
|
||||||
std::cerr << "RsGenExchange::updateGroup() token: " << token;
|
std::cerr << "RsGenExchange::updateGroup() token: " << token;
|
||||||
@ -1828,7 +1828,9 @@ void RsGenExchange::processGroupUpdatePublish()
|
|||||||
const RsGxsGroupId& groupId = gup.grpItem->meta.mGroupId;
|
const RsGxsGroupId& groupId = gup.grpItem->meta.mGroupId;
|
||||||
RsGxsGrpMetaData* meta = grpMeta[groupId];
|
RsGxsGrpMetaData* meta = grpMeta[groupId];
|
||||||
|
|
||||||
GxsGrpPendingSign ggps(ggps.mItem, ggps.mToken);
|
gup.grpItem->meta = *meta;
|
||||||
|
assignMetaUpdates(gup.grpItem->meta, gup.mUpdateMeta);
|
||||||
|
GxsGrpPendingSign ggps(gup.grpItem, ggps.mToken);
|
||||||
|
|
||||||
bool split = splitKeys(meta->keys, ggps.mPrivateKeys, ggps.mPublicKeys);
|
bool split = splitKeys(meta->keys, ggps.mPrivateKeys, ggps.mPublicKeys);
|
||||||
|
|
||||||
@ -1849,6 +1851,27 @@ void RsGenExchange::processGroupUpdatePublish()
|
|||||||
mGroupUpdatePublish.clear();
|
mGroupUpdatePublish.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void RsGenExchange::assignMetaUpdates(RsGroupMetaData& meta, const RsGxsGroupUpdateMeta metaUpdate) const
|
||||||
|
{
|
||||||
|
const RsGxsGroupUpdateMeta::GxsMetaUpdate* updates;
|
||||||
|
RsGxsGroupUpdateMeta::GxsMetaUpdate::const_iterator mit = updates->begin();
|
||||||
|
for(; mit != updates->end(); mit++)
|
||||||
|
{
|
||||||
|
const UpdateItem* item = mit->second;
|
||||||
|
RsGxsGroupUpdateMeta::UpdateType utype = mit->first;
|
||||||
|
|
||||||
|
if(utype == RsGxsGroupUpdateMeta::NAME)
|
||||||
|
{
|
||||||
|
const StringUpdateItem* sitem = NULL;
|
||||||
|
|
||||||
|
if((sitem = dynamic_cast<const StringUpdateItem*>(item)) != NULL)
|
||||||
|
{
|
||||||
|
meta.mGroupName = sitem->getUpdate();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
bool RsGenExchange::splitKeys(const RsTlvSecurityKeySet& keySet, RsTlvSecurityKeySet& privateKeySet, RsTlvSecurityKeySet& publicKeySet)
|
bool RsGenExchange::splitKeys(const RsTlvSecurityKeySet& keySet, RsTlvSecurityKeySet& privateKeySet, RsTlvSecurityKeySet& publicKeySet)
|
||||||
{
|
{
|
||||||
|
|
||||||
|
@ -527,12 +527,12 @@ protected:
|
|||||||
|
|
||||||
/*!
|
/*!
|
||||||
* Updates an existing group item \n
|
* Updates an existing group item \n
|
||||||
* This will induce a related change message \n
|
* This will induce a related change message \n
|
||||||
* Ownership of item passes to this rsgenexchange \n
|
* Ownership of item passes to this rsgenexchange \n
|
||||||
* @param token
|
* @param token
|
||||||
* @param grpItem
|
* @param grpItem
|
||||||
*/
|
*/
|
||||||
void updateGroup(uint32_t& token, RsGxsGrpItem* grpItem);
|
void updateGroup(uint32_t& token, RsGxsGroupUpdateMeta& updateMeta, RsGxsGrpItem* grpItem);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
/*!
|
/*!
|
||||||
@ -762,7 +762,20 @@ private:
|
|||||||
*/
|
*/
|
||||||
bool updateValid(RsGxsGrpMetaData& oldGrp, RsNxsGrp& newGrp) const;
|
bool updateValid(RsGxsGrpMetaData& oldGrp, RsNxsGrp& newGrp) const;
|
||||||
|
|
||||||
bool splitKeys(const RsTlvSecurityKeySet& keySet, RsTlvSecurityKeySet& privateKeySet, RsTlvSecurityKeySet& publicKeySet);
|
/*!
|
||||||
|
* convenience function for splitting key sets into private and public
|
||||||
|
* @param keySet The keys set to split into a private and public set
|
||||||
|
* @param privateKeySet contains the publish and admin private keys
|
||||||
|
* @param publicKeySet contains the publish and admin public keys
|
||||||
|
* @return false, if 2 private and public keys are not found in keySet
|
||||||
|
*/
|
||||||
|
bool splitKeys(const RsTlvSecurityKeySet& keySet, RsTlvSecurityKeySet& privateKeySet,
|
||||||
|
RsTlvSecurityKeySet& publicKeySet);
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Convenience function for assigning the meta update items to the actual group meta
|
||||||
|
*/
|
||||||
|
void assignMetaUpdates(RsGroupMetaData& meta, const RsGxsGroupUpdateMeta metaUpdate) const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
|
@ -1366,6 +1366,7 @@ void RsGxsNetService::locked_genReqGrpTransaction(NxsTransaction* tr)
|
|||||||
}
|
}
|
||||||
|
|
||||||
std::map<std::string, RsGxsGrpMetaData*> grpMetaMap;
|
std::map<std::string, RsGxsGrpMetaData*> grpMetaMap;
|
||||||
|
std::map<std::string, RsGxsGrpMetaData*>::const_iterator metaIter;
|
||||||
mDataStore->retrieveGxsGrpMetaData(grpMetaMap);
|
mDataStore->retrieveGxsGrpMetaData(grpMetaMap);
|
||||||
|
|
||||||
// now do compare and add loop
|
// now do compare and add loop
|
||||||
@ -1380,8 +1381,14 @@ void RsGxsNetService::locked_genReqGrpTransaction(NxsTransaction* tr)
|
|||||||
{
|
{
|
||||||
RsNxsSyncGrpItem*& grpSyncItem = *llit;
|
RsNxsSyncGrpItem*& grpSyncItem = *llit;
|
||||||
const std::string& grpId = grpSyncItem->grpId;
|
const std::string& grpId = grpSyncItem->grpId;
|
||||||
|
metaIter = grpMetaMap.find(grpId);
|
||||||
|
bool haveItem = metaIter != grpMetaMap.end();
|
||||||
|
bool latestItem = false;
|
||||||
|
|
||||||
if(grpMetaMap.find(grpId) == grpMetaMap.end()){
|
if(!haveItem)
|
||||||
|
latestItem = grpSyncItem->publishTs > metaIter->second->mPublishTs;
|
||||||
|
|
||||||
|
if(haveItem && latestItem){
|
||||||
|
|
||||||
// determine if you need to check reputation
|
// determine if you need to check reputation
|
||||||
bool checkRep = !grpSyncItem->authorId.empty();
|
bool checkRep = !grpSyncItem->authorId.empty();
|
||||||
|
@ -139,4 +139,14 @@ public:
|
|||||||
bool validUpdate;
|
bool validUpdate;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
class GroupUpdatePublish
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
GroupUpdatePublish(RsGxsGrpItem* item, RsGxsGroupUpdateMeta updateMeta, uint32_t token)
|
||||||
|
: grpItem(item), mToken(token), mUpdateMeta(updateMeta) {}
|
||||||
|
RsGxsGrpItem* grpItem;
|
||||||
|
RsGxsGroupUpdateMeta mUpdateMeta;
|
||||||
|
uint32_t mToken;
|
||||||
|
};
|
||||||
|
|
||||||
#endif /* GXSUTIL_H_ */
|
#endif /* GXSUTIL_H_ */
|
||||||
|
@ -84,6 +84,14 @@ virtual void setMessageReadStatus(uint32_t& token, const RsGxsGrpMsgIdPair& msgI
|
|||||||
virtual bool createGroup(uint32_t &token, RsGxsForumGroup &group) = 0;
|
virtual bool createGroup(uint32_t &token, RsGxsForumGroup &group) = 0;
|
||||||
virtual bool createMsg(uint32_t &token, RsGxsForumMsg &msg) = 0;
|
virtual bool createMsg(uint32_t &token, RsGxsForumMsg &msg) = 0;
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* To update forum group with new information
|
||||||
|
* @param token the token used to check completion status of update
|
||||||
|
* @param group group to be updated, groupId element must be set or will be rejected
|
||||||
|
* @return false groupId not set, true if set and accepted (still check token for completion)
|
||||||
|
*/
|
||||||
|
virtual bool updateGroup(uint32_t &token, RsGxsGroupUpdateMeta&, RsGxsForumGroup &group);
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
@ -128,7 +128,6 @@ public:
|
|||||||
class GxsGroupStatistic
|
class GxsGroupStatistic
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|
||||||
/// number of message
|
/// number of message
|
||||||
RsGxsGroupId mGrpId;
|
RsGxsGroupId mGrpId;
|
||||||
uint32_t mNumMsgs;
|
uint32_t mNumMsgs;
|
||||||
@ -147,4 +146,67 @@ public:
|
|||||||
uint32_t mSizeStore;
|
uint32_t mSizeStore;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
class UpdateItem
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
virtual ~UpdateItem() { }
|
||||||
|
};
|
||||||
|
|
||||||
|
class StringUpdateItem : public UpdateItem
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
StringUpdateItem(const std::string update) : mUpdate(update) {}
|
||||||
|
const std::string& getUpdate() const { return mUpdate; }
|
||||||
|
|
||||||
|
private:
|
||||||
|
std::string mUpdate;
|
||||||
|
};
|
||||||
|
|
||||||
|
class RsGxsGroupUpdateMeta
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
|
||||||
|
// expand as support is added for other utypes
|
||||||
|
enum UpdateType { DESCRIPTION, NAME };
|
||||||
|
|
||||||
|
RsGxsGroupUpdateMeta(const std::string& groupId);
|
||||||
|
~RsGxsGroupUpdateMeta()
|
||||||
|
{
|
||||||
|
GxsMetaUpdate::iterator mit = mUpdates.begin();
|
||||||
|
for(; mit != mUpdates.end(); mit++)
|
||||||
|
delete mit->second;
|
||||||
|
}
|
||||||
|
|
||||||
|
typedef std::map<UpdateType, UpdateItem*> GxsMetaUpdate;
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Only one item of a utype can exist
|
||||||
|
* @param utype the type of meta update
|
||||||
|
* @param item update item containing the change value
|
||||||
|
*/
|
||||||
|
void setMetaUpdate(UpdateType utype, UpdateItem* item)
|
||||||
|
{
|
||||||
|
GxsMetaUpdate::iterator mit;
|
||||||
|
if ((mit = mUpdates.find(utype)) != mUpdates.end())
|
||||||
|
mUpdates[utype] = item;
|
||||||
|
else
|
||||||
|
delete mUpdates[utype];
|
||||||
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* @param utype update type to remove
|
||||||
|
* @return false if update did not exist, true if update successfully removed
|
||||||
|
*/
|
||||||
|
bool removeUpdateType(UpdateType utype){ return mUpdates.erase(utype) == 1; }
|
||||||
|
|
||||||
|
const GxsMetaUpdate* getUpdate() { return &mUpdates; }
|
||||||
|
|
||||||
|
const std::string& getGroupId() { return mGroupId; }
|
||||||
|
|
||||||
|
private:
|
||||||
|
|
||||||
|
GxsMetaUpdate mUpdates;
|
||||||
|
std::string mGroupId;
|
||||||
|
};
|
||||||
|
|
||||||
#endif /* RSGXSIFACETYPES_H_ */
|
#endif /* RSGXSIFACETYPES_H_ */
|
||||||
|
@ -215,6 +215,20 @@ bool p3GxsForums::createGroup(uint32_t &token, RsGxsForumGroup &group)
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool p3GxsForums::updateGroup(uint32_t &token, RsGxsGroupUpdateMeta& meta, RsGxsForumGroup &group)
|
||||||
|
{
|
||||||
|
std::cerr << "p3GxsForums::createGroup()" << std::endl;
|
||||||
|
|
||||||
|
if(group.mMeta.mGroupId.empty())
|
||||||
|
return false;
|
||||||
|
|
||||||
|
RsGxsForumGroupItem* grpItem = new RsGxsForumGroupItem();
|
||||||
|
grpItem->mGroup = group;
|
||||||
|
grpItem->meta = group.mMeta;
|
||||||
|
|
||||||
|
RsGenExchange::updateGroup(token, meta, grpItem);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
bool p3GxsForums::createMsg(uint32_t &token, RsGxsForumMsg &msg)
|
bool p3GxsForums::createMsg(uint32_t &token, RsGxsForumMsg &msg)
|
||||||
{
|
{
|
||||||
|
@ -74,6 +74,13 @@ virtual void setMessageReadStatus(uint32_t& token, const RsGxsGrpMsgIdPair& msgI
|
|||||||
virtual bool createGroup(uint32_t &token, RsGxsForumGroup &group);
|
virtual bool createGroup(uint32_t &token, RsGxsForumGroup &group);
|
||||||
virtual bool createMsg(uint32_t &token, RsGxsForumMsg &msg);
|
virtual bool createMsg(uint32_t &token, RsGxsForumMsg &msg);
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* To update forum group with new information
|
||||||
|
* @param token the token used to check completion status of update
|
||||||
|
* @param group group to be updated, groupId element must be set or will be rejected
|
||||||
|
* @return false groupId not set, true if set and accepted (still check token for completion)
|
||||||
|
*/
|
||||||
|
virtual bool updateGroup(uint32_t &token, RsGxsGroupUpdateMeta& meta, RsGxsForumGroup &group);
|
||||||
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
@ -148,13 +148,13 @@ void GxsGroupDialog::initMode()
|
|||||||
{
|
{
|
||||||
ui.buttonBox->setStandardButtons(QDialogButtonBox::Close);
|
ui.buttonBox->setStandardButtons(QDialogButtonBox::Close);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
//TODO
|
case MODE_EDIT:
|
||||||
// case MODE_EDIT:
|
{
|
||||||
// {
|
ui.buttonBox->setStandardButtons(QDialogButtonBox::Ok | QDialogButtonBox::Cancel);
|
||||||
// ui.createButton->setText(tr("Submit Changes"));
|
ui.buttonBox->button(QDialogButtonBox::Ok)->setText(tr("Submit Group Changes"));
|
||||||
// }
|
}
|
||||||
// break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -320,14 +320,47 @@ void GxsGroupDialog::submitGroup()
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case MODE_EDIT:
|
case MODE_EDIT:
|
||||||
{
|
{
|
||||||
/* TEMP: just close if down */
|
|
||||||
cancelDialog();
|
editGroup();
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void GxsGroupDialog::editGroup()
|
||||||
|
{
|
||||||
|
std::cerr << "GxsGroupDialog::editGroup()" << std::endl;
|
||||||
|
|
||||||
|
QString name = misc::removeNewLine(ui.groupName->text());
|
||||||
|
uint32_t flags = GXS_SERV::FLAG_PRIVACY_PUBLIC;
|
||||||
|
|
||||||
|
if(name.isEmpty())
|
||||||
|
{
|
||||||
|
/* error message */
|
||||||
|
QMessageBox::warning(this, "RetroShare", tr("Please add a Name"), QMessageBox::Ok, QMessageBox::Ok);
|
||||||
|
return; //Don't add a empty name!!
|
||||||
|
}
|
||||||
|
|
||||||
|
uint32_t token;
|
||||||
|
RsGroupMetaData meta;
|
||||||
|
|
||||||
|
// Fill in the MetaData as best we can.
|
||||||
|
meta.mGroupName = std::string(name.toUtf8());
|
||||||
|
|
||||||
|
meta.mGroupFlags = flags;
|
||||||
|
meta.mSignFlags = getGroupSignFlags();
|
||||||
|
|
||||||
|
if (service_CreateGroup(token, meta))
|
||||||
|
{
|
||||||
|
// get the Queue to handle response.
|
||||||
|
if(mTokenQueue != NULL)
|
||||||
|
mTokenQueue->queueRequest(token, TOKENREQ_GROUPINFO, RS_TOKREQ_ANSTYPE_ACK, GXSGROUP_NEWGROUPID);
|
||||||
|
}
|
||||||
|
|
||||||
|
close();
|
||||||
|
}
|
||||||
|
|
||||||
void GxsGroupDialog::createGroup()
|
void GxsGroupDialog::createGroup()
|
||||||
{
|
{
|
||||||
std::cerr << "GxsGroupDialog::createGroup()";
|
std::cerr << "GxsGroupDialog::createGroup()";
|
||||||
|
@ -202,6 +202,7 @@ private:
|
|||||||
void setupVisibility();
|
void setupVisibility();
|
||||||
void clearForm();
|
void clearForm();
|
||||||
void createGroup();
|
void createGroup();
|
||||||
|
void editGroup();
|
||||||
void sendShareList(std::string forumId);
|
void sendShareList(std::string forumId);
|
||||||
void loadNewGroupId(const uint32_t &token);
|
void loadNewGroupId(const uint32_t &token);
|
||||||
|
|
||||||
|
@ -23,6 +23,7 @@
|
|||||||
#include <QMessageBox>
|
#include <QMessageBox>
|
||||||
|
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
|
#include <algorithm>
|
||||||
|
|
||||||
#include "GxsChannelDialog.h"
|
#include "GxsChannelDialog.h"
|
||||||
#include "gui/feeds/GxsChannelPostItem.h"
|
#include "gui/feeds/GxsChannelPostItem.h"
|
||||||
|
@ -52,6 +52,13 @@ const uint32_t ForumCreateDefaultsFlags = ( GXS_GROUP_DEFAULTS_DISTRIB_PUBLIC
|
|||||||
GXS_GROUP_DEFAULTS_COMMENTS_NO |
|
GXS_GROUP_DEFAULTS_COMMENTS_NO |
|
||||||
0);
|
0);
|
||||||
|
|
||||||
|
|
||||||
|
const uint32_t ForumEditEnabledFlags = ( GXS_GROUP_FLAGS_ICON |
|
||||||
|
GXS_GROUP_FLAGS_DESCRIPTION |
|
||||||
|
0);
|
||||||
|
|
||||||
|
const uint32_t ForumEditDefaultsFlags = 0;
|
||||||
|
|
||||||
GxsForumGroupDialog::GxsForumGroupDialog(TokenQueue *tokenQueue, QWidget *parent)
|
GxsForumGroupDialog::GxsForumGroupDialog(TokenQueue *tokenQueue, QWidget *parent)
|
||||||
:GxsGroupDialog(tokenQueue, ForumCreateEnabledFlags, ForumCreateDefaultsFlags, parent)
|
:GxsGroupDialog(tokenQueue, ForumCreateEnabledFlags, ForumCreateDefaultsFlags, parent)
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user