mirror of
https://github.com/RetroShare/RetroShare.git
synced 2025-07-30 01:38:51 -04:00
Merge "Switched security items to new notification system #1735" csoler-v0.6-SecNotification
This commit is contained in:
commit
c96223a2a8
79 changed files with 1526 additions and 1991 deletions
File diff suppressed because it is too large
Load diff
|
@ -56,7 +56,7 @@ class RsFeedItem;
|
|||
class FeedNotify;
|
||||
class FeedItem;
|
||||
|
||||
class NewsFeed : public RsAutoUpdatePage, public FeedHolder, public TokenResponse
|
||||
class NewsFeed : public MainPage,public FeedHolder
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
|
@ -81,7 +81,7 @@ public:
|
|||
static void testFeeds(uint notifyFlags);
|
||||
static void testFeed(FeedNotify *feedNotify);
|
||||
|
||||
virtual void updateDisplay();
|
||||
void handleEvent(std::shared_ptr<const RsEvent> event); // get events from libretroshare
|
||||
|
||||
signals:
|
||||
void newsFeedChanged(int count);
|
||||
|
@ -89,82 +89,36 @@ signals:
|
|||
protected:
|
||||
void processSettings(bool load);
|
||||
|
||||
/* TokenResponse */
|
||||
virtual void loadRequest(const TokenQueue *queue, const TokenRequest &req);
|
||||
|
||||
private slots:
|
||||
// void toggleChanMsgItems(bool on);
|
||||
void feedoptions();
|
||||
void sortChanged(int index);
|
||||
|
||||
void sendNewsFeedChanged();
|
||||
|
||||
private:
|
||||
void handleEvent_main_thread(std::shared_ptr<const RsEvent> event);
|
||||
|
||||
void handleSecurityEvent(std::shared_ptr<const RsEvent> event);
|
||||
void handleConnectionEvent(std::shared_ptr<const RsEvent> event);
|
||||
void handleCircleEvent(std::shared_ptr<const RsEvent> event);
|
||||
void handleForumEvent(std::shared_ptr<const RsEvent> event);
|
||||
void handleMailEvent(std::shared_ptr<const RsEvent> event);
|
||||
void handlePostedEvent(std::shared_ptr<const RsEvent> event);
|
||||
void handleChannelEvent(std::shared_ptr<const RsEvent> event);
|
||||
|
||||
void addFeedItem(FeedItem *item);
|
||||
void addFeedItemIfUnique(FeedItem *item, int itemType, const std::string& id1, const std::string& id2, const std::string& id3, const std::string& id4, bool replace);
|
||||
void remUniqueFeedItem(FeedItem *item, int itemType, const std::string& id1, const std::string& id2, const std::string& id3, const std::string& id4);
|
||||
|
||||
void addFeedItemPeerConnect(const RsFeedItem &fi);
|
||||
void addFeedItemPeerDisconnect(const RsFeedItem &fi);
|
||||
void addFeedItemPeerHello(const RsFeedItem &fi);
|
||||
void addFeedItemPeerNew(const RsFeedItem &fi);
|
||||
void addFeedItemPeerOffset(const RsFeedItem &fi);
|
||||
|
||||
void addFeedItemSecurityConnectAttempt(const RsFeedItem &fi);
|
||||
void addFeedItemSecurityAuthDenied(const RsFeedItem &fi);
|
||||
void addFeedItemSecurityUnknownIn(const RsFeedItem &fi);
|
||||
void addFeedItemSecurityUnknownOut(const RsFeedItem &fi);
|
||||
void addFeedItemSecurityIpBlacklisted(const RsFeedItem &fi, bool isTest);
|
||||
void addFeedItemSecurityWrongExternalIpReported(const RsFeedItem &fi, bool isTest);
|
||||
|
||||
void addFeedItemChannelNew(const RsFeedItem &fi);
|
||||
// void addFeedItemChannelUpdate(const RsFeedItem &fi);
|
||||
void addFeedItemChannelMsg(const RsFeedItem &fi);
|
||||
void addFeedItemChannelPublishKey(const RsFeedItem &fi);
|
||||
|
||||
void addFeedItemForumNew(const RsFeedItem &fi);
|
||||
// void addFeedItemForumUpdate(const RsFeedItem &fi);
|
||||
void addFeedItemForumMsg(const RsFeedItem &fi);
|
||||
|
||||
void addFeedItemPostedNew(const RsFeedItem &fi);
|
||||
// void addFeedItemPostedUpdate(const RsFeedItem &fi);
|
||||
void addFeedItemPostedMsg(const RsFeedItem &fi);
|
||||
|
||||
void addFeedItemIfUnique(FeedItem *item, bool replace);
|
||||
void remUniqueFeedItem(FeedItem *item);
|
||||
#if 0
|
||||
void addFeedItemBlogNew(const RsFeedItem &fi);
|
||||
void addFeedItemBlogMsg(const RsFeedItem &fi);
|
||||
#endif
|
||||
|
||||
void addFeedItemChatNew(const RsFeedItem &fi, bool addWithoutCheck);
|
||||
void addFeedItemMessage(const RsFeedItem &fi);
|
||||
void addFeedItemFilesNew(const RsFeedItem &fi);
|
||||
|
||||
void addFeedItemCircleMembReq(const RsFeedItem &fi);
|
||||
void remFeedItemCircleMembReq(const RsFeedItem &fi);
|
||||
void addFeedItemCircleInvitRec(const RsFeedItem &fi);
|
||||
|
||||
virtual void loadChannelGroup(const uint32_t &token);
|
||||
virtual void loadChannelPost(const uint32_t &token);
|
||||
virtual void loadChannelPublishKey(const uint32_t &token);
|
||||
|
||||
virtual void loadForumGroup(const uint32_t &token);
|
||||
virtual void loadForumMessage(const uint32_t &token);
|
||||
virtual void loadForumPublishKey(const uint32_t &token);
|
||||
|
||||
virtual void loadPostedGroup(const uint32_t &token);
|
||||
virtual void loadPostedMessage(const uint32_t &token);
|
||||
|
||||
virtual void loadCircleGroup(const uint32_t &token);
|
||||
virtual void loadCircleMessage(const uint32_t &token);
|
||||
|
||||
private:
|
||||
TokenQueue *mTokenQueueChannel;
|
||||
TokenQueue *mTokenQueueCircle;
|
||||
TokenQueue *mTokenQueueForum;
|
||||
TokenQueue *mTokenQueuePosted;
|
||||
|
||||
/* UI - from Designer */
|
||||
Ui::NewsFeed *ui;
|
||||
|
||||
RsEventsHandlerId_t mEventHandlerId;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
|
@ -49,6 +49,7 @@ public:
|
|||
const RsPostedPost &getPost() const;
|
||||
RsPostedPost &post();
|
||||
|
||||
uint64_t uniqueIdentifier() const override { return hash_64bits("PostedItem " + mMessageId.toStdString()); }
|
||||
protected:
|
||||
/* FeedItem */
|
||||
virtual void doExpand(bool open);
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>825</width>
|
||||
<height>337</height>
|
||||
<height>339</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
|
@ -529,10 +529,22 @@
|
|||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="readAndClearButton">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>50</width>
|
||||
<height>44</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>24</width>
|
||||
<height>16777215</height>
|
||||
<width>50</width>
|
||||
<height>44</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="focusPolicy">
|
||||
|
@ -549,10 +561,22 @@
|
|||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="clearButton">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>50</width>
|
||||
<height>44</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>24</width>
|
||||
<height>16777215</height>
|
||||
<width>50</width>
|
||||
<height>44</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="focusPolicy">
|
||||
|
@ -692,9 +716,9 @@
|
|||
</customwidget>
|
||||
</customwidgets>
|
||||
<resources>
|
||||
<include location="Posted_images.qrc"/>
|
||||
<include location="../images.qrc"/>
|
||||
<include location="../icons.qrc"/>
|
||||
<include location="../images.qrc"/>
|
||||
<include location="Posted_images.qrc"/>
|
||||
</resources>
|
||||
<connections/>
|
||||
</ui>
|
||||
|
|
|
@ -37,6 +37,8 @@
|
|||
#define POSTED_DEFAULT_LISTING_LENGTH 10
|
||||
#define POSTED_MAX_INDEX 10000
|
||||
|
||||
#define DEBUG_POSTED_LIST_WIDGET
|
||||
|
||||
#define TOPIC_DEFAULT_IMAGE ":/icons/png/posted.png"
|
||||
|
||||
/** Constructor */
|
||||
|
@ -143,15 +145,19 @@ QScrollArea *PostedListWidget::getScrollArea()
|
|||
|
||||
void PostedListWidget::deleteFeedItem(QWidget */*item*/, uint32_t /*type*/)
|
||||
{
|
||||
#ifdef DEBUG_POSTED_LIST_WIDGET
|
||||
std::cerr << "PostedListWidget::deleteFeedItem() Nah";
|
||||
std::cerr << std::endl;
|
||||
#endif
|
||||
return;
|
||||
}
|
||||
|
||||
void PostedListWidget::openChat(const RsPeerId & /*peerId*/)
|
||||
{
|
||||
#ifdef DEBUG_POSTED_LIST_WIDGET
|
||||
std::cerr << "PostedListWidget::openChat() Nah";
|
||||
std::cerr << std::endl;
|
||||
#endif
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -207,8 +213,10 @@ void PostedListWidget::getRankings(int i)
|
|||
if (groupId().isNull())
|
||||
return;
|
||||
|
||||
#ifdef DEBUG_POSTED_LIST_WIDGET
|
||||
std::cerr << "PostedListWidget::getRankings()";
|
||||
std::cerr << std::endl;
|
||||
#endif
|
||||
|
||||
int oldSortMethod = mSortMethod;
|
||||
|
||||
|
@ -268,6 +276,7 @@ void PostedListWidget::submitVote(const RsGxsGrpMsgIdPair &msgId, bool up)
|
|||
vote.mVoteType = GXS_VOTE_DOWN;
|
||||
}//if (up)
|
||||
|
||||
#ifdef DEBUG_POSTED_LIST_WIDGET
|
||||
std::cerr << "PostedListWidget::submitVote()";
|
||||
std::cerr << std::endl;
|
||||
|
||||
|
@ -275,6 +284,7 @@ void PostedListWidget::submitVote(const RsGxsGrpMsgIdPair &msgId, bool up)
|
|||
std::cerr << "ThreadId : " << vote.mMeta.mThreadId << std::endl;
|
||||
std::cerr << "ParentId : " << vote.mMeta.mParentId << std::endl;
|
||||
std::cerr << "AuthorId : " << vote.mMeta.mAuthorId << std::endl;
|
||||
#endif
|
||||
|
||||
uint32_t token;
|
||||
rsPosted->createNewVote(token, vote);
|
||||
|
@ -464,8 +474,10 @@ static bool CmpPINew(const GxsFeedItem *a, const GxsFeedItem *b)
|
|||
void PostedListWidget::applyRanking()
|
||||
{
|
||||
/* uses current settings to sort posts, then add to layout */
|
||||
#ifdef DEBUG_POSTED_LIST_WIDGET
|
||||
std::cerr << "PostedListWidget::applyRanking()";
|
||||
std::cerr << std::endl;
|
||||
#endif
|
||||
|
||||
shallowClearPosts();
|
||||
|
||||
|
@ -474,25 +486,33 @@ void PostedListWidget::applyRanking()
|
|||
{
|
||||
default:
|
||||
case RsPosted::HotRankType:
|
||||
#ifdef DEBUG_POSTED_LIST_WIDGET
|
||||
std::cerr << "PostedListWidget::applyRanking() HOT";
|
||||
std::cerr << std::endl;
|
||||
#endif
|
||||
qSort(mPostItems.begin(), mPostItems.end(), CmpPIHot);
|
||||
break;
|
||||
case RsPosted::NewRankType:
|
||||
#ifdef DEBUG_POSTED_LIST_WIDGET
|
||||
std::cerr << "PostedListWidget::applyRanking() NEW";
|
||||
std::cerr << std::endl;
|
||||
#endif
|
||||
qSort(mPostItems.begin(), mPostItems.end(), CmpPINew);
|
||||
break;
|
||||
case RsPosted::TopRankType:
|
||||
#ifdef DEBUG_POSTED_LIST_WIDGET
|
||||
std::cerr << "PostedListWidget::applyRanking() TOP";
|
||||
std::cerr << std::endl;
|
||||
#endif
|
||||
qSort(mPostItems.begin(), mPostItems.end(), CmpPITop);
|
||||
break;
|
||||
}
|
||||
mLastSortMethod = mSortMethod;
|
||||
|
||||
#ifdef DEBUG_POSTED_LIST_WIDGET
|
||||
std::cerr << "PostedListWidget::applyRanking() Sorted mPostList";
|
||||
std::cerr << std::endl;
|
||||
#endif
|
||||
|
||||
/* go through list (skipping out-of-date items) to get */
|
||||
QLayout *alayout = ui->scrollAreaWidgetContents->layout();
|
||||
|
@ -500,42 +520,54 @@ void PostedListWidget::applyRanking()
|
|||
time_t min_ts = 0;
|
||||
foreach (PostedItem *item, mPostItems)
|
||||
{
|
||||
#ifdef DEBUG_POSTED_LIST_WIDGET
|
||||
std::cerr << "PostedListWidget::applyRanking() Item: " << item;
|
||||
std::cerr << std::endl;
|
||||
#endif
|
||||
|
||||
if (item->getPost().mMeta.mPublishTs < min_ts)
|
||||
{
|
||||
#ifdef DEBUG_POSTED_LIST_WIDGET
|
||||
std::cerr << "\t Skipping OLD";
|
||||
std::cerr << std::endl;
|
||||
#endif
|
||||
item->hide();
|
||||
continue;
|
||||
}
|
||||
|
||||
if (counter >= mPostIndex + mPostShow)
|
||||
{
|
||||
#ifdef DEBUG_POSTED_LIST_WIDGET
|
||||
std::cerr << "\t END - Counter too high";
|
||||
std::cerr << std::endl;
|
||||
#endif
|
||||
item->hide();
|
||||
}
|
||||
else if (counter >= mPostIndex)
|
||||
{
|
||||
#ifdef DEBUG_POSTED_LIST_WIDGET
|
||||
std::cerr << "\t Adding to Layout";
|
||||
std::cerr << std::endl;
|
||||
#endif
|
||||
/* add it in! */
|
||||
alayout->addWidget(item);
|
||||
item->show();
|
||||
}
|
||||
else
|
||||
{
|
||||
#ifdef DEBUG_POSTED_LIST_WIDGET
|
||||
std::cerr << "\t Skipping to Low";
|
||||
std::cerr << std::endl;
|
||||
#endif
|
||||
item->hide();
|
||||
}
|
||||
++counter;
|
||||
}
|
||||
|
||||
#ifdef DEBUG_POSTED_LIST_WIDGET
|
||||
std::cerr << "PostedListWidget::applyRanking() Loaded New Order";
|
||||
std::cerr << std::endl;
|
||||
#endif
|
||||
|
||||
// trigger a redraw.
|
||||
ui->scrollAreaWidgetContents->update();
|
||||
|
@ -564,7 +596,9 @@ bool PostedListWidget::navigatePostItem(const RsGxsMessageId & /*msgId*/)
|
|||
|
||||
void PostedListWidget::shallowClearPosts()
|
||||
{
|
||||
#ifdef DEBUG_POSTED_LIST_WIDGET
|
||||
std::cerr << "PostedListWidget::shallowClearPosts()" << std::endl;
|
||||
#endif
|
||||
|
||||
std::list<PostedItem *> postedItems;
|
||||
std::list<PostedItem *>::iterator pit;
|
||||
|
@ -576,24 +610,30 @@ void PostedListWidget::shallowClearPosts()
|
|||
QLayoutItem *litem = alayout->itemAt(i);
|
||||
if (!litem)
|
||||
{
|
||||
#ifdef DEBUG_POSTED_LIST_WIDGET
|
||||
std::cerr << "PostedListWidget::shallowClearPosts() missing litem";
|
||||
std::cerr << std::endl;
|
||||
#endif
|
||||
continue;
|
||||
}
|
||||
|
||||
PostedItem *item = dynamic_cast<PostedItem *>(litem->widget());
|
||||
if (item)
|
||||
{
|
||||
#ifdef DEBUG_POSTED_LIST_WIDGET
|
||||
std::cerr << "PostedListWidget::shallowClearPosts() item: " << item;
|
||||
std::cerr << std::endl;
|
||||
#endif
|
||||
|
||||
postedItems.push_back(item);
|
||||
}
|
||||
#ifdef DEBUG_POSTED_LIST_WIDGET
|
||||
else
|
||||
{
|
||||
std::cerr << "PostedListWidget::shallowClearPosts() Found Child, which is not a PostedItem???";
|
||||
std::cerr << std::endl;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
for(pit = postedItems.begin(); pit != postedItems.end(); ++pit)
|
||||
|
@ -646,15 +686,19 @@ void PostedListWidget::insertPosts(const uint32_t &token)
|
|||
// modify post content
|
||||
if(mPosts.find(p.mMeta.mMsgId) != mPosts.end())
|
||||
{
|
||||
#ifdef DEBUG_POSTED_LIST_WIDGET
|
||||
std::cerr << "PostedListWidget::updateCurrentDisplayComplete() updating MsgId: " << p.mMeta.mMsgId;
|
||||
std::cerr << std::endl;
|
||||
#endif
|
||||
|
||||
mPosts[p.mMeta.mMsgId]->setPost(p);
|
||||
}
|
||||
else
|
||||
{
|
||||
#ifdef DEBUG_POSTED_LIST_WIDGET
|
||||
std::cerr << "PostedListWidget::updateCurrentDisplayComplete() loading New MsgId: " << p.mMeta.mMsgId;
|
||||
std::cerr << std::endl;
|
||||
#endif
|
||||
/* insert new entry */
|
||||
loadPost(p);
|
||||
}
|
||||
|
@ -689,8 +733,10 @@ void PostedListWidget::setAllMessagesReadDo(bool read, uint32_t &token)
|
|||
|
||||
void PostedListWidget::loadRequest(const TokenQueue *queue, const TokenRequest &req)
|
||||
{
|
||||
#ifdef DEBUG_POSTED_LIST_WIDGET
|
||||
std::cerr << "PostedListWidget::loadRequest() UserType: " << req.mUserType;
|
||||
std::cerr << std::endl;
|
||||
#endif
|
||||
|
||||
if (queue == mTokenQueue)
|
||||
{
|
||||
|
|
|
@ -578,7 +578,7 @@ RetroShareLink RetroShareLink::createCertificate(const RsPeerId& ssl_id)
|
|||
|
||||
return link;
|
||||
}
|
||||
RetroShareLink RetroShareLink::createUnknwonSslCertificate(const RsPeerId& sslId, const RsPgpId& gpgId)
|
||||
RetroShareLink RetroShareLink::createUnknownSslCertificate(const RsPeerId& sslId, const RsPgpId& gpgId)
|
||||
{
|
||||
RetroShareLink link;
|
||||
link.clear();
|
||||
|
|
|
@ -90,7 +90,7 @@ class RetroShareLink
|
|||
static RetroShareLink createMessage(const RsPeerId &peerId, const QString& subject);
|
||||
static RetroShareLink createMessage(const RsGxsId &peerId, const QString& subject);
|
||||
static RetroShareLink createCertificate(const RsPeerId &ssl_id) ;
|
||||
static RetroShareLink createUnknwonSslCertificate(const RsPeerId &sslId, const RsPgpId &gpgId = RsPgpId()) ;
|
||||
static RetroShareLink createUnknownSslCertificate(const RsPeerId &sslId, const RsPgpId &gpgId = RsPgpId()) ;
|
||||
static RetroShareLink createExtraFile(const QString& name, uint64_t size, const QString& hash, const QString& ssl_id);
|
||||
static RetroShareLink createPublicMsgInvite(time_t time_stamp,const QString& pgp_id,const QString& hash) ;
|
||||
static RetroShareLink createIdentity(const RsGxsId& gxs_id,const QString& name,const QString& radix_data) ;
|
||||
|
|
|
@ -47,6 +47,7 @@
|
|||
#include "RSTreeWidgetItem.h"
|
||||
#include "StatusDefs.h"
|
||||
#include "util/misc.h"
|
||||
#include "util/qtthreadsutils.h"
|
||||
#include "vmessagebox.h"
|
||||
#include "util/QtVersion.h"
|
||||
#include "gui/chat/ChatUserNotify.h"
|
||||
|
@ -176,6 +177,9 @@ NewFriendList::NewFriendList(QWidget *parent) : /* RsAutoUpdatePage(5000,parent)
|
|||
ui->filterLineEdit->setPlaceholderText(tr("Search")) ;
|
||||
ui->filterLineEdit->showFilterIcon();
|
||||
|
||||
mEventHandlerId=0; // forces initialization
|
||||
rsEvents->registerEventsHandler( [this](std::shared_ptr<const RsEvent> e) { handleEvent(e); }, mEventHandlerId );
|
||||
|
||||
mModel = new RsFriendListModel();
|
||||
mProxyModel = new FriendListSortFilterProxyModel(ui->peerTreeWidget->header(),this);
|
||||
|
||||
|
@ -236,8 +240,6 @@ NewFriendList::NewFriendList(QWidget *parent) : /* RsAutoUpdatePage(5000,parent)
|
|||
|
||||
connect(NotifyQt::getInstance(), SIGNAL(friendsChanged()) , this, SLOT(forceUpdateDisplay()),Qt::QueuedConnection);
|
||||
connect(NotifyQt::getInstance(), SIGNAL(groupsChanged(int)) , this, SLOT(forceUpdateDisplay()),Qt::QueuedConnection);
|
||||
connect(NotifyQt::getInstance(), SIGNAL(peerConnected(const QString&)) , this, SLOT(forceUpdateDisplay()),Qt::QueuedConnection);
|
||||
connect(NotifyQt::getInstance(), SIGNAL(peerDisconnected(const QString&)), this, SLOT(forceUpdateDisplay()),Qt::QueuedConnection);
|
||||
|
||||
connect(ui->actionShowOfflineFriends, SIGNAL(triggered(bool)), this, SLOT(setShowUnconnected(bool)));
|
||||
connect(ui->actionShowState, SIGNAL(triggered(bool)), this, SLOT(setShowState(bool)) );
|
||||
|
@ -254,6 +256,17 @@ NewFriendList::NewFriendList(QWidget *parent) : /* RsAutoUpdatePage(5000,parent)
|
|||
|
||||
}
|
||||
|
||||
void NewFriendList::handleEvent(std::shared_ptr<const RsEvent> e)
|
||||
{
|
||||
if(e->mType == RsEventType::PEER_CONNECTION)
|
||||
{
|
||||
// /!\ The function we're in is called from a different thread. It's very important
|
||||
// to use this trick in order to avoid data races.
|
||||
|
||||
RsQThreadUtils::postToObject( [=]() { forceUpdateDisplay() ; }, this ) ;
|
||||
}
|
||||
}
|
||||
|
||||
NewFriendList::~NewFriendList()
|
||||
{
|
||||
delete ui;
|
||||
|
|
|
@ -95,6 +95,7 @@ private slots:
|
|||
|
||||
protected:
|
||||
void changeEvent(QEvent *e);
|
||||
void handleEvent(std::shared_ptr<const RsEvent> e);
|
||||
|
||||
private:
|
||||
Ui::NewFriendList *ui;
|
||||
|
@ -117,6 +118,7 @@ private:
|
|||
|
||||
// Settings for peer list display
|
||||
bool mShowState;
|
||||
RsEventsHandlerId_t mEventHandlerId;
|
||||
|
||||
std::set<RsNodeGroupId> openGroups;
|
||||
std::set<RsPgpId> openPeers;
|
||||
|
|
|
@ -28,7 +28,8 @@
|
|||
|
||||
#include <iostream>
|
||||
|
||||
#define COLUMN_FEED 0
|
||||
#define COLUMN_FEED 0
|
||||
#define COLUMN_IDENTIFIER 1
|
||||
|
||||
#define SINGLE_STEP 15
|
||||
|
||||
|
@ -74,6 +75,8 @@ RSFeedWidget::RSFeedWidget(QWidget *parent)
|
|||
ui->treeWidget->installEventFilter(this);
|
||||
|
||||
ui->treeWidget->setVerticalScrollBar(new RSFeedWidgetScrollBar);
|
||||
ui->treeWidget->setColumnCount(2);
|
||||
ui->treeWidget->setColumnHidden(COLUMN_IDENTIFIER,true);
|
||||
}
|
||||
|
||||
RSFeedWidget::~RSFeedWidget()
|
||||
|
@ -130,17 +133,14 @@ bool RSFeedWidget::eventFilter(QObject *object, QEvent *event)
|
|||
|
||||
void RSFeedWidget::feedAdded(FeedItem *feedItem, QTreeWidgetItem *treeItem)
|
||||
{
|
||||
mItems.insert(feedItem, treeItem);
|
||||
}
|
||||
|
||||
void RSFeedWidget::feedRemoved(FeedItem *feedItem)
|
||||
{
|
||||
mItems.remove(feedItem);
|
||||
}
|
||||
|
||||
void RSFeedWidget::feedsCleared()
|
||||
{
|
||||
mItems.clear();
|
||||
}
|
||||
|
||||
void RSFeedWidget::connectSignals(FeedItem *feedItem)
|
||||
|
@ -179,6 +179,7 @@ void RSFeedWidget::addFeedItem(FeedItem *feedItem, Qt::ItemDataRole sortRole, co
|
|||
QTreeWidgetItem *treeItem = new RSTreeWidgetItem(mFeedCompareRole);
|
||||
|
||||
treeItem->setData(COLUMN_FEED, sortRole, value);
|
||||
treeItem->setData(COLUMN_IDENTIFIER, Qt::DisplayRole, QString("%1").arg(feedItem->uniqueIdentifier(),8,16,QChar('0')));
|
||||
|
||||
ui->treeWidget->addTopLevelItem(treeItem);
|
||||
ui->treeWidget->setItemWidget(treeItem, 0, feedItem);
|
||||
|
@ -206,6 +207,7 @@ void RSFeedWidget::addFeedItem(FeedItem *feedItem, const QMap<Qt::ItemDataRole,
|
|||
for (it = sort.begin(); it != sort.end(); ++it) {
|
||||
treeItem->setData(COLUMN_FEED, it.key(), it.value());
|
||||
}
|
||||
treeItem->setData(COLUMN_IDENTIFIER, Qt::DisplayRole, QString("%1").arg(feedItem->uniqueIdentifier(),8,16,QChar('0')));
|
||||
|
||||
ui->treeWidget->addTopLevelItem(treeItem);
|
||||
ui->treeWidget->setItemWidget(treeItem, 0, feedItem);
|
||||
|
@ -223,14 +225,13 @@ void RSFeedWidget::addFeedItem(FeedItem *feedItem, const QMap<Qt::ItemDataRole,
|
|||
|
||||
void RSFeedWidget::setSort(FeedItem *feedItem, Qt::ItemDataRole sortRole, const QVariant &value)
|
||||
{
|
||||
if (!feedItem) {
|
||||
if (!feedItem)
|
||||
return;
|
||||
}
|
||||
|
||||
QTreeWidgetItem *treeItem = findTreeWidgetItem(feedItem);
|
||||
if (!treeItem) {
|
||||
QTreeWidgetItem *treeItem = findTreeWidgetItem(feedItem->uniqueIdentifier());
|
||||
|
||||
if (!treeItem)
|
||||
return;
|
||||
}
|
||||
|
||||
treeItem->setData(COLUMN_FEED, sortRole, value);
|
||||
}
|
||||
|
@ -241,10 +242,9 @@ void RSFeedWidget::setSort(FeedItem *feedItem, const QMap<Qt::ItemDataRole, QVar
|
|||
return;
|
||||
}
|
||||
|
||||
QTreeWidgetItem *treeItem = findTreeWidgetItem(feedItem);
|
||||
if (!treeItem) {
|
||||
QTreeWidgetItem *treeItem = findTreeWidgetItem(feedItem->uniqueIdentifier());
|
||||
if (!treeItem)
|
||||
return;
|
||||
}
|
||||
|
||||
QMap<Qt::ItemDataRole, QVariant>::const_iterator it;
|
||||
for (it = sort.begin(); it != sort.end(); ++it) {
|
||||
|
@ -388,13 +388,23 @@ void RSFeedWidget::removeFeedItem(FeedItem *feedItem)
|
|||
return;
|
||||
}
|
||||
|
||||
disconnectSignals(feedItem);
|
||||
QTreeWidgetItem *treeItem = findTreeWidgetItem(feedItem->uniqueIdentifier());
|
||||
|
||||
QTreeWidgetItem *treeItem = findTreeWidgetItem(feedItem);
|
||||
feedRemoved(feedItem);
|
||||
if (treeItem) {
|
||||
delete(treeItem);
|
||||
}
|
||||
if (treeItem)
|
||||
{
|
||||
int treeItem_index = ui->treeWidget->indexOfTopLevelItem(treeItem);
|
||||
|
||||
if(treeItem_index < 0)
|
||||
{
|
||||
std::cerr << "(EE) Cannot remove designated item \"" << feedItem->uniqueIdentifier() << "\": not found!" << std::endl;
|
||||
return ;
|
||||
}
|
||||
|
||||
feedRemoved(feedItem);
|
||||
disconnectSignals(feedItem);
|
||||
|
||||
delete ui->treeWidget->takeTopLevelItem(treeItem_index);
|
||||
}
|
||||
|
||||
if (!mCountChangedDisabled) {
|
||||
emit feedCountChanged();
|
||||
|
@ -418,40 +428,42 @@ void RSFeedWidget::feedItemDestroyed(FeedItem *feedItem)
|
|||
{
|
||||
/* No need to disconnect when object will be destroyed */
|
||||
|
||||
QTreeWidgetItem *treeItem = findTreeWidgetItem(feedItem);
|
||||
feedRemoved(feedItem);
|
||||
if (treeItem) {
|
||||
delete(treeItem);
|
||||
}
|
||||
QTreeWidgetItem *treeItem = findTreeWidgetItem(feedItem->uniqueIdentifier());
|
||||
|
||||
if (!mCountChangedDisabled) {
|
||||
feedRemoved(feedItem);
|
||||
if (treeItem)
|
||||
delete(treeItem);
|
||||
|
||||
if (!mCountChangedDisabled)
|
||||
emit feedCountChanged();
|
||||
}
|
||||
}
|
||||
|
||||
QTreeWidgetItem *RSFeedWidget::findTreeWidgetItem(FeedItem *feedItem)
|
||||
QTreeWidgetItem *RSFeedWidget::findTreeWidgetItem(uint64_t identifier)
|
||||
{
|
||||
QMap<FeedItem*, QTreeWidgetItem*>::iterator it = mItems.find(feedItem);
|
||||
if (it == mItems.end()) {
|
||||
return NULL;
|
||||
}
|
||||
QList<QTreeWidgetItem*> list = ui->treeWidget->findItems(QString("%1").arg(identifier,8,16,QChar('0')),Qt::MatchExactly,COLUMN_IDENTIFIER);
|
||||
|
||||
return it.value();
|
||||
if(list.empty())
|
||||
return nullptr;
|
||||
else if(list.size() == 1)
|
||||
return list.front();
|
||||
else
|
||||
{
|
||||
std::cerr << "(EE) More than a single item with identifier \"" << identifier << "\" in the feed tree widget. This shouldn't happen!" << std::endl;
|
||||
return nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
bool RSFeedWidget::scrollTo(FeedItem *feedItem, bool focus)
|
||||
{
|
||||
QTreeWidgetItem *item = findTreeWidgetItem(feedItem);
|
||||
if (!feedItem) {
|
||||
QTreeWidgetItem *item = findTreeWidgetItem(feedItem->uniqueIdentifier());
|
||||
if (!feedItem)
|
||||
return false;
|
||||
}
|
||||
|
||||
ui->treeWidget->scrollToItem(item);
|
||||
ui->treeWidget->setCurrentItem(item);
|
||||
|
||||
if (focus) {
|
||||
if (focus)
|
||||
ui->treeWidget->setFocus();
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
@ -476,25 +488,24 @@ void RSFeedWidget::withAll(RSFeedWidgetCallbackFunction callback, void *data)
|
|||
}
|
||||
}
|
||||
|
||||
FeedItem *RSFeedWidget::findFeedItem(RSFeedWidgetFindCallbackFunction callback, void *data)
|
||||
FeedItem *RSFeedWidget::findFeedItem(uint64_t identifier)
|
||||
{
|
||||
if (!callback) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
QTreeWidgetItemIterator it(ui->treeWidget);
|
||||
QTreeWidgetItem *treeItem;
|
||||
QTreeWidgetItem *treeItem=NULL;
|
||||
|
||||
// this search could probably be automatised by giving the tree items the identifier as data for some specific role, then calling QTreeWidget::findItems()
|
||||
#warning TODO
|
||||
while ((treeItem = *it) != NULL) {
|
||||
++it;
|
||||
|
||||
FeedItem *feedItem = feedItemFromTreeItem(treeItem);
|
||||
if (!feedItem) {
|
||||
if (!feedItem)
|
||||
continue;
|
||||
}
|
||||
|
||||
if (callback(feedItem, data)) {
|
||||
uint64_t id = feedItem->uniqueIdentifier();
|
||||
|
||||
if (id == identifier)
|
||||
return feedItem;
|
||||
}
|
||||
}
|
||||
|
||||
return NULL;
|
||||
|
|
|
@ -71,7 +71,7 @@ public:
|
|||
bool scrollTo(FeedItem *feedItem, bool focus);
|
||||
|
||||
void withAll(RSFeedWidgetCallbackFunction callback, void *data);
|
||||
FeedItem *findFeedItem(RSFeedWidgetFindCallbackFunction callback, void *data);
|
||||
FeedItem *findFeedItem(uint64_t identifier);
|
||||
|
||||
void selectedFeedItems(QList<FeedItem*> &feedItems);
|
||||
|
||||
|
@ -98,7 +98,7 @@ private:
|
|||
void connectSignals(FeedItem *feedItem);
|
||||
void disconnectSignals(FeedItem *feedItem);
|
||||
FeedItem *feedItemFromTreeItem(QTreeWidgetItem *treeItem);
|
||||
QTreeWidgetItem *findTreeWidgetItem(FeedItem *feedItem);
|
||||
QTreeWidgetItem *findTreeWidgetItem(uint64_t identifier);
|
||||
void filterItems();
|
||||
void filterItem(QTreeWidgetItem *treeItem, FeedItem *feedItem);
|
||||
|
||||
|
@ -117,9 +117,6 @@ private:
|
|||
/* Options */
|
||||
int mCountChangedDisabled;
|
||||
|
||||
/* Items */
|
||||
QMap<FeedItem*, QTreeWidgetItem*> mItems;
|
||||
|
||||
Ui::RSFeedWidget *ui;
|
||||
};
|
||||
|
||||
|
|
|
@ -337,24 +337,49 @@ void ConnectFriendWizard::setCertificate(const QString &certificate, bool friend
|
|||
|
||||
void ConnectFriendWizard::setGpgId(const RsPgpId &gpgId, const RsPeerId &sslId, bool friendRequest)
|
||||
{
|
||||
if (!rsPeers->getGPGDetails(gpgId, peerDetails)) {
|
||||
setField("errorMessage", tr("Cannot get peer details of PGP key %1").arg(QString::fromStdString(gpgId.toStdString())));
|
||||
if(sslId == rsPeers->getOwnId())
|
||||
{
|
||||
setField("errorMessage", tr("This is your own certificate! You would not want to make friend with yourself. Wouldn't you?") ) ;
|
||||
setStartId(Page_ErrorMessage);
|
||||
return;
|
||||
error = false;
|
||||
}
|
||||
|
||||
/* Set ssl id when available */
|
||||
peerDetails.id = sslId;
|
||||
if (!rsPeers->getGPGDetails(gpgId, peerDetails))
|
||||
{
|
||||
mIsShortInvite = true;
|
||||
|
||||
//setStartId(friendRequest ? Page_FriendRequest : Page_Conclusion);
|
||||
setStartId(Page_Conclusion);
|
||||
if (friendRequest){
|
||||
ui->cp_Label->show();
|
||||
ui->requestinfolabel->show();
|
||||
setTitleText(ui->ConclusionPage,tr("Friend request"));
|
||||
ui->ConclusionPage->setSubTitle(tr("Details about the request"));
|
||||
setButtonText(QWizard::FinishButton , tr("Accept"));
|
||||
}
|
||||
peerDetails.id = sslId;
|
||||
peerDetails.gpg_id = gpgId;
|
||||
peerDetails.skip_pgp_signature_validation = true;
|
||||
|
||||
mCertificate.clear();
|
||||
|
||||
setStartId(Page_Conclusion);
|
||||
|
||||
if (friendRequest){
|
||||
ui->cp_Label->show();
|
||||
ui->requestinfolabel->show();
|
||||
setTitleText(ui->ConclusionPage, tr("Friend request"));
|
||||
ui->ConclusionPage->setSubTitle(tr("Details about the request"));
|
||||
setButtonText(QWizard::FinishButton , tr("Accept"));
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
/* Set ssl id when available */
|
||||
peerDetails.id = sslId;
|
||||
mIsShortInvite = false;
|
||||
|
||||
//setStartId(friendRequest ? Page_FriendRequest : Page_Conclusion);
|
||||
setStartId(Page_Conclusion);
|
||||
if (friendRequest){
|
||||
ui->cp_Label->show();
|
||||
ui->requestinfolabel->show();
|
||||
setTitleText(ui->ConclusionPage,tr("Friend request"));
|
||||
ui->ConclusionPage->setSubTitle(tr("Details about the request"));
|
||||
setButtonText(QWizard::FinishButton , tr("Accept"));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
ConnectFriendWizard::~ConnectFriendWizard()
|
||||
|
@ -507,7 +532,7 @@ void ConnectFriendWizard::initializePage(int id)
|
|||
ui->cp_Label->setText(tr("You have a friend request from") + " " + QString::fromUtf8(peerDetails.name.c_str()));
|
||||
ui->nameEdit->setText(QString::fromUtf8(peerDetails.name.c_str()));
|
||||
ui->trustEdit->setText(trustString);
|
||||
ui->emailEdit->setText(QString::fromUtf8(peerDetails.email.c_str()));
|
||||
ui->profileIdEdit->setText(QString::fromStdString(peerDetails.gpg_id.toStdString()));
|
||||
QString loc = QString::fromUtf8(peerDetails.location.c_str());
|
||||
if (!loc.isEmpty())
|
||||
{
|
||||
|
@ -540,12 +565,19 @@ void ConnectFriendWizard::initializePage(int id)
|
|||
ui->ipLabel->setPixmap(QPixmap(":/images/anonymous_128_blue.png").scaledToHeight(S*2,Qt::SmoothTransformation));
|
||||
ui->ipLabel->setToolTip("This is a Hidden node - you need tor/i2p proxy to connect");
|
||||
}
|
||||
|
||||
if(peerDetails.email.empty())
|
||||
if(mIsShortInvite)
|
||||
{
|
||||
ui->emailLabel->hide(); // is it ever used?
|
||||
ui->emailEdit->hide();
|
||||
ui->nameEdit->setText(tr("[Unknown]"));
|
||||
ui->addKeyToKeyring_CB->setChecked(false);
|
||||
ui->addKeyToKeyring_CB->setEnabled(false);
|
||||
ui->signersEdit->hide();
|
||||
ui->signersLabel->hide();
|
||||
ui->signGPGCheckBox->setChecked(false);
|
||||
ui->signGPGCheckBox->setEnabled(false);
|
||||
ui->acceptNoSignGPGCheckBox->setChecked(true);
|
||||
ui->acceptNoSignGPGCheckBox->setEnabled(false);
|
||||
}
|
||||
|
||||
ui->ipEdit->setTextInteractionFlags(Qt::TextSelectableByMouse);
|
||||
|
||||
}
|
||||
|
|
|
@ -6,8 +6,8 @@
|
|||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>600</width>
|
||||
<height>437</height>
|
||||
<width>1139</width>
|
||||
<height>1171</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
|
@ -480,14 +480,14 @@
|
|||
</widget>
|
||||
</item>
|
||||
<item row="3" column="0">
|
||||
<widget class="QLabel" name="emailLabel">
|
||||
<widget class="QLabel" name="profileIdLabel">
|
||||
<property name="text">
|
||||
<string>Email:</string>
|
||||
<string>Profile ID:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="1">
|
||||
<widget class="QLabel" name="emailEdit">
|
||||
<widget class="QLabel" name="profileIdEdit">
|
||||
<property name="text">
|
||||
<string notr="true">Email</string>
|
||||
</property>
|
||||
|
@ -794,8 +794,8 @@
|
|||
</customwidget>
|
||||
</customwidgets>
|
||||
<resources>
|
||||
<include location="../images.qrc"/>
|
||||
<include location="../icons.qrc"/>
|
||||
<include location="../images.qrc"/>
|
||||
</resources>
|
||||
<connections/>
|
||||
</ui>
|
||||
|
|
|
@ -37,6 +37,7 @@ public:
|
|||
|
||||
void updateItemStatic();
|
||||
|
||||
virtual uint64_t uniqueIdentifier() const override { return hash_64bits("ChatMsgItem " + mPeerId.toStdString()); }
|
||||
protected:
|
||||
/* FeedItem */
|
||||
virtual void doExpand(bool /*open*/) {}
|
||||
|
|
|
@ -18,10 +18,11 @@
|
|||
* *
|
||||
*******************************************************************************/
|
||||
|
||||
#include <iostream>
|
||||
#include "FeedItem.h"
|
||||
|
||||
/** Constructor */
|
||||
FeedItem::FeedItem(QWidget *parent) : QWidget(parent)
|
||||
FeedItem::FeedItem(QWidget *parent) : QWidget(parent), mHash(0)
|
||||
{
|
||||
mWasExpanded = false;
|
||||
}
|
||||
|
@ -43,3 +44,16 @@ void FeedItem::expand(bool open)
|
|||
mWasExpanded = true;
|
||||
}
|
||||
}
|
||||
|
||||
uint64_t FeedItem::hash_64bits(const std::string& s) const
|
||||
{
|
||||
if(mHash == 0)
|
||||
{
|
||||
mHash = 0x01110bbfa09;
|
||||
|
||||
for(uint32_t i=0;i<s.size();++i)
|
||||
mHash = ~(((mHash << 31) ^ (mHash >> 3)) + s[i]*0x217898fbba7 + 0x0294379);
|
||||
}
|
||||
|
||||
return mHash;
|
||||
}
|
||||
|
|
|
@ -36,16 +36,24 @@ public:
|
|||
bool wasExpanded() { return mWasExpanded; }
|
||||
void expand(bool open);
|
||||
|
||||
/*!
|
||||
* \brief uniqueIdentifier
|
||||
* \return returns a string that is unique to this specific item. The string will be used to search for an existing item that
|
||||
* would contain the same information. It should therefore sumarise the data represented by the item.
|
||||
*/
|
||||
virtual uint64_t uniqueIdentifier() const =0;
|
||||
protected:
|
||||
virtual void doExpand(bool open) = 0;
|
||||
virtual void expandFill(bool /*first*/) {}
|
||||
|
||||
uint64_t hash_64bits(const std::string& s) const;
|
||||
signals:
|
||||
void sizeChanged(FeedItem *feedItem);
|
||||
void feedItemDestroyed(FeedItem *feedItem);
|
||||
|
||||
private:
|
||||
bool mWasExpanded;
|
||||
mutable uint64_t mHash;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
|
@ -41,7 +41,7 @@ public:
|
|||
~GxsChannelGroupItem();
|
||||
|
||||
bool setGroup(const RsGxsChannelGroup &group);
|
||||
|
||||
uint64_t uniqueIdentifier() const override { return hash_64bits("GxsChannelGroupItem " + groupId().toStdString()) ; }
|
||||
protected:
|
||||
/* FeedItem */
|
||||
virtual void doExpand(bool open);
|
||||
|
|
|
@ -71,6 +71,7 @@ void GxsChannelPostItem::init(const RsGxsMessageId& messageId,const std::set<RsG
|
|||
|
||||
setup();
|
||||
|
||||
mPost.mMeta.mMsgId = messageId; // useful for uniqueIdentifer() before the post is loaded
|
||||
mLoaded = false ;
|
||||
}
|
||||
|
||||
|
@ -183,6 +184,7 @@ void GxsChannelPostItem::setup()
|
|||
|
||||
connect(ui->downloadButton, SIGNAL(clicked()), this, SLOT(download()));
|
||||
// HACK FOR NOW.
|
||||
ui->commentButton->hide();// hidden until properly enabled.
|
||||
connect(ui->commentButton, SIGNAL(clicked()), this, SLOT(loadComments()));
|
||||
|
||||
connect(ui->playButton, SIGNAL(clicked()), this, SLOT(play(void)));
|
||||
|
|
|
@ -53,6 +53,8 @@ public:
|
|||
//GxsChannelPostItem(FeedHolder *feedHolder, uint32_t feedId, const RsGxsChannelPost &post, bool isHome, bool autoUpdate);
|
||||
virtual ~GxsChannelPostItem();
|
||||
|
||||
uint64_t uniqueIdentifier() const override { hash_64bits("GxsChannelPostItem " + mPost.mMeta.mMsgId.toStdString()) ; }
|
||||
|
||||
bool setGroup(const RsGxsChannelGroup &group, bool doFill = true);
|
||||
bool setPost(const RsGxsChannelPost &post, bool doFill = true);
|
||||
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>1140</width>
|
||||
<width>1359</width>
|
||||
<height>342</height>
|
||||
</rect>
|
||||
</property>
|
||||
|
@ -57,18 +57,6 @@
|
|||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>82</width>
|
||||
<height>108</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>156</width>
|
||||
<height>107</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string/>
|
||||
</property>
|
||||
|
@ -138,12 +126,6 @@
|
|||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>16777215</width>
|
||||
<height>60</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string notr="true">Short Description</string>
|
||||
</property>
|
||||
|
@ -570,8 +552,8 @@
|
|||
</customwidget>
|
||||
</customwidgets>
|
||||
<resources>
|
||||
<include location="../images.qrc"/>
|
||||
<include location="../icons.qrc"/>
|
||||
<include location="../images.qrc"/>
|
||||
</resources>
|
||||
<connections/>
|
||||
</ui>
|
||||
|
|
|
@ -91,12 +91,18 @@ void GxsCircleItem::setup()
|
|||
ui->iconLabel->setPixmap(pixmap);
|
||||
ui->gxsIdLabel->setId(mGxsId);
|
||||
|
||||
|
||||
|
||||
ui->acceptButton->setToolTip(tr("Grant membership request"));
|
||||
ui->revokeButton->setToolTip(tr("Revoke membership request"));
|
||||
connect(ui->acceptButton, SIGNAL(clicked()), this, SLOT(grantCircleMembership()));
|
||||
connect(ui->revokeButton, SIGNAL(clicked()), this, SLOT(revokeCircleMembership()));
|
||||
if(circleDetails.mAmIAdmin)
|
||||
{
|
||||
ui->acceptButton->setToolTip(tr("Grant membership request"));
|
||||
ui->revokeButton->setToolTip(tr("Revoke membership request"));
|
||||
connect(ui->acceptButton, SIGNAL(clicked()), this, SLOT(grantCircleMembership()));
|
||||
connect(ui->revokeButton, SIGNAL(clicked()), this, SLOT(revokeCircleMembership()));
|
||||
}
|
||||
else
|
||||
{
|
||||
ui->acceptButton->setEnabled(false);
|
||||
ui->revokeButton->setEnabled(false);
|
||||
}
|
||||
}
|
||||
else if (mType == RS_FEED_ITEM_CIRCLE_INVIT_REC)
|
||||
{
|
||||
|
@ -110,7 +116,43 @@ void GxsCircleItem::setup()
|
|||
connect(ui->acceptButton, SIGNAL(clicked()), this, SLOT(acceptCircleSubscription()));
|
||||
ui->revokeButton->setHidden(true);
|
||||
}
|
||||
else if (mType == RS_FEED_ITEM_CIRCLE_MEMB_LEAVE)
|
||||
{
|
||||
ui->titleLabel->setText(idName + tr(" has left this circle you belong to."));
|
||||
ui->nameLabel->setText(QString::fromUtf8(circleDetails.mCircleName.c_str()));
|
||||
ui->gxsIdLabel->setText(idName);
|
||||
ui->iconLabel->setPixmap(pixmap);
|
||||
ui->gxsIdLabel->setId(mGxsId);
|
||||
|
||||
ui->acceptButton->setHidden(true);
|
||||
ui->revokeButton->setHidden(true);
|
||||
}
|
||||
else if (mType == RS_FEED_ITEM_CIRCLE_MEMB_JOIN)
|
||||
{
|
||||
ui->titleLabel->setText(idName + tr(" has join this circle you also belong to."));
|
||||
ui->nameLabel->setText(QString::fromUtf8(circleDetails.mCircleName.c_str()));
|
||||
ui->gxsIdLabel->setText(idName);
|
||||
ui->iconLabel->setPixmap(pixmap);
|
||||
ui->gxsIdLabel->setId(mGxsId);
|
||||
|
||||
ui->acceptButton->setHidden(true);
|
||||
ui->revokeButton->setHidden(true);
|
||||
}
|
||||
else if (mType == RS_FEED_ITEM_CIRCLE_MEMB_REVOQUED)
|
||||
{
|
||||
if(rsIdentity->isOwnId(mGxsId))
|
||||
ui->titleLabel->setText(tr("Your identity %1 has been revoqued from this circle.").arg(idName));
|
||||
else
|
||||
ui->titleLabel->setText(tr("Identity %1 has been revoqued from this circle you belong to.").arg(idName));
|
||||
|
||||
ui->nameLabel->setText(QString::fromUtf8(circleDetails.mCircleName.c_str()));
|
||||
ui->gxsIdLabel->setText(idName);
|
||||
ui->iconLabel->setPixmap(pixmap);
|
||||
ui->gxsIdLabel->setId(mGxsId);
|
||||
|
||||
ui->acceptButton->setHidden(true);
|
||||
ui->revokeButton->setHidden(true);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -125,14 +167,9 @@ void GxsCircleItem::setup()
|
|||
|
||||
}
|
||||
|
||||
bool GxsCircleItem::isSame(const RsGxsCircleId &circleId, const RsGxsId &gxsId, uint32_t type)
|
||||
uint64_t GxsCircleItem::uniqueIdentifier() const
|
||||
{
|
||||
if ((mCircleId == circleId) && (mGxsId == gxsId) && (mType == type))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
|
||||
return hash_64bits("GxsCircle " + mCircleId.toStdString() + " " + mGxsId.toStdString() + " " + QString::number(mType).toStdString());
|
||||
}
|
||||
|
||||
void GxsCircleItem::removeItem()
|
||||
|
|
|
@ -52,8 +52,7 @@ public:
|
|||
GxsCircleItem(FeedHolder *feedHolder, uint32_t feedId, const RsGxsCircleId &circleId, const RsGxsId &gxsId, const uint32_t type);
|
||||
virtual ~GxsCircleItem();
|
||||
|
||||
bool isSame(const RsGxsCircleId &circleId, const RsGxsId &gxsId, uint32_t type);
|
||||
|
||||
uint64_t uniqueIdentifier() const override;
|
||||
void loadRequest(const TokenQueue *queue, const TokenRequest &req);
|
||||
|
||||
|
||||
|
|
|
@ -42,6 +42,7 @@ public:
|
|||
|
||||
bool setGroup(const RsGxsForumGroup &group);
|
||||
|
||||
uint64_t uniqueIdentifier() const override { return hash_64bits("GxsForumGroupItem " + groupId().toStdString()) ; }
|
||||
protected:
|
||||
/* FeedItem */
|
||||
virtual void doExpand(bool open);
|
||||
|
|
|
@ -43,6 +43,8 @@
|
|||
GxsForumMsgItem::GxsForumMsgItem(FeedHolder *feedHolder, uint32_t feedId, const RsGxsGroupId &groupId, const RsGxsMessageId &messageId, bool isHome, bool autoUpdate) :
|
||||
GxsFeedItem(feedHolder, feedId, groupId, messageId, isHome, rsGxsForums, autoUpdate)
|
||||
{
|
||||
mMessage.mMeta.mMsgId = messageId; // useful for uniqueIdentifier() before the post is actually loaded
|
||||
mMessage.mMeta.mGroupId = groupId;
|
||||
setup();
|
||||
|
||||
requestGroup();
|
||||
|
|
|
@ -43,6 +43,7 @@ public:
|
|||
bool setGroup(const RsGxsForumGroup &group, bool doFill = true);
|
||||
bool setMessage(const RsGxsForumMsg &msg, bool doFill = true);
|
||||
|
||||
uint64_t uniqueIdentifier() const override { return hash_64bits("GxsForumMsgItem " + mMessage.mMeta.mMsgId.toStdString()) ; }
|
||||
protected:
|
||||
/* FeedItem */
|
||||
virtual void doExpand(bool open);
|
||||
|
|
|
@ -38,6 +38,7 @@ public:
|
|||
|
||||
void updateItemStatic();
|
||||
|
||||
uint64_t uniqueIdentifier() const override { return hash_64bits("MsgItem " + mMsgId) ; }
|
||||
protected:
|
||||
/* FeedItem */
|
||||
virtual void doExpand(bool open);
|
||||
|
|
|
@ -26,7 +26,7 @@ NewsFeedUserNotify::NewsFeedUserNotify(NewsFeed *newsFeed, QObject *parent) :
|
|||
{
|
||||
mNewFeedCount = 0;
|
||||
|
||||
connect(newsFeed, SIGNAL(newsFeedChanged(int)), this, SLOT(newsFeedChanged(int)));
|
||||
connect(newsFeed, SIGNAL(newsFeedChanged(int)), this, SLOT(newsFeedChanged(int)),Qt::QueuedConnection);
|
||||
}
|
||||
|
||||
void NewsFeedUserNotify::newsFeedChanged(int count)
|
||||
|
|
|
@ -67,17 +67,11 @@ PeerItem::PeerItem(FeedHolder *parent, uint32_t feedId, const RsPeerId &peerId,
|
|||
updateItem();
|
||||
}
|
||||
|
||||
|
||||
bool PeerItem::isSame(const RsPeerId &peerId, uint32_t type)
|
||||
uint64_t PeerItem::uniqueIdentifier() const
|
||||
{
|
||||
if ((mPeerId == peerId) && (mType == type))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
return hash_64bits("PeerItem " + mPeerId.toStdString() + " " + QString::number(mType).toStdString()) ;
|
||||
}
|
||||
|
||||
|
||||
void PeerItem::updateItemStatic()
|
||||
{
|
||||
if (!rsPeers)
|
||||
|
@ -100,7 +94,7 @@ void PeerItem::updateItemStatic()
|
|||
title = tr("Friend Connected");
|
||||
break;
|
||||
case PEER_TYPE_HELLO:
|
||||
title = tr("Connect Attempt");
|
||||
title = tr("Connection refused by peer");
|
||||
break;
|
||||
case PEER_TYPE_NEW_FOF:
|
||||
title = tr("Friend of Friend");
|
||||
|
@ -135,15 +129,16 @@ void PeerItem::updateItemStatic()
|
|||
}
|
||||
else
|
||||
{
|
||||
statusLabel->setText(tr("Unknown Peer"));
|
||||
titleLabel->setText(tr("Unknown Peer"));
|
||||
trustLabel->setText(tr("Unknown Peer"));
|
||||
nameLabel->setText(tr("Unknown Peer"));
|
||||
idLabel->setText(tr("Unknown Peer"));
|
||||
locLabel->setText(tr("Unknown Peer"));
|
||||
ipLabel->setText(tr("Unknown Peer"));
|
||||
connLabel->setText(tr("Unknown Peer"));
|
||||
lastLabel->setText(tr("Unknown Peer"));
|
||||
peerNameLabel->setText(tr("Unknown peer"));
|
||||
statusLabel->setText(tr("Unknown"));
|
||||
titleLabel->setText(tr("Unknown peer"));
|
||||
trustLabel->setText(tr("Unknown"));
|
||||
nameLabel->setText(tr("Unknown"));
|
||||
idLabel->setText(tr("Unknown"));
|
||||
locLabel->setText(tr("Unknown"));
|
||||
ipLabel->setText(tr("Unknown"));
|
||||
connLabel->setText(tr("Unknown"));
|
||||
lastLabel->setText(tr("Unknown"));
|
||||
|
||||
chatButton->setEnabled(false);
|
||||
}
|
||||
|
@ -192,7 +187,19 @@ void PeerItem::updateItem()
|
|||
statusLabel->setText(status);
|
||||
trustLabel->setText(QString::fromStdString(RsPeerTrustString(details.trustLvl)));
|
||||
|
||||
ipLabel->setText(QString("%1:%2/%3:%4").arg(QString::fromStdString(details.localAddr)).arg(details.localPort).arg(QString::fromStdString(details.extAddr)).arg(details.extPort));
|
||||
QString ip_string;
|
||||
|
||||
if(details.localPort != 0)
|
||||
ip_string += QString("%1:%2").arg(QString::fromStdString(details.localAddr)).arg(details.localPort);
|
||||
|
||||
if(details.extPort != 0)
|
||||
{
|
||||
if(!ip_string.isNull())
|
||||
ip_string += "/" ;
|
||||
|
||||
ip_string += ip_string += QString("%1:%2").arg(QString::fromStdString(details.extAddr)).arg(details.extPort);
|
||||
}
|
||||
ipLabel->setText(ip_string);
|
||||
|
||||
connLabel->setText(StatusDefs::connectStateString(details));
|
||||
|
||||
|
|
|
@ -43,7 +43,7 @@ public:
|
|||
|
||||
void updateItemStatic();
|
||||
|
||||
bool isSame(const RsPeerId &peerId, uint32_t type);
|
||||
uint64_t uniqueIdentifier() const override;
|
||||
|
||||
protected:
|
||||
/* FeedItem */
|
||||
|
|
|
@ -42,6 +42,8 @@ public:
|
|||
|
||||
bool setGroup(const RsPostedGroup &group);
|
||||
|
||||
uint64_t uniqueIdentifier() const override { return hash_64bits("PostedGroupItem " + groupId().toStdString()) ; }
|
||||
|
||||
protected:
|
||||
/* FeedItem */
|
||||
virtual void doExpand(bool open);
|
||||
|
|
|
@ -78,13 +78,9 @@ void SecurityIpItem::setup()
|
|||
updateItem();
|
||||
}
|
||||
|
||||
bool SecurityIpItem::isSame(const RsPeerId &sslId, const std::string& ipAddr, const std::string& ipAddrReported, uint32_t type)
|
||||
uint64_t SecurityIpItem::uniqueIdentifier() const
|
||||
{
|
||||
if (mType == type && mSslId==sslId && mIpAddr == ipAddr && mIpAddrReported == ipAddrReported) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
return hash_64bits("SecurityItem " + QString::number(mType).toStdString() + " " + mSslId.toStdString() + " " + mIpAddr + " " + mIpAddrReported) ;
|
||||
}
|
||||
|
||||
void SecurityIpItem::updateItemStatic()
|
||||
|
|
|
@ -43,7 +43,7 @@ public:
|
|||
|
||||
void updateItemStatic();
|
||||
|
||||
bool isSame(const RsPeerId &sslId, const std::string& ipAddr, const std::string& ipAddrReported, uint32_t type);
|
||||
uint64_t uniqueIdentifier() const override;
|
||||
|
||||
protected:
|
||||
/* FeedItem */
|
||||
|
|
|
@ -81,17 +81,11 @@ SecurityItem::SecurityItem(FeedHolder *parent, uint32_t feedId, const RsPgpId &g
|
|||
updateItem();
|
||||
}
|
||||
|
||||
|
||||
bool SecurityItem::isSame(const RsPeerId &sslId, uint32_t type)
|
||||
uint64_t SecurityItem::uniqueIdentifier() const
|
||||
{
|
||||
if ((mSslId == sslId) && (mType == type))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
return hash_64bits("SecurityItem " + QString::number(mType).toStdString() + " " + mSslId.toStdString());
|
||||
}
|
||||
|
||||
|
||||
void SecurityItem::updateItemStatic()
|
||||
{
|
||||
if (!rsPeers)
|
||||
|
@ -180,40 +174,47 @@ void SecurityItem::updateItem()
|
|||
std::cerr << std::endl;
|
||||
#endif
|
||||
|
||||
if(!RsAutoUpdatePage::eventsLocked()) {
|
||||
if(!RsAutoUpdatePage::eventsLocked())
|
||||
{
|
||||
RsPeerDetails details;
|
||||
/* first try sslid */
|
||||
if (!rsPeers->getPeerDetails(mSslId, details))
|
||||
/* first try sslid */;
|
||||
if (!rsPeers->getPeerDetails(mSslId, details) && !rsPeers->getGPGDetails(mGpgId, details))
|
||||
{
|
||||
/* then gpgid */
|
||||
if(!rsPeers->getGPGDetails(mGpgId, details))
|
||||
{
|
||||
/* it is very likely that we will end up here for some of the
|
||||
/* it is very likely that we will end up here for some of the
|
||||
* Unknown peer cases.... so allow them here
|
||||
*/
|
||||
|
||||
/* set peer name */
|
||||
peerNameLabel->setText(QString("%1 (%2)").arg(tr("Unknown Peer"), QString::fromUtf8(mSslCn.c_str())));
|
||||
/* set peer name */
|
||||
peerNameLabel->setText(tr("A unknown peer"));
|
||||
|
||||
nameLabel->setText(QString::fromUtf8(mSslCn.c_str()) + " (" + QString::fromStdString(mGpgId.toStdString()) + ")");
|
||||
idLabel->setText(QString::fromStdString(mSslId.toStdString()));
|
||||
nameLabel->setText(tr("Unknown") + " (" + tr("Profile ID: ") + QString::fromStdString(mGpgId.toStdString()) + ")");
|
||||
idLabel->setText(QString::fromStdString(mSslId.toStdString()));
|
||||
|
||||
statusLabel->setText(tr("Unknown Peer"));
|
||||
trustLabel->setText(tr("Unknown Peer"));
|
||||
locLabel->setText(tr("Unknown Peer"));
|
||||
ipLabel->setText(QString::fromStdString(mIP)) ; //tr("Unknown Peer"));
|
||||
connLabel->setText(tr("Unknown Peer"));
|
||||
statusLabel->hide();
|
||||
typeLabel->hide();
|
||||
|
||||
chatButton->hide();
|
||||
//quickmsgButton->hide();
|
||||
requestLabel->hide();
|
||||
trustLabel->hide();
|
||||
trustLeftLabel->hide();
|
||||
|
||||
removeFriendButton->setEnabled(false);
|
||||
removeFriendButton->hide();
|
||||
peerDetailsButton->setEnabled(false);
|
||||
locLabel->hide();
|
||||
locLeftLabel->hide();
|
||||
|
||||
return;
|
||||
}
|
||||
ipLabel->setText(QString::fromStdString(mIP)) ;
|
||||
connLabel->hide();
|
||||
connLeftLabel->hide();
|
||||
|
||||
chatButton->hide();
|
||||
//quickmsgButton->hide();
|
||||
requestLabel->hide();
|
||||
|
||||
removeFriendButton->setEnabled(false);
|
||||
removeFriendButton->hide();
|
||||
peerDetailsButton->setEnabled(false);
|
||||
|
||||
friendRequesttoolButton->show();
|
||||
requestLabel->show();
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
/* set peer name */
|
||||
|
@ -350,6 +351,7 @@ void SecurityItem::friendRequest()
|
|||
#endif
|
||||
|
||||
ConnectFriendWizard *connectFriendWizard = new ConnectFriendWizard;
|
||||
|
||||
connectFriendWizard->setAttribute(Qt::WA_DeleteOnClose, true);
|
||||
connectFriendWizard->setGpgId(mGpgId, mSslId, true);
|
||||
connectFriendWizard->show();
|
||||
|
|
|
@ -42,7 +42,7 @@ public:
|
|||
|
||||
void updateItemStatic();
|
||||
|
||||
bool isSame(const RsPeerId &sslId, uint32_t type);
|
||||
uint64_t uniqueIdentifier() const override;
|
||||
|
||||
protected:
|
||||
/* FeedItem */
|
||||
|
|
|
@ -6,8 +6,8 @@
|
|||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>763</width>
|
||||
<height>246</height>
|
||||
<width>1196</width>
|
||||
<height>491</height>
|
||||
</rect>
|
||||
</property>
|
||||
<layout class="QGridLayout">
|
||||
|
@ -354,7 +354,7 @@
|
|||
<item>
|
||||
<layout class="QVBoxLayout" name="verticalLayout">
|
||||
<item>
|
||||
<widget class="QLabel" name="label_3">
|
||||
<widget class="QLabel" name="nameLeftLabel">
|
||||
<property name="font">
|
||||
<font>
|
||||
<weight>75</weight>
|
||||
|
@ -367,7 +367,7 @@
|
|||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLabel" name="label_4">
|
||||
<widget class="QLabel" name="idLeftLabel">
|
||||
<property name="font">
|
||||
<font>
|
||||
<weight>75</weight>
|
||||
|
@ -380,7 +380,7 @@
|
|||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLabel" name="label">
|
||||
<widget class="QLabel" name="trustLeftLabel">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="Minimum">
|
||||
<horstretch>0</horstretch>
|
||||
|
@ -399,7 +399,7 @@
|
|||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLabel" name="label_6">
|
||||
<widget class="QLabel" name="locLeftLabel">
|
||||
<property name="font">
|
||||
<font>
|
||||
<weight>75</weight>
|
||||
|
@ -412,7 +412,7 @@
|
|||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLabel" name="label_8">
|
||||
<widget class="QLabel" name="ipLeftLabel">
|
||||
<property name="font">
|
||||
<font>
|
||||
<weight>75</weight>
|
||||
|
@ -425,7 +425,7 @@
|
|||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLabel" name="label_9">
|
||||
<widget class="QLabel" name="connLeftLabel">
|
||||
<property name="font">
|
||||
<font>
|
||||
<weight>75</weight>
|
||||
|
@ -578,8 +578,8 @@
|
|||
</customwidget>
|
||||
</customwidgets>
|
||||
<resources>
|
||||
<include location="../images.qrc"/>
|
||||
<include location="../icons.qrc"/>
|
||||
<include location="../images.qrc"/>
|
||||
</resources>
|
||||
<connections/>
|
||||
</ui>
|
||||
|
|
|
@ -351,7 +351,9 @@ void GxsIdChooser::setDefaultItem()
|
|||
|
||||
if (def >= 0) {
|
||||
setCurrentIndex(def);
|
||||
#ifdef IDCHOOSER_DEBUG
|
||||
std::cerr << "GxsIdChooser-002" << (void*)this << " setting current index to " << def << std::endl;
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -363,7 +365,9 @@ bool GxsIdChooser::setChosenId(const RsGxsId &gxsId)
|
|||
int index = findData(id);
|
||||
if (index >= 0) {
|
||||
setCurrentIndex(index);
|
||||
#ifdef IDCHOOSER_DEBUG
|
||||
std::cerr << "GxsIdChooser-001" << (void*)this << " setting current index to " << index << std::endl;
|
||||
#endif
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
|
|
|
@ -50,6 +50,28 @@ public:
|
|||
GxsChannelDialog::GxsChannelDialog(QWidget *parent)
|
||||
: GxsGroupFrameDialog(rsGxsChannels, parent,true)
|
||||
{
|
||||
mEventHandlerId = 0;
|
||||
// Needs to be asynced because this function is likely to be called by another thread!
|
||||
rsEvents->registerEventsHandler( [this](std::shared_ptr<const RsEvent> event) { RsQThreadUtils::postToObject( [=]() { handleEvent_main_thread(event); }, this ); }, mEventHandlerId );
|
||||
}
|
||||
|
||||
void GxsChannelDialog::handleEvent_main_thread(std::shared_ptr<const RsEvent> event)
|
||||
{
|
||||
if(event->mType == RsEventType::GXS_CHANNELS)
|
||||
{
|
||||
const RsGxsChannelEvent *e = dynamic_cast<const RsGxsChannelEvent*>(event.get());
|
||||
|
||||
if(!e)
|
||||
return;
|
||||
|
||||
switch(e->mChannelEventCode)
|
||||
{
|
||||
case RsGxsChannelEvent::ChannelEventCode::SUBSCRIBE_STATUS_CHANGED: updateDisplay(true);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
GxsChannelDialog::~GxsChannelDialog()
|
||||
|
|
|
@ -74,6 +74,10 @@ private:
|
|||
virtual QWidget *createCommentHeaderWidget(const RsGxsGroupId &grpId, const RsGxsMessageId &msgId);
|
||||
virtual uint32_t requestGroupSummaryType() { return GXS_REQUEST_TYPE_GROUP_DATA; } // request complete group data
|
||||
virtual void loadGroupSummaryToken(const uint32_t &token, std::list<RsGroupMetaData> &groupInfo, RsUserdata* &userdata);
|
||||
|
||||
void handleEvent_main_thread(std::shared_ptr<const RsEvent> event);
|
||||
|
||||
RsEventsHandlerId_t mEventHandlerId;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
|
@ -128,6 +128,35 @@ GxsChannelPostsWidget::GxsChannelPostsWidget(const RsGxsGroupId &channelId, QWid
|
|||
setAutoDownload(false);
|
||||
settingsChanged();
|
||||
setGroupId(channelId);
|
||||
|
||||
mEventHandlerId = 0;
|
||||
// Needs to be asynced because this function is likely to be called by another thread!
|
||||
|
||||
rsEvents->registerEventsHandler( [this](std::shared_ptr<const RsEvent> event) { RsQThreadUtils::postToObject( [=]() { handleEvent_main_thread(event); }, this ); }, mEventHandlerId );
|
||||
}
|
||||
|
||||
void GxsChannelPostsWidget::handleEvent_main_thread(std::shared_ptr<const RsEvent> event)
|
||||
{
|
||||
if(event->mType == RsEventType::GXS_CHANNELS)
|
||||
{
|
||||
const RsGxsChannelEvent *e = dynamic_cast<const RsGxsChannelEvent*>(event.get());
|
||||
|
||||
if(!e)
|
||||
return;
|
||||
|
||||
switch(e->mChannelEventCode)
|
||||
{
|
||||
case RsGxsChannelEvent::ChannelEventCode::UPDATED_CHANNEL:
|
||||
case RsGxsChannelEvent::ChannelEventCode::NEW_CHANNEL:
|
||||
case RsGxsChannelEvent::ChannelEventCode::UPDATED_MESSAGE:
|
||||
case RsGxsChannelEvent::ChannelEventCode::NEW_MESSAGE:
|
||||
if(e->mChannelGroupId == mChannelGroupId)
|
||||
updateDisplay(true);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
GxsChannelPostsWidget::~GxsChannelPostsWidget()
|
||||
|
@ -712,6 +741,7 @@ bool GxsChannelPostsWidget::insertGroupData(const uint32_t &token, RsGroupMetaDa
|
|||
{
|
||||
insertChannelDetails(groups[0]);
|
||||
metaData = groups[0].mMeta;
|
||||
mChannelGroupId = groups[0].mMeta.mGroupId;
|
||||
return true;
|
||||
}
|
||||
else
|
||||
|
@ -721,6 +751,7 @@ bool GxsChannelPostsWidget::insertGroupData(const uint32_t &token, RsGroupMetaDa
|
|||
{
|
||||
insertChannelDetails(distant_group);
|
||||
metaData = distant_group.mMeta;
|
||||
mChannelGroupId = distant_group.mMeta.mGroupId;
|
||||
return true ;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -97,11 +97,14 @@ private:
|
|||
void insertChannelPosts(std::vector<RsGxsChannelPost> &posts, GxsMessageFramePostThread *thread, bool related);
|
||||
|
||||
void createPostItem(const RsGxsChannelPost &post, bool related);
|
||||
void handleEvent_main_thread(std::shared_ptr<const RsEvent> event);
|
||||
|
||||
private:
|
||||
QAction *mAutoDownloadAction;
|
||||
|
||||
bool mUseThread;
|
||||
RsGxsGroupId mChannelGroupId;
|
||||
RsEventsHandlerId_t mEventHandlerId ;
|
||||
|
||||
/* UI - from Designer */
|
||||
Ui::GxsChannelPostsWidget *ui;
|
||||
|
|
|
@ -432,6 +432,35 @@ GxsForumThreadWidget::GxsForumThreadWidget(const RsGxsGroupId &forumId, QWidget
|
|||
#ifdef SUSPENDED_CODE
|
||||
ui->threadTreeWidget->enableColumnCustomize(true);
|
||||
#endif
|
||||
|
||||
mEventHandlerId = 0;
|
||||
// Needs to be asynced because this function is likely to be called by another thread!
|
||||
|
||||
rsEvents->registerEventsHandler( [this](std::shared_ptr<const RsEvent> event) { RsQThreadUtils::postToObject( [=]() { handleEvent_main_thread(event); }, this ); }, mEventHandlerId );
|
||||
}
|
||||
|
||||
void GxsForumThreadWidget::handleEvent_main_thread(std::shared_ptr<const RsEvent> event)
|
||||
{
|
||||
if(event->mType == RsEventType::GXS_FORUMS)
|
||||
{
|
||||
const RsGxsForumEvent *e = dynamic_cast<const RsGxsForumEvent*>(event.get());
|
||||
|
||||
if(!e)
|
||||
return;
|
||||
|
||||
switch(e->mForumEventCode)
|
||||
{
|
||||
case RsGxsForumEvent::ForumEventCode::UPDATED_FORUM:
|
||||
case RsGxsForumEvent::ForumEventCode::NEW_FORUM:
|
||||
case RsGxsForumEvent::ForumEventCode::UPDATED_MESSAGE:
|
||||
case RsGxsForumEvent::ForumEventCode::NEW_MESSAGE:
|
||||
if(e->mForumGroupId == mForumGroup.mMeta.mGroupId)
|
||||
updateDisplay(true);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void GxsForumThreadWidget::blank()
|
||||
|
|
|
@ -172,6 +172,8 @@ private:
|
|||
void updateMessageData(const RsGxsMessageId& msgId);
|
||||
void updateForumDescription();
|
||||
|
||||
void handleEvent_main_thread(std::shared_ptr<const RsEvent> event);
|
||||
|
||||
private:
|
||||
RsGxsGroupId mLastForumID;
|
||||
RsGxsMessageId mThreadId;
|
||||
|
@ -201,6 +203,7 @@ private:
|
|||
QList<RsGxsMessageId> mSavedExpandedMessages;
|
||||
|
||||
Ui::GxsForumThreadWidget *ui;
|
||||
RsEventsHandlerId_t mEventHandlerId;
|
||||
};
|
||||
|
||||
#endif // GXSFORUMTHREADWIDGET_H
|
||||
|
|
|
@ -25,6 +25,7 @@
|
|||
#include "GxsForumUserNotify.h"
|
||||
#include "gui/notifyqt.h"
|
||||
#include "gui/gxs/GxsGroupShareKey.h"
|
||||
#include "util/qtthreadsutils.h"
|
||||
#include "gui/common/GroupTreeWidget.h"
|
||||
|
||||
class GxsForumGroupInfoData : public RsUserdata
|
||||
|
@ -41,6 +42,29 @@ GxsForumsDialog::GxsForumsDialog(QWidget *parent)
|
|||
: GxsGroupFrameDialog(rsGxsForums, parent)
|
||||
{
|
||||
mCountChildMsgs = true;
|
||||
mEventHandlerId = 0;
|
||||
// Needs to be asynced because this function is likely to be called by another thread!
|
||||
|
||||
rsEvents->registerEventsHandler( [this](std::shared_ptr<const RsEvent> event) { RsQThreadUtils::postToObject( [=]() { handleEvent_main_thread(event); }, this ); }, mEventHandlerId );
|
||||
}
|
||||
|
||||
void GxsForumsDialog::handleEvent_main_thread(std::shared_ptr<const RsEvent> event)
|
||||
{
|
||||
if(event->mType == RsEventType::GXS_FORUMS)
|
||||
{
|
||||
const RsGxsForumEvent *e = dynamic_cast<const RsGxsForumEvent*>(event.get());
|
||||
|
||||
if(!e)
|
||||
return;
|
||||
|
||||
switch(e->mForumEventCode)
|
||||
{
|
||||
case RsGxsForumEvent::ForumEventCode::SUBSCRIBE_STATUS_CHANGED: updateDisplay(true);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
GxsForumsDialog::~GxsForumsDialog()
|
||||
|
|
|
@ -58,6 +58,10 @@ private:
|
|||
virtual GxsMessageFrameWidget *createMessageFrameWidget(const RsGxsGroupId &groupId);
|
||||
virtual uint32_t requestGroupSummaryType() { return GXS_REQUEST_TYPE_GROUP_DATA; } // request complete group data
|
||||
virtual void loadGroupSummaryToken(const uint32_t &token, std::list<RsGroupMetaData> &groupInfo, RsUserdata* &userdata);
|
||||
|
||||
void handleEvent_main_thread(std::shared_ptr<const RsEvent> event);
|
||||
|
||||
RsEventsHandlerId_t mEventHandlerId;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
|
@ -584,16 +584,18 @@ void MessageComposer::recommendFriend(const std::set <RsPeerId> &sslIds, const R
|
|||
/* window will destroy itself! */
|
||||
}
|
||||
|
||||
void MessageComposer::sendConnectAttemptMsg(const RsPgpId &gpgId, const RsPeerId &sslId, const QString &/*sslName*/)
|
||||
void MessageComposer::addConnectAttemptMsg(const RsPgpId &gpgId, const RsPeerId &sslId, const QString &/*sslName*/)
|
||||
{
|
||||
if (gpgId.isNull()) {
|
||||
if (gpgId.isNull())
|
||||
return;
|
||||
}
|
||||
|
||||
RetroShareLink link = RetroShareLink::createUnknwonSslCertificate(sslId, gpgId);
|
||||
if (link.valid() == false) {
|
||||
// PGPId+SslId are always here. But if the peer is not a friend the SSL id cannot be used.
|
||||
// (todo) If the PGP id doesn't get us a PGP key from the keyring, we need to create a short invite
|
||||
|
||||
RetroShareLink link = RetroShareLink::createUnknownSslCertificate(sslId);
|
||||
|
||||
if (!link.valid())
|
||||
return;
|
||||
}
|
||||
|
||||
QString title = QString("%1 %2").arg(link.name(), tr("wants to be friends with you on RetroShare"));
|
||||
|
||||
|
|
|
@ -62,7 +62,7 @@ public:
|
|||
|
||||
static QString recommendMessage();
|
||||
static void recommendFriend(const std::set <RsPeerId> &sslIds, const RsPeerId &to = RsPeerId(), const QString &msg = "", bool autoSend = false);
|
||||
static void sendConnectAttemptMsg(const RsPgpId &gpgId, const RsPeerId &sslId, const QString &sslName);
|
||||
static void addConnectAttemptMsg(const RsPgpId &gpgId, const RsPeerId &sslId, const QString &sslName);
|
||||
static void sendInvite(const RsGxsId &to, bool autoSend);
|
||||
#ifdef UNUSED_CODE
|
||||
static void sendChannelPublishKey(RsGxsChannelGroup &group);
|
||||
|
|
|
@ -422,6 +422,7 @@ void NotifyQt::notifyPeerStatusChangedSummary()
|
|||
emit peerStatusChangedSummary();
|
||||
}
|
||||
|
||||
#ifdef TO_REMOVE
|
||||
void NotifyQt::notifyGxsChange(const RsGxsChanges& changes)
|
||||
{
|
||||
{
|
||||
|
@ -436,6 +437,7 @@ void NotifyQt::notifyGxsChange(const RsGxsChanges& changes)
|
|||
|
||||
emit gxsChange(changes);
|
||||
}
|
||||
#endif
|
||||
|
||||
void NotifyQt::notifyOwnStatusMessageChanged()
|
||||
{
|
||||
|
@ -492,20 +494,6 @@ void NotifyQt::notifyChatLobbyTimeShift(int shift)
|
|||
emit chatLobbyTimeShift(shift) ;
|
||||
}
|
||||
|
||||
void NotifyQt::notifyConnectionWithoutCert()
|
||||
{
|
||||
{
|
||||
QMutexLocker m(&_mutex) ;
|
||||
if(!_enabled)
|
||||
return ;
|
||||
}
|
||||
|
||||
#ifdef NOTIFY_DEBUG
|
||||
std::cerr << "notifyQt: Received notifyConnectionWithoutCert" << std::endl;
|
||||
#endif
|
||||
emit connectionWithoutCert();
|
||||
}
|
||||
|
||||
void NotifyQt::handleChatLobbyTimeShift(int /*shift*/)
|
||||
{
|
||||
return ; // we say nothing. The help dialog of lobbies explains this already.
|
||||
|
@ -750,27 +738,6 @@ void NotifyQt::notifyListChange(int list, int type)
|
|||
return;
|
||||
}
|
||||
|
||||
void NotifyQt::notifyPeerConnected(const std::string& peer_id)
|
||||
{
|
||||
{
|
||||
QMutexLocker m(&_mutex) ;
|
||||
if(!_enabled)
|
||||
return ;
|
||||
}
|
||||
|
||||
emit peerConnected(QString::fromStdString(peer_id));
|
||||
}
|
||||
void NotifyQt::notifyPeerDisconnected(const std::string& peer_id)
|
||||
{
|
||||
{
|
||||
QMutexLocker m(&_mutex) ;
|
||||
if(!_enabled)
|
||||
return ;
|
||||
}
|
||||
|
||||
emit peerDisconnected(QString::fromStdString(peer_id));
|
||||
}
|
||||
|
||||
void NotifyQt::notifyListPreChange(int list, int /*type*/)
|
||||
{
|
||||
{
|
||||
|
|
|
@ -56,12 +56,10 @@ class NotifyQt: public QObject, public NotifyClient
|
|||
static bool isAllDisable();
|
||||
void enable() ;
|
||||
|
||||
virtual ~NotifyQt() { return; }
|
||||
virtual ~NotifyQt() = default;
|
||||
|
||||
void setNetworkDialog(NetworkDialog *c) { cDialog = c; }
|
||||
|
||||
virtual void notifyPeerConnected(const std::string& /* peer_id */);
|
||||
virtual void notifyPeerDisconnected(const std::string& /* peer_id */);
|
||||
virtual void notifyListPreChange(int list, int type);
|
||||
virtual void notifyListChange(int list, int type);
|
||||
virtual void notifyErrorMsg(int list, int sev, std::string msg);
|
||||
|
@ -76,7 +74,6 @@ class NotifyQt: public QObject, public NotifyClient
|
|||
virtual void notifyOwnAvatarChanged() ;
|
||||
virtual void notifyChatLobbyEvent(uint64_t /* lobby id */, uint32_t /* event type */, const RsGxsId & /*nickname*/, const std::string& /* any string */) ;
|
||||
virtual void notifyChatLobbyTimeShift(int time_shift) ;
|
||||
void notifyConnectionWithoutCert();
|
||||
|
||||
virtual void notifyOwnStatusMessageChanged() ;
|
||||
virtual void notifyDiskFull(uint32_t loc,uint32_t size_in_mb) ;
|
||||
|
@ -85,8 +82,6 @@ class NotifyQt: public QObject, public NotifyClient
|
|||
/* one or more peers has changed the states */
|
||||
virtual void notifyPeerStatusChangedSummary();
|
||||
|
||||
virtual void notifyGxsChange(const RsGxsChanges& change);
|
||||
|
||||
virtual void notifyHistoryChanged(uint32_t msgId, int type);
|
||||
|
||||
virtual void notifyDiscInfoChanged() ;
|
||||
|
@ -123,8 +118,6 @@ class NotifyQt: public QObject, public NotifyClient
|
|||
// It's beneficial to send info to the GUI using signals, because signals are thread-safe
|
||||
// as they get queued by Qt.
|
||||
//
|
||||
void peerConnected(const QString&) const ;
|
||||
void peerDisconnected(const QString&) const ;
|
||||
void hashingInfoChanged(const QString&) const ;
|
||||
void filesPreModChanged(bool) const ;
|
||||
void filesPostModChanged(bool) const ;
|
||||
|
|
|
@ -37,7 +37,14 @@ QMap<RsGxsIfaceHelper*, RsGxsUpdateBroadcast*> updateBroadcastMap;
|
|||
RsGxsUpdateBroadcast::RsGxsUpdateBroadcast(RsGxsIfaceHelper *ifaceImpl) :
|
||||
QObject(NULL), mIfaceImpl(ifaceImpl)
|
||||
{
|
||||
connect(NotifyQt::getInstance(), SIGNAL(gxsChange(RsGxsChanges)), this, SLOT(onChangesReceived(RsGxsChanges)));
|
||||
mEventHandlerId = 0; // forces initialization in registerEventsHandler()
|
||||
|
||||
rsEvents->registerEventsHandler( [this](std::shared_ptr<const RsEvent> event)
|
||||
{
|
||||
if(event->mType == RsEventType::GXS_CHANGES)
|
||||
onChangesReceived(*dynamic_cast<const RsGxsChanges*>(event.get()));
|
||||
|
||||
}, mEventHandlerId );
|
||||
}
|
||||
|
||||
void RsGxsUpdateBroadcast::cleanup()
|
||||
|
|
|
@ -24,6 +24,7 @@
|
|||
#include <QObject>
|
||||
|
||||
#include <retroshare/rsgxsifacetypes.h>
|
||||
#include <retroshare/rsevents.h>
|
||||
|
||||
struct RsGxsIfaceHelper;
|
||||
struct RsGxsChanges;
|
||||
|
@ -53,6 +54,7 @@ private:
|
|||
|
||||
private:
|
||||
RsGxsIfaceHelper* mIfaceImpl;
|
||||
RsEventsHandlerId_t mEventHandlerId ;
|
||||
};
|
||||
|
||||
#endif // RSGXSUPDATEBROADCAST_H
|
||||
|
|
|
@ -34,7 +34,7 @@ TokenQueue::TokenQueue(RsTokenService *service, TokenResponse *resp)
|
|||
{
|
||||
mTrigger = new RsProtectedTimer(this);
|
||||
mTrigger->setSingleShot(true);
|
||||
connect(mTrigger, SIGNAL(timeout()), this, SLOT(pollRequests()));
|
||||
connect(mTrigger, SIGNAL(timeout()), this, SLOT(pollRequests()),Qt::QueuedConnection);
|
||||
}
|
||||
|
||||
bool TokenQueue::requestGroupInfo(uint32_t &token, uint32_t anstype, const RsTokReqOptions &opts, std::list<RsGxsGroupId>& ids, uint32_t usertype)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue