mirror of
https://github.com/RetroShare/RetroShare.git
synced 2025-01-11 23:49:38 -05:00
Update photo/wire/wiki interfaces to support Blocking Group API.
Add blocking API Group Interfaces for photo,wire and wiki services. Add service blocking API calls for createGroup/updateGroup/getGroupData. Update GUI classes to match new GxsGroupDialog Interfaces.
This commit is contained in:
parent
3402aa861f
commit
1c20d75a03
@ -62,13 +62,10 @@ public:
|
||||
#define RSPHOTO_SHAREMODE_DUP_200K (4)
|
||||
#define RSPHOTO_SHAREMODE_DUP_1M (5)
|
||||
|
||||
class RsPhotoAlbum
|
||||
struct RsPhotoAlbum: RsGxsGenericGroupData
|
||||
{
|
||||
public:
|
||||
RsPhotoAlbum();
|
||||
|
||||
RsGroupMetaData mMeta;
|
||||
|
||||
// V2 Album - keep it simple.
|
||||
// mMeta.mTitle.
|
||||
uint32_t mShareMode;
|
||||
@ -221,7 +218,29 @@ public:
|
||||
*/
|
||||
virtual bool acknowledgeGrp(const uint32_t& token, RsGxsGroupId& grpId) = 0;
|
||||
|
||||
// Blocking versions.
|
||||
/*!
|
||||
* request to create a new album. Blocks until process completes.
|
||||
* @param album album to be submitted
|
||||
* @return true if created false otherwise
|
||||
*/
|
||||
virtual bool createAlbum(RsPhotoAlbum &album) = 0;
|
||||
|
||||
/*!
|
||||
* request to update an existing album. Blocks until process completes.
|
||||
* @param album album to be submitted
|
||||
* @return true if created false otherwise
|
||||
*/
|
||||
virtual bool updateAlbum(const RsPhotoAlbum &album) = 0;
|
||||
|
||||
/*!
|
||||
* retrieve albums based in groupIds.
|
||||
* @param groupIds the ids to fetch.
|
||||
* @param albums vector to be filled by request.
|
||||
* @return true is successful, false otherwise.
|
||||
*/
|
||||
virtual bool getAlbums(const std::list<RsGxsGroupId> &groupIds,
|
||||
std::vector<RsPhotoAlbum> &albums) = 0;
|
||||
};
|
||||
|
||||
|
||||
|
@ -69,22 +69,17 @@ class CollectionRef
|
||||
std::string CollectionId;
|
||||
};
|
||||
|
||||
|
||||
class RsWikiCollection
|
||||
struct RsWikiCollection: RsGxsGenericGroupData
|
||||
{
|
||||
public:
|
||||
|
||||
RsGroupMetaData mMeta;
|
||||
|
||||
std::string mDescription;
|
||||
std::string mCategory;
|
||||
|
||||
std::string mHashTags;
|
||||
|
||||
//std::map<std::string, CollectionRef> linkReferences;
|
||||
// std::map<std::string, CollectionRef> linkReferences;
|
||||
};
|
||||
|
||||
|
||||
class RsWikiSnapshot
|
||||
{
|
||||
public:
|
||||
@ -129,6 +124,11 @@ virtual bool submitComment(uint32_t &token, RsWikiComment &comment) = 0;
|
||||
|
||||
virtual bool updateCollection(uint32_t &token, RsWikiCollection &collection) = 0;
|
||||
|
||||
// Blocking Interfaces.
|
||||
virtual bool createCollection(RsWikiCollection &collection) = 0;
|
||||
virtual bool updateCollection(const RsWikiCollection &collection) = 0;
|
||||
virtual bool getCollections(const std::list<RsGxsGroupId> groupIds, std::vector<RsWikiCollection> &groups) = 0;
|
||||
|
||||
};
|
||||
|
||||
#endif
|
||||
|
@ -34,16 +34,13 @@
|
||||
class RsWire;
|
||||
extern RsWire *rsWire;
|
||||
|
||||
class RsWireGroup
|
||||
struct RsWireGroup: RsGxsGenericGroupData
|
||||
{
|
||||
public:
|
||||
|
||||
RsGroupMetaData mMeta;
|
||||
std::string mDescription;
|
||||
};
|
||||
|
||||
|
||||
|
||||
/***********************************************************************
|
||||
* RsWire - is intended to be a Twitter clone - but fully decentralised.
|
||||
*
|
||||
@ -154,6 +151,11 @@ virtual bool getPulseData(const uint32_t &token, std::vector<RsWirePulse> &pulse
|
||||
virtual bool createGroup(uint32_t &token, RsWireGroup &group) = 0;
|
||||
virtual bool createPulse(uint32_t &token, RsWirePulse &pulse) = 0;
|
||||
|
||||
// Blocking Interfaces.
|
||||
virtual bool createGroup(RsWireGroup &group) = 0;
|
||||
virtual bool updateGroup(const RsWireGroup &group) = 0;
|
||||
virtual bool getGroups(const std::list<RsGxsGroupId> grpIds, std::vector<RsWireGroup> &groups) = 0;
|
||||
|
||||
};
|
||||
|
||||
#endif
|
||||
|
@ -317,3 +317,38 @@ bool p3PhotoService::subscribeToAlbum(uint32_t &token, const RsGxsGroupId &grpId
|
||||
return true;
|
||||
}
|
||||
|
||||
// Blocking versions =============================================================
|
||||
|
||||
bool p3PhotoService::createAlbum(RsPhotoAlbum &album)
|
||||
{
|
||||
uint32_t token;
|
||||
return submitAlbumDetails(token, album) && waitToken(token) == RsTokenService::COMPLETE;
|
||||
}
|
||||
|
||||
bool p3PhotoService::updateAlbum(const RsPhotoAlbum &album)
|
||||
{
|
||||
// TODO
|
||||
return false;
|
||||
}
|
||||
|
||||
bool p3PhotoService::getAlbums(const std::list<RsGxsGroupId> &groupIds,
|
||||
std::vector<RsPhotoAlbum> &albums)
|
||||
{
|
||||
uint32_t token;
|
||||
RsTokReqOptions opts;
|
||||
opts.mReqType = GXS_REQUEST_TYPE_GROUP_DATA;
|
||||
|
||||
if (groupIds.empty())
|
||||
{
|
||||
if (!requestGroupInfo(token, opts) || waitToken(token) != RsTokenService::COMPLETE )
|
||||
return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!requestGroupInfo(token, opts, groupIds) || waitToken(token) != RsTokenService::COMPLETE )
|
||||
return false;
|
||||
}
|
||||
|
||||
return getAlbum(token, albums) && !albums.empty();
|
||||
}
|
||||
|
||||
|
@ -109,6 +109,13 @@ public:
|
||||
return acknowledgeMsg(token, msgId);
|
||||
}
|
||||
|
||||
// Blocking versions.
|
||||
virtual bool createComment(RsGxsComment &msg) override
|
||||
{
|
||||
uint32_t token;
|
||||
return mCommentService->createGxsComment(token, msg) && waitToken(token) == RsTokenService::COMPLETE;
|
||||
}
|
||||
|
||||
public:
|
||||
|
||||
/** Modifications **/
|
||||
@ -165,6 +172,29 @@ public:
|
||||
*/
|
||||
bool acknowledgeGrp(const uint32_t& token, RsGxsGroupId& grpId);
|
||||
|
||||
// Blocking versions.
|
||||
/*!
|
||||
* request to create a new album. Blocks until process completes.
|
||||
* @param album album to be submitted
|
||||
* @return true if created false otherwise
|
||||
*/
|
||||
virtual bool createAlbum(RsPhotoAlbum &album) override;
|
||||
|
||||
/*!
|
||||
* request to update an existing album. Blocks until process completes.
|
||||
* @param album album to be submitted
|
||||
* @return true if created false otherwise
|
||||
*/
|
||||
virtual bool updateAlbum(const RsPhotoAlbum &album) override;
|
||||
|
||||
/*!
|
||||
* retrieve albums based in groupIds.
|
||||
* @param groupIds the ids to fetch.
|
||||
* @param albums vector to be filled by request.
|
||||
* @return true is successful, false otherwise.
|
||||
*/
|
||||
virtual bool getAlbums(const std::list<RsGxsGroupId> &groupIds,
|
||||
std::vector<RsPhotoAlbum> &albums) override;
|
||||
private:
|
||||
p3GxsCommentService* mCommentService;
|
||||
|
||||
|
@ -323,6 +323,38 @@ bool p3Wiki::updateCollection(uint32_t &token, RsWikiCollection &group)
|
||||
return true;
|
||||
}
|
||||
|
||||
// Blocking Interfaces.
|
||||
bool p3Wiki::createCollection(RsWikiCollection &group)
|
||||
{
|
||||
uint32_t token;
|
||||
return submitCollection(token, group) && waitToken(token) == RsTokenService::COMPLETE;
|
||||
}
|
||||
|
||||
bool p3Wiki::updateCollection(const RsWikiCollection &group)
|
||||
{
|
||||
uint32_t token;
|
||||
RsWikiCollection update(group);
|
||||
return updateCollection(token, update) && waitToken(token) == RsTokenService::COMPLETE;
|
||||
}
|
||||
|
||||
bool p3Wiki::getCollections(const std::list<RsGxsGroupId> groupIds, std::vector<RsWikiCollection> &groups)
|
||||
{
|
||||
uint32_t token;
|
||||
RsTokReqOptions opts;
|
||||
opts.mReqType = GXS_REQUEST_TYPE_GROUP_DATA;
|
||||
|
||||
if (groupIds.empty())
|
||||
{
|
||||
if (!requestGroupInfo(token, opts) || waitToken(token) != RsTokenService::COMPLETE )
|
||||
return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!requestGroupInfo(token, opts, groupIds) || waitToken(token) != RsTokenService::COMPLETE )
|
||||
return false;
|
||||
}
|
||||
return getCollections(token, groups) && !groups.empty();
|
||||
}
|
||||
|
||||
std::ostream &operator<<(std::ostream &out, const RsWikiCollection &group)
|
||||
{
|
||||
|
@ -56,17 +56,22 @@ public:
|
||||
virtual void service_tick();
|
||||
|
||||
/* Specific Service Data */
|
||||
virtual bool getCollections(const uint32_t &token, std::vector<RsWikiCollection> &collections);
|
||||
virtual bool getSnapshots(const uint32_t &token, std::vector<RsWikiSnapshot> &snapshots);
|
||||
virtual bool getComments(const uint32_t &token, std::vector<RsWikiComment> &comments);
|
||||
virtual bool getCollections(const uint32_t &token, std::vector<RsWikiCollection> &collections) override;
|
||||
virtual bool getSnapshots(const uint32_t &token, std::vector<RsWikiSnapshot> &snapshots) override;
|
||||
virtual bool getComments(const uint32_t &token, std::vector<RsWikiComment> &comments) override;
|
||||
|
||||
virtual bool getRelatedSnapshots(const uint32_t &token, std::vector<RsWikiSnapshot> &snapshots);
|
||||
virtual bool getRelatedSnapshots(const uint32_t &token, std::vector<RsWikiSnapshot> &snapshots) override;
|
||||
|
||||
virtual bool submitCollection(uint32_t &token, RsWikiCollection &collection);
|
||||
virtual bool submitSnapshot(uint32_t &token, RsWikiSnapshot &snapshot);
|
||||
virtual bool submitComment(uint32_t &token, RsWikiComment &comment);
|
||||
virtual bool submitCollection(uint32_t &token, RsWikiCollection &collection) override;
|
||||
virtual bool submitSnapshot(uint32_t &token, RsWikiSnapshot &snapshot) override;
|
||||
virtual bool submitComment(uint32_t &token, RsWikiComment &comment) override;
|
||||
|
||||
virtual bool updateCollection(uint32_t &token, RsWikiCollection &collection);
|
||||
virtual bool updateCollection(uint32_t &token, RsWikiCollection &collection) override;
|
||||
|
||||
// Blocking Interfaces.
|
||||
virtual bool createCollection(RsWikiCollection &collection) override;
|
||||
virtual bool updateCollection(const RsWikiCollection &collection) override;
|
||||
virtual bool getCollections(const std::list<RsGxsGroupId> groupIds, std::vector<RsWikiCollection> &groups) override;
|
||||
|
||||
private:
|
||||
|
||||
|
@ -208,6 +208,38 @@ bool p3Wire::createPulse(uint32_t &token, RsWirePulse &pulse)
|
||||
return true;
|
||||
}
|
||||
|
||||
// Blocking Interfaces.
|
||||
bool p3Wire::createGroup(RsWireGroup &group)
|
||||
{
|
||||
uint32_t token;
|
||||
return createGroup(token, group) && waitToken(token) == RsTokenService::COMPLETE;
|
||||
}
|
||||
|
||||
bool p3Wire::updateGroup(const RsWireGroup &group)
|
||||
{
|
||||
// TODO
|
||||
return false;
|
||||
}
|
||||
|
||||
bool p3Wire::getGroups(const std::list<RsGxsGroupId> groupIds, std::vector<RsWireGroup> &groups)
|
||||
{
|
||||
uint32_t token;
|
||||
RsTokReqOptions opts;
|
||||
opts.mReqType = GXS_REQUEST_TYPE_GROUP_DATA;
|
||||
|
||||
if (groupIds.empty())
|
||||
{
|
||||
if (!requestGroupInfo(token, opts) || waitToken(token) != RsTokenService::COMPLETE )
|
||||
return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!requestGroupInfo(token, opts, groupIds) || waitToken(token) != RsTokenService::COMPLETE )
|
||||
return false;
|
||||
}
|
||||
return getGroupData(token, groups) && !groups.empty();
|
||||
}
|
||||
|
||||
|
||||
std::ostream &operator<<(std::ostream &out, const RsWireGroup &group)
|
||||
{
|
||||
|
@ -50,11 +50,16 @@ public:
|
||||
virtual RsTokenService* getTokenService();
|
||||
|
||||
/* Specific Service Data */
|
||||
virtual bool getGroupData(const uint32_t &token, std::vector<RsWireGroup> &groups);
|
||||
virtual bool getPulseData(const uint32_t &token, std::vector<RsWirePulse> &pulses);
|
||||
virtual bool getGroupData(const uint32_t &token, std::vector<RsWireGroup> &groups) override;
|
||||
virtual bool getPulseData(const uint32_t &token, std::vector<RsWirePulse> &pulses) override;
|
||||
|
||||
virtual bool createGroup(uint32_t &token, RsWireGroup &group);
|
||||
virtual bool createPulse(uint32_t &token, RsWirePulse &pulse);
|
||||
virtual bool createGroup(uint32_t &token, RsWireGroup &group) override;
|
||||
virtual bool createPulse(uint32_t &token, RsWirePulse &pulse) override;
|
||||
|
||||
// Blocking Interfaces.
|
||||
virtual bool createGroup(RsWireGroup &group) override;
|
||||
virtual bool updateGroup(const RsWireGroup &group) override;
|
||||
virtual bool getGroups(const std::list<RsGxsGroupId> grpIds, std::vector<RsWireGroup> &groups) override;
|
||||
|
||||
private:
|
||||
virtual void generateDummyData();
|
||||
|
@ -62,13 +62,13 @@ uint32_t AlbumCreateDefaultsFlags = ( GXS_GROUP_DEFAULTS_DISTRIB_PUBLIC |
|
||||
uint32_t AlbumEditEnabledFlags = AlbumCreateEnabledFlags;
|
||||
uint32_t AlbumEditDefaultsFlags = AlbumCreateDefaultsFlags;
|
||||
|
||||
AlbumGroupDialog::AlbumGroupDialog(TokenQueue *tokenQueue, QWidget *parent)
|
||||
: GxsGroupDialog(tokenQueue, AlbumCreateEnabledFlags, AlbumCreateDefaultsFlags, parent)
|
||||
AlbumGroupDialog::AlbumGroupDialog(QWidget *parent)
|
||||
: GxsGroupDialog(AlbumCreateEnabledFlags, AlbumCreateDefaultsFlags, parent)
|
||||
{
|
||||
}
|
||||
|
||||
AlbumGroupDialog::AlbumGroupDialog(TokenQueue *tokenExternalQueue, RsTokenService *tokenService, Mode mode, RsGxsGroupId groupId, QWidget *parent)
|
||||
: GxsGroupDialog(tokenExternalQueue, tokenService, mode, groupId, AlbumEditEnabledFlags, AlbumEditDefaultsFlags, parent)
|
||||
AlbumGroupDialog::AlbumGroupDialog(Mode mode, RsGxsGroupId groupId, QWidget *parent)
|
||||
: GxsGroupDialog(mode, groupId, AlbumEditEnabledFlags, AlbumEditDefaultsFlags, parent)
|
||||
{
|
||||
}
|
||||
|
||||
@ -129,54 +129,44 @@ void AlbumGroupDialog::prepareAlbumGroup(RsPhotoAlbum &group, const RsGroupMetaD
|
||||
group.mWhen = mAlbumExtra->getWhen();
|
||||
}
|
||||
|
||||
bool AlbumGroupDialog::service_CreateGroup(uint32_t &token, const RsGroupMetaData &meta)
|
||||
bool AlbumGroupDialog::service_createGroup(RsGroupMetaData &meta)
|
||||
{
|
||||
// Specific Function.
|
||||
RsPhotoAlbum grp;
|
||||
prepareAlbumGroup(grp, meta);
|
||||
|
||||
rsPhoto->submitAlbumDetails(token, grp);
|
||||
return true;
|
||||
bool success = rsPhoto->createAlbum(grp);
|
||||
// TODO createAlbum should refresh groupId or GroupObj.
|
||||
return success;
|
||||
}
|
||||
|
||||
bool AlbumGroupDialog::service_EditGroup(uint32_t &token, RsGroupMetaData &editedMeta)
|
||||
bool AlbumGroupDialog::service_updateGroup(const RsGroupMetaData &editedMeta)
|
||||
{
|
||||
RsPhotoAlbum grp;
|
||||
prepareAlbumGroup(grp, editedMeta);
|
||||
|
||||
std::cerr << "AlbumGroupDialog::service_EditGroup() submitting changes";
|
||||
std::cerr << "AlbumGroupDialog::service_updateGroup() submitting changes";
|
||||
std::cerr << std::endl;
|
||||
|
||||
// TODO: no interface here, yet.
|
||||
// rsPhoto->updateGroup(token, grp);
|
||||
return true;
|
||||
bool success = rsPhoto->updateAlbum(grp);
|
||||
// TODO updateAlbum should refresh groupId or GroupObj.
|
||||
return success;
|
||||
}
|
||||
|
||||
bool AlbumGroupDialog::service_loadGroup(uint32_t token, Mode /*mode*/, RsGroupMetaData& groupMetaData, QString &description)
|
||||
bool AlbumGroupDialog::service_loadGroup(const RsGxsGenericGroupData *data, Mode /*mode*/, QString &description)
|
||||
{
|
||||
std::cerr << "AlbumGroupDialog::service_loadGroup(" << token << ")";
|
||||
std::cerr << "AlbumGroupDialog::service_loadGroup()";
|
||||
std::cerr << std::endl;
|
||||
|
||||
std::vector<RsPhotoAlbum> groups;
|
||||
if (!rsPhoto->getAlbum(token, groups))
|
||||
const RsPhotoAlbum *pgroup = dynamic_cast<const RsPhotoAlbum*>(data);
|
||||
|
||||
if(pgroup == nullptr)
|
||||
{
|
||||
std::cerr << "AlbumGroupDialog::service_loadGroup() Error getting GroupData";
|
||||
std::cerr << std::endl;
|
||||
std::cerr << "AlbumGroupDialog::service_loadGroup() Error not a RsPhotoAlbum" << std::endl;
|
||||
return false;
|
||||
}
|
||||
|
||||
if (groups.size() != 1)
|
||||
{
|
||||
std::cerr << "AlbumGroupDialog::service_loadGroup() Error Group.size() != 1";
|
||||
std::cerr << std::endl;
|
||||
return false;
|
||||
}
|
||||
|
||||
std::cerr << "AlbumGroupDialog::service_loadGroup() Unfinished Loading";
|
||||
std::cerr << std::endl;
|
||||
|
||||
const RsPhotoAlbum &group = groups[0];
|
||||
groupMetaData = group.mMeta;
|
||||
const RsPhotoAlbum& group = *pgroup;
|
||||
description = QString::fromUtf8(group.mDescription.c_str());
|
||||
|
||||
if (group.mThumbnail.mData) {
|
||||
@ -197,3 +187,29 @@ bool AlbumGroupDialog::service_loadGroup(uint32_t token, Mode /*mode*/, RsGroupM
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool AlbumGroupDialog::service_getGroupData(const RsGxsGroupId& grpId,RsGxsGenericGroupData *& data)
|
||||
{
|
||||
std::cerr << "AlbumGroupDialog::service_getGroupData(" << grpId << ")";
|
||||
std::cerr << std::endl;
|
||||
|
||||
std::list<RsGxsGroupId> groupIds({grpId});
|
||||
std::vector<RsPhotoAlbum> groups;
|
||||
if (!rsPhoto->getAlbums(groupIds, groups))
|
||||
{
|
||||
std::cerr << "AlbumGroupDialog::service_getGroupData() Error getting GroupData";
|
||||
std::cerr << std::endl;
|
||||
return false;
|
||||
}
|
||||
|
||||
if (groups.size() != 1)
|
||||
{
|
||||
std::cerr << "AlbumGroupDialog::service_getGroupData() Error Group.size() != 1";
|
||||
std::cerr << std::endl;
|
||||
return false;
|
||||
}
|
||||
|
||||
data = new RsPhotoAlbum(groups[0]);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -32,15 +32,16 @@ class AlbumGroupDialog : public GxsGroupDialog
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
AlbumGroupDialog(TokenQueue *tokenQueue, QWidget *parent);
|
||||
AlbumGroupDialog(TokenQueue *tokenExternalQueue, RsTokenService *tokenService, Mode mode, RsGxsGroupId groupId, QWidget *parent);
|
||||
AlbumGroupDialog(QWidget *parent);
|
||||
AlbumGroupDialog(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);
|
||||
virtual void initUi() override;
|
||||
virtual QPixmap serviceImage() override;
|
||||
virtual bool service_createGroup(RsGroupMetaData &meta) override;
|
||||
virtual bool service_updateGroup(const RsGroupMetaData &editedMeta) override;
|
||||
virtual bool service_loadGroup(const RsGxsGenericGroupData *data, Mode mode, QString &description) override;
|
||||
virtual bool service_getGroupData(const RsGxsGroupId &grpId, RsGxsGenericGroupData *&data) override;
|
||||
|
||||
private:
|
||||
void prepareAlbumGroup(RsPhotoAlbum &group, const RsGroupMetaData &meta);
|
||||
|
@ -233,7 +233,7 @@ void PhotoShare::OpenSlideShow()
|
||||
|
||||
void PhotoShare::createAlbum()
|
||||
{
|
||||
AlbumGroupDialog albumCreate(mPhotoQueue, this);
|
||||
AlbumGroupDialog albumCreate(this);
|
||||
albumCreate.exec();
|
||||
}
|
||||
|
||||
@ -246,7 +246,7 @@ void PhotoShare::OpenViewEditAlbumDialog()
|
||||
if (canEdit) {
|
||||
mode = GxsGroupDialog::MODE_EDIT;
|
||||
}
|
||||
AlbumGroupDialog agDialog(mPhotoQueue, rsPhoto->getTokenService(), mode, album.mMeta.mGroupId, this);
|
||||
AlbumGroupDialog agDialog(mode, album.mMeta.mGroupId, this);
|
||||
agDialog.exec();
|
||||
}
|
||||
}
|
||||
|
@ -206,7 +206,7 @@ void WireDialog::checkUpdate()
|
||||
|
||||
void WireDialog::createGroup()
|
||||
{
|
||||
WireGroupDialog wireCreate(mWireQueue, this);
|
||||
WireGroupDialog wireCreate(this);
|
||||
wireCreate.exec();
|
||||
}
|
||||
|
||||
|
@ -56,13 +56,13 @@ uint32_t WireCreateDefaultsFlags = ( GXS_GROUP_DEFAULTS_DISTRIB_PUBLIC |
|
||||
uint32_t WireEditEnabledFlags = WireCreateEnabledFlags;
|
||||
uint32_t WireEditDefaultsFlags = WireCreateDefaultsFlags;
|
||||
|
||||
WireGroupDialog::WireGroupDialog(TokenQueue *tokenQueue, QWidget *parent)
|
||||
: GxsGroupDialog(tokenQueue, WireCreateEnabledFlags, WireCreateDefaultsFlags, parent)
|
||||
WireGroupDialog::WireGroupDialog(QWidget *parent)
|
||||
: GxsGroupDialog(WireCreateEnabledFlags, WireCreateDefaultsFlags, parent)
|
||||
{
|
||||
}
|
||||
|
||||
WireGroupDialog::WireGroupDialog(TokenQueue *tokenExternalQueue, RsTokenService *tokenService, Mode mode, RsGxsGroupId groupId, QWidget *parent)
|
||||
: GxsGroupDialog(tokenExternalQueue, tokenService, mode, groupId, WireEditEnabledFlags, WireEditDefaultsFlags, parent)
|
||||
WireGroupDialog::WireGroupDialog(Mode mode, RsGxsGroupId groupId, QWidget *parent)
|
||||
: GxsGroupDialog(mode, groupId, WireEditEnabledFlags, WireEditDefaultsFlags, parent)
|
||||
{
|
||||
}
|
||||
|
||||
@ -115,54 +115,43 @@ void WireGroupDialog::prepareWireGroup(RsWireGroup &group, const RsGroupMetaData
|
||||
|
||||
}
|
||||
|
||||
bool WireGroupDialog::service_CreateGroup(uint32_t &token, const RsGroupMetaData &meta)
|
||||
bool WireGroupDialog::service_createGroup(RsGroupMetaData &meta)
|
||||
{
|
||||
// Specific Function.
|
||||
RsWireGroup grp;
|
||||
prepareWireGroup(grp, meta);
|
||||
|
||||
rsWire->createGroup(token, grp);
|
||||
return true;
|
||||
bool success = rsWire->createGroup(grp);
|
||||
// TODO createGroup should refresh groupId or Data
|
||||
return success;
|
||||
}
|
||||
|
||||
bool WireGroupDialog::service_EditGroup(uint32_t & /* token */, RsGroupMetaData &editedMeta)
|
||||
bool WireGroupDialog::service_updateGroup(const RsGroupMetaData &editedMeta)
|
||||
{
|
||||
RsWireGroup grp;
|
||||
prepareWireGroup(grp, editedMeta);
|
||||
|
||||
std::cerr << "WireGroupDialog::service_EditGroup() submitting changes";
|
||||
std::cerr << "WireGroupDialog::service_updateGroup() submitting changes";
|
||||
std::cerr << std::endl;
|
||||
|
||||
// TODO: no interface here, yet.
|
||||
// rsWire->updateGroup(token, grp);
|
||||
return true;
|
||||
bool success = rsWire->updateGroup(grp);
|
||||
// TODO updateGroup should refresh groupId or Data
|
||||
return success;
|
||||
}
|
||||
|
||||
bool WireGroupDialog::service_loadGroup(uint32_t token, Mode /*mode*/, RsGroupMetaData& groupMetaData, QString &description)
|
||||
bool WireGroupDialog::service_loadGroup(const RsGxsGenericGroupData *data, Mode mode, QString &description)
|
||||
{
|
||||
std::cerr << "WireGroupDialog::service_loadGroup(" << token << ")";
|
||||
std::cerr << "WireGroupDialog::service_loadGroup()";
|
||||
std::cerr << std::endl;
|
||||
|
||||
std::vector<RsWireGroup> groups;
|
||||
if (!rsWire->getGroupData(token, groups))
|
||||
const RsWireGroup *pgroup = dynamic_cast<const RsWireGroup*>(data);
|
||||
if (pgroup == nullptr)
|
||||
{
|
||||
std::cerr << "WireGroupDialog::service_loadGroup() Error getting GroupData";
|
||||
std::cerr << "WireGroupDialog::service_loadGroup() Error not a RsWireGroup";
|
||||
std::cerr << std::endl;
|
||||
return false;
|
||||
}
|
||||
|
||||
if (groups.size() != 1)
|
||||
{
|
||||
std::cerr << "WireGroupDialog::service_loadGroup() Error Group.size() != 1";
|
||||
std::cerr << std::endl;
|
||||
return false;
|
||||
}
|
||||
|
||||
std::cerr << "WireGroupDialog::service_loadGroup() Unfinished Loading";
|
||||
std::cerr << std::endl;
|
||||
|
||||
const RsWireGroup &group = groups[0];
|
||||
groupMetaData = group.mMeta;
|
||||
const RsWireGroup &group = *pgroup;
|
||||
description = QString::fromUtf8(group.mDescription.c_str());
|
||||
|
||||
#if 0
|
||||
@ -178,3 +167,28 @@ bool WireGroupDialog::service_loadGroup(uint32_t token, Mode /*mode*/, RsGroupMe
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool WireGroupDialog::service_getGroupData(const RsGxsGroupId &grpId, RsGxsGenericGroupData *&data)
|
||||
{
|
||||
std::cerr << "WireGroupDialog::service_getGroupData(" << grpId << ")";
|
||||
std::cerr << std::endl;
|
||||
|
||||
std::list<RsGxsGroupId> groupIds({grpId});
|
||||
std::vector<RsWireGroup> groups;
|
||||
if (!rsWire->getGroups(groupIds, groups))
|
||||
{
|
||||
std::cerr << "WireGroupDialog::service_loadGroup() Error getting GroupData";
|
||||
std::cerr << std::endl;
|
||||
return false;
|
||||
}
|
||||
|
||||
if (groups.size() != 1)
|
||||
{
|
||||
std::cerr << "WireGroupDialog::service_loadGroup() Error Group.size() != 1";
|
||||
std::cerr << std::endl;
|
||||
return false;
|
||||
}
|
||||
|
||||
data = new RsWireGroup(groups[0]);
|
||||
return true;
|
||||
}
|
||||
|
@ -29,15 +29,16 @@ class WireGroupDialog : public GxsGroupDialog
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
WireGroupDialog(TokenQueue *tokenQueue, QWidget *parent);
|
||||
WireGroupDialog(TokenQueue *tokenExternalQueue, RsTokenService *tokenService, Mode mode, RsGxsGroupId groupId, QWidget *parent);
|
||||
WireGroupDialog(QWidget *parent);
|
||||
WireGroupDialog(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);
|
||||
virtual void initUi() override;
|
||||
virtual QPixmap serviceImage() override;
|
||||
virtual bool service_createGroup(RsGroupMetaData &meta) override;
|
||||
virtual bool service_updateGroup(const RsGroupMetaData &editedMeta) override;
|
||||
virtual bool service_loadGroup(const RsGxsGenericGroupData *data, Mode mode, QString &description) override;
|
||||
virtual bool service_getGroupData(const RsGxsGroupId &grpId, RsGxsGenericGroupData *&data) override;
|
||||
|
||||
private:
|
||||
void prepareWireGroup(RsWireGroup &group, const RsGroupMetaData &meta);
|
||||
|
@ -181,7 +181,7 @@ void WikiDialog::OpenOrShowAddGroupDialog()
|
||||
|
||||
void WikiDialog::newGroup()
|
||||
{
|
||||
WikiGroupDialog cf(mWikiQueue, this);
|
||||
WikiGroupDialog cf(this);
|
||||
cf.exec ();
|
||||
}
|
||||
|
||||
@ -195,7 +195,7 @@ void WikiDialog::showGroupDetails()
|
||||
return;
|
||||
}
|
||||
|
||||
WikiGroupDialog cf(mWikiQueue, rsWiki->getTokenService(), GxsGroupDialog::MODE_SHOW, groupId, this);
|
||||
WikiGroupDialog cf(GxsGroupDialog::MODE_SHOW, groupId, this);
|
||||
cf.exec ();
|
||||
}
|
||||
|
||||
@ -209,7 +209,7 @@ void WikiDialog::editGroupDetails()
|
||||
return;
|
||||
}
|
||||
|
||||
WikiGroupDialog cf(mWikiQueue, rsWiki->getTokenService(), GxsGroupDialog::MODE_EDIT, groupId, this);
|
||||
WikiGroupDialog cf(GxsGroupDialog::MODE_EDIT, groupId, this);
|
||||
cf.exec ();
|
||||
}
|
||||
|
||||
|
@ -54,13 +54,13 @@ uint32_t WikiCreateDefaultsFlags = ( GXS_GROUP_DEFAULTS_DISTRIB_PUBLIC |
|
||||
uint32_t WikiEditDefaultsFlags = WikiCreateDefaultsFlags;
|
||||
uint32_t WikiEditEnabledFlags = WikiCreateEnabledFlags;
|
||||
|
||||
WikiGroupDialog::WikiGroupDialog(TokenQueue *tokenQueue, QWidget *parent)
|
||||
:GxsGroupDialog(tokenQueue, WikiCreateEnabledFlags, WikiCreateDefaultsFlags, parent)
|
||||
WikiGroupDialog::WikiGroupDialog(QWidget *parent)
|
||||
:GxsGroupDialog(WikiCreateEnabledFlags, WikiCreateDefaultsFlags, parent)
|
||||
{
|
||||
}
|
||||
|
||||
WikiGroupDialog::WikiGroupDialog(TokenQueue *tokenExternalQueue, RsTokenService *tokenService, Mode mode, RsGxsGroupId groupId, QWidget *parent)
|
||||
:GxsGroupDialog(tokenExternalQueue, tokenService, mode, groupId, WikiEditEnabledFlags, WikiEditDefaultsFlags, parent)
|
||||
WikiGroupDialog::WikiGroupDialog(Mode mode, RsGxsGroupId groupId, QWidget *parent)
|
||||
:GxsGroupDialog(mode, groupId, WikiEditEnabledFlags, WikiEditDefaultsFlags, parent)
|
||||
{
|
||||
}
|
||||
|
||||
@ -90,40 +90,62 @@ QPixmap WikiGroupDialog::serviceImage()
|
||||
return QPixmap(":/icons/png/wiki.png");
|
||||
}
|
||||
|
||||
bool WikiGroupDialog::service_CreateGroup(uint32_t &token, const RsGroupMetaData &meta)
|
||||
|
||||
bool WikiGroupDialog::service_createGroup(RsGroupMetaData &meta)
|
||||
{
|
||||
// Specific Function.
|
||||
RsWikiCollection grp;
|
||||
grp.mMeta = meta;
|
||||
grp.mDescription = getDescription().toStdString();
|
||||
std::cerr << "WikiGroupDialog::service_CreateGroup() storing to Queue";
|
||||
|
||||
std::cerr << "WikiGroupDialog::service_CreateGroup()";
|
||||
std::cerr << std::endl;
|
||||
|
||||
rsWiki->submitCollection(token, grp);
|
||||
|
||||
return true;
|
||||
bool success = rsWiki->createCollection(grp);
|
||||
// createCollection should refresh groupId or data
|
||||
return success;
|
||||
}
|
||||
|
||||
bool WikiGroupDialog::service_EditGroup(uint32_t &token, RsGroupMetaData &editedMeta)
|
||||
bool WikiGroupDialog::service_updateGroup(const RsGroupMetaData &editedMeta)
|
||||
{
|
||||
RsWikiCollection grp;
|
||||
grp.mMeta = editedMeta;
|
||||
grp.mDescription = getDescription().toStdString();
|
||||
|
||||
std::cerr << "WikiGroupDialog::service_EditGroup() submitting changes.";
|
||||
std::cerr << "WikiGroupDialog::service_updateGroup() submitting changes.";
|
||||
std::cerr << std::endl;
|
||||
|
||||
rsWiki->updateCollection(token, grp);
|
||||
bool success = rsWiki->updateCollection(grp);
|
||||
// updateCollection should refresh groupId or data
|
||||
return success;
|
||||
}
|
||||
|
||||
bool WikiGroupDialog::service_loadGroup(const RsGxsGenericGroupData *data, Mode mode, QString &description)
|
||||
{
|
||||
std::cerr << "WikiGroupDialog::service_loadGroup()";
|
||||
std::cerr << std::endl;
|
||||
|
||||
const RsWikiCollection *pgroup = dynamic_cast<const RsWikiCollection *>(data);
|
||||
if (pgroup == nullptr)
|
||||
{
|
||||
std::cerr << "WikiGroupDialog::service_loadGroup() Error not a RsWikiCollection";
|
||||
std::cerr << std::endl;
|
||||
return false;
|
||||
}
|
||||
|
||||
const RsWikiCollection &group = *pgroup;
|
||||
description = QString::fromUtf8(group.mDescription.c_str());
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool WikiGroupDialog::service_loadGroup(uint32_t token, Mode /*mode*/, RsGroupMetaData& groupMetaData, QString &description)
|
||||
bool WikiGroupDialog::service_getGroupData(const RsGxsGroupId &groupId, RsGxsGenericGroupData *&data)
|
||||
{
|
||||
std::cerr << "WikiGroupDialog::service_loadGroup(" << token << ")";
|
||||
std::cerr << "WikiGroupDialog::service_getGroupData(" << groupId << ")";
|
||||
std::cerr << std::endl;
|
||||
|
||||
std::list<RsGxsGroupId> groupIds({groupId});
|
||||
std::vector<RsWikiCollection> groups;
|
||||
if (!rsWiki->getCollections(token, groups))
|
||||
if (!rsWiki->getCollections(groupIds, groups))
|
||||
{
|
||||
std::cerr << "WikiGroupDialog::service_loadGroup() Error getting GroupData";
|
||||
std::cerr << std::endl;
|
||||
@ -137,11 +159,7 @@ bool WikiGroupDialog::service_loadGroup(uint32_t token, Mode /*mode*/, RsGroupMe
|
||||
return false;
|
||||
}
|
||||
|
||||
std::cerr << "WikisGroupDialog::service_loadGroup() Unfinished Loading";
|
||||
std::cerr << std::endl;
|
||||
|
||||
groupMetaData = groups[0].mMeta;
|
||||
description = QString::fromUtf8(groups[0].mDescription.c_str());
|
||||
|
||||
data = new RsWikiCollection(groups[0]);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -29,15 +29,16 @@ class WikiGroupDialog : public GxsGroupDialog
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
WikiGroupDialog(TokenQueue *tokenQueue, QWidget *parent);
|
||||
WikiGroupDialog(TokenQueue *tokenExternalQueue, RsTokenService *tokenService, Mode mode, RsGxsGroupId groupId, QWidget *parent = NULL);
|
||||
WikiGroupDialog(QWidget *parent);
|
||||
WikiGroupDialog(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& groupMetaData);
|
||||
virtual void initUi() override;
|
||||
virtual QPixmap serviceImage() override;
|
||||
virtual bool service_createGroup(RsGroupMetaData &meta) override;
|
||||
virtual bool service_updateGroup(const RsGroupMetaData &editedMeta) override;
|
||||
virtual bool service_loadGroup(const RsGxsGenericGroupData *data, Mode mode, QString &description) override;
|
||||
virtual bool service_getGroupData(const RsGxsGroupId &groupId, RsGxsGenericGroupData *&data) override;
|
||||
|
||||
private:
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user