diff --git a/retroshare-gui/src/gui/common/FriendSelectionWidget.cpp b/retroshare-gui/src/gui/common/FriendSelectionWidget.cpp index e7e670571..9f023983b 100644 --- a/retroshare-gui/src/gui/common/FriendSelectionWidget.cpp +++ b/retroshare-gui/src/gui/common/FriendSelectionWidget.cpp @@ -41,6 +41,8 @@ #define COLUMN_DATA 0 #define COLUMN_COUNT 1 +#define IDDIALOG_IDLIST 1 + #define ROLE_ID Qt::UserRole #define ROLE_SORT Qt::UserRole + 1 @@ -73,9 +75,8 @@ static void setSelected(FriendSelectionWidget::Modus modus, QTreeWidgetItem *ite } } -FriendSelectionWidget::FriendSelectionWidget(QWidget *parent) : - QWidget(parent), - ui(new Ui::FriendSelectionWidget) +FriendSelectionWidget::FriendSelectionWidget(QWidget *parent) + : RsGxsUpdateBroadcastPage(rsIdentity,parent), ui(new Ui::FriendSelectionWidget) { ui->setupUi(this); @@ -87,6 +88,8 @@ FriendSelectionWidget::FriendSelectionWidget(QWidget *parent) : mInSslItemChanged = false; mInFillList = false; + mIdQueue = new TokenQueue(rsIdentity->getTokenService(), this); + connect(ui->friendList, SIGNAL(customContextMenuRequested(QPoint)), this, SLOT(contextMenuRequested(QPoint))); connect(ui->friendList, SIGNAL(itemDoubleClicked(QTreeWidgetItem*,int)), this, SLOT(itemDoubleClicked(QTreeWidgetItem*,int))); connect(ui->friendList, SIGNAL(itemChanged(QTreeWidgetItem*,int)), this, SLOT(itemChanged(QTreeWidgetItem*,int))); @@ -228,6 +231,34 @@ void FriendSelectionWidget::fillList() secured_fillList() ; } +void FriendSelectionWidget::loadRequest(const TokenQueue */*queue*/, const TokenRequest &req) +{ + // store all IDs locally, and call fillList() ; + + uint32_t token = req.mToken ; + + RsGxsIdGroup data; + std::vector datavector; + std::vector::iterator vit; + + if (!rsIdentity->getGroupData(token, datavector)) + { + std::cerr << "FriendSelectionWidget::loadRequest() ERROR. Cannot load data from rsIdentity." << std::endl; + return ; + } + + gxsIds.clear() ; + + for(uint32_t i=0;igetFriendList(sslIds); } - std::list gxsIds ; - std::list::iterator gxsIt ; - - if(mShowTypes & SHOW_GXS) - rsIdentity->getOwnIds(gxsIds) ; // should get all ids, not just own. What's the correct call?? - std::list statusInfo; std::list::iterator statusIt; rsStatus->getStatusList(statusInfo); @@ -488,7 +513,7 @@ void FriendSelectionWidget::secured_fillList() if(mShowTypes & SHOW_GXS) { // iterate through gpg ids - for (gxsIt = gxsIds.begin(); gxsIt != gxsIds.end(); gxsIt++) + for (std::vector::const_iterator gxsIt = gxsIds.begin(); gxsIt != gxsIds.end(); gxsIt++) { // we fill the not assigned gpg ids if (std::find(filledIds.begin(), filledIds.end(), (*gxsIt).toStdString()) != filledIds.end()) @@ -498,7 +523,7 @@ void FriendSelectionWidget::secured_fillList() filledIds.push_back((*gxsIt).toStdString()); RsIdentityDetails detail; - if (!rsIdentity->getIdDetails(*gxsIt, detail)) + if (!rsIdentity->getIdDetails(RsGxsId(*gxsIt), detail)) continue; /* BAD */ // make a widget per friend @@ -544,6 +569,29 @@ void FriendSelectionWidget::secured_fillList() emit contentChanged(); } +void FriendSelectionWidget::updateDisplay(bool) +{ + requestGXSIdList() ; +} +void FriendSelectionWidget::requestGXSIdList() +{ + if (!mIdQueue) + return; + + //mStateHelper->setLoading(IDDIALOG_IDLIST, true); + //mStateHelper->setLoading(IDDIALOG_IDDETAILS, true); + //mStateHelper->setLoading(IDDIALOG_REPLIST, true); + + mIdQueue->cancelActiveRequestTokens(IDDIALOG_IDLIST); + + RsTokReqOptions opts; + opts.mReqType = GXS_REQUEST_TYPE_GROUP_DATA; + + uint32_t token; + + mIdQueue->requestGroupInfo(token, RS_TOKREQ_ANSTYPE_DATA, opts, IDDIALOG_IDLIST); +} + void FriendSelectionWidget::groupsChanged(int /*type*/) { diff --git a/retroshare-gui/src/gui/common/FriendSelectionWidget.h b/retroshare-gui/src/gui/common/FriendSelectionWidget.h index a699374b3..d31dbfc7c 100644 --- a/retroshare-gui/src/gui/common/FriendSelectionWidget.h +++ b/retroshare-gui/src/gui/common/FriendSelectionWidget.h @@ -26,6 +26,9 @@ #include #include +#include +#include "util/TokenQueue.h" + namespace Ui { class FriendSelectionWidget; } @@ -33,7 +36,7 @@ class FriendSelectionWidget; class QTreeWidgetItem; class RSTreeWidgetItemCompareRole; -class FriendSelectionWidget : public QWidget +class FriendSelectionWidget : public RsGxsUpdateBroadcastPage, public TokenResponse { Q_OBJECT @@ -109,6 +112,9 @@ public: protected: void changeEvent(QEvent *e); + virtual void loadRequest(const TokenQueue *queue,const TokenRequest& req); + virtual void updateDisplay(bool complete); + signals: void itemAdded(int idType, const QString &id, QTreeWidgetItem *item); void contentChanged(); @@ -134,6 +140,8 @@ private: void selectedIds(IdType idType, std::list &ids, bool onlyDirectSelected); void setSelectedIds(IdType idType, const std::list &ids, bool add); + void requestGXSIdList() ; + bool mStarted; RSTreeWidgetItemCompareRole *mCompareRole; Modus mListModus; @@ -149,6 +157,9 @@ private: Ui::FriendSelectionWidget *ui; friend class FriendSelectionDialog ; + + std::vector gxsIds ; + TokenQueue *mIdQueue ; }; Q_DECLARE_OPERATORS_FOR_FLAGS(FriendSelectionWidget::ShowTypes)