mirror of
https://github.com/RetroShare/RetroShare.git
synced 2025-02-26 01:31:30 -05:00
Merge branch 'csoler-v0.6-SecNotification'
This commit is contained in:
commit
b17738f668
@ -855,12 +855,8 @@ bool p3ChatService::handleRecvChatMsgItem(RsChatMsgItem *& ci)
|
|||||||
{
|
{
|
||||||
#ifdef RS_DIRECT_CHAT
|
#ifdef RS_DIRECT_CHAT
|
||||||
/* notify public chat message */
|
/* notify public chat message */
|
||||||
RsServer::notify()->AddPopupMessage(
|
RsServer::notify()->AddPopupMessage( RS_POPUP_GROUPCHAT, ci->PeerId().toStdString(), "", message );
|
||||||
RS_POPUP_GROUPCHAT,
|
//RsServer::notify()->AddFeedItem( RS_FEED_ITEM_CHAT_NEW, ci->PeerId().toStdString(), message, "" );
|
||||||
ci->PeerId().toStdString(), "", message );
|
|
||||||
RsServer::notify()->AddFeedItem(
|
|
||||||
RS_FEED_ITEM_CHAT_NEW,
|
|
||||||
ci->PeerId().toStdString(), message, "" );
|
|
||||||
#else // def RS_DIRECT_CHAT
|
#else // def RS_DIRECT_CHAT
|
||||||
/* Ignore deprecated direct node broadcast chat messages */
|
/* Ignore deprecated direct node broadcast chat messages */
|
||||||
return false;
|
return false;
|
||||||
|
@ -163,10 +163,25 @@ void RsGenExchange::tick()
|
|||||||
|
|
||||||
processRoutingClues() ;
|
processRoutingClues() ;
|
||||||
|
|
||||||
if(!mNotifications.empty())
|
|
||||||
{
|
{
|
||||||
notifyChanges(mNotifications);
|
std::vector<RsGxsNotify*> mNotifications_copy;
|
||||||
mNotifications.clear();
|
|
||||||
|
// make a non-deep copy of mNotifications so that it can be passed off-mutex to notifyChanged()
|
||||||
|
// that will delete it. The potential high cost of notifyChanges() makes it preferable to call off-mutex.
|
||||||
|
{
|
||||||
|
RS_STACK_MUTEX(mGenMtx);
|
||||||
|
if(!mNotifications.empty())
|
||||||
|
{
|
||||||
|
mNotifications_copy = mNotifications;
|
||||||
|
mNotifications.clear();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Calling notifyChanges() calls back RsGxsIfaceHelper::receiveChanges() that deletes the pointers in the array
|
||||||
|
// and the array itself. This is pretty bad and we should normally delete the changes here.
|
||||||
|
|
||||||
|
if(!mNotifications_copy.empty())
|
||||||
|
notifyChanges(mNotifications_copy);
|
||||||
}
|
}
|
||||||
|
|
||||||
// implemented service tick function
|
// implemented service tick function
|
||||||
@ -1118,38 +1133,25 @@ void RsGenExchange::receiveChanges(std::vector<RsGxsNotify*>& changes)
|
|||||||
if((mc = dynamic_cast<RsGxsMsgChange*>(n)) != nullptr)
|
if((mc = dynamic_cast<RsGxsMsgChange*>(n)) != nullptr)
|
||||||
{
|
{
|
||||||
if (mc->metaChange())
|
if (mc->metaChange())
|
||||||
{
|
|
||||||
addMessageChanged(out.mMsgsMeta, mc->msgChangeMap);
|
addMessageChanged(out.mMsgsMeta, mc->msgChangeMap);
|
||||||
}
|
|
||||||
else
|
else
|
||||||
{
|
|
||||||
addMessageChanged(out.mMsgs, mc->msgChangeMap);
|
addMessageChanged(out.mMsgs, mc->msgChangeMap);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
else if((gc = dynamic_cast<RsGxsGroupChange*>(n)) != nullptr)
|
else if((gc = dynamic_cast<RsGxsGroupChange*>(n)) != nullptr)
|
||||||
{
|
{
|
||||||
if(gc->metaChange())
|
if(gc->metaChange())
|
||||||
{
|
|
||||||
out.mGrpsMeta.splice(out.mGrpsMeta.end(), gc->mGrpIdList);
|
out.mGrpsMeta.splice(out.mGrpsMeta.end(), gc->mGrpIdList);
|
||||||
}
|
|
||||||
else
|
else
|
||||||
{
|
|
||||||
out.mGrps.splice(out.mGrps.end(), gc->mGrpIdList);
|
out.mGrps.splice(out.mGrps.end(), gc->mGrpIdList);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
else if(( gt =
|
else if(( gt = dynamic_cast<RsGxsDistantSearchResultChange*>(n) ) != nullptr)
|
||||||
dynamic_cast<RsGxsDistantSearchResultChange*>(n) ) != nullptr)
|
|
||||||
{
|
|
||||||
out.mDistantSearchReqs.push_back(gt->mRequestId);
|
out.mDistantSearchReqs.push_back(gt->mRequestId);
|
||||||
}
|
|
||||||
else
|
else
|
||||||
RsErr() << __PRETTY_FUNCTION__ << " Unknown changes type!"
|
RsErr() << __PRETTY_FUNCTION__ << " Unknown changes type!" << std::endl;
|
||||||
<< std::endl;
|
|
||||||
delete n;
|
delete n;
|
||||||
}
|
}
|
||||||
changes.clear() ;
|
changes.clear() ;
|
||||||
|
|
||||||
RsServer::notify()->notifyGxsChange(out);
|
|
||||||
if(rsEvents) rsEvents->postEvent(std::move(evt));
|
if(rsEvents) rsEvents->postEvent(std::move(evt));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1296,7 +1296,9 @@ bool p3GxsTunnelService::locked_sendEncryptedTunnelData(RsGxsTunnelItem *item)
|
|||||||
}
|
}
|
||||||
if(it->second.status != RS_GXS_TUNNEL_STATUS_CAN_TALK)
|
if(it->second.status != RS_GXS_TUNNEL_STATUS_CAN_TALK)
|
||||||
{
|
{
|
||||||
|
#ifdef DEBUG_GXS_TUNNEL
|
||||||
std::cerr << "(EE) Cannot talk to tunnel id " << tunnel_id << ". Tunnel status is: " << it->second.status << std::endl;
|
std::cerr << "(EE) Cannot talk to tunnel id " << tunnel_id << ". Tunnel status is: " << it->second.status << std::endl;
|
||||||
|
#endif
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1186,11 +1186,13 @@ int AuthSSLimpl::VerifyX509Callback(int /*preverify_ok*/, X509_STORE_CTX* ctx)
|
|||||||
|
|
||||||
RsErr() << __PRETTY_FUNCTION__ << " " << errMsg << std::endl;
|
RsErr() << __PRETTY_FUNCTION__ << " " << errMsg << std::endl;
|
||||||
|
|
||||||
if(rsEvents)
|
// if(rsEvents)
|
||||||
{
|
// {
|
||||||
ev->mErrorMsg = errMsg;
|
// ev->mErrorMsg = errMsg;
|
||||||
rsEvents->postEvent(std::move(ev));
|
// ev->mErrorCode = RsAuthSslConnectionAutenticationEvent::NO_CERTIFICATE_SUPPLIED;
|
||||||
}
|
//
|
||||||
|
// rsEvents->postEvent(std::move(ev));
|
||||||
|
// }
|
||||||
|
|
||||||
return verificationFailed;
|
return verificationFailed;
|
||||||
}
|
}
|
||||||
@ -1217,8 +1219,11 @@ int AuthSSLimpl::VerifyX509Callback(int /*preverify_ok*/, X509_STORE_CTX* ctx)
|
|||||||
if(rsEvents)
|
if(rsEvents)
|
||||||
{
|
{
|
||||||
ev->mSslCn = sslCn;
|
ev->mSslCn = sslCn;
|
||||||
|
ev->mSslId = sslId;
|
||||||
ev->mPgpId = pgpId;
|
ev->mPgpId = pgpId;
|
||||||
ev->mErrorMsg = errMsg;
|
ev->mErrorMsg = errMsg;
|
||||||
|
ev->mErrorCode = RsAuthSslError::MISSING_AUTHENTICATION_INFO;
|
||||||
|
|
||||||
rsEvents->postEvent(std::move(ev));
|
rsEvents->postEvent(std::move(ev));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1237,6 +1242,8 @@ int AuthSSLimpl::VerifyX509Callback(int /*preverify_ok*/, X509_STORE_CTX* ctx)
|
|||||||
ev->mSslId = sslId;
|
ev->mSslId = sslId;
|
||||||
ev->mSslCn = sslCn;
|
ev->mSslCn = sslCn;
|
||||||
ev->mErrorMsg = errMsg;
|
ev->mErrorMsg = errMsg;
|
||||||
|
ev->mErrorCode = RsAuthSslError::MISSING_AUTHENTICATION_INFO;
|
||||||
|
|
||||||
rsEvents->postEvent(std::move(ev));
|
rsEvents->postEvent(std::move(ev));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1266,6 +1273,7 @@ int AuthSSLimpl::VerifyX509Callback(int /*preverify_ok*/, X509_STORE_CTX* ctx)
|
|||||||
ev->mSslCn = sslCn;
|
ev->mSslCn = sslCn;
|
||||||
ev->mPgpId = pgpId;
|
ev->mPgpId = pgpId;
|
||||||
ev->mErrorMsg = errorMsg;
|
ev->mErrorMsg = errorMsg;
|
||||||
|
ev->mErrorCode = RsAuthSslError::MISMATCHED_PGP_ID;
|
||||||
rsEvents->postEvent(std::move(ev));
|
rsEvents->postEvent(std::move(ev));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1290,12 +1298,29 @@ int AuthSSLimpl::VerifyX509Callback(int /*preverify_ok*/, X509_STORE_CTX* ctx)
|
|||||||
ev->mSslId = sslId;
|
ev->mSslId = sslId;
|
||||||
ev->mSslCn = sslCn;
|
ev->mSslCn = sslCn;
|
||||||
ev->mPgpId = pgpId;
|
ev->mPgpId = pgpId;
|
||||||
|
|
||||||
|
switch(auth_diagnostic)
|
||||||
|
{
|
||||||
|
case RS_SSL_HANDSHAKE_DIAGNOSTIC_ISSUER_UNKNOWN:
|
||||||
|
ev->mErrorCode = RsAuthSslError::NOT_A_FRIEND;
|
||||||
|
break;
|
||||||
|
case RS_SSL_HANDSHAKE_DIAGNOSTIC_WRONG_SIGNATURE:
|
||||||
|
ev->mErrorCode = RsAuthSslError::PGP_SIGNATURE_VALIDATION_FAILED;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
ev->mErrorCode = RsAuthSslError::MISSING_AUTHENTICATION_INFO;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
ev->mErrorMsg = errMsg;
|
ev->mErrorMsg = errMsg;
|
||||||
rsEvents->postEvent(std::move(ev));
|
rsEvents->postEvent(std::move(ev));
|
||||||
}
|
}
|
||||||
|
|
||||||
return verificationFailed;
|
return verificationFailed;
|
||||||
}
|
}
|
||||||
|
#ifdef AUTHSSL_DEBUG
|
||||||
|
std::cerr << "******* VerifyX509Callback cert: " << std::hex << ctx->cert <<std::dec << std::endl;
|
||||||
|
#endif
|
||||||
|
|
||||||
if ( !isSslOnlyFriend && pgpId != AuthGPG::getAuthGPG()->getGPGOwnId() && !AuthGPG::getAuthGPG()->isGPGAccepted(pgpId) )
|
if ( !isSslOnlyFriend && pgpId != AuthGPG::getAuthGPG()->getGPGOwnId() && !AuthGPG::getAuthGPG()->isGPGAccepted(pgpId) )
|
||||||
{
|
{
|
||||||
@ -1311,28 +1336,20 @@ int AuthSSLimpl::VerifyX509Callback(int /*preverify_ok*/, X509_STORE_CTX* ctx)
|
|||||||
ev->mSslCn = sslCn;
|
ev->mSslCn = sslCn;
|
||||||
ev->mPgpId = pgpId;
|
ev->mPgpId = pgpId;
|
||||||
ev->mErrorMsg = errMsg;
|
ev->mErrorMsg = errMsg;
|
||||||
|
ev->mErrorCode = RsAuthSslError::NOT_A_FRIEND;
|
||||||
rsEvents->postEvent(std::move(ev));
|
rsEvents->postEvent(std::move(ev));
|
||||||
}
|
}
|
||||||
|
|
||||||
return verificationFailed;
|
return verificationFailed;
|
||||||
}
|
}
|
||||||
|
|
||||||
setCurrentConnectionAttemptInfo(pgpId, sslId, sslCn);
|
//setCurrentConnectionAttemptInfo(pgpId, sslId, sslCn);
|
||||||
LocalStoreCert(x509Cert);
|
LocalStoreCert(x509Cert);
|
||||||
|
|
||||||
RsInfo() << __PRETTY_FUNCTION__ << " authentication successfull for "
|
RsInfo() << __PRETTY_FUNCTION__ << " authentication successfull for "
|
||||||
<< "sslId: " << sslId << " isSslOnlyFriend: " << isSslOnlyFriend
|
<< "sslId: " << sslId << " isSslOnlyFriend: " << isSslOnlyFriend
|
||||||
<< std::endl;
|
<< std::endl;
|
||||||
|
|
||||||
if(rsEvents)
|
|
||||||
{
|
|
||||||
ev->mSuccess = true;
|
|
||||||
ev->mSslId = sslId;
|
|
||||||
ev->mSslCn = sslCn;
|
|
||||||
ev->mPgpId = pgpId;
|
|
||||||
rsEvents->postEvent(std::move(ev));
|
|
||||||
}
|
|
||||||
|
|
||||||
return verificationSuccess;
|
return verificationSuccess;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1583,32 +1600,6 @@ bool AuthSSLimpl::decrypt(void *&out, int &outlen, const void *in, int inlen)
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/********************************************************************************/
|
|
||||||
/********************************************************************************/
|
|
||||||
/********************* Cert Search / Add / Remove **************************/
|
|
||||||
/********************************************************************************/
|
|
||||||
/********************************************************************************/
|
|
||||||
|
|
||||||
void AuthSSLimpl::setCurrentConnectionAttemptInfo(const RsPgpId& gpg_id,const RsPeerId& ssl_id,const std::string& ssl_cn)
|
|
||||||
{
|
|
||||||
#ifdef AUTHSSL_DEBUG
|
|
||||||
std::cerr << "AuthSSL: registering connection attempt from:" << std::endl;
|
|
||||||
std::cerr << " GPG id: " << gpg_id << std::endl;
|
|
||||||
std::cerr << " SSL id: " << ssl_id << std::endl;
|
|
||||||
std::cerr << " SSL cn: " << ssl_cn << std::endl;
|
|
||||||
#endif
|
|
||||||
_last_gpgid_to_connect = gpg_id ;
|
|
||||||
_last_sslid_to_connect = ssl_id ;
|
|
||||||
_last_sslcn_to_connect = ssl_cn ;
|
|
||||||
}
|
|
||||||
void AuthSSLimpl::getCurrentConnectionAttemptInfo(RsPgpId& gpg_id,RsPeerId& ssl_id,std::string& ssl_cn)
|
|
||||||
{
|
|
||||||
gpg_id = _last_gpgid_to_connect ;
|
|
||||||
ssl_id = _last_sslid_to_connect ;
|
|
||||||
ssl_cn = _last_sslcn_to_connect ;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Locked search -> internal help function */
|
/* Locked search -> internal help function */
|
||||||
bool AuthSSLimpl::locked_FindCert(const RsPeerId& id, X509** cert)
|
bool AuthSSLimpl::locked_FindCert(const RsPeerId& id, X509** cert)
|
||||||
{
|
{
|
||||||
@ -1785,9 +1776,6 @@ bool AuthSSLimpl::loadList(std::list<RsItem*>& load)
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
RsAuthSslConnectionAutenticationEvent::RsAuthSslConnectionAutenticationEvent() :
|
|
||||||
RsEvent(RsEventType::AUTHSSL_CONNECTION_AUTENTICATION), mSuccess(false) {}
|
|
||||||
|
|
||||||
const EVP_PKEY*RsX509Cert::getPubKey(const X509& x509)
|
const EVP_PKEY*RsX509Cert::getPubKey(const X509& x509)
|
||||||
{
|
{
|
||||||
#if OPENSSL_VERSION_NUMBER < 0x10100000L || defined(LIBRESSL_VERSION_NUMBER)
|
#if OPENSSL_VERSION_NUMBER < 0x10100000L || defined(LIBRESSL_VERSION_NUMBER)
|
||||||
|
@ -52,34 +52,6 @@ RsPeerId getCertSslId(const X509& x509);
|
|||||||
const EVP_PKEY* getPubKey(const X509& x509);
|
const EVP_PKEY* getPubKey(const X509& x509);
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
|
||||||
* Event triggered by AuthSSL when authentication of a connection attempt either
|
|
||||||
* fail or success
|
|
||||||
*/
|
|
||||||
struct RsAuthSslConnectionAutenticationEvent : RsEvent
|
|
||||||
{
|
|
||||||
RsAuthSslConnectionAutenticationEvent();
|
|
||||||
|
|
||||||
bool mSuccess;
|
|
||||||
RsPeerId mSslId;
|
|
||||||
std::string mSslCn;
|
|
||||||
RsPgpId mPgpId;
|
|
||||||
std::string mErrorMsg;
|
|
||||||
|
|
||||||
///* @see RsEvent @see RsSerializable
|
|
||||||
void serial_process( RsGenericSerializer::SerializeJob j,
|
|
||||||
RsGenericSerializer::SerializeContext& ctx) override
|
|
||||||
{
|
|
||||||
RsEvent::serial_process(j, ctx);
|
|
||||||
RS_SERIAL_PROCESS(mSuccess);
|
|
||||||
RS_SERIAL_PROCESS(mSslId);
|
|
||||||
RS_SERIAL_PROCESS(mSslCn);
|
|
||||||
RS_SERIAL_PROCESS(mPgpId);
|
|
||||||
RS_SERIAL_PROCESS(mErrorMsg);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This is an implementation of SSL certificate authentication with PGP
|
* This is an implementation of SSL certificate authentication with PGP
|
||||||
* signatures, instead of centralized certification authority.
|
* signatures, instead of centralized certification authority.
|
||||||
@ -165,13 +137,6 @@ public:
|
|||||||
/// SSL specific functions used in pqissl/pqissllistener
|
/// SSL specific functions used in pqissl/pqissllistener
|
||||||
virtual SSL_CTX* getCTX() = 0;
|
virtual SSL_CTX* getCTX() = 0;
|
||||||
|
|
||||||
virtual void setCurrentConnectionAttemptInfo(
|
|
||||||
const RsPgpId& gpg_id, const RsPeerId& ssl_id,
|
|
||||||
const std::string& ssl_cn ) = 0;
|
|
||||||
virtual void getCurrentConnectionAttemptInfo(
|
|
||||||
RsPgpId& gpg_id, RsPeerId& ssl_id, std::string& ssl_cn ) = 0;
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This function parse X509 certificate from the file and return some
|
* This function parse X509 certificate from the file and return some
|
||||||
* verified informations, like ID and signer
|
* verified informations, like ID and signer
|
||||||
@ -258,14 +223,6 @@ public:
|
|||||||
/* SSL specific functions used in pqissl/pqissllistener */
|
/* SSL specific functions used in pqissl/pqissllistener */
|
||||||
SSL_CTX* getCTX() override;
|
SSL_CTX* getCTX() override;
|
||||||
|
|
||||||
/* Restored these functions: */
|
|
||||||
void setCurrentConnectionAttemptInfo(
|
|
||||||
const RsPgpId& gpg_id, const RsPeerId& ssl_id,
|
|
||||||
const std::string& ssl_cn ) override;
|
|
||||||
void getCurrentConnectionAttemptInfo(
|
|
||||||
RsPgpId& gpg_id, RsPeerId& ssl_id, std::string& ssl_cn ) override;
|
|
||||||
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
bool LocalStoreCert(X509* x509);
|
bool LocalStoreCert(X509* x509);
|
||||||
|
@ -473,27 +473,20 @@ void p3LinkMgrIMPL::tickMonitors()
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* notify GUI */
|
/* notify GUI */
|
||||||
if (peer.actions & RS_PEER_CONNECTED)
|
if (rsEvents && (peer.actions & RS_PEER_CONNECTED))
|
||||||
{
|
{
|
||||||
p3Notify *notify = RsServer::notify();
|
auto e = std::make_shared<RsConnectionEvent>();
|
||||||
|
e->mConnectionInfoCode = RsConnectionEventCode::PEER_CONNECTED;
|
||||||
if (notify)
|
e->mSslId = peer.id;
|
||||||
{
|
rsEvents->postEvent(e);
|
||||||
// normally these two below should disappear: there's no notion of popup in libretroshare.
|
|
||||||
// all GUI-type display features should be chosen in NotifyQt.
|
|
||||||
notify->AddPopupMessage(RS_POPUP_CONNECT, peer.id.toStdString(),"", "Online: ");
|
|
||||||
notify->AddFeedItem(RS_FEED_ITEM_PEER_CONNECT, peer.id.toStdString());
|
|
||||||
|
|
||||||
notify->notifyPeerConnected(peer.id.toStdString());
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
if (peer.actions & RS_PEER_DISCONNECTED)
|
if (rsEvents && (peer.actions & RS_PEER_DISCONNECTED))
|
||||||
{
|
{
|
||||||
p3Notify *notify = RsServer::notify();
|
auto e = std::make_shared<RsConnectionEvent>();
|
||||||
|
e->mConnectionInfoCode = RsConnectionEventCode::PEER_DISCONNECTED;
|
||||||
if (notify)
|
e->mSslId = peer.id;
|
||||||
notify->notifyPeerDisconnected(peer.id.toStdString());
|
rsEvents->postEvent(e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -217,8 +217,6 @@ void p3Notify::notifyChatLobbyEvent(uint64_t lobby_id, uint32_t event_type,const
|
|||||||
void p3Notify::notifyListPreChange(int list, int type) { FOR_ALL_NOTIFY_CLIENTS (*it)->notifyListPreChange(list,type) ; }
|
void p3Notify::notifyListPreChange(int list, int type) { FOR_ALL_NOTIFY_CLIENTS (*it)->notifyListPreChange(list,type) ; }
|
||||||
void p3Notify::notifyListChange (int list, int type) { FOR_ALL_NOTIFY_CLIENTS (*it)->notifyListChange (list,type) ; }
|
void p3Notify::notifyListChange (int list, int type) { FOR_ALL_NOTIFY_CLIENTS (*it)->notifyListChange (list,type) ; }
|
||||||
|
|
||||||
void p3Notify::notifyPeerConnected (const std::string& peer_id) { FOR_ALL_NOTIFY_CLIENTS (*it)->notifyPeerConnected(peer_id); }
|
|
||||||
void p3Notify::notifyPeerDisconnected (const std::string& peer_id) { FOR_ALL_NOTIFY_CLIENTS (*it)->notifyPeerDisconnected(peer_id); }
|
|
||||||
void p3Notify::notifyErrorMsg (int list, int sev, std::string msg) { FOR_ALL_NOTIFY_CLIENTS (*it)->notifyErrorMsg(list,sev,msg) ; }
|
void p3Notify::notifyErrorMsg (int list, int sev, std::string msg) { FOR_ALL_NOTIFY_CLIENTS (*it)->notifyErrorMsg(list,sev,msg) ; }
|
||||||
void p3Notify::notifyChatMessage (const ChatMessage &msg) { FOR_ALL_NOTIFY_CLIENTS (*it)->notifyChatMessage(msg) ; }
|
void p3Notify::notifyChatMessage (const ChatMessage &msg) { FOR_ALL_NOTIFY_CLIENTS (*it)->notifyChatMessage(msg) ; }
|
||||||
void p3Notify::notifyChatStatus (const ChatId& chat_id, const std::string& status_string) { FOR_ALL_NOTIFY_CLIENTS (*it)->notifyChatStatus(chat_id,status_string) ; }
|
void p3Notify::notifyChatStatus (const ChatId& chat_id, const std::string& status_string) { FOR_ALL_NOTIFY_CLIENTS (*it)->notifyChatStatus(chat_id,status_string) ; }
|
||||||
@ -235,8 +233,6 @@ void p3Notify::notifyOwnAvatarChanged ()
|
|||||||
void p3Notify::notifyOwnStatusMessageChanged() { FOR_ALL_NOTIFY_CLIENTS (*it)->notifyOwnStatusMessageChanged() ; }
|
void p3Notify::notifyOwnStatusMessageChanged() { FOR_ALL_NOTIFY_CLIENTS (*it)->notifyOwnStatusMessageChanged() ; }
|
||||||
void p3Notify::notifyDiskFull (uint32_t location , uint32_t size_limit_in_MB ) { FOR_ALL_NOTIFY_CLIENTS (*it)->notifyDiskFull (location,size_limit_in_MB) ; }
|
void p3Notify::notifyDiskFull (uint32_t location , uint32_t size_limit_in_MB ) { FOR_ALL_NOTIFY_CLIENTS (*it)->notifyDiskFull (location,size_limit_in_MB) ; }
|
||||||
void p3Notify::notifyPeerStatusChanged (const std::string& peer_id , uint32_t status ) { FOR_ALL_NOTIFY_CLIENTS (*it)->notifyPeerStatusChanged (peer_id,status) ; }
|
void p3Notify::notifyPeerStatusChanged (const std::string& peer_id , uint32_t status ) { FOR_ALL_NOTIFY_CLIENTS (*it)->notifyPeerStatusChanged (peer_id,status) ; }
|
||||||
void p3Notify::notifyGxsChange (const RsGxsChanges& changes) {FOR_ALL_NOTIFY_CLIENTS (*it)->notifyGxsChange(changes) ;}
|
|
||||||
void p3Notify::notifyConnectionWithoutCert () { FOR_ALL_NOTIFY_CLIENTS (*it)->notifyConnectionWithoutCert(); }
|
|
||||||
|
|
||||||
void p3Notify::notifyPeerStatusChangedSummary () { FOR_ALL_NOTIFY_CLIENTS (*it)->notifyPeerStatusChangedSummary() ; }
|
void p3Notify::notifyPeerStatusChangedSummary () { FOR_ALL_NOTIFY_CLIENTS (*it)->notifyPeerStatusChangedSummary() ; }
|
||||||
void p3Notify::notifyDiscInfoChanged () { FOR_ALL_NOTIFY_CLIENTS (*it)->notifyDiscInfoChanged () ; }
|
void p3Notify::notifyDiscInfoChanged () { FOR_ALL_NOTIFY_CLIENTS (*it)->notifyDiscInfoChanged () ; }
|
||||||
|
@ -91,8 +91,6 @@ class p3Notify: public RsNotify
|
|||||||
|
|
||||||
// Notifications of clients. Can be called from anywhere inside libretroshare.
|
// Notifications of clients. Can be called from anywhere inside libretroshare.
|
||||||
//
|
//
|
||||||
void notifyPeerConnected (const std::string& /* peer_id */);
|
|
||||||
void notifyPeerDisconnected (const std::string& /* peer_id */);
|
|
||||||
void notifyListPreChange (int /* list */, int /* type */) ;
|
void notifyListPreChange (int /* list */, int /* type */) ;
|
||||||
void notifyListChange (int /* list */, int /* type */) ;
|
void notifyListChange (int /* list */, int /* type */) ;
|
||||||
void notifyErrorMsg (int /* list */, int /* sev */, std::string /* msg */) ;
|
void notifyErrorMsg (int /* list */, int /* sev */, std::string /* msg */) ;
|
||||||
@ -111,7 +109,6 @@ class p3Notify: public RsNotify
|
|||||||
void notifyOwnStatusMessageChanged () ;
|
void notifyOwnStatusMessageChanged () ;
|
||||||
void notifyDiskFull (uint32_t /* location */, uint32_t /* size limit in MB */) ;
|
void notifyDiskFull (uint32_t /* location */, uint32_t /* size limit in MB */) ;
|
||||||
void notifyPeerStatusChanged (const std::string& /* peer_id */, uint32_t /* status */) ;
|
void notifyPeerStatusChanged (const std::string& /* peer_id */, uint32_t /* status */) ;
|
||||||
void notifyGxsChange (const RsGxsChanges& /* changes */);
|
|
||||||
void notifyConnectionWithoutCert ();
|
void notifyConnectionWithoutCert ();
|
||||||
|
|
||||||
void notifyPeerStatusChangedSummary () ;
|
void notifyPeerStatusChangedSummary () ;
|
||||||
|
@ -1804,12 +1804,24 @@ bool p3PeerMgrIMPL::addCandidateForOwnExternalAddress(const RsPeerId &from, cons
|
|||||||
|
|
||||||
// Notify for every friend that has reported a wrong external address, except if that address is in the IP whitelist.
|
// Notify for every friend that has reported a wrong external address, except if that address is in the IP whitelist.
|
||||||
|
|
||||||
if((rsBanList!=NULL && !rsBanList->isAddressAccepted(addr_filtered,RSBANLIST_CHECKING_FLAGS_WHITELIST)) && (!sockaddr_storage_sameip(own_addr,addr_filtered)))
|
if((rsBanList && !rsBanList->isAddressAccepted(addr_filtered, RSBANLIST_CHECKING_FLAGS_WHITELIST))
|
||||||
{
|
&& !sockaddr_storage_sameip(own_addr, addr_filtered) )
|
||||||
std::cerr << " Peer " << from << " reports a connection address (" << sockaddr_storage_iptostring(addr_filtered) <<") that is not your current external address (" << sockaddr_storage_iptostring(own_addr) << "). This is weird." << std::endl;
|
{
|
||||||
|
RsInfo() << __PRETTY_FUNCTION__ << " Peer " << from
|
||||||
|
<< " reports a connection address (" << addr_filtered
|
||||||
|
<<") that is not your current external address ("
|
||||||
|
<< own_addr << "). This is weird." << std::endl;
|
||||||
|
|
||||||
RsServer::notify()->AddFeedItem(RS_FEED_ITEM_SEC_IP_WRONG_EXTERNAL_IP_REPORTED, from.toStdString(), sockaddr_storage_iptostring(own_addr), sockaddr_storage_iptostring(addr));
|
if(rsEvents)
|
||||||
}
|
{
|
||||||
|
auto ev = std::make_shared<RsConnectionEvent>();
|
||||||
|
ev->mSslId = from;
|
||||||
|
ev->mOwnLocator = RsUrl(own_addr);
|
||||||
|
ev->mReportedLocator = RsUrl(addr);
|
||||||
|
ev->mConnectionInfoCode = RsConnectionEventCode::PEER_REPORTS_WRONG_IP;
|
||||||
|
rsEvents->postEvent(ev);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// we could also sweep over all connected friends and see if some report a different address.
|
// we could also sweep over all connected friends and see if some report a different address.
|
||||||
|
|
||||||
|
@ -1096,8 +1096,7 @@ int pqissl::SSL_Connection_Complete()
|
|||||||
if (err != 1)
|
if (err != 1)
|
||||||
{
|
{
|
||||||
int serr = SSL_get_error(ssl_connection, err);
|
int serr = SSL_get_error(ssl_connection, err);
|
||||||
if ((serr == SSL_ERROR_WANT_READ)
|
if ((serr == SSL_ERROR_WANT_READ) || (serr == SSL_ERROR_WANT_WRITE))
|
||||||
|| (serr == SSL_ERROR_WANT_WRITE))
|
|
||||||
{
|
{
|
||||||
#ifdef PQISSL_LOG_DEBUG
|
#ifdef PQISSL_LOG_DEBUG
|
||||||
rslog(RSL_DEBUG_BASIC, pqisslzone,
|
rslog(RSL_DEBUG_BASIC, pqisslzone,
|
||||||
@ -1108,6 +1107,14 @@ int pqissl::SSL_Connection_Complete()
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(rsEvents)
|
||||||
|
{
|
||||||
|
X509 *x509 = SSL_get_peer_certificate(ssl_connection);
|
||||||
|
auto ev = std::make_shared<RsAuthSslConnectionAutenticationEvent>();
|
||||||
|
ev->mSslId = RsX509Cert::getCertSslId(*x509);
|
||||||
|
ev->mErrorCode = RsAuthSslError::PEER_REFUSED_CONNECTION;
|
||||||
|
rsEvents->postEvent(ev);
|
||||||
|
}
|
||||||
|
|
||||||
std::string out;
|
std::string out;
|
||||||
rs_sprintf(out, "pqissl::SSL_Connection_Complete()\nIssues with SSL Connect(%d)!\n", err);
|
rs_sprintf(out, "pqissl::SSL_Connection_Complete()\nIssues with SSL Connect(%d)!\n", err);
|
||||||
@ -1253,10 +1260,12 @@ int pqissl::accept_locked( SSL *ssl, int fd,
|
|||||||
if (rsPeers->servicePermissionFlags(PeerId()) & RS_NODE_PERM_REQUIRE_WL)
|
if (rsPeers->servicePermissionFlags(PeerId()) & RS_NODE_PERM_REQUIRE_WL)
|
||||||
checking_flags |= RSBANLIST_CHECKING_FLAGS_WHITELIST;
|
checking_flags |= RSBANLIST_CHECKING_FLAGS_WHITELIST;
|
||||||
|
|
||||||
if(rsBanList && !rsBanList->isAddressAccepted(
|
if( RsX509Cert::getCertSslId(*SSL_get_peer_certificate(ssl)) != PeerId())
|
||||||
foreign_addr, checking_flags, check_result ))
|
std::cerr << "(EE) pqissl::accept_locked(): PeerId() is " << PeerId() << " but certificate ID is " << RsX509Cert::getCertSslId(*SSL_get_peer_certificate(ssl)) << std::endl;
|
||||||
|
|
||||||
|
if(rsBanList && !rsBanList->isAddressAccepted( foreign_addr, checking_flags, check_result ))
|
||||||
{
|
{
|
||||||
RsErr() << __PRETTY_FUNCTION__
|
RsInfo() << __PRETTY_FUNCTION__
|
||||||
<< " Refusing incoming SSL connection from blacklisted "
|
<< " Refusing incoming SSL connection from blacklisted "
|
||||||
<< "foreign address " << foreign_addr
|
<< "foreign address " << foreign_addr
|
||||||
<< ". Reason: " << check_result << ". This should never happen "
|
<< ". Reason: " << check_result << ". This should never happen "
|
||||||
@ -1264,11 +1273,16 @@ int pqissl::accept_locked( SSL *ssl, int fd,
|
|||||||
<< std::endl;
|
<< std::endl;
|
||||||
print_stacktrace();
|
print_stacktrace();
|
||||||
|
|
||||||
RsServer::notify()->AddFeedItem(
|
if(rsEvents)
|
||||||
RS_FEED_ITEM_SEC_IP_BLACKLISTED,
|
{
|
||||||
PeerId().toStdString(),
|
X509 *x509 = SSL_get_peer_certificate(ssl);
|
||||||
sockaddr_storage_iptostring(foreign_addr), "", "",
|
auto ev = std::make_shared<RsAuthSslConnectionAutenticationEvent>();
|
||||||
check_result);
|
ev->mSslId = RsX509Cert::getCertSslId(*x509);
|
||||||
|
ev->mLocator = RsUrl(foreign_addr);
|
||||||
|
ev->mErrorCode = RsAuthSslError::IP_IS_BLACKLISTED;
|
||||||
|
rsEvents->postEvent(ev);
|
||||||
|
}
|
||||||
|
|
||||||
reset_locked();
|
reset_locked();
|
||||||
return failure;
|
return failure;
|
||||||
}
|
}
|
||||||
@ -1324,7 +1338,7 @@ int pqissl::accept_locked( SSL *ssl, int fd,
|
|||||||
/* shutdown existing - in all cases use the new one */
|
/* shutdown existing - in all cases use the new one */
|
||||||
if ((ssl_connection) && (ssl_connection != ssl))
|
if ((ssl_connection) && (ssl_connection != ssl))
|
||||||
{
|
{
|
||||||
std::cerr << __PRETTY_FUNCTION__
|
RsInfo() << __PRETTY_FUNCTION__
|
||||||
<< " closing Previous/Existing ssl_connection" << std::endl;
|
<< " closing Previous/Existing ssl_connection" << std::endl;
|
||||||
SSL_shutdown(ssl_connection);
|
SSL_shutdown(ssl_connection);
|
||||||
SSL_free (ssl_connection);
|
SSL_free (ssl_connection);
|
||||||
@ -1332,7 +1346,7 @@ int pqissl::accept_locked( SSL *ssl, int fd,
|
|||||||
|
|
||||||
if ((sockfd > -1) && (sockfd != fd))
|
if ((sockfd > -1) && (sockfd != fd))
|
||||||
{
|
{
|
||||||
std::cerr << __PRETTY_FUNCTION__ << " closing Previous/Existing sockfd"
|
RsInfo() << __PRETTY_FUNCTION__ << " closing Previous/Existing sockfd"
|
||||||
<< std::endl;
|
<< std::endl;
|
||||||
net_internal_close(sockfd);
|
net_internal_close(sockfd);
|
||||||
}
|
}
|
||||||
@ -1348,7 +1362,7 @@ int pqissl::accept_locked( SSL *ssl, int fd,
|
|||||||
*/
|
*/
|
||||||
sockaddr_storage_copy(foreign_addr, remote_addr);
|
sockaddr_storage_copy(foreign_addr, remote_addr);
|
||||||
|
|
||||||
std::cerr << __PRETTY_FUNCTION__ << " SUCCESSFUL connection to: "
|
RsInfo() << __PRETTY_FUNCTION__ << " SUCCESSFUL connection to: "
|
||||||
<< PeerId().toStdString() << " remoteaddr: "
|
<< PeerId().toStdString() << " remoteaddr: "
|
||||||
<< sockaddr_storage_iptostring(remote_addr) << std::endl;
|
<< sockaddr_storage_iptostring(remote_addr) << std::endl;
|
||||||
|
|
||||||
|
@ -424,23 +424,8 @@ int pqissllistenbase::continueSSL(IncomingSSLInfo& incoming_connexion_info, bool
|
|||||||
{
|
{
|
||||||
// attempt the accept again.
|
// attempt the accept again.
|
||||||
int fd = SSL_get_fd(incoming_connexion_info.ssl);
|
int fd = SSL_get_fd(incoming_connexion_info.ssl);
|
||||||
|
|
||||||
AuthSSL::getAuthSSL()->setCurrentConnectionAttemptInfo(RsPgpId(),RsPeerId(),std::string()) ;
|
|
||||||
int err = SSL_accept(incoming_connexion_info.ssl);
|
int err = SSL_accept(incoming_connexion_info.ssl);
|
||||||
|
|
||||||
// Now grab the connection info that was filled in by the callback.
|
|
||||||
// In the case the callback did not succeed the SSL certificate will not be accessible
|
|
||||||
// from SSL_get_peer_certificate, so we need to get it from the callback system.
|
|
||||||
//
|
|
||||||
AuthSSL::getAuthSSL()->getCurrentConnectionAttemptInfo(incoming_connexion_info.gpgid,incoming_connexion_info.sslid,incoming_connexion_info.sslcn) ;
|
|
||||||
|
|
||||||
#ifdef DEBUG_LISTENNER
|
|
||||||
std::cerr << "Info from callback: " << std::endl;
|
|
||||||
std::cerr << " Got PGP Id = " << incoming_connexion_info.gpgid << std::endl;
|
|
||||||
std::cerr << " Got SSL Id = " << incoming_connexion_info.sslid << std::endl;
|
|
||||||
std::cerr << " Got SSL CN = " << incoming_connexion_info.sslcn << std::endl;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
if (err <= 0)
|
if (err <= 0)
|
||||||
{
|
{
|
||||||
int ssl_err = SSL_get_error(incoming_connexion_info.ssl, err);
|
int ssl_err = SSL_get_error(incoming_connexion_info.ssl, err);
|
||||||
@ -486,10 +471,22 @@ int pqissllistenbase::continueSSL(IncomingSSLInfo& incoming_connexion_info, bool
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
closeConnection(fd, incoming_connexion_info.ssl) ;
|
|
||||||
|
|
||||||
pqioutput(PQL_WARNING, pqissllistenzone, "Read Error on the SSL Socket\nShutting it down!");
|
pqioutput(PQL_WARNING, pqissllistenzone, "Read Error on the SSL Socket\nShutting it down!");
|
||||||
|
|
||||||
|
// We use SSL_get_verify_result() in order to differentiate two cases:
|
||||||
|
// case 1: the incoming connection is closed because the peer is not a friend. This is already handled in authssl.
|
||||||
|
// case 2: the incoming connection is closed because no authentication info is available, in which case it returns X509_V_OK
|
||||||
|
auto vres = SSL_get_verify_result(incoming_connexion_info.ssl);
|
||||||
|
|
||||||
|
if(vres == X509_V_OK && nullptr != rsEvents)
|
||||||
|
{
|
||||||
|
auto ev = std::make_shared<RsAuthSslConnectionAutenticationEvent>();
|
||||||
|
ev->mLocator = RsUrl(incoming_connexion_info.addr);
|
||||||
|
ev->mErrorCode = RsAuthSslError::MISSING_AUTHENTICATION_INFO;
|
||||||
|
rsEvents->postEvent(ev);
|
||||||
|
}
|
||||||
|
closeConnection(fd, incoming_connexion_info.ssl);
|
||||||
|
|
||||||
// failure -1, pending 0, sucess 1.
|
// failure -1, pending 0, sucess 1.
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
@ -505,23 +502,22 @@ int pqissllistenbase::continueSSL(IncomingSSLInfo& incoming_connexion_info, bool
|
|||||||
incoming_connexion_info.sslcn = RsX509Cert::getCertName(*x509);
|
incoming_connexion_info.sslcn = RsX509Cert::getCertName(*x509);
|
||||||
incoming_connexion_info.sslid = RsX509Cert::getCertSslId(*x509);
|
incoming_connexion_info.sslid = RsX509Cert::getCertSslId(*x509);
|
||||||
|
|
||||||
#ifdef DEBUG_LISTENNER
|
#ifndef DEBUG_LISTENNER
|
||||||
|
std::cerr << "ContinueSSL:" << std::endl;
|
||||||
std::cerr << " Got PGP Id = " << incoming_connexion_info.gpgid << std::endl;
|
std::cerr << " Got PGP Id = " << incoming_connexion_info.gpgid << std::endl;
|
||||||
std::cerr << " Got SSL Id = " << incoming_connexion_info.sslid << std::endl;
|
std::cerr << " Got SSL Id = " << incoming_connexion_info.sslid << std::endl;
|
||||||
std::cerr << " Got SSL CN = " << incoming_connexion_info.sslcn << std::endl;
|
std::cerr << " Got SSL CN = " << incoming_connexion_info.sslcn << std::endl;
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef DEBUG_LISTENNER
|
#ifdef DEBUG_LISTENNER
|
||||||
else
|
else
|
||||||
std::cerr << " no info." << std::endl;
|
std::cerr << " no info." << std::endl;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
// if it succeeds
|
// if it succeeds
|
||||||
if (0 < completeConnection(fd, incoming_connexion_info))
|
if (0 < completeConnection(fd, incoming_connexion_info))
|
||||||
{
|
|
||||||
return 1;
|
return 1;
|
||||||
}
|
|
||||||
|
|
||||||
/* else we shut it down! */
|
/* else we shut it down! */
|
||||||
pqioutput(PQL_WARNING, pqissllistenzone,
|
pqioutput(PQL_WARNING, pqissllistenzone,
|
||||||
|
@ -27,6 +27,7 @@
|
|||||||
#include <functional>
|
#include <functional>
|
||||||
|
|
||||||
#include "util/rsmemory.h"
|
#include "util/rsmemory.h"
|
||||||
|
#include "util/rsurl.h"
|
||||||
#include "serialiser/rsserializable.h"
|
#include "serialiser/rsserializable.h"
|
||||||
#include "serialiser/rstypeserializer.h"
|
#include "serialiser/rstypeserializer.h"
|
||||||
#include "util/rstime.h"
|
#include "util/rstime.h"
|
||||||
@ -61,7 +62,7 @@ enum class RsEventType : uint32_t
|
|||||||
AUTHSSL_CONNECTION_AUTENTICATION = 3,
|
AUTHSSL_CONNECTION_AUTENTICATION = 3,
|
||||||
|
|
||||||
/// @see pqissl
|
/// @see pqissl
|
||||||
REMOTE_PEER_REFUSED_CONNECTION = 4,
|
PEER_CONNECTION = 4,
|
||||||
|
|
||||||
/// @see RsGxsChanges
|
/// @see RsGxsChanges
|
||||||
GXS_CHANGES = 5,
|
GXS_CHANGES = 5,
|
||||||
@ -72,6 +73,18 @@ enum class RsEventType : uint32_t
|
|||||||
/// @see RsMailStatusEvent
|
/// @see RsMailStatusEvent
|
||||||
MAIL_STATUS_CHANGE = 7,
|
MAIL_STATUS_CHANGE = 7,
|
||||||
|
|
||||||
|
/// @see RsGxsCircleEvent
|
||||||
|
GXS_CIRCLES = 8,
|
||||||
|
|
||||||
|
/// @see RsGxsChannelEvent
|
||||||
|
GXS_CHANNELS = 9,
|
||||||
|
|
||||||
|
/// @see RsGxsForumEvent
|
||||||
|
GXS_FORUMS = 10,
|
||||||
|
|
||||||
|
/// @see RsGxsPostedEvent
|
||||||
|
GXS_POSTED = 11,
|
||||||
|
|
||||||
MAX /// Used to detect invalid event type passed
|
MAX /// Used to detect invalid event type passed
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -173,3 +186,4 @@ public:
|
|||||||
|
|
||||||
virtual ~RsEvents();
|
virtual ~RsEvents();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -103,6 +103,48 @@ struct RsGxsChannelPost : RsSerializable
|
|||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
enum class RsChannelEventCode: uint8_t
|
||||||
|
{
|
||||||
|
UNKNOWN = 0x00,
|
||||||
|
NEW_CHANNEL = 0x01, /// emitted when new channel is received
|
||||||
|
|
||||||
|
/// emitted when existing channel is updated
|
||||||
|
UPDATED_CHANNEL = 0x02,
|
||||||
|
|
||||||
|
/// new message reeived in a particular channel (group and msg id)
|
||||||
|
NEW_MESSAGE = 0x03,
|
||||||
|
|
||||||
|
/// existing message has been updated in a particular channel
|
||||||
|
UPDATED_MESSAGE = 0x04,
|
||||||
|
|
||||||
|
/// publish key for this channel has been received
|
||||||
|
RECEIVED_PUBLISH_KEY = 0x05,
|
||||||
|
|
||||||
|
/// subscription for channel mChannelGroupId changed.
|
||||||
|
SUBSCRIBE_STATUS_CHANGED = 0x06,
|
||||||
|
};
|
||||||
|
|
||||||
|
struct RsGxsChannelEvent: RsEvent
|
||||||
|
{
|
||||||
|
RsGxsChannelEvent():
|
||||||
|
RsEvent(RsEventType::GXS_CHANNELS),
|
||||||
|
mChannelEventCode(RsChannelEventCode::UNKNOWN) {}
|
||||||
|
|
||||||
|
RsChannelEventCode mChannelEventCode;
|
||||||
|
RsGxsGroupId mChannelGroupId;
|
||||||
|
RsGxsMessageId mChannelMsgId;
|
||||||
|
|
||||||
|
///* @see RsEvent @see RsSerializable
|
||||||
|
void serial_process( RsGenericSerializer::SerializeJob j,RsGenericSerializer::SerializeContext& ctx) override
|
||||||
|
{
|
||||||
|
RsEvent::serial_process(j, ctx);
|
||||||
|
|
||||||
|
RS_SERIAL_PROCESS(mChannelEventCode);
|
||||||
|
RS_SERIAL_PROCESS(mChannelGroupId);
|
||||||
|
RS_SERIAL_PROCESS(mChannelMsgId);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
class RsGxsChannels: public RsGxsIfaceHelper, public RsGxsCommentService
|
class RsGxsChannels: public RsGxsIfaceHelper, public RsGxsCommentService
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
@ -123,7 +123,7 @@ struct RsGxsCircleDetails : RsSerializable
|
|||||||
{
|
{
|
||||||
RsGxsCircleDetails() :
|
RsGxsCircleDetails() :
|
||||||
mCircleType(static_cast<uint32_t>(RsGxsCircleType::EXTERNAL)),
|
mCircleType(static_cast<uint32_t>(RsGxsCircleType::EXTERNAL)),
|
||||||
mAmIAllowed(false) {}
|
mAmIAllowed(false),mAmIAdmin(false) {}
|
||||||
~RsGxsCircleDetails() override;
|
~RsGxsCircleDetails() override;
|
||||||
|
|
||||||
RsGxsCircleId mCircleId;
|
RsGxsCircleId mCircleId;
|
||||||
@ -136,6 +136,9 @@ struct RsGxsCircleDetails : RsSerializable
|
|||||||
* list & subscribed list). */
|
* list & subscribed list). */
|
||||||
bool mAmIAllowed;
|
bool mAmIAllowed;
|
||||||
|
|
||||||
|
/// true when we're an administrator of the circle group, meaning that we can add/remove members from the invitee list.
|
||||||
|
bool mAmIAdmin;
|
||||||
|
|
||||||
/// This crosses admin list and subscribed list
|
/// This crosses admin list and subscribed list
|
||||||
std::set<RsGxsId> mAllowedGxsIds;
|
std::set<RsGxsId> mAllowedGxsIds;
|
||||||
std::set<RsPgpId> mAllowedNodes;
|
std::set<RsPgpId> mAllowedNodes;
|
||||||
@ -152,12 +155,63 @@ struct RsGxsCircleDetails : RsSerializable
|
|||||||
RS_SERIAL_PROCESS(mCircleType);
|
RS_SERIAL_PROCESS(mCircleType);
|
||||||
RS_SERIAL_PROCESS(mRestrictedCircleId);
|
RS_SERIAL_PROCESS(mRestrictedCircleId);
|
||||||
RS_SERIAL_PROCESS(mAmIAllowed);
|
RS_SERIAL_PROCESS(mAmIAllowed);
|
||||||
|
RS_SERIAL_PROCESS(mAmIAdmin);
|
||||||
RS_SERIAL_PROCESS(mAllowedGxsIds);
|
RS_SERIAL_PROCESS(mAllowedGxsIds);
|
||||||
RS_SERIAL_PROCESS(mAllowedNodes);
|
RS_SERIAL_PROCESS(mAllowedNodes);
|
||||||
RS_SERIAL_PROCESS(mSubscriptionFlags);
|
RS_SERIAL_PROCESS(mSubscriptionFlags);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
enum class RsGxsCircleEventCode: uint8_t
|
||||||
|
{
|
||||||
|
UNKNOWN = 0x00,
|
||||||
|
|
||||||
|
/** mCircleId contains the circle id and mGxsId is the id requesting
|
||||||
|
* membership */
|
||||||
|
CIRCLE_MEMBERSHIP_REQUEST = 0x01,
|
||||||
|
|
||||||
|
/** mCircleId is the circle that invites me, and mGxsId is my own Id that is
|
||||||
|
* invited */
|
||||||
|
CIRCLE_MEMBERSHIP_INVITE = 0x02,
|
||||||
|
|
||||||
|
/** mCircleId contains the circle id and mGxsId is the id dropping
|
||||||
|
* membership */
|
||||||
|
CIRCLE_MEMBERSHIP_LEAVE = 0x03,
|
||||||
|
|
||||||
|
/// mCircleId contains the circle id and mGxsId is the id of the new member
|
||||||
|
CIRCLE_MEMBERSHIP_JOIN = 0x04,
|
||||||
|
|
||||||
|
/** mCircleId contains the circle id and mGxsId is the id that was revoqued
|
||||||
|
* by admin */
|
||||||
|
CIRCLE_MEMBERSHIP_REVOQUED= 0x05,
|
||||||
|
};
|
||||||
|
|
||||||
|
struct RsGxsCircleEvent: RsEvent
|
||||||
|
{
|
||||||
|
RsGxsCircleEvent()
|
||||||
|
: RsEvent(RsEventType::GXS_CIRCLES),
|
||||||
|
mCircleEventType(RsGxsCircleEventCode::UNKNOWN) {}
|
||||||
|
|
||||||
|
|
||||||
|
RsGxsCircleEventCode mCircleEventType;
|
||||||
|
RsGxsCircleId mCircleId;
|
||||||
|
RsGxsId mGxsId;
|
||||||
|
|
||||||
|
///* @see RsEvent @see RsSerializable
|
||||||
|
void serial_process(
|
||||||
|
RsGenericSerializer::SerializeJob j,
|
||||||
|
RsGenericSerializer::SerializeContext& ctx ) override
|
||||||
|
{
|
||||||
|
RsEvent::serial_process(j, ctx);
|
||||||
|
RS_SERIAL_PROCESS(mCircleEventType);
|
||||||
|
RS_SERIAL_PROCESS(mCircleId);
|
||||||
|
RS_SERIAL_PROCESS(mGxsId);
|
||||||
|
}
|
||||||
|
|
||||||
|
~RsGxsCircleEvent() override;
|
||||||
|
};
|
||||||
|
|
||||||
class RsGxsCircles: public RsGxsIfaceHelper
|
class RsGxsCircles: public RsGxsIfaceHelper
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
@ -243,6 +297,17 @@ public:
|
|||||||
*/
|
*/
|
||||||
virtual bool getCircleRequests( const RsGxsGroupId& circleId,
|
virtual bool getCircleRequests( const RsGxsGroupId& circleId,
|
||||||
std::vector<RsGxsCircleMsg>& requests ) = 0;
|
std::vector<RsGxsCircleMsg>& requests ) = 0;
|
||||||
|
/**
|
||||||
|
* @brief Get specific circle request
|
||||||
|
* @jsonapi{development}
|
||||||
|
* @param[in] circleId id of the circle of which the requests are requested
|
||||||
|
* @param[in] msgId id of the request
|
||||||
|
* @param[out] msg storage for the circle request
|
||||||
|
* @return false if something failed, true otherwhise
|
||||||
|
*/
|
||||||
|
virtual bool getCircleRequest(const RsGxsGroupId& circleId,
|
||||||
|
const RsGxsMessageId& msgId,
|
||||||
|
RsGxsCircleMsg& msg) =0;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Invite identities to circle
|
* @brief Invite identities to circle
|
||||||
|
@ -105,6 +105,46 @@ struct RsGxsForumMsg : RsSerializable
|
|||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
enum class RsForumEventCode: uint8_t
|
||||||
|
{
|
||||||
|
UNKNOWN = 0x00,
|
||||||
|
NEW_FORUM = 0x01, /// emitted when new forum is received
|
||||||
|
UPDATED_FORUM = 0x02, /// emitted when existing forum is updated
|
||||||
|
|
||||||
|
/// new message reeived in a particular forum
|
||||||
|
NEW_MESSAGE = 0x03,
|
||||||
|
|
||||||
|
/// existing message has been updated in a particular forum
|
||||||
|
UPDATED_MESSAGE = 0x04,
|
||||||
|
|
||||||
|
/// forum was subscribed or unsubscribed
|
||||||
|
SUBSCRIBE_STATUS_CHANGED = 0x05,
|
||||||
|
};
|
||||||
|
|
||||||
|
struct RsGxsForumEvent: RsEvent
|
||||||
|
{
|
||||||
|
RsGxsForumEvent()
|
||||||
|
: RsEvent(RsEventType::GXS_FORUMS),
|
||||||
|
mForumEventCode(RsForumEventCode::UNKNOWN) {}
|
||||||
|
|
||||||
|
RsForumEventCode mForumEventCode;
|
||||||
|
RsGxsGroupId mForumGroupId;
|
||||||
|
RsGxsMessageId mForumMsgId;
|
||||||
|
|
||||||
|
///* @see RsEvent @see RsSerializable
|
||||||
|
void serial_process(
|
||||||
|
RsGenericSerializer::SerializeJob j,
|
||||||
|
RsGenericSerializer::SerializeContext& ctx ) override
|
||||||
|
{
|
||||||
|
RsEvent::serial_process(j, ctx);
|
||||||
|
RS_SERIAL_PROCESS(mForumEventCode);
|
||||||
|
RS_SERIAL_PROCESS(mForumGroupId);
|
||||||
|
RS_SERIAL_PROCESS(mForumMsgId);
|
||||||
|
}
|
||||||
|
|
||||||
|
~RsGxsForumEvent() override;
|
||||||
|
};
|
||||||
|
|
||||||
class RsGxsForums: public RsGxsIfaceHelper
|
class RsGxsForums: public RsGxsIfaceHelper
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
@ -296,10 +296,25 @@ struct MsgTagType : RsSerializable
|
|||||||
} //namespace Rs
|
} //namespace Rs
|
||||||
} //namespace Msgs
|
} //namespace Msgs
|
||||||
|
|
||||||
|
|
||||||
|
enum class RsMailStatusEventCode: uint8_t
|
||||||
|
{
|
||||||
|
NEW_MESSAGE = 0x00,
|
||||||
|
MESSAGE_REMOVED = 0x01,
|
||||||
|
MESSAGE_SENT = 0x02,
|
||||||
|
|
||||||
|
/// means the peer received the message
|
||||||
|
MESSAGE_RECEIVED_ACK = 0x03,
|
||||||
|
|
||||||
|
/// An error occurred attempting to sign the message
|
||||||
|
SIGNATURE_FAILED = 0x04,
|
||||||
|
};
|
||||||
|
|
||||||
struct RsMailStatusEvent : RsEvent
|
struct RsMailStatusEvent : RsEvent
|
||||||
{
|
{
|
||||||
RsMailStatusEvent() : RsEvent(RsEventType::MAIL_STATUS_CHANGE) {}
|
RsMailStatusEvent() : RsEvent(RsEventType::MAIL_STATUS_CHANGE) {}
|
||||||
|
|
||||||
|
RsMailStatusEventCode mMailStatusEventCode;
|
||||||
std::set<RsMailMessageId> mChangedMsgIds;
|
std::set<RsMailMessageId> mChangedMsgIds;
|
||||||
|
|
||||||
/// @see RsEvent
|
/// @see RsEvent
|
||||||
@ -308,6 +323,7 @@ struct RsMailStatusEvent : RsEvent
|
|||||||
{
|
{
|
||||||
RsEvent::serial_process(j, ctx);
|
RsEvent::serial_process(j, ctx);
|
||||||
RS_SERIAL_PROCESS(mChangedMsgIds);
|
RS_SERIAL_PROCESS(mChangedMsgIds);
|
||||||
|
RS_SERIAL_PROCESS(mMailStatusEventCode);
|
||||||
}
|
}
|
||||||
|
|
||||||
~RsMailStatusEvent() override;
|
~RsMailStatusEvent() override;
|
||||||
|
@ -79,9 +79,10 @@ const uint32_t RS_FEED_ITEM_PEER_DISCONNECT = RS_FEED_TYPE_PEER | 0x000
|
|||||||
const uint32_t RS_FEED_ITEM_PEER_HELLO = RS_FEED_TYPE_PEER | 0x0003;
|
const uint32_t RS_FEED_ITEM_PEER_HELLO = RS_FEED_TYPE_PEER | 0x0003;
|
||||||
const uint32_t RS_FEED_ITEM_PEER_NEW = RS_FEED_TYPE_PEER | 0x0004;
|
const uint32_t RS_FEED_ITEM_PEER_NEW = RS_FEED_TYPE_PEER | 0x0004;
|
||||||
const uint32_t RS_FEED_ITEM_PEER_OFFSET = RS_FEED_TYPE_PEER | 0x0005;
|
const uint32_t RS_FEED_ITEM_PEER_OFFSET = RS_FEED_TYPE_PEER | 0x0005;
|
||||||
|
const uint32_t RS_FEED_ITEM_PEER_DENIES_CONNEXION = RS_FEED_TYPE_PEER | 0x0006;
|
||||||
|
|
||||||
const uint32_t RS_FEED_ITEM_SEC_CONNECT_ATTEMPT = RS_FEED_TYPE_SECURITY | 0x0001;
|
const uint32_t RS_FEED_ITEM_SEC_CONNECT_ATTEMPT = RS_FEED_TYPE_SECURITY | 0x0001;
|
||||||
const uint32_t RS_FEED_ITEM_SEC_AUTH_DENIED = RS_FEED_TYPE_SECURITY | 0x0002;
|
const uint32_t RS_FEED_ITEM_SEC_AUTH_DENIED = RS_FEED_TYPE_SECURITY | 0x0002; // locally denied connection
|
||||||
const uint32_t RS_FEED_ITEM_SEC_UNKNOWN_IN = RS_FEED_TYPE_SECURITY | 0x0003;
|
const uint32_t RS_FEED_ITEM_SEC_UNKNOWN_IN = RS_FEED_TYPE_SECURITY | 0x0003;
|
||||||
const uint32_t RS_FEED_ITEM_SEC_UNKNOWN_OUT = RS_FEED_TYPE_SECURITY | 0x0004;
|
const uint32_t RS_FEED_ITEM_SEC_UNKNOWN_OUT = RS_FEED_TYPE_SECURITY | 0x0004;
|
||||||
const uint32_t RS_FEED_ITEM_SEC_WRONG_SIGNATURE = RS_FEED_TYPE_SECURITY | 0x0005;
|
const uint32_t RS_FEED_ITEM_SEC_WRONG_SIGNATURE = RS_FEED_TYPE_SECURITY | 0x0005;
|
||||||
@ -114,8 +115,11 @@ const uint32_t RS_FEED_ITEM_CHAT_NEW = RS_FEED_TYPE_CHAT | 0x0001;
|
|||||||
const uint32_t RS_FEED_ITEM_MESSAGE = RS_FEED_TYPE_MSG | 0x0001;
|
const uint32_t RS_FEED_ITEM_MESSAGE = RS_FEED_TYPE_MSG | 0x0001;
|
||||||
const uint32_t RS_FEED_ITEM_FILES_NEW = RS_FEED_TYPE_FILES | 0x0001;
|
const uint32_t RS_FEED_ITEM_FILES_NEW = RS_FEED_TYPE_FILES | 0x0001;
|
||||||
|
|
||||||
const uint32_t RS_FEED_ITEM_CIRCLE_MEMB_REQ = RS_FEED_TYPE_CIRCLE | 0x0001;
|
const uint32_t RS_FEED_ITEM_CIRCLE_MEMB_REQ = RS_FEED_TYPE_CIRCLE | 0x0001;
|
||||||
const uint32_t RS_FEED_ITEM_CIRCLE_INVIT_REC = RS_FEED_TYPE_CIRCLE | 0x0002;
|
const uint32_t RS_FEED_ITEM_CIRCLE_INVIT_REC = RS_FEED_TYPE_CIRCLE | 0x0002;
|
||||||
|
const uint32_t RS_FEED_ITEM_CIRCLE_MEMB_LEAVE = RS_FEED_TYPE_CIRCLE | 0x0003;
|
||||||
|
const uint32_t RS_FEED_ITEM_CIRCLE_MEMB_JOIN = RS_FEED_TYPE_CIRCLE | 0x0004;
|
||||||
|
const uint32_t RS_FEED_ITEM_CIRCLE_MEMB_REVOQUED = RS_FEED_TYPE_CIRCLE | 0x0005;
|
||||||
|
|
||||||
const uint32_t RS_MESSAGE_CONNECT_ATTEMPT = 0x0001;
|
const uint32_t RS_MESSAGE_CONNECT_ATTEMPT = 0x0001;
|
||||||
|
|
||||||
@ -212,8 +216,6 @@ public:
|
|||||||
NotifyClient() {}
|
NotifyClient() {}
|
||||||
virtual ~NotifyClient() {}
|
virtual ~NotifyClient() {}
|
||||||
|
|
||||||
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 notifyListPreChange (int /* list */, int /* type */) {}
|
||||||
virtual void notifyListChange (int /* list */, int /* type */) {}
|
virtual void notifyListChange (int /* list */, int /* type */) {}
|
||||||
virtual void notifyErrorMsg (int /* list */, int /* sev */, std::string /* msg */) {}
|
virtual void notifyErrorMsg (int /* list */, int /* sev */, std::string /* msg */) {}
|
||||||
@ -230,8 +232,6 @@ public:
|
|||||||
virtual void notifyOwnStatusMessageChanged () {}
|
virtual void notifyOwnStatusMessageChanged () {}
|
||||||
virtual void notifyDiskFull (uint32_t /* location */, uint32_t /* size limit in MB */) {}
|
virtual void notifyDiskFull (uint32_t /* location */, uint32_t /* size limit in MB */) {}
|
||||||
virtual void notifyPeerStatusChanged (const std::string& /* peer_id */, uint32_t /* status */) {}
|
virtual void notifyPeerStatusChanged (const std::string& /* peer_id */, uint32_t /* status */) {}
|
||||||
virtual void notifyGxsChange (const RsGxsChanges& /* changes */) {}
|
|
||||||
virtual void notifyConnectionWithoutCert () {}
|
|
||||||
|
|
||||||
/* one or more peers has changed the states */
|
/* one or more peers has changed the states */
|
||||||
virtual void notifyPeerStatusChangedSummary () {}
|
virtual void notifyPeerStatusChangedSummary () {}
|
||||||
|
@ -206,6 +206,100 @@ std::string RsPeerTrustString(uint32_t trustLvl);
|
|||||||
std::string RsPeerNetModeString(uint32_t netModel);
|
std::string RsPeerNetModeString(uint32_t netModel);
|
||||||
std::string RsPeerLastConnectString(uint32_t lastConnect);
|
std::string RsPeerLastConnectString(uint32_t lastConnect);
|
||||||
|
|
||||||
|
//===================================================================================================//
|
||||||
|
// Connexion and security events //
|
||||||
|
//===================================================================================================//
|
||||||
|
|
||||||
|
enum class RsAuthSslError: uint8_t
|
||||||
|
{
|
||||||
|
NO_ERROR = 0x00,
|
||||||
|
MISSING_AUTHENTICATION_INFO = 0x01,
|
||||||
|
PGP_SIGNATURE_VALIDATION_FAILED = 0x02,
|
||||||
|
MISMATCHED_PGP_ID = 0x03,
|
||||||
|
NO_CERTIFICATE_SUPPLIED = 0x04,
|
||||||
|
NOT_A_FRIEND = 0x05,
|
||||||
|
MISSING_CERTIFICATE = 0x06,
|
||||||
|
IP_IS_BLACKLISTED = 0x07,
|
||||||
|
PEER_REFUSED_CONNECTION = 0x08,
|
||||||
|
UNKNOWN_ERROR = 0x09,
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Event triggered by AuthSSL when authentication of a connection attempt either
|
||||||
|
* fail or success
|
||||||
|
*/
|
||||||
|
struct RsAuthSslConnectionAutenticationEvent : RsEvent
|
||||||
|
{
|
||||||
|
RsAuthSslConnectionAutenticationEvent() :
|
||||||
|
RsEvent(RsEventType::AUTHSSL_CONNECTION_AUTENTICATION) {}
|
||||||
|
|
||||||
|
RsPeerId mSslId;
|
||||||
|
std::string mSslCn;
|
||||||
|
RsPgpId mPgpId;
|
||||||
|
RsUrl mLocator;
|
||||||
|
std::string mErrorMsg;
|
||||||
|
RsAuthSslError mErrorCode;
|
||||||
|
|
||||||
|
///* @see RsEvent @see RsSerializable
|
||||||
|
void serial_process( RsGenericSerializer::SerializeJob j,
|
||||||
|
RsGenericSerializer::SerializeContext& ctx) override
|
||||||
|
{
|
||||||
|
RsEvent::serial_process(j, ctx);
|
||||||
|
RS_SERIAL_PROCESS(mSslId);
|
||||||
|
RS_SERIAL_PROCESS(mSslCn);
|
||||||
|
RS_SERIAL_PROCESS(mPgpId);
|
||||||
|
RS_SERIAL_PROCESS(mLocator);
|
||||||
|
RS_SERIAL_PROCESS(mErrorMsg);
|
||||||
|
RS_SERIAL_PROCESS(mErrorCode);
|
||||||
|
}
|
||||||
|
|
||||||
|
~RsAuthSslConnectionAutenticationEvent() override;
|
||||||
|
};
|
||||||
|
|
||||||
|
enum class RsConnectionEventCode: uint8_t
|
||||||
|
{
|
||||||
|
UNKNOWN = 0x00,
|
||||||
|
PEER_CONNECTED = 0x01,
|
||||||
|
PEER_DISCONNECTED = 0x02,
|
||||||
|
PEER_TIME_SHIFT = 0x03, // mTimeShift = time shift in seconds
|
||||||
|
PEER_REPORTS_WRONG_IP = 0x04, // mPeerLocator = address reported, mOwnLocator = own address
|
||||||
|
};
|
||||||
|
|
||||||
|
struct RsConnectionEvent : RsEvent
|
||||||
|
{
|
||||||
|
RsConnectionEvent()
|
||||||
|
: RsEvent(RsEventType::PEER_CONNECTION),
|
||||||
|
mConnectionInfoCode(RsConnectionEventCode::UNKNOWN), mTimeShift(0) {}
|
||||||
|
|
||||||
|
RsConnectionEventCode mConnectionInfoCode;
|
||||||
|
RsPeerId mSslId;
|
||||||
|
RsUrl mOwnLocator;
|
||||||
|
RsUrl mReportedLocator;
|
||||||
|
|
||||||
|
/** If there is a time shift with the peer aka
|
||||||
|
* mConnectionInfoCode == PEER_TIME_SHIFT contains the time shift value in
|
||||||
|
* seconds */
|
||||||
|
rstime_t mTimeShift;
|
||||||
|
|
||||||
|
///* @see RsEvent @see RsSerializable
|
||||||
|
void serial_process(
|
||||||
|
RsGenericSerializer::SerializeJob j,
|
||||||
|
RsGenericSerializer::SerializeContext& ctx ) override
|
||||||
|
{
|
||||||
|
RsEvent::serial_process(j, ctx);
|
||||||
|
RS_SERIAL_PROCESS(mConnectionInfoCode);
|
||||||
|
RS_SERIAL_PROCESS(mSslId);
|
||||||
|
RS_SERIAL_PROCESS(mOwnLocator);
|
||||||
|
RS_SERIAL_PROCESS(mReportedLocator);
|
||||||
|
RS_SERIAL_PROCESS(mTimeShift);
|
||||||
|
}
|
||||||
|
|
||||||
|
~RsConnectionEvent() override;
|
||||||
|
};
|
||||||
|
|
||||||
|
//===================================================================================================//
|
||||||
|
// Peer Details //
|
||||||
|
//===================================================================================================//
|
||||||
|
|
||||||
/* We should definitely split this into 2 sub-structures:
|
/* We should definitely split this into 2 sub-structures:
|
||||||
* PGP info (or profile info) with all info related to PGP keys
|
* PGP info (or profile info) with all info related to PGP keys
|
||||||
|
@ -68,6 +68,33 @@ class RsPostedGroup
|
|||||||
std::ostream &operator<<(std::ostream &out, const RsPostedGroup &group);
|
std::ostream &operator<<(std::ostream &out, const RsPostedGroup &group);
|
||||||
std::ostream &operator<<(std::ostream &out, const RsPostedPost &post);
|
std::ostream &operator<<(std::ostream &out, const RsPostedPost &post);
|
||||||
|
|
||||||
|
enum class RsPostedEventCode: uint8_t
|
||||||
|
{
|
||||||
|
UNKNOWN = 0x00,
|
||||||
|
NEW_POSTED_GROUP = 0x01,
|
||||||
|
NEW_MESSAGE = 0x02
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
struct RsGxsPostedEvent: RsEvent
|
||||||
|
{
|
||||||
|
RsGxsPostedEvent():
|
||||||
|
RsEvent(RsEventType::GXS_POSTED),
|
||||||
|
mPostedEventCode(RsPostedEventCode::UNKNOWN) {}
|
||||||
|
|
||||||
|
RsPostedEventCode mPostedEventCode;
|
||||||
|
RsGxsGroupId mPostedGroupId;
|
||||||
|
RsGxsMessageId mPostedMsgId;
|
||||||
|
|
||||||
|
///* @see RsEvent @see RsSerializable
|
||||||
|
void serial_process( RsGenericSerializer::SerializeJob j,RsGenericSerializer::SerializeContext& ctx) override
|
||||||
|
{
|
||||||
|
RsEvent::serial_process(j, ctx);
|
||||||
|
RS_SERIAL_PROCESS(mPostedEventCode);
|
||||||
|
RS_SERIAL_PROCESS(mPostedGroupId);
|
||||||
|
RS_SERIAL_PROCESS(mPostedMsgId);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
class RsPosted : public RsGxsIfaceHelper, public RsGxsCommentService
|
class RsPosted : public RsGxsIfaceHelper, public RsGxsCommentService
|
||||||
{
|
{
|
||||||
|
@ -1859,3 +1859,5 @@ RsPeerStateChangedEvent::RsPeerStateChangedEvent(RsPeerId sslId) :
|
|||||||
RsEvent(RsEventType::PEER_STATE_CHANGED), mSslId(sslId) {}
|
RsEvent(RsEventType::PEER_STATE_CHANGED), mSslId(sslId) {}
|
||||||
|
|
||||||
RsPeers::~RsPeers() = default;
|
RsPeers::~RsPeers() = default;
|
||||||
|
RsAuthSslConnectionAutenticationEvent::~RsAuthSslConnectionAutenticationEvent() = default;
|
||||||
|
RsConnectionEvent::~RsConnectionEvent() = default;
|
||||||
|
@ -136,14 +136,14 @@ uint32_t p3GxsChannels::channelsAuthenPolicy()
|
|||||||
static const uint32_t GXS_CHANNELS_CONFIG_MAX_TIME_NOTIFY_STORAGE = 86400*30*2 ; // ignore notifications for 2 months
|
static const uint32_t GXS_CHANNELS_CONFIG_MAX_TIME_NOTIFY_STORAGE = 86400*30*2 ; // ignore notifications for 2 months
|
||||||
static const uint8_t GXS_CHANNELS_CONFIG_SUBTYPE_NOTIFY_RECORD = 0x01 ;
|
static const uint8_t GXS_CHANNELS_CONFIG_SUBTYPE_NOTIFY_RECORD = 0x01 ;
|
||||||
|
|
||||||
struct RsGxsForumNotifyRecordsItem: public RsItem
|
struct RsGxsGroupNotifyRecordsItem: public RsItem
|
||||||
{
|
{
|
||||||
|
|
||||||
RsGxsForumNotifyRecordsItem()
|
RsGxsGroupNotifyRecordsItem()
|
||||||
: RsItem(RS_PKT_VERSION_SERVICE,RS_SERVICE_GXS_TYPE_CHANNELS_CONFIG,GXS_CHANNELS_CONFIG_SUBTYPE_NOTIFY_RECORD)
|
: RsItem(RS_PKT_VERSION_SERVICE,RS_SERVICE_GXS_TYPE_CHANNELS_CONFIG,GXS_CHANNELS_CONFIG_SUBTYPE_NOTIFY_RECORD)
|
||||||
{}
|
{}
|
||||||
|
|
||||||
virtual ~RsGxsForumNotifyRecordsItem() {}
|
virtual ~RsGxsGroupNotifyRecordsItem() {}
|
||||||
|
|
||||||
void serial_process( RsGenericSerializer::SerializeJob j,
|
void serial_process( RsGenericSerializer::SerializeJob j,
|
||||||
RsGenericSerializer::SerializeContext& ctx )
|
RsGenericSerializer::SerializeContext& ctx )
|
||||||
@ -167,7 +167,7 @@ public:
|
|||||||
|
|
||||||
switch(item_sub_id)
|
switch(item_sub_id)
|
||||||
{
|
{
|
||||||
case GXS_CHANNELS_CONFIG_SUBTYPE_NOTIFY_RECORD: return new RsGxsForumNotifyRecordsItem();
|
case GXS_CHANNELS_CONFIG_SUBTYPE_NOTIFY_RECORD: return new RsGxsGroupNotifyRecordsItem();
|
||||||
default:
|
default:
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
@ -178,7 +178,7 @@ bool p3GxsChannels::saveList(bool &cleanup, std::list<RsItem *>&saveList)
|
|||||||
{
|
{
|
||||||
cleanup = true ;
|
cleanup = true ;
|
||||||
|
|
||||||
RsGxsForumNotifyRecordsItem *item = new RsGxsForumNotifyRecordsItem ;
|
RsGxsGroupNotifyRecordsItem *item = new RsGxsGroupNotifyRecordsItem ;
|
||||||
|
|
||||||
{
|
{
|
||||||
RS_STACK_MUTEX(mKnownChannelsMutex);
|
RS_STACK_MUTEX(mKnownChannelsMutex);
|
||||||
@ -198,7 +198,7 @@ bool p3GxsChannels::loadList(std::list<RsItem *>& loadList)
|
|||||||
|
|
||||||
rstime_t now = time(NULL);
|
rstime_t now = time(NULL);
|
||||||
|
|
||||||
RsGxsForumNotifyRecordsItem *fnr = dynamic_cast<RsGxsForumNotifyRecordsItem*>(item) ;
|
RsGxsGroupNotifyRecordsItem *fnr = dynamic_cast<RsGxsGroupNotifyRecordsItem*>(item) ;
|
||||||
|
|
||||||
if(fnr)
|
if(fnr)
|
||||||
{
|
{
|
||||||
@ -238,12 +238,6 @@ void p3GxsChannels::notifyChanges(std::vector<RsGxsNotify *> &changes)
|
|||||||
std::cerr << "p3GxsChannels::notifyChanges() : " << changes.size() << "changes to notify" << std::endl;
|
std::cerr << "p3GxsChannels::notifyChanges() : " << changes.size() << "changes to notify" << std::endl;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
p3Notify* notify = nullptr;
|
|
||||||
if (!changes.empty())
|
|
||||||
{
|
|
||||||
notify = RsServer::notify();
|
|
||||||
}
|
|
||||||
|
|
||||||
/* iterate through and grab any new messages */
|
/* iterate through and grab any new messages */
|
||||||
std::list<RsGxsGroupId> unprocessedGroups;
|
std::list<RsGxsGroupId> unprocessedGroups;
|
||||||
|
|
||||||
@ -256,13 +250,17 @@ void p3GxsChannels::notifyChanges(std::vector<RsGxsNotify *> &changes)
|
|||||||
if (msgChange->getType() == RsGxsNotify::TYPE_RECEIVED_NEW)
|
if (msgChange->getType() == RsGxsNotify::TYPE_RECEIVED_NEW)
|
||||||
{
|
{
|
||||||
/* message received */
|
/* message received */
|
||||||
if (notify)
|
if (rsEvents)
|
||||||
{
|
{
|
||||||
std::map<RsGxsGroupId, std::set<RsGxsMessageId> > &msgChangeMap = msgChange->msgChangeMap;
|
std::map<RsGxsGroupId, std::set<RsGxsMessageId> > &msgChangeMap = msgChange->msgChangeMap;
|
||||||
for (auto mit = msgChangeMap.begin(); mit != msgChangeMap.end(); ++mit)
|
for (auto mit = msgChangeMap.begin(); mit != msgChangeMap.end(); ++mit)
|
||||||
for (auto mit1 = mit->second.begin(); mit1 != mit->second.end(); ++mit1)
|
for (auto mit1 = mit->second.begin(); mit1 != mit->second.end(); ++mit1)
|
||||||
{
|
{
|
||||||
notify->AddFeedItem(RS_FEED_ITEM_CHANNEL_MSG, mit->first.toStdString(), mit1->toStdString());
|
auto ev = std::make_shared<RsGxsChannelEvent>();
|
||||||
|
ev->mChannelMsgId = *mit1;
|
||||||
|
ev->mChannelGroupId = mit->first;
|
||||||
|
ev->mChannelEventCode = RsChannelEventCode::NEW_MESSAGE;
|
||||||
|
rsEvents->postEvent(ev);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -298,48 +296,68 @@ void p3GxsChannels::notifyChanges(std::vector<RsGxsNotify *> &changes)
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (notify)
|
if (rsEvents)
|
||||||
{
|
{
|
||||||
RsGxsGroupChange *grpChange = dynamic_cast<RsGxsGroupChange*>(*it);
|
RsGxsGroupChange *grpChange = dynamic_cast<RsGxsGroupChange*>(*it);
|
||||||
if (grpChange)
|
if (grpChange)
|
||||||
{
|
{
|
||||||
switch (grpChange->getType())
|
switch (grpChange->getType())
|
||||||
{
|
{
|
||||||
default:
|
default:
|
||||||
case RsGxsNotify::TYPE_PROCESSED:
|
case RsGxsNotify::TYPE_PROCESSED: // happens when the group is subscribed
|
||||||
case RsGxsNotify::TYPE_PUBLISHED:
|
{
|
||||||
break;
|
std::list<RsGxsGroupId> &grpList = grpChange->mGrpIdList;
|
||||||
|
std::list<RsGxsGroupId>::iterator git;
|
||||||
case RsGxsNotify::TYPE_RECEIVED_NEW:
|
for (git = grpList.begin(); git != grpList.end(); ++git)
|
||||||
{
|
{
|
||||||
/* group received */
|
auto ev = std::make_shared<RsGxsChannelEvent>();
|
||||||
std::list<RsGxsGroupId> &grpList = grpChange->mGrpIdList;
|
ev->mChannelGroupId = *git;
|
||||||
std::list<RsGxsGroupId>::iterator git;
|
ev->mChannelEventCode = RsChannelEventCode::SUBSCRIBE_STATUS_CHANGED;
|
||||||
RS_STACK_MUTEX(mKnownChannelsMutex);
|
rsEvents->postEvent(ev);
|
||||||
for (git = grpList.begin(); git != grpList.end(); ++git)
|
|
||||||
{
|
|
||||||
if(mKnownChannels.find(*git) == mKnownChannels.end())
|
|
||||||
{
|
|
||||||
notify->AddFeedItem(RS_FEED_ITEM_CHANNEL_NEW, git->toStdString());
|
|
||||||
mKnownChannels.insert(std::make_pair(*git,time(NULL))) ;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
std::cerr << "(II) Not notifying already known channel " << *git << std::endl;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
case RsGxsNotify::TYPE_RECEIVED_PUBLISHKEY:
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
case RsGxsNotify::TYPE_PUBLISHED:
|
||||||
|
case RsGxsNotify::TYPE_RECEIVED_NEW:
|
||||||
|
{
|
||||||
|
/* group received */
|
||||||
|
std::list<RsGxsGroupId> &grpList = grpChange->mGrpIdList;
|
||||||
|
std::list<RsGxsGroupId>::iterator git;
|
||||||
|
RS_STACK_MUTEX(mKnownChannelsMutex);
|
||||||
|
for (git = grpList.begin(); git != grpList.end(); ++git)
|
||||||
{
|
{
|
||||||
/* group received */
|
if(mKnownChannels.find(*git) == mKnownChannels.end())
|
||||||
std::list<RsGxsGroupId> &grpList = grpChange->mGrpIdList;
|
|
||||||
std::list<RsGxsGroupId>::iterator git;
|
|
||||||
for (git = grpList.begin(); git != grpList.end(); ++git)
|
|
||||||
{
|
{
|
||||||
notify->AddFeedItem(RS_FEED_ITEM_CHANNEL_PUBLISHKEY, git->toStdString());
|
mKnownChannels.insert(std::make_pair(*git,time(NULL))) ;
|
||||||
|
IndicateConfigChanged();
|
||||||
|
|
||||||
|
auto ev = std::make_shared<RsGxsChannelEvent>();
|
||||||
|
ev->mChannelGroupId = *git;
|
||||||
|
ev->mChannelEventCode = RsChannelEventCode::NEW_CHANNEL;
|
||||||
|
rsEvents->postEvent(ev);
|
||||||
}
|
}
|
||||||
break;
|
else
|
||||||
|
std::cerr << "(II) Not notifying already known channel " << *git << std::endl;
|
||||||
}
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
case RsGxsNotify::TYPE_RECEIVED_PUBLISHKEY:
|
||||||
|
{
|
||||||
|
/* group received */
|
||||||
|
std::list<RsGxsGroupId> &grpList = grpChange->mGrpIdList;
|
||||||
|
std::list<RsGxsGroupId>::iterator git;
|
||||||
|
for (git = grpList.begin(); git != grpList.end(); ++git)
|
||||||
|
{
|
||||||
|
auto ev = std::make_shared<RsGxsChannelEvent>();
|
||||||
|
ev->mChannelGroupId = *git;
|
||||||
|
ev->mChannelEventCode = RsChannelEventCode::RECEIVED_PUBLISH_KEY;
|
||||||
|
rsEvents->postEvent(ev);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -351,6 +369,7 @@ void p3GxsChannels::notifyChanges(std::vector<RsGxsNotify *> &changes)
|
|||||||
if(!unprocessedGroups.empty())
|
if(!unprocessedGroups.empty())
|
||||||
request_SpecificSubscribedGroups(unprocessedGroups);
|
request_SpecificSubscribedGroups(unprocessedGroups);
|
||||||
|
|
||||||
|
// the call below deletes changes and its content.
|
||||||
RsGxsIfaceHelper::receiveChanges(changes);
|
RsGxsIfaceHelper::receiveChanges(changes);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -305,6 +305,32 @@ bool p3GxsCircles::getCircleRequests( const RsGxsGroupId& circleId,
|
|||||||
return getMsgData(token, requests);
|
return getMsgData(token, requests);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool p3GxsCircles::getCircleRequest(const RsGxsGroupId& circleId,const RsGxsMessageId& msgId,RsGxsCircleMsg& msg)
|
||||||
|
{
|
||||||
|
RsTokReqOptions opts;
|
||||||
|
opts.mReqType = GXS_REQUEST_TYPE_MSG_DATA;
|
||||||
|
|
||||||
|
std::set<RsGxsMessageId> contentsIds;
|
||||||
|
contentsIds.insert(msgId);
|
||||||
|
|
||||||
|
GxsMsgReq msgIds;
|
||||||
|
msgIds[circleId] = contentsIds;
|
||||||
|
|
||||||
|
uint32_t token;
|
||||||
|
if( !requestMsgInfo(token, opts, msgIds) || waitToken(token) != RsTokenService::COMPLETE )
|
||||||
|
return false;
|
||||||
|
|
||||||
|
std::vector<RsGxsCircleMsg> msgs;
|
||||||
|
|
||||||
|
if(getMsgData(token, msgs) && msgs.size() == 1)
|
||||||
|
{
|
||||||
|
msg = msgs.front();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
bool p3GxsCircles::inviteIdsToCircle( const std::set<RsGxsId>& identities,
|
bool p3GxsCircles::inviteIdsToCircle( const std::set<RsGxsId>& identities,
|
||||||
const RsGxsCircleId& circleId )
|
const RsGxsCircleId& circleId )
|
||||||
{
|
{
|
||||||
@ -442,6 +468,7 @@ void p3GxsCircles::service_tick()
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void p3GxsCircles::notifyChanges(std::vector<RsGxsNotify *> &changes)
|
void p3GxsCircles::notifyChanges(std::vector<RsGxsNotify *> &changes)
|
||||||
{
|
{
|
||||||
#ifdef DEBUG_CIRCLES
|
#ifdef DEBUG_CIRCLES
|
||||||
@ -467,13 +494,31 @@ void p3GxsCircles::notifyChanges(std::vector<RsGxsNotify *> &changes)
|
|||||||
#ifdef DEBUG_CIRCLES
|
#ifdef DEBUG_CIRCLES
|
||||||
std::cerr << " Msgs for Group: " << mit->first << std::endl;
|
std::cerr << " Msgs for Group: " << mit->first << std::endl;
|
||||||
#endif
|
#endif
|
||||||
force_cache_reload(RsGxsCircleId(mit->first));
|
RsGxsCircleId circle_id(mit->first);
|
||||||
|
|
||||||
if (notify && (c->getType() == RsGxsNotify::TYPE_RECEIVED_NEW) )
|
force_cache_reload(circle_id);
|
||||||
|
|
||||||
|
RsGxsCircleDetails details;
|
||||||
|
getCircleDetails(circle_id,details);
|
||||||
|
|
||||||
|
if(rsEvents && (c->getType() == RsGxsNotify::TYPE_RECEIVED_NEW) )
|
||||||
for (auto msgIdIt(mit->second.begin()), end(mit->second.end()); msgIdIt != end; ++msgIdIt)
|
for (auto msgIdIt(mit->second.begin()), end(mit->second.end()); msgIdIt != end; ++msgIdIt)
|
||||||
{
|
{
|
||||||
const RsGxsMessageId& msgId = *msgIdIt;
|
RsGxsCircleMsg msg;
|
||||||
notify->AddFeedItem(RS_FEED_ITEM_CIRCLE_MEMB_REQ,RsGxsCircleId(mit->first).toStdString(),msgId.toStdString());
|
getCircleRequest(RsGxsGroupId(circle_id),*msgIdIt,msg);
|
||||||
|
|
||||||
|
auto ev = std::make_shared<RsGxsCircleEvent>();
|
||||||
|
ev->mCircleId = circle_id;
|
||||||
|
ev->mGxsId = msg.mMeta.mAuthorId;
|
||||||
|
|
||||||
|
if (msg.stuff == "SUBSCRIPTION_REQUEST_UNSUBSCRIBE")
|
||||||
|
ev->mCircleEventType = RsGxsCircleEventCode::CIRCLE_MEMBERSHIP_LEAVE;
|
||||||
|
else if(details.mAllowedGxsIds.find(msg.mMeta.mAuthorId) != details.mAllowedGxsIds.end())
|
||||||
|
ev->mCircleEventType = RsGxsCircleEventCode::CIRCLE_MEMBERSHIP_JOIN;
|
||||||
|
else
|
||||||
|
ev->mCircleEventType = RsGxsCircleEventCode::CIRCLE_MEMBERSHIP_REQUEST;
|
||||||
|
|
||||||
|
rsEvents->postEvent(ev);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -506,15 +551,59 @@ void p3GxsCircles::notifyChanges(std::vector<RsGxsNotify *> &changes)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if(groupChange)
|
if(groupChange)
|
||||||
|
{
|
||||||
|
std::list<RsGxsId> own_ids;
|
||||||
|
rsIdentity->getOwnIds(own_ids);
|
||||||
|
|
||||||
for(std::list<RsGxsGroupId>::const_iterator git(groupChange->mGrpIdList.begin());git!=groupChange->mGrpIdList.end();++git)
|
for(std::list<RsGxsGroupId>::const_iterator git(groupChange->mGrpIdList.begin());git!=groupChange->mGrpIdList.end();++git)
|
||||||
{
|
{
|
||||||
#ifdef DEBUG_CIRCLES
|
#ifdef DEBUG_CIRCLES
|
||||||
std::cerr << " forcing cache loading for circle " << *git << " in order to trigger subscribe update." << std::endl;
|
std::cerr << " forcing cache loading for circle " << *git << " in order to trigger subscribe update." << std::endl;
|
||||||
#endif
|
#endif
|
||||||
force_cache_reload(RsGxsCircleId(*git)) ;
|
|
||||||
if (notify && (c->getType() == RsGxsNotify::TYPE_RECEIVED_NEW) )
|
#ifdef TODO
|
||||||
notify->AddFeedItem(RS_FEED_ITEM_CIRCLE_INVIT_REC,RsGxsCircleId(*git).toStdString(),"");
|
// This code will not work: we would like to detect changes in the circle data that reflects the fact that one of the
|
||||||
}
|
// owned GXS ids is invited. But there's no way to compare the old circle data to the new if cache has to be updated.
|
||||||
|
// For this we need to add the old metadata and group data in the RsGxsGroupChange structure and account for it.
|
||||||
|
|
||||||
|
if(rsEvents && (c->getType() == RsGxsNotify::TYPE_RECEIVED_NEW) )
|
||||||
|
{
|
||||||
|
RsGxsCircleId circle_id(*git);
|
||||||
|
force_cache_reload(circle_id);
|
||||||
|
|
||||||
|
RsGxsCircleDetails details;
|
||||||
|
getCircleDetails(circle_id,details);
|
||||||
|
|
||||||
|
// We check that the change corresponds to one of our own ids. Since we do not know what the change is, we notify
|
||||||
|
// for whatever is different from what is currently known. Other ids, that get invited only trigger a notification when the
|
||||||
|
// ID also accepts the invitation, so it becomes a member of the circle.
|
||||||
|
|
||||||
|
for(auto own_id: own_ids)
|
||||||
|
{
|
||||||
|
auto it = details.mSubscriptionFlags.find(own_id);
|
||||||
|
|
||||||
|
if(it == details.mSubscriptionFlags.end())
|
||||||
|
continue;
|
||||||
|
|
||||||
|
bool invited ( it->second & GXS_EXTERNAL_CIRCLE_FLAGS_IN_ADMIN_LIST );
|
||||||
|
bool subscrb ( it->second & GXS_EXTERNAL_CIRCLE_FLAGS_SUBSCRIBED );
|
||||||
|
|
||||||
|
if(std::find(details.mAllowedGxsIds.begin(),details.mAllowedGxsIds.end(),id) != details.mAllowedGxsIds.end() && !me_in_circle)
|
||||||
|
{
|
||||||
|
auto ev = std::make_shared<RsGxsCircleEvent>();
|
||||||
|
|
||||||
|
ev->mType = RsGxsCircleEvent::CIRCLE_MEMBERSHIP_INVITE;
|
||||||
|
ev->mCircleId = circle_id;
|
||||||
|
ev->mGxsId = ;
|
||||||
|
|
||||||
|
rsEvents->sendEvent(ev);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
RsGxsIfaceHelper::receiveChanges(changes); // this clear up the vector and delete its elements
|
RsGxsIfaceHelper::receiveChanges(changes); // this clear up the vector and delete its elements
|
||||||
@ -550,6 +639,7 @@ bool p3GxsCircles::getCircleDetails(
|
|||||||
details.mSubscriptionFlags.clear();
|
details.mSubscriptionFlags.clear();
|
||||||
details.mAllowedGxsIds.clear();
|
details.mAllowedGxsIds.clear();
|
||||||
details.mAmIAllowed = false ;
|
details.mAmIAllowed = false ;
|
||||||
|
details.mAmIAdmin = bool(data.mGroupSubscribeFlags & GXS_SERV::GROUP_SUBSCRIBE_ADMIN);
|
||||||
|
|
||||||
for(std::map<RsGxsId,RsGxsCircleMembershipStatus>::const_iterator it(data.mMembershipStatus.begin());it!=data.mMembershipStatus.end();++it)
|
for(std::map<RsGxsId,RsGxsCircleMembershipStatus>::const_iterator it(data.mMembershipStatus.begin());it!=data.mMembershipStatus.end();++it)
|
||||||
{
|
{
|
||||||
@ -860,7 +950,7 @@ RsGxsCircleCache::RsGxsCircleCache()
|
|||||||
mUpdateTime = 0;
|
mUpdateTime = 0;
|
||||||
mGroupStatus = 0;
|
mGroupStatus = 0;
|
||||||
mGroupSubscribeFlags = 0;
|
mGroupSubscribeFlags = 0;
|
||||||
mLastUpdatedMembershipTS = 0 ;
|
mLastUpdatedMembershipTS = 0 ;
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -2324,3 +2414,4 @@ RsGxsCircles::~RsGxsCircles() = default;
|
|||||||
RsGxsCircleMsg::~RsGxsCircleMsg() = default;
|
RsGxsCircleMsg::~RsGxsCircleMsg() = default;
|
||||||
RsGxsCircleDetails::~RsGxsCircleDetails() = default;
|
RsGxsCircleDetails::~RsGxsCircleDetails() = default;
|
||||||
RsGxsCircleGroup::~RsGxsCircleGroup() = default;
|
RsGxsCircleGroup::~RsGxsCircleGroup() = default;
|
||||||
|
RsGxsCircleEvent::~RsGxsCircleEvent() = default;
|
||||||
|
@ -208,6 +208,11 @@ public:
|
|||||||
bool inviteIdsToCircle( const std::set<RsGxsId>& identities,
|
bool inviteIdsToCircle( const std::set<RsGxsId>& identities,
|
||||||
const RsGxsCircleId& circleId ) override;
|
const RsGxsCircleId& circleId ) override;
|
||||||
|
|
||||||
|
/// @see RsGxsCircles
|
||||||
|
bool getCircleRequest(const RsGxsGroupId& circleId,
|
||||||
|
const RsGxsMessageId& msgId,
|
||||||
|
RsGxsCircleMsg& msg) override;
|
||||||
|
|
||||||
/// @see RsGxsCircles
|
/// @see RsGxsCircles
|
||||||
bool exportCircleLink(
|
bool exportCircleLink(
|
||||||
std::string& link, const RsGxsCircleId& circleId,
|
std::string& link, const RsGxsCircleId& circleId,
|
||||||
|
@ -53,7 +53,7 @@ p3GxsForums::p3GxsForums( RsGeneralDataService *gds,
|
|||||||
RsGenExchange( gds, nes, new RsGxsForumSerialiser(),
|
RsGenExchange( gds, nes, new RsGxsForumSerialiser(),
|
||||||
RS_SERVICE_GXS_TYPE_FORUMS, gixs, forumsAuthenPolicy()),
|
RS_SERVICE_GXS_TYPE_FORUMS, gixs, forumsAuthenPolicy()),
|
||||||
RsGxsForums(static_cast<RsGxsIface&>(*this)), mGenToken(0),
|
RsGxsForums(static_cast<RsGxsIface&>(*this)), mGenToken(0),
|
||||||
mGenActive(false), mGenCount(0)
|
mGenActive(false), mGenCount(0), mKnownForumsMutex("GXS forums known forums timestamp cache")
|
||||||
{
|
{
|
||||||
// Test Data disabled in Repo.
|
// Test Data disabled in Repo.
|
||||||
//RsTickEvent::schedule_in(FORUM_TESTEVENT_DUMMYDATA, DUMMYDATA_PERIOD);
|
//RsTickEvent::schedule_in(FORUM_TESTEVENT_DUMMYDATA, DUMMYDATA_PERIOD);
|
||||||
@ -96,14 +96,14 @@ uint32_t p3GxsForums::forumsAuthenPolicy()
|
|||||||
static const uint32_t GXS_FORUMS_CONFIG_MAX_TIME_NOTIFY_STORAGE = 86400*30*2 ; // ignore notifications for 2 months
|
static const uint32_t GXS_FORUMS_CONFIG_MAX_TIME_NOTIFY_STORAGE = 86400*30*2 ; // ignore notifications for 2 months
|
||||||
static const uint8_t GXS_FORUMS_CONFIG_SUBTYPE_NOTIFY_RECORD = 0x01 ;
|
static const uint8_t GXS_FORUMS_CONFIG_SUBTYPE_NOTIFY_RECORD = 0x01 ;
|
||||||
|
|
||||||
struct RsGxsForumNotifyRecordsItem: public RsItem
|
struct RsGxsGroupNotifyRecordsItem: public RsItem
|
||||||
{
|
{
|
||||||
|
|
||||||
RsGxsForumNotifyRecordsItem()
|
RsGxsGroupNotifyRecordsItem()
|
||||||
: RsItem(RS_PKT_VERSION_SERVICE,RS_SERVICE_GXS_TYPE_FORUMS_CONFIG,GXS_FORUMS_CONFIG_SUBTYPE_NOTIFY_RECORD)
|
: RsItem(RS_PKT_VERSION_SERVICE,RS_SERVICE_GXS_TYPE_FORUMS_CONFIG,GXS_FORUMS_CONFIG_SUBTYPE_NOTIFY_RECORD)
|
||||||
{}
|
{}
|
||||||
|
|
||||||
virtual ~RsGxsForumNotifyRecordsItem() {}
|
virtual ~RsGxsGroupNotifyRecordsItem() {}
|
||||||
|
|
||||||
void serial_process( RsGenericSerializer::SerializeJob j,
|
void serial_process( RsGenericSerializer::SerializeJob j,
|
||||||
RsGenericSerializer::SerializeContext& ctx )
|
RsGenericSerializer::SerializeContext& ctx )
|
||||||
@ -127,7 +127,7 @@ public:
|
|||||||
|
|
||||||
switch(item_sub_id)
|
switch(item_sub_id)
|
||||||
{
|
{
|
||||||
case GXS_FORUMS_CONFIG_SUBTYPE_NOTIFY_RECORD: return new RsGxsForumNotifyRecordsItem();
|
case GXS_FORUMS_CONFIG_SUBTYPE_NOTIFY_RECORD: return new RsGxsGroupNotifyRecordsItem();
|
||||||
default:
|
default:
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
@ -138,7 +138,7 @@ bool p3GxsForums::saveList(bool &cleanup, std::list<RsItem *>&saveList)
|
|||||||
{
|
{
|
||||||
cleanup = true ;
|
cleanup = true ;
|
||||||
|
|
||||||
RsGxsForumNotifyRecordsItem *item = new RsGxsForumNotifyRecordsItem ;
|
RsGxsGroupNotifyRecordsItem *item = new RsGxsGroupNotifyRecordsItem ;
|
||||||
|
|
||||||
item->records = mKnownForums ;
|
item->records = mKnownForums ;
|
||||||
|
|
||||||
@ -155,7 +155,7 @@ bool p3GxsForums::loadList(std::list<RsItem *>& loadList)
|
|||||||
|
|
||||||
rstime_t now = time(NULL);
|
rstime_t now = time(NULL);
|
||||||
|
|
||||||
RsGxsForumNotifyRecordsItem *fnr = dynamic_cast<RsGxsForumNotifyRecordsItem*>(item) ;
|
RsGxsGroupNotifyRecordsItem *fnr = dynamic_cast<RsGxsGroupNotifyRecordsItem*>(item) ;
|
||||||
|
|
||||||
if(fnr != NULL)
|
if(fnr != NULL)
|
||||||
{
|
{
|
||||||
@ -181,82 +181,140 @@ RsSerialiser* p3GxsForums::setupSerialiser()
|
|||||||
|
|
||||||
void p3GxsForums::notifyChanges(std::vector<RsGxsNotify *> &changes)
|
void p3GxsForums::notifyChanges(std::vector<RsGxsNotify *> &changes)
|
||||||
{
|
{
|
||||||
if (!changes.empty())
|
#ifdef GXSFORUMS_DEBUG
|
||||||
|
std::cerr << "p3GxsForums::notifyChanges() : " << changes.size() << "changes to notify" << std::endl;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
std::vector<RsGxsNotify *>::iterator it;
|
||||||
|
for(it = changes.begin(); it != changes.end(); ++it)
|
||||||
{
|
{
|
||||||
p3Notify *notify = RsServer::notify();
|
RsGxsMsgChange *msgChange = dynamic_cast<RsGxsMsgChange *>(*it);
|
||||||
|
if (msgChange)
|
||||||
if (notify)
|
|
||||||
{
|
{
|
||||||
std::vector<RsGxsNotify*>::iterator it;
|
if (msgChange->getType() == RsGxsNotify::TYPE_RECEIVED_NEW) /* message received */
|
||||||
for(it = changes.begin(); it != changes.end(); ++it)
|
if (rsEvents)
|
||||||
{
|
|
||||||
RsGxsNotify *c = *it;
|
|
||||||
|
|
||||||
switch (c->getType())
|
|
||||||
{
|
{
|
||||||
default:
|
std::map<RsGxsGroupId, std::set<RsGxsMessageId> >& msgChangeMap = msgChange->msgChangeMap;
|
||||||
case RsGxsNotify::TYPE_PROCESSED:
|
for (auto mit = msgChangeMap.begin(); mit != msgChangeMap.end(); ++mit)
|
||||||
case RsGxsNotify::TYPE_PUBLISHED:
|
for (auto mit1 = mit->second.begin(); mit1 != mit->second.end(); ++mit1)
|
||||||
break;
|
{
|
||||||
|
auto ev = std::make_shared<RsGxsForumEvent>();
|
||||||
|
ev->mForumMsgId = *mit1;
|
||||||
|
ev->mForumGroupId = mit->first;
|
||||||
|
ev->mForumEventCode = RsForumEventCode::NEW_MESSAGE;
|
||||||
|
rsEvents->postEvent(ev);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
case RsGxsNotify::TYPE_RECEIVED_NEW:
|
#ifdef NOT_USED_YET
|
||||||
|
if (!msgChange->metaChange())
|
||||||
|
{
|
||||||
|
#ifdef GXSCHANNELS_DEBUG
|
||||||
|
std::cerr << "p3GxsForums::notifyChanges() Found Message Change Notification";
|
||||||
|
std::cerr << std::endl;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
std::map<RsGxsGroupId, std::set<RsGxsMessageId> > &msgChangeMap = msgChange->msgChangeMap;
|
||||||
|
for(auto mit = msgChangeMap.begin(); mit != msgChangeMap.end(); ++mit)
|
||||||
|
{
|
||||||
|
#ifdef GXSCHANNELS_DEBUG
|
||||||
|
std::cerr << "p3GxsForums::notifyChanges() Msgs for Group: " << mit->first;
|
||||||
|
std::cerr << std::endl;
|
||||||
|
#endif
|
||||||
|
bool enabled = false;
|
||||||
|
if (autoDownloadEnabled(mit->first, enabled) && enabled)
|
||||||
{
|
{
|
||||||
RsGxsMsgChange *msgChange = dynamic_cast<RsGxsMsgChange*>(c);
|
#ifdef GXSCHANNELS_DEBUG
|
||||||
if (msgChange)
|
std::cerr << "p3GxsChannels::notifyChanges() AutoDownload for Group: " << mit->first;
|
||||||
{
|
std::cerr << std::endl;
|
||||||
std::map<RsGxsGroupId, std::set<RsGxsMessageId> > &msgChangeMap = msgChange->msgChangeMap;
|
#endif
|
||||||
|
|
||||||
for (auto mit = msgChangeMap.begin(); mit != msgChangeMap.end(); ++mit)
|
/* problem is most of these will be comments and votes,
|
||||||
{
|
* should make it occasional - every 5mins / 10minutes TODO */
|
||||||
for (auto mit1 = mit->second.begin(); mit1 != mit->second.end(); ++mit1)
|
unprocessedGroups.push_back(mit->first);
|
||||||
notify->AddFeedItem(RS_FEED_ITEM_FORUM_MSG, mit->first.toStdString(), mit1->toStdString());
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
RsGxsGroupChange *grpChange = dynamic_cast<RsGxsGroupChange *>(*it);
|
|
||||||
if (grpChange)
|
|
||||||
{
|
|
||||||
/* group received */
|
|
||||||
std::list<RsGxsGroupId> &grpList = grpChange->mGrpIdList;
|
|
||||||
std::list<RsGxsGroupId>::iterator git;
|
|
||||||
|
|
||||||
for (git = grpList.begin(); git != grpList.end(); ++git)
|
|
||||||
{
|
|
||||||
if(mKnownForums.find(*git) == mKnownForums.end())
|
|
||||||
{
|
|
||||||
notify->AddFeedItem(RS_FEED_ITEM_FORUM_NEW, git->toStdString());
|
|
||||||
mKnownForums.insert(std::make_pair(*git,time(NULL))) ;
|
|
||||||
|
|
||||||
IndicateConfigChanged();
|
|
||||||
}
|
|
||||||
else
|
|
||||||
std::cerr << "(II) Not notifying already known forum " << *git << std::endl;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
case RsGxsNotify::TYPE_RECEIVED_PUBLISHKEY:
|
|
||||||
{
|
|
||||||
RsGxsGroupChange *grpChange = dynamic_cast<RsGxsGroupChange *>(*it);
|
|
||||||
if (grpChange)
|
|
||||||
{
|
|
||||||
/* group received */
|
|
||||||
std::list<RsGxsGroupId> &grpList = grpChange->mGrpIdList;
|
|
||||||
std::list<RsGxsGroupId>::iterator git;
|
|
||||||
for (git = grpList.begin(); git != grpList.end(); ++git)
|
|
||||||
{
|
|
||||||
notify->AddFeedItem(RS_FEED_ITEM_FORUM_PUBLISHKEY, git->toStdString());
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (rsEvents)
|
||||||
|
{
|
||||||
|
RsGxsGroupChange *grpChange = dynamic_cast<RsGxsGroupChange*>(*it);
|
||||||
|
if (grpChange)
|
||||||
|
{
|
||||||
|
switch (grpChange->getType())
|
||||||
|
{
|
||||||
|
default:
|
||||||
|
case RsGxsNotify::TYPE_PROCESSED: // happens when the group is subscribed
|
||||||
|
{
|
||||||
|
std::list<RsGxsGroupId> &grpList = grpChange->mGrpIdList;
|
||||||
|
std::list<RsGxsGroupId>::iterator git;
|
||||||
|
for (git = grpList.begin(); git != grpList.end(); ++git)
|
||||||
|
{
|
||||||
|
auto ev = std::make_shared<RsGxsForumEvent>();
|
||||||
|
ev->mForumGroupId = *git;
|
||||||
|
ev->mForumEventCode = RsForumEventCode::SUBSCRIBE_STATUS_CHANGED;
|
||||||
|
rsEvents->postEvent(ev);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
case RsGxsNotify::TYPE_PUBLISHED:
|
||||||
|
case RsGxsNotify::TYPE_RECEIVED_NEW:
|
||||||
|
{
|
||||||
|
/* group received */
|
||||||
|
std::list<RsGxsGroupId> &grpList = grpChange->mGrpIdList;
|
||||||
|
std::list<RsGxsGroupId>::iterator git;
|
||||||
|
|
||||||
|
RS_STACK_MUTEX(mKnownForumsMutex);
|
||||||
|
for (git = grpList.begin(); git != grpList.end(); ++git)
|
||||||
|
{
|
||||||
|
if(mKnownForums.find(*git) == mKnownForums.end())
|
||||||
|
{
|
||||||
|
mKnownForums.insert(
|
||||||
|
std::make_pair(*git, time(nullptr)));
|
||||||
|
IndicateConfigChanged();
|
||||||
|
|
||||||
|
auto ev = std::make_shared<RsGxsForumEvent>();
|
||||||
|
ev->mForumGroupId = *git;
|
||||||
|
ev->mForumEventCode = RsForumEventCode::NEW_FORUM;
|
||||||
|
rsEvents->postEvent(ev);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
RsInfo() << __PRETTY_FUNCTION__
|
||||||
|
<< " Not notifying already known forum "
|
||||||
|
<< *git << std::endl;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
#ifdef NOT_USED_YET
|
||||||
|
case RsGxsNotify::TYPE_RECEIVED_PUBLISHKEY:
|
||||||
|
{
|
||||||
|
/* group received */
|
||||||
|
std::list<RsGxsGroupId> &grpList = grpChange->mGrpIdList;
|
||||||
|
std::list<RsGxsGroupId>::iterator git;
|
||||||
|
for (git = grpList.begin(); git != grpList.end(); ++git)
|
||||||
|
{
|
||||||
|
auto ev = std::make_shared<RsGxsChannelEvent>();
|
||||||
|
|
||||||
|
ev->mChannelGroupId = *git;
|
||||||
|
ev->mChannelEventCode = RsGxsChannelEvent::RECEIVED_PUBLISH_KEY;
|
||||||
|
|
||||||
|
rsEvents->sendEvent(ev);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* shouldn't need to worry about groups - as they need to be subscribed to */
|
||||||
}
|
}
|
||||||
|
|
||||||
RsGxsIfaceHelper::receiveChanges(changes);
|
RsGxsIfaceHelper::receiveChanges(changes);
|
||||||
@ -1087,3 +1145,4 @@ bool RsGxsForumGroup::canEditPosts(const RsGxsId& id) const
|
|||||||
RsGxsForumGroup::~RsGxsForumGroup() = default;
|
RsGxsForumGroup::~RsGxsForumGroup() = default;
|
||||||
RsGxsForumMsg::~RsGxsForumMsg() = default;
|
RsGxsForumMsg::~RsGxsForumMsg() = default;
|
||||||
RsGxsForums::~RsGxsForums() = default;
|
RsGxsForums::~RsGxsForums() = default;
|
||||||
|
RsGxsForumEvent::~RsGxsForumEvent() = default;
|
||||||
|
@ -166,4 +166,5 @@ bool generateGroup(uint32_t &token, std::string groupName);
|
|||||||
RsGxsMessageId mGenThreadId;
|
RsGxsMessageId mGenThreadId;
|
||||||
std::map<RsGxsGroupId,rstime_t> mKnownForums ;
|
std::map<RsGxsGroupId,rstime_t> mKnownForums ;
|
||||||
|
|
||||||
|
RsMutex mKnownForumsMutex;
|
||||||
};
|
};
|
||||||
|
@ -175,14 +175,12 @@ void p3MsgService::processIncomingMsg(RsMsgItem *mi)
|
|||||||
mi->msgFlags &= (RS_MSG_FLAGS_DISTANT | RS_MSG_FLAGS_SYSTEM); // remove flags except those
|
mi->msgFlags &= (RS_MSG_FLAGS_DISTANT | RS_MSG_FLAGS_SYSTEM); // remove flags except those
|
||||||
mi->msgFlags |= RS_MSG_FLAGS_NEW;
|
mi->msgFlags |= RS_MSG_FLAGS_NEW;
|
||||||
|
|
||||||
p3Notify *notify = RsServer::notify();
|
if (rsEvents)
|
||||||
if (notify)
|
|
||||||
{
|
{
|
||||||
notify->AddPopupMessage(RS_POPUP_MSG, mi->PeerId().toStdString(), mi->subject, mi->message);
|
auto ev = std::make_shared<RsMailStatusEvent>();
|
||||||
|
ev->mMailStatusEventCode = RsMailStatusEventCode::NEW_MESSAGE;
|
||||||
std::string out;
|
ev->mChangedMsgIds.insert(std::to_string(mi->msgId));
|
||||||
rs_sprintf(out, "%lu", mi->msgId);
|
rsEvents->postEvent(ev);
|
||||||
notify->AddFeedItem(RS_FEED_ITEM_MESSAGE, out, "", "");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
imsg[mi->msgId] = mi;
|
imsg[mi->msgId] = mi;
|
||||||
@ -207,13 +205,6 @@ void p3MsgService::processIncomingMsg(RsMsgItem *mi)
|
|||||||
}
|
}
|
||||||
|
|
||||||
RsServer::notify()->notifyListChange(NOTIFY_LIST_MESSAGELIST,NOTIFY_TYPE_ADD);
|
RsServer::notify()->notifyListChange(NOTIFY_LIST_MESSAGELIST,NOTIFY_TYPE_ADD);
|
||||||
|
|
||||||
if(rsEvents)
|
|
||||||
{
|
|
||||||
std::shared_ptr<RsMailStatusEvent> pEvent(new RsMailStatusEvent());
|
|
||||||
pEvent->mChangedMsgIds.insert(std::to_string(mi->msgId));
|
|
||||||
rsEvents->postEvent(pEvent);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool p3MsgService::checkAndRebuildPartialMessage(RsMsgItem *ci)
|
bool p3MsgService::checkAndRebuildPartialMessage(RsMsgItem *ci)
|
||||||
@ -345,8 +336,8 @@ int p3MsgService::checkOutgoingMessages()
|
|||||||
bool changed = false;
|
bool changed = false;
|
||||||
std::list<RsMsgItem*> output_queue;
|
std::list<RsMsgItem*> output_queue;
|
||||||
|
|
||||||
using Evt_t = RsMailStatusEvent;
|
auto pEvent = std::make_shared<RsMailStatusEvent>();
|
||||||
std::shared_ptr<Evt_t> pEvent(new Evt_t());
|
pEvent->mMailStatusEventCode = RsMailStatusEventCode::MESSAGE_SENT;
|
||||||
|
|
||||||
{
|
{
|
||||||
RS_STACK_MUTEX(mMsgMtx); /********** STACK LOCKED MTX ******/
|
RS_STACK_MUTEX(mMsgMtx); /********** STACK LOCKED MTX ******/
|
||||||
@ -404,11 +395,10 @@ int p3MsgService::checkOutgoingMessages()
|
|||||||
mit->second->msgFlags |= RS_MSG_FLAGS_ROUTED;
|
mit->second->msgFlags |= RS_MSG_FLAGS_ROUTED;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
#ifdef DEBUG_DISTANT_MSG
|
||||||
else
|
else
|
||||||
{
|
Dbg3() << __PRETTY_FUNCTION__ << " Delaying until available..." << std::endl;
|
||||||
Dbg3() << __PRETTY_FUNCTION__ << " Delaying until available..."
|
#endif
|
||||||
<< std::endl;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* clean up */
|
/* clean up */
|
||||||
@ -906,8 +896,9 @@ bool p3MsgService::removeMsgId(const std::string &mid)
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool changed = false;
|
bool changed = false;
|
||||||
using Evt_t = RsMailStatusEvent;
|
|
||||||
std::shared_ptr<Evt_t> pEvent(new Evt_t());
|
auto pEvent = std::make_shared<RsMailStatusEvent>();
|
||||||
|
pEvent->mMailStatusEventCode = RsMailStatusEventCode::MESSAGE_REMOVED;
|
||||||
|
|
||||||
{
|
{
|
||||||
RsStackMutex stack(mMsgMtx); /********** STACK LOCKED MTX ******/
|
RsStackMutex stack(mMsgMtx); /********** STACK LOCKED MTX ******/
|
||||||
@ -1274,8 +1265,9 @@ uint32_t p3MsgService::sendMail(
|
|||||||
std::back_inserter(msgInfo.files) );
|
std::back_inserter(msgInfo.files) );
|
||||||
|
|
||||||
uint32_t ret = 0;
|
uint32_t ret = 0;
|
||||||
using Evt_t = RsMailStatusEvent;
|
|
||||||
std::shared_ptr<Evt_t> pEvent(new Evt_t());
|
auto pEvent = std::make_shared<RsMailStatusEvent>();
|
||||||
|
pEvent->mMailStatusEventCode = RsMailStatusEventCode::MESSAGE_SENT;
|
||||||
|
|
||||||
auto pSend = [&](const std::set<RsGxsId>& sDest)
|
auto pSend = [&](const std::set<RsGxsId>& sDest)
|
||||||
{
|
{
|
||||||
@ -2089,10 +2081,13 @@ void p3MsgService::notifyDataStatus( const GRouterMsgPropagationId& id,
|
|||||||
NOTIFY_TYPE_ADD );
|
NOTIFY_TYPE_ADD );
|
||||||
IndicateConfigChanged();
|
IndicateConfigChanged();
|
||||||
|
|
||||||
using Evt_t = RsMailStatusEvent;
|
if(rsEvents)
|
||||||
std::shared_ptr<Evt_t> pEvent(new Evt_t());
|
{
|
||||||
pEvent->mChangedMsgIds.insert(std::to_string(msg_id));
|
auto pEvent = std::make_shared<RsMailStatusEvent>();
|
||||||
if(rsEvents) rsEvents->postEvent(pEvent);
|
pEvent->mMailStatusEventCode = RsMailStatusEventCode::NEW_MESSAGE;
|
||||||
|
pEvent->mChangedMsgIds.insert(std::to_string(msg_id));
|
||||||
|
rsEvents->postEvent(pEvent);
|
||||||
|
}
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -2189,11 +2184,11 @@ bool p3MsgService::notifyGxsTransSendStatus( RsGxsTransId mailId,
|
|||||||
Dbg2() << __PRETTY_FUNCTION__ << " " << mailId << ", "
|
Dbg2() << __PRETTY_FUNCTION__ << " " << mailId << ", "
|
||||||
<< static_cast<uint32_t>(status) << std::endl;
|
<< static_cast<uint32_t>(status) << std::endl;
|
||||||
|
|
||||||
using Evt_t = RsMailStatusEvent;
|
auto pEvent = std::make_shared<RsMailStatusEvent>();
|
||||||
std::shared_ptr<Evt_t> pEvent(new Evt_t());
|
|
||||||
|
|
||||||
if( status == GxsTransSendStatus::RECEIPT_RECEIVED )
|
if( status == GxsTransSendStatus::RECEIPT_RECEIVED )
|
||||||
{
|
{
|
||||||
|
pEvent->mMailStatusEventCode = RsMailStatusEventCode::NEW_MESSAGE;
|
||||||
uint32_t msg_id;
|
uint32_t msg_id;
|
||||||
|
|
||||||
{
|
{
|
||||||
@ -2248,19 +2243,20 @@ bool p3MsgService::notifyGxsTransSendStatus( RsGxsTransId mailId,
|
|||||||
else if( status >= GxsTransSendStatus::FAILED_RECEIPT_SIGNATURE )
|
else if( status >= GxsTransSendStatus::FAILED_RECEIPT_SIGNATURE )
|
||||||
{
|
{
|
||||||
uint32_t msg_id;
|
uint32_t msg_id;
|
||||||
|
pEvent->mMailStatusEventCode = RsMailStatusEventCode::SIGNATURE_FAILED;
|
||||||
|
|
||||||
{
|
{
|
||||||
RS_STACK_MUTEX(gxsOngoingMutex);
|
RS_STACK_MUTEX(gxsOngoingMutex);
|
||||||
|
RsErr() << __PRETTY_FUNCTION__ << " mail delivery "
|
||||||
std::cerr << __PRETTY_FUNCTION__ << " mail delivery "
|
<< "mailId: " << mailId
|
||||||
<< "mailId: " << mailId
|
<< " failed with " << static_cast<uint32_t>(status);
|
||||||
<< " failed with " << static_cast<uint32_t>(status);
|
|
||||||
|
|
||||||
auto it = gxsOngoingMessages.find(mailId);
|
auto it = gxsOngoingMessages.find(mailId);
|
||||||
if(it == gxsOngoingMessages.end())
|
if(it == gxsOngoingMessages.end())
|
||||||
{
|
{
|
||||||
std::cerr << " cannot find pending message to notify"
|
RsErr() << __PRETTY_FUNCTION__
|
||||||
<< std::endl;
|
<< " cannot find pending message to notify"
|
||||||
|
<< std::endl;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -29,7 +29,7 @@
|
|||||||
#include "rsitems/rsgxscommentitems.h"
|
#include "rsitems/rsgxscommentitems.h"
|
||||||
|
|
||||||
#include "rsserver/p3face.h"
|
#include "rsserver/p3face.h"
|
||||||
#include "retroshare/rsnotify.h"
|
#include "retroshare/rsposted.h"
|
||||||
|
|
||||||
// For Dummy Msgs.
|
// For Dummy Msgs.
|
||||||
#include "util/rsrandom.h"
|
#include "util/rsrandom.h"
|
||||||
@ -87,12 +87,6 @@ void p3PostBase::notifyChanges(std::vector<RsGxsNotify *> &changes)
|
|||||||
std::cerr << std::endl;
|
std::cerr << std::endl;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
p3Notify *notify = NULL;
|
|
||||||
if (!changes.empty())
|
|
||||||
{
|
|
||||||
notify = RsServer::notify();
|
|
||||||
}
|
|
||||||
|
|
||||||
std::vector<RsGxsNotify *>::iterator it;
|
std::vector<RsGxsNotify *>::iterator it;
|
||||||
|
|
||||||
for(it = changes.begin(); it != changes.end(); ++it)
|
for(it = changes.begin(); it != changes.end(); ++it)
|
||||||
@ -118,13 +112,15 @@ void p3PostBase::notifyChanges(std::vector<RsGxsNotify *> &changes)
|
|||||||
// It could be taken a step further and directly request these msgs for an update.
|
// It could be taken a step further and directly request these msgs for an update.
|
||||||
addGroupForProcessing(mit->first);
|
addGroupForProcessing(mit->first);
|
||||||
|
|
||||||
if (notify && msgChange->getType() == RsGxsNotify::TYPE_RECEIVED_NEW)
|
if (rsEvents && msgChange->getType() == RsGxsNotify::TYPE_RECEIVED_NEW)
|
||||||
{
|
|
||||||
for (auto mit1 = mit->second.begin(); mit1 != mit->second.end(); ++mit1)
|
for (auto mit1 = mit->second.begin(); mit1 != mit->second.end(); ++mit1)
|
||||||
{
|
{
|
||||||
notify->AddFeedItem(RS_FEED_ITEM_POSTED_MSG, mit->first.toStdString(), mit1->toStdString());
|
auto ev = std::make_shared<RsGxsPostedEvent>();
|
||||||
|
ev->mPostedMsgId = *mit1;
|
||||||
|
ev->mPostedGroupId = mit->first;
|
||||||
|
ev->mPostedEventCode = RsPostedEventCode::NEW_MESSAGE;
|
||||||
|
rsEvents->postEvent(ev);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -137,17 +133,20 @@ void p3PostBase::notifyChanges(std::vector<RsGxsNotify *> &changes)
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
std::list<RsGxsGroupId> &groupList = groupChange->mGrpIdList;
|
std::list<RsGxsGroupId> &groupList = groupChange->mGrpIdList;
|
||||||
std::list<RsGxsGroupId>::iterator git;
|
|
||||||
for(git = groupList.begin(); git != groupList.end(); ++git)
|
for(auto git = groupList.begin(); git != groupList.end(); ++git)
|
||||||
{
|
{
|
||||||
#ifdef POSTBASE_DEBUG
|
#ifdef POSTBASE_DEBUG
|
||||||
std::cerr << "p3PostBase::notifyChanges() Incoming Group: " << *git;
|
std::cerr << "p3PostBase::notifyChanges() Incoming Group: " << *git;
|
||||||
std::cerr << std::endl;
|
std::cerr << std::endl;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (notify && groupChange->getType() == RsGxsNotify::TYPE_RECEIVED_NEW)
|
if (rsEvents && groupChange->getType() == RsGxsNotify::TYPE_RECEIVED_NEW)
|
||||||
{
|
{
|
||||||
notify->AddFeedItem(RS_FEED_ITEM_POSTED_NEW, git->toStdString());
|
auto ev = std::make_shared<RsGxsPostedEvent>();
|
||||||
|
ev->mPostedGroupId = *git;
|
||||||
|
ev->mPostedEventCode = RsPostedEventCode::NEW_POSTED_GROUP;
|
||||||
|
rsEvents->postEvent(ev);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -20,19 +20,20 @@
|
|||||||
* *
|
* *
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
#include <iomanip>
|
#include <iomanip>
|
||||||
|
#include <sys/time.h>
|
||||||
|
#include <cmath>
|
||||||
|
|
||||||
#include "util/rsdir.h"
|
#include "util/rsdir.h"
|
||||||
#include "retroshare/rsiface.h"
|
#include "retroshare/rsiface.h"
|
||||||
|
#include "retroshare/rspeers.h"
|
||||||
#include "pqi/pqibin.h"
|
#include "pqi/pqibin.h"
|
||||||
#include "pqi/pqistore.h"
|
#include "pqi/pqistore.h"
|
||||||
#include "pqi/p3linkmgr.h"
|
#include "pqi/p3linkmgr.h"
|
||||||
#include "rsserver/p3face.h"
|
#include "rsserver/p3face.h"
|
||||||
|
#include "util/cxx17retrocompat.h"
|
||||||
#include "services/p3rtt.h"
|
#include "services/p3rtt.h"
|
||||||
#include "rsitems/rsrttitems.h"
|
#include "rsitems/rsrttitems.h"
|
||||||
|
|
||||||
#include <sys/time.h>
|
|
||||||
#include <math.h>
|
|
||||||
|
|
||||||
/****
|
/****
|
||||||
* #define DEBUG_RTT 1
|
* #define DEBUG_RTT 1
|
||||||
@ -352,28 +353,29 @@ int p3rtt::storePongResult(const RsPeerId& id, uint32_t counter, double recv_ts,
|
|||||||
|
|
||||||
|
|
||||||
while(peerInfo->mPongResults.size() > MAX_PONG_RESULTS)
|
while(peerInfo->mPongResults.size() > MAX_PONG_RESULTS)
|
||||||
{
|
|
||||||
peerInfo->mPongResults.pop_front();
|
peerInfo->mPongResults.pop_front();
|
||||||
}
|
|
||||||
|
|
||||||
//Wait at least 20 pongs before compute mean time offset
|
//Wait at least 20 pongs before compute mean time offset
|
||||||
if(peerInfo->mPongResults.size() > 20)
|
if(peerInfo->mPongResults.size() > 20)
|
||||||
{
|
{
|
||||||
double mean = 0;
|
double mean = 0;
|
||||||
for(std::list<RsRttPongResult>::const_iterator prIt = peerInfo->mPongResults.begin(), end = peerInfo->mPongResults.end(); prIt != end; ++ prIt)
|
for(auto prIt : std::as_const(peerInfo->mPongResults))
|
||||||
{
|
mean += prIt.mOffset;
|
||||||
mean += prIt->mOffset;
|
|
||||||
}
|
|
||||||
peerInfo->mCurrentMeanOffset = mean / peerInfo->mPongResults.size();
|
peerInfo->mCurrentMeanOffset = mean / peerInfo->mPongResults.size();
|
||||||
|
|
||||||
if(fabs(peerInfo->mCurrentMeanOffset) > 120)
|
if(fabs(peerInfo->mCurrentMeanOffset) > 120)
|
||||||
{
|
{
|
||||||
p3Notify *notify = RsServer::notify();
|
if(rsEvents)
|
||||||
if (notify)
|
|
||||||
{
|
{
|
||||||
//notify->AddPopupMessage(RS_POPUP_OFFSET, eerInfo->mId.toStdString(),"", "Time Offset: ");
|
auto ev = std::make_shared<RsConnectionEvent>();
|
||||||
notify->AddFeedItem(RS_FEED_ITEM_PEER_OFFSET, peerInfo->mId.toStdString());
|
ev->mSslId = peerInfo->mId;
|
||||||
|
ev->mTimeShift = static_cast<rstime_t>(peerInfo->mCurrentMeanOffset);
|
||||||
|
ev->mConnectionInfoCode = RsConnectionEventCode::PEER_TIME_SHIFT;
|
||||||
|
rsEvents->postEvent(ev);
|
||||||
}
|
}
|
||||||
std::cerr << "(WW) Peer:" << peerInfo->mId << " get time offset more than two minutes with you!!!" << std::endl;
|
RsWarn() << __PRETTY_FUNCTION__ << " Peer: " << peerInfo->mId
|
||||||
|
<< " have a time offset of more than two minutes with you"
|
||||||
|
<< std::endl;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return 1;
|
return 1;
|
||||||
@ -438,6 +440,7 @@ bool RttPeerInfo::initialisePeerInfo(const RsPeerId& id)
|
|||||||
mCurrentPingTS = 0;
|
mCurrentPingTS = 0;
|
||||||
mCurrentPingCounter = 0;
|
mCurrentPingCounter = 0;
|
||||||
mCurrentPongRecvd = true;
|
mCurrentPongRecvd = true;
|
||||||
|
mCurrentMeanOffset = 0;
|
||||||
|
|
||||||
mSentPings = 0;
|
mSentPings = 0;
|
||||||
mLostPongs = 0;
|
mLostPongs = 0;
|
||||||
|
@ -34,6 +34,8 @@ class p3ServiceControl;
|
|||||||
class RttPeerInfo
|
class RttPeerInfo
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
RttPeerInfo()
|
||||||
|
: mCurrentPingTS(0.0),mCurrentPingCounter(0.0),mCurrentPongRecvd(false),mCurrentMeanOffset(0.0),mLostPongs(0),mSentPings(0){}
|
||||||
|
|
||||||
bool initialisePeerInfo(const RsPeerId& id);
|
bool initialisePeerInfo(const RsPeerId& id);
|
||||||
|
|
||||||
|
File diff suppressed because it is too large
Load Diff
@ -56,7 +56,7 @@ class RsFeedItem;
|
|||||||
class FeedNotify;
|
class FeedNotify;
|
||||||
class FeedItem;
|
class FeedItem;
|
||||||
|
|
||||||
class NewsFeed : public RsAutoUpdatePage, public FeedHolder, public TokenResponse
|
class NewsFeed : public MainPage,public FeedHolder
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
@ -81,7 +81,7 @@ public:
|
|||||||
static void testFeeds(uint notifyFlags);
|
static void testFeeds(uint notifyFlags);
|
||||||
static void testFeed(FeedNotify *feedNotify);
|
static void testFeed(FeedNotify *feedNotify);
|
||||||
|
|
||||||
virtual void updateDisplay();
|
void handleEvent(std::shared_ptr<const RsEvent> event); // get events from libretroshare
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void newsFeedChanged(int count);
|
void newsFeedChanged(int count);
|
||||||
@ -89,82 +89,36 @@ signals:
|
|||||||
protected:
|
protected:
|
||||||
void processSettings(bool load);
|
void processSettings(bool load);
|
||||||
|
|
||||||
/* TokenResponse */
|
|
||||||
virtual void loadRequest(const TokenQueue *queue, const TokenRequest &req);
|
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
// void toggleChanMsgItems(bool on);
|
|
||||||
void feedoptions();
|
void feedoptions();
|
||||||
void sortChanged(int index);
|
void sortChanged(int index);
|
||||||
|
|
||||||
void sendNewsFeedChanged();
|
void sendNewsFeedChanged();
|
||||||
|
|
||||||
private:
|
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 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 addFeedItemIfUnique(FeedItem *item, 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 remUniqueFeedItem(FeedItem *item);
|
||||||
|
|
||||||
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);
|
|
||||||
|
|
||||||
#if 0
|
#if 0
|
||||||
void addFeedItemBlogNew(const RsFeedItem &fi);
|
void addFeedItemBlogNew(const RsFeedItem &fi);
|
||||||
void addFeedItemBlogMsg(const RsFeedItem &fi);
|
void addFeedItemBlogMsg(const RsFeedItem &fi);
|
||||||
#endif
|
#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:
|
private:
|
||||||
TokenQueue *mTokenQueueChannel;
|
|
||||||
TokenQueue *mTokenQueueCircle;
|
|
||||||
TokenQueue *mTokenQueueForum;
|
|
||||||
TokenQueue *mTokenQueuePosted;
|
|
||||||
|
|
||||||
/* UI - from Designer */
|
/* UI - from Designer */
|
||||||
Ui::NewsFeed *ui;
|
Ui::NewsFeed *ui;
|
||||||
|
|
||||||
|
RsEventsHandlerId_t mEventHandlerId;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -49,6 +49,7 @@ public:
|
|||||||
const RsPostedPost &getPost() const;
|
const RsPostedPost &getPost() const;
|
||||||
RsPostedPost &post();
|
RsPostedPost &post();
|
||||||
|
|
||||||
|
uint64_t uniqueIdentifier() const override { return hash_64bits("PostedItem " + mMessageId.toStdString()); }
|
||||||
protected:
|
protected:
|
||||||
/* FeedItem */
|
/* FeedItem */
|
||||||
virtual void doExpand(bool open);
|
virtual void doExpand(bool open);
|
||||||
|
@ -7,7 +7,7 @@
|
|||||||
<x>0</x>
|
<x>0</x>
|
||||||
<y>0</y>
|
<y>0</y>
|
||||||
<width>825</width>
|
<width>825</width>
|
||||||
<height>337</height>
|
<height>339</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
<property name="windowTitle">
|
<property name="windowTitle">
|
||||||
@ -529,10 +529,22 @@
|
|||||||
</item>
|
</item>
|
||||||
<item>
|
<item>
|
||||||
<widget class="QPushButton" name="readAndClearButton">
|
<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">
|
<property name="maximumSize">
|
||||||
<size>
|
<size>
|
||||||
<width>24</width>
|
<width>50</width>
|
||||||
<height>16777215</height>
|
<height>44</height>
|
||||||
</size>
|
</size>
|
||||||
</property>
|
</property>
|
||||||
<property name="focusPolicy">
|
<property name="focusPolicy">
|
||||||
@ -549,10 +561,22 @@
|
|||||||
</item>
|
</item>
|
||||||
<item>
|
<item>
|
||||||
<widget class="QPushButton" name="clearButton">
|
<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">
|
<property name="maximumSize">
|
||||||
<size>
|
<size>
|
||||||
<width>24</width>
|
<width>50</width>
|
||||||
<height>16777215</height>
|
<height>44</height>
|
||||||
</size>
|
</size>
|
||||||
</property>
|
</property>
|
||||||
<property name="focusPolicy">
|
<property name="focusPolicy">
|
||||||
@ -692,9 +716,9 @@
|
|||||||
</customwidget>
|
</customwidget>
|
||||||
</customwidgets>
|
</customwidgets>
|
||||||
<resources>
|
<resources>
|
||||||
<include location="Posted_images.qrc"/>
|
|
||||||
<include location="../images.qrc"/>
|
|
||||||
<include location="../icons.qrc"/>
|
<include location="../icons.qrc"/>
|
||||||
|
<include location="../images.qrc"/>
|
||||||
|
<include location="Posted_images.qrc"/>
|
||||||
</resources>
|
</resources>
|
||||||
<connections/>
|
<connections/>
|
||||||
</ui>
|
</ui>
|
||||||
|
@ -37,6 +37,8 @@
|
|||||||
#define POSTED_DEFAULT_LISTING_LENGTH 10
|
#define POSTED_DEFAULT_LISTING_LENGTH 10
|
||||||
#define POSTED_MAX_INDEX 10000
|
#define POSTED_MAX_INDEX 10000
|
||||||
|
|
||||||
|
#define DEBUG_POSTED_LIST_WIDGET
|
||||||
|
|
||||||
#define TOPIC_DEFAULT_IMAGE ":/icons/png/posted.png"
|
#define TOPIC_DEFAULT_IMAGE ":/icons/png/posted.png"
|
||||||
|
|
||||||
/** Constructor */
|
/** Constructor */
|
||||||
@ -143,15 +145,19 @@ QScrollArea *PostedListWidget::getScrollArea()
|
|||||||
|
|
||||||
void PostedListWidget::deleteFeedItem(QWidget */*item*/, uint32_t /*type*/)
|
void PostedListWidget::deleteFeedItem(QWidget */*item*/, uint32_t /*type*/)
|
||||||
{
|
{
|
||||||
|
#ifdef DEBUG_POSTED_LIST_WIDGET
|
||||||
std::cerr << "PostedListWidget::deleteFeedItem() Nah";
|
std::cerr << "PostedListWidget::deleteFeedItem() Nah";
|
||||||
std::cerr << std::endl;
|
std::cerr << std::endl;
|
||||||
|
#endif
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
void PostedListWidget::openChat(const RsPeerId & /*peerId*/)
|
void PostedListWidget::openChat(const RsPeerId & /*peerId*/)
|
||||||
{
|
{
|
||||||
|
#ifdef DEBUG_POSTED_LIST_WIDGET
|
||||||
std::cerr << "PostedListWidget::openChat() Nah";
|
std::cerr << "PostedListWidget::openChat() Nah";
|
||||||
std::cerr << std::endl;
|
std::cerr << std::endl;
|
||||||
|
#endif
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -207,8 +213,10 @@ void PostedListWidget::getRankings(int i)
|
|||||||
if (groupId().isNull())
|
if (groupId().isNull())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
#ifdef DEBUG_POSTED_LIST_WIDGET
|
||||||
std::cerr << "PostedListWidget::getRankings()";
|
std::cerr << "PostedListWidget::getRankings()";
|
||||||
std::cerr << std::endl;
|
std::cerr << std::endl;
|
||||||
|
#endif
|
||||||
|
|
||||||
int oldSortMethod = mSortMethod;
|
int oldSortMethod = mSortMethod;
|
||||||
|
|
||||||
@ -268,6 +276,7 @@ void PostedListWidget::submitVote(const RsGxsGrpMsgIdPair &msgId, bool up)
|
|||||||
vote.mVoteType = GXS_VOTE_DOWN;
|
vote.mVoteType = GXS_VOTE_DOWN;
|
||||||
}//if (up)
|
}//if (up)
|
||||||
|
|
||||||
|
#ifdef DEBUG_POSTED_LIST_WIDGET
|
||||||
std::cerr << "PostedListWidget::submitVote()";
|
std::cerr << "PostedListWidget::submitVote()";
|
||||||
std::cerr << std::endl;
|
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 << "ThreadId : " << vote.mMeta.mThreadId << std::endl;
|
||||||
std::cerr << "ParentId : " << vote.mMeta.mParentId << std::endl;
|
std::cerr << "ParentId : " << vote.mMeta.mParentId << std::endl;
|
||||||
std::cerr << "AuthorId : " << vote.mMeta.mAuthorId << std::endl;
|
std::cerr << "AuthorId : " << vote.mMeta.mAuthorId << std::endl;
|
||||||
|
#endif
|
||||||
|
|
||||||
uint32_t token;
|
uint32_t token;
|
||||||
rsPosted->createNewVote(token, vote);
|
rsPosted->createNewVote(token, vote);
|
||||||
@ -464,8 +474,10 @@ static bool CmpPINew(const GxsFeedItem *a, const GxsFeedItem *b)
|
|||||||
void PostedListWidget::applyRanking()
|
void PostedListWidget::applyRanking()
|
||||||
{
|
{
|
||||||
/* uses current settings to sort posts, then add to layout */
|
/* uses current settings to sort posts, then add to layout */
|
||||||
|
#ifdef DEBUG_POSTED_LIST_WIDGET
|
||||||
std::cerr << "PostedListWidget::applyRanking()";
|
std::cerr << "PostedListWidget::applyRanking()";
|
||||||
std::cerr << std::endl;
|
std::cerr << std::endl;
|
||||||
|
#endif
|
||||||
|
|
||||||
shallowClearPosts();
|
shallowClearPosts();
|
||||||
|
|
||||||
@ -474,25 +486,33 @@ void PostedListWidget::applyRanking()
|
|||||||
{
|
{
|
||||||
default:
|
default:
|
||||||
case RsPosted::HotRankType:
|
case RsPosted::HotRankType:
|
||||||
|
#ifdef DEBUG_POSTED_LIST_WIDGET
|
||||||
std::cerr << "PostedListWidget::applyRanking() HOT";
|
std::cerr << "PostedListWidget::applyRanking() HOT";
|
||||||
std::cerr << std::endl;
|
std::cerr << std::endl;
|
||||||
|
#endif
|
||||||
qSort(mPostItems.begin(), mPostItems.end(), CmpPIHot);
|
qSort(mPostItems.begin(), mPostItems.end(), CmpPIHot);
|
||||||
break;
|
break;
|
||||||
case RsPosted::NewRankType:
|
case RsPosted::NewRankType:
|
||||||
|
#ifdef DEBUG_POSTED_LIST_WIDGET
|
||||||
std::cerr << "PostedListWidget::applyRanking() NEW";
|
std::cerr << "PostedListWidget::applyRanking() NEW";
|
||||||
std::cerr << std::endl;
|
std::cerr << std::endl;
|
||||||
|
#endif
|
||||||
qSort(mPostItems.begin(), mPostItems.end(), CmpPINew);
|
qSort(mPostItems.begin(), mPostItems.end(), CmpPINew);
|
||||||
break;
|
break;
|
||||||
case RsPosted::TopRankType:
|
case RsPosted::TopRankType:
|
||||||
|
#ifdef DEBUG_POSTED_LIST_WIDGET
|
||||||
std::cerr << "PostedListWidget::applyRanking() TOP";
|
std::cerr << "PostedListWidget::applyRanking() TOP";
|
||||||
std::cerr << std::endl;
|
std::cerr << std::endl;
|
||||||
|
#endif
|
||||||
qSort(mPostItems.begin(), mPostItems.end(), CmpPITop);
|
qSort(mPostItems.begin(), mPostItems.end(), CmpPITop);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
mLastSortMethod = mSortMethod;
|
mLastSortMethod = mSortMethod;
|
||||||
|
|
||||||
|
#ifdef DEBUG_POSTED_LIST_WIDGET
|
||||||
std::cerr << "PostedListWidget::applyRanking() Sorted mPostList";
|
std::cerr << "PostedListWidget::applyRanking() Sorted mPostList";
|
||||||
std::cerr << std::endl;
|
std::cerr << std::endl;
|
||||||
|
#endif
|
||||||
|
|
||||||
/* go through list (skipping out-of-date items) to get */
|
/* go through list (skipping out-of-date items) to get */
|
||||||
QLayout *alayout = ui->scrollAreaWidgetContents->layout();
|
QLayout *alayout = ui->scrollAreaWidgetContents->layout();
|
||||||
@ -500,42 +520,54 @@ void PostedListWidget::applyRanking()
|
|||||||
time_t min_ts = 0;
|
time_t min_ts = 0;
|
||||||
foreach (PostedItem *item, mPostItems)
|
foreach (PostedItem *item, mPostItems)
|
||||||
{
|
{
|
||||||
|
#ifdef DEBUG_POSTED_LIST_WIDGET
|
||||||
std::cerr << "PostedListWidget::applyRanking() Item: " << item;
|
std::cerr << "PostedListWidget::applyRanking() Item: " << item;
|
||||||
std::cerr << std::endl;
|
std::cerr << std::endl;
|
||||||
|
#endif
|
||||||
|
|
||||||
if (item->getPost().mMeta.mPublishTs < min_ts)
|
if (item->getPost().mMeta.mPublishTs < min_ts)
|
||||||
{
|
{
|
||||||
|
#ifdef DEBUG_POSTED_LIST_WIDGET
|
||||||
std::cerr << "\t Skipping OLD";
|
std::cerr << "\t Skipping OLD";
|
||||||
std::cerr << std::endl;
|
std::cerr << std::endl;
|
||||||
|
#endif
|
||||||
item->hide();
|
item->hide();
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (counter >= mPostIndex + mPostShow)
|
if (counter >= mPostIndex + mPostShow)
|
||||||
{
|
{
|
||||||
|
#ifdef DEBUG_POSTED_LIST_WIDGET
|
||||||
std::cerr << "\t END - Counter too high";
|
std::cerr << "\t END - Counter too high";
|
||||||
std::cerr << std::endl;
|
std::cerr << std::endl;
|
||||||
|
#endif
|
||||||
item->hide();
|
item->hide();
|
||||||
}
|
}
|
||||||
else if (counter >= mPostIndex)
|
else if (counter >= mPostIndex)
|
||||||
{
|
{
|
||||||
|
#ifdef DEBUG_POSTED_LIST_WIDGET
|
||||||
std::cerr << "\t Adding to Layout";
|
std::cerr << "\t Adding to Layout";
|
||||||
std::cerr << std::endl;
|
std::cerr << std::endl;
|
||||||
|
#endif
|
||||||
/* add it in! */
|
/* add it in! */
|
||||||
alayout->addWidget(item);
|
alayout->addWidget(item);
|
||||||
item->show();
|
item->show();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
#ifdef DEBUG_POSTED_LIST_WIDGET
|
||||||
std::cerr << "\t Skipping to Low";
|
std::cerr << "\t Skipping to Low";
|
||||||
std::cerr << std::endl;
|
std::cerr << std::endl;
|
||||||
|
#endif
|
||||||
item->hide();
|
item->hide();
|
||||||
}
|
}
|
||||||
++counter;
|
++counter;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef DEBUG_POSTED_LIST_WIDGET
|
||||||
std::cerr << "PostedListWidget::applyRanking() Loaded New Order";
|
std::cerr << "PostedListWidget::applyRanking() Loaded New Order";
|
||||||
std::cerr << std::endl;
|
std::cerr << std::endl;
|
||||||
|
#endif
|
||||||
|
|
||||||
// trigger a redraw.
|
// trigger a redraw.
|
||||||
ui->scrollAreaWidgetContents->update();
|
ui->scrollAreaWidgetContents->update();
|
||||||
@ -564,7 +596,9 @@ bool PostedListWidget::navigatePostItem(const RsGxsMessageId & /*msgId*/)
|
|||||||
|
|
||||||
void PostedListWidget::shallowClearPosts()
|
void PostedListWidget::shallowClearPosts()
|
||||||
{
|
{
|
||||||
|
#ifdef DEBUG_POSTED_LIST_WIDGET
|
||||||
std::cerr << "PostedListWidget::shallowClearPosts()" << std::endl;
|
std::cerr << "PostedListWidget::shallowClearPosts()" << std::endl;
|
||||||
|
#endif
|
||||||
|
|
||||||
std::list<PostedItem *> postedItems;
|
std::list<PostedItem *> postedItems;
|
||||||
std::list<PostedItem *>::iterator pit;
|
std::list<PostedItem *>::iterator pit;
|
||||||
@ -576,24 +610,30 @@ void PostedListWidget::shallowClearPosts()
|
|||||||
QLayoutItem *litem = alayout->itemAt(i);
|
QLayoutItem *litem = alayout->itemAt(i);
|
||||||
if (!litem)
|
if (!litem)
|
||||||
{
|
{
|
||||||
|
#ifdef DEBUG_POSTED_LIST_WIDGET
|
||||||
std::cerr << "PostedListWidget::shallowClearPosts() missing litem";
|
std::cerr << "PostedListWidget::shallowClearPosts() missing litem";
|
||||||
std::cerr << std::endl;
|
std::cerr << std::endl;
|
||||||
|
#endif
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
PostedItem *item = dynamic_cast<PostedItem *>(litem->widget());
|
PostedItem *item = dynamic_cast<PostedItem *>(litem->widget());
|
||||||
if (item)
|
if (item)
|
||||||
{
|
{
|
||||||
|
#ifdef DEBUG_POSTED_LIST_WIDGET
|
||||||
std::cerr << "PostedListWidget::shallowClearPosts() item: " << item;
|
std::cerr << "PostedListWidget::shallowClearPosts() item: " << item;
|
||||||
std::cerr << std::endl;
|
std::cerr << std::endl;
|
||||||
|
#endif
|
||||||
|
|
||||||
postedItems.push_back(item);
|
postedItems.push_back(item);
|
||||||
}
|
}
|
||||||
|
#ifdef DEBUG_POSTED_LIST_WIDGET
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
std::cerr << "PostedListWidget::shallowClearPosts() Found Child, which is not a PostedItem???";
|
std::cerr << "PostedListWidget::shallowClearPosts() Found Child, which is not a PostedItem???";
|
||||||
std::cerr << std::endl;
|
std::cerr << std::endl;
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
for(pit = postedItems.begin(); pit != postedItems.end(); ++pit)
|
for(pit = postedItems.begin(); pit != postedItems.end(); ++pit)
|
||||||
@ -646,15 +686,19 @@ void PostedListWidget::insertPosts(const uint32_t &token)
|
|||||||
// modify post content
|
// modify post content
|
||||||
if(mPosts.find(p.mMeta.mMsgId) != mPosts.end())
|
if(mPosts.find(p.mMeta.mMsgId) != mPosts.end())
|
||||||
{
|
{
|
||||||
|
#ifdef DEBUG_POSTED_LIST_WIDGET
|
||||||
std::cerr << "PostedListWidget::updateCurrentDisplayComplete() updating MsgId: " << p.mMeta.mMsgId;
|
std::cerr << "PostedListWidget::updateCurrentDisplayComplete() updating MsgId: " << p.mMeta.mMsgId;
|
||||||
std::cerr << std::endl;
|
std::cerr << std::endl;
|
||||||
|
#endif
|
||||||
|
|
||||||
mPosts[p.mMeta.mMsgId]->setPost(p);
|
mPosts[p.mMeta.mMsgId]->setPost(p);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
#ifdef DEBUG_POSTED_LIST_WIDGET
|
||||||
std::cerr << "PostedListWidget::updateCurrentDisplayComplete() loading New MsgId: " << p.mMeta.mMsgId;
|
std::cerr << "PostedListWidget::updateCurrentDisplayComplete() loading New MsgId: " << p.mMeta.mMsgId;
|
||||||
std::cerr << std::endl;
|
std::cerr << std::endl;
|
||||||
|
#endif
|
||||||
/* insert new entry */
|
/* insert new entry */
|
||||||
loadPost(p);
|
loadPost(p);
|
||||||
}
|
}
|
||||||
@ -689,8 +733,10 @@ void PostedListWidget::setAllMessagesReadDo(bool read, uint32_t &token)
|
|||||||
|
|
||||||
void PostedListWidget::loadRequest(const TokenQueue *queue, const TokenRequest &req)
|
void PostedListWidget::loadRequest(const TokenQueue *queue, const TokenRequest &req)
|
||||||
{
|
{
|
||||||
|
#ifdef DEBUG_POSTED_LIST_WIDGET
|
||||||
std::cerr << "PostedListWidget::loadRequest() UserType: " << req.mUserType;
|
std::cerr << "PostedListWidget::loadRequest() UserType: " << req.mUserType;
|
||||||
std::cerr << std::endl;
|
std::cerr << std::endl;
|
||||||
|
#endif
|
||||||
|
|
||||||
if (queue == mTokenQueue)
|
if (queue == mTokenQueue)
|
||||||
{
|
{
|
||||||
|
@ -578,7 +578,7 @@ RetroShareLink RetroShareLink::createCertificate(const RsPeerId& ssl_id)
|
|||||||
|
|
||||||
return link;
|
return link;
|
||||||
}
|
}
|
||||||
RetroShareLink RetroShareLink::createUnknwonSslCertificate(const RsPeerId& sslId, const RsPgpId& gpgId)
|
RetroShareLink RetroShareLink::createUnknownSslCertificate(const RsPeerId& sslId, const RsPgpId& gpgId)
|
||||||
{
|
{
|
||||||
RetroShareLink link;
|
RetroShareLink link;
|
||||||
link.clear();
|
link.clear();
|
||||||
|
@ -90,7 +90,7 @@ class RetroShareLink
|
|||||||
static RetroShareLink createMessage(const RsPeerId &peerId, const QString& subject);
|
static RetroShareLink createMessage(const RsPeerId &peerId, const QString& subject);
|
||||||
static RetroShareLink createMessage(const RsGxsId &peerId, const QString& subject);
|
static RetroShareLink createMessage(const RsGxsId &peerId, const QString& subject);
|
||||||
static RetroShareLink createCertificate(const RsPeerId &ssl_id) ;
|
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 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 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) ;
|
static RetroShareLink createIdentity(const RsGxsId& gxs_id,const QString& name,const QString& radix_data) ;
|
||||||
|
@ -47,6 +47,7 @@
|
|||||||
#include "RSTreeWidgetItem.h"
|
#include "RSTreeWidgetItem.h"
|
||||||
#include "StatusDefs.h"
|
#include "StatusDefs.h"
|
||||||
#include "util/misc.h"
|
#include "util/misc.h"
|
||||||
|
#include "util/qtthreadsutils.h"
|
||||||
#include "vmessagebox.h"
|
#include "vmessagebox.h"
|
||||||
#include "util/QtVersion.h"
|
#include "util/QtVersion.h"
|
||||||
#include "gui/chat/ChatUserNotify.h"
|
#include "gui/chat/ChatUserNotify.h"
|
||||||
@ -176,6 +177,9 @@ NewFriendList::NewFriendList(QWidget *parent) : /* RsAutoUpdatePage(5000,parent)
|
|||||||
ui->filterLineEdit->setPlaceholderText(tr("Search")) ;
|
ui->filterLineEdit->setPlaceholderText(tr("Search")) ;
|
||||||
ui->filterLineEdit->showFilterIcon();
|
ui->filterLineEdit->showFilterIcon();
|
||||||
|
|
||||||
|
mEventHandlerId=0; // forces initialization
|
||||||
|
rsEvents->registerEventsHandler( [this](std::shared_ptr<const RsEvent> e) { handleEvent(e); }, mEventHandlerId );
|
||||||
|
|
||||||
mModel = new RsFriendListModel();
|
mModel = new RsFriendListModel();
|
||||||
mProxyModel = new FriendListSortFilterProxyModel(ui->peerTreeWidget->header(),this);
|
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(friendsChanged()) , this, SLOT(forceUpdateDisplay()),Qt::QueuedConnection);
|
||||||
connect(NotifyQt::getInstance(), SIGNAL(groupsChanged(int)) , 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->actionShowOfflineFriends, SIGNAL(triggered(bool)), this, SLOT(setShowUnconnected(bool)));
|
||||||
connect(ui->actionShowState, SIGNAL(triggered(bool)), this, SLOT(setShowState(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()
|
NewFriendList::~NewFriendList()
|
||||||
{
|
{
|
||||||
delete ui;
|
delete ui;
|
||||||
|
@ -95,6 +95,7 @@ private slots:
|
|||||||
|
|
||||||
protected:
|
protected:
|
||||||
void changeEvent(QEvent *e);
|
void changeEvent(QEvent *e);
|
||||||
|
void handleEvent(std::shared_ptr<const RsEvent> e);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Ui::NewFriendList *ui;
|
Ui::NewFriendList *ui;
|
||||||
@ -117,6 +118,7 @@ private:
|
|||||||
|
|
||||||
// Settings for peer list display
|
// Settings for peer list display
|
||||||
bool mShowState;
|
bool mShowState;
|
||||||
|
RsEventsHandlerId_t mEventHandlerId;
|
||||||
|
|
||||||
std::set<RsNodeGroupId> openGroups;
|
std::set<RsNodeGroupId> openGroups;
|
||||||
std::set<RsPgpId> openPeers;
|
std::set<RsPgpId> openPeers;
|
||||||
|
@ -28,7 +28,8 @@
|
|||||||
|
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
|
|
||||||
#define COLUMN_FEED 0
|
#define COLUMN_FEED 0
|
||||||
|
#define COLUMN_IDENTIFIER 1
|
||||||
|
|
||||||
#define SINGLE_STEP 15
|
#define SINGLE_STEP 15
|
||||||
|
|
||||||
@ -74,6 +75,8 @@ RSFeedWidget::RSFeedWidget(QWidget *parent)
|
|||||||
ui->treeWidget->installEventFilter(this);
|
ui->treeWidget->installEventFilter(this);
|
||||||
|
|
||||||
ui->treeWidget->setVerticalScrollBar(new RSFeedWidgetScrollBar);
|
ui->treeWidget->setVerticalScrollBar(new RSFeedWidgetScrollBar);
|
||||||
|
ui->treeWidget->setColumnCount(2);
|
||||||
|
ui->treeWidget->setColumnHidden(COLUMN_IDENTIFIER,true);
|
||||||
}
|
}
|
||||||
|
|
||||||
RSFeedWidget::~RSFeedWidget()
|
RSFeedWidget::~RSFeedWidget()
|
||||||
@ -130,17 +133,14 @@ bool RSFeedWidget::eventFilter(QObject *object, QEvent *event)
|
|||||||
|
|
||||||
void RSFeedWidget::feedAdded(FeedItem *feedItem, QTreeWidgetItem *treeItem)
|
void RSFeedWidget::feedAdded(FeedItem *feedItem, QTreeWidgetItem *treeItem)
|
||||||
{
|
{
|
||||||
mItems.insert(feedItem, treeItem);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void RSFeedWidget::feedRemoved(FeedItem *feedItem)
|
void RSFeedWidget::feedRemoved(FeedItem *feedItem)
|
||||||
{
|
{
|
||||||
mItems.remove(feedItem);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void RSFeedWidget::feedsCleared()
|
void RSFeedWidget::feedsCleared()
|
||||||
{
|
{
|
||||||
mItems.clear();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void RSFeedWidget::connectSignals(FeedItem *feedItem)
|
void RSFeedWidget::connectSignals(FeedItem *feedItem)
|
||||||
@ -179,6 +179,7 @@ void RSFeedWidget::addFeedItem(FeedItem *feedItem, Qt::ItemDataRole sortRole, co
|
|||||||
QTreeWidgetItem *treeItem = new RSTreeWidgetItem(mFeedCompareRole);
|
QTreeWidgetItem *treeItem = new RSTreeWidgetItem(mFeedCompareRole);
|
||||||
|
|
||||||
treeItem->setData(COLUMN_FEED, sortRole, value);
|
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->addTopLevelItem(treeItem);
|
||||||
ui->treeWidget->setItemWidget(treeItem, 0, feedItem);
|
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) {
|
for (it = sort.begin(); it != sort.end(); ++it) {
|
||||||
treeItem->setData(COLUMN_FEED, it.key(), it.value());
|
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->addTopLevelItem(treeItem);
|
||||||
ui->treeWidget->setItemWidget(treeItem, 0, feedItem);
|
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)
|
void RSFeedWidget::setSort(FeedItem *feedItem, Qt::ItemDataRole sortRole, const QVariant &value)
|
||||||
{
|
{
|
||||||
if (!feedItem) {
|
if (!feedItem)
|
||||||
return;
|
return;
|
||||||
}
|
|
||||||
|
|
||||||
QTreeWidgetItem *treeItem = findTreeWidgetItem(feedItem);
|
QTreeWidgetItem *treeItem = findTreeWidgetItem(feedItem->uniqueIdentifier());
|
||||||
if (!treeItem) {
|
|
||||||
|
if (!treeItem)
|
||||||
return;
|
return;
|
||||||
}
|
|
||||||
|
|
||||||
treeItem->setData(COLUMN_FEED, sortRole, value);
|
treeItem->setData(COLUMN_FEED, sortRole, value);
|
||||||
}
|
}
|
||||||
@ -241,10 +242,9 @@ void RSFeedWidget::setSort(FeedItem *feedItem, const QMap<Qt::ItemDataRole, QVar
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
QTreeWidgetItem *treeItem = findTreeWidgetItem(feedItem);
|
QTreeWidgetItem *treeItem = findTreeWidgetItem(feedItem->uniqueIdentifier());
|
||||||
if (!treeItem) {
|
if (!treeItem)
|
||||||
return;
|
return;
|
||||||
}
|
|
||||||
|
|
||||||
QMap<Qt::ItemDataRole, QVariant>::const_iterator it;
|
QMap<Qt::ItemDataRole, QVariant>::const_iterator it;
|
||||||
for (it = sort.begin(); it != sort.end(); ++it) {
|
for (it = sort.begin(); it != sort.end(); ++it) {
|
||||||
@ -388,13 +388,23 @@ void RSFeedWidget::removeFeedItem(FeedItem *feedItem)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
disconnectSignals(feedItem);
|
QTreeWidgetItem *treeItem = findTreeWidgetItem(feedItem->uniqueIdentifier());
|
||||||
|
|
||||||
QTreeWidgetItem *treeItem = findTreeWidgetItem(feedItem);
|
if (treeItem)
|
||||||
feedRemoved(feedItem);
|
{
|
||||||
if (treeItem) {
|
int treeItem_index = ui->treeWidget->indexOfTopLevelItem(treeItem);
|
||||||
delete(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) {
|
if (!mCountChangedDisabled) {
|
||||||
emit feedCountChanged();
|
emit feedCountChanged();
|
||||||
@ -418,40 +428,42 @@ void RSFeedWidget::feedItemDestroyed(FeedItem *feedItem)
|
|||||||
{
|
{
|
||||||
/* No need to disconnect when object will be destroyed */
|
/* No need to disconnect when object will be destroyed */
|
||||||
|
|
||||||
QTreeWidgetItem *treeItem = findTreeWidgetItem(feedItem);
|
QTreeWidgetItem *treeItem = findTreeWidgetItem(feedItem->uniqueIdentifier());
|
||||||
feedRemoved(feedItem);
|
|
||||||
if (treeItem) {
|
|
||||||
delete(treeItem);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!mCountChangedDisabled) {
|
feedRemoved(feedItem);
|
||||||
|
if (treeItem)
|
||||||
|
delete(treeItem);
|
||||||
|
|
||||||
|
if (!mCountChangedDisabled)
|
||||||
emit feedCountChanged();
|
emit feedCountChanged();
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
QTreeWidgetItem *RSFeedWidget::findTreeWidgetItem(FeedItem *feedItem)
|
QTreeWidgetItem *RSFeedWidget::findTreeWidgetItem(uint64_t identifier)
|
||||||
{
|
{
|
||||||
QMap<FeedItem*, QTreeWidgetItem*>::iterator it = mItems.find(feedItem);
|
QList<QTreeWidgetItem*> list = ui->treeWidget->findItems(QString("%1").arg(identifier,8,16,QChar('0')),Qt::MatchExactly,COLUMN_IDENTIFIER);
|
||||||
if (it == mItems.end()) {
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
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)
|
bool RSFeedWidget::scrollTo(FeedItem *feedItem, bool focus)
|
||||||
{
|
{
|
||||||
QTreeWidgetItem *item = findTreeWidgetItem(feedItem);
|
QTreeWidgetItem *item = findTreeWidgetItem(feedItem->uniqueIdentifier());
|
||||||
if (!feedItem) {
|
if (!feedItem)
|
||||||
return false;
|
return false;
|
||||||
}
|
|
||||||
|
|
||||||
ui->treeWidget->scrollToItem(item);
|
ui->treeWidget->scrollToItem(item);
|
||||||
ui->treeWidget->setCurrentItem(item);
|
ui->treeWidget->setCurrentItem(item);
|
||||||
|
|
||||||
if (focus) {
|
if (focus)
|
||||||
ui->treeWidget->setFocus();
|
ui->treeWidget->setFocus();
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
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);
|
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) {
|
while ((treeItem = *it) != NULL) {
|
||||||
++it;
|
++it;
|
||||||
|
|
||||||
FeedItem *feedItem = feedItemFromTreeItem(treeItem);
|
FeedItem *feedItem = feedItemFromTreeItem(treeItem);
|
||||||
if (!feedItem) {
|
if (!feedItem)
|
||||||
continue;
|
continue;
|
||||||
}
|
|
||||||
|
|
||||||
if (callback(feedItem, data)) {
|
uint64_t id = feedItem->uniqueIdentifier();
|
||||||
|
|
||||||
|
if (id == identifier)
|
||||||
return feedItem;
|
return feedItem;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return NULL;
|
return NULL;
|
||||||
|
@ -71,7 +71,7 @@ public:
|
|||||||
bool scrollTo(FeedItem *feedItem, bool focus);
|
bool scrollTo(FeedItem *feedItem, bool focus);
|
||||||
|
|
||||||
void withAll(RSFeedWidgetCallbackFunction callback, void *data);
|
void withAll(RSFeedWidgetCallbackFunction callback, void *data);
|
||||||
FeedItem *findFeedItem(RSFeedWidgetFindCallbackFunction callback, void *data);
|
FeedItem *findFeedItem(uint64_t identifier);
|
||||||
|
|
||||||
void selectedFeedItems(QList<FeedItem*> &feedItems);
|
void selectedFeedItems(QList<FeedItem*> &feedItems);
|
||||||
|
|
||||||
@ -98,7 +98,7 @@ private:
|
|||||||
void connectSignals(FeedItem *feedItem);
|
void connectSignals(FeedItem *feedItem);
|
||||||
void disconnectSignals(FeedItem *feedItem);
|
void disconnectSignals(FeedItem *feedItem);
|
||||||
FeedItem *feedItemFromTreeItem(QTreeWidgetItem *treeItem);
|
FeedItem *feedItemFromTreeItem(QTreeWidgetItem *treeItem);
|
||||||
QTreeWidgetItem *findTreeWidgetItem(FeedItem *feedItem);
|
QTreeWidgetItem *findTreeWidgetItem(uint64_t identifier);
|
||||||
void filterItems();
|
void filterItems();
|
||||||
void filterItem(QTreeWidgetItem *treeItem, FeedItem *feedItem);
|
void filterItem(QTreeWidgetItem *treeItem, FeedItem *feedItem);
|
||||||
|
|
||||||
@ -117,9 +117,6 @@ private:
|
|||||||
/* Options */
|
/* Options */
|
||||||
int mCountChangedDisabled;
|
int mCountChangedDisabled;
|
||||||
|
|
||||||
/* Items */
|
|
||||||
QMap<FeedItem*, QTreeWidgetItem*> mItems;
|
|
||||||
|
|
||||||
Ui::RSFeedWidget *ui;
|
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)
|
void ConnectFriendWizard::setGpgId(const RsPgpId &gpgId, const RsPeerId &sslId, bool friendRequest)
|
||||||
{
|
{
|
||||||
if (!rsPeers->getGPGDetails(gpgId, peerDetails)) {
|
if(sslId == rsPeers->getOwnId())
|
||||||
setField("errorMessage", tr("Cannot get peer details of PGP key %1").arg(QString::fromStdString(gpgId.toStdString())));
|
{
|
||||||
|
setField("errorMessage", tr("This is your own certificate! You would not want to make friend with yourself. Wouldn't you?") ) ;
|
||||||
setStartId(Page_ErrorMessage);
|
setStartId(Page_ErrorMessage);
|
||||||
return;
|
error = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Set ssl id when available */
|
if (!rsPeers->getGPGDetails(gpgId, peerDetails))
|
||||||
peerDetails.id = sslId;
|
{
|
||||||
|
mIsShortInvite = true;
|
||||||
|
|
||||||
//setStartId(friendRequest ? Page_FriendRequest : Page_Conclusion);
|
peerDetails.id = sslId;
|
||||||
setStartId(Page_Conclusion);
|
peerDetails.gpg_id = gpgId;
|
||||||
if (friendRequest){
|
peerDetails.skip_pgp_signature_validation = true;
|
||||||
ui->cp_Label->show();
|
|
||||||
ui->requestinfolabel->show();
|
mCertificate.clear();
|
||||||
setTitleText(ui->ConclusionPage,tr("Friend request"));
|
|
||||||
ui->ConclusionPage->setSubTitle(tr("Details about the request"));
|
setStartId(Page_Conclusion);
|
||||||
setButtonText(QWizard::FinishButton , tr("Accept"));
|
|
||||||
}
|
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()
|
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->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->nameEdit->setText(QString::fromUtf8(peerDetails.name.c_str()));
|
||||||
ui->trustEdit->setText(trustString);
|
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());
|
QString loc = QString::fromUtf8(peerDetails.location.c_str());
|
||||||
if (!loc.isEmpty())
|
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->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");
|
ui->ipLabel->setToolTip("This is a Hidden node - you need tor/i2p proxy to connect");
|
||||||
}
|
}
|
||||||
|
if(mIsShortInvite)
|
||||||
if(peerDetails.email.empty())
|
|
||||||
{
|
{
|
||||||
ui->emailLabel->hide(); // is it ever used?
|
ui->nameEdit->setText(tr("[Unknown]"));
|
||||||
ui->emailEdit->hide();
|
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);
|
ui->ipEdit->setTextInteractionFlags(Qt::TextSelectableByMouse);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -6,8 +6,8 @@
|
|||||||
<rect>
|
<rect>
|
||||||
<x>0</x>
|
<x>0</x>
|
||||||
<y>0</y>
|
<y>0</y>
|
||||||
<width>600</width>
|
<width>1139</width>
|
||||||
<height>437</height>
|
<height>1171</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
<property name="windowTitle">
|
<property name="windowTitle">
|
||||||
@ -480,14 +480,14 @@
|
|||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="3" column="0">
|
<item row="3" column="0">
|
||||||
<widget class="QLabel" name="emailLabel">
|
<widget class="QLabel" name="profileIdLabel">
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>Email:</string>
|
<string>Profile ID:</string>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="3" column="1">
|
<item row="3" column="1">
|
||||||
<widget class="QLabel" name="emailEdit">
|
<widget class="QLabel" name="profileIdEdit">
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string notr="true">Email</string>
|
<string notr="true">Email</string>
|
||||||
</property>
|
</property>
|
||||||
@ -794,8 +794,8 @@
|
|||||||
</customwidget>
|
</customwidget>
|
||||||
</customwidgets>
|
</customwidgets>
|
||||||
<resources>
|
<resources>
|
||||||
<include location="../images.qrc"/>
|
|
||||||
<include location="../icons.qrc"/>
|
<include location="../icons.qrc"/>
|
||||||
|
<include location="../images.qrc"/>
|
||||||
</resources>
|
</resources>
|
||||||
<connections/>
|
<connections/>
|
||||||
</ui>
|
</ui>
|
||||||
|
@ -37,6 +37,7 @@ public:
|
|||||||
|
|
||||||
void updateItemStatic();
|
void updateItemStatic();
|
||||||
|
|
||||||
|
virtual uint64_t uniqueIdentifier() const override { return hash_64bits("ChatMsgItem " + mPeerId.toStdString()); }
|
||||||
protected:
|
protected:
|
||||||
/* FeedItem */
|
/* FeedItem */
|
||||||
virtual void doExpand(bool /*open*/) {}
|
virtual void doExpand(bool /*open*/) {}
|
||||||
|
@ -18,10 +18,11 @@
|
|||||||
* *
|
* *
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
|
|
||||||
|
#include <iostream>
|
||||||
#include "FeedItem.h"
|
#include "FeedItem.h"
|
||||||
|
|
||||||
/** Constructor */
|
/** Constructor */
|
||||||
FeedItem::FeedItem(QWidget *parent) : QWidget(parent)
|
FeedItem::FeedItem(QWidget *parent) : QWidget(parent), mHash(0)
|
||||||
{
|
{
|
||||||
mWasExpanded = false;
|
mWasExpanded = false;
|
||||||
}
|
}
|
||||||
@ -43,3 +44,16 @@ void FeedItem::expand(bool open)
|
|||||||
mWasExpanded = true;
|
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; }
|
bool wasExpanded() { return mWasExpanded; }
|
||||||
void expand(bool open);
|
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:
|
protected:
|
||||||
virtual void doExpand(bool open) = 0;
|
virtual void doExpand(bool open) = 0;
|
||||||
virtual void expandFill(bool /*first*/) {}
|
virtual void expandFill(bool /*first*/) {}
|
||||||
|
|
||||||
|
uint64_t hash_64bits(const std::string& s) const;
|
||||||
signals:
|
signals:
|
||||||
void sizeChanged(FeedItem *feedItem);
|
void sizeChanged(FeedItem *feedItem);
|
||||||
void feedItemDestroyed(FeedItem *feedItem);
|
void feedItemDestroyed(FeedItem *feedItem);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
bool mWasExpanded;
|
bool mWasExpanded;
|
||||||
|
mutable uint64_t mHash;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -41,7 +41,7 @@ public:
|
|||||||
~GxsChannelGroupItem();
|
~GxsChannelGroupItem();
|
||||||
|
|
||||||
bool setGroup(const RsGxsChannelGroup &group);
|
bool setGroup(const RsGxsChannelGroup &group);
|
||||||
|
uint64_t uniqueIdentifier() const override { return hash_64bits("GxsChannelGroupItem " + groupId().toStdString()) ; }
|
||||||
protected:
|
protected:
|
||||||
/* FeedItem */
|
/* FeedItem */
|
||||||
virtual void doExpand(bool open);
|
virtual void doExpand(bool open);
|
||||||
|
@ -71,6 +71,7 @@ void GxsChannelPostItem::init(const RsGxsMessageId& messageId,const std::set<RsG
|
|||||||
|
|
||||||
setup();
|
setup();
|
||||||
|
|
||||||
|
mPost.mMeta.mMsgId = messageId; // useful for uniqueIdentifer() before the post is loaded
|
||||||
mLoaded = false ;
|
mLoaded = false ;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -183,6 +184,7 @@ void GxsChannelPostItem::setup()
|
|||||||
|
|
||||||
connect(ui->downloadButton, SIGNAL(clicked()), this, SLOT(download()));
|
connect(ui->downloadButton, SIGNAL(clicked()), this, SLOT(download()));
|
||||||
// HACK FOR NOW.
|
// HACK FOR NOW.
|
||||||
|
ui->commentButton->hide();// hidden until properly enabled.
|
||||||
connect(ui->commentButton, SIGNAL(clicked()), this, SLOT(loadComments()));
|
connect(ui->commentButton, SIGNAL(clicked()), this, SLOT(loadComments()));
|
||||||
|
|
||||||
connect(ui->playButton, SIGNAL(clicked()), this, SLOT(play(void)));
|
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);
|
//GxsChannelPostItem(FeedHolder *feedHolder, uint32_t feedId, const RsGxsChannelPost &post, bool isHome, bool autoUpdate);
|
||||||
virtual ~GxsChannelPostItem();
|
virtual ~GxsChannelPostItem();
|
||||||
|
|
||||||
|
uint64_t uniqueIdentifier() const override { hash_64bits("GxsChannelPostItem " + mPost.mMeta.mMsgId.toStdString()) ; }
|
||||||
|
|
||||||
bool setGroup(const RsGxsChannelGroup &group, bool doFill = true);
|
bool setGroup(const RsGxsChannelGroup &group, bool doFill = true);
|
||||||
bool setPost(const RsGxsChannelPost &post, bool doFill = true);
|
bool setPost(const RsGxsChannelPost &post, bool doFill = true);
|
||||||
|
|
||||||
|
@ -6,7 +6,7 @@
|
|||||||
<rect>
|
<rect>
|
||||||
<x>0</x>
|
<x>0</x>
|
||||||
<y>0</y>
|
<y>0</y>
|
||||||
<width>1140</width>
|
<width>1359</width>
|
||||||
<height>342</height>
|
<height>342</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
@ -57,18 +57,6 @@
|
|||||||
<verstretch>0</verstretch>
|
<verstretch>0</verstretch>
|
||||||
</sizepolicy>
|
</sizepolicy>
|
||||||
</property>
|
</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">
|
<property name="text">
|
||||||
<string/>
|
<string/>
|
||||||
</property>
|
</property>
|
||||||
@ -138,12 +126,6 @@
|
|||||||
<verstretch>0</verstretch>
|
<verstretch>0</verstretch>
|
||||||
</sizepolicy>
|
</sizepolicy>
|
||||||
</property>
|
</property>
|
||||||
<property name="maximumSize">
|
|
||||||
<size>
|
|
||||||
<width>16777215</width>
|
|
||||||
<height>60</height>
|
|
||||||
</size>
|
|
||||||
</property>
|
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string notr="true">Short Description</string>
|
<string notr="true">Short Description</string>
|
||||||
</property>
|
</property>
|
||||||
@ -570,8 +552,8 @@
|
|||||||
</customwidget>
|
</customwidget>
|
||||||
</customwidgets>
|
</customwidgets>
|
||||||
<resources>
|
<resources>
|
||||||
<include location="../images.qrc"/>
|
|
||||||
<include location="../icons.qrc"/>
|
<include location="../icons.qrc"/>
|
||||||
|
<include location="../images.qrc"/>
|
||||||
</resources>
|
</resources>
|
||||||
<connections/>
|
<connections/>
|
||||||
</ui>
|
</ui>
|
||||||
|
@ -91,12 +91,18 @@ void GxsCircleItem::setup()
|
|||||||
ui->iconLabel->setPixmap(pixmap);
|
ui->iconLabel->setPixmap(pixmap);
|
||||||
ui->gxsIdLabel->setId(mGxsId);
|
ui->gxsIdLabel->setId(mGxsId);
|
||||||
|
|
||||||
|
if(circleDetails.mAmIAdmin)
|
||||||
|
{
|
||||||
ui->acceptButton->setToolTip(tr("Grant membership request"));
|
ui->acceptButton->setToolTip(tr("Grant membership request"));
|
||||||
ui->revokeButton->setToolTip(tr("Revoke membership request"));
|
ui->revokeButton->setToolTip(tr("Revoke membership request"));
|
||||||
connect(ui->acceptButton, SIGNAL(clicked()), this, SLOT(grantCircleMembership()));
|
connect(ui->acceptButton, SIGNAL(clicked()), this, SLOT(grantCircleMembership()));
|
||||||
connect(ui->revokeButton, SIGNAL(clicked()), this, SLOT(revokeCircleMembership()));
|
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)
|
else if (mType == RS_FEED_ITEM_CIRCLE_INVIT_REC)
|
||||||
{
|
{
|
||||||
@ -110,7 +116,43 @@ void GxsCircleItem::setup()
|
|||||||
connect(ui->acceptButton, SIGNAL(clicked()), this, SLOT(acceptCircleSubscription()));
|
connect(ui->acceptButton, SIGNAL(clicked()), this, SLOT(acceptCircleSubscription()));
|
||||||
ui->revokeButton->setHidden(true);
|
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
|
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 hash_64bits("GxsCircle " + mCircleId.toStdString() + " " + mGxsId.toStdString() + " " + QString::number(mType).toStdString());
|
||||||
{
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void GxsCircleItem::removeItem()
|
void GxsCircleItem::removeItem()
|
||||||
|
@ -52,8 +52,7 @@ public:
|
|||||||
GxsCircleItem(FeedHolder *feedHolder, uint32_t feedId, const RsGxsCircleId &circleId, const RsGxsId &gxsId, const uint32_t type);
|
GxsCircleItem(FeedHolder *feedHolder, uint32_t feedId, const RsGxsCircleId &circleId, const RsGxsId &gxsId, const uint32_t type);
|
||||||
virtual ~GxsCircleItem();
|
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);
|
void loadRequest(const TokenQueue *queue, const TokenRequest &req);
|
||||||
|
|
||||||
|
|
||||||
|
@ -42,6 +42,7 @@ public:
|
|||||||
|
|
||||||
bool setGroup(const RsGxsForumGroup &group);
|
bool setGroup(const RsGxsForumGroup &group);
|
||||||
|
|
||||||
|
uint64_t uniqueIdentifier() const override { return hash_64bits("GxsForumGroupItem " + groupId().toStdString()) ; }
|
||||||
protected:
|
protected:
|
||||||
/* FeedItem */
|
/* FeedItem */
|
||||||
virtual void doExpand(bool open);
|
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) :
|
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)
|
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();
|
setup();
|
||||||
|
|
||||||
requestGroup();
|
requestGroup();
|
||||||
|
@ -43,6 +43,7 @@ public:
|
|||||||
bool setGroup(const RsGxsForumGroup &group, bool doFill = true);
|
bool setGroup(const RsGxsForumGroup &group, bool doFill = true);
|
||||||
bool setMessage(const RsGxsForumMsg &msg, 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:
|
protected:
|
||||||
/* FeedItem */
|
/* FeedItem */
|
||||||
virtual void doExpand(bool open);
|
virtual void doExpand(bool open);
|
||||||
|
@ -38,6 +38,7 @@ public:
|
|||||||
|
|
||||||
void updateItemStatic();
|
void updateItemStatic();
|
||||||
|
|
||||||
|
uint64_t uniqueIdentifier() const override { return hash_64bits("MsgItem " + mMsgId) ; }
|
||||||
protected:
|
protected:
|
||||||
/* FeedItem */
|
/* FeedItem */
|
||||||
virtual void doExpand(bool open);
|
virtual void doExpand(bool open);
|
||||||
|
@ -26,7 +26,7 @@ NewsFeedUserNotify::NewsFeedUserNotify(NewsFeed *newsFeed, QObject *parent) :
|
|||||||
{
|
{
|
||||||
mNewFeedCount = 0;
|
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)
|
void NewsFeedUserNotify::newsFeedChanged(int count)
|
||||||
|
@ -67,17 +67,11 @@ PeerItem::PeerItem(FeedHolder *parent, uint32_t feedId, const RsPeerId &peerId,
|
|||||||
updateItem();
|
updateItem();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
uint64_t PeerItem::uniqueIdentifier() const
|
||||||
bool PeerItem::isSame(const RsPeerId &peerId, uint32_t type)
|
|
||||||
{
|
{
|
||||||
if ((mPeerId == peerId) && (mType == type))
|
return hash_64bits("PeerItem " + mPeerId.toStdString() + " " + QString::number(mType).toStdString()) ;
|
||||||
{
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void PeerItem::updateItemStatic()
|
void PeerItem::updateItemStatic()
|
||||||
{
|
{
|
||||||
if (!rsPeers)
|
if (!rsPeers)
|
||||||
@ -100,7 +94,7 @@ void PeerItem::updateItemStatic()
|
|||||||
title = tr("Friend Connected");
|
title = tr("Friend Connected");
|
||||||
break;
|
break;
|
||||||
case PEER_TYPE_HELLO:
|
case PEER_TYPE_HELLO:
|
||||||
title = tr("Connect Attempt");
|
title = tr("Connection refused by peer");
|
||||||
break;
|
break;
|
||||||
case PEER_TYPE_NEW_FOF:
|
case PEER_TYPE_NEW_FOF:
|
||||||
title = tr("Friend of Friend");
|
title = tr("Friend of Friend");
|
||||||
@ -135,15 +129,16 @@ void PeerItem::updateItemStatic()
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
statusLabel->setText(tr("Unknown Peer"));
|
peerNameLabel->setText(tr("Unknown peer"));
|
||||||
titleLabel->setText(tr("Unknown Peer"));
|
statusLabel->setText(tr("Unknown"));
|
||||||
trustLabel->setText(tr("Unknown Peer"));
|
titleLabel->setText(tr("Unknown peer"));
|
||||||
nameLabel->setText(tr("Unknown Peer"));
|
trustLabel->setText(tr("Unknown"));
|
||||||
idLabel->setText(tr("Unknown Peer"));
|
nameLabel->setText(tr("Unknown"));
|
||||||
locLabel->setText(tr("Unknown Peer"));
|
idLabel->setText(tr("Unknown"));
|
||||||
ipLabel->setText(tr("Unknown Peer"));
|
locLabel->setText(tr("Unknown"));
|
||||||
connLabel->setText(tr("Unknown Peer"));
|
ipLabel->setText(tr("Unknown"));
|
||||||
lastLabel->setText(tr("Unknown Peer"));
|
connLabel->setText(tr("Unknown"));
|
||||||
|
lastLabel->setText(tr("Unknown"));
|
||||||
|
|
||||||
chatButton->setEnabled(false);
|
chatButton->setEnabled(false);
|
||||||
}
|
}
|
||||||
@ -192,7 +187,19 @@ void PeerItem::updateItem()
|
|||||||
statusLabel->setText(status);
|
statusLabel->setText(status);
|
||||||
trustLabel->setText(QString::fromStdString(RsPeerTrustString(details.trustLvl)));
|
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));
|
connLabel->setText(StatusDefs::connectStateString(details));
|
||||||
|
|
||||||
|
@ -43,7 +43,7 @@ public:
|
|||||||
|
|
||||||
void updateItemStatic();
|
void updateItemStatic();
|
||||||
|
|
||||||
bool isSame(const RsPeerId &peerId, uint32_t type);
|
uint64_t uniqueIdentifier() const override;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
/* FeedItem */
|
/* FeedItem */
|
||||||
|
@ -42,6 +42,8 @@ public:
|
|||||||
|
|
||||||
bool setGroup(const RsPostedGroup &group);
|
bool setGroup(const RsPostedGroup &group);
|
||||||
|
|
||||||
|
uint64_t uniqueIdentifier() const override { return hash_64bits("PostedGroupItem " + groupId().toStdString()) ; }
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
/* FeedItem */
|
/* FeedItem */
|
||||||
virtual void doExpand(bool open);
|
virtual void doExpand(bool open);
|
||||||
|
@ -78,13 +78,9 @@ void SecurityIpItem::setup()
|
|||||||
updateItem();
|
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 hash_64bits("SecurityItem " + QString::number(mType).toStdString() + " " + mSslId.toStdString() + " " + mIpAddr + " " + mIpAddrReported) ;
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void SecurityIpItem::updateItemStatic()
|
void SecurityIpItem::updateItemStatic()
|
||||||
|
@ -43,7 +43,7 @@ public:
|
|||||||
|
|
||||||
void updateItemStatic();
|
void updateItemStatic();
|
||||||
|
|
||||||
bool isSame(const RsPeerId &sslId, const std::string& ipAddr, const std::string& ipAddrReported, uint32_t type);
|
uint64_t uniqueIdentifier() const override;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
/* FeedItem */
|
/* FeedItem */
|
||||||
|
@ -81,17 +81,11 @@ SecurityItem::SecurityItem(FeedHolder *parent, uint32_t feedId, const RsPgpId &g
|
|||||||
updateItem();
|
updateItem();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
uint64_t SecurityItem::uniqueIdentifier() const
|
||||||
bool SecurityItem::isSame(const RsPeerId &sslId, uint32_t type)
|
|
||||||
{
|
{
|
||||||
if ((mSslId == sslId) && (mType == type))
|
return hash_64bits("SecurityItem " + QString::number(mType).toStdString() + " " + mSslId.toStdString());
|
||||||
{
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void SecurityItem::updateItemStatic()
|
void SecurityItem::updateItemStatic()
|
||||||
{
|
{
|
||||||
if (!rsPeers)
|
if (!rsPeers)
|
||||||
@ -180,40 +174,47 @@ void SecurityItem::updateItem()
|
|||||||
std::cerr << std::endl;
|
std::cerr << std::endl;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if(!RsAutoUpdatePage::eventsLocked()) {
|
if(!RsAutoUpdatePage::eventsLocked())
|
||||||
|
{
|
||||||
RsPeerDetails details;
|
RsPeerDetails details;
|
||||||
/* first try sslid */
|
/* first try sslid */;
|
||||||
if (!rsPeers->getPeerDetails(mSslId, details))
|
if (!rsPeers->getPeerDetails(mSslId, details) && !rsPeers->getGPGDetails(mGpgId, details))
|
||||||
{
|
{
|
||||||
/* then gpgid */
|
/* it is very likely that we will end up here for some of the
|
||||||
if(!rsPeers->getGPGDetails(mGpgId, details))
|
|
||||||
{
|
|
||||||
/* it is very likely that we will end up here for some of the
|
|
||||||
* Unknown peer cases.... so allow them here
|
* Unknown peer cases.... so allow them here
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/* set peer name */
|
/* set peer name */
|
||||||
peerNameLabel->setText(QString("%1 (%2)").arg(tr("Unknown Peer"), QString::fromUtf8(mSslCn.c_str())));
|
peerNameLabel->setText(tr("A unknown peer"));
|
||||||
|
|
||||||
nameLabel->setText(QString::fromUtf8(mSslCn.c_str()) + " (" + QString::fromStdString(mGpgId.toStdString()) + ")");
|
nameLabel->setText(tr("Unknown") + " (" + tr("Profile ID: ") + QString::fromStdString(mGpgId.toStdString()) + ")");
|
||||||
idLabel->setText(QString::fromStdString(mSslId.toStdString()));
|
idLabel->setText(QString::fromStdString(mSslId.toStdString()));
|
||||||
|
|
||||||
statusLabel->setText(tr("Unknown Peer"));
|
statusLabel->hide();
|
||||||
trustLabel->setText(tr("Unknown Peer"));
|
typeLabel->hide();
|
||||||
locLabel->setText(tr("Unknown Peer"));
|
|
||||||
ipLabel->setText(QString::fromStdString(mIP)) ; //tr("Unknown Peer"));
|
|
||||||
connLabel->setText(tr("Unknown Peer"));
|
|
||||||
|
|
||||||
chatButton->hide();
|
trustLabel->hide();
|
||||||
//quickmsgButton->hide();
|
trustLeftLabel->hide();
|
||||||
requestLabel->hide();
|
|
||||||
|
|
||||||
removeFriendButton->setEnabled(false);
|
locLabel->hide();
|
||||||
removeFriendButton->hide();
|
locLeftLabel->hide();
|
||||||
peerDetailsButton->setEnabled(false);
|
|
||||||
|
|
||||||
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 */
|
/* set peer name */
|
||||||
@ -350,6 +351,7 @@ void SecurityItem::friendRequest()
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
ConnectFriendWizard *connectFriendWizard = new ConnectFriendWizard;
|
ConnectFriendWizard *connectFriendWizard = new ConnectFriendWizard;
|
||||||
|
|
||||||
connectFriendWizard->setAttribute(Qt::WA_DeleteOnClose, true);
|
connectFriendWizard->setAttribute(Qt::WA_DeleteOnClose, true);
|
||||||
connectFriendWizard->setGpgId(mGpgId, mSslId, true);
|
connectFriendWizard->setGpgId(mGpgId, mSslId, true);
|
||||||
connectFriendWizard->show();
|
connectFriendWizard->show();
|
||||||
|
@ -42,7 +42,7 @@ public:
|
|||||||
|
|
||||||
void updateItemStatic();
|
void updateItemStatic();
|
||||||
|
|
||||||
bool isSame(const RsPeerId &sslId, uint32_t type);
|
uint64_t uniqueIdentifier() const override;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
/* FeedItem */
|
/* FeedItem */
|
||||||
|
@ -6,8 +6,8 @@
|
|||||||
<rect>
|
<rect>
|
||||||
<x>0</x>
|
<x>0</x>
|
||||||
<y>0</y>
|
<y>0</y>
|
||||||
<width>763</width>
|
<width>1196</width>
|
||||||
<height>246</height>
|
<height>491</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
<layout class="QGridLayout">
|
<layout class="QGridLayout">
|
||||||
@ -354,7 +354,7 @@
|
|||||||
<item>
|
<item>
|
||||||
<layout class="QVBoxLayout" name="verticalLayout">
|
<layout class="QVBoxLayout" name="verticalLayout">
|
||||||
<item>
|
<item>
|
||||||
<widget class="QLabel" name="label_3">
|
<widget class="QLabel" name="nameLeftLabel">
|
||||||
<property name="font">
|
<property name="font">
|
||||||
<font>
|
<font>
|
||||||
<weight>75</weight>
|
<weight>75</weight>
|
||||||
@ -367,7 +367,7 @@
|
|||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item>
|
<item>
|
||||||
<widget class="QLabel" name="label_4">
|
<widget class="QLabel" name="idLeftLabel">
|
||||||
<property name="font">
|
<property name="font">
|
||||||
<font>
|
<font>
|
||||||
<weight>75</weight>
|
<weight>75</weight>
|
||||||
@ -380,7 +380,7 @@
|
|||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item>
|
<item>
|
||||||
<widget class="QLabel" name="label">
|
<widget class="QLabel" name="trustLeftLabel">
|
||||||
<property name="sizePolicy">
|
<property name="sizePolicy">
|
||||||
<sizepolicy hsizetype="Preferred" vsizetype="Minimum">
|
<sizepolicy hsizetype="Preferred" vsizetype="Minimum">
|
||||||
<horstretch>0</horstretch>
|
<horstretch>0</horstretch>
|
||||||
@ -399,7 +399,7 @@
|
|||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item>
|
<item>
|
||||||
<widget class="QLabel" name="label_6">
|
<widget class="QLabel" name="locLeftLabel">
|
||||||
<property name="font">
|
<property name="font">
|
||||||
<font>
|
<font>
|
||||||
<weight>75</weight>
|
<weight>75</weight>
|
||||||
@ -412,7 +412,7 @@
|
|||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item>
|
<item>
|
||||||
<widget class="QLabel" name="label_8">
|
<widget class="QLabel" name="ipLeftLabel">
|
||||||
<property name="font">
|
<property name="font">
|
||||||
<font>
|
<font>
|
||||||
<weight>75</weight>
|
<weight>75</weight>
|
||||||
@ -425,7 +425,7 @@
|
|||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item>
|
<item>
|
||||||
<widget class="QLabel" name="label_9">
|
<widget class="QLabel" name="connLeftLabel">
|
||||||
<property name="font">
|
<property name="font">
|
||||||
<font>
|
<font>
|
||||||
<weight>75</weight>
|
<weight>75</weight>
|
||||||
@ -578,8 +578,8 @@
|
|||||||
</customwidget>
|
</customwidget>
|
||||||
</customwidgets>
|
</customwidgets>
|
||||||
<resources>
|
<resources>
|
||||||
<include location="../images.qrc"/>
|
|
||||||
<include location="../icons.qrc"/>
|
<include location="../icons.qrc"/>
|
||||||
|
<include location="../images.qrc"/>
|
||||||
</resources>
|
</resources>
|
||||||
<connections/>
|
<connections/>
|
||||||
</ui>
|
</ui>
|
||||||
|
@ -351,7 +351,9 @@ void GxsIdChooser::setDefaultItem()
|
|||||||
|
|
||||||
if (def >= 0) {
|
if (def >= 0) {
|
||||||
setCurrentIndex(def);
|
setCurrentIndex(def);
|
||||||
|
#ifdef IDCHOOSER_DEBUG
|
||||||
std::cerr << "GxsIdChooser-002" << (void*)this << " setting current index to " << def << std::endl;
|
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);
|
int index = findData(id);
|
||||||
if (index >= 0) {
|
if (index >= 0) {
|
||||||
setCurrentIndex(index);
|
setCurrentIndex(index);
|
||||||
|
#ifdef IDCHOOSER_DEBUG
|
||||||
std::cerr << "GxsIdChooser-001" << (void*)this << " setting current index to " << index << std::endl;
|
std::cerr << "GxsIdChooser-001" << (void*)this << " setting current index to " << index << std::endl;
|
||||||
|
#endif
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
|
@ -50,6 +50,28 @@ public:
|
|||||||
GxsChannelDialog::GxsChannelDialog(QWidget *parent)
|
GxsChannelDialog::GxsChannelDialog(QWidget *parent)
|
||||||
: GxsGroupFrameDialog(rsGxsChannels, parent,true)
|
: 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 RsChannelEventCode::SUBSCRIBE_STATUS_CHANGED: updateDisplay(true);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
GxsChannelDialog::~GxsChannelDialog()
|
GxsChannelDialog::~GxsChannelDialog()
|
||||||
|
@ -74,6 +74,10 @@ private:
|
|||||||
virtual QWidget *createCommentHeaderWidget(const RsGxsGroupId &grpId, const RsGxsMessageId &msgId);
|
virtual QWidget *createCommentHeaderWidget(const RsGxsGroupId &grpId, const RsGxsMessageId &msgId);
|
||||||
virtual uint32_t requestGroupSummaryType() { return GXS_REQUEST_TYPE_GROUP_DATA; } // request complete group data
|
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);
|
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
|
#endif
|
||||||
|
@ -128,6 +128,35 @@ GxsChannelPostsWidget::GxsChannelPostsWidget(const RsGxsGroupId &channelId, QWid
|
|||||||
setAutoDownload(false);
|
setAutoDownload(false);
|
||||||
settingsChanged();
|
settingsChanged();
|
||||||
setGroupId(channelId);
|
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 RsChannelEventCode::UPDATED_CHANNEL:
|
||||||
|
case RsChannelEventCode::NEW_CHANNEL:
|
||||||
|
case RsChannelEventCode::UPDATED_MESSAGE:
|
||||||
|
case RsChannelEventCode::NEW_MESSAGE:
|
||||||
|
if(e->mChannelGroupId == mChannelGroupId)
|
||||||
|
updateDisplay(true);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
GxsChannelPostsWidget::~GxsChannelPostsWidget()
|
GxsChannelPostsWidget::~GxsChannelPostsWidget()
|
||||||
@ -712,6 +741,7 @@ bool GxsChannelPostsWidget::insertGroupData(const uint32_t &token, RsGroupMetaDa
|
|||||||
{
|
{
|
||||||
insertChannelDetails(groups[0]);
|
insertChannelDetails(groups[0]);
|
||||||
metaData = groups[0].mMeta;
|
metaData = groups[0].mMeta;
|
||||||
|
mChannelGroupId = groups[0].mMeta.mGroupId;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -721,6 +751,7 @@ bool GxsChannelPostsWidget::insertGroupData(const uint32_t &token, RsGroupMetaDa
|
|||||||
{
|
{
|
||||||
insertChannelDetails(distant_group);
|
insertChannelDetails(distant_group);
|
||||||
metaData = distant_group.mMeta;
|
metaData = distant_group.mMeta;
|
||||||
|
mChannelGroupId = distant_group.mMeta.mGroupId;
|
||||||
return true ;
|
return true ;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -97,11 +97,14 @@ private:
|
|||||||
void insertChannelPosts(std::vector<RsGxsChannelPost> &posts, GxsMessageFramePostThread *thread, bool related);
|
void insertChannelPosts(std::vector<RsGxsChannelPost> &posts, GxsMessageFramePostThread *thread, bool related);
|
||||||
|
|
||||||
void createPostItem(const RsGxsChannelPost &post, bool related);
|
void createPostItem(const RsGxsChannelPost &post, bool related);
|
||||||
|
void handleEvent_main_thread(std::shared_ptr<const RsEvent> event);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QAction *mAutoDownloadAction;
|
QAction *mAutoDownloadAction;
|
||||||
|
|
||||||
bool mUseThread;
|
bool mUseThread;
|
||||||
|
RsGxsGroupId mChannelGroupId;
|
||||||
|
RsEventsHandlerId_t mEventHandlerId ;
|
||||||
|
|
||||||
/* UI - from Designer */
|
/* UI - from Designer */
|
||||||
Ui::GxsChannelPostsWidget *ui;
|
Ui::GxsChannelPostsWidget *ui;
|
||||||
|
@ -432,6 +432,32 @@ GxsForumThreadWidget::GxsForumThreadWidget(const RsGxsGroupId &forumId, QWidget
|
|||||||
#ifdef SUSPENDED_CODE
|
#ifdef SUSPENDED_CODE
|
||||||
ui->threadTreeWidget->enableColumnCustomize(true);
|
ui->threadTreeWidget->enableColumnCustomize(true);
|
||||||
#endif
|
#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 RsForumEventCode::UPDATED_FORUM: // [[fallthrough]];
|
||||||
|
case RsForumEventCode::NEW_FORUM: // [[fallthrough]];
|
||||||
|
case RsForumEventCode::UPDATED_MESSAGE: // [[fallthrough]];
|
||||||
|
case RsForumEventCode::NEW_MESSAGE:
|
||||||
|
if(e->mForumGroupId == mForumGroup.mMeta.mGroupId)
|
||||||
|
updateDisplay(true);
|
||||||
|
break;
|
||||||
|
default: break;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void GxsForumThreadWidget::blank()
|
void GxsForumThreadWidget::blank()
|
||||||
|
@ -172,6 +172,8 @@ private:
|
|||||||
void updateMessageData(const RsGxsMessageId& msgId);
|
void updateMessageData(const RsGxsMessageId& msgId);
|
||||||
void updateForumDescription();
|
void updateForumDescription();
|
||||||
|
|
||||||
|
void handleEvent_main_thread(std::shared_ptr<const RsEvent> event);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
RsGxsGroupId mLastForumID;
|
RsGxsGroupId mLastForumID;
|
||||||
RsGxsMessageId mThreadId;
|
RsGxsMessageId mThreadId;
|
||||||
@ -201,6 +203,7 @@ private:
|
|||||||
QList<RsGxsMessageId> mSavedExpandedMessages;
|
QList<RsGxsMessageId> mSavedExpandedMessages;
|
||||||
|
|
||||||
Ui::GxsForumThreadWidget *ui;
|
Ui::GxsForumThreadWidget *ui;
|
||||||
|
RsEventsHandlerId_t mEventHandlerId;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // GXSFORUMTHREADWIDGET_H
|
#endif // GXSFORUMTHREADWIDGET_H
|
||||||
|
@ -25,6 +25,7 @@
|
|||||||
#include "GxsForumUserNotify.h"
|
#include "GxsForumUserNotify.h"
|
||||||
#include "gui/notifyqt.h"
|
#include "gui/notifyqt.h"
|
||||||
#include "gui/gxs/GxsGroupShareKey.h"
|
#include "gui/gxs/GxsGroupShareKey.h"
|
||||||
|
#include "util/qtthreadsutils.h"
|
||||||
#include "gui/common/GroupTreeWidget.h"
|
#include "gui/common/GroupTreeWidget.h"
|
||||||
|
|
||||||
class GxsForumGroupInfoData : public RsUserdata
|
class GxsForumGroupInfoData : public RsUserdata
|
||||||
@ -41,6 +42,29 @@ GxsForumsDialog::GxsForumsDialog(QWidget *parent)
|
|||||||
: GxsGroupFrameDialog(rsGxsForums, parent)
|
: GxsGroupFrameDialog(rsGxsForums, parent)
|
||||||
{
|
{
|
||||||
mCountChildMsgs = true;
|
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 RsForumEventCode::SUBSCRIBE_STATUS_CHANGED: updateDisplay(true);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
GxsForumsDialog::~GxsForumsDialog()
|
GxsForumsDialog::~GxsForumsDialog()
|
||||||
|
@ -58,6 +58,10 @@ private:
|
|||||||
virtual GxsMessageFrameWidget *createMessageFrameWidget(const RsGxsGroupId &groupId);
|
virtual GxsMessageFrameWidget *createMessageFrameWidget(const RsGxsGroupId &groupId);
|
||||||
virtual uint32_t requestGroupSummaryType() { return GXS_REQUEST_TYPE_GROUP_DATA; } // request complete group data
|
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);
|
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
|
#endif
|
||||||
|
@ -584,16 +584,18 @@ void MessageComposer::recommendFriend(const std::set <RsPeerId> &sslIds, const R
|
|||||||
/* window will destroy itself! */
|
/* 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;
|
return;
|
||||||
}
|
|
||||||
|
|
||||||
RetroShareLink link = RetroShareLink::createUnknwonSslCertificate(sslId, gpgId);
|
// PGPId+SslId are always here. But if the peer is not a friend the SSL id cannot be used.
|
||||||
if (link.valid() == false) {
|
// (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;
|
return;
|
||||||
}
|
|
||||||
|
|
||||||
QString title = QString("%1 %2").arg(link.name(), tr("wants to be friends with you on RetroShare"));
|
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 QString recommendMessage();
|
||||||
static void recommendFriend(const std::set <RsPeerId> &sslIds, const RsPeerId &to = RsPeerId(), const QString &msg = "", bool autoSend = false);
|
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);
|
static void sendInvite(const RsGxsId &to, bool autoSend);
|
||||||
#ifdef UNUSED_CODE
|
#ifdef UNUSED_CODE
|
||||||
static void sendChannelPublishKey(RsGxsChannelGroup &group);
|
static void sendChannelPublishKey(RsGxsChannelGroup &group);
|
||||||
|
@ -422,6 +422,7 @@ void NotifyQt::notifyPeerStatusChangedSummary()
|
|||||||
emit peerStatusChangedSummary();
|
emit peerStatusChangedSummary();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef TO_REMOVE
|
||||||
void NotifyQt::notifyGxsChange(const RsGxsChanges& changes)
|
void NotifyQt::notifyGxsChange(const RsGxsChanges& changes)
|
||||||
{
|
{
|
||||||
{
|
{
|
||||||
@ -436,6 +437,7 @@ void NotifyQt::notifyGxsChange(const RsGxsChanges& changes)
|
|||||||
|
|
||||||
emit gxsChange(changes);
|
emit gxsChange(changes);
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
void NotifyQt::notifyOwnStatusMessageChanged()
|
void NotifyQt::notifyOwnStatusMessageChanged()
|
||||||
{
|
{
|
||||||
@ -492,20 +494,6 @@ void NotifyQt::notifyChatLobbyTimeShift(int shift)
|
|||||||
emit chatLobbyTimeShift(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*/)
|
void NotifyQt::handleChatLobbyTimeShift(int /*shift*/)
|
||||||
{
|
{
|
||||||
return ; // we say nothing. The help dialog of lobbies explains this already.
|
return ; // we say nothing. The help dialog of lobbies explains this already.
|
||||||
@ -750,27 +738,6 @@ void NotifyQt::notifyListChange(int list, int type)
|
|||||||
return;
|
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*/)
|
void NotifyQt::notifyListPreChange(int list, int /*type*/)
|
||||||
{
|
{
|
||||||
{
|
{
|
||||||
|
@ -56,12 +56,10 @@ class NotifyQt: public QObject, public NotifyClient
|
|||||||
static bool isAllDisable();
|
static bool isAllDisable();
|
||||||
void enable() ;
|
void enable() ;
|
||||||
|
|
||||||
virtual ~NotifyQt() { return; }
|
virtual ~NotifyQt() = default;
|
||||||
|
|
||||||
void setNetworkDialog(NetworkDialog *c) { cDialog = c; }
|
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 notifyListPreChange(int list, int type);
|
||||||
virtual void notifyListChange(int list, int type);
|
virtual void notifyListChange(int list, int type);
|
||||||
virtual void notifyErrorMsg(int list, int sev, std::string msg);
|
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 notifyOwnAvatarChanged() ;
|
||||||
virtual void notifyChatLobbyEvent(uint64_t /* lobby id */, uint32_t /* event type */, const RsGxsId & /*nickname*/, const std::string& /* any string */) ;
|
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) ;
|
virtual void notifyChatLobbyTimeShift(int time_shift) ;
|
||||||
void notifyConnectionWithoutCert();
|
|
||||||
|
|
||||||
virtual void notifyOwnStatusMessageChanged() ;
|
virtual void notifyOwnStatusMessageChanged() ;
|
||||||
virtual void notifyDiskFull(uint32_t loc,uint32_t size_in_mb) ;
|
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 */
|
/* one or more peers has changed the states */
|
||||||
virtual void notifyPeerStatusChangedSummary();
|
virtual void notifyPeerStatusChangedSummary();
|
||||||
|
|
||||||
virtual void notifyGxsChange(const RsGxsChanges& change);
|
|
||||||
|
|
||||||
virtual void notifyHistoryChanged(uint32_t msgId, int type);
|
virtual void notifyHistoryChanged(uint32_t msgId, int type);
|
||||||
|
|
||||||
virtual void notifyDiscInfoChanged() ;
|
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
|
// It's beneficial to send info to the GUI using signals, because signals are thread-safe
|
||||||
// as they get queued by Qt.
|
// as they get queued by Qt.
|
||||||
//
|
//
|
||||||
void peerConnected(const QString&) const ;
|
|
||||||
void peerDisconnected(const QString&) const ;
|
|
||||||
void hashingInfoChanged(const QString&) const ;
|
void hashingInfoChanged(const QString&) const ;
|
||||||
void filesPreModChanged(bool) const ;
|
void filesPreModChanged(bool) const ;
|
||||||
void filesPostModChanged(bool) const ;
|
void filesPostModChanged(bool) const ;
|
||||||
|
@ -37,7 +37,14 @@ QMap<RsGxsIfaceHelper*, RsGxsUpdateBroadcast*> updateBroadcastMap;
|
|||||||
RsGxsUpdateBroadcast::RsGxsUpdateBroadcast(RsGxsIfaceHelper *ifaceImpl) :
|
RsGxsUpdateBroadcast::RsGxsUpdateBroadcast(RsGxsIfaceHelper *ifaceImpl) :
|
||||||
QObject(NULL), mIfaceImpl(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()
|
void RsGxsUpdateBroadcast::cleanup()
|
||||||
|
@ -24,6 +24,7 @@
|
|||||||
#include <QObject>
|
#include <QObject>
|
||||||
|
|
||||||
#include <retroshare/rsgxsifacetypes.h>
|
#include <retroshare/rsgxsifacetypes.h>
|
||||||
|
#include <retroshare/rsevents.h>
|
||||||
|
|
||||||
struct RsGxsIfaceHelper;
|
struct RsGxsIfaceHelper;
|
||||||
struct RsGxsChanges;
|
struct RsGxsChanges;
|
||||||
@ -53,6 +54,7 @@ private:
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
RsGxsIfaceHelper* mIfaceImpl;
|
RsGxsIfaceHelper* mIfaceImpl;
|
||||||
|
RsEventsHandlerId_t mEventHandlerId ;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // RSGXSUPDATEBROADCAST_H
|
#endif // RSGXSUPDATEBROADCAST_H
|
||||||
|
@ -34,7 +34,7 @@ TokenQueue::TokenQueue(RsTokenService *service, TokenResponse *resp)
|
|||||||
{
|
{
|
||||||
mTrigger = new RsProtectedTimer(this);
|
mTrigger = new RsProtectedTimer(this);
|
||||||
mTrigger->setSingleShot(true);
|
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)
|
bool TokenQueue::requestGroupInfo(uint32_t &token, uint32_t anstype, const RsTokReqOptions &opts, std::list<RsGxsGroupId>& ids, uint32_t usertype)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user