Merge pull request #2106 from csoler/v0.6-BugFixing_2

[WIP] Continue fixing 0.6.6 bugs
This commit is contained in:
csoler 2020-11-15 20:04:20 +01:00 committed by GitHub
commit 509f89cb59
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
32 changed files with 1548 additions and 1280 deletions

View file

@ -1082,7 +1082,15 @@ bool p3NetMgrIMPL::checkNetAddress()
{ {
RsInfo() << __PRETTY_FUNCTION__ << " local address changed, resetting" RsInfo() << __PRETTY_FUNCTION__ << " local address changed, resetting"
<<" network." << std::endl; <<" network." << std::endl;
if(rsEvents)
{
auto ev = std::make_shared<RsNetworkEvent>();
ev->mNetworkEventCode = RsNetworkEventCode::LOCAL_IP_UPDATED;
ev->mIPAddress = sockaddr_storage_iptostring(mLocalAddr);
rsEvents->postEvent(ev);
}
if (mPeerMgr) mPeerMgr->UpdateOwnAddress(mLocalAddr, mExtAddr); if (mPeerMgr) mPeerMgr->UpdateOwnAddress(mLocalAddr, mExtAddr);
netReset(); netReset();
@ -1123,7 +1131,7 @@ bool p3NetMgrIMPL::setLocalAddress(const struct sockaddr_storage &addr)
#ifdef NETMGR_DEBUG_RESET #ifdef NETMGR_DEBUG_RESET
std::cerr << "p3NetMgrIMPL::setLocalAddress() Calling NetReset" << std::endl; std::cerr << "p3NetMgrIMPL::setLocalAddress() Calling NetReset" << std::endl;
#endif #endif
rslog(RSL_WARNING, p3netmgrzone, "p3NetMgr::setLocalAddress() local address changed, resetting network"); rslog(RSL_WARNING, p3netmgrzone, "p3NetMgr::setLocalAddress() local address changed, resetting network");
netReset(); netReset();
} }
return true; return true;
@ -1159,6 +1167,15 @@ bool p3NetMgrIMPL::setExtAddress(const struct sockaddr_storage &addr)
#ifdef NETMGR_DEBUG_RESET #ifdef NETMGR_DEBUG_RESET
std::cerr << "p3NetMgrIMPL::setExtAddress() Calling NetReset" << std::endl; std::cerr << "p3NetMgrIMPL::setExtAddress() Calling NetReset" << std::endl;
#endif #endif
if(rsEvents)
{
auto ev = std::make_shared<RsNetworkEvent>();
ev->mNetworkEventCode = RsNetworkEventCode::EXTERNAL_IP_UPDATED;
ev->mIPAddress = sockaddr_storage_iptostring(addr);
rsEvents->postEvent(ev);
}
rslog(RSL_WARNING, p3netmgrzone, "p3NetMgr::setExtAddress() ext address changed, resetting network"); rslog(RSL_WARNING, p3netmgrzone, "p3NetMgr::setExtAddress() ext address changed, resetting network");
netReset(); netReset();
} }

View file

@ -317,7 +317,7 @@ void p3PeerMgrIMPL::tick()
const RsPeerId& p3PeerMgrIMPL::getOwnId() const RsPeerId& p3PeerMgrIMPL::getOwnId()
{ {
return AuthSSL::getAuthSSL()->OwnId(); return AuthSSL::getAuthSSL()->OwnId();
} }
@ -1471,7 +1471,7 @@ bool p3PeerMgrIMPL::UpdateOwnAddress( const sockaddr_storage& pLocalAddr,
} }
sockaddr_storage_copy(localAddr, mOwnState.localaddr); sockaddr_storage_copy(localAddr, mOwnState.localaddr);
} }
{ {
@ -1646,7 +1646,7 @@ bool p3PeerMgrIMPL::setExtAddress( const RsPeerId &id,
{ {
mOwnState.serveraddr = addr; mOwnState.serveraddr = addr;
changed = true; changed = true;
} }
} }
mNetMgr->setExtAddress(addr); mNetMgr->setExtAddress(addr);
@ -1660,7 +1660,7 @@ bool p3PeerMgrIMPL::setExtAddress( const RsPeerId &id,
if (mFriendList.end() == (it = mFriendList.find(id))) if (mFriendList.end() == (it = mFriendList.find(id)))
{ {
#ifdef PEER_DEBUG #ifdef PEER_DEBUG
std::cerr << "p3PeerMgrIMPL::setLocalAddress() cannot add addres " << "info : peer id not found in friend list id: " << id << std::endl; std::cerr << "p3PeerMgrIMPL::setExtAddress() cannot add addres " << "info : peer id not found in friend list id: " << id << std::endl;
#endif #endif
return false; return false;
} }

View file

@ -100,6 +100,9 @@ enum class RsEventType : uint32_t
/// @see RsMsgs /// @see RsMsgs
CHAT_MESSAGE = 15, CHAT_MESSAGE = 15,
/// @see rspeers.h
NETWORK = 16,
__MAX /// Used internally, keep last __MAX /// Used internally, keep last
}; };

View file

@ -299,6 +299,32 @@ struct RsConnectionEvent : RsEvent
~RsConnectionEvent() override; ~RsConnectionEvent() override;
}; };
enum class RsNetworkEventCode: uint8_t {
UNKNOWN = 0x00,
LOCAL_IP_UPDATED = 0x01,
EXTERNAL_IP_UPDATED = 0x02,
};
struct RsNetworkEvent : RsEvent
{
RsNetworkEvent()
: RsEvent(RsEventType::NETWORK),
mNetworkEventCode(RsNetworkEventCode::UNKNOWN){}
RsNetworkEventCode mNetworkEventCode;
std::string mIPAddress; // local or external IP depending on the event type
///* @see RsEvent @see RsSerializable
void serial_process(
RsGenericSerializer::SerializeJob j,
RsGenericSerializer::SerializeContext& ctx ) override
{
RsEvent::serial_process(j, ctx);
RS_SERIAL_PROCESS(mNetworkEventCode);
RS_SERIAL_PROCESS(mIPAddress);
}
};
//===================================================================================================// //===================================================================================================//
// Peer Details // // Peer Details //
//===================================================================================================// //===================================================================================================//
@ -483,6 +509,16 @@ struct RsPeerStateChangedEvent : RsEvent
} }
}; };
enum class RetroshareInviteFlags:uint32_t {
NOTHING = 0x00,
CURRENT_IP = 0x01,
FULL_IP_HISTORY = 0x02,
DNS = 0x04,
RADIX_FORMAT = 0x08,
PGP_SIGNATURES = 0x10,
};
RS_REGISTER_ENUM_FLAGS_TYPE(RetroshareInviteFlags)
/** The Main Interface Class - for information about your Peers /** The Main Interface Class - for information about your Peers
* A peer is another RS instance, means associated with an SSL certificate * A peer is another RS instance, means associated with an SSL certificate
* A same GPG person can have multiple peer running with different SSL certs * A same GPG person can have multiple peer running with different SSL certs
@ -492,6 +528,7 @@ struct RsPeerStateChangedEvent : RsEvent
class RsPeers class RsPeers
{ {
public: public:
/** /**
* @brief Get own SSL peer id * @brief Get own SSL peer id
* @return own peer id * @return own peer id
@ -766,8 +803,7 @@ public:
*/ */
virtual std::string GetRetroshareInvite( virtual std::string GetRetroshareInvite(
const RsPeerId& sslId = RsPeerId(), const RsPeerId& sslId = RsPeerId(),
bool includeSignatures = false, RetroshareInviteFlags = RetroshareInviteFlags::DNS | RetroshareInviteFlags::CURRENT_IP ) = 0;
bool includeExtraLocators = true ) = 0;
/** /**
* @brief Get RetroShare short invite of the given peer * @brief Get RetroShare short invite of the given peer
@ -785,9 +821,8 @@ public:
* "normal" looking web link. Used only if formatRadix is false. * "normal" looking web link. Used only if formatRadix is false.
* @return false if error occurred, true otherwise * @return false if error occurred, true otherwise
*/ */
virtual bool getShortInvite( virtual bool getShortInvite(std::string& invite, const RsPeerId& sslId = RsPeerId(),
std::string& invite, const RsPeerId& sslId = RsPeerId(), RetroshareInviteFlags locator_flags = RetroshareInviteFlags::CURRENT_IP | RetroshareInviteFlags::DNS,
bool formatRadix = false, bool bareBones = false,
const std::string& baseUrl = "https://retroshare.me/" ) = 0; const std::string& baseUrl = "https://retroshare.me/" ) = 0;
/** /**

View file

@ -1189,9 +1189,7 @@ static void addPacketHeader(RsShortInviteFieldType ptag, size_t size, unsigned c
offset += PGPKeyParser::write_125Size(&buf[offset],size) ; offset += PGPKeyParser::write_125Size(&buf[offset],size) ;
} }
bool p3Peers::getShortInvite( bool p3Peers::getShortInvite(std::string& invite, const RsPeerId& _sslId, RetroshareInviteFlags invite_flags, const std::string& baseUrl )
std::string& invite, const RsPeerId& _sslId, bool formatRadix,
bool bareBones, const std::string& baseUrl )
{ {
RsPeerId sslId = _sslId; RsPeerId sslId = _sslId;
if(sslId.isNull()) sslId = getOwnId(); if(sslId.isNull()) sslId = getOwnId();
@ -1213,71 +1211,68 @@ bool p3Peers::getShortInvite(
memcpy(&buf[offset],tDetails.name.c_str(),tDetails.name.size()); memcpy(&buf[offset],tDetails.name.c_str(),tDetails.name.size());
offset += tDetails.name.size(); offset += tDetails.name.size();
if(!bareBones) /* If it is a hidden node, always use hidden address and port as locator */
{ sockaddr_storage tExt;
/* If is hidden use hidden address and port as locator, else if we have if(tDetails.isHiddenNode)
* a valid dyndns and extPort use that as locator, else if we have a {
* valid extAddr and extPort use that as locator, otherwise use most addPacketHeader(RsShortInviteFieldType::HIDDEN_LOCATOR,4 + 2 + tDetails.hiddenNodeAddress.size(),buf,offset,buf_size);
* recently known locator */
sockaddr_storage tExt;
if(tDetails.isHiddenNode)
{
addPacketHeader(RsShortInviteFieldType::HIDDEN_LOCATOR,4 + 2 + tDetails.hiddenNodeAddress.size(),buf,offset,buf_size);
buf[offset+0] = (uint8_t)((tDetails.hiddenType >> 24) & 0xff); buf[offset+0] = (uint8_t)((tDetails.hiddenType >> 24) & 0xff);
buf[offset+1] = (uint8_t)((tDetails.hiddenType >> 16) & 0xff); buf[offset+1] = (uint8_t)((tDetails.hiddenType >> 16) & 0xff);
buf[offset+2] = (uint8_t)((tDetails.hiddenType >> 8) & 0xff); buf[offset+2] = (uint8_t)((tDetails.hiddenType >> 8) & 0xff);
buf[offset+3] = (uint8_t)((tDetails.hiddenType ) & 0xff); buf[offset+3] = (uint8_t)((tDetails.hiddenType ) & 0xff);
buf[offset+4] = (uint8_t)((tDetails.hiddenNodePort >> 8) & 0xff); buf[offset+4] = (uint8_t)((tDetails.hiddenNodePort >> 8) & 0xff);
buf[offset+5] = (uint8_t)((tDetails.hiddenNodePort ) & 0xff); buf[offset+5] = (uint8_t)((tDetails.hiddenNodePort ) & 0xff);
memcpy(&buf[offset+6],tDetails.hiddenNodeAddress.c_str(),tDetails.hiddenNodeAddress.size()); memcpy(&buf[offset+6],tDetails.hiddenNodeAddress.c_str(),tDetails.hiddenNodeAddress.size());
offset += 4 + 2 + tDetails.hiddenNodeAddress.size(); offset += 4 + 2 + tDetails.hiddenNodeAddress.size();
} }
else if( !tDetails.dyndns.empty() && (tDetails.extPort || tDetails.localPort) )
{
uint16_t tPort = tDetails.extPort ? tDetails.extPort : tDetails.localPort;
addPacketHeader(RsShortInviteFieldType::DNS_LOCATOR, 2 + tDetails.dyndns.size(),buf,offset,buf_size); if( !!(invite_flags & RetroshareInviteFlags::DNS) && !tDetails.dyndns.empty() && (tDetails.extPort || tDetails.localPort))
{
uint16_t tPort = tDetails.extPort ? tDetails.extPort : tDetails.localPort;
buf[offset+0] = (uint8_t)((tPort >> 8) & 0xff); addPacketHeader(RsShortInviteFieldType::DNS_LOCATOR, 2 + tDetails.dyndns.size(),buf,offset,buf_size);
buf[offset+1] = (uint8_t)((tPort ) & 0xff);
memcpy(&buf[offset+2],tDetails.dyndns.c_str(),tDetails.dyndns.size()); buf[offset+0] = (uint8_t)((tPort >> 8) & 0xff);
offset += 2 + tDetails.dyndns.size(); buf[offset+1] = (uint8_t)((tPort ) & 0xff);
}
else if( sockaddr_storage_inet_pton(tExt, tDetails.extAddr) &&
sockaddr_storage_isValidNet(tExt) &&
sockaddr_storage_ipv6_to_ipv4(tExt) &&
tDetails.extPort )
{
uint32_t t4Addr = reinterpret_cast<sockaddr_in&>(tExt).sin_addr.s_addr;
addPacketHeader(RsShortInviteFieldType::EXT4_LOCATOR, 4 + 2,buf,offset,buf_size); memcpy(&buf[offset+2],tDetails.dyndns.c_str(),tDetails.dyndns.size());
offset += 2 + tDetails.dyndns.size();
}
buf[offset+0] = (uint8_t)((t4Addr >> 24) & 0xff); if( !!(invite_flags & RetroshareInviteFlags::CURRENT_IP) && sockaddr_storage_inet_pton(tExt, tDetails.extAddr)
buf[offset+1] = (uint8_t)((t4Addr >> 16) & 0xff); && sockaddr_storage_isValidNet(tExt) && sockaddr_storage_ipv6_to_ipv4(tExt) && tDetails.extPort )
buf[offset+2] = (uint8_t)((t4Addr >> 8) & 0xff); {
buf[offset+3] = (uint8_t)((t4Addr ) & 0xff); uint32_t t4Addr = reinterpret_cast<sockaddr_in&>(tExt).sin_addr.s_addr;
buf[offset+4] = (uint8_t)((tDetails.extPort >> 8) & 0xff); addPacketHeader(RsShortInviteFieldType::EXT4_LOCATOR, 4 + 2,buf,offset,buf_size);
buf[offset+5] = (uint8_t)((tDetails.extPort ) & 0xff);
offset += 4+2; buf[offset+0] = (uint8_t)((t4Addr >> 24) & 0xff);
} buf[offset+1] = (uint8_t)((t4Addr >> 16) & 0xff);
else if(!tDetails.ipAddressList.empty()) buf[offset+2] = (uint8_t)((t4Addr >> 8) & 0xff);
{ buf[offset+3] = (uint8_t)((t4Addr ) & 0xff);
const std::string& tLc = tDetails.ipAddressList.front();
std::string tLocator = tLc.substr(0, tLc.find_first_of(" ")-1);
addPacketHeader(RsShortInviteFieldType::LOCATOR, tLocator.size(),buf,offset,buf_size); buf[offset+4] = (uint8_t)((tDetails.extPort >> 8) & 0xff);
buf[offset+5] = (uint8_t)((tDetails.extPort ) & 0xff);
offset += 4+2;
}
if( !!(invite_flags & RetroshareInviteFlags::FULL_IP_HISTORY) && (!tDetails.ipAddressList.empty()))
for(auto& s: tDetails.ipAddressList)
{
const std::string& tLc = s;
std::string tLocator = tLc.substr(0, tLc.find_first_of(" ")-1);
addPacketHeader(RsShortInviteFieldType::LOCATOR, tLocator.size(),buf,offset,buf_size);
memcpy(&buf[offset],tLocator.c_str(),tLocator.size()); memcpy(&buf[offset],tLocator.c_str(),tLocator.size());
offset += tLocator.size(); offset += tLocator.size();
} }
}
uint32_t computed_crc = PGPKeyManagement::compute24bitsCRC(buf,offset) ; uint32_t computed_crc = PGPKeyManagement::compute24bitsCRC(buf,offset) ;
// handle endian issues. // handle endian issues.
unsigned char mem[3] ; unsigned char mem[3] ;
@ -1291,7 +1286,7 @@ bool p3Peers::getShortInvite(
Radix64::encode(buf, static_cast<int>(offset), invite); Radix64::encode(buf, static_cast<int>(offset), invite);
if(!formatRadix) if(!(invite_flags & RetroshareInviteFlags::RADIX_FORMAT))
{ {
RsUrl inviteUrl(baseUrl); RsUrl inviteUrl(baseUrl);
inviteUrl.setQueryKV("rsInvite", invite); inviteUrl.setQueryKV("rsInvite", invite);
@ -1523,9 +1518,7 @@ bool p3Peers::acceptInvite( const std::string& invite,
return true; return true;
} }
std::string p3Peers::GetRetroshareInvite( std::string p3Peers::GetRetroshareInvite( const RsPeerId& sslId, RetroshareInviteFlags invite_flags)
const RsPeerId& sslId, bool include_signatures,
bool includeExtraLocators )
{ {
#ifdef P3PEERS_DEBUG #ifdef P3PEERS_DEBUG
std::cerr << __PRETTY_FUNCTION__ << std::endl; std::cerr << __PRETTY_FUNCTION__ << std::endl;
@ -1538,14 +1531,13 @@ std::string p3Peers::GetRetroshareInvite(
if (getPeerDetails(ssl_id, detail)) if (getPeerDetails(ssl_id, detail))
{ {
if(!includeExtraLocators && !detail.isHiddenNode) detail.ipAddressList.clear(); if(!(invite_flags & RetroshareInviteFlags::FULL_IP_HISTORY) || detail.isHiddenNode)
detail.ipAddressList.clear();
unsigned char *mem_block = nullptr; unsigned char *mem_block = nullptr;
size_t mem_block_size = 0; size_t mem_block_size = 0;
if(!AuthGPG::getAuthGPG()->exportPublicKey( if(!AuthGPG::getAuthGPG()->exportPublicKey( RsPgpId(detail.gpg_id), mem_block, mem_block_size, false, !!(invite_flags & RetroshareInviteFlags::PGP_SIGNATURES) ))
RsPgpId(detail.gpg_id), mem_block, mem_block_size, false,
include_signatures ))
{ {
std::cerr << "Cannot output certificate for id \"" << detail.gpg_id std::cerr << "Cannot output certificate for id \"" << detail.gpg_id
<< "\". Sorry." << std::endl; << "\". Sorry." << std::endl;

View file

@ -52,54 +52,54 @@ public:
virtual bool OthersChanged(); virtual bool OthersChanged();
/* Peer Details (Net & Auth) */ /* Peer Details (Net & Auth) */
virtual const RsPeerId& getOwnId(); virtual const RsPeerId& getOwnId() override;
virtual bool haveSecretKey(const RsPgpId& gpg_id) ; virtual bool haveSecretKey(const RsPgpId& gpg_id) override;
virtual bool getOnlineList(std::list<RsPeerId> &ids); virtual bool getOnlineList(std::list<RsPeerId> &ids) override;
virtual bool getFriendList(std::list<RsPeerId> &ids); virtual bool getFriendList(std::list<RsPeerId> &ids) override;
virtual bool getPeersCount( virtual bool getPeersCount(
uint32_t& peersCount, uint32_t& onlinePeersCount, uint32_t& peersCount, uint32_t& onlinePeersCount,
bool countLocations ); bool countLocations ) override;
RS_DEPRECATED RS_DEPRECATED
virtual bool getPeerCount (unsigned int *friendCount, unsigned int *onlineCount, bool ssl); virtual bool getPeerCount (unsigned int *friendCount, unsigned int *onlineCount, bool ssl) override;
virtual bool isOnline(const RsPeerId &id); virtual bool isOnline(const RsPeerId &id) override;
virtual bool isFriend(const RsPeerId &id); virtual bool isFriend(const RsPeerId &id) override;
virtual bool isPgpFriend(const RsPgpId& pgpId); virtual bool isPgpFriend(const RsPgpId& pgpId) override;
/// @see RsPeers /// @see RsPeers
bool isSslOnlyFriend(const RsPeerId& sslId) override; bool isSslOnlyFriend(const RsPeerId& sslId) override;
RS_DEPRECATED_FOR(isPgpFriend) RS_DEPRECATED_FOR(isPgpFriend)
virtual bool isGPGAccepted(const RsPgpId &gpg_id_is_friend); virtual bool isGPGAccepted(const RsPgpId &gpg_id_is_friend) override;
virtual std::string getGPGName(const RsPgpId &gpg_id); virtual std::string getGPGName(const RsPgpId &gpg_id) override;
virtual std::string getPeerName(const RsPeerId& ssl_or_gpg_id); virtual std::string getPeerName(const RsPeerId& ssl_or_gpg_id) override;
virtual bool getPeerDetails(const RsPeerId& ssl_or_gpg_id, RsPeerDetails &d); virtual bool getPeerDetails(const RsPeerId& ssl_or_gpg_id, RsPeerDetails &d) override;
/* Using PGP Ids */ /* Using PGP Ids */
virtual const RsPgpId& getGPGOwnId(); virtual const RsPgpId& getGPGOwnId() override;
virtual RsPgpId getGPGId(const RsPeerId &ssl_id); virtual RsPgpId getGPGId(const RsPeerId &ssl_id) override;
virtual bool isKeySupported(const RsPgpId& ids); virtual bool isKeySupported(const RsPgpId& ids) override;
/// @see RsPeers /// @see RsPeers
bool getPgpFriendList(std::vector<RsPgpId>& pgpIds) override; bool getPgpFriendList(std::vector<RsPgpId>& pgpIds) override;
RS_DEPRECATED_FOR(getPgpFriendList) RS_DEPRECATED_FOR(getPgpFriendList)
virtual bool getGPGAcceptedList(std::list<RsPgpId> &ids); virtual bool getGPGAcceptedList(std::list<RsPgpId> &ids) override;
virtual bool getGPGSignedList(std::list<RsPgpId> &ids); virtual bool getGPGSignedList(std::list<RsPgpId> &ids) override;
virtual bool getGPGValidList(std::list<RsPgpId> &ids); virtual bool getGPGValidList(std::list<RsPgpId> &ids) override;
virtual bool getGPGAllList(std::list<RsPgpId> &ids); virtual bool getGPGAllList(std::list<RsPgpId> &ids) override;
virtual bool getGPGDetails(const RsPgpId &id, RsPeerDetails &d); virtual bool getGPGDetails(const RsPgpId &id, RsPeerDetails &d) override;
virtual bool getAssociatedSSLIds(const RsPgpId& gpg_id, std::list<RsPeerId> &ids); virtual bool getAssociatedSSLIds(const RsPgpId& gpg_id, std::list<RsPeerId> &ids) override;
virtual bool gpgSignData(const void *data, const uint32_t len, unsigned char *sign, unsigned int *signlen, std::string reason = "") ; virtual bool gpgSignData(const void *data, const uint32_t len, unsigned char *sign, unsigned int *signlen, std::string reason = "") override;
virtual RsPgpId pgpIdFromFingerprint(const RsPgpFingerprint& fpr) override; virtual RsPgpId pgpIdFromFingerprint(const RsPgpFingerprint& fpr) override;
/* Add/Remove Friends */ /* Add/Remove Friends */
virtual bool addFriend(const RsPeerId &ssl_id, const RsPgpId &gpg_id,ServicePermissionFlags flags = RS_NODE_PERM_DEFAULT); virtual bool addFriend(const RsPeerId &ssl_id, const RsPgpId &gpg_id,ServicePermissionFlags flags = RS_NODE_PERM_DEFAULT) override;
/// @see RsPeers /// @see RsPeers
bool addSslOnlyFriend( bool addSslOnlyFriend(
@ -107,50 +107,48 @@ public:
const RsPgpId& pgp_id, const RsPgpId& pgp_id,
const RsPeerDetails& details = RsPeerDetails() ) override; const RsPeerDetails& details = RsPeerDetails() ) override;
virtual bool removeFriend(const RsPgpId& gpgid); virtual bool removeFriend(const RsPgpId& gpgid) override;
virtual bool removeFriendLocation(const RsPeerId& sslId); virtual bool removeFriendLocation(const RsPeerId& sslId) override;
/* keyring management */ /* keyring management */
virtual bool removeKeysFromPGPKeyring(const std::set<RsPgpId> &pgp_ids,std::string& backup_file,uint32_t& error_code); virtual bool removeKeysFromPGPKeyring(const std::set<RsPgpId> &pgp_ids,std::string& backup_file,uint32_t& error_code) override;
/* Network Stuff */ /* Network Stuff */
virtual bool connectAttempt(const RsPeerId &id); virtual bool connectAttempt(const RsPeerId &id) override;
virtual bool setLocation(const RsPeerId &ssl_id, const std::string &location);//location is shown in the gui to differentiate ssl certs virtual bool setLocation(const RsPeerId &ssl_id, const std::string &location) override;//location is shown in the gui to differentiate ssl certs
virtual bool setHiddenNode(const RsPeerId &id, const std::string &hidden_node_address); virtual bool setHiddenNode(const RsPeerId &id, const std::string &hidden_node_address) override;
virtual bool setHiddenNode(const RsPeerId &id, const std::string &address, uint16_t port); virtual bool setHiddenNode(const RsPeerId &id, const std::string &address, uint16_t port) override;
virtual bool isHiddenNode(const RsPeerId &id); virtual bool isHiddenNode(const RsPeerId &id) override;
virtual bool addPeerLocator(const RsPeerId &ssl_id, const RsUrl& locator); virtual bool addPeerLocator(const RsPeerId &ssl_id, const RsUrl& locator) override;
virtual bool setLocalAddress(const RsPeerId &id, const std::string &addr, uint16_t port); virtual bool setLocalAddress(const RsPeerId &id, const std::string &addr, uint16_t port) override;
virtual bool setExtAddress(const RsPeerId &id, const std::string &addr, uint16_t port); virtual bool setExtAddress(const RsPeerId &id, const std::string &addr, uint16_t port) override;
virtual bool setDynDNS(const RsPeerId &id, const std::string &dyndns); virtual bool setDynDNS(const RsPeerId &id, const std::string &dyndns) override;
virtual bool setNetworkMode(const RsPeerId &id, uint32_t netMode); virtual bool setNetworkMode(const RsPeerId &id, uint32_t netMode) override;
virtual bool setVisState(const RsPeerId &id, uint16_t vs_disc, uint16_t vs_dht); virtual bool setVisState(const RsPeerId &id, uint16_t vs_disc, uint16_t vs_dht) override;
virtual bool getProxyServer(const uint32_t type, std::string &addr, uint16_t &port,uint32_t& status); virtual bool getProxyServer(const uint32_t type, std::string &addr, uint16_t &port,uint32_t& status) override;
virtual bool setProxyServer(const uint32_t type, const std::string &addr, const uint16_t port); virtual bool setProxyServer(const uint32_t type, const std::string &addr, const uint16_t port) override;
virtual bool isProxyAddress(const uint32_t type, const sockaddr_storage &addr); virtual bool isProxyAddress(const uint32_t type, const sockaddr_storage &addr);
virtual void getIPServersList(std::list<std::string>& ip_servers); virtual void getIPServersList(std::list<std::string>& ip_servers) override;
virtual void allowServerIPDetermination(bool); virtual void allowServerIPDetermination(bool) override;
virtual bool getAllowServerIPDetermination(); virtual bool getAllowServerIPDetermination() override;
virtual bool resetOwnExternalAddressList(); virtual bool resetOwnExternalAddressList() override;
/* Auth Stuff */ /* Auth Stuff */
// Get the invitation (GPG cert + local/ext address + SSL id for the given peer) // Get the invitation (GPG cert + local/ext address + SSL id for the given peer)
virtual std::string GetRetroshareInvite( virtual std::string GetRetroshareInvite(const RsPeerId& ssl_id = RsPeerId(), RetroshareInviteFlags invite_flags = RetroshareInviteFlags::DNS | RetroshareInviteFlags::CURRENT_IP ) override;
const RsPeerId& ssl_id = RsPeerId(),
bool include_signatures = false, bool includeExtraLocators = true );
RS_DEPRECATED /// @see RsPeers RS_DEPRECATED /// @see RsPeers
std::string getPGPKey(const RsPgpId& pgp_id,bool include_signatures) override; std::string getPGPKey(const RsPgpId& pgp_id,bool include_signatures) override;
virtual bool GetPGPBase64StringAndCheckSum(const RsPgpId& gpg_id,std::string& gpg_base64_string,std::string& gpg_base64_checksum); virtual bool GetPGPBase64StringAndCheckSum(const RsPgpId& gpg_id,std::string& gpg_base64_string,std::string& gpg_base64_checksum);
/// @see RsPeers /// @see RsPeers
bool getShortInvite( bool getShortInvite(std::string& invite, const RsPeerId& sslId = RsPeerId(),
std::string& invite, const RsPeerId& sslId = RsPeerId(), RetroshareInviteFlags invite_flags = RetroshareInviteFlags::CURRENT_IP | RetroshareInviteFlags::DNS,
bool formatRadix = false, bool bareBones = false, const std::string& baseUrl = "https://retroshare.me/" ) override;
const std::string& baseUrl = "https://retroshare.me/" ) override;
/// @see RsPeers /// @see RsPeers
bool parseShortInvite(const std::string& invite, RsPeerDetails& details, uint32_t &err_code ) override; bool parseShortInvite(const std::string& invite, RsPeerDetails& details, uint32_t &err_code ) override;
@ -158,39 +156,39 @@ public:
/// @see RsPeers::acceptInvite /// @see RsPeers::acceptInvite
virtual bool acceptInvite( virtual bool acceptInvite(
const std::string& invite, const std::string& invite,
ServicePermissionFlags flags = RS_NODE_PERM_DEFAULT ); ServicePermissionFlags flags = RS_NODE_PERM_DEFAULT ) override;
virtual bool loadCertificateFromString(const std::string& cert, RsPeerId& ssl_id,RsPgpId& pgp_id, std::string& error_string); virtual bool loadCertificateFromString(const std::string& cert, RsPeerId& ssl_id,RsPgpId& pgp_id, std::string& error_string) override;
virtual bool loadPgpKeyFromBinaryData( const unsigned char *bin_key_data,uint32_t bin_key_len, RsPgpId& gpg_id, std::string& error_string ); virtual bool loadPgpKeyFromBinaryData( const unsigned char *bin_key_data,uint32_t bin_key_len, RsPgpId& gpg_id, std::string& error_string ) override;
virtual bool loadDetailsFromStringCert(const std::string &cert, RsPeerDetails &pd, uint32_t& error_code); virtual bool loadDetailsFromStringCert(const std::string &cert, RsPeerDetails &pd, uint32_t& error_code) override;
virtual bool cleanCertificate(const std::string &certstr, std::string &cleanCert, bool &is_short_format, uint32_t& error_code) override; virtual bool cleanCertificate(const std::string &certstr, std::string &cleanCert, bool &is_short_format, uint32_t& error_code) override;
virtual std::string saveCertificateToString(const RsPeerId &id); virtual std::string saveCertificateToString(const RsPeerId &id) override;
virtual bool signGPGCertificate(const RsPgpId &id); virtual bool signGPGCertificate(const RsPgpId &id) override;
virtual bool trustGPGCertificate(const RsPgpId &id, uint32_t trustlvl); virtual bool trustGPGCertificate(const RsPgpId &id, uint32_t trustlvl) override;
/* Group Stuff */ /* Group Stuff */
virtual bool addGroup(RsGroupInfo &groupInfo); virtual bool addGroup(RsGroupInfo &groupInfo) override;
virtual bool editGroup(const RsNodeGroupId &groupId, RsGroupInfo &groupInfo); virtual bool editGroup(const RsNodeGroupId &groupId, RsGroupInfo &groupInfo) override;
virtual bool removeGroup(const RsNodeGroupId &groupId); virtual bool removeGroup(const RsNodeGroupId &groupId) override;
virtual bool getGroupInfo(const RsNodeGroupId &groupId, RsGroupInfo &groupInfo); virtual bool getGroupInfo(const RsNodeGroupId &groupId, RsGroupInfo &groupInfo) override;
virtual bool getGroupInfoByName(const std::string& groupName, RsGroupInfo& groupInfo); virtual bool getGroupInfoByName(const std::string& groupName, RsGroupInfo& groupInfo) override;
virtual bool getGroupInfoList(std::list<RsGroupInfo> &groupInfoList); virtual bool getGroupInfoList(std::list<RsGroupInfo> &groupInfoList) override;
virtual bool assignPeerToGroup(const RsNodeGroupId &groupId, const RsPgpId &peerId, bool assign); virtual bool assignPeerToGroup(const RsNodeGroupId &groupId, const RsPgpId &peerId, bool assign) override;
virtual bool assignPeersToGroup(const RsNodeGroupId &groupId, const std::list<RsPgpId>& peerIds, bool assign); virtual bool assignPeersToGroup(const RsNodeGroupId &groupId, const std::list<RsPgpId>& peerIds, bool assign) override;
virtual FileSearchFlags computePeerPermissionFlags(const RsPeerId& peer_id, FileStorageFlags share_flags, const std::list<RsNodeGroupId> &parent_groups); virtual FileSearchFlags computePeerPermissionFlags(const RsPeerId& peer_id, FileStorageFlags share_flags, const std::list<RsNodeGroupId> &parent_groups) override;
// service permission stuff // service permission stuff
virtual ServicePermissionFlags servicePermissionFlags(const RsPgpId& gpg_id); virtual ServicePermissionFlags servicePermissionFlags(const RsPgpId& gpg_id) override;
virtual ServicePermissionFlags servicePermissionFlags(const RsPeerId & ssl_id); virtual ServicePermissionFlags servicePermissionFlags(const RsPeerId & ssl_id) override;
virtual void setServicePermissionFlags(const RsPgpId& gpg_id,const ServicePermissionFlags& flags); virtual void setServicePermissionFlags(const RsPgpId& gpg_id,const ServicePermissionFlags& flags) override;
virtual bool setPeerMaximumRates(const RsPgpId& pid,uint32_t maxUploadRate,uint32_t maxDownloadRate); virtual bool setPeerMaximumRates(const RsPgpId& pid,uint32_t maxUploadRate,uint32_t maxDownloadRate) override;
virtual bool getPeerMaximumRates(const RsPgpId& pid,uint32_t& maxUploadRate,uint32_t& maxDownloadRate); virtual bool getPeerMaximumRates(const RsPgpId& pid,uint32_t& maxUploadRate,uint32_t& maxDownloadRate) override;
virtual bool getPeerMaximumRates(const RsPeerId& pid,uint32_t& maxUploadRate,uint32_t& maxDownloadRate); virtual bool getPeerMaximumRates(const RsPeerId& pid,uint32_t& maxUploadRate,uint32_t& maxDownloadRate) override;
private: private:
p3LinkMgr *mLinkMgr; p3LinkMgr *mLinkMgr;

View file

@ -1400,6 +1400,7 @@ bool p3GxsCircles::cache_load_for_token(uint32_t token)
std::cerr << " Unprocessed peers. Requesting reload..." << std::endl; std::cerr << " Unprocessed peers. Requesting reload..." << std::endl;
#endif #endif
cache.mAllIdsHere = false; cache.mAllIdsHere = false;
cache.mStatus = CircleEntryCacheStatus::UPDATING;
/* schedule event to try reload gxsIds */ /* schedule event to try reload gxsIds */
RsTickEvent::schedule_in(CIRCLE_EVENT_RELOADIDS, GXSID_LOAD_CYCLE, id.toStdString()); RsTickEvent::schedule_in(CIRCLE_EVENT_RELOADIDS, GXSID_LOAD_CYCLE, id.toStdString());

View file

@ -38,6 +38,7 @@
#include "util/misc.h" #include "util/misc.h"
#include "util/QtVersion.h" #include "util/QtVersion.h"
#include "util/RsFile.h" #include "util/RsFile.h"
#include "util/qtthreadsutils.h"
#include "retroshare/rsdisc.h" #include "retroshare/rsdisc.h"
#include "retroshare/rsfiles.h" #include "retroshare/rsfiles.h"
@ -1098,12 +1099,11 @@ TransfersDialog::TransfersDialog(QWidget *parent)
registerHelpButton(ui.helpButton,help_str,"TransfersDialog") ; registerHelpButton(ui.helpButton,help_str,"TransfersDialog") ;
mEventHandlerId=0; mEventHandlerId=0;
rsEvents->registerEventsHandler( // Do the GUI events in the GUI thread!
[this](std::shared_ptr<const RsEvent> event) { handleEvent(event); }, rsEvents->registerEventsHandler( [this](std::shared_ptr<const RsEvent> event) { RsQThreadUtils::postToObject( [this,event]() { handleEvent_main_thread(event); }) ;}, mEventHandlerId, RsEventType::FILE_TRANSFER );
mEventHandlerId, RsEventType::FILE_TRANSFER );
} }
void TransfersDialog::handleEvent(std::shared_ptr<const RsEvent> event) void TransfersDialog::handleEvent_main_thread(std::shared_ptr<const RsEvent> event)
{ {
if(event->mType != RsEventType::FILE_TRANSFER) return; if(event->mType != RsEventType::FILE_TRANSFER) return;
@ -1115,6 +1115,7 @@ void TransfersDialog::handleEvent(std::shared_ptr<const RsEvent> event)
{ {
case RsFileTransferEventCode::DOWNLOAD_COMPLETE: case RsFileTransferEventCode::DOWNLOAD_COMPLETE:
case RsFileTransferEventCode::COMPLETED_FILES_REMOVED: case RsFileTransferEventCode::COMPLETED_FILES_REMOVED:
getUserNotify()->updateIcon(); getUserNotify()->updateIcon();
default: default:
break; break;

View file

@ -260,7 +260,7 @@ private:
bool controlTransferFile(uint32_t flags); bool controlTransferFile(uint32_t flags);
void changePriority(int priority); void changePriority(int priority);
void setChunkStrategy(FileChunksInfo::ChunkStrategy s) ; void setChunkStrategy(FileChunksInfo::ChunkStrategy s) ;
void handleEvent(std::shared_ptr<const RsEvent> event); void handleEvent_main_thread(std::shared_ptr<const RsEvent> event);
QTreeView *downloadList; QTreeView *downloadList;

View file

@ -235,7 +235,7 @@ void GetStartedDialog::inviteFriends()
{ {
RsAutoUpdatePage::lockAllEvents(); RsAutoUpdatePage::lockAllEvents();
cert = rsPeers->GetRetroshareInvite(RsPeerId(),false,false); cert = rsPeers->GetRetroshareInvite(RsPeerId(),RetroshareInviteFlags::DNS | RetroshareInviteFlags::CURRENT_IP | RetroshareInviteFlags::FULL_IP_HISTORY);
RsAutoUpdatePage::unlockAllEvents() ; RsAutoUpdatePage::unlockAllEvents() ;
} }

View file

@ -23,6 +23,8 @@
#include "retroshare/rsinit.h" #include "retroshare/rsinit.h"
#include "util/qtthreadsutils.h"
#include "gui/notifyqt.h" #include "gui/notifyqt.h"
#include "gui/msgs/MessageComposer.h" #include "gui/msgs/MessageComposer.h"
#include "gui/connect/ConnectFriendWizard.h" #include "gui/connect/ConnectFriendWizard.h"
@ -49,8 +51,7 @@ HomePage::HomePage(QWidget *parent) :
MainPage(parent), MainPage(parent),
ui(new Ui::HomePage), ui(new Ui::HomePage),
mIncludeAllIPs(false), mIncludeAllIPs(false),
mUseShortFormat(false), mUseShortFormat(true)
mUseBackwardCompatibleCert(false)
{ {
ui->setupUi(this); ui->setupUi(this);
@ -86,7 +87,7 @@ HomePage::HomePage(QWidget *parent) :
useOldFormatAct->setToolTip(tr("Displays the certificate format used up to version 0.6.5\nOld Retroshare nodes will not understand the\nnew short format")); useOldFormatAct->setToolTip(tr("Displays the certificate format used up to version 0.6.5\nOld Retroshare nodes will not understand the\nnew short format"));
connect(useOldFormatAct, SIGNAL(triggered()), this, SLOT(toggleUseOldFormat())); connect(useOldFormatAct, SIGNAL(triggered()), this, SLOT(toggleUseOldFormat()));
useOldFormatAct->setCheckable(true); useOldFormatAct->setCheckable(true);
useOldFormatAct->setChecked(mUseBackwardCompatibleCert); useOldFormatAct->setChecked(!mUseShortFormat);
menu->addAction(useOldFormatAct); menu->addAction(useOldFormatAct);
menu->addSeparator(); menu->addSeparator();
@ -96,27 +97,53 @@ HomePage::HomePage(QWidget *parent) :
ui->shareButton->setMenu(menu); ui->shareButton->setMenu(menu);
QObject::connect(ui->userCertEdit,SIGNAL(customContextMenuRequested(QPoint)),this,SLOT(certContextMenu(QPoint)));
connect(ui->openwebhelp,SIGNAL(clicked()), this,SLOT(openWebHelp())) ; connect(ui->openwebhelp,SIGNAL(clicked()), this,SLOT(openWebHelp())) ;
ui->userCertEdit->hide();
int S = QFontMetricsF(font()).height(); int S = QFontMetricsF(font()).height();
QString help_str = tr( QString help_str = tr(
" <h1><img width=\"%1\" src=\":/icons/help_64.png\">&nbsp;&nbsp;Welcome to Retroshare!</h1>\ " <h1><img width=\"%1\" src=\":/icons/help_64.png\">&nbsp;&nbsp;Welcome to Retroshare!</h1>\
<p>You need to <b>make friends</b>! After you create a network of friends or join an existing network,\ <p>You need to <b>make friends</b>! After you create a network of friends or join an existing network,\
you'll be able to exchange files, chat, talk in forums, etc. </p>\ you'll be able to exchange files, chat, talk in forums, etc. </p>\
<div align=center>\ <div align=center>\
<IMG align=\"center\" width=\"%2\" src=\":/images/network_map.png\"/> \ <IMG align=\"center\" width=\"%2\" src=\":/images/network_map.png\"/> \
</div>\ </div>\
<p>To do so, copy your certificate on this page and send it to friends, and add your friends' certificate.</p> \ <p>To do so, copy your certificate on this page and send it to friends, and add your friends' certificate.</p> \
<p>Another option is to search the internet for \"Retroshare chat servers\" (independently administrated). These servers allow you to exchange \ <p>Another option is to search the internet for \"Retroshare chat servers\" (independently administrated). These servers allow you to exchange \
certificates with a dedicated Retroshare node, through which\ certificates with a dedicated Retroshare node, through which\
you will be able to anonymously meet other people.</p> ").arg(QString::number(2*S)).arg(width()*0.5); you will be able to anonymously meet other people.</p> ").arg(QString::number(2*S)).arg(width()*0.5);
registerHelpButton(ui->helpButton,help_str,"HomePage") ; registerHelpButton(ui->helpButton,help_str,"HomePage") ;
// register a event handler to catch IP updates
mEventHandlerId = 0;
rsEvents->registerEventsHandler( [this](std::shared_ptr<const RsEvent> event) { handleEvent(event); }, mEventHandlerId, RsEventType::NETWORK );
} }
void HomePage::handleEvent(std::shared_ptr<const RsEvent> e)
{
if(e->mType != RsEventType::NETWORK)
return;
const RsNetworkEvent *ne = dynamic_cast<const RsNetworkEvent*>(e.get());
if(!ne)
return;
// in any case we update the IPs
switch(ne->mNetworkEventCode)
{
case RsNetworkEventCode::LOCAL_IP_UPDATED: // [fallthrough]
case RsNetworkEventCode::EXTERNAL_IP_UPDATED: // [fallthrough]
RsQThreadUtils::postToObject( [=]()
{
updateCertificate();
},this);
break;
default:
break;
}
}
void HomePage::certContextMenu(QPoint point) void HomePage::certContextMenu(QPoint point)
{ {
QMenu menu(this) ; QMenu menu(this) ;
@ -168,10 +195,7 @@ HomePage::~HomePage()
void HomePage::updateCertificate() void HomePage::updateCertificate()
{ {
if(mUseBackwardCompatibleCert) updateOwnCert();
updateOwnCert();
else
updateOwnId();
} }
void HomePage::updateOwnCert() void HomePage::updateOwnCert()
@ -186,54 +210,43 @@ void HomePage::updateOwnCert()
return ; return ;
} }
std::string invite ; QString invite ;
RetroshareInviteFlags invite_flags = RetroshareInviteFlags::CURRENT_IP;
if(mIncludeAllIPs)
invite_flags |= RetroshareInviteFlags::FULL_IP_HISTORY;
if(mUseShortFormat) if(mUseShortFormat)
rsPeers->getShortInvite(invite,rsPeers->getOwnId(),true,!mIncludeAllIPs); {
else std::string short_invite;
invite = rsPeers->GetRetroshareInvite(detail.id,false,include_extra_locators); rsPeers->getShortInvite(short_invite,rsPeers->getOwnId(),invite_flags | RetroshareInviteFlags::RADIX_FORMAT);
ui->retroshareid->setText("\n"+QString::fromUtf8(invite.c_str())+"\n"); QString S;
QString txt;
for(uint32_t i=0;i<short_invite.size();)
if(S.length() < 100)
S += short_invite[i++];
else
{
txt += S + "\n";
S.clear();
}
txt += S;
invite = txt; // the "\n" is here to make some space
}
else
invite = QString::fromStdString(rsPeers->GetRetroshareInvite(detail.id,invite_flags));
ui->retroshareid->setText("\n"+invite+"\n");
QString description = ConfCertDialog::getCertificateDescription(detail,false,mUseShortFormat,include_extra_locators); QString description = ConfCertDialog::getCertificateDescription(detail,false,mUseShortFormat,include_extra_locators);
ui->retroshareid->setToolTip(description); ui->retroshareid->setToolTip(description);
} }
void HomePage::updateOwnId()
{
RsPeerDetails detail;
if (!rsPeers->getPeerDetails(rsPeers->getOwnId(), detail))
{
std::cerr << "(EE) Cannot retrieve information about own certificate. That is a real problem!!" << std::endl;
return ;
}
bool include_extra_locators = mIncludeAllIPs || detail.isHiddenNode;
std::string invite ;
rsPeers->getShortInvite(invite,rsPeers->getOwnId(),true,!include_extra_locators);
QString S;
QString txt;
int i=0;
for(uint32_t i=0;i<invite.size();)
if(S.length() < 100)
S += invite[i++];
else
{
txt += S + "\n";
S.clear();
}
txt += S;
ui->retroshareid->setText("\n"+txt+"\n"); // the "\n" is here to make some space
//#endif
// ui->retroshareid->setText(QString::fromUtf8(invite.c_str()));
}
static void sendMail(QString sAddress, QString sSubject, QString sBody) static void sendMail(QString sAddress, QString sSubject, QString sBody)
{ {
#ifdef Q_OS_WIN #ifdef Q_OS_WIN
@ -335,18 +348,6 @@ void HomePage::openWebHelp()
void HomePage::toggleUseOldFormat() void HomePage::toggleUseOldFormat()
{ {
mUseBackwardCompatibleCert = !mUseBackwardCompatibleCert; mUseShortFormat = !mUseShortFormat;
updateCertificate(); updateCertificate();
if (mUseBackwardCompatibleCert)
{
//ui->userCertEdit->show();
//ui->expandButton->setToolTip(tr("Revert to normal Retroshare ID"));
}
else
{
//ui->userCertEdit->hide();
//ui->expandButton->setToolTip(tr("Show full certificate (old format for backward compatibility)"));
}
} }

View file

@ -50,7 +50,6 @@ private slots:
void certContextMenu(QPoint); void certContextMenu(QPoint);
void updateOwnCert(); void updateOwnCert();
void updateCertificate(); void updateCertificate();
void updateOwnId();
void runEmailClient(); void runEmailClient();
void copyCert(); void copyCert();
void copyId(); void copyId();
@ -69,8 +68,10 @@ private:
bool mIncludeAllIPs; bool mIncludeAllIPs;
bool mUseShortFormat; bool mUseShortFormat;
bool mUseBackwardCompatibleCert;
RsEventsHandlerId_t mEventHandlerId;
void handleEvent(std::shared_ptr<const RsEvent> event);
}; };
#endif // HomePage_H #endif // HomePage_H

View file

@ -225,64 +225,7 @@ private and secure decentralized communication platform.
<property name="verticalSpacing"> <property name="verticalSpacing">
<number>0</number> <number>0</number>
</property> </property>
<item row="2" column="0" colspan="7"> <item row="2" column="0">
<widget class="QPlainTextEdit" name="userCertEdit">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Expanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="font">
<font>
<family>Courier New</family>
</font>
</property>
<property name="contextMenuPolicy">
<enum>Qt::CustomContextMenu</enum>
</property>
<property name="whatsThis">
<string/>
</property>
<property name="styleSheet">
<string notr="true"/>
</property>
<property name="lineWrapMode">
<enum>QPlainTextEdit::NoWrap</enum>
</property>
<property name="readOnly">
<bool>true</bool>
</property>
<property name="tabStopWidth">
<number>80</number>
</property>
<property name="centerOnScroll">
<bool>false</bool>
</property>
</widget>
</item>
<item row="0" column="0" colspan="4">
<widget class="QLabel" name="userCertLabel">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="font">
<font>
<pointsize>11</pointsize>
</font>
</property>
<property name="text">
<string>This is your Retroshare ID. Copy and share with your friends!</string>
</property>
<property name="alignment">
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter</set>
</property>
</widget>
</item>
<item row="3" column="0">
<widget class="QLabel" name="retroshareid"> <widget class="QLabel" name="retroshareid">
<property name="sizePolicy"> <property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Preferred"> <sizepolicy hsizetype="Preferred" vsizetype="Preferred">
@ -312,24 +255,7 @@ private and secure decentralized communication platform.
</property> </property>
</widget> </widget>
</item> </item>
<item row="0" column="6"> <item row="0" column="2">
<widget class="QToolButton" name="helpButton">
<property name="text">
<string>...</string>
</property>
<property name="icon">
<iconset resource="icons.qrc">
<normaloff>:/icons/help_64.png</normaloff>:/icons/help_64.png</iconset>
</property>
<property name="checkable">
<bool>true</bool>
</property>
<property name="autoRaise">
<bool>true</bool>
</property>
</widget>
</item>
<item row="0" column="5">
<widget class="QToolButton" name="shareButton"> <widget class="QToolButton" name="shareButton">
<property name="sizePolicy"> <property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed"> <sizepolicy hsizetype="Fixed" vsizetype="Fixed">
@ -361,6 +287,44 @@ private and secure decentralized communication platform.
</property> </property>
</widget> </widget>
</item> </item>
<item row="0" column="0" colspan="2">
<widget class="QLabel" name="userCertLabel">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="font">
<font>
<pointsize>11</pointsize>
</font>
</property>
<property name="text">
<string>This is your Retroshare ID. Copy and share with your friends!</string>
</property>
<property name="alignment">
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter</set>
</property>
</widget>
</item>
<item row="0" column="3">
<widget class="QToolButton" name="helpButton">
<property name="text">
<string>...</string>
</property>
<property name="icon">
<iconset resource="icons.qrc">
<normaloff>:/icons/help_64.png</normaloff>:/icons/help_64.png</iconset>
</property>
<property name="checkable">
<bool>true</bool>
</property>
<property name="autoRaise">
<bool>true</bool>
</property>
</widget>
</item>
</layout> </layout>
</item> </item>
</layout> </layout>

View file

@ -153,16 +153,10 @@ IdDialog::IdDialog(QWidget *parent) : MainPage(parent), ui(new Ui::IdDialog)
ui->setupUi(this); ui->setupUi(this);
mEventHandlerId_identity = 0; mEventHandlerId_identity = 0;
rsEvents->registerEventsHandler( rsEvents->registerEventsHandler( [this](std::shared_ptr<const RsEvent> event) { RsQThreadUtils::postToObject([=](){ handleEvent_main_thread(event); }, this); }, mEventHandlerId_identity, RsEventType::GXS_IDENTITY );
[this](std::shared_ptr<const RsEvent> event)
{ RsQThreadUtils::postToObject([=](){ handleEvent_main_thread(event); }, this); },
mEventHandlerId_identity, RsEventType::GXS_IDENTITY );
mEventHandlerId_circles = 0; mEventHandlerId_circles = 0;
rsEvents->registerEventsHandler( rsEvents->registerEventsHandler( [this](std::shared_ptr<const RsEvent> event) { RsQThreadUtils::postToObject([=](){ handleEvent_main_thread(event); }, this); }, mEventHandlerId_circles, RsEventType::GXS_CIRCLES );
[this](std::shared_ptr<const RsEvent> event)
{ RsQThreadUtils::postToObject([=](){ handleEvent_main_thread(event); }, this); },
mEventHandlerId_circles, RsEventType::GXS_CIRCLES );
// This is used to grab the broadcast of changes from p3GxsCircles, which is discarded by the current dialog, since it expects data for p3Identity only. // This is used to grab the broadcast of changes from p3GxsCircles, which is discarded by the current dialog, since it expects data for p3Identity only.
//mCirclesBroadcastBase = new RsGxsUpdateBroadcastBase(rsGxsCircles, this); //mCirclesBroadcastBase = new RsGxsUpdateBroadcastBase(rsGxsCircles, this);
@ -2387,6 +2381,10 @@ void IdDialog::sendMsg()
if(selected_items.empty()) if(selected_items.empty())
return ; return ;
if(selected_items.size() > 20)
if(QMessageBox::warning(nullptr,tr("Too many identities"),tr("<p>It is not recommended to send a message to more than 20 persons at once. Large scale diffusion of data (including friend invitations) are much more efficiently handled by forums. Click ok to proceed anyway.</p>"),QMessageBox::Ok|QMessageBox::Cancel,QMessageBox::Cancel)==QMessageBox::Cancel)
return;
MessageComposer *nMsgDialog = MessageComposer::newMsg(); MessageComposer *nMsgDialog = MessageComposer::newMsg();
if (nMsgDialog == NULL) if (nMsgDialog == NULL)
return; return;

View file

@ -566,7 +566,7 @@ RetroShareLink RetroShareLink::createCertificate(const RsPeerId& ssl_id)
} else { } else {
link._type = TYPE_CERTIFICATE; link._type = TYPE_CERTIFICATE;
link._radix = QString::fromUtf8(rsPeers->GetRetroshareInvite(ssl_id,false,false).c_str()); link._radix = QString::fromUtf8(rsPeers->GetRetroshareInvite(ssl_id).c_str());
link._name = QString::fromUtf8(detail.name.c_str()); link._name = QString::fromUtf8(detail.name.c_str());
link._location = QString::fromUtf8(detail.location.c_str()); link._location = QString::fromUtf8(detail.location.c_str());
link._radix.replace("\n",""); link._radix.replace("\n","");

View file

@ -292,6 +292,9 @@ void NewFriendList::sortColumn(int col,Qt::SortOrder so)
mProxyModel->sort(col,so); mProxyModel->sort(col,so);
mProxyModel->setSortingEnabled(false); mProxyModel->setSortingEnabled(false);
restoreExpandedPathsAndSelection(expanded_indexes, selected_indexes); restoreExpandedPathsAndSelection(expanded_indexes, selected_indexes);
mLastSortColumn = col;
mLastSortOrder = so;
} }
void NewFriendList::headerContextMenuRequested(QPoint /*p*/) void NewFriendList::headerContextMenuRequested(QPoint /*p*/)
@ -1133,6 +1136,9 @@ void NewFriendList::applyWhileKeepingTree(std::function<void()> predicate)
ui->peerTreeWidget->setColumnHidden(i,!col_visible[i]); ui->peerTreeWidget->setColumnHidden(i,!col_visible[i]);
ui->peerTreeWidget->setColumnWidth(i,col_sizes[i]); ui->peerTreeWidget->setColumnWidth(i,col_sizes[i]);
} }
// restore sorting
sortColumn(mLastSortColumn,mLastSortOrder);
} }
void NewFriendList::checkInternalData(bool force) void NewFriendList::checkInternalData(bool force)
@ -1267,7 +1273,8 @@ bool NewFriendList::exportFriendlist(QString &fileName)
if (!rsPeers->getPeerDetails(*list_iter, detailSSL)) if (!rsPeers->getPeerDetails(*list_iter, detailSSL))
continue; continue;
std::string certificate = rsPeers->GetRetroshareInvite(detailSSL.id, true,true); std::string certificate = rsPeers->GetRetroshareInvite(detailSSL.id, RetroshareInviteFlags::CURRENT_IP | RetroshareInviteFlags::DNS | RetroshareInviteFlags::RADIX_FORMAT);
// remove \n from certificate // remove \n from certificate
certificate.erase(std::remove(certificate.begin(), certificate.end(), '\n'), certificate.end()); certificate.erase(std::remove(certificate.begin(), certificate.end(), '\n'), certificate.end());

View file

@ -126,6 +126,9 @@ private:
std::set<RsNodeGroupId> openGroups; std::set<RsNodeGroupId> openGroups;
std::set<RsPgpId> openPeers; std::set<RsPgpId> openPeers;
int mLastSortColumn;
Qt::SortOrder mLastSortOrder;
bool getOrCreateGroup(const std::string& name, uint flag, RsNodeGroupId& id); bool getOrCreateGroup(const std::string& name, uint flag, RsNodeGroupId& id);
bool getGroupIdByName(const std::string& name, RsNodeGroupId& id); bool getGroupIdByName(const std::string& name, RsNodeGroupId& id);

View file

@ -275,15 +275,22 @@ void ConfCertDialog::loadInvitePage()
// ui.userCertificateText_2->setText(QString::fromUtf8(pgp_key.c_str())); // ui.userCertificateText_2->setText(QString::fromUtf8(pgp_key.c_str()));
std::string invite ; std::string invite ;
RetroshareInviteFlags flags = RetroshareInviteFlags::DNS | RetroshareInviteFlags::CURRENT_IP | RetroshareInviteFlags::RADIX_FORMAT;
if(!detail.isHiddenNode && ui._includeIPHistory_CB->isChecked())
flags |= RetroshareInviteFlags::FULL_IP_HISTORY;
if(ui._shortFormat_CB->isChecked()) if(ui._shortFormat_CB->isChecked())
{ {
rsPeers->getShortInvite(invite,detail.id,true,!(ui._includeIPHistory_CB->isChecked()|| detail.isHiddenNode) ); rsPeers->getShortInvite(invite,detail.id,flags);
ui.stabWidget->setTabText(1, tr("Retroshare ID")); ui.stabWidget->setTabText(1, tr("Retroshare ID"));
} }
else else
{ {
invite = rsPeers->GetRetroshareInvite(detail.id, ui._shouldAddSignatures_CB->isChecked(), ui._includeIPHistory_CB->isChecked() ) ; if(ui._shouldAddSignatures_CB->isChecked())
flags |= RetroshareInviteFlags::PGP_SIGNATURES;
invite = rsPeers->GetRetroshareInvite(detail.id, flags ) ;
ui.stabWidget->setTabText(1, tr("Retroshare Certificate")); ui.stabWidget->setTabText(1, tr("Retroshare Certificate"));
} }

View file

@ -550,7 +550,25 @@ void ConnectFriendWizard::initializePage(int id)
} }
ui->nodeEdit->setText(loc); ui->nodeEdit->setText(loc);
ui->ipEdit->setText(QString::fromStdString(peerDetails.isHiddenNode ? peerDetails.hiddenNodeAddress : peerDetails.extAddr));
std::string s;
if(peerDetails.isHiddenNode)
s += peerDetails.hiddenNodeAddress;
else
{
if(peerDetails.localAddr!="0.0.0.0")// This is not so nice, but because we deal we string there's no way
s += peerDetails.localAddr; // to ask about if the ip is null. We really need a proper IP class.
if(peerDetails.extAddr!="0.0.0.0")
{
if(!s.empty()) s += " / " ;
s += peerDetails.extAddr;
}
if(!peerDetails.dyndns.empty())
s += "(" + peerDetails.dyndns + ")" ;
}
ui->ipEdit->setText(QString::fromStdString(s));
ui->signersEdit->setPlainText(ts); ui->signersEdit->setPlainText(ts);
fillGroups(this, ui->groupComboBox, groupId); fillGroups(this, ui->groupComboBox, groupId);

View file

@ -6,8 +6,8 @@
<rect> <rect>
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>600</width> <width>654</width>
<height>400</height> <height>677</height>
</rect> </rect>
</property> </property>
<property name="windowTitle"> <property name="windowTitle">
@ -284,7 +284,7 @@
<string>Email</string> <string>Email</string>
</property> </property>
<property name="icon"> <property name="icon">
<iconset resource="../icons.qrc"> <iconset>
<normaloff>:/icons/mail_128.png</normaloff>:/icons/mail_128.png</iconset> <normaloff>:/icons/mail_128.png</normaloff>:/icons/mail_128.png</iconset>
</property> </property>
<property name="iconSize"> <property name="iconSize">

View file

@ -87,7 +87,20 @@ void updateCommentCounts( std::vector<RsGxsChannelPost>& posts, std::vector<RsGx
// now look into comments and increase the count // now look into comments and increase the count
for(uint32_t i=0;i<comments.size();++i) for(uint32_t i=0;i<comments.size();++i)
++posts[post_indices[comments[i].mMeta.mThreadId]].mCommentCount; {
auto it = post_indices.find(comments[i].mMeta.mThreadId);
// This happens when because of sync periods, we receive
// the comments for a post, but not the post itself.
// In this case, the post the comment refers to is just not here.
// it->second>=posts.size() is impossible by construction, since post_indices
// is previously filled using posts ids.
if(it == post_indices.end())
continue;
++posts[it->second].mCommentCount;
}
} }
@ -104,11 +117,12 @@ void RsGxsChannelPostsModel::handleEvent_main_thread(std::shared_ptr<const RsEve
case RsChannelEventCode::READ_STATUS_CHANGED: case RsChannelEventCode::READ_STATUS_CHANGED:
{ {
// Normally we should just emit dataChanged() on the index of the data that has changed: // Normally we should just emit dataChanged() on the index of the data that has changed:
//
// We need to update the data! // We need to update the data!
// make a copy of e, so as to avoid destruction of the shared pointer during async thread execution, since [e] doesn't actually tell // make a copy of e, so as to avoid destruction of the shared pointer during async thread execution, since [e] doesn't actually tell
// the shared_ptr that it is copied! So no counter is updated. // the original shared_ptr that it is copied! So no counter is updated in event, which will be destroyed (as e will be) during or even before
// the execution of the lambda.
RsGxsChannelEvent E(*e); RsGxsChannelEvent E(*e);
if(E.mChannelGroupId == mChannelGroup.mMeta.mGroupId) if(E.mChannelGroupId == mChannelGroup.mMeta.mGroupId)
@ -120,8 +134,6 @@ void RsGxsChannelPostsModel::handleEvent_main_thread(std::shared_ptr<const RsEve
std::vector<RsGxsComment> comments; std::vector<RsGxsComment> comments;
std::vector<RsGxsVote> votes; std::vector<RsGxsVote> votes;
std::cerr << "display of e 1: " << E << std::endl;
if(!rsGxsChannels->getChannelContent(E.mChannelGroupId,std::set<RsGxsMessageId>{ E.mChannelMsgId }, posts,comments,votes)) if(!rsGxsChannels->getChannelContent(E.mChannelGroupId,std::set<RsGxsMessageId>{ E.mChannelMsgId }, posts,comments,votes))
{ {
std::cerr << __PRETTY_FUNCTION__ << " failed to retrieve channel message data for channel/msg " << E.mChannelGroupId << "/" << E.mChannelMsgId << std::endl; std::cerr << __PRETTY_FUNCTION__ << " failed to retrieve channel message data for channel/msg " << E.mChannelGroupId << "/" << E.mChannelMsgId << std::endl;
@ -131,8 +143,6 @@ void RsGxsChannelPostsModel::handleEvent_main_thread(std::shared_ptr<const RsEve
// Need to call this in order to get the actuall comment count. The previous call only retrieves the message, since we supplied the message ID. // Need to call this in order to get the actuall comment count. The previous call only retrieves the message, since we supplied the message ID.
// another way to go would be to save the comment ids of the existing message and re-insert them before calling getChannelContent. // another way to go would be to save the comment ids of the existing message and re-insert them before calling getChannelContent.
std::cerr << "display of e 2: " << E << std::endl;
std::cerr << "Before call : IS_MSG_READ=" << IS_MSG_NEW(posts[0].mMeta.mMsgFlags) << " for message id " << E.mChannelMsgId << std::endl;
if(!rsGxsChannels->getChannelComments(E.mChannelGroupId,std::set<RsGxsMessageId>{ E.mChannelMsgId },comments)) if(!rsGxsChannels->getChannelComments(E.mChannelGroupId,std::set<RsGxsMessageId>{ E.mChannelMsgId },comments))
{ {
std::cerr << __PRETTY_FUNCTION__ << " failed to retrieve message comment data for channel/msg " << E.mChannelGroupId << "/" << E.mChannelMsgId << std::endl; std::cerr << __PRETTY_FUNCTION__ << " failed to retrieve message comment data for channel/msg " << E.mChannelGroupId << "/" << E.mChannelMsgId << std::endl;
@ -141,7 +151,6 @@ void RsGxsChannelPostsModel::handleEvent_main_thread(std::shared_ptr<const RsEve
updateCommentCounts(posts,comments); updateCommentCounts(posts,comments);
std::cerr << "After call : IS_MSG_READ=" << IS_MSG_NEW(posts[0].mMeta.mMsgFlags) << std::endl;
// 2 - update the model in the UI thread. // 2 - update the model in the UI thread.
RsQThreadUtils::postToObject( [posts,this]() RsQThreadUtils::postToObject( [posts,this]()

View file

@ -134,6 +134,7 @@ MessageComposer::MessageComposer(QWidget *parent, Qt::WindowFlags flags)
m_completer = NULL; m_completer = NULL;
ui.distantFrame->hide(); ui.distantFrame->hide();
ui.sizeLimitFrame->hide();
ui.respond_to_CB->hide(); ui.respond_to_CB->hide();
ui.fromLabel->hide(); ui.fromLabel->hide();
@ -395,6 +396,11 @@ void MessageComposer::updateCells(int,int)
ui.distantFrame->hide() ; ui.distantFrame->hide() ;
ui.fromLabel->hide(); ui.fromLabel->hide();
} }
if(rowCount > 20)
ui.sizeLimitFrame->show();
else
ui.sizeLimitFrame->hide();
} }
void MessageComposer::processSettings(bool bLoad) void MessageComposer::processSettings(bool bLoad)
@ -2770,7 +2776,10 @@ void MessageComposer::showTagLabels()
ui.tagLayout->addStretch(); ui.tagLayout->addStretch();
} }
} }
void MessageComposer::on_closeSizeLimitFrameButton_clicked()
{
ui.sizeLimitFrame->setVisible(false);
}
void MessageComposer::on_closeInfoFrameButton_clicked() void MessageComposer::on_closeInfoFrameButton_clicked()
{ {
ui.distantFrame->setVisible(false); ui.distantFrame->setVisible(false);

View file

@ -164,7 +164,8 @@ private slots:
void tagRemoveAll(); void tagRemoveAll();
void on_closeInfoFrameButton_clicked(); void on_closeInfoFrameButton_clicked();
void on_closeSizeLimitFrameButton_clicked();
static QString inviteMessage(); static QString inviteMessage();
private: private:

File diff suppressed because it is too large Load diff

View file

@ -46,6 +46,7 @@
#include "util/DateTime.h" #include "util/DateTime.h"
#include "util/RsProtectedTimer.h" #include "util/RsProtectedTimer.h"
#include "util/QtVersion.h" #include "util/QtVersion.h"
#include "util/qtthreadsutils.h"
#include <retroshare/rspeers.h> #include <retroshare/rspeers.h>
#include <retroshare/rsmsgs.h> #include <retroshare/rsmsgs.h>
@ -286,10 +287,10 @@ MessagesDialog::MessagesDialog(QWidget *parent)
connect(ui.messageTreeWidget->selectionModel(), SIGNAL(currentChanged(const QModelIndex&,const QModelIndex&)), this, SLOT(currentChanged(const QModelIndex&,const QModelIndex&))); connect(ui.messageTreeWidget->selectionModel(), SIGNAL(currentChanged(const QModelIndex&,const QModelIndex&)), this, SLOT(currentChanged(const QModelIndex&,const QModelIndex&)));
mEventHandlerId=0; mEventHandlerId=0;
rsEvents->registerEventsHandler( [this](std::shared_ptr<const RsEvent> event) { handleEvent(event); }, mEventHandlerId, RsEventType::MAIL_STATUS ); rsEvents->registerEventsHandler( [this](std::shared_ptr<const RsEvent> event) { RsQThreadUtils::postToObject( [this,event]() { handleEvent_main_thread(event); }); }, mEventHandlerId, RsEventType::MAIL_STATUS );
} }
void MessagesDialog::handleEvent(std::shared_ptr<const RsEvent> event) void MessagesDialog::handleEvent_main_thread(std::shared_ptr<const RsEvent> event)
{ {
if(event->mType != RsEventType::MAIL_STATUS) if(event->mType != RsEventType::MAIL_STATUS)
return; return;

View file

@ -111,7 +111,7 @@ private slots:
void tabCloseRequested(int tab); void tabCloseRequested(int tab);
private: private:
void handleEvent(std::shared_ptr<const RsEvent> event); void handleEvent_main_thread(std::shared_ptr<const RsEvent> event);
void updateInterface(); void updateInterface();

View file

@ -92,7 +92,8 @@ void ProfileWidget::statusmessagedlg()
void ProfileWidget::copyCert() void ProfileWidget::copyCert()
{ {
std::string cert = rsPeers->GetRetroshareInvite(RsPeerId(),false,false); std::string cert = rsPeers->GetRetroshareInvite(RsPeerId());
if (cert.empty()) { if (cert.empty()) {
QMessageBox::information(this, tr("RetroShare"), QMessageBox::information(this, tr("RetroShare"),
tr("Sorry, create certificate failed"), tr("Sorry, create certificate failed"),

View file

@ -29,6 +29,7 @@
#include "CryptoPage.h" #include "CryptoPage.h"
#include "util/misc.h" #include "util/misc.h"
#include "util/DateTime.h" #include "util/DateTime.h"
#include "retroshare/rsinit.h"
#include <gui/RetroShareLink.h> #include <gui/RetroShareLink.h>
#include <gui/connect/ConfCertDialog.h> #include <gui/connect/ConfCertDialog.h>
#include <gui/profile/ProfileManager.h> #include <gui/profile/ProfileManager.h>
@ -57,16 +58,38 @@ CryptoPage::CryptoPage(QWidget * parent, Qt::WindowFlags flags)
// hide profile manager as it causes bugs when generating a new profile. // hide profile manager as it causes bugs when generating a new profile.
//ui.profile_Button->hide() ; //ui.profile_Button->hide() ;
connect(ui.exportprofile,SIGNAL(clicked()), this, SLOT(profilemanager())); //connect(ui.exportprofile,SIGNAL(clicked()), this, SLOT(profilemanager()));
connect(ui.exportprofile,SIGNAL(clicked()), this, SLOT(exportProfile()));
ui.onlinesince->setText(DateTime::formatLongDateTime(Rshare::startupTime())); ui.onlinesince->setText(DateTime::formatLongDateTime(Rshare::startupTime()));
} }
#ifdef UNUSED_CODE
void CryptoPage::profilemanager() void CryptoPage::profilemanager()
{ {
ProfileManager().exec(); ProfileManager().exec();
} }
#endif
void CryptoPage::exportProfile()
{
RsPgpId gpgId(rsPeers->getGPGOwnId());
QString fname = QFileDialog::getSaveFileName(this, tr("Export Identity"), "", tr("RetroShare Identity files (*.asc)"));
if (fname.isNull())
return;
if (fname.right(4).toUpper() != ".ASC") fname += ".asc";
if (RsAccounts::ExportIdentity(fname.toUtf8().constData(), gpgId))
QMessageBox::information(this, tr("Identity saved"), tr("Your identity was successfully saved\nIt is encrypted\n\nYou can now copy it to another computer\nand use the import button to load it"));
else
QMessageBox::information(this, tr("Identity not saved"), tr("Your identity was not saved. An error occurred."));
}
void CryptoPage::showEvent ( QShowEvent * /*event*/ ) void CryptoPage::showEvent ( QShowEvent * /*event*/ )
{ {
RsPeerDetails detail; RsPeerDetails detail;
@ -80,7 +103,7 @@ void CryptoPage::showEvent ( QShowEvent * /*event*/ )
ui.pgpfingerprint->setText(misc::fingerPrintStyleSplit(QString::fromStdString(detail.fpr.toStdString()))); ui.pgpfingerprint->setText(misc::fingerPrintStyleSplit(QString::fromStdString(detail.fpr.toStdString())));
std::string invite ; std::string invite ;
rsPeers->getShortInvite(invite,rsPeers->getOwnId(),true,false); rsPeers->getShortInvite(invite,rsPeers->getOwnId(),RetroshareInviteFlags::RADIX_FORMAT | RetroshareInviteFlags::DNS | RetroshareInviteFlags::CURRENT_IP);
ui.retroshareid->setText(QString::fromUtf8(invite.c_str())); ui.retroshareid->setText(QString::fromUtf8(invite.c_str()));
/* set retroshare version */ /* set retroshare version */
@ -116,11 +139,22 @@ void
CryptoPage::load() CryptoPage::load()
{ {
std::string cert ; std::string cert ;
RetroshareInviteFlags flags = RetroshareInviteFlags::DNS | RetroshareInviteFlags::CURRENT_IP;
if(ui._shortFormat_CB->isChecked()) if(ui._shortFormat_CB->isChecked())
rsPeers->getShortInvite(cert,rsPeers->getOwnId(), true, !ui._includeAllIPs_CB->isChecked()); {
if(ui._includeAllIPs_CB->isChecked())
flags |= RetroshareInviteFlags::FULL_IP_HISTORY;
rsPeers->getShortInvite(cert,rsPeers->getOwnId(), RetroshareInviteFlags::RADIX_FORMAT | flags);
}
else else
cert = rsPeers->GetRetroshareInvite( rsPeers->getOwnId(), ui._includeSignatures_CB->isChecked(), ui._includeAllIPs_CB->isChecked() ); {
if(ui._includeSignatures_CB->isChecked())
flags |= RetroshareInviteFlags::PGP_SIGNATURES;
cert = rsPeers->GetRetroshareInvite( rsPeers->getOwnId(), flags);
}
ui.certplainTextEdit->setPlainText( QString::fromUtf8( cert.c_str() ) ); ui.certplainTextEdit->setPlainText( QString::fromUtf8( cert.c_str() ) );

View file

@ -42,11 +42,12 @@ class CryptoPage : public ConfigPage
virtual QString helpText() const { return ""; } virtual QString helpText() const { return ""; }
private slots: private slots:
void exportProfile();
virtual void load(); virtual void load();
void copyPublicKey(); void copyPublicKey();
void copyRSLink() ; void copyRSLink() ;
virtual void showEvent ( QShowEvent * event ); virtual void showEvent ( QShowEvent * event );
void profilemanager(); // void profilemanager();
bool fileSave(); bool fileSave();
bool fileSaveAs(); bool fileSaveAs();
void showStats(); void showStats();

View file

@ -6,8 +6,8 @@
<rect> <rect>
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>644</width> <width>869</width>
<height>459</height> <height>487</height>
</rect> </rect>
</property> </property>
<layout class="QGridLayout" name="gridLayout_2"> <layout class="QGridLayout" name="gridLayout_2">
@ -246,6 +246,9 @@
</item> </item>
<item row="14" column="1"> <item row="14" column="1">
<widget class="QPushButton" name="exportprofile"> <widget class="QPushButton" name="exportprofile">
<property name="toolTip">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;Use this to export your profile key. You can then import it in a different computer and make a new node with the same profile. Doing so, existing friends that you also add to the new node will automatically recognise that new node as friend.&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
<property name="text"> <property name="text">
<string>Export</string> <string>Export</string>
</property> </property>

View file

@ -26,6 +26,7 @@
#include "retroshare/rsfiles.h" #include "retroshare/rsfiles.h"
#include "hashingstatus.h" #include "hashingstatus.h"
#include "gui/common/ElidedLabel.h" #include "gui/common/ElidedLabel.h"
#include "util/qtthreadsutils.h"
#include "gui/notifyqt.h" #include "gui/notifyqt.h"
#include "gui/common/FilesDefs.h" #include "gui/common/FilesDefs.h"
@ -54,13 +55,13 @@ HashingStatus::HashingStatus(QWidget *parent)
statusHashing->hide(); statusHashing->hide();
mEventHandlerId=0; mEventHandlerId=0;
rsEvents->registerEventsHandler( rsEvents->registerEventsHandler( [this](std::shared_ptr<const RsEvent> event) { RsQThreadUtils::postToObject( [this,event]() { handleEvent_main_thread(event); }) ;}, mEventHandlerId, RsEventType::SHARED_DIRECTORIES );
[this](std::shared_ptr<const RsEvent> event) { handleEvent(event); },
mEventHandlerId, RsEventType::SHARED_DIRECTORIES );
} }
void HashingStatus::handleEvent(std::shared_ptr<const RsEvent> event) void HashingStatus::handleEvent_main_thread(std::shared_ptr<const RsEvent> event)
{ {
// Warning: no GUI calls should happen here!
if(event->mType != RsEventType::SHARED_DIRECTORIES) if(event->mType != RsEventType::SHARED_DIRECTORIES)
return; return;
@ -72,7 +73,8 @@ void HashingStatus::handleEvent(std::shared_ptr<const RsEvent> event)
switch (fe->mEventCode) switch (fe->mEventCode)
{ {
case RsSharedDirectoriesEventCode::STARTING_DIRECTORY_SWEEP: default:
case RsSharedDirectoriesEventCode::STARTING_DIRECTORY_SWEEP:
info = tr("Examining shared files..."); info = tr("Examining shared files...");
break; break;
case RsSharedDirectoriesEventCode::DIRECTORY_SWEEP_ENDED: case RsSharedDirectoriesEventCode::DIRECTORY_SWEEP_ENDED:
@ -85,7 +87,9 @@ void HashingStatus::handleEvent(std::shared_ptr<const RsEvent> event)
break; break;
} }
updateHashingInfo(info); // GUI calls should only happen in the GUI thread, which is achieved by postToObject().
updateHashingInfo(info);
} }
HashingStatus::~HashingStatus() HashingStatus::~HashingStatus()

View file

@ -40,7 +40,7 @@ public:
private: private:
void updateHashingInfo(const QString& s); void updateHashingInfo(const QString& s);
void handleEvent(std::shared_ptr<const RsEvent> event); void handleEvent_main_thread(std::shared_ptr<const RsEvent> event);
ElidedLabel *statusHashing; ElidedLabel *statusHashing;
QLabel *hashloader; QLabel *hashloader;