GxsIdChooser: request only data for own ids (was requesting all ids before)

git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@8043 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
electron128 2015-03-18 13:33:38 +00:00
parent b2019b680f
commit 148fd8bb05
2 changed files with 6 additions and 67 deletions

View File

@ -56,7 +56,6 @@ GxsIdChooser::GxsIdChooser(QWidget *parent)
/* Initialize ui */
setSizeAdjustPolicy(QComboBox::AdjustToContents);
mIdQueue = NULL;
mFirstLoad = true;
mDefaultId.clear() ;
@ -72,8 +71,6 @@ GxsIdChooser::GxsIdChooser(QWidget *parent)
/* Connect signals */
connect(this, SIGNAL(currentIndexChanged(int)), this, SLOT(myCurrentIndexChanged(int)));
connect(this, SIGNAL(activated(int)), this, SLOT(indexActivated(int)));
mIdQueue = new TokenQueue(rsIdentity->getTokenService(), this);
}
void GxsIdChooser::setFlags(uint32_t flags)
@ -84,10 +81,6 @@ void GxsIdChooser::setFlags(uint32_t flags)
GxsIdChooser::~GxsIdChooser()
{
if (mIdQueue) {
delete(mIdQueue);
mIdQueue = NULL;
}
}
void GxsIdChooser::fillDisplay(bool complete)
@ -165,27 +158,14 @@ static void loadPrivateIdsCallback(GxsIdDetailsType type, const RsIdentityDetail
chooser->blockSignals(false) ;
}
void GxsIdChooser::loadPrivateIds(uint32_t token)
void GxsIdChooser::loadPrivateIds()
{
if (mFirstLoad) {
clear();
}
std::list<RsGxsId> ids;
//rsIdentity->getOwnIds(ids);
std::vector<RsGxsIdGroup> datavector;
if (!rsIdentity->getGroupData(token, datavector)) {
std::cerr << "GxsIdChooser::loadPrivateIds() Error getting GroupData";
std::cerr << std::endl;
return;
}
for (std::vector<RsGxsIdGroup>::iterator vit = datavector.begin(); vit != datavector.end(); ++vit) {
RsGxsIdGroup data = (*vit);
if (data.mMeta.mSubscribeFlags & GXS_SERV::GROUP_SUBSCRIBE_ADMIN) {
ids.push_back((RsGxsId) data.mMeta.mGroupId);
}
}
rsIdentity->getOwnIds(ids);
//rsIdentity->getDefaultId(defId);
// Prefer to use an application specific default???
@ -330,41 +310,5 @@ void GxsIdChooser::updateDisplay(bool complete)
Q_UNUSED(complete)
/* Update identity list */
requestIdList();
}
void GxsIdChooser::requestIdList()
{
if (!mIdQueue) {
return;
}
mIdQueue->cancelActiveRequestTokens(IDCHOOSER_REFRESH);
RsTokReqOptions opts;
opts.mReqType = GXS_REQUEST_TYPE_GROUP_DATA;
uint32_t token;
mIdQueue->requestGroupInfo(token, RS_TOKREQ_ANSTYPE_DATA, opts, IDCHOOSER_REFRESH);
}
void GxsIdChooser::loadRequest(const TokenQueue *queue, const TokenRequest &req)
{
Q_UNUSED(queue)
#ifdef IDCHOOSER_DEBUG
std::cerr << "IdDialog::loadRequest() UserType: " << req.mUserType;
std::cerr << std::endl;
#endif
switch(req.mUserType) {
case IDCHOOSER_REFRESH:
loadPrivateIds(req.mToken);
break;
default:
std::cerr << "IdDialog::loadRequest() ERROR";
std::cerr << std::endl;
break;
}
loadPrivateIds();
}

View File

@ -25,7 +25,7 @@
#define _GXS_ID_CHOOSER_H
#include <QComboBox>
#include "util/TokenQueue.h"
#include <retroshare/rsgxsifacetypes.h>
// This class implement a basic RS functionality which is that ComboBox displaying Id
// should update regularly. They also should update only when visible, to save CPU time.
@ -38,7 +38,7 @@ class RsGxsUpdateBroadcastBase;
#define IDCHOOSER_ANON_DEFAULT 0x0002
#define IDCHOOSER_NO_CREATE 0x0004
class GxsIdChooser : public QComboBox, public TokenResponse
class GxsIdChooser : public QComboBox
{
Q_OBJECT
@ -49,9 +49,6 @@ public:
void setFlags(uint32_t flags) ;
/* TokenResponse */
virtual void loadRequest(const TokenQueue *queue, const TokenRequest &req);
enum ChosenId_Ret {None, KnowId, UnKnowId, NoId} ;
void loadIds(uint32_t chooserFlags, const RsGxsId &defId);
void setDefaultId(const RsGxsId &defId);
@ -69,15 +66,13 @@ private slots:
void indexActivated(int index);
private:
void requestIdList() ;
void loadPrivateIds(uint32_t token);
void loadPrivateIds();
void setDefaultItem();
uint32_t mFlags;
RsGxsId mDefaultId;
bool mFirstLoad;
TokenQueue *mIdQueue;
RsGxsUpdateBroadcastBase *mBase;
};