diff --git a/retroshare-gui/src/RetroShare.pro b/retroshare-gui/src/RetroShare.pro index 02b8ff94d..1ac440f12 100644 --- a/retroshare-gui/src/RetroShare.pro +++ b/retroshare-gui/src/RetroShare.pro @@ -4,11 +4,11 @@ CONFIG += qt gui uic qrc resources uitools idle bitdht CONFIG += photoshare CONFIG += wikipoos CONFIG += identities +CONFIG += circles CONFIG += gxsforums CONFIG += posted CONFIG += unfinished CONFIG += gxsgui -#CONFIG += circles #CONFIG += thewire #CONFIG += pluginmgr @@ -1037,6 +1037,8 @@ gxsgui { gui/gxs/GxsForumGroupDialog.h \ gui/gxs/GxsIdChooser.h \ gui/gxs/GxsIdLabel.h \ + gui/gxs/GxsCircleChooser.h \ + gui/gxs/GxsCircleLabel.h \ gui/gxs/GxsIdTreeWidgetItem.h \ # gui/gxs/GxsMsgDialog.h \ @@ -1052,6 +1054,8 @@ gxsgui { gui/gxs/GxsForumGroupDialog.cpp \ gui/gxs/GxsIdChooser.cpp \ gui/gxs/GxsIdLabel.cpp \ + gui/gxs/GxsCircleChooser.cpp \ + gui/gxs/GxsCircleLabel.cpp \ gui/gxs/GxsIdTreeWidgetItem.cpp \ # gui/gxs/GxsMsgDialog.cpp \ diff --git a/retroshare-gui/src/gui/Circles/CirclesDialog.cpp b/retroshare-gui/src/gui/Circles/CirclesDialog.cpp new file mode 100644 index 000000000..de4a2aacf --- /dev/null +++ b/retroshare-gui/src/gui/Circles/CirclesDialog.cpp @@ -0,0 +1,665 @@ +/* + * Retroshare Circle Plugin. + * + * Copyright 2012-2012 by Robert Fernie. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License Version 2.1 as published by the Free Software Foundation. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 + * USA. + * + * Please report all bugs and problems to "retroshare@lunamutt.com". + * + */ + +#include +#include + +#include "gui/Circles/CirclesDialog.h" + +#include + +#include +#include + +#include + +/****** + * #define CIRCLE_DEBUG 1 + *****/ + + +#if 0 +#define WIKIDIALOG_LISTING_GROUPDATA 2 +#define WIKIDIALOG_LISTING_PAGES 5 +#define WIKIDIALOG_MOD_LIST 6 +#define WIKIDIALOG_MOD_PAGES 7 +#define WIKIDIALOG_WIKI_PAGE 8 + +#define WIKIDIALOG_EDITTREE_DATA 9 + +#endif + + +/** Constructor */ +CirclesDialog::CirclesDialog(QWidget *parent) +: MainPage(parent) +{ + /* Invoke the Qt Designer generated object setup routine */ + ui.setupUi(this); + +#if 0 + mAddPageDialog = NULL; + mAddGroupDialog = NULL; + mEditDialog = NULL; + + connect( ui.toolButton_NewGroup, SIGNAL(clicked()), this, SLOT(OpenOrShowAddGroupDialog())); + connect( ui.toolButton_NewPage, SIGNAL(clicked()), this, SLOT(OpenOrShowAddPageDialog())); + connect( ui.toolButton_Edit, SIGNAL(clicked()), this, SLOT(OpenOrShowEditDialog())); + connect( ui.toolButton_Republish, SIGNAL(clicked()), this, SLOT(OpenOrShowRepublishDialog())); + + // Usurped until Refresh works normally + connect( ui.toolButton_Delete, SIGNAL(clicked()), this, SLOT(insertWikiGroups())); + + connect( ui.treeWidget_Pages, SIGNAL(itemSelectionChanged()), this, SLOT(groupTreeChanged())); + + QTimer *timer = new QTimer(this); + timer->connect(timer, SIGNAL(timeout()), this, SLOT(checkUpdate())); + timer->start(1000); + + /* setup TokenQueue */ + rsWiki->generateDummyData(); + mCircleQueue = new TokenQueue(rsWiki->getTokenService(), this); +#endif + + connect( ui.treeWidget_membership, SIGNAL(itemSelectionChanged()), this, SLOT(circle_selected())); + connect( ui.treeWidget_friends, SIGNAL(itemSelectionChanged()), this, SLOT(friend_selected())); + connect( ui.treeWidget_category, SIGNAL(itemSelectionChanged()), this, SLOT(category_selected())); + + +} + + +#if 0 + +void CirclesDialog::checkUpdate() +{ + + /* update */ + if (!rsWiki) + return; + + if (rsWiki->updated()) + { + insertWikiGroups(); + } + + return; +} + + + + +void CirclesDialog::update() +{ + /* load all circles, personal groups + * into the lists. + */ + + /* load friend list */ + + /* load categories */ + + std::list public_circles; + rsGxsCircles->getPublicCircles(public_circle); + + + +} + + +void CirclesDialog::circle_selected() +{ + /* update friend lists */ + + /* if personal group, update permissions */ +} + + +void CirclesDialog::friend_selected() +{ + /* update circle lists */ + + + /* update permission lists */ +} + +void CirclesDialog::category_selected() +{ + + + +} + + +#endif + + +#if 0 + + +void CirclesDialog::OpenOrShowAddPageDialog() +{ + std::string groupId = getSelectedGroup(); + if (groupId == "") + { + std::cerr << "CirclesDialog::OpenOrShowAddPageDialog() No Group selected"; + std::cerr << std::endl; + return; + } + + if (!mEditDialog) + { + mEditDialog = new WikiEditDialog(NULL); + } + + std::cerr << "CirclesDialog::OpenOrShowAddPageDialog() GroupId: " << groupId; + std::cerr << std::endl; + + mEditDialog->setupData(groupId, ""); + mEditDialog->setNewPage(); + + mEditDialog->show(); +} + + + +void CirclesDialog::OpenOrShowAddGroupDialog() +{ + newGroup(); +} + +/*********************** **** **** **** ***********************/ +/** New / Edit Groups ********************************/ +/*********************** **** **** **** ***********************/ + +void CirclesDialog::newGroup() +{ + WikiGroupDialog cf(mWikiQueue, this); + cf.wikitype(); + + cf.exec (); +} + +void CirclesDialog::showGroupDetails() +{ + std::string groupId = getSelectedGroup(); + if (groupId == "") + { + std::cerr << "CirclesDialog::showGroupDetails() No Group selected"; + std::cerr << std::endl; + return; + } +} + +void CirclesDialog::editGroupDetails() +{ + std::string groupId = getSelectedGroup(); + if (groupId == "") + { + std::cerr << "CirclesDialog::editGroupDetails() No Group selected"; + std::cerr << std::endl; + return; + } + + + //WikiGroupDialog cf (this); + //cf.existingGroup(groupId, GXS_GROUP_DIALOG_EDIT_MODE); + + //cf.exec (); +} + + + +void CirclesDialog::OpenOrShowEditDialog() +{ + std::string groupId; + std::string pageId; + std::string origPageId; + + if (!getSelectedPage(groupId, pageId, origPageId)) + { + std::cerr << "CirclesDialog::OpenOrShowAddPageDialog() No Group or PageId selected"; + std::cerr << std::endl; + return; + } + + std::cerr << "CirclesDialog::OpenOrShowAddPageDialog()"; + std::cerr << std::endl; + + if (!mEditDialog) + { + mEditDialog = new WikiEditDialog(NULL); + } + + mEditDialog->setupData(groupId, pageId); + mEditDialog->show(); +} + +void CirclesDialog::OpenOrShowRepublishDialog() +{ + OpenOrShowEditDialog(); + + std::string groupId; + std::string pageId; + std::string origPageId; + + if (!getSelectedPage(groupId, pageId, origPageId)) + { + std::cerr << "CirclesDialog::OpenOrShowAddRepublishDialog() No Group or PageId selected"; + std::cerr << std::endl; + if (mEditDialog) + { + mEditDialog->hide(); + } + return; + } + + mEditDialog->setRepublishMode(origPageId); +} + + +void CirclesDialog::groupTreeChanged() +{ + /* */ + std::string groupId; + std::string pageId; + std::string origPageId; + + getSelectedPage(groupId, pageId, origPageId); + if (pageId == mPageSelected) + { + return; /* nothing changed */ + } + + if (pageId == "") + { + /* clear Mods */ + clearGroupTree(); + return; + } + + RsGxsGrpMsgIdPair origPagePair = std::make_pair(groupId, origPageId); + RsGxsGrpMsgIdPair pagepair = std::make_pair(groupId, pageId); + requestWikiPage(pagepair); +} + +void CirclesDialog::updateWikiPage(const RsWikiSnapshot &page) +{ +#ifdef USE_PEGMMD_RENDERER + /* render as HTML */ + int extensions = 0; + char *answer = markdown_to_string((char *) page.mPage.c_str(), extensions, HTML_FORMAT); + + QString renderedText = QString::fromUtf8(answer); + ui.textBrowser->setHtml(renderedText); + + // free answer. + free(answer); +#else + /* render as HTML */ + QString renderedText = "IN (dummy) RENDERED TEXT MODE:\n"; + renderedText += QString::fromStdString(page.mPage); + ui.textBrowser->setPlainText(renderedText); +#endif +} + + +void CirclesDialog::clearWikiPage() +{ + ui.textBrowser->setPlainText(""); +} + + +void CirclesDialog::clearGroupTree() +{ + ui.treeWidget_Pages->clear(); +} + + +#define WIKI_GROUP_COL_GROUPNAME 0 +#define WIKI_GROUP_COL_GROUPID 1 + +#define WIKI_GROUP_COL_PAGENAME 0 +#define WIKI_GROUP_COL_PAGEID 1 +#define WIKI_GROUP_COL_ORIGPAGEID 2 + + +bool CirclesDialog::getSelectedPage(std::string &groupId, std::string &pageId, std::string &origPageId) +{ +#ifdef WIKI_DEBUG + std::cerr << "CirclesDialog::getSelectedPage()" << std::endl; +#endif + + /* get current item */ + QTreeWidgetItem *item = ui.treeWidget_Pages->currentItem(); + + if (!item) + { + /* leave current list */ +#ifdef WIKI_DEBUG + std::cerr << "CirclesDialog::getSelectedPage() Nothing selected" << std::endl; +#endif + return false; + } + + QTreeWidgetItem *parent = item->parent(); + + if (!parent) + { +#ifdef WIKI_DEBUG + std::cerr << "CirclesDialog::getSelectedPage() No Parent -> Group Selected" << std::endl; +#endif + return false; + } + + + /* check if it has changed */ + groupId = parent->text(WIKI_GROUP_COL_GROUPID).toStdString(); + pageId = item->text(WIKI_GROUP_COL_PAGEID).toStdString(); + origPageId = item->text(WIKI_GROUP_COL_ORIGPAGEID).toStdString(); + +#ifdef WIKI_DEBUG + std::cerr << "CirclesDialog::getSelectedPage() PageId: " << pageId << std::endl; +#endif + return true; +} + + +std::string CirclesDialog::getSelectedGroup() +{ + std::string groupId; +#ifdef WIKI_DEBUG + std::cerr << "CirclesDialog::getSelectedGroup()" << std::endl; +#endif + + /* get current item */ + QTreeWidgetItem *item = ui.treeWidget_Pages->currentItem(); + + if (!item) + { + /* leave current list */ +#ifdef WIKI_DEBUG + std::cerr << "CirclesDialog::getSelectedGroup() Nothing selected" << std::endl; +#endif + return groupId; + } + + QTreeWidgetItem *parent = item->parent(); + + if (parent) + { + groupId = parent->text(WIKI_GROUP_COL_GROUPID).toStdString(); +#ifdef WIKI_DEBUG + std::cerr << "CirclesDialog::getSelectedGroup() Page -> GroupId: " << groupId << std::endl; +#endif + return groupId; + } + + /* otherwise, we are on the group already */ + groupId = item->text(WIKI_GROUP_COL_GROUPID).toStdString(); +#ifdef WIKI_DEBUG + std::cerr << "CirclesDialog::getSelectedGroup() GroupId: " << groupId << std::endl; +#endif + return groupId; +} + +/************************** Request / Response *************************/ +/*** Loading Main Index ***/ + +void CirclesDialog::insertWikiGroups() +{ + requestGroupList(); +} + + +void CirclesDialog::requestGroupList() +{ + std::cerr << "CirclesDialog::requestGroupList()"; + std::cerr << std::endl; + + RsTokReqOptions opts; + opts.mReqType = GXS_REQUEST_TYPE_GROUP_DATA; + + uint32_t token; + mWikiQueue->requestGroupInfo(token, RS_TOKREQ_ANSTYPE_DATA, opts, WIKIDIALOG_LISTING_GROUPDATA); +} + + +void CirclesDialog::loadGroupData(const uint32_t &token) +{ + std::cerr << "CirclesDialog::loadGroupData()"; + std::cerr << std::endl; + + clearGroupTree(); + + std::vector datavector; + std::vector::iterator vit; + + if (!rsWiki->getCollections(token, datavector)) + { + std::cerr << "CirclesDialog::loadGroupData() Error getting GroupData"; + std::cerr << std::endl; + return; + } + + for(vit = datavector.begin(); vit != datavector.end(); vit++) + { + RsWikiCollection &group = *vit; + + /* Add Widget, and request Pages */ + + std::cerr << "CirclesDialog::addGroup() GroupId: " << group.mMeta.mGroupId; + std::cerr << " Group: " << group.mMeta.mGroupName; + std::cerr << std::endl; + + QTreeWidgetItem *groupItem = new QTreeWidgetItem(); + groupItem->setText(WIKI_GROUP_COL_GROUPNAME, QString::fromStdString(group.mMeta.mGroupName)); + groupItem->setText(WIKI_GROUP_COL_GROUPID, QString::fromStdString(group.mMeta.mGroupId)); + ui.treeWidget_Pages->addTopLevelItem(groupItem); + + /* request pages */ + std::list groupIds; + groupIds.push_back(group.mMeta.mGroupId); + + requestPages(groupIds); + //requestOriginalPages(groupIds); + } +} + + +void CirclesDialog::requestPages(const std::list &groupIds) +{ + std::cerr << "CirclesDialog::requestPages()"; + std::cerr << std::endl; + + RsTokReqOptions opts; + opts.mReqType = GXS_REQUEST_TYPE_MSG_DATA; + opts.mOptions = (RS_TOKREQOPT_MSG_LATEST | RS_TOKREQOPT_MSG_THREAD); // We want latest version of Thread Heads. + uint32_t token; + mWikiQueue->requestMsgInfo(token, RS_TOKREQ_ANSTYPE_DATA, opts, groupIds, WIKIDIALOG_LISTING_PAGES); +} + + +void CirclesDialog::loadPages(const uint32_t &token) +{ + std::cerr << "CirclesDialog::loadPages()"; + std::cerr << std::endl; + + /* find parent in GUI Tree - stick children */ + + QTreeWidgetItem *groupItem = NULL; + + std::vector snapshots; + std::vector::iterator vit; + if (!rsWiki->getSnapshots(token, snapshots)) + { + // ERROR + return; + } + + for(vit = snapshots.begin(); vit != snapshots.end(); vit++) + { + RsWikiSnapshot page = *vit; + if (!groupItem) + { + /* find the entry */ + int itemCount = ui.treeWidget_Pages->topLevelItemCount(); + for (int nIndex = 0; nIndex < itemCount; nIndex++) + { + QTreeWidgetItem *tmpItem = ui.treeWidget_Pages->topLevelItem(nIndex); + std::string tmpid = tmpItem->data(WIKI_GROUP_COL_GROUPID, + Qt::DisplayRole).toString().toStdString(); + if (tmpid == page.mMeta.mGroupId) + { + groupItem = tmpItem; + break; + } + } + + if (!groupItem) + { + /* error */ + std::cerr << "CirclesDialog::loadPages() ERROR Unable to find group"; + std::cerr << std::endl; + return; + } + } + + + std::cerr << "CirclesDialog::loadPages() PageId: " << page.mMeta.mMsgId; + std::cerr << " Page: " << page.mMeta.mMsgName; + std::cerr << std::endl; + + QTreeWidgetItem *pageItem = new QTreeWidgetItem(); + pageItem->setText(WIKI_GROUP_COL_PAGENAME, QString::fromStdString(page.mMeta.mMsgName)); + pageItem->setText(WIKI_GROUP_COL_PAGEID, QString::fromStdString(page.mMeta.mMsgId)); + pageItem->setText(WIKI_GROUP_COL_ORIGPAGEID, QString::fromStdString(page.mMeta.mOrigMsgId)); + + groupItem->addChild(pageItem); + } +} + +/***** Wiki *****/ + +void CirclesDialog::requestWikiPage(const RsGxsGrpMsgIdPair &msgId) +{ + std::cerr << "CirclesDialog::requestWikiPage(" << msgId.first << "," << msgId.second << ")"; + std::cerr << std::endl; + + RsTokReqOptions opts; + opts.mReqType = GXS_REQUEST_TYPE_MSG_DATA; + + uint32_t token; + + GxsMsgReq msgIds; + std::vector &vect_msgIds = msgIds[msgId.first]; + vect_msgIds.push_back(msgId.second); + + mWikiQueue->requestMsgInfo(token, RS_TOKREQ_ANSTYPE_DATA, opts, msgIds, WIKIDIALOG_WIKI_PAGE); + + //mWikiQueue->requestMsgRelatedInfo(token, RS_TOKREQ_ANSTYPE_DATA, opts, msgIds, WIKIDIALOG_WIKI_PAGE); +} + + +void CirclesDialog::loadWikiPage(const uint32_t &token) +{ + std::cerr << "CirclesDialog::loadWikiPage()"; + std::cerr << std::endl; + + // Should only have one WikiPage.... + std::vector snapshots; + if (!rsWiki->getSnapshots(token, snapshots)) + { + std::cerr << "CirclesDialog::loadWikiPage() ERROR"; + std::cerr << std::endl; + + // ERROR + return; + } + + if (snapshots.size() != 1) + { + std::cerr << "CirclesDialog::loadWikiPage() SIZE ERROR"; + std::cerr << std::endl; + + // ERROR + return; + } + + + RsWikiSnapshot page = snapshots[0]; + + std::cerr << "CirclesDialog::loadWikiPage() PageId: " << page.mMeta.mMsgId; + std::cerr << " Page: " << page.mMeta.mMsgName; + std::cerr << std::endl; + + updateWikiPage(page); +} + +#endif + + +void CirclesDialog::loadRequest(const TokenQueue *queue, const TokenRequest &req) +{ + +#if 0 + std::cerr << "CirclesDialog::loadRequest() UserType: " << req.mUserType; + std::cerr << std::endl; + + if (queue == mWikiQueue) + { + /* now switch on req */ + switch(req.mUserType) + { + case WIKIDIALOG_LISTING_GROUPDATA: + loadGroupData(req.mToken); + break; + + case WIKIDIALOG_LISTING_PAGES: + loadPages(req.mToken); + break; + + case WIKIDIALOG_WIKI_PAGE: + loadWikiPage(req.mToken); + break; + +#define GXSGROUP_NEWGROUPID 1 + case GXSGROUP_NEWGROUPID: + insertWikiGroups(); + break; + default: + std::cerr << "CirclesDialog::loadRequest() ERROR: INVALID TYPE"; + std::cerr << std::endl; + break; + } + } + +#endif + +} + + + + + + diff --git a/retroshare-gui/src/gui/Circles/CirclesDialog.h b/retroshare-gui/src/gui/Circles/CirclesDialog.h new file mode 100644 index 000000000..c763effd9 --- /dev/null +++ b/retroshare-gui/src/gui/Circles/CirclesDialog.h @@ -0,0 +1,93 @@ +/* + * Retroshare Circle. + * + * Copyright 2012-2012 by Robert Fernie. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License Version 2.1 as published by the Free Software Foundation. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 + * USA. + * + * Please report all bugs and problems to "retroshare@lunamutt.com". + * + */ + +#ifndef MRK_CIRCLE_DIALOG_H +#define MRK_CIRCLE_DIALOG_H + +#include "retroshare-gui/mainpage.h" +#include "ui_CirclesDialog.h" + +//#include + +#include "util/TokenQueue.h" + +#include + +class CirclesDialog : public MainPage, public TokenResponse +{ + Q_OBJECT + +public: + CirclesDialog(QWidget *parent = 0); + +void loadRequest(const TokenQueue *queue, const TokenRequest &req); + +private slots: + +#if 0 + void checkUpdate(); + void OpenOrShowAddPageDialog(); + void OpenOrShowAddGroupDialog(); + void OpenOrShowEditDialog(); + void OpenOrShowRepublishDialog(); + + void groupTreeChanged(); + + void newGroup(); + void showGroupDetails(); + void editGroupDetails(); + + void insertWikiGroups(); +#endif + +private: + +#if 0 +void clearWikiPage(); +void clearGroupTree(); + +void updateWikiPage(const RsWikiSnapshot &page); + +bool getSelectedPage(std::string &groupId, std::string &pageId, std::string &origPageId); +std::string getSelectedPage(); +std::string getSelectedGroup(); + +void requestGroupList(); +void loadGroupData(const uint32_t &token); + +void requestPages(const std::list &groupIds); +void loadPages(const uint32_t &token); + +void requestWikiPage(const RsGxsGrpMsgIdPair &msgId); +void loadWikiPage(const uint32_t &token); +#endif + + TokenQueue *mCircleQueue; + + /* UI - from Designer */ + Ui::CirclesDialog ui; + +}; + +#endif + diff --git a/retroshare-gui/src/gui/Circles/CirclesDialog.ui b/retroshare-gui/src/gui/Circles/CirclesDialog.ui new file mode 100644 index 000000000..c4c5edc27 --- /dev/null +++ b/retroshare-gui/src/gui/Circles/CirclesDialog.ui @@ -0,0 +1,198 @@ + + + CirclesDialog + + + + 0 + 0 + 746 + 568 + + + + + + + + + + + + Create Personal Group + + + + + + + Create Public Group + + + + + + + Refresh + + + + + + + Qt::Horizontal + + + + 378 + 20 + + + + + + + + + + + 75 + true + + + + Showing details: + + + + + + + + + Membership + + + + + + + Name + + + + + IDs + + + + + Personal Circles + + + + + Public Circles + + + + + + + + + + + true + + + Peers + + + + + + + Name + + + + + Status + + + + + ID + + + + + Friends + + + + + + + + Friends of Friends + + + + + + + + Others + + + + + + + + + + + + + + Permissions + + + + + + Anon Transfers + + + + + + + Discovery + + + + + + + + Share Category + + + + + + + + + + + + + + + + diff --git a/retroshare-gui/src/gui/Circles/Circles_images.qrc b/retroshare-gui/src/gui/Circles/Circles_images.qrc new file mode 100644 index 000000000..1ea8313ef --- /dev/null +++ b/retroshare-gui/src/gui/Circles/Circles_images.qrc @@ -0,0 +1,16 @@ + + + images/arrow-left.png + images/arrow-right.png + images/resource-group-new.png + images/appointment-new.png + images/book2_32.png + images/story-editor.png + images/story-editor_48.png + images/republish.png + images/resource-group-new_48.png + images/wikibook_32.png + images/resource-group_64.png + images/appointment-new_64.png + + diff --git a/retroshare-gui/src/gui/gxs/GxsCircleChooser.cpp b/retroshare-gui/src/gui/gxs/GxsCircleChooser.cpp new file mode 100644 index 000000000..926400320 --- /dev/null +++ b/retroshare-gui/src/gui/gxs/GxsCircleChooser.cpp @@ -0,0 +1,108 @@ +/**************************************************************** + * RetroShare is distributed under the following license: + * + * Copyright (C) 2008 Robert Fernie + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public License + * as published by the Free Software Foundation; either version 2.1 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301, USA. + ****************************************************************/ + +#include "GxsCircleChooser.h" + +#include + +#include + +#include + +/** Constructor */ +GxsCircleChooser::GxsCircleChooser(QWidget *parent) +: QComboBox(parent), mFlags(0) +{ + return; +} + +void GxsCircleChooser::loadCircles(uint32_t chooserFlags) +{ + mFlags = chooserFlags; + loadGxsCircles(); +} + + +bool MakeGxsCircleDesc(const RsGxsCircleId &id, QString &desc) +{ + RsGxsCircleDetails details; + + if (rsGxsCircles->getCircleDetails(id, details)) + { + desc = QString::fromUtf8(details.mCircleName.c_str()); + } + else + { + desc += "Unknown"; + } + + desc += " (Ext) ["; + desc += QString::fromStdString(id.substr(0,5)); + desc += "...]"; + + return true; +} + + +void GxsCircleChooser::loadGxsCircles() +{ + std::list ids; + rsGxsCircles->getCircleIdList(ids); + + if (ids.empty()) + { + std::cerr << "GxsCircleChooser::loadGxsCircles() ERROR no ids"; + std::cerr << std::endl; + return; + } + + std::list::iterator it; + for(it = ids.begin(); it != ids.end(); it++) + { + /* add to Chooser */ + QString str; + if (!MakeGxsCircleDesc(*it, str)) + { + std::cerr << "GxsCircleChooser::loadGxsCircles() ERROR Desc for Id: " << *it; + std::cerr << std::endl; + continue; + } + QString id = QString::fromStdString(*it); + + addItem(str, id); + } +} + +bool GxsCircleChooser::getChosenCircle(RsGxsCircleId &id) +{ + if (count() < 1) + { + return false; + } + + int idx = currentIndex(); + + QVariant var = itemData(idx); + id = var.toString().toStdString(); + + return true; +} + diff --git a/retroshare-gui/src/gui/gxs/GxsCircleChooser.h b/retroshare-gui/src/gui/gxs/GxsCircleChooser.h new file mode 100644 index 000000000..74986e02f --- /dev/null +++ b/retroshare-gui/src/gui/gxs/GxsCircleChooser.h @@ -0,0 +1,45 @@ +/**************************************************************** + * RetroShare is distributed under the following license: + * + * Copyright (C) 2008 Robert Fernie + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public License + * as published by the Free Software Foundation; either version 2.1 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301, USA. + ****************************************************************/ + + +#ifndef _GXS_CIRCLES_CHOOSER_H +#define _GXS_CIRCLES_CHOOSER_H + +#include +#include + +class GxsCircleChooser : public QComboBox +{ + Q_OBJECT + +public: + GxsCircleChooser(QWidget *parent = NULL); + + void loadCircles(uint32_t chooserFlags); + bool getChosenCircle(RsGxsCircleId &id); + +private: + void loadGxsCircles(); + uint32_t mFlags; +}; + +#endif + diff --git a/retroshare-gui/src/gui/gxs/GxsCircleLabel.cpp b/retroshare-gui/src/gui/gxs/GxsCircleLabel.cpp new file mode 100644 index 000000000..02f9f0800 --- /dev/null +++ b/retroshare-gui/src/gui/gxs/GxsCircleLabel.cpp @@ -0,0 +1,103 @@ +/**************************************************************** + * RetroShare is distributed under the following license: + * + * Copyright (C) 2008 Robert Fernie + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public License + * as published by the Free Software Foundation; either version 2.1 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301, USA. + ****************************************************************/ + +#include "GxsCircleLabel.h" + +#include + +#include + +#include + +/** Constructor */ +GxsCircleLabel::GxsCircleLabel(QWidget *parent) +:QLabel(parent), mTimer(NULL), mCount(0) +{ + mTimer = new QTimer(this); + mTimer->setSingleShot(true); + connect(mTimer, SIGNAL(timeout()), this, SLOT(loadId())); + + return; +} + +void GxsCircleLabel::setCircleId(const RsGxsCircleId &id) +{ + mId = id; + if (mId == "") + { + setText("No Circle"); + } + else + { + loadGxsCircle(); + } +} + +bool GxsCircleLabel::getCircleId(RsGxsCircleId &id) +{ + id = mId; + return true; +} + +static bool MakeCircleDesc(const RsGxsCircleId &id, QString &str) +{ + RsGxsCircleDetails details; + + if (!rsGxsCircles->getCircleDetails(id, details)) + { + str = "Loading... " + QString::fromStdString(id.substr(0,5)); + return false; + } + + str = QString::fromUtf8(details.mCircleName.c_str()); + + str += " (Ext) ["; + str += QString::fromStdString(id.substr(0,5)); + str += "...]"; + + return true; +} + +#define MAX_ATTEMPTS 3 + +void GxsCircleLabel::loadGxsCircle() +{ + mCount++; + + /* try and get details - if not there ... set callback */ + QString desc; + bool loaded = MakeCircleDesc(mId, desc); + + setText(desc); + + if (loaded) + { + return; + } + + if (mCount < MAX_ATTEMPTS) + { + /* timer event to try again (circles take longer) */ + mTimer->setInterval(mCount * 3000); + mTimer->start(); + } +} + diff --git a/retroshare-gui/src/gui/gxs/GxsCircleLabel.h b/retroshare-gui/src/gui/gxs/GxsCircleLabel.h new file mode 100644 index 000000000..03f43d62a --- /dev/null +++ b/retroshare-gui/src/gui/gxs/GxsCircleLabel.h @@ -0,0 +1,51 @@ +/**************************************************************** + * RetroShare is distributed under the following license: + * + * Copyright (C) 2008 Robert Fernie + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public License + * as published by the Free Software Foundation; either version 2.1 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301, USA. + ****************************************************************/ + + +#ifndef _GXS_CIRCLE_LABEL_H +#define _GXS_CIRCLE_LABEL_H + +#include +#include +#include + +class GxsCircleLabel : public QLabel +{ + Q_OBJECT + +public: + GxsCircleLabel(QWidget *parent = NULL); + + void setCircleId(const RsGxsCircleId &id); + bool getCircleId(RsGxsCircleId &id); + +private slots: + void loadGxsCircle(); + +private: + + QTimer *mTimer; + RsGxsCircleId mId; + int mCount; +}; + +#endif + diff --git a/retroshare-gui/src/gui/gxs/GxsGroupDialog.cpp b/retroshare-gui/src/gui/gxs/GxsGroupDialog.cpp index 3c392201c..7d32ede06 100644 --- a/retroshare-gui/src/gui/gxs/GxsGroupDialog.cpp +++ b/retroshare-gui/src/gui/gxs/GxsGroupDialog.cpp @@ -29,6 +29,7 @@ #include #include +#include #include @@ -51,12 +52,12 @@ /** Constructor */ GxsGroupDialog::GxsGroupDialog(TokenQueue *tokenQueue, uint32_t enableFlags, uint16_t defaultFlags, QWidget *parent) - : QDialog(parent, Qt::WindowSystemMenuHint | Qt::WindowTitleHint | Qt::WindowCloseButtonHint), mTokenQueue(tokenQueue), mMode(MODE_CREATE), mEnabledFlags(enableFlags), mReadonlyFlags(0), mDefaultsFlags(defaultFlags) + : QDialog(parent, Qt::WindowSystemMenuHint | Qt::WindowTitleHint | Qt::WindowCloseButtonHint), mTokenQueue(tokenQueue), mMode(MODE_CREATE), mEnabledFlags(enableFlags), mReadonlyFlags(0), mDefaultsFlags(defaultFlags) { - /* Invoke the Qt Designer generated object setup routine */ - ui.setupUi(this); + /* Invoke the Qt Designer generated object setup routine */ + ui.setupUi(this); - init(); + init(); } GxsGroupDialog::GxsGroupDialog(const RsGroupMetaData &grpMeta, Mode mode, QWidget *parent) @@ -70,64 +71,72 @@ GxsGroupDialog::GxsGroupDialog(const RsGroupMetaData &grpMeta, Mode mode, QWidge void GxsGroupDialog::init() { - // connect up the buttons. - connect( ui.buttonBox, SIGNAL(accepted()), this, SLOT(submitGroup())); - connect( ui.buttonBox, SIGNAL(rejected()), this, SLOT(cancelDialog())); - connect( ui.pubKeyShare_cb, SIGNAL( clicked() ), this, SLOT( setShareList( ) )); + // connect up the buttons. + connect( ui.buttonBox, SIGNAL(accepted()), this, SLOT(submitGroup())); + connect( ui.buttonBox, SIGNAL(rejected()), this, SLOT(cancelDialog())); + 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()); - } + ui.typePublic->setChecked(true); + updateCircleOptions(); - /* initialize key share list */ - ui.keyShareList->setHeaderText(tr("Contacts:")); - ui.keyShareList->setModus(FriendSelectionWidget::MODUS_CHECK); - ui.keyShareList->start(); + connect( ui.typePublic, SIGNAL(clicked()), this , SLOT(updateCircleOptions())); + connect( ui.typeGroup, SIGNAL(clicked()), this , SLOT(updateCircleOptions())); + connect( ui.typeLocal, SIGNAL(clicked()), this , SLOT(updateCircleOptions())); - /* Setup Reasonable Defaults */ + if (!ui.pubKeyShare_cb->isChecked()) + { + ui.contactsdockWidget->hide(); + this->resize(this->size().width() - ui.contactsdockWidget->size().width(), this->size().height()); + } - ui.idChooser->loadIds(0,""); + /* initialize key share list */ + ui.keyShareList->setHeaderText(tr("Contacts:")); + ui.keyShareList->setModus(FriendSelectionWidget::MODUS_CHECK); + ui.keyShareList->start(); - initMode(); + /* Setup Reasonable Defaults */ + + ui.idChooser->loadIds(0,""); + ui.circleComboBox->loadCircles(0); + + initMode(); } void GxsGroupDialog::showEvent(QShowEvent*) { - QString header = serviceHeader(); - ui.headerFrame->setHeaderText(header); - setWindowTitle(header); - ui.headerFrame->setHeaderImage(serviceImage()); + QString header = serviceHeader(); + ui.headerFrame->setHeaderText(header); + setWindowTitle(header); + ui.headerFrame->setHeaderImage(serviceImage()); } void GxsGroupDialog::initMode() { - switch (mode()) - { - case MODE_CREATE: - { - ui.buttonBox->setStandardButtons(QDialogButtonBox::Ok | QDialogButtonBox::Cancel); - ui.buttonBox->button(QDialogButtonBox::Ok)->setText(tr("Create Group")); - newGroup(); - } - break; + switch (mode()) + { + case MODE_CREATE: + { + ui.buttonBox->setStandardButtons(QDialogButtonBox::Ok | QDialogButtonBox::Cancel); + ui.buttonBox->button(QDialogButtonBox::Ok)->setText(tr("Create Group")); + newGroup(); + } + break; - case MODE_SHOW: - { - ui.buttonBox->setStandardButtons(QDialogButtonBox::Close); - } - break; + case MODE_SHOW: + { + ui.buttonBox->setStandardButtons(QDialogButtonBox::Close); + } + break; //TODO -// case MODE_EDIT: -// { -// ui.createButton->setText(tr("Submit Changes")); -// } -// break; - } +// case MODE_EDIT: +// { +// ui.createButton->setText(tr("Submit Changes")); +// } +// break; + } } @@ -142,259 +151,335 @@ 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(); } void GxsGroupDialog::submitGroup() { - std::cerr << "GxsGroupDialog::submitGroup()"; - std::cerr << std::endl; + std::cerr << "GxsGroupDialog::submitGroup()"; + std::cerr << std::endl; - /* switch depending on mode */ - switch (mode()) - { - case MODE_CREATE: - { - /* just close if down */ - createGroup(); - } - break; + /* switch depending on mode */ + switch (mode()) + { + case MODE_CREATE: + { + /* just close if down */ + createGroup(); + } + break; - case MODE_SHOW: - { - /* just close if down */ - cancelDialog(); - } - break; + case MODE_SHOW: + { + /* just close if down */ + cancelDialog(); + } + break; - case MODE_EDIT: - { - /* TEMP: just close if down */ - cancelDialog(); - } - break; - } + case MODE_EDIT: + { + /* TEMP: just close if down */ + cancelDialog(); + } + break; + } } void GxsGroupDialog::createGroup() { - std::cerr << "GxsGroupDialog::createGroup()"; - std::cerr << std::endl; + std::cerr << "GxsGroupDialog::createGroup()"; + std::cerr << std::endl; - QString name = misc::removeNewLine(ui.groupName->text()); - 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!! + } - uint32_t token; - RsGroupMetaData meta; + uint32_t token; + RsGroupMetaData meta; - // Fill in the MetaData as best we can. - meta.mGroupName = std::string(name.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(); - 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(); + setCircleParameters(meta); + + 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_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(); - } + 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); - } + /* 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); + } } + + +/**** Above logic is flawed, and will be removed shortly + * + * + ****/ + +void GxsGroupDialog::updateCircleOptions() +{ + if (ui.typeGroup->isChecked()) + { + ui.circleComboBox->setEnabled(true); + ui.circleComboBox->setVisible(true); + } + else + { + ui.circleComboBox->setEnabled(false); + ui.circleComboBox->setVisible(false); + } + + if (ui.typeLocal->isChecked()) + { + ui.localComboBox->setEnabled(true); + ui.localComboBox->setVisible(true); + } + else + { + ui.localComboBox->setEnabled(false); + ui.localComboBox->setVisible(false); + } +} + +void GxsGroupDialog::setCircleParameters(RsGroupMetaData &meta) +{ + bool problem = false; + if (ui.typePublic->isChecked()) + { + meta.mCircleType = GXS_CIRCLE_TYPE_PUBLIC; + meta.mCircleId.clear(); + } + else if (ui.typeGroup->isChecked()) + { + meta.mCircleType = GXS_CIRCLE_TYPE_EXTERNAL; + if (!ui.circleComboBox->getChosenCircle(meta.mCircleId)) + { + problem = true; + } + } + else if (ui.typeGroup->isChecked()) + { + meta.mCircleType = GXS_CIRCLE_TYPE_YOUREYESONLY; + meta.mCircleId.clear(); + meta.mOriginator.clear(); + meta.mInternalCircle = "Internal Circle Id"; + + problem = true; + } + else + { + problem = true; + } + + if (problem) + { + // error. + meta.mCircleType = GXS_CIRCLE_TYPE_PUBLIC; + meta.mCircleId.clear(); + meta.mOriginator.clear(); + meta.mInternalCircle.clear(); + } +} + + + void GxsGroupDialog::cancelDialog() { std::cerr << "GxsGroupDialog::cancelDialog() Should Close!"; @@ -418,12 +503,12 @@ void GxsGroupDialog::addGroupLogo() QPixmap GxsGroupDialog::getLogo() { - return picture; + return picture; } QString GxsGroupDialog::getDescription() { - return ui.groupDesc->document()->toPlainText(); + return ui.groupDesc->document()->toPlainText(); } /*********************************************************************************** @@ -437,13 +522,13 @@ void GxsGroupDialog::sendShareList(std::string groupId) 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()); + } } void GxsGroupDialog::wikitype() diff --git a/retroshare-gui/src/gui/gxs/GxsGroupDialog.h b/retroshare-gui/src/gui/gxs/GxsGroupDialog.h index 4af920686..beae5e965 100644 --- a/retroshare-gui/src/gui/gxs/GxsGroupDialog.h +++ b/retroshare-gui/src/gui/gxs/GxsGroupDialog.h @@ -188,8 +188,14 @@ private slots: // set private forum key share list void setShareList(); + void updateCircleOptions(); + private: + + void setCircleParameters(RsGroupMetaData &meta); + + void setGroupSignFlags(uint32_t signFlags); uint32_t getGroupSignFlags(); void setupDefaults(); diff --git a/retroshare-gui/src/gui/gxs/GxsGroupDialog.ui b/retroshare-gui/src/gui/gxs/GxsGroupDialog.ui index c2811703c..6c30bc5eb 100644 --- a/retroshare-gui/src/gui/gxs/GxsGroupDialog.ui +++ b/retroshare-gui/src/gui/gxs/GxsGroupDialog.ui @@ -297,19 +297,16 @@ - - - - Select Group of Friends - - - + Qt::Horizontal + + QSizePolicy::MinimumExpanding + 40 @@ -319,25 +316,29 @@ - - - Edit Groups - + + + + Some Friends + + + + + Another Group + + + + + Family? + + + + + Enemies + + - - - - Qt::Horizontal - - - - 40 - 20 - - - - @@ -491,6 +492,11 @@
gui/common/FriendSelectionWidget.h
1 + + GxsCircleChooser + QComboBox +
gui/gxs/GxsCircleChooser.h
+
diff --git a/retroshare-gui/src/gui/unfinished/ApplicationWindow.cpp b/retroshare-gui/src/gui/unfinished/ApplicationWindow.cpp index 972b383c4..b6e1fc2a3 100644 --- a/retroshare-gui/src/gui/unfinished/ApplicationWindow.cpp +++ b/retroshare-gui/src/gui/unfinished/ApplicationWindow.cpp @@ -27,6 +27,7 @@ #include #include "gui/Identity/IdDialog.h" +#include "gui/Circles/CirclesDialog.h" #include "gui/PhotoShare/PhotoShare.h" #include "gui/WikiPoos/WikiDialog.h" #include "gui/Posted/PostedDialog.h" @@ -91,6 +92,10 @@ ApplicationWindow::ApplicationWindow(QWidget* parent, Qt::WFlags flags) ui.stackPages->add(idDialog = new IdDialog(ui.stackPages), createPageAction(QIcon(IMAGE_LIBRARY), tr("Identities"), grp)); + CirclesDialog *circlesDialog = NULL; + ui.stackPages->add(circlesDialog = new CirclesDialog(ui.stackPages), + createPageAction(QIcon(IMAGE_LIBRARY), tr("Circles"), grp)); + PhotoShare *photoShare = NULL; ui.stackPages->add(photoShare = new PhotoShare(ui.stackPages), createPageAction(QIcon(IMAGE_PHOTO), tr("Photo Share"), grp));