mirror of
https://github.com/RetroShare/RetroShare.git
synced 2025-06-19 11:54:22 -04:00
moerged with upstream/master
This commit is contained in:
commit
18e9e1c2db
25 changed files with 239 additions and 127 deletions
|
@ -1,5 +1,40 @@
|
||||||
retroshare06 (0.6.0-1.XXXXXX~YYYYYY) YYYYYY; urgency=low
|
retroshare06 (0.6.0-1.XXXXXX~YYYYYY) YYYYYY; urgency=low
|
||||||
|
|
||||||
|
0dc43c3 csoler Sat, 23 Apr 2016 08:29:53 -0400 Merge pull request #338 from Nyfor/master
|
||||||
|
5e94c77 Nyfor Mon, 4 Apr 2016 12:07:09 +0200 Fixed compilation for Clang.
|
||||||
|
d696f72 csoler Fri, 22 Apr 2016 20:38:07 -0400 fixed compilation
|
||||||
|
acd059b csoler Fri, 22 Apr 2016 18:49:42 -0400 removed potential memory leak in TransfersDialog
|
||||||
|
52cf66a csoler Fri, 22 Apr 2016 17:55:15 -0400 fixed memory leak in SubscribeToolButton menu
|
||||||
|
55e8087 csoler Fri, 22 Apr 2016 17:30:55 -0400 added missing free for public keys used in envelop encryption
|
||||||
|
10230df csoler Fri, 22 Apr 2016 16:50:43 -0400 added missing SSL shutdown when replacing existing connection
|
||||||
|
5261c3c csoler Thu, 21 Apr 2016 22:23:07 -0400 prevented turtle to not deleting a config item when it is not cast
|
||||||
|
e9fa9eb csoler Thu, 21 Apr 2016 22:07:50 -0400 removed tricky memory leak in chat lobbies due to handling of partial messages
|
||||||
|
7aea6e5 csoler Thu, 21 Apr 2016 22:07:10 -0400 removed some debug info
|
||||||
|
eca83fd csoler Thu, 21 Apr 2016 19:54:50 -0400 removed some debug info
|
||||||
|
fba3d37 csoler Thu, 21 Apr 2016 19:47:34 -0400 fixed memory leak after receiving RsNxsItem deserialised from decrypted memory
|
||||||
|
0d3ff0e csoler Thu, 21 Apr 2016 19:46:47 -0400 fixed possible uninitialised memory read in memory decryption return
|
||||||
|
0c711a4 csoler Thu, 21 Apr 2016 19:41:21 -0400 added missing calls to EVP_CIPHER_CTX_cleanup() to release memory after decryption, causing memory
|
||||||
|
3fae108 csoler Thu, 21 Apr 2016 12:58:48 -0400 removed div by zero in transfers dialog
|
||||||
|
0572492 csoler Wed, 20 Apr 2016 21:20:47 -0400 severely reduced packet grouping, which limited the effectiveness of QoS
|
||||||
|
d6ae71e csoler Wed, 20 Apr 2016 20:21:29 -0400 removed pointer to QStringList in QHash, causing memory loss
|
||||||
|
aba3d2f csoler Wed, 20 Apr 2016 18:24:02 -0400 removed memory leak due to zeroing (on purpose!) a data chunk in GRouter before deleting it
|
||||||
|
d017771 csoler Wed, 20 Apr 2016 18:08:26 -0400 fixed missing sendTime in distant chat, causing inconsistent display in GUI
|
||||||
|
80a9fec csoler Tue, 19 Apr 2016 22:18:25 -0400 Merge pull request #353 from crhode/master
|
||||||
|
39553a6 csoler Tue, 19 Apr 2016 21:58:30 -0400 removed debug info
|
||||||
|
5645e44 Manuel Davis Tue, 19 Apr 2016 11:32:56 -0500 Change regular expression(s) for identifying hotlinks in feral text.
|
||||||
|
8be53dd Manuel Davis Tue, 19 Apr 2016 11:11:58 -0500 Improve inserting placemark in ChatLobby.
|
||||||
|
26af7c9 csoler Sun, 17 Apr 2016 22:58:48 -0400 changed heart beat limit to a larger value. Apparently too tight a value causes disconnections due
|
||||||
|
c14c240 csoler Sun, 17 Apr 2016 00:51:45 -0400 fixed update of circles GUI using a timer. This is not optimal, and should be replaced by a proper
|
||||||
|
3000f94 csoler Sat, 16 Apr 2016 22:44:06 -0400 separated subscribe status from wether we are part of a circle or not. Still needs update of GUI
|
||||||
|
b861aa9 csoler Sat, 16 Apr 2016 17:10:36 -0400 Merge pull request #352 from AsamK/trailing_semicolon
|
||||||
|
e7ec204 AsamK Sat, 16 Apr 2016 20:40:24 +0200 Add trailing semi-colon to MimeType in .desktop files
|
||||||
|
fa8a585 csoler Fri, 15 Apr 2016 18:25:53 -0400 removed some debug info
|
||||||
|
d642934 csoler Fri, 15 Apr 2016 18:25:41 -0400 increased frequency of update for banned PGP nodes
|
||||||
|
|
||||||
|
-- Cyril Soler <csoler@users.sourceforge.net> Sun, 24 Apr 2016 12:00:00 -0500
|
||||||
|
|
||||||
|
retroshare06 (0.6.0-1.20160415.26574fd9~trusty) trusty; urgency=low
|
||||||
|
|
||||||
2552b55 defnax Fri, 15 Apr 2016 20:32:00 +0200 Merge branch 'master' of https://github.com/RetroShare/RetroShare
|
2552b55 defnax Fri, 15 Apr 2016 20:32:00 +0200 Merge branch 'master' of https://github.com/RetroShare/RetroShare
|
||||||
85942f4 defnax Fri, 15 Apr 2016 20:30:32 +0200 improving the create circle layout
|
85942f4 defnax Fri, 15 Apr 2016 20:30:32 +0200 improving the create circle layout
|
||||||
cb6c2c9 csoler Thu, 14 Apr 2016 23:49:55 -0400 Merge pull request #350 from csoler/v0.6-Circles
|
cb6c2c9 csoler Thu, 14 Apr 2016 23:49:55 -0400 Merge pull request #350 from csoler/v0.6-Circles
|
||||||
|
|
|
@ -264,9 +264,12 @@ bool DistantChatService::initiateDistantChatConnexion(const RsGxsId& to_gxs_id,
|
||||||
RsChatMsgItem *item = new RsChatMsgItem;
|
RsChatMsgItem *item = new RsChatMsgItem;
|
||||||
item->message = "[Starting distant chat. Please wait for secure tunnel to be established]" ;
|
item->message = "[Starting distant chat. Please wait for secure tunnel to be established]" ;
|
||||||
item->chatFlags = RS_CHAT_FLAG_PRIVATE ;
|
item->chatFlags = RS_CHAT_FLAG_PRIVATE ;
|
||||||
|
item->sendTime = time(NULL) ;
|
||||||
item->PeerId(RsPeerId(tunnel_id)) ;
|
item->PeerId(RsPeerId(tunnel_id)) ;
|
||||||
handleRecvChatMsgItem(item) ;
|
handleRecvChatMsgItem(item) ;
|
||||||
|
|
||||||
|
delete item ; // item is replaced by NULL if partial, but this is not the case here.
|
||||||
|
|
||||||
return true ;
|
return true ;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -63,7 +63,7 @@ public:
|
||||||
|
|
||||||
// derived in p3ChatService, so as to pass down some info
|
// derived in p3ChatService, so as to pass down some info
|
||||||
virtual void handleIncomingItem(RsItem *) = 0;
|
virtual void handleIncomingItem(RsItem *) = 0;
|
||||||
virtual bool handleRecvChatMsgItem(RsChatMsgItem *ci)=0 ;
|
virtual bool handleRecvChatMsgItem(RsChatMsgItem *& ci)=0 ;
|
||||||
|
|
||||||
bool handleOutgoingItem(RsChatItem *) ;
|
bool handleOutgoingItem(RsChatItem *) ;
|
||||||
bool handleRecvItem(RsChatItem *) ;
|
bool handleRecvItem(RsChatItem *) ;
|
||||||
|
|
|
@ -424,11 +424,6 @@ void DistributedChatService::checkSizeAndSendLobbyMessage(RsChatItem *msg)
|
||||||
sendChatItem(msg) ;
|
sendChatItem(msg) ;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool DistributedChatService::locked_checkAndRebuildPartialLobbyMessage(RsChatLobbyMsgItem *ci)
|
|
||||||
{
|
|
||||||
return true ;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool DistributedChatService::handleRecvItem(RsChatItem *item)
|
bool DistributedChatService::handleRecvItem(RsChatItem *item)
|
||||||
{
|
{
|
||||||
switch(item->PacketSubType())
|
switch(item->PacketSubType())
|
||||||
|
|
|
@ -90,7 +90,6 @@ class DistributedChatService
|
||||||
void addToSaveList(std::list<RsItem*>& list) const ;
|
void addToSaveList(std::list<RsItem*>& list) const ;
|
||||||
bool processLoadListItem(const RsItem *item) ;
|
bool processLoadListItem(const RsItem *item) ;
|
||||||
|
|
||||||
bool locked_checkAndRebuildPartialLobbyMessage(RsChatLobbyMsgItem *) ;
|
|
||||||
void checkSizeAndSendLobbyMessage(RsChatItem *) ;
|
void checkSizeAndSendLobbyMessage(RsChatItem *) ;
|
||||||
|
|
||||||
bool sendLobbyChat(const ChatLobbyId &lobby_id, const std::string&) ;
|
bool sendLobbyChat(const ChatLobbyId &lobby_id, const std::string&) ;
|
||||||
|
|
|
@ -428,7 +428,14 @@ bool p3ChatService::sendChat(ChatId destination, std::string msg)
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool p3ChatService::locked_checkAndRebuildPartialMessage(RsChatMsgItem *ci)
|
// This method might take control over the memory, or modify it, possibly adding missing parts.
|
||||||
|
// This function looks weird because it cannot duplicate the message since it does not know
|
||||||
|
// what type of object it is and the duplicate method of lobby messages is reserved for
|
||||||
|
// ChatLobby bouncing objects.
|
||||||
|
//
|
||||||
|
// Returns false if the item shouldn't be used (and replaced to NULL)
|
||||||
|
|
||||||
|
bool p3ChatService::locked_checkAndRebuildPartialMessage(RsChatMsgItem *& ci)
|
||||||
{
|
{
|
||||||
// Check is the item is ending an incomplete item.
|
// Check is the item is ending an incomplete item.
|
||||||
//
|
//
|
||||||
|
@ -446,12 +453,15 @@ bool p3ChatService::locked_checkAndRebuildPartialMessage(RsChatMsgItem *ci)
|
||||||
ci->message = it->second->message + ci->message ;
|
ci->message = it->second->message + ci->message ;
|
||||||
ci->chatFlags |= it->second->chatFlags ;
|
ci->chatFlags |= it->second->chatFlags ;
|
||||||
|
|
||||||
delete it->second ;
|
// always remove existing partial. The compound message is in ci now.
|
||||||
|
|
||||||
if(!ci_is_incomplete)
|
delete it->second ;
|
||||||
_pendingPartialMessages.erase(it) ;
|
_pendingPartialMessages.erase(it) ;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// now decide what to do: if ci is incomplete, store it and replace the pointer with NULL
|
||||||
|
// if complete, return it.
|
||||||
|
|
||||||
if(ci_is_incomplete)
|
if(ci_is_incomplete)
|
||||||
{
|
{
|
||||||
#ifdef CHAT_DEBUG
|
#ifdef CHAT_DEBUG
|
||||||
|
@ -459,7 +469,8 @@ bool p3ChatService::locked_checkAndRebuildPartialMessage(RsChatMsgItem *ci)
|
||||||
#endif
|
#endif
|
||||||
// The item is a partial message. Push it, and wait for the rest.
|
// The item is a partial message. Push it, and wait for the rest.
|
||||||
//
|
//
|
||||||
_pendingPartialMessages[ci->PeerId()] = ci ;
|
_pendingPartialMessages[ci->PeerId()] = ci ; // cannot use duplicate() here
|
||||||
|
ci = NULL ; // takes memory ownership over ci
|
||||||
return false ;
|
return false ;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -504,7 +515,9 @@ void p3ChatService::handleIncomingItem(RsItem *item)
|
||||||
RsChatMsgItem *ci = dynamic_cast<RsChatMsgItem*>(item) ;
|
RsChatMsgItem *ci = dynamic_cast<RsChatMsgItem*>(item) ;
|
||||||
if(ci != NULL)
|
if(ci != NULL)
|
||||||
{
|
{
|
||||||
if(! handleRecvChatMsgItem(ci))
|
handleRecvChatMsgItem(ci);
|
||||||
|
|
||||||
|
if(ci)
|
||||||
delete ci ;
|
delete ci ;
|
||||||
|
|
||||||
return ; // don't delete! It's handled by handleRecvChatMsgItem in some specific cases only.
|
return ; // don't delete! It's handled by handleRecvChatMsgItem in some specific cases only.
|
||||||
|
@ -665,7 +678,7 @@ bool p3ChatService::checkForMessageSecurity(RsChatMsgItem *ci)
|
||||||
return true ;
|
return true ;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool p3ChatService::handleRecvChatMsgItem(RsChatMsgItem *ci)
|
bool p3ChatService::handleRecvChatMsgItem(RsChatMsgItem *& ci)
|
||||||
{
|
{
|
||||||
time_t now = time(NULL);
|
time_t now = time(NULL);
|
||||||
std::string name;
|
std::string name;
|
||||||
|
@ -674,15 +687,8 @@ bool p3ChatService::handleRecvChatMsgItem(RsChatMsgItem *ci)
|
||||||
{
|
{
|
||||||
RsStackMutex stack(mChatMtx); /********** STACK LOCKED MTX ******/
|
RsStackMutex stack(mChatMtx); /********** STACK LOCKED MTX ******/
|
||||||
|
|
||||||
// This crap is because chat lobby messages use a different method for chunking messages using an additional
|
if(!locked_checkAndRebuildPartialMessage(ci)) // we make sure this call does not take control over the memory
|
||||||
// subpacket ID, and a list of lobbies. We cannot just collapse the two because it would make the normal chat
|
return true ; // message is a subpart of an existing message. So everything ok, but we need to return.
|
||||||
// (and chat lobbies) not backward compatible.
|
|
||||||
|
|
||||||
if(!DistributedChatService::locked_checkAndRebuildPartialLobbyMessage(dynamic_cast<RsChatLobbyMsgItem*>(ci)))
|
|
||||||
return true ;
|
|
||||||
|
|
||||||
if(!locked_checkAndRebuildPartialMessage(ci))
|
|
||||||
return true ;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check for security. This avoids bombing messages, and so on.
|
// Check for security. This avoids bombing messages, and so on.
|
||||||
|
|
|
@ -205,7 +205,8 @@ private:
|
||||||
void receiveStateString(const RsPeerId& id,const std::string& s) ;
|
void receiveStateString(const RsPeerId& id,const std::string& s) ;
|
||||||
|
|
||||||
/// methods for handling various Chat items.
|
/// methods for handling various Chat items.
|
||||||
bool handleRecvChatMsgItem(RsChatMsgItem *item) ; // returns false if the item should be deleted.
|
virtual bool handleRecvChatMsgItem(RsChatMsgItem *&item) ; // NULL-ifies the item if memory ownership is taken
|
||||||
|
|
||||||
void handleRecvChatStatusItem(RsChatStatusItem *item) ;
|
void handleRecvChatStatusItem(RsChatStatusItem *item) ;
|
||||||
void handleRecvChatAvatarItem(RsChatAvatarItem *item) ;
|
void handleRecvChatAvatarItem(RsChatAvatarItem *item) ;
|
||||||
|
|
||||||
|
@ -220,7 +221,8 @@ private:
|
||||||
void checkSizeAndSendMessage(RsChatMsgItem *item) ; // keep for compatibility for a few weeks.
|
void checkSizeAndSendMessage(RsChatMsgItem *item) ; // keep for compatibility for a few weeks.
|
||||||
|
|
||||||
/// Called when a RsChatMsgItem is received. The item may be collapsed with any waiting partial chat item from the same peer.
|
/// Called when a RsChatMsgItem is received. The item may be collapsed with any waiting partial chat item from the same peer.
|
||||||
bool locked_checkAndRebuildPartialMessage(RsChatMsgItem *) ;
|
/// if so, the chat item will be turned to NULL
|
||||||
|
bool locked_checkAndRebuildPartialMessage(RsChatMsgItem *&) ;
|
||||||
|
|
||||||
RsChatAvatarItem *makeOwnAvatarItem() ;
|
RsChatAvatarItem *makeOwnAvatarItem() ;
|
||||||
RsChatStatusItem *makeOwnCustomStateStringItem() ;
|
RsChatStatusItem *makeOwnCustomStateStringItem() ;
|
||||||
|
|
|
@ -613,7 +613,6 @@ RsGRouterAbstractMsgItem *GRouterDataInfo::addDataChunk(RsGRouterTransactionChun
|
||||||
{
|
{
|
||||||
RsItem *data_item = RsGRouterSerialiser().deserialise(incoming_data_buffer->chunk_data,&incoming_data_buffer->chunk_size) ;
|
RsItem *data_item = RsGRouterSerialiser().deserialise(incoming_data_buffer->chunk_data,&incoming_data_buffer->chunk_size) ;
|
||||||
|
|
||||||
incoming_data_buffer->chunk_data = NULL;
|
|
||||||
delete incoming_data_buffer;
|
delete incoming_data_buffer;
|
||||||
incoming_data_buffer = NULL ;
|
incoming_data_buffer = NULL ;
|
||||||
|
|
||||||
|
|
|
@ -225,20 +225,13 @@ private:
|
||||||
void handleLowLevelTransactionAckItem(RsGRouterTransactionAcknItem*) ;
|
void handleLowLevelTransactionAckItem(RsGRouterTransactionAcknItem*) ;
|
||||||
|
|
||||||
static Sha1CheckSum computeDataItemHash(RsGRouterGenericDataItem *data_item);
|
static Sha1CheckSum computeDataItemHash(RsGRouterGenericDataItem *data_item);
|
||||||
#ifdef __APPLE__
|
|
||||||
public:
|
|
||||||
#endif
|
|
||||||
class nullstream: public std::ostream {};
|
|
||||||
|
|
||||||
std::ostream& grouter_debug() const
|
std::ostream& grouter_debug() const
|
||||||
{
|
{
|
||||||
static nullstream null ;
|
static std::ostream null(0);
|
||||||
|
|
||||||
return _debug_enabled?(std::cerr):null;
|
return _debug_enabled?(std::cerr):null;
|
||||||
}
|
}
|
||||||
#ifdef __APPLE__
|
|
||||||
private:
|
|
||||||
#endif
|
|
||||||
void routePendingObjects() ;
|
void routePendingObjects() ;
|
||||||
void handleTunnels() ;
|
void handleTunnels() ;
|
||||||
void autoWash() ;
|
void autoWash() ;
|
||||||
|
@ -364,5 +357,3 @@ private:
|
||||||
|
|
||||||
uint64_t _random_salt ;
|
uint64_t _random_salt ;
|
||||||
};
|
};
|
||||||
|
|
||||||
template<typename T> p3GRouter::nullstream& operator<<(p3GRouter::nullstream& ns,const T&) { return ns ; }
|
|
||||||
|
|
|
@ -425,6 +425,8 @@ bool GxsSecurity::encrypt(uint8_t *& out, uint32_t &outlen, const uint8_t *in, u
|
||||||
// [--- Encrypted session key length ---|--- Encrypted session key ---|--- IV ---|---- Encrypted data ---]
|
// [--- Encrypted session key length ---|--- Encrypted session key ---|--- IV ---|---- Encrypted data ---]
|
||||||
//
|
//
|
||||||
|
|
||||||
|
out = NULL ;
|
||||||
|
|
||||||
RSA *tmpkey = ::extractPublicKey(key) ;
|
RSA *tmpkey = ::extractPublicKey(key) ;
|
||||||
RSA *rsa_publish_pub = RSAPublicKey_dup(tmpkey) ;
|
RSA *rsa_publish_pub = RSAPublicKey_dup(tmpkey) ;
|
||||||
RSA_free(tmpkey) ;
|
RSA_free(tmpkey) ;
|
||||||
|
@ -521,6 +523,8 @@ bool GxsSecurity::encrypt(uint8_t *& out, uint32_t &outlen, const uint8_t *in, u
|
||||||
// free encrypted key data
|
// free encrypted key data
|
||||||
free(ek);
|
free(ek);
|
||||||
|
|
||||||
|
EVP_CIPHER_CTX_cleanup(&ctx);
|
||||||
|
|
||||||
outlen = out_offset;
|
outlen = out_offset;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -538,11 +542,12 @@ bool GxsSecurity::encrypt(uint8_t *& out, uint32_t &outlen, const uint8_t *in, u
|
||||||
//
|
//
|
||||||
|
|
||||||
out = NULL ;
|
out = NULL ;
|
||||||
|
EVP_CIPHER_CTX ctx;
|
||||||
|
EVP_CIPHER_CTX_init(&ctx);
|
||||||
|
std::vector<EVP_PKEY *> public_keys(keys.size(),NULL);
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
std::vector<EVP_PKEY *> public_keys(keys.size(),NULL);
|
|
||||||
|
|
||||||
for(uint32_t i=0;i<keys.size();++i)
|
for(uint32_t i=0;i<keys.size();++i)
|
||||||
{
|
{
|
||||||
RSA *tmpkey = ::extractPublicKey(keys[i]) ;
|
RSA *tmpkey = ::extractPublicKey(keys[i]) ;
|
||||||
|
@ -561,9 +566,7 @@ bool GxsSecurity::encrypt(uint8_t *& out, uint32_t &outlen, const uint8_t *in, u
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
EVP_CIPHER_CTX ctx;
|
|
||||||
unsigned char iv[EVP_MAX_IV_LENGTH];
|
unsigned char iv[EVP_MAX_IV_LENGTH];
|
||||||
EVP_CIPHER_CTX_init(&ctx);
|
|
||||||
|
|
||||||
std::vector<unsigned char *> ek(keys.size(),NULL) ;
|
std::vector<unsigned char *> ek(keys.size(),NULL) ;
|
||||||
std::vector<int> eklen(keys.size(),0) ;
|
std::vector<int> eklen(keys.size(),0) ;
|
||||||
|
@ -587,6 +590,11 @@ bool GxsSecurity::encrypt(uint8_t *& out, uint32_t &outlen, const uint8_t *in, u
|
||||||
if(!EVP_SealInit(&ctx, EVP_aes_128_cbc(), ek.data(), eklen.data(), iv, public_keys.data(), keys.size()))
|
if(!EVP_SealInit(&ctx, EVP_aes_128_cbc(), ek.data(), eklen.data(), iv, public_keys.data(), keys.size()))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
|
// now we can release the encryption keys
|
||||||
|
for(uint32_t i=0;i<public_keys.size();++i)
|
||||||
|
EVP_PKEY_free(public_keys[i]) ;
|
||||||
|
public_keys.clear() ;
|
||||||
|
|
||||||
int total_ek_size = MULTI_ENCRYPTION_FORMAT_v001_ENCRYPTED_KEY_SIZE * keys.size() ;
|
int total_ek_size = MULTI_ENCRYPTION_FORMAT_v001_ENCRYPTED_KEY_SIZE * keys.size() ;
|
||||||
|
|
||||||
int max_outlen = MULTI_ENCRYPTION_FORMAT_v001_HEADER_SIZE + MULTI_ENCRYPTION_FORMAT_v001_NUMBER_OF_KEYS_SIZE + total_ek_size + EVP_MAX_IV_LENGTH + (inlen + cipher_block_size) ;
|
int max_outlen = MULTI_ENCRYPTION_FORMAT_v001_HEADER_SIZE + MULTI_ENCRYPTION_FORMAT_v001_NUMBER_OF_KEYS_SIZE + total_ek_size + EVP_MAX_IV_LENGTH + (inlen + cipher_block_size) ;
|
||||||
|
@ -653,15 +661,23 @@ bool GxsSecurity::encrypt(uint8_t *& out, uint32_t &outlen, const uint8_t *in, u
|
||||||
if(ek[i]) free(ek[i]);
|
if(ek[i]) free(ek[i]);
|
||||||
|
|
||||||
outlen = out_offset;
|
outlen = out_offset;
|
||||||
|
|
||||||
|
EVP_CIPHER_CTX_cleanup(&ctx);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
catch(std::exception& e)
|
catch(std::exception& e)
|
||||||
{
|
{
|
||||||
std::cerr << "(EE) Exception caught while encrypting: " << e.what() << std::endl;
|
std::cerr << "(EE) Exception caught while encrypting: " << e.what() << std::endl;
|
||||||
|
|
||||||
|
EVP_CIPHER_CTX_cleanup(&ctx);
|
||||||
|
|
||||||
if(out) free(out) ;
|
if(out) free(out) ;
|
||||||
out = NULL ;
|
out = NULL ;
|
||||||
|
|
||||||
|
for(uint32_t i=0;i<public_keys.size();++i)
|
||||||
|
EVP_PKEY_free(public_keys[i]) ;
|
||||||
|
public_keys.clear() ;
|
||||||
|
|
||||||
return false ;
|
return false ;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -675,6 +691,7 @@ bool GxsSecurity::decrypt(uint8_t *& out, uint32_t & outlen, const uint8_t *in,
|
||||||
//
|
//
|
||||||
// This method can be used to decrypt multi-encrypted data, if passing he correct encrypted key block (corresponding to the given key)
|
// This method can be used to decrypt multi-encrypted data, if passing he correct encrypted key block (corresponding to the given key)
|
||||||
|
|
||||||
|
out = NULL ;
|
||||||
#ifdef GXS_SECURITY_DEBUG
|
#ifdef GXS_SECURITY_DEBUG
|
||||||
std::cerr << "GxsSecurity::decrypt() " << std::endl;
|
std::cerr << "GxsSecurity::decrypt() " << std::endl;
|
||||||
#endif
|
#endif
|
||||||
|
@ -767,6 +784,7 @@ bool GxsSecurity::decrypt(uint8_t *& out, uint32_t & outlen, const uint8_t *in,
|
||||||
outlen += out_currOffset;
|
outlen += out_currOffset;
|
||||||
free(ek);
|
free(ek);
|
||||||
|
|
||||||
|
EVP_CIPHER_CTX_cleanup(&ctx);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -783,9 +801,13 @@ bool GxsSecurity::decrypt(uint8_t *& out, uint32_t & outlen, const uint8_t *in,
|
||||||
#ifdef DISTRIB_DEBUG
|
#ifdef DISTRIB_DEBUG
|
||||||
std::cerr << "GxsSecurity::decrypt() " << std::endl;
|
std::cerr << "GxsSecurity::decrypt() " << std::endl;
|
||||||
#endif
|
#endif
|
||||||
|
EVP_CIPHER_CTX ctx;
|
||||||
|
EVP_CIPHER_CTX_init(&ctx);
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
out = NULL ;
|
||||||
|
|
||||||
// check that the input block has a valid format.
|
// check that the input block has a valid format.
|
||||||
|
|
||||||
uint32_t offset = 0 ;
|
uint32_t offset = 0 ;
|
||||||
|
@ -826,8 +848,6 @@ bool GxsSecurity::decrypt(uint8_t *& out, uint32_t & outlen, const uint8_t *in,
|
||||||
|
|
||||||
// decrypt
|
// decrypt
|
||||||
|
|
||||||
EVP_CIPHER_CTX ctx;
|
|
||||||
EVP_CIPHER_CTX_init(&ctx);
|
|
||||||
bool succeed = false;
|
bool succeed = false;
|
||||||
|
|
||||||
for(uint32_t j=0;j<keys.size() && !succeed;++j)
|
for(uint32_t j=0;j<keys.size() && !succeed;++j)
|
||||||
|
@ -855,6 +875,9 @@ bool GxsSecurity::decrypt(uint8_t *& out, uint32_t & outlen, const uint8_t *in,
|
||||||
{
|
{
|
||||||
succeed = EVP_OpenInit(&ctx, EVP_aes_128_cbc(),in + encrypted_keys_offset + i*MULTI_ENCRYPTION_FORMAT_v001_ENCRYPTED_KEY_SIZE , MULTI_ENCRYPTION_FORMAT_v001_ENCRYPTED_KEY_SIZE, in+IV_offset, privateKey);
|
succeed = EVP_OpenInit(&ctx, EVP_aes_128_cbc(),in + encrypted_keys_offset + i*MULTI_ENCRYPTION_FORMAT_v001_ENCRYPTED_KEY_SIZE , MULTI_ENCRYPTION_FORMAT_v001_ENCRYPTED_KEY_SIZE, in+IV_offset, privateKey);
|
||||||
|
|
||||||
|
if(!succeed)
|
||||||
|
EVP_CIPHER_CTX_cleanup(&ctx);
|
||||||
|
|
||||||
#ifdef GXS_SECURITY_DEBUG
|
#ifdef GXS_SECURITY_DEBUG
|
||||||
std::cerr << " encrypted key at offset " << encrypted_keys_offset + i*MULTI_ENCRYPTION_FORMAT_v001_ENCRYPTED_KEY_SIZE << ": " << succeed << std::endl;
|
std::cerr << " encrypted key at offset " << encrypted_keys_offset + i*MULTI_ENCRYPTION_FORMAT_v001_ENCRYPTED_KEY_SIZE << ": " << succeed << std::endl;
|
||||||
#endif
|
#endif
|
||||||
|
@ -890,6 +913,7 @@ bool GxsSecurity::decrypt(uint8_t *& out, uint32_t & outlen, const uint8_t *in,
|
||||||
#ifdef GXS_SECURITY_DEBUG
|
#ifdef GXS_SECURITY_DEBUG
|
||||||
std::cerr << " successfully decrypted block of size " << outlen << std::endl;
|
std::cerr << " successfully decrypted block of size " << outlen << std::endl;
|
||||||
#endif
|
#endif
|
||||||
|
EVP_CIPHER_CTX_cleanup(&ctx);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
catch(std::exception& e)
|
catch(std::exception& e)
|
||||||
|
@ -905,6 +929,7 @@ bool GxsSecurity::decrypt(uint8_t *& out, uint32_t & outlen, const uint8_t *in,
|
||||||
out = NULL ;
|
out = NULL ;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
EVP_CIPHER_CTX_cleanup(&ctx);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1626,8 +1626,10 @@ void RsGxsNetService::recvNxsItemQueue()
|
||||||
GXSNETDEBUG_P_(item->PeerId()) << " decrypted item " << std::endl;
|
GXSNETDEBUG_P_(item->PeerId()) << " decrypted item " << std::endl;
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
#ifdef NXS_NET_DEBUG_7
|
||||||
else
|
else
|
||||||
std::cerr << "(EE) Could not decrypt incoming encrypted NXS item. Probably a friend subscribed to a circle-restricted group." << std::endl;
|
GXSNETDEBUG_P_(item->PeerId()) << " (EE) Could not decrypt incoming encrypted NXS item. Probably a friend subscribed to a circle-restricted group." << std::endl;
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
switch(ni->PacketSubType())
|
switch(ni->PacketSubType())
|
||||||
|
@ -1638,6 +1640,7 @@ void RsGxsNetService::recvNxsItemQueue()
|
||||||
case RS_PKT_SUBTYPE_NXS_GRP_PUBLISH_KEY_ITEM:handleRecvPublishKeys (dynamic_cast<RsNxsGroupPublishKeyItem*>(ni)) ; break ;
|
case RS_PKT_SUBTYPE_NXS_GRP_PUBLISH_KEY_ITEM:handleRecvPublishKeys (dynamic_cast<RsNxsGroupPublishKeyItem*>(ni)) ; break ;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
|
if(ni->PacketSubType() != RS_PKT_SUBTYPE_NXS_ENCRYPTED_DATA_ITEM)
|
||||||
std::cerr << "Unhandled item subtype " << (uint32_t) ni->PacketSubType() << " in RsGxsNetService: " << std::endl; break;
|
std::cerr << "Unhandled item subtype " << (uint32_t) ni->PacketSubType() << " in RsGxsNetService: " << std::endl; break;
|
||||||
}
|
}
|
||||||
delete item ;
|
delete item ;
|
||||||
|
@ -3861,7 +3864,9 @@ bool RsGxsNetService::decryptSingleNxsItem(const RsNxsEncryptedDataItem *encrypt
|
||||||
|
|
||||||
if(!GxsSecurity::decrypt(decrypted_mem,decrypted_len, (uint8_t*)encrypted_item->encrypted_data.bin_data,encrypted_item->encrypted_data.bin_len,private_keys))
|
if(!GxsSecurity::decrypt(decrypted_mem,decrypted_len, (uint8_t*)encrypted_item->encrypted_data.bin_data,encrypted_item->encrypted_data.bin_len,private_keys))
|
||||||
{
|
{
|
||||||
std::cerr << "Failed! Cannot decrypt this item." << std::endl;
|
#ifdef NXS_NET_DEBUG_7
|
||||||
|
GXSNETDEBUG_P_(encrypted_item->PeerId()) << " Failed! Cannot decrypt this item." << std::endl;
|
||||||
|
#endif
|
||||||
decrypted_mem = NULL ; // for safety
|
decrypted_mem = NULL ; // for safety
|
||||||
return false ;
|
return false ;
|
||||||
}
|
}
|
||||||
|
@ -3876,6 +3881,7 @@ bool RsGxsNetService::decryptSingleNxsItem(const RsNxsEncryptedDataItem *encrypt
|
||||||
if(decrypted_mem!=NULL)
|
if(decrypted_mem!=NULL)
|
||||||
{
|
{
|
||||||
ditem = RsNxsSerialiser(mServType).deserialise(decrypted_mem,&decrypted_len) ;
|
ditem = RsNxsSerialiser(mServType).deserialise(decrypted_mem,&decrypted_len) ;
|
||||||
|
free(decrypted_mem) ;
|
||||||
|
|
||||||
if(ditem != NULL)
|
if(ditem != NULL)
|
||||||
{
|
{
|
||||||
|
|
|
@ -1074,6 +1074,12 @@ int pqissl::Initiate_SSL_Connection()
|
||||||
"pqissl::Initiate_SSL_Connection() SSL Connection Okay");
|
"pqissl::Initiate_SSL_Connection() SSL Connection Okay");
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
if(ssl_connection != NULL)
|
||||||
|
{
|
||||||
|
SSL_shutdown(ssl_connection);
|
||||||
|
SSL_free(ssl_connection) ;
|
||||||
|
}
|
||||||
|
|
||||||
ssl_connection = ssl;
|
ssl_connection = ssl;
|
||||||
|
|
||||||
net_internal_SSL_set_fd(ssl, sockfd);
|
net_internal_SSL_set_fd(ssl, sockfd);
|
||||||
|
|
|
@ -366,11 +366,7 @@ int RsInit::InitRetroShare(int argcIgnored, char **argvIgnored, bool strictCheck
|
||||||
#ifdef LOCALNET_TESTING
|
#ifdef LOCALNET_TESTING
|
||||||
>> parameter('R',"restrict-port" ,portRestrictions ,"port1-port2","Apply port restriction" ,false)
|
>> parameter('R',"restrict-port" ,portRestrictions ,"port1-port2","Apply port restriction" ,false)
|
||||||
#endif
|
#endif
|
||||||
#ifdef __APPLE__
|
|
||||||
>> help('h',"help","Display this Help") ;
|
>> help('h',"help","Display this Help") ;
|
||||||
#else
|
|
||||||
>> help() ;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
as.defaultErrorHandling(true) ;
|
as.defaultErrorHandling(true) ;
|
||||||
|
|
||||||
|
|
|
@ -726,7 +726,7 @@ bool p3turtle::loadList(std::list<RsItem*>& load)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
delete vitem ;
|
delete *it ;
|
||||||
}
|
}
|
||||||
load.clear() ;
|
load.clear() ;
|
||||||
return true ;
|
return true ;
|
||||||
|
|
|
@ -141,15 +141,10 @@ namespace
|
||||||
inline OptionHolder(char s,
|
inline OptionHolder(char s,
|
||||||
const char* l,
|
const char* l,
|
||||||
const char* desc);
|
const char* desc);
|
||||||
#ifdef __APPLE__
|
|
||||||
friend OptionHolder help(char s,
|
friend OptionHolder help(char s,
|
||||||
const char* l,
|
const char* l,
|
||||||
const char* desc);
|
const char* desc);
|
||||||
#else
|
|
||||||
friend OptionHolder help(char s='h',
|
|
||||||
const char* l="help",
|
|
||||||
const char* desc="Display this help");
|
|
||||||
#endif
|
|
||||||
private:
|
private:
|
||||||
std::string shortName_;
|
std::string shortName_;
|
||||||
std::string longName_;
|
std::string longName_;
|
||||||
|
|
|
@ -219,8 +219,8 @@ TransfersDialog::TransfersDialog(QWidget *parent)
|
||||||
|
|
||||||
// workaround for Qt bug, should be solved in next Qt release 4.7.0
|
// workaround for Qt bug, should be solved in next Qt release 4.7.0
|
||||||
// http://bugreports.qt.nokia.com/browse/QTBUG-8270
|
// http://bugreports.qt.nokia.com/browse/QTBUG-8270
|
||||||
QShortcut *Shortcut = new QShortcut(QKeySequence (Qt::Key_Delete), ui.downloadList, 0, 0, Qt::WidgetShortcut);
|
mShortcut = new QShortcut(QKeySequence (Qt::Key_Delete), ui.downloadList, 0, 0, Qt::WidgetShortcut);
|
||||||
connect(Shortcut, SIGNAL(activated()), this, SLOT( cancel ()));
|
connect(mShortcut, SIGNAL(activated()), this, SLOT( cancel ()));
|
||||||
|
|
||||||
//Selection Setup
|
//Selection Setup
|
||||||
selection = ui.downloadList->selectionModel();
|
selection = ui.downloadList->selectionModel();
|
||||||
|
@ -942,7 +942,8 @@ int TransfersDialog::addItem(int row, const FileInfo &fileInfo)
|
||||||
|
|
||||||
qlonglong completed = fileInfo.transfered;
|
qlonglong completed = fileInfo.transfered;
|
||||||
qlonglong remaining = fileInfo.size - fileInfo.transfered;
|
qlonglong remaining = fileInfo.size - fileInfo.transfered;
|
||||||
qlonglong downloadtime = (fileInfo.size - fileInfo.transfered) / (fileInfo.tfRate * 1024.0);
|
|
||||||
|
qlonglong downloadtime = (fileInfo.tfRate > 0)?( (fileInfo.size - fileInfo.transfered) / (fileInfo.tfRate * 1024.0) ) : 0 ;
|
||||||
qint64 qi64LastDL = fileInfo.lastTS ; //std::numeric_limits<qint64>::max();
|
qint64 qi64LastDL = fileInfo.lastTS ; //std::numeric_limits<qint64>::max();
|
||||||
|
|
||||||
if (qi64LastDL == 0) // file is complete, or any raison why the time has not been set properly
|
if (qi64LastDL == 0) // file is complete, or any raison why the time has not been set properly
|
||||||
|
@ -1355,7 +1356,7 @@ void TransfersDialog::insertTransfers()
|
||||||
qlonglong fileSize = info.size;
|
qlonglong fileSize = info.size;
|
||||||
qlonglong completed = pit->transfered;
|
qlonglong completed = pit->transfered;
|
||||||
// double progress = (info.size > 0)?(pit->transfered * 100.0 / info.size):0.0;
|
// double progress = (info.size > 0)?(pit->transfered * 100.0 / info.size):0.0;
|
||||||
qlonglong remaining = (info.size - pit->transfered) / (pit->tfRate * 1024.0);
|
qlonglong remaining = (pit->tfRate>0)?((info.size - pit->transfered) / (pit->tfRate * 1024.0)):0;
|
||||||
|
|
||||||
// Estimate the completion. We need something more accurate, meaning that we need to
|
// Estimate the completion. We need something more accurate, meaning that we need to
|
||||||
// transmit the completion info.
|
// transmit the completion info.
|
||||||
|
|
|
@ -31,6 +31,7 @@
|
||||||
|
|
||||||
#define IMAGE_TRANSFERS ":/icons/ktorrent_128.png"
|
#define IMAGE_TRANSFERS ":/icons/ktorrent_128.png"
|
||||||
|
|
||||||
|
class QShortcut;
|
||||||
class DLListDelegate;
|
class DLListDelegate;
|
||||||
class ULListDelegate;
|
class ULListDelegate;
|
||||||
class QStandardItemModel;
|
class QStandardItemModel;
|
||||||
|
@ -243,6 +244,8 @@ private:
|
||||||
QString downloads;
|
QString downloads;
|
||||||
QString uploads;
|
QString uploads;
|
||||||
|
|
||||||
|
QShortcut *mShortcut ;
|
||||||
|
|
||||||
/** Qt Designer generated object */
|
/** Qt Designer generated object */
|
||||||
Ui::TransfersDialog ui;
|
Ui::TransfersDialog ui;
|
||||||
|
|
||||||
|
|
|
@ -1725,7 +1725,11 @@ void ChatWidget::quote()
|
||||||
|
|
||||||
void ChatWidget::dropPlacemark()
|
void ChatWidget::dropPlacemark()
|
||||||
{
|
{
|
||||||
ui->textBrowser->append("----------");
|
ui->textBrowser->moveCursor(QTextCursor::End); // *append* inserts text at end but with formatting in effect at
|
||||||
|
ui->textBrowser->append("----------"); // current cursor position, such as in the middle of a hotlink,
|
||||||
|
// which would be strange. This OTOH inserts text with
|
||||||
|
// formatting in effect on the last line, which may be strange
|
||||||
|
// or not.
|
||||||
}
|
}
|
||||||
|
|
||||||
void ChatWidget::saveImage()
|
void ChatWidget::saveImage()
|
||||||
|
|
|
@ -10,6 +10,7 @@ SubscribeToolButton::SubscribeToolButton(QWidget *parent) :
|
||||||
{
|
{
|
||||||
mSubscribed = false;
|
mSubscribed = false;
|
||||||
|
|
||||||
|
mMenu = NULL ;
|
||||||
setToolButtonStyle(Qt::ToolButtonTextBesideIcon);
|
setToolButtonStyle(Qt::ToolButtonTextBesideIcon);
|
||||||
|
|
||||||
#ifdef USE_MENUBUTTONPOPUP
|
#ifdef USE_MENUBUTTONPOPUP
|
||||||
|
@ -46,14 +47,18 @@ void SubscribeToolButton::updateUi()
|
||||||
setIcon(QIcon(":/images/accepted16.png"));
|
setIcon(QIcon(":/images/accepted16.png"));
|
||||||
setText(tr("Subscribed"));
|
setText(tr("Subscribed"));
|
||||||
|
|
||||||
QMenu *menu = new QMenu;
|
if(mMenu != NULL) // that's because setMenu does not give away memory ownership
|
||||||
menu->addAction(QIcon(":/images/cancel.png"), tr("Unsubscribe"), this, SLOT(unsubscribePrivate()));
|
delete mMenu ;
|
||||||
|
|
||||||
|
mMenu = new QMenu;
|
||||||
|
mMenu->addAction(QIcon(":/images/cancel.png"), tr("Unsubscribe"), this, SLOT(unsubscribePrivate()));
|
||||||
|
|
||||||
if (!mSubscribedActions.empty()) {
|
if (!mSubscribedActions.empty()) {
|
||||||
menu->addSeparator();
|
mMenu->addSeparator();
|
||||||
menu->addActions(mSubscribedActions);
|
mMenu->addActions(mSubscribedActions);
|
||||||
}
|
}
|
||||||
setMenu(menu);
|
|
||||||
|
setMenu(mMenu);
|
||||||
|
|
||||||
#ifndef USE_MENUBUTTONPOPUP
|
#ifndef USE_MENUBUTTONPOPUP
|
||||||
disconnect(this, SIGNAL(clicked()), this, SLOT(subscribePrivate()));
|
disconnect(this, SIGNAL(clicked()), this, SLOT(subscribePrivate()));
|
||||||
|
|
|
@ -26,6 +26,7 @@ private:
|
||||||
private:
|
private:
|
||||||
bool mSubscribed;
|
bool mSubscribed;
|
||||||
QList<QAction*> mSubscribedActions;
|
QList<QAction*> mSubscribedActions;
|
||||||
|
QMenu *mMenu ;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // SUBSCRIBETOOLBUTTON_H
|
#endif // SUBSCRIBETOOLBUTTON_H
|
||||||
|
|
|
@ -259,7 +259,7 @@ void GraphWidget::keyPressEvent(QKeyEvent *event)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void convolveWithGaussian(double *forceMap,int S,int /*s*/)
|
static void convolveWithGaussian(double *forceMap,unsigned int S,int /*s*/)
|
||||||
{
|
{
|
||||||
static double *bf = NULL ;
|
static double *bf = NULL ;
|
||||||
|
|
||||||
|
@ -267,8 +267,8 @@ static void convolveWithGaussian(double *forceMap,int S,int /*s*/)
|
||||||
{
|
{
|
||||||
bf = new double[S*S*2] ;
|
bf = new double[S*S*2] ;
|
||||||
|
|
||||||
for(int i=0;i<S;++i)
|
for(unsigned int i=0;i<S;++i)
|
||||||
for(int j=0;j<S;++j)
|
for(unsigned int j=0;j<S;++j)
|
||||||
{
|
{
|
||||||
int x = (i<S/2)?i:(S-i) ;
|
int x = (i<S/2)?i:(S-i) ;
|
||||||
int y = (j<S/2)?j:(S-j) ;
|
int y = (j<S/2)?j:(S-j) ;
|
||||||
|
@ -284,8 +284,8 @@ static void convolveWithGaussian(double *forceMap,int S,int /*s*/)
|
||||||
unsigned long nn[2] = {S,S};
|
unsigned long nn[2] = {S,S};
|
||||||
fourn(&forceMap[-1],&nn[-1],2,1) ;
|
fourn(&forceMap[-1],&nn[-1],2,1) ;
|
||||||
|
|
||||||
for(int i=0;i<S;++i)
|
for(unsigned int i=0;i<S;++i)
|
||||||
for(int j=0;j<S;++j)
|
for(unsigned int j=0;j<S;++j)
|
||||||
{
|
{
|
||||||
float a = forceMap[2*(i+S*j)]*bf[2*(i+S*j)] - forceMap[2*(i+S*j)+1]*bf[2*(i+S*j)+1] ;
|
float a = forceMap[2*(i+S*j)]*bf[2*(i+S*j)] - forceMap[2*(i+S*j)+1]*bf[2*(i+S*j)+1] ;
|
||||||
float b = forceMap[2*(i+S*j)]*bf[2*(i+S*j)+1] + forceMap[2*(i+S*j)+1]*bf[2*(i+S*j)] ;
|
float b = forceMap[2*(i+S*j)]*bf[2*(i+S*j)+1] + forceMap[2*(i+S*j)+1]*bf[2*(i+S*j)] ;
|
||||||
|
@ -296,7 +296,7 @@ static void convolveWithGaussian(double *forceMap,int S,int /*s*/)
|
||||||
|
|
||||||
fourn(&forceMap[-1],&nn[-1],2,-1) ;
|
fourn(&forceMap[-1],&nn[-1],2,-1) ;
|
||||||
|
|
||||||
for(int i=0;i<S*S*2;++i)
|
for(unsigned int i=0;i<S*S*2;++i)
|
||||||
forceMap[i] /= S*S;
|
forceMap[i] /= S*S;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -362,21 +362,21 @@ Rshare::showUsageMessageBox()
|
||||||
out << "<table>";
|
out << "<table>";
|
||||||
//out << trow(tcol("-"ARG_HELP) +
|
//out << trow(tcol("-"ARG_HELP) +
|
||||||
// tcol(tr("Displays this usage message and exits.")));
|
// tcol(tr("Displays this usage message and exits.")));
|
||||||
out << trow(tcol("-"ARG_RESET) +
|
out << trow(tcol("-" ARG_RESET) +
|
||||||
tcol(tr("Resets ALL stored RetroShare settings.")));
|
tcol(tr("Resets ALL stored RetroShare settings.")));
|
||||||
out << trow(tcol("-"ARG_DATADIR" <dir>") +
|
out << trow(tcol("-" ARG_DATADIR" <dir>") +
|
||||||
tcol(tr("Sets the directory RetroShare uses for data files.")));
|
tcol(tr("Sets the directory RetroShare uses for data files.")));
|
||||||
out << trow(tcol("-"ARG_LOGFILE" <file>") +
|
out << trow(tcol("-" ARG_LOGFILE" <file>") +
|
||||||
tcol(tr("Sets the name and location of RetroShare's logfile.")));
|
tcol(tr("Sets the name and location of RetroShare's logfile.")));
|
||||||
out << trow(tcol("-"ARG_LOGLEVEL" <level>") +
|
out << trow(tcol("-" ARG_LOGLEVEL" <level>") +
|
||||||
tcol(tr("Sets the verbosity of RetroShare's logging.") +
|
tcol(tr("Sets the verbosity of RetroShare's logging.") +
|
||||||
"<br>[" + Log::logLevels().join("|") +"]"));
|
"<br>[" + Log::logLevels().join("|") +"]"));
|
||||||
out << trow(tcol("-"ARG_GUISTYLE" <style>") +
|
out << trow(tcol("-" ARG_GUISTYLE" <style>") +
|
||||||
tcol(tr("Sets RetroShare's interface style.") +
|
tcol(tr("Sets RetroShare's interface style.") +
|
||||||
"<br>[" + QStyleFactory::keys().join("|") + "]"));
|
"<br>[" + QStyleFactory::keys().join("|") + "]"));
|
||||||
out << trow(tcol("-"ARG_GUISTYLESHEET" <stylesheet>") +
|
out << trow(tcol("-" ARG_GUISTYLESHEET" <stylesheet>") +
|
||||||
tcol(tr("Sets RetroShare's interface stylesheets.")));
|
tcol(tr("Sets RetroShare's interface stylesheets.")));
|
||||||
out << trow(tcol("-"ARG_LANGUAGE" <language>") +
|
out << trow(tcol("-" ARG_LANGUAGE" <language>") +
|
||||||
tcol(tr("Sets RetroShare's language.") +
|
tcol(tr("Sets RetroShare's language.") +
|
||||||
"<br>[" + LanguageSupport::languageCodes().join("|") + "]"));
|
"<br>[" + LanguageSupport::languageCodes().join("|") + "]"));
|
||||||
out << "</table>";
|
out << "</table>";
|
||||||
|
|
|
@ -17,6 +17,10 @@
|
||||||
* along with this program; if not, write to the Free Software
|
* along with this program; if not, write to the Free Software
|
||||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
||||||
* Boston, MA 02110-1301, USA.
|
* Boston, MA 02110-1301, USA.
|
||||||
|
*
|
||||||
|
* ccr . 2016 Jan 30 . Change regular expression(s) for identifying
|
||||||
|
* . . hotlinks in feral text.
|
||||||
|
*
|
||||||
****************************************************************/
|
****************************************************************/
|
||||||
|
|
||||||
#include <QApplication>
|
#include <QApplication>
|
||||||
|
@ -56,7 +60,7 @@ protected:
|
||||||
|
|
||||||
public:
|
public:
|
||||||
const EmbeddedType myType;
|
const EmbeddedType myType;
|
||||||
QRegExp myRE;
|
QList<QRegExp> myREs;
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -67,10 +71,42 @@ class EmbedInHtmlAhref : public EmbedInHtml
|
||||||
public:
|
public:
|
||||||
EmbedInHtmlAhref() : EmbedInHtml(Ahref)
|
EmbedInHtmlAhref() : EmbedInHtml(Ahref)
|
||||||
{
|
{
|
||||||
myRE.setPattern("(\\bretroshare://[^\\s]*)|(\\bhttps?://[^\\s]*)|(\\bfile://[^\\s]*)|(\\bwww\\.[^\\s]*)");
|
// myRE.setPattern("(\\bretroshare://[^\\s]*)|(\\bhttps?://[^\\s]*)|(\\bfile://[^\\s]*)|(\\bwww\\.[^\\s]*)");
|
||||||
|
|
||||||
|
// The following regular expressions for finding URLs in
|
||||||
|
// plain text are borrowed from *gnome-terminal*:
|
||||||
|
|
||||||
|
QString regPassCharset = "[-\\w,?;\\.:/!%$^*&~\\\"#']";
|
||||||
|
QString regHost = "[-\\w]+(\\.[-\\w]+)*";
|
||||||
|
QString regPort = "(?:\\:\\d{1,5})?";
|
||||||
|
QString regPathCharset = "[-\\w_$\\.+!*,;@&=?/~#%]";
|
||||||
|
QString regPathTermSet = "[^\\]'.}<>) \\t\\r\\n,\\\"]";
|
||||||
|
QStringList regSchemes;
|
||||||
|
// regSchemes.append("news:");
|
||||||
|
// regSchemes.append("telnet:");
|
||||||
|
// regSchemes.append("nntp:");
|
||||||
|
// regSchemes.append("file:/");
|
||||||
|
regSchemes.append("https?:");
|
||||||
|
// regSchemes.append("ftps?:");
|
||||||
|
// regSchemes.append("sftp:");
|
||||||
|
// regSchemes.append("webcal:");
|
||||||
|
regSchemes.append("retroshare:");
|
||||||
|
QString regScheme = "((?:" + regSchemes.join(")|(?:") + "))";
|
||||||
|
QString regUserPass = "[-\\w]+(?:%s+)?" % regPassCharset;
|
||||||
|
QString regUrlPath = "(?:(/" + regPathCharset + "+(?:[(]" + regPathCharset +"*[)])*" + regPathCharset + "*)*" + regPathTermSet + ")?";
|
||||||
|
QStringList regHotLinkFinders;
|
||||||
|
regHotLinkFinders.append(regScheme + "//(?:" + regUserPass + "@)?"+ regHost + regPort + regUrlPath);
|
||||||
|
// regHotLinkFinders.append("(?:(?:www)|(?:ftp))[-\\w]*\\." + regHost + regPort + regUrlPath);
|
||||||
|
// regHotLinkFinders.append("(?:(?:callto:)|(?:h323:)|(?:sip:))[-\\w][-\\w\\.]*(?:" + regPort + "/[a-z0-9]+)?@" + regHost);
|
||||||
|
// regHotLinkFinders.append("(?:mailto:)?[-\\w][-\\w\\.]*@[-\\w]+\\." + regHost);
|
||||||
|
// regHotLinkFinders.append("news:[\\w^_{|}~!\\\"#$%&'()*+,\\./;:=?`]+");
|
||||||
|
while (!regHotLinkFinders.isEmpty()) {
|
||||||
|
myREs.append(QRegExp(regHotLinkFinders.takeFirst(), Qt::CaseInsensitive));
|
||||||
|
};
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This class is used to store information for embedding smileys into <img/> tags.
|
* This class is used to store information for embedding smileys into <img/> tags.
|
||||||
*
|
*
|
||||||
|
@ -134,7 +170,7 @@ void RsHtml::initEmoticons(const QHash< QString, QString >& hash)
|
||||||
*/
|
*/
|
||||||
}
|
}
|
||||||
newRE.chop(1); // remove last |
|
newRE.chop(1); // remove last |
|
||||||
defEmbedImg.myRE.setPattern(newRE);
|
defEmbedImg.myREs.append(QRegExp(newRE));
|
||||||
}
|
}
|
||||||
|
|
||||||
bool RsHtml::canReplaceAnchor(QDomDocument &/*doc*/, QDomElement &/*element*/, const RetroShareLink &link)
|
bool RsHtml::canReplaceAnchor(QDomDocument &/*doc*/, QDomElement &/*element*/, const RetroShareLink &link)
|
||||||
|
@ -243,7 +279,7 @@ void RsHtml::replaceAnchorWithImg(QDomDocument &doc, QDomElement &element, QText
|
||||||
* nodes. Any other kind of node is terminal.
|
* nodes. Any other kind of node is terminal.
|
||||||
*
|
*
|
||||||
* If the node is of type Text, its data is checked against the user-provided
|
* If the node is of type Text, its data is checked against the user-provided
|
||||||
* regular expression. If there is a match, the text is cut in three parts: the
|
* regular expression(s). If there is a match, the text is cut in three parts: the
|
||||||
* preceding part that will be inserted before, the part to be replaced, and the
|
* preceding part that will be inserted before, the part to be replaced, and the
|
||||||
* following part which will be itself checked against the regular expression.
|
* following part which will be itself checked against the regular expression.
|
||||||
*
|
*
|
||||||
|
@ -252,13 +288,10 @@ void RsHtml::replaceAnchorWithImg(QDomDocument &doc, QDomElement &element, QText
|
||||||
*
|
*
|
||||||
* @param[in] doc The whole DOM tree, necessary to create new nodes
|
* @param[in] doc The whole DOM tree, necessary to create new nodes
|
||||||
* @param[in,out] currentElement The current node (which is of type Element)
|
* @param[in,out] currentElement The current node (which is of type Element)
|
||||||
* @param[in] embedInfos The regular expression and the type of embedding to use
|
* @param[in] embedInfos The regular expression(s) and the type of embedding to use
|
||||||
*/
|
*/
|
||||||
void RsHtml::embedHtml(QTextDocument *textDocument, QDomDocument& doc, QDomElement& currentElement, EmbedInHtml& embedInfos, ulong flag)
|
void RsHtml::embedHtml(QTextDocument *textDocument, QDomDocument& doc, QDomElement& currentElement, EmbedInHtml& embedInfos, ulong flag)
|
||||||
{
|
{
|
||||||
if(embedInfos.myRE.pattern().length() == 0) // we'll get stuck with an empty regexp
|
|
||||||
return;
|
|
||||||
|
|
||||||
QDomNodeList children = currentElement.childNodes();
|
QDomNodeList children = currentElement.childNodes();
|
||||||
for(uint index = 0; index < (uint)children.length(); index++) {
|
for(uint index = 0; index < (uint)children.length(); index++) {
|
||||||
QDomNode node = children.item(index);
|
QDomNode node = children.item(index);
|
||||||
|
@ -300,13 +333,18 @@ void RsHtml::embedHtml(QTextDocument *textDocument, QDomDocument& doc, QDomEleme
|
||||||
else if(node.isText()) {
|
else if(node.isText()) {
|
||||||
// child is a text, we parse it
|
// child is a text, we parse it
|
||||||
QString tempText = node.toText().data();
|
QString tempText = node.toText().data();
|
||||||
if(embedInfos.myRE.indexIn(tempText) == -1)
|
for (int patNdx = 0; patNdx < embedInfos.myREs.size(); ++patNdx) {
|
||||||
|
QRegExp myRE = embedInfos.myREs.at(patNdx);
|
||||||
|
if(myRE.pattern().length() == 0) // we'll get stuck with an empty regexp
|
||||||
|
return;
|
||||||
|
|
||||||
|
if(myRE.indexIn(tempText) == -1)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
// there is at least one link inside, we start replacing
|
// there is at least one link inside, we start replacing
|
||||||
int currentPos = 0;
|
int currentPos = 0;
|
||||||
int nextPos = 0;
|
int nextPos = 0;
|
||||||
while((nextPos = embedInfos.myRE.indexIn(tempText, currentPos)) != -1) {
|
while((nextPos = myRE.indexIn(tempText, currentPos)) != -1) {
|
||||||
// if nextPos == 0 it means the text begins by a link
|
// if nextPos == 0 it means the text begins by a link
|
||||||
if(nextPos > 0) {
|
if(nextPos > 0) {
|
||||||
QDomText textPart = doc.createTextNode(tempText.mid(currentPos, nextPos - currentPos));
|
QDomText textPart = doc.createTextNode(tempText.mid(currentPos, nextPos - currentPos));
|
||||||
|
@ -320,10 +358,10 @@ void RsHtml::embedHtml(QTextDocument *textDocument, QDomDocument& doc, QDomEleme
|
||||||
case Ahref:
|
case Ahref:
|
||||||
{
|
{
|
||||||
insertedTag = doc.createElement("a");
|
insertedTag = doc.createElement("a");
|
||||||
insertedTag.setAttribute("href", embedInfos.myRE.cap(0));
|
insertedTag.setAttribute("href", myRE.cap(0));
|
||||||
insertedTag.appendChild(doc.createTextNode(embedInfos.myRE.cap(0)));
|
insertedTag.appendChild(doc.createTextNode(myRE.cap(0)));
|
||||||
|
|
||||||
RetroShareLink link(embedInfos.myRE.cap(0));
|
RetroShareLink link(myRE.cap(0));
|
||||||
if (link.valid()) {
|
if (link.valid()) {
|
||||||
QString title = link.title();
|
QString title = link.title();
|
||||||
if (!title.isEmpty()) {
|
if (!title.isEmpty()) {
|
||||||
|
@ -340,11 +378,11 @@ void RsHtml::embedHtml(QTextDocument *textDocument, QDomDocument& doc, QDomEleme
|
||||||
{
|
{
|
||||||
insertedTag = doc.createElement("img");
|
insertedTag = doc.createElement("img");
|
||||||
const EmbedInHtmlImg& embedImg = static_cast<const EmbedInHtmlImg&>(embedInfos);
|
const EmbedInHtmlImg& embedImg = static_cast<const EmbedInHtmlImg&>(embedInfos);
|
||||||
// embedInfos.myRE.cap(0) may include spaces at the end/beginning -> trim!
|
// myRE.cap(0) may include spaces at the end/beginning -> trim!
|
||||||
insertedTag.setAttribute("src", embedImg.smileys[embedInfos.myRE.cap(0).trimmed()]);
|
insertedTag.setAttribute("src", embedImg.smileys[myRE.cap(0).trimmed()]);
|
||||||
/*
|
/*
|
||||||
* NOTE
|
* NOTE
|
||||||
* Trailing spaces are matched, too. This leads to embedInfos.myRE.matchedLength() being incorrect.
|
* Trailing spaces are matched, too. This leads to myRE.matchedLength() being incorrect.
|
||||||
* This hack reduces nextPos by one so that the new value of currentPos is calculated corretly.
|
* This hack reduces nextPos by one so that the new value of currentPos is calculated corretly.
|
||||||
* This is needed to match multiple smileys since the leading whitespace in front of a smiley is required!
|
* This is needed to match multiple smileys since the leading whitespace in front of a smiley is required!
|
||||||
*
|
*
|
||||||
|
@ -353,7 +391,7 @@ void RsHtml::embedHtml(QTextDocument *textDocument, QDomDocument& doc, QDomEleme
|
||||||
* NOTE
|
* NOTE
|
||||||
* Preceding spaces are also matched and removed.
|
* Preceding spaces are also matched and removed.
|
||||||
*/
|
*/
|
||||||
if(embedInfos.myRE.cap(0).endsWith(' '))
|
if(myRE.cap(0).endsWith(' '))
|
||||||
nextPos--;
|
nextPos--;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
@ -362,7 +400,7 @@ void RsHtml::embedHtml(QTextDocument *textDocument, QDomDocument& doc, QDomEleme
|
||||||
currentElement.insertBefore(insertedTag, node);
|
currentElement.insertBefore(insertedTag, node);
|
||||||
index++;
|
index++;
|
||||||
|
|
||||||
currentPos = nextPos + embedInfos.myRE.matchedLength();
|
currentPos = nextPos + myRE.matchedLength();
|
||||||
}
|
}
|
||||||
|
|
||||||
// text after the last link, only if there's one, don't touch the index
|
// text after the last link, only if there's one, don't touch the index
|
||||||
|
@ -375,10 +413,18 @@ void RsHtml::embedHtml(QTextDocument *textDocument, QDomDocument& doc, QDomEleme
|
||||||
index--;
|
index--;
|
||||||
|
|
||||||
currentElement.removeChild(node);
|
currentElement.removeChild(node);
|
||||||
|
break;
|
||||||
|
// We'd better not expect that
|
||||||
|
// subsequent hotlink patterns
|
||||||
|
// wouldn't also match replacements
|
||||||
|
// we've already made. They might, so
|
||||||
|
// skip 'em to be safe.
|
||||||
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Save space and tab out of bracket that XML loose.
|
* Save space and tab out of bracket that XML loose.
|
||||||
*
|
*
|
||||||
|
@ -612,7 +658,7 @@ static void findBestColor(QString &val, qreal bglum, qreal desiredContrast)
|
||||||
*/
|
*/
|
||||||
static void optimizeHtml(QDomDocument& doc
|
static void optimizeHtml(QDomDocument& doc
|
||||||
, QDomElement& currentElement
|
, QDomElement& currentElement
|
||||||
, QHash<QString, QStringList*> &stylesList
|
, QHash<QString, QStringList> &stylesList
|
||||||
, QHash<QString, QString> &knownStyle)
|
, QHash<QString, QString> &knownStyle)
|
||||||
{
|
{
|
||||||
if (doc.documentElement().namedItem("style").toElement().attributeNode("RSOptimized").isAttr()) {
|
if (doc.documentElement().namedItem("style").toElement().attributeNode("RSOptimized").isAttr()) {
|
||||||
|
@ -631,10 +677,10 @@ static void optimizeHtml(QDomDocument& doc
|
||||||
QString keyvalue = pair.at(1);
|
QString keyvalue = pair.at(1);
|
||||||
keyvalue.replace(";","");
|
keyvalue.replace(";","");
|
||||||
QStringList classUsingIt(pair.at(0).split(','));
|
QStringList classUsingIt(pair.at(0).split(','));
|
||||||
QStringList* exported = new QStringList();
|
QStringList exported ;
|
||||||
foreach (QString keyVal, classUsingIt) {
|
foreach (QString keyVal, classUsingIt) {
|
||||||
if(!keyVal.trimmed().isEmpty()) {
|
if(!keyVal.trimmed().isEmpty()) {
|
||||||
exported->append(keyVal.trimmed().replace(".",""));
|
exported.append(keyVal.trimmed().replace(".",""));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -759,14 +805,10 @@ static void optimizeHtml(QDomDocument& doc
|
||||||
foreach (QString pair, styles) {
|
foreach (QString pair, styles) {
|
||||||
pair.replace(" ","");
|
pair.replace(" ","");
|
||||||
if (!pair.isEmpty()) {
|
if (!pair.isEmpty()) {
|
||||||
QStringList* stylesListItem = stylesList.value(pair);
|
QStringList& stylesListItem = stylesList[pair];
|
||||||
if(!stylesListItem){
|
|
||||||
// If value doesn't exist create it
|
|
||||||
stylesListItem = new QStringList();
|
|
||||||
stylesList.insert(pair, stylesListItem);
|
|
||||||
}
|
|
||||||
//Add the new class to this value
|
//Add the new class to this value
|
||||||
stylesListItem->push_back(className);
|
stylesListItem.push_back(className);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -800,7 +842,7 @@ static void optimizeHtml(QDomDocument& doc
|
||||||
* @param desiredMinimumFontSize: Minimum font size.
|
* @param desiredMinimumFontSize: Minimum font size.
|
||||||
*/
|
*/
|
||||||
static void styleCreate(QDomDocument& doc
|
static void styleCreate(QDomDocument& doc
|
||||||
, QHash<QString, QStringList*> stylesList
|
, QHash<QString, QStringList>& stylesList
|
||||||
, unsigned int flag
|
, unsigned int flag
|
||||||
, qreal bglum
|
, qreal bglum
|
||||||
, qreal desiredContrast
|
, qreal desiredContrast
|
||||||
|
@ -840,12 +882,12 @@ static void styleCreate(QDomDocument& doc
|
||||||
|
|
||||||
QString style = "";
|
QString style = "";
|
||||||
|
|
||||||
QHashIterator<QString, QStringList*> it(stylesList);
|
QHashIterator<QString, QStringList> it(stylesList);
|
||||||
while(it.hasNext()) {
|
while(it.hasNext()) {
|
||||||
it.next();
|
it.next();
|
||||||
QStringList* classUsingIt = it.value();
|
const QStringList& classUsingIt ( it.value()) ;
|
||||||
bool first = true;
|
bool first = true;
|
||||||
foreach(QString className, *classUsingIt) {
|
foreach(QString className, classUsingIt) {
|
||||||
if (!className.trimmed().isEmpty()) {
|
if (!className.trimmed().isEmpty()) {
|
||||||
style += QString(first?".":",.") + className;// + " ";
|
style += QString(first?".":",.") + className;// + " ";
|
||||||
first = false;
|
first = false;
|
||||||
|
@ -961,7 +1003,8 @@ void RsHtml::optimizeHtml(QString &text, unsigned int flag /*= 0*/
|
||||||
}
|
}
|
||||||
|
|
||||||
QDomElement body = doc.documentElement();
|
QDomElement body = doc.documentElement();
|
||||||
QHash<QString, QStringList*> stylesList;
|
|
||||||
|
QHash<QString, QStringList> stylesList;
|
||||||
QHash<QString, QString> knownStyle;
|
QHash<QString, QString> knownStyle;
|
||||||
|
|
||||||
::optimizeHtml(doc, body, stylesList, knownStyle);
|
::optimizeHtml(doc, body, stylesList, knownStyle);
|
||||||
|
|
|
@ -86,11 +86,8 @@ int main(int argc, char **argv)
|
||||||
// unfinished
|
// unfinished
|
||||||
//args >> parameter("http-listen", listenAddress, "ipv6 address", "Listen only on the specified address.", false);
|
//args >> parameter("http-listen", listenAddress, "ipv6 address", "Listen only on the specified address.", false);
|
||||||
args >> option("http-allow-all", allowAllIps, "allow connections from all IP adresses (default= localhost only)");
|
args >> option("http-allow-all", allowAllIps, "allow connections from all IP adresses (default= localhost only)");
|
||||||
#ifdef __APPLE__
|
|
||||||
args >> help('h',"help","Display this Help");
|
args >> help('h',"help","Display this Help");
|
||||||
#else
|
|
||||||
args >> help();
|
|
||||||
#endif
|
|
||||||
if (args.helpRequested())
|
if (args.helpRequested())
|
||||||
{
|
{
|
||||||
std::cerr << args.usage() << std::endl;
|
std::cerr << args.usage() << std::endl;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue