mirror of
https://github.com/RetroShare/RetroShare.git
synced 2024-12-25 23:49: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 |
|
||||
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 |
|
||||
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, 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,24 +551,26 @@ void PostedListDialog::loadRequest(const TokenQueue *queue, const TokenRequest &
|
||||
if (queue == mPostedQueue)
|
||||
{
|
||||
/* now switch on req */
|
||||
switch(req.mUserType)
|
||||
switch(req.mType)
|
||||
{
|
||||
case POSTEDDIALOG_LISTING:
|
||||
loadGroupSummary(req.mToken);
|
||||
break;
|
||||
case TOKENREQ_GROUPINFO:
|
||||
switch(req.mAnsType)
|
||||
{
|
||||
|
||||
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;
|
||||
break;
|
||||
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;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
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)
|
||||
{
|
||||
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,100 +50,83 @@
|
||||
#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);
|
||||
/* 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( ) ) );
|
||||
connect( ui.pubKeyShare_cb, SIGNAL( clicked() ), this, SLOT( setShareList( ) ));
|
||||
|
||||
// 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( ui.groupLogo, SIGNAL(clicked() ), this , SLOT(addGroupLogo()));
|
||||
connect( ui.addLogoButton, SIGNAL(clicked() ), this , SLOT(addGroupLogo()));
|
||||
|
||||
connect( ui.groupLogo, SIGNAL(clicked() ), this , SLOT(addGroupLogo()));
|
||||
connect( ui.addLogoButton, SIGNAL(clicked() ), this , SLOT(addGroupLogo()));
|
||||
if (!ui.pubKeyShare_cb->isChecked()) {
|
||||
ui.contactsdockWidget->hide();
|
||||
this->resize(this->size().width() - ui.contactsdockWidget->size().width(), this->size().height());
|
||||
}
|
||||
|
||||
if (!ui.pubKeyShare_cb->isChecked()) {
|
||||
ui.contactsdockWidget->hide();
|
||||
this->resize(this->size().width() - ui.contactsdockWidget->size().width(), this->size().height());
|
||||
}
|
||||
|
||||
/* initialize key share list */
|
||||
ui.keyShareList->setHeaderText(tr("Contacts:"));
|
||||
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 |
|
||||
GXS_GROUP_FLAGS_DESCRIPTION |
|
||||
GXS_GROUP_FLAGS_DISTRIBUTION |
|
||||
GXS_GROUP_FLAGS_PUBLISHSIGN |
|
||||
GXS_GROUP_FLAGS_SHAREKEYS |
|
||||
GXS_GROUP_FLAGS_PERSONALSIGN |
|
||||
GXS_GROUP_FLAGS_COMMENTS );
|
||||
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 );
|
||||
|
||||
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);
|
||||
uint32_t defaultsFlags = ( GXS_GROUP_DEFAULTS_DISTRIB_PUBLIC |
|
||||
GXS_GROUP_DEFAULTS_PUBLISH_THREADS |
|
||||
GXS_GROUP_DEFAULTS_PERSONAL_IFNOPUB |
|
||||
GXS_GROUP_DEFAULTS_COMMENTS_YES |
|
||||
0);
|
||||
|
||||
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;
|
||||
mEnabledFlags = enabledFlags;
|
||||
mDefaultsFlags = defaultsFlags;
|
||||
}
|
||||
|
||||
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 */
|
||||
switch(mMode)
|
||||
{
|
||||
case GXS_GROUP_DIALOG_CREATE_MODE:
|
||||
{
|
||||
ui.createButton->setText(tr("Create Group"));
|
||||
}
|
||||
break;
|
||||
default:
|
||||
case GXS_GROUP_DIALOG_SHOW_MODE:
|
||||
{
|
||||
ui.cancelButton->setVisible(false);
|
||||
ui.createButton->setText(tr("Close"));
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
case GXS_GROUP_DIALOG_SHOW_MODE:
|
||||
{
|
||||
ui.cancelButton->setVisible(false);
|
||||
ui.createButton->setText(tr("Close"));
|
||||
}
|
||||
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();
|
||||
}
|
||||
|
||||
@ -160,359 +142,270 @@ void GxsGroupDialog::setupDefaults()
|
||||
{
|
||||
/* Enable / Show Parts based on Flags */
|
||||
|
||||
if (mDefaultsFlags & GXS_GROUP_DEFAULTS_DISTRIB_MASK)
|
||||
{
|
||||
if (mDefaultsFlags & GXS_GROUP_DEFAULTS_DISTRIB_PUBLIC)
|
||||
{
|
||||
ui.typePublic->setChecked(true);
|
||||
}
|
||||
else if (mDefaultsFlags & GXS_GROUP_DEFAULTS_DISTRIB_GROUP)
|
||||
{
|
||||
ui.typeGroup->setChecked(true);
|
||||
}
|
||||
else if (mDefaultsFlags & GXS_GROUP_DEFAULTS_DISTRIB_LOCAL)
|
||||
{
|
||||
ui.typeLocal->setChecked(true);
|
||||
}
|
||||
else
|
||||
{
|
||||
// default
|
||||
ui.typePublic->setChecked(true);
|
||||
}
|
||||
}
|
||||
if (mDefaultsFlags & GXS_GROUP_DEFAULTS_DISTRIB_MASK)
|
||||
{
|
||||
if (mDefaultsFlags & GXS_GROUP_DEFAULTS_DISTRIB_PUBLIC)
|
||||
{
|
||||
ui.typePublic->setChecked(true);
|
||||
}
|
||||
else if (mDefaultsFlags & GXS_GROUP_DEFAULTS_DISTRIB_GROUP)
|
||||
{
|
||||
ui.typeGroup->setChecked(true);
|
||||
}
|
||||
else if (mDefaultsFlags & GXS_GROUP_DEFAULTS_DISTRIB_LOCAL)
|
||||
{
|
||||
ui.typeLocal->setChecked(true);
|
||||
}
|
||||
else
|
||||
{
|
||||
// default
|
||||
ui.typePublic->setChecked(true);
|
||||
}
|
||||
}
|
||||
|
||||
if (mDefaultsFlags & GXS_GROUP_DEFAULTS_PUBLISH_MASK)
|
||||
{
|
||||
if (mDefaultsFlags & GXS_GROUP_DEFAULTS_PUBLISH_ENCRYPTED)
|
||||
{
|
||||
ui.publish_encrypt->setChecked(true);
|
||||
}
|
||||
else if (mDefaultsFlags & GXS_GROUP_DEFAULTS_PUBLISH_REQUIRED)
|
||||
{
|
||||
ui.publish_required->setChecked(true);
|
||||
}
|
||||
else if (mDefaultsFlags & GXS_GROUP_DEFAULTS_PUBLISH_THREADS)
|
||||
{
|
||||
ui.publish_threads->setChecked(true);
|
||||
}
|
||||
else
|
||||
{
|
||||
// default
|
||||
ui.publish_open->setChecked(true);
|
||||
}
|
||||
}
|
||||
if (mDefaultsFlags & GXS_GROUP_DEFAULTS_PUBLISH_MASK)
|
||||
{
|
||||
if (mDefaultsFlags & GXS_GROUP_DEFAULTS_PUBLISH_ENCRYPTED)
|
||||
{
|
||||
ui.publish_encrypt->setChecked(true);
|
||||
}
|
||||
else if (mDefaultsFlags & GXS_GROUP_DEFAULTS_PUBLISH_REQUIRED)
|
||||
{
|
||||
ui.publish_required->setChecked(true);
|
||||
}
|
||||
else if (mDefaultsFlags & GXS_GROUP_DEFAULTS_PUBLISH_THREADS)
|
||||
{
|
||||
ui.publish_threads->setChecked(true);
|
||||
}
|
||||
else
|
||||
{
|
||||
// default
|
||||
ui.publish_open->setChecked(true);
|
||||
}
|
||||
}
|
||||
|
||||
if (mDefaultsFlags & GXS_GROUP_DEFAULTS_PERSONAL_MASK)
|
||||
{
|
||||
if (mDefaultsFlags & GXS_GROUP_DEFAULTS_PERSONAL_PGP)
|
||||
{
|
||||
ui.personal_pgp->setChecked(true);
|
||||
}
|
||||
else if (mDefaultsFlags & GXS_GROUP_DEFAULTS_PERSONAL_REQUIRED)
|
||||
{
|
||||
ui.personal_required->setChecked(true);
|
||||
}
|
||||
else if (mDefaultsFlags & GXS_GROUP_DEFAULTS_PERSONAL_IFNOPUB)
|
||||
{
|
||||
ui.personal_ifnopub->setChecked(true);
|
||||
}
|
||||
else
|
||||
{
|
||||
// default
|
||||
ui.personal_ifnopub->setChecked(true);
|
||||
}
|
||||
}
|
||||
if (mDefaultsFlags & GXS_GROUP_DEFAULTS_PERSONAL_MASK)
|
||||
{
|
||||
if (mDefaultsFlags & GXS_GROUP_DEFAULTS_PERSONAL_PGP)
|
||||
{
|
||||
ui.personal_pgp->setChecked(true);
|
||||
}
|
||||
else if (mDefaultsFlags & GXS_GROUP_DEFAULTS_PERSONAL_REQUIRED)
|
||||
{
|
||||
ui.personal_required->setChecked(true);
|
||||
}
|
||||
else if (mDefaultsFlags & GXS_GROUP_DEFAULTS_PERSONAL_IFNOPUB)
|
||||
{
|
||||
ui.personal_ifnopub->setChecked(true);
|
||||
}
|
||||
else
|
||||
{
|
||||
// default
|
||||
ui.personal_ifnopub->setChecked(true);
|
||||
}
|
||||
}
|
||||
|
||||
if (mDefaultsFlags & GXS_GROUP_DEFAULTS_COMMENTS_MASK)
|
||||
{
|
||||
if (mDefaultsFlags & GXS_GROUP_DEFAULTS_COMMENTS_YES)
|
||||
{
|
||||
ui.comments_allowed->setChecked(true);
|
||||
}
|
||||
else if (mDefaultsFlags & GXS_GROUP_DEFAULTS_COMMENTS_NO)
|
||||
{
|
||||
ui.comments_no->setChecked(true);
|
||||
}
|
||||
else
|
||||
{
|
||||
// default
|
||||
ui.comments_no->setChecked(true);
|
||||
}
|
||||
|
||||
}
|
||||
if (mDefaultsFlags & GXS_GROUP_DEFAULTS_COMMENTS_MASK)
|
||||
{
|
||||
if (mDefaultsFlags & GXS_GROUP_DEFAULTS_COMMENTS_YES)
|
||||
{
|
||||
ui.comments_allowed->setChecked(true);
|
||||
}
|
||||
else if (mDefaultsFlags & GXS_GROUP_DEFAULTS_COMMENTS_NO)
|
||||
{
|
||||
ui.comments_no->setChecked(true);
|
||||
}
|
||||
else
|
||||
{
|
||||
// default
|
||||
ui.comments_no->setChecked(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void GxsGroupDialog::setupVisibility()
|
||||
{
|
||||
{
|
||||
ui.groupLogo->setVisible(mEnabledFlags & GXS_GROUP_FLAGS_ICON);
|
||||
ui.addLogoButton->setVisible(mEnabledFlags & GXS_GROUP_FLAGS_ICON);
|
||||
}
|
||||
{
|
||||
ui.groupLogo->setVisible(mEnabledFlags & GXS_GROUP_FLAGS_ICON);
|
||||
ui.addLogoButton->setVisible(mEnabledFlags & GXS_GROUP_FLAGS_ICON);
|
||||
}
|
||||
|
||||
{
|
||||
ui.groupDesc->setVisible(mEnabledFlags & GXS_GROUP_FLAGS_DESCRIPTION);
|
||||
ui.groupDescLabel->setVisible(mEnabledFlags & GXS_GROUP_FLAGS_DESCRIPTION);
|
||||
}
|
||||
{
|
||||
ui.groupDesc->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()
|
||||
{
|
||||
setupDefaults();
|
||||
setupVisibility();
|
||||
clearForm();
|
||||
setupDefaults();
|
||||
setupVisibility();
|
||||
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();
|
||||
setupVisibility();
|
||||
clearForm();
|
||||
/* should set stuff - according to parameters */
|
||||
setGroupSignFlags(meta.mSignFlags);
|
||||
ui.groupName->setText(QString::fromUtf8(meta.mGroupName.c_str()));
|
||||
|
||||
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)
|
||||
{
|
||||
/* 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;
|
||||
}
|
||||
|
||||
|
||||
void GxsGroupDialog::submitGroup()
|
||||
{
|
||||
std::cerr << "GxsGroupDialog::submitGroup()";
|
||||
std::cerr << std::endl;
|
||||
std::cerr << "GxsGroupDialog::submitGroup()";
|
||||
std::cerr << std::endl;
|
||||
|
||||
/* switch depending on mode */
|
||||
switch(mMode)
|
||||
{
|
||||
case GXS_GROUP_DIALOG_CREATE_MODE:
|
||||
{
|
||||
/* just close if down */
|
||||
createGroup();
|
||||
}
|
||||
break;
|
||||
/* switch depending on mode */
|
||||
switch(mMode)
|
||||
{
|
||||
case GXS_GROUP_DIALOG_CREATE_MODE:
|
||||
{
|
||||
/* just close if down */
|
||||
createGroup();
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
case GXS_GROUP_DIALOG_SHOW_MODE:
|
||||
{
|
||||
/* just close if down */
|
||||
cancelDialog();
|
||||
}
|
||||
break;
|
||||
default:
|
||||
case GXS_GROUP_DIALOG_SHOW_MODE:
|
||||
{
|
||||
/* just close if down */
|
||||
cancelDialog();
|
||||
}
|
||||
break;
|
||||
|
||||
case GXS_GROUP_DIALOG_EDIT_MODE:
|
||||
{
|
||||
/* TEMP: just close if down */
|
||||
cancelDialog();
|
||||
}
|
||||
break;
|
||||
}
|
||||
case GXS_GROUP_DIALOG_EDIT_MODE:
|
||||
{
|
||||
/* TEMP: just close if down */
|
||||
cancelDialog();
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
void GxsGroupDialog::createGroup()
|
||||
{
|
||||
QString name = misc::removeNewLine(ui.groupName->text());
|
||||
QString desc = ui.groupDesc->toPlainText(); //toHtml();
|
||||
uint32_t flags = 0;
|
||||
QString name = misc::removeNewLine(ui.groupName->text());
|
||||
uint32_t flags = 0;
|
||||
|
||||
if(name.isEmpty())
|
||||
{
|
||||
/* error message */
|
||||
QMessageBox::warning(this, "RetroShare", tr("Please add a Name"), QMessageBox::Ok, QMessageBox::Ok);
|
||||
return; //Don't add a empty name!!
|
||||
}
|
||||
if(name.isEmpty())
|
||||
{
|
||||
/* error message */
|
||||
QMessageBox::warning(this, "RetroShare", tr("Please add a Name"), QMessageBox::Ok, QMessageBox::Ok);
|
||||
return; //Don't add a empty name!!
|
||||
}
|
||||
|
||||
if (mRsService)
|
||||
{
|
||||
|
||||
uint32_t token;
|
||||
RsGroupMetaData meta;
|
||||
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());
|
||||
// Fill in the MetaData as best we can.
|
||||
meta.mGroupName = std::string(name.toUtf8());
|
||||
|
||||
meta.mGroupFlags = flags;
|
||||
meta.mSignFlags = getGroupSignFlags();
|
||||
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 (service_CreateGroup(token, meta))
|
||||
{
|
||||
// get the Queue to handle response.
|
||||
if(mTokenQueue != NULL)
|
||||
mTokenQueue->queueRequest(token, TOKENREQ_GROUPINFO, RS_TOKREQ_ANSTYPE_ACK, GXSGROUP_NEWGROUPID);
|
||||
}
|
||||
close();
|
||||
}
|
||||
|
||||
uint32_t GxsGroupDialog::getGroupSignFlags()
|
||||
{
|
||||
/* grab from the ui options -> */
|
||||
uint32_t signFlags = 0;
|
||||
if (ui.publish_encrypt->isChecked()) {
|
||||
signFlags |= RSGXS_GROUP_SIGN_PUBLISH_ENCRYPTED;
|
||||
} else if (ui.publish_required->isChecked()) {
|
||||
signFlags |= RSGXS_GROUP_SIGN_PUBLISH_ALLSIGNED;
|
||||
} else if (ui.publish_threads->isChecked()) {
|
||||
signFlags |= RSGXS_GROUP_SIGN_PUBLISH_THREADHEAD;
|
||||
} else { // publish_open (default).
|
||||
signFlags |= RSGXS_GROUP_SIGN_PUBLISH_NONEREQ;
|
||||
}
|
||||
/* grab from the ui options -> */
|
||||
uint32_t signFlags = 0;
|
||||
if (ui.publish_encrypt->isChecked()) {
|
||||
signFlags |= RSGXS_GROUP_SIGN_PUBLISH_ENCRYPTED;
|
||||
} else if (ui.publish_required->isChecked()) {
|
||||
signFlags |= RSGXS_GROUP_SIGN_PUBLISH_ALLSIGNED;
|
||||
} else if (ui.publish_threads->isChecked()) {
|
||||
signFlags |= RSGXS_GROUP_SIGN_PUBLISH_THREADHEAD;
|
||||
} else { // publish_open (default).
|
||||
signFlags |= RSGXS_GROUP_SIGN_PUBLISH_NONEREQ;
|
||||
}
|
||||
|
||||
// Author Signature.
|
||||
if (ui.personal_pgp->isChecked()) {
|
||||
signFlags |= RSGXS_GROUP_SIGN_AUTHOR_GPG;
|
||||
} else if (ui.personal_required->isChecked()) {
|
||||
signFlags |= RSGXS_GROUP_SIGN_AUTHOR_REQUIRED;
|
||||
} else if (ui.personal_ifnopub->isChecked()) {
|
||||
signFlags |= RSGXS_GROUP_SIGN_AUTHOR_IFNOPUBSIGN;
|
||||
} else { // shouldn't allow this one.
|
||||
signFlags |= RSGXS_GROUP_SIGN_AUTHOR_NONE;
|
||||
}
|
||||
return signFlags;
|
||||
if (ui.personal_pgp->isChecked()) {
|
||||
signFlags |= RSGXS_GROUP_SIGN_AUTHOR_GPG;
|
||||
} else if (ui.personal_required->isChecked()) {
|
||||
signFlags |= RSGXS_GROUP_SIGN_AUTHOR_REQUIRED;
|
||||
} else if (ui.personal_ifnopub->isChecked()) {
|
||||
signFlags |= RSGXS_GROUP_SIGN_AUTHOR_IFNOPUBSIGN;
|
||||
} else { // shouldn't allow this one.
|
||||
signFlags |= RSGXS_GROUP_SIGN_AUTHOR_NONE;
|
||||
}
|
||||
return signFlags;
|
||||
}
|
||||
|
||||
void GxsGroupDialog::setGroupSignFlags(uint32_t signFlags)
|
||||
{
|
||||
|
||||
if (signFlags & RSGXS_GROUP_SIGN_PUBLISH_ENCRYPTED) {
|
||||
ui.publish_encrypt->setChecked(true);
|
||||
} else if (signFlags & RSGXS_GROUP_SIGN_PUBLISH_ALLSIGNED) {
|
||||
ui.publish_required->setChecked(true);
|
||||
} else if (signFlags & RSGXS_GROUP_SIGN_PUBLISH_THREADHEAD) {
|
||||
ui.publish_threads->setChecked(true);
|
||||
} else if (signFlags & RSGXS_GROUP_SIGN_PUBLISH_NONEREQ) {
|
||||
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_PUBLISH_ENCRYPTED) {
|
||||
ui.publish_encrypt->setChecked(true);
|
||||
} else if (signFlags & RSGXS_GROUP_SIGN_PUBLISH_ALLSIGNED) {
|
||||
ui.publish_required->setChecked(true);
|
||||
} else if (signFlags & RSGXS_GROUP_SIGN_PUBLISH_THREADHEAD) {
|
||||
ui.publish_threads->setChecked(true);
|
||||
} else if (signFlags & RSGXS_GROUP_SIGN_PUBLISH_NONEREQ) {
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
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,98 +436,17 @@ void GxsGroupDialog::addGroupLogo()
|
||||
|
||||
void GxsGroupDialog::sendShareList(std::string groupId)
|
||||
{
|
||||
|
||||
close();
|
||||
}
|
||||
|
||||
void GxsGroupDialog::setShareList()
|
||||
{
|
||||
if (ui.pubKeyShare_cb->isChecked()){
|
||||
this->resize(this->size().width() + ui.contactsdockWidget->size().width(), this->size().height());
|
||||
ui.contactsdockWidget->show();
|
||||
} else { // hide share widget
|
||||
ui.contactsdockWidget->hide();
|
||||
this->resize(this->size().width() - ui.contactsdockWidget->size().width(), this->size().height());
|
||||
}
|
||||
if (ui.pubKeyShare_cb->isChecked()){
|
||||
this->resize(this->size().width() + ui.contactsdockWidget->size().width(), this->size().height());
|
||||
ui.contactsdockWidget->show();
|
||||
} else { // hide share widget
|
||||
ui.contactsdockWidget->hide();
|
||||
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;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
@ -90,47 +90,91 @@ 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 */
|
||||
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.
|
||||
virtual void loadRequest(const TokenQueue *queue, const TokenRequest &req);
|
||||
private:
|
||||
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:
|
||||
void submitGroup();
|
||||
void addGroupLogo();
|
||||
void submitGroup();
|
||||
void addGroupLogo();
|
||||
|
||||
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