mirror of
https://github.com/RetroShare/RetroShare.git
synced 2024-12-25 07:29:33 -05:00
- Added re-check of "Not found" identities for chat lobby participants list.
- Added check of RsAutoUpdatePage::eventsLocked to GxsIdDetails::timerEvent. git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@8006 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
parent
f6a1cbb3b2
commit
325a383fba
@ -1108,7 +1108,7 @@ void MessagesDialog::insertMessages()
|
||||
setText = false;
|
||||
if (gotInfo || rsMsgs->getMessage(it->msgId, msgInfo)) {
|
||||
gotInfo = true;
|
||||
item->setId(RsGxsId(msgInfo.rsgxsid_srcId), COLUMN_FROM);
|
||||
item->setId(RsGxsId(msgInfo.rsgxsid_srcId), COLUMN_FROM, false);
|
||||
} else {
|
||||
std::cerr << "MessagesDialog::insertMsgTxtAndFiles() Couldn't find Msg" << std::endl;
|
||||
}
|
||||
|
@ -395,7 +395,7 @@ void ChatLobbyDialog::updateParticipantsList()
|
||||
// TE: Add Wigdet to participantsList with Checkbox, to mute Participant
|
||||
|
||||
widgetitem = new GxsIdRSTreeWidgetItem(mParticipantCompareRole);
|
||||
widgetitem->setId(it2->first,COLUMN_NAME) ;
|
||||
widgetitem->setId(it2->first,COLUMN_NAME, true) ;
|
||||
//widgetitem->setText(COLUMN_NAME, participant);
|
||||
widgetitem->setText(COLUMN_ACTIVITY,QString::number(time(NULL)));
|
||||
widgetitem->setText(COLUMN_ID,QString::fromStdString(it2->first.toStdString()));
|
||||
|
@ -430,7 +430,7 @@ void GxsCommentTreeWidget::service_loadThread(const uint32_t &token)
|
||||
item->setText(PCITEM_COLUMN_COMMENT, text);
|
||||
|
||||
RsGxsId authorId = comment.mMeta.mAuthorId;
|
||||
item->setId(authorId, PCITEM_COLUMN_AUTHOR);
|
||||
item->setId(authorId, PCITEM_COLUMN_AUTHOR, false);
|
||||
|
||||
text = QString::number(comment.mScore);
|
||||
item->setText(PCITEM_COLUMN_SCORE, text);
|
||||
|
@ -28,6 +28,7 @@
|
||||
|
||||
#include <math.h>
|
||||
#include "GxsIdDetails.h"
|
||||
#include "retroshare-gui/RsAutoUpdatePage.h"
|
||||
|
||||
#include <retroshare/rspeers.h>
|
||||
|
||||
@ -119,57 +120,59 @@ void GxsIdDetails::connectObject_locked(QObject *object, bool doConnect)
|
||||
void GxsIdDetails::timerEvent(QTimerEvent *event)
|
||||
{
|
||||
if (event->timerId() == mCheckTimerId) {
|
||||
/* Stop timer */
|
||||
killTimer(mCheckTimerId);
|
||||
mCheckTimerId = 0;
|
||||
if (!RsAutoUpdatePage::eventsLocked()) {
|
||||
/* Stop timer */
|
||||
killTimer(mCheckTimerId);
|
||||
mCheckTimerId = 0;
|
||||
|
||||
if (rsIdentity) {
|
||||
QMutexLocker lock(&mMutex);
|
||||
if (rsIdentity) {
|
||||
QMutexLocker lock(&mMutex);
|
||||
|
||||
if (!mPendingData.empty()) {
|
||||
/* Check pending id's */
|
||||
QList<CallbackData>::iterator dataIt;
|
||||
for (dataIt = mPendingData.begin(); dataIt != mPendingData.end(); ) {
|
||||
CallbackData &pendingData = *dataIt;
|
||||
if (!mPendingData.empty()) {
|
||||
/* Check pending id's */
|
||||
QList<CallbackData>::iterator dataIt;
|
||||
for (dataIt = mPendingData.begin(); dataIt != mPendingData.end(); ) {
|
||||
CallbackData &pendingData = *dataIt;
|
||||
|
||||
RsIdentityDetails details;
|
||||
if (rsIdentity->getIdDetails(pendingData.mId, details)) {
|
||||
/* Got details */
|
||||
pendingData.mCallback(GXS_ID_DETAILS_TYPE_DONE, details, pendingData.mObject, pendingData.mData);
|
||||
RsIdentityDetails details;
|
||||
if (rsIdentity->getIdDetails(pendingData.mId, details)) {
|
||||
/* Got details */
|
||||
pendingData.mCallback(GXS_ID_DETAILS_TYPE_DONE, details, pendingData.mObject, pendingData.mData);
|
||||
|
||||
QObject *object = pendingData.mObject;
|
||||
dataIt = mPendingData.erase(dataIt);
|
||||
connectObject_locked(object, false);
|
||||
QObject *object = pendingData.mObject;
|
||||
dataIt = mPendingData.erase(dataIt);
|
||||
connectObject_locked(object, false);
|
||||
|
||||
continue;
|
||||
continue;
|
||||
}
|
||||
|
||||
if (++pendingData.mAttempt > MAX_ATTEMPTS) {
|
||||
/* Max attempts reached, stop trying */
|
||||
details.mId = pendingData.mId;
|
||||
pendingData.mCallback(GXS_ID_DETAILS_TYPE_FAILED, details, pendingData.mObject, pendingData.mData);
|
||||
|
||||
QObject *object = pendingData.mObject;
|
||||
dataIt = mPendingData.erase(dataIt);
|
||||
connectObject_locked(object, false);
|
||||
|
||||
continue;
|
||||
}
|
||||
|
||||
++dataIt;
|
||||
}
|
||||
|
||||
if (++pendingData.mAttempt > MAX_ATTEMPTS) {
|
||||
/* Max attempts reached, stop trying */
|
||||
details.mId = pendingData.mId;
|
||||
pendingData.mCallback(GXS_ID_DETAILS_TYPE_FAILED, details, pendingData.mObject, pendingData.mData);
|
||||
|
||||
QObject *object = pendingData.mObject;
|
||||
dataIt = mPendingData.erase(dataIt);
|
||||
connectObject_locked(object, false);
|
||||
|
||||
continue;
|
||||
}
|
||||
|
||||
++dataIt;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
QMutexLocker lock(&mMutex);
|
||||
QMutexLocker lock(&mMutex);
|
||||
|
||||
if (mPendingData.empty()) {
|
||||
/* All done */
|
||||
mInstance = NULL;
|
||||
deleteLater();
|
||||
} else {
|
||||
/* Start timer */
|
||||
doStartTimer();
|
||||
if (mPendingData.empty()) {
|
||||
/* All done */
|
||||
mInstance = NULL;
|
||||
deleteLater();
|
||||
} else {
|
||||
/* Start timer */
|
||||
doStartTimer();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -21,6 +21,7 @@
|
||||
*
|
||||
*/
|
||||
|
||||
#include "rshare.h"
|
||||
#include "GxsIdTreeWidgetItem.h"
|
||||
#include "GxsIdDetails.h"
|
||||
#include "util/HandleRichText.h"
|
||||
@ -40,68 +41,89 @@ GxsIdRSTreeWidgetItem::GxsIdRSTreeWidgetItem(const RSTreeWidgetItemCompareRole *
|
||||
|
||||
void GxsIdRSTreeWidgetItem::init()
|
||||
{
|
||||
mIdFound = false;
|
||||
mRetryWhenFailed = false;
|
||||
}
|
||||
|
||||
static void fillGxsIdRSTreeWidgetItemCallback(GxsIdDetailsType type, const RsIdentityDetails &details, QObject *object, const QVariant &/*data*/)
|
||||
{
|
||||
GxsIdRSTreeWidgetItem *item = dynamic_cast<GxsIdRSTreeWidgetItem*>(object);
|
||||
if (!item) {
|
||||
return;
|
||||
}
|
||||
GxsIdRSTreeWidgetItem *item = dynamic_cast<GxsIdRSTreeWidgetItem*>(object);
|
||||
if (!item) {
|
||||
return;
|
||||
}
|
||||
|
||||
QString toolTip;
|
||||
QList<QIcon> icons;
|
||||
QString toolTip;
|
||||
QList<QIcon> icons;
|
||||
|
||||
switch (type) {
|
||||
case GXS_ID_DETAILS_TYPE_EMPTY:
|
||||
case GXS_ID_DETAILS_TYPE_FAILED:
|
||||
break;
|
||||
switch (type) {
|
||||
case GXS_ID_DETAILS_TYPE_EMPTY:
|
||||
item->processResult(true);
|
||||
break;
|
||||
|
||||
case GXS_ID_DETAILS_TYPE_LOADING:
|
||||
icons.push_back(GxsIdDetails::getLoadingIcon(details.mId));
|
||||
break;
|
||||
case GXS_ID_DETAILS_TYPE_FAILED:
|
||||
item->processResult(false);
|
||||
break;
|
||||
|
||||
case GXS_ID_DETAILS_TYPE_DONE:
|
||||
GxsIdDetails::getIcons(details, icons);
|
||||
break;
|
||||
}
|
||||
toolTip = GxsIdDetails::getComment(details);
|
||||
case GXS_ID_DETAILS_TYPE_LOADING:
|
||||
icons.push_back(GxsIdDetails::getLoadingIcon(details.mId));
|
||||
break;
|
||||
|
||||
int column = item->idColumn();
|
||||
case GXS_ID_DETAILS_TYPE_DONE:
|
||||
GxsIdDetails::getIcons(details, icons);
|
||||
item->processResult(true);
|
||||
break;
|
||||
}
|
||||
toolTip = GxsIdDetails::getComment(details);
|
||||
|
||||
item->setText(column, GxsIdDetails::getNameForType(type, details));
|
||||
item->setData(column, Qt::UserRole, QString::fromStdString(details.mId.toStdString()));
|
||||
int column = item->idColumn();
|
||||
|
||||
QPixmap combinedPixmap;
|
||||
if (!icons.empty()) {
|
||||
GxsIdDetails::GenerateCombinedPixmap(combinedPixmap, icons, 16);
|
||||
}
|
||||
item->setData(column, Qt::DecorationRole, combinedPixmap);
|
||||
QImage pix ;
|
||||
item->setText(column, GxsIdDetails::getNameForType(type, details));
|
||||
item->setData(column, Qt::UserRole, QString::fromStdString(details.mId.toStdString()));
|
||||
|
||||
if(details.mAvatar.mSize == 0 || !pix.loadFromData(details.mAvatar.mData, details.mAvatar.mSize, "PNG"))
|
||||
pix = GxsIdDetails::makeDefaultIcon(details.mId);
|
||||
QPixmap combinedPixmap;
|
||||
if (!icons.empty()) {
|
||||
GxsIdDetails::GenerateCombinedPixmap(combinedPixmap, icons, 16);
|
||||
}
|
||||
item->setData(column, Qt::DecorationRole, combinedPixmap);
|
||||
QImage pix ;
|
||||
|
||||
QString embeddedImage ;
|
||||
if(details.mAvatar.mSize == 0 || !pix.loadFromData(details.mAvatar.mData, details.mAvatar.mSize, "PNG"))
|
||||
pix = GxsIdDetails::makeDefaultIcon(details.mId);
|
||||
|
||||
if(RsHtml::makeEmbeddedImage(pix.scaled(QSize(64,64),Qt::KeepAspectRatio,Qt::SmoothTransformation),embeddedImage,128*128))
|
||||
toolTip = "<table><tr><td>"+embeddedImage+"</td><td>" +toolTip+ "</td></table>" ;
|
||||
QString embeddedImage ;
|
||||
|
||||
item->setToolTip(column, toolTip);
|
||||
if(RsHtml::makeEmbeddedImage(pix.scaled(QSize(64,64),Qt::KeepAspectRatio,Qt::SmoothTransformation),embeddedImage,128*128))
|
||||
toolTip = "<table><tr><td>"+embeddedImage+"</td><td>" +toolTip+ "</td></table>" ;
|
||||
|
||||
item->setToolTip(column, toolTip);
|
||||
}
|
||||
|
||||
void GxsIdRSTreeWidgetItem::setId(const RsGxsId &id, int column)
|
||||
void GxsIdRSTreeWidgetItem::setId(const RsGxsId &id, int column, bool retryWhenFailed)
|
||||
{
|
||||
//std::cerr << " GxsIdRSTreeWidgetItem::setId(" << id << "," << column << ")";
|
||||
//std::cerr << std::endl;
|
||||
|
||||
if (mColumn == column && mId == id) {
|
||||
return;
|
||||
if (mIdFound) {
|
||||
if (mColumn == column && mId == id) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
mIdFound = false;
|
||||
mRetryWhenFailed = retryWhenFailed;
|
||||
|
||||
mId = id;
|
||||
mColumn = column;
|
||||
|
||||
startProcess();
|
||||
}
|
||||
|
||||
void GxsIdRSTreeWidgetItem::startProcess()
|
||||
{
|
||||
if (mRetryWhenFailed) {
|
||||
disconnect(rApp, SIGNAL(minuteTick()), this, SLOT(startProcess()));
|
||||
}
|
||||
|
||||
GxsIdDetails::process(mId, fillGxsIdRSTreeWidgetItemCallback, this);
|
||||
}
|
||||
|
||||
@ -110,3 +132,13 @@ bool GxsIdRSTreeWidgetItem::getId(RsGxsId &id)
|
||||
id = mId;
|
||||
return true;
|
||||
}
|
||||
|
||||
void GxsIdRSTreeWidgetItem::processResult(bool success)
|
||||
{
|
||||
mIdFound = success;
|
||||
|
||||
if (!mIdFound && mRetryWhenFailed) {
|
||||
/* Try again */
|
||||
connect(rApp, SIGNAL(minuteTick()), this, SLOT(startProcess()));
|
||||
}
|
||||
}
|
||||
|
@ -42,16 +42,22 @@ public:
|
||||
GxsIdRSTreeWidgetItem(const RSTreeWidgetItemCompareRole *compareRole, QTreeWidget *parent = NULL);
|
||||
GxsIdRSTreeWidgetItem(const RSTreeWidgetItemCompareRole *compareRole, QTreeWidgetItem *parent);
|
||||
|
||||
void setId(const RsGxsId &id, int column);
|
||||
void setId(const RsGxsId &id, int column, bool retryWhenFailed);
|
||||
bool getId(RsGxsId &id);
|
||||
|
||||
int idColumn() { return mColumn; }
|
||||
void processResult(bool success);
|
||||
|
||||
private slots:
|
||||
void startProcess();
|
||||
|
||||
private:
|
||||
void init();
|
||||
|
||||
RsGxsId mId;
|
||||
int mColumn;
|
||||
bool mIdFound;
|
||||
bool mRetryWhenFailed;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
@ -850,7 +850,7 @@ QTreeWidgetItem *GxsForumThreadWidget::convertMsgToThreadWidget(const RsGxsForum
|
||||
item->setText(COLUMN_THREAD_DATE, text);
|
||||
item->setData(COLUMN_THREAD_DATE, ROLE_THREAD_SORT, sort);
|
||||
|
||||
item->setId(msg.mMeta.mAuthorId, COLUMN_THREAD_AUTHOR);
|
||||
item->setId(msg.mMeta.mAuthorId, COLUMN_THREAD_AUTHOR, false);
|
||||
item->setData(COLUMN_THREAD_DATA, ROLE_THREAD_AUTHOR, QString::fromStdString(msg.mMeta.mAuthorId.toStdString()));
|
||||
//#TODO
|
||||
#if 0
|
||||
@ -1013,7 +1013,7 @@ static void copyItem(QTreeWidgetItem *item, const QTreeWidgetItem *newItem)
|
||||
GxsIdRSTreeWidgetItem *gxsIdItem = dynamic_cast<GxsIdRSTreeWidgetItem*>(item);
|
||||
if (gxsIdItem) {
|
||||
/* Set new gxs id */
|
||||
gxsIdItem->setId(RsGxsId(authorId.toStdString()), i);
|
||||
gxsIdItem->setId(RsGxsId(authorId.toStdString()), i, false);
|
||||
} else {
|
||||
/* Copy text */
|
||||
item->setText(i, newItem->text(i));
|
||||
|
@ -120,6 +120,11 @@ Rshare::Rshare(QStringList args, int &argc, char **argv, const QString &dir)
|
||||
connect(timer, SIGNAL(timeout()), this, SLOT(blinkTimer()));
|
||||
timer->start();
|
||||
|
||||
timer = new QTimer(this);
|
||||
timer->setInterval(60000);
|
||||
connect(timer, SIGNAL(timeout()), this, SIGNAL(minuteTick()));
|
||||
timer->start();
|
||||
|
||||
/* Read in all our command-line arguments. */
|
||||
parseArguments(args);
|
||||
|
||||
|
@ -142,6 +142,8 @@ signals:
|
||||
void blink(bool on);
|
||||
/** Global timer every second */
|
||||
void secondTick();
|
||||
/** Global timer every minute */
|
||||
void minuteTick();
|
||||
|
||||
private slots:
|
||||
/** Called when the application's main event loop has started. This method
|
||||
|
Loading…
Reference in New Issue
Block a user