mirror of
https://github.com/RetroShare/RetroShare.git
synced 2024-12-26 07:59:35 -05:00
fixed window minupnpc source, header file incorrect
got Topic creation working with Posted GUI/backend refactored Posted/PostedGroupDialog to posted folder git-svn-id: http://svn.code.sf.net/p/retroshare/code/branches/v0.5-gxs-b1@5742 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
parent
cddeaeea81
commit
da70036f0f
@ -68,6 +68,8 @@ public:
|
||||
class RsGxsPostedSerialiser : public RsSerialType
|
||||
{
|
||||
|
||||
public:
|
||||
|
||||
RsGxsPostedSerialiser()
|
||||
: RsSerialType(RS_PKT_VERSION_SERVICE, RS_SERVICE_GXSV1_TYPE_PHOTO)
|
||||
{ return; }
|
||||
|
@ -8,7 +8,7 @@ const uint32_t RsPosted::FLAG_MSGTYPE_VOTE = 0x0004;
|
||||
RsPosted *rsPosted = NULL;
|
||||
|
||||
p3Posted::p3Posted(RsGeneralDataService *gds, RsNetworkExchangeService *nes)
|
||||
: RsGenExchange(gds, nes, NULL, RS_SERVICE_GXSV1_TYPE_POSTED), RsPosted(this)
|
||||
: RsGenExchange(gds, nes, new RsGxsPostedSerialiser(), RS_SERVICE_GXSV1_TYPE_POSTED), RsPosted(this)
|
||||
{
|
||||
}
|
||||
|
||||
|
@ -10,7 +10,7 @@ extern "C" {
|
||||
#endif
|
||||
/* This stuff is actually C */
|
||||
|
||||
#include "upnp/upnphandler.h"
|
||||
#include "upnp/upnphandler_miniupnp.h"
|
||||
#include "upnp/upnputil.h"
|
||||
|
||||
class uPnPConfigData
|
||||
@ -402,6 +402,7 @@ bool upnphandler::shutdown_upnp()
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
upnphandler::upnphandler()
|
||||
: dataMtx("upnpState"), toEnable(false), toStart(false), toStop(false),
|
||||
eport(0), eport_curr(0),
|
||||
|
@ -987,7 +987,8 @@ posted {
|
||||
gui/Posted/PostedListDialog.h \
|
||||
gui/Posted/PostedItem.h \
|
||||
gui/Posted/PostedComments.h \
|
||||
util/TokenQueueVEG.h
|
||||
util/TokenQueueVEG.h \
|
||||
gui/Posted/PostedGroupDialog.h \
|
||||
|
||||
FORMS += gui/Posted/PostedDialog.ui \
|
||||
gui/Posted/PostedListDialog.ui \
|
||||
@ -998,14 +999,14 @@ posted {
|
||||
gui/Posted/PostedListDialog.cpp \
|
||||
gui/Posted/PostedItem.cpp \
|
||||
gui/Posted/PostedComments.cpp \
|
||||
util/TokenQueueVEG.cpp
|
||||
util/TokenQueueVEG.cpp \
|
||||
gui/Posted/PostedGroupDialog.cpp
|
||||
|
||||
}
|
||||
|
||||
gxsgui {
|
||||
|
||||
HEADERS += gui/gxs/GxsGroupDialog.h \
|
||||
gui/gxs/PostedGroupDialog.h \
|
||||
gui/gxs/GxsCommentTreeWidget.h
|
||||
# gui/gxs/ForumV2GroupDialog.h \
|
||||
# gui/gxs/WikiGroupDialog.h \
|
||||
@ -1017,7 +1018,6 @@ gxsgui {
|
||||
# gui/gxs/GxsCommentTreeWidget.ui \
|
||||
|
||||
SOURCES += gui/gxs/GxsGroupDialog.cpp \
|
||||
gui/gxs/PostedGroupDialog.cpp \
|
||||
gui/gxs/GxsCommentTreeWidget.cpp
|
||||
#gui/gxs/ForumV2GroupDialog.cpp \
|
||||
# gui/gxs/WikiGroupDialog.cpp \
|
||||
|
@ -20,12 +20,13 @@
|
||||
****************************************************************/
|
||||
|
||||
#include "PostedGroupDialog.h"
|
||||
#include "util/TokenQueue.h"
|
||||
|
||||
#include <retroshare/rsposted.h>
|
||||
#include <iostream>
|
||||
|
||||
PostedGroupDialog::PostedGroupDialog(QWidget *parent)
|
||||
:GxsGroupDialog(rsPosted->getTokenService(), parent)
|
||||
PostedGroupDialog::PostedGroupDialog(TokenQueue* tokenQueue, QWidget *parent)
|
||||
:GxsGroupDialog(tokenQueue, parent, GXS_GROUP_DIALOG_CREATE_MODE)
|
||||
{
|
||||
|
||||
// To start with we only have open forums - with distribution controls.
|
||||
@ -41,24 +42,40 @@ PostedGroupDialog::PostedGroupDialog(QWidget *parent)
|
||||
|
||||
uint32_t readonlyFlags = 0;
|
||||
|
||||
uint32_t defaultsFlags = ( //GXS_GROUP_DEFAULTS_DISTRIB_PUBLIC |
|
||||
//GXS_GROUP_DEFAULTS_DISTRIB_GROUP |
|
||||
GXS_GROUP_DEFAULTS_DISTRIB_LOCAL |
|
||||
|
||||
//GXS_GROUP_DEFAULTS_PUBLISH_OPEN |
|
||||
//GXS_GROUP_DEFAULTS_PUBLISH_THREADS |
|
||||
uint32_t defaultsFlags = ( GXS_GROUP_DEFAULTS_DISTRIB_LOCAL |
|
||||
GXS_GROUP_DEFAULTS_PUBLISH_REQUIRED |
|
||||
//GXS_GROUP_DEFAULTS_PUBLISH_ENCRYPTED |
|
||||
|
||||
//GXS_GROUP_DEFAULTS_PERSONAL_GPG |
|
||||
//GXS_GROUP_DEFAULTS_PERSONAL_REQUIRED |
|
||||
GXS_GROUP_DEFAULTS_PERSONAL_IFNOPUB |
|
||||
|
||||
//GXS_GROUP_DEFAULTS_COMMENTS_YES |
|
||||
GXS_GROUP_DEFAULTS_COMMENTS_NO |
|
||||
0);
|
||||
|
||||
setFlags(enabledFlags, readonlyFlags, defaultsFlags);
|
||||
setFlags(enabledFlags, defaultsFlags);
|
||||
|
||||
}
|
||||
|
||||
PostedGroupDialog::PostedGroupDialog(const RsPostedGroup &grp, QWidget *parent)
|
||||
:GxsGroupDialog(NULL, parent, GXS_GROUP_DIALOG_SHOW_MODE), mGrp(grp)
|
||||
{
|
||||
|
||||
// To start with we only have open forums - with distribution controls.
|
||||
|
||||
uint32_t enabledFlags = ( GXS_GROUP_FLAGS_ICON |
|
||||
GXS_GROUP_FLAGS_DESCRIPTION |
|
||||
GXS_GROUP_FLAGS_DISTRIBUTION |
|
||||
GXS_GROUP_FLAGS_PUBLISHSIGN |
|
||||
GXS_GROUP_FLAGS_SHAREKEYS |
|
||||
GXS_GROUP_FLAGS_PERSONALSIGN |
|
||||
GXS_GROUP_FLAGS_COMMENTS |
|
||||
0);
|
||||
|
||||
uint32_t readonlyFlags = 0;
|
||||
|
||||
uint32_t defaultsFlags = ( GXS_GROUP_DEFAULTS_DISTRIB_LOCAL |
|
||||
GXS_GROUP_DEFAULTS_PUBLISH_REQUIRED |
|
||||
GXS_GROUP_DEFAULTS_PERSONAL_IFNOPUB |
|
||||
GXS_GROUP_DEFAULTS_COMMENTS_NO |
|
||||
0);
|
||||
|
||||
setFlags(enabledFlags, defaultsFlags);
|
||||
|
||||
}
|
||||
|
||||
@ -68,31 +85,24 @@ bool PostedGroupDialog::service_CreateGroup(uint32_t &token, const RsGroupMetaDa
|
||||
// Specific Function.
|
||||
RsPostedGroup grp;
|
||||
grp.mMeta = meta;
|
||||
//grp.mDescription = std::string(desc.toUtf8());
|
||||
|
||||
rsPosted->submitGroup(token, grp);
|
||||
return true;
|
||||
}
|
||||
|
||||
void PostedGroupDialog::service_loadExistingGroup(const uint32_t &token)
|
||||
QPixmap PostedGroupDialog::service_getLogo()
|
||||
{
|
||||
std::cerr << "PostedGroupDialog::service_loadExistingGroup()";
|
||||
std::cerr << std::endl;
|
||||
return QPixmap(); // null pixmap
|
||||
}
|
||||
|
||||
RsPostedGroup group;
|
||||
if (!rsPosted->getGroup(token, group))
|
||||
{
|
||||
std::cerr << "PostedGroupDialog::service_loadExistingGroup() ERROR Getting Group";
|
||||
std::cerr << std::endl;
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
/* must call metadata loader */
|
||||
loadExistingGroupMetaData(group.mMeta);
|
||||
|
||||
/* now load any extra data we feel like */
|
||||
QString PostedGroupDialog::service_getDescription()
|
||||
{
|
||||
return QString();
|
||||
}
|
||||
|
||||
RsGroupMetaData PostedGroupDialog::service_getMeta()
|
||||
{
|
||||
return mGrp.mMeta;
|
||||
}
|
||||
|
||||
|
@ -23,20 +23,52 @@
|
||||
#ifndef _POSTED_GROUP_DIALOG_H
|
||||
#define _POSTED_GROUP_DIALOG_H
|
||||
|
||||
#include "GxsGroupDialog.h"
|
||||
#include "gui/gxs/GxsGroupDialog.h"
|
||||
#include "retroshare/rsposted.h"
|
||||
|
||||
class PostedGroupDialog : public GxsGroupDialog
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
PostedGroupDialog(QWidget *parent);
|
||||
|
||||
/*!
|
||||
* This constructs a create dialog
|
||||
*/
|
||||
PostedGroupDialog(TokenQueue* tokenQueue, QWidget *parent = NULL);
|
||||
|
||||
/*!
|
||||
* This constructs a show dialog which displays an already existing group
|
||||
*/
|
||||
PostedGroupDialog(const RsPostedGroup& grp, QWidget *parent = NULL);
|
||||
|
||||
protected:
|
||||
virtual bool service_CreateGroup(uint32_t &token, const RsGroupMetaData &meta);
|
||||
// virtual bool service_CompleteCreateGroup(const RsGroupMetaData &meta);
|
||||
|
||||
virtual void service_loadExistingGroup(const uint32_t &token);
|
||||
bool service_CreateGroup(uint32_t &token, const RsGroupMetaData &meta);
|
||||
|
||||
/*!
|
||||
* This should return a group logo \n
|
||||
* Will be called when GxsGroupDialog is initialised in show mode
|
||||
*
|
||||
*/
|
||||
virtual QPixmap service_getLogo();
|
||||
|
||||
/*!
|
||||
* This should return a group description string
|
||||
* @return group description string
|
||||
*/
|
||||
virtual QString service_getDescription();
|
||||
|
||||
/*!
|
||||
* Used in show mode, returns a meta type
|
||||
* @return the meta of existing grpMeta
|
||||
*/
|
||||
virtual RsGroupMetaData service_getMeta();
|
||||
|
||||
|
||||
private:
|
||||
|
||||
RsPostedGroup mGrp;
|
||||
|
||||
};
|
||||
|
@ -23,9 +23,10 @@
|
||||
|
||||
#include "PostedListDialog.h"
|
||||
|
||||
#include "gui/gxs/PostedGroupDialog.h"
|
||||
#include "gui/Posted/PostedGroupDialog.h"
|
||||
|
||||
#include <retroshare/rsposted.h>
|
||||
#include <gxs/rsgxsflags.h>
|
||||
|
||||
#include <iostream>
|
||||
#include <sstream>
|
||||
@ -276,9 +277,7 @@ void PostedListDialog::periodChanged( int index )
|
||||
|
||||
void PostedListDialog::newGroup()
|
||||
{
|
||||
PostedGroupDialog cf (this);
|
||||
cf.newGroup();
|
||||
|
||||
PostedGroupDialog cf (mPostedQueue, this);
|
||||
cf.exec ();
|
||||
}
|
||||
|
||||
@ -289,38 +288,16 @@ void PostedListDialog::showGroupDetails()
|
||||
return;
|
||||
}
|
||||
|
||||
PostedGroupDialog cf (this);
|
||||
cf.existingGroup(mCurrTopicId, GXS_GROUP_DIALOG_SHOW_MODE);
|
||||
|
||||
PostedGroupDialog cf(mGroups[mCurrTopicId], this);
|
||||
cf.exec ();
|
||||
}
|
||||
|
||||
void PostedListDialog::editGroupDetails()
|
||||
{
|
||||
if (mCurrTopicId.empty())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
PostedGroupDialog cf (this);
|
||||
cf.existingGroup(mCurrTopicId, GXS_GROUP_DIALOG_EDIT_MODE);
|
||||
|
||||
cf.exec ();
|
||||
}
|
||||
|
||||
|
||||
/*********************** **** **** **** ***********************/
|
||||
/** Request / Response of Data ********************************/
|
||||
/*********************** **** **** **** ***********************/
|
||||
|
||||
#define POSTEDDIALOG_LISTING 1
|
||||
#define POSTEDDIALOG_CURRENTFORUM 2
|
||||
#define POSTEDDIALOG_INSERTTHREADS 3
|
||||
#define POSTEDDIALOG_INSERTCHILD 4
|
||||
#define POSTEDDIALOG_INSERT_POST 5
|
||||
#define POSTEDDIALOG_REPLY_MESSAGE 6
|
||||
|
||||
|
||||
void PostedListDialog::insertGroups()
|
||||
{
|
||||
requestGroupSummary();
|
||||
@ -337,6 +314,23 @@ void PostedListDialog::requestGroupSummary()
|
||||
mPostedQueue->requestGroupInfo(token, RS_TOKREQ_ANSTYPE_SUMMARY, opts, ids, POSTEDDIALOG_LISTING);
|
||||
}
|
||||
|
||||
void PostedListDialog::acknowledgeGroup(const uint32_t &token)
|
||||
{
|
||||
RsGxsGroupId grpId;
|
||||
rsPosted->acknowledgeGrp(token, grpId);
|
||||
|
||||
if(!grpId.empty())
|
||||
{
|
||||
std::list<RsGxsGroupId> grpIds;
|
||||
grpIds.push_back(grpId);
|
||||
|
||||
RsTokReqOptions opts;
|
||||
opts.mReqType = GXS_REQUEST_TYPE_GROUP_META;
|
||||
uint32_t reqToken;
|
||||
mPostedQueue->requestGroupInfo(reqToken, RS_TOKREQ_ANSTYPE_SUMMARY, opts, grpIds, 0);
|
||||
}
|
||||
}
|
||||
|
||||
void PostedListDialog::loadGroupSummary(const uint32_t &token)
|
||||
{
|
||||
std::cerr << "PostedListDialog::loadGroupSummary()";
|
||||
@ -557,20 +551,22 @@ void PostedListDialog::loadRequest(const TokenQueue *queue, const TokenRequest &
|
||||
if (queue == mPostedQueue)
|
||||
{
|
||||
/* now switch on req */
|
||||
switch(req.mUserType)
|
||||
switch(req.mType)
|
||||
{
|
||||
case POSTEDDIALOG_LISTING:
|
||||
case TOKENREQ_GROUPINFO:
|
||||
switch(req.mAnsType)
|
||||
{
|
||||
|
||||
case RS_TOKREQ_ANSTYPE_ACK:
|
||||
acknowledgeGroup(req.mToken);
|
||||
break;
|
||||
case RS_TOKREQ_ANSTYPE_SUMMARY:
|
||||
loadGroupSummary(req.mToken);
|
||||
default:
|
||||
std::cerr << "Error, unexpected anstype:" << req.mAnsType << std::endl;
|
||||
break;
|
||||
|
||||
case POSTEDDIALOG_CURRENTFORUM:
|
||||
loadGroupSummary_CurrentForum(req.mToken);
|
||||
}
|
||||
break;
|
||||
|
||||
case POSTEDDIALOG_INSERTTHREADS:
|
||||
loadGroupThreadData_InsertThreads(req.mToken);
|
||||
break;
|
||||
|
||||
default:
|
||||
std::cerr << "PostedListDialog::loadRequest() ERROR: INVALID TYPE";
|
||||
std::cerr << std::endl;
|
||||
@ -589,12 +585,72 @@ void PostedListDialog::loadRequest(const TokenQueue *queue, const TokenRequest &
|
||||
|
||||
void PostedListDialog::groupInfoToGroupItemInfo(const RsGroupMetaData &groupInfo, GroupItemInfo &groupItemInfo)
|
||||
{
|
||||
groupItemInfo.id = QString::fromStdString(groupInfo.mGroupId);
|
||||
groupItemInfo.name = QString::fromUtf8(groupInfo.mGroupName.c_str());
|
||||
//groupItemInfo.description = QString::fromUtf8(groupInfo.forumDesc);
|
||||
groupItemInfo.popularity = groupInfo.mPop;
|
||||
groupItemInfo.lastpost = QDateTime::fromTime_t(groupInfo.mLastPost);
|
||||
|
||||
|
||||
}
|
||||
|
||||
void PostedListDialog::insertGroupData(const std::list<RsGroupMetaData> &groupList)
|
||||
{
|
||||
|
||||
std::list<RsGroupMetaData>::const_iterator it;
|
||||
|
||||
QList<GroupItemInfo> adminList;
|
||||
QList<GroupItemInfo> subList;
|
||||
QList<GroupItemInfo> popList;
|
||||
QList<GroupItemInfo> otherList;
|
||||
std::multimap<uint32_t, GroupItemInfo> popMap;
|
||||
|
||||
for (it = groupList.begin(); it != groupList.end(); it++) {
|
||||
/* sort it into Publish (Own), Subscribed, Popular and Other */
|
||||
uint32_t flags = it->mSubscribeFlags;
|
||||
|
||||
GroupItemInfo groupItemInfo;
|
||||
groupInfoToGroupItemInfo(*it, groupItemInfo);
|
||||
|
||||
// if (flags & GXS_SERV::GROUP_SUBSCRIBE_ADMIN) {
|
||||
adminList.push_back(groupItemInfo);
|
||||
// } else if (flags & GXS_SERV::GROUP_SUBSCRIBE_SUBSCRIBED) {
|
||||
/* subscribed forum */
|
||||
// subList.push_back(groupItemInfo);
|
||||
// } else {
|
||||
/* rate the others by popularity */
|
||||
// popMap.insert(std::make_pair(it->mPop, groupItemInfo));
|
||||
}
|
||||
// }
|
||||
|
||||
/* iterate backwards through popMap - take the top 5 or 10% of list */
|
||||
uint32_t popCount = 5;
|
||||
if (popCount < popMap.size() / 10)
|
||||
{
|
||||
popCount = popMap.size() / 10;
|
||||
}
|
||||
|
||||
uint32_t i = 0;
|
||||
uint32_t popLimit = 0;
|
||||
std::multimap<uint32_t, GroupItemInfo>::reverse_iterator rit;
|
||||
for(rit = popMap.rbegin(); ((rit != popMap.rend()) && (i < popCount)); rit++, i++) ;
|
||||
if (rit != popMap.rend()) {
|
||||
popLimit = rit->first;
|
||||
}
|
||||
|
||||
for (rit = popMap.rbegin(); rit != popMap.rend(); rit++) {
|
||||
if (rit->second.popularity < (int) popLimit) {
|
||||
otherList.append(rit->second);
|
||||
} else {
|
||||
popList.append(rit->second);
|
||||
}
|
||||
}
|
||||
|
||||
/* now we can add them in as a tree! */
|
||||
ui.groupTreeWidget->fillGroupItems(yourTopics, adminList);
|
||||
ui.groupTreeWidget->fillGroupItems(subscribedTopics, subList);
|
||||
ui.groupTreeWidget->fillGroupItems(popularTopics, popList);
|
||||
ui.groupTreeWidget->fillGroupItems(otherTopics, otherList);
|
||||
}
|
||||
|
||||
/**************************************************************************************/
|
||||
|
@ -38,6 +38,17 @@
|
||||
|
||||
#include "retroshare-gui/RsAutoUpdatePage.h"
|
||||
|
||||
/*********************** **** **** **** ***********************/
|
||||
/** Request / Response of Data ********************************/
|
||||
/*********************** **** **** **** ***********************/
|
||||
|
||||
#define POSTEDDIALOG_LISTING 1
|
||||
#define POSTEDDIALOG_CURRENTFORUM 2
|
||||
#define POSTEDDIALOG_INSERTTHREADS 3
|
||||
#define POSTEDDIALOG_INSERTCHILD 4
|
||||
#define POSTEDDIALOG_INSERT_POST 5
|
||||
#define POSTEDDIALOG_REPLY_MESSAGE 6
|
||||
|
||||
class PostedListDialog : public RsAutoUpdatePage, public PostedHolder, public TokenResponse
|
||||
{
|
||||
Q_OBJECT
|
||||
@ -75,6 +86,7 @@ void loadPost(const RsPostedPost &post);
|
||||
|
||||
void insertGroups();
|
||||
void requestGroupSummary();
|
||||
void acknowledgeGroup(const uint32_t &token);
|
||||
void loadGroupSummary(const uint32_t &token);
|
||||
|
||||
void requestGroupSummary_CurrentForum(const std::string &forumId);
|
||||
@ -103,6 +115,7 @@ void groupInfoToGroupItemInfo(const RsGroupMetaData &groupInfo, GroupItemInfo &
|
||||
bool mThreadLoading;
|
||||
std::string mCurrTopicId;
|
||||
|
||||
QMap<RsGxsGroupId, RsPostedGroup> mGroups;
|
||||
TokenQueue *mPostedQueue;
|
||||
|
||||
/* UI - from Designer */
|
||||
|
@ -50,14 +50,12 @@
|
||||
#define GXSGROUP_LOADGROUP 2
|
||||
|
||||
/** Constructor */
|
||||
GxsGroupDialog::GxsGroupDialog(RsTokenService *service, QWidget *parent)
|
||||
: QDialog(parent), mRsService(service)
|
||||
GxsGroupDialog::GxsGroupDialog(TokenQueue* tokenQueue, QWidget *parent, uint32_t mode)
|
||||
: QDialog(parent), mTokenQueue(tokenQueue), mMode(mode)
|
||||
{
|
||||
/* Invoke the Qt Designer generated object setup routine */
|
||||
ui.setupUi(this);
|
||||
|
||||
mTokenQueue = new TokenQueue(service, this);
|
||||
|
||||
// connect up the buttons.
|
||||
connect( ui.cancelButton, SIGNAL( clicked ( bool ) ), this, SLOT( cancelDialog( ) ) );
|
||||
connect( ui.createButton, SIGNAL( clicked ( bool ) ), this, SLOT( submitGroup( ) ) );
|
||||
@ -87,46 +85,31 @@ GxsGroupDialog::GxsGroupDialog(RsTokenService *service, QWidget *parent)
|
||||
GXS_GROUP_FLAGS_PERSONALSIGN |
|
||||
GXS_GROUP_FLAGS_COMMENTS );
|
||||
|
||||
uint32_t readonlyFlags = 0;
|
||||
|
||||
uint32_t defaultsFlags = ( GXS_GROUP_DEFAULTS_DISTRIB_PUBLIC |
|
||||
//GXS_GROUP_DEFAULTS_DISTRIB_GROUP |
|
||||
//GXS_GROUP_DEFAULTS_DISTRIB_LOCAL |
|
||||
|
||||
//GXS_GROUP_DEFAULTS_PUBLISH_OPEN |
|
||||
GXS_GROUP_DEFAULTS_PUBLISH_THREADS |
|
||||
//GXS_GROUP_DEFAULTS_PUBLISH_REQUIRED |
|
||||
//GXS_GROUP_DEFAULTS_PUBLISH_ENCRYPTED |
|
||||
|
||||
//GXS_GROUP_DEFAULTS_PERSONAL_GPG |
|
||||
//GXS_GROUP_DEFAULTS_PERSONAL_REQUIRED |
|
||||
GXS_GROUP_DEFAULTS_PERSONAL_IFNOPUB |
|
||||
|
||||
GXS_GROUP_DEFAULTS_COMMENTS_YES |
|
||||
//GXS_GROUP_DEFAULTS_COMMENTS_NO |
|
||||
0);
|
||||
|
||||
setFlags(enabledFlags, readonlyFlags, defaultsFlags);
|
||||
|
||||
setFlags(enabledFlags, defaultsFlags);
|
||||
setMode(mode);
|
||||
}
|
||||
|
||||
void GxsGroupDialog::setFlags(uint32_t enabledFlags, uint32_t readonlyFlags, uint32_t defaultsFlags)
|
||||
void GxsGroupDialog::setFlags(uint32_t enabledFlags, uint32_t defaultsFlags)
|
||||
{
|
||||
mEnabledFlags = enabledFlags;
|
||||
mReadonlyFlags = readonlyFlags;
|
||||
mDefaultsFlags = defaultsFlags;
|
||||
}
|
||||
|
||||
void GxsGroupDialog::setMode(uint32_t mode)
|
||||
{
|
||||
mMode = mode;
|
||||
|
||||
/* switch depending on mode */
|
||||
switch(mMode)
|
||||
{
|
||||
case GXS_GROUP_DIALOG_CREATE_MODE:
|
||||
{
|
||||
ui.createButton->setText(tr("Create Group"));
|
||||
newGroup();
|
||||
}
|
||||
break;
|
||||
|
||||
@ -138,11 +121,11 @@ void GxsGroupDialog::setMode(uint32_t mode)
|
||||
}
|
||||
break;
|
||||
|
||||
case GXS_GROUP_DIALOG_EDIT_MODE:
|
||||
{
|
||||
ui.createButton->setText(tr("Submit Changes"));
|
||||
}
|
||||
break;
|
||||
// case GXS_GROUP_DIALOG_EDIT_MODE:
|
||||
// {
|
||||
// ui.createButton->setText(tr("Submit Changes"));
|
||||
// }
|
||||
// break;
|
||||
}
|
||||
}
|
||||
|
||||
@ -151,7 +134,6 @@ void GxsGroupDialog::clearForm()
|
||||
{
|
||||
ui.groupName->clear();
|
||||
ui.groupDesc->clear();
|
||||
|
||||
ui.groupName->setFocus();
|
||||
}
|
||||
|
||||
@ -238,7 +220,6 @@ void GxsGroupDialog::setupDefaults()
|
||||
// default
|
||||
ui.comments_no->setChecked(true);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@ -286,59 +267,16 @@ void GxsGroupDialog::newGroup()
|
||||
setupVisibility();
|
||||
clearForm();
|
||||
|
||||
setMode(GXS_GROUP_DIALOG_CREATE_MODE);
|
||||
|
||||
service_NewGroup();
|
||||
}
|
||||
|
||||
|
||||
void GxsGroupDialog::existingGroup(std::string groupId, uint32_t mode)
|
||||
{
|
||||
setupDefaults();
|
||||
setupVisibility();
|
||||
clearForm();
|
||||
|
||||
setMode(mode);
|
||||
|
||||
service_ExistingGroup();
|
||||
|
||||
/* request data */
|
||||
{
|
||||
RsTokReqOptions opts;
|
||||
|
||||
std::list<std::string> grpIds;
|
||||
grpIds.push_back(groupId);
|
||||
|
||||
std::cerr << "GxsGroupDialog::existingGroup() Requesting Data.";
|
||||
std::cerr << std::endl;
|
||||
|
||||
uint32_t token;
|
||||
mTokenQueue->requestGroupInfo(token, RS_TOKREQ_ANSTYPE_DATA, opts, grpIds, GXSGROUP_LOADGROUP);
|
||||
}
|
||||
}
|
||||
|
||||
bool GxsGroupDialog::loadExistingGroupMetaData(const RsGroupMetaData &meta)
|
||||
void GxsGroupDialog::loadExistingGroupMetaData(const RsGroupMetaData &meta)
|
||||
{
|
||||
/* should set stuff - according to parameters */
|
||||
setGroupSignFlags(meta.mSignFlags);
|
||||
ui.groupName->setText(QString::fromUtf8(meta.mGroupName.c_str()));
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
|
||||
bool GxsGroupDialog::service_NewGroup()
|
||||
{
|
||||
/* setup any extra bits */
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
bool GxsGroupDialog::service_ExistingGroup()
|
||||
{
|
||||
/* setup any extra bits */
|
||||
return true;
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@ -374,15 +312,9 @@ void GxsGroupDialog::submitGroup()
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
void GxsGroupDialog::createGroup()
|
||||
{
|
||||
QString name = misc::removeNewLine(ui.groupName->text());
|
||||
QString desc = ui.groupDesc->toPlainText(); //toHtml();
|
||||
uint32_t flags = 0;
|
||||
|
||||
if(name.isEmpty())
|
||||
@ -392,29 +324,22 @@ void GxsGroupDialog::createGroup()
|
||||
return; //Don't add a empty name!!
|
||||
}
|
||||
|
||||
if (mRsService)
|
||||
{
|
||||
|
||||
uint32_t token;
|
||||
RsGroupMetaData meta;
|
||||
|
||||
// Fill in the MetaData as best we can.
|
||||
meta.mGroupName = std::string(name.toUtf8());
|
||||
//meta.mDesc = std::string(desc.toUtf8());
|
||||
|
||||
meta.mGroupFlags = flags;
|
||||
meta.mSignFlags = getGroupSignFlags();
|
||||
|
||||
// These ones shouldn't be needed here - but will be used, until we have fully functional backend.
|
||||
meta.mSubscribeFlags = GXS_SERV::GROUP_SUBSCRIBE_ADMIN;
|
||||
meta.mPublishTs = time(NULL);
|
||||
|
||||
if (service_CreateGroup(token, meta))
|
||||
{
|
||||
// get the Queue to handle response.
|
||||
mTokenQueue->queueRequest(token, TOKENREQ_MSGINFO, RS_TOKREQ_ANSTYPE_SUMMARY, GXSGROUP_NEWGROUPID);
|
||||
}
|
||||
if(mTokenQueue != NULL)
|
||||
mTokenQueue->queueRequest(token, TOKENREQ_GROUPINFO, RS_TOKREQ_ANSTYPE_ACK, GXSGROUP_NEWGROUPID);
|
||||
}
|
||||
close();
|
||||
}
|
||||
|
||||
uint32_t GxsGroupDialog::getGroupSignFlags()
|
||||
@ -478,41 +403,9 @@ void GxsGroupDialog::setGroupSignFlags(uint32_t signFlags)
|
||||
{
|
||||
ui.comments_no->setChecked(true);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
bool GxsGroupDialog::service_CreateGroup(uint32_t &token, const RsGroupMetaData &meta)
|
||||
{
|
||||
token = 0;
|
||||
return false;
|
||||
}
|
||||
|
||||
bool GxsGroupDialog::service_CompleteCreateGroup(const RsGroupMetaData &meta)
|
||||
{
|
||||
/* dummy function - for overloading */
|
||||
return true;
|
||||
}
|
||||
|
||||
void GxsGroupDialog::completeCreateGroup(const RsGroupMetaData &newMeta)
|
||||
{
|
||||
std::cerr << "GxsGroupDialog::completeCreateGroup() Created Group with MetaData: ";
|
||||
std::cerr << std::endl;
|
||||
std::cerr << newMeta;
|
||||
std::cerr << std::endl;
|
||||
|
||||
sendShareList(newMeta.mGroupId);
|
||||
|
||||
service_CompleteCreateGroup(newMeta);
|
||||
|
||||
std::cerr << "GxsGroupDialog::completeCreateGroup() Should Close!";
|
||||
std::cerr << std::endl;
|
||||
|
||||
close();
|
||||
}
|
||||
|
||||
void GxsGroupDialog::cancelDialog()
|
||||
{
|
||||
std::cerr << "GxsGroupDialog::cancelDialog() Should Close!";
|
||||
@ -543,7 +436,6 @@ void GxsGroupDialog::addGroupLogo()
|
||||
|
||||
void GxsGroupDialog::sendShareList(std::string groupId)
|
||||
{
|
||||
|
||||
close();
|
||||
}
|
||||
|
||||
@ -558,83 +450,3 @@ void GxsGroupDialog::setShareList()
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/***********************************************************************************
|
||||
Handle Callbacks for Load / Create.
|
||||
***********************************************************************************/
|
||||
|
||||
void GxsGroupDialog::loadNewGroupId(const uint32_t &token)
|
||||
{
|
||||
std::cerr << "GxsGroupDialog::loadNewGroupId()";
|
||||
std::cerr << std::endl;
|
||||
|
||||
std::list<RsGroupMetaData> groupInfo;
|
||||
|
||||
if (groupInfo.size() == 1)
|
||||
{
|
||||
RsGroupMetaData fi = groupInfo.front();
|
||||
completeCreateGroup(fi);
|
||||
}
|
||||
else
|
||||
{
|
||||
std::cerr << "GxsGroupDialog::loadNewGroupId() ERROR INVALID Number of Forums Created";
|
||||
std::cerr << std::endl;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void GxsGroupDialog::service_loadExistingGroup(const uint32_t &token)
|
||||
{
|
||||
std::cerr << "GxsGroupDialog::service_loadExistingGroup() ERROR Must be Overloaded";
|
||||
std::cerr << std::endl;
|
||||
|
||||
#if 0
|
||||
std::list<RsGroupMetaData> groupInfo;
|
||||
mRsService->getGroupSummary(token, groupInfo);
|
||||
|
||||
if (groupInfo.size() == 1)
|
||||
{
|
||||
RsGroupMetaData fi = groupInfo.front();
|
||||
completeCreateGroup(fi);
|
||||
}
|
||||
else
|
||||
{
|
||||
std::cerr << "GxsGroupDialog::loadNewGroupId() ERROR INVALID Number of Forums Created";
|
||||
std::cerr << std::endl;
|
||||
}
|
||||
#endif
|
||||
|
||||
}
|
||||
|
||||
|
||||
void GxsGroupDialog::loadRequest(const TokenQueue *queue, const TokenRequest &req)
|
||||
{
|
||||
std::cerr << "GxsGroupDialog::loadRequest() UserType: " << req.mUserType;
|
||||
std::cerr << std::endl;
|
||||
|
||||
if (queue != mTokenQueue)
|
||||
{
|
||||
std::cerr << "GxsGroupDialog::loadRequest() Queue ERROR";
|
||||
std::cerr << std::endl;
|
||||
return;
|
||||
}
|
||||
|
||||
/* now switch on req */
|
||||
switch(req.mUserType)
|
||||
{
|
||||
|
||||
case GXSGROUP_NEWGROUPID:
|
||||
loadNewGroupId(req.mToken);
|
||||
break;
|
||||
case GXSGROUP_LOADGROUP:
|
||||
service_loadExistingGroup(req.mToken);
|
||||
break;
|
||||
default:
|
||||
std::cerr << "GxsGroupDialog::loadRequest() UNKNOWN UserType ";
|
||||
std::cerr << std::endl;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
@ -90,23 +90,46 @@ public:
|
||||
#define GXS_GROUP_DIALOG_SHOW_MODE 2
|
||||
#define GXS_GROUP_DIALOG_EDIT_MODE 3
|
||||
|
||||
class GxsGroupDialog : public QDialog, public TokenResponse
|
||||
/*!
|
||||
* The aim of this dialog is to be convenient to encapsulate group
|
||||
* creation code for several GXS services such forums, channels
|
||||
* and posted
|
||||
* The functionality provided are for group creation are:
|
||||
* - Specifying the authentication type of the group
|
||||
* - Specifying group image
|
||||
* -
|
||||
* The main limitation is that it will not deal with the actual service GXS Group
|
||||
* data structure, but the meta structure which is the same across GXS services
|
||||
* 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
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
GxsGroupDialog(RsTokenService *service, QWidget *parent = 0);
|
||||
|
||||
void setFlags(uint32_t enabledFlags, uint32_t readonlyFlags, uint32_t defaultFlags);
|
||||
void setMode(uint32_t mode);
|
||||
/*!
|
||||
*
|
||||
* @param tokenQueue This should be the token service of the services Dialog \n
|
||||
* in order to receive acknowledgement of group creation, if set to NULL with create mode \n
|
||||
* creation will not happen
|
||||
* @param parent The parent dialog
|
||||
* @param mode
|
||||
*/
|
||||
GxsGroupDialog(TokenQueue* tokenQueue, QWidget *parent = NULL, uint32_t mode = GXS_GROUP_DIALOG_SHOW_MODE);
|
||||
|
||||
/*** Open Window -> in Correct Mode */
|
||||
/*!
|
||||
*
|
||||
* @param enabledFlags This determines what options are enabled
|
||||
* @param readonlyFlags This determines what is modifiable is particularly relevant to what mode the
|
||||
* @param defaultFlags
|
||||
*/
|
||||
void setFlags(uint32_t enabledFlags, uint32_t defaultFlags);
|
||||
|
||||
private:
|
||||
void newGroup();
|
||||
void existingGroup(std::string groupId, uint32_t mode);
|
||||
|
||||
// Callback for all Loads.
|
||||
virtual void loadRequest(const TokenQueue *queue, const TokenRequest &req);
|
||||
|
||||
void setMode(uint32_t mode);
|
||||
|
||||
// Functions that can be overloaded for specific stuff.
|
||||
|
||||
@ -116,21 +139,42 @@ protected slots:
|
||||
|
||||
protected:
|
||||
|
||||
// Functions to be overloaded.
|
||||
/*!
|
||||
* Main purpose is to help tansfer meta data to service
|
||||
* and also
|
||||
* @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;
|
||||
|
||||
// Group Creation.
|
||||
virtual bool service_NewGroup();
|
||||
virtual bool service_CreateGroup(uint32_t &token, const RsGroupMetaData &meta);
|
||||
virtual bool service_CompleteCreateGroup(const RsGroupMetaData &meta);
|
||||
/*!
|
||||
* This should return a group logo \n
|
||||
* Will be called when GxsGroupDialog is initialised in show mode
|
||||
*
|
||||
*/
|
||||
virtual QPixmap service_getLogo() = 0;
|
||||
|
||||
// Group Edit / Display.
|
||||
virtual bool service_ExistingGroup(); // Initial Setup.
|
||||
virtual void service_loadExistingGroup(const uint32_t &token);
|
||||
/*!
|
||||
* This should return a group description string
|
||||
* @return group description string
|
||||
*/
|
||||
virtual QString service_getDescription() = 0;
|
||||
|
||||
bool loadExistingGroupMetaData(const RsGroupMetaData &meta);
|
||||
/*!
|
||||
* Used in show mode, returns a meta type
|
||||
* @return the meta of existing grpMeta
|
||||
*/
|
||||
virtual RsGroupMetaData service_getMeta() = 0;
|
||||
|
||||
/*!
|
||||
* Loads meta data for group to GUI dialog
|
||||
* @param meta the meta loaded fir group
|
||||
*/
|
||||
void loadExistingGroupMetaData(const RsGroupMetaData &meta);
|
||||
|
||||
|
||||
private slots:
|
||||
|
||||
/* actions to take.... */
|
||||
void cancelDialog();
|
||||
|
||||
@ -141,29 +185,19 @@ private:
|
||||
|
||||
void setGroupSignFlags(uint32_t signFlags);
|
||||
uint32_t getGroupSignFlags();
|
||||
|
||||
void setupDefaults();
|
||||
void setupVisibility();
|
||||
void clearForm();
|
||||
|
||||
void createGroup();
|
||||
|
||||
virtual void completeCreateGroup(const RsGroupMetaData &newForumMeta);
|
||||
|
||||
|
||||
void sendShareList(std::string forumId);
|
||||
|
||||
void loadNewGroupId(const uint32_t &token);
|
||||
|
||||
|
||||
std::list<std::string> mShareList;
|
||||
|
||||
QPixmap picture;
|
||||
|
||||
RsTokenService *mRsService;
|
||||
TokenQueue *mTokenQueue;
|
||||
|
||||
uint32_t mMode;
|
||||
|
||||
uint32_t mEnabledFlags;
|
||||
uint32_t mReadonlyFlags;
|
||||
uint32_t mDefaultsFlags;
|
||||
|
Loading…
Reference in New Issue
Block a user