- removed PGP ids and added GXS Ids from/to Message composer (PGP code is still here, but not used)

- added GXS ids to FriendSelection{Dialog,Widget}
- temporarily suspended distant messaging for PGP in NetworkDialog/SecurityItem



git-svn-id: http://svn.code.sf.net/p/retroshare/code/branches/v0.6-IdCleaning@7182 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
csoler 2014-03-10 21:24:17 +00:00
parent 3bde69d61e
commit 1a68d5d633
22 changed files with 511 additions and 461 deletions

View file

@ -35,11 +35,11 @@ uint32_t RsGRouterPublishKeyItem::serial_size() const
uint32_t s = 8 ; // header
s += POW_PAYLOAD_SIZE ; // proof of work bytes
s += 4 ; // diffusion_id
s += 20 ; // sha1 for published_key
s += published_key.serial_size() ; // sha1 for published_key
s += 4 ; // service id
s += 4 ; // randomized distance
s += GetTlvStringSize(description_string) ; // description
s += PGP_KEY_FINGERPRINT_SIZE ; // fingerprint
s += fingerprint.serial_size() ; // fingerprint
return s ;
}
@ -370,7 +370,7 @@ uint32_t RsGRouterGenericDataItem::serial_size() const
{
uint32_t s = 8 ; // header
s += sizeof(GRouterMsgPropagationId) ; // routing id
s += 20 ; // sha1 for published_key
s += destination_key.serial_size() ; // destination_key
s += 4 ; // data_size
s += data_size ; // data_size
@ -434,7 +434,7 @@ uint32_t RsGRouterMatrixCluesItem::serial_size() const
{
uint32_t s = 8 ; // header
s += 20 ; // Key size
s += destination_key.serial_size() ; // Key size
s += 4 ; // list<RoutingMatrixHitEntry>::size()
s += (4+4+8) * clues.size() ;
@ -452,14 +452,14 @@ uint32_t RsGRouterRoutingInfoItem::serial_size() const
{
uint32_t s = 8 ; // header
s += 4 ; // status_flags
s += origin.SIZE_IN_BYTES ; // origin
s += origin.serial_size() ; // origin
s += 8 ; // received_time
s += 4 ; // tried_friends.size() ;
s += tried_friends.size() * ( RsPeerId::SIZE_IN_BYTES + 8 ) ; // FriendTrialRecord
s += 4; // data_item->routing_id
s += data_item->destination_key.SIZE_IN_BYTES; // data_item->destination_key
s += data_item->destination_key.serial_size(); // data_item->destination_key
s += 4; // data_item->data_size
s += data_item->data_size; // data_item->data_bytes

View file

@ -27,8 +27,10 @@
#include "util/rsdir.h"
#include "grouter/groutertypes.h"
#include "retroshare/rsids.h"
typedef GRouterKeyIdType GRouterKeyId ; // we use SSLIds, so that it's easier in the GUI to mix up peer ids with grouter ids.
typedef Sha1CheckSum GRouterKeyId ; // we use sha1. Gives sufficient entropy.
class GRouterClientService ;
class RsGRouterGenericDataItem ;

View file

@ -220,8 +220,10 @@ static const uint32_t RS_GENERIC_ID_GXS_GROUP_ID_TYPE = 0x0005 ;
static const uint32_t RS_GENERIC_ID_GXS_ID_TYPE = 0x0006 ;
static const uint32_t RS_GENERIC_ID_GXS_MSG_ID_TYPE = 0x0007 ;
static const uint32_t RS_GENERIC_ID_GXS_CIRCLE_ID_TYPE = 0x0008 ;
static const uint32_t RS_GENERIC_ID_GROUTER_ID_TYPE = 0x0009 ;
typedef t_RsGenericIdType< SSL_ID_SIZE , false, RS_GENERIC_ID_SSL_ID_TYPE> SSLIdType ;
typedef t_RsGenericIdType< SSL_ID_SIZE , false, RS_GENERIC_ID_GROUTER_ID_TYPE> GRouterKeyIdType ;
typedef t_RsGenericIdType< PGP_KEY_ID_SIZE , true, RS_GENERIC_ID_PGP_ID_TYPE> PGPIdType ;
typedef t_RsGenericIdType< SHA1_SIZE , false, RS_GENERIC_ID_SHA1_ID_TYPE> Sha1CheckSum ;
typedef t_RsGenericIdType< PGP_KEY_FINGERPRINT_SIZE, true, RS_GENERIC_ID_PGP_FINGERPRINT_TYPE> PGPFingerprintType ;

View file

@ -33,6 +33,7 @@
#include <set>
#include "rstypes.h"
#include "rsgxsifacetypes.h"
/********************** For Messages and Channels *****************/
@ -88,7 +89,7 @@ typedef uint64_t ChatLobbyMsgId ;
typedef std::string ChatLobbyNickName ;
typedef RsPeerId DistantChatPeerId ;
typedef RsPeerId DistantMsgPeerId ;
typedef GRouterKeyIdType DistantMsgPeerId ;
class MessageInfo
{
@ -241,7 +242,7 @@ extern RsMsgs *rsMsgs;
struct DistantOfflineMessengingInvite
{
RsPgpId issuer_pgp_id ;
Sha1CheckSum hash ;
DistantMsgPeerId peer_id ;
time_t time_of_validity ;
};
@ -295,7 +296,7 @@ virtual bool createDistantOfflineMessengingInvite(time_t validity_time_stamp, Di
virtual bool getDistantOfflineMessengingInvites(std::vector<DistantOfflineMessengingInvite>& invites) = 0 ;
virtual void enableDistantMessaging(bool b) = 0;
virtual bool distantMessagingEnabled() = 0;
virtual bool getDistantMessagePeerId(const RsPgpId& pgp_id, DistantMsgPeerId& peerId) = 0;
virtual bool getDistantMessagePeerId(const RsGxsId& gxs_id, DistantMsgPeerId& peerId) = 0;
/****************************************/
/* Chat */

View file

@ -116,7 +116,7 @@ bool p3Msgs::distantMessagingEnabled()
{
return mMsgSrv->distantMessagingEnabled();
}
bool p3Msgs::getDistantMessagePeerId(const RsPgpId& pgp_id,DistantMsgPeerId &pid)
bool p3Msgs::getDistantMessagePeerId(const RsGxsId& pgp_id,DistantMsgPeerId &pid)
{
return mMsgSrv->getDistantMessagePeerId(pgp_id,pid);
}

View file

@ -27,6 +27,7 @@
*/
#include "retroshare/rsmsgs.h"
#include "retroshare/rsgxsifacetypes.h"
class p3MsgService;
class p3ChatService;
@ -85,7 +86,7 @@ class p3Msgs: public RsMsgs
virtual void enableDistantMessaging(bool b) ;
virtual bool distantMessagingEnabled() ;
virtual bool getDistantMessagePeerId(const RsPgpId& pgp_id,DistantMsgPeerId& pid) ;
virtual bool getDistantMessagePeerId(const RsGxsId &pgp_id,DistantMsgPeerId& pid) ;
/*!
* gets avatar from peer, image data in jpeg format

View file

@ -1320,8 +1320,6 @@ int RsServer::StartupRetroShare()
#ifdef GROUTER
msgSrv->connectToGlobalRouter(gr) ;
#endif
msgSrv->connectToTurtleRouter(tr) ;
pqih -> addService(mHeart);
pqih -> addService(mDisc);
pqih -> addService(msgSrv);

View file

@ -50,6 +50,7 @@
#include <iomanip>
#include <map>
#include <sstream>
//#define MSG_DEBUG 1
//#define DEBUG_DISTANT_MSG
@ -57,11 +58,13 @@
const int msgservicezone = 54319;
static const uint32_t RS_DISTANT_MSG_STATUS_TUNNEL_OK = 0x0001 ;
static const uint32_t RS_DISTANT_MSG_STATUS_TUNNEL_DN = 0x0000 ;
static const uint32_t DISTANT_MSG_HASH_SIZE = Sha1CheckSum::SIZE_IN_BYTES ;
static const uint8_t DISTANT_MSG_TAG_IDENTITY = 0x10 ;
static const uint8_t DISTANT_MSG_TAG_CLEAR_MSG = 0x20 ;
static const uint8_t DISTANT_MSG_TAG_ENCRYPTED_MSG = 0x21 ;
static const uint8_t DISTANT_MSG_TAG_SIGNATURE = 0x30 ;
static const uint8_t ENCRYPTED_MSG_PROTOCOL_VERSION_01 = 0x37 ;
static const uint8_t DISTANT_MSG_PROTOCOL_VERSION_01 = 0x47 ;
static const uint8_t DISTANT_MSG_PROTOCOL_VERSION_02 = 0x48 ;
/* Another little hack ..... unique message Ids
* will be handled in this class.....
@ -88,24 +91,6 @@ p3MsgService::p3MsgService(p3LinkMgr *lm)
if(lm)
initStandardTagTypes();
#ifdef GROUTER
// Debug stuff. Create a random key and register it.
const RsPeerId& own_ssl_id = rsPeers->getOwnId() ;
const RsPgpId& gpg_id = rsPeers->getGPGOwnId() ;
RsPeerDetails d;
rsPeers->getGPGDetails(gpg_id,d) ;
PGPFingerprintType fingerp( d.fpr ) ;
// Re-hash the SSL id, to make it one way. Will be replaced by proper invitations in the future.
//
GRouterKeyId key ( RsDirUtil::sha1sum( own_ssl_id.toByteArray(),own_ssl_id.SIZE_IN_BYTES )) ;
static GRouterServiceId client_id = GROUTER_CLIENT_ID_MESSAGES;
static std::string description = "Test string for debug purpose" ;
mGRouter->registerKey(key,fingerp,client_id,description) ;
#endif
}
uint32_t p3MsgService::getNewUniqueMsgId()
@ -276,21 +261,15 @@ void p3MsgService::checkSizeAndSendMessage(RsMsgItem *msg)
static const uint32_t MAX_STRING_SIZE = 15000 ;
std::cerr << "Msg is size " << msg->message.size() << std::endl;
Sha1CheckSum hash ;
if( msg->msgFlags & RS_MSG_FLAGS_DISTANT )
{
RsStackMutex stack(mMsgMtx); /********** STACK LOCKED MTX ******/
#ifdef DEBUG_DISTANT_MSG
std::cerr << "checkOutgoingMessages(): removing pending message flag for hash " << (*it)->PeerId() << "." << std::endl;
std::cerr << "checkOutgoingMessages(): removing pending message flag for peer id " << msg->PeerId() << "." << std::endl;
#endif
if(!locked_findHashForVirtualPeerId(msg->PeerId(),hash))
{
std::cerr << "p3MsgService::checkSizeAndSendMessage(): Cannot find hash for virtual peer id " << msg->PeerId() << ". This is unexpected!" << std::endl;
return ;
}
_messenging_contacts[hash].pending_messages = false ;
_messenging_contacts[GRouterKeyId(msg->PeerId())].pending_messages = false ;
}
while(msg->message.size() > MAX_STRING_SIZE)
@ -311,11 +290,7 @@ void p3MsgService::checkSizeAndSendMessage(RsMsgItem *msg)
item->msgFlags |= RS_MSG_FLAGS_PARTIAL ;
if(msg->msgFlags & RS_MSG_FLAGS_DISTANT)
{
sendPrivateMsgItem(hash,item) ;
}
sendPrivateMsgItem(item) ;
else
sendItem(item) ;
}
@ -324,7 +299,7 @@ void p3MsgService::checkSizeAndSendMessage(RsMsgItem *msg)
#endif
if(msg->msgFlags & RS_MSG_FLAGS_DISTANT)
sendPrivateMsgItem(hash,msg) ;
sendPrivateMsgItem(msg) ;
else
sendItem(msg) ;
}
@ -1792,28 +1767,35 @@ RsMsgItem *p3MsgService::initMIRsMsg(MessageInfo &info, const RsPeerId &to)
return msg;
}
bool p3MsgService::encryptMessage(const RsPgpId& pgp_id,RsMsgItem *item)
bool p3MsgService::createDistantMessage(const RsGxsId& destination_gxs_id,const RsGxsId& source_gxs_id,RsMsgItem *item)
{
#ifdef DEBUG_DISTANT_MSG
std::cerr << "Encrypting message with public key " << pgp_id << " in place." << std::endl;
std::cerr << "Creating distant message for recipient " << item->PeerId() << ", encryption key=" << destination_gxs_id << " in place." << std::endl;
#endif
// 0 - append own id to the data.
//
uint32_t rssize = _serialiser->size(item) ;
unsigned char *data = (unsigned char *)malloc(1+rssize+PGP_KEY_ID_SIZE) ;
uint32_t conservative_max_signature_size = 1000 ;
uint32_t message_size = _serialiser->size(item) ;
uint32_t total_data_size = 1+5+source_gxs_id.SIZE_IN_BYTES+5+message_size+conservative_max_signature_size ;
unsigned char *data = (unsigned char *)malloc(total_data_size) ;
// -1 - setup protocol version
//
#ifdef DEBUG_DISTANT_MSG
std::cerr << " adding protocol version TAG = " << std::hex << (int)ENCRYPTED_MSG_PROTOCOL_VERSION_01 << std::dec << std::endl;
std::cerr << " adding protocol version TAG = " << std::hex << (int)DISTANT_MSG_PROTOCOL_VERSION_02 << std::dec << std::endl;
#endif
data[0] = ENCRYPTED_MSG_PROTOCOL_VERSION_01 ;
uint32_t offset = 0 ;
data[offset++] = DISTANT_MSG_PROTOCOL_VERSION_02 ;
#ifdef DEBUG_DISTANT_MSG
std::cerr << " adding own key ID " << AuthGPG::getAuthGPG()->getGPGOwnId() << std::endl;
#endif
memcpy(&data[1], RsPgpId(AuthGPG::getAuthGPG()->getGPGOwnId()).toByteArray(), PGP_KEY_ID_SIZE) ;
data[offset++] = DISTANT_MSG_TAG_IDENTITY ;
offset += PGPKeyParser::write_125Size(&data[offset],source_gxs_id.SIZE_IN_BYTES) ;
memcpy(&data[offset], source_gxs_id.toByteArray(), source_gxs_id.SIZE_IN_BYTES) ;
offset += source_gxs_id.SIZE_IN_BYTES ;
// 1 - serialise the whole message item into a binary chunk.
//
@ -1821,12 +1803,18 @@ bool p3MsgService::encryptMessage(const RsPgpId& pgp_id,RsMsgItem *item)
#ifdef DEBUG_DISTANT_MSG
std::cerr << " serialising item..." << std::endl;
#endif
if(!_serialiser->serialise(item,&data[1+PGP_KEY_ID_SIZE],&rssize))
data[offset++] = DISTANT_MSG_TAG_CLEAR_MSG ;
offset += PGPKeyParser::write_125Size(&data[offset],message_size) ;
uint32_t remaining_size = total_data_size - offset ;
if(!_serialiser->serialise(item,&data[offset],&remaining_size))
{
std::cerr << "(EE) p3MsgService::encryptMessage(): Serialization error." << std::endl;
free(data) ;
return false;
}
offset += message_size ;
// 2 - now sign the data, if necessary, and put the signature up front
@ -1841,7 +1829,9 @@ bool p3MsgService::encryptMessage(const RsPgpId& pgp_id,RsMsgItem *item)
signature_length = 2000 ;
signature_data = new unsigned char[signature_length] ;
if(!AuthGPG::getAuthGPG()->SignDataBin(data,1+rssize+PGP_KEY_ID_SIZE,signature_data,&signature_length))
// do a proper signature here
//
//if(!AuthGPG::getAuthGPG()->SignDataBin(data,1+rssize+PGP_KEY_ID_SIZE,signature_data,&signature_length))
{
free(data) ;
std::cerr << "Signature failed!" << std::endl;
@ -1852,7 +1842,7 @@ bool p3MsgService::encryptMessage(const RsPgpId& pgp_id,RsMsgItem *item)
#endif
}
#ifdef DEBUG_DISTANT_MSG
std::cerr << " total decrypted size = " << PGP_KEY_ID_SIZE + 1 + rssize + signature_length << std::endl;
std::cerr << " total decrypted size = " << offset + signature_length << std::endl;
#endif
// 3 - append the signature to the serialized data.
@ -1861,19 +1851,20 @@ bool p3MsgService::encryptMessage(const RsPgpId& pgp_id,RsMsgItem *item)
#ifdef DEBUG_DISTANT_MSG
std::cerr << " Appending signature." << std::endl;
#endif
data = (uint8_t*)realloc(data,1+rssize+signature_length+PGP_KEY_ID_SIZE) ;
memcpy(&data[1+rssize+PGP_KEY_ID_SIZE],signature_data,signature_length) ;
memcpy(&data[offset],signature_data,signature_length) ;
offset += signature_length ;
}
// 2 - pgp-encrypt the whole chunk with the user-supplied public key.
//
uint32_t encrypted_size = 1+rssize + PGP_KEY_ID_SIZE + signature_length + 1000 ;
uint32_t encrypted_size = offset + 1000 ;
unsigned char *encrypted_data = new unsigned char[encrypted_size] ;
#ifdef DEBUG_DISTANT_MSG
std::cerr << " Encrypting for Key ID " << pgp_id << std::endl;
#endif
if(!AuthGPG::getAuthGPG()->encryptDataBin(pgp_id,data,1+rssize+signature_length+PGP_KEY_ID_SIZE,encrypted_data,&encrypted_size))
// Do proper encryption here
//if(!AuthGPG::getAuthGPG()->encryptDataBin(pgp_id,data,1+rssize+signature_length+PGP_KEY_ID_SIZE,encrypted_data,&encrypted_size))
{
free(data) ;
delete[] encrypted_data ;
@ -1883,7 +1874,7 @@ bool p3MsgService::encryptMessage(const RsPgpId& pgp_id,RsMsgItem *item)
free(data) ;
#ifdef DEBUG_DISTANT_MSG
std::cerr << " Decrypted size = " << 1+rssize+signature_length+PGP_KEY_ID_SIZE << std::endl;
std::cerr << " Decrypted size = " << offset << std::endl;
std::cerr << " Encrypted size = " << encrypted_size << std::endl;
std::cerr << " First bytes of encrypted data: " << std::hex << (int)encrypted_data[0] << " " << (int)encrypted_data[1] << " " << (int)encrypted_data[2] << std::dec << std::endl;
std::cerr << " Encrypted data hash = " << RsDirUtil::sha1sum(encrypted_data,encrypted_size).toStdString() << std::endl;
@ -1897,10 +1888,6 @@ bool p3MsgService::encryptMessage(const RsPgpId& pgp_id,RsMsgItem *item)
Radix64::encode((char *)encrypted_data,encrypted_size,armoured_data) ;
delete[] encrypted_data ;
//std::wstring encrypted_msg = armoured_data;
//if(!librs::util::ConvertUtf8ToUtf16(armoured_data,encrypted_msg))
// return false;
// wipe the item clean and replace the message by the encrypted data.
item->message = armoured_data ;
@ -1917,183 +1904,225 @@ bool p3MsgService::encryptMessage(const RsPgpId& pgp_id,RsMsgItem *item)
return true ;
}
std::string printNumber(uint32_t n,bool hex)
{
std::ostringstream os ;
if(hex) os << std::hex ;
os << n ;
return os.str() ;
}
bool p3MsgService::decryptMessage(const std::string& mId)
{
uint32_t msgId = atoi(mId.c_str());
std::string encrypted_string ;
unsigned char *decrypted_data = NULL;
char *encrypted_data = NULL;
try
{
uint32_t msgId = atoi(mId.c_str());
std::string encrypted_string ;
#ifdef DEBUG_DISTANT_MSG
std::cerr << "Decrypting message with Id " << mId << std::endl;
std::cerr << "Decrypting message with Id " << mId << std::endl;
#endif
{
RsStackMutex stack(mMsgMtx); /********** STACK LOCKED MTX ******/
{
RsStackMutex stack(mMsgMtx); /********** STACK LOCKED MTX ******/
std::map<uint32_t, RsMsgItem *>::iterator mit = imsg.find(msgId);
std::map<uint32_t, RsMsgItem *>::iterator mit = imsg.find(msgId);
if(mit == imsg.end())
{
std::cerr << "Can't find this message in msg list. Id=" << mId << std::endl;
return false;
}
if(mit == imsg.end())
{
std::cerr << "Can't find this message in msg list. Id=" << mId << std::endl;
return false;
}
encrypted_string = mit->second->message ;
}
encrypted_string = mit->second->message ;
}
char *encrypted_data ;
size_t encrypted_size ;
size_t encrypted_size ;
Radix64::decode(encrypted_string,encrypted_data,encrypted_size) ;
Radix64::decode(encrypted_string,encrypted_data,encrypted_size) ;
#ifdef DEBUG_DISTANT_MSG
std::cerr << " Message has been radix64 decoded." << std::endl;
std::cerr << " Message has been radix64 decoded." << std::endl;
#endif
uint32_t decrypted_size = encrypted_size + 500 ;
unsigned char *decrypted_data = new unsigned char[decrypted_size] ;
uint32_t decrypted_size = encrypted_size + 500 ;
unsigned char *decrypted_data = new unsigned char[decrypted_size] ;
#ifdef DEBUG_DISTANT_MSG
std::cerr << " Calling decryption. Encrypted data size = " << encrypted_size << ", Allocated size = " << decrypted_size << std::endl;
std::cerr << " First bytes of encrypted data: " << std::hex << (int)((unsigned char*)encrypted_data)[0] << " " << (int)((unsigned char*)encrypted_data)[1] << " " << (int)((unsigned char*)encrypted_data)[2] << std::dec << std::endl;
std::cerr << " Encrypted data hash = " << RsDirUtil::sha1sum((uint8_t*)encrypted_data,encrypted_size).toStdString() << std::endl;
std::cerr << " Calling decryption. Encrypted data size = " << encrypted_size << ", Allocated size = " << decrypted_size << std::endl;
std::cerr << " First bytes of encrypted data: " << std::hex << (int)((unsigned char*)encrypted_data)[0] << " " << (int)((unsigned char*)encrypted_data)[1] << " " << (int)((unsigned char*)encrypted_data)[2] << std::dec << std::endl;
std::cerr << " Encrypted data hash = " << RsDirUtil::sha1sum((uint8_t*)encrypted_data,encrypted_size).toStdString() << std::endl;
#endif
if(!AuthGPG::getAuthGPG()->decryptDataBin(encrypted_data,encrypted_size,decrypted_data,&decrypted_size))
{
delete[] encrypted_data ;
delete[] decrypted_data ;
std::cerr << "decryption failed!" << std::endl;
return false;
}
#ifdef DEBUG_DISTANT_MSG
std::cerr << " Message has succesfully decrypted. Decrypted size = " << decrypted_size << std::endl;
#endif
// 1 - get the sender's id
unsigned char protocol_version = decrypted_data[0] ;
// Use proper GXS decryption here.
// We need something like:
//
// if(!rsGxs->decryptDataBin(encrypted_data,encrypted_size,decrypted_data,&decrypted_size))
// throw std::runtime_error("decryption failed!") ;
#ifdef DEBUG_DISTANT_MSG
std::cerr << " Read protocol version number " << std::hex << (int)protocol_version << std::dec << std::endl;
std::cerr << " Message has succesfully decrypted. Decrypted size = " << decrypted_size << std::endl;
#endif
if(protocol_version != ENCRYPTED_MSG_PROTOCOL_VERSION_01)
{
std::cerr << "Bad version number " << std::hex << (int)protocol_version << std::dec << " => packet is dropped." << std::endl;
delete[] encrypted_data ;
delete[] decrypted_data ;
return false;
}
RsPgpId senders_id(&decrypted_data[1]) ;
// 1 - get the sender's id
uint32_t offset = 0 ;
unsigned char protocol_version = decrypted_data[offset++] ;
#ifdef DEBUG_DISTANT_MSG
std::cerr << " Sender's ID: " << senders_id.toStdString() << std::endl;
std::cerr << " Read protocol version number " << std::hex << (int)protocol_version << std::dec << std::endl;
#endif
// 2 - deserialize the item
if(protocol_version != DISTANT_MSG_PROTOCOL_VERSION_02)
throw std::runtime_error("Bad protocol version number " + printNumber(protocol_version,true) + " => packet is dropped.") ;
#ifdef DEBUG_DISTANT_MSG
std::cerr << " Deserializing..." << std::endl;
std::cerr << " Reading identity section " << std::endl;
#endif
uint32_t item_size = decrypted_size ; // just needs to be larger than the actual size.
RsMsgItem *item = dynamic_cast<RsMsgItem*>(_serialiser->deserialise(&decrypted_data[1+PGP_KEY_ID_SIZE],&item_size)) ;
uint8_t ptag = decrypted_data[offset] ;
if(item == NULL)
{
std::cerr << "Decrypted message could not be deserialized." << std::endl;
return false ;
}
if(ptag != DISTANT_MSG_TAG_IDENTITY)
throw std::runtime_error("Bad ptag in encrypted msg packet "+printNumber(ptag,true)+" => packet is dropped.") ;
// 3 - check signature
unsigned char *tmp_data = &decrypted_data[offset] ;
uint32_t identity_size = PGPKeyParser::read_125Size(tmp_data) ;
offset += tmp_data - decrypted_data ;
bool signature_present = false ;
bool signature_ok = false ;
if(identity_size != RsGxsId::SIZE_IN_BYTES)
throw std::runtime_error("Bad size in Identity section " + printNumber(identity_size,false) + " => packet is dropped.") ;
if(1+item_size + PGP_KEY_ID_SIZE < decrypted_size)
{
std::cerr << " Signature is present. Verifying it..." << std::endl;
RsGxsId senders_id(&decrypted_data[offset]) ;
offset += identity_size ;
PGPFingerprintType fingerprint ;
if(!AuthGPG::getAuthGPG()->getKeyFingerprint(senders_id,fingerprint))
{
std::cerr << "Cannot get fingerprint" << std::endl;
return false ;
}
std::cerr << " Fingerprint = " << fingerprint.toStdString() << std::endl;
signature_present = true ;
signature_ok = AuthGPG::getAuthGPG()->VerifySignBin(decrypted_data, 1+PGP_KEY_ID_SIZE+item_size, &decrypted_data[1+PGP_KEY_ID_SIZE+item_size], decrypted_size - PGP_KEY_ID_SIZE - item_size - 1, fingerprint) ;
}
else if(1 + item_size + PGP_KEY_ID_SIZE == decrypted_size)
std::cerr << " No signature in this packet" << std::endl;
else
{
std::cerr << "Structural error in packet: sizes do not match. Dropping the message." << std::endl;
return false ;
}
delete[] decrypted_data ;
// 4 - replace the item with the decrypted data, and update flags
#ifdef DEBUG_DISTANT_MSG
std::cerr << " Decrypted message was succesfully deserialized. New message:" << std::endl;
item->print(std::cerr,0) ;
std::cerr << " Sender's ID: " << senders_id.toStdString() << std::endl;
#endif
RsPeerId own_id ;
const RsPgpId& own_pgp_id = AuthGPG::getAuthGPG()->getGPGOwnId();
getDistantMessagePeerId(own_pgp_id,own_id) ;
// 2 - deserialize the item
{
RsStackMutex stack(mMsgMtx); /********** STACK LOCKED MTX ******/
ptag = decrypted_data[offset] ;
// Keer the id.
RsMsgItem& msgi( *imsg[msgId] ) ;
if(ptag != DISTANT_MSG_TAG_CLEAR_MSG)
throw std::runtime_error("Bad ptag in encrypted msg packet " + printNumber(ptag,true) + " => packet is dropped.") ;
msgi = *item ; // copy everything
msgi.msgId = msgId ; // restore the correct message id, to make it consistent
msgi.msgFlags &= ~RS_MSG_FLAGS_ENCRYPTED ; // just in case.
msgi.msgFlags |= RS_MSG_FLAGS_DECRYPTED ; // previousy encrypted msg is now decrypted
DistantMsgPeerId senders_vpid ;
getDistantMessagePeerId(senders_id,senders_vpid) ;
msgi.PeerId(senders_vpid) ;
tmp_data = &decrypted_data[offset] ;
uint32_t item_size = PGPKeyParser::read_125Size(tmp_data) ;
offset += tmp_data - decrypted_data ;
//for(std::list<RsPeerId>::iterator it(msgi.msgto.ids.begin());it!=msgi.msgto.ids.end();++it) if(*it == own_id) *it = own_pgp_id ;
//for(std::list<RsPeerId>::iterator it(msgi.msgcc.ids.begin());it!=msgi.msgcc.ids.end();++it) if(*it == own_id) *it = own_pgp_id ;
//for(std::list<RsPeerId>::iterator it(msgi.msgbcc.ids.begin());it!=msgi.msgbcc.ids.end();++it) if(*it == own_id) *it = own_pgp_id ;
#ifdef DEBUG_DISTANT_MSG
std::cerr << " Deserializing..." << std::endl;
#endif
RsMsgItem *item = dynamic_cast<RsMsgItem*>(_serialiser->deserialise(&decrypted_data[offset],&item_size)) ;
if(signature_present)
{
msgi.msgFlags |= RS_MSG_FLAGS_SIGNED ;
if(item == NULL)
throw std::runtime_error("Decrypted message could not be deserialized.") ;
if(signature_ok)
msgi.msgFlags |= RS_MSG_FLAGS_SIGNATURE_CHECKS ; // just in case.
else
msgi.msgFlags &= ~RS_MSG_FLAGS_SIGNATURE_CHECKS ; // just in case.
}
// 3 - check signature
std::map<uint32_t, RsMsgSrcId*>::iterator it = mSrcIds.find(msgi.msgId) ;
bool signature_present = false ;
bool signature_ok = false ;
uint32_t size_of_signed_data = offset ;
if(it == mSrcIds.end())
{
std::cerr << "Warning: could not find message source for id " << msgi.msgId << ". Weird." << std::endl;
if(offset < decrypted_size)
{
uint8_t ptag = decrypted_data[offset++] ;
RsMsgSrcId* msi = new RsMsgSrcId();
msi->msgId = msgi.msgId;
msi->srcId = senders_vpid ;
if(ptag != DISTANT_MSG_TAG_SIGNATURE)
throw std::runtime_error("Bad ptag in signature packet " + printNumber(ptag,true) + " => packet is dropped.") ;
mSrcIds.insert(std::pair<uint32_t, RsMsgSrcId*>(msi->msgId, msi));
}
else
{
std::cerr << "Substituting source name for message id " << msgi.msgId << ": " << it->second->srcId << " -> " << senders_id << std::endl;
it->second->srcId = senders_vpid ;
}
}
delete item ;
unsigned char *tmp_data = &decrypted_data[offset] ;
uint32_t signature_size = PGPKeyParser::read_125Size(tmp_data) ;
offset += tmp_data - decrypted_data ;
IndicateConfigChanged() ;
RsServer::notify()->notifyListChange(NOTIFY_LIST_MESSAGELIST,NOTIFY_TYPE_MOD);
std::cerr << " Signature is present. Verifying it..." << std::endl;
return true ;
// Do proper GXS signature check here!!
// Because we're using GXS ids, not pgp ids.
// We need something like:
//
// signature_ok = rsGxs->VerifySignBin(decrypted_data, size_of_signed_data, &decrypted_data[offset], signature_size, senders_id) ;
signature_present = false ;
//signature_ok = AuthGPG::getAuthGPG()->VerifySignBin(decrypted_data, size_of_signed_data, &decrypted_data[offset], signature_size, fingerprint) ;
}
else if(offset == decrypted_size)
std::cerr << " No signature in this packet" << std::endl;
else
throw std::runtime_error("Structural error in packet: sizes do not match. Dropping the message.") ;
delete[] decrypted_data ;
decrypted_data = NULL ;
// 4 - replace the item with the decrypted data, and update flags
#ifdef DEBUG_DISTANT_MSG
std::cerr << " Decrypted message was succesfully deserialized. New message:" << std::endl;
item->print(std::cerr,0) ;
#endif
RsGxsId own_gxs_id ; // we should use the correct own GXS ID that was used to send that message!
DistantMsgPeerId own_id ;
getDistantMessagePeerId(own_gxs_id,own_id) ;
{
RsStackMutex stack(mMsgMtx); /********** STACK LOCKED MTX ******/
// Keer the id.
RsMsgItem& msgi( *imsg[msgId] ) ;
msgi = *item ; // copy everything
msgi.msgId = msgId ; // restore the correct message id, to make it consistent
msgi.msgFlags &= ~RS_MSG_FLAGS_ENCRYPTED ; // just in case.
msgi.msgFlags |= RS_MSG_FLAGS_DECRYPTED ; // previousy encrypted msg is now decrypted
DistantMsgPeerId senders_vpid ;
getDistantMessagePeerId(senders_id,senders_vpid) ;
msgi.PeerId(RsPeerId(senders_vpid)) ;
//for(std::list<RsPeerId>::iterator it(msgi.msgto.ids.begin());it!=msgi.msgto.ids.end();++it) if(*it == own_id) *it = own_pgp_id ;
//for(std::list<RsPeerId>::iterator it(msgi.msgcc.ids.begin());it!=msgi.msgcc.ids.end();++it) if(*it == own_id) *it = own_pgp_id ;
//for(std::list<RsPeerId>::iterator it(msgi.msgbcc.ids.begin());it!=msgi.msgbcc.ids.end();++it) if(*it == own_id) *it = own_pgp_id ;
if(signature_present)
{
msgi.msgFlags |= RS_MSG_FLAGS_SIGNED ;
if(signature_ok)
msgi.msgFlags |= RS_MSG_FLAGS_SIGNATURE_CHECKS ; // just in case.
else
msgi.msgFlags &= ~RS_MSG_FLAGS_SIGNATURE_CHECKS ; // just in case.
}
std::map<uint32_t, RsMsgSrcId*>::iterator it = mSrcIds.find(msgi.msgId) ;
if(it == mSrcIds.end())
{
std::cerr << "Warning: could not find message source for id " << msgi.msgId << ". Weird." << std::endl;
RsMsgSrcId* msi = new RsMsgSrcId();
msi->msgId = msgi.msgId;
msi->srcId = RsPeerId(senders_vpid) ;
mSrcIds.insert(std::pair<uint32_t, RsMsgSrcId*>(msi->msgId, msi));
}
else
{
std::cerr << "Substituting source name for message id " << msgi.msgId << ": " << it->second->srcId << " -> " << senders_id << std::endl;
it->second->srcId = RsPeerId(senders_vpid) ;
}
}
delete item ;
IndicateConfigChanged() ;
RsServer::notify()->notifyListChange(NOTIFY_LIST_MESSAGELIST,NOTIFY_TYPE_MOD);
return true ;
}
catch(std::exception& e)
{
std::cerr << "Decryption failed: " << e.what() << std::endl;
if(encrypted_data != NULL) delete[] encrypted_data ;
if(decrypted_data != NULL) delete[] decrypted_data ;
return false ;
}
}
#ifdef GROUTER
@ -2101,13 +2130,25 @@ void p3MsgService::connectToGlobalRouter(p3GRouter *gr)
{
mGRouter = gr ;
gr->registerClientService(RS_SERVICE_TYPE_MSG,this) ;
// Debug stuff. Create a random key and register it.
const RsPeerId& own_ssl_id = rsPeers->getOwnId() ;
const RsPgpId& gpg_id = rsPeers->getGPGOwnId() ;
RsPeerDetails d;
rsPeers->getGPGDetails(gpg_id,d) ;
PGPFingerprintType fingerp( d.fpr ) ;
// Re-hash the SSL id, to make it one way. Will be replaced by proper invitations in the future.
//
GRouterKeyId key ( own_ssl_id ) ;
static GRouterServiceId client_id = GROUTER_CLIENT_ID_MESSAGES;
static std::string description = "Test string for debug purpose" ;
mGRouter->registerKey(key,fingerp,client_id,description) ;
}
#endif
void p3MsgService::connectToTurtleRouter(p3turtle *pt)
{
mTurtle = pt ;
pt->registerTunnelService(this) ;
}
bool p3MsgService::createDistantOfflineMessengingInvite(time_t time_of_validity,DistantMsgPeerId& peer_id)
{
@ -2131,28 +2172,25 @@ bool p3MsgService::createDistantOfflineMessengingInvite(time_t time_of_validity,
void p3MsgService::enableDistantMessaging(bool b)
{
// compute the hash
// compute the hash
Sha1CheckSum hash ;
if(!getDistantMessageHash(AuthGPG::getAuthGPG()->getGPGOwnId(),hash))
return ;
bool cchanged = false ;
#ifdef DEBUG_DISTANT_MSG
std::cerr << (b?"Enabling":"Disabling") << " distant messaging, with hash = " << hash << std::endl;
#endif
{
RsStackMutex stack(mMsgMtx); /********** STACK LOCKED MTX ******/
std::map<Sha1CheckSum,DistantMessengingInvite>::iterator it = _messenging_invites.find(hash) ;
GRouterKeyId distant_msg_peer_id ( rsPeers->getOwnId() );
#ifdef DEBUG_DISTANT_MSG
std::cerr << (b?"Enabling":"Disabling") << " distant messaging, with peer id = " << distant_msg_peer_id << std::endl;
#endif
std::map<GRouterKeyId,DistantMessengingInvite>::iterator it = _messenging_invites.find(distant_msg_peer_id) ;
if(b && it == _messenging_invites.end())
{
DistantMessengingInvite invite ;
invite.time_of_validity = time(NULL) + 10*365*86400; // 10 years from now
_messenging_invites[hash] = invite ;
_messenging_invites[distant_msg_peer_id] = invite ;
mDistantMessagingEnabled = true ;
#ifdef GROUTER
std::cerr << "Notifying the global router." << std::endl;
@ -2167,7 +2205,7 @@ void p3MsgService::enableDistantMessaging(bool b)
// Re-hash the SSL id, to make it one way. Will be replaced by proper invitations in the future.
//
GRouterKeyId key ( RsDirUtil::sha1sum( own_ssl_id.toByteArray(),own_ssl_id.SIZE_IN_BYTES ) ) ;
GRouterKeyId key ( own_ssl_id ) ;
static GRouterServiceId client_id = GROUTER_CLIENT_ID_MESSAGES;
static std::string description = "Test string for debug purpose" ;
@ -2181,7 +2219,7 @@ void p3MsgService::enableDistantMessaging(bool b)
_messenging_invites.erase(it) ;
mDistantMessagingEnabled = false ;
#ifdef GROUTER
mGRouter->unregisterKey(GRouterKeyId(hash)) ;
mGRouter->unregisterKey(GRouterKeyId(distant_msg_peer_id)) ;
#endif
cchanged = true ;
}
@ -2193,46 +2231,34 @@ void p3MsgService::enableDistantMessaging(bool b)
#ifdef DEBUG_DISTANT_MSG
std::cerr << "List of distant message invites: " << std::endl;
for(std::map<Sha1CheckSum,DistantMessengingInvite>::const_iterator it(_messenging_invites.begin());it!=_messenging_invites.end();++it)
std::cerr << " hash = " << it->first << std::endl;
std::cerr << " distant_msg_peer_id = " << it->first << std::endl;
#endif
}
bool p3MsgService::distantMessagingEnabled()
{
// compute the hash
Sha1CheckSum hash ;
if(!getDistantMessageHash(AuthGPG::getAuthGPG()->getGPGOwnId(),hash))
return false;
bool res ;
{
RsStackMutex stack(mMsgMtx); /********** STACK LOCKED MTX ******/
res = _messenging_invites.find(hash) != _messenging_invites.end() ;
}
return res ;
std::cerr << __PRETTY_FUNCTION__ << ": not yet implemented!" <<std::endl;
// bool res ;
// {
// RsStackMutex stack(mMsgMtx); /********** STACK LOCKED MTX ******/
// res = _messenging_invites.find(rsPeers->getOwnId()) != _messenging_invites.end() ;
// }
return false ;
}
bool p3MsgService::getDistantMessagePeerId(const RsPgpId& pgp_id,DistantMsgPeerId& peer_id)
bool p3MsgService::getDistantMessagePeerId(const RsGxsId& gxs_id,DistantMsgPeerId& pid)
{
if(!AuthGPG::getAuthGPG()->isKeySupported(pgp_id))
return false ;
// if(!AuthGPG::getAuthGPG()->isKeySupported(pgp_id))
// return false ;
unsigned char tmp[RsPeerId::SIZE_IN_BYTES] ;
memset(tmp,0,RsPeerId::SIZE_IN_BYTES) ;
memcpy(tmp,pgp_id.toByteArray(),RsPgpId::SIZE_IN_BYTES) ;
assert(pid.SIZE_IN_BYTES >= gxs_id.SIZE_IN_BYTES) ;
peer_id = RsPeerId(tmp) ;
unsigned char bytes[pid.SIZE_IN_BYTES];
memset(bytes,0,pid.SIZE_IN_BYTES) ;
memcpy(bytes,gxs_id.toByteArray(),gxs_id.SIZE_IN_BYTES) ;
// Also check that we have the public key.
return true ;
}
bool p3MsgService::getDistantMessageHash(const RsPgpId& pgp_id,Sha1CheckSum& hash)
{
if(!AuthGPG::getAuthGPG()->isKeySupported(pgp_id))
return false ;
hash = RsDirUtil::sha1sum(pgp_id.toByteArray(),RsPgpId::SIZE_IN_BYTES) ;
pid = DistantMsgPeerId(bytes) ;
// Also check that we have the public key.
@ -2242,10 +2268,10 @@ bool p3MsgService::getDistantOfflineMessengingInvites(std::vector<DistantOffline
{
RsStackMutex stack(mMsgMtx); /********** STACK LOCKED MTX ******/
for(std::map<Sha1CheckSum,DistantMessengingInvite>::const_iterator it(_messenging_invites.begin());it!=_messenging_invites.end();++it)
for(std::map<DistantMsgPeerId,DistantMessengingInvite>::const_iterator it(_messenging_invites.begin());it!=_messenging_invites.end();++it)
{
DistantOfflineMessengingInvite invite ;
invite.hash = it->first ;
invite.peer_id = it->first ;
invite.issuer_pgp_id = AuthGPG::getAuthGPG()->getGPGOwnId() ;
invite.time_of_validity = it->second.time_of_validity ;
@ -2258,23 +2284,6 @@ bool p3MsgService::getDistantOfflineMessengingInvites(std::vector<DistantOffline
return true ;
}
bool p3MsgService::handleTunnelRequest(const Sha1CheckSum &hash,const RsPeerId& /*peer_id*/)
{
RsStackMutex stack(mMsgMtx); /********** STACK LOCKED MTX ******/
std::map<Sha1CheckSum,DistantMessengingInvite>::const_iterator it = _messenging_invites.find(hash) ;
#ifdef DEBUG_DISTANT_MSG
if(it != _messenging_invites.end())
{
std::cerr << "p3MsgService::handleTunnelRequest: received TR for hash " << hash << std::endl;
std::cerr << "Responding OK!" << std::endl;
}
#endif
return it != _messenging_invites.end() ;
}
void p3MsgService::manageDistantPeers()
{
// now possibly flush pending messages
@ -2288,13 +2297,13 @@ void p3MsgService::manageDistantPeers()
// clean dead invites.
//
for(std::map<Sha1CheckSum,DistantMessengingInvite>::iterator it(_messenging_invites.begin());it!=_messenging_invites.end();)
for(std::map<GRouterKeyId,DistantMessengingInvite>::iterator it(_messenging_invites.begin());it!=_messenging_invites.end();)
if(it->second.time_of_validity < now)
{
#ifdef DEBUG_DISTANT_MSG
std::cerr << " Removing outdated invite " << it->second.time_of_validity << ", hash=" << it->first << std::endl;
#endif
std::map<Sha1CheckSum,DistantMessengingInvite>::iterator tmp(it) ;
std::map<GRouterKeyId,DistantMessengingInvite>::iterator tmp(it) ;
++tmp ;
_messenging_invites.erase(it) ;
it = tmp ;
@ -2378,63 +2387,6 @@ static void printBinaryData(void *data,uint32_t size)
}
#endif
void p3MsgService::sendTurtleData(const Sha1CheckSum& hash,RsMsgItem *msgitem)
{
// The item is serialized and turned into a generic turtle item.
uint32_t msg_serialized_rssize = _serialiser->size(msgitem) ;
unsigned char *msg_serialized_data = new unsigned char[msg_serialized_rssize] ;
if(!_serialiser->serialise(msgitem,msg_serialized_data,&msg_serialized_rssize))
{
std::cerr << "(EE) p3MsgService::sendTurtleData(): Serialization error." << std::endl;
delete[] msg_serialized_data ;
return ;
}
RsTurtleGenericDataItem *item = new RsTurtleGenericDataItem ;
item->data_bytes = malloc(msg_serialized_rssize) ;
item->data_size = msg_serialized_rssize ;
memcpy(item->data_bytes,msg_serialized_data,msg_serialized_rssize) ;
delete[] msg_serialized_data ;
#ifdef DEBUG_DISTANT_MSG
printBinaryData(item->data_bytes,item->data_size) ;
std::cerr << std::endl;
#endif
// do we have a working tunnel for that hash ?
// If not, put on the contact's waiting list.
RsPeerId virtual_peer_id ;
{
RsStackMutex stack(mMsgMtx); /********** STACK LOCKED MTX ******/
std::map<Sha1CheckSum,DistantMessengingContact>::const_iterator it = _messenging_contacts.find(hash) ;
if(it == _messenging_contacts.end())
{
std::cerr << "(EE) p3MsgService::sendTurtleData(): Can't find hash " << hash << " in recorded contact list." << std::endl;
delete[] msg_serialized_data ;
return ;
}
if(!it->second.status == RS_DISTANT_MSG_STATUS_TUNNEL_OK)
{
std::cerr << "p3MsgService::sendTurtleData(): tunnel is not ok. Putting items on waiting list." << std::endl;
return ;
}
virtual_peer_id = it->second.virtual_peer_id ;
}
#ifdef DEBUG_DISTANT_MSG
std::cerr << "p3MsgService::sendTurtleData(): Sending through virtual peer: " << virtual_peer_id << std::endl;
std::cerr << " item->data_size = " << item->data_size << std::endl;
std::cerr << " data = " ;
#endif
mTurtle->sendTurtleData(virtual_peer_id,item) ;
}
//void p3MsgService::receiveTurtleData(RsTurtleGenericTunnelItem *gitem,const Sha1CheckSum& hash,
// const RsPeerId& virtual_peer_id,RsTurtleGenericTunnelItem::Direction /*direction*/)
//{
@ -2491,7 +2443,7 @@ void p3MsgService::sendTurtleData(const Sha1CheckSum& hash,RsMsgItem *msgitem)
// }
//}
#ifdef GROUTER
void p3MsgService::sendGRouterData(const Sha1CheckSum& hash,RsMsgItem *msgitem)
void p3MsgService::sendGRouterData(const GRouterKeyId& key_id,RsMsgItem *msgitem)
{
// The item is serialized and turned into a generic turtle item.
@ -2513,7 +2465,7 @@ void p3MsgService::sendGRouterData(const Sha1CheckSum& hash,RsMsgItem *msgitem)
delete[] msg_serialized_data ;
mGRouter->sendData(GRouterKeyId(hash),item) ;
mGRouter->sendData(key_id,item) ;
}
void p3MsgService::receiveGRouterData(RsGRouterGenericDataItem *gitem,const GRouterKeyId& key)
{
@ -2521,28 +2473,18 @@ void p3MsgService::receiveGRouterData(RsGRouterGenericDataItem *gitem,const GRou
}
#endif
bool p3MsgService::locked_findHashForVirtualPeerId(const RsPeerId& vpid,Sha1CheckSum& hash)
{
for(std::map<Sha1CheckSum,DistantMessengingContact>::const_iterator it = _messenging_contacts.begin(); it!=_messenging_contacts.end();++it)
if(it->second.virtual_peer_id == vpid)
{
hash = it->first ;
return true ;
}
return false ;
}
void p3MsgService::sendPrivateMsgItem(const Sha1CheckSum& hash,RsMsgItem *msgitem)
void p3MsgService::sendPrivateMsgItem(RsMsgItem *msgitem)
{
#ifdef DEBUG_DISTANT_MSG
std::cerr << "p3MsgService::sendDistanteMsgItem(): sending distant msg item to peer " << msgitem->PeerId() << std::endl;
#endif
{
GRouterKeyId key_id(msgitem->PeerId()) ;
{
RsStackMutex stack(mMsgMtx); /********** STACK LOCKED MTX ******/
// allocate a new contact. If it does not exist, set its tunnel state to DN
//
std::map<Sha1CheckSum,DistantMessengingContact>::iterator it = _messenging_contacts.find(hash) ;
std::map<GRouterKeyId,DistantMessengingContact>::iterator it = _messenging_contacts.find(key_id) ;
if(it == _messenging_contacts.end())
{
@ -2550,12 +2492,6 @@ void p3MsgService::sendPrivateMsgItem(const Sha1CheckSum& hash,RsMsgItem *msgite
return ;
}
if(it->second.status != RS_DISTANT_MSG_STATUS_TUNNEL_OK)
{
std::cerr << "(WW) p3MsgService::sendPrivateMsgItem(): WARNING: no tunnel for message to send. This should not happen. " << std::endl;
return ;
}
if(!it->second.pending_messages)
std::cerr << "(WW) p3MsgService::sendPrivateMsgItem(): WARNING: no pending message flag. This should not happen. " << std::endl;
}
@ -2564,9 +2500,7 @@ void p3MsgService::sendPrivateMsgItem(const Sha1CheckSum& hash,RsMsgItem *msgite
std::cerr << " Flushing msg " << msgitem->msgId << " for peer id " << msgitem->PeerId() << std::endl;
#endif
#ifdef GROUTER
sendGRouterData(hash,msgitem) ;
#else
sendTurtleData(hash,msgitem) ;
sendGRouterData(key_id,msgitem) ;
#endif
}

View file

@ -43,17 +43,17 @@
#include "serialiser/rsmsgitems.h"
#include "util/rsthreads.h"
#ifdef GROUTER
#include "retroshare/rsgxsifacetypes.h"
#include "grouter/p3grouter.h"
#include "grouter/grouterclientservice.h"
#endif
#include "turtle/p3turtle.h"
#include "turtle/turtleclientservice.h"
class p3LinkMgr;
// Temp tweak to test grouter
class p3MsgService: public p3Service, public p3Config, public pqiMonitor, public RsTurtleClientService
class p3MsgService: public p3Service, public p3Config, public pqiMonitor
#ifdef GROUTER
, public GRouterClientService
#endif
@ -114,8 +114,6 @@ int checkOutgoingMessages();
#ifdef GROUTER
virtual void connectToGlobalRouter(p3GRouter *) ;
#endif
virtual void connectToTurtleRouter(p3turtle *) ;
struct DistantMessengingInvite
{
time_t time_of_validity ;
@ -132,46 +130,38 @@ int checkOutgoingMessages();
void enableDistantMessaging(bool b) ;
bool distantMessagingEnabled() ;
bool getDistantMessagePeerId(const RsPgpId& pgp_id,DistantMsgPeerId &peer_id) ;
bool getDistantMessagePeerId(const RsGxsId &gxs_id,DistantMsgPeerId &peer_id) ;
private:
bool getDistantMessageHash(const RsPgpId& pgp_id,Sha1CheckSum &hash) ;
void sendPrivateMsgItem(const Sha1CheckSum& hash,RsMsgItem *) ;
void sendPrivateMsgItem(RsMsgItem *msgitem) ;
// This maps contains the current invitations to respond to.
// The map is indexed by the hash
std::map<Sha1CheckSum,DistantMessengingInvite> _messenging_invites ;
std::map<GRouterKeyId,DistantMessengingInvite> _messenging_invites ;
// This contains the ongoing tunnel handling contacts.
// The map is indexed by the hash
std::map<Sha1CheckSum,DistantMessengingContact> _messenging_contacts ;
std::map<GRouterKeyId,DistantMessengingContact> _messenging_contacts ;
// Overloaded from RsTurtleClientService
#ifdef GROUTER
virtual void receiveGRouterData(RsGRouterGenericDataItem *item, const GRouterKeyId& key) ;
#endif
virtual bool handleTunnelRequest(const Sha1CheckSum& hash,const RsPeerId& peer_id) ;
// virtual void receiveTurtleData(RsTurtleGenericTunnelItem *item,const Sha1CheckSum& hash,const RsPeerId& virtual_peer_id,RsTurtleGenericTunnelItem::Direction direction) ;
void addVirtualPeer(const TurtleFileHash&, const TurtleVirtualPeerId&,RsTurtleGenericTunnelItem::Direction dir) {}
void removeVirtualPeer(const TurtleFileHash&, const TurtleVirtualPeerId&) {}
// Utility functions
bool encryptMessage(const RsPgpId& pgp_id,RsMsgItem *msg) ;
bool createDistantMessage(const RsGxsId& destination_gxs_id,const RsGxsId& source_gxs_id,RsMsgItem *msg) ;
bool locked_findHashForVirtualPeerId(const RsPeerId& pid,Sha1CheckSum& hash) ;
void manageDistantPeers() ;
void sendTurtleData(const Sha1CheckSum& hash,RsMsgItem *) ;
#ifdef GROUTER
void sendGRouterData(const Sha1CheckSum& hash,RsMsgItem *) ;
void sendGRouterData(const GRouterKeyId &key_id,RsMsgItem *) ;
#endif
void handleIncomingItem(RsMsgItem *) ;
#ifdef GROUTER
p3GRouter *mGRouter ;
#endif
p3turtle *mTurtle ;
uint32_t getNewUniqueMsgId();
int sendMessage(RsMsgItem *item);

View file

@ -221,7 +221,7 @@ void NetworkDialog::connectTreeWidgetCostumPopupMenu( QPoint /*point*/ )
contextMnu->addAction(QIcon(IMAGE_EXPORT), tr("Export my certificate..."), this, SLOT(on_actionExportKey_activated()));
contextMnu->addAction(QIcon(IMAGE_PEERDETAILS), tr("Peer details..."), this, SLOT(peerdetails()));
contextMnu->addAction(QIcon(IMAGE_MESSAGE), tr("Send Message"), this, SLOT(sendDistantMessage()));
//contextMnu->addAction(QIcon(IMAGE_MESSAGE), tr("Send Message"), this, SLOT(sendDistantMessage()));
contextMnu->addAction(QIcon(IMAGE_COPYLINK), tr("Copy RetroShare Link"), this, SLOT(copyLink()));
contextMnu->addSeparator() ;
contextMnu->addAction(QIcon(IMAGE_CLEAN_UNUSED), tr("Remove unused keys..."), this, SLOT(removeUnusedKeys()));
@ -352,30 +352,30 @@ void NetworkDialog::copyLink()
RSLinkClipboard::copyLinks(urls);
}
void NetworkDialog::sendDistantMessage()
{
QTreeWidgetItem *wi = getCurrentNeighbour();
if (wi == NULL) {
return;
}
MessageComposer *nMsgDialog = MessageComposer::newMsg();
if (nMsgDialog == NULL) {
return;
}
DistantMsgPeerId pid ;
RsPgpId mGpgId(wi->text(COLUMN_PEERID).toStdString()) ;
if(rsMsgs->getDistantMessagePeerId(mGpgId,pid))
{
nMsgDialog->addRecipient(MessageComposer::TO, pid, mGpgId);
nMsgDialog->show();
nMsgDialog->activateWindow();
}
/* window will destroy itself! */
}
//void NetworkDialog::sendDistantMessage()
//{
// QTreeWidgetItem *wi = getCurrentNeighbour();
// if (wi == NULL) {
// return;
// }
//
// MessageComposer *nMsgDialog = MessageComposer::newMsg();
// if (nMsgDialog == NULL) {
// return;
// }
//
// DistantMsgPeerId pid ;
// RsPgpId mGpgId(wi->text(COLUMN_PEERID).toStdString()) ;
//
// if(rsMsgs->getDistantMessagePeerId(mGpgId,pid))
// {
// nMsgDialog->addRecipient(MessageComposer::TO, pid, mGpgId);
// nMsgDialog->show();
// nMsgDialog->activateWindow();
// }
//
// /* window will destroy itself! */
//}
void NetworkDialog::updateDisplay()
{

View file

@ -72,7 +72,7 @@ private slots:
// void deleteCert() ;
void peerdetails();
void copyLink();
void sendDistantMessage();
// void sendDistantMessage();
/** Create the context popup menu and it's submenus */
void connectTreeWidgetCostumPopupMenu( QPoint point );
//void unvalidGPGKeyWidgetCostumPopupMenu( QPoint point );

View file

@ -1513,8 +1513,9 @@ static void processList(const QStringList &list, const QString &textSingular, co
}
msg->show();
messageStarted.append(PeerDefs::nameWithLocation(detail));
}
else if(rsMsgs->getDistantMessagePeerId(detail.gpg_id,dm_pid))
}
#ifdef SUSPENDED
else if(rsMsgs->getDistantMessagePeerId(detail.gpg_id,dm_pid))
{
MessageComposer *msg = MessageComposer::newMsg();
msg->addRecipient(MessageComposer::TO, dm_pid,detail.gpg_id) ;
@ -1525,7 +1526,8 @@ static void processList(const QStringList &list, const QString &textSingular, co
msg->show();
messageStarted.append(PeerDefs::nameWithLocation(detail));
}
}
#endif
else
{
messageReceipientNotAccepted.append(PeerDefs::nameWithLocation(detail));

View file

@ -46,6 +46,27 @@ std::list<RsPeerId> FriendSelectionDialog::selectFriends_SSL(QWidget *parent,con
return sids ;
}
std::list<RsGxsId> FriendSelectionDialog::selectFriends_GXS(QWidget *parent,const QString& caption,const QString& header_text,
FriendSelectionWidget::Modus modus,
FriendSelectionWidget::ShowTypes show_type,
const std::list<RsGxsId>& pre_selected_ids)
{
std::list<std::string> psids ;
for(std::list<RsGxsId>::const_iterator it(pre_selected_ids.begin());it!=pre_selected_ids.end();++it)
psids.push_back( (*it).toStdString() ) ;
FriendSelectionDialog dialog(parent,header_text,modus,show_type,FriendSelectionWidget::IDTYPE_SSL,psids) ;
dialog.setWindowTitle(caption) ;
if(QDialog::Rejected == dialog.exec())
return std::list<RsGxsId>() ;
std::list<RsGxsId> sids ;
dialog.friends_widget->selectedIds<RsGxsId,FriendSelectionWidget::IDTYPE_GXS>(sids,false) ;
return sids ;
}
FriendSelectionDialog::FriendSelectionDialog(QWidget *parent,const QString& header_text,
FriendSelectionWidget::Modus modus,
FriendSelectionWidget::ShowTypes show_type,

View file

@ -2,6 +2,7 @@
#include <QDialog>
#include <retroshare/rstypes.h>
#include <retroshare/rsidentity.h>
#include <gui/common/FriendSelectionWidget.h>
class FriendSelectionDialog : public QDialog
@ -9,13 +10,19 @@ class FriendSelectionDialog : public QDialog
public:
static std::list<RsPgpId> selectFriends_PGP(QWidget *parent,const QString& caption,const QString& header_string,
FriendSelectionWidget::Modus modus = FriendSelectionWidget::MODUS_MULTI,
FriendSelectionWidget::ShowTypes = FriendSelectionWidget::SHOW_GROUP | FriendSelectionWidget::SHOW_SSL,
FriendSelectionWidget::ShowTypes = FriendSelectionWidget::SHOW_GROUP,
const std::list<RsPgpId>& pre_selected_ids = std::list<RsPgpId>()) ;
static std::list<RsPeerId> selectFriends_SSL(QWidget *parent,const QString& caption,const QString& header_string,
FriendSelectionWidget::Modus modus = FriendSelectionWidget::MODUS_MULTI,
FriendSelectionWidget::ShowTypes = FriendSelectionWidget::SHOW_GROUP | FriendSelectionWidget::SHOW_SSL,
const std::list<RsPeerId>& pre_selected_ids = std::list<RsPeerId>()) ;
static std::list<RsGxsId> selectFriends_GXS(QWidget *parent,const QString& caption,const QString& header_string,
FriendSelectionWidget::Modus modus = FriendSelectionWidget::MODUS_MULTI,
FriendSelectionWidget::ShowTypes = FriendSelectionWidget::SHOW_GROUP | FriendSelectionWidget::SHOW_GXS,
const std::list<RsGxsId>& pre_selected_ids = std::list<RsGxsId>()) ;
private:
virtual ~FriendSelectionDialog() ;
FriendSelectionDialog(QWidget *parent,const QString& header_string,FriendSelectionWidget::Modus modus,FriendSelectionWidget::ShowTypes show_type,

View file

@ -248,6 +248,10 @@ void FriendSelectionWidget::secured_fillList()
selectedIds<RsPgpId,IDTYPE_GPG>(gpgIdsSelected,true);
}
std::list<RsGxsId> gxsIdsSelected;
if (mShowTypes & SHOW_GXS)
selectedIds<RsGxsId,IDTYPE_GXS>(gxsIdsSelected,true);
// remove old items
ui->friendList->clear();
@ -271,6 +275,12 @@ void FriendSelectionWidget::secured_fillList()
rsPeers->getFriendList(sslIds);
}
std::list<RsGxsId> gxsIds ;
std::list<RsGxsId>::iterator gxsIt ;
if(mShowTypes & SHOW_GXS)
rsIdentity->getOwnIds(gxsIds) ; // should get all ids, not just own. What's the correct call??
std::list<StatusInfo> statusInfo;
std::list<StatusInfo>::iterator statusIt;
rsStatus->getStatusList(statusInfo);
@ -282,9 +292,11 @@ void FriendSelectionWidget::secured_fillList()
while (true) {
QTreeWidgetItem *groupItem = NULL;
QTreeWidgetItem *gpgItem = NULL;
RsGroupInfo *groupInfo = NULL;
QTreeWidgetItem *gxsItem = NULL;
RsGroupInfo *groupInfo = NULL;
if ((mShowTypes & SHOW_GROUP) && groupIt != groupInfoList.end()) {
if ((mShowTypes & SHOW_GROUP) && groupIt != groupInfoList.end())
{
groupInfo = &(*groupIt);
if (groupInfo->peerIds.size() == 0) {
@ -323,7 +335,8 @@ void FriendSelectionWidget::secured_fillList()
}
}
if (mShowTypes & (SHOW_GPG | SHOW_NON_FRIEND_GPG)) {
if (mShowTypes & (SHOW_GPG | SHOW_NON_FRIEND_GPG))
{
// iterate through gpg ids
for (gpgIt = gpgIds.begin(); gpgIt != gpgIds.end(); gpgIt++) {
if (groupInfo) {
@ -422,7 +435,9 @@ void FriendSelectionWidget::secured_fillList()
setSelected(mListModus, gpgItem, true);
}
}
} else {
}
else
{
// iterate through ssl ids
for (sslIt = sslIds.begin(); sslIt != sslIds.end(); sslIt++) {
RsPeerDetails detail;
@ -470,6 +485,47 @@ void FriendSelectionWidget::secured_fillList()
}
}
if(mShowTypes & SHOW_GXS)
{
// iterate through gpg ids
for (gxsIt = gxsIds.begin(); gxsIt != gxsIds.end(); gxsIt++)
{
// we fill the not assigned gpg ids
if (std::find(filledIds.begin(), filledIds.end(), (*gxsIt).toStdString()) != filledIds.end())
continue;
// add equal too, its no problem
filledIds.push_back((*gxsIt).toStdString());
RsIdentityDetails detail;
if (!rsIdentity->getIdDetails(*gxsIt, detail))
continue; /* BAD */
// make a widget per friend
gxsItem = new RSTreeWidgetItem(mCompareRole, IDTYPE_GXS);
QString name = QString::fromUtf8(detail.mNickname.c_str());
gxsItem->setText(COLUMN_NAME, name + " ("+QString::fromStdString( (*gxsIt).toStdString() )+")");
gxsItem->setTextColor(COLUMN_NAME, textColorOnline());
gxsItem->setFlags(Qt::ItemIsUserCheckable | gxsItem->flags());
gxsItem->setIcon(COLUMN_NAME, QIcon(StatusDefs::imageUser(RS_STATUS_ONLINE)));
gxsItem->setData(COLUMN_DATA, ROLE_ID, QString::fromStdString(detail.mId.toStdString()));
gxsItem->setData(COLUMN_DATA, ROLE_SORT, "2 " + name);
if (mListModus == MODUS_CHECK)
gxsItem->setCheckState(0, Qt::Unchecked);
ui->friendList->addTopLevelItem(gxsItem);
gxsItem->setExpanded(true);
emit itemAdded(IDTYPE_GXS, QString::fromStdString(detail.mId.toStdString()), gxsItem);
if (std::find(gxsIdsSelected.begin(), gxsIdsSelected.end(), detail.mId) != gxsIdsSelected.end())
setSelected(mListModus, gxsItem, true);
}
}
if (groupIt != groupInfoList.end()) {
groupIt++;
} else {
@ -657,7 +713,8 @@ void FriendSelectionWidget::itemChanged(QTreeWidgetItem *item, int column)
}
break;
case IDTYPE_GPG:
{
case IDTYPE_GXS:
{
if (mInGpgItemChanged) {
break;
}
@ -790,7 +847,9 @@ void FriendSelectionWidget::selectedIds(IdType idType, std::list<std::string> &i
}
break;
case IDTYPE_GPG:
if (idType == IDTYPE_GPG) {
case IDTYPE_GXS:
if (idType == IDTYPE_GPG || idType == IDTYPE_GXS)
{
if (isSelected(mListModus, item)) {
id = idFromItem(item);
} else {
@ -858,7 +917,8 @@ void FriendSelectionWidget::setSelectedIds(IdType idType, const std::list<std::s
case IDTYPE_GROUP:
case IDTYPE_GPG:
case IDTYPE_SSL:
if (idType == itemType) {
case IDTYPE_GXS:
if (idType == itemType) {
if (std::find(ids.begin(), ids.end(), id) != ids.end()) {
setSelected(mListModus, item, true);
break;

View file

@ -45,7 +45,8 @@ public:
IDTYPE_NONE,
IDTYPE_GROUP,
IDTYPE_SSL,
IDTYPE_GPG
IDTYPE_GPG,
IDTYPE_GXS
};
enum Modus
@ -61,6 +62,7 @@ public:
SHOW_GPG = 2,
SHOW_SSL = 4,
SHOW_NON_FRIEND_GPG = 8,
SHOW_GXS =16
};
Q_DECLARE_FLAGS(ShowTypes, ShowType)

View file

@ -22,6 +22,7 @@
#include <QCoreApplication>
#include <retroshare/rspeers.h>
#include <retroshare/rsmsgs.h>
#include <retroshare/rsidentity.h>
#include "PeerDefs.h"
@ -42,6 +43,14 @@ const QString PeerDefs::rsid(const std::string &name, const RsPgpId &id)
return QString::fromUtf8(name.c_str()) + "@" + QString::fromStdString(id.toStdString());
}
const QString PeerDefs::rsid(const std::string &name, const RsGxsId &id)
{
if (name.empty()) {
return qApp->translate("PeerDefs", "Unknown") + "@" + QString::fromStdString(id.toStdString());
}
return QString::fromUtf8(name.c_str()) + "@" + QString::fromStdString(id.toStdString());
}
const QString PeerDefs::rsid(const std::string &name, const RsPeerId &id)
{
if (name.empty()) {
@ -60,32 +69,42 @@ const QString PeerDefs::rsidFromId(const RsPeerId &id, QString *name /* = NULL*/
QString rsid;
std::string peerName = rsPeers->getPeerName(id);
DistantMsgPeerId pid ;
DistantMsgPeerId pid ;
if(!peerName.empty())
{
if(!peerName.empty())
{
rsid = PeerDefs::rsid(peerName, id);
if (name) {
if (name)
*name = QString::fromUtf8(peerName.c_str());
}
}
else if(rsMsgs->getDistantMessagePeerId(rsPeers->getGPGOwnId(),pid) && pid == id)
{
// not a real peer. Try from hash for distant messages
peerName = rsPeers->getGPGName(rsPeers->getGPGOwnId()) ;
rsid = PeerDefs::rsid(peerName, rsPeers->getGPGOwnId());
if(name)
*name = QString::fromUtf8(peerName.c_str());
}
else
{
rsid = PeerDefs::rsid("", id);
if (name)
*name = qApp->translate("PeerDefs", "Unknown");
}
return rsid ;
}
std::list<RsGxsId> gxs_ids ;
rsIdentity->getOwnIds(gxs_ids) ;
for(std::list<RsGxsId>::const_iterator it(gxs_ids.begin());it!=gxs_ids.end();++it)
if(rsMsgs->getDistantMessagePeerId(*it,pid) && RsPeerId(pid) == id)
{
// not a real peer. Try from hash for distant messages
RsIdentityDetails details ;
if(!rsIdentity->getIdDetails(*it,details))
continue ;
peerName = details.mNickname ;
rsid = PeerDefs::rsid(peerName, *it);
if(name)
*name = QString::fromUtf8(peerName.c_str());
}
rsid = PeerDefs::rsid("", id);
if (name)
*name = qApp->translate("PeerDefs", "Unknown");
return rsid;
}

View file

@ -24,6 +24,7 @@
#define _PEERDEFS_H
#include <QString>
#include <retroshare/rsidentity.h>
class RsPeerDetails;
@ -35,6 +36,7 @@ public:
static const QString rsid(const RsPeerDetails &details);
static const QString rsid(const std::string &name, const RsPeerId &id);
static const QString rsid(const std::string &name, const RsPgpId &id);
static const QString rsid(const std::string &name, const RsGxsId &id);
static const QString rsidFromId(const RsPgpId &id, QString *name = NULL);
static const QString rsidFromId(const RsPeerId &id, QString *name = NULL);
static RsPeerId idFromRsid(const QString &rsid, bool check);

View file

@ -375,6 +375,8 @@ void SecurityItem::sendMsg()
std::cerr << std::endl;
#endif
std::cerr << __PRETTY_FUNCTION__ << ": suspended for now." << std::endl;
#ifdef SUSPENDED
MessageComposer *nMsgDialog = MessageComposer::newMsg();
if (nMsgDialog == NULL) {
return;
@ -389,7 +391,8 @@ void SecurityItem::sendMsg()
nMsgDialog->activateWindow();
}
/* window will destroy itself! */
/* window will destroy itself! */
#endif
}
void SecurityItem::openChat()

View file

@ -44,6 +44,7 @@
#include <retroshare/rsmsgs.h>
#include <retroshare/rsstatus.h>
#include <retroshare/rsfiles.h>
#include <retroshare/rsidentity.h>
#include "gui/notifyqt.h"
#include "gui/common/RSTreeWidgetItem.h"
@ -215,7 +216,8 @@ MessageComposer::MessageComposer(QWidget *parent, Qt::WindowFlags flags)
ui.friendSelectionWidget->setModus(FriendSelectionWidget::MODUS_MULTI);
ui.friendSelectionWidget->setShowType(FriendSelectionWidget::SHOW_GROUP
| FriendSelectionWidget::SHOW_SSL
| (ui.onlyTrustedKeys->isChecked()? FriendSelectionWidget::SHOW_NONE : FriendSelectionWidget::SHOW_NON_FRIEND_GPG));
| FriendSelectionWidget::SHOW_GXS);
//| (ui.onlyTrustedKeys->isChecked()? FriendSelectionWidget::SHOW_NONE : FriendSelectionWidget::SHOW_NON_FRIEND_GPG));
//ui.friendSelectionWidget->setShowType(FriendSelectionWidget::SHOW_GROUP | FriendSelectionWidget::SHOW_SSL );
ui.friendSelectionWidget->start();
@ -359,26 +361,27 @@ void MessageComposer::processSettings(bool bLoad)
Settings->endGroup();
}
/*static*/ void MessageComposer::msgDistantPeer(const RsPgpId& pgp_id)
/*static*/ void MessageComposer::msgGxsIdentity(const RsGxsId &id)
{
// std::cerr << "MessageComposer::msgfriend()" << std::endl;
/* create a message */
DistantMsgPeerId pid ;
rsMsgs->getDistantMessagePeerId(pgp_id,pid) ;
MessageComposer *pMsgDialog = MessageComposer::newMsg();
if (pMsgDialog == NULL)
if (pMsgDialog == NULL)
return;
pMsgDialog->addRecipient(TO,pid,pgp_id) ;
DistantMsgPeerId pid ;
rsMsgs->getDistantMessagePeerId(id,pid) ;
pMsgDialog->addRecipient(TO, RsPeerId(pid), false);
pMsgDialog->show();
/* window will destroy itself! */
}
/*static*/ void MessageComposer::msgFriend(const RsPeerId &id, bool group)
{
// std::cerr << "MessageComposer::msgfriend()" << std::endl;
@ -1423,17 +1426,19 @@ void MessageComposer::setRecipientToRow(int row, enumType type, const std::strin
{
RsPeerDetails details;
if(_distant_peers.find(RsPeerId(id)) != _distant_peers.end())
{
if(!rsPeers->getGPGDetails(_distant_peers[RsPeerId(id)], details))
{
std::cerr << "Can't get peer details from " << _distant_peers[RsPeerId(id)] << std::endl;
return ;
}
if(_distant_peers.find(DistantMsgPeerId(id)) != _distant_peers.end())
{
RsIdentityDetails detail;
name = tr("Distant peer (name: %2, PGP key: %1)").arg(QString::fromStdString(_distant_peers[RsPeerId(id)].toStdString())).arg(QString::fromStdString(details.name)) ;
icon = QIcon(StatusDefs::imageUser(RS_STATUS_ONLINE));
}
if(!rsIdentity->getIdDetails(_distant_peers[DistantMsgPeerId(id)], detail))
{
std::cerr << "Can't get peer details from " << _distant_peers[DistantMsgPeerId(id)] << std::endl;
return ;
}
name = tr("Distant peer (name: %2, PGP key: %1)").arg(QString::fromStdString(_distant_peers[DistantMsgPeerId(id)].toStdString())).arg(QString::fromStdString(detail.mNickname)) ;
icon = QIcon(StatusDefs::imageUser(RS_STATUS_ONLINE));
}
else if(rsPeers->getPeerDetails(RsPeerId(id), details) && (!details.isOnlyGPGdetail))
{
name = PeerDefs::nameWithLocation(details);
@ -1580,9 +1585,9 @@ void MessageComposer::editingRecipientFinished()
lineEdit->setText(text);
}
void MessageComposer::addRecipient(enumType type, const DistantMsgPeerId& pid,const RsPgpId& pgp_id)
void MessageComposer::addRecipient(enumType type, const DistantMsgPeerId& pid,const RsGxsId& gxs_id)
{
_distant_peers[pid] = pgp_id ;
_distant_peers[pid] = gxs_id ;
int rowCount = ui.recipientWidget->rowCount();
int row;
@ -2313,22 +2318,23 @@ void MessageComposer::addContact(enumType type)
addRecipient(type, *idIt, false);
}
std::list<RsPgpId> id2 ;
ui.friendSelectionWidget->selectedIds<RsPgpId,FriendSelectionWidget::IDTYPE_GPG>(id2, true);
for (std::list<RsPgpId>::const_iterator idIt = id2.begin(); idIt != id2.end(); idIt++)
{
std::list<RsGxsId> id2 ;
ui.friendSelectionWidget->selectedIds<RsGxsId,FriendSelectionWidget::IDTYPE_GXS>(id2, true);
for (std::list<RsGxsId>::const_iterator idIt = id2.begin(); idIt != id2.end(); idIt++)
{
DistantMsgPeerId pid ;
if(rsMsgs->getDistantMessagePeerId(*idIt,pid))
addRecipient(type, pid, *idIt);
}
}
}
void MessageComposer::toggleShowNonFriend(bool bValue)
{
ui.friendSelectionWidget->setShowType(FriendSelectionWidget::SHOW_GROUP
| FriendSelectionWidget::SHOW_SSL
| (bValue?FriendSelectionWidget::SHOW_NONE : FriendSelectionWidget::SHOW_NON_FRIEND_GPG));
| (bValue?FriendSelectionWidget::SHOW_NONE : FriendSelectionWidget::SHOW_GXS));
Settings->setValueToGroup("MessageComposer", "ShowOnlyTrustedKeys", bValue);
}

View file

@ -51,7 +51,7 @@ public:
static void msgFriend(const RsPeerId &id, bool group);
//static void msgDistantPeer(const std::string& hash,const std::string& pgp_id) ;
static void msgDistantPeer(const RsPgpId& pgp_id) ;
static void msgGxsIdentity(const RsGxsId& gxs_id) ;
static QString recommendMessage();
static void recommendFriend(const std::list <RsPeerId> &sslIds, const RsPeerId &to = RsPeerId(), const QString &msg = "", bool autoSend = false);
@ -69,7 +69,7 @@ public:
void setQuotedMsg(const QString &msg, const QString &header);
void setMsgText(const QString &msg, bool asHtml = false);
void addRecipient(enumType type, const RsPeerId &id, bool group);
void addRecipient(enumType type, const DistantMsgPeerId &pid, const RsPgpId &pgp_id) ;
void addRecipient(enumType type, const DistantMsgPeerId &pid, const RsGxsId &gxs_id) ;
public slots:
/* actions to take.... */
@ -221,7 +221,7 @@ private:
Ui::MessageComposer ui;
std::list<FileInfo> _recList ;
std::map<DistantMsgPeerId,RsPgpId> _distant_peers ; // pairs (hash,pgp_id)
std::map<DistantMsgPeerId,RsGxsId> _distant_peers ; // pairs (hash,gxs_id)
};
#endif

View file

@ -11,7 +11,7 @@ greaterThan(QT_MAJOR_VERSION, 4) {
# Below is for GXS services.
# Should be disabled for releases.
#CONFIG += gxs debug
CONFIG += gxs debug
gxs {
@ -25,7 +25,7 @@ gxs {
CONFIG += gxsgui
# thewire is incomplete - dont enable
#CONFIG += thewire
#CONFIG += photoshare
CONFIG += photoshare
DEFINES += RS_ENABLE_GXS
}