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:
chrisparker126 2012-10-29 22:41:41 +00:00
parent cddeaeea81
commit da70036f0f
10 changed files with 541 additions and 581 deletions

View File

@ -68,6 +68,8 @@ public:
class RsGxsPostedSerialiser : public RsSerialType class RsGxsPostedSerialiser : public RsSerialType
{ {
public:
RsGxsPostedSerialiser() RsGxsPostedSerialiser()
: RsSerialType(RS_PKT_VERSION_SERVICE, RS_SERVICE_GXSV1_TYPE_PHOTO) : RsSerialType(RS_PKT_VERSION_SERVICE, RS_SERVICE_GXSV1_TYPE_PHOTO)
{ return; } { return; }

View File

@ -8,7 +8,7 @@ const uint32_t RsPosted::FLAG_MSGTYPE_VOTE = 0x0004;
RsPosted *rsPosted = NULL; RsPosted *rsPosted = NULL;
p3Posted::p3Posted(RsGeneralDataService *gds, RsNetworkExchangeService *nes) 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)
{ {
} }

View File

@ -10,7 +10,7 @@ extern "C" {
#endif #endif
/* This stuff is actually C */ /* This stuff is actually C */
#include "upnp/upnphandler.h" #include "upnp/upnphandler_miniupnp.h"
#include "upnp/upnputil.h" #include "upnp/upnputil.h"
class uPnPConfigData class uPnPConfigData
@ -402,6 +402,7 @@ bool upnphandler::shutdown_upnp()
* *
*/ */
upnphandler::upnphandler() upnphandler::upnphandler()
: dataMtx("upnpState"), toEnable(false), toStart(false), toStop(false), : dataMtx("upnpState"), toEnable(false), toStart(false), toStop(false),
eport(0), eport_curr(0), eport(0), eport_curr(0),

View File

@ -987,7 +987,8 @@ posted {
gui/Posted/PostedListDialog.h \ gui/Posted/PostedListDialog.h \
gui/Posted/PostedItem.h \ gui/Posted/PostedItem.h \
gui/Posted/PostedComments.h \ gui/Posted/PostedComments.h \
util/TokenQueueVEG.h util/TokenQueueVEG.h \
gui/Posted/PostedGroupDialog.h \
FORMS += gui/Posted/PostedDialog.ui \ FORMS += gui/Posted/PostedDialog.ui \
gui/Posted/PostedListDialog.ui \ gui/Posted/PostedListDialog.ui \
@ -998,14 +999,14 @@ posted {
gui/Posted/PostedListDialog.cpp \ gui/Posted/PostedListDialog.cpp \
gui/Posted/PostedItem.cpp \ gui/Posted/PostedItem.cpp \
gui/Posted/PostedComments.cpp \ gui/Posted/PostedComments.cpp \
util/TokenQueueVEG.cpp util/TokenQueueVEG.cpp \
gui/Posted/PostedGroupDialog.cpp
} }
gxsgui { gxsgui {
HEADERS += gui/gxs/GxsGroupDialog.h \ HEADERS += gui/gxs/GxsGroupDialog.h \
gui/gxs/PostedGroupDialog.h \
gui/gxs/GxsCommentTreeWidget.h gui/gxs/GxsCommentTreeWidget.h
# gui/gxs/ForumV2GroupDialog.h \ # gui/gxs/ForumV2GroupDialog.h \
# gui/gxs/WikiGroupDialog.h \ # gui/gxs/WikiGroupDialog.h \
@ -1017,7 +1018,6 @@ gxsgui {
# gui/gxs/GxsCommentTreeWidget.ui \ # gui/gxs/GxsCommentTreeWidget.ui \
SOURCES += gui/gxs/GxsGroupDialog.cpp \ SOURCES += gui/gxs/GxsGroupDialog.cpp \
gui/gxs/PostedGroupDialog.cpp \
gui/gxs/GxsCommentTreeWidget.cpp gui/gxs/GxsCommentTreeWidget.cpp
#gui/gxs/ForumV2GroupDialog.cpp \ #gui/gxs/ForumV2GroupDialog.cpp \
# gui/gxs/WikiGroupDialog.cpp \ # gui/gxs/WikiGroupDialog.cpp \

View File

@ -20,12 +20,13 @@
****************************************************************/ ****************************************************************/
#include "PostedGroupDialog.h" #include "PostedGroupDialog.h"
#include "util/TokenQueue.h"
#include <retroshare/rsposted.h> #include <retroshare/rsposted.h>
#include <iostream> #include <iostream>
PostedGroupDialog::PostedGroupDialog(QWidget *parent) PostedGroupDialog::PostedGroupDialog(TokenQueue* tokenQueue, QWidget *parent)
:GxsGroupDialog(rsPosted->getTokenService(), parent) :GxsGroupDialog(tokenQueue, parent, GXS_GROUP_DIALOG_CREATE_MODE)
{ {
// To start with we only have open forums - with distribution controls. // 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 readonlyFlags = 0;
uint32_t defaultsFlags = ( //GXS_GROUP_DEFAULTS_DISTRIB_PUBLIC | uint32_t defaultsFlags = ( GXS_GROUP_DEFAULTS_DISTRIB_LOCAL |
//GXS_GROUP_DEFAULTS_DISTRIB_GROUP | GXS_GROUP_DEFAULTS_PUBLISH_REQUIRED |
GXS_GROUP_DEFAULTS_DISTRIB_LOCAL | GXS_GROUP_DEFAULTS_PERSONAL_IFNOPUB |
GXS_GROUP_DEFAULTS_COMMENTS_NO |
//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); 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. // Specific Function.
RsPostedGroup grp; RsPostedGroup grp;
grp.mMeta = meta; grp.mMeta = meta;
//grp.mDescription = std::string(desc.toUtf8());
rsPosted->submitGroup(token, grp); rsPosted->submitGroup(token, grp);
return true; return true;
} }
void PostedGroupDialog::service_loadExistingGroup(const uint32_t &token) QPixmap PostedGroupDialog::service_getLogo()
{ {
std::cerr << "PostedGroupDialog::service_loadExistingGroup()"; return QPixmap(); // null pixmap
std::cerr << std::endl; }
RsPostedGroup group; QString PostedGroupDialog::service_getDescription()
if (!rsPosted->getGroup(token, group)) {
{ return QString();
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 */
RsGroupMetaData PostedGroupDialog::service_getMeta()
{
return mGrp.mMeta;
} }

View File

@ -23,20 +23,52 @@
#ifndef _POSTED_GROUP_DIALOG_H #ifndef _POSTED_GROUP_DIALOG_H
#define _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 class PostedGroupDialog : public GxsGroupDialog
{ {
Q_OBJECT Q_OBJECT
public: 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: 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;
}; };

View File

@ -23,9 +23,10 @@
#include "PostedListDialog.h" #include "PostedListDialog.h"
#include "gui/gxs/PostedGroupDialog.h" #include "gui/Posted/PostedGroupDialog.h"
#include <retroshare/rsposted.h> #include <retroshare/rsposted.h>
#include <gxs/rsgxsflags.h>
#include <iostream> #include <iostream>
#include <sstream> #include <sstream>
@ -276,9 +277,7 @@ void PostedListDialog::periodChanged( int index )
void PostedListDialog::newGroup() void PostedListDialog::newGroup()
{ {
PostedGroupDialog cf (this); PostedGroupDialog cf (mPostedQueue, this);
cf.newGroup();
cf.exec (); cf.exec ();
} }
@ -289,38 +288,16 @@ void PostedListDialog::showGroupDetails()
return; return;
} }
PostedGroupDialog cf (this); PostedGroupDialog cf(mGroups[mCurrTopicId], this);
cf.existingGroup(mCurrTopicId, GXS_GROUP_DIALOG_SHOW_MODE);
cf.exec (); cf.exec ();
} }
void PostedListDialog::editGroupDetails() 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() void PostedListDialog::insertGroups()
{ {
requestGroupSummary(); requestGroupSummary();
@ -337,6 +314,23 @@ void PostedListDialog::requestGroupSummary()
mPostedQueue->requestGroupInfo(token, RS_TOKREQ_ANSTYPE_SUMMARY, opts, ids, POSTEDDIALOG_LISTING); 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) void PostedListDialog::loadGroupSummary(const uint32_t &token)
{ {
std::cerr << "PostedListDialog::loadGroupSummary()"; std::cerr << "PostedListDialog::loadGroupSummary()";
@ -557,24 +551,26 @@ void PostedListDialog::loadRequest(const TokenQueue *queue, const TokenRequest &
if (queue == mPostedQueue) if (queue == mPostedQueue)
{ {
/* now switch on req */ /* now switch on req */
switch(req.mUserType) switch(req.mType)
{ {
case POSTEDDIALOG_LISTING: case TOKENREQ_GROUPINFO:
loadGroupSummary(req.mToken); switch(req.mAnsType)
break; {
case POSTEDDIALOG_CURRENTFORUM: case RS_TOKREQ_ANSTYPE_ACK:
loadGroupSummary_CurrentForum(req.mToken); acknowledgeGroup(req.mToken);
break; break;
case RS_TOKREQ_ANSTYPE_SUMMARY:
case POSTEDDIALOG_INSERTTHREADS: loadGroupSummary(req.mToken);
loadGroupThreadData_InsertThreads(req.mToken); default:
break; std::cerr << "Error, unexpected anstype:" << req.mAnsType << std::endl;
break;
default: }
std::cerr << "PostedListDialog::loadRequest() ERROR: INVALID TYPE"; break;
std::cerr << std::endl; default:
break; std::cerr << "PostedListDialog::loadRequest() ERROR: INVALID TYPE";
std::cerr << std::endl;
break;
} }
} }
} }
@ -589,12 +585,72 @@ void PostedListDialog::loadRequest(const TokenQueue *queue, const TokenRequest &
void PostedListDialog::groupInfoToGroupItemInfo(const RsGroupMetaData &groupInfo, GroupItemInfo &groupItemInfo) 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) 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);
} }
/**************************************************************************************/ /**************************************************************************************/

View File

@ -38,6 +38,17 @@
#include "retroshare-gui/RsAutoUpdatePage.h" #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 class PostedListDialog : public RsAutoUpdatePage, public PostedHolder, public TokenResponse
{ {
Q_OBJECT Q_OBJECT
@ -75,6 +86,7 @@ void loadPost(const RsPostedPost &post);
void insertGroups(); void insertGroups();
void requestGroupSummary(); void requestGroupSummary();
void acknowledgeGroup(const uint32_t &token);
void loadGroupSummary(const uint32_t &token); void loadGroupSummary(const uint32_t &token);
void requestGroupSummary_CurrentForum(const std::string &forumId); void requestGroupSummary_CurrentForum(const std::string &forumId);
@ -103,6 +115,7 @@ void groupInfoToGroupItemInfo(const RsGroupMetaData &groupInfo, GroupItemInfo &
bool mThreadLoading; bool mThreadLoading;
std::string mCurrTopicId; std::string mCurrTopicId;
QMap<RsGxsGroupId, RsPostedGroup> mGroups;
TokenQueue *mPostedQueue; TokenQueue *mPostedQueue;
/* UI - from Designer */ /* UI - from Designer */

View File

@ -50,100 +50,83 @@
#define GXSGROUP_LOADGROUP 2 #define GXSGROUP_LOADGROUP 2
/** Constructor */ /** Constructor */
GxsGroupDialog::GxsGroupDialog(RsTokenService *service, QWidget *parent) GxsGroupDialog::GxsGroupDialog(TokenQueue* tokenQueue, QWidget *parent, uint32_t mode)
: QDialog(parent), mRsService(service) : QDialog(parent), mTokenQueue(tokenQueue), mMode(mode)
{ {
/* Invoke the Qt Designer generated object setup routine */ /* Invoke the Qt Designer generated object setup routine */
ui.setupUi(this); 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( ) ) );
connect( ui.pubKeyShare_cb, SIGNAL( clicked() ), this, SLOT( setShareList( ) ));
// connect up the buttons. connect( ui.groupLogo, SIGNAL(clicked() ), this , SLOT(addGroupLogo()));
connect( ui.cancelButton, SIGNAL( clicked ( bool ) ), this, SLOT( cancelDialog( ) ) ); connect( ui.addLogoButton, SIGNAL(clicked() ), this , SLOT(addGroupLogo()));
connect( ui.createButton, SIGNAL( clicked ( bool ) ), this, SLOT( submitGroup( ) ) );
connect( ui.pubKeyShare_cb, SIGNAL( clicked() ), this, SLOT( setShareList( ) ));
connect( ui.groupLogo, SIGNAL(clicked() ), this , SLOT(addGroupLogo())); if (!ui.pubKeyShare_cb->isChecked()) {
connect( ui.addLogoButton, SIGNAL(clicked() ), this , SLOT(addGroupLogo())); ui.contactsdockWidget->hide();
this->resize(this->size().width() - ui.contactsdockWidget->size().width(), this->size().height());
}
if (!ui.pubKeyShare_cb->isChecked()) { /* initialize key share list */
ui.contactsdockWidget->hide(); ui.keyShareList->setHeaderText(tr("Contacts:"));
this->resize(this->size().width() - ui.contactsdockWidget->size().width(), this->size().height()); ui.keyShareList->setModus(FriendSelectionWidget::MODUS_CHECK);
} ui.keyShareList->start();
/* initialize key share list */
ui.keyShareList->setHeaderText(tr("Contacts:"));
ui.keyShareList->setModus(FriendSelectionWidget::MODUS_CHECK);
ui.keyShareList->start();
/* Setup Reasonable Defaults */ /* Setup Reasonable Defaults */
uint32_t enabledFlags = ( GXS_GROUP_FLAGS_ICON | uint32_t enabledFlags = ( GXS_GROUP_FLAGS_ICON |
GXS_GROUP_FLAGS_DESCRIPTION | GXS_GROUP_FLAGS_DESCRIPTION |
GXS_GROUP_FLAGS_DISTRIBUTION | GXS_GROUP_FLAGS_DISTRIBUTION |
GXS_GROUP_FLAGS_PUBLISHSIGN | GXS_GROUP_FLAGS_PUBLISHSIGN |
GXS_GROUP_FLAGS_SHAREKEYS | GXS_GROUP_FLAGS_SHAREKEYS |
GXS_GROUP_FLAGS_PERSONALSIGN | GXS_GROUP_FLAGS_PERSONALSIGN |
GXS_GROUP_FLAGS_COMMENTS ); GXS_GROUP_FLAGS_COMMENTS );
uint32_t readonlyFlags = 0;
uint32_t defaultsFlags = ( GXS_GROUP_DEFAULTS_DISTRIB_PUBLIC | uint32_t defaultsFlags = ( GXS_GROUP_DEFAULTS_DISTRIB_PUBLIC |
//GXS_GROUP_DEFAULTS_DISTRIB_GROUP | GXS_GROUP_DEFAULTS_PUBLISH_THREADS |
//GXS_GROUP_DEFAULTS_DISTRIB_LOCAL | GXS_GROUP_DEFAULTS_PERSONAL_IFNOPUB |
GXS_GROUP_DEFAULTS_COMMENTS_YES |
//GXS_GROUP_DEFAULTS_PUBLISH_OPEN | 0);
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; mEnabledFlags = enabledFlags;
mReadonlyFlags = readonlyFlags; mDefaultsFlags = defaultsFlags;
mDefaultsFlags = defaultsFlags;
} }
void GxsGroupDialog::setMode(uint32_t mode) void GxsGroupDialog::setMode(uint32_t mode)
{ {
mMode = mode; switch(mMode)
{
case GXS_GROUP_DIALOG_CREATE_MODE:
{
ui.createButton->setText(tr("Create Group"));
newGroup();
}
break;
/* switch depending on mode */ default:
switch(mMode) case GXS_GROUP_DIALOG_SHOW_MODE:
{ {
case GXS_GROUP_DIALOG_CREATE_MODE: ui.cancelButton->setVisible(false);
{ ui.createButton->setText(tr("Close"));
ui.createButton->setText(tr("Create Group")); }
} break;
break;
default: // case GXS_GROUP_DIALOG_EDIT_MODE:
case GXS_GROUP_DIALOG_SHOW_MODE: // {
{ // ui.createButton->setText(tr("Submit Changes"));
ui.cancelButton->setVisible(false); // }
ui.createButton->setText(tr("Close")); // break;
} }
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.groupName->clear();
ui.groupDesc->clear(); ui.groupDesc->clear();
ui.groupName->setFocus(); ui.groupName->setFocus();
} }
@ -160,359 +142,270 @@ void GxsGroupDialog::setupDefaults()
{ {
/* Enable / Show Parts based on Flags */ /* Enable / Show Parts based on Flags */
if (mDefaultsFlags & GXS_GROUP_DEFAULTS_DISTRIB_MASK) if (mDefaultsFlags & GXS_GROUP_DEFAULTS_DISTRIB_MASK)
{ {
if (mDefaultsFlags & GXS_GROUP_DEFAULTS_DISTRIB_PUBLIC) if (mDefaultsFlags & GXS_GROUP_DEFAULTS_DISTRIB_PUBLIC)
{ {
ui.typePublic->setChecked(true); ui.typePublic->setChecked(true);
} }
else if (mDefaultsFlags & GXS_GROUP_DEFAULTS_DISTRIB_GROUP) else if (mDefaultsFlags & GXS_GROUP_DEFAULTS_DISTRIB_GROUP)
{ {
ui.typeGroup->setChecked(true); ui.typeGroup->setChecked(true);
} }
else if (mDefaultsFlags & GXS_GROUP_DEFAULTS_DISTRIB_LOCAL) else if (mDefaultsFlags & GXS_GROUP_DEFAULTS_DISTRIB_LOCAL)
{ {
ui.typeLocal->setChecked(true); ui.typeLocal->setChecked(true);
} }
else else
{ {
// default // default
ui.typePublic->setChecked(true); ui.typePublic->setChecked(true);
} }
} }
if (mDefaultsFlags & GXS_GROUP_DEFAULTS_PUBLISH_MASK) if (mDefaultsFlags & GXS_GROUP_DEFAULTS_PUBLISH_MASK)
{ {
if (mDefaultsFlags & GXS_GROUP_DEFAULTS_PUBLISH_ENCRYPTED) if (mDefaultsFlags & GXS_GROUP_DEFAULTS_PUBLISH_ENCRYPTED)
{ {
ui.publish_encrypt->setChecked(true); ui.publish_encrypt->setChecked(true);
} }
else if (mDefaultsFlags & GXS_GROUP_DEFAULTS_PUBLISH_REQUIRED) else if (mDefaultsFlags & GXS_GROUP_DEFAULTS_PUBLISH_REQUIRED)
{ {
ui.publish_required->setChecked(true); ui.publish_required->setChecked(true);
} }
else if (mDefaultsFlags & GXS_GROUP_DEFAULTS_PUBLISH_THREADS) else if (mDefaultsFlags & GXS_GROUP_DEFAULTS_PUBLISH_THREADS)
{ {
ui.publish_threads->setChecked(true); ui.publish_threads->setChecked(true);
} }
else else
{ {
// default // default
ui.publish_open->setChecked(true); ui.publish_open->setChecked(true);
} }
} }
if (mDefaultsFlags & GXS_GROUP_DEFAULTS_PERSONAL_MASK) if (mDefaultsFlags & GXS_GROUP_DEFAULTS_PERSONAL_MASK)
{ {
if (mDefaultsFlags & GXS_GROUP_DEFAULTS_PERSONAL_PGP) if (mDefaultsFlags & GXS_GROUP_DEFAULTS_PERSONAL_PGP)
{ {
ui.personal_pgp->setChecked(true); ui.personal_pgp->setChecked(true);
} }
else if (mDefaultsFlags & GXS_GROUP_DEFAULTS_PERSONAL_REQUIRED) else if (mDefaultsFlags & GXS_GROUP_DEFAULTS_PERSONAL_REQUIRED)
{ {
ui.personal_required->setChecked(true); ui.personal_required->setChecked(true);
} }
else if (mDefaultsFlags & GXS_GROUP_DEFAULTS_PERSONAL_IFNOPUB) else if (mDefaultsFlags & GXS_GROUP_DEFAULTS_PERSONAL_IFNOPUB)
{ {
ui.personal_ifnopub->setChecked(true); ui.personal_ifnopub->setChecked(true);
} }
else else
{ {
// default // default
ui.personal_ifnopub->setChecked(true); ui.personal_ifnopub->setChecked(true);
} }
} }
if (mDefaultsFlags & GXS_GROUP_DEFAULTS_COMMENTS_MASK) if (mDefaultsFlags & GXS_GROUP_DEFAULTS_COMMENTS_MASK)
{ {
if (mDefaultsFlags & GXS_GROUP_DEFAULTS_COMMENTS_YES) if (mDefaultsFlags & GXS_GROUP_DEFAULTS_COMMENTS_YES)
{ {
ui.comments_allowed->setChecked(true); ui.comments_allowed->setChecked(true);
} }
else if (mDefaultsFlags & GXS_GROUP_DEFAULTS_COMMENTS_NO) else if (mDefaultsFlags & GXS_GROUP_DEFAULTS_COMMENTS_NO)
{ {
ui.comments_no->setChecked(true); ui.comments_no->setChecked(true);
} }
else else
{ {
// default // default
ui.comments_no->setChecked(true); ui.comments_no->setChecked(true);
} }
}
}
} }
void GxsGroupDialog::setupVisibility() void GxsGroupDialog::setupVisibility()
{ {
{ {
ui.groupLogo->setVisible(mEnabledFlags & GXS_GROUP_FLAGS_ICON); ui.groupLogo->setVisible(mEnabledFlags & GXS_GROUP_FLAGS_ICON);
ui.addLogoButton->setVisible(mEnabledFlags & GXS_GROUP_FLAGS_ICON); ui.addLogoButton->setVisible(mEnabledFlags & GXS_GROUP_FLAGS_ICON);
} }
{ {
ui.groupDesc->setVisible(mEnabledFlags & GXS_GROUP_FLAGS_DESCRIPTION); ui.groupDesc->setVisible(mEnabledFlags & GXS_GROUP_FLAGS_DESCRIPTION);
ui.groupDescLabel->setVisible(mEnabledFlags & GXS_GROUP_FLAGS_DESCRIPTION); ui.groupDescLabel->setVisible(mEnabledFlags & GXS_GROUP_FLAGS_DESCRIPTION);
} }
{ {
ui.distribGroupBox->setVisible(mEnabledFlags & GXS_GROUP_FLAGS_DISTRIBUTION); ui.distribGroupBox->setVisible(mEnabledFlags & GXS_GROUP_FLAGS_DISTRIBUTION);
} }
{ {
ui.publishGroupBox->setVisible(mEnabledFlags & GXS_GROUP_FLAGS_PUBLISHSIGN); ui.publishGroupBox->setVisible(mEnabledFlags & GXS_GROUP_FLAGS_PUBLISHSIGN);
} }
{ {
ui.pubKeyShare_cb->setVisible(mEnabledFlags & GXS_GROUP_FLAGS_SHAREKEYS); ui.pubKeyShare_cb->setVisible(mEnabledFlags & GXS_GROUP_FLAGS_SHAREKEYS);
} }
{ {
ui.personalGroupBox->setVisible(mEnabledFlags & GXS_GROUP_FLAGS_PERSONALSIGN); ui.personalGroupBox->setVisible(mEnabledFlags & GXS_GROUP_FLAGS_PERSONALSIGN);
} }
{ {
ui.commentGroupBox->setVisible(mEnabledFlags & GXS_GROUP_FLAGS_COMMENTS); ui.commentGroupBox->setVisible(mEnabledFlags & GXS_GROUP_FLAGS_COMMENTS);
} }
{ {
ui.extraFrame->setVisible(mEnabledFlags & GXS_GROUP_FLAGS_EXTRA); ui.extraFrame->setVisible(mEnabledFlags & GXS_GROUP_FLAGS_EXTRA);
} }
} }
void GxsGroupDialog::newGroup() void GxsGroupDialog::newGroup()
{ {
setupDefaults(); setupDefaults();
setupVisibility(); setupVisibility();
clearForm(); clearForm();
setMode(GXS_GROUP_DIALOG_CREATE_MODE);
service_NewGroup();
} }
void GxsGroupDialog::existingGroup(std::string groupId, uint32_t mode) void GxsGroupDialog::loadExistingGroupMetaData(const RsGroupMetaData &meta)
{ {
setupDefaults(); /* should set stuff - according to parameters */
setupVisibility(); setGroupSignFlags(meta.mSignFlags);
clearForm(); ui.groupName->setText(QString::fromUtf8(meta.mGroupName.c_str()));
setMode(mode); return;
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)
{
/* 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;
} }
void GxsGroupDialog::submitGroup() void GxsGroupDialog::submitGroup()
{ {
std::cerr << "GxsGroupDialog::submitGroup()"; std::cerr << "GxsGroupDialog::submitGroup()";
std::cerr << std::endl; std::cerr << std::endl;
/* switch depending on mode */ /* switch depending on mode */
switch(mMode) switch(mMode)
{ {
case GXS_GROUP_DIALOG_CREATE_MODE: case GXS_GROUP_DIALOG_CREATE_MODE:
{ {
/* just close if down */ /* just close if down */
createGroup(); createGroup();
} }
break; break;
default: default:
case GXS_GROUP_DIALOG_SHOW_MODE: case GXS_GROUP_DIALOG_SHOW_MODE:
{ {
/* just close if down */ /* just close if down */
cancelDialog(); cancelDialog();
} }
break; break;
case GXS_GROUP_DIALOG_EDIT_MODE: case GXS_GROUP_DIALOG_EDIT_MODE:
{ {
/* TEMP: just close if down */ /* TEMP: just close if down */
cancelDialog(); cancelDialog();
} }
break; break;
} }
} }
void GxsGroupDialog::createGroup() void GxsGroupDialog::createGroup()
{ {
QString name = misc::removeNewLine(ui.groupName->text()); QString name = misc::removeNewLine(ui.groupName->text());
QString desc = ui.groupDesc->toPlainText(); //toHtml(); uint32_t flags = 0;
uint32_t flags = 0;
if(name.isEmpty()) if(name.isEmpty())
{ {
/* error message */ /* error message */
QMessageBox::warning(this, "RetroShare", tr("Please add a Name"), QMessageBox::Ok, QMessageBox::Ok); QMessageBox::warning(this, "RetroShare", tr("Please add a Name"), QMessageBox::Ok, QMessageBox::Ok);
return; //Don't add a empty name!! return; //Don't add a empty name!!
} }
if (mRsService) uint32_t token;
{ RsGroupMetaData meta;
uint32_t token; // Fill in the MetaData as best we can.
RsGroupMetaData meta; meta.mGroupName = std::string(name.toUtf8());
// Fill in the MetaData as best we can. meta.mGroupFlags = flags;
meta.mGroupName = std::string(name.toUtf8()); meta.mSignFlags = getGroupSignFlags();
//meta.mDesc = std::string(desc.toUtf8());
meta.mGroupFlags = flags; if (service_CreateGroup(token, meta))
meta.mSignFlags = getGroupSignFlags(); {
// get the Queue to handle response.
// These ones shouldn't be needed here - but will be used, until we have fully functional backend. if(mTokenQueue != NULL)
meta.mSubscribeFlags = GXS_SERV::GROUP_SUBSCRIBE_ADMIN; mTokenQueue->queueRequest(token, TOKENREQ_GROUPINFO, RS_TOKREQ_ANSTYPE_ACK, GXSGROUP_NEWGROUPID);
meta.mPublishTs = time(NULL); }
close();
if (service_CreateGroup(token, meta))
{
// get the Queue to handle response.
mTokenQueue->queueRequest(token, TOKENREQ_MSGINFO, RS_TOKREQ_ANSTYPE_SUMMARY, GXSGROUP_NEWGROUPID);
}
}
} }
uint32_t GxsGroupDialog::getGroupSignFlags() uint32_t GxsGroupDialog::getGroupSignFlags()
{ {
/* grab from the ui options -> */ /* grab from the ui options -> */
uint32_t signFlags = 0; uint32_t signFlags = 0;
if (ui.publish_encrypt->isChecked()) { if (ui.publish_encrypt->isChecked()) {
signFlags |= RSGXS_GROUP_SIGN_PUBLISH_ENCRYPTED; signFlags |= RSGXS_GROUP_SIGN_PUBLISH_ENCRYPTED;
} else if (ui.publish_required->isChecked()) { } else if (ui.publish_required->isChecked()) {
signFlags |= RSGXS_GROUP_SIGN_PUBLISH_ALLSIGNED; signFlags |= RSGXS_GROUP_SIGN_PUBLISH_ALLSIGNED;
} else if (ui.publish_threads->isChecked()) { } else if (ui.publish_threads->isChecked()) {
signFlags |= RSGXS_GROUP_SIGN_PUBLISH_THREADHEAD; signFlags |= RSGXS_GROUP_SIGN_PUBLISH_THREADHEAD;
} else { // publish_open (default). } else { // publish_open (default).
signFlags |= RSGXS_GROUP_SIGN_PUBLISH_NONEREQ; signFlags |= RSGXS_GROUP_SIGN_PUBLISH_NONEREQ;
} }
// Author Signature. // Author Signature.
if (ui.personal_pgp->isChecked()) { if (ui.personal_pgp->isChecked()) {
signFlags |= RSGXS_GROUP_SIGN_AUTHOR_GPG; signFlags |= RSGXS_GROUP_SIGN_AUTHOR_GPG;
} else if (ui.personal_required->isChecked()) { } else if (ui.personal_required->isChecked()) {
signFlags |= RSGXS_GROUP_SIGN_AUTHOR_REQUIRED; signFlags |= RSGXS_GROUP_SIGN_AUTHOR_REQUIRED;
} else if (ui.personal_ifnopub->isChecked()) { } else if (ui.personal_ifnopub->isChecked()) {
signFlags |= RSGXS_GROUP_SIGN_AUTHOR_IFNOPUBSIGN; signFlags |= RSGXS_GROUP_SIGN_AUTHOR_IFNOPUBSIGN;
} else { // shouldn't allow this one. } else { // shouldn't allow this one.
signFlags |= RSGXS_GROUP_SIGN_AUTHOR_NONE; signFlags |= RSGXS_GROUP_SIGN_AUTHOR_NONE;
} }
return signFlags; return signFlags;
} }
void GxsGroupDialog::setGroupSignFlags(uint32_t signFlags) void GxsGroupDialog::setGroupSignFlags(uint32_t signFlags)
{ {
if (signFlags & RSGXS_GROUP_SIGN_PUBLISH_ENCRYPTED) { if (signFlags & RSGXS_GROUP_SIGN_PUBLISH_ENCRYPTED) {
ui.publish_encrypt->setChecked(true); ui.publish_encrypt->setChecked(true);
} else if (signFlags & RSGXS_GROUP_SIGN_PUBLISH_ALLSIGNED) { } else if (signFlags & RSGXS_GROUP_SIGN_PUBLISH_ALLSIGNED) {
ui.publish_required->setChecked(true); ui.publish_required->setChecked(true);
} else if (signFlags & RSGXS_GROUP_SIGN_PUBLISH_THREADHEAD) { } else if (signFlags & RSGXS_GROUP_SIGN_PUBLISH_THREADHEAD) {
ui.publish_threads->setChecked(true); ui.publish_threads->setChecked(true);
} else if (signFlags & RSGXS_GROUP_SIGN_PUBLISH_NONEREQ) { } else if (signFlags & RSGXS_GROUP_SIGN_PUBLISH_NONEREQ) {
ui.publish_open->setChecked(true); ui.publish_open->setChecked(true);
} }
if (signFlags & RSGXS_GROUP_SIGN_AUTHOR_GPG) {
ui.personal_pgp->setChecked(true);
} else if (signFlags & RSGXS_GROUP_SIGN_AUTHOR_REQUIRED) {
ui.personal_required->setChecked(true);
} else if (signFlags & RSGXS_GROUP_SIGN_AUTHOR_IFNOPUBSIGN) {
ui.personal_ifnopub->setChecked(true);
} else if (signFlags & RSGXS_GROUP_SIGN_AUTHOR_NONE) {
// Its the same... but not quite.
//ui.personal_noifpub->setChecked();
}
/* guess at comments */
if ((signFlags & RSGXS_GROUP_SIGN_PUBLISH_THREADHEAD)
&& (signFlags & RSGXS_GROUP_SIGN_AUTHOR_IFNOPUBSIGN))
{
ui.comments_allowed->setChecked(true);
}
else
{
ui.comments_no->setChecked(true);
}
if (signFlags & RSGXS_GROUP_SIGN_AUTHOR_GPG) {
ui.personal_pgp->setChecked(true);
} else if (signFlags & RSGXS_GROUP_SIGN_AUTHOR_REQUIRED) {
ui.personal_required->setChecked(true);
} else if (signFlags & RSGXS_GROUP_SIGN_AUTHOR_IFNOPUBSIGN) {
ui.personal_ifnopub->setChecked(true);
} else if (signFlags & RSGXS_GROUP_SIGN_AUTHOR_NONE) {
// Its the same... but not quite.
//ui.personal_noifpub->setChecked();
}
/* guess at comments */
if ((signFlags & RSGXS_GROUP_SIGN_PUBLISH_THREADHEAD)
&& (signFlags & RSGXS_GROUP_SIGN_AUTHOR_IFNOPUBSIGN))
{
ui.comments_allowed->setChecked(true);
}
else
{
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() void GxsGroupDialog::cancelDialog()
{ {
std::cerr << "GxsGroupDialog::cancelDialog() Should Close!"; std::cerr << "GxsGroupDialog::cancelDialog() Should Close!";
@ -543,98 +436,17 @@ void GxsGroupDialog::addGroupLogo()
void GxsGroupDialog::sendShareList(std::string groupId) void GxsGroupDialog::sendShareList(std::string groupId)
{ {
close(); close();
} }
void GxsGroupDialog::setShareList() void GxsGroupDialog::setShareList()
{ {
if (ui.pubKeyShare_cb->isChecked()){ if (ui.pubKeyShare_cb->isChecked()){
this->resize(this->size().width() + ui.contactsdockWidget->size().width(), this->size().height()); this->resize(this->size().width() + ui.contactsdockWidget->size().width(), this->size().height());
ui.contactsdockWidget->show(); ui.contactsdockWidget->show();
} else { // hide share widget } else { // hide share widget
ui.contactsdockWidget->hide(); ui.contactsdockWidget->hide();
this->resize(this->size().width() - ui.contactsdockWidget->size().width(), this->size().height()); this->resize(this->size().width() - ui.contactsdockWidget->size().width(), this->size().height());
} }
} }
/***********************************************************************************
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;
}
}

View File

@ -90,47 +90,91 @@ public:
#define GXS_GROUP_DIALOG_SHOW_MODE 2 #define GXS_GROUP_DIALOG_SHOW_MODE 2
#define GXS_GROUP_DIALOG_EDIT_MODE 3 #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 Q_OBJECT
public: 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 */ /*!
void newGroup(); *
void existingGroup(std::string groupId, uint32_t 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);
// Callback for all Loads. private:
virtual void loadRequest(const TokenQueue *queue, const TokenRequest &req); void newGroup();
void setMode(uint32_t mode);
// Functions that can be overloaded for specific stuff.
// Functions that can be overloaded for specific stuff.
protected slots: protected slots:
void submitGroup(); void submitGroup();
void addGroupLogo(); void addGroupLogo();
protected: 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(); * This should return a group logo \n
virtual bool service_CreateGroup(uint32_t &token, const RsGroupMetaData &meta); * Will be called when GxsGroupDialog is initialised in show mode
virtual bool service_CompleteCreateGroup(const RsGroupMetaData &meta); *
*/
virtual QPixmap service_getLogo() = 0;
// Group Edit / Display. /*!
virtual bool service_ExistingGroup(); // Initial Setup. * This should return a group description string
virtual void service_loadExistingGroup(const uint32_t &token); * @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: private slots:
/* actions to take.... */ /* actions to take.... */
void cancelDialog(); void cancelDialog();
@ -141,29 +185,19 @@ private:
void setGroupSignFlags(uint32_t signFlags); void setGroupSignFlags(uint32_t signFlags);
uint32_t getGroupSignFlags(); uint32_t getGroupSignFlags();
void setupDefaults(); void setupDefaults();
void setupVisibility(); void setupVisibility();
void clearForm(); void clearForm();
void createGroup(); void createGroup();
virtual void completeCreateGroup(const RsGroupMetaData &newForumMeta);
void sendShareList(std::string forumId); void sendShareList(std::string forumId);
void loadNewGroupId(const uint32_t &token); void loadNewGroupId(const uint32_t &token);
std::list<std::string> mShareList; std::list<std::string> mShareList;
QPixmap picture; QPixmap picture;
RsTokenService *mRsService;
TokenQueue *mTokenQueue; TokenQueue *mTokenQueue;
uint32_t mMode; uint32_t mMode;
uint32_t mEnabledFlags; uint32_t mEnabledFlags;
uint32_t mReadonlyFlags; uint32_t mReadonlyFlags;
uint32_t mDefaultsFlags; uint32_t mDefaultsFlags;