mirror of
https://github.com/RetroShare/RetroShare.git
synced 2025-08-01 10:46:23 -04:00
switched security items to new notification system
This commit is contained in:
parent
694e05d4b9
commit
d8569d813c
11 changed files with 179 additions and 52 deletions
|
@ -973,11 +973,13 @@ void AboutWidget::on_copy_button_clicked()
|
|||
verInfo+=addLibraries("libretroshare", libraries);
|
||||
|
||||
#ifdef RS_JSONAPI
|
||||
/* Add version numbers of RetroShare */
|
||||
// Add versions here. Find a better place.
|
||||
libraries.clear();
|
||||
libraries.push_back(RsLibraryInfo("RestBed", restbed::get_version()));
|
||||
verInfo+=addLibraries("RetroShare", libraries);
|
||||
// No version number available for restbed apparently.
|
||||
//
|
||||
// /* Add version numbers of RetroShare */
|
||||
// // Add versions here. Find a better place.
|
||||
// libraries.clear();
|
||||
// libraries.push_back(RsLibraryInfo("RestBed", restbed::get_version()));
|
||||
// verInfo+=addLibraries("RetroShare", libraries);
|
||||
#endif
|
||||
|
||||
/* Add version numbers of plugins */
|
||||
|
|
|
@ -33,6 +33,7 @@
|
|||
#include <retroshare/rsplugin.h>
|
||||
#include <retroshare/rsposted.h>
|
||||
|
||||
#include "util/qtthreadsutils.h"
|
||||
#include "feeds/ChatMsgItem.h"
|
||||
#include "feeds/GxsCircleItem.h"
|
||||
#include "feeds/GxsChannelGroupItem.h"
|
||||
|
@ -74,6 +75,8 @@ NewsFeed::NewsFeed(QWidget *parent) :
|
|||
RsAutoUpdatePage(1000,parent),
|
||||
ui(new Ui::NewsFeed)
|
||||
{
|
||||
rsEvents->registerEventsHandler( [this](std::shared_ptr<const RsEvent> event) { handleEvent(event); }, mEventHandlerId );
|
||||
|
||||
/* Invoke the Qt Designer generated object setup routine */
|
||||
ui->setupUi(this);
|
||||
|
||||
|
@ -123,6 +126,8 @@ QString hlp_str = tr(
|
|||
|
||||
NewsFeed::~NewsFeed()
|
||||
{
|
||||
rsEvents->unregisterEventsHandler(mEventHandlerId);
|
||||
|
||||
// save settings
|
||||
processSettings(false);
|
||||
|
||||
|
@ -176,6 +181,88 @@ void NewsFeed::sortChanged(int index)
|
|||
ui->feedWidget->setSortRole(ROLE_RECEIVED, sortOrder);
|
||||
}
|
||||
|
||||
// handler for the new notification system in libretroshare.
|
||||
|
||||
void NewsFeed::handleEvent(std::shared_ptr<const RsEvent> event)
|
||||
{
|
||||
uint flags = Settings->getNewsFeedFlags();
|
||||
|
||||
const RsAuthSslConnectionAutenticationEvent *pssl_e = dynamic_cast<const RsAuthSslConnectionAutenticationEvent*>(event.get());
|
||||
|
||||
if(pssl_e != nullptr && (flags & (RS_FEED_TYPE_SECURITY | RS_FEED_TYPE_PEER)))
|
||||
{
|
||||
RsAuthSslConnectionAutenticationEvent e = *pssl_e; // make a copy because we lose memory ownership here
|
||||
|
||||
RsQThreadUtils::postToObject( [=]()
|
||||
{
|
||||
/* Here it goes any code you want to be executed on the Qt Gui
|
||||
* thread, for example to update the data model with new information
|
||||
* after a blocking call to RetroShare API complete, note that
|
||||
* Qt::QueuedConnection is important!
|
||||
*/
|
||||
handleSecurityEvent(e);
|
||||
|
||||
}, this );
|
||||
}
|
||||
}
|
||||
|
||||
void NewsFeed::handleSecurityEvent(const RsAuthSslConnectionAutenticationEvent& e)
|
||||
{
|
||||
std::cerr << "NotifyQt: handling connection security event from (" << e.mSslId << "," << e.mPgpId << ") error code: " << e.mErrorCode << std::endl;
|
||||
uint flags = Settings->getNewsFeedFlags();
|
||||
|
||||
if(e.mSuccess)
|
||||
if(flags & RS_FEED_TYPE_PEER)
|
||||
{
|
||||
addFeedItem(new PeerItem(this, NEWSFEED_PEERLIST, e.mSslId, PEER_TYPE_CONNECT, false));
|
||||
return;
|
||||
}
|
||||
else
|
||||
return;
|
||||
|
||||
uint32_t FeedItemType=0;
|
||||
|
||||
switch(e.mErrorCode)
|
||||
{
|
||||
case RsAuthSslConnectionAutenticationEvent::NO_CERTIFICATE_SUPPLIED:
|
||||
case RsAuthSslConnectionAutenticationEvent::MISMATCHED_PGP_ID: // fallthrough
|
||||
case RsAuthSslConnectionAutenticationEvent::MISSING_AUTHENTICATION_INFO: FeedItemType = RS_FEED_ITEM_SEC_BAD_CERTIFICATE;
|
||||
break;
|
||||
|
||||
case RsAuthSslConnectionAutenticationEvent::PGP_SIGNATURE_VALIDATION_FAILED: FeedItemType = RS_FEED_ITEM_SEC_WRONG_SIGNATURE;
|
||||
break;
|
||||
|
||||
case RsAuthSslConnectionAutenticationEvent::NOT_A_FRIEND: FeedItemType = RS_FEED_ITEM_SEC_AUTH_DENIED;
|
||||
break;
|
||||
|
||||
case RsAuthSslConnectionAutenticationEvent::IP_IS_BLACKLISTED: FeedItemType = RS_FEED_ITEM_SEC_IP_BLACKLISTED;
|
||||
break;
|
||||
|
||||
case RsAuthSslConnectionAutenticationEvent::MISSING_CERTIFICATE: FeedItemType = RS_FEED_ITEM_SEC_MISSING_CERTIFICATE;
|
||||
break;
|
||||
|
||||
default:
|
||||
return; // display nothing
|
||||
}
|
||||
|
||||
RsPeerDetails det;
|
||||
rsPeers->getPeerDetails(e.mSslId,det) || rsPeers->getGPGDetails(e.mPgpId,det);
|
||||
|
||||
addFeedItemIfUnique(new SecurityItem(this,
|
||||
NEWSFEED_SECLIST,
|
||||
det.gpg_id, det.id,
|
||||
det.location,
|
||||
e.mLocator.toString(),
|
||||
FeedItemType,
|
||||
false),
|
||||
RS_FEED_ITEM_SEC_BAD_CERTIFICATE,
|
||||
det.gpg_id.toStdString(),
|
||||
std::string(),
|
||||
std::string(),
|
||||
std::string(),
|
||||
true );
|
||||
}
|
||||
|
||||
void NewsFeed::updateDisplay()
|
||||
{
|
||||
if (!rsNotify)
|
||||
|
|
|
@ -83,6 +83,8 @@ public:
|
|||
|
||||
virtual void updateDisplay();
|
||||
|
||||
void handleEvent(std::shared_ptr<const RsEvent> event); // get events from libretroshare
|
||||
|
||||
signals:
|
||||
void newsFeedChanged(int count);
|
||||
|
||||
|
@ -100,6 +102,8 @@ private slots:
|
|||
void sendNewsFeedChanged();
|
||||
|
||||
private:
|
||||
void handleSecurityEvent(const RsAuthSslConnectionAutenticationEvent& e);
|
||||
|
||||
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);
|
||||
|
@ -165,6 +169,8 @@ private:
|
|||
|
||||
/* UI - from Designer */
|
||||
Ui::NewsFeed *ui;
|
||||
|
||||
RsEventsHandlerId_t mEventHandlerId;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
|
@ -89,6 +89,10 @@ void NotifyQt::SetDisableAll(bool bValue)
|
|||
}
|
||||
}
|
||||
|
||||
NotifyQt::~NotifyQt()
|
||||
{
|
||||
}
|
||||
|
||||
NotifyQt::NotifyQt() : cDialog(NULL)
|
||||
{
|
||||
runningToasterTimer = new QTimer(this);
|
||||
|
@ -492,20 +496,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.
|
||||
|
|
|
@ -56,7 +56,7 @@ class NotifyQt: public QObject, public NotifyClient
|
|||
static bool isAllDisable();
|
||||
void enable() ;
|
||||
|
||||
virtual ~NotifyQt() { return; }
|
||||
virtual ~NotifyQt() ;
|
||||
|
||||
void setNetworkDialog(NetworkDialog *c) { cDialog = c; }
|
||||
|
||||
|
@ -76,7 +76,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) ;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue