diff --git a/libretroshare/src/retroshare/rsgxscircles.h b/libretroshare/src/retroshare/rsgxscircles.h index f650db4e6..4ebf45aca 100644 --- a/libretroshare/src/retroshare/rsgxscircles.h +++ b/libretroshare/src/retroshare/rsgxscircles.h @@ -134,6 +134,11 @@ virtual bool getCircleDetails(const RsGxsCircleId &id, RsGxsCircleDetails &detai virtual bool getCircleExternalIdList(std::list &circleIds) = 0; virtual bool getCirclePersonalIdList(std::list &circleIds) = 0; + /* membership management for external circles */ + + virtual bool requestCircleMembership(const RsGxsCircleId& id)=0 ; + virtual bool cancelCircleMembership(const RsGxsCircleId& id)=0 ; + /* standard load */ virtual bool getGroupData(const uint32_t &token, std::vector &groups) = 0; diff --git a/libretroshare/src/services/p3gxscircles.cc b/libretroshare/src/services/p3gxscircles.cc index e4f650ff0..9746620bd 100644 --- a/libretroshare/src/services/p3gxscircles.cc +++ b/libretroshare/src/services/p3gxscircles.cc @@ -1820,4 +1820,14 @@ void p3GxsCircles::handle_event(uint32_t event_type, const std::string &elabel) } +bool p3GxsCircles::requestCircleMembership(const RsGxsCircleId& id) +{ +#warning code missing here !!! +} + +bool p3GxsCircles::cancelCircleMembership(const RsGxsCircleId& id) +{ +#warning code missing here !!! +} + diff --git a/libretroshare/src/services/p3gxscircles.h b/libretroshare/src/services/p3gxscircles.h index 1edb5a3c6..f15cd2dc8 100644 --- a/libretroshare/src/services/p3gxscircles.h +++ b/libretroshare/src/services/p3gxscircles.h @@ -192,6 +192,11 @@ virtual RsServiceInfo getServiceInfo(); virtual void updateGroup(uint32_t &token, RsGxsCircleGroup &group); + /* membership management for external circles */ + + virtual bool requestCircleMembership(const RsGxsCircleId& id) ; + virtual bool cancelCircleMembership(const RsGxsCircleId& id) ; + /**********************************************/ // needed for background processing. diff --git a/retroshare-gui/src/gui/Identity/IdDialog.cpp b/retroshare-gui/src/gui/Identity/IdDialog.cpp index 54d7374dd..51f2ebd79 100644 --- a/retroshare-gui/src/gui/Identity/IdDialog.cpp +++ b/retroshare-gui/src/gui/Identity/IdDialog.cpp @@ -57,9 +57,10 @@ #define IDDIALOG_REPLIST 3 #define IDDIALOG_REFRESH 4 -#define CIRCLEGROUP_CIRCLE_COL_GROUPNAME 0 -#define CIRCLEGROUP_CIRCLE_COL_GROUPID 1 -#define CIRCLEGROUP_CIRCLE_COL_GROUPFLAGS 2 +#define CIRCLEGROUP_CIRCLE_COL_GROUPNAME 0 +#define CIRCLEGROUP_CIRCLE_COL_GROUPID 1 +#define CIRCLEGROUP_CIRCLE_COL_GROUPFLAGS 2 +#define CIRCLEGROUP_CIRCLE_COL_SUBSCRIBEFLAGS 3 #define CIRCLEGROUP_FRIEND_COL_NAME 0 #define CIRCLEGROUP_FRIEND_COL_ID 1 @@ -321,10 +322,10 @@ void IdDialog::requestCircleGroupMeta() { mStateHelper->setLoading(CIRCLESDIALOG_GROUPMETA, true); -//#ifdef ID_DEBUG +#ifdef ID_DEBUG std::cerr << "CirclesDialog::requestGroupMeta()"; std::cerr << std::endl; -//#endif +#endif mCircleQueue->cancelActiveRequestTokens(CIRCLESDIALOG_GROUPMETA); @@ -461,6 +462,7 @@ void IdDialog::loadCircleGroupMeta(const uint32_t &token) item->setText(CIRCLEGROUP_CIRCLE_COL_GROUPNAME, QString::fromUtf8(vit->mGroupName.c_str())); item->setText(CIRCLEGROUP_CIRCLE_COL_GROUPID, QString::fromStdString(vit->mGroupId.toStdString())); item->setData(CIRCLEGROUP_CIRCLE_COL_GROUPFLAGS, Qt::UserRole, QVariant(vit->mSubscribeFlags)); + item->setData(CIRCLEGROUP_CIRCLE_COL_SUBSCRIBEFLAGS, Qt::UserRole, QVariant(details.mSubscribeFlags)); if(am_I_in_circle) { @@ -484,6 +486,10 @@ void IdDialog::loadCircleGroupMeta(const uint32_t &token) #endif item->setText(CIRCLEGROUP_CIRCLE_COL_GROUPNAME, QString::fromUtf8(vit->mGroupName.c_str())); } + // just in case. + + item->setData(CIRCLEGROUP_CIRCLE_COL_GROUPFLAGS, Qt::UserRole, QVariant(vit->mSubscribeFlags)); + item->setData(CIRCLEGROUP_CIRCLE_COL_SUBSCRIBEFLAGS, Qt::UserRole, QVariant(details.mSubscribeFlags)); if (vit->mSubscribeFlags & GXS_SERV::GROUP_SUBSCRIBE_ADMIN) { @@ -608,6 +614,32 @@ void IdDialog::showEditExistingCircle() requestCircleGroupMeta(); // update GUI } +void IdDialog::acceptCircleSubscription() +{ + QTreeWidgetItem *item = ui->treeWidget_membership->currentItem(); + + if (!item) + return ; + + QString coltext = item->text(CIRCLEGROUP_CIRCLE_COL_GROUPID); + RsGxsCircleId circle_id ( coltext.toStdString()) ; + + rsGxsCircles->requestCircleMembership(circle_id) ; +} + +void IdDialog::refuseCircleSubscription() +{ + QTreeWidgetItem *item = ui->treeWidget_membership->currentItem(); + + if (!item) + return ; + + QString coltext = item->text(CIRCLEGROUP_CIRCLE_COL_GROUPID); + RsGxsCircleId circle_id ( coltext.toStdString()) ; + + rsGxsCircles->cancelCircleMembership(circle_id) ; +} + void IdDialog::CircleListCustomPopupMenu( QPoint ) { QMenu contextMnu( this ); @@ -616,14 +648,32 @@ void IdDialog::CircleListCustomPopupMenu( QPoint ) if (item) { - uint32_t subscribe_flags = item->data(CIRCLEGROUP_CIRCLE_COL_GROUPFLAGS, Qt::UserRole).toUInt(); + uint32_t group_flags = item->data(CIRCLEGROUP_CIRCLE_COL_GROUPFLAGS, Qt::UserRole).toUInt(); if(item->parent() != NULL) - if(subscribe_flags & GXS_SERV::GROUP_SUBSCRIBE_ADMIN) + if(group_flags & GXS_SERV::GROUP_SUBSCRIBE_ADMIN) contextMnu.addAction(QIcon(IMAGE_EDIT), tr("Edit Circle"), this, SLOT(showEditExistingCircle())); else contextMnu.addAction(QIcon(IMAGE_EDIT), tr("See details"), this, SLOT(showEditExistingCircle())); } + + contextMnu.addSeparator() ; + + uint32_t subscribe_flags = item->data(CIRCLEGROUP_CIRCLE_COL_SUBSCRIBEFLAGS, Qt::UserRole).toUInt(); + + if(subscribe_flags & GXS_EXTERNAL_CIRCLE_FLAGS_SUBSCRIBED) + if(subscribe_flags & GXS_EXTERNAL_CIRCLE_FLAGS_IN_ADMIN_LIST) + contextMnu.addAction(QIcon(IMAGE_EDIT), tr("Remove me from this circle"), this, SLOT(refuseCircleMembership())); + else + contextMnu.addAction(QIcon(IMAGE_EDIT), tr("Cancel subscription request"), this, SLOT(refuseCircleMembership())); + else + if(subscribe_flags & GXS_EXTERNAL_CIRCLE_FLAGS_IN_ADMIN_LIST) + contextMnu.addAction(QIcon(IMAGE_EDIT), tr("Accept circle invite and join the circle"), this, SLOT(acceptCircleMembership())); + else + contextMnu.addAction(QIcon(IMAGE_EDIT), tr("Request to join this circle"), this, SLOT(acceptCircleMembership())); + + contextMnu.addSeparator() ; + contextMnu.addAction(QIcon(IMAGE_CREATE), tr("Create external circle"), this, SLOT(createExternalCircle())); contextMnu.exec(QCursor::pos()); } diff --git a/retroshare-gui/src/gui/Identity/IdDialog.h b/retroshare-gui/src/gui/Identity/IdDialog.h index a6eb3623a..c8af44fe6 100644 --- a/retroshare-gui/src/gui/Identity/IdDialog.h +++ b/retroshare-gui/src/gui/Identity/IdDialog.h @@ -66,6 +66,9 @@ private slots: void createExternalCircle(); void showEditExistingCircle(); void updateCirclesDisplay(); + + void acceptCircleSubscription() ; + void refuseCircleSubscription() ; void filterComboBoxChanged(); void filterChanged(const QString &text);